@oxagen/cli 5.5.1-16 → 5.5.1-69

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.
Files changed (2) hide show
  1. package/oxagen.mjs +1005 -635
  2. package/package.json +1 -1
package/oxagen.mjs CHANGED
@@ -6814,16 +6814,7 @@ var init_wire = __esm({
6814
6814
  *
6815
6815
  * Optional: absent from a daemon that predates the field.
6816
6816
  */
6817
- held_sessions: external_exports.array(external_exports.string().uuid()).max(TACHO_MAX_HELD_SESSIONS).optional(),
6818
- /**
6819
- * The machine's connection revision (ADR-8897): how many workspace
6820
- * switches it has made. A switch the control plane queues for the device
6821
- * names the revision it last saw here, and the recorder refuses it once
6822
- * a later switch moved the count. Optional: absent from a daemon that
6823
- * predates the field, and from one that could not read its connection
6824
- * file.
6825
- */
6826
- connection_revision: external_exports.number().int().nonnegative().optional()
6817
+ held_sessions: external_exports.array(external_exports.string().uuid()).max(TACHO_MAX_HELD_SESSIONS).optional()
6827
6818
  }).strict();
6828
6819
  TACHO_MAX_BATCH = 200;
6829
6820
  TACHO_MAX_BODY_BYTES = 1048576;
@@ -8526,6 +8517,29 @@ function classifySimpleEffect(command2) {
8526
8517
  }
8527
8518
  return "git_commit";
8528
8519
  }
