Skip to content

feat(agents): add Kiro CLI as an agent runtime - #250

Merged
artempartos merged 1 commit into
developfrom
feat/kiro-cli-runtime
Sep 11, 2026
Merged

artempartos merged 1 commit into
developfrom
feat/kiro-cli-runtime

Conversation

@artempartos

Copy link
Copy Markdown
Contributor

Adds AWS Kiro CLI as an agent runtime: its own image, adapter, launch and auth commands, and the usual plumbing across the backend constants and the frontend AgentType union. Sessions run on Kiro's current engine (--v3).

Verified end to end against a live account: device-code login → credential captured → model picker populated → session runs on the chosen model → MCP tools available → the agent ends its own session → cost, model and logs recorded.

Four things the docs do not warn about

Each of these was found by measurement, and each is silent when it goes wrong.

The credential is a SQLite database, not a JSON document. It is captured whole and restored byte for byte. Detecting that a login finished takes care: the database exists from the CLI's first run and gains a device-registration row the moment the code is displayed, so "the file exists" would close the auth terminal while the user was still approving in their browser. What appears only on success is the token payload, whose OAuth field names sit in the file's bytes and do not vary with the login method — unlike the row's key, which is named after it (kirocli:odic:token for Builder ID, kirocli:social:token for a social login). The container watcher grows a third mode for that, __contains__:<text>, alongside __present__ and JSON dotted keys.

state device-registration row access_token / refresh_token
fresh container, no login absent absent
device code on screen, not yet approved present absent
login finished present present

V3 drops a plain-HTTP MCP server that is not on loopback, without a word. The rule is in the CLI's own binary (crates/agent/src/agent/mcp/mod.rs): "host must be 127.0.0.1 or localhost, got web". Our MCP endpoint is internal HTTP in every environment — http://web:4002/action_mcp locally, http://mcp.<namespace>.svc.cluster.local:4002/action_mcp in staging and production. The symptom is not an error but an empty tool list, which leaves an automatic session unable to call finish_session and therefore unable to end. The agent container now forwards a loopback port to that service (the watcher's MCP_FORWARD_PORT/MCP_FORWARD_TARGET, inert for every other runtime) and the adapter rewrites the host it writes into mcp.json. An HTTPS or already-loopback URL passes through untouched.

The prompt only arrives in --no-interactive. chat documents a positional first question and every other runtime here is driven that way, but the TUI ignores it on both engines, and neither bracketed paste nor literal keystrokes reach its input. An automatic session launched interactively never receives its task and sits at ready until a watchdog closes it. Interactive sessions keep the TUI — they carry no prompt, so nothing is lost.

Billing is in credits, and the CLI reports its own. Its OpenTelemetry export is redirectable, so it is pointed at the collector Claude Code already reports into: kiro_cli_credits_consumed arrives per turn with the model attached, priced by the account's overage rate, and cost appears while the session is still running. Two coarser fallbacks sit behind it — the usageSummary activity in the MITM log, then the movement of the account's credit counter. Turning the CLI's telemetry off is not an option: measured, it takes the cost figures with it, and silencing it wins no privacy, because redirecting the export is exactly what stops the vendor receiving it.

Also here

  • The model catalogue and the account's credit balance come from Kiro's V3 control plane (management.<region>.kiro.dev). The bearer and the profile ARN live in two different tables of that SQLite database, and the region comes from the profile rather than from the identity centre.
  • BaseAdapter grows collect_credential_metadata, a no-op for every other runtime, so the CLI can be asked for the catalogue its own sessions will accept.
  • The profile's usage card now shows a credit plan as counts rather than a bare percentage — "9,999.25 of 10,000 credits left" — since a percentage of an allowance the user cannot see is not actionable.

Checks

make check_all is green except SchemaParityTest, which fails on develop as well: git diff origin/develop -- db/ is empty and this branch adds no migrations, so both of that test's inputs are byte-identical to develop. The cause is a Postgres version difference in how one CHECK constraint is rendered (ARRAY[…]::text[] vs ARRAY['…'::character varying::text, …]), not anything in this change.

Research and as-built notes: docs/planning-artifacts/research/technical-kiro-cli-as-a-platform-agent-runtime-research-2026-08-28.md, whose Appendix A is a runtime-agnostic playbook for adding the next one.

🤖 Generated with Claude Code

Kiro CLI joins the runtime menu: its own image, adapter, launch and auth
commands, and the usual runtime plumbing across the backend constants and the
frontend `AgentType` union. Sessions run on Kiro's current engine (`--v3`).

Four things needed measuring rather than reading, because the CLI is silent
about each of them.

**The credential is a SQLite database**, not a JSON document, so the adapter
captures the file whole and restores it byte for byte. Detecting that a login
finished needs care: the database exists from the CLI's first run and gains a
device-registration row the moment the code is displayed, so "the file exists"
would close the auth terminal while the user was still approving in a browser.
What appears only on success is the token payload, whose OAuth field names sit
in the file's bytes and do not vary with the login method — unlike the row's
key, which is named after it. The watcher grows a third mode for that,
`__contains__:<text>`, alongside `__present__` and JSON dotted keys.

**An MCP server on internal HTTP is dropped without a word.** V3 accepts a
plain-HTTP MCP server only on a loopback host ("host must be 127.0.0.1 or
localhost, got `web`", from the CLI's own source); ours is
`http://web:4002/action_mcp` locally and a cluster address in production. The
symptom is not an error but an empty tool list, which leaves an automatic
session unable to call `finish_session` and therefore unable to end. The agent
container now forwards a loopback port to that service — inert for every other
runtime — and the adapter rewrites the host it writes into mcp.json. An HTTPS
or already-loopback URL passes through untouched.

**The prompt only arrives in `--no-interactive`.** `chat` documents a
positional first question and every other runtime here is driven that way, but
the TUI ignores it on both engines, and neither bracketed paste nor literal
keystrokes reach its input. An automatic session launched interactively never
receives its task. Interactive sessions keep the TUI; they carry no prompt.

**Billing is in credits, and the CLI reports its own.** Its OpenTelemetry
export is redirectable, so it is pointed at the collector Claude Code already
reports into: `kiro_cli_credits_consumed` arrives per turn with the model
attached, priced by the account's overage rate. Two coarser fallbacks stay
behind it — the `usageSummary` activity in the MITM log, then the movement of
the account's credit counter. Turning the CLI's telemetry off is not an option:
measured, it takes the cost figures with it, and silencing it wins no privacy
because redirecting the export is what stops the vendor receiving it.

The model catalogue and the account's credit balance come from Kiro's V3
control plane (`management.<region>.kiro.dev`), whose bearer and profile ARN
live in two different tables of that SQLite database. `BaseAdapter` grows
`collect_credential_metadata`, a no-op for every other runtime, so the CLI can
be asked for the catalogue it will actually accept.

Research and as-built notes:
docs/planning-artifacts/research/technical-kiro-cli-as-a-platform-agent-runtime-research-2026-08-28.md

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Artem Petrov <[email protected]>
@artempartos
artempartos merged commit 652a187 into develop Sep 11, 2026
7 checks passed
artempartos pushed a commit that referenced this pull request Nov 11, 2026
Figtree and Hanken Grotesk give way to one Inter variable font from Google
Fonts, loaded through a shared partial with a metric-matched Arial fallback so
the swap does not shift the layout. Hardcoded monospace stacks now read the
--app-font-mono token. Emails hide the font link from Outlook for Windows,
which otherwise drops the whole stack for Times New Roman.

Refs task #250

Signed-off-by: Dmitry Vislov <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant