claude-use 9.8.0 → 9.10.0

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
@@ -318,10 +318,10 @@ function mergeDefs(...defs) {
318
318
  function cloneDef(schema) {
319
319
  return mergeDefs(schema._zod.def);
320
320
  }
321
- function getElementAtPath(obj, path50) {
322
- if (!path50)
321
+ function getElementAtPath(obj, path51) {
322
+ if (!path51)
323
323
  return obj;
324
- return path50.reduce((acc, key) => acc?.[key], obj);
324
+ return path51.reduce((acc, key) => acc?.[key], obj);
325
325
  }
326
326
  function promiseAllObject(promisesObj) {
327
327
  const keys = Object.keys(promisesObj);
@@ -580,11 +580,11 @@ function explicitlyAborted(x, startIndex = 0) {
580
580
  }
581
581
  return false;
582
582
  }
583
- function prefixIssues(path50, issues) {
583
+ function prefixIssues(path51, issues) {
584
584
  return issues.map((iss) => {
585
585
  var _a4;
586
586
  (_a4 = iss).path ?? (_a4.path = []);
587
- iss.path.unshift(path50);
587
+ iss.path.unshift(path51);
588
588
  return iss;
589
589
  });
590
590
  }
@@ -1105,16 +1105,16 @@ function flattenError(error63, mapper = (issue2) => issue2.message) {
1105
1105
  }
1106
1106
  function formatError(error63, mapper = (issue2) => issue2.message) {
1107
1107
  const fieldErrors = { _errors: [] };
1108
- const processError = (error64, path50 = []) => {
1108
+ const processError = (error64, path51 = []) => {
1109
1109
  for (const issue2 of error64.issues) {
1110
1110
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1111
- issue2.errors.map((issues) => processError({ issues }, [...path50, ...issue2.path]));
1111
+ issue2.errors.map((issues) => processError({ issues }, [...path51, ...issue2.path]));
1112
1112
  } else if (issue2.code === "invalid_key") {
1113
- processError({ issues: issue2.issues }, [...path50, ...issue2.path]);
1113
+ processError({ issues: issue2.issues }, [...path51, ...issue2.path]);
1114
1114
  } else if (issue2.code === "invalid_element") {
1115
- processError({ issues: issue2.issues }, [...path50, ...issue2.path]);
1115
+ processError({ issues: issue2.issues }, [...path51, ...issue2.path]);
1116
1116
  } else {
1117
- const fullpath = [...path50, ...issue2.path];
1117
+ const fullpath = [...path51, ...issue2.path];
1118
1118
  if (fullpath.length === 0) {
1119
1119
  fieldErrors._errors.push(mapper(issue2));
1120
1120
  } else {
@@ -1153,17 +1153,17 @@ function formatError(error63, mapper = (issue2) => issue2.message) {
1153
1153
  }
1154
1154
  function treeifyError(error63, mapper = (issue2) => issue2.message) {
1155
1155
  const result = { errors: [] };
1156
- const processError = (error64, path50 = []) => {
1156
+ const processError = (error64, path51 = []) => {
1157
1157
  var _a4;
1158
1158
  for (const issue2 of error64.issues) {
1159
1159
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1160
- issue2.errors.map((issues) => processError({ issues }, [...path50, ...issue2.path]));
1160
+ issue2.errors.map((issues) => processError({ issues }, [...path51, ...issue2.path]));
1161
1161
  } else if (issue2.code === "invalid_key") {
1162
- processError({ issues: issue2.issues }, [...path50, ...issue2.path]);
1162
+ processError({ issues: issue2.issues }, [...path51, ...issue2.path]);
1163
1163
  } else if (issue2.code === "invalid_element") {
1164
- processError({ issues: issue2.issues }, [...path50, ...issue2.path]);
1164
+ processError({ issues: issue2.issues }, [...path51, ...issue2.path]);
1165
1165
  } else {
1166
- const fullpath = [...path50, ...issue2.path];
1166
+ const fullpath = [...path51, ...issue2.path];
1167
1167
  if (fullpath.length === 0) {
1168
1168
  result.errors.push(mapper(issue2));
1169
1169
  continue;
@@ -1202,8 +1202,8 @@ function treeifyError(error63, mapper = (issue2) => issue2.message) {
1202
1202
  }
1203
1203
  function toDotPath(_path) {
1204
1204
  const segs = [];
1205
- const path50 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1206
- for (const seg of path50) {
1205
+ const path51 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1206
+ for (const seg of path51) {
1207
1207
  if (typeof seg === "number")
1208
1208
  segs.push(`[${seg}]`);
1209
1209
  else if (typeof seg === "symbol")
@@ -19199,13 +19199,13 @@ function resolveRef(ref, ctx) {
19199
19199
  if (!ref.startsWith("#")) {
19200
19200
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
19201
19201
  }
19202
- const path50 = ref.slice(1).split("/").filter(Boolean);
19203
- if (path50.length === 0) {
19202
+ const path51 = ref.slice(1).split("/").filter(Boolean);
19203
+ if (path51.length === 0) {
19204
19204
  return ctx.rootSchema;
19205
19205
  }
19206
19206
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
19207
- if (path50[0] === defsKey) {
19208
- const key = path50[1] === void 0 ? void 0 : decodeJSONPointerSegment(path50[1]);
19207
+ if (path51[0] === defsKey) {
19208
+ const key = path51[1] === void 0 ? void 0 : decodeJSONPointerSegment(path51[1]);
19209
19209
  if (!key || !ctx.defs[key]) {
19210
19210
  throw new Error(`Reference not found: ${ref}`);
19211
19211
  }
@@ -23712,42 +23712,42 @@ var require_defaults = __commonJS({
23712
23712
  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
- var path50 = require("path");
23715
+ var path51 = require("path");
23716
23716
  var os12 = require("os");
23717
23717
  var homedir = os12.homedir();
23718
23718
  var tmpdir = os12.tmpdir();
23719
23719
  var { env } = process;
23720
23720
  var macos = (name) => {
23721
- const library = path50.join(homedir, "Library");
23721
+ const library = path51.join(homedir, "Library");
23722
23722
  return {
23723
- data: path50.join(library, "Application Support", name),
23724
- config: path50.join(library, "Preferences", name),
23725
- cache: path50.join(library, "Caches", name),
23726
- log: path50.join(library, "Logs", name),
23727
- temp: path50.join(tmpdir, name)
23723
+ data: path51.join(library, "Application Support", name),
23724
+ config: path51.join(library, "Preferences", name),
23725
+ cache: path51.join(library, "Caches", name),
23726
+ log: path51.join(library, "Logs", name),
23727
+ temp: path51.join(tmpdir, name)
23728
23728
  };
23729
23729
  };
23730
23730
  var windows = (name) => {
23731
- const appData = env.APPDATA || path50.join(homedir, "AppData", "Roaming");
23732
- const localAppData = env.LOCALAPPDATA || path50.join(homedir, "AppData", "Local");
23731
+ const appData = env.APPDATA || path51.join(homedir, "AppData", "Roaming");
23732
+ const localAppData = env.LOCALAPPDATA || path51.join(homedir, "AppData", "Local");
23733
23733
  return {
23734
23734
  // Data/config/cache/log are invented by me as Windows isn't opinionated about this
23735
- data: path50.join(localAppData, name, "Data"),
23736
- config: path50.join(appData, name, "Config"),
23737
- cache: path50.join(localAppData, name, "Cache"),
23738
- log: path50.join(localAppData, name, "Log"),
23739
- temp: path50.join(tmpdir, name)
23735
+ data: path51.join(localAppData, name, "Data"),
23736
+ config: path51.join(appData, name, "Config"),
23737
+ cache: path51.join(localAppData, name, "Cache"),
23738
+ log: path51.join(localAppData, name, "Log"),
23739
+ temp: path51.join(tmpdir, name)
23740
23740
  };
23741
23741
  };
23742
23742
  var linux = (name) => {
23743
- const username = path50.basename(homedir);
23743
+ const username = path51.basename(homedir);
23744
23744
  return {
23745
- data: path50.join(env.XDG_DATA_HOME || path50.join(homedir, ".local", "share"), name),
23746
- config: path50.join(env.XDG_CONFIG_HOME || path50.join(homedir, ".config"), name),
23747
- cache: path50.join(env.XDG_CACHE_HOME || path50.join(homedir, ".cache"), name),
23745
+ data: path51.join(env.XDG_DATA_HOME || path51.join(homedir, ".local", "share"), name),
23746
+ config: path51.join(env.XDG_CONFIG_HOME || path51.join(homedir, ".config"), name),
23747
+ cache: path51.join(env.XDG_CACHE_HOME || path51.join(homedir, ".cache"), name),
23748
23748
  // https://wiki.debian.org/XDGBaseDirectorySpecification#state
23749
- log: path50.join(env.XDG_STATE_HOME || path50.join(homedir, ".local", "state"), name),
23750
- temp: path50.join(tmpdir, username, name)
23749
+ log: path51.join(env.XDG_STATE_HOME || path51.join(homedir, ".local", "state"), name),
23750
+ temp: path51.join(tmpdir, username, name)
23751
23751
  };
23752
23752
  };
23753
23753
  var envPaths = (name, options) => {
@@ -23815,11 +23815,11 @@ var require_util = __commonJS({
23815
23815
  return result;
23816
23816
  }
23817
23817
  exports2.emplace = emplace;
23818
- function getPropertyByPath(source, path50) {
23819
- if (typeof path50 === "string" && Object.prototype.hasOwnProperty.call(source, path50)) {
23820
- return source[path50];
23818
+ function getPropertyByPath(source, path51) {
23819
+ if (typeof path51 === "string" && Object.prototype.hasOwnProperty.call(source, path51)) {
23820
+ return source[path51];
23821
23821
  }
23822
- const parsedPath = typeof path50 === "string" ? path50.split(".") : path50;
23822
+ const parsedPath = typeof path51 === "string" ? path51.split(".") : path51;
23823
23823
  return parsedPath.reduce((previous, key) => {
23824
23824
  if (previous === void 0) {
23825
23825
  return previous;
@@ -23842,9 +23842,9 @@ var require_util = __commonJS({
23842
23842
  return Object.fromEntries(Object.entries(options).filter(([, value2]) => value2 !== void 0));
23843
23843
  }
23844
23844
  exports2.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
23845
- async function isDirectory(path50) {
23845
+ async function isDirectory(path51) {
23846
23846
  try {
23847
- const stat = await fs_1.promises.stat(path50);
23847
+ const stat = await fs_1.promises.stat(path51);
23848
23848
  return stat.isDirectory();
23849
23849
  } catch (e14) {
23850
23850
  if (e14.code === "ENOENT") {
@@ -23854,9 +23854,9 @@ var require_util = __commonJS({
23854
23854
  }
23855
23855
  }
23856
23856
  exports2.isDirectory = isDirectory;
23857
- function isDirectorySync(path50) {
23857
+ function isDirectorySync(path51) {
23858
23858
  try {
23859
- const stat = fs_1.default.statSync(path50);
23859
+ const stat = fs_1.default.statSync(path51);
23860
23860
  return stat.isDirectory();
23861
23861
  } catch (e14) {
23862
23862
  if (e14.code === "ENOENT") {
@@ -23954,7 +23954,7 @@ var require_ExplorerBase = __commonJS({
23954
23954
  const idx = importStack.indexOf(fullPath);
23955
23955
  if (idx !== -1) {
23956
23956
  throw new Error(`Circular import detected:
23957
- ${[...importStack, fullPath].map((path50, i10) => `${i10 + 1}. ${path50}`).join("\n")} (same as ${idx + 1}.)`);
23957
+ ${[...importStack, fullPath].map((path51, i10) => `${i10 + 1}. ${path51}`).join("\n")} (same as ${idx + 1}.)`);
23958
23958
  }
23959
23959
  }
23960
23960
  }
@@ -24142,9 +24142,9 @@ var require_Explorer = __commonJS({
24142
24142
  throw error63;
24143
24143
  }
24144
24144
  }
24145
- async #fileExists(path50) {
24145
+ async #fileExists(path51) {
24146
24146
  try {
24147
- await promises_1.default.stat(path50);
24147
+ await promises_1.default.stat(path51);
24148
24148
  return true;
24149
24149
  } catch (e14) {
24150
24150
  return false;
@@ -24304,9 +24304,9 @@ var require_ExplorerSync = __commonJS({
24304
24304
  throw error63;
24305
24305
  }
24306
24306
  }
24307
- #fileExists(path50) {
24307
+ #fileExists(path51) {
24308
24308
  try {
24309
- fs_1.default.statSync(path50);
24309
+ fs_1.default.statSync(path51);
24310
24310
  return true;
24311
24311
  } catch (e14) {
24312
24312
  return false;
@@ -24430,7 +24430,7 @@ var require_dist = __commonJS({
24430
24430
  };
24431
24431
  }
24432
24432
  function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
24433
- const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path50) => path50.replace("{name}", moduleName));
24433
+ const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path51) => path51.replace("{name}", moduleName));
24434
24434
  if (userConfiguredOptions.mergeSearchPlaces) {
24435
24435
  return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
24436
24436
  }
@@ -27055,43 +27055,43 @@ function parseJson(raw, schema) {
27055
27055
  const parsed = schema.safeParse(JSON.parse(raw));
27056
27056
  return parsed.success ? parsed.data : void 0;
27057
27057
  }
27058
- function readHeadroomState(fs21, stateFile) {
27058
+ function readHeadroomState(fs22, stateFile) {
27059
27059
  try {
27060
- return parseJson(fs21.readFileUtf8(stateFile), HeadroomStateSchema);
27060
+ return parseJson(fs22.readFileUtf8(stateFile), HeadroomStateSchema);
27061
27061
  } catch {
27062
27062
  return void 0;
27063
27063
  }
27064
27064
  }
27065
- function writeHeadroomState(fs21, stateFile, state) {
27066
- fs21.mkdirp(import_node_path5.default.dirname(stateFile));
27067
- fs21.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27065
+ function writeHeadroomState(fs22, stateFile, state) {
27066
+ fs22.mkdirp(import_node_path5.default.dirname(stateFile));
27067
+ fs22.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27068
27068
  `);
27069
27069
  }
27070
- function resolveServingHeadroomState(fs21, files, isRunning) {
27071
- const current = readHeadroomState(fs21, files.stateFile);
27070
+ function resolveServingHeadroomState(fs22, files, isRunning) {
27071
+ const current = readHeadroomState(fs22, files.stateFile);
27072
27072
  if (current !== void 0) {
27073
27073
  return { path: files.stateFile, state: current };
27074
27074
  }
27075
- const legacy = readHeadroomState(fs21, files.legacyStateFile);
27075
+ const legacy = readHeadroomState(fs22, files.legacyStateFile);
27076
27076
  if (legacy?.supervisorPid !== void 0 && isRunning(legacy.supervisorPid)) {
27077
27077
  return { path: files.legacyStateFile, state: legacy };
27078
27078
  }
27079
27079
  return void 0;
27080
27080
  }
27081
- function migrateHeadroomState(fs21, files, isRunning) {
27082
- const legacy = readHeadroomState(fs21, files.legacyStateFile);
27081
+ function migrateHeadroomState(fs22, files, isRunning) {
27082
+ const legacy = readHeadroomState(fs22, files.legacyStateFile);
27083
27083
  const legacyLive = legacy?.supervisorPid !== void 0 && isRunning(legacy.supervisorPid);
27084
- const current = readHeadroomState(fs21, files.stateFile);
27084
+ const current = readHeadroomState(fs22, files.stateFile);
27085
27085
  if (current !== void 0 || legacyLive) {
27086
- if (!legacyLive && fs21.readFileUtf8(files.legacyStateFile) !== void 0) {
27087
- fs21.removeRecursive(files.legacyStateFile);
27086
+ if (!legacyLive && fs22.readFileUtf8(files.legacyStateFile) !== void 0) {
27087
+ fs22.removeRecursive(files.legacyStateFile);
27088
27088
  }
27089
27089
  return;
27090
27090
  }
27091
27091
  if (legacy !== void 0) {
27092
- writeHeadroomState(fs21, files.stateFile, legacy);
27092
+ writeHeadroomState(fs22, files.stateFile, legacy);
27093
27093
  }
27094
- fs21.removeRecursive(files.legacyStateFile);
27094
+ fs22.removeRecursive(files.legacyStateFile);
27095
27095
  }
27096
27096
  function headroomAllowlist(providers) {
27097
27097
  const urls = /* @__PURE__ */ new Set([HEADROOM_ANTHROPIC_UPSTREAM]);
@@ -27110,14 +27110,14 @@ function headroomUpstreams(providers, frontDoorOrigin2) {
27110
27110
  function hashAllowlist(allowlist) {
27111
27111
  return (0, import_node_crypto2.createHash)("sha256").update(allowlist.join("\n")).digest("hex");
27112
27112
  }
27113
- function readAllProviders(fs21, providersDir) {
27113
+ function readAllProviders(fs22, providersDir) {
27114
27114
  const result = [];
27115
- for (const name of fs21.readdir(providersDir)) {
27115
+ for (const name of fs22.readdir(providersDir)) {
27116
27116
  if (!name.endsWith(".json")) {
27117
27117
  continue;
27118
27118
  }
27119
27119
  try {
27120
- const parsed = parseJson(fs21.readFileUtf8(import_node_path5.default.join(providersDir, name)), ProviderSchema);
27120
+ const parsed = parseJson(fs22.readFileUtf8(import_node_path5.default.join(providersDir, name)), ProviderSchema);
27121
27121
  if (parsed !== void 0) {
27122
27122
  result.push({ name: name.slice(0, -".json".length), provider: parsed });
27123
27123
  }
@@ -27127,22 +27127,22 @@ function readAllProviders(fs21, providersDir) {
27127
27127
  }
27128
27128
  return result;
27129
27129
  }
27130
- function writeSession(fs21, sessionsDir, session) {
27131
- fs21.mkdirp(sessionsDir);
27132
- fs21.writeFileUtf8(import_node_path5.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27130
+ function writeSession(fs22, sessionsDir, session) {
27131
+ fs22.mkdirp(sessionsDir);
27132
+ fs22.writeFileUtf8(import_node_path5.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27133
27133
  `);
27134
27134
  }
27135
- function removeSession(fs21, sessionsDir, pid) {
27136
- fs21.removeRecursive(import_node_path5.default.join(sessionsDir, `${String(pid)}.json`));
27135
+ function removeSession(fs22, sessionsDir, pid) {
27136
+ fs22.removeRecursive(import_node_path5.default.join(sessionsDir, `${String(pid)}.json`));
27137
27137
  }
27138
- function listSessions(fs21, sessionsDir) {
27138
+ function listSessions(fs22, sessionsDir) {
27139
27139
  const sessions = [];
27140
- for (const name of fs21.readdir(sessionsDir)) {
27140
+ for (const name of fs22.readdir(sessionsDir)) {
27141
27141
  if (!name.endsWith(".json")) {
27142
27142
  continue;
27143
27143
  }
27144
27144
  try {
27145
- const parsed = parseJson(fs21.readFileUtf8(import_node_path5.default.join(sessionsDir, name)), HeadroomSessionSchema);
27145
+ const parsed = parseJson(fs22.readFileUtf8(import_node_path5.default.join(sessionsDir, name)), HeadroomSessionSchema);
27146
27146
  if (parsed !== void 0) {
27147
27147
  sessions.push(parsed);
27148
27148
  }
@@ -27152,22 +27152,22 @@ function listSessions(fs21, sessionsDir) {
27152
27152
  }
27153
27153
  return sessions.sort((a10, b) => a10.pid - b.pid);
27154
27154
  }
27155
- function sessionsForSupervisor(fs21, sessionsDir, supervisorPid) {
27156
- return listSessions(fs21, sessionsDir).filter((session) => session.supervisorPid === supervisorPid);
27155
+ function sessionsForSupervisor(fs22, sessionsDir, supervisorPid) {
27156
+ return listSessions(fs22, sessionsDir).filter((session) => session.supervisorPid === supervisorPid);
27157
27157
  }
27158
- function pruneDeadSessions(fs21, sessionsDir, isRunning) {
27158
+ function pruneDeadSessions(fs22, sessionsDir, isRunning) {
27159
27159
  const removed = [];
27160
- for (const session of listSessions(fs21, sessionsDir)) {
27160
+ for (const session of listSessions(fs22, sessionsDir)) {
27161
27161
  if (!isRunning(session.pid)) {
27162
- removeSession(fs21, sessionsDir, session.pid);
27162
+ removeSession(fs22, sessionsDir, session.pid);
27163
27163
  removed.push(session.pid);
27164
27164
  }
27165
27165
  }
27166
27166
  return removed;
27167
27167
  }
27168
- function readStartLock(fs21, lockFile) {
27168
+ function readStartLock(fs22, lockFile) {
27169
27169
  try {
27170
- return parseJson(fs21.readFileUtf8(lockFile), HeadroomLockSchema);
27170
+ return parseJson(fs22.readFileUtf8(lockFile), HeadroomLockSchema);
27171
27171
  } catch {
27172
27172
  return void 0;
27173
27173
  }
@@ -27281,10 +27281,10 @@ var init_ensure = __esm({
27281
27281
  });
27282
27282
 
27283
27283
  // src/frontdoor/state.ts
27284
- function readFrontDoorState(fs21, stateFile) {
27284
+ function readFrontDoorState(fs22, stateFile) {
27285
27285
  let raw;
27286
27286
  try {
27287
- raw = fs21.readFileUtf8(stateFile);
27287
+ raw = fs22.readFileUtf8(stateFile);
27288
27288
  } catch {
27289
27289
  return void 0;
27290
27290
  }
@@ -27298,28 +27298,28 @@ function readFrontDoorState(fs21, stateFile) {
27298
27298
  return void 0;
27299
27299
  }
27300
27300
  }
27301
- function writeFrontDoorState(fs21, stateFile, state) {
27302
- fs21.mkdirp(import_node_path6.default.dirname(stateFile));
27303
- fs21.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27301
+ function writeFrontDoorState(fs22, stateFile, state) {
27302
+ fs22.mkdirp(import_node_path6.default.dirname(stateFile));
27303
+ fs22.writeFilePrivate(stateFile, `${JSON.stringify(state, null, 2)}
27304
27304
  `);
27305
27305
  }
27306
27306
  function frontDoorOrigin(state) {
27307
27307
  const port = state?.directPort ?? state?.lastDirectPort;
27308
27308
  return port === void 0 ? void 0 : `http://127.0.0.1:${String(port)}`;
27309
27309
  }
27310
- function writeFrontDoorSession(fs21, sessionsDir, session) {
27311
- fs21.mkdirPrivate(sessionsDir);
27312
- fs21.writeFilePrivate(import_node_path6.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27310
+ function writeFrontDoorSession(fs22, sessionsDir, session) {
27311
+ fs22.mkdirPrivate(sessionsDir);
27312
+ fs22.writeFilePrivate(import_node_path6.default.join(sessionsDir, `${String(session.pid)}.json`), `${JSON.stringify(session, null, 2)}
27313
27313
  `);
27314
27314
  }
27315
- function listFrontDoorSessions(fs21, sessionsDir) {
27315
+ function listFrontDoorSessions(fs22, sessionsDir) {
27316
27316
  const sessions = [];
27317
- for (const name of fs21.readdir(sessionsDir)) {
27317
+ for (const name of fs22.readdir(sessionsDir)) {
27318
27318
  if (!name.endsWith(".json")) {
27319
27319
  continue;
27320
27320
  }
27321
27321
  try {
27322
- const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs21.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
27322
+ const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs22.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
27323
27323
  if (parsed.success) {
27324
27324
  sessions.push({ pid: parsed.data.pid, startedAt: parsed.data.startedAt });
27325
27325
  }
@@ -27329,27 +27329,27 @@ function listFrontDoorSessions(fs21, sessionsDir) {
27329
27329
  }
27330
27330
  return sessions.sort((a10, b) => a10.pid - b.pid);
27331
27331
  }
27332
- function removeFrontDoorSession(fs21, sessionsDir, pid) {
27333
- fs21.removeRecursive(import_node_path6.default.join(sessionsDir, `${String(pid)}.json`));
27332
+ function removeFrontDoorSession(fs22, sessionsDir, pid) {
27333
+ fs22.removeRecursive(import_node_path6.default.join(sessionsDir, `${String(pid)}.json`));
27334
27334
  }
27335
- function pruneDeadFrontDoorSessions(fs21, sessionsDir, isRunning) {
27335
+ function pruneDeadFrontDoorSessions(fs22, sessionsDir, isRunning) {
27336
27336
  const removed = [];
27337
- for (const session of listFrontDoorSessions(fs21, sessionsDir)) {
27337
+ for (const session of listFrontDoorSessions(fs22, sessionsDir)) {
27338
27338
  if (!isRunning(session.pid)) {
27339
- removeFrontDoorSession(fs21, sessionsDir, session.pid);
27339
+ removeFrontDoorSession(fs22, sessionsDir, session.pid);
27340
27340
  removed.push(session.pid);
27341
27341
  }
27342
27342
  }
27343
27343
  return removed;
27344
27344
  }
27345
- function liveSessionTokens(fs21, sessionsDir) {
27345
+ function liveSessionTokens(fs22, sessionsDir) {
27346
27346
  const tokens = /* @__PURE__ */ new Set();
27347
- for (const name of fs21.readdir(sessionsDir)) {
27347
+ for (const name of fs22.readdir(sessionsDir)) {
27348
27348
  if (!name.endsWith(".json")) {
27349
27349
  continue;
27350
27350
  }
27351
27351
  try {
27352
- const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs21.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
27352
+ const parsed = FrontDoorSessionSchema.safeParse(JSON.parse(fs22.readFileUtf8(import_node_path6.default.join(sessionsDir, name)) ?? ""));
27353
27353
  if (parsed.success) {
27354
27354
  tokens.add(parsed.data.token);
27355
27355
  }
@@ -27470,7 +27470,7 @@ function verifyHeadroomSocket(socketPath, ports) {
27470
27470
  const refusal2 = ownerOnlyRefusal("socket directory", directory, ports.lstat(directory), "dir", uid) ?? ownerOnlyRefusal("socket", socketPath, ports.lstat(socketPath), "socket", uid);
27471
27471
  return refusal2 === void 0 ? { socketPath } : { refused: refusal2 };
27472
27472
  }
27473
- function prepareHeadroomSocket(fs21, ports, paths, supervisorPid) {
27473
+ function prepareHeadroomSocket(fs22, ports, paths, supervisorPid) {
27474
27474
  const unsupported = platformRefusal(ports.platform);
27475
27475
  if (unsupported !== void 0) {
27476
27476
  return { refused: unsupported };
@@ -27485,18 +27485,18 @@ function prepareHeadroomSocket(fs21, ports, paths, supervisorPid) {
27485
27485
  if (ports.lstat(paths.headroomSocketDir)?.kind === "symlink") {
27486
27486
  return { refused: `the headroom socket directory ${paths.headroomSocketDir} is a symlink; it must be the real directory` };
27487
27487
  }
27488
- fs21.mkdirPrivate(paths.headroomSocketDir);
27488
+ fs22.mkdirPrivate(paths.headroomSocketDir);
27489
27489
  const refusal2 = ownerOnlyRefusal("socket directory", paths.headroomSocketDir, ports.lstat(paths.headroomSocketDir), "dir", ports.currentUid());
27490
27490
  return refusal2 === void 0 ? { socketPath } : { refused: refusal2 };
27491
27491
  }
27492
- function pruneStaleHeadroomSockets(fs21, paths, isRunning) {
27492
+ function pruneStaleHeadroomSockets(fs22, paths, isRunning) {
27493
27493
  const removed = [];
27494
- for (const name of fs21.readdir(paths.headroomSocketDir)) {
27494
+ for (const name of fs22.readdir(paths.headroomSocketDir)) {
27495
27495
  const pid = HEADROOM_SOCKET_NAME.exec(name)?.[1];
27496
27496
  if (pid === void 0 || isRunning(Number.parseInt(pid, 10))) {
27497
27497
  continue;
27498
27498
  }
27499
- fs21.removeRecursive(import_node_path7.default.join(paths.headroomSocketDir, name));
27499
+ fs22.removeRecursive(import_node_path7.default.join(paths.headroomSocketDir, name));
27500
27500
  removed.push(name);
27501
27501
  }
27502
27502
  return removed;
@@ -27637,29 +27637,29 @@ function compareVersions2(a10, b) {
27637
27637
  return 0;
27638
27638
  }
27639
27639
  async function runSupervisor(initialConfig, ports, options = {}) {
27640
- const { fs: fs21, paths } = ports;
27640
+ const { fs: fs22, paths } = ports;
27641
27641
  let config2 = initialConfig;
27642
- migrateHeadroomState(fs21, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
27643
- const previousState = resolveServingHeadroomState(fs21, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
27642
+ migrateHeadroomState(fs22, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning);
27643
+ const previousState = resolveServingHeadroomState(fs22, { stateFile: paths.headroomStateFile, legacyStateFile: paths.headroomLegacyStateFile }, ports.isRunning)?.state;
27644
27644
  if (previousState?.supervisorPid !== void 0 && previousState.supervisorPid !== ports.ownPid && ports.isRunning(previousState.supervisorPid)) {
27645
27645
  ports.log(`agent-shim headroom supervisor ${String(ports.ownPid)}: supervisor ${String(previousState.supervisorPid)} already owns the daemon; exiting`);
27646
27646
  return 0;
27647
27647
  }
27648
27648
  let installedSource = previousState?.installedSource;
27649
27649
  const ownsState = () => {
27650
- const owner = readHeadroomState(fs21, paths.headroomStateFile)?.supervisorPid;
27650
+ const owner = readHeadroomState(fs22, paths.headroomStateFile)?.supervisorPid;
27651
27651
  return owner === void 0 || owner === ports.ownPid || !ports.isRunning(owner);
27652
27652
  };
27653
27653
  const writeOwnState = (state) => {
27654
27654
  if (!ownsState()) {
27655
27655
  return false;
27656
27656
  }
27657
- writeHeadroomState(fs21, paths.headroomStateFile, state);
27657
+ writeHeadroomState(fs22, paths.headroomStateFile, state);
27658
27658
  return true;
27659
27659
  };
27660
27660
  const fail = (message) => {
27661
27661
  if (writeOwnState({ lastError: message })) {
27662
- fs21.removeRecursive(paths.headroomLockFile);
27662
+ fs22.removeRecursive(paths.headroomLockFile);
27663
27663
  }
27664
27664
  ports.log(`agent-shim headroom supervisor: ${message}`);
27665
27665
  return 1;
@@ -27681,12 +27681,12 @@ async function runSupervisor(initialConfig, ports, options = {}) {
27681
27681
  installedSource = config2.source;
27682
27682
  return true;
27683
27683
  };
27684
- const socket = prepareHeadroomSocket(fs21, ports.socketTrust, paths, ports.ownPid);
27684
+ const socket = prepareHeadroomSocket(fs22, ports.socketTrust, paths, ports.ownPid);
27685
27685
  if (socket.refused !== void 0) {
27686
27686
  return fail(socket.refused);
27687
27687
  }
27688
27688
  const { socketPath } = socket;
27689
- pruneStaleHeadroomSockets(fs21, paths, ports.isRunning);
27689
+ pruneStaleHeadroomSockets(fs22, paths, ports.isRunning);
27690
27690
  if (!ensureInstalled()) {
27691
27691
  return fail(`could not install headroom from ${config2.source}: install failed (is uv installed and on PATH?)`);
27692
27692
  }
@@ -27714,7 +27714,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
27714
27714
  const settingsHash = hashSettings(config2.settings);
27715
27715
  const allowlist = allowlistOf(ports);
27716
27716
  const allowlistHash = hashAllowlist(allowlist);
27717
- pruneDeadSessions(fs21, paths.headroomSessionsDir, ports.isRunning);
27717
+ pruneDeadSessions(fs22, paths.headroomSessionsDir, ports.isRunning);
27718
27718
  const ownsNow = ownsState();
27719
27719
  if (!ownsNow && !superseded) {
27720
27720
  ports.log("agent-shim headroom supervisor: another supervisor now owns the state file; serving this daemon's own sessions until they end");
@@ -27756,7 +27756,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
27756
27756
  installedSource: config2.source
27757
27757
  });
27758
27758
  if (recorded) {
27759
- fs21.removeRecursive(paths.headroomLockFile);
27759
+ fs22.removeRecursive(paths.headroomLockFile);
27760
27760
  }
27761
27761
  idleSince = void 0;
27762
27762
  ports.log(`agent-shim headroom supervisor: headroom pid ${String(pid)} ready on unix socket ${socketPath}`);
@@ -27771,7 +27771,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
27771
27771
  }
27772
27772
  } else {
27773
27773
  if (runningHash !== allowlistHash || runningSettingsHash !== settingsHash || installedSource !== config2.source) {
27774
- if (sessionsForSupervisor(fs21, paths.headroomSessionsDir, ports.ownPid).length === 0) {
27774
+ if (sessionsForSupervisor(fs22, paths.headroomSessionsDir, ports.ownPid).length === 0) {
27775
27775
  ports.log("agent-shim headroom supervisor: configuration drifted and no sessions are live; restarting headroom");
27776
27776
  ports.stopProcess(headroomPid);
27777
27777
  headroomPid = void 0;
@@ -27780,7 +27780,7 @@ async function runSupervisor(initialConfig, ports, options = {}) {
27780
27780
  continue;
27781
27781
  }
27782
27782
  }
27783
- const sessions = sessionsForSupervisor(fs21, paths.headroomSessionsDir, ports.ownPid);
27783
+ const sessions = sessionsForSupervisor(fs22, paths.headroomSessionsDir, ports.ownPid);
27784
27784
  if (sessions.length === 0) {
27785
27785
  idleSince ??= ports.now();
27786
27786
  const idleMs = ports.now() - idleSince;
@@ -27799,9 +27799,9 @@ async function runSupervisor(initialConfig, ports, options = {}) {
27799
27799
  await ports.sleep(HEADROOM_POLL_MS);
27800
27800
  }
27801
27801
  }
27802
- function currentHeadroomAllowlist(fs21, paths) {
27803
- const providers = readAllProviders(fs21, paths.providersDir).map((entry) => entry.provider);
27804
- return headroomAllowlist(headroomUpstreams(providers, frontDoorOrigin(readFrontDoorState(fs21, paths.frontdoorStateFile))));
27802
+ function currentHeadroomAllowlist(fs22, paths) {
27803
+ const providers = readAllProviders(fs22, paths.providersDir).map((entry) => entry.provider);
27804
+ return headroomAllowlist(headroomUpstreams(providers, frontDoorOrigin(readFrontDoorState(fs22, paths.frontdoorStateFile))));
27805
27805
  }
27806
27806
  function allowlistOf(ports) {
27807
27807
  return currentHeadroomAllowlist(ports.fs, ports.paths);
@@ -28870,8 +28870,8 @@ var require_utils = __commonJS({
28870
28870
  }
28871
28871
  return output2;
28872
28872
  };
28873
- exports2.basename = (path50, { windows } = {}) => {
28874
- const segs = path50.split(windows ? /[\\/]/ : "/");
28873
+ exports2.basename = (path51, { windows } = {}) => {
28874
+ const segs = path51.split(windows ? /[\\/]/ : "/");
28875
28875
  const last = segs[segs.length - 1];
28876
28876
  if (last === "") {
28877
28877
  return segs[segs.length - 2];
@@ -30543,8 +30543,8 @@ var init_classify = __esm({
30543
30543
  function poolNameOf(selector) {
30544
30544
  return selector.startsWith(POOL_SELECTOR_PREFIX) ? selector.slice(POOL_SELECTOR_PREFIX.length) : void 0;
30545
30545
  }
30546
- function readActiveIdentity(fs21, activeIdentityFile) {
30547
- const trimmed = fs21.readFileUtf8(activeIdentityFile)?.trim();
30546
+ function readActiveIdentity(fs22, activeIdentityFile) {
30547
+ const trimmed = fs22.readFileUtf8(activeIdentityFile)?.trim();
30548
30548
  return trimmed === void 0 || trimmed === "" ? void 0 : trimmed;
30549
30549
  }
30550
30550
  function isNonEmpty(value2) {
@@ -30591,8 +30591,8 @@ function decideConfigProfile(params) {
30591
30591
  }
30592
30592
  return { source: "none" };
30593
30593
  }
30594
- function loadIdentity(identitiesDir, name, fs21) {
30595
- return loadConfigFile(import_node_path10.default.join(identitiesDir, name, "identity.json"), IdentitySchema, fs21.readConfigFile);
30594
+ function loadIdentity(identitiesDir, name, fs22) {
30595
+ return loadConfigFile(import_node_path10.default.join(identitiesDir, name, "identity.json"), IdentitySchema, fs22.readConfigFile);
30596
30596
  }
30597
30597
  var import_node_path10, IDENTITY_DECISION_SOURCES, CONFIG_PROFILE_DECISION_SOURCES;
30598
30598
  var init_identity = __esm({
@@ -31996,8 +31996,8 @@ var init_pipeline = __esm({
31996
31996
  });
31997
31997
 
31998
31998
  // src/launcher/farm.ts
31999
- function readFarmManifest(fs21, farmRoot) {
32000
- const raw = fs21.readFileUtf8(import_node_path18.default.join(farmRoot, FARM_MANIFEST_FILENAME)) ?? fs21.readFileUtf8(import_node_path18.default.join(farmRoot, LEGACY_FARM_MANIFEST_FILENAME));
31999
+ function readFarmManifest(fs22, farmRoot) {
32000
+ const raw = fs22.readFileUtf8(import_node_path18.default.join(farmRoot, FARM_MANIFEST_FILENAME)) ?? fs22.readFileUtf8(import_node_path18.default.join(farmRoot, LEGACY_FARM_MANIFEST_FILENAME));
32001
32001
  if (raw === void 0) {
32002
32002
  return void 0;
32003
32003
  }
@@ -32055,9 +32055,9 @@ function buildEntryFacts(params) {
32055
32055
  entries
32056
32056
  };
32057
32057
  }
32058
- function listSubtree(fs21, root, rel) {
32058
+ function listSubtree(fs22, root, rel) {
32059
32059
  const absolute = import_node_path18.default.join(root, rel);
32060
- const stat = fs21.lstat(absolute);
32060
+ const stat = fs22.lstat(absolute);
32061
32061
  if (stat === void 0) {
32062
32062
  return [];
32063
32063
  }
@@ -32065,10 +32065,10 @@ function listSubtree(fs21, root, rel) {
32065
32065
  return [{ rel, kind: "symlink" }];
32066
32066
  }
32067
32067
  if (stat.kind === "dir") {
32068
- const children = [...fs21.readdir(absolute)].sort().flatMap((name) => listSubtree(fs21, root, `${rel}/${name}`));
32068
+ const children = [...fs22.readdir(absolute)].sort().flatMap((name) => listSubtree(fs22, root, `${rel}/${name}`));
32069
32069
  return [{ rel, kind: "dir" }, ...children];
32070
32070
  }
32071
- const contentHash = fs21.hashFile(absolute);
32071
+ const contentHash = fs22.hashFile(absolute);
32072
32072
  return [{ rel, kind: "file", ...contentHash === void 0 ? {} : { contentHash } }];
32073
32073
  }
32074
32074
  function topLevelScopeRoots(roots) {
@@ -32082,25 +32082,25 @@ function topLevelScopeRoots(roots) {
32082
32082
  }
32083
32083
  return kept;
32084
32084
  }
32085
- function reconciliationScope(fs21, farmRoot, manifest) {
32085
+ function reconciliationScope(fs22, farmRoot, manifest) {
32086
32086
  if (manifest !== void 0) {
32087
32087
  return topLevelScopeRoots(manifest.materialised);
32088
32088
  }
32089
- return [...fs21.readdir(farmRoot)].filter((name) => name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME && fs21.lstat(import_node_path18.default.join(farmRoot, name))?.kind === "dir").sort();
32089
+ return [...fs22.readdir(farmRoot)].filter((name) => name !== FARM_MANIFEST_FILENAME && name !== LEGACY_FARM_MANIFEST_FILENAME && fs22.lstat(import_node_path18.default.join(farmRoot, name))?.kind === "dir").sort();
32090
32090
  }
32091
- function collectFarmListing(fs21, farmRoot, scopeRoots) {
32092
- return scopeRoots.flatMap((root) => listSubtree(fs21, farmRoot, root));
32091
+ function collectFarmListing(fs22, farmRoot, scopeRoots) {
32092
+ return scopeRoots.flatMap((root) => listSubtree(fs22, farmRoot, root));
32093
32093
  }
32094
- function collectCanonicalCounterparts(fs21, claudeHome, farmListing) {
32094
+ function collectCanonicalCounterparts(fs22, claudeHome, farmListing) {
32095
32095
  const out = [];
32096
32096
  for (const entry of farmListing) {
32097
32097
  const absolute = import_node_path18.default.join(claudeHome, entry.rel);
32098
- const stat = fs21.lstat(absolute);
32098
+ const stat = fs22.lstat(absolute);
32099
32099
  if (stat === void 0) {
32100
32100
  continue;
32101
32101
  }
32102
32102
  if (stat.kind === "file") {
32103
- const contentHash = fs21.hashFile(absolute);
32103
+ const contentHash = fs22.hashFile(absolute);
32104
32104
  out.push({ rel: entry.rel, kind: "file", ...contentHash === void 0 ? {} : { contentHash } });
32105
32105
  continue;
32106
32106
  }
@@ -32536,7 +32536,8 @@ function buildLayoutPaths(root) {
32536
32536
  usageDir: import_node_path19.default.join(root, "usage"),
32537
32537
  usageLogDir: import_node_path19.default.join(root, "usage", "log"),
32538
32538
  usageSnapshotsDir: import_node_path19.default.join(root, "usage", "snapshots"),
32539
- usagePicksFile: import_node_path19.default.join(root, "usage", "picks.json")
32539
+ usagePicksFile: import_node_path19.default.join(root, "usage", "picks.json"),
32540
+ mcpPermissionsFile: import_node_path19.default.join(root, "mcp", "permissions.json")
32540
32541
  };
32541
32542
  }
32542
32543
  function resolveLayoutPaths() {
@@ -33242,7 +33243,7 @@ var init_package = __esm({
33242
33243
  "package.json"() {
33243
33244
  package_default = {
33244
33245
  name: "claude-use",
33245
- version: "9.8.0",
33246
+ version: "9.10.0",
33246
33247
  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.",
33247
33248
  license: "MIT",
33248
33249
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -33355,12 +33356,12 @@ function isIdentityName(name) {
33355
33356
  function claudeJsonPath(identitiesDir, identity) {
33356
33357
  return import_node_path23.default.join(identitiesDir, identity, CLAUDE_JSON);
33357
33358
  }
33358
- function readAccountMetadata(fs21, identitiesDir, identity) {
33359
+ function readAccountMetadata(fs22, identitiesDir, identity) {
33359
33360
  if (!isIdentityName(identity)) {
33360
33361
  throw new Error(`"${identity}" is not a valid identity name.`);
33361
33362
  }
33362
33363
  const file2 = claudeJsonPath(identitiesDir, identity);
33363
- const raw = fs21.readFileUtf8(file2);
33364
+ const raw = fs22.readFileUtf8(file2);
33364
33365
  if (raw === void 0) {
33365
33366
  return void 0;
33366
33367
  }
@@ -33390,19 +33391,19 @@ function readAccountMetadata(fs21, identitiesDir, identity) {
33390
33391
  }
33391
33392
  return account.data;
33392
33393
  }
33393
- function createAccountReader(fs21, identitiesDir) {
33394
+ function createAccountReader(fs22, identitiesDir) {
33394
33395
  const cache = /* @__PURE__ */ new Map();
33395
33396
  return (identity) => {
33396
33397
  if (!isIdentityName(identity)) {
33397
33398
  throw new Error(`"${identity}" is not a valid identity name.`);
33398
33399
  }
33399
- const stat = fs21.lstat(claudeJsonPath(identitiesDir, identity));
33400
+ const stat = fs22.lstat(claudeJsonPath(identitiesDir, identity));
33400
33401
  const stamp = stat === void 0 ? "absent" : `${String(stat.mtimeMs)}:${String(stat.sizeBytes)}`;
33401
33402
  const cached2 = cache.get(identity);
33402
33403
  if (cached2?.stamp === stamp) {
33403
33404
  return cached2.account;
33404
33405
  }
33405
- const account = readAccountMetadata(fs21, identitiesDir, identity);
33406
+ const account = readAccountMetadata(fs22, identitiesDir, identity);
33406
33407
  cache.set(identity, { stamp, account });
33407
33408
  return account;
33408
33409
  };
@@ -33513,11 +33514,11 @@ function identifyRequest(headers) {
33513
33514
  function directOrigin(port) {
33514
33515
  return `http://127.0.0.1:${String(port)}`;
33515
33516
  }
33516
- function parseProviderPath(path50) {
33517
- if (!path50.startsWith(PROVIDER_PATH_PREFIX)) {
33517
+ function parseProviderPath(path51) {
33518
+ if (!path51.startsWith(PROVIDER_PATH_PREFIX)) {
33518
33519
  return void 0;
33519
33520
  }
33520
- const tail = path50.slice(PROVIDER_PATH_PREFIX.length);
33521
+ const tail = path51.slice(PROVIDER_PATH_PREFIX.length);
33521
33522
  const slash = tail.indexOf("/");
33522
33523
  if (slash <= 0) {
33523
33524
  return void 0;
@@ -33843,9 +33844,9 @@ function decoderFor(encoding) {
33843
33844
  return void 0;
33844
33845
  }
33845
33846
  }
33846
- function destinationOf(path50) {
33847
- const scoped = parseProviderPath(path50);
33848
- return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path50 } : { provider: scoped.provider, endpoint: scoped.rest };
33847
+ function destinationOf(path51) {
33848
+ const scoped = parseProviderPath(path51);
33849
+ return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path51 } : { provider: scoped.provider, endpoint: scoped.rest };
33849
33850
  }
33850
33851
  function buildRecord(event, context) {
33851
33852
  const { scan } = context;
@@ -34236,8 +34237,8 @@ function segmentDay(epochMs) {
34236
34237
  function segmentName(day, pid) {
34237
34238
  return `${day}.${String(pid)}.jsonl`;
34238
34239
  }
34239
- function listLogSegments(fs21, logDir) {
34240
- return fs21.readdir(logDir).flatMap((name) => {
34240
+ function listLogSegments(fs22, logDir) {
34241
+ return fs22.readdir(logDir).flatMap((name) => {
34241
34242
  const match = SEGMENT_RE.exec(name);
34242
34243
  const day = match?.[1];
34243
34244
  if (day === void 0) {
@@ -34246,15 +34247,15 @@ function listLogSegments(fs21, logDir) {
34246
34247
  return [{ name, day, endsAt: Date.parse(`${day}T00:00:00.000Z`) + DAY_MS }];
34247
34248
  }).sort((left, right) => left.day.localeCompare(right.day) || left.name.localeCompare(right.name));
34248
34249
  }
34249
- function readUsageLog(fs21, logDir, options = {}) {
34250
+ function readUsageLog(fs22, logDir, options = {}) {
34250
34251
  const { sinceMs } = options;
34251
34252
  const records = [];
34252
34253
  let invalidLines = 0;
34253
- for (const segment of listLogSegments(fs21, logDir)) {
34254
+ for (const segment of listLogSegments(fs22, logDir)) {
34254
34255
  if (sinceMs !== void 0 && segment.endsAt <= sinceMs) {
34255
34256
  continue;
34256
34257
  }
34257
- const contents = fs21.readFileUtf8(import_node_path24.default.join(logDir, segment.name));
34258
+ const contents = fs22.readFileUtf8(import_node_path24.default.join(logDir, segment.name));
34258
34259
  if (contents === void 0) {
34259
34260
  continue;
34260
34261
  }
@@ -34290,9 +34291,9 @@ function snapshotPath(snapshotsDir, identity) {
34290
34291
  }
34291
34292
  return import_node_path24.default.join(snapshotsDir, `${identity}.json`);
34292
34293
  }
34293
- function readUsageSnapshot(fs21, snapshotsDir, identity) {
34294
+ function readUsageSnapshot(fs22, snapshotsDir, identity) {
34294
34295
  const file2 = snapshotPath(snapshotsDir, identity);
34295
- const raw = fs21.readFileUtf8(file2);
34296
+ const raw = fs22.readFileUtf8(file2);
34296
34297
  if (raw === void 0) {
34297
34298
  return void 0;
34298
34299
  }
@@ -34308,8 +34309,8 @@ function readUsageSnapshot(fs21, snapshotsDir, identity) {
34308
34309
  }
34309
34310
  return snapshot.data;
34310
34311
  }
34311
- function listUsageSnapshots(fs21, snapshotsDir) {
34312
- return fs21.readdir(snapshotsDir).flatMap((name) => {
34312
+ function listUsageSnapshots(fs22, snapshotsDir) {
34313
+ return fs22.readdir(snapshotsDir).flatMap((name) => {
34313
34314
  if (!name.endsWith(".json")) {
34314
34315
  return [];
34315
34316
  }
@@ -34317,7 +34318,7 @@ function listUsageSnapshots(fs21, snapshotsDir) {
34317
34318
  if (!isIdentityName(identity)) {
34318
34319
  return [];
34319
34320
  }
34320
- const snapshot = readUsageSnapshot(fs21, snapshotsDir, identity);
34321
+ const snapshot = readUsageSnapshot(fs22, snapshotsDir, identity);
34321
34322
  return snapshot === void 0 ? [] : [snapshot];
34322
34323
  }).sort((left, right) => left.identity.localeCompare(right.identity));
34323
34324
  }
@@ -34391,11 +34392,11 @@ var init_read = __esm({
34391
34392
  });
34392
34393
 
34393
34394
  // src/usage/store.ts
34394
- function pruneUsageLog(fs21, logDir, nowMs) {
34395
+ function pruneUsageLog(fs22, logDir, nowMs) {
34395
34396
  const cutoff = nowMs - USAGE_RETENTION_MS;
34396
- for (const segment of listLogSegments(fs21, logDir)) {
34397
+ for (const segment of listLogSegments(fs22, logDir)) {
34397
34398
  if (segment.endsAt <= cutoff) {
34398
- fs21.removeRecursive(import_node_path25.default.join(logDir, segment.name));
34399
+ fs22.removeRecursive(import_node_path25.default.join(logDir, segment.name));
34399
34400
  }
34400
34401
  }
34401
34402
  }
@@ -34424,7 +34425,7 @@ function foldProviderState(current, record2) {
34424
34425
  };
34425
34426
  }
34426
34427
  function createUsageStore(deps) {
34427
- const { fs: fs21, paths } = deps;
34428
+ const { fs: fs22, paths } = deps;
34428
34429
  let prunedDay;
34429
34430
  const rewriteSnapshot = (identity, fold) => {
34430
34431
  if (!isIdentityName(identity)) {
@@ -34433,7 +34434,7 @@ function createUsageStore(deps) {
34433
34434
  }
34434
34435
  let current;
34435
34436
  try {
34436
- current = readUsageSnapshot(fs21, paths.usageSnapshotsDir, identity);
34437
+ current = readUsageSnapshot(fs22, paths.usageSnapshotsDir, identity);
34437
34438
  } catch (error63) {
34438
34439
  if (!(error63 instanceof UsageSnapshotError)) {
34439
34440
  throw error63;
@@ -34460,8 +34461,8 @@ function createUsageStore(deps) {
34460
34461
  ...account === void 0 ? {} : { account },
34461
34462
  providers
34462
34463
  });
34463
- fs21.mkdirPrivate(paths.usageSnapshotsDir);
34464
- fs21.writeFilePrivate(snapshotPath(paths.usageSnapshotsDir, identity), `${JSON.stringify(snapshot, null, 2)}
34464
+ fs22.mkdirPrivate(paths.usageSnapshotsDir);
34465
+ fs22.writeFilePrivate(snapshotPath(paths.usageSnapshotsDir, identity), `${JSON.stringify(snapshot, null, 2)}
34465
34466
  `);
34466
34467
  deps.publish?.(snapshot);
34467
34468
  return true;
@@ -34470,14 +34471,14 @@ function createUsageStore(deps) {
34470
34471
  record: (input2) => {
34471
34472
  const record2 = UsageRecordSchema.parse(input2);
34472
34473
  const nowMs = deps.now();
34473
- fs21.mkdirPrivate(paths.usageDir);
34474
- fs21.mkdirPrivate(paths.usageLogDir);
34474
+ fs22.mkdirPrivate(paths.usageDir);
34475
+ fs22.mkdirPrivate(paths.usageLogDir);
34475
34476
  const day = segmentDay(nowMs);
34476
34477
  if (prunedDay !== day) {
34477
- pruneUsageLog(fs21, paths.usageLogDir, nowMs);
34478
+ pruneUsageLog(fs22, paths.usageLogDir, nowMs);
34478
34479
  prunedDay = day;
34479
34480
  }
34480
- fs21.appendFilePrivate(import_node_path25.default.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record2)}
34481
+ fs22.appendFilePrivate(import_node_path25.default.join(paths.usageLogDir, segmentName(day, deps.pid)), `${JSON.stringify(record2)}
34481
34482
  `);
34482
34483
  if (record2.identity !== void 0) {
34483
34484
  rewriteSnapshot(record2.identity, (current) => ({ ...current?.providers, [record2.provider]: foldProviderState(current?.providers[record2.provider], record2) }));
@@ -34519,14 +34520,14 @@ var init_store2 = __esm({
34519
34520
  function errorMessage(error63) {
34520
34521
  return error63 instanceof Error ? error63.message : String(error63);
34521
34522
  }
34522
- function loadPoolMembers(fs21, paths, identities, nowMs) {
34523
+ function loadPoolMembers(fs22, paths, identities, nowMs) {
34523
34524
  const windowStartMs = nowMs - FIVE_HOUR_WINDOW_MS;
34524
- const log = readUsageLog(fs21, paths.usageLogDir, { sinceMs: windowStartMs });
34525
+ const log = readUsageLog(fs22, paths.usageLogDir, { sinceMs: windowStartMs });
34525
34526
  return identities.map((identity) => {
34526
34527
  const records = log.records.filter((record2) => record2.identity === identity && record2.provider === ANTHROPIC_PROVIDER && Date.parse(record2.at) >= windowStartMs);
34527
34528
  try {
34528
- const snapshot = readUsageSnapshot(fs21, paths.usageSnapshotsDir, identity);
34529
- const account = readAccountMetadata(fs21, paths.identitiesDir, identity) ?? snapshot?.account;
34529
+ const snapshot = readUsageSnapshot(fs22, paths.usageSnapshotsDir, identity);
34530
+ const account = readAccountMetadata(fs22, paths.identitiesDir, identity) ?? snapshot?.account;
34530
34531
  return { identity, records, ...snapshot === void 0 ? {} : { snapshot }, ...account === void 0 ? {} : { account } };
34531
34532
  } catch (error63) {
34532
34533
  if (error63 instanceof UsageSnapshotError || error63 instanceof AccountMetadataError) {
@@ -34597,9 +34598,9 @@ function nestedMember(input2, nestedName, childStack, sticky) {
34597
34598
  missing: nested.missing
34598
34599
  };
34599
34600
  }
34600
- function readPicksFile(fs21, file2) {
34601
+ function readPicksFile(fs22, file2) {
34601
34602
  const empty = { schemaVersion: SCHEMA_VERSION, picks: {} };
34602
- const raw = fs21.readFileUtf8(file2);
34603
+ const raw = fs22.readFileUtf8(file2);
34603
34604
  if (raw === void 0) {
34604
34605
  return { file: empty };
34605
34606
  }
@@ -34612,17 +34613,17 @@ function readPicksFile(fs21, file2) {
34612
34613
  const result = PicksFileSchema.safeParse(parsed);
34613
34614
  return result.success ? { file: result.data } : { file: empty, problem: `${file2} is not a picks file this agent-shim can read` };
34614
34615
  }
34615
- function readStickyPick(fs21, picksFile, directory) {
34616
- const read = readPicksFile(fs21, picksFile);
34616
+ function readStickyPick(fs22, picksFile, directory) {
34617
+ const read = readPicksFile(fs22, picksFile);
34617
34618
  const entry = read.file.picks[directory];
34618
34619
  return { ...entry === void 0 ? {} : { sticky: entry }, ...read.problem === void 0 ? {} : { problem: read.problem } };
34619
34620
  }
34620
- function recordStickyPick(fs21, picksFile, directory, identity, nowMs) {
34621
- const current = readPicksFile(fs21, picksFile).file.picks;
34621
+ function recordStickyPick(fs22, picksFile, directory, identity, nowMs) {
34622
+ const current = readPicksFile(fs22, picksFile).file.picks;
34622
34623
  const kept = Object.entries(current).filter(([, entry]) => nowMs - Date.parse(entry.at) <= USAGE_RETENTION_MS);
34623
34624
  const next = { schemaVersion: SCHEMA_VERSION, picks: { ...Object.fromEntries(kept), [directory]: { identity, at: new Date(nowMs).toISOString() } } };
34624
- fs21.mkdirPrivate(import_node_path26.default.dirname(picksFile));
34625
- fs21.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
34625
+ fs22.mkdirPrivate(import_node_path26.default.dirname(picksFile));
34626
+ fs22.writeFilePrivate(picksFile, `${JSON.stringify(next, null, 2)}
34626
34627
  `);
34627
34628
  }
34628
34629
  var import_node_path26, PoolGraphError, SCHEMA_VERSION, PickEntrySchema, PicksFileSchema;
@@ -36255,14 +36256,14 @@ var require_util2 = __commonJS({
36255
36256
  }
36256
36257
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
36257
36258
  let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
36258
- let path50 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
36259
+ let path51 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
36259
36260
  if (origin[origin.length - 1] === "/") {
36260
36261
  origin = origin.slice(0, origin.length - 1);
36261
36262
  }
36262
- if (path50 && path50[0] !== "/") {
36263
- path50 = `/${path50}`;
36263
+ if (path51 && path51[0] !== "/") {
36264
+ path51 = `/${path51}`;
36264
36265
  }
36265
- return new URL(`${origin}${path50}`);
36266
+ return new URL(`${origin}${path51}`);
36266
36267
  }
36267
36268
  if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
36268
36269
  throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -37083,9 +37084,9 @@ var require_diagnostics = __commonJS({
37083
37084
  "undici:client:sendHeaders",
37084
37085
  (evt) => {
37085
37086
  const {
37086
- request: { method, path: path50, origin }
37087
+ request: { method, path: path51, origin }
37087
37088
  } = evt;
37088
- debugLog("sending request to %s %s%s", method, origin, path50);
37089
+ debugLog("sending request to %s %s%s", method, origin, path51);
37089
37090
  }
37090
37091
  );
37091
37092
  }
@@ -37103,14 +37104,14 @@ var require_diagnostics = __commonJS({
37103
37104
  "undici:request:headers",
37104
37105
  (evt) => {
37105
37106
  const {
37106
- request: { method, path: path50, origin },
37107
+ request: { method, path: path51, origin },
37107
37108
  response: { statusCode }
37108
37109
  } = evt;
37109
37110
  debugLog(
37110
37111
  "received response to %s %s%s - HTTP %d",
37111
37112
  method,
37112
37113
  origin,
37113
- path50,
37114
+ path51,
37114
37115
  statusCode
37115
37116
  );
37116
37117
  }
@@ -37119,23 +37120,23 @@ var require_diagnostics = __commonJS({
37119
37120
  "undici:request:trailers",
37120
37121
  (evt) => {
37121
37122
  const {
37122
- request: { method, path: path50, origin }
37123
+ request: { method, path: path51, origin }
37123
37124
  } = evt;
37124
- debugLog("trailers received from %s %s%s", method, origin, path50);
37125
+ debugLog("trailers received from %s %s%s", method, origin, path51);
37125
37126
  }
37126
37127
  );
37127
37128
  diagnosticsChannel.subscribe(
37128
37129
  "undici:request:error",
37129
37130
  (evt) => {
37130
37131
  const {
37131
- request: { method, path: path50, origin },
37132
+ request: { method, path: path51, origin },
37132
37133
  error: error63
37133
37134
  } = evt;
37134
37135
  debugLog(
37135
37136
  "request to %s %s%s errored - %s",
37136
37137
  method,
37137
37138
  origin,
37138
- path50,
37139
+ path51,
37139
37140
  error63.message
37140
37141
  );
37141
37142
  }
@@ -37250,7 +37251,7 @@ var require_request = __commonJS({
37250
37251
  var kHandler = /* @__PURE__ */ Symbol("handler");
37251
37252
  var Request2 = class {
37252
37253
  constructor(origin, {
37253
- path: path50,
37254
+ path: path51,
37254
37255
  method,
37255
37256
  body,
37256
37257
  headers,
@@ -37267,11 +37268,11 @@ var require_request = __commonJS({
37267
37268
  maxRedirections,
37268
37269
  typeOfService
37269
37270
  }, handler) {
37270
- if (typeof path50 !== "string") {
37271
+ if (typeof path51 !== "string") {
37271
37272
  throw new InvalidArgumentError2("path must be a string");
37272
- } else if (path50[0] !== "/" && !(path50.startsWith("http://") || path50.startsWith("https://")) && method !== "CONNECT") {
37273
+ } else if (path51[0] !== "/" && !(path51.startsWith("http://") || path51.startsWith("https://")) && method !== "CONNECT") {
37273
37274
  throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
37274
- } else if (invalidPathRegex.test(path50)) {
37275
+ } else if (invalidPathRegex.test(path51)) {
37275
37276
  throw new InvalidArgumentError2("invalid request path");
37276
37277
  }
37277
37278
  if (typeof method !== "string") {
@@ -37346,7 +37347,7 @@ var require_request = __commonJS({
37346
37347
  this.completed = false;
37347
37348
  this.aborted = false;
37348
37349
  this.upgrade = upgrade || null;
37349
- this.path = query ? serializePathWithQuery(path50, query) : path50;
37350
+ this.path = query ? serializePathWithQuery(path51, query) : path51;
37350
37351
  this.origin = origin;
37351
37352
  this.protocol = getProtocolFromUrlString(origin);
37352
37353
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
@@ -42528,7 +42529,7 @@ var require_client_h1 = __commonJS({
42528
42529
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
42529
42530
  }
42530
42531
  function writeH1(client, request7) {
42531
- const { method, path: path50, host, upgrade, blocking, reset } = request7;
42532
+ const { method, path: path51, host, upgrade, blocking, reset } = request7;
42532
42533
  let { body, headers, contentLength } = request7;
42533
42534
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
42534
42535
  if (util2.isFormDataLike(body)) {
@@ -42606,7 +42607,7 @@ var require_client_h1 = __commonJS({
42606
42607
  if (socket.setTypeOfService) {
42607
42608
  socket.setTypeOfService(request7.typeOfService);
42608
42609
  }
42609
- let header = `${method} ${path50} HTTP/1.1\r
42610
+ let header = `${method} ${path51} HTTP/1.1\r
42610
42611
  `;
42611
42612
  if (typeof host === "string") {
42612
42613
  header += `host: ${host}\r
@@ -43285,7 +43286,7 @@ var require_client_h2 = __commonJS({
43285
43286
  const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
43286
43287
  const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
43287
43288
  const session = client[kHTTP2Session];
43288
- const { method, path: path50, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
43289
+ const { method, path: path51, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
43289
43290
  let { body } = request7;
43290
43291
  if (upgrade != null && upgrade !== "websocket") {
43291
43292
  util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
@@ -43354,7 +43355,7 @@ var require_client_h2 = __commonJS({
43354
43355
  }
43355
43356
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
43356
43357
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
43357
- headers[HTTP2_HEADER_PATH] = path50;
43358
+ headers[HTTP2_HEADER_PATH] = path51;
43358
43359
  if (protocol === "ws:" || protocol === "wss:") {
43359
43360
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
43360
43361
  } else {
@@ -43396,7 +43397,7 @@ var require_client_h2 = __commonJS({
43396
43397
  stream.setTimeout(headersTimeout);
43397
43398
  return true;
43398
43399
  }
43399
- headers[HTTP2_HEADER_PATH] = path50;
43400
+ headers[HTTP2_HEADER_PATH] = path51;
43400
43401
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
43401
43402
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
43402
43403
  if (body && typeof body.read === "function") {
@@ -45748,10 +45749,10 @@ var require_proxy_agent = __commonJS({
45748
45749
  };
45749
45750
  const {
45750
45751
  origin,
45751
- path: path50 = "/",
45752
+ path: path51 = "/",
45752
45753
  headers = {}
45753
45754
  } = opts;
45754
- opts.path = origin + path50;
45755
+ opts.path = origin + path51;
45755
45756
  if (!("host" in headers) && !("Host" in headers)) {
45756
45757
  const { host } = new URL(origin);
45757
45758
  headers.host = host;
@@ -47860,20 +47861,20 @@ var require_mock_utils = __commonJS({
47860
47861
  }
47861
47862
  return normalizedQp;
47862
47863
  }
47863
- function safeUrl(path50) {
47864
- if (typeof path50 !== "string") {
47865
- return path50;
47864
+ function safeUrl(path51) {
47865
+ if (typeof path51 !== "string") {
47866
+ return path51;
47866
47867
  }
47867
- const pathSegments = path50.split("?", 3);
47868
+ const pathSegments = path51.split("?", 3);
47868
47869
  if (pathSegments.length !== 2) {
47869
- return path50;
47870
+ return path51;
47870
47871
  }
47871
47872
  const qp2 = new URLSearchParams(pathSegments.pop());
47872
47873
  qp2.sort();
47873
47874
  return [...pathSegments, qp2.toString()].join("?");
47874
47875
  }
47875
- function matchKey(mockDispatch2, { path: path50, method, body, headers }) {
47876
- const pathMatch = matchValue(mockDispatch2.path, path50);
47876
+ function matchKey(mockDispatch2, { path: path51, method, body, headers }) {
47877
+ const pathMatch = matchValue(mockDispatch2.path, path51);
47877
47878
  const methodMatch = matchValue(mockDispatch2.method, method);
47878
47879
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
47879
47880
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -47898,8 +47899,8 @@ var require_mock_utils = __commonJS({
47898
47899
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
47899
47900
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
47900
47901
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
47901
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path50, ignoreTrailingSlash }) => {
47902
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path50)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path50), resolvedPath);
47902
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path51, ignoreTrailingSlash }) => {
47903
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path51)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path51), resolvedPath);
47903
47904
  });
47904
47905
  if (matchedMockDispatches.length === 0) {
47905
47906
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -47938,19 +47939,19 @@ var require_mock_utils = __commonJS({
47938
47939
  mockDispatches.splice(index, 1);
47939
47940
  }
47940
47941
  }
47941
- function removeTrailingSlash(path50) {
47942
- while (path50.endsWith("/")) {
47943
- path50 = path50.slice(0, -1);
47942
+ function removeTrailingSlash(path51) {
47943
+ while (path51.endsWith("/")) {
47944
+ path51 = path51.slice(0, -1);
47944
47945
  }
47945
- if (path50.length === 0) {
47946
- path50 = "/";
47946
+ if (path51.length === 0) {
47947
+ path51 = "/";
47947
47948
  }
47948
- return path50;
47949
+ return path51;
47949
47950
  }
47950
47951
  function buildKey(opts) {
47951
- const { path: path50, method, body, headers, query } = opts;
47952
+ const { path: path51, method, body, headers, query } = opts;
47952
47953
  return {
47953
- path: path50,
47954
+ path: path51,
47954
47955
  method,
47955
47956
  body,
47956
47957
  headers,
@@ -48640,10 +48641,10 @@ var require_pending_interceptors_formatter = __commonJS({
48640
48641
  }
48641
48642
  format(pendingInterceptors) {
48642
48643
  const withPrettyHeaders = pendingInterceptors.map(
48643
- ({ method, path: path50, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
48644
+ ({ method, path: path51, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
48644
48645
  Method: method,
48645
48646
  Origin: origin,
48646
- Path: path50,
48647
+ Path: path51,
48647
48648
  "Status code": statusCode,
48648
48649
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
48649
48650
  Invocations: timesInvoked,
@@ -48725,9 +48726,9 @@ var require_mock_agent = __commonJS({
48725
48726
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
48726
48727
  const dispatchOpts = { ...opts };
48727
48728
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
48728
- const [path50, searchParams] = dispatchOpts.path.split("?");
48729
+ const [path51, searchParams] = dispatchOpts.path.split("?");
48729
48730
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
48730
- dispatchOpts.path = `${path50}?${normalizedSearchParams}`;
48731
+ dispatchOpts.path = `${path51}?${normalizedSearchParams}`;
48731
48732
  }
48732
48733
  return this[kAgent].dispatch(dispatchOpts, handler);
48733
48734
  }
@@ -49128,12 +49129,12 @@ var require_snapshot_recorder = __commonJS({
49128
49129
  * @return {Promise<void>} - Resolves when snapshots are loaded
49129
49130
  */
49130
49131
  async loadSnapshots(filePath) {
49131
- const path50 = filePath || this.#snapshotPath;
49132
- if (!path50) {
49132
+ const path51 = filePath || this.#snapshotPath;
49133
+ if (!path51) {
49133
49134
  throw new InvalidArgumentError2("Snapshot path is required");
49134
49135
  }
49135
49136
  try {
49136
- const data = await readFile(resolve2(path50), "utf8");
49137
+ const data = await readFile(resolve2(path51), "utf8");
49137
49138
  const parsed = JSON.parse(data);
49138
49139
  if (Array.isArray(parsed)) {
49139
49140
  this.#snapshots.clear();
@@ -49147,7 +49148,7 @@ var require_snapshot_recorder = __commonJS({
49147
49148
  if (error63.code === "ENOENT") {
49148
49149
  this.#snapshots.clear();
49149
49150
  } else {
49150
- throw new UndiciError(`Failed to load snapshots from ${path50}`, { cause: error63 });
49151
+ throw new UndiciError(`Failed to load snapshots from ${path51}`, { cause: error63 });
49151
49152
  }
49152
49153
  }
49153
49154
  }
@@ -49158,11 +49159,11 @@ var require_snapshot_recorder = __commonJS({
49158
49159
  * @returns {Promise<void>} - Resolves when snapshots are saved
49159
49160
  */
49160
49161
  async saveSnapshots(filePath) {
49161
- const path50 = filePath || this.#snapshotPath;
49162
- if (!path50) {
49162
+ const path51 = filePath || this.#snapshotPath;
49163
+ if (!path51) {
49163
49164
  throw new InvalidArgumentError2("Snapshot path is required");
49164
49165
  }
49165
- const resolvedPath = resolve2(path50);
49166
+ const resolvedPath = resolve2(path51);
49166
49167
  await mkdir(dirname3(resolvedPath), { recursive: true });
49167
49168
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
49168
49169
  hash: hash2,
@@ -49794,15 +49795,15 @@ var require_redirect_handler = __commonJS({
49794
49795
  return;
49795
49796
  }
49796
49797
  const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
49797
- const path50 = search ? `${pathname}${search}` : pathname;
49798
- const redirectUrlString = `${origin}${path50}`;
49798
+ const path51 = search ? `${pathname}${search}` : pathname;
49799
+ const redirectUrlString = `${origin}${path51}`;
49799
49800
  for (const historyUrl of this.history) {
49800
49801
  if (historyUrl.toString() === redirectUrlString) {
49801
49802
  throw new InvalidArgumentError2(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
49802
49803
  }
49803
49804
  }
49804
49805
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
49805
- this.opts.path = path50;
49806
+ this.opts.path = path51;
49806
49807
  this.opts.origin = origin;
49807
49808
  this.opts.query = null;
49808
49809
  }
@@ -51562,10 +51563,10 @@ var require_cache_handler = __commonJS({
51562
51563
  }
51563
51564
  return locationUrl.pathname + locationUrl.search;
51564
51565
  }
51565
- function deleteCachedUri(store, cacheKey, path50) {
51566
+ function deleteCachedUri(store, cacheKey, path51) {
51566
51567
  deleteCachedValue(store, {
51567
51568
  ...cacheKey,
51568
- path: path50
51569
+ path: path51
51569
51570
  });
51570
51571
  for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
51571
51572
  const method = util2.safeHTTPMethods[i10];
@@ -51573,7 +51574,7 @@ var require_cache_handler = __commonJS({
51573
51574
  deleteCachedValue(store, {
51574
51575
  ...cacheKey,
51575
51576
  method,
51576
- path: path50
51577
+ path: path51
51577
51578
  });
51578
51579
  }
51579
51580
  }
@@ -51584,9 +51585,9 @@ var require_cache_handler = __commonJS({
51584
51585
  }
51585
51586
  const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
51586
51587
  for (let i10 = 0; i10 < values.length; i10++) {
51587
- const path50 = getSameOriginPath(cacheKey, values[i10]);
51588
- if (path50 !== void 0) {
51589
- deleteCachedUri(store, cacheKey, path50);
51588
+ const path51 = getSameOriginPath(cacheKey, values[i10]);
51589
+ if (path51 !== void 0) {
51590
+ deleteCachedUri(store, cacheKey, path51);
51590
51591
  }
51591
51592
  }
51592
51593
  }
@@ -56586,11 +56587,11 @@ var require_fetch = __commonJS({
56586
56587
  function dispatch({ body }) {
56587
56588
  const url2 = requestCurrentURL(request7);
56588
56589
  const agent = fetchParams.controller.dispatcher;
56589
- const path50 = url2.pathname + url2.search;
56590
+ const path51 = url2.pathname + url2.search;
56590
56591
  const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
56591
56592
  return new Promise((resolve2, reject) => agent.dispatch(
56592
56593
  {
56593
- path: hasTrailingQuestionMark ? `${path50}?` : path50,
56594
+ path: hasTrailingQuestionMark ? `${path51}?` : path51,
56594
56595
  origin: url2.origin,
56595
56596
  method: request7.method,
56596
56597
  body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
@@ -57537,9 +57538,9 @@ var require_util5 = __commonJS({
57537
57538
  }
57538
57539
  }
57539
57540
  }
57540
- function validateCookiePath(path50) {
57541
- for (let i10 = 0; i10 < path50.length; ++i10) {
57542
- const code = path50.charCodeAt(i10);
57541
+ function validateCookiePath(path51) {
57542
+ for (let i10 = 0; i10 < path51.length; ++i10) {
57543
+ const code = path51.charCodeAt(i10);
57543
57544
  if (code < 32 || // exclude CTLs (0-31)
57544
57545
  code > 126 || // exclude DEL and non-ascii
57545
57546
  code === 59) {
@@ -60887,11 +60888,11 @@ var require_undici = __commonJS({
60887
60888
  if (typeof opts.path !== "string") {
60888
60889
  throw new InvalidArgumentError2("invalid opts.path");
60889
60890
  }
60890
- let path50 = opts.path;
60891
+ let path51 = opts.path;
60891
60892
  if (!opts.path.startsWith("/")) {
60892
- path50 = `/${path50}`;
60893
+ path51 = `/${path51}`;
60893
60894
  }
60894
- url2 = new URL(util2.parseOrigin(url2).origin + path50);
60895
+ url2 = new URL(util2.parseOrigin(url2).origin + path51);
60895
60896
  } else {
60896
60897
  if (!opts) {
60897
60898
  opts = typeof url2 === "object" ? url2 : {};
@@ -61172,14 +61173,14 @@ request.on("error", (error) => finish(failed, (error.code ? error.code + ": " :
61172
61173
 
61173
61174
  // src/frontdoor/trust.ts
61174
61175
  function resolveTrustBundle(params) {
61175
- const { caCertFile, bundlesDir, variable, inherited, fs: fs21 } = params;
61176
+ const { caCertFile, bundlesDir, variable, inherited, fs: fs22 } = params;
61176
61177
  if (inherited === void 0 || inherited === "" || import_node_path32.default.resolve(inherited) === import_node_path32.default.resolve(caCertFile)) {
61177
61178
  return { path: caCertFile };
61178
61179
  }
61179
- const caPem = fs21.readFileUtf8(caCertFile);
61180
+ const caPem = fs22.readFileUtf8(caCertFile);
61180
61181
  let inheritedPem;
61181
61182
  try {
61182
- inheritedPem = fs21.readFileUtf8(inherited);
61183
+ inheritedPem = fs22.readFileUtf8(inherited);
61183
61184
  } catch (error63) {
61184
61185
  return {
61185
61186
  path: caCertFile,
@@ -61192,9 +61193,9 @@ function resolveTrustBundle(params) {
61192
61193
  const combined = `${inheritedPem.trimEnd()}
61193
61194
  ${caPem}`;
61194
61195
  const bundle = import_node_path32.default.join(bundlesDir, `${(0, import_node_crypto11.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
61195
- if (!fs21.exists(bundle)) {
61196
- fs21.mkdirp(bundlesDir);
61197
- fs21.writeFileAtomic(bundle, combined);
61196
+ if (!fs22.exists(bundle)) {
61197
+ fs22.mkdirp(bundlesDir);
61198
+ fs22.writeFileAtomic(bundle, combined);
61198
61199
  }
61199
61200
  return { path: bundle };
61200
61201
  }
@@ -61356,20 +61357,20 @@ function lockHolder(contents) {
61356
61357
  const pid = Number((contents ?? "").trim());
61357
61358
  return Number.isInteger(pid) && pid > 0 ? pid : void 0;
61358
61359
  }
61359
- function acquireUpdateLock(fs21, isProcessAlive, pid, lockPath) {
61360
- const take = () => fs21.writeFileExclusive(lockPath, `${String(pid)}
61360
+ function acquireUpdateLock(fs22, isProcessAlive, pid, lockPath) {
61361
+ const take = () => fs22.writeFileExclusive(lockPath, `${String(pid)}
61361
61362
  `);
61362
61363
  const release = () => {
61363
- fs21.unlink(lockPath);
61364
+ fs22.unlink(lockPath);
61364
61365
  };
61365
61366
  if (take()) {
61366
61367
  return release;
61367
61368
  }
61368
- const holder = lockHolder(fs21.readFileUtf8(lockPath));
61369
+ const holder = lockHolder(fs22.readFileUtf8(lockPath));
61369
61370
  if (holder !== void 0 && holder !== pid && isProcessAlive(holder)) {
61370
61371
  throw new UpdateConflictError(`another agent-shim update (pid ${String(holder)}) is already running`);
61371
61372
  }
61372
- fs21.unlink(lockPath);
61373
+ fs22.unlink(lockPath);
61373
61374
  if (!take()) {
61374
61375
  throw new UpdateConflictError("another agent-shim update took the lock while it was being replaced");
61375
61376
  }
@@ -62250,7 +62251,7 @@ function resolveIdentityCredential(identity, credential, env, port) {
62250
62251
  return resolution.ok ? resolution : { ok: false, status: CREDENTIAL_UNAVAILABLE_EXIT, message: resolution.message };
62251
62252
  }
62252
62253
  function pickFromPool(decided, params, parsedArgv, readOnly) {
62253
- const { paths, fs: fs21, proc, log } = params;
62254
+ const { paths, fs: fs22, proc, log } = params;
62254
62255
  if (decided.pool === void 0) {
62255
62256
  return { identityDecision: decided };
62256
62257
  }
@@ -62264,7 +62265,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
62264
62265
  selectedVia: decided.source,
62265
62266
  pools: params.pools,
62266
62267
  paths,
62267
- fs: fs21,
62268
+ fs: fs22,
62268
62269
  usageFs: farmRuntime.fs,
62269
62270
  cwd: farmRuntime.cwd,
62270
62271
  now: farmRuntime.now,
@@ -62286,7 +62287,7 @@ function pickFromPool(decided, params, parsedArgv, readOnly) {
62286
62287
  };
62287
62288
  }
62288
62289
  function decideLaunch(params, readOnly) {
62289
- const { paths, fs: fs21, proc, log } = params;
62290
+ const { paths, fs: fs22, proc, log } = params;
62290
62291
  const { env, argv } = proc;
62291
62292
  const parsedArgv = parseLauncherArgv(argv);
62292
62293
  const cliOverride = buildCliOverride({
@@ -62301,7 +62302,7 @@ function decideLaunch(params, readOnly) {
62301
62302
  argv0Identity: parsedArgv.identity,
62302
62303
  directoryPinnedIdentity: params.directoryPinnedIdentity,
62303
62304
  readActiveIdentityFile: () => {
62304
- const raw = fs21.readFileUtf8(paths.activeIdentityFile);
62305
+ const raw = fs22.readFileUtf8(paths.activeIdentityFile);
62305
62306
  if (raw === void 0) {
62306
62307
  return void 0;
62307
62308
  }
@@ -62336,7 +62337,7 @@ function decideLaunch(params, readOnly) {
62336
62337
  }
62337
62338
  let loadedIdentity;
62338
62339
  if (identityDecision.name !== void 0) {
62339
- loadedIdentity = loadIdentity(paths.identitiesDir, identityDecision.name, fs21);
62340
+ loadedIdentity = loadIdentity(paths.identitiesDir, identityDecision.name, fs22);
62340
62341
  if (loadedIdentity === void 0) {
62341
62342
  log.error(
62342
62343
  `agent-shim: no identity named "${identityDecision.name}" (selected via ${identityDecision.source}). Run \`agent-shim identity add ${identityDecision.name}\` first.`
@@ -62351,7 +62352,7 @@ function decideLaunch(params, readOnly) {
62351
62352
  identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
62352
62353
  globalDefaultConfigProfile: params.globalDefaultConfigProfile
62353
62354
  });
62354
- if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs21.readConfigFile(import_node_path36.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
62355
+ if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs22.readConfigFile(import_node_path36.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
62355
62356
  log.error(
62356
62357
  `agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
62357
62358
  );
@@ -62360,7 +62361,7 @@ function decideLaunch(params, readOnly) {
62360
62361
  const farmContext = farm !== void 0 && farmIdentity !== void 0 ? { farm, identity: farmIdentity, cascade: farm.loadCascade(configProfileDecision.name, cliOverride) } : void 0;
62361
62362
  const providerParams = {
62362
62363
  paths,
62363
- port: fs21,
62364
+ port: fs22,
62364
62365
  ...parsedArgv.provider === void 0 || parsedArgv.provider === false ? {} : { cliProvider: parsedArgv.provider },
62365
62366
  ...farmContext === void 0 ? {} : { cascade: farmContext.cascade }
62366
62367
  };
@@ -99847,8 +99848,8 @@ var require_utils3 = __commonJS({
99847
99848
  }
99848
99849
  return ind;
99849
99850
  }
99850
- function removeDotSegments(path50) {
99851
- let input2 = path50;
99851
+ function removeDotSegments(path51) {
99852
+ let input2 = path51;
99852
99853
  const output2 = [];
99853
99854
  let nextSlash = -1;
99854
99855
  let len = 0;
@@ -100257,8 +100258,8 @@ var require_schemes = __commonJS({
100257
100258
  }
100258
100259
  if (wsComponent.resourceName) {
100259
100260
  const queryIndex = wsComponent.resourceName.indexOf("?");
100260
- const path50 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
100261
- wsComponent.path = path50 && path50 !== "/" ? path50 : void 0;
100261
+ const path51 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
100262
+ wsComponent.path = path51 && path51 !== "/" ? path51 : void 0;
100262
100263
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
100263
100264
  wsComponent.resourceName = void 0;
100264
100265
  }
@@ -103771,12 +103772,12 @@ var require_dist2 = __commonJS({
103771
103772
  throw new Error(`Unknown format "${name}"`);
103772
103773
  return f;
103773
103774
  };
103774
- function addFormats(ajv, list, fs21, exportName) {
103775
+ function addFormats(ajv, list, fs22, exportName) {
103775
103776
  var _a4;
103776
103777
  var _b2;
103777
103778
  (_a4 = (_b2 = ajv.opts.code).formats) !== null && _a4 !== void 0 ? _a4 : _b2.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
103778
103779
  for (const f of list)
103779
- ajv.addFormat(f, fs21[f]);
103780
+ ajv.addFormat(f, fs22[f]);
103780
103781
  }
103781
103782
  module2.exports = exports2 = formatsPlugin;
103782
103783
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -103785,7 +103786,7 @@ var require_dist2 = __commonJS({
103785
103786
  });
103786
103787
 
103787
103788
  // src/cli.ts
103788
- var import_node_path49 = __toESM(require("node:path"), 1);
103789
+ var import_node_path50 = __toESM(require("node:path"), 1);
103789
103790
 
103790
103791
  // node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
103791
103792
  var CommanderError = class extends Error {
@@ -106898,9 +106899,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
106898
106899
  * @param {string} [path]
106899
106900
  * @return {(string|null|Command)}
106900
106901
  */
106901
- executableDir(path50) {
106902
- if (path50 === void 0) return this._executableDir;
106903
- this._executableDir = path50;
106902
+ executableDir(path51) {
106903
+ if (path51 === void 0) return this._executableDir;
106904
+ this._executableDir = path51;
106904
106905
  return this;
106905
106906
  }
106906
106907
  /**
@@ -108549,19 +108550,19 @@ function writePools(paths, pools) {
108549
108550
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
108550
108551
  }
108551
108552
  function poolCycleOf(pools, name) {
108552
- const walk = (current, path50) => {
108553
+ const walk = (current, path51) => {
108553
108554
  for (const entry of pools[current]?.identities ?? []) {
108554
108555
  const nested = poolNameOf(poolMemberIdentity(entry));
108555
108556
  if (nested === void 0) {
108556
108557
  continue;
108557
108558
  }
108558
108559
  if (nested === name) {
108559
- return [...path50, nested];
108560
+ return [...path51, nested];
108560
108561
  }
108561
- if (path50.includes(nested)) {
108562
+ if (path51.includes(nested)) {
108562
108563
  continue;
108563
108564
  }
108564
- const found = walk(nested, [...path50, nested]);
108565
+ const found = walk(nested, [...path51, nested]);
108565
108566
  if (found !== void 0) {
108566
108567
  return found;
108567
108568
  }
@@ -112181,9 +112182,9 @@ var FRONTDOOR_SUPERVISOR_STILL_RUNNING = -1;
112181
112182
  var FRONTDOOR_POLL_MS = 1e3;
112182
112183
  var MS_PER_MINUTE2 = 6e4;
112183
112184
  async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {}) {
112184
- const { fs: fs21, paths } = ports;
112185
+ const { fs: fs22, paths } = ports;
112185
112186
  const servingBinary = ports.statOwnExecutable();
112186
- const previous = readFrontDoorState(fs21, paths.frontdoorStateFile);
112187
+ const previous = readFrontDoorState(fs22, paths.frontdoorStateFile);
112187
112188
  let lastPort = previous?.lastPort;
112188
112189
  let lastConnectPort = previous?.lastConnectPort;
112189
112190
  let lastDirectPort = previous?.lastDirectPort;
@@ -112194,12 +112195,12 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112194
112195
  });
112195
112196
  const fail = (message) => {
112196
112197
  ports.closeRcStreamHub();
112197
- writeFrontDoorState(fs21, paths.frontdoorStateFile, { lastError: message, ...sticky() });
112198
- fs21.removeRecursive(paths.frontdoorLockFile);
112198
+ writeFrontDoorState(fs22, paths.frontdoorStateFile, { lastError: message, ...sticky() });
112199
+ fs22.removeRecursive(paths.frontdoorLockFile);
112199
112200
  ports.log(`agent-shim frontdoor supervisor: ${message}`);
112200
112201
  return 1;
112201
112202
  };
112202
- writeFrontDoorState(fs21, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, ...sticky() });
112203
+ writeFrontDoorState(fs22, paths.frontdoorStateFile, { supervisorPid: ports.ownPid, ...sticky() });
112203
112204
  const previousSticky = lastPort;
112204
112205
  let http8;
112205
112206
  try {
@@ -112239,9 +112240,9 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112239
112240
  ports.log(`agent-shim frontdoor supervisor: sticky direct port ${String(previousStickyDirect)} was occupied; moving to ${String(direct.port)} (headroom must be restarted to admit the new address)`);
112240
112241
  }
112241
112242
  lastDirectPort = direct.port;
112242
- writeFrontDoorState(fs21, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http8.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
112243
+ writeFrontDoorState(fs22, paths.frontdoorStateFile, { protocol: FRONT_DOOR_PROTOCOL, supervisorPid: ports.ownPid, port: http8.port, connectPort: connect3.port, directPort: direct.port, ...sticky() });
112243
112244
  ports.doorHealth.generation({ providerPort: http8.port, connectPort: connect3.port, directPort: direct.port });
112244
- fs21.removeRecursive(paths.frontdoorLockFile);
112245
+ fs22.removeRecursive(paths.frontdoorLockFile);
112245
112246
  ports.log(`agent-shim frontdoor supervisor ${String(ports.ownPid)}: front door on 127.0.0.1:${String(http8.port)}, CONNECT surface on 127.0.0.1:${String(connect3.port)}`);
112246
112247
  let idleSince;
112247
112248
  let ticks = 0;
@@ -112254,7 +112255,7 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112254
112255
  await connect3.close();
112255
112256
  await http8.close();
112256
112257
  ports.closeRcStreamHub();
112257
- writeFrontDoorState(fs21, paths.frontdoorStateFile, sticky());
112258
+ writeFrontDoorState(fs22, paths.frontdoorStateFile, sticky());
112258
112259
  return 0;
112259
112260
  };
112260
112261
  for (; ; ) {
@@ -112262,8 +112263,8 @@ async function runFrontDoorSupervisor(idleShutdownMinutes, ports, options = {})
112262
112263
  return FRONTDOOR_SUPERVISOR_STILL_RUNNING;
112263
112264
  }
112264
112265
  ticks += 1;
112265
- const listed = listFrontDoorSessions(fs21, paths.frontdoorSessionsDir);
112266
- const pruned = pruneDeadFrontDoorSessions(fs21, paths.frontdoorSessionsDir, ports.isRunning);
112266
+ const listed = listFrontDoorSessions(fs22, paths.frontdoorSessionsDir);
112267
+ const pruned = pruneDeadFrontDoorSessions(fs22, paths.frontdoorSessionsDir, ports.isRunning);
112267
112268
  ports.observeLaunchRegistry(listed, pruned);
112268
112269
  ports.checkQuotaExpiry();
112269
112270
  const prunedPids = new Set(pruned);
@@ -112329,8 +112330,8 @@ function parseConnectTarget(authority) {
112329
112330
  }
112330
112331
  return { host, port };
112331
112332
  }
112332
- function servedByPipeline(path50) {
112333
- return path50?.startsWith(ROUTED_PATH_PREFIX) === true;
112333
+ function servedByPipeline(path51) {
112334
+ return path51?.startsWith(ROUTED_PATH_PREFIX) === true;
112334
112335
  }
112335
112336
  var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
112336
112337
  "connection",
@@ -112849,11 +112850,11 @@ function createRcSessionTracker(deps) {
112849
112850
  };
112850
112851
  const observeExchange = (request7) => {
112851
112852
  const method = (request7.method ?? "").toUpperCase();
112852
- const path50 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
112853
- if (!path50.startsWith(RC_SESSIONS_PATH_PREFIX)) {
112853
+ const path51 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
112854
+ if (!path51.startsWith(RC_SESSIONS_PATH_PREFIX)) {
112854
112855
  return void 0;
112855
112856
  }
112856
- const tail = path50.slice(RC_SESSIONS_PATH_PREFIX.length);
112857
+ const tail = path51.slice(RC_SESSIONS_PATH_PREFIX.length);
112857
112858
  const facts = {
112858
112859
  oauthAuthorization: oauthAuthorizationOf(request7.headers),
112859
112860
  anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
@@ -113214,8 +113215,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
113214
113215
  function isRcReadFileEncoding(value2) {
113215
113216
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
113216
113217
  }
113217
- function buildRcReadFilePayload(requestId, path50, options) {
113218
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path50, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
113218
+ function buildRcReadFilePayload(requestId, path51, options) {
113219
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path51, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
113219
113220
  }
113220
113221
  function buildRcFileSuggestionsPayload(requestId, query) {
113221
113222
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -113317,15 +113318,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
113317
113318
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
113318
113319
  return result.ok ? { ...result, requestId } : result;
113319
113320
  }
113320
- async function readRcSessionFile(deps, sessionId, path50, options) {
113321
- if (path50 === "") {
113321
+ async function readRcSessionFile(deps, sessionId, path51, options) {
113322
+ if (path51 === "") {
113322
113323
  return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
113323
113324
  }
113324
113325
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
113325
113326
  return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
113326
113327
  }
113327
113328
  const requestId = deps.newUuid();
113328
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path50, options), `read ${path50} from session ${sessionId}`);
113329
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path51, options), `read ${path51} from session ${sessionId}`);
113329
113330
  return result.ok ? { ...result, requestId } : result;
113330
113331
  }
113331
113332
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -113496,11 +113497,11 @@ function createRcControlHandler(deps) {
113496
113497
  path: "read-file",
113497
113498
  read: (body) => {
113498
113499
  const session = bodyString(body, "session");
113499
- const path50 = bodyString(body, "path");
113500
+ const path51 = bodyString(body, "path");
113500
113501
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
113501
113502
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
113502
- const refused2 = session === void 0 || path50 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
113503
- return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path50, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
113503
+ const refused2 = session === void 0 || path51 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
113504
+ return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path51, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
113504
113505
  }
113505
113506
  },
113506
113507
  {
@@ -113810,9 +113811,9 @@ function requestIdOfBody(body) {
113810
113811
  }
113811
113812
  function frontDoorRcControl(transport, token) {
113812
113813
  const headers = { authorization: `Bearer ${token}` };
113813
- const listAnswerOf = async (path50, what) => {
113814
+ const listAnswerOf = async (path51, what) => {
113814
113815
  try {
113815
- return await transport.request({ method: "GET", path: path50, headers });
113816
+ return await transport.request({ method: "GET", path: path51, headers });
113816
113817
  } catch (error63) {
113817
113818
  throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
113818
113819
  }
@@ -113884,10 +113885,10 @@ function frontDoorRcControl(transport, token) {
113884
113885
  }
113885
113886
  return pending;
113886
113887
  };
113887
- const writeOf = async (path50, body, describeFailure) => {
113888
+ const writeOf = async (path51, body, describeFailure) => {
113888
113889
  let answer;
113889
113890
  try {
113890
- answer = await transport.request({ method: "POST", path: path50, headers: { ...headers, "content-type": "application/json" }, body });
113891
+ answer = await transport.request({ method: "POST", path: path51, headers: { ...headers, "content-type": "application/json" }, body });
113891
113892
  } catch (error63) {
113892
113893
  return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
113893
113894
  }
@@ -113918,10 +113919,10 @@ function frontDoorRcControl(transport, token) {
113918
113919
  endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
113919
113920
  getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
113920
113921
  getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
113921
- readFile: async (sessionId, path50, options) => await writeOf(
113922
+ readFile: async (sessionId, path51, options) => await writeOf(
113922
113923
  `${CONTROL_PATH_PREFIX}/read-file`,
113923
- JSON.stringify({ session: sessionId, path: path50, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
113924
- (status, message) => `reading ${path50} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
113924
+ JSON.stringify({ session: sessionId, path: path51, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
113925
+ (status, message) => `reading ${path51} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
113925
113926
  ),
113926
113927
  fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
113927
113928
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -114215,12 +114216,12 @@ function tlsFacts(options) {
114215
114216
  }
114216
114217
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
114217
114218
  const agent = new ExemptTlsAgent();
114218
- const post = async (path50, headers, body) => await new Promise((resolve2, reject) => {
114219
+ const post = async (path51, headers, body) => await new Promise((resolve2, reject) => {
114219
114220
  const options = {
114220
114221
  host: target.host,
114221
114222
  port: target.port,
114222
114223
  method: "POST",
114223
- path: path50,
114224
+ path: path51,
114224
114225
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
114225
114226
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
114226
114227
  agent
@@ -114285,12 +114286,12 @@ function lateRcStreamDial(resolve2) {
114285
114286
  }
114286
114287
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
114287
114288
  const agent = new ExemptTlsAgent();
114288
- const request7 = async (method, path50, headers, body, signal) => await new Promise((resolve2, reject) => {
114289
+ const request7 = async (method, path51, headers, body, signal) => await new Promise((resolve2, reject) => {
114289
114290
  const options = {
114290
114291
  host: target.host,
114291
114292
  port: target.port,
114292
114293
  method,
114293
- path: path50,
114294
+ path: path51,
114294
114295
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
114295
114296
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
114296
114297
  agent,
@@ -114332,9 +114333,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
114332
114333
  return { status, body: await readAll(response) };
114333
114334
  },
114334
114335
  openStream: async (sessionId, headers, resume, signal) => {
114335
- const path50 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
114336
+ const path51 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
114336
114337
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
114337
- const { status, response } = await request7("GET", path50, streamHeaders, void 0, signal);
114338
+ const { status, response } = await request7("GET", path51, streamHeaders, void 0, signal);
114338
114339
  if (!isSuccessful2(status)) {
114339
114340
  await readAll(response);
114340
114341
  return { status, chunks: NO_CHUNKS };
@@ -114573,12 +114574,12 @@ function decideSignIn(facts) {
114573
114574
  function credentialsFilePath(farmRoot) {
114574
114575
  return import_node_path39.default.join(farmRoot, CREDENTIALS_FILE);
114575
114576
  }
114576
- function identitySignIn(fs21, probe, identity) {
114577
+ function identitySignIn(fs22, probe, identity) {
114577
114578
  const probing = !identity.hasCredentialBlock;
114578
114579
  return decideSignIn({
114579
114580
  hasCredentialBlock: identity.hasCredentialBlock,
114580
114581
  keychainItem: probing && probe.platform === "darwin" && probe.run !== void 0 ? keychainHasItem(probe.run, identity.farmRoot) : void 0,
114581
- credentialsFile: probing && fs21.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
114582
+ credentialsFile: probing && fs22.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
114582
114583
  platform: probe.platform
114583
114584
  });
114584
114585
  }
@@ -115422,11 +115423,11 @@ function tryOrUndefined(fn2) {
115422
115423
  return void 0;
115423
115424
  }
115424
115425
  }
115425
- function pathToHttpPath(path50) {
115426
- return `/${path50.map(safeEncodeURIComponent).join("/")}`;
115426
+ function pathToHttpPath(path51) {
115427
+ return `/${path51.map(safeEncodeURIComponent).join("/")}`;
115427
115428
  }
115428
- function normalizeHttpPath(path50) {
115429
- const paths = path50.split("/");
115429
+ function normalizeHttpPath(path51) {
115430
+ const paths = path51.split("/");
115430
115431
  if (paths.at(0) === "") {
115431
115432
  paths.shift();
115432
115433
  }
@@ -115611,9 +115612,9 @@ function isPlainObject2(value2) {
115611
115612
  function getOwn(object3, key) {
115612
115613
  return Object.hasOwn(object3, key) ? object3[key] : void 0;
115613
115614
  }
115614
- function get(object3, path50) {
115615
+ function get(object3, path51) {
115615
115616
  let current = object3;
115616
- for (const key of path50) {
115617
+ for (const key of path51) {
115617
115618
  if (!isTypescriptObject(current)) {
115618
115619
  return void 0;
115619
115620
  }
@@ -116836,7 +116837,7 @@ function resolveClientRest(rest) {
116836
116837
  // rest[1] can be undefined if all fields of FriendlyClientOptions are optional
116837
116838
  ];
116838
116839
  }
116839
- function createORPCClient(link, { path: path50 = [], ...options } = {}) {
116840
+ function createORPCClient(link, { path: path51 = [], ...options } = {}) {
116840
116841
  const procedureClient = (...rest) => {
116841
116842
  const [input2, callOptions] = resolveClientRest(rest);
116842
116843
  const interceptors = [
@@ -116845,7 +116846,7 @@ function createORPCClient(link, { path: path50 = [], ...options } = {}) {
116845
116846
  ];
116846
116847
  return intercept(
116847
116848
  interceptors,
116848
- { ...callOptions, input: input2, path: path50 },
116849
+ { ...callOptions, input: input2, path: path51 },
116849
116850
  ({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
116850
116851
  );
116851
116852
  };
@@ -116859,7 +116860,7 @@ function createORPCClient(link, { path: path50 = [], ...options } = {}) {
116859
116860
  if (client === void 0) {
116860
116861
  client = createORPCClient(link, {
116861
116862
  ...options,
116862
- path: [...path50, key],
116863
+ path: [...path51, key],
116863
116864
  scoped: options.scoped?.[key]
116864
116865
  });
116865
116866
  cache.set(key, client);
@@ -116881,24 +116882,24 @@ var BracketNotationSerializer = class {
116881
116882
  this.internalSerialize(data, "", true, result);
116882
116883
  return result;
116883
116884
  }
116884
- internalSerialize(data, path50, isRoot, result) {
116885
+ internalSerialize(data, path51, isRoot, result) {
116885
116886
  if (Array.isArray(data)) {
116886
116887
  data.forEach((item, i10) => {
116887
- this.internalSerialize(item, isRoot ? i10.toString() : `${path50}[${i10}]`, false, result);
116888
+ this.internalSerialize(item, isRoot ? i10.toString() : `${path51}[${i10}]`, false, result);
116888
116889
  });
116889
116890
  } else if (isPlainObject2(data)) {
116890
116891
  for (const key of Object.keys(data)) {
116891
- this.internalSerialize(data[key], isRoot ? key : `${path50}[${key}]`, false, result);
116892
+ this.internalSerialize(data[key], isRoot ? key : `${path51}[${key}]`, false, result);
116892
116893
  }
116893
116894
  } else {
116894
- result.push([path50, data]);
116895
+ result.push([path51, data]);
116895
116896
  }
116896
116897
  }
116897
116898
  deserialize(serialized) {
116898
116899
  const arrayPushStyles = /* @__PURE__ */ new WeakSet();
116899
116900
  const root = new NullProtoObj();
116900
- for (const [path50, value2] of serialized) {
116901
- const segments = this.parsePath(path50);
116901
+ for (const [path51, value2] of serialized) {
116902
+ const segments = this.parsePath(path51);
116902
116903
  let currentRef = root;
116903
116904
  let nextSegment = segments[0];
116904
116905
  for (let i10 = 1; i10 < segments.length; i10++) {
@@ -116949,13 +116950,13 @@ var BracketNotationSerializer = class {
116949
116950
  }
116950
116951
  return result;
116951
116952
  }
116952
- parsePath(path50) {
116953
+ parsePath(path51) {
116953
116954
  const segments = [];
116954
116955
  let inBrackets = false;
116955
116956
  let currentSegment = "";
116956
- for (let i10 = 0; i10 < path50.length; i10++) {
116957
- const char = path50[i10];
116958
- const nextChar = path50[i10 + 1];
116957
+ for (let i10 = 0; i10 < path51.length; i10++) {
116958
+ const char = path51[i10];
116959
+ const nextChar = path51[i10 + 1];
116959
116960
  if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
116960
116961
  if (nextChar === void 0) {
116961
116962
  inBrackets = false;
@@ -116971,7 +116972,7 @@ var BracketNotationSerializer = class {
116971
116972
  currentSegment += char;
116972
116973
  }
116973
116974
  }
116974
- return inBrackets || segments.length === 0 ? [path50] : segments;
116975
+ return inBrackets || segments.length === 0 ? [path51] : segments;
116975
116976
  }
116976
116977
  };
116977
116978
  var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
@@ -117544,11 +117545,11 @@ var OpenAPISerializer = class {
117544
117545
  return json2;
117545
117546
  }
117546
117547
  const form = new FormData();
117547
- for (const [path50, value22] of this.bracketNotation.serialize(json2)) {
117548
+ for (const [path51, value22] of this.bracketNotation.serialize(json2)) {
117548
117549
  if (value22 instanceof Blob) {
117549
- form.append(path50, value22);
117550
+ form.append(path51, value22);
117550
117551
  } else if (value22 !== void 0 && value22 !== null) {
117551
- form.append(path50, String(value22));
117552
+ form.append(path51, String(value22));
117552
117553
  }
117553
117554
  }
117554
117555
  return form;
@@ -117586,30 +117587,30 @@ function isBodylessMethod(method) {
117586
117587
  return method === "GET" || method === "HEAD";
117587
117588
  }
117588
117589
  var PARAMETER_NAME_REGEX = /^[\w-]+$/;
117589
- function getDynamicPathParams(path50) {
117590
- if (!path50.includes("{")) {
117590
+ function getDynamicPathParams(path51) {
117591
+ if (!path51.includes("{")) {
117591
117592
  return void 0;
117592
117593
  }
117593
- const len = path50.length;
117594
+ const len = path51.length;
117594
117595
  let params;
117595
117596
  let index = 1;
117596
117597
  while (index < len) {
117597
117598
  const segmentStart = index;
117598
- const slashPos = path50.indexOf("/", index);
117599
+ const slashPos = path51.indexOf("/", index);
117599
117600
  const segmentEnd = slashPos === -1 ? len : slashPos;
117600
- if (segmentEnd > segmentStart && path50.charCodeAt(segmentStart) === 123 && path50.charCodeAt(segmentEnd - 1) === 125) {
117601
+ if (segmentEnd > segmentStart && path51.charCodeAt(segmentStart) === 123 && path51.charCodeAt(segmentEnd - 1) === 125) {
117601
117602
  let parameterStart = segmentStart + 1;
117602
117603
  let allowsSlash = false;
117603
- const operator = path50.charCodeAt(parameterStart);
117604
+ const operator = path51.charCodeAt(parameterStart);
117604
117605
  if (operator === 43) {
117605
117606
  allowsSlash = true;
117606
117607
  parameterStart++;
117607
117608
  }
117608
- const parameterName = path50.slice(parameterStart, segmentEnd - 1);
117609
+ const parameterName = path51.slice(parameterStart, segmentEnd - 1);
117609
117610
  if (PARAMETER_NAME_REGEX.test(parameterName)) {
117610
117611
  params ??= [];
117611
117612
  params.push({
117612
- segment: path50.slice(segmentStart, segmentEnd),
117613
+ segment: path51.slice(segmentStart, segmentEnd),
117613
117614
  startIndex: segmentStart,
117614
117615
  parameterName,
117615
117616
  allowsSlash
@@ -117652,8 +117653,8 @@ openapi.method = (method) => ({
117652
117653
  ...openapi({ method }),
117653
117654
  name: "~openapi/method"
117654
117655
  });
117655
- openapi.path = (path50) => ({
117656
- ...openapi({ path: path50 }),
117656
+ openapi.path = (path51) => ({
117657
+ ...openapi({ path: path51 }),
117657
117658
  name: "~openapi/path"
117658
117659
  });
117659
117660
  openapi.spec = (spec) => ({
@@ -118514,22 +118515,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
118514
118515
  }
118515
118516
  }
118516
118517
  }
118517
- function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path50 = []) {
118518
+ function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path51 = []) {
118518
118519
  if (!value2 || typeof value2 !== "object") {
118519
118520
  return value2;
118520
118521
  }
118521
118522
  if (Array.isArray(value2)) {
118522
- return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path50, index]));
118523
+ return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path51, index]));
118523
118524
  }
118524
118525
  const result = {};
118525
118526
  for (const key of Object.keys(value2)) {
118526
118527
  const val = value2[key];
118527
118528
  if (key === "$ref" && typeof val === "string") {
118528
- setOwn(result, key, map2(val, [...path50, key]));
118529
+ setOwn(result, key, map2(val, [...path51, key]));
118529
118530
  } else if (!schemaLevel) {
118530
- setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path50, key]));
118531
+ setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path51, key]));
118531
118532
  } else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
118532
- setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path50, key]));
118533
+ setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path51, key]));
118533
118534
  } else {
118534
118535
  setOwn(result, key, val);
118535
118536
  }
@@ -119059,7 +119060,7 @@ function unlazy(maybeLazy) {
119059
119060
  function createProcedureClient(lazyableProcedure, ...rest) {
119060
119061
  const options = resolveMaybeOptionalOptions(rest);
119061
119062
  return async (...[input2, callerOptions]) => {
119062
- const path50 = toArray(options.path);
119063
+ const path51 = toArray(options.path);
119063
119064
  const { default: procedure } = await unlazy(lazyableProcedure);
119064
119065
  const clientContext = callerOptions?.context ?? {};
119065
119066
  const context = await value(options.context, clientContext) ?? {};
@@ -119072,7 +119073,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
119072
119073
  };
119073
119074
  try {
119074
119075
  const output2 = await runWithSpan("call_procedure", (span) => {
119075
- span?.setAttribute("procedure.path", path50);
119076
+ span?.setAttribute("procedure.path", path51);
119076
119077
  return intercept(
119077
119078
  options.interceptors,
119078
119079
  {
@@ -119080,7 +119081,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
119080
119081
  // input can be optional if it is undefinable
119081
119082
  input: input2,
119082
119083
  errors,
119083
- path: path50,
119084
+ path: path51,
119084
119085
  procedure,
119085
119086
  signal: callerOptions?.signal,
119086
119087
  lastEventId: callerOptions?.lastEventId
@@ -119331,10 +119332,10 @@ function augmentRouter(router, options) {
119331
119332
  }
119332
119333
  return enhanced;
119333
119334
  }
119334
- function getRouter(router, path50) {
119335
+ function getRouter(router, path51) {
119335
119336
  let current = router;
119336
- for (let i10 = 0; i10 < path50.length; i10++) {
119337
- const segment = path50[i10];
119337
+ for (let i10 = 0; i10 < path51.length; i10++) {
119338
+ const segment = path51[i10];
119338
119339
  if (!isTypescriptObject(current)) {
119339
119340
  return void 0;
119340
119341
  }
@@ -119346,7 +119347,7 @@ function getRouter(router, path50) {
119346
119347
  continue;
119347
119348
  }
119348
119349
  const lazied = current;
119349
- const rest = path50.slice(i10);
119350
+ const rest = path51.slice(i10);
119350
119351
  return new Lazy({
119351
119352
  ...lazied["~orpc"],
119352
119353
  async loader() {
@@ -119361,40 +119362,40 @@ function getRouter(router, path50) {
119361
119362
  }
119362
119363
  return current;
119363
119364
  }
119364
- function walkProcedureContractsSync(router, callback, path50 = []) {
119365
+ function walkProcedureContractsSync(router, callback, path51 = []) {
119365
119366
  const lazyResults = [];
119366
- walkProcedureContractsSyncInternal(router, callback, path50.slice(), lazyResults);
119367
+ walkProcedureContractsSyncInternal(router, callback, path51.slice(), lazyResults);
119367
119368
  return lazyResults;
119368
119369
  }
119369
- function walkProcedureContractsSyncInternal(router, callback, path50, lazyResults) {
119370
+ function walkProcedureContractsSyncInternal(router, callback, path51, lazyResults) {
119370
119371
  const hiddenContract = getHiddenRouterContract(router);
119371
119372
  if (hiddenContract !== void 0) {
119372
119373
  router = hiddenContract;
119373
119374
  }
119374
119375
  if (router instanceof ProcedureContract) {
119375
- callback(router, path50.slice());
119376
+ callback(router, path51.slice());
119376
119377
  return;
119377
119378
  }
119378
119379
  if (!isTypescriptObject(router)) {
119379
119380
  return;
119380
119381
  }
119381
119382
  for (const [key, value2] of Object.entries(router)) {
119382
- path50.push(key);
119383
+ path51.push(key);
119383
119384
  if (value2 instanceof Lazy) {
119384
- lazyResults.push({ router: value2, path: path50.slice() });
119385
+ lazyResults.push({ router: value2, path: path51.slice() });
119385
119386
  } else {
119386
- walkProcedureContractsSyncInternal(value2, callback, path50, lazyResults);
119387
+ walkProcedureContractsSyncInternal(value2, callback, path51, lazyResults);
119387
119388
  }
119388
- path50.pop();
119389
+ path51.pop();
119389
119390
  }
119390
119391
  }
119391
- async function walkProcedureContractsAsync(router, callback, path50 = []) {
119392
+ async function walkProcedureContractsAsync(router, callback, path51 = []) {
119392
119393
  const hiddenContract = getHiddenRouterContract(router);
119393
119394
  if (hiddenContract !== void 0) {
119394
119395
  router = hiddenContract;
119395
119396
  }
119396
119397
  if (router instanceof ProcedureContract) {
119397
- await callback(router, path50);
119398
+ await callback(router, path51);
119398
119399
  return;
119399
119400
  }
119400
119401
  if (!isTypescriptObject(router)) {
@@ -119403,9 +119404,9 @@ async function walkProcedureContractsAsync(router, callback, path50 = []) {
119403
119404
  for (const [key, value2] of Object.entries(router)) {
119404
119405
  if (value2 instanceof Lazy) {
119405
119406
  const { default: router2 } = await unlazy(value2);
119406
- await walkProcedureContractsAsync(router2, callback, [...path50, key]);
119407
+ await walkProcedureContractsAsync(router2, callback, [...path51, key]);
119407
119408
  } else {
119408
- await walkProcedureContractsAsync(value2, callback, [...path50, key]);
119409
+ await walkProcedureContractsAsync(value2, callback, [...path51, key]);
119409
119410
  }
119410
119411
  }
119411
119412
  }
@@ -119891,18 +119892,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
119891
119892
  }
119892
119893
  var OpenAPIGeneratorError = class extends TypeError {
119893
119894
  };
119894
- function toOpenAPIPath(path50, dynamicPathParams) {
119895
+ function toOpenAPIPath(path51, dynamicPathParams) {
119895
119896
  if (!dynamicPathParams?.length) {
119896
- return path50;
119897
+ return path51;
119897
119898
  }
119898
119899
  let normalized = "";
119899
119900
  let currentIndex = 0;
119900
119901
  for (const param of dynamicPathParams) {
119901
- normalized += path50.slice(currentIndex, param.startIndex);
119902
+ normalized += path51.slice(currentIndex, param.startIndex);
119902
119903
  normalized += `{${param.parameterName}}`;
119903
119904
  currentIndex = param.startIndex + param.segment.length;
119904
119905
  }
119905
- normalized += path50.slice(currentIndex);
119906
+ normalized += path51.slice(currentIndex);
119906
119907
  return normalized;
119907
119908
  }
119908
119909
  function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
@@ -120336,8 +120337,8 @@ var OpenAPIGenerator = class {
120336
120337
  customErrorResponseBodySchema: options.customErrorResponseBodySchema
120337
120338
  };
120338
120339
  const errors = [];
120339
- await walkProcedureContractsAsync(router, (contract, path50) => {
120340
- if (value(options.filter, contract, path50) === false) {
120340
+ await walkProcedureContractsAsync(router, (contract, path51) => {
120341
+ if (value(options.filter, contract, path51) === false) {
120341
120342
  return;
120342
120343
  }
120343
120344
  try {
@@ -120349,7 +120350,7 @@ var OpenAPIGenerator = class {
120349
120350
  `QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
120350
120351
  );
120351
120352
  }
120352
- const postPath = meta3?.path ?? pathToHttpPath(path50);
120353
+ const postPath = meta3?.path ?? pathToHttpPath(path51);
120353
120354
  const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
120354
120355
  const dynamicPathParams = getDynamicPathParams(httpPath);
120355
120356
  const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
@@ -120358,7 +120359,7 @@ var OpenAPIGenerator = class {
120358
120359
  operation = meta3.spec;
120359
120360
  } else {
120360
120361
  operation = {
120361
- operationId: meta3?.operationId ?? path50.join("."),
120362
+ operationId: meta3?.operationId ?? path51.join("."),
120362
120363
  summary: meta3?.summary,
120363
120364
  description: meta3?.description,
120364
120365
  deprecated: meta3?.deprecated,
@@ -120378,7 +120379,7 @@ var OpenAPIGenerator = class {
120378
120379
  if (!(e14 instanceof OpenAPIGeneratorError)) {
120379
120380
  throw e14;
120380
120381
  }
120381
- errors.push(`Procedure at ${path50.join(".") || "(root)"}: ${e14.message}`);
120382
+ errors.push(`Procedure at ${path51.join(".") || "(root)"}: ${e14.message}`);
120382
120383
  }
120383
120384
  });
120384
120385
  if (errors.length) {
@@ -121147,16 +121148,16 @@ var StandardLink = class {
121147
121148
  /**
121148
121149
  * @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
121149
121150
  */
121150
- call(path50, input2, options) {
121151
- return runWithSpan(`${ORPC_NAME}.${path50.join("/")}`, (span) => {
121151
+ call(path51, input2, options) {
121152
+ return runWithSpan(`${ORPC_NAME}.${path51.join("/")}`, (span) => {
121152
121153
  span?.setAttribute("rpc.system", ORPC_NAME);
121153
- span?.setAttribute("rpc.method", path50.join("."));
121154
+ span?.setAttribute("rpc.method", path51.join("."));
121154
121155
  if (getTracer() && isAsyncIteratorObject(input2)) {
121155
121156
  input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
121156
121157
  } else if (getTracer() && input2 instanceof ReadableStream) {
121157
121158
  input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
121158
121159
  }
121159
- return intercept(this.interceptors, { ...options, path: path50, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
121160
+ return intercept(this.interceptors, { ...options, path: path51, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
121160
121161
  const tracer = getTracer();
121161
121162
  const activeSpan = tracer?.getActiveSpan() ?? span;
121162
121163
  let request7 = await runWithSpan(
@@ -121213,18 +121214,18 @@ var RPCLinkCodec = class {
121213
121214
  this.headers = options.headers ?? {};
121214
121215
  this.serializer = options.serializer ?? new RPCSerializer();
121215
121216
  }
121216
- async encodeInput(input2, path50, options) {
121217
- let headers = toResolvedStandardHeaders(await value(this.headers, options, path50, input2));
121217
+ async encodeInput(input2, path51, options) {
121218
+ let headers = toResolvedStandardHeaders(await value(this.headers, options, path51, input2));
121218
121219
  if (options.lastEventId !== void 0) {
121219
121220
  headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
121220
121221
  }
121221
- const expectedMethod = await value(this.expectedMethod, options, path50, input2);
121222
- const baseUrl = await value(this.baseUrl, options, path50, input2);
121222
+ const expectedMethod = await value(this.expectedMethod, options, path51, input2);
121223
+ const baseUrl = await value(this.baseUrl, options, path51, input2);
121223
121224
  const [pathname, search, hash2] = parseStandardUrl(baseUrl);
121224
- const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path50)}`;
121225
+ const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path51)}`;
121225
121226
  const serialized = this.serializer.serialize(input2);
121226
121227
  if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
121227
- const maxUrlLength = await value(this.maxUrlLength, options, path50, input2);
121228
+ const maxUrlLength = await value(this.maxUrlLength, options, path51, input2);
121228
121229
  const mergedSearch = new URLSearchParams(search);
121229
121230
  mergedSearch.append("data", stringifyJSON(serialized) ?? "");
121230
121231
  const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
@@ -121309,8 +121310,8 @@ var FetchLinkTransport = class {
121309
121310
  this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
121310
121311
  this.toFetchRequestOptions = options.toFetchRequest;
121311
121312
  }
121312
- async send(standardRequest, path50, options) {
121313
- let origin = await value(this.origin, options, path50);
121313
+ async send(standardRequest, path51, options) {
121314
+ let origin = await value(this.origin, options, path51);
121314
121315
  if (origin?.endsWith("/")) {
121315
121316
  origin = origin.slice(0, -1);
121316
121317
  }
@@ -121330,7 +121331,7 @@ var FetchLinkTransport = class {
121330
121331
  }
121331
121332
  }
121332
121333
  const fetch3 = this.fetch;
121333
- const response = await fetch3(url2, init, options, path50);
121334
+ const response = await fetch3(url2, init, options, path51);
121334
121335
  const standardResponse = toStandardLazyResponse(response);
121335
121336
  return standardResponse;
121336
121337
  }
@@ -121721,14 +121722,14 @@ var StandardHandler = class {
121721
121722
  span?.setAttribute("url.path", request22.url);
121722
121723
  return { matched: false };
121723
121724
  }
121724
- const { path: path50, procedure, decodeInput } = matchedOrNot;
121725
- span?.updateName(`${ORPC_NAME}.${path50.join("/")}`);
121725
+ const { path: path51, procedure, decodeInput } = matchedOrNot;
121726
+ span?.updateName(`${ORPC_NAME}.${path51.join("/")}`);
121726
121727
  span?.setAttribute("rpc.system", ORPC_NAME);
121727
- span?.setAttribute("rpc.method", path50.join("."));
121728
+ span?.setAttribute("rpc.method", path51.join("."));
121728
121729
  try {
121729
121730
  const response = await intercept(
121730
121731
  this.interceptors,
121731
- { context: context2, prefix: prefix2, request: request22, path: path50, procedure, decodeInput },
121732
+ { context: context2, prefix: prefix2, request: request22, path: path51, procedure, decodeInput },
121732
121733
  async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
121733
121734
  step2 = "decode_input";
121734
121735
  let input2 = await runWithSpan("decode_input", decodeInput2);
@@ -121762,7 +121763,7 @@ var StandardHandler = class {
121762
121763
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
121763
121764
  cause: e14
121764
121765
  }) : toORPCError(e14);
121765
- const response = await this.codec.encodeError(error63, procedure, path50, { context: context2, prefix: prefix2 });
121766
+ const response = await this.codec.encodeError(error63, procedure, path51, { context: context2, prefix: prefix2 });
121766
121767
  return { matched: true, response };
121767
121768
  }
121768
121769
  }
@@ -121868,7 +121869,7 @@ var RPCMatcher = class {
121868
121869
  this.rootRouter = router;
121869
121870
  this.index(router);
121870
121871
  }
121871
- index(router, path50 = []) {
121872
+ index(router, path51 = []) {
121872
121873
  const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
121873
121874
  if (!value(this.filter, procedure, procedurePath)) {
121874
121875
  return;
@@ -121879,7 +121880,7 @@ var RPCMatcher = class {
121879
121880
  // contract-first entries have no implementation yet, resolveProcedure fills it in on demand
121880
121881
  procedure: procedure instanceof Procedure ? procedure : void 0
121881
121882
  });
121882
- }, path50);
121883
+ }, path51);
121883
121884
  for (const result of lazyResults) {
121884
121885
  this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
121885
121886
  }
@@ -122011,10 +122012,10 @@ var RPCHandlerCodec = class {
122011
122012
  }
122012
122013
  };
122013
122014
  }
122014
- encodeOutput(output2, procedure, path50, options) {
122015
+ encodeOutput(output2, procedure, path51, options) {
122015
122016
  return {
122016
122017
  headers: {},
122017
- status: value(this.outputStatus, output2, procedure, path50, options) ?? DEFAULT_SUCCESS_STATUS,
122018
+ status: value(this.outputStatus, output2, procedure, path51, options) ?? DEFAULT_SUCCESS_STATUS,
122018
122019
  body: this.serializer.serialize(output2)
122019
122020
  };
122020
122021
  }
@@ -122068,39 +122069,39 @@ function createRouter() {
122068
122069
  static: new NullProtoObj2()
122069
122070
  };
122070
122071
  }
122071
- function scanFirstGroup(path50) {
122072
+ function scanFirstGroup(path51) {
122072
122073
  let i10 = 0;
122073
122074
  let depth = 0;
122074
- for (; i10 < path50.length; i10++) {
122075
- const c10 = path50.charCodeAt(i10);
122075
+ for (; i10 < path51.length; i10++) {
122076
+ const c10 = path51.charCodeAt(i10);
122076
122077
  if (c10 === 92) i10++;
122077
122078
  else if (c10 === 40) depth++;
122078
122079
  else if (c10 === 41 && depth > 0) depth--;
122079
122080
  else if (c10 === 123 && depth === 0) break;
122080
122081
  }
122081
- if (i10 >= path50.length) return;
122082
+ if (i10 >= path51.length) return;
122082
122083
  let j10 = i10 + 1;
122083
122084
  depth = 0;
122084
- for (; j10 < path50.length; j10++) {
122085
- const c10 = path50.charCodeAt(j10);
122085
+ for (; j10 < path51.length; j10++) {
122086
+ const c10 = path51.charCodeAt(j10);
122086
122087
  if (c10 === 92) j10++;
122087
122088
  else if (c10 === 40) depth++;
122088
122089
  else if (c10 === 41 && depth > 0) depth--;
122089
122090
  else if (c10 === 125 && depth === 0) break;
122090
122091
  }
122091
- if (j10 >= path50.length) return;
122092
- const mod = path50[j10 + 1];
122092
+ if (j10 >= path51.length) return;
122093
+ const mod = path51[j10 + 1];
122093
122094
  const hasMod = mod === "?" || mod === "+" || mod === "*";
122094
122095
  return [
122095
- path50.slice(0, i10),
122096
- path50.slice(i10 + 1, j10),
122097
- path50.slice(j10 + (hasMod ? 2 : 1)),
122096
+ path51.slice(0, i10),
122097
+ path51.slice(i10 + 1, j10),
122098
+ path51.slice(j10 + (hasMod ? 2 : 1)),
122098
122099
  hasMod ? mod : void 0
122099
122100
  ];
122100
122101
  }
122101
- function expandGroupDelimiters(path50) {
122102
- if (!path50.includes("{")) return;
122103
- const group = scanFirstGroup(path50);
122102
+ function expandGroupDelimiters(path51) {
122103
+ if (!path51.includes("{")) return;
122104
+ const group = scanFirstGroup(path51);
122104
122105
  if (!group) return;
122105
122106
  const [pre2, body, suf, mod] = group;
122106
122107
  if (!mod) return [pre2 + body + suf];
@@ -122170,9 +122171,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
122170
122171
  }
122171
122172
  return [replaced, nextIndex];
122172
122173
  }
122173
- function encodeEscapes(path50) {
122174
- if (!path50.includes("\\")) return path50;
122175
- return path50.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
122174
+ function encodeEscapes(path51) {
122175
+ if (!path51.includes("\\")) return path51;
122176
+ return path51.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
122176
122177
  }
122177
122178
  function segmentKey(segment) {
122178
122179
  if (segment.startsWith("**")) return 2;
@@ -122201,22 +122202,22 @@ function expandModifiers(segments) {
122201
122202
  return m10[2] === "+" ? [wc2] : [wc2, without];
122202
122203
  }
122203
122204
  }
122204
- function normalizePath(path50) {
122205
- if (!path50.includes("/.")) return path50;
122205
+ function normalizePath(path51) {
122206
+ if (!path51.includes("/.")) return path51;
122206
122207
  const r10 = [];
122207
- for (const s of path50.split("/")) if (s === ".") continue;
122208
+ for (const s of path51.split("/")) if (s === ".") continue;
122208
122209
  else if (s === ".." && r10.length > 1) r10.pop();
122209
122210
  else r10.push(s);
122210
122211
  return r10.join("/") || "/";
122211
122212
  }
122212
- function splitPath(path50) {
122213
- const s = path50.split("/");
122213
+ function splitPath(path51) {
122214
+ const s = path51.split("/");
122214
122215
  s.shift();
122215
122216
  if (s[s.length - 1] === "") s.pop();
122216
122217
  return s;
122217
122218
  }
122218
- function splitRoute(path50) {
122219
- const s = splitPath(path50);
122219
+ function splitRoute(path51) {
122220
+ const s = splitPath(path51);
122220
122221
  while (s[s.length - 1] === "") s.pop();
122221
122222
  return s;
122222
122223
  }
@@ -122232,16 +122233,16 @@ function getMatchParams(segments, paramsMap) {
122232
122233
  }
122233
122234
  return params;
122234
122235
  }
122235
- function addRoute(ctx, method = "", path50, data) {
122236
+ function addRoute(ctx, method = "", path51, data) {
122236
122237
  method = method.toUpperCase();
122237
- if (path50.charCodeAt(0) !== 47) path50 = `/${path50}`;
122238
- const groupExpanded = expandGroupDelimiters(path50);
122238
+ if (path51.charCodeAt(0) !== 47) path51 = `/${path51}`;
122239
+ const groupExpanded = expandGroupDelimiters(path51);
122239
122240
  if (groupExpanded) {
122240
122241
  for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
122241
122242
  return;
122242
122243
  }
122243
- path50 = encodeEscapes(path50);
122244
- const segments = splitRoute(path50);
122244
+ path51 = encodeEscapes(path51);
122245
+ const segments = splitRoute(path51);
122245
122246
  const expanded = expandModifiers(segments);
122246
122247
  if (expanded) {
122247
122248
  for (const p of expanded) addRoute(ctx, method, p, data);
@@ -122332,15 +122333,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
122332
122333
  const regex = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
122333
122334
  return [new RegExp(`^${regex}$`), _i2];
122334
122335
  }
122335
- function findRoute(ctx, method = "", path50, opts) {
122336
- if (opts?.normalize) path50 = normalizePath(path50);
122337
- if (path50.charCodeAt(path50.length - 1) === 47) path50 = path50.slice(0, -1);
122338
- const staticNode = ctx.static[path50];
122336
+ function findRoute(ctx, method = "", path51, opts) {
122337
+ if (opts?.normalize) path51 = normalizePath(path51);
122338
+ if (path51.charCodeAt(path51.length - 1) === 47) path51 = path51.slice(0, -1);
122339
+ const staticNode = ctx.static[path51];
122339
122340
  if (staticNode && staticNode.methods) {
122340
122341
  const staticMatch = staticNode.methods[method] || staticNode.methods[""];
122341
122342
  if (staticMatch !== void 0) return staticMatch[0];
122342
122343
  }
122343
- const segments = splitPath(path50);
122344
+ const segments = splitPath(path51);
122344
122345
  const match = _lookupTree(ctx.root, method, segments, 0);
122345
122346
  if (match === void 0) return;
122346
122347
  if (opts?.params === false) return match;
@@ -122540,7 +122541,7 @@ var OpenAPIMatcher = class {
122540
122541
  this.rootRouter = router;
122541
122542
  this.index(router);
122542
122543
  }
122543
- index(router, path50 = []) {
122544
+ index(router, path51 = []) {
122544
122545
  const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
122545
122546
  if (!value(this.filter, contract, path210)) {
122546
122547
  return;
@@ -122555,7 +122556,7 @@ var OpenAPIMatcher = class {
122555
122556
  contract,
122556
122557
  procedure: contract instanceof Procedure ? contract : void 0
122557
122558
  });
122558
- }, path50);
122559
+ }, path51);
122559
122560
  for (const result of lazyResults) {
122560
122561
  const prefix = getOpenAPIMeta(result.router)?.prefix;
122561
122562
  this.pendingLazyRouters.add({
@@ -122642,20 +122643,20 @@ var OpenAPIMatcher = class {
122642
122643
  return entry.procedure;
122643
122644
  }
122644
122645
  };
122645
- function toRou3Pattern(path50) {
122646
- const params = getDynamicPathParams(path50);
122646
+ function toRou3Pattern(path51) {
122647
+ const params = getDynamicPathParams(path51);
122647
122648
  if (!params?.length) {
122648
- return path50;
122649
+ return path51;
122649
122650
  }
122650
122651
  for (let i10 = params.length - 1; i10 >= 0; i10--) {
122651
122652
  const param = params[i10];
122652
122653
  const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
122653
- path50 = path50.slice(0, param.startIndex) + pattern + path50.slice(param.startIndex + param.segment.length);
122654
+ path51 = path51.slice(0, param.startIndex) + pattern + path51.slice(param.startIndex + param.segment.length);
122654
122655
  }
122655
- return path50;
122656
+ return path51;
122656
122657
  }
122657
- function toRou3PrefixMatcher(path50) {
122658
- const pattern = toRou3Pattern(path50);
122658
+ function toRou3PrefixMatcher(path51) {
122659
+ const pattern = toRou3Pattern(path51);
122659
122660
  return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
122660
122661
  }
122661
122662
  function decodeParams(params) {
@@ -122734,7 +122735,7 @@ var OpenAPIHandlerCodecCore = class {
122734
122735
  /**
122735
122736
  * @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
122736
122737
  */
122737
- encodeOutput(output2, procedure, path50) {
122738
+ encodeOutput(output2, procedure, path51) {
122738
122739
  const meta3 = getOpenAPIMeta(procedure);
122739
122740
  const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
122740
122741
  const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
@@ -122747,7 +122748,7 @@ var OpenAPIHandlerCodecCore = class {
122747
122748
  }
122748
122749
  if (!isValidDetailedOutput(output2)) {
122749
122750
  throw new TypeError(`
122750
- Invalid "detailed" output structure returned by procedure (${path50.join(".")}):
122751
+ Invalid "detailed" output structure returned by procedure (${path51.join(".")}):
122751
122752
  \u2022 Expected an object with optional properties:
122752
122753
  - status (number <400)
122753
122754
  - headers (object)
@@ -123295,7 +123296,7 @@ function profileValue(name, paths) {
123295
123296
  function createConfigApiRouter(deps) {
123296
123297
  const authed = doorApiAuth(deps.expectedToken);
123297
123298
  const { paths } = deps;
123298
- const route = (path50, summary) => authed.meta(openapi({ method: "POST", path: path50, summary, tags: [CONFIG_API_TAG] }));
123299
+ const route = (path51, summary) => authed.meta(openapi({ method: "POST", path: path51, summary, tags: [CONFIG_API_TAG] }));
123299
123300
  return {
123300
123301
  config: {
123301
123302
  identity: {
@@ -125145,8 +125146,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
125145
125146
  request7.body.resume();
125146
125147
  return;
125147
125148
  }
125148
- const path50 = new URL(request7.url, "http://127.0.0.1").pathname;
125149
- const translated = { method: request7.method, path: path50, body, signal: request7.signal };
125149
+ const path51 = new URL(request7.url, "http://127.0.0.1").pathname;
125150
+ const translated = { method: request7.method, path: path51, body, signal: request7.signal };
125150
125151
  const routed = await route(translated);
125151
125152
  if (request7.signal.aborted) {
125152
125153
  return;
@@ -125180,7 +125181,7 @@ function createPassthroughRoute(name, target) {
125180
125181
  headroomUpstream: target.headroomUpstream,
125181
125182
  serve: async (request7, response) => {
125182
125183
  const incoming = new URL(request7.url, "http://127.0.0.1");
125183
- const path50 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
125184
+ const path51 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
125184
125185
  const headers = forwardableHeaders(request7.headers);
125185
125186
  delete headers.host;
125186
125187
  await new Promise((resolve2) => {
@@ -125188,7 +125189,7 @@ function createPassthroughRoute(name, target) {
125188
125189
  host: base.hostname,
125189
125190
  port: base.port === "" ? void 0 : Number(base.port),
125190
125191
  method: request7.method,
125191
- path: `${basePath}${path50}${incoming.search}`,
125192
+ path: `${basePath}${path51}${incoming.search}`,
125192
125193
  headers,
125193
125194
  agent
125194
125195
  };
@@ -125321,7 +125322,7 @@ async function scanRequestHead(request7, wholeBody = false) {
125321
125322
 
125322
125323
  // src/frontdoor/providerRoute.ts
125323
125324
  function createProviderRouteResolver(deps) {
125324
- const isRcSelfHostPath = (path50) => path50 === "/v1/code/sessions" || path50.startsWith("/v1/code/sessions/") || path50 === "/v1/sessions" || path50.startsWith("/v1/sessions/");
125325
+ const isRcSelfHostPath = (path51) => path51 === "/v1/code/sessions" || path51.startsWith("/v1/code/sessions/") || path51 === "/v1/sessions" || path51.startsWith("/v1/sessions/");
125325
125326
  const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
125326
125327
  const passthroughByTarget = /* @__PURE__ */ new Map();
125327
125328
  const passthroughFor = (name, target) => {
@@ -125335,16 +125336,16 @@ function createProviderRouteResolver(deps) {
125335
125336
  return route;
125336
125337
  };
125337
125338
  const resolve2 = (request7) => {
125338
- const path50 = new URL(request7.url, "http://127.0.0.1").pathname;
125339
- const scoped = parseProviderPath(path50);
125339
+ const path51 = new URL(request7.url, "http://127.0.0.1").pathname;
125340
+ const scoped = parseProviderPath(path51);
125340
125341
  if (scoped === void 0) {
125341
- if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path50)) {
125342
+ if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path51)) {
125342
125343
  return { ok: true, route: deps.rcSelfHostRoute };
125343
125344
  }
125344
- if (request7.session.provider !== void 0 && path50.startsWith("/v1/") && !isRcSelfHostPath(path50)) {
125345
+ if (request7.session.provider !== void 0 && path51.startsWith("/v1/") && !isRcSelfHostPath(path51)) {
125345
125346
  return resolve2({ ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` });
125346
125347
  }
125347
- return path50.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path50}` };
125348
+ return path51.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path51}` };
125348
125349
  }
125349
125350
  const { provider } = scoped;
125350
125351
  let definition;
@@ -125397,8 +125398,8 @@ function createProviderRouteResolver(deps) {
125397
125398
  let replay;
125398
125399
  const visited = /* @__PURE__ */ new Set();
125399
125400
  for (; ; ) {
125400
- const path50 = new URL(current.url, "http://127.0.0.1").pathname;
125401
- const scoped = parseProviderPath(path50);
125401
+ const path51 = new URL(current.url, "http://127.0.0.1").pathname;
125402
+ const scoped = parseProviderPath(path51);
125402
125403
  const providerName = scoped?.provider ?? current.session.provider;
125403
125404
  if (providerName !== void 0 && visited.has(providerName)) {
125404
125405
  return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
@@ -125456,7 +125457,7 @@ function createProviderRouteResolver(deps) {
125456
125457
  const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
125457
125458
  replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
125458
125459
  }
125459
- const rest = scoped === void 0 ? path50 : path50.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
125460
+ const rest = scoped === void 0 ? path51 : path51.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
125460
125461
  const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
125461
125462
  current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
125462
125463
  }
@@ -125679,8 +125680,8 @@ var SELF_HOST_SUBSCRIPTION_TYPE = "max";
125679
125680
  function isRecord7(value2) {
125680
125681
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
125681
125682
  }
125682
- function readJsonObject(fs21, file2) {
125683
- const raw = fs21.readFileUtf8(file2);
125683
+ function readJsonObject(fs22, file2) {
125684
+ const raw = fs22.readFileUtf8(file2);
125684
125685
  if (raw === void 0) {
125685
125686
  return void 0;
125686
125687
  }
@@ -125692,8 +125693,8 @@ function readJsonObject(fs21, file2) {
125692
125693
  }
125693
125694
  return isRecord7(parsed) ? parsed : void 0;
125694
125695
  }
125695
- function readRcSelfHostRecord(fs21, frontdoorDir) {
125696
- const parsed = readJsonObject(fs21, import_node_path43.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
125696
+ function readRcSelfHostRecord(fs22, frontdoorDir) {
125697
+ const parsed = readJsonObject(fs22, import_node_path43.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
125697
125698
  if (parsed === void 0) {
125698
125699
  return void 0;
125699
125700
  }
@@ -126138,11 +126139,11 @@ function credentialOfJson(parsed) {
126138
126139
  function sequenceNumOfJson(value2) {
126139
126140
  return typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 ? value2 : void 0;
126140
126141
  }
126141
- function createRcCredentialStore(fs21, dir) {
126142
- fs21.mkdirPrivate(dir);
126142
+ function createRcCredentialStore(fs22, dir) {
126143
+ fs22.mkdirPrivate(dir);
126143
126144
  const fileFor = (sessionId) => import_node_path44.default.join(dir, `${sessionId}.json`);
126144
126145
  const readParsed = (sessionId) => {
126145
- const raw = fs21.readFileUtf8(fileFor(sessionId));
126146
+ const raw = fs22.readFileUtf8(fileFor(sessionId));
126146
126147
  if (raw === void 0) {
126147
126148
  return void 0;
126148
126149
  }
@@ -126167,7 +126168,7 @@ function createRcCredentialStore(fs21, dir) {
126167
126168
  }
126168
126169
  const cursor3 = sequenceNumOfJson(readParsed(sessionId)?.highestSequenceNum);
126169
126170
  const record2 = { ...credential, ...cursor3 === void 0 ? {} : { highestSequenceNum: cursor3 } };
126170
- fs21.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
126171
+ fs22.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
126171
126172
  `);
126172
126173
  },
126173
126174
  readCursor: (sessionId) => {
@@ -126182,14 +126183,14 @@ function createRcCredentialStore(fs21, dir) {
126182
126183
  }
126183
126184
  const credential = credentialOfJson(readParsed(sessionId));
126184
126185
  const record2 = credential === void 0 ? { highestSequenceNum } : { ...credential, highestSequenceNum };
126185
- fs21.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
126186
+ fs22.writeFilePrivate(fileFor(sessionId), `${JSON.stringify(record2, null, 2)}
126186
126187
  `);
126187
126188
  },
126188
126189
  remove: (sessionId) => {
126189
126190
  if (!isSafeSessionId(sessionId)) {
126190
126191
  return;
126191
126192
  }
126192
- fs21.removeRecursive(fileFor(sessionId));
126193
+ fs22.removeRecursive(fileFor(sessionId));
126193
126194
  }
126194
126195
  };
126195
126196
  }
@@ -130322,6 +130323,7 @@ var StdioServerTransport = class {
130322
130323
  };
130323
130324
 
130324
130325
  // src/mcp/command.ts
130326
+ init_cliError();
130325
130327
  init_commandDeps();
130326
130328
  init_package();
130327
130329
  init_realPorts();
@@ -130700,8 +130702,8 @@ function getErrorMap2() {
130700
130702
 
130701
130703
  // node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
130702
130704
  var makeIssue = (params) => {
130703
- const { data, path: path50, errorMaps, issueData } = params;
130704
- const fullPath = [...path50, ...issueData.path || []];
130705
+ const { data, path: path51, errorMaps, issueData } = params;
130706
+ const fullPath = [...path51, ...issueData.path || []];
130705
130707
  const fullIssue = {
130706
130708
  ...issueData,
130707
130709
  path: fullPath
@@ -130816,11 +130818,11 @@ var errorUtil;
130816
130818
 
130817
130819
  // node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
130818
130820
  var ParseInputLazyPath = class {
130819
- constructor(parent, value2, path50, key) {
130821
+ constructor(parent, value2, path51, key) {
130820
130822
  this._cachedPath = [];
130821
130823
  this.parent = parent;
130822
130824
  this.data = value2;
130823
- this._path = path50;
130825
+ this._path = path51;
130824
130826
  this._key = key;
130825
130827
  }
130826
130828
  get path() {
@@ -134383,11 +134385,11 @@ function normalizeObjectSchema(schema) {
134383
134385
  }
134384
134386
  return void 0;
134385
134387
  }
134386
- function getDotPath(path50) {
134387
- if (path50.length === 0) {
134388
+ function getDotPath(path51) {
134389
+ if (path51.length === 0) {
134388
134390
  return "object root";
134389
134391
  }
134390
- return path50.reduce((acc, seg, index) => {
134392
+ return path51.reduce((acc, seg, index) => {
134391
134393
  if (index === 0) {
134392
134394
  return String(seg);
134393
134395
  }
@@ -138384,7 +138386,7 @@ function failureText(error63) {
138384
138386
  return error63 instanceof Error ? error63.message : String(error63);
138385
138387
  }
138386
138388
  function createMcpServer(identity, ports) {
138387
- const mcp = new McpServer(identity, { capabilities: { tools: {} } });
138389
+ const mcp = new McpServer(identity, { capabilities: { tools: { listChanged: true } } });
138388
138390
  const { server } = mcp;
138389
138391
  server.setRequestHandler(ListToolsRequestSchema, async () => {
138390
138392
  const tools = await ports.listTools();
@@ -138413,12 +138415,50 @@ function createMcpServer(identity, ports) {
138413
138415
  });
138414
138416
  return mcp;
138415
138417
  }
138416
- async function serveMcp(mcp, transport) {
138418
+ async function serveMcp(mcp, transport, whileConnected) {
138417
138419
  const closed = new Promise((resolve2) => {
138418
138420
  mcp.server.onclose = resolve2;
138419
138421
  });
138420
138422
  await mcp.connect(transport);
138423
+ const stop = whileConnected?.(() => {
138424
+ void mcp.server.sendToolListChanged();
138425
+ });
138421
138426
  await closed;
138427
+ stop?.();
138428
+ }
138429
+
138430
+ // src/mcp/permissions.ts
138431
+ var import_node_fs17 = __toESM(require("node:fs"), 1);
138432
+ var import_node_path46 = __toESM(require("node:path"), 1);
138433
+ init_zod();
138434
+ init_store();
138435
+ var StoredMcpPermissionsSchema = external_exports.strictObject({
138436
+ writes: external_exports.boolean(),
138437
+ remoteControl: external_exports.boolean()
138438
+ });
138439
+ var OWNER_ONLY_MODE = 384;
138440
+ var NONE2 = { writes: false, remoteControl: false };
138441
+ function readStoredMcpPermissions(paths) {
138442
+ return readJson(paths.mcpPermissionsFile, StoredMcpPermissionsSchema) ?? NONE2;
138443
+ }
138444
+ function writeStoredMcpPermissions(paths, permissions) {
138445
+ writeJsonAtomic(paths.mcpPermissionsFile, { writes: permissions.writes, remoteControl: permissions.remoteControl });
138446
+ import_node_fs17.default.chmodSync(paths.mcpPermissionsFile, OWNER_ONLY_MODE);
138447
+ }
138448
+ function effectiveMcpPermissions(flags, stored) {
138449
+ return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl };
138450
+ }
138451
+ function watchMcpPermissions(paths, onChange) {
138452
+ const directory = import_node_path46.default.dirname(paths.mcpPermissionsFile);
138453
+ import_node_fs17.default.mkdirSync(directory, { recursive: true });
138454
+ const watcher = import_node_fs17.default.watch(directory, (_event, filename) => {
138455
+ if (filename === null || filename === import_node_path46.default.basename(paths.mcpPermissionsFile)) {
138456
+ onChange();
138457
+ }
138458
+ });
138459
+ return () => {
138460
+ watcher.close();
138461
+ };
138422
138462
  }
138423
138463
 
138424
138464
  // src/mcp/tools.ts
@@ -138508,7 +138548,7 @@ function doorMcpPorts(paths, permissions) {
138508
138548
  return {
138509
138549
  listTools: async () => {
138510
138550
  const { port, ca: ca2, token } = material();
138511
- return toolsFromOpenApiDocument(await fetchFrontDoorOpenApiDocument(port, ca2, token), permissions);
138551
+ return toolsFromOpenApiDocument(await fetchFrontDoorOpenApiDocument(port, ca2, token), permissions());
138512
138552
  },
138513
138553
  callProcedure: async (procedure, input2) => {
138514
138554
  const { port, ca: ca2, token } = material();
@@ -138520,15 +138560,47 @@ function doorMcpPorts(paths, permissions) {
138520
138560
  }
138521
138561
  };
138522
138562
  }
138563
+ var PERMISSION_FIELDS = { writes: "writes", "remote-control": "remoteControl" };
138564
+ function permissionName(value2) {
138565
+ if (value2 !== "writes" && value2 !== "remote-control") {
138566
+ throw new UsageError(`unknown permission "${value2}": expected writes or remote-control`);
138567
+ }
138568
+ return value2;
138569
+ }
138523
138570
  function registerMcpCommand(program2, deps) {
138571
+ const mcp = program2.command("mcp").description("Serve the front door's typed API as MCP tools on standard input and output, so an agent can read quota and door state and, when allowed, act on it.").option("--allow-writes", "Also expose the operations that change the door's configuration and lifecycle, whatever `mcp permissions` says. Read-only without it or a stored permission.").option("--allow-remote-control", "Also expose the Remote Control operations that send into, answer for and end other sessions, whatever `mcp permissions` says.").action(async (options) => {
138572
+ const flags = { writes: options.allowWrites === true, remoteControl: options.allowRemoteControl === true };
138573
+ const inForce = () => effectiveMcpPermissions(flags, readStoredMcpPermissions(deps.paths));
138574
+ const server = createMcpServer({ name: "agent-shim", version: package_default.version }, doorMcpPorts(deps.paths, inForce));
138575
+ await serveMcp(server, new StdioServerTransport(), (announce) => watchMcpPermissions(deps.paths, announce));
138576
+ });
138577
+ withExamples(mcp, ["agent-shim mcp", "agent-shim mcp --allow-writes"]);
138578
+ const permissions = withExamples(
138579
+ mcp.command("permissions").description("Show or change what the MCP server's agents may do. A running server picks a change up on its next request, with no restart."),
138580
+ ["agent-shim mcp permissions show", "agent-shim mcp permissions allow writes"]
138581
+ );
138524
138582
  withExamples(
138525
- program2.command("mcp").description("Serve the front door's typed API as MCP tools on standard input and output, so an agent can read quota and door state and, when allowed, act on it.").option("--allow-writes", "Also expose the operations that change the door's configuration and lifecycle. Read-only without it.").option("--allow-remote-control", "Also expose the Remote Control operations that send into, answer for and end other sessions.").action(async (options) => {
138526
- const permissions = { writes: options.allowWrites === true, remoteControl: options.allowRemoteControl === true };
138527
- const server = createMcpServer({ name: "agent-shim", version: package_default.version }, doorMcpPorts(deps.paths, permissions));
138528
- await serveMcp(server, new StdioServerTransport());
138583
+ permissions.command("show").description("Print the permissions the stored file grants.").option("--json", "Print them as JSON.").action((options) => {
138584
+ const stored = readStoredMcpPermissions(deps.paths);
138585
+ if (options.json === true) {
138586
+ printJson(stored);
138587
+ return;
138588
+ }
138589
+ console.log(`writes: ${stored.writes ? "allowed" : "not allowed"}`);
138590
+ console.log(`remote-control: ${stored.remoteControl ? "allowed" : "not allowed"}`);
138529
138591
  }),
138530
- ["agent-shim mcp", "agent-shim mcp --allow-writes"]
138592
+ ["agent-shim mcp permissions show"]
138531
138593
  );
138594
+ for (const [verb, granted] of [["allow", true], ["deny", false]]) {
138595
+ withExamples(
138596
+ permissions.command(`${verb} <permission>`).description(`${verb === "allow" ? "Allow" : "Stop allowing"} \`writes\` (configuration and lifecycle operations) or \`remote-control\` (operations on other sessions) for the MCP server's agents.`).action((permission) => {
138597
+ const field = PERMISSION_FIELDS[permissionName(permission)];
138598
+ writeStoredMcpPermissions(deps.paths, { ...readStoredMcpPermissions(deps.paths), [field]: granted });
138599
+ console.log(`${permission}: ${granted ? "allowed" : "not allowed"}`);
138600
+ }),
138601
+ [`agent-shim mcp permissions ${verb} writes`]
138602
+ );
138603
+ }
138532
138604
  }
138533
138605
 
138534
138606
  // src/completion.ts
@@ -138683,17 +138755,17 @@ init_credential();
138683
138755
  init_credentialCache();
138684
138756
 
138685
138757
  // src/identityToken.ts
138686
- var import_node_fs17 = __toESM(require("node:fs"), 1);
138687
- var import_node_path46 = __toESM(require("node:path"), 1);
138758
+ var import_node_fs18 = __toESM(require("node:fs"), 1);
138759
+ var import_node_path47 = __toESM(require("node:path"), 1);
138688
138760
  init_cliError();
138689
138761
  var TOKEN_FILE_MODE = 384;
138690
138762
  var TOKEN_DIR_MODE = 448;
138691
138763
  var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
138692
138764
  function identityTokenDir(paths) {
138693
- return import_node_path46.default.join(paths.root, "credentials");
138765
+ return import_node_path47.default.join(paths.root, "credentials");
138694
138766
  }
138695
138767
  function identityTokenPath(paths, identityName) {
138696
- return import_node_path46.default.join(identityTokenDir(paths), `${identityName}.token`);
138768
+ return import_node_path47.default.join(identityTokenDir(paths), `${identityName}.token`);
138697
138769
  }
138698
138770
  function storeIdentityToken(paths, identityName, raw) {
138699
138771
  const token = raw.trim();
@@ -138701,13 +138773,13 @@ function storeIdentityToken(paths, identityName, raw) {
138701
138773
  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.");
138702
138774
  }
138703
138775
  const dir = identityTokenDir(paths);
138704
- import_node_fs17.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
138705
- import_node_fs17.default.chmodSync(dir, TOKEN_DIR_MODE);
138776
+ import_node_fs18.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
138777
+ import_node_fs18.default.chmodSync(dir, TOKEN_DIR_MODE);
138706
138778
  const target = identityTokenPath(paths, identityName);
138707
- const temp = import_node_path46.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
138708
- import_node_fs17.default.writeFileSync(temp, `${token}
138779
+ const temp = import_node_path47.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
138780
+ import_node_fs18.default.writeFileSync(temp, `${token}
138709
138781
  `, { mode: TOKEN_FILE_MODE });
138710
- import_node_fs17.default.renameSync(temp, target);
138782
+ import_node_fs18.default.renameSync(temp, target);
138711
138783
  return target;
138712
138784
  }
138713
138785
 
@@ -138870,9 +138942,9 @@ function registerDoctorCommand(program2, deps) {
138870
138942
  }
138871
138943
 
138872
138944
  // src/headroom/commands.ts
138873
- var import_node_fs18 = __toESM(require("node:fs"), 1);
138945
+ var import_node_fs19 = __toESM(require("node:fs"), 1);
138874
138946
  var import_node_http4 = __toESM(require("node:http"), 1);
138875
- var import_node_path47 = __toESM(require("node:path"), 1);
138947
+ var import_node_path48 = __toESM(require("node:path"), 1);
138876
138948
  var import_node_child_process6 = require("node:child_process");
138877
138949
  init_commandDeps();
138878
138950
  init_realFrontDoorPort();
@@ -138986,12 +139058,12 @@ function readInstalledHeadroomCommit() {
138986
139058
  if (toolDir.status !== 0) {
138987
139059
  return void 0;
138988
139060
  }
138989
- const libDir = import_node_path47.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
139061
+ const libDir = import_node_path48.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
138990
139062
  for (const python of realFarmFs.readdir(libDir)) {
138991
- const sitePackages = import_node_path47.default.join(libDir, python, "site-packages");
139063
+ const sitePackages = import_node_path48.default.join(libDir, python, "site-packages");
138992
139064
  for (const entry of realFarmFs.readdir(sitePackages)) {
138993
139065
  if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
138994
- const directUrl = realFarmFs.readFileUtf8(import_node_path47.default.join(sitePackages, entry, "direct_url.json"));
139066
+ const directUrl = realFarmFs.readFileUtf8(import_node_path48.default.join(sitePackages, entry, "direct_url.json"));
138995
139067
  return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
138996
139068
  }
138997
139069
  }
@@ -139015,12 +139087,12 @@ function realSupervisorPorts(paths) {
139015
139087
  readConfig: () => resolveSupervisorConfig(readGlobalConfig(paths)?.headroom ?? {}),
139016
139088
  spawnHeadroom: (socketPath, allowlist, settings2) => {
139017
139089
  const trust = resolveHeadroomTrustBundle({ caCertFile: paths.frontdoorCaCertFile, bundlesDir: paths.frontdoorCaBundlesDir, inherited: process.env[HEADROOM_CA_BUNDLE], fs: realTrustBundleFs });
139018
- import_node_fs18.default.mkdirSync(paths.logsDir, { recursive: true });
139090
+ import_node_fs19.default.mkdirSync(paths.logsDir, { recursive: true });
139019
139091
  if (trust?.warning !== void 0) {
139020
- import_node_fs18.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${trust.warning}
139092
+ import_node_fs19.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${trust.warning}
139021
139093
  `);
139022
139094
  }
139023
- const logFd = import_node_fs18.default.openSync(paths.headroomLogPath, "a");
139095
+ const logFd = import_node_fs19.default.openSync(paths.headroomLogPath, "a");
139024
139096
  try {
139025
139097
  const child = (0, import_node_child_process6.spawn)("headroom", headroomProxyArgs(socketPath, settings2), {
139026
139098
  detached: true,
@@ -139035,12 +139107,12 @@ function realSupervisorPorts(paths) {
139035
139107
  child.once("exit", (code, signal) => {
139036
139108
  ownedHeadroom.delete(pid);
139037
139109
  exitedHeadroom.add(pid);
139038
- import_node_fs18.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: headroom exited (${signal ?? `code ${String(code)}`})
139110
+ import_node_fs19.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: headroom exited (${signal ?? `code ${String(code)}`})
139039
139111
  `);
139040
139112
  });
139041
139113
  return pid;
139042
139114
  } finally {
139043
- import_node_fs18.default.closeSync(logFd);
139115
+ import_node_fs19.default.closeSync(logFd);
139044
139116
  }
139045
139117
  },
139046
139118
  stopProcess: (pid) => {
@@ -139053,7 +139125,7 @@ function realSupervisorPorts(paths) {
139053
139125
  now: () => Date.now()
139054
139126
  });
139055
139127
  if (outcome === "still-running") {
139056
- import_node_fs18.default.appendFileSync(
139128
+ import_node_fs19.default.appendFileSync(
139057
139129
  paths.headroomLogPath,
139058
139130
  `${(/* @__PURE__ */ new Date()).toISOString()} agent-shim headroom supervisor: pid ${String(pid)} survived SIGKILL within its grace; it is stuck uninterruptibly
139059
139131
  `
@@ -139067,10 +139139,10 @@ function realSupervisorPorts(paths) {
139067
139139
  return { ok: false, error: `uv is not installed or not on PATH (${result.error.message})` };
139068
139140
  }
139069
139141
  if (result.stdout !== "") {
139070
- import_node_fs18.default.appendFileSync(paths.headroomLogPath, result.stdout);
139142
+ import_node_fs19.default.appendFileSync(paths.headroomLogPath, result.stdout);
139071
139143
  }
139072
139144
  if (result.stderr !== "") {
139073
- import_node_fs18.default.appendFileSync(paths.headroomLogPath, result.stderr);
139145
+ import_node_fs19.default.appendFileSync(paths.headroomLogPath, result.stderr);
139074
139146
  }
139075
139147
  return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
139076
139148
  },
@@ -139080,8 +139152,8 @@ function realSupervisorPorts(paths) {
139080
139152
  },
139081
139153
  installedCommit: readInstalledHeadroomCommit,
139082
139154
  log: (line) => {
139083
- import_node_fs18.default.mkdirSync(paths.logsDir, { recursive: true });
139084
- import_node_fs18.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
139155
+ import_node_fs19.default.mkdirSync(paths.logsDir, { recursive: true });
139156
+ import_node_fs19.default.appendFileSync(paths.headroomLogPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
139085
139157
  `);
139086
139158
  }
139087
139159
  };
@@ -139531,7 +139603,7 @@ function registerRunCommand(program2, handler) {
139531
139603
  }
139532
139604
 
139533
139605
  // src/usage/commands.ts
139534
- var import_node_path48 = __toESM(require("node:path"), 1);
139606
+ var import_node_path49 = __toESM(require("node:path"), 1);
139535
139607
  init_commandDeps();
139536
139608
  init_realPorts();
139537
139609
  init_account();
@@ -139547,14 +139619,14 @@ function requireIdentity(paths, name) {
139547
139619
  throw new IdentityNotFoundError(name);
139548
139620
  }
139549
139621
  }
139550
- function collectUsageReport(fs21, paths, filters) {
139622
+ function collectUsageReport(fs22, paths, filters) {
139551
139623
  const { identity, provider, sinceMs } = filters;
139552
139624
  if (identity !== void 0) {
139553
139625
  requireIdentity(paths, identity);
139554
139626
  }
139555
- const log = readUsageLog(fs21, paths.usageLogDir, sinceMs === void 0 ? {} : { sinceMs });
139627
+ const log = readUsageLog(fs22, paths.usageLogDir, sinceMs === void 0 ? {} : { sinceMs });
139556
139628
  const records = log.records.filter((record2) => (identity === void 0 || record2.identity === identity) && (provider === void 0 || record2.provider === provider));
139557
- const snapshots = (identity === void 0 ? listUsageSnapshots(fs21, paths.usageSnapshotsDir) : [readUsageSnapshot(fs21, 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);
139629
+ const snapshots = (identity === void 0 ? listUsageSnapshots(fs22, paths.usageSnapshotsDir) : [readUsageSnapshot(fs22, 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);
139558
139630
  return {
139559
139631
  since: sinceMs === void 0 ? void 0 : new Date(sinceMs).toISOString(),
139560
139632
  logDir: paths.usageLogDir,
@@ -139670,16 +139742,16 @@ function formatUsageReport(report) {
139670
139742
  }
139671
139743
  return lines;
139672
139744
  }
139673
- function collectAccounts(fs21, paths, identity, probe) {
139745
+ function collectAccounts(fs22, paths, identity, probe) {
139674
139746
  if (identity !== void 0) {
139675
139747
  requireIdentity(paths, identity);
139676
139748
  }
139677
139749
  const names = identity === void 0 ? listIdentities(paths).map((entry) => entry.name) : [identity];
139678
139750
  return names.map((name) => ({
139679
139751
  identity: name,
139680
- account: readAccountMetadata(fs21, paths.identitiesDir, name),
139681
- signIn: identitySignIn(fs21, probe, { farmRoot: import_node_path48.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
139682
- usage: readUsageSnapshot(fs21, paths.usageSnapshotsDir, name)
139752
+ account: readAccountMetadata(fs22, paths.identitiesDir, name),
139753
+ signIn: identitySignIn(fs22, probe, { farmRoot: import_node_path49.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
139754
+ usage: readUsageSnapshot(fs22, paths.usageSnapshotsDir, name)
139683
139755
  }));
139684
139756
  }
139685
139757
  function formatAccounts(views) {
@@ -140011,7 +140083,7 @@ async function runClaude(argvOverride) {
140011
140083
  // src/cli.ts
140012
140084
  async function main() {
140013
140085
  aliasLegacyEnv(process.env);
140014
- const invokedName = import_node_path49.default.basename(process.argv[1] ?? "agent-shim");
140086
+ const invokedName = import_node_path50.default.basename(process.argv[1] ?? "agent-shim");
140015
140087
  if (isInvokedAsClaude(invokedName)) {
140016
140088
  await runClaude();
140017
140089
  return;