@agentclientprotocol/claude-agent-acp 0.91.1-preview.3 → 0.91.1-preview.5

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.
@@ -69,9 +69,8 @@ export class V2Terminals {
69
69
  /**
70
70
  * The report without the extension's keys, or undefined when it carried
71
71
  * nothing else but `_meta`: the output report of a command carries the output
72
- * alone, and only the stamps that every report of the tool call repeats. In v2
73
- * a concrete `_meta` replaces the stored one, so sending them would drop the
74
- * other keys that the tool call holds.
72
+ * alone, and only the stamps that every report of the tool call repeats. The
73
+ * client already holds those stamps, so the report goes without them.
75
74
  */
76
75
  function withoutTerminalKeys(report) {
77
76
  if (!report._meta || !TERMINAL_KEYS.some((key) => key in report._meta))
@@ -4,15 +4,17 @@
4
4
  *
5
5
  * The agent gives each v1 tool call report the `_meta` keys of that report.
6
6
  * An AIR client merges them by key (see `ToolCallFieldTracker`), and another
7
- * v1 client reads them per report. A v2 client stores a tool call's `_meta`,
8
- * and a report that carries `_meta` replaces it. So the earlier keys must
9
- * travel again, or the `{ toolName }` of a tool's result would replace, for
10
- * example, the reason of the denial before it.
7
+ * v1 client reads them per report. A v2 client patches its stored `_meta` by
8
+ * top-level key: a key the report leaves out keeps its value, a key set to
9
+ * `null` is removed, and any other value replaces the key whole, nested
10
+ * objects included.
11
11
  *
12
12
  * {@link V2ToolCallMeta} therefore keeps the merged `_meta` of each tool call,
13
13
  * with the `claudeCode` keys merged one by one and every other key replaced
14
- * whole, as `ToolCallFieldTracker` models it. A report that changes it carries
15
- * all of it; a report that changes nothing carries no `_meta`.
14
+ * whole, as `ToolCallFieldTracker` models it. A report carries the top-level
15
+ * keys that changed: all of `claudeCode` when one of its keys changed, since
16
+ * the client does not merge it, and `null` for a key that is gone. A report
17
+ * that changes nothing carries no `_meta`.
16
18
  *
17
19
  * `claudeCode.toolName` repeats the name of the tool, which v2 has a field
18
20
  * for. It becomes the `name` of a tool call that has none yet, and is left out
@@ -24,16 +26,23 @@ export declare class V2ToolCallMeta {
24
26
  /** The stored `_meta` of each tool call, by session and tool call, oldest first. */
25
27
  private readonly calls;
26
28
  /**
27
- * `report` with the tool call's whole `_meta` when the report changes it,
28
- * without `_meta` when it does not, and with `name` when it names the tool
29
- * call for the first time. `starts` says that the report starts the tool
30
- * call (a v1 `tool_call`), which forgets what an earlier one stored.
29
+ * The v2 reports of `report`: the report with the `_meta` keys it changes,
30
+ * without `_meta` when it changes none, and with `name` when it names the
31
+ * tool call for the first time.
32
+ *
33
+ * `starts` says that the report starts the tool call (a v1 `tool_call`),
34
+ * which forgets what an earlier one with the same id stored: the report sets
35
+ * `null` for each of its keys. `replaying` says that the client may hold
36
+ * `_meta` of the tool call from before this connection, for example from an
37
+ * earlier live session. A replayed start of a tool call this connection has
38
+ * not reported then clears it with `_meta: null`, and a second report sets
39
+ * the current keys.
31
40
  */
32
- apply<Report extends ToolCall | ToolCallUpdate>(sessionId: string, report: Report, starts: boolean): Report;
41
+ apply<Report extends ToolCall | ToolCallUpdate>(sessionId: string, report: Report, starts: boolean, replaying?: boolean): [Report] | [Report, ToolCallUpdate];
33
42
  /**
34
43
  * The tool call of a permission request's subject: like {@link apply}, but
35
- * with the tool call's whole `_meta` even when the subject changes nothing,
36
- * since a client can show the request from the request alone.
44
+ * with every stored `_meta` key even when the subject changes nothing, since
45
+ * a client can show the request from the request alone.
37
46
  */
38
47
  subject<Report extends ToolCall | ToolCallUpdate>(sessionId: string, toolCall: Report): Report;
39
48
  /** Forgets the tool calls of a session, when it closes. */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-call-meta.d.ts","sourceRoot":"","sources":["../../src/v2/tool-call-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAOzE,qBAAa,cAAc;IACzB,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqD;IAE3E;;;;;OAKG;IACH,KAAK,CAAC,MAAM,SAAS,QAAQ,GAAG,cAAc,EAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GACd,MAAM;IA6BT;;;;OAIG;IACH,OAAO,CAAC,MAAM,SAAS,QAAQ,GAAG,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAO9F,2DAA2D;IAC3D,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAM/B,0FAA0F;IAC1F,OAAO,CAAC,QAAQ;CAQjB"}
1
+ {"version":3,"file":"tool-call-meta.d.ts","sourceRoot":"","sources":["../../src/v2/tool-call-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAOzE,qBAAa,cAAc;IACzB,oFAAoF;IACpF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqD;IAE3E;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,MAAM,SAAS,QAAQ,GAAG,cAAc,EAC5C,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,EACf,SAAS,UAAQ,GAChB,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC;IA6CtC;;;;OAIG;IACH,OAAO,CAAC,MAAM,SAAS,QAAQ,GAAG,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAO9F,2DAA2D;IAC3D,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAM/B,0FAA0F;IAC1F,OAAO,CAAC,QAAQ;CAQjB"}
@@ -4,14 +4,23 @@ export class V2ToolCallMeta {
4
4
  /** The stored `_meta` of each tool call, by session and tool call, oldest first. */
5
5
  calls = new Map();
6
6
  /**
7
- * `report` with the tool call's whole `_meta` when the report changes it,
8
- * without `_meta` when it does not, and with `name` when it names the tool
9
- * call for the first time. `starts` says that the report starts the tool
10
- * call (a v1 `tool_call`), which forgets what an earlier one stored.
7
+ * The v2 reports of `report`: the report with the `_meta` keys it changes,
8
+ * without `_meta` when it changes none, and with `name` when it names the
9
+ * tool call for the first time.
10
+ *
11
+ * `starts` says that the report starts the tool call (a v1 `tool_call`),
12
+ * which forgets what an earlier one with the same id stored: the report sets
13
+ * `null` for each of its keys. `replaying` says that the client may hold
14
+ * `_meta` of the tool call from before this connection, for example from an
15
+ * earlier live session. A replayed start of a tool call this connection has
16
+ * not reported then clears it with `_meta: null`, and a second report sets
17
+ * the current keys.
11
18
  */
12
- apply(sessionId, report, starts) {
19
+ apply(sessionId, report, starts, replaying = false) {
13
20
  const key = `${sessionId} ${report.toolCallId}`;
14
- const call = (!starts && this.calls.get(key)) || { meta: {}, named: false };
21
+ const previous = this.calls.get(key);
22
+ const held = previous?.meta ?? {};
23
+ const call = (!starts && previous) || { meta: {}, named: false };
15
24
  this.remember(key, call);
16
25
  const { _meta, ...fields } = report;
17
26
  const result = fields;
@@ -25,28 +34,47 @@ export class V2ToolCallMeta {
25
34
  }
26
35
  const meta = { ...call.meta };
27
36
  for (const [name, value] of Object.entries(_meta ?? {})) {
28
- if (name !== "claudeCode")
37
+ if (name === "claudeCode")
38
+ continue;
39
+ // `null` removes the key in v2, so it is not stored.
40
+ if (value === null)
41
+ delete meta[name];
42
+ else
29
43
  meta[name] = value;
30
44
  }
31
45
  if (Object.keys(claudeCode).length > 0) {
32
46
  meta.claudeCode = { ...asRecord(call.meta.claudeCode), ...claudeCode };
33
47
  }
34
- if (JSON.stringify(meta) !== JSON.stringify(call.meta)) {
35
- call.meta = meta;
36
- result._meta = meta;
48
+ call.meta = meta;
49
+ if (starts && replaying && !previous) {
50
+ result._meta = null;
51
+ if (Object.keys(meta).length === 0)
52
+ return [result];
53
+ return [result, { toolCallId: report.toolCallId, _meta: meta }];
37
54
  }
38
- return result;
55
+ const patch = {};
56
+ for (const name of Object.keys(held)) {
57
+ if (!(name in meta))
58
+ patch[name] = null;
59
+ }
60
+ for (const [name, value] of Object.entries(meta)) {
61
+ if (JSON.stringify(value) !== JSON.stringify(held[name]))
62
+ patch[name] = value;
63
+ }
64
+ if (Object.keys(patch).length > 0)
65
+ result._meta = patch;
66
+ return [result];
39
67
  }
40
68
  /**
41
69
  * The tool call of a permission request's subject: like {@link apply}, but
42
- * with the tool call's whole `_meta` even when the subject changes nothing,
43
- * since a client can show the request from the request alone.
70
+ * with every stored `_meta` key even when the subject changes nothing, since
71
+ * a client can show the request from the request alone.
44
72
  */
45
73
  subject(sessionId, toolCall) {
46
- const result = this.apply(sessionId, toolCall, false);
74
+ const [result] = this.apply(sessionId, toolCall, false);
47
75
  const stored = this.calls.get(`${sessionId} ${toolCall.toolCallId}`)?.meta ?? {};
48
- if (result._meta === undefined && Object.keys(stored).length > 0)
49
- result._meta = stored;
76
+ if (Object.keys(stored).length > 0)
77
+ result._meta = { ...result._meta, ...stored };
50
78
  return result;
51
79
  }
52
80
  /** Forgets the tool calls of a session, when it closes. */
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.91.1-preview.3",
6
+ "version": "0.91.1-preview.5",
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,7 +65,7 @@
65
65
  "node": ">=22"
66
66
  },
67
67
  "dependencies": {
68
- "@agentclientprotocol/sdk": "1.8.0",
68
+ "@agentclientprotocol/sdk": "1.9.0",
69
69
  "@anthropic-ai/claude-agent-sdk": "0.3.300",
70
70
  "diff": "9.0.0",
71
71
  "zod": "4.6.7"