@agentclientprotocol/claude-agent-acp 0.85.2-preview.4 → 0.85.2-preview.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/acp-agent.d.ts +41 -9
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +254 -107
- 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/mcp-command.d.ts +51 -0
- package/dist/mcp-command.d.ts.map +1 -0
- package/dist/mcp-command.js +321 -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-mode.d.ts +14 -0
- package/dist/session-mode.d.ts.map +1 -1
- package/dist/session-mode.js +22 -0
- 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/package.json +1 -1
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;
|
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,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,qBAAa,QAAQ,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAClD,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,SAAS,CAA8C;IAC/D,OAAO,CAAC,IAAI,CAAS;IAErB,IAAI,CAAC,IAAI,EAAE,CAAC;IASZ,GAAG;IAQH,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAgB3C;AAGD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC,CAclF;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,QAA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AE,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/package.json
CHANGED