@lucascouts/claude-agent-acp-plus 0.37.0 → 0.38.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.
- package/dist/acp-agent.d.ts +89 -25
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +391 -173
- package/dist/context-usage.d.ts +65 -0
- package/dist/context-usage.d.ts.map +1 -0
- package/dist/context-usage.js +82 -0
- package/dist/elicitation.d.ts +4 -2
- package/dist/elicitation.d.ts.map +1 -1
- package/dist/retracted-tool-calls.d.ts +41 -0
- package/dist/retracted-tool-calls.d.ts.map +1 -0
- package/dist/retracted-tool-calls.js +75 -0
- package/dist/session-rewind.d.ts +59 -0
- package/dist/session-rewind.d.ts.map +1 -0
- package/dist/session-rewind.js +94 -0
- package/dist/side-question.d.ts +56 -0
- package/dist/side-question.d.ts.map +1 -0
- package/dist/side-question.js +91 -0
- package/dist/task-feed.d.ts +2 -1
- package/dist/task-feed.d.ts.map +1 -1
- package/dist/task-feed.js +9 -2
- package/dist/tool-progress-target.d.ts +30 -0
- package/dist/tool-progress-target.d.ts.map +1 -0
- package/dist/tool-progress-target.js +33 -0
- package/dist/turn-cut.d.ts +23 -0
- package/dist/turn-cut.d.ts.map +1 -0
- package/dist/turn-cut.js +67 -0
- package/package.json +3 -3
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
|
|
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
|
-
|
|
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"}
|
package/dist/turn-cut.js
ADDED
|
@@ -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.
|
|
6
|
+
"version": "0.38.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.
|
|
73
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
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": {
|