@lucascouts/claude-agent-tui 0.6.0 → 0.8.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/NOTICE +1 -1
- package/README.md +1 -1
- package/dist/acp-agent.d.ts +153 -8
- package/dist/acp-agent.js +356 -17
- package/dist/agent-catalog.d.ts +0 -1
- package/dist/ansi-mirror.d.ts +0 -1
- package/dist/besteffort.d.ts +0 -1
- package/dist/billing/entrypoint-guard.d.ts +0 -1
- package/dist/claude-path.d.ts +0 -1
- package/dist/command-catalog.d.ts +84 -0
- package/dist/command-catalog.js +339 -0
- package/dist/diff-enriched-reader.d.ts +0 -1
- package/dist/diff-source.d.ts +0 -1
- package/dist/drift-checks.d.ts +0 -1
- package/dist/end-of-turn.d.ts +0 -1
- package/dist/engine-lifecycle.d.ts +0 -1
- package/dist/engine-pty.d.ts +0 -1
- package/dist/engine-watcher.d.ts +0 -1
- package/dist/engine.d.ts +0 -1
- package/dist/event-switch.d.ts +0 -1
- package/dist/gate/port.d.ts +0 -1
- package/dist/gate/settings-writer.d.ts +0 -1
- package/dist/image-input.d.ts +0 -1
- package/dist/image-vision-smoke.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +20 -2
- package/dist/jsonl.d.ts +0 -1
- package/dist/lib.d.ts +0 -1
- package/dist/linearize.d.ts +1 -2
- package/dist/linearize.js +1 -1
- package/dist/live-diff-env.d.ts +0 -1
- package/dist/live-subagent-env.d.ts +0 -1
- package/dist/mcp-config-writer.d.ts +0 -1
- package/dist/model-catalog.d.ts +107 -10
- package/dist/model-catalog.js +233 -25
- package/dist/permissions/allow-inject.d.ts +0 -1
- package/dist/permissions/deny.d.ts +12 -1
- package/dist/permissions/deny.js +18 -0
- package/dist/permissions/elicitation-bridge.d.ts +71 -0
- package/dist/permissions/elicitation-bridge.js +146 -0
- package/dist/permissions/gate-wiring.d.ts +23 -3
- package/dist/permissions/gate-wiring.js +123 -1
- package/dist/permissions/hook-server.d.ts +11 -3
- package/dist/permissions/hook-server.js +10 -1
- package/dist/permissions/permission-mode.d.ts +0 -1
- package/dist/permissions/request-permission.d.ts +0 -1
- package/dist/settings.d.ts +0 -1
- package/dist/stop-reason-map.d.ts +0 -1
- package/dist/subagent-gate.d.ts +0 -1
- package/dist/subagent-source.d.ts +0 -1
- package/dist/subagent-watcher.d.ts +0 -1
- package/dist/tools.d.ts +0 -1
- package/dist/tools.js +20 -0
- package/dist/usage-env.d.ts +0 -1
- package/dist/usage.d.ts +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/zed-register.d.ts +0 -1
- package/package.json +13 -10
- package/dist/acp-agent.d.ts.map +0 -1
- package/dist/agent-catalog.d.ts.map +0 -1
- package/dist/ansi-mirror.d.ts.map +0 -1
- package/dist/besteffort.d.ts.map +0 -1
- package/dist/billing/entrypoint-guard.d.ts.map +0 -1
- package/dist/claude-path.d.ts.map +0 -1
- package/dist/diff-enriched-reader.d.ts.map +0 -1
- package/dist/diff-source.d.ts.map +0 -1
- package/dist/drift-checks.d.ts.map +0 -1
- package/dist/end-of-turn.d.ts.map +0 -1
- package/dist/engine-lifecycle.d.ts.map +0 -1
- package/dist/engine-pty.d.ts.map +0 -1
- package/dist/engine-watcher.d.ts.map +0 -1
- package/dist/engine.d.ts.map +0 -1
- package/dist/event-switch.d.ts.map +0 -1
- package/dist/gate/port.d.ts.map +0 -1
- package/dist/gate/settings-writer.d.ts.map +0 -1
- package/dist/image-input.d.ts.map +0 -1
- package/dist/image-vision-smoke.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/jsonl.d.ts.map +0 -1
- package/dist/lib.d.ts.map +0 -1
- package/dist/linearize.d.ts.map +0 -1
- package/dist/live-diff-env.d.ts.map +0 -1
- package/dist/live-subagent-env.d.ts.map +0 -1
- package/dist/mcp-config-writer.d.ts.map +0 -1
- package/dist/model-catalog.d.ts.map +0 -1
- package/dist/permissions/allow-inject.d.ts.map +0 -1
- package/dist/permissions/deny.d.ts.map +0 -1
- package/dist/permissions/gate-wiring.d.ts.map +0 -1
- package/dist/permissions/hook-server.d.ts.map +0 -1
- package/dist/permissions/permission-mode.d.ts.map +0 -1
- package/dist/permissions/request-permission.d.ts.map +0 -1
- package/dist/settings.d.ts.map +0 -1
- package/dist/stop-reason-map.d.ts.map +0 -1
- package/dist/subagent-gate.d.ts.map +0 -1
- package/dist/subagent-source.d.ts.map +0 -1
- package/dist/subagent-watcher.d.ts.map +0 -1
- package/dist/tools.d.ts.map +0 -1
- package/dist/usage-env.d.ts.map +0 -1
- package/dist/usage.d.ts.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/zed-register.d.ts.map +0 -1
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,18 +22,114 @@ 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[];
|
|
38
|
+
/**
|
|
39
|
+
* Story 068 (R1, R1.1, R2) — the REAL per-alias context window, keyed by the EXACT {@link MODEL_CATALOG}
|
|
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).
|
|
44
|
+
*
|
|
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).
|
|
51
|
+
*/
|
|
52
|
+
export declare const MODEL_CONTEXT_WINDOWS: Record<string, number>;
|
|
53
|
+
/**
|
|
54
|
+
* Story 069 (R1.1) — the REAL context window per concrete model ID, mirroring the claude CLI's
|
|
55
|
+
* `context:{window}` table. Used to AUTHORITATIVELY refine the window from a turn's actual `model`
|
|
56
|
+
* (the JSONL `model` field), correcting the alias seed. Opus is NOT uniform: 4.6 = 200K, 4.7+ = 1M.
|
|
57
|
+
* Dated snapshots / future versions are covered by the family+version heuristic in
|
|
58
|
+
* `inferContextWindowFromModelId`; this table is the exact-ID source of truth for today's gateway IDs.
|
|
59
|
+
*/
|
|
60
|
+
export declare const MODEL_ID_CONTEXT_WINDOWS: Record<string, number>;
|
|
61
|
+
/**
|
|
62
|
+
* Story 072 — the version/context PREFIX the claude `/model` picker now shows before the static tagline
|
|
63
|
+
* (e.g. "Opus 4.8 with 1M context · Best for everyday, complex tasks"). Keyed by catalog `value`.
|
|
64
|
+
*
|
|
65
|
+
* CURATED + DRIFT-PRONE, exactly like MODEL_CATALOG membership: the fork holds only aliases pre-turn and
|
|
66
|
+
* cannot derive the concrete version (the SDK `supportedModels()` was cut), so these MIRROR the LIVE
|
|
67
|
+
* picker and MUST be re-verified on each model launch (source: the user's live `/model` output). The
|
|
68
|
+
* static tagline stays on `ModelInfo.description` (069 R3 untouched); this only prepends "<version> · ".
|
|
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.
|
|
71
|
+
*/
|
|
72
|
+
export declare const MODEL_VERSION_LABELS: Record<string, string>;
|
|
73
|
+
/**
|
|
74
|
+
* Story 072 — compose the Zed selector description: "<version label> · <tagline>", or the bare tagline
|
|
75
|
+
* when no label exists. PURE + TOTAL: never throws on a missing label or tagline.
|
|
76
|
+
*/
|
|
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;
|
|
36
134
|
/** The safe fallback entry, kept as a named export so callers can seed/anchor on it without a lookup. */
|
|
37
135
|
export declare const DEFAULT_MODEL_INFO: ModelInfo;
|
|
38
|
-
//# sourceMappingURL=model-catalog.d.ts.map
|
package/dist/model-catalog.js
CHANGED
|
@@ -26,46 +26,52 @@ 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
|
{
|
|
42
43
|
value: "default",
|
|
43
44
|
displayName: "Default (recommended)",
|
|
44
|
-
|
|
45
|
+
// Story 069 (R3): `default` resolves to the recommended Opus, so it carries the Opus description.
|
|
46
|
+
description: "Best for everyday, complex tasks",
|
|
45
47
|
supportsEffort: true,
|
|
46
48
|
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
47
49
|
supportsAutoMode: true,
|
|
48
50
|
},
|
|
49
51
|
{
|
|
50
|
-
value: "
|
|
51
|
-
|
|
52
|
-
|
|
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",
|
|
53
59
|
supportsEffort: true,
|
|
54
60
|
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
55
61
|
supportsAutoMode: true,
|
|
56
62
|
},
|
|
57
63
|
{
|
|
58
|
-
value: "
|
|
59
|
-
displayName: "
|
|
60
|
-
description: "
|
|
64
|
+
value: "opus",
|
|
65
|
+
displayName: "Opus",
|
|
66
|
+
description: "Best for everyday, complex tasks",
|
|
61
67
|
supportsEffort: true,
|
|
62
68
|
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
63
69
|
supportsAutoMode: true,
|
|
64
70
|
},
|
|
65
71
|
{
|
|
66
|
-
value: "sonnet
|
|
67
|
-
displayName: "Sonnet
|
|
68
|
-
description: "
|
|
72
|
+
value: "sonnet",
|
|
73
|
+
displayName: "Sonnet",
|
|
74
|
+
description: "Efficient for routine tasks",
|
|
69
75
|
supportsEffort: true,
|
|
70
76
|
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
71
77
|
supportsAutoMode: true,
|
|
@@ -73,13 +79,215 @@ export const MODEL_CATALOG = [
|
|
|
73
79
|
{
|
|
74
80
|
value: "haiku",
|
|
75
81
|
displayName: "Haiku",
|
|
76
|
-
description: "
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
value: "opusplan",
|
|
80
|
-
displayName: "Opus Plan",
|
|
81
|
-
description: "Opus while planning, Sonnet for execution (plan-mode workflow; fork extra).",
|
|
82
|
+
description: "Fastest for quick answers",
|
|
82
83
|
},
|
|
83
84
|
];
|
|
85
|
+
/**
|
|
86
|
+
* Story 068 (R1, R1.1, R2) — the REAL per-alias context window, keyed by the EXACT {@link MODEL_CATALOG}
|
|
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).
|
|
91
|
+
*
|
|
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
|
+
*/
|
|
99
|
+
export const MODEL_CONTEXT_WINDOWS = {
|
|
100
|
+
default: 1_000_000,
|
|
101
|
+
fable5: 1_000_000,
|
|
102
|
+
opus: 1_000_000,
|
|
103
|
+
sonnet: 1_000_000,
|
|
104
|
+
haiku: 200_000,
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Story 069 (R1.1) — the REAL context window per concrete model ID, mirroring the claude CLI's
|
|
108
|
+
* `context:{window}` table. Used to AUTHORITATIVELY refine the window from a turn's actual `model`
|
|
109
|
+
* (the JSONL `model` field), correcting the alias seed. Opus is NOT uniform: 4.6 = 200K, 4.7+ = 1M.
|
|
110
|
+
* Dated snapshots / future versions are covered by the family+version heuristic in
|
|
111
|
+
* `inferContextWindowFromModelId`; this table is the exact-ID source of truth for today's gateway IDs.
|
|
112
|
+
*/
|
|
113
|
+
export const MODEL_ID_CONTEXT_WINDOWS = {
|
|
114
|
+
"claude-opus-4-8": 1_000_000,
|
|
115
|
+
"claude-opus-4-7": 1_000_000,
|
|
116
|
+
"claude-opus-4-6": 200_000,
|
|
117
|
+
"claude-fable-5": 1_000_000,
|
|
118
|
+
"claude-sonnet-5": 1_000_000,
|
|
119
|
+
"claude-sonnet-4-6": 200_000,
|
|
120
|
+
"claude-sonnet-4-5-20250929": 200_000,
|
|
121
|
+
"claude-sonnet-4-20250514": 200_000,
|
|
122
|
+
"claude-haiku-4-5": 200_000,
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Story 072 — the version/context PREFIX the claude `/model` picker now shows before the static tagline
|
|
126
|
+
* (e.g. "Opus 4.8 with 1M context · Best for everyday, complex tasks"). Keyed by catalog `value`.
|
|
127
|
+
*
|
|
128
|
+
* CURATED + DRIFT-PRONE, exactly like MODEL_CATALOG membership: the fork holds only aliases pre-turn and
|
|
129
|
+
* cannot derive the concrete version (the SDK `supportedModels()` was cut), so these MIRROR the LIVE
|
|
130
|
+
* picker and MUST be re-verified on each model launch (source: the user's live `/model` output). The
|
|
131
|
+
* static tagline stays on `ModelInfo.description` (069 R3 untouched); this only prepends "<version> · ".
|
|
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.
|
|
134
|
+
*/
|
|
135
|
+
export const MODEL_VERSION_LABELS = {
|
|
136
|
+
default: "Opus 4.8 with 1M context",
|
|
137
|
+
fable5: "Fable 5 with 1M context",
|
|
138
|
+
opus: "Opus 4.8 with 1M context",
|
|
139
|
+
sonnet: "Sonnet 5 with 1M context",
|
|
140
|
+
haiku: "Haiku 4.5",
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Story 072 — compose the Zed selector description: "<version label> · <tagline>", or the bare tagline
|
|
144
|
+
* when no label exists. PURE + TOTAL: never throws on a missing label or tagline.
|
|
145
|
+
*/
|
|
146
|
+
export function modelSelectorDescription(info) {
|
|
147
|
+
const label = MODEL_VERSION_LABELS[info.value];
|
|
148
|
+
const tagline = info.description ?? "";
|
|
149
|
+
if (!label)
|
|
150
|
+
return tagline;
|
|
151
|
+
return tagline ? `${label} · ${tagline}` : label;
|
|
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
|
+
}
|
|
84
292
|
/** The safe fallback entry, kept as a named export so callers can seed/anchor on it without a lookup. */
|
|
85
293
|
export const DEFAULT_MODEL_INFO = MODEL_CATALOG[0];
|
|
@@ -64,4 +64,3 @@ export interface ClearNativePromptOptions {
|
|
|
64
64
|
* @returns an {@link InjectResult}: `'suppressed'` | `'cleared'` | `'stuck'`.
|
|
65
65
|
*/
|
|
66
66
|
export declare function clearNativePrompt(opts: ClearNativePromptOptions): Promise<InjectResult>;
|
|
67
|
-
//# sourceMappingURL=allow-inject.d.ts.map
|
|
@@ -44,6 +44,18 @@ export declare function denyDecision(toolCall: DenyToolCall, reason?: string): H
|
|
|
44
44
|
* @returns `{ hookSpecificOutput: { hookEventName:'PreToolUse', permissionDecision:'allow', … } }`.
|
|
45
45
|
*/
|
|
46
46
|
export declare function allowDecision(toolCall: DenyToolCall, reason?: string): HookResponse;
|
|
47
|
+
/** Story 064 — the interactive tool the gate denies fail-closed over the Zed bridge (R1). */
|
|
48
|
+
export declare const ASK_USER_QUESTION_TOOL = "AskUserQuestion";
|
|
49
|
+
/** True iff `toolName` is the AskUserQuestion interactive picker tool (exact, case-sensitive). */
|
|
50
|
+
export declare function isAskUserQuestionTool(toolName: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Story 064 (R1.1) — the deny reason for AskUserQuestion over the Zed bridge. AskUserQuestion renders
|
|
53
|
+
* an interactive multiple-choice picker bound to the hidden PTY's stdin; the Zed user can neither see
|
|
54
|
+
* nor answer it, so allowing it would stall the turn until the watchdog fires. Deny it fail-closed with
|
|
55
|
+
* this reason so the model proceeds without it (interim until story 065 relays it via ACP elicitation).
|
|
56
|
+
* MUST name the tool and cite the bridge limitation (the body matches `/AskUserQuestion/` and `/bridge/i`).
|
|
57
|
+
*/
|
|
58
|
+
export declare function askUserQuestionDenyReason(): string;
|
|
47
59
|
/**
|
|
48
60
|
* Matcher-scoped deny predicate (R2.3 NUANCE): does this deny matcher target the given tool?
|
|
49
61
|
*
|
|
@@ -57,4 +69,3 @@ export declare function allowDecision(toolCall: DenyToolCall, reason?: string):
|
|
|
57
69
|
* @returns true iff the matcher scopes the deny to this tool.
|
|
58
70
|
*/
|
|
59
71
|
export declare function denyMatchesTool(matcher: string, toolName: string): boolean;
|
|
60
|
-
//# sourceMappingURL=deny.d.ts.map
|
package/dist/permissions/deny.js
CHANGED
|
@@ -64,6 +64,24 @@ export function allowDecision(toolCall, reason) {
|
|
|
64
64
|
},
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
+
/** Story 064 — the interactive tool the gate denies fail-closed over the Zed bridge (R1). */
|
|
68
|
+
export const ASK_USER_QUESTION_TOOL = "AskUserQuestion";
|
|
69
|
+
/** True iff `toolName` is the AskUserQuestion interactive picker tool (exact, case-sensitive). */
|
|
70
|
+
export function isAskUserQuestionTool(toolName) {
|
|
71
|
+
return toolName === ASK_USER_QUESTION_TOOL;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Story 064 (R1.1) — the deny reason for AskUserQuestion over the Zed bridge. AskUserQuestion renders
|
|
75
|
+
* an interactive multiple-choice picker bound to the hidden PTY's stdin; the Zed user can neither see
|
|
76
|
+
* nor answer it, so allowing it would stall the turn until the watchdog fires. Deny it fail-closed with
|
|
77
|
+
* this reason so the model proceeds without it (interim until story 065 relays it via ACP elicitation).
|
|
78
|
+
* MUST name the tool and cite the bridge limitation (the body matches `/AskUserQuestion/` and `/bridge/i`).
|
|
79
|
+
*/
|
|
80
|
+
export function askUserQuestionDenyReason() {
|
|
81
|
+
return (`${ASK_USER_QUESTION_TOOL} is not supported over the Zed bridge: its interactive multiple-choice ` +
|
|
82
|
+
`picker renders in a hidden PTY the user cannot see or answer, so the turn would stall. Denying it ` +
|
|
83
|
+
`fail-closed — continue without asking an interactive question.`);
|
|
84
|
+
}
|
|
67
85
|
/**
|
|
68
86
|
* Matcher-scoped deny predicate (R2.3 NUANCE): does this deny matcher target the given tool?
|
|
69
87
|
*
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { CreateElicitationRequest, CreateElicitationResponse } from "@agentclientprotocol/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* The gate decision this bridge yields. Mirrors hook-server's `DenyWithReason`: AskUserQuestion is
|
|
4
|
+
* ALWAYS denied at the wire, and the user's selection (or the dismissal note) is carried in `reason`.
|
|
5
|
+
*/
|
|
6
|
+
export interface ElicitationDecision {
|
|
7
|
+
decision: "deny";
|
|
8
|
+
reason: string;
|
|
9
|
+
}
|
|
10
|
+
/** The `AskUserQuestion` tool_input subset the bridge projects into a form elicitation. */
|
|
11
|
+
export interface AskUserQuestionInput {
|
|
12
|
+
questions: Array<{
|
|
13
|
+
/** The human-readable question text — becomes the property `title`. */
|
|
14
|
+
question: string;
|
|
15
|
+
/** The short key — becomes the property name AND a `required` entry. */
|
|
16
|
+
header: string;
|
|
17
|
+
/** Whether multiple options may be selected (currently projected as a single string-enum). */
|
|
18
|
+
multiSelect?: boolean;
|
|
19
|
+
options: Array<{
|
|
20
|
+
label: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
}>;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The minimal ACP client surface the bridge needs — structurally satisfied by the kept
|
|
27
|
+
* `AgentSideConnection` (`client.unstable_createElicitation(params)`). Injected so a unit test drives
|
|
28
|
+
* the bridge with a fake client OFFLINE (no AgentSideConnection, no Zed).
|
|
29
|
+
*/
|
|
30
|
+
export interface ElicitationClient {
|
|
31
|
+
unstable_createElicitation(params: CreateElicitationRequest): Promise<CreateElicitationResponse>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Project an `AskUserQuestion` tool_input into an ACP form `CreateElicitationRequest`, scoped to the
|
|
35
|
+
* session and tied to the originating tool call by `tool_use.id` (R1.1, R1.2).
|
|
36
|
+
*
|
|
37
|
+
* Each question becomes one string-enum property keyed by its `header`: `{ type: "string", title:
|
|
38
|
+
* <question>, enum: <option labels, in order> }`, and every header is marked `required` (one entry per
|
|
39
|
+
* question, in order). The returned literal is shaped to satisfy the pinned SDK `zCreateElicitationRequest`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildElicitationRequest(toolUseId: string, sessionId: string, toolInput: AskUserQuestionInput): CreateElicitationRequest;
|
|
42
|
+
/**
|
|
43
|
+
* Map an elicitation outcome back to a gate decision (R2). EVERY branch returns a `deny`: the gate
|
|
44
|
+
* always denies AskUserQuestion at the wire and surfaces the result through `reason` (the R2.1 seam — a
|
|
45
|
+
* PreToolUse hook cannot synthesize a native tool_result).
|
|
46
|
+
*
|
|
47
|
+
* - `accept`: the reason embeds EVERY selected answer (e.g. `Env=prod, Cache=yes`) so the model can
|
|
48
|
+
* read the choice from the deny reason. `content` null/undefined is handled defensively (still deny).
|
|
49
|
+
* - `decline`/`cancel`/any unrecognized-or-missing action: the reason reads as a user DISMISSAL, not
|
|
50
|
+
* an answer (default-deny defensively for unknown actions).
|
|
51
|
+
*/
|
|
52
|
+
export declare function mapOutcomeToDecision(resp: CreateElicitationResponse): ElicitationDecision;
|
|
53
|
+
/** Options for {@link requestElicitation}. */
|
|
54
|
+
export interface RequestElicitationOptions {
|
|
55
|
+
/** The hard upper bound (ms) on the round-trip; a slower client fails closed to a cancel. */
|
|
56
|
+
timeoutMs: number;
|
|
57
|
+
/** Optional sink for the fail-closed diagnostics (defaults to no-op; production wires the logger). */
|
|
58
|
+
onWarn?: (message: string) => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Perform the bounded, fail-closed elicitation round-trip (R4). NEVER throws and NEVER hangs past
|
|
62
|
+
* ~`timeoutMs`.
|
|
63
|
+
*
|
|
64
|
+
* - Happy path (a well-formed response, action ∈ {accept,decline,cancel}) → returned UNCHANGED.
|
|
65
|
+
* - Timeout → `onWarn` (naming the timeout) and resolve `{ action: "cancel" }`.
|
|
66
|
+
* - Client throws → `onWarn` (including the underlying error text) and resolve `{ action: "cancel" }`.
|
|
67
|
+
* - Malformed response (action not accept|decline|cancel) → normalized to `{ action: "cancel" }`.
|
|
68
|
+
*
|
|
69
|
+
* The timer is always cleared on settle so no live handle keeps the event loop open.
|
|
70
|
+
*/
|
|
71
|
+
export declare function requestElicitation(client: ElicitationClient, req: CreateElicitationRequest, opts: RequestElicitationOptions): Promise<CreateElicitationResponse>;
|