@lucascouts/claude-agent-tui 0.17.3 → 0.17.4

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.
@@ -32,8 +32,8 @@ 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 { injectHook, restore } from "../gate/settings-writer.js";
36
- import { startHookServer, } from "./hook-server.js";
35
+ import { DEFAULT_HOOK_TIMEOUT_SECONDS, injectHook, restore, } from "../gate/settings-writer.js";
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";
39
39
  import { buildElicitationRequest, mapOutcomeToDecision, requestElicitation, } from "./elicitation-bridge.js";
@@ -236,7 +236,8 @@ class SessionGateImpl {
236
236
  this.server = await startHookServer({
237
237
  port: this.port,
238
238
  token: this.token,
239
- deciderTimeoutMs: this.opts.deciderTimeoutMs,
239
+ // Item 226: always under the hook timeout written below, so the deny reaches claude first.
240
+ deciderTimeoutMs: deciderBudgetMs(this.opts.hookTimeoutSeconds ?? DEFAULT_HOOK_TIMEOUT_SECONDS, this.opts.deciderTimeoutMs),
240
241
  onWarn: (m) => this.warn(m),
241
242
  onToolCall: (call) => this.decide(call),
242
243
  });
@@ -71,8 +71,20 @@ export interface StartHookServerOptions {
71
71
  */
72
72
  token?: string;
73
73
  }
74
- /** Default decider timeout (ms) — long enough for an async Zed decision relay, short of a hang. */
75
- export declare const DEFAULT_DECIDER_TIMEOUT_MS = 600000;
74
+ /** Time left between the decider's deny and claude giving up on the hook, so the deny crosses
75
+ * loopback first. Item 226: when claude's hook timer wins, it falls back to its own permission flow,
76
+ * and an allow rule or auto mode then runs the tool with nobody deciding (CLI 2.1.319 and 2.1.325,
77
+ * measured 2026-11-14). The decider used to wait exactly as long as the hook, and always lost. */
78
+ export declare const HOOK_DEADLINE_MARGIN_MS = 15000;
79
+ /**
80
+ * The decider's budget for a hook of `hookTimeoutSeconds`: whatever was requested, but never past the
81
+ * hook's deadline minus the margin (half the hook, for a hook shorter than twice the margin). A
82
+ * requested budget can only shorten it, so no caller can reopen item 226.
83
+ */
84
+ export declare function deciderBudgetMs(hookTimeoutSeconds: number, requestedMs: number | undefined): number;
85
+ /** Default decider timeout (ms) — the default hook's budget: long enough for a person to answer in
86
+ * Zed, and over before claude would give up on the hook. */
87
+ export declare const DEFAULT_DECIDER_TIMEOUT_MS: number;
76
88
  /**
77
89
  * Parse a PreToolUse payload from raw JSON, normalizing to {@link ForwardedToolCall}. Returns null when
78
90
  * the body is unparseable OR lacks a `tool_use_id`/`tool_name` — the caller fails closed on null (a
@@ -20,10 +20,26 @@
20
20
  import { createServer } from "node:http";
21
21
  import { appendFileSync } from "node:fs";
22
22
  import { LOOPBACK_HOST } from "../gate/port.js";
23
- import { FORK_HOOK_MARKER_PATH } from "../gate/settings-writer.js";
23
+ import { DEFAULT_HOOK_TIMEOUT_SECONDS, FORK_HOOK_MARKER_PATH } from "../gate/settings-writer.js";
24
24
  import { allowDecision, denyDecision } from "./deny.js";
25
- /** Default decider timeout (ms) — long enough for an async Zed decision relay, short of a hang. */
26
- export const DEFAULT_DECIDER_TIMEOUT_MS = 600_000;
25
+ /** Time left between the decider's deny and claude giving up on the hook, so the deny crosses
26
+ * loopback first. Item 226: when claude's hook timer wins, it falls back to its own permission flow,
27
+ * and an allow rule or auto mode then runs the tool with nobody deciding (CLI 2.1.319 and 2.1.325,
28
+ * measured 2026-11-14). The decider used to wait exactly as long as the hook, and always lost. */
29
+ export const HOOK_DEADLINE_MARGIN_MS = 15_000;
30
+ /**
31
+ * The decider's budget for a hook of `hookTimeoutSeconds`: whatever was requested, but never past the
32
+ * hook's deadline minus the margin (half the hook, for a hook shorter than twice the margin). A
33
+ * requested budget can only shorten it, so no caller can reopen item 226.
34
+ */
35
+ export function deciderBudgetMs(hookTimeoutSeconds, requestedMs) {
36
+ const hookMs = hookTimeoutSeconds * 1000;
37
+ const ceiling = hookMs - Math.min(HOOK_DEADLINE_MARGIN_MS, hookMs / 2);
38
+ return Math.min(requestedMs ?? ceiling, ceiling);
39
+ }
40
+ /** Default decider timeout (ms) — the default hook's budget: long enough for a person to answer in
41
+ * Zed, and over before claude would give up on the hook. */
42
+ export const DEFAULT_DECIDER_TIMEOUT_MS = deciderBudgetMs(DEFAULT_HOOK_TIMEOUT_SECONDS, undefined);
27
43
  /** Read a request body fully into a UTF-8 string (bounded by Node's own socket limits). */
28
44
  function readBody(req) {
29
45
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.17.3",
6
+ "version": "0.17.4",
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",