@agentclientprotocol/claude-agent-acp 0.85.2-preview.2 → 0.85.2-preview.21
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 +1 -0
- package/dist/acp-agent.d.ts +100 -23
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +528 -183
- package/dist/air-extension.d.ts +2 -0
- package/dist/air-extension.d.ts.map +1 -1
- package/dist/air-extension.js +2 -0
- package/dist/clear-context-coordinator.d.ts +1 -0
- package/dist/clear-context-coordinator.d.ts.map +1 -1
- package/dist/clear-context-coordinator.js +2 -1
- package/dist/diff.d.ts +45 -8
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +111 -30
- package/dist/mcp-command.d.ts +51 -0
- package/dist/mcp-command.d.ts.map +1 -0
- package/dist/mcp-command.js +321 -0
- package/dist/permissions/presentation.d.ts +17 -2
- package/dist/permissions/presentation.d.ts.map +1 -1
- package/dist/permissions/presentation.js +4 -0
- package/dist/resumed-session.d.ts +16 -6
- package/dist/resumed-session.d.ts.map +1 -1
- package/dist/resumed-session.js +91 -25
- 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-mode.d.ts +14 -0
- package/dist/session-mode.d.ts.map +1 -1
- package/dist/session-mode.js +22 -0
- package/dist/tool-calls/client-capabilities.d.ts +20 -2
- package/dist/tool-calls/client-capabilities.d.ts.map +1 -1
- package/dist/tool-calls/client-capabilities.js +14 -4
- package/dist/tool-calls/facts.d.ts +8 -1
- package/dist/tool-calls/facts.d.ts.map +1 -1
- package/dist/tool-calls/renderer.d.ts +5 -1
- package/dist/tool-calls/renderer.d.ts.map +1 -1
- package/dist/tool-calls/renderer.js +14 -3
- package/dist/tool-calls/reporters/bash.d.ts.map +1 -1
- package/dist/tool-calls/reporters/bash.js +32 -5
- package/dist/tool-calls/reporters/file-edit.d.ts +1 -1
- package/dist/tool-calls/reporters/file-edit.d.ts.map +1 -1
- package/dist/tool-calls/reporters/file-edit.js +20 -14
- package/dist/turn-events.d.ts +11 -5
- package/dist/turn-events.d.ts.map +1 -1
- package/dist/usage-markdown.d.ts +2 -0
- package/dist/usage-markdown.d.ts.map +1 -1
- package/dist/usage-markdown.js +2 -1
- package/dist/utils.d.ts +12 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +121 -17
- package/dist/v2/initialize.d.ts +2 -5
- package/dist/v2/initialize.d.ts.map +1 -1
- package/dist/v2/initialize.js +23 -6
- package/dist/v2/permission.d.ts +25 -0
- package/dist/v2/permission.d.ts.map +1 -0
- package/dist/v2/permission.js +38 -0
- package/dist/v2/prompt.d.ts +47 -0
- package/dist/v2/prompt.d.ts.map +1 -0
- package/dist/v2/prompt.js +153 -0
- package/dist/v2/session-update.d.ts +6 -0
- package/dist/v2/session-update.d.ts.map +1 -1
- package/dist/v2/session-update.js +27 -0
- package/dist/v2/session.d.ts +15 -4
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +20 -6
- package/dist/v2/terminal.d.ts +42 -0
- package/dist/v2/terminal.d.ts.map +1 -0
- package/dist/v2/terminal.js +95 -0
- package/dist/v2/tool-call.d.ts +38 -0
- package/dist/v2/tool-call.d.ts.map +1 -0
- package/dist/v2/tool-call.js +49 -0
- package/package.json +2 -2
package/dist/session-mode.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RequestError, } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { AIR_KIND_KEY, airOnlyMeta } from "./air-extension.js";
|
|
3
|
+
import { resolvePermissionMode } from "./permissions/modes.js";
|
|
3
4
|
import { noticeOrTranscriptUpdate, noticeTranscriptText, sentenceCase, } from "./session-notices.js";
|
|
4
5
|
export const MODE_CONFIG_ID = "mode";
|
|
5
6
|
export const AUTO_MODE_FALLBACK = "acceptEdits";
|
|
@@ -11,6 +12,27 @@ const AUTO_MODE_FALLBACK_NOTICE = {
|
|
|
11
12
|
title: "Auto mode unavailable",
|
|
12
13
|
description: sentenceCase(AUTO_MODE_FALLBACK_REASON),
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* The permission mode a new Claude query starts in.
|
|
17
|
+
*
|
|
18
|
+
* An explicit mode wins. A resume or a load continues in the mode of the last
|
|
19
|
+
* user record of the transcript. If that mode is unknown or not available now,
|
|
20
|
+
* for example bypass, the session starts in `defaultMode` of the settings.
|
|
21
|
+
*/
|
|
22
|
+
export function resolveInitialPermissionMode(sources, logger, allowBypass) {
|
|
23
|
+
if (sources.explicit !== undefined) {
|
|
24
|
+
return resolvePermissionMode(sources.explicit, logger, allowBypass);
|
|
25
|
+
}
|
|
26
|
+
if (sources.resumed !== undefined) {
|
|
27
|
+
let rejected = false;
|
|
28
|
+
const mode = resolvePermissionMode(sources.resumed, { error: () => (rejected = true) }, allowBypass);
|
|
29
|
+
if (!rejected)
|
|
30
|
+
return mode;
|
|
31
|
+
logger.error(`Ignoring permission mode "${sources.resumed}" of the resumed transcript: ` +
|
|
32
|
+
`not available in this session.`);
|
|
33
|
+
}
|
|
34
|
+
return resolvePermissionMode(sources.defaultMode, logger, allowBypass);
|
|
35
|
+
}
|
|
14
36
|
/** Owns session-mode policy and the ACP/SDK synchronization it requires. */
|
|
15
37
|
export class SessionModeManager {
|
|
16
38
|
options;
|
|
@@ -16,6 +16,14 @@ export declare class ClientCapabilities {
|
|
|
16
16
|
readonly diffPatch: boolean;
|
|
17
17
|
/** The capabilities that only JetBrains AIR declares. */
|
|
18
18
|
readonly air: AirCapabilities;
|
|
19
|
+
/**
|
|
20
|
+
* The client speaks ACP v2. Its diffs carry structured `changes` and an
|
|
21
|
+
* optional git patch, which a v1 diff cannot express. Only the v2 surface
|
|
22
|
+
* sets this, never the capabilities that a client sends. A v2 client also
|
|
23
|
+
* takes the terminal extension (`terminalOutput`), which the v2 surface
|
|
24
|
+
* sends as display terminals.
|
|
25
|
+
*/
|
|
26
|
+
readonly v2: boolean;
|
|
19
27
|
constructor(
|
|
20
28
|
/** The client renders a terminal from `_meta.terminal_info`, `terminal_output`, and `terminal_exit`. */
|
|
21
29
|
terminalOutput?: boolean,
|
|
@@ -24,8 +32,18 @@ export declare class ClientCapabilities {
|
|
|
24
32
|
/** The client accepts an exact git patch in a diff (`jetbrains.air` `diffPatch`). */
|
|
25
33
|
diffPatch?: boolean,
|
|
26
34
|
/** The capabilities that only JetBrains AIR declares. */
|
|
27
|
-
air?: AirCapabilities
|
|
28
|
-
|
|
35
|
+
air?: AirCapabilities,
|
|
36
|
+
/**
|
|
37
|
+
* The client speaks ACP v2. Its diffs carry structured `changes` and an
|
|
38
|
+
* optional git patch, which a v1 diff cannot express. Only the v2 surface
|
|
39
|
+
* sets this, never the capabilities that a client sends. A v2 client also
|
|
40
|
+
* takes the terminal extension (`terminalOutput`), which the v2 surface
|
|
41
|
+
* sends as display terminals.
|
|
42
|
+
*/
|
|
43
|
+
v2?: boolean);
|
|
44
|
+
static from(capabilities: AcpClientCapabilities | null | undefined, { v2 }?: {
|
|
45
|
+
v2?: boolean;
|
|
46
|
+
}): ClientCapabilities;
|
|
29
47
|
}
|
|
30
48
|
/** The capabilities of JetBrains AIR, read from `_meta.jetbrains.air`. */
|
|
31
49
|
export interface AirCapabilities {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-capabilities.d.ts","sourceRoot":"","sources":["../../src/tool-calls/client-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAS5F;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAE3B,wGAAwG;IACxG,QAAQ,CAAC,cAAc,EAAE,OAAO;IAChC,4FAA4F;IAC5F,QAAQ,CAAC,mBAAmB,EAAE,OAAO;IACrC,qFAAqF;IACrF,QAAQ,CAAC,SAAS,EAAE,OAAO;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,eAAe;;
|
|
1
|
+
{"version":3,"file":"client-capabilities.d.ts","sourceRoot":"","sources":["../../src/tool-calls/client-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAS5F;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAE3B,wGAAwG;IACxG,QAAQ,CAAC,cAAc,EAAE,OAAO;IAChC,4FAA4F;IAC5F,QAAQ,CAAC,mBAAmB,EAAE,OAAO;IACrC,qFAAqF;IACrF,QAAQ,CAAC,SAAS,EAAE,OAAO;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,GAAG,EAAE,eAAe;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,OAAO;;IAfpB,wGAAwG;IAC/F,cAAc,GAAE,OAAe;IACxC,4FAA4F;IACnF,mBAAmB,GAAE,OAAe;IAC7C,qFAAqF;IAC5E,SAAS,GAAE,OAAe;IACnC,yDAAyD;IAChD,GAAG,GAAE,eAAwB;IACtC;;;;;;OAMG;IACM,EAAE,GAAE,OAAe;IAG9B,MAAM,CAAC,IAAI,CACT,YAAY,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,EACtD,EAAE,EAAU,EAAE,GAAE;QAAE,EAAE,CAAC,EAAE,OAAO,CAAA;KAAO,GACpC,kBAAkB;CAkBtB;AAED,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -12,6 +12,7 @@ export class ClientCapabilities {
|
|
|
12
12
|
terminalOutputDelta;
|
|
13
13
|
diffPatch;
|
|
14
14
|
air;
|
|
15
|
+
v2;
|
|
15
16
|
constructor(
|
|
16
17
|
/** The client renders a terminal from `_meta.terminal_info`, `terminal_output`, and `terminal_exit`. */
|
|
17
18
|
terminalOutput = false,
|
|
@@ -20,20 +21,29 @@ export class ClientCapabilities {
|
|
|
20
21
|
/** The client accepts an exact git patch in a diff (`jetbrains.air` `diffPatch`). */
|
|
21
22
|
diffPatch = false,
|
|
22
23
|
/** The capabilities that only JetBrains AIR declares. */
|
|
23
|
-
air = NO_AIR
|
|
24
|
+
air = NO_AIR,
|
|
25
|
+
/**
|
|
26
|
+
* The client speaks ACP v2. Its diffs carry structured `changes` and an
|
|
27
|
+
* optional git patch, which a v1 diff cannot express. Only the v2 surface
|
|
28
|
+
* sets this, never the capabilities that a client sends. A v2 client also
|
|
29
|
+
* takes the terminal extension (`terminalOutput`), which the v2 surface
|
|
30
|
+
* sends as display terminals.
|
|
31
|
+
*/
|
|
32
|
+
v2 = false) {
|
|
24
33
|
this.terminalOutput = terminalOutput;
|
|
25
34
|
this.terminalOutputDelta = terminalOutputDelta;
|
|
26
35
|
this.diffPatch = diffPatch;
|
|
27
36
|
this.air = air;
|
|
37
|
+
this.v2 = v2;
|
|
28
38
|
}
|
|
29
|
-
static from(capabilities) {
|
|
39
|
+
static from(capabilities, { v2 = false } = {}) {
|
|
30
40
|
const meta = capabilities?._meta;
|
|
31
41
|
const terminalOutputDelta = meta?.["terminal_output_delta"] === true;
|
|
32
|
-
return new ClientCapabilities(terminalOutputDelta || meta?.["terminal_output"] === true, terminalOutputDelta, clientSupportsAirCapability(capabilities, AIR_DIFF_PATCH_CAPABILITY), {
|
|
42
|
+
return new ClientCapabilities(v2 || terminalOutputDelta || meta?.["terminal_output"] === true, terminalOutputDelta, clientSupportsAirCapability(capabilities, AIR_DIFF_PATCH_CAPABILITY), {
|
|
33
43
|
client: isAirClient(capabilities),
|
|
34
44
|
rawInputRendering: clientSupportsAirCapability(capabilities, AIR_RAW_INPUT_RENDERING_CAPABILITY),
|
|
35
45
|
planFile: clientSupportsAirCapability(capabilities, AIR_PLAN_FILE_CAPABILITY),
|
|
36
|
-
});
|
|
46
|
+
}, v2);
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
49
|
const NO_AIR = {
|
|
@@ -41,7 +41,14 @@ export interface ToolUseFacts {
|
|
|
41
41
|
/** The output of a command, for the terminal channel. */
|
|
42
42
|
export interface CommandOutput {
|
|
43
43
|
output: string;
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The exit code of the command, when the tool result says it. Absent when it
|
|
46
|
+
* does not: a failure that names no code, an interrupted or backgrounded
|
|
47
|
+
* command, or a non-zero code that Claude Code accepted as a success.
|
|
48
|
+
*/
|
|
49
|
+
exitCode?: number;
|
|
50
|
+
/** The command was interrupted before it ended. */
|
|
51
|
+
interrupted?: boolean;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* The facts of a tool result, read once from the SDK tool_result.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../../src/tool-calls/facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,wCAAwC;AACxC,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EA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AC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACvF"}
|
|
@@ -41,7 +41,11 @@ export type ToolUpdateMeta = {
|
|
|
41
41
|
};
|
|
42
42
|
terminal_exit?: {
|
|
43
43
|
terminal_id: string;
|
|
44
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Null when the agent does not know the code, as in `TerminalExitStatus`.
|
|
46
|
+
* AIR always gets a number.
|
|
47
|
+
*/
|
|
48
|
+
exit_code: number | null;
|
|
45
49
|
signal: string | null;
|
|
46
50
|
};
|
|
47
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/tool-calls/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,IAAI,qBAAqB,EAC3C,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EACjB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI5F,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAK3D,yCAAyC;AACzC,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,CAAC,EAAE;QAIX,QAAQ,CAAC,EAAE,MAAM,CAAC;QAIlB,YAAY,CAAC,EAAE,OAAO,CAAC;QAIvB,eAAe,CAAC,EAAE,MAAM,CAAC;QAMzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAG1B,YAAY,CAAC,EAAE,MAAM,CAAC;QAEtB,SAAS,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC9C,CAAC;IAEF,SAAS,CAAC,EAAE;QACV,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
permissionToolCall(toolUse, options = {}) {
|
|
119
119
|
const facts = this.facts(toolUse, options.cwd);
|
|
120
120
|
if (!this.capabilities.air.client) {
|
|
121
|
-
// The upstream shape: the whole tool call again.
|
|
122
|
-
|
|
121
|
+
// The upstream shape: the whole tool call again. A v2 client also gets
|
|
122
|
+
// the exact preview patch, which the tool call does not show.
|
|
123
|
+
const content = options.previewContent ?? this.toolUseContent(toolUse.id, facts);
|
|
123
124
|
const locations = [...(facts.locations ?? []), ...(options.extraLocations ?? [])];
|
|
124
125
|
return {
|
|
125
126
|
toolCallId: toolUse.id,
|
|
@@ -191,7 +192,17 @@ export class AcpToolCallRenderer {
|
|
|
191
192
|
...(this.capabilities.terminalOutputDelta
|
|
192
193
|
? { terminal_output_delta: output }
|
|
193
194
|
: { terminal_output: output }),
|
|
194
|
-
terminal_exit: {
|
|
195
|
+
terminal_exit: {
|
|
196
|
+
terminal_id: terminalId,
|
|
197
|
+
// AIR keeps the numbers it always got: 1 for a failed or
|
|
198
|
+
// interrupted command, else the exit code, or 0 when unknown.
|
|
199
|
+
exit_code: this.capabilities.air.client
|
|
200
|
+
? result.is_error === true || command.interrupted
|
|
201
|
+
? 1
|
|
202
|
+
: (command.exitCode ?? 0)
|
|
203
|
+
: (command.exitCode ?? null),
|
|
204
|
+
signal: null,
|
|
205
|
+
},
|
|
195
206
|
},
|
|
196
207
|
};
|
|
197
208
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElG,gFAAgF;AAChF,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;IAUrC,iFAAiF;IACjF,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,SAAS;IAIpE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,eAAe;
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/bash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElG,gFAAgF;AAChF,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY;IAUrC,iFAAiF;IACjF,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe,GAAG,SAAS;IAIpE,UAAU,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,iBAAiB,GAAG,eAAe;CAsFvE"}
|
|
@@ -30,7 +30,11 @@ export class BashReporter {
|
|
|
30
30
|
// 4. Array content: text blocks for stdout, or image blocks when the
|
|
31
31
|
// command produces an image.
|
|
32
32
|
let output = "";
|
|
33
|
-
|
|
33
|
+
// Claude Code accepts a non-zero code as a success only with a
|
|
34
|
+
// `returnCodeInterpretation` (grep's "No matches found"), so a success
|
|
35
|
+
// without one exited with 0.
|
|
36
|
+
let exitCode = isError ? undefined : 0;
|
|
37
|
+
let interrupted = false;
|
|
34
38
|
const structuredBash = structuredResult(structured);
|
|
35
39
|
if (structuredBash &&
|
|
36
40
|
typeof structuredBash.stdout === "string" &&
|
|
@@ -38,12 +42,15 @@ export class BashReporter {
|
|
|
38
42
|
!structuredBash.isImage &&
|
|
39
43
|
structuredBash.backgroundTaskId === undefined) {
|
|
40
44
|
output = [structuredBash.stdout, structuredBash.stderr].filter(Boolean).join("\n");
|
|
41
|
-
// The CLI appends its abort marker only to the model-facing text
|
|
42
|
-
//
|
|
45
|
+
// The CLI appends its abort marker only to the model-facing text. The
|
|
46
|
+
// result does not carry the code of the aborted command.
|
|
43
47
|
if (structuredBash.interrupted) {
|
|
44
48
|
output = [output, "[Command was aborted before completion]"].filter(Boolean).join("\n");
|
|
45
|
-
exitCode =
|
|
49
|
+
exitCode = undefined;
|
|
50
|
+
interrupted = true;
|
|
46
51
|
}
|
|
52
|
+
if (structuredBash.returnCodeInterpretation !== undefined)
|
|
53
|
+
exitCode = undefined;
|
|
47
54
|
// Structured stdout is clipped when the full output was persisted to
|
|
48
55
|
// disk. Without this note the clip is silent.
|
|
49
56
|
if (typeof structuredBash.persistedOutputPath === "string") {
|
|
@@ -78,6 +85,26 @@ export class BashReporter {
|
|
|
78
85
|
}
|
|
79
86
|
output = content.map((c) => c.text).join("\n");
|
|
80
87
|
}
|
|
81
|
-
|
|
88
|
+
if (isError && exitCode === undefined)
|
|
89
|
+
exitCode = failureExitCode(output);
|
|
90
|
+
// A backgrounded command is still running: the result only announces it.
|
|
91
|
+
if (structuredBash?.backgroundTaskId !== undefined)
|
|
92
|
+
exitCode = undefined;
|
|
93
|
+
return {
|
|
94
|
+
command: {
|
|
95
|
+
output,
|
|
96
|
+
...(exitCode !== undefined ? { exitCode } : {}),
|
|
97
|
+
...(interrupted ? { interrupted } : {}),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
82
100
|
}
|
|
83
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* The exit code that the text of a failed command names. Claude Code starts the
|
|
104
|
+
* text of a command that exited with a failing code with `Exit code N`. Other
|
|
105
|
+
* failures, such as a denial or a command that could not start, name none.
|
|
106
|
+
*/
|
|
107
|
+
function failureExitCode(text) {
|
|
108
|
+
const match = /^Exit code (\d+)(?:\n|$)/.exec(text);
|
|
109
|
+
return match ? Number(match[1]) : undefined;
|
|
110
|
+
}
|
|
@@ -22,7 +22,7 @@ type NormalizedWriteInput = Partial<FileWriteInput> & {
|
|
|
22
22
|
export declare function normalizeWriteInput(input: unknown): NormalizedWriteInput | undefined;
|
|
23
23
|
/** Edit: the diff holds the old and the new text. */
|
|
24
24
|
export declare class EditReporter implements ToolReporter {
|
|
25
|
-
toolUse(input: unknown, { cwd }: ToolUseContext): ToolUseFacts;
|
|
25
|
+
toolUse(input: unknown, { cwd, capabilities }: ToolUseContext): ToolUseFacts;
|
|
26
26
|
toolResult(): ToolResultFacts;
|
|
27
27
|
hookResult(toolResponse: unknown, context: ToolUseContext): Promise<ToolResultFacts>;
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-edit.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/file-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EAEf,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"file-edit.d.ts","sourceRoot":"","sources":["../../../src/tool-calls/reporters/file-edit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EAEf,MAAM,6CAA6C,CAAC;AAQrD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACb,MAAM,aAAa,CAAC;AAErB;;;GAGG;AACH,qBAAa,aAAc,YAAW,YAAY;IAChD,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,YAAY;IAoCpF,UAAU,IAAI,eAAe;IAI7B,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAGrF;AAED,yFAAyF;AACzF,KAAK,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAI9E;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAYpF;AAED,qDAAqD;AACrD,qBAAa,YAAa,YAAW,YAAY;IAC/C,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,cAAc,GAAG,YAAY;IA0B5E,UAAU,IAAI,eAAe;IAI7B,UAAU,CAAC,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAGrF;AAyCD;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,cAAc,GAAG,YAAY;IAsB5E;;;OAGG;IACH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,eAAe;CAMxD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { patchUpdateFromDiffToolResponse, toolUpdateFromDiffToolResponse } from "../../diff.js";
|
|
1
|
+
import { patchUpdateFromDiffToolResponse, toolUpdateFromDiffToolResponse, v2UpdateFromDiffToolResponse, } from "../../diff.js";
|
|
2
2
|
import { markdownEscape, resultText, textContent, toDisplayPath } from "../content.js";
|
|
3
3
|
/**
|
|
4
4
|
* Write: the diff holds the file text. The PostToolUse hook sends the final
|
|
@@ -14,12 +14,15 @@ export class WriteReporter {
|
|
|
14
14
|
locations: write?.file_path ? [{ path: write.file_path }] : [],
|
|
15
15
|
};
|
|
16
16
|
if (write?.file_path) {
|
|
17
|
-
// A negotiated client
|
|
18
|
-
// from the PostToolUse hook. The input does not tell
|
|
19
|
-
// exists, so the live tool call shows no diff: a diff
|
|
20
|
-
// text would claim a creation. The adapter reads the
|
|
21
|
-
// preview. A replay has no preview and no hook, so it
|
|
22
|
-
|
|
17
|
+
// A negotiated client and a v2 client get the exact patch from the
|
|
18
|
+
// approval preview or from the PostToolUse hook. The input does not tell
|
|
19
|
+
// whether the file exists, so the live tool call shows no diff: a diff
|
|
20
|
+
// without the old text would claim a creation. The adapter reads the
|
|
21
|
+
// file only for the preview. A replay has no preview and no hook, so it
|
|
22
|
+
// keeps the diff, except for a v2 client: a v2 diff names the operation,
|
|
23
|
+
// which the input does not tell.
|
|
24
|
+
const inputDiff = capabilities.v2 ? false : !capabilities.diffPatch || replay;
|
|
25
|
+
if (inputDiff) {
|
|
23
26
|
facts.change = [
|
|
24
27
|
{
|
|
25
28
|
type: "diff",
|
|
@@ -68,7 +71,7 @@ export function normalizeWriteInput(input) {
|
|
|
68
71
|
}
|
|
69
72
|
/** Edit: the diff holds the old and the new text. */
|
|
70
73
|
export class EditReporter {
|
|
71
|
-
toolUse(input, { cwd }) {
|
|
74
|
+
toolUse(input, { cwd, capabilities }) {
|
|
72
75
|
const edit = input;
|
|
73
76
|
const displayPath = edit?.file_path ? toDisplayPath(edit.file_path, cwd) : undefined;
|
|
74
77
|
const facts = {
|
|
@@ -76,10 +79,11 @@ export class EditReporter {
|
|
|
76
79
|
kind: "edit",
|
|
77
80
|
locations: edit?.file_path ? [{ path: edit.file_path }] : [],
|
|
78
81
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
// The standard diff, also for a client that negotiated patches: the input
|
|
83
|
+
// holds a snippet, not the file, so a patch would need line numbers that
|
|
84
|
+
// the adapter does not know here. A v2 diff cannot hold a snippet, so a v2
|
|
85
|
+
// client gets the patch from the PostToolUse hook alone.
|
|
86
|
+
if (edit?.file_path && (edit.old_string || edit.new_string) && !capabilities.v2) {
|
|
83
87
|
facts.change = [
|
|
84
88
|
{
|
|
85
89
|
type: "diff",
|
|
@@ -104,12 +108,14 @@ export class EditReporter {
|
|
|
104
108
|
* PostToolUse `tool_response`. For Write it replaces the optimistic creation
|
|
105
109
|
* diff with the real diff of an updated file. A negotiated client gets an
|
|
106
110
|
* exact git patch built from the written file, or the standard diff when none
|
|
107
|
-
* can be built.
|
|
111
|
+
* can be built. A v2 client gets a v2 diff.
|
|
108
112
|
*/
|
|
109
113
|
async function finalChange(toolResponse, { capabilities }) {
|
|
114
|
+
if (capabilities.v2)
|
|
115
|
+
return v2UpdateFromDiffToolResponse(toolResponse);
|
|
110
116
|
if (!capabilities.diffPatch)
|
|
111
117
|
return toolUpdateFromDiffToolResponse(toolResponse);
|
|
112
|
-
const patch = await patchUpdateFromDiffToolResponse(toolResponse);
|
|
118
|
+
const patch = await patchUpdateFromDiffToolResponse(toolResponse, "air");
|
|
113
119
|
if (patch)
|
|
114
120
|
return patch;
|
|
115
121
|
const created = createdFileDiff(toolResponse);
|
package/dist/turn-events.d.ts
CHANGED
|
@@ -13,9 +13,14 @@ export interface TurnEvents {
|
|
|
13
13
|
/**
|
|
14
14
|
* Claude Code took the prompt in as the user message `messageId` of the
|
|
15
15
|
* conversation. Reported at most once per turn, and never after
|
|
16
|
-
* {@link ended} or {@link failed}.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* {@link ended} or {@link failed}.
|
|
17
|
+
*
|
|
18
|
+
* When Claude Code reports command lifecycles (`msg_lifecycle_v1`), that is
|
|
19
|
+
* when the prompt starts a turn, before the turn's output. Otherwise, and
|
|
20
|
+
* while another turn is still active (held for its background work,
|
|
21
|
+
* steered, or cancelled but not yet ended), it is the prompt's echo, after
|
|
22
|
+
* that turn ended; for a command Claude Code does not echo (such as
|
|
23
|
+
* `/compact`), it is the command's result, after any output it streamed.
|
|
19
24
|
*/
|
|
20
25
|
inserted(messageId: string): void;
|
|
21
26
|
/**
|
|
@@ -37,9 +42,10 @@ export interface TurnEvents {
|
|
|
37
42
|
ended(outcome: TurnOutcome): void;
|
|
38
43
|
/**
|
|
39
44
|
* The turn failed. Without {@link inserted} before, Claude Code was not seen
|
|
40
|
-
* taking the prompt in.
|
|
45
|
+
* taking the prompt in. `title`, when the agent has one, describes the
|
|
46
|
+
* failure for the user in plain text, such as "API Error: 529 Overloaded".
|
|
41
47
|
*/
|
|
42
|
-
failed(error: unknown): void;
|
|
48
|
+
failed(error: unknown, title?: string): void;
|
|
43
49
|
}
|
|
44
50
|
/** Why a turn ended. Every ACP version has these reasons. */
|
|
45
51
|
export type StopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-events.d.ts","sourceRoot":"","sources":["../src/turn-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB
|
|
1
|
+
{"version":3,"file":"turn-events.d.ts","sourceRoot":"","sources":["../src/turn-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC;;;;;OAKG;IACH,YAAY,IAAI,IAAI,CAAC;IACrB;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9C;AAED,6DAA6D;AAC7D,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,mBAAmB,GAAG,SAAS,GAAG,WAAW,CAAC;AAEnG,wBAAwB;AACxB,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,UAAU,CAAC;IACvB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC"}
|
package/dist/usage-markdown.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { SDKControlGetUsageResponse } from "@anthropic-ai/claude-agent-sdk"
|
|
|
2
2
|
/** Validate the experimental SDK response at the runtime boundary. */
|
|
3
3
|
export declare function parseUsageResponse(value: unknown): SDKControlGetUsageResponse | null;
|
|
4
4
|
export declare function isUsageCommandText(text: string): boolean;
|
|
5
|
+
/** Escape the Markdown syntax characters of `value` and fold its line breaks. */
|
|
6
|
+
export declare function escapeMarkdown(value: string): string;
|
|
5
7
|
/** Render the SDK's structured `/usage` response as Markdown. */
|
|
6
8
|
export declare function formatUsageResponse(usage: SDKControlGetUsageResponse): string;
|
|
7
9
|
//# sourceMappingURL=usage-markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-markdown.d.ts","sourceRoot":"","sources":["../src/usage-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AA8DjF,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,GAAG,IAAI,CAMpF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;
|
|
1
|
+
{"version":3,"file":"usage-markdown.d.ts","sourceRoot":"","sources":["../src/usage-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AA8DjF,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,GAAG,IAAI,CAMpF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AASD,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AA+DD,iEAAiE;AACjE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,0BAA0B,GAAG,MAAM,CAiE7E"}
|
package/dist/usage-markdown.js
CHANGED
|
@@ -71,7 +71,8 @@ function usageBar(percent) {
|
|
|
71
71
|
const filled = clamped === 0 ? 0 : Math.max(1, Math.round((clamped / 100) * cells));
|
|
72
72
|
return `${"█".repeat(filled)}${"░".repeat(cells - filled)}`;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
/** Escape the Markdown syntax characters of `value` and fold its line breaks. */
|
|
75
|
+
export function escapeMarkdown(value) {
|
|
75
76
|
return value.replace(/([\\`*_[\]<>|])/g, "\\$1").replace(/[\r\n]+/g, " ");
|
|
76
77
|
}
|
|
77
78
|
function formatDuration(milliseconds) {
|
package/dist/utils.d.ts
CHANGED
|
@@ -13,4 +13,16 @@ export declare function nodeToWebWritable(nodeStream: Writable): WritableStream<
|
|
|
13
13
|
export declare function nodeToWebReadable(nodeStream: Readable): ReadableStream<Uint8Array>;
|
|
14
14
|
export declare function unreachable(value: never, logger?: Logger): void;
|
|
15
15
|
export declare function sleep(time: number): Promise<void>;
|
|
16
|
+
/** The outcome of {@link raceTimeoutAndAbort}. */
|
|
17
|
+
export type RaceOutcome<T> = {
|
|
18
|
+
type: "done";
|
|
19
|
+
value: T;
|
|
20
|
+
} | {
|
|
21
|
+
type: "timeout";
|
|
22
|
+
} | {
|
|
23
|
+
type: "aborted";
|
|
24
|
+
};
|
|
25
|
+
/** Wait for `promise` until `timeoutMs` passes or `signal` aborts. A rejection
|
|
26
|
+
* of `promise` rejects the result. The timer does not keep the process alive. */
|
|
27
|
+
export declare function raceTimeoutAndAbort<T>(promise: Promise<T>, timeoutMs: number, signal: AbortSignal): Promise<RaceOutcome<T>>;
|
|
16
28
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,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C,CAAC;CAgB3C;AAGD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAclF;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAUlF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,MAAgB,QAQjE;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjD;AAED,kDAAkD;AAClD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEpG;kFACkF;AAClF,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAoBzB"}
|
package/dist/utils.js
CHANGED
|
@@ -79,3 +79,31 @@ export function unreachable(value, logger = console) {
|
|
|
79
79
|
export function sleep(time) {
|
|
80
80
|
return new Promise((resolve) => setTimeout(resolve, time));
|
|
81
81
|
}
|
|
82
|
+
/** Wait for `promise` until `timeoutMs` passes or `signal` aborts. A rejection
|
|
83
|
+
* of `promise` rejects the result. The timer does not keep the process alive. */
|
|
84
|
+
export async function raceTimeoutAndAbort(promise, timeoutMs, signal) {
|
|
85
|
+
let timeout;
|
|
86
|
+
let onAbort;
|
|
87
|
+
try {
|
|
88
|
+
return await Promise.race([
|
|
89
|
+
promise.then((value) => ({ type: "done", value })),
|
|
90
|
+
new Promise((resolve) => {
|
|
91
|
+
timeout = setTimeout(() => resolve({ type: "timeout" }), timeoutMs);
|
|
92
|
+
timeout.unref?.();
|
|
93
|
+
}),
|
|
94
|
+
new Promise((resolve) => {
|
|
95
|
+
onAbort = () => resolve({ type: "aborted" });
|
|
96
|
+
if (signal.aborted)
|
|
97
|
+
onAbort();
|
|
98
|
+
else
|
|
99
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
100
|
+
}),
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
if (timeout)
|
|
105
|
+
clearTimeout(timeout);
|
|
106
|
+
if (onAbort)
|
|
107
|
+
signal.removeEventListener("abort", onAbort);
|
|
108
|
+
}
|
|
109
|
+
}
|
package/dist/v2/agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/v2/agent.ts"],"names":[],"mappings":"
|
|
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"}
|