@lucascouts/claude-agent-tui 0.17.4 → 0.17.5
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.
|
@@ -4,6 +4,13 @@ export declare const FORK_HOOK_MARKER_PATH = "/__fork-acp-gate__";
|
|
|
4
4
|
export declare const FORK_HOOK_MARKER_KEY = "__forkAcpGate";
|
|
5
5
|
/** Default hook timeout in SECONDS (claude default is 600); kept a parameter so nothing is magic. */
|
|
6
6
|
export declare const DEFAULT_HOOK_TIMEOUT_SECONDS = 600;
|
|
7
|
+
/**
|
|
8
|
+
* Renderer pinned in the per-session scratch settings. The native-prompt markers the gate and the
|
|
9
|
+
* PTY reader match were measured on the classic renderer; a user file selecting `"tui":
|
|
10
|
+
* "fullscreen"` would otherwise draw the PTY claude on the alternate screen. The `--settings`
|
|
11
|
+
* layer outranks the user file, so pinning it here wins.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SCRATCH_RENDERER = "default";
|
|
7
14
|
/** Tool matcher for the gate hook; `"*"` matches all tools (the shape the story-007 probe fired). */
|
|
8
15
|
export declare const FORK_HOOK_MATCHER = "*";
|
|
9
16
|
/** A single http-hook entry as it appears inside a matcher group's `hooks` array (story-007 shape). */
|
|
@@ -11,6 +18,15 @@ export interface HttpHookEntry {
|
|
|
11
18
|
type: "http";
|
|
12
19
|
url: string;
|
|
13
20
|
timeout: number;
|
|
21
|
+
/**
|
|
22
|
+
* What claude does when the hook cannot answer: a dead or unreachable server, a timeout, a
|
|
23
|
+
* malformed reply, or a loopback URL that a managed `allowedHttpHookUrls` refuses. Without
|
|
24
|
+
* `"block"` claude treats such a hook as not having answered and hands the call to its own
|
|
25
|
+
* permission flow, where an allow rule or auto mode can run it with nobody deciding (CLI
|
|
26
|
+
* 2.1.330 strings: a failing hook counts as a block only "where onFailure is 'block'";
|
|
27
|
+
* supported for http hooks since CLI 2.1.295). The gate must fail closed, so it is always set.
|
|
28
|
+
*/
|
|
29
|
+
onFailure: "block";
|
|
14
30
|
}
|
|
15
31
|
/** The `{ matcher, hooks:[…] }` group as it appears under `PreToolUse`, plus the fork sentinel key. */
|
|
16
32
|
export interface PreToolUseGroup {
|
|
@@ -94,6 +110,8 @@ export interface Backup {
|
|
|
94
110
|
existed: boolean;
|
|
95
111
|
/** The exact prior file bytes (only when `existed` is true). */
|
|
96
112
|
priorBytes: Buffer | null;
|
|
113
|
+
/** The `tui` value {@link injectHook} wrote, so {@link restore} can take it back out. */
|
|
114
|
+
injectedRenderer?: string;
|
|
97
115
|
}
|
|
98
116
|
/** Result of {@link restore}: which removal path ran (`'surgical'` preferred, `'backup'` fallback). */
|
|
99
117
|
export interface RestoreResult {
|
|
@@ -124,6 +142,8 @@ export declare function injectHook(opts: {
|
|
|
124
142
|
timeout?: number;
|
|
125
143
|
/** Story 055 (R1.3) — per-session token bound into the hook URL after {@link FORK_HOOK_MARKER_PATH}. */
|
|
126
144
|
token?: string;
|
|
145
|
+
/** When given, written as the top-level `tui` key (see {@link SCRATCH_RENDERER}). */
|
|
146
|
+
renderer?: string;
|
|
127
147
|
}): Promise<Backup>;
|
|
128
148
|
/**
|
|
129
149
|
* Teardown: remove the fork's injected hook, leaving ZERO residue (R4.2, R4.3).
|
|
@@ -31,6 +31,13 @@ export const FORK_HOOK_MARKER_PATH = "/__fork-acp-gate__";
|
|
|
31
31
|
export const FORK_HOOK_MARKER_KEY = "__forkAcpGate";
|
|
32
32
|
/** Default hook timeout in SECONDS (claude default is 600); kept a parameter so nothing is magic. */
|
|
33
33
|
export const DEFAULT_HOOK_TIMEOUT_SECONDS = 600;
|
|
34
|
+
/**
|
|
35
|
+
* Renderer pinned in the per-session scratch settings. The native-prompt markers the gate and the
|
|
36
|
+
* PTY reader match were measured on the classic renderer; a user file selecting `"tui":
|
|
37
|
+
* "fullscreen"` would otherwise draw the PTY claude on the alternate screen. The `--settings`
|
|
38
|
+
* layer outranks the user file, so pinning it here wins.
|
|
39
|
+
*/
|
|
40
|
+
export const SCRATCH_RENDERER = "default";
|
|
34
41
|
/** Tool matcher for the gate hook; `"*"` matches all tools (the shape the story-007 probe fired). */
|
|
35
42
|
export const FORK_HOOK_MATCHER = "*";
|
|
36
43
|
/**
|
|
@@ -62,6 +69,7 @@ export function buildHookEntry(port, optsOrTimeout = DEFAULT_HOOK_TIMEOUT_SECOND
|
|
|
62
69
|
type: "http",
|
|
63
70
|
url: `http://127.0.0.1:${port}${FORK_HOOK_MARKER_PATH}${tokenSuffix}`,
|
|
64
71
|
timeout,
|
|
72
|
+
onFailure: "block",
|
|
65
73
|
},
|
|
66
74
|
],
|
|
67
75
|
[FORK_HOOK_MARKER_KEY]: true,
|
|
@@ -230,7 +238,7 @@ async function readPriorBytes(settingsPath) {
|
|
|
230
238
|
* deleted) before rejecting, so a failed inject never leaves a file claude could read half-written.
|
|
231
239
|
*/
|
|
232
240
|
export async function injectHook(opts) {
|
|
233
|
-
const { settingsPath, port, timeout, token } = opts;
|
|
241
|
+
const { settingsPath, port, timeout, token, renderer } = opts;
|
|
234
242
|
// 1) Snapshot the prior state (bytes or absence) — captured BEFORE any mutation (R4.1).
|
|
235
243
|
const priorBytes = await readPriorBytes(settingsPath);
|
|
236
244
|
const backup = { settingsPath, existed: priorBytes !== null, priorBytes };
|
|
@@ -243,6 +251,10 @@ export async function injectHook(opts) {
|
|
|
243
251
|
prior = text.length === 0 ? null : parsePriorSettings(text);
|
|
244
252
|
}
|
|
245
253
|
const merged = mergeHook(prior, group);
|
|
254
|
+
if (renderer !== undefined) {
|
|
255
|
+
merged.tui = renderer;
|
|
256
|
+
backup.injectedRenderer = renderer;
|
|
257
|
+
}
|
|
246
258
|
const out = `${JSON.stringify(merged, null, 2)}\n`;
|
|
247
259
|
// 3) Durably write BEFORE returning control to the spawn path (R3.1, R3.2). On failure, roll back
|
|
248
260
|
// to the prior bytes (or delete a file we just created) so claude never reads a half-written file.
|
|
@@ -330,6 +342,18 @@ export async function restore(backup) {
|
|
|
330
342
|
delete next.hooks;
|
|
331
343
|
}
|
|
332
344
|
}
|
|
345
|
+
// Take back the renderer inject wrote, unless the key has been changed since: the prior value
|
|
346
|
+
// when the file had one, else nothing. Left in place, it would keep a created file alive.
|
|
347
|
+
if (backup.injectedRenderer !== undefined && next.tui === backup.injectedRenderer) {
|
|
348
|
+
const priorText = backup.priorBytes?.toString("utf8").trim() ?? "";
|
|
349
|
+
const priorTui = priorText.length === 0 ? undefined : parsePriorSettings(priorText).tui;
|
|
350
|
+
if (priorTui === undefined) {
|
|
351
|
+
delete next.tui;
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
next.tui = priorTui;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
333
357
|
// If, after removing the fork hook, the document is empty AND the file did not exist before
|
|
334
358
|
// inject (the fork created it), delete it so no empty `{}` husk is left as residue (R4.2).
|
|
335
359
|
if (!backup.existed && Object.keys(next).length === 0) {
|
package/dist/model-catalog.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ export declare const MODEL_CATALOG: ModelInfo[];
|
|
|
60
60
|
*
|
|
61
61
|
* `sonnet` seeds to 1M because plain `sonnet` now resolves to Sonnet 5, which is natively 1M (the
|
|
62
62
|
* redundant `sonnet[1m]` alias was dropped). `default` and `opus` both resolve to Opus 5.5 and `fable`
|
|
63
|
-
* to Fable 5.
|
|
63
|
+
* to Fable 5.2 — all three natively 1M per the CLI's baked-in catalogue. This is only the
|
|
64
64
|
* PRE-FIRST-TURN seed: once a turn arrives, `inferContextWindowFromModelId` (story 069) AUTHORITATIVELY
|
|
65
65
|
* refines the window from the transcript's real `model`. Keys MIRROR `MODEL_CATALOG` `value`s; the drift
|
|
66
66
|
* guard lives in the test (068 anti-drift: every catalog value has an explicit entry).
|
package/dist/model-catalog.js
CHANGED
|
@@ -67,14 +67,15 @@ export const MODEL_CATALOG = [
|
|
|
67
67
|
{
|
|
68
68
|
value: "fable",
|
|
69
69
|
// The title carries the concrete version, matching the live CLI rows this list stands in for.
|
|
70
|
-
displayName: "Fable 5.
|
|
71
|
-
// The tier alias, PROBED not guessed: `--model fable`
|
|
72
|
-
// turn (2026-09-23)
|
|
70
|
+
displayName: "Fable 5.2",
|
|
71
|
+
// The tier alias, PROBED not guessed: `--model fable` resolved to `claude-fable-5-1` on a real
|
|
72
|
+
// turn (2026-09-23), and to `claude-fable-5-2` since CLI 2.1.321 (4872 transcript lines on this
|
|
73
|
+
// host name `claude-fable-5-2`, measured 2026-11-24 on CLI 2.1.330). It replaces the `fable51`/`fable5` rows, which the CLI rejected outright —
|
|
73
74
|
// see the closed-set note on MODEL_CATALOG above.
|
|
74
75
|
// The description is the same string the live `/model` picker shows for the top of the
|
|
75
|
-
// family — the CLI ships exactly three taglines and none is
|
|
76
|
+
// family — the CLI ships exactly three taglines and none is version-specific, so this is
|
|
76
77
|
// verbatim rather than invented.
|
|
77
|
-
description: "Fable 5.
|
|
78
|
+
description: "Fable 5.2 with 1M context · Most capable for your hardest and longest-running tasks",
|
|
78
79
|
supportsEffort: true,
|
|
79
80
|
supportedEffortLevels: REASONING_EFFORT_LEVELS,
|
|
80
81
|
supportsAutoMode: true,
|
|
@@ -119,7 +120,7 @@ export const MODEL_CATALOG = [
|
|
|
119
120
|
*
|
|
120
121
|
* `sonnet` seeds to 1M because plain `sonnet` now resolves to Sonnet 5, which is natively 1M (the
|
|
121
122
|
* redundant `sonnet[1m]` alias was dropped). `default` and `opus` both resolve to Opus 5.5 and `fable`
|
|
122
|
-
* to Fable 5.
|
|
123
|
+
* to Fable 5.2 — all three natively 1M per the CLI's baked-in catalogue. This is only the
|
|
123
124
|
* PRE-FIRST-TURN seed: once a turn arrives, `inferContextWindowFromModelId` (story 069) AUTHORITATIVELY
|
|
124
125
|
* refines the window from the transcript's real `model`. Keys MIRROR `MODEL_CATALOG` `value`s; the drift
|
|
125
126
|
* guard lives in the test (068 anti-drift: every catalog value has an explicit entry).
|
|
@@ -149,6 +150,8 @@ export const MODEL_ID_CONTEXT_WINDOWS = {
|
|
|
149
150
|
"claude-opus-4-8": 1_000_000,
|
|
150
151
|
"claude-opus-4-7": 1_000_000,
|
|
151
152
|
"claude-opus-4-6": 200_000,
|
|
153
|
+
// CLI 2.1.330's catalogue: `claude-fable-5-2` is `window: 1e6, native_1m: true`.
|
|
154
|
+
"claude-fable-5-2": 1_000_000,
|
|
152
155
|
"claude-fable-5-1": 1_000_000,
|
|
153
156
|
"claude-fable-5": 1_000_000,
|
|
154
157
|
"claude-sonnet-5-5": 1_000_000,
|
|
@@ -32,7 +32,7 @@ import * as os from "node:os";
|
|
|
32
32
|
import * as path from "node:path";
|
|
33
33
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
34
34
|
import { findFreePort } from "../gate/port.js";
|
|
35
|
-
import { DEFAULT_HOOK_TIMEOUT_SECONDS, injectHook, restore, } from "../gate/settings-writer.js";
|
|
35
|
+
import { DEFAULT_HOOK_TIMEOUT_SECONDS, injectHook, restore, SCRATCH_RENDERER, } from "../gate/settings-writer.js";
|
|
36
36
|
import { deciderBudgetMs, startHookServer, } from "./hook-server.js";
|
|
37
37
|
import { askUserQuestionDenyReason, isAskUserQuestionTool } from "./deny.js";
|
|
38
38
|
import { requestPermission, ToolUseCorrelator, } from "./request-permission.js";
|
|
@@ -249,6 +249,7 @@ class SessionGateImpl {
|
|
|
249
249
|
port: this.port,
|
|
250
250
|
token: this.token,
|
|
251
251
|
timeout: this.opts.hookTimeoutSeconds,
|
|
252
|
+
renderer: SCRATCH_RENDERER,
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
255
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.17.
|
|
6
|
+
"version": "0.17.5",
|
|
7
7
|
"description": "Runs the official Claude Code TUI over a PTY and exposes it via ACP, so Claude Code threads render natively in Zed's agent panel. Built for Anthropic's June 2026 billing split (since paused).",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@agentclientprotocol/sdk": "2.4.0",
|
|
68
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
68
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.331",
|
|
69
69
|
"node-pty": "1.1.0",
|
|
70
70
|
"zod": "^4.0.0"
|
|
71
71
|
},
|