Add ACP replay harness and session lifecycle support

- Add replay agent and fixture-driven ACP transcript testing
- Support session lifecycle, auth methods, and session resume/fork flows
- Expand orchestration V2 adapter coverage and debug tooling
This commit is contained in:
Julius Marminge committed 2026-06-18 20:55:08 -07:00
1 parent 9d38de8628
commit 1161529645
65 files changed
+9914 -74

No files matched your search

@@ -90,9 +90,40 @@ Cursor receives the same authenticated HTTP MCP endpoint through the SDK's
`mcpServers` agent and send options. The adapter passes the authorization header
to the SDK but projects only redacted option metadata into protocol diagnostics.
### Grok ACP V2
Grok receives the authenticated HTTP MCP endpoint through the ACP
`session/new`, `session/load`, and `session/fork` `mcpServers` field. The shared
ACP adapter owns standard protocol behavior; the Grok flavor adds xAI extension
requests such as structured user questions.
ACP does not define native subagents or active steering. Grok therefore uses
orchestrator-owned child threads and implements steering through
cancel-and-restart. Its current driver also lacks `session/fork`, so app forks
use portable context transfer. These are orchestrator policies, not
provider-specific MCP tools.
### ACP Registry V2
The `acpRegistry` driver is the generic flavor of the same shared ACP adapter.
Each provider instance names an agent from the official ACP Registry. At
session startup the driver resolves the current platform distribution, uses a
managed binary cache or the declared `npx`/`uvx` package, and then negotiates
standard ACP capabilities during `initialize`. A local executable may override
the managed command without changing the registry-declared arguments or
environment.
Capabilities such as session loading, session forking, models, modes, and MCP
transport are enabled only when the selected agent advertises them. Missing
features degrade through V2 policy: steering uses interrupt-and-restart,
forking uses portable context when native `session/fork` is unavailable, and
subagents use orchestrator-owned child threads. Registry agents do not receive
provider-specific extensions; those remain in flavors such as Grok.
### Initial Provider Support
The V2 provider adapters are Codex, Claude Agent SDK, and Cursor Agent SDK.
The V2 provider adapters are Codex, Claude Agent SDK, Cursor Agent SDK, and
Grok plus generic registry agents over ACP.
Capability discovery still reports other registered provider instances, but marks them
unavailable for orchestration when no V2 adapter exists. This keeps provider
selection model-visible without allowing a request that cannot run.
@@ -299,6 +330,6 @@ Coverage includes:
- inheritance and per-thread provider overrides; and
- idempotent retries.
Provider adapter tests separately verify Codex, Claude, and Cursor MCP injection, and
the provider-session manager test verifies that credentials exist before an
adapter opens and are revoked when it closes.
Provider adapter tests separately verify Codex, Claude, Cursor, Grok, and ACP
Registry behavior and MCP injection. The provider-session manager test verifies
that credentials exist before an adapter opens and are revoked when it closes.
+20 -1
View File
@@ -122,6 +122,14 @@ Claude replay transcript
Cursor replay transcript
-> Cursor Agent SDK open/send calls and ordered onDelta/run results
-> consumed by CursorAdapter
OpenCode replay transcript
-> OpenCode SDK requests/responses plus ordered SSE events
-> consumed by OpenCodeAdapter
ACP replay transcript
-> logical JSON-RPC requests/responses/notifications over a strict NDJSON peer
-> consumed by AcpAdapter and a provider flavor (Grok or ACP Registry)
```
Fixtures should preserve raw provider evidence as closely as possible. Expected V2 events or projections are assertions, not fixture input.
@@ -131,6 +139,17 @@ call. A transcript should include the `query` prompt/options we sent and then re
`SDKMessage` chunks in provider order. This intentionally tests the V2 adapter against real Claude
SDK output; it does not test the SDK's own subprocess or transport parser.
ACP fixtures run against a child-process replay peer that validates every outbound frame and
serves recorded inbound frames. This replaces only the external ACP driver transport; the shared
runtime, adapter normalization, orchestration, persistence, and projections remain production code.
The generic ACP Registry harness retargets protocol-standard ACP transcripts;
provider-extension transcripts remain scoped to the flavor that owns the extension.
OpenCode fixtures replace the SDK client at its HTTP/SSE boundary. They must preserve races between
request responses and SSE events, because user messages and terminal `session.status` events can
arrive before the corresponding `promptAsync` or `abort` response. Subagent fixtures must retain
both parent and child session ids so root-only terminal behavior remains testable.
Provider transcript recorders live with the server orchestration testkit, not with provider client
packages. Use `bun run record:codex-replay -- --scenario <name>` for Codex app-server transcripts
and `bun run record:claude-replay -- --scenario <name>` for Claude Agent SDK transcripts. Use
@@ -206,7 +225,7 @@ Testing infrastructure should be built before production rewrites:
2. Effect service definitions.
3. provider runtime transport abstraction.
4. generic replay runtime.
5. Codex, Claude, and Cursor transcript loaders for app-owned provider replay fixtures.
5. Codex, Claude, Cursor, OpenCode, and ACP transcript loaders for app-owned provider replay fixtures.
6. projection reducer tests for core invariants.
7. full command-to-projection integration tests.
8. production layers.