agent-shim 11.25.0 → 11.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -56,7 +56,10 @@ var init_categories_default = __esm({
56
56
  "usage-data",
57
57
  "ide",
58
58
  "cache",
59
- "scheduled_tasks.lock"
59
+ "scheduled_tasks.lock",
60
+ "policy-limits.json*",
61
+ "remote-settings.json*",
62
+ "state"
60
63
  ],
61
64
  history: [
62
65
  "projects",
@@ -242,7 +245,7 @@ function isTimeZone(name) {
242
245
  return false;
243
246
  }
244
247
  }
245
- var import_node_path2, import_zod, import_trilean, 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, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, 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, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
248
+ var import_node_path2, import_zod, import_trilean, 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, ANTIGRAVITY_MODES, CLAUDE_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, PickerModelSchema, PickerModelsSchema, ProviderCatalogueSchema, HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, 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, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
246
249
  var init_schema = __esm({
247
250
  "src/config/schema.ts"() {
248
251
  "use strict";
@@ -424,6 +427,12 @@ var init_schema = __esm({
424
427
  description: import_zod.z.string().min(1).optional()
425
428
  });
426
429
  PickerModelsSchema = import_zod.z.array(PickerModelSchema).refine((models) => new Set(models.map((entry) => entry.model)).size === models.length, { message: "pickerModels names a model more than once" });
430
+ ProviderCatalogueSchema = import_zod.z.strictObject({
431
+ tier: import_zod.z.enum(CLAUDE_TIERS),
432
+ include: import_zod.z.array(import_zod.z.string().min(1)).min(1).optional(),
433
+ exclude: import_zod.z.array(import_zod.z.string().min(1)).min(1).optional(),
434
+ url: import_zod.z.url().optional()
435
+ });
427
436
  HttpProviderSchema = import_zod.z.strictObject({
428
437
  $schema: import_zod.z.string().optional(),
429
438
  kind: import_zod.z.literal("http").optional(),
@@ -433,6 +442,8 @@ var init_schema = __esm({
433
442
  env: ProviderEnvSchema.optional(),
434
443
  /** Extra models `/model` lists beside the ones the tier settings name. */
435
444
  pickerModels: PickerModelsSchema.optional(),
445
+ /** The provider's own model catalogue, listed in `/model` when set. */
446
+ catalogue: ProviderCatalogueSchema.optional(),
436
447
  /** Per-request routing: when present, each request this provider would serve is matched against the list in order, and the first definite match is sent to that entry's provider instead (itself resolved exactly as a directly dialled request would be). Unmatched requests stay on this provider. */
437
448
  routes: import_zod.z.array(ProviderRouteSchema).optional()
438
449
  });
@@ -643,7 +654,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
643
654
  return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
644
655
  }
645
656
  function describeIgnoredKeys(filePath, ignored) {
646
- const places = ignored.map(({ path: path42, keys }) => `${path42.length === 0 ? "" : `${path42.map(String).join(".")}.`}${keys.join(", ")}`);
657
+ const places = ignored.map(({ path: path43, keys }) => `${path43.length === 0 ? "" : `${path43.map(String).join(".")}.`}${keys.join(", ")}`);
647
658
  return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
648
659
  }
649
660
  function noteIgnoredKeys(filePath, ignored) {
@@ -665,9 +676,9 @@ function restoreIgnoredKeys(filePath, value) {
665
676
  return value;
666
677
  }
667
678
  const restored = structuredClone(value);
668
- for (const { path: path42, values } of ignored) {
679
+ for (const { path: path43, values } of ignored) {
669
680
  let holder = restored;
670
- for (const step of path42) {
681
+ for (const step of path43) {
671
682
  holder = isRecord(holder) ? holder[step] : void 0;
672
683
  }
673
684
  if (isRecord(holder)) {
@@ -1475,6 +1486,12 @@ var init_flatten = __esm({
1475
1486
  });
1476
1487
 
1477
1488
  // src/resolve/decide.ts
1489
+ function unclassifiedEntryMessage(names) {
1490
+ const quoted = names.map((name) => `"${name}"`).join(", ");
1491
+ const subject = names.length === 1 ? `${quoted} is not` : `${String(names.length)} entries are not`;
1492
+ const excluded = names.length === 1 ? "it is excluded" : `they are excluded: ${quoted}`;
1493
+ return `${subject} in the category map, so ${excluded}. Run \`agent-shim configure\` to classify ${names.length === 1 ? "it" : "them"}, which records the answer in the local overlay without touching the shipped default map.`;
1494
+ }
1478
1495
  function selectRule(relPath, flattened, context) {
1479
1496
  const eliminated = [];
1480
1497
  for (const rule of matchingRules(flattened, relPath)) {
@@ -1512,7 +1529,7 @@ function resolveEntry(relPath, params) {
1512
1529
  diagnostics.push({
1513
1530
  code: "UNCLASSIFIED_ENTRY",
1514
1531
  severity: "warning",
1515
- message: `"${head}" is not in the category map, so it is excluded. Run \`agent-shim configure\` to classify it, which records the answer in the local overlay without touching the shipped default map.`,
1532
+ message: unclassifiedEntryMessage([head]),
1516
1533
  subject: head
1517
1534
  });
1518
1535
  return { decision: { relPath, shared: false, via: "unclassified", category }, diagnostics };
@@ -2947,7 +2964,7 @@ var init_package = __esm({
2947
2964
  "package.json"() {
2948
2965
  package_default = {
2949
2966
  name: "agent-shim",
2950
- version: "11.25.0",
2967
+ version: "11.27.0",
2951
2968
  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.",
2952
2969
  license: "MIT",
2953
2970
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -4113,6 +4130,40 @@ var init_supervisor = __esm({
4113
4130
  }
4114
4131
  });
4115
4132
 
4133
+ // src/logStyle.ts
4134
+ function styledDiagnostic(style, colour, line) {
4135
+ const lead = DIAGNOSTIC_LEAD.exec(line);
4136
+ if (lead === null) {
4137
+ return style([colour], line);
4138
+ }
4139
+ const [whole, prefix = "", code = "", separator = ""] = lead;
4140
+ return `${style([colour], prefix)}${style([colour, "bold"], code)}${style([colour], `${separator}${line.slice(whole.length)}`)}`;
4141
+ }
4142
+ function createLogPort(sinks, styleFor) {
4143
+ return {
4144
+ info: (message) => {
4145
+ sinks.out(styleFor.out(["dim"], message));
4146
+ },
4147
+ warn: (message) => {
4148
+ sinks.warn(styledDiagnostic(styleFor.err, "yellow", message));
4149
+ },
4150
+ error: (message) => {
4151
+ sinks.err(styledDiagnostic(styleFor.err, "red", message));
4152
+ }
4153
+ };
4154
+ }
4155
+ function styleTextFor(stream) {
4156
+ return (formats, text) => (0, import_node_util.styleText)([...formats], text, { stream });
4157
+ }
4158
+ var import_node_util, DIAGNOSTIC_LEAD;
4159
+ var init_logStyle = __esm({
4160
+ "src/logStyle.ts"() {
4161
+ "use strict";
4162
+ import_node_util = require("node:util");
4163
+ DIAGNOSTIC_LEAD = /^(agent-shim: )([A-Z][A-Z0-9_]*)(: )/;
4164
+ }
4165
+ });
4166
+
4116
4167
  // src/realPorts.ts
4117
4168
  function isEnoent3(error) {
4118
4169
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
@@ -4351,7 +4402,7 @@ function realResolveClaudeBinary(isOwnBinary) {
4351
4402
  function realInstalledClaudeVersions() {
4352
4403
  return installedVersions(listVersionsDir(defaultVersionsDir()));
4353
4404
  }
4354
- var import_node_child_process2, import_node_crypto8, import_node_fs2, import_node_os2, import_node_path14, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, PS_TIMEOUT_MS, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
4405
+ var import_node_child_process2, import_node_crypto8, import_node_fs2, import_node_os2, import_node_path14, import_node_sea, realFsPort, OWNER_ONLY_DIR_MODE, OWNER_ONLY_FILE_MODE, PERMISSION_BITS, realFarmFs, INT32_BYTE_LENGTH, PS_TIMEOUT_MS, realRunPort, MACOS_GUI_SESSION_MANAGER, realCredentialPort, SOCKET_PERMISSION_BITS, realHeadroomSocketTrust, realSpawnPort, realProcPort, realLogPort, EXECUTE_BITS_MASK, WINDOWS_DEFAULT_PATHEXT;
4355
4406
  var init_realPorts = __esm({
4356
4407
  "src/realPorts.ts"() {
4357
4408
  "use strict";
@@ -4368,6 +4419,7 @@ var init_realPorts = __esm({
4368
4419
  init_ensure();
4369
4420
  init_supervisor();
4370
4421
  init_state2();
4422
+ init_logStyle();
4371
4423
  realFsPort = {
4372
4424
  readFileUtf8(filePath) {
4373
4425
  try {
@@ -4573,6 +4625,16 @@ var init_realPorts = __esm({
4573
4625
  argv: process.argv.slice(2),
4574
4626
  exit: (code) => process.exit(code)
4575
4627
  };
4628
+ realLogPort = createLogPort(
4629
+ { out: (line) => {
4630
+ console.log(line);
4631
+ }, warn: (line) => {
4632
+ console.warn(line);
4633
+ }, err: (line) => {
4634
+ console.error(line);
4635
+ } },
4636
+ { out: styleTextFor(process.stdout), err: styleTextFor(process.stderr) }
4637
+ );
4576
4638
  EXECUTE_BITS_MASK = 73;
4577
4639
  WINDOWS_DEFAULT_PATHEXT = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PS1";
4578
4640
  }
@@ -6055,6 +6117,7 @@ function buildLayoutPaths(root) {
6055
6117
  usageDir: import_node_path23.default.join(root, "usage"),
6056
6118
  usageLogDir: import_node_path23.default.join(root, "usage", "log"),
6057
6119
  usageSnapshotsDir: import_node_path23.default.join(root, "usage", "snapshots"),
6120
+ catalogueDir: import_node_path23.default.join(root, "catalogues"),
6058
6121
  usagePicksFile: import_node_path23.default.join(root, "usage", "picks.json"),
6059
6122
  usageAnchorsFile: import_node_path23.default.join(root, "usage", "anchors.json"),
6060
6123
  usageJobsFile: import_node_path23.default.join(root, "usage", "jobs.json"),
@@ -6501,7 +6564,10 @@ function loadProvider(providersDir, name, port) {
6501
6564
  const raw = port.readConfigFile(filePath);
6502
6565
  return raw === void 0 ? void 0 : parseProviderFile(filePath, raw);
6503
6566
  }
6504
- function listProviders(paths) {
6567
+ function reportInvalidProvider(name, message) {
6568
+ console.error(`agent-shim: providers/${name}.json is invalid and was skipped: ${message}`);
6569
+ }
6570
+ function listProviders(paths, onInvalid = reportInvalidProvider) {
6505
6571
  const names = listProviderNames(
6506
6572
  (dir) => import_node_fs6.default.readdirSync(dir),
6507
6573
  paths.providersDir
@@ -6515,7 +6581,7 @@ function listProviders(paths) {
6515
6581
  if (!(error instanceof ConfigValidationError || error instanceof LegacyProviderFileError)) {
6516
6582
  throw error;
6517
6583
  }
6518
- console.error(`agent-shim: providers/${name}.json is invalid and was skipped: ${error.message}`);
6584
+ onInvalid(name, error.message);
6519
6585
  continue;
6520
6586
  }
6521
6587
  if (provider !== void 0) {
@@ -6565,6 +6631,9 @@ function addProvider(paths, name, input) {
6565
6631
  if (kind === "http" && input.baseUrl === void 0) {
6566
6632
  throw new ProviderKindMismatchError("An http provider needs --base-url.");
6567
6633
  }
6634
+ if (kind !== "http" && input.catalogue !== void 0) {
6635
+ throw new ProviderKindMismatchError("A model catalogue applies only to an http provider.");
6636
+ }
6568
6637
  if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
6569
6638
  throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
6570
6639
  }
@@ -6578,7 +6647,7 @@ function addProvider(paths, name, input) {
6578
6647
  ...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
6579
6648
  };
6580
6649
  const parsed = ProviderSchema.safeParse(
6581
- kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl }
6650
+ kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl, ...input.catalogue === void 0 ? {} : { catalogue: input.catalogue } }
6582
6651
  );
6583
6652
  if (!parsed.success) {
6584
6653
  throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
@@ -6607,6 +6676,9 @@ function updateProvider(paths, name, input) {
6607
6676
  if (isAntigravityProvider(existing) && input.baseUrl !== void 0) {
6608
6677
  throw new ProviderKindMismatchError(`Provider "${name}" is an antigravity provider, which has no base URL.`);
6609
6678
  }
6679
+ if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
6680
+ throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
6681
+ }
6610
6682
  if (!isCodexProvider(existing) && !isEmptyCodexConfig(input.codex)) {
6611
6683
  throw new ProviderKindMismatchError(`Provider "${name}" is not a codex provider; codex settings apply only to a codex provider.`);
6612
6684
  }
@@ -6639,7 +6711,8 @@ function updateProvider(paths, name, input) {
6639
6711
  };
6640
6712
  candidate = { ...existing, ...shared, antigravity: isEmptyAntigravityConfig(antigravity) ? void 0 : antigravity };
6641
6713
  } else {
6642
- candidate = { ...existing, ...shared, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
6714
+ const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
6715
+ candidate = { ...existing, ...shared, catalogue, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
6643
6716
  }
6644
6717
  const parsed = ProviderSchema.safeParse(candidate);
6645
6718
  if (!parsed.success) {
@@ -7872,6 +7945,42 @@ var init_claudeSession = __esm({
7872
7945
  }
7873
7946
  });
7874
7947
 
7948
+ // src/launcher/diagnostics.ts
7949
+ function diagnosticLines(diagnostics) {
7950
+ const unclassified = [...new Set(diagnostics.filter((diagnostic) => diagnostic.code === "UNCLASSIFIED_ENTRY").map((diagnostic) => diagnostic.subject))];
7951
+ const lines = [];
7952
+ let unclassifiedReported = false;
7953
+ for (const diagnostic of diagnostics) {
7954
+ if (diagnostic.severity === "info") {
7955
+ continue;
7956
+ }
7957
+ if (diagnostic.code === "UNCLASSIFIED_ENTRY") {
7958
+ if (!unclassifiedReported) {
7959
+ unclassifiedReported = true;
7960
+ lines.push({ severity: diagnostic.severity, text: `agent-shim: ${diagnostic.code}: ${unclassifiedEntryMessage(unclassified.filter((name) => name !== void 0))}` });
7961
+ }
7962
+ continue;
7963
+ }
7964
+ lines.push({ severity: diagnostic.severity, text: `agent-shim: ${diagnostic.code}: ${diagnostic.message}` });
7965
+ }
7966
+ return lines;
7967
+ }
7968
+ function reportDiagnostics(log, diagnostics, options) {
7969
+ for (const line of diagnosticLines(diagnostics)) {
7970
+ if (line.severity === "error" && !options.errorsAsWarnings) {
7971
+ log.error(line.text);
7972
+ } else {
7973
+ log.warn(line.text);
7974
+ }
7975
+ }
7976
+ }
7977
+ var init_diagnostics = __esm({
7978
+ "src/launcher/diagnostics.ts"() {
7979
+ "use strict";
7980
+ init_decide();
7981
+ }
7982
+ });
7983
+
7875
7984
  // src/antigravity/cloudUpstream.ts
7876
7985
  var init_cloudUpstream = __esm({
7877
7986
  "src/antigravity/cloudUpstream.ts"() {
@@ -8032,6 +8141,49 @@ var init_translate2 = __esm({
8032
8141
  }
8033
8142
  });
8034
8143
 
8144
+ // src/providerCatalogue.ts
8145
+ function catalogueCachePath(paths, name) {
8146
+ return import_node_path38.default.join(paths.catalogueDir, `${name}.json`);
8147
+ }
8148
+ function parseCatalogueCache(text) {
8149
+ if (text === void 0) {
8150
+ return void 0;
8151
+ }
8152
+ try {
8153
+ const parsed = CatalogueCacheSchema.safeParse(JSON.parse(text));
8154
+ return parsed.success ? parsed.data : void 0;
8155
+ } catch {
8156
+ return void 0;
8157
+ }
8158
+ }
8159
+ function filterCatalogue(models, catalogue) {
8160
+ const included = catalogue.include === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.include, { dot: true });
8161
+ const excluded = catalogue.exclude === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.exclude, { dot: true });
8162
+ return models.filter((model) => included?.(model.id) !== false && excluded?.(model.id) !== true);
8163
+ }
8164
+ var import_node_path38, import_picomatch4, import_zod30, DEFAULT_CANDIDATE_URLS, MS_PER_SECOND7, SECONDS_PER_HOUR2, HOURS_PER_DAY5, MS_PER_HOUR5, HOURS_BETWEEN_RETRIES, CATALOGUE_MAX_AGE_MS, CATALOGUE_RETRY_MS, CATALOGUE_REQUEST_SECONDS, CATALOGUE_REQUEST_TIMEOUT_MS, CATALOGUE_REFRESH_TIMEOUT_MS, CatalogueModelSchema, CatalogueCacheSchema;
8165
+ var init_providerCatalogue = __esm({
8166
+ "src/providerCatalogue.ts"() {
8167
+ "use strict";
8168
+ import_node_path38 = __toESM(require("node:path"), 1);
8169
+ import_picomatch4 = __toESM(require("picomatch"), 1);
8170
+ import_zod30 = require("zod");
8171
+ DEFAULT_CANDIDATE_URLS = 2;
8172
+ MS_PER_SECOND7 = 1e3;
8173
+ SECONDS_PER_HOUR2 = 3600;
8174
+ HOURS_PER_DAY5 = 24;
8175
+ MS_PER_HOUR5 = SECONDS_PER_HOUR2 * MS_PER_SECOND7;
8176
+ HOURS_BETWEEN_RETRIES = 1;
8177
+ CATALOGUE_MAX_AGE_MS = HOURS_PER_DAY5 * MS_PER_HOUR5;
8178
+ CATALOGUE_RETRY_MS = HOURS_BETWEEN_RETRIES * MS_PER_HOUR5;
8179
+ CATALOGUE_REQUEST_SECONDS = 10;
8180
+ CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND7;
8181
+ CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
8182
+ CatalogueModelSchema = import_zod30.z.strictObject({ id: import_zod30.z.string().min(1), name: import_zod30.z.string().min(1).optional() });
8183
+ CatalogueCacheSchema = import_zod30.z.strictObject({ fetchedAt: import_zod30.z.number(), url: import_zod30.z.string().min(1), models: import_zod30.z.array(CatalogueModelSchema) });
8184
+ }
8185
+ });
8186
+
8035
8187
  // src/launcher/modelPicker.ts
8036
8188
  function labelOf(model) {
8037
8189
  return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? model.slice(0, -CONTEXT_MARKER_1M.length) : model;
@@ -8098,14 +8250,23 @@ function declaredRow(entry) {
8098
8250
  behavesAs: TIER_BEHAVES_AS[entry.tier]
8099
8251
  };
8100
8252
  }
8101
- function providerModelRows(provider) {
8253
+ function catalogueRows(provider, models) {
8254
+ if (provider.kind !== void 0 && provider.kind !== "http" || provider.catalogue === void 0) {
8255
+ return [];
8256
+ }
8257
+ const { tier } = provider.catalogue;
8258
+ return filterCatalogue(models, provider.catalogue).map((model) => ({ model: model.id, label: labelOf(model.id), description: describedAs(model.id, model.name === void 0 ? "Listed by the provider" : `Listed by the provider as ${model.name}`), behavesAs: TIER_BEHAVES_AS[tier] })).sort((left, right) => left.model.localeCompare(right.model));
8259
+ }
8260
+ function providerModelRows(provider, catalogue = []) {
8102
8261
  const derived = provider.kind === "codex" ? codexRows(provider) : provider.kind === "antigravity" ? antigravityRows(provider) : httpRows(provider);
8103
8262
  const declared = (provider.pickerModels ?? []).map(declaredRow);
8104
8263
  const declaredModels = new Set(declared.map((row) => row.model));
8105
- return [...derived.filter((row) => !declaredModels.has(row.model)), ...declared];
8264
+ const named = [...derived.filter((row) => !declaredModels.has(row.model)), ...declared];
8265
+ const taken = new Set(named.map((row) => labelOf(row.model)));
8266
+ return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
8106
8267
  }
8107
- function modelPickerSettings(provider) {
8108
- const options = providerModelRows(provider);
8268
+ function modelPickerSettings(provider, catalogue = []) {
8269
+ const options = providerModelRows(provider, catalogue);
8109
8270
  return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
8110
8271
  }
8111
8272
  var CONTEXT_MARKER_1M, TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
@@ -8114,6 +8275,7 @@ var init_modelPicker = __esm({
8114
8275
  "use strict";
8115
8276
  init_translate();
8116
8277
  init_translate2();
8278
+ init_providerCatalogue();
8117
8279
  init_schema();
8118
8280
  CONTEXT_MARKER_1M = "[1m]";
8119
8281
  TIER_BEHAVES_AS = Object.freeze({
@@ -8445,7 +8607,7 @@ function decideLaunch(params, readOnly) {
8445
8607
  identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
8446
8608
  globalDefaultConfigProfile: params.globalDefaultConfigProfile
8447
8609
  });
8448
- if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs13.readConfigFile(import_node_path38.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
8610
+ if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs13.readConfigFile(import_node_path39.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
8449
8611
  log.error(
8450
8612
  `agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
8451
8613
  );
@@ -8525,17 +8687,7 @@ function decideLaunch(params, readOnly) {
8525
8687
  const flattened = flattenLayers(assembled.layers, { home: params.farm.home });
8526
8688
  cascadeLaunch = flattened.launch;
8527
8689
  if (readOnly || farmContext === void 0) {
8528
- for (const diagnostic of [...assembled.diagnostics, ...flattened.diagnostics]) {
8529
- if (diagnostic.severity === "info") {
8530
- continue;
8531
- }
8532
- const message = `agent-shim: ${diagnostic.code}: ${diagnostic.message}`;
8533
- if (diagnostic.severity === "error" && !readOnly) {
8534
- log.error(message);
8535
- } else {
8536
- log.warn(message);
8537
- }
8538
- }
8690
+ reportDiagnostics(log, [...assembled.diagnostics, ...flattened.diagnostics], { errorsAsWarnings: readOnly });
8539
8691
  }
8540
8692
  }
8541
8693
  const pinnedVersion = resolveClaudeVersion({ env, ...parsedArgv.claudeVersion === void 0 ? {} : { flag: parsedArgv.claudeVersion }, ...cascadeLaunch?.claudeVersion === void 0 ? {} : { cascade: cascadeLaunch.claudeVersion } });
@@ -8555,7 +8707,8 @@ function decideLaunch(params, readOnly) {
8555
8707
  log.info(`agent-shim: identity ${loginlessProvider.identity} has no stored login, so Remote Control, which needs one, is off for this launch; provider ${loginlessProvider.provider} runs without it`);
8556
8708
  }
8557
8709
  const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
8558
- const pickerSettings = selectedProvider === void 0 ? void 0 : modelPickerSettings(selectedProvider.definition);
8710
+ const catalogue = selectedProvider === void 0 ? void 0 : parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, selectedProvider.name)));
8711
+ const pickerSettings = selectedProvider === void 0 ? void 0 : modelPickerSettings(selectedProvider.definition, catalogue?.models);
8559
8712
  const callerSettings = hasSettingsArgument(parsedArgv.rest);
8560
8713
  if (pickerSettings !== void 0 && callerSettings && !readOnly) {
8561
8714
  log.info("agent-shim: this launch passes its own --settings, so /model keeps Claude Code's own model names instead of listing the provider's models");
@@ -8566,7 +8719,7 @@ function decideLaunch(params, readOnly) {
8566
8719
  extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
8567
8720
  passthrough: withLauncherSettings(params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised), launcherSettings)
8568
8721
  });
8569
- const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path38.default.join(paths.identitiesDir, identityDecision.name);
8722
+ const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path39.default.join(paths.identitiesDir, identityDecision.name);
8570
8723
  const decision = {
8571
8724
  identitySource: identityDecision.source,
8572
8725
  configDirEscapeHatch: identityDecision.configDirEscapeHatch,
@@ -8607,7 +8760,7 @@ function prepareLaunch(params) {
8607
8760
  );
8608
8761
  const updateCheck = runLaunchUpdateCheck({
8609
8762
  mode: params.updateMode ?? "off",
8610
- checkPath: import_node_path38.default.join(paths.root, "update.check"),
8763
+ checkPath: import_node_path39.default.join(paths.root, "update.check"),
8611
8764
  currentVersion: package_default.version,
8612
8765
  port: params.update
8613
8766
  });
@@ -8639,16 +8792,12 @@ function prepareLaunch(params) {
8639
8792
  }
8640
8793
  throw error;
8641
8794
  }
8642
- for (const diagnostic of result.diagnostics) {
8643
- if (diagnostic.severity === "error") {
8644
- log.error(`agent-shim: ${diagnostic.code}: ${diagnostic.message}`);
8645
- } else if (diagnostic.severity === "warning") {
8646
- log.warn(`agent-shim: ${diagnostic.code}: ${diagnostic.message}`);
8647
- }
8795
+ reportDiagnostics(log, result.diagnostics, { errorsAsWarnings: false });
8796
+ if (!result.noOp) {
8797
+ log.info(
8798
+ `agent-shim: farm at ${result.farmRoot} resynced (${String(result.manifest.links.length)} link(s), ${String(result.manifest.materialised.length)} built director(ies)${result.adopted.length === 0 ? "" : `, ${String(result.adopted.length)} adopted into ${resyncFarmRuntime.claudeHome}`})`
8799
+ );
8648
8800
  }
8649
- log.info(
8650
- result.noOp ? `agent-shim: farm at ${result.farmRoot} already matches the resolved cascade` : `agent-shim: farm at ${result.farmRoot} resynced (${String(result.manifest.links.length)} link(s), ${String(result.manifest.materialised.length)} built director(ies)${result.adopted.length === 0 ? "" : `, ${String(result.adopted.length)} adopted into ${resyncFarmRuntime.claudeHome}`})`
8651
- );
8652
8801
  }
8653
8802
  if (decided.pinnedVersion !== void 0) {
8654
8803
  log.info(`agent-shim: Claude Code ${decided.pinnedVersion.version} (pinned by ${decided.pinnedVersion.source})`);
@@ -8741,12 +8890,12 @@ function runLaunchPlan(plan, spawn3) {
8741
8890
  function runLauncher(params) {
8742
8891
  params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
8743
8892
  }
8744
- var import_node_crypto11, import_node_path38;
8893
+ var import_node_crypto11, import_node_path39;
8745
8894
  var init_launcher = __esm({
8746
8895
  "src/launcher.ts"() {
8747
8896
  "use strict";
8748
8897
  import_node_crypto11 = require("node:crypto");
8749
- import_node_path38 = __toESM(require("node:path"), 1);
8898
+ import_node_path39 = __toESM(require("node:path"), 1);
8750
8899
  init_package();
8751
8900
  init_envBool();
8752
8901
  init_argv();
@@ -8757,7 +8906,9 @@ var init_launcher = __esm({
8757
8906
  init_flags();
8758
8907
  init_extraFlags();
8759
8908
  init_claudeSession();
8909
+ init_diagnostics();
8760
8910
  init_modelPicker();
8911
+ init_providerCatalogue();
8761
8912
  init_pool();
8762
8913
  init_resumeContext();
8763
8914
  init_lock();
@@ -8780,13 +8931,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
8780
8931
  if (distDir === void 0) {
8781
8932
  throw new OwnCliPathUnknownError();
8782
8933
  }
8783
- return import_node_path39.default.join(distDir, OWN_CLI_FILE_NAME);
8934
+ return import_node_path40.default.join(distDir, OWN_CLI_FILE_NAME);
8784
8935
  }
8785
- var import_node_path39, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
8936
+ var import_node_path40, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
8786
8937
  var init_ownCli = __esm({
8787
8938
  "src/ownCli.ts"() {
8788
8939
  "use strict";
8789
- import_node_path39 = __toESM(require("node:path"), 1);
8940
+ import_node_path40 = __toESM(require("node:path"), 1);
8790
8941
  init_cliError();
8791
8942
  OWN_CLI_FILE_NAME = "cli.cjs";
8792
8943
  OwnCliPathUnknownError = class extends CliError {
@@ -8812,7 +8963,7 @@ var init_selfIdentity = __esm({
8812
8963
  // src/frontdoor/trust.ts
8813
8964
  function resolveTrustBundle(params) {
8814
8965
  const { caCertFile, bundlesDir, variable, inherited, fs: fs13 } = params;
8815
- if (inherited === void 0 || inherited === "" || import_node_path40.default.resolve(inherited) === import_node_path40.default.resolve(caCertFile)) {
8966
+ if (inherited === void 0 || inherited === "" || import_node_path41.default.resolve(inherited) === import_node_path41.default.resolve(caCertFile)) {
8816
8967
  return { path: caCertFile };
8817
8968
  }
8818
8969
  const caPem = fs13.readFileUtf8(caCertFile);
@@ -8830,19 +8981,19 @@ function resolveTrustBundle(params) {
8830
8981
  }
8831
8982
  const combined = `${inheritedPem.trimEnd()}
8832
8983
  ${caPem}`;
8833
- const bundle = import_node_path40.default.join(bundlesDir, `${(0, import_node_crypto12.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
8984
+ const bundle = import_node_path41.default.join(bundlesDir, `${(0, import_node_crypto12.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
8834
8985
  if (!fs13.exists(bundle)) {
8835
8986
  fs13.mkdirp(bundlesDir);
8836
8987
  fs13.writeFileAtomic(bundle, combined);
8837
8988
  }
8838
8989
  return { path: bundle };
8839
8990
  }
8840
- var import_node_crypto12, import_node_path40, BUNDLE_NAME_HEX_DIGITS;
8991
+ var import_node_crypto12, import_node_path41, BUNDLE_NAME_HEX_DIGITS;
8841
8992
  var init_trust = __esm({
8842
8993
  "src/frontdoor/trust.ts"() {
8843
8994
  "use strict";
8844
8995
  import_node_crypto12 = require("node:crypto");
8845
- import_node_path40 = __toESM(require("node:path"), 1);
8996
+ import_node_path41 = __toESM(require("node:path"), 1);
8846
8997
  BUNDLE_NAME_HEX_DIGITS = 16;
8847
8998
  }
8848
8999
  });
@@ -8961,7 +9112,7 @@ function realPrepareLaunchParams(paths, options) {
8961
9112
  headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
8962
9113
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
8963
9114
  credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
8964
- hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot: import_node_path41.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
9115
+ hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot: import_node_path42.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
8965
9116
  ...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
8966
9117
  ...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
8967
9118
  ...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
@@ -9018,12 +9169,12 @@ function resolveClaudeLaunch(options) {
9018
9169
  };
9019
9170
  return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, farm: buildFarmRuntime(paths, options.cwd) })), warnings };
9020
9171
  }
9021
- var import_node_os7, import_node_path41, import_node_crypto13, LaunchRefusedError;
9172
+ var import_node_os7, import_node_path42, import_node_crypto13, LaunchRefusedError;
9022
9173
  var init_launchWiring = __esm({
9023
9174
  "src/launchWiring.ts"() {
9024
9175
  "use strict";
9025
9176
  import_node_os7 = __toESM(require("node:os"), 1);
9026
- import_node_path41 = __toESM(require("node:path"), 1);
9177
+ import_node_path42 = __toESM(require("node:path"), 1);
9027
9178
  import_node_crypto13 = require("node:crypto");
9028
9179
  init_cliError();
9029
9180
  init_claudeShim();
@@ -9239,76 +9390,76 @@ var init_identityClaude = __esm({
9239
9390
  });
9240
9391
 
9241
9392
  // src/usage/providerQuota.ts
9242
- var import_zod30, MS_PER_SECOND7, SECONDS_PER_HOUR2, HOURS_PER_DAY5, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
9393
+ var import_zod31, MS_PER_SECOND8, SECONDS_PER_HOUR3, HOURS_PER_DAY6, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
9243
9394
  var init_providerQuota = __esm({
9244
9395
  "src/usage/providerQuota.ts"() {
9245
9396
  "use strict";
9246
- import_zod30 = require("zod");
9397
+ import_zod31 = require("zod");
9247
9398
  init_cloudUpstream();
9248
9399
  init_schema2();
9249
- MS_PER_SECOND7 = 1e3;
9250
- SECONDS_PER_HOUR2 = 3600;
9251
- HOURS_PER_DAY5 = 24;
9400
+ MS_PER_SECOND8 = 1e3;
9401
+ SECONDS_PER_HOUR3 = 3600;
9402
+ HOURS_PER_DAY6 = 24;
9252
9403
  DAYS_PER_MONTH = 30;
9253
9404
  ZAI_HOST = "api.z.ai";
9254
9405
  ZAI_QUOTA_URL = `https://${ZAI_HOST}/api/monitor/usage/quota/limit`;
9255
9406
  ZAI_UNIT_HOURS = 3;
9256
9407
  ZAI_UNIT_MONTHS = 5;
9257
9408
  ZAI_UNIT_MS = /* @__PURE__ */ new Map([
9258
- [ZAI_UNIT_HOURS, SECONDS_PER_HOUR2 * MS_PER_SECOND7],
9259
- [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7]
9409
+ [ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND8],
9410
+ [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8]
9260
9411
  ]);
9261
- ZaiLimitSchema = import_zod30.z.object({
9262
- type: import_zod30.z.string(),
9263
- unit: import_zod30.z.number().int(),
9264
- number: import_zod30.z.number().int().positive(),
9265
- percentage: import_zod30.z.number().nonnegative(),
9266
- nextResetTime: import_zod30.z.number().positive().optional(),
9267
- usage: import_zod30.z.number().nonnegative().optional(),
9268
- currentValue: import_zod30.z.number().nonnegative().optional(),
9269
- remaining: import_zod30.z.number().nonnegative().optional()
9412
+ ZaiLimitSchema = import_zod31.z.object({
9413
+ type: import_zod31.z.string(),
9414
+ unit: import_zod31.z.number().int(),
9415
+ number: import_zod31.z.number().int().positive(),
9416
+ percentage: import_zod31.z.number().nonnegative(),
9417
+ nextResetTime: import_zod31.z.number().positive().optional(),
9418
+ usage: import_zod31.z.number().nonnegative().optional(),
9419
+ currentValue: import_zod31.z.number().nonnegative().optional(),
9420
+ remaining: import_zod31.z.number().nonnegative().optional()
9270
9421
  });
9271
- ZaiResponseSchema = import_zod30.z.object({
9272
- success: import_zod30.z.boolean(),
9273
- msg: import_zod30.z.string().optional(),
9274
- data: import_zod30.z.object({ level: import_zod30.z.string().optional(), limits: import_zod30.z.array(ZaiLimitSchema) })
9422
+ ZaiResponseSchema = import_zod31.z.object({
9423
+ success: import_zod31.z.boolean(),
9424
+ msg: import_zod31.z.string().optional(),
9425
+ data: import_zod31.z.object({ level: import_zod31.z.string().optional(), limits: import_zod31.z.array(ZaiLimitSchema) })
9275
9426
  });
9276
9427
  OPENROUTER_HOST = "openrouter.ai";
9277
9428
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
9278
9429
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
9279
- MS_PER_DAY3 = HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9280
- OpenRouterKeySchema = import_zod30.z.object({
9281
- data: import_zod30.z.object({
9282
- limit: import_zod30.z.number().nonnegative().nullable(),
9283
- limit_remaining: import_zod30.z.number().nullable(),
9284
- limit_reset: import_zod30.z.string().nullable(),
9285
- is_free_tier: import_zod30.z.boolean().optional(),
9286
- free_model_daily_requests: import_zod30.z.object({ used: import_zod30.z.number().nonnegative(), limit: import_zod30.z.number().nonnegative(), remaining: import_zod30.z.number() }).optional()
9430
+ MS_PER_DAY3 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
9431
+ OpenRouterKeySchema = import_zod31.z.object({
9432
+ data: import_zod31.z.object({
9433
+ limit: import_zod31.z.number().nonnegative().nullable(),
9434
+ limit_remaining: import_zod31.z.number().nullable(),
9435
+ limit_reset: import_zod31.z.string().nullable(),
9436
+ is_free_tier: import_zod31.z.boolean().optional(),
9437
+ free_model_daily_requests: import_zod31.z.object({ used: import_zod31.z.number().nonnegative(), limit: import_zod31.z.number().nonnegative(), remaining: import_zod31.z.number() }).optional()
9287
9438
  })
9288
9439
  });
9289
- OpenRouterCreditsSchema = import_zod30.z.object({ data: import_zod30.z.object({ total_credits: import_zod30.z.number().nonnegative(), total_usage: import_zod30.z.number().nonnegative() }) });
9440
+ OpenRouterCreditsSchema = import_zod31.z.object({ data: import_zod31.z.object({ total_credits: import_zod31.z.number().nonnegative(), total_usage: import_zod31.z.number().nonnegative() }) });
9290
9441
  ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
9291
9442
  ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
9292
9443
  ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
9293
9444
  FIVE_HOURS2 = 5;
9294
9445
  DAYS_PER_WEEK2 = 7;
9295
- FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9296
- WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9297
- AntigravityBucketSchema = import_zod30.z.object({
9298
- bucketId: import_zod30.z.string(),
9299
- remainingFraction: import_zod30.z.number().optional(),
9300
- resetTime: import_zod30.z.string().optional()
9446
+ FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
9447
+ WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
9448
+ AntigravityBucketSchema = import_zod31.z.object({
9449
+ bucketId: import_zod31.z.string(),
9450
+ remainingFraction: import_zod31.z.number().optional(),
9451
+ resetTime: import_zod31.z.string().optional()
9301
9452
  });
9302
- AntigravitySummarySchema = import_zod30.z.object({ groups: import_zod30.z.array(import_zod30.z.object({ buckets: import_zod30.z.array(AntigravityBucketSchema) })) });
9303
- GoogleTokenInfoSchema = import_zod30.z.object({
9304
- email: import_zod30.z.string().optional(),
9305
- sub: import_zod30.z.string().optional()
9453
+ AntigravitySummarySchema = import_zod31.z.object({ groups: import_zod31.z.array(import_zod31.z.object({ buckets: import_zod31.z.array(AntigravityBucketSchema) })) });
9454
+ GoogleTokenInfoSchema = import_zod31.z.object({
9455
+ email: import_zod31.z.string().optional(),
9456
+ sub: import_zod31.z.string().optional()
9306
9457
  });
9307
- AntigravityUserSchema = import_zod30.z.object({
9458
+ AntigravityUserSchema = import_zod31.z.object({
9308
9459
  /** The code-assist tier context, which defaults to the free tier for every account. */
9309
- currentTier: import_zod30.z.object({ name: import_zod30.z.string().optional(), id: import_zod30.z.string().optional() }).optional(),
9460
+ currentTier: import_zod31.z.object({ name: import_zod31.z.string().optional(), id: import_zod31.z.string().optional() }).optional(),
9310
9461
  /** The account's paid subscription; absent when the account has none. */
9311
- paidTier: import_zod30.z.object({ name: import_zod30.z.string().optional(), id: import_zod30.z.string().optional() }).optional()
9462
+ paidTier: import_zod31.z.object({ name: import_zod31.z.string().optional(), id: import_zod31.z.string().optional() }).optional()
9312
9463
  });
9313
9464
  }
9314
9465
  });
@@ -10321,8 +10472,8 @@ function parseConnectTarget(authority) {
10321
10472
  function isInterceptedHost(host, interceptHosts) {
10322
10473
  return interceptHosts.includes(host);
10323
10474
  }
10324
- function servedByPipeline(path42) {
10325
- return path42?.startsWith(ROUTED_PATH_PREFIX) === true;
10475
+ function servedByPipeline(path43) {
10476
+ return path43?.startsWith(ROUTED_PATH_PREFIX) === true;
10326
10477
  }
10327
10478
  var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
10328
10479
  "connection",
@@ -11116,11 +11267,11 @@ function createRcSessionTracker(deps) {
11116
11267
  };
11117
11268
  const observeExchange = (request4) => {
11118
11269
  const method = (request4.method ?? "").toUpperCase();
11119
- const path42 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
11120
- if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
11270
+ const path43 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
11271
+ if (!path43.startsWith(RC_SESSIONS_PATH_PREFIX)) {
11121
11272
  return void 0;
11122
11273
  }
11123
- const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
11274
+ const tail = path43.slice(RC_SESSIONS_PATH_PREFIX.length);
11124
11275
  const facts = {
11125
11276
  oauthAuthorization: oauthAuthorizationOf(request4.headers),
11126
11277
  anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
@@ -11510,8 +11661,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
11510
11661
  function isRcReadFileEncoding(value) {
11511
11662
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
11512
11663
  }
11513
- function buildRcReadFilePayload(requestId, path42, options) {
11514
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path42, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
11664
+ function buildRcReadFilePayload(requestId, path43, options) {
11665
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path43, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
11515
11666
  }
11516
11667
  function buildRcFileSuggestionsPayload(requestId, query) {
11517
11668
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -11613,15 +11764,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
11613
11764
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
11614
11765
  return result.ok ? { ...result, requestId } : result;
11615
11766
  }
11616
- async function readRcSessionFile(deps, sessionId, path42, options) {
11617
- if (path42 === "") {
11767
+ async function readRcSessionFile(deps, sessionId, path43, options) {
11768
+ if (path43 === "") {
11618
11769
  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" };
11619
11770
  }
11620
11771
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
11621
11772
  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" };
11622
11773
  }
11623
11774
  const requestId = deps.newUuid();
11624
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path42, options), `read ${path42} from session ${sessionId}`);
11775
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path43, options), `read ${path43} from session ${sessionId}`);
11625
11776
  return result.ok ? { ...result, requestId } : result;
11626
11777
  }
11627
11778
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -11790,11 +11941,11 @@ function createRcControlHandler(deps) {
11790
11941
  path: "read-file",
11791
11942
  read: (body) => {
11792
11943
  const session = bodyString(body, "session");
11793
- const path42 = bodyString(body, "path");
11944
+ const path43 = bodyString(body, "path");
11794
11945
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
11795
11946
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
11796
- const refused2 = session === void 0 || path42 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
11797
- 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, path42, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
11947
+ const refused2 = session === void 0 || path43 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
11948
+ 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, path43, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
11798
11949
  }
11799
11950
  },
11800
11951
  {
@@ -12104,9 +12255,9 @@ function requestIdOfBody(body) {
12104
12255
  }
12105
12256
  function frontDoorRcControl(transport, token) {
12106
12257
  const headers = { authorization: `Bearer ${token}` };
12107
- const listAnswerOf = async (path42, what) => {
12258
+ const listAnswerOf = async (path43, what) => {
12108
12259
  try {
12109
- return await transport.request({ method: "GET", path: path42, headers });
12260
+ return await transport.request({ method: "GET", path: path43, headers });
12110
12261
  } catch (error) {
12111
12262
  throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
12112
12263
  }
@@ -12178,10 +12329,10 @@ function frontDoorRcControl(transport, token) {
12178
12329
  }
12179
12330
  return pending;
12180
12331
  };
12181
- const writeOf = async (path42, body, describeFailure2) => {
12332
+ const writeOf = async (path43, body, describeFailure2) => {
12182
12333
  let answer;
12183
12334
  try {
12184
- answer = await transport.request({ method: "POST", path: path42, headers: { ...headers, "content-type": "application/json" }, body });
12335
+ answer = await transport.request({ method: "POST", path: path43, headers: { ...headers, "content-type": "application/json" }, body });
12185
12336
  } catch (error) {
12186
12337
  return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
12187
12338
  }
@@ -12212,10 +12363,10 @@ function frontDoorRcControl(transport, token) {
12212
12363
  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}`),
12213
12364
  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}`),
12214
12365
  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}`),
12215
- readFile: async (sessionId, path42, options) => await writeOf(
12366
+ readFile: async (sessionId, path43, options) => await writeOf(
12216
12367
  `${CONTROL_PATH_PREFIX}/read-file`,
12217
- JSON.stringify({ session: sessionId, path: path42, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
12218
- (status, message) => `reading ${path42} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
12368
+ JSON.stringify({ session: sessionId, path: path43, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
12369
+ (status, message) => `reading ${path43} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
12219
12370
  ),
12220
12371
  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}`),
12221
12372
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -12374,12 +12525,12 @@ function tlsFacts(options) {
12374
12525
  }
12375
12526
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
12376
12527
  const agent = new ExemptTlsAgent();
12377
- const post = async (path42, headers, body) => await new Promise((resolve, reject) => {
12528
+ const post = async (path43, headers, body) => await new Promise((resolve, reject) => {
12378
12529
  const options = {
12379
12530
  host: target.host,
12380
12531
  port: target.port,
12381
12532
  method: "POST",
12382
- path: path42,
12533
+ path: path43,
12383
12534
  // 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.
12384
12535
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
12385
12536
  agent
@@ -12444,12 +12595,12 @@ function lateRcStreamDial(resolve) {
12444
12595
  }
12445
12596
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
12446
12597
  const agent = new ExemptTlsAgent();
12447
- const request4 = async (method, path42, headers, body, signal) => await new Promise((resolve, reject) => {
12598
+ const request4 = async (method, path43, headers, body, signal) => await new Promise((resolve, reject) => {
12448
12599
  const options = {
12449
12600
  host: target.host,
12450
12601
  port: target.port,
12451
12602
  method,
12452
- path: path42,
12603
+ path: path43,
12453
12604
  // 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.
12454
12605
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
12455
12606
  agent,
@@ -12491,9 +12642,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
12491
12642
  return { status, body: await readAll(response) };
12492
12643
  },
12493
12644
  openStream: async (sessionId, headers, resume, signal) => {
12494
- const path42 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
12645
+ const path43 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
12495
12646
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
12496
- const { status, response } = await request4("GET", path42, streamHeaders, void 0, signal);
12647
+ const { status, response } = await request4("GET", path43, streamHeaders, void 0, signal);
12497
12648
  if (!isSuccessful2(status)) {
12498
12649
  await readAll(response);
12499
12650
  return { status, chunks: NO_CHUNKS };
@@ -13645,19 +13796,19 @@ function writePools(paths, pools) {
13645
13796
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
13646
13797
  }
13647
13798
  function poolCycleOf(pools, name) {
13648
- const walk = (current, path42) => {
13799
+ const walk = (current, path43) => {
13649
13800
  for (const entry of pools[current]?.identities ?? []) {
13650
13801
  const nested = poolNameOf(poolMemberIdentity(entry));
13651
13802
  if (nested === void 0) {
13652
13803
  continue;
13653
13804
  }
13654
13805
  if (nested === name) {
13655
- return [...path42, nested];
13806
+ return [...path43, nested];
13656
13807
  }
13657
- if (path42.includes(nested)) {
13808
+ if (path43.includes(nested)) {
13658
13809
  continue;
13659
13810
  }
13660
- const found = walk(nested, [...path42, nested]);
13811
+ const found = walk(nested, [...path43, nested]);
13661
13812
  if (found !== void 0) {
13662
13813
  return found;
13663
13814
  }
@@ -15936,7 +16087,7 @@ function profileValue(name, paths) {
15936
16087
  function createConfigApiRouter(deps) {
15937
16088
  const authed = doorApiAuth(deps.expectedToken);
15938
16089
  const { paths } = deps;
15939
- const route = (path42, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path42, summary, tags: [CONFIG_API_TAG] }));
16090
+ const route = (path43, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path43, summary, tags: [CONFIG_API_TAG] }));
15940
16091
  return {
15941
16092
  config: {
15942
16093
  identity: {