8520
+ function shellSkillLoad(line) {
8521
+ const named2 = new Set(
8522
+ [...line.matchAll(SKILL_FILE_IN_LINE)].map((match) => match[1])
8523
+ );
8524
+ if (named2.size !== 1) return void 0;
8525
+ for (const piece of splitCommandList(line)) {
8526
+ const words3 = tokenizeSimpleCommand(piece);
8527
+ if (words3 === void 0) continue;
8528
+ const start = words3.findIndex((word2) => !ASSIGNMENT.test(word2));
8529
+ if (start === -1) continue;
8530
+ const [program2, ...args] = words3.slice(start);
8531
+ const printer = posix.basename(program2 ?? "");
8532
+ if (!FILE_PRINTERS.has(printer)) continue;
8533
+ if (args.some((arg) => STDOUT_REDIRECT.test(arg))) continue;
8534
+ if (printer === "sed" && args.some((arg) => SED_IN_PLACE.test(arg)))
8535
+ continue;
8536
+ for (const arg of args) {
8537
+ const name2 = skillFileName(arg);
8538
+ if (name2 !== void 0 && named2.has(name2)) return name2;
8539
+ }
8540
+ }
8541
+ return void 0;
8542
+ }
8529
8543
  function classifyTool(toolName4, toolInput2) {
8530
8544
  const input = toolInput2 ?? {};
8531
8545
  const mcp = mcpToolName(toolName4);
@@ -8594,8 +8608,9 @@ function classifyTool(toolName4, toolInput2) {
8594
8608
  const raw = input["command"];
8595
8609
  const command2 = head(raw);
8596
8610
  const effect = typeof raw === "string" ? classifyShellEffect(raw) : void 0;
8611
+ const loadsSkill = command2 !== void 0 && shellSkillLoad(command2) !== void 0;
8597
8612
  return {
8598
- tool_source: "builtin",
8613
+ tool_source: loadsSkill ? "skill" : "builtin",
8599
8614
  effect_kind: effect ?? "command",
8600
8615
  tool_is_mutating: true,
8601
8616
  ...command2 !== void 0 ? { tool_target: command2 } : {}
@@ -8769,7 +8784,7 @@ function mcpIssueAction(tool, input) {
8769
8784
  if (ends("update_issue") || ends("issue_update")) return bystate("edited");
8770
8785
  return void 0;
8771
8786
  }
8772
- var TARGET_MAX, READ_TOOLS, SINGLE_FILE_READS, SKILL_FILE, WRITE_TOOLS, EDIT_TOOLS, NETWORK_TOOLS, READ_VERBS, WRITE_VERBS, READ_ONLY_BUILTINS, COMMAND_SEPARATORS, GIT_GLOBAL_OPTIONS_WITH_VALUE, GIT_GLOBAL_FLAGS, EFFECT_REACH, ASSIGNMENT, ARGV_SHELLS, PULL_REQUEST_URL, ISSUE_URL, WHOLE_ISSUE_URL, REPO_SEGMENT;
8787
+ var TARGET_MAX, READ_TOOLS, SINGLE_FILE_READS, SKILL_FILE, WRITE_TOOLS, EDIT_TOOLS, NETWORK_TOOLS, READ_VERBS, WRITE_VERBS, READ_ONLY_BUILTINS, COMMAND_SEPARATORS, GIT_GLOBAL_OPTIONS_WITH_VALUE, GIT_GLOBAL_FLAGS, EFFECT_REACH, ASSIGNMENT, FILE_PRINTERS, SED_IN_PLACE, STDOUT_REDIRECT, SKILL_FILE_IN_LINE, ARGV_SHELLS, PULL_REQUEST_URL, ISSUE_URL, WHOLE_ISSUE_URL, REPO_SEGMENT;
8773
8788
  var init_tools = __esm({
8774
8789
  "../../packages/tacho/src/claude-code/tools.ts"() {
8775
8790
  "use strict";
@@ -8785,7 +8800,7 @@ var init_tools = __esm({
8785
8800
  "read_file"
8786
8801
  ]);
8787
8802
  SINGLE_FILE_READS = /* @__PURE__ */ new Set(["Read", "read_file"]);
8788
- SKILL_FILE = /(?:^|\/)\.(?:claude|agents|cursor|stella)\/skills\/([^/]+)\/SKILL\.md$/;
8803
+ SKILL_FILE = /(?:^|\/)\.(?:claude|agents|codex|cursor|stella)\/skills\/([^/]+)\/SKILL\.md$/;
8789
8804
  WRITE_TOOLS = /* @__PURE__ */ new Set(["Write"]);
8790
8805
  EDIT_TOOLS = /* @__PURE__ */ new Set(["Edit", "MultiEdit", "NotebookEdit"]);
8791
8806
  NETWORK_TOOLS = /* @__PURE__ */ new Set(["WebFetch", "WebSearch"]);
@@ -8871,6 +8886,19 @@ var init_tools = __esm({
8871
8886
  "git_commit"
8872
8887
  ];
8873
8888
  ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/;
8889
+ FILE_PRINTERS = /* @__PURE__ */ new Set([
8890
+ "cat",
8891
+ "sed",
8892
+ "head",
8893
+ "tail",
8894
+ "nl",
8895
+ "less",
8896
+ "more",
8897
+ "bat"
8898
+ ]);
8899
+ SED_IN_PLACE = /^(?:-[a-zA-Z]*i|--in-place)/;
8900
+ STDOUT_REDIRECT = /^1?>/;
8901
+ SKILL_FILE_IN_LINE = /(?:^|[/\s'"])\.(?:claude|agents|codex|cursor|stella)\/skills\/([^/\s'"]+)\/SKILL\.md(?=$|[\s'";&|)])/g;
8874
8902
  ARGV_SHELLS = /* @__PURE__ */ new Set(["bash", "sh", "zsh", "dash"]);
8875
8903
  PULL_REQUEST_URL = /https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/pull\/(\d+)/;
8876
8904
  ISSUE_URL = /https:\/\/github\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/issues\/(\d+)\b/;
@@ -17921,7 +17949,8 @@ var init_replay_grade = __esm({
17921
17949
  "hooks_partial",
17922
17950
  "unobserved_tail",
17923
17951
  "chain_break",
17924
- "telemetry_gap"
17952
+ "telemetry_gap",
17953
+ "unapproved_output_schema"
17925
17954
  ];
17926
17955
  GRADE_ENFORCEMENT_TIERS = [
17927
17956
  "contained",
@@ -23867,6 +23896,101 @@ var init_recorder = __esm({
23867
23896
  }
23868
23897
  });
23869
23898
 
23899
+ // ../../packages/tacho/src/collector/agent-file.ts
23900
+ import {
23901
+ closeSync as closeSync4,
23902
+ constants as constants2,
23903
+ fstatSync,
23904
+ openSync as openSync4,
23905
+ promises as fsp,
23906
+ readFileSync as readFileSync6
23907
+ } from "node:fs";
23908
+ function processAgentFileGuard() {
23909
+ return processGuard;
23910
+ }
23911
+ function refused(path2) {
23912
+ const error2 = new Error(
23913
+ `${path2} is not a file or folder the agent owns, so it is not read`
23914
+ );
23915
+ error2.code = "ENOENT";
23916
+ return error2;
23917
+ }
23918
+ function admits(st, guard) {
23919
+ return st.isFile() && st.uid === guard.allowedOwner;
23920
+ }
23921
+ async function statAgentFile(path2, guard) {
23922
+ try {
23923
+ if (guard === void 0) return await fsp.stat(path2);
23924
+ const st = await fsp.lstat(path2);
23925
+ return admits(st, guard) ? st : void 0;
23926
+ } catch (error2) {
23927
+ if (error2.code === "ENOENT") return void 0;
23928
+ throw error2;
23929
+ }
23930
+ }
23931
+ async function openAgentFile(path2, guard) {
23932
+ if (guard === void 0) return fsp.open(path2, "r");
23933
+ let handle;
23934
+ try {
23935
+ handle = await fsp.open(path2, NO_FOLLOW);
23936
+ } catch (error2) {
23937
+ if (error2.code === "ELOOP") throw refused(path2);
23938
+ throw error2;
23939
+ }
23940
+ try {
23941
+ if (!admits(await handle.stat(), guard)) throw refused(path2);
23942
+ return handle;
23943
+ } catch (error2) {
23944
+ await handle.close();
23945
+ throw error2;
23946
+ }
23947
+ }
23948
+ async function readAgentDir(path2, guard) {
23949
+ if (guard === void 0) return fsp.readdir(path2);
23950
+ let handle;
23951
+ try {
23952
+ handle = await fsp.open(path2, NO_FOLLOW_DIR);
23953
+ } catch (error2) {
23954
+ const code = error2.code;
23955
+ if (code === "ELOOP" || code === "ENOTDIR") throw refused(path2);
23956
+ throw error2;
23957
+ }
23958
+ try {
23959
+ const st = await handle.stat();
23960
+ if (!st.isDirectory() || st.uid !== guard.allowedOwner) throw refused(path2);
23961
+ try {
23962
+ return await fsp.readdir(`/proc/self/fd/${String(handle.fd)}`);
23963
+ } catch (error2) {
23964
+ if (error2.code !== "ENOENT") throw error2;
23965
+ return await fsp.readdir(path2);
23966
+ }
23967
+ } finally {
23968
+ await handle.close();
23969
+ }
23970
+ }
23971
+ function readAgentTextOrUndefined(path2, guard = processAgentFileGuard()) {
23972
+ try {
23973
+ if (guard === void 0) return readFileSync6(path2, "utf8");
23974
+ const fd2 = openSync4(path2, NO_FOLLOW);
23975
+ try {
23976
+ if (!admits(fstatSync(fd2), guard)) return void 0;
23977
+ return readFileSync6(fd2, "utf8");
23978
+ } finally {
23979
+ closeSync4(fd2);
23980
+ }
23981
+ } catch {
23982
+ return void 0;
23983
+ }
23984
+ }
23985
+ var processGuard, NO_FOLLOW, NO_FOLLOW_DIR;
23986
+ var init_agent_file = __esm({
23987
+ "../../packages/tacho/src/collector/agent-file.ts"() {
23988
+ "use strict";
23989
+ NO_FOLLOW = constants2.O_RDONLY | (constants2.O_NOFOLLOW ?? 0);
23990
+ NO_FOLLOW_DIR = NO_FOLLOW | (constants2.O_DIRECTORY ?? 0);
23991
+ }
23992
+ });
23993
+
23870
23994
  // ../../packages/tacho/src/collector/registry.ts
23871
23995
  function contextForHarness(context, harness, customAgent) {
23872
23996
  if (customAgent !== void 0) {
@@ -24897,7 +25021,6 @@ var init_registry = __esm({
24897
25021
  });
24898
25022
 
24899
25023
  // ../../packages/tacho/src/collector/transcript-tailer.ts
24900
- import { promises as fs } from "node:fs";
24901
25024
  import { basename as basename2, join as join14 } from "node:path";
24902
25025
  function hasTranscriptNormalizer(session) {
24903
25026
  return session.harness === void 0 || TRANSCRIPT_NORMALIZED_HARNESSES.has(session.harness);
@@ -24922,7 +25045,7 @@ function isFileCursor(value) {
24922
25045
  if (!isRecord4(value)) return false;
24923
25046
  return typeof value.path === "string" && Number.isSafeInteger(value.offset) && value.offset >= 0 && isOptional(value.ino, (ino) => typeof ino === "number") && isOptional(value.head, (head3) => typeof head3 === "string") && isOptional(
24924
25047
  value.refused,
24925
- (refused2) => isRecord4(refused2) && typeof refused2.count === "number" && typeof refused2.detail === "string"
25048
+ (refused3) => isRecord4(refused3) && typeof refused3.count === "number" && typeof refused3.detail === "string"
24926
25049
  ) && isOptional(value.codex, isRecord4);
24927
25050
  }
24928
25051
  function storedCursor(value) {
@@ -24946,20 +25069,15 @@ function storedCursor(value) {
24946
25069
  subagents: stored.subagents ?? []
24947
25070
  };
24948
25071
  }
24949
- async function statIfExists(path2) {
24950
- try {
24951
- const st = await fs.stat(path2);
24952
- return { size: st.size, ino: st.ino };
24953
- } catch (error2) {
24954
- if (error2.code === "ENOENT") return void 0;
24955
- throw error2;
24956
- }
25072
+ async function statIfExists(path2, guard) {
25073
+ const st = await statAgentFile(path2, guard);
25074
+ return st === void 0 ? void 0 : { size: st.size, ino: st.ino };
24957
25075
  }
24958
25076
  function yieldTurn() {
24959
25077
  return new Promise((resolve29) => setImmediate(resolve29));
24960
25078
  }
24961
- async function readAt(path2, offset, length) {
24962
- const handle = await fs.open(path2, "r");
25079
+ async function readAt(path2, offset, length, guard) {
25080
+ const handle = await openAgentFile(path2, guard);
24963
25081
  try {
24964
25082
  const buffer = Buffer.allocUnsafe(length);
24965
25083
  let filled = 0;
@@ -24993,6 +25111,7 @@ var init_transcript_tailer = __esm({
24993
25111
  "use strict";
24994
25112
  init_hook_payload_fit();
24995
25113
  init_fs();
25114
+ init_agent_file();
24996
25115
  init_registry();
24997
25116
  DEFAULT_TAIL_BUDGET_BYTES = 4 * 1024 * 1024;
24998
25117
  MAX_TRANSCRIPT_LINE_BYTES = HOOK_READ_MAX_BYTES;
@@ -25025,8 +25144,11 @@ var init_transcript_tailer = __esm({
25025
25144
  * start: a subagent id, or `OWN_TRANSCRIPT` for the session's own.
25026
25145
  */
25027
25146
  fileResumeAt = /* @__PURE__ */ new Map();
25147
+ /** What every read of a transcript refuses; see `TranscriptTailerOptions.guard`. */
25148
+ guard;
25028
25149
  constructor(options) {
25029
25150
  this.options = options;
25151
+ this.guard = options.guard ?? processAgentFileGuard();
25030
25152
  this.budget = options.budgetBytes ?? DEFAULT_TAIL_BUDGET_BYTES;
25031
25153
  this.maxLine = options.maxLineBytes ?? MAX_TRANSCRIPT_LINE_BYTES;
25032
25154
  this.tickBudget = Math.max(
@@ -25435,7 +25557,7 @@ var init_transcript_tailer = __esm({
25435
25557
  );
25436
25558
  if (found === void 0)
25437
25559
  return cursor.finished?.[subagentId] === void 0 ? void 0 : 0;
25438
- const ino = cursor.finished?.[subagentId] === void 0 ? void 0 : (await statIfExists(found))?.ino;
25560
+ const ino = cursor.finished?.[subagentId] === void 0 ? void 0 : (await statIfExists(found, this.guard))?.ino;
25439
25561
  sub = this.takeFinished(cursor, subagentId, found, ino) ?? {
25440
25562
  path: found,
25441
25563
  offset: 0
@@ -25548,13 +25670,23 @@ var init_transcript_tailer = __esm({
25548
25670
  * project directory its transcript is in. Undefined when neither is there.
25549
25671
  */
25550
25672
  async locateSubagentTranscript(session, subagentId, path2) {
25551
- if (await statIfExists(path2) !== void 0) return path2;
25673
+ if (await statIfExists(path2, this.guard) !== void 0) return path2;
25552
25674
  if (session.harness === "codex") return void 0;
25553
25675
  const dir = session.transcriptPath === void 0 ? void 0 : subagentDirOf(session.transcriptPath);
25554
25676
  if (dir === void 0) return void 0;
25555
- const own = join14(dir, `agent-${subagentId}.jsonl`);
25556
- if (own === path2) return void 0;
25557
- return await statIfExists(own) === void 0 ? void 0 : own;
25677
+ const name2 = `agent-${subagentId}.jsonl`;
25678
+ const own = join14(dir, name2);
25679
+ if (own !== path2 && await statIfExists(own, this.guard) !== void 0)
25680
+ return own;
25681
+ const workflows = join14(dir, "workflows");
25682
+ for (const workflow of await this.listDir(workflows)) {
25683
+ const at2 = join14(workflows, workflow);
25684
+ if (!(await this.listDir(at2)).includes(name2)) continue;
25685
+ const found = join14(at2, name2);
25686
+ if (found !== path2 && await statIfExists(found, this.guard) !== void 0)
25687
+ return found;
25688
+ }
25689
+ return void 0;
25558
25690
  }
25559
25691
  /**
25560
25692
  * Start tailing a Codex subagent's rollout on a cursor of its own, fed
@@ -25659,7 +25791,7 @@ var init_transcript_tailer = __esm({
25659
25791
  */
25660
25792
  async listDir(dir) {
25661
25793
  try {
25662
- return await fs.readdir(dir);
25794
+ return await readAgentDir(dir, this.guard);
25663
25795
  } catch (error2) {
25664
25796
  const code = error2.code;
25665
25797
  if (code !== "ENOENT" && code !== "ENOTDIR")
@@ -25739,14 +25871,14 @@ var init_transcript_tailer = __esm({
25739
25871
  const pass2 = await this.feed(session, cursor, budget, sealer, subagentId);
25740
25872
  if (cursor.refused === void 0) return pass2;
25741
25873
  await sealer.run(() => {
25742
- const refused2 = cursor.refused;
25743
- if (refused2 === void 0 || !sealer.current()) return;
25874
+ const refused3 = cursor.refused;
25875
+ if (refused3 === void 0 || !sealer.current()) return;
25744
25876
  this.sealGap(
25745
25877
  session,
25746
25878
  "transcript_line_refused",
25747
- refused2.detail,
25879
+ refused3.detail,
25748
25880
  subagentId,
25749
- refused2.count
25881
+ refused3.count
25750
25882
  );
25751
25883
  delete cursor.refused;
25752
25884
  this.dirty = true;
@@ -25769,7 +25901,7 @@ var init_transcript_tailer = __esm({
25769
25901
  let bytes = 0;
25770
25902
  let st;
25771
25903
  try {
25772
- st = await statIfExists(cursor.path);
25904
+ st = await statIfExists(cursor.path, this.guard);
25773
25905
  } catch (error2) {
25774
25906
  this.options.log?.(
25775
25907
  `transcript ${cursor.path} unreadable: ${describe2(error2)}`
@@ -25786,7 +25918,12 @@ var init_transcript_tailer = __esm({
25786
25918
  if (!replaced && !idle && at2 > 0 && cursor.head !== void 0) {
25787
25919
  const expected = Buffer.from(cursor.head, "base64");
25788
25920
  try {
25789
- const actual = await readAt(cursor.path, 0, expected.length);
25921
+ const actual = await readAt(
25922
+ cursor.path,
25923
+ 0,
25924
+ expected.length,
25925
+ this.guard
25926
+ );
25790
25927
  replaced = !actual.equals(expected);
25791
25928
  } catch {
25792
25929
  }
@@ -25818,7 +25955,7 @@ var init_transcript_tailer = __esm({
25818
25955
  const want = Math.min(remaining, size - from, this.budget);
25819
25956
  let chunk;
25820
25957
  try {
25821
- chunk = await readAt(cursor.path, from, want);
25958
+ chunk = await readAt(cursor.path, from, want, this.guard);
25822
25959
  } catch (error2) {
25823
25960
  this.options.log?.(
25824
25961
  `transcript ${cursor.path} read failed at ${from}: ${describe2(error2)}`
@@ -25834,7 +25971,7 @@ var init_transcript_tailer = __esm({
25834
25971
  if (skipTo - from <= this.maxLine) {
25835
25972
  let whole;
25836
25973
  try {
25837
- whole = await readAt(cursor.path, from, skipTo - from);
25974
+ whole = await readAt(cursor.path, from, skipTo - from, this.guard);
25838
25975
  } catch (error2) {
25839
25976
  this.options.log?.(
25840
25977
  `transcript ${cursor.path} read failed at ${from}: ${describe2(error2)}`
@@ -25924,7 +26061,7 @@ var init_transcript_tailer = __esm({
25924
26061
  const known = cursor.head === void 0 ? 0 : Buffer.from(cursor.head, "base64").length;
25925
26062
  if (statApplied && headLength > known) {
25926
26063
  try {
25927
- const head3 = await readAt(cursor.path, 0, headLength);
26064
+ const head3 = await readAt(cursor.path, 0, headLength, this.guard);
25928
26065
  await sealer.run(() => {
25929
26066
  if (!sealer.current() || cursor.offset < headLength) return;
25930
26067
  cursor.head = head3.toString("base64");
@@ -25945,7 +26082,12 @@ var init_transcript_tailer = __esm({
25945
26082
  async findLineEnd(path2, from, size) {
25946
26083
  let at2 = from;
25947
26084
  while (at2 < size) {
25948
- const chunk = await readAt(path2, at2, Math.min(this.budget, size - at2));
26085
+ const chunk = await readAt(
26086
+ path2,
26087
+ at2,
26088
+ Math.min(this.budget, size - at2),
26089
+ this.guard
26090
+ );
25949
26091
  if (chunk.length === 0) return void 0;
25950
26092
  const nl = chunk.indexOf(10);
25951
26093
  if (nl >= 0) return at2 + nl + 1;
@@ -25958,7 +26100,7 @@ var init_transcript_tailer = __esm({
25958
26100
  });
25959
26101
 
25960
26102
  // ../../packages/tacho/src/collector/backfill.ts
25961
- import { promises as fs2 } from "node:fs";
26103
+ import { promises as fs } from "node:fs";
25962
26104
  import { basename as basename3, dirname as dirname10, join as join15 } from "node:path";
25963
26105
  function shown(value) {
25964
26106
  return JSON.stringify(value.length > 64 ? `${value.slice(0, 64)}\u2026` : value);
@@ -26007,12 +26149,12 @@ function parseBackfillRequest(value) {
26007
26149
  return { request: request4 };
26008
26150
  }
26009
26151
  async function writeSensitiveFile(path2, text6) {
26010
- await fs2.mkdir(dirname10(path2), { recursive: true, mode: 448 });
26152
+ await fs.mkdir(dirname10(path2), { recursive: true, mode: 448 });
26011
26153
  const tmp = join15(
26012
26154
  dirname10(path2),
26013
26155
  `.${basename3(path2)}.${process.pid}.${Date.now()}.tmp`
26014
26156
  );
26015
- const handle = await fs2.open(tmp, "w", 384);
26157
+ const handle = await fs.open(tmp, "w", 384);
26016
26158
  try {
26017
26159
  try {
26018
26160
  await handle.writeFile(text6, "utf8");
@@ -26020,10 +26162,10 @@ async function writeSensitiveFile(path2, text6) {
26020
26162
  } finally {
26021
26163
  await handle.close();
26022
26164
  }
26023
- await fs2.chmod(tmp, 384);
26024
- await fs2.rename(tmp, path2);
26165
+ await fs.chmod(tmp, 384);
26166
+ await fs.rename(tmp, path2);
26025
26167
  } catch (error2) {
26026
- await fs2.unlink(tmp).catch(() => void 0);
26168
+ await fs.unlink(tmp).catch(() => void 0);
26027
26169
  throw error2;
26028
26170
  }
26029
26171
  }
@@ -26205,7 +26347,7 @@ async function discover(request4, deps, unreadable) {
26205
26347
  if (!included) continue;
26206
26348
  let stat7;
26207
26349
  try {
26208
- stat7 = await fs2.stat(path2);
26350
+ stat7 = await fs.stat(path2);
26209
26351
  } catch (error2) {
26210
26352
  unreadable(path2, error2);
26211
26353
  continue;
@@ -26243,7 +26385,7 @@ function isAbsent(error2) {
26243
26385
  }
26244
26386
  async function listDir(dir, unreadable) {
26245
26387
  try {
26246
- return await fs2.readdir(dir);
26388
+ return await fs.readdir(dir);
26247
26389
  } catch (error2) {
26248
26390
  if (isAbsent(error2)) return [];
26249
26391
  if (unreadable === void 0) throw error2;
@@ -26253,7 +26395,7 @@ async function listDir(dir, unreadable) {
26253
26395
  }
26254
26396
  async function isDirectory(path2, unreadable) {
26255
26397
  try {
26256
- return (await fs2.stat(path2)).isDirectory();
26398
+ return (await fs.stat(path2)).isDirectory();
26257
26399
  } catch (error2) {
26258
26400
  if (!isAbsent(error2)) unreadable(path2, error2);
26259
26401
  return false;
@@ -26306,7 +26448,7 @@ async function countSubagents(sessionDir) {
26306
26448
  async function readMeta(path2, unreadable) {
26307
26449
  let parsed2;
26308
26450
  try {
26309
- parsed2 = JSON.parse(await fs2.readFile(path2, "utf8"));
26451
+ parsed2 = JSON.parse(await fs.readFile(path2, "utf8"));
26310
26452
  } catch (error2) {
26311
26453
  if (!isAbsent(error2)) unreadable(path2, error2);
26312
26454
  return {};
@@ -26338,7 +26480,7 @@ async function firstRecordMs(path2) {
26338
26480
  async function readHead(path2, length) {
26339
26481
  let handle;
26340
26482
  try {
26341
- handle = await fs2.open(path2, "r");
26483
+ handle = await fs.open(path2, "r");
26342
26484
  const buffer = Buffer.alloc(length);
26343
26485
  const { bytesRead } = await handle.read(buffer, 0, length, 0);
26344
26486
  return buffer.subarray(0, bytesRead);
@@ -26591,7 +26733,7 @@ async function resultAgentIds(path2) {
26591
26733
  return out;
26592
26734
  }
26593
26735
  async function readSlices(path2, sliceBytes, onSlice) {
26594
- const handle = await fs2.open(path2, "r");
26736
+ const handle = await fs.open(path2, "r");
26595
26737
  try {
26596
26738
  const buffer = Buffer.alloc(READ_CHUNK_BYTES2);
26597
26739
  let position = 0;
@@ -26746,7 +26888,7 @@ var init_backfill2 = __esm({
26746
26888
  async prune() {
26747
26889
  for (const [path2, entry2] of [...this.entries]) {
26748
26890
  try {
26749
- await fs2.stat(path2);
26891
+ await fs.stat(path2);
26750
26892
  } catch (error2) {
26751
26893
  if (errorCodeOf(error2) !== "ENOENT") continue;
26752
26894
  this.entries.delete(path2);
@@ -27759,7 +27901,7 @@ var init_model_failure = __esm({
27759
27901
 
27760
27902
  // ../../packages/tacho/src/host/run-token.ts
27761
27903
  import { createHmac, randomBytes as randomBytes4, timingSafeEqual } from "node:crypto";
27762
- import { readFileSync as readFileSync6 } from "node:fs";
27904
+ import { readFileSync as readFileSync7 } from "node:fs";
27763
27905
  function keyFromBytes(bytes) {
27764
27906
  if (bytes.length !== KEY_BYTES)
27765
27907
  throw new Error(
@@ -27780,7 +27922,7 @@ function runTokenKeyFromHex(hex) {
27780
27922
  function loadOrCreateRunTokenKey(path2) {
27781
27923
  try {
27782
27924
  return {
27783
- key: runTokenKeyFromHex(readFileSync6(path2, "utf8")),
27925
+ key: runTokenKeyFromHex(readFileSync7(path2, "utf8")),
27784
27926
  created: false
27785
27927
  };
27786
27928
  } catch (error2) {
@@ -27801,7 +27943,7 @@ function readRunTokenKey(path2) {
27801
27943
  if (seen?.version === version3) return seen.key;
27802
27944
  let key;
27803
27945
  try {
27804
- key = runTokenKeyFromHex(readFileSync6(path2, "utf8"));
27946
+ key = runTokenKeyFromHex(readFileSync7(path2, "utf8"));
27805
27947
  } catch (error2) {
27806
27948
  if (error2.code === "ENOENT") return void 0;
27807
27949
  throw error2;
@@ -27937,11 +28079,11 @@ var init_run_token = __esm({
27937
28079
  // ../../packages/tacho/src/host/credential-store.ts
27938
28080
  import { createCipheriv, createDecipheriv, randomBytes as randomBytes5 } from "node:crypto";
27939
28081
  import {
27940
- closeSync as closeSync4,
28082
+ closeSync as closeSync5,
27941
28083
  existsSync as existsSync7,
27942
28084
  fsyncSync as fsyncSync3,
27943
- openSync as openSync4,
27944
- readFileSync as readFileSync7,
28085
+ openSync as openSync5,
28086
+ readFileSync as readFileSync8,
27945
28087
  statSync as statSync3,
27946
28088
  unlinkSync as unlinkSync4,
27947
28089
  writeSync as writeSync3
@@ -28016,7 +28158,7 @@ function heldBackAt(failure4, now) {
28016
28158
  }
28017
28159
  function readKey(path2) {
28018
28160
  try {
28019
- const hex = readFileSync7(path2, "utf8").trim();
28161
+ const hex = readFileSync8(path2, "utf8").trim();
28020
28162
  if (!/^[0-9a-f]{64}$/i.test(hex))
28021
28163
  throw new Error(`${path2} does not hold a 32-byte key`);
28022
28164
  return Buffer.from(hex, "hex");
@@ -28045,13 +28187,13 @@ function overwriteInPlace(path2) {
28045
28187
  let fd2;
28046
28188
  try {
28047
28189
  const size = statSync3(path2).size;
28048
- fd2 = openSync4(path2, "r+");
28190
+ fd2 = openSync5(path2, "r+");
28049
28191
  writeSync3(fd2, randomBytes5(Math.max(size, KEY_BYTES2 * 2)), 0, void 0, 0);
28050
28192
  fsyncSync3(fd2);
28051
28193
  } catch (error2) {
28052
28194
  if (error2.code !== "ENOENT") throw error2;
28053
28195
  } finally {
28054
- if (fd2 !== void 0) closeSync4(fd2);
28196
+ if (fd2 !== void 0) closeSync5(fd2);
28055
28197
  }
28056
28198
  }
28057
28199
  function seal(key, secret, aad) {
@@ -28156,7 +28298,7 @@ function openCredentialStore(paths) {
28156
28298
  if (entriesSeen?.version === version3) return entriesSeen.entries;
28157
28299
  let text6;
28158
28300
  try {
28159
- text6 = readFileSync7(paths.file, "utf8");
28301
+ text6 = readFileSync8(paths.file, "utf8");
28160
28302
  } catch (error2) {
28161
28303
  if (error2.code === "ENOENT") return [];
28162
28304
  throw error2;
@@ -28558,7 +28700,7 @@ var init_credential_store = __esm({
28558
28700
 
28559
28701
  // ../../packages/tacho/src/host/claude-setup-token.ts
28560
28702
  import { spawn } from "node:child_process";
28561
- import { accessSync as accessSync2, constants as constants2 } from "node:fs";
28703
+ import { accessSync as accessSync2, constants as constants3 } from "node:fs";
28562
28704
  import { delimiter, join as join17 } from "node:path";
28563
28705
  function isSubscriptionToken(value) {
28564
28706
  return TOKEN.test(value.trim());
@@ -28601,7 +28743,7 @@ function findHarnessBinary(name2, env, home) {
28601
28743
  ].map((dir) => join17(dir, file));
28602
28744
  for (const path2 of candidates) {
28603
28745
  try {
28604
- accessSync2(path2, constants2.X_OK);
28746
+ accessSync2(path2, constants3.X_OK);
28605
28747
  return path2;
28606
28748
  } catch {
28607
28749
  }
@@ -28844,7 +28986,7 @@ var init_model_base_url_toml = __esm({
28844
28986
  });
28845
28987
 
28846
28988
  // ../../packages/tacho/src/host/model-base-url.ts
28847
- import { chmodSync as chmodSync3, existsSync as existsSync8, readFileSync as readFileSync8, unlinkSync as unlinkSync5 } from "node:fs";
28989
+ import { chmodSync as chmodSync3, existsSync as existsSync8, readFileSync as readFileSync9, unlinkSync as unlinkSync5 } from "node:fs";
28848
28990
  import { basename as basename4, dirname as dirname12, join as join18 } from "node:path";
28849
28991
  function claudeToolSearchEnabled(value) {
28850
28992
  return typeof value === "string" && /^(true|auto(:\d+)?)$/i.test(value);
@@ -29222,7 +29364,7 @@ function describe3(harness, options, { changed, text: text6, sidecar, unreadable
29222
29364
  }
29223
29365
  function readBytesIfExists(path2) {
29224
29366
  try {
29225
- return readFileSync8(path2);
29367
+ return readFileSync9(path2);
29226
29368
  } catch (error2) {
29227
29369
  if (error2.code === "ENOENT") return void 0;
29228
29370
  throw error2;
@@ -31367,7 +31509,7 @@ import { join as join20 } from "node:path";
31367
31509
  import {
31368
31510
  existsSync as existsSync11,
31369
31511
  readdirSync as readdirSync7,
31370
- readFileSync as readFileSync9,
31512
+ readFileSync as readFileSync10,
31371
31513
  rmdirSync as rmdirSync4,
31372
31514
  unlinkSync as unlinkSync7
31373
31515
  } from "node:fs";
@@ -31468,7 +31610,7 @@ function launchdManager(options) {
31468
31610
  unitPath,
31469
31611
  install: (spec) => {
31470
31612
  const plist = renderLaunchdPlist(spec);
31471
- const unchanged = existsSync11(unitPath) && readFileSync9(unitPath, "utf8") === plist;
31613
+ const unchanged = existsSync11(unitPath) && readFileSync10(unitPath, "utf8") === plist;
31472
31614
  if (unchanged && loaded()) {
31473
31615
  const kicked = options.exec("launchctl", ["kickstart", "-k", target]);
31474
31616
  if (kicked.status === 0 && loaded()) return;
@@ -31518,7 +31660,7 @@ function noUserManager(result2) {
31518
31660
  function stopByPidFile(options) {
31519
31661
  const { pidPath } = options;
31520
31662
  if (pidPath === void 0 || !existsSync11(pidPath)) return;
31521
- const record2 = parseDaemonPid(readFileSync9(pidPath, "utf8"));
31663
+ const record2 = parseDaemonPid(readFileSync10(pidPath, "utf8"));
31522
31664
  if (record2 === void 0) return;
31523
31665
  const sleep2 = options.sleep ?? blockingSleep;
31524
31666
  const processes = options.processes ?? {
@@ -31569,7 +31711,7 @@ function systemdManager(options) {
31569
31711
  throw new Error(
31570
31712
  `no systemd user manager is available (${probe.stderr.trim().split("\n")[0] ?? ""}). Turn on systemd for your login (on WSL, set \`systemd=true\` under \`[boot]\` in /etc/wsl.conf and run \`wsl --shutdown\`), or run \`oxagen daemon\` yourself`
31571
31713
  );
31572
- const previous = existsSync11(unitPath) ? readFileSync9(unitPath, "utf8") : void 0;
31714
+ const previous = existsSync11(unitPath) ? readFileSync10(unitPath, "utf8") : void 0;
31573
31715
  const createsWants = previous === void 0 ? !existsSync11(wants) : unitCreatedWants(previous);
31574
31716
  ensureDir(dir, 493);
31575
31717
  writeSensitiveFileAtomic(
@@ -31628,7 +31770,7 @@ function systemdManager(options) {
31628
31770
  `systemctl could not remove tachod.service: ${disabled.stderr.trim() || active2.stderr.trim() || active2.stdout.trim() || "service state is unknown"}. Run \`systemctl --user disable --now tachod.service\`, then try again`
31629
31771
  );
31630
31772
  }
31631
- const unit4 = existsSync11(unitPath) ? readFileSync9(unitPath, "utf8") : void 0;
31773
+ const unit4 = existsSync11(unitPath) ? readFileSync10(unitPath, "utf8") : void 0;
31632
31774
  if (unit4 !== void 0) unlinkSync7(unitPath);
31633
31775
  try {
31634
31776
  const reload = options.exec("systemctl", ["--user", "daemon-reload"]);
@@ -31714,7 +31856,7 @@ function schtasksManager(options) {
31714
31856
  const pidPath = options.pidPath ?? join20(launcher, "..", "tachod.pid");
31715
31857
  const liveRecord = () => {
31716
31858
  if (!existsSync11(pidPath)) return void 0;
31717
- const record2 = parseDaemonPid(readFileSync9(pidPath, "utf8"));
31859
+ const record2 = parseDaemonPid(readFileSync10(pidPath, "utf8"));
31718
31860
  if (record2 === void 0) return void 0;
31719
31861
  const { pid } = record2;
31720
31862
  const query = options.exec("tasklist", [
@@ -31885,15 +32027,15 @@ var init_service = __esm({
31885
32027
  });
31886
32028
 
31887
32029
  // ../../packages/tacho/src/version.ts
31888
- import { readFileSync as readFileSync10 } from "node:fs";
32030
+ import { readFileSync as readFileSync11 } from "node:fs";
31889
32031
  import { dirname as dirname14, resolve as resolve3 } from "node:path";
31890
32032
  import { fileURLToPath } from "node:url";
31891
32033
  function readVersion() {
31892
- if (true) return "5.5.1-16";
32034
+ if (true) return "5.5.1-69";
31893
32035
  try {
31894
32036
  const here = dirname14(fileURLToPath(import.meta.url));
31895
32037
  const pkg = JSON.parse(
31896
- readFileSync10(resolve3(here, "..", "package.json"), "utf8")
32038
+ readFileSync11(resolve3(here, "..", "package.json"), "utf8")
31897
32039
  );
31898
32040
  return pkg.version ?? "0.0.0";
31899
32041
  } catch {
@@ -33071,7 +33213,7 @@ import {
33071
33213
  sign as sign3,
33072
33214
  verify as verify3
33073
33215
  } from "node:crypto";
33074
- import { readFileSync as readFileSync11 } from "node:fs";
33216
+ import { readFileSync as readFileSync12 } from "node:fs";
33075
33217
  function encodePublicKey(privateKey) {
33076
33218
  const spki = createPublicKey3(privateKey).export({
33077
33219
  type: "spki",
@@ -33109,7 +33251,7 @@ function deviceKeyPem(key) {
33109
33251
  function loadOrCreateDeviceKey(path2) {
33110
33252
  try {
33111
33253
  return {
33112
- key: deviceKeyFromPem(readFileSync11(path2, "utf8")),
33254
+ key: deviceKeyFromPem(readFileSync12(path2, "utf8")),
33113
33255
  created: false
33114
33256
  };
33115
33257
  } catch (error2) {
@@ -33532,9 +33674,9 @@ var init_control_client = __esm({
33532
33674
  // ../../packages/tacho/src/host/wal-index.ts
33533
33675
  import {
33534
33676
  appendFileSync,
33535
- closeSync as closeSync5,
33677
+ closeSync as closeSync6,
33536
33678
  existsSync as existsSync13,
33537
- openSync as openSync5,
33679
+ openSync as openSync6,
33538
33680
  readSync as readSync2,
33539
33681
  statSync as statSync5,
33540
33682
  unlinkSync as unlinkSync8
@@ -33556,7 +33698,7 @@ function parseStoredBody(text6) {
33556
33698
  }
33557
33699
  function readTailLine(path2, size = statSync5(path2).size, window2 = SCAN_CHUNK_BYTES) {
33558
33700
  if (size === 0) return void 0;
33559
- const fd2 = openSync5(path2, "r");
33701
+ const fd2 = openSync6(path2, "r");
33560
33702
  try {
33561
33703
  let end = size;
33562
33704
  let terminated = false;
@@ -33604,12 +33746,12 @@ function readTailLine(path2, size = statSync5(path2).size, window2 = SCAN_CHUNK_
33604
33746
  windowSize *= 2;
33605
33747
  }
33606
33748
  } finally {
33607
- closeSync5(fd2);
33749
+ closeSync6(fd2);
33608
33750
  }
33609
33751
  }
33610
33752
  function* readLinesBackward(path2, size = statSync5(path2).size, window2 = SCAN_CHUNK_BYTES) {
33611
33753
  if (size === 0) return;
33612
- const fd2 = openSync5(path2, "r");
33754
+ const fd2 = openSync6(path2, "r");
33613
33755
  try {
33614
33756
  let buffer = Buffer.alloc(0);
33615
33757
  let start = size;
@@ -33671,11 +33813,11 @@ function* readLinesBackward(path2, size = statSync5(path2).size, window2 = SCAN_
33671
33813
  end = offset;
33672
33814
  }
33673
33815
  } finally {
33674
- closeSync5(fd2);
33816
+ closeSync6(fd2);
33675
33817
  }
33676
33818
  }
33677
33819
  function* readLinesFrom(path2, from = 0, chunkBytes = SCAN_CHUNK_BYTES) {
33678
- const fd2 = openSync5(path2, "r");
33820
+ const fd2 = openSync6(path2, "r");
33679
33821
  try {
33680
33822
  const splitter = new LineSplitter(from);
33681
33823
  let position = from;
@@ -33689,7 +33831,7 @@ function* readLinesFrom(path2, from = 0, chunkBytes = SCAN_CHUNK_BYTES) {
33689
33831
  const rest = splitter.rest();
33690
33832
  if (rest !== void 0) yield rest;
33691
33833
  } finally {
33692
- closeSync5(fd2);
33834
+ closeSync6(fd2);
33693
33835
  }
33694
33836
  }
33695
33837
  async function* readLinesFromAsync(path2, from = 0, to = Number.POSITIVE_INFINITY) {
@@ -34227,11 +34369,11 @@ ${list2.join("\n")}
34227
34369
  // ../../packages/tacho/src/host/wal.ts
34228
34370
  import {
34229
34371
  appendFileSync as appendFileSync3,
34230
- closeSync as closeSync6,
34372
+ closeSync as closeSync7,
34231
34373
  fdatasyncSync,
34232
- fstatSync,
34374
+ fstatSync as fstatSync2,
34233
34375
  fsyncSync as fsyncSync4,
34234
- openSync as openSync6,
34376
+ openSync as openSync7,
34235
34377
  existsSync as existsSync15,
34236
34378
  readdirSync as readdirSync9,
34237
34379
  readSync as readSync3,
@@ -34317,7 +34459,7 @@ async function copyRange(path2, out, from, to, signal) {
34317
34459
  function readRangeSync(path2, from, to) {
34318
34460
  const buffer = Buffer.alloc(Math.max(0, to - from));
34319
34461
  if (buffer.length === 0) return buffer;
34320
- const fd2 = openSync6(path2, "r");
34462
+ const fd2 = openSync7(path2, "r");
34321
34463
  try {
34322
34464
  let filled = 0;
34323
34465
  while (filled < buffer.length) {
@@ -34333,7 +34475,7 @@ function readRangeSync(path2, from, to) {
34333
34475
  }
34334
34476
  return buffer.subarray(0, filled);
34335
34477
  } finally {
34336
- closeSync6(fd2);
34478
+ closeSync7(fd2);
34337
34479
  }
34338
34480
  }
34339
34481
  var BODY_READ_SLICE, BODY_DROP_SLICE_BYTES, BODY_DROP_SCANS, BODY_PURGE_SLICE_BYTES, BODY_PURGE_SCANS, BODY_PURGE_CATCH_UPS, NEWLINE, EVENT_TAIL_WINDOW, WalRecoveryConflict, Wal;
@@ -34505,7 +34647,7 @@ var init_wal = __esm({
34505
34647
  for (const path2 of paths) {
34506
34648
  let fd2;
34507
34649
  try {
34508
- fd2 = openSync6(path2, "r+");
34650
+ fd2 = openSync7(path2, "r+");
34509
34651
  fdatasyncSync(fd2);
34510
34652
  } catch (error2) {
34511
34653
  if (fd2 === void 0 && error2.code === "ENOENT")
@@ -34513,7 +34655,7 @@ var init_wal = __esm({
34513
34655
  this.dirtyPaths.add(path2);
34514
34656
  failure4 ??= error2;
34515
34657
  } finally {
34516
- if (fd2 !== void 0) closeSync6(fd2);
34658
+ if (fd2 !== void 0) closeSync7(fd2);
34517
34659
  }
34518
34660
  }
34519
34661
  if (failure4 !== void 0) throw failure4;
@@ -34937,7 +35079,7 @@ ${lines.join("\n")}
34937
35079
  */
34938
35080
  readBodiesAt(path2, idems, index) {
34939
35081
  const found = /* @__PURE__ */ new Map();
34940
- const fd2 = openSync6(path2, "r");
35082
+ const fd2 = openSync7(path2, "r");
34941
35083
  try {
34942
35084
  for (const idem of idems) {
34943
35085
  const at2 = index.entries.get(idem);
@@ -34965,7 +35107,7 @@ ${lines.join("\n")}
34965
35107
  });
34966
35108
  }
34967
35109
  } finally {
34968
- closeSync6(fd2);
35110
+ closeSync7(fd2);
34969
35111
  }
34970
35112
  return found;
34971
35113
  }
@@ -35256,7 +35398,7 @@ ${lines.join("\n")}
35256
35398
  blankSlice(path2, found, from, idems) {
35257
35399
  let fd2;
35258
35400
  try {
35259
- fd2 = openSync6(path2, "r+");
35401
+ fd2 = openSync7(path2, "r+");
35260
35402
  } catch (error2) {
35261
35403
  if (error2.code === "ENOENT") return void 0;
35262
35404
  throw error2;
@@ -35265,7 +35407,7 @@ ${lines.join("\n")}
35265
35407
  let moved = false;
35266
35408
  let next = from;
35267
35409
  try {
35268
- const size = fstatSync(fd2).size;
35410
+ const size = fstatSync2(fd2).size;
35269
35411
  let taken = 0;
35270
35412
  while (next < found.length && taken < BODY_DROP_SLICE_BYTES) {
35271
35413
  const at2 = found[next];
@@ -35280,7 +35422,7 @@ ${lines.join("\n")}
35280
35422
  }
35281
35423
  if (blanked > 0) fdatasyncSync(fd2);
35282
35424
  } finally {
35283
- closeSync6(fd2);
35425
+ closeSync7(fd2);
35284
35426
  }
35285
35427
  return { blanked, moved, next };
35286
35428
  }
@@ -36223,10 +36365,10 @@ ${lines.join("\n")}
36223
36365
  if (!scan.keptAny && tail.toString("utf8").trim().length === 0) {
36224
36366
  unlinkSync10(path2);
36225
36367
  } else {
36226
- const fd2 = openSync6(tmp, "r+");
36368
+ const fd2 = openSync7(tmp, "r+");
36227
36369
  try {
36228
36370
  let written2 = 0;
36229
- const at2 = fstatSync(fd2).size;
36371
+ const at2 = fstatSync2(fd2).size;
36230
36372
  while (written2 < tail.length)
36231
36373
  written2 += writeSync4(
36232
36374
  fd2,
@@ -36237,7 +36379,7 @@ ${lines.join("\n")}
36237
36379
  );
36238
36380
  fdatasyncSync(fd2);
36239
36381
  } finally {
36240
- closeSync6(fd2);
36382
+ closeSync7(fd2);
36241
36383
  }
36242
36384
  renameSync3(tmp, path2);
36243
36385
  }
@@ -36309,7 +36451,7 @@ ${lines.join("\n")}
36309
36451
  const path2 = this.bodyFileFor(sessionUuid2);
36310
36452
  if (!existsSync15(path2)) return 0;
36311
36453
  const tmp = `${path2}.${randomUUID()}.tmp`;
36312
- const fd2 = openSync6(tmp, "wx", 384);
36454
+ const fd2 = openSync7(tmp, "wx", 384);
36313
36455
  let cut = 0;
36314
36456
  let kept = 0;
36315
36457
  try {
@@ -36329,7 +36471,7 @@ ${lines.join("\n")}
36329
36471
  }
36330
36472
  if (cut > 0 && kept > 0) fsyncSync4(fd2);
36331
36473
  } finally {
36332
- closeSync6(fd2);
36474
+ closeSync7(fd2);
36333
36475
  }
36334
36476
  if (cut === 0) return 0;
36335
36477
  if (kept === 0) unlinkSync10(path2);
@@ -36464,7 +36606,7 @@ ${lines.join("\n")}
36464
36606
  });
36465
36607
 
36466
36608
  // ../../packages/tacho/src/cli/github.ts
36467
- import { existsSync as existsSync16, readFileSync as readFileSync12, realpathSync } from "node:fs";
36609
+ import { existsSync as existsSync16, readFileSync as readFileSync13, realpathSync } from "node:fs";
36468
36610
  import { resolve as resolve6 } from "node:path";
36469
36611
  function git(deps, cwd, args, allowMissing = false) {
36470
36612
  const out = deps.exec("git", ["-C", cwd, ...args]);
@@ -36666,7 +36808,7 @@ function daemonReason(body2) {
36666
36808
  return body2.trim().slice(0, 200) || "no reason given";
36667
36809
  }
36668
36810
  function readCredentialInput() {
36669
- return readFileSync12(0, "utf8");
36811
+ return readFileSync13(0, "utf8");
36670
36812
  }
36671
36813
  function checkoutGone(deps, cwd) {
36672
36814
  if (!existsSync16(cwd)) return true;
@@ -38861,7 +39003,7 @@ ${problems.map((problem2) => ` ${problem2}`).join("\n")}`
38861
39003
  deps.out(
38862
39004
  ` adding ${added.join(", ")} to ${existing.agent_key}: revoking ${existing.host_enrollment_id} and enrolling again for ${harnesses.join(", ")} so the control plane's host record follows (device key, port and local token kept)`
38863
39005
  );
38864
- const refused2 = [];
39006
+ const refused3 = [];
38865
39007
  const revoked = await revokeOnControlPlane(
38866
39008
  existing,
38867
39009
  {
@@ -38869,13 +39011,13 @@ ${problems.map((problem2) => ` ${problem2}`).join("\n")}`
38869
39011
  reason: `oxagen agent enroll --harness ${harnesses.join(",")}`
38870
39012
  },
38871
39013
  deps,
38872
- refused2
39014
+ refused3
38873
39015
  );
38874
39016
  if (!revoked) {
38875
39017
  deps.err(
38876
- `Cannot add ${added.join(", ")}: ${existing.host_enrollment_id} could not be revoked (${refused2.join("; ")}), so nothing was changed; this host still reports as ${existing.agent_key} for ${existing.harnesses.join(", ")}.`
39018
+ `Cannot add ${added.join(", ")}: ${existing.host_enrollment_id} could not be revoked (${refused3.join("; ")}), so nothing was changed; this host still reports as ${existing.agent_key} for ${existing.harnesses.join(", ")}.`
38877
39019
  );
38878
- return { ok: false, warnings: [...warnings, ...refused2] };
39020
+ return { ok: false, warnings: [...warnings, ...refused3] };
38879
39021
  }
38880
39022
  writeHostFile(deps.paths.hostFile, {
38881
39023
  ...existing,
@@ -40758,7 +40900,7 @@ var init_reassign = __esm({
40758
40900
  import {
40759
40901
  lstatSync as lstatSync6,
40760
40902
  readdirSync as readdirSync11,
40761
- readFileSync as readFileSync13,
40903
+ readFileSync as readFileSync14,
40762
40904
  readlinkSync as readlinkSync3,
40763
40905
  realpathSync as realpathSync2,
40764
40906
  rmdirSync as rmdirSync6,
@@ -40819,7 +40961,7 @@ function readDesktopRecord(path2) {
40819
40961
  };
40820
40962
  let parsed2;
40821
40963
  try {
40822
- parsed2 = JSON.parse(readFileSync13(path2, "utf8"));
40964
+ parsed2 = JSON.parse(readFileSync14(path2, "utf8"));
40823
40965
  } catch (error2) {
40824
40966
  if (error2.code === "ENOENT") return none;
40825
40967
  return {
@@ -40901,7 +41043,7 @@ function errorCode(error2) {
40901
41043
  function readText2(path2) {
40902
41044
  let bytes;
40903
41045
  try {
40904
- bytes = readFileSync13(path2);
41046
+ bytes = readFileSync14(path2);
40905
41047
  } catch (error2) {
40906
41048
  if (errorCode(error2) === "ENOENT") return void 0;
40907
41049
  throw error2;
@@ -43537,6 +43679,25 @@ import { chmodSync as chmodSync6 } from "node:fs";
43537
43679
  import {
43538
43680
  createServer as createServer2
43539
43681
  } from "node:http";
43682
+ import { join as join29 } from "node:path";
43683
+ function isClaudeSubagentId(value) {
43684
+ return typeof value === "string" && CLAUDE_SUBAGENT_ID.test(value);
43685
+ }
43686
+ function transcriptPathOf(options, sessionId) {
43687
+ if (options.harness !== "claude-code" || options.transcripts === void 0)
43688
+ return void 0;
43689
+ if (typeof sessionId !== "string" || !CLAUDE_SESSION_ID.test(sessionId))
43690
+ return void 0;
43691
+ return join29(options.transcripts.projectsDir, `${sessionId}.jsonl`);
43692
+ }
43693
+ function subagentTranscriptPathOf(sessionTranscript, hookEventName, agentId) {
43694
+ if (hookEventName !== "SubagentStop" || sessionTranscript === void 0)
43695
+ return void 0;
43696
+ if (typeof agentId !== "string" || !isClaudeSubagentId(agentId))
43697
+ return void 0;
43698
+ const dir = subagentDirOf(sessionTranscript);
43699
+ return dir === void 0 ? void 0 : join29(dir, `agent-${agentId}.jsonl`);
43700
+ }
43540
43701
  function send(response, status2, body2) {
43541
43702
  response.writeHead(status2, { "content-type": "application/json" });
43542
43703
  response.end(JSON.stringify(body2));
@@ -43611,13 +43772,26 @@ function containedBridgeHandler(options) {
43611
43772
  "Contained hook payload must be a JSON object"
43612
43773
  );
43613
43774
  const stella = options.harness === "stella";
43775
+ const sent = stella ? translateStellaPayload(input, 0) : input;
43614
43776
  const payload = {
43615
- ...stella ? translateStellaPayload(input, 0) : input,
43777
+ ...sent,
43616
43778
  session_id: options.sessionId,
43617
43779
  cwd: options.workspace
43618
43780
  };
43619
43781
  delete payload["transcript_path"];
43782
+ delete payload["agent_transcript_path"];
43620
43783
  delete payload["pid"];
43784
+ const transcript = transcriptPathOf(options, sent["session_id"]);
43785
+ if (transcript !== void 0) payload["transcript_path"] = transcript;
43786
+ if (options.harness === "claude-code" && payload["agent_id"] !== void 0 && !isClaudeSubagentId(payload["agent_id"]))
43787
+ delete payload["agent_id"];
43788
+ const subagentTranscript = subagentTranscriptPathOf(
43789
+ transcript,
43790
+ payload["hook_event_name"],
43791
+ payload["agent_id"]
43792
+ );
43793
+ if (subagentTranscript !== void 0)
43794
+ payload["agent_transcript_path"] = subagentTranscript;
43621
43795
  const event = typeof payload["hook_event_name"] === "string" ? payload["hook_event_name"] : "";
43622
43796
  const answer = (body2) => {
43623
43797
  if (!stella) {
@@ -43755,12 +43929,15 @@ async function startContainedBridge(options) {
43755
43929
  }
43756
43930
  };
43757
43931
  }
43758
- var GIT_HEADERS, ContainedRequestError, MAX_BODY_BYTES, CLAUDE_CODE_BETA_QUERY, ANTHROPIC_MODEL_PATHS, ANTHROPIC_PREFIX, ASK_IN_OXAGEN;
43932
+ var CLAUDE_SESSION_ID, CLAUDE_SUBAGENT_ID, GIT_HEADERS, ContainedRequestError, MAX_BODY_BYTES, CLAUDE_CODE_BETA_QUERY, ANTHROPIC_MODEL_PATHS, ANTHROPIC_PREFIX, ASK_IN_OXAGEN;
43759
43933
  var init_bridge = __esm({
43760
43934
  "../../packages/tacho/src/contained/bridge.ts"() {
43761
43935
  "use strict";
43762
43936
  init_stella_adapter();
43937
+ init_transcript_tailer();
43763
43938
  init_github2();
43939
+ CLAUDE_SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
43940
+ CLAUDE_SUBAGENT_ID = /^[A-Za-z0-9_-]{1,128}$/;
43764
43941
  GIT_HEADERS = [
43765
43942
  "content-type",
43766
43943
  "content-encoding",
@@ -43789,8 +43966,8 @@ var init_bridge = __esm({
43789
43966
  });
43790
43967
 
43791
43968
  // ../../packages/tacho/src/contained/workspace.ts
43792
- import { lstatSync as lstatSync7, readFileSync as readFileSync14, readdirSync as readdirSync12, realpathSync as realpathSync4 } from "node:fs";
43793
- import { isAbsolute as isAbsolute4, join as join29, relative as relative3, resolve as resolve9, sep as sep3 } from "node:path";
43969
+ import { lstatSync as lstatSync7, readFileSync as readFileSync15, readdirSync as readdirSync12, realpathSync as realpathSync4 } from "node:fs";
43970
+ import { isAbsolute as isAbsolute4, join as join30, relative as relative3, resolve as resolve9, sep as sep3 } from "node:path";
43794
43971
  function within(root, path2) {
43795
43972
  const rel = relative3(root, path2);
43796
43973
  return rel === "" || !isAbsolute4(rel) && rel !== ".." && !rel.startsWith(`..${sep3}`);
@@ -43798,7 +43975,7 @@ function within(root, path2) {
43798
43975
  function isEnvFile(entry2) {
43799
43976
  return /^\.env(?:\.|$)/.test(entry2) && !/^\.env\.(?:example|sample|template)$/.test(entry2);
43800
43977
  }
43801
- function validateContainedWorkspace(workspace, sessionDirectory, mountInfo = readFileSync14("/proc/self/mountinfo", "utf8")) {
43978
+ function validateContainedWorkspace(workspace, sessionDirectory, mountInfo = readFileSync15("/proc/self/mountinfo", "utf8")) {
43802
43979
  const root = realpathSync4(workspace);
43803
43980
  const session = realpathSync4(sessionDirectory);
43804
43981
  if (root === "/" || within(root, session) || within(session, root))
@@ -43820,7 +43997,7 @@ function validateContainedWorkspace(workspace, sessionDirectory, mountInfo = rea
43820
43997
  }
43821
43998
  const visit2 = (directory) => {
43822
43999
  for (const entry2 of readdirSync12(directory)) {
43823
- const path2 = join29(directory, entry2);
44000
+ const path2 = join30(directory, entry2);
43824
44001
  if (CREDENTIAL_PATHS.has(entry2) || isEnvFile(entry2))
43825
44002
  throw new Error(
43826
44003
  `Remove local credential files from the contained checkout before launch: ${named2(path2)}`
@@ -43854,7 +44031,7 @@ function validateContainedWorkspace(workspace, sessionDirectory, mountInfo = rea
43854
44031
  }
43855
44032
  function gitDirectoryMounts(workspace) {
43856
44033
  const root = realpathSync4(workspace);
43857
- const dotGit = join29(root, ".git");
44034
+ const dotGit = join30(root, ".git");
43858
44035
  let stat7;
43859
44036
  try {
43860
44037
  stat7 = lstatSync7(dotGit);
@@ -43873,7 +44050,7 @@ function gitDirectoryMounts(workspace) {
43873
44050
  throw new Error(
43874
44051
  "Contained repository's .git is neither a directory nor a file"
43875
44052
  );
43876
- const pointer = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync14(dotGit, "utf8"));
44053
+ const pointer = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync15(dotGit, "utf8"));
43877
44054
  if (pointer === null)
43878
44055
  throw new Error(
43879
44056
  "Contained repository's .git file names no git directory"
@@ -43892,7 +44069,7 @@ function gitDirectoryMounts(workspace) {
43892
44069
  if (gitDir !== void 0) {
43893
44070
  let common;
43894
44071
  try {
43895
- common = readFileSync14(join29(gitDir, "commondir"), "utf8").trim();
44072
+ common = readFileSync15(join30(gitDir, "commondir"), "utf8").trim();
43896
44073
  } catch {
43897
44074
  common = void 0;
43898
44075
  }
@@ -43918,8 +44095,8 @@ var init_workspace = __esm({
43918
44095
 
43919
44096
  // ../../packages/tacho/src/collector/hardened-git.ts
43920
44097
  import { execFile as execFile2 } from "node:child_process";
43921
- import { lstatSync as lstatSync8, readFileSync as readFileSync15, statSync as statSync8 } from "node:fs";
43922
- import { dirname as dirname20, join as join30, resolve as resolve10 } from "node:path";
44098
+ import { lstatSync as lstatSync8, readFileSync as readFileSync16, statSync as statSync8 } from "node:fs";
44099
+ import { dirname as dirname20, join as join31, resolve as resolve10 } from "node:path";
43923
44100
  function hardenedGitArgs(cwd, args, globals = []) {
43924
44101
  const subcommand = args[0];
43925
44102
  const end = args.indexOf("--");
@@ -43958,7 +44135,7 @@ function gitIdentity(repository, deps = DEFAULT_IDENTITY_DEPS) {
43958
44135
  };
43959
44136
  }
43960
44137
  for (let at2 = directory; ; at2 = dirname20(at2)) {
43961
- const marker = join30(at2, ".git");
44138
+ const marker = join31(at2, ".git");
43962
44139
  const link = tryStat(deps.lstat, marker);
43963
44140
  if (link !== void 0) {
43964
44141
  owners.push(link);
@@ -43966,7 +44143,7 @@ function gitIdentity(repository, deps = DEFAULT_IDENTITY_DEPS) {
43966
44143
  if (target !== void 0) {
43967
44144
  owners.push(target);
43968
44145
  if (target.isDirectory()) {
43969
- const config2 = tryStat(deps.stat, join30(marker, "config"));
44146
+ const config2 = tryStat(deps.stat, join31(marker, "config"));
43970
44147
  if (config2 !== void 0) owners.push(config2);
43971
44148
  }
43972
44149
  }
@@ -44022,13 +44199,13 @@ function createGitExecAsync(run3 = runExecFile, deps = DEFAULT_IDENTITY_DEPS, en
44022
44199
  const repository = options?.repository ?? (command2 === "git" && args[0] === "-C" ? args[1] : void 0);
44023
44200
  if (repository === void 0) {
44024
44201
  if (command2 === "git" && deps.getuid() === 0)
44025
- return refused(
44202
+ return refused2(
44026
44203
  "git did not run: root names no repository to run it as"
44027
44204
  );
44028
44205
  return run3(command2, args, inherited);
44029
44206
  }
44030
44207
  const identity = gitIdentity(repository, deps);
44031
- if (identity.kind === "refuse") return refused(identity.reason);
44208
+ if (identity.kind === "refuse") return refused2(identity.reason);
44032
44209
  if (identity.kind === "self") return run3(command2, args, inherited);
44033
44210
  const env = {};
44034
44211
  for (const name2 of KEPT_VARIABLES) {
@@ -44044,7 +44221,7 @@ function createGitExecAsync(run3 = runExecFile, deps = DEFAULT_IDENTITY_DEPS, en
44044
44221
  });
44045
44222
  };
44046
44223
  }
44047
- function refused(reason3) {
44224
+ function refused2(reason3) {
44048
44225
  return { status: 1, stdout: "", stderr: reason3 };
44049
44226
  }
44050
44227
  function definedOnly(environment) {
@@ -44106,7 +44283,7 @@ var init_hardened_git = __esm({
44106
44283
  lstat: (path2) => lstatSync8(path2),
44107
44284
  passwd: () => {
44108
44285
  try {
44109
- return readFileSync15("/etc/passwd", "utf8");
44286
+ return readFileSync16("/etc/passwd", "utf8");
44110
44287
  } catch {
44111
44288
  return void 0;
44112
44289
  }
@@ -44118,7 +44295,7 @@ var init_hardened_git = __esm({
44118
44295
 
44119
44296
  // ../../packages/tacho/src/contained/profile.ts
44120
44297
  import { createHash as createHash9 } from "node:crypto";
44121
- import { isAbsolute as isAbsolute5, join as join31, relative as relative4, sep as sep4 } from "node:path";
44298
+ import { isAbsolute as isAbsolute5, join as join32, relative as relative4, sep as sep4 } from "node:path";
44122
44299
  function containerPath(workspace, path2) {
44123
44300
  const inside2 = relative4(workspace, path2);
44124
44301
  if (inside2 === "" || isAbsolute5(inside2) || inside2 === ".." || inside2.startsWith(`..${sep4}`))
@@ -44128,7 +44305,7 @@ function containerPath(workspace, path2) {
44128
44305
  return `/workspace/${inside2.split(sep4).join("/")}`;
44129
44306
  }
44130
44307
  function gitMountPairs(spec) {
44131
- if (!spec.gitMounts.includes(join31(spec.workspace, ".git")))
44308
+ if (!spec.gitMounts.includes(join32(spec.workspace, ".git")))
44132
44309
  throw new Error(
44133
44310
  "Contained execution must mount the repository's .git read-only"
44134
44311
  );
@@ -44295,7 +44472,7 @@ import {
44295
44472
  writeFileSync as writeFileSync2
44296
44473
  } from "node:fs";
44297
44474
  import { tmpdir } from "node:os";
44298
- import { isAbsolute as isAbsolute6, join as join32 } from "node:path";
44475
+ import { isAbsolute as isAbsolute6, join as join33 } from "node:path";
44299
44476
  import { promisify } from "node:util";
44300
44477
  function reason(error2) {
44301
44478
  return error2 instanceof Error ? error2.message : String(error2);
@@ -44334,7 +44511,7 @@ async function launchContainedAgent(options) {
44334
44511
  if (digest6 === void 0)
44335
44512
  throw new Error("The operator's contained image is not installed");
44336
44513
  const sessionId = `contained-${randomBytes8(16).toString("hex")}`;
44337
- const directory = mkdtempSync(join32(tmpdir(), "oxagen-contained-"));
44514
+ const directory = mkdtempSync(join33(tmpdir(), "oxagen-contained-"));
44338
44515
  chmodSync7(directory, 448);
44339
44516
  let prepared;
44340
44517
  let containerCreated = false;
@@ -44355,7 +44532,7 @@ async function launchContainedAgent(options) {
44355
44532
  for (const [name3, contents] of entries2) {
44356
44533
  if (!/^[a-z0-9.-]+$/.test(name3))
44357
44534
  throw new Error("Invalid contained configuration filename");
44358
- writeFileSync2(join32(directory, name3), contents, {
44535
+ writeFileSync2(join33(directory, name3), contents, {
44359
44536
  mode: 256,
44360
44537
  flag: "wx"
44361
44538
  });
@@ -44772,7 +44949,7 @@ var init_privilege = __esm({
44772
44949
 
44773
44950
  // ../../packages/tacho/src/contained/sandbox/launcher.ts
44774
44951
  import { randomBytes as randomBytes9 } from "node:crypto";
44775
- import { dirname as dirname22, join as join33 } from "node:path";
44952
+ import { dirname as dirname22, join as join34 } from "node:path";
44776
44953
  function harnessVersionOf(stdout) {
44777
44954
  const words3 = stdout.trim().split(/\s+/).filter((word2) => word2.length > 0);
44778
44955
  const version3 = words3.find((word2) => /^v?\d+(?:\.\d+)+/.test(word2));
@@ -44926,7 +45103,7 @@ async function launchSandboxAgent(options) {
44926
45103
  for (const [name2, contents] of Object.entries(
44927
45104
  start.userState(options.gatewayPort, checkouts.target.path)
44928
45105
  )) {
44929
- const path2 = join33(SANDBOX_AGENT_HOME, name2);
45106
+ const path2 = join34(SANDBOX_AGENT_HOME, name2);
44930
45107
  if (dirname22(path2) !== SANDBOX_AGENT_HOME)
44931
45108
  system.mkdir(dirname22(path2), 448, AGENT_OWNER);
44932
45109
  system.writeFile(path2, contents, 384, AGENT_OWNER);
@@ -45058,6 +45235,85 @@ var init_launcher2 = __esm({
45058
45235
  }
45059
45236
  });
45060
45237
 
45238
+ // ../../packages/tacho/src/collector/memory-capture/memory-text.ts
45239
+ function clip2(text6, max2) {
45240
+ if (text6.length <= max2) return text6;
45241
+ let end = max2;
45242
+ const last = text6.charCodeAt(end - 1);
45243
+ if (last >= 55296 && last <= 56319) end -= 1;
45244
+ return text6.slice(0, end).trimEnd();
45245
+ }
45246
+ function frontmatterScalar(raw) {
45247
+ const value = raw.trim();
45248
+ if (/^[|>][+-]?$/.test(value)) return void 0;
45249
+ if (value.length >= 2 && value.startsWith('"') && value.endsWith('"'))
45250
+ return value.slice(1, -1).replace(/\\"/g, '"');
45251
+ if (value.length >= 2 && value.startsWith("'") && value.endsWith("'"))
45252
+ return value.slice(1, -1).replace(/''/g, "'");
45253
+ return value;
45254
+ }
45255
+ function frontmatterOf(block) {
45256
+ const fields = {};
45257
+ let inMetadata = false;
45258
+ for (const line of block.split(/\r?\n/)) {
45259
+ const match = FRONTMATTER_LINE.exec(line);
45260
+ if (match === null) continue;
45261
+ const [, indent = "", key = "", raw = ""] = match;
45262
+ if (indent === "") {
45263
+ inMetadata = key === "metadata" && raw.trim() === "";
45264
+ if (key === "name" || key === "description" || key === "type") {
45265
+ const value = frontmatterScalar(raw);
45266
+ if (value !== void 0) fields[key] = value;
45267
+ }
45268
+ continue;
45269
+ }
45270
+ if (inMetadata && key === "type") {
45271
+ const value = frontmatterScalar(raw);
45272
+ if (value !== void 0) fields.metadataType = value;
45273
+ }
45274
+ }
45275
+ return fields;
45276
+ }
45277
+ function textField(value, max2) {
45278
+ if (value === void 0) return void 0;
45279
+ const text6 = clip2(value.trim(), max2);
45280
+ return text6.length > 0 ? text6 : void 0;
45281
+ }
45282
+ function typeField(fields) {
45283
+ const value = (fields.metadataType ?? fields.type)?.trim().toLowerCase();
45284
+ return value !== void 0 && MEMORY_TYPE_PATTERN.test(value) ? value : void 0;
45285
+ }
45286
+ function memoryTextOf(text6) {
45287
+ const unmarked = text6.replace(/^\uFEFF/, "");
45288
+ const match = FRONTMATTER.exec(unmarked);
45289
+ const body2 = match === null ? unmarked : unmarked.slice(match[0].length);
45290
+ const fields = match === null ? {} : frontmatterOf(match[1] ?? "");
45291
+ const label = textField(fields.name, MEMORY_LABEL_MAX_CHARS);
45292
+ const summary = textField(fields.description, MEMORY_SUMMARY_MAX_CHARS);
45293
+ const memoryType = typeField(fields);
45294
+ return {
45295
+ statement: clip2(body2.trim(), MEMORY_STATEMENT_MAX_CHARS),
45296
+ ...label !== void 0 ? { label } : {},
45297
+ ...summary !== void 0 ? { summary } : {},
45298
+ ...memoryType !== void 0 ? { memoryType } : {}
45299
+ };
45300
+ }
45301
+ function claudeCodeProjectName(dir) {
45302
+ return dir.replace(/[^a-zA-Z0-9]/g, "-");
45303
+ }
45304
+ var MEMORY_STATEMENT_MAX_CHARS, MEMORY_LABEL_MAX_CHARS, MEMORY_SUMMARY_MAX_CHARS, MEMORY_TYPE_PATTERN, FRONTMATTER, FRONTMATTER_LINE;
45305
+ var init_memory_text = __esm({
45306
+ "../../packages/tacho/src/collector/memory-capture/memory-text.ts"() {
45307
+ "use strict";
45308
+ MEMORY_STATEMENT_MAX_CHARS = 2e3;
45309
+ MEMORY_LABEL_MAX_CHARS = 200;
45310
+ MEMORY_SUMMARY_MAX_CHARS = 1e3;
45311
+ MEMORY_TYPE_PATTERN = /^[a-z][a-z0-9_-]{0,31}$/;
45312
+ FRONTMATTER = /^---[ \t]*\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(?:\r?\n|$)/;
45313
+ FRONTMATTER_LINE = /^([ \t]*)([A-Za-z_][\w-]*)[ \t]*:[ \t]*(.*)$/;
45314
+ }
45315
+ });
45316
+
45061
45317
  // ../../packages/tacho/src/contained/sandbox/system.ts
45062
45318
  var system_exports = {};
45063
45319
  __export(system_exports, {
@@ -45067,16 +45323,16 @@ __export(system_exports, {
45067
45323
  });
45068
45324
  import { execFile as execFile4, spawn as spawn5 } from "node:child_process";
45069
45325
  import {
45070
- closeSync as closeSync7,
45071
- constants as constants3,
45326
+ closeSync as closeSync8,
45327
+ constants as constants4,
45072
45328
  existsSync as existsSync20,
45073
45329
  fchmodSync,
45074
45330
  fchownSync,
45075
45331
  lchownSync,
45076
45332
  lstatSync as lstatSync9,
45077
45333
  mkdirSync as mkdirSync5,
45078
- openSync as openSync7,
45079
- readFileSync as readFileSync16,
45334
+ openSync as openSync8,
45335
+ readFileSync as readFileSync17,
45080
45336
  rmSync as rmSync7,
45081
45337
  statSync as statSync9,
45082
45338
  unlinkSync as unlinkSync12,
@@ -45128,12 +45384,12 @@ function writeFileNoFollow(path2, contents, mode, owner) {
45128
45384
  if (parent !== void 0) assertDirectoriesOnly(parent, path2);
45129
45385
  const found = entryAt(path2);
45130
45386
  if (found !== void 0) removeEntry(path2, found);
45131
- const fd2 = openSync7(path2, "wx", mode);
45387
+ const fd2 = openSync8(path2, "wx", mode);
45132
45388
  try {
45133
45389
  writeFileSync3(fd2, contents);
45134
45390
  settle(fd2, mode, owner);
45135
45391
  } finally {
45136
- closeSync7(fd2);
45392
+ closeSync8(fd2);
45137
45393
  }
45138
45394
  }
45139
45395
  function mkdirNoFollow(path2, mode, owner) {
@@ -45148,14 +45404,14 @@ function mkdirNoFollow(path2, mode, owner) {
45148
45404
  if (found !== void 0) removeEntry(directory, found);
45149
45405
  mkdirSync5(directory, { mode });
45150
45406
  }
45151
- const fd2 = openSync7(
45407
+ const fd2 = openSync8(
45152
45408
  target,
45153
- constants3.O_RDONLY | constants3.O_DIRECTORY | constants3.O_NOFOLLOW
45409
+ constants4.O_RDONLY | constants4.O_DIRECTORY | constants4.O_NOFOLLOW
45154
45410
  );
45155
45411
  try {
45156
45412
  settle(fd2, mode, owner);
45157
45413
  } finally {
45158
- closeSync7(fd2);
45414
+ closeSync8(fd2);
45159
45415
  }
45160
45416
  }
45161
45417
  var run, nodeSandboxSystem;
@@ -45214,7 +45470,7 @@ var init_system = __esm({
45214
45470
  return void 0;
45215
45471
  }
45216
45472
  },
45217
- readFile: (path2) => readFileSync16(path2),
45473
+ readFile: (path2) => readFileSync17(path2),
45218
45474
  writeFile: writeFileNoFollow,
45219
45475
  mkdir: mkdirNoFollow,
45220
45476
  chown: (path2, uid, gid) => lchownSync(path2, uid, gid)
@@ -45223,10 +45479,20 @@ var init_system = __esm({
45223
45479
  });
45224
45480
 
45225
45481
  // ../../packages/tacho/src/contained/runner.ts
45226
- import { join as join34 } from "node:path";
45482
+ import { join as join35 } from "node:path";
45483
+ function sandboxClaudeProjectsDir(workspace) {
45484
+ return {
45485
+ projectsDir: join35(
45486
+ SANDBOX_AGENT_HOME,
45487
+ ".claude",
45488
+ "projects",
45489
+ claudeCodeProjectName(workspace)
45490
+ )
45491
+ };
45492
+ }
45227
45493
  function containedHookEnv(harness, workspace) {
45228
- const home = join34(workspace, ".oxagen-contained", "home");
45229
- return harness === "codex" ? { CODEX_HOME: join34(home, ".codex") } : { CLAUDE_CONFIG_DIR: join34(home, ".claude") };
45494
+ const home = join35(workspace, ".oxagen-contained", "home");
45495
+ return harness === "codex" ? { CODEX_HOME: join35(home, ".codex") } : { CLAUDE_CONFIG_DIR: join35(home, ".claude") };
45230
45496
  }
45231
45497
  function containedLaunchEndpoint(host) {
45232
45498
  const ingest = new URL(host.endpoints.ingest);
@@ -45372,6 +45638,7 @@ function createContainedRunner(options) {
45372
45638
  opening: route.opening,
45373
45639
  env: route.env,
45374
45640
  log: options.log,
45641
+ ...route.transcripts === void 0 ? {} : { transcripts: route.transcripts },
45375
45642
  mcp: (body2) => gateway.handle(body2, {
45376
45643
  sessionId: route.sessionId,
45377
45644
  enrollmentId: options.host().host_enrollment_id,
@@ -45476,7 +45743,7 @@ function createContainedRunner(options) {
45476
45743
  sessionUuid2 = started.recorder.sessionUuid;
45477
45744
  active2.set(sessionUuid2, controller);
45478
45745
  const bridge = await startContainedBridge({
45479
- socketPath: join34(directory, "bridge.sock"),
45746
+ socketPath: join35(directory, "bridge.sock"),
45480
45747
  ...bridgeRoutes({
45481
45748
  sessionId,
45482
45749
  workspace,
@@ -45560,7 +45827,7 @@ function createContainedRunner(options) {
45560
45827
  const abort = () => controller.abort();
45561
45828
  signal?.addEventListener("abort", abort, { once: true });
45562
45829
  if (signal?.aborted) abort();
45563
- const env = input.harness === "codex" ? { CODEX_HOME: CODEX_SANDBOX_HOME } : input.harness === "stella" ? { STELLA_HOME: STELLA_SANDBOX_HOME } : { CLAUDE_CONFIG_DIR: join34(SANDBOX_AGENT_HOME, ".claude") };
45830
+ const env = input.harness === "codex" ? { CODEX_HOME: CODEX_SANDBOX_HOME } : input.harness === "stella" ? { STELLA_HOME: STELLA_SANDBOX_HOME } : { CLAUDE_CONFIG_DIR: join35(SANDBOX_AGENT_HOME, ".claude") };
45564
45831
  let sessionUuid2;
45565
45832
  let launchedSessionId;
45566
45833
  let opened = false;
@@ -45650,7 +45917,14 @@ function createContainedRunner(options) {
45650
45917
  })
45651
45918
  )
45652
45919
  },
45653
- ...input.gitlab !== void 0 ? { gitlabHost: input.gitlab.host } : {}
45920
+ ...input.gitlab !== void 0 ? { gitlabHost: input.gitlab.host } : {},
45921
+ // Claude Code runs as the agent user and writes its
45922
+ // transcript, and each subagent's, under its own config
45923
+ // folder. Naming that folder lets the daemon tail them, and
45924
+ // open a chain for each subagent the run starts.
45925
+ ...input.harness === "claude-code" ? {
45926
+ transcripts: sandboxClaudeProjectsDir(context.workspace)
45927
+ } : {}
45654
45928
  }),
45655
45929
  options.sandboxGatewayPort
45656
45930
  );
@@ -45709,6 +45983,7 @@ var init_runner = __esm({
45709
45983
  init_launcher2();
45710
45984
  init_stella();
45711
45985
  init_profile();
45986
+ init_memory_text();
45712
45987
  init_request();
45713
45988
  init_system();
45714
45989
  LAUNCH_FAILED_REASON = "contained_launch_failed";
@@ -46234,13 +46509,13 @@ var init_credential_pool = __esm({
46234
46509
  });
46235
46510
 
46236
46511
  // ../../packages/tacho/src/host/repositories.ts
46237
- import { existsSync as existsSync21, readFileSync as readFileSync17, statSync as statSync10 } from "node:fs";
46238
- import { dirname as dirname23, join as join35, resolve as resolve11, sep as sep5 } from "node:path";
46512
+ import { existsSync as existsSync21, readFileSync as readFileSync18, statSync as statSync10 } from "node:fs";
46513
+ import { dirname as dirname23, join as join36, resolve as resolve11, sep as sep5 } from "node:path";
46239
46514
  function repositoriesFile(home) {
46240
- return join35(home.tachoDir, "repositories.json");
46515
+ return join36(home.tachoDir, "repositories.json");
46241
46516
  }
46242
46517
  function workTreesDir(home) {
46243
- return join35(home.tachoDir, "work");
46518
+ return join36(home.tachoDir, "work");
46244
46519
  }
46245
46520
  function readIndex(home) {
46246
46521
  let raw;
@@ -46292,23 +46567,23 @@ function recordCheckout(home, canonical3, root, seenAt) {
46292
46567
  return true;
46293
46568
  }
46294
46569
  function mainCheckoutOf(root) {
46295
- const dotGit = join35(root, ".git");
46570
+ const dotGit = join36(root, ".git");
46296
46571
  try {
46297
46572
  if (!statSync10(dotGit).isFile()) return root;
46298
- const line = readFileSync17(dotGit, "utf8").trim();
46573
+ const line = readFileSync18(dotGit, "utf8").trim();
46299
46574
  const match = /^gitdir:\s*(.+)$/m.exec(line);
46300
46575
  if (match === null) return root;
46301
46576
  const gitdir = resolve11(root, match[1].trim());
46302
46577
  const worktrees = dirname23(gitdir);
46303
46578
  if (!worktrees.endsWith(`${sep5}.git${sep5}worktrees`)) return root;
46304
46579
  const clone5 = dirname23(dirname23(worktrees));
46305
- return existsSync21(join35(clone5, ".git")) ? clone5 : root;
46580
+ return existsSync21(join36(clone5, ".git")) ? clone5 : root;
46306
46581
  } catch {
46307
46582
  return root;
46308
46583
  }
46309
46584
  }
46310
46585
  function defaultIsCheckout(root) {
46311
- return existsSync21(join35(root, ".git"));
46586
+ return existsSync21(join36(root, ".git"));
46312
46587
  }
46313
46588
  function findCheckout(home, repository, host, deps = {}) {
46314
46589
  const isCheckout = deps.isCheckout ?? defaultIsCheckout;
@@ -46352,11 +46627,11 @@ var init_repositories = __esm({
46352
46627
 
46353
46628
  // ../../packages/tacho/src/host/reauth-requests.ts
46354
46629
  import { readdirSync as readdirSync13, rmSync as rmSync8 } from "node:fs";
46355
- import { join as join36 } from "node:path";
46630
+ import { join as join37 } from "node:path";
46356
46631
  function requestFile(paths, id2) {
46357
46632
  if (!REAUTH_REQUEST_ID_PATTERN.test(id2))
46358
46633
  throw new Error(`${JSON.stringify(id2)} is not a sign-in request id`);
46359
- return join36(paths.reauthRequests, `${id2}.json`);
46634
+ return join37(paths.reauthRequests, `${id2}.json`);
46360
46635
  }
46361
46636
  function readKept2(path2) {
46362
46637
  try {
@@ -46426,8 +46701,8 @@ var init_reauth_requests = __esm({
46426
46701
  });
46427
46702
 
46428
46703
  // ../../packages/tacho/src/collector/detector.ts
46429
- import { promises as fs3 } from "node:fs";
46430
- import { basename as basename6, join as join37 } from "node:path";
46704
+ import { promises as fs2 } from "node:fs";
46705
+ import { basename as basename6, join as join38 } from "node:path";
46431
46706
  async function eachLimited(items, limit, task) {
46432
46707
  let next = 0;
46433
46708
  const workers = Array.from(
@@ -46445,7 +46720,7 @@ async function eachLimited(items, limit, task) {
46445
46720
  async function scanProject(dir) {
46446
46721
  let names2;
46447
46722
  try {
46448
- names2 = await fs3.readdir(dir);
46723
+ names2 = await fs2.readdir(dir);
46449
46724
  } catch {
46450
46725
  return [];
46451
46726
  }
@@ -46453,9 +46728,9 @@ async function scanProject(dir) {
46453
46728
  await eachLimited(names2, SCAN_CONCURRENCY, async (name2) => {
46454
46729
  const match = SESSION_FILE.exec(name2);
46455
46730
  if (match === null) return;
46456
- const path2 = join37(dir, name2);
46731
+ const path2 = join38(dir, name2);
46457
46732
  try {
46458
- const st = await fs3.stat(path2);
46733
+ const st = await fs2.stat(path2);
46459
46734
  out.push({ sessionId: match[1], path: path2, mtimeMs: st.mtimeMs });
46460
46735
  } catch {
46461
46736
  }
@@ -46489,14 +46764,14 @@ var init_detector = __esm({
46489
46764
  for (const root of this.roots) {
46490
46765
  let names2;
46491
46766
  try {
46492
- names2 = await fs3.readdir(root);
46767
+ names2 = await fs2.readdir(root);
46493
46768
  } catch {
46494
46769
  continue;
46495
46770
  }
46496
46771
  await eachLimited(names2, SCAN_CONCURRENCY, async (name2) => {
46497
- const dir = join37(root, name2);
46772
+ const dir = join38(root, name2);
46498
46773
  try {
46499
- const st = await fs3.stat(dir);
46774
+ const st = await fs2.stat(dir);
46500
46775
  if (st.isDirectory()) dirs.push({ dir, mtimeMs: st.mtimeMs });
46501
46776
  } catch {
46502
46777
  }
@@ -46544,7 +46819,7 @@ var init_detector = __esm({
46544
46819
  await eachLimited([...out], SCAN_CONCURRENCY, async (entry2) => {
46545
46820
  if (!watched.has(entry2.path)) return;
46546
46821
  try {
46547
- entry2.mtimeMs = (await fs3.stat(entry2.path)).mtimeMs;
46822
+ entry2.mtimeMs = (await fs2.stat(entry2.path)).mtimeMs;
46548
46823
  } catch {
46549
46824
  }
46550
46825
  });
@@ -46734,7 +47009,7 @@ var init_detector = __esm({
46734
47009
  transcript_path: transcript.path,
46735
47010
  transcript_mtime: new Date(transcript.mtimeMs).toISOString(),
46736
47011
  claude_pids: processes.map((p) => p.pid),
46737
- project: basename6(join37(transcript.path, ".."))
47012
+ project: basename6(join38(transcript.path, ".."))
46738
47013
  }
46739
47014
  })
46740
47015
  );
@@ -47143,9 +47418,9 @@ var init_git_facts = __esm({
47143
47418
  });
47144
47419
 
47145
47420
  // ../../packages/tacho/src/host/workspace-connection.ts
47146
- import { join as join38 } from "node:path";
47421
+ import { join as join39 } from "node:path";
47147
47422
  function workspaceConnectionFile(home) {
47148
- return join38(home.tachoDir, "connection.json");
47423
+ return join39(home.tachoDir, "connection.json");
47149
47424
  }
47150
47425
  function readWorkspaceConnection(home) {
47151
47426
  const path2 = workspaceConnectionFile(home);
@@ -47371,15 +47646,15 @@ var init_work_order_start = __esm({
47371
47646
 
47372
47647
  // ../../packages/tacho/src/collector/work-order-autostart.ts
47373
47648
  import { spawn as spawn6 } from "node:child_process";
47374
- import { closeSync as closeSync8, existsSync as existsSync22, openSync as openSync8, readSync as readSync4, statSync as statSync11 } from "node:fs";
47375
- import { dirname as dirname24, join as join39 } from "node:path";
47649
+ import { closeSync as closeSync9, existsSync as existsSync22, openSync as openSync9, readSync as readSync4, statSync as statSync11 } from "node:fs";
47650
+ import { dirname as dirname24, join as join40 } from "node:path";
47376
47651
  function lastLogLine(path2) {
47377
47652
  let fd2;
47378
47653
  try {
47379
47654
  const size = statSync11(path2).size;
47380
47655
  const length = Math.min(size, 4096);
47381
47656
  const buffer = Buffer.alloc(length);
47382
- fd2 = openSync8(path2, "r");
47657
+ fd2 = openSync9(path2, "r");
47383
47658
  readSync4(fd2, buffer, 0, length, size - length);
47384
47659
  const line = buffer.toString("utf8").replace(TERMINAL_CODE, "").split(/\r?\n/).map((text6) => text6.trim()).filter((text6) => text6.length > 0).pop();
47385
47660
  if (line === void 0) return void 0;
@@ -47389,7 +47664,7 @@ function lastLogLine(path2) {
47389
47664
  } finally {
47390
47665
  if (fd2 !== void 0) {
47391
47666
  try {
47392
- closeSync8(fd2);
47667
+ closeSync9(fd2);
47393
47668
  } catch {
47394
47669
  }
47395
47670
  }
@@ -47471,7 +47746,7 @@ function createWorkOrderAutostart(deps) {
47471
47746
  }
47472
47747
  async function abandon(id2) {
47473
47748
  forget(id2);
47474
- const worktree = join39(workTreesDir(paths), id2);
47749
+ const worktree = join40(workTreesDir(paths), id2);
47475
47750
  if (!existsSync22(worktree)) return;
47476
47751
  const [common, branch, head3] = await Promise.all([
47477
47752
  git5(worktree, [
@@ -47513,7 +47788,7 @@ function createWorkOrderAutostart(deps) {
47513
47788
  return waitMs;
47514
47789
  }
47515
47790
  async function prepareWorktree(root, id2, itemNumber, continued) {
47516
- const worktree = join39(workTreesDir(paths), id2);
47791
+ const worktree = join40(workTreesDir(paths), id2);
47517
47792
  const logPath = `${worktree}.log`;
47518
47793
  if (existsSync22(worktree)) {
47519
47794
  const [branch2, head3] = await Promise.all([
@@ -47688,9 +47963,9 @@ function createWorkOrderAutostart(deps) {
47688
47963
  if (running !== void 0) return;
47689
47964
  const wait2 = retry.get(id2);
47690
47965
  if (wait2 !== void 0 && deps.now() < wait2.at) return;
47691
- let refused2;
47966
+ let refused3;
47692
47967
  try {
47693
- refused2 = workOrderConnectionRefusal(
47968
+ refused3 = workOrderConnectionRefusal(
47694
47969
  readWorkspaceConnection(paths),
47695
47970
  deps.host(),
47696
47971
  order.connection_generation ?? 0
@@ -47702,8 +47977,8 @@ function createWorkOrderAutostart(deps) {
47702
47977
  );
47703
47978
  return;
47704
47979
  }
47705
- if (refused2 !== void 0) {
47706
- await endSend(id2, refused2);
47980
+ if (refused3 !== void 0) {
47981
+ await endSend(id2, refused3);
47707
47982
  return;
47708
47983
  }
47709
47984
  const outcome = await claimForStart(deps.client, deps.host(), id2);
@@ -47897,7 +48172,7 @@ var init_work_order_autostart = __esm({
47897
48172
  let fd2;
47898
48173
  try {
47899
48174
  ensureDir(dirname24(options.logPath));
47900
- fd2 = openSync8(options.logPath, "a", 384);
48175
+ fd2 = openSync9(options.logPath, "a", 384);
47901
48176
  } catch (error2) {
47902
48177
  resolve29({ ok: false, error: asError(error2) });
47903
48178
  return;
@@ -47907,7 +48182,7 @@ var init_work_order_autostart = __esm({
47907
48182
  if (!open7) return;
47908
48183
  open7 = false;
47909
48184
  try {
47910
- closeSync8(fd2);
48185
+ closeSync9(fd2);
47911
48186
  } catch {
47912
48187
  }
47913
48188
  };
@@ -48000,7 +48275,7 @@ import {
48000
48275
  rm,
48001
48276
  unlink
48002
48277
  } from "node:fs/promises";
48003
- import { dirname as dirname25, join as join40 } from "node:path";
48278
+ import { dirname as dirname25, join as join41 } from "node:path";
48004
48279
  function byPath(a, b3) {
48005
48280
  return a.path < b3.path ? -1 : a.path > b3.path ? 1 : 0;
48006
48281
  }
@@ -48043,7 +48318,7 @@ async function contentHash(absolutePath, kind, keep) {
48043
48318
  if (keep !== void 0) {
48044
48319
  try {
48045
48320
  await mkdir(keep.dir, { recursive: true, mode: 448 });
48046
- const temp2 = join40(keep.dir, `.partial-${randomUUID2()}`);
48321
+ const temp2 = join41(keep.dir, `.partial-${randomUUID2()}`);
48047
48322
  copy = {
48048
48323
  temp: temp2,
48049
48324
  handle: await open4(temp2, "wx", keep.executable ? 448 : 384)
@@ -48087,7 +48362,7 @@ async function settleCopy(temp, name2) {
48087
48362
  if (temp === void 0) return;
48088
48363
  if (name2 !== void 0)
48089
48364
  try {
48090
- await rename(temp, join40(dirname25(temp), name2));
48365
+ await rename(temp, join41(dirname25(temp), name2));
48091
48366
  return;
48092
48367
  } catch {
48093
48368
  }
@@ -48103,7 +48378,7 @@ async function copiedBytes(dir) {
48103
48378
  let total2 = 0;
48104
48379
  for (const name2 of names2) {
48105
48380
  try {
48106
- total2 += (await lstat(join40(dir, name2))).size;
48381
+ total2 += (await lstat(join41(dir, name2))).size;
48107
48382
  } catch {
48108
48383
  }
48109
48384
  }
@@ -48119,7 +48394,7 @@ async function removeCopiesOutside(root, live) {
48119
48394
  const keep = new Set(live());
48120
48395
  await Promise.all(
48121
48396
  names2.filter((name2) => !keep.has(name2)).map(
48122
- (name2) => rm(join40(root, name2), { recursive: true, force: true }).catch(
48397
+ (name2) => rm(join41(root, name2), { recursive: true, force: true }).catch(
48123
48398
  () => void 0
48124
48399
  )
48125
48400
  )
@@ -48226,7 +48501,7 @@ async function contributionOf(exec4, cwd, root, repoRelative, entry2, copies) {
48226
48501
  let copy = null;
48227
48502
  if (entry2 !== null) {
48228
48503
  if (copies === void 0 || !COPY_NAME.test(entry2[0])) return void 0;
48229
- copy = join40(copies, entry2[0]);
48504
+ copy = join41(copies, entry2[0]);
48230
48505
  const kept = await statOf(copy);
48231
48506
  if (kept === void 0 || kept === "absent" || kept.kind !== "file")
48232
48507
  return void 0;
@@ -48643,7 +48918,7 @@ var init_session_changes = __esm({
48643
48918
  });
48644
48919
 
48645
48920
  // ../../packages/tacho/src/collector/session-commits.ts
48646
- import { join as join41 } from "node:path";
48921
+ import { join as join42 } from "node:path";
48647
48922
  function parseMeta(stdout) {
48648
48923
  const out = [];
48649
48924
  for (const record2 of stdout.split("\0")) {
@@ -48768,7 +49043,7 @@ async function readSessionCommits(exec4, cwd, input) {
48768
49043
  const test = input.tests[commit.sha];
48769
49044
  const toolUseId = callAt(times.get(commit.sha), calls);
48770
49045
  const written2 = input.written;
48771
- const outside = merge2 || written2 === void 0 || root === void 0 ? void 0 : files2.some((file) => !written2.has(join41(root, file.path)));
49046
+ const outside = merge2 || written2 === void 0 || root === void 0 ? void 0 : files2.some((file) => !written2.has(join42(root, file.path)));
48772
49047
  return {
48773
49048
  sha: commit.sha,
48774
49049
  parent_shas: commit.parents.slice(0, MAX_COMMIT_PARENTS),
@@ -48816,7 +49091,7 @@ var init_session_commits = __esm({
48816
49091
 
48817
49092
  // ../../packages/tacho/src/collector/worktree-snapshot.ts
48818
49093
  import { lstat as lstat2 } from "node:fs/promises";
48819
- import { join as join42 } from "node:path";
49094
+ import { join as join43 } from "node:path";
48820
49095
  function headerPath(prefix, path2) {
48821
49096
  const name2 = `${prefix}${path2}`;
48822
49097
  let quoted3 = false;
@@ -48900,7 +49175,7 @@ async function worktreeFingerprint(status2, root) {
48900
49175
  const path2 = statusPath(record2);
48901
49176
  if (path2 === null) return "";
48902
49177
  try {
48903
- const info = await lstat2(join42(root, path2));
49178
+ const info = await lstat2(join43(root, path2));
48904
49179
  return `${info.size}:${info.mtimeMs}:${info.ctimeMs}`;
48905
49180
  } catch {
48906
49181
  return "absent";
@@ -49008,7 +49283,7 @@ async function readWorktreeSnapshot(exec4, cwd, baseline, measured) {
49008
49283
  }
49009
49284
  let present;
49010
49285
  try {
49011
- present = (await lstat2(join42(root, path2))).isFile();
49286
+ present = (await lstat2(join43(root, path2))).isFile();
49012
49287
  } catch {
49013
49288
  present = false;
49014
49289
  }
@@ -49111,10 +49386,10 @@ var init_worktree_snapshot = __esm({
49111
49386
  });
49112
49387
 
49113
49388
  // ../../packages/tacho/src/collector/git-lane.ts
49114
- import { join as join43 } from "node:path";
49389
+ import { join as join44 } from "node:path";
49115
49390
  function copiesDirOf(root, session) {
49116
49391
  const uuid2 = session.recorder.sessionUuid;
49117
- return /^[0-9a-f-]{36}$/i.test(uuid2) ? join43(root, uuid2) : void 0;
49392
+ return /^[0-9a-f-]{36}$/i.test(uuid2) ? join44(root, uuid2) : void 0;
49118
49393
  }
49119
49394
  function holdsBaseline(session) {
49120
49395
  return session.baselineCommit !== void 0 || Object.keys(session.baselines ?? {}).length > 0;
@@ -49931,9 +50206,9 @@ import {
49931
50206
  writeFile
49932
50207
  } from "node:fs/promises";
49933
50208
  import { homedir as homedir5 } from "node:os";
49934
- import { dirname as dirname26, join as join44, resolve as resolve12 } from "node:path";
50209
+ import { dirname as dirname26, join as join45, resolve as resolve12 } from "node:path";
49935
50210
  function stagingFolder(root, name2) {
49936
- return join44(root, `.${name2}${STAGING_SUFFIX}`);
50211
+ return join45(root, `.${name2}${STAGING_SUFFIX}`);
49937
50212
  }
49938
50213
  function isStagingName(name2) {
49939
50214
  return name2.startsWith(".") && name2.endsWith(STAGING_SUFFIX);
@@ -49976,17 +50251,17 @@ function envDir(env, key) {
49976
50251
  function skillsRoot(harness, env = process.env, home = homedir5()) {
49977
50252
  switch (harness) {
49978
50253
  case "claude-code":
49979
- return join44(
49980
- envDir(env, "CLAUDE_CONFIG_DIR") ?? join44(home, ".claude"),
50254
+ return join45(
50255
+ envDir(env, "CLAUDE_CONFIG_DIR") ?? join45(home, ".claude"),
49981
50256
  "skills"
49982
50257
  );
49983
50258
  case "codex": {
49984
50259
  const codexHome = envDir(env, "CODEX_HOME");
49985
- return codexHome === null ? join44(home, ".agents", "skills") : join44(codexHome, "skills");
50260
+ return codexHome === null ? join45(home, ".agents", "skills") : join45(codexHome, "skills");
49986
50261
  }
49987
50262
  case "stella":
49988
- return join44(
49989
- envDir(env, "STELLA_HOME") ?? join44(home, ".stella"),
50263
+ return join45(
50264
+ envDir(env, "STELLA_HOME") ?? join45(home, ".stella"),
49990
50265
  "skills"
49991
50266
  );
49992
50267
  case "cursor":
@@ -50081,11 +50356,11 @@ async function readMarker(folder) {
50081
50356
  if (!found.isDirectory()) return { state: "foreign" };
50082
50357
  const entries2 = await readdir2(folder);
50083
50358
  if (!entries2.includes(SESSION_MARKER)) return { state: "foreign" };
50084
- if ((await entryAt2(join44(folder, SESSION_MARKER)))?.isFile() !== true)
50359
+ if ((await entryAt2(join45(folder, SESSION_MARKER)))?.isFile() !== true)
50085
50360
  return { state: "foreign" };
50086
50361
  try {
50087
50362
  const parsed2 = JSON.parse(
50088
- await readFile(join44(folder, SESSION_MARKER), "utf8")
50363
+ await readFile(join45(folder, SESSION_MARKER), "utf8")
50089
50364
  );
50090
50365
  return isMarker(parsed2) ? { state: "ours", marker: parsed2 } : { state: "foreign" };
50091
50366
  } catch {
@@ -50102,22 +50377,22 @@ function liveSessions(marker, now) {
50102
50377
  return live;
50103
50378
  }
50104
50379
  async function writeMarker(folder, marker) {
50105
- const temp = join44(folder, MARKER_TEMP);
50380
+ const temp = join45(folder, MARKER_TEMP);
50106
50381
  await writeNew(temp, `${JSON.stringify(marker, null, 2)}
50107
50382
  `);
50108
- await rename2(temp, join44(folder, SESSION_MARKER));
50383
+ await rename2(temp, join45(folder, SESSION_MARKER));
50109
50384
  }
50110
50385
  async function writeSkill(root, skill, marker) {
50111
- const folder = join44(root, skill.name);
50386
+ const folder = join45(root, skill.name);
50112
50387
  const staging = stagingFolder(root, skill.name);
50113
50388
  await removeEntry2(folder);
50114
50389
  await removeEntry2(staging);
50115
50390
  await mkdir2(staging);
50116
50391
  await writeMarker(staging, { digest: UNFINISHED_DIGEST, sessions: {} });
50117
50392
  await rename2(staging, folder);
50118
- await writeNew(join44(folder, "SKILL.md"), skillMarkdown(skill));
50393
+ await writeNew(join45(folder, "SKILL.md"), skillMarkdown(skill));
50119
50394
  for (const file of skill.files) {
50120
- const target = join44(folder, file.path);
50395
+ const target = join45(folder, file.path);
50121
50396
  await mkdir2(dirname26(target), { recursive: true });
50122
50397
  await writeNew(target, file.content);
50123
50398
  }
@@ -50147,7 +50422,7 @@ async function placeSkills(root, sessionId, skills, now = /* @__PURE__ */ new Da
50147
50422
  result2.warnings.push(refusal);
50148
50423
  continue;
50149
50424
  }
50150
- const folder = join44(root, skill.name);
50425
+ const folder = join45(root, skill.name);
50151
50426
  if (taken.has(skill.name)) {
50152
50427
  result2.skipped.push(skill.name);
50153
50428
  result2.warnings.push(
@@ -50231,7 +50506,7 @@ async function removeSkills(root, sessionId, now = /* @__PURE__ */ new Date(), l
50231
50506
  throw error2;
50232
50507
  }
50233
50508
  for (const name2 of names2.sort(compareText)) {
50234
- const folder = join44(root, name2);
50509
+ const folder = join45(root, name2);
50235
50510
  if (isStagingName(name2)) {
50236
50511
  await removeEntry2(folder);
50237
50512
  continue;
@@ -50289,7 +50564,7 @@ var init_place = __esm({
50289
50564
 
50290
50565
  // ../../packages/tacho/src/skills/inventory.ts
50291
50566
  import { lstatSync as lstatSync10, readdirSync as readdirSync14 } from "node:fs";
50292
- import { join as join45 } from "node:path";
50567
+ import { join as join46 } from "node:path";
50293
50568
  function errorCode2(error2) {
50294
50569
  return typeof error2 === "object" && error2 !== null && "code" in error2 ? error2.code : void 0;
50295
50570
  }
@@ -50300,8 +50575,8 @@ function skillInventoryRoots(place2) {
50300
50575
  const project2 = projectOf(place2);
50301
50576
  if (project2 !== void 0)
50302
50577
  for (const folder of PROJECT_SKILL_FOLDERS[place2.harness])
50303
- roots.push(join45(project2, folder));
50304
- const user = place2.harness === "cursor" ? join45(home, ".cursor", "skills") : skillsRoot(place2.harness, place2.env, home);
50578
+ roots.push(join46(project2, folder));
50579
+ const user = place2.harness === "cursor" ? join46(home, ".cursor", "skills") : skillsRoot(place2.harness, place2.env, home);
50305
50580
  if (user !== null) roots.push(user);
50306
50581
  return [...new Set(roots)];
50307
50582
  }
@@ -50322,7 +50597,7 @@ function skillInventory(place2, reader) {
50322
50597
  if (entries2.length > SKILL_INVENTORY_SCAN_MAX) return void 0;
50323
50598
  for (const entry2 of entries2) {
50324
50599
  if (entry2.startsWith(".")) continue;
50325
- if (reader.isFile(join45(root, entry2, SKILL_FILE2)))
50600
+ if (reader.isFile(join46(root, entry2, SKILL_FILE2)))
50326
50601
  names2.add(entry2.slice(0, SKILL_INVENTORY_NAME_MAX));
50327
50602
  }
50328
50603
  }
@@ -50370,14 +50645,14 @@ var init_inventory = __esm({
50370
50645
  });
50371
50646
 
50372
50647
  // ../../packages/tacho/src/collector/subagent-meta.ts
50373
- import { join as join46 } from "node:path";
50648
+ import { join as join47 } from "node:path";
50374
50649
  function subagentMetaPaths(sessionTranscript, agentId, agentTranscript) {
50375
50650
  const paths = [];
50376
50651
  if (agentTranscript?.endsWith(".jsonl"))
50377
50652
  paths.push(`${agentTranscript.slice(0, -".jsonl".length)}.meta.json`);
50378
50653
  const dir = sessionTranscript === void 0 ? void 0 : subagentDirOf(sessionTranscript);
50379
50654
  if (dir !== void 0) {
50380
- const own = join46(dir, `agent-${agentId}.meta.json`);
50655
+ const own = join47(dir, `agent-${agentId}.meta.json`);
50381
50656
  if (!paths.includes(own)) paths.push(own);
50382
50657
  }
50383
50658
  return paths;
@@ -50873,7 +51148,7 @@ function questionBoundary(harness) {
50873
51148
  function holdToolCall(evaluation, record2) {
50874
51149
  const held = record2.control.interjection;
50875
51150
  if (held === void 0 || evaluation.decision === "deny") return evaluation;
50876
- const refused2 = {
51151
+ const refused3 = {
50877
51152
  ...evaluation,
50878
51153
  decision: "deny",
50879
51154
  evaluated: "deny",
@@ -50881,9 +51156,9 @@ function holdToolCall(evaluation, record2) {
50881
51156
  reason_code: INTERJECTION_OPEN,
50882
51157
  reason: held.question
50883
51158
  };
50884
- delete refused2.rule;
50885
- delete refused2.rules;
50886
- return refused2;
51159
+ delete refused3.rule;
51160
+ delete refused3.rules;
51161
+ return refused3;
50887
51162
  }
50888
51163
  function isBound(clause, remote) {
50889
51164
  const bound = new Set(clause.bound_remote_digests);
@@ -51562,7 +51837,7 @@ function loopRefusal(input, record2, deps, events, replay, evaluation, call2, at
51562
51837
  return void 0;
51563
51838
  events.push(...sealLoopNotice(record2, input, held, "PreToolUse", at2));
51564
51839
  markLoopNoticed(record2, chain, held);
51565
- const refused2 = {
51840
+ const refused3 = {
51566
51841
  ...evaluation,
51567
51842
  decision: "deny",
51568
51843
  evaluated: "deny",
@@ -51570,9 +51845,9 @@ function loopRefusal(input, record2, deps, events, replay, evaluation, call2, at
51570
51845
  reason_code: LOOP_NOTICE_REASON_CODE,
51571
51846
  reason: `${LOOP_REFUSAL_LEAD}${loopNoticeText(held)}`
51572
51847
  };
51573
- delete refused2.rule;
51574
- delete refused2.rules;
51575
- return refused2;
51848
+ delete refused3.rule;
51849
+ delete refused3.rules;
51850
+ return refused3;
51576
51851
  }
51577
51852
  function noteHandedContext(record2, input, replay, text6, at2) {
51578
51853
  if (replay !== void 0 || input.agent_id !== void 0) return;
@@ -51869,15 +52144,16 @@ async function routeHook(raw, env, deps, replay, harness, agent, hookId) {
51869
52144
  const events = [...reopening];
51870
52145
  const replayed = replayAttrs(replay);
51871
52146
  const pushBasis = await gitPushBasis(input, record2, deps);
52147
+ const readSettings = deps.readAgentText ?? deps.readText;
51872
52148
  const settingsOf = (draft) => {
51873
- if (draft.kind !== "agent_start" || (record2.harness ?? "claude-code") !== "claude-code" || deps.readText === void 0)
52149
+ if (draft.kind !== "agent_start" || (record2.harness ?? "claude-code") !== "claude-code" || readSettings === void 0)
51874
52150
  return draft;
51875
52151
  const model = typeof draft.body["model"] === "string" ? draft.body["model"] : void 0;
51876
52152
  const facts = claudeSettingsFacts(
51877
52153
  { ...env, HOME: env["HOME"] ?? homedir6() },
51878
52154
  record2.cwd ?? input.cwd,
51879
52155
  model,
51880
- deps.readText
52156
+ readSettings
51881
52157
  );
51882
52158
  return Object.keys(facts).length === 0 ? draft : { ...draft, body: { ...draft.body, ...facts } };
51883
52159
  };
@@ -52452,15 +52728,15 @@ function subagentMetaFor(record2, input, deps) {
52452
52728
  if (input.hook_event_name !== "SubagentStart" && input.hook_event_name !== "SubagentStop")
52453
52729
  return void 0;
52454
52730
  if ((record2.harness ?? "claude-code") !== "claude-code") return void 0;
52455
- if (input.agent_id === void 0 || deps.readText === void 0)
52456
- return void 0;
52731
+ const readText3 = deps.readAgentText ?? deps.readText;
52732
+ if (input.agent_id === void 0 || readText3 === void 0) return void 0;
52457
52733
  const agentTranscript = input["agent_transcript_path"];
52458
52734
  const paths = subagentMetaPaths(
52459
52735
  record2.transcriptPath ?? input.transcript_path,
52460
52736
  input.agent_id,
52461
52737
  typeof agentTranscript === "string" ? agentTranscript : void 0
52462
52738
  );
52463
- return readSubagentMeta(deps.readText, paths) ?? null;
52739
+ return readSubagentMeta(readText3, paths) ?? null;
52464
52740
  }
52465
52741
  function writtenDir(input) {
52466
52742
  const path2 = writtenPath(input);
@@ -52715,7 +52991,7 @@ var init_steer_waiters = __esm({
52715
52991
  });
52716
52992
 
52717
52993
  // ../../packages/tacho/src/collector/hook-id-journal.ts
52718
- import { appendFileSync as appendFileSync4, existsSync as existsSync23, readFileSync as readFileSync18, rmSync as rmSync9 } from "node:fs";
52994
+ import { appendFileSync as appendFileSync4, existsSync as existsSync23, readFileSync as readFileSync19, rmSync as rmSync9 } from "node:fs";
52719
52995
  function hookIdJournalEntry(session, key, at2, events) {
52720
52996
  const highest = /* @__PURE__ */ new Map();
52721
52997
  for (const event of events) {
@@ -52742,7 +53018,7 @@ function isEntry(value) {
52742
53018
  function readHookIdJournal(path2) {
52743
53019
  if (!existsSync23(path2)) return [];
52744
53020
  const entries2 = [];
52745
- for (const line of readFileSync18(path2, "utf8").split("\n")) {
53021
+ for (const line of readFileSync19(path2, "utf8").split("\n")) {
52746
53022
  if (line.trim().length === 0) continue;
52747
53023
  try {
52748
53024
  const value = JSON.parse(line);
@@ -53255,9 +53531,9 @@ var init_inbox = __esm({
53255
53531
 
53256
53532
  // ../../packages/tacho/src/collector/gateway-frame.ts
53257
53533
  function gatewayFrameBody(call2) {
53258
- const refused2 = call2.status === "rejected";
53534
+ const refused3 = call2.status === "rejected";
53259
53535
  return {
53260
- kind: refused2 ? "policy_decision" : "tool_call",
53536
+ kind: refused3 ? "policy_decision" : "tool_call",
53261
53537
  body: {
53262
53538
  tool_name: call2.toolName,
53263
53539
  tool_source: "mcp",
@@ -53273,7 +53549,7 @@ function gatewayFrameBody(call2) {
53273
53549
  tool_output_digest: call2.outputDigest,
53274
53550
  tool_output_bytes: call2.outputBytes
53275
53551
  },
53276
- ...refused2 ? {
53552
+ ...refused3 ? {
53277
53553
  policy_decision: "deny",
53278
53554
  policy_source: "kernel",
53279
53555
  policy_reason_code: "mcp_refused",
@@ -54192,88 +54468,9 @@ var init_memory_send = __esm({
54192
54468
  }
54193
54469
  });
54194
54470
 
54195
- // ../../packages/tacho/src/collector/memory-capture/memory-text.ts
54196
- function clip2(text6, max2) {
54197
- if (text6.length <= max2) return text6;
54198
- let end = max2;
54199
- const last = text6.charCodeAt(end - 1);
54200
- if (last >= 55296 && last <= 56319) end -= 1;
54201
- return text6.slice(0, end).trimEnd();
54202
- }
54203
- function frontmatterScalar(raw) {
54204
- const value = raw.trim();
54205
- if (/^[|>][+-]?$/.test(value)) return void 0;
54206
- if (value.length >= 2 && value.startsWith('"') && value.endsWith('"'))
54207
- return value.slice(1, -1).replace(/\\"/g, '"');
54208
- if (value.length >= 2 && value.startsWith("'") && value.endsWith("'"))
54209
- return value.slice(1, -1).replace(/''/g, "'");
54210
- return value;
54211
- }
54212
- function frontmatterOf(block) {
54213
- const fields = {};
54214
- let inMetadata = false;
54215
- for (const line of block.split(/\r?\n/)) {
54216
- const match = FRONTMATTER_LINE.exec(line);
54217
- if (match === null) continue;
54218
- const [, indent = "", key = "", raw = ""] = match;
54219
- if (indent === "") {
54220
- inMetadata = key === "metadata" && raw.trim() === "";
54221
- if (key === "name" || key === "description" || key === "type") {
54222
- const value = frontmatterScalar(raw);
54223
- if (value !== void 0) fields[key] = value;
54224
- }
54225
- continue;
54226
- }
54227
- if (inMetadata && key === "type") {
54228
- const value = frontmatterScalar(raw);
54229
- if (value !== void 0) fields.metadataType = value;
54230
- }
54231
- }
54232
- return fields;
54233
- }
54234
- function textField(value, max2) {
54235
- if (value === void 0) return void 0;
54236
- const text6 = clip2(value.trim(), max2);
54237
- return text6.length > 0 ? text6 : void 0;
54238
- }
54239
- function typeField(fields) {
54240
- const value = (fields.metadataType ?? fields.type)?.trim().toLowerCase();
54241
- return value !== void 0 && MEMORY_TYPE_PATTERN.test(value) ? value : void 0;
54242
- }
54243
- function memoryTextOf(text6) {
54244
- const unmarked = text6.replace(/^\uFEFF/, "");
54245
- const match = FRONTMATTER.exec(unmarked);
54246
- const body2 = match === null ? unmarked : unmarked.slice(match[0].length);
54247
- const fields = match === null ? {} : frontmatterOf(match[1] ?? "");
54248
- const label = textField(fields.name, MEMORY_LABEL_MAX_CHARS);
54249
- const summary = textField(fields.description, MEMORY_SUMMARY_MAX_CHARS);
54250
- const memoryType = typeField(fields);
54251
- return {
54252
- statement: clip2(body2.trim(), MEMORY_STATEMENT_MAX_CHARS),
54253
- ...label !== void 0 ? { label } : {},
54254
- ...summary !== void 0 ? { summary } : {},
54255
- ...memoryType !== void 0 ? { memoryType } : {}
54256
- };
54257
- }
54258
- function claudeCodeProjectName(dir) {
54259
- return dir.replace(/[^a-zA-Z0-9]/g, "-");
54260
- }
54261
- var MEMORY_STATEMENT_MAX_CHARS, MEMORY_LABEL_MAX_CHARS, MEMORY_SUMMARY_MAX_CHARS, MEMORY_TYPE_PATTERN, FRONTMATTER, FRONTMATTER_LINE;
54262
- var init_memory_text = __esm({
54263
- "../../packages/tacho/src/collector/memory-capture/memory-text.ts"() {
54264
- "use strict";
54265
- MEMORY_STATEMENT_MAX_CHARS = 2e3;
54266
- MEMORY_LABEL_MAX_CHARS = 200;
54267
- MEMORY_SUMMARY_MAX_CHARS = 1e3;
54268
- MEMORY_TYPE_PATTERN = /^[a-z][a-z0-9_-]{0,31}$/;
54269
- FRONTMATTER = /^---[ \t]*\r?\n(?:([\s\S]*?)\r?\n)?---[ \t]*(?:\r?\n|$)/;
54270
- FRONTMATTER_LINE = /^([ \t]*)([A-Za-z_][\w-]*)[ \t]*:[ \t]*(.*)$/;
54271
- }
54272
- });
54273
-
54274
54471
  // ../../packages/tacho/src/collector/memory-capture/memory-reader.ts
54275
54472
  import { createRequire as createRequire2 } from "node:module";
54276
- import { basename as basename7, dirname as dirname28, isAbsolute as isAbsolute10, join as join47, resolve as resolve15, sep as sep7 } from "node:path";
54473
+ import { basename as basename7, dirname as dirname28, isAbsolute as isAbsolute10, join as join48, resolve as resolve15, sep as sep7 } from "node:path";
54277
54474
  function claudeCodeLocation(projectsDir, memoryDir, scope) {
54278
54475
  return {
54279
54476
  harness: "claude-code",
@@ -54286,19 +54483,19 @@ function claudeCodeLocation(projectsDir, memoryDir, scope) {
54286
54483
  }
54287
54484
  function claudeCodeMemoryLocations(configDir, projectDirs = []) {
54288
54485
  const locations = [
54289
- claudeCodeLocation(() => join47(configDir, "projects"), "memory", {
54486
+ claudeCodeLocation(() => join48(configDir, "projects"), "memory", {
54290
54487
  kind: "project-folders"
54291
54488
  }),
54292
- claudeCodeLocation(() => join47(configDir, "agent-memory"), "", {
54489
+ claudeCodeLocation(() => join48(configDir, "agent-memory"), "", {
54293
54490
  kind: "personal"
54294
54491
  })
54295
54492
  ];
54296
54493
  for (const dir of projectDirs.slice(0, MEMORY_PROJECT_DIRS_MAX)) {
54297
54494
  const scope = { kind: "directory", dir };
54298
54495
  locations.push(
54299
- claudeCodeLocation(() => join47(dir, ".claude", "agent-memory"), "", scope),
54496
+ claudeCodeLocation(() => join48(dir, ".claude", "agent-memory"), "", scope),
54300
54497
  claudeCodeLocation(
54301
- () => join47(dir, ".claude", "agent-memory-local"),
54498
+ () => join48(dir, ".claude", "agent-memory-local"),
54302
54499
  "",
54303
54500
  scope
54304
54501
  )
@@ -54359,8 +54556,8 @@ function locate(file, locations, home) {
54359
54556
  const top = location.projectsDir(home);
54360
54557
  if (dirname28(projectDir) !== resolve15(top)) continue;
54361
54558
  const project2 = basename7(projectDir);
54362
- const dir = location.memoryDir === "" ? join47(top, project2) : join47(top, project2, location.memoryDir);
54363
- return { location, top, project: project2, dir, path: join47(dir, name2) };
54559
+ const dir = location.memoryDir === "" ? join48(top, project2) : join48(top, project2, location.memoryDir);
54560
+ return { location, top, project: project2, dir, path: join48(dir, name2) };
54364
54561
  }
54365
54562
  return void 0;
54366
54563
  }
@@ -54439,7 +54636,7 @@ function createMemoryReader(deps) {
54439
54636
  saveTimer = setTimeout(persist, MEMORY_SENT_SAVE_DELAY_MS);
54440
54637
  saveTimer.unref?.();
54441
54638
  }
54442
- const refused2 = /* @__PURE__ */ new Map();
54639
+ const refused3 = /* @__PURE__ */ new Map();
54443
54640
  const uploading = /* @__PURE__ */ new Set();
54444
54641
  let running;
54445
54642
  let reads = 0;
@@ -54509,10 +54706,10 @@ function createMemoryReader(deps) {
54509
54706
  continue;
54510
54707
  }
54511
54708
  if (outcome === "refused") {
54512
- refused2.set(key, { digest: digest6, at: now() });
54709
+ refused3.set(key, { digest: digest6, at: now() });
54513
54710
  return "held";
54514
54711
  }
54515
- refused2.delete(key);
54712
+ refused3.delete(key);
54516
54713
  sent.set(key, digest6);
54517
54714
  sentRead.set(key, read2);
54518
54715
  dirty = true;
@@ -54529,7 +54726,7 @@ function createMemoryReader(deps) {
54529
54726
  if (superseded || (sentRead.get(key) ?? 0) > read2) return "unchanged";
54530
54727
  const digest6 = sentDigest(entry2);
54531
54728
  if (sent.get(key) === digest6) return "unchanged";
54532
- if (stillHeld(refused2.get(key), digest6, now())) return "held";
54729
+ if (stillHeld(refused3.get(key), digest6, now())) return "held";
54533
54730
  const send5 = sendOnce(entry2, key, digest6, budget, read2).finally(() => {
54534
54731
  sending.delete(key);
54535
54732
  });
@@ -54583,13 +54780,13 @@ function createMemoryReader(deps) {
54583
54780
  const whole = [];
54584
54781
  const read2 = /* @__PURE__ */ new Set();
54585
54782
  const seen = /* @__PURE__ */ new Set();
54586
- const known = /* @__PURE__ */ new Set([...sent.keys(), ...refused2.keys()]);
54783
+ const known = /* @__PURE__ */ new Set([...sent.keys(), ...refused3.keys()]);
54587
54784
  const budget = { max: MEMORY_SCAN_WAIT_MAX_MS, waited: 0 };
54588
54785
  async function readFolder(location, dir, names2, where, paths) {
54589
54786
  for (const name2 of names2) {
54590
54787
  if (!name2.endsWith(location.extension)) continue;
54591
54788
  if (location.skip.includes(name2)) continue;
54592
- const path2 = join47(dir, name2);
54789
+ const path2 = join48(dir, name2);
54593
54790
  const file = await readAt2(location.harness, path2);
54594
54791
  if (file.kind === "absent" || file.kind === "empty") continue;
54595
54792
  paths.push(path2);
@@ -54618,7 +54815,7 @@ function createMemoryReader(deps) {
54618
54815
  if (location.scope.kind === "project-folders") {
54619
54816
  const projects = await list2(top);
54620
54817
  for (const project2 of projects.names) {
54621
- const dir = join47(top, project2, location.memoryDir);
54818
+ const dir = join48(top, project2, location.memoryDir);
54622
54819
  const files2 = await list2(dir);
54623
54820
  if (!files2.found) continue;
54624
54821
  const where2 = await scoper.projectFolder(project2);
@@ -54644,7 +54841,7 @@ function createMemoryReader(deps) {
54644
54841
  const folders = await list2(top);
54645
54842
  let complete = folders.complete;
54646
54843
  for (const folder of folders.names) {
54647
- const dir = location.memoryDir === "" ? join47(top, folder) : join47(top, folder, location.memoryDir);
54844
+ const dir = location.memoryDir === "" ? join48(top, folder) : join48(top, folder, location.memoryDir);
54648
54845
  const files2 = await list2(dir);
54649
54846
  if (!files2.complete) complete = false;
54650
54847
  if (!await readFolder(location, dir, files2.names, where, paths))
@@ -54691,7 +54888,7 @@ function createMemoryReader(deps) {
54691
54888
  sentRead.delete(key);
54692
54889
  dirty = true;
54693
54890
  }
54694
- for (const key of [...refused2.keys()]) if (gone(key)) refused2.delete(key);
54891
+ for (const key of [...refused3.keys()]) if (gone(key)) refused3.delete(key);
54695
54892
  return { sent: count14, scans, counts: counts2 };
54696
54893
  }
54697
54894
  async function sendFile(given) {
@@ -54789,10 +54986,10 @@ var init_memory_reader = __esm({
54789
54986
  MEMORY_WRITE_WAIT_MAX_MS = 2 * MEMORY_RATE_WAIT_MAX_MS;
54790
54987
  MEMORY_PROJECT_DIRS_MAX = 200;
54791
54988
  HARNESS_MEMORY_LOCATIONS = [
54792
- claudeCodeLocation((home) => join47(home, ".claude", "projects"), "memory", {
54989
+ claudeCodeLocation((home) => join48(home, ".claude", "projects"), "memory", {
54793
54990
  kind: "project-folders"
54794
54991
  }),
54795
- claudeCodeLocation((home) => join47(home, ".claude", "agent-memory"), "", {
54992
+ claudeCodeLocation((home) => join48(home, ".claude", "agent-memory"), "", {
54796
54993
  kind: "personal"
54797
54994
  })
54798
54995
  ];
@@ -55181,9 +55378,9 @@ var init_memory_recall = __esm({
55181
55378
  });
55182
55379
 
55183
55380
  // ../../packages/tacho/src/collector/memory-capture/memory-scope.ts
55184
- import { join as join48, resolve as resolve16 } from "node:path";
55381
+ import { join as join49, resolve as resolve16 } from "node:path";
55185
55382
  function machineWideDirs(home) {
55186
- return [resolve16(home), resolve16(join48(home, "Projects"))];
55383
+ return [resolve16(home), resolve16(join49(home, "Projects"))];
55187
55384
  }
55188
55385
  async function decodeProjectName(name2, readdir6) {
55189
55386
  if (!name2.startsWith("-")) return void 0;
@@ -55209,7 +55406,7 @@ async function decodeProjectName(name2, readdir6) {
55209
55406
  for (const entry2 of names2) {
55210
55407
  const part = `-${claudeCodeProjectName(entry2)}`;
55211
55408
  if (rest === part || rest.startsWith(`${part}-`))
55212
- await walk2(join48(dir, entry2), rest.slice(part.length));
55409
+ await walk2(join49(dir, entry2), rest.slice(part.length));
55213
55410
  if (found.length > 1 || cut) return;
55214
55411
  }
55215
55412
  }
@@ -55458,8 +55655,8 @@ var init_store_watch = __esm({
55458
55655
  });
55459
55656
 
55460
55657
  // ../../packages/tacho/src/collector/memory-capture/memory-uses.ts
55461
- import { readFileSync as readFileSync19, statSync as statSync12 } from "node:fs";
55462
- import { basename as basename9, dirname as dirname30, isAbsolute as isAbsolute12, join as join49, resolve as resolve18 } from "node:path";
55658
+ import { readFileSync as readFileSync20, statSync as statSync12 } from "node:fs";
55659
+ import { basename as basename9, dirname as dirname30, isAbsolute as isAbsolute12, join as join50, resolve as resolve18 } from "node:path";
55463
55660
  function memoryFileOf(path2, locations, home) {
55464
55661
  if (!isAbsolute12(path2)) return void 0;
55465
55662
  const file = resolve18(path2);
@@ -55477,7 +55674,7 @@ function memoryFileOf(path2, locations, home) {
55477
55674
  return void 0;
55478
55675
  }
55479
55676
  function pathOf(word2, cwd, home) {
55480
- const expanded = /^(?:~|\$HOME|\$\{HOME\})\//.test(word2) ? join49(home, word2.slice(word2.indexOf("/") + 1)) : word2;
55677
+ const expanded = /^(?:~|\$HOME|\$\{HOME\})\//.test(word2) ? join50(home, word2.slice(word2.indexOf("/") + 1)) : word2;
55481
55678
  if (isAbsolute12(expanded)) return expanded;
55482
55679
  if (cwd !== void 0 && isAbsolute12(cwd)) return resolve18(cwd, expanded);
55483
55680
  return void 0;
@@ -55510,14 +55707,14 @@ function claudeCodeProjectSlug(root) {
55510
55707
  function claudeCodeProjectRoot(cwd, files2) {
55511
55708
  const start = resolve18(cwd);
55512
55709
  for (let dir = start; ; dir = dirname30(dir)) {
55513
- const dotGit = join49(dir, ".git");
55710
+ const dotGit = join50(dir, ".git");
55514
55711
  if (files2.isDirectory(dotGit)) return dir;
55515
55712
  const pointer = files2.readText(dotGit);
55516
55713
  if (pointer !== void 0) {
55517
55714
  const gitDir = /^gitdir:\s*(.+)$/m.exec(pointer)?.[1]?.trim();
55518
55715
  if (gitDir === void 0) return dir;
55519
55716
  const own = resolve18(dir, gitDir);
55520
- const common = files2.readText(join49(own, "commondir"))?.trim();
55717
+ const common = files2.readText(join50(own, "commondir"))?.trim();
55521
55718
  const commonDir = common === void 0 ? own : resolve18(own, common);
55522
55719
  return basename9(commonDir) === ".git" ? dirname30(commonDir) : dir;
55523
55720
  }
@@ -55546,12 +55743,12 @@ function indexedMemoriesOf(cwd, home, locations, files2 = hostIndexFiles) {
55546
55743
  if (indexName === void 0) return [];
55547
55744
  const roots = /* @__PURE__ */ new Set([claudeCodeProjectRoot(cwd, files2), resolve18(cwd)]);
55548
55745
  for (const root of roots) {
55549
- const folder = join49(
55746
+ const folder = join50(
55550
55747
  projects.projectsDir(home),
55551
55748
  claudeCodeProjectSlug(root),
55552
55749
  projects.memoryDir
55553
55750
  );
55554
- const index = files2.readText(join49(folder, indexName));
55751
+ const index = files2.readText(join50(folder, indexName));
55555
55752
  if (index !== void 0)
55556
55753
  return memoriesListedIn(index, folder, locations, home);
55557
55754
  }
@@ -55845,7 +56042,7 @@ var init_memory_uses = __esm({
55845
56042
  hostIndexFiles = {
55846
56043
  readText: (path2) => {
55847
56044
  try {
55848
- return readFileSync19(path2, "utf8");
56045
+ return readFileSync20(path2, "utf8");
55849
56046
  } catch {
55850
56047
  return void 0;
55851
56048
  }
@@ -55873,7 +56070,7 @@ ${use.path}`;
55873
56070
  });
55874
56071
 
55875
56072
  // ../../packages/tacho/src/collector/memory-capture/stella-store.ts
55876
- import { dirname as dirname31, isAbsolute as isAbsolute13, join as join50, resolve as resolve19 } from "node:path";
56073
+ import { dirname as dirname31, isAbsolute as isAbsolute13, join as join51, resolve as resolve19 } from "node:path";
55877
56074
  function queryStellaStore(path2, afterSeq, limit) {
55878
56075
  const db = new (nodeSqlite()).DatabaseSync(path2, { readOnly: true });
55879
56076
  try {
@@ -55963,7 +56160,7 @@ async function stellaStoreOf(dir, exists) {
55963
56160
  if (!isAbsolute13(dir)) return void 0;
55964
56161
  let at2 = resolve19(dir);
55965
56162
  for (let depth = 0; depth < WORKSPACE_SEARCH_DEPTH; depth += 1) {
55966
- const candidate = join50(at2, STELLA_CONTEXT_DB);
56163
+ const candidate = join51(at2, STELLA_CONTEXT_DB);
55967
56164
  if (await exists(candidate)) return candidate;
55968
56165
  const up = dirname31(at2);
55969
56166
  if (up === at2) return void 0;
@@ -55976,7 +56173,7 @@ var init_stella_store = __esm({
55976
56173
  "../../packages/tacho/src/collector/memory-capture/stella-store.ts"() {
55977
56174
  "use strict";
55978
56175
  init_memory_reader();
55979
- STELLA_CONTEXT_DB = join50(".stella", "private", "context.db");
56176
+ STELLA_CONTEXT_DB = join51(".stella", "private", "context.db");
55980
56177
  STELLA_MEMORIES_VIEW = "export_memories_v1";
55981
56178
  STELLA_USES_VIEW = "export_memory_uses_v1";
55982
56179
  STELLA_USES_PER_READ = 5e3;
@@ -56066,7 +56263,7 @@ function createStellaMemories(deps) {
56066
56263
  }
56067
56264
  const gone = /* @__PURE__ */ new Set();
56068
56265
  const sent = /* @__PURE__ */ new Map();
56069
- const refused2 = /* @__PURE__ */ new Map();
56266
+ const refused3 = /* @__PURE__ */ new Map();
56070
56267
  const failures = /* @__PURE__ */ new Map();
56071
56268
  const viewsMissingLogged = /* @__PURE__ */ new Set();
56072
56269
  let running;
@@ -56143,7 +56340,7 @@ ${lineage}`;
56143
56340
  const key = sentKey(store, memory.lineage);
56144
56341
  const digest6 = sentDigest2(memory);
56145
56342
  if (sent.get(key) === digest6) continue;
56146
- if (stillHeld(refused2.get(key), digest6, deps.now())) continue;
56343
+ if (stillHeld(refused3.get(key), digest6, deps.now())) continue;
56147
56344
  let outcome;
56148
56345
  try {
56149
56346
  outcome = await deps.send(entryOf2(memory, store));
@@ -56152,10 +56349,10 @@ ${lineage}`;
56152
56349
  break;
56153
56350
  }
56154
56351
  if (outcome === "refused") {
56155
- refused2.set(key, { digest: digest6, at: deps.now() });
56352
+ refused3.set(key, { digest: digest6, at: deps.now() });
56156
56353
  continue;
56157
56354
  }
56158
- refused2.delete(key);
56355
+ refused3.delete(key);
56159
56356
  sent.set(key, digest6);
56160
56357
  result2.sent += 1;
56161
56358
  }
@@ -56715,7 +56912,7 @@ var init_cloud_link = __esm({
56715
56912
 
56716
56913
  // ../../packages/tacho/src/collector/local-servers/digest.ts
56717
56914
  import { createHash as createHash14 } from "node:crypto";
56718
- import { join as join51 } from "node:path";
56915
+ import { join as join52 } from "node:path";
56719
56916
  function rememberBounded(map, key, value) {
56720
56917
  if (!map.has(key) && map.size >= MAX_REMEMBERED_DIGESTS) {
56721
56918
  const oldest = map.keys().next();
@@ -56752,7 +56949,7 @@ function npmNameSegment(name2) {
56752
56949
  return name2.startsWith("@") ? `@${encodeURIComponent(name2.slice(1))}` : encodeURIComponent(name2);
56753
56950
  }
56754
56951
  async function whichOnPath(command2, pathValue, search) {
56755
- const candidates = command2.includes("/") || command2.includes("\\") ? [command2] : (pathValue ?? "").split(search.delimiter).filter((dir) => dir.length > 0).map((dir) => join51(dir, command2));
56952
+ const candidates = command2.includes("/") || command2.includes("\\") ? [command2] : (pathValue ?? "").split(search.delimiter).filter((dir) => dir.length > 0).map((dir) => join52(dir, command2));
56756
56953
  for (const candidate of candidates) {
56757
56954
  for (const extension2 of search.extensions) {
56758
56955
  if (await search.isExecutable(candidate + extension2))
@@ -57616,7 +57813,7 @@ function createLocalServers(options) {
57616
57813
  } catch {
57617
57814
  }
57618
57815
  }
57619
- function refused2(id2, refusal, toolsChanged = false) {
57816
+ function refused3(id2, refusal, toolsChanged = false) {
57620
57817
  options.log(`The local gateway refused ${id2}. ${refusalText(refusal)}`);
57621
57818
  return {
57622
57819
  kind: "refused",
@@ -57650,7 +57847,7 @@ function createLocalServers(options) {
57650
57847
  now: now(),
57651
57848
  skewMs
57652
57849
  });
57653
- if (!check3.ok) return refused2(envelope2.nonce, check3.refusal);
57850
+ if (!check3.ok) return refused3(envelope2.nonce, check3.refusal);
57654
57851
  const launch = await launchFor(delivery.launch, signal);
57655
57852
  const result2 = await callTool(
57656
57853
  {
@@ -57684,7 +57881,7 @@ function createLocalServers(options) {
57684
57881
  now: now(),
57685
57882
  skewMs
57686
57883
  });
57687
- if (!check3.ok) return refused2(envelope2.nonce, check3.refusal);
57884
+ if (!check3.ok) return refused3(envelope2.nonce, check3.refusal);
57688
57885
  const launch = await launchFor(delivery.launch, signal);
57689
57886
  const listed = await listTools({
57690
57887
  spawn: options.spawn,
@@ -57709,8 +57906,8 @@ function createLocalServers(options) {
57709
57906
  return delivery.kind === "call" ? await runCall(delivery, signal, notice) : await runDiscover(delivery, signal);
57710
57907
  } catch (error2) {
57711
57908
  if (error2 instanceof LocalServerError)
57712
- return refused2(id2, error2.refusal(), notice.toolsChanged);
57713
- return refused2(
57909
+ return refused3(id2, error2.refusal(), notice.toolsChanged);
57910
+ return refused3(
57714
57911
  id2,
57715
57912
  serverFailed(
57716
57913
  delivery.launch.server,
@@ -57806,7 +58003,7 @@ var init_local_servers = __esm({
57806
58003
 
57807
58004
  // ../../packages/tacho/src/collector/local-servers/machine.ts
57808
58005
  import { spawn as nodeSpawn } from "node:child_process";
57809
- import { access, constants as constants4, readFile as readFile2, realpath, stat } from "node:fs/promises";
58006
+ import { access, constants as constants5, readFile as readFile2, realpath, stat } from "node:fs/promises";
57810
58007
  function machineParked(host) {
57811
58008
  if (host.revoked_at !== null || host.host_status === "revoked")
57812
58009
  return "the enrollment is revoked";
@@ -57831,7 +58028,7 @@ function createMachineLink(host, fetch2, env) {
57831
58028
  async function isExecutable(path2) {
57832
58029
  try {
57833
58030
  if (!(await stat(path2)).isFile()) return false;
57834
- await access(path2, constants4.X_OK);
58031
+ await access(path2, constants5.X_OK);
57835
58032
  return true;
57836
58033
  } catch {
57837
58034
  return false;
@@ -57987,7 +58184,7 @@ import {
57987
58184
  rmSync as rmSync10,
57988
58185
  writeFileSync as writeFileSync4
57989
58186
  } from "node:fs";
57990
- import { join as join52 } from "node:path";
58187
+ import { join as join53 } from "node:path";
57991
58188
  function remoteName(url2) {
57992
58189
  let trimmed = url2.trim().replace(/\/+$/, "");
57993
58190
  if (trimmed.endsWith(".git")) trimmed = trimmed.slice(0, -".git".length);
@@ -58062,7 +58259,7 @@ function graphDir(root, repo) {
58062
58259
  const char = String.fromCharCode(byte);
58063
58260
  segment += /[A-Za-z0-9._-]/.test(char) ? char : `%${byte.toString(16).toUpperCase().padStart(2, "0")}`;
58064
58261
  }
58065
- return join52(root, segment);
58262
+ return join53(root, segment);
58066
58263
  }
58067
58264
  async function checkoutOf(git5, path2) {
58068
58265
  let url2;
@@ -58152,23 +58349,23 @@ async function fetchBaseDocument(fetch2, host, checkout, timeoutMs = BASE_TIMEOU
58152
58349
  return { ok: true, base: document, repoKey, fullName };
58153
58350
  }
58154
58351
  function saveBaseDocument(dir, document) {
58155
- const folder = join52(dir, BASE_DIR);
58352
+ const folder = join53(dir, BASE_DIR);
58156
58353
  mkdirSync6(folder, { recursive: true, mode: 448 });
58157
58354
  const name2 = `${document.commit}.json`;
58158
- const path2 = join52(folder, name2);
58159
- const temp = join52(folder, `.${name2}.${process.pid}.part`);
58355
+ const path2 = join53(folder, name2);
58356
+ const temp = join53(folder, `.${name2}.${process.pid}.part`);
58160
58357
  writeFileSync4(temp, JSON.stringify(document), { mode: 384 });
58161
58358
  renameSync4(temp, path2);
58162
58359
  for (const entry2 of readdirSync15(folder)) {
58163
58360
  if (entry2 !== name2 && entry2.endsWith(".json"))
58164
- rmSync10(join52(folder, entry2), { force: true });
58361
+ rmSync10(join53(folder, entry2), { force: true });
58165
58362
  }
58166
58363
  return path2;
58167
58364
  }
58168
58365
  function saveBinding(dir, repoKey, now = /* @__PURE__ */ new Date(), fullName = null) {
58169
58366
  mkdirSync6(dir, { recursive: true, mode: 448 });
58170
- const path2 = join52(dir, BINDING_FILE);
58171
- const temp = join52(dir, `.${BINDING_FILE}.${process.pid}.part`);
58367
+ const path2 = join53(dir, BINDING_FILE);
58368
+ const temp = join53(dir, `.${BINDING_FILE}.${process.pid}.part`);
58172
58369
  const body2 = {
58173
58370
  repoKey,
58174
58371
  fullName: repoKey === null ? null : fullName,
@@ -58248,7 +58445,7 @@ import {
58248
58445
  rmSync as rmSync11,
58249
58446
  writeFileSync as writeFileSync5
58250
58447
  } from "node:fs";
58251
- import { join as join53 } from "node:path";
58448
+ import { join as join54 } from "node:path";
58252
58449
  function codegraphTriple(platform2, arch) {
58253
58450
  if (platform2 === "darwin" && arch === "arm64") return "aarch64-apple-darwin";
58254
58451
  if (platform2 === "darwin" && arch === "x64") return "x86_64-apple-darwin";
@@ -58323,8 +58520,8 @@ async function downloadCodegraph(input) {
58323
58520
  failures.push(answer.message);
58324
58521
  continue;
58325
58522
  }
58326
- const dir = join53(input.home, ".oxagen", "bin");
58327
- const path2 = join53(
58523
+ const dir = join54(input.home, ".oxagen", "bin");
58524
+ const path2 = join54(
58328
58525
  dir,
58329
58526
  input.platform === "win32" ? "codegraph.exe" : "codegraph"
58330
58527
  );
@@ -58360,8 +58557,8 @@ import { createHash as createHash16, randomBytes as randomBytes11, timingSafeEqu
58360
58557
  import {
58361
58558
  createServer as createServer4
58362
58559
  } from "node:http";
58363
- import { mkdirSync as mkdirSync8, readFileSync as readFileSync20, writeFileSync as writeFileSync6 } from "node:fs";
58364
- import { join as join54 } from "node:path";
58560
+ import { mkdirSync as mkdirSync8, readFileSync as readFileSync21, writeFileSync as writeFileSync6 } from "node:fs";
58561
+ import { join as join55 } from "node:path";
58365
58562
  function oxagenCardHash(text6) {
58366
58563
  return createHash16("sha256").update(
58367
58564
  JSON.stringify({
@@ -58600,14 +58797,14 @@ function createEmbedRelay(deps) {
58600
58797
  cache.set(hash4, found);
58601
58798
  return Array.from(found);
58602
58799
  }
58603
- function refused2(answer) {
58800
+ function refused3(answer) {
58604
58801
  failure4.failed(`${answer.refusal.reason}: ${answer.refusal.message}`);
58605
58802
  deps.onRefusal?.(answer.refusal);
58606
58803
  return answer;
58607
58804
  }
58608
58805
  function hold(answer, ms) {
58609
58806
  held = { until: now() + ms, answer };
58610
- return refused2(answer);
58807
+ return refused3(answer);
58611
58808
  }
58612
58809
  function heldAnswer() {
58613
58810
  if (held === void 0) return void 0;
@@ -58649,7 +58846,7 @@ function createEmbedRelay(deps) {
58649
58846
  return outOfTime(lane, "rate_limited");
58650
58847
  const host = deps.host();
58651
58848
  if (host === void 0)
58652
- return refused2({
58849
+ return refused3({
58653
58850
  status: 424,
58654
58851
  refusal: {
58655
58852
  reason: "not_enrolled",
@@ -58678,7 +58875,7 @@ function createEmbedRelay(deps) {
58678
58875
  if (answer.ok) {
58679
58876
  const vectors = vectorsOf(answer.text, cards.length);
58680
58877
  if (vectors === void 0)
58681
- return refused2({
58878
+ return refused3({
58682
58879
  status: 424,
58683
58880
  refusal: {
58684
58881
  reason: "bad_answer",
@@ -58718,7 +58915,7 @@ function createEmbedRelay(deps) {
58718
58915
  }
58719
58916
  const refusal = worded(refusalOf2(answer));
58720
58917
  const out = { status: answer.status, refusal };
58721
- return refusal.reason === "spend_refused" ? hold(out, SPEND_HOLD_MS) : refused2(out);
58918
+ return refusal.reason === "spend_refused" ? hold(out, SPEND_HOLD_MS) : refused3(out);
58722
58919
  }
58723
58920
  }
58724
58921
  function relayFailure(error2) {
@@ -58906,7 +59103,7 @@ function createEmbedRelay(deps) {
58906
59103
  function savedPort() {
58907
59104
  try {
58908
59105
  const port = Number(
58909
- readFileSync20(join54(deps.root, RELAY_PORT_FILE), "utf8").trim()
59106
+ readFileSync21(join55(deps.root, RELAY_PORT_FILE), "utf8").trim()
58910
59107
  );
58911
59108
  return Number.isInteger(port) && port > 0 && port < 65536 ? port : void 0;
58912
59109
  } catch {
@@ -58932,7 +59129,7 @@ function createEmbedRelay(deps) {
58932
59129
  server = bound.server;
58933
59130
  base2 = `http://127.0.0.1:${bound.port}/v1`;
58934
59131
  if (bound.port !== saved)
58935
- writeFileSync6(join54(deps.root, RELAY_PORT_FILE), `${bound.port}
59132
+ writeFileSync6(join55(deps.root, RELAY_PORT_FILE), `${bound.port}
58936
59133
  `, {
58937
59134
  mode: 384
58938
59135
  });
@@ -59012,15 +59209,15 @@ var init_embed_relay = __esm({
59012
59209
  import { spawn as spawnChild } from "node:child_process";
59013
59210
  import {
59014
59211
  accessSync as accessSync3,
59015
- constants as constants5,
59212
+ constants as constants6,
59016
59213
  existsSync as existsSync24,
59017
59214
  mkdirSync as mkdirSync9,
59018
- readFileSync as readFileSync21,
59215
+ readFileSync as readFileSync22,
59019
59216
  realpathSync as realpathSync6,
59020
59217
  statSync as statSync13
59021
59218
  } from "node:fs";
59022
59219
  import { homedir as homedir7, totalmem } from "node:os";
59023
- import { delimiter as delimiter3, dirname as dirname32, isAbsolute as isAbsolute15, join as join55 } from "node:path";
59220
+ import { delimiter as delimiter3, dirname as dirname32, isAbsolute as isAbsolute15, join as join56 } from "node:path";
59024
59221
  import { createInterface as createInterface2 } from "node:readline";
59025
59222
  function serveMemoryMb(env, totalBytes) {
59026
59223
  const text6 = env[MEMORY_OVERRIDE]?.trim();
@@ -59039,11 +59236,11 @@ function machineMemory(totalBytes) {
59039
59236
  }
59040
59237
  function codegraphRoot(env, home) {
59041
59238
  const named2 = env["OXAGEN_CODEGRAPH_ROOT"];
59042
- return named2 !== void 0 && named2.length > 0 ? named2 : join55(home, ".oxagen", "codegraph");
59239
+ return named2 !== void 0 && named2.length > 0 ? named2 : join56(home, ".oxagen", "codegraph");
59043
59240
  }
59044
59241
  function defaultIsExecutable(path2) {
59045
59242
  try {
59046
- accessSync3(path2, constants5.X_OK);
59243
+ accessSync3(path2, constants6.X_OK);
59047
59244
  return statSync13(path2).isFile();
59048
59245
  } catch {
59049
59246
  return false;
@@ -59068,9 +59265,9 @@ function locateCodegraphBinary(input) {
59068
59265
  return named2;
59069
59266
  }
59070
59267
  const candidates = [
59071
- ...input.selfDirs.map((dir) => join55(dir, exe)),
59072
- join55(input.home, ".oxagen", "bin", exe),
59073
- ...(input.env["PATH"] ?? "").split(delimiter3).filter((dir) => dir.length > 0 && isAbsolute15(dir)).map((dir) => join55(dir, exe))
59268
+ ...input.selfDirs.map((dir) => join56(dir, exe)),
59269
+ join56(input.home, ".oxagen", "bin", exe),
59270
+ ...(input.env["PATH"] ?? "").split(delimiter3).filter((dir) => dir.length > 0 && isAbsolute15(dir)).map((dir) => join56(dir, exe))
59074
59271
  ];
59075
59272
  return candidates.find((candidate) => input.isExecutable(candidate));
59076
59273
  }
@@ -59188,7 +59385,7 @@ function createCodeGraphSupervisor(deps) {
59188
59385
  if (!downloaded.ok) {
59189
59386
  facts.binary = void 0;
59190
59387
  throw new CodeGraphUnavailableError(
59191
- `no codegraph binary was found, and the download failed (${downloaded.message}). Install it at ${join55(home, ".oxagen", "bin", "codegraph")}, put it on PATH, or set OXAGEN_CODEGRAPH_BIN to its path`
59388
+ `no codegraph binary was found, and the download failed (${downloaded.message}). Install it at ${join56(home, ".oxagen", "bin", "codegraph")}, put it on PATH, or set OXAGEN_CODEGRAPH_BIN to its path`
59192
59389
  );
59193
59390
  }
59194
59391
  found = downloaded.path;
@@ -59218,7 +59415,7 @@ function createCodeGraphSupervisor(deps) {
59218
59415
  async function ensureGrammars(bin) {
59219
59416
  const named2 = deps.env["CODEGRAPH_GRAMMAR_DIR"];
59220
59417
  if (named2 !== void 0 && named2.length > 0) return;
59221
- if (existsSync24(join55(root, "grammars"))) return;
59418
+ if (existsSync24(join56(root, "grammars"))) return;
59222
59419
  deps.log("codegraph: fetching the grammar pack");
59223
59420
  const code = await runOnce(bin, ["fetch-grammars", "--root", root]);
59224
59421
  if (code !== 0)
@@ -59390,11 +59587,11 @@ function createCodeGraphSupervisor(deps) {
59390
59587
  }
59391
59588
  let token;
59392
59589
  try {
59393
- token = readFileSync21(join55(root, "token"), "utf8").trim();
59590
+ token = readFileSync22(join56(root, "token"), "utf8").trim();
59394
59591
  } catch (error2) {
59395
59592
  child.kill("SIGTERM");
59396
59593
  throw new CodeGraphUnavailableError(
59397
- `codegraph serve started but its token could not be read from ${join55(root, "token")}: ${error2 instanceof Error ? error2.message : String(error2)}`
59594
+ `codegraph serve started but its token could not be read from ${join56(root, "token")}: ${error2 instanceof Error ? error2.message : String(error2)}`
59398
59595
  );
59399
59596
  }
59400
59597
  const started = { child, base: base2, token };
@@ -60822,12 +61019,32 @@ function modelSteeringAttributes(manifest) {
60822
61019
  );
60823
61020
  return attrs2;
60824
61021
  }
60825
- function mandatorySteeringCut(manifest) {
60826
- return manifest.cut.some(
61022
+ function requiredBudgetCuts(manifest) {
61023
+ return manifest.cut.filter(
60827
61024
  (record2) => record2.reason === "budget" && (record2.force === "must" || record2.force === "should")
60828
61025
  );
60829
61026
  }
60830
- var MODEL_STEERING_BUDGET_TOKENS, MODEL_STEERING_TIMEOUT_MS, MODEL_STEERING_MANIFEST_ATTR, MODEL_STEERING_STATUS_ATTR, MODEL_STEERING_RUN_HEADER, MODEL_STEERING_PATH, entrySchema2, modelSteeringManifestSchema, renderedModelSteeringSchema, modelSteeringContextSchema, INSTRUCTION_HEADING, INSTRUCTION_BULLET, INSTRUCTION_BOUNDARY;
61027
+ function mandatorySteeringCut(manifest) {
61028
+ return requiredBudgetCuts(manifest).length > 0;
61029
+ }
61030
+ function overBudgetAction(rendered) {
61031
+ if (!mandatorySteeringCut(rendered.manifest)) return null;
61032
+ return rendered.over_budget ?? "stop";
61033
+ }
61034
+ function overBudgetWarning(manifest) {
61035
+ const cut = requiredBudgetCuts(manifest);
61036
+ const shown3 = cut.slice(0, 5).map((record2) => record2.lineage);
61037
+ const more = cut.length > shown3.length ? ` and ${cut.length - shown3.length} more` : "";
61038
+ const budget = manifest.budget_tokens === null ? "the steering budget" : `the steering budget of ${manifest.budget_tokens} tokens`;
61039
+ return `${OVER_BUDGET_WARNING_PREFIX} ${budget}, so ${cut.length === 1 ? "1 required record was" : `${cut.length} required records were`} left out of this call: ${shown3.join(", ")}${more}. Tell the person once, so a workspace Admin can shorten the required steering or change [steering] over_budget in steering/governance.toml.`;
61040
+ }
61041
+ function withOverBudgetWarning(text6, manifest) {
61042
+ const warning = overBudgetWarning(manifest);
61043
+ return text6 === "" ? warning : `${warning}
61044
+
61045
+ ${text6}`;
61046
+ }
61047
+ var MODEL_STEERING_BUDGET_TOKENS, MODEL_STEERING_TIMEOUT_MS, MODEL_STEERING_MANIFEST_ATTR, MODEL_STEERING_STATUS_ATTR, MODEL_STEERING_RUN_HEADER, MODEL_STEERING_PATH, MODEL_STEERING_OVER_BUDGET_ATTR, STEERING_OVER_BUDGET_ACTIONS, steeringOverBudgetActionSchema, entrySchema2, modelSteeringManifestSchema, renderedModelSteeringSchema, modelSteeringContextSchema, INSTRUCTION_HEADING, INSTRUCTION_BULLET, INSTRUCTION_BOUNDARY, OVER_BUDGET_WARNING_PREFIX;
60831
61048
  var init_model_steering = __esm({
60832
61049
  "../../packages/tacho/src/model-steering.ts"() {
60833
61050
  "use strict";
@@ -60839,6 +61056,16 @@ var init_model_steering = __esm({
60839
61056
  MODEL_STEERING_STATUS_ATTR = "oxagen.steering_status";
60840
61057
  MODEL_STEERING_RUN_HEADER = "x-oxagen-session-uuid";
60841
61058
  MODEL_STEERING_PATH = "/v1/tacho/steering/render";
61059
+ MODEL_STEERING_OVER_BUDGET_ATTR = "oxagen.steering_over_budget";
61060
+ STEERING_OVER_BUDGET_ACTIONS = [
61061
+ "none",
61062
+ "recorded",
61063
+ "warn",
61064
+ "stop"
61065
+ ];
61066
+ steeringOverBudgetActionSchema = external_exports.enum(
61067
+ STEERING_OVER_BUDGET_ACTIONS
61068
+ );
60842
61069
  entrySchema2 = external_exports.object({
60843
61070
  lineage: external_exports.string().min(1),
60844
61071
  as: external_exports.enum(["body", "index"]),
@@ -60869,7 +61096,13 @@ var init_model_steering = __esm({
60869
61096
  renderedModelSteeringSchema = external_exports.object({
60870
61097
  text: external_exports.string().max(MODEL_STEERING_BUDGET_TOKENS * 4),
60871
61098
  prefix_length: external_exports.number().int().nonnegative(),
60872
- manifest: modelSteeringManifestSchema
61099
+ manifest: modelSteeringManifestSchema,
61100
+ /**
61101
+ * The workspace's choice for required steering that does not fit. The
61102
+ * control plane sends it only to a caller that asked for it, because an
61103
+ * older recorder reads this object strictly. Absent, the caller stops.
61104
+ */
61105
+ over_budget: steeringOverBudgetActionSchema.optional()
60873
61106
  }).strict();
60874
61107
  modelSteeringContextSchema = external_exports.object({
60875
61108
  repository: external_exports.string().max(512).nullable(),
@@ -60881,6 +61114,7 @@ var init_model_steering = __esm({
60881
61114
  INSTRUCTION_HEADING = /^(?:#{1,3} [^\n]*|MUST|SHOULD|MAY|INFO)\n/gm;
60882
61115
  INSTRUCTION_BULLET = /^- /gm;
60883
61116
  INSTRUCTION_BOUNDARY = /^(?:#{1,3} [^\n]*\n|MUST\n|SHOULD\n|MAY\n|INFO\n|- )/gm;
61117
+ OVER_BUDGET_WARNING_PREFIX = "Oxagen warning: this workspace's required steering does not fit";
60884
61118
  }
60885
61119
  });
60886
61120
 
@@ -61673,7 +61907,7 @@ function createModelProxy(deps) {
61673
61907
  const observed = /* @__PURE__ */ new Map();
61674
61908
  const priors = new RequestPrefixMemory();
61675
61909
  let callsObserved = 0;
61676
- let refused2 = 0;
61910
+ let refused3 = 0;
61677
61911
  const handoffs = /* @__PURE__ */ new WeakMap();
61678
61912
  retireIdleSockets(httpAgent);
61679
61913
  retireIdleSockets(httpsAgent);
@@ -61779,7 +62013,7 @@ function createModelProxy(deps) {
61779
62013
  return verdict.ok ? { claims: verdict.claims } : void 0;
61780
62014
  }
61781
62015
  function refuseUnrouted(req, res, route, message2) {
61782
- refused2 += 1;
62016
+ refused3 += 1;
61783
62017
  const attempt = {
61784
62018
  startedAt: deps.now(),
61785
62019
  bytesRead: 0,
@@ -62672,7 +62906,7 @@ function createModelProxy(deps) {
62672
62906
  status: credentialRefusalStatus(credential.refusal.code)
62673
62907
  } : void 0) ?? unrunnablePatternRefusal(gatewayPolicy) ?? (screen === "reject" ? sensitiveRequestRefusal(json2()) : void 0);
62674
62908
  const refuse3 = async (refusal) => {
62675
- refused2 += 1;
62909
+ refused3 += 1;
62676
62910
  const view = deps.policy();
62677
62911
  const decision = {
62678
62912
  policy_decision: "deny",
@@ -62851,9 +63085,11 @@ function createModelProxy(deps) {
62851
63085
  }
62852
63086
  if (result2.steeringStatus !== void 0)
62853
63087
  attrs2[MODEL_STEERING_STATUS_ATTR] = result2.steeringStatus;
63088
+ if (result2.steeringOverBudget !== void 0)
63089
+ attrs2[MODEL_STEERING_OVER_BUDGET_ATTR] = result2.steeringOverBudget;
62854
63090
  steeringManifest = result2.steeringManifest;
62855
63091
  if (result2.steeringStatus === "unavailable" && abortReason === void 0 && record2 !== void 0 && metered) {
62856
- refused2 += 1;
63092
+ refused3 += 1;
62857
63093
  if (steeringManifest)
62858
63094
  Object.assign(attrs2, modelSteeringAttributes(steeringManifest));
62859
63095
  admitted.release?.();
@@ -63078,6 +63314,9 @@ function createModelProxy(deps) {
63078
63314
  ) : {},
63079
63315
  ...attrs2[MODEL_STEERING_STATUS_ATTR] !== void 0 ? {
63080
63316
  [MODEL_STEERING_STATUS_ATTR]: attrs2[MODEL_STEERING_STATUS_ATTR]
63317
+ } : {},
63318
+ ...attrs2[MODEL_STEERING_OVER_BUDGET_ATTR] !== void 0 ? {
63319
+ [MODEL_STEERING_OVER_BUDGET_ATTR]: attrs2[MODEL_STEERING_OVER_BUDGET_ATTR]
63081
63320
  } : {}
63082
63321
  },
63083
63322
  target,
@@ -63690,7 +63929,7 @@ function createModelProxy(deps) {
63690
63929
  stats: () => {
63691
63930
  let open7 = 0;
63692
63931
  for (const calls of inFlight.values()) open7 += calls.size;
63693
- return { callsObserved, refused: refused2, inFlight: open7 };
63932
+ return { callsObserved, refused: refused3, inFlight: open7 };
63694
63933
  },
63695
63934
  close: () => {
63696
63935
  clearInterval(keepAliveTimer);
@@ -64078,6 +64317,9 @@ function createModelSteering(deps) {
64078
64317
  const failures = changedFailureLog(
64079
64318
  (detail) => deps.log(`model steering: ${detail}; the model call was refused`)
64080
64319
  );
64320
+ const overBudgetLog = changedFailureLog(
64321
+ (detail) => deps.log(`model steering: ${detail}`)
64322
+ );
64081
64323
  return async (request4) => {
64082
64324
  if (!request4.session || request4.api === "other")
64083
64325
  return { ...request4, steeringStatus: "unbound" };
@@ -64117,7 +64359,11 @@ function createModelSteering(deps) {
64117
64359
  MODEL_STEERING_PATH,
64118
64360
  {
64119
64361
  session_uuid: request4.session.sessionUuid,
64120
- context: { ...context, ...observed, files: files2 }
64362
+ context: { ...context, ...observed, files: files2 },
64363
+ // Ask for the workspace's over-budget choice. A control plane that
64364
+ // predates it would refuse the field, but the API deploys before
64365
+ // the CLI that sends it is published.
64366
+ over_budget: true
64121
64367
  },
64122
64368
  signal
64123
64369
  );
@@ -64138,7 +64384,8 @@ function createModelSteering(deps) {
64138
64384
  const rendered = renderedModelSteeringSchema.parse(
64139
64385
  JSON.parse(answer.text)
64140
64386
  );
64141
- if (mandatorySteeringCut(rendered.manifest)) {
64387
+ const overBudget = overBudgetAction(rendered);
64388
+ if (overBudget === "stop") {
64142
64389
  failures.failed("required steering exceeds the added-text budget");
64143
64390
  return {
64144
64391
  ...request4,
@@ -64147,12 +64394,22 @@ function createModelSteering(deps) {
64147
64394
  steeringFailure: { reason: "budget" }
64148
64395
  };
64149
64396
  }
64397
+ if (overBudget === "warn")
64398
+ overBudgetLog.failed(
64399
+ `${requiredBudgetCuts(rendered.manifest).length} required records did not fit the steering budget; the call was sent with the steering that fit, because the workspace's over_budget is warn`
64400
+ );
64401
+ else overBudgetLog.clear();
64150
64402
  failures.clear();
64151
64403
  return {
64152
64404
  ...request4,
64153
- json: withModelSteering(request4.json, request4.api, rendered.text),
64405
+ json: withModelSteering(
64406
+ request4.json,
64407
+ request4.api,
64408
+ overBudget === "warn" ? withOverBudgetWarning(rendered.text, rendered.manifest) : rendered.text
64409
+ ),
64154
64410
  steeringManifest: rendered.manifest,
64155
- steeringStatus: "rendered"
64411
+ steeringStatus: "rendered",
64412
+ ...overBudget === "recorded" || overBudget === "warn" ? { steeringOverBudget: overBudget } : {}
64156
64413
  };
64157
64414
  } catch (error2) {
64158
64415
  failures.failed(error2 instanceof Error ? error2.message : String(error2));
@@ -64974,13 +65231,13 @@ var init_session_router = __esm({
64974
65231
  });
64975
65232
 
64976
65233
  // ../../packages/tacho/src/collector/refused.ts
64977
- import { readdirSync as readdirSync16, readFileSync as readFileSync22, statSync as statSync15 } from "node:fs";
64978
- import { join as join56 } from "node:path";
65234
+ import { readdirSync as readdirSync16, readFileSync as readFileSync23, statSync as statSync15 } from "node:fs";
65235
+ import { join as join57 } from "node:path";
64979
65236
  function refusalRetryable(refusal) {
64980
65237
  return refusal === "malformed" || refusal === "parked";
64981
65238
  }
64982
65239
  function refusedRecordPath(dir, event) {
64983
- return join56(
65240
+ return join57(
64984
65241
  dir,
64985
65242
  `${event.session_uuid}-${String(event.seq).padStart(8, "0")}.json`
64986
65243
  );
@@ -65029,7 +65286,7 @@ function readRefusedEntry(file) {
65029
65286
  let record2;
65030
65287
  let mtimeMs;
65031
65288
  try {
65032
- record2 = JSON.parse(readFileSync22(file, "utf8"));
65289
+ record2 = JSON.parse(readFileSync23(file, "utf8"));
65033
65290
  mtimeMs = statSync15(file).mtimeMs;
65034
65291
  } catch {
65035
65292
  return void 0;
@@ -65062,7 +65319,7 @@ function scanRefused(dir, now, limit = MAX_REFUSED_RETRIES_PER_PASS) {
65062
65319
  };
65063
65320
  const due = [];
65064
65321
  for (const name2 of names2) {
65065
- const entry2 = readRefusedEntry(join56(dir, name2));
65322
+ const entry2 = readRefusedEntry(join57(dir, name2));
65066
65323
  if (entry2 === void 0) continue;
65067
65324
  summary.total += 1;
65068
65325
  if (summary.lastRefusedAt === void 0 || entry2.refusedAt > summary.lastRefusedAt)
@@ -65098,8 +65355,8 @@ var init_refused = __esm({
65098
65355
  });
65099
65356
 
65100
65357
  // ../../packages/tacho/src/collector/spool.ts
65101
- import { existsSync as existsSync26, readFileSync as readFileSync23, unlinkSync as unlinkSync14 } from "node:fs";
65102
- import { join as join57 } from "node:path";
65358
+ import { existsSync as existsSync26, readFileSync as readFileSync24, unlinkSync as unlinkSync14 } from "node:fs";
65359
+ import { join as join58 } from "node:path";
65103
65360
  function sessionOwnedElsewhere(error2) {
65104
65361
  return error2.status === 403 && error2.body.includes(SESSION_OWNED_ELSEWHERE) && !sessionFramesRefused(error2);
65105
65362
  }
@@ -65367,12 +65624,12 @@ var init_spool = __esm({
65367
65624
  }
65368
65625
  /** Add a body to a quarantine record that was written without one. */
65369
65626
  stashBodyBeside(event, body2) {
65370
- const path2 = join57(
65627
+ const path2 = join58(
65371
65628
  this.options.quarantineDir,
65372
65629
  `${event.session_uuid}-${String(event.seq).padStart(8, "0")}.json`
65373
65630
  );
65374
65631
  try {
65375
- const record2 = JSON.parse(readFileSync23(path2, "utf8"));
65632
+ const record2 = JSON.parse(readFileSync24(path2, "utf8"));
65376
65633
  if (record2["body"] !== void 0) return;
65377
65634
  writeSensitiveFileAtomic(
65378
65635
  path2,
@@ -65540,11 +65797,11 @@ var init_spool = __esm({
65540
65797
  const now = this.options.now();
65541
65798
  for (const [session, until] of this.foreignSessions)
65542
65799
  if (until <= now) this.foreignSessions.delete(session);
65543
- const refused2 = batch.filter(
65800
+ const refused3 = batch.filter(
65544
65801
  (e) => this.foreignSessions.has(e.session_uuid)
65545
65802
  );
65546
- if (refused2.length === 0) return this.sendBatch(batch, bodies);
65547
- for (const event of refused2) {
65803
+ if (refused3.length === 0) return this.sendBatch(batch, bodies);
65804
+ for (const event of refused3) {
65548
65805
  const until = this.foreignSessions.get(event.session_uuid) ?? Infinity;
65549
65806
  const permanent = until === Infinity;
65550
65807
  this.stash(
@@ -65555,19 +65812,19 @@ var init_spool = __esm({
65555
65812
  permanent ? void 0 : until
65556
65813
  );
65557
65814
  }
65558
- this.markShipped(refused2);
65815
+ this.markShipped(refused3);
65559
65816
  this.options.log(
65560
- `quarantined ${refused2.length} event(s) from session(s) the control plane refuses`
65817
+ `quarantined ${refused3.length} event(s) from session(s) the control plane refuses`
65561
65818
  );
65562
65819
  const rest = batch.filter((e) => !this.foreignSessions.has(e.session_uuid));
65563
65820
  if (rest.length === 0)
65564
65821
  return {
65565
65822
  shipped: 0,
65566
- quarantined: refused2.length,
65823
+ quarantined: refused3.length,
65567
65824
  reachable: this.reachable
65568
65825
  };
65569
65826
  const result2 = await this.sendBatch(rest, bodies);
65570
- return { ...result2, quarantined: result2.quarantined + refused2.length };
65827
+ return { ...result2, quarantined: result2.quarantined + refused3.length };
65571
65828
  }
65572
65829
  /** Halve a refused batch and ship each half, stopping at the first that stalls. */
65573
65830
  async bisect(batch, bodies) {
@@ -66155,14 +66412,14 @@ __export(daemon_exports, {
66155
66412
  import {
66156
66413
  existsSync as existsSync27,
66157
66414
  readdirSync as readdirSync17,
66158
- readFileSync as readFileSync24,
66415
+ readFileSync as readFileSync25,
66159
66416
  renameSync as renameSync6,
66160
66417
  statSync as statSync16,
66161
66418
  unlinkSync as unlinkSync15
66162
66419
  } from "node:fs";
66163
66420
  import { readdir as readdir3, readFile as readFile3, stat as stat2 } from "node:fs/promises";
66164
66421
  import { homedir as homedir9, hostname as osHostname2 } from "node:os";
66165
- import { dirname as dirname33, join as join58 } from "node:path";
66422
+ import { dirname as dirname33, join as join59 } from "node:path";
66166
66423
  import { spawnSync as spawnSync6 } from "node:child_process";
66167
66424
  function cloudGatewayUpstreams(origin = CLOUD_GATEWAY_ORIGIN) {
66168
66425
  const base2 = new URL(origin).origin;
@@ -66203,7 +66460,7 @@ function cloudGatewayCredentialStore(disk, runToken) {
66203
66460
  }
66204
66461
  function readTextOrUndefined(path2) {
66205
66462
  try {
66206
- return readFileSync24(path2, "utf8");
66463
+ return readFileSync25(path2, "utf8");
66207
66464
  } catch {
66208
66465
  return void 0;
66209
66466
  }
@@ -67225,7 +67482,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
67225
67482
  controlReachable: lastControlAt !== void 0 && now() - lastControlAt < 2 * timers.bundleRefreshMs
67226
67483
  };
67227
67484
  }
67228
- const bodyPurgeOwedPath = join58(paths.wal, "body-purge-owed");
67485
+ const bodyPurgeOwedPath = join59(paths.wal, "body-purge-owed");
67229
67486
  function markBodyPurgeOwed(retention, dropped) {
67230
67487
  try {
67231
67488
  ensureDir(paths.wal);
@@ -67247,7 +67504,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
67247
67504
  if (!existsSync27(bodyPurgeOwedPath)) return void 0;
67248
67505
  let text6;
67249
67506
  try {
67250
- text6 = readFileSync24(bodyPurgeOwedPath, "utf8");
67507
+ text6 = readFileSync25(bodyPurgeOwedPath, "utf8");
67251
67508
  } catch (error2) {
67252
67509
  log(
67253
67510
  `cannot read the owed body purge at ${bodyPurgeOwedPath}: ${error2 instanceof Error ? error2.message : String(error2)}; the retry sweeps against the clause in force. Check the file's permissions`
@@ -67581,7 +67838,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
67581
67838
  }
67582
67839
  void workOrderAutostart.reconcile();
67583
67840
  }
67584
- const lastIngestFile = join58(paths.dir, "last-ingest.json");
67841
+ const lastIngestFile = join59(paths.dir, "last-ingest.json");
67585
67842
  const shipper = new Shipper({
67586
67843
  wal,
67587
67844
  client,
@@ -67618,7 +67875,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
67618
67875
  read: () => {
67619
67876
  try {
67620
67877
  const at2 = Date.parse(
67621
- JSON.parse(readFileSync24(lastIngestFile, "utf8")).at ?? ""
67878
+ JSON.parse(readFileSync25(lastIngestFile, "utf8")).at ?? ""
67622
67879
  );
67623
67880
  return Number.isFinite(at2) ? at2 : void 0;
67624
67881
  } catch {
@@ -67809,7 +68066,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
67809
68066
  `subagent transcript ${path2} not read: this collector holds no session ${sessionId}`
67810
68067
  );
67811
68068
  else if ((session.harness ?? "claude-code") !== "claude-code" || readSubagentMeta(
67812
- readTextOrUndefined,
68069
+ (file) => readAgentTextOrUndefined(file),
67813
68070
  subagentMetaPaths(session.transcriptPath, agentId, path2)
67814
68071
  ) !== void 0)
67815
68072
  log(
@@ -68135,7 +68392,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
68135
68392
  async function readSpoolFile(name2) {
68136
68393
  try {
68137
68394
  const file = parseSpoolFile(
68138
- await readFile3(join58(paths.spool, name2), "utf8")
68395
+ await readFile3(join59(paths.spool, name2), "utf8")
68139
68396
  );
68140
68397
  spoolFacts.set(name2, spoolFactsOf(file));
68141
68398
  return file;
@@ -68185,6 +68442,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
68185
68442
  registry: registry3,
68186
68443
  policy,
68187
68444
  readText: readTextOrUndefined,
68445
+ readAgentText: (path2) => readAgentTextOrUndefined(path2),
68188
68446
  skillFolders: diskSkillFolderReader,
68189
68447
  home: options.home ?? homedir9(),
68190
68448
  // A hook waits a bounded time for a refresh and none during a
@@ -68354,7 +68612,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
68354
68612
  function setAsideConflictingTerminal(uuid2, pending, conflict) {
68355
68613
  const name2 = `${uuid2}-terminal-conflict-${String(conflict.seq).padStart(8, "0")}.json`;
68356
68614
  writeSensitiveFileAtomic(
68357
- join58(paths.quarantine, name2),
68615
+ join59(paths.quarantine, name2),
68358
68616
  JSON.stringify(
68359
68617
  {
68360
68618
  reason: conflict.message,
@@ -68438,8 +68696,8 @@ async function initializeDaemon(options, server, port, ready, clock2) {
68438
68696
  function moveToFailedSpool(path2, name2, reason3) {
68439
68697
  log(`spool file ${name2} moved to spool/failed/: ${reason3}`);
68440
68698
  try {
68441
- ensureDir(join58(paths.spool, "failed"));
68442
- renameSync6(path2, join58(paths.spool, "failed", name2));
68699
+ ensureDir(join59(paths.spool, "failed"));
68700
+ renameSync6(path2, join59(paths.spool, "failed", name2));
68443
68701
  } catch (error2) {
68444
68702
  log(
68445
68703
  `spool file ${name2} could not be moved to spool/failed/: ${error2 instanceof Error ? error2.message : String(error2)}`
@@ -68492,7 +68750,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
68492
68750
  continue;
68493
68751
  }
68494
68752
  reads += 1;
68495
- const path2 = join58(paths.spool, name2);
68753
+ const path2 = join59(paths.spool, name2);
68496
68754
  let file;
68497
68755
  try {
68498
68756
  file = await readSpoolFile(name2);
@@ -69414,7 +69672,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
69414
69672
  }
69415
69673
  function moveSpoolFile(path2, name2, target) {
69416
69674
  ensureDir(target.spoolDir);
69417
- renameSync6(path2, join58(target.spoolDir, name2));
69675
+ renameSync6(path2, join59(target.spoolDir, name2));
69418
69676
  spoolFacts.delete(name2);
69419
69677
  log(
69420
69678
  `spool file ${name2} moved to enrollment ${target.enrollmentId}, which owns its session`
@@ -69745,7 +70003,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
69745
70003
  let removed = 0;
69746
70004
  for (const name2 of readdirSync17(paths.quarantine)) {
69747
70005
  if (!name2.endsWith(".json")) continue;
69748
- const file = join58(paths.quarantine, name2);
70006
+ const file = join59(paths.quarantine, name2);
69749
70007
  try {
69750
70008
  const refusedAt = readRefusedEntry(file)?.refusedAt ?? statSync16(file).mtimeMs;
69751
70009
  if (at2 - refusedAt < retainMs) continue;
@@ -70160,7 +70418,7 @@ async function initializeDaemon(options, server, port, ready, clock2) {
70160
70418
  const memorySends = /* @__PURE__ */ new Set();
70161
70419
  let memoryStoreWatch;
70162
70420
  if (options.listen ?? true) {
70163
- const codexStore = join58(dirname33(paths.codexHooks), CODEX_MEMORY_STORE_FILE);
70421
+ const codexStore = join59(dirname33(paths.codexHooks), CODEX_MEMORY_STORE_FILE);
70164
70422
  const codexMemories = createCodexMemoryStore({
70165
70423
  path: codexStore,
70166
70424
  stat: (path2) => stat2(path2),
@@ -70501,6 +70759,7 @@ var init_daemon = __esm({
70501
70759
  init_interjection2();
70502
70760
  init_refused();
70503
70761
  init_session_heads();
70762
+ init_agent_file();
70504
70763
  init_subagent_meta();
70505
70764
  init_transcript_tailer();
70506
70765
  IDLE_COMMAND_POLL_FACTOR = 8;
@@ -70805,7 +71064,7 @@ var init_sandbox_launch = __esm({
70805
71064
  // ../../packages/tacho/src/cli/agent-run.ts
70806
71065
  import { spawn as spawn7 } from "node:child_process";
70807
71066
  import { randomUUID as randomUUID3 } from "node:crypto";
70808
- import { constants as constants6 } from "node:os";
71067
+ import { constants as constants7 } from "node:os";
70809
71068
  import { posix as posix5, win32 as win325 } from "node:path";
70810
71069
  function programName(program2) {
70811
71070
  const base2 = (program2.includes("\\") ? win325 : posix5).basename(program2);
@@ -70831,7 +71090,7 @@ function sessionRefusal2(stdout) {
70831
71090
  function exitCodeOf3(exit) {
70832
71091
  if (exit.error !== void 0) return 1;
70833
71092
  if (exit.code !== null) return exit.code;
70834
- const number5 = exit.signal !== null ? constants6.signals[exit.signal] : void 0;
71093
+ const number5 = exit.signal !== null ? constants7.signals[exit.signal] : void 0;
70835
71094
  return number5 !== void 0 ? 128 + number5 : 1;
70836
71095
  }
70837
71096
  function spawnAgent(command2, args, options) {
@@ -71623,7 +71882,7 @@ async function switchLocked(home, target, options) {
71623
71882
  }
71624
71883
  }
71625
71884
  const generations = { ...connection.generations };
71626
- const refused2 = [];
71885
+ const refused3 = [];
71627
71886
  for (const agent of toConnect) {
71628
71887
  try {
71629
71888
  const answer = await clientFor2(agent).setConnection("pending");
@@ -71636,14 +71895,14 @@ async function switchLocked(home, target, options) {
71636
71895
  });
71637
71896
  } catch (error2) {
71638
71897
  const message2 = messageOf5(error2);
71639
- refused2.push(`${agent.host.agent_key}: ${message2}`);
71898
+ refused3.push(`${agent.host.agent_key}: ${message2}`);
71640
71899
  outcomes.push({ ...described(agent.host), state: "failed", message: message2 });
71641
71900
  }
71642
71901
  }
71643
71902
  connection = {
71644
71903
  ...connection,
71645
71904
  generations,
71646
- ...refused2.length > 0 ? { state: "failed", failure: refused2.join(" ") } : {},
71905
+ ...refused3.length > 0 ? { state: "failed", failure: refused3.join(" ") } : {},
71647
71906
  changed_at: now().toISOString()
71648
71907
  };
71649
71908
  writeWorkspaceConnection(home, connection);
@@ -71765,11 +72024,11 @@ var init_workspace_switch = __esm({
71765
72024
  });
71766
72025
 
71767
72026
  // ../../packages/tacho/src/codegraph/harness-entries.ts
71768
- import { existsSync as existsSync28, readFileSync as readFileSync25 } from "node:fs";
71769
- import { dirname as dirname34, join as join59 } from "node:path";
72027
+ import { existsSync as existsSync28, readFileSync as readFileSync26 } from "node:fs";
72028
+ import { dirname as dirname34, join as join60 } from "node:path";
71770
72029
  function codexEntry(config2, deps) {
71771
72030
  const codexHome = dirname34(deps.paths.codexHooks);
71772
- const path2 = join59(codexHome, "config.toml");
72031
+ const path2 = join60(codexHome, "config.toml");
71773
72032
  if (!existsSync28(codexHome))
71774
72033
  return {
71775
72034
  harness: "codex",
@@ -71808,9 +72067,9 @@ function stellaEntry(host, deps, target) {
71808
72067
  }
71809
72068
  function repositoryStellaEntry(target) {
71810
72069
  if (target === void 0) return void 0;
71811
- const file = join59(target, ".stella", "mcp.toml");
72070
+ const file = join60(target, ".stella", "mcp.toml");
71812
72071
  try {
71813
- return namesOxagenServer(readFileSync25(file, "utf8")) ? `${file} has its own oxagen server, which Stella uses in place of this one in a trusted checkout` : void 0;
72072
+ return namesOxagenServer(readFileSync26(file, "utf8")) ? `${file} has its own oxagen server, which Stella uses in place of this one in a trusted checkout` : void 0;
71814
72073
  } catch {
71815
72074
  return void 0;
71816
72075
  }
@@ -73216,7 +73475,7 @@ var require_command = __commonJS({
73216
73475
  var EventEmitter = __require("node:events").EventEmitter;
73217
73476
  var childProcess = __require("node:child_process");
73218
73477
  var path2 = __require("node:path");
73219
- var fs4 = __require("node:fs");
73478
+ var fs3 = __require("node:fs");
73220
73479
  var process2 = __require("node:process");
73221
73480
  var { Argument: Argument2, humanReadableArgName } = require_argument();
73222
73481
  var { CommanderError: CommanderError2 } = require_error();
@@ -74149,10 +74408,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
74149
74408
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
74150
74409
  function findFile(baseDir, baseName) {
74151
74410
  const localBin = path2.resolve(baseDir, baseName);
74152
- if (fs4.existsSync(localBin)) return localBin;
74411
+ if (fs3.existsSync(localBin)) return localBin;
74153
74412
  if (sourceExt.includes(path2.extname(baseName))) return void 0;
74154
74413
  const foundExt = sourceExt.find(
74155
- (ext) => fs4.existsSync(`${localBin}${ext}`)
74414
+ (ext) => fs3.existsSync(`${localBin}${ext}`)
74156
74415
  );
74157
74416
  if (foundExt) return `${localBin}${foundExt}`;
74158
74417
  return void 0;
@@ -74164,7 +74423,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
74164
74423
  if (this._scriptPath) {
74165
74424
  let resolvedScriptPath;
74166
74425
  try {
74167
- resolvedScriptPath = fs4.realpathSync(this._scriptPath);
74426
+ resolvedScriptPath = fs3.realpathSync(this._scriptPath);
74168
74427
  } catch (err2) {
74169
74428
  resolvedScriptPath = this._scriptPath;
74170
74429
  }
@@ -75300,8 +75559,8 @@ var init_esm = __esm({
75300
75559
  });
75301
75560
 
75302
75561
  // ../../packages/tacho/src/collector/run.ts
75303
- import { readFileSync as readFileSync26, realpathSync as realpathSync7, statSync as statSync17, unlinkSync as unlinkSync16 } from "node:fs";
75304
- import { dirname as dirname35, join as join60 } from "node:path";
75562
+ import { readFileSync as readFileSync27, realpathSync as realpathSync7, statSync as statSync17, unlinkSync as unlinkSync16 } from "node:fs";
75563
+ import { dirname as dirname35, join as join61 } from "node:path";
75305
75564
  function stopWithin(stop, graceMs, exit, log) {
75306
75565
  const timer = setTimeout(() => {
75307
75566
  log(`recorderd: stop did not finish within ${graceMs} ms, exiting
@@ -75363,7 +75622,7 @@ function writeDaemonPid(path2, now = /* @__PURE__ */ new Date(), execPath = proc
75363
75622
  420
75364
75623
  );
75365
75624
  }
75366
- function installedCliVersion(entry2 = process.argv[1], read2 = (path2) => readFileSync26(path2, "utf8"), realpath4 = realpathSync7) {
75625
+ function installedCliVersion(entry2 = process.argv[1], read2 = (path2) => readFileSync27(path2, "utf8"), realpath4 = realpathSync7) {
75367
75626
  if (entry2 === void 0) return void 0;
75368
75627
  let dir;
75369
75628
  try {
@@ -75373,7 +75632,7 @@ function installedCliVersion(entry2 = process.argv[1], read2 = (path2) => readFi
75373
75632
  }
75374
75633
  for (let depth = 0; depth < CLI_PACKAGE_DEPTH_MAX; depth += 1) {
75375
75634
  try {
75376
- const pkg = JSON.parse(read2(join60(dir, "package.json")));
75635
+ const pkg = JSON.parse(read2(join61(dir, "package.json")));
75377
75636
  if (pkg.name === "@oxagen/cli")
75378
75637
  return typeof pkg.version === "string" ? pkg.version : void 0;
75379
75638
  } catch {
@@ -75390,7 +75649,7 @@ function processProbe() {
75390
75649
  native: isNativeBuild(),
75391
75650
  execPath: process.execPath,
75392
75651
  platform: process.platform,
75393
- read: (path2) => readFileSync26(path2, "utf8"),
75652
+ read: (path2) => readFileSync27(path2, "utf8"),
75394
75653
  realpath: realpathSync7,
75395
75654
  stat: statSync17,
75396
75655
  exists: (path2) => {
@@ -75450,14 +75709,14 @@ function ownProcStart() {
75450
75709
  }
75451
75710
  function readPidFile(path2) {
75452
75711
  try {
75453
- return readFileSync26(path2, "utf8");
75712
+ return readFileSync27(path2, "utf8");
75454
75713
  } catch {
75455
75714
  return void 0;
75456
75715
  }
75457
75716
  }
75458
75717
  function releaseDaemonPid(path2, previous) {
75459
75718
  try {
75460
- if (parseDaemonPid(readFileSync26(path2, "utf8"))?.pid !== process.pid) return;
75719
+ if (parseDaemonPid(readFileSync27(path2, "utf8"))?.pid !== process.pid) return;
75461
75720
  if (previous === void 0) unlinkSync16(path2);
75462
75721
  else writeSensitiveFileAtomic(path2, previous, 420);
75463
75722
  } catch {
@@ -75634,17 +75893,17 @@ var init_run2 = __esm({
75634
75893
 
75635
75894
  // ../../packages/tacho/src/arp/bundle.ts
75636
75895
  import {
75637
- closeSync as closeSync9,
75638
- constants as constants7,
75639
- fstatSync as fstatSync2,
75896
+ closeSync as closeSync10,
75897
+ constants as constants8,
75898
+ fstatSync as fstatSync3,
75640
75899
  lstatSync as lstatSync11,
75641
75900
  mkdirSync as mkdirSync10,
75642
- openSync as openSync9,
75901
+ openSync as openSync10,
75643
75902
  readSync as readSync5,
75644
75903
  realpathSync as realpathSync8,
75645
75904
  writeFileSync as writeFileSync7
75646
75905
  } from "node:fs";
75647
- import { dirname as dirname36, join as join61, resolve as resolve22 } from "node:path";
75906
+ import { dirname as dirname36, join as join62, resolve as resolve22 } from "node:path";
75648
75907
  function bundlePath(root, relative11, create2 = false) {
75649
75908
  const absolute = resolve22(root);
75650
75909
  if (create2) mkdirSync10(absolute, { recursive: true, mode: 448 });
@@ -75655,7 +75914,7 @@ function bundlePath(root, relative11, create2 = false) {
75655
75914
  let current = base2;
75656
75915
  const parts = relative11.split("/");
75657
75916
  for (let i2 = 0; i2 < parts.length; i2++) {
75658
- current = join61(current, parts[i2]);
75917
+ current = join62(current, parts[i2]);
75659
75918
  try {
75660
75919
  const stat7 = lstatSync11(current);
75661
75920
  if (stat7.isSymbolicLink() || i2 < parts.length - 1 && !stat7.isDirectory()) {
@@ -75676,9 +75935,9 @@ function bundlePath(root, relative11, create2 = false) {
75676
75935
  }
75677
75936
  function readBounded(root, relative11, limit = ARP_MAX_BLOB_BYTES) {
75678
75937
  const path2 = bundlePath(root, relative11);
75679
- const fd2 = openSync9(path2, constants7.O_RDONLY | constants7.O_NOFOLLOW);
75938
+ const fd2 = openSync10(path2, constants8.O_RDONLY | constants8.O_NOFOLLOW);
75680
75939
  try {
75681
- const stat7 = fstatSync2(fd2);
75940
+ const stat7 = fstatSync3(fd2);
75682
75941
  if (!stat7.isFile() || stat7.size > limit)
75683
75942
  arpFail(
75684
75943
  `The bundle file ${relative11} is not a regular file of at most ${limit} bytes.`
@@ -75695,20 +75954,20 @@ function readBounded(root, relative11, limit = ARP_MAX_BLOB_BYTES) {
75695
75954
  arpFail(`The bundle file ${relative11} changed while it was read.`);
75696
75955
  return bytes;
75697
75956
  } finally {
75698
- closeSync9(fd2);
75957
+ closeSync10(fd2);
75699
75958
  }
75700
75959
  }
75701
75960
  function writeNew2(root, relative11, bytes) {
75702
75961
  const path2 = bundlePath(root, relative11, true);
75703
- const fd2 = openSync9(
75962
+ const fd2 = openSync10(
75704
75963
  path2,
75705
- constants7.O_WRONLY | constants7.O_CREAT | constants7.O_EXCL | constants7.O_NOFOLLOW,
75964
+ constants8.O_WRONLY | constants8.O_CREAT | constants8.O_EXCL | constants8.O_NOFOLLOW,
75706
75965
  384
75707
75966
  );
75708
75967
  try {
75709
75968
  writeFileSync7(fd2, bytes);
75710
75969
  } finally {
75711
- closeSync9(fd2);
75970
+ closeSync10(fd2);
75712
75971
  }
75713
75972
  }
75714
75973
  function blobPath(ref) {
@@ -76608,18 +76867,18 @@ var init_oracles = __esm({
76608
76867
  // ../../packages/tacho/src/arp/transfer.ts
76609
76868
  import { randomUUID as randomUUID4 } from "node:crypto";
76610
76869
  import {
76611
- closeSync as closeSync10,
76612
- constants as constants8,
76613
- fstatSync as fstatSync3,
76870
+ closeSync as closeSync11,
76871
+ constants as constants9,
76872
+ fstatSync as fstatSync4,
76614
76873
  lstatSync as lstatSync12,
76615
76874
  mkdirSync as mkdirSync11,
76616
- openSync as openSync10,
76875
+ openSync as openSync11,
76617
76876
  readSync as readSync6,
76618
76877
  realpathSync as realpathSync9,
76619
76878
  rmSync as rmSync13,
76620
76879
  writeFileSync as writeFileSync8
76621
76880
  } from "node:fs";
76622
- import { dirname as dirname37, isAbsolute as isAbsolute16, join as join62, relative as relative6, resolve as resolve23, sep as sep8 } from "node:path";
76881
+ import { dirname as dirname37, isAbsolute as isAbsolute16, join as join63, relative as relative6, resolve as resolve23, sep as sep8 } from "node:path";
76623
76882
  function outsideProfile(path2) {
76624
76883
  return HARNESS_CONFIG_PATH.test(path2) || CREDENTIAL_PATH.test(path2);
76625
76884
  }
@@ -76630,9 +76889,9 @@ function sameJson(bytes, expected) {
76630
76889
  return jcs(JSON.parse(bytes.toString("utf8"))) === jcs(expected);
76631
76890
  }
76632
76891
  function readRegular(label, path2, limit) {
76633
- const fd2 = openSync10(path2, constants8.O_RDONLY | constants8.O_NOFOLLOW);
76892
+ const fd2 = openSync11(path2, constants9.O_RDONLY | constants9.O_NOFOLLOW);
76634
76893
  try {
76635
- const before = fstatSync3(fd2);
76894
+ const before = fstatSync4(fd2);
76636
76895
  if (!before.isFile() || before.size > limit)
76637
76896
  arpFail(`${label} ${path2} is not a regular file of at most ${limit} bytes.`);
76638
76897
  const bytes = Buffer.alloc(before.size);
@@ -76649,7 +76908,7 @@ function readRegular(label, path2, limit) {
76649
76908
  arpFail(
76650
76909
  `${label} ${path2} grew while it was read. Stop its writer and capture again.`
76651
76910
  );
76652
- const after = fstatSync3(fd2);
76911
+ const after = fstatSync4(fd2);
76653
76912
  if (before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs) {
76654
76913
  arpFail(
76655
76914
  `${label} ${path2} changed while it was read. Stop its writer and capture again.`
@@ -76657,7 +76916,7 @@ function readRegular(label, path2, limit) {
76657
76916
  }
76658
76917
  return { bytes, mode: before.mode };
76659
76918
  } finally {
76660
- closeSync10(fd2);
76919
+ closeSync11(fd2);
76661
76920
  }
76662
76921
  }
76663
76922
  function rejectSecrets(label, bytes) {
@@ -76673,7 +76932,7 @@ function within2(root, path2) {
76673
76932
  }
76674
76933
  function newPath(path2) {
76675
76934
  const full = resolve23(path2);
76676
- return join62(
76935
+ return join63(
76677
76936
  realpathSync9(dirname37(full)),
76678
76937
  full.slice(dirname37(full).length + 1)
76679
76938
  );
@@ -76687,7 +76946,7 @@ function sourcePath(root, path2) {
76687
76946
  }
76688
76947
  let current = root;
76689
76948
  for (const part of path2.split("/")) {
76690
- current = join62(current, part);
76949
+ current = join63(current, part);
76691
76950
  if (lstatSync12(current).isSymbolicLink())
76692
76951
  arpFail(
76693
76952
  `${path2} is a symlink or passes through one. Symlinks require a resource adapter.`
@@ -76954,10 +77213,10 @@ function prepareCheckpoint(options) {
76954
77213
  });
76955
77214
  mkdirSync11(destination, { mode: 448 });
76956
77215
  try {
76957
- const restored = join62(destination, "workspace");
77216
+ const restored = join63(destination, "workspace");
76958
77217
  mkdirSync11(restored, { mode: 448 });
76959
77218
  for (const item of restore) {
76960
- const path2 = join62(restored, item.path);
77219
+ const path2 = join63(restored, item.path);
76961
77220
  if (item.kind === "directory")
76962
77221
  mkdirSync11(path2, { recursive: true, mode: 448 });
76963
77222
  else {
@@ -76968,9 +77227,9 @@ function prepareCheckpoint(options) {
76968
77227
  });
76969
77228
  }
76970
77229
  }
76971
- const promptDir = join62(restored, ".arp");
77230
+ const promptDir = join63(restored, ".arp");
76972
77231
  mkdirSync11(promptDir, { mode: 448 });
76973
- const promptFile = join62(promptDir, "handoff.json");
77232
+ const promptFile = join63(promptDir, "handoff.json");
76974
77233
  const prompt = {
76975
77234
  checkpoint_digest: checkpointDigest,
76976
77235
  task: task.data.request,
@@ -76987,7 +77246,7 @@ function prepareCheckpoint(options) {
76987
77246
  flag: "wx",
76988
77247
  mode: 384
76989
77248
  });
76990
- const reportPath = join62(destination, "report.json");
77249
+ const reportPath = join63(destination, "report.json");
76991
77250
  writeFileSync8(
76992
77251
  reportPath,
76993
77252
  jcs(
@@ -77255,7 +77514,7 @@ __export(main_exports, {
77255
77514
  recordedCliDeps: () => recordedCliDeps,
77256
77515
  tokenOption: () => tokenOption
77257
77516
  });
77258
- import { readFileSync as readFileSync27 } from "node:fs";
77517
+ import { readFileSync as readFileSync28 } from "node:fs";
77259
77518
  function parsePort(value) {
77260
77519
  const port = Number(value);
77261
77520
  if (!/^\d+$/.test(value) || port < 1024 || port > 65535)
@@ -77292,7 +77551,7 @@ function parseOneHarness(value) {
77292
77551
  throw new InvalidArgumentError("name one harness");
77293
77552
  return harness;
77294
77553
  }
77295
- function tokenOption(opts, err2, readStdin3 = () => readFileSync27(0, "utf8")) {
77554
+ function tokenOption(opts, err2, readStdin3 = () => readFileSync28(0, "utf8")) {
77296
77555
  const flag2 = opts.token;
77297
77556
  if (opts.tokenStdin !== true) {
77298
77557
  if (flag2 !== void 0)
@@ -77795,7 +78054,7 @@ var init_package = __esm({
77795
78054
  "package.json"() {
77796
78055
  package_default = {
77797
78056
  name: "@oxagen/cli",
77798
- version: "5.5.1-16",
78057
+ version: "5.5.1-69",
77799
78058
  description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
77800
78059
  type: "module",
77801
78060
  main: "./dist/index.js",
@@ -77864,10 +78123,10 @@ var init_package = __esm({
77864
78123
 
77865
78124
  // src/lib/atomic-write.ts
77866
78125
  import { writeFileSync as writeFileSync9, renameSync as renameSync7, unlinkSync as unlinkSync17, existsSync as existsSync29 } from "node:fs";
77867
- import { dirname as dirname38, join as join63 } from "node:path";
78126
+ import { dirname as dirname38, join as join64 } from "node:path";
77868
78127
  function atomicWriteFileSync(path2, data, mode) {
77869
78128
  const dir = dirname38(path2);
77870
- const tmp = join63(
78129
+ const tmp = join64(
77871
78130
  dir,
77872
78131
  `.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2)}.tmp`
77873
78132
  );
@@ -77892,8 +78151,8 @@ var init_atomic_write = __esm({
77892
78151
 
77893
78152
  // src/lib/config.ts
77894
78153
  import { homedir as homedir10 } from "os";
77895
- import { join as join64 } from "path";
77896
- import { readFileSync as readFileSync28, mkdirSync as mkdirSync12, existsSync as existsSync30, statSync as statSync18 } from "fs";
78154
+ import { join as join65 } from "path";
78155
+ import { readFileSync as readFileSync29, mkdirSync as mkdirSync12, existsSync as existsSync30, statSync as statSync18 } from "fs";
77897
78156
  function getConfigDir() {
77898
78157
  return CONFIG_DIR;
77899
78158
  }
@@ -77939,7 +78198,7 @@ function readConfig() {
77939
78198
  }
77940
78199
  if (cached2?.identity === identity) return structuredClone(cached2.config);
77941
78200
  try {
77942
- const config2 = parseConfig(JSON.parse(readFileSync28(CONFIG_FILE, "utf8")));
78201
+ const config2 = parseConfig(JSON.parse(readFileSync29(CONFIG_FILE, "utf8")));
77943
78202
  cached2 = { identity, config: config2 };
77944
78203
  return structuredClone(config2);
77945
78204
  } catch (err2) {
@@ -77990,8 +78249,8 @@ var CONFIG_DIR, CONFIG_FILE, STRING_FIELDS, LINK_FIELDS, TELEMETRY_FIELDS, cache
77990
78249
  var init_config = __esm({
77991
78250
  "src/lib/config.ts"() {
77992
78251
  init_atomic_write();
77993
- CONFIG_DIR = join64(homedir10(), ".config", "oxagen");
77994
- CONFIG_FILE = join64(CONFIG_DIR, "config.json");
78252
+ CONFIG_DIR = join65(homedir10(), ".config", "oxagen");
78253
+ CONFIG_FILE = join65(CONFIG_DIR, "config.json");
77995
78254
  STRING_FIELDS = [
77996
78255
  "token",
77997
78256
  "orgSlug",
@@ -78044,16 +78303,16 @@ import {
78044
78303
  writeFile as writeFile2
78045
78304
  } from "node:fs/promises";
78046
78305
  import { homedir as homedir11 } from "node:os";
78047
- import { join as join65 } from "node:path";
78306
+ import { join as join66 } from "node:path";
78048
78307
  function isDebugEnabled() {
78049
78308
  const v = process.env[DEBUG_ENV];
78050
78309
  return v === "1" || v === "true";
78051
78310
  }
78052
78311
  function logsDir() {
78053
- return join65(homedir11(), ".oxagen", "logs");
78312
+ return join66(homedir11(), ".oxagen", "logs");
78054
78313
  }
78055
78314
  function debugLogFile() {
78056
- return join65(logsDir(), "cli.output");
78315
+ return join66(logsDir(), "cli.output");
78057
78316
  }
78058
78317
  function sanitize(value, depth = 0) {
78059
78318
  if (value === null || value === void 0) return value;
@@ -80660,7 +80919,7 @@ var init_revision = __esm({
80660
80919
  observations: unique(external_exports.string().min(1)),
80661
80920
  /** Each graph file the revision serves. */
80662
80921
  graphFiles: external_exports.array(graphFileRefSchema).min(1).refine(
80663
- (fs4) => new Set(fs4.map((f) => f.name)).size === fs4.length,
80922
+ (fs3) => new Set(fs3.map((f) => f.name)).size === fs3.length,
80664
80923
  "names a graph file twice"
80665
80924
  )
80666
80925
  }).strict();
@@ -89539,14 +89798,14 @@ var require_parser = __commonJS({
89539
89798
  case "scalar":
89540
89799
  case "single-quoted-scalar":
89541
89800
  case "double-quoted-scalar": {
89542
- const fs4 = this.flowScalar(this.type);
89801
+ const fs3 = this.flowScalar(this.type);
89543
89802
  if (atNextItem || it.value) {
89544
- map.items.push({ start, key: fs4, sep: [] });
89803
+ map.items.push({ start, key: fs3, sep: [] });
89545
89804
  this.onKeyLine = true;
89546
89805
  } else if (it.sep) {
89547
- this.stack.push(fs4);
89806
+ this.stack.push(fs3);
89548
89807
  } else {
89549
- Object.assign(it, { key: fs4, sep: [] });
89808
+ Object.assign(it, { key: fs3, sep: [] });
89550
89809
  this.onKeyLine = true;
89551
89810
  }
89552
89811
  return;
@@ -89674,13 +89933,13 @@ var require_parser = __commonJS({
89674
89933
  case "scalar":
89675
89934
  case "single-quoted-scalar":
89676
89935
  case "double-quoted-scalar": {
89677
- const fs4 = this.flowScalar(this.type);
89936
+ const fs3 = this.flowScalar(this.type);
89678
89937
  if (!it || it.value)
89679
- fc.items.push({ start: [], key: fs4, sep: [] });
89938
+ fc.items.push({ start: [], key: fs3, sep: [] });
89680
89939
  else if (it.sep)
89681
- this.stack.push(fs4);
89940
+ this.stack.push(fs3);
89682
89941
  else
89683
- Object.assign(it, { key: fs4, sep: [] });
89942
+ Object.assign(it, { key: fs3, sep: [] });
89684
89943
  return;
89685
89944
  }
89686
89945
  case "flow-map-end":
@@ -90642,7 +90901,7 @@ var init_src3 = __esm({
90642
90901
 
90643
90902
  // src/commands/codegraph-upload/files.ts
90644
90903
  import { readdir as readdir4, realpath as realpath2, stat as stat4 } from "node:fs/promises";
90645
- import { isAbsolute as isAbsolute17, join as join66, relative as relative7, sep as sep9 } from "node:path";
90904
+ import { isAbsolute as isAbsolute17, join as join67, relative as relative7, sep as sep9 } from "node:path";
90646
90905
  function hasGlobChars(pattern) {
90647
90906
  return /[*?[\]{}]/.test(pattern);
90648
90907
  }
@@ -90658,7 +90917,7 @@ async function walk(root, dir, out) {
90658
90917
  const entries2 = await readdir4(dir, { withFileTypes: true });
90659
90918
  for (const entry2 of entries2) {
90660
90919
  if (entry2.isSymbolicLink()) continue;
90661
- const full = join66(dir, entry2.name);
90920
+ const full = join67(dir, entry2.name);
90662
90921
  if (entry2.isDirectory()) {
90663
90922
  if (!SKIP_DIRS.has(entry2.name)) await walk(root, full, out);
90664
90923
  } else if (entry2.isFile()) {
@@ -90672,7 +90931,7 @@ async function expandPattern(root, pattern) {
90672
90931
  try {
90673
90932
  const [base2, file] = await Promise.all([
90674
90933
  realpath2(root),
90675
- realpath2(join66(root, wanted))
90934
+ realpath2(join67(root, wanted))
90676
90935
  ]);
90677
90936
  if (!isInside2(base2, file)) return [];
90678
90937
  const info = await stat4(file);
@@ -90752,12 +91011,12 @@ async function uploadFile(input) {
90752
91011
  message: `The endpoint answered ${response.status} with a body this step does not read. Update @oxagen/cli.`
90753
91012
  };
90754
91013
  }
90755
- const refused2 = uploadErrorSchema.safeParse(json2);
91014
+ const refused3 = uploadErrorSchema.safeParse(json2);
90756
91015
  return {
90757
91016
  ok: false,
90758
91017
  status: response.status,
90759
- code: refused2.success ? refused2.data.error.code : `http_${response.status}`,
90760
- message: refused2.success ? refused2.data.error.message : `The endpoint answered ${response.status}.`
91018
+ code: refused3.success ? refused3.data.error.code : `http_${response.status}`,
91019
+ message: refused3.success ? refused3.data.error.message : `The endpoint answered ${response.status}.`
90761
91020
  };
90762
91021
  }
90763
91022
  var VERSION;
@@ -90826,7 +91085,7 @@ var init_token = __esm({
90826
91085
  });
90827
91086
 
90828
91087
  // src/commands/codegraph-upload/run.ts
90829
- import { join as join67 } from "node:path";
91088
+ import { join as join68 } from "node:path";
90830
91089
  function addDropped(into, more) {
90831
91090
  into.sensitiveValues += more.sensitiveValues;
90832
91091
  into.secretData += more.secretData;
@@ -90844,7 +91103,7 @@ async function uploadOne(deps, config2, token, group, path2, totals2) {
90844
91103
  const label = `${group.kind}/${group.source} ${path2}`;
90845
91104
  let bytes;
90846
91105
  try {
90847
- bytes = await deps.readFile(join67(deps.cwd, path2));
91106
+ bytes = await deps.readFile(join68(deps.cwd, path2));
90848
91107
  } catch (error2) {
90849
91108
  totals2.failed += 1;
90850
91109
  deps.log(`error: ${label}: cannot read the file: ${error2.message}`);
@@ -91360,7 +91619,7 @@ __export(sandbox_run_exports, {
91360
91619
  sandboxesNotReleased: () => sandboxesNotReleased,
91361
91620
  scopeOrRefuse: () => scopeOrRefuse
91362
91621
  });
91363
- import { readFileSync as readFileSync29 } from "node:fs";
91622
+ import { readFileSync as readFileSync30 } from "node:fs";
91364
91623
  function refusalOf3(err2) {
91365
91624
  const text6 = errorMessage3(err2);
91366
91625
  const match = /^Error \d+ from \S+: ([\s\S]*)$/.exec(text6);
@@ -91450,7 +91709,7 @@ async function sandboxRun(opts, writer = stdoutWriter, deps = {}) {
91450
91709
  let prompt = opts.prompt;
91451
91710
  if (opts.promptFile !== void 0) {
91452
91711
  try {
91453
- prompt = (deps.readFile ?? ((p) => readFileSync29(p, "utf8")))(
91712
+ prompt = (deps.readFile ?? ((p) => readFileSync30(p, "utf8")))(
91454
91713
  opts.promptFile
91455
91714
  );
91456
91715
  } catch (err2) {
@@ -95489,7 +95748,7 @@ function der(tag, content) {
95489
95748
  out.set(content, head3.length);
95490
95749
  return out;
95491
95750
  }
95492
- function join68(parts) {
95751
+ function join69(parts) {
95493
95752
  const out = new Uint8Array(parts.reduce((n2, p) => n2 + p.length, 0));
95494
95753
  let at2 = 0;
95495
95754
  for (const p of parts) {
@@ -95556,10 +95815,10 @@ var init_der = __esm({
95556
95815
  SEQUENCE: 48,
95557
95816
  SET: 49
95558
95817
  };
95559
- seq = (...parts) => der(TAG.SEQUENCE, join68(parts));
95818
+ seq = (...parts) => der(TAG.SEQUENCE, join69(parts));
95560
95819
  setOf = (...parts) => der(
95561
95820
  TAG.SET,
95562
- join68(
95821
+ join69(
95563
95822
  [...parts].sort((a, b3) => {
95564
95823
  const n2 = Math.min(a.length, b3.length);
95565
95824
  for (let i2 = 0; i2 < n2; i2 += 1) {
@@ -95575,7 +95834,7 @@ var init_der = __esm({
95575
95834
  nullValue = () => der(TAG.NULL, new Uint8Array());
95576
95835
  bool3 = (v) => der(TAG.BOOLEAN, Uint8Array.of(v ? 255 : 0));
95577
95836
  utf8 = (text6) => der(TAG.UTF8_STRING, new TextEncoder().encode(text6));
95578
- bitString = (bytes) => der(TAG.BIT_STRING, join68([Uint8Array.of(0), bytes]));
95837
+ bitString = (bytes) => der(TAG.BIT_STRING, join69([Uint8Array.of(0), bytes]));
95579
95838
  }
95580
95839
  });
95581
95840
 
@@ -98272,9 +98531,9 @@ var init_host = __esm({
98272
98531
  });
98273
98532
 
98274
98533
  // src/lib/harnesses.ts
98275
- import { accessSync as accessSync4, constants as constants9, statSync as statSync19 } from "node:fs";
98534
+ import { accessSync as accessSync4, constants as constants10, statSync as statSync19 } from "node:fs";
98276
98535
  import { homedir as homedir12 } from "node:os";
98277
- import { delimiter as delimiter4, join as join69 } from "node:path";
98536
+ import { delimiter as delimiter4, join as join70 } from "node:path";
98278
98537
  async function terminalDirs() {
98279
98538
  const { harnessPath: harnessPath2, loginShellPath: loginShellPath2 } = await Promise.resolve().then(() => (init_host(), host_exports));
98280
98539
  const env = process.env;
@@ -98284,7 +98543,7 @@ async function terminalDirs() {
98284
98543
  function isExecutableFile(path2) {
98285
98544
  try {
98286
98545
  if (!statSync19(path2).isFile()) return false;
98287
- accessSync4(path2, constants9.X_OK);
98546
+ accessSync4(path2, constants10.X_OK);
98288
98547
  return true;
98289
98548
  } catch {
98290
98549
  return false;
@@ -98300,7 +98559,7 @@ async function detectHarnesses(deps = {}) {
98300
98559
  const found = [];
98301
98560
  for (const harness of WRAPPED_HARNESSES) {
98302
98561
  const names2 = commandNames(HARNESS_BINARY[harness], platform2);
98303
- const path2 = dirs.flatMap((dir) => names2.map((name2) => join69(dir, name2))).find(isExecutable2);
98562
+ const path2 = dirs.flatMap((dir) => names2.map((name2) => join70(dir, name2))).find(isExecutable2);
98304
98563
  if (path2 !== void 0) {
98305
98564
  found.push({ harness, label: harnessLabel2(harness), path: path2 });
98306
98565
  }
@@ -98347,13 +98606,13 @@ import {
98347
98606
  existsSync as existsSync31,
98348
98607
  lstatSync as lstatSync13,
98349
98608
  mkdirSync as mkdirSync13,
98350
- readFileSync as readFileSync30,
98609
+ readFileSync as readFileSync31,
98351
98610
  readdirSync as readdirSync18,
98352
98611
  realpathSync as realpathSync10,
98353
98612
  writeFileSync as writeFileSync10
98354
98613
  } from "node:fs";
98355
98614
  import { homedir as homedir13, hostname as osHostname3 } from "node:os";
98356
- import { join as join70, resolve as resolve24, sep as sep10 } from "node:path";
98615
+ import { join as join71, resolve as resolve24, sep as sep10 } from "node:path";
98357
98616
  function git3(cwd, args) {
98358
98617
  return new Promise((done) => {
98359
98618
  try {
@@ -98400,7 +98659,7 @@ function parseRemoteRepository(url2) {
98400
98659
  }
98401
98660
  function oxagenPresent(root) {
98402
98661
  try {
98403
- return readdirSync18(join70(root, ".oxagen")).some(
98662
+ return readdirSync18(join71(root, ".oxagen")).some(
98404
98663
  (name2) => name2 !== "workspace.json"
98405
98664
  );
98406
98665
  } catch {
@@ -98409,18 +98668,18 @@ function oxagenPresent(root) {
98409
98668
  }
98410
98669
  function symlinkState(root) {
98411
98670
  try {
98412
- if (!lstatSync13(join70(root, ".stella")).isDirectory()) return "none";
98671
+ if (!lstatSync13(join71(root, ".stella")).isDirectory()) return "none";
98413
98672
  } catch {
98414
98673
  return "none";
98415
98674
  }
98416
98675
  let oxagenReal;
98417
98676
  try {
98418
- oxagenReal = realpathSync10(join70(root, ".oxagen"));
98677
+ oxagenReal = realpathSync10(join71(root, ".oxagen"));
98419
98678
  } catch {
98420
98679
  return "missing";
98421
98680
  }
98422
98681
  for (const link of STELLA_LINKS) {
98423
- const at2 = join70(root, link);
98682
+ const at2 = join71(root, link);
98424
98683
  try {
98425
98684
  if (!lstatSync13(at2).isSymbolicLink()) return "missing";
98426
98685
  const target = realpathSync10(at2);
@@ -98434,11 +98693,11 @@ function symlinkState(root) {
98434
98693
  return "linked";
98435
98694
  }
98436
98695
  function machineId(configDir = getConfigDir()) {
98437
- const file = join70(configDir, MACHINE_ID_FILE);
98696
+ const file = join71(configDir, MACHINE_ID_FILE);
98438
98697
  let secret = null;
98439
98698
  try {
98440
98699
  if (existsSync31(file)) {
98441
- const stored = readFileSync30(file, "utf8").trim();
98700
+ const stored = readFileSync31(file, "utf8").trim();
98442
98701
  if (/^[0-9a-f]{64}$/.test(stored)) secret = stored;
98443
98702
  }
98444
98703
  if (secret === null) {
@@ -98896,10 +99155,10 @@ function scopeOf(opts, out) {
98896
99155
  }
98897
99156
  async function machineRegister(opts, writer = stdoutWriter, deps = {}) {
98898
99157
  const out = createOutput({ json: opts.json }, writer);
98899
- const refused2 = { ok: false, enrolled: false };
99158
+ const refused3 = { ok: false, enrolled: false };
98900
99159
  if (!opts.harness) {
98901
99160
  out.error(`Pass --harness: ${HARNESS_CHOICES}.`, "usage");
98902
- return refused2;
99161
+ return refused3;
98903
99162
  }
98904
99163
  const harness = harnessName(opts.harness);
98905
99164
  if (!isMachineHarness(harness)) {
@@ -98907,7 +99166,7 @@ async function machineRegister(opts, writer = stdoutWriter, deps = {}) {
98907
99166
  `--harness takes ${HARNESS_CHOICES}. "${opts.harness}" is not one.`,
98908
99167
  "usage"
98909
99168
  );
98910
- return refused2;
99169
+ return refused3;
98911
99170
  }
98912
99171
  const machineName = (opts.machineName ?? (deps.hostname ?? hostname2)()).trim();
98913
99172
  if (machineName === "") {
@@ -98915,10 +99174,10 @@ async function machineRegister(opts, writer = stdoutWriter, deps = {}) {
98915
99174
  opts.machineName === void 0 ? "This machine reports no host name. Pass --machine-name <name>." : "--machine-name is empty. Pass the machine's host name.",
98916
99175
  "usage"
98917
99176
  );
98918
- return refused2;
99177
+ return refused3;
98919
99178
  }
98920
99179
  const scope = scopeOf(opts, out);
98921
- if (!scope) return refused2;
99180
+ if (!scope) return refused3;
98922
99181
  let answer;
98923
99182
  try {
98924
99183
  answer = await apiPostOrThrow(
@@ -98936,7 +99195,7 @@ async function machineRegister(opts, writer = stdoutWriter, deps = {}) {
98936
99195
  } catch (err2) {
98937
99196
  const refusal = refusalOf3(err2);
98938
99197
  out.error(refusal.message, refusal.reason ?? "api");
98939
- return refused2;
99198
+ return refused3;
98940
99199
  }
98941
99200
  if (opts.enroll !== true) {
98942
99201
  if (out.isJson) {
@@ -99879,8 +100138,8 @@ async function workspaceConnect(argument, opts, writer = stdoutWriter, deps = {}
99879
100138
  const connection = await device.read();
99880
100139
  if (connection !== void 0 && connection.workspace_id !== found.id) {
99881
100140
  servedElsewhere = `${connection.org_slug}/${connection.workspace_slug}`;
99882
- const { failed: refused2 } = await device.standByOutside();
99883
- for (const outcome of refused2)
100141
+ const { failed: refused3 } = await device.standByOutside();
100142
+ for (const outcome of refused3)
99884
100143
  out.warn(
99885
100144
  `${outcome.agentKey} could not stop taking sends from ${outcome.workspace}: ${outcome.message ?? ""} This machine still refuses that work when it arrives.`
99886
100145
  );
@@ -101308,7 +101567,7 @@ function dayRangeSchemaOf(maxDays) {
101308
101567
  path: ["to"]
101309
101568
  });
101310
101569
  }
101311
- var costBasisSchema, microsSchema, moneySchema, costSchema, daySchema, monthSchema, SPEND_RANGE_DAYS_MAX, DAY_MS, dayRangeSchema, principalPublicIdSchema, tokenCountsSchema, standingTokensSchema, spendGroupKindSchema, ratioSchema, spendFigureSchema, spendDaySchema, unmeteredRunsSchema;
101570
+ var costBasisSchema, microsSchema, moneySchema, costSchema, daySchema, monthSchema, SPEND_RANGE_DAYS_MAX, DAY_MS, dayRangeSchema, principalPublicIdSchema, tokenCountsSchema, standingTokensSchema, spendGroupKindSchema, ratioSchema, FIGURES_PULL_REQUEST_URL_MAX, runFiguresSchema, spendFigureSchema, spendDaySchema, unmeteredRunsSchema;
101312
101571
  var init_spend_shared = __esm({
101313
101572
  "../../packages/oxagen/src/contracts/spend.shared.ts"() {
101314
101573
  "use strict";
@@ -101365,13 +101624,53 @@ var init_spend_shared = __esm({
101365
101624
  "cost_center"
101366
101625
  ]);
101367
101626
  ratioSchema = external_exports.number().min(0).max(1);
101627
+ FIGURES_PULL_REQUEST_URL_MAX = 50;
101628
+ runFiguresSchema = external_exports.object({
101629
+ tokens: external_exports.object({
101630
+ /** Every input class: uncached input, cache reads and cache writes. */
101631
+ input: external_exports.number().int().nonnegative(),
101632
+ /** Output and reasoning. */
101633
+ output: external_exports.number().int().nonnegative(),
101634
+ /** Input the cache served, inside `input`. */
101635
+ cacheRead: external_exports.number().int().nonnegative(),
101636
+ /** Input written to the cache, both lifetimes, inside `input`. */
101637
+ cacheWrite: external_exports.number().int().nonnegative(),
101638
+ /** `input` plus `output`. */
101639
+ total: external_exports.number().int().nonnegative()
101640
+ }).strict(),
101641
+ /**
101642
+ * Zero for a run that used no model. Null when a model was used and the
101643
+ * rollup could price none of it, or when a work item's runs cost in more
101644
+ * than one currency.
101645
+ */
101646
+ cost: costSchema.nullable(),
101647
+ /** A sum: zero when nothing shows a change. */
101648
+ lines: external_exports.object({
101649
+ added: external_exports.number().int().nonnegative(),
101650
+ removed: external_exports.number().int().nonnegative()
101651
+ }).strict(),
101652
+ /** How many pull requests, each once. */
101653
+ pullRequests: external_exports.number().int().nonnegative(),
101654
+ /** Their URLs in one standard form, sorted, up to FIGURES_PULL_REQUEST_URL_MAX. */
101655
+ pullRequestUrls: external_exports.array(external_exports.string().url()).max(FIGURES_PULL_REQUEST_URL_MAX),
101656
+ /**
101657
+ * True until the run ends and the rollup that read its end lands. A
101658
+ * work item's figures are an estimate while any of its runs' are.
101659
+ */
101660
+ estimate: external_exports.boolean()
101661
+ }).strict();
101368
101662
  spendFigureSchema = external_exports.object({
101369
101663
  /** Null when no frame in the group was priced. */
101370
101664
  cost: costSchema.nullable(),
101371
101665
  calls: external_exports.number().int().nonnegative(),
101372
101666
  runs: external_exports.number().int().nonnegative(),
101373
101667
  accepted: moneySchema.nullable(),
101374
- productiveRatio: ratioSchema.nullable()
101668
+ /**
101669
+ * Advanced steps over graded steps (ADR-199). It counts steps, never
101670
+ * spend: unproductive spend is what finding claims price (ADR-208,
101671
+ * ADR-8994). Null when no run in the group was graded.
101672
+ */
101673
+ advancedStepShare: ratioSchema.nullable()
101375
101674
  }).strict();
101376
101675
  spendDaySchema = external_exports.object({
101377
101676
  day: daySchema,
@@ -101555,6 +101854,8 @@ var init_workspace_settings = __esm({
101555
101854
  alwaysOnTokens: "alwaysOnTokens",
101556
101855
  /** The memory half-life: steering-repo/governance.ts. */
101557
101856
  memoryHalfLifeDays: "memoryHalfLifeDays",
101857
+ /** What a model call does when required steering does not fit: steering-repo/governance.ts. */
101858
+ steeringOverBudget: "steeringOverBudget",
101558
101859
  /** The provider search mode ranks with: steering-repo/workspace.ts. */
101559
101860
  embeddings: "embeddings",
101560
101861
  /** The Stella archive delay in days: steering-repo/workspace.ts. */
@@ -106754,6 +107055,9 @@ var init_steering_markdown_import_shared = __esm({
106754
107055
  function findingIdentity(finding) {
106755
107056
  return IDENTITIES.get(finding) ?? finding.message;
106756
107057
  }
107058
+ function identityIgnoresField(finding) {
107059
+ return FIELDLESS.has(finding);
107060
+ }
106757
107061
  function finder(check3) {
106758
107062
  return (init) => {
106759
107063
  const finding = {
@@ -106769,6 +107073,7 @@ function finder(check3) {
106769
107073
  };
106770
107074
  if (init.detail !== void 0) finding.detail = init.detail;
106771
107075
  if (init.identity !== void 0) IDENTITIES.set(finding, init.identity);
107076
+ if (init.identityIgnoresField === true) FIELDLESS.add(finding);
106772
107077
  return finding;
106773
107078
  };
106774
107079
  }
@@ -106783,11 +107088,12 @@ function sentence(message2) {
106783
107088
  const first = trimmed.charAt(0).toUpperCase() + trimmed.slice(1);
106784
107089
  return /[.?]$/.test(first) ? first : `${first}.`;
106785
107090
  }
106786
- var IDENTITIES;
107091
+ var IDENTITIES, FIELDLESS;
106787
107092
  var init_finding = __esm({
106788
107093
  "../../packages/steering-check/src/finding.ts"() {
106789
107094
  "use strict";
106790
107095
  IDENTITIES = /* @__PURE__ */ new WeakMap();
107096
+ FIELDLESS = /* @__PURE__ */ new WeakSet();
106791
107097
  }
106792
107098
  });
106793
107099
 
@@ -106818,7 +107124,7 @@ var init_toolbelt_shared = __esm({
106818
107124
  });
106819
107125
 
106820
107126
  // ../../packages/oxagen/src/contracts/agent.list.ts
106821
- var instant4, agentHarnessSchema, agentIdentityStatusSchema, agentEnforcementTierSchema, agentListItem, agentList;
107127
+ var instant4, AGENT_LIST_ORDERS, agentHarnessSchema, agentIdentityStatusSchema, agentEnforcementTierSchema, agentListItem, agentList;
106822
107128
  var init_agent_list = __esm({
106823
107129
  "../../packages/oxagen/src/contracts/agent.list.ts"() {
106824
107130
  "use strict";
@@ -106828,6 +107134,7 @@ var init_agent_list = __esm({
106828
107134
  init_spend_shared();
106829
107135
  init_toolbelt_shared();
106830
107136
  instant4 = external_exports.string().datetime({ offset: true });
107137
+ AGENT_LIST_ORDERS = ["slug", "updated"];
106831
107138
  agentHarnessSchema = external_exports.enum([
106832
107139
  "stella",
106833
107140
  "claude-code",
@@ -106952,7 +107259,13 @@ var init_agent_list = __esm({
106952
107259
  hosts: external_exports.number().int().nonnegative(),
106953
107260
  /** The hostname of the live host seen most recently; null when none is live. */
106954
107261
  host: external_exports.string().nullable(),
106955
- registeredAt: instant4
107262
+ registeredAt: instant4,
107263
+ /**
107264
+ * When a person last changed the agent: the later of the last write to its
107265
+ * row and to its principal, since a suspend or resume writes the principal
107266
+ * alone.
107267
+ */
107268
+ updatedAt: instant4
106956
107269
  }).strict();
106957
107270
  agentList = registerCapability({
106958
107271
  name: "list_agents",
@@ -106985,7 +107298,15 @@ var init_agent_list = __esm({
106985
107298
  * agent for work never sees one unless it asks. Pass the same value on
106986
107299
  * every page of one walk. The totals ignore it.
106987
107300
  */
106988
- includeRetired: external_exports.boolean().default(false)
107301
+ includeRetired: external_exports.boolean().default(false),
107302
+ /**
107303
+ * The walk's order: `slug`, or `updated` for the newest change first, by
107304
+ * the time `items[].updatedAt` carries. A caller that shows the newest
107305
+ * changes reads them from the first page this way. Pass the same value
107306
+ * on every page of one walk, because a cursor from the other order
107307
+ * starts over at the first page.
107308
+ */
107309
+ order: external_exports.enum(AGENT_LIST_ORDERS).default("slug")
106989
107310
  }).strict(),
106990
107311
  output: external_exports.object({
106991
107312
  items: external_exports.array(agentListItem).max(100),
@@ -109315,7 +109636,7 @@ var init_codegraph_settings = __esm({
109315
109636
  }).strict(),
109316
109637
  "repos"
109317
109638
  ).optional().describe(
109318
- "One row per linked code repository: its source tags and what its builds read. A repository with no row takes the defaults."
109639
+ "One row per linked code repository: its source tags and what its builds read. A repository with no row takes the defaults. Only a repository with a row gets the Code graph freshness check on its pull requests."
109319
109640
  )
109320
109641
  }).strict();
109321
109642
  CODEGRAPH_SOURCES_DEFAULTS = {
@@ -110019,10 +110340,11 @@ var init_delivery = __esm({
110019
110340
  });
110020
110341
 
110021
110342
  // ../../packages/oxagen/src/steering-repo/governance.ts
110022
- var ledgerRotationSchema, governanceSchema, ALWAYS_ON_TOKENS_SETTING, MEMORY_HALF_LIFE_SETTING;
110343
+ var ledgerRotationSchema, governanceSchema, ALWAYS_ON_TOKENS_SETTING, MEMORY_HALF_LIFE_SETTING, STEERING_OVER_BUDGET_SETTING;
110023
110344
  var init_governance = __esm({
110024
110345
  "../../packages/oxagen/src/steering-repo/governance.ts"() {
110025
110346
  "use strict";
110347
+ init_model_steering();
110026
110348
  init_zod();
110027
110349
  init_context_steering_shared();
110028
110350
  init_settings_bag();
@@ -110039,6 +110361,9 @@ var init_governance = __esm({
110039
110361
  steering: external_exports.object({
110040
110362
  always_on_tokens: external_exports.union([external_exports.number().int().positive(), external_exports.literal("off")]).optional().describe(
110041
110363
  "The always-on budget per code repository, or off. Unset inherits Oxagen's default, the largest harness hook limit. A budget above that limit fails the budget check."
110364
+ ),
110365
+ over_budget: steeringOverBudgetActionSchema.optional().describe(
110366
+ "What a model call does when the workspace's required steering does not fit the steering budget. none: send it with the steering that fits. recorded: send it and mark the run. warn: send it, mark the run, and warn the person. stop: refuse it until the steering fits. Unset is warn."
110042
110367
  )
110043
110368
  }).strict().optional(),
110044
110369
  ledger: external_exports.object({
@@ -110075,6 +110400,7 @@ var init_governance = __esm({
110075
110400
  );
110076
110401
  ALWAYS_ON_TOKENS_SETTING = WORKSPACE_SETTINGS_KEYS.alwaysOnTokens;
110077
110402
  MEMORY_HALF_LIFE_SETTING = WORKSPACE_SETTINGS_KEYS.memoryHalfLifeDays;
110403
+ STEERING_OVER_BUDGET_SETTING = WORKSPACE_SETTINGS_KEYS.steeringOverBudget;
110078
110404
  }
110079
110405
  });
110080
110406
 
@@ -111990,7 +112316,16 @@ var init_hash2 = __esm({
111990
112316
  field,
111991
112317
  message: published ? "The record changed, but its id and hash still name the published version." : "The record carries an id and hash that Oxagen did not write for this content.",
111992
112318
  expected: `id ${stamp.id} and hash ${stamp.hash}, or no id and hash before the merge.`,
111993
- fix: "Delete the id and hash lines. Oxagen writes them when the steering PR merges."
112319
+ fix: "Delete the id and hash lines. Oxagen writes them when the steering PR merges.",
112320
+ // Whether the record counts as published depends on the base: the
112321
+ // head run knows the base's records, and the base run, which has no
112322
+ // base of its own, knows only the index. An archived record leaves the
112323
+ // index, so the same stale stamp read as unpublished on the base and
112324
+ // published on the head, and every steering PR was blamed for it. The
112325
+ // stamp itself is the identity, so a stamp already on the production
112326
+ // branch stays old.
112327
+ identity: `${file.lineage} ${String(id2)} ${String(hash4)}`,
112328
+ identityIgnoresField: true
111994
112329
  })
111995
112330
  );
111996
112331
  }
@@ -113357,7 +113692,7 @@ function findingKey(finding) {
113357
113692
  finding.check,
113358
113693
  finding.rule,
113359
113694
  finding.path,
113360
- finding.field,
113695
+ identityIgnoresField(finding) ? null : finding.field,
113361
113696
  findingIdentity(finding)
113362
113697
  ]);
113363
113698
  }
@@ -114133,7 +114468,7 @@ __export(steering_import_exports, {
114133
114468
  });
114134
114469
  import { readdir as readdir5, realpath as realpath3, stat as stat5 } from "node:fs/promises";
114135
114470
  import { homedir as homedir14 } from "node:os";
114136
- import { basename as basename11, extname, join as join71, relative as relative9, sep as sep12 } from "node:path";
114471
+ import { basename as basename11, extname, join as join72, relative as relative9, sep as sep12 } from "node:path";
114137
114472
  function envDir2(env, key) {
114138
114473
  const value = env[key];
114139
114474
  return value === void 0 || value.trim() === "" ? null : value;
@@ -114141,34 +114476,34 @@ function envDir2(env, key) {
114141
114476
  function harnessHome(harness, env = process.env, home = homedir14()) {
114142
114477
  switch (harness) {
114143
114478
  case "claude-code": {
114144
- const config2 = envDir2(env, "CLAUDE_CONFIG_DIR") ?? join71(home, ".claude");
114479
+ const config2 = envDir2(env, "CLAUDE_CONFIG_DIR") ?? join72(home, ".claude");
114145
114480
  return {
114146
114481
  harness,
114147
114482
  folders: [
114148
114483
  {
114149
- dir: skillsRoot("claude-code", env, home) ?? join71(config2, "skills"),
114484
+ dir: skillsRoot("claude-code", env, home) ?? join72(config2, "skills"),
114150
114485
  mount: ".claude/skills"
114151
114486
  },
114152
- { dir: join71(config2, "commands"), mount: ".claude/commands" },
114153
- { dir: join71(config2, "agents"), mount: ".claude/agents" }
114487
+ { dir: join72(config2, "commands"), mount: ".claude/commands" },
114488
+ { dir: join72(config2, "agents"), mount: ".claude/agents" }
114154
114489
  ],
114155
114490
  instructions: [
114156
- { file: join71(config2, "CLAUDE.md"), filename: ".claude/CLAUDE.md" }
114491
+ { file: join72(config2, "CLAUDE.md"), filename: ".claude/CLAUDE.md" }
114157
114492
  ]
114158
114493
  };
114159
114494
  }
114160
114495
  case "codex": {
114161
- const codexHome = envDir2(env, "CODEX_HOME") ?? join71(home, ".codex");
114496
+ const codexHome = envDir2(env, "CODEX_HOME") ?? join72(home, ".codex");
114162
114497
  return {
114163
114498
  harness,
114164
114499
  folders: [
114165
114500
  {
114166
- dir: skillsRoot("codex", env, home) ?? join71(home, ".agents", "skills"),
114501
+ dir: skillsRoot("codex", env, home) ?? join72(home, ".agents", "skills"),
114167
114502
  mount: ".agents/skills"
114168
114503
  }
114169
114504
  ],
114170
114505
  instructions: ["AGENTS.override.md", "AGENTS.md"].map((name2) => ({
114171
- file: join71(codexHome, name2),
114506
+ file: join72(codexHome, name2),
114172
114507
  filename: `.codex/${name2}`
114173
114508
  }))
114174
114509
  };
@@ -114177,8 +114512,8 @@ function harnessHome(harness, env = process.env, home = homedir14()) {
114177
114512
  return {
114178
114513
  harness,
114179
114514
  folders: [
114180
- { dir: join71(home, ".cursor", "skills"), mount: ".cursor/skills" },
114181
- { dir: join71(home, ".cursor", "commands"), mount: ".cursor/commands" }
114515
+ { dir: join72(home, ".cursor", "skills"), mount: ".cursor/skills" },
114516
+ { dir: join72(home, ".cursor", "commands"), mount: ".cursor/commands" }
114182
114517
  ],
114183
114518
  instructions: []
114184
114519
  };
@@ -114224,7 +114559,7 @@ async function findMarkdownFiles(paths, harness) {
114224
114559
  }
114225
114560
  const found = [];
114226
114561
  for (const entry2 of entries2.sort(byName)) {
114227
- const path2 = join71(dir, entry2.name);
114562
+ const path2 = join72(dir, entry2.name);
114228
114563
  if (entry2.isDirectory()) {
114229
114564
  if (!entry2.name.startsWith(".") && entry2.name !== "node_modules")
114230
114565
  found.push(...await filesUnder(path2, from));
@@ -114246,7 +114581,7 @@ async function findMarkdownFiles(paths, harness) {
114246
114581
  const { folder } = frame2;
114247
114582
  const named2 = (rel) => frame2.fixedNames ? { filename: rel } : {};
114248
114583
  for (const entry2 of entries2) {
114249
- const path2 = join71(dir, entry2.name);
114584
+ const path2 = join72(dir, entry2.name);
114250
114585
  const rel = frame2.relOf(path2);
114251
114586
  if (entry2.isDirectory()) {
114252
114587
  if (entry2.name === "node_modules") continue;
@@ -114305,7 +114640,7 @@ async function findMarkdownFiles(paths, harness) {
114305
114640
  }
114306
114641
  if (folderGiven) {
114307
114642
  const catalogue = CATALOGUE_FOLDERS.has(basename11(path2));
114308
- const root = catalogue ? join71(path2, "..") : path2;
114643
+ const root = catalogue ? join72(path2, "..") : path2;
114309
114644
  await walk2(path2, {
114310
114645
  relOf: (p) => under(root, p),
114311
114646
  folder: path2,
@@ -115313,6 +115648,7 @@ var init_steering_suggestions = __esm({
115313
115648
  // src/commands/tools.ts
115314
115649
  var tools_exports = {};
115315
115650
  __export(tools_exports, {
115651
+ toolsApproveSchema: () => toolsApproveSchema,
115316
115652
  toolsMigrate: () => toolsMigrate
115317
115653
  });
115318
115654
  async function toolsMigrate(opts = {}, writer = stdoutWriter) {
@@ -115335,6 +115671,29 @@ async function toolsMigrate(opts = {}, writer = stdoutWriter) {
115335
115671
  for (const pr of result2.pullRequests)
115336
115672
  writer.write(`#${pr.number} ${pr.url}`);
115337
115673
  }
115674
+ async function toolsApproveSchema(toolVersionId, opts, writer = stdoutWriter) {
115675
+ const cmd = createOutput({ json: opts.json }, writer);
115676
+ let result2;
115677
+ try {
115678
+ result2 = await apiPostOrThrow(
115679
+ "tools/versions/observed-schema/approve",
115680
+ { toolVersionId, schemaHash: opts.hash }
115681
+ );
115682
+ } catch (err2) {
115683
+ cmd.error(err2, "api");
115684
+ return;
115685
+ }
115686
+ if (cmd.isJson) {
115687
+ cmd.data(result2);
115688
+ return;
115689
+ }
115690
+ writer.write(
115691
+ `Approved the observed output schema of ${result2.toolVersionId} at hash ${result2.schemaHash}.`
115692
+ );
115693
+ writer.write(
115694
+ "An output that fits it now counts as checked against a schema. One that does not puts the schema back up for approval."
115695
+ );
115696
+ }
115338
115697
  var HEADLINES;
115339
115698
  var init_tools2 = __esm({
115340
115699
  "src/commands/tools.ts"() {
@@ -116668,7 +117027,7 @@ __export(credentials_exports, {
116668
117027
  });
116669
117028
  import { spawn as spawn8 } from "node:child_process";
116670
117029
  import { homedir as homedir15 } from "node:os";
116671
- import { join as join72 } from "node:path";
117030
+ import { join as join73 } from "node:path";
116672
117031
  function sharedBody(opts) {
116673
117032
  return opts.shared ? { scope: "workspace" } : {};
116674
117033
  }
@@ -116855,7 +117214,7 @@ async function runHarnessLogin(harness) {
116855
117214
  }
116856
117215
  async function readCodexAuthFile() {
116857
117216
  const host = await Promise.resolve().then(() => (init_host(), host_exports));
116858
- const path2 = join72(host.codexHomeFor(process.env, homedir15()), "auth.json");
117217
+ const path2 = join73(host.codexHomeFor(process.env, homedir15()), "auth.json");
116859
117218
  return { path: path2, text: host.readTextIfExists(path2) };
116860
117219
  }
116861
117220
  function keyFlagOf(key) {
@@ -118550,11 +118909,11 @@ import {
118550
118909
  existsSync as existsSync32,
118551
118910
  mkdirSync as mkdirSync14,
118552
118911
  readdirSync as readdirSync19,
118553
- readFileSync as readFileSync31,
118912
+ readFileSync as readFileSync32,
118554
118913
  statSync as statSync20,
118555
118914
  writeFileSync as writeFileSync11
118556
118915
  } from "node:fs";
118557
- import { dirname as dirname40, join as join73 } from "node:path";
118916
+ import { dirname as dirname40, join as join74 } from "node:path";
118558
118917
  function isBundleName(name2) {
118559
118918
  return BUNDLE_FILES.has(name2) || isClaimBundleName(name2);
118560
118919
  }
@@ -118566,7 +118925,7 @@ function readDirectoryEntries(dir) {
118566
118925
  const entries2 = /* @__PURE__ */ new Map();
118567
118926
  const walk2 = (folder, prefix) => {
118568
118927
  for (const entry2 of readdirSync19(folder)) {
118569
- const path2 = join73(folder, entry2);
118928
+ const path2 = join74(folder, entry2);
118570
118929
  const name2 = `${prefix}${entry2}`;
118571
118930
  if (statSync20(path2).isDirectory()) {
118572
118931
  if (prefix === "" && (entry2 === "heads" || entry2 === "trust"))
@@ -118575,7 +118934,7 @@ function readDirectoryEntries(dir) {
118575
118934
  } else {
118576
118935
  entries2.set(
118577
118936
  name2,
118578
- isBundleName(name2) ? new Uint8Array(readFileSync31(path2)) : UNREAD
118937
+ isBundleName(name2) ? new Uint8Array(readFileSync32(path2)) : UNREAD
118579
118938
  );
118580
118939
  }
118581
118940
  }
@@ -118587,7 +118946,7 @@ function readZipEntries(path2) {
118587
118946
  let raw;
118588
118947
  const skipped2 = [];
118589
118948
  try {
118590
- raw = unzipSync(new Uint8Array(readFileSync31(path2)), {
118949
+ raw = unzipSync(new Uint8Array(readFileSync32(path2)), {
118591
118950
  filter: (file) => {
118592
118951
  const inner = underOneFolder(file.name);
118593
118952
  const read2 = file.originalSize <= MAX_ENTRY_BYTES && (isBundleName(file.name) || inner !== null && isBundleName(inner));
@@ -118798,7 +119157,7 @@ async function writeSampleBundle(dir, writer = stdoutWriter) {
118798
119157
  const { files: files2, pins } = buildSampleClaimBundle();
118799
119158
  const zipped = {};
118800
119159
  for (const [name2, bytes] of files2) {
118801
- const path2 = join73(dir, name2);
119160
+ const path2 = join74(dir, name2);
118802
119161
  mkdirSync14(dirname40(path2), { recursive: true });
118803
119162
  writeFileSync11(path2, bytes);
118804
119163
  zipped[name2] = bytes;
@@ -128695,11 +129054,11 @@ var require_codegen = __commonJS({
128695
129054
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
128696
129055
  return `${varKind} ${this.name}${rhs};` + _n;
128697
129056
  }
128698
- optimizeNames(names2, constants10) {
129057
+ optimizeNames(names2, constants11) {
128699
129058
  if (!names2[this.name.str])
128700
129059
  return;
128701
129060
  if (this.rhs)
128702
- this.rhs = optimizeExpr(this.rhs, names2, constants10);
129061
+ this.rhs = optimizeExpr(this.rhs, names2, constants11);
128703
129062
  return this;
128704
129063
  }
128705
129064
  get names() {
@@ -128716,10 +129075,10 @@ var require_codegen = __commonJS({
128716
129075
  render({ _n }) {
128717
129076
  return `${this.lhs} = ${this.rhs};` + _n;
128718
129077
  }
128719
- optimizeNames(names2, constants10) {
129078
+ optimizeNames(names2, constants11) {
128720
129079
  if (this.lhs instanceof code_1.Name && !names2[this.lhs.str] && !this.sideEffects)
128721
129080
  return;
128722
- this.rhs = optimizeExpr(this.rhs, names2, constants10);
129081
+ this.rhs = optimizeExpr(this.rhs, names2, constants11);
128723
129082
  return this;
128724
129083
  }
128725
129084
  get names() {
@@ -128780,8 +129139,8 @@ var require_codegen = __commonJS({
128780
129139
  optimizeNodes() {
128781
129140
  return `${this.code}` ? this : void 0;
128782
129141
  }
128783
- optimizeNames(names2, constants10) {
128784
- this.code = optimizeExpr(this.code, names2, constants10);
129142
+ optimizeNames(names2, constants11) {
129143
+ this.code = optimizeExpr(this.code, names2, constants11);
128785
129144
  return this;
128786
129145
  }
128787
129146
  get names() {
@@ -128810,12 +129169,12 @@ var require_codegen = __commonJS({
128810
129169
  }
128811
129170
  return nodes.length > 0 ? this : void 0;
128812
129171
  }
128813
- optimizeNames(names2, constants10) {
129172
+ optimizeNames(names2, constants11) {
128814
129173
  const { nodes } = this;
128815
129174
  let i2 = nodes.length;
128816
129175
  while (i2--) {
128817
129176
  const n2 = nodes[i2];
128818
- if (n2.optimizeNames(names2, constants10))
129177
+ if (n2.optimizeNames(names2, constants11))
128819
129178
  continue;
128820
129179
  subtractNames(names2, n2.names);
128821
129180
  nodes.splice(i2, 1);
@@ -128868,12 +129227,12 @@ var require_codegen = __commonJS({
128868
129227
  return void 0;
128869
129228
  return this;
128870
129229
  }
128871
- optimizeNames(names2, constants10) {
129230
+ optimizeNames(names2, constants11) {
128872
129231
  var _a2;
128873
- this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants10);
128874
- if (!(super.optimizeNames(names2, constants10) || this.else))
129232
+ this.else = (_a2 = this.else) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants11);
129233
+ if (!(super.optimizeNames(names2, constants11) || this.else))
128875
129234
  return;
128876
- this.condition = optimizeExpr(this.condition, names2, constants10);
129235
+ this.condition = optimizeExpr(this.condition, names2, constants11);
128877
129236
  return this;
128878
129237
  }
128879
129238
  get names() {
@@ -128896,10 +129255,10 @@ var require_codegen = __commonJS({
128896
129255
  render(opts) {
128897
129256
  return `for(${this.iteration})` + super.render(opts);
128898
129257
  }
128899
- optimizeNames(names2, constants10) {
128900
- if (!super.optimizeNames(names2, constants10))
129258
+ optimizeNames(names2, constants11) {
129259
+ if (!super.optimizeNames(names2, constants11))
128901
129260
  return;
128902
- this.iteration = optimizeExpr(this.iteration, names2, constants10);
129261
+ this.iteration = optimizeExpr(this.iteration, names2, constants11);
128903
129262
  return this;
128904
129263
  }
128905
129264
  get names() {
@@ -128935,10 +129294,10 @@ var require_codegen = __commonJS({
128935
129294
  render(opts) {
128936
129295
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
128937
129296
  }
128938
- optimizeNames(names2, constants10) {
128939
- if (!super.optimizeNames(names2, constants10))
129297
+ optimizeNames(names2, constants11) {
129298
+ if (!super.optimizeNames(names2, constants11))
128940
129299
  return;
128941
- this.iterable = optimizeExpr(this.iterable, names2, constants10);
129300
+ this.iterable = optimizeExpr(this.iterable, names2, constants11);
128942
129301
  return this;
128943
129302
  }
128944
129303
  get names() {
@@ -128980,11 +129339,11 @@ var require_codegen = __commonJS({
128980
129339
  (_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNodes();
128981
129340
  return this;
128982
129341
  }
128983
- optimizeNames(names2, constants10) {
129342
+ optimizeNames(names2, constants11) {
128984
129343
  var _a2, _b2;
128985
- super.optimizeNames(names2, constants10);
128986
- (_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants10);
128987
- (_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNames(names2, constants10);
129344
+ super.optimizeNames(names2, constants11);
129345
+ (_a2 = this.catch) === null || _a2 === void 0 ? void 0 : _a2.optimizeNames(names2, constants11);
129346
+ (_b2 = this.finally) === null || _b2 === void 0 ? void 0 : _b2.optimizeNames(names2, constants11);
128988
129347
  return this;
128989
129348
  }
128990
129349
  get names() {
@@ -129285,7 +129644,7 @@ var require_codegen = __commonJS({
129285
129644
  function addExprNames(names2, from) {
129286
129645
  return from instanceof code_1._CodeOrName ? addNames(names2, from.names) : names2;
129287
129646
  }
129288
- function optimizeExpr(expr, names2, constants10) {
129647
+ function optimizeExpr(expr, names2, constants11) {
129289
129648
  if (expr instanceof code_1.Name)
129290
129649
  return replaceName(expr);
129291
129650
  if (!canOptimize(expr))
@@ -129300,14 +129659,14 @@ var require_codegen = __commonJS({
129300
129659
  return items;
129301
129660
  }, []));
129302
129661
  function replaceName(n2) {
129303
- const c = constants10[n2.str];
129662
+ const c = constants11[n2.str];
129304
129663
  if (c === void 0 || names2[n2.str] !== 1)
129305
129664
  return n2;
129306
129665
  delete names2[n2.str];
129307
129666
  return c;
129308
129667
  }
129309
129668
  function canOptimize(e) {
129310
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 && constants10[c.str] !== void 0);
129669
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names2[c.str] === 1 && constants11[c.str] !== void 0);
129311
129670
  }
129312
129671
  }
129313
129672
  function subtractNames(names2, from) {
@@ -135470,12 +135829,12 @@ var require_dist2 = __commonJS({
135470
135829
  throw new Error(`Unknown format "${name2}"`);
135471
135830
  return f;
135472
135831
  };
135473
- function addFormats(ajv, list2, fs4, exportName) {
135832
+ function addFormats(ajv, list2, fs3, exportName) {
135474
135833
  var _a2;
135475
135834
  var _b2;
135476
135835
  (_a2 = (_b2 = ajv.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
135477
135836
  for (const f of list2)
135478
- ajv.addFormat(f, fs4[f]);
135837
+ ajv.addFormat(f, fs3[f]);
135479
135838
  }
135480
135839
  module.exports = exports = formatsPlugin;
135481
135840
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -149090,17 +149449,17 @@ var require_codegen2 = __commonJS({
149090
149449
  var require_fs = __commonJS({
149091
149450
  "../../node_modules/.pnpm/@protobufjs+fetch@1.1.1/node_modules/@protobufjs/fetch/util/fs.js"(exports, module) {
149092
149451
  "use strict";
149093
- var fs4 = null;
149452
+ var fs3 = null;
149094
149453
  try {
149095
- fs4 = __require(
149454
+ fs3 = __require(
149096
149455
  /* webpackIgnore: true */
149097
149456
  "fs"
149098
149457
  );
149099
- if (!fs4 || !fs4.readFile || !fs4.readFileSync)
149100
- fs4 = null;
149458
+ if (!fs3 || !fs3.readFile || !fs3.readFileSync)
149459
+ fs3 = null;
149101
149460
  } catch (e) {
149102
149461
  }
149103
- module.exports = fs4;
149462
+ module.exports = fs3;
149104
149463
  }
149105
149464
  });
149106
149465
 
@@ -149110,7 +149469,7 @@ var require_fetch = __commonJS({
149110
149469
  "use strict";
149111
149470
  module.exports = fetch2;
149112
149471
  var asPromise = require_aspromise();
149113
- var fs4 = require_fs();
149472
+ var fs3 = require_fs();
149114
149473
  function fetch2(filename, options, callback) {
149115
149474
  if (typeof options === "function") {
149116
149475
  callback = options;
@@ -149119,8 +149478,8 @@ var require_fetch = __commonJS({
149119
149478
  options = {};
149120
149479
  if (!callback)
149121
149480
  return asPromise(fetch2, this, filename, options);
149122
- if (!options.xhr && fs4 && fs4.readFile)
149123
- return fs4.readFile(filename, function fetchReadFileCallback(err2, contents) {
149481
+ if (!options.xhr && fs3 && fs3.readFile)
149482
+ return fs3.readFile(filename, function fetchReadFileCallback(err2, contents) {
149124
149483
  return err2 && typeof XMLHttpRequest !== "undefined" ? fetch2.xhr(filename, options, callback) : err2 ? callback(err2) : callback(null, options.binary ? contents : contents.toString("utf8"));
149125
149484
  });
149126
149485
  return fetch2.xhr(filename, options, callback);
@@ -149223,17 +149582,17 @@ var require_patterns = __commonJS({
149223
149582
  var require_fs2 = __commonJS({
149224
149583
  "../../node_modules/.pnpm/protobufjs@7.6.5/node_modules/protobufjs/src/util/fs.js"(exports, module) {
149225
149584
  "use strict";
149226
- var fs4 = null;
149585
+ var fs3 = null;
149227
149586
  try {
149228
- fs4 = __require(
149587
+ fs3 = __require(
149229
149588
  /* webpackIgnore: true */
149230
149589
  "fs"
149231
149590
  );
149232
- if (!fs4 || !fs4.readFile || !fs4.readFileSync)
149233
- fs4 = null;
149591
+ if (!fs3 || !fs3.readFile || !fs3.readFileSync)
149592
+ fs3 = null;
149234
149593
  } catch (e) {
149235
149594
  }
149236
- module.exports = fs4;
149595
+ module.exports = fs3;
149237
149596
  }
149238
149597
  });
149239
149598
 
@@ -161961,14 +162320,14 @@ var require_tls_helpers = __commonJS({
161961
162320
  Object.defineProperty(exports, "__esModule", { value: true });
161962
162321
  exports.CIPHER_SUITES = void 0;
161963
162322
  exports.getDefaultRootsData = getDefaultRootsData;
161964
- var fs4 = __require("fs");
162323
+ var fs3 = __require("fs");
161965
162324
  exports.CIPHER_SUITES = process.env.GRPC_SSL_CIPHER_SUITES;
161966
162325
  var DEFAULT_ROOTS_FILE_PATH = process.env.GRPC_DEFAULT_SSL_ROOTS_FILE_PATH;
161967
162326
  var defaultRootsData = null;
161968
162327
  function getDefaultRootsData() {
161969
162328
  if (DEFAULT_ROOTS_FILE_PATH) {
161970
162329
  if (defaultRootsData === null) {
161971
- defaultRootsData = fs4.readFileSync(DEFAULT_ROOTS_FILE_PATH);
162330
+ defaultRootsData = fs3.readFileSync(DEFAULT_ROOTS_FILE_PATH);
161972
162331
  }
161973
162332
  return defaultRootsData;
161974
162333
  }
@@ -168384,7 +168743,7 @@ var require_util3 = __commonJS({
168384
168743
  "use strict";
168385
168744
  Object.defineProperty(exports, "__esModule", { value: true });
168386
168745
  exports.addCommonProtos = exports.loadProtosWithOptionsSync = exports.loadProtosWithOptions = void 0;
168387
- var fs4 = __require("fs");
168746
+ var fs3 = __require("fs");
168388
168747
  var path2 = __require("path");
168389
168748
  var Protobuf = require_protobufjs();
168390
168749
  function addIncludePathResolver(root, includePaths) {
@@ -168396,7 +168755,7 @@ var require_util3 = __commonJS({
168396
168755
  for (const directory of includePaths) {
168397
168756
  const fullPath = path2.join(directory, target);
168398
168757
  try {
168399
- fs4.accessSync(fullPath, fs4.constants.R_OK);
168758
+ fs3.accessSync(fullPath, fs3.constants.R_OK);
168400
168759
  return fullPath;
168401
168760
  } catch (err2) {
168402
168761
  continue;
@@ -177492,7 +177851,7 @@ var require_certificate_provider = __commonJS({
177492
177851
  "use strict";
177493
177852
  Object.defineProperty(exports, "__esModule", { value: true });
177494
177853
  exports.FileWatcherCertificateProvider = void 0;
177495
- var fs4 = __require("fs");
177854
+ var fs3 = __require("fs");
177496
177855
  var logging = require_logging();
177497
177856
  var constants_1 = require_constants();
177498
177857
  var util_1 = __require("util");
@@ -177500,7 +177859,7 @@ var require_certificate_provider = __commonJS({
177500
177859
  function trace(text6) {
177501
177860
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text6);
177502
177861
  }
177503
- var readFilePromise = (0, util_1.promisify)(fs4.readFile);
177862
+ var readFilePromise = (0, util_1.promisify)(fs3.readFile);
177504
177863
  var FileWatcherCertificateProvider = class {
177505
177864
  constructor(config2) {
177506
177865
  this.config = config2;
@@ -182396,11 +182755,11 @@ import { createHash as createHash32 } from "node:crypto";
182396
182755
  import {
182397
182756
  lstatSync as lstatSync14,
182398
182757
  mkdirSync as mkdirSync15,
182399
- readFileSync as readFileSync32,
182758
+ readFileSync as readFileSync33,
182400
182759
  readlinkSync as readlinkSync4,
182401
182760
  statSync as statSync21
182402
182761
  } from "node:fs";
182403
- import { dirname as dirname41, isAbsolute as isAbsolute19, join as join74, relative as relative10, resolve as resolve28, sep as sep13 } from "node:path";
182762
+ import { dirname as dirname41, isAbsolute as isAbsolute19, join as join75, relative as relative10, resolve as resolve28, sep as sep13 } from "node:path";
182404
182763
  function cloneRepoKind(root) {
182405
182764
  const out = git4(root, ["remote", "get-url", "origin"]);
182406
182765
  const url2 = out?.toString("utf8").trim() ?? "";
@@ -182440,11 +182799,11 @@ function commitOf(root, ref) {
182440
182799
  return sha2.length > 0 ? sha2 : null;
182441
182800
  }
182442
182801
  function readWorkingFile(root, path2) {
182443
- const abs = join74(root, ...path2.split("/"));
182802
+ const abs = join75(root, ...path2.split("/"));
182444
182803
  try {
182445
182804
  const stat7 = lstatSync14(abs);
182446
182805
  if (stat7.isSymbolicLink()) return readlinkSync4(abs, "utf8");
182447
- return stat7.isFile() ? readFileSync32(abs, "utf8") : null;
182806
+ return stat7.isFile() ? readFileSync33(abs, "utf8") : null;
182448
182807
  } catch {
182449
182808
  return null;
182450
182809
  }
@@ -182534,7 +182893,7 @@ function isDir(path2) {
182534
182893
  function findSteeringRoot(start) {
182535
182894
  let dir = resolve28(start);
182536
182895
  for (; ; ) {
182537
- if (isFile(join74(dir, WORKSPACE_TOML_PATH)) || isFile(join74(dir, AGENTS_MD_PATH)) && isDir(join74(dir, STEERING_DIR))) {
182896
+ if (isFile(join75(dir, WORKSPACE_TOML_PATH)) || isFile(join75(dir, AGENTS_MD_PATH)) && isDir(join75(dir, STEERING_DIR))) {
182538
182897
  return dir;
182539
182898
  }
182540
182899
  const parent = dirname41(dir);
@@ -182614,12 +182973,12 @@ function cacheFile(cacheDir, root) {
182614
182973
  key: token === void 0 ? null : createHash32("sha256").update(token).digest("hex").slice(0, 16)
182615
182974
  };
182616
182975
  const key = createHash32("sha256").update(JSON.stringify([root, identity])).digest("hex").slice(0, 32);
182617
- return join74(cacheDir, `${key}.json`);
182976
+ return join75(cacheDir, `${key}.json`);
182618
182977
  }
182619
182978
  function readCache(file, now) {
182620
182979
  let entry2;
182621
182980
  try {
182622
- entry2 = JSON.parse(readFileSync32(file, "utf8"));
182981
+ entry2 = JSON.parse(readFileSync33(file, "utf8"));
182623
182982
  } catch {
182624
182983
  return null;
182625
182984
  }
@@ -182728,7 +183087,7 @@ function defaultDeps2() {
182728
183087
  return {
182729
183088
  fetchPublished: fetchSteeringIndex,
182730
183089
  cedar: cedarHooks,
182731
- cacheDir: join74(getConfigDir(), "cache", "steering-check"),
183090
+ cacheDir: join75(getConfigDir(), "cache", "steering-check"),
182732
183091
  now: () => Date.now()
182733
183092
  };
182734
183093
  }
@@ -184694,7 +185053,7 @@ __export(secret_exports, {
184694
185053
  handleSecretReveal: () => handleSecretReveal,
184695
185054
  handleSecretSet: () => handleSecretSet
184696
185055
  });
184697
- import { readFileSync as readFileSync33, writeFileSync as writeFileSync12 } from "fs";
185056
+ import { readFileSync as readFileSync34, writeFileSync as writeFileSync12 } from "fs";
184698
185057
  async function readStdin2() {
184699
185058
  const chunks = [];
184700
185059
  for await (const chunk of process.stdin) chunks.push(chunk);
@@ -184807,7 +185166,7 @@ async function handleSecretReveal(key, opts, writer = stdoutWriter) {
184807
185166
  async function handleSecretImport(opts, writer = stdoutWriter) {
184808
185167
  const out = createOutput({}, writer);
184809
185168
  try {
184810
- const text6 = opts.file ? readFileSync33(opts.file, "utf8") : await readStdin2();
185169
+ const text6 = opts.file ? readFileSync34(opts.file, "utf8") : await readStdin2();
184811
185170
  const environmentId = opts.env ? await resolveEnvironmentId(opts.env) : null;
184812
185171
  const { rows, committed } = await apiPostOrThrow("secret/import-env", { text: text6, environmentId, commit: !!opts.yes });
184813
185172
  const newCount = rows.filter((r) => r.isNewKey).length;
@@ -185939,6 +186298,17 @@ function buildProgram() {
185939
186298
  const { toolsMigrate: toolsMigrate2 } = await Promise.resolve().then(() => (init_tools2(), tools_exports));
185940
186299
  await toolsMigrate2(opts);
185941
186300
  });
186301
+ toolsCmd.command("approve-schema").description(
186302
+ "Approve the output schema the gateway observed for a tool version whose server declares none"
186303
+ ).argument("<toolVersionId>", "The tlv_\u2026 version").requiredOption(
186304
+ "--hash <sha256>",
186305
+ "The observed schema's hash, as list_tool_versions reports it"
186306
+ ).option("--json", "Output JSON").action(
186307
+ async (toolVersionId, opts) => {
186308
+ const { toolsApproveSchema: toolsApproveSchema2 } = await Promise.resolve().then(() => (init_tools2(), tools_exports));
186309
+ await toolsApproveSchema2(toolVersionId, opts);
186310
+ }
186311
+ );
185942
186312
  const runCmd = program2.command("run").description(
185943
186313
  "Start an agent under the contained launcher (`oxagen run -- claude -p <task>`), start a run in its own sandbox (`oxagen run --harness claude --workspace-slug <slug> --repo <owner/name>`), or read a recorded run: its chain, Oxagen's lock on it, and its locked evidence export"
185944
186314
  ).option("--image <ref>", "The contained image (or OXAGEN_CONTAINED_IMAGE)").option(