mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-11-17 23:01:26 +00:00
Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6ba98ff3c | ||
|
|
c4dd80d739 | ||
|
|
4a076397c6 | ||
|
|
451bc04ae0 | ||
|
|
20aeb46ece | ||
|
|
bcd3cdad35 | ||
|
|
9d71d12336 | ||
|
|
378e85d060 | ||
|
|
0073280b97 | ||
|
|
edab713502 | ||
|
|
7ad73cceb9 | ||
|
|
be2219cef1 | ||
|
|
dc769c132c | ||
|
|
b437e4ee16 | ||
|
|
81650db3d3 | ||
|
|
c03b66cc9f | ||
|
|
7d9e1f6135 | ||
|
|
c203b919ec | ||
|
|
41417f6eee | ||
|
|
8de49818f1 | ||
|
|
db5413513c | ||
|
|
3067a5db36 | ||
|
|
e73d7909ce | ||
|
|
29dde3633a | ||
|
|
b1c198754d | ||
|
|
7e857d59ec | ||
|
|
c5c120dba9 | ||
|
|
4f474d655b | ||
|
|
21f3e0430b | ||
|
|
c78bcc7f41 | ||
|
|
ca46b412f5 | ||
|
|
9619805306 | ||
|
|
ddee24ef8f | ||
|
|
4804917a6f | ||
|
|
c331e178a5 | ||
|
|
830f05a0ac | ||
|
|
4df69996ca | ||
|
|
ecd066c870 | ||
|
|
a22a797db2 | ||
|
|
4f690e129c | ||
|
|
51f514d73c | ||
|
|
b1763c750a | ||
|
|
f6d6429187 | ||
|
|
9fca22a03b | ||
|
|
4a3ff6a1eb | ||
|
|
b73ee491c8 | ||
|
|
626015bf81 | ||
|
|
1ffbb6b577 | ||
|
|
36cb674589 | ||
|
|
f5d79167a6 | ||
|
|
a4a8534c23 | ||
|
|
6bc2e058cb | ||
|
|
99cc1f3245 | ||
|
|
bce309f482 | ||
|
|
6b86f7b46a | ||
|
|
b89e4497da | ||
|
|
7d95d30ec3 | ||
|
|
3d6eb7b5b6 |
@@ -1,3 +1,3 @@
|
||||
{
|
||||
".": "0.104.0"
|
||||
".": "0.108.0"
|
||||
}
|
||||
|
||||
111
CHANGELOG.md
111
CHANGELOG.md
@@ -1,5 +1,116 @@
|
||||
# Changelog
|
||||
|
||||
## [0.108.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.107.3...v0.108.0) (2026-11-17)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* stream the output of foreground Bash commands ([#1587](https://github.com/agentclientprotocol/claude-agent-acp/issues/1587)) ([378e85d](https://github.com/agentclientprotocol/claude-agent-acp/commit/378e85d06027f5fa1802e94535548747a0feccc9))
|
||||
* support MCP servers that the client serves over the ACP connection (MCP-over-ACP) ([#1645](https://github.com/agentclientprotocol/claude-agent-acp/issues/1645)) ([20aeb46](https://github.com/agentclientprotocol/claude-agent-acp/commit/20aeb46ecedc60fef26ca8b1439b37e3bbd9b27a))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* an autonomous result naming the original prompt must not end a steered turn early ([#1451](https://github.com/agentclientprotocol/claude-agent-acp/issues/1451)) ([edab713](https://github.com/agentclientprotocol/claude-agent-acp/commit/edab7135028d83efaeaa38d0f8efe62ea7ddf203))
|
||||
* do not count a confirmWithUser question as an unfinished tool call ([#1644](https://github.com/agentclientprotocol/claude-agent-acp/issues/1644)) ([bcd3cda](https://github.com/agentclientprotocol/claude-agent-acp/commit/bcd3cdad35e4356247303870ac3137675e401227))
|
||||
* handle invalid file paths in tool reports ([#1419](https://github.com/agentclientprotocol/claude-agent-acp/issues/1419)) ([0073280](https://github.com/agentclientprotocol/claude-agent-acp/commit/0073280b977a69934fb56670943d1ef42e7b687e))
|
||||
* keep a workflow agent's tool call out of the turn's unfinished tools ([#1638](https://github.com/agentclientprotocol/claude-agent-acp/issues/1638)) ([451bc04](https://github.com/agentclientprotocol/claude-agent-acp/commit/451bc04ae022ef02473bdd92740cf19d8ceb5f3c))
|
||||
* offer clearing the context on plan approval only when Claude Code's setting is on ([#1627](https://github.com/agentclientprotocol/claude-agent-acp/issues/1627)) ([9d71d12](https://github.com/agentclientprotocol/claude-agent-acp/commit/9d71d12336c392c28967c600f8409841deaab7e0))
|
||||
* send MCP servers to Claude Code over stdin, not on its command line ([#1647](https://github.com/agentclientprotocol/claude-agent-acp/issues/1647)) ([c4dd80d](https://github.com/agentclientprotocol/claude-agent-acp/commit/c4dd80d7392b035f331b50bfdd802cfb3e144d37))
|
||||
* update to @anthropic-ai/claude-agent-sdk 0.3.326 ([#1646](https://github.com/agentclientprotocol/claude-agent-acp/issues/1646)) ([4a07639](https://github.com/agentclientprotocol/claude-agent-acp/commit/4a076397c6e785a8dd9166e8ea1df14fe17c52ed))
|
||||
|
||||
## [0.107.3](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.107.2...v0.107.3) (2026-11-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allow Claude Enterprise accounts under --hide-claude-auth ([#1641](https://github.com/agentclientprotocol/claude-agent-acp/issues/1641)) ([be2219c](https://github.com/agentclientprotocol/claude-agent-acp/commit/be2219cef1f5b2b93129d5eef4b80574f57bdb1b))
|
||||
* pass a model id the picker does not list to Claude Code ([#1630](https://github.com/agentclientprotocol/claude-agent-acp/issues/1630)) ([dc769c1](https://github.com/agentclientprotocol/claude-agent-acp/commit/dc769c132cacc8bbc7aff0d512e5ab587a1802e3))
|
||||
|
||||
## [0.107.2](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.107.1...v0.107.2) (2026-11-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* end the turn task of a cycle that has no turn to claim its result ([#1622](https://github.com/agentclientprotocol/claude-agent-acp/issues/1622)) ([8de4981](https://github.com/agentclientprotocol/claude-agent-acp/commit/8de49818f1172c5187496a736f721dc6d2ba3fec))
|
||||
* keep Fast mode on when it is turned on after a model switch or mid-turn ([#1637](https://github.com/agentclientprotocol/claude-agent-acp/issues/1637)) ([81650db](https://github.com/agentclientprotocol/claude-agent-acp/commit/81650db3d3ca6f7b640fd5e1bbb5e1ff45f62fb7))
|
||||
* list a live Monitor whose task Claude Code reports as local_bash ([#1607](https://github.com/agentclientprotocol/claude-agent-acp/issues/1607)) ([41417f6](https://github.com/agentclientprotocol/claude-agent-acp/commit/41417f6eeeb5010c0eb439e256032cd7e9a44e37))
|
||||
* read the Claude Code stream after a query restart, not at the next prompt ([#1636](https://github.com/agentclientprotocol/claude-agent-acp/issues/1636)) ([c03b66c](https://github.com/agentclientprotocol/claude-agent-acp/commit/c03b66cc9f1aa6aa5e56668ac05e5a7f48418850))
|
||||
* read the Claude Code stream after every session setup, not at the first prompt ([#1623](https://github.com/agentclientprotocol/claude-agent-acp/issues/1623)) ([7d9e1f6](https://github.com/agentclientprotocol/claude-agent-acp/commit/7d9e1f6135b2c85cd8bdd0e76bc2bcf00795e6c9))
|
||||
* reject the SDK no-token sentinel in auth guards ([#1609](https://github.com/agentclientprotocol/claude-agent-acp/issues/1609)) ([c203b91](https://github.com/agentclientprotocol/claude-agent-acp/commit/c203b919ecca8a58e11bebb72274a5a203653d88))
|
||||
* update to @anthropic-ai/claude-agent-sdk 0.3.325 ([#1634](https://github.com/agentclientprotocol/claude-agent-acp/issues/1634)) ([db54135](https://github.com/agentclientprotocol/claude-agent-acp/commit/db5413513cbe58c045885e6bb015abfdb76be524))
|
||||
|
||||
## [0.107.1](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.107.0...v0.107.1) (2026-11-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* end a v2 turn once when Claude Code folds a prompt into it ([#1618](https://github.com/agentclientprotocol/claude-agent-acp/issues/1618)) ([7e857d5](https://github.com/agentclientprotocol/claude-agent-acp/commit/7e857d59ec777356969ab615af83eef02ac43e59))
|
||||
* resolve a model preference without a version to the newest listed row ([#1633](https://github.com/agentclientprotocol/claude-agent-acp/issues/1633)) ([e73d790](https://github.com/agentclientprotocol/claude-agent-acp/commit/e73d7909ce0295bfa351da49940e067da02ea0e4))
|
||||
* send v2 terminal output with CR LF, as a PTY would ([#1632](https://github.com/agentclientprotocol/claude-agent-acp/issues/1632)) ([29dde36](https://github.com/agentclientprotocol/claude-agent-acp/commit/29dde3633a13cb9f32fca6c1578a9d95b9e6c08e))
|
||||
* update to @agentclientprotocol/sdk 2.7.0 ([#1629](https://github.com/agentclientprotocol/claude-agent-acp/issues/1629)) ([b1c1987](https://github.com/agentclientprotocol/claude-agent-acp/commit/b1c198754d1cb4e086de6c6bc6a9659ae3351a0a))
|
||||
|
||||
## [0.107.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.106.0...v0.107.0) (2026-11-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* report the turn's rate limit in rate-limit failure errors ([#1610](https://github.com/agentclientprotocol/claude-agent-acp/issues/1610)) ([4f474d6](https://github.com/agentclientprotocol/claude-agent-acp/commit/4f474d655b88a075ec7d0124d45cafa0f5565af7))
|
||||
* report unknown subagent state at a conversation reset and reference children from tool calls ([#1608](https://github.com/agentclientprotocol/claude-agent-acp/issues/1608)) ([4804917](https://github.com/agentclientprotocol/claude-agent-acp/commit/4804917a6fa7050490d1d62c6689e78c231c752a))
|
||||
* say the cause of an api retry in the AIR warning details ([#1594](https://github.com/agentclientprotocol/claude-agent-acp/issues/1594)) ([4f690e1](https://github.com/agentclientprotocol/claude-agent-acp/commit/4f690e129c01f22e2c2a87e0e0a3c5b503241f15))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* assume a 1M context window until Claude Code reports it ([#1613](https://github.com/agentclientprotocol/claude-agent-acp/issues/1613)) ([9619805](https://github.com/agentclientprotocol/claude-agent-acp/commit/96198053067cf4d7b7440c52036174ad4f54183e))
|
||||
* end the tool calls of a response that Claude Code took back ([#1616](https://github.com/agentclientprotocol/claude-agent-acp/issues/1616)) ([21f3e04](https://github.com/agentclientprotocol/claude-agent-acp/commit/21f3e0430b693e6b04750ab3018e1eaf726af173))
|
||||
* explain why Claude Code turns Fast mode off ([#1602](https://github.com/agentclientprotocol/claude-agent-acp/issues/1602)) ([c331e17](https://github.com/agentclientprotocol/claude-agent-acp/commit/c331e178a5df47448be1a3ed2f71270c3aad2433))
|
||||
* follow Claude Code's rule for managed deniedModels in the model picker ([#1615](https://github.com/agentclientprotocol/claude-agent-acp/issues/1615)) ([c78bcc7](https://github.com/agentclientprotocol/claude-agent-acp/commit/c78bcc7f417fc8d3da66f51021b43f4528826ec0))
|
||||
* log a managed policy source that did not load ([#1614](https://github.com/agentclientprotocol/claude-agent-acp/issues/1614)) ([ca46b41](https://github.com/agentclientprotocol/claude-agent-acp/commit/ca46b412f51cdb7b5a303c751f5d48c216700887))
|
||||
* report a mid-turn API error notice where the response broke off ([#1599](https://github.com/agentclientprotocol/claude-agent-acp/issues/1599)) ([4df6999](https://github.com/agentclientprotocol/claude-agent-acp/commit/4df69996ca74adff6c42fc60e4b9b742f2d3fdf5))
|
||||
* say why the login failed in the v2 authRequired error ([#1598](https://github.com/agentclientprotocol/claude-agent-acp/issues/1598)) ([ecd066c](https://github.com/agentclientprotocol/claude-agent-acp/commit/ecd066c8700955e3456dd9387e6b8317f024e26c))
|
||||
* update to @anthropic-ai/claude-agent-sdk 0.3.323 ([#1612](https://github.com/agentclientprotocol/claude-agent-acp/issues/1612)) ([ddee24e](https://github.com/agentclientprotocol/claude-agent-acp/commit/ddee24ef8fd0abc0401fb32d567914030fbf6944))
|
||||
|
||||
## [0.106.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.105.0...v0.106.0) (2026-11-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* report the auth detail as the account's description ([#1591](https://github.com/agentclientprotocol/claude-agent-acp/issues/1591)) ([f6d6429](https://github.com/agentclientprotocol/claude-agent-acp/commit/f6d64291876177f9f593415abfc7e50eb7e7ff56))
|
||||
* serve session/options and initial config options ([#1592](https://github.com/agentclientprotocol/claude-agent-acp/issues/1592)) ([b1763c7](https://github.com/agentclientprotocol/claude-agent-acp/commit/b1763c750aef83fd05ce16901ff1a0d9b4b90234))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* honour the client's settings option in idle compaction ([#1555](https://github.com/agentclientprotocol/claude-agent-acp/issues/1555)) ([b73ee49](https://github.com/agentclientprotocol/claude-agent-acp/commit/b73ee491c8f60a1584a95a7f03557f356e1a991c))
|
||||
* replay the messages before each compaction on ACP v1 and v2 ([#1430](https://github.com/agentclientprotocol/claude-agent-acp/issues/1430)) ([626015b](https://github.com/agentclientprotocol/claude-agent-acp/commit/626015bf81fd34f952406ae77bf60feb9ca39a16))
|
||||
* stop the release executable from loading the project's .env and bunfig.toml ([#1589](https://github.com/agentclientprotocol/claude-agent-acp/issues/1589)) ([4a3ff6a](https://github.com/agentclientprotocol/claude-agent-acp/commit/4a3ff6a1eb16075b96676616ab2bbb98694a4d24))
|
||||
* update to @agentclientprotocol/sdk 2.6.0 ([#1590](https://github.com/agentclientprotocol/claude-agent-acp/issues/1590)) ([9fca22a](https://github.com/agentclientprotocol/claude-agent-acp/commit/9fca22a03bdec5dc265bfdc42df316fb286a8142))
|
||||
|
||||
## [0.105.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.104.1...v0.105.0) (2026-11-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* serve session/set_title on ACP v1 and v2 ([#1585](https://github.com/agentclientprotocol/claude-agent-acp/issues/1585)) ([a4a8534](https://github.com/agentclientprotocol/claude-agent-acp/commit/a4a8534c23b08cdfd7f656d25f9ab16068fd8ffd))
|
||||
* serve session/status on v1 and v2 ([#1584](https://github.com/agentclientprotocol/claude-agent-acp/issues/1584)) ([6bc2e05](https://github.com/agentclientprotocol/claude-agent-acp/commit/6bc2e058cb27624b4307462ac46167535af400d1))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* include inline model settings in the model picker ([#1488](https://github.com/agentclientprotocol/claude-agent-acp/issues/1488)) ([36cb674](https://github.com/agentclientprotocol/claude-agent-acp/commit/36cb6745897bf9dabcb967b54233c42b860436b3))
|
||||
* keep a v2 session idle when the model changes between turns ([#1586](https://github.com/agentclientprotocol/claude-agent-acp/issues/1586)) ([f5d7916](https://github.com/agentclientprotocol/claude-agent-acp/commit/f5d79167a649737bdeb1ce3b55ad449a34bb9d47))
|
||||
* report Claude Code's API error message as a notice in v2 ([#1582](https://github.com/agentclientprotocol/claude-agent-acp/issues/1582)) ([99cc1f3](https://github.com/agentclientprotocol/claude-agent-acp/commit/99cc1f324586fad07f1da14bb9764cd16c64e920))
|
||||
|
||||
## [0.104.1](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.104.0...v0.104.1) (2026-11-10)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* carry the auth detail in the ACP account label ([#1573](https://github.com/agentclientprotocol/claude-agent-acp/issues/1573)) ([3d6eb7b](https://github.com/agentclientprotocol/claude-agent-acp/commit/3d6eb7b5b650a1f9e5d2e869e92e313c32dbdc86))
|
||||
* distinguish Ultra from Max in auth status ([#1574](https://github.com/agentclientprotocol/claude-agent-acp/issues/1574)) ([7d95d30](https://github.com/agentclientprotocol/claude-agent-acp/commit/7d95d30ec3a4813d580b3bfdedb08f03d93a3571))
|
||||
* update to @anthropic-ai/claude-agent-sdk 0.3.322 ([#1577](https://github.com/agentclientprotocol/claude-agent-acp/issues/1577)) ([b89e449](https://github.com/agentclientprotocol/claude-agent-acp/commit/b89e4497da9184072e7f3c4bb28de79801659222))
|
||||
|
||||
## [0.104.0](https://github.com/agentclientprotocol/claude-agent-acp/compare/v0.103.0...v0.104.0) (2026-11-10)
|
||||
|
||||
|
||||
|
||||
88
README.md
88
README.md
@@ -16,7 +16,7 @@ This tool implements an ACP agent by using the official [Claude Agent SDK](https
|
||||
- Nested subagent transcripts
|
||||
- Interactive (and background) terminals
|
||||
- Custom [Slash commands](https://docs.anthropic.com/en/docs/claude-code/slash-commands)
|
||||
- Client MCP servers
|
||||
- Client MCP servers, including the ones that the client serves over the ACP connection ([MCP-over-ACP](https://agentclientprotocol.com/rfds/mcp-over-acp), `"type": "acp"`)
|
||||
- An Ultracode session config option, which turns on Claude Code's dynamic workflows for every task. It appears when dynamic workflows are enabled and the model supports ultracode (any model with `xhigh` effort)
|
||||
- `/mcp` in the chat: the MCP server status as a list. The adapter runs `/mcp reconnect`, `/mcp enable`, and `/mcp disable` through the SDK control API, because Claude Code refuses them in SDK mode. A reconnect of an ACP server that needs authentication starts MCP OAuth through URL elicitation
|
||||
- Session-scoped long-running goals for AIR through the [goal extension](docs/air-extensions.md#goal) under `_meta.jetbrains.air.goal`
|
||||
@@ -46,6 +46,10 @@ Claude CLI (`claude`) it runs. Keep them in the same directory; a symlink to
|
||||
instead, set `CLAUDE_CODE_EXECUTABLE`. On Alpine, install `libgcc` and
|
||||
`libstdc++` first.
|
||||
|
||||
A CLI named with `CLAUDE_CODE_EXECUTABLE` gets a session's MCP servers on its
|
||||
command line, where other users of the machine can read their `env` and
|
||||
`headers`. The CLI that comes with the adapter gets them over stdin.
|
||||
|
||||
To build one for your machine (needs [Bun](https://bun.sh)) and check it:
|
||||
|
||||
```sh
|
||||
@@ -53,81 +57,6 @@ npm run build:binary
|
||||
npm run smoke:binary # add `-- --full` to drive a real session; needs a Claude login
|
||||
```
|
||||
|
||||
### Subagent sessions
|
||||
|
||||
A client that declares `clientCapabilities.subagents`, other than JetBrains AIR, gets each Agent or
|
||||
Task subagent as its own child session, following the [subagents RFD](https://github.com/agentclientprotocol/agent-client-protocol/blob/main/docs/rfds/subagents.mdx):
|
||||
|
||||
- `subagent_update` on the parent announces the child before any of its traffic, with the
|
||||
parent's `title` and `description` for it, and reports its work state: `running`,
|
||||
`requires_action` while one of its requests is open (and `running` again when the last one ends,
|
||||
unless a cancel withdrew it: the child is stopping then), and `idle` when its work ends, with
|
||||
`end_turn` or `cancelled` when the SDK gives the reason. A failure is `idle` with the `error`
|
||||
stop reason and the SDK's error text as its `error`. The child keeps its session for every
|
||||
delegation to it.
|
||||
- A child that runs outside its parent's working directory, such as an Agent call with
|
||||
`isolation: "worktree"`, gets its `cwd` on `subagent_update` before its first tool call. The
|
||||
adapter takes it from the `cwd` of the child's own hooks: its SubagentStart hook runs before its
|
||||
first model request. It sends `cwd: null` when the child is back in its parent's directory. A
|
||||
child in its parent's directory gets no `cwd`, and no child gets `additionalDirectories`: Claude
|
||||
Code gives a subagent the session's additional directories, so it inherits them. A replay
|
||||
announces a child with the `cwd` that its transcript recorded, and clears it after the response
|
||||
when that directory no longer exists.
|
||||
- Session messages replace the Agent or Task call that launches the child, which its parent is
|
||||
not shown:
|
||||
- The launch's prompt is a `session_message` in both transcripts: the parent's outgoing view and
|
||||
the child's incoming one. Both use the launch's tool use id, and each names the other with the
|
||||
draft RFD's `recipientMessageId` and `senderMessageId`.
|
||||
- A foreground child's answer, from the launch's result, is the child's `session_message` to
|
||||
the parent. In Claude Code's hand-back mode, the child's `SubagentHandback` call is its
|
||||
message to the parent instead, in both transcripts and linked the same way.
|
||||
- A launch whose child is never exposed is shown as a tool call after all, with its final
|
||||
status.
|
||||
- The message of a SendMessage call that resumes the child is a `session_message` in the child's
|
||||
transcript. The SendMessage call stays a tool call of the session that made it.
|
||||
- `session/cancel` on the parent interrupts Claude Code, which stops the foreground children that
|
||||
the turn waits on. Background children keep running, as the RFD prefers; a client stops one with
|
||||
its own `cancel`. Each stopped child reports `idle` with `cancelled` from Claude Code's own
|
||||
events, and its open requests are withdrawn. The adapter ends no child at a cancel itself, so a
|
||||
child that keeps running keeps its open requests and its open tool calls. To spare background
|
||||
children, the adapter declares the SDK option `perTaskStopAffordance`, which a client can turn
|
||||
off in `_meta.claudeCode.options`. That option spares background workflows too, which a client
|
||||
cannot stop, so the adapter stops them after the interrupt, as Claude Code did without it.
|
||||
Background commands keep running after a cancel either way. A tool call of a stopped child that Claude Code reports no
|
||||
result for, such as the command it was running, ends in the child's session before the cancelled
|
||||
prompt resolves. When Claude Code stops a background child after that, or while no prompt runs,
|
||||
the tool call ends right after the child reports `idle`. A child that still runs when Claude Code
|
||||
exits is `idle` with no stop reason.
|
||||
- A child whose parent is not yet known when it ends is not exposed, since the RFD forbids
|
||||
guessing its parent.
|
||||
- A replay restores each child under its live session id, from its own transcript, with the same
|
||||
session messages as live, and its end is an `idle` before the response.
|
||||
A launch without Claude Code's metadata file for the child stays an ordinary tool call of the
|
||||
parent, and a notice, for a client that takes notices, says that subagent history is missing.
|
||||
- After a load or resume, with or without replay, a SendMessage that resumes an agent from before
|
||||
it runs that agent in its session from before. Before the agent's traffic, each of its ancestors
|
||||
that the client was not told about in this connection is announced, parent before child and
|
||||
with no work state, as the RFD requires. An agent whose launch the session's history does not
|
||||
record stays unexposed.
|
||||
- Each running child is announced with the `cancel` capability. `session/cancel` with the child's
|
||||
session id stops that child's current work, through the SDK's `Query.stopTask`, and not its
|
||||
parent's: Claude Code also stops the foreground children it waits on, and the parent's turn goes
|
||||
on. Each stopped child reports `idle` with `cancelled` from Claude Code's own events, and its
|
||||
requests that the stop withdraws report no `running` first. A replayed child, which no longer
|
||||
runs, gets no capabilities. A client cannot prompt or otherwise change a child.
|
||||
|
||||
An [ACP v2](#experimental-acp-v2) client gets the same without declaring anything, since subagents
|
||||
are part of v2's baseline. Each child also reports its work state as its own `state_update`, right
|
||||
after the parent's copy.
|
||||
|
||||
JetBrains AIR keeps the earlier draft of the RFD (`subagent_spawned`, `subagent_state_update`),
|
||||
which it enables with `nativeSubagentSessions` in `_meta.jetbrains.air.capabilities`. See
|
||||
[AIR extensions](docs/air-extensions.md#native-subagent-sessions).
|
||||
|
||||
Without either signal, Agent and Task stay ordinary tool calls and child interactions stay on the
|
||||
root session. Clients that use the historical `_meta["subagent-transcript"]` capability or the
|
||||
`forwardSubagentText` session option retain the flattened child transcript.
|
||||
|
||||
### Experimental ACP v2
|
||||
|
||||
The adapter also serves the [draft ACP v2](https://agentclientprotocol.com/protocol/v2/overview):
|
||||
@@ -139,10 +68,11 @@ for v2 is negotiated down to v1. With `v2`, the adapter rejects the `initialize`
|
||||
`auto`, the default, serves both.
|
||||
|
||||
On v2 the adapter serves the session baseline (`session/new`, `session/list`, `session/resume`
|
||||
with replay, `session/close`, `session/prompt`, `session/cancel`), `session/delete`,
|
||||
`session/fork`, additional directories, config options (the mode is one), plans, notices,
|
||||
with replay, which `replay_complete` ends, `session/close`, `session/prompt`, `session/cancel`), `session/delete`,
|
||||
`session/fork`, `session/status`, `session/options` (with initial `configOptions` on `session/new`,
|
||||
`session/resume` and `session/fork`), `session/set_title`, additional directories, config options (the mode is one), plans, notices,
|
||||
compaction, display terminals for commands, permission requests, elicitation, providers, auth, and
|
||||
[subagents](#subagent-sessions). Steering is v1 only for now.
|
||||
[subagents](docs/subagent-sessions.md). Steering is v1 only for now.
|
||||
|
||||
v2 is served by the v2 agent in `src/v2/`, which runs straight on Claude
|
||||
Code instead of translating to v1. A v2 client that declares JetBrains AIR
|
||||
|
||||
@@ -151,7 +151,7 @@ The v2 core (`src/v2/`) serves an AIR client only the extensions that ACP v2 doe
|
||||
Its `initialize` response lists `agentFileChangeReport` and `recommendedValue`.
|
||||
It also serves the [permission presentation](#permission-presentation), the [question custom answers](#question-custom-answers), the [predicted follow-up prompt](#predicted-follow-up-prompt), and [load replay end](#load-replay-end).
|
||||
The [agent file-change report](#agent-file-change-report) goes out at the end of the turn that serves the prompt, before the turn's idle `state_update`, because a v2 `session/prompt` is answered when Claude Code takes the prompt in.
|
||||
ACP v2 covers subagents, background work, file plans, patches, compaction, the system prompt, and turn failures itself, so the v2 core serves no `nativeSubagentSessions`, `backgroundSubagents`, `asyncTasks`, `planFile`, `diffPatch`, `contextCompaction`, `customInstructions`, or `sessionFailure`.
|
||||
ACP v2 covers subagents, background work, plans, patches, compaction, the system prompt, and turn failures itself, so the v2 core serves no `nativeSubagentSessions`, `backgroundSubagents`, `asyncTasks`, `planFile`, `diffPatch`, `contextCompaction`, `customInstructions`, or `sessionFailure`.
|
||||
It does not serve the [tool call contract](#tool-call-contract) yet.
|
||||
|
||||
### Capabilities
|
||||
@@ -228,7 +228,7 @@ The adapter keeps them where they are.
|
||||
|
||||
## Auth source display
|
||||
|
||||
The connection-scoped `_auth/status_update` continues to report agent-owned authentication, not client-owned `providers/set` routing. The adapter also reports the same identity through the ACP `auth/status` method and `auth/status_update` notification (advertised as `auth.status`), with `kind`, `detail` and `plan` under the account's `_meta.claudeCode`. Each notification is sent when its own payload changed. `auth/status` answers with the identity last reported and starts a new read, whose change arrives as a notification. When the active key source is `apiKeyHelper`, the adapter reads the effective helper command through SDK `resolveSettings` / the session's `SettingsManager`, including programmatic settings overrides.
|
||||
The connection-scoped `_auth/status_update` continues to report agent-owned authentication, not client-owned `providers/set` routing. The adapter also reports the same identity through the ACP `auth/status` method and `auth/status_update` notification (advertised as `auth.status`), with `kind`, `detail` and `plan` under the account's `_meta.claudeCode`. The account's `description` carries the `detail` too, e.g. `label: "Anthropic API key"` with `description: "ANTHROPIC_API_KEY"`. Each notification is sent when its own payload changed. `auth/status` answers with the identity last reported and starts a new read, whose change arrives as a notification. When the active key source is `apiKeyHelper`, the adapter reads the effective helper command through SDK `resolveSettings` / the session's `SettingsManager`, including programmatic settings overrides.
|
||||
|
||||
A command containing the whole word `central` and the word sequence `proxy start` is displayed as:
|
||||
|
||||
@@ -240,6 +240,8 @@ Matching is case-insensitive and accepts multiple whitespace characters between
|
||||
|
||||
Other active helpers use `label: "Anthropic API key"` and `detail: "API key helper"`; unknown key-source identifiers are not exposed as display text. CLI and SDK reads share this presentation, retain stale-probe protection, and suppress unchanged notifications.
|
||||
|
||||
For Max subscriptions, the existing `claude auth status --json` probe's optional `planTier` distinguishes `max_20x` (displayed as `Claude Ultra`) from `max_5x` (`Claude Max`). Missing, unrecognized, or malformed tiers fall back to the subscription's usual label. Other subscriptions and auth sources keep their existing classification. The raw `account.plan` and ACP `_meta.claudeCode.plan` remain unchanged. SDK account reads lack the tier, so they preserve the known label for the same account and plan; a fresh CLI read replaces it, including when the tier is absent. This is display metadata, not an entitlement check, and requires no additional probe or direct credential-file reads.
|
||||
|
||||
## Zed conventions
|
||||
|
||||
The adapter keeps these Zed and upstream conventions unchanged for every client.
|
||||
@@ -699,7 +701,7 @@ When `matchedAskRule` is present, the adapter offers no persistent choice. A con
|
||||
| WebFetch | One-time allow; a generated `domain:<hostname>` local rule; reject. |
|
||||
| Skill | One-time allow; exact skill and optional `prefix:*` local rules; reject. |
|
||||
| EnterPlanMode | Enter plan mode once, or reject and continue. |
|
||||
| ExitPlanMode | One keep-context and one clear-context elevated mode (`auto` before bypass before accept edits), manual approval, or reject. |
|
||||
| ExitPlanMode | One keep-context elevated mode, one clear-context mode (with `showClearContextOnPlanAccept` on), manual approval, or reject. |
|
||||
| SandboxNetworkAccess | One-time allow; the exact SDK host rule when representable; reject. |
|
||||
| Computer Use MCP | One-time allow; an exact representable SDK allow suggestion; reject. |
|
||||
| MCP | One-time allow; an exact representable SDK allow suggestion for that tool; reject. |
|
||||
@@ -724,7 +726,9 @@ A host removes `Bypass permissions` with `_meta.claudeCode.options.allowDangerou
|
||||
A `bypassPermissions` settings default then falls back to `default`.
|
||||
|
||||
`ExitPlanMode` offers one elevated keep-context choice by priority: `auto`, then `bypassPermissions`, then `acceptEdits`.
|
||||
A non-empty plan also gets one clear-context choice with the same priority.
|
||||
When Claude Code's `showClearContextOnPlanAccept` setting is on, a non-empty plan also gets one clear-context choice with the same priority.
|
||||
The setting is off by default, as in Claude Code.
|
||||
The adapter reads it as Claude Code does: managed settings first, then the `settings` option of the session, then the user, project, and local settings files.
|
||||
After that choice, the adapter stops the old private Claude query and hides that internal rejection.
|
||||
It starts a new private query under the same ACP session.
|
||||
It continues the turn with `Implement the following plan:` and the complete plan.
|
||||
@@ -1406,6 +1410,8 @@ Each row carries `_meta.jetbrains.air` with flat row fields of the RFDs. `archiv
|
||||
|
||||
`_session/rename { "sessionId": "…", "title": "…" }` returns `{}`.
|
||||
|
||||
ACP's `session/set_title` renames the same way for every client, on v1 and v2, without `sessionIndex`, and returns `{ "title": "…" }`: the title as `session/list` shows it to the client. On v1 an AIR client gets it without the archive prefix, and every other client, and every v2 client, with it.
|
||||
|
||||
- A blank title is `-32602`. The adapter collapses whitespace and keeps the first 200 characters, trimmed, as the CLI does. An `[archived] ` prefix of the requested title is dropped: a rename never changes the archive state.
|
||||
- The title is stored as the title records of [Archive](#archive): a `custom-title` and an `agent-name` record. An archived session keeps its `[archived] ` prefix (and the title is cut to 200 characters with it), so a rename does not unarchive it.
|
||||
- A session that runs here on a CLI without the `rename_session` control request is refused with `-32600`: its CLI holds the title and would write it back.
|
||||
@@ -1668,7 +1674,7 @@ The request has no clear-context option, because the fresh query must continue a
|
||||
"No, keep planning" stops only the followup cycle. There is no turn to end.
|
||||
|
||||
A prompt turn owns the request when the turn is active, or when Claude Code asks before the echo of its prompt.
|
||||
Then the request has the clear-context option.
|
||||
Then the request has the clear-context option, when `showClearContextOnPlanAccept` is on.
|
||||
A turn that took over a followup cycle also owns the request of that cycle, and the accepted plan continues in that turn.
|
||||
|
||||
## Context compaction
|
||||
@@ -1728,8 +1734,9 @@ A client that is not AIR gets neither key.
|
||||
|
||||
## Load replay end
|
||||
|
||||
ACP has no signal that the history replay of `session/load` is over, other than the response.
|
||||
ACP v1 has no signal that the history replay of `session/load` is over, other than the response.
|
||||
The adapter replays the transcript while the Claude Code CLI starts, so the history can arrive long before the response.
|
||||
ACP v2 has the `replay_complete` update for this, which the adapter sends to every v2 client.
|
||||
|
||||
The client declares `loadReplayEnd` in its capabilities. The agent does not advertise it.
|
||||
After the history replay of the loaded session, the agent then sends one more update for that session:
|
||||
@@ -1747,7 +1754,7 @@ After the history replay of the loaded session, the agent then sends one more up
|
||||
- The update has no `title` and no `updatedAt`. A `null` there would clear the value.
|
||||
- It comes after every replayed update, the subagent history that the replay sends to the child sessions included, and before the `session/load` response.
|
||||
- It comes also for an empty history.
|
||||
- It comes for `session/load` of a new or an already live session, and for the ACP v2 `session/resume` with `replayFrom: {type: "start"}`.
|
||||
- It comes for `session/load` of a new or an already live session, and for the ACP v2 `session/resume` with `replayFrom: {type: "start"}`. On v2 it comes right after the session's `replay_complete`, which marks the same point.
|
||||
- It does not come when the replay stops or fails. The replay stops when the CLI start fails during the replay.
|
||||
- It does not come for a live update, and it does not come to a client without the capability.
|
||||
- The `session/load` can still fail after it, for example when the CLI start fails after the replay. The event means that the recorded history arrived whole. The client decides what to do with the failed load.
|
||||
|
||||
95
docs/subagent-sessions.md
Normal file
95
docs/subagent-sessions.md
Normal file
@@ -0,0 +1,95 @@
|
||||
# Subagent sessions
|
||||
|
||||
A client that declares `clientCapabilities.subagents`, other than JetBrains AIR, gets each Agent or
|
||||
Task subagent as its own child session, following the [subagents RFD](https://github.com/agentclientprotocol/agent-client-protocol/blob/main/docs/rfds/subagents.mdx):
|
||||
|
||||
- `subagent_update` on the parent announces the child before any of its traffic, with the
|
||||
parent's `title` and `description` for it, and reports its work state: `running`,
|
||||
`requires_action` while one of its requests is open (and `running` again when the last one ends,
|
||||
unless a cancel withdrew it: the child is stopping then), and `idle` when its work ends, with
|
||||
`end_turn` or `cancelled` when the SDK gives the reason. A failure is `idle` with the `error`
|
||||
stop reason and the SDK's error text as its `error`. The child keeps its session for every
|
||||
delegation to it.
|
||||
- A child that still works when Claude Code starts a fresh conversation, such as for `/clear`, is
|
||||
`unknown`, and loses its `cancel` capability. Claude Code can keep such a child running, but the
|
||||
adapter forgets the children of the old conversation, so it reports nothing more for it and
|
||||
cannot stop it. Its unfinished tool calls keep their status. An idle child keeps its state.
|
||||
- A child that runs outside its parent's working directory, such as an Agent call with
|
||||
`isolation: "worktree"`, gets its `cwd` on `subagent_update` before its first tool call. The
|
||||
adapter takes it from the `cwd` of the child's own hooks: its SubagentStart hook runs before its
|
||||
first model request. It sends `cwd: null` when the child is back in its parent's directory. A
|
||||
child in its parent's directory gets no `cwd`, and no child gets `additionalDirectories`: Claude
|
||||
Code gives a subagent the session's additional directories, so it inherits them. A replay
|
||||
announces a child with the `cwd` that its transcript recorded, and clears it after the response
|
||||
when that directory no longer exists.
|
||||
- Session messages replace the Agent or Task call that launches the child, which its parent is
|
||||
not shown:
|
||||
- The launch's prompt is a `session_message` in both transcripts: the parent's outgoing view and
|
||||
the child's incoming one. Both use the launch's tool use id, and each names the other with the
|
||||
RFD's `recipientMessageId` and `senderMessageId`.
|
||||
- A foreground child's answer, from the launch's result, is the child's `session_message` to
|
||||
the parent. In Claude Code's hand-back mode, the child's `SubagentHandback` call is its
|
||||
message to the parent instead, in both transcripts and linked the same way.
|
||||
- A launch whose child is never exposed is shown as a tool call after all, with its final
|
||||
status.
|
||||
- A SendMessage call that resumes the child is not shown either. Its message is a
|
||||
`session_message` in both transcripts, the sender's outgoing view and the child's incoming one,
|
||||
linked like a launch's prompt. A SendMessage call whose message resumes no announced child,
|
||||
such as one to the parent, is shown as a tool call, with its final status.
|
||||
- Every message is one whole `session_message`. The adapter sends no `session_message_chunk`: it
|
||||
has each message's full text before it reports it, from the input or the result of the tool call
|
||||
that sent it.
|
||||
- A tool call that the client is shown and that operates on an announced child of another session
|
||||
carries the RFD's `session` content, `{ "type": "session", "sessionId": "<child>" }`, after its
|
||||
other content: a TaskStop call whose `task_id`, or a SendMessage call whose `to`, is the child's
|
||||
agent id; a SendMessage call that resumed the child and stays shown because a permission request
|
||||
showed it first; and, on v1, an Agent or Task call that stays shown for the same reason. A
|
||||
`tool_call_update` without content carries none, since it would replace the content the client
|
||||
holds. A call that names the child by its name gets no reference: Claude Code resolves the
|
||||
name, and the adapter cannot tell which agent it picked.
|
||||
- `session/cancel` on the parent interrupts Claude Code, which stops the foreground children that
|
||||
the turn waits on. Background children keep running, as the RFD prefers; a client stops one with
|
||||
its own `cancel`. Each stopped child reports `idle` with `cancelled` from Claude Code's own
|
||||
events, and its open requests are withdrawn. The adapter ends no child at a cancel itself, so a
|
||||
child that keeps running keeps its open requests and its open tool calls. To spare background
|
||||
children, the adapter declares the SDK option `perTaskStopAffordance`, which a client can turn
|
||||
off in `_meta.claudeCode.options`. That option spares background workflows too, which a client
|
||||
cannot stop, so the adapter stops them after the interrupt, as Claude Code did without it.
|
||||
Background commands keep running after a cancel either way. A tool call of a stopped child that Claude Code reports no
|
||||
result for, such as the command it was running, ends in the child's session before the cancelled
|
||||
prompt resolves. When Claude Code stops a background child after that, or while no prompt runs,
|
||||
the tool call ends right after the child reports `idle`. A child that still runs when Claude Code
|
||||
exits is `idle`, since its work ended with the process: with no stop reason on v1, and on v2
|
||||
with the `error` stop reason and the error that ends the root's work.
|
||||
- A child whose parent is not yet known when it ends is not exposed, since the RFD forbids
|
||||
guessing its parent.
|
||||
- A replay restores each child under its live session id, from its own transcript, with the same
|
||||
session messages and `session` references as live, and its end is an `idle` before the response.
|
||||
Each replayed child's current state follows the response.
|
||||
A launch without Claude Code's metadata file for the child stays an ordinary tool call of the
|
||||
parent, and a notice, for a client that takes notices, says that subagent history is missing.
|
||||
- After a load or resume, with or without replay, a SendMessage that resumes an agent from before
|
||||
it runs that agent in its session from before. Before the agent's traffic, each of its ancestors
|
||||
that the client was not told about in this connection is announced, parent before child and
|
||||
with no work state, as the RFD requires. An agent whose launch the session's history does not
|
||||
record stays unexposed.
|
||||
- Each running child is announced with the `cancel` capability. `session/cancel` with the child's
|
||||
session id stops that child's current work, through the SDK's `Query.stopTask`, and not its
|
||||
parent's: Claude Code also stops the foreground children it waits on, and the parent's turn goes
|
||||
on. Each stopped child reports `idle` with `cancelled` from Claude Code's own events, and its
|
||||
requests that the stop withdraws report no `running` first. A replayed child, which no longer
|
||||
runs, gets no capabilities. A client cannot prompt or otherwise change a child.
|
||||
|
||||
An [ACP v2](../README.md#experimental-acp-v2) client gets the same without declaring anything, since subagents
|
||||
are part of v2's baseline. Each child also reports its work state as its own `state_update`, right
|
||||
after the parent's copy. A replay ends each child's history with a `replay_complete` on the child's
|
||||
session, before the child's `idle`. The notice that subagent history is missing follows the
|
||||
parent's `replay_complete`.
|
||||
|
||||
JetBrains AIR keeps the earlier draft of the RFD (`subagent_spawned`, `subagent_state_update`),
|
||||
which it enables with `nativeSubagentSessions` in `_meta.jetbrains.air.capabilities`. See
|
||||
[AIR extensions](air-extensions.md#native-subagent-sessions).
|
||||
|
||||
Without either signal, Agent and Task stay ordinary tool calls and child interactions stay on the
|
||||
root session. Clients that use the historical `_meta["subagent-transcript"]` capability or the
|
||||
`forwardSubagentText` session option retain the flattened child transcript.
|
||||
578
package-lock.json
generated
578
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@@ -3,7 +3,7 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"version": "0.104.0",
|
||||
"version": "0.108.0",
|
||||
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
||||
"main": "dist/lib.js",
|
||||
"types": "dist/lib.d.ts",
|
||||
@@ -68,24 +68,24 @@
|
||||
"node": ">=22"
|
||||
},
|
||||
"dependencies": {
|
||||
"@agentclientprotocol/sdk": "2.5.0",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.321",
|
||||
"@agentclientprotocol/sdk": "2.7.0",
|
||||
"@anthropic-ai/claude-agent-sdk": "0.3.326",
|
||||
"diff": "9.0.0",
|
||||
"zod": "4.6.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anthropic-ai/sdk": "1.7.0",
|
||||
"@anthropic-ai/sdk": "1.9.0",
|
||||
"@eslint/js": "10.0.1",
|
||||
"@tsconfig/node22": "22.0.6",
|
||||
"@tsconfig/node22": "22.0.7",
|
||||
"@types/node": "26.6.6",
|
||||
"@typescript-eslint/eslint-plugin": "8.72.2",
|
||||
"@typescript-eslint/parser": "8.72.2",
|
||||
"@typescript-eslint/eslint-plugin": "8.73.0",
|
||||
"@typescript-eslint/parser": "8.73.0",
|
||||
"ajv": "8.20.0",
|
||||
"ajv-formats": "3.0.1",
|
||||
"eslint": "10.14.0",
|
||||
"eslint": "10.15.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"globals": "17.14.0",
|
||||
"prettier": "3.9.10",
|
||||
"prettier": "3.10.1",
|
||||
"typescript": "6.0.3",
|
||||
"vitest": "5.1.0"
|
||||
}
|
||||
|
||||
@@ -74,9 +74,24 @@ try {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// By default a compiled executable loads `.env`, `.env.local` and `bunfig.toml`
|
||||
// from its working directory at startup. That directory is the user's project:
|
||||
// its dotenv values would reach Claude and every Bash command as real
|
||||
// environment variables (overriding the project's own `.env.test`), and a
|
||||
// `bunfig.toml` that fails to parse would stop the agent from starting.
|
||||
const bun = spawnSync(
|
||||
"bun",
|
||||
["build", "src/binary-entry.ts", "--compile", "--target", target, "--outfile", outfile],
|
||||
[
|
||||
"build",
|
||||
"src/binary-entry.ts",
|
||||
"--compile",
|
||||
"--no-compile-autoload-dotenv",
|
||||
"--no-compile-autoload-bunfig",
|
||||
"--target",
|
||||
target,
|
||||
"--outfile",
|
||||
outfile,
|
||||
],
|
||||
{ cwd: repoRoot, stdio: "inherit", shell: process.platform === "win32" },
|
||||
);
|
||||
if (bun.error) {
|
||||
|
||||
@@ -58,8 +58,9 @@ function check(ok, label, detail) {
|
||||
|
||||
// ---------------------------------------------------------------- basic
|
||||
|
||||
function runSync(args, [cmd, ...cmdArgs] = [command, ...commandArgs]) {
|
||||
function runSync(args, [cmd, ...cmdArgs] = [command, ...commandArgs], cwd) {
|
||||
const result = spawnSync(cmd, [...cmdArgs, ...args], {
|
||||
cwd,
|
||||
encoding: "utf8",
|
||||
timeout: 60_000,
|
||||
});
|
||||
@@ -101,6 +102,26 @@ if (positionals.length === 0) {
|
||||
"without claude next to it, says the CLI is missing",
|
||||
missing.stdout || missing.error,
|
||||
);
|
||||
|
||||
// Started in a project directory, the executable must not read the
|
||||
// project's dotenv files or bunfig.toml. Node stands in for `claude`, to
|
||||
// print the environment the CLI is spawned with.
|
||||
copyFileSync(process.execPath, join(scratch, `claude${exe}`));
|
||||
const project = join(scratch, "project");
|
||||
mkdirSync(project);
|
||||
writeFileSync(join(project, ".env"), "ACP_SMOKE_DOTENV=leaked\n");
|
||||
writeFileSync(join(project, ".env.local"), "ACP_SMOKE_DOTENV_LOCAL=leaked\n");
|
||||
writeFileSync(join(project, "bunfig.toml"), "= not toml\n");
|
||||
const probe = runSync(
|
||||
["--cli", "-p", "[process.env.ACP_SMOKE_DOTENV, process.env.ACP_SMOKE_DOTENV_LOCAL].join()"],
|
||||
[alone],
|
||||
project,
|
||||
);
|
||||
check(
|
||||
probe.stdout === ",",
|
||||
"ignores .env, .env.local and bunfig.toml in the working directory",
|
||||
probe.stdout || probe.error,
|
||||
);
|
||||
} finally {
|
||||
rmSync(scratch, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ import type {
|
||||
CompleteElicitationNotification,
|
||||
CreateElicitationRequest,
|
||||
CreateElicitationResponse,
|
||||
McpServerAcp,
|
||||
ReadTextFileRequest,
|
||||
ReadTextFileResponse,
|
||||
RequestPermissionResponse,
|
||||
WriteTextFileRequest,
|
||||
WriteTextFileResponse,
|
||||
} from "@agentclientprotocol/sdk/unstable";
|
||||
import type { McpHttpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
||||
import type { AcpSessionNotification } from "./acp-subagents.js";
|
||||
import type { AcpPermissionRequest } from "./permissions/presentation.js";
|
||||
|
||||
@@ -16,7 +18,7 @@ import type { AcpPermissionRequest } from "./permissions/presentation.js";
|
||||
* Client-facing surface the agent calls back into. This is the subset of ACP
|
||||
* client methods the agent actually uses, expressed as a narrow interface so
|
||||
* tests can supply lightweight mocks. In the v1 agent it is backed by
|
||||
* `ClientConnection` (`v1/acp-agent.ts`) over the SDK's typed `AgentContext`.
|
||||
* `ClientConnection` (`v1/client-connection.ts`) over the SDK's typed `AgentContext`.
|
||||
* The v2 session output passes one that only takes `sessionUpdate`
|
||||
* (`v2/stream.ts`).
|
||||
*/
|
||||
@@ -43,4 +45,10 @@ export interface AcpClient {
|
||||
authStatusUpdate(params: AuthStatusUpdateNotification): Promise<void>;
|
||||
/** Send a custom (extension) notification, e.g. `_claude/sdkMessage`. */
|
||||
extNotification(method: string, params: Record<string, unknown>): Promise<void>;
|
||||
/**
|
||||
* The SDK config of an MCP server that the client serves over this
|
||||
* connection (`"type": "acp"`): an endpoint that sends each MCP request to
|
||||
* the client as `mcp/message` (see `McpOverAcp` in `mcp-servers.ts`).
|
||||
*/
|
||||
mcpServerOverAcp(server: McpServerAcp): Promise<McpHttpServerConfig>;
|
||||
}
|
||||
|
||||
@@ -879,7 +879,7 @@ function recordPublished(task: AsyncTask, fields: Record<string, unknown>): void
|
||||
* its tool result. The text of a tool result never gives a task id: a
|
||||
* foreground command can print any text.
|
||||
*
|
||||
* Claude Code sends no `tool_use_result` with a subagent's tool results. For
|
||||
* Claude Code sends no `tool_use_result` with a subagent's Bash results. For
|
||||
* those, `startedTaskOf` gives the background `local_bash` task whose
|
||||
* `task_started` named the Bash call, which comes before the result.
|
||||
*/
|
||||
|
||||
@@ -188,8 +188,8 @@ export class AuthStatusReporter {
|
||||
/**
|
||||
* Report the identity behind a session's `AccountInfo`.
|
||||
*
|
||||
* `AccountInfo` is richer than the CLI probe (it is what the live query
|
||||
* actually authenticates with). The v1 core calls it before the
|
||||
* `AccountInfo` describes what the live query authenticates with, but lacks
|
||||
* the CLI's plan tier. The v1 core calls it before the
|
||||
* `--hide-claude-auth` guard may refuse the session or the turn: that flag
|
||||
* blocks the *use* of a subscription, it does not make the state secret, and
|
||||
* a refusal is when the client most needs to know the account it was
|
||||
@@ -225,7 +225,7 @@ export class AuthStatusReporter {
|
||||
}
|
||||
const fromSession = fromAccountInfo(account, apiKeyHelper);
|
||||
if (fromSession) {
|
||||
this.set(fromSession);
|
||||
this.set(mergeAuthStatus(this.current, fromSession, "session"));
|
||||
} else if (!this.loggedUninformativeAccount) {
|
||||
this.loggedUninformativeAccount = true;
|
||||
this.options.logger.log(
|
||||
@@ -337,7 +337,7 @@ export class AuthStatusReporter {
|
||||
// The CLI probe can be poorer than the session `AccountInfo` for the very
|
||||
// same login (no organization, say). Keep those extra fields rather than
|
||||
// regressing the payload; a different identity replaces it wholesale.
|
||||
const merged = mergeAuthStatus(this.current, status);
|
||||
const merged = mergeAuthStatus(this.current, status, "cli");
|
||||
this.set(merged);
|
||||
this.options.onProbe?.(status.kind);
|
||||
return merged;
|
||||
|
||||
@@ -104,8 +104,10 @@ export type AcpAuthStatus = Pick<AuthStatusResponse, "state" | "accounts">;
|
||||
* - No identity read yet (`undefined`): `unknown`, no accounts.
|
||||
* - `kind: "none"`: `unauthenticated`, no accounts.
|
||||
* - Any other kind: `authenticated`, with the identity as the one account,
|
||||
* marked `active`. `_meta.claudeCode` carries the `kind`, `detail` and
|
||||
* `plan` that the account fields have no place for.
|
||||
* marked `active`. `detail` is the account's `description`, e.g. label
|
||||
* "Anthropic API key" with description "ANTHROPIC_API_KEY".
|
||||
* `_meta.claudeCode` carries the `kind` and `plan`, and the `detail` again
|
||||
* for clients that read it there.
|
||||
*
|
||||
* `--hide-claude-auth` does not change the payload: it reports the login the
|
||||
* CLI holds, also when the subscription guard refuses to use it.
|
||||
@@ -118,6 +120,7 @@ export function toAcpAuthStatus(status: AuthStatus | undefined): AcpAuthStatus {
|
||||
return { state: "unauthenticated" };
|
||||
}
|
||||
const account: AuthAccount = { label: status.label, active: true };
|
||||
if (status.detail) account.description = status.detail;
|
||||
if (status.account?.email) account.email = status.account.email;
|
||||
if (status.account?.organization) account.organization = status.account.organization;
|
||||
account._meta = {
|
||||
@@ -141,6 +144,8 @@ export type CliAuthStatus = {
|
||||
orgId?: string;
|
||||
orgName?: string;
|
||||
subscriptionType?: string;
|
||||
/** CLI-only tier, e.g. "max_5x" or "max_20x"; not in SDK AccountInfo. */
|
||||
planTier?: string;
|
||||
};
|
||||
|
||||
const NOT_LOGGED_IN: AuthStatus = {
|
||||
@@ -267,6 +272,7 @@ export function fromCliStatus(stdout: string, apiKeyHelper?: string): AuthStatus
|
||||
return mapAuthFields({
|
||||
apiProvider: status.apiProvider,
|
||||
subscriptionType: status.subscriptionType,
|
||||
planTier: status.planTier,
|
||||
apiKeySource: status.apiKeySource,
|
||||
email: status.email,
|
||||
organization: status.orgName,
|
||||
@@ -287,6 +293,7 @@ export function fromCliStatus(stdout: string, apiKeyHelper?: string): AuthStatus
|
||||
function mapAuthFields(fields: {
|
||||
apiProvider?: string;
|
||||
subscriptionType?: string;
|
||||
planTier?: string;
|
||||
apiKeySource?: string;
|
||||
email?: string;
|
||||
organization?: string;
|
||||
@@ -326,7 +333,7 @@ function mapAuthFields(fields: {
|
||||
if (organization) account.organization = organization;
|
||||
return {
|
||||
kind: "account",
|
||||
label: planLabel(subscriptionType),
|
||||
label: planLabel(subscriptionType, fields.planTier),
|
||||
// No detail: the client falls back to `account.email` for line 2.
|
||||
account,
|
||||
};
|
||||
@@ -334,12 +341,14 @@ function mapAuthFields(fields: {
|
||||
return notLoggedInAuthStatus();
|
||||
}
|
||||
|
||||
/** Names the plan with exactly one "Claude". A newer CLI already reports
|
||||
* "Claude Max", an older one reports "max", and both must read "Claude Max".
|
||||
* Each word is title-cased; a word that already carries capitals is kept. */
|
||||
function planLabel(plan: string): string {
|
||||
/** Names the plan with exactly one "Claude". Without a tier, "Claude Max"
|
||||
* from a newer CLI and "max" from an older one both read "Claude Max".
|
||||
* Each word is title-cased; a word that already carries capitals is kept.
|
||||
* The CLI's max_20x tier identifies Ultra; other tiers keep the plan label. */
|
||||
function planLabel(plan: string, planTier?: string): string {
|
||||
const titled = plan.replace(/\S+/g, (word) => word.charAt(0).toUpperCase() + word.slice(1));
|
||||
return /^claude(\s|$)/i.test(plan) ? titled : `Claude ${titled}`;
|
||||
const label = /^claude(\s|$)/i.test(plan) ? titled : `Claude ${titled}`;
|
||||
return label.toLowerCase() === "claude max" && planTier === "max_20x" ? "Claude Ultra" : label;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,8 +376,14 @@ export function sameIdentity(a: AuthStatus, b: AuthStatus): boolean {
|
||||
* organization the CLI probe omits. So when the read describes the same
|
||||
* identity, its values win field by field but the fields it lacks are kept;
|
||||
* when it describes a different identity, it replaces the old one wholesale.
|
||||
* Session reads lack the CLI's plan tier, so keep the label for the same plan.
|
||||
* A CLI read always replaces the label, including when its tier is absent.
|
||||
*/
|
||||
export function mergeAuthStatus(previous: AuthStatus | undefined, next: AuthStatus): AuthStatus {
|
||||
export function mergeAuthStatus(
|
||||
previous: AuthStatus | undefined,
|
||||
next: AuthStatus,
|
||||
source: "cli" | "session",
|
||||
): AuthStatus {
|
||||
if (!previous || !sameIdentity(previous, next)) {
|
||||
return next;
|
||||
}
|
||||
@@ -379,6 +394,14 @@ export function mergeAuthStatus(previous: AuthStatus | undefined, next: AuthStat
|
||||
if (previous.account || next.account) {
|
||||
merged.account = { ...previous.account, ...next.account };
|
||||
}
|
||||
if (
|
||||
source === "session" &&
|
||||
previous.account?.plan &&
|
||||
next.account?.plan &&
|
||||
planLabel(previous.account.plan).toLowerCase() === planLabel(next.account.plan).toLowerCase()
|
||||
) {
|
||||
merged.label = previous.label;
|
||||
}
|
||||
if (merged.vendor === undefined && previous.vendor !== undefined) {
|
||||
merged.vendor = previous.vendor;
|
||||
}
|
||||
|
||||
@@ -129,3 +129,166 @@ export class BackgroundOutputTail {
|
||||
await this.publish({ text, replaces });
|
||||
}
|
||||
}
|
||||
|
||||
/** What Claude Code's `get_task_output` returns: the end of a shell task's output. */
|
||||
export interface TaskOutput {
|
||||
/** At most the last 8 KiB of the output, decoded as UTF-8. */
|
||||
output: string;
|
||||
/** The size of the whole output in bytes. */
|
||||
total_bytes: number;
|
||||
/** Whether `output` holds only the end of the output. */
|
||||
truncated: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The most bytes at the start of a truncated `output` that may not match the
|
||||
* command's bytes: a character that the 8 KiB cut split decodes as U+FFFD.
|
||||
*/
|
||||
const CUT_CHARACTER_BYTES = 4;
|
||||
|
||||
/**
|
||||
* Follows the output of a command that runs in the foreground, read with
|
||||
* `read` (Claude Code's `get_task_output`), and hands each piece of new text
|
||||
* to `publish`, in order. Claude Code streams no output of a foreground Bash
|
||||
* command either: the output arrives in the tool result. Claude Code writes
|
||||
* the output to the command's task before then, and `get_task_output` reads
|
||||
* it, though the task's `task_started` names no output file.
|
||||
*
|
||||
* The new text is the output past the bytes already sent. When `output` does
|
||||
* not hold all of it, or its bytes may not match the command's (not UTF-8),
|
||||
* the whole `output` replaces the terminal's output, as a snapshot. A read
|
||||
* that ends in U+FFFD may have cut a character that the command is still
|
||||
* writing, so it is sent only at the next read.
|
||||
*
|
||||
* Once the command ends, Claude Code drops its output: the task then reads as
|
||||
* empty (`total_bytes: 0`, CLI 2.1.325), up to the tool result that carries
|
||||
* the whole output. A read that holds less than was sent is that end, so it
|
||||
* stops the poll and publishes nothing: an empty snapshot would clear the
|
||||
* terminal.
|
||||
*
|
||||
* One read runs at a time: a poll that comes during a read is skipped, so a
|
||||
* read that Claude Code never answers queues nothing behind it. A read that
|
||||
* fails is tried again at the next poll. `publish` must not reject.
|
||||
*/
|
||||
export class TaskOutputPoll {
|
||||
private sentBytes = 0;
|
||||
private sent = false;
|
||||
private stopped = false;
|
||||
/** A read is in progress, or the publish of its text. */
|
||||
private busy = false;
|
||||
/** The publish in progress, or the last one. */
|
||||
private publishing: Promise<void> = Promise.resolve();
|
||||
private readonly timer: ReturnType<typeof setInterval>;
|
||||
|
||||
constructor(
|
||||
private readonly read: () => Promise<TaskOutput>,
|
||||
private readonly publish: (output: BackgroundOutput) => Promise<void>,
|
||||
) {
|
||||
this.timer = setInterval(() => void this.poll(), BACKGROUND_OUTPUT_POLL_MS);
|
||||
// A command that runs on must not keep the agent process alive.
|
||||
this.timer.unref();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops, once a publish in progress is out. Returns whether any text was
|
||||
* published: the tool result then replaces it with the whole output.
|
||||
*
|
||||
* A read in progress is not waited for. It publishes nothing after this,
|
||||
* and Claude Code may never answer it.
|
||||
*/
|
||||
async finish(): Promise<boolean> {
|
||||
this.stop();
|
||||
await this.publishing;
|
||||
return this.sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops now and returns whether any text was published, for a caller whose
|
||||
* `publish` sends in the same synchronous step (v2), so none is in progress.
|
||||
*/
|
||||
end(): boolean {
|
||||
this.stop();
|
||||
return this.sent;
|
||||
}
|
||||
|
||||
/** Stops without waiting: the command's task, the query or the session ended. */
|
||||
stop(): void {
|
||||
clearInterval(this.timer);
|
||||
this.stopped = true;
|
||||
}
|
||||
|
||||
private async poll(): Promise<void> {
|
||||
if (this.stopped || this.busy) return;
|
||||
this.busy = true;
|
||||
try {
|
||||
const read = await this.read();
|
||||
if (this.stopped) return;
|
||||
if (read.total_bytes < this.sentBytes) {
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
const output = this.newText(read);
|
||||
if (output === undefined) return;
|
||||
this.sentBytes = read.total_bytes;
|
||||
this.sent = true;
|
||||
this.publishing = this.publish(output);
|
||||
await this.publishing;
|
||||
} catch {
|
||||
// The read failed: try again at the next poll.
|
||||
} finally {
|
||||
this.busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The text that `read` adds to what was sent, or undefined when it adds none
|
||||
* yet. `read` holds at least the bytes that were sent.
|
||||
*/
|
||||
private newText({ output, total_bytes, truncated }: TaskOutput): BackgroundOutput | undefined {
|
||||
if (total_bytes === this.sentBytes || output.endsWith("\uFFFD")) return undefined;
|
||||
const bytes = Buffer.from(output, "utf8");
|
||||
const added = total_bytes - this.sentBytes;
|
||||
const exact = truncated
|
||||
? added <= bytes.length - CUT_CHARACTER_BYTES
|
||||
: bytes.length === total_bytes;
|
||||
// `sentBytes` ends a read that ended in a whole character, so the cut is
|
||||
// at a character boundary.
|
||||
if (exact) {
|
||||
return { text: bytes.subarray(bytes.length - added).toString("utf8"), replaces: false };
|
||||
}
|
||||
return { text: output, replaces: true };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The id of the tool call whose command the task `started` runs in the
|
||||
* foreground, or undefined for any other task. Claude Code starts the task of
|
||||
* a foreground command once the command has run for a few seconds (3.1 s with
|
||||
* CLI 2.1.325). A faster command gets no task, and its output comes with its
|
||||
* tool result, as before.
|
||||
*/
|
||||
export function foregroundCommandToolCall(started: {
|
||||
task_type?: string;
|
||||
is_backgrounded?: boolean;
|
||||
tool_use_id?: string;
|
||||
}): string | undefined {
|
||||
return started.task_type === "local_bash" && started.is_backgrounded === false
|
||||
? started.tool_use_id
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/** Whether a call of the tool `name` runs a command that a terminal shows. */
|
||||
export function isCommandTool(name: string | undefined): boolean {
|
||||
return name === "Bash" || name === "PowerShell";
|
||||
}
|
||||
|
||||
/**
|
||||
* Claude Code's `get_task_output` on the SDK's query. Like `mcpAuthenticate`,
|
||||
* it is on the query object but not in the public `Query` declaration yet,
|
||||
* though the SDK types its control request (`SDKControlGetTaskOutputRequest`).
|
||||
*/
|
||||
export type TaskOutputQuery = { getTaskOutput(taskId: string): Promise<TaskOutput> };
|
||||
|
||||
export function supportsTaskOutput<T extends object>(query: T): query is T & TaskOutputQuery {
|
||||
return typeof (query as Partial<TaskOutputQuery>).getTaskOutput === "function";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import type { Options } from "@anthropic-ai/claude-agent-sdk";
|
||||
|
||||
const CLI_FILE_NAME = process.platform === "win32" ? "claude.exe" : "claude";
|
||||
|
||||
@@ -30,6 +31,28 @@ export async function claudeCliPath(): Promise<string> {
|
||||
return installedClaudeCliPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* How a session's MCP servers reach the CLI of {@link claudeCliPath}, unless
|
||||
* the client's options name a `mcpServersDelivery`.
|
||||
*
|
||||
* - `'initialize'` for the CLI that the adapter ships: over stdin, in the
|
||||
* SDK's initialize request. A server's `env` and `headers`, such as the
|
||||
* bearer token of an MCP-over-ACP endpoint (see `McpOverAcp`), stay off the
|
||||
* CLI's command line, which other users of the machine can read. Only a
|
||||
* launch that the client's options give `--sdk-url` still gets them there.
|
||||
* - `'argv'` for a CLI that `CLAUDE_CODE_EXECUTABLE` names: in the
|
||||
* `--mcp-config` flag, so on its command line, as before SDK 0.3.326. Its
|
||||
* version is not known, and the SDK ends the session at startup when the CLI
|
||||
* cannot read the servers from the initialize request (e.g. 2.1.323).
|
||||
*
|
||||
* The adapter always sets the option. It names the CLI to start
|
||||
* (`pathToClaudeCodeExecutable`), and for such an app the SDK prints a
|
||||
* `DeprecationWarning` when a session has MCP servers and the option is unset.
|
||||
*/
|
||||
export function mcpServersDelivery(): NonNullable<Options["mcpServersDelivery"]> {
|
||||
return process.env.CLAUDE_CODE_EXECUTABLE ? "argv" : "initialize";
|
||||
}
|
||||
|
||||
function bundledClaudeCliPath(directory: string): string {
|
||||
const path = join(directory, CLI_FILE_NAME);
|
||||
// Without this check, spawning a missing CLI fails with a bare ENOENT.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* `getContextUsage`, and learned from each result's `modelUsage`.
|
||||
*/
|
||||
import type { ModelInfo, Query } from "@anthropic-ai/claude-agent-sdk";
|
||||
import { DEFAULT_CONTEXT_WINDOW, inferContextWindowFromModel } from "./session-usage.js";
|
||||
import { DEFAULT_CONTEXT_WINDOW } from "./session-usage.js";
|
||||
|
||||
/** Cross-session cache of authoritative context windows, keyed by
|
||||
* `${providerCacheKey}\0${modelId}` (see {@link contextWindowCacheKey}).
|
||||
@@ -61,8 +61,8 @@ const PROVIDER_ROUTING_ENV_VARS = [
|
||||
* Header/credential values can be secrets; the key only ever lives as an
|
||||
* in-memory Map key and is never logged or surfaced. Over-keying is the safe
|
||||
* side: a var change that didn't really change the backend costs one cache
|
||||
* miss (heuristic seed until the next result), while under-keying would serve
|
||||
* one backend's window for another's. */
|
||||
* miss (the default window until Claude Code reports it), while under-keying
|
||||
* would serve one backend's window for another's. */
|
||||
export function providerCacheKeyFor(env: Record<string, string | undefined>): string {
|
||||
return PROVIDER_ROUTING_ENV_VARS.map((name) => env[name] ?? "").join("\0");
|
||||
}
|
||||
@@ -107,31 +107,24 @@ export function cacheResultContextWindow(
|
||||
/** The context window to report *right now* for a model, with NO IPC on the
|
||||
* critical path: the cached authoritative value if we've learned it (from a
|
||||
* prior turn's `result.modelUsage`, this or any session on the same backend),
|
||||
* else the text heuristic over the model row's identity strings, else the
|
||||
* default. Derives the cache key itself — `modelInfo?.resolvedModel ?? modelId`,
|
||||
* the same rule at every seed site — so read keys can't drift from the write
|
||||
* site's spelling. `authoritative` reports whether the value came from the
|
||||
* cache: an authoritative window can legitimately equal
|
||||
* DEFAULT_CONTEXT_WINDOW, so the value alone can't tell the caller. */
|
||||
* else DEFAULT_CONTEXT_WINDOW. The model's names do not give the window:
|
||||
* Claude Code 2.1.323 reports 1M for `sonnet`, and 200K for it under
|
||||
* `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`. Derives the cache key itself —
|
||||
* `modelInfo?.resolvedModel ?? modelId`, the same rule at every seed site — so
|
||||
* read keys can't drift from the write site's spelling. `authoritative`
|
||||
* reports whether the value came from the cache: an authoritative window can
|
||||
* legitimately equal DEFAULT_CONTEXT_WINDOW, so the value alone can't tell the
|
||||
* caller. */
|
||||
export function immediateContextWindow(
|
||||
providerCacheKey: string,
|
||||
modelId: string,
|
||||
modelInfo?: Pick<ModelInfo, "resolvedModel" | "displayName" | "description">,
|
||||
modelInfo?: Pick<ModelInfo, "resolvedModel">,
|
||||
): { size: number; authoritative: boolean } {
|
||||
const cached = contextWindowCache.get(
|
||||
contextWindowCacheKey(providerCacheKey, modelInfo?.resolvedModel ?? modelId),
|
||||
);
|
||||
if (cached !== undefined) return { size: cached, authoritative: true };
|
||||
return {
|
||||
size:
|
||||
inferContextWindowFromModel(
|
||||
modelId,
|
||||
modelInfo?.resolvedModel,
|
||||
modelInfo?.displayName,
|
||||
modelInfo?.description,
|
||||
) ?? DEFAULT_CONTEXT_WINDOW,
|
||||
authoritative: false,
|
||||
};
|
||||
return { size: DEFAULT_CONTEXT_WINDOW, authoritative: false };
|
||||
}
|
||||
|
||||
/** Forgets the learned windows, as a logout asks: 1M-context entitlement is
|
||||
|
||||
@@ -587,6 +587,17 @@ export async function answerMcpElicitation(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `toolUseID` is the id of a question that Claude Code asks on its own
|
||||
* (its `confirmWithUser`), such as whether to download a connector's file. It
|
||||
* asks through `canUseTool` as AskUserQuestion under a `confirm_<uuid>` id,
|
||||
* and reads the answer from the callback's result: no tool_use and no
|
||||
* tool_result of the stream carry that id.
|
||||
*/
|
||||
export function isConfirmQuestion(toolUseID: string): boolean {
|
||||
return toolUseID.startsWith("confirm_");
|
||||
}
|
||||
|
||||
/**
|
||||
* Presents the AskUserQuestion tool's questions as a form elicitation of
|
||||
* `sessionId` through `elicit`, and returns the answers as the tool's
|
||||
|
||||
@@ -6,11 +6,10 @@ import {
|
||||
import {
|
||||
forkSession as forkClaudeSession,
|
||||
getSessionMessages,
|
||||
importSessionToStore,
|
||||
type SessionStore,
|
||||
type SessionStoreEntry,
|
||||
} from "@anthropic-ai/claude-agent-sdk";
|
||||
import { createHash } from "node:crypto";
|
||||
import { loadFullSessionHistory } from "./resumed-session.js";
|
||||
import { assistantMessageText } from "./session-failure-extension.js";
|
||||
import { SessionTiming } from "./session-timing.js";
|
||||
|
||||
@@ -69,19 +68,6 @@ function forkPointMessageIdCandidates(messageId: string): string[] {
|
||||
return protocolMessageId === messageId ? [messageId] : [messageId, protocolMessageId];
|
||||
}
|
||||
|
||||
async function loadFullSessionHistory(sessionId: string): Promise<SessionStoreEntry[]> {
|
||||
// getSessionMessages returns only the active parentUuid chain. The import keeps inactive branches that AIR can still reference.
|
||||
const entries: SessionStoreEntry[] = [];
|
||||
const store: SessionStore = {
|
||||
append: async (_key, batch) => {
|
||||
entries.push(...batch);
|
||||
},
|
||||
load: async () => null,
|
||||
};
|
||||
await importSessionToStore(sessionId, store, { includeSubagents: false });
|
||||
return entries;
|
||||
}
|
||||
|
||||
function assistantGroups(
|
||||
entries: SessionStoreEntry[],
|
||||
messageIdForGrouping: ForkSessionDependencies["messageIdForGrouping"],
|
||||
@@ -235,6 +221,7 @@ async function forkTranscript(
|
||||
.find((message) => dependencies.messageIdForGrouping(message) === candidateId)?.uuid,
|
||||
)
|
||||
.find(Boolean);
|
||||
// getSessionMessages returns only the active parentUuid chain. The full history keeps inactive branches that AIR can still reference.
|
||||
const fullHistoryUuid = messageUuid
|
||||
? undefined
|
||||
: resolveFromFullHistory(
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* `--hide-claude-auth`: this integration must never bill a claude.ai
|
||||
* subscription. Under the flag the agent hides the claude.ai login method from
|
||||
* `initialize`, and refuses with `authRequired` every session and every turn
|
||||
* that a subscription would pay for. `v1/acp-agent.ts` decides when the guard
|
||||
* applies (flag on, no provider override); this module decides what it refuses.
|
||||
* subscription, except a Claude Enterprise plan. Under the flag the agent hides
|
||||
* the claude.ai login method from `initialize`, and refuses with `authRequired`
|
||||
* every session and every turn that a Free, Pro, Max or Team plan would pay
|
||||
* for. `v1/acp-agent.ts` and `v2/subscription-guard.ts` decide when the guard
|
||||
* applies (flag on, no provider override); {@link claudeAuthRefusal} decides
|
||||
* what it refuses.
|
||||
*
|
||||
* The guard judges the `AccountInfo` that the SDK caches at `initialize`. That
|
||||
* cache never changes during the life of a query, but the CLI itself picks up
|
||||
@@ -77,6 +79,11 @@ const API_KEY_SOURCES_ABOVE_SUBSCRIPTION: ReadonlySet<string> = new Set([
|
||||
"/login managed key",
|
||||
]);
|
||||
|
||||
/** `none` is the SDK's explicit no-token source. */
|
||||
function hasTokenSource(account: AccountInfo): boolean {
|
||||
return Boolean(account.tokenSource && account.tokenSource !== "none");
|
||||
}
|
||||
|
||||
/**
|
||||
* True when a turn on this account is paid by a claude.ai subscription.
|
||||
*
|
||||
@@ -85,8 +92,8 @@ const API_KEY_SOURCES_ABOVE_SUBSCRIPTION: ReadonlySet<string> = new Set([
|
||||
* proves it, and an unknown value keeps the guard on.
|
||||
*
|
||||
* - `subscriptionType` must be set. Without it the CLI reports no subscription.
|
||||
* - `tokenSource` must be absent. The CLI sets it in place of the subscription
|
||||
* when a bearer or OAuth environment token pays for the turn.
|
||||
* - `tokenSource` must be absent, empty, or `none`. A bearer or OAuth
|
||||
* environment token takes precedence over the subscription.
|
||||
* - `apiProvider` must be absent or `firstParty`. The SDK documents that the
|
||||
* Anthropic OAuth login applies only to `firstParty`; for a third-party
|
||||
* backend such as `bedrock`, `vertex`, `foundry` or `gateway` the other
|
||||
@@ -99,7 +106,7 @@ export function billsClaudeSubscription(account: AccountInfo | undefined): boole
|
||||
if (!account?.subscriptionType) {
|
||||
return false;
|
||||
}
|
||||
if (account.tokenSource) {
|
||||
if (hasTokenSource(account)) {
|
||||
return false;
|
||||
}
|
||||
if (account.apiProvider !== undefined && account.apiProvider !== "firstParty") {
|
||||
@@ -108,6 +115,20 @@ export function billsClaudeSubscription(account: AccountInfo | undefined): boole
|
||||
return !API_KEY_SOURCES_ABOVE_SUBSCRIPTION.has(account.apiKeySource ?? "");
|
||||
}
|
||||
|
||||
/**
|
||||
* True when `subscriptionType` names a Claude Enterprise plan, which the flag
|
||||
* lets pay for turns: Anthropic allows an Enterprise plan in third-party
|
||||
* integrations.
|
||||
*
|
||||
* The SDK's `AccountInfo` carries the CLI's display name, "Claude Enterprise";
|
||||
* older CLIs report the raw plan, "enterprise". Any other value is refused,
|
||||
* including a "Claude <name>" built from a custom `plan_display_name` in the
|
||||
* claude.ai profile: the guard cannot tell which plan that name belongs to.
|
||||
*/
|
||||
export function isClaudeEnterprisePlan(subscriptionType: string | undefined): boolean {
|
||||
return /^(claude\s+)?enterprise$/i.test(subscriptionType?.trim() ?? "");
|
||||
}
|
||||
|
||||
/**
|
||||
* True when the account already holds a credential this integration accepts:
|
||||
* a third-party backend, a bearer or OAuth environment token, or one of the
|
||||
@@ -125,12 +146,33 @@ export function holdsNonSubscriptionCredential(account: AccountInfo | undefined)
|
||||
if (account.apiProvider !== undefined && account.apiProvider !== "firstParty") {
|
||||
return true;
|
||||
}
|
||||
if (account.tokenSource) {
|
||||
if (hasTokenSource(account)) {
|
||||
return true;
|
||||
}
|
||||
return API_KEY_SOURCES_ABOVE_SUBSCRIPTION.has(account.apiKeySource ?? "");
|
||||
}
|
||||
|
||||
/**
|
||||
* The refusal the flag gives a session or turn on `account`, or `undefined`
|
||||
* when the account may run it:
|
||||
*
|
||||
* - a subscription pays, and it is not {@link isClaudeEnterprisePlan}:
|
||||
* {@link claudeSubscriptionNotSupportedError};
|
||||
* - no subscription pays and the account holds no other credential (signed
|
||||
* out): {@link claudeLoginRequiredError}.
|
||||
*
|
||||
* Session creation on v1 and v2 and the per-turn guard all decide through
|
||||
* this function.
|
||||
*/
|
||||
export function claudeAuthRefusal(account: AccountInfo): RequestError | undefined {
|
||||
if (billsClaudeSubscription(account)) {
|
||||
return isClaudeEnterprisePlan(account.subscriptionType)
|
||||
? undefined
|
||||
: claudeSubscriptionNotSupportedError();
|
||||
}
|
||||
return holdsNonSubscriptionCredential(account) ? undefined : claudeLoginRequiredError();
|
||||
}
|
||||
|
||||
export function claudeSubscriptionNotSupportedError(): RequestError {
|
||||
return RequestError.authRequired(
|
||||
{ reason: CLAUDE_SUBSCRIPTION_NOT_SUPPORTED_REASON satisfies AuthRequiredReason },
|
||||
@@ -214,8 +256,8 @@ type GuardOptions = {
|
||||
* real account. This guard does not see the residual case the module header
|
||||
* names either.
|
||||
*
|
||||
* A turn is refused when the account bills a subscription, and also when it
|
||||
* holds nothing this integration accepts, which is the user signing out in
|
||||
* A turn is refused when the account bills a subscription other than Claude
|
||||
* Enterprise, and also when it holds nothing this integration accepts, which is the user signing out in
|
||||
* mid-session. The refusal mirrors the signed-out path exactly (see
|
||||
* `failActiveWithSessionFailure` for `auth_required` in `v1/acp-agent.ts`): every
|
||||
* client gets the `authRequired` JSON-RPC rejection that starts its own auth
|
||||
@@ -257,13 +299,7 @@ async function evaluateGuard(options: GuardOptions): Promise<RequestError | unde
|
||||
error instanceof Error ? error.message : String(error),
|
||||
);
|
||||
}
|
||||
if (billsClaudeSubscription(account)) {
|
||||
return claudeSubscriptionNotSupportedError();
|
||||
}
|
||||
if (!holdsNonSubscriptionCredential(account)) {
|
||||
return claudeLoginRequiredError();
|
||||
}
|
||||
return undefined;
|
||||
return claudeAuthRefusal(account);
|
||||
}
|
||||
|
||||
/** The account the SDK cached at `initialize`. `undefined` when the query
|
||||
|
||||
@@ -5,7 +5,8 @@ export type IdleCompactionHost = {
|
||||
isBusy(): boolean;
|
||||
/** Context size after the last main-thread request, or undefined if unknown. */
|
||||
contextTokens(): number | undefined;
|
||||
/** Current merged Claude Code settings. */
|
||||
/** Current Claude Code settings, the client's `settings` option included
|
||||
* (`SettingsManager.getCompactionSettings`). */
|
||||
settings(): {
|
||||
idleCompaction?: boolean;
|
||||
autoCompactEnabled?: boolean;
|
||||
|
||||
64
src/initial-config-options.ts
Normal file
64
src/initial-config-options.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* The unstable "Session options" RFD, as both cores serve it: `session/options`
|
||||
* answers with what a session would start with, and a setup request's
|
||||
* `configOptions` set the initial values of the session's config options.
|
||||
*/
|
||||
import { RequestError } from "@agentclientprotocol/sdk/unstable";
|
||||
import type { Logger } from "./logger.js";
|
||||
|
||||
/**
|
||||
* What a core advertises as `options` in its session capabilities:
|
||||
* `session/options`, and `configOptions` on its setup requests, `session/fork`
|
||||
* included.
|
||||
*/
|
||||
export const SESSION_OPTIONS_CAPABILITY = {};
|
||||
|
||||
const INVALID_PARAMS = RequestError.invalidParams().code;
|
||||
|
||||
/**
|
||||
* The entries of a setup request's `configOptions`. Omitted and `null` are no
|
||||
* entries. Two entries with the same `configId` fail with `-32602`. Call it
|
||||
* before the session starts, so a refused request starts none.
|
||||
*/
|
||||
export function initialConfigOptions<E extends { configId: string }>(
|
||||
entries: readonly E[] | null | undefined,
|
||||
): readonly E[] {
|
||||
const seen = new Set<string>();
|
||||
for (const { configId } of entries ?? []) {
|
||||
if (seen.has(configId)) {
|
||||
throw RequestError.invalidParams(
|
||||
{ configId },
|
||||
`\`configOptions\` sets ${configId} more than once. Send one entry for each config option.`,
|
||||
);
|
||||
}
|
||||
seen.add(configId);
|
||||
}
|
||||
return entries ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets each entry with `set`, in list order. `set` checks an entry against the
|
||||
* options as the entries before it left them, so a model entry decides which
|
||||
* effort levels a later entry can pick.
|
||||
*
|
||||
* An entry that `set` refuses is skipped, and the entries after it still
|
||||
* apply. The option keeps its value, which the setup response reports:
|
||||
*
|
||||
* - `-32602`: an unknown `configId`, a value of another type than the
|
||||
* option's, or a value that the option does not offer.
|
||||
* - Any other failure, such as a model that Claude Code refuses. It is logged.
|
||||
*/
|
||||
export async function applyInitialConfigOptions<E extends { configId: string }>(
|
||||
entries: readonly E[],
|
||||
set: (entry: E) => Promise<unknown>,
|
||||
logger: Logger,
|
||||
): Promise<void> {
|
||||
for (const entry of entries) {
|
||||
try {
|
||||
await set(entry);
|
||||
} catch (error) {
|
||||
if (error instanceof RequestError && error.code === INVALID_PARAMS) continue;
|
||||
logger.error(`Could not set the initial value of config option ${entry.configId}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,28 @@
|
||||
import { resolveSettings } from "@anthropic-ai/claude-agent-sdk";
|
||||
|
||||
/** The machine policy sources that `machinePolicy.didNotLoad` names. */
|
||||
const POLICY_SOURCES: Record<string, string> = {
|
||||
profile: "the macOS MDM profile",
|
||||
registry: "the Windows registry policy",
|
||||
file: "the managed-settings file",
|
||||
};
|
||||
|
||||
/**
|
||||
* The machine policy sources that may be there and did not load
|
||||
* (`machinePolicy.didNotLoad`, SDK 0.3.323), named for a log line: "the macOS
|
||||
* MDM profile, the managed-settings file". The resolved settings show such a
|
||||
* source as absent, so the adapter applies nothing from it, and Claude Code
|
||||
* reads the policy itself. Undefined when every source loaded, and when the
|
||||
* SDK does not report it.
|
||||
*/
|
||||
export function unloadedPolicySources(
|
||||
resolved: Pick<Awaited<ReturnType<typeof resolveSettings>>, "machinePolicy">,
|
||||
): string | undefined {
|
||||
const unloaded = resolved.machinePolicy?.didNotLoad;
|
||||
if (!unloaded || unloaded.length === 0) return undefined;
|
||||
return unloaded.map((kind) => POLICY_SOURCES[kind] ?? kind).join(", ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the managed-policy tier's env vars to `process.env` before any SDK
|
||||
* call, so the SDK subprocess inherits them. Going through `resolveSettings`
|
||||
@@ -28,6 +51,13 @@ export async function applyManagedPolicyEnv(
|
||||
console.error("Failed to resolve managed policy settings:", error);
|
||||
return;
|
||||
}
|
||||
const unloaded = unloadedPolicySources(policy);
|
||||
if (unloaded) {
|
||||
console.error(
|
||||
`Managed settings did not load from ${unloaded}: its env vars are not applied. ` +
|
||||
"Restart the agent to read it again.",
|
||||
);
|
||||
}
|
||||
for (const [key, value] of Object.entries(policy.effective.env ?? {})) {
|
||||
env[key] = value;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,29 @@
|
||||
import type { McpServer } from "@agentclientprotocol/sdk/unstable";
|
||||
import type { McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
||||
import {
|
||||
McpOverAcpCaller,
|
||||
RequestError,
|
||||
type HasConnectionContext,
|
||||
type McpServer,
|
||||
type McpServerAcp,
|
||||
} from "@agentclientprotocol/sdk/unstable";
|
||||
import { McpOverAcpHttpBridge } from "@agentclientprotocol/sdk/experimental/mcp-http";
|
||||
import type { McpHttpServerConfig, McpServerConfig } from "@anthropic-ai/claude-agent-sdk";
|
||||
|
||||
/**
|
||||
* Makes the SDK config of an MCP server that the client serves over the ACP
|
||||
* connection (`"type": "acp"`): {@link McpOverAcp.sdkConfig} for a connection.
|
||||
*/
|
||||
export type McpOverAcpConfig = (server: McpServerAcp) => Promise<McpHttpServerConfig>;
|
||||
|
||||
/**
|
||||
* The SDK configs of a session's ACP MCP servers, by name. HTTP and SSE
|
||||
* servers keep their URL and headers; a server without `type` is stdio. A
|
||||
* server of any other transport is left out: the session's `initialize`
|
||||
* advertises none.
|
||||
* servers keep their URL and headers; a server without `type` is stdio; an
|
||||
* `acp` server gets the config that `overAcp` makes. A server of any other
|
||||
* transport is left out: the session's `initialize` advertises none.
|
||||
*/
|
||||
export function sdkMcpServers(
|
||||
export async function sdkMcpServers(
|
||||
servers: readonly McpServer[] | null | undefined,
|
||||
): Record<string, McpServerConfig> {
|
||||
overAcp: McpOverAcpConfig,
|
||||
): Promise<Record<string, McpServerConfig>> {
|
||||
const configs: Record<string, McpServerConfig> = {};
|
||||
for (const server of servers ?? []) {
|
||||
if ("type" in server && (server.type === "http" || server.type === "sse")) {
|
||||
@@ -20,6 +34,8 @@ export function sdkMcpServers(
|
||||
? Object.fromEntries(server.headers.map((e) => [e.name, e.value]))
|
||||
: undefined,
|
||||
};
|
||||
} else if ("type" in server && server.type === "acp") {
|
||||
configs[server.name] = await overAcp(server);
|
||||
} else if (!("type" in server)) {
|
||||
configs[server.name] = {
|
||||
type: "stdio",
|
||||
@@ -31,3 +47,59 @@ export function sdkMcpServers(
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serves the MCP servers that a client declares with `"type": "acp"` to Claude
|
||||
* Code (MCP-over-ACP). Claude Code's MCP client connects to a command or a
|
||||
* URL, so each server gets an MCP 2026-07-28 HTTP endpoint on 127.0.0.1 that
|
||||
* sends every MCP request to the client as an `mcp/message` request (the ACP
|
||||
* SDK's `McpOverAcpHttpBridge`). The `acp` servers of a connection share one
|
||||
* listener, which closes with the connection. A request needs the bearer
|
||||
* token of its server, which only that server's config carries.
|
||||
*
|
||||
* The endpoint takes no `initialize`. Claude Code (2.1.325) sends
|
||||
* `server/discover` to an HTTP server first, unless
|
||||
* `MCP_PROTOCOL_NEGOTIATION=legacy` or its
|
||||
* `tengu_mcp_protocol_negotiation_http` flag turns that off. Then it sends
|
||||
* `initialize`, and the server is listed as failed.
|
||||
*/
|
||||
export class McpOverAcp {
|
||||
private readonly caller = new McpOverAcpCaller();
|
||||
private readonly bridge = new McpOverAcpHttpBridge(this.caller);
|
||||
|
||||
/**
|
||||
* Hands an `mcp/message` notification of the client (such as the progress
|
||||
* of a tool call) to the HTTP response of the MCP request that it names. An
|
||||
* agent app registers it for `methods.agent.mcp.message`.
|
||||
*/
|
||||
readonly handleNotification = this.caller.handleNotification;
|
||||
|
||||
/**
|
||||
* The SDK config of `server` for the sessions of the connection behind
|
||||
* `client`. A server gets the same config every time for as long as the
|
||||
* connection lives, so a session that restarts or resumes with the same
|
||||
* servers sees no change. Fails with an internal error (-32603) when the
|
||||
* listener cannot open, or the connection is closed.
|
||||
*/
|
||||
async sdkConfig(
|
||||
client: HasConnectionContext,
|
||||
server: McpServerAcp,
|
||||
): Promise<McpHttpServerConfig> {
|
||||
let http;
|
||||
try {
|
||||
http = await this.bridge.toHttp(client, { ...server, type: "acp" });
|
||||
} catch (error) {
|
||||
throw RequestError.internalError(
|
||||
{ name: server.name },
|
||||
`Could not open the local endpoint that serves MCP server ${server.name} to Claude Code: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}. Start the session without the server, or try again.`,
|
||||
);
|
||||
}
|
||||
return {
|
||||
type: "http",
|
||||
url: http.url,
|
||||
headers: Object.fromEntries(http.headers.map((header) => [header.name, header.value])),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,22 @@ function hasMarkerTag(text: string, tag: string): boolean {
|
||||
return markerTagText(text, tag) !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the content of a user message is only the output of a local
|
||||
* command, such as the `<local-command-stdout>Set model to …</local-command-stdout>`
|
||||
* that Claude Code echoes when the model changes.
|
||||
*/
|
||||
export function isLocalCommandOutput(content: unknown): boolean {
|
||||
if (typeof content !== "string") return false;
|
||||
if (
|
||||
!hasMarkerTag(content, "local-command-stdout") &&
|
||||
!hasMarkerTag(content, "local-command-stderr")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return stripMarkerTags(content).trim() === "";
|
||||
}
|
||||
|
||||
function commandInvocationFromMarkerOnlyText(text: string): string | null {
|
||||
if (hasMarkerTag(text, "local-command-stdout") || hasMarkerTag(text, "local-command-stderr")) {
|
||||
return null;
|
||||
|
||||
@@ -117,10 +117,15 @@ export type TaskEnd = {
|
||||
/** The SDK's reason for an unusual end, such as `worker_restart`. */
|
||||
reason?: string;
|
||||
/**
|
||||
* The adapter knows that the work ended, but not why: the stream ended, or
|
||||
* the conversation was reset, with the task still running.
|
||||
* The adapter knows that the work ended, but not why: the stream ended
|
||||
* with the task still running.
|
||||
*/
|
||||
unexplained?: boolean;
|
||||
/**
|
||||
* The adapter stops following the task, which may still run: the
|
||||
* conversation was reset, and the runtime forgets its children.
|
||||
*/
|
||||
unobservable?: boolean;
|
||||
};
|
||||
|
||||
type TaskStarted = {
|
||||
@@ -225,6 +230,11 @@ export class NativeSubagentRuntime {
|
||||
string,
|
||||
{ initial: AcpSessionNotification; message?: string; delegationId?: string }
|
||||
>();
|
||||
/**
|
||||
* The RFD form: the agent that each TaskStop or SendMessage call names (see
|
||||
* {@link targetAgentId}), until the call's final update.
|
||||
*/
|
||||
private readonly targetByToolCall = new Map<string, string>();
|
||||
private readonly generationByTaskId = new Map<string, number>();
|
||||
private readonly pending = new Map<string, AcpSessionNotification[]>();
|
||||
private pendingCount = 0;
|
||||
@@ -280,7 +290,10 @@ export class NativeSubagentRuntime {
|
||||
const routed = await this.routeUpdate(notification, deliver, forcedSessionId);
|
||||
if (!routed) return routed;
|
||||
this.rememberSendMessage(routed);
|
||||
return this.form === "rfd" ? this.routeRfdSendMessage(routed, forcedSessionId) : routed;
|
||||
if (this.form !== "rfd") return routed;
|
||||
this.rememberTarget(routed);
|
||||
const shown = this.routeRfdSendMessage(routed, forcedSessionId);
|
||||
return shown && this.withTarget(shown);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -828,7 +841,10 @@ export class NativeSubagentRuntime {
|
||||
if (child.parentToolUseId) {
|
||||
for (const pending of this.takePending(child.parentToolUseId)) await deliver(pending);
|
||||
}
|
||||
if (this.form === "rfd") {
|
||||
if (this.form === "rfd" && end?.unobservable) {
|
||||
// The child's `cancel` goes with it: a forgotten child cannot be stopped.
|
||||
await this.reportState(child, { state: "unknown" }, { capabilities: null });
|
||||
} else if (this.form === "rfd") {
|
||||
await this.reportState(child, rfdEndState(state, end));
|
||||
child.missingError = state === "failed" && !end?.error && !end?.unexplained;
|
||||
if (child.parentToolUseId) (child.endedRuns ??= new Set()).add(child.parentToolUseId);
|
||||
@@ -853,14 +869,33 @@ export class NativeSubagentRuntime {
|
||||
|
||||
/**
|
||||
* Ends every child that still runs, because the stream ended or the
|
||||
* conversation was reset. AIR's draft reports `state` for each. In the RFD
|
||||
* form the cause of each child's end is unknown, so it is idle with no stop
|
||||
* reason: a child that a cancel stopped already reported it from the SDK's
|
||||
* events, and a background child that outlived the cancel was not cancelled.
|
||||
* conversation was reset. AIR's draft reports `state` for each.
|
||||
*
|
||||
* The RFD form, at the end of the stream: Claude Code's process ran the
|
||||
* children and is gone, or the caller closes the query next, which
|
||||
* terminates it, so their work ended. Its cause is unknown, so each is idle with no stop reason: a
|
||||
* child that a cancel stopped already reported it from the SDK's events,
|
||||
* and a background child that outlived the cancel was not cancelled.
|
||||
*
|
||||
* The RFD form, at a conversation reset (`mayStillRun`): Claude Code can
|
||||
* keep the old conversation's subagents running, and the caller forgets
|
||||
* them next (`clear`), so no later event of theirs is reported. Their work
|
||||
* did not end as far as the adapter knows, so each is `unknown`, as the
|
||||
* RFD requires when a child can no longer be observed, and loses its
|
||||
* `cancel` capability. A child that is idle keeps its state.
|
||||
*/
|
||||
async finishAll(state: SubagentState, deliver: Publish): Promise<void> {
|
||||
async finishAll(
|
||||
state: SubagentState,
|
||||
deliver: Publish,
|
||||
{ mayStillRun = false }: { mayStillRun?: boolean } = {},
|
||||
): Promise<void> {
|
||||
const errors: unknown[] = [];
|
||||
const end = this.form === "rfd" ? { unexplained: true } : undefined;
|
||||
const end: TaskEnd | undefined =
|
||||
this.form !== "rfd"
|
||||
? undefined
|
||||
: mayStillRun
|
||||
? { unobservable: true }
|
||||
: { unexplained: true };
|
||||
try {
|
||||
for (const taskId of [...this.children.keys()].reverse()) {
|
||||
try {
|
||||
@@ -1235,13 +1270,25 @@ export class NativeSubagentRuntime {
|
||||
await this.publishConfiguration(child);
|
||||
}
|
||||
|
||||
/** The RFD form: publishes the work state of `child` on its parent. */
|
||||
private async reportState(child: NativeSubagent, state: WorkState): Promise<void> {
|
||||
/**
|
||||
* The RFD form: publishes the work state of `child` on its parent, with
|
||||
* `capabilities` when the child's change with it.
|
||||
*/
|
||||
private async reportState(
|
||||
child: NativeSubagent,
|
||||
state: WorkState,
|
||||
capabilities?: { capabilities: null },
|
||||
): Promise<void> {
|
||||
child.workState = state.state;
|
||||
child.missingError = false;
|
||||
await this.publish({
|
||||
sessionId: child.parentSessionId,
|
||||
update: { sessionUpdate: "subagent_update", sessionId: child.sessionId, state },
|
||||
update: {
|
||||
sessionUpdate: "subagent_update",
|
||||
sessionId: child.sessionId,
|
||||
...capabilities,
|
||||
state,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1439,6 +1486,42 @@ export class NativeSubagentRuntime {
|
||||
return unexposedControlFallback(sendMessage.initial, notification, sendMessage.sender);
|
||||
}
|
||||
|
||||
/** The RFD form: remembers the agent that a TaskStop or SendMessage call names. */
|
||||
private rememberTarget({ update }: AcpSessionNotification): void {
|
||||
if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update") return;
|
||||
const claudeMeta = update._meta?.claudeCode as { toolName?: unknown } | undefined;
|
||||
const agentId = targetAgentId(claudeMeta?.toolName, update.rawInput);
|
||||
if (agentId !== undefined) this.targetByToolCall.set(update.toolCallId, agentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* The RFD form: `notification`, an update that the client is shown, with
|
||||
* the RFD's `session` reference when it is of a tool call that operates on
|
||||
* an announced child of another session (see {@link withSessionReference}):
|
||||
*
|
||||
* - a TaskStop or SendMessage call that names the child by its agent id;
|
||||
* - a SendMessage call that resumed the child, and stays shown because a
|
||||
* permission request showed it;
|
||||
* - an Agent/Task call that launched the child, and stays shown for the
|
||||
* same reason.
|
||||
*
|
||||
* The RFD requires the announcement before the reference, so a call whose
|
||||
* child is not announced yet gets none.
|
||||
*/
|
||||
private withTarget(notification: AcpSessionNotification): AcpSessionNotification {
|
||||
const { update } = notification;
|
||||
if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update") {
|
||||
return notification;
|
||||
}
|
||||
const agentId = this.targetByToolCall.get(update.toolCallId);
|
||||
if (isFinalToolCallStatus(update.status)) this.targetByToolCall.delete(update.toolCallId);
|
||||
const child =
|
||||
this.childByParentToolUse.get(update.toolCallId) ??
|
||||
(agentId !== undefined ? this.children.get(agentId) : undefined);
|
||||
if (!child?.announced || child.sessionId === notification.sessionId) return notification;
|
||||
return withSessionReference(notification, child.sessionId);
|
||||
}
|
||||
|
||||
/** Whether `update` is of an Agent/Task call, by its tool name or, in the
|
||||
* RFD form, by the id of a call the client is not shown. */
|
||||
private isControlUpdate(
|
||||
@@ -1504,6 +1587,7 @@ export class NativeSubagentRuntime {
|
||||
this.hiddenLaunches.clear();
|
||||
this.hiddenSendMessages.clear();
|
||||
this.handbacks.clear();
|
||||
this.targetByToolCall.clear();
|
||||
this.generationByTaskId.clear();
|
||||
this.pending.clear();
|
||||
this.pendingCount = 0;
|
||||
@@ -1835,7 +1919,7 @@ async function publishPrompt(
|
||||
* prompt goes from the parent to the child, a SendMessage call, whose message
|
||||
* goes from its sender to a child, or a child's SubagentHandback call, whose
|
||||
* report goes from the child to the parent. Both views use the
|
||||
* call's tool use id, and each names the other with the draft RFD's
|
||||
* call's tool use id, and each names the other with the RFD's
|
||||
* `recipientMessageId` and `senderMessageId`.
|
||||
*/
|
||||
export function linkedSessionMessages(
|
||||
@@ -1863,6 +1947,49 @@ export function linkedSessionMessages(
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The RFD form: the agent that a tool call names as the one it operates on:
|
||||
* the `task_id` of a TaskStop call, or the `to` of a SendMessage call. It is
|
||||
* an agent only if it is the id of one: an agent's id is its child session's
|
||||
* id. Both tools also take a name, which is not resolved here: Claude Code
|
||||
* resolves it, and the adapter cannot tell which agent it picked. `undefined`
|
||||
* for any other call.
|
||||
*/
|
||||
export function targetAgentId(toolName: unknown, rawInput: unknown): string | undefined {
|
||||
if (typeof rawInput !== "object" || rawInput === null) return undefined;
|
||||
const input = rawInput as { task_id?: unknown; to?: unknown };
|
||||
if (toolName === "TaskStop") return nonBlankString(input.task_id);
|
||||
if (toolName === "SendMessage") return nonBlankString(input.to);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The RFD form: `notification`, a tool call's report, with a `session`
|
||||
* reference to `sessionId` after its content: `{ "type": "session",
|
||||
* "sessionId": "..." }`, which links the call to the session it operates on.
|
||||
* A `tool_call_update` replaces the content that the client holds, so the
|
||||
* reference goes on every report that carries content, and a
|
||||
* `tool_call_update` without content is returned as it is.
|
||||
*/
|
||||
export function withSessionReference(
|
||||
notification: AcpSessionNotification,
|
||||
sessionId: string,
|
||||
): AcpSessionNotification {
|
||||
const { update } = notification;
|
||||
if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update") {
|
||||
return notification;
|
||||
}
|
||||
if (update.sessionUpdate === "tool_call_update" && update.content == null) return notification;
|
||||
const content = update.content ?? [];
|
||||
if (content.some((item) => item.type === "session" && item.sessionId === sessionId)) {
|
||||
return notification;
|
||||
}
|
||||
return {
|
||||
...notification,
|
||||
update: { ...update, content: [...content, { type: "session", sessionId }] },
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The tool with which a child hands its report to its parent, when Claude
|
||||
* Code runs in hand-back mode. The Agent/Task result then only says that the
|
||||
@@ -1953,6 +2080,9 @@ function isWorking(child: NativeSubagent): boolean {
|
||||
* A task that a worker restart orphaned, or that was still running when the
|
||||
* stream ended, is idle with no stop reason: its work ended, but the adapter
|
||||
* did not see a cancellation or a failure, which the RFD forbids claiming.
|
||||
*
|
||||
* A child that the adapter can no longer observe and that may still run is
|
||||
* not idle but `unknown` (see `NativeSubagentRuntime.finishAll`).
|
||||
*/
|
||||
export function rfdEndState(state: SubagentState, end: TaskEnd | undefined): WorkState {
|
||||
if (end?.unexplained || end?.reason === "worker_restart") return { state: "idle" };
|
||||
|
||||
13
src/paths.ts
13
src/paths.ts
@@ -5,3 +5,16 @@ import * as path from "node:path";
|
||||
export function claudeConfigDir(): string {
|
||||
return process.env.CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), ".claude");
|
||||
}
|
||||
|
||||
/** `<config>/projects`, normalized like the SDK does. */
|
||||
export function projectsRoot(): string {
|
||||
return path.join(claudeConfigDir(), "projects").normalize("NFC");
|
||||
}
|
||||
|
||||
const SESSION_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
/** Whether `value` is a Claude session id (a UUID). Only such ids name a
|
||||
* transcript, and only such ids are safe to use as a file name. */
|
||||
export function isSessionId(value: unknown): value is string {
|
||||
return typeof value === "string" && SESSION_ID_PATTERN.test(value);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ export interface PermissionOptionContext {
|
||||
/** False when no ACP turn can continue an accepted plan in a fresh
|
||||
* context. Then an ExitPlanMode request offers no clear-context option. */
|
||||
allowContextReset?: boolean;
|
||||
/** Claude Code's `showClearContextOnPlanAccept` setting. An ExitPlanMode
|
||||
* request offers the clear-context option only when it is true. */
|
||||
showClearContextOnPlanAccept?: boolean;
|
||||
}
|
||||
|
||||
export function allowOnce(name = "Yes"): PermissionOption {
|
||||
|
||||
@@ -70,7 +70,11 @@ export function buildExitPlanModePermissionOptions(
|
||||
: (["auto", "bypassPermissions"] as const)
|
||||
).filter((mode) => modes.has(mode));
|
||||
const preferredMode = elevatedModes[0] ?? "acceptEdits";
|
||||
if (context.allowContextReset !== false && plainString(context.input.plan)) {
|
||||
if (
|
||||
context.showClearContextOnPlanAccept === true &&
|
||||
context.allowContextReset !== false &&
|
||||
plainString(context.input.plan)
|
||||
) {
|
||||
const usage =
|
||||
context.contextUsedPercent === undefined ? "" : ` (${context.contextUsedPercent}% used)`;
|
||||
options.push(
|
||||
|
||||
@@ -8,9 +8,26 @@
|
||||
import type {
|
||||
SDKMessage,
|
||||
SDKMessageOrigin,
|
||||
SDKRateLimitInfo,
|
||||
SDKResultMessage,
|
||||
} from "@anthropic-ai/claude-agent-sdk";
|
||||
|
||||
/**
|
||||
* The `data` of the error that fails a turn, for clients to dispatch on
|
||||
* without matching its text: the assistant message's `errorKind`, and for a
|
||||
* `rate_limit` failure the turn's latest `rate_limit_event` info as
|
||||
* `rateLimit`, whose `resetsAt` says when the account can run again. A turn
|
||||
* refused before its first usage sends no `usage_update` to carry that info.
|
||||
* `undefined` without an error kind.
|
||||
*/
|
||||
export function turnErrorData<K extends string>(
|
||||
errorKind: K | undefined,
|
||||
rateLimit: SDKRateLimitInfo | undefined,
|
||||
): { errorKind: K; rateLimit?: SDKRateLimitInfo } | undefined {
|
||||
if (!errorKind) return undefined;
|
||||
return errorKind === "rate_limit" && rateLimit ? { errorKind, rateLimit } : { errorKind };
|
||||
}
|
||||
|
||||
export type ResultEnd =
|
||||
| { stopReason: "refusal" | "max_tokens" | "end_turn" | "max_turn_requests" }
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import { getSessionMessages, type SessionMessage } from "@anthropic-ai/claude-agent-sdk";
|
||||
import {
|
||||
getSessionMessages,
|
||||
importSessionToStore,
|
||||
type SessionMessage,
|
||||
type SessionStore,
|
||||
type SessionStoreEntry,
|
||||
} from "@anthropic-ai/claude-agent-sdk";
|
||||
import { access, open, readdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { isCompactSummaryMessage } from "./context-compaction.js";
|
||||
import { claudeConfigDir } from "./paths.js";
|
||||
import { SessionTiming } from "./session-timing.js";
|
||||
|
||||
@@ -68,6 +75,97 @@ export async function readResumedSession(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the messages of a session from its first prompt on, given the
|
||||
* `getSessionMessages` chain of the session.
|
||||
*
|
||||
* `getSessionMessages` follows `parentUuid` links. Claude Code writes each
|
||||
* `compact_boundary` with `parentUuid: null`, so after a compaction the chain
|
||||
* starts at its summary. The boundary keeps the last message before it in
|
||||
* `logicalParentUuid`. For a chain that starts at a summary, this links each
|
||||
* boundary to that message and reads the transcript through
|
||||
* `getSessionMessages` again. For a session compacted twice, the result has
|
||||
* both summaries and the messages before, between and after them. The result
|
||||
* ends at the last message of `messages`. Any other chain is returned as it
|
||||
* is, and so is the chain when the read fails or when its result does not
|
||||
* reach that last message (e.g. the transcript changed between the reads).
|
||||
*
|
||||
* `dir` is the project directory of the first read: both reads then resolve
|
||||
* the same transcript file. Without it, all project directories are searched.
|
||||
*
|
||||
* The preserved-message metadata of each boundary is dropped. With it,
|
||||
* `getSessionMessages` moves the messages that a compaction kept to after the
|
||||
* summary, and the relinked boundary then leads from them back to the summary:
|
||||
* the chain loops and ends there. Without it, the kept messages stay where
|
||||
* they were said, before the boundary.
|
||||
*/
|
||||
export async function readHistoryAcrossCompactions(
|
||||
sessionId: string,
|
||||
messages: SessionMessage[],
|
||||
logger?: ResumeLogger,
|
||||
dir?: string,
|
||||
): Promise<SessionMessage[]> {
|
||||
if (!isCompactSummaryMessage(messages[0])) return messages;
|
||||
try {
|
||||
const entries = (await loadFullSessionHistory(sessionId, dir)).map(linkCompactBoundary);
|
||||
const history = await getSessionMessages(sessionId, {
|
||||
dir,
|
||||
sessionStore: { append: async () => {}, load: async () => entries },
|
||||
});
|
||||
const leaf = messages.at(-1)?.uuid;
|
||||
const end = history.findIndex((message) => message.uuid === leaf);
|
||||
if (end < 0) {
|
||||
logger?.error(
|
||||
`The history before the last compaction of session ${sessionId} does not reach message ${leaf}: replaying the messages after it`,
|
||||
);
|
||||
return messages;
|
||||
}
|
||||
return history.slice(0, end + 1);
|
||||
} catch (error) {
|
||||
logger?.error(
|
||||
`Failed to read the history before the last compaction of session ${sessionId}:`,
|
||||
error,
|
||||
);
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
|
||||
/** Every record of a session's transcript, including the inactive branches
|
||||
* and the history before a compaction that `getSessionMessages` leaves out.
|
||||
* Without `dir`, all project directories are searched. */
|
||||
export async function loadFullSessionHistory(
|
||||
sessionId: string,
|
||||
dir?: string,
|
||||
): Promise<SessionStoreEntry[]> {
|
||||
const entries: SessionStoreEntry[] = [];
|
||||
const store: SessionStore = {
|
||||
append: async (_key, batch) => {
|
||||
entries.push(...batch);
|
||||
},
|
||||
load: async () => null,
|
||||
};
|
||||
await importSessionToStore(sessionId, store, { dir, includeSubagents: false });
|
||||
return entries;
|
||||
}
|
||||
|
||||
/** The record unchanged, or a compaction boundary linked to the message before it. */
|
||||
function linkCompactBoundary(entry: SessionStoreEntry): SessionStoreEntry {
|
||||
if (
|
||||
entry.type !== "system" ||
|
||||
entry.subtype !== "compact_boundary" ||
|
||||
typeof entry.logicalParentUuid !== "string"
|
||||
) {
|
||||
return entry;
|
||||
}
|
||||
const compactMetadata: Record<string, unknown> =
|
||||
typeof entry.compactMetadata === "object" && entry.compactMetadata !== null
|
||||
? { ...entry.compactMetadata }
|
||||
: {};
|
||||
delete compactMetadata.preservedSegment;
|
||||
delete compactMetadata.preservedMessages;
|
||||
return { ...entry, parentUuid: entry.logicalParentUuid, compactMetadata };
|
||||
}
|
||||
|
||||
/** What a resume restores from the end of the local transcript. */
|
||||
export type ResumedTail = {
|
||||
model?: string;
|
||||
|
||||
@@ -192,12 +192,20 @@ export function buildConfigOptions(
|
||||
* a fallback for resolutions that don't map back onto a selectable option
|
||||
* (e.g. a fuzzy hit on an out-of-picker verbatim entry). `value` is then the
|
||||
* canonical option value, the model id rather than the alias.
|
||||
*
|
||||
* With `passUnlisted`, a model value that resolves to none of the entries is
|
||||
* returned as it is, marked `unlisted`, for Claude Code to decide: the CLI's
|
||||
* picker leaves out models it runs, such as `claude-fable-5-2` before a CLI
|
||||
* lists it, or `claude-opus-4-6` once a newer Opus replaces it.
|
||||
* {@link setSelectedModel} refuses it with invalid params when Claude Code
|
||||
* does. Without it, such a value is refused here.
|
||||
*/
|
||||
export function configOptionValue(
|
||||
option: SessionConfigOption,
|
||||
params: SetSessionConfigOptionRequest,
|
||||
modelInfos: ModelInfo[],
|
||||
): { enabled: boolean } | { value: string } {
|
||||
passUnlisted = false,
|
||||
): { enabled: boolean } | { value: string; unlisted?: true } {
|
||||
const expectedType = option.type === "boolean" ? "boolean" : "string";
|
||||
if (typeof params.value !== expectedType) {
|
||||
throw RequestError.invalidParams(
|
||||
@@ -233,6 +241,9 @@ export function configOptionValue(
|
||||
}));
|
||||
validValue = toOptionValue(resolveModelPreference(optionInfos, requested));
|
||||
}
|
||||
if (!validValue && passUnlisted && requested.trim() !== "") {
|
||||
return { value: requested.trim(), unlisted: true };
|
||||
}
|
||||
}
|
||||
if (!validValue) {
|
||||
throw RequestError.invalidParams(
|
||||
@@ -242,3 +253,59 @@ export function configOptionValue(
|
||||
}
|
||||
return { value: validValue.value };
|
||||
}
|
||||
|
||||
/**
|
||||
* The codes with which Claude Code's `setModel` refuses a model id that the
|
||||
* session cannot use: an id it does not know (`not_found`,
|
||||
* `catalog_unknown`), one that settings restrict (`restricted_by_org`: an
|
||||
* `availableModels` allowlist, a managed `deniedModels` entry), one the
|
||||
* account or this CLI does not offer, and a `[1m]` form that is turned off or
|
||||
* that the model lacks.
|
||||
*
|
||||
* Claude Code sends the code as `error_code` of its answer and the SDK
|
||||
* (0.3.325) copies it to `errorCode` of the error that `setModel()` rejects
|
||||
* with. The SDK's types do not declare it.
|
||||
*/
|
||||
const UNUSABLE_MODEL_ERROR_CODES: ReadonlySet<string> = new Set([
|
||||
"not_found",
|
||||
"catalog_unknown",
|
||||
"restricted_by_org",
|
||||
"unavailable_for_account",
|
||||
"not_offered",
|
||||
"alias_1m_disabled",
|
||||
"alias_1m_unsupported",
|
||||
]);
|
||||
|
||||
/** Whether `setModel()` rejected with `error` because the session cannot use the model id. */
|
||||
function refusesModelId(error: unknown): error is Error {
|
||||
if (!(error instanceof Error)) return false;
|
||||
const code = (error as { errorCode?: unknown }).errorCode;
|
||||
return typeof code === "string" && UNUSABLE_MODEL_ERROR_CODES.has(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches `query` to the model that {@link configOptionValue} selected.
|
||||
*
|
||||
* When Claude Code refuses an `unlisted` id as one the session cannot use
|
||||
* (see {@link UNUSABLE_MODEL_ERROR_CODES}), that is invalid params with Claude
|
||||
* Code's reason ("Model 'gpt-4' not found"), as for a value the option lacks.
|
||||
* Every other failure is thrown as it is and reaches the client as an
|
||||
* internal error: a failed switch to a listed value, and a failure that does
|
||||
* not judge the id, such as `auth_failed`, `rate_limit`, `check_unreachable`
|
||||
* (the API did not answer), `blocked_by_hook`, a closed query, or a refusal
|
||||
* without a code.
|
||||
*/
|
||||
export async function setSelectedModel(
|
||||
query: Pick<Query, "setModel">,
|
||||
selected: { value: string; unlisted?: true },
|
||||
): Promise<void> {
|
||||
try {
|
||||
await query.setModel(selected.value);
|
||||
} catch (error) {
|
||||
if (!selected.unlisted || !refusesModelId(error)) throw error;
|
||||
throw RequestError.invalidParams(
|
||||
undefined,
|
||||
`Invalid value for config option ${MODEL_CONFIG_ID}: ${selected.value}. ${error.message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,9 @@ export function buildEffortConfigOption(
|
||||
useRecommendedValue: boolean,
|
||||
): SessionConfigOption | undefined {
|
||||
const currentModelInfo = modelInfos.find((model) => model.value === currentModelId);
|
||||
// In Claude Code's order, which lists the levels from lowest to highest
|
||||
// ("low" to "max"), as ACP v2 asks of a `thought_level` select. Nothing
|
||||
// here sorts them.
|
||||
const supportedLevels = currentModelInfo?.supportsEffort
|
||||
? (currentModelInfo.supportedEffortLevels ?? [])
|
||||
: [];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { ClientCapabilities, SessionNotification } from "@agentclientprotocol/sdk/unstable";
|
||||
import {
|
||||
getSessionMessages,
|
||||
type SDKAPIRetryMessage,
|
||||
type SDKAssistantMessageError,
|
||||
USAGE_LIMIT_ERROR_PREFIXES,
|
||||
} from "@anthropic-ai/claude-agent-sdk";
|
||||
@@ -446,6 +447,84 @@ export class SessionFailureController {
|
||||
}
|
||||
}
|
||||
|
||||
/** Formats a wait in whole seconds, at least 1s: `8000` → `"8s"`. */
|
||||
function retrySeconds(ms: number): string {
|
||||
return `${Math.max(1, Math.round(ms / 1000))}s`;
|
||||
}
|
||||
|
||||
/** The wait before the next attempt: `0` → `"now"`, `8000` → `"in 8s"`, and
|
||||
* from 120 s whole minutes rounded up: `1_800_000` → `"in 30m"`. The CLI sends
|
||||
* `0` for a `no_response` retry and minutes for a background rate-limit wait. */
|
||||
function nextAttemptDelay(ms: number): string {
|
||||
const seconds = Math.round(ms / 1000);
|
||||
if (seconds <= 0) return "now";
|
||||
if (seconds < 120) return `in ${seconds}s`;
|
||||
return `in ${Math.ceil(ms / 60_000)}m`;
|
||||
}
|
||||
|
||||
/** Plain-English names of the SDK error kinds. `unknown` has none: it adds
|
||||
* nothing to the HTTP status or the connection error. */
|
||||
const RETRY_ERROR_KIND_LABELS: Record<Exclude<SDKAssistantMessageError, "unknown">, string> = {
|
||||
authentication_failed: "authentication failed",
|
||||
oauth_org_not_allowed: "organization not allowed",
|
||||
account_on_hold: "account on hold",
|
||||
verification_required: "verification required",
|
||||
billing_error: "billing error",
|
||||
rate_limit: "rate limited",
|
||||
overloaded: "overloaded",
|
||||
invalid_request: "invalid request",
|
||||
model_not_found: "model not found",
|
||||
server_error: "server error",
|
||||
max_output_tokens: "output token limit",
|
||||
cloud_credential_error: "cloud credential error",
|
||||
};
|
||||
|
||||
/** The `api_retry` message fields the warning reads. `error` is optional
|
||||
* because an older CLI can omit it; the warning then treats it as `unknown`. */
|
||||
type ApiRetryWarningInput = Pick<
|
||||
SDKAPIRetryMessage,
|
||||
"attempt" | "max_retries" | "error_status" | "retry_delay_ms" | "no_response"
|
||||
> & { error?: SDKAssistantMessageError };
|
||||
|
||||
/** The cause of a retry. A null `error_status` with a kind is not always a
|
||||
* lost connection: the CLI maps an SSE `overloaded_error` event after HTTP 200
|
||||
* to `overloaded` with no status. */
|
||||
function apiRetryCause(message: ApiRetryWarningInput): string {
|
||||
const kind = message.error ?? "unknown";
|
||||
const label =
|
||||
kind === "unknown"
|
||||
? undefined
|
||||
: (RETRY_ERROR_KIND_LABELS[kind] ?? String(kind).replaceAll("_", " "));
|
||||
if (message.error_status !== null) {
|
||||
return `HTTP ${message.error_status}${label ? ` (${label})` : ""}.`;
|
||||
}
|
||||
return label ? `No HTTP status (${label}).` : "Connection error: no HTTP response.";
|
||||
}
|
||||
|
||||
/** The title and the `details` of an `api_retry` warning. The title says the
|
||||
* attempt and, for a `no_response` retry, how long the CLI waited and will
|
||||
* wait. The details say the cause and the wait before the next attempt, e.g.
|
||||
* "HTTP 529 (overloaded). Next attempt in 8s." The details do not repeat the
|
||||
* `no_response` wait. */
|
||||
export function apiRetryWarning(message: ApiRetryWarningInput): {
|
||||
title: string;
|
||||
details: string;
|
||||
} {
|
||||
// `no_response` (SDK 0.3.261+): the API sent no response headers
|
||||
// within the first-byte window, so this retry waits longer for
|
||||
// them. Say so — "attempt 1 of 1" alone reads like a final
|
||||
// failure, and the wait is what the user is about to sit through.
|
||||
const noResponse = message.no_response
|
||||
? ` No response after ${retrySeconds(message.no_response.waited_ms)}; waiting up to ${retrySeconds(message.no_response.retry_wait_ms)}.`
|
||||
: "";
|
||||
const title =
|
||||
message.error_status === null
|
||||
? `Reconnecting to Claude, attempt ${message.attempt} of ${message.max_retries}.${noResponse}`
|
||||
: `Retrying Claude, attempt ${message.attempt} of ${message.max_retries}.${noResponse}`;
|
||||
const delay = nextAttemptDelay(message.retry_delay_ms);
|
||||
return { title, details: `${apiRetryCause(message)} Next attempt ${delay}.` };
|
||||
}
|
||||
|
||||
export function providerFailureCategory(
|
||||
errorKind?: SDKAssistantMessageError,
|
||||
isUsageLimit = false,
|
||||
|
||||
@@ -28,16 +28,9 @@ export function fastModeStateEnabled(state: FastModeState): boolean {
|
||||
return state !== "off";
|
||||
}
|
||||
|
||||
/** User-facing explanations for the SDK's `fast_mode_disabled_reason` values
|
||||
* that a user can act on (or at least wants to know about). Deliberately
|
||||
* partial — the omitted reasons are not worth surfacing:
|
||||
* - `sdk_opt_in_required`: every SDK session starts here (the toggle IS the
|
||||
* opt-in), so it describes the default, not a problem.
|
||||
* - `preference`: the user turned Fast mode off themselves.
|
||||
* - `pending`: eligibility is still resolving; the next report supersedes it.
|
||||
* - `unknown`: nothing meaningful to say.
|
||||
* Unknown future reasons fall through the same way (open set — the SDK's docs
|
||||
* say to ignore values you don't handle). */
|
||||
/** User-facing explanations for the SDK's `fast_mode_disabled_reason` values.
|
||||
* Every reason is explained except the two in {@link FAST_MODE_UNEXPLAINED_REASONS};
|
||||
* a code missing here gets the generic text from {@link explainFastModeDisabledReason}. */
|
||||
const FAST_MODE_UNAVAILABLE_EXPLANATIONS: Partial<Record<FastModeDisabledReason, string>> = {
|
||||
free: "not available on the free plan",
|
||||
extra_usage_disabled: "requires extra usage to be enabled for this account",
|
||||
@@ -45,17 +38,38 @@ const FAST_MODE_UNAVAILABLE_EXPLANATIONS: Partial<Record<FastModeDisabledReason,
|
||||
not_first_party: "not available on this API provider",
|
||||
disabled_by_env: "disabled by environment configuration",
|
||||
network_error: "eligibility could not be verified (network error)",
|
||||
preference: "not enabled for your organization or API gateway",
|
||||
unknown: "currently unavailable",
|
||||
};
|
||||
|
||||
/** Reasons that are never explained:
|
||||
* - `sdk_opt_in_required`: every SDK session starts here (the toggle IS the
|
||||
* opt-in), so it describes the default, not a problem.
|
||||
* - `pending`: eligibility is still resolving; the next report supersedes it. */
|
||||
const FAST_MODE_UNEXPLAINED_REASONS: ReadonlySet<FastModeDisabledReason> = new Set([
|
||||
"sdk_opt_in_required",
|
||||
"pending",
|
||||
]);
|
||||
|
||||
/** The user-facing explanation of a `fast_mode_disabled_reason`: `undefined`
|
||||
* for no reason, `sdk_opt_in_required` or `pending`; the table text when there
|
||||
* is one; else a generic text naming the code (a reason a newer SDK added). */
|
||||
export function explainFastModeDisabledReason(
|
||||
reason: FastModeDisabledReason | undefined,
|
||||
): string | undefined {
|
||||
if (reason === undefined || FAST_MODE_UNEXPLAINED_REASONS.has(reason)) return undefined;
|
||||
return FAST_MODE_UNAVAILABLE_EXPLANATIONS[reason] ?? `not available (${reason})`;
|
||||
}
|
||||
|
||||
/** Normalize an SDK-reported `fast_mode_disabled_reason` to the one we retain:
|
||||
* a reason we have an explanation for, else `undefined`. Keeping only
|
||||
* explainable reasons means state comparisons (see `fastModeStateChange`) track
|
||||
* exactly what the user can see, so routine reports like
|
||||
* `sdk_opt_in_required` never churn the config option. */
|
||||
* a reason {@link explainFastModeDisabledReason} explains (including codes a
|
||||
* newer SDK adds), else `undefined`. State comparisons (see
|
||||
* `fastModeStateChange`) then track exactly what the user can see, so
|
||||
* `sdk_opt_in_required` and `pending` never churn the config option. */
|
||||
export function normalizeFastModeDisabledReason(
|
||||
reason: FastModeDisabledReason | undefined,
|
||||
): FastModeDisabledReason | undefined {
|
||||
return reason && FAST_MODE_UNAVAILABLE_EXPLANATIONS[reason] ? reason : undefined;
|
||||
return explainFastModeDisabledReason(reason) !== undefined ? reason : undefined;
|
||||
}
|
||||
|
||||
/** Build the Fast mode config option. When the Client supports boolean config
|
||||
@@ -73,9 +87,7 @@ export function createFastModeConfigOption(
|
||||
useBooleanOption: boolean,
|
||||
disabledReason?: FastModeDisabledReason,
|
||||
): SessionConfigOption {
|
||||
const explanation = enabled
|
||||
? undefined
|
||||
: disabledReason && FAST_MODE_UNAVAILABLE_EXPLANATIONS[disabledReason];
|
||||
const explanation = enabled ? undefined : explainFastModeDisabledReason(disabledReason);
|
||||
const base = {
|
||||
id: FAST_MODE_CONFIG_ID,
|
||||
name: "Fast mode",
|
||||
@@ -118,6 +130,27 @@ export function resolveFastModeEnabled(params: SetSessionConfigOptionRequest): b
|
||||
);
|
||||
}
|
||||
|
||||
/** Set the Fast mode flag on Claude Code, through `applyFlagSettings`.
|
||||
*
|
||||
* Turning it on sends `fastMode: false` first, a workaround for Claude Code
|
||||
* (CLI 2.1.325): it acts on `fastMode: true` only when its flag does not hold
|
||||
* `true` already, and ignores a repeat. Its flag stays `true` while it stops
|
||||
* serving Fast mode at a model switch (Fable 5.2 and Mythos 5.2 take only a
|
||||
* Fast mode that was turned on while they were selected) and reports
|
||||
* `fast_mode_state: "off"`. Without the reset, turning the toggle back on
|
||||
* changes nothing there, and the next `system`/init turns it off again.
|
||||
*
|
||||
* A refusal of the reset changes nothing. If Claude Code takes the reset and
|
||||
* refuses `true`, it is left off; the caller's option keeps its value, and the
|
||||
* next `system`/init turns off an option that reads on. */
|
||||
export async function applyFastModeFlag(
|
||||
applyFlagSettings: (settings: { fastMode: boolean }) => Promise<void>,
|
||||
enabled: boolean,
|
||||
): Promise<void> {
|
||||
if (enabled) await applyFlagSettings({ fastMode: false });
|
||||
await applyFlagSettings({ fastMode: enabled });
|
||||
}
|
||||
|
||||
/** Per-model Fast mode state threaded into `buildConfigOptions`. The
|
||||
* option is only surfaced when the current model `supported`s fast mode. */
|
||||
export type FastModeOptionState = {
|
||||
@@ -141,15 +174,19 @@ export type FastModeOptionState = {
|
||||
* off), or the same state with the same explainable reason.
|
||||
*
|
||||
* `reason` is the SDK's `fast_mode_disabled_reason`, reported alongside the
|
||||
* state. Only explainable reasons are retained (see
|
||||
* {@link normalizeFastModeDisabledReason}), so a routine
|
||||
* `sdk_opt_in_required` report on every turn's result can't churn the
|
||||
* option, while a real blocker updates the description even when the
|
||||
* state. Every reason except `sdk_opt_in_required` and `pending` is retained
|
||||
* (see {@link normalizeFastModeDisabledReason}; unknown future codes get the
|
||||
* generic text), so `sdk_opt_in_required` on every turn's result can't churn
|
||||
* the option, while a real blocker updates the description even when the
|
||||
* toggle's own value is unchanged.
|
||||
*
|
||||
* `notice` is set when the user had Fast mode on and the SDK turned it off
|
||||
* for an explainable reason: the description carries the same explanation,
|
||||
* but a toggle silently snapping back is worth saying out loud once. */
|
||||
* with a retained reason: the description carries the same explanation, but a
|
||||
* toggle silently snapping back is worth saying out loud once. Off with no
|
||||
* reason, `sdk_opt_in_required` or `pending` stays quiet: a report can carry
|
||||
* the flag as it was before a request of ours (see
|
||||
* {@link fastModeResultIsNews}), so a notice there would falsely say "turned
|
||||
* off". */
|
||||
export function fastModeStateChange(
|
||||
current: { enabled: boolean; disabledReason?: FastModeDisabledReason },
|
||||
state: FastModeState | undefined,
|
||||
@@ -163,8 +200,7 @@ export function fastModeStateChange(
|
||||
// so it can't decorate the option the next time fast mode goes off.
|
||||
const disabledReason = enabled ? undefined : normalizeFastModeDisabledReason(reason);
|
||||
if (enabled === current.enabled && disabledReason === current.disabledReason) return undefined;
|
||||
const explanation =
|
||||
disabledReason !== undefined ? FAST_MODE_UNAVAILABLE_EXPLANATIONS[disabledReason] : undefined;
|
||||
const explanation = explainFastModeDisabledReason(disabledReason);
|
||||
if (!current.enabled || enabled || explanation === undefined) {
|
||||
return { enabled, disabledReason };
|
||||
}
|
||||
@@ -182,6 +218,41 @@ export function fastModeStateChange(
|
||||
};
|
||||
}
|
||||
|
||||
/** A Fast mode report of Claude Code: the `fast_mode_state` and
|
||||
* `fast_mode_disabled_reason` of a `system`/init or of a result. */
|
||||
export type FastModeReport = {
|
||||
state: FastModeState | undefined;
|
||||
reason: FastModeDisabledReason | undefined;
|
||||
};
|
||||
|
||||
/** Whether a result's Fast mode report says something that `init`, the report
|
||||
* of its turn's `system`/init, did not.
|
||||
*
|
||||
* Claude Code (CLI 2.1.325) reads the `fastMode` flag once when a turn starts
|
||||
* and builds that turn's init and result from the one reading. A result that
|
||||
* repeats its init therefore predates a `session/set_config_option` that
|
||||
* arrived in between: mirroring it would turn the toggle back, until the next
|
||||
* turn's init. What a result adds is what Claude Code evaluates when it sends
|
||||
* it: a refusal by the account or the model, or the end of one.
|
||||
*
|
||||
* Reasons compare as retained ({@link normalizeFastModeDisabledReason}):
|
||||
* turning Fast mode on mid-turn drops `sdk_opt_in_required` from the result,
|
||||
* which is no news. True without an init, as for a result whose turn sent none.
|
||||
*
|
||||
* Not covered: a request that Claude Code applies after it read the flag and
|
||||
* before it sent the init. That init reports the earlier value too, and the
|
||||
* next turn's init corrects the toggle. */
|
||||
export function fastModeResultIsNews(
|
||||
init: FastModeReport | undefined,
|
||||
result: FastModeReport,
|
||||
): boolean {
|
||||
if (init === undefined) return true;
|
||||
return (
|
||||
result.state !== init.state ||
|
||||
normalizeFastModeDisabledReason(result.reason) !== normalizeFastModeDisabledReason(init.reason)
|
||||
);
|
||||
}
|
||||
|
||||
/** The notice of Fast mode that the SDK turned off, and its transcript line
|
||||
* for a client without `notice` updates. */
|
||||
export type FastModeOffNotice = {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
import { createReadStream } from "node:fs";
|
||||
import { createInterface } from "node:readline";
|
||||
import { TASK_NOTIFICATION_TAG, taskNotificationsOf } from "../../task-notifications.js";
|
||||
import { TASK_NOTIFICATION_TAG, taskNotificationsOf } from "../task-notifications.js";
|
||||
|
||||
export type BackgroundTasks = {
|
||||
/** The ids of the tasks that started and did not end, in start order. */
|
||||
@@ -49,7 +49,8 @@ import {
|
||||
type LiveSessionRegistry,
|
||||
type LiveSnapshot,
|
||||
} from "./live-registry.js";
|
||||
import { isExactProjectDir, isSessionId, projectDirMatches, projectsRoot } from "./project-dirs.js";
|
||||
import { isSessionId, projectsRoot } from "../paths.js";
|
||||
import { isExactProjectDir, projectDirMatches } from "./project-dirs.js";
|
||||
import { type IndexRow, type SessionIndex, type TranscriptCandidate } from "./session-index.js";
|
||||
import { changeSignature, sessionInfoOf } from "./session-info.js";
|
||||
|
||||
@@ -23,7 +23,7 @@ import { execFile } from "node:child_process";
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { claudeConfigDir } from "../../paths.js";
|
||||
import { claudeConfigDir } from "../paths.js";
|
||||
import { errorCode } from "./project-dirs.js";
|
||||
|
||||
const SNAPSHOT_TTL_MS = 5_000;
|
||||
@@ -14,24 +14,10 @@
|
||||
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as path from "node:path";
|
||||
import { claudeConfigDir } from "../../paths.js";
|
||||
|
||||
/** The SDK cuts an encoded path at this length and appends a hash. */
|
||||
const MAX_SANITIZED_LENGTH = 200;
|
||||
|
||||
const SESSION_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
|
||||
/** Whether `value` is a Claude session id (a UUID). Only such ids name a
|
||||
* transcript, and only such ids are safe to use as a file name. */
|
||||
export function isSessionId(value: unknown): value is string {
|
||||
return typeof value === "string" && SESSION_ID_PATTERN.test(value);
|
||||
}
|
||||
|
||||
/** `<config>/projects`, normalized like the SDK does. */
|
||||
export function projectsRoot(): string {
|
||||
return path.join(claudeConfigDir(), "projects").normalize("NFC");
|
||||
}
|
||||
|
||||
function sanitize(value: string): string {
|
||||
return value.replace(/[^a-zA-Z0-9]/g, "-");
|
||||
}
|
||||
115
src/session-index/rename.ts
Normal file
115
src/session-index/rename.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* Client renames of a session: `session/set_title` (v1 and v2) and AIR's
|
||||
* `_session/rename` (v1). Both cores call {@link renameSession}, which stores
|
||||
* the title in every transcript of the session (see
|
||||
* {@link SessionIndexService.retitle}) and, for a session loaded on the
|
||||
* connection, makes it the client title that no generated title replaces.
|
||||
*/
|
||||
|
||||
import { RequestError } from "@agentclientprotocol/sdk/unstable";
|
||||
import type { Query } from "@anthropic-ai/claude-agent-sdk";
|
||||
import type { SessionTitles, TitledSession } from "../session-titles.js";
|
||||
import { storedTitle } from "./archive-title.js";
|
||||
import {
|
||||
renameTo,
|
||||
type RenameSessionRequest,
|
||||
type RetitleOptions,
|
||||
type SessionIndexService,
|
||||
type TitleChange,
|
||||
} from "./service.js";
|
||||
|
||||
/** A session loaded on the connection, and its title state. */
|
||||
export interface RetitledSession {
|
||||
readonly session: TitledSession;
|
||||
readonly titles: Pick<
|
||||
SessionTitles,
|
||||
"setExplicitTitle" | "storedTitle" | "rememberStoredTitle" | "shownTitle"
|
||||
>;
|
||||
}
|
||||
|
||||
type RenamingQuery = Query & {
|
||||
renameSession?: (title: string, sessionId?: string) => Promise<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Names a session; no generated title replaces it. An archived session stays
|
||||
* archived. `loaded` is the session loaded on this connection, if any;
|
||||
* `clientTitle` turns a stored title into the one the client shows (an AIR
|
||||
* client's drops the archive prefix). Returns that title, which the loaded
|
||||
* session also publishes as a `session_info_update`.
|
||||
*
|
||||
* A session that is not loaded and has no transcript is unknown (`-32002`).
|
||||
*/
|
||||
export async function renameSession(
|
||||
index: SessionIndexService,
|
||||
request: RenameSessionRequest,
|
||||
loaded: RetitledSession | undefined,
|
||||
clientTitle: (stored: string) => string = (stored) => stored,
|
||||
): Promise<string> {
|
||||
const { sessionId } = request;
|
||||
// As the CLI keeps it, and never with the archive prefix: a rename does
|
||||
// not change the archive state.
|
||||
const title = storedTitle(request.title, false, sessionId);
|
||||
// The title as stored: an archived one is cut with its prefix.
|
||||
const shown = (stored: string | undefined) => clientTitle(stored ?? title);
|
||||
const stored = await retitleSession(index, sessionId, renameTo(title), shown, loaded, {
|
||||
mayBeUnwritten: true,
|
||||
sidecar: "always",
|
||||
});
|
||||
return shown(stored);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retitles a session (see {@link SessionIndexService.retitle}) and returns
|
||||
* the title stored. A session that runs here is titled through its CLI
|
||||
* (`rename_session`). A loaded session's title state takes the change as a
|
||||
* client title, so no generated title replaces it; `publish` is the title it
|
||||
* then publishes.
|
||||
*/
|
||||
export async function retitleSession(
|
||||
index: SessionIndexService,
|
||||
sessionId: string,
|
||||
change: TitleChange,
|
||||
publish: Parameters<SessionTitles["setExplicitTitle"]>[0],
|
||||
loaded: RetitledSession | undefined,
|
||||
options: Pick<RetitleOptions, "mayBeUnwritten" | "sidecar">,
|
||||
): Promise<string | undefined> {
|
||||
let stored: string | undefined;
|
||||
// Decided once a title generation in flight has ended: the query may
|
||||
// have closed meanwhile.
|
||||
const persist = async () => {
|
||||
const session = loaded?.session;
|
||||
const query = session?.query as RenamingQuery | undefined;
|
||||
// A closed session's CLI is gone here: only a running query titles it.
|
||||
const running = session !== undefined && !session.queryClosed;
|
||||
if (running && typeof query?.renameSession !== "function") {
|
||||
// Its CLI holds the title and would write it back over ours.
|
||||
throw RequestError.invalidRequest(
|
||||
{ sessionId },
|
||||
"The Claude Code CLI of this session cannot change its title while it runs.",
|
||||
);
|
||||
}
|
||||
const live = running
|
||||
? {
|
||||
cwd: session.cwd,
|
||||
rename: (title: string) => query!.renameSession!(title, sessionId),
|
||||
stored: () => loaded!.titles.storedTitle,
|
||||
remember: (title: string) => loaded!.titles.rememberStoredTitle(title),
|
||||
shown: loaded!.titles.shownTitle,
|
||||
}
|
||||
: undefined;
|
||||
stored = await index.retitle(sessionId, change, {
|
||||
...options,
|
||||
// Without its CLI, a session needs its transcript.
|
||||
mayBeUnwritten: live !== undefined && options.mayBeUnwritten,
|
||||
live,
|
||||
});
|
||||
return stored;
|
||||
};
|
||||
if (loaded) {
|
||||
await loaded.titles.setExplicitTitle(publish, persist);
|
||||
} else {
|
||||
await persist();
|
||||
}
|
||||
return stored;
|
||||
}
|
||||
@@ -18,8 +18,8 @@ import {
|
||||
type SessionInfo,
|
||||
} from "@agentclientprotocol/sdk/unstable";
|
||||
import { deleteSession as sdkDeleteSession } from "@anthropic-ai/claude-agent-sdk";
|
||||
import { airExtensionMeta } from "../../air-extension.js";
|
||||
import { sanitizeTitle } from "../../session-titles.js";
|
||||
import { airExtensionMeta } from "../air-extension.js";
|
||||
import { sanitizeTitle } from "../session-titles.js";
|
||||
import type { OwnSessionState } from "./activity.js";
|
||||
import {
|
||||
effectiveTitle,
|
||||
@@ -36,11 +36,11 @@ import {
|
||||
type ListSubscriptionDeps,
|
||||
} from "./list-subscriptions.js";
|
||||
import { LiveSessionRegistry } from "./live-registry.js";
|
||||
import { isSessionId } from "../paths.js";
|
||||
import {
|
||||
canonicalPath,
|
||||
exists,
|
||||
isExactProjectDir,
|
||||
isSessionId,
|
||||
projectDirMatches,
|
||||
sameProjectPath,
|
||||
} from "./project-dirs.js";
|
||||
@@ -466,6 +466,18 @@ export type SessionIndexDeps = {
|
||||
logError: (message: string, error: unknown) => void;
|
||||
};
|
||||
|
||||
/** The transcript reads and writes of the session index, without its list
|
||||
* or watcher: what a client without `sessionIndex` uses for
|
||||
* `session/set_title`, AIR's archive on delete, and delete's ordering
|
||||
* after them (see {@link SessionIndexService.exclusive}). */
|
||||
export function transcriptWriter(logger: {
|
||||
error: (message: string, error: unknown) => void;
|
||||
}): SessionIndexService {
|
||||
return new SessionIndexService({
|
||||
logError: (message, error) => logger.error(`[session-index] ${message}:`, error),
|
||||
});
|
||||
}
|
||||
|
||||
export class SessionIndexService {
|
||||
readonly index: SessionIndex;
|
||||
readonly registry: LiveSessionRegistry;
|
||||
@@ -541,8 +553,10 @@ export class SessionIndexService {
|
||||
};
|
||||
}
|
||||
|
||||
/** Runs `mutation` after the previous mutation of the session ended. */
|
||||
private exclusive<T>(sessionId: string, mutation: () => Promise<T>): Promise<T> {
|
||||
/** Runs `mutation` after the previous mutation of the session ended, such
|
||||
* as a delete that does not go through {@link delete}, so that a retitle
|
||||
* cannot append to a transcript the delete is removing. */
|
||||
exclusive<T>(sessionId: string, mutation: () => Promise<T>): Promise<T> {
|
||||
const previous = this.mutations.get(sessionId) ?? Promise.resolve();
|
||||
const next = previous.catch(() => undefined).then(mutation);
|
||||
const settled = next.catch(() => undefined);
|
||||
@@ -21,20 +21,19 @@
|
||||
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as path from "node:path";
|
||||
import { sanitizeTitle } from "../../session-titles.js";
|
||||
import { sanitizeTitle } from "../session-titles.js";
|
||||
import { effectiveTitle, visibleTitle } from "./archive-title.js";
|
||||
import { isSessionId, projectsRoot } from "../paths.js";
|
||||
import {
|
||||
canonicalPath,
|
||||
encodeProjectPath,
|
||||
errorCode,
|
||||
exists,
|
||||
isExactProjectDir,
|
||||
isSessionId,
|
||||
normalizePath,
|
||||
pathAndAncestors,
|
||||
projectDirMatches,
|
||||
projectDirsOf,
|
||||
projectsRoot,
|
||||
sameProjectPath,
|
||||
} from "./project-dirs.js";
|
||||
import {
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import type { SessionInfo } from "@agentclientprotocol/sdk/unstable";
|
||||
import { withAirMeta } from "../../air-extension.js";
|
||||
import { withAirMeta } from "../air-extension.js";
|
||||
import { deriveActivity, selectCost, type OwnSessionState } from "./activity.js";
|
||||
import type { LiveRecord } from "./live-registry.js";
|
||||
import type { IndexRow } from "./session-index.js";
|
||||
@@ -550,7 +550,55 @@ function stringFields(text: string, key: string): string[] {
|
||||
return values;
|
||||
}
|
||||
|
||||
const lastField = (text: string, key: string) => stringFields(text, key).at(-1) || undefined;
|
||||
/** The string `field` of the JSON record `line`, which is of `type` when one
|
||||
* is given. `null` when the line is no JSON. */
|
||||
function recordField(line: string, field: string, type?: string): string | null | undefined {
|
||||
let record: unknown;
|
||||
try {
|
||||
record = JSON.parse(line);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
if (typeof record !== "object" || record === null) return undefined;
|
||||
if (type !== undefined && (record as Entry).type !== type) return undefined;
|
||||
const value = (record as Entry)[field];
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* The top-level string `field` of the last record of `text` that has one,
|
||||
* as the SDK reads a session's metadata since 0.3.323: it parses each line
|
||||
* that names the field, from the last one back. A `"customTitle":"…"` inside
|
||||
* a message, such as a tool result that shows a transcript, is no title.
|
||||
*
|
||||
* With `type`, only a record of that `type` counts, and a line that names
|
||||
* the type but is no JSON is read from its last `{"type":"<type>"` that does
|
||||
* not follow `:`, `,` or `[`: a record appended to a line whose write was cut
|
||||
* off. The record that the start of the tail window cuts has no such start
|
||||
* in the window, and is not read.
|
||||
*
|
||||
* Undefined when the field of that record is empty: older records are not
|
||||
* searched.
|
||||
*/
|
||||
function lastRecordField(text: string, field: string, type?: string): string | undefined {
|
||||
const fieldMarker = `"${field}":`;
|
||||
const typeMarkers = type === undefined ? undefined : [`"type":"${type}"`, `"type": "${type}"`];
|
||||
const lines = text.split("\n");
|
||||
for (let i = lines.length - 1; i >= 0; i--) {
|
||||
const line = lines[i]!;
|
||||
if (!line.includes(fieldMarker)) continue;
|
||||
if (typeMarkers && !typeMarkers.some((marker) => line.includes(marker))) continue;
|
||||
let value = recordField(line, field, type);
|
||||
if (value === null && typeMarkers) {
|
||||
const start = line.lastIndexOf(`{${typeMarkers[0]}`);
|
||||
if (start > 0 && !":,[".includes(line[start - 1]!)) {
|
||||
value = recordField(line.slice(start), field, type);
|
||||
}
|
||||
}
|
||||
if (typeof value === "string") return value || undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** Whether the first record of the transcript is a sidechain one, which the
|
||||
* SDK never lists. */
|
||||
@@ -560,9 +608,10 @@ export function isSidechainTranscript(head: string): boolean {
|
||||
return first.includes('"isSidechain":true') || first.includes('"isSidechain": true');
|
||||
}
|
||||
|
||||
/** The last `customTitle` of the tail, as the SDK reads it. */
|
||||
/** The title of the last `custom-title` record of the tail, as the SDK reads
|
||||
* it (see {@link lastRecordField}). */
|
||||
export function tailCustomTitle({ tail, sdkTail }: HeadTail): string | undefined {
|
||||
return lastField(sdkTail ?? tail, "customTitle");
|
||||
return lastRecordField(sdkTail ?? tail, "customTitle", "custom-title");
|
||||
}
|
||||
|
||||
/** The last non-blank top-level `agentName` of the records of `text`, the
|
||||
@@ -607,22 +656,23 @@ export function sdkTitles(
|
||||
): SdkTitles {
|
||||
const tail = sdkTail ?? wholeLines;
|
||||
const customTitle =
|
||||
lastField(tail, "customTitle") ??
|
||||
lastRecordField(tail, "customTitle", "custom-title") ??
|
||||
sidecarTitle ??
|
||||
lastField(head, "customTitle") ??
|
||||
lastField(tail, "aiTitle") ??
|
||||
lastField(head, "aiTitle");
|
||||
lastRecordField(head, "customTitle", "custom-title") ??
|
||||
lastRecordField(tail, "aiTitle", "ai-title") ??
|
||||
lastRecordField(head, "aiTitle", "ai-title");
|
||||
return { customTitle, summary: customTitle ?? generatedTitle({ head, tail }) };
|
||||
}
|
||||
|
||||
/** The title of a transcript without a custom title, in the SDK's order: AI
|
||||
* title, last prompt, summary, first prompt. */
|
||||
* title, last prompt, summary, first prompt. The last prompt and the summary
|
||||
* are the field of a record of any type. */
|
||||
export function generatedTitle({ head, tail }: HeadTail): string | undefined {
|
||||
return (
|
||||
lastField(tail, "aiTitle") ??
|
||||
lastField(head, "aiTitle") ??
|
||||
lastField(tail, "lastPrompt") ??
|
||||
lastField(tail, "summary") ??
|
||||
lastRecordField(tail, "aiTitle", "ai-title") ??
|
||||
lastRecordField(head, "aiTitle", "ai-title") ??
|
||||
lastRecordField(tail, "lastPrompt") ??
|
||||
lastRecordField(tail, "summary") ??
|
||||
(firstPrompt(head) || mediaPrompt(head) || undefined)
|
||||
);
|
||||
}
|
||||
@@ -285,7 +285,16 @@ export class SessionModeManager<S extends SessionMode> {
|
||||
return true;
|
||||
}
|
||||
|
||||
async selectMode(sessionId: string, modeId: string): Promise<PermissionMode> {
|
||||
/**
|
||||
* Sets the mode on the query. `auto` on a model without Auto runs as its
|
||||
* fallback, with the warning. With `deferWarning`, the warning waits for
|
||||
* the next prompt (see {@link deferFallbackWarning}).
|
||||
*/
|
||||
async selectMode(
|
||||
sessionId: string,
|
||||
modeId: string,
|
||||
deferWarning = false,
|
||||
): Promise<PermissionMode> {
|
||||
const session = this.requireOpenSession(sessionId);
|
||||
const requestedMode = this.parseMode(modeId);
|
||||
if (!this.isAvailable(session.modes.availableModes, requestedMode)) {
|
||||
@@ -308,7 +317,8 @@ export class SessionModeManager<S extends SessionMode> {
|
||||
}
|
||||
|
||||
if (effectiveMode !== requestedMode) {
|
||||
await this.publishFallbackWarning(sessionId, session);
|
||||
if (deferWarning) this.deferFallbackWarning(session);
|
||||
else await this.publishFallbackWarning(sessionId, session);
|
||||
}
|
||||
return effectiveMode;
|
||||
}
|
||||
@@ -352,6 +362,16 @@ export class SessionModeManager<S extends SessionMode> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Leaves the Auto fallback's warning for the next prompt
|
||||
* (`autoModeFallbackWarningPending`), as a session's start does. For a
|
||||
* fallback during session setup: the client cannot place an update of a
|
||||
* session before the setup response names it.
|
||||
*/
|
||||
deferFallbackWarning(session: SessionMode): void {
|
||||
if (!session.autoModeFallbackWarningShown) session.autoModeFallbackWarningPending = true;
|
||||
}
|
||||
|
||||
async publishFallbackState(sessionId: string, session: SessionMode): Promise<void> {
|
||||
await this.publishCurrent(sessionId, AUTO_MODE_FALLBACK);
|
||||
await this.publishFallbackWarning(sessionId, session);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import type { SessionConfigOption } from "@agentclientprotocol/sdk/unstable";
|
||||
import type { ModelInfo, Query, Settings } from "@anthropic-ai/claude-agent-sdk";
|
||||
// matchDeniedModels is marked @alpha in the SDK; API may shift in a future release.
|
||||
import {
|
||||
matchDeniedModels,
|
||||
type ModelInfo,
|
||||
type Query,
|
||||
type Settings,
|
||||
} from "@anthropic-ai/claude-agent-sdk";
|
||||
import { AIR_RECOMMENDED_CONFIG_VALUE_CAPABILITY, withAirMeta } from "./air-extension.js";
|
||||
import { bedrockRegionPrefix } from "./gateway-models.js";
|
||||
|
||||
@@ -105,7 +111,7 @@ function containsWords(haystack: string, needle: string): boolean {
|
||||
}
|
||||
|
||||
/** `id` without the gateway spellings that `normalizeModelId` keeps for
|
||||
* `deniedModels` and gateway listings: path segments before `claude-`
|
||||
* gateway listings: path segments before `claude-`
|
||||
* (`vertex_ai/`, `openrouter/anthropic/`, `publishers/anthropic/models/`)
|
||||
* and the Anthropic API's `-latest` suffix (`claude-3-5-haiku-latest`). */
|
||||
function withoutGatewaySpelling(id: string): string {
|
||||
@@ -140,6 +146,8 @@ function modelCoversTokens(model: ModelInfo, tokens: string[]): boolean {
|
||||
* of its model words, preferring one with the same context hint ("sonnet[1m]"
|
||||
* for "claude-sonnet-5-1m"). The fuzzy tiers need a compatible version, and
|
||||
* words match whole: "not-a-model", "son" and "foo-sonnet" name no entry.
|
||||
* For a preference without a version, the fuzzy tiers take the entry of the
|
||||
* newest version: "opus[1m]" gives "claude-opus-5-5", not "claude-opus-4-5".
|
||||
*/
|
||||
export function resolveModelPreference(models: ModelInfo[], preference: string): ModelInfo | null {
|
||||
const trimmed = preference.trim();
|
||||
@@ -169,27 +177,58 @@ export function resolveModelPreference(models: ModelInfo[], preference: string):
|
||||
|
||||
const preferenceHint = contextHintOf(trimmed);
|
||||
const tokens = modelPreferenceTokens(trimmed);
|
||||
const includesMatch = models.find((model) => {
|
||||
if (!modelVersionsCompatible(trimmed, model)) return false;
|
||||
if (contextHintOf(model.value) !== preferenceHint) return false;
|
||||
return (
|
||||
containsWords(model.value, trimmed) ||
|
||||
containsWords(model.displayName, trimmed) ||
|
||||
(containsWords(trimmed, model.value) && modelCoversTokens(model, tokens))
|
||||
);
|
||||
});
|
||||
// A preference without a version (`opus`, `opus[1m]`) runs its family's
|
||||
// newest model in the CLI, so the fuzzy tiers pick the newest row, not the
|
||||
// first: an allowlist lists `claude-opus-4-5-20251101` before `claude-opus-5-5`.
|
||||
const pick =
|
||||
extractModelFamilyVersion(trimmed) === null
|
||||
? newestModel
|
||||
: (rows: ModelInfo[]): ModelInfo | undefined => rows[0];
|
||||
const includesMatch = pick(
|
||||
models.filter((model) => {
|
||||
if (!modelVersionsCompatible(trimmed, model)) return false;
|
||||
if (contextHintOf(model.value) !== preferenceHint) return false;
|
||||
return (
|
||||
containsWords(model.value, trimmed) ||
|
||||
containsWords(model.displayName, trimmed) ||
|
||||
(containsWords(trimmed, model.value) && modelCoversTokens(model, tokens))
|
||||
);
|
||||
}),
|
||||
);
|
||||
if (includesMatch) return includesMatch;
|
||||
|
||||
const candidates = models.filter(
|
||||
(model) => modelVersionsCompatible(trimmed, model) && modelCoversTokens(model, tokens),
|
||||
);
|
||||
return (
|
||||
candidates.find((model) => contextHintOf(model.value) === preferenceHint) ??
|
||||
candidates[0] ??
|
||||
pick(candidates.filter((model) => contextHintOf(model.value) === preferenceHint)) ??
|
||||
pick(candidates) ??
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/** The row of `models` that runs the newest family version, the first one of
|
||||
* equal versions. A row of an unknown version (`my-model`) ranks below each
|
||||
* row of a known one. */
|
||||
function newestModel(models: ModelInfo[]): ModelInfo | undefined {
|
||||
let newest: ModelInfo | undefined;
|
||||
let newestVersion: { major: number; minor: number } | null = null;
|
||||
for (const model of models) {
|
||||
const version = familyVersionOf(normalizeModelId(model.resolvedModel ?? model.value));
|
||||
const newer =
|
||||
newest === undefined ||
|
||||
(version !== null &&
|
||||
(newestVersion === null ||
|
||||
version.major > newestVersion.major ||
|
||||
(version.major === newestVersion.major && version.minor > newestVersion.minor)));
|
||||
if (newer) {
|
||||
newest = model;
|
||||
newestVersion = version;
|
||||
}
|
||||
}
|
||||
return newest;
|
||||
}
|
||||
|
||||
export function matchResumedModel(models: ModelInfo[], liveModel: string): ModelInfo {
|
||||
const live = canonicalizeModelId(liveModel);
|
||||
const defaultEntry = models.find((model) => model.value === "default");
|
||||
@@ -376,8 +415,8 @@ export function aliasResumedModelRow(
|
||||
|
||||
/** A model id without the spellings that name the same model: provider
|
||||
* prefixes, dates, version suffixes, `:variant` suffixes, dotted versions,
|
||||
* `-fast` and context hints. `deniedModels` and gateway listings both match on
|
||||
* it. OpenRouter lists `anthropic/claude-opus-5.5:batch[1m]`, which normalizes
|
||||
* `-fast` and context hints. Gateway listings match on it. OpenRouter lists
|
||||
* `anthropic/claude-opus-5.5:batch[1m]`, which normalizes
|
||||
* to `claude-opus-5-5`; `anthropic/openai/gpt-5` keeps its `openai/` prefix and
|
||||
* matches no Claude id. */
|
||||
function normalizeModelId(value: string): string {
|
||||
@@ -401,24 +440,56 @@ function normalizeModelId(value: string): string {
|
||||
);
|
||||
}
|
||||
|
||||
/** A path that no model id starts with. Nothing enforces that no
|
||||
* `deniedModels` entry names it (see {@link deniedModelSpellings}). */
|
||||
const VERSION_SPELLING_PATH = "version-of/";
|
||||
|
||||
/**
|
||||
* Whether managed `deniedModels` blocks a model id, following the CLI's rules
|
||||
* closely enough for the picker: a family alias blocks the whole family, and a
|
||||
* model id blocks that version in every spelling plus the later minor versions
|
||||
* it prefixes (`claude-opus-5` also blocks `claude-opus-5-5`). Entries share
|
||||
* `normalizeModelId`, so `claude-opus-4.5` or `anthropic/claude-opus-4.5` also
|
||||
* blocks `claude-opus-4-5`, which the CLI may still allow. The CLI stays the
|
||||
* enforcer; this only keeps the picker from offering a refused row.
|
||||
* The spellings of `id` to ask the SDK's `matchDeniedModels` about. That
|
||||
* function compares an id with the entries alone. The CLI blocks more
|
||||
* (`setModel` against CLI 2.1.323):
|
||||
* - a last path segment that an exact-name entry names: `my-model` blocks
|
||||
* `gateway/my-model`;
|
||||
* - a version behind a `:variant` suffix or written with a dot:
|
||||
* `claude-opus-5-5` blocks `claude-opus-5-5:free` and
|
||||
* `anthropic/claude-opus-5.5`.
|
||||
*
|
||||
* An exact-name entry does not block a `:variant`: `my-model` leaves
|
||||
* `my-model:free` allowed. So the version spelling goes behind a path, which
|
||||
* the SDK ignores for a versioned id and which keeps the spelling from
|
||||
* equalling an exact name.
|
||||
*/
|
||||
export function isDeniedModel(modelId: string, deniedModels: readonly string[]): boolean {
|
||||
const id = normalizeModelId(modelId);
|
||||
if (!id) return false;
|
||||
return deniedModels.some((entry) => {
|
||||
const denied = normalizeModelId(entry);
|
||||
if (!denied) return false;
|
||||
if (MODEL_FAMILY_ALIASES.has(denied)) return id === denied || id.includes(`-${denied}`);
|
||||
return id === denied || id.startsWith(`${denied}-`);
|
||||
});
|
||||
function deniedModelSpellings(id: string): string[] {
|
||||
const lastSegment = id.slice(id.lastIndexOf("/") + 1);
|
||||
const version = lastSegment.replace(/:.*$/, "").replace(/(?<=\d)\.(?=\d)/g, "-");
|
||||
return [id, lastSegment, `${VERSION_SPELLING_PATH}${version}`];
|
||||
}
|
||||
|
||||
/**
|
||||
* Which of `ids` a managed `deniedModels` list blocks, by the CLI's own entry
|
||||
* rules: the SDK's `matchDeniedModels`, asked about each of the
|
||||
* {@link deniedModelSpellings} of an id.
|
||||
* - A family alias (`opus`) blocks the family.
|
||||
* - A model id blocks that version in every spelling, and the later minor
|
||||
* versions when it names none (`claude-opus-5` also blocks `claude-opus-5-5`).
|
||||
* - Any other entry (`claude-opus-4.5`, `my-model`) blocks only that name,
|
||||
* alone or as the last path segment (`gateway/my-model`).
|
||||
* - `default`, `best` and `opusplan` block nothing.
|
||||
*
|
||||
* The CLI stays the enforcer; this only keeps the picker from offering a row
|
||||
* that `setModel` would refuse.
|
||||
*/
|
||||
export async function deniedModelIds(
|
||||
ids: readonly string[],
|
||||
deniedModels: readonly string[],
|
||||
): Promise<Set<string>> {
|
||||
if (ids.length === 0 || deniedModels.length === 0) return new Set();
|
||||
const asked = ids.flatMap((id) => deniedModelSpellings(id).map((spelling) => ({ id, spelling })));
|
||||
const { denied } = await matchDeniedModels(
|
||||
asked.map(({ spelling }) => spelling),
|
||||
deniedModels,
|
||||
);
|
||||
return new Set(asked.filter((_, index) => denied[index]).map(({ id }) => id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,15 +507,16 @@ export function isDeniedModel(modelId: string, deniedModels: readonly string[]):
|
||||
* - `undefined` is handled by the caller (no allowlist applied).
|
||||
* - The Default option is unaffected by `availableModels` — it always remains
|
||||
* available, even when the allowlist is `[]`.
|
||||
* - Managed `deniedModels` wins over the allowlist, so a denied entry is
|
||||
* dropped even though the CLI would otherwise leave it unmatched.
|
||||
* - Managed `deniedModels` wins over the allowlist: an entry is dropped when
|
||||
* the list blocks its name, its `modelOverrides` target, or the model of the
|
||||
* row it resolves to (see {@link deniedModelIds}).
|
||||
*/
|
||||
export function applyAvailableModelsAllowlist(
|
||||
export async function applyAvailableModelsAllowlist(
|
||||
sdkModels: ModelInfo[],
|
||||
allowlist: string[],
|
||||
settingsModelOverrides?: Record<string, string>,
|
||||
deniedModels: readonly string[] = [],
|
||||
): ModelInfo[] {
|
||||
): Promise<ModelInfo[]> {
|
||||
// Default is always preserved per the docs. Synthesize one if the SDK
|
||||
// didn't surface it so downstream code (e.g. `getAvailableModels` picking
|
||||
// `models[0]` as a fallback) still has something to work with.
|
||||
@@ -465,22 +537,21 @@ export function applyAvailableModelsAllowlist(
|
||||
// opaque provider IDs) often won't textually resemble anything in
|
||||
// `sdkModelsWithoutDefault`. Only the entry's surfaced `value` becomes the
|
||||
// override target, so it's what `setModel` ends up passing to the API.
|
||||
for (const entry of allowlist) {
|
||||
const entries = allowlist.flatMap((entry) => {
|
||||
const trimmed = entry.trim();
|
||||
if (!trimmed || seen.has(trimmed)) continue;
|
||||
|
||||
const overridden = settingsModelOverrides?.[trimmed];
|
||||
const effective = overridden ?? trimmed;
|
||||
if (seen.has(effective)) continue;
|
||||
|
||||
if (!trimmed) return [];
|
||||
const effective = settingsModelOverrides?.[trimmed] ?? trimmed;
|
||||
const sdkMatch = resolveModelPreference(sdkModelsWithoutDefault, trimmed);
|
||||
if (
|
||||
[trimmed, effective, sdkMatch?.resolvedModel].some(
|
||||
(id) => id != null && isDeniedModel(id, deniedModels),
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const ids = [trimmed, effective, ...(sdkMatch?.resolvedModel ? [sdkMatch.resolvedModel] : [])];
|
||||
return [{ trimmed, effective, sdkMatch, ids }];
|
||||
});
|
||||
const denied = await deniedModelIds(
|
||||
entries.flatMap(({ ids }) => ids),
|
||||
deniedModels,
|
||||
);
|
||||
for (const { trimmed, effective, sdkMatch, ids } of entries) {
|
||||
if (seen.has(trimmed) || seen.has(effective)) continue;
|
||||
if (ids.some((id) => denied.has(id))) continue;
|
||||
if (sdkMatch) {
|
||||
result.push({ ...sdkMatch, value: effective });
|
||||
} else {
|
||||
@@ -568,10 +639,10 @@ export function narrowToGatewayModels(
|
||||
* capability flag (current and future); the identity fields are overridden
|
||||
* because the fuzzy-matched sibling's resolvedModel/displayName/description
|
||||
* can describe a different context lane and would poison later resolvedModel
|
||||
* matching (a model switch that the adapter did not make) and context-window
|
||||
* inference if they traveled under this id. `allowlistedModelInfo` is the
|
||||
* allowlisted entry alone, the only one whose identity strings are a
|
||||
* trustworthy window signal.
|
||||
* matching (a model switch that the adapter did not make) and the lookup of
|
||||
* the learned context window (`immediateContextWindow`) if they traveled under
|
||||
* this id. `allowlistedModelInfo` is the allowlisted entry alone, the only one
|
||||
* whose `resolvedModel` that lookup may use.
|
||||
*/
|
||||
export function withCurrentModelInfo(
|
||||
allowedModels: ModelInfo[],
|
||||
|
||||
68
src/session-status.ts
Normal file
68
src/session-status.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* `session/status` (the unstable "Session status" RFD) of a session that the
|
||||
* connection does not hold: `saved` or unknown. Each core answers `open`
|
||||
* itself for the sessions it holds.
|
||||
*/
|
||||
import * as fs from "node:fs/promises";
|
||||
import * as path from "node:path";
|
||||
import { RequestError } from "@agentclientprotocol/sdk/unstable";
|
||||
import { isSessionId, projectsRoot } from "./paths.js";
|
||||
|
||||
/** What a core advertises as `status` in its session capabilities. */
|
||||
export const SESSION_STATUS_CAPABILITY = {};
|
||||
|
||||
/**
|
||||
* `saved` when a project directory holds a transcript file of `sessionId`
|
||||
* that is not empty. Its content is not read, so a transcript without a
|
||||
* conversation is `saved` too, and its resume fails with `-32002`. Fails with
|
||||
* `-32002` and `data.sessionId` otherwise:
|
||||
*
|
||||
* - an id that is not a UUID, such as a subagent's session id;
|
||||
* - an id without a transcript: one never used, a session never prompted
|
||||
* (Claude Code writes the transcript at the first prompt), and a session
|
||||
* whose transcripts were removed.
|
||||
*
|
||||
* The request names no `cwd`, so a transcript of any project counts: a
|
||||
* resume with another `cwd` can still fail with `-32002`.
|
||||
*
|
||||
* It lists the project directories and stats the one file name in each. No
|
||||
* query starts and no session is loaded. A directory or file that cannot be
|
||||
* read for another reason than being absent fails the request: it does not
|
||||
* make the session unknown.
|
||||
*/
|
||||
export async function savedSessionStatus(sessionId: string): Promise<{ status: "saved" }> {
|
||||
if (!isSessionId(sessionId) || !(await hasTranscript(sessionId))) {
|
||||
throw RequestError.sessionNotFound(sessionId);
|
||||
}
|
||||
return { status: "saved" };
|
||||
}
|
||||
|
||||
async function hasTranscript(sessionId: string): Promise<boolean> {
|
||||
const root = projectsRoot();
|
||||
let projects: string[];
|
||||
try {
|
||||
projects = await fs.readdir(root);
|
||||
} catch (error) {
|
||||
// No session was ever stored.
|
||||
if (isAbsent(error)) return false;
|
||||
throw error;
|
||||
}
|
||||
const found = await Promise.all(
|
||||
projects.map((project) =>
|
||||
fs.stat(path.join(root, project, `${sessionId}.jsonl`)).then(
|
||||
(stats) => stats.isFile() && stats.size > 0,
|
||||
(error: unknown) => {
|
||||
// No such transcript, or `project` is a file.
|
||||
if (isAbsent(error)) return false;
|
||||
throw error;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
return found.includes(true);
|
||||
}
|
||||
|
||||
function isAbsent(error: unknown): boolean {
|
||||
const code = (error as { code?: unknown }).code;
|
||||
return code === "ENOENT" || code === "ENOTDIR";
|
||||
}
|
||||
@@ -30,7 +30,14 @@ export const ZERO_USAGE = Object.freeze({
|
||||
cache_creation_input_tokens: 0,
|
||||
});
|
||||
|
||||
export const DEFAULT_CONTEXT_WINDOW = 200000;
|
||||
/**
|
||||
* The context window reported for a model until Claude Code says what it is
|
||||
* (see `context-window.ts`): 1M, the window Claude Code itself assumes for a
|
||||
* model id it does not know (since 2.1.323). Claude Code reports 200K for an
|
||||
* older model such as `claude-sonnet-4-5`, and for every model under
|
||||
* `CLAUDE_CODE_DISABLE_1M_CONTEXT=1`.
|
||||
*/
|
||||
export const DEFAULT_CONTEXT_WINDOW = 1_000_000;
|
||||
|
||||
/** `_meta.quota` for work that spent `usage` in its main agent loop and
|
||||
* `modelUsage` by model (see `turnQuotaMeta` in `v1/acp-agent.ts`). */
|
||||
@@ -212,26 +219,6 @@ function commonPrefixLength(a: string, b: string) {
|
||||
return i;
|
||||
}
|
||||
|
||||
/** Best-effort first guess of a model's context window, used to seed the
|
||||
* window synchronously (via `immediateContextWindow`) until a `result` message
|
||||
* arrives with the authoritative `modelUsage` value.
|
||||
*
|
||||
* Anthropic 1M-context variants encode "1m" as a distinct token in the SDK
|
||||
* model ID (e.g., "claude-opus-4-6-1m"), which `\b1m\b` catches without also
|
||||
* matching things like "10m" or embedded substrings. Semantic aliases like
|
||||
* `default` carry no such token in the ID, but their `resolvedModel` and the
|
||||
* SDK's human-facing `displayName`/`description` can (e.g.
|
||||
* "claude-opus-4-8[1m]", "Opus 4.7 (1M context)"), so callers pass those too.
|
||||
* This text scan can't catch every model — some resolve to extended-context
|
||||
* models with no "1m" anywhere (e.g. `sonnet` → claude-sonnet-5, natively
|
||||
* ~1M). Such a miss falls back to the default window, is refined by the
|
||||
* background `getContextUsage` (`refreshContextWindowInBackground`), and is
|
||||
* corrected by `result.modelUsage` (and cached) within one turn. */
|
||||
export function inferContextWindowFromModel(...texts: Array<string | undefined>): number | null {
|
||||
if (texts.some((text) => text != null && /\b1m\b/i.test(text))) return 1_000_000;
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getMatchingModelUsage(
|
||||
modelUsage: Record<string, ModelUsage>,
|
||||
currentModel: string,
|
||||
|
||||
111
src/settings.ts
111
src/settings.ts
@@ -7,6 +7,7 @@ import {
|
||||
resolveSettings,
|
||||
type Settings,
|
||||
} from "@anthropic-ai/claude-agent-sdk";
|
||||
import { unloadedPolicySources } from "./managed-policy.js";
|
||||
import { claudeConfigDir } from "./paths.js";
|
||||
|
||||
/**
|
||||
@@ -37,6 +38,15 @@ export interface SettingsManagerOptions {
|
||||
logger?: { log: (...args: any[]) => void; error: (...args: any[]) => void };
|
||||
}
|
||||
|
||||
type ModelSelectionSettings = Pick<Settings, "availableModels" | "modelOverrides">;
|
||||
|
||||
/** The settings that decide whether Claude Code compacts (see `idle-compaction.ts`). */
|
||||
export type CompactionSettings = {
|
||||
idleCompaction?: boolean;
|
||||
autoCompactEnabled?: boolean;
|
||||
env?: Record<string, string>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Manages Claude Code settings using the SDK's `resolveSettings` merge engine
|
||||
* so the values we see match what `query()` would observe.
|
||||
@@ -50,7 +60,12 @@ export class SettingsManager {
|
||||
private cwd: string;
|
||||
private effective: Settings = {};
|
||||
private managedDeniedModels: string[] = [];
|
||||
private managedModelSettings: ModelSelectionSettings = {};
|
||||
private managedApiKeyHelper?: string;
|
||||
private managedCompactionSettings: CompactionSettings = {};
|
||||
private managedShowClearContextOnPlanAccept?: boolean;
|
||||
/** The policy sources last logged as not loaded (see {@link unloadedPolicySources}). */
|
||||
private unloadedPolicy?: string;
|
||||
private watchers: fs.FSWatcher[] = [];
|
||||
private onChange?: () => void;
|
||||
private logger: { log: (...args: any[]) => void; error: (...args: any[]) => void };
|
||||
@@ -107,20 +122,56 @@ export class SettingsManager {
|
||||
private async loadAllSettings(): Promise<void> {
|
||||
try {
|
||||
const resolved = await resolveSettings({ cwd: this.cwd });
|
||||
// Once per change: a reload after each settings file edit would repeat it.
|
||||
const unloaded = unloadedPolicySources(resolved);
|
||||
if (unloaded !== this.unloadedPolicy) {
|
||||
this.unloadedPolicy = unloaded;
|
||||
if (unloaded) {
|
||||
this.logger.error(
|
||||
`Managed settings did not load from ${unloaded}: the session's settings ` +
|
||||
"and model list do not reflect it. Claude Code reads the policy itself.",
|
||||
);
|
||||
}
|
||||
}
|
||||
this.effective = filterEscalatingDefaultMode(resolved);
|
||||
// The CLI reads `deniedModels` from managed settings only.
|
||||
this.managedDeniedModels = resolved.sources
|
||||
.filter((entry) => entry.source === "managed")
|
||||
.flatMap((entry) => entry.settings.deniedModels ?? []);
|
||||
this.managedModelSettings = Object.assign(
|
||||
{},
|
||||
...resolved.sources
|
||||
.filter((entry) => entry.source === "managed")
|
||||
.map((entry) => ({
|
||||
availableModels: entry.settings.availableModels,
|
||||
modelOverrides: entry.settings.modelOverrides,
|
||||
})),
|
||||
);
|
||||
this.managedApiKeyHelper =
|
||||
resolved.provenance.apiKeyHelper?.source === "managed"
|
||||
? resolved.effective.apiKeyHelper
|
||||
: undefined;
|
||||
const managed = resolved.sources
|
||||
.filter((entry) => entry.source === "managed")
|
||||
.map((entry) => entry.settings);
|
||||
this.managedCompactionSettings = {
|
||||
idleCompaction: managed.findLast((tier) => tier.idleCompaction !== undefined)
|
||||
?.idleCompaction,
|
||||
autoCompactEnabled: managed.findLast((tier) => tier.autoCompactEnabled !== undefined)
|
||||
?.autoCompactEnabled,
|
||||
env: Object.assign({}, ...managed.map((tier) => tier.env)),
|
||||
};
|
||||
this.managedShowClearContextOnPlanAccept = managed.findLast(
|
||||
(tier) => tier.showClearContextOnPlanAccept !== undefined,
|
||||
)?.showClearContextOnPlanAccept;
|
||||
} catch (error) {
|
||||
this.logger.error("Failed to resolve settings:", error);
|
||||
this.effective = {};
|
||||
this.managedDeniedModels = [];
|
||||
this.managedModelSettings = {};
|
||||
this.managedApiKeyHelper = undefined;
|
||||
this.managedCompactionSettings = {};
|
||||
this.managedShowClearContextOnPlanAccept = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +244,66 @@ export class SettingsManager {
|
||||
);
|
||||
}
|
||||
|
||||
/** Model selection settings including the inline SDK settings tier. */
|
||||
getModelSelectionSettings(override?: Settings): ModelSelectionSettings {
|
||||
// The SDK unions non-managed allowlists, but a managed list owns the
|
||||
// whole allowlist. Keep that policy when adding
|
||||
// models the SDK did not include in its initialization result.
|
||||
const lists = [this.effective.availableModels, override?.availableModels].filter(
|
||||
(list): list is string[] => Array.isArray(list),
|
||||
);
|
||||
const managed = this.managedModelSettings;
|
||||
return {
|
||||
availableModels:
|
||||
managed.availableModels ?? (lists.length > 0 ? [...new Set(lists.flat())] : undefined),
|
||||
modelOverrides: {
|
||||
...this.effective.modelOverrides,
|
||||
...override?.modelOverrides,
|
||||
...managed.modelOverrides,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* `idleCompaction`, `autoCompactEnabled` and `env` as the CLI resolves them:
|
||||
* managed settings outrank the `--settings` override, which outranks the
|
||||
* user/project/local files. `env` merges entry by entry in the same order. A
|
||||
* key whose value is `undefined` in the override does not hide the files' value.
|
||||
*/
|
||||
getCompactionSettings(settingsOverride?: Settings): CompactionSettings {
|
||||
const managed = this.managedCompactionSettings;
|
||||
const env: Record<string, string> = {};
|
||||
for (const tier of [this.effective.env, settingsOverride?.env, managed.env]) {
|
||||
for (const [name, value] of Object.entries(tier ?? {})) {
|
||||
if (value !== undefined) env[name] = value;
|
||||
}
|
||||
}
|
||||
return {
|
||||
idleCompaction:
|
||||
managed.idleCompaction ?? settingsOverride?.idleCompaction ?? this.effective.idleCompaction,
|
||||
autoCompactEnabled:
|
||||
managed.autoCompactEnabled ??
|
||||
settingsOverride?.autoCompactEnabled ??
|
||||
this.effective.autoCompactEnabled,
|
||||
env,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an approved plan may be continued in a fresh context, as the CLI
|
||||
* resolves `showClearContextOnPlanAccept`: managed settings outrank the
|
||||
* `--settings` override, which outranks the user/project/local files. Off
|
||||
* unless one of them sets it, like the CLI.
|
||||
*/
|
||||
getShowClearContextOnPlanAccept(settingsOverride?: Settings): boolean {
|
||||
return (
|
||||
this.managedShowClearContextOnPlanAccept ??
|
||||
settingsOverride?.showClearContextOnPlanAccept ??
|
||||
this.effective.showClearContextOnPlanAccept ??
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* `deniedModels` entries from the managed tier, the only tier the CLI
|
||||
* honors them from.
|
||||
|
||||
@@ -20,7 +20,10 @@
|
||||
* reached the call is that message too: the sender's outgoing view, at the
|
||||
* call, and the child's incoming one, in the child's history. A child's
|
||||
* history follows its launch, so a call to a child from its parent is always
|
||||
* delivered first. Any other SendMessage call stays a tool call.
|
||||
* delivered first. Any other SendMessage call stays a tool call. As live, a
|
||||
* TaskStop or SendMessage call that the client is shown and that names a
|
||||
* replayed child by its agent id carries the RFD's `session` reference to it
|
||||
* (`ReplayTranscript.withTarget`).
|
||||
*
|
||||
* Right after its announcement, each child gets its `model` option: the model
|
||||
* of its first response, in its transcript. A later response with another
|
||||
@@ -50,6 +53,8 @@ import {
|
||||
rfdLabels,
|
||||
sameDirectory,
|
||||
type SubagentModels,
|
||||
targetAgentId,
|
||||
withSessionReference,
|
||||
type WorkState,
|
||||
} from "./native-subagents.js";
|
||||
import { noticeUpdate } from "./session-notices.js";
|
||||
@@ -116,9 +121,29 @@ export class ReplayTranscript<Child extends ReplayChild = ReplayChild> {
|
||||
readonly omitted = new Set<string>();
|
||||
/** The SubagentHandback calls, by tool use id. */
|
||||
readonly handbacks = new Map<string, ReplayHandback>();
|
||||
/** The agent that each TaskStop or SendMessage call names (see `targetAgentId`), by tool use id. */
|
||||
private readonly targets = new Map<string, string>();
|
||||
|
||||
constructor(private readonly history: SubagentHistory) {}
|
||||
|
||||
/**
|
||||
* `notification`, a replayed tool call update that the client is shown on
|
||||
* the session `shownOn`, with the RFD's `session` reference when the call
|
||||
* names a child of another session by its agent id, as live
|
||||
* (`NativeSubagentRuntime.withTarget`). Only a child that the replay
|
||||
* announced before the update is referenced.
|
||||
*/
|
||||
withTarget(notification: AcpSessionNotification, shownOn: string): AcpSessionNotification {
|
||||
const { update } = notification;
|
||||
if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update") {
|
||||
return notification;
|
||||
}
|
||||
const agentId = this.targets.get(update.toolCallId);
|
||||
const child = agentId !== undefined ? this.byAgentId.get(agentId) : undefined;
|
||||
if (!child?.announced || child.sessionId === shownOn) return notification;
|
||||
return withSessionReference(notification, child.sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the launches, the launch results, and the SendMessage calls in
|
||||
* `messages`, the transcript of the session `ownerSessionId`.
|
||||
@@ -127,6 +152,8 @@ export class ReplayTranscript<Child extends ReplayChild = ReplayChild> {
|
||||
for (const message of messages) {
|
||||
for (const block of contentBlocks(message)) {
|
||||
if (block.type === "tool_use" && typeof block.id === "string") {
|
||||
const agentId = targetAgentId(block.name, block.input);
|
||||
if (agentId !== undefined) this.targets.set(block.id, agentId);
|
||||
if (isNativeSubagentControlTool(block.name)) {
|
||||
this.registerLaunch(block.id, inputOf(block), ownerSessionId);
|
||||
} else if (block.name === HANDBACK_TOOL) {
|
||||
@@ -214,6 +241,11 @@ export class RfdSubagentReplay {
|
||||
}
|
||||
|
||||
/** The child that the tool use `toolUseId` launched, when the replay shows it. */
|
||||
/** See {@link ReplayTranscript.withTarget}. */
|
||||
withTarget(notification: AcpSessionNotification, shownOn: string): AcpSessionNotification {
|
||||
return this.transcript.withTarget(notification, shownOn);
|
||||
}
|
||||
|
||||
childOfLaunch(toolUseId: string): ReplayChild | undefined {
|
||||
return this.transcript.children.get(toolUseId);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* The `<task-notification>` inputs that Claude Code writes to a transcript
|
||||
* when a background task stops. The replay of a session (`v1/acp-agent.ts`) and
|
||||
* the session index (`v1/session-index/background-tasks.ts`) read them here, so
|
||||
* the session index (`session-index/background-tasks.ts`) read them here, so
|
||||
* both read the same fields.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"initialize","payload":{"_meta":{"jetbrains":{"air":{"capabilities":["sessionFailure","agentFileChangeReport","nativeSubagentSessions","asyncTasks","customInstructions","recommendedValue","diffPatch","planFile","backgroundSubagents"],"goal":{"actions":["set","clear"],"controlMethod":"_session/goal","version":1},"version":1}},"steering":{"supported":true}},"agentCapabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"logout":{},"status":{}},"loadSession":true,"mcpCapabilities":{"http":true,"sse":true},"promptCapabilities":{"embeddedContext":true,"image":true},"providers":{},"sessionCapabilities":{"additionalDirectories":{},"close":{},"delete":{},"fork":{},"list":{},"resume":{},"subagents":{},"systemPrompt":{"mode":{"override":{}}}}},"agentInfo":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"authMethods":[],"protocolVersion":1}}
|
||||
{"kind":"initialize","payload":{"_meta":{"jetbrains":{"air":{"capabilities":["sessionFailure","agentFileChangeReport","nativeSubagentSessions","asyncTasks","customInstructions","recommendedValue","diffPatch","planFile","backgroundSubagents"],"goal":{"actions":["set","clear"],"controlMethod":"_session/goal","version":1},"version":1}},"steering":{"supported":true}},"agentCapabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"logout":{},"status":{}},"loadSession":true,"mcpCapabilities":{"acp":true,"http":true,"sse":true},"promptCapabilities":{"embeddedContext":true,"image":true},"providers":{},"sessionCapabilities":{"additionalDirectories":{},"close":{},"delete":{},"fork":{},"list":{},"options":{},"resume":{},"status":{},"subagents":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"agentInfo":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"authMethods":[],"protocolVersion":1}}
|
||||
{"kind":"sessionUpdate","payload":{"sessionId":"<session>","update":{"content":{"text":"Fix the bug","type":"text"},"messageId":"00000000-0000-4000-8000-00000000c001","sessionUpdate":"user_message_chunk"}}}
|
||||
{"kind":"sessionUpdate","payload":{"sessionId":"<session>","update":{"content":{"text":"Check the file.","type":"text"},"messageId":"msg_r1","sessionUpdate":"agent_thought_chunk"}}}
|
||||
{"kind":"sessionUpdate","payload":{"sessionId":"<session>","update":{"content":{"text":"I will edit it.","type":"text"},"messageId":"msg_r1","sessionUpdate":"agent_message_chunk"}}}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{"kind":"initialize","payload":{"_meta":{"jetbrains":{"air":{"capabilities":["sessionFailure","agentFileChangeReport","nativeSubagentSessions","asyncTasks","customInstructions","recommendedValue","diffPatch","planFile","backgroundSubagents"],"goal":{"actions":["set","clear"],"controlMethod":"_session/goal","version":1},"version":1}},"steering":{"supported":true}},"agentCapabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"logout":{},"status":{}},"loadSession":true,"mcpCapabilities":{"http":true,"sse":true},"promptCapabilities":{"embeddedContext":true,"image":true},"providers":{},"sessionCapabilities":{"additionalDirectories":{},"close":{},"delete":{},"fork":{},"list":{},"resume":{},"subagents":{},"systemPrompt":{"mode":{"override":{}}}}},"agentInfo":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"authMethods":[],"protocolVersion":1}}
|
||||
{"kind":"initialize","payload":{"_meta":{"jetbrains":{"air":{"capabilities":["sessionFailure","agentFileChangeReport","nativeSubagentSessions","asyncTasks","customInstructions","recommendedValue","diffPatch","planFile","backgroundSubagents"],"goal":{"actions":["set","clear"],"controlMethod":"_session/goal","version":1},"version":1}},"steering":{"supported":true}},"agentCapabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"logout":{},"status":{}},"loadSession":true,"mcpCapabilities":{"acp":true,"http":true,"sse":true},"promptCapabilities":{"embeddedContext":true,"image":true},"providers":{},"sessionCapabilities":{"additionalDirectories":{},"close":{},"delete":{},"fork":{},"list":{},"options":{},"resume":{},"status":{},"subagents":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"agentInfo":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"authMethods":[],"protocolVersion":1}}
|
||||
{"kind":"newSession","payload":{"configOptions":[{"category":"mode","currentValue":"auto","description":"Session permission mode","id":"mode","name":"Mode","options":[{"_meta":{"jetbrains":{"air":{"kind":"standard","version":1}}},"description":"Always ask before making changes","name":"Manual","value":"default"},{"_meta":{"jetbrains":{"air":{"kind":"standard","version":1}}},"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"_meta":{"jetbrains":{"air":{"kind":"plan","version":1}}},"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"_meta":{"jetbrains":{"air":{"kind":"auto_review","version":1}}},"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"_meta":{"jetbrains":{"air":{"kind":"full_access","version":1}}},"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","id":"model","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"modes":{"availableModes":[{"_meta":{"jetbrains":{"air":{"kind":"standard","version":1}}},"description":"Always ask before making changes","id":"default","name":"Manual"},{"_meta":{"jetbrains":{"air":{"kind":"standard","version":1}}},"description":"Automatically accept all file edits","id":"acceptEdits","name":"Accept edits"},{"_meta":{"jetbrains":{"air":{"kind":"plan","version":1}}},"description":"Create a plan before making changes","id":"plan","name":"Plan"},{"_meta":{"jetbrains":{"air":{"kind":"auto_review","version":1}}},"description":"Claude handles permission decisions","id":"auto","name":"Auto"},{"_meta":{"jetbrains":{"air":{"kind":"full_access","version":1}}},"description":"Accepts all permissions","id":"bypassPermissions","name":"Bypass permissions"}],"currentModeId":"auto"},"sessionId":"<session>"}}
|
||||
{"kind":"sessionUpdate","payload":{"sessionId":"<session>","update":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]"},"name":"mcp"}],"sessionUpdate":"available_commands_update"}}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
@@ -10,7 +10,7 @@
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"rawInput":{"command":"false"},"sessionUpdate":"tool_call_update","title":"false","toolCallId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"_meta":{"_claude/model":"claude-sonnet-4-6"},"sessionUpdate":"usage_update","size":200000,"used":3}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"rawInput":{"command":"false","description":"Fail"},"sessionUpdate":"tool_call_update","toolCallId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"output":{"data":"RXhpdCBjb2RlIDEKYm9vbQ=="},"sessionUpdate":"terminal_update","terminalId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"output":{"data":"RXhpdCBjb2RlIDENCmJvb20="},"sessionUpdate":"terminal_update","terminalId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"exitStatus":{"exitCode":1},"sessionUpdate":"terminal_update","terminalId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"sessionUpdate":"tool_call_update","status":"failed","toolCallId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"_meta":{"_claude/model":"claude-sonnet-4-6"},"cost":{"amount":0,"currency":"USD"},"sessionUpdate":"usage_update","size":200000,"used":2}}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
@@ -13,7 +13,7 @@
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"background":[],"sessionUpdate":"state_update","state":"requires_action"}}}
|
||||
{"kind":"request","method":"session/request_permission","payload":{"options":[{"kind":"allow_once","name":"Yes","optionId":"allow-once"},{"kind":"reject_once","name":"No","optionId":"reject"}],"sessionId":"<session>","subject":{"toolCall":{"content":[{"terminalId":"toolu_bash","type":"terminal"}],"kind":"execute","name":"Bash","rawInput":{"command":"ls -la","description":"List files"},"title":"ls -la","toolCallId":"toolu_bash"},"type":"tool_call"},"title":"ls -la"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"background":[],"sessionUpdate":"state_update","state":"running"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"output":{"data":"YS50cwpiLnRz"},"sessionUpdate":"terminal_update","terminalId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"output":{"data":"YS50cw0KYi50cw=="},"sessionUpdate":"terminal_update","terminalId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"exitStatus":{"exitCode":0},"sessionUpdate":"terminal_update","terminalId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"sessionUpdate":"tool_call_update","status":"completed","toolCallId":"toolu_bash"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":{"text":"Do","type":"text"},"messageId":"msg_done","sessionUpdate":"agent_message_chunk"}}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"/goal Ship the feature","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[],"messageId":"00000000-0000-4000-8000-00000000c001","sessionUpdate":"user_message"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":{"text":"Fix the bug","type":"text"},"messageId":"00000000-0000-4000-8000-00000000c001","sessionUpdate":"user_message_chunk"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[],"messageId":"msg_r1","sessionUpdate":"agent_thought"}}}
|
||||
@@ -16,6 +16,7 @@
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"content":{"text":"Report.","type":"text"},"type":"content"}],"rawOutput":"Report.","sessionUpdate":"tool_call_update","status":"completed","toolCallId":"toolu_r_task"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[],"messageId":"msg_r2","sessionUpdate":"agent_message"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":{"text":"Fixed.","type":"text"},"messageId":"msg_r2","sessionUpdate":"agent_message_chunk"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"sessionUpdate":"replay_complete"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"description":"The history of 1 subagent of this session could not be restored.","sessionUpdate":"notice","severity":"info","title":"Some subagent history is not available"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"sessionUpdate":"session_info_update","title":"Fix the app","updatedAt":"2026-01-01T00:00:00.000Z"}}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"background":[],"sessionUpdate":"state_update","state":"idle"}}}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"http":{},"stdio":{}},"prompt":{"embeddedContext":{},"image":{}},"systemPrompt":{"mode":{"override":{}}}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"initialize","payload":{"authMethods":[],"capabilities":{"_meta":{"authStatus":{},"claudeCode":{"promptQueueing":true}},"auth":{"status":{}},"providers":{},"session":{"additionalDirectories":{},"delete":{},"fork":{},"mcp":{"acp":{},"http":{},"stdio":{}},"options":{},"prompt":{"embeddedContext":{},"image":{}},"status":{},"systemPrompt":{"mode":{"override":{}}},"title":{}}},"info":{"name":"@agentclientprotocol/claude-agent-acp","title":"Claude Agent","version":"<version>"},"protocolVersion":2}}
|
||||
{"kind":"response","method":"session/new","payload":{"availableCommands":[{"description":"Show the MCP servers and their status, or reconnect, enable, or disable a server","input":{"hint":"[reconnect|enable|disable [<server>|all]]","type":"text"},"name":"mcp","type":"command"}],"configOptions":[{"category":"mode","configId":"mode","currentValue":"auto","description":"Session permission mode","name":"Mode","options":[{"description":"Always ask before making changes","name":"Manual","value":"default"},{"description":"Automatically accept all file edits","name":"Accept edits","value":"acceptEdits"},{"description":"Create a plan before making changes","name":"Plan","value":"plan"},{"description":"Claude handles permission decisions","name":"Auto","value":"auto"},{"description":"Accepts all permissions","name":"Bypass permissions","value":"bypassPermissions"}],"type":"select"},{"category":"model","configId":"model","currentValue":"claude-sonnet-4-6","description":"AI model to use","name":"Model","options":[{"description":"Fast","name":"Claude Sonnet 4.6","value":"claude-sonnet-4-6"}],"type":"select"}],"sessionId":"<session>"}}
|
||||
{"kind":"notification","method":"session/update","payload":{"sessionId":"<session>","update":{"content":[{"text":"prompt 1","type":"text"}],"messageId":"<id-1>","sessionUpdate":"user_message"}}}
|
||||
{"kind":"response","method":"session/prompt","payload":{"messageId":"<id-1>"}}
|
||||
|
||||
@@ -28,6 +28,20 @@
|
||||
* - The `initialize` response also advertises `agentCapabilities.auth.status`,
|
||||
* which origin/main did not: the agent now answers `auth/status` and sends
|
||||
* `auth/status_update`.
|
||||
* - The `initialize` response also advertises
|
||||
* `agentCapabilities.sessionCapabilities.status`, which origin/main did
|
||||
* not: the agent now serves `session/status`.
|
||||
* - The `initialize` response also advertises
|
||||
* `agentCapabilities.sessionCapabilities.title`, which origin/main did not:
|
||||
* the agent now serves `session/set_title`.
|
||||
* - The `initialize` response also advertises
|
||||
* `agentCapabilities.sessionCapabilities.options`, which origin/main did
|
||||
* not: the agent now serves `session/options` and takes `configOptions` on
|
||||
* session setup requests.
|
||||
* - The `initialize` response also advertises
|
||||
* `agentCapabilities.mcpCapabilities.acp`, which origin/main did not: the
|
||||
* agent now takes MCP servers that the client serves over the ACP
|
||||
* connection (`"type": "acp"`).
|
||||
* - A SandboxNetworkAccess tool call is settled by a `tool_call_update` with
|
||||
* only its final `status` once its permission request is answered. The
|
||||
* callback runs nothing, so origin/main never settled the call (see
|
||||
@@ -229,32 +243,30 @@ function isMeta(key: string): boolean {
|
||||
return key.startsWith("_meta.");
|
||||
}
|
||||
|
||||
/** `record` without the session capability `key`, when it is an `initialize` response. */
|
||||
function withoutSessionCapability(record: Recorded, key: string): Recorded {
|
||||
/** `record` without the session capabilities `keys`, when it is an `initialize` response. */
|
||||
function withoutSessionCapabilities(record: Recorded, keys: readonly string[]): Recorded {
|
||||
if (record.kind !== "initialize") return record;
|
||||
const payload = record.payload as Json;
|
||||
const agent = payload.agentCapabilities as Json | undefined;
|
||||
const session = agent?.sessionCapabilities as Json | undefined;
|
||||
if (!session || !(key in session)) return record;
|
||||
if (!session || !keys.some((key) => key in session)) return record;
|
||||
const remaining = keys.reduce((rest, key) => without(rest, key), session);
|
||||
return {
|
||||
...record,
|
||||
payload: {
|
||||
...payload,
|
||||
agentCapabilities: { ...agent, sessionCapabilities: without(session, key) },
|
||||
},
|
||||
payload: { ...payload, agentCapabilities: { ...agent, sessionCapabilities: remaining } },
|
||||
} as Recorded;
|
||||
}
|
||||
|
||||
/** `record` without `agentCapabilities.auth.status`, when it is an `initialize` response. */
|
||||
function withoutAuthStatusCapability(record: Recorded): Recorded {
|
||||
/** `record` without `agentCapabilities.<group>.<key>`, when it is an `initialize` response. */
|
||||
function withoutAgentCapability(record: Recorded, group: string, key: string): Recorded {
|
||||
if (record.kind !== "initialize") return record;
|
||||
const payload = record.payload as Json;
|
||||
const agent = payload.agentCapabilities as Json | undefined;
|
||||
const auth = agent?.auth as Json | undefined;
|
||||
if (!auth || !("status" in auth)) return record;
|
||||
const capabilities = agent?.[group] as Json | undefined;
|
||||
if (!capabilities || !(key in capabilities)) return record;
|
||||
return {
|
||||
...record,
|
||||
payload: { ...payload, agentCapabilities: { ...agent, auth: without(auth, "status") } },
|
||||
payload: { ...payload, agentCapabilities: { ...agent, [group]: without(capabilities, key) } },
|
||||
} as Recorded;
|
||||
}
|
||||
|
||||
@@ -264,14 +276,24 @@ function withoutAuthStatusCapability(record: Recorded): Recorded {
|
||||
*/
|
||||
export function compareWithBaseline(baseline: Recorded[], traffic: Recorded[]): string[] {
|
||||
const expected = baseline
|
||||
.map((record) => withoutSessionCapability(withoutAirOnlyKeys(record) as Recorded, "subagents"))
|
||||
.map((record) =>
|
||||
withoutSessionCapabilities(withoutAirOnlyKeys(record) as Recorded, ["subagents"]),
|
||||
)
|
||||
.filter((record) => {
|
||||
const update = updateOf(record);
|
||||
return !(update?.sessionUpdate === "session_info_update" && Object.keys(update).length === 1);
|
||||
});
|
||||
const current = withoutSandboxNetworkSettlements(
|
||||
traffic.map((record) =>
|
||||
withoutAuthStatusCapability(withoutSessionCapability(record, "systemPrompt")),
|
||||
withoutAgentCapability(
|
||||
withoutAgentCapability(
|
||||
withoutSessionCapabilities(record, ["systemPrompt", "status", "title", "options"]),
|
||||
"auth",
|
||||
"status",
|
||||
),
|
||||
"mcpCapabilities",
|
||||
"acp",
|
||||
),
|
||||
),
|
||||
);
|
||||
const violations: string[] = [];
|
||||
|
||||
@@ -16,6 +16,25 @@ import {
|
||||
|
||||
const bashInput = { command: "ls -la", description: "List files" };
|
||||
|
||||
/**
|
||||
* The heartbeat of a PreToolUse or PostToolUse hook that runs long, as Claude
|
||||
* Code sends it every 30 seconds since 2.1.323: `tool_name` is the hook
|
||||
* event, and `parent_tool_use_id` is the tool call the hook runs for.
|
||||
*/
|
||||
const hookHeartbeat = (event: "PreToolUse" | "PostToolUse", toolUseId: string, uuid: string) => ({
|
||||
type: "tool_progress",
|
||||
tool_use_id: `hook-${event}-${toolUseId}-heartbeat-0`,
|
||||
tool_name: event,
|
||||
parent_tool_use_id: toolUseId,
|
||||
elapsed_time_seconds: 30,
|
||||
heartbeat: true,
|
||||
uuid,
|
||||
session_id: activeSdkSessionId(),
|
||||
});
|
||||
|
||||
/** Project settings that make ExitPlanMode offer clearing the context. */
|
||||
const CLEAR_CONTEXT_SETTINGS = JSON.stringify({ showClearContextOnPlanAccept: true });
|
||||
|
||||
export const SCENARIOS: Scenario[] = [
|
||||
{
|
||||
name: "session-setup",
|
||||
@@ -947,6 +966,8 @@ export const SCENARIOS: Scenario[] = [
|
||||
},
|
||||
{
|
||||
name: "exit-plan-approve",
|
||||
// Claude Code offers clearing the context only with this setting on.
|
||||
files: { ".claude/settings.json": CLEAR_CONTEXT_SETTINGS },
|
||||
turns: [
|
||||
async function* (ctx) {
|
||||
yield* toolCall(
|
||||
@@ -965,6 +986,8 @@ export const SCENARIOS: Scenario[] = [
|
||||
},
|
||||
{
|
||||
name: "exit-plan-reject",
|
||||
// Claude Code offers clearing the context only with this setting on.
|
||||
files: { ".claude/settings.json": CLEAR_CONTEXT_SETTINGS },
|
||||
permission: "reject_once",
|
||||
turns: [
|
||||
async function* (ctx) {
|
||||
@@ -1118,6 +1141,9 @@ export const SCENARIOS: Scenario[] = [
|
||||
yield* assistantTurn("msg_progress", [
|
||||
{ type: "tool_use", id: "toolu_slow", name: "Bash", input: { command: "make" } },
|
||||
]);
|
||||
// The heartbeats of its hooks report no progress of the tool: the
|
||||
// client gets nothing for them.
|
||||
yield hookHeartbeat("PreToolUse", "toolu_slow", "00000000-0000-4000-8000-00000000b004");
|
||||
for (const seconds of [1, 2, 3]) {
|
||||
yield {
|
||||
type: "tool_progress",
|
||||
@@ -1129,6 +1155,7 @@ export const SCENARIOS: Scenario[] = [
|
||||
session_id: activeSdkSessionId(),
|
||||
};
|
||||
}
|
||||
yield hookHeartbeat("PostToolUse", "toolu_slow", "00000000-0000-4000-8000-00000000b005");
|
||||
yield toolResult("toolu_slow", "built", {
|
||||
structured: { stdout: "built", stderr: "", interrupted: false, isImage: false },
|
||||
});
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import { appendFile, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { query } from "@anthropic-ai/claude-agent-sdk";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
BACKGROUND_OUTPUT_MAX_BACKLOG_BYTES,
|
||||
BACKGROUND_OUTPUT_READ_BYTES,
|
||||
type BackgroundOutput,
|
||||
BackgroundOutputTail,
|
||||
supportsTaskOutput,
|
||||
type TaskOutput,
|
||||
TaskOutputPoll,
|
||||
} from "../background-output.js";
|
||||
|
||||
describe("BackgroundOutputTail", () => {
|
||||
@@ -127,3 +131,129 @@ describe("BackgroundOutputTail", () => {
|
||||
expect(published).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("TaskOutputPoll", () => {
|
||||
let published: BackgroundOutput[];
|
||||
let poll: TaskOutputPoll | undefined;
|
||||
/**
|
||||
* `get_task_output` returning each of `reads` in turn, then the last one
|
||||
* again. An `unanswered` read never returns.
|
||||
*/
|
||||
const follow = (reads: Array<TaskOutput | "unanswered">) => {
|
||||
let next = 0;
|
||||
const read = async () => {
|
||||
const answer = reads[Math.min(next++, reads.length - 1)]!;
|
||||
return answer === "unanswered" ? new Promise<never>(() => {}) : answer;
|
||||
};
|
||||
poll = new TaskOutputPoll(read, async (output) => void published.push(output));
|
||||
return () => next;
|
||||
};
|
||||
const whole = (output: string): TaskOutput => ({
|
||||
output,
|
||||
total_bytes: Buffer.byteLength(output),
|
||||
truncated: false,
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
published = [];
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
poll?.stop();
|
||||
});
|
||||
|
||||
it("appends what the output adds, and reports on finish that it sent text", async () => {
|
||||
follow([whole(""), whole("line1\n"), whole("line1\nline2 ✓\n")]);
|
||||
await vi.waitFor(() => expect(published).toHaveLength(2), { timeout: 3000 });
|
||||
|
||||
expect(await poll!.finish()).toBe(true);
|
||||
expect(published).toEqual([
|
||||
{ text: "line1\n", replaces: false },
|
||||
{ text: "line2 ✓\n", replaces: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
// More was added than the 8 KiB tail holds.
|
||||
[
|
||||
"a tail that misses text",
|
||||
[whole("a\n"), { output: "z\n", total_bytes: 9000, truncated: true }],
|
||||
],
|
||||
// Bytes that are not UTF-8 decode to other bytes.
|
||||
[
|
||||
"an output that is not UTF-8",
|
||||
[whole("a\n"), { output: "a\nb\n", total_bytes: 3, truncated: false }],
|
||||
],
|
||||
])("sends %s as a snapshot", async (_case, reads) => {
|
||||
follow(reads);
|
||||
await vi.waitFor(() => expect(published).toHaveLength(2), { timeout: 3000 });
|
||||
|
||||
expect(published[1]).toEqual({ text: reads[1]!.output, replaces: true });
|
||||
});
|
||||
|
||||
// Claude Code drops a foreground command's output when the command ends:
|
||||
// CLI 2.1.325 then answers `total_bytes: 0` until the tool result comes.
|
||||
it("stops at a read that holds less than was sent, without clearing the terminal", async () => {
|
||||
const reads = follow([whole("line1\n"), whole("")]);
|
||||
await vi.waitFor(() => expect(reads()).toBe(2), { timeout: 3000 });
|
||||
await new Promise((resolve) => setTimeout(resolve, 700));
|
||||
|
||||
expect(reads()).toBe(2);
|
||||
expect(published).toEqual([{ text: "line1\n", replaces: false }]);
|
||||
expect(await poll!.finish()).toBe(true);
|
||||
});
|
||||
|
||||
it("does not wait at finish for a read that Claude Code never answers", async () => {
|
||||
const reads = follow([whole("line1\n"), "unanswered"]);
|
||||
await vi.waitFor(() => expect(reads()).toBe(2), { timeout: 3000 });
|
||||
|
||||
expect(await poll!.finish()).toBe(true);
|
||||
expect(published).toEqual([{ text: "line1\n", replaces: false }]);
|
||||
});
|
||||
|
||||
it("appends from the end of a truncated tail that holds all the new text", async () => {
|
||||
const tail = "x".repeat(8000);
|
||||
follow([
|
||||
{ output: tail, total_bytes: 9000, truncated: true },
|
||||
{ output: tail.slice(3) + "end", total_bytes: 9003, truncated: true },
|
||||
]);
|
||||
await vi.waitFor(() => expect(published).toHaveLength(2), { timeout: 3000 });
|
||||
|
||||
expect(published[1]).toEqual({ text: "end", replaces: false });
|
||||
});
|
||||
|
||||
it("holds a read that ends in a cut character until the character is whole", async () => {
|
||||
const reads = follow([whole("a\uFFFD"), whole("a✓")]);
|
||||
await vi.waitFor(() => expect(reads()).toBeGreaterThan(2), { timeout: 3000 });
|
||||
|
||||
expect(published).toEqual([{ text: "a✓", replaces: false }]);
|
||||
});
|
||||
|
||||
it("reports that it sent nothing when no read added text, and reads nothing after finish", async () => {
|
||||
const reads = follow([whole("")]);
|
||||
expect(await poll!.finish()).toBe(false);
|
||||
await new Promise((resolve) => setTimeout(resolve, 700));
|
||||
expect(reads()).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportsTaskOutput", () => {
|
||||
// The SDK's `Query` type does not declare `getTaskOutput`, so the compiler
|
||||
// does not report an SDK update that drops it, and no poll would start.
|
||||
it("finds getTaskOutput on a query of the installed SDK", () => {
|
||||
// The CLI of this query exits at once: the check reads the query object only.
|
||||
const sdkQuery = query({
|
||||
prompt: "hi",
|
||||
options: { pathToClaudeCodeExecutable: "/usr/bin/false" },
|
||||
});
|
||||
try {
|
||||
expect(supportsTaskOutput(sdkQuery)).toBe(true);
|
||||
} finally {
|
||||
sdkQuery.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("finds none on a query without the method", () => {
|
||||
expect(supportsTaskOutput({ interrupt: async () => {} })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user