@lucascouts/claude-agent-tui 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/acp-agent.d.ts +95 -3
- package/dist/acp-agent.js +248 -7
- package/dist/index.js +20 -2
- package/dist/model-catalog.d.ts +80 -21
- package/dist/model-catalog.js +178 -40
- package/dist/tools.d.ts +3 -1
- package/dist/tools.js +266 -10
- package/package.json +10 -10
package/dist/model-catalog.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ModelInfo } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import type { ClientCapabilities, SessionConfigOption } from "@agentclientprotocol/sdk";
|
|
2
3
|
/**
|
|
3
4
|
* Effort levels offered for reasoning-capable models — the SDK's `supportedEffortLevels` vocabulary.
|
|
4
5
|
* Story 060: exported so the ultracode guard test can assert membership stays the five real levels
|
|
@@ -21,30 +22,32 @@ export declare const ULTRACODE_EFFORT_LABEL = "ultracode (xhigh + orchestration)
|
|
|
21
22
|
* `claude` TUI alias accepted by `/model <alias>` (live) and `--model <alias>` (spawn). `default` is
|
|
22
23
|
* first and is the safe fallback.
|
|
23
24
|
*
|
|
24
|
-
* ORDER + membership
|
|
25
|
-
* `
|
|
26
|
-
*
|
|
27
|
-
* `sonnet[1m]`
|
|
28
|
-
*
|
|
25
|
+
* ORDER + membership: `Default (recommended)`, `Fable 5`, `Opus`, `Sonnet`, `Haiku`. The original gets
|
|
26
|
+
* its list from the SDK `supportedModels()` the fork cut, so we curate it statically. `fable5` (`/model
|
|
27
|
+
* fable5` — the Claude 5 family's top model, released 2026-07-01) sits right after `default`. The
|
|
28
|
+
* redundant `sonnet[1m]` alias was dropped: Sonnet 5 is natively 1M, so plain `sonnet` already IS the 1M
|
|
29
|
+
* model. The fork-only `opusplan` extra was dropped too (three Sonnet-flavored entries + inconsistent
|
|
30
|
+
* Opus thinking made it more confusing than useful).
|
|
29
31
|
*
|
|
30
|
-
* Effort-capable models (`default`/`opus`/`sonnet
|
|
31
|
-
* `supportedEffortLevels`; `haiku
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* Effort-capable models (`default`/`fable5`/`opus`/`sonnet`) carry `supportsEffort` +
|
|
33
|
+
* `supportedEffortLevels`; `haiku` advertises none. `supportsAutoMode: true` on the same four surfaces
|
|
34
|
+
* the `auto` permission mode (a model classifier) — the original drops `auto` on `haiku` (the SDK signal
|
|
35
|
+
* `reconcileModeFromTranscript` clamps), so haiku omits it.
|
|
34
36
|
*/
|
|
35
37
|
export declare const MODEL_CATALOG: ModelInfo[];
|
|
36
38
|
/**
|
|
37
39
|
* Story 068 (R1, R1.1, R2) — the REAL per-alias context window, keyed by the EXACT {@link MODEL_CATALOG}
|
|
38
|
-
* `value`. These windows are NOT uniform: `opus`
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
40
|
+
* `value`. These windows are NOT uniform: `default`/`fable5`/`opus`/`sonnet` are natively 1M and `haiku`
|
|
41
|
+
* is 200K. This map is the single source of truth that `inferContextWindowFromModel` (acp-agent.ts)
|
|
42
|
+
* consults BEFORE the `\b1m\b` regex fallback — the bug it fixes is `opus` having wrongly reported 200K
|
|
43
|
+
* (the regex only ever matched the literal `1m` token).
|
|
42
44
|
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* `sonnet` seeds to 1M because plain `sonnet` now resolves to Sonnet 5, which is natively 1M (the
|
|
46
|
+
* redundant `sonnet[1m]` alias was dropped). `default` is the recommended Opus (the claude TUI's `/model
|
|
47
|
+
* default` resolves to `claude-opus-4-8[1m]`, a 1M model) and `fable5` is Fable 5 (1M). This is only the
|
|
48
|
+
* PRE-FIRST-TURN seed: once a turn arrives, `inferContextWindowFromModelId` (story 069) AUTHORITATIVELY
|
|
49
|
+
* refines the window from the transcript's real `model`. Keys MIRROR `MODEL_CATALOG` `value`s; the drift
|
|
50
|
+
* guard lives in the test (068 anti-drift: every catalog value has an explicit entry).
|
|
48
51
|
*/
|
|
49
52
|
export declare const MODEL_CONTEXT_WINDOWS: Record<string, number>;
|
|
50
53
|
/**
|
|
@@ -63,14 +66,70 @@ export declare const MODEL_ID_CONTEXT_WINDOWS: Record<string, number>;
|
|
|
63
66
|
* cannot derive the concrete version (the SDK `supportedModels()` was cut), so these MIRROR the LIVE
|
|
64
67
|
* picker and MUST be re-verified on each model launch (source: the user's live `/model` output). The
|
|
65
68
|
* static tagline stays on `ModelInfo.description` (069 R3 untouched); this only prepends "<version> · ".
|
|
66
|
-
*
|
|
67
|
-
*
|
|
69
|
+
* Every current catalog entry carries a label; the no-label branch in {@link modelSelectorDescription}
|
|
70
|
+
* stays as a total-function safeguard for any future label-less entry.
|
|
68
71
|
*/
|
|
69
72
|
export declare const MODEL_VERSION_LABELS: Record<string, string>;
|
|
70
73
|
/**
|
|
71
74
|
* Story 072 — compose the Zed selector description: "<version label> · <tagline>", or the bare tagline
|
|
72
|
-
* when no label exists
|
|
75
|
+
* when no label exists. PURE + TOTAL: never throws on a missing label or tagline.
|
|
73
76
|
*/
|
|
74
77
|
export declare function modelSelectorDescription(info: ModelInfo): string;
|
|
78
|
+
/**
|
|
79
|
+
* Story 073 (R5.1) — the catalog `value`s that support fast mode (`/fast on|off`). Fast mode "uses
|
|
80
|
+
* Claude Opus with faster output (it does not downgrade to a smaller model)" and is available on Opus
|
|
81
|
+
* 4.8/4.7 only; the CLI turns it off when switching to a non-Opus model. `default` resolves to the
|
|
82
|
+
* recommended Opus, so both `default` and `opus` qualify; `fable5`/`sonnet`/`haiku` do NOT.
|
|
83
|
+
*
|
|
84
|
+
* Kept HERE (not on {@link ModelInfo}) because `ModelInfo` is the SDK shape and cannot carry a
|
|
85
|
+
* fork-only `supportsFastMode` field — the same reason the effort/auto flags that DO exist on the SDK
|
|
86
|
+
* type live inline while this predicate is external.
|
|
87
|
+
*/
|
|
88
|
+
export declare const FAST_MODE_MODELS: ReadonlySet<string>;
|
|
89
|
+
/** Story 073 (R5.1) — true when the catalog `value` is an Opus alias that supports fast mode. */
|
|
90
|
+
export declare function isFastModeCapableModel(value: string): boolean;
|
|
91
|
+
/** Story 074 (R4.2) — the fork's fast-mode config-option id, replacing the inline `"fast"` literal. */
|
|
92
|
+
export declare const FAST_MODE_CONFIG_ID = "fast";
|
|
93
|
+
/** Story 074 (R4.2) — the on/off select values, replacing the inline `"on"`/`"off"` literals. */
|
|
94
|
+
export declare const FAST_MODE_ON = "on";
|
|
95
|
+
export declare const FAST_MODE_OFF = "off";
|
|
96
|
+
/**
|
|
97
|
+
* Story 074 (R4.1) — did the client advertise support for boolean session config options
|
|
98
|
+
* (`clientCapabilities.session.configOptions.boolean`)? A present (non-null) object — even `{}` —
|
|
99
|
+
* means the agent may emit `type:"boolean"` entries and the client may send boolean `set_config_option`
|
|
100
|
+
* values. Read from the `initialize()`-stored capabilities; NO createSession/prompt touch (R4.5).
|
|
101
|
+
*/
|
|
102
|
+
export declare function clientSupportsBooleanConfigOptions(caps?: ClientCapabilities | null): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Story 074 (R4.3) — resolve the intended fast-mode ENABLED state from a `set_config_option` payload
|
|
105
|
+
* that may be a boolean (a client using the boolean option) OR the `"on"`/`"off"` string (the select
|
|
106
|
+
* fallback). Any non-`"on"` string (and any other shape) resolves to OFF — a toggle never half-applies.
|
|
107
|
+
*/
|
|
108
|
+
export declare function resolveFastModeEnabled(value: unknown): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Story 074 (R4.1) — build the `fast` config option. Emits `type:"boolean"` (currentValue tracks the
|
|
111
|
+
* toggle) when the client advertised boolean config options, else the `on`/`off` select fallback. The
|
|
112
|
+
* external ACP `id` and on/off values are unchanged from story 073; only the type negotiation aligns
|
|
113
|
+
* with upstream #828. The PTY `/fast on|off` inject mechanism and the FAST_MODE_MODELS gate are kept.
|
|
114
|
+
*/
|
|
115
|
+
export declare function createFastModeConfigOption(enabled: boolean, useBooleanOption: boolean): SessionConfigOption;
|
|
116
|
+
/**
|
|
117
|
+
* Story 073 (R1) — the verdict of parsing the `/fast` panel captured from the live PTY:
|
|
118
|
+
* - `"available"` — the panel rendered its On/Off toggle (no gate line) → advertise the toggle.
|
|
119
|
+
* - `"unavailable"` — the panel rendered a gate line ("requires usage credits", etc.) → omit it.
|
|
120
|
+
* - `"pending"` — the panel has not fully rendered yet (or is still checking) → keep waiting; the
|
|
121
|
+
* caller fails CLOSED (treats it as unavailable) once its bounded window elapses.
|
|
122
|
+
*/
|
|
123
|
+
export type FastModeSignal = "available" | "unavailable" | "pending";
|
|
124
|
+
/**
|
|
125
|
+
* Story 073 (R1) — classify the `/fast` panel text captured from the live PTY into a {@link FastModeSignal}.
|
|
126
|
+
*
|
|
127
|
+
* Pure and side-effect free so it is unit-testable against the spike's live capture; the live PTY drive
|
|
128
|
+
* that FEEDS it lives behind the `FastModeProbe` seam (acp-agent `defaultFastModeProbe`). Order matters:
|
|
129
|
+
* pending is checked first (its text also matches a gate substring), then the gate markers, then — only
|
|
130
|
+
* once the panel anchor confirms a full render with NO gate line — `available`. Anything else is
|
|
131
|
+
* `pending`, and the caller fails closed on timeout (R1.2).
|
|
132
|
+
*/
|
|
133
|
+
export declare function classifyFastModeSignal(raw: string): FastModeSignal;
|
|
75
134
|
/** The safe fallback entry, kept as a named export so callers can seed/anchor on it without a lookup. */
|
|
76
135
|
export declare const DEFAULT_MODEL_INFO: ModelInfo;
|
package/dist/model-catalog.js
CHANGED
|
@@ -26,16 +26,17 @@ export const ULTRACODE_EFFORT_LABEL = "ultracode (xhigh + orchestration)";
|
|
|
26
26
|
* `claude` TUI alias accepted by `/model <alias>` (live) and `--model <alias>` (spawn). `default` is
|
|
27
27
|
* first and is the safe fallback.
|
|
28
28
|
*
|
|
29
|
-
* ORDER + membership
|
|
30
|
-
* `
|
|
31
|
-
*
|
|
32
|
-
* `sonnet[1m]`
|
|
33
|
-
*
|
|
29
|
+
* ORDER + membership: `Default (recommended)`, `Fable 5`, `Opus`, `Sonnet`, `Haiku`. The original gets
|
|
30
|
+
* its list from the SDK `supportedModels()` the fork cut, so we curate it statically. `fable5` (`/model
|
|
31
|
+
* fable5` — the Claude 5 family's top model, released 2026-07-01) sits right after `default`. The
|
|
32
|
+
* redundant `sonnet[1m]` alias was dropped: Sonnet 5 is natively 1M, so plain `sonnet` already IS the 1M
|
|
33
|
+
* model. The fork-only `opusplan` extra was dropped too (three Sonnet-flavored entries + inconsistent
|
|
34
|
+
* Opus thinking made it more confusing than useful).
|
|
34
35
|
*
|
|
35
|
-
* Effort-capable models (`default`/`opus`/`sonnet
|
|
36
|
-
* `supportedEffortLevels`; `haiku
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* Effort-capable models (`default`/`fable5`/`opus`/`sonnet`) carry `supportsEffort` +
|
|
37
|
+
* `supportedEffortLevels`; `haiku` advertises none. `supportsAutoMode: true` on the same four surfaces
|
|
38
|
+
* the `auto` permission mode (a model classifier) — the original drops `auto` on `haiku` (the SDK signal
|
|
39
|
+
* `reconcileModeFromTranscript` clamps), so haiku omits it.
|
|
39
40
|
*/
|
|
40
41
|
export const MODEL_CATALOG = [
|
|
41
42
|
{
|
|
@@ -47,6 +48,18 @@ export const MODEL_CATALOG = [
|
|
|
47
48
|
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
48
49
|
supportsAutoMode: true,
|
|
49
50
|
},
|
|
51
|
+
{
|
|
52
|
+
value: "fable5",
|
|
53
|
+
// Bare family name in the title (like Opus/Sonnet/Haiku); the "Fable 5" version lives in the
|
|
54
|
+
// MODEL_VERSION_LABELS prefix that composes the selector description.
|
|
55
|
+
displayName: "Fable",
|
|
56
|
+
// Fable 5 (Claude 5 family, released 2026-07-01) — the most advanced generally available model.
|
|
57
|
+
// Description verbatim from the live `/model` picker of the interactive `claude` CLI.
|
|
58
|
+
description: "Most capable for your hardest and longest-running tasks",
|
|
59
|
+
supportsEffort: true,
|
|
60
|
+
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
61
|
+
supportsAutoMode: true,
|
|
62
|
+
},
|
|
50
63
|
{
|
|
51
64
|
value: "opus",
|
|
52
65
|
displayName: "Opus",
|
|
@@ -63,46 +76,32 @@ export const MODEL_CATALOG = [
|
|
|
63
76
|
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
64
77
|
supportsAutoMode: true,
|
|
65
78
|
},
|
|
66
|
-
{
|
|
67
|
-
value: "sonnet[1m]",
|
|
68
|
-
displayName: "Sonnet (1M context)",
|
|
69
|
-
// Story 069 (R3): fork-only 1M variant — the Sonnet description plus its 1M-window note.
|
|
70
|
-
description: "Efficient for routine tasks, with a 1M-token context window",
|
|
71
|
-
supportsEffort: true,
|
|
72
|
-
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
73
|
-
supportsAutoMode: true,
|
|
74
|
-
},
|
|
75
79
|
{
|
|
76
80
|
value: "haiku",
|
|
77
81
|
displayName: "Haiku",
|
|
78
82
|
description: "Fastest for quick answers",
|
|
79
83
|
},
|
|
80
|
-
{
|
|
81
|
-
value: "opusplan",
|
|
82
|
-
displayName: "Opus Plan Mode",
|
|
83
|
-
description: "Use Opus in plan mode, Sonnet otherwise",
|
|
84
|
-
},
|
|
85
84
|
];
|
|
86
85
|
/**
|
|
87
86
|
* Story 068 (R1, R1.1, R2) — the REAL per-alias context window, keyed by the EXACT {@link MODEL_CATALOG}
|
|
88
|
-
* `value`. These windows are NOT uniform: `opus`
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
87
|
+
* `value`. These windows are NOT uniform: `default`/`fable5`/`opus`/`sonnet` are natively 1M and `haiku`
|
|
88
|
+
* is 200K. This map is the single source of truth that `inferContextWindowFromModel` (acp-agent.ts)
|
|
89
|
+
* consults BEFORE the `\b1m\b` regex fallback — the bug it fixes is `opus` having wrongly reported 200K
|
|
90
|
+
* (the regex only ever matched the literal `1m` token).
|
|
92
91
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
92
|
+
* `sonnet` seeds to 1M because plain `sonnet` now resolves to Sonnet 5, which is natively 1M (the
|
|
93
|
+
* redundant `sonnet[1m]` alias was dropped). `default` is the recommended Opus (the claude TUI's `/model
|
|
94
|
+
* default` resolves to `claude-opus-4-8[1m]`, a 1M model) and `fable5` is Fable 5 (1M). This is only the
|
|
95
|
+
* PRE-FIRST-TURN seed: once a turn arrives, `inferContextWindowFromModelId` (story 069) AUTHORITATIVELY
|
|
96
|
+
* refines the window from the transcript's real `model`. Keys MIRROR `MODEL_CATALOG` `value`s; the drift
|
|
97
|
+
* guard lives in the test (068 anti-drift: every catalog value has an explicit entry).
|
|
98
98
|
*/
|
|
99
99
|
export const MODEL_CONTEXT_WINDOWS = {
|
|
100
100
|
default: 1_000_000,
|
|
101
|
+
fable5: 1_000_000,
|
|
101
102
|
opus: 1_000_000,
|
|
102
|
-
sonnet:
|
|
103
|
-
"sonnet[1m]": 1_000_000,
|
|
103
|
+
sonnet: 1_000_000,
|
|
104
104
|
haiku: 200_000,
|
|
105
|
-
opusplan: 1_000_000,
|
|
106
105
|
};
|
|
107
106
|
/**
|
|
108
107
|
* Story 069 (R1.1) — the REAL context window per concrete model ID, mirroring the claude CLI's
|
|
@@ -130,19 +129,19 @@ export const MODEL_ID_CONTEXT_WINDOWS = {
|
|
|
130
129
|
* cannot derive the concrete version (the SDK `supportedModels()` was cut), so these MIRROR the LIVE
|
|
131
130
|
* picker and MUST be re-verified on each model launch (source: the user's live `/model` output). The
|
|
132
131
|
* static tagline stays on `ModelInfo.description` (069 R3 untouched); this only prepends "<version> · ".
|
|
133
|
-
*
|
|
134
|
-
*
|
|
132
|
+
* Every current catalog entry carries a label; the no-label branch in {@link modelSelectorDescription}
|
|
133
|
+
* stays as a total-function safeguard for any future label-less entry.
|
|
135
134
|
*/
|
|
136
135
|
export const MODEL_VERSION_LABELS = {
|
|
137
136
|
default: "Opus 4.8 with 1M context",
|
|
137
|
+
fable5: "Fable 5 with 1M context",
|
|
138
138
|
opus: "Opus 4.8 with 1M context",
|
|
139
|
-
sonnet: "Sonnet 5",
|
|
140
|
-
"sonnet[1m]": "Sonnet 5 with 1M context",
|
|
139
|
+
sonnet: "Sonnet 5 with 1M context",
|
|
141
140
|
haiku: "Haiku 4.5",
|
|
142
141
|
};
|
|
143
142
|
/**
|
|
144
143
|
* Story 072 — compose the Zed selector description: "<version label> · <tagline>", or the bare tagline
|
|
145
|
-
* when no label exists
|
|
144
|
+
* when no label exists. PURE + TOTAL: never throws on a missing label or tagline.
|
|
146
145
|
*/
|
|
147
146
|
export function modelSelectorDescription(info) {
|
|
148
147
|
const label = MODEL_VERSION_LABELS[info.value];
|
|
@@ -151,5 +150,144 @@ export function modelSelectorDescription(info) {
|
|
|
151
150
|
return tagline;
|
|
152
151
|
return tagline ? `${label} · ${tagline}` : label;
|
|
153
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Story 073 (R5.1) — the catalog `value`s that support fast mode (`/fast on|off`). Fast mode "uses
|
|
155
|
+
* Claude Opus with faster output (it does not downgrade to a smaller model)" and is available on Opus
|
|
156
|
+
* 4.8/4.7 only; the CLI turns it off when switching to a non-Opus model. `default` resolves to the
|
|
157
|
+
* recommended Opus, so both `default` and `opus` qualify; `fable5`/`sonnet`/`haiku` do NOT.
|
|
158
|
+
*
|
|
159
|
+
* Kept HERE (not on {@link ModelInfo}) because `ModelInfo` is the SDK shape and cannot carry a
|
|
160
|
+
* fork-only `supportsFastMode` field — the same reason the effort/auto flags that DO exist on the SDK
|
|
161
|
+
* type live inline while this predicate is external.
|
|
162
|
+
*/
|
|
163
|
+
export const FAST_MODE_MODELS = new Set(["default", "opus"]);
|
|
164
|
+
/** Story 073 (R5.1) — true when the catalog `value` is an Opus alias that supports fast mode. */
|
|
165
|
+
export function isFastModeCapableModel(value) {
|
|
166
|
+
return FAST_MODE_MODELS.has(value);
|
|
167
|
+
}
|
|
168
|
+
// --- Story 074 / #828 — fast-mode config-option surface (reconcile with upstream v0.57) ----------
|
|
169
|
+
// Upstream #828 exports the fast-mode identity as constants, negotiates `type:"boolean"` when the
|
|
170
|
+
// client advertises it (select fallback otherwise), and resolves a boolean OR on/off payload. The fork
|
|
171
|
+
// adopts that SURFACE while keeping its PTY `/fast on|off` inject and the FAST_MODE_MODELS gate (the
|
|
172
|
+
// SDK `applyFlagSettings`/`fast_mode_state`/`cooldown` reconcile has no PTY equivalent — CUT).
|
|
173
|
+
/** Story 074 (R4.2) — the fork's fast-mode config-option id, replacing the inline `"fast"` literal. */
|
|
174
|
+
export const FAST_MODE_CONFIG_ID = "fast";
|
|
175
|
+
/** Story 074 (R4.2) — the on/off select values, replacing the inline `"on"`/`"off"` literals. */
|
|
176
|
+
export const FAST_MODE_ON = "on";
|
|
177
|
+
export const FAST_MODE_OFF = "off";
|
|
178
|
+
/**
|
|
179
|
+
* Story 074 (R4.1) — did the client advertise support for boolean session config options
|
|
180
|
+
* (`clientCapabilities.session.configOptions.boolean`)? A present (non-null) object — even `{}` —
|
|
181
|
+
* means the agent may emit `type:"boolean"` entries and the client may send boolean `set_config_option`
|
|
182
|
+
* values. Read from the `initialize()`-stored capabilities; NO createSession/prompt touch (R4.5).
|
|
183
|
+
*/
|
|
184
|
+
export function clientSupportsBooleanConfigOptions(caps) {
|
|
185
|
+
const booleanCap = caps?.session?.configOptions?.boolean;
|
|
186
|
+
return booleanCap !== null && booleanCap !== undefined;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Story 074 (R4.3) — resolve the intended fast-mode ENABLED state from a `set_config_option` payload
|
|
190
|
+
* that may be a boolean (a client using the boolean option) OR the `"on"`/`"off"` string (the select
|
|
191
|
+
* fallback). Any non-`"on"` string (and any other shape) resolves to OFF — a toggle never half-applies.
|
|
192
|
+
*/
|
|
193
|
+
export function resolveFastModeEnabled(value) {
|
|
194
|
+
if (typeof value === "boolean")
|
|
195
|
+
return value;
|
|
196
|
+
return value === FAST_MODE_ON;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Story 074 (R4.1) — build the `fast` config option. Emits `type:"boolean"` (currentValue tracks the
|
|
200
|
+
* toggle) when the client advertised boolean config options, else the `on`/`off` select fallback. The
|
|
201
|
+
* external ACP `id` and on/off values are unchanged from story 073; only the type negotiation aligns
|
|
202
|
+
* with upstream #828. The PTY `/fast on|off` inject mechanism and the FAST_MODE_MODELS gate are kept.
|
|
203
|
+
*/
|
|
204
|
+
export function createFastModeConfigOption(enabled, useBooleanOption) {
|
|
205
|
+
const base = {
|
|
206
|
+
id: FAST_MODE_CONFIG_ID,
|
|
207
|
+
name: "Fast Mode",
|
|
208
|
+
description: "Faster Opus output at a higher usage-credit rate (/fast). Turns off on non-Opus models.",
|
|
209
|
+
category: "model",
|
|
210
|
+
};
|
|
211
|
+
if (useBooleanOption) {
|
|
212
|
+
return { ...base, type: "boolean", currentValue: enabled };
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
...base,
|
|
216
|
+
type: "select",
|
|
217
|
+
currentValue: enabled ? FAST_MODE_ON : FAST_MODE_OFF,
|
|
218
|
+
// Per-option descriptions mirror the `model` selector — Zed renders the selected option's
|
|
219
|
+
// description as the selector tooltip (an omitted per-option description shows no tooltip).
|
|
220
|
+
options: [
|
|
221
|
+
{ value: FAST_MODE_OFF, name: "Off", description: "Standard Opus output speed." },
|
|
222
|
+
{
|
|
223
|
+
value: FAST_MODE_ON,
|
|
224
|
+
name: "On",
|
|
225
|
+
description: "Faster Opus output — draws from usage credits at a higher rate.",
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Story 073 (R1) — strip the ANSI/OSC/CSI control sequences the interactive TUI interleaves so the
|
|
232
|
+
* marker substrings below match on the plain text. Deliberately conservative (removes only escape
|
|
233
|
+
* sequences, never printable bytes) so a marker can never be split apart by cursor-addressing codes.
|
|
234
|
+
*/
|
|
235
|
+
function stripControlSequences(raw) {
|
|
236
|
+
// Control chars in these regexes are intentional: we are matching ANSI/OSC
|
|
237
|
+
// escape sequences (ESC/BEL), never printable text, so no-control-regex is
|
|
238
|
+
// suppressed by design.
|
|
239
|
+
/* eslint-disable no-control-regex */
|
|
240
|
+
return raw
|
|
241
|
+
.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g, "") // OSC ...BEL / ST
|
|
242
|
+
.replace(/\x1b[@-Z\\-_]/g, "") // 2-byte ESC (Fe)
|
|
243
|
+
.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, ""); // CSI ...final
|
|
244
|
+
/* eslint-enable no-control-regex */
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Story 073 (R1) — the `/fast` panel header, present in BOTH the available and gated renders (verified
|
|
248
|
+
* live in the spike). Its presence means the panel finished rendering, so a verdict can be reached; its
|
|
249
|
+
* absence means "not rendered yet" → pending.
|
|
250
|
+
*/
|
|
251
|
+
const FAST_PANEL_ANCHORS = [/fast mode \(research preview\)/i, /high-speed mode for opus/i];
|
|
252
|
+
/** Story 073 (R1) — still resolving. Checked BEFORE the gate markers because the CLI renders this as
|
|
253
|
+
* `Fast mode unavailable: Checking fast mode availability`, which also matches a gate substring. */
|
|
254
|
+
const FAST_PENDING_MARKERS = ["checking fast mode availability"];
|
|
255
|
+
/**
|
|
256
|
+
* Story 073 (R1) — gate lines that mean fast mode is NOT usable for this account. ANY match ⇒
|
|
257
|
+
* unavailable. `requires usage credits` is the LIVE-captured signal from the spike (Opus 4.8 · Claude
|
|
258
|
+
* Max, no credits); the rest are the sibling reasons mined from the pinned CLI binary (2.1.198): free/
|
|
259
|
+
* oauth → paid subscription, org preference → disabled, first-party gate → Anthropic-API-only, plus the
|
|
260
|
+
* generic `Fast mode unavailable: <reason>` and `Fast mode is not available` families.
|
|
261
|
+
*/
|
|
262
|
+
const FAST_UNAVAILABLE_MARKERS = [
|
|
263
|
+
"requires usage credits",
|
|
264
|
+
"requires a paid subscription",
|
|
265
|
+
"unavailable during evaluation",
|
|
266
|
+
"has been disabled by your organization",
|
|
267
|
+
"only available when using the anthropic api directly",
|
|
268
|
+
"fast mode unavailable", // generic `Fast mode unavailable: <reason>`
|
|
269
|
+
"fast mode is not available",
|
|
270
|
+
"fast mode is currently unavailable",
|
|
271
|
+
];
|
|
272
|
+
/**
|
|
273
|
+
* Story 073 (R1) — classify the `/fast` panel text captured from the live PTY into a {@link FastModeSignal}.
|
|
274
|
+
*
|
|
275
|
+
* Pure and side-effect free so it is unit-testable against the spike's live capture; the live PTY drive
|
|
276
|
+
* that FEEDS it lives behind the `FastModeProbe` seam (acp-agent `defaultFastModeProbe`). Order matters:
|
|
277
|
+
* pending is checked first (its text also matches a gate substring), then the gate markers, then — only
|
|
278
|
+
* once the panel anchor confirms a full render with NO gate line — `available`. Anything else is
|
|
279
|
+
* `pending`, and the caller fails closed on timeout (R1.2).
|
|
280
|
+
*/
|
|
281
|
+
export function classifyFastModeSignal(raw) {
|
|
282
|
+
const text = stripControlSequences(raw).toLowerCase();
|
|
283
|
+
if (FAST_PENDING_MARKERS.some((m) => text.includes(m)))
|
|
284
|
+
return "pending";
|
|
285
|
+
if (FAST_UNAVAILABLE_MARKERS.some((m) => text.includes(m)))
|
|
286
|
+
return "unavailable";
|
|
287
|
+
// No gate line. If the panel finished rendering (anchor present), the On/Off toggle is usable.
|
|
288
|
+
if (FAST_PANEL_ANCHORS.some((re) => re.test(text)))
|
|
289
|
+
return "available";
|
|
290
|
+
return "pending"; // panel not rendered yet → keep waiting within the caller's bounded window
|
|
291
|
+
}
|
|
154
292
|
/** The safe fallback entry, kept as a named export so callers can seed/anchor on it without a lookup. */
|
|
155
293
|
export const DEFAULT_MODEL_INFO = MODEL_CATALOG[0];
|
package/dist/tools.d.ts
CHANGED
|
@@ -59,7 +59,9 @@ interface RawToolUse {
|
|
|
59
59
|
export declare function toolInfoFromToolUse(toolUse: RawToolUse, supportsTerminalOutput?: boolean, cwd?: string): ToolInfo;
|
|
60
60
|
export declare function toolUpdateFromToolResult(toolResult: ToolResultBlockParam | BetaToolResultBlockParam | BetaWebSearchToolResultBlockParam | BetaWebFetchToolResultBlockParam | WebSearchToolResultBlockParam | BetaCodeExecutionToolResultBlockParam | BetaBashCodeExecutionToolResultBlockParam | BetaTextEditorCodeExecutionToolResultBlockParam | BetaRequestMCPToolResultBlockParam | BetaToolSearchToolResultBlockParam, toolUse: {
|
|
61
61
|
name?: string;
|
|
62
|
-
|
|
62
|
+
id?: string;
|
|
63
|
+
input?: unknown;
|
|
64
|
+
} | undefined, supportsTerminalOutput?: boolean, toolUseResult?: unknown): ToolUpdate;
|
|
63
65
|
export type ClaudePlanEntry = {
|
|
64
66
|
content: string;
|
|
65
67
|
status: "pending" | "in_progress" | "completed";
|