@agentclientprotocol/claude-agent-acp 0.85.2-preview.23 → 0.85.2-preview.25

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.
@@ -6,6 +6,8 @@ import { ClaudeAcpAgent, type Logger } from "../acp-agent.js";
6
6
  * As in `v1AgentApp`, the agent of the connection is created when the
7
7
  * connection opens, before the connection processes any inbound message.
8
8
  * `onAgent` receives it for the owner of the process (shutdown).
9
+ *
10
+ * The provider methods pass through: their types are the same in v1 and v2.
9
11
  */
10
12
  export declare function v2AgentApp(logger: Logger | undefined, onAgent: (agent: ClaudeAcpAgent) => void): v2.AgentApp;
11
13
  //# sourceMappingURL=agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAkB,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAiB9E;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GACvC,EAAE,CAAC,QAAQ,CA6Cb"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAkB,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAkB9E;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GACvC,EAAE,CAAC,QAAQ,CA4Db"}
package/dist/v2/agent.js CHANGED
@@ -3,7 +3,7 @@ import { ClaudeAcpAgent } from "../acp-agent.js";
3
3
  import { v1InitializeRequest, v2InitializeResponse } from "./initialize.js";
4
4
  import { v1PermissionResponse, v2PermissionRequest } from "./permission.js";
5
5
  import { v2Prompt } from "./prompt.js";
6
- import { v1NewSessionRequest, v1RestoreSessionRequest, v1SetSessionConfigOptionRequest, v2ConfigOptions, v2NewSessionResponse, v2ResumeSessionResponse, } from "./session.js";
6
+ import { v1ForkSessionRequests, v1NewSessionRequest, v1RestoreSessionRequest, v1SetSessionConfigOptionRequest, v2ConfigOptions, v2NewSessionResponse, v2ResumeSessionResponse, } from "./session.js";
7
7
  import { v2SessionUpdate } from "./session-update.js";
8
8
  import { V2Terminals } from "./terminal.js";
9
9
  /**
@@ -12,6 +12,8 @@ import { V2Terminals } from "./terminal.js";
12
12
  * As in `v1AgentApp`, the agent of the connection is created when the
13
13
  * connection opens, before the connection processes any inbound message.
14
14
  * `onAgent` receives it for the owner of the process (shutdown).
15
+ *
16
+ * The provider methods pass through: their types are the same in v1 and v2.
15
17
  */
