mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-10-27 04:30:59 +00:00
v0.85.2-preview.9
757 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2b7fab7d98 |
test: run the ACP scenarios on the experimental v2 surface (#1230)
Last part of step 3 of opt-in ACP v2 support (#1222, #1226): the scenario suite now also runs on the v2 surface. It's test-only. ## What `src/tests/acp-scenarios-v2.test.ts` runs all 40 scenarios of the ACP scenario suite the way `serveAcp` serves v2: through the protocol router, driven by the SDK's own v2 client. Per scenario: - `initialize`, then `session/new`, or `session/resume` with `replayFrom` for a transcript; - one `session/prompt` per turn, waiting for the turn's `idle`. The agent's JSON-RPC messages are recorded off the wire, so a message the client would reject is still recorded and checked. Three checks: 1. **Status table.** A scenario passes when every turn ends with a stop reason other than `_error`. Otherwise it records why it stopped: the rejected request's error, or the failed turn's notice. | Status today | Scenarios | |---|---| | passes | 7: `session-setup`, `text-and-thinking`, `goal`, `rate-limit-and-origin`, the three async-task scenarios | | `tool_call` not translated yet (step 4) | 30 | | `plan` not translated yet (step 5) | 2 | | replay not supported yet (step 4) | 1 | Each step that translates more updates must flip its entries to `passes`, so the table is that step's checklist. 2. **Schema.** Every recorded message, including those of scenarios that stop, validates against the SDK's draft v2 JSON schema. The definition is looked up from the method and side the schema itself names (`x-method`/`x-side`). One test checks that the validator rejects a chunk without `messageId`, so the check can't pass vacuously. 3. **Golden files** for the passing scenarios, in `src/tests/acp-scenarios/__snapshots__/v2/`. For example, `text-and-thinking.jsonl` shows the prompt lifecycle from #1226: `user_message`, `running`, the `session/prompt` answer, the chunks with their `messageId`, and `idle end_turn` with usage. `harness.ts` gains `runScenarioV2` next to `runScenario`, sharing the scripted Claude Code, the id normalization and the elicitation answer. `schema.ts` gains `validateV2Message` next to `validateRecorded`. ## Testing - Dropping `messageId` from the v2 chunk translation fails both the schema check and the golden files of the scenarios with chunks. - The v2 file is stable across repeated runs and takes about 1.3 s; the full suite stays at about 4.4 s. `npm run build`, `npm run check`, `npm run test:run` (2293 passed).v0.85.2-preview.9 |
||
|
|
d3e673b263 |
fix: end a held turn cancelled mid-followup at its interrupt's idle (#1229)
Found while reviewing #1226. It affects ACP v1 and v2. ## Problem A turn held open for its background subagents (`Turn.deferredSettle`, issues #864–#866) was settled `cancelled` inside `cancel()`, before the interrupt. The followup cycle can be live at that point, writing the subagents' summary or blocked on a permission request. The interrupt still flushes that cycle's output, so: - **v1:** the output arrives after `session/prompt` has answered `cancelled`, when many clients have stopped listening. - **v2 (#1226):** the output arrives after `idle cancelled`. The v2 draft says updates after a cancel MUST come before it. ## Change `cancel()` now settles inline only where the consumer can't: - **a settling turn,** blocked in its checkpoint preview, which can't process the interrupt's trailing idle (unchanged); - **a held turn whose session sits idle,** or has reported no state yet: the interrupt emits nothing, so no trailing idle comes (unchanged). **A held turn with a live followup** (`running` or `requires_action`) is now left to the consumer, like any live turn. It ends at the interrupt's trailing idle, or at the next prompt's echo if that idle lags, after the output the interrupt flushed. The force-cancel backstop is armed for it meanwhile. Two consequences, both handled: - **The trailing-idle debt:** the interrupted followup's result is autonomous, so it records its trailing idle as owed. When that idle ends the cancelled held turn, it now also pays the debt. Otherwise the debt would absorb a later issue-#825 signal. - **Usage:** a held turn can now be ended by the trailing idle, the echo hand-off, stream end or the backstop, not only by `cancel()`. All of them take the outcome from one rule, `cancelledOutcome`: a turn that already has its result keeps that result's usage and `_meta`, as the inline settle did (issue #844). Today the session's tally equals that recorded outcome anyway, since followup results aren't accumulated. Stream end already treats the stored one as authoritative. ## Testing - **New:** `src/tests/turn-events.test.ts` cancels a held turn mid-followup. The interrupt flushes more of the summary, then the followup's result and idle arrive. It asserts: - the flushed output comes before the turn ends `cancelled`; - a wedged next turn still fails at its un-owed idle (issue #825), so no trailer debt leaked. - **Updated:** the two existing tests that cancel a held turn in a live cycle (running, and blocked on a permission request) expected the prompt to resolve at `cancel()`. Their scripts send the interrupt's trailer only after the next prompt's echo, so the turn now ends at that echo hand-off. They keep their issue #825 assertion, and one now also checks the usage the turn keeps (issue #844). - **Unchanged:** the tests for an idle hold, which settles at `cancel()` without pre-counting a trailer, pass as before. - **Mutations:** settling a live held turn inline again, settling an idle one at an idle that never comes, or skipping the debt payment each fail at least one test. `npm run build`, `npm run check`, `npm run test:run` (2244 passed).v0.85.2-preview.8 |
||
|
|
d83f28a403 |
fix: drop queued prompts a cancel ends from Claude Code's queue (#1228)
Found while reviewing #1226: a prompt that `session/cancel` reports as cancelled still runs in Claude Code. It affects ACP v1 and v2. ## Problem `cancel()` settles every queued prompt as `cancelled`, but each was already pushed to Claude Code. Claude Code keeps queued messages through an interrupt and runs them next. The SDK documents the interrupt receipt's `still_queued` as "messages that WILL still run unless cancelled first". So: - Claude Code answers prompts the client was told were cancelled, and they stay in the conversation, and in the model's context, for later turns. - The orphan accounting skips their results, and a cancelled session drops consolidated `assistant` frames, but their streamed deltas still reach the client after the cancel. - In v2 (#1226), such a prompt is answered `-32800` ("not inserted"), then its output arrives anyway. ## Change `cancel()` now sends `cancel_async_message` for each queued message it abandons, before the interrupt. That covers queued prompts and pending steers. This is the pattern the SDK's own docs describe for a wrapper that wants per-uuid control, rather than `cancel_queued` on the interrupt, which would also sweep a prompt the client sends right after the cancel. - **Before the interrupt**, because once the interrupt stops the running turn, Claude Code starts the next queued message right away. - **Not awaited.** The SDK writes control requests to Claude Code in call order, so the drops still arrive before the interrupt, and a wedged CLI can't hold up the cancel, or the teardown that uses it. - **No new accounting.** A dropped message gets a `cancelled` lifecycle frame and is missing from the interrupt receipt's `still_queued`, and the orphan accounting already handles both. - **Residual window:** a message Claude Code had already dequeued, or one the SDK hadn't written yet, still runs as an orphan, exactly as before. The SDK implements the request as `Query.cancelAsyncMessage` (0.3.287) but doesn't type it, so it's looked up. A mocked query without it skips the drop. A CLI that doesn't know the request rejects it, which is logged. ## Testing A new test in `src/tests/turn-events.test.ts` scripts Claude Code's queue: a queued prompt runs after the interrupt unless it was dropped first, as the real CLI does. It asserts: - the drop goes out before the interrupt; - the queued turn ends `cancelled`; - the cancelled prompt's answer never reaches the client. Without the drop, the test fails with the leaked answer (`chunk Answer to a cancelled prompt` after `first ended cancelled`). Sending the drop after the interrupt also fails it. The rest of the suite passes unchanged. `npm run build`, `npm run check`, `npm run test:run` (2243 passed).v0.85.2-preview.7 |
||
|
|
ba5ed170ae |
refactor: report a turn inserted when Claude Code starts it (#1227)
Part of opt-in ACP v2 support. It fixes the first issue the review of #1226 found in the agent's turn reporting. It's independent of #1226 and changes nothing for ACP v1. ## Problem A turn reported `inserted` (#1222) at activation: the prompt's echo, or for an echo-less command, its result. The echo can come after the turn's first output; the agent already handles deltas that stream before it (see `injectSessionEchoAt` in the tests). With #1226's v2 mapping, that means a v2 client sees: - a turn's output before its `user_message` and before `running`; - `/compact`'s `session/prompt` answered only after the whole command. ## Change On CLIs that report command lifecycles (`msg_lifecycle_v1`), the `command_lifecycle` "started" frame now reports the turn inserted. **Why that frame is early enough.** I read the order in the CLI bundled with SDK 0.3.287 rather than in a live capture: - **A command that starts a fresh turn:** the engine pushes "started" into its lifecycle buffer at turn start (`C.push(W(w.uuid,"started"))`, before `[engine] turn N start`). The turn's message loop then flushes that buffer before it yields anything the turn produced (`if(C.length>0)yield*te()`), including its echo and first `stream_event`. - **A prompt folded into a running turn:** its `queued_command` attachment (the echo) is yielded before "started", so activation at the echo already comes first and this frame changes nothing. **One guard.** While another turn is still active, insertion still waits for the echo. That covers a turn held for its background work, a steered turn, and a cancelled turn awaiting its trailing idle. The echo's hand-off ends that turn first, so a turn is never reported inserted before the previous one ends. **Older CLIs** without lifecycle frames keep insertion at activation. Only the time `inserted` is reported changes. Activation, output attribution and settlement don't, and ACP v1 ignores `inserted`. ## Testing `src/tests/turn-events.test.ts`: - a fresh turn whose answer streams between "started" and its echo is reported inserted before that output; - a prompt that starts while the turn before it is held is reported inserted only after that turn ended. Removing the new insertion point fails the first test, and removing the guard fails the second. The rest of the suite passes unchanged, including the recorded v1 scenario traffic. `npm run build`, `npm run check`, `npm run test:run` (2231 passed). |
||
|
|
d24272c6b0 |
refactor: serve ACP v2 prompts through the turn events (#1226)
Second part of step 3 of opt-in ACP v2 support (#1217, #1219, #1222). The v2 surface now serves `session/prompt` and `session/cancel`. It still doesn't advertise `capabilities.session`; that waits for tool calls and replay (step 4). ## What `src/v2/prompt.ts` serves a v2 prompt through the agent's turn events (#1222), instead of translating it into a v1 prompt: | Turn event | v2 | |---|---| | `inserted(messageId)` | `user_message` (the prompt as received, under the uuid Claude Code echoed), `state_update: running`, then the answer `{ messageId }` | | `awaitingUser()` / `resumed()` | `requires_action` / `running` | | `ended(outcome)` | `idle` with the stop reason, `usage`, and `_meta` | | `ended` before insertion | `-32800`: a queued prompt that a cancel ended | | `failed` before insertion | the error as the JSON-RPC answer | | `failed` after insertion | an error `notice` that shows it, then `idle` with the custom stop reason `_error` and v1's JSON-RPC error in `_meta.claudeCode.error` | The last row is a gap in the draft: the idle `state_update` has no error, its stop reasons are all non-error ones, and a notice "must not carry … fatal-error reporting". So the failure travels on `idle` as a `_`-prefixed custom stop reason, which the draft allows, with the error in `_meta`; `auth_required`'s code survives there. The notice shows the agent's own failure title ("API Error: 529 Overloaded"); `TurnEvents.failed` gains an optional `title` for it. That's going back to the v2 draft as feedback. - `session/cancel` maps to the v1 cancel. - **Ordering:** the turn's state updates and the agent's own updates go through one `ctx.notify` path in call order, so `idle` comes after the turn's last output. The tests check the order. - **Message chunks** (`agent_message_chunk`, `agent_thought_chunk`, `user_message_chunk`) are translated with the `messageId` v2 requires, and fail loudly without one. - **Prompt content:** blocks that v1 can't express (a custom or future type) are rejected with `-32602`. Audience roles that v1 doesn't know are dropped from annotations, which the agent doesn't read. - Tool call and plan updates still fail loudly until their step. ## The one change on v1 The agent built three message chunks without a `messageId`: local command output, a result forwarded as the answer (a local-only command, or the issue #453 fallback), and a refusal explanation. Each now carries the uuid of the SDK message it came from, the id `messageIdForGrouping` already uses for non-assistant messages. It's an additive field on v1. None of the recorded v1 scenario baselines contain these chunks, so they don't change. ## Testing `src/tests/acp-v2.test.ts` drives the router with the SDK's v2 client, which validates every message against the v2 schema. Its mocked Claude Code now answers prompts: each turn echoes its prompt, then runs a script. New tests: - a prompt is answered with the echoed uuid while its turn still runs, then `agent_message_chunk` and `idle end_turn` with usage; - a queued prompt stays unanswered until the turn before it ends, then is answered with its own echoed uuid; - an MCP elicitation during the turn gives `requires_action`, then `running`; - `session/cancel` follows a real interrupt: output Claude Code sends after it arrives before `idle cancelled`, and a queued prompt is answered `-32800`; - a turn whose result is an API error gives an error `notice` with the agent's title, then `idle _error` with the error code; a missing login keeps `auth_required`'s code; - a queued prompt whose stream ends before insertion is answered with the error; - a refusal explanation carries the refusing result's uuid; - local command output and a forwarded result each arrive with their SDK message's uuid as `messageId`; - a prompt with a `_acme/widget` block is rejected and never reaches Claude Code; - a chunk without a `messageId` fails translation, and audience roles v1 doesn't know are dropped. Mutation check: answering at the end or at queueing instead of at insertion, dropping `user_message`, answering a cancelled queued prompt, dropping the failure notice or its title, ending a failure with `end_turn` or without the error, dropping `requires_action`, removing any of the three new `messageId`s, accepting any content block, or swallowing a failure before insertion each fails at least one test. `npm run build`, `npm run check`, `npm run test:run` (2240 passed). ## Not in this PR A review of this PR found these in the agent's turn reporting and cancellation, outside the mapping. They're tracked for their own PRs before the v2 surface is advertised; the first three also affect v1: - insertion is reported at the echo, which can lag the turn's first output; - a cancelled queued prompt's streamed output still reaches the client; - cancelling a held turn settles it before the interrupt's remaining output; - `session/close` answers before the active turn's `idle cancelled`; - whether a held turn should delay `idle` in v2 at all.v0.85.2-preview.6 |
||
|
|
190a00f68f |
feat: answer /mcp in chat with the MCP server status and a reconnect (#1218)
## Summary In an ACP client, `/mcp` showed the CLI text "… Use `/mcp` in the terminal for details." The user of an ACP client has no terminal. In SDK mode, Claude Code also refuses `/mcp reconnect|enable|disable` with "Reconnect, enable, and disable aren't available in this session." and changes nothing. - `/mcp` and `/mcp reconnect|enable|disable [<server>|all]` still run as a normal Claude Code turn. The adapter replaces the text of the local command, through the same hook that `/usage` uses. Prompt order, cancel, and the provider update stay with the turn. - For an action, the adapter runs it in that turn through the SDK control API (`reconnectMcpServer`, `toggleMcpServer`). It shows one result line for each server, then the status list. - The status list comes from `query.mcpServerStatus()`. It has a summary line and groups by status: failed, needs authentication, connecting, connected, and disabled on one line. A failed server shows a short cleaned error. A list is used and not a table, because a table breaks words in narrow columns. - Useful CLI sentences stay, for example "There's no MCP server named …". Sentences that point to the terminal are removed. - After an explicit reconnect, a server from the ACP session that needs authentication starts the existing MCP OAuth flow, when the client supports URL elicitation. - `/mcp` is advertised with the input hint `[reconnect|enable|disable [<server>|all]]` and is hidden on history replay. ## Other commits in this branch This branch also carries commits of other work: skill command metadata for AIR, a faster `session/load` replay, and the resumed permission mode. They can move to separate PRs if preferred. ## Tests - `src/tests/mcp-command.test.ts` (61 tests). The fake CLI answers with the real SDK-mode texts and message shapes (synthetic assistant + result) and does not change any status. - A live run through the adapter with a broken and a working stdio server: `/mcp`, `/mcp disable good`, `/mcp enable good`, `/mcp reconnect broken`, `/mcp reconnect nosuch`. - `compare.ts` allows one new difference against the origin/main baseline: the `mcp` command in `available_commands_update`. The baseline files are unchanged. - `npm run check` and `npm run test:run` pass.v0.85.2-preview.5 |
||
|
|
ddd5f54187 |
feat(deps): Bump @anthropic-ai/claude-agent-sdk to 0.3.287 (#1224)
## Summary
- Bumps `@anthropic-ai/claude-agent-sdk` to 0.3.287 (Claude Code
2.1.287). No compile or test fixes were needed.
## Review notes for 0.3.287
- **WebFetch/WebSearch keep running when a steer arrives: not active for
the adapter.** In 2.1.287, a human-origin `priority: 'now'` steer no
longer cancels WebFetch or WebSearch. The call keeps running, and its
tool_result is a "[Still running…]" notice for the model with
`tool_use_result: {detachedToolCall: true}`. The steer gets its own
result, and the CLI holds back idle. When the fetch finishes, Claude
starts a follow-up turn on its own. That turn has no user message and
its result carries no uuid, and idle only arrives after it. I checked
this against the live CLI. However, the CLI only does this when no
PostToolUse, PostToolUseFailure or PostToolBatch hook applies to the
tool. The adapter's PostToolUse hook has no matcher, so it applies to
every tool, and through the adapter the steer still cancels the fetch,
as before. I also checked that end to end. Turning the new behavior on
needs three changes: limit the hook to
Write/Edit/NotebookEdit/EnterPlanMode, render the card while the call
keeps running, and close the card at the follow-up turn. That is left
for a follow-up PR.
- **No changes needed:**
- the `includePartialMessages` late or missing `message_stop` fix (the
adapter's `message_stop` handling can safely run more than once)
- the `commands_changed`-before-`init` fix
- the clearer revoked-OAuth error text (it still arrives as an
`authentication_failed` error)
- MCP `structuredContentOmitted` (the adapter doesn't read
`structuredContent`)
- the `alwaysLoad: false` semantics (unused)
- the remote-only `first_text_post_*` result fields
- `get_task_output` (in the types, but `Query` has no method for it)
- the fix for a model fallback repeating on every later message
## Test plan
- [x] `npm run build`
- [x] `npm run test:run` (2142 passed)
- [x] `npm run check`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
v0.85.2-preview.4
|
||
|
|
3d4017b15a |
test: keep the suite off the real Claude CLI (#1223)
Fixes an intermittent failure of "replays a subagent from its own transcript file", and with it a broader leak: the unit suite was running the real Claude CLI hundreds of times per run. ## Cause The agent runs `claude auth status --json` in the background, without awaiting it, on every `initialize` and prompt. The scenario suite stubs it (`CLAUDE_CODE_EXECUTABLE=/usr/bin/false`), but other files didn't. Logging the probe's executable over one `vitest run` showed about 670 runs of the real CLI: | File | Real CLI runs | |---|---| | `acp-agent.test.ts` | 375 | | `create-session-options.test.ts` | 14 | | `incomplete-tools.test.ts` | 12 | | `session-titles.test.ts` | 8 | | `file-change-audit-integration.test.ts` | 5 | Each run uses the machine's own Claude config, unless a test points `CLAUDE_CONFIG_DIR` elsewhere. That flaky test points `CLAUDE_CONFIG_DIR` at a temp dir. The CLI it started then wrote `.claude.json`, `.claude.json.lock` and `backups/` into that dir about a second later, after the test body had finished. Under full-suite load, that overlapped the `rm` in the test's `finally`, which failed with `ENOTEMPTY`. Its assertions always passed. ## Change `vitest.config.ts` sets `CLAUDE_CODE_EXECUTABLE=/usr/bin/false` in `test.env`: - It's the override `claudeCliPath()` already honors, and the value the scenario suite already uses, so production code doesn't change. - `test.env` is the base environment, so it survives the `vi.unstubAllEnvs()` that three files call. - Runs that exercise the real CLI keep it: with `RUN_INTEGRATION_TESTS` (`npm run test:integration`) or `RUN_LIVE_CAPABILITY_AUDIT=true`, the variable is left unset. Tests that mock `execFile` or set their own executable are unaffected. ## Evidence - After the change, the same logging shows 0 runs of the real CLI: 688 probes run `/usr/bin/false`, and 108 hit files that already mock `execFile`. - The flaky test's temp dir now holds only the test's own `projects/` after the test, with no `.claude.json`. - Before the change, it failed in about 2 of 6 full runs on my machine. After, 8 of 8 full runs passed. - A full run takes about 4.8 s instead of 8.4 s. - The variable is `/usr/bin/false` in a default run and unset with either opt-in flag. - `npm run build`, `npm run check`, `npm run test:run`.v0.85.2-preview.3 |
||
|
|
6b69852cfc |
refactor: report each prompt turn through internal turn events (#1222)
First part of step 3 of opt-in ACP v2 support (step 1: #1217, step 2: #1219). It's independent of #1219. It changes no ACP v1 behavior, apart from one failure-only case noted below. ## Why ACP v2 changes the prompt lifecycle. `session/prompt` is answered when the prompt is *inserted* into the conversation, and progress and the stop reason arrive as `state_update`s. In v1, the response comes at the end of the turn. The agent only exposed the v1 shape: `prompt()` returns at the end of the turn. So v2 can't be mapped from the outside. Following the discussion on #1219, the adapter gets its own view of a turn, and each ACP version maps to it, instead of v2 being translated into v1. ## What `src/turn-events.ts` defines the adapter's own turn lifecycle: - `inserted(messageId)`: Claude Code took the prompt in as this user message. At most once, and never after the turn ends. - `awaitingUser()` / `resumed()`: a permission request or question is open in the session / none is open any more. - `ended(outcome)`: with a `TurnOutcome` (`stopReason`, `usage`, `_meta`). - `failed(error)`. The agent calls these synchronously while it updates its own state, so handlers must not throw or call back into the agent. In the agent: - `startTurn(params, events)` starts a turn. It resolves once the prompt is queued for Claude Code, and rejects only if the prompt is refused before that. Events can arrive before it resolves. `prompt()` is now the v1 view of it: it awaits the turn's outcome. - **inserted** is reported in `activateTurn`, the single place a queued turn becomes active. That's when Claude Code takes the prompt in: its echo, or for an echo-less command, its result. Two guards: - a clear-context restart re-activates the same turn in the fresh session, so it's reported once; - a turn that a cancel settled during the previous turn's hand-off isn't reported at all. - **awaiting user / resumed** follow one session-level rule: the active turn awaits the user exactly while any request in the session is open, rechecked when a turn activates. A request carries no prompt id, and Claude Code can ask for a queued prompt before the consumer reaches its echo. So tying a request to the turn that was active when it opened would misattribute it. - **ended / failed** come from the existing settle points, each guarded by `settled`, so a turn reports exactly one of them. - `TurnOutcome` and `StopReason` are the adapter's own types. A turn's outcome is field for field a v1 prompt response, so `PromptResponse` now only appears at the v1 boundary. **The one v1 difference:** a prompt that sets a goal publishes it to AIR clients after the prompt is queued. If that notification fails, `startTurn` now logs it rather than rejecting, because the turn is already running. For v1 this only matters on a dead connection: `prompt()` waits for the outcome instead of rejecting with the write error. ## Notes for the v2 step - A prompt sent while another turn is running is inserted only when Claude Code takes it in, after the running turn. The open question about queued prompts is going back to the v2 draft. - An echo-less command (such as `/compact`) is inserted at its result, after its output. On `msg_lifecycle_v1` CLIs, the `command_lifecycle` "started" frame may be an earlier insertion point. - A queued turn that a cancel ends before insertion may still be run by Claude Code (the orphan accounting). - Any open request counts towards `requires_action`, a background task's included; `agentID` could refine that in the permission step. ## Testing `src/tests/turn-events.test.ts` covers: - a normal turn: inserted under the uuid of the message Claude Code received, then ended; - a permission request: awaiting user, then resumed; - a request open from before the turn: the turn awaits the user from insertion, through its own answered request, until the earlier one is answered too; - a cancel during the hand-off from the previous turn: the queued turn ends as cancelled and is never inserted; - cancelling while a second prompt is queued: the active turn is inserted, then ended as cancelled, and the queued turn ends as cancelled without being inserted; - the stream ending with a turn queued: it fails without being inserted; - a prompt for an unknown session: `startTurn` rejects and reports nothing. The existing clear-context restart test also checks that the restarted turn is inserted once. Each guard is checked by mutation: removing the `insertedReported` guard, the `settled` guard, the activation recheck, or the change-only dedupe; tying `resumed` to the request's own turn; or reporting insertion at enqueue each fails at least one test. The existing suite passes unchanged, including the 474 scenario tests that compare outbound v1 traffic with recorded baselines. `npm run build`, `npm run check`, `npm run test:run`.v0.85.2-preview.2 |
||
|
|
c60fa48fd8 |
refactor: serve the ACP v2 session lifecycle without prompts (#1219)
Step 2 of opt-in ACP v2 support (step 1: #1217). Behind `CLAUDE_AGENT_ACP_EXPERIMENTAL_V2=1`, the v2 surface now serves `session/new`, `session/list`, `session/resume` (without replay), `session/close`, `session/delete`, and `session/set_config_option`. ACP v1 is unchanged. `capabilities.session` is still not advertised. Under v2, advertising it commits the agent to the whole baseline, including `session/prompt` and `replayFrom: start` replay, and those come in later steps. Until then these methods are served but not advertised. ## Translation As in step 1, each v2 request becomes the v1 request that `ClaudeAcpAgent` already serves, and each v1 response or update becomes its v2 form (`src/v2/session.ts`, `src/v2/session-update.ts`): - **MCP servers:** v2 requires a `type` on every transport, but the agent recognizes a v1 stdio server by its *missing* `type`. A v2 `type: "stdio"` config passed through as is would be silently skipped, so the tag is dropped. The lists v1 requires (`args`, `env`, `headers`) are defaulted. A transport v1 can't express is rejected with invalid params instead of being left out of the session. - **Config options:** `id` → `configId`, a select group's `group` → `groupId`. A select value in `session/set_config_option` drops its v2 `type: "id"`, and value types v1 can't express are rejected. - **Modes:** responses drop `modes`, and `current_mode_update` is dropped. The agent always lists the mode as the `mode` config option, and every mode change also reaches the client as a `config_option_update` or in the `set_config_option` response. - **Commands:** `available_commands_update` inputs gain `type: "text"`. - **Notices, session info, usage:** passed through unchanged. v2 needs no capability for notices, so a v2 client is reported to the agent as taking them, and advisories arrive as `notice` instead of transcript messages. - **Elicitation:** the same in v1 and v2, so it's forwarded. MCP OAuth at `session/new` works. - Update kinds that aren't translated yet (messages, tool calls, plans, extensions) throw, so a gap shows up as an error, not a missing update. - `replayFrom` is rejected until replayed history can be translated. Also bumps `@agentclientprotocol/sdk`: - to 1.6.1, whose router types `closed` as always present, so `serveAcp` drops its `closed!`; - to 1.7.0, which type-checks the v2 extensible-union values the adapter builds, at any depth ([typescript-sdk#268](https://github.com/agentclientprotocol/typescript-sdk/pull/268)). The v2 translations compile unchanged. The exception is `createElicitation`, which relays the v1 request: v1 types a property schema's tag as any string, and an MCP server's schema passes through unchecked, as on v1. It gets a cast with a comment saying so. ## Testing - `src/tests/acp-v2.test.ts` drives the router with the SDK's v2 client app, which validates every response, session update, and elicitation against the v2 schema. New cases cover session creation with v2 MCP servers, config options, and commands; rejected MCP transports; list/close/resume/delete and rejected `replayFrom`; setting the mode with no `current_mode_update` reaching the client; notice support; MCP OAuth through URL elicitation; and unit tests for grouped options, rejected value types, and untranslated updates. Breaking the stdio or command-input translation makes the tests fail. - Ran the built binary over stdio against a real Claude Code session: v2 `initialize`, `session/new`, `list`, setting the mode, and `close` all passed the v2 client's validation, and the 52 real commands arrived with `type: "text"` inputs. `session/new` took ~0.7 s, the same as over v1. - `npm run build`, `npm run check`, `npm run test:run`.v0.85.2-preview.1 |
||
|
|
686c0c99b3 |
chore(main): release 0.85.1 (#1213)
🤖 I have created a release *beep* *boop* --- ## [0.85.1](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.85.0...v0.85.1) (2026-10-01) ### Bug Fixes * answer session/close without waiting for the interrupt reply ([#1216](https://github.com/agentclientprotocol/claude-agent-acp/issues/1216)) ([v0.85.1 |
||
|
|
8e893f51ea |
refactor: add an opt-in experimental ACP v2 handshake (#1217)
First step toward optional support for the [draft ACP v2 protocol](https://agentclientprotocol.com/protocol/v2/draft/overview). ACP v1 stays the default and is unchanged. ## What it does Set `CLAUDE_AGENT_ACP_EXPERIMENTAL_V2=1` and the adapter routes each connection by the protocol version the client requests in `initialize` (via the SDK's `AgentProtocolRouter`): - A client that requests version 2 or later gets the draft ACP v2 `initialize`, `auth/login`, and `auth/logout`, plus the `_auth/status_update` push. - Every other client gets ACP v1, served by the same handlers as today. Without the variable, the adapter never builds the router and serves ACP v1 exactly as before. The v2 response does not advertise `capabilities.session` yet. A v2 agent that advertises it must serve the whole session baseline (`session/new`, `list`, `resume`, `close`, `prompt`, `cancel`, `update`), which follow-up PRs add. So for now a v2 client can initialize and authenticate, but cannot open a session. ## How `ClaudeAcpAgent` keeps speaking ACP v1 types. The v2 surface in `src/v2/` is a thin translation layer around it, so v1 and v2 share one implementation: - `v2AgentApp` registers the v2 methods and translates each request to the v1 request the agent already serves, and each response back. For `initialize` that means `info`/`capabilities` instead of `agentInfo`/`agentCapabilities`, and auth methods with `methodId` and a required `type`, with terminal `env` as `{ name, value }` pairs. A v2 client gets no client `fs` or terminals, and boolean config options are baseline. - `V2ClientConnection` is the `AcpClient` of a v2 connection. It sends the agent's v1-shaped messages in their v2 form. Only connection-level messages can reach it so far; session-scoped methods reject until v2 sessions land. - `v1AgentApp` is the existing v1 handler registration, pulled out of `runAcp` so the router can reuse it. Each surface now creates the agent of its connection in `onConnect`, because under the router the connection opens only after `initialize` has been read. `runAcp` (a public export) behaves as before. Also bumps `@agentclientprotocol/sdk` to 1.6.0 (schema v2.0.0-alpha.7). The bump changes nothing for v1: the full suite passes unchanged on it. ## Testing - `src/tests/acp-v2.test.ts` drives the real router over in-memory streams with the SDK's own v1 and v2 client apps (the v2 client validates every response against the v2 schema). It covers the v1 handshake through the router, the v2 handshake, method-not-found for v2 session methods, the `_auth/status_update` push, and gateway `auth/login` followed by `auth/logout`. - Ran the built binary over stdio: v2 client with the flag, v1 client with the flag, v2 client without the flag (gets the unchanged v1 response), and stdin EOF before `initialize` (exits 0). - `npm run build`, `npm run check`, `npm run test:run`.v0.85.1-preview.4 |
||
|
|
0c862e2949 |
fix: answer session/close without waiting for the interrupt reply (#1216)
## Summary - `teardownSession` sends the interrupt but does not await its reply - `query.close()` follows at once and ends the CLI process - `session/cancel` still awaits the interrupt reply On a fresh session, the background `getContextUsage` request from `refreshContextWindowInBackground` is still in flight. The SDK serializes control requests, so the CLI answered the interrupt only after it. With a real CLI, `session/close` took 2.5 s in an empty directory and 3.2 s in a large repository. ACP clients with a 3 s close timeout timed out. With this change, close answers in about 2 ms, and the CLI process exits. ## Tests - `npm run test:run -- src/tests/create-session-options.test.ts` - `npx tsc --noEmit` - `npm run check`v0.85.1-preview.3 |
||
|
|
4ffa625977 |
fix: restore background task stops on replay instead of showing them as prompts (#1205)
When a background task stops, the CLI persists a `<task-notification>` user record. Live, the adapter hides it and handles the SDK task lifecycle frame; replay previously showed the raw XML as a user prompt. Replay now hides notification records and removes embedded notification XML while preserving adjacent user text and delivered prompts with an origin `subkind`. It restores known non-agent tasks through `AsyncTaskRuntime`, including `killed` → `stopped` and duplicate terminal-event suppression. Agent notifications override the launch result's terminal state. Unknown tasks remain hidden without creating a task card. Task launches are recognized in `tool_use`, `server_tool_use`, and `mcp_tool_use` blocks. Async task updates use the session that owns the launching tool call, even when another session receives the notification. History has no `task_started` frame, so tasks without a persisted stop notification cannot be reconstructed. The large Write patch test now uses a fixed clock to check patch correctness independently of CI speed; a separate advancing-clock test verifies the existing timeout fallback. The production 100 ms budget remains unchanged. Validation on current main (SDK 0.3.286): - `npm run build`: passed. - `npm run check`: passed. - `env -u ANTHROPIC_BASE_URL npm run test:run`: 2119 passed, 29 skipped. The local gateway environment otherwise changes the expected default URL in four provider tests. - Regression coverage includes origin/text notifications, adjacent user text, unknown and repeated tasks, killed tasks, background Agents, delivered subkind prompts, alternate tool block types, task session ownership, and patch timeout fallback.v0.85.1-preview.2 |
||
|
|
7f8d5471e2 |
fix: fail turns with unfinished tools (#1212)
Fixing silent agent turn completion in case of tools failurev0.85.1-preview.1 |
||
|
|
c84845272f |
chore(main): release 0.85.0 (#1209)
🤖 I have created a release *beep* *boop* --- ## [0.85.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.84.0...v0.85.0) (2026-10-01) ### Features * **deps:** Bump @anthropic-ai/claude-agent-sdk to 0.3.286 ([#1211](https://github.com/agentclientprotocol/claude-agent-acp/issues/1211)) ([v0.85.0 |
||
|
|
af0b43de94 |
fix: send the legacy custom answer key to AIR (#1210)
Released AIR versions, such as 262.air/release-09, read the custom answer companion only from the root key _meta._askUserQuestionCustomAnswer. The adapter sent only _meta.jetbrains.air.customAnswer, so these versions showed the companion as a separate question. For an AIR client the companion now carries both keys with the same value. Other clients get no key, as before. Remove the root key when the ACP registry no longer serves AIR versions that read only that key. IJAI-2892v0.84.1-preview.3 |
||
|
|
f53b0d7f40 |
feat(deps): Bump @anthropic-ai/claude-agent-sdk to 0.3.286 (#1211)
## Summary
- Bumps `@anthropic-ai/claude-agent-sdk` to 0.3.286 (Claude Code
2.1.286). No compile or test fixes were needed.
- Updates the steer comments for a CLI behavior change. A `priority:
'now'` steer that lands during a foreground tool call (Bash, Agent, MCP)
now moves the tool to the background instead of stopping the turn.
Depending on timing, the CLI then either:
- adds the steer to the running cycle, which ends in **one** result
stamped with both the prompt's and the steer's uuids, or
- ends the cycle early and runs the steer as a second cycle.
During plain text output it still stops the turn, as before.
- Adds a test for the case where the steer joins the running cycle, with
and without an echo of the steer. The case where the steer runs as a
second cycle was already covered.
I checked all of this against the live CLI 2.1.286. In each case the
result that answered the steer carried the steer's uuid, so the existing
steer settlement logic handles it without code changes.
## Review notes for 0.3.285 and 0.3.286
- **Raw XML in subagent replay:** `getSubagentMessages()` now returns
delivered `<task-notification>` rows as plain user messages (`origin:
{kind: "task-notification"}`, `isQueuedCommand: true`, no `is_meta`).
They reach child replay and show up as raw XML user messages. #1205
already hides this exact shape, so it fixes the subagent case once
merged.
- **Omitted `permissionMode`:** the SDK now leaves it to the CLI. The
adapter always passes an explicit mode, so this has no effect.
- **No changes needed:** the `fallback_credit` type, Artifact pin/unpin,
`provider_not_allowed`, the SDK MCP manifest fields, the background Bash
timeout (its stop notice goes through the existing task-stopped path),
and the `setModel` output-limit fix.
## Test plan
- [x] `npm run build`
- [x] `npm run test:run` (2095 passed)
- [x] `npm run check`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
v0.84.1-preview.2
|
||
|
|
4af807968c |
fix: Adapt to SDK 0.3.284 replay and ultracode changes (#1208)
Follow-ups to the SDK 0.3.284 / CLI 2.1.284 bump (#1189), which landed with only package changes. ## Replay showed messages from other agents and sessions as user text Since 0.3.284, `getSessionMessages()` returns `is_meta` user messages from other agents, sessions and channels (`origin.kind` peer, channel, observer, observer-activity, slack-ping). Their content is the full harness framing: the `<cross-session-message>` envelope plus the "not typed by your user" preamble. `replayMessage` sent them as `user_message_chunk`, while the live prompt loop never shows them. Replay now skips them. Other `is_meta` messages (compact summaries) still replay. Verified against a live 0.3.284 transcript: the enveloped peer turn is gone, and the user's own prompts still replay. Fixes #1203. Complements #1205, which hides `task-notification` records the same way. The two cover different origin kinds and merge with only a trivial test-file conflict. ## Effort applies turned ultracode off CLI 2.1.284 turns ultracode off when an `applyFlagSettings` call changes `effortLevel` without an `ultracode` key. The adapter applies effort at session start (recommended-value clients), after a model switch and from the effort picker, so a settings-enabled `ultracode: true` was silently cleared. The CLI's own `/effort` control now keeps ultracode on at any level, so all three applies send `ultracode: true` when the settings request it (`effortFlagSettings`). ## Checked, no change needed Elicitation-hook `decision: 'block'`, the background-agent stdin fix (the adapter never hit it; keep `CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS=1`), MCP startup waits, Sonnet 5.5 (natively 1M, already covered by the background context-window refresh), malformed-image handling (now done by the CLI), and notice rewording (the adapter matches none of the changed strings). ## Testing - New tests for both helpers, replay of the probe's peer-message shape, and a session test checking that the startup and picker applies keep ultracode. - `npm run build`, `npm run check` and `npm run test:run` (2093 passed) all pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>v0.84.1-preview.1 |
||
|
|
bdb50ad984 |
chore(main): release 0.84.0 (#1190)
🤖 I have created a release *beep* *boop* --- ## [0.84.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.83.0...v0.84.0) (2026-09-28) ### Features * **deps:** update Claude SDK ([#1189](https://github.com/agentclientprotocol/claude-agent-acp/issues/1189)) ([v0.84.0 |
||
|
|
d5e6f33046 | feat(deps): update Claude SDK (#1189) v0.83.1-preview.1 | ||
|
|
691328a919 |
chore(main): release 0.83.0 (#1188)
🤖 I have created a release *beep* *boop* --- ## [0.83.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.82.0...v0.83.0) (2026-09-28) ### Features * **deps:** Bump @anthropic-ai/claude-agent-sdk to 0.3.283 ([#1186](https://github.com/agentclientprotocol/claude-agent-acp/issues/1186)) ([v0.83.0 |
||
|
|
49858b5273 |
feat(deps): Bump @anthropic-ai/claude-agent-sdk to 0.3.283 (#1186)
Bumps the minor group with 38 updates in the / directory: | Package | From | To | | --- | --- | --- | | [@anthropic-ai/claude-agent-sdk](https://github.com/anthropics/claude-agent-sdk-typescript) | `0.3.280` | `0.3.282` | | [@anthropic-ai/sdk](https://github.com/anthropics/anthropic-sdk-typescript) | `0.127.0` | `0.128.0` | | [prettier](https://github.com/prettier/prettier) | `3.9.8` | `3.9.9` | | [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) | `5.0.1` | `5.0.2` | | @anthropic-ai/claude-agent-sdk-darwin-arm64 | `0.3.280` | `0.3.282` | | @anthropic-ai/claude-agent-sdk-darwin-x64 | `0.3.280` | `0.3.282` | | @anthropic-ai/claude-agent-sdk-linux-arm64 | `0.3.280` | `0.3.282` | | @anthropic-ai/claude-agent-sdk-linux-arm64-musl | `0.3.280` | `0.3.282` | | @anthropic-ai/claude-agent-sdk-linux-x64 | `0.3.280` | `0.3.282` | | @anthropic-ai/claude-agent-sdk-linux-x64-musl | `0.3.280` | `0.3.282` | | @anthropic-ai/claude-agent-sdk-win32-arm64 | `0.3.280` | `0.3.282` | | @anthropic-ai/claude-agent-sdk-win32-x64 | `0.3.280` | `0.3.282` | | [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/typescript-sdk) | `1.30.0` | `1.30.1` | | [@oxc-project/types](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxc-types) | `0.150.0` | `0.151.0` | | [@rolldown/binding-android-arm-eabi](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-android-arm64](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-darwin-arm64](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-darwin-x64](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-freebsd-x64](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-linux-arm-gnueabihf](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-linux-arm64-gnu](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-linux-arm64-musl](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-linux-ppc64-gnu](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-linux-s390x-gnu](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-linux-x64-gnu](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-linux-x64-musl](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-openharmony-arm64](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-win32-arm64-msvc](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@rolldown/binding-win32-x64-msvc](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [@vitest/mocker](https://github.com/vitest-dev/vitest/tree/HEAD/packages/mocker) | `5.0.1` | `5.0.2` | | [@vitest/spy](https://github.com/vitest-dev/vitest/tree/HEAD/packages/spy) | `5.0.1` | `5.0.2` | | [hono](https://github.com/honojs/hono) | `4.13.8` | `4.13.10` | | [magic-string](https://github.com/Rich-Harris/magic-string) | `1.4.1` | `1.4.2` | | [rolldown](https://github.com/rolldown/rolldown/tree/HEAD/packages/rolldown) | `1.2.9` | `1.2.11` | | [tinybench](https://github.com/tinylibs/tinybench) | `6.1.4` | `6.2.0` | | [tinyexec](https://github.com/tinylibs/tinyexec) | `1.3.0` | `1.3.1` | | [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) | `8.3.0` | `8.3.1` | | [why-is-node-running](https://github.com/mafintosh/why-is-node-running) | `2.3.0` | `3.2.2` | Updates `@anthropic-ai/claude-agent-sdk` from 0.3.280 to 0.3.282 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/anthropics/claude-agent-sdk-typescript/releases">@anthropic-ai/claude-agent-sdk's releases</a>.</em></p> <blockquote> <h2>v0.3.282</h2> <h2>What's changed</h2> <ul> <li>Added support for <code>strictKnownMarketplaces</code> and <code>blockedMarketplaces</code> in host-supplied <code>managedSettings</code>: the allowlist applies only where admin policy sets none; the blocklist adds to the admin's</li> <li>Added <code>@anthropic-ai/claude-agent-sdk/core</code>, a smaller entry point for apps that bundle the SDK (query, MCP tool helpers, session mutations, <code>resolveSettings</code>); it uses your installed zod and MCP SDK</li> <li>Added <code>prewarm()</code> and <code>SpareProcess.claim()</code> (alpha): start a Claude Code process before its session is known and bind it to a folder and its per-session options later</li> <li>Fixed <code>readMcpResource()</code> relaying content <code>_meta</code> keys under the CLI-reserved <code>com.anthropic/</code> prefix; they are now dropped, as for tool results</li> <li>Updated to parity with Claude Code v2.1.282</li> </ul> <h2>Update</h2> <pre lang="sh"><code>npm install @anthropic-ai/claude-agent-sdk@0.3.282 # or yarn add @anthropic-ai/claude-agent-sdk@0.3.282 # or pnpm add @anthropic-ai/claude-agent-sdk@0.3.282 # or bun add @anthropic-ai/claude-agent-sdk@0.3.282 </code></pre> <h2>v0.3.281</h2> <h2>What's changed</h2> <ul> <li>Added optional <code>trigger</code>, <code>user_message_uuid</code> and <code>timestamp</code> fields to the <code>conversation_reset</code> message so clients can tell what reset the conversation, match a /clear to its message, and show when the reset happened</li> <li>Fixed permission and dialog callbacks still being invoked for requests that arrived after <code>close()</code></li> <li>Fixed control requests issued after a query closed hanging or leaking, and permission prompts that could not be cancelled after a cancelled request was redelivered</li> <li>Fixed <code>session_state_changed</code> staying at <code>requires_action</code> after an overlapping permission prompt and sandbox network-access prompt were both answered</li> <li>Improved SDK package size and load time: <code>sdk.mjs</code> no longer bundles unused dependencies (1.47 MB → 0.97 MB)</li> <li>Improved startup time for <code>query()</code> sessions with in-process MCP servers (<code>createSdkMcpServer</code>) by running their handshake inside the SDK; <code>initialize</code> may now wait up to 250 ms for them</li> <li>Improved SDK session start-up: the CLI now answers the host's initialize request before starting its background start-up work</li> <li>Changed the <code>Settings</code> type's <code>attribution</code> field to <code>boolean | {...}</code>; TypeScript code that reads <code>attribution.commit</code> from returned settings needs a type narrow</li> <li>Updated to parity with Claude Code v2.1.281</li> </ul> <h2>Update</h2> <pre lang="sh"><code>npm install @anthropic-ai/claude-agent-sdk@0.3.281 # or yarn add @anthropic-ai/claude-agent-sdk@0.3.281 # or pnpm add @anthropic-ai/claude-agent-sdk@0.3.281 # or bun add @anthropic-ai/claude-agent-sdk@0.3.281 </code></pre> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/anthropics/claude-agent-sdk-typescript/blob/main/CHANGELOG.md">@anthropic-ai/claude-agent-sdk's changelog</a>.</em></p> <blockquote> <h2>0.3.282</h2> <ul> <li>Added support for <code>strictKnownMarketplaces</code> and <code>blockedMarketplaces</code> in host-supplied <code>managedSettings</code>: the allowlist applies only where admin policy sets none; the blocklist adds to the admin's</li> <li>Added <code>@anthropic-ai/claude-agent-sdk/core</code>, a smaller entry point for apps that bundle the SDK (query, MCP tool helpers, session mutations, <code>resolveSettings</code>); it uses your installed zod and MCP SDK</li> <li>Added <code>prewarm()</code> and <code>SpareProcess.claim()</code> (alpha): start a Claude Code process before its session is known and bind it to a folder and its per-session options later</li> <li>Fixed <code>readMcpResource()</code> relaying content <code>_meta</code> keys under the CLI-reserved <code>com.anthropic/</code> prefix; they are now dropped, as for tool results</li> <li>Updated to parity with Claude Code v2.1.282</li> </ul> <h2>0.3.281</h2> <ul> <li>Added optional <code>trigger</code>, <code>user_message_uuid</code> and <code>timestamp</code> fields to the <code>conversation_reset</code> message so clients can tell what reset the conversation, match a /clear to its message, and show when the reset happened</li> <li>Fixed permission and dialog callbacks still being invoked for requests that arrived after <code>close()</code></li> <li>Fixed control requests issued after a query closed hanging or leaking, and permission prompts that could not be cancelled after a cancelled request was redelivered</li> <li>Fixed <code>session_state_changed</code> staying at <code>requires_action</code> after an overlapping permission prompt and sandbox network-access prompt were both answered</li> <li>Improved SDK package size and load time: <code>sdk.mjs</code> no longer bundles unused dependencies (1.47 MB → 0.97 MB)</li> <li>Improved startup time for <code>query()</code> sessions with in-process MCP servers (<code>createSdkMcpServer</code>) by running their handshake inside the SDK; <code>initialize</code> may now wait up to 250 ms for them</li> <li>Improved SDK session start-up: the CLI now answers the host's initialize request before starting its background start-up work</li> <li>Changed the <code>Settings</code> type's <code>attribution</code> field to <code>boolean | {...}</code>; TypeScript code that reads <code>attribution.commit</code> from returned settings needs a type narrow</li> <li>Updated to parity with Claude Code v2.1.281</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="v0.82.1-preview.2 |
||
|
|
77ceab0339 |
chore(deps): Bump diff from 8.0.4 to 9.0.0 (#1187)
Bumps [diff](https://github.com/kpdecker/jsdiff) from 8.0.4 to 9.0.0. <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/kpdecker/jsdiff/blob/master/release-notes.md">diff's changelog</a>.</em></p> <blockquote> <h2>9.0.0</h2> <p>(All changes part of PR <a href="https://redirect.github.com/kpdecker/jsdiff/pull/672">#672</a>.)</p> <ul> <li> <p><strong>ES5 support is dropped</strong>. <code>parsePatch</code> now uses <code>TextDecoder</code> and <code>Uint8Array</code>, which are not available in ES5, and TypeScript is now compiled with the "es6" <code>target</code>. From now on, I intend to freely use any features that are deemed "Widely available" by <a href="https://web.dev/baseline">Baseline</a>. Users who need ES5 support should stick to version 8.</p> </li> <li> <p><strong>C-style quoted strings in filename headers are now properly supported</strong>.</p> <p>When the name of either the old or new file in a patch contains "special characters", both GNU <code>diff</code> and Git quote the filename in the patch's headers and escape special characters using the same escape sequences that are used in string literals in C, including octal escapes for all non-ASCII characters. Previously, jsdiff had very little support for this; <code>parsePatch</code> would remove the quotes, and unescape any escaped backslashes, but would not unescape other escape sequences. <code>formatPatch</code>, meanwhile, did not quote or escape special characters at all.</p> <p>Now, <code>parsePatch</code> parses all the possible escape sequences that GNU diff (or Git) ever output, and <code>formatPatch</code> quotes and escapes filenames containing special characters in the same way GNU diff does.</p> </li> <li> <p><strong><code>formatPatch</code> now omits file headers when <code>oldFileName</code> or <code>newFileName</code> in the provided patch object are <code>undefined</code></strong>, regardless of the <code>headerOptions</code> parameter. (Previously, it would treat the absence of <code>oldFileName</code> or <code>newFileName</code> as indicating the filename was the word "undefined" and emit headers <code>--- undefined</code> / <code>+++ undefined</code>.)</p> </li> <li> <p><strong><code>formatPatch</code> no longer outputs trailing tab characters at the end of <code>---</code>/<code>+++</code> headers.</strong></p> <p>Previously, if <code>formatPatch</code> was passed a patch object to serialize that had empty strings for the <code>oldHeader</code> or <code>newHeader</code> property, it would include a trailing tab character after the filename in the <code>---</code> and/or <code>+++</code> file header. Now, this scenario is treated the same as when <code>oldHeader</code>/<code>newHeader</code> is <code>undefined</code> - i.e. the trailing tab is omitted.</p> </li> <li> <p><strong><code>formatPatch</code> no longer mutates its input</strong> when serializing a patch containing a hunk where either the old or new content contained zero lines. (Such a hunk occurs only when the hunk has no context lines and represents a pure insertion or pure deletion, which for instance will occur whenever one of the two files being diffed is completely empty.) Previously <code>formatPatch</code> would provide the correct output but also mutate the <code>oldLines</code> or <code>newLines</code> property on the hunk, changing the meaning of the underlying patch.</p> </li> <li> <p><strong>Git-style patches are now supported by <code>parsePatch</code>, <code>formatPatch</code>, and <code>reversePatch</code></strong>.</p> <p>Patches output by <code>git diff</code> can include some features that are unlike those output by GNU <code>diff</code>, and therefore not handled by an ordinary unified diff format parser. An ordinary diff simply describes the differences between the <em>content</em> of two files, but Git diffs can also indicate, via "extended headers", the creation or deletion of (potentially empty) files, indicate that a file was renamed, and contain information about file mode changes. Furthermore, when these changes appear in a diff in the absence of a content change (e.g. when an empty file is created, or a file is renamed without content changes), the patch will contain no associated <code>---</code>/<code>+++</code> file headers nor any hunks.</p> <p>jsdiff previously did not support parsing Git's extended headers, nor hunkless patches. Now <code>parsePatch</code> parses some of the extended headers, parses hunkless Git patches, and can determine filenames (e.g. from the extended headers) when parsing a patch that includes no <code>---</code> or <code>+++</code> file headers. The additional information conveyed by the extended headers we support is recorded on new fields on the result object returned by <code>parsePatch</code>. See <code>isGit</code> and subsequent properties in the docs in the README.md file.</p> <p><code>formatPatch</code> now outputs extended headers based on these new Git-specific properties, and <code>reversePatch</code> respects them as far as possible (with one unavoidable caveat noted in the README.md file).</p> </li> <li> <p><strong>Unpaired file headers now cause <code>parsePatch</code> to throw</strong>.</p> <p>It remains acceptable to have a patch with no file headers whatsoever (e.g. one that begins with a <code>@@</code> hunk header on the very first line), but a patch with <em>only</em> a <code>---</code> header or only a <code>+++</code> header is now considered an error.</p> </li> <li> <p><strong><code>parsePatch</code> is now more tolerant of "trailing garbage"</strong></p> <p>That is: after a patch, or between files/indexes in a patch, it is now acceptable to have arbitrary lines of "garbage" (so long as they unambiguously have no syntactic meaning - e.g. trailing garbage that leads with a <code>+</code>, <code>-</code>, or <code> </code> and thus is interpretable as part of a hunk still triggers a throw).</p> <p>This means we no longer reject patches output by tools that include extra data in "garbage" lines not understood by generic unified diff parsers. (For example, SVN patches can include "Property changes on:" lines that generic unified diff parsers should discard as garbage; jsdiff previously threw errors when encountering them.)</p> <p>This change brings jsdiff's behaviour more in line with GNU <code>patch</code>, which is highly permissive of "garbage".</p> </li> <li> <p><strong>The <code>oldFileName</code> and <code>newFileName</code> fields of <code>StructuredPatch</code> are now typed as <code>string | undefined</code> instead of <code>string</code></strong>. This type change reflects the (pre-existing) reality that <code>parsePatch</code> can produce patches without filenames (e.g. when parsing a patch that simply contains hunks with no file headers).</p> </li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="v0.82.1-preview.1 |
||
|
|
18de376240 |
chore(main): release 0.82.0 (#1180)
🤖 I have created a release *beep* *boop* --- ## [0.82.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.81.2...v0.82.0) (2026-09-28) ### Features * AIR tool call contract, exact git patches, plan file, and fixes for every client ([#1153](https://github.com/agentclientprotocol/claude-agent-acp/issues/1153)) ([v0.82.0 |
||
|
|
875d75f2a4 |
feat: AIR tool call contract, exact git patches, plan file, and fixes for every client (#1153)
## Summary One PR with separate commits (the earlier stack #1168 and #1169 is folded back in). ### Exact git patches - `src/diff.ts` builds exact git patches for Edit and Write: real line numbers, file modes, CRLF, the final-newline marker, a size limit (including a bound for `replace_all`), binary detection, and an asynchronous diff with a time budget. The approval preview mirrors the input normalisation of the bundled CLI. - No creation patch over an existing file or for an Edit of an existing empty file, and no patch for a Write that changed nothing. ### For every client Clients that do not declare `_meta.jetbrains.air` (Zed, plain ACP clients) get the same information as on `main`. - A `tool_call_update` omits top-level fields that did not change since the last report of the same tool call (ACP merge semantics). The `_meta` of each report stays complete. - Bug fixes: a failed approval preview no longer blanks the approval diff; a permission denial replaces a pinned approval patch; the compaction summary is not repeated when the streamed text is identical; streamed subagent text is not sent twice; async task fields are recorded only after a successful send; late updates of a finished native subagent are dropped; the updates of a fresh Claude context after a clear-context restart reach the ACP session. ### For AIR only - One fact in one field: input in `rawInput`, the file text of an edit only in the diff (`diffPatch`), output once, no display copies of the input (`rawInputRendering`), `_meta.claudeCode` reduced to `toolName`, `parentToolUseId` and the `toolResponse` markers, per-key `_meta` filtering. - Plan file mode (`planFile`): ExitPlanMode carries only `rawInput.planFilePath`; AIR follows the file that Claude writes. - AIR-only keys move under `_meta.jetbrains.air.*` and are no longer sent to other clients. ### Structure and docs - `src/tool-calls/`: one reporter per tool, one `ClientCapabilities`, one `AcpToolCallRenderer`, the field tracker and the changed-meta filter. - `docs/air-extensions.md` replaces the per-extension AIR docs. ## Tests - `npm run build`, `npm run check`, `npm run test:run`: 1995 passed. - Scenario tests for plain, Zed, and AIR clients: the SDK mock honours the adapter's session id, every update must reach its ACP session, every message is validated against the ACP JSON schema with all formats checked, plain and Zed are compared with a recorded `main` baseline, AIR keeps compact golden recordings.v0.81.3-preview.2 |
||
|
|
e6681d2a57 |
fix: use ACP auth errors without access updates (#1179)
Authentication failures now use the ACP authRequired error only. The adapter does not send a second access failure or login text as a chat message. Provider verification and cloud credential errors use the service category because signing in cannot resolve them. Checks: npm run check; npm run build; npm run test:run (1468 passed, 28 skipped).v0.81.3-preview.1 |
||
|
|
5dbb453c63 |
chore(main): release 0.81.2 (#1171)
🤖 I have created a release *beep* *boop* --- ## [0.81.2](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.81.1...v0.81.2) (2026-09-24) ### Bug Fixes * announce resumed subagent generations when they start ([#1173](https://github.com/agentclientprotocol/claude-agent-acp/issues/1173)) ([v0.81.2 |
||
|
|
b495e55a22 |
fix: announce resumed subagent generations when they start (#1173)
### Summary Fixes #1158. When a native subagent session is resumed for subsequent turn execution (`task_started`), `this.parentByToolUse.get(task.toolUseId)` returns `undefined` because `finishTask` deletes the mapping at the completion of earlier generations. Because `knownParentSessionId` evaluated to `undefined`, `if (knownParentSessionId || !task.toolUseId)` evaluated to `false`, postponing the subagent announcement until `finishTask`. ### Changes - In `src/native-subagents.ts`: Added fallback `const knownParentSessionId = this.parentByToolUse.get(task.toolUseId) ?? previous?.parentSessionId;` so resumed subagents recognize their existing session parent at `task_started`. - In `src/tests/native-subagents.test.ts`: Added unit test confirming `subagent_spawned` is emitted immediately upon `taskStarted` for resumed sessions. ### Verification - `npm test src/tests/native-subagents.test.ts` (all 8 tests passing). - `npx tsc --noEmit` (clean, 0 type errors). --------- Co-authored-by: shobhitagnihotri69 <shobhitagnihotri69@users.noreply.github.com> Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.2-preview.2 |
||
|
|
a2c362c948 |
fix: continue clear-context plans approved in a background followup (#1170)
Fixes #1167. ## Problem In plan mode the model often runs Explore agents in the background. The user turn's result then comes back while those agents are still running, so `session/prompt` is held open (#864/#866). When an agent finishes, the model writes the plan and calls `ExitPlanMode` in the **task-notification followup**. The user accepts it with a clear-context option. The interrupted cycle's `[ede_diagnostic] … stop_reason=tool_use` result carries that cycle's `task-notification` origin. That sends it into the autonomous-result branch, which: 1. sends the `usage_update` with `_claude/origin: task-notification`. This is the "background task finished at the same time" update from the report; it's actually the same cycle. 2. settles the held turn with `end_turn` and returns early, before the ExitPlanMode restart check runs. The plan is never continued, the mode stays `plan`, and nothing tells the client. ## Fix - The diagnostic match now lives in one shared function, `isExitPlanInterruptionResult()` in `exit-plan.ts`. Both the user-result path and the new check call it; the user path behaves as before. - In the autonomous branch, when the active turn is held and the result is the recorded ExitPlanMode interruption: - **Clear-context option:** drop the held turn's stored outcome, then run the usual fresh-context restart. The fresh query doesn't have the old background tasks, so the stale hold would otherwise settle the moved turn with `end_turn` before the plan runs. The continuation's own result settles the turn. - **"No, keep planning":** settle `cancelled` with the user turn's own usage, through `settleOrDefer`, so the turn stays open while other spawned subagents are still running. ## Tests There are two new tests in the deferred-settlement block. Each runs a held turn whose task-notification followup calls `ExitPlanMode`: one for the clear-context restart, one for keep-planning. The restart test also fails if the held outcome isn't dropped. ## Known limitations (unchanged by this PR) - **Background agents are killed by the restart.** Upstream `/clear` keeps background agent tasks running (`hasAgentTaskSurvivingClear`). The adapter's restart closes the old query, so any other running subagents are killed, just as on the existing user-turn restart path. - **Plans approved after the turn has ended are still dropped.** If `ExitPlanMode` runs after the turn has already settled, there's no open turn to continue, and the plan is dropped as before. A client-visible notice for that case would be a follow-up. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.2-preview.1 |
||
|
|
b264b52bee |
chore(main): release 0.81.1 (#1162)
🤖 I have created a release *beep* *boop* --- ## [0.81.1](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.81.0...v0.81.1) (2026-09-23) ### Bug Fixes * gate login result text on error state ([#1103](https://github.com/agentclientprotocol/claude-agent-acp/issues/1103)) ([v0.81.1 |
||
|
|
da11f1feb2 |
fix: include model on usage updates (#1032)
## Summary - include the current assistant model id on `usage_update` notifications as `model` - mirror the same value in `_meta["_claude/model"]` so clients that prefer extension metadata can consume it - preserve existing `_meta` entries such as `_claude/origin` and rate-limit metadata Fixes #1021 ## Verification - `npm run build` - `npm run check` - `npm run test:run -- src/tests/acp-agent.test.ts -t 'usage_update|effective model|origin handling'` - `npm run test:run` *(fails only in existing root-environment `resolve-permission-mode` expectations: `bypassPermissions` falls back to `default` when run as root; unrelated to usage updates)* --------- Signed-off-by: Emre Koca <110906681+kocaemre@users.noreply.github.com> Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.13 |
||
|
|
df38cccae0 |
fix: recreate resumed sessions when any session option changes (#1097)
A warm `session/resume` or `session/load` currently ignores changed `maxTurns` and `maxBudgetUsd`: the session fingerprint compares only cwd and MCP servers, so the SDK query retains its old options. A client can request a tighter limit and receive success while the old limit remains active. Include these two SDK execution limits in the session fingerprint. Adding, changing or removing a limit recreates the query with the supplied options and the same session ID. Identical limits reuse the existing query; object key order does not trigger recreation. Budget accounting across recreated SDK processes remains the client's responsibility. Validation: - Four regression cases failed before the fix; six new cases cover both methods, both limits, tightening/removal, and unchanged reuse. - `npm run check` and `npm run build` passed. - Focused suites: 551 passed, 9 skipped. - Full suite with `--maxWorkers=2`: 1,240 passed, 27 skipped. An initial unrestricted run hit one existing provider-switch test's 5s timeout and macOS `EMFILE` watcher errors; bounding workers passed without changing tests or timeouts. Prepared while integrating typed runtime limits in BinaryBourbon/fountain#1732. No live SDK budget-enforcement claim is made by these adapter tests. --------- Signed-off-by: Jake Gaylor <jhgaylor@gmail.com> Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.12 |
||
|
|
39062b63ff |
fix: preserve context usage when quota is exhausted (#1132)
Synthetic usage-limit frames from the Claude SDK carry an all-zero usage object. When one follows a real assistant response, the ACP bridge currently overwrites the latest context measurement and emits a final `usage_update` with `used: 0`. Keep the previous measurement for a synthetic usage-limit frame when one exists. A fresh quota-limited turn remains zero. Includes a regression test covering a 170,910-token context followed by a synthetic spend-limit frame. Verified with: - `npx vitest run src/tests/acp-agent.test.ts` - `npm run check` - `npm run build` --------- Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.11 |
||
|
|
29a4e98477 |
fix: preserve native Vertex endpoint defaults (#1104)
## Summary - keep `ANTHROPIC_VERTEX_BASE_URL` unset when `providers/set` selects Vertex's native default endpoint - retain explicit `ANTHROPIC_VERTEX_BASE_URL` only for custom Vertex gateways/endpoints - add a regression test for the default Vertex endpoint env mapping Closes #1087 ## Test Plan - `npm run test:run -- src/tests/providers.test.ts` — passed (21 tests) - `npm run check` — passed (`eslint src --ext .ts` + `prettier --check .`) - `npm run build` — passed (`tsc`) - `git diff --check origin/main..HEAD` — passed Note: `claude -p` delegation was attempted for candidate discovery but this cron shell's Claude Code auth is not logged in (`Not logged in · Please run /login`), so the implementation/validation above was done directly with local tests. Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>v0.81.1-preview.10 |
||
|
|
6e97e071c5 |
fix: gate login result text on error state (#1103)
## Summary - Fixes #1092 by treating `Please run /login` in a `success` result as auth-required only when the result is actually error-shaped. - Applies the same error-state guard to goal-command failure detection so quoted login text in a normal answer does not roll back the active goal. - Adds a regression test for a successful model answer that mentions `/login` without publishing a session failure. ## Test Plan - [x] `npm run test:run -- src/tests/acp-agent.test.ts -t 'login|auth_required'` - [x] `npm run build` - [x] `npm run check` - [ ] `npm run test:run` (blocked locally by pre-existing root permission-mode assertions: `resolvePermissionMode("bypassPermissions")` and `resolvePermissionMode("bypass")` resolve to `default` when running as root) Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>v0.81.1-preview.9 |
||
|
|
2b0201a801 |
test: tolerate minute-aligned scheduled wakeups (#1044)
## Summary - allow the scheduled-wakeup live audit to wait through the full minute-alignment window - keep a small buffer for the autonomous model turn to complete - raise the Vitest case timeout accordingly `ScheduleWakeup(delaySeconds=60)` is persisted as a minute-aligned cron entry. Depending on where scheduling lands within a minute, delivery can take close to two minutes. The previous 75-second predicate timeout can therefore fail even though the idle ACP stream delivers the wakeup correctly. I reproduced both outcomes against current `main`: one run timed out at 75 seconds, while a second run delivered `LIVE_WAKE_OK` through the idle ACP stream. Related: #838 ## Verification - `npm run check` - `npm run build` - `npm run test:run` (971 passed, 27 skipped) - live SDK/ACP probe on Agent SDK 0.3.238 observed `SCHEDULED` followed by autonomous `LIVE_WAKE_OK` while idle |
||
|
|
97394d93b6 |
fix: replay marker-only slash skill prompts (#1035)
## Summary - reconstructs marker-only model-bound slash skill prompts during history replay - keeps client/local command metadata hidden when local stdout/stderr is present - adds regression coverage for both string and content-array transcript shapes Closes #998. ## Verification - `npm run test:run -- src/tests/acp-agent.test.ts -t 'stripLocalCommandMetadata'` - `npm run test:run -- src/tests/acp-agent.test.ts` - `npm run build` - `npm run check` - `git diff --check` I also ran `npm run test:run`. It completed with 965 passing tests, 27 skipped, and the same two root-environment `resolve-permission-mode` failures seen when running as root: `bypassPermissions` is intentionally downgraded to `default` in that environment. The changed replay/metadata tests passed. Signed-off-by: Emre Koca <1328630750+kocaemre@users.noreply.github.com> Co-authored-by: Emre Koca <1328630750+kocaemre@users.noreply.github.com>v0.81.1-preview.8 |
||
|
|
388a0f5191 |
fix(session): recreate query when configured skills change (#968)
## Summary - include normalized Claude SDK `skills` in the resumed-session fingerprint - preserve the distinct semantics of omitted, `'all'`, empty, and explicit skill selections - avoid unnecessary Query recreation for reordered or duplicate skill names - keep unrelated `_meta.claudeCode.options` fields out of the fingerprint - recreate the Query with the same native session ID when skills change - merge the latest `origin/main` so the change is validated against the current session logic and SDK 0.3.238 ## Testing - clean Linux Node 22 environment with `@anthropic-ai/claude-agent-sdk@0.3.238` - `npm run build` - `npm run lint` - `npm run check` - targeted lifecycle tests: `425 passed, 9 skipped` - full test suite: `978 passed, 27 skipped` - successful lifecycle case: `newSession(['pdf']) -> resumeSession(['docx'])` Closes #955v0.81.1-preview.7 |
||
|
|
9392c69cc6 |
fix: settle steered turns on the result that answers the steer (#1166)
Fixes #1114. ## Problem A steered turn settles only at an SDK `idle`, and only once the steer's echo has been replayed and an outcome recorded. Two ways that never happens, both from #1114: - **Missing echo.** If the CLI never replays the steered message, every idle is swallowed and `session/prompt` parks until cancel or the next prompt. - **Owed-idle debt eats the settling idle.** If the steer aborts an autonomous followup, that followup's result counts a trailing idle, but the abort folds it into the one idle that spans both cycles. The debt lane absorbs that idle and the steered turn never settles. ## Fix 1. **Exact lane: settle on the result that answers the steer.** A result whose `user_message_uuids` (falling back to `user_message_uuid`) names one of the turn's steers retires that steer's echo, even if the CLI never replayed it. Once no steer is outstanding, the turn leaves the steer lane and settles at that result through the ordinary lanes, including the subagent hold and failure lanes. It owes its trailing idle like any other settling result. No timer. 2. **Idle fallback, for producers that don't stamp results: count only a result recorded after the last echo.** Before this, the outcome of the cycle the steer interrupted (or a held turn's outcome that `steer()` moved over) made the turn look ready as soon as the echo landed. `steeredAwaitingResult` is set when an echo drains and cleared when a result is recorded. 3. **A ready steered turn takes the idle ahead of owed-idle debt.** Its outcome is final, so whichever idle arrives settles it correctly. The debt is left standing: a separate trailing idle still absorbs the idle it belongs to, and one that never comes is cleared by the existing sweep at the next `running` transition. A steered turn that isn't ready still goes through the debt lane first, so an earlier turn's late idle can never settle a steered cycle that's still running. ## Live verification (CLI 2.1.280, SDK 0.3.280) A probe with the adapter's query options (`replay-user-messages`, partial messages) steered a running turn three ways: mid-generation at `now`, mid-tool-call at `now`, and mid-tool-call at `later`. All three had the same frame order: ``` RESULT stamp=ORIG stamps=[ORIG] <- interrupted (or finished) original cycle lifecycle ORIG cancelled|completed lifecycle STEER started ECHO STEER RESULT stamp=STEER stamps=[STEER] <- steered cycle lifecycle STEER completed STATE idle <- the only idle ``` So the interrupted cycle's result never names the steer, and the steered cycle's result always does. `later` doesn't fold the steer into the running turn either; it runs as its own cycle after the original finishes, with no idle in between. ## Tests Three new tests in `turn steering (_session/steering)`: - **Echo missing, stamped result:** the turn settles at the result before any idle, and the idle that follows is absorbed. Hangs on `main`. - **Steer aborts an autonomous followup, only one idle:** the turn settles. Hangs on `main`. - **Owed idle arrives after the echo but before the steered result:** the turn must not settle on it, and it ends with both cycles' usage. Passes on `main`, but fails with the post-echo readiness check removed, so it guards against settling early on a pre-steer outcome. `npm run build`, `npm run test:run` and `npm run check` pass. ## Remaining gap If the echo never replays and the result carries no stamp (older producers), the turn still waits for cancel or the next prompt, as documented before. Supersedes #1115 and #1063. Thanks to @KlausUllrich for the #1114 analysis and the result-acknowledgement idea, which this builds on. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.6 |
||
|
|
281e47eb81 |
fix: honor permissions.disableBypassPermissionsMode (#1165)
## Problem Claude Code refuses `bypassPermissions` when any settings tier sets `permissions.disableBypassPermissionsMode` to `"disable"`. The adapter ignored the setting: it still listed the Bypass mode, passed `allowDangerouslySkipPermissions`, and accepted `defaultMode: "bypassPermissions"` as the starting mode. ## Change Fold the setting into `allowBypass` at session creation. That single value already drives the mode catalog, the SDK flag and the spawn-time mode clamp, so all three now agree with the CLI. Like the CLI, the setting is honored from any tier. It can only take away a permission, so project settings are trusted for it. ## Validation - `npm run build`, `npm run check` and `npm run test:run` pass. - New tests set the option in user settings and in project settings. Both fail without the fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.5 |
||
|
|
43c27e97aa |
fix: offer bypass alongside auto in plan approval (#1164)
Supersedes #1140 by @s-cork. Their commit is kept as-is (rebased onto `main`), plus one follow-up commit. The fork is org-owned, so maintainers can't push to it. ## Problem ExitPlanMode always led with Auto and dropped bypass, even when the session advertised `bypassPermissions`. Clients that deliberately run in full-access mode lost that choice at plan approval. Claude Code itself offers one elevated choice and prefers bypass over Auto. It can do that because the CLI only offers bypass to users who launched with it. The adapter advertises bypass for every non-root session, so copying that priority would hide Auto for almost everyone. ## Change - Offer both Auto and bypass whenever the session advertises them (@s-cork's commit). - Follow-up: remember the mode the session left when it entered plan mode (`SessionModeManager.syncConfig`, which every mode change goes through, including plan approval since #1163). If that was `bypassPermissions`, bypass comes first and is also what the clear-context option uses. Otherwise Auto leads, as before. A remembered bypass mode is ignored if the session no longer advertises it. This also fills the gap where the clear-context choice only ever came in the Auto flavour. Partially addresses #1077. ## Validation - `npm run build`, `npm run check` and `npm run test:run` pass. - New tests cover the pre-plan mode tracking and the option order with and without a pre-plan bypass mode, including the clear-context row. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: stu <stucork@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
bd059c10e0 |
fix: mark informational chunks with metadata (#1055)
## Summary - tag SDK `informational` notices with `_meta.claudeCode.kind = "informational"` - include the notice `level` so clients can separate hook/status notices from model text - keep the existing rendered text unchanged for clients that ignore `_meta` Fixes #1042 ## Test plan - `npm test -- --run src/tests/acp-agent.test.ts -t informational` - `npm run build` - `npm run check` - `IS_SANDBOX=1 npm run test:run` - `git diff --check` --------- Signed-off-by: Emre Koca <110906681+kocaemre@users.noreply.github.com> Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.4 |
||
|
|
58c5db1fdc |
fix: keep the agent starting when the managed-policy tier cannot be read (#1146)
Fixes #1124. ## The defect `src/index.ts` awaited `resolveSettings` at module scope with nothing around it: ```ts const policy = await resolveSettings({ settingSources: [] }); for (const [key, value] of Object.entries(policy.effective.env ?? {})) { process.env[key] = value; } ``` That is a top-level `await` in an ESM entry point, so a rejection aborts module evaluation and the process exits before serving any ACP traffic. The client only sees a process that exited 1 with no protocol messages. Two neighbours make this the only call that can do it, and both are still true on \`main\`: - `SettingsManager.loadAllSettings` (`src/settings.ts:105-113`) wraps the same SDK call in `try`/`catch` and falls back to `{}`. - The `process.on("unhandledRejection", ...)` handler is registered at \`src/index.ts:62\`, after this await, so it does not cover it. Reading the managed tier is best-effort by nature — on a host with no MDM and no managed policy the result is empty and the agent behaves identically — so a transient `EINTR`/`EMFILE`/`EAGAIN` while reading it should leave the agent running with no policy env rather than stop it from starting. ## The change The guard lives in a new `src/managed-policy.ts` rather than inline, for one reason: `src/index.ts` is an ESM entry point with top-level side effects, so nothing in it can be imported by a test. Extracting the tier read makes the failure path testable, which is what the regression test below exercises. `applyManagedPolicyEnv` mirrors `loadAllSettings`: it takes the SDK call through a parameter defaulting to `resolveSettings` and a target env defaulting to `process.env`, reports the failure on stderr, and returns without applying anything. `src/index.ts` becomes: ```ts await applyManagedPolicyEnv(); ``` `console.error` is correct here: this runs before stdout is redirected, so the ACP stream stays clean. ## Verification Four tests in `src/tests/managed-policy.test.ts` cover the applied case, an empty tier, a tier with no `env` table, and the failure path — the last one asserts the promise **resolves** rather than rejects, with the target env untouched, which is the property the entry point depends on. ``` before after tests 17 failed | 1366 passed 17 failed | 1370 passed ``` The 17 failures are pre-existing in this checkout and untouched by this change; the four added tests account for the difference. `eslint src --ext .ts`, `tsc`, and `prettier --check` (with the repository's `.prettierrc.json`) are clean on the three files. ## Note I have not established whether those 17 pre-existing failures are host-specific or real, so I am not claiming anything about them or changing anything for them.v0.81.1-preview.3 |
||
|
|
a2f4239543 |
fix: publish effective mode after plan approval (#1163)
Supersedes #1139 by @s-cork. Their commit is kept as-is (rebased onto `main`), plus one follow-up commit. The fork is org-owned, so maintainers can't push to it. ## Problem Approving a plan through ExitPlanMode changes the SDK permission mode, but ACP clients keep showing Plan. When Auto isn't available for the current model, clients should also see the fallback mode that actually applies. ## Change - After an ExitPlanMode permission is allowed, send `current_mode_update` and `config_option_update` with the session mode as it stands after `applyPermissionFallback`. Rejection and clear-context handling don't change. - Follow-up: wrap those two notifications in a try/catch. The plan is already approved at that point, so a rejected `sessionUpdate` is logged and no longer turns the approval into a failed permission request. This matches `publishFallbackWarning`. Partially addresses #1077. It doesn't fix session restoration after a clear-context approval. ## Validation - `npm run build`, `npm run check` and `npm run test:run` pass. - Regression tests cover the ordinary default, bypass and Auto approvals, plus Auto falling back to acceptEdits. They check both the stored mode and both ACP notifications. - A new test rejects the mode notification and checks that the approval still returns `allow` with the `setMode` update. It fails without the follow-up fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: stu <stucork@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.2 |
||
|
|
90cde4b397 |
fix: render Write tool calls that use path/file_text aliases (#1161)
Claude Code 2.1.280 (SDK 0.3.280, bumped in #1157) now accepts Write calls where the model sends `path` instead of `file_path`, or `file_text`/`file_content` instead of `content`. The CLI renames these for its own validation, but the streamed `tool_use` block keeps the model's original field names. So we showed the call as "Preparing file…" with no diff or location, even though the write went through. `toolInfoFromToolUse` now reads those fields the same way the CLI does. When both spellings are present, the canonical fields win. Nothing else in the 0.3.280 / 2.1.280 changelog needed an adapter change. I checked Opus 5.5 model rows, the hand-back frame header, `requires_action` during MCP elicitation, and headless elicitation cancellation. ## Test plan - New `toolInfoFromToolUse - Write input aliases` tests - `npm run build`, `npm run check`, `npm run test:run` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>v0.81.1-preview.1 |
||
|
|
d571358e26 |
chore(main): release 0.81.0 (#1156)
🤖 I have created a release *beep* *boop* --- ## [0.81.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.80.0...v0.81.0) (2026-09-22) ### Features * **deps:** update Claude SDK ([#1157](https://github.com/agentclientprotocol/claude-agent-acp/issues/1157)) ([v0.81.0 |
||
|
|
eb989e93f4 | feat(deps): update Claude SDK (#1157) v0.80.1-preview.2 | ||
|
|
79851b8668 | feat: Send experimental session notices for live advisories (#1155) v0.80.1-preview.1 | ||
|
|
16c9d1a3af |
chore(main): release 0.80.0 (#1151)
🤖 I have created a release *beep* *boop* --- ## [0.80.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.79.0...v0.80.0) (2026-09-22) ### Features * **deps:** Bump claude-agent-sdk to 0.3.278 ([#1147](https://github.com/agentclientprotocol/claude-agent-acp/issues/1147)) ([v0.80.0 |