@agentclientprotocol/claude-agent-acp 0.94.1-preview.1 → 0.94.1-preview.2
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 +7 -4
- package/dist/acp-subagents.d.ts +2 -1
- package/dist/acp-subagents.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/serve.d.ts +19 -11
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +26 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -95,10 +95,13 @@ root session. Clients that use the historical `_meta["subagent-transcript"]` cap
|
|
|
95
95
|
|
|
96
96
|
### Experimental ACP v2
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
The adapter also serves the [draft ACP v2](https://agentclientprotocol.com/protocol/v2/overview):
|
|
99
|
+
a client that asks for protocol version 2 or later in `initialize` gets v2, and every other client
|
|
100
|
+
gets v1. The draft can still change, and this surface changes with it.
|
|
101
|
+
|
|
102
|
+
`CLAUDE_AGENT_ACP_PROTOCOL` limits the adapter to one version. With `v1`, a client that asks
|
|
103
|
+
for v2 is negotiated down to v1. With `v2`, the adapter rejects the `initialize` of a v1 client.
|
|
104
|
+
`auto`, the default, serves both.
|
|
102
105
|
|
|
103
106
|
On v2 the adapter serves the session baseline (`session/new`, `session/list`, `session/resume`
|
|
104
107
|
with replay, `session/close`, `session/prompt`, `session/cancel`), `session/delete`,
|
package/dist/acp-subagents.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export { AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY } from "./air-extension.js";
|
|
|
6
6
|
* - `rfd`: the subagents RFD (agentclientprotocol/agent-client-protocol#1992,
|
|
7
7
|
* as revised): `subagent_update` and `session_message`, which the SDK types.
|
|
8
8
|
* A client that declares `clientCapabilities.subagents` and is not AIR gets
|
|
9
|
-
* it. (ACP v2
|
|
9
|
+
* it. (An ACP v2 client gets it without declaring anything, since subagents
|
|
10
|
+
* are part of v2's baseline.)
|
|
10
11
|
* - `air`: the earlier draft of that RFD, which AIR implements:
|
|
11
12
|
* `subagent_spawned` and `subagent_state_update`, typed below. AIR gets it,
|
|
12
13
|
* whichever capability it declares (`docs/air-extensions.md`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-subagents.d.ts","sourceRoot":"","sources":["../src/acp-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAO3C,OAAO,EAAE,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AAE7E
|
|
1
|
+
{"version":3,"file":"acp-subagents.d.ts","sourceRoot":"","sources":["../src/acp-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,mCAAmC,CAAC;AAO3C,OAAO,EAAE,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC;AAEzC,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,YAAY,GAAG,SAAS,CAG/F;AAED;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,EAAE,kBAAkB,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM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
2
2
|
import { claudeCliPath } from "./acp-agent.js";
|
|
3
3
|
import { applyManagedPolicyEnv } from "./managed-policy.js";
|
|
4
|
-
import { serveAcp } from "./serve.js";
|
|
4
|
+
import { acpProtocolsFromEnv, serveAcp } from "./serve.js";
|
|
5
5
|
import packageJson from "../package.json" with { type: "json" };
|
|
6
6
|
import { appendFileSync, mkdirSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
@@ -78,9 +78,8 @@ else {
|
|
|
78
78
|
})()
|
|
79
79
|
: undefined;
|
|
80
80
|
logger?.log("Claude ACP started");
|
|
81
|
-
// The draft ACP v2 is opt-in while it is a draft.
|
|
82
81
|
const acp = serveAcp(logger, {
|
|
83
|
-
|
|
82
|
+
protocols: acpProtocolsFromEnv(process.env.CLAUDE_AGENT_ACP_PROTOCOL),
|
|
84
83
|
});
|
|
85
84
|
async function shutdown() {
|
|
86
85
|
await acp.dispose().catch((err) => {
|
package/dist/serve.d.ts
CHANGED
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
import * as v2 from "@agentclientprotocol/sdk/experimental/v2
|
|
1
|
+
import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
|
|
2
2
|
import { type ClaudeAcpAgent, type Logger } from "./acp-agent.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* With `experimentalV2`, the connection goes through {@link acpProtocolRouter}.
|
|
7
|
-
* Without it, the adapter serves ACP v1 alone and never routes by protocol
|
|
8
|
-
* version, exactly as before.
|
|
4
|
+
* The ACP versions that the adapter serves: `v1` or `v2` alone, or both with
|
|
5
|
+
* `auto`, where the client's `initialize` picks the version.
|
|
9
6
|
*/
|
|
7
|
+
export type AcpProtocols = "auto" | "v1" | "v2";
|
|
8
|
+
/**
|
|
9
|
+
* Reads `CLAUDE_AGENT_ACP_PROTOCOL`: unset, empty, or `auto` serves both
|
|
10
|
+
* versions, and `v1` or `v2` serves that version alone. Throws on any other
|
|
11
|
+
* value, so that a typo such as `CLAUDE_AGENT_ACP_PROTOCOL=1` fails at startup
|
|
12
|
+
* instead of silently serving both.
|
|
13
|
+
*/
|
|
14
|
+
export declare function acpProtocolsFromEnv(value: string | undefined): AcpProtocols;
|
|
15
|
+
/** Serves ACP on stdio through {@link acpProtocolRouter}. */
|
|
10
16
|
export declare function serveAcp(logger: Logger | undefined, options: {
|
|
11
|
-
|
|
17
|
+
protocols: AcpProtocols;
|
|
12
18
|
}): {
|
|
13
19
|
closed: Promise<void>;
|
|
14
20
|
dispose(): Promise<void>;
|
|
15
21
|
};
|
|
16
22
|
/**
|
|
17
23
|
* Routes a connection to the protocol version that the client negotiates in
|
|
18
|
-
* `initialize
|
|
19
|
-
*
|
|
20
|
-
*
|
|
24
|
+
* `initialize`. With `auto`, a client that requests version 2 or later gets
|
|
25
|
+
* the draft ACP v2, and every other client gets ACP v1. With `v1`, a v2
|
|
26
|
+
* client is negotiated down to v1. With `v2`, the router rejects the
|
|
27
|
+
* `initialize` of a v1 client as an unsupported protocol version. `onAgent`
|
|
28
|
+
* receives the agent of the connection once the router has opened it.
|
|
21
29
|
*/
|
|
22
|
-
export declare function acpProtocolRouter(logger: Logger | undefined, onAgent: (agent: ClaudeAcpAgent) => void): v2.AgentProtocolRouter;
|
|
30
|
+
export declare function acpProtocolRouter(logger: Logger | undefined, onAgent: (agent: ClaudeAcpAgent) => void, protocols?: AcpProtocols): v2.AgentProtocolRouter;
|
|
23
31
|
//# sourceMappingURL=serve.d.ts.map
|
package/dist/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAC/D,OAAO,EAAc,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI9E;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAM3E;AAED,6DAA6D;AAC7D,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE;IAAE,SAAS,EAAE,YAAY,CAAA;CAAE,GACnC;IAAE,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAkBrD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,EACxC,SAAS,GAAE,YAAqB,GAC/B,EAAE,CAAC,mBAAmB,CAKxB"}
|
package/dist/serve.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
1
|
+
import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
|
|
3
2
|
import { v1AgentApp } from "./acp-agent.js";
|
|
4
3
|
import { nodeToWebReadable, nodeToWebWritable } from "./utils.js";
|
|
5
4
|
import { v2AgentApp } from "./v2/agent.js";
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* version, exactly as before.
|
|
6
|
+
* Reads `CLAUDE_AGENT_ACP_PROTOCOL`: unset, empty, or `auto` serves both
|
|
7
|
+
* versions, and `v1` or `v2` serves that version alone. Throws on any other
|
|
8
|
+
* value, so that a typo such as `CLAUDE_AGENT_ACP_PROTOCOL=1` fails at startup
|
|
9
|
+
* instead of silently serving both.
|
|
12
10
|
*/
|
|
11
|
+
export function acpProtocolsFromEnv(value) {
|
|
12
|
+
if (value === undefined || value === "")
|
|
13
|
+
return "auto";
|
|
14
|
+
if (value === "auto" || value === "v1" || value === "v2")
|
|
15
|
+
return value;
|
|
16
|
+
throw new Error(`CLAUDE_AGENT_ACP_PROTOCOL must be "auto", "v1", or "v2", not ${JSON.stringify(value)}`);
|
|
17
|
+
}
|
|
18
|
+
/** Serves ACP on stdio through {@link acpProtocolRouter}. */
|
|
13
19
|
export function serveAcp(logger, options) {
|
|
14
20
|
const output = nodeToWebWritable(process.stdout);
|
|
15
21
|
const input = nodeToWebReadable(process.stdin);
|
|
@@ -19,9 +25,7 @@ export function serveAcp(logger, options) {
|
|
|
19
25
|
const onAgent = (created) => {
|
|
20
26
|
agent = created;
|
|
21
27
|
};
|
|
22
|
-
const { closed } = options.
|
|
23
|
-
? acpProtocolRouter(logger, onAgent).connect(v2.ndJsonStream(output, input))
|
|
24
|
-
: v1AgentApp(logger, onAgent).connect(ndJsonStream(output, input));
|
|
28
|
+
const { closed } = acpProtocolRouter(logger, onAgent, options.protocols).connect(v2.ndJsonStream(output, input));
|
|
25
29
|
return {
|
|
26
30
|
closed,
|
|
27
31
|
dispose: async () => {
|
|
@@ -31,13 +35,17 @@ export function serveAcp(logger, options) {
|
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* Routes a connection to the protocol version that the client negotiates in
|
|
34
|
-
* `initialize
|
|
35
|
-
*
|
|
36
|
-
*
|
|
38
|
+
* `initialize`. With `auto`, a client that requests version 2 or later gets
|
|
39
|
+
* the draft ACP v2, and every other client gets ACP v1. With `v1`, a v2
|
|
40
|
+
* client is negotiated down to v1. With `v2`, the router rejects the
|
|
41
|
+
* `initialize` of a v1 client as an unsupported protocol version. `onAgent`
|
|
42
|
+
* receives the agent of the connection once the router has opened it.
|
|
37
43
|
*/
|
|
38
|
-
export function acpProtocolRouter(logger, onAgent) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.withV1(v1AgentApp(logger, onAgent))
|
|
42
|
-
|
|
44
|
+
export function acpProtocolRouter(logger, onAgent, protocols = "auto") {
|
|
45
|
+
const router = v2.agentProtocolRouter();
|
|
46
|
+
if (protocols !== "v2")
|
|
47
|
+
router.withV1(v1AgentApp(logger, onAgent));
|
|
48
|
+
if (protocols !== "v1")
|
|
49
|
+
router.withV2(v2AgentApp(logger, onAgent));
|
|
50
|
+
return router;
|
|
43
51
|
}
|
package/package.json
CHANGED