@agentclientprotocol/claude-agent-acp 0.85.1 → 0.85.2-preview.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/acp-agent.d.ts +101 -22
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +450 -171
- package/dist/air-extension.d.ts +2 -0
- package/dist/air-extension.d.ts.map +1 -1
- package/dist/air-extension.js +2 -0
- package/dist/mcp-command.d.ts +51 -0
- package/dist/mcp-command.d.ts.map +1 -0
- package/dist/mcp-command.js +321 -0
- package/dist/resumed-session.d.ts +16 -6
- package/dist/resumed-session.d.ts.map +1 -1
- package/dist/resumed-session.js +91 -25
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +1 -2
- package/dist/session-mode.d.ts +14 -0
- package/dist/session-mode.d.ts.map +1 -1
- package/dist/session-mode.js +22 -0
- package/dist/turn-events.d.ts +71 -0
- package/dist/turn-events.d.ts.map +1 -0
- package/dist/turn-events.js +1 -0
- package/dist/usage-markdown.d.ts +2 -0
- package/dist/usage-markdown.d.ts.map +1 -1
- package/dist/usage-markdown.js +2 -1
- package/dist/utils.d.ts +12 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/v2/agent.d.ts +0 -7
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +56 -23
- package/dist/v2/initialize.d.ts.map +1 -1
- package/dist/v2/initialize.js +4 -2
- package/dist/v2/prompt.d.ts +47 -0
- package/dist/v2/prompt.d.ts.map +1 -0
- package/dist/v2/prompt.js +153 -0
- package/dist/v2/session-update.d.ts +15 -0
- package/dist/v2/session-update.d.ts.map +1 -0
- package/dist/v2/session-update.js +41 -0
- package/dist/v2/session.d.ts +23 -0
- package/dist/v2/session.d.ts.map +1 -0
- package/dist/v2/session.js +96 -0
- package/dist/v2/tool-call.d.ts +30 -0
- package/dist/v2/tool-call.d.ts.map +1 -0
- package/dist/v2/tool-call.js +30 -0
- package/package.json +3 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ACP v2 session lifecycle, expressed through the v1 session methods of
|
|
3
|
+
* `ClaudeAcpAgent`: v2 requests become the v1 requests that the agent serves,
|
|
4
|
+
* and its v1 responses become v2 responses.
|
|
5
|
+
*/
|
|
6
|
+
import { type AvailableCommand, type NewSessionRequest, type NewSessionResponse, type ResumeSessionRequest, type ResumeSessionResponse, type SessionConfigOption, type SetSessionConfigOptionRequest } from "@agentclientprotocol/sdk";
|
|
7
|
+
import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
|
|
8
|
+
export declare function v1NewSessionRequest(params: v2.NewSessionRequest): NewSessionRequest;
|
|
9
|
+
/**
|
|
10
|
+
* `replayFrom` is rejected until the v2 surface can translate the replayed
|
|
11
|
+
* history, which needs the message and tool call updates.
|
|
12
|
+
*/
|
|
13
|
+
export declare function v1ResumeSessionRequest(params: v2.ResumeSessionRequest): ResumeSessionRequest;
|
|
14
|
+
/** v2 drops `modes`: the session mode is the `mode` config option, which the agent always lists. */
|
|
15
|
+
export declare function v2NewSessionResponse(response: NewSessionResponse): v2.NewSessionResponse;
|
|
16
|
+
export declare function v2ResumeSessionResponse(response: ResumeSessionResponse): v2.ResumeSessionResponse;
|
|
17
|
+
/** v2 tags a select value with `type: "id"`; v1 leaves it untagged. */
|
|
18
|
+
export declare function v1SetSessionConfigOptionRequest(params: v2.SetSessionConfigOptionRequest): SetSessionConfigOptionRequest;
|
|
19
|
+
/** v2 names the id of an option `configId` and the id of a select group `groupId`. */
|
|
20
|
+
export declare function v2ConfigOptions(options: SessionConfigOption[]): v2.SessionConfigOption[];
|
|
21
|
+
/** v2 tags the free-text input of a command with `type: "text"`. */
|
|
22
|
+
export declare function v2AvailableCommands(commands: AvailableCommand[]): v2.AvailableCommand[];
|
|
23
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/v2/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAGxB,KAAK,6BAA6B,EACnC,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAE/D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,GAAG,iBAAiB,CAInF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAoB,GAAG,oBAAoB,CAS5F;AAED,oGAAoG;AACpG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,EAAE,CAAC,kBAAkB,CAExF;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,EAAE,CAAC,qBAAqB,CAKjG;AAED,uEAAuE;AACvE,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,EAAE,CAAC,6BAA6B,GACvC,6BAA6B,CAgB/B;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAQxF;AAWD,oEAAoE;AACpE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAKvF"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ACP v2 session lifecycle, expressed through the v1 session methods of
|
|
3
|
+
* `ClaudeAcpAgent`: v2 requests become the v1 requests that the agent serves,
|
|
4
|
+
* and its v1 responses become v2 responses.
|
|
5
|
+
*/
|
|
6
|
+
import { RequestError, } from "@agentclientprotocol/sdk";
|
|
7
|
+
import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
|
|
8
|
+
export function v1NewSessionRequest(params) {
|
|
9
|
+
const { mcpServers, ...request } = params;
|
|
10
|
+
// v1 requires the list; v2 treats an omitted list as an empty one.
|
|
11
|
+
return { ...request, mcpServers: (mcpServers ?? []).map(v1McpServer) };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `replayFrom` is rejected until the v2 surface can translate the replayed
|
|
15
|
+
* history, which needs the message and tool call updates.
|
|
16
|
+
*/
|
|
17
|
+
export function v1ResumeSessionRequest(params) {
|
|
18
|
+
const { replayFrom, mcpServers, ...request } = params;
|
|
19
|
+
if (replayFrom != null) {
|
|
20
|
+
throw RequestError.invalidParams({ replayFrom }, "The ACP v2 surface does not replay session history yet");
|
|
21
|
+
}
|
|
22
|
+
return { ...request, ...(mcpServers ? { mcpServers: mcpServers.map(v1McpServer) } : {}) };
|
|
23
|
+
}
|
|
24
|
+
/** v2 drops `modes`: the session mode is the `mode` config option, which the agent always lists. */
|
|
25
|
+
export function v2NewSessionResponse(response) {
|
|
26
|
+
return { sessionId: response.sessionId, ...v2ResumeSessionResponse(response) };
|
|
27
|
+
}
|
|
28
|
+
export function v2ResumeSessionResponse(response) {
|
|
29
|
+
return {
|
|
30
|
+
...v2ConfigOptionsField(response.configOptions),
|
|
31
|
+
...(response._meta != null ? { _meta: response._meta } : {}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** v2 tags a select value with `type: "id"`; v1 leaves it untagged. */
|
|
35
|
+
export function v1SetSessionConfigOptionRequest(params) {
|
|
36
|
+
const request = {
|
|
37
|
+
sessionId: params.sessionId,
|
|
38
|
+
configId: params.configId,
|
|
39
|
+
...(params._meta != null ? { _meta: params._meta } : {}),
|
|
40
|
+
};
|
|
41
|
+
if (v2.SetSessionConfigOptionRequest.isId(params)) {
|
|
42
|
+
return { ...request, value: params.value };
|
|
43
|
+
}
|
|
44
|
+
if (v2.SetSessionConfigOptionRequest.isBoolean(params)) {
|
|
45
|
+
return { ...request, type: "boolean", value: params.value };
|
|
46
|
+
}
|
|
47
|
+
throw RequestError.invalidParams({ type: params.type }, `Config option values of type ${params.type} are not supported`);
|
|
48
|
+
}
|
|
49
|
+
/** v2 names the id of an option `configId` and the id of a select group `groupId`. */
|
|
50
|
+
export function v2ConfigOptions(options) {
|
|
51
|
+
return options.map((option) => {
|
|
52
|
+
const { id, ...rest } = option;
|
|
53
|
+
if (rest.type === "select") {
|
|
54
|
+
return { ...rest, configId: id, options: v2SelectOptions(rest.options) };
|
|
55
|
+
}
|
|
56
|
+
return { ...rest, configId: id };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function v2SelectOptions(options) {
|
|
60
|
+
if (!isGrouped(options))
|
|
61
|
+
return options;
|
|
62
|
+
return options.map(({ group, ...selectGroup }) => ({ ...selectGroup, groupId: group }));
|
|
63
|
+
}
|
|
64
|
+
function isGrouped(options) {
|
|
65
|
+
return options.some((entry) => "group" in entry);
|
|
66
|
+
}
|
|
67
|
+
/** v2 tags the free-text input of a command with `type: "text"`. */
|
|
68
|
+
export function v2AvailableCommands(commands) {
|
|
69
|
+
return commands.map(({ input, ...command }) => ({
|
|
70
|
+
...command,
|
|
71
|
+
...(input != null ? { input: { type: "text", ...input } } : {}),
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
/** v1 responses may send `null`; v2 omits the field instead. */
|
|
75
|
+
function v2ConfigOptionsField(options) {
|
|
76
|
+
return options != null ? { configOptions: v2ConfigOptions(options) } : {};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* v2 requires a `type` on every transport and makes the empty lists optional.
|
|
80
|
+
* The agent recognizes a v1 stdio server by its missing `type`, so the v2 tag
|
|
81
|
+
* is dropped. A transport that v1 cannot express is rejected rather than
|
|
82
|
+
* silently left out of the session.
|
|
83
|
+
*/
|
|
84
|
+
function v1McpServer(server) {
|
|
85
|
+
if (v2.McpServer.isStdio(server)) {
|
|
86
|
+
const { name, command, args, env, _meta } = server;
|
|
87
|
+
return { name, command, args: args ?? [], env: env ?? [], ...(_meta != null ? { _meta } : {}) };
|
|
88
|
+
}
|
|
89
|
+
if (v2.McpServer.isHttp(server)) {
|
|
90
|
+
return { ...server, headers: server.headers ?? [] };
|
|
91
|
+
}
|
|
92
|
+
if (v2.McpServer.isAcp(server)) {
|
|
93
|
+
return server;
|
|
94
|
+
}
|
|
95
|
+
throw RequestError.invalidParams({ type: server.type }, `MCP servers of type ${server.type} are not supported`);
|
|
96
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The v2 form of the tool call reports that `ClaudeAcpAgent` sends as v1
|
|
3
|
+
* `tool_call` and `tool_call_update` updates.
|
|
4
|
+
*/
|
|
5
|
+
import type { ToolCall, ToolCallUpdate } from "@agentclientprotocol/sdk";
|
|
6
|
+
import type * as v2 from "@agentclientprotocol/sdk/experimental/v2";
|
|
7
|
+
type V1ToolCallReport = (ToolCall & {
|
|
8
|
+
sessionUpdate: "tool_call";
|
|
9
|
+
}) | (ToolCallUpdate & {
|
|
10
|
+
sessionUpdate: "tool_call_update";
|
|
11
|
+
});
|
|
12
|
+
type V2ToolCallUpdate = v2.ToolCallUpdate & {
|
|
13
|
+
sessionUpdate: "tool_call_update";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The v2 form of a v1 tool call report.
|
|
17
|
+
*
|
|
18
|
+
* v1 reports a new tool call with `tool_call` and changes it with
|
|
19
|
+
* `tool_call_update`; v2 has one `tool_call_update` that upserts by
|
|
20
|
+
* `toolCallId`. Both leave a field that a report omits unchanged, and both
|
|
21
|
+
* replace `content` and `locations` as whole arrays. They differ on `null`:
|
|
22
|
+
* in v1 it leaves the field unchanged too, in v2 it clears the field, so `null`
|
|
23
|
+
* fields are left out.
|
|
24
|
+
*
|
|
25
|
+
* Diff and terminal content throw until the v2 surface translates them
|
|
26
|
+
* (step 4 of `docs/acp-v2.md`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function v2ToolCallUpdate(report: V1ToolCallReport): V2ToolCallUpdate;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=tool-call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../src/v2/tool-call.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAmB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,KAAK,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAEpE,KAAK,gBAAgB,GACjB,CAAC,QAAQ,GAAG;IAAE,aAAa,EAAE,WAAW,CAAA;CAAE,CAAC,GAC3C,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC;AAE7D,KAAK,gBAAgB,GAAG,EAAE,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAElF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAW3E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The v2 form of a v1 tool call report.
|
|
3
|
+
*
|
|
4
|
+
* v1 reports a new tool call with `tool_call` and changes it with
|
|
5
|
+
* `tool_call_update`; v2 has one `tool_call_update` that upserts by
|
|
6
|
+
* `toolCallId`. Both leave a field that a report omits unchanged, and both
|
|
7
|
+
* replace `content` and `locations` as whole arrays. They differ on `null`:
|
|
8
|
+
* in v1 it leaves the field unchanged too, in v2 it clears the field, so `null`
|
|
9
|
+
* fields are left out.
|
|
10
|
+
*
|
|
11
|
+
* Diff and terminal content throw until the v2 surface translates them
|
|
12
|
+
* (step 4 of `docs/acp-v2.md`).
|
|
13
|
+
*/
|
|
14
|
+
export function v2ToolCallUpdate(report) {
|
|
15
|
+
const patch = Object.fromEntries(Object.entries(report).filter(([key, value]) => value !== null && key !== "sessionUpdate" && key !== "content"));
|
|
16
|
+
return {
|
|
17
|
+
...patch,
|
|
18
|
+
sessionUpdate: "tool_call_update",
|
|
19
|
+
...(report.content != null ? { content: report.content.map(v2ToolCallContent) } : {}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function v2ToolCallContent(item) {
|
|
23
|
+
switch (item.type) {
|
|
24
|
+
case "content":
|
|
25
|
+
// v2 content blocks are a superset of the v1 blocks.
|
|
26
|
+
return item;
|
|
27
|
+
default:
|
|
28
|
+
throw new Error(`The ACP v2 surface does not translate ${item.type} tool call content yet`);
|
|
29
|
+
}
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.85.
|
|
6
|
+
"version": "0.85.2-preview.10",
|
|
7
7
|
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"node": ">=22"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@agentclientprotocol/sdk": "1.
|
|
69
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
68
|
+
"@agentclientprotocol/sdk": "1.7.0",
|
|
69
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.287",
|
|
70
70
|
"diff": "9.0.0",
|
|
71
71
|
"zod": "4.6.5"
|
|
72
72
|
},
|