context-mode 2.1.4 → 2.1.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.
package/pi/index.js CHANGED
@@ -2666,7 +2666,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
2666
2666
  return (payload, ctx) => fn(shape, payload, ctx);
2667
2667
  };
2668
2668
  let fastpass;
2669
- const isObject8 = isObject;
2669
+ const isObject9 = isObject;
2670
2670
  const jit = !globalConfig.jitless;
2671
2671
  const allowsEval4 = allowsEval;
2672
2672
  const fastEnabled = jit && allowsEval4.value;
@@ -2675,7 +2675,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
2675
2675
  inst._zod.parse = (payload, ctx) => {
2676
2676
  value ?? (value = _normalized.value);
2677
2677
  const input = payload.value;
2678
- if (!isObject8(input)) {
2678
+ if (!isObject9(input)) {
2679
2679
  payload.issues.push({
2680
2680
  expected: "object",
2681
2681
  code: "invalid_type",
@@ -11467,6 +11467,31 @@ var SED_QUIET_FLAGS = Object.freeze(["-n", "--quiet", "--silent"]);
11467
11467
  var JQ_COMMAND = "jq";
11468
11468
  var READ_PATH_KEYS = Object.freeze(["file_path", "absolute_path", "path", "filePath"]);
11469
11469
  var READ_PATH_LIST_KEY = "filePaths";
11470
+ var READ_MEDIA_TYPES = Object.freeze({
11471
+ png: { exts: [".png"], sig: [{ at: 0, bytes: [137, 80, 78, 71, 13, 10, 26, 10] }] },
11472
+ jpeg: { exts: [".jpg", ".jpeg"], sig: [{ at: 0, bytes: [255, 216, 255] }] },
11473
+ gif: { exts: [".gif"], sig: [{ at: 0, bytes: [71, 73, 70, 56] }] },
11474
+ // "GIF8"
11475
+ webp: { exts: [".webp"], sig: [{ at: 0, bytes: [82, 73, 70, 70] }, { at: 8, bytes: [87, 69, 66, 80] }] },
11476
+ // "RIFF" .... "WEBP"
11477
+ pdf: { exts: [".pdf"], sig: [{ at: 0, bytes: [37, 80, 68, 70, 45] }] }
11478
+ // "%PDF-"
11479
+ });
11480
+ var READ_MEDIA_SNIFF_BYTES = 12;
11481
+ var READ_IMAGES = Object.freeze(["png", "jpeg", "gif", "webp"]);
11482
+ var READ_IMAGES_AND_PDF = Object.freeze([...READ_IMAGES, "pdf"]);
11483
+ var READ_MEDIA_BY_AGENT = Object.freeze({
11484
+ "claude-code": READ_IMAGES_AND_PDF,
11485
+ gemini: READ_IMAGES_AND_PDF,
11486
+ qwen: READ_IMAGES_AND_PDF,
11487
+ opencode: READ_IMAGES_AND_PDF,
11488
+ pi: READ_IMAGES,
11489
+ vscode: READ_IMAGES,
11490
+ "copilot-cli": [],
11491
+ codex: [],
11492
+ kiro: [],
11493
+ zcode: []
11494
+ });
11470
11495
  var OWN_TOOL_PREFIX = "ctx_";
11471
11496
  var SHELL_TOOL = "Bash";
11472
11497
  var EDIT_TOOLS = Object.freeze(["Write", "Edit"]);
@@ -11576,7 +11601,7 @@ var DECISION_ANSWERS_KEY = "answers";
11576
11601
  var DECISION_OPTION_KEY = "option";
11577
11602
  var DECISION_LABEL_JOIN = " | ";
11578
11603
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11579
- var BUNDLE_SHA = true ? "b496e208f503714cb28500a0b5767799ba882039" : void 0;
11604
+ var BUNDLE_SHA = true ? "f75e51d580374d518a8ceefc1422a009ffe67311" : void 0;
11580
11605
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11581
11606
  var DOCTOR_LABEL = Object.freeze({
11582
11607
  D1: "version",
@@ -11834,10 +11859,12 @@ var REGEX_ESCAPE = "\\";
11834
11859
  var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
11835
11860
  var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
11836
11861
  var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace trigger came back replaced: a bounded Read must reach the model whole";
11862
+ var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
11837
11863
  var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
11838
11864
  function D5_SLOW_DETAIL(ms) {
11839
11865
  return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
11840
11866
  }
11867
+ var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
11841
11868
  var D5_FIX = "run ctx_upgrade";
11842
11869
  var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
11843
11870
  function D10_DETAIL(mode) {
@@ -12444,10 +12471,17 @@ function encode2(ev, d, _extra) {
12444
12471
  // src/adapters/codex.ts
12445
12472
  var TOOL_NAME_PREFIX3 = "mcp__context_mode__";
12446
12473
  var CODEX_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact", fork: "resume" };
12474
+ var STOP_EVENT = "Stop";
12475
+ var EMPTY = { stdout: "", exitCode: 0 };
12447
12476
  function decode3(raw) {
12477
+ if (typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === STOP_EVENT) {
12478
+ const p = raw;
12479
+ return { event: STOP_EVENT, agent: "codex", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
12480
+ }
12448
12481
  return decodeClaudeShape(raw, "codex", TOOL_NAME_PREFIX3, CODEX_SOURCES);
12449
12482
  }
12450
12483
  function encode3(ev, d, _extra) {
12484
+ if (ev.event === STOP_EVENT) return EMPTY;
12451
12485
  return encodeClaudeShape(ev, d, false);
12452
12486
  }
12453
12487
 
@@ -12463,7 +12497,7 @@ var GEMINI_EVENTS = {
12463
12497
  var GEMINI_SOURCES = { startup: "startup", resume: "resume", clear: "clear" };
12464
12498
  var HINT_EVENTS = ["SessionStart", "UserPromptSubmit", "PostToolUse"];
12465
12499
  var DENY_EVENTS = ["UserPromptSubmit", "PreToolUse"];
12466
- var EMPTY = { stdout: "", exitCode: 0 };
12500
+ var EMPTY2 = { stdout: "", exitCode: 0 };
12467
12501
  var GEMINI_REPLACE_LEAD = "the tool ran and succeeded; context-mode indexed its full output, and this is the part that answers the call:\n";
12468
12502
  function own(p, key) {
12469
12503
  return Object.hasOwn(p, key) ? p[key] : void 0;
@@ -12504,7 +12538,13 @@ function readResult3(resp) {
12504
12538
  const llm = obj === void 0 ? void 0 : own(obj, "llmContent");
12505
12539
  const text = resp === void 0 ? "" : typeof resp === "string" ? resp : typeof llm === "string" ? llm : partsText(llm) ?? JSON.stringify(resp);
12506
12540
  const err = obj === void 0 ? void 0 : own(obj, "error");
12507
- return { isError: err !== void 0 && err !== null, bytes: Buffer.byteLength(text), text };
12541
+ const info = { isError: err !== void 0 && err !== null, bytes: Buffer.byteLength(text), text };
12542
+ if (hasMediaPart(llm)) info.keep = true;
12543
+ return info;
12544
+ }
12545
+ function hasMediaPart(llm) {
12546
+ const parts = Array.isArray(llm) ? llm : [llm];
12547
+ return parts.some((p) => typeof p === "object" && p !== null && (Object.hasOwn(p, "inlineData") || Object.hasOwn(p, "fileData")));
12508
12548
  }
12509
12549
  var URL_STARTS = ["https://", "http://"];
12510
12550
  var URL_TRAIL = `.,;:!?)]}>'"`;
@@ -12571,15 +12611,15 @@ function decode4(raw) {
12571
12611
  function encode4(ev, d, _extra) {
12572
12612
  switch (d.kind) {
12573
12613
  case "allow":
12574
- return EMPTY;
12614
+ return EMPTY2;
12575
12615
  case "hint":
12576
- if (!HINT_EVENTS.includes(ev.event)) return EMPTY;
12616
+ if (!HINT_EVENTS.includes(ev.event)) return EMPTY2;
12577
12617
  return { stdout: JSON.stringify({ hookSpecificOutput: { additionalContext: d.text } }), exitCode: 0 };
12578
12618
  case "deny":
12579
- if (!DENY_EVENTS.includes(ev.event)) return EMPTY;
12619
+ if (!DENY_EVENTS.includes(ev.event)) return EMPTY2;
12580
12620
  return { stdout: JSON.stringify({ decision: "deny", reason: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason }), exitCode: 0 };
12581
12621
  case "replace":
12582
- if (ev.event !== "PostToolUse") return EMPTY;
12622
+ if (ev.event !== "PostToolUse") return EMPTY2;
12583
12623
  return { stdout: JSON.stringify({ decision: "deny", reason: GEMINI_REPLACE_LEAD + d.output }), exitCode: 0 };
12584
12624
  }
12585
12625
  }
@@ -12699,21 +12739,21 @@ function decode6(raw) {
12699
12739
  if (event === "PostToolUse") ev.result = readResult4(raw[k.result], native.casing, native.failure);
12700
12740
  return ev;
12701
12741
  }
12702
- var EMPTY2 = { stdout: "", exitCode: 0 };
12742
+ var EMPTY3 = { stdout: "", exitCode: 0 };
12703
12743
  function encode6(ev, d, _extra) {
12704
12744
  switch (d.kind) {
12705
12745
  case "allow":
12706
- return EMPTY2;
12746
+ return EMPTY3;
12707
12747
  case "hint":
12708
- return ev.event === "PostToolUse" ? EMPTY2 : { stdout: JSON.stringify({ additionalContext: d.text }), exitCode: 0 };
12748
+ return ev.event === "PostToolUse" ? EMPTY3 : { stdout: JSON.stringify({ additionalContext: d.text }), exitCode: 0 };
12709
12749
  case "deny":
12710
- if (ev.event !== "PreToolUse") return EMPTY2;
12750
+ if (ev.event !== "PreToolUse") return EMPTY3;
12711
12751
  return {
12712
12752
  stdout: JSON.stringify({ permissionDecision: "deny", permissionDecisionReason: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason }),
12713
12753
  exitCode: 0
12714
12754
  };
12715
12755
  case "replace":
12716
- if (ev.event !== "PostToolUse") return EMPTY2;
12756
+ if (ev.event !== "PostToolUse") return EMPTY3;
12717
12757
  return { stdout: JSON.stringify({ modifiedResult: { resultType: RESULT_SUCCESS, textResultForLlm: d.output } }), exitCode: 0 };
12718
12758
  }
12719
12759
  }
@@ -13787,7 +13827,7 @@ var HEAD_BYTES = "-c";
13787
13827
  var HEAD_BYTES_LONG = "--bytes";
13788
13828
  var GREP_COUNT_SHORT = "c";
13789
13829
  var GREP_COUNT_LONG = "--count";
13790
- var EMPTY3 = () => ({ cmds: [], simple: null });
13830
+ var EMPTY4 = () => ({ cmds: [], simple: null });
13791
13831
  var at = (p, k = 0) => p.toks[p.i + k];
13792
13832
  var isOp = (t, text) => t !== void 0 && t.kind === "op" && t.text === text;
13793
13833
  var isWord = (t, text) => t !== void 0 && t.kind === "word" && t.text === text;
@@ -13904,7 +13944,7 @@ function compound(p, body) {
13904
13944
  p.depth++;
13905
13945
  if (p.depth > MAX_NEST_DEPTH) {
13906
13946
  p.err = "nesting-too-deep";
13907
- return EMPTY3();
13947
+ return EMPTY4();
13908
13948
  }
13909
13949
  const cmds = body();
13910
13950
  p.depth--;
@@ -14032,7 +14072,7 @@ function simple(p) {
14032
14072
  words2.push(t);
14033
14073
  p.i++;
14034
14074
  }
14035
- if (p.i === first) return EMPTY3();
14075
+ if (p.i === first) return EMPTY4();
14036
14076
  const raw = p.src.slice(p.toks[first].start, p.toks[p.i - 1].end);
14037
14077
  if (words2.length === 0) return { cmds: carrier(raw), simple: null };
14038
14078
  const text = (t) => t.kind === "word" ? dequote(t.text) : t.text;
@@ -14043,9 +14083,9 @@ function simple(p) {
14043
14083
  }
14044
14084
  function element(p) {
14045
14085
  const t = at(p);
14046
- if (t === void 0) return EMPTY3();
14086
+ if (t === void 0) return EMPTY4();
14047
14087
  if (t.kind === "op") {
14048
- if (t.text !== SUBSHELL_OPEN) return EMPTY3();
14088
+ if (t.text !== SUBSHELL_OPEN) return EMPTY4();
14049
14089
  return compound(p, () => {
14050
14090
  p.i++;
14051
14091
  const body = list(p, NO_STOP);
@@ -14078,10 +14118,10 @@ function element(p) {
14078
14118
  return compound(p, () => caseBody(p));
14079
14119
  case KW.coproc:
14080
14120
  p.err = "coproc";
14081
- return EMPTY3();
14121
+ return EMPTY4();
14082
14122
  case KW.select:
14083
14123
  p.err = "select";
14084
- return EMPTY3();
14124
+ return EMPTY4();
14085
14125
  case KW.function: {
14086
14126
  p.i++;
14087
14127
  const nameTok = at(p);
@@ -14105,7 +14145,7 @@ function element(p) {
14105
14145
  function pipeline(p) {
14106
14146
  if (isWord(at(p), NOT)) p.i++;
14107
14147
  const all = [];
14108
- let last2 = EMPTY3();
14148
+ let last2 = EMPTY4();
14109
14149
  while (p.err === null) {
14110
14150
  last2 = element(p);
14111
14151
  append(all, last2.cmds);
@@ -14462,21 +14502,21 @@ function cdTarget(words2) {
14462
14502
  function walk(script, cwd, depth, found) {
14463
14503
  let dir = cwd;
14464
14504
  for (const stages of psParse(script)) {
14465
- const head = stages[0];
14466
- if (head.words.length === 0) continue;
14467
- const name = cmdName(head.words[0]);
14505
+ const head2 = stages[0];
14506
+ if (head2.words.length === 0) continue;
14507
+ const name = cmdName(head2.words[0]);
14468
14508
  if (stages.length === 1 && CD_COMMANDS.includes(name)) {
14469
- const t = cdTarget(head.words);
14509
+ const t = cdTarget(head2.words);
14470
14510
  if (t !== null) dir = resolve(dir, t);
14471
14511
  continue;
14472
14512
  }
14473
- const inner = depth < MAX_NEST_DEPTH ? nestedScript(name, head.words) : null;
14513
+ const inner = depth < MAX_NEST_DEPTH ? nestedScript(name, head2.words) : null;
14474
14514
  if (inner !== null) {
14475
14515
  walk(inner, dir, depth + 1, found);
14476
14516
  continue;
14477
14517
  }
14478
- if (head.toFile || head.chained) continue;
14479
- const d = psDump(head.words);
14518
+ if (head2.toFile || head2.chained) continue;
14519
+ const d = psDump(head2.words);
14480
14520
  if (d === null || d.bounded) continue;
14481
14521
  let shown2 = true;
14482
14522
  for (let k = 1; k < stages.length; k++) {
@@ -15119,6 +15159,33 @@ function READ_DENY_MESSAGE(path8, size, prefix = "") {
15119
15159
  return prefixToolNames(READ_DENY_TEMPLATE, prefix).split(SIZE).join(String(size)).split(PATH).join(path8);
15120
15160
  }
15121
15161
 
15162
+ // src/core/policy/read-media.ts
15163
+ import { extname } from "node:path";
15164
+ var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
15165
+ function head(abs) {
15166
+ let fd = null;
15167
+ try {
15168
+ fd = openSync(abs, "r");
15169
+ const buf = Buffer.alloc(READ_MEDIA_SNIFF_BYTES);
15170
+ const n = readSync(fd, buf, 0, READ_MEDIA_SNIFF_BYTES, 0);
15171
+ return buf.subarray(0, n);
15172
+ } catch {
15173
+ return null;
15174
+ } finally {
15175
+ if (fd !== null) closeSync(fd);
15176
+ }
15177
+ }
15178
+ function isMediaRead(agent, abs) {
15179
+ const types = READ_MEDIA_BY_AGENT[agent] ?? [];
15180
+ if (types.length === 0) return false;
15181
+ const ext = extname(abs).toLowerCase();
15182
+ const named2 = types.filter((t) => READ_MEDIA_TYPES[t].exts.includes(ext));
15183
+ if (named2.length === 0) return false;
15184
+ const bytes5 = head(abs);
15185
+ if (bytes5 === null) return false;
15186
+ return named2.some((t) => READ_MEDIA_TYPES[t].sig.every((s) => s.bytes.every((b, i) => bytes5[s.at + i] === b)));
15187
+ }
15188
+
15122
15189
  // src/core/policy/decide.ts
15123
15190
  var { statSync } = process.getBuiltinModule("node:fs");
15124
15191
  var BASH = "Bash";
@@ -15322,7 +15389,7 @@ function read(ev, row5, input) {
15322
15389
  for (const p of readPaths(input)) {
15323
15390
  const abs = resolve3(ev.cwd, p);
15324
15391
  const size = fileSize(abs);
15325
- if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row5.toolNamePrefix));
15392
+ if (size > OUTPUT_CAP && !isMediaRead(ev.agent, abs)) return deny(READ_DENY_MESSAGE(abs, size, row5.toolNamePrefix));
15326
15393
  }
15327
15394
  }
15328
15395
  return ALLOW;
@@ -19086,14 +19153,14 @@ function lineBlocks(src, md) {
19086
19153
  close();
19087
19154
  } else {
19088
19155
  const opener = md ? fenceOf(line) : "";
19089
- const head = md && opener === "" ? headingOf(line) : void 0;
19090
- const table3 = md && opener === "" && head === void 0 && line.includes("|");
19091
- if (md && start >= 0 && (table3 !== inTable || opener !== "" || head !== void 0)) close();
19156
+ const head2 = md && opener === "" ? headingOf(line) : void 0;
19157
+ const table3 = md && opener === "" && head2 === void 0 && line.includes("|");
19158
+ if (md && start >= 0 && (table3 !== inTable || opener !== "" || head2 !== void 0)) close();
19092
19159
  add(pos, eol, table3);
19093
19160
  fence = opener;
19094
19161
  if (opener !== "") fenceInfo = { fence: opener, openEnd: eol, closeStart: -1 };
19095
- if (head !== void 0) {
19096
- heading = head;
19162
+ if (head2 !== void 0) {
19163
+ heading = head2;
19097
19164
  close();
19098
19165
  }
19099
19166
  }
@@ -19525,9 +19592,9 @@ function hasDigit(t) {
19525
19592
  return false;
19526
19593
  }
19527
19594
  function similarity(tpl, toks) {
19528
- let same = 0;
19529
- for (let i = 0; i < tpl.length; i++) if (tpl[i] === toks[i] || tpl[i] === "<*>" || toks[i] === "<*>") same++;
19530
- return same / tpl.length;
19595
+ let same2 = 0;
19596
+ for (let i = 0; i < tpl.length; i++) if (tpl[i] === toks[i] || tpl[i] === "<*>" || toks[i] === "<*>") same2++;
19597
+ return same2 / tpl.length;
19531
19598
  }
19532
19599
  function lineShape(text) {
19533
19600
  const all = text.split("\n");
@@ -19821,10 +19888,10 @@ function bigFile(abs) {
19821
19888
  return false;
19822
19889
  }
19823
19890
  }
19824
- function bigRead(input, cwd) {
19891
+ function bigRead(agent, input, cwd) {
19825
19892
  if ((input.offset ?? null) !== null || (input.limit ?? null) !== null) return false;
19826
19893
  const many = Array.isArray(input[READ_PATH_LIST_KEY]) ? input[READ_PATH_LIST_KEY].filter((x) => typeof x === "string") : [];
19827
- return [firstString(input, READ_PATH_KEYS), ...many].some((p) => p !== "" && bigFile(resolve5(cwd, p)));
19894
+ return [firstString(input, READ_PATH_KEYS), ...many].some((p) => p !== "" && bigFile(resolve5(cwd, p)) && !isMediaRead(agent, resolve5(cwd, p)));
19828
19895
  }
19829
19896
  function failureOutput(agent, raw, err, cwdFallback = "") {
19830
19897
  const row5 = getAdapter(agent);
@@ -19837,7 +19904,7 @@ function failureOutput(agent, raw, err, cwdFallback = "") {
19837
19904
  const kind = kindOf(row5, name);
19838
19905
  if (kind === null) return allow();
19839
19906
  const cwd = firstString(raw, HOOK_FAIL_CWD_KEYS) || cwdFallback;
19840
- if (kind === "read" && !bigRead(inputOf(raw), cwd)) return allow();
19907
+ if (kind === "read" && !bigRead(agent, inputOf(raw), cwd)) return allow();
19841
19908
  const redirect = kind === "read" ? HOOK_FAIL_REDIRECT.read : HOOK_FAIL_REDIRECT[kind];
19842
19909
  const reason = prefixToolNames(redirect, row5.toolNamePrefix) + "\n" + HOOK_FAIL_LINE(errorLabel(err), row5.toolNamePrefix);
19843
19910
  return row5.encode({ event: "PreToolUse", agent, sessionId: "", cwd, turn: 0 }, { kind: "deny", reason });
@@ -19852,7 +19919,7 @@ var { read: read2, writeSync } = process.getBuiltinModule("node:fs");
19852
19919
  // src/core/hooks/dispatch.ts
19853
19920
  var { lstatSync: lstatSync2, readFileSync: readFileSync4 } = process.getBuiltinModule("node:fs");
19854
19921
  var ALLOW2 = { kind: "allow" };
19855
- var EMPTY4 = { stdout: "", exitCode: 0 };
19922
+ var EMPTY5 = { stdout: "", exitCode: 0 };
19856
19923
  var DIGIT_0 = 48;
19857
19924
  function isAgentId(s) {
19858
19925
  return AGENT_IDS.includes(s);
@@ -19866,7 +19933,7 @@ function str2(v) {
19866
19933
  async function handleHook(agent, raw, env) {
19867
19934
  if (!isAgentId(agent)) {
19868
19935
  process.stderr.write("hooks: unknown agent " + JSON.stringify(agent) + "\n");
19869
- return EMPTY4;
19936
+ return EMPTY5;
19870
19937
  }
19871
19938
  const row5 = getAdapter(agent);
19872
19939
  const fail7 = (stage, err, line) => {
@@ -19882,6 +19949,7 @@ async function handleHook(agent, raw, env) {
19882
19949
  } catch (err) {
19883
19950
  return fail7("decode", err);
19884
19951
  }
19952
+ if (ev.event === "Stop") return row5.encode(ev, ALLOW2);
19885
19953
  let project;
19886
19954
  try {
19887
19955
  fault(env, "project");
@@ -20241,16 +20309,16 @@ function hostToolResult(file2, sessionId, env) {
20241
20309
  return st.isFile() && st.size <= PERSISTED_OUTPUT_MAX_BYTES && isInside(projects, file2);
20242
20310
  }
20243
20311
  function wholeOutput(result, sessionId, env) {
20244
- const head = result.text ?? "";
20245
- if (result.persistedPath === void 0) return head;
20312
+ const head2 = result.text ?? "";
20313
+ if (result.persistedPath === void 0) return head2;
20246
20314
  try {
20247
20315
  if (!hostToolResult(result.persistedPath, sessionId, env)) {
20248
20316
  logHookError(env, "claude-code", "persisted-output", new Error("persisted output path is outside this session's tool-results dir or too large; kept the head"));
20249
- return head;
20317
+ return head2;
20250
20318
  }
20251
20319
  return readFileSync4(result.persistedPath, "utf8");
20252
20320
  } catch {
20253
- return head;
20321
+ return head2;
20254
20322
  }
20255
20323
  }
20256
20324
  async function lastPrompt(project, sessionId) {
@@ -20263,8 +20331,8 @@ async function lastPrompt(project, sessionId) {
20263
20331
  function mainLabel(tool, ev) {
20264
20332
  const cmd = str2(tool.input.command) ?? str2(tool.input.file_path) ?? "";
20265
20333
  const nl = cmd.indexOf("\n");
20266
- const head = (tool.canonicalName + ":" + (nl < 0 ? cmd : cmd.slice(0, nl))).slice(0, SOURCE_LABEL_MAX_CHARS);
20267
- return head + "#" + (tool.callId ?? String(ev.turn ?? 0));
20334
+ const head2 = (tool.canonicalName + ":" + (nl < 0 ? cmd : cmd.slice(0, nl))).slice(0, SOURCE_LABEL_MAX_CHARS);
20335
+ return head2 + "#" + (tool.callId ?? String(ev.turn ?? 0));
20268
20336
  }
20269
20337
  function indexDetached(project, sessionId, sourceId, label2, text, chunks) {
20270
20338
  void openDb(project).then((db) => {
@@ -20471,10 +20539,10 @@ function startArgv(argv) {
20471
20539
  return sh === null ? null : [sh, ...argv];
20472
20540
  }
20473
20541
  function runProcess(argv, o) {
20474
- return new Promise((resolve9) => {
20542
+ return new Promise((resolve10) => {
20475
20543
  const isWin2 = process.platform === "win32";
20476
20544
  const start = startArgv(argv);
20477
- if (start === null) return resolve9(NOT_STARTED);
20545
+ if (start === null) return resolve10(NOT_STARTED);
20478
20546
  let child;
20479
20547
  try {
20480
20548
  child = spawn(start[0], start.slice(1), {
@@ -20488,7 +20556,7 @@ function runProcess(argv, o) {
20488
20556
  windowsHide: true
20489
20557
  });
20490
20558
  } catch {
20491
- return resolve9(NOT_STARTED);
20559
+ return resolve10(NOT_STARTED);
20492
20560
  }
20493
20561
  const stdoutChunks = [];
20494
20562
  const stderrChunks = [];
@@ -20513,7 +20581,7 @@ function runProcess(argv, o) {
20513
20581
  settled = true;
20514
20582
  clearTimeout(timer);
20515
20583
  o.signal.removeEventListener("abort", onAbort);
20516
- resolve9({
20584
+ resolve10({
20517
20585
  stdout: Buffer.concat(stdoutChunks),
20518
20586
  stderr: Buffer.concat(stderrChunks),
20519
20587
  exitCode,
@@ -20787,9 +20855,9 @@ function relevance(db, given, scope, ctx, nm, ms, indexed) {
20787
20855
  more.push({ q, pos: offset });
20788
20856
  return;
20789
20857
  }
20790
- const head = "Query " + JSON.stringify(q) + ":";
20791
- lines.push(head);
20792
- used += bytes2(head) + 1;
20858
+ const head2 = "Query " + JSON.stringify(q) + ":";
20859
+ lines.push(head2);
20860
+ used += bytes2(head2) + 1;
20793
20861
  const again = /* @__PURE__ */ new Map();
20794
20862
  const mine = /* @__PURE__ */ new Set();
20795
20863
  let cut = -1;
@@ -21047,8 +21115,8 @@ function answer2(db, ctx, ownIds, queries, share, own4) {
21047
21115
  if (ctx.signal.aborted) break;
21048
21116
  let hits = ownIds.length === 0 ? [] : ftsQuery(db, q, "session", ctx.project, ctx.sessionId, SEARCH_PAGE_SIZE, 0, void 0, ownIds);
21049
21117
  if (hits.length === 0) hits = ftsQuery(db, q, "session", ctx.project, ctx.sessionId, SEARCH_PAGE_SIZE, 0);
21050
- const head = "## " + (bytes3(q) > ECHO_MAX_BYTES ? "query " + (qi + 1) : q);
21051
- let used = bytes3(head) + 1;
21118
+ const head2 = "## " + (bytes3(q) > ECHO_MAX_BYTES ? "query " + (qi + 1) : q);
21119
+ let used = bytes3(head2) + 1;
21052
21120
  const body = [];
21053
21121
  for (const h of hits) {
21054
21122
  const key = chunkKey(h.sourceId, h.ord);
@@ -21066,7 +21134,7 @@ function answer2(db, ctx, ownIds, queries, share, own4) {
21066
21134
  }
21067
21135
  if (hits.length === 0) body.push("No hits.");
21068
21136
  else if (body.length === 0) body.push("No new section.");
21069
- lines.push(head, ...body);
21137
+ lines.push(head2, ...body);
21070
21138
  }
21071
21139
  return { lines, seen };
21072
21140
  }
@@ -24709,20 +24777,20 @@ function highestTag(stdout, tag2) {
24709
24777
  }
24710
24778
  return best;
24711
24779
  }
24712
- function versionRow(head, installed, tag2, source, latest, tail) {
24780
+ function versionRow(head2, installed, tag2, source, latest, tail) {
24713
24781
  const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
24714
- if (cmp === 0) return pass3("D1", head + D1_LATEST_PASS(tag2, source) + tail);
24715
- if (cmp > 0) return pass3("D1", head + D1_LATEST_AHEAD(tag2, source, latest) + tail);
24716
- return fail4("D1", head + D1_LATEST_UPDATE(tag2, source, latest) + tail, DOCTOR_FIX_UPGRADE);
24782
+ if (cmp === 0) return pass3("D1", head2 + D1_LATEST_PASS(tag2, source) + tail);
24783
+ if (cmp > 0) return pass3("D1", head2 + D1_LATEST_AHEAD(tag2, source, latest) + tail);
24784
+ return fail4("D1", head2 + D1_LATEST_UPDATE(tag2, source, latest) + tail, DOCTOR_FIX_UPGRADE);
24717
24785
  }
24718
24786
  async function checkVersion(i) {
24719
24787
  if (i.bundleSha === void 0) return unknown3("D1", D1_DEV_BUILD_DETAIL);
24720
- const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
24721
- if (i.version === void 0) return unknown3("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
24788
+ const head2 = D1_PREFIX(i.version, i.bundleSha) + ": ";
24789
+ if (i.version === void 0) return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
24722
24790
  const tag2 = channelOf(i.version);
24723
24791
  const git2 = findRuntime(GIT_BIN, i.env);
24724
24792
  const npm = await npmLatest(i.registryUrl, tag2, i.signal, i.timeoutMs);
24725
- if (npm.ok) return versionRow(head, i.version, tag2, D1_SOURCE_NPM, npm.version, "");
24793
+ if (npm.ok) return versionRow(head2, i.version, tag2, D1_SOURCE_NPM, npm.version, "");
24726
24794
  let cause = D1_GIT_MISSING;
24727
24795
  if (git2 !== null) {
24728
24796
  const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
@@ -24733,13 +24801,13 @@ async function checkVersion(i) {
24733
24801
  });
24734
24802
  if (r.exitCode === 0 && r.killed === null) {
24735
24803
  const latest = highestTag(r.stdout.toString("utf8"), tag2);
24736
- if (latest !== void 0) return versionRow(head, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause);
24804
+ if (latest !== void 0) return versionRow(head2, i.version, tag2, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause);
24737
24805
  cause = D1_GIT_NO_TAG(tag2);
24738
24806
  } else {
24739
24807
  cause = gitCause(r, i.timeoutMs);
24740
24808
  }
24741
24809
  }
24742
- return unknown3("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
24810
+ return unknown3("D1", head2 + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
24743
24811
  }
24744
24812
  function numbers(v) {
24745
24813
  const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
@@ -24796,10 +24864,1821 @@ function checkShell(env) {
24796
24864
  }
24797
24865
 
24798
24866
  // src/core/ops/doctor-hook.ts
24799
- import { existsSync as existsSync12, mkdtempSync, readFileSync as readFileSync11, realpathSync as realpathSync8, rmSync as rmSync2 } from "node:fs";
24867
+ import { existsSync as existsSync12, mkdtempSync, readFileSync as readFileSync11, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
24800
24868
  import { tmpdir as tmpdir2 } from "node:os";
24801
24869
  import path7 from "node:path";
24802
24870
 
24871
+ // tests/fixtures/host-schemas/claude-code.json
24872
+ var claude_code_default = {
24873
+ host: "claude-code",
24874
+ source: "Claude Code 2.1.274 native binary, zod hook output schemas: top level eW, hookSpecificOutput union members xF (PreToolUse, permissionDecision enum FK), DF (UserPromptSubmit), UF (SessionStart), the PostToolUse member. zod drops keys it does not read, so each object lists only the keys the host reads.",
24875
+ output: {
24876
+ PreToolUse: {
24877
+ title: "Claude Code 2.1.274 PreToolUse reply",
24878
+ definitions: {
24879
+ Specific: {
24880
+ type: "object",
24881
+ additionalProperties: false,
24882
+ properties: {
24883
+ hookEventName: {
24884
+ type: "string",
24885
+ const: "PreToolUse"
24886
+ },
24887
+ permissionDecision: {
24888
+ type: "string",
24889
+ enum: [
24890
+ "allow",
24891
+ "deny",
24892
+ "ask",
24893
+ "defer"
24894
+ ]
24895
+ },
24896
+ permissionDecisionReason: {
24897
+ type: "string"
24898
+ },
24899
+ updatedInput: {
24900
+ type: "object"
24901
+ },
24902
+ additionalContext: {
24903
+ type: "string"
24904
+ },
24905
+ permissionDisplay: {
24906
+ description: "@internal Desktop host only"
24907
+ }
24908
+ },
24909
+ required: [
24910
+ "hookEventName"
24911
+ ]
24912
+ }
24913
+ },
24914
+ type: "object",
24915
+ additionalProperties: false,
24916
+ properties: {
24917
+ continue: {
24918
+ type: "boolean"
24919
+ },
24920
+ suppressOutput: {
24921
+ type: "boolean"
24922
+ },
24923
+ stopReason: {
24924
+ type: "string"
24925
+ },
24926
+ decision: {
24927
+ type: "string",
24928
+ enum: [
24929
+ "approve",
24930
+ "block"
24931
+ ]
24932
+ },
24933
+ systemMessage: {
24934
+ type: "string"
24935
+ },
24936
+ terminalSequence: {
24937
+ type: "string"
24938
+ },
24939
+ reason: {
24940
+ type: "string"
24941
+ },
24942
+ hookSpecificOutput: {
24943
+ allOf: [
24944
+ {
24945
+ $ref: "#/definitions/Specific"
24946
+ }
24947
+ ]
24948
+ }
24949
+ }
24950
+ },
24951
+ PostToolUse: {
24952
+ title: "Claude Code 2.1.274 PostToolUse reply",
24953
+ definitions: {
24954
+ Specific: {
24955
+ type: "object",
24956
+ additionalProperties: false,
24957
+ properties: {
24958
+ hookEventName: {
24959
+ type: "string",
24960
+ const: "PostToolUse"
24961
+ },
24962
+ additionalContext: {
24963
+ type: "string"
24964
+ },
24965
+ classifierContext: {
24966
+ type: "string"
24967
+ },
24968
+ updatedToolOutput: {
24969
+ description: "the tool's own output object"
24970
+ },
24971
+ updatedMCPToolOutput: {
24972
+ description: "an MCP tool's own output"
24973
+ }
24974
+ },
24975
+ required: [
24976
+ "hookEventName"
24977
+ ]
24978
+ }
24979
+ },
24980
+ type: "object",
24981
+ additionalProperties: false,
24982
+ properties: {
24983
+ continue: {
24984
+ type: "boolean"
24985
+ },
24986
+ suppressOutput: {
24987
+ type: "boolean"
24988
+ },
24989
+ stopReason: {
24990
+ type: "string"
24991
+ },
24992
+ decision: {
24993
+ type: "string",
24994
+ enum: [
24995
+ "approve",
24996
+ "block"
24997
+ ]
24998
+ },
24999
+ systemMessage: {
25000
+ type: "string"
25001
+ },
25002
+ terminalSequence: {
25003
+ type: "string"
25004
+ },
25005
+ reason: {
25006
+ type: "string"
25007
+ },
25008
+ hookSpecificOutput: {
25009
+ allOf: [
25010
+ {
25011
+ $ref: "#/definitions/Specific"
25012
+ }
25013
+ ]
25014
+ }
25015
+ }
25016
+ },
25017
+ UserPromptSubmit: {
25018
+ title: "Claude Code 2.1.274 UserPromptSubmit reply",
25019
+ definitions: {
25020
+ Specific: {
25021
+ type: "object",
25022
+ additionalProperties: false,
25023
+ properties: {
25024
+ hookEventName: {
25025
+ type: "string",
25026
+ const: "UserPromptSubmit"
25027
+ },
25028
+ additionalContext: {
25029
+ type: "string"
25030
+ },
25031
+ sessionTitle: {
25032
+ type: "string"
25033
+ },
25034
+ suppressOriginalPrompt: {
25035
+ type: "boolean"
25036
+ }
25037
+ },
25038
+ required: [
25039
+ "hookEventName"
25040
+ ]
25041
+ }
25042
+ },
25043
+ type: "object",
25044
+ additionalProperties: false,
25045
+ properties: {
25046
+ continue: {
25047
+ type: "boolean"
25048
+ },
25049
+ suppressOutput: {
25050
+ type: "boolean"
25051
+ },
25052
+ stopReason: {
25053
+ type: "string"
25054
+ },
25055
+ decision: {
25056
+ type: "string",
25057
+ enum: [
25058
+ "approve",
25059
+ "block"
25060
+ ]
25061
+ },
25062
+ systemMessage: {
25063
+ type: "string"
25064
+ },
25065
+ terminalSequence: {
25066
+ type: "string"
25067
+ },
25068
+ reason: {
25069
+ type: "string"
25070
+ },
25071
+ hookSpecificOutput: {
25072
+ allOf: [
25073
+ {
25074
+ $ref: "#/definitions/Specific"
25075
+ }
25076
+ ]
25077
+ }
25078
+ }
25079
+ },
25080
+ SessionStart: {
25081
+ title: "Claude Code 2.1.274 SessionStart reply",
25082
+ definitions: {
25083
+ Specific: {
25084
+ type: "object",
25085
+ additionalProperties: false,
25086
+ properties: {
25087
+ hookEventName: {
25088
+ type: "string",
25089
+ const: "SessionStart"
25090
+ },
25091
+ additionalContext: {
25092
+ type: "string"
25093
+ },
25094
+ initialUserMessage: {
25095
+ type: "string"
25096
+ },
25097
+ sessionTitle: {
25098
+ type: "string"
25099
+ },
25100
+ watchPaths: {
25101
+ type: "array",
25102
+ items: {
25103
+ type: "string"
25104
+ }
25105
+ },
25106
+ reloadSkills: {
25107
+ type: "boolean"
25108
+ }
25109
+ },
25110
+ required: [
25111
+ "hookEventName"
25112
+ ]
25113
+ }
25114
+ },
25115
+ type: "object",
25116
+ additionalProperties: false,
25117
+ properties: {
25118
+ continue: {
25119
+ type: "boolean"
25120
+ },
25121
+ suppressOutput: {
25122
+ type: "boolean"
25123
+ },
25124
+ stopReason: {
25125
+ type: "string"
25126
+ },
25127
+ decision: {
25128
+ type: "string",
25129
+ enum: [
25130
+ "approve",
25131
+ "block"
25132
+ ]
25133
+ },
25134
+ systemMessage: {
25135
+ type: "string"
25136
+ },
25137
+ terminalSequence: {
25138
+ type: "string"
25139
+ },
25140
+ reason: {
25141
+ type: "string"
25142
+ },
25143
+ hookSpecificOutput: {
25144
+ allOf: [
25145
+ {
25146
+ $ref: "#/definitions/Specific"
25147
+ }
25148
+ ]
25149
+ }
25150
+ }
25151
+ }
25152
+ }
25153
+ };
25154
+
25155
+ // tests/fixtures/host-schemas/codex.json
25156
+ var codex_default = {
25157
+ host: "codex",
25158
+ source: "github.com/openai/codex tag rust-v0.166.0 codex-rs/hooks/schema/generated/*.command.output.schema.json",
25159
+ output: {
25160
+ PreToolUse: {
25161
+ $schema: "http://json-schema.org/draft-07/schema#",
25162
+ additionalProperties: false,
25163
+ definitions: {
25164
+ PreToolUseDecisionWire: {
25165
+ enum: [
25166
+ "approve",
25167
+ "block"
25168
+ ],
25169
+ type: "string"
25170
+ },
25171
+ PreToolUseHookSpecificOutputWire: {
25172
+ additionalProperties: false,
25173
+ properties: {
25174
+ additionalContext: {
25175
+ default: null,
25176
+ type: "string"
25177
+ },
25178
+ hookEventName: {
25179
+ const: "PreToolUse",
25180
+ type: "string"
25181
+ },
25182
+ permissionDecision: {
25183
+ allOf: [
25184
+ {
25185
+ $ref: "#/definitions/PreToolUsePermissionDecisionWire"
25186
+ }
25187
+ ],
25188
+ default: null
25189
+ },
25190
+ permissionDecisionReason: {
25191
+ default: null,
25192
+ type: "string"
25193
+ },
25194
+ updatedInput: {
25195
+ default: null
25196
+ }
25197
+ },
25198
+ required: [
25199
+ "hookEventName"
25200
+ ],
25201
+ type: "object"
25202
+ },
25203
+ PreToolUsePermissionDecisionWire: {
25204
+ enum: [
25205
+ "allow",
25206
+ "deny",
25207
+ "ask"
25208
+ ],
25209
+ type: "string"
25210
+ }
25211
+ },
25212
+ properties: {
25213
+ continue: {
25214
+ default: true,
25215
+ type: "boolean"
25216
+ },
25217
+ decision: {
25218
+ allOf: [
25219
+ {
25220
+ $ref: "#/definitions/PreToolUseDecisionWire"
25221
+ }
25222
+ ],
25223
+ default: null
25224
+ },
25225
+ hookSpecificOutput: {
25226
+ allOf: [
25227
+ {
25228
+ $ref: "#/definitions/PreToolUseHookSpecificOutputWire"
25229
+ }
25230
+ ],
25231
+ default: null
25232
+ },
25233
+ reason: {
25234
+ default: null,
25235
+ type: "string"
25236
+ },
25237
+ stopReason: {
25238
+ default: null,
25239
+ type: "string"
25240
+ },
25241
+ suppressOutput: {
25242
+ default: false,
25243
+ type: "boolean"
25244
+ },
25245
+ systemMessage: {
25246
+ default: null,
25247
+ type: "string"
25248
+ }
25249
+ },
25250
+ title: "pre-tool-use.command.output",
25251
+ type: "object"
25252
+ },
25253
+ PostToolUse: {
25254
+ $schema: "http://json-schema.org/draft-07/schema#",
25255
+ additionalProperties: false,
25256
+ definitions: {
25257
+ BlockDecisionWire: {
25258
+ enum: [
25259
+ "block"
25260
+ ],
25261
+ type: "string"
25262
+ },
25263
+ PostToolUseHookSpecificOutputWire: {
25264
+ additionalProperties: false,
25265
+ properties: {
25266
+ additionalContext: {
25267
+ default: null,
25268
+ type: "string"
25269
+ },
25270
+ hookEventName: {
25271
+ const: "PostToolUse",
25272
+ type: "string"
25273
+ },
25274
+ updatedMCPToolOutput: {
25275
+ default: null
25276
+ }
25277
+ },
25278
+ required: [
25279
+ "hookEventName"
25280
+ ],
25281
+ type: "object"
25282
+ }
25283
+ },
25284
+ properties: {
25285
+ continue: {
25286
+ default: true,
25287
+ type: "boolean"
25288
+ },
25289
+ decision: {
25290
+ allOf: [
25291
+ {
25292
+ $ref: "#/definitions/BlockDecisionWire"
25293
+ }
25294
+ ],
25295
+ default: null
25296
+ },
25297
+ hookSpecificOutput: {
25298
+ allOf: [
25299
+ {
25300
+ $ref: "#/definitions/PostToolUseHookSpecificOutputWire"
25301
+ }
25302
+ ],
25303
+ default: null
25304
+ },
25305
+ reason: {
25306
+ default: null,
25307
+ type: "string"
25308
+ },
25309
+ stopReason: {
25310
+ default: null,
25311
+ type: "string"
25312
+ },
25313
+ suppressOutput: {
25314
+ default: false,
25315
+ type: "boolean"
25316
+ },
25317
+ systemMessage: {
25318
+ default: null,
25319
+ type: "string"
25320
+ }
25321
+ },
25322
+ title: "post-tool-use.command.output",
25323
+ type: "object"
25324
+ },
25325
+ SessionStart: {
25326
+ $schema: "http://json-schema.org/draft-07/schema#",
25327
+ additionalProperties: false,
25328
+ definitions: {
25329
+ SessionStartHookSpecificOutputWire: {
25330
+ additionalProperties: false,
25331
+ properties: {
25332
+ additionalContext: {
25333
+ default: null,
25334
+ type: "string"
25335
+ },
25336
+ hookEventName: {
25337
+ const: "SessionStart",
25338
+ type: "string"
25339
+ }
25340
+ },
25341
+ required: [
25342
+ "hookEventName"
25343
+ ],
25344
+ type: "object"
25345
+ }
25346
+ },
25347
+ properties: {
25348
+ continue: {
25349
+ default: true,
25350
+ type: "boolean"
25351
+ },
25352
+ hookSpecificOutput: {
25353
+ allOf: [
25354
+ {
25355
+ $ref: "#/definitions/SessionStartHookSpecificOutputWire"
25356
+ }
25357
+ ],
25358
+ default: null
25359
+ },
25360
+ stopReason: {
25361
+ default: null,
25362
+ type: "string"
25363
+ },
25364
+ suppressOutput: {
25365
+ default: false,
25366
+ type: "boolean"
25367
+ },
25368
+ systemMessage: {
25369
+ default: null,
25370
+ type: "string"
25371
+ }
25372
+ },
25373
+ title: "session-start.command.output",
25374
+ type: "object"
25375
+ },
25376
+ UserPromptSubmit: {
25377
+ $schema: "http://json-schema.org/draft-07/schema#",
25378
+ additionalProperties: false,
25379
+ definitions: {
25380
+ BlockDecisionWire: {
25381
+ enum: [
25382
+ "block"
25383
+ ],
25384
+ type: "string"
25385
+ },
25386
+ UserPromptSubmitHookSpecificOutputWire: {
25387
+ additionalProperties: false,
25388
+ properties: {
25389
+ additionalContext: {
25390
+ default: null,
25391
+ type: "string"
25392
+ },
25393
+ hookEventName: {
25394
+ const: "UserPromptSubmit",
25395
+ type: "string"
25396
+ }
25397
+ },
25398
+ required: [
25399
+ "hookEventName"
25400
+ ],
25401
+ type: "object"
25402
+ }
25403
+ },
25404
+ properties: {
25405
+ continue: {
25406
+ default: true,
25407
+ type: "boolean"
25408
+ },
25409
+ decision: {
25410
+ allOf: [
25411
+ {
25412
+ $ref: "#/definitions/BlockDecisionWire"
25413
+ }
25414
+ ],
25415
+ default: null
25416
+ },
25417
+ hookSpecificOutput: {
25418
+ allOf: [
25419
+ {
25420
+ $ref: "#/definitions/UserPromptSubmitHookSpecificOutputWire"
25421
+ }
25422
+ ],
25423
+ default: null
25424
+ },
25425
+ reason: {
25426
+ default: null,
25427
+ type: "string"
25428
+ },
25429
+ stopReason: {
25430
+ default: null,
25431
+ type: "string"
25432
+ },
25433
+ suppressOutput: {
25434
+ default: false,
25435
+ type: "boolean"
25436
+ },
25437
+ systemMessage: {
25438
+ default: null,
25439
+ type: "string"
25440
+ }
25441
+ },
25442
+ title: "user-prompt-submit.command.output",
25443
+ type: "object"
25444
+ },
25445
+ Stop: {
25446
+ $schema: "http://json-schema.org/draft-07/schema#",
25447
+ additionalProperties: false,
25448
+ definitions: {
25449
+ BlockDecisionWire: {
25450
+ enum: [
25451
+ "block"
25452
+ ],
25453
+ type: "string"
25454
+ }
25455
+ },
25456
+ properties: {
25457
+ continue: {
25458
+ default: true,
25459
+ type: "boolean"
25460
+ },
25461
+ decision: {
25462
+ allOf: [
25463
+ {
25464
+ $ref: "#/definitions/BlockDecisionWire"
25465
+ }
25466
+ ],
25467
+ default: null
25468
+ },
25469
+ reason: {
25470
+ default: null,
25471
+ description: "Claude requires `reason` when `decision` is `block`; we enforce that semantic rule during output parsing rather than in the JSON schema.",
25472
+ type: "string"
25473
+ },
25474
+ stopReason: {
25475
+ default: null,
25476
+ type: "string"
25477
+ },
25478
+ suppressOutput: {
25479
+ default: false,
25480
+ type: "boolean"
25481
+ },
25482
+ systemMessage: {
25483
+ default: null,
25484
+ type: "string"
25485
+ }
25486
+ },
25487
+ title: "stop.command.output",
25488
+ type: "object"
25489
+ }
25490
+ }
25491
+ };
25492
+
25493
+ // tests/fixtures/host-schemas/gemini.json
25494
+ var gemini_default = {
25495
+ host: "gemini",
25496
+ source: "@google/gemini-cli 0.67.0: bundle/docs/hooks/reference.md (Common output fields; BeforeTool, AfterTool, BeforeAgent, SessionStart output fields) and bundle/chunk-O7MGOE2I.js HookOutput (isBlockingDecision block|deny, isAskDecision ask). Keys are canonical events; each title names the native event.",
25497
+ output: {
25498
+ PreToolUse: {
25499
+ title: "Gemini CLI 0.67.0 BeforeTool reply",
25500
+ definitions: {
25501
+ Specific: {
25502
+ type: "object",
25503
+ additionalProperties: false,
25504
+ properties: {
25505
+ hookEventName: {
25506
+ type: "string"
25507
+ },
25508
+ tool_input: {
25509
+ type: "object"
25510
+ }
25511
+ }
25512
+ }
25513
+ },
25514
+ type: "object",
25515
+ additionalProperties: false,
25516
+ properties: {
25517
+ systemMessage: {
25518
+ type: "string"
25519
+ },
25520
+ suppressOutput: {
25521
+ type: "boolean"
25522
+ },
25523
+ continue: {
25524
+ type: "boolean"
25525
+ },
25526
+ stopReason: {
25527
+ type: "string"
25528
+ },
25529
+ decision: {
25530
+ type: "string",
25531
+ enum: [
25532
+ "allow",
25533
+ "deny",
25534
+ "block",
25535
+ "ask"
25536
+ ]
25537
+ },
25538
+ reason: {
25539
+ type: "string"
25540
+ },
25541
+ hookSpecificOutput: {
25542
+ allOf: [
25543
+ {
25544
+ $ref: "#/definitions/Specific"
25545
+ }
25546
+ ]
25547
+ }
25548
+ }
25549
+ },
25550
+ PostToolUse: {
25551
+ title: "Gemini CLI 0.67.0 AfterTool reply",
25552
+ definitions: {
25553
+ Specific: {
25554
+ type: "object",
25555
+ additionalProperties: false,
25556
+ properties: {
25557
+ hookEventName: {
25558
+ type: "string"
25559
+ },
25560
+ additionalContext: {
25561
+ type: "string"
25562
+ },
25563
+ tailToolCallRequest: {
25564
+ type: "object",
25565
+ additionalProperties: false,
25566
+ properties: {
25567
+ name: {
25568
+ type: "string"
25569
+ },
25570
+ args: {
25571
+ type: "object"
25572
+ }
25573
+ },
25574
+ required: [
25575
+ "name",
25576
+ "args"
25577
+ ]
25578
+ }
25579
+ }
25580
+ }
25581
+ },
25582
+ type: "object",
25583
+ additionalProperties: false,
25584
+ properties: {
25585
+ systemMessage: {
25586
+ type: "string"
25587
+ },
25588
+ suppressOutput: {
25589
+ type: "boolean"
25590
+ },
25591
+ continue: {
25592
+ type: "boolean"
25593
+ },
25594
+ stopReason: {
25595
+ type: "string"
25596
+ },
25597
+ decision: {
25598
+ type: "string",
25599
+ enum: [
25600
+ "allow",
25601
+ "deny",
25602
+ "block",
25603
+ "ask"
25604
+ ]
25605
+ },
25606
+ reason: {
25607
+ type: "string"
25608
+ },
25609
+ hookSpecificOutput: {
25610
+ allOf: [
25611
+ {
25612
+ $ref: "#/definitions/Specific"
25613
+ }
25614
+ ]
25615
+ }
25616
+ }
25617
+ },
25618
+ UserPromptSubmit: {
25619
+ title: "Gemini CLI 0.67.0 BeforeAgent reply",
25620
+ definitions: {
25621
+ Specific: {
25622
+ type: "object",
25623
+ additionalProperties: false,
25624
+ properties: {
25625
+ hookEventName: {
25626
+ type: "string"
25627
+ },
25628
+ additionalContext: {
25629
+ type: "string"
25630
+ }
25631
+ }
25632
+ }
25633
+ },
25634
+ type: "object",
25635
+ additionalProperties: false,
25636
+ properties: {
25637
+ systemMessage: {
25638
+ type: "string"
25639
+ },
25640
+ suppressOutput: {
25641
+ type: "boolean"
25642
+ },
25643
+ continue: {
25644
+ type: "boolean"
25645
+ },
25646
+ stopReason: {
25647
+ type: "string"
25648
+ },
25649
+ decision: {
25650
+ type: "string",
25651
+ enum: [
25652
+ "allow",
25653
+ "deny",
25654
+ "block",
25655
+ "ask"
25656
+ ]
25657
+ },
25658
+ reason: {
25659
+ type: "string"
25660
+ },
25661
+ hookSpecificOutput: {
25662
+ allOf: [
25663
+ {
25664
+ $ref: "#/definitions/Specific"
25665
+ }
25666
+ ]
25667
+ }
25668
+ }
25669
+ },
25670
+ SessionStart: {
25671
+ title: "Gemini CLI 0.67.0 SessionStart reply",
25672
+ definitions: {
25673
+ Specific: {
25674
+ type: "object",
25675
+ additionalProperties: false,
25676
+ properties: {
25677
+ hookEventName: {
25678
+ type: "string"
25679
+ },
25680
+ additionalContext: {
25681
+ type: "string"
25682
+ }
25683
+ }
25684
+ }
25685
+ },
25686
+ type: "object",
25687
+ additionalProperties: false,
25688
+ properties: {
25689
+ systemMessage: {
25690
+ type: "string"
25691
+ },
25692
+ suppressOutput: {
25693
+ type: "boolean"
25694
+ },
25695
+ continue: {
25696
+ type: "boolean"
25697
+ },
25698
+ stopReason: {
25699
+ type: "string"
25700
+ },
25701
+ decision: {
25702
+ type: "string",
25703
+ enum: [
25704
+ "allow",
25705
+ "deny",
25706
+ "block",
25707
+ "ask"
25708
+ ]
25709
+ },
25710
+ reason: {
25711
+ type: "string"
25712
+ },
25713
+ hookSpecificOutput: {
25714
+ allOf: [
25715
+ {
25716
+ $ref: "#/definitions/Specific"
25717
+ }
25718
+ ]
25719
+ }
25720
+ }
25721
+ }
25722
+ }
25723
+ };
25724
+
25725
+ // tests/fixtures/host-schemas/qwen.json
25726
+ var qwen_default = {
25727
+ host: "qwen",
25728
+ source: "@qwen-code/qwen-code 0.26.7: bundled/qc-helper/docs/features/hooks.md (Hook Output Structure, per-event Output Options) and chunks/chunk-6GTPLW7K.js HookOutput (getPermissionDecision reads hookSpecificOutput.permissionDecision allow|deny|ask, then decision allow|approve|deny|block|ask; a missing permissionDecision is no decision).",
25729
+ output: {
25730
+ PreToolUse: {
25731
+ title: "Qwen Code 0.26.7 PreToolUse reply",
25732
+ definitions: {
25733
+ Specific: {
25734
+ type: "object",
25735
+ additionalProperties: false,
25736
+ properties: {
25737
+ hookEventName: {
25738
+ type: "string",
25739
+ const: "PreToolUse"
25740
+ },
25741
+ permissionDecision: {
25742
+ type: "string",
25743
+ enum: [
25744
+ "allow",
25745
+ "deny",
25746
+ "ask"
25747
+ ]
25748
+ },
25749
+ permissionDecisionReason: {
25750
+ type: "string"
25751
+ },
25752
+ updatedInput: {
25753
+ type: "object"
25754
+ },
25755
+ additionalContext: {
25756
+ type: "string"
25757
+ }
25758
+ },
25759
+ required: [
25760
+ "hookEventName"
25761
+ ]
25762
+ }
25763
+ },
25764
+ type: "object",
25765
+ additionalProperties: false,
25766
+ properties: {
25767
+ continue: {
25768
+ type: "boolean"
25769
+ },
25770
+ stopReason: {
25771
+ type: "string"
25772
+ },
25773
+ suppressOutput: {
25774
+ type: "boolean"
25775
+ },
25776
+ systemMessage: {
25777
+ type: "string"
25778
+ },
25779
+ decision: {
25780
+ type: "string",
25781
+ enum: [
25782
+ "allow",
25783
+ "approve",
25784
+ "deny",
25785
+ "block",
25786
+ "ask"
25787
+ ]
25788
+ },
25789
+ reason: {
25790
+ type: "string"
25791
+ },
25792
+ hookSpecificOutput: {
25793
+ allOf: [
25794
+ {
25795
+ $ref: "#/definitions/Specific"
25796
+ }
25797
+ ]
25798
+ }
25799
+ }
25800
+ },
25801
+ PostToolUse: {
25802
+ title: "Qwen Code 0.26.7 PostToolUse reply",
25803
+ definitions: {
25804
+ Specific: {
25805
+ type: "object",
25806
+ additionalProperties: false,
25807
+ properties: {
25808
+ hookEventName: {
25809
+ type: "string",
25810
+ const: "PostToolUse"
25811
+ },
25812
+ additionalContext: {
25813
+ type: "string"
25814
+ }
25815
+ },
25816
+ required: [
25817
+ "hookEventName"
25818
+ ]
25819
+ }
25820
+ },
25821
+ type: "object",
25822
+ additionalProperties: false,
25823
+ properties: {
25824
+ continue: {
25825
+ type: "boolean"
25826
+ },
25827
+ stopReason: {
25828
+ type: "string"
25829
+ },
25830
+ suppressOutput: {
25831
+ type: "boolean"
25832
+ },
25833
+ systemMessage: {
25834
+ type: "string"
25835
+ },
25836
+ decision: {
25837
+ type: "string",
25838
+ enum: [
25839
+ "allow",
25840
+ "approve",
25841
+ "deny",
25842
+ "block",
25843
+ "ask"
25844
+ ]
25845
+ },
25846
+ reason: {
25847
+ type: "string"
25848
+ },
25849
+ hookSpecificOutput: {
25850
+ allOf: [
25851
+ {
25852
+ $ref: "#/definitions/Specific"
25853
+ }
25854
+ ]
25855
+ }
25856
+ }
25857
+ },
25858
+ UserPromptSubmit: {
25859
+ title: "Qwen Code 0.26.7 UserPromptSubmit reply",
25860
+ definitions: {
25861
+ Specific: {
25862
+ type: "object",
25863
+ additionalProperties: false,
25864
+ properties: {
25865
+ hookEventName: {
25866
+ type: "string",
25867
+ const: "UserPromptSubmit"
25868
+ },
25869
+ additionalContext: {
25870
+ type: "string"
25871
+ }
25872
+ },
25873
+ required: [
25874
+ "hookEventName"
25875
+ ]
25876
+ }
25877
+ },
25878
+ type: "object",
25879
+ additionalProperties: false,
25880
+ properties: {
25881
+ continue: {
25882
+ type: "boolean"
25883
+ },
25884
+ stopReason: {
25885
+ type: "string"
25886
+ },
25887
+ suppressOutput: {
25888
+ type: "boolean"
25889
+ },
25890
+ systemMessage: {
25891
+ type: "string"
25892
+ },
25893
+ decision: {
25894
+ type: "string",
25895
+ enum: [
25896
+ "allow",
25897
+ "approve",
25898
+ "deny",
25899
+ "block",
25900
+ "ask"
25901
+ ]
25902
+ },
25903
+ reason: {
25904
+ type: "string"
25905
+ },
25906
+ hookSpecificOutput: {
25907
+ allOf: [
25908
+ {
25909
+ $ref: "#/definitions/Specific"
25910
+ }
25911
+ ]
25912
+ }
25913
+ }
25914
+ },
25915
+ SessionStart: {
25916
+ title: "Qwen Code 0.26.7 SessionStart reply",
25917
+ definitions: {
25918
+ Specific: {
25919
+ type: "object",
25920
+ additionalProperties: false,
25921
+ properties: {
25922
+ hookEventName: {
25923
+ type: "string",
25924
+ const: "SessionStart"
25925
+ },
25926
+ additionalContext: {
25927
+ type: "string"
25928
+ }
25929
+ },
25930
+ required: [
25931
+ "hookEventName"
25932
+ ]
25933
+ }
25934
+ },
25935
+ type: "object",
25936
+ additionalProperties: false,
25937
+ properties: {
25938
+ continue: {
25939
+ type: "boolean"
25940
+ },
25941
+ stopReason: {
25942
+ type: "string"
25943
+ },
25944
+ suppressOutput: {
25945
+ type: "boolean"
25946
+ },
25947
+ systemMessage: {
25948
+ type: "string"
25949
+ },
25950
+ decision: {
25951
+ type: "string",
25952
+ enum: [
25953
+ "allow",
25954
+ "approve",
25955
+ "deny",
25956
+ "block",
25957
+ "ask"
25958
+ ]
25959
+ },
25960
+ reason: {
25961
+ type: "string"
25962
+ },
25963
+ hookSpecificOutput: {
25964
+ allOf: [
25965
+ {
25966
+ $ref: "#/definitions/Specific"
25967
+ }
25968
+ ]
25969
+ }
25970
+ }
25971
+ }
25972
+ }
25973
+ };
25974
+
25975
+ // tests/fixtures/host-schemas/copilot-cli.json
25976
+ var copilot_cli_default = {
25977
+ host: "copilot-cli",
25978
+ source: "GitHub Copilot CLI 1.0.105 copilot-sdk/types.d.ts: PreToolUseHookOutput, PostToolUseHookOutput (modifiedResult: ToolResultObject, ToolResultType), UserPromptSubmittedHookOutput, SessionStartHookOutput. Replies are flat objects with no hookSpecificOutput.",
25979
+ output: {
25980
+ PreToolUse: {
25981
+ title: "Copilot CLI 1.0.105 preToolUse reply",
25982
+ type: "object",
25983
+ additionalProperties: false,
25984
+ properties: {
25985
+ permissionDecision: {
25986
+ type: "string",
25987
+ enum: [
25988
+ "allow",
25989
+ "deny",
25990
+ "ask"
25991
+ ]
25992
+ },
25993
+ permissionDecisionReason: {
25994
+ type: "string"
25995
+ },
25996
+ modifiedArgs: {
25997
+ description: "unknown"
25998
+ },
25999
+ additionalContext: {
26000
+ type: "string"
26001
+ },
26002
+ suppressOutput: {
26003
+ type: "boolean"
26004
+ }
26005
+ }
26006
+ },
26007
+ PostToolUse: {
26008
+ title: "Copilot CLI 1.0.105 postToolUse reply",
26009
+ definitions: {
26010
+ ToolResultObject: {
26011
+ type: "object",
26012
+ additionalProperties: false,
26013
+ properties: {
26014
+ textResultForLlm: {
26015
+ type: "string"
26016
+ },
26017
+ binaryResultsForLlm: {
26018
+ type: "array",
26019
+ items: {
26020
+ type: "object"
26021
+ }
26022
+ },
26023
+ resultType: {
26024
+ type: "string",
26025
+ enum: [
26026
+ "success",
26027
+ "failure",
26028
+ "rejected",
26029
+ "denied",
26030
+ "timeout"
26031
+ ]
26032
+ },
26033
+ error: {
26034
+ type: "string"
26035
+ },
26036
+ sessionLog: {
26037
+ type: "string"
26038
+ },
26039
+ toolTelemetry: {
26040
+ type: "object"
26041
+ },
26042
+ toolReferences: {
26043
+ type: "array",
26044
+ items: {
26045
+ type: "string"
26046
+ }
26047
+ }
26048
+ },
26049
+ required: [
26050
+ "textResultForLlm",
26051
+ "resultType"
26052
+ ]
26053
+ }
26054
+ },
26055
+ type: "object",
26056
+ additionalProperties: false,
26057
+ properties: {
26058
+ modifiedResult: {
26059
+ allOf: [
26060
+ {
26061
+ $ref: "#/definitions/ToolResultObject"
26062
+ }
26063
+ ]
26064
+ },
26065
+ additionalContext: {
26066
+ type: "string"
26067
+ },
26068
+ suppressOutput: {
26069
+ type: "boolean"
26070
+ }
26071
+ }
26072
+ },
26073
+ UserPromptSubmit: {
26074
+ title: "Copilot CLI 1.0.105 userPromptSubmitted reply",
26075
+ type: "object",
26076
+ additionalProperties: false,
26077
+ properties: {
26078
+ modifiedPrompt: {
26079
+ type: "string"
26080
+ },
26081
+ additionalContext: {
26082
+ type: "string"
26083
+ },
26084
+ suppressOutput: {
26085
+ type: "boolean"
26086
+ },
26087
+ decision: {
26088
+ type: "string",
26089
+ const: "block"
26090
+ },
26091
+ reason: {
26092
+ type: "string"
26093
+ }
26094
+ }
26095
+ },
26096
+ SessionStart: {
26097
+ title: "Copilot CLI 1.0.105 sessionStart reply",
26098
+ type: "object",
26099
+ additionalProperties: false,
26100
+ properties: {
26101
+ additionalContext: {
26102
+ type: "string"
26103
+ },
26104
+ modifiedConfig: {
26105
+ type: "object"
26106
+ }
26107
+ }
26108
+ }
26109
+ }
26110
+ };
26111
+
26112
+ // tests/fixtures/host-schemas/vscode.json
26113
+ var vscode_default = {
26114
+ host: "vscode",
26115
+ source: "VS Code Copilot Chat 0.44.0 (5863f5a) src/platform/chat/common/hookCommandTypes.ts (IPreToolUseHookSpecificCommandOutput, IPostToolUseHookSpecificCommandOutput) and chatHookService.ts (UserPromptSubmitHookOutput, SessionStartHookOutput, IPostToolUseHookResult decision 'block').",
26116
+ output: {
26117
+ PreToolUse: {
26118
+ title: "VS Code Copilot Chat 0.44.0 PreToolUse reply",
26119
+ definitions: {
26120
+ Specific: {
26121
+ type: "object",
26122
+ additionalProperties: false,
26123
+ properties: {
26124
+ hookEventName: {
26125
+ type: "string"
26126
+ },
26127
+ permissionDecision: {
26128
+ type: "string",
26129
+ enum: [
26130
+ "allow",
26131
+ "deny",
26132
+ "ask"
26133
+ ]
26134
+ },
26135
+ permissionDecisionReason: {
26136
+ type: "string"
26137
+ },
26138
+ updatedInput: {
26139
+ type: "object"
26140
+ },
26141
+ additionalContext: {
26142
+ type: "string"
26143
+ }
26144
+ }
26145
+ }
26146
+ },
26147
+ type: "object",
26148
+ additionalProperties: false,
26149
+ properties: {
26150
+ hookSpecificOutput: {
26151
+ allOf: [
26152
+ {
26153
+ $ref: "#/definitions/Specific"
26154
+ }
26155
+ ]
26156
+ }
26157
+ }
26158
+ },
26159
+ PostToolUse: {
26160
+ title: "VS Code Copilot Chat 0.44.0 PostToolUse reply",
26161
+ definitions: {
26162
+ Specific: {
26163
+ type: "object",
26164
+ additionalProperties: false,
26165
+ properties: {
26166
+ hookEventName: {
26167
+ type: "string"
26168
+ },
26169
+ additionalContext: {
26170
+ type: "string"
26171
+ }
26172
+ }
26173
+ }
26174
+ },
26175
+ type: "object",
26176
+ additionalProperties: false,
26177
+ properties: {
26178
+ decision: {
26179
+ type: "string",
26180
+ const: "block"
26181
+ },
26182
+ reason: {
26183
+ type: "string"
26184
+ },
26185
+ hookSpecificOutput: {
26186
+ allOf: [
26187
+ {
26188
+ $ref: "#/definitions/Specific"
26189
+ }
26190
+ ]
26191
+ }
26192
+ }
26193
+ },
26194
+ UserPromptSubmit: {
26195
+ title: "VS Code Copilot Chat 0.44.0 UserPromptSubmit reply",
26196
+ definitions: {
26197
+ Specific: {
26198
+ type: "object",
26199
+ additionalProperties: false,
26200
+ properties: {
26201
+ hookEventName: {
26202
+ type: "string"
26203
+ },
26204
+ additionalContext: {
26205
+ type: "string"
26206
+ }
26207
+ }
26208
+ }
26209
+ },
26210
+ type: "object",
26211
+ additionalProperties: false,
26212
+ properties: {
26213
+ decision: {
26214
+ type: "string",
26215
+ const: "block"
26216
+ },
26217
+ reason: {
26218
+ type: "string"
26219
+ },
26220
+ hookSpecificOutput: {
26221
+ allOf: [
26222
+ {
26223
+ $ref: "#/definitions/Specific"
26224
+ }
26225
+ ]
26226
+ }
26227
+ }
26228
+ },
26229
+ SessionStart: {
26230
+ title: "VS Code Copilot Chat 0.44.0 SessionStart reply",
26231
+ definitions: {
26232
+ Specific: {
26233
+ type: "object",
26234
+ additionalProperties: false,
26235
+ properties: {
26236
+ hookEventName: {
26237
+ type: "string"
26238
+ },
26239
+ additionalContext: {
26240
+ type: "string"
26241
+ }
26242
+ }
26243
+ }
26244
+ },
26245
+ type: "object",
26246
+ additionalProperties: false,
26247
+ properties: {
26248
+ hookSpecificOutput: {
26249
+ allOf: [
26250
+ {
26251
+ $ref: "#/definitions/Specific"
26252
+ }
26253
+ ]
26254
+ }
26255
+ }
26256
+ }
26257
+ }
26258
+ };
26259
+
26260
+ // tests/fixtures/host-schemas/kiro.json
26261
+ var kiro_default = {
26262
+ host: "kiro",
26263
+ source: "kiro-cli 3.0.0 (BUILD_HASH 21067db0a7cc, 2026-11-02), V3 engine KAS 3.0.0-e315409f JS bundle (acp-server.js, unpacked by `kiro-cli serve`)",
26264
+ mcpToolId: {
26265
+ from: "function uel(server, tool): r = server + '_' + tool; r = r.replace(/[\\s-]/g, '_'); r = r.replace(/[^a-zA-Z0-9_]/g, ''); id = 'mcp_' + r.toLowerCase(); cut to 64 chars",
26266
+ prefix: "mcp_",
26267
+ join: "_",
26268
+ maxLength: 64
26269
+ },
26270
+ hookStdin: {
26271
+ from: "function sJn: {session_id, hook_event_name, cwd} plus per trigger fields",
26272
+ UserPromptSubmit: ["session_id", "hook_event_name", "cwd", "prompt"],
26273
+ PreToolUse: ["session_id", "hook_event_name", "cwd", "tool_name", "tool_input"],
26274
+ PostToolUse: ["session_id", "hook_event_name", "cwd", "tool_name", "tool_input", "tool_response"],
26275
+ SessionStart: ["session_id", "hook_event_name", "cwd"]
26276
+ },
26277
+ hookOutputCapChars: 3e3,
26278
+ windowsHookShell: "child_process.spawn(command, {shell: true}) in the V3 hook process runner (class tje): COMSPEC (cmd.exe /d /s /c) on win32",
26279
+ stdout: "text",
26280
+ output: {
26281
+ PreToolUse: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" },
26282
+ PostToolUse: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" },
26283
+ UserPromptSubmit: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" },
26284
+ SessionStart: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" }
26285
+ }
26286
+ };
26287
+
26288
+ // tests/fixtures/host-schemas/zcode.json
26289
+ var zcode_default = {
26290
+ host: "zcode",
26291
+ source: "ZCode 0.17.1 (a9fe401e) apps/zcode-cli/packages/contracts/src/hooks/index.ts: HookJSONOutputSchema and HookSpecificOutputSchema (zod discriminatedUnion on hookEventName). zod drops keys it does not read, so each object lists only the keys the host reads.",
26292
+ output: {
26293
+ PreToolUse: {
26294
+ title: "ZCode 0.17.1 PreToolUse reply",
26295
+ definitions: {
26296
+ Specific: {
26297
+ type: "object",
26298
+ additionalProperties: false,
26299
+ properties: {
26300
+ additionalContext: {
26301
+ type: "string"
26302
+ },
26303
+ hookEventName: {
26304
+ type: "string",
26305
+ const: "PreToolUse"
26306
+ },
26307
+ permissionDecision: {
26308
+ type: "string",
26309
+ enum: [
26310
+ "allow",
26311
+ "ask",
26312
+ "deny"
26313
+ ]
26314
+ },
26315
+ permissionDecisionReason: {
26316
+ type: "string"
26317
+ },
26318
+ updatedInput: {
26319
+ description: "z.unknown()"
26320
+ }
26321
+ },
26322
+ required: [
26323
+ "hookEventName"
26324
+ ]
26325
+ }
26326
+ },
26327
+ type: "object",
26328
+ additionalProperties: false,
26329
+ properties: {
26330
+ additionalContext: {
26331
+ type: "string"
26332
+ },
26333
+ additional_context: {
26334
+ type: "string"
26335
+ },
26336
+ continue: {
26337
+ type: "boolean"
26338
+ },
26339
+ decision: {
26340
+ type: "string",
26341
+ enum: [
26342
+ "approve",
26343
+ "block"
26344
+ ]
26345
+ },
26346
+ reason: {
26347
+ type: "string"
26348
+ },
26349
+ stopReason: {
26350
+ type: "string"
26351
+ },
26352
+ suppressOutput: {
26353
+ type: "boolean"
26354
+ },
26355
+ systemMessage: {
26356
+ type: "string"
26357
+ },
26358
+ hookSpecificOutput: {
26359
+ allOf: [
26360
+ {
26361
+ $ref: "#/definitions/Specific"
26362
+ }
26363
+ ]
26364
+ }
26365
+ }
26366
+ },
26367
+ PostToolUse: {
26368
+ title: "ZCode 0.17.1 PostToolUse reply",
26369
+ definitions: {
26370
+ Specific: {
26371
+ type: "object",
26372
+ additionalProperties: false,
26373
+ properties: {
26374
+ additionalContext: {
26375
+ type: "string"
26376
+ },
26377
+ hookEventName: {
26378
+ type: "string",
26379
+ const: "PostToolUse"
26380
+ }
26381
+ },
26382
+ required: [
26383
+ "hookEventName"
26384
+ ]
26385
+ }
26386
+ },
26387
+ type: "object",
26388
+ additionalProperties: false,
26389
+ properties: {
26390
+ additionalContext: {
26391
+ type: "string"
26392
+ },
26393
+ additional_context: {
26394
+ type: "string"
26395
+ },
26396
+ continue: {
26397
+ type: "boolean"
26398
+ },
26399
+ decision: {
26400
+ type: "string",
26401
+ enum: [
26402
+ "approve",
26403
+ "block"
26404
+ ]
26405
+ },
26406
+ reason: {
26407
+ type: "string"
26408
+ },
26409
+ stopReason: {
26410
+ type: "string"
26411
+ },
26412
+ suppressOutput: {
26413
+ type: "boolean"
26414
+ },
26415
+ systemMessage: {
26416
+ type: "string"
26417
+ },
26418
+ hookSpecificOutput: {
26419
+ allOf: [
26420
+ {
26421
+ $ref: "#/definitions/Specific"
26422
+ }
26423
+ ]
26424
+ }
26425
+ }
26426
+ },
26427
+ UserPromptSubmit: {
26428
+ title: "ZCode 0.17.1 UserPromptSubmit reply",
26429
+ definitions: {
26430
+ Specific: {
26431
+ type: "object",
26432
+ additionalProperties: false,
26433
+ properties: {
26434
+ additionalContext: {
26435
+ type: "string"
26436
+ },
26437
+ hookEventName: {
26438
+ type: "string",
26439
+ const: "UserPromptSubmit"
26440
+ }
26441
+ },
26442
+ required: [
26443
+ "hookEventName"
26444
+ ]
26445
+ }
26446
+ },
26447
+ type: "object",
26448
+ additionalProperties: false,
26449
+ properties: {
26450
+ additionalContext: {
26451
+ type: "string"
26452
+ },
26453
+ additional_context: {
26454
+ type: "string"
26455
+ },
26456
+ continue: {
26457
+ type: "boolean"
26458
+ },
26459
+ decision: {
26460
+ type: "string",
26461
+ enum: [
26462
+ "approve",
26463
+ "block"
26464
+ ]
26465
+ },
26466
+ reason: {
26467
+ type: "string"
26468
+ },
26469
+ stopReason: {
26470
+ type: "string"
26471
+ },
26472
+ suppressOutput: {
26473
+ type: "boolean"
26474
+ },
26475
+ systemMessage: {
26476
+ type: "string"
26477
+ },
26478
+ hookSpecificOutput: {
26479
+ allOf: [
26480
+ {
26481
+ $ref: "#/definitions/Specific"
26482
+ }
26483
+ ]
26484
+ }
26485
+ }
26486
+ },
26487
+ SessionStart: {
26488
+ title: "ZCode 0.17.1 SessionStart reply",
26489
+ definitions: {
26490
+ Specific: {
26491
+ type: "object",
26492
+ additionalProperties: false,
26493
+ properties: {
26494
+ additionalContext: {
26495
+ type: "string"
26496
+ },
26497
+ hookEventName: {
26498
+ type: "string",
26499
+ const: "SessionStart"
26500
+ }
26501
+ },
26502
+ required: [
26503
+ "hookEventName"
26504
+ ]
26505
+ }
26506
+ },
26507
+ type: "object",
26508
+ additionalProperties: false,
26509
+ properties: {
26510
+ additionalContext: {
26511
+ type: "string"
26512
+ },
26513
+ additional_context: {
26514
+ type: "string"
26515
+ },
26516
+ continue: {
26517
+ type: "boolean"
26518
+ },
26519
+ decision: {
26520
+ type: "string",
26521
+ enum: [
26522
+ "approve",
26523
+ "block"
26524
+ ]
26525
+ },
26526
+ reason: {
26527
+ type: "string"
26528
+ },
26529
+ stopReason: {
26530
+ type: "string"
26531
+ },
26532
+ suppressOutput: {
26533
+ type: "boolean"
26534
+ },
26535
+ systemMessage: {
26536
+ type: "string"
26537
+ },
26538
+ hookSpecificOutput: {
26539
+ allOf: [
26540
+ {
26541
+ $ref: "#/definitions/Specific"
26542
+ }
26543
+ ]
26544
+ }
26545
+ }
26546
+ }
26547
+ }
26548
+ };
26549
+
26550
+ // tests/fixtures/host-schemas/pi.json
26551
+ var pi_default = {
26552
+ host: "pi",
26553
+ source: "@earendil-works/pi-coding-agent 1.5.0 dist/core/extensions/types.d.ts (ToolCallEventResult {block, reason}, ToolResultEventResult content, BeforeAgentStartEventResult) and runner.js l.895-1010. The hook runs in process (src/entries/pi.ts): plain stdout becomes the reason, the replaced content or the added context; exit 2 blocks the tool call.",
26554
+ stdout: "text",
26555
+ output: {
26556
+ PreToolUse: {
26557
+ type: "string",
26558
+ description: "plain text read by src/entries/pi.ts"
26559
+ },
26560
+ PostToolUse: {
26561
+ type: "string",
26562
+ description: "plain text read by src/entries/pi.ts"
26563
+ },
26564
+ UserPromptSubmit: {
26565
+ type: "string",
26566
+ description: "plain text read by src/entries/pi.ts"
26567
+ },
26568
+ SessionStart: {
26569
+ type: "string",
26570
+ description: "plain text read by src/entries/pi.ts"
26571
+ }
26572
+ }
26573
+ };
26574
+
26575
+ // tests/fixtures/host-schemas/opencode.json
26576
+ var opencode_default = {
26577
+ host: "opencode",
26578
+ source: "@opencode/cli 2.2.5 plugin hooks (tool.execute.before throws to block, session hooks add text). The plugin runs the hook and reads plain stdout; exit 2 blocks the tool call with stdout as the reason.",
26579
+ stdout: "text",
26580
+ output: {
26581
+ PreToolUse: {
26582
+ type: "string",
26583
+ description: "plain text read by the context-mode OpenCode plugin"
26584
+ },
26585
+ PostToolUse: {
26586
+ type: "string",
26587
+ description: "plain text read by the context-mode OpenCode plugin"
26588
+ },
26589
+ UserPromptSubmit: {
26590
+ type: "string",
26591
+ description: "plain text read by the context-mode OpenCode plugin"
26592
+ },
26593
+ SessionStart: {
26594
+ type: "string",
26595
+ description: "plain text read by the context-mode OpenCode plugin"
26596
+ }
26597
+ }
26598
+ };
26599
+
26600
+ // src/core/ops/hook-shape.ts
26601
+ var HOST_SHAPES = {
26602
+ "claude-code": claude_code_default,
26603
+ codex: codex_default,
26604
+ gemini: gemini_default,
26605
+ qwen: qwen_default,
26606
+ "copilot-cli": copilot_cli_default,
26607
+ vscode: vscode_default,
26608
+ kiro: kiro_default,
26609
+ zcode: zcode_default,
26610
+ pi: pi_default,
26611
+ opencode: opencode_default
26612
+ };
26613
+ var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
26614
+ var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
26615
+ function isObject5(v) {
26616
+ return typeof v === "object" && v !== null && !Array.isArray(v);
26617
+ }
26618
+ function typeOf(v) {
26619
+ if (v === null) return "null";
26620
+ if (Array.isArray(v)) return "array";
26621
+ return typeof v;
26622
+ }
26623
+ function hasType(v, t) {
26624
+ if (t === "integer") return Number.isInteger(v);
26625
+ return typeOf(v) === t;
26626
+ }
26627
+ function same(a, b) {
26628
+ return JSON.stringify(a) === JSON.stringify(b);
26629
+ }
26630
+ function resolve7(root, ref) {
26631
+ const parts = ref.split("/");
26632
+ if (parts[0] !== "#") throw new Error(`hook-shape: only local $ref is read, got ${ref}`);
26633
+ let at2 = root;
26634
+ for (const p of parts.slice(1)) at2 = isObject5(at2) ? at2[p] : void 0;
26635
+ if (!isObject5(at2)) throw new Error(`hook-shape: $ref ${ref} names nothing`);
26636
+ return at2;
26637
+ }
26638
+ function shapeErrors(schema, value, root = schema, at2 = "$") {
26639
+ for (const k of Object.keys(schema)) {
26640
+ if (!NOTE_KEYS.has(k) && !RULE_KEYS.has(k)) throw new Error(`hook-shape: keyword ${k} at ${at2} is not read by the checker`);
26641
+ }
26642
+ const errs = [];
26643
+ if (typeof schema.$ref === "string") errs.push(...shapeErrors(resolve7(root, schema.$ref), value, root, at2));
26644
+ if (Array.isArray(schema.allOf)) for (const s of schema.allOf) errs.push(...shapeErrors(s, value, root, at2));
26645
+ if (schema.type !== void 0) {
26646
+ const types = Array.isArray(schema.type) ? schema.type : [schema.type];
26647
+ if (!types.some((t) => hasType(value, String(t)))) return [...errs, `${at2}: ${typeOf(value)} is not ${types.join(" or ")}`];
26648
+ }
26649
+ if (Array.isArray(schema.enum) && !schema.enum.some((e) => same(e, value))) errs.push(`${at2}: ${JSON.stringify(value)} is not one of ${JSON.stringify(schema.enum)}`);
26650
+ if (Object.hasOwn(schema, "const") && !same(schema.const, value)) errs.push(`${at2}: ${JSON.stringify(value)} is not ${JSON.stringify(schema.const)}`);
26651
+ if (isObject5(value)) {
26652
+ const props = isObject5(schema.properties) ? schema.properties : {};
26653
+ if (Array.isArray(schema.required)) {
26654
+ for (const r of schema.required) if (!Object.hasOwn(value, String(r))) errs.push(`${at2}: ${String(r)} is required`);
26655
+ }
26656
+ for (const [k, v] of Object.entries(value)) {
26657
+ if (Object.hasOwn(props, k)) errs.push(...shapeErrors(props[k], v, root, `${at2}.${k}`));
26658
+ else if (schema.additionalProperties === false) errs.push(`${at2}: ${k} is not a known key`);
26659
+ else if (isObject5(schema.additionalProperties)) errs.push(...shapeErrors(schema.additionalProperties, v, root, `${at2}.${k}`));
26660
+ }
26661
+ }
26662
+ if (Array.isArray(value) && isObject5(schema.items)) {
26663
+ const items = schema.items;
26664
+ value.forEach((v, n) => errs.push(...shapeErrors(items, v, root, `${at2}[${n}]`)));
26665
+ }
26666
+ return errs;
26667
+ }
26668
+ function replyErrors(agent, event, stdout) {
26669
+ const host = HOST_SHAPES[agent];
26670
+ const schema = host.output[event];
26671
+ if (schema === void 0) return [`${agent} has no ${event} reply schema`];
26672
+ if (host.stdout === "text") return shapeErrors(schema, stdout);
26673
+ let value;
26674
+ try {
26675
+ value = JSON.parse(stdout);
26676
+ } catch {
26677
+ return [`${agent} ${event}: stdout is not JSON`];
26678
+ }
26679
+ return shapeErrors(schema, value);
26680
+ }
26681
+
24803
26682
  // src/core/sandbox/host-node.ts
24804
26683
  var BUN_BE_BUN_ENV = "BUN_BE_BUN";
24805
26684
  function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.execPath }, find2 = findRuntime) {
@@ -24928,14 +26807,14 @@ function pluginHooksFromReply(m, pluginId) {
24928
26807
  function askPluginHooks(env, pluginId, cwd) {
24929
26808
  const bin = whichBin("codex", env);
24930
26809
  if (!bin) return Promise.resolve({ kind: "absent" });
24931
- return new Promise((resolve9) => {
26810
+ return new Promise((resolve10) => {
24932
26811
  let asked;
24933
26812
  const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
24934
26813
  let f;
24935
26814
  try {
24936
26815
  f = spawnForm(bin, ["app-server"], env);
24937
26816
  } catch {
24938
- resolve9({ kind: "silent" });
26817
+ resolve10({ kind: "silent" });
24939
26818
  return;
24940
26819
  }
24941
26820
  const child = spawn2(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
@@ -24945,7 +26824,7 @@ function askPluginHooks(env, pluginId, cwd) {
24945
26824
  let result;
24946
26825
  const settle3 = () => {
24947
26826
  clearTimeout(grace);
24948
- resolve9(done_(result));
26827
+ resolve10(done_(result));
24949
26828
  };
24950
26829
  let grace;
24951
26830
  const finish2 = (v) => {
@@ -25029,7 +26908,7 @@ var D5_CODEX_SILENT_DETAIL = (home) => `codex app-server gave no hooks/list answ
25029
26908
  var D5_CODEX_OTHER_HOME_DETAIL = (asked, home) => `codex answers for ${asked}, but the context-mode plugin runs from ${home}`;
25030
26909
  var D5_CODEX_NONE_DETAIL = (home) => `codex lists no context-mode plugin hooks in ${home}, so they do not run`;
25031
26910
  var row = (status, detail, fixCommand) => fixCommand === void 0 ? { id: "D5", label: DOCTOR_LABEL.D5, status, detail } : { id: "D5", label: DOCTOR_LABEL.D5, status, detail, fixCommand };
25032
- function isObject5(v) {
26911
+ function isObject6(v) {
25033
26912
  return typeof v === "object" && v !== null && !Array.isArray(v);
25034
26913
  }
25035
26914
  function loadFixture(bundleDir2, agent) {
@@ -25041,10 +26920,10 @@ function loadFixture(bundleDir2, agent) {
25041
26920
  } catch (err) {
25042
26921
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
25043
26922
  }
25044
- if (!isObject5(all)) return { cause: D5_FIXTURE_PARSE(file2, "top level is not an object") };
26923
+ if (!isObject6(all)) return { cause: D5_FIXTURE_PARSE(file2, "top level is not an object") };
25045
26924
  if (!Object.hasOwn(all, agent)) return { cause: D5_NO_FIXTURE_DETAIL(agent) + ": " + D5_FIXTURE_AGENT_ABSENT(file2, Object.keys(all)) };
25046
26925
  const e = all[agent];
25047
- if (!isObject5(e) || typeof e.event !== "string" || !Object.hasOwn(e, "payload")) {
26926
+ if (!isObject6(e) || typeof e.event !== "string" || !Object.hasOwn(e, "payload")) {
25048
26927
  return { cause: D5_NO_FIXTURE_DETAIL(agent) + ": the entry lacks an event name or a payload" };
25049
26928
  }
25050
26929
  return { event: e.event, payload: e.payload };
@@ -25062,39 +26941,11 @@ var CWD_KEY = {
25062
26941
  opencode: "directory"
25063
26942
  };
25064
26943
  function payloadFor(agent, payload, worktree) {
25065
- return worktree !== void 0 && isObject5(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
25066
- }
25067
- var SHAPE = {
25068
- "claude-code": "claude",
25069
- codex: "claude",
25070
- qwen: "claude",
25071
- vscode: "claude",
25072
- zcode: "claude",
25073
- gemini: "gemini",
25074
- "copilot-cli": "copilot",
25075
- kiro: "text",
25076
- pi: "text",
25077
- opencode: "text"
25078
- };
25079
- var COPILOT_KEYS = ["permissionDecision", "additionalContext", "modifiedResult"];
26944
+ return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
26945
+ }
25080
26946
  function isNativeShape(agent, stdout, exitCode, killed, event) {
25081
26947
  if (killed !== null || exitCode !== 0 && exitCode !== 2) return false;
25082
- if (stdout.length === 0 || SHAPE[agent] === "text") return true;
25083
- let out;
25084
- try {
25085
- out = JSON.parse(stdout);
25086
- } catch {
25087
- return false;
25088
- }
25089
- if (!isObject5(out)) return false;
25090
- switch (SHAPE[agent]) {
25091
- case "claude":
25092
- return isObject5(out.hookSpecificOutput) && out.hookSpecificOutput.hookEventName === event;
25093
- case "gemini":
25094
- return typeof out.decision === "string" || isObject5(out.hookSpecificOutput);
25095
- default:
25096
- return COPILOT_KEYS.some((k) => Object.hasOwn(out, k));
25097
- }
26948
+ return stdout.length === 0 || replyErrors(agent, event, stdout).length === 0;
25098
26949
  }
25099
26950
  var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
25100
26951
  function readProbePayload(cwd, ranged) {
@@ -25119,9 +26970,9 @@ function isReadShape(stdout) {
25119
26970
  } catch {
25120
26971
  return false;
25121
26972
  }
25122
- if (!isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
26973
+ if (!isObject6(out) || !isObject6(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
25123
26974
  const r = out.hookSpecificOutput.updatedToolOutput;
25124
- if (!isObject5(r) || r.type !== "text" || !isObject5(r.file)) return false;
26975
+ if (!isObject6(r) || r.type !== "text" || !isObject6(r.file)) return false;
25125
26976
  const f = r.file;
25126
26977
  return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
25127
26978
  }
@@ -25149,11 +27000,49 @@ function isPassThrough(stdout) {
25149
27000
  } catch {
25150
27001
  return false;
25151
27002
  }
25152
- return !isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput");
27003
+ return !isObject6(out) || !isObject6(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput");
27004
+ }
27005
+ var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
27006
+ async function mediaProbe(i, timeoutMs) {
27007
+ const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-media-"));
27008
+ try {
27009
+ const filePath = path7.join(home, "d5-media-probe.png");
27010
+ writeFileSync2(filePath, Buffer.concat([PNG_SIGNATURE, Buffer.alloc(OUTPUT_CAP + 1)]));
27011
+ const node3 = nodeLaunch({ ...i.env, HOME: home, USERPROFILE: home });
27012
+ const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
27013
+ cwd: i.bundleDir,
27014
+ env: node3.env,
27015
+ signal: i.signal,
27016
+ timeoutMs,
27017
+ stdin: JSON.stringify({
27018
+ session_id: "d5-media-probe",
27019
+ transcript_path: "",
27020
+ cwd: home,
27021
+ hook_event_name: "PreToolUse",
27022
+ tool_name: "Read",
27023
+ tool_use_id: "toolu_d5_media_probe",
27024
+ tool_input: { file_path: filePath }
27025
+ })
27026
+ });
27027
+ return r.stdout.toString("utf8");
27028
+ } finally {
27029
+ rmSync2(home, { recursive: true, force: true });
27030
+ }
27031
+ }
27032
+ function isDeny(stdout) {
27033
+ if (stdout.trim() === "") return false;
27034
+ let out;
27035
+ try {
27036
+ out = JSON.parse(stdout);
27037
+ } catch {
27038
+ return false;
27039
+ }
27040
+ return isObject6(out) && isObject6(out.hookSpecificOutput) && out.hookSpecificOutput.permissionDecision === "deny";
25153
27041
  }
25154
27042
  async function readProbeDetail(i, timeoutMs) {
25155
27043
  if (!isReadShape(await readProbe(i, timeoutMs, false))) return D5_READ_SHAPE_DETAIL;
25156
27044
  if (!isPassThrough(await readProbe(i, timeoutMs, true))) return D5_READ_RANGE_DETAIL;
27045
+ if (isDeny(await mediaProbe(i, timeoutMs))) return D5_READ_MEDIA_DETAIL;
25157
27046
  return null;
25158
27047
  }
25159
27048
  function codexHookJournaled(db) {
@@ -25184,6 +27073,36 @@ async function codexPluginTrust(i) {
25184
27073
  if (reply4.hooks.length === 0) return row("FAIL", D5_CODEX_NONE_DETAIL(home), D5_CODEX_TRUST_FIX);
25185
27074
  return null;
25186
27075
  }
27076
+ function codexStopPayload(cwd) {
27077
+ return {
27078
+ session_id: "d5-stop-probe",
27079
+ turn_id: "d5-stop-turn",
27080
+ transcript_path: null,
27081
+ cwd,
27082
+ hook_event_name: "Stop",
27083
+ model: "d5-probe",
27084
+ permission_mode: "default",
27085
+ stop_hook_active: false,
27086
+ last_assistant_message: "d5 stop probe"
27087
+ };
27088
+ }
27089
+ async function codexStopDetail(i, timeoutMs) {
27090
+ const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-stop-"));
27091
+ try {
27092
+ const node3 = nodeLaunch({ ...i.env, HOME: home, USERPROFILE: home, [DATA_DIR_ENV]: home });
27093
+ const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
27094
+ cwd: i.bundleDir,
27095
+ env: node3.env,
27096
+ signal: i.signal,
27097
+ timeoutMs,
27098
+ stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
27099
+ });
27100
+ const logged = existsSync12(path7.join(home, HOOK_ERROR_LOG_FILE));
27101
+ return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
27102
+ } finally {
27103
+ rmSync2(home, { recursive: true, force: true });
27104
+ }
27105
+ }
25187
27106
  async function checkHookRoundTrip(i) {
25188
27107
  if (i.agent === "codex") {
25189
27108
  const trust = await codexPluginTrust(i);
@@ -25225,7 +27144,7 @@ async function checkHookRoundTrip(i) {
25225
27144
  if (n >= minPairs && ms <= HOOK_P95_MS) break;
25226
27145
  }
25227
27146
  if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
25228
- const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : null;
27147
+ const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
25229
27148
  if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
25230
27149
  return row("PASS", DOCTOR_PASS_DETAIL);
25231
27150
  }
@@ -25235,7 +27154,7 @@ import { existsSync as existsSync13, mkdirSync as mkdirSync5, rmSync as rmSync4
25235
27154
  import { basename as basename4, dirname as dirname8, join as join16 } from "node:path";
25236
27155
 
25237
27156
  // src/core/store/owners.ts
25238
- import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync12, rmSync as rmSync3, writeFileSync as writeFileSync2 } from "node:fs";
27157
+ import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync12, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
25239
27158
  import { basename as basename3, join as join15 } from "node:path";
25240
27159
  function ownersDir(configDir, projectKey) {
25241
27160
  return join15(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
@@ -25248,7 +27167,7 @@ function errCode2(err) {
25248
27167
  }
25249
27168
  function writeOwnerPid(configDir, projectKey, serverId) {
25250
27169
  mkdirSync4(ownersDir(configDir, projectKey), { recursive: true });
25251
- writeFileSync2(ownerFile(configDir, projectKey, serverId), String(process.pid), "utf8");
27170
+ writeFileSync3(ownerFile(configDir, projectKey, serverId), String(process.pid), "utf8");
25252
27171
  }
25253
27172
  function removeOwnerPid(configDir, projectKey, serverId) {
25254
27173
  rmSync3(ownerFile(configDir, projectKey, serverId), { force: true });
@@ -25432,7 +27351,7 @@ function buildReportHead(input) {
25432
27351
 
25433
27352
  // src/core/ops/doctor-issue.ts
25434
27353
  import { spawnSync as spawnSync3 } from "node:child_process";
25435
- import { closeSync, existsSync as existsSync14, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync13, readSync, realpathSync as realpathSync9, writeFileSync as writeFileSync3 } from "node:fs";
27354
+ import { closeSync as closeSync2, existsSync as existsSync14, fstatSync, mkdirSync as mkdirSync6, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
25436
27355
  import { delimiter, join as join17 } from "node:path";
25437
27356
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
25438
27357
  function tildeOf(env) {
@@ -25485,31 +27404,31 @@ function hookLogTail(env) {
25485
27404
  const file2 = hookLogPath(env);
25486
27405
  if (file2 === "" || !existsSync14(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
25487
27406
  try {
25488
- const fd = openSync(file2, "r");
27407
+ const fd = openSync2(file2, "r");
25489
27408
  try {
25490
27409
  const size = fstatSync(fd).size;
25491
27410
  const start = Math.max(0, size - DOCTOR_LOG_TAIL_BYTES);
25492
27411
  const buf = Buffer.alloc(size - start);
25493
- readSync(fd, buf, 0, buf.length, start);
27412
+ readSync2(fd, buf, 0, buf.length, start);
25494
27413
  const lines = buf.toString("utf8").split("\n").filter((l) => l.trim() !== "");
25495
27414
  if (start > 0) lines.shift();
25496
27415
  return lines.slice(-DOCTOR_HOOK_LOG_LINES).map(maskLine);
25497
27416
  } finally {
25498
- closeSync(fd);
27417
+ closeSync2(fd);
25499
27418
  }
25500
27419
  } catch (err) {
25501
27420
  return [`hook-errors.log read: ${err instanceof Error ? err.message : String(err)}`];
25502
27421
  }
25503
27422
  }
25504
27423
  async function journalRows(ctx) {
25505
- const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
27424
+ const head2 = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
25506
27425
  if (!existsSync14(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
25507
27426
  try {
25508
27427
  const db = await openDb(ctx.project, { readOnly: true });
25509
27428
  try {
25510
27429
  const rows = db.raw.prepare(`SELECT kind, tool, bytes, ok, exit_code, created_at FROM events ORDER BY seq DESC LIMIT ${DOCTOR_JOURNAL_ROWS}`).all();
25511
27430
  const cell5 = (v) => v === null || v === void 0 ? "" : String(v);
25512
- return head.concat(rows.map((r) => `| ${cell5(r.kind)} | ${cell5(r.tool)} | ${cell5(r.bytes)} | ${cell5(r.ok)} | ${cell5(r.exit_code)} | ${typeof r.created_at === "number" ? new Date(r.created_at).toISOString() : cell5(r.created_at)} |`));
27431
+ return head2.concat(rows.map((r) => `| ${cell5(r.kind)} | ${cell5(r.tool)} | ${cell5(r.bytes)} | ${cell5(r.ok)} | ${cell5(r.exit_code)} | ${typeof r.created_at === "number" ? new Date(r.created_at).toISOString() : cell5(r.created_at)} |`));
25513
27432
  } finally {
25514
27433
  closeDb(db);
25515
27434
  }
@@ -25608,7 +27527,7 @@ async function writeIssueReport(i) {
25608
27527
  const dir = join17(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
25609
27528
  mkdirSync6(dir, { recursive: true });
25610
27529
  const file2 = join17(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
25611
- writeFileSync3(file2, body);
27530
+ writeFileSync4(file2, body);
25612
27531
  const shown2 = tilde(file2);
25613
27532
  const title = issueTitle(i.adapter.id, i.rows);
25614
27533
  const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
@@ -25763,9 +27682,9 @@ var ctxDoctor = Object.freeze({
25763
27682
  });
25764
27683
 
25765
27684
  // src/core/tools/execute.ts
25766
- import { existsSync as existsSync16, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync4 } from "node:fs";
27685
+ import { existsSync as existsSync16, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
25767
27686
  import { tmpdir as tmpdir3 } from "node:os";
25768
- import { dirname as dirname10, join as join19, parse as parse3, resolve as resolve7 } from "node:path";
27687
+ import { dirname as dirname10, join as join19, parse as parse3, resolve as resolve8 } from "node:path";
25769
27688
 
25770
27689
  // src/core/sandbox/win-build.ts
25771
27690
  var SEPARATORS2 = ";&|(\n";
@@ -25884,16 +27803,16 @@ async function finish(input, ctx, r, exitCode, journal) {
25884
27803
  const isError = exitCode !== 0 && !(input.language === "shell" && exitCode === SOFT_EXIT && r.stderr.length === 0);
25885
27804
  const combined = r.stdout.toString("utf8") + (exitCode !== 0 ? r.stderr.toString("utf8") : "");
25886
27805
  const fullBytes = Buffer.byteLength(combined, "utf8");
25887
- const head = summaryLine(exitCode, fullBytes);
27806
+ const head2 = summaryLine(exitCode, fullBytes);
25888
27807
  const intent = input.intent ?? "";
25889
27808
  const bare2 = exitCode === 0 && input.summary !== true && combined !== "";
25890
- const direct = (bare2 ? "" : head + "\n") + (input.summary === true ? echoBlock(input.language, input.code) + "\n" : "") + combined;
25891
- const fits = Buffer.byteLength(head + "\n" + (input.summary === true ? echoBlock(input.language, input.code) + "\n" : "") + combined, "utf8") <= OUTPUT_CAP;
27809
+ const direct = (bare2 ? "" : head2 + "\n") + (input.summary === true ? echoBlock(input.language, input.code) + "\n" : "") + combined;
27810
+ const fits = Buffer.byteLength(head2 + "\n" + (input.summary === true ? echoBlock(input.language, input.code) + "\n" : "") + combined, "utf8") <= OUTPUT_CAP;
25892
27811
  if (intent === "" && fits) {
25893
27812
  return { text: direct, isError, sandboxBytes: fullBytes, journal };
25894
27813
  }
25895
27814
  const label2 = sourceLabel(input.code);
25896
- const budget = (fits ? OUTPUT_CAP : EXEC_PREVIEW_BYTES) - Buffer.byteLength(head, "utf8") - 2 - moreReserve(intent, label2);
27815
+ const budget = (fits ? OUTPUT_CAP : EXEC_PREVIEW_BYTES) - Buffer.byteLength(head2, "utf8") - 2 - moreReserve(intent, label2);
25897
27816
  const db = await openDb(ctx.project);
25898
27817
  let picked;
25899
27818
  try {
@@ -25902,7 +27821,7 @@ async function finish(input, ctx, r, exitCode, journal) {
25902
27821
  } finally {
25903
27822
  closeDb(db);
25904
27823
  }
25905
- const text = head + "\n" + picked.text + (picked.more === null ? "" : "\n" + picked.more);
27824
+ const text = head2 + "\n" + picked.text + (picked.more === null ? "" : "\n" + picked.more);
25906
27825
  return { text: capBytes(text, OUTPUT_CAP).text, isError, sandboxBytes: fullBytes, journal };
25907
27826
  }
25908
27827
  async function handler3(raw, ctx) {
@@ -25912,7 +27831,7 @@ async function handler3(raw, ctx) {
25912
27831
  const cwd = ctx.project.worktree;
25913
27832
  const extra = { ...PLAIN_OUTPUT_ENV2 };
25914
27833
  if (input.file !== void 0) {
25915
- const abs = resolve7(cwd, input.file);
27834
+ const abs = resolve8(cwd, input.file);
25916
27835
  const bad = fileError(input.file, abs, ctx.project.containmentRoot);
25917
27836
  if (bad !== null) return fail5(bad);
25918
27837
  extra.CTX_FILE = abs;
@@ -25931,7 +27850,7 @@ async function handler3(raw, ctx) {
25931
27850
  } else {
25932
27851
  tmpDir = mkdtempSync2(join19(tmpdir3(), TMP_PREFIX));
25933
27852
  const file2 = join19(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
25934
- writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
27853
+ writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
25935
27854
  argv = scriptArgv(input.language, runtime, file2);
25936
27855
  }
25937
27856
  if (input.background === true) {
@@ -25967,7 +27886,7 @@ var ctxExecute = {
25967
27886
 
25968
27887
  // src/core/tools/index.ts
25969
27888
  import { existsSync as existsSync17, readFileSync as readFileSync16, statSync as statSync8 } from "node:fs";
25970
- import { dirname as dirname11, extname, join as join21, relative as relative5, resolve as resolve8 } from "node:path";
27889
+ import { dirname as dirname11, extname as extname2, join as join21, relative as relative5, resolve as resolve9 } from "node:path";
25971
27890
 
25972
27891
  // src/core/index/walk.ts
25973
27892
  import { readdirSync as readdirSync7, readFileSync as readFileSync15, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
@@ -26212,9 +28131,9 @@ function ipv6Words(address) {
26212
28131
  };
26213
28132
  const gap = a.indexOf("::");
26214
28133
  if (gap < 0) return words2(a);
26215
- const head = words2(a.slice(0, gap));
28134
+ const head2 = words2(a.slice(0, gap));
26216
28135
  const tail = words2(a.slice(gap + 2));
26217
- return [...head, ...new Array(8 - head.length - tail.length).fill(0), ...tail];
28136
+ return [...head2, ...new Array(8 - head2.length - tail.length).fill(0), ...tail];
26218
28137
  }
26219
28138
  function dotted(hi, lo) {
26220
28139
  return [hi >> 8, hi & 255, lo >> 8, lo & 255].join(".");
@@ -26254,18 +28173,18 @@ function request(u, conn, proxy, signal) {
26254
28173
  const host = bare(u.hostname);
26255
28174
  const port = u.port === "" ? defaultPort(u.protocol) : Number(u.port);
26256
28175
  const path8 = u.pathname + u.search;
26257
- return new Promise((resolve9, reject) => {
28176
+ return new Promise((resolve10, reject) => {
26258
28177
  const onErr = (err) => reject(fail6(causeCode(err)));
26259
28178
  if (proxy === void 0) {
26260
28179
  const mod = u.protocol === "https:" ? https : http;
26261
28180
  const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
26262
- req.on("response", resolve9).on("error", onErr).end();
28181
+ req.on("response", resolve10).on("error", onErr).end();
26263
28182
  return;
26264
28183
  }
26265
28184
  const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
26266
28185
  if (u.protocol === "http:") {
26267
28186
  const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
26268
- req.on("response", resolve9).on("error", onErr).end();
28187
+ req.on("response", resolve10).on("error", onErr).end();
26269
28188
  return;
26270
28189
  }
26271
28190
  const authority = (isIP(host) === 6 ? "[" + host + "]" : host) + ":" + port;
@@ -26285,16 +28204,16 @@ function request(u, conn, proxy, signal) {
26285
28204
  headers: { host: u.host },
26286
28205
  createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
26287
28206
  });
26288
- req.on("response", resolve9).on("error", onErr).end();
28207
+ req.on("response", resolve10).on("error", onErr).end();
26289
28208
  });
26290
28209
  tunnel.end();
26291
28210
  });
26292
28211
  }
26293
28212
  function readBody(res) {
26294
- return new Promise((resolve9, reject) => {
28213
+ return new Promise((resolve10, reject) => {
26295
28214
  const parts = [];
26296
28215
  res.on("data", (b) => parts.push(b));
26297
- res.on("end", () => resolve9(Buffer.concat(parts)));
28216
+ res.on("end", () => resolve10(Buffer.concat(parts)));
26298
28217
  res.on("error", (err) => reject(fail6(causeCode(err))));
26299
28218
  res.on("aborted", () => reject(fail6("ECONNRESET")));
26300
28219
  });
@@ -30151,7 +32070,7 @@ function userLabel(label2) {
30151
32070
  return label2 === DECISION_SOURCE ? DECISION_USER_LABEL : label2;
30152
32071
  }
30153
32072
  function kindOfPath(p) {
30154
- return EXT_KIND[extname(p).toLowerCase()] ?? "text";
32073
+ return EXT_KIND[extname2(p).toLowerCase()] ?? "text";
30155
32074
  }
30156
32075
  function kindOfType(contentType) {
30157
32076
  const semi = contentType.indexOf(";");
@@ -30172,7 +32091,7 @@ function missingOrOutside(given, abs, root) {
30172
32091
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
30173
32092
  }
30174
32093
  function pathItems(input, project) {
30175
- const abs = resolve8(project.worktree, input.path);
32094
+ const abs = resolve9(project.worktree, input.path);
30176
32095
  if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
30177
32096
  const base = relative5(project.worktree, abs);
30178
32097
  if (statSync8(abs).isDirectory()) {
@@ -30250,8 +32169,8 @@ async function handler4(input, ctx) {
30250
32169
  } finally {
30251
32170
  closeDb(db);
30252
32171
  }
30253
- const head = "Indexed " + sources + " source(s), " + chunks + " chunk(s) from ";
30254
- const first = sources === 1 && lastId > 0 ? head + sourceHandle(lastId) + ". " + indexedLabelLine(from, lastId) : head + shownLabel(from, null) + ".";
32172
+ const head2 = "Indexed " + sources + " source(s), " + chunks + " chunk(s) from ";
32173
+ const first = sources === 1 && lastId > 0 ? head2 + sourceHandle(lastId) + ". " + indexedLabelLine(from, lastId) : head2 + shownLabel(from, null) + ".";
30255
32174
  const line = [first, ...notes].join("\n");
30256
32175
  return {
30257
32176
  text: capBytes(line, OUTPUT_CAP).text,
@@ -30423,7 +32342,7 @@ function readWeek(raw, lastMs) {
30423
32342
  }
30424
32343
  return days;
30425
32344
  }
30426
- var EMPTY5 = Object.freeze({ calls: 0, produced: 0, returned: 0, saved: 0 });
32345
+ var EMPTY6 = Object.freeze({ calls: 0, produced: 0, returned: 0, saved: 0 });
30427
32346
  function totals(r) {
30428
32347
  const produced = Number(r.produced);
30429
32348
  const returned = Number(r.returned);
@@ -30463,7 +32382,7 @@ function sum(groups) {
30463
32382
  produced: t.produced + g.produced,
30464
32383
  returned: t.returned + g.returned,
30465
32384
  saved: t.saved + g.saved
30466
- }), EMPTY5);
32385
+ }), EMPTY6);
30467
32386
  }
30468
32387
  function reductionPct(t) {
30469
32388
  if (t.calls === 0) return 0;
@@ -30521,8 +32440,8 @@ function plural(n, word) {
30521
32440
  }
30522
32441
  function table2(title, rows) {
30523
32442
  const max = Math.max(0, ...rows.map((r) => r.saved));
30524
- const head = " " + title.padEnd(LABEL_W) + right("Calls", STATS_CALLS_W) + right("Made", NUM_W) + right("Sent", NUM_W) + right("Kept out", NUM_W) + right("%", PCT_W);
30525
- return [head, ...rows.map((r) => (" " + label(r.name) + right(count(r.calls), STATS_CALLS_W) + right(bytes4(r.produced), NUM_W) + right(bytes4(r.returned), NUM_W) + right(bytes4(r.saved), NUM_W) + right(pct(r), PCT_W) + " " + bar(r.saved, max, STATS_ROW_BAR)).trimEnd())];
32443
+ const head2 = " " + title.padEnd(LABEL_W) + right("Calls", STATS_CALLS_W) + right("Made", NUM_W) + right("Sent", NUM_W) + right("Kept out", NUM_W) + right("%", PCT_W);
32444
+ return [head2, ...rows.map((r) => (" " + label(r.name) + right(count(r.calls), STATS_CALLS_W) + right(bytes4(r.produced), NUM_W) + right(bytes4(r.returned), NUM_W) + right(bytes4(r.saved), NUM_W) + right(pct(r), PCT_W) + " " + bar(r.saved, max, STATS_ROW_BAR)).trimEnd())];
30526
32445
  }
30527
32446
  function bySaved(a, b) {
30528
32447
  return b.saved - a.saved || b.produced - a.produced || a.returned - b.returned || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
@@ -30566,10 +32485,10 @@ function windowLine(saved) {
30566
32485
  const t = saved / STATS_BYTES_PER_TOKEN;
30567
32486
  const share = t / STATS_WINDOW_TOKENS;
30568
32487
  const win = `a ${tokens(STATS_WINDOW_TOKENS)} window`;
30569
- const head = ` about ${tokens(t)} tokens kept out`;
30570
- if (share >= 1) return `${head}, ${whole(share)} times ${win}`;
32488
+ const head2 = ` about ${tokens(t)} tokens kept out`;
32489
+ if (share >= 1) return `${head2}, ${whole(share)} times ${win}`;
30571
32490
  const p = share * PERCENT_SCALE;
30572
- return p * STATS_WHOLE_FROM < 1 ? head : `${head}, ${whole(p)}% of ${win}`;
32491
+ return p * STATS_WHOLE_FROM < 1 ? head2 : `${head2}, ${whole(p)}% of ${win}`;
30573
32492
  }
30574
32493
  function ymd(day) {
30575
32494
  return new Date(day * MS_PER_DAY).toISOString().slice(0, "yyyy-mm-dd".length);
@@ -30600,14 +32519,14 @@ function lastDays(week, allCalls) {
30600
32519
  const all = saved.reduce((a, b) => a + b, 0);
30601
32520
  const calls = week.reduce((a, d) => a + d.calls, 0);
30602
32521
  const max = Math.max(0, ...saved);
30603
- const head = `Last ${STATS_DAYS} days of use \xB7 ${ymd(week[0].day)} to ${ymd(week[week.length - 1].day)}`;
32522
+ const head2 = `Last ${STATS_DAYS} days of use \xB7 ${ymd(week[0].day)} to ${ymd(week[week.length - 1].day)}`;
30604
32523
  const card = calls < allCalls ? [
30605
32524
  cards(["Kept out", "Tokens kept out", "Calls", "Kept out per call"]),
30606
32525
  cards([bytes4(all), "about " + tokens(all / STATS_BYTES_PER_TOKEN), count(calls), bytes4(calls > 0 ? all / calls : 0)]),
30607
32526
  ""
30608
32527
  ] : [];
30609
32528
  return [
30610
- head,
32529
+ head2,
30611
32530
  ...card,
30612
32531
  ...week.flatMap((d, i) => saved[i] > 0 ? [" " + mmdd(d.day) + " " + stack(STATS_WAYS.map(([w]) => d.ways[w]), max, STATS_DAY_BAR).padEnd(STATS_DAY_BAR) + right(bytes4(saved[i]), NUM_W)] : []),
30613
32532
  " " + STATS_WAYS.map(([, ch, name]) => `${ch} ${name}`).join(" "),
@@ -30626,15 +32545,15 @@ function fit(line) {
30626
32545
  return chars.length <= STATS_WIDTH ? line : chars.slice(0, STATS_WIDTH - 1).join("") + "\u2026";
30627
32546
  }
30628
32547
  function report(f, sessionId, agent) {
30629
- const head = [STATS_REPORT_TITLE, "\u2500".repeat(STATS_WIDTH), ""];
32548
+ const head2 = [STATS_REPORT_TITLE, "\u2500".repeat(STATS_WIDTH), ""];
30630
32549
  const project = sum(f.groups);
30631
- if (project.calls === 0) return [...head, ...STATS_EMPTY_LINES].join("\n");
32550
+ if (project.calls === 0) return [...head2, ...STATS_EMPTY_LINES].join("\n");
30632
32551
  const session = sum(f.groups.filter((g) => g.session === sessionId));
30633
32552
  const [scopeName, focus] = session.calls > 0 ? ["This session", session] : ["This project", project];
30634
32553
  const top = Math.max(focus.produced, focus.returned);
30635
32554
  const extra = session.calls > 0 ? ` \xB7 ${span(f.span)} active` : "";
30636
32555
  const lines = [
30637
- ...head,
32556
+ ...head2,
30638
32557
  `${scopeName} \xB7 ${plural(focus.calls, "call")}${extra}`,
30639
32558
  ` ${bytes4(focus.produced)} became ${bytes4(focus.returned)}: ${bytes4(focus.saved)} kept out (${pct(focus)})`,
30640
32559
  " " + "Without context-mode".padEnd(LABEL_W) + "|" + bar(focus.produced, top, STATS_HEAD_BAR, "\u2588", "\u2591") + "|" + right(bytes4(focus.produced), NUM_W),
@@ -30657,8 +32576,8 @@ function report(f, sessionId, agent) {
30657
32576
  ] : []
30658
32577
  ];
30659
32578
  const agents = /* @__PURE__ */ new Map();
30660
- for (const g of f.groups) agents.set(g.agent, sum([agents.get(g.agent) ?? EMPTY5, g]));
30661
- if (!agents.has(agent)) agents.set(agent, EMPTY5);
32579
+ for (const g of f.groups) agents.set(g.agent, sum([agents.get(g.agent) ?? EMPTY6, g]));
32580
+ if (!agents.has(agent)) agents.set(agent, EMPTY6);
30662
32581
  lines.push("By agent (this project)", ...table2("Agent", [...agents].map(([name, t]) => ({ name, ...t })).sort(bySaved)), "");
30663
32582
  const maxKind = Math.max(0, ...[...f.kinds.values()].map((k) => k.project));
30664
32583
  lines.push("Kept in the session journal", " " + "Journal".padEnd(LABEL_W) + right("Session", STATS_KIND_W) + right("Project", STATS_KIND_W));
@@ -30718,10 +32637,10 @@ var ctxStats = Object.freeze({
30718
32637
  });
30719
32638
 
30720
32639
  // src/core/ops/host-write.ts
30721
- import { copyFileSync, existsSync as existsSync18, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
32640
+ import { copyFileSync, existsSync as existsSync18, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6 } from "node:fs";
30722
32641
  import { dirname as dirname12, join as join22 } from "node:path";
30723
32642
  function defaultWrite(file2, text) {
30724
- writeFileSync5(file2, text, "utf8");
32643
+ writeFileSync6(file2, text, "utf8");
30725
32644
  }
30726
32645
  function hostConfigPath(agent, home, env) {
30727
32646
  const own4 = OWN_MCP_ENTRY[agent];
@@ -30788,7 +32707,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
30788
32707
  }
30789
32708
 
30790
32709
  // src/core/ops/uninstall.ts
30791
- import { existsSync as existsSync19, readdirSync as readdirSync8, rmSync as rmSync6, writeFileSync as writeFileSync6 } from "node:fs";
32710
+ import { existsSync as existsSync19, readdirSync as readdirSync8, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
30792
32711
  import { join as join23 } from "node:path";
30793
32712
  function row2(area, before, after) {
30794
32713
  return { area, before, after };
@@ -30796,7 +32715,7 @@ function row2(area, before, after) {
30796
32715
  function stopServers(configDir, projectKey) {
30797
32716
  const stopped = listLiveOwners(configDir, projectKey);
30798
32717
  const dir = join23(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
30799
- for (const serverId of stopped) writeFileSync6(join23(dir, serverId + OWNER_STOP_EXT), "", "utf8");
32718
+ for (const serverId of stopped) writeFileSync7(join23(dir, serverId + OWNER_STOP_EXT), "", "utf8");
30800
32719
  return stopped.length === 0 ? { row: row2(UPGRADE_SERVER_AREA, "", UPGRADE_NOT_FOUND), stopped } : { row: row2(UPGRADE_SERVER_AREA, UPGRADE_SERVER_RUNNING, UPGRADE_SERVER_STOPPED), stopped };
30801
32720
  }
30802
32721
  function rootOrNull(adapter, env) {
@@ -31284,7 +33203,7 @@ __export(util_exports2, {
31284
33203
  hexToUint8Array: () => hexToUint8Array,
31285
33204
  hide: () => hide,
31286
33205
  installLazyProp: () => installLazyProp,
31287
- isObject: () => isObject6,
33206
+ isObject: () => isObject7,
31288
33207
  isPlainObject: () => isPlainObject4,
31289
33208
  issue: () => issue2,
31290
33209
  joinValues: () => joinValues2,
@@ -31509,7 +33428,7 @@ function slugify(input) {
31509
33428
  }
31510
33429
  var captureStackTrace2 = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
31511
33430
  };
31512
- function isObject6(data) {
33431
+ function isObject7(data) {
31513
33432
  return typeof data === "object" && data !== null && !Array.isArray(data);
31514
33433
  }
31515
33434
  var allowsEval2 = /* @__PURE__ */ cached2(() => {
@@ -31528,7 +33447,7 @@ var allowsEval2 = /* @__PURE__ */ cached2(() => {
31528
33447
  }
31529
33448
  });
31530
33449
  function isPlainObject4(o) {
31531
- if (isObject6(o) === false)
33450
+ if (isObject7(o) === false)
31532
33451
  return false;
31533
33452
  const ctor = o.constructor;
31534
33453
  if (ctor === void 0)
@@ -31536,7 +33455,7 @@ function isPlainObject4(o) {
31536
33455
  if (typeof ctor !== "function")
31537
33456
  return true;
31538
33457
  const prot = ctor.prototype;
31539
- if (isObject6(prot) === false)
33458
+ if (isObject7(prot) === false)
31540
33459
  return false;
31541
33460
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
31542
33461
  return false;
@@ -33728,7 +35647,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33728
35647
  }
33729
35648
  return propValues;
33730
35649
  });
33731
- const isObject8 = isObject6;
35650
+ const isObject9 = isObject7;
33732
35651
  const catchall = def.catchall;
33733
35652
  let value;
33734
35653
  const memo5 = globalConfig2.memoizer;
@@ -33736,7 +35655,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
33736
35655
  inst._zod.parse = (payload, ctx) => {
33737
35656
  value ?? (value = _normalized.value);
33738
35657
  const input = payload.value;
33739
- if (!isObject8(input)) {
35658
+ if (!isObject9(input)) {
33740
35659
  payload.issues.push({
33741
35660
  expected: "object",
33742
35661
  code: "invalid_type",
@@ -33872,7 +35791,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33872
35791
  return doc.compile();
33873
35792
  };
33874
35793
  let fastpass;
33875
- const isObject8 = isObject6;
35794
+ const isObject9 = isObject7;
33876
35795
  const jit = !globalConfig2.jitless;
33877
35796
  const allowsEval4 = allowsEval2;
33878
35797
  const fastEnabled = jit && allowsEval4.value;
@@ -33881,7 +35800,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def) =
33881
35800
  inst._zod.parse = (payload, ctx) => {
33882
35801
  value ?? (value = _normalized.value);
33883
35802
  const input = payload.value;
33884
- if (!isObject8(input)) {
35803
+ if (!isObject9(input)) {
33885
35804
  payload.issues.push({
33886
35805
  expected: "object",
33887
35806
  code: "invalid_type",
@@ -34019,7 +35938,7 @@ var $ZodDiscriminatedUnion2 = /* @__PURE__ */ $constructor2("$ZodDiscriminatedUn
34019
35938
  const disc = cached2(() => discriminatorMap(def));
34020
35939
  inst._zod.parse = (payload, ctx) => {
34021
35940
  const input = payload.value;
34022
- if (!isObject6(input)) {
35941
+ if (!isObject7(input)) {
34023
35942
  payload.issues.push({
34024
35943
  code: "invalid_type",
34025
35944
  expected: "object",
@@ -34659,7 +36578,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
34659
36578
  var NONE3 = 0;
34660
36579
  var ASSUMED = 1;
34661
36580
  var PROVEN = 2;
34662
- function isRecursive(inst, stack2, resolve9) {
36581
+ function isRecursive(inst, stack2, resolve10) {
34663
36582
  const cached4 = recursive.get(inst);
34664
36583
  if (cached4 !== void 0)
34665
36584
  return cached4 ? PROVEN : NONE3;
@@ -34669,7 +36588,7 @@ function isRecursive(inst, stack2, resolve9) {
34669
36588
  let result = NONE3;
34670
36589
  const check2 = (child) => {
34671
36590
  if (result !== PROVEN && child?._zod) {
34672
- const answer3 = isRecursive(child, stack2, resolve9);
36591
+ const answer3 = isRecursive(child, stack2, resolve10);
34673
36592
  if (answer3 > result)
34674
36593
  result = answer3;
34675
36594
  }
@@ -34680,7 +36599,7 @@ function isRecursive(inst, stack2, resolve9) {
34680
36599
  const desc = Object.getOwnPropertyDescriptor(sh, key);
34681
36600
  if (spread && !desc.enumerable)
34682
36601
  continue;
34683
- const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve9) : NONE3;
36602
+ const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve10) : NONE3;
34684
36603
  if (child > answer3)
34685
36604
  answer3 = child;
34686
36605
  }
@@ -34744,7 +36663,7 @@ function isRecursive(inst, stack2, resolve9) {
34744
36663
  break;
34745
36664
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
34746
36665
  case "lazy": {
34747
- const inner = def._cachedInner ?? (resolve9 ? inst._zod.innerType : void 0);
36666
+ const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
34748
36667
  merge5(inner ? isRecursive(inner, stack2, false) : ASSUMED);
34749
36668
  break;
34750
36669
  }
@@ -38865,7 +40784,7 @@ __export(util_exports3, {
38865
40784
  hexToUint8Array: () => hexToUint8Array2,
38866
40785
  hide: () => hide2,
38867
40786
  installLazyProp: () => installLazyProp2,
38868
- isObject: () => isObject7,
40787
+ isObject: () => isObject8,
38869
40788
  isPlainObject: () => isPlainObject5,
38870
40789
  issue: () => issue3,
38871
40790
  joinValues: () => joinValues3,
@@ -39090,7 +41009,7 @@ function slugify2(input) {
39090
41009
  }
39091
41010
  var captureStackTrace3 = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
39092
41011
  };
39093
- function isObject7(data) {
41012
+ function isObject8(data) {
39094
41013
  return typeof data === "object" && data !== null && !Array.isArray(data);
39095
41014
  }
39096
41015
  var allowsEval3 = /* @__PURE__ */ cached3(() => {
@@ -39109,7 +41028,7 @@ var allowsEval3 = /* @__PURE__ */ cached3(() => {
39109
41028
  }
39110
41029
  });
39111
41030
  function isPlainObject5(o) {
39112
- if (isObject7(o) === false)
41031
+ if (isObject8(o) === false)
39113
41032
  return false;
39114
41033
  const ctor = o.constructor;
39115
41034
  if (ctor === void 0)
@@ -39117,7 +41036,7 @@ function isPlainObject5(o) {
39117
41036
  if (typeof ctor !== "function")
39118
41037
  return true;
39119
41038
  const prot = ctor.prototype;
39120
- if (isObject7(prot) === false)
41039
+ if (isObject8(prot) === false)
39121
41040
  return false;
39122
41041
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
39123
41042
  return false;
@@ -41257,7 +43176,7 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
41257
43176
  }
41258
43177
  return propValues;
41259
43178
  });
41260
- const isObject8 = isObject7;
43179
+ const isObject9 = isObject8;
41261
43180
  const catchall = def.catchall;
41262
43181
  let value;
41263
43182
  const memo5 = globalConfig3.memoizer;
@@ -41265,7 +43184,7 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
41265
43184
  inst._zod.parse = (payload, ctx) => {
41266
43185
  value ?? (value = _normalized.value);
41267
43186
  const input = payload.value;
41268
- if (!isObject8(input)) {
43187
+ if (!isObject9(input)) {
41269
43188
  payload.issues.push({
41270
43189
  expected: "object",
41271
43190
  code: "invalid_type",
@@ -41401,7 +43320,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
41401
43320
  return doc.compile();
41402
43321
  };
41403
43322
  let fastpass;
41404
- const isObject8 = isObject7;
43323
+ const isObject9 = isObject8;
41405
43324
  const jit = !globalConfig3.jitless;
41406
43325
  const allowsEval4 = allowsEval3;
41407
43326
  const fastEnabled = jit && allowsEval4.value;
@@ -41410,7 +43329,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor3("$ZodObjectJIT", (inst, def)
41410
43329
  inst._zod.parse = (payload, ctx) => {
41411
43330
  value ?? (value = _normalized.value);
41412
43331
  const input = payload.value;
41413
- if (!isObject8(input)) {
43332
+ if (!isObject9(input)) {
41414
43333
  payload.issues.push({
41415
43334
  expected: "object",
41416
43335
  code: "invalid_type",
@@ -41548,7 +43467,7 @@ var $ZodDiscriminatedUnion3 = /* @__PURE__ */ $constructor3("$ZodDiscriminatedUn
41548
43467
  const disc = cached3(() => discriminatorMap2(def));
41549
43468
  inst._zod.parse = (payload, ctx) => {
41550
43469
  const input = payload.value;
41551
- if (!isObject7(input)) {
43470
+ if (!isObject8(input)) {
41552
43471
  payload.issues.push({
41553
43472
  code: "invalid_type",
41554
43473
  expected: "object",
@@ -42188,7 +44107,7 @@ var recursive2 = /* @__PURE__ */ new WeakMap();
42188
44107
  var NONE4 = 0;
42189
44108
  var ASSUMED2 = 1;
42190
44109
  var PROVEN2 = 2;
42191
- function isRecursive2(inst, stack2, resolve9) {
44110
+ function isRecursive2(inst, stack2, resolve10) {
42192
44111
  const cached4 = recursive2.get(inst);
42193
44112
  if (cached4 !== void 0)
42194
44113
  return cached4 ? PROVEN2 : NONE4;
@@ -42198,7 +44117,7 @@ function isRecursive2(inst, stack2, resolve9) {
42198
44117
  let result = NONE4;
42199
44118
  const check2 = (child) => {
42200
44119
  if (result !== PROVEN2 && child?._zod) {
42201
- const answer3 = isRecursive2(child, stack2, resolve9);
44120
+ const answer3 = isRecursive2(child, stack2, resolve10);
42202
44121
  if (answer3 > result)
42203
44122
  result = answer3;
42204
44123
  }
@@ -42209,7 +44128,7 @@ function isRecursive2(inst, stack2, resolve9) {
42209
44128
  const desc = Object.getOwnPropertyDescriptor(sh, key);
42210
44129
  if (spread && !desc.enumerable)
42211
44130
  continue;
42212
- const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve9) : NONE4;
44131
+ const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve10) : NONE4;
42213
44132
  if (child > answer3)
42214
44133
  answer3 = child;
42215
44134
  }
@@ -42273,7 +44192,7 @@ function isRecursive2(inst, stack2, resolve9) {
42273
44192
  break;
42274
44193
  // `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
42275
44194
  case "lazy": {
42276
- const inner = def._cachedInner ?? (resolve9 ? inst._zod.innerType : void 0);
44195
+ const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
42277
44196
  merge5(inner ? isRecursive2(inner, stack2, false) : ASSUMED2);
42278
44197
  break;
42279
44198
  }
@@ -48877,14 +50796,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
48877
50796
  return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
48878
50797
  }
48879
50798
  function sleep(ms, signal) {
48880
- return new Promise((resolve9, reject) => {
50799
+ return new Promise((resolve10, reject) => {
48881
50800
  if (signal?.aborted) {
48882
50801
  reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
48883
50802
  return;
48884
50803
  }
48885
50804
  const timer = setTimeout(() => {
48886
50805
  signal?.removeEventListener("abort", onAbort);
48887
- resolve9();
50806
+ resolve10();
48888
50807
  }, ms);
48889
50808
  const onAbort = () => {
48890
50809
  clearTimeout(timer);
@@ -49683,7 +51602,7 @@ var Protocol = class {
49683
51602
  const flowStartedAt = Date.now();
49684
51603
  let onAbort;
49685
51604
  let cleanupMessageId;
49686
- return new Promise((resolve9, reject) => {
51605
+ return new Promise((resolve10, reject) => {
49687
51606
  const earlyReject = (error42) => {
49688
51607
  reject(error42);
49689
51608
  };
@@ -49752,7 +51671,7 @@ var Protocol = class {
49752
51671
  }
49753
51672
  if (decoded.kind === "invalid") return reject(decoded.error);
49754
51673
  if (decoded.kind === "input_required") {
49755
- if (options?.allowInputRequired === true) return resolve9(manualInputRequiredValue(decoded));
51674
+ if (options?.allowInputRequired === true) return resolve10(manualInputRequiredValue(decoded));
49756
51675
  const flow = {
49757
51676
  codec,
49758
51677
  request: request2,
@@ -49764,11 +51683,11 @@ var Protocol = class {
49764
51683
  params
49765
51684
  }, resultSchema, legOptions)
49766
51685
  };
49767
- return resolve9(this._resolveNonCompleteResult(decoded, flow));
51686
+ return resolve10(this._resolveNonCompleteResult(decoded, flow));
49768
51687
  }
49769
51688
  const result = decoded.result;
49770
51689
  validateStandardSchema(resultSchema, result).then((parseResult) => {
49771
- if (parseResult.success) resolve9(parseResult.data);
51690
+ if (parseResult.success) resolve10(parseResult.data);
49772
51691
  else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
49773
51692
  }, reject);
49774
51693
  });
@@ -52684,7 +54603,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
52684
54603
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
52685
54604
  const schOrFunc = root.refs[ref];
52686
54605
  if (schOrFunc) return schOrFunc;
52687
- let _sch = resolve9.call(this, root, ref);
54606
+ let _sch = resolve10.call(this, root, ref);
52688
54607
  if (_sch === void 0) {
52689
54608
  const schema = (_a5 = root.localRefs) === null || _a5 === void 0 ? void 0 : _a5[ref];
52690
54609
  const { schemaId } = this.opts;
@@ -52710,7 +54629,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
52710
54629
  function sameSchemaEnv(s1, s2) {
52711
54630
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
52712
54631
  }
52713
- function resolve9(root, ref) {
54632
+ function resolve10(root, ref) {
52714
54633
  let sch;
52715
54634
  while (typeof (sch = this.refs[ref]) == "string") ref = sch;
52716
54635
  return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
@@ -53160,7 +55079,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
53160
55079
  else if (typeof uri === "object") uri = parse6(serialize(uri, options), options);
53161
55080
  return uri;
53162
55081
  }
53163
- function resolve9(baseURI, relativeURI, options) {
55082
+ function resolve10(baseURI, relativeURI, options) {
53164
55083
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
53165
55084
  const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
53166
55085
  schemelessOptions.skipEscape = true;
@@ -53334,7 +55253,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
53334
55253
  const fastUri = {
53335
55254
  SCHEMES,
53336
55255
  normalize: normalize2,
53337
- resolve: resolve9,
55256
+ resolve: resolve10,
53338
55257
  resolveComponent,
53339
55258
  equal,
53340
55259
  serialize,
@@ -58799,7 +60718,7 @@ var StdioServerTransport = class {
58799
60718
  }
58800
60719
  send(message3) {
58801
60720
  if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
58802
- return new Promise((resolve9, reject) => {
60721
+ return new Promise((resolve10, reject) => {
58803
60722
  const json2 = serializeMessage(message3);
58804
60723
  let settled = false;
58805
60724
  const onError = (error42) => {
@@ -58814,14 +60733,14 @@ var StdioServerTransport = class {
58814
60733
  settled = true;
58815
60734
  this._stdout.off("error", onError);
58816
60735
  this._stdout.off("drain", onDrain);
58817
- resolve9();
60736
+ resolve10();
58818
60737
  };
58819
60738
  this._stdout.once("error", onError);
58820
60739
  if (this._stdout.write(json2)) {
58821
60740
  if (settled) return;
58822
60741
  settled = true;
58823
60742
  this._stdout.off("error", onError);
58824
- resolve9();
60743
+ resolve10();
58825
60744
  } else if (!settled) this._stdout.once("drain", onDrain);
58826
60745
  });
58827
60746
  }
@@ -58875,14 +60794,14 @@ var StdioConnectionChannel = class {
58875
60794
  */
58876
60795
  async whenRequestsAnswered(timeoutMs) {
58877
60796
  if (this._closed || this._pendingRequests.size === 0) return true;
58878
- return await new Promise((resolve9) => {
60797
+ return await new Promise((resolve10) => {
58879
60798
  const waiter = () => {
58880
60799
  clearTimeout(timer);
58881
- resolve9(true);
60800
+ resolve10(true);
58882
60801
  };
58883
60802
  const timer = setTimeout(() => {
58884
60803
  this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
58885
- resolve9(false);
60804
+ resolve10(false);
58886
60805
  }, timeoutMs);
58887
60806
  this._drainWaiters.push(waiter);
58888
60807
  });
@@ -59598,7 +61517,7 @@ async function startServer(argv, env) {
59598
61517
  }
59599
61518
  installExitGuard({ onShutdown: shutdown, isTTY: process.stdin.isTTY === true });
59600
61519
  handle = serveStdio(createServer);
59601
- await new Promise((resolve9) => process.once("exit", () => resolve9()));
61520
+ await new Promise((resolve10) => process.once("exit", () => resolve10()));
59602
61521
  }
59603
61522
  if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
59604
61523
  const [, , ...cliArgs] = process.argv;