@agentclientprotocol/claude-agent-acp 0.99.2-preview.5 → 0.99.2-preview.7
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 +8 -0
- package/dist/acp-agent.d.ts +8 -0
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +68 -10
- package/dist/fork-session.d.ts.map +1 -1
- package/dist/fork-session.js +23 -0
- package/dist/native-subagents.d.ts +49 -3
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +118 -4
- package/dist/session-index/service.d.ts +3 -1
- package/dist/session-index/service.d.ts.map +1 -1
- package/dist/session-index/service.js +5 -10
- package/dist/subagent-history.d.ts +8 -1
- package/dist/subagent-history.d.ts.map +1 -1
- package/dist/subagent-history.js +40 -1
- package/dist/subagent-replay.d.ts +19 -3
- package/dist/subagent-replay.d.ts.map +1 -1
- package/dist/subagent-replay.js +46 -4
- package/dist/v2/initialize.d.ts +16 -1
- package/dist/v2/initialize.d.ts.map +1 -1
- package/dist/v2/initialize.js +26 -3
- package/dist/v2/prompt.d.ts +2 -1
- package/dist/v2/prompt.d.ts.map +1 -1
- package/dist/v2/prompt.js +5 -1
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +21 -9
- package/package.json +1 -1
package/dist/v2/initialize.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { PROTOCOL_VERSION as V1_PROTOCOL_VERSION, } from "@agentclientprotocol/sdk/unstable";
|
|
11
11
|
import * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
12
|
+
import { AIR_ASYNC_TASKS_CAPABILITY, AIR_GOAL_KEY } from "../air-extension.js";
|
|
12
13
|
import { SYSTEM_PROMPT_CAPABILITY } from "../client-system-prompt.js";
|
|
13
14
|
/** The v1 `initialize` request that a v2 client means. */
|
|
14
15
|
export function v1InitializeRequest(request) {
|
|
@@ -57,14 +58,15 @@ const UNSERVED_EXTENSION_KEYS = ["steering"];
|
|
|
57
58
|
* The v2 `initialize` response for the v1 response of the agent.
|
|
58
59
|
*
|
|
59
60
|
* It does not advertise what the v2 surface does not serve yet: the
|
|
60
|
-
* extensions of {@link UNSERVED_EXTENSION_KEYS}
|
|
61
|
+
* extensions of {@link UNSERVED_EXTENSION_KEYS}, and the AIR extensions of
|
|
62
|
+
* {@link withoutUnservedAirExtensions}.
|
|
61
63
|
*/
|
|
62
64
|
export function v2InitializeResponse(response) {
|
|
63
65
|
if (!response.agentInfo) {
|
|
64
66
|
throw new Error("ACP v2 requires agentInfo, and the agent reported none");
|
|
65
67
|
}
|
|
66
68
|
const meta = response.agentCapabilities?._meta;
|
|
67
|
-
const topMeta = Object.fromEntries(Object.entries(response._meta ?? {}).filter(([key]) => !UNSERVED_EXTENSION_KEYS.includes(key)));
|
|
69
|
+
const topMeta = withoutUnservedAirExtensions(Object.fromEntries(Object.entries(response._meta ?? {}).filter(([key]) => !UNSERVED_EXTENSION_KEYS.includes(key))));
|
|
68
70
|
return {
|
|
69
71
|
protocolVersion: v2.PROTOCOL_VERSION,
|
|
70
72
|
info: response.agentInfo,
|
|
@@ -81,6 +83,27 @@ export function v2InitializeResponse(response) {
|
|
|
81
83
|
...(Object.keys(topMeta).length > 0 ? { _meta: topMeta } : {}),
|
|
82
84
|
};
|
|
83
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* `meta` without the AIR extensions whose methods the v2 surface does not
|
|
88
|
+
* register: the `asyncTasks` capability (`_session/async_task/stop`) and the
|
|
89
|
+
* `goal` entry (`_session/goal`) of `_meta.jetbrains.air`.
|
|
90
|
+
*/
|
|
91
|
+
function withoutUnservedAirExtensions(meta) {
|
|
92
|
+
const jetbrains = asRecord(meta.jetbrains);
|
|
93
|
+
const air = asRecord(jetbrains.air);
|
|
94
|
+
if (Object.keys(air).length === 0)
|
|
95
|
+
return meta;
|
|
96
|
+
const served = Object.fromEntries(Object.entries(air).filter(([key]) => key !== AIR_GOAL_KEY));
|
|
97
|
+
if (Array.isArray(served.capabilities)) {
|
|
98
|
+
served.capabilities = served.capabilities.filter((capability) => capability !== AIR_ASYNC_TASKS_CAPABILITY);
|
|
99
|
+
}
|
|
100
|
+
return { ...meta, jetbrains: { ...jetbrains, air: served } };
|
|
101
|
+
}
|
|
102
|
+
function asRecord(value) {
|
|
103
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
104
|
+
? value
|
|
105
|
+
: {};
|
|
106
|
+
}
|
|
84
107
|
/**
|
|
85
108
|
* The session capabilities of the v2 surface, which serves each through a v1
|
|
86
109
|
* method of the agent.
|
|
@@ -94,7 +117,7 @@ export function v2InitializeResponse(response) {
|
|
|
94
117
|
* v1 baseline; v2 has no SSE transport.
|
|
95
118
|
* - `systemPrompt`, in `append` and `override` mode.
|
|
96
119
|
*/
|
|
97
|
-
const V2_SESSION_CAPABILITIES = {
|
|
120
|
+
export const V2_SESSION_CAPABILITIES = {
|
|
98
121
|
prompt: { image: {}, embeddedContext: {} },
|
|
99
122
|
mcp: { stdio: {}, http: {} },
|
|
100
123
|
delete: {},
|
package/dist/v2/prompt.d.ts
CHANGED
|
@@ -51,7 +51,8 @@ export declare function v2Foreground(send: (update: v2.SessionUpdate) => void):
|
|
|
51
51
|
* so such a block fails the request with invalid params (-32602) rather than
|
|
52
52
|
* being dropped from the prompt. The same goes for an embedded blob that
|
|
53
53
|
* Claude cannot read, e.g. an `application/zip` resource: `promptToClaude`
|
|
54
|
-
* would drop it.
|
|
54
|
+
* would drop it. An empty `prompt` fails the same way: v2 requires at least
|
|
55
|
+
* one content block.
|
|
55
56
|
*/
|
|
56
57
|
export declare function v1PromptRequest({ prompt, ...request }: v2.PromptRequest): PromptRequest;
|
|
57
58
|
export declare function v1ContentBlock(block: v2.ContentBlock): ContentBlock;
|
package/dist/v2/prompt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/v2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;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,aAAa,KAAK,IAAI,GAAG,gBAAgB,CAoBvF;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,CAAC,aAAa,GAAG,aAAa,CAqBvF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,GAAG,YAAY,CAcnE"}
|
package/dist/v2/prompt.js
CHANGED
|
@@ -129,9 +129,13 @@ function idle({ stopReason, usage, _meta }) {
|
|
|
129
129
|
* so such a block fails the request with invalid params (-32602) rather than
|
|
130
130
|
* being dropped from the prompt. The same goes for an embedded blob that
|
|
131
131
|
* Claude cannot read, e.g. an `application/zip` resource: `promptToClaude`
|
|
132
|
-
* would drop it.
|
|
132
|
+
* would drop it. An empty `prompt` fails the same way: v2 requires at least
|
|
133
|
+
* one content block.
|
|
133
134
|
*/
|
|
134
135
|
export function v1PromptRequest({ prompt, ...request }) {
|
|
136
|
+
if (prompt.length === 0) {
|
|
137
|
+
throw RequestError.invalidParams({ prompt }, "`prompt` must hold at least one content block");
|
|
138
|
+
}
|
|
135
139
|
return {
|
|
136
140
|
...request,
|
|
137
141
|
prompt: prompt.map((block) => {
|
package/dist/v2/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/v2/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EAGxB,KAAK,6BAA6B,EAEnC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,MAA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Q,EAAE,gBAAgB,EAAE,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAMvF"}
|
package/dist/v2/session.js
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { RequestError, } from "@agentclientprotocol/sdk/unstable";
|
|
7
7
|
import * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
8
|
+
import { V2_SESSION_CAPABILITIES } from "./initialize.js";
|
|
8
9
|
import { v1ContentBlock } from "./prompt.js";
|
|
9
10
|
export function v1NewSessionRequest(params) {
|
|
10
11
|
const { mcpServers, systemPrompt, ...request } = params;
|
|
11
12
|
// v1 requires the list; v2 treats an omitted list as an empty one.
|
|
12
13
|
return {
|
|
13
14
|
...request,
|
|
14
|
-
mcpServers: (mcpServers ?? []
|
|
15
|
+
mcpServers: v1McpServers(mcpServers) ?? [],
|
|
15
16
|
...v1SystemPromptField(systemPrompt),
|
|
16
17
|
};
|
|
17
18
|
}
|
|
@@ -30,15 +31,16 @@ export function v1RestoreSessionRequest(params) {
|
|
|
30
31
|
if (replayFrom == null) {
|
|
31
32
|
return {
|
|
32
33
|
method: "resume",
|
|
33
|
-
request: { ...request, ...(mcpServers ? { mcpServers: mcpServers
|
|
34
|
+
request: { ...request, ...(mcpServers ? { mcpServers: v1McpServers(mcpServers) } : {}) },
|
|
34
35
|
};
|
|
35
36
|
}
|
|
37
|
+
const servers = v1McpServers(mcpServers);
|
|
36
38
|
if (replayFrom.type !== "start") {
|
|
37
39
|
throw RequestError.invalidParams({ replayFrom }, `Replaying from a ${replayFrom.type} cursor is not supported`);
|
|
38
40
|
}
|
|
39
41
|
return {
|
|
40
42
|
method: "load",
|
|
41
|
-
request: { ...request, mcpServers:
|
|
43
|
+
request: { ...request, mcpServers: servers ?? [] },
|
|
42
44
|
};
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
@@ -49,7 +51,7 @@ export function v1ForkSessionRequest(params) {
|
|
|
49
51
|
const { mcpServers, systemPrompt, ...request } = params;
|
|
50
52
|
return {
|
|
51
53
|
...request,
|
|
52
|
-
...(mcpServers ? { mcpServers: mcpServers
|
|
54
|
+
...(mcpServers ? { mcpServers: v1McpServers(mcpServers) } : {}),
|
|
53
55
|
...v1SystemPromptField(systemPrompt),
|
|
54
56
|
};
|
|
55
57
|
}
|
|
@@ -120,13 +122,23 @@ export function v2AvailableCommands(commands) {
|
|
|
120
122
|
function v2ConfigOptionsField(options) {
|
|
121
123
|
return options != null ? { configOptions: v2ConfigOptions(options) } : {};
|
|
122
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* The v1 list of the MCP servers of a v2 setup request, or undefined for no
|
|
127
|
+
* list. A request with two servers of the same `name`, or with a transport
|
|
128
|
+
* that the agent does not advertise in `session.mcp` (such as `acp` or a
|
|
129
|
+
* custom `_` type), fails with invalid params (-32602): the v1 session setup
|
|
130
|
+
* would otherwise drop the server without telling the client.
|
|
131
|
+
*/
|
|
132
|
+
function v1McpServers(servers) {
|
|
133
|
+
if (servers == null)
|
|
134
|
+
return undefined;
|
|
135
|
+
v2.assertSupportedMcpServers(servers, V2_SESSION_CAPABILITIES.mcp);
|
|
136
|
+
return servers.map(v1McpServer);
|
|
137
|
+
}
|
|
123
138
|
/**
|
|
124
139
|
* v2 requires a `type` on every transport and makes the empty lists optional.
|
|
125
140
|
* The agent recognizes a v1 stdio server by its missing `type`, so the v2 tag
|
|
126
|
-
* is dropped.
|
|
127
|
-
* the request with invalid params (-32602): the agent advertises only stdio
|
|
128
|
-
* and HTTP, and the v1 session setup would otherwise drop the server without
|
|
129
|
-
* telling the client.
|
|
141
|
+
* is dropped. {@link v1McpServers} has already rejected every other transport.
|
|
130
142
|
*/
|
|
131
143
|
function v1McpServer(server) {
|
|
132
144
|
if (v2.McpServer.isStdio(server)) {
|
|
@@ -136,5 +148,5 @@ function v1McpServer(server) {
|
|
|
136
148
|
if (v2.McpServer.isHttp(server)) {
|
|
137
149
|
return { ...server, headers: server.headers ?? [] };
|
|
138
150
|
}
|
|
139
|
-
throw
|
|
151
|
+
throw new Error(`Unreachable: MCP server of type ${server.type} passed the transport check`);
|
|
140
152
|
}
|
package/package.json
CHANGED