@lucascouts/claude-agent-acp-plus 0.37.1 → 0.39.0

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.
@@ -0,0 +1,91 @@
1
+ /**
2
+ * `/btw` — a side question answered without entering the conversation (Zeo
3
+ * proposal §6.8, ask 29).
4
+ *
5
+ * The CLI answers a side question through the `side_question` control request,
6
+ * which the SDK exposes as `Query.askSideQuestion(question, { signal })`. It is
7
+ * on the runtime object but absent from the SDK's published types (0.3.325), so
8
+ * it is feature-detected here and a missing method answers `unsupported`
9
+ * instead of throwing. The answer never enters the session's transcript: the
10
+ * model's history is unchanged, and a reloaded session does not replay it.
11
+ *
12
+ * Two ways in, one implementation: the `_claude/btw` ext method, which Zeo
13
+ * sends at once while a turn runs and renders as a dismissable card, and the
14
+ * `/btw <question>` command typed into any client's composer, answered as an
15
+ * agent message chunk.
16
+ */
17
+ import { RequestError } from "@agentclientprotocol/sdk";
18
+ export const BTW_METHOD = "_claude/btw";
19
+ /** Advertised under `agentCapabilities._meta`; bump on a breaking wire change. */
20
+ export const BTW_CAPABILITY_KEY = "_claude/btw";
21
+ export const BTW_CAPABILITY_VERSION = 1;
22
+ /** Generous for a typed or dictated question; refuses a pasted file. */
23
+ export const BTW_MAX_QUESTION_CHARS = 8000;
24
+ const BTW_COMMAND = /^\/btw(?=\s|$)/;
25
+ /** `/btw <question>` → the question; bare `/btw` → usage; anything else → null.
26
+ * The command token must be the whole first word, at the very start. */
27
+ export function parseBtwInvocation(text) {
28
+ const match = text.match(BTW_COMMAND);
29
+ if (!match)
30
+ return null;
31
+ const question = text.slice(match[0].length).trim();
32
+ return question ? { kind: "ask", question } : { kind: "usage" };
33
+ }
34
+ /** Validate raw JSON-RPC params for `_claude/btw`. */
35
+ export function parseSideQuestionRequest(params) {
36
+ const record = params && typeof params === "object" ? params : undefined;
37
+ const sessionId = record?.sessionId;
38
+ if (typeof sessionId !== "string" || sessionId.length === 0) {
39
+ throw RequestError.invalidParams(undefined, `${BTW_METHOD} params require a non-empty sessionId`);
40
+ }
41
+ const raw = record?.question;
42
+ const question = typeof raw === "string" ? raw.trim() : "";
43
+ if (!question) {
44
+ throw RequestError.invalidParams(undefined, `${BTW_METHOD} params require a non-empty question`);
45
+ }
46
+ if (question.length > BTW_MAX_QUESTION_CHARS) {
47
+ throw RequestError.invalidParams(undefined, `${BTW_METHOD} question must be at most ${BTW_MAX_QUESTION_CHARS} characters`);
48
+ }
49
+ return { sessionId, question };
50
+ }
51
+ /** Ask one side question. Never throws: every outcome is a result. */
52
+ export async function askSideQuestion(query, question, signal) {
53
+ if (typeof query.askSideQuestion !== "function") {
54
+ return { status: "unsupported" };
55
+ }
56
+ try {
57
+ const answer = await query.askSideQuestion(question, { signal });
58
+ if (answer === null || typeof answer?.response !== "string") {
59
+ return { status: "no_answer" };
60
+ }
61
+ const fallbackModel = answer.refusalFallback?.fallbackModel;
62
+ return {
63
+ status: "answered",
64
+ answer: answer.response,
65
+ synthetic: answer.synthetic ?? false,
66
+ ...(fallbackModel ? { fallbackModel } : {}),
67
+ };
68
+ }
69
+ catch (error) {
70
+ return { status: "failed", message: error instanceof Error ? error.message : String(error) };
71
+ }
72
+ }
73
+ export const BTW_USAGE_TEXT = "Usage: `/btw <question>` — ask something on the side. The answer is not added to the conversation.";
74
+ /** Markdown for the `/btw` command typed into a composer. */
75
+ export function formatSideAnswer(result) {
76
+ switch (result.status) {
77
+ case "answered":
78
+ return `**By the way** (not added to the conversation)\n\n${result.answer}`;
79
+ case "no_answer":
80
+ return "The side question got no answer.";
81
+ case "unsupported":
82
+ return "This Claude Code version cannot answer side questions (`/btw`).";
83
+ case "failed":
84
+ return `The side question failed: ${result.message}`;
85
+ default: {
86
+ // Exhaustive: a new status fails to compile here.
87
+ const unknownStatus = result;
88
+ return `The side question ended unexpectedly (${String(unknownStatus)}).`;
89
+ }
90
+ }
91
+ }
@@ -108,7 +108,8 @@ export declare class TaskFeed {
108
108
  private readonly tasks;
109
109
  /** Ended tasks whose final snapshot was sent successfully: never shown again. */
110
110
  private readonly published;
111
- /** Ambient task ids: never shown, and their later messages are not news. */
111
+ /** Ambient task ids that no tool call started: never shown, and their later
112
+ * messages are not news. */
112
113
  private readonly ambient;
113
114
  /** task id → its current life; bumped on every start. */
114
115
  private readonly lives;
@@ -1 +1 @@
1
- {"version":3,"file":"task-feed.d.ts","sourceRoot":"","sources":["../src/task-feed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAElE,2EAA2E;AAC3E,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C;2DAC2D;AAC3D,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,CAAC;AAExF,MAAM,MAAM,SAAS,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK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,QAAQ,CAAC,KAAK,CAA6B;IACnD,6EAA6E;IAC7E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAG1B,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,iBAAiB,EAC5B,MAAM,GAAE,YAA+B,EACvC,UAAU,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAY,EAC1D,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,EACtC,SAAS,SAAK;IAGjC,wFAAwF;IACxF,IAAI,IAAI,IAAI;IAMZ;;;OAGG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBjD,OAAO,IAAI,IAAI;IAKf,OAAO,CAAC,IAAI;YAKE,IAAI;CA0CnB"}
package/dist/task-feed.js CHANGED
@@ -106,7 +106,8 @@ export class TaskFeed {
106
106
  tasks = new Map();
107
107
  /** Ended tasks whose final snapshot was sent successfully: never shown again. */
108
108
  published = new Set();
109
- /** Ambient task ids: never shown, and their later messages are not news. */
109
+ /** Ambient task ids that no tool call started: never shown, and their later
110
+ * messages are not news. */
110
111
  ambient = new Set();
111
112
  /** task id → its current life; bumped on every start. */
112
113
  lives = new Map();
@@ -133,7 +134,13 @@ export class TaskFeed {
133
134
  * for a shell is the command text. Other task types keep the SDK's.
134
135
  */
135
136
  onStarted(msg, toolDescription) {
136
- if (msg.ambient) {
137
+ // Claude Code marks `ambient` its own housekeeping and every live-update
138
+ // watcher, "requested or auto-started" (SDK docs), so a Monitor the model
139
+ // called is ambient too. Upstream #1538's rule: a task a tool call started
140
+ // is work the operator can see and stop (`_claude/tasks/stop`), so it stays;
141
+ // only the ambient tasks Claude Code starts by itself, which name no tool
142
+ // call, are left out.
143
+ if (msg.ambient && !msg.tool_use_id) {
137
144
  this.ambient.add(msg.task_id);
138
145
  return "none";
139
146
  }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The tool call that a `tool_progress` beat reports on, of the calls the client
3
+ * holds (`held`), or undefined for a beat to drop. Ported from upstream
4
+ * claude-agent-acp #1612 (`progressToolCallId`), so the rule lives in one place.
5
+ *
6
+ * Not every beat reports under the id of a call the client has seen: a tool's
7
+ * heartbeat derives `<tool_use_id>-heartbeat-<n>`, and the `agent_api_retry`
8
+ * beats behind `subagentRetry` report under `agent_<assistant_message_id>`.
9
+ * Forwarding those ids leaves the client resolving a call it was never told
10
+ * about (#851). The SDK stamps `parent_tool_use_id` with the id of the executing
11
+ * tool on them, so they go to that call. A beat under the id of a held call
12
+ * keeps it: a subagent's `bash_progress`, whose parent is the Agent call that
13
+ * spawned it.
14
+ *
15
+ * Dropped:
16
+ * - a beat for a call the client does not hold: never announced, or returned
17
+ * (an id leaves `held` at its tool result, so a late beat cannot reopen it);
18
+ * - the heartbeat of a hook that runs long (`hook-<event>-<id>-heartbeat-<n>`,
19
+ * since Claude Code 2.1.323). Its `tool_name` is the hook event and its
20
+ * elapsed time is the hook's. For a PreToolUse or PostToolUse hook its
21
+ * `parent_tool_use_id` is the tool call, which is not running then: sent on,
22
+ * it would mark the call `in_progress`, name it `PreToolUse` and restart its
23
+ * elapsed time. Hooks have no ACP surface, as `hook_started`/`hook_response`
24
+ * already show by being ignored.
25
+ */
26
+ export declare function progressToolCallId(beat: {
27
+ tool_use_id: string;
28
+ parent_tool_use_id: string | null;
29
+ }, held: ReadonlySet<string>): string | undefined;
30
+ //# sourceMappingURL=tool-progress-target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-progress-target.d.ts","sourceRoot":"","sources":["../src/tool-progress-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAChE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GACxB,MAAM,GAAG,SAAS,CAKpB"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The tool call that a `tool_progress` beat reports on, of the calls the client
3
+ * holds (`held`), or undefined for a beat to drop. Ported from upstream
4
+ * claude-agent-acp #1612 (`progressToolCallId`), so the rule lives in one place.
5
+ *
6
+ * Not every beat reports under the id of a call the client has seen: a tool's
7
+ * heartbeat derives `<tool_use_id>-heartbeat-<n>`, and the `agent_api_retry`
8
+ * beats behind `subagentRetry` report under `agent_<assistant_message_id>`.
9
+ * Forwarding those ids leaves the client resolving a call it was never told
10
+ * about (#851). The SDK stamps `parent_tool_use_id` with the id of the executing
11
+ * tool on them, so they go to that call. A beat under the id of a held call
12
+ * keeps it: a subagent's `bash_progress`, whose parent is the Agent call that
13
+ * spawned it.
14
+ *
15
+ * Dropped:
16
+ * - a beat for a call the client does not hold: never announced, or returned
17
+ * (an id leaves `held` at its tool result, so a late beat cannot reopen it);
18
+ * - the heartbeat of a hook that runs long (`hook-<event>-<id>-heartbeat-<n>`,
19
+ * since Claude Code 2.1.323). Its `tool_name` is the hook event and its
20
+ * elapsed time is the hook's. For a PreToolUse or PostToolUse hook its
21
+ * `parent_tool_use_id` is the tool call, which is not running then: sent on,
22
+ * it would mark the call `in_progress`, name it `PreToolUse` and restart its
23
+ * elapsed time. Hooks have no ACP surface, as `hook_started`/`hook_response`
24
+ * already show by being ignored.
25
+ */
26
+ export function progressToolCallId(beat, held) {
27
+ if (held.has(beat.tool_use_id))
28
+ return beat.tool_use_id;
29
+ if (beat.tool_use_id.startsWith("hook-"))
30
+ return undefined;
31
+ const parent = beat.parent_tool_use_id;
32
+ return parent !== null && held.has(parent) ? parent : undefined;
33
+ }
@@ -0,0 +1,23 @@
1
+ import type { SDKMessage } from "@anthropic-ai/claude-agent-sdk";
2
+ /** A transcript row as `getSessionMessages` returns it, read structurally. */
3
+ export type TranscriptRow = SDKMessage;
4
+ export type CutAt = {
5
+ messageId: string;
6
+ } | {
7
+ turn: number;
8
+ };
9
+ export type TurnCut = {
10
+ kind: "cut";
11
+ cutUuid: string;
12
+ nextPromptUuid: string;
13
+ droppedTurns: number;
14
+ } | {
15
+ kind: "nothing_to_cut";
16
+ } | {
17
+ kind: "not_found";
18
+ };
19
+ /** Validate a `CutAt` from client params; `method` names the caller in errors. */
20
+ export declare function parseCutAt(value: unknown, method: string): CutAt;
21
+ /** Resolve a cut point against a session's transcript. */
22
+ export declare function resolveTurnCut(transcript: TranscriptRow[], at: CutAt, messageIdToUuid: ReadonlyMap<string, string>): TurnCut;
23
+ //# sourceMappingURL=turn-cut.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-cut.d.ts","sourceRoot":"","sources":["../src/turn-cut.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAGjE,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC;AAEvC,MAAM,MAAM,KAAK,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAE1B,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAYhE;AAOD,0DAA0D;AAC1D,wBAAgB,cAAc,CAC5B,UAAU,EAAE,aAAa,EAAE,EAC3B,EAAE,EAAE,KAAK,EACT,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3C,OAAO,CA6BT"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Where to cut a conversation "at the end of a turn" — the shared core of
3
+ * fork-from-here and rewind-to-here (Zeo proposal §6.33, asks 55 and 61).
4
+ *
5
+ * A client names the turn to keep either by the ACP `messageId` of one of its
6
+ * agent messages, translated through `Session.messageIdToUuid`, or by its
7
+ * 1-based position among the user's prompts. Either way the cut is the LAST
8
+ * transcript entry before the next prompt, never the named message itself:
9
+ * the SDK's guidance for a fork point is the kept turn's last chain entry
10
+ * (`resumeDropsTurn` in the SDK types), so a tool result or a final reply after
11
+ * the named message stays with its turn.
12
+ *
13
+ * What counts as a prompt is `/rewind`'s rule (`listCheckpoints`): a top-level
14
+ * user row that is not a tool result or a local-command marker and has text. A
15
+ * prompt holding only an image therefore does not start a turn here.
16
+ */
17
+ import { RequestError } from "@agentclientprotocol/sdk";
18
+ import { listCheckpoints } from "./rewind-command.js";
19
+ /** Validate a `CutAt` from client params; `method` names the caller in errors. */
20
+ export function parseCutAt(value, method) {
21
+ const record = value && typeof value === "object" ? value : null;
22
+ if (record && typeof record.messageId === "string" && record.messageId.length > 0) {
23
+ return { messageId: record.messageId };
24
+ }
25
+ if (record && Number.isInteger(record.turn) && record.turn >= 1) {
26
+ return { turn: record.turn };
27
+ }
28
+ throw RequestError.invalidParams(undefined, `${method} needs a cut point: {messageId} or {turn}, a positive integer`);
29
+ }
30
+ function rowUuid(row) {
31
+ const uuid = row.uuid;
32
+ return typeof uuid === "string" && uuid.length > 0 ? uuid : undefined;
33
+ }
34
+ /** Resolve a cut point against a session's transcript. */
35
+ export function resolveTurnCut(transcript, at, messageIdToUuid) {
36
+ // listCheckpoints answers most recent first; turns are counted forwards.
37
+ const promptUuids = listCheckpoints(transcript)
38
+ .map((checkpoint) => checkpoint.uuid)
39
+ .reverse();
40
+ const promptIndexes = promptUuids.map((uuid) => transcript.findIndex((r) => rowUuid(r) === uuid));
41
+ // The index of the first prompt that starts a dropped turn.
42
+ let firstDropped;
43
+ if ("turn" in at) {
44
+ firstDropped = at.turn;
45
+ }
46
+ else {
47
+ const uuid = messageIdToUuid.get(at.messageId);
48
+ const atIndex = uuid === undefined ? -1 : transcript.findIndex((r) => rowUuid(r) === uuid);
49
+ if (atIndex < 0)
50
+ return { kind: "not_found" };
51
+ firstDropped = promptIndexes.findIndex((index) => index > atIndex);
52
+ if (firstDropped < 0)
53
+ return { kind: "nothing_to_cut" };
54
+ }
55
+ if (firstDropped >= promptIndexes.length)
56
+ return { kind: "nothing_to_cut" };
57
+ const nextPromptIndex = promptIndexes[firstDropped];
58
+ const cutUuid = nextPromptIndex > 0 ? rowUuid(transcript[nextPromptIndex - 1]) : undefined;
59
+ if (cutUuid === undefined)
60
+ return { kind: "nothing_to_cut" };
61
+ return {
62
+ kind: "cut",
63
+ cutUuid,
64
+ nextPromptUuid: promptUuids[firstDropped],
65
+ droppedTurns: promptIndexes.length - firstDropped,
66
+ };
67
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.37.1",
6
+ "version": "0.39.0",
7
7
  "description": "Claude Code in Zed and other ACP clients with the VS Code extension's UX — multi-select questions, refusal consent, live quota windows, background tasks, Ultracode effort and session notices. Fork of claude-agent-acp.",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",
@@ -69,8 +69,8 @@
69
69
  "node": ">=24"
70
70
  },
71
71
  "dependencies": {
72
- "@agentclientprotocol/sdk": "2.4.0",
73
- "@anthropic-ai/claude-agent-sdk": "0.3.319",
72
+ "@agentclientprotocol/sdk": "2.6.0",
73
+ "@anthropic-ai/claude-agent-sdk": "0.3.325",
74
74
  "zod": "^4.0.0"
75
75
  },
76
76
  "devDependencies": {