Compare commits

...

3 Commits

Author SHA1 Message Date
acp-release-bot[bot]
4af4581ad5 chore(main): release 0.109.1 (#1675)
🤖 I have created a release *beep* *boop*
---


##
[0.109.1](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.109.0...v0.109.1)
(2026-11-21)


### Bug Fixes

* announce a live subagent again when its session is loaded or resumed
([#1688](https://github.com/agentclientprotocol/claude-agent-acp/issues/1688))
([b977017](b977017ed8))
* apply a provider's route to the running session
([#1691](https://github.com/agentclientprotocol/claude-agent-acp/issues/1691))
([988a58b](988a58b908))
* give a forked skill's child session its tool calls and text
([#1677](https://github.com/agentclientprotocol/claude-agent-acp/issues/1677))
([1c90fb9](1c90fb959a))
* keep built-in web-fetch and claude-code-guide agents out of the Agent
picker
([#1672](https://github.com/agentclientprotocol/claude-agent-acp/issues/1672))
([eb4c16f](eb4c16f10a))
* match v1 session/options to resume when workspace roots change
([#1679](https://github.com/agentclientprotocol/claude-agent-acp/issues/1679))
([184b7df](184b7df993))
* reject requests that name a replayed subagent session with -32602
([#1686](https://github.com/agentclientprotocol/claude-agent-acp/issues/1686))
([3304ca7](3304ca724c))
* report unusable Claude subscriptions as unauthenticated
([#1678](https://github.com/agentclientprotocol/claude-agent-acp/issues/1678))
([a4f0f78](a4f0f78bb3))
* send a replayed subagent's configuration after the replay, not inside
it
([#1685](https://github.com/agentclientprotocol/claude-agent-acp/issues/1685))
([6a760cb](6a760cbca6))
* show readable titles for MCP tool calls
([#1674](https://github.com/agentclientprotocol/claude-agent-acp/issues/1674))
([80440d8](80440d8b82))
* update to @agentclientprotocol/sdk 2.9.0
([#1687](https://github.com/agentclientprotocol/claude-agent-acp/issues/1687))
([022ff53](022ff53244))
* update to @agentclientprotocol/sdk 2.9.1
([#1690](https://github.com/agentclientprotocol/claude-agent-acp/issues/1690))
([85a0d6c](85a0d6c6f1))
* update to @anthropic-ai/claude-agent-sdk 0.3.330
([#1689](https://github.com/agentclientprotocol/claude-agent-acp/issues/1689))
([6d9e276](6d9e2766c7))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: acp-release-bot[bot] <246668977+acp-release-bot[bot]@users.noreply.github.com>
2026-11-21 16:33:53 +01:00
Ben Brandt
988a58b908 fix: apply a provider's route to the running session (#1691)
## Summary

Both cores now send the route of a provider, or of a gateway login, to
Claude Code a second time: right after a session starts, with
`applyFlagSettings()`.

The route is already part of the query's `settings` option, in one
object with the client's settings and the model configuration of the
environment. Claude Code loads that object as a whole or not at all: one
value that fails validation leaves all of it out. Since 2.1.330 it says
so in a warning (see #1689). The second delivery does not depend on that
object.

## What changes

- **One place for the route as settings.** `providerRouteSettings()` in
`src/providers.ts` builds it: `apiKeyHelper: ""` and the env of
`createEnvForProvider()`. Both cores built that object on their own
before.
- **`applyProviderRoute()`** in the same module sends it to a running
query. v1 and v2 call it right after the query's initialize response,
before a request of the session reaches the provider. The context read
is such a request: `getContextUsage()` sends `count_tokens`.
- **A session without a provider or gateway login** gets no such call.
- **When Claude Code refuses the call, the session is not started.** The
request fails with `-32603`, "The session was not started, because
Claude Code did not take its provider or gateway route. Try again, or
set the provider or the gateway login again.", and Claude Code's text in
`data.details`. The adapter builds the route itself, and I know no input
that makes Claude Code refuse it.

## What a client can notice

Nothing when its `settings` load. The call then changes nothing: Claude
Code merges `env` key by key, and the values are the ones of the
`settings` option. Recorded with the real CLI: after the call, the flag
settings still hold the client's own `env` keys and its `permissions`.

When a value of its `settings` fails validation, the client's settings
are not in effect, as before. The route of the provider is.

## Testing

- `npm run build`, `npm run check`, `npm run test:run` (4,437 tests
pass)
- Each core has a test that the route is applied (on v1: before the
first context read), and a test that a refused route starts no session
and releases the query. They fail without the change.
- Real CLI: a new test in `v2/v2-integration.test.ts` with two local
servers, so it costs no API usage. One is the provider. The project's
`.claude/settings.json` names the other as `ANTHROPIC_BASE_URL`, and the
client's `settings` hold `permissions.allow: "Bash"`. The session's
model requests reach the provider's server. The test fails without the
change. It passes with Claude Code 2.1.330 and 2.1.328, and with a CLI
named in `CLAUDE_CODE_EXECUTABLE`, which gets its settings in a flag.
- Real CLI through the built adapter, with the same two servers: on v1
and on v2, with valid and with invalid client `settings`, every model
request reaches the provider's server.
- Real CLI: the whole suite, as `npm run test:integration` runs it (with
`CLAUDE_CODE_ENTRYPOINT` unset): 4,470 tests pass and 9 are skipped (the
live capability audits, the baseline recording, and one test that skips
itself)
2026-11-21 15:28:56 +00:00
Ben Brandt
6d9e2766c7 fix: update to @anthropic-ai/claude-agent-sdk 0.3.330 (#1689)
## Summary

Updates `@anthropic-ai/claude-agent-sdk` from 0.3.328 to 0.3.330, which
bundles Claude Code 2.1.330. The adapter's code does not change: the
build passes, and no changelog entry needs a change.

Also bumps the dev dependency `@anthropic-ai/sdk` 1.10.0 → 1.12.0.

`npm update` brings the in-range lockfile bumps: `@babel/runtime`
7.29.14 → 7.29.15, `@hono/node-server` 2.1.9 → 2.1.11 and
`source-map-js` 1.2.3 → 1.2.4.

TypeScript stays at 6.0.3: 7.0.2 is out, but `@typescript-eslint/parser`
8.73.0 still requires `typescript <6.1.0`.

## Changelog review

Read the SDK changelog for 0.3.329 and 0.3.330 and the Claude Code
changelog for 2.1.329 and 2.1.330, and compared `sdk.d.ts` and
`sdk-tools.d.ts` of 0.3.328 and 0.3.330.

### What a client can notice

- **A warning when settings do not load** (0.3.330). When a value in a
session's `settings` or in a settings file fails validation, Claude Code
leaves the whole object or file out, as before. It now says so in the
session's first turn, in an `informational` message at level `warning`
(tag `settings_not_in_effect`). Both cores pass such a message on: as a
`notice` with `severity: "warning"` on v2 and for a v1 client with
`session.notices`, as quoted `**Warning:**` text for other v1 clients.
Checked through the built adapter, see Testing.
- **A warning when the hooks of managed settings do not load** (0.3.329,
tag `managed_hooks_not_loaded`). The same kind of message, passed on the
same way. Not reproduced: it needs managed settings.
- **The Fast mode state of a new session is that of its model.** The
initialize response's `fast_mode_state` described the default model, and
both cores set the Fast mode option of a new session from it. Recorded
with `settings: { model: "haiku", fastMode: true }`: `on` with 0.3.328,
`off` with 0.3.330.
- **A login that the macOS Keychain cannot save** ends a request with
`invalid_request` and no status, not with `authentication_failed` and
401. The adapter then fails the prompt with Claude Code's text ("… can't
save to the Keychain …") and no longer asks the client to sign in again.
Read from the changelogs and the CLI's text, not reproduced.
- **Prompt suggestions.** Claude Code now drops a placeholder such as
`_(no suggestion)_` where it generates the suggestion, so the adapter's
suggestion updates do not carry one.
- **claude.ai connectors are in the server list of `system/init` at
once.** Before, the list was empty at start and they came later. The
startup notices of both cores cover the client's own MCP servers only,
so a client gets no new notice.

### No change for the adapter

- **Types.** Doc text, plus:
- two `Settings` keys, `permissions.workingDirectoriesExclude` and
`desktopMcpServersListScope`
- the subkind `external-event` of a `task-notification` origin, which
only a session server stamps
  - `maxAgeMs` and `otherOneShots` on the output of `CronCreate`
- **`query()` refuses a `settings` JSON string that does not parse**,
when the `sandbox` option is set. The adapter passes no string: it reads
a client's settings file itself and passes an object.
- **Request ids of SDK MCP servers.** The adapter starts none.
- **`rewind_conversation` and `SpareProcess.claim()`.** Not used.
- **Background agents.** A stopped agent stays stopped, and Claude no
longer waits for an agent that `stopTask()` stopped as it finished.
Picked up as they are.
- **The system prompt after a model change that follows a context read,
and the memory use of idle sessions.** Picked up as they are.
- **The shorter sign-in link.** The adapter runs `claude auth login` in
the client's terminal and reads no link.
- **`getSessionInfo`, `listSessions` and `getSessionMessages`** read a
transcript as before: a differential run of 0.3.328 against 0.3.330 over
4,500 generated transcripts gave no mismatch. The run is not part of
this PR.
- **`@anthropic-ai/sdk` 1.11.0 and 1.12.0.** The adapter uses its types
only. The releases add Admin API methods and an error code, and fix the
client's default headers.

## Testing

- `npm run build`, `npm run check`, `npm run test:run` (4,434 tests
pass), on `main` with #1690
- Real CLI: the whole suite, as `npm run test:integration` runs it (with
`CLAUDE_CODE_ENTRYPOINT` unset). Before #1690 landed, the run passed in
full: 4,465 tests pass and 9 are skipped (the live capability audits,
the baseline recording, and one test that skips itself). On `main` with
#1690, on a machine under heavy load, 4,460 pass; one timing test of
`v1/acp-agent.test.ts` failed, and the 10-second build hook of the v1
subprocess tests timed out, which skipped those five. All six pass when
run again by themselves.
- Real CLI through the built adapter: one Haiku prompt in a session
whose client `settings` hold `permissions.allow: "nope"`. On v1 without
`session.notices` the warning is quoted text, on v1 with it and on v2 it
is a `notice`. Each time it comes inside the turn, before the answer.
- Real SDK and CLI without a prompt, 0.3.328 against 0.3.330: the Fast
mode state per model, the settings read for valid and invalid settings,
and the MCP server list at start
2026-11-21 16:18:08 +01:00
14 changed files with 313 additions and 70 deletions

View File

@@ -1,3 +1,3 @@
{
".": "0.109.0"
".": "0.109.1"
}

View File

@@ -1,5 +1,23 @@
# Changelog
## [0.109.1](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.109.0...v0.109.1) (2026-11-21)
### Bug Fixes
* announce a live subagent again when its session is loaded or resumed ([#1688](https://github.com/agentclientprotocol/claude-agent-acp/issues/1688)) ([b977017](https://github.com/agentclientprotocol/claude-agent-acp/commit/b977017ed88148fbbc8bdd6e24cd275313c546e6))
* apply a provider's route to the running session ([#1691](https://github.com/agentclientprotocol/claude-agent-acp/issues/1691)) ([988a58b](https://github.com/agentclientprotocol/claude-agent-acp/commit/988a58b908d55a933e9d297c142e9040d478bd69))
* give a forked skill's child session its tool calls and text ([#1677](https://github.com/agentclientprotocol/claude-agent-acp/issues/1677)) ([1c90fb9](https://github.com/agentclientprotocol/claude-agent-acp/commit/1c90fb959a003eba1eed1dac94400c9cdef63195))
* keep built-in web-fetch and claude-code-guide agents out of the Agent picker ([#1672](https://github.com/agentclientprotocol/claude-agent-acp/issues/1672)) ([eb4c16f](https://github.com/agentclientprotocol/claude-agent-acp/commit/eb4c16f10a753925090289c21f2d95bd902a7b63))
* match v1 session/options to resume when workspace roots change ([#1679](https://github.com/agentclientprotocol/claude-agent-acp/issues/1679)) ([184b7df](https://github.com/agentclientprotocol/claude-agent-acp/commit/184b7df993c0c64df593188f15bb0e5206f3e6fb))
* reject requests that name a replayed subagent session with -32602 ([#1686](https://github.com/agentclientprotocol/claude-agent-acp/issues/1686)) ([3304ca7](https://github.com/agentclientprotocol/claude-agent-acp/commit/3304ca724c25c7258c837cc0394adb4111ea8987))
* report unusable Claude subscriptions as unauthenticated ([#1678](https://github.com/agentclientprotocol/claude-agent-acp/issues/1678)) ([a4f0f78](https://github.com/agentclientprotocol/claude-agent-acp/commit/a4f0f78bb31539005d0d54ab69f7e28f91443b14))
* send a replayed subagent's configuration after the replay, not inside it ([#1685](https://github.com/agentclientprotocol/claude-agent-acp/issues/1685)) ([6a760cb](https://github.com/agentclientprotocol/claude-agent-acp/commit/6a760cbca64adc72634274088914e99a51da084a))
* show readable titles for MCP tool calls ([#1674](https://github.com/agentclientprotocol/claude-agent-acp/issues/1674)) ([80440d8](https://github.com/agentclientprotocol/claude-agent-acp/commit/80440d8b8294f9d4cd086d7cba39c716107657f0))
* update to @agentclientprotocol/sdk 2.9.0 ([#1687](https://github.com/agentclientprotocol/claude-agent-acp/issues/1687)) ([022ff53](https://github.com/agentclientprotocol/claude-agent-acp/commit/022ff532449371198a0d715a921578e27c101532))
* update to @agentclientprotocol/sdk 2.9.1 ([#1690](https://github.com/agentclientprotocol/claude-agent-acp/issues/1690)) ([85a0d6c](https://github.com/agentclientprotocol/claude-agent-acp/commit/85a0d6c6f111119855b0e199801a9f71b60f50bf))
* update to @anthropic-ai/claude-agent-sdk 0.3.330 ([#1689](https://github.com/agentclientprotocol/claude-agent-acp/issues/1689)) ([6d9e276](https://github.com/agentclientprotocol/claude-agent-acp/commit/6d9e2766c74dcd9ccd5c5a83b8523b65c234041f))
## [0.109.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.108.1...v0.109.0) (2026-11-19)

104
package-lock.json generated
View File

@@ -1,16 +1,16 @@
{
"name": "@agentclientprotocol/claude-agent-acp",
"version": "0.109.0",
"version": "0.109.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@agentclientprotocol/claude-agent-acp",
"version": "0.109.0",
"version": "0.109.1",
"license": "Apache-2.0",
"dependencies": {
"@agentclientprotocol/sdk": "2.9.1",
"@anthropic-ai/claude-agent-sdk": "0.3.328",
"@anthropic-ai/claude-agent-sdk": "0.3.330",
"diff": "9.0.0",
"zod": "4.6.7"
},
@@ -18,7 +18,7 @@
"claude-agent-acp": "dist/index.js"
},
"devDependencies": {
"@anthropic-ai/sdk": "1.10.0",
"@anthropic-ai/sdk": "1.12.0",
"@eslint/js": "10.0.1",
"@tsconfig/node22": "22.0.7",
"@types/node": "26.6.6",
@@ -53,22 +53,22 @@
}
},
"node_modules/@anthropic-ai/claude-agent-sdk": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk/-/claude-agent-sdk-0.3.328.tgz",
"integrity": "sha512-YcOWlpXVm7etPjPVrvSJEfynDksMiG11zvEybSBnk1EVWji6rSjU75HbbhJ8XPEB2ECEwRRP597Udu6IWMtsDw==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk/-/claude-agent-sdk-0.3.330.tgz",
"integrity": "sha512-7om9Xus6tfkeCUCfzg6ilJuN6Z7okkEvJ0mx+ukXa/Id5U/6BGtPkOYni+3ebedwa3b9SVF7A05+ln+/9EoU/w==",
"license": "SEE LICENSE IN README.md",
"engines": {
"node": ">=18.14.0"
},
"optionalDependencies": {
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.328",
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.328",
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.328",
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.328",
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.328",
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.328",
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.328",
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.328"
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "0.3.330",
"@anthropic-ai/claude-agent-sdk-darwin-x64": "0.3.330",
"@anthropic-ai/claude-agent-sdk-linux-arm64": "0.3.330",
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "0.3.330",
"@anthropic-ai/claude-agent-sdk-linux-x64": "0.3.330",
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "0.3.330",
"@anthropic-ai/claude-agent-sdk-win32-arm64": "0.3.330",
"@anthropic-ai/claude-agent-sdk-win32-x64": "0.3.330"
},
"peerDependencies": {
"@anthropic-ai/sdk": ">=0.93.0",
@@ -77,9 +77,9 @@
}
},
"node_modules/@anthropic-ai/claude-agent-sdk-darwin-arm64": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-arm64/-/claude-agent-sdk-darwin-arm64-0.3.328.tgz",
"integrity": "sha512-vjBASSSZFNs5M84XONCM4xAJMKPD0E9RtF0UDQ/a1Qqt5L+slNxhSADkH5n0tEM5HJMK7j9DCPi+0FVOBpZr3w==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-arm64/-/claude-agent-sdk-darwin-arm64-0.3.330.tgz",
"integrity": "sha512-J9nqvcfD2V90O5uoR8At66R51VYtSMKnxSmPc0S4A4F5oX1VbokcpJLXU1yVCOuTtzr/OIHjRr9nn2vKi/S6rQ==",
"cpu": [
"arm64"
],
@@ -90,9 +90,9 @@
]
},
"node_modules/@anthropic-ai/claude-agent-sdk-darwin-x64": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-x64/-/claude-agent-sdk-darwin-x64-0.3.328.tgz",
"integrity": "sha512-pkZuDNi16H4yJFo6cS2sw8mFj7m7ESAxV74t2gQ9EFzZOpXbQoJqhPBHNEZJ2q/+kr/3vHUtRc2W6jURA6nS+A==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-darwin-x64/-/claude-agent-sdk-darwin-x64-0.3.330.tgz",
"integrity": "sha512-woe+f9qeZYWML5fACibNyth0xMDf22riNRNDryIYuhdteh7IoWrK6zC31cC2MrZRoqDZcPVtfOLND79+iZbrLA==",
"cpu": [
"x64"
],
@@ -103,9 +103,9 @@
]
},
"node_modules/@anthropic-ai/claude-agent-sdk-linux-arm64": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64/-/claude-agent-sdk-linux-arm64-0.3.328.tgz",
"integrity": "sha512-VvsUzOEf7r3ZtOPfliNGxqknsIvxEmnUOtQnq4+uw7MsfiALKR4s0bx2SP32UuXpqbmqxR1gn456D27XgsAmnA==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64/-/claude-agent-sdk-linux-arm64-0.3.330.tgz",
"integrity": "sha512-2Q+kfzaoTvJv1rsyu+iR4UHDZ3nxiOfdXISk+2ydQShU9DqXNlgQAt3BdJMh0Yx4MrxB66TMphVvVQeRslwwhA==",
"cpu": [
"arm64"
],
@@ -119,9 +119,9 @@
]
},
"node_modules/@anthropic-ai/claude-agent-sdk-linux-arm64-musl": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64-musl/-/claude-agent-sdk-linux-arm64-musl-0.3.328.tgz",
"integrity": "sha512-4Vui26/OZwr8AU7FpAt+R5s/1AKmj5qDorUZIqF1MMfdjAQf8/ut/+HyEkuMom/MVF2JeQLdvnFFFmbfgmAq/g==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-arm64-musl/-/claude-agent-sdk-linux-arm64-musl-0.3.330.tgz",
"integrity": "sha512-fXmuAEegw31v+kiBd51yn7RVhjs7Rz2lnhfx/+XJXqt5lyqR2v7Ul/U/9r1CQZKuIw8M3ms9jQqGpmKbgKndqQ==",
"cpu": [
"arm64"
],
@@ -135,9 +135,9 @@
]
},
"node_modules/@anthropic-ai/claude-agent-sdk-linux-x64": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64/-/claude-agent-sdk-linux-x64-0.3.328.tgz",
"integrity": "sha512-saP4fWgVZj1n7MYCqvTKADHXIc/hIAMRDpLVpXD5xB0IT68vhWgIMkzIrsg5P02P6zA49TDuoijbP1YBUEXT4A==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64/-/claude-agent-sdk-linux-x64-0.3.330.tgz",
"integrity": "sha512-9w4uMdA3vNZXocwOUhivOGotXoRDxN/C/xPMkZMY9WPpKLAlj8upMZskNgPjQKlVRXhxPfNagcBijGPUH4WepA==",
"cpu": [
"x64"
],
@@ -151,9 +151,9 @@
]
},
"node_modules/@anthropic-ai/claude-agent-sdk-linux-x64-musl": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64-musl/-/claude-agent-sdk-linux-x64-musl-0.3.328.tgz",
"integrity": "sha512-oJowzzjhWGbdBGyRjqV9CT0nfh4A4/fEI11LjX6b1SkhrNNgy9QT2HzSe8A2yNlliOWo1xJl6nAHT8pLwMNlVg==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-linux-x64-musl/-/claude-agent-sdk-linux-x64-musl-0.3.330.tgz",
"integrity": "sha512-kooZMdp6tFwNFkDXbGoNTZMgFcPQfJVfG+gZ2qAdkk11S6MFts9ybHRLQmzUK3VrqlahH7T9fmI2mNfzYgOXkw==",
"cpu": [
"x64"
],
@@ -167,9 +167,9 @@
]
},
"node_modules/@anthropic-ai/claude-agent-sdk-win32-arm64": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-arm64/-/claude-agent-sdk-win32-arm64-0.3.328.tgz",
"integrity": "sha512-FkqzA++c+giPH2k8svb0egWDiGDkvSLQJTp5bq7QFXOxPEael4ct1yjKit/Yu6Sd48uLEgNT1waBYbyApPzhOw==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-arm64/-/claude-agent-sdk-win32-arm64-0.3.330.tgz",
"integrity": "sha512-6jscch7vk/XBSn7mm1i6zwTeiz05q98nKrQ3HdTavQEDGvXycMcB/QxIdMrs3vrdNEjWuoxwrL1qlT1lOyAWLg==",
"cpu": [
"arm64"
],
@@ -180,9 +180,9 @@
]
},
"node_modules/@anthropic-ai/claude-agent-sdk-win32-x64": {
"version": "0.3.328",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-x64/-/claude-agent-sdk-win32-x64-0.3.328.tgz",
"integrity": "sha512-9Wd0XrZ0QWkgtcKxObcYDvUpQjUzN3Uq4Chbvu1SOWOoKPfQdD40dwRQMCeKx2KGxAfMrggJ7I3JYnvRWAFYjg==",
"version": "0.3.330",
"resolved": "https://registry.npmjs.org/@anthropic-ai/claude-agent-sdk-win32-x64/-/claude-agent-sdk-win32-x64-0.3.330.tgz",
"integrity": "sha512-ooThWbUXlXKTDgj2VgWBXQ/6vSOTaAbBDWPvvCGNHi20haoSkw4uPX9gczkX+HJuVTslvvLiYIfe8zleVPzi7A==",
"cpu": [
"x64"
],
@@ -193,9 +193,9 @@
]
},
"node_modules/@anthropic-ai/sdk": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.10.0.tgz",
"integrity": "sha512-j4uVct5p3aGIz/BU4K8VU5vt2A6AueHTvx2gfF3xr4mVpwH9IJMWEAUKNwSwdZSJOHQq1Za2tv5huYc5v02D0w==",
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-1.12.0.tgz",
"integrity": "sha512-0j9zwiQdkvr90LoiiBDUh7kae1lsNW2EqeE0vGceYne4BrmMDdDVoQ4KGOieUee0zWZbVJKsf/06JY8U5i63Xg==",
"license": "Apache-2.0",
"dependencies": {
"@opentelemetry/api": "^1.4.1",
@@ -215,9 +215,9 @@
}
},
"node_modules/@babel/runtime": {
"version": "7.29.14",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.14.tgz",
"integrity": "sha512-Y5tqevQaUAZhhj82BpYMNC1ssvLQTVAfwKdm8iy8qwmhvC2/CpcAu8OC+QEtjM7pMk7knx83u1Qj8gzkicyelw==",
"version": "7.29.15",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.15.tgz",
"integrity": "sha512-304gsbbGVmQc+cNGHzwHBlqepYdWLKj3VXCQBGt/EGcV7PUPfKI7kAUNW1FZEOCwlQiLvQjg1JEaAlRQ616h+Q==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
@@ -400,9 +400,9 @@
}
},
"node_modules/@hono/node-server": {
"version": "2.1.9",
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.9.tgz",
"integrity": "sha512-Sk4NQd3GFY0WZWCzndwFMPwJhtD0y9qjsQ+pjID0/03nK9pxyBCUoUHCho8QYBLBVhi0ssL8UkNPHqbgSOFPIQ==",
"version": "2.1.11",
"resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.11.tgz",
"integrity": "sha512-KzKz9vl4vvr1vgLHamj+g5uonbrj5NwAdO3yzOS6cd2HjALVeOgTgeZOyAzNxejbkfOOPIcvuf/Tg8l1pEFLog==",
"license": "MIT",
"peer": true,
"engines": {
@@ -3609,14 +3609,14 @@
}
},
"node_modules/source-map-js": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.3.tgz",
"integrity": "sha512-xj+WrAkyv5Qp+t7r9N5HvCBu7g1qOe6CKRNpq22X1GGcPEQADFU54v5qsPVs3/vrUFQ7XivFrcAVKA2stI0kWA==",
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.4.tgz",
"integrity": "sha512-J7ZjMvHd9O1fcT/5V09QWaaSl2BbWx3F6O08spde82Namf9UB0GxRVIPiNbVsdKkoizHiSpTodo3vp2bAy91MA==",
"dev": true,
"license": "BSD-3-Clause",
"peer": true,
"engines": {
"node": ">=0.10.0"
"node": ">=6.0.0"
}
},
"node_modules/standardwebhooks": {

View File

@@ -3,7 +3,7 @@
"publishConfig": {
"access": "public"
},
"version": "0.109.0",
"version": "0.109.1",
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
"main": "dist/lib.js",
"types": "dist/lib.d.ts",
@@ -69,12 +69,12 @@
},
"dependencies": {
"@agentclientprotocol/sdk": "2.9.1",
"@anthropic-ai/claude-agent-sdk": "0.3.328",
"@anthropic-ai/claude-agent-sdk": "0.3.330",
"diff": "9.0.0",
"zod": "4.6.7"
},
"devDependencies": {
"@anthropic-ai/sdk": "1.10.0",
"@anthropic-ai/sdk": "1.12.0",
"@eslint/js": "10.0.1",
"@tsconfig/node22": "22.0.7",
"@types/node": "26.6.6",

View File

@@ -4,7 +4,9 @@
* `providers/disable`, and the legacy gateway logins (`authenticate` or
* `auth/login` with `gateway` or `gateway-bedrock`). Each core holds its own
* {@link ProviderConfig} and gateway login, and builds the query env of its
* sessions with {@link createEnvForProvider}.
* sessions with {@link createEnvForProvider}. It holds that route above the
* user's and the project's settings with {@link providerRouteSettings} and
* {@link applyProviderRoute}.
*/
import {
RequestError,
@@ -15,6 +17,7 @@ import {
type ProviderInfo,
type SetProviderRequest,
} from "@agentclientprotocol/sdk/unstable";
import type { Query } from "@anthropic-ai/claude-agent-sdk";
import {
GatewayListingError,
listBedrockModels,
@@ -187,6 +190,50 @@ export function createEnvForProvider(config: ProviderConfig | null): Record<stri
};
}
/** A provider's route as settings of Claude Code (see {@link providerRouteSettings}). */
export type ProviderRouteSettings = { apiKeyHelper: ""; env: Record<string, string> };
/**
* The route of a provider as settings of Claude Code, for the tier of the
* `settings` option. `env` is the result of {@link createEnvForProvider}.
*
* Claude Code applies the `env` of settings files after the process env, so
* without this tier the user's or the project's settings could restore another
* `ANTHROPIC_BASE_URL`. The empty `apiKeyHelper` turns off a helper of theirs.
*/
export function providerRouteSettings(env: Record<string, string>): ProviderRouteSettings {
return { apiKeyHelper: "", env };
}
/**
* Sends `route` to the running session, into the tier of the `settings`
* option (`applyFlagSettings`). Call it right after the query's initialize
* response, before a request of the session reaches the provider:
* `getContextUsage()` sends one (`count_tokens`).
*
* The `settings` option holds the route too, in one object with the client's
* settings and the model configuration. Claude Code loads that object as a
* whole or not at all: one value that fails validation, e.g.
* `permissions.allow: "Bash"`, leaves all of it out. This call does not depend
* on that object. When the object did load, the call changes nothing: Claude
* Code merges `env` key by key.
*
* Throws when Claude Code refuses the route. The caller must close the query.
*/
export async function applyProviderRoute(
query: Pick<Query, "applyFlagSettings">,
route: ProviderRouteSettings,
): Promise<void> {
try {
await query.applyFlagSettings(route);
} catch (error) {
throw RequestError.internalError(
{ details: error instanceof Error ? error.message : String(error) },
"The session was not started, because Claude Code did not take its provider or gateway route. Try again, or set the provider or the gateway login again.",
);
}
}
function sameHeaders(a: Record<string, string>, b: Record<string, string>): boolean {
const aKeys = Object.keys(a);
return aKeys.length === Object.keys(b).length && aKeys.every((key) => b[key] === a[key]);

View File

@@ -39,6 +39,7 @@ export function makeMockQuery(overrides: Record<string, unknown> = {}) {
supportedCommands: async () => [],
mcpServerStatus: async () => [],
setMcpServers: async () => ({ added: [], removed: [], errors: {} }),
applyFlagSettings: async () => {},
getContextUsage: async () => DEFAULT_CONTEXT_USAGE,
// No ultracode fields: session creation falls back to settings and the
// model's effort levels, as with a CLI that does not report them.

View File

@@ -149,6 +149,7 @@ function scriptedTurnQuery(args: any, account: Record<string, unknown>) {
query.accountInfo = async () => account;
query.setModel = async () => {};
query.setPermissionMode = async () => {};
query.applyFlagSettings = async () => {};
query.supportedCommands = async () => [];
query.mcpServerStatus = async () => [];
query.getContextUsage = async () => DEFAULT_CONTEXT_USAGE;

View File

@@ -15,6 +15,7 @@ const mockQuery = vi.hoisted(() =>
}),
setModel: vi.fn(),
setPermissionMode: vi.fn(),
applyFlagSettings: vi.fn().mockResolvedValue(undefined),
supportedCommands: vi.fn().mockResolvedValue([]),
close: vi.fn(() => closed.resolve()),
interrupt: vi.fn().mockResolvedValue(undefined),
@@ -221,9 +222,65 @@ describe("providers", () => {
expect(mockQuery).toHaveBeenCalledOnce();
expect(mockQuery.mock.calls[0][0].options.resume).toBeUndefined();
expect(mockQuery.mock.results[0].value.applyFlagSettings).not.toHaveBeenCalled();
expect(mockQuery.mock.results[0].value.close).not.toHaveBeenCalled();
});
it("applies the route to the running session before its first context read", async () => {
const [agent, mockQuery] = await createAgentMock();
await agent.initialize({ protocolVersion: 1, clientCapabilities: {} });
await agent.unstable_setProvider({
providerId: "main",
apiType: "anthropic",
baseUrl: "https://gateway.example",
headers: { "x-api-key": "test" },
});
await agent.newSession({ cwd: process.cwd(), mcpServers: [] });
const query = mockQuery.mock.results[0].value;
// The route of the `settings` option, without the client's settings.
expect(query.applyFlagSettings.mock.calls[0]).toEqual([
{
apiKeyHelper: "",
env: expect.objectContaining({
ANTHROPIC_AUTH_TOKEN: "acp-proxy",
ANTHROPIC_BASE_URL: "https://gateway.example",
ANTHROPIC_CUSTOM_HEADERS: "x-api-key: test",
}),
},
]);
expect(query.applyFlagSettings.mock.invocationCallOrder[0]).toBeLessThan(
query.getContextUsage.mock.invocationCallOrder[0],
);
});
it("starts no session when Claude Code refuses the route", async () => {
const [agent, mockQuery] = await createAgentMock();
await agent.initialize({ protocolVersion: 1, clientCapabilities: {} });
await agent.unstable_setProvider({
providerId: "main",
apiType: "anthropic",
baseUrl: "https://gateway.example",
});
// The text of Claude Code 2.1.328 for a refused `applyFlagSettings`.
const refusal =
"apply_flag_settings: nothing in this request was applied and earlier settings stay in force. Fix or remove these invalid settings and send it again: env";
const query = mockQuery.getMockImplementation()!();
query.applyFlagSettings.mockRejectedValue(new Error(refusal));
mockQuery.mockReturnValueOnce(query);
await expect(agent.newSession({ cwd: process.cwd(), mcpServers: [] })).rejects.toMatchObject({
code: -32603,
message: expect.stringContaining("Claude Code did not take its provider or gateway route"),
data: { details: refusal },
});
expect(query.getContextUsage).not.toHaveBeenCalled();
expect(query.close).toHaveBeenCalledOnce();
expect(Object.keys(agent.sessions)).toEqual([]);
});
it("recreates loaded sessions with the new provider between turns", async () => {
const [agent, mockQuery] = await createAgentMock();
await agent.initialize({ protocolVersion: 1, clientCapabilities: {} });
@@ -615,6 +672,7 @@ describe("providers", () => {
initializationResult: vi.fn().mockResolvedValue({ models }),
setModel,
setPermissionMode: vi.fn(),
applyFlagSettings: vi.fn().mockResolvedValue(undefined),
supportedCommands: vi.fn().mockResolvedValue([]),
close: vi.fn(),
interrupt: vi.fn().mockResolvedValue(undefined),

View File

@@ -1558,6 +1558,11 @@ describe("ACP v2 sessions", () => {
expect(sdk.queryOptions).toHaveLength(2);
expect(sdk.queryOptions[1].effort).toBeUndefined();
expect(sdk.flagSettings).toEqual([
// The provider's route, before the session's own choices.
{
apiKeyHelper: "",
env: expect.objectContaining({ ANTHROPIC_BASE_URL: "https://gateway.example.com" }),
},
{ ultracode: true },
{ fastMode: false },
{ fastMode: true },

View File

@@ -1,6 +1,9 @@
import { spawn, spawnSync, type ChildProcess } from "node:child_process";
import { randomUUID } from "node:crypto";
import { once } from "node:events";
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
import { createServer, type Server } from "node:http";
import type { AddressInfo } from "node:net";
import * as os from "node:os";
import * as path from "node:path";
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
@@ -260,6 +263,57 @@ describe.skipIf(!process.env.RUN_INTEGRATION_TESTS)("v2 core with Claude Code",
60_000,
);
// The session's requests go to two local servers: it costs no API usage.
it("keeps a provider's route when Claude Code does not load the client's settings", async () => {
const servers: Server[] = [];
/** Starts a local server that records the paths of its POST requests in `posts`. */
const serve = async (posts: string[]): Promise<string> => {
const server = createServer((request, response) => {
if (request.method === "POST") posts.push(request.url ?? "");
// No model listing (404), and no answer to a model request (400).
response.writeHead(request.method === "POST" ? 400 : 404, {
"content-type": "application/json",
});
response.end(
JSON.stringify({
type: "error",
error: { type: "invalid_request_error", message: "local test server" },
}),
);
}).listen(0, "127.0.0.1");
servers.push(server);
await once(server, "listening");
return `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
};
try {
const providerPosts: string[] = [];
const projectPosts: string[] = [];
// The project's settings name another base URL than the provider's.
await mkdir(path.join(cwd, ".claude"));
await writeFile(
path.join(cwd, ".claude", "settings.json"),
JSON.stringify({ env: { ANTHROPIC_BASE_URL: await serve(projectPosts) } }),
);
await agent.request(v2.methods.agent.providers.set, {
providerId: "main",
apiType: "anthropic",
baseUrl: await serve(providerPosts),
});
const { sessionId } = await agent.request(v2.methods.agent.session.new, {
cwd,
// `allow` must be a list, so Claude Code leaves the whole `settings` option out.
_meta: { claudeCode: { options: { settings: { permissions: { allow: "Bash" } } } } },
});
await prompt(sessionId, "Reply with exactly the single word: pong");
await until(() => states(sessionId).some((update) => update.state === "idle"));
expect(providerPosts.some((url) => url.startsWith("/v1/messages"))).toBe(true);
expect(projectPosts).toEqual([]);
} finally {
for (const server of servers) server.close();
}
}, 180_000);
it("reports requires_action while a permission request waits", async () => {
const sessionId = await newSession("default");
await prompt(

View File

@@ -75,6 +75,8 @@ const sdk = vi.hoisted(() => ({
startFailure: undefined as Error | undefined,
/** When set, the SDK refuses the query's options with it: `query()` throws. */
optionsRefusal: undefined as Error | undefined,
/** When set, Claude Code refuses flag settings with it: `applyFlagSettings` rejects. */
flagRefusal: undefined as Error | undefined,
/** When set, Claude Code's start waits for it. */
startGate: undefined as Promise<void> | undefined,
/** When set, the query serves Remote Control with it (`enableRemoteControl`). */
@@ -119,7 +121,9 @@ vi.mock("@anthropic-ai/claude-agent-sdk", async () => {
setModel: vi.fn(async () => {}),
stopTask: vi.fn(async () => {}),
close: vi.fn(() => push({ value: undefined, done: true })),
applyFlagSettings: vi.fn(async () => {}),
applyFlagSettings: vi.fn(async () => {
if (sdk.flagRefusal) throw sdk.flagRefusal;
}),
rewindFiles: vi.fn(async () => ({ canRewind: true, filesChanged: [] })),
};
sdk.processes.push(fake);
@@ -223,6 +227,7 @@ beforeEach(async () => {
sdk.previewGate = undefined;
sdk.startFailure = undefined;
sdk.optionsRefusal = undefined;
sdk.flagRefusal = undefined;
sdk.startGate = undefined;
sdk.enableRemoteControl = undefined;
vi.mocked(forkSession).mockClear();
@@ -650,6 +655,43 @@ describe("ACP v2 core", () => {
});
// In the settings tier too, so a settings.json env cannot restore another route.
expect(settings).toMatchObject({ apiKeyHelper: "", env: { ANTHROPIC_BASE_URL: baseUrl } });
// And applied to the running session, which does not depend on the `settings` option.
expect(sdk.processes[0].applyFlagSettings.mock.calls[0]).toEqual([
{ apiKeyHelper: "", env: expect.objectContaining({ ANTHROPIC_BASE_URL: baseUrl }) },
]);
});
it("starts no session when Claude Code refuses the route of a gateway login", async () => {
// The text of Claude Code 2.1.328 for a refused `applyFlagSettings`.
sdk.flagRefusal = new Error(
"apply_flag_settings: nothing in this request was applied and earlier settings stay in force. " +
"Fix or remove these invalid settings and send it again: env",
);
const initialized = vi.spyOn(SettingsManager.prototype, "initialize");
const disposed = vi.spyOn(SettingsManager.prototype, "dispose");
const client = v2Client();
const error = await client.connect(async (agent) => {
await agent.request(v2.methods.agent.initialize, {
protocolVersion: v2.PROTOCOL_VERSION,
info: { name: "v2-test-client", version: "1.0.0" },
capabilities: { auth: { _meta: { gateway: true } } },
});
await agent.request(v2.methods.agent.auth.login, {
methodId: "gateway",
_meta: { gateway: { baseUrl: "https://gateway.example.com" } },
});
return agent.request(v2.methods.agent.session.new, { cwd }).catch((error: unknown) => error);
});
expect(error).toMatchObject({
code: -32603,
message: expect.stringContaining("Claude Code did not take its provider or gateway route"),
data: { details: sdk.flagRefusal.message },
});
expect(sdk.processes[0].close).toHaveBeenCalledOnce();
expect(disposed).toHaveBeenCalledTimes(initialized.mock.calls.length);
initialized.mockRestore();
disposed.mockRestore();
});
it("rejects an incompatible provider listing before a prompt and recovers", async () => {

View File

@@ -379,6 +379,7 @@ import {
withCurrentModelInfo,
} from "../session-model.js";
import {
applyProviderRoute,
createEnvForProvider,
defaultProviderConfig,
gatewayRequestToProviderConfig,
@@ -389,6 +390,7 @@ import {
PROVIDER_ID,
type ProviderConfig,
providerConfigFromSetRequest,
providerRouteSettings,
validatedGatewayAuthRequest,
withListedModels,
} from "../providers.js";
@@ -10216,14 +10218,14 @@ export class ClaudeAcpAgent {
userProvidedOptions?.settings,
params.cwd,
);
// Claude Code applies env from settings.json after the subprocess env. Put
// an active ACP route in the programmatic settings tier too so user/project
// settings cannot silently restore a different ANTHROPIC_BASE_URL.
const settings = resolvedProvider
// An active ACP route goes into the programmatic settings tier too (see
// `providerRouteSettings`).
const route = resolvedProvider ? providerRouteSettings(providerEnv) : undefined;
const settings = route
? {
...configuredSettingsObject,
apiKeyHelper: "",
env: { ...configuredSettingsObject?.env, ...providerEnv },
...route,
env: { ...configuredSettingsObject?.env, ...route.env },
}
: configuredSettingsObject;
const env = {
@@ -10520,6 +10522,8 @@ export class ClaudeAcpAgent {
}
throw startupFailureError(error) ?? error;
}
// Before a request of the session reaches the provider.
if (route) await applyProviderRoute(q, route);
timing.phase("sdk-initialize");
// Publish the identity BEFORE the guard can refuse this session. A

View File

@@ -47,6 +47,7 @@ import {
promptSuggestionOptions,
type PromptSuggestionForms,
} from "../prompt-suggestions.js";
import { applyProviderRoute } from "../providers.js";
import {
readHistoryAcrossCompactions,
readResumedTail,
@@ -1230,6 +1231,16 @@ class V2Agent implements AgentHandle, SessionConnection {
}
throw startupFailureError(error) ?? error;
}
if (routing.settings) {
// Before a request of the session reaches the provider.
try {
await applyProviderRoute(q, routing.settings);
} catch (error) {
q.close();
settings.dispose();
throw error;
}
}
authStarted(sessionId, initialization.account);
try {
this.guard.sessionStarted(sessionId, initialization.account, settings.getApiKeyHelper());

View File

@@ -17,7 +17,7 @@
*/
import { RequestError } from "@agentclientprotocol/sdk/unstable";
import * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
import type { AccountInfo, ModelInfo, Settings } from "@anthropic-ai/claude-agent-sdk";
import type { AccountInfo, ModelInfo } from "@anthropic-ai/claude-agent-sdk";
import type { AuthStatusKind } from "../auth-status.js";
import type { Logger } from "../logger.js";
import { terminalAuthMethods } from "../auth-methods.js";
@@ -40,6 +40,8 @@ import {
PROVIDER_ID,
type ProviderConfig,
providerConfigFromSetRequest,
type ProviderRouteSettings,
providerRouteSettings,
validatedGatewayAuthRequest,
withListedModels,
} from "../providers.js";
@@ -51,11 +53,11 @@ export interface SessionRouting {
/** Added to the query's env. Empty without a gateway login or a provider. */
env: Record<string, string>;
/**
* The programmatic settings of the query, with the route's env too: Claude
* Code applies the env of settings.json after the process env, so user or
* project settings could restore another `ANTHROPIC_BASE_URL` otherwise.
* The route as settings, for the query's `settings` option and for the
* running session (see `providerRouteSettings` and `applyProviderRoute`).
* Absent without a gateway login or a provider.
*/
settings?: Settings;
settings?: ProviderRouteSettings;
/** The models the session offers: those the provider's gateway listed. */
models(models: ModelInfo[]): ModelInfo[];
/** Whether {@link models} narrows the models to a gateway's list. */
@@ -243,7 +245,7 @@ export class V2Auth {
const env = createEnvForProvider(config);
return {
env,
...(config ? { settings: { apiKeyHelper: "", env } } : {}),
...(config ? { settings: providerRouteSettings(env) } : {}),
models: (models) =>
config?.listedModels
? narrowToGatewayModels(models, config.listedModels, config.bedrockRegionPrefix)