claude-use 9.14.0 → 9.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -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, path52) {
322
- if (!path52)
321
+ function getElementAtPath(obj, path54) {
322
+ if (!path54)
323
323
  return obj;
324
- return path52.reduce((acc, key) => acc?.[key], obj);
324
+ return path54.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(path52, issues) {
583
+ function prefixIssues(path54, issues) {
584
584
  return issues.map((iss) => {
585
585
  var _a4;
586
586
  (_a4 = iss).path ?? (_a4.path = []);
587
- iss.path.unshift(path52);
587
+ iss.path.unshift(path54);
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, path52 = []) => {
1108
+ const processError = (error64, path54 = []) => {
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 }, [...path52, ...issue2.path]));
1111
+ issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
1112
1112
  } else if (issue2.code === "invalid_key") {
1113
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
1113
+ processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
1114
1114
  } else if (issue2.code === "invalid_element") {
1115
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
1115
+ processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
1116
1116
  } else {
1117
- const fullpath = [...path52, ...issue2.path];
1117
+ const fullpath = [...path54, ...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, path52 = []) => {
1156
+ const processError = (error64, path54 = []) => {
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 }, [...path52, ...issue2.path]));
1160
+ issue2.errors.map((issues) => processError({ issues }, [...path54, ...issue2.path]));
1161
1161
  } else if (issue2.code === "invalid_key") {
1162
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
1162
+ processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
1163
1163
  } else if (issue2.code === "invalid_element") {
1164
- processError({ issues: issue2.issues }, [...path52, ...issue2.path]);
1164
+ processError({ issues: issue2.issues }, [...path54, ...issue2.path]);
1165
1165
  } else {
1166
- const fullpath = [...path52, ...issue2.path];
1166
+ const fullpath = [...path54, ...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 path52 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1206
- for (const seg of path52) {
1205
+ const path54 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1206
+ for (const seg of path54) {
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 path52 = ref.slice(1).split("/").filter(Boolean);
19203
- if (path52.length === 0) {
19202
+ const path54 = ref.slice(1).split("/").filter(Boolean);
19203
+ if (path54.length === 0) {
19204
19204
  return ctx.rootSchema;
19205
19205
  }
19206
19206
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
19207
- if (path52[0] === defsKey) {
19208
- const key = path52[1] === void 0 ? void 0 : decodeJSONPointerSegment(path52[1]);
19207
+ if (path54[0] === defsKey) {
19208
+ const key = path54[1] === void 0 ? void 0 : decodeJSONPointerSegment(path54[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 path52 = require("path");
23715
+ var path54 = 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 = path52.join(homedir, "Library");
23721
+ const library = path54.join(homedir, "Library");
23722
23722
  return {
23723
- data: path52.join(library, "Application Support", name),
23724
- config: path52.join(library, "Preferences", name),
23725
- cache: path52.join(library, "Caches", name),
23726
- log: path52.join(library, "Logs", name),
23727
- temp: path52.join(tmpdir, name)
23723
+ data: path54.join(library, "Application Support", name),
23724
+ config: path54.join(library, "Preferences", name),
23725
+ cache: path54.join(library, "Caches", name),
23726
+ log: path54.join(library, "Logs", name),
23727
+ temp: path54.join(tmpdir, name)
23728
23728
  };
23729
23729
  };
23730
23730
  var windows = (name) => {
23731
- const appData = env.APPDATA || path52.join(homedir, "AppData", "Roaming");
23732
- const localAppData = env.LOCALAPPDATA || path52.join(homedir, "AppData", "Local");
23731
+ const appData = env.APPDATA || path54.join(homedir, "AppData", "Roaming");
23732
+ const localAppData = env.LOCALAPPDATA || path54.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: path52.join(localAppData, name, "Data"),
23736
- config: path52.join(appData, name, "Config"),
23737
- cache: path52.join(localAppData, name, "Cache"),
23738
- log: path52.join(localAppData, name, "Log"),
23739
- temp: path52.join(tmpdir, name)
23735
+ data: path54.join(localAppData, name, "Data"),
23736
+ config: path54.join(appData, name, "Config"),
23737
+ cache: path54.join(localAppData, name, "Cache"),
23738
+ log: path54.join(localAppData, name, "Log"),
23739
+ temp: path54.join(tmpdir, name)
23740
23740
  };
23741
23741
  };
23742
23742
  var linux = (name) => {
23743
- const username = path52.basename(homedir);
23743
+ const username = path54.basename(homedir);
23744
23744
  return {
23745
- data: path52.join(env.XDG_DATA_HOME || path52.join(homedir, ".local", "share"), name),
23746
- config: path52.join(env.XDG_CONFIG_HOME || path52.join(homedir, ".config"), name),
23747
- cache: path52.join(env.XDG_CACHE_HOME || path52.join(homedir, ".cache"), name),
23745
+ data: path54.join(env.XDG_DATA_HOME || path54.join(homedir, ".local", "share"), name),
23746
+ config: path54.join(env.XDG_CONFIG_HOME || path54.join(homedir, ".config"), name),
23747
+ cache: path54.join(env.XDG_CACHE_HOME || path54.join(homedir, ".cache"), name),
23748
23748
  // https://wiki.debian.org/XDGBaseDirectorySpecification#state
23749
- log: path52.join(env.XDG_STATE_HOME || path52.join(homedir, ".local", "state"), name),
23750
- temp: path52.join(tmpdir, username, name)
23749
+ log: path54.join(env.XDG_STATE_HOME || path54.join(homedir, ".local", "state"), name),
23750
+ temp: path54.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, path52) {
23819
- if (typeof path52 === "string" && Object.prototype.hasOwnProperty.call(source, path52)) {
23820
- return source[path52];
23818
+ function getPropertyByPath(source, path54) {
23819
+ if (typeof path54 === "string" && Object.prototype.hasOwnProperty.call(source, path54)) {
23820
+ return source[path54];
23821
23821
  }
23822
- const parsedPath = typeof path52 === "string" ? path52.split(".") : path52;
23822
+ const parsedPath = typeof path54 === "string" ? path54.split(".") : path54;
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(path52) {
23845
+ async function isDirectory(path54) {
23846
23846
  try {
23847
- const stat = await fs_1.promises.stat(path52);
23847
+ const stat = await fs_1.promises.stat(path54);
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(path52) {
23857
+ function isDirectorySync(path54) {
23858
23858
  try {
23859
- const stat = fs_1.default.statSync(path52);
23859
+ const stat = fs_1.default.statSync(path54);
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((path52, i10) => `${i10 + 1}. ${path52}`).join("\n")} (same as ${idx + 1}.)`);
23957
+ ${[...importStack, fullPath].map((path54, i10) => `${i10 + 1}. ${path54}`).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(path52) {
24145
+ async #fileExists(path54) {
24146
24146
  try {
24147
- await promises_1.default.stat(path52);
24147
+ await promises_1.default.stat(path54);
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(path52) {
24307
+ #fileExists(path54) {
24308
24308
  try {
24309
- fs_1.default.statSync(path52);
24309
+ fs_1.default.statSync(path54);
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((path52) => path52.replace("{name}", moduleName));
24433
+ const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path54) => path54.replace("{name}", moduleName));
24434
24434
  if (userConfiguredOptions.mergeSearchPlaces) {
24435
24435
  return [...userConfiguredSearchPlaces ?? [], ...toolDefinedSearchPlaces];
24436
24436
  }
@@ -26807,7 +26807,7 @@ function isTimeZone(name) {
26807
26807
  return false;
26808
26808
  }
26809
26809
  }
26810
- var import_node_path4, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, CODEX_TIERS, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, HttpProviderSchema, CodexProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, PoolSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, WEEKDAYS, AnchorSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
26810
+ var import_node_path4, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, CODEX_TIERS, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, HttpProviderSchema, CodexProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
26811
26811
  var init_schema = __esm({
26812
26812
  "src/config/schema.ts"() {
26813
26813
  "use strict";
@@ -26982,6 +26982,25 @@ var init_schema = __esm({
26982
26982
  identities: external_exports.array(PoolMemberSchema).min(1).refine((members2) => new Set(members2.map(poolMemberIdentity)).size === members2.length, { message: "pool members must be unique" }),
26983
26983
  preference: PoolPreferenceSchema.optional()
26984
26984
  });
26985
+ WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
26986
+ AnchorSchema = external_exports.strictObject({
26987
+ days: external_exports.array(external_exports.enum(WEEKDAYS)).min(1).refine((days) => new Set(days).size === days.length, "an anchor names each weekday at most once"),
26988
+ time: external_exports.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "a 24-hour time such as 06:00"),
26989
+ timeZone: external_exports.string().refine(isTimeZone, "an IANA time zone such as Europe/London").optional()
26990
+ });
26991
+ JOB_WINDOWS = ["fiveHour", "sevenDay"];
26992
+ JobTriggerSchema = external_exports.union([external_exports.strictObject({ at: external_exports.array(AnchorSchema).min(1) }), external_exports.strictObject({ beforeReset: external_exports.enum(JOB_WINDOWS), lead: external_exports.string().regex(DURATION_RE) })]);
26993
+ JobTargetSchema = external_exports.union([external_exports.strictObject({ identity: IdentitySelectorSchema }), external_exports.strictObject({ pool: PoolNameSchema })]);
26994
+ JobSchema = external_exports.strictObject({
26995
+ target: JobTargetSchema,
26996
+ trigger: JobTriggerSchema,
26997
+ prompt: external_exports.string().min(1),
26998
+ /** The absolute directory the run works in. */
26999
+ cwd: external_exports.string().min(1),
27000
+ timeout: external_exports.string().regex(DURATION_RE),
27001
+ model: external_exports.string().min(1).optional(),
27002
+ allowedTools: external_exports.array(external_exports.string().min(1)).min(1).optional()
27003
+ });
26985
27004
  DirectoryRuleSchema = ConfigProfileSchema.omit({ description: true }).extend({
26986
27005
  path: external_exports.string().min(1),
26987
27006
  configProfile: external_exports.string().min(1).optional(),
@@ -27050,13 +27069,8 @@ var init_schema = __esm({
27050
27069
  headroom: HeadroomGlobalConfigSchema.optional(),
27051
27070
  frontdoor: FrontDoorGlobalConfigSchema.optional(),
27052
27071
  update: UpdateGlobalConfigSchema.optional(),
27053
- pools: external_exports.record(PoolNameSchema, PoolSchema).optional()
27054
- });
27055
- WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
27056
- AnchorSchema = external_exports.strictObject({
27057
- days: external_exports.array(external_exports.enum(WEEKDAYS)).min(1).refine((days) => new Set(days).size === days.length, "an anchor names each weekday at most once"),
27058
- time: external_exports.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/, "a 24-hour time such as 06:00"),
27059
- timeZone: external_exports.string().refine(isTimeZone, "an IANA time zone such as Europe/London").optional()
27072
+ pools: external_exports.record(PoolNameSchema, PoolSchema).optional(),
27073
+ jobs: external_exports.record(PoolNameSchema, JobSchema).optional()
27060
27074
  });
27061
27075
  IdentitySchema = external_exports.strictObject({
27062
27076
  $schema: external_exports.string().optional(),
@@ -28927,8 +28941,8 @@ var require_utils = __commonJS({
28927
28941
  }
28928
28942
  return output2;
28929
28943
  };
28930
- exports2.basename = (path52, { windows } = {}) => {
28931
- const segs = path52.split(windows ? /[\\/]/ : "/");
28944
+ exports2.basename = (path54, { windows } = {}) => {
28945
+ const segs = path54.split(windows ? /[\\/]/ : "/");
28932
28946
  const last = segs[segs.length - 1];
28933
28947
  if (last === "") {
28934
28948
  return segs[segs.length - 2];
@@ -32595,6 +32609,8 @@ function buildLayoutPaths(root) {
32595
32609
  usageSnapshotsDir: import_node_path19.default.join(root, "usage", "snapshots"),
32596
32610
  usagePicksFile: import_node_path19.default.join(root, "usage", "picks.json"),
32597
32611
  usageAnchorsFile: import_node_path19.default.join(root, "usage", "anchors.json"),
32612
+ usageJobsFile: import_node_path19.default.join(root, "usage", "jobs.json"),
32613
+ jobLogsDir: import_node_path19.default.join(root, "logs", "jobs"),
32598
32614
  mcpPermissionsFile: import_node_path19.default.join(root, "mcp", "permissions.json")
32599
32615
  };
32600
32616
  }
@@ -33301,7 +33317,7 @@ var init_package = __esm({
33301
33317
  "package.json"() {
33302
33318
  package_default = {
33303
33319
  name: "claude-use",
33304
- version: "9.14.0",
33320
+ version: "9.15.1",
33305
33321
  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.",
33306
33322
  license: "MIT",
33307
33323
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -33572,11 +33588,11 @@ function identifyRequest(headers) {
33572
33588
  function directOrigin(port) {
33573
33589
  return `http://127.0.0.1:${String(port)}`;
33574
33590
  }
33575
- function parseProviderPath(path52) {
33576
- if (!path52.startsWith(PROVIDER_PATH_PREFIX)) {
33591
+ function parseProviderPath(path54) {
33592
+ if (!path54.startsWith(PROVIDER_PATH_PREFIX)) {
33577
33593
  return void 0;
33578
33594
  }
33579
- const tail = path52.slice(PROVIDER_PATH_PREFIX.length);
33595
+ const tail = path54.slice(PROVIDER_PATH_PREFIX.length);
33580
33596
  const slash = tail.indexOf("/");
33581
33597
  if (slash <= 0) {
33582
33598
  return void 0;
@@ -33902,9 +33918,9 @@ function decoderFor(encoding) {
33902
33918
  return void 0;
33903
33919
  }
33904
33920
  }
33905
- function destinationOf(path52) {
33906
- const scoped = parseProviderPath(path52);
33907
- return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path52 } : { provider: scoped.provider, endpoint: scoped.rest };
33921
+ function destinationOf(path54) {
33922
+ const scoped = parseProviderPath(path54);
33923
+ return scoped === void 0 ? { provider: ANTHROPIC_PROVIDER, endpoint: path54 } : { provider: scoped.provider, endpoint: scoped.rest };
33908
33924
  }
33909
33925
  function buildRecord(event, context) {
33910
33926
  const { scan } = context;
@@ -36340,14 +36356,14 @@ var require_util2 = __commonJS({
36340
36356
  }
36341
36357
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
36342
36358
  let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
36343
- let path52 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
36359
+ let path54 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
36344
36360
  if (origin[origin.length - 1] === "/") {
36345
36361
  origin = origin.slice(0, origin.length - 1);
36346
36362
  }
36347
- if (path52 && path52[0] !== "/") {
36348
- path52 = `/${path52}`;
36363
+ if (path54 && path54[0] !== "/") {
36364
+ path54 = `/${path54}`;
36349
36365
  }
36350
- return new URL(`${origin}${path52}`);
36366
+ return new URL(`${origin}${path54}`);
36351
36367
  }
36352
36368
  if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
36353
36369
  throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -37168,9 +37184,9 @@ var require_diagnostics = __commonJS({
37168
37184
  "undici:client:sendHeaders",
37169
37185
  (evt) => {
37170
37186
  const {
37171
- request: { method, path: path52, origin }
37187
+ request: { method, path: path54, origin }
37172
37188
  } = evt;
37173
- debugLog("sending request to %s %s%s", method, origin, path52);
37189
+ debugLog("sending request to %s %s%s", method, origin, path54);
37174
37190
  }
37175
37191
  );
37176
37192
  }
@@ -37188,14 +37204,14 @@ var require_diagnostics = __commonJS({
37188
37204
  "undici:request:headers",
37189
37205
  (evt) => {
37190
37206
  const {
37191
- request: { method, path: path52, origin },
37207
+ request: { method, path: path54, origin },
37192
37208
  response: { statusCode }
37193
37209
  } = evt;
37194
37210
  debugLog(
37195
37211
  "received response to %s %s%s - HTTP %d",
37196
37212
  method,
37197
37213
  origin,
37198
- path52,
37214
+ path54,
37199
37215
  statusCode
37200
37216
  );
37201
37217
  }
@@ -37204,23 +37220,23 @@ var require_diagnostics = __commonJS({
37204
37220
  "undici:request:trailers",
37205
37221
  (evt) => {
37206
37222
  const {
37207
- request: { method, path: path52, origin }
37223
+ request: { method, path: path54, origin }
37208
37224
  } = evt;
37209
- debugLog("trailers received from %s %s%s", method, origin, path52);
37225
+ debugLog("trailers received from %s %s%s", method, origin, path54);
37210
37226
  }
37211
37227
  );
37212
37228
  diagnosticsChannel.subscribe(
37213
37229
  "undici:request:error",
37214
37230
  (evt) => {
37215
37231
  const {
37216
- request: { method, path: path52, origin },
37232
+ request: { method, path: path54, origin },
37217
37233
  error: error63
37218
37234
  } = evt;
37219
37235
  debugLog(
37220
37236
  "request to %s %s%s errored - %s",
37221
37237
  method,
37222
37238
  origin,
37223
- path52,
37239
+ path54,
37224
37240
  error63.message
37225
37241
  );
37226
37242
  }
@@ -37335,7 +37351,7 @@ var require_request = __commonJS({
37335
37351
  var kHandler = /* @__PURE__ */ Symbol("handler");
37336
37352
  var Request2 = class {
37337
37353
  constructor(origin, {
37338
- path: path52,
37354
+ path: path54,
37339
37355
  method,
37340
37356
  body,
37341
37357
  headers,
@@ -37352,11 +37368,11 @@ var require_request = __commonJS({
37352
37368
  maxRedirections,
37353
37369
  typeOfService
37354
37370
  }, handler) {
37355
- if (typeof path52 !== "string") {
37371
+ if (typeof path54 !== "string") {
37356
37372
  throw new InvalidArgumentError2("path must be a string");
37357
- } else if (path52[0] !== "/" && !(path52.startsWith("http://") || path52.startsWith("https://")) && method !== "CONNECT") {
37373
+ } else if (path54[0] !== "/" && !(path54.startsWith("http://") || path54.startsWith("https://")) && method !== "CONNECT") {
37358
37374
  throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
37359
- } else if (invalidPathRegex.test(path52)) {
37375
+ } else if (invalidPathRegex.test(path54)) {
37360
37376
  throw new InvalidArgumentError2("invalid request path");
37361
37377
  }
37362
37378
  if (typeof method !== "string") {
@@ -37431,7 +37447,7 @@ var require_request = __commonJS({
37431
37447
  this.completed = false;
37432
37448
  this.aborted = false;
37433
37449
  this.upgrade = upgrade || null;
37434
- this.path = query ? serializePathWithQuery(path52, query) : path52;
37450
+ this.path = query ? serializePathWithQuery(path54, query) : path54;
37435
37451
  this.origin = origin;
37436
37452
  this.protocol = getProtocolFromUrlString(origin);
37437
37453
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
@@ -42613,7 +42629,7 @@ var require_client_h1 = __commonJS({
42613
42629
  return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
42614
42630
  }
42615
42631
  function writeH1(client, request7) {
42616
- const { method, path: path52, host, upgrade, blocking, reset } = request7;
42632
+ const { method, path: path54, host, upgrade, blocking, reset } = request7;
42617
42633
  let { body, headers, contentLength } = request7;
42618
42634
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
42619
42635
  if (util2.isFormDataLike(body)) {
@@ -42691,7 +42707,7 @@ var require_client_h1 = __commonJS({
42691
42707
  if (socket.setTypeOfService) {
42692
42708
  socket.setTypeOfService(request7.typeOfService);
42693
42709
  }
42694
- let header = `${method} ${path52} HTTP/1.1\r
42710
+ let header = `${method} ${path54} HTTP/1.1\r
42695
42711
  `;
42696
42712
  if (typeof host === "string") {
42697
42713
  header += `host: ${host}\r
@@ -43370,7 +43386,7 @@ var require_client_h2 = __commonJS({
43370
43386
  const headersTimeout = request7.headersTimeout ?? client[kHeadersTimeout];
43371
43387
  const bodyTimeout = request7.bodyTimeout ?? client[kBodyTimeout];
43372
43388
  const session = client[kHTTP2Session];
43373
- const { method, path: path52, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
43389
+ const { method, path: path54, host, upgrade, expectContinue, signal, protocol, headers: reqHeaders } = request7;
43374
43390
  let { body } = request7;
43375
43391
  if (upgrade != null && upgrade !== "websocket") {
43376
43392
  util2.errorRequest(client, request7, new InvalidArgumentError2(`Custom upgrade "${upgrade}" not supported over HTTP/2`));
@@ -43439,7 +43455,7 @@ var require_client_h2 = __commonJS({
43439
43455
  }
43440
43456
  headers[HTTP2_HEADER_METHOD] = "CONNECT";
43441
43457
  headers[HTTP2_HEADER_PROTOCOL] = "websocket";
43442
- headers[HTTP2_HEADER_PATH] = path52;
43458
+ headers[HTTP2_HEADER_PATH] = path54;
43443
43459
  if (protocol === "ws:" || protocol === "wss:") {
43444
43460
  headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
43445
43461
  } else {
@@ -43481,7 +43497,7 @@ var require_client_h2 = __commonJS({
43481
43497
  stream.setTimeout(headersTimeout);
43482
43498
  return true;
43483
43499
  }
43484
- headers[HTTP2_HEADER_PATH] = path52;
43500
+ headers[HTTP2_HEADER_PATH] = path54;
43485
43501
  headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
43486
43502
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
43487
43503
  if (body && typeof body.read === "function") {
@@ -45833,10 +45849,10 @@ var require_proxy_agent = __commonJS({
45833
45849
  };
45834
45850
  const {
45835
45851
  origin,
45836
- path: path52 = "/",
45852
+ path: path54 = "/",
45837
45853
  headers = {}
45838
45854
  } = opts;
45839
- opts.path = origin + path52;
45855
+ opts.path = origin + path54;
45840
45856
  if (!("host" in headers) && !("Host" in headers)) {
45841
45857
  const { host } = new URL(origin);
45842
45858
  headers.host = host;
@@ -47945,20 +47961,20 @@ var require_mock_utils = __commonJS({
47945
47961
  }
47946
47962
  return normalizedQp;
47947
47963
  }
47948
- function safeUrl(path52) {
47949
- if (typeof path52 !== "string") {
47950
- return path52;
47964
+ function safeUrl(path54) {
47965
+ if (typeof path54 !== "string") {
47966
+ return path54;
47951
47967
  }
47952
- const pathSegments = path52.split("?", 3);
47968
+ const pathSegments = path54.split("?", 3);
47953
47969
  if (pathSegments.length !== 2) {
47954
- return path52;
47970
+ return path54;
47955
47971
  }
47956
47972
  const qp2 = new URLSearchParams(pathSegments.pop());
47957
47973
  qp2.sort();
47958
47974
  return [...pathSegments, qp2.toString()].join("?");
47959
47975
  }
47960
- function matchKey(mockDispatch2, { path: path52, method, body, headers }) {
47961
- const pathMatch = matchValue(mockDispatch2.path, path52);
47976
+ function matchKey(mockDispatch2, { path: path54, method, body, headers }) {
47977
+ const pathMatch = matchValue(mockDispatch2.path, path54);
47962
47978
  const methodMatch = matchValue(mockDispatch2.method, method);
47963
47979
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
47964
47980
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -47983,8 +47999,8 @@ var require_mock_utils = __commonJS({
47983
47999
  const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
47984
48000
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
47985
48001
  const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
47986
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path52, ignoreTrailingSlash }) => {
47987
- return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path52)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path52), resolvedPath);
48002
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path54, ignoreTrailingSlash }) => {
48003
+ return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path54)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path54), resolvedPath);
47988
48004
  });
47989
48005
  if (matchedMockDispatches.length === 0) {
47990
48006
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
@@ -48023,19 +48039,19 @@ var require_mock_utils = __commonJS({
48023
48039
  mockDispatches.splice(index, 1);
48024
48040
  }
48025
48041
  }
48026
- function removeTrailingSlash(path52) {
48027
- while (path52.endsWith("/")) {
48028
- path52 = path52.slice(0, -1);
48042
+ function removeTrailingSlash(path54) {
48043
+ while (path54.endsWith("/")) {
48044
+ path54 = path54.slice(0, -1);
48029
48045
  }
48030
- if (path52.length === 0) {
48031
- path52 = "/";
48046
+ if (path54.length === 0) {
48047
+ path54 = "/";
48032
48048
  }
48033
- return path52;
48049
+ return path54;
48034
48050
  }
48035
48051
  function buildKey(opts) {
48036
- const { path: path52, method, body, headers, query } = opts;
48052
+ const { path: path54, method, body, headers, query } = opts;
48037
48053
  return {
48038
- path: path52,
48054
+ path: path54,
48039
48055
  method,
48040
48056
  body,
48041
48057
  headers,
@@ -48725,10 +48741,10 @@ var require_pending_interceptors_formatter = __commonJS({
48725
48741
  }
48726
48742
  format(pendingInterceptors) {
48727
48743
  const withPrettyHeaders = pendingInterceptors.map(
48728
- ({ method, path: path52, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
48744
+ ({ method, path: path54, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
48729
48745
  Method: method,
48730
48746
  Origin: origin,
48731
- Path: path52,
48747
+ Path: path54,
48732
48748
  "Status code": statusCode,
48733
48749
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
48734
48750
  Invocations: timesInvoked,
@@ -48810,9 +48826,9 @@ var require_mock_agent = __commonJS({
48810
48826
  const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
48811
48827
  const dispatchOpts = { ...opts };
48812
48828
  if (acceptNonStandardSearchParameters && dispatchOpts.path) {
48813
- const [path52, searchParams] = dispatchOpts.path.split("?");
48829
+ const [path54, searchParams] = dispatchOpts.path.split("?");
48814
48830
  const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
48815
- dispatchOpts.path = `${path52}?${normalizedSearchParams}`;
48831
+ dispatchOpts.path = `${path54}?${normalizedSearchParams}`;
48816
48832
  }
48817
48833
  return this[kAgent].dispatch(dispatchOpts, handler);
48818
48834
  }
@@ -49213,12 +49229,12 @@ var require_snapshot_recorder = __commonJS({
49213
49229
  * @return {Promise<void>} - Resolves when snapshots are loaded
49214
49230
  */
49215
49231
  async loadSnapshots(filePath) {
49216
- const path52 = filePath || this.#snapshotPath;
49217
- if (!path52) {
49232
+ const path54 = filePath || this.#snapshotPath;
49233
+ if (!path54) {
49218
49234
  throw new InvalidArgumentError2("Snapshot path is required");
49219
49235
  }
49220
49236
  try {
49221
- const data = await readFile(resolve2(path52), "utf8");
49237
+ const data = await readFile(resolve2(path54), "utf8");
49222
49238
  const parsed = JSON.parse(data);
49223
49239
  if (Array.isArray(parsed)) {
49224
49240
  this.#snapshots.clear();
@@ -49232,7 +49248,7 @@ var require_snapshot_recorder = __commonJS({
49232
49248
  if (error63.code === "ENOENT") {
49233
49249
  this.#snapshots.clear();
49234
49250
  } else {
49235
- throw new UndiciError(`Failed to load snapshots from ${path52}`, { cause: error63 });
49251
+ throw new UndiciError(`Failed to load snapshots from ${path54}`, { cause: error63 });
49236
49252
  }
49237
49253
  }
49238
49254
  }
@@ -49243,11 +49259,11 @@ var require_snapshot_recorder = __commonJS({
49243
49259
  * @returns {Promise<void>} - Resolves when snapshots are saved
49244
49260
  */
49245
49261
  async saveSnapshots(filePath) {
49246
- const path52 = filePath || this.#snapshotPath;
49247
- if (!path52) {
49262
+ const path54 = filePath || this.#snapshotPath;
49263
+ if (!path54) {
49248
49264
  throw new InvalidArgumentError2("Snapshot path is required");
49249
49265
  }
49250
- const resolvedPath = resolve2(path52);
49266
+ const resolvedPath = resolve2(path54);
49251
49267
  await mkdir(dirname3(resolvedPath), { recursive: true });
49252
49268
  const data = Array.from(this.#snapshots.entries()).map(([hash2, snapshot]) => ({
49253
49269
  hash: hash2,
@@ -49879,15 +49895,15 @@ var require_redirect_handler = __commonJS({
49879
49895
  return;
49880
49896
  }
49881
49897
  const { origin, pathname, search } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
49882
- const path52 = search ? `${pathname}${search}` : pathname;
49883
- const redirectUrlString = `${origin}${path52}`;
49898
+ const path54 = search ? `${pathname}${search}` : pathname;
49899
+ const redirectUrlString = `${origin}${path54}`;
49884
49900
  for (const historyUrl of this.history) {
49885
49901
  if (historyUrl.toString() === redirectUrlString) {
49886
49902
  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.`);
49887
49903
  }
49888
49904
  }
49889
49905
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
49890
- this.opts.path = path52;
49906
+ this.opts.path = path54;
49891
49907
  this.opts.origin = origin;
49892
49908
  this.opts.query = null;
49893
49909
  }
@@ -51647,10 +51663,10 @@ var require_cache_handler = __commonJS({
51647
51663
  }
51648
51664
  return locationUrl.pathname + locationUrl.search;
51649
51665
  }
51650
- function deleteCachedUri(store, cacheKey, path52) {
51666
+ function deleteCachedUri(store, cacheKey, path54) {
51651
51667
  deleteCachedValue(store, {
51652
51668
  ...cacheKey,
51653
- path: path52
51669
+ path: path54
51654
51670
  });
51655
51671
  for (let i10 = 0; i10 < util2.safeHTTPMethods.length; i10++) {
51656
51672
  const method = util2.safeHTTPMethods[i10];
@@ -51658,7 +51674,7 @@ var require_cache_handler = __commonJS({
51658
51674
  deleteCachedValue(store, {
51659
51675
  ...cacheKey,
51660
51676
  method,
51661
- path: path52
51677
+ path: path54
51662
51678
  });
51663
51679
  }
51664
51680
  }
@@ -51669,9 +51685,9 @@ var require_cache_handler = __commonJS({
51669
51685
  }
51670
51686
  const values = Array.isArray(headerValue2) ? headerValue2 : [headerValue2];
51671
51687
  for (let i10 = 0; i10 < values.length; i10++) {
51672
- const path52 = getSameOriginPath(cacheKey, values[i10]);
51673
- if (path52 !== void 0) {
51674
- deleteCachedUri(store, cacheKey, path52);
51688
+ const path54 = getSameOriginPath(cacheKey, values[i10]);
51689
+ if (path54 !== void 0) {
51690
+ deleteCachedUri(store, cacheKey, path54);
51675
51691
  }
51676
51692
  }
51677
51693
  }
@@ -56671,11 +56687,11 @@ var require_fetch = __commonJS({
56671
56687
  function dispatch({ body }) {
56672
56688
  const url2 = requestCurrentURL(request7);
56673
56689
  const agent = fetchParams.controller.dispatcher;
56674
- const path52 = url2.pathname + url2.search;
56690
+ const path54 = url2.pathname + url2.search;
56675
56691
  const hasTrailingQuestionMark = url2.search.length === 0 && url2.href[url2.href.length - url2.hash.length - 1] === "?";
56676
56692
  return new Promise((resolve2, reject) => agent.dispatch(
56677
56693
  {
56678
- path: hasTrailingQuestionMark ? `${path52}?` : path52,
56694
+ path: hasTrailingQuestionMark ? `${path54}?` : path54,
56679
56695
  origin: url2.origin,
56680
56696
  method: request7.method,
56681
56697
  body: agent.isMockActive ? request7.body && (request7.body.source || request7.body.stream) : body,
@@ -57622,9 +57638,9 @@ var require_util5 = __commonJS({
57622
57638
  }
57623
57639
  }
57624
57640
  }
57625
- function validateCookiePath(path52) {
57626
- for (let i10 = 0; i10 < path52.length; ++i10) {
57627
- const code = path52.charCodeAt(i10);
57641
+ function validateCookiePath(path54) {
57642
+ for (let i10 = 0; i10 < path54.length; ++i10) {
57643
+ const code = path54.charCodeAt(i10);
57628
57644
  if (code < 32 || // exclude CTLs (0-31)
57629
57645
  code > 126 || // exclude DEL and non-ascii
57630
57646
  code === 59) {
@@ -60972,11 +60988,11 @@ var require_undici = __commonJS({
60972
60988
  if (typeof opts.path !== "string") {
60973
60989
  throw new InvalidArgumentError2("invalid opts.path");
60974
60990
  }
60975
- let path52 = opts.path;
60991
+ let path54 = opts.path;
60976
60992
  if (!opts.path.startsWith("/")) {
60977
- path52 = `/${path52}`;
60993
+ path54 = `/${path54}`;
60978
60994
  }
60979
- url2 = new URL(util2.parseOrigin(url2).origin + path52);
60995
+ url2 = new URL(util2.parseOrigin(url2).origin + path54);
60980
60996
  } else {
60981
60997
  if (!opts) {
60982
60998
  opts = typeof url2 === "object" ? url2 : {};
@@ -99973,8 +99989,8 @@ var require_utils3 = __commonJS({
99973
99989
  }
99974
99990
  return ind;
99975
99991
  }
99976
- function removeDotSegments(path52) {
99977
- let input2 = path52;
99992
+ function removeDotSegments(path54) {
99993
+ let input2 = path54;
99978
99994
  const output2 = [];
99979
99995
  let nextSlash = -1;
99980
99996
  let len = 0;
@@ -100383,8 +100399,8 @@ var require_schemes = __commonJS({
100383
100399
  }
100384
100400
  if (wsComponent.resourceName) {
100385
100401
  const queryIndex = wsComponent.resourceName.indexOf("?");
100386
- const path52 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
100387
- wsComponent.path = path52 && path52 !== "/" ? path52 : void 0;
100402
+ const path54 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
100403
+ wsComponent.path = path54 && path54 !== "/" ? path54 : void 0;
100388
100404
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
100389
100405
  wsComponent.resourceName = void 0;
100390
100406
  }
@@ -103911,7 +103927,7 @@ var require_dist2 = __commonJS({
103911
103927
  });
103912
103928
 
103913
103929
  // src/cli.ts
103914
- var import_node_path51 = __toESM(require("node:path"), 1);
103930
+ var import_node_path53 = __toESM(require("node:path"), 1);
103915
103931
 
103916
103932
  // node_modules/.pnpm/commander@15.0.0/node_modules/commander/lib/error.js
103917
103933
  var CommanderError = class extends Error {
@@ -107024,9 +107040,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
107024
107040
  * @param {string} [path]
107025
107041
  * @return {(string|null|Command)}
107026
107042
  */
107027
- executableDir(path52) {
107028
- if (path52 === void 0) return this._executableDir;
107029
- this._executableDir = path52;
107043
+ executableDir(path54) {
107044
+ if (path54 === void 0) return this._executableDir;
107045
+ this._executableDir = path54;
107030
107046
  return this;
107031
107047
  }
107032
107048
  /**
@@ -108675,19 +108691,19 @@ function writePools(paths, pools) {
108675
108691
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
108676
108692
  }
108677
108693
  function poolCycleOf(pools, name) {
108678
- const walk = (current, path52) => {
108694
+ const walk = (current, path54) => {
108679
108695
  for (const entry of pools[current]?.identities ?? []) {
108680
108696
  const nested = poolNameOf(poolMemberIdentity(entry));
108681
108697
  if (nested === void 0) {
108682
108698
  continue;
108683
108699
  }
108684
108700
  if (nested === name) {
108685
- return [...path52, nested];
108701
+ return [...path54, nested];
108686
108702
  }
108687
- if (path52.includes(nested)) {
108703
+ if (path54.includes(nested)) {
108688
108704
  continue;
108689
108705
  }
108690
- const found = walk(nested, [...path52, nested]);
108706
+ const found = walk(nested, [...path54, nested]);
108691
108707
  if (found !== void 0) {
108692
108708
  return found;
108693
108709
  }
@@ -109753,6 +109769,12 @@ function collectRepeated(value2, previous = []) {
109753
109769
  function collectAnchor(value2, previous = []) {
109754
109770
  return [...previous, asInvalidArgument(() => parseAnchor(value2))];
109755
109771
  }
109772
+ function parseDurationLiteral(value2) {
109773
+ return asInvalidArgument(() => {
109774
+ parseDuration(value2);
109775
+ return value2;
109776
+ });
109777
+ }
109756
109778
  function parseDurationOption(value2) {
109757
109779
  return asInvalidArgument(() => parseDuration(value2));
109758
109780
  }
@@ -111623,7 +111645,7 @@ function registerCodexCommand(program2, deps) {
111623
111645
 
111624
111646
  // src/frontdoor/commands.ts
111625
111647
  var import_node_crypto20 = require("node:crypto");
111626
- var import_node_path46 = __toESM(require("node:path"), 1);
111648
+ var import_node_path47 = __toESM(require("node:path"), 1);
111627
111649
  var import_node_fs16 = __toESM(require("node:fs"), 1);
111628
111650
  init_commandDeps();
111629
111651
  init_schema();
@@ -111824,6 +111846,63 @@ function registerUpdateCommand(program2, deps, ports = realUpdatePorts) {
111824
111846
  );
111825
111847
  }
111826
111848
 
111849
+ // src/jobStore.ts
111850
+ init_cliError();
111851
+ init_store();
111852
+ init_schema();
111853
+ var JobNotFoundError = class extends CliError {
111854
+ constructor(jobName) {
111855
+ super(`No job named "${jobName}". Run \`agent-shim job add ${jobName} ...\` first.`);
111856
+ this.jobName = jobName;
111857
+ this.name = "JobNotFoundError";
111858
+ }
111859
+ jobName;
111860
+ };
111861
+ var JobAlreadyExistsError = class extends CliError {
111862
+ constructor(jobName) {
111863
+ super(`A job named "${jobName}" already exists. Remove it with \`agent-shim job remove ${jobName}\` to define it again.`);
111864
+ this.jobName = jobName;
111865
+ this.name = "JobAlreadyExistsError";
111866
+ }
111867
+ jobName;
111868
+ };
111869
+ var InvalidJobNameError = class extends CliError {
111870
+ constructor(attemptedName) {
111871
+ super(`"${attemptedName}" is not a valid job name: it must start with a letter or number and may then contain letters, numbers, dots, hyphens and underscores.`);
111872
+ this.attemptedName = attemptedName;
111873
+ this.name = "InvalidJobNameError";
111874
+ }
111875
+ attemptedName;
111876
+ };
111877
+ function readJobs(paths) {
111878
+ return readGlobalConfig(paths)?.jobs ?? {};
111879
+ }
111880
+ function requireJob(paths, name) {
111881
+ const job = readJobs(paths)[name];
111882
+ if (job === void 0) {
111883
+ throw new JobNotFoundError(name);
111884
+ }
111885
+ return job;
111886
+ }
111887
+ function writeJobs(paths, jobs) {
111888
+ applyPatch(paths.globalConfigFile, GlobalConfigSchema, { jobs: Object.keys(jobs).length === 0 ? void 0 : jobs }, { defaults: {} });
111889
+ }
111890
+ function addJob(paths, name, job) {
111891
+ if (!PoolNameSchema.safeParse(name).success) {
111892
+ throw new InvalidJobNameError(name);
111893
+ }
111894
+ const jobs = readJobs(paths);
111895
+ if (jobs[name] !== void 0) {
111896
+ throw new JobAlreadyExistsError(name);
111897
+ }
111898
+ writeJobs(paths, { ...jobs, [name]: job });
111899
+ return job;
111900
+ }
111901
+ function removeJob(paths, name) {
111902
+ requireJob(paths, name);
111903
+ writeJobs(paths, Object.fromEntries(Object.entries(readJobs(paths)).filter(([existing]) => existing !== name)));
111904
+ }
111905
+
111827
111906
  // src/launcher/poolRefresh.ts
111828
111907
  init_anthropicUsageRefresh();
111829
111908
  async function refreshStalePoolMembers(params) {
@@ -111839,6 +111918,75 @@ init_anthropicUsageRefresh();
111839
111918
  init_poolPick();
111840
111919
  init_realAnthropicUsageProbe();
111841
111920
 
111921
+ // src/usage/realJobRunner.ts
111922
+ var import_node_path38 = __toESM(require("node:path"), 1);
111923
+ init_conditions();
111924
+ init_identityClaude();
111925
+
111926
+ // src/usage/sdkResult.ts
111927
+ function successfulResult(message) {
111928
+ if (message.subtype !== "success") {
111929
+ throw new Error(`the run ended as ${message.subtype}`);
111930
+ }
111931
+ if (message.is_error) {
111932
+ throw new Error(`the run ended on an error: ${message.result}`);
111933
+ }
111934
+ return message.result;
111935
+ }
111936
+
111937
+ // src/usage/realJobRunner.ts
111938
+ var JOB_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
111939
+ var JOB_ISOLATION_OPTIONS = { settingSources: ["user"], mcpServers: {}, strictMcpConfig: true };
111940
+ function logEntry(name, identity, endedAt, outcome) {
111941
+ return `${endedAt.toISOString()} job ${name} as ${identity}
111942
+ ${outcome.trimEnd()}
111943
+
111944
+ `;
111945
+ }
111946
+ function createRealJobRunner(params) {
111947
+ return async (name, identity, job) => {
111948
+ const logFile = import_node_path38.default.join(params.paths.jobLogsDir, `${name}.log`);
111949
+ const append = (outcome) => {
111950
+ params.fs.mkdirPrivate(params.paths.jobLogsDir);
111951
+ params.fs.appendFilePrivate(logFile, logEntry(name, identity, params.now(), outcome));
111952
+ };
111953
+ try {
111954
+ const result = await withIdentityClaude({ paths: params.paths, spawnDaemon: params.spawnDaemon, cwd: job.cwd, timeoutMs: parseDuration(job.timeout) }, identity, JOB_LAUNCH_FLAGS, async ({ bin, env, cwd, abort }) => {
111955
+ const { query } = await Promise.resolve().then(() => (init_sdk(), sdk_exports));
111956
+ const session = query({
111957
+ prompt: job.prompt,
111958
+ options: {
111959
+ pathToClaudeCodeExecutable: bin,
111960
+ env,
111961
+ cwd,
111962
+ abortController: abort,
111963
+ settingSources: [...JOB_ISOLATION_OPTIONS.settingSources],
111964
+ mcpServers: JOB_ISOLATION_OPTIONS.mcpServers,
111965
+ strictMcpConfig: JOB_ISOLATION_OPTIONS.strictMcpConfig,
111966
+ permissionMode: "dontAsk",
111967
+ ...job.model === void 0 ? {} : { model: job.model },
111968
+ ...job.allowedTools === void 0 ? {} : { allowedTools: [...job.allowedTools] }
111969
+ }
111970
+ });
111971
+ try {
111972
+ for await (const message of session) {
111973
+ if (message.type === "result") {
111974
+ return successfulResult(message);
111975
+ }
111976
+ }
111977
+ throw new Error("the run ended without a result");
111978
+ } finally {
111979
+ session.close();
111980
+ }
111981
+ });
111982
+ append(result);
111983
+ } catch (error63) {
111984
+ append(`FAILED: ${error63 instanceof Error ? error63.message : String(error63)}`);
111985
+ throw error63;
111986
+ }
111987
+ };
111988
+ }
111989
+
111842
111990
  // src/usage/realWindowOpener.ts
111843
111991
  init_identityClaude();
111844
111992
  var OPENER_LAUNCH_FLAGS = ["--no-headroom", "--no-remote-control", "--track-usage"];
@@ -111871,9 +112019,7 @@ function createRealWindowOpener(params) {
111871
112019
  try {
111872
112020
  for await (const message of session) {
111873
112021
  if (message.type === "result") {
111874
- if (message.subtype !== "success") {
111875
- throw new Error(`the opening request ended as ${message.subtype}`);
111876
- }
112022
+ successfulResult(message);
111877
112023
  return;
111878
112024
  }
111879
112025
  }
@@ -111885,18 +112031,18 @@ function createRealWindowOpener(params) {
111885
112031
  };
111886
112032
  }
111887
112033
 
111888
- // src/usage/windowKeeper.ts
111889
- var import_node_path38 = __toESM(require("node:path"), 1);
112034
+ // src/usage/jobKeeper.ts
112035
+ init_conditions();
112036
+
112037
+ // src/usage/handledStamps.ts
112038
+ var import_node_path39 = __toESM(require("node:path"), 1);
111890
112039
  init_zod();
111891
- init_preflight();
111892
- init_pick();
111893
- init_middleware();
111894
112040
  var STAMPS_SCHEMA_VERSION = 1;
111895
112041
  var StampsFileSchema = external_exports.strictObject({
111896
112042
  schemaVersion: external_exports.literal(STAMPS_SCHEMA_VERSION),
111897
112043
  handled: external_exports.record(external_exports.string().min(1), external_exports.iso.datetime())
111898
112044
  });
111899
- function readStamps(fs22, file2) {
112045
+ function readHandled(fs22, file2) {
111900
112046
  const raw = fs22.readFileUtf8(file2);
111901
112047
  if (raw === void 0) {
111902
112048
  return {};
@@ -111908,14 +112054,31 @@ function readStamps(fs22, file2) {
111908
112054
  parsed = void 0;
111909
112055
  }
111910
112056
  const result = StampsFileSchema.safeParse(parsed);
111911
- return result.success ? Object.fromEntries(Object.entries(result.data.handled).map(([identity, at2]) => [identity, Date.parse(at2)])) : {};
112057
+ return result.success ? Object.fromEntries(Object.entries(result.data.handled).map(([key, at2]) => [key, Date.parse(at2)])) : {};
111912
112058
  }
111913
- function writeStamps(fs22, file2, handled) {
111914
- const next = { schemaVersion: STAMPS_SCHEMA_VERSION, handled: Object.fromEntries(Object.entries(handled).map(([identity, at2]) => [identity, new Date(at2).toISOString()])) };
111915
- fs22.mkdirPrivate(import_node_path38.default.dirname(file2));
112059
+ function writeHandled(fs22, file2, handled) {
112060
+ const next = { schemaVersion: STAMPS_SCHEMA_VERSION, handled: Object.fromEntries(Object.entries(handled).map(([key, at2]) => [key, new Date(at2).toISOString()])) };
112061
+ fs22.mkdirPrivate(import_node_path39.default.dirname(file2));
111916
112062
  fs22.writeFilePrivate(file2, `${JSON.stringify(next, null, 2)}
111917
112063
  `);
111918
112064
  }
112065
+
112066
+ // src/usage/jobKeeper.ts
112067
+ init_middleware();
112068
+ init_pick();
112069
+ init_preflight();
112070
+
112071
+ // src/usage/windowKeeper.ts
112072
+ init_preflight();
112073
+ init_pick();
112074
+ init_middleware();
112075
+ function refusalReason(identity, snapshot, nowMs) {
112076
+ if (snapshot === void 0) {
112077
+ return void 0;
112078
+ }
112079
+ const candidate = rankPool({ members: [{ identity, snapshot, records: [] }], nowMs, resuming: false }).candidates[0];
112080
+ return candidate?.class === "ineligible" ? `it is refused right now (${candidate.reasons[0] ?? "no reason recorded"})` : void 0;
112081
+ }
111919
112082
  function reasonNotToOpen(identity, snapshot, nowMs) {
111920
112083
  if (snapshot === void 0) {
111921
112084
  return void 0;
@@ -111928,13 +112091,12 @@ function reasonNotToOpen(identity, snapshot, nowMs) {
111928
112091
  if (five?.resetsAtMs !== void 0) {
111929
112092
  return `a five-hour window is already open, resetting in ${formatAge(five.resetsAtMs - nowMs)}`;
111930
112093
  }
111931
- const candidate = rankPool({ members: [{ identity, snapshot, records: [] }], nowMs, resuming: false }).candidates[0];
111932
- return candidate?.class === "ineligible" ? `it is refused right now (${candidate.reasons[0] ?? "no reason recorded"})` : void 0;
112094
+ return refusalReason(identity, snapshot, nowMs);
111933
112095
  }
111934
112096
  async function runWindowKeeper(ports) {
111935
112097
  const nowMs = ports.nowMs();
111936
112098
  const anchored = ports.anchored();
111937
- const previous = readStamps(ports.fs, ports.stampsFile);
112099
+ const previous = readHandled(ports.fs, ports.stampsFile);
111938
112100
  const handled = Object.fromEntries(anchored.flatMap(({ identity }) => previous[identity] === void 0 ? [] : [[identity, previous[identity]]]));
111939
112101
  const outcomes = [];
111940
112102
  for (const { identity, anchors } of anchored) {
@@ -111962,7 +112124,7 @@ async function runWindowKeeper(ports) {
111962
112124
  outcomes.push({ identity, status: "failed", detail: `anchor ${new Date(due2).toISOString()}: could not open a window: ${error63 instanceof Error ? error63.message : String(error63)}` });
111963
112125
  }
111964
112126
  }
111965
- writeStamps(ports.fs, ports.stampsFile, handled);
112127
+ writeHandled(ports.fs, ports.stampsFile, handled);
111966
112128
  for (const outcome of outcomes) {
111967
112129
  if (outcome.status === "opened" || outcome.status === "skipped" || outcome.status === "failed") {
111968
112130
  ports.log(`window keeper: ${outcome.identity}: ${outcome.detail}`);
@@ -111971,6 +112133,113 @@ async function runWindowKeeper(ports) {
111971
112133
  return outcomes;
111972
112134
  }
111973
112135
 
112136
+ // src/usage/jobKeeper.ts
112137
+ var WINDOW_LENGTH_MS = { fiveHour: FIVE_HOUR_WINDOW_MS, sevenDay: SEVEN_DAY_WINDOW_MS };
112138
+ function sameWindowInstance(handledMs, resetsAtMs, window) {
112139
+ return handledMs !== void 0 && Math.abs(handledMs - resetsAtMs) < WINDOW_LENGTH_MS[window] / 2;
112140
+ }
112141
+ function pendingReset(snapshot, window, nowMs) {
112142
+ const recorded = snapshot?.providers[ANTHROPIC_PROVIDER]?.rateLimit?.unified?.[window];
112143
+ return recorded === void 0 ? void 0 : effectiveWindow(recorded, nowMs).resetsAtMs;
112144
+ }
112145
+ function runJobs(ports) {
112146
+ const nowMs = ports.nowMs();
112147
+ const jobs = ports.jobs();
112148
+ const previous = readHandled(ports.fs, ports.stampsFile);
112149
+ const handled = Object.fromEntries(jobs.flatMap(({ name }) => previous[name] === void 0 ? [] : [[name, previous[name]]]));
112150
+ const outcomes = [];
112151
+ const runs = [];
112152
+ const start = (name, identity, job, stamp, detail) => {
112153
+ handled[name] = stamp;
112154
+ ports.running.add(name);
112155
+ outcomes.push({ name, status: "started", detail });
112156
+ runs.push(
112157
+ ports.run(name, identity, job).catch((error63) => {
112158
+ ports.log(`job ${name}: failed as ${identity}: ${error63 instanceof Error ? error63.message : String(error63)}`);
112159
+ }).finally(() => {
112160
+ ports.running.delete(name);
112161
+ })
112162
+ );
112163
+ };
112164
+ const resolve2 = (target) => {
112165
+ try {
112166
+ const identity = ports.resolveIdentity(target);
112167
+ return identity === void 0 ? { problem: "no member of its pool can be picked" } : { identity };
112168
+ } catch (error63) {
112169
+ return { problem: error63 instanceof Error ? error63.message : String(error63) };
112170
+ }
112171
+ };
112172
+ const startIfServable = (name, identity, job, stamp, firedFor) => {
112173
+ const refusal2 = refusalReason(identity, ports.snapshot(identity), nowMs);
112174
+ if (refusal2 === void 0) {
112175
+ start(name, identity, job, stamp, `${firedFor}: running as ${identity}`);
112176
+ return;
112177
+ }
112178
+ handled[name] = stamp;
112179
+ outcomes.push({ name, status: "skipped", detail: `${firedFor}: ${identity}: ${refusal2}` });
112180
+ };
112181
+ for (const { name, job } of jobs) {
112182
+ if (ports.running.has(name)) {
112183
+ outcomes.push({ name, status: "running", detail: "a previous run is still going" });
112184
+ continue;
112185
+ }
112186
+ const { trigger } = job;
112187
+ if ("at" in trigger) {
112188
+ const last = handled[name];
112189
+ if (last === void 0) {
112190
+ handled[name] = nowMs;
112191
+ outcomes.push({ name, status: "armed", detail: "schedule noted; the next anchor to fall is the first acted on" });
112192
+ continue;
112193
+ }
112194
+ const due2 = dueAnchor(trigger.at, nowMs, last, ports.timeZone);
112195
+ if (due2 === void 0) {
112196
+ outcomes.push({ name, status: "waiting", detail: "no anchor has fallen since the last handled" });
112197
+ continue;
112198
+ }
112199
+ const firedFor = `anchor ${new Date(due2).toISOString()}`;
112200
+ const { identity: identity2, problem: problem2 } = resolve2(job.target);
112201
+ if (identity2 === void 0) {
112202
+ handled[name] = nowMs;
112203
+ outcomes.push({ name, status: "skipped", detail: `${firedFor}: ${problem2 ?? "no identity"}` });
112204
+ continue;
112205
+ }
112206
+ startIfServable(name, identity2, job, nowMs, firedFor);
112207
+ continue;
112208
+ }
112209
+ const { identity, problem } = resolve2(job.target);
112210
+ if (identity === void 0) {
112211
+ outcomes.push({ name, status: "skipped", detail: problem ?? "no identity" });
112212
+ continue;
112213
+ }
112214
+ const resetsAtMs = pendingReset(ports.snapshot(identity), trigger.beforeReset, nowMs);
112215
+ if (resetsAtMs === void 0) {
112216
+ outcomes.push({ name, status: "skipped", detail: `${identity} has no ${trigger.beforeReset} window to run before` });
112217
+ continue;
112218
+ }
112219
+ if (resetsAtMs - parseDuration(trigger.lead) > nowMs || sameWindowInstance(handled[name], resetsAtMs, trigger.beforeReset)) {
112220
+ outcomes.push({ name, status: "waiting", detail: `${trigger.beforeReset} window resets in ${formatAge(resetsAtMs - nowMs)}` });
112221
+ continue;
112222
+ }
112223
+ startIfServable(name, identity, job, resetsAtMs, `${trigger.beforeReset} window resetting in ${formatAge(resetsAtMs - nowMs)}`);
112224
+ }
112225
+ writeHandled(ports.fs, ports.stampsFile, handled);
112226
+ for (const outcome of outcomes) {
112227
+ if ((outcome.status === "started" || outcome.status === "skipped") && handled[outcome.name] !== previous[outcome.name]) {
112228
+ ports.log(`job ${outcome.name}: ${outcome.detail}`);
112229
+ }
112230
+ }
112231
+ return { outcomes, settled: Promise.all(runs).then(() => void 0) };
112232
+ }
112233
+
112234
+ // src/usage/jobTarget.ts
112235
+ init_poolPick();
112236
+ function resolveJobIdentity(deps, target) {
112237
+ if ("identity" in target) {
112238
+ return target.identity;
112239
+ }
112240
+ return rankPoolGraph({ fs: deps.fs, paths: deps.paths, pools: deps.pools, poolName: target.pool, nowMs: deps.nowMs, resuming: false, identityExists: deps.identityExists }).ranking.pick?.identity;
112241
+ }
112242
+
111974
112243
  // src/frontdoor/commands.ts
111975
112244
  init_realCredentialCache();
111976
112245
 
@@ -112080,7 +112349,7 @@ init_capability();
112080
112349
 
112081
112350
  // src/frontdoor/capture.ts
112082
112351
  var fs15 = __toESM(require("node:fs"), 1);
112083
- var path38 = __toESM(require("node:path"), 1);
112352
+ var path39 = __toESM(require("node:path"), 1);
112084
112353
  var SECRET_HEADER_NAME = /authorization|cookie|token|secret|credential|api[-_]key/i;
112085
112354
  var SECRET_JSON_KEY = /token|secret|password|credential|authorization|api[-_]key/i;
112086
112355
  var SECRET_BODY_PATTERNS = [
@@ -112124,10 +112393,10 @@ function redactBody(chunk) {
112124
112393
  }
112125
112394
  var CAPTURE_ENV = "AGENT_SHIM_FRONTDOOR_CAPTURE";
112126
112395
  function captureFromEnv(env, logsDir) {
112127
- return env[CAPTURE_ENV] === "1" ? createFileCapture(path38.join(logsDir, "frontdoor-capture.jsonl")) : void 0;
112396
+ return env[CAPTURE_ENV] === "1" ? createFileCapture(path39.join(logsDir, "frontdoor-capture.jsonl")) : void 0;
112128
112397
  }
112129
112398
  function createFileCapture(file2, now = () => /* @__PURE__ */ new Date()) {
112130
- fs15.mkdirSync(path38.dirname(file2), { recursive: true });
112399
+ fs15.mkdirSync(path39.dirname(file2), { recursive: true });
112131
112400
  let nextId = 0;
112132
112401
  const append = (record2) => {
112133
112402
  fs15.appendFileSync(file2, `${JSON.stringify({ ts: now().toISOString(), ...record2 })}
@@ -112546,14 +112815,14 @@ init_capability();
112546
112815
  init_route();
112547
112816
 
112548
112817
  // src/frontdoor/supervisor.ts
112549
- var import_node_path39 = __toESM(require("node:path"), 1);
112818
+ var import_node_path40 = __toESM(require("node:path"), 1);
112550
112819
  init_state2();
112551
112820
  function watchedInstallEntry(resolvedOwnExecutablePath, siblingExists) {
112552
- const parsed = import_node_path39.default.parse(resolvedOwnExecutablePath);
112821
+ const parsed = import_node_path40.default.parse(resolvedOwnExecutablePath);
112553
112822
  if (parsed.name === "agent-shim") {
112554
112823
  return resolvedOwnExecutablePath;
112555
112824
  }
112556
- const sibling = import_node_path39.default.join(parsed.dir, `agent-shim${parsed.ext}`);
112825
+ const sibling = import_node_path40.default.join(parsed.dir, `agent-shim${parsed.ext}`);
112557
112826
  return siblingExists(sibling) ? sibling : resolvedOwnExecutablePath;
112558
112827
  }
112559
112828
  var FRONTDOOR_SUPERVISOR_STILL_RUNNING = -1;
@@ -112740,8 +113009,8 @@ function parseConnectTarget(authority) {
112740
113009
  }
112741
113010
  return { host, port };
112742
113011
  }
112743
- function servedByPipeline(path52) {
112744
- return path52?.startsWith(ROUTED_PATH_PREFIX) === true;
113012
+ function servedByPipeline(path54) {
113013
+ return path54?.startsWith(ROUTED_PATH_PREFIX) === true;
112745
113014
  }
112746
113015
  var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
112747
113016
  "connection",
@@ -113260,11 +113529,11 @@ function createRcSessionTracker(deps) {
113260
113529
  };
113261
113530
  const observeExchange = (request7) => {
113262
113531
  const method = (request7.method ?? "").toUpperCase();
113263
- const path52 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
113264
- if (!path52.startsWith(RC_SESSIONS_PATH_PREFIX)) {
113532
+ const path54 = new URL(request7.url ?? "/", "http://127.0.0.1").pathname;
113533
+ if (!path54.startsWith(RC_SESSIONS_PATH_PREFIX)) {
113265
113534
  return void 0;
113266
113535
  }
113267
- const tail = path52.slice(RC_SESSIONS_PATH_PREFIX.length);
113536
+ const tail = path54.slice(RC_SESSIONS_PATH_PREFIX.length);
113268
113537
  const facts = {
113269
113538
  oauthAuthorization: oauthAuthorizationOf(request7.headers),
113270
113539
  anthropicVersion: singleHeader(request7.headers, "anthropic-version"),
@@ -113625,8 +113894,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
113625
113894
  function isRcReadFileEncoding(value2) {
113626
113895
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value2);
113627
113896
  }
113628
- function buildRcReadFilePayload(requestId, path52, options) {
113629
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path52, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
113897
+ function buildRcReadFilePayload(requestId, path54, options) {
113898
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path54, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
113630
113899
  }
113631
113900
  function buildRcFileSuggestionsPayload(requestId, query) {
113632
113901
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -113728,15 +113997,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
113728
113997
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
113729
113998
  return result.ok ? { ...result, requestId } : result;
113730
113999
  }
113731
- async function readRcSessionFile(deps, sessionId, path52, options) {
113732
- if (path52 === "") {
114000
+ async function readRcSessionFile(deps, sessionId, path54, options) {
114001
+ if (path54 === "") {
113733
114002
  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" };
113734
114003
  }
113735
114004
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
113736
114005
  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" };
113737
114006
  }
113738
114007
  const requestId = deps.newUuid();
113739
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path52, options), `read ${path52} from session ${sessionId}`);
114008
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path54, options), `read ${path54} from session ${sessionId}`);
113740
114009
  return result.ok ? { ...result, requestId } : result;
113741
114010
  }
113742
114011
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -113907,11 +114176,11 @@ function createRcControlHandler(deps) {
113907
114176
  path: "read-file",
113908
114177
  read: (body) => {
113909
114178
  const session = bodyString(body, "session");
113910
- const path52 = bodyString(body, "path");
114179
+ const path54 = bodyString(body, "path");
113911
114180
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
113912
114181
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
113913
- const refused2 = session === void 0 || path52 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
113914
- 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, path52, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
114182
+ const refused2 = session === void 0 || path54 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
114183
+ 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, path54, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
113915
114184
  }
113916
114185
  },
113917
114186
  {
@@ -114221,9 +114490,9 @@ function requestIdOfBody(body) {
114221
114490
  }
114222
114491
  function frontDoorRcControl(transport, token) {
114223
114492
  const headers = { authorization: `Bearer ${token}` };
114224
- const listAnswerOf = async (path52, what) => {
114493
+ const listAnswerOf = async (path54, what) => {
114225
114494
  try {
114226
- return await transport.request({ method: "GET", path: path52, headers });
114495
+ return await transport.request({ method: "GET", path: path54, headers });
114227
114496
  } catch (error63) {
114228
114497
  throw new Error(`${what}: could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}`, { cause: error63 });
114229
114498
  }
@@ -114295,10 +114564,10 @@ function frontDoorRcControl(transport, token) {
114295
114564
  }
114296
114565
  return pending;
114297
114566
  };
114298
- const writeOf = async (path52, body, describeFailure) => {
114567
+ const writeOf = async (path54, body, describeFailure) => {
114299
114568
  let answer;
114300
114569
  try {
114301
- answer = await transport.request({ method: "POST", path: path52, headers: { ...headers, "content-type": "application/json" }, body });
114570
+ answer = await transport.request({ method: "POST", path: path54, headers: { ...headers, "content-type": "application/json" }, body });
114302
114571
  } catch (error63) {
114303
114572
  return { ok: false, message: `could not reach the front door's control listener: ${error63 instanceof Error ? error63.message : String(error63)}` };
114304
114573
  }
@@ -114329,10 +114598,10 @@ function frontDoorRcControl(transport, token) {
114329
114598
  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}`),
114330
114599
  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}`),
114331
114600
  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}`),
114332
- readFile: async (sessionId, path52, options) => await writeOf(
114601
+ readFile: async (sessionId, path54, options) => await writeOf(
114333
114602
  `${CONTROL_PATH_PREFIX}/read-file`,
114334
- JSON.stringify({ session: sessionId, path: path52, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
114335
- (status, message) => `reading ${path52} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
114603
+ JSON.stringify({ session: sessionId, path: path54, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
114604
+ (status, message) => `reading ${path54} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
114336
114605
  ),
114337
114606
  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}`),
114338
114607
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -114626,12 +114895,12 @@ function tlsFacts(options) {
114626
114895
  }
114627
114896
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
114628
114897
  const agent = new ExemptTlsAgent();
114629
- const post = async (path52, headers, body) => await new Promise((resolve2, reject) => {
114898
+ const post = async (path54, headers, body) => await new Promise((resolve2, reject) => {
114630
114899
  const options = {
114631
114900
  host: target.host,
114632
114901
  port: target.port,
114633
114902
  method: "POST",
114634
- path: path52,
114903
+ path: path54,
114635
114904
  // 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.
114636
114905
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
114637
114906
  agent
@@ -114696,12 +114965,12 @@ function lateRcStreamDial(resolve2) {
114696
114965
  }
114697
114966
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
114698
114967
  const agent = new ExemptTlsAgent();
114699
- const request7 = async (method, path52, headers, body, signal) => await new Promise((resolve2, reject) => {
114968
+ const request7 = async (method, path54, headers, body, signal) => await new Promise((resolve2, reject) => {
114700
114969
  const options = {
114701
114970
  host: target.host,
114702
114971
  port: target.port,
114703
114972
  method,
114704
- path: path52,
114973
+ path: path54,
114705
114974
  // 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.
114706
114975
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
114707
114976
  agent,
@@ -114743,9 +115012,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
114743
115012
  return { status, body: await readAll(response) };
114744
115013
  },
114745
115014
  openStream: async (sessionId, headers, resume, signal) => {
114746
- const path52 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
115015
+ const path54 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
114747
115016
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
114748
- const { status, response } = await request7("GET", path52, streamHeaders, void 0, signal);
115017
+ const { status, response } = await request7("GET", path54, streamHeaders, void 0, signal);
114749
115018
  if (!isSuccessful2(status)) {
114750
115019
  await readAll(response);
114751
115020
  return { status, chunks: NO_CHUNKS };
@@ -114961,10 +115230,10 @@ init_claudeShim();
114961
115230
  init_store();
114962
115231
  init_realPorts();
114963
115232
  var import_node_fs15 = __toESM(require("node:fs"), 1);
114964
- var import_node_path41 = __toESM(require("node:path"), 1);
115233
+ var import_node_path42 = __toESM(require("node:path"), 1);
114965
115234
 
114966
115235
  // src/usage/signIn.ts
114967
- var import_node_path40 = __toESM(require("node:path"), 1);
115236
+ var import_node_path41 = __toESM(require("node:path"), 1);
114968
115237
  var CREDENTIALS_FILE = ".credentials.json";
114969
115238
  function keychainHasItem(run, account) {
114970
115239
  return run.run("security", ["find-generic-password", "-a", account]).status === 0;
@@ -114982,7 +115251,7 @@ function decideSignIn(facts) {
114982
115251
  return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
114983
115252
  }
114984
115253
  function credentialsFilePath(farmRoot) {
114985
- return import_node_path40.default.join(farmRoot, CREDENTIALS_FILE);
115254
+ return import_node_path41.default.join(farmRoot, CREDENTIALS_FILE);
114986
115255
  }
114987
115256
  function identitySignIn(fs22, probe, identity) {
114988
115257
  const probing = !identity.hasCredentialBlock;
@@ -115108,7 +115377,7 @@ function tcpPortEraRecord(raw) {
115108
115377
  return (has("port") || has("lastPort")) && !has("socketPath");
115109
115378
  }
115110
115379
  function pushPathResolution(push, resolution) {
115111
- const ownDir = import_node_path41.default.dirname(resolution.ownExecutablePath);
115380
+ const ownDir = import_node_path42.default.dirname(resolution.ownExecutablePath);
115112
115381
  switch (resolution.agentShim.status) {
115113
115382
  case "ok":
115114
115383
  push("path-resolution", "pass", `\`agent-shim\` on PATH resolves to this running executable, ${resolution.ownExecutablePath}.`, "agent-shim");
@@ -115207,14 +115476,14 @@ function pushProvider(push, entry, cacheEnv, signIn) {
115207
115476
  }
115208
115477
  function pushLegacyName(push, params) {
115209
115478
  const legacyVariables = Object.keys(params.env).filter((name) => name.startsWith(LEGACY_ENV_PREFIX) && params.env[name] !== void 0).sort();
115210
- if (legacyVariables.length === 0 && import_node_path41.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
115479
+ if (legacyVariables.length === 0 && import_node_path42.default.basename(params.rootPath) !== LEGACY_HOME_DIRNAME) {
115211
115480
  push("legacy-name", "pass", "Nothing here still uses the former `claude-use` name.");
115212
115481
  return;
115213
115482
  }
115214
115483
  for (const name of legacyVariables) {
115215
115484
  push("legacy-name", "warn", `${name} is the former name of ${name.replace(LEGACY_ENV_PREFIX, ENV_PREFIX)}. Rename it; the old name still works but is only a fallback.`, name);
115216
115485
  }
115217
- if (import_node_path41.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
115486
+ if (import_node_path42.default.basename(params.rootPath) === LEGACY_HOME_DIRNAME) {
115218
115487
  push(
115219
115488
  "legacy-name",
115220
115489
  "warn",
@@ -115587,18 +115856,18 @@ function collectDoctorReport(params) {
115587
115856
  const { paths } = params;
115588
115857
  const identityNames = import_node_fs15.default.existsSync(paths.identitiesDir) ? import_node_fs15.default.readdirSync(paths.identitiesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory() && isIdentityDirectoryName(entry.name)).map((entry) => entry.name).sort() : [];
115589
115858
  const identities = identityNames.map((name) => {
115590
- const farmRoot = import_node_path41.default.join(paths.identitiesDir, name);
115591
- const identityPath = import_node_path41.default.join(farmRoot, "identity.json");
115859
+ const farmRoot = import_node_path42.default.join(paths.identitiesDir, name);
115860
+ const identityPath = import_node_path42.default.join(farmRoot, "identity.json");
115592
115861
  return { name, path: identityPath, raw: realFsPort.readFileUtf8(identityPath), farmRoot, credentialsFilePresent: import_node_fs15.default.existsSync(credentialsFilePath(farmRoot)) };
115593
115862
  });
115594
115863
  const profileNames = import_node_fs15.default.existsSync(paths.configProfilesDir) ? import_node_fs15.default.readdirSync(paths.configProfilesDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
115595
115864
  const configProfiles = profileNames.map((name) => {
115596
- const profilePath = import_node_path41.default.join(paths.configProfilesDir, `${name}.json`);
115865
+ const profilePath = import_node_path42.default.join(paths.configProfilesDir, `${name}.json`);
115597
115866
  return { name, path: profilePath, raw: realFsPort.readFileUtf8(profilePath) };
115598
115867
  });
115599
115868
  const providerNames = import_node_fs15.default.existsSync(paths.providersDir) ? import_node_fs15.default.readdirSync(paths.providersDir, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name.slice(0, -".json".length)).sort() : [];
115600
115869
  const providers = providerNames.map((name) => {
115601
- const providerPath = import_node_path41.default.join(paths.providersDir, `${name}.json`);
115870
+ const providerPath = import_node_path42.default.join(paths.providersDir, `${name}.json`);
115602
115871
  return { name, path: providerPath, raw: realFsPort.readFileUtf8(providerPath) };
115603
115872
  });
115604
115873
  const ownExecutablePath = realOwnExecutablePath();
@@ -115610,12 +115879,12 @@ function collectDoctorReport(params) {
115610
115879
  binaryDiscovery = { ok: false, message: error63 instanceof Error ? error63.message : String(error63) };
115611
115880
  }
115612
115881
  const shimState = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
115613
- const pathDirs = (params.env.PATH ?? "").split(import_node_path41.default.delimiter).filter((dir) => dir !== "");
115882
+ const pathDirs = (params.env.PATH ?? "").split(import_node_path42.default.delimiter).filter((dir) => dir !== "");
115614
115883
  const claudeShimShadow = shimState === void 0 ? void 0 : refinePathShadow(
115615
115884
  findPathShadow({
115616
115885
  pathDirs,
115617
- targetDir: import_node_path41.default.dirname(shimState.targetPath),
115618
- targetFilename: import_node_path41.default.basename(shimState.targetPath),
115886
+ targetDir: import_node_path42.default.dirname(shimState.targetPath),
115887
+ targetFilename: import_node_path42.default.basename(shimState.targetPath),
115619
115888
  findExecutableInDir
115620
115889
  }),
115621
115890
  shimState.targetPath,
@@ -115644,7 +115913,7 @@ function collectDoctorReport(params) {
115644
115913
  agentShim: refinePathShadow(
115645
115914
  findPathShadow({
115646
115915
  pathDirs,
115647
- targetDir: import_node_path41.default.dirname(ownExecutablePath),
115916
+ targetDir: import_node_path42.default.dirname(ownExecutablePath),
115648
115917
  targetFilename: commandFilename(ownExecutablePath, "agent-shim"),
115649
115918
  findExecutableInDir
115650
115919
  }),
@@ -115907,11 +116176,11 @@ function tryOrUndefined(fn2) {
115907
116176
  return void 0;
115908
116177
  }
115909
116178
  }
115910
- function pathToHttpPath(path52) {
115911
- return `/${path52.map(safeEncodeURIComponent).join("/")}`;
116179
+ function pathToHttpPath(path54) {
116180
+ return `/${path54.map(safeEncodeURIComponent).join("/")}`;
115912
116181
  }
115913
- function normalizeHttpPath(path52) {
115914
- const paths = path52.split("/");
116182
+ function normalizeHttpPath(path54) {
116183
+ const paths = path54.split("/");
115915
116184
  if (paths.at(0) === "") {
115916
116185
  paths.shift();
115917
116186
  }
@@ -116096,9 +116365,9 @@ function isPlainObject2(value2) {
116096
116365
  function getOwn(object3, key) {
116097
116366
  return Object.hasOwn(object3, key) ? object3[key] : void 0;
116098
116367
  }
116099
- function get(object3, path52) {
116368
+ function get(object3, path54) {
116100
116369
  let current = object3;
116101
- for (const key of path52) {
116370
+ for (const key of path54) {
116102
116371
  if (!isTypescriptObject(current)) {
116103
116372
  return void 0;
116104
116373
  }
@@ -117321,7 +117590,7 @@ function resolveClientRest(rest) {
117321
117590
  // rest[1] can be undefined if all fields of FriendlyClientOptions are optional
117322
117591
  ];
117323
117592
  }
117324
- function createORPCClient(link, { path: path52 = [], ...options } = {}) {
117593
+ function createORPCClient(link, { path: path54 = [], ...options } = {}) {
117325
117594
  const procedureClient = (...rest) => {
117326
117595
  const [input2, callOptions] = resolveClientRest(rest);
117327
117596
  const interceptors = [
@@ -117330,7 +117599,7 @@ function createORPCClient(link, { path: path52 = [], ...options } = {}) {
117330
117599
  ];
117331
117600
  return intercept(
117332
117601
  interceptors,
117333
- { ...callOptions, input: input2, path: path52 },
117602
+ { ...callOptions, input: input2, path: path54 },
117334
117603
  ({ path: path210, input: input22, ...callOptions2 }) => link.call(path210, input22, callOptions2)
117335
117604
  );
117336
117605
  };
@@ -117344,7 +117613,7 @@ function createORPCClient(link, { path: path52 = [], ...options } = {}) {
117344
117613
  if (client === void 0) {
117345
117614
  client = createORPCClient(link, {
117346
117615
  ...options,
117347
- path: [...path52, key],
117616
+ path: [...path54, key],
117348
117617
  scoped: options.scoped?.[key]
117349
117618
  });
117350
117619
  cache.set(key, client);
@@ -117366,24 +117635,24 @@ var BracketNotationSerializer = class {
117366
117635
  this.internalSerialize(data, "", true, result);
117367
117636
  return result;
117368
117637
  }
117369
- internalSerialize(data, path52, isRoot, result) {
117638
+ internalSerialize(data, path54, isRoot, result) {
117370
117639
  if (Array.isArray(data)) {
117371
117640
  data.forEach((item, i10) => {
117372
- this.internalSerialize(item, isRoot ? i10.toString() : `${path52}[${i10}]`, false, result);
117641
+ this.internalSerialize(item, isRoot ? i10.toString() : `${path54}[${i10}]`, false, result);
117373
117642
  });
117374
117643
  } else if (isPlainObject2(data)) {
117375
117644
  for (const key of Object.keys(data)) {
117376
- this.internalSerialize(data[key], isRoot ? key : `${path52}[${key}]`, false, result);
117645
+ this.internalSerialize(data[key], isRoot ? key : `${path54}[${key}]`, false, result);
117377
117646
  }
117378
117647
  } else {
117379
- result.push([path52, data]);
117648
+ result.push([path54, data]);
117380
117649
  }
117381
117650
  }
117382
117651
  deserialize(serialized) {
117383
117652
  const arrayPushStyles = /* @__PURE__ */ new WeakSet();
117384
117653
  const root = new NullProtoObj();
117385
- for (const [path52, value2] of serialized) {
117386
- const segments = this.parsePath(path52);
117654
+ for (const [path54, value2] of serialized) {
117655
+ const segments = this.parsePath(path54);
117387
117656
  let currentRef = root;
117388
117657
  let nextSegment = segments[0];
117389
117658
  for (let i10 = 1; i10 < segments.length; i10++) {
@@ -117434,13 +117703,13 @@ var BracketNotationSerializer = class {
117434
117703
  }
117435
117704
  return result;
117436
117705
  }
117437
- parsePath(path52) {
117706
+ parsePath(path54) {
117438
117707
  const segments = [];
117439
117708
  let inBrackets = false;
117440
117709
  let currentSegment = "";
117441
- for (let i10 = 0; i10 < path52.length; i10++) {
117442
- const char = path52[i10];
117443
- const nextChar = path52[i10 + 1];
117710
+ for (let i10 = 0; i10 < path54.length; i10++) {
117711
+ const char = path54[i10];
117712
+ const nextChar = path54[i10 + 1];
117444
117713
  if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
117445
117714
  if (nextChar === void 0) {
117446
117715
  inBrackets = false;
@@ -117456,7 +117725,7 @@ var BracketNotationSerializer = class {
117456
117725
  currentSegment += char;
117457
117726
  }
117458
117727
  }
117459
- return inBrackets || segments.length === 0 ? [path52] : segments;
117728
+ return inBrackets || segments.length === 0 ? [path54] : segments;
117460
117729
  }
117461
117730
  };
117462
117731
  var INTEGER_PATTERN = /^0$|^[1-9]\d*$/;
@@ -118029,11 +118298,11 @@ var OpenAPISerializer = class {
118029
118298
  return json2;
118030
118299
  }
118031
118300
  const form = new FormData();
118032
- for (const [path52, value22] of this.bracketNotation.serialize(json2)) {
118301
+ for (const [path54, value22] of this.bracketNotation.serialize(json2)) {
118033
118302
  if (value22 instanceof Blob) {
118034
- form.append(path52, value22);
118303
+ form.append(path54, value22);
118035
118304
  } else if (value22 !== void 0 && value22 !== null) {
118036
- form.append(path52, String(value22));
118305
+ form.append(path54, String(value22));
118037
118306
  }
118038
118307
  }
118039
118308
  return form;
@@ -118071,30 +118340,30 @@ function isBodylessMethod(method) {
118071
118340
  return method === "GET" || method === "HEAD";
118072
118341
  }
118073
118342
  var PARAMETER_NAME_REGEX = /^[\w-]+$/;
118074
- function getDynamicPathParams(path52) {
118075
- if (!path52.includes("{")) {
118343
+ function getDynamicPathParams(path54) {
118344
+ if (!path54.includes("{")) {
118076
118345
  return void 0;
118077
118346
  }
118078
- const len = path52.length;
118347
+ const len = path54.length;
118079
118348
  let params;
118080
118349
  let index = 1;
118081
118350
  while (index < len) {
118082
118351
  const segmentStart = index;
118083
- const slashPos = path52.indexOf("/", index);
118352
+ const slashPos = path54.indexOf("/", index);
118084
118353
  const segmentEnd = slashPos === -1 ? len : slashPos;
118085
- if (segmentEnd > segmentStart && path52.charCodeAt(segmentStart) === 123 && path52.charCodeAt(segmentEnd - 1) === 125) {
118354
+ if (segmentEnd > segmentStart && path54.charCodeAt(segmentStart) === 123 && path54.charCodeAt(segmentEnd - 1) === 125) {
118086
118355
  let parameterStart = segmentStart + 1;
118087
118356
  let allowsSlash = false;
118088
- const operator = path52.charCodeAt(parameterStart);
118357
+ const operator = path54.charCodeAt(parameterStart);
118089
118358
  if (operator === 43) {
118090
118359
  allowsSlash = true;
118091
118360
  parameterStart++;
118092
118361
  }
118093
- const parameterName = path52.slice(parameterStart, segmentEnd - 1);
118362
+ const parameterName = path54.slice(parameterStart, segmentEnd - 1);
118094
118363
  if (PARAMETER_NAME_REGEX.test(parameterName)) {
118095
118364
  params ??= [];
118096
118365
  params.push({
118097
- segment: path52.slice(segmentStart, segmentEnd),
118366
+ segment: path54.slice(segmentStart, segmentEnd),
118098
118367
  startIndex: segmentStart,
118099
118368
  parameterName,
118100
118369
  allowsSlash
@@ -118137,8 +118406,8 @@ openapi.method = (method) => ({
118137
118406
  ...openapi({ method }),
118138
118407
  name: "~openapi/method"
118139
118408
  });
118140
- openapi.path = (path52) => ({
118141
- ...openapi({ path: path52 }),
118409
+ openapi.path = (path54) => ({
118410
+ ...openapi({ path: path54 }),
118142
118411
  name: "~openapi/path"
118143
118412
  });
118144
118413
  openapi.spec = (spec) => ({
@@ -118999,22 +119268,22 @@ function visitJsonSchemaRefs(value2, visit2, schemaLevel = true, seen = /* @__PU
118999
119268
  }
119000
119269
  }
119001
119270
  }
119002
- function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path52 = []) {
119271
+ function mapJsonSchemaRefs(value2, map2, schemaLevel = true, path54 = []) {
119003
119272
  if (!value2 || typeof value2 !== "object") {
119004
119273
  return value2;
119005
119274
  }
119006
119275
  if (Array.isArray(value2)) {
119007
- return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path52, index]));
119276
+ return value2.map((item, index) => mapJsonSchemaRefs(item, map2, schemaLevel, [...path54, index]));
119008
119277
  }
119009
119278
  const result = {};
119010
119279
  for (const key of Object.keys(value2)) {
119011
119280
  const val = value2[key];
119012
119281
  if (key === "$ref" && typeof val === "string") {
119013
- setOwn(result, key, map2(val, [...path52, key]));
119282
+ setOwn(result, key, map2(val, [...path54, key]));
119014
119283
  } else if (!schemaLevel) {
119015
- setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path52, key]));
119284
+ setOwn(result, key, mapJsonSchemaRefs(val, map2, true, [...path54, key]));
119016
119285
  } else if (JSON_SCHEMA_LOGIC_KEYWORDS.has(key) || JSON_SCHEMA_RECORD_KEYWORDS.has(key)) {
119017
- setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path52, key]));
119286
+ setOwn(result, key, mapJsonSchemaRefs(val, map2, !JSON_SCHEMA_RECORD_KEYWORDS.has(key), [...path54, key]));
119018
119287
  } else {
119019
119288
  setOwn(result, key, val);
119020
119289
  }
@@ -119544,7 +119813,7 @@ function unlazy(maybeLazy) {
119544
119813
  function createProcedureClient(lazyableProcedure, ...rest) {
119545
119814
  const options = resolveMaybeOptionalOptions(rest);
119546
119815
  return async (...[input2, callerOptions]) => {
119547
- const path52 = toArray(options.path);
119816
+ const path54 = toArray(options.path);
119548
119817
  const { default: procedure } = await unlazy(lazyableProcedure);
119549
119818
  const clientContext = callerOptions?.context ?? {};
119550
119819
  const context = await value(options.context, clientContext) ?? {};
@@ -119557,7 +119826,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
119557
119826
  };
119558
119827
  try {
119559
119828
  const output2 = await runWithSpan("call_procedure", (span) => {
119560
- span?.setAttribute("procedure.path", path52);
119829
+ span?.setAttribute("procedure.path", path54);
119561
119830
  return intercept(
119562
119831
  options.interceptors,
119563
119832
  {
@@ -119565,7 +119834,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
119565
119834
  // input can be optional if it is undefinable
119566
119835
  input: input2,
119567
119836
  errors,
119568
- path: path52,
119837
+ path: path54,
119569
119838
  procedure,
119570
119839
  signal: callerOptions?.signal,
119571
119840
  lastEventId: callerOptions?.lastEventId
@@ -119816,10 +120085,10 @@ function augmentRouter(router, options) {
119816
120085
  }
119817
120086
  return enhanced;
119818
120087
  }
119819
- function getRouter(router, path52) {
120088
+ function getRouter(router, path54) {
119820
120089
  let current = router;
119821
- for (let i10 = 0; i10 < path52.length; i10++) {
119822
- const segment = path52[i10];
120090
+ for (let i10 = 0; i10 < path54.length; i10++) {
120091
+ const segment = path54[i10];
119823
120092
  if (!isTypescriptObject(current)) {
119824
120093
  return void 0;
119825
120094
  }
@@ -119831,7 +120100,7 @@ function getRouter(router, path52) {
119831
120100
  continue;
119832
120101
  }
119833
120102
  const lazied = current;
119834
- const rest = path52.slice(i10);
120103
+ const rest = path54.slice(i10);
119835
120104
  return new Lazy({
119836
120105
  ...lazied["~orpc"],
119837
120106
  async loader() {
@@ -119846,40 +120115,40 @@ function getRouter(router, path52) {
119846
120115
  }
119847
120116
  return current;
119848
120117
  }
119849
- function walkProcedureContractsSync(router, callback, path52 = []) {
120118
+ function walkProcedureContractsSync(router, callback, path54 = []) {
119850
120119
  const lazyResults = [];
119851
- walkProcedureContractsSyncInternal(router, callback, path52.slice(), lazyResults);
120120
+ walkProcedureContractsSyncInternal(router, callback, path54.slice(), lazyResults);
119852
120121
  return lazyResults;
119853
120122
  }
119854
- function walkProcedureContractsSyncInternal(router, callback, path52, lazyResults) {
120123
+ function walkProcedureContractsSyncInternal(router, callback, path54, lazyResults) {
119855
120124
  const hiddenContract = getHiddenRouterContract(router);
119856
120125
  if (hiddenContract !== void 0) {
119857
120126
  router = hiddenContract;
119858
120127
  }
119859
120128
  if (router instanceof ProcedureContract) {
119860
- callback(router, path52.slice());
120129
+ callback(router, path54.slice());
119861
120130
  return;
119862
120131
  }
119863
120132
  if (!isTypescriptObject(router)) {
119864
120133
  return;
119865
120134
  }
119866
120135
  for (const [key, value2] of Object.entries(router)) {
119867
- path52.push(key);
120136
+ path54.push(key);
119868
120137
  if (value2 instanceof Lazy) {
119869
- lazyResults.push({ router: value2, path: path52.slice() });
120138
+ lazyResults.push({ router: value2, path: path54.slice() });
119870
120139
  } else {
119871
- walkProcedureContractsSyncInternal(value2, callback, path52, lazyResults);
120140
+ walkProcedureContractsSyncInternal(value2, callback, path54, lazyResults);
119872
120141
  }
119873
- path52.pop();
120142
+ path54.pop();
119874
120143
  }
119875
120144
  }
119876
- async function walkProcedureContractsAsync(router, callback, path52 = []) {
120145
+ async function walkProcedureContractsAsync(router, callback, path54 = []) {
119877
120146
  const hiddenContract = getHiddenRouterContract(router);
119878
120147
  if (hiddenContract !== void 0) {
119879
120148
  router = hiddenContract;
119880
120149
  }
119881
120150
  if (router instanceof ProcedureContract) {
119882
- await callback(router, path52);
120151
+ await callback(router, path54);
119883
120152
  return;
119884
120153
  }
119885
120154
  if (!isTypescriptObject(router)) {
@@ -119888,9 +120157,9 @@ async function walkProcedureContractsAsync(router, callback, path52 = []) {
119888
120157
  for (const [key, value2] of Object.entries(router)) {
119889
120158
  if (value2 instanceof Lazy) {
119890
120159
  const { default: router2 } = await unlazy(value2);
119891
- await walkProcedureContractsAsync(router2, callback, [...path52, key]);
120160
+ await walkProcedureContractsAsync(router2, callback, [...path54, key]);
119892
120161
  } else {
119893
- await walkProcedureContractsAsync(value2, callback, [...path52, key]);
120162
+ await walkProcedureContractsAsync(value2, callback, [...path54, key]);
119894
120163
  }
119895
120164
  }
119896
120165
  }
@@ -120376,18 +120645,18 @@ function rewriteComponentSchemaRefs(schema, renameMap) {
120376
120645
  }
120377
120646
  var OpenAPIGeneratorError = class extends TypeError {
120378
120647
  };
120379
- function toOpenAPIPath(path52, dynamicPathParams) {
120648
+ function toOpenAPIPath(path54, dynamicPathParams) {
120380
120649
  if (!dynamicPathParams?.length) {
120381
- return path52;
120650
+ return path54;
120382
120651
  }
120383
120652
  let normalized = "";
120384
120653
  let currentIndex = 0;
120385
120654
  for (const param of dynamicPathParams) {
120386
- normalized += path52.slice(currentIndex, param.startIndex);
120655
+ normalized += path54.slice(currentIndex, param.startIndex);
120387
120656
  normalized += `{${param.parameterName}}`;
120388
120657
  currentIndex = param.startIndex + param.segment.length;
120389
120658
  }
120390
- normalized += path52.slice(currentIndex);
120659
+ normalized += path54.slice(currentIndex);
120391
120660
  return normalized;
120392
120661
  }
120393
120662
  function buildRequest(ctx, operation, def, meta3, dynamicPathParams) {
@@ -120821,8 +121090,8 @@ var OpenAPIGenerator = class {
120821
121090
  customErrorResponseBodySchema: options.customErrorResponseBodySchema
120822
121091
  };
120823
121092
  const errors = [];
120824
- await walkProcedureContractsAsync(router, (contract, path52) => {
120825
- if (value(options.filter, contract, path52) === false) {
121093
+ await walkProcedureContractsAsync(router, (contract, path54) => {
121094
+ if (value(options.filter, contract, path54) === false) {
120826
121095
  return;
120827
121096
  }
120828
121097
  try {
@@ -120834,7 +121103,7 @@ var OpenAPIGenerator = class {
120834
121103
  `QUERY operations require OpenAPI 3.2, but version "${version2}" was requested.`
120835
121104
  );
120836
121105
  }
120837
- const postPath = meta3?.path ?? pathToHttpPath(path52);
121106
+ const postPath = meta3?.path ?? pathToHttpPath(path54);
120838
121107
  const httpPath = meta3?.prefix ? mergeHttpPath(meta3.prefix, postPath) : postPath;
120839
121108
  const dynamicPathParams = getDynamicPathParams(httpPath);
120840
121109
  const openApiPath = toOpenAPIPath(httpPath, dynamicPathParams);
@@ -120843,7 +121112,7 @@ var OpenAPIGenerator = class {
120843
121112
  operation = meta3.spec;
120844
121113
  } else {
120845
121114
  operation = {
120846
- operationId: meta3?.operationId ?? path52.join("."),
121115
+ operationId: meta3?.operationId ?? path54.join("."),
120847
121116
  summary: meta3?.summary,
120848
121117
  description: meta3?.description,
120849
121118
  deprecated: meta3?.deprecated,
@@ -120863,7 +121132,7 @@ var OpenAPIGenerator = class {
120863
121132
  if (!(e14 instanceof OpenAPIGeneratorError)) {
120864
121133
  throw e14;
120865
121134
  }
120866
- errors.push(`Procedure at ${path52.join(".") || "(root)"}: ${e14.message}`);
121135
+ errors.push(`Procedure at ${path54.join(".") || "(root)"}: ${e14.message}`);
120867
121136
  }
120868
121137
  });
120869
121138
  if (errors.length) {
@@ -121171,7 +121440,7 @@ var ResetRowSchema = external_exports.strictObject({
121171
121440
  var ResetScheduleSchema = external_exports.strictObject({ resets: external_exports.readonly(external_exports.array(ResetRowSchema)) });
121172
121441
 
121173
121442
  // src/frontdoor/controlSchemas.ts
121174
- var import_node_path42 = __toESM(require("node:path"), 1);
121443
+ var import_node_path43 = __toESM(require("node:path"), 1);
121175
121444
  init_zod();
121176
121445
  init_schema2();
121177
121446
 
@@ -121383,11 +121652,11 @@ var FrontDoorSessionsOutputSchema = external_exports.strictObject({ sessions: ex
121383
121652
  var CheckRunInputSchema = external_exports.strictObject({
121384
121653
  path: external_exports.string().min(1),
121385
121654
  identity: external_exports.string().min(1).optional()
121386
- }).refine((input2) => import_node_path42.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
121655
+ }).refine((input2) => import_node_path43.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
121387
121656
  var PoolPickInputSchema = external_exports.strictObject({
121388
121657
  pool: external_exports.string().min(1),
121389
121658
  path: external_exports.string().min(1)
121390
- }).refine((input2) => import_node_path42.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
121659
+ }).refine((input2) => import_node_path43.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
121391
121660
  var DoctorFindingSchema = external_exports.strictObject({
121392
121661
  section: external_exports.enum(DOCTOR_SECTIONS),
121393
121662
  subject: external_exports.string().optional(),
@@ -121708,16 +121977,16 @@ var StandardLink = class {
121708
121977
  /**
121709
121978
  * @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
121710
121979
  */
121711
- call(path52, input2, options) {
121712
- return runWithSpan(`${ORPC_NAME}.${path52.join("/")}`, (span) => {
121980
+ call(path54, input2, options) {
121981
+ return runWithSpan(`${ORPC_NAME}.${path54.join("/")}`, (span) => {
121713
121982
  span?.setAttribute("rpc.system", ORPC_NAME);
121714
- span?.setAttribute("rpc.method", path52.join("."));
121983
+ span?.setAttribute("rpc.method", path54.join("."));
121715
121984
  if (getTracer() && isAsyncIteratorObject(input2)) {
121716
121985
  input2 = override(input2, traceAsyncIterator("consume_async_iterator_object_input", input2));
121717
121986
  } else if (getTracer() && input2 instanceof ReadableStream) {
121718
121987
  input2 = override(input2, traceReadableStream("consume_octet_stream_input", input2));
121719
121988
  }
121720
- return intercept(this.interceptors, { ...options, path: path52, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
121989
+ return intercept(this.interceptors, { ...options, path: path54, input: input2 }, async ({ path: path210, input: input22, ...options2 }) => {
121721
121990
  const tracer = getTracer();
121722
121991
  const activeSpan = tracer?.getActiveSpan() ?? span;
121723
121992
  let request7 = await runWithSpan(
@@ -121774,18 +122043,18 @@ var RPCLinkCodec = class {
121774
122043
  this.headers = options.headers ?? {};
121775
122044
  this.serializer = options.serializer ?? new RPCSerializer();
121776
122045
  }
121777
- async encodeInput(input2, path52, options) {
121778
- let headers = toResolvedStandardHeaders(await value(this.headers, options, path52, input2));
122046
+ async encodeInput(input2, path54, options) {
122047
+ let headers = toResolvedStandardHeaders(await value(this.headers, options, path54, input2));
121779
122048
  if (options.lastEventId !== void 0) {
121780
122049
  headers = mergeStandardHeaders(headers, { "last-event-id": options.lastEventId });
121781
122050
  }
121782
- const expectedMethod = await value(this.expectedMethod, options, path52, input2);
121783
- const baseUrl = await value(this.baseUrl, options, path52, input2);
122051
+ const expectedMethod = await value(this.expectedMethod, options, path54, input2);
122052
+ const baseUrl = await value(this.baseUrl, options, path54, input2);
121784
122053
  const [pathname, search, hash2] = parseStandardUrl(baseUrl);
121785
- const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path52)}`;
122054
+ const newPathname = `${pathname.replace(END_SLASH_REGEX, "")}${pathToHttpPath(path54)}`;
121786
122055
  const serialized = this.serializer.serialize(input2);
121787
122056
  if (expectedMethod === "GET" && !(serialized instanceof Blob) && !(serialized instanceof ReadableStream) && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) {
121788
- const maxUrlLength = await value(this.maxUrlLength, options, path52, input2);
122057
+ const maxUrlLength = await value(this.maxUrlLength, options, path54, input2);
121789
122058
  const mergedSearch = new URLSearchParams(search);
121790
122059
  mergedSearch.append("data", stringifyJSON(serialized) ?? "");
121791
122060
  const url22 = `${newPathname}?${mergedSearch}${hash2 ?? ""}`;
@@ -121870,8 +122139,8 @@ var FetchLinkTransport = class {
121870
122139
  this.fetch = options.fetch ?? ((url2, init) => globalThis.fetch(url2, init));
121871
122140
  this.toFetchRequestOptions = options.toFetchRequest;
121872
122141
  }
121873
- async send(standardRequest, path52, options) {
121874
- let origin = await value(this.origin, options, path52);
122142
+ async send(standardRequest, path54, options) {
122143
+ let origin = await value(this.origin, options, path54);
121875
122144
  if (origin?.endsWith("/")) {
121876
122145
  origin = origin.slice(0, -1);
121877
122146
  }
@@ -121891,7 +122160,7 @@ var FetchLinkTransport = class {
121891
122160
  }
121892
122161
  }
121893
122162
  const fetch3 = this.fetch;
121894
- const response = await fetch3(url2, init, options, path52);
122163
+ const response = await fetch3(url2, init, options, path54);
121895
122164
  const standardResponse = toStandardLazyResponse(response);
121896
122165
  return standardResponse;
121897
122166
  }
@@ -122282,14 +122551,14 @@ var StandardHandler = class {
122282
122551
  span?.setAttribute("url.path", request22.url);
122283
122552
  return { matched: false };
122284
122553
  }
122285
- const { path: path52, procedure, decodeInput } = matchedOrNot;
122286
- span?.updateName(`${ORPC_NAME}.${path52.join("/")}`);
122554
+ const { path: path54, procedure, decodeInput } = matchedOrNot;
122555
+ span?.updateName(`${ORPC_NAME}.${path54.join("/")}`);
122287
122556
  span?.setAttribute("rpc.system", ORPC_NAME);
122288
- span?.setAttribute("rpc.method", path52.join("."));
122557
+ span?.setAttribute("rpc.method", path54.join("."));
122289
122558
  try {
122290
122559
  const response = await intercept(
122291
122560
  this.interceptors,
122292
- { context: context2, prefix: prefix2, request: request22, path: path52, procedure, decodeInput },
122561
+ { context: context2, prefix: prefix2, request: request22, path: path54, procedure, decodeInput },
122293
122562
  async ({ context: context3, prefix: prefix3, request: request32, path: path210, procedure: procedure2, decodeInput: decodeInput2 }) => {
122294
122563
  step2 = "decode_input";
122295
122564
  let input2 = await runWithSpan("decode_input", decodeInput2);
@@ -122323,7 +122592,7 @@ var StandardHandler = class {
122323
122592
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
122324
122593
  cause: e14
122325
122594
  }) : toORPCError(e14);
122326
- const response = await this.codec.encodeError(error63, procedure, path52, { context: context2, prefix: prefix2 });
122595
+ const response = await this.codec.encodeError(error63, procedure, path54, { context: context2, prefix: prefix2 });
122327
122596
  return { matched: true, response };
122328
122597
  }
122329
122598
  }
@@ -122429,7 +122698,7 @@ var RPCMatcher = class {
122429
122698
  this.rootRouter = router;
122430
122699
  this.index(router);
122431
122700
  }
122432
- index(router, path52 = []) {
122701
+ index(router, path54 = []) {
122433
122702
  const lazyResults = walkProcedureContractsSync(router, (procedure, procedurePath) => {
122434
122703
  if (!value(this.filter, procedure, procedurePath)) {
122435
122704
  return;
@@ -122440,7 +122709,7 @@ var RPCMatcher = class {
122440
122709
  // contract-first entries have no implementation yet, resolveProcedure fills it in on demand
122441
122710
  procedure: procedure instanceof Procedure ? procedure : void 0
122442
122711
  });
122443
- }, path52);
122712
+ }, path54);
122444
122713
  for (const result of lazyResults) {
122445
122714
  this.pendingLazyRouters.set(pathToHttpPath(result.path), result);
122446
122715
  }
@@ -122572,10 +122841,10 @@ var RPCHandlerCodec = class {
122572
122841
  }
122573
122842
  };
122574
122843
  }
122575
- encodeOutput(output2, procedure, path52, options) {
122844
+ encodeOutput(output2, procedure, path54, options) {
122576
122845
  return {
122577
122846
  headers: {},
122578
- status: value(this.outputStatus, output2, procedure, path52, options) ?? DEFAULT_SUCCESS_STATUS,
122847
+ status: value(this.outputStatus, output2, procedure, path54, options) ?? DEFAULT_SUCCESS_STATUS,
122579
122848
  body: this.serializer.serialize(output2)
122580
122849
  };
122581
122850
  }
@@ -122629,39 +122898,39 @@ function createRouter() {
122629
122898
  static: new NullProtoObj2()
122630
122899
  };
122631
122900
  }
122632
- function scanFirstGroup(path52) {
122901
+ function scanFirstGroup(path54) {
122633
122902
  let i10 = 0;
122634
122903
  let depth = 0;
122635
- for (; i10 < path52.length; i10++) {
122636
- const c10 = path52.charCodeAt(i10);
122904
+ for (; i10 < path54.length; i10++) {
122905
+ const c10 = path54.charCodeAt(i10);
122637
122906
  if (c10 === 92) i10++;
122638
122907
  else if (c10 === 40) depth++;
122639
122908
  else if (c10 === 41 && depth > 0) depth--;
122640
122909
  else if (c10 === 123 && depth === 0) break;
122641
122910
  }
122642
- if (i10 >= path52.length) return;
122911
+ if (i10 >= path54.length) return;
122643
122912
  let j10 = i10 + 1;
122644
122913
  depth = 0;
122645
- for (; j10 < path52.length; j10++) {
122646
- const c10 = path52.charCodeAt(j10);
122914
+ for (; j10 < path54.length; j10++) {
122915
+ const c10 = path54.charCodeAt(j10);
122647
122916
  if (c10 === 92) j10++;
122648
122917
  else if (c10 === 40) depth++;
122649
122918
  else if (c10 === 41 && depth > 0) depth--;
122650
122919
  else if (c10 === 125 && depth === 0) break;
122651
122920
  }
122652
- if (j10 >= path52.length) return;
122653
- const mod = path52[j10 + 1];
122921
+ if (j10 >= path54.length) return;
122922
+ const mod = path54[j10 + 1];
122654
122923
  const hasMod = mod === "?" || mod === "+" || mod === "*";
122655
122924
  return [
122656
- path52.slice(0, i10),
122657
- path52.slice(i10 + 1, j10),
122658
- path52.slice(j10 + (hasMod ? 2 : 1)),
122925
+ path54.slice(0, i10),
122926
+ path54.slice(i10 + 1, j10),
122927
+ path54.slice(j10 + (hasMod ? 2 : 1)),
122659
122928
  hasMod ? mod : void 0
122660
122929
  ];
122661
122930
  }
122662
- function expandGroupDelimiters(path52) {
122663
- if (!path52.includes("{")) return;
122664
- const group = scanFirstGroup(path52);
122931
+ function expandGroupDelimiters(path54) {
122932
+ if (!path54.includes("{")) return;
122933
+ const group = scanFirstGroup(path54);
122665
122934
  if (!group) return;
122666
122935
  const [pre2, body, suf, mod] = group;
122667
122936
  if (!mod) return [pre2 + body + suf];
@@ -122731,9 +123000,9 @@ function replaceSegmentWildcards(segment, unnamedStart, toGroupKey = toUnnamedGr
122731
123000
  }
122732
123001
  return [replaced, nextIndex];
122733
123002
  }
122734
- function encodeEscapes(path52) {
122735
- if (!path52.includes("\\")) return path52;
122736
- return path52.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
123003
+ function encodeEscapes(path54) {
123004
+ if (!path54.includes("\\")) return path54;
123005
+ return path54.replace(/\\([:(){}])/g, (_, c10) => "\uFFFD" + "ABCDE"[":(){}".indexOf(c10)]);
122737
123006
  }
122738
123007
  function segmentKey(segment) {
122739
123008
  if (segment.startsWith("**")) return 2;
@@ -122762,22 +123031,22 @@ function expandModifiers(segments) {
122762
123031
  return m10[2] === "+" ? [wc2] : [wc2, without];
122763
123032
  }
122764
123033
  }
122765
- function normalizePath(path52) {
122766
- if (!path52.includes("/.")) return path52;
123034
+ function normalizePath(path54) {
123035
+ if (!path54.includes("/.")) return path54;
122767
123036
  const r10 = [];
122768
- for (const s of path52.split("/")) if (s === ".") continue;
123037
+ for (const s of path54.split("/")) if (s === ".") continue;
122769
123038
  else if (s === ".." && r10.length > 1) r10.pop();
122770
123039
  else r10.push(s);
122771
123040
  return r10.join("/") || "/";
122772
123041
  }
122773
- function splitPath(path52) {
122774
- const s = path52.split("/");
123042
+ function splitPath(path54) {
123043
+ const s = path54.split("/");
122775
123044
  s.shift();
122776
123045
  if (s[s.length - 1] === "") s.pop();
122777
123046
  return s;
122778
123047
  }
122779
- function splitRoute(path52) {
122780
- const s = splitPath(path52);
123048
+ function splitRoute(path54) {
123049
+ const s = splitPath(path54);
122781
123050
  while (s[s.length - 1] === "") s.pop();
122782
123051
  return s;
122783
123052
  }
@@ -122793,16 +123062,16 @@ function getMatchParams(segments, paramsMap) {
122793
123062
  }
122794
123063
  return params;
122795
123064
  }
122796
- function addRoute(ctx, method = "", path52, data) {
123065
+ function addRoute(ctx, method = "", path54, data) {
122797
123066
  method = method.toUpperCase();
122798
- if (path52.charCodeAt(0) !== 47) path52 = `/${path52}`;
122799
- const groupExpanded = expandGroupDelimiters(path52);
123067
+ if (path54.charCodeAt(0) !== 47) path54 = `/${path54}`;
123068
+ const groupExpanded = expandGroupDelimiters(path54);
122800
123069
  if (groupExpanded) {
122801
123070
  for (const expandedPath of groupExpanded) addRoute(ctx, method, expandedPath, data);
122802
123071
  return;
122803
123072
  }
122804
- path52 = encodeEscapes(path52);
122805
- const segments = splitRoute(path52);
123073
+ path54 = encodeEscapes(path54);
123074
+ const segments = splitRoute(path54);
122806
123075
  const expanded = expandModifiers(segments);
122807
123076
  if (expanded) {
122808
123077
  for (const p of expanded) addRoute(ctx, method, p, data);
@@ -122893,15 +123162,15 @@ function getParamRegexp(segment, unnamedStart = 0) {
122893
123162
  const regex = _s2.replace(/:([\w-]+)(?:\(([^)]*)\))?/g, (_, id2, p) => `(?<${toGroupName(id2)}>${p || "[^/]+"})`).replace(/\((?![?<])/g, () => `(?<${toUnnamedGroupKey(_i2++)}>`).replace(/\uFFFE(.)/g, (_, c10) => /[.*+?^${}()|[\]\\]/.test(c10) ? `\\${c10}` : c10);
122894
123163
  return [new RegExp(`^${regex}$`), _i2];
122895
123164
  }
122896
- function findRoute(ctx, method = "", path52, opts) {
122897
- if (opts?.normalize) path52 = normalizePath(path52);
122898
- if (path52.charCodeAt(path52.length - 1) === 47) path52 = path52.slice(0, -1);
122899
- const staticNode = ctx.static[path52];
123165
+ function findRoute(ctx, method = "", path54, opts) {
123166
+ if (opts?.normalize) path54 = normalizePath(path54);
123167
+ if (path54.charCodeAt(path54.length - 1) === 47) path54 = path54.slice(0, -1);
123168
+ const staticNode = ctx.static[path54];
122900
123169
  if (staticNode && staticNode.methods) {
122901
123170
  const staticMatch = staticNode.methods[method] || staticNode.methods[""];
122902
123171
  if (staticMatch !== void 0) return staticMatch[0];
122903
123172
  }
122904
- const segments = splitPath(path52);
123173
+ const segments = splitPath(path54);
122905
123174
  const match = _lookupTree(ctx.root, method, segments, 0);
122906
123175
  if (match === void 0) return;
122907
123176
  if (opts?.params === false) return match;
@@ -123101,7 +123370,7 @@ var OpenAPIMatcher = class {
123101
123370
  this.rootRouter = router;
123102
123371
  this.index(router);
123103
123372
  }
123104
- index(router, path52 = []) {
123373
+ index(router, path54 = []) {
123105
123374
  const lazyResults = walkProcedureContractsSync(router, (contract, path210) => {
123106
123375
  if (!value(this.filter, contract, path210)) {
123107
123376
  return;
@@ -123116,7 +123385,7 @@ var OpenAPIMatcher = class {
123116
123385
  contract,
123117
123386
  procedure: contract instanceof Procedure ? contract : void 0
123118
123387
  });
123119
- }, path52);
123388
+ }, path54);
123120
123389
  for (const result of lazyResults) {
123121
123390
  const prefix = getOpenAPIMeta(result.router)?.prefix;
123122
123391
  this.pendingLazyRouters.add({
@@ -123203,20 +123472,20 @@ var OpenAPIMatcher = class {
123203
123472
  return entry.procedure;
123204
123473
  }
123205
123474
  };
123206
- function toRou3Pattern(path52) {
123207
- const params = getDynamicPathParams(path52);
123475
+ function toRou3Pattern(path54) {
123476
+ const params = getDynamicPathParams(path54);
123208
123477
  if (!params?.length) {
123209
- return path52;
123478
+ return path54;
123210
123479
  }
123211
123480
  for (let i10 = params.length - 1; i10 >= 0; i10--) {
123212
123481
  const param = params[i10];
123213
123482
  const pattern = param.allowsSlash ? `**:${param.parameterName}` : `:${param.parameterName}`;
123214
- path52 = path52.slice(0, param.startIndex) + pattern + path52.slice(param.startIndex + param.segment.length);
123483
+ path54 = path54.slice(0, param.startIndex) + pattern + path54.slice(param.startIndex + param.segment.length);
123215
123484
  }
123216
- return path52;
123485
+ return path54;
123217
123486
  }
123218
- function toRou3PrefixMatcher(path52) {
123219
- const pattern = toRou3Pattern(path52);
123487
+ function toRou3PrefixMatcher(path54) {
123488
+ const pattern = toRou3Pattern(path54);
123220
123489
  return routeToRegExp(pattern === "/" ? "/**" : `${pattern}/**`);
123221
123490
  }
123222
123491
  function decodeParams(params) {
@@ -123295,7 +123564,7 @@ var OpenAPIHandlerCodecCore = class {
123295
123564
  /**
123296
123565
  * @throws {TypeError} If `outputStructure` is "detailed" and the output doesn't match the expected structure.
123297
123566
  */
123298
- encodeOutput(output2, procedure, path52) {
123567
+ encodeOutput(output2, procedure, path54) {
123299
123568
  const meta3 = getOpenAPIMeta(procedure);
123300
123569
  const successStatus = meta3?.successStatus ?? DEFAULT_SUCCESS_STATUS;
123301
123570
  const outputStructure = meta3?.outputStructure ?? DEFAULT_OPENAPI_OUTPUT_STRUCTURE;
@@ -123308,7 +123577,7 @@ var OpenAPIHandlerCodecCore = class {
123308
123577
  }
123309
123578
  if (!isValidDetailedOutput(output2)) {
123310
123579
  throw new TypeError(`
123311
- Invalid "detailed" output structure returned by procedure (${path52.join(".")}):
123580
+ Invalid "detailed" output structure returned by procedure (${path54.join(".")}):
123312
123581
  \u2022 Expected an object with optional properties:
123313
123582
  - status (number <400)
123314
123583
  - headers (object)
@@ -123860,7 +124129,7 @@ function profileValue(name, paths) {
123860
124129
  function createConfigApiRouter(deps) {
123861
124130
  const authed = doorApiAuth(deps.expectedToken);
123862
124131
  const { paths } = deps;
123863
- const route = (path52, summary) => authed.meta(openapi({ method: "POST", path: path52, summary, tags: [CONFIG_API_TAG] }));
124132
+ const route = (path54, summary) => authed.meta(openapi({ method: "POST", path: path54, summary, tags: [CONFIG_API_TAG] }));
123864
124133
  return {
123865
124134
  config: {
123866
124135
  identity: {
@@ -124215,7 +124484,7 @@ function createLifecycleApiRouter(deps) {
124215
124484
  init_cliError();
124216
124485
 
124217
124486
  // src/frontdoor/launchSchemas.ts
124218
- var import_node_path43 = __toESM(require("node:path"), 1);
124487
+ var import_node_path44 = __toESM(require("node:path"), 1);
124219
124488
  init_zod();
124220
124489
  init_claudeVersion();
124221
124490
  init_identity();
@@ -124225,7 +124494,7 @@ var LaunchResolveInputSchema = external_exports.strictObject({
124225
124494
  argv: external_exports.readonly(external_exports.array(external_exports.string())).optional(),
124226
124495
  /** The launch's inherited environment. Absent means an empty one: the door's own environment is never a substitute for the caller's, so a caller that wants `AGENT_SHIM_*` switches or a `CLAUDE_CONFIG_DIR` considered names them here. Values are read, never reported. */
124227
124496
  env: external_exports.record(external_exports.string(), external_exports.string()).optional()
124228
- }).refine((input2) => import_node_path43.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
124497
+ }).refine((input2) => import_node_path44.default.isAbsolute(input2.path), { message: "path must be absolute: the door cannot resolve a relative path against the caller's working directory" });
124229
124498
  var LaunchPoolDecisionSchema = external_exports.strictObject({
124230
124499
  name: external_exports.string(),
124231
124500
  reasons: external_exports.readonly(external_exports.array(external_exports.string())),
@@ -125722,8 +125991,8 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
125722
125991
  request7.body.resume();
125723
125992
  return;
125724
125993
  }
125725
- const path52 = new URL(request7.url, "http://127.0.0.1").pathname;
125726
- const translated = { method: request7.method, path: path52, body, signal: request7.signal };
125994
+ const path54 = new URL(request7.url, "http://127.0.0.1").pathname;
125995
+ const translated = { method: request7.method, path: path54, body, signal: request7.signal };
125727
125996
  const routed = await route(translated);
125728
125997
  if (request7.signal.aborted) {
125729
125998
  return;
@@ -125757,7 +126026,7 @@ function createPassthroughRoute(name, target) {
125757
126026
  headroomUpstream: target.headroomUpstream,
125758
126027
  serve: async (request7, response) => {
125759
126028
  const incoming = new URL(request7.url, "http://127.0.0.1");
125760
- const path52 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
126029
+ const path54 = target.stripPrefix !== void 0 && incoming.pathname.startsWith(target.stripPrefix) ? incoming.pathname.slice(target.stripPrefix.length) : incoming.pathname;
125761
126030
  const headers = forwardableHeaders(request7.headers);
125762
126031
  delete headers.host;
125763
126032
  await new Promise((resolve2) => {
@@ -125765,7 +126034,7 @@ function createPassthroughRoute(name, target) {
125765
126034
  host: base.hostname,
125766
126035
  port: base.port === "" ? void 0 : Number(base.port),
125767
126036
  method: request7.method,
125768
- path: `${basePath}${path52}${incoming.search}`,
126037
+ path: `${basePath}${path54}${incoming.search}`,
125769
126038
  headers,
125770
126039
  agent
125771
126040
  };
@@ -125898,7 +126167,7 @@ async function scanRequestHead(request7, wholeBody = false) {
125898
126167
 
125899
126168
  // src/frontdoor/providerRoute.ts
125900
126169
  function createProviderRouteResolver(deps) {
125901
- const isRcSelfHostPath = (path52) => path52 === "/v1/code/sessions" || path52.startsWith("/v1/code/sessions/") || path52 === "/v1/sessions" || path52.startsWith("/v1/sessions/");
126170
+ const isRcSelfHostPath = (path54) => path54 === "/v1/code/sessions" || path54.startsWith("/v1/code/sessions/") || path54 === "/v1/sessions" || path54.startsWith("/v1/sessions/");
125902
126171
  const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
125903
126172
  const passthroughByTarget = /* @__PURE__ */ new Map();
125904
126173
  const passthroughFor = (name, target) => {
@@ -125912,16 +126181,16 @@ function createProviderRouteResolver(deps) {
125912
126181
  return route;
125913
126182
  };
125914
126183
  const resolve2 = (request7) => {
125915
- const path52 = new URL(request7.url, "http://127.0.0.1").pathname;
125916
- const scoped = parseProviderPath(path52);
126184
+ const path54 = new URL(request7.url, "http://127.0.0.1").pathname;
126185
+ const scoped = parseProviderPath(path54);
125917
126186
  if (scoped === void 0) {
125918
- if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path52)) {
126187
+ if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path54)) {
125919
126188
  return { ok: true, route: deps.rcSelfHostRoute };
125920
126189
  }
125921
- if (request7.session.provider !== void 0 && path52.startsWith("/v1/") && !isRcSelfHostPath(path52)) {
126190
+ if (request7.session.provider !== void 0 && path54.startsWith("/v1/") && !isRcSelfHostPath(path54)) {
125922
126191
  return resolve2({ ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` });
125923
126192
  }
125924
- return path52.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path52}` };
126193
+ return path54.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path54}` };
125925
126194
  }
125926
126195
  const { provider } = scoped;
125927
126196
  let definition;
@@ -125974,8 +126243,8 @@ function createProviderRouteResolver(deps) {
125974
126243
  let replay;
125975
126244
  const visited = /* @__PURE__ */ new Set();
125976
126245
  for (; ; ) {
125977
- const path52 = new URL(current.url, "http://127.0.0.1").pathname;
125978
- const scoped = parseProviderPath(path52);
126246
+ const path54 = new URL(current.url, "http://127.0.0.1").pathname;
126247
+ const scoped = parseProviderPath(path54);
125979
126248
  const providerName = scoped?.provider ?? current.session.provider;
125980
126249
  if (providerName !== void 0 && visited.has(providerName)) {
125981
126250
  return { ok: false, status: HTTP_STATUS.internalServerError, message: `provider routing cycle: ${[...visited, providerName].join(" -> ")}` };
@@ -126033,7 +126302,7 @@ function createProviderRouteResolver(deps) {
126033
126302
  const headers = Object.fromEntries(Object.entries(replay.headers).filter(([name]) => name.toLowerCase() !== "content-length"));
126034
126303
  replay = { ...replay, headers, body: import_node_stream3.Readable.from([Buffer.from(rewritten, "utf8")]) };
126035
126304
  }
126036
- const rest = scoped === void 0 ? path52 : path52.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
126305
+ const rest = scoped === void 0 ? path54 : path54.slice(`${PROVIDER_PATH_PREFIX}${encodeURIComponent(scoped.provider)}`.length);
126037
126306
  const query = current.url.includes("?") ? current.url.slice(current.url.indexOf("?")) : "";
126038
126307
  current = { ...current, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(matched.provider)}${rest}${query}`, body: replay.body, headers: replay.headers };
126039
126308
  }
@@ -126140,7 +126409,7 @@ function createRcLiveUsage(deps) {
126140
126409
  }
126141
126410
 
126142
126411
  // src/frontdoor/rcSelfHostMint.ts
126143
- var import_node_path44 = __toESM(require("node:path"), 1);
126412
+ var import_node_path45 = __toESM(require("node:path"), 1);
126144
126413
  init_account();
126145
126414
 
126146
126415
  // src/frontdoor/rcSelfHostLocal.ts
@@ -126270,7 +126539,7 @@ function readJsonObject(fs22, file2) {
126270
126539
  return isRecord7(parsed) ? parsed : void 0;
126271
126540
  }
126272
126541
  function readRcSelfHostRecord(fs22, frontdoorDir) {
126273
- const parsed = readJsonObject(fs22, import_node_path44.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
126542
+ const parsed = readJsonObject(fs22, import_node_path45.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
126274
126543
  if (parsed === void 0) {
126275
126544
  return void 0;
126276
126545
  }
@@ -126284,11 +126553,11 @@ function mintRcSelfHostCredential(deps) {
126284
126553
  if (!isIdentityName(deps.identity)) {
126285
126554
  throw new Error(`"${deps.identity}" is not a valid identity name.`);
126286
126555
  }
126287
- const identityDir = import_node_path44.default.join(deps.identitiesDir, deps.identity);
126288
- const credentialsFile = import_node_path44.default.join(identityDir, CREDENTIALS_FILE2);
126289
- const claudeJsonFile = import_node_path44.default.join(identityDir, CLAUDE_JSON2);
126290
- const recordDir = import_node_path44.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
126291
- const recordFile = import_node_path44.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
126556
+ const identityDir = import_node_path45.default.join(deps.identitiesDir, deps.identity);
126557
+ const credentialsFile = import_node_path45.default.join(identityDir, CREDENTIALS_FILE2);
126558
+ const claudeJsonFile = import_node_path45.default.join(identityDir, CLAUDE_JSON2);
126559
+ const recordDir = import_node_path45.default.join(deps.frontdoorDir, RC_SELF_HOST_RECORD_DIR);
126560
+ const recordFile = import_node_path45.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
126292
126561
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
126293
126562
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
126294
126563
  const existingOauth = isRecord7(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
@@ -126304,7 +126573,7 @@ function mintRcSelfHostCredential(deps) {
126304
126573
  const organizationUuid = deps.newUuid();
126305
126574
  const accountUuid = deps.newUuid();
126306
126575
  const mintedAt = new Date(deps.now()).toISOString();
126307
- deps.fs.mkdirPrivate(import_node_path44.default.dirname(credentialsFile));
126576
+ deps.fs.mkdirPrivate(import_node_path45.default.dirname(credentialsFile));
126308
126577
  deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
126309
126578
  `);
126310
126579
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
@@ -126691,7 +126960,7 @@ function registerRcCommand(frontdoor, paths) {
126691
126960
  }
126692
126961
 
126693
126962
  // src/frontdoor/rcCredentialStore.ts
126694
- var import_node_path45 = __toESM(require("node:path"), 1);
126963
+ var import_node_path46 = __toESM(require("node:path"), 1);
126695
126964
  function isSafeSessionId(sessionId) {
126696
126965
  return /^[A-Za-z0-9_-]+$/.test(sessionId);
126697
126966
  }
@@ -126717,7 +126986,7 @@ function sequenceNumOfJson(value2) {
126717
126986
  }
126718
126987
  function createRcCredentialStore(fs22, dir) {
126719
126988
  fs22.mkdirPrivate(dir);
126720
- const fileFor = (sessionId) => import_node_path45.default.join(dir, `${sessionId}.json`);
126989
+ const fileFor = (sessionId) => import_node_path46.default.join(dir, `${sessionId}.json`);
126721
126990
  const readParsed = (sessionId) => {
126722
126991
  const raw = fs22.readFileUtf8(fileFor(sessionId));
126723
126992
  if (raw === void 0) {
@@ -128995,8 +129264,14 @@ function realFrontDoorSupervisorPorts(paths) {
128995
129264
  const quotaRefresher = createRealQuotaRefresher({ paths, store: usageStore, log });
128996
129265
  const anthropicRefresher = createRealAnthropicUsageRefresher({ paths, store: usageStore, cwd: process.cwd(), spawnDaemon: spawnDetachedSupervisor, log });
128997
129266
  setInterval(() => {
128998
- const pools = readPools(paths);
128999
- void refreshStalePoolMembers({ poolNames: Object.keys(pools), pools, loadMembers: (identities) => loadPoolMembers(realFarmFs, paths, identities, Date.now()), refresher: anthropicRefresher });
129267
+ try {
129268
+ const pools = readPools(paths);
129269
+ refreshStalePoolMembers({ poolNames: Object.keys(pools), pools, loadMembers: (identities) => loadPoolMembers(realFarmFs, paths, identities, Date.now()), refresher: anthropicRefresher }).catch((error63) => {
129270
+ log(`pool usage refresh failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
129271
+ });
129272
+ } catch (error63) {
129273
+ log(`pool usage refresh failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
129274
+ }
129000
129275
  }, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
129001
129276
  const windowOpener = createRealWindowOpener({ paths, cwd: process.cwd(), spawnDaemon: spawnDetachedSupervisor });
129002
129277
  let keeperRunning = false;
@@ -129020,6 +129295,26 @@ function realFrontDoorSupervisorPorts(paths) {
129020
129295
  keeperRunning = false;
129021
129296
  });
129022
129297
  }, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
129298
+ const jobRunner = createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() });
129299
+ const runningJobs = /* @__PURE__ */ new Set();
129300
+ setInterval(() => {
129301
+ try {
129302
+ runJobs({
129303
+ fs: realFarmFs,
129304
+ stampsFile: paths.usageJobsFile,
129305
+ nowMs: () => Date.now(),
129306
+ timeZone: machineTimeZone(),
129307
+ jobs: () => Object.entries(readJobs(paths)).map(([name, job]) => ({ name, job })),
129308
+ resolveIdentity: (target) => resolveJobIdentity({ paths, fs: realFarmFs, pools: readPools(paths), nowMs: Date.now(), identityExists: (name) => identityExists(paths, name) }, target),
129309
+ snapshot: (identity) => readUsageSnapshot(realFarmFs, paths.usageSnapshotsDir, identity),
129310
+ run: jobRunner,
129311
+ running: runningJobs,
129312
+ log
129313
+ });
129314
+ } catch (error63) {
129315
+ log(`job keeper failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
129316
+ }
129317
+ }, ANTHROPIC_USAGE_FRESHNESS_MS).unref();
129023
129318
  const usageMiddleware = createUsageMiddleware({
129024
129319
  record: withQuotaRefresh(usageStore.record, quotaRefresher),
129025
129320
  defer: (task) => {
@@ -129163,7 +129458,7 @@ function realFrontDoorSupervisorPorts(paths) {
129163
129458
  const leafFor = createLeafCache(loadCa(), () => /* @__PURE__ */ new Date());
129164
129459
  const capture = captureFromEnv(process.env, paths.logsDir);
129165
129460
  if (capture !== void 0) {
129166
- log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path46.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
129461
+ log(`capture enabled, recording CONNECT targets and piped exchanges to ${import_node_path47.default.join(paths.logsDir, "frontdoor-capture.jsonl")}`);
129167
129462
  }
129168
129463
  if (rcSelfHostSurface !== void 0) {
129169
129464
  log("self-hosted Remote Control surface on: the door serves the CCR session family itself, and its own client-half dials its own transparent surface");
@@ -131300,8 +131595,8 @@ function getErrorMap2() {
131300
131595
 
131301
131596
  // node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/helpers/parseUtil.js
131302
131597
  var makeIssue = (params) => {
131303
- const { data, path: path52, errorMaps, issueData } = params;
131304
- const fullPath = [...path52, ...issueData.path || []];
131598
+ const { data, path: path54, errorMaps, issueData } = params;
131599
+ const fullPath = [...path54, ...issueData.path || []];
131305
131600
  const fullIssue = {
131306
131601
  ...issueData,
131307
131602
  path: fullPath
@@ -131416,11 +131711,11 @@ var errorUtil;
131416
131711
 
131417
131712
  // node_modules/.pnpm/zod@4.6.5/node_modules/zod/v3/types.js
131418
131713
  var ParseInputLazyPath = class {
131419
- constructor(parent, value2, path52, key) {
131714
+ constructor(parent, value2, path54, key) {
131420
131715
  this._cachedPath = [];
131421
131716
  this.parent = parent;
131422
131717
  this.data = value2;
131423
- this._path = path52;
131718
+ this._path = path54;
131424
131719
  this._key = key;
131425
131720
  }
131426
131721
  get path() {
@@ -134983,11 +135278,11 @@ function normalizeObjectSchema(schema) {
134983
135278
  }
134984
135279
  return void 0;
134985
135280
  }
134986
- function getDotPath(path52) {
134987
- if (path52.length === 0) {
135281
+ function getDotPath(path54) {
135282
+ if (path54.length === 0) {
134988
135283
  return "object root";
134989
135284
  }
134990
- return path52.reduce((acc, seg, index) => {
135285
+ return path54.reduce((acc, seg, index) => {
134991
135286
  if (index === 0) {
134992
135287
  return String(seg);
134993
135288
  }
@@ -139030,7 +139325,7 @@ async function serveMcp(mcp, transport, options = {}) {
139030
139325
 
139031
139326
  // src/mcp/permissions.ts
139032
139327
  var import_node_fs17 = __toESM(require("node:fs"), 1);
139033
- var import_node_path47 = __toESM(require("node:path"), 1);
139328
+ var import_node_path48 = __toESM(require("node:path"), 1);
139034
139329
  init_zod();
139035
139330
  init_store();
139036
139331
  var StoredMcpPermissionsSchema = external_exports.strictObject({
@@ -139050,10 +139345,10 @@ function effectiveMcpPermissions(flags, stored) {
139050
139345
  return { writes: flags.writes || stored.writes, remoteControl: flags.remoteControl || stored.remoteControl };
139051
139346
  }
139052
139347
  function watchMcpPermissions(paths, onChange) {
139053
- const directory = import_node_path47.default.dirname(paths.mcpPermissionsFile);
139348
+ const directory = import_node_path48.default.dirname(paths.mcpPermissionsFile);
139054
139349
  import_node_fs17.default.mkdirSync(directory, { recursive: true });
139055
139350
  const watcher = import_node_fs17.default.watch(directory, (_event, filename) => {
139056
- if (filename === null || filename === import_node_path47.default.basename(paths.mcpPermissionsFile)) {
139351
+ if (filename === null || filename === import_node_path48.default.basename(paths.mcpPermissionsFile)) {
139057
139352
  onChange();
139058
139353
  }
139059
139354
  });
@@ -139362,16 +139657,16 @@ init_credentialCache();
139362
139657
 
139363
139658
  // src/identityToken.ts
139364
139659
  var import_node_fs18 = __toESM(require("node:fs"), 1);
139365
- var import_node_path48 = __toESM(require("node:path"), 1);
139660
+ var import_node_path49 = __toESM(require("node:path"), 1);
139366
139661
  init_cliError();
139367
139662
  var TOKEN_FILE_MODE = 384;
139368
139663
  var TOKEN_DIR_MODE = 448;
139369
139664
  var OAUTH_TOKEN_RE = /^sk-ant-oat\d+-[A-Za-z0-9_-]+$/;
139370
139665
  function identityTokenDir(paths) {
139371
- return import_node_path48.default.join(paths.root, "credentials");
139666
+ return import_node_path49.default.join(paths.root, "credentials");
139372
139667
  }
139373
139668
  function identityTokenPath(paths, identityName) {
139374
- return import_node_path48.default.join(identityTokenDir(paths), `${identityName}.token`);
139669
+ return import_node_path49.default.join(identityTokenDir(paths), `${identityName}.token`);
139375
139670
  }
139376
139671
  function storeIdentityToken(paths, identityName, raw) {
139377
139672
  const token = raw.trim();
@@ -139382,7 +139677,7 @@ function storeIdentityToken(paths, identityName, raw) {
139382
139677
  import_node_fs18.default.mkdirSync(dir, { recursive: true, mode: TOKEN_DIR_MODE });
139383
139678
  import_node_fs18.default.chmodSync(dir, TOKEN_DIR_MODE);
139384
139679
  const target = identityTokenPath(paths, identityName);
139385
- const temp = import_node_path48.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
139680
+ const temp = import_node_path49.default.join(dir, `.${identityName}.${String(process.pid)}.tmp`);
139386
139681
  import_node_fs18.default.writeFileSync(temp, `${token}
139387
139682
  `, { mode: TOKEN_FILE_MODE });
139388
139683
  import_node_fs18.default.renameSync(temp, target);
@@ -139550,7 +139845,7 @@ function registerDoctorCommand(program2, deps) {
139550
139845
  // src/headroom/commands.ts
139551
139846
  var import_node_fs19 = __toESM(require("node:fs"), 1);
139552
139847
  var import_node_http4 = __toESM(require("node:http"), 1);
139553
- var import_node_path49 = __toESM(require("node:path"), 1);
139848
+ var import_node_path50 = __toESM(require("node:path"), 1);
139554
139849
  var import_node_child_process6 = require("node:child_process");
139555
139850
  init_commandDeps();
139556
139851
  init_realFrontDoorPort();
@@ -139680,12 +139975,12 @@ function readInstalledHeadroomCommit() {
139680
139975
  if (toolDir.status !== 0) {
139681
139976
  return void 0;
139682
139977
  }
139683
- const libDir = import_node_path49.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
139978
+ const libDir = import_node_path50.default.join(toolDir.stdout.trim(), HEADROOM_TOOL_NAME, "lib");
139684
139979
  for (const python of realFarmFs.readdir(libDir)) {
139685
- const sitePackages = import_node_path49.default.join(libDir, python, "site-packages");
139980
+ const sitePackages = import_node_path50.default.join(libDir, python, "site-packages");
139686
139981
  for (const entry of realFarmFs.readdir(sitePackages)) {
139687
139982
  if (entry.startsWith("headroom_ai-") && entry.endsWith(".dist-info")) {
139688
- const directUrl = realFarmFs.readFileUtf8(import_node_path49.default.join(sitePackages, entry, "direct_url.json"));
139983
+ const directUrl = realFarmFs.readFileUtf8(import_node_path50.default.join(sitePackages, entry, "direct_url.json"));
139689
139984
  return directUrl === void 0 ? void 0 : parseInstalledCommit(directUrl);
139690
139985
  }
139691
139986
  }
@@ -139820,6 +140115,134 @@ function registerHeadroomCommand(program2, deps) {
139820
140115
  });
139821
140116
  }
139822
140117
 
140118
+ // src/jobs.ts
140119
+ var import_node_path51 = __toESM(require("node:path"), 1);
140120
+ init_commandDeps();
140121
+ init_cliError();
140122
+ init_schema();
140123
+ init_realPorts();
140124
+ function jobOf(options) {
140125
+ if (options.identity === void 0 === (options.pool === void 0)) {
140126
+ throw new UsageError("A job runs as one identity or one pool's pick: pass exactly one of --identity or --pool.");
140127
+ }
140128
+ if (options.at === void 0 === (options.beforeReset === void 0)) {
140129
+ throw new UsageError("A job needs exactly one trigger: pass --at (repeatable) or --before-reset with --lead.");
140130
+ }
140131
+ if (options.beforeReset !== void 0 && options.lead === void 0) {
140132
+ throw new UsageError("--before-reset needs --lead, how long before the window resets the job runs.");
140133
+ }
140134
+ if (options.at !== void 0 && options.lead !== void 0) {
140135
+ throw new UsageError("--lead only goes with --before-reset.");
140136
+ }
140137
+ if (options.prompt === void 0 || options.timeout === void 0) {
140138
+ throw new UsageError("A job needs --prompt, what to run, and --timeout, how long one run may take.");
140139
+ }
140140
+ return {
140141
+ target: options.identity === void 0 ? { pool: options.pool ?? "" } : { identity: options.identity },
140142
+ trigger: options.at === void 0 ? { beforeReset: options.beforeReset ?? "fiveHour", lead: options.lead ?? "" } : { at: options.at },
140143
+ prompt: options.prompt,
140144
+ cwd: import_node_path51.default.resolve(options.cwd ?? process.cwd()),
140145
+ timeout: options.timeout,
140146
+ ...options.model === void 0 ? {} : { model: options.model },
140147
+ ...options.allowedTool === void 0 ? {} : { allowedTools: options.allowedTool }
140148
+ };
140149
+ }
140150
+ function describeTrigger(job) {
140151
+ return "at" in job.trigger ? `at ${job.trigger.at.map(formatAnchor).join(" ")}` : `${job.trigger.lead} before the ${job.trigger.beforeReset} window resets`;
140152
+ }
140153
+ function describeTarget(job) {
140154
+ return "identity" in job.target ? `identity ${job.target.identity}` : `the pick of pool ${job.target.pool}`;
140155
+ }
140156
+ function registerJobCommand(program2, deps) {
140157
+ const { paths } = deps;
140158
+ const job = withExamples(
140159
+ program2.command("job").description("Manage jobs: prompts the front door runs unattended as an identity, on a schedule or shortly before a quota window resets to use quota that would expire."),
140160
+ ["agent-shim job add digest --identity work --before-reset sevenDay --lead 6h --prompt 'summarise open PRs' --timeout 30m", "agent-shim job list"]
140161
+ );
140162
+ withExamples(
140163
+ job.command("add <name>").description("Define a job. Fails if one with this name already exists.").option("--identity <name>", "Run as this identity.").option("--pool <name>", "Run as whichever member of this pool the ranking picks when the job fires.").option("--at <spec>", `Run at these times (repeatable): ${ANCHOR_SYNTAX}.`, collectAnchor).addOption(new Option("--before-reset <window>", "Run once per instance of this quota window, when it has --lead or less left.").choices(JOB_WINDOWS)).option("--lead <duration>", "With --before-reset: how long before the window resets the job runs, a count followed by m, h, d or w, such as 6h.", parseDurationLiteral).option("--prompt <text>", "What to run.").option("--cwd <dir>", "The directory the run works in. Defaults to the current directory.").option("--timeout <duration>", "How long one run may take, such as 30m. A run that goes on longer is stopped.", parseDurationLiteral).option("--model <model>", "The model to run with. Defaults to the settings' own.").option("--allowed-tool <tool>", "A tool the run may use without asking, beyond what its settings allow (repeatable). An unattended run cannot answer a permission prompt, so any other tool is refused.", collectRepeated).option("--json", "Print the result as JSON.").action((name, options) => {
140164
+ const defined = jobOf(options);
140165
+ if ("identity" in defined.target) {
140166
+ requireIdentityNames(paths, [defined.target.identity]);
140167
+ } else {
140168
+ requirePool(paths, defined.target.pool);
140169
+ }
140170
+ const created = addJob(paths, name, defined);
140171
+ reportMutation(options.json, { action: "created", kind: "job", name, value: created }, () => {
140172
+ console.log(`Created job "${name}": runs as ${describeTarget(created)}, ${describeTrigger(created)}.`);
140173
+ });
140174
+ }),
140175
+ ["agent-shim job add digest --identity work --at mon-fri@06:00 --prompt 'summarise open PRs' --timeout 30m --cwd ~/work/app", "agent-shim job add burn --pool subs --before-reset fiveHour --lead 20m --prompt 'continue the migration plan' --timeout 20m --allowed-tool Read --allowed-tool Edit"]
140176
+ );
140177
+ withExamples(
140178
+ job.command("list").description("List every job.").option("--json", "Print the jobs as JSON.").action((options) => {
140179
+ const jobs = readJobs(paths);
140180
+ if (options.json === true) {
140181
+ printJson(Object.entries(jobs).map(([name, entry]) => ({ name, ...entry })));
140182
+ return;
140183
+ }
140184
+ const names = Object.keys(jobs).sort();
140185
+ if (names.length === 0) {
140186
+ console.log("No jobs yet. Run `agent-shim job add <name> ...` to create one.");
140187
+ return;
140188
+ }
140189
+ for (const name of names) {
140190
+ const entry = jobs[name];
140191
+ if (entry !== void 0) {
140192
+ console.log(`${name}: ${describeTarget(entry)}, ${describeTrigger(entry)}`);
140193
+ }
140194
+ }
140195
+ }),
140196
+ ["agent-shim job list", "agent-shim job list --json"]
140197
+ );
140198
+ withExamples(
140199
+ job.command("show <name>").description("Show one job.").option("--json", "Print the job as JSON.").action((name, options) => {
140200
+ const entry = requireJob(paths, name);
140201
+ if (options.json === true) {
140202
+ printJson({ name, ...entry });
140203
+ return;
140204
+ }
140205
+ console.log(`Job: ${name}`);
140206
+ console.log(`Runs as: ${describeTarget(entry)}`);
140207
+ console.log(`Trigger: ${describeTrigger(entry)}`);
140208
+ console.log(`Directory: ${entry.cwd}`);
140209
+ console.log(`Timeout: ${entry.timeout}`);
140210
+ if (entry.model !== void 0) {
140211
+ console.log(`Model: ${entry.model}`);
140212
+ }
140213
+ if (entry.allowedTools !== void 0) {
140214
+ console.log(`Allowed tools: ${entry.allowedTools.join(", ")}`);
140215
+ }
140216
+ console.log(`Prompt: ${entry.prompt}`);
140217
+ console.log(`Results: ${import_node_path51.default.join(paths.jobLogsDir, `${name}.log`)}`);
140218
+ }),
140219
+ ["agent-shim job show digest"]
140220
+ );
140221
+ withExamples(
140222
+ job.command("remove <name>").description("Delete a job.").option("--yes", "Skip the confirmation prompt.").option("--json", "Print the result as JSON.").action(async (name, options) => {
140223
+ requireJob(paths, name);
140224
+ await confirmRemoval(deps, options.yes, `job "${name}"`);
140225
+ removeJob(paths, name);
140226
+ reportMutation(options.json, { action: "removed", kind: "job", name }, () => {
140227
+ console.log(`Removed job "${name}".`);
140228
+ });
140229
+ }),
140230
+ ["agent-shim job remove digest --yes"]
140231
+ );
140232
+ withExamples(
140233
+ job.command("run <name>").description("Run a job now, in this terminal, as its trigger would: for a pool the member is picked at this moment. The result is appended to the job's log, and a failure exits non-zero.").action(async (name) => {
140234
+ const entry = requireJob(paths, name);
140235
+ const identity = resolveJobIdentity({ paths, fs: realFarmFs, pools: readPools(paths), nowMs: Date.now(), identityExists: (candidate) => identityExists(paths, candidate) }, entry.target);
140236
+ if (identity === void 0) {
140237
+ throw new UsageError(`No member of the job's pool can be picked right now.`);
140238
+ }
140239
+ await createRealJobRunner({ paths, spawnDaemon: spawnDetachedSupervisor, fs: realFarmFs, now: () => /* @__PURE__ */ new Date() })(name, identity, entry);
140240
+ console.log(`Ran job "${name}" as ${identity}; the result is in ${import_node_path51.default.join(paths.jobLogsDir, `${name}.log`)}.`);
140241
+ }),
140242
+ ["agent-shim job run digest"]
140243
+ );
140244
+ }
140245
+
139823
140246
  // src/pools.ts
139824
140247
  init_commandDeps();
139825
140248
  init_cliError();
@@ -140225,7 +140648,7 @@ function registerRunCommand(program2, handler) {
140225
140648
  }
140226
140649
 
140227
140650
  // src/usage/commands.ts
140228
- var import_node_path50 = __toESM(require("node:path"), 1);
140651
+ var import_node_path52 = __toESM(require("node:path"), 1);
140229
140652
  init_commandDeps();
140230
140653
  init_realPorts();
140231
140654
  init_account();
@@ -140363,7 +140786,7 @@ function collectAccounts(fs22, paths, identity, probe) {
140363
140786
  return names.map((name) => ({
140364
140787
  identity: name,
140365
140788
  account: readAccountMetadata(fs22, paths.identitiesDir, name),
140366
- signIn: identitySignIn(fs22, probe, { farmRoot: import_node_path50.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
140789
+ signIn: identitySignIn(fs22, probe, { farmRoot: import_node_path52.default.join(paths.identitiesDir, name), hasCredentialBlock: readIdentity(paths, name)?.credential !== void 0 }),
140367
140790
  usage: readUsageSnapshot(fs22, paths.usageSnapshotsDir, name)
140368
140791
  }));
140369
140792
  }
@@ -140534,6 +140957,7 @@ function buildProgram(deps) {
140534
140957
  registerIdentityCommand(program2, deps);
140535
140958
  registerProfileCommand(program2, deps);
140536
140959
  registerPoolCommand(program2, deps);
140960
+ registerJobCommand(program2, deps);
140537
140961
  registerProviderCommand(program2, deps);
140538
140962
  registerRuleCommand(program2, deps);
140539
140963
  registerCredentialCommand(program2, deps, deps.credentialPorts);
@@ -140708,7 +141132,7 @@ async function runClaude(argvOverride) {
140708
141132
  // src/cli.ts
140709
141133
  async function main() {
140710
141134
  aliasLegacyEnv(process.env);
140711
- const invokedName = import_node_path51.default.basename(process.argv[1] ?? "agent-shim");
141135
+ const invokedName = import_node_path53.default.basename(process.argv[1] ?? "agent-shim");
140712
141136
  if (isInvokedAsClaude(invokedName)) {
140713
141137
  await runClaude();
140714
141138
  return;