feat(cli)!: drive cloud sessions through installed plugin packages
Summary
A cloud session names the installed npm package that drives it; a new provider needs no core edits. Decision: ADR 0042, cross-linked from 0034 and 0041.
type CloudAttach =
| { kind: 'agent-device-daemon'; daemonBaseUrl: string; daemonAuthToken: string; leasing?: 'proxy-front' }
| { kind: 'plugin'; plugin: string; token: string; expiresAt: string; proxyPath?: string; data: Record<string, Json> }
// accepts: ['agent-device-daemon', { kind: 'plugin', plugin: '<package>' }, ...]
// renew: GET /v1/sessions/<id>?attach=1
- Core validates the envelope, saves it privately with a revision, and passes
AttachmentInputtohostedAttachment.inspect/bind. - Renewal runs in
connectbehind a fence: it stops the generation's daemon first and lifts only after readiness passes on the new revision. - Renewal must keep the plugin's assignment identity. An unconfirmed release keeps its record and blocks a new booking on that name.
- New reasons:
cloud_plugin_required,cloud_attachment_token_rejected,cloud_session_ended. - Deleted from core: vendor catalog flag, plugin table, credential tables, env builders, vendor reasons. The native route, with proxy-front leasing, is unchanged.
- Limrun and ADC bind from
AttachmentInput.
Depends on the cloud service's new wire format. #5318 rebases onto this as a plugin-only change.
Upgrade: no legacy decoder. Before upgrading, disconnect with the old CLI every plugin-driven session from an earlier 0.22 nightly, and every native session whose saved request offered plugin packages: those lose same-intent reconnect.
Before / after
connect cloud --platform android with a plugin installed:
before: "accepts":["agent-device-daemon","example"]
after: "accepts":["agent-device-daemon",{"kind":"plugin","plugin":"@example/cloud-plugin"}]
Validation
At e6a08e01cf: pnpm check:affected --run --base origin/0.22 passed every runnable check, exactCommit=true (full set). A generic test with an uncatalogued package covers discovery, create, bind, renewal, the readiness fence, expired-revision recovery, assignment change, account mismatch, refusals and disconnect. Migrated Limrun and ADC scenarios pass. CI owns coverage, native and device lanes.
Not covered: two concurrent sessions. Limrun and ADC renew only at expiry.