claude-use 11.50.2 → 11.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -9022,8 +9022,8 @@ var init_ko = __esm({
9022
9022
  });
9023
9023
 
9024
9024
  // node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/lt.js
9025
- function getUnitTypeFromNumber(number4) {
9026
- const abs = Math.abs(number4);
9025
+ function getUnitTypeFromNumber(number5) {
9026
+ const abs = Math.abs(number5);
9027
9027
  const last = abs % 10;
9028
9028
  const last2 = abs % 100;
9029
9029
  if (last2 >= 11 && last2 <= 19 || last === 0)
@@ -9041,8 +9041,8 @@ var capitalizeFirstCharacter, error33;
9041
9041
  var init_lt = __esm({
9042
9042
  "node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/locales/lt.js"() {
9043
9043
  init_util();
9044
- capitalizeFirstCharacter = (text2) => {
9045
- return text2.charAt(0).toUpperCase() + text2.slice(1);
9044
+ capitalizeFirstCharacter = (text3) => {
9045
+ return text3.charAt(0).toUpperCase() + text3.slice(1);
9046
9046
  };
9047
9047
  error33 = () => {
9048
9048
  const Sizable = {
@@ -20530,8 +20530,8 @@ var require_common = __commonJS({
20530
20530
  }
20531
20531
  return result;
20532
20532
  }
20533
- function isNegativeZero(number4) {
20534
- return number4 === 0 && Number.NEGATIVE_INFINITY === 1 / number4;
20533
+ function isNegativeZero(number5) {
20534
+ return number5 === 0 && Number.NEGATIVE_INFINITY === 1 / number5;
20535
20535
  }
20536
20536
  module2.exports.isNothing = isNothing;
20537
20537
  module2.exports.isObject = isObject5;
@@ -23713,9 +23713,9 @@ var require_env_paths = __commonJS({
23713
23713
  "node_modules/.pnpm/env-paths@2.2.1/node_modules/env-paths/index.js"(exports2, module2) {
23714
23714
  "use strict";
23715
23715
  var path66 = require("path");
23716
- var os13 = require("os");
23717
- var homedir = os13.homedir();
23718
- var tmpdir = os13.tmpdir();
23716
+ var os14 = require("os");
23717
+ var homedir = os14.homedir();
23718
+ var tmpdir = os14.tmpdir();
23719
23719
  var { env } = process;
23720
23720
  var macos = (name) => {
23721
23721
  const library = path66.join(homedir, "Library");
@@ -23995,7 +23995,7 @@ var require_merge2 = __commonJS({
23995
23995
  exports2.mergeAll = exports2.hasOwn = void 0;
23996
23996
  exports2.hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
23997
23997
  var objToString = Function.prototype.call.bind(Object.prototype.toString);
23998
- function isPlainObject4(obj) {
23998
+ function isPlainObject5(obj) {
23999
23999
  return objToString(obj) === "[object Object]";
24000
24000
  }
24001
24001
  function merge2(target, source, options) {
@@ -24010,7 +24010,7 @@ var require_merge2 = __commonJS({
24010
24010
  target[key].push(...newValue);
24011
24011
  continue;
24012
24012
  }
24013
- } else if (isPlainObject4(target[key]) && isPlainObject4(newValue)) {
24013
+ } else if (isPlainObject5(target[key]) && isPlainObject5(newValue)) {
24014
24014
  target[key] = merge2(target[key], newValue, options);
24015
24015
  continue;
24016
24016
  }
@@ -25040,59 +25040,124 @@ var init_proxyBypass = __esm({
25040
25040
  function distinctList(member) {
25041
25041
  return external_exports.array(member).refine((items) => new Set(items).size === items.length, "must not repeat a segment");
25042
25042
  }
25043
+ function isSingleVisibleGrapheme(text3) {
25044
+ return [...GRAPHEMES.segment(text3)].length === 1 && !/[\p{C}\p{Z}]/u.test(text3);
25045
+ }
25046
+ function isPlainObject2(value2) {
25047
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
25048
+ }
25049
+ function mergeStatuslineSettings(base, over) {
25050
+ if (!isPlainObject2(base) || !isPlainObject2(over)) {
25051
+ return over === void 0 ? base : over;
25052
+ }
25053
+ const merged = { ...base };
25054
+ for (const [key, value2] of Object.entries(over)) {
25055
+ merged[key] = key in base ? mergeStatuslineSettings(base[key], value2) : value2;
25056
+ }
25057
+ return merged;
25058
+ }
25043
25059
  function resolveStatusline(settings2) {
25044
- const resolved = {
25045
- header: settings2?.header ?? STATUSLINE_DEFAULTS.header,
25046
- bars: settings2?.bars ?? STATUSLINE_DEFAULTS.bars,
25047
- warnAt: settings2?.warnAt ?? STATUSLINE_DEFAULTS.warnAt,
25048
- criticalAt: settings2?.criticalAt ?? STATUSLINE_DEFAULTS.criticalAt,
25049
- fiveHourLabel: settings2?.fiveHourLabel ?? STATUSLINE_DEFAULTS.fiveHourLabel,
25050
- sevenDayLabel: settings2?.sevenDayLabel ?? STATUSLINE_DEFAULTS.sevenDayLabel,
25051
- barWidth: settings2?.barWidth ?? STATUSLINE_DEFAULTS.barWidth
25052
- };
25053
- if (resolved.warnAt >= resolved.criticalAt) {
25054
- throw new RangeError(`statusline warnAt (${String(resolved.warnAt)}) must be below criticalAt (${String(resolved.criticalAt)})`);
25060
+ const resolved = ResolvedStatuslineSchema.parse(mergeStatuslineSettings(STATUSLINE_DEFAULTS, settings2));
25061
+ if (resolved.bands.warnAt >= resolved.bands.criticalAt) {
25062
+ throw new RangeError(`statusline bands.warnAt (${String(resolved.bands.warnAt)}) must be below bands.criticalAt (${String(resolved.bands.criticalAt)})`);
25055
25063
  }
25056
25064
  return resolved;
25057
25065
  }
25058
- var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_BAR_GROUPS, MAX_PERCENT, MAX_STATUSLINE_LABEL_CHARS, MAX_BAR_CELLS, LABEL_RE2, wholePercent, StatuslineSchema, StatuslineChangeSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
25066
+ var STATUSLINE_HEADER_SEGMENTS, STATUSLINE_ROWS, STATUSLINE_COLOUR_NAMES, MAX_PERCENT, MAX_STATUSLINE_PALETTE_INDEX, MAX_STATUSLINE_LABEL_CHARS, MAX_BAR_CELLS, LABEL_RE2, colourValue, GRAPHEMES, barCharacter, labelText, wholePercent, SHAPES, StatuslineSchema, ResolvedStatuslineSchema, STATUSLINE_DEFAULTS, STATUSLINE_ENV;
25059
25067
  var init_statusline = __esm({
25060
25068
  "src/config/statusline.ts"() {
25061
25069
  "use strict";
25062
25070
  init_zod();
25063
25071
  STATUSLINE_HEADER_SEGMENTS = ["model", "provider", "route", "account", "identity", "headroom"];
25064
- STATUSLINE_BAR_GROUPS = ["context", "quota"];
25072
+ STATUSLINE_ROWS = ["context", "quota"];
25073
+ STATUSLINE_COLOUR_NAMES = [
25074
+ "default",
25075
+ "dim",
25076
+ "black",
25077
+ "red",
25078
+ "green",
25079
+ "yellow",
25080
+ "blue",
25081
+ "magenta",
25082
+ "cyan",
25083
+ "white",
25084
+ "brightBlack",
25085
+ "brightRed",
25086
+ "brightGreen",
25087
+ "brightYellow",
25088
+ "brightBlue",
25089
+ "brightMagenta",
25090
+ "brightCyan",
25091
+ "brightWhite"
25092
+ ];
25065
25093
  MAX_PERCENT = 100;
25094
+ MAX_STATUSLINE_PALETTE_INDEX = 255;
25066
25095
  MAX_STATUSLINE_LABEL_CHARS = 12;
25067
25096
  MAX_BAR_CELLS = 40;
25068
25097
  LABEL_RE2 = /^[^\p{C}\p{Z}]+(?: [^\p{C}\p{Z}]+)*$/u;
25098
+ colourValue = external_exports.union([external_exports.enum(STATUSLINE_COLOUR_NAMES), external_exports.number().int().min(0).max(MAX_STATUSLINE_PALETTE_INDEX), external_exports.string().regex(/^#[0-9a-fA-F]{6}$/, "must be a colour name, a palette index from 0 to 255 or #rrggbb")]);
25099
+ GRAPHEMES = new Intl.Segmenter(void 0, { granularity: "grapheme" });
25100
+ barCharacter = external_exports.string().refine(isSingleVisibleGrapheme, "must be a single visible character");
25101
+ labelText = external_exports.string().max(MAX_STATUSLINE_LABEL_CHARS).regex(LABEL_RE2, "must be visible text without control characters");
25069
25102
  wholePercent = external_exports.number().int().min(1).max(MAX_PERCENT);
25103
+ SHAPES = {
25104
+ layout: {
25105
+ header: distinctList(external_exports.enum(STATUSLINE_HEADER_SEGMENTS)).describe("The header segments to draw, in drawing order; a segment left out is hidden, and an empty list hides the header."),
25106
+ rows: distinctList(external_exports.enum(STATUSLINE_ROWS)).describe("The rows to draw below the header, in drawing order; a row left out is hidden, and an empty list hides every row.")
25107
+ },
25108
+ bands: {
25109
+ warnAt: wholePercent.describe("The whole percentage of use at which a bar turns yellow; it must be below criticalAt."),
25110
+ criticalAt: wholePercent.describe("The whole percentage of use at which a bar turns red.")
25111
+ },
25112
+ labels: {
25113
+ fiveHour: labelText.describe("The name of the five-hour subscription window."),
25114
+ sevenDay: labelText.describe("The name of the weekly subscription window.")
25115
+ },
25116
+ bar: {
25117
+ width: external_exports.number().int().min(1).max(MAX_BAR_CELLS).describe("A bar's width in cells before the line's spare width is shared out among the bars."),
25118
+ filled: barCharacter.describe("The character that draws the used part of a bar."),
25119
+ empty: barCharacter.describe("The character that draws the unused part of a bar.")
25120
+ },
25121
+ colours: {
25122
+ context: colourValue.describe("The colour of the context bar and its figures below the warning threshold."),
25123
+ usage: colourValue.describe("The colour of the quota bars and their figures below the warning threshold."),
25124
+ warning: colourValue.describe("The colour of the context bar at or above bands.warnAt, and of a cache hit share that is middling."),
25125
+ usageWarning: colourValue.describe("The colour of a quota bar at or above bands.warnAt."),
25126
+ critical: colourValue.describe("The colour of a bar at or above bands.criticalAt, and of a cache hit share that is nearly nothing."),
25127
+ model: colourValue.describe("The colour of the model and provider segments."),
25128
+ label: colourValue.describe("The colour of labels and secondary text: row labels, and the route, account, identity and headroom segments."),
25129
+ empty: colourValue.describe("The colour of the unused part of a bar.")
25130
+ }
25131
+ };
25070
25132
  StatuslineSchema = external_exports.strictObject({
25071
- header: distinctList(external_exports.enum(STATUSLINE_HEADER_SEGMENTS)).optional(),
25072
- bars: distinctList(external_exports.enum(STATUSLINE_BAR_GROUPS)).optional(),
25073
- warnAt: wholePercent.optional(),
25074
- criticalAt: wholePercent.optional(),
25075
- fiveHourLabel: external_exports.string().max(MAX_STATUSLINE_LABEL_CHARS).regex(LABEL_RE2, "must be visible text without control characters").optional(),
25076
- sevenDayLabel: external_exports.string().max(MAX_STATUSLINE_LABEL_CHARS).regex(LABEL_RE2, "must be visible text without control characters").optional(),
25077
- barWidth: external_exports.number().int().min(1).max(MAX_BAR_CELLS).optional()
25078
- });
25079
- StatuslineChangeSchema = external_exports.strictObject({
25080
- header: external_exports.union([StatuslineSchema.shape.header.unwrap(), external_exports.literal(false)]).optional(),
25081
- bars: external_exports.union([StatuslineSchema.shape.bars.unwrap(), external_exports.literal(false)]).optional(),
25082
- warnAt: external_exports.union([StatuslineSchema.shape.warnAt.unwrap(), external_exports.literal(false)]).optional(),
25083
- criticalAt: external_exports.union([StatuslineSchema.shape.criticalAt.unwrap(), external_exports.literal(false)]).optional(),
25084
- fiveHourLabel: external_exports.union([StatuslineSchema.shape.fiveHourLabel.unwrap(), external_exports.literal(false)]).optional(),
25085
- sevenDayLabel: external_exports.union([StatuslineSchema.shape.sevenDayLabel.unwrap(), external_exports.literal(false)]).optional(),
25086
- barWidth: external_exports.union([StatuslineSchema.shape.barWidth.unwrap(), external_exports.literal(false)]).optional()
25133
+ layout: external_exports.strictObject(SHAPES.layout).partial().optional(),
25134
+ bands: external_exports.strictObject(SHAPES.bands).partial().optional(),
25135
+ labels: external_exports.strictObject(SHAPES.labels).partial().optional(),
25136
+ bar: external_exports.strictObject(SHAPES.bar).partial().optional(),
25137
+ colours: external_exports.strictObject(SHAPES.colours).partial().optional()
25138
+ });
25139
+ ResolvedStatuslineSchema = external_exports.strictObject({
25140
+ layout: external_exports.strictObject(SHAPES.layout),
25141
+ bands: external_exports.strictObject(SHAPES.bands),
25142
+ labels: external_exports.strictObject(SHAPES.labels),
25143
+ bar: external_exports.strictObject(SHAPES.bar),
25144
+ colours: external_exports.strictObject(SHAPES.colours)
25087
25145
  });
25088
25146
  STATUSLINE_DEFAULTS = {
25089
- header: STATUSLINE_HEADER_SEGMENTS,
25090
- bars: STATUSLINE_BAR_GROUPS,
25091
- warnAt: 70,
25092
- criticalAt: 90,
25093
- fiveHourLabel: "5h",
25094
- sevenDayLabel: "Wk",
25095
- barWidth: 10
25147
+ layout: { header: [...STATUSLINE_HEADER_SEGMENTS], rows: [...STATUSLINE_ROWS] },
25148
+ bands: { warnAt: 70, criticalAt: 90 },
25149
+ labels: { fiveHour: "5h", sevenDay: "Wk" },
25150
+ bar: { width: 10, filled: "\u2588", empty: "\u2591" },
25151
+ colours: {
25152
+ context: "green",
25153
+ usage: "green",
25154
+ warning: "yellow",
25155
+ usageWarning: "yellow",
25156
+ critical: "red",
25157
+ model: "default",
25158
+ label: "default",
25159
+ empty: "brightBlack"
25160
+ }
25096
25161
  };
25097
25162
  STATUSLINE_ENV = "AGENT_SHIM_STATUSLINE";
25098
25163
  }
@@ -27555,10 +27620,10 @@ var init_schema = __esm({
27555
27620
  });
27556
27621
 
27557
27622
  // src/frontdoor/state.ts
27558
- function readFrontDoorState(fs29, stateFile) {
27623
+ function readFrontDoorState(fs30, stateFile) {
27559
27624
  let raw;
27560
27625
  try {
27561
- raw = fs29.readFileUtf8(stateFile);
27626
+ raw = fs30.readFileUtf8(stateFile);
27562
27627
  } catch {
27563
27628
  return void 0;
27564
27629
  }
@@ -27572,9 +27637,9 @@ function readFrontDoorState(fs29, stateFile) {
27572
27637
  return void 0;
27573
27638
  }
27574
27639
  }
27575
- function writeFrontDoorState(fs29, stateFile, state) {
27576
- fs29.mkdirp(import_node_path5.default.dirname(stateFile));
27577
- fs29.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27640
+ function writeFrontDoorState(fs30, stateFile, state) {
27641
+ fs30.mkdirp(import_node_path5.default.dirname(stateFile));
27642
+ fs30.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27578
27643
  `);
27579
27644
  }
27580
27645
  function directOrigin(port) {
@@ -27584,37 +27649,37 @@ function frontDoorOrigin(state) {
27584
27649
  const port = state?.directPort ?? state?.lastDirectPort;
27585
27650
  return port === void 0 ? void 0 : directOrigin(port);
27586
27651
  }
27587
- function writeFrontDoorDirectRecord(fs29, recordsDir, record2) {
27588
- fs29.mkdirp(recordsDir);
27589
- fs29.writeFilePrivate(import_node_path5.default.join(recordsDir, `${String(record2.pid)}.json`), `${JSON.stringify({ directPort: record2.directPort })}
27652
+ function writeFrontDoorDirectRecord(fs30, recordsDir, record2) {
27653
+ fs30.mkdirp(recordsDir);
27654
+ fs30.writeFilePrivate(import_node_path5.default.join(recordsDir, `${String(record2.pid)}.json`), `${JSON.stringify({ directPort: record2.directPort })}
27590
27655
  `);
27591
27656
  }
27592
- function removeFrontDoorDirectRecord(fs29, recordsDir, pid) {
27593
- fs29.removeRecursive(import_node_path5.default.join(recordsDir, `${String(pid)}.json`));
27657
+ function removeFrontDoorDirectRecord(fs30, recordsDir, pid) {
27658
+ fs30.removeRecursive(import_node_path5.default.join(recordsDir, `${String(pid)}.json`));
27594
27659
  }
27595
- function markFrontDoorDraining(fs29, markersDir, pid) {
27596
- fs29.mkdirp(markersDir);
27597
- fs29.writeFilePrivate(import_node_path5.default.join(markersDir, String(pid)), "\n");
27660
+ function markFrontDoorDraining(fs30, markersDir, pid) {
27661
+ fs30.mkdirp(markersDir);
27662
+ fs30.writeFilePrivate(import_node_path5.default.join(markersDir, String(pid)), "\n");
27598
27663
  }
27599
- function unmarkFrontDoorDraining(fs29, markersDir, pid) {
27600
- fs29.removeRecursive(import_node_path5.default.join(markersDir, String(pid)));
27664
+ function unmarkFrontDoorDraining(fs30, markersDir, pid) {
27665
+ fs30.removeRecursive(import_node_path5.default.join(markersDir, String(pid)));
27601
27666
  }
27602
- function listDrainingFrontDoors(fs29, markersDir, isRunning) {
27603
- return fs29.readdir(markersDir).flatMap((file2) => /^[1-9]\d*$/.test(file2) && Number.isSafeInteger(Number(file2)) ? [Number(file2)] : []).filter(isRunning).sort((a10, b) => a10 - b);
27667
+ function listDrainingFrontDoors(fs30, markersDir, isRunning) {
27668
+ return fs30.readdir(markersDir).flatMap((file2) => /^[1-9]\d*$/.test(file2) && Number.isSafeInteger(Number(file2)) ? [Number(file2)] : []).filter(isRunning).sort((a10, b) => a10 - b);
27604
27669
  }
27605
27670
  function recordPid(file2) {
27606
27671
  const pidText = /^([1-9]\d*)\.json$/.exec(file2)?.[1];
27607
27672
  const pid = pidText === void 0 ? void 0 : Number(pidText);
27608
27673
  return pid !== void 0 && Number.isSafeInteger(pid) ? pid : void 0;
27609
27674
  }
27610
- function readDirectRecordEntry(fs29, recordsDir, file2) {
27675
+ function readDirectRecordEntry(fs30, recordsDir, file2) {
27611
27676
  const pid = recordPid(file2);
27612
27677
  if (pid === void 0) {
27613
27678
  return void 0;
27614
27679
  }
27615
27680
  let raw;
27616
27681
  try {
27617
- raw = fs29.readFileUtf8(import_node_path5.default.join(recordsDir, file2));
27682
+ raw = fs30.readFileUtf8(import_node_path5.default.join(recordsDir, file2));
27618
27683
  } catch {
27619
27684
  return void 0;
27620
27685
  }
@@ -27628,47 +27693,47 @@ function readDirectRecordEntry(fs29, recordsDir, file2) {
27628
27693
  return { malformed: true };
27629
27694
  }
27630
27695
  }
27631
- function listFrontDoorDirectRecords(fs29, recordsDir) {
27632
- return fs29.readdir(recordsDir).flatMap((file2) => {
27633
- const entry = readDirectRecordEntry(fs29, recordsDir, file2);
27696
+ function listFrontDoorDirectRecords(fs30, recordsDir) {
27697
+ return fs30.readdir(recordsDir).flatMap((file2) => {
27698
+ const entry = readDirectRecordEntry(fs30, recordsDir, file2);
27634
27699
  return entry?.record === void 0 ? [] : [entry.record];
27635
27700
  }).sort((a10, b) => a10.pid - b.pid);
27636
27701
  }
27637
- function pruneMalformedFrontDoorDirectFiles(fs29, recordsDir, isRunning) {
27638
- for (const file2 of fs29.readdir(recordsDir)) {
27702
+ function pruneMalformedFrontDoorDirectFiles(fs30, recordsDir, isRunning) {
27703
+ for (const file2 of fs30.readdir(recordsDir)) {
27639
27704
  const writer = RECORD_TEMPORARY_FILE.exec(file2)?.[1];
27640
27705
  const stale = writer !== void 0 && !isRunning(Number(writer));
27641
- if (stale || readDirectRecordEntry(fs29, recordsDir, file2)?.malformed === true) {
27642
- fs29.removeRecursive(import_node_path5.default.join(recordsDir, file2));
27706
+ if (stale || readDirectRecordEntry(fs30, recordsDir, file2)?.malformed === true) {
27707
+ fs30.removeRecursive(import_node_path5.default.join(recordsDir, file2));
27643
27708
  }
27644
27709
  }
27645
27710
  }
27646
27711
  function liveFrontDoorDirectRecords(records, liveness) {
27647
27712
  return records.filter((record2) => liveness.doors.has(record2.pid) || liveness.unknown.has(record2.pid));
27648
27713
  }
27649
- function pruneDeadFrontDoorDirectRecords(fs29, recordsDir, records, liveness) {
27714
+ function pruneDeadFrontDoorDirectRecords(fs30, recordsDir, records, liveness) {
27650
27715
  for (const record2 of records) {
27651
27716
  if (!liveness.doors.has(record2.pid) && !liveness.unknown.has(record2.pid)) {
27652
- removeFrontDoorDirectRecord(fs29, recordsDir, record2.pid);
27717
+ removeFrontDoorDirectRecord(fs30, recordsDir, record2.pid);
27653
27718
  }
27654
27719
  }
27655
27720
  }
27656
27721
  function recordOf(details) {
27657
27722
  return details === void 0 ? {} : { sessionId: details.sessionId, ...details.models === void 0 ? {} : { models: details.models } };
27658
27723
  }
27659
- function writeFrontDoorSession(fs29, sessionsDir, session) {
27660
- fs29.mkdirPrivate(sessionsDir);
27661
- fs29.writeFilePrivate(import_node_path5.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27724
+ function writeFrontDoorSession(fs30, sessionsDir, session) {
27725
+ fs30.mkdirPrivate(sessionsDir);
27726
+ fs30.writeFilePrivate(import_node_path5.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27662
27727
  `);
27663
27728
  }
27664
- function listFrontDoorSessions(fs29, sessionsDir) {
27729
+ function listFrontDoorSessions(fs30, sessionsDir) {
27665
27730
  const sessions = [];
27666
- for (const name of fs29.readdir(sessionsDir)) {
27731
+ for (const name of fs30.readdir(sessionsDir)) {
27667
27732
  if (!name.endsWith(".json")) {
27668
27733
  continue;
27669
27734
  }
27670
27735
  try {
27671
- const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs29.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
27736
+ const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs30.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
27672
27737
  if (parsed.success) {
27673
27738
  sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt, ...parsed.data.supervisorPid === void 0 ? {} : { supervisorPid: parsed.data.supervisorPid } });
27674
27739
  }
@@ -27678,27 +27743,27 @@ function listFrontDoorSessions(fs29, sessionsDir) {
27678
27743
  }
27679
27744
  return sessions.sort((a10, b) => a10.pid - b.pid);
27680
27745
  }
27681
- function removeFrontDoorSession(fs29, sessionsDir, pid) {
27682
- fs29.removeRecursive(import_node_path5.default.join(sessionsDir, `${String(pid)}.json`));
27746
+ function removeFrontDoorSession(fs30, sessionsDir, pid) {
27747
+ fs30.removeRecursive(import_node_path5.default.join(sessionsDir, `${String(pid)}.json`));
27683
27748
  }
27684
- function pruneDeadFrontDoorSessions(fs29, sessionsDir, isRunning) {
27749
+ function pruneDeadFrontDoorSessions(fs30, sessionsDir, isRunning) {
27685
27750
  const removed = [];
27686
- for (const session of listFrontDoorSessions(fs29, sessionsDir)) {
27751
+ for (const session of listFrontDoorSessions(fs30, sessionsDir)) {
27687
27752
  if (!isRunning(session.pid)) {
27688
- removeFrontDoorSession(fs29, sessionsDir, session.pid);
27753
+ removeFrontDoorSession(fs30, sessionsDir, session.pid);
27689
27754
  removed.push(session.pid);
27690
27755
  }
27691
27756
  }
27692
27757
  return removed;
27693
27758
  }
27694
- function liveSessionTokens(fs29, sessionsDir) {
27759
+ function liveSessionTokens(fs30, sessionsDir) {
27695
27760
  const tokens = /* @__PURE__ */ new Set();
27696
- for (const name of fs29.readdir(sessionsDir)) {
27761
+ for (const name of fs30.readdir(sessionsDir)) {
27697
27762
  if (!name.endsWith(".json")) {
27698
27763
  continue;
27699
27764
  }
27700
27765
  try {
27701
- const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs29.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
27766
+ const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs30.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
27702
27767
  if (parsed.success) {
27703
27768
  tokens.add(parsed.data.token);
27704
27769
  }
@@ -27708,13 +27773,13 @@ function liveSessionTokens(fs29, sessionsDir) {
27708
27773
  }
27709
27774
  return tokens;
27710
27775
  }
27711
- function readFrontDoorSessionModels(fs29, sessionsDir, sessionId) {
27712
- for (const name of fs29.readdir(sessionsDir)) {
27776
+ function readFrontDoorSessionModels(fs30, sessionsDir, sessionId) {
27777
+ for (const name of fs30.readdir(sessionsDir)) {
27713
27778
  if (!name.endsWith(".json")) {
27714
27779
  continue;
27715
27780
  }
27716
27781
  try {
27717
- const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs29.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
27782
+ const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs30.readFileUtf8(import_node_path5.default.join(sessionsDir, name)) ?? ""));
27718
27783
  if (parsed.success && parsed.data.sessionId === sessionId) {
27719
27784
  return parsed.data.models;
27720
27785
  }
@@ -27777,43 +27842,43 @@ function parseJson(raw, schema) {
27777
27842
  const parsed = schema.safeParse(JSON.parse(raw));
27778
27843
  return parsed.success ? parsed.data : void 0;
27779
27844
  }
27780
- function readHeadroomState(fs29, stateFile) {
27845
+ function readHeadroomState(fs30, stateFile) {
27781
27846
  try {
27782
- return parseJson(fs29.readFileUtf8(stateFile), HeadroomStateSchema);
27847
+ return parseJson(fs30.readFileUtf8(stateFile), HeadroomStateSchema);
27783
27848
  } catch {
27784
27849
  return void 0;
27785
27850
  }
27786
27851
  }
27787
- function writeHeadroomState(fs29, stateFile, state) {
27788
- fs29.mkdirp(import_node_path6.default.dirname(stateFile));
27789
- fs29.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27852
+ function writeHeadroomState(fs30, stateFile, state) {
27853
+ fs30.mkdirp(import_node_path6.default.dirname(stateFile));
27854
+ fs30.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27790
27855
  `);
27791
27856
  }
27792
- function resolveServingHeadroomState(fs29, files, isRunning) {
27793
- const current = readHeadroomState(fs29, files.stateFile);
27857
+ function resolveServingHeadroomState(fs30, files, isRunning) {
27858
+ const current = readHeadroomState(fs30, files.stateFile);
27794
27859
  if (current !== void 0) {
27795
27860
  return { path: files.stateFile, state: current };
27796
27861
  }
27797
- const legacy = readHeadroomState(fs29, files.legacyStateFile);
27862
+ const legacy = readHeadroomState(fs30, files.legacyStateFile);
27798
27863
  if (legacy?.supervisorPid !== void 0 && isRunning(legacy.supervisorPid)) {
27799
27864
  return { path: files.legacyStateFile, state: legacy };
27800
27865
  }
27801
27866
  return void 0;
27802
27867
  }
27803
- function migrateHeadroomState(fs29, files, isRunning) {
27804
- const legacy = readHeadroomState(fs29, files.legacyStateFile);
27868
+ function migrateHeadroomState(fs30, files, isRunning) {
27869
+ const legacy = readHeadroomState(fs30, files.legacyStateFile);
27805
27870
  const legacyLive = legacy?.supervisorPid !== void 0 && isRunning(legacy.supervisorPid);
27806
- const current = readHeadroomState(fs29, files.stateFile);
27871
+ const current = readHeadroomState(fs30, files.stateFile);
27807
27872
  if (current !== void 0 || legacyLive) {
27808
- if (!legacyLive && fs29.readFileUtf8(files.legacyStateFile) !== void 0) {
27809
- fs29.removeRecursive(files.legacyStateFile);
27873
+ if (!legacyLive && fs30.readFileUtf8(files.legacyStateFile) !== void 0) {
27874
+ fs30.removeRecursive(files.legacyStateFile);
27810
27875
  }
27811
27876
  return;
27812
27877
  }
27813
27878
  if (legacy !== void 0) {
27814
- writeHeadroomState(fs29, files.stateFile, legacy);
27879
+ writeHeadroomState(fs30, files.stateFile, legacy);
27815
27880
  }
27816
- fs29.removeRecursive(files.legacyStateFile);
27881
+ fs30.removeRecursive(files.legacyStateFile);
27817
27882
  }
27818
27883
  function hashAllowlist(allowlist) {
27819
27884
  return (0, import_node_crypto2.createHash)("sha256").update(allowlist.join("\n")).digest("hex");
@@ -27846,27 +27911,27 @@ function isAdmissibleUrl(entry) {
27846
27911
  function parseAllowlistFile(content) {
27847
27912
  return content.replace(/^\uFEFF/, "").replace(ALLOWLIST_FILE_COMMENT, "").split(ALLOWLIST_FILE_SEPARATORS).map((entry) => entry.replace(ALLOWLIST_SURROUNDING_WHITESPACE, "")).filter((entry) => entry !== "" && !ALLOWLIST_ENTRY_WHITESPACE.test(entry) && (entry.includes("://") ? isAdmissibleUrl(entry) : isBareHost(entry)));
27848
27913
  }
27849
- function writeAllowlistFile(fs29, allowlistFile, allowlist) {
27850
- fs29.mkdirPrivate(import_node_path6.default.dirname(allowlistFile));
27851
- fs29.writeFilePrivate(allowlistFile, formatAllowlistFile(allowlist));
27914
+ function writeAllowlistFile(fs30, allowlistFile, allowlist) {
27915
+ fs30.mkdirPrivate(import_node_path6.default.dirname(allowlistFile));
27916
+ fs30.writeFilePrivate(allowlistFile, formatAllowlistFile(allowlist));
27852
27917
  }
27853
- function pruneStaleAllowlistTemporaries(fs29, allowlistFile, isRunning) {
27918
+ function pruneStaleAllowlistTemporaries(fs30, allowlistFile, isRunning) {
27854
27919
  const prefix = `${import_node_path6.default.basename(allowlistFile)}.`;
27855
- for (const name of fs29.readdir(import_node_path6.default.dirname(allowlistFile))) {
27920
+ for (const name of fs30.readdir(import_node_path6.default.dirname(allowlistFile))) {
27856
27921
  const writer = name.startsWith(prefix) ? /^([1-9]\d*)\.tmp$/.exec(name.slice(prefix.length))?.[1] : void 0;
27857
27922
  if (writer !== void 0 && !isRunning(Number(writer))) {
27858
- fs29.removeRecursive(import_node_path6.default.join(import_node_path6.default.dirname(allowlistFile), name));
27923
+ fs30.removeRecursive(import_node_path6.default.join(import_node_path6.default.dirname(allowlistFile), name));
27859
27924
  }
27860
27925
  }
27861
27926
  }
27862
- function readAllProviders(fs29, providersDir) {
27927
+ function readAllProviders(fs30, providersDir) {
27863
27928
  const result = [];
27864
- for (const name of fs29.readdir(providersDir)) {
27929
+ for (const name of fs30.readdir(providersDir)) {
27865
27930
  if (!name.endsWith(".json")) {
27866
27931
  continue;
27867
27932
  }
27868
27933
  try {
27869
- const parsed = parseJson(fs29.readFileUtf8(import_node_path6.default.join(providersDir, name)), ProviderSchema);
27934
+ const parsed = parseJson(fs30.readFileUtf8(import_node_path6.default.join(providersDir, name)), ProviderSchema);
27870
27935
  if (parsed !== void 0) {
27871
27936
  result.push({ name: name.slice(0, -".json".length), provider: parsed });
27872
27937
  }
@@ -27876,22 +27941,22 @@ function readAllProviders(fs29, providersDir) {
27876
27941
  }
27877
27942
  return result;
27878
27943
  }
27879
- function writeSession(fs29, sessionsDir, session) {
27880
- fs29.mkdirp(sessionsDir);
27881
- fs29.writeFileUtf8(import_node_path6.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27944
+ function writeSession(fs30, sessionsDir, session) {
27945
+ fs30.mkdirp(sessionsDir);
27946
+ fs30.writeFileUtf8(import_node_path6.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27882
27947
  `);
27883
27948
  }
27884
- function removeSession(fs29, sessionsDir, pid) {
27885
- fs29.removeRecursive(import_node_path6.default.join(sessionsDir, `${String(pid)}.json`));
27949
+ function removeSession(fs30, sessionsDir, pid) {
27950
+ fs30.removeRecursive(import_node_path6.default.join(sessionsDir, `${String(pid)}.json`));
27886
27951
  }
27887
- function listSessions(fs29, sessionsDir) {
27952
+ function listSessions(fs30, sessionsDir) {
27888
27953
  const sessions = [];
27889
- for (const name of fs29.readdir(sessionsDir)) {
27954
+ for (const name of fs30.readdir(sessionsDir)) {
27890
27955
  if (!name.endsWith(".json")) {
27891
27956
  continue;
27892
27957
  }
27893
27958
  try {
27894
- const parsed = parseJson(fs29.readFileUtf8(import_node_path6.default.join(sessionsDir, name)), HeadroomSessionSchema);
27959
+ const parsed = parseJson(fs30.readFileUtf8(import_node_path6.default.join(sessionsDir, name)), HeadroomSessionSchema);
27895
27960
  if (parsed !== void 0) {
27896
27961
  sessions.push(parsed);
27897
27962
  }
@@ -27901,22 +27966,22 @@ function listSessions(fs29, sessionsDir) {
27901
27966
  }
27902
27967
  return sessions.sort((a10, b) => a10.pid - b.pid);
27903
27968
  }
27904
- function sessionsForSupervisor(fs29, sessionsDir, supervisorPid) {
27905
- return listSessions(fs29, sessionsDir).filter((session) => session.supervisorPid === supervisorPid);
27969
+ function sessionsForSupervisor(fs30, sessionsDir, supervisorPid) {
27970
+ return listSessions(fs30, sessionsDir).filter((session) => session.supervisorPid === supervisorPid);
27906
27971
  }
27907
- function pruneDeadSessions(fs29, sessionsDir, isRunning) {
27972
+ function pruneDeadSessions(fs30, sessionsDir, isRunning) {
27908
27973
  const removed = [];
27909
- for (const session of listSessions(fs29, sessionsDir)) {
27974
+ for (const session of listSessions(fs30, sessionsDir)) {
27910
27975
  if (!isRunning(session.pid)) {
27911
- removeSession(fs29, sessionsDir, session.pid);
27976
+ removeSession(fs30, sessionsDir, session.pid);
27912
27977
  removed.push(session.pid);
27913
27978
  }
27914
27979
  }
27915
27980
  return removed;
27916
27981
  }
27917
- function readStartLock(fs29, lockFile) {
27982
+ function readStartLock(fs30, lockFile) {
27918
27983
  try {
27919
- return parseJson(fs29.readFileUtf8(lockFile), HeadroomLockSchema);
27984
+ return parseJson(fs30.readFileUtf8(lockFile), HeadroomLockSchema);
27920
27985
  } catch {
27921
27986
  return void 0;
27922
27987
  }
@@ -28009,12 +28074,12 @@ function earlierReleaseAllowlistHash(providers, doorOrigin) {
28009
28074
  }
28010
28075
  return hashAllowlist([...entries].sort());
28011
28076
  }
28012
- function earlierReleaseDaemon(fs29, paths, daemon) {
28077
+ function earlierReleaseDaemon(fs30, paths, daemon) {
28013
28078
  if (daemonIdentity(daemon.commandLine, daemon.socketPath) !== "earlier-release") {
28014
28079
  return void 0;
28015
28080
  }
28016
- const providers = readAllProviders(fs29, paths.providersDir).map((entry) => entry.provider);
28017
- const expected = earlierReleaseAllowlistHash(providers, frontDoorOrigin(readFrontDoorState(fs29, paths.frontdoorStateFile)));
28081
+ const providers = readAllProviders(fs30, paths.providersDir).map((entry) => entry.provider);
28082
+ const expected = earlierReleaseAllowlistHash(providers, frontDoorOrigin(readFrontDoorState(fs30, paths.frontdoorStateFile)));
28018
28083
  return { admitsServingDoor: daemon.recordedHash === expected };
28019
28084
  }
28020
28085
  var EARLIER_RELEASE_ALLOWLIST, EARLIER_RELEASE_ANTHROPIC_UPSTREAM;
@@ -28039,8 +28104,8 @@ function awaitingCause(daemonPid, identity, allowlistFile) {
28039
28104
  }
28040
28105
  return `the headroom supervisor has not written an allowlist admitting this launch's upstreams to ${allowlistFile} within ${String(HEADROOM_START_TIMEOUT_MS)}ms`;
28041
28106
  }
28042
- function daemonAdmits(fs29, allowlistFile, recordedHash, required2) {
28043
- const content = fs29.readFileUtf8(allowlistFile);
28107
+ function daemonAdmits(fs30, allowlistFile, recordedHash, required2) {
28108
+ const content = fs30.readFileUtf8(allowlistFile);
28044
28109
  if (content === void 0 || recordedHash === void 0) {
28045
28110
  return false;
28046
28111
  }
@@ -28180,8 +28245,8 @@ function redactHeaders(headers) {
28180
28245
  }
28181
28246
  return result;
28182
28247
  }
28183
- function redactText(text2) {
28184
- return SECRET_BODY_PATTERNS.reduce((accumulated, { pattern, replacement }) => accumulated.replace(pattern, replacement), text2);
28248
+ function redactText(text3) {
28249
+ return SECRET_BODY_PATTERNS.reduce((accumulated, { pattern, replacement }) => accumulated.replace(pattern, replacement), text3);
28185
28250
  }
28186
28251
  function redactJsonValue(value2) {
28187
28252
  if (typeof value2 === "string") {
@@ -28196,12 +28261,12 @@ function redactJsonValue(value2) {
28196
28261
  return value2;
28197
28262
  }
28198
28263
  function redactBody(chunk2) {
28199
- const text2 = chunk2.toString("utf8");
28264
+ const text3 = chunk2.toString("utf8");
28200
28265
  try {
28201
- const parsed = JSON.parse(text2);
28266
+ const parsed = JSON.parse(text3);
28202
28267
  return JSON.stringify(redactJsonValue(parsed));
28203
28268
  } catch {
28204
- return redactText(text2);
28269
+ return redactText(text3);
28205
28270
  }
28206
28271
  }
28207
28272
  function captureFromEnv(env, logsDir) {
@@ -28236,8 +28301,8 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
28236
28301
  }
28237
28302
  const excerpt2 = chunk2.subarray(0, Math.min(CHUNK_LOG_CAP_BYTES, budget));
28238
28303
  stored[direction] += excerpt2.length;
28239
- const text2 = excerpt2.toString("utf8");
28240
- const faithful = Buffer.from(text2, "utf8").equals(excerpt2);
28304
+ const text3 = excerpt2.toString("utf8");
28305
+ const faithful = Buffer.from(text3, "utf8").equals(excerpt2);
28241
28306
  append({
28242
28307
  kind: "stream-chunk",
28243
28308
  id: id2,
@@ -28246,7 +28311,7 @@ function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
28246
28311
  bytes: chunk2.length,
28247
28312
  stored: excerpt2.length,
28248
28313
  truncated: excerpt2.length < chunk2.length,
28249
- ...faithful ? { body: redactText(text2) } : { b64: excerpt2.toString("base64") }
28314
+ ...faithful ? { body: redactText(text3) } : { b64: excerpt2.toString("base64") }
28250
28315
  });
28251
28316
  },
28252
28317
  onEnd: () => {
@@ -28430,7 +28495,7 @@ function verifyAllowlistFile(allowlistFile, ports) {
28430
28495
  const replaceable = fileStat === void 0 || fileStat.kind === "file" || fileStat.kind === "symlink";
28431
28496
  return { message: refusal2, repairable: replaceable };
28432
28497
  }
28433
- function prepareHeadroomSocket(fs29, ports, paths, supervisorPid) {
28498
+ function prepareHeadroomSocket(fs30, ports, paths, supervisorPid) {
28434
28499
  const unsupported = platformRefusal(ports.platform);
28435
28500
  if (unsupported !== void 0) {
28436
28501
  return { refused: unsupported };
@@ -28445,18 +28510,18 @@ function prepareHeadroomSocket(fs29, ports, paths, supervisorPid) {
28445
28510
  if (ports.lstat(paths.headroomSocketDir)?.kind === "symlink") {
28446
28511
  return { refused: `the headroom socket directory ${paths.headroomSocketDir} is a symlink; it must be the real directory` };
28447
28512
  }
28448
- fs29.mkdirPrivate(paths.headroomSocketDir);
28513
+ fs30.mkdirPrivate(paths.headroomSocketDir);
28449
28514
  const refusal2 = ownerOnlyRefusal("socket directory", paths.headroomSocketDir, ports.lstat(paths.headroomSocketDir), "dir", ports.currentUid());
28450
28515
  return refusal2 === void 0 ? { socketPath } : { refused: refusal2 };
28451
28516
  }
28452
- function pruneStaleHeadroomSockets(fs29, paths, isRunning) {
28517
+ function pruneStaleHeadroomSockets(fs30, paths, isRunning) {
28453
28518
  const removed = [];
28454
- for (const name of fs29.readdir(paths.headroomSocketDir)) {
28519
+ for (const name of fs30.readdir(paths.headroomSocketDir)) {
28455
28520
  const pid = HEADROOM_SOCKET_NAME.exec(name)?.[1];
28456
28521
  if (pid === void 0 || isRunning(Number.parseInt(pid, 10))) {
28457
28522
  continue;
28458
28523
  }
28459
- fs29.removeRecursive(import_node_path7.default.join(paths.headroomSocketDir, name));
28524
+ fs30.removeRecursive(import_node_path7.default.join(paths.headroomSocketDir, name));
28460
28525
  removed.push(name);
28461
28526
  }
28462
28527
  return removed;
@@ -28603,37 +28668,37 @@ function compareVersions2(a10, b) {
28603
28668
  return 0;
28604
28669
  }
28605
28670
  async function runSupervisor(initialConfig, ports, options = {}) {
28606
- const { fs: fs29, paths } = ports;
28671
+ const { fs: fs30, paths } = ports;
28607
28672
  let config2 = initialConfig;
28608
- migrateHeadroomState(fs29, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
28609
- const previousState = resolveServingHeadroomState(fs29, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
28673
+ migrateHeadroomState(fs30, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
28674
+ const previousState = resolveServingHeadroomState(fs30, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
28610
28675
  if (previousState?.supervisorPid !== void 0 && previousState.supervisorPid !== ports.ownPid && ports.isRunning(previousState.supervisorPid)) {
28611
28676
  ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: supervisor ${String(previousState.supervisorPid)} already owns the daemon; exiting`);
28612
28677
  return 0;
28613
28678
  }
28614
28679
  let installedSource = previousState?.installedSource;
28615
28680
  const ownsState = () => {
28616
- const owner = readHeadroomState(fs29, paths.headroomStateFile)?.supervisorPid;
28681
+ const owner = readHeadroomState(fs30, paths.headroomStateFile)?.supervisorPid;
28617
28682
  return owner === void 0 || owner === ports.ownPid || !ports.isRunning(owner);
28618
28683
  };
28619
28684
  const writeOwnState = (state) => {
28620
28685
  if (!ownsState()) {
28621
28686
  return false;
28622
28687
  }
28623
- writeHeadroomState(fs29, paths.headroomStateFile, state);
28688
+ writeHeadroomState(fs30, paths.headroomStateFile, state);
28624
28689
  return true;
28625
28690
  };
28626
28691
  const fail = (message) => {
28627
28692
  if (writeOwnState({ lastError: message })) {
28628
- fs29.removeRecursive(paths.headroomLockFile);
28693
+ fs30.removeRecursive(paths.headroomLockFile);
28629
28694
  }
28630
28695
  ports.log(`agent-shim headroom supervisor: ${message}`);
28631
28696
  return 1;
28632
28697
  };
28633
28698
  const syncAllowlistFile = (allowlist) => {
28634
28699
  try {
28635
- if (fs29.readFileUtf8(paths.headroomAllowlistFile) !== formatAllowlistFile(allowlist)) {
28636
- writeAllowlistFile(fs29, paths.headroomAllowlistFile, allowlist);
28700
+ if (fs30.readFileUtf8(paths.headroomAllowlistFile) !== formatAllowlistFile(allowlist)) {
28701
+ writeAllowlistFile(fs30, paths.headroomAllowlistFile, allowlist);
28637
28702
  ports.log(`agent-shim headroom supervisor: wrote allowlist [${allowlist.join(", ")}] to ${paths.headroomAllowlistFile}`);
28638
28703
  }
28639
28704
  return void 0;
@@ -28651,9 +28716,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
28651
28716
  }
28652
28717
  ports.log(`agent-shim headroom supervisor: repairing the allowlist file: ${problem.message}`);
28653
28718
  try {
28654
- fs29.mkdirPrivate(paths.headroomDir);
28655
- fs29.mkdirPrivate(import_node_path8.default.dirname(paths.headroomAllowlistFile));
28656
- writeAllowlistFile(fs29, paths.headroomAllowlistFile, allowlist);
28719
+ fs30.mkdirPrivate(paths.headroomDir);
28720
+ fs30.mkdirPrivate(import_node_path8.default.dirname(paths.headroomAllowlistFile));
28721
+ writeAllowlistFile(fs30, paths.headroomAllowlistFile, allowlist);
28657
28722
  } catch (error63) {
28658
28723
  return `could not write the headroom allowlist file ${paths.headroomAllowlistFile}: ${error63 instanceof Error ? error63.message : String(error63)}`;
28659
28724
  }
@@ -28678,20 +28743,20 @@ async function runSupervisor(initialConfig, ports, options = {}) {
28678
28743
  installedSource = config2.source;
28679
28744
  return void 0;
28680
28745
  };
28681
- const socket = prepareHeadroomSocket(fs29, ports.socketTrust, paths, ports.ownPid);
28746
+ const socket = prepareHeadroomSocket(fs30, ports.socketTrust, paths, ports.ownPid);
28682
28747
  if (socket.refused !== void 0) {
28683
28748
  return fail(socket.refused);
28684
28749
  }
28685
28750
  const { socketPath } = socket;
28686
- pruneStaleHeadroomSockets(fs29, paths, ports.isRunning);
28687
- pruneStaleAllowlistTemporaries(fs29, paths.headroomAllowlistFile, ports.isRunning);
28751
+ pruneStaleHeadroomSockets(fs30, paths, ports.isRunning);
28752
+ pruneStaleAllowlistTemporaries(fs30, paths.headroomAllowlistFile, ports.isRunning);
28688
28753
  const installFailure = ensureInstalled();
28689
28754
  if (installFailure !== void 0) {
28690
28755
  return fail(installFailure);
28691
28756
  }
28692
28757
  const version2 = ports.headroomVersion() ?? "unknown";
28693
28758
  writeOwnState({ supervisorPid: ports.ownPid, version: version2, installedSource });
28694
- ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: managing headroom on allowlist [${currentHeadroomAllowlistInputs(fs29, paths, ports.frontDoorLiveness).frontDoorOrigins.join(", ")}]`);
28759
+ ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: managing headroom on allowlist [${currentHeadroomAllowlistInputs(fs30, paths, ports.frontDoorLiveness).frontDoorOrigins.join(", ")}]`);
28695
28760
  const orphanPid = previousState?.headroomPid;
28696
28761
  const orphanSocket = previousState?.socketPath ?? (previousState?.supervisorPid === void 0 ? void 0 : headroomSocketPath(paths, previousState.supervisorPid));
28697
28762
  const orphanIdentity = orphanPid === void 0 || orphanSocket === void 0 || !ports.isRunning(orphanPid) ? void 0 : daemonIdentity(ports.daemonCommandLine(orphanPid), orphanSocket);
@@ -28726,12 +28791,12 @@ async function runSupervisor(initialConfig, ports, options = {}) {
28726
28791
  ticks += 1;
28727
28792
  config2 = ports.readConfig();
28728
28793
  const settingsHash = hashSettings(config2.settings);
28729
- const inputs = currentHeadroomAllowlistInputs(fs29, paths, ports.frontDoorLiveness);
28730
- pruneDeadFrontDoorDirectRecords(fs29, paths.frontdoorDirectRecordsDir, inputs.frontDoorRecords, inputs.frontDoorLiveness);
28731
- pruneMalformedFrontDoorDirectFiles(fs29, paths.frontdoorDirectRecordsDir, ports.isRunning);
28794
+ const inputs = currentHeadroomAllowlistInputs(fs30, paths, ports.frontDoorLiveness);
28795
+ pruneDeadFrontDoorDirectRecords(fs30, paths.frontdoorDirectRecordsDir, inputs.frontDoorRecords, inputs.frontDoorLiveness);
28796
+ pruneMalformedFrontDoorDirectFiles(fs30, paths.frontdoorDirectRecordsDir, ports.isRunning);
28732
28797
  const allowlist = inputs.frontDoorOrigins;
28733
28798
  const allowlistHash = hashAllowlist(allowlist);
28734
- pruneDeadSessions(fs29, paths.headroomSessionsDir, ports.isRunning);
28799
+ pruneDeadSessions(fs30, paths.headroomSessionsDir, ports.isRunning);
28735
28800
  const ownsNow = ownsState();
28736
28801
  if (!ownsNow && !superseded) {
28737
28802
  ports.log("agent-shim headroom supervisor: another supervisor now owns the state file; serving this daemon's own sessions until they end");
@@ -28778,7 +28843,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
28778
28843
  runningSettingsHash = settingsHash;
28779
28844
  const recorded = writeOwnState(servingState(pid));
28780
28845
  if (recorded) {
28781
- fs29.removeRecursive(paths.headroomLockFile);
28846
+ fs30.removeRecursive(paths.headroomLockFile);
28782
28847
  }
28783
28848
  idleSince = void 0;
28784
28849
  ports.log(`agent-shim headroom supervisor: headroom pid ${String(pid)} ready on unix socket ${socketPath}`);
@@ -28806,7 +28871,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
28806
28871
  ports.log(`agent-shim headroom supervisor: headroom pid ${String(headroomPid)} now serves allowlist [${allowlist.join(", ")}]`);
28807
28872
  }
28808
28873
  if (runningSettingsHash !== settingsHash || installedSource !== config2.source) {
28809
- if (sessionsForSupervisor(fs29, paths.headroomSessionsDir, ports.ownPid).length === 0) {
28874
+ if (sessionsForSupervisor(fs30, paths.headroomSessionsDir, ports.ownPid).length === 0) {
28810
28875
  ports.log("agent-shim headroom supervisor: configuration drifted and no sessions are live; restarting headroom");
28811
28876
  ports.stopProcess(headroomPid);
28812
28877
  headroomPid = void 0;
@@ -28815,7 +28880,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
28815
28880
  continue;
28816
28881
  }
28817
28882
  }
28818
- const sessions = sessionsForSupervisor(fs29, paths.headroomSessionsDir, ports.ownPid);
28883
+ const sessions = sessionsForSupervisor(fs30, paths.headroomSessionsDir, ports.ownPid);
28819
28884
  if (sessions.length === 0) {
28820
28885
  idleSince ??= ports.now();
28821
28886
  const idleMs = ports.now() - idleSince;
@@ -28840,9 +28905,9 @@ function undeterminedFrontDoors(inputs) {
28840
28905
  return reason === void 0 ? [] : [{ pid: record2.pid, origin: directOrigin(record2.directPort), reason }];
28841
28906
  });
28842
28907
  }
28843
- function currentHeadroomAllowlistInputs(fs29, paths, frontDoorLiveness) {
28844
- const named = frontDoorOrigin(readFrontDoorState(fs29, paths.frontdoorStateFile));
28845
- const records = listFrontDoorDirectRecords(fs29, paths.frontdoorDirectRecordsDir);
28908
+ function currentHeadroomAllowlistInputs(fs30, paths, frontDoorLiveness) {
28909
+ const named = frontDoorOrigin(readFrontDoorState(fs30, paths.frontdoorStateFile));
28910
+ const records = listFrontDoorDirectRecords(fs30, paths.frontdoorDirectRecordsDir);
28846
28911
  const liveness = frontDoorLiveness(records.map((record2) => record2.pid));
28847
28912
  const live = liveFrontDoorDirectRecords(records, liveness).map((record2) => directOrigin(record2.directPort));
28848
28913
  return {
@@ -28851,8 +28916,8 @@ function currentHeadroomAllowlistInputs(fs29, paths, frontDoorLiveness) {
28851
28916
  frontDoorOrigins: [.../* @__PURE__ */ new Set([...named === void 0 ? [] : [named], ...live])].sort()
28852
28917
  };
28853
28918
  }
28854
- function launchRequiredUpstreams(fs29, paths) {
28855
- const door = frontDoorOrigin(readFrontDoorState(fs29, paths.frontdoorStateFile));
28919
+ function launchRequiredUpstreams(fs30, paths) {
28920
+ const door = frontDoorOrigin(readFrontDoorState(fs30, paths.frontdoorStateFile));
28856
28921
  return door === void 0 ? [] : [door];
28857
28922
  }
28858
28923
  async function waitUntilReady(ports, socketPath, pid) {
@@ -28930,8 +28995,8 @@ var init_report = __esm({
28930
28995
  });
28931
28996
 
28932
28997
  // src/logStyle.ts
28933
- function styledDiagnostic(style, colour, text2) {
28934
- return text2.split("\n").map((line, index) => {
28998
+ function styledDiagnostic(style, colour, text3) {
28999
+ return text3.split("\n").map((line, index) => {
28935
29000
  const lead = index === 0 ? DIAGNOSTIC_LEAD.exec(line) : null;
28936
29001
  if (lead === null) {
28937
29002
  return style([colour], line);
@@ -28959,7 +29024,7 @@ function createLogPort(sinks, styleFor) {
28959
29024
  };
28960
29025
  }
28961
29026
  function styleTextFor(stream) {
28962
- return (formats, text2) => (0, import_node_util3.styleText)([...formats], text2, { stream });
29027
+ return (formats, text3) => (0, import_node_util3.styleText)([...formats], text3, { stream });
28963
29028
  }
28964
29029
  var import_node_util3, DIAGNOSTIC_LEAD;
28965
29030
  var init_logStyle = __esm({
@@ -31779,8 +31844,8 @@ var init_classify = __esm({
31779
31844
  function poolNameOf(selector) {
31780
31845
  return selector.startsWith(POOL_SELECTOR_PREFIX) ? selector.slice(POOL_SELECTOR_PREFIX.length) : void 0;
31781
31846
  }
31782
- function readActiveIdentity(fs29, activeIdentityFile) {
31783
- const trimmed = fs29.readFileUtf8(activeIdentityFile)?.trim();
31847
+ function readActiveIdentity(fs30, activeIdentityFile) {
31848
+ const trimmed = fs30.readFileUtf8(activeIdentityFile)?.trim();
31784
31849
  return trimmed === void 0 || trimmed === "" ? void 0 : trimmed;
31785
31850
  }
31786
31851
  function isNonEmpty(value2) {
@@ -31827,8 +31892,8 @@ function decideConfigProfile(params) {
31827
31892
  }
31828
31893
  return { source: "none" };
31829
31894
  }
31830
- function loadIdentity(identitiesDir, name, fs29) {
31831
- return loadConfigFile(import_node_path11.default.join(identitiesDir, name, "identity.json"), IdentitySchema, fs29.readConfigFile);
31895
+ function loadIdentity(identitiesDir, name, fs30) {
31896
+ return loadConfigFile(import_node_path11.default.join(identitiesDir, name, "identity.json"), IdentitySchema, fs30.readConfigFile);
31832
31897
  }
31833
31898
  var import_node_path11, IDENTITY_DECISION_SOURCES, CONFIG_PROFILE_DECISION_SOURCES;
31834
31899
  var init_identity = __esm({
@@ -31868,6 +31933,148 @@ var init_identity = __esm({
31868
31933
  }
31869
31934
  });
31870
31935
 
31936
+ // src/statusline/keys.ts
31937
+ function valueAt(source, path66) {
31938
+ let current = source;
31939
+ for (const part of path66) {
31940
+ if (!isPlainObject2(current)) {
31941
+ return void 0;
31942
+ }
31943
+ current = current[part];
31944
+ }
31945
+ return current;
31946
+ }
31947
+ function keyOf(path66, leaf) {
31948
+ const common = { path: path66.join("."), description: leaf.description ?? "", defaultValue: valueAt(STATUSLINE_DEFAULTS, path66) };
31949
+ if (leaf instanceof external_exports.ZodNumber) {
31950
+ return { ...common, kind: "integer", choices: [] };
31951
+ }
31952
+ if (leaf instanceof external_exports.ZodString) {
31953
+ return { ...common, kind: "text", choices: [] };
31954
+ }
31955
+ if (leaf instanceof external_exports.ZodUnion) {
31956
+ return { ...common, kind: "colour", choices: [...STATUSLINE_COLOUR_NAMES] };
31957
+ }
31958
+ if (leaf instanceof external_exports.ZodEnum) {
31959
+ return { ...common, kind: "choice", choices: Object.values(leaf.enum).map(String) };
31960
+ }
31961
+ if (leaf instanceof external_exports.ZodArray && leaf.element instanceof external_exports.ZodEnum) {
31962
+ return { ...common, kind: "list", choices: Object.values(leaf.element.enum).map(String) };
31963
+ }
31964
+ throw new TypeError(`statusline setting ${path66.join(".")} has a kind the key listing does not describe`);
31965
+ }
31966
+ function walk(shape, prefix) {
31967
+ return Object.entries(shape).flatMap(([name, schema]) => schema instanceof external_exports.ZodObject ? walk(schema.shape, [...prefix, name]) : [keyOf([...prefix, name], schema)]);
31968
+ }
31969
+ function statuslineKeys() {
31970
+ return walk(ResolvedStatuslineSchema.shape, []);
31971
+ }
31972
+ function formatStatuslineKeys(keys) {
31973
+ return keys.map((key) => {
31974
+ const takes = key.kind === "choice" || key.kind === "list" || key.kind === "colour" ? `${key.kind} of ${key.choices.join(", ")}` : key.kind;
31975
+ return `${key.path} (${takes}; default ${JSON.stringify(key.defaultValue)})
31976
+ ${key.description}`;
31977
+ }).join("\n");
31978
+ }
31979
+ var init_keys = __esm({
31980
+ "src/statusline/keys.ts"() {
31981
+ "use strict";
31982
+ init_zod();
31983
+ init_statusline();
31984
+ }
31985
+ });
31986
+
31987
+ // src/statusline/change.ts
31988
+ function keyNamed(path66) {
31989
+ const found = statuslineKeys().find((key) => key.path === path66);
31990
+ if (found === void 0) {
31991
+ throw new UsageError(`"${path66}" is not a statusline setting; \`agent-shim statusline keys\` lists them.`);
31992
+ }
31993
+ return found;
31994
+ }
31995
+ function parseStatuslineAssignment(text3) {
31996
+ const split = text3.indexOf("=");
31997
+ if (split < 1) {
31998
+ throw new UsageError(`"${text3}" is not <setting>=<value>.`);
31999
+ }
32000
+ const path66 = text3.slice(0, split);
32001
+ const raw = text3.slice(split + 1);
32002
+ const key = keyNamed(path66);
32003
+ switch (key.kind) {
32004
+ case "integer": {
32005
+ const number5 = Number(raw);
32006
+ if (raw.trim() === "" || !Number.isFinite(number5)) {
32007
+ throw new UsageError(`${path66}: "${raw}" is not a number.`);
32008
+ }
32009
+ return { path: path66, value: number5 };
32010
+ }
32011
+ case "text":
32012
+ case "choice":
32013
+ return { path: path66, value: raw };
32014
+ case "colour":
32015
+ return { path: path66, value: /^\d+$/.test(raw) ? Number(raw) : raw };
32016
+ case "list":
32017
+ return { path: path66, value: raw === "" ? [] : raw.split(",") };
32018
+ default:
32019
+ return key.kind;
32020
+ }
32021
+ }
32022
+ function setAt(target, path66, value2) {
32023
+ const [head, ...rest] = path66;
32024
+ if (head === void 0) {
32025
+ return;
32026
+ }
32027
+ if (rest.length === 0) {
32028
+ target[head] = value2;
32029
+ return;
32030
+ }
32031
+ const child = target[head];
32032
+ const next = isPlainObject2(child) ? child : {};
32033
+ target[head] = next;
32034
+ setAt(next, rest, value2);
32035
+ }
32036
+ function removeAt(target, path66) {
32037
+ const [head, ...rest] = path66;
32038
+ if (head === void 0) {
32039
+ return;
32040
+ }
32041
+ const child = target[head];
32042
+ if (rest.length === 0) {
32043
+ Reflect.deleteProperty(target, head);
32044
+ return;
32045
+ }
32046
+ if (isPlainObject2(child)) {
32047
+ removeAt(child, rest);
32048
+ if (Object.keys(child).length === 0) {
32049
+ Reflect.deleteProperty(target, head);
32050
+ }
32051
+ }
32052
+ }
32053
+ function applyStatuslineChange(existing, change) {
32054
+ const draft = structuredClone(existing ?? {});
32055
+ for (const [path66, value2] of Object.entries(change.set ?? {})) {
32056
+ keyNamed(path66);
32057
+ setAt(draft, path66.split("."), value2);
32058
+ }
32059
+ for (const path66 of change.unset ?? []) {
32060
+ keyNamed(path66);
32061
+ removeAt(draft, path66.split("."));
32062
+ }
32063
+ const result = StatuslineSchema.safeParse(draft);
32064
+ if (!result.success) {
32065
+ throw new UsageError(`statusline: ${result.error.issues.map((issue2) => `${issue2.path.join(".")}: ${issue2.message}`).join("; ")}.`);
32066
+ }
32067
+ return Object.keys(result.data).length === 0 ? void 0 : result.data;
32068
+ }
32069
+ var init_change = __esm({
32070
+ "src/statusline/change.ts"() {
32071
+ "use strict";
32072
+ init_cliError();
32073
+ init_statusline();
32074
+ init_keys();
32075
+ }
32076
+ });
32077
+
31871
32078
  // src/configProfilesStore.ts
31872
32079
  function profileJsonPath(paths, name) {
31873
32080
  return import_node_path12.default.join(paths.configProfilesDir, `${name}.json`);
@@ -31967,17 +32174,6 @@ function removeProfile(paths, name) {
31967
32174
  requireProfileExists(paths, name);
31968
32175
  import_node_fs5.default.rmSync(profileJsonPath(paths, name));
31969
32176
  }
31970
- function withStatuslineChange(existing, change) {
31971
- const merged = new Map(Object.entries({ ...existing }));
31972
- for (const [key, value2] of Object.entries(change)) {
31973
- if (value2 === false) {
31974
- merged.delete(key);
31975
- } else {
31976
- merged.set(key, value2);
31977
- }
31978
- }
31979
- return merged.size === 0 ? void 0 : StatuslineSchema.parse(Object.fromEntries(merged));
31980
- }
31981
32177
  function applyProfileChange(paths, name, change) {
31982
32178
  let touched = false;
31983
32179
  if (change.category !== void 0) {
@@ -32027,7 +32223,7 @@ function applyProfileChange(paths, name, change) {
32027
32223
  launchPatch.explain = change.launchExplain;
32028
32224
  }
32029
32225
  if (change.launchStatusline !== void 0) {
32030
- launchPatch.statusline = withStatuslineChange(readProfile(paths, name)?.launch?.statusline, change.launchStatusline);
32226
+ launchPatch.statusline = applyStatuslineChange(readProfile(paths, name)?.launch?.statusline, change.launchStatusline);
32031
32227
  }
32032
32228
  if (Object.keys(launchPatch).length > 0) {
32033
32229
  setProfileLaunchFlags(paths, name, launchPatch);
@@ -32044,7 +32240,7 @@ var init_configProfilesStore = __esm({
32044
32240
  init_store();
32045
32241
  init_schema();
32046
32242
  init_cliError();
32047
- init_statusline();
32243
+ init_change();
32048
32244
  init_load();
32049
32245
  ProfileNotFoundError = class extends CliError {
32050
32246
  constructor(profileName) {
@@ -32671,9 +32867,9 @@ function referencesFact(when, key) {
32671
32867
  if (when === void 0 || !("kind" in when)) {
32672
32868
  return false;
32673
32869
  }
32674
- const walk2 = (node2) => {
32870
+ const walk3 = (node2) => {
32675
32871
  if (Array.isArray(node2)) {
32676
- return node2.some(walk2);
32872
+ return node2.some(walk3);
32677
32873
  }
32678
32874
  if (typeof node2 !== "object" || node2 === null) {
32679
32875
  return false;
@@ -32681,9 +32877,9 @@ function referencesFact(when, key) {
32681
32877
  if ("kind" in node2 && node2.kind === "reference" && "key" in node2 && node2.key === key) {
32682
32878
  return true;
32683
32879
  }
32684
- return Object.values(node2).some(walk2);
32880
+ return Object.values(node2).some(walk3);
32685
32881
  };
32686
- return walk2(when);
32882
+ return walk3(when);
32687
32883
  }
32688
32884
  function isVacuousWhen(when) {
32689
32885
  return when !== void 0 && !("kind" in when) && Object.keys(when).length === 0;
@@ -33003,7 +33199,7 @@ function flattenLayers(layers, options) {
33003
33199
  launch.proxyBypass = layer.launch.proxyBypass;
33004
33200
  }
33005
33201
  if (layer.launch.statusline !== void 0) {
33006
- launch.statusline = { ...launch.statusline, ...layer.launch.statusline };
33202
+ launch.statusline = StatuslineSchema.parse(mergeStatuslineSettings(launch.statusline, layer.launch.statusline));
33007
33203
  }
33008
33204
  }
33009
33205
  if (layer.models !== void 0) {
@@ -33184,6 +33380,7 @@ var init_flatten = __esm({
33184
33380
  "src/resolve/flatten.ts"() {
33185
33381
  "use strict";
33186
33382
  init_schema();
33383
+ init_statusline();
33187
33384
  init_conditions();
33188
33385
  init_match();
33189
33386
  }
@@ -33553,8 +33750,8 @@ var init_pipeline = __esm({
33553
33750
  });
33554
33751
 
33555
33752
  // src/launcher/farm.ts
33556
- function readFarmManifest(fs29, farmRoot) {
33557
- const raw = fs29.readFileUtf8(import_node_path19.default.join(farmRoot, FARM_MANIFEST_FILENAME)) ?? fs29.readFileUtf8(import_node_path19.default.join(farmRoot, LEGACY_FARM_MANIFEST_FILENAME));
33753
+ function readFarmManifest(fs30, farmRoot) {
33754
+ const raw = fs30.readFileUtf8(import_node_path19.default.join(farmRoot, FARM_MANIFEST_FILENAME)) ?? fs30.readFileUtf8(import_node_path19.default.join(farmRoot, LEGACY_FARM_MANIFEST_FILENAME));
33558
33755
  if (raw === void 0) {
33559
33756
  return void 0;
33560
33757
  }
@@ -33612,9 +33809,9 @@ function buildEntryFacts(params) {
33612
33809
  entries
33613
33810
  };
33614
33811
  }
33615
- function listSubtree(fs29, root, rel) {
33812
+ function listSubtree(fs30, root, rel) {
33616
33813
  const absolute = import_node_path19.default.join(root, rel);
33617
- const stat = fs29.lstat(absolute);
33814
+ const stat = fs30.lstat(absolute);
33618
33815
  if (stat === void 0) {
33619
33816
  return [];
33620
33817
  }
@@ -33622,10 +33819,10 @@ function listSubtree(fs29, root, rel) {
33622
33819
  return [{ rel, kind: "symlink" }];
33623
33820
  }
33624
33821
  if (stat.kind === "dir") {
33625
- const children = [...fs29.readdir(absolute)].sort().flatMap((name) => listSubtree(fs29, root, `${rel}/${name}`));
33822
+ const children = [...fs30.readdir(absolute)].sort().flatMap((name) => listSubtree(fs30, root, `${rel}/${name}`));
33626
33823
  return [{ rel, kind: "dir" }, ...children];
33627
33824
  }
33628
- const contentHash = fs29.hashFile(absolute);
33825
+ const contentHash = fs30.hashFile(absolute);
33629
33826
  return [{ rel, kind: "file", ...contentHash === void 0 ? {} : { contentHash } }];
33630
33827
  }
33631
33828
  function topLevelScopeRoots(roots) {
@@ -33639,25 +33836,25 @@ function topLevelScopeRoots(roots) {
33639
33836
  }
33640
33837
  return kept;
33641
33838
  }
33642
- function reconciliationScope(fs29, farmRoot, manifest) {
33839
+ function reconciliationScope(fs30, farmRoot, manifest) {
33643
33840
  if (manifest !== void 0) {
33644
33841
  return topLevelScopeRoots(manifest.materialised);
33645
33842
  }
33646
- return [...fs29.readdir(farmRoot)].filter((name) => name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME && fs29.lstat(import_node_path19.default.join(farmRoot, name))?.kind === "dir").sort();
33843
+ return [...fs30.readdir(farmRoot)].filter((name) => name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME && fs30.lstat(import_node_path19.default.join(farmRoot, name))?.kind === "dir").sort();
33647
33844
  }
33648
- function collectFarmListing(fs29, farmRoot, scopeRoots) {
33649
- return scopeRoots.flatMap((root) => listSubtree(fs29, farmRoot, root));
33845
+ function collectFarmListing(fs30, farmRoot, scopeRoots) {
33846
+ return scopeRoots.flatMap((root) => listSubtree(fs30, farmRoot, root));
33650
33847
  }
33651
- function collectCanonicalCounterparts(fs29, claudeHome, farmListing) {
33848
+ function collectCanonicalCounterparts(fs30, claudeHome, farmListing) {
33652
33849
  const out = [];
33653
33850
  for (const entry of farmListing) {
33654
33851
  const absolute = import_node_path19.default.join(claudeHome, entry.rel);
33655
- const stat = fs29.lstat(absolute);
33852
+ const stat = fs30.lstat(absolute);
33656
33853
  if (stat === void 0) {
33657
33854
  continue;
33658
33855
  }
33659
33856
  if (stat.kind === "file") {
33660
- const contentHash = fs29.hashFile(absolute);
33857
+ const contentHash = fs30.hashFile(absolute);
33661
33858
  out.push({ rel: entry.rel, kind: "file", ...contentHash === void 0 ? {} : { contentHash } });
33662
33859
  continue;
33663
33860
  }
@@ -34920,7 +35117,7 @@ function keyUsageExtension(bits) {
34920
35117
  }
34921
35118
  function ipv6Groups(address) {
34922
35119
  const [head = "", tail] = address.split("::");
34923
- const split = (text2) => text2 === "" ? [] : text2.split(":");
35120
+ const split = (text3) => text3 === "" ? [] : text3.split(":");
34924
35121
  const expand = (groups) => groups.flatMap((group) => {
34925
35122
  if (!import_node_net.default.isIPv4(group)) {
34926
35123
  return [Number.parseInt(group, HEX_RADIX)];
@@ -35330,9 +35527,9 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
35330
35527
  }
35331
35528
  }
35332
35529
  async function serveFrontDoor(idleShutdownMinutes, ports, options) {
35333
- const { fs: fs29, paths } = ports;
35530
+ const { fs: fs30, paths } = ports;
35334
35531
  const servingBinary = ports.statOwnExecutable();
35335
- const previous = readFrontDoorState(fs29, paths.frontdoorStateFile);
35532
+ const previous = readFrontDoorState(fs30, paths.frontdoorStateFile);
35336
35533
  let lastPort = previous?.lastPort;
35337
35534
  let lastConnectPort = previous?.lastConnectPort;
35338
35535
  let lastDirectPort = previous?.lastDirectPort;
@@ -35343,12 +35540,12 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
35343
35540
  });
35344
35541
  const fail = (message) => {
35345
35542
  ports.closeRcStreamHub();
35346
- writeFrontDoorState(fs29, paths.frontdoorStateFile, { lastError: message, ...sticky() });
35347
- fs29.removeRecursive(paths.frontdoorLockFile);
35543
+ writeFrontDoorState(fs30, paths.frontdoorStateFile, { lastError: message, ...sticky() });
35544
+ fs30.removeRecursive(paths.frontdoorLockFile);
35348
35545
  ports.log(`agent-shim frontdoor supervisor: ${message}`);
35349
35546
  return 1;
35350
35547
  };
35351
- writeFrontDoorState(fs29, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, ...sticky() });
35548
+ writeFrontDoorState(fs30, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, ...sticky() });
35352
35549
  const previousSticky = lastPort;
35353
35550
  let http9;
35354
35551
  try {
@@ -35388,16 +35585,16 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
35388
35585
  ports.log(`agent-shim frontdoor supervisor: sticky direct port ${String(previousStickyDirect)} was occupied; moving to ${String(direct.port)} (headroom admits the new address once its supervisor rewrites the allowlist file)`);
35389
35586
  }
35390
35587
  lastDirectPort = direct.port;
35391
- writeFrontDoorDirectRecord(fs29, paths.frontdoorDirectRecordsDir, { pid: ports.ownPid, directPort: direct.port });
35392
- writeFrontDoorState(fs29, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http9.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
35588
+ writeFrontDoorDirectRecord(fs30, paths.frontdoorDirectRecordsDir, { pid: ports.ownPid, directPort: direct.port });
35589
+ writeFrontDoorState(fs30, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http9.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
35393
35590
  ports.doorHealth.generation({ providerPort: http9.port, connectPort: connect3.port, directPort: direct.port });
35394
- fs29.removeRecursive(paths.frontdoorLockFile);
35591
+ fs30.removeRecursive(paths.frontdoorLockFile);
35395
35592
  ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http9.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
35396
35593
  const watchdog = ports.startWatchdog?.();
35397
35594
  let idleSince;
35398
35595
  let ticks = 0;
35399
35596
  const supersedingOwner = () => {
35400
- const owner = readFrontDoorState(fs29, paths.frontdoorStateFile)?.supervisorPid;
35597
+ const owner = readFrontDoorState(fs30, paths.frontdoorStateFile)?.supervisorPid;
35401
35598
  return owner !== void 0 && owner !== ports.ownPid && ports.isRunning(owner) ? owner : void 0;
35402
35599
  };
35403
35600
  let supersededBy;
@@ -35424,13 +35621,13 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
35424
35621
  ports.stopBackgroundWork?.();
35425
35622
  const drained = [direct.drain(), connect3.drain(), http9.drain()];
35426
35623
  if (supersedingOwner() === void 0) {
35427
- writeFrontDoorState(fs29, paths.frontdoorStateFile, sticky());
35624
+ writeFrontDoorState(fs30, paths.frontdoorStateFile, sticky());
35428
35625
  }
35429
- markFrontDoorDraining(fs29, paths.frontdoorDrainingDir, ports.ownPid);
35626
+ markFrontDoorDraining(fs30, paths.frontdoorDrainingDir, ports.ownPid);
35430
35627
  ports.closeRcStreamHub();
35431
35628
  await Promise.all(drained);
35432
- unmarkFrontDoorDraining(fs29, paths.frontdoorDrainingDir, ports.ownPid);
35433
- removeFrontDoorDirectRecord(fs29, paths.frontdoorDirectRecordsDir, ports.ownPid);
35629
+ unmarkFrontDoorDraining(fs30, paths.frontdoorDrainingDir, ports.ownPid);
35630
+ removeFrontDoorDirectRecord(fs30, paths.frontdoorDirectRecordsDir, ports.ownPid);
35434
35631
  ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: the connections this door carried have ended; exiting`);
35435
35632
  return 0;
35436
35633
  };
@@ -35440,12 +35637,12 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
35440
35637
  await connect3.close();
35441
35638
  await http9.close();
35442
35639
  ports.closeRcStreamHub();
35443
- removeFrontDoorDirectRecord(fs29, paths.frontdoorDirectRecordsDir, ports.ownPid);
35640
+ removeFrontDoorDirectRecord(fs30, paths.frontdoorDirectRecordsDir, ports.ownPid);
35444
35641
  };
35445
35642
  const shutdown = async () => {
35446
35643
  await closeServing();
35447
35644
  if (supersedingOwner() === void 0) {
35448
- writeFrontDoorState(fs29, paths.frontdoorStateFile, sticky());
35645
+ writeFrontDoorState(fs30, paths.frontdoorStateFile, sticky());
35449
35646
  }
35450
35647
  return 0;
35451
35648
  };
@@ -35459,8 +35656,8 @@ async function serveFrontDoor(idleShutdownMinutes, ports, options) {
35459
35656
  return FRONTDOOR_SUPERVISOR_STILL_RUNNING;
35460
35657
  }
35461
35658
  ticks += 1;
35462
- const listed = listFrontDoorSessions(fs29, paths.frontdoorSessionsDir);
35463
- const pruned = pruneDeadFrontDoorSessions(fs29, paths.frontdoorSessionsDir, ports.isRunning);
35659
+ const listed = listFrontDoorSessions(fs30, paths.frontdoorSessionsDir);
35660
+ const pruned = pruneDeadFrontDoorSessions(fs30, paths.frontdoorSessionsDir, ports.isRunning);
35464
35661
  ports.observeLaunchRegistry(listed, pruned);
35465
35662
  ports.checkQuotaExpiry();
35466
35663
  const prunedPids = new Set(pruned);
@@ -36010,7 +36207,7 @@ var init_package = __esm({
36010
36207
  "package.json"() {
36011
36208
  package_default = {
36012
36209
  name: "claude-use",
36013
- version: "11.50.2",
36210
+ version: "11.52.1",
36014
36211
  description: "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
36015
36212
  license: "MIT",
36016
36213
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -36123,14 +36320,14 @@ function isIdentityName(name) {
36123
36320
  function claudeJsonPath(identitiesDir, identity) {
36124
36321
  return import_node_path25.default.join(identitiesDir, identity, CLAUDE_JSON);
36125
36322
  }
36126
- function readAccountMetadata(fs29, identitiesDir, identity) {
36323
+ function readAccountMetadata(fs30, identitiesDir, identity) {
36127
36324
  if (!isIdentityName(identity)) {
36128
36325
  throw new Error(`"${identity}" is not a valid identity name.`);
36129
36326
  }
36130
- return readAccountMetadataFile(fs29, claudeJsonPath(identitiesDir, identity));
36327
+ return readAccountMetadataFile(fs30, claudeJsonPath(identitiesDir, identity));
36131
36328
  }
36132
- function readAccountMetadataFile(fs29, file2) {
36133
- const raw = fs29.readFileUtf8(file2);
36329
+ function readAccountMetadataFile(fs30, file2) {
36330
+ const raw = fs30.readFileUtf8(file2);
36134
36331
  if (raw === void 0) {
36135
36332
  return void 0;
36136
36333
  }
@@ -36160,19 +36357,19 @@ function readAccountMetadataFile(fs29, file2) {
36160
36357
  }
36161
36358
  return account.data;
36162
36359
  }
36163
- function createAccountReader(fs29, identitiesDir) {
36360
+ function createAccountReader(fs30, identitiesDir) {
36164
36361
  const cache = /* @__PURE__ */ new Map();
36165
36362
  return (identity) => {
36166
36363
  if (!isIdentityName(identity)) {
36167
36364
  throw new Error(`"${identity}" is not a valid identity name.`);
36168
36365
  }
36169
- const stat = fs29.lstat(claudeJsonPath(identitiesDir, identity));
36366
+ const stat = fs30.lstat(claudeJsonPath(identitiesDir, identity));
36170
36367
  const stamp = stat === void 0 ? "absent" : `${String(stat.mtimeMs)}:${String(stat.sizeBytes)}`;
36171
36368
  const cached2 = cache.get(identity);
36172
36369
  if (cached2?.stamp === stamp) {
36173
36370
  return cached2.account;
36174
36371
  }
36175
- const account = readAccountMetadata(fs29, identitiesDir, identity);
36372
+ const account = readAccountMetadata(fs30, identitiesDir, identity);
36176
36373
  cache.set(identity, { stamp, account });
36177
36374
  return account;
36178
36375
  };
@@ -36274,9 +36471,9 @@ function errorInfo(raw) {
36274
36471
  function isObject3(value2) {
36275
36472
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
36276
36473
  }
36277
- function parseJson2(text2) {
36474
+ function parseJson2(text3) {
36278
36475
  try {
36279
- const parsed = JSON.parse(text2);
36476
+ const parsed = JSON.parse(text3);
36280
36477
  return parsed;
36281
36478
  } catch {
36282
36479
  return void 0;
@@ -36324,26 +36521,26 @@ function createSseScanner() {
36324
36521
  return void 0;
36325
36522
  };
36326
36523
  const completeLine = (complete) => {
36327
- const text2 = complete.endsWith("\r") ? complete.slice(0, -1) : complete;
36328
- if (text2 === "") {
36524
+ const text3 = complete.endsWith("\r") ? complete.slice(0, -1) : complete;
36525
+ if (text3 === "") {
36329
36526
  dispatch();
36330
36527
  return;
36331
36528
  }
36332
- if (text2.startsWith("event:")) {
36333
- eventName = text2.slice("event:".length).trim();
36529
+ if (text3.startsWith("event:")) {
36530
+ eventName = text3.slice("event:".length).trim();
36334
36531
  return;
36335
36532
  }
36336
- if (text2.startsWith("data:")) {
36337
- const value2 = text2.slice("data:".length);
36533
+ if (text3.startsWith("data:")) {
36534
+ const value2 = text3.slice("data:".length);
36338
36535
  data.push(value2.startsWith(" ") ? value2.slice(1) : value2);
36339
36536
  }
36340
36537
  };
36341
36538
  return {
36342
- push: (text2) => {
36539
+ push: (text3) => {
36343
36540
  let start = 0;
36344
36541
  for (; ; ) {
36345
- const newline = text2.indexOf("\n", start);
36346
- const piece = newline === -1 ? text2.slice(start) : text2.slice(start, newline);
36542
+ const newline = text3.indexOf("\n", start);
36543
+ const piece = newline === -1 ? text3.slice(start) : text3.slice(start, newline);
36347
36544
  if (!skipping) {
36348
36545
  line += piece;
36349
36546
  if (worthKeeping(line) === false) {
@@ -36457,8 +36654,8 @@ function createJsonScanner() {
36457
36654
  }
36458
36655
  };
36459
36656
  return {
36460
- push: (text2) => {
36461
- for (const char of text2) {
36657
+ push: (text3) => {
36658
+ for (const char of text3) {
36462
36659
  step2(char);
36463
36660
  }
36464
36661
  },
@@ -36585,13 +36782,13 @@ function createUsageMiddleware(deps) {
36585
36782
  const scanner = scannerFor(event.headers);
36586
36783
  const decoder = scanner === void 0 ? null : decoderFor(headerValue(event.headers, "content-encoding"));
36587
36784
  let scanning = scanner !== void 0 && decoder !== void 0;
36588
- const text2 = new TextDecoder();
36785
+ const text3 = new TextDecoder();
36589
36786
  const feed = (bytes, final) => {
36590
36787
  if (!scanning || scanner === void 0) {
36591
36788
  return;
36592
36789
  }
36593
36790
  try {
36594
- scanner.push(text2.decode(bytes, { stream: !final }));
36791
+ scanner.push(text3.decode(bytes, { stream: !final }));
36595
36792
  } catch (error63) {
36596
36793
  scanning = false;
36597
36794
  deps.log(`usage: body scan failed for ${event.route}: ${error63 instanceof Error ? error63.message : String(error63)}`);
@@ -37002,8 +37199,8 @@ function segmentDay(epochMs) {
37002
37199
  function segmentName(day, pid) {
37003
37200
  return `${day}.${String(pid)}.jsonl`;
37004
37201
  }
37005
- function listLogSegments(fs29, logDir) {
37006
- return fs29.readdir(logDir).flatMap((name) => {
37202
+ function listLogSegments(fs30, logDir) {
37203
+ return fs30.readdir(logDir).flatMap((name) => {
37007
37204
  const match = SEGMENT_RE.exec(name);
37008
37205
  const day = match?.[1];
37009
37206
  if (day === void 0) {
@@ -37012,15 +37209,15 @@ function listLogSegments(fs29, logDir) {
37012
37209
  return [{ name, day, endsAt: Date.parse(`${day}T00:00:00.000Z`) + DAY_MS }];
37013
37210
  }).sort((left, right) => left.day.localeCompare(right.day) || left.name.localeCompare(right.name));
37014
37211
  }
37015
- function readUsageLog(fs29, logDir, options = {}) {
37212
+ function readUsageLog(fs30, logDir, options = {}) {
37016
37213
  const { sinceMs } = options;
37017
37214
  const records = [];
37018
37215
  let invalidLines = 0;
37019
- for (const segment of listLogSegments(fs29, logDir)) {
37216
+ for (const segment of listLogSegments(fs30, logDir)) {
37020
37217
  if (sinceMs !== void 0 && segment.endsAt <= sinceMs) {
37021
37218
  continue;
37022
37219
  }
37023
- const contents = fs29.readFileUtf8(import_node_path26.default.join(logDir, segment.name));
37220
+ const contents = fs30.readFileUtf8(import_node_path26.default.join(logDir, segment.name));
37024
37221
  if (contents === void 0) {
37025
37222
  continue;
37026
37223
  }
@@ -37056,9 +37253,9 @@ function snapshotPath(snapshotsDir, identity) {
37056
37253
  }
37057
37254
  return import_node_path26.default.join(snapshotsDir, `${identity}.json`);
37058
37255
  }
37059
- function readUsageSnapshot(fs29, snapshotsDir, identity) {
37256
+ function readUsageSnapshot(fs30, snapshotsDir, identity) {
37060
37257
  const file2 = snapshotPath(snapshotsDir, identity);
37061
- const raw = fs29.readFileUtf8(file2);
37258
+ const raw = fs30.readFileUtf8(file2);
37062
37259
  if (raw === void 0) {
37063
37260
  return void 0;
37064
37261
  }
@@ -37074,8 +37271,8 @@ function readUsageSnapshot(fs29, snapshotsDir, identity) {
37074
37271
  }
37075
37272
  return snapshot.data;
37076
37273
  }
37077
- function listUsageSnapshots(fs29, snapshotsDir) {
37078
- return fs29.readdir(snapshotsDir).flatMap((name) => {
37274
+ function listUsageSnapshots(fs30, snapshotsDir) {
37275
+ return fs30.readdir(snapshotsDir).flatMap((name) => {
37079
37276
  if (!name.endsWith(".json")) {
37080
37277
  return [];
37081
37278
  }
@@ -37083,7 +37280,7 @@ function listUsageSnapshots(fs29, snapshotsDir) {
37083
37280
  if (!isIdentityName(identity)) {
37084
37281
  return [];
37085
37282
  }
37086
- const snapshot = readUsageSnapshot(fs29, snapshotsDir, identity);
37283
+ const snapshot = readUsageSnapshot(fs30, snapshotsDir, identity);
37087
37284
  return snapshot === void 0 ? [] : [snapshot];
37088
37285
  }).sort((left, right) => left.identity.localeCompare(right.identity));
37089
37286
  }
@@ -37157,11 +37354,11 @@ var init_read = __esm({
37157
37354
  });
37158
37355
 
37159
37356
  // src/usage/store.ts
37160
- function pruneUsageLog(fs29, logDir, nowMs) {
37357
+ function pruneUsageLog(fs30, logDir, nowMs) {
37161
37358
  const cutoff = nowMs - USAGE_RETENTION_MS;
37162
- for (const segment of listLogSegments(fs29, logDir)) {
37359
+ for (const segment of listLogSegments(fs30, logDir)) {
37163
37360
  if (segment.endsAt <= cutoff) {
37164
- fs29.removeRecursive(import_node_path27.default.join(logDir, segment.name));
37361
+ fs30.removeRecursive(import_node_path27.default.join(logDir, segment.name));
37165
37362
  }
37166
37363
  }
37167
37364
  }
@@ -37190,7 +37387,7 @@ function foldProviderState(current, record2) {
37190
37387
  };
37191
37388
  }
37192
37389
  function createUsageStore(deps) {
37193
- const { fs: fs29, paths } = deps;
37390
+ const { fs: fs30, paths } = deps;
37194
37391
  let prunedDay;
37195
37392
  const rewriteSnapshot = (identity, fold) => {
37196
37393
  if (!isIdentityName(identity)) {
@@ -37199,7 +37396,7 @@ function createUsageStore(deps) {
37199
37396
  }
37200
37397
  let current;
37201
37398
  try {
37202
- current = readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity);
37399
+ current = readUsageSnapshot(fs30, paths.usageSnapshotsDir, identity);
37203
37400
  } catch (error63) {
37204
37401
  if (!(error63 instanceof UsageSnapshotError)) {
37205
37402
  throw error63;
@@ -37226,8 +37423,8 @@ function createUsageStore(deps) {
37226
37423
  ...account === void 0 ? {} : { account },
37227
37424
  providers
37228
37425
  });
37229
- fs29.mkdirPrivate(paths.usageSnapshotsDir);
37230
- fs29.writeFilePrivate(snapshotPath(paths.usageSnapshotsDir, identity), `${JSON.stringify(snapshot, null, 2)}
37426
+ fs30.mkdirPrivate(paths.usageSnapshotsDir);
37427
+ fs30.writeFilePrivate(snapshotPath(paths.usageSnapshotsDir, identity), `${JSON.stringify(snapshot, null, 2)}
37231
37428
  `);
37232
37429
  deps.publish?.(snapshot);
37233
37430
  return true;
@@ -37236,14 +37433,14 @@ function createUsageStore(deps) {
37236
37433
  record: (input2) => {
37237
37434
  const record2 = UsageRecordSchema.parse(input2);
37238
37435
  const nowMs = deps.now();
37239
- fs29.mkdirPrivate(paths.usageDir);
37240
- fs29.mkdirPrivate(paths.usageLogDir);
37436
+ fs30.mkdirPrivate(paths.usageDir);
37437
+ fs30.mkdirPrivate(paths.usageLogDir);
37241
37438
  const day = segmentDay(nowMs);
37242
37439
  if (prunedDay !== day) {
37243
- pruneUsageLog(fs29, paths.usageLogDir, nowMs);
37440
+ pruneUsageLog(fs30, paths.usageLogDir, nowMs);
37244
37441
  prunedDay = day;
37245
37442
  }
37246
- fs29.appendFilePrivate(import_node_path27.default.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record2)}
37443
+ fs30.appendFilePrivate(import_node_path27.default.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record2)}
37247
37444
  `);
37248
37445
  deps.onRecord?.(record2);
37249
37446
  if (record2.identity !== void 0) {
@@ -37286,14 +37483,14 @@ var init_store2 = __esm({
37286
37483
  function errorMessage(error63) {
37287
37484
  return error63 instanceof Error ? error63.message : String(error63);
37288
37485
  }
37289
- function loadPoolMembers(fs29, paths, identities, nowMs) {
37486
+ function loadPoolMembers(fs30, paths, identities, nowMs) {
37290
37487
  const windowStartMs = nowMs - FIVE_HOUR_WINDOW_MS;
37291
- const log = readUsageLog(fs29, paths.usageLogDir, { sinceMs: windowStartMs });
37488
+ const log = readUsageLog(fs30, paths.usageLogDir, { sinceMs: windowStartMs });
37292
37489
  return identities.map((identity) => {
37293
37490
  const records = log.records.filter((record2) => record2.identity === identity && record2.provider === ANTHROPIC_PROVIDER && Date.parse(record2.at) >= windowStartMs);
37294
37491
  try {
37295
- const snapshot = readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity);
37296
- const account = readAccountMetadata(fs29, paths.identitiesDir, identity) ?? snapshot?.account;
37492
+ const snapshot = readUsageSnapshot(fs30, paths.usageSnapshotsDir, identity);
37493
+ const account = readAccountMetadata(fs30, paths.identitiesDir, identity) ?? snapshot?.account;
37297
37494
  return { identity, records, ...snapshot === void 0 ? {} : { snapshot }, ...account === void 0 ? {} : { account } };
37298
37495
  } catch (error63) {
37299
37496
  if (error63 instanceof UsageSnapshotError || error63 instanceof AccountMetadataError) {
@@ -37366,9 +37563,9 @@ function nestedMember(input2, nestedName, childStack, sticky) {
37366
37563
  missing: nested.missing
37367
37564
  };
37368
37565
  }
37369
- function readPicksFile(fs29, file2) {
37566
+ function readPicksFile(fs30, file2) {
37370
37567
  const empty = { schemaVersion: SCHEMA_VERSION, picks: {} };
37371
- const raw = fs29.readFileUtf8(file2);
37568
+ const raw = fs30.readFileUtf8(file2);
37372
37569
  if (raw === void 0) {
37373
37570
  return { file: empty };
37374
37571
  }
@@ -37381,17 +37578,17 @@ function readPicksFile(fs29, file2) {
37381
37578
  const result = PicksFileSchema.safeParse(parsed);
37382
37579
  return result.success ? { file: result.data } : { file: empty, problem: `${file2} is not a picks file this agent-shim can read` };
37383
37580
  }
37384
- function readStickyPick(fs29, picksFile, directory) {
37385
- const read = readPicksFile(fs29, picksFile);
37581
+ function readStickyPick(fs30, picksFile, directory) {
37582
+ const read = readPicksFile(fs30, picksFile);
37386
37583
  const entry = read.file.picks[directory];
37387
37584
  return { ...entry === void 0 ? {} : { sticky: entry }, ...read.problem === void 0 ? {} : { problem: read.problem } };
37388
37585
  }
37389
- function recordStickyPick(fs29, picksFile, directory, identity, nowMs) {
37390
- const current = readPicksFile(fs29, picksFile).file.picks;
37586
+ function recordStickyPick(fs30, picksFile, directory, identity, nowMs) {
37587
+ const current = readPicksFile(fs30, picksFile).file.picks;
37391
37588
  const kept = Object.entries(current).filter(([, entry]) => nowMs - Date.parse(entry.at) <= USAGE_RETENTION_MS);
37392
37589
  const next = { schemaVersion: SCHEMA_VERSION, picks: { ...Object.fromEntries(kept), [directory]: { identity, at: new Date(nowMs).toISOString() } } };
37393
- fs29.mkdirPrivate(import_node_path28.default.dirname(picksFile));
37394
- fs29.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
37590
+ fs30.mkdirPrivate(import_node_path28.default.dirname(picksFile));
37591
+ fs30.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
37395
37592
  `);
37396
37593
  }
37397
37594
  var import_node_path28, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
@@ -38258,12 +38455,12 @@ function decideSignIn(facts) {
38258
38455
  function credentialsFilePath(farmRoot) {
38259
38456
  return import_node_path31.default.join(farmRoot, CREDENTIALS_FILE);
38260
38457
  }
38261
- function identitySignIn(fs29, probe, identity) {
38458
+ function identitySignIn(fs30, probe, identity) {
38262
38459
  const probing = !identity.hasCredentialBlock;
38263
38460
  return decideSignIn({
38264
38461
  hasCredentialBlock: identity.hasCredentialBlock,
38265
38462
  keychainItem: probing && probe.platform === "darwin" && probe.run !== void 0 ? keychainHasItem(probe.run, identity.farmRoot) : void 0,
38266
- credentialsFile: probing && fs29.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
38463
+ credentialsFile: probing && fs30.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
38267
38464
  platform: probe.platform
38268
38465
  });
38269
38466
  }
@@ -51721,17 +51918,17 @@ var require_mock_call_history = __commonJS({
51721
51918
  lastCall() {
51722
51919
  return this.logs.at(-1);
51723
51920
  }
51724
- nthCall(number4) {
51725
- if (typeof number4 !== "number") {
51921
+ nthCall(number5) {
51922
+ if (typeof number5 !== "number") {
51726
51923
  throw new InvalidArgumentError2("nthCall must be called with a number");
51727
51924
  }
51728
- if (!Number.isInteger(number4)) {
51925
+ if (!Number.isInteger(number5)) {
51729
51926
  throw new InvalidArgumentError2("nthCall must be called with an integer");
51730
51927
  }
51731
- if (Math.sign(number4) !== 1) {
51928
+ if (Math.sign(number5) !== 1) {
51732
51929
  throw new InvalidArgumentError2("nthCall must be called with a positive value. use firstCall or lastCall instead");
51733
51930
  }
51734
- return this.logs.at(number4 - 1);
51931
+ return this.logs.at(number5 - 1);
51735
51932
  }
51736
51933
  filterCalls(criteria, options) {
51737
51934
  if (this.logs.length === 0) {
@@ -64578,14 +64775,14 @@ var init_selfIdentity = __esm({
64578
64775
 
64579
64776
  // src/frontdoor/trust.ts
64580
64777
  function resolveTrustBundle(params) {
64581
- const { caCertFile, bundlesDir, variable, inherited, fs: fs29 } = params;
64778
+ const { caCertFile, bundlesDir, variable, inherited, fs: fs30 } = params;
64582
64779
  if (inherited === void 0 || inherited === "" || import_node_path38.default.resolve(inherited) === import_node_path38.default.resolve(caCertFile)) {
64583
64780
  return { path: caCertFile };
64584
64781
  }
64585
- const caPem = fs29.readFileUtf8(caCertFile);
64782
+ const caPem = fs30.readFileUtf8(caCertFile);
64586
64783
  let inheritedPem;
64587
64784
  try {
64588
- inheritedPem = fs29.readFileUtf8(inherited);
64785
+ inheritedPem = fs30.readFileUtf8(inherited);
64589
64786
  } catch (error63) {
64590
64787
  return {
64591
64788
  path: caCertFile,
@@ -64598,9 +64795,9 @@ function resolveTrustBundle(params) {
64598
64795
  const combined = `${inheritedPem.trimEnd()}
64599
64796
  ${caPem}`;
64600
64797
  const bundle = import_node_path38.default.join(bundlesDir, `${(0, import_node_crypto15.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
64601
- if (!fs29.exists(bundle)) {
64602
- fs29.mkdirp(bundlesDir);
64603
- fs29.writeFileAtomic(bundle, combined);
64798
+ if (!fs30.exists(bundle)) {
64799
+ fs30.mkdirp(bundlesDir);
64800
+ fs30.writeFileAtomic(bundle, combined);
64604
64801
  }
64605
64802
  return { path: bundle };
64606
64803
  }
@@ -64777,20 +64974,20 @@ function lockHolder(contents) {
64777
64974
  const pid = Number((contents ?? "").trim());
64778
64975
  return Number.isInteger(pid) && pid > 0 ? pid : void 0;
64779
64976
  }
64780
- function acquireUpdateLock(fs29, isProcessAlive, pid, lockPath) {
64781
- const take = () => fs29.writeFileExclusive(lockPath, `${String(pid)}
64977
+ function acquireUpdateLock(fs30, isProcessAlive, pid, lockPath) {
64978
+ const take = () => fs30.writeFileExclusive(lockPath, `${String(pid)}
64782
64979
  `);
64783
64980
  const release = () => {
64784
- fs29.unlink(lockPath);
64981
+ fs30.unlink(lockPath);
64785
64982
  };
64786
64983
  if (take()) {
64787
64984
  return release;
64788
64985
  }
64789
- const holder = lockHolder(fs29.readFileUtf8(lockPath));
64986
+ const holder = lockHolder(fs30.readFileUtf8(lockPath));
64790
64987
  if (holder !== void 0 && holder !== pid && isProcessAlive(holder)) {
64791
64988
  throw new UpdateConflictError(`another agent-shim update (pid ${String(holder)}) is already running`);
64792
64989
  }
64793
- fs29.unlink(lockPath);
64990
+ fs30.unlink(lockPath);
64794
64991
  if (!take()) {
64795
64992
  throw new UpdateConflictError("another agent-shim update took the lock while it was being replaced");
64796
64993
  }
@@ -64959,7 +65156,7 @@ function isAnthropicUsageStale(member, nowMs) {
64959
65156
  function poolIdentityNames(pools, poolName) {
64960
65157
  const seenPools = /* @__PURE__ */ new Set();
64961
65158
  const identities = /* @__PURE__ */ new Set();
64962
- const walk2 = (name) => {
65159
+ const walk3 = (name) => {
64963
65160
  const pool = pools[name];
64964
65161
  if (pool === void 0 || seenPools.has(name)) {
64965
65162
  return;
@@ -64971,11 +65168,11 @@ function poolIdentityNames(pools, poolName) {
64971
65168
  if (nested === void 0) {
64972
65169
  identities.add(member);
64973
65170
  } else {
64974
- walk2(nested);
65171
+ walk3(nested);
64975
65172
  }
64976
65173
  }
64977
65174
  };
64978
- walk2(poolName);
65175
+ walk3(poolName);
64979
65176
  return [...identities];
64980
65177
  }
64981
65178
  function describeError(error63) {
@@ -65555,8 +65752,8 @@ function countOf(usage, key) {
65555
65752
  const value2 = key in usage ? Reflect.get(usage, key) : void 0;
65556
65753
  return typeof value2 === "number" && Number.isFinite(value2) && value2 >= 0 ? value2 : 0;
65557
65754
  }
65558
- function contextTokensOfTranscript(text2) {
65559
- const lines = text2.split("\n");
65755
+ function contextTokensOfTranscript(text3) {
65756
+ const lines = text3.split("\n");
65560
65757
  for (let index = lines.length - 1; index >= 0; index -= 1) {
65561
65758
  const line = lines[index];
65562
65759
  if (line === void 0 || line === "") {
@@ -65580,15 +65777,15 @@ function contextTokensOfTranscript(text2) {
65580
65777
  }
65581
65778
  return void 0;
65582
65779
  }
65583
- function newestTranscript(fs29, projectDir) {
65780
+ function newestTranscript(fs30, projectDir) {
65584
65781
  let newest;
65585
65782
  let newestMs = -Infinity;
65586
- for (const name of fs29.readdir(projectDir)) {
65783
+ for (const name of fs30.readdir(projectDir)) {
65587
65784
  if (!name.endsWith(".jsonl")) {
65588
65785
  continue;
65589
65786
  }
65590
65787
  const candidate = import_node_path43.default.join(projectDir, name);
65591
- const stat = fs29.lstat(candidate);
65788
+ const stat = fs30.lstat(candidate);
65592
65789
  if (stat?.kind === "file" && stat.mtimeMs > newestMs) {
65593
65790
  newestMs = stat.mtimeMs;
65594
65791
  newest = candidate;
@@ -65596,19 +65793,19 @@ function newestTranscript(fs29, projectDir) {
65596
65793
  }
65597
65794
  return newest;
65598
65795
  }
65599
- function latestConversationId(fs29, params) {
65600
- const file2 = newestTranscript(fs29, import_node_path43.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd)));
65796
+ function latestConversationId(fs30, params) {
65797
+ const file2 = newestTranscript(fs30, import_node_path43.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd)));
65601
65798
  return file2 === void 0 ? void 0 : import_node_path43.default.basename(file2, ".jsonl");
65602
65799
  }
65603
- function resumedContextTokens(fs29, params) {
65800
+ function resumedContextTokens(fs30, params) {
65604
65801
  const target = resumeTargetOf(params.passthrough);
65605
65802
  if (target === void 0) {
65606
65803
  return void 0;
65607
65804
  }
65608
65805
  const projectDir = import_node_path43.default.join(params.claudeHome, "projects", projectDirNameOf(params.cwd));
65609
- const file2 = target.kind === "id" ? import_node_path43.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs29, projectDir);
65610
- const text2 = file2 === void 0 ? void 0 : fs29.readFileUtf8(file2);
65611
- return text2 === void 0 ? void 0 : contextTokensOfTranscript(text2);
65806
+ const file2 = target.kind === "id" ? import_node_path43.default.join(projectDir, `${target.id}.jsonl`) : newestTranscript(fs30, projectDir);
65807
+ const text3 = file2 === void 0 ? void 0 : fs30.readFileUtf8(file2);
65808
+ return text3 === void 0 ? void 0 : contextTokensOfTranscript(text3);
65612
65809
  }
65613
65810
  var import_node_path43;
65614
65811
  var init_resumeContext = __esm({
@@ -65871,8 +66068,8 @@ function farmRow(links, builtDirectories, adopted) {
65871
66068
  const parts = [counted(links, "link", "links"), counted(builtDirectories, "built directory", "built directories"), ...adopted === 0 ? [] : [`${String(adopted)} adopted`]];
65872
66069
  return { label: "farm", value: "resynced", detail: parts.join(", ") };
65873
66070
  }
65874
- function noteRow(text2) {
65875
- return { label: "note", value: text2 };
66071
+ function noteRow(text3) {
66072
+ return { label: "note", value: text3 };
65876
66073
  }
65877
66074
  var init_launchReport = __esm({
65878
66075
  "src/launcher/launchReport.ts"() {
@@ -66649,9 +66846,9 @@ function flattenToolResult(content) {
66649
66846
  }
66650
66847
  return content.map((block2) => isTextBlock(block2) ? block2.text : NON_TEXT_TOOL_RESULT).join("\n");
66651
66848
  }
66652
- function systemReminder(text2) {
66849
+ function systemReminder(text3) {
66653
66850
  return `<system-reminder>
66654
- ${text2}
66851
+ ${text3}
66655
66852
  </system-reminder>`;
66656
66853
  }
66657
66854
  function turnBlocks(message) {
@@ -66888,9 +67085,9 @@ function flattenToolResult2(content) {
66888
67085
  }
66889
67086
  return content.map((block2) => isTextBlock(block2) ? block2.text : NON_TEXT_TOOL_RESULT2).join("\n");
66890
67087
  }
66891
- function systemReminder2(text2) {
67088
+ function systemReminder2(text3) {
66892
67089
  return `<system-reminder>
66893
- ${text2}
67090
+ ${text3}
66894
67091
  </system-reminder>`;
66895
67092
  }
66896
67093
  function turnBlocks2(message) {
@@ -67015,12 +67212,12 @@ var init_translate2 = __esm({
67015
67212
  function catalogueCachePath(paths, name) {
67016
67213
  return import_node_path44.default.join(paths.catalogueDir, `${name}.json`);
67017
67214
  }
67018
- function parseCatalogueCache(text2) {
67019
- if (text2 === void 0) {
67215
+ function parseCatalogueCache(text3) {
67216
+ if (text3 === void 0) {
67020
67217
  return void 0;
67021
67218
  }
67022
67219
  try {
67023
- const parsed = CatalogueCacheSchema.safeParse(JSON.parse(text2));
67220
+ const parsed = CatalogueCacheSchema.safeParse(JSON.parse(text3));
67024
67221
  return parsed.success ? parsed.data : void 0;
67025
67222
  } catch {
67026
67223
  return void 0;
@@ -67168,14 +67365,14 @@ function memberKindOf(ref, models) {
67168
67365
  function expandMembers(name, models) {
67169
67366
  const virtual = models?.virtual ?? {};
67170
67367
  const expanded = [];
67171
- const walk2 = (current, chain) => {
67368
+ const walk3 = (current, chain) => {
67172
67369
  const nested = virtual[current];
67173
67370
  if (nested !== void 0) {
67174
67371
  if (chain.includes(current)) {
67175
67372
  throw new Error(`virtual model cycle: ${[...chain, current].join(" -> ")}`);
67176
67373
  }
67177
67374
  for (const member of nested.members) {
67178
- walk2(member, [...chain, current]);
67375
+ walk3(member, [...chain, current]);
67179
67376
  }
67180
67377
  return;
67181
67378
  }
@@ -67188,7 +67385,7 @@ function expandMembers(name, models) {
67188
67385
  throw new VirtualModelNotFoundError(name);
67189
67386
  }
67190
67387
  for (const member of top.members) {
67191
- walk2(member, [name]);
67388
+ walk3(member, [name]);
67192
67389
  }
67193
67390
  return expanded;
67194
67391
  }
@@ -67637,7 +67834,7 @@ function resolveIdentityCredential(identity, credential, env, port) {
67637
67834
  return resolution.ok ? resolution : { ok: false, status: CREDENTIAL_UNAVAILABLE_EXIT, message: resolution.message };
67638
67835
  }
67639
67836
  function pickFromPool(decided, params, parsedArgv, readOnly) {
67640
- const { paths, fs: fs29, proc, log } = params;
67837
+ const { paths, fs: fs30, proc, log } = params;
67641
67838
  if (decided.pool === void 0) {
67642
67839
  return { identityDecision: decided };
67643
67840
  }
@@ -67656,7 +67853,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
67656
67853
  selectedVia: decided.source,
67657
67854
  pools: params.pools,
67658
67855
  paths,
67659
- fs: fs29,
67856
+ fs: fs30,
67660
67857
  usageFs: farmRuntime.fs,
67661
67858
  cwd: farmRuntime.cwd,
67662
67859
  now: farmRuntime.now,
@@ -67679,7 +67876,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
67679
67876
  };
67680
67877
  }
67681
67878
  function decideLaunch(params, readOnly) {
67682
- const { paths, fs: fs29, proc, log } = params;
67879
+ const { paths, fs: fs30, proc, log } = params;
67683
67880
  const { env, argv } = proc;
67684
67881
  const parsedArgv = parseLauncherArgv(argv);
67685
67882
  const cliOverride = buildCliOverride({
@@ -67694,7 +67891,7 @@ function decideLaunch(params, readOnly) {
67694
67891
  argv0Identity: parsedArgv.identity,
67695
67892
  directoryPinnedIdentity: params.directoryPinnedIdentity,
67696
67893
  readActiveIdentityFile: () => {
67697
- const raw = fs29.readFileUtf8(paths.activeIdentityFile);
67894
+ const raw = fs30.readFileUtf8(paths.activeIdentityFile);
67698
67895
  if (raw === void 0) {
67699
67896
  return void 0;
67700
67897
  }
@@ -67729,7 +67926,7 @@ function decideLaunch(params, readOnly) {
67729
67926
  }
67730
67927
  let loadedIdentity;
67731
67928
  if (identityDecision.name !== void 0) {
67732
- loadedIdentity = loadIdentity(paths.identitiesDir, identityDecision.name, fs29);
67929
+ loadedIdentity = loadIdentity(paths.identitiesDir, identityDecision.name, fs30);
67733
67930
  if (loadedIdentity === void 0) {
67734
67931
  log.error(
67735
67932
  `agent-shim: no identity named "${identityDecision.name}" (selected via ${identityDecision.source}). Run \`agent-shim identity add ${identityDecision.name}\` first.`
@@ -67744,7 +67941,7 @@ function decideLaunch(params, readOnly) {
67744
67941
  identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
67745
67942
  globalDefaultConfigProfile: params.globalDefaultConfigProfile
67746
67943
  });
67747
- if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs29.readConfigFile(import_node_path45.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
67944
+ if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs30.readConfigFile(import_node_path45.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
67748
67945
  log.error(
67749
67946
  `agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
67750
67947
  );
@@ -67753,7 +67950,7 @@ function decideLaunch(params, readOnly) {
67753
67950
  const farmContext = farm !== void 0 && farmIdentity !== void 0 ? { farm, identity: farmIdentity, cascade: farm.loadCascade(configProfileDecision.name, cliOverride) } : void 0;
67754
67951
  const providerParams = {
67755
67952
  paths,
67756
- port: fs29,
67953
+ port: fs30,
67757
67954
  ...parsedArgv.provider === void 0 || parsedArgv.provider === false ? {} : { cliProvider: parsedArgv.provider },
67758
67955
  ...farmContext === void 0 ? {} : { cascade: farmContext.cascade }
67759
67956
  };
@@ -67852,9 +68049,9 @@ function decideLaunch(params, readOnly) {
67852
68049
  const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
67853
68050
  const globalModels = loadConfigFile(paths.globalConfigFile, GlobalConfigSchema, params.fs.readConfigFile)?.config.models;
67854
68051
  const models = launchCascade !== void 0 && params.farm !== void 0 ? cascadeModels : globalModels;
67855
- const listedProviders = listProviderNames(fs29.readdir, paths.providersDir).flatMap((name) => {
68052
+ const listedProviders = listProviderNames(fs30.readdir, paths.providersDir).flatMap((name) => {
67856
68053
  try {
67857
- const definition = loadProvider(paths.providersDir, name, fs29);
68054
+ const definition = loadProvider(paths.providersDir, name, fs30);
67858
68055
  return definition === void 0 ? [] : [[name, definition, parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, name)))?.models ?? []]];
67859
68056
  } catch {
67860
68057
  return [];
@@ -106770,7 +106967,7 @@ var require_core2 = __commonJS({
106770
106967
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
106771
106968
  if (!errors || errors.length === 0)
106772
106969
  return "No errors";
106773
- return errors.map((e14) => `${dataVar}${e14.instancePath} ${e14.message}`).reduce((text2, msg) => text2 + separator + msg);
106970
+ return errors.map((e14) => `${dataVar}${e14.instancePath} ${e14.message}`).reduce((text3, msg) => text3 + separator + msg);
106774
106971
  }
106775
106972
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
106776
106973
  const rules = this.RULES.all;
@@ -109331,12 +109528,12 @@ var require_dist2 = __commonJS({
109331
109528
  throw new Error(`Unknown format "${name}"`);
109332
109529
  return f;
109333
109530
  };
109334
- function addFormats(ajv, list, fs29, exportName) {
109531
+ function addFormats(ajv, list, fs30, exportName) {
109335
109532
  var _a4;
109336
109533
  var _b2;
109337
109534
  (_a4 = (_b2 = ajv.opts.code).formats) !== null && _a4 !== void 0 ? _a4 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
109338
109535
  for (const f of list)
109339
- ajv.addFormat(f, fs29[f]);
109536
+ ajv.addFormat(f, fs30[f]);
109340
109537
  }
109341
109538
  module2.exports = exports2 = formatsPlugin;
109342
109539
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -112477,9 +112674,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
112477
112674
  helpWidth: context.helpWidth,
112478
112675
  outputHasColors: context.hasColors
112479
112676
  });
112480
- const text2 = helper.formatHelp(this, helper);
112481
- if (context.hasColors) return text2;
112482
- return this._outputConfiguration.stripColor(text2);
112677
+ const text3 = helper.formatHelp(this, helper);
112678
+ if (context.hasColors) return text3;
112679
+ return this._outputConfiguration.stripColor(text3);
112483
112680
  }
112484
112681
  /**
112485
112682
  * @typedef HelpContext
@@ -112639,7 +112836,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
112639
112836
  * @param {(string | Function)} text - string to add, or a function returning a string
112640
112837
  * @return {Command} `this` command for chaining
112641
112838
  */
112642
- addHelpText(position, text2) {
112839
+ addHelpText(position, text3) {
112643
112840
  const allowedValues = ["beforeAll", "before", "after", "afterAll"];
112644
112841
  if (!allowedValues.includes(position)) {
112645
112842
  throw new Error(`Unexpected value for position to addHelpText.
@@ -112648,10 +112845,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
112648
112845
  const helpEvent = `${position}Help`;
112649
112846
  this.on(helpEvent, (context) => {
112650
112847
  let helpStr;
112651
- if (typeof text2 === "function") {
112652
- helpStr = text2({ error: context.error, command: context.command });
112848
+ if (typeof text3 === "function") {
112849
+ helpStr = text3({ error: context.error, command: context.command });
112653
112850
  } else {
112654
- helpStr = text2;
112851
+ helpStr = text3;
112655
112852
  }
112656
112853
  if (helpStr) {
112657
112854
  context.write(`${helpStr}
@@ -113936,7 +114133,7 @@ function writePools(paths, pools) {
113936
114133
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
113937
114134
  }
113938
114135
  function poolCycleOf(pools, name) {
113939
- const walk2 = (current, path66) => {
114136
+ const walk3 = (current, path66) => {
113940
114137
  for (const entry of pools[current]?.identities ?? []) {
113941
114138
  const nested = poolNameOf(poolMemberIdentity(entry));
113942
114139
  if (nested === void 0) {
@@ -113948,14 +114145,14 @@ function poolCycleOf(pools, name) {
113948
114145
  if (path66.includes(nested)) {
113949
114146
  continue;
113950
114147
  }
113951
- const found = walk2(nested, [...path66, nested]);
114148
+ const found = walk3(nested, [...path66, nested]);
113952
114149
  if (found !== void 0) {
113953
114150
  return found;
113954
114151
  }
113955
114152
  }
113956
114153
  return void 0;
113957
114154
  };
113958
- return walk2(name, [name]);
114155
+ return walk3(name, [name]);
113959
114156
  }
113960
114157
  function validateMembers(pools, name, members2) {
113961
114158
  for (const entry of members2) {
@@ -115117,7 +115314,7 @@ async function resolveFarmConflicts(params) {
115117
115314
  // src/configProfiles.ts
115118
115315
  init_commandDeps();
115119
115316
  init_cliError();
115120
- init_statusline();
115317
+ init_change();
115121
115318
  init_proxyBypass2();
115122
115319
  init_configProfilesStore();
115123
115320
  async function ensureProfileExists(deps, name) {
@@ -115144,28 +115341,12 @@ async function ensureProfileExists(deps, name) {
115144
115341
  function toProfileView(name, profile, globalDefault) {
115145
115342
  return { name, globalDefault: name === globalDefault, ...profile, $schema: void 0 };
115146
115343
  }
115147
- function segmentList(values) {
115148
- return values.length === 1 && values[0] === "none" ? [] : values;
115149
- }
115150
115344
  function statuslineChangeOf(options) {
115151
- const raw = {
115152
- header: options.statuslineHeader === void 0 || options.statuslineHeader === false ? options.statuslineHeader : segmentList(options.statuslineHeader),
115153
- bars: options.statuslineBars === void 0 || options.statuslineBars === false ? options.statuslineBars : segmentList(options.statuslineBars),
115154
- warnAt: options.statuslineWarnAt === void 0 || options.statuslineWarnAt === false ? options.statuslineWarnAt : Number(options.statuslineWarnAt),
115155
- criticalAt: options.statuslineCriticalAt === void 0 || options.statuslineCriticalAt === false ? options.statuslineCriticalAt : Number(options.statuslineCriticalAt),
115156
- fiveHourLabel: options.statuslineFiveHourLabel,
115157
- sevenDayLabel: options.statuslineSevenDayLabel,
115158
- barWidth: options.statuslineBarWidth === void 0 || options.statuslineBarWidth === false ? options.statuslineBarWidth : Number(options.statuslineBarWidth)
115159
- };
115160
- const given = Object.entries(raw).filter(([, value2]) => value2 !== void 0);
115161
- if (given.length === 0) {
115345
+ if (options.statusline === void 0 && options.unsetStatusline === void 0) {
115162
115346
  return void 0;
115163
115347
  }
115164
- const result = StatuslineSchema.safeParse(Object.fromEntries(given.filter(([, value2]) => value2 !== false)));
115165
- if (!result.success) {
115166
- throw new UsageError(`--statusline-*: ${result.error.issues.map((issue2) => `${issue2.path.join(".")}: ${issue2.message}`).join("; ")}.`);
115167
- }
115168
- return Object.fromEntries(given);
115348
+ const assignments = (options.statusline ?? []).map(parseStatuslineAssignment);
115349
+ return { set: Object.fromEntries(assignments.map(({ path: path66, value: value2 }) => [path66, value2])), unset: options.unsetStatusline ?? [] };
115169
115350
  }
115170
115351
  function registerProfileCommand(program2, deps) {
115171
115352
  const { paths } = deps;
@@ -115202,7 +115383,7 @@ function registerProfileCommand(program2, deps) {
115202
115383
  withExamples(
115203
115384
  profile.command("set <name>").description(
115204
115385
  "Update a configuration profile's categories, entries, extends list, description or launch settings. With no options on a terminal, walks through its categories."
115205
- ).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--launch-claude-version <version>", "Launches under this profile run exactly this installed Claude Code version (such as 2.1.220); a version that is not installed fails the launch.").option("--no-launch-claude-version", "Clear this profile's Claude Code version pin.").option("--launch-delay <duration>", "Launches under this profile wait this long (such as 5s) after the launcher's own output before starting claude, so the output can be read.", parseDurationLiteral).option("--no-launch-delay", "Clear this profile's launch delay.").option("--launch-pause", "Launches under this profile wait for a key press after the launcher's own output before starting claude.").option("--no-launch-pause", "Launches under this profile start claude without waiting for a key press.").option("--launch-explain", "Launches under this profile that pick from a pool list every member the pick ranked and why, in the launcher's report.").option("--no-launch-explain", "Launches under this profile name only the member a pool pick chose.").option("--launch-proxy-bypass <host>", "Launches under this profile keep this host off the front door by adding it to NO_PROXY, so its traffic goes direct (repeatable; replaces the profile's list).", collectRepeated).option("--no-launch-proxy-bypass", "Clear this profile's list of hosts kept off the front door.").option("--statusline-header <segment>", `The statusline header segments to draw, in drawing order (repeatable; one of ${STATUSLINE_HEADER_SEGMENTS.join(", ")}, or "none" to hide the header).`, collectRepeated).option("--no-statusline-header", "Clear this profile's header segment list, restoring the default.").option("--statusline-bars <group>", `The statusline bar groups to draw, in drawing order (repeatable; one of ${STATUSLINE_BAR_GROUPS.join(", ")}, or "none" to hide the bars).`, collectRepeated).option("--no-statusline-bars", "Clear this profile's bar group list, restoring the default.").option("--statusline-warn-at <percent>", "The whole percentage of use at which a statusline bar turns yellow.").option("--no-statusline-warn-at", "Clear this profile's warning threshold.").option("--statusline-critical-at <percent>", "The whole percentage of use at which a statusline bar turns red.").option("--no-statusline-critical-at", "Clear this profile's critical threshold.").option("--statusline-five-hour-label <text>", "The statusline's name for the five-hour window.").option("--no-statusline-five-hour-label", "Clear this profile's five-hour window label.").option("--statusline-seven-day-label <text>", "The statusline's name for the weekly window.").option("--no-statusline-seven-day-label", "Clear this profile's weekly window label.").option("--statusline-bar-width <cells>", "The width of a statusline bar in cells, before the line's spare width is shared out among the bars.").option("--no-statusline-bar-width", "Clear this profile's bar width.").option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
115386
+ ).option("--category <category=bool>", "Share (true) or hide (false) a whole category (repeatable).", collectBoolPair).option("--entry <path=bool>", "Share (true) or hide (false) one <category>/<path> entry (repeatable).", collectBoolPair).option("--extends <profile>", "Replace the extends list with these profiles (repeatable, in order).", collectRepeated).option("--no-extends", "Clear the extends list.").option("--description <text>", "Replace the description.").option("--no-description", "Clear the description.").option("--launch-skip-permissions", "Launches under this profile skip permission prompts.").option("--no-launch-skip-permissions", "Launches under this profile keep permission prompts.").option("--launch-remote-control", "Launches under this profile enable Remote Control.").option("--no-launch-remote-control", "Launches under this profile leave Remote Control off.").option("--launch-headroom", "Launches under this profile route through headroom.").option("--no-launch-headroom", "Launches under this profile route direct.").option("--launch-track-usage", "Launches under this profile route through the front door so their requests and quota are recorded, with no headroom needed.").option("--no-launch-track-usage", "Launches under this profile are not recorded unless a provider or headroom routes them anyway.").option("--launch-provider <provider>", "Launches under this profile route through this provider.").option("--no-launch-provider", "Clear this profile's provider selection.").option("--launch-claude-version <version>", "Launches under this profile run exactly this installed Claude Code version (such as 2.1.220); a version that is not installed fails the launch.").option("--no-launch-claude-version", "Clear this profile's Claude Code version pin.").option("--launch-delay <duration>", "Launches under this profile wait this long (such as 5s) after the launcher's own output before starting claude, so the output can be read.", parseDurationLiteral).option("--no-launch-delay", "Clear this profile's launch delay.").option("--launch-pause", "Launches under this profile wait for a key press after the launcher's own output before starting claude.").option("--no-launch-pause", "Launches under this profile start claude without waiting for a key press.").option("--launch-explain", "Launches under this profile that pick from a pool list every member the pick ranked and why, in the launcher's report.").option("--no-launch-explain", "Launches under this profile name only the member a pool pick chose.").option("--launch-proxy-bypass <host>", "Launches under this profile keep this host off the front door by adding it to NO_PROXY, so its traffic goes direct (repeatable; replaces the profile's list).", collectRepeated).option("--no-launch-proxy-bypass", "Clear this profile's list of hosts kept off the front door.").option("--statusline <setting=value>", "Set one statusline setting for launches under this profile (repeatable; `agent-shim statusline keys` lists them; a list is comma-separated, and an empty value is the empty list).", collectRepeated).option("--unset-statusline <setting>", "Remove one statusline setting from this profile so the shallower layers or the default apply again (repeatable).", collectRepeated).option("--json", "Print the result as JSON.").action(async (name, allOptions) => {
115206
115387
  const { json: json2, ...options } = allOptions;
115207
115388
  requireProfileExists(paths, name);
115208
115389
  if (Object.entries(allOptions).every(([key, value2]) => key === "json" || value2 === void 0)) {
@@ -117099,17 +117280,17 @@ function parseEntry2(project, entry) {
117099
117280
  const base = match?.[1];
117100
117281
  return base === void 0 ? { project, sessionId: entry, superseded: false, entry } : { project, sessionId: base, superseded: true, entry };
117101
117282
  }
117102
- function listSessions2(fs29, configDir) {
117283
+ function listSessions2(fs30, configDir) {
117103
117284
  const found = [];
117104
- for (const project of fs29.readdir(import_node_path35.default.join(configDir, PROJECTS_DIR))) {
117285
+ for (const project of fs30.readdir(import_node_path35.default.join(configDir, PROJECTS_DIR))) {
117105
117286
  const projectDir = import_node_path35.default.join(configDir, PROJECTS_DIR, project);
117106
117287
  const entries = /* @__PURE__ */ new Set();
117107
- for (const name of fs29.readdir(projectDir)) {
117288
+ for (const name of fs30.readdir(projectDir)) {
117108
117289
  if (name.endsWith(TRANSCRIPT_SUFFIX)) {
117109
117290
  entries.add(name.slice(0, -TRANSCRIPT_SUFFIX.length));
117110
117291
  continue;
117111
117292
  }
117112
- const children = fs29.readdir(import_node_path35.default.join(projectDir, name));
117293
+ const children = fs30.readdir(import_node_path35.default.join(projectDir, name));
117113
117294
  if (children.includes(SUBAGENTS_DIR) || children.includes(WORKFLOWS_DIR)) {
117114
117295
  entries.add(name);
117115
117296
  }
@@ -117120,9 +117301,9 @@ function listSessions2(fs29, configDir) {
117120
117301
  }
117121
117302
  return found.sort((left, right) => left.project.localeCompare(right.project) || left.entry.localeCompare(right.entry));
117122
117303
  }
117123
- function locateAgents(fs29, configDir, relativeDir, workflowRunId, report) {
117304
+ function locateAgents(fs30, configDir, relativeDir, workflowRunId, report) {
117124
117305
  const located = [];
117125
- for (const name of listDirOrReport(fs29, configDir, relativeDir, report)) {
117306
+ for (const name of listDirOrReport(fs30, configDir, relativeDir, report)) {
117126
117307
  if (!name.startsWith(AGENT_FILE_PREFIX) || !name.endsWith(META_SUFFIX)) {
117127
117308
  continue;
117128
117309
  }
@@ -117171,25 +117352,25 @@ function toNode(read, children) {
117171
117352
  function describeFailure(error63) {
117172
117353
  return error63 instanceof Error ? error63.message : String(error63);
117173
117354
  }
117174
- function readFileOrReport(fs29, configDir, relative, report) {
117355
+ function readFileOrReport(fs30, configDir, relative, report) {
117175
117356
  try {
117176
- return fs29.readFileUtf8(import_node_path35.default.join(configDir, relative));
117357
+ return fs30.readFileUtf8(import_node_path35.default.join(configDir, relative));
117177
117358
  } catch (error63) {
117178
117359
  report({ path: relative, reason: `could not be read: ${describeFailure(error63)}` });
117179
117360
  return void 0;
117180
117361
  }
117181
117362
  }
117182
- function listDirOrReport(fs29, configDir, relative, report) {
117363
+ function listDirOrReport(fs30, configDir, relative, report) {
117183
117364
  try {
117184
- return fs29.readdir(import_node_path35.default.join(configDir, relative));
117365
+ return fs30.readdir(import_node_path35.default.join(configDir, relative));
117185
117366
  } catch (error63) {
117186
117367
  report({ path: relative, reason: `could not be listed: ${describeFailure(error63)}` });
117187
117368
  return [];
117188
117369
  }
117189
117370
  }
117190
- function parseJson3(text2) {
117371
+ function parseJson3(text3) {
117191
117372
  try {
117192
- const value2 = JSON.parse(text2);
117373
+ const value2 = JSON.parse(text3);
117193
117374
  return value2;
117194
117375
  } catch {
117195
117376
  return void 0;
@@ -117204,22 +117385,22 @@ var WorkflowRunFileSchema = external_exports.object({
117204
117385
  phases: external_exports.array(external_exports.object({ title: external_exports.string() })).default([]),
117205
117386
  summary: external_exports.string().optional()
117206
117387
  });
117207
- function summariseSession(fs29, configDir, ref) {
117388
+ function summariseSession(fs30, configDir, ref) {
117208
117389
  const sessionRelative = import_node_path35.default.join(PROJECTS_DIR, ref.project, ref.entry);
117209
117390
  const subagentsRelative = import_node_path35.default.join(sessionRelative, SUBAGENTS_DIR);
117210
117391
  const workflowsUnderSubagents = import_node_path35.default.join(subagentsRelative, WORKFLOWS_DIR);
117211
117392
  const isMeta = (name) => name.startsWith(AGENT_FILE_PREFIX) && name.endsWith(META_SUFFIX);
117212
- let agentCount = fs29.readdir(import_node_path35.default.join(configDir, subagentsRelative)).filter(isMeta).length;
117213
- for (const runDir of fs29.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents))) {
117393
+ let agentCount = fs30.readdir(import_node_path35.default.join(configDir, subagentsRelative)).filter(isMeta).length;
117394
+ for (const runDir of fs30.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents))) {
117214
117395
  if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
117215
- agentCount += fs29.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
117396
+ agentCount += fs30.readdir(import_node_path35.default.join(configDir, workflowsUnderSubagents, runDir)).filter(isMeta).length;
117216
117397
  }
117217
117398
  }
117218
- const workflowRunCount = fs29.readdir(import_node_path35.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
117219
- const transcript = fs29.lstat(import_node_path35.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
117399
+ const workflowRunCount = fs30.readdir(import_node_path35.default.join(configDir, sessionRelative, WORKFLOWS_DIR)).filter((name) => name.startsWith(WORKFLOW_RUN_PREFIX) && name.endsWith(JSON_SUFFIX)).length;
117400
+ const transcript = fs30.lstat(import_node_path35.default.join(configDir, PROJECTS_DIR, ref.project, `${ref.entry}${TRANSCRIPT_SUFFIX}`));
117220
117401
  return { ...ref, agentCount, workflowRunCount, ...transcript === void 0 ? {} : { updatedAt: new Date(transcript.mtimeMs).toISOString() } };
117221
117402
  }
117222
- function readSessionAgentTree(fs29, configDir, ref, options = {}) {
117403
+ function readSessionAgentTree(fs30, configDir, ref, options = {}) {
117223
117404
  const problems = [];
117224
117405
  const report = (problem) => {
117225
117406
  problems.push(problem);
@@ -117227,19 +117408,19 @@ function readSessionAgentTree(fs29, configDir, ref, options = {}) {
117227
117408
  const sessionRelative = import_node_path35.default.join(PROJECTS_DIR, ref.project, ref.entry);
117228
117409
  const subagentsRelative = import_node_path35.default.join(sessionRelative, SUBAGENTS_DIR);
117229
117410
  const workflowsUnderSubagents = import_node_path35.default.join(subagentsRelative, WORKFLOWS_DIR);
117230
- const located = locateAgents(fs29, configDir, subagentsRelative, void 0, report);
117231
- for (const runDir of listDirOrReport(fs29, configDir, workflowsUnderSubagents, report)) {
117411
+ const located = locateAgents(fs30, configDir, subagentsRelative, void 0, report);
117412
+ for (const runDir of listDirOrReport(fs30, configDir, workflowsUnderSubagents, report)) {
117232
117413
  if (runDir.startsWith(WORKFLOW_RUN_PREFIX)) {
117233
- located.push(...locateAgents(fs29, configDir, import_node_path35.default.join(workflowsUnderSubagents, runDir), runDir, report));
117414
+ located.push(...locateAgents(fs30, configDir, import_node_path35.default.join(workflowsUnderSubagents, runDir), runDir, report));
117234
117415
  }
117235
117416
  }
117236
117417
  const agents = /* @__PURE__ */ new Map();
117237
117418
  for (const candidate of located) {
117238
- const text2 = readFileOrReport(fs29, configDir, candidate.metaPath, report);
117239
- if (text2 === void 0) {
117419
+ const text3 = readFileOrReport(fs30, configDir, candidate.metaPath, report);
117420
+ if (text3 === void 0) {
117240
117421
  continue;
117241
117422
  }
117242
- const parsed = AgentMetaSchema.safeParse(parseJson3(text2));
117423
+ const parsed = AgentMetaSchema.safeParse(parseJson3(text3));
117243
117424
  if (!parsed.success) {
117244
117425
  report({ path: candidate.metaPath, reason: "meta file is not a JSON object with an agentType" });
117245
117426
  continue;
@@ -117247,7 +117428,7 @@ function readSessionAgentTree(fs29, configDir, ref, options = {}) {
117247
117428
  agents.set(candidate.id, { located: candidate, meta: parsed.data });
117248
117429
  }
117249
117430
  const teamNames = [...new Set([...agents.values()].flatMap((agent) => agent.meta.teamName === void 0 ? [] : [agent.meta.teamName]))].sort();
117250
- const parentOf4 = resolveParents(fs29, configDir, agents, report);
117431
+ const parentOf4 = resolveParents(fs30, configDir, agents, report);
117251
117432
  const childrenOf = /* @__PURE__ */ new Map();
117252
117433
  const roots = [];
117253
117434
  for (const id2 of agents.keys()) {
@@ -117270,12 +117451,12 @@ function readSessionAgentTree(fs29, configDir, ref, options = {}) {
117270
117451
  sessionId: ref.sessionId,
117271
117452
  superseded: ref.superseded,
117272
117453
  agents: roots.sort().map(build),
117273
- tasks: readTasks(fs29, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id2) => !ownTaskLists(ref.sessionId).includes(id2)), report),
117274
- workflowRuns: readWorkflowRuns(fs29, configDir, import_node_path35.default.join(sessionRelative, WORKFLOWS_DIR), report),
117454
+ tasks: readTasks(fs30, configDir, ownTaskLists(ref.sessionId), [.../* @__PURE__ */ new Set([...teamNames, ...options.taskListIds ?? []])].filter((id2) => !ownTaskLists(ref.sessionId).includes(id2)), report),
117455
+ workflowRuns: readWorkflowRuns(fs30, configDir, import_node_path35.default.join(sessionRelative, WORKFLOWS_DIR), report),
117275
117456
  problems
117276
117457
  };
117277
117458
  }
117278
- function resolveParents(fs29, configDir, agents, report) {
117459
+ function resolveParents(fs30, configDir, agents, report) {
117279
117460
  const parentOf4 = /* @__PURE__ */ new Map();
117280
117461
  const transcriptCache = /* @__PURE__ */ new Map();
117281
117462
  const transcriptOf = (agent) => {
@@ -117283,9 +117464,9 @@ function resolveParents(fs29, configDir, agents, report) {
117283
117464
  if (cached2 !== void 0) {
117284
117465
  return cached2;
117285
117466
  }
117286
- const text2 = readFileOrReport(fs29, configDir, agent.located.transcriptPath, report) ?? "";
117287
- transcriptCache.set(agent.located.id, text2);
117288
- return text2;
117467
+ const text3 = readFileOrReport(fs30, configDir, agent.located.transcriptPath, report) ?? "";
117468
+ transcriptCache.set(agent.located.id, text3);
117469
+ return text3;
117289
117470
  };
117290
117471
  const wouldCycle = (child, parent) => {
117291
117472
  for (let cursor3 = parent; cursor3 !== void 0; cursor3 = parentOf4.get(cursor3)) {
@@ -117333,37 +117514,37 @@ function resolveParents(fs29, configDir, agents, report) {
117333
117514
  function ownTaskLists(sessionId) {
117334
117515
  return [sessionId, `${SHORT_SESSION_LIST_PREFIX}${sessionId.slice(0, SHORT_SESSION_ID_LENGTH)}`];
117335
117516
  }
117336
- function readTasks(fs29, configDir, ownLists, sharedLists, report) {
117517
+ function readTasks(fs30, configDir, ownLists, sharedLists, report) {
117337
117518
  const tasks = [];
117338
117519
  [...ownLists, ...sharedLists].forEach((scope, index) => {
117339
117520
  const relativeDir = import_node_path35.default.join(TASKS_DIR, scope);
117340
- for (const name of [...listDirOrReport(fs29, configDir, relativeDir, report)].sort()) {
117521
+ for (const name of [...listDirOrReport(fs30, configDir, relativeDir, report)].sort()) {
117341
117522
  if (name.startsWith(".") || !name.endsWith(JSON_SUFFIX)) {
117342
117523
  continue;
117343
117524
  }
117344
117525
  const relative = import_node_path35.default.join(relativeDir, name);
117345
- const text2 = readFileOrReport(fs29, configDir, relative, report);
117346
- const parsed = TaskFileSchema.safeParse(text2 === void 0 ? void 0 : parseJson3(text2));
117526
+ const text3 = readFileOrReport(fs30, configDir, relative, report);
117527
+ const parsed = TaskFileSchema.safeParse(text3 === void 0 ? void 0 : parseJson3(text3));
117347
117528
  if (parsed.success) {
117348
117529
  tasks.push(index < ownLists.length ? parsed.data : { ...parsed.data, taskList: scope });
117349
- } else if (text2 !== void 0) {
117530
+ } else if (text3 !== void 0) {
117350
117531
  report({ path: relative, reason: "task file is not a task" });
117351
117532
  }
117352
117533
  }
117353
117534
  });
117354
117535
  return tasks;
117355
117536
  }
117356
- function readWorkflowRuns(fs29, configDir, relativeDir, report) {
117537
+ function readWorkflowRuns(fs30, configDir, relativeDir, report) {
117357
117538
  const runs = [];
117358
- for (const name of [...listDirOrReport(fs29, configDir, relativeDir, report)].sort()) {
117539
+ for (const name of [...listDirOrReport(fs30, configDir, relativeDir, report)].sort()) {
117359
117540
  if (!name.startsWith(WORKFLOW_RUN_PREFIX) || !name.endsWith(JSON_SUFFIX)) {
117360
117541
  continue;
117361
117542
  }
117362
117543
  const relative = import_node_path35.default.join(relativeDir, name);
117363
- const text2 = readFileOrReport(fs29, configDir, relative, report);
117364
- const parsed = WorkflowRunFileSchema.safeParse(text2 === void 0 ? void 0 : parseJson3(text2));
117544
+ const text3 = readFileOrReport(fs30, configDir, relative, report);
117545
+ const parsed = WorkflowRunFileSchema.safeParse(text3 === void 0 ? void 0 : parseJson3(text3));
117365
117546
  if (!parsed.success) {
117366
- if (text2 !== void 0) {
117547
+ if (text3 !== void 0) {
117367
117548
  report({ path: relative, reason: "workflow run file is not a run record" });
117368
117549
  }
117369
117550
  continue;
@@ -117384,11 +117565,11 @@ var SessionLookupError = class extends CliError {
117384
117565
  function identityConfigDir(identitiesDir, identity) {
117385
117566
  return import_node_path36.default.join(identitiesDir, identity);
117386
117567
  }
117387
- function historyStores(fs29, identitiesDir, identities) {
117568
+ function historyStores(fs30, identitiesDir, identities) {
117388
117569
  const byRealPath = /* @__PURE__ */ new Map();
117389
117570
  for (const identity of identities) {
117390
117571
  const configDir = identityConfigDir(identitiesDir, identity);
117391
- const real = fs29.realpath(import_node_path36.default.join(configDir, "projects"));
117572
+ const real = fs30.realpath(import_node_path36.default.join(configDir, "projects"));
117392
117573
  if (real === void 0) {
117393
117574
  continue;
117394
117575
  }
@@ -117401,15 +117582,15 @@ function historyStores(fs29, identitiesDir, identities) {
117401
117582
  }
117402
117583
  return [...byRealPath.values()];
117403
117584
  }
117404
- function collectSessionList(fs29, identitiesDir, identities, filters) {
117585
+ function collectSessionList(fs30, identitiesDir, identities, filters) {
117405
117586
  const names = filters.identity === void 0 ? identities : identities.filter((name) => name === filters.identity);
117406
117587
  if (filters.identity !== void 0 && names.length === 0) {
117407
117588
  throw new SessionLookupError(`no identity named "${filters.identity}"`);
117408
117589
  }
117409
117590
  const sessions = [];
117410
- for (const store of historyStores(fs29, identitiesDir, names)) {
117411
- for (const ref of listSessions2(fs29, store.configDir)) {
117412
- const summary = summariseSession(fs29, store.configDir, ref);
117591
+ for (const store of historyStores(fs30, identitiesDir, names)) {
117592
+ for (const ref of listSessions2(fs30, store.configDir)) {
117593
+ const summary = summariseSession(fs30, store.configDir, ref);
117413
117594
  if (filters.all === true || summary.agentCount > 0 || summary.workflowRunCount > 0) {
117414
117595
  sessions.push({ ...summary, identities: store.identities });
117415
117596
  }
@@ -117417,14 +117598,14 @@ function collectSessionList(fs29, identitiesDir, identities, filters) {
117417
117598
  }
117418
117599
  return sessions.sort((left, right) => (right.updatedAt ?? "").localeCompare(left.updatedAt ?? "") || left.sessionId.localeCompare(right.sessionId));
117419
117600
  }
117420
- function locateSession(fs29, identitiesDir, identities, query, onlyIdentity) {
117601
+ function locateSession(fs30, identitiesDir, identities, query, onlyIdentity) {
117421
117602
  const names = onlyIdentity === void 0 ? identities : identities.filter((name) => name === onlyIdentity);
117422
117603
  if (onlyIdentity !== void 0 && names.length === 0) {
117423
117604
  throw new SessionLookupError(`no identity named "${onlyIdentity}"`);
117424
117605
  }
117425
117606
  const matches = [];
117426
- for (const store of historyStores(fs29, identitiesDir, names)) {
117427
- for (const ref of listSessions2(fs29, store.configDir)) {
117607
+ for (const store of historyStores(fs30, identitiesDir, names)) {
117608
+ for (const ref of listSessions2(fs30, store.configDir)) {
117428
117609
  if (ref.sessionId.startsWith(query)) {
117429
117610
  matches.push({ identities: store.identities, configDir: store.configDir, ref });
117430
117611
  }
@@ -117441,9 +117622,9 @@ function locateSession(fs29, identitiesDir, identities, query, onlyIdentity) {
117441
117622
  }
117442
117623
  throw new SessionLookupError(`"${query}" matches ${String(candidates.length)} sessions: ${candidates.map((match) => `${match.ref.sessionId} (${match.identities.join(", ")})`).join("; ")}; give more of the id or pass --identity`);
117443
117624
  }
117444
- function showSession(fs29, identitiesDir, identities, query, onlyIdentity) {
117445
- const located = locateSession(fs29, identitiesDir, identities, query, onlyIdentity);
117446
- return { identities: located.identities, tree: readSessionAgentTree(fs29, located.configDir, located.ref) };
117625
+ function showSession(fs30, identitiesDir, identities, query, onlyIdentity) {
117626
+ const located = locateSession(fs30, identitiesDir, identities, query, onlyIdentity);
117627
+ return { identities: located.identities, tree: readSessionAgentTree(fs30, located.configDir, located.ref) };
117447
117628
  }
117448
117629
 
117449
117630
  // src/frontdoor/commands.ts
@@ -117489,13 +117670,13 @@ function stateDirOf(paths, pool) {
117489
117670
  function sessionStatePath(paths, pool, sessionId) {
117490
117671
  return import_node_path37.default.join(stateDirOf(paths, pool), `${sessionId}.json`);
117491
117672
  }
117492
- function writeSessionState(fs29, paths, pool, sessionId, state) {
117493
- fs29.mkdirPrivate(stateDirOf(paths, pool));
117494
- fs29.writeFilePrivate(sessionStatePath(paths, pool, sessionId), `${JSON.stringify(SessionStateSchema.parse(state))}
117673
+ function writeSessionState(fs30, paths, pool, sessionId, state) {
117674
+ fs30.mkdirPrivate(stateDirOf(paths, pool));
117675
+ fs30.writeFilePrivate(sessionStatePath(paths, pool, sessionId), `${JSON.stringify(SessionStateSchema.parse(state))}
117495
117676
  `);
117496
117677
  }
117497
- function readSessionState(fs29, paths, pool, sessionId) {
117498
- const raw = fs29.readFileUtf8(sessionStatePath(paths, pool, sessionId));
117678
+ function readSessionState(fs30, paths, pool, sessionId) {
117679
+ const raw = fs30.readFileUtf8(sessionStatePath(paths, pool, sessionId));
117499
117680
  if (raw === void 0) {
117500
117681
  return void 0;
117501
117682
  }
@@ -117506,20 +117687,20 @@ function readSessionState(fs29, paths, pool, sessionId) {
117506
117687
  return void 0;
117507
117688
  }
117508
117689
  }
117509
- function registerSupervised(fs29, paths, session) {
117510
- fs29.mkdirPrivate(sessionsDirOf(paths, session.pool));
117511
- fs29.writeFilePrivate(sessionFileOf(paths, session.pool, session.sessionId), `${JSON.stringify(SupervisedSessionSchema.parse(session))}
117690
+ function registerSupervised(fs30, paths, session) {
117691
+ fs30.mkdirPrivate(sessionsDirOf(paths, session.pool));
117692
+ fs30.writeFilePrivate(sessionFileOf(paths, session.pool, session.sessionId), `${JSON.stringify(SupervisedSessionSchema.parse(session))}
117512
117693
  `);
117513
117694
  }
117514
- function unregisterSupervised(fs29, paths, pool, sessionId) {
117515
- fs29.removeRecursive(sessionFileOf(paths, pool, sessionId));
117516
- fs29.removeRecursive(sessionStatePath(paths, pool, sessionId));
117695
+ function unregisterSupervised(fs30, paths, pool, sessionId) {
117696
+ fs30.removeRecursive(sessionFileOf(paths, pool, sessionId));
117697
+ fs30.removeRecursive(sessionStatePath(paths, pool, sessionId));
117517
117698
  }
117518
- function liveSupervised(fs29, paths, pool, isRunning) {
117699
+ function liveSupervised(fs30, paths, pool, isRunning) {
117519
117700
  const live = [];
117520
- for (const name of fs29.readdir(sessionsDirOf(paths, pool))) {
117701
+ for (const name of fs30.readdir(sessionsDirOf(paths, pool))) {
117521
117702
  const file2 = import_node_path37.default.join(sessionsDirOf(paths, pool), name);
117522
- const raw = fs29.readFileUtf8(file2);
117703
+ const raw = fs30.readFileUtf8(file2);
117523
117704
  if (raw === void 0) {
117524
117705
  continue;
117525
117706
  }
@@ -117527,13 +117708,13 @@ function liveSupervised(fs29, paths, pool, isRunning) {
117527
117708
  try {
117528
117709
  parsed = SupervisedSessionSchema.safeParse(JSON.parse(raw));
117529
117710
  } catch {
117530
- fs29.removeRecursive(file2);
117711
+ fs30.removeRecursive(file2);
117531
117712
  continue;
117532
117713
  }
117533
117714
  if (parsed.success && isRunning(parsed.data.pid)) {
117534
117715
  live.push(parsed.data);
117535
117716
  } else {
117536
- fs29.removeRecursive(file2);
117717
+ fs30.removeRecursive(file2);
117537
117718
  }
117538
117719
  }
117539
117720
  return live;
@@ -117562,13 +117743,13 @@ var ModelMoveRequestSchema = external_exports.strictObject({
117562
117743
  /** When the door wrote the request, so a supervisor can tell a fresh request from one left behind. */
117563
117744
  at: external_exports.iso.datetime()
117564
117745
  });
117565
- function writeModelMove(fs29, paths, request7) {
117566
- fs29.mkdirPrivate(paths.modelMovesDir);
117567
- fs29.writeFilePrivate(import_node_path37.default.join(paths.modelMovesDir, `${request7.sessionId}.json`), `${JSON.stringify(ModelMoveRequestSchema.parse(request7))}
117746
+ function writeModelMove(fs30, paths, request7) {
117747
+ fs30.mkdirPrivate(paths.modelMovesDir);
117748
+ fs30.writeFilePrivate(import_node_path37.default.join(paths.modelMovesDir, `${request7.sessionId}.json`), `${JSON.stringify(ModelMoveRequestSchema.parse(request7))}
117568
117749
  `);
117569
117750
  }
117570
- function readModelMove(fs29, paths, sessionId) {
117571
- const raw = fs29.readFileUtf8(import_node_path37.default.join(paths.modelMovesDir, `${sessionId}.json`));
117751
+ function readModelMove(fs30, paths, sessionId) {
117752
+ const raw = fs30.readFileUtf8(import_node_path37.default.join(paths.modelMovesDir, `${sessionId}.json`));
117572
117753
  if (raw === void 0) {
117573
117754
  return void 0;
117574
117755
  }
@@ -117578,12 +117759,12 @@ function readModelMove(fs29, paths, sessionId) {
117578
117759
  return void 0;
117579
117760
  }
117580
117761
  }
117581
- function removeModelMove(fs29, paths, sessionId) {
117582
- fs29.removeRecursive(import_node_path37.default.join(paths.modelMovesDir, `${sessionId}.json`));
117762
+ function removeModelMove(fs30, paths, sessionId) {
117763
+ fs30.removeRecursive(import_node_path37.default.join(paths.modelMovesDir, `${sessionId}.json`));
117583
117764
  }
117584
- function supervisedSessionOf(fs29, paths, sessionId, isRunning) {
117585
- for (const pool of fs29.readdir(paths.superviseDir)) {
117586
- const sessions = liveSupervised(fs29, paths, pool, isRunning);
117765
+ function supervisedSessionOf(fs30, paths, sessionId, isRunning) {
117766
+ for (const pool of fs30.readdir(paths.superviseDir)) {
117767
+ const sessions = liveSupervised(fs30, paths, pool, isRunning);
117587
117768
  const found = sessions.find((session) => session.sessionId === sessionId);
117588
117769
  if (found !== void 0) {
117589
117770
  return found;
@@ -117641,9 +117822,9 @@ function blendedPricePerMTok(prices, mix) {
117641
117822
 
117642
117823
  // src/selection/targetStore.ts
117643
117824
  var SEED_LOOKBACK_RECORDS = 500;
117644
- function createTargetObservationStore(fs29, paths) {
117825
+ function createTargetObservationStore(fs30, paths) {
117645
117826
  let observations = /* @__PURE__ */ new Map();
117646
- const seeded = readUsageLog(fs29, paths.usageLogDir, {}).records.slice(-SEED_LOOKBACK_RECORDS);
117827
+ const seeded = readUsageLog(fs30, paths.usageLogDir, {}).records.slice(-SEED_LOOKBACK_RECORDS);
117647
117828
  for (const record2 of seeded) {
117648
117829
  observations = observeRecord(observations, record2);
117649
117830
  }
@@ -118063,8 +118244,8 @@ var StampsFileSchema = external_exports.strictObject({
118063
118244
  schemaVersion: external_exports.literal(STAMPS_SCHEMA_VERSION),
118064
118245
  handled: external_exports.record(external_exports.string().min(1), external_exports.iso.datetime())
118065
118246
  });
118066
- function readHandled(fs29, file2) {
118067
- const raw = fs29.readFileUtf8(file2);
118247
+ function readHandled(fs30, file2) {
118248
+ const raw = fs30.readFileUtf8(file2);
118068
118249
  if (raw === void 0) {
118069
118250
  return {};
118070
118251
  }
@@ -118077,10 +118258,10 @@ function readHandled(fs29, file2) {
118077
118258
  const result = StampsFileSchema.safeParse(parsed);
118078
118259
  return result.success ? Object.fromEntries(Object.entries(result.data.handled).map(([key, at2]) => [key, Date.parse(at2)])) : {};
118079
118260
  }
118080
- function writeHandled(fs29, file2, handled) {
118261
+ function writeHandled(fs30, file2, handled) {
118081
118262
  const next = { schemaVersion: STAMPS_SCHEMA_VERSION, handled: Object.fromEntries(Object.entries(handled).map(([key, at2]) => [key, new Date(at2).toISOString()])) };
118082
- fs29.mkdirPrivate(import_node_path48.default.dirname(file2));
118083
- fs29.writeFilePrivate(file2, `${JSON.stringify(next, null, 2)}
118263
+ fs30.mkdirPrivate(import_node_path48.default.dirname(file2));
118264
+ fs30.writeFilePrivate(file2, `${JSON.stringify(next, null, 2)}
118084
118265
  `);
118085
118266
  }
118086
118267
 
@@ -118726,8 +118907,8 @@ function finiteNumber(record2, field) {
118726
118907
  const value2 = record2 === void 0 ? void 0 : record2[field];
118727
118908
  return typeof value2 === "number" && Number.isFinite(value2) ? value2 : void 0;
118728
118909
  }
118729
- function excerpt(text2) {
118730
- return text2.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text2 : `${text2.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
118910
+ function excerpt(text3) {
118911
+ return text3.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text3 : `${text3.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
118731
118912
  }
118732
118913
  function payloadEventsOf(body) {
118733
118914
  const parsed = parseJsonObject(body);
@@ -118857,8 +119038,8 @@ function createRcSessionTracker(deps) {
118857
119038
  if (!accepted2 || buffered2 >= RC_CREATE_RESPONSE_CAP_BYTES) {
118858
119039
  return;
118859
119040
  }
118860
- const text2 = Buffer.from(chunk2).toString("utf8");
118861
- body = body + text2.slice(0, RC_CREATE_RESPONSE_CAP_BYTES - buffered2);
119041
+ const text3 = Buffer.from(chunk2).toString("utf8");
119042
+ body = body + text3.slice(0, RC_CREATE_RESPONSE_CAP_BYTES - buffered2);
118862
119043
  buffered2 = body.length;
118863
119044
  },
118864
119045
  onEnd: () => {
@@ -119076,13 +119257,13 @@ function teeRoutedResponse(response, observer, onSettled) {
119076
119257
  }
119077
119258
 
119078
119259
  // src/frontdoor/rcWrites.ts
119079
- function buildRcUserMessagePayload(uuid3, sessionId, text2) {
119260
+ function buildRcUserMessagePayload(uuid3, sessionId, text3) {
119080
119261
  return {
119081
119262
  type: "user",
119082
119263
  uuid: uuid3,
119083
119264
  session_id: sessionId,
119084
119265
  parent_tool_use_id: null,
119085
- message: { role: "user", content: text2 }
119266
+ message: { role: "user", content: text3 }
119086
119267
  };
119087
119268
  }
119088
119269
  function buildRcEventWriteBody(payload) {
@@ -119147,7 +119328,7 @@ function rcWriteHeaders(credential) {
119147
119328
  }
119148
119329
  return headers;
119149
119330
  }
119150
- async function injectRcUserMessage(deps, sessionId, text2) {
119331
+ async function injectRcUserMessage(deps, sessionId, text3) {
119151
119332
  const credential = deps.credentialOf(sessionId);
119152
119333
  if (credential === void 0) {
119153
119334
  return { ok: false, message: rcSessionNotObservedMessage(sessionId) };
@@ -119155,7 +119336,7 @@ async function injectRcUserMessage(deps, sessionId, text2) {
119155
119336
  if (credential.authorization === void 0) {
119156
119337
  return noOAuthCredentialResult(sessionId);
119157
119338
  }
119158
- const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text2)));
119339
+ const body = JSON.stringify(buildRcEventWriteBody(buildRcUserMessagePayload(deps.newUuid(), sessionId, text3)));
119159
119340
  let answer;
119160
119341
  try {
119161
119342
  answer = await deps.dial.writeEvents(sessionId, rcWriteHeaders(credential), body);
@@ -119378,9 +119559,9 @@ var RC_PERMISSION_MODE_LIST = RC_PERMISSION_MODES.join(", ");
119378
119559
  var CONTROL_PATH_PREFIX = "/__agent-shim/rc";
119379
119560
  var CONTROL_BODY_CAP_BYTES = 10485760;
119380
119561
  function answerJson(response, status, body) {
119381
- const text2 = JSON.stringify(body);
119382
- response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text2, "utf8")) });
119383
- response.end(text2);
119562
+ const text3 = JSON.stringify(body);
119563
+ response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text3, "utf8")) });
119564
+ response.end(text3);
119384
119565
  }
119385
119566
  function isJsonObject(value2) {
119386
119567
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
@@ -119629,12 +119810,12 @@ function createRcControlHandler(deps) {
119629
119810
  answerJson(response, HTTP_STATUS.badRequest, { error: "the answer body must be JSON naming a non-empty session id, request id, and an approve boolean" });
119630
119811
  return;
119631
119812
  }
119632
- const text2 = "text" in parsed && typeof parsed.text === "string" ? parsed.text : void 0;
119633
- if (parsed.approve && text2 !== void 0 && text2 !== "") {
119813
+ const text3 = "text" in parsed && typeof parsed.text === "string" ? parsed.text : void 0;
119814
+ if (parsed.approve && text3 !== void 0 && text3 !== "") {
119634
119815
  answerJson(response, HTTP_STATUS.badRequest, { error: "an approval carries no text (the protocol's allow result has no message field); text is the denial message" });
119635
119816
  return;
119636
119817
  }
119637
- const result = await deps.answer(parsed.session, parsed.request, { approve: parsed.approve, message: parsed.approve ? void 0 : text2 });
119818
+ const result = await deps.answer(parsed.session, parsed.request, { approve: parsed.approve, message: parsed.approve ? void 0 : text3 });
119638
119819
  if (result.ok) {
119639
119820
  answerJson(response, HTTP_STATUS.ok, { session: parsed.session, request: parsed.request, sequenceNums: result.sequenceNums });
119640
119821
  return;
@@ -119897,7 +120078,7 @@ function frontDoorRcControl(transport, token) {
119897
120078
  listSessions: async () => sessionsOf(await listAnswerOf(`${CONTROL_PATH_PREFIX}/sessions`, "listing the door's Remote Control sessions"), "listing the door's Remote Control sessions"),
119898
120079
  statusOf: async (sessionId) => statusesOf(await listAnswerOf(`${CONTROL_PATH_PREFIX}/status${sessionQuery(sessionId)}`, "reading the door's Remote Control session status"), "reading the door's Remote Control session status"),
119899
120080
  pendingOf: async (sessionId) => pendingOfAnswer(await listAnswerOf(`${CONTROL_PATH_PREFIX}/pending${sessionQuery(sessionId)}`, "listing the door's pending Remote Control control requests"), "listing the door's pending Remote Control control requests"),
119900
- sendPrompt: async (sessionId, text2) => await writeOf(`${CONTROL_PATH_PREFIX}/inject`, JSON.stringify({ session: sessionId, text: text2 }), (status, message) => `injecting into ${sessionId} failed (HTTP ${String(status)}): ${message}`),
120081
+ sendPrompt: async (sessionId, text3) => await writeOf(`${CONTROL_PATH_PREFIX}/inject`, JSON.stringify({ session: sessionId, text: text3 }), (status, message) => `injecting into ${sessionId} failed (HTTP ${String(status)}): ${message}`),
119901
120082
  answerRequest: async (sessionId, requestId, decision) => await writeOf(
119902
120083
  `${CONTROL_PATH_PREFIX}/answer`,
119903
120084
  JSON.stringify({ session: sessionId, request: requestId, approve: decision.approve, ...decision.approve || decision.message === void 0 ? {} : { text: decision.message } }),
@@ -121610,11 +121791,11 @@ var AsyncIteratorClass = class {
121610
121791
  return this;
121611
121792
  }
121612
121793
  };
121613
- function parseEmptyableJSON(text2) {
121614
- if (!text2) {
121794
+ function parseEmptyableJSON(text3) {
121795
+ if (!text3) {
121615
121796
  return void 0;
121616
121797
  }
121617
- return JSON.parse(text2);
121798
+ return JSON.parse(text3);
121618
121799
  }
121619
121800
  function stringifyJSON(value2) {
121620
121801
  return JSON.stringify(value2);
@@ -121899,7 +122080,7 @@ function findDeepMatches(check2, payload, segments = [], maps = [], values = [])
121899
122080
  payload.forEach((v, i10) => {
121900
122081
  findDeepMatches(check2, v, [...segments, i10], maps, values);
121901
122082
  });
121902
- } else if (isPlainObject2(payload)) {
122083
+ } else if (isPlainObject3(payload)) {
121903
122084
  for (const key of Object.keys(payload)) {
121904
122085
  findDeepMatches(check2, payload[key], [...segments, key], maps, values);
121905
122086
  }
@@ -121924,7 +122105,7 @@ function* getConstructors(value2) {
121924
122105
  proto = Object.getPrototypeOf(proto);
121925
122106
  }
121926
122107
  }
121927
- function isPlainObject2(value2) {
122108
+ function isPlainObject3(value2) {
121928
122109
  if (!value2 || typeof value2 !== "object") {
121929
122110
  return false;
121930
122111
  }
@@ -121957,7 +122138,7 @@ function setOwn(object3, key, value2) {
121957
122138
  }
121958
122139
  }
121959
122140
  function mergeTwoLevels(first, second) {
121960
- if (!isPlainObject2(first) || !isPlainObject2(second)) {
122141
+ if (!isPlainObject3(first) || !isPlainObject3(second)) {
121961
122142
  return second;
121962
122143
  }
121963
122144
  const result = { ...first, ...second };
@@ -121967,7 +122148,7 @@ function mergeTwoLevels(first, second) {
121967
122148
  }
121968
122149
  const firstValue = first[key];
121969
122150
  const secondValue = second[key];
121970
- if (isPlainObject2(firstValue) && isPlainObject2(secondValue)) {
122151
+ if (isPlainObject3(firstValue) && isPlainObject3(secondValue)) {
121971
122152
  result[key] = { ...firstValue, ...secondValue };
121972
122153
  }
121973
122154
  }
@@ -121996,7 +122177,7 @@ function cloneWithVisited(value2, visited) {
121996
122177
  }
121997
122178
  return result;
121998
122179
  }
121999
- if (isPlainObject2(value2)) {
122180
+ if (isPlainObject3(value2)) {
122000
122181
  const existing = visited.get(value2);
122001
122182
  if (existing) {
122002
122183
  return existing;
@@ -122021,7 +122202,7 @@ function copyOnWrite(parent, key, original) {
122021
122202
  let copy;
122022
122203
  if (Array.isArray(value2)) {
122023
122204
  copy = value2.slice();
122024
- } else if (isPlainObject2(value2)) {
122205
+ } else if (isPlainObject3(value2)) {
122025
122206
  copy = { ...value2 };
122026
122207
  } else {
122027
122208
  return value2;
@@ -122638,7 +122819,7 @@ function toORPCError(error63) {
122638
122819
  return error63 instanceof ORPCError ? error63 : new ORPCError("INTERNAL_SERVER_ERROR", { cause: error63 });
122639
122820
  }
122640
122821
  function isORPCErrorJson(json2) {
122641
- if (!isPlainObject2(json2)) {
122822
+ if (!isPlainObject3(json2)) {
122642
122823
  return false;
122643
122824
  }
122644
122825
  const validKeys = ["defined", "code", "message", "data"];
@@ -122665,14 +122846,14 @@ function createORPCErrorFromMalformedResponse(options) {
122665
122846
  }
122666
122847
  var INFERRED_MESSAGE_MIN_LENGTH = 1;
122667
122848
  var INFERRED_MESSAGE_MAX_LENGTH = 256;
122668
- function isInferableMessage(text2) {
122669
- return text2.length >= INFERRED_MESSAGE_MIN_LENGTH && text2.length <= INFERRED_MESSAGE_MAX_LENGTH;
122849
+ function isInferableMessage(text3) {
122850
+ return text3.length >= INFERRED_MESSAGE_MIN_LENGTH && text3.length <= INFERRED_MESSAGE_MAX_LENGTH;
122670
122851
  }
122671
122852
  function inferMalformedResponseMessage(response) {
122672
122853
  if (typeof response.body === "string" && isInferableMessage(response.body)) {
122673
122854
  return response.body;
122674
122855
  }
122675
- if (isPlainObject2(response.body) && typeof response.body.message === "string" && isInferableMessage(response.body.message)) {
122856
+ if (isPlainObject3(response.body) && typeof response.body.message === "string" && isInferableMessage(response.body.message)) {
122676
122857
  return response.body.message;
122677
122858
  }
122678
122859
  const commonCode = Object.entries(COMMON_ERROR_STATUS_MAP).find(([, status]) => status === response.status)?.[0];
@@ -122963,7 +123144,7 @@ var RPCJsonSerializer = class {
122963
123144
  }
122964
123145
  return json2;
122965
123146
  }
122966
- if (isPlainObject2(data)) {
123147
+ if (isPlainObject3(data)) {
122967
123148
  const json2 = new NullProtoObj();
122968
123149
  for (const k10 of Object.keys(data)) {
122969
123150
  const v = data[k10];
@@ -123209,7 +123390,7 @@ var BracketNotationSerializer = class {
123209
123390
  data.forEach((item, i10) => {
123210
123391
  this.internalSerialize(item, isRoot ? i10.toString() : `${path66}[${i10}]`, false, result);
123211
123392
  });
123212
- } else if (isPlainObject2(data)) {
123393
+ } else if (isPlainObject3(data)) {
123213
123394
  for (const key of Object.keys(data)) {
123214
123395
  this.internalSerialize(data[key], isRoot ? key : `${path66}[${key}]`, false, result);
123215
123396
  }
@@ -123229,7 +123410,7 @@ var BracketNotationSerializer = class {
123229
123410
  const isLast = i10 === segments.length - 1;
123230
123411
  const existing = getOwn(currentRef, nextSegment);
123231
123412
  let child = existing;
123232
- if (!Array.isArray(child) && !isPlainObject2(child)) {
123413
+ if (!Array.isArray(child) && !isPlainObject3(child)) {
123233
123414
  child = [];
123234
123415
  }
123235
123416
  if (Array.isArray(child)) {
@@ -123784,7 +123965,7 @@ var OpenAPIJsonSerializer = class {
123784
123965
  }
123785
123966
  return json2;
123786
123967
  }
123787
- if (isPlainObject2(data)) {
123968
+ if (isPlainObject3(data)) {
123788
123969
  const json2 = new NullProtoObj();
123789
123970
  for (const k10 of Object.keys(data)) {
123790
123971
  const v = data[k10];
@@ -126618,7 +126799,7 @@ function toBodyContent(ctx, direction, schema) {
126618
126799
  if (rest.length > 0) {
126619
126800
  const restSchema = fileSchemasByMediaType.size ? combineJsonSchemasWithComposition("anyOf", rest) : schema;
126620
126801
  const hasNestedFiles = findDeepMatches(
126621
- (v) => isPlainObject2(v) && isJsonFileSchema(v),
126802
+ (v) => isPlainObject3(v) && isJsonFileSchema(v),
126622
126803
  restSchema
126623
126804
  ).values.length > 0;
126624
126805
  const contentType = hasNestedFiles ? "multipart/form-data" : "application/json";
@@ -127403,15 +127584,15 @@ async function toStandardBody(re, options) {
127403
127584
  throw new TypeError("Failed to read body: body stream already read");
127404
127585
  }
127405
127586
  if (hint === "json") {
127406
- const text2 = await re.text();
127407
- return parseEmptyableJSON(text2);
127587
+ const text3 = await re.text();
127588
+ return parseEmptyableJSON(text3);
127408
127589
  }
127409
127590
  if (hint === "form-data") {
127410
127591
  return await re.formData();
127411
127592
  }
127412
127593
  if (hint === "url-search-params") {
127413
- const text2 = await re.text();
127414
- return new URLSearchParams(text2);
127594
+ const text3 = await re.text();
127595
+ return new URLSearchParams(text3);
127415
127596
  }
127416
127597
  if (hint === "event-stream") {
127417
127598
  return toAsyncIteratorObject(re.body);
@@ -127887,16 +128068,16 @@ async function toStandardBody2(req, options = {}) {
127887
128068
  throw new TypeError("Failed to read body: body stream already read or destroyed");
127888
128069
  }
127889
128070
  if (hint === "json") {
127890
- const text2 = await _streamToString(req);
127891
- return parseEmptyableJSON(text2);
128071
+ const text3 = await _streamToString(req);
128072
+ return parseEmptyableJSON(text3);
127892
128073
  }
127893
128074
  const contentType = req.headers["content-type"];
127894
128075
  if (hint === "form-data") {
127895
128076
  return _streamToFormData(req, contentType);
127896
128077
  }
127897
128078
  if (hint === "url-search-params") {
127898
- const text2 = await _streamToString(req);
127899
- return new URLSearchParams(text2);
128079
+ const text3 = await _streamToString(req);
128080
+ return new URLSearchParams(text3);
127900
128081
  }
127901
128082
  if (hint === "event-stream") {
127902
128083
  return toAsyncIteratorObject2(req);
@@ -129117,7 +129298,7 @@ var OpenAPIHandlerCodecCore = class {
129117
129298
  if (!params || Object.keys(params).length < 1) {
129118
129299
  return data;
129119
129300
  }
129120
- if (!isPlainObject2(data)) {
129301
+ if (!isPlainObject3(data)) {
129121
129302
  return params;
129122
129303
  }
129123
129304
  return {
@@ -129177,7 +129358,7 @@ var OpenAPIHandlerCodecCore = class {
129177
129358
  const [, search] = parseStandardUrl(url2);
129178
129359
  const searchParams = new URLSearchParams(search);
129179
129360
  const parsed = this.serializer.deserialize(searchParams);
129180
- if (!styles || !isPlainObject2(parsed)) {
129361
+ if (!styles || !isPlainObject3(parsed)) {
129181
129362
  return parsed;
129182
129363
  }
129183
129364
  Object.entries(styles).forEach(([key, hint]) => {
@@ -129513,7 +129694,6 @@ init_providersStore();
129513
129694
  // src/frontdoor/configSchemas.ts
129514
129695
  init_zod();
129515
129696
  init_schema();
129516
- init_statusline();
129517
129697
  var RemovalConfirmationSchema = external_exports.boolean();
129518
129698
  var CredentialWriteSchema = (targets) => external_exports.strictObject({
129519
129699
  sources: external_exports.array(RemoteCredentialSourceSchema).min(1).optional(),
@@ -129590,7 +129770,10 @@ var ConfigProfileSetInputSchema = external_exports.strictObject({
129590
129770
  pause: external_exports.boolean().optional(),
129591
129771
  explain: external_exports.boolean().optional(),
129592
129772
  proxyBypass: external_exports.union([external_exports.array(external_exports.string().min(1)), external_exports.literal(false)]).optional(),
129593
- statusline: StatuslineChangeSchema.optional()
129773
+ statusline: external_exports.strictObject({
129774
+ set: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
129775
+ unset: external_exports.array(external_exports.string()).optional()
129776
+ }).optional()
129594
129777
  }).optional()
129595
129778
  });
129596
129779
  var ConfigProfileSetOutputSchema = storedMutationOutput("profile", "updated", ProfileValueSchema);
@@ -130607,7 +130790,7 @@ function nextToken(body, from) {
130607
130790
  }
130608
130791
  return SCALAR;
130609
130792
  }
130610
- function walk(body, hashing, parentAfter) {
130793
+ function walk2(body, hashing, parentAfter) {
130611
130794
  const thread = (0, import_node_crypto22.createHash)("sha256");
130612
130795
  const messages = (0, import_node_crypto22.createHash)("sha256");
130613
130796
  let parentDigest;
@@ -130676,16 +130859,16 @@ function walk(body, hashing, parentAfter) {
130676
130859
  continue;
130677
130860
  }
130678
130861
  const isKey = kind === STRING && depth >= 1 && expectKey[depth - 1] === true;
130679
- const text2 = isKey ? body.toString("latin1", start, end) : void 0;
130680
- if (isKey && text2 === CACHE_MARKER_KEY) {
130862
+ const text3 = isKey ? body.toString("latin1", start, end) : void 0;
130863
+ if (isKey && text3 === CACHE_MARKER_KEY) {
130681
130864
  skipNextValue = true;
130682
130865
  continue;
130683
130866
  }
130684
130867
  if (depth === 1 && isKey) {
130685
- topKey = text2;
130868
+ topKey = text3;
130686
130869
  }
130687
130870
  const closesMessages = kind === CLOSE && inMessages && depth === MESSAGES_ARRAY_DEPTH;
130688
- if (hashing && !closesMessages && !(depth === 1 && isKey && !THREAD_MEMBER_KEYS.has(text2 ?? ""))) {
130871
+ if (hashing && !closesMessages && !(depth === 1 && isKey && !THREAD_MEMBER_KEYS.has(text3 ?? ""))) {
130689
130872
  const target = inMessages ? messages : depth >= 1 && topKey !== void 0 && THREAD_MEMBER_KEYS.has(topKey) ? thread : void 0;
130690
130873
  if (target !== void 0) {
130691
130874
  target.update(body.subarray(start, end));
@@ -130724,12 +130907,12 @@ function lineageOf(body) {
130724
130907
  if (body.length > LINEAGE_BODY_BYTES_LIMIT) {
130725
130908
  return void 0;
130726
130909
  }
130727
- const counted = walk(body, false, void 0);
130910
+ const counted = walk2(body, false, void 0);
130728
130911
  if (counted.abandoned || !counted.sawMessages) {
130729
130912
  return void 0;
130730
130913
  }
130731
130914
  const parentAfter = counted.elements > MESSAGES_PER_TURN ? counted.elements - MESSAGES_PER_TURN : void 0;
130732
- const hashed = walk(body, true, parentAfter);
130915
+ const hashed = walk2(body, true, parentAfter);
130733
130916
  const combine = (messagesDigest) => (0, import_node_crypto22.createHash)("sha256").update(hashed.threadDigest).update(messagesDigest).digest("hex");
130734
130917
  return { ownKey: combine(hashed.messagesDigest), parentKey: hashed.parentDigest === void 0 ? void 0 : combine(hashed.parentDigest) };
130735
130918
  }
@@ -131655,8 +131838,8 @@ function createCodexRoute(ports) {
131655
131838
  if (!parsed.success) {
131656
131839
  return errorResponse(HTTP_STATUS.badRequest, "not a count_tokens request");
131657
131840
  }
131658
- const text2 = JSON.stringify({ system: parsed.data.system, messages: parsed.data.messages, tools: parsed.data.tools });
131659
- return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input_tokens: Math.ceil(text2.length / CHARS_PER_TOKEN) }) };
131841
+ const text3 = JSON.stringify({ system: parsed.data.system, messages: parsed.data.messages, tools: parsed.data.tools });
131842
+ return { status: HTTP_STATUS.ok, headers: { "Content-Type": "application/json" }, body: JSON.stringify({ input_tokens: Math.ceil(text3.length / CHARS_PER_TOKEN) }) };
131660
131843
  };
131661
131844
  return async (request7) => {
131662
131845
  if (request7.method === "GET" && request7.path === "/healthz") {
@@ -132517,28 +132700,28 @@ async function scanRequestHead(request7, wholeBody = false) {
132517
132700
  const body = request7.body;
132518
132701
  const head = [];
132519
132702
  let seen = 0;
132520
- let text2 = "";
132703
+ let text3 = "";
132521
132704
  let decided = false;
132522
132705
  let ended = false;
132523
132706
  let error63;
132524
132707
  const replay = new import_node_stream2.PassThrough();
132525
- const modelIn = () => /"model"\s*:\s*"([^"]+)"/.exec(text2)?.[1];
132708
+ const modelIn = () => /"model"\s*:\s*"([^"]+)"/.exec(text3)?.[1];
132526
132709
  const settled = new Promise((resolve2) => {
132527
132710
  const settle2 = () => {
132528
132711
  const model = modelIn();
132529
- const hasImage = /"type"\s*:\s*"image"/.test(text2);
132712
+ const hasImage = /"type"\s*:\s*"image"/.test(text3);
132530
132713
  for (const chunk2 of head) {
132531
132714
  replay.write(chunk2);
132532
132715
  }
132533
- const maxTokens = /"max_tokens"\s*:\s*([0-9]+)/.exec(text2)?.[1];
132716
+ const maxTokens = /"max_tokens"\s*:\s*([0-9]+)/.exec(text3)?.[1];
132534
132717
  resolve2({
132535
132718
  ...model === void 0 ? {} : { model },
132536
132719
  hasImage,
132537
- toolsPresent: /"tools"\s*:\s*\[\s*\{/.test(text2),
132538
- thinking: /"thinking"\s*:\s*\{\s*"type"\s*:\s*"enabled"/.test(text2),
132720
+ toolsPresent: /"tools"\s*:\s*\[\s*\{/.test(text3),
132721
+ thinking: /"thinking"\s*:\s*\{\s*"type"\s*:\s*"enabled"/.test(text3),
132539
132722
  ...maxTokens === void 0 ? {} : { maxTokens: Number(maxTokens) },
132540
132723
  isCountTokens: request7.url.includes("/v1/messages/count_tokens"),
132541
- ...wholeBody ? { whole: true, text: text2 } : {},
132724
+ ...wholeBody ? { whole: true, text: text3 } : {},
132542
132725
  replayed: { ...request7, body: replay }
132543
132726
  });
132544
132727
  };
@@ -132554,7 +132737,7 @@ async function scanRequestHead(request7, wholeBody = false) {
132554
132737
  }
132555
132738
  head.push(chunk2);
132556
132739
  seen += chunk2.length;
132557
- text2 += chunk2.toString("utf8");
132740
+ text3 += chunk2.toString("utf8");
132558
132741
  if (!wholeBody && (modelIn() !== void 0 || seen >= REQUEST_SCAN_CAP_BYTES)) {
132559
132742
  decided = true;
132560
132743
  settle2();
@@ -133057,9 +133240,9 @@ function growthBookFeatures() {
133057
133240
  };
133058
133241
  }
133059
133242
  var answerServerJson = (response, status, body) => {
133060
- const text2 = JSON.stringify(body);
133061
- response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text2, "utf8")) });
133062
- response.end(text2);
133243
+ const text3 = JSON.stringify(body);
133244
+ response.writeHead(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text3, "utf8")) });
133245
+ response.end(text3);
133063
133246
  };
133064
133247
  function createRcSelfHostLocal(deps) {
133065
133248
  return {
@@ -133143,8 +133326,8 @@ var SELF_HOST_SUBSCRIPTION_TYPE = "max";
133143
133326
  function isRecord16(value2) {
133144
133327
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
133145
133328
  }
133146
- function readJsonObject(fs29, file2) {
133147
- const raw = fs29.readFileUtf8(file2);
133329
+ function readJsonObject(fs30, file2) {
133330
+ const raw = fs30.readFileUtf8(file2);
133148
133331
  if (raw === void 0) {
133149
133332
  return void 0;
133150
133333
  }
@@ -133156,8 +133339,8 @@ function readJsonObject(fs29, file2) {
133156
133339
  }
133157
133340
  return isRecord16(parsed) ? parsed : void 0;
133158
133341
  }
133159
- function readRcSelfHostRecord(fs29, frontdoorDir) {
133160
- const parsed = readJsonObject(fs29, import_node_path52.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
133342
+ function readRcSelfHostRecord(fs30, frontdoorDir) {
133343
+ const parsed = readJsonObject(fs30, import_node_path52.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
133161
133344
  if (parsed === void 0) {
133162
133345
  return void 0;
133163
133346
  }
@@ -133270,8 +133453,8 @@ function formatRcPendingList(pending) {
133270
133453
  }
133271
133454
  return pending.map((request7) => `${request7.sessionId} ${request7.requestId} ${request7.type}${request7.summary === "" ? "" : ` ${request7.summary}`} observed ${new Date(request7.observedAt).toISOString()}`);
133272
133455
  }
133273
- function eventExcerpt(text2) {
133274
- return text2.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text2 : `${text2.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
133456
+ function eventExcerpt(text3) {
133457
+ return text3.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text3 : `${text3.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
133275
133458
  }
133276
133459
  var PERCENT_SCALE = 100;
133277
133460
  var MS_PER_SECOND14 = 1e3;
@@ -133602,11 +133785,11 @@ function credentialOfJson(parsed) {
133602
133785
  function sequenceNumOfJson(value2) {
133603
133786
  return typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 ? value2 : void 0;
133604
133787
  }
133605
- function createRcCredentialStore(fs29, dir) {
133606
- fs29.mkdirPrivate(dir);
133788
+ function createRcCredentialStore(fs30, dir) {
133789
+ fs30.mkdirPrivate(dir);
133607
133790
  const fileFor = (sessionId) => import_node_path53.default.join(dir, `${sessionId}.json`);
133608
133791
  const readParsed = (sessionId) => {
133609
- const raw = fs29.readFileUtf8(fileFor(sessionId));
133792
+ const raw = fs30.readFileUtf8(fileFor(sessionId));
133610
133793
  if (raw === void 0) {
133611
133794
  return void 0;
133612
133795
  }
@@ -133631,7 +133814,7 @@ function createRcCredentialStore(fs29, dir) {
133631
133814
  }
133632
133815
  const cursor3 = sequenceNumOfJson(readParsed(sessionId)?.highestSequenceNum);
133633
133816
  const record2 = { ...credential, ...cursor3 === void 0 ? {} : { highestSequenceNum: cursor3 } };
133634
- fs29.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
133817
+ fs30.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
133635
133818
  `);
133636
133819
  },
133637
133820
  readCursor: (sessionId) => {
@@ -133646,14 +133829,14 @@ function createRcCredentialStore(fs29, dir) {
133646
133829
  }
133647
133830
  const credential = credentialOfJson(readParsed(sessionId));
133648
133831
  const record2 = credential === void 0 ? { highestSequenceNum } : { ...credential, highestSequenceNum };
133649
- fs29.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
133832
+ fs30.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
133650
133833
  `);
133651
133834
  },
133652
133835
  remove: (sessionId) => {
133653
133836
  if (!isSafeSessionId(sessionId)) {
133654
133837
  return;
133655
133838
  }
133656
- fs29.removeRecursive(fileFor(sessionId));
133839
+ fs30.removeRecursive(fileFor(sessionId));
133657
133840
  }
133658
133841
  };
133659
133842
  }
@@ -134970,9 +135153,9 @@ data: ${JSON.stringify(envelope)}
134970
135153
  };
134971
135154
  const sessionRow = (session) => ({ id: session.id, title: session.title, created_at: new Date(session.createdAt).toISOString(), status: "active", conversation_id: session.conversation.id });
134972
135155
  const answerJson2 = async (response, status, body, extraHeaders = {}) => {
134973
- const text2 = JSON.stringify(body);
134974
- response.start(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text2, "utf8")), ...extraHeaders });
134975
- await response.write(text2);
135156
+ const text3 = JSON.stringify(body);
135157
+ response.start(status, { "content-type": "application/json", "content-length": String(Buffer.byteLength(text3, "utf8")), ...extraHeaders });
135158
+ await response.write(text3);
134976
135159
  response.end();
134977
135160
  };
134978
135161
  const noCredential = async (response) => {
@@ -135374,8 +135557,8 @@ function createSseParser() {
135374
135557
  let dataLines = [];
135375
135558
  let seenAnyText = false;
135376
135559
  return {
135377
- write: (text2) => {
135378
- let incoming = text2;
135560
+ write: (text3) => {
135561
+ let incoming = text3;
135379
135562
  if (!seenAnyText) {
135380
135563
  seenAnyText = true;
135381
135564
  incoming = incoming.charCodeAt(0) === SSE_BYTE_ORDER_MARK ? incoming.slice(1) : incoming;
@@ -136267,7 +136450,7 @@ function realFrontDoorSupervisorPorts(paths, respawnGeneration, retire, trackTun
136267
136450
  startProviderListener: async (preferredPort) => {
136268
136451
  const authority = loadCa();
136269
136452
  const rcDial = rcSelfHost ? lateRcEventDial(rcSelfHostDialTarget) : realRcEventDial();
136270
- const rcInject = async (sessionId, text2) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto25.randomUUID }, sessionId, text2);
136453
+ const rcInject = async (sessionId, text3) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto25.randomUUID }, sessionId, text3);
136271
136454
  const rcAnswer = async (sessionId, requestId, decision) => await answerRcControlRequest({ credentialOf: rcTracker.credentialOf, pendingOf: (id2) => rcTracker.pendingOf(id2), completePending: rcTracker.completePending, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial }, sessionId, requestId, decision);
136272
136455
  const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto25.randomUUID };
136273
136456
  const rcInterrupt = async (sessionId) => await interruptRcSession(rcControlRequestDeps, sessionId);
@@ -136551,8 +136734,8 @@ function registerFrontDoorCommand(program2, deps) {
136551
136734
  }
136552
136735
 
136553
136736
  // src/statusline/commands.ts
136554
- var import_node_child_process7 = require("node:child_process");
136555
- var import_node_os12 = __toESM(require("node:os"), 1);
136737
+ var import_node_child_process8 = require("node:child_process");
136738
+ var import_node_os13 = __toESM(require("node:os"), 1);
136556
136739
  var import_node_path56 = __toESM(require("node:path"), 1);
136557
136740
  init_commandDeps();
136558
136741
  init_statusline();
@@ -136567,8 +136750,8 @@ function isAntigravityPayload(payload) {
136567
136750
  return typeof payload === "object" && payload !== null && "product" in payload && payload.product === "antigravity";
136568
136751
  }
136569
136752
  var ANTIGRAVITY_SETTINGS_SEGMENTS = [".gemini", "antigravity-cli", "settings.json"];
136570
- function antigravityStacksWithDefault(fs29, homeDir) {
136571
- const raw = fs29.readFileUtf8(import_node_path55.default.join(homeDir, ...ANTIGRAVITY_SETTINGS_SEGMENTS));
136753
+ function antigravityStacksWithDefault(fs30, homeDir) {
136754
+ const raw = fs30.readFileUtf8(import_node_path55.default.join(homeDir, ...ANTIGRAVITY_SETTINGS_SEGMENTS));
136572
136755
  if (raw === void 0) {
136573
136756
  return false;
136574
136757
  }
@@ -136872,17 +137055,90 @@ function providerScopedState(snapshot, providerName, providerDisplayName) {
136872
137055
  // src/statusline/commands.ts
136873
137056
  init_read();
136874
137057
 
137058
+ // src/statusline/payload.ts
137059
+ init_zod();
137060
+ var number4 = external_exports.number().optional().catch(void 0);
137061
+ var text2 = external_exports.string().optional().catch(void 0);
137062
+ var ClientPayloadSchema = external_exports.looseObject({
137063
+ session_id: text2,
137064
+ transcript_path: text2,
137065
+ cwd: text2,
137066
+ workspace: external_exports.looseObject({
137067
+ current_dir: text2,
137068
+ project_dir: text2,
137069
+ added_dirs: external_exports.array(external_exports.string()).optional().catch(void 0),
137070
+ git_worktree: text2
137071
+ }).optional().catch(void 0),
137072
+ model: external_exports.looseObject({ id: text2, display_name: text2 }).optional().catch(void 0),
137073
+ context_window: external_exports.looseObject({
137074
+ context_window_size: number4,
137075
+ total_input_tokens: number4,
137076
+ total_output_tokens: number4,
137077
+ used_percentage: number4,
137078
+ remaining_percentage: number4,
137079
+ current_usage: external_exports.looseObject({ input_tokens: number4, output_tokens: number4, cache_creation_input_tokens: number4, cache_read_input_tokens: number4 }).optional().catch(void 0)
137080
+ }).optional().catch(void 0),
137081
+ prompt_cache: external_exports.looseObject({ hit_ratio: number4 }).optional().catch(void 0),
137082
+ cost: external_exports.looseObject({ total_cost_usd: number4, total_duration_ms: number4, total_api_duration_ms: number4, total_lines_added: number4, total_lines_removed: number4 }).optional().catch(void 0),
137083
+ rate_limits: external_exports.looseObject({
137084
+ five_hour: external_exports.looseObject({ used_percentage: number4, resets_at: number4 }).optional().catch(void 0),
137085
+ seven_day: external_exports.looseObject({ used_percentage: number4, resets_at: number4 }).optional().catch(void 0),
137086
+ model_scoped: external_exports.array(external_exports.looseObject({ display_name: text2, utilization: number4, resets_at: text2 })).optional().catch(void 0)
137087
+ }).optional().catch(void 0)
137088
+ }).catch({});
137089
+ function parseClientPayload(raw) {
137090
+ return ClientPayloadSchema.parse(raw);
137091
+ }
137092
+ function viewOf(payload) {
137093
+ return {
137094
+ modelDisplayName: payload.model?.display_name,
137095
+ contextUsedPercentage: payload.context_window?.used_percentage,
137096
+ contextTotalTokens: payload.context_window?.total_input_tokens,
137097
+ contextWindowTokens: payload.context_window?.context_window_size,
137098
+ cacheHitRatio: payload.prompt_cache?.hit_ratio,
137099
+ cacheReadTokens: payload.context_window?.current_usage?.cache_read_input_tokens,
137100
+ freshInputTokens: payload.context_window?.current_usage?.input_tokens
137101
+ };
137102
+ }
137103
+
137104
+ // src/statusline/ports.ts
137105
+ var import_node_child_process7 = require("node:child_process");
137106
+ var import_node_fs22 = __toESM(require("node:fs"), 1);
137107
+ var import_node_os12 = __toESM(require("node:os"), 1);
137108
+ var RUN_TIMEOUT_MS = 2e3;
137109
+ var RUN_MAX_BUFFER_BYTES = 1048576;
137110
+ function realStatuslinePorts(env) {
137111
+ return {
137112
+ env,
137113
+ homeDirectory: import_node_os12.default.homedir(),
137114
+ readText: (path66) => {
137115
+ try {
137116
+ return import_node_fs22.default.readFileSync(path66, "utf8");
137117
+ } catch {
137118
+ return void 0;
137119
+ }
137120
+ },
137121
+ run: (file2, args, cwd) => {
137122
+ try {
137123
+ return (0, import_node_child_process7.execFileSync)(file2, [...args], { cwd, encoding: "utf8", timeout: RUN_TIMEOUT_MS, maxBuffer: RUN_MAX_BUFFER_BYTES, stdio: ["ignore", "pipe", "ignore"] });
137124
+ } catch {
137125
+ return void 0;
137126
+ }
137127
+ }
137128
+ };
137129
+ }
137130
+
137131
+ // src/statusline/render.ts
137132
+ init_statusline();
137133
+
136875
137134
  // src/statusline/ansi.ts
136876
137135
  var ESCAPE_CHAR_CODE = 27;
136877
137136
  var ESCAPE = String.fromCharCode(ESCAPE_CHAR_CODE);
136878
137137
  var ANSI_REGEX = new RegExp(`${ESCAPE}\\[[0-9;]*[a-zA-Z]`, "g");
136879
- function visibleLength(text2) {
136880
- return text2.replace(ANSI_REGEX, "").length;
137138
+ function visibleLength(text3) {
137139
+ return text3.replace(ANSI_REGEX, "").length;
136881
137140
  }
136882
137141
 
136883
- // src/statusline/render.ts
136884
- init_statusline();
136885
-
136886
137142
  // src/statusline/barGrid.ts
136887
137143
  var BRACKET_COLUMNS = 2;
136888
137144
  function chunk(items, size) {
@@ -136909,8 +137165,8 @@ function measureGrid(rows, separatorLength, baseBarCells) {
136909
137165
  const fixed = [...prefixWidths, ...suffixWidths].reduce((total, width) => total + width, 0) + columns * (baseBarCells + BRACKET_COLUMNS);
136910
137166
  return { rows, columns, prefixWidths, suffixWidths, baseWidth: fixed + separatorLength * (columns - 1) };
136911
137167
  }
136912
- function padTo(text2, width) {
136913
- return text2 + " ".repeat(Math.max(0, width - visibleLength(text2)));
137168
+ function padTo(text3, width) {
137169
+ return text3 + " ".repeat(Math.max(0, width - visibleLength(text3)));
136914
137170
  }
136915
137171
  function renderGrid(grid, maxWidth, separator, baseBarCells) {
136916
137172
  const separatorLength = visibleLength(separator);
@@ -136953,7 +137209,122 @@ function layoutBarGrid(groups, maxWidth, separator, baseBarCells) {
136953
137209
  return renderGrid(layoutFor(1), maxWidth, separator, baseBarCells);
136954
137210
  }
136955
137211
 
136956
- // src/statusline/render.ts
137212
+ // src/statusline/elements/header/account.ts
137213
+ function tierSuffixOf(tier) {
137214
+ const match = /_(\d+x)$/i.exec(tier ?? "");
137215
+ return match === null ? void 0 : match[1];
137216
+ }
137217
+ function accountPlanLabel(summary) {
137218
+ switch (summary.loginOrganizationType) {
137219
+ case void 0:
137220
+ return planLabelOf(summary.loginRateLimitTier);
137221
+ case "claude_max": {
137222
+ const tier = tierSuffixOf(summary.loginRateLimitTier);
137223
+ return tier === void 0 ? "Max" : `Max ${tier}`;
137224
+ }
137225
+ case "claude_pro":
137226
+ return "Pro";
137227
+ case "claude_team":
137228
+ if (summary.loginSeatTier === "team_standard") {
137229
+ return "Team Standard";
137230
+ }
137231
+ if (summary.loginSeatTier === "team_tier_1") {
137232
+ return "Team Premium";
137233
+ }
137234
+ return "Team";
137235
+ case "claude_enterprise":
137236
+ return "Enterprise";
137237
+ default:
137238
+ return summary.loginOrganizationType;
137239
+ }
137240
+ }
137241
+ function planLabelOf(tier) {
137242
+ if (tier === void 0 || tier === "") {
137243
+ return void 0;
137244
+ }
137245
+ const cleaned = tier.startsWith("default_") ? tier.slice("default_".length) : tier;
137246
+ if (cleaned === "free") {
137247
+ return "Free";
137248
+ }
137249
+ const maxWithMultiplier = /^claude_max_(\d+)x$/.exec(cleaned);
137250
+ if (maxWithMultiplier !== null) {
137251
+ return `Max ${maxWithMultiplier[1] ?? ""}x`;
137252
+ }
137253
+ if (cleaned === "claude_max") {
137254
+ return "Max";
137255
+ }
137256
+ if (cleaned === "claude_pro") {
137257
+ return "Pro";
137258
+ }
137259
+ return cleaned;
137260
+ }
137261
+ function accountSegment({ summary }) {
137262
+ const loginPlan = summary.provider === void 0 ? summary.loginPlan ?? accountPlanLabel(summary) : void 0;
137263
+ const loginOrgName = summary.loginOrganizationType === "claude_team" || summary.loginOrganizationType === "claude_enterprise" ? summary.loginOrganizationName : void 0;
137264
+ const loginParts = [summary.loginAccountEmail, loginOrgName, loginPlan].filter((part) => part !== void 0);
137265
+ if (summary.loginAccountEmail !== void 0 && summary.loginAccountEmail !== summary.providerAccountEmail) {
137266
+ return loginParts.join(" \xB7 ");
137267
+ }
137268
+ return summary.provider === void 0 && loginParts.length > 0 ? loginParts.join(" \xB7 ") : void 0;
137269
+ }
137270
+
137271
+ // src/statusline/palette.ts
137272
+ init_statusline();
137273
+ var RESET = `${ESCAPE}[0m`;
137274
+ var SGR_BY_NAME = {
137275
+ default: "",
137276
+ dim: "2",
137277
+ black: "30",
137278
+ red: "31",
137279
+ green: "32",
137280
+ yellow: "33",
137281
+ blue: "34",
137282
+ magenta: "35",
137283
+ cyan: "36",
137284
+ white: "37",
137285
+ brightBlack: "90",
137286
+ brightRed: "91",
137287
+ brightGreen: "92",
137288
+ brightYellow: "93",
137289
+ brightBlue: "94",
137290
+ brightMagenta: "95",
137291
+ brightCyan: "96",
137292
+ brightWhite: "97"
137293
+ };
137294
+ function isColourName(value2) {
137295
+ return STATUSLINE_COLOUR_NAMES.some((name) => name === value2);
137296
+ }
137297
+ var CHANNELS = 3;
137298
+ var CHANNEL_DIGITS = 2;
137299
+ var HEX_RADIX2 = 16;
137300
+ function sgrOf(value2) {
137301
+ if (typeof value2 === "number") {
137302
+ return `38;5;${String(value2)}`;
137303
+ }
137304
+ if (value2.startsWith("#")) {
137305
+ const channels = Array.from({ length: CHANNELS }, (_, index) => Number.parseInt(value2.slice(1 + index * CHANNEL_DIGITS, 1 + (index + 1) * CHANNEL_DIGITS), HEX_RADIX2));
137306
+ return `38;2;${channels.join(";")}`;
137307
+ }
137308
+ return isColourName(value2) ? SGR_BY_NAME[value2] : "";
137309
+ }
137310
+ function colourEnabled(env) {
137311
+ return env.NO_COLOR === void 0;
137312
+ }
137313
+ function createPalette(colours, enabled) {
137314
+ const ansi = (role) => {
137315
+ const sgr = enabled ? sgrOf(colours[role]) : "";
137316
+ return sgr === "" ? "" : `${ESCAPE}[${sgr}m`;
137317
+ };
137318
+ return {
137319
+ ansi,
137320
+ paint: (role, text3) => {
137321
+ const start = ansi(role);
137322
+ return start === "" ? text3 : `${start}${text3}${RESET}`;
137323
+ }
137324
+ };
137325
+ }
137326
+
137327
+ // src/statusline/style.ts
136957
137328
  var SECONDS_PER_MINUTE2 = 60;
136958
137329
  var MINUTES_PER_HOUR4 = 60;
136959
137330
  var SECONDS_PER_DAY = 86400;
@@ -136961,34 +137332,26 @@ var THOUSAND = 1e3;
136961
137332
  var MILLION = 1e6;
136962
137333
  var TEN = 10;
136963
137334
  var TWENTY = 20;
136964
- var RESERVED_COLUMNS = 4;
136965
- var SEPARATOR2 = " | ";
136966
137335
  var FULL_PERCENT3 = 100;
136967
137336
  var ONE_PERCENT = 1;
136968
- var RESET = `${ESCAPE}[0m`;
136969
- var DIM = `${ESCAPE}[90m`;
136970
- var GREEN = `${ESCAPE}[32m`;
136971
- var YELLOW = `${ESCAPE}[33m`;
136972
- var RED = `${ESCAPE}[31m`;
136973
- function colorize() {
136974
- return process.env.NO_COLOR === void 0;
136975
- }
136976
- function statusColor(fraction, isUsedMetric, bands) {
136977
- if (!colorize()) {
136978
- return "";
136979
- }
136980
- const yellowAt = bands.warnAt / FULL_PERCENT3;
136981
- const redAt = bands.criticalAt / FULL_PERCENT3;
137337
+ function withColor(color, text3) {
137338
+ return color === "" ? text3 : `${color}${text3}${RESET}`;
137339
+ }
137340
+ function statusColor(fraction, isUsedMetric, style) {
137341
+ const yellowAt = style.bands.warnAt / FULL_PERCENT3;
137342
+ const redAt = style.bands.criticalAt / FULL_PERCENT3;
137343
+ const warningRole = style.okRole === "usage" ? "usageWarning" : "warning";
137344
+ const { ansi } = style.palette;
136982
137345
  if (isUsedMetric) {
136983
137346
  if (fraction >= redAt) {
136984
- return RED;
137347
+ return ansi("critical");
136985
137348
  }
136986
- return fraction >= yellowAt ? YELLOW : GREEN;
137349
+ return fraction >= yellowAt ? ansi(warningRole) : ansi(style.okRole);
136987
137350
  }
136988
137351
  if (fraction <= 1 - redAt) {
136989
- return RED;
137352
+ return ansi("critical");
136990
137353
  }
136991
- return fraction <= 1 - yellowAt ? YELLOW : GREEN;
137354
+ return fraction <= 1 - yellowAt ? ansi(warningRole) : ansi(style.okRole);
136992
137355
  }
136993
137356
  function formatTokens(num) {
136994
137357
  if (num >= MILLION) {
@@ -137016,6 +137379,29 @@ function formatDuration(seconds) {
137016
137379
  }
137017
137380
  return `${String(minutes)}m`;
137018
137381
  }
137382
+ function secondsUntil(resetAt, nowMs) {
137383
+ if (resetAt === void 0) {
137384
+ return void 0;
137385
+ }
137386
+ const resetMs = Date.parse(resetAt);
137387
+ return Number.isNaN(resetMs) ? void 0 : Math.max(0, Math.round((resetMs - nowMs) / THOUSAND));
137388
+ }
137389
+ function drawBar(fraction, cells, style) {
137390
+ const clamped = Math.max(0, Math.min(1, fraction));
137391
+ const filled = Math.round(clamped * cells);
137392
+ const color = statusColor(clamped, true, style);
137393
+ const emptyColor = style.palette.ansi("empty");
137394
+ const body = `${style.filled.repeat(filled)}${style.empty.repeat(cells - filled)}`;
137395
+ if (color === "" && emptyColor === "") {
137396
+ return `[${body}]`;
137397
+ }
137398
+ return `[${color}${style.filled.repeat(filled)}${emptyColor}${style.empty.repeat(cells - filled)}${RESET}]`;
137399
+ }
137400
+ function barCell(prefix, suffix, fraction, style) {
137401
+ return { prefix, suffix, draw: (cells) => drawBar(fraction, cells, style) };
137402
+ }
137403
+
137404
+ // src/statusline/elements/header/headroom.ts
137019
137405
  function headroomText(stats) {
137020
137406
  if (stats === void 0) {
137021
137407
  return void 0;
@@ -137028,91 +137414,129 @@ function headroomText(stats) {
137028
137414
  ].filter((part) => part !== void 0);
137029
137415
  return parts.length === 0 ? void 0 : `headroom ${parts.join(" \xB7 ")}`;
137030
137416
  }
137031
- function cacheHitText(hitFraction, bands) {
137417
+ function headroomSegment({ summary }) {
137418
+ return headroomText(summary.headroom);
137419
+ }
137420
+
137421
+ // src/statusline/elements/header/identity.ts
137422
+ function identitySegment({ summary }) {
137423
+ if (summary.identity !== void 0 && summary.provider !== void 0 && summary.identity !== summary.providerAccountEmail && summary.identity !== summary.loginAccountEmail) {
137424
+ return summary.identity;
137425
+ }
137426
+ return void 0;
137427
+ }
137428
+
137429
+ // src/statusline/elements/header/model.ts
137430
+ function choiceNamesProvider(summary) {
137431
+ return summary.modelChoice !== void 0 && (summary.modelChoice.providers.length > 1 || summary.routedTarget !== void 0);
137432
+ }
137433
+ function modelSegment({ summary, view }) {
137434
+ const namesProvider = choiceNamesProvider(summary);
137435
+ const segment = summary.modelChoice !== void 0 && view.modelDisplayName !== void 0 && view.modelDisplayName !== "" ? `${view.modelDisplayName} -> ${namesProvider ? `${summary.modelChoice.provider}/${summary.modelChoice.served}` : summary.modelChoice.served}` : view.modelDisplayName;
137436
+ return segment !== void 0 && segment !== "" ? segment : void 0;
137437
+ }
137438
+
137439
+ // src/statusline/elements/header/provider.ts
137440
+ function providerSegment({ summary }) {
137441
+ if (summary.provider === void 0) {
137442
+ return void 0;
137443
+ }
137444
+ const account = [summary.providerAccountEmail, summary.providerPlan].filter((part) => part !== void 0);
137445
+ return account.length > 0 ? `${summary.provider} \xB7 ${account.join(" \xB7 ")}` : summary.provider;
137446
+ }
137447
+
137448
+ // src/statusline/elements/header/route.ts
137449
+ function routeSegment({ summary }) {
137450
+ return summary.routedTarget !== void 0 && !choiceNamesProvider(summary) ? `via ${summary.routedTarget}` : void 0;
137451
+ }
137452
+
137453
+ // src/statusline/elements/context.ts
137454
+ function barStyleOf({ settings: settings2, palette }, okRole) {
137455
+ return { bands: settings2.bands, palette, okRole, filled: settings2.bar.filled, empty: settings2.bar.empty };
137456
+ }
137457
+
137458
+ // src/statusline/elements/rows/context.ts
137459
+ function cacheHitText(hitFraction, style) {
137032
137460
  const clamped = Math.max(0, Math.min(1, hitFraction));
137033
- return ` (Cache: ${statusColor(clamped, false, bands)}${(clamped * FULL_PERCENT3).toFixed(0)}%${RESET})`;
137461
+ return ` (Cache: ${withColor(statusColor(clamped, false, style), `${(clamped * FULL_PERCENT3).toFixed(0)}%`)})`;
137034
137462
  }
137035
- function cacheShareText(view, bands) {
137463
+ function cacheShareText(view, style) {
137036
137464
  const hitRatio = view.cacheHitRatio;
137037
137465
  if (hitRatio !== void 0 && Number.isFinite(hitRatio)) {
137038
- return cacheHitText(hitRatio, bands);
137466
+ return cacheHitText(hitRatio, style);
137039
137467
  }
137040
137468
  const promptTotal = (view.cacheReadTokens ?? 0) + (view.freshInputTokens ?? 0);
137041
137469
  if (promptTotal > 0 && (view.cacheReadTokens ?? 0) > 0) {
137042
- return cacheHitText((view.cacheReadTokens ?? 0) / promptTotal, bands);
137470
+ return cacheHitText((view.cacheReadTokens ?? 0) / promptTotal, style);
137043
137471
  }
137044
137472
  return "";
137045
137473
  }
137046
- function tierSuffixOf(tier) {
137047
- const match = /_(\d+x)$/i.exec(tier ?? "");
137048
- return match === null ? void 0 : match[1];
137474
+ function contextRow(context) {
137475
+ const { view, palette } = context;
137476
+ const style = barStyleOf(context, "context");
137477
+ const cells = [];
137478
+ if (view.contextUsedPercentage !== void 0) {
137479
+ const fraction = Math.max(0, Math.min(1, view.contextUsedPercentage / FULL_PERCENT3));
137480
+ const color = statusColor(fraction, true, style);
137481
+ const percent2 = withColor(color, `${view.contextUsedPercentage.toFixed(1)}%`);
137482
+ const tokens = view.contextTotalTokens !== void 0 && view.contextWindowTokens !== void 0 ? `${formatTokens(view.contextTotalTokens)}/${formatTokens(view.contextWindowTokens)} ` : "";
137483
+ const cache = cacheShareText(view, style);
137484
+ cells.push(barCell(palette.paint("label", `Ctx ${tokens}`), ` ${percent2}${cache}`, fraction, style));
137485
+ }
137486
+ return { kind: "bars", cells };
137049
137487
  }
137050
- function accountPlanLabel(summary) {
137051
- switch (summary.loginOrganizationType) {
137052
- case void 0:
137053
- return planLabelOf(summary.loginRateLimitTier);
137054
- case "claude_max": {
137055
- const tier = tierSuffixOf(summary.loginRateLimitTier);
137056
- return tier === void 0 ? "Max" : `Max ${tier}`;
137488
+
137489
+ // src/statusline/elements/rows/quota.ts
137490
+ function quotaRow(context) {
137491
+ const { summary, nowMs, settings: settings2, palette } = context;
137492
+ const style = barStyleOf(context, "usage");
137493
+ const cells = [];
137494
+ const drawWindow = (label, fraction, resetsAt) => {
137495
+ const clamped = Math.max(0, Math.min(1, fraction));
137496
+ const color = statusColor(clamped, true, style);
137497
+ cells.push(barCell(palette.paint("label", `${label} `), ` ${withColor(color, `${(fraction * FULL_PERCENT3).toFixed(1)}%`)} (${formatDuration(secondsUntil(resetsAt, nowMs))})`, clamped, style));
137498
+ };
137499
+ if (summary.quotaFamilies.length > 0) {
137500
+ for (const window of summary.quotaFamilies) {
137501
+ drawWindow(window.measures, window.utilization, window.resetsAt);
137057
137502
  }
137058
- case "claude_pro":
137059
- return "Pro";
137060
- case "claude_team":
137061
- if (summary.loginSeatTier === "team_standard") {
137062
- return "Team Standard";
137063
- }
137064
- if (summary.loginSeatTier === "team_tier_1") {
137065
- return "Team Premium";
137503
+ } else {
137504
+ if (summary.fiveHourUsed !== void 0) {
137505
+ drawWindow(settings2.labels.fiveHour, summary.fiveHourUsed / FULL_PERCENT3, summary.fiveHourResetAt);
137506
+ }
137507
+ if (summary.sevenDayUsed !== void 0) {
137508
+ drawWindow(settings2.labels.sevenDay, summary.sevenDayUsed / FULL_PERCENT3, summary.sevenDayResetAt);
137509
+ }
137510
+ if (summary.fiveHourUsed === void 0 && summary.sevenDayUsed === void 0) {
137511
+ for (const window of summary.providerQuotaWindows) {
137512
+ drawWindow(window.measures, window.utilization, window.resetsAt);
137066
137513
  }
137067
- return "Team";
137068
- case "claude_enterprise":
137069
- return "Enterprise";
137070
- default:
137071
- return summary.loginOrganizationType;
137072
- }
137073
- }
137074
- function planLabelOf(tier) {
137075
- if (tier === void 0 || tier === "") {
137076
- return void 0;
137077
- }
137078
- const cleaned = tier.startsWith("default_") ? tier.slice("default_".length) : tier;
137079
- if (cleaned === "free") {
137080
- return "Free";
137081
- }
137082
- const maxWithMultiplier = /^claude_max_(\d+)x$/.exec(cleaned);
137083
- if (maxWithMultiplier !== null) {
137084
- return `Max ${maxWithMultiplier[1] ?? ""}x`;
137085
- }
137086
- if (cleaned === "claude_max") {
137087
- return "Max";
137088
- }
137089
- if (cleaned === "claude_pro") {
137090
- return "Pro";
137091
- }
137092
- return cleaned;
137093
- }
137094
- function secondsUntil(resetAt, nowMs) {
137095
- if (resetAt === void 0) {
137096
- return void 0;
137514
+ }
137097
137515
  }
137098
- const resetMs = Date.parse(resetAt);
137099
- return Number.isNaN(resetMs) ? void 0 : Math.max(0, Math.round((resetMs - nowMs) / THOUSAND));
137100
- }
137101
- function drawBar(fraction, cells, bands) {
137102
- const clamped = Math.max(0, Math.min(1, fraction));
137103
- const filled = Math.round(clamped * cells);
137104
- const color = statusColor(clamped, true, bands);
137105
- return color === "" ? `[${"\u2588".repeat(filled)}${"\u2591".repeat(cells - filled)}]` : `[${color}${"\u2588".repeat(filled)}${DIM}${"\u2591".repeat(cells - filled)}${RESET}]`;
137106
- }
137107
- function barCell(prefix, suffix, fraction, bands) {
137108
- return { prefix, suffix, draw: (cells) => drawBar(fraction, cells, bands) };
137516
+ return { kind: "bars", cells };
137109
137517
  }
137518
+
137519
+ // src/statusline/elements/registry.ts
137520
+ var HEADER_ROLES = {
137521
+ model: "model",
137522
+ provider: "model",
137523
+ route: "label",
137524
+ account: "label",
137525
+ identity: "label",
137526
+ headroom: "label"
137527
+ };
137528
+ var ELEMENTS = {
137529
+ header: { model: modelSegment, provider: providerSegment, route: routeSegment, account: accountSegment, identity: identitySegment, headroom: headroomSegment },
137530
+ rows: { context: contextRow, quota: quotaRow }
137531
+ };
137532
+
137533
+ // src/statusline/headerLayout.ts
137110
137534
  function justify(texts, maxWidth, separator) {
137111
137535
  if (texts.length < 2) {
137112
137536
  return texts.join(separator);
137113
137537
  }
137114
137538
  const separatorLength = visibleLength(separator);
137115
- const total = texts.reduce((sum, text2) => sum + visibleLength(text2), 0) + separatorLength * (texts.length - 1);
137539
+ const total = texts.reduce((sum, text3) => sum + visibleLength(text3), 0) + separatorLength * (texts.length - 1);
137116
137540
  const spare = maxWidth - total;
137117
137541
  if (spare <= 0) {
137118
137542
  return texts.join(separator);
@@ -137121,7 +137545,7 @@ function justify(texts, maxWidth, separator) {
137121
137545
  const extraPerGap = Math.floor(spare / gaps);
137122
137546
  let remainder = spare % gaps;
137123
137547
  const parts = [];
137124
- texts.forEach((text2, index) => {
137548
+ texts.forEach((text3, index) => {
137125
137549
  if (index > 0) {
137126
137550
  const extra = extraPerGap + (remainder > 0 ? 1 : 0);
137127
137551
  if (remainder > 0) {
@@ -137130,7 +137554,7 @@ function justify(texts, maxWidth, separator) {
137130
137554
  const left = Math.floor(extra / 2);
137131
137555
  parts.push(`${" ".repeat(left + 1)}|${" ".repeat(extra - left + 1)}`);
137132
137556
  }
137133
- parts.push(text2);
137557
+ parts.push(text3);
137134
137558
  });
137135
137559
  return parts.join("");
137136
137560
  }
@@ -137139,15 +137563,15 @@ function layoutHeader(texts, maxWidth, separator) {
137139
137563
  const lines = [];
137140
137564
  let current = [];
137141
137565
  let currentWidth = 0;
137142
- for (const text2 of texts) {
137143
- const width = visibleLength(text2);
137566
+ for (const text3 of texts) {
137567
+ const width = visibleLength(text3);
137144
137568
  const added = current.length === 0 ? width : width + separatorLength;
137145
137569
  if (current.length > 0 && currentWidth + added > maxWidth) {
137146
137570
  lines.push(current);
137147
- current = [text2];
137571
+ current = [text3];
137148
137572
  currentWidth = width;
137149
137573
  } else {
137150
- current.push(text2);
137574
+ current.push(text3);
137151
137575
  currentWidth += added;
137152
137576
  }
137153
137577
  }
@@ -137156,80 +137580,50 @@ function layoutHeader(texts, maxWidth, separator) {
137156
137580
  }
137157
137581
  return lines.map((line) => justify(line, maxWidth, separator)).join("\n");
137158
137582
  }
137159
- function renderStatuslineBlock(summary, view, terminalWidth, nowMs, settings2 = STATUSLINE_DEFAULTS) {
137160
- const segments = {};
137161
- const choiceNamesProvider = summary.modelChoice !== void 0 && (summary.modelChoice.providers.length > 1 || summary.routedTarget !== void 0);
137162
- const modelSegment = summary.modelChoice !== void 0 && view.modelDisplayName !== void 0 && view.modelDisplayName !== "" ? `${view.modelDisplayName} -> ${choiceNamesProvider ? `${summary.modelChoice.provider}/${summary.modelChoice.served}` : summary.modelChoice.served}` : view.modelDisplayName;
137163
- if (modelSegment !== void 0 && modelSegment !== "") {
137164
- segments.model = modelSegment;
137165
- }
137166
- if (summary.provider !== void 0) {
137167
- const account = [summary.providerAccountEmail, summary.providerPlan].filter((part) => part !== void 0);
137168
- segments.provider = account.length > 0 ? `${summary.provider} \xB7 ${account.join(" \xB7 ")}` : summary.provider;
137169
- }
137170
- if (summary.routedTarget !== void 0 && !choiceNamesProvider) {
137171
- segments.route = `via ${summary.routedTarget}`;
137172
- }
137173
- const loginPlan = summary.provider === void 0 ? summary.loginPlan ?? accountPlanLabel(summary) : void 0;
137174
- const loginOrgName = summary.loginOrganizationType === "claude_team" || summary.loginOrganizationType === "claude_enterprise" ? summary.loginOrganizationName : void 0;
137175
- const loginParts = [summary.loginAccountEmail, loginOrgName, loginPlan].filter((part) => part !== void 0);
137176
- if (summary.loginAccountEmail !== void 0 && summary.loginAccountEmail !== summary.providerAccountEmail) {
137177
- segments.account = loginParts.join(" \xB7 ");
137178
- } else if (summary.provider === void 0 && loginParts.length > 0) {
137179
- segments.account = loginParts.join(" \xB7 ");
137180
- }
137181
- if (summary.identity !== void 0 && summary.provider !== void 0 && summary.identity !== summary.providerAccountEmail && summary.identity !== summary.loginAccountEmail) {
137182
- segments.identity = summary.identity;
137183
- }
137184
- const savings = headroomText(summary.headroom);
137185
- if (savings !== void 0) {
137186
- segments.headroom = savings;
137187
- }
137188
- const header = settings2.header.flatMap((name) => segments[name] ?? []);
137189
- const bands = { warnAt: settings2.warnAt, criticalAt: settings2.criticalAt };
137190
- const contextGroup = [];
137191
- if (view.contextUsedPercentage !== void 0) {
137192
- const fraction = Math.max(0, Math.min(1, view.contextUsedPercentage / FULL_PERCENT3));
137193
- const color = statusColor(fraction, true, bands);
137194
- const percent2 = `${color}${view.contextUsedPercentage.toFixed(1)}%${RESET}`;
137195
- const tokens = view.contextTotalTokens !== void 0 && view.contextWindowTokens !== void 0 ? `${formatTokens(view.contextTotalTokens)}/${formatTokens(view.contextWindowTokens)} ` : "";
137196
- const cache = cacheShareText(view, bands);
137197
- contextGroup.push(barCell(`Ctx ${tokens}`, ` ${percent2}${cache}`, fraction, bands));
137198
- }
137199
- const quotaGroup = [];
137200
- const drawWindow = (label, fraction, resetsAt) => {
137201
- const clamped = Math.max(0, Math.min(1, fraction));
137202
- const color = statusColor(clamped, true, bands);
137203
- quotaGroup.push(barCell(`${label} `, ` ${color}${(fraction * FULL_PERCENT3).toFixed(1)}%${RESET} (${formatDuration(secondsUntil(resetsAt, nowMs))})`, clamped, bands));
137583
+
137584
+ // src/statusline/render.ts
137585
+ var RESERVED_COLUMNS = 4;
137586
+ var SEPARATOR2 = " | ";
137587
+ function renderStatuslineBlock(input2) {
137588
+ const { terminalWidth, settings: settings2 = STATUSLINE_DEFAULTS, elements = ELEMENTS } = input2;
137589
+ const context = {
137590
+ summary: input2.summary,
137591
+ view: input2.view,
137592
+ payload: input2.payload,
137593
+ nowMs: input2.nowMs,
137594
+ settings: settings2,
137595
+ palette: createPalette(settings2.colours, colourEnabled(input2.ports.env)),
137596
+ ports: input2.ports
137204
137597
  };
137205
- if (summary.quotaFamilies.length > 0) {
137206
- for (const window of summary.quotaFamilies) {
137207
- drawWindow(window.measures, window.utilization, window.resetsAt);
137208
- }
137209
- } else {
137210
- if (summary.fiveHourUsed !== void 0) {
137211
- drawWindow(settings2.fiveHourLabel, summary.fiveHourUsed / FULL_PERCENT3, summary.fiveHourResetAt);
137212
- }
137213
- if (summary.sevenDayUsed !== void 0) {
137214
- drawWindow(settings2.sevenDayLabel, summary.sevenDayUsed / FULL_PERCENT3, summary.sevenDayResetAt);
137215
- }
137216
- if (summary.fiveHourUsed === void 0 && summary.sevenDayUsed === void 0) {
137217
- for (const window of summary.providerQuotaWindows) {
137218
- drawWindow(window.measures, window.utilization, window.resetsAt);
137219
- }
137220
- }
137221
- }
137598
+ const header = settings2.layout.header.flatMap((name) => {
137599
+ const text3 = elements.header[name](context);
137600
+ return text3 === void 0 ? [] : context.palette.paint(HEADER_ROLES[name], text3);
137601
+ });
137222
137602
  const width = Math.max(TWENTY, terminalWidth - RESERVED_COLUMNS);
137223
137603
  const lines = [];
137224
137604
  if (header.length > 0) {
137225
137605
  lines.push(layoutHeader(header, width, SEPARATOR2));
137226
137606
  }
137227
- const groups = { context: contextGroup, quota: quotaGroup };
137228
- lines.push(...layoutBarGrid(settings2.bars.map((name) => groups[name]), width, SEPARATOR2, settings2.barWidth));
137607
+ let barGroups = [];
137608
+ const flushBars = () => {
137609
+ lines.push(...layoutBarGrid(barGroups, width, SEPARATOR2, settings2.bar.width));
137610
+ barGroups = [];
137611
+ };
137612
+ for (const name of settings2.layout.rows) {
137613
+ const output2 = elements.rows[name](context);
137614
+ if (output2.kind === "bars") {
137615
+ barGroups.push(output2.cells);
137616
+ } else {
137617
+ flushBars();
137618
+ lines.push(...output2.lines);
137619
+ }
137620
+ }
137621
+ flushBars();
137229
137622
  return lines.join("\n");
137230
137623
  }
137231
137624
 
137232
137625
  // src/statusline/commands.ts
137626
+ init_keys();
137233
137627
  init_settings2();
137234
137628
 
137235
137629
  // src/statusline/width.ts
@@ -137243,30 +137637,6 @@ function terminalWidthOf(payload, env) {
137243
137637
  }
137244
137638
 
137245
137639
  // src/statusline/commands.ts
137246
- function payloadViewOf(payload) {
137247
- const empty = { modelDisplayName: void 0, contextUsedPercentage: void 0, contextTotalTokens: void 0, contextWindowTokens: void 0, cacheHitRatio: void 0, cacheReadTokens: void 0, freshInputTokens: void 0 };
137248
- if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
137249
- return empty;
137250
- }
137251
- const record2 = {};
137252
- for (const [key, value2] of Object.entries(payload)) {
137253
- record2[key] = value2;
137254
- }
137255
- const model = record2.model;
137256
- const displayName = typeof model === "object" && model !== null && !Array.isArray(model) && "display_name" in model && typeof model.display_name === "string" ? model.display_name : void 0;
137257
- const context = record2.context_window;
137258
- const ctx = typeof context === "object" && context !== null && !Array.isArray(context) ? context : void 0;
137259
- const used = ctx !== void 0 && "used_percentage" in ctx && typeof ctx.used_percentage === "number" ? ctx.used_percentage : void 0;
137260
- const totalIn = ctx !== void 0 && "total_input_tokens" in ctx && typeof ctx.total_input_tokens === "number" ? ctx.total_input_tokens : void 0;
137261
- const size = ctx !== void 0 && "context_window_size" in ctx && typeof ctx.context_window_size === "number" ? ctx.context_window_size : void 0;
137262
- const current = ctx !== void 0 && "current_usage" in ctx && typeof ctx.current_usage === "object" && ctx.current_usage !== null && !Array.isArray(ctx.current_usage) ? ctx.current_usage : void 0;
137263
- const cacheRead = current !== void 0 && "cache_read_input_tokens" in current && typeof current.cache_read_input_tokens === "number" ? current.cache_read_input_tokens : void 0;
137264
- const fresh = current !== void 0 && "input_tokens" in current && typeof current.input_tokens === "number" ? current.input_tokens : void 0;
137265
- const promptCache = record2.prompt_cache;
137266
- const cache = typeof promptCache === "object" && promptCache !== null && !Array.isArray(promptCache) ? promptCache : void 0;
137267
- const hitRatio = cache !== void 0 && "hit_ratio" in cache && typeof cache.hit_ratio === "number" ? cache.hit_ratio : void 0;
137268
- return { modelDisplayName: displayName, contextUsedPercentage: used, contextTotalTokens: totalIn, contextWindowTokens: size, cacheHitRatio: hitRatio, cacheReadTokens: cacheRead, freshInputTokens: fresh };
137269
- }
137270
137640
  async function readAllStdin() {
137271
137641
  return await new Promise((resolve2) => {
137272
137642
  const chunks = [];
@@ -137281,8 +137651,9 @@ async function readAllStdin() {
137281
137651
  }
137282
137652
  var ROUTED_TARGET_LOOKBACK_MS = 36e5;
137283
137653
  function registerStatuslineCommand(program2, deps) {
137654
+ const statusline = program2.command("statusline");
137284
137655
  withExamples(
137285
- program2.command("statusline").description("Serve as a statusline entrypoint: read the client's stdin payload, add the identity's live provider, account and usage windows under an agent_shim key, then run the renderer named in AGENT_SHIM_STATUSLINE_CMD or print the built-in line.").action(async () => {
137656
+ statusline.description("Serve as a statusline entrypoint: read the client's stdin payload, add the identity's live provider, account and usage windows under an agent_shim key, then run the renderer named in AGENT_SHIM_STATUSLINE_CMD or print the built-in line.").action(async () => {
137286
137657
  const stdin2 = await readAllStdin();
137287
137658
  let payload;
137288
137659
  try {
@@ -137307,7 +137678,7 @@ function registerStatuslineCommand(program2, deps) {
137307
137678
  } else {
137308
137679
  const configDir = process.env.CLAUDE_CONFIG_DIR;
137309
137680
  try {
137310
- account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ? import_node_path56.default.join(import_node_os12.default.homedir(), ".claude.json") : import_node_path56.default.join(configDir, ".claude.json"));
137681
+ account = readAccountMetadataFile(realFarmFs, configDir === void 0 || configDir === "" ? import_node_path56.default.join(import_node_os13.default.homedir(), ".claude.json") : import_node_path56.default.join(configDir, ".claude.json"));
137311
137682
  } catch {
137312
137683
  account = void 0;
137313
137684
  }
@@ -137347,7 +137718,7 @@ function registerStatuslineCommand(program2, deps) {
137347
137718
  const { payload: enriched, summary } = enrichStatuslinePayload({ payload, env: process.env, snapshot, account, providerName, nowMs, headroom, routedTarget, ...modelChoice === void 0 ? {} : { modelChoice } });
137348
137719
  const renderer = process.env.AGENT_SHIM_STATUSLINE_CMD;
137349
137720
  if (renderer !== void 0 && renderer !== "") {
137350
- const child = (0, import_node_child_process7.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
137721
+ const child = (0, import_node_child_process8.spawn)("/bin/sh", ["-c", renderer], { stdio: ["pipe", "inherit", "inherit"] });
137351
137722
  child.stdin.end(`${JSON.stringify(enriched)}
137352
137723
  `);
137353
137724
  child.on("close", (code) => {
@@ -137358,18 +137729,32 @@ function registerStatuslineCommand(program2, deps) {
137358
137729
  let stackedUnderDefault = false;
137359
137730
  if (isAntigravityPayload(payload)) {
137360
137731
  try {
137361
- stackedUnderDefault = antigravityStacksWithDefault(realFarmFs, import_node_os12.default.homedir());
137732
+ stackedUnderDefault = antigravityStacksWithDefault(realFarmFs, import_node_os13.default.homedir());
137362
137733
  } catch {
137363
137734
  stackedUnderDefault = false;
137364
137735
  }
137365
137736
  }
137366
- const view = { ...payloadViewOf(payload), ...stackedUnderDefault ? { modelDisplayName: void 0 } : {} };
137737
+ const clientPayload = parseClientPayload(payload);
137738
+ const view = { ...viewOf(clientPayload), ...stackedUnderDefault ? { modelDisplayName: void 0 } : {} };
137367
137739
  const rawSettings = process.env[STATUSLINE_ENV];
137368
137740
  const settings2 = resolveStatusline(rawSettings === void 0 || rawSettings === "" ? void 0 : statuslineSettingsFromEnv(rawSettings, STATUSLINE_ENV));
137369
- console.log(renderStatuslineBlock(summary, view, terminalWidthOf(payload, process.env), nowMs, settings2));
137741
+ console.log(renderStatuslineBlock({ summary, view, payload: clientPayload, terminalWidth: terminalWidthOf(payload, process.env), nowMs, settings: settings2, ports: realStatuslinePorts(process.env) }));
137370
137742
  }),
137371
137743
  ["$ agent-shim statusline # a client's statusline setting names this; it renders or delegates"]
137372
137744
  );
137745
+ registerStatuslineKeys(statusline);
137746
+ }
137747
+ function registerStatuslineKeys(statusline) {
137748
+ withExamples(
137749
+ statusline.command("keys").description("List every setting of the built-in statusline with its kind, its default and what it does.").option("--json", "Print the settings as JSON."),
137750
+ ["agent-shim statusline keys", "agent-shim statusline keys --json"]
137751
+ ).action((options) => {
137752
+ if (options.json === true) {
137753
+ printJson(statuslineKeys());
137754
+ return;
137755
+ }
137756
+ console.log(formatStatuslineKeys(statuslineKeys()));
137757
+ });
137373
137758
  }
137374
137759
 
137375
137760
  // node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.0_supports-color@7.2.0_zod@4.6.5/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
@@ -145437,7 +145822,7 @@ var Protocol = class {
145437
145822
  };
145438
145823
  }
145439
145824
  };
145440
- function isPlainObject3(value2) {
145825
+ function isPlainObject4(value2) {
145441
145826
  return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
145442
145827
  }
145443
145828
  function mergeCapabilities(base, additional) {
@@ -145448,7 +145833,7 @@ function mergeCapabilities(base, additional) {
145448
145833
  if (addValue === void 0)
145449
145834
  continue;
145450
145835
  const baseValue = result[k10];
145451
- if (isPlainObject3(baseValue) && isPlainObject3(addValue)) {
145836
+ if (isPlainObject4(baseValue) && isPlainObject4(addValue)) {
145452
145837
  result[k10] = { ...baseValue, ...addValue };
145453
145838
  } else {
145454
145839
  result[k10] = addValue;
@@ -147119,7 +147504,7 @@ async function serveMcp(mcp, transport, options = {}) {
147119
147504
  }
147120
147505
 
147121
147506
  // src/mcp/permissions.ts
147122
- var import_node_fs22 = __toESM(require("node:fs"), 1);
147507
+ var import_node_fs23 = __toESM(require("node:fs"), 1);
147123
147508
  var import_node_path57 = __toESM(require("node:path"), 1);
147124
147509
  init_zod();
147125
147510
  init_store();
@@ -147136,15 +147521,15 @@ function readStoredMcpPermissions(paths) {
147136
147521
  }
147137
147522
  function writeStoredMcpPermissions(paths, permissions) {
147138
147523
  writeJsonAtomic(paths.mcpPermissionsFile, { writes: permissions.writes, remoteControl: permissions.remoteControl, history: permissions.history });
147139
- import_node_fs22.default.chmodSync(paths.mcpPermissionsFile, OWNER_ONLY_MODE);
147524
+ import_node_fs23.default.chmodSync(paths.mcpPermissionsFile, OWNER_ONLY_MODE);
147140
147525
  }
147141
147526
  function effectiveMcpPermissions(flags, stored) {
147142
147527
  return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl, history: flags.history || stored.history };
147143
147528
  }
147144
147529
  function watchMcpPermissions(paths, onChange) {
147145
147530
  const directory = import_node_path57.default.dirname(paths.mcpPermissionsFile);
147146
- import_node_fs22.default.mkdirSync(directory, { recursive: true });
147147
- const watcher = import_node_fs22.default.watch(directory, (_event, filename) => {
147531
+ import_node_fs23.default.mkdirSync(directory, { recursive: true });
147532
+ const watcher = import_node_fs23.default.watch(directory, (_event, filename) => {
147148
147533
  if (filename === null || filename === import_node_path57.default.basename(paths.mcpPermissionsFile)) {
147149
147534
  onChange();
147150
147535
  }
@@ -147310,9 +147695,9 @@ init_cliError();
147310
147695
  init_argv();
147311
147696
  init_legacy();
147312
147697
  var COMPLETION_SHELLS = ["bash", "zsh", "fish"];
147313
- function firstSentence(text2) {
147314
- const end = text2.search(/\.(\s|$)/);
147315
- return end === -1 ? text2 : text2.slice(0, end);
147698
+ function firstSentence(text3) {
147699
+ const end = text3.search(/\.(\s|$)/);
147700
+ return end === -1 ? text3 : text3.slice(0, end);
147316
147701
  }
147317
147702
  function collectNodes(program2) {
147318
147703
  const help = new Help();
@@ -147333,11 +147718,11 @@ function collectNodes(program2) {
147333
147718
  visit2(program2, "root");
147334
147719
  return nodes;
147335
147720
  }
147336
- function singleQuote(text2) {
147337
- return `'${text2.replaceAll("'", `'\\''`)}'`;
147721
+ function singleQuote(text3) {
147722
+ return `'${text3.replaceAll("'", `'\\''`)}'`;
147338
147723
  }
147339
- function fishQuote(text2) {
147340
- return `'${text2.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
147724
+ function fishQuote(text3) {
147725
+ return `'${text3.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
147341
147726
  }
147342
147727
  function transitionArms(nodes, indent) {
147343
147728
  return nodes.flatMap((node2) => [...node2.children].map(([name, child]) => `${indent}${singleQuote(`${node2.id}:${name}`)}) node=${singleQuote(child)} ;;`)).join("\n");
@@ -147450,7 +147835,7 @@ function registerCompletionCommand(program2) {
147450
147835
  }
147451
147836
 
147452
147837
  // src/credentialCommand.ts
147453
- var import_node_child_process8 = require("node:child_process");
147838
+ var import_node_child_process9 = require("node:child_process");
147454
147839
  init_commandDeps();
147455
147840
  init_cliError();
147456
147841
  init_schema();
@@ -147458,7 +147843,7 @@ init_credential();
147458
147843
  init_credentialCache();
147459
147844
 
147460
147845
  // src/identityToken.ts
147461
- var import_node_fs23 = __toESM(require("node:fs"), 1);
147846
+ var import_node_fs24 = __toESM(require("node:fs"), 1);
147462
147847
  var import_node_path58 = __toESM(require("node:path"), 1);
147463
147848
  init_cliError();
147464
147849
  var TOKEN_FILE_MODE = 384;
@@ -147476,13 +147861,13 @@ function storeIdentityToken(paths, identityName, raw) {
147476
147861
  throw new UsageError("That is not a claude setup-token token (expected it to start with sk-ant-oat). Run `claude setup-token` and pass its token on standard input.");
147477
147862
  }
147478
147863
  const dir = identityTokenDir(paths);
147479
- import_node_fs23.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
147480
- import_node_fs23.default.chmodSync(dir, TOKEN_DIR_MODE);
147864
+ import_node_fs24.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
147865
+ import_node_fs24.default.chmodSync(dir, TOKEN_DIR_MODE);
147481
147866
  const target = identityTokenPath(paths, identityName);
147482
147867
  const temp = import_node_path58.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
147483
- import_node_fs23.default.writeFileSync(temp, `${token}
147868
+ import_node_fs24.default.writeFileSync(temp, `${token}
147484
147869
  `, { mode: TOKEN_FILE_MODE });
147485
- import_node_fs23.default.renameSync(temp, target);
147870
+ import_node_fs24.default.renameSync(temp, target);
147486
147871
  return target;
147487
147872
  }
147488
147873
 
@@ -147511,7 +147896,7 @@ function realCommandPorts(deps) {
147511
147896
  cache: createRealCredentialCache(deps.paths.root),
147512
147897
  platform: process.platform,
147513
147898
  now: () => Date.now(),
147514
- ssh: (host, remoteCommand, input2) => (0, import_node_child_process8.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
147899
+ ssh: (host, remoteCommand, input2) => (0, import_node_child_process9.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
147515
147900
  };
147516
147901
  }
147517
147902
  var REMOTE_ROOT_SCRIPT = 'root="${AGENT_SHIM_HOME:-${CLAUDE_USE_HOME:-}}"; if [ -z "$root" ]; then if [ ! -d "$HOME/.agent-shim" ] && [ -d "$HOME/.claude-use" ]; then root="$HOME/.claude-use"; else root="$HOME/.agent-shim"; fi; fi';
@@ -147648,10 +148033,10 @@ function registerDoctorCommand(program2, deps) {
147648
148033
  }
147649
148034
 
147650
148035
  // src/headroom/commands.ts
147651
- var import_node_fs24 = __toESM(require("node:fs"), 1);
148036
+ var import_node_fs25 = __toESM(require("node:fs"), 1);
147652
148037
  var import_node_http5 = __toESM(require("node:http"), 1);
147653
148038
  var import_node_path59 = __toESM(require("node:path"), 1);
147654
- var import_node_child_process9 = require("node:child_process");
148039
+ var import_node_child_process10 = require("node:child_process");
147655
148040
  init_commandDeps();
147656
148041
  init_configProfilesStore();
147657
148042
  init_realFrontDoorPort();
@@ -147836,7 +148221,7 @@ async function readyOverSocket(socketPath) {
147836
148221
  }
147837
148222
  var HEADROOM_TOOL_NAME = "headroom-ai";
147838
148223
  function readInstalledHeadroomCommit() {
147839
- const toolDir = (0, import_node_child_process9.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
148224
+ const toolDir = (0, import_node_child_process10.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
147840
148225
  if (toolDir.status !== 0) {
147841
148226
  return void 0;
147842
148227
  }
@@ -147873,14 +148258,14 @@ function realSupervisorPorts(paths) {
147873
148258
  readConfig: () => resolveSupervisorConfig(readGlobalConfig(paths)?.headroom ?? {}),
147874
148259
  spawnHeadroom: (socketPath, allowlistFile, settings2) => {
147875
148260
  const trust = resolveHeadroomTrustBundle({ caCertFile: paths.frontdoorCaCertFile, bundlesDir: paths.frontdoorCaBundlesDir, inherited: process.env[HEADROOM_CA_BUNDLE], fs: realTrustBundleFs });
147876
- import_node_fs24.default.mkdirSync(paths.logsDir, { recursive: true });
148261
+ import_node_fs25.default.mkdirSync(paths.logsDir, { recursive: true });
147877
148262
  if (trust?.warning !== void 0) {
147878
- import_node_fs24.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${trust.warning}
148263
+ import_node_fs25.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${trust.warning}
147879
148264
  `);
147880
148265
  }
147881
- const logFd = import_node_fs24.default.openSync(paths.headroomLogPath, "a");
148266
+ const logFd = import_node_fs25.default.openSync(paths.headroomLogPath, "a");
147882
148267
  try {
147883
- const child = (0, import_node_child_process9.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
148268
+ const child = (0, import_node_child_process10.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
147884
148269
  detached: true,
147885
148270
  stdio: ["ignore", logFd, logFd],
147886
148271
  env: headroomSpawnEnv(process.env, settings2, trust?.path)
@@ -147893,12 +148278,12 @@ function realSupervisorPorts(paths) {
147893
148278
  child.once("exit", (code, signal) => {
147894
148279
  ownedHeadroom.delete(pid);
147895
148280
  exitedHeadroom.add(pid);
147896
- import_node_fs24.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: headroom exited (${signal ?? `code ${String(code)}`})
148281
+ import_node_fs25.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: headroom exited (${signal ?? `code ${String(code)}`})
147897
148282
  `);
147898
148283
  });
147899
148284
  return pid;
147900
148285
  } finally {
147901
- import_node_fs24.default.closeSync(logFd);
148286
+ import_node_fs25.default.closeSync(logFd);
147902
148287
  }
147903
148288
  },
147904
148289
  stopProcess: (pid) => {
@@ -147911,7 +148296,7 @@ function realSupervisorPorts(paths) {
147911
148296
  now: () => Date.now()
147912
148297
  });
147913
148298
  if (outcome === "still-running") {
147914
- import_node_fs24.default.appendFileSync(
148299
+ import_node_fs25.default.appendFileSync(
147915
148300
  paths.headroomLogPath,
147916
148301
  `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: pid ${String(pid)} survived SIGKILL within its grace; it is stuck uninterruptibly
147917
148302
  `
@@ -147920,7 +148305,7 @@ function realSupervisorPorts(paths) {
147920
148305
  },
147921
148306
  ready: readyOverSocket,
147922
148307
  install: (spec) => {
147923
- const result = (0, import_node_child_process9.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
148308
+ const result = (0, import_node_child_process10.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
147924
148309
  if (result.error !== void 0) {
147925
148310
  const timedOut = "code" in result.error && result.error.code === "ETIMEDOUT";
147926
148311
  return {
@@ -147929,21 +148314,21 @@ function realSupervisorPorts(paths) {
147929
148314
  };
147930
148315
  }
147931
148316
  if (result.stdout !== "") {
147932
- import_node_fs24.default.appendFileSync(paths.headroomLogPath, result.stdout);
148317
+ import_node_fs25.default.appendFileSync(paths.headroomLogPath, result.stdout);
147933
148318
  }
147934
148319
  if (result.stderr !== "") {
147935
- import_node_fs24.default.appendFileSync(paths.headroomLogPath, result.stderr);
148320
+ import_node_fs25.default.appendFileSync(paths.headroomLogPath, result.stderr);
147936
148321
  }
147937
148322
  return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
147938
148323
  },
147939
148324
  headroomVersion: () => {
147940
- const result = (0, import_node_child_process9.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
148325
+ const result = (0, import_node_child_process10.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
147941
148326
  return result.status === 0 ? result.stdout.trim() : void 0;
147942
148327
  },
147943
148328
  installedCommit: readInstalledHeadroomCommit,
147944
148329
  log: (line) => {
147945
- import_node_fs24.default.mkdirSync(paths.logsDir, { recursive: true });
147946
- import_node_fs24.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
148330
+ import_node_fs25.default.mkdirSync(paths.logsDir, { recursive: true });
148331
+ import_node_fs25.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
147947
148332
  `);
147948
148333
  }
147949
148334
  };
@@ -148076,9 +148461,9 @@ init_providersStore();
148076
148461
  init_realPorts();
148077
148462
  var realCatalogueFetch = async (url2, headers, timeoutMs) => {
148078
148463
  const response = await fetch(url2, { headers: { ...headers }, signal: AbortSignal.timeout(timeoutMs) });
148079
- const text2 = await response.text();
148464
+ const text3 = await response.text();
148080
148465
  try {
148081
- const body = JSON.parse(text2);
148466
+ const body = JSON.parse(text3);
148082
148467
  return { status: response.status, body };
148083
148468
  } catch {
148084
148469
  return { status: response.status, body: void 0 };
@@ -148450,12 +148835,12 @@ init_translate();
148450
148835
  init_schema();
148451
148836
  init_cliError();
148452
148837
  init_providerCatalogue();
148453
- var import_node_fs26 = __toESM(require("node:fs"), 1);
148838
+ var import_node_fs27 = __toESM(require("node:fs"), 1);
148454
148839
  init_credential();
148455
148840
  init_providerAliases();
148456
148841
 
148457
148842
  // src/providerRename.ts
148458
- var import_node_fs25 = __toESM(require("node:fs"), 1);
148843
+ var import_node_fs26 = __toESM(require("node:fs"), 1);
148459
148844
  var import_node_path62 = __toESM(require("node:path"), 1);
148460
148845
  init_schema();
148461
148846
  init_store();
@@ -148521,7 +148906,7 @@ function renameProvider(paths, from, to2, ports) {
148521
148906
  const previousAliases = readProviderAliases(paths);
148522
148907
  writeProviderAliases(paths, aliasesAfterRename(previousAliases, from, to2));
148523
148908
  try {
148524
- import_node_fs25.default.renameSync(providerJsonPath(paths, from), providerJsonPath(paths, to2));
148909
+ import_node_fs26.default.renameSync(providerJsonPath(paths, from), providerJsonPath(paths, to2));
148525
148910
  } catch (error63) {
148526
148911
  writeProviderAliases(paths, previousAliases);
148527
148912
  throw error63;
@@ -148541,8 +148926,8 @@ function moveState(paths, from, to2, ports) {
148541
148926
  `);
148542
148927
  moved.push(`usage ${snapshot.identity}`);
148543
148928
  }
148544
- if (import_node_fs25.default.existsSync(catalogueCachePath(paths, from))) {
148545
- import_node_fs25.default.renameSync(catalogueCachePath(paths, from), catalogueCachePath(paths, to2));
148929
+ if (import_node_fs26.default.existsSync(catalogueCachePath(paths, from))) {
148930
+ import_node_fs26.default.renameSync(catalogueCachePath(paths, from), catalogueCachePath(paths, to2));
148546
148931
  moved.push("catalogue");
148547
148932
  }
148548
148933
  const renamed = readProvider(paths, to2);
@@ -148873,7 +149258,7 @@ function registerProviderCommand(program2, deps) {
148873
149258
  throw new UsageError(`Provider "${name}" has no catalogue setting. Set one with \`agent-shim provider set ${name} --catalogue-tier <tier>\`.`);
148874
149259
  }
148875
149260
  const catalogueSetting = found.catalogue;
148876
- const cache = options.refresh === true ? await refreshCatalogueForReal(paths, name, process.env) : parseCatalogueCache(import_node_fs26.default.existsSync(catalogueCachePath(paths, name)) ? import_node_fs26.default.readFileSync(catalogueCachePath(paths, name), "utf8") : void 0);
149261
+ const cache = options.refresh === true ? await refreshCatalogueForReal(paths, name, process.env) : parseCatalogueCache(import_node_fs27.default.existsSync(catalogueCachePath(paths, name)) ? import_node_fs27.default.readFileSync(catalogueCachePath(paths, name), "utf8") : void 0);
148877
149262
  if (cache === void 0) {
148878
149263
  throw new UsageError(`No catalogue has been fetched for "${name}" yet: the front door fetches it shortly after it starts, or run \`agent-shim provider models ${name} --refresh\`.`);
148879
149264
  }
@@ -149417,14 +149802,14 @@ function requireIdentity(paths, name) {
149417
149802
  throw new IdentityNotFoundError(name);
149418
149803
  }
149419
149804
  }
149420
- function collectUsageReport(fs29, paths, filters) {
149805
+ function collectUsageReport(fs30, paths, filters) {
149421
149806
  const { identity, provider, sinceMs } = filters;
149422
149807
  if (identity !== void 0) {
149423
149808
  requireIdentity(paths, identity);
149424
149809
  }
149425
- const log = readUsageLog(fs29, paths.usageLogDir, sinceMs === void 0 ? {} : { sinceMs });
149810
+ const log = readUsageLog(fs30, paths.usageLogDir, sinceMs === void 0 ? {} : { sinceMs });
149426
149811
  const records = log.records.filter((record2) => (identity === void 0 || record2.identity === identity) && (provider === void 0 || record2.provider === provider));
149427
- const snapshots = (identity === void 0 ? listUsageSnapshots(fs29, paths.usageSnapshotsDir) : [readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity)].flatMap((snapshot) => snapshot === void 0 ? [] : [snapshot])).map((snapshot) => provider === void 0 ? snapshot : { ...snapshot, providers: Object.fromEntries(Object.entries(snapshot.providers).filter(([name]) => name === provider)) }).filter((snapshot) => Object.keys(snapshot.providers).length > 0);
149812
+ const snapshots = (identity === void 0 ? listUsageSnapshots(fs30, paths.usageSnapshotsDir) : [readUsageSnapshot(fs30, paths.usageSnapshotsDir, identity)].flatMap((snapshot) => snapshot === void 0 ? [] : [snapshot])).map((snapshot) => provider === void 0 ? snapshot : { ...snapshot, providers: Object.fromEntries(Object.entries(snapshot.providers).filter(([name]) => name === provider)) }).filter((snapshot) => Object.keys(snapshot.providers).length > 0);
149428
149813
  return {
149429
149814
  since: sinceMs === void 0 ? void 0 : new Date(sinceMs).toISOString(),
149430
149815
  logDir: paths.usageLogDir,
@@ -149531,16 +149916,16 @@ function formatUsageReport(report) {
149531
149916
  }
149532
149917
  return lines;
149533
149918
  }
149534
- function collectAccounts(fs29, paths, identity, probe) {
149919
+ function collectAccounts(fs30, paths, identity, probe) {
149535
149920
  if (identity !== void 0) {
149536
149921
  requireIdentity(paths, identity);
149537
149922
  }
149538
149923
  const names = identity === void 0 ? listIdentities(paths).map((entry) => entry.name) : [identity];
149539
149924
  return names.map((name) => ({
149540
149925
  identity: name,
149541
- account: readAccountMetadata(fs29, paths.identitiesDir, name),
149542
- signIn: identitySignIn(fs29, probe, { farmRoot: import_node_path63.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
149543
- usage: readUsageSnapshot(fs29, paths.usageSnapshotsDir, name)
149926
+ account: readAccountMetadata(fs30, paths.identitiesDir, name),
149927
+ signIn: identitySignIn(fs30, probe, { farmRoot: import_node_path63.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
149928
+ usage: readUsageSnapshot(fs30, paths.usageSnapshotsDir, name)
149544
149929
  }));
149545
149930
  }
149546
149931
  function formatAccounts(views) {
@@ -149876,8 +150261,8 @@ function createRealCompactor(params) {
149876
150261
  sizes = boundarySizes(message);
149877
150262
  }
149878
150263
  if (message.type === "result") {
149879
- const text2 = successfulResult(message);
149880
- return sizes === void 0 ? { kind: "unchanged", reason: text2 === "" ? "nothing was compacted" : text2 } : { kind: "compacted", ...sizes };
150264
+ const text3 = successfulResult(message);
150265
+ return sizes === void 0 ? { kind: "unchanged", reason: text3 === "" ? "nothing was compacted" : text3 } : { kind: "compacted", ...sizes };
149881
150266
  }
149882
150267
  }
149883
150268
  throw new Error("the compaction ended without a result");
@@ -149890,15 +150275,15 @@ function createRealCompactor(params) {
149890
150275
  // src/supervise/compactionDeps.ts
149891
150276
  var COMPACT_SLOT_STALE_MS = COMPACT_TIMEOUT_MS * 2;
149892
150277
  function createCompactionDeps(wiring) {
149893
- const { paths, fs: fs29, pool } = wiring;
150278
+ const { paths, fs: fs30, pool } = wiring;
149894
150279
  return {
149895
150280
  shouldCompact: (identity, sessionId) => {
149896
150281
  const nowMs = wiring.now();
149897
- const sessions = liveSupervised(fs29, paths, pool, wiring.isRunning).filter((session) => session.identity === identity).map((session) => ({ sessionId: session.sessionId, state: readSessionState(fs29, paths, pool, session.sessionId) }));
150282
+ const sessions = liveSupervised(fs30, paths, pool, wiring.isRunning).filter((session) => session.identity === identity).map((session) => ({ sessionId: session.sessionId, state: readSessionState(fs30, paths, pool, session.sessionId) }));
149898
150283
  return decideCompaction({
149899
150284
  atUtilisation: wiring.policy.compactAtUtilisation,
149900
- snapshot: readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity),
149901
- records: () => readUsageLog(fs29, paths.usageLogDir, { sinceMs: nowMs - FIVE_HOUR_WINDOW_MS }).records.filter((record2) => record2.identity === identity),
150285
+ snapshot: readUsageSnapshot(fs30, paths.usageSnapshotsDir, identity),
150286
+ records: () => readUsageLog(fs30, paths.usageLogDir, { sinceMs: nowMs - FIVE_HOUR_WINDOW_MS }).records.filter((record2) => record2.identity === identity),
149902
150287
  sessions,
149903
150288
  sessionId,
149904
150289
  nowMs
@@ -149906,7 +150291,7 @@ function createCompactionDeps(wiring) {
149906
150291
  },
149907
150292
  acquire: (identity) => {
149908
150293
  try {
149909
- const lock = acquireIdentityLock({ identity: `compact-${identity}`, dir: superviseDirOf(paths, pool), fs: fs29, nowMs: wiring.now, pid: wiring.pid, isRunning: wiring.isRunning, sleep: wiring.sleep, maxAttempts: 1, staleAfterMs: COMPACT_SLOT_STALE_MS });
150294
+ const lock = acquireIdentityLock({ identity: `compact-${identity}`, dir: superviseDirOf(paths, pool), fs: fs30, nowMs: wiring.now, pid: wiring.pid, isRunning: wiring.isRunning, sleep: wiring.sleep, maxAttempts: 1, staleAfterMs: COMPACT_SLOT_STALE_MS });
149910
150295
  return { release: lock.release };
149911
150296
  } catch (error63) {
149912
150297
  if (error63 instanceof IdentityLockBusyError) {
@@ -149917,8 +150302,8 @@ function createCompactionDeps(wiring) {
149917
150302
  },
149918
150303
  compact: wiring.compact,
149919
150304
  markCompacted: (sessionId, compacted) => {
149920
- const previous = readSessionState(fs29, paths, pool, sessionId);
149921
- writeSessionState(fs29, paths, pool, sessionId, {
150305
+ const previous = readSessionState(fs30, paths, pool, sessionId);
150306
+ writeSessionState(fs30, paths, pool, sessionId, {
149922
150307
  mark: previous?.mark ?? "idle",
149923
150308
  ...previous?.contextTokens === void 0 ? {} : { contextTokens: previous.contextTokens },
149924
150309
  ...compacted ? { compacted: true } : {},
@@ -149930,12 +150315,12 @@ function createCompactionDeps(wiring) {
149930
150315
 
149931
150316
  // src/supervise/limit.ts
149932
150317
  init_read();
149933
- function quotaHitOf(fs29, paths, identity, sessionId, sinceMs, nowMs) {
149934
- const reason = refusalReason(identity, readUsageSnapshot(fs29, paths.usageSnapshotsDir, identity), nowMs);
150318
+ function quotaHitOf(fs30, paths, identity, sessionId, sinceMs, nowMs) {
150319
+ const reason = refusalReason(identity, readUsageSnapshot(fs30, paths.usageSnapshotsDir, identity), nowMs);
149935
150320
  if (reason === void 0) {
149936
150321
  return void 0;
149937
150322
  }
149938
- const { records } = readUsageLog(fs29, paths.usageLogDir, { sinceMs });
150323
+ const { records } = readUsageLog(fs30, paths.usageLogDir, { sinceMs });
149939
150324
  for (let index = records.length - 1; index >= 0; index -= 1) {
149940
150325
  const record2 = records[index];
149941
150326
  if (record2?.sessionId === sessionId && record2.identity === identity && record2.limit?.kind === "quota-exhausted") {
@@ -150054,12 +150439,12 @@ function createIdentityMover(deps) {
150054
150439
  }
150055
150440
 
150056
150441
  // src/supervise/realPorts.ts
150057
- var import_node_child_process10 = require("node:child_process");
150058
- var import_node_fs27 = __toESM(require("node:fs"), 1);
150442
+ var import_node_child_process11 = require("node:child_process");
150443
+ var import_node_fs28 = __toESM(require("node:fs"), 1);
150059
150444
  init_realPorts();
150060
150445
  var realSupervisedSpawnPort = {
150061
150446
  spawn(command, args, options) {
150062
- const child = (0, import_node_child_process10.spawn)(command, [...args], { stdio: options.stdio, env: { ...options.env } });
150447
+ const child = (0, import_node_child_process11.spawn)(command, [...args], { stdio: options.stdio, env: { ...options.env } });
150063
150448
  const exit = new Promise((resolve2) => {
150064
150449
  child.once("error", (error63) => {
150065
150450
  resolve2({ status: null, signal: null, error: error63 });
@@ -150101,7 +150486,7 @@ var realTimerPort = {
150101
150486
  function realWatchDirectory(directory, accepts, what, log) {
150102
150487
  return (onChange) => {
150103
150488
  realFarmFs.mkdirPrivate(directory);
150104
- const watcher = import_node_fs27.default.watch(directory, { persistent: false }, (_event, filename) => {
150489
+ const watcher = import_node_fs28.default.watch(directory, { persistent: false }, (_event, filename) => {
150105
150490
  if (filename === null || accepts(filename)) {
150106
150491
  onChange();
150107
150492
  }
@@ -150121,7 +150506,7 @@ function resetTerminal() {
150121
150506
  return;
150122
150507
  }
150123
150508
  process.stdout.write(TERMINAL_RESET);
150124
- (0, import_node_child_process10.spawnSync)("stty", ["sane"], { stdio: ["inherit", "ignore", "ignore"] });
150509
+ (0, import_node_child_process11.spawnSync)("stty", ["sane"], { stdio: ["inherit", "ignore", "ignore"] });
150125
150510
  }
150126
150511
 
150127
150512
  // src/supervise/supervise.ts