@agentclientprotocol/claude-agent-acp 0.102.1-preview.1 → 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 +113 -439
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +362 -2409
- 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/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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { SessionConfigOption, SetSessionConfigOptionRequest } from "@agentclientprotocol/sdk/unstable";
|
|
2
|
+
import type { FastModeDisabledReason, FastModeState } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
export declare const FAST_MODE_CONFIG_ID = "fast";
|
|
4
|
+
/** Select-fallback values used when the client has not opted into boolean
|
|
5
|
+
* config options (see {@link createFastModeConfigOption}). */
|
|
6
|
+
export declare const FAST_MODE_ON = "on";
|
|
7
|
+
export declare const FAST_MODE_OFF = "off";
|
|
8
|
+
/** Map the SDK's tri-state `fast_mode_state` onto the boolean config toggle.
|
|
9
|
+
* `cooldown` (fast mode temporarily suspended after a rate limit, per the SDK
|
|
10
|
+
* docs) keeps the toggle on so it reflects the user's intent — only an
|
|
11
|
+
* explicit `off` clears it. */
|
|
12
|
+
export declare function fastModeStateEnabled(state: FastModeState): boolean;
|
|
13
|
+
/** Normalize an SDK-reported `fast_mode_disabled_reason` to the one we retain:
|
|
14
|
+
* a reason we have an explanation for, else `undefined`. Keeping only
|
|
15
|
+
* explainable reasons means state comparisons (see `fastModeStateChange`) track
|
|
16
|
+
* exactly what the user can see, so routine reports like
|
|
17
|
+
* `sdk_opt_in_required` never churn the config option. */
|
|
18
|
+
export declare function normalizeFastModeDisabledReason(reason: FastModeDisabledReason | undefined): FastModeDisabledReason | undefined;
|
|
19
|
+
/** Build the Fast mode config option. When the Client supports boolean config
|
|
20
|
+
* options we expose a native `type: "boolean"` toggle; otherwise we degrade to
|
|
21
|
+
* a two-value `select` ("on"/"off") so older Clients still get a usable
|
|
22
|
+
* control.
|
|
23
|
+
*
|
|
24
|
+
* `disabledReason` (the SDK's `fast_mode_disabled_reason`) is folded into the
|
|
25
|
+
* description while the toggle reads off, so a user whose account or provider
|
|
26
|
+
* can't serve Fast mode sees why instead of a switch that silently refuses to
|
|
27
|
+
* stay on. Ignored while enabled: a reason reported alongside an `on`/`cooldown`
|
|
28
|
+
* state isn't blocking anything right now. */
|
|
29
|
+
export declare function createFastModeConfigOption(enabled: boolean, useBooleanOption: boolean, disabledReason?: FastModeDisabledReason): SessionConfigOption;
|
|
30
|
+
/** Resolve the requested Fast mode value from a `session/set_config_option`
|
|
31
|
+
* request. Accepts a native boolean (boolean-capable Clients) or the
|
|
32
|
+
* "on"/"off" select-fallback strings. */
|
|
33
|
+
export declare function resolveFastModeEnabled(params: SetSessionConfigOptionRequest): boolean;
|
|
34
|
+
/** Per-model Fast mode state threaded into `buildConfigOptions`. The
|
|
35
|
+
* option is only surfaced when the current model `supported`s fast mode. */
|
|
36
|
+
export type FastModeOptionState = {
|
|
37
|
+
supported: boolean;
|
|
38
|
+
enabled: boolean;
|
|
39
|
+
/** Whether the Client opted into boolean config options. */
|
|
40
|
+
useBooleanOption: boolean;
|
|
41
|
+
/** Latest explainable `fast_mode_disabled_reason`, folded into the option's
|
|
42
|
+
* description while the toggle reads off. */
|
|
43
|
+
disabledReason?: FastModeDisabledReason;
|
|
44
|
+
};
|
|
45
|
+
/** What a reported `fast_mode_state` changes in a Fast mode toggle that the
|
|
46
|
+
* current model shows. The SDK can flip fast mode independently of the
|
|
47
|
+
* user — e.g. back to `on` once a rate-limit `cooldown` clears — so
|
|
48
|
+
* definitive on/off changes are mirrored into the option.
|
|
49
|
+
*
|
|
50
|
+
* Undefined when nothing changes: an absent state, a `cooldown` (a transient
|
|
51
|
+
* suspension of an already-enabled fast mode: the toggle stays as-is rather
|
|
52
|
+
* than flapping, and a stray cooldown never enables a toggle the user has
|
|
53
|
+
* off), or the same state with the same explainable reason.
|
|
54
|
+
*
|
|
55
|
+
* `reason` is the SDK's `fast_mode_disabled_reason`, reported alongside the
|
|
56
|
+
* state. Only explainable reasons are retained (see
|
|
57
|
+
* {@link normalizeFastModeDisabledReason}), so a routine
|
|
58
|
+
* `sdk_opt_in_required` report on every turn's result can't churn the
|
|
59
|
+
* option, while a real blocker updates the description even when the
|
|
60
|
+
* toggle's own value is unchanged.
|
|
61
|
+
*
|
|
62
|
+
* `notice` is set when the user had Fast mode on and the SDK turned it off
|
|
63
|
+
* for an explainable reason: the description carries the same explanation,
|
|
64
|
+
* but a toggle silently snapping back is worth saying out loud once. */
|
|
65
|
+
export declare function fastModeStateChange(current: {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
disabledReason?: FastModeDisabledReason;
|
|
68
|
+
}, state: FastModeState | undefined, reason: FastModeDisabledReason | undefined): {
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
disabledReason?: FastModeDisabledReason;
|
|
71
|
+
notice?: FastModeOffNotice;
|
|
72
|
+
} | undefined;
|
|
73
|
+
/** The notice of Fast mode that the SDK turned off, and its transcript line
|
|
74
|
+
* for a client without `notice` updates. */
|
|
75
|
+
export type FastModeOffNotice = {
|
|
76
|
+
notice: {
|
|
77
|
+
severity: "warning";
|
|
78
|
+
title: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
transcript: string;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=session-fast-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-fast-mode.d.ts","sourceRoot":"","sources":["../src/session-fast-mode.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,mBAAmB,EACnB,6BAA6B,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG5F,eAAO,MAAM,mBAAmB,SAAS,CAAC;AAE1C;+DAC+D;AAC/D,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,aAAa,QAAQ,CAAC;AAGnC;;;gCAGgC;AAChC,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAElE;AAqBD;;;;2DAI2D;AAC3D,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,sBAAsB,GAAG,SAAS,GACzC,sBAAsB,GAAG,SAAS,CAEpC;AAED;;;;;;;;;+CAS+C;AAC/C,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,OAAO,EACzB,cAAc,CAAC,EAAE,sBAAsB,GACtC,mBAAmB,CAwBrB;AAED;;0CAE0C;AAC1C,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,6BAA6B,GAAG,OAAO,CAerF;AAED;6EAC6E;AAC7E,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,4DAA4D;IAC5D,gBAAgB,EAAE,OAAO,CAAC;IAC1B;kDAC8C;IAC9C,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;yEAmByE;AACzE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,sBAAsB,CAAA;CAAE,EACtE,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,MAAM,EAAE,sBAAsB,GAAG,SAAS,GAExC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,sBAAsB,CAAC;IAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAAE,GACzF,SAAS,CAwBZ;AAED;6CAC6C;AAC7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE;QAAE,QAAQ,EAAE,SAAS,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Fast mode toggle of a session: its config option, the value a
|
|
3
|
+
* `session/set_config_option` request sets, and the state Claude Code reports
|
|
4
|
+
* (`fast_mode_state` and `fast_mode_disabled_reason`, on `system`/init and on
|
|
5
|
+
* results). Shared by the v1 core and the v2 core.
|
|
6
|
+
*/
|
|
7
|
+
import { RequestError } from "@agentclientprotocol/sdk/unstable";
|
|
8
|
+
import { sentenceCase } from "./session-notices.js";
|
|
9
|
+
export const FAST_MODE_CONFIG_ID = "fast";
|
|
10
|
+
/** Select-fallback values used when the client has not opted into boolean
|
|
11
|
+
* config options (see {@link createFastModeConfigOption}). */
|
|
12
|
+
export const FAST_MODE_ON = "on";
|
|
13
|
+
export const FAST_MODE_OFF = "off";
|
|
14
|
+
const FAST_MODE_DESCRIPTION = "Faster responses on supported models";
|
|
15
|
+
/** Map the SDK's tri-state `fast_mode_state` onto the boolean config toggle.
|
|
16
|
+
* `cooldown` (fast mode temporarily suspended after a rate limit, per the SDK
|
|
17
|
+
* docs) keeps the toggle on so it reflects the user's intent — only an
|
|
18
|
+
* explicit `off` clears it. */
|
|
19
|
+
export function fastModeStateEnabled(state) {
|
|
20
|
+
return state !== "off";
|
|
21
|
+
}
|
|
22
|
+
/** User-facing explanations for the SDK's `fast_mode_disabled_reason` values
|
|
23
|
+
* that a user can act on (or at least wants to know about). Deliberately
|
|
24
|
+
* partial — the omitted reasons are not worth surfacing:
|
|
25
|
+
* - `sdk_opt_in_required`: every SDK session starts here (the toggle IS the
|
|
26
|
+
* opt-in), so it describes the default, not a problem.
|
|
27
|
+
* - `preference`: the user turned Fast mode off themselves.
|
|
28
|
+
* - `pending`: eligibility is still resolving; the next report supersedes it.
|
|
29
|
+
* - `unknown`: nothing meaningful to say.
|
|
30
|
+
* Unknown future reasons fall through the same way (open set — the SDK's docs
|
|
31
|
+
* say to ignore values you don't handle). */
|
|
32
|
+
const FAST_MODE_UNAVAILABLE_EXPLANATIONS = {
|
|
33
|
+
free: "not available on the free plan",
|
|
34
|
+
extra_usage_disabled: "requires extra usage to be enabled for this account",
|
|
35
|
+
model_not_allowed: "not available for the selected model",
|
|
36
|
+
not_first_party: "not available on this API provider",
|
|
37
|
+
disabled_by_env: "disabled by environment configuration",
|
|
38
|
+
network_error: "eligibility could not be verified (network error)",
|
|
39
|
+
};
|
|
40
|
+
/** Normalize an SDK-reported `fast_mode_disabled_reason` to the one we retain:
|
|
41
|
+
* a reason we have an explanation for, else `undefined`. Keeping only
|
|
42
|
+
* explainable reasons means state comparisons (see `fastModeStateChange`) track
|
|
43
|
+
* exactly what the user can see, so routine reports like
|
|
44
|
+
* `sdk_opt_in_required` never churn the config option. */
|
|
45
|
+
export function normalizeFastModeDisabledReason(reason) {
|
|
46
|
+
return reason && FAST_MODE_UNAVAILABLE_EXPLANATIONS[reason] ? reason : undefined;
|
|
47
|
+
}
|
|
48
|
+
/** Build the Fast mode config option. When the Client supports boolean config
|
|
49
|
+
* options we expose a native `type: "boolean"` toggle; otherwise we degrade to
|
|
50
|
+
* a two-value `select` ("on"/"off") so older Clients still get a usable
|
|
51
|
+
* control.
|
|
52
|
+
*
|
|
53
|
+
* `disabledReason` (the SDK's `fast_mode_disabled_reason`) is folded into the
|
|
54
|
+
* description while the toggle reads off, so a user whose account or provider
|
|
55
|
+
* can't serve Fast mode sees why instead of a switch that silently refuses to
|
|
56
|
+
* stay on. Ignored while enabled: a reason reported alongside an `on`/`cooldown`
|
|
57
|
+
* state isn't blocking anything right now. */
|
|
58
|
+
export function createFastModeConfigOption(enabled, useBooleanOption, disabledReason) {
|
|
59
|
+
const explanation = enabled
|
|
60
|
+
? undefined
|
|
61
|
+
: disabledReason && FAST_MODE_UNAVAILABLE_EXPLANATIONS[disabledReason];
|
|
62
|
+
const base = {
|
|
63
|
+
id: FAST_MODE_CONFIG_ID,
|
|
64
|
+
name: "Fast mode",
|
|
65
|
+
description: explanation ? `${FAST_MODE_DESCRIPTION} — ${explanation}` : FAST_MODE_DESCRIPTION,
|
|
66
|
+
category: "model_config",
|
|
67
|
+
};
|
|
68
|
+
if (useBooleanOption) {
|
|
69
|
+
return { ...base, type: "boolean", currentValue: enabled };
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
...base,
|
|
73
|
+
type: "select",
|
|
74
|
+
currentValue: enabled ? FAST_MODE_ON : FAST_MODE_OFF,
|
|
75
|
+
options: [
|
|
76
|
+
{ value: FAST_MODE_ON, name: "On" },
|
|
77
|
+
{ value: FAST_MODE_OFF, name: "Off" },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Resolve the requested Fast mode value from a `session/set_config_option`
|
|
82
|
+
* request. Accepts a native boolean (boolean-capable Clients) or the
|
|
83
|
+
* "on"/"off" select-fallback strings. */
|
|
84
|
+
export function resolveFastModeEnabled(params) {
|
|
85
|
+
const value = params.value;
|
|
86
|
+
if (typeof value === "boolean") {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
if (value === FAST_MODE_ON) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
if (value === FAST_MODE_OFF) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
throw RequestError.invalidParams(undefined, `Invalid value for config option ${FAST_MODE_CONFIG_ID}: ${value}`);
|
|
96
|
+
}
|
|
97
|
+
/** What a reported `fast_mode_state` changes in a Fast mode toggle that the
|
|
98
|
+
* current model shows. The SDK can flip fast mode independently of the
|
|
99
|
+
* user — e.g. back to `on` once a rate-limit `cooldown` clears — so
|
|
100
|
+
* definitive on/off changes are mirrored into the option.
|
|
101
|
+
*
|
|
102
|
+
* Undefined when nothing changes: an absent state, a `cooldown` (a transient
|
|
103
|
+
* suspension of an already-enabled fast mode: the toggle stays as-is rather
|
|
104
|
+
* than flapping, and a stray cooldown never enables a toggle the user has
|
|
105
|
+
* off), or the same state with the same explainable reason.
|
|
106
|
+
*
|
|
107
|
+
* `reason` is the SDK's `fast_mode_disabled_reason`, reported alongside the
|
|
108
|
+
* state. Only explainable reasons are retained (see
|
|
109
|
+
* {@link normalizeFastModeDisabledReason}), so a routine
|
|
110
|
+
* `sdk_opt_in_required` report on every turn's result can't churn the
|
|
111
|
+
* option, while a real blocker updates the description even when the
|
|
112
|
+
* toggle's own value is unchanged.
|
|
113
|
+
*
|
|
114
|
+
* `notice` is set when the user had Fast mode on and the SDK turned it off
|
|
115
|
+
* for an explainable reason: the description carries the same explanation,
|
|
116
|
+
* but a toggle silently snapping back is worth saying out loud once. */
|
|
117
|
+
export function fastModeStateChange(current, state, reason) {
|
|
118
|
+
if (state === undefined || state === "cooldown")
|
|
119
|
+
return undefined;
|
|
120
|
+
const enabled = state === "on";
|
|
121
|
+
// A reason only describes an off state; drop any that rides an `on` report
|
|
122
|
+
// so it can't decorate the option the next time fast mode goes off.
|
|
123
|
+
const disabledReason = enabled ? undefined : normalizeFastModeDisabledReason(reason);
|
|
124
|
+
if (enabled === current.enabled && disabledReason === current.disabledReason)
|
|
125
|
+
return undefined;
|
|
126
|
+
const explanation = disabledReason !== undefined ? FAST_MODE_UNAVAILABLE_EXPLANATIONS[disabledReason] : undefined;
|
|
127
|
+
if (!current.enabled || enabled || explanation === undefined) {
|
|
128
|
+
return { enabled, disabledReason };
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
enabled,
|
|
132
|
+
disabledReason,
|
|
133
|
+
notice: {
|
|
134
|
+
notice: {
|
|
135
|
+
severity: "warning",
|
|
136
|
+
title: "Fast mode turned off",
|
|
137
|
+
description: `${sentenceCase(explanation)}.`,
|
|
138
|
+
},
|
|
139
|
+
transcript: `**Fast mode turned off:** ${explanation}.`,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -60,11 +60,8 @@ export declare class SessionIndexConnection {
|
|
|
60
60
|
/** When the query of a session failed here, by session id. */
|
|
61
61
|
private readonly failedQueries;
|
|
62
62
|
constructor(host: SessionIndexHost);
|
|
63
|
-
/** Sets the index up for the client of `initialize`.
|
|
64
|
-
|
|
65
|
-
negotiate(request: InitializeRequest, options: {
|
|
66
|
-
v2: boolean;
|
|
67
|
-
}): void;
|
|
63
|
+
/** Sets the index up for the client of `initialize`. */
|
|
64
|
+
negotiate(request: InitializeRequest): void;
|
|
68
65
|
/** A stored title as the client shows it: an AIR client gets the title
|
|
69
66
|
* of an archived session without the archive prefix, as in its list;
|
|
70
67
|
* every other client the title as stored. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/session-index/connection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAC1B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAalE,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAYL,mBAAmB,EACnB,KAAK,oBAAoB,EAEzB,KAAK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,mBAAmB,GAAG;IACzB,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACrF,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACnF,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC/E,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzE,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACjE,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CACpE,CAAC;AAEF;sEACsE;AACtE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,GAAG,QAAQ,CAgChG"}
|
|
@@ -34,13 +34,11 @@ export class SessionIndexConnection {
|
|
|
34
34
|
constructor(host) {
|
|
35
35
|
this.host = host;
|
|
36
36
|
}
|
|
37
|
-
/** Sets the index up for the client of `initialize`.
|
|
38
|
-
|
|
39
|
-
negotiate(request, options) {
|
|
37
|
+
/** Sets the index up for the client of `initialize`. */
|
|
38
|
+
negotiate(request) {
|
|
40
39
|
this.service?.dispose();
|
|
41
40
|
this.service = undefined;
|
|
42
|
-
if (
|
|
43
|
-
this.host.isAirClient() &&
|
|
41
|
+
if (this.host.isAirClient() &&
|
|
44
42
|
clientSupportsAirCapability(request.clientCapabilities, AIR_SESSION_INDEX_CAPABILITY)) {
|
|
45
43
|
this.service = new SessionIndexService({
|
|
46
44
|
ownSessionState: (sessionId) => this.ownSessionState(sessionId),
|
package/dist/session-mode.d.ts
CHANGED
|
@@ -102,5 +102,6 @@ export declare class SessionModeManager<S extends SessionMode> {
|
|
|
102
102
|
private parseMode;
|
|
103
103
|
private trySyncMode;
|
|
104
104
|
}
|
|
105
|
+
export declare function buildAvailableModes({ allowBypass, allowAuto }: ModeAvailability, air?: boolean): SessionModeState["availableModes"];
|
|
105
106
|
export {};
|
|
106
107
|
//# sourceMappingURL=session-mode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-mode.d.ts","sourceRoot":"","sources":["../src/session-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,KAAK,EACN,MAAM,gCAAgC,CAAC;AAUxC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,kBAAkB,EAAE,cAA8B,CAAC;AAYhE,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;IACxC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC;IACxB,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;IACnC,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,8EAA8E;IAC9E,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gFAAgF;IAChF,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,WAAW,IAAI;IAC7D,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAC7C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAA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AS,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAKlF,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,SAAS;YAcH,WAAW;CAW1B;AAED,wBAAgB,mBAAmB,CACjC,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,gBAAgB,EAC5C,GAAG,UAAQ,GACV,gBAAgB,CAAC,gBAAgB,CAAC,CA2CpC"}
|
package/dist/session-mode.js
CHANGED
|
@@ -261,7 +261,7 @@ export class SessionModeManager {
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
|
-
function buildAvailableModes({ allowBypass, allowAuto }, air = false) {
|
|
264
|
+
export function buildAvailableModes({ allowBypass, allowAuto }, air = false) {
|
|
265
265
|
// Only AIR gets the mode kind.
|
|
266
266
|
const kind = (value) => {
|
|
267
267
|
const meta = airOnlyMeta(air, AIR_KIND_KEY, value);
|
package/dist/session-model.d.ts
CHANGED
|
@@ -16,6 +16,18 @@ type ModelLogger = {
|
|
|
16
16
|
type ModelSettingsSource = {
|
|
17
17
|
getSettings(): Settings;
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* The entry of `models` that `preference` names, or null when it names none.
|
|
21
|
+
* `best` names the entry `opus` resolves to, unless an entry's value is `best`.
|
|
22
|
+
* In order: an entry whose value, display name or `resolvedModel` equals it
|
|
23
|
+
* (in either context-hint spelling); an entry whose value or display name
|
|
24
|
+
* contains its words ("opus" for "claude-opus-4-5"), or whose value it
|
|
25
|
+
* contains while every model word of the preference is the entry's
|
|
26
|
+
* ("sonnet" for "us.anthropic.claude-sonnet-5-v1:0"); then any entry with all
|
|
27
|
+
* of its model words, preferring one with the same context hint ("sonnet[1m]"
|
|
28
|
+
* for "claude-sonnet-5-1m"). The fuzzy tiers need a compatible version, and
|
|
29
|
+
* words match whole: "not-a-model", "son" and "foo-sonnet" name no entry.
|
|
30
|
+
*/
|
|
19
31
|
export declare function resolveModelPreference(models: ModelInfo[], preference: string): ModelInfo | null;
|
|
20
32
|
export declare function matchResumedModel(models: ModelInfo[], liveModel: string): ModelInfo;
|
|
21
33
|
export declare function buildModelConfigOption(models: SessionModelState, modelInfos: ModelInfo[], useRecommendedValue: boolean): SessionConfigOption;
|
|
@@ -88,6 +100,35 @@ export declare function applyAvailableModelsAllowlist(sdkModels: ModelInfo[], al
|
|
|
88
100
|
* models, and nothing is left: the session offers no model.
|
|
89
101
|
*/
|
|
90
102
|
export declare function narrowToGatewayModels(models: ModelInfo[], listedModelIds: readonly string[], regionPrefix?: string): ModelInfo[];
|
|
103
|
+
/**
|
|
104
|
+
* The capabilities of the session's current model, and the model infos that
|
|
105
|
+
* every later lookup reads.
|
|
106
|
+
*
|
|
107
|
+
* A resumed session can be running a model outside the `availableModels`
|
|
108
|
+
* allowlist (currentModelId is then the verbatim live id, see
|
|
109
|
+
* `matchResumedModel`); its capabilities are still known to the SDK's
|
|
110
|
+
* unfiltered list, so they are resolved from that before the model is treated
|
|
111
|
+
* as unknown — otherwise auto mode would be spuriously clamped and the
|
|
112
|
+
* Fast-mode/Effort options hidden for a model that supports them.
|
|
113
|
+
*
|
|
114
|
+
* The fallback-resolved capabilities are registered under the verbatim live
|
|
115
|
+
* id, so every modelInfos consumer (the effort option, later rebuilds) agrees
|
|
116
|
+
* with that gating. `buildModelConfigOption` lists this model as its own
|
|
117
|
+
* entry while it is current and drops it once the user switches to a listed
|
|
118
|
+
* model; it is never added to `availableModels`. The spread keeps every
|
|
119
|
+
* capability flag (current and future); the identity fields are overridden
|
|
120
|
+
* because the fuzzy-matched sibling's resolvedModel/displayName/description
|
|
121
|
+
* can describe a different context lane and would poison later resolvedModel
|
|
122
|
+
* matching (a model switch that the adapter did not make) and context-window
|
|
123
|
+
* inference if they traveled under this id. `allowlistedModelInfo` is the
|
|
124
|
+
* allowlisted entry alone, the only one whose identity strings are a
|
|
125
|
+
* trustworthy window signal.
|
|
126
|
+
*/
|
|
127
|
+
export declare function withCurrentModelInfo(allowedModels: ModelInfo[], sdkModels: ModelInfo[], currentModelId: string): {
|
|
128
|
+
allowlistedModelInfo: ModelInfo | undefined;
|
|
129
|
+
currentModelInfo: ModelInfo | undefined;
|
|
130
|
+
modelInfos: ModelInfo[];
|
|
131
|
+
};
|
|
91
132
|
export declare function getAvailableModels(query: Query, models: ModelInfo[], sdkModels: ModelInfo[], settingsManager: ModelSettingsSource, logger: ModelLogger, isResumedSession: boolean, sessionId: string, resumedModelHint?: string, narrowedByGateway?: boolean): Promise<SessionModelState>;
|
|
92
133
|
/** The display name of the model id `model` in `modelInfos`, if it is there. */
|
|
93
134
|
export declare function modelDisplayName(modelInfos: ModelInfo[], model: string): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-model.d.ts","sourceRoot":"","sources":["../src/session-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAIjF,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChF,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IAClC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACrC,CAAC;AACF,KAAK,mBAAmB,GAAG;IAAE,WAAW,IAAI,QAAQ,CAAA;CAAE,CA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MAAM,GAAG,SAAS,CAQ3F;AAaD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC3B,aAAa,EAAE,SAAS,mBAAmB,EAAE,EAC7C,UAAU,EAAE,SAAS,EAAE,EACvB,KAAK,EAAE,MAAM,GACZ;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAW7C"}
|
package/dist/session-model.js
CHANGED
|
@@ -64,42 +64,71 @@ function versionedModelDisplayName(model) {
|
|
|
64
64
|
// Keep the suffix in its original spelling and insert the version before it.
|
|
65
65
|
return `${withoutContext} ${version}${contextSuffix[0]}`;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const tokens = lower
|
|
71
|
-
.replace(MODEL_CONTEXT_HINT_PATTERN, " $1 ")
|
|
67
|
+
function modelWords(value) {
|
|
68
|
+
return value
|
|
69
|
+
.toLowerCase()
|
|
72
70
|
.split(/[^a-z0-9]+/)
|
|
73
|
-
.filter(Boolean)
|
|
74
|
-
.map((token) => {
|
|
75
|
-
if (token === "opusplan")
|
|
76
|
-
return "opus";
|
|
77
|
-
if (token === "best" || token === "default")
|
|
78
|
-
return "";
|
|
79
|
-
return token;
|
|
80
|
-
})
|
|
81
|
-
.filter((token) => token && token !== "claude")
|
|
82
|
-
.filter((token) => /[a-z]/.test(token) || token.endsWith("m"));
|
|
83
|
-
return { tokens, contextHint };
|
|
71
|
+
.filter(Boolean);
|
|
84
72
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
73
|
+
/** Whether `needle`'s words appear in `haystack`'s words, adjacent and in
|
|
74
|
+
* order: "opus" in "claude-opus-4-5", but not "son" in "sonnet" or "a" in
|
|
75
|
+
* "Default (recommended)". */
|
|
76
|
+
function containsWords(haystack, needle) {
|
|
77
|
+
const words = modelWords(haystack);
|
|
78
|
+
const wanted = modelWords(needle);
|
|
79
|
+
if (wanted.length === 0)
|
|
80
|
+
return false;
|
|
81
|
+
for (let start = 0; start + wanted.length <= words.length; start++) {
|
|
82
|
+
if (wanted.every((word, offset) => words[start + offset] === word))
|
|
83
|
+
return true;
|
|
95
84
|
}
|
|
96
|
-
return
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
/** `id` without the gateway spellings that `normalizeModelId` keeps for
|
|
88
|
+
* `deniedModels` and gateway listings: path segments before `claude-`
|
|
89
|
+
* (`vertex_ai/`, `openrouter/anthropic/`, `publishers/anthropic/models/`)
|
|
90
|
+
* and the Anthropic API's `-latest` suffix (`claude-3-5-haiku-latest`). */
|
|
91
|
+
function withoutGatewaySpelling(id) {
|
|
92
|
+
return id.replace(/^(?:[^/]+\/)+(?=claude-)/, "").replace(/-latest$/, "");
|
|
93
|
+
}
|
|
94
|
+
/** The words of `preference` that name a model: without what
|
|
95
|
+
* `normalizeModelId` drops (provider prefixes, dates, `-v1:0`, `-fast`,
|
|
96
|
+
* context hints), version numbers, "claude", and "best"/"default".
|
|
97
|
+
* "us.anthropic.claude-sonnet-4-5-v1:0" gives ["sonnet"], "opusplan" gives
|
|
98
|
+
* ["opus"]. */
|
|
99
|
+
function modelPreferenceTokens(preference) {
|
|
100
|
+
return modelWords(withoutGatewaySpelling(normalizeModelId(preference)))
|
|
101
|
+
.map((token) => (token === "opusplan" ? "opus" : token))
|
|
102
|
+
.filter((token) => /[a-z]/.test(token) && !["claude", "best", "default"].includes(token));
|
|
103
|
+
}
|
|
104
|
+
/** Whether every one of `tokens` is a word of `model`'s value or display name. */
|
|
105
|
+
function modelCoversTokens(model, tokens) {
|
|
106
|
+
const words = new Set(modelWords(`${model.value} ${model.displayName}`));
|
|
107
|
+
return tokens.length > 0 && tokens.every((token) => words.has(token));
|
|
97
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The entry of `models` that `preference` names, or null when it names none.
|
|
111
|
+
* `best` names the entry `opus` resolves to, unless an entry's value is `best`.
|
|
112
|
+
* In order: an entry whose value, display name or `resolvedModel` equals it
|
|
113
|
+
* (in either context-hint spelling); an entry whose value or display name
|
|
114
|
+
* contains its words ("opus" for "claude-opus-4-5"), or whose value it
|
|
115
|
+
* contains while every model word of the preference is the entry's
|
|
116
|
+
* ("sonnet" for "us.anthropic.claude-sonnet-5-v1:0"); then any entry with all
|
|
117
|
+
* of its model words, preferring one with the same context hint ("sonnet[1m]"
|
|
118
|
+
* for "claude-sonnet-5-1m"). The fuzzy tiers need a compatible version, and
|
|
119
|
+
* words match whole: "not-a-model", "son" and "foo-sonnet" name no entry.
|
|
120
|
+
*/
|
|
98
121
|
export function resolveModelPreference(models, preference) {
|
|
99
122
|
const trimmed = preference.trim();
|
|
100
123
|
if (!trimmed)
|
|
101
124
|
return null;
|
|
102
125
|
const lower = trimmed.toLowerCase();
|
|
126
|
+
// The CLI resolves `best` to its flagship: Opus, unless a server-side flag
|
|
127
|
+
// names another family that this adapter cannot read. The CLI ignores a
|
|
128
|
+
// `[1m]` hint on `best`. A listed entry named `best` still matches directly.
|
|
129
|
+
if (stripContextHints(lower) === "best" && !models.some((model) => model.value === trimmed)) {
|
|
130
|
+
return resolveModelPreference(models, "opus");
|
|
131
|
+
}
|
|
103
132
|
const canonicalPreference = canonicalizeModelId(trimmed);
|
|
104
133
|
const directMatch = models.find((model) => model.value === trimmed ||
|
|
105
134
|
canonicalizeModelId(model.value) === canonicalPreference ||
|
|
@@ -112,32 +141,22 @@ export function resolveModelPreference(models, preference) {
|
|
|
112
141
|
if (resolvedMatch)
|
|
113
142
|
return resolvedMatch;
|
|
114
143
|
const preferenceHint = contextHintOf(trimmed);
|
|
144
|
+
const tokens = modelPreferenceTokens(trimmed);
|
|
115
145
|
const includesMatch = models.find((model) => {
|
|
116
146
|
if (!modelVersionsCompatible(trimmed, model))
|
|
117
147
|
return false;
|
|
118
148
|
if (contextHintOf(model.value) !== preferenceHint)
|
|
119
149
|
return false;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
150
|
+
return (containsWords(model.value, trimmed) ||
|
|
151
|
+
containsWords(model.displayName, trimmed) ||
|
|
152
|
+
(containsWords(trimmed, model.value) && modelCoversTokens(model, tokens)));
|
|
123
153
|
});
|
|
124
154
|
if (includesMatch)
|
|
125
155
|
return includesMatch;
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
let bestScore = 0;
|
|
131
|
-
for (const model of models) {
|
|
132
|
-
if (!modelVersionsCompatible(trimmed, model))
|
|
133
|
-
continue;
|
|
134
|
-
const score = scoreModelMatch(model, tokens, contextHint);
|
|
135
|
-
if (score > 0 && (!bestMatch || score > bestScore)) {
|
|
136
|
-
bestMatch = model;
|
|
137
|
-
bestScore = score;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return bestMatch;
|
|
156
|
+
const candidates = models.filter((model) => modelVersionsCompatible(trimmed, model) && modelCoversTokens(model, tokens));
|
|
157
|
+
return (candidates.find((model) => contextHintOf(model.value) === preferenceHint) ??
|
|
158
|
+
candidates[0] ??
|
|
159
|
+
null);
|
|
141
160
|
}
|
|
142
161
|
export function matchResumedModel(models, liveModel) {
|
|
143
162
|
const live = canonicalizeModelId(liveModel);
|
|
@@ -447,6 +466,52 @@ export function narrowToGatewayModels(models, listedModelIds, regionPrefix) {
|
|
|
447
466
|
? narrowed
|
|
448
467
|
: [];
|
|
449
468
|
}
|
|
469
|
+
/**
|
|
470
|
+
* The capabilities of the session's current model, and the model infos that
|
|
471
|
+
* every later lookup reads.
|
|
472
|
+
*
|
|
473
|
+
* A resumed session can be running a model outside the `availableModels`
|
|
474
|
+
* allowlist (currentModelId is then the verbatim live id, see
|
|
475
|
+
* `matchResumedModel`); its capabilities are still known to the SDK's
|
|
476
|
+
* unfiltered list, so they are resolved from that before the model is treated
|
|
477
|
+
* as unknown — otherwise auto mode would be spuriously clamped and the
|
|
478
|
+
* Fast-mode/Effort options hidden for a model that supports them.
|
|
479
|
+
*
|
|
480
|
+
* The fallback-resolved capabilities are registered under the verbatim live
|
|
481
|
+
* id, so every modelInfos consumer (the effort option, later rebuilds) agrees
|
|
482
|
+
* with that gating. `buildModelConfigOption` lists this model as its own
|
|
483
|
+
* entry while it is current and drops it once the user switches to a listed
|
|
484
|
+
* model; it is never added to `availableModels`. The spread keeps every
|
|
485
|
+
* capability flag (current and future); the identity fields are overridden
|
|
486
|
+
* because the fuzzy-matched sibling's resolvedModel/displayName/description
|
|
487
|
+
* can describe a different context lane and would poison later resolvedModel
|
|
488
|
+
* matching (a model switch that the adapter did not make) and context-window
|
|
489
|
+
* inference if they traveled under this id. `allowlistedModelInfo` is the
|
|
490
|
+
* allowlisted entry alone, the only one whose identity strings are a
|
|
491
|
+
* trustworthy window signal.
|
|
492
|
+
*/
|
|
493
|
+
export function withCurrentModelInfo(allowedModels, sdkModels, currentModelId) {
|
|
494
|
+
const allowlistedModelInfo = allowedModels.find((m) => m.value === currentModelId);
|
|
495
|
+
const fallbackModelInfo = allowlistedModelInfo
|
|
496
|
+
? undefined
|
|
497
|
+
: (resolveModelPreference(sdkModels, currentModelId) ?? undefined);
|
|
498
|
+
return {
|
|
499
|
+
allowlistedModelInfo,
|
|
500
|
+
currentModelInfo: allowlistedModelInfo ?? fallbackModelInfo,
|
|
501
|
+
modelInfos: fallbackModelInfo
|
|
502
|
+
? [
|
|
503
|
+
...allowedModels,
|
|
504
|
+
{
|
|
505
|
+
...fallbackModelInfo,
|
|
506
|
+
value: currentModelId,
|
|
507
|
+
displayName: currentModelId,
|
|
508
|
+
description: "",
|
|
509
|
+
resolvedModel: undefined,
|
|
510
|
+
},
|
|
511
|
+
]
|
|
512
|
+
: allowedModels,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
450
515
|
/** Whether a rejected `setModel` was vetoed by a user-configured
|
|
451
516
|
* PreModelSwitch hook. The CLI's rejection message is the stable,
|
|
452
517
|
* distinguishable marker ("Model switch blocked by a PreModelSwitch hook:
|
|
@@ -48,4 +48,48 @@ export declare function noticePlainText(text: string): string;
|
|
|
48
48
|
* first line stands as the title when it is short enough, otherwise the whole
|
|
49
49
|
* text becomes the description under `fallbackTitle`. */
|
|
50
50
|
export declare function splitNoticeText(text: string, fallbackTitle: string): Pick<SessionNotice, "title" | "description">;
|
|
51
|
+
/** The notice of Claude Code's `informational` message (e.g. why a Stop hook
|
|
52
|
+
* blocked continuation): a warning at level `warning`, else info. */
|
|
53
|
+
export declare function informationalNotice(message: {
|
|
54
|
+
level: string;
|
|
55
|
+
content: string;
|
|
56
|
+
}): SessionNotice;
|
|
57
|
+
/** The notice of a client MCP server that the `system/init` lists as not
|
|
58
|
+
* started: `failed`, or `needs-auth` when the client cannot run the OAuth
|
|
59
|
+
* flow (`oauthAvailable`). Undefined for any other status. */
|
|
60
|
+
export declare function mcpServerStartupNotice(server: {
|
|
61
|
+
name: string;
|
|
62
|
+
status: string;
|
|
63
|
+
}, oauthAvailable: boolean): SessionNotice | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* What Claude Code's `model_refusal_fallback` tells the user: the SDK retried
|
|
66
|
+
* a refused turn on the fallback model.
|
|
67
|
+
*
|
|
68
|
+
* Current CLIs only emit direction "retry", a swap that lasts for the
|
|
69
|
+
* session. "revert"/"sticky" are retained in the SDK enum for older CLIs,
|
|
70
|
+
* where "revert" marked a turn-only fallback: the session stays on the
|
|
71
|
+
* original model. `scope` (CLI 2.1.232+) "local" means a subagent,
|
|
72
|
+
* side-question or background fork response fell back and the session model
|
|
73
|
+
* is unchanged. Absent scope means an older CLI, where every retry was a
|
|
74
|
+
* session-level swap. `persistent` is whether the session now runs
|
|
75
|
+
* `fallback_model`, so its model option must follow.
|
|
76
|
+
*/
|
|
77
|
+
export declare function modelRefusalFallback(message: {
|
|
78
|
+
original_model: string;
|
|
79
|
+
fallback_model: string;
|
|
80
|
+
direction?: string;
|
|
81
|
+
scope?: string;
|
|
82
|
+
api_refusal_category?: string | null;
|
|
83
|
+
api_refusal_explanation?: string | null;
|
|
84
|
+
}): {
|
|
85
|
+
persistent: boolean;
|
|
86
|
+
/** The one-line summary. */
|
|
87
|
+
summary: string;
|
|
88
|
+
explanation: string | undefined;
|
|
89
|
+
/** The notice: the summary as its title when it is short enough, else a
|
|
90
|
+
* generic title with everything in the description. */
|
|
91
|
+
notice: SessionNotice;
|
|
92
|
+
/** The transcript line for a client without `notice` updates. */
|
|
93
|
+
transcript: string;
|
|
94
|
+
};
|
|
51
95
|
//# sourceMappingURL=session-notices.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-notices.d.ts","sourceRoot":"","sources":["../src/session-notices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAEjG;;8DAE8D;AAC9D,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACvC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;kEACkE;AAClE,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;oEAEoE;AACpE,wBAAgB,qBAAqB,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CAGvF;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAOjF;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAElE;AAED;;;gFAGgF;AAChF,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,aAAa,EACrB,eAAe,EAAE,OAAO,EACxB,cAAc,GAAE,MAAqC,EACrD,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,G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