claude-use 11.24.0 → 11.26.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
@@ -242,7 +242,7 @@ function isTimeZone(name) {
242
242
  return false;
243
243
  }
244
244
  }
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, ANTIGRAVITY_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_TIERS, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, 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;
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, 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
246
  var init_schema = __esm({
247
247
  "src/config/schema.ts"() {
248
248
  "use strict";
@@ -343,7 +343,7 @@ var init_schema = __esm({
343
343
  });
344
344
  PROVIDER_KINDS = ["http", "codex", "antigravity"];
345
345
  ANTIGRAVITY_MODES = ["cloud", "local"];
346
- ANTIGRAVITY_TIERS = ["fable", "opus", "sonnet", "haiku"];
346
+ CLAUDE_TIERS = ["fable", "opus", "sonnet", "haiku"];
347
347
  ANTIGRAVITY_EFFORTS = ["none", "low", "medium", "high", "xhigh", "max"];
348
348
  ANTIGRAVITY_DEFAULT_MODE = "cloud";
349
349
  ANTIGRAVITY_DEFAULT_MODEL = "gemini-3.8-flash-high";
@@ -360,7 +360,7 @@ var init_schema = __esm({
360
360
  mode: import_zod.z.enum(ANTIGRAVITY_MODES).optional(),
361
361
  /** The model a request maps to when no tier matches its model name. */
362
362
  defaultModel: import_zod.z.string().min(1).optional(),
363
- /** Model name mapping. A key naming a tier (`fable`, `opus`, `sonnet`, `haiku`) overrides that tier's shipped model and is matched by substring of the requested name in `ANTIGRAVITY_TIERS` order; any other key is an alias, matched against the whole requested name case-insensitively, so `/model <alias>` selects its backend model. An alias outranks every other rule, including the pass-through of backend names. A value is one model or an ordered list of candidates: the request goes to the first whose quota windows are not spent, and when every candidate is spent, to the one whose binding window lifts soonest. */
363
+ /** Model name mapping. A key naming a tier (`fable`, `opus`, `sonnet`, `haiku`) overrides that tier's shipped model and is matched by substring of the requested name in `CLAUDE_TIERS` order; any other key is an alias, matched against the whole requested name case-insensitively, so `/model <alias>` selects its backend model. An alias outranks every other rule, including the pass-through of backend names. A value is one model or an ordered list of candidates: the request goes to the first whose quota windows are not spent, and when every candidate is spent, to the one whose binding window lifts soonest. */
364
364
  models: import_zod.z.record(import_zod.z.string().min(1), AntigravityModelTargetSchema).optional(),
365
365
  /** When every candidate of the tier a request names has no quota left, serve it from the next tier down, and onward through the lower tiers, instead of failing with the quota limit. Applies to a name that selects a tier (`/model fable`), not to an alias or a backend model name. Defaults to false. */
366
366
  degradeDownTiers: import_zod.z.boolean().optional(),
@@ -383,7 +383,6 @@ var init_schema = __esm({
383
383
  socketPath: import_zod.z.string().min(1).optional()
384
384
  }).optional()
385
385
  });
386
- CODEX_TIERS = ["fable", "opus", "sonnet", "haiku"];
387
386
  CODEX_EFFORTS = ["none", "low", "medium", "high"];
388
387
  CODEX_LOGINS = ["codex-cli", "chatgpt-sign-in"];
389
388
  CODEX_DEFAULT_LOGIN = "codex-cli";
@@ -398,7 +397,7 @@ var init_schema = __esm({
398
397
  CodexProviderConfigSchema = import_zod.z.strictObject({
399
398
  /** The codex model a request maps to when no tier matches its model name. */
400
399
  defaultModel: import_zod.z.string().min(1).optional(),
401
- /** Per-tier overrides of the shipped mapping, matched by substring of the requested model name in `CODEX_TIERS` order. */
400
+ /** Per-tier overrides of the shipped mapping, matched by substring of the requested model name in `CLAUDE_TIERS` order. */
402
401
  models: import_zod.z.strictObject({
403
402
  fable: import_zod.z.string().min(1).optional(),
404
403
  opus: import_zod.z.string().min(1).optional(),
@@ -418,6 +417,19 @@ var init_schema = __esm({
418
417
  /** The model name to rewrite the request to before it reaches the target, for a provider that expects another form (OpenRouter's `anthropic/claude-...` for instance). A route that rewrites reads the whole body, the one copy the rewrite needs. */
419
418
  model: import_zod.z.string().min(1).optional()
420
419
  });
420
+ PickerModelSchema = import_zod.z.strictObject({
421
+ model: import_zod.z.string().min(1),
422
+ tier: import_zod.z.enum(CLAUDE_TIERS),
423
+ label: import_zod.z.string().min(1).optional(),
424
+ description: import_zod.z.string().min(1).optional()
425
+ });
426
+ 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" });
427
+ ProviderCatalogueSchema = import_zod.z.strictObject({
428
+ tier: import_zod.z.enum(CLAUDE_TIERS),
429
+ include: import_zod.z.array(import_zod.z.string().min(1)).min(1).optional(),
430
+ exclude: import_zod.z.array(import_zod.z.string().min(1)).min(1).optional(),
431
+ url: import_zod.z.url().optional()
432
+ });
421
433
  HttpProviderSchema = import_zod.z.strictObject({
422
434
  $schema: import_zod.z.string().optional(),
423
435
  kind: import_zod.z.literal("http").optional(),
@@ -425,6 +437,10 @@ var init_schema = __esm({
425
437
  baseUrl: import_zod.z.url(),
426
438
  credential: ProviderCredentialSchema,
427
439
  env: ProviderEnvSchema.optional(),
440
+ /** Extra models `/model` lists beside the ones the tier settings name. */
441
+ pickerModels: PickerModelsSchema.optional(),
442
+ /** The provider's own model catalogue, listed in `/model` when set. */
443
+ catalogue: ProviderCatalogueSchema.optional(),
428
444
  /** 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. */
429
445
  routes: import_zod.z.array(ProviderRouteSchema).optional()
430
446
  });
@@ -434,6 +450,8 @@ var init_schema = __esm({
434
450
  displayName: import_zod.z.string().min(1),
435
451
  credential: ProviderCredentialSchema,
436
452
  env: ProviderEnvSchema.optional(),
453
+ /** Extra models `/model` lists beside the ones the tier settings name. */
454
+ pickerModels: PickerModelsSchema.optional(),
437
455
  codex: CodexProviderConfigSchema.optional()
438
456
  });
439
457
  AntigravityProviderSchema = import_zod.z.strictObject({
@@ -442,6 +460,8 @@ var init_schema = __esm({
442
460
  displayName: import_zod.z.string().min(1),
443
461
  credential: ProviderCredentialSchema,
444
462
  env: ProviderEnvSchema.optional(),
463
+ /** Extra models `/model` lists beside the ones the tier settings name. */
464
+ pickerModels: PickerModelsSchema.optional(),
445
465
  antigravity: AntigravityProviderConfigSchema.optional()
446
466
  });
447
467
  ProviderSchema = import_zod.z.discriminatedUnion("kind", [HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema]);
@@ -631,7 +651,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
631
651
  return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
632
652
  }
633
653
  function describeIgnoredKeys(filePath, ignored) {
634
- const places = ignored.map(({ path: path42, keys }) => `${path42.length === 0 ? "" : `${path42.map(String).join(".")}.`}${keys.join(", ")}`);
654
+ const places = ignored.map(({ path: path43, keys }) => `${path43.length === 0 ? "" : `${path43.map(String).join(".")}.`}${keys.join(", ")}`);
635
655
  return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
636
656
  }
637
657
  function noteIgnoredKeys(filePath, ignored) {
@@ -653,9 +673,9 @@ function restoreIgnoredKeys(filePath, value) {
653
673
  return value;
654
674
  }
655
675
  const restored = structuredClone(value);
656
- for (const { path: path42, values } of ignored) {
676
+ for (const { path: path43, values } of ignored) {
657
677
  let holder = restored;
658
- for (const step of path42) {
678
+ for (const step of path43) {
659
679
  holder = isRecord(holder) ? holder[step] : void 0;
660
680
  }
661
681
  if (isRecord(holder)) {
@@ -2935,7 +2955,7 @@ var init_package = __esm({
2935
2955
  "package.json"() {
2936
2956
  package_default = {
2937
2957
  name: "claude-use",
2938
- version: "11.24.0",
2958
+ version: "11.26.0",
2939
2959
  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.",
2940
2960
  license: "MIT",
2941
2961
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -6043,6 +6063,7 @@ function buildLayoutPaths(root) {
6043
6063
  usageDir: import_node_path23.default.join(root, "usage"),
6044
6064
  usageLogDir: import_node_path23.default.join(root, "usage", "log"),
6045
6065
  usageSnapshotsDir: import_node_path23.default.join(root, "usage", "snapshots"),
6066
+ catalogueDir: import_node_path23.default.join(root, "catalogues"),
6046
6067
  usagePicksFile: import_node_path23.default.join(root, "usage", "picks.json"),
6047
6068
  usageAnchorsFile: import_node_path23.default.join(root, "usage", "anchors.json"),
6048
6069
  usageJobsFile: import_node_path23.default.join(root, "usage", "jobs.json"),
@@ -6489,7 +6510,10 @@ function loadProvider(providersDir, name, port) {
6489
6510
  const raw = port.readConfigFile(filePath);
6490
6511
  return raw === void 0 ? void 0 : parseProviderFile(filePath, raw);
6491
6512
  }
6492
- function listProviders(paths) {
6513
+ function reportInvalidProvider(name, message) {
6514
+ console.error(`agent-shim: providers/${name}.json is invalid and was skipped: ${message}`);
6515
+ }
6516
+ function listProviders(paths, onInvalid = reportInvalidProvider) {
6493
6517
  const names = listProviderNames(
6494
6518
  (dir) => import_node_fs6.default.readdirSync(dir),
6495
6519
  paths.providersDir
@@ -6503,7 +6527,7 @@ function listProviders(paths) {
6503
6527
  if (!(error instanceof ConfigValidationError || error instanceof LegacyProviderFileError)) {
6504
6528
  throw error;
6505
6529
  }
6506
- console.error(`agent-shim: providers/${name}.json is invalid and was skipped: ${error.message}`);
6530
+ onInvalid(name, error.message);
6507
6531
  continue;
6508
6532
  }
6509
6533
  if (provider !== void 0) {
@@ -6553,6 +6577,9 @@ function addProvider(paths, name, input) {
6553
6577
  if (kind === "http" && input.baseUrl === void 0) {
6554
6578
  throw new ProviderKindMismatchError("An http provider needs --base-url.");
6555
6579
  }
6580
+ if (kind !== "http" && input.catalogue !== void 0) {
6581
+ throw new ProviderKindMismatchError("A model catalogue applies only to an http provider.");
6582
+ }
6556
6583
  if (kind !== "codex" && !isEmptyCodexConfig(input.codex)) {
6557
6584
  throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
6558
6585
  }
@@ -6562,10 +6589,11 @@ function addProvider(paths, name, input) {
6562
6589
  const shared = {
6563
6590
  displayName: input.displayName,
6564
6591
  credential: { sources: input.sources, ...input.target === void 0 ? {} : { target: input.target } },
6565
- ...input.env === void 0 || Object.keys(input.env).length === 0 ? {} : { env: input.env }
6592
+ ...input.env === void 0 || Object.keys(input.env).length === 0 ? {} : { env: input.env },
6593
+ ...input.pickerModels === void 0 || input.pickerModels.length === 0 ? {} : { pickerModels: input.pickerModels }
6566
6594
  };
6567
6595
  const parsed = ProviderSchema.safeParse(
6568
- kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input.codex) ? {} : { codex: input.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input.antigravity) ? {} : { antigravity: input.antigravity } } : { ...shared, baseUrl: input.baseUrl }
6596
+ 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 } }
6569
6597
  );
6570
6598
  if (!parsed.success) {
6571
6599
  throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
@@ -6580,6 +6608,12 @@ function updateProvider(paths, name, input) {
6580
6608
  }
6581
6609
  const unset = new Set(input.unsetEnv);
6582
6610
  const env = Object.fromEntries(Object.entries({ ...existing.env, ...input.env }).filter(([key]) => !unset.has(key)));
6611
+ const unsetPicker = new Set(input.unsetPickerModels);
6612
+ const added = new Map((input.pickerModels ?? []).map((entry) => [entry.model, entry]));
6613
+ const pickerModels = [
6614
+ ...(existing.pickerModels ?? []).filter((entry) => !unsetPicker.has(entry.model)).map((entry) => added.get(entry.model) ?? entry),
6615
+ ...[...added.values()].filter((entry) => !(existing.pickerModels ?? []).some((kept) => kept.model === entry.model))
6616
+ ];
6583
6617
  const target = input.target ?? existing.credential.target;
6584
6618
  const cache = input.cache === void 0 ? existing.credential.cache : input.cache === false ? void 0 : input.cache;
6585
6619
  if (isCodexProvider(existing) && input.baseUrl !== void 0) {
@@ -6588,6 +6622,9 @@ function updateProvider(paths, name, input) {
6588
6622
  if (isAntigravityProvider(existing) && input.baseUrl !== void 0) {
6589
6623
  throw new ProviderKindMismatchError(`Provider "${name}" is an antigravity provider, which has no base URL.`);
6590
6624
  }
6625
+ if ((isCodexProvider(existing) || isAntigravityProvider(existing)) && input.catalogue !== void 0 && input.catalogue !== false) {
6626
+ throw new ProviderKindMismatchError(`Provider "${name}" is not an http provider; a model catalogue applies only to an http provider.`);
6627
+ }
6591
6628
  if (!isCodexProvider(existing) && !isEmptyCodexConfig(input.codex)) {
6592
6629
  throw new ProviderKindMismatchError(`Provider "${name}" is not a codex provider; codex settings apply only to a codex provider.`);
6593
6630
  }
@@ -6601,7 +6638,8 @@ function updateProvider(paths, name, input) {
6601
6638
  ...target === void 0 ? {} : { target },
6602
6639
  ...cache === void 0 ? {} : { cache }
6603
6640
  },
6604
- env: Object.keys(env).length === 0 ? void 0 : env
6641
+ env: Object.keys(env).length === 0 ? void 0 : env,
6642
+ pickerModels: pickerModels.length === 0 ? void 0 : pickerModels
6605
6643
  };
6606
6644
  let candidate;
6607
6645
  if (isCodexProvider(existing)) {
@@ -6619,7 +6657,8 @@ function updateProvider(paths, name, input) {
6619
6657
  };
6620
6658
  candidate = { ...existing, ...shared, antigravity: isEmptyAntigravityConfig(antigravity) ? void 0 : antigravity };
6621
6659
  } else {
6622
- candidate = { ...existing, ...shared, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
6660
+ const catalogue = input.catalogue === void 0 ? existing.catalogue : input.catalogue === false ? void 0 : input.catalogue;
6661
+ candidate = { ...existing, ...shared, catalogue, ...input.baseUrl === void 0 ? {} : { baseUrl: input.baseUrl } };
6623
6662
  }
6624
6663
  const parsed = ProviderSchema.safeParse(candidate);
6625
6664
  if (!parsed.success) {
@@ -7947,7 +7986,7 @@ function candidatesOf(target) {
7947
7986
  return typeof target === "string" ? [target] : target;
7948
7987
  }
7949
7988
  function isAntigravityTier(key) {
7950
- return ANTIGRAVITY_TIERS.some((tier) => tier === key);
7989
+ return CLAUDE_TIERS.some((tier) => tier === key);
7951
7990
  }
7952
7991
  function resolveAntigravityConfig(config) {
7953
7992
  const overrides = config?.models ?? {};
@@ -8012,7 +8051,56 @@ var init_translate2 = __esm({
8012
8051
  }
8013
8052
  });
8014
8053
 
8054
+ // src/providerCatalogue.ts
8055
+ function catalogueCachePath(paths, name) {
8056
+ return import_node_path38.default.join(paths.catalogueDir, `${name}.json`);
8057
+ }
8058
+ function parseCatalogueCache(text) {
8059
+ if (text === void 0) {
8060
+ return void 0;
8061
+ }
8062
+ try {
8063
+ const parsed = CatalogueCacheSchema.safeParse(JSON.parse(text));
8064
+ return parsed.success ? parsed.data : void 0;
8065
+ } catch {
8066
+ return void 0;
8067
+ }
8068
+ }
8069
+ function filterCatalogue(models, catalogue) {
8070
+ const included = catalogue.include === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.include, { dot: true });
8071
+ const excluded = catalogue.exclude === void 0 ? void 0 : (0, import_picomatch4.default)(catalogue.exclude, { dot: true });
8072
+ return models.filter((model) => included?.(model.id) !== false && excluded?.(model.id) !== true);
8073
+ }
8074
+ 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;
8075
+ var init_providerCatalogue = __esm({
8076
+ "src/providerCatalogue.ts"() {
8077
+ "use strict";
8078
+ import_node_path38 = __toESM(require("node:path"), 1);
8079
+ import_picomatch4 = __toESM(require("picomatch"), 1);
8080
+ import_zod30 = require("zod");
8081
+ DEFAULT_CANDIDATE_URLS = 2;
8082
+ MS_PER_SECOND7 = 1e3;
8083
+ SECONDS_PER_HOUR2 = 3600;
8084
+ HOURS_PER_DAY5 = 24;
8085
+ MS_PER_HOUR5 = SECONDS_PER_HOUR2 * MS_PER_SECOND7;
8086
+ HOURS_BETWEEN_RETRIES = 1;
8087
+ CATALOGUE_MAX_AGE_MS = HOURS_PER_DAY5 * MS_PER_HOUR5;
8088
+ CATALOGUE_RETRY_MS = HOURS_BETWEEN_RETRIES * MS_PER_HOUR5;
8089
+ CATALOGUE_REQUEST_SECONDS = 10;
8090
+ CATALOGUE_REQUEST_TIMEOUT_MS = CATALOGUE_REQUEST_SECONDS * MS_PER_SECOND7;
8091
+ CATALOGUE_REFRESH_TIMEOUT_MS = DEFAULT_CANDIDATE_URLS * CATALOGUE_REQUEST_TIMEOUT_MS;
8092
+ CatalogueModelSchema = import_zod30.z.strictObject({ id: import_zod30.z.string().min(1), name: import_zod30.z.string().min(1).optional() });
8093
+ CatalogueCacheSchema = import_zod30.z.strictObject({ fetchedAt: import_zod30.z.number(), url: import_zod30.z.string().min(1), models: import_zod30.z.array(CatalogueModelSchema) });
8094
+ }
8095
+ });
8096
+
8015
8097
  // src/launcher/modelPicker.ts
8098
+ function labelOf(model) {
8099
+ return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? model.slice(0, -CONTEXT_MARKER_1M.length) : model;
8100
+ }
8101
+ function describedAs(model, description) {
8102
+ return model.toLowerCase().endsWith(CONTEXT_MARKER_1M) ? `${description}; 1M context` : description;
8103
+ }
8016
8104
  function joined(parts) {
8017
8105
  const last = parts[parts.length - 1];
8018
8106
  return last === void 0 || parts.length === 1 ? last ?? "" : `${parts.slice(0, -1).join(", ")} and ${last}`;
@@ -8026,7 +8114,7 @@ function rowOf2(model, reaches) {
8026
8114
  const fallbacks = reaches.filter((reach) => reach.standing === "fallback").map((reach) => reach.tier);
8027
8115
  const serves = firsts.length === 0 ? [] : [`Serves the ${joined(firsts)} tier${firsts.length === 1 ? "" : "s"}`];
8028
8116
  const falls = fallbacks.length === 0 ? [] : [`${serves.length === 0 ? "Fallback" : "fallback"} for ${joined(fallbacks)}`];
8029
- return { model, label: model, description: [...serves, ...falls].join("; "), behavesAs: TIER_BEHAVES_AS[lead.tier] };
8117
+ return { model, label: labelOf(model), description: describedAs(model, [...serves, ...falls].join("; ")), behavesAs: TIER_BEHAVES_AS[lead.tier] };
8030
8118
  }
8031
8119
  function rowsOfTable(table) {
8032
8120
  const reachesByModel = /* @__PURE__ */ new Map();
@@ -8043,47 +8131,63 @@ function rowsOfTable(table) {
8043
8131
  }
8044
8132
  function antigravityRows(provider) {
8045
8133
  const config = resolveAntigravityConfig(provider.antigravity);
8046
- const tiers = rowsOfTable(ANTIGRAVITY_TIERS.map((tier) => [tier, config.models[tier]]));
8134
+ const tiers = rowsOfTable(CLAUDE_TIERS.map((tier) => [tier, config.models[tier]]));
8047
8135
  const behavesAsOf = new Map(tiers.map((row) => [row.model, row.behavesAs]));
8048
8136
  const aliases = [...config.aliases].flatMap(([alias, candidates]) => {
8049
8137
  const [first] = candidates;
8050
8138
  const behavesAs = first === void 0 ? void 0 : behavesAsOf.get(first);
8051
- return behavesAs === void 0 ? [] : [{ model: alias, label: alias, description: `Alias for ${candidates.join(", then ")}`, behavesAs }];
8139
+ return behavesAs === void 0 ? [] : [{ model: alias, label: labelOf(alias), description: `Alias for ${candidates.join(", then ")}`, behavesAs }];
8052
8140
  });
8053
8141
  return [...tiers, ...aliases];
8054
8142
  }
8055
8143
  function codexRows(provider) {
8056
8144
  const config = resolveCodexConfig(provider.codex);
8057
- return rowsOfTable(CODEX_TIERS.map((tier) => [tier, [config.models[tier]]]));
8145
+ return rowsOfTable(CLAUDE_TIERS.map((tier) => [tier, [config.models[tier]]]));
8058
8146
  }
8059
8147
  function httpRows(provider) {
8060
8148
  const env = provider.env ?? {};
8061
- const table = CODEX_TIERS.flatMap((tier) => {
8149
+ const table = CLAUDE_TIERS.flatMap((tier) => {
8062
8150
  const model = env[TIER_ENV_VARIABLES[tier]];
8063
8151
  return model === void 0 || model === "" ? [] : [[tier, [model]]];
8064
8152
  });
8065
8153
  return rowsOfTable(table);
8066
8154
  }
8067
- function providerModelRows(provider) {
8068
- if (provider.kind === "codex") {
8069
- return codexRows(provider);
8070
- }
8071
- if (provider.kind === "antigravity") {
8072
- return antigravityRows(provider);
8155
+ function declaredRow(entry) {
8156
+ return {
8157
+ model: entry.model,
8158
+ label: entry.label ?? labelOf(entry.model),
8159
+ description: entry.description ?? describedAs(entry.model, `Declared by the provider for the ${entry.tier} tier`),
8160
+ behavesAs: TIER_BEHAVES_AS[entry.tier]
8161
+ };
8162
+ }
8163
+ function catalogueRows(provider, models) {
8164
+ if (provider.kind !== void 0 && provider.kind !== "http" || provider.catalogue === void 0) {
8165
+ return [];
8073
8166
  }
8074
- return httpRows(provider);
8167
+ const { tier } = provider.catalogue;
8168
+ 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));
8169
+ }
8170
+ function providerModelRows(provider, catalogue = []) {
8171
+ const derived = provider.kind === "codex" ? codexRows(provider) : provider.kind === "antigravity" ? antigravityRows(provider) : httpRows(provider);
8172
+ const declared = (provider.pickerModels ?? []).map(declaredRow);
8173
+ const declaredModels = new Set(declared.map((row) => row.model));
8174
+ const named = [...derived.filter((row) => !declaredModels.has(row.model)), ...declared];
8175
+ const taken = new Set(named.map((row) => labelOf(row.model)));
8176
+ return [...named, ...catalogueRows(provider, catalogue).filter((row) => !taken.has(labelOf(row.model)))];
8075
8177
  }
8076
- function modelPickerSettings(provider) {
8077
- const options = providerModelRows(provider);
8178
+ function modelPickerSettings(provider, catalogue = []) {
8179
+ const options = providerModelRows(provider, catalogue);
8078
8180
  return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
8079
8181
  }
8080
- var TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
8182
+ var CONTEXT_MARKER_1M, TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
8081
8183
  var init_modelPicker = __esm({
8082
8184
  "src/launcher/modelPicker.ts"() {
8083
8185
  "use strict";
8084
8186
  init_translate();
8085
8187
  init_translate2();
8188
+ init_providerCatalogue();
8086
8189
  init_schema();
8190
+ CONTEXT_MARKER_1M = "[1m]";
8087
8191
  TIER_BEHAVES_AS = Object.freeze({
8088
8192
  fable: "claude-fable-5-1",
8089
8193
  opus: "claude-opus-5-5",
@@ -8413,7 +8517,7 @@ function decideLaunch(params, readOnly) {
8413
8517
  identityDefaultConfigProfile: loadedIdentity?.config.defaultConfigProfile,
8414
8518
  globalDefaultConfigProfile: params.globalDefaultConfigProfile
8415
8519
  });
8416
- if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs13.readConfigFile(import_node_path38.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
8520
+ if (configProfileDecision.name !== void 0 && params.allowMissingConfigProfile !== true && fs13.readConfigFile(import_node_path39.default.join(paths.configProfilesDir, `${configProfileDecision.name}.json`)) === void 0) {
8417
8521
  log.error(
8418
8522
  `agent-shim: no configuration profile named "${configProfileDecision.name}" (selected via ${configProfileDecision.source}). Run \`agent-shim profile add ${configProfileDecision.name}\` first.`
8419
8523
  );
@@ -8523,7 +8627,8 @@ function decideLaunch(params, readOnly) {
8523
8627
  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`);
8524
8628
  }
8525
8629
  const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
8526
- const pickerSettings = selectedProvider === void 0 ? void 0 : modelPickerSettings(selectedProvider.definition);
8630
+ const catalogue = selectedProvider === void 0 ? void 0 : parseCatalogueCache(params.fs.readFileUtf8(catalogueCachePath(paths, selectedProvider.name)));
8631
+ const pickerSettings = selectedProvider === void 0 ? void 0 : modelPickerSettings(selectedProvider.definition, catalogue?.models);
8527
8632
  const callerSettings = hasSettingsArgument(parsedArgv.rest);
8528
8633
  if (pickerSettings !== void 0 && callerSettings && !readOnly) {
8529
8634
  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");
@@ -8534,7 +8639,7 @@ function decideLaunch(params, readOnly) {
8534
8639
  extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
8535
8640
  passthrough: withLauncherSettings(params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised), launcherSettings)
8536
8641
  });
8537
- const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path38.default.join(paths.identitiesDir, identityDecision.name);
8642
+ const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path39.default.join(paths.identitiesDir, identityDecision.name);
8538
8643
  const decision = {
8539
8644
  identitySource: identityDecision.source,
8540
8645
  configDirEscapeHatch: identityDecision.configDirEscapeHatch,
@@ -8575,7 +8680,7 @@ function prepareLaunch(params) {
8575
8680
  );
8576
8681
  const updateCheck = runLaunchUpdateCheck({
8577
8682
  mode: params.updateMode ?? "off",
8578
- checkPath: import_node_path38.default.join(paths.root, "update.check"),
8683
+ checkPath: import_node_path39.default.join(paths.root, "update.check"),
8579
8684
  currentVersion: package_default.version,
8580
8685
  port: params.update
8581
8686
  });
@@ -8709,12 +8814,12 @@ function runLaunchPlan(plan, spawn3) {
8709
8814
  function runLauncher(params) {
8710
8815
  params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
8711
8816
  }
8712
- var import_node_crypto11, import_node_path38;
8817
+ var import_node_crypto11, import_node_path39;
8713
8818
  var init_launcher = __esm({
8714
8819
  "src/launcher.ts"() {
8715
8820
  "use strict";
8716
8821
  import_node_crypto11 = require("node:crypto");
8717
- import_node_path38 = __toESM(require("node:path"), 1);
8822
+ import_node_path39 = __toESM(require("node:path"), 1);
8718
8823
  init_package();
8719
8824
  init_envBool();
8720
8825
  init_argv();
@@ -8726,6 +8831,7 @@ var init_launcher = __esm({
8726
8831
  init_extraFlags();
8727
8832
  init_claudeSession();
8728
8833
  init_modelPicker();
8834
+ init_providerCatalogue();
8729
8835
  init_pool();
8730
8836
  init_resumeContext();
8731
8837
  init_lock();
@@ -8748,13 +8854,13 @@ function agentShimCliPath(distDir = typeof __AGENT_SHIM_DIST_DIR__ === "string"
8748
8854
  if (distDir === void 0) {
8749
8855
  throw new OwnCliPathUnknownError();
8750
8856
  }
8751
- return import_node_path39.default.join(distDir, OWN_CLI_FILE_NAME);
8857
+ return import_node_path40.default.join(distDir, OWN_CLI_FILE_NAME);
8752
8858
  }
8753
- var import_node_path39, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
8859
+ var import_node_path40, OWN_CLI_FILE_NAME, OwnCliPathUnknownError;
8754
8860
  var init_ownCli = __esm({
8755
8861
  "src/ownCli.ts"() {
8756
8862
  "use strict";
8757
- import_node_path39 = __toESM(require("node:path"), 1);
8863
+ import_node_path40 = __toESM(require("node:path"), 1);
8758
8864
  init_cliError();
8759
8865
  OWN_CLI_FILE_NAME = "cli.cjs";
8760
8866
  OwnCliPathUnknownError = class extends CliError {
@@ -8780,7 +8886,7 @@ var init_selfIdentity = __esm({
8780
8886
  // src/frontdoor/trust.ts
8781
8887
  function resolveTrustBundle(params) {
8782
8888
  const { caCertFile, bundlesDir, variable, inherited, fs: fs13 } = params;
8783
- if (inherited === void 0 || inherited === "" || import_node_path40.default.resolve(inherited) === import_node_path40.default.resolve(caCertFile)) {
8889
+ if (inherited === void 0 || inherited === "" || import_node_path41.default.resolve(inherited) === import_node_path41.default.resolve(caCertFile)) {
8784
8890
  return { path: caCertFile };
8785
8891
  }
8786
8892
  const caPem = fs13.readFileUtf8(caCertFile);
@@ -8798,19 +8904,19 @@ function resolveTrustBundle(params) {
8798
8904
  }
8799
8905
  const combined = `${inheritedPem.trimEnd()}
8800
8906
  ${caPem}`;
8801
- 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`);
8907
+ 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`);
8802
8908
  if (!fs13.exists(bundle)) {
8803
8909
  fs13.mkdirp(bundlesDir);
8804
8910
  fs13.writeFileAtomic(bundle, combined);
8805
8911
  }
8806
8912
  return { path: bundle };
8807
8913
  }
8808
- var import_node_crypto12, import_node_path40, BUNDLE_NAME_HEX_DIGITS;
8914
+ var import_node_crypto12, import_node_path41, BUNDLE_NAME_HEX_DIGITS;
8809
8915
  var init_trust = __esm({
8810
8916
  "src/frontdoor/trust.ts"() {
8811
8917
  "use strict";
8812
8918
  import_node_crypto12 = require("node:crypto");
8813
- import_node_path40 = __toESM(require("node:path"), 1);
8919
+ import_node_path41 = __toESM(require("node:path"), 1);
8814
8920
  BUNDLE_NAME_HEX_DIGITS = 16;
8815
8921
  }
8816
8922
  });
@@ -8929,7 +9035,7 @@ function realPrepareLaunchParams(paths, options) {
8929
9035
  headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
8930
9036
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
8931
9037
  credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
8932
- hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot: import_node_path41.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
9038
+ hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot: import_node_path42.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
8933
9039
  ...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
8934
9040
  ...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
8935
9041
  ...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
@@ -8986,12 +9092,12 @@ function resolveClaudeLaunch(options) {
8986
9092
  };
8987
9093
  return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, farm: buildFarmRuntime(paths, options.cwd) })), warnings };
8988
9094
  }
8989
- var import_node_os7, import_node_path41, import_node_crypto13, LaunchRefusedError;
9095
+ var import_node_os7, import_node_path42, import_node_crypto13, LaunchRefusedError;
8990
9096
  var init_launchWiring = __esm({
8991
9097
  "src/launchWiring.ts"() {
8992
9098
  "use strict";
8993
9099
  import_node_os7 = __toESM(require("node:os"), 1);
8994
- import_node_path41 = __toESM(require("node:path"), 1);
9100
+ import_node_path42 = __toESM(require("node:path"), 1);
8995
9101
  import_node_crypto13 = require("node:crypto");
8996
9102
  init_cliError();
8997
9103
  init_claudeShim();
@@ -9207,76 +9313,76 @@ var init_identityClaude = __esm({
9207
9313
  });
9208
9314
 
9209
9315
  // src/usage/providerQuota.ts
9210
- 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;
9316
+ 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;
9211
9317
  var init_providerQuota = __esm({
9212
9318
  "src/usage/providerQuota.ts"() {
9213
9319
  "use strict";
9214
- import_zod30 = require("zod");
9320
+ import_zod31 = require("zod");
9215
9321
  init_cloudUpstream();
9216
9322
  init_schema2();
9217
- MS_PER_SECOND7 = 1e3;
9218
- SECONDS_PER_HOUR2 = 3600;
9219
- HOURS_PER_DAY5 = 24;
9323
+ MS_PER_SECOND8 = 1e3;
9324
+ SECONDS_PER_HOUR3 = 3600;
9325
+ HOURS_PER_DAY6 = 24;
9220
9326
  DAYS_PER_MONTH = 30;
9221
9327
  ZAI_HOST = "api.z.ai";
9222
9328
  ZAI_QUOTA_URL = `https://${ZAI_HOST}/api/monitor/usage/quota/limit`;
9223
9329
  ZAI_UNIT_HOURS = 3;
9224
9330
  ZAI_UNIT_MONTHS = 5;
9225
9331
  ZAI_UNIT_MS = /* @__PURE__ */ new Map([
9226
- [ZAI_UNIT_HOURS, SECONDS_PER_HOUR2 * MS_PER_SECOND7],
9227
- [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7]
9332
+ [ZAI_UNIT_HOURS, SECONDS_PER_HOUR3 * MS_PER_SECOND8],
9333
+ [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8]
9228
9334
  ]);
9229
- ZaiLimitSchema = import_zod30.z.object({
9230
- type: import_zod30.z.string(),
9231
- unit: import_zod30.z.number().int(),
9232
- number: import_zod30.z.number().int().positive(),
9233
- percentage: import_zod30.z.number().nonnegative(),
9234
- nextResetTime: import_zod30.z.number().positive().optional(),
9235
- usage: import_zod30.z.number().nonnegative().optional(),
9236
- currentValue: import_zod30.z.number().nonnegative().optional(),
9237
- remaining: import_zod30.z.number().nonnegative().optional()
9335
+ ZaiLimitSchema = import_zod31.z.object({
9336
+ type: import_zod31.z.string(),
9337
+ unit: import_zod31.z.number().int(),
9338
+ number: import_zod31.z.number().int().positive(),
9339
+ percentage: import_zod31.z.number().nonnegative(),
9340
+ nextResetTime: import_zod31.z.number().positive().optional(),
9341
+ usage: import_zod31.z.number().nonnegative().optional(),
9342
+ currentValue: import_zod31.z.number().nonnegative().optional(),
9343
+ remaining: import_zod31.z.number().nonnegative().optional()
9238
9344
  });
9239
- ZaiResponseSchema = import_zod30.z.object({
9240
- success: import_zod30.z.boolean(),
9241
- msg: import_zod30.z.string().optional(),
9242
- data: import_zod30.z.object({ level: import_zod30.z.string().optional(), limits: import_zod30.z.array(ZaiLimitSchema) })
9345
+ ZaiResponseSchema = import_zod31.z.object({
9346
+ success: import_zod31.z.boolean(),
9347
+ msg: import_zod31.z.string().optional(),
9348
+ data: import_zod31.z.object({ level: import_zod31.z.string().optional(), limits: import_zod31.z.array(ZaiLimitSchema) })
9243
9349
  });
9244
9350
  OPENROUTER_HOST = "openrouter.ai";
9245
9351
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
9246
9352
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
9247
- MS_PER_DAY3 = HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9248
- OpenRouterKeySchema = import_zod30.z.object({
9249
- data: import_zod30.z.object({
9250
- limit: import_zod30.z.number().nonnegative().nullable(),
9251
- limit_remaining: import_zod30.z.number().nullable(),
9252
- limit_reset: import_zod30.z.string().nullable(),
9253
- is_free_tier: import_zod30.z.boolean().optional(),
9254
- 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()
9353
+ MS_PER_DAY3 = HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
9354
+ OpenRouterKeySchema = import_zod31.z.object({
9355
+ data: import_zod31.z.object({
9356
+ limit: import_zod31.z.number().nonnegative().nullable(),
9357
+ limit_remaining: import_zod31.z.number().nullable(),
9358
+ limit_reset: import_zod31.z.string().nullable(),
9359
+ is_free_tier: import_zod31.z.boolean().optional(),
9360
+ 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()
9255
9361
  })
9256
9362
  });
9257
- OpenRouterCreditsSchema = import_zod30.z.object({ data: import_zod30.z.object({ total_credits: import_zod30.z.number().nonnegative(), total_usage: import_zod30.z.number().nonnegative() }) });
9363
+ OpenRouterCreditsSchema = import_zod31.z.object({ data: import_zod31.z.object({ total_credits: import_zod31.z.number().nonnegative(), total_usage: import_zod31.z.number().nonnegative() }) });
9258
9364
  ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
9259
9365
  ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
9260
9366
  ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
9261
9367
  FIVE_HOURS2 = 5;
9262
9368
  DAYS_PER_WEEK2 = 7;
9263
- FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9264
- WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9265
- AntigravityBucketSchema = import_zod30.z.object({
9266
- bucketId: import_zod30.z.string(),
9267
- remainingFraction: import_zod30.z.number().optional(),
9268
- resetTime: import_zod30.z.string().optional()
9369
+ FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
9370
+ WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY6 * SECONDS_PER_HOUR3 * MS_PER_SECOND8;
9371
+ AntigravityBucketSchema = import_zod31.z.object({
9372
+ bucketId: import_zod31.z.string(),
9373
+ remainingFraction: import_zod31.z.number().optional(),
9374
+ resetTime: import_zod31.z.string().optional()
9269
9375
  });
9270
- AntigravitySummarySchema = import_zod30.z.object({ groups: import_zod30.z.array(import_zod30.z.object({ buckets: import_zod30.z.array(AntigravityBucketSchema) })) });
9271
- GoogleTokenInfoSchema = import_zod30.z.object({
9272
- email: import_zod30.z.string().optional(),
9273
- sub: import_zod30.z.string().optional()
9376
+ AntigravitySummarySchema = import_zod31.z.object({ groups: import_zod31.z.array(import_zod31.z.object({ buckets: import_zod31.z.array(AntigravityBucketSchema) })) });
9377
+ GoogleTokenInfoSchema = import_zod31.z.object({
9378
+ email: import_zod31.z.string().optional(),
9379
+ sub: import_zod31.z.string().optional()
9274
9380
  });
9275
- AntigravityUserSchema = import_zod30.z.object({
9381
+ AntigravityUserSchema = import_zod31.z.object({
9276
9382
  /** The code-assist tier context, which defaults to the free tier for every account. */
9277
- currentTier: import_zod30.z.object({ name: import_zod30.z.string().optional(), id: import_zod30.z.string().optional() }).optional(),
9383
+ currentTier: import_zod31.z.object({ name: import_zod31.z.string().optional(), id: import_zod31.z.string().optional() }).optional(),
9278
9384
  /** The account's paid subscription; absent when the account has none. */
9279
- paidTier: import_zod30.z.object({ name: import_zod30.z.string().optional(), id: import_zod30.z.string().optional() }).optional()
9385
+ paidTier: import_zod31.z.object({ name: import_zod31.z.string().optional(), id: import_zod31.z.string().optional() }).optional()
9280
9386
  });
9281
9387
  }
9282
9388
  });
@@ -10289,8 +10395,8 @@ function parseConnectTarget(authority) {
10289
10395
  function isInterceptedHost(host, interceptHosts) {
10290
10396
  return interceptHosts.includes(host);
10291
10397
  }
10292
- function servedByPipeline(path42) {
10293
- return path42?.startsWith(ROUTED_PATH_PREFIX) === true;
10398
+ function servedByPipeline(path43) {
10399
+ return path43?.startsWith(ROUTED_PATH_PREFIX) === true;
10294
10400
  }
10295
10401
  var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
10296
10402
  "connection",
@@ -11084,11 +11190,11 @@ function createRcSessionTracker(deps) {
11084
11190
  };
11085
11191
  const observeExchange = (request4) => {
11086
11192
  const method = (request4.method ?? "").toUpperCase();
11087
- const path42 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
11088
- if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
11193
+ const path43 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
11194
+ if (!path43.startsWith(RC_SESSIONS_PATH_PREFIX)) {
11089
11195
  return void 0;
11090
11196
  }
11091
- const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
11197
+ const tail = path43.slice(RC_SESSIONS_PATH_PREFIX.length);
11092
11198
  const facts = {
11093
11199
  oauthAuthorization: oauthAuthorizationOf(request4.headers),
11094
11200
  anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
@@ -11478,8 +11584,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
11478
11584
  function isRcReadFileEncoding(value) {
11479
11585
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
11480
11586
  }
11481
- function buildRcReadFilePayload(requestId, path42, options) {
11482
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path42, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
11587
+ function buildRcReadFilePayload(requestId, path43, options) {
11588
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path43, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
11483
11589
  }
11484
11590
  function buildRcFileSuggestionsPayload(requestId, query) {
11485
11591
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -11581,15 +11687,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
11581
11687
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
11582
11688
  return result.ok ? { ...result, requestId } : result;
11583
11689
  }
11584
- async function readRcSessionFile(deps, sessionId, path42, options) {
11585
- if (path42 === "") {
11690
+ async function readRcSessionFile(deps, sessionId, path43, options) {
11691
+ if (path43 === "") {
11586
11692
  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" };
11587
11693
  }
11588
11694
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
11589
11695
  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" };
11590
11696
  }
11591
11697
  const requestId = deps.newUuid();
11592
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path42, options), `read ${path42} from session ${sessionId}`);
11698
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path43, options), `read ${path43} from session ${sessionId}`);
11593
11699
  return result.ok ? { ...result, requestId } : result;
11594
11700
  }
11595
11701
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -11758,11 +11864,11 @@ function createRcControlHandler(deps) {
11758
11864
  path: "read-file",
11759
11865
  read: (body) => {
11760
11866
  const session = bodyString(body, "session");
11761
- const path42 = bodyString(body, "path");
11867
+ const path43 = bodyString(body, "path");
11762
11868
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
11763
11869
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
11764
- const refused2 = session === void 0 || path42 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
11765
- 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 } }) };
11870
+ const refused2 = session === void 0 || path43 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
11871
+ 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 } }) };
11766
11872
  }
11767
11873
  },
11768
11874
  {
@@ -12072,9 +12178,9 @@ function requestIdOfBody(body) {
12072
12178
  }
12073
12179
  function frontDoorRcControl(transport, token) {
12074
12180
  const headers = { authorization: `Bearer ${token}` };
12075
- const listAnswerOf = async (path42, what) => {
12181
+ const listAnswerOf = async (path43, what) => {
12076
12182
  try {
12077
- return await transport.request({ method: "GET", path: path42, headers });
12183
+ return await transport.request({ method: "GET", path: path43, headers });
12078
12184
  } catch (error) {
12079
12185
  throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
12080
12186
  }
@@ -12146,10 +12252,10 @@ function frontDoorRcControl(transport, token) {
12146
12252
  }
12147
12253
  return pending;
12148
12254
  };
12149
- const writeOf = async (path42, body, describeFailure2) => {
12255
+ const writeOf = async (path43, body, describeFailure2) => {
12150
12256
  let answer;
12151
12257
  try {
12152
- answer = await transport.request({ method: "POST", path: path42, headers: { ...headers, "content-type": "application/json" }, body });
12258
+ answer = await transport.request({ method: "POST", path: path43, headers: { ...headers, "content-type": "application/json" }, body });
12153
12259
  } catch (error) {
12154
12260
  return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
12155
12261
  }
@@ -12180,10 +12286,10 @@ function frontDoorRcControl(transport, token) {
12180
12286
  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}`),
12181
12287
  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}`),
12182
12288
  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}`),
12183
- readFile: async (sessionId, path42, options) => await writeOf(
12289
+ readFile: async (sessionId, path43, options) => await writeOf(
12184
12290
  `${CONTROL_PATH_PREFIX}/read-file`,
12185
- JSON.stringify({ session: sessionId, path: path42, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
12186
- (status, message) => `reading ${path42} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
12291
+ JSON.stringify({ session: sessionId, path: path43, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
12292
+ (status, message) => `reading ${path43} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
12187
12293
  ),
12188
12294
  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}`),
12189
12295
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -12342,12 +12448,12 @@ function tlsFacts(options) {
12342
12448
  }
12343
12449
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
12344
12450
  const agent = new ExemptTlsAgent();
12345
- const post = async (path42, headers, body) => await new Promise((resolve, reject) => {
12451
+ const post = async (path43, headers, body) => await new Promise((resolve, reject) => {
12346
12452
  const options = {
12347
12453
  host: target.host,
12348
12454
  port: target.port,
12349
12455
  method: "POST",
12350
- path: path42,
12456
+ path: path43,
12351
12457
  // 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.
12352
12458
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
12353
12459
  agent
@@ -12412,12 +12518,12 @@ function lateRcStreamDial(resolve) {
12412
12518
  }
12413
12519
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
12414
12520
  const agent = new ExemptTlsAgent();
12415
- const request4 = async (method, path42, headers, body, signal) => await new Promise((resolve, reject) => {
12521
+ const request4 = async (method, path43, headers, body, signal) => await new Promise((resolve, reject) => {
12416
12522
  const options = {
12417
12523
  host: target.host,
12418
12524
  port: target.port,
12419
12525
  method,
12420
- path: path42,
12526
+ path: path43,
12421
12527
  // 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.
12422
12528
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
12423
12529
  agent,
@@ -12459,9 +12565,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
12459
12565
  return { status, body: await readAll(response) };
12460
12566
  },
12461
12567
  openStream: async (sessionId, headers, resume, signal) => {
12462
- 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)}`;
12568
+ 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)}`;
12463
12569
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
12464
- const { status, response } = await request4("GET", path42, streamHeaders, void 0, signal);
12570
+ const { status, response } = await request4("GET", path43, streamHeaders, void 0, signal);
12465
12571
  if (!isSuccessful2(status)) {
12466
12572
  await readAll(response);
12467
12573
  return { status, chunks: NO_CHUNKS };
@@ -13613,19 +13719,19 @@ function writePools(paths, pools) {
13613
13719
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
13614
13720
  }
13615
13721
  function poolCycleOf(pools, name) {
13616
- const walk = (current, path42) => {
13722
+ const walk = (current, path43) => {
13617
13723
  for (const entry of pools[current]?.identities ?? []) {
13618
13724
  const nested = poolNameOf(poolMemberIdentity(entry));
13619
13725
  if (nested === void 0) {
13620
13726
  continue;
13621
13727
  }
13622
13728
  if (nested === name) {
13623
- return [...path42, nested];
13729
+ return [...path43, nested];
13624
13730
  }
13625
- if (path42.includes(nested)) {
13731
+ if (path43.includes(nested)) {
13626
13732
  continue;
13627
13733
  }
13628
- const found = walk(nested, [...path42, nested]);
13734
+ const found = walk(nested, [...path43, nested]);
13629
13735
  if (found !== void 0) {
13630
13736
  return found;
13631
13737
  }
@@ -15904,7 +16010,7 @@ function profileValue(name, paths) {
15904
16010
  function createConfigApiRouter(deps) {
15905
16011
  const authed = doorApiAuth(deps.expectedToken);
15906
16012
  const { paths } = deps;
15907
- const route = (path42, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path42, summary, tags: [CONFIG_API_TAG] }));
16013
+ const route = (path43, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path43, summary, tags: [CONFIG_API_TAG] }));
15908
16014
  return {
15909
16015
  config: {
15910
16016
  identity: {