| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
Overall: impressive scope for a draft-protocol integration — the boundary-cast strategy is documented at every cast site, the v2 prompt lifecycle (async admit + state_update driving) is a sensible mapping onto opencode's model, and the test coverage (event-v2, service-session, e2e v2-prompt) is substantial. Concerns, roughly in priority order:
Minor: resumeSession drops the limit: 20 whenever replayFrom is present, making an unbounded messages fetch per resume — fine for now, worth a cap later; v2 prompts emit state_update running immediately and via onBusy on the first busy event (duplicate notifications); v2DiffContent guards only path but assumes oldText/newText are strings; and the "======" line filter is safe only because unified-diff body lines carry /+/- prefixes — a comment would prevent future breakage. Nice work overall. |
Sorry, something went wrong.
|
Thanks for the review — all concerns addressed in the latest commits.
Minor items:
|
Sorry, something went wrong.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
Implements the ACP v2 draft prompt lifecycle behind
OPENCODE_EXPERIMENTAL_ACP_V2, gated by protocolVersion negotiation.
v1 peers are unaffected.
- session/prompt returns {} on acceptance (via prompt_async) instead of
blocking for the whole turn; a second prompt admitted mid-turn steers
by default at the next safe boundary
- emit v2 session/update notifications: user_message ack on acceptance,
state_update running on busy, state_update idle with stopReason on
turn completion (derived from the latest assistant message)
- session/cancel still routes through the existing abort path; the
cancelled stopReason is derived from MessageAbortedError at idle
- initialize negotiates protocolVersion 2 when the flag is on and the
client requests v2; otherwise falls back to v1
- v2 state_update/user_message variants are cast at the wire boundary
since SDK 0.21 ships only v1 SessionUpdate types
https://agentclientprotocol.com/announcements/acp-v2-draft
…update, and plan_update - Add AgentProtocolRouter for per-connection v1/v2 selection - Implement v2 app builder (agent-v2.ts) with wrapClient - Implement structured diffs (changes array + git_patch format) - Implement terminal_update for bash/shell tools with exitStatus - Implement plan_update for todo.updated events in v2 mode - Implement replayFrom on session/resume - Implement v2 permission request structure (title, subject union) - Implement configId naming in v2 config options - Implement auth/login + auth/logout routing - Implement tool_call_update for creation in v2 mode - Implement user_message acknowledgment emission - Implement slash command input type:text discriminator - Add v2 ndJsonStream with JSON-RPC batch support - Upgrade @agentclientprotocol/sdk from 0.21.0 to 1.3.0 - Add 12 new v2 tests covering all implemented features
…ity, and _meta passthrough - Emit requires_action state_update before permission requests, running after resolution - Preserve _meta on resource_link and text content chunks output - Render unknown content block types as text fallback when _meta is present - Pass through _meta from incoming resource_link blocks as metadata on text parts - Add _meta field to ReplayPart types for metadata propagation - Add 8 new tests: requires_action before/after permission, v2 permission structure, _meta on resource_link/text chunks, unknown block fallback, _meta preservation
… SetSessionModeRequest SDK 1.3.0 removed the unstable SetSessionModelRequest type (which carried modelId for LLM model selection). The previous workaround retyped setSessionModel to use SetSessionModeRequest, but that type carries modeId (session mode like 'build'), not modelId (LLM model like 'anthropic/claude-3.5-sonnet'). Define a local type to preserve the correct semantics.
- Fix exitStatus reading input.exitCode (never populated) instead of part.state.metadata.exit (where opencode records exit codes) - Remove unused toolCall variable in toolStart, deduplicate pendingToolCall call - Filter undefined mcpConfig results (acp type) before passing to sdk.mcp.add - Deduplicate state_update running: track v2Running set so onBusy doesn't emit a second running after the eager emission on prompt acceptance - Guard v2DiffContent against non-string oldText/newText - Add comment explaining the ======= line filter safety in v2DiffContent - Document single-connection constraint on v2Active (ACP stdio is 1:1) - Add TODO for unbounded messages fetch in resumeSession replay
Replace unbounded messages fetch with paginated retrieval using the session.messages cursor (50 per page). Non-replay resumes keep the existing limit:20 behavior.
| Back | FazBrowse Home | New Git URL |
Issue for this PR
Closes #44877
This is a WIP implementation of the ACP v2 draft spec per the migration guide.
Type of change
What does this PR do?
Implements ACP v2 draft support behind OPENCODE_EXPERIMENTAL_ACP_V2, gated by protocolVersion negotiation. v1 peers are unaffected — the agent answers protocolVersion: 1 unless the flag is on AND the client requests v2.
Upgrades @agentclientprotocol/sdk from 0.21.0 → 1.3.0. Uses the SDK v2 experimental builder (@agentclientprotocol/sdk/experimental/v2) for v2 connections and the v1 builder for v1 connections, with AgentProtocolRouter selecting per-connection based on initialize protocolVersion.
Architecture: AgentProtocolRouter (agent.ts) selects v1 or v2 per-connection. v1 uses createV1App() (v1 AgentApp builder). v2 uses createV2App() (agent-v2.ts, v2 AgentApp builder). Both share ACPService.make() core logic. v2 ndJsonStream from the SDK accepts both individual and batch JSON-RPC messages. ACP over stdio is inherently single-connection-per-process — v2Active is connection-scoped in practice (see comment in service.ts).
All items from the v2 migration checklist are implemented:
SDK 1.3.0 breaking changes addressed:
How did you verify your code works?
Automated tests:
New v2 unit tests:
v1 backward compatibility is verified by the existing CLI test suite (lifecycle, prompt-content, config-options, skills, initialize-auth) which all use protocolVersion: 1 and exercise the full v1 wire path against SDK 1.3.0.
Manual end-to-end testing:
A standalone test client is available on the acp-v2-test-client branch of the fork. It uses the SDK's built-in ClientApp from @agentclientprotocol/sdk/experimental/v2 to spawn an opencode ACP process, negotiate v2, create a session, send prompts, and stream all session/update notifications.
Scenario test results (using opencode/big-pickle):
Screenshots / recordings
N/A — no UI changes.
Checklist