16
18
  export function v2AgentApp(logger, onAgent) {
17
19
  let agent;
@@ -26,6 +28,9 @@ export function v2AgentApp(logger, onAgent) {
26
28
  .onRequest(v2.methods.agent.initialize, async ({ params }) => v2InitializeResponse(await agent.initialize(v1InitializeRequest(params))))
27
29
  .onRequest(v2.methods.agent.auth.login, ({ params }) => agent.authenticate(params))
28
30
  .onRequest(v2.methods.agent.auth.logout, ({ params }) => agent.logout(params))
31
+ .onRequest(v2.methods.agent.providers.list, ({ params }) => agent.unstable_listProviders(params))
32
+ .onRequest(v2.methods.agent.providers.set, ({ params }) => agent.unstable_setProvider(params))
33
+ .onRequest(v2.methods.agent.providers.disable, ({ params }) => agent.unstable_disableProvider(params))
29
34
  .onRequest(v2.methods.agent.session.new, async ({ params }) => v2NewSessionResponse(await agent.newSession(v1NewSessionRequest(params))))
30
35
  .onRequest(v2.methods.agent.session.list, ({ params }) => agent.listSessions(params))
31
36
  .onRequest(v2.methods.agent.session.resume, async ({ params }) => {
@@ -33,6 +38,14 @@ export function v2AgentApp(logger, onAgent) {
33
38
  return v2ResumeSessionResponse(restore.method === "resume"
34
39
  ? await agent.resumeSession(restore.request)
35
40
  : await client.replaying(params.sessionId, () => agent.loadSession(restore.request)));
41
+ })
42
+ .onRequest(v2.methods.agent.session.fork, async ({ params }) => {
43
+ const requests = v1ForkSessionRequests(params);
44
+ const { sessionId } = await agent.unstable_forkSession(requests.fork);
45
+ return {
46
+ sessionId,
47
+ ...v2ResumeSessionResponse(await agent.resumeSession(requests.resume(sessionId))),
48
+ };
36
49
  })
37
50
  .onRequest(v2.methods.agent.session.close, async ({ params }) => {
38
51
  const response = await agent.closeSession(params);
@@ -14,8 +14,8 @@ export declare function v1InitializeRequest(request: v2.InitializeRequest): Init
14
14
  /**
15
15
  * The v2 `initialize` response for the v1 response of the agent.
16
16
  *
17
- * It does not advertise what the v2 surface does not serve yet: the unstable
18
- * `providers` methods, and the extensions of {@link UNSERVED_EXTENSION_KEYS}.
17
+ * It does not advertise what the v2 surface does not serve yet: the
18
+ * extensions of {@link UNSERVED_EXTENSION_KEYS}.
19
19
  */
20
20
  export declare function v2InitializeResponse(response: InitializeResponse): v2.InitializeResponse;
21
21
  //# sourceMappingURL=initialize.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/v2/initialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAE/D,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,GAAG,iBAAiB,CA0BpF;AASD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,EAAE,CAAC,kBAAkB,CAoBxF"}
1
+ {"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/v2/initialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAGL,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,0CAA0C,CAAC;AAE/D,0DAA0D;AAC1D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,GAAG,iBAAiB,CA0BpF;AASD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,EAAE,CAAC,kBAAkB,CAuBxF"}
@@ -46,8 +46,8 @@ const UNSERVED_EXTENSION_KEYS = ["steering"];
46
46
  /**
47
47
  * The v2 `initialize` response for the v1 response of the agent.
48
48
  *
49
- * It does not advertise what the v2 surface does not serve yet: the unstable
50
- * `providers` methods, and the extensions of {@link UNSERVED_EXTENSION_KEYS}.
49
+ * It does not advertise what the v2 surface does not serve yet: the
50
+ * extensions of {@link UNSERVED_EXTENSION_KEYS}.
51
51
  */
52
52
  export function v2InitializeResponse(response) {
53
53
  if (!response.agentInfo) {
@@ -62,6 +62,9 @@ export function v2InitializeResponse(response) {
62
62
  // methods must serve `auth/logout`.
63
63
  capabilities: {
64
64
  session: V2_SESSION_CAPABILITIES,
65
+ // `providers/list`, `set`, and `disable`, which the agent serves for
66
+ // every client.
67
+ providers: {},
65
68
  ...(meta != null ? { _meta: meta } : {}),
66
69
  },
67
70
  authMethods: (response.authMethods ?? []).map(v2AuthMethod),
@@ -74,7 +77,8 @@ export function v2InitializeResponse(response) {
74
77
  *
75
78
  * - The session baseline: `session/new`, `list`, `resume` (with replay),
76
79
  * `close`, `prompt`, `cancel`, and `update`.
77
- * - `session/delete` and `additionalDirectories`. Not `session/fork` yet.
80
+ * - `session/delete`, `session/fork` (which returns a session the client can
81
+ * prompt, see `v1ForkSessionRequests`), and `additionalDirectories`.
78
82
  * - The prompt content and MCP transports that the agent's v1 `initialize`
79
83
  * lists: images, embedded context, and HTTP servers. Stdio servers are in the
80
84
  * v1 baseline; v2 has no SSE transport.
@@ -83,6 +87,7 @@ const V2_SESSION_CAPABILITIES = {
83
87
  prompt: { image: {}, embeddedContext: {} },
84
88
  mcp: { stdio: {}, http: {} },
85
89
  delete: {},
90
+ fork: {},
86
91
  additionalDirectories: {},
87
92
  };
88
93
  /** v2 names the id of a method `methodId`, requires `type`, and lists `env` as name and value pairs. */
@@ -3,7 +3,7 @@
3
3
  * `ClaudeAcpAgent`: v2 requests become the v1 requests that the agent serves,
4
4
  * and its v1 responses become v2 responses.
5
5
  */
6
- import { type AvailableCommand, type LoadSessionRequest, type NewSessionRequest, type NewSessionResponse, type ResumeSessionRequest, type ResumeSessionResponse, type SessionConfigOption, type SetSessionConfigOptionRequest } from "@agentclientprotocol/sdk";
6
+ import { type AvailableCommand, type ForkSessionRequest, type LoadSessionRequest, type NewSessionRequest, type NewSessionResponse, type ResumeSessionRequest, type ResumeSessionResponse, type SessionConfigOption, type SetSessionConfigOptionRequest } from "@agentclientprotocol/sdk";
7
7
  import * as v2 from "@agentclientprotocol/sdk/experimental/v2";
8
8
  export declare function v1NewSessionRequest(params: v2.NewSessionRequest): NewSessionRequest;
9
9
  /**
@@ -22,6 +22,20 @@ export declare function v1RestoreSessionRequest(params: v2.ResumeSessionRequest)
22
22
  method: "load";
23
23
  request: LoadSessionRequest;
24
24
  };
25
+ /**
26
+ * The v1 requests that a v2 `session/fork` means.
27
+ *
28
+ * The agent's v1 fork copies the transcript into a new session and returns
29
+ * only its id; a v1 client then resumes or loads it. A v2 fork returns the new
30
+ * session with its config options, like `session/new`, so the client can
31
+ * prompt it. The v2 surface therefore forks, then resumes the fork without
32
+ * replay, with the request's `cwd`, `additionalDirectories`, and
33
+ * `mcpServers`. The request's `_meta` goes to the fork alone.
34
+ */
35
+ export declare function v1ForkSessionRequests(params: v2.ForkSessionRequest): {
36
+ fork: ForkSessionRequest;
37
+ resume: (sessionId: string) => ResumeSessionRequest;
38
+ };
25
39
  /** v2 drops `modes`: the session mode is the `mode` config option, which the agent always lists. */
26
40
  export declare function v2NewSessionResponse(response: NewSessionResponse): v2.NewSessionResponse;
27
41
  export declare function v2ResumeSessionResponse(response: ResumeSessionResponse): v2.ResumeSessionResponse;
@@ -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,EAEvB,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;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,EAAE,CAAC,oBAAoB,GAE7B;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,GACnD;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAkBlD;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,oE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vC,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"}
@@ -35,6 +35,27 @@ export function v1RestoreSessionRequest(params) {
35
35
  request: { ...request, mcpServers: (mcpServers ?? []).map(v1McpServer) },
36
36
  };
37
37
  }
38
+ /**
39
+ * The v1 requests that a v2 `session/fork` means.
40
+ *
41
+ * The agent's v1 fork copies the transcript into a new session and returns
42
+ * only its id; a v1 client then resumes or loads it. A v2 fork returns the new
43
+ * session with its config options, like `session/new`, so the client can
44
+ * prompt it. The v2 surface therefore forks, then resumes the fork without
45
+ * replay, with the request's `cwd`, `additionalDirectories`, and
46
+ * `mcpServers`. The request's `_meta` goes to the fork alone.
47
+ */
48
+ export function v1ForkSessionRequests(params) {
49
+ const { mcpServers, _meta, ...request } = params;
50
+ const session = {
51
+ ...request,
52
+ ...(mcpServers ? { mcpServers: mcpServers.map(v1McpServer) } : {}),
53
+ };
54
+ return {
55
+ fork: { ...session, ...(_meta != null ? { _meta } : {}) },
56
+ resume: (sessionId) => ({ ...session, sessionId }),
57
+ };
58
+ }
38
59
  /** v2 drops `modes`: the session mode is the `mode` config option, which the agent always lists. */
39
60
  export function v2NewSessionResponse(response) {
40
61
  return { sessionId: response.sessionId, ...v2ResumeSessionResponse(response) };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.85.2-preview.23",
6
+ "version": "0.85.2-preview.25",
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",