Repository navigation
Description
Problem
When a seat is connected through the Connect page (or an approved connect_local_agent card) and started with the page's lines, the installation is config.runtime.runtimeType: 'webhook'. Then commonly agent run <name> picks the adapter (claude / codex / pi / opencode / qwen) on the user's machine and stores it only in the local token file. The CLI says so itself (cli/src/commands/agent.js, bootstrapAgentRecordFromEnv): "The adapter names a binary on THIS machine — the one fact the server cannot know."
So the server can't tell which CLI a page-connected seat runs. Measured read-only on production: the installation has no adapter, the bot's botMetadata has none, and the agent's messages carry none. Everything that reads the resolved adapter sees null for these seats:
adapterForRuntimeBinding()(backend/services/grantBrokerConfinement.ts), which the grant-broker check uses. A seat that names no adapter is judged as daemon-decided (the claude/codex union).runtimeAdapterinGET /api/agents/runtime/installations, which the CLI's ownserverAdapterBindingRefusalreads.- Any per-seat or per-team count of which CLIs connected seats run, for support and usage analytics.
The daemon path already fills this field: commonly agent config <name> --adapter <x> PATCHes config.runtime.adapter (updateAgentConfiguration → PATCH /api/registry/pods/:podId/agents/:name), and daemon-supervisor.js reads it. Only the Connect-page / env-token path leaves it empty.
Proposal
CLI half (SWE): after bootstrapAgentRecordFromEnv resolves the adapter and passes the binding check, report it to the server once, into the installation's config.runtime.adapter. Do this only on first bootstrap, never on later runs from an existing token file. Make it best-effort: a failed report logs one line and never blocks the run.
Route half (CTO gates): the bootstrap path holds only the runtime token (cm_agent_*), so it can't use the installer-gated PATCH /api/registry/pods/:podId/agents/:name (user auth, installer-or-admin). It needs a narrow runtime-token write. One shape:
agentRuntimeAuth, applying only to installations of the calling agent identity (req.agentUser).- Body
{ podId, instanceId, adapter }.adaptermust be a known adapter name, normalized like the daemon does (trim + lowercase). - Write-once: a conditional update on
config.runtime.adapterbeing absent, and only whenruntimeTypeis a runtime kind that names no adapter (webhook). Otherwise return 409 with no change.
Why the route half needs a gate
config.runtime.adapter is not informational today:
daemon-supervisor.jsreadsrow.runtime.adapterto choose which CLI it launches for a daemon-managed seat.grantBrokerConfinement.tsuses it to decideadapter_cannot_confineand which sandbox modes count as enforceable.- Once it's set,
serverAdapterBindingRefusalrefuses a later bootstrap with a different CLI. Switching from claude to codex then needsagent config --adapter(the installer) instead of a freshagent run --adapter.
That's why the existing writer is installer-only: config reaches the owner's machine. Write-once plus webhook-only keeps the seat from changing an adapter someone else set, but the reviewer should decide:
- (a) whether a seat may set it even once, or
- (b) whether a separate report-only field that no spawner or policy reads (e.g.
config.runtime.reportedAdapter) is the better place.
Either one closes the gap for the readers that only want to know which CLI is running.
Acceptance
- Page lines →
commonly agent run x(claude detected) → installation showsconfig.runtime.adapter: 'claude', or the chosen field, andruntimeAdapterprojects it. - A second
agent runfrom the saved token file makes no write. - The route refuses: another agent's installation (403/404), an unknown adapter (400), and an installation that already names an adapter (409, unchanged).
- Unit tests for the route (write-once, ownership, allowlist) and for the CLI bootstrap (reports once, a failed report doesn't block the run).
Activity