@agentclientprotocol/claude-agent-acp 0.102.0 → 0.102.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 +5 -1
- package/dist/acp-agent.d.ts +119 -439
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +380 -2412
- package/dist/acp-subagents.d.ts +1 -2
- package/dist/acp-subagents.d.ts.map +1 -1
- package/dist/auth-methods.d.ts +21 -0
- package/dist/auth-methods.d.ts.map +1 -0
- package/dist/auth-methods.js +68 -0
- package/dist/auth-status-reporter.d.ts +112 -0
- package/dist/auth-status-reporter.d.ts.map +1 -0
- package/dist/auth-status-reporter.js +253 -0
- package/dist/background-work.d.ts +12 -265
- package/dist/background-work.d.ts.map +1 -1
- package/dist/background-work.js +8 -558
- package/dist/client-system-prompt.d.ts +7 -0
- package/dist/client-system-prompt.d.ts.map +1 -1
- package/dist/client-system-prompt.js +24 -0
- package/dist/context-compaction.d.ts +20 -0
- package/dist/context-compaction.d.ts.map +1 -1
- package/dist/context-compaction.js +26 -0
- package/dist/context-window.d.ts +70 -0
- package/dist/context-window.d.ts.map +1 -0
- package/dist/context-window.js +132 -0
- package/dist/diff.d.ts +1 -1
- package/dist/diff.js +1 -1
- package/dist/elicitation.d.ts +66 -1
- package/dist/elicitation.d.ts.map +1 -1
- package/dist/elicitation.js +109 -0
- package/dist/file-change-audit.d.ts +4 -3
- package/dist/file-change-audit.d.ts.map +1 -1
- package/dist/file-change-audit.js +3 -2
- package/dist/mcp-oauth.d.ts +44 -0
- package/dist/mcp-oauth.d.ts.map +1 -0
- package/dist/mcp-oauth.js +142 -0
- package/dist/mcp-servers.d.ts +10 -0
- package/dist/mcp-servers.d.ts.map +1 -0
- package/dist/mcp-servers.js +29 -0
- package/dist/native-subagents.d.ts +18 -8
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +7 -35
- package/dist/permissions/presentation.d.ts +29 -0
- package/dist/permissions/presentation.d.ts.map +1 -1
- package/dist/permissions/presentation.js +38 -11
- package/dist/plans.d.ts +36 -6
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +49 -11
- package/dist/prompt-suggestions.d.ts +29 -0
- package/dist/prompt-suggestions.d.ts.map +1 -1
- package/dist/prompt-suggestions.js +45 -0
- package/dist/providers.d.ts +139 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +286 -0
- package/dist/remote-control.d.ts +62 -0
- package/dist/remote-control.d.ts.map +1 -0
- package/dist/remote-control.js +78 -0
- package/dist/result-end.d.ts +39 -0
- package/dist/result-end.d.ts.map +1 -0
- package/dist/result-end.js +50 -0
- package/dist/serve.d.ts +7 -2
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +10 -5
- package/dist/session-config-ids.d.ts +1 -0
- package/dist/session-config-ids.d.ts.map +1 -1
- package/dist/session-config-ids.js +1 -0
- package/dist/session-config-options.d.ts +64 -0
- package/dist/session-config-options.d.ts.map +1 -0
- package/dist/session-config-options.js +162 -0
- package/dist/session-effort.d.ts +67 -0
- package/dist/session-effort.d.ts.map +1 -1
- package/dist/session-effort.js +98 -0
- package/dist/session-env.d.ts +22 -0
- package/dist/session-env.d.ts.map +1 -0
- package/dist/session-env.js +66 -0
- package/dist/session-fast-mode.d.ts +83 -0
- package/dist/session-fast-mode.d.ts.map +1 -0
- package/dist/session-fast-mode.js +142 -0
- package/dist/session-index/connection.d.ts +2 -5
- package/dist/session-index/connection.d.ts.map +1 -1
- package/dist/session-index/connection.js +3 -5
- package/dist/session-mode.d.ts +1 -0
- package/dist/session-mode.d.ts.map +1 -1
- package/dist/session-mode.js +1 -1
- package/dist/session-model.d.ts +41 -0
- package/dist/session-model.d.ts.map +1 -1
- package/dist/session-model.js +110 -45
- package/dist/session-notices.d.ts +44 -0
- package/dist/session-notices.d.ts.map +1 -1
- package/dist/session-notices.js +68 -0
- package/dist/session-titles.d.ts +34 -12
- package/dist/session-titles.d.ts.map +1 -1
- package/dist/session-titles.js +7 -6
- package/dist/session-usage.d.ts +125 -0
- package/dist/session-usage.d.ts.map +1 -0
- package/dist/session-usage.js +196 -0
- package/dist/streamed-text.d.ts +33 -0
- package/dist/streamed-text.d.ts.map +1 -0
- package/dist/streamed-text.js +71 -0
- package/dist/subagent-configuration.d.ts +32 -0
- package/dist/subagent-configuration.d.ts.map +1 -0
- package/dist/subagent-configuration.js +70 -0
- package/dist/subagent-replay.d.ts +18 -0
- package/dist/subagent-replay.d.ts.map +1 -1
- package/dist/subagent-replay.js +25 -15
- package/dist/tool-calls/client-capabilities.d.ts +8 -8
- package/dist/tool-calls/client-capabilities.js +4 -4
- package/dist/tool-calls/renderer.d.ts +4 -5
- package/dist/tool-calls/renderer.d.ts.map +1 -1
- package/dist/tool-calls/renderer.js +4 -5
- package/dist/turn-events.d.ts +6 -46
- package/dist/turn-events.d.ts.map +1 -1
- package/dist/v2/agent.d.ts +7 -11
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +751 -331
- package/dist/v2/air.d.ts +33 -0
- package/dist/v2/air.d.ts.map +1 -0
- package/dist/v2/air.js +29 -0
- package/dist/v2/auth.d.ts +97 -0
- package/dist/v2/auth.d.ts.map +1 -0
- package/dist/v2/auth.js +216 -0
- package/dist/v2/background.d.ts +27 -16
- package/dist/v2/background.d.ts.map +1 -1
- package/dist/v2/background.js +4 -32
- package/dist/v2/child-config.d.ts +55 -0
- package/dist/v2/child-config.d.ts.map +1 -0
- package/dist/v2/child-config.js +92 -0
- package/dist/v2/clear-context.d.ts +94 -0
- package/dist/v2/clear-context.d.ts.map +1 -0
- package/dist/v2/clear-context.js +176 -0
- package/dist/v2/commands.d.ts +46 -0
- package/dist/v2/commands.d.ts.map +1 -0
- package/dist/v2/commands.js +54 -0
- package/dist/v2/config.d.ts +187 -0
- package/dist/v2/config.d.ts.map +1 -0
- package/dist/v2/config.js +494 -0
- package/dist/v2/elicitation.d.ts +93 -0
- package/dist/v2/elicitation.d.ts.map +1 -0
- package/dist/v2/elicitation.js +160 -0
- package/dist/v2/file-changes.d.ts +61 -0
- package/dist/v2/file-changes.d.ts.map +1 -0
- package/dist/v2/file-changes.js +108 -0
- package/dist/v2/file-preview.d.ts +18 -0
- package/dist/v2/file-preview.d.ts.map +1 -0
- package/dist/v2/file-preview.js +29 -0
- package/dist/v2/initialize.d.ts +10 -24
- package/dist/v2/initialize.d.ts.map +1 -1
- package/dist/v2/initialize.js +4 -111
- package/dist/v2/outcome.d.ts +81 -0
- package/dist/v2/outcome.d.ts.map +1 -0
- package/dist/v2/outcome.js +165 -0
- package/dist/v2/permissions.d.ts +92 -0
- package/dist/v2/permissions.d.ts.map +1 -0
- package/dist/v2/permissions.js +162 -0
- package/dist/v2/prompt.d.ts +2 -42
- package/dist/v2/prompt.d.ts.map +1 -1
- package/dist/v2/prompt.js +2 -119
- package/dist/v2/remote-control.d.ts +41 -0
- package/dist/v2/remote-control.d.ts.map +1 -0
- package/dist/v2/remote-control.js +63 -0
- package/dist/v2/reports.d.ts +198 -0
- package/dist/v2/reports.d.ts.map +1 -0
- package/dist/v2/reports.js +487 -0
- package/dist/v2/restarts.d.ts +128 -0
- package/dist/v2/restarts.d.ts.map +1 -0
- package/dist/v2/restarts.js +348 -0
- package/dist/v2/session-requests.d.ts +20 -0
- package/dist/v2/session-requests.d.ts.map +1 -0
- package/dist/v2/session-requests.js +108 -0
- package/dist/v2/session-update.d.ts +2 -13
- package/dist/v2/session-update.d.ts.map +1 -1
- package/dist/v2/session-update.js +2 -22
- package/dist/v2/session.d.ts +340 -41
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +1223 -141
- package/dist/v2/setup.d.ts +49 -0
- package/dist/v2/setup.d.ts.map +1 -0
- package/dist/v2/setup.js +62 -0
- package/dist/v2/stopped-work.d.ts +123 -0
- package/dist/v2/stopped-work.d.ts.map +1 -0
- package/dist/v2/stopped-work.js +210 -0
- package/dist/v2/stream.d.ts +228 -0
- package/dist/v2/stream.d.ts.map +1 -0
- package/dist/v2/stream.js +506 -0
- package/dist/v2/subagent-replay.d.ts +115 -0
- package/dist/v2/subagent-replay.d.ts.map +1 -0
- package/dist/v2/subagent-replay.js +479 -0
- package/dist/v2/subscription-guard.d.ts +60 -0
- package/dist/v2/subscription-guard.d.ts.map +1 -0
- package/dist/v2/subscription-guard.js +84 -0
- package/dist/v2/tasks.d.ts +492 -0
- package/dist/v2/tasks.d.ts.map +1 -0
- package/dist/v2/tasks.js +1728 -0
- package/dist/v2/terminal.d.ts.map +1 -1
- package/dist/v2/terminal.js +6 -1
- package/dist/v2/tool-call.d.ts +3 -2
- package/dist/v2/tool-call.d.ts.map +1 -1
- package/dist/v2/update-translator.d.ts +36 -0
- package/dist/v2/update-translator.d.ts.map +1 -0
- package/dist/v2/update-translator.js +80 -0
- package/dist/workflow-progress.d.ts +23 -0
- package/dist/workflow-progress.d.ts.map +1 -1
- package/dist/workflow-progress.js +31 -8
- package/package.json +1 -1
- package/dist/v2/permission.d.ts +0 -28
- package/dist/v2/permission.d.ts.map +0 -1
- package/dist/v2/permission.js +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/v2/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAE7E,KAAK,gBAAgB,GACjB,CAAC,QAAQ,GAAG;IAAE,aAAa,EAAE,WAAW,CAAA;CAAE,CAAC,GAC3C,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC;AAiB7D,0EAA0E;AAC1E,qBAAa,WAAW;IACtB,oGAAoG;IACpG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGpB;IAEJ;;;;;;;;OAQG;IACH,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,GACvB;QAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC;QAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAA;KAAE;
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/v2/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAE7E,KAAK,gBAAgB,GACjB,CAAC,QAAQ,GAAG;IAAE,aAAa,EAAE,WAAW,CAAA;CAAE,CAAC,GAC3C,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC;AAiB7D,0EAA0E;AAC1E,qBAAa,WAAW;IACtB,oGAAoG;IACpG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGpB;IAEJ;;;;;;;;OAQG;IACH,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,gBAAgB,GACvB;QAAE,QAAQ,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC;QAAC,MAAM,EAAE,gBAAgB,GAAG,SAAS,CAAA;KAAE;IAiDzE;;;;;;OAMG;IACH,eAAe,CACb,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,UAAQ,GACZ,EAAE,CAAC,aAAa,GAAG,SAAS;IAa/B,0CAA0C;IAC1C,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAKhC"}
|
package/dist/v2/terminal.js
CHANGED
|
@@ -20,8 +20,13 @@ export class V2Terminals {
|
|
|
20
20
|
split(sessionId, report) {
|
|
21
21
|
const meta = (report._meta ?? {});
|
|
22
22
|
const key = `${sessionId} ${report.toolCallId}`;
|
|
23
|
-
|
|
23
|
+
// A replay of a command that still runs, such as one in the background,
|
|
24
|
+
// names its terminal again: the running entry keeps its command and
|
|
25
|
+
// `cancellable`.
|
|
26
|
+
if (meta.terminal_info &&
|
|
27
|
+
this.running.get(key)?.terminalId !== meta.terminal_info.terminal_id) {
|
|
24
28
|
this.running.set(key, { terminalId: meta.terminal_info.terminal_id });
|
|
29
|
+
}
|
|
25
30
|
const terminal = [];
|
|
26
31
|
const running = this.running.get(key);
|
|
27
32
|
if (running) {
|
package/dist/v2/tool-call.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The v2 form of the tool call reports that
|
|
3
|
-
* `tool_call` and `tool_call_update` updates, and
|
|
2
|
+
* The v2 form of the tool call reports that the shared SDK-to-ACP mapping
|
|
3
|
+
* produces as v1 `tool_call` and `tool_call_update` updates, and of the tool
|
|
4
|
+
* calls of permission requests.
|
|
4
5
|
*/
|
|
5
6
|
import type { ToolCall, ToolCallUpdate } from "@agentclientprotocol/sdk/unstable";
|
|
6
7
|
import type * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../src/v2/tool-call.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tool-call.d.ts","sourceRoot":"","sources":["../../src/v2/tool-call.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAmB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAE7E,KAAK,gBAAgB,GACjB,CAAC,QAAQ,GAAG;IAAE,aAAa,EAAE,WAAW,CAAA;CAAE,CAAC,GAC3C,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAAC;AAE7D,KAAK,gBAAgB,GAAG,EAAE,CAAC,cAAc,GAAG;IAAE,aAAa,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAElF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAE3E;AAcD;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAM9E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,EAAE,CAAC,cAAc,CAUtF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns the v1 session updates that the shared SDK-to-ACP mapping produces
|
|
3
|
+
* (`toAcpNotifications`) into the v2 updates of one connection.
|
|
4
|
+
*
|
|
5
|
+
* The v2 core uses it for every update that it maps from
|
|
6
|
+
* the SDK stream. It holds the per-connection state that the translation
|
|
7
|
+
* needs: the display terminals of commands and the `_meta` the client stores
|
|
8
|
+
* for each tool call.
|
|
9
|
+
*/
|
|
10
|
+
import type * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
11
|
+
import type { AcpSessionNotification } from "../acp-subagents.js";
|
|
12
|
+
import { V2Terminals } from "./terminal.js";
|
|
13
|
+
import { V2ToolCallMeta } from "./tool-call-meta.js";
|
|
14
|
+
export declare class V2UpdateTranslator {
|
|
15
|
+
/** The display terminals of the commands that the agent runs. */
|
|
16
|
+
readonly terminals: V2Terminals;
|
|
17
|
+
/** The `_meta` that the client stores for each tool call. */
|
|
18
|
+
readonly toolCallMeta: V2ToolCallMeta;
|
|
19
|
+
/**
|
|
20
|
+
* The v2 updates of a v1 update: for a tool call report, the updates of its
|
|
21
|
+
* terminal first (see {@link V2Terminals}), then the report itself, with the
|
|
22
|
+
* `_meta` keys that it changes (see {@link V2ToolCallMeta}), and during a
|
|
23
|
+
* replay the `_meta` of a tool call that the report cleared.
|
|
24
|
+
*/
|
|
25
|
+
updates(sessionId: string, update: AcpSessionNotification["update"], replaying?: boolean): v2.SessionUpdate[];
|
|
26
|
+
/** Forgets the terminals and tool calls of a session, when it closes. */
|
|
27
|
+
forget(sessionId: string): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The update that clears the message of a replayed chunk, when it is the
|
|
31
|
+
* first replayed chunk of that message: a v2 client may still hold a message
|
|
32
|
+
* that a replay sends again, and chunks append to it. `cleared` holds the
|
|
33
|
+
* messages that the replay has cleared so far, and gains this one.
|
|
34
|
+
*/
|
|
35
|
+
export declare function replayClear(cleared: Set<string>, update: v2.SessionUpdate): v2.SessionUpdate | undefined;
|
|
36
|
+
//# sourceMappingURL=update-translator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-translator.d.ts","sourceRoot":"","sources":["../../src/v2/update-translator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,qBAAa,kBAAkB;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,SAAS,cAAqB;IAEvC,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,iBAAwB;IAE7C;;;;;OAKG;IACH,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,sBAAsB,CAAC,QAAQ,CAAC,EACxC,SAAS,UAAQ,GAChB,EAAE,CAAC,aAAa,EAAE;IA0BrB,yEAAyE;IACzE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAIhC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,MAAM,EAAE,EAAE,CAAC,aAAa,GACvB,EAAE,CAAC,aAAa,GAAG,SAAS,CAQ9B"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { v2SessionUpdate } from "./session-update.js";
|
|
2
|
+
import { V2Terminals } from "./terminal.js";
|
|
3
|
+
import { V2ToolCallMeta } from "./tool-call-meta.js";
|
|
4
|
+
import { v2RestartedToolCall } from "./tool-call.js";
|
|
5
|
+
export class V2UpdateTranslator {
|
|
6
|
+
/** The display terminals of the commands that the agent runs. */
|
|
7
|
+
terminals = new V2Terminals();
|
|
8
|
+
/** The `_meta` that the client stores for each tool call. */
|
|
9
|
+
toolCallMeta = new V2ToolCallMeta();
|
|
10
|
+
/**
|
|
11
|
+
* The v2 updates of a v1 update: for a tool call report, the updates of its
|
|
12
|
+
* terminal first (see {@link V2Terminals}), then the report itself, with the
|
|
13
|
+
* `_meta` keys that it changes (see {@link V2ToolCallMeta}), and during a
|
|
14
|
+
* replay the `_meta` of a tool call that the report cleared.
|
|
15
|
+
*/
|
|
16
|
+
updates(sessionId, update, replaying = false) {
|
|
17
|
+
if (update.sessionUpdate !== "tool_call" && update.sessionUpdate !== "tool_call_update") {
|
|
18
|
+
const v2Update = v2SessionUpdate(update);
|
|
19
|
+
return v2Update ? [v2Update] : [];
|
|
20
|
+
}
|
|
21
|
+
const { terminal, report } = this.terminals.split(sessionId, update);
|
|
22
|
+
if (!report)
|
|
23
|
+
return terminal;
|
|
24
|
+
const starts = report.sessionUpdate === "tool_call";
|
|
25
|
+
// A v1 `tool_call` starts the tool call afresh, but v2 only has updates,
|
|
26
|
+
// which keep each field they leave out. The client may already hold this
|
|
27
|
+
// id: from an earlier report on this connection, or, during a replay, from
|
|
28
|
+
// before it (a client that resumes a session it showed before).
|
|
29
|
+
const restarts = starts && (replaying || this.toolCallMeta.reported(sessionId, report.toolCallId));
|
|
30
|
+
const [reported, metaPatch] = this.toolCallMeta.apply(sessionId, report, starts, replaying);
|
|
31
|
+
const reportUpdate = restarts ? v2RestartedToolCall(reported) : v2SessionUpdate(reported);
|
|
32
|
+
const metaUpdate = metaPatch
|
|
33
|
+
? v2SessionUpdate({ sessionUpdate: "tool_call_update", ...metaPatch })
|
|
34
|
+
: undefined;
|
|
35
|
+
return [
|
|
36
|
+
...terminal,
|
|
37
|
+
...(reportUpdate ? [reportUpdate] : []),
|
|
38
|
+
...(metaUpdate ? [metaUpdate] : []),
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
/** Forgets the terminals and tool calls of a session, when it closes. */
|
|
42
|
+
forget(sessionId) {
|
|
43
|
+
this.terminals.forget(sessionId);
|
|
44
|
+
this.toolCallMeta.forget(sessionId);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The update that clears the message of a replayed chunk, when it is the
|
|
49
|
+
* first replayed chunk of that message: a v2 client may still hold a message
|
|
50
|
+
* that a replay sends again, and chunks append to it. `cleared` holds the
|
|
51
|
+
* messages that the replay has cleared so far, and gains this one.
|
|
52
|
+
*/
|
|
53
|
+
export function replayClear(cleared, update) {
|
|
54
|
+
const kind = MESSAGE_OF_CHUNK.get(update.sessionUpdate);
|
|
55
|
+
if (!kind)
|
|
56
|
+
return undefined;
|
|
57
|
+
const { messageId } = update;
|
|
58
|
+
const key = `${kind} ${messageId}`;
|
|
59
|
+
if (cleared.has(key))
|
|
60
|
+
return undefined;
|
|
61
|
+
cleared.add(key);
|
|
62
|
+
return emptyMessage(kind, messageId);
|
|
63
|
+
}
|
|
64
|
+
/** The message update of each message chunk. */
|
|
65
|
+
const MESSAGE_OF_CHUNK = new Map([
|
|
66
|
+
["user_message_chunk", "user_message"],
|
|
67
|
+
["agent_message_chunk", "agent_message"],
|
|
68
|
+
["agent_thought_chunk", "agent_thought"],
|
|
69
|
+
]);
|
|
70
|
+
function emptyMessage(kind, messageId) {
|
|
71
|
+
const message = { messageId, content: [] };
|
|
72
|
+
switch (kind) {
|
|
73
|
+
case "user_message":
|
|
74
|
+
return { ...message, sessionUpdate: kind };
|
|
75
|
+
case "agent_message":
|
|
76
|
+
return { ...message, sessionUpdate: kind };
|
|
77
|
+
default:
|
|
78
|
+
return { ...message, sessionUpdate: kind };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* some progress reports and none on others. Entries that don't match it are
|
|
10
10
|
* skipped, so a change in the CLI drops the list instead of the card.
|
|
11
11
|
*/
|
|
12
|
+
import type { ToolCallContent } from "@agentclientprotocol/sdk/unstable";
|
|
13
|
+
import type { TaskProgressFields } from "./async-tasks.js";
|
|
12
14
|
export type WorkflowPhase = {
|
|
13
15
|
index: number;
|
|
14
16
|
title: string;
|
|
@@ -29,6 +31,27 @@ export type WorkflowSnapshot = {
|
|
|
29
31
|
phases: WorkflowPhase[];
|
|
30
32
|
agents: WorkflowAgent[];
|
|
31
33
|
};
|
|
34
|
+
/** What a workflow card shows: the task's progress fields and its latest phase and agent list. */
|
|
35
|
+
export type WorkflowCardProgress = TaskProgressFields & {
|
|
36
|
+
workflow?: WorkflowSnapshot;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The latest workflow activity, as the title and the one replaceable body of
|
|
40
|
+
* the workflow's tool call. Undefined when no progress came. For example, the
|
|
41
|
+
* title `Workflow: Probe: probe` and the body:
|
|
42
|
+
*
|
|
43
|
+
* ```
|
|
44
|
+
* Run a probe
|
|
45
|
+
*
|
|
46
|
+
* Last activity: probe
|
|
47
|
+
*
|
|
48
|
+
* 4,003 tokens · 2 tool calls · 1s
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function workflowCard(progress: WorkflowCardProgress | undefined): {
|
|
52
|
+
title: string;
|
|
53
|
+
content: ToolCallContent[];
|
|
54
|
+
} | undefined;
|
|
32
55
|
/** Reads a `workflow_progress` value. Undefined when it holds no phase or agent. */
|
|
33
56
|
export declare function workflowSnapshot(value: unknown): WorkflowSnapshot | undefined;
|
|
34
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-progress.d.ts","sourceRoot":"","sources":["../src/workflow-progress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"workflow-progress.d.ts","sourceRoot":"","sources":["../src/workflow-progress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAG3D,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAAC,MAAM,EAAE,aAAa,EAAE,CAAA;CAAE,CAAC;AAEpF,kGAAkG;AAClG,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,GAAG;IAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAExF;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,oBAAoB,GAAG,SAAS,GACzC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,eAAe,EAAE,CAAA;CAAE,GAAG,SAAS,CAkB3D;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAsB7E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAYvE"}
|
|
@@ -1,14 +1,37 @@
|
|
|
1
|
+
import { textContent } from "./tool-calls/content.js";
|
|
1
2
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
3
|
+
* The latest workflow activity, as the title and the one replaceable body of
|
|
4
|
+
* the workflow's tool call. Undefined when no progress came. For example, the
|
|
5
|
+
* title `Workflow: Probe: probe` and the body:
|
|
4
6
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* ```
|
|
8
|
+
* Run a probe
|
|
9
|
+
*
|
|
10
|
+
* Last activity: probe
|
|
11
|
+
*
|
|
12
|
+
* 4,003 tokens · 2 tool calls · 1s
|
|
13
|
+
* ```
|
|
11
14
|
*/
|
|
15
|
+
export function workflowCard(progress) {
|
|
16
|
+
if (!progress || Object.keys(progress).length === 0)
|
|
17
|
+
return undefined;
|
|
18
|
+
const activity = progress.description ?? progress.summary;
|
|
19
|
+
const usage = progress.usage;
|
|
20
|
+
const text = [
|
|
21
|
+
progress.summary ?? progress.description,
|
|
22
|
+
progress.lastToolName ? `Last activity: ${progress.lastToolName}` : undefined,
|
|
23
|
+
usage
|
|
24
|
+
? `${usage.totalTokens.toLocaleString("en-US")} tokens · ${usage.toolUses.toLocaleString("en-US")} tool calls · ${Math.floor(usage.durationMs / 1000)}s`
|
|
25
|
+
: undefined,
|
|
26
|
+
progress.workflow ? workflowSnapshotText(progress.workflow) : undefined,
|
|
27
|
+
]
|
|
28
|
+
.filter((part) => part !== undefined)
|
|
29
|
+
.join("\n\n");
|
|
30
|
+
return {
|
|
31
|
+
title: activity ? `Workflow: ${activity}` : "Workflow",
|
|
32
|
+
content: [textContent(text)],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
12
35
|
/** Reads a `workflow_progress` value. Undefined when it holds no phase or agent. */
|
|
13
36
|
export function workflowSnapshot(value) {
|
|
14
37
|
if (!Array.isArray(value))
|
package/package.json
CHANGED
package/dist/v2/permission.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The v2 form of the permission requests that `ClaudeAcpAgent` sends, and the
|
|
3
|
-
* v1 form of their answers.
|
|
4
|
-
*/
|
|
5
|
-
import type { RequestPermissionResponse } from "@agentclientprotocol/sdk/unstable";
|
|
6
|
-
import type * as v2 from "@agentclientprotocol/sdk/experimental/v2/unstable";
|
|
7
|
-
import type { AcpPermissionRequest } from "../permissions/presentation.js";
|
|
8
|
-
/**
|
|
9
|
-
* The v2 form of a permission request of the agent.
|
|
10
|
-
*
|
|
11
|
-
* v1 asks about a tool call, whose title the prompt shows. v2 gives the prompt
|
|
12
|
-
* its own `title` and `description`, which the agent sets for a v2 client
|
|
13
|
-
* (`AcpPermissionRequest`), and asks about a `subject`: here always the tool
|
|
14
|
-
* call, as the same patch that a `tool_call_update` carries.
|
|
15
|
-
*/
|
|
16
|
-
export declare function v2PermissionRequest(request: AcpPermissionRequest): v2.RequestPermissionRequest;
|
|
17
|
-
/**
|
|
18
|
-
* The v1 form of the answer to a permission request.
|
|
19
|
-
*
|
|
20
|
-
* v2 adds outcomes that v1 does not know, which the draft says are no
|
|
21
|
-
* approval. They become `cancelled`. In v2, `cancelled` also means that the
|
|
22
|
-
* user dismissed the prompt or the client declined it by policy. So the agent
|
|
23
|
-
* reads a `cancelled` outcome on v2 as the user refusing the tool, unless a
|
|
24
|
-
* `session/cancel` is stopping the session's work: then the tool use is
|
|
25
|
-
* aborted, as on v1.
|
|
26
|
-
*/
|
|
27
|
-
export declare function v1PermissionResponse(response: v2.RequestPermissionResponse): RequestPermissionResponse;
|
|
28
|
-
//# sourceMappingURL=permission.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/v2/permission.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,KAAK,KAAK,EAAE,MAAM,mDAAmD,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,EAAE,CAAC,wBAAwB,CAY9F;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,EAAE,CAAC,yBAAyB,GACrC,yBAAyB,CAS3B"}
|
package/dist/v2/permission.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { v2ToolCallPatch } from "./tool-call.js";
|
|
2
|
-
/**
|
|
3
|
-
* The v2 form of a permission request of the agent.
|
|
4
|
-
*
|
|
5
|
-
* v1 asks about a tool call, whose title the prompt shows. v2 gives the prompt
|
|
6
|
-
* its own `title` and `description`, which the agent sets for a v2 client
|
|
7
|
-
* (`AcpPermissionRequest`), and asks about a `subject`: here always the tool
|
|
8
|
-
* call, as the same patch that a `tool_call_update` carries.
|
|
9
|
-
*/
|
|
10
|
-
export function v2PermissionRequest(request) {
|
|
11
|
-
if (request.title === undefined) {
|
|
12
|
-
throw new Error("An ACP v2 permission request needs a title");
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
sessionId: request.sessionId,
|
|
16
|
-
title: request.title,
|
|
17
|
-
...(request.description ? { description: request.description } : {}),
|
|
18
|
-
subject: { type: "tool_call", toolCall: v2ToolCallPatch(request.toolCall) },
|
|
19
|
-
options: request.options,
|
|
20
|
-
...(request._meta != null ? { _meta: request._meta } : {}),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The v1 form of the answer to a permission request.
|
|
25
|
-
*
|
|
26
|
-
* v2 adds outcomes that v1 does not know, which the draft says are no
|
|
27
|
-
* approval. They become `cancelled`. In v2, `cancelled` also means that the
|
|
28
|
-
* user dismissed the prompt or the client declined it by policy. So the agent
|
|
29
|
-
* reads a `cancelled` outcome on v2 as the user refusing the tool, unless a
|
|
30
|
-
* `session/cancel` is stopping the session's work: then the tool use is
|
|
31
|
-
* aborted, as on v1.
|
|
32
|
-
*/
|
|
33
|
-
export function v1PermissionResponse(response) {
|
|
34
|
-
const outcome = response.outcome;
|
|
35
|
-
return {
|
|
36
|
-
outcome: outcome.outcome === "selected"
|
|
37
|
-
? outcome
|
|
38
|
-
: { outcome: "cancelled" },
|
|
39
|
-
...(response._meta != null ? { _meta: response._meta } : {}),
|
|
40
|
-
};
|
|
41
|
-
}
|