@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/acp-agent.js
CHANGED
|
@@ -24,12 +24,16 @@ import { guardEvent } from "./billing/entrypoint-guard.js";
|
|
|
24
24
|
import { usageUpdatesFor } from "./usage.js";
|
|
25
25
|
import { createTurnResolver } from "./end-of-turn.js";
|
|
26
26
|
import { sendPrompt } from "./engine-pty.js";
|
|
27
|
-
import { MODEL_CATALOG, DEFAULT_MODEL_INFO, ULTRACODE_EFFORT, ULTRACODE_EFFORT_LEVEL, ULTRACODE_EFFORT_LABEL, } from "./model-catalog.js";
|
|
27
|
+
import { MODEL_CATALOG, MODEL_CONTEXT_WINDOWS, MODEL_ID_CONTEXT_WINDOWS, modelSelectorDescription, DEFAULT_MODEL_INFO, isFastModeCapableModel, classifyFastModeSignal, FAST_MODE_CONFIG_ID, FAST_MODE_ON, FAST_MODE_OFF, createFastModeConfigOption, clientSupportsBooleanConfigOptions, resolveFastModeEnabled, ULTRACODE_EFFORT, ULTRACODE_EFFORT_LEVEL, ULTRACODE_EFFORT_LABEL, } from "./model-catalog.js";
|
|
28
28
|
// Story 060 (R2.2/R2.3/R3.2) — the declarative spawn-time complement to the live ultracode keyword:
|
|
29
29
|
// toggle the {ultracode,ultracodeKeywordTrigger} keys in the gate's per-session scratch settings file
|
|
30
30
|
// (preserving the hook + every other key). Lives in the gate's settings-writer so it reuses durableWrite.
|
|
31
31
|
import { applyUltracodeSettings } from "./gate/settings-writer.js";
|
|
32
32
|
import { discoverAgents } from "./agent-catalog.js";
|
|
33
|
+
// Story 063 (R1) — OFFLINE disk discovery of the `available_commands` set (custom slash-commands +
|
|
34
|
+
// skills + enabled-plugin surfaces + built-ins), keyed on the session cwd. Populates the
|
|
35
|
+
// `available_commands_update` the session emits at creation in place of the old unconditional `[]`.
|
|
36
|
+
import { discoverCommands } from "./command-catalog.js";
|
|
33
37
|
import { setupSessionGate } from "./permissions/gate-wiring.js";
|
|
34
38
|
// Story 057 / Task 2.3 — MCP scratch-file lifecycle (translate ACP servers → claude `--mcp-config`
|
|
35
39
|
// JSON, durable 0600 write, idempotent teardown removal). Mirrors the gate's settings-scratch
|
|
@@ -50,7 +54,84 @@ function sanitizeTitle(text) {
|
|
|
50
54
|
}
|
|
51
55
|
return sanitized.slice(0, MAX_TITLE_LENGTH - 1) + "…";
|
|
52
56
|
}
|
|
53
|
-
const DEFAULT_CONTEXT_WINDOW = 200000;
|
|
57
|
+
export const DEFAULT_CONTEXT_WINDOW = 200000;
|
|
58
|
+
/** Production default — fail-closed (R1.2), invariant-safe: performs NO PTY write, so it preserves the
|
|
59
|
+
* read-only-load (R4.3) and no-unsolicited-Ctrl+U invariants. The live signal is characterized (see
|
|
60
|
+
* {@link classifyFastModeSignal}) and the live driver is {@link driveFastModeProbe}; wiring it as the
|
|
61
|
+
* default is deferred to the R7.3 live-proof + a non-intrusive (idle-gated) wiring follow-up. */
|
|
62
|
+
export const defaultFastModeProbe = () => false;
|
|
63
|
+
/** Story 073 (R1) — bounded window the live driver waits for the `/fast` panel to render before failing
|
|
64
|
+
* closed, polled every {@link FAST_PROBE_POLL_MS}. Generous because at session start the TUI needs a
|
|
65
|
+
* beat to become input-ready. While still pending, the `/fast` inject is re-sent every
|
|
66
|
+
* {@link FAST_PROBE_REINJECT_MS} — a session-start TUI can swallow the first inject before it is
|
|
67
|
+
* input-ready (the createSession race the R7.3 live-proof surfaced), so a single inject would miss it. */
|
|
68
|
+
const FAST_PROBE_WINDOW_MS = 6000;
|
|
69
|
+
const FAST_PROBE_POLL_MS = 150;
|
|
70
|
+
const FAST_PROBE_REINJECT_MS = 2000;
|
|
71
|
+
/**
|
|
72
|
+
* Story 073 (R1) — the OPT-IN live fast-mode detector (Task 1 spike + Task 3.1 parser). Opens the
|
|
73
|
+
* `/fast` panel via the SAME live PTY inject as `/effort` (no re-spawn, no `-p`/credit path — R3.3),
|
|
74
|
+
* collects the panel text on a temporary onData listener, classifies it with {@link classifyFastModeSignal},
|
|
75
|
+
* then writes Esc to dismiss the panel. Fails CLOSED (returns `false`) on timeout, a broken/dead PTY, or
|
|
76
|
+
* any throw (R1.2).
|
|
77
|
+
*
|
|
78
|
+
* NOT the production default: it writes to the PTY at probe time, which is safe only when the input box
|
|
79
|
+
* is idle. Wiring it as {@link defaultFastModeProbe} would break the read-only-load (R4.3) and
|
|
80
|
+
* no-Ctrl+U-in-closed-loop invariants (an unsolicited session-start write). It is exported so it can be
|
|
81
|
+
* injected via `deps.fastModeProbe` once the R7.3 live-proof validates it on a fast-available account and
|
|
82
|
+
* a non-intrusive (idle-gated) wiring lands. The pure classifier it delegates to IS unit-tested against
|
|
83
|
+
* the spike's live capture; this thin live-drive glue is exercised offline via a fake signal-emitting pty.
|
|
84
|
+
*/
|
|
85
|
+
export const driveFastModeProbe = async ({ pty }) => {
|
|
86
|
+
let sub;
|
|
87
|
+
try {
|
|
88
|
+
let buffer = "";
|
|
89
|
+
sub = pty.onData((d) => {
|
|
90
|
+
buffer += d;
|
|
91
|
+
});
|
|
92
|
+
// Open the panel with the SAME seam every live inject uses (Ctrl+U clear + `/fast` + \r). Safe ONLY on
|
|
93
|
+
// an idle input box; interactive-only, so billing is untouched (R3.3).
|
|
94
|
+
const openPanel = () => {
|
|
95
|
+
sendPrompt(pty, "/fast", (fn) => fn());
|
|
96
|
+
};
|
|
97
|
+
openPanel();
|
|
98
|
+
const deadline = Date.now() + FAST_PROBE_WINDOW_MS;
|
|
99
|
+
let nextReinject = Date.now() + FAST_PROBE_REINJECT_MS;
|
|
100
|
+
while (Date.now() < deadline) {
|
|
101
|
+
await new Promise((resolve) => setTimeout(resolve, FAST_PROBE_POLL_MS));
|
|
102
|
+
const verdict = classifyFastModeSignal(buffer);
|
|
103
|
+
if (verdict === "available")
|
|
104
|
+
return true;
|
|
105
|
+
if (verdict === "unavailable")
|
|
106
|
+
return false;
|
|
107
|
+
// "pending" → the panel has not rendered a decisive line yet. A session-start TUI may have swallowed
|
|
108
|
+
// the inject before it was input-ready, so re-open periodically until it takes. We ONLY re-inject
|
|
109
|
+
// while pending (no panel rendered), so an already-open panel is never disturbed.
|
|
110
|
+
if (Date.now() >= nextReinject) {
|
|
111
|
+
openPanel();
|
|
112
|
+
nextReinject = Date.now() + FAST_PROBE_REINJECT_MS;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false; // window elapsed without a decisive panel → fail closed (R1.2)
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return false; // dead/broken PTY or any inject error → fail closed (R1.2)
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
try {
|
|
122
|
+
pty.write("\x1b"); // Esc — dismiss the `/fast` panel (raw escape, NEVER via sendPrompt — GOTCHA)
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
/* pty already gone — nothing to dismiss */
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
sub?.dispose();
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
/* listener already disposed */
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
54
135
|
/**
|
|
55
136
|
* No-op {@link IPty} stub for the Degrau-1 replay-only load path: there is no live `claude` process,
|
|
56
137
|
* but the session record's `pty` field is typed `IPty`. Every method is inert — teardown's `kill()`
|
|
@@ -532,6 +613,14 @@ function deriveSubagentLabel(messages, parentId) {
|
|
|
532
613
|
export class ClaudeAcpAgent {
|
|
533
614
|
constructor(client, logger, engine = createStubEngine(), deps = {}) {
|
|
534
615
|
this.backgroundTerminals = {};
|
|
616
|
+
/**
|
|
617
|
+
* Story 065 (R1/R3) — did the client advertise `clientCapabilities.elicitation.form`
|
|
618
|
+
* at initialize? Presence-based (a present `form` may legitimately be an empty `{}`,
|
|
619
|
+
* so this is derived with `!= null`, NOT property truthiness). The 065 gate (task 3.1)
|
|
620
|
+
* reads this to decide relay-via-elicitation (R1) vs the story-064 deny fallback (R3).
|
|
621
|
+
* Defaults `false` so a client that never advertised elicitation falls back safely.
|
|
622
|
+
*/
|
|
623
|
+
this.clientSupportsElicitationForm = false;
|
|
535
624
|
/** Live PTY-engine registry shared with the per-session engines (story 014 cleanup map). */
|
|
536
625
|
this.engines = new Map();
|
|
537
626
|
this.sessions = {};
|
|
@@ -540,6 +629,7 @@ export class ClaudeAcpAgent {
|
|
|
540
629
|
this.logger = logger ?? console;
|
|
541
630
|
this.engine = engine;
|
|
542
631
|
this.startEngine = deps.startEngine ?? defaultStartEngine;
|
|
632
|
+
this.fastModeProbe = deps.fastModeProbe ?? defaultFastModeProbe;
|
|
543
633
|
// Story 043 (R2.1): when liveDiff is ON, the live JSONL reader is the diff-enriched reader
|
|
544
634
|
// (getSessionMessages + uuid→toolUseResult hydration), which restores the story-021 Edit/Write
|
|
545
635
|
// diff on BOTH the live pump and the session/load replay (both read this.getMessages once). The
|
|
@@ -571,12 +661,27 @@ export class ClaudeAcpAgent {
|
|
|
571
661
|
// Story 056 (R3.2): main-thread agent-persona discovery — defaults to the glob-only
|
|
572
662
|
// discoverAgents; tests inject an in-memory fake so the `agent` surface is hermetic.
|
|
573
663
|
this.discoverAgents = deps.discoverAgents ?? discoverAgents;
|
|
664
|
+
// Story 063 (R1/R1.1): offline `available_commands` discovery — defaults to the disk-only
|
|
665
|
+
// discoverCommands; tests inject an in-memory fake so the surface is hermetic (no real ~/.claude read).
|
|
666
|
+
this.discoverCommands = deps.discoverCommands ?? discoverCommands;
|
|
574
667
|
// Story 056 (#812): end-of-turn session_info_update title source — defaults to the pure SDK
|
|
575
668
|
// getSessionInfo; tests inject an in-memory fake so the push is hermetic (no real ~/.claude read).
|
|
576
669
|
this.getSessionInfo = deps.getSessionInfo ?? getSessionInfo;
|
|
577
670
|
}
|
|
578
671
|
async initialize(request) {
|
|
579
672
|
this.clientCapabilities = request.clientCapabilities;
|
|
673
|
+
// Story 065 (R1/R3): capability negotiation — a present (non-null) `elicitation.form`
|
|
674
|
+
// means the client supports form elicitation. Presence-based detection is deliberate: both
|
|
675
|
+
// `undefined` and `null` are unsupported, and an empty `{}` `form` IS supported (the UNSTABLE
|
|
676
|
+
// ElicitationFormCapabilities type carries only an optional `_meta`, so a present `form` is
|
|
677
|
+
// legitimately `{}` — detection MUST be presence-based, not truthiness). Written as explicit
|
|
678
|
+
// `!== undefined && !== null` (not `!= null`) to satisfy the eqeqeq lint rule.
|
|
679
|
+
const elicitationForm = request.clientCapabilities?.elicitation?.form;
|
|
680
|
+
this.clientSupportsElicitationForm = elicitationForm !== undefined && elicitationForm !== null;
|
|
681
|
+
// Story 065 (Task 6.1 live-probe): make the negotiated capability observable in the Zed logs so
|
|
682
|
+
// the in-Zed verdict (form rendered vs. gated-dormant behind the 064 deny) is deterministic. Goes
|
|
683
|
+
// to STDERR via logger.error — NEVER stdout, which carries the ACP ndJson stream.
|
|
684
|
+
this.logger.error(`[065] clientCapabilities.elicitation.form advertised: ${this.clientSupportsElicitationForm}`);
|
|
580
685
|
// Bypasses standard auth by routing requests through a custom Anthropic-protocol gateway.
|
|
581
686
|
// Only offered when the client advertises `auth._meta.gateway` capability.
|
|
582
687
|
const supportsGatewayAuth = request.clientCapabilities?.auth?._meta?.gateway === true;
|
|
@@ -780,6 +885,19 @@ export class ClaudeAcpAgent {
|
|
|
780
885
|
}
|
|
781
886
|
throw new Error("Method not implemented.");
|
|
782
887
|
}
|
|
888
|
+
/**
|
|
889
|
+
* ACP `logout` (acp-sdk 1.0.0, acp.d.ts:1646). Under the PTY engine the bridge
|
|
890
|
+
* authenticates lazily and only tracks an in-memory `gatewayAuthRequest`; the
|
|
891
|
+
* interactive `claude` TUI owns the on-disk credential lifecycle. So `logout`
|
|
892
|
+
* here drops the in-memory auth intent and re-offers a clean handshake on the
|
|
893
|
+
* next `initialize()` (authMethods are recomputed there, unconditioned by this
|
|
894
|
+
* field). It does NOT read/write/delete `~/.claude` (billing seam — story 062
|
|
895
|
+
* R2) and never bridges `/logout` to the PTY (R3). Idempotent with no prior
|
|
896
|
+
* authenticate() (R4); active sessions are untouched (R6).
|
|
897
|
+
*/
|
|
898
|
+
async logout(_params) {
|
|
899
|
+
this.gatewayAuthRequest = undefined;
|
|
900
|
+
}
|
|
783
901
|
async prompt(params) {
|
|
784
902
|
const sessionRecord = this.sessions[params.sessionId];
|
|
785
903
|
if (!sessionRecord) {
|
|
@@ -983,6 +1101,8 @@ export class ClaudeAcpAgent {
|
|
|
983
1101
|
}
|
|
984
1102
|
/** Tear down all active sessions. Called when the ACP connection closes. */
|
|
985
1103
|
async dispose() {
|
|
1104
|
+
// Drop the in-memory auth intent on teardown (story 062 R7) — same clear as logout().
|
|
1105
|
+
this.gatewayAuthRequest = undefined;
|
|
986
1106
|
await Promise.all(Object.keys(this.sessions).map((id) => this.teardownSession(id)));
|
|
987
1107
|
}
|
|
988
1108
|
async closeSession(params) {
|
|
@@ -992,7 +1112,7 @@ export class ClaudeAcpAgent {
|
|
|
992
1112
|
await this.teardownSession(params.sessionId);
|
|
993
1113
|
return {};
|
|
994
1114
|
}
|
|
995
|
-
async
|
|
1115
|
+
async deleteSession(params) {
|
|
996
1116
|
// Tear down any active in-memory state first so the on-disk file isn't
|
|
997
1117
|
// recreated by an outstanding query writing to it.
|
|
998
1118
|
if (this.sessions[params.sessionId]) {
|
|
@@ -1019,6 +1139,26 @@ export class ClaudeAcpAgent {
|
|
|
1019
1139
|
if (!session) {
|
|
1020
1140
|
throw new Error("Session not found");
|
|
1021
1141
|
}
|
|
1142
|
+
// Story 074 (#828, R4.3): the `fast` option may be advertised as a boolean (when the client
|
|
1143
|
+
// advertised boolean config options) OR as the on/off select. A boolean payload has no select
|
|
1144
|
+
// `options` to validate against and would trip the string-only guard below — resolve it directly and
|
|
1145
|
+
// apply it via the SAME PTY `/fast on|off` inject (mechanism unchanged), then reflect the toggle in
|
|
1146
|
+
// the option's currentValue (boolean or on/off, matching how it was advertised). The on/off STRING
|
|
1147
|
+
// payload still flows through the generic select validation below. NO createSession/prompt touch.
|
|
1148
|
+
if (params.configId === FAST_MODE_CONFIG_ID && typeof params.value === "boolean") {
|
|
1149
|
+
const option = session.configOptions.find((o) => o.id === FAST_MODE_CONFIG_ID);
|
|
1150
|
+
if (!option) {
|
|
1151
|
+
throw new Error(`Unknown config option: ${params.configId}`);
|
|
1152
|
+
}
|
|
1153
|
+
const enabled = resolveFastModeEnabled(params.value);
|
|
1154
|
+
this.applyFastModeChange(session, enabled);
|
|
1155
|
+
session.configOptions = session.configOptions.map((o) => o.id === FAST_MODE_CONFIG_ID
|
|
1156
|
+
? o.type === "boolean"
|
|
1157
|
+
? { ...o, currentValue: enabled }
|
|
1158
|
+
: { ...o, currentValue: enabled ? FAST_MODE_ON : FAST_MODE_OFF }
|
|
1159
|
+
: o);
|
|
1160
|
+
return { configOptions: session.configOptions };
|
|
1161
|
+
}
|
|
1022
1162
|
if (typeof params.value !== "string") {
|
|
1023
1163
|
throw new Error(`Invalid value for config option ${params.configId}: ${params.value}`);
|
|
1024
1164
|
}
|
|
@@ -1100,6 +1240,13 @@ export class ClaudeAcpAgent {
|
|
|
1100
1240
|
// skipped so the prior currentValue stays unchanged (R3.7-style failure path).
|
|
1101
1241
|
await this.applyAgentChange(params.sessionId, session, resolvedValue);
|
|
1102
1242
|
}
|
|
1243
|
+
else if (params.configId === FAST_MODE_CONFIG_ID) {
|
|
1244
|
+
// Story 073 (R3): fast mode is a LIVE `/fast on|off` inject (mirrors /effort — no re-spawn, works
|
|
1245
|
+
// pre-first-interaction, defers mid-turn). It never throws, so applyConfigOptionValue below always
|
|
1246
|
+
// commits the new currentValue (optimistic, like /effort). This is the SELECT (on/off string)
|
|
1247
|
+
// path; a boolean payload is resolved earlier (story 074, R4.3). resolveFastModeEnabled unifies both.
|
|
1248
|
+
this.applyFastModeChange(session, resolveFastModeEnabled(resolvedValue));
|
|
1249
|
+
}
|
|
1103
1250
|
await this.applyConfigOptionValue(params.sessionId, session, params.configId, resolvedValue);
|
|
1104
1251
|
return { configOptions: session.configOptions };
|
|
1105
1252
|
}
|
|
@@ -1214,6 +1361,12 @@ export class ClaudeAcpAgent {
|
|
|
1214
1361
|
session.pendingEffortInjection = undefined;
|
|
1215
1362
|
this.injectEffortCommand(session, effort);
|
|
1216
1363
|
}
|
|
1364
|
+
// Story 073 (R3.1) — flush a deferred `/fast on|off` injection too (last-write-wins).
|
|
1365
|
+
const fast = session.pendingFastInjection;
|
|
1366
|
+
if (fast !== undefined) {
|
|
1367
|
+
session.pendingFastInjection = undefined;
|
|
1368
|
+
this.injectFastCommand(session, fast);
|
|
1369
|
+
}
|
|
1217
1370
|
}
|
|
1218
1371
|
/**
|
|
1219
1372
|
* Story 046 (R3.3, design §6b) — drive the TUI to `target` with closed-loop raw Shift+Tab. Writes
|
|
@@ -1451,6 +1604,86 @@ export class ClaudeAcpAgent {
|
|
|
1451
1604
|
injectEffortCommand(session, level) {
|
|
1452
1605
|
sendPrompt(session.pty, `/effort ${level}`, (fn) => fn());
|
|
1453
1606
|
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Story 073 (R3) — apply a fast-mode toggle LIVE via `/fast on|off`, mirroring {@link applyEffortChange}
|
|
1609
|
+
* exactly: a side-channel PTY write, no re-spawn, no turn, works before the first interaction. A no-op
|
|
1610
|
+
* (same on/off state) applies nothing; mid-turn it defers (pendingFastInjection) and flushes when the
|
|
1611
|
+
* turn settles. `enabled` is the resolved boolean state (story 074 R4.3 — resolveFastModeEnabled maps
|
|
1612
|
+
* a boolean payload OR the on/off string to it). NO billing/spawn/credential change (R3.3).
|
|
1613
|
+
*/
|
|
1614
|
+
applyFastModeChange(session, enabled) {
|
|
1615
|
+
if (enabled === (session.fastModeOn ?? false))
|
|
1616
|
+
return; // no state change → no-op
|
|
1617
|
+
session.fastModeOn = enabled;
|
|
1618
|
+
if (session.turnDetector !== undefined) {
|
|
1619
|
+
// A turn is in flight — injecting mid-turn corrupts the PTY input. Defer (mirrors /effort, /model).
|
|
1620
|
+
session.pendingFastInjection = enabled;
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
this.injectFastCommand(session, enabled);
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Side-channel `/fast on|off` write — synchronous, resolves immediately (never a turn). In claude
|
|
1627
|
+
* 2.1.201 `/fast` is a `local-jsx` command: `/fast on|off` opens the "Fast mode (research preview)"
|
|
1628
|
+
* confirmation panel (`tengu_fast_mode_picker_shown`) and leaves it OPEN — the arg pre-selects the
|
|
1629
|
+
* target but does NOT auto-apply. So, exactly like {@link injectModelCommand}'s "Switch model?"
|
|
1630
|
+
* dialog, schedule ONE blind confirm Enter once the panel has rendered; if no panel appears (same
|
|
1631
|
+
* state / flag flipped) Enter-on-empty-input is a harmless no-op. (Superseded the earlier INLINE
|
|
1632
|
+
* assumption, which left the panel unconfirmed so the toggle never took — story 073 R7.3 live-proof.)
|
|
1633
|
+
*/
|
|
1634
|
+
injectFastCommand(session, on) {
|
|
1635
|
+
sendPrompt(session.pty, on ? "/fast on" : "/fast off", (fn) => fn());
|
|
1636
|
+
// Confirm the fast-mode panel — blind + scheduled, mirroring the /model "Switch?" confirm.
|
|
1637
|
+
this.schedule(() => {
|
|
1638
|
+
if (session.engine?.isDisposed)
|
|
1639
|
+
return; // PTY exited meanwhile → nothing to confirm
|
|
1640
|
+
session.pty.write("\r");
|
|
1641
|
+
}, MODEL_CONFIRM_DELAY_MS);
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Story 073 (R1) — (re-)probe fast-mode availability for a session and reconcile the `fast` toggle.
|
|
1645
|
+
* On a non-Opus model it forces the toggle OFF/absent WITHOUT probing (R4.1); on an Opus model it
|
|
1646
|
+
* consults the injectable {@link FastModeProbe} (production default fails closed), caches the result
|
|
1647
|
+
* (R1.3), rebuilds `configOptions`, and emits a `config_option_update` only when the visible option
|
|
1648
|
+
* set changes. Fire-and-forget from createSession + the model-switch reconcile (R4.2).
|
|
1649
|
+
*/
|
|
1650
|
+
async refreshFastMode(sessionId, session) {
|
|
1651
|
+
const modelOpt = session.configOptions.find((o) => o.id === "model");
|
|
1652
|
+
const modelId = typeof modelOpt?.currentValue === "string" ? modelOpt.currentValue : DEFAULT_MODEL_INFO.value;
|
|
1653
|
+
let available;
|
|
1654
|
+
if (!isFastModeCapableModel(modelId)) {
|
|
1655
|
+
available = false; // non-Opus → never advertise, never probe (R2.2/R4.1)
|
|
1656
|
+
}
|
|
1657
|
+
else {
|
|
1658
|
+
try {
|
|
1659
|
+
available = await this.fastModeProbe({ pty: session.pty, cwd: session.cwd });
|
|
1660
|
+
}
|
|
1661
|
+
catch {
|
|
1662
|
+
available = false; // a throwing probe fails CLOSED (R1.2)
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
const before = session.fastModeAvailable ?? false;
|
|
1666
|
+
session.fastModeAvailable = available;
|
|
1667
|
+
if (available === before)
|
|
1668
|
+
return; // no visible change → no rebuild/emit
|
|
1669
|
+
session.configOptions = this.rebuildConfigOptionsPreserving(session, modelId);
|
|
1670
|
+
// The session may have been torn down while the probe was awaited — guard the emit.
|
|
1671
|
+
if (!this.sessions[sessionId])
|
|
1672
|
+
return;
|
|
1673
|
+
await this.client.sessionUpdate({
|
|
1674
|
+
sessionId,
|
|
1675
|
+
update: { sessionUpdate: "config_option_update", configOptions: session.configOptions },
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
/** Story 073 — rebuild `configOptions` from the session's current selections (model/effort/agent) plus
|
|
1679
|
+
* the fast-mode state, without re-globbing agents. Used by {@link refreshFastMode}. */
|
|
1680
|
+
rebuildConfigOptionsPreserving(session, modelId) {
|
|
1681
|
+
const effortOpt = session.configOptions.find((o) => o.id === "effort");
|
|
1682
|
+
const currentEffort = typeof effortOpt?.currentValue === "string" ? effortOpt.currentValue : undefined;
|
|
1683
|
+
const agentOpt = session.configOptions.find((o) => o.id === "agent");
|
|
1684
|
+
const currentAgent = typeof agentOpt?.currentValue === "string" ? agentOpt.currentValue : undefined;
|
|
1685
|
+
return buildConfigOptions(session.modes, modelId, session.modelInfos, currentEffort, session.agents ?? [], currentAgent, session.fastModeAvailable ?? false, session.fastModeOn ?? false, clientSupportsBooleanConfigOptions(this.clientCapabilities));
|
|
1686
|
+
}
|
|
1454
1687
|
/**
|
|
1455
1688
|
* Story 056 (R3.3/R3.4) — apply a main-thread agent-persona change. Like effort, the persona has no
|
|
1456
1689
|
* live mid-session mechanism (`--agent "<name>"` is a spawn flag), so a change re-spawns in place
|
|
@@ -1585,6 +1818,14 @@ export class ClaudeAcpAgent {
|
|
|
1585
1818
|
// in pumpUpdates, so the replay-only load never emitted it).
|
|
1586
1819
|
if (session && !session.usageDisabled) {
|
|
1587
1820
|
const carrier = turn.message.message ?? {};
|
|
1821
|
+
// Story 069 (R1) — refine the window from the turn's REAL model (the JSONL `model`), authoritatively
|
|
1822
|
+
// correcting the alias seed (e.g. default → claude-opus-4-8[1m] → 1M). A missing / non-string model or
|
|
1823
|
+
// an unknown id leaves the current value unchanged (R1.3 — never overwrite with null).
|
|
1824
|
+
const realModel = carrier.model;
|
|
1825
|
+
if (typeof realModel === "string" && realModel.length > 0) {
|
|
1826
|
+
session.contextWindowSize =
|
|
1827
|
+
inferContextWindowFromModelId(realModel) ?? session.contextWindowSize;
|
|
1828
|
+
}
|
|
1588
1829
|
for (const usageUpdate of usageUpdatesFor(carrier, {
|
|
1589
1830
|
usageUpdate: this.usageUpdate,
|
|
1590
1831
|
contextWindowSize: session.contextWindowSize,
|
|
@@ -1914,15 +2155,26 @@ export class ClaudeAcpAgent {
|
|
|
1914
2155
|
const session = this.sessions[sessionId];
|
|
1915
2156
|
if (!session)
|
|
1916
2157
|
return;
|
|
1917
|
-
// === SEAM(023) Group 1:
|
|
1918
|
-
// `query.supportedCommands()`
|
|
1919
|
-
//
|
|
1920
|
-
//
|
|
2158
|
+
// === SEAM(023) Group 1: `available_commands_update`. Historically the SDK
|
|
2159
|
+
// `query.supportedCommands()` was dropped (slash commands are owned by the interactive TUI and are
|
|
2160
|
+
// not enumerable over the read-only JSONL path), so Degrau-1 emitted a static empty set.
|
|
2161
|
+
// Story 063 (R1/R1.1) now POPULATES this set OFFLINE from disk — `discoverCommands(session.cwd)`
|
|
2162
|
+
// scans the cwd/user `.claude/{commands,skills}`, the enabled-plugin surfaces, and the built-in
|
|
2163
|
+
// tier — instead of the unconditional `[]`. Discovery is SYNCHRONOUS but the 4 call-sites invoke
|
|
2164
|
+
// this method fire-and-forget (`setTimeout(0)`), so it never blocks session creation (R4).
|
|
2165
|
+
// Degrau 2 (030/032): PTY-backed control — surface the TUI's real live command set. ===
|
|
2166
|
+
let availableCommands;
|
|
2167
|
+
try {
|
|
2168
|
+
availableCommands = this.discoverCommands(session.cwd);
|
|
2169
|
+
}
|
|
2170
|
+
catch {
|
|
2171
|
+
availableCommands = []; // R4 — discovery must NEVER crash the session; degrade to []
|
|
2172
|
+
}
|
|
1921
2173
|
await this.client.sessionUpdate({
|
|
1922
2174
|
sessionId,
|
|
1923
2175
|
update: {
|
|
1924
2176
|
sessionUpdate: "available_commands_update",
|
|
1925
|
-
availableCommands
|
|
2177
|
+
availableCommands,
|
|
1926
2178
|
},
|
|
1927
2179
|
});
|
|
1928
2180
|
}
|
|
@@ -1987,7 +2239,20 @@ export class ClaudeAcpAgent {
|
|
|
1987
2239
|
// keeps the option absent when none were discovered (the gate).
|
|
1988
2240
|
const agentOpt = session.configOptions.find((o) => o.id === "agent");
|
|
1989
2241
|
const currentAgent = typeof agentOpt?.currentValue === "string" ? agentOpt.currentValue : undefined;
|
|
1990
|
-
|
|
2242
|
+
// Story 073 (R4.1) — a model switch turns fast mode OFF and drops its availability (mirroring the
|
|
2243
|
+
// CLI's "switching to other models turns off fast mode"). The rebuild below therefore omits the
|
|
2244
|
+
// toggle; if the new model is Opus, refreshFastMode (kicked off after) re-probes and re-advertises.
|
|
2245
|
+
if (previousModelId !== value) {
|
|
2246
|
+
session.fastModeOn = false;
|
|
2247
|
+
session.fastModeAvailable = false;
|
|
2248
|
+
}
|
|
2249
|
+
session.configOptions = buildConfigOptions(session.modes, value, session.modelInfos, currentEffort, session.agents ?? [], currentAgent, session.fastModeAvailable ?? false, session.fastModeOn ?? false, clientSupportsBooleanConfigOptions(this.clientCapabilities));
|
|
2250
|
+
// Story 073 (R4.2) — on a switch TO an Opus model, re-run availability detection out of band and
|
|
2251
|
+
// re-advertise the toggle (as off) when available. Fire-and-forget: the synchronous response above
|
|
2252
|
+
// ships without the toggle; refreshFastMode emits a follow-up config_option_update once it settles.
|
|
2253
|
+
if (previousModelId !== value && isFastModeCapableModel(value)) {
|
|
2254
|
+
void this.refreshFastMode(sessionId, session);
|
|
2255
|
+
}
|
|
1991
2256
|
// === SEAM(023) Group 1: the SDK effort sync (query.applyFlagSettings) after a model switch is
|
|
1992
2257
|
// dropped — configOptions already reflects the new effort locally.
|
|
1993
2258
|
// Degrau 2 (030/032): PTY-backed control. ===
|
|
@@ -2113,6 +2378,11 @@ export class ClaudeAcpAgent {
|
|
|
2113
2378
|
gate = await setupSessionGate({
|
|
2114
2379
|
...this.gateOptions,
|
|
2115
2380
|
client: this.client,
|
|
2381
|
+
// Story 065 (R1/R3): negotiated in initialize() from clientCapabilities.elicitation.form. When
|
|
2382
|
+
// true the gate drives AskUserQuestion through a real ACP form elicitation; when false it keeps
|
|
2383
|
+
// the story-064 fail-closed deny-guard. this.client (AgentSideConnection) already satisfies the
|
|
2384
|
+
// broadened client type (it has unstable_createElicitation).
|
|
2385
|
+
clientSupportsElicitationForm: this.clientSupportsElicitationForm,
|
|
2116
2386
|
onWarn: (m) => this.logger.error(m),
|
|
2117
2387
|
});
|
|
2118
2388
|
}
|
|
@@ -2246,6 +2516,11 @@ export class ClaudeAcpAgent {
|
|
|
2246
2516
|
taskState,
|
|
2247
2517
|
gate,
|
|
2248
2518
|
};
|
|
2519
|
+
// Story 073 (R1) — the seed model is Opus (`default`), so probe fast-mode availability out of band
|
|
2520
|
+
// and advertise the toggle when available. Fire-and-forget (like sendAvailableCommandsUpdate): the
|
|
2521
|
+
// response below ships the seed options; refreshFastMode emits a follow-up config_option_update. The
|
|
2522
|
+
// production probe fails closed, so today's stream is byte-for-byte unaffected until the spike wires it.
|
|
2523
|
+
void this.refreshFastMode(startedSessionId, this.sessions[startedSessionId]);
|
|
2249
2524
|
return {
|
|
2250
2525
|
sessionId: startedSessionId,
|
|
2251
2526
|
modes,
|
|
@@ -2301,7 +2576,7 @@ function buildAvailableModes(modelInfo) {
|
|
|
2301
2576
|
// `applyFlagSettings` in @anthropic-ai/claude-agent-sdk. Mapping both the
|
|
2302
2577
|
// `"default"` sentinel and `undefined` (effort option absent for the model) to
|
|
2303
2578
|
// `null` ensures any previously-applied flag is actually cleared.
|
|
2304
|
-
function buildConfigOptions(modes, currentModelId, modelInfos, currentEffortLevel, agents = [], currentAgent) {
|
|
2579
|
+
function buildConfigOptions(modes, currentModelId, modelInfos, currentEffortLevel, agents = [], currentAgent, fastAvailable = false, currentFast = false, fastUsesBooleanOption = false) {
|
|
2305
2580
|
const options = [
|
|
2306
2581
|
{
|
|
2307
2582
|
id: "mode",
|
|
@@ -2326,10 +2601,21 @@ function buildConfigOptions(modes, currentModelId, modelInfos, currentEffortLeve
|
|
|
2326
2601
|
options: modelInfos.map((m) => ({
|
|
2327
2602
|
value: m.value,
|
|
2328
2603
|
name: m.displayName,
|
|
2329
|
-
|
|
2604
|
+
// Story 072 — prepend the version/context label ("Opus 4.8 with 1M context · <tagline>"),
|
|
2605
|
+
// mirroring the live `/model` picker; bare tagline when no label (e.g. opusplan).
|
|
2606
|
+
description: modelSelectorDescription(m) || undefined,
|
|
2330
2607
|
})),
|
|
2331
2608
|
},
|
|
2332
2609
|
];
|
|
2610
|
+
// Story 073 (R2) — the fast-mode toggle, positioned right after the model selector. GATED on an
|
|
2611
|
+
// Opus alias (R2.2, isFastModeCapableModel) AND detected availability (R1, fastAvailable): fast mode
|
|
2612
|
+
// is Opus-only and account-gated, so a non-Opus model or an unavailable account omits it entirely.
|
|
2613
|
+
// Story 074 (#828, R4.1): the option is emitted as `type:"boolean"` when the client advertised
|
|
2614
|
+
// boolean config options (fastUsesBooleanOption), else the `on`/`off` select fallback — via the
|
|
2615
|
+
// model-catalog helper. currentValue mirrors the session's fast-mode state.
|
|
2616
|
+
if (isFastModeCapableModel(currentModelId) && fastAvailable) {
|
|
2617
|
+
options.push(createFastModeConfigOption(currentFast, fastUsesBooleanOption));
|
|
2618
|
+
}
|
|
2333
2619
|
// Add effort level option based on the currently selected model
|
|
2334
2620
|
const currentModelInfo = modelInfos.find((m) => m.value === currentModelId);
|
|
2335
2621
|
const supportedLevels = currentModelInfo?.supportsEffort
|
|
@@ -2634,6 +2920,12 @@ export function toAcpNotifications(content, role, sessionId, toolUseCache, clien
|
|
|
2634
2920
|
const registerHooks = options?.registerHooks !== false;
|
|
2635
2921
|
const supportsTerminalOutput = options?.clientCapabilities?._meta?.["terminal_output"] === true;
|
|
2636
2922
|
if (typeof content === "string") {
|
|
2923
|
+
// Story 074 (#841): an empty full-string content block must emit NO message chunk
|
|
2924
|
+
// (an empty agent_message_chunk breaks strict ACP clients — e.g. JetBrains Air
|
|
2925
|
+
// freezes the transcript). Mirrors the empty-thinking guard (#793). The
|
|
2926
|
+
// `case "text"`/`text_delta` block path stays DEAD (no content_block_delta, 034).
|
|
2927
|
+
if (content.length === 0)
|
|
2928
|
+
return [];
|
|
2637
2929
|
const update = {
|
|
2638
2930
|
sessionUpdate: role === "assistant" ? "agent_message_chunk" : "user_message_chunk",
|
|
2639
2931
|
content: {
|
|
@@ -2955,13 +3247,60 @@ export function runAcp(deps) {
|
|
|
2955
3247
|
}, stream);
|
|
2956
3248
|
return { connection, agent };
|
|
2957
3249
|
}
|
|
2958
|
-
/**
|
|
2959
|
-
*
|
|
2960
|
-
*
|
|
2961
|
-
*
|
|
2962
|
-
*
|
|
2963
|
-
|
|
3250
|
+
/** Resolve a model alias's context window (the usage_update `size` denominator).
|
|
3251
|
+
* NOTE (story 068): there is NO `result.modelUsage` window to refresh from — the
|
|
3252
|
+
* JSONL `usage` carries only token counts; the window comes from static curation
|
|
3253
|
+
* (the Models API `max_input_tokens` is the real authority, which this fork does
|
|
3254
|
+
* not call), as detailed below.
|
|
3255
|
+
*
|
|
3256
|
+
* Story 068 (R1, R1.1, R1.2): consults the static {@link MODEL_CONTEXT_WINDOWS}
|
|
3257
|
+
* alias→window map FIRST (an exact catalog-`value` hit — `default`/`fable5`/`opus`/
|
|
3258
|
+
* `sonnet`=1M, `haiku`=200K). This fixes `opus` having wrongly reported 200K, and
|
|
3259
|
+
* `sonnet` now seeds 1M (Sonnet 5 is native 1M). An alias absent from the map then
|
|
3260
|
+
* falls back to the legacy `\b1m\b` inference: Anthropic 1M-context variants
|
|
3261
|
+
* encode "1m" as a distinct token in the SDK model ID (e.g., "claude-opus-4-6-1m"),
|
|
3262
|
+
* which `\b1m\b` catches without also matching "10m" or embedded substrings.
|
|
3263
|
+
* `null` (fully unknown) is intentional — the two call sites apply
|
|
3264
|
+
* `?? DEFAULT_CONTEXT_WINDOW`. */
|
|
3265
|
+
export function inferContextWindowFromModel(model) {
|
|
3266
|
+
const mapped = MODEL_CONTEXT_WINDOWS[model];
|
|
3267
|
+
if (mapped !== undefined)
|
|
3268
|
+
return mapped; // exact alias hit (!== undefined, NOT truthiness)
|
|
2964
3269
|
if (/\b1m\b/i.test(model))
|
|
3270
|
+
return 1_000_000; // unknown alias that still encodes a 1m token
|
|
3271
|
+
return null; // caller applies ?? DEFAULT_CONTEXT_WINDOW
|
|
3272
|
+
}
|
|
3273
|
+
/** Story 069 (R1) — AUTHORITATIVE context window from a turn's REAL model ID (the JSONL `model`
|
|
3274
|
+
* field), used by the pump to refine the alias seed once the model is known. Exact-ID lookup first
|
|
3275
|
+
* (MODEL_ID_CONTEXT_WINDOWS), then a family+version heuristic for dated snapshots / future variants
|
|
3276
|
+
* (Opus is NOT uniform: 4.6 and earlier = 200K, 4.7+ = 1M; Sonnet 4.x = 200K but Sonnet 5+ = 1M;
|
|
3277
|
+
* haiku = 200K; fable = 1M — story 071), then a
|
|
3278
|
+
* `\b1m\b` suffix, then null (R1.3: a missing / non-string id never refines). */
|
|
3279
|
+
export function inferContextWindowFromModelId(id) {
|
|
3280
|
+
if (typeof id !== "string" || id.length === 0)
|
|
3281
|
+
return null;
|
|
3282
|
+
const exact = MODEL_ID_CONTEXT_WINDOWS[id];
|
|
3283
|
+
if (exact !== undefined)
|
|
3284
|
+
return exact;
|
|
3285
|
+
// An explicit long-context `[1m]`/`-1m` suffix wins over the family heuristic
|
|
3286
|
+
// (`claude-sonnet-…[1m]` = 1M, not 200K; `/model default` resolves to `claude-opus-4-8[1m]`).
|
|
3287
|
+
if (/\b1m\b/i.test(id))
|
|
3288
|
+
return 1_000_000;
|
|
3289
|
+
const opus = id.match(/claude-opus-(\d+)-(\d+)/);
|
|
3290
|
+
if (opus) {
|
|
3291
|
+
const major = Number(opus[1]);
|
|
3292
|
+
const minor = Number(opus[2]);
|
|
3293
|
+
return major > 4 || (major === 4 && minor >= 7) ? 1_000_000 : 200_000;
|
|
3294
|
+
}
|
|
3295
|
+
if (/claude-fable/.test(id))
|
|
2965
3296
|
return 1_000_000;
|
|
3297
|
+
// Sonnet is NOT uniform across generations (story 071): the subscription CLI serves Sonnet 4.x
|
|
3298
|
+
// at 200K but Sonnet 5+ natively at 1M (Sonnet 5 has no smaller context variant). Version-aware,
|
|
3299
|
+
// like the Opus 4-6 vs 4-7/4-8 split above; dated snapshots (`claude-sonnet-5-<date>`) match too.
|
|
3300
|
+
const sonnet = id.match(/claude-sonnet-(\d+)/);
|
|
3301
|
+
if (sonnet)
|
|
3302
|
+
return Number(sonnet[1]) >= 5 ? 1_000_000 : 200_000;
|
|
3303
|
+
if (/claude-haiku/.test(id))
|
|
3304
|
+
return 200_000;
|
|
2966
3305
|
return null;
|
|
2967
3306
|
}
|
package/dist/agent-catalog.d.ts
CHANGED
package/dist/ansi-mirror.d.ts
CHANGED
package/dist/besteffort.d.ts
CHANGED
|
@@ -94,4 +94,3 @@ export declare function guardEvent(event: WatchedMessage, hooks: GuardHooks): Gu
|
|
|
94
94
|
* is the spawn helper's anti-recusa concern, distinct from this billing check — §10).
|
|
95
95
|
*/
|
|
96
96
|
export declare function assertCleanBillingEnv(env: Record<string, string | undefined>): void;
|
|
97
|
-
//# sourceMappingURL=entrypoint-guard.d.ts.map
|
package/dist/claude-path.d.ts
CHANGED