@agentclientprotocol/claude-agent-acp 0.102.1-preview.1 → 0.102.1-preview.3
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 +93 -622
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +369 -3474
- package/dist/acp-client.d.ts +28 -0
- package/dist/acp-client.d.ts.map +1 -0
- package/dist/acp-client.js +1 -0
- 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/lib.d.ts +5 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +3 -1
- package/dist/logger.d.ts +10 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +1 -0
- 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/message-filters.d.ts +43 -0
- package/dist/message-filters.d.ts.map +1 -0
- package/dist/message-filters.js +197 -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/new-session-meta.d.ts +40 -0
- package/dist/new-session-meta.d.ts.map +1 -0
- package/dist/new-session-meta.js +1 -0
- 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/prompt-suggestions.d.ts +29 -0
- package/dist/prompt-suggestions.d.ts.map +1 -1
- package/dist/prompt-suggestions.js +45 -0
- package/dist/prompt-to-claude.d.ts +10 -0
- package/dist/prompt-to-claude.d.ts.map +1 -0
- package/dist/prompt-to-claude.js +120 -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 +68 -0
- package/dist/result-end.d.ts.map +1 -0
- package/dist/result-end.js +84 -0
- package/dist/sdk-to-acp.d.ts +93 -0
- package/dist/sdk-to-acp.d.ts.map +1 -0
- package/dist/sdk-to-acp.js +635 -0
- package/dist/serve.d.ts +9 -3
- 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 +5 -6
- 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/slash-commands.d.ts +10 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/slash-commands.js +99 -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/utils.d.ts +1 -1
- package/dist/utils.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 +166 -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 +1224 -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 +229 -0
- package/dist/v2/stream.d.ts.map +1 -0
- package/dist/v2/stream.js +507 -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,4 +1,5 @@
|
|
|
1
1
|
import { createContextCompactionMeta, } from "./context-compaction-meta.js";
|
|
2
|
+
import { assistantMessageText } from "./session-failure-extension.js";
|
|
2
3
|
import { compactionToolCall } from "./tool-calls/reporters/compaction.js";
|
|
3
4
|
export function clientSupportsCompactionUpdates(capabilities) {
|
|
4
5
|
const compaction = capabilities?.session?.compaction;
|
|
@@ -81,6 +82,31 @@ export function isCompactSummaryMessage(message) {
|
|
|
81
82
|
message.type === "user" &&
|
|
82
83
|
message.isCompactSummary === true);
|
|
83
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Replays the compact summary message `message` (see
|
|
87
|
+
* {@link isCompactSummaryMessage}) of the root conversation as one completed
|
|
88
|
+
* `compaction_update` at its transcript position, keyed by the message's
|
|
89
|
+
* uuid. Returns false, and sends nothing, for any other message.
|
|
90
|
+
*
|
|
91
|
+
* The boundary's own system record comes back from `getSessionMessages`
|
|
92
|
+
* without its metadata, so the summary message is the one durable marker.
|
|
93
|
+
* Its uuid differs from the live id (the `compacting` status uuid): replay
|
|
94
|
+
* is terminal-first by the RFD, and no client merges a replay into a live
|
|
95
|
+
* entity store. A summary whose framing is unrecognized is still this
|
|
96
|
+
* compaction, without summary text.
|
|
97
|
+
*/
|
|
98
|
+
export async function replayCompactSummary(message, sendUpdate, options) {
|
|
99
|
+
if (!isCompactSummaryMessage(message) || typeof message.uuid !== "string" || !message.uuid) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
const replayed = new ContextCompactionLifecycle(sendUpdate, {
|
|
103
|
+
...options,
|
|
104
|
+
presentation: "compaction_update",
|
|
105
|
+
});
|
|
106
|
+
replayed.recordSummary(assistantMessageText(message.message));
|
|
107
|
+
await replayed.finish(message.uuid, "completed");
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
84
110
|
/**
|
|
85
111
|
* Translates Claude's compaction signals into one idempotent ACP lifecycle.
|
|
86
112
|
*
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The context window of a session's model, as both the v1 core and the
|
|
3
|
+
* v2 core report it in `usage_update.size`: seeded without IPC when the
|
|
4
|
+
* session starts or switches models, refined by a background
|
|
5
|
+
* `getContextUsage`, and learned from each result's `modelUsage`.
|
|
6
|
+
*/
|
|
7
|
+
import type { ModelInfo, Query } from "@anthropic-ai/claude-agent-sdk";
|
|
8
|
+
/** Stable identifier for the LLM backend a session's query is created against,
|
|
9
|
+
* used to scope {@link contextWindowCache} per backend. Positional `\0`-join
|
|
10
|
+
* of {@link PROVIDER_ROUTING_ENV_VARS} values, so no segment can masquerade
|
|
11
|
+
* as another and unset vars everywhere yield one stable "default" bucket.
|
|
12
|
+
* Header/credential values can be secrets; the key only ever lives as an
|
|
13
|
+
* in-memory Map key and is never logged or surfaced. Over-keying is the safe
|
|
14
|
+
* side: a var change that didn't really change the backend costs one cache
|
|
15
|
+
* miss (heuristic seed until the next result), while under-keying would serve
|
|
16
|
+
* one backend's window for another's. */
|
|
17
|
+
export declare function providerCacheKeyFor(env: Record<string, string | undefined>): string;
|
|
18
|
+
/** Compose the `contextWindowCache` key from a session's provider key and a
|
|
19
|
+
* model id. `\0`-joined so the model segment can't collide with a provider
|
|
20
|
+
* segment. */
|
|
21
|
+
export declare function contextWindowCacheKey(providerCacheKey: string, modelId: string): string;
|
|
22
|
+
/** Caches the window that a result's `modelUsage` reported, keyed on (the
|
|
23
|
+
* session's provider, the resolved model id — the `modelUsage` key, e.g.
|
|
24
|
+
* "claude-sonnet-5[1m]") so a later session/new or switch on the same
|
|
25
|
+
* provider that resolves to this model seeds the correct window
|
|
26
|
+
* synchronously, with no getContextUsage IPC.
|
|
27
|
+
*
|
|
28
|
+
* Also caches it under the assistant message's own (bare) spelling. Seed-time
|
|
29
|
+
* reads fall back to a picker value / verbatim live id when a row carries no
|
|
30
|
+
* resolvedModel (the synthesized out-of-allowlist resume row sets it
|
|
31
|
+
* undefined on purpose), and those spellings match `.model` from the
|
|
32
|
+
* assistant message, not the decorated modelUsage key — without this entry
|
|
33
|
+
* such rows could never hit the cache. A non-positive window is not cached. */
|
|
34
|
+
export declare function cacheResultContextWindow(providerCacheKey: string, modelUsageKey: string, assistantModel: string | null | undefined, window: number): void;
|
|
35
|
+
/** The context window to report *right now* for a model, with NO IPC on the
|
|
36
|
+
* critical path: the cached authoritative value if we've learned it (from a
|
|
37
|
+
* prior turn's `result.modelUsage`, this or any session on the same backend),
|
|
38
|
+
* else the text heuristic over the model row's identity strings, else the
|
|
39
|
+
* default. Derives the cache key itself — `modelInfo?.resolvedModel ?? modelId`,
|
|
40
|
+
* the same rule at every seed site — so read keys can't drift from the write
|
|
41
|
+
* site's spelling. `authoritative` reports whether the value came from the
|
|
42
|
+
* cache: an authoritative window can legitimately equal
|
|
43
|
+
* DEFAULT_CONTEXT_WINDOW, so the value alone can't tell the caller. */
|
|
44
|
+
export declare function immediateContextWindow(providerCacheKey: string, modelId: string, modelInfo?: Pick<ModelInfo, "resolvedModel" | "displayName" | "description">): {
|
|
45
|
+
size: number;
|
|
46
|
+
authoritative: boolean;
|
|
47
|
+
};
|
|
48
|
+
/** Forgets the learned windows, as a logout asks: 1M-context entitlement is
|
|
49
|
+
* gated per org/tier, and an OAuth re-login is invisible to the env-derived
|
|
50
|
+
* provider cache key, so windows learned under the old login must not seed
|
|
51
|
+
* sessions under the next. */
|
|
52
|
+
export declare function clearContextWindowCache(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Reads the window of the query's current model with
|
|
55
|
+
* `getContextUsage().rawMaxTokens`. Undefined when Claude Code reports none.
|
|
56
|
+
*
|
|
57
|
+
* Requests the `summary` detail instead of the default `full` breakdown,
|
|
58
|
+
* which issues one `messages/count_tokens` call per category (~18 for a bare
|
|
59
|
+
* session) and hit rate limits on every model switch; `summary` answers
|
|
60
|
+
* locally with the same `rawMaxTokens`. Callers never await it on the setup
|
|
61
|
+
* or switch path: SDK control requests are serialized, so awaiting would
|
|
62
|
+
* delay session/new or a model switch (~15s on older CLIs, issues
|
|
63
|
+
* #886/#880; ~0.5s on 2.1.283).
|
|
64
|
+
*
|
|
65
|
+
* The result does not go into the cross-session cache: its `rawMaxTokens` can
|
|
66
|
+
* differ from the `result.modelUsage` window (e.g. 967000 vs 1000000 for
|
|
67
|
+
* sonnet), so it only refines the live session.
|
|
68
|
+
*/
|
|
69
|
+
export declare function readContextWindow(query: Pick<Query, "getContextUsage">): Promise<number | undefined>;
|
|
70
|
+
//# sourceMappingURL=context-window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-window.d.ts","sourceRoot":"","sources":["../src/context-window.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAkDvE;;;;;;;;0CAQ0C;AAC1C,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAEnF;AAED;;eAEe;AACf,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvF;AAQD;;;;;;;;;;;gFAWgF;AAChF,wBAAgB,wBAAwB,CACtC,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACzC,MAAM,EAAE,MAAM,GACb,IAAI,CAKN;AAED;;;;;;;;wEAQwE;AACxE,wBAAgB,sBAAsB,CACpC,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,eAAe,GAAG,aAAa,GAAG,aAAa,CAAC,GAC3E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAe1C;AAED;;;+BAG+B;AAC/B,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,GACpC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAG7B"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { DEFAULT_CONTEXT_WINDOW, inferContextWindowFromModel } from "./session-usage.js";
|
|
2
|
+
/** Cross-session cache of authoritative context windows, keyed by
|
|
3
|
+
* `${providerCacheKey}\0${modelId}` (see {@link contextWindowCacheKey}).
|
|
4
|
+
* The window is a property of (model id, backend): the same resolved model id
|
|
5
|
+
* (e.g. "claude-sonnet-5[1m]", the spelling of the `result.modelUsage` keys)
|
|
6
|
+
* can name different context lanes behind different base URLs, routing
|
|
7
|
+
* headers, or credentials, so the key carries both. Caching it module-level
|
|
8
|
+
* lets a later session/new or switch that resolves to the same (backend,
|
|
9
|
+
* model) — in this session or any other, within the adapter's lifetime — seed
|
|
10
|
+
* the correct window synchronously with no IPC. Keying on the resolved id
|
|
11
|
+
* (rather than the picker value) means aliases that resolve to the same
|
|
12
|
+
* concrete model share one entry; the result handler additionally writes the
|
|
13
|
+
* bare assistant-message spelling so seed-time reads that fall back to a
|
|
14
|
+
* verbatim live id (rows without `resolvedModel`) can hit too.
|
|
15
|
+
*
|
|
16
|
+
* Populated authoritatively by each `result.modelUsage` a turn confirms (see
|
|
17
|
+
* the consumer's result handler). We deliberately never populate it from
|
|
18
|
+
* `getContextUsage`: its `model` spelling and `rawMaxTokens` can differ from
|
|
19
|
+
* the `result.modelUsage` key and window (e.g. 967000 vs 1000000 for sonnet),
|
|
20
|
+
* so it only refines the live session (`refreshContextWindowInBackground`).
|
|
21
|
+
* Cleared on `logout`: 1M-context entitlement can differ per account/tier, so
|
|
22
|
+
* windows learned under one login must not seed sessions under the next. */
|
|
23
|
+
const contextWindowCache = new Map();
|
|
24
|
+
/** The env vars that determine which LLM backend — and which context lane on
|
|
25
|
+
* it — a query's API traffic reaches: endpoint selection (base URLs and the
|
|
26
|
+
* Bedrock/Vertex switches with their project/region), routing/beta headers
|
|
27
|
+
* (an `anthropic-beta: context-1m-…` header flips the same model id at the
|
|
28
|
+
* same endpoint between context lanes), and credential identity (extended
|
|
29
|
+
* context is entitlement-gated per account). Used to derive the
|
|
30
|
+
* provider-cache key from the exact env a query is created with, so
|
|
31
|
+
* `providers/set` config, per-session `_meta` env overrides, and ambient
|
|
32
|
+
* process env are all distinguished exactly as the CLI will see them. */
|
|
33
|
+
const PROVIDER_ROUTING_ENV_VARS = [
|
|
34
|
+
"ANTHROPIC_BASE_URL",
|
|
35
|
+
"ANTHROPIC_BEDROCK_BASE_URL",
|
|
36
|
+
"ANTHROPIC_VERTEX_BASE_URL",
|
|
37
|
+
"CLAUDE_CODE_USE_BEDROCK",
|
|
38
|
+
"CLAUDE_CODE_USE_VERTEX",
|
|
39
|
+
"ANTHROPIC_VERTEX_PROJECT_ID",
|
|
40
|
+
"CLOUD_ML_REGION",
|
|
41
|
+
"AWS_REGION",
|
|
42
|
+
"ANTHROPIC_CUSTOM_HEADERS",
|
|
43
|
+
"ANTHROPIC_API_KEY",
|
|
44
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
45
|
+
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
46
|
+
];
|
|
47
|
+
/** Stable identifier for the LLM backend a session's query is created against,
|
|
48
|
+
* used to scope {@link contextWindowCache} per backend. Positional `\0`-join
|
|
49
|
+
* of {@link PROVIDER_ROUTING_ENV_VARS} values, so no segment can masquerade
|
|
50
|
+
* as another and unset vars everywhere yield one stable "default" bucket.
|
|
51
|
+
* Header/credential values can be secrets; the key only ever lives as an
|
|
52
|
+
* in-memory Map key and is never logged or surfaced. Over-keying is the safe
|
|
53
|
+
* side: a var change that didn't really change the backend costs one cache
|
|
54
|
+
* miss (heuristic seed until the next result), while under-keying would serve
|
|
55
|
+
* one backend's window for another's. */
|
|
56
|
+
export function providerCacheKeyFor(env) {
|
|
57
|
+
return PROVIDER_ROUTING_ENV_VARS.map((name) => env[name] ?? "").join("\0");
|
|
58
|
+
}
|
|
59
|
+
/** Compose the `contextWindowCache` key from a session's provider key and a
|
|
60
|
+
* model id. `\0`-joined so the model segment can't collide with a provider
|
|
61
|
+
* segment. */
|
|
62
|
+
export function contextWindowCacheKey(providerCacheKey, modelId) {
|
|
63
|
+
return `${providerCacheKey}\0${modelId}`;
|
|
64
|
+
}
|
|
65
|
+
function cacheContextWindow(modelKey, window) {
|
|
66
|
+
if (window > 0) {
|
|
67
|
+
contextWindowCache.set(modelKey, window);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Caches the window that a result's `modelUsage` reported, keyed on (the
|
|
71
|
+
* session's provider, the resolved model id — the `modelUsage` key, e.g.
|
|
72
|
+
* "claude-sonnet-5[1m]") so a later session/new or switch on the same
|
|
73
|
+
* provider that resolves to this model seeds the correct window
|
|
74
|
+
* synchronously, with no getContextUsage IPC.
|
|
75
|
+
*
|
|
76
|
+
* Also caches it under the assistant message's own (bare) spelling. Seed-time
|
|
77
|
+
* reads fall back to a picker value / verbatim live id when a row carries no
|
|
78
|
+
* resolvedModel (the synthesized out-of-allowlist resume row sets it
|
|
79
|
+
* undefined on purpose), and those spellings match `.model` from the
|
|
80
|
+
* assistant message, not the decorated modelUsage key — without this entry
|
|
81
|
+
* such rows could never hit the cache. A non-positive window is not cached. */
|
|
82
|
+
export function cacheResultContextWindow(providerCacheKey, modelUsageKey, assistantModel, window) {
|
|
83
|
+
cacheContextWindow(contextWindowCacheKey(providerCacheKey, modelUsageKey), window);
|
|
84
|
+
if (assistantModel && assistantModel !== modelUsageKey) {
|
|
85
|
+
cacheContextWindow(contextWindowCacheKey(providerCacheKey, assistantModel), window);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** The context window to report *right now* for a model, with NO IPC on the
|
|
89
|
+
* critical path: the cached authoritative value if we've learned it (from a
|
|
90
|
+
* prior turn's `result.modelUsage`, this or any session on the same backend),
|
|
91
|
+
* else the text heuristic over the model row's identity strings, else the
|
|
92
|
+
* default. Derives the cache key itself — `modelInfo?.resolvedModel ?? modelId`,
|
|
93
|
+
* the same rule at every seed site — so read keys can't drift from the write
|
|
94
|
+
* site's spelling. `authoritative` reports whether the value came from the
|
|
95
|
+
* cache: an authoritative window can legitimately equal
|
|
96
|
+
* DEFAULT_CONTEXT_WINDOW, so the value alone can't tell the caller. */
|
|
97
|
+
export function immediateContextWindow(providerCacheKey, modelId, modelInfo) {
|
|
98
|
+
const cached = contextWindowCache.get(contextWindowCacheKey(providerCacheKey, modelInfo?.resolvedModel ?? modelId));
|
|
99
|
+
if (cached !== undefined)
|
|
100
|
+
return { size: cached, authoritative: true };
|
|
101
|
+
return {
|
|
102
|
+
size: inferContextWindowFromModel(modelId, modelInfo?.resolvedModel, modelInfo?.displayName, modelInfo?.description) ?? DEFAULT_CONTEXT_WINDOW,
|
|
103
|
+
authoritative: false,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** Forgets the learned windows, as a logout asks: 1M-context entitlement is
|
|
107
|
+
* gated per org/tier, and an OAuth re-login is invisible to the env-derived
|
|
108
|
+
* provider cache key, so windows learned under the old login must not seed
|
|
109
|
+
* sessions under the next. */
|
|
110
|
+
export function clearContextWindowCache() {
|
|
111
|
+
contextWindowCache.clear();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Reads the window of the query's current model with
|
|
115
|
+
* `getContextUsage().rawMaxTokens`. Undefined when Claude Code reports none.
|
|
116
|
+
*
|
|
117
|
+
* Requests the `summary` detail instead of the default `full` breakdown,
|
|
118
|
+
* which issues one `messages/count_tokens` call per category (~18 for a bare
|
|
119
|
+
* session) and hit rate limits on every model switch; `summary` answers
|
|
120
|
+
* locally with the same `rawMaxTokens`. Callers never await it on the setup
|
|
121
|
+
* or switch path: SDK control requests are serialized, so awaiting would
|
|
122
|
+
* delay session/new or a model switch (~15s on older CLIs, issues
|
|
123
|
+
* #886/#880; ~0.5s on 2.1.283).
|
|
124
|
+
*
|
|
125
|
+
* The result does not go into the cross-session cache: its `rawMaxTokens` can
|
|
126
|
+
* differ from the `result.modelUsage` window (e.g. 967000 vs 1000000 for
|
|
127
|
+
* sonnet), so it only refines the live session.
|
|
128
|
+
*/
|
|
129
|
+
export async function readContextWindow(query) {
|
|
130
|
+
const usage = await query.getContextUsage({ detail: "summary" });
|
|
131
|
+
return usage.rawMaxTokens > 0 ? usage.rawMaxTokens : undefined;
|
|
132
|
+
}
|
package/dist/diff.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ export declare function clearDiffMemo(): void;
|
|
|
112
112
|
*
|
|
113
113
|
* The agent builds tool call content in v1 types, and v1 cannot express a v2
|
|
114
114
|
* diff, so the diff travels as v1 content. Nothing in the agent reads inside a
|
|
115
|
-
* diff, and only a v2 client gets one: the v2
|
|
115
|
+
* diff, and only a v2 client gets one: the v2 core sends it as it is
|
|
116
116
|
* (`src/v2/tool-call.ts`).
|
|
117
117
|
*/
|
|
118
118
|
export declare function v2DiffContent(filePath: string, change: FileChange, hunks?: PatchHunk[]): ToolCallContent;
|
package/dist/diff.js
CHANGED
|
@@ -595,7 +595,7 @@ function airPatchContent(filePath, { change, hunks }) {
|
|
|
595
595
|
*
|
|
596
596
|
* The agent builds tool call content in v1 types, and v1 cannot express a v2
|
|
597
597
|
* diff, so the diff travels as v1 content. Nothing in the agent reads inside a
|
|
598
|
-
* diff, and only a v2 client gets one: the v2
|
|
598
|
+
* diff, and only a v2 client gets one: the v2 core sends it as it is
|
|
599
599
|
* (`src/v2/tool-call.ts`).
|
|
600
600
|
*/
|
|
601
601
|
export function v2DiffContent(filePath, change, hunks) {
|
package/dist/elicitation.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CreateElicitationRequest, CreateElicitationResponse } from "@agentclientprotocol/sdk/unstable";
|
|
2
|
-
import type { ElicitationRequest, ElicitationResult } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import type { ElicitationRequest, ElicitationResult, PermissionResult, UserDialogRequest, UserDialogResult } from "@anthropic-ai/claude-agent-sdk";
|
|
3
3
|
import type { AskUserQuestionInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
4
4
|
/**
|
|
5
5
|
* Bridges between the Claude Agent SDK's elicitation/dialog callbacks and ACP's
|
|
@@ -144,4 +144,69 @@ export declare function refusalFallbackToCreateRequest(prompt: RefusalFallbackPr
|
|
|
144
144
|
* switch the user didn't ask for.
|
|
145
145
|
*/
|
|
146
146
|
export declare function refusalFallbackResultFromResponse(response: CreateElicitationResponse): string;
|
|
147
|
+
/**
|
|
148
|
+
* What became of an elicitation: the client's response, or `withdrawn` when
|
|
149
|
+
* its signal aborted first (Claude Code withdrew the request, or a cancel or
|
|
150
|
+
* close of the session did). A response that comes after the abort counts as
|
|
151
|
+
* withdrawn too.
|
|
152
|
+
*/
|
|
153
|
+
export type ElicitationOutcome = {
|
|
154
|
+
response: CreateElicitationResponse;
|
|
155
|
+
} | {
|
|
156
|
+
withdrawn: true;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Sends an elicitation with `send` and reads what became of it. A rejection
|
|
160
|
+
* while `signal` is not aborted, such as the client's -32602 for a form it
|
|
161
|
+
* cannot render, is rethrown.
|
|
162
|
+
*/
|
|
163
|
+
export declare function elicitUnlessWithdrawn(signal: AbortSignal, send: (signal: AbortSignal) => Promise<CreateElicitationResponse>): Promise<ElicitationOutcome>;
|
|
164
|
+
/** Sends a built elicitation to the client (see {@link elicitUnlessWithdrawn}). */
|
|
165
|
+
export type Elicit = (request: CreateElicitationRequest) => Promise<ElicitationOutcome>;
|
|
166
|
+
type ElicitationLogger = {
|
|
167
|
+
error: (...args: unknown[]) => void;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* Answers an MCP server's elicitation (the SDK's `onElicitation`) through
|
|
171
|
+
* `elicit`. Only the user's own decline reaches the MCP server as `decline`.
|
|
172
|
+
* A request the user never saw, because the client did not advertise its
|
|
173
|
+
* mode, it cannot be represented, the client answered with an error, or it
|
|
174
|
+
* was withdrawn, is a `cancel`.
|
|
175
|
+
*/
|
|
176
|
+
export declare function answerMcpElicitation(request: ElicitationRequest, { sessionId, support, elicit, logger, }: {
|
|
177
|
+
sessionId: string;
|
|
178
|
+
support: ElicitationSupport;
|
|
179
|
+
elicit: Elicit;
|
|
180
|
+
logger: ElicitationLogger;
|
|
181
|
+
}): Promise<ElicitationResult>;
|
|
182
|
+
/**
|
|
183
|
+
* Presents the AskUserQuestion tool's questions as a form elicitation of
|
|
184
|
+
* `sessionId` through `elicit`, and returns the answers as the tool's
|
|
185
|
+
* `updatedInput`. A withdrawn question, or one the user cancelled, aborts the
|
|
186
|
+
* tool use. `reportUnanswered` is read once the answer is in (see
|
|
187
|
+
* {@link applyAskElicitationResponse}).
|
|
188
|
+
*/
|
|
189
|
+
export declare function answerAskUserQuestion(toolInput: Record<string, unknown>, { sessionId, toolUseID, airClient, reportUnanswered, elicit, logger, }: {
|
|
190
|
+
sessionId: string;
|
|
191
|
+
toolUseID: string;
|
|
192
|
+
airClient?: boolean;
|
|
193
|
+
reportUnanswered: () => boolean;
|
|
194
|
+
elicit: Elicit;
|
|
195
|
+
logger: ElicitationLogger;
|
|
196
|
+
}): Promise<PermissionResult>;
|
|
197
|
+
/**
|
|
198
|
+
* Answers a `request_user_dialog` of Claude Code (the SDK's `onUserDialog`).
|
|
199
|
+
* Only kinds declared in `supportedDialogKinds` are ever emitted; everything
|
|
200
|
+
* unexpected is answered `cancelled` (the required answer for unrecognized
|
|
201
|
+
* kinds), which applies the dialog's default behavior CLI-side. The only
|
|
202
|
+
* declared kind is the refusal-fallback consent prompt, rendered as a form
|
|
203
|
+
* elicitation. A failed or withdrawn elicitation is `cancelled` too: the CLI
|
|
204
|
+
* then keeps the refusal rather than switching models without consent.
|
|
205
|
+
*/
|
|
206
|
+
export declare function answerUserDialog(request: UserDialogRequest, { sessionId, elicit, logger }: {
|
|
207
|
+
sessionId: string;
|
|
208
|
+
elicit: Elicit;
|
|
209
|
+
logger: ElicitationLogger;
|
|
210
|
+
}): Promise<UserDialogResult>;
|
|
211
|
+
export {};
|
|
147
212
|
//# sourceMappingURL=elicitation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAI1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAI1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,6CAA6C,CAAC;AAOrD;;;;;;;;;;;;;GAaG;AAEH,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,GAChB,wBAAwB,GAAG,IAAI,CAyBjC;AAqBD;;;GAGG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,yBAAyB,GAClC,iBAAiB,CAcnB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KA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,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GACA,OAAO,CAAC,gBAAgB,CAAC,CAuB3B;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,iBAAiB,EAC1B,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAC9F,OAAO,CAAC,gBAAgB,CAAC,CAsB3B"}
|
package/dist/elicitation.js
CHANGED
|
@@ -386,3 +386,112 @@ export function refusalFallbackResultFromResponse(response) {
|
|
|
386
386
|
const choice = acceptedElicitationContent(response)[REFUSAL_FALLBACK_CHOICE_KEY];
|
|
387
387
|
return choice === RETRY_FALLBACK_RESULT ? RETRY_FALLBACK_RESULT : KEEP_REFUSAL_RESULT;
|
|
388
388
|
}
|
|
389
|
+
/**
|
|
390
|
+
* Sends an elicitation with `send` and reads what became of it. A rejection
|
|
391
|
+
* while `signal` is not aborted, such as the client's -32602 for a form it
|
|
392
|
+
* cannot render, is rethrown.
|
|
393
|
+
*/
|
|
394
|
+
export async function elicitUnlessWithdrawn(signal, send) {
|
|
395
|
+
try {
|
|
396
|
+
const response = await send(signal);
|
|
397
|
+
return signal.aborted ? { withdrawn: true } : { response };
|
|
398
|
+
}
|
|
399
|
+
catch (error) {
|
|
400
|
+
if (signal.aborted)
|
|
401
|
+
return { withdrawn: true };
|
|
402
|
+
throw error;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Answers an MCP server's elicitation (the SDK's `onElicitation`) through
|
|
407
|
+
* `elicit`. Only the user's own decline reaches the MCP server as `decline`.
|
|
408
|
+
* A request the user never saw, because the client did not advertise its
|
|
409
|
+
* mode, it cannot be represented, the client answered with an error, or it
|
|
410
|
+
* was withdrawn, is a `cancel`.
|
|
411
|
+
*/
|
|
412
|
+
export async function answerMcpElicitation(request, { sessionId, support, elicit, logger, }) {
|
|
413
|
+
const isUrl = request.mode === "url";
|
|
414
|
+
if ((isUrl && !support.url) || (!isUrl && !support.form)) {
|
|
415
|
+
return { action: "cancel" };
|
|
416
|
+
}
|
|
417
|
+
const createRequest = mcpElicitationToCreateRequest(request, sessionId);
|
|
418
|
+
if (!createRequest) {
|
|
419
|
+
return { action: "cancel" };
|
|
420
|
+
}
|
|
421
|
+
try {
|
|
422
|
+
const outcome = await elicit(createRequest);
|
|
423
|
+
if ("withdrawn" in outcome)
|
|
424
|
+
return { action: "cancel" };
|
|
425
|
+
return createElicitationResponseToElicitResult(outcome.response);
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
// The client answered with an error, e.g. -32602 for a form it cannot
|
|
429
|
+
// render, so the user never saw the request. MCP's `decline` means the
|
|
430
|
+
// user refused; `cancel` means they made no explicit choice.
|
|
431
|
+
logger.error(`Failed to forward MCP elicitation: ${error}`);
|
|
432
|
+
return { action: "cancel" };
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Presents the AskUserQuestion tool's questions as a form elicitation of
|
|
437
|
+
* `sessionId` through `elicit`, and returns the answers as the tool's
|
|
438
|
+
* `updatedInput`. A withdrawn question, or one the user cancelled, aborts the
|
|
439
|
+
* tool use. `reportUnanswered` is read once the answer is in (see
|
|
440
|
+
* {@link applyAskElicitationResponse}).
|
|
441
|
+
*/
|
|
442
|
+
export async function answerAskUserQuestion(toolInput, { sessionId, toolUseID, airClient = false, reportUnanswered, elicit, logger, }) {
|
|
443
|
+
const questions = extractAskUserQuestions(toolInput);
|
|
444
|
+
if (!questions) {
|
|
445
|
+
return { behavior: "deny", message: "AskUserQuestion called with no valid questions." };
|
|
446
|
+
}
|
|
447
|
+
const createRequest = askUserQuestionsToCreateRequest(questions, sessionId, toolUseID, airClient);
|
|
448
|
+
let outcome;
|
|
449
|
+
try {
|
|
450
|
+
outcome = await elicit(createRequest);
|
|
451
|
+
}
|
|
452
|
+
catch (error) {
|
|
453
|
+
logger.error(`Failed to present AskUserQuestion elicitation: ${error}`);
|
|
454
|
+
return { behavior: "deny", message: "Could not present the question to the user." };
|
|
455
|
+
}
|
|
456
|
+
if ("withdrawn" in outcome) {
|
|
457
|
+
throw new Error("Tool use aborted");
|
|
458
|
+
}
|
|
459
|
+
const answer = applyAskElicitationResponse(outcome.response, toolInput, questions, {
|
|
460
|
+
reportUnanswered: reportUnanswered(),
|
|
461
|
+
});
|
|
462
|
+
if (answer.action === "cancel") {
|
|
463
|
+
throw new Error("Tool use aborted");
|
|
464
|
+
}
|
|
465
|
+
return { behavior: "allow", updatedInput: answer.updatedInput };
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Answers a `request_user_dialog` of Claude Code (the SDK's `onUserDialog`).
|
|
469
|
+
* Only kinds declared in `supportedDialogKinds` are ever emitted; everything
|
|
470
|
+
* unexpected is answered `cancelled` (the required answer for unrecognized
|
|
471
|
+
* kinds), which applies the dialog's default behavior CLI-side. The only
|
|
472
|
+
* declared kind is the refusal-fallback consent prompt, rendered as a form
|
|
473
|
+
* elicitation. A failed or withdrawn elicitation is `cancelled` too: the CLI
|
|
474
|
+
* then keeps the refusal rather than switching models without consent.
|
|
475
|
+
*/
|
|
476
|
+
export async function answerUserDialog(request, { sessionId, elicit, logger }) {
|
|
477
|
+
if (request.dialogKind !== REFUSAL_FALLBACK_DIALOG_KIND) {
|
|
478
|
+
return { behavior: "cancelled" };
|
|
479
|
+
}
|
|
480
|
+
const prompt = extractRefusalFallbackPrompt(request.payload);
|
|
481
|
+
if (!prompt) {
|
|
482
|
+
logger.error(`refusal_fallback_prompt payload had an unexpected shape; cancelling the dialog: ${JSON.stringify(request.payload)}`);
|
|
483
|
+
return { behavior: "cancelled" };
|
|
484
|
+
}
|
|
485
|
+
let outcome;
|
|
486
|
+
try {
|
|
487
|
+
outcome = await elicit(refusalFallbackToCreateRequest(prompt, sessionId));
|
|
488
|
+
}
|
|
489
|
+
catch (error) {
|
|
490
|
+
logger.error(`Failed to present refusal fallback elicitation: ${error}`);
|
|
491
|
+
return { behavior: "cancelled" };
|
|
492
|
+
}
|
|
493
|
+
if ("withdrawn" in outcome) {
|
|
494
|
+
return { behavior: "cancelled" };
|
|
495
|
+
}
|
|
496
|
+
return { behavior: "completed", result: refusalFallbackResultFromResponse(outcome.response) };
|
|
497
|
+
}
|
|
@@ -50,11 +50,12 @@ export declare function agentFileChangeReportMeta(result: AgentFileChangeReportR
|
|
|
50
50
|
* Adds to `turn.editedPaths` the `file_path` (`notebook_path` for NotebookEdit)
|
|
51
51
|
* of each successful file-tool edit among the tool results of a subagent
|
|
52
52
|
* message. Root-agent messages (`parentToolUseId === null`) are skipped: the
|
|
53
|
-
* checkpoint already tracks their files.
|
|
54
|
-
* drops the tool use
|
|
53
|
+
* checkpoint already tracks their files. A turn that v1 marked `settled`
|
|
54
|
+
* records nothing. Must run before `toAcpNotifications` drops the tool use
|
|
55
|
+
* cache entries.
|
|
55
56
|
*/
|
|
56
57
|
export declare function recordSubagentFileEdits(turn: (NativeFileChangeReportTurn & {
|
|
57
|
-
settled
|
|
58
|
+
settled?: boolean;
|
|
58
59
|
}) | null | undefined, parentToolUseId: string | null, content: unknown, toolUses: Record<string, {
|
|
59
60
|
name: string;
|
|
60
61
|
input: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-change-audit.d.ts","sourceRoot":"","sources":["../src/file-change-audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAqB,MAAM,gCAAgC,CAAC;AAK/E,eAAO,MAAM,mCAAmC,0BAA0B,CAAC;AAI3E,eAAO,MAAM,kCAAkC,QAAa,CAAC;AAC7D,eAAO,MAAM,mCAAmC,OAAQ,CAAC;AAGzD,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE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AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,CAAC,0BAA0B,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,IAAI,GAAG,SAAS,EAC7E,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,GACrE,IAAI,CAmBN;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,+BAA+B,GACvC,wBAAwB,CA8G1B"}
|
|
@@ -35,8 +35,9 @@ const FILE_EDIT_TOOLS = new Set(["Edit", "Write", "MultiEdit", "NotebookEdit"]);
|
|
|
35
35
|
* Adds to `turn.editedPaths` the `file_path` (`notebook_path` for NotebookEdit)
|
|
36
36
|
* of each successful file-tool edit among the tool results of a subagent
|
|
37
37
|
* message. Root-agent messages (`parentToolUseId === null`) are skipped: the
|
|
38
|
-
* checkpoint already tracks their files.
|
|
39
|
-
* drops the tool use
|
|
38
|
+
* checkpoint already tracks their files. A turn that v1 marked `settled`
|
|
39
|
+
* records nothing. Must run before `toAcpNotifications` drops the tool use
|
|
40
|
+
* cache entries.
|
|
40
41
|
*/
|
|
41
42
|
export function recordSubagentFileEdits(turn, parentToolUseId, content, toolUses) {
|
|
42
43
|
if (parentToolUseId === null || !turn || turn.settled || !turn.fileChangeReport)
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export { ClaudeAcpAgent,
|
|
1
|
+
export { ClaudeAcpAgent, runAcp } from "./acp-agent.js";
|
|
2
|
+
export { isLocalCommandMetadata, stripLocalCommandMetadata } from "./message-filters.js";
|
|
3
|
+
export { toAcpNotifications, streamEventToAcpNotifications } from "./sdk-to-acp.js";
|
|
4
|
+
export type { NewSessionMeta, SDKMessageFilter } from "./new-session-meta.js";
|
|
5
|
+
export type { ToolUpdateMeta } from "./tool-calls/renderer.js";
|
|
2
6
|
export { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
|
|
3
7
|
export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
|
|
4
8
|
export { SettingsManager, type SettingsManagerOptions } from "./settings.js";
|
package/dist/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AACpF,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,YAAY,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG7E,OAAO,EACL,yBAAyB,EACzB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,4BAA4B,GAClC,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/lib.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Export the main agent class and utilities for library usage
|
|
2
|
-
export { ClaudeAcpAgent,
|
|
2
|
+
export { ClaudeAcpAgent, runAcp } from "./acp-agent.js";
|
|
3
|
+
export { isLocalCommandMetadata, stripLocalCommandMetadata } from "./message-filters.js";
|
|
4
|
+
export { toAcpNotifications, streamEventToAcpNotifications } from "./sdk-to-acp.js";
|
|
3
5
|
export { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
|
|
4
6
|
export { toolInfoFromToolUse, toDisplayPath, planEntries, toolUpdateFromToolResult, } from "./tools.js";
|
|
5
7
|
export { SettingsManager } from "./settings.js";
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger interface for customizing logging output
|
|
3
|
+
*/
|
|
4
|
+
export interface Logger {
|
|
5
|
+
log: (...args: any[]) => void;
|
|
6
|
+
error: (...args: any[]) => void;
|
|
7
|
+
/** Optional: a caller that supplies no `warn` gets its warnings on `error`. */
|
|
8
|
+
warn?: (...args: any[]) => void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAC9B,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IAChC,+EAA+E;IAC/E,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;CACjC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse } from "@agentclientprotocol/sdk/unstable";
|
|
2
|
+
import type { Query } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
/** Runtime MCP OAuth control exposed by the pinned Agent SDK. It is not yet in
|
|
4
|
+
* the public `Query` declaration, even though the method is present on the
|
|
5
|
+
* SDK query object and backed by Claude Code's `mcp_authenticate` control. */
|
|
6
|
+
type McpOAuthQuery = Query & {
|
|
7
|
+
mcpAuthenticate(serverName: string, redirectUri?: string): Promise<{
|
|
8
|
+
authUrl?: string;
|
|
9
|
+
requiresUserAction: boolean;
|
|
10
|
+
callbackExpected: boolean;
|
|
11
|
+
redirectScheme?: "localhost" | "custom";
|
|
12
|
+
callbackPort?: number;
|
|
13
|
+
state?: string;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
export declare function supportsMcpOAuth(query: Query): query is McpOAuthQuery;
|
|
17
|
+
/** What an OAuth run needs of the client connection. */
|
|
18
|
+
export type McpOAuthClient = {
|
|
19
|
+
/** Whether the client advertised URL elicitation. Without it, OAuth does not start. */
|
|
20
|
+
readonly urlElicitation: boolean;
|
|
21
|
+
createElicitation(params: CreateElicitationRequest, signal: AbortSignal): Promise<CreateElicitationResponse>;
|
|
22
|
+
completeElicitation(params: CompleteElicitationNotification): Promise<void>;
|
|
23
|
+
readonly logger: {
|
|
24
|
+
error: (...args: unknown[]) => void;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/** What an OAuth run needs of the session. */
|
|
28
|
+
export type McpOAuthSession = {
|
|
29
|
+
/** One OAuth run at a time per key: the session object. */
|
|
30
|
+
readonly key: object;
|
|
31
|
+
readonly sessionId: string;
|
|
32
|
+
/** The session's query now, or `undefined` once the session is gone. */
|
|
33
|
+
currentQuery(): Query | undefined;
|
|
34
|
+
/** Aborts when the session closes. */
|
|
35
|
+
readonly closed: AbortSignal;
|
|
36
|
+
};
|
|
37
|
+
/** Start OAuth in the background for the servers in `requestedServers` that
|
|
38
|
+
* Claude reports as needing authentication. It does nothing while another
|
|
39
|
+
* OAuth run of the session is in progress. */
|
|
40
|
+
export declare function startMcpServerAuthentication(client: McpOAuthClient, session: McpOAuthSession, requestedServers: Set<string>): void;
|
|
41
|
+
/** Wait for a polling interval, resolving false when the session is aborted. */
|
|
42
|
+
export declare function waitUnlessAborted(milliseconds: number, signal: AbortSignal): Promise<boolean>;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=mcp-oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-oauth.d.ts","sourceRoot":"","sources":["../src/mcp-oauth.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAmB,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAS7E;;+EAE+E;AAC/E,KAAK,aAAa,GAAG,KAAK,GAAG;IAC3B,eAAe,CACb,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,gBAAgB,EAAE,OAAO,CAAC;QAC1B,cAAc,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;QACxC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,aAAa,CAErE;AAED,wDAAwD;AACxD,MAAM,MAAM,cAAc,GAAG;IAC3B,uFAAuF;IACvF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,iBAAiB,CACf,MAAM,EAAE,wBAAwB,EAChC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACtC,mBAAmB,CAAC,MAAM,EAA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