claude-use 11.8.2 → 11.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -26886,9 +26886,15 @@ function expandAllCategoryKey(pairs) {
26886
26886
  const expanded = Object.fromEntries(OVERRIDABLE_CATEGORIES.filter((category) => !all2 || category !== "runtime").map((category) => [category, all2]));
26887
26887
  return { ...expanded, ...rest };
26888
26888
  }
26889
+ function isHttpProvider(provider) {
26890
+ return provider.kind === void 0 || provider.kind === "http";
26891
+ }
26889
26892
  function isCodexProvider(provider) {
26890
26893
  return provider.kind === "codex";
26891
26894
  }
26895
+ function isAntigravityProvider(provider) {
26896
+ return provider.kind === "antigravity";
26897
+ }
26892
26898
  function poolMemberIdentity(member) {
26893
26899
  return typeof member === "string" ? member : member.identity;
26894
26900
  }
@@ -26900,7 +26906,7 @@ function isTimeZone(name) {
26900
26906
  return false;
26901
26907
  }
26902
26908
  }
26903
- var import_node_path4, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, CODEX_TIERS, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, HttpProviderSchema, CodexProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
26909
+ var import_node_path4, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, ANTIGRAVITY_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, 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, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FRONTDOOR_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
26904
26910
  var init_schema = __esm({
26905
26911
  "src/config/schema.ts"() {
26906
26912
  "use strict";
@@ -26999,7 +27005,50 @@ var init_schema = __esm({
26999
27005
  ProviderEnvSchema = external_exports.record(external_exports.string().min(1), external_exports.string()).refine((env) => !Object.keys(env).some((key) => RESERVED_PROVIDER_ENV_KEYS.includes(key)), {
27000
27006
  message: `env may not set ${RESERVED_PROVIDER_ENV_KEYS.join(", ")}: the credential block's target sets one and agent-shim removes the others`
27001
27007
  });
27002
- PROVIDER_KINDS = ["http", "codex"];
27008
+ PROVIDER_KINDS = ["http", "codex", "antigravity"];
27009
+ ANTIGRAVITY_MODES = ["cloud", "local"];
27010
+ ANTIGRAVITY_TIERS = ["fable", "opus", "sonnet", "haiku"];
27011
+ ANTIGRAVITY_EFFORTS = ["none", "low", "medium", "high", "xhigh", "max"];
27012
+ ANTIGRAVITY_DEFAULT_MODE = "cloud";
27013
+ ANTIGRAVITY_DEFAULT_MODEL = "gemini-3.8-flash-high";
27014
+ ANTIGRAVITY_DEFAULT_TIER_MODELS = Object.freeze({
27015
+ fable: "gemini-3.8-flash-high",
27016
+ opus: "gemini-3.8-flash-high",
27017
+ sonnet: "gemini-3.8-flash-medium",
27018
+ haiku: "gemini-3.8-flash-low"
27019
+ });
27020
+ ANTIGRAVITY_DEFAULT_EFFORT = "low";
27021
+ AntigravityProviderConfigSchema = external_exports.strictObject({
27022
+ /** Operational mode: direct cloud endpoint or local ACP daemon. Defaults to `cloud`. */
27023
+ mode: external_exports.enum(ANTIGRAVITY_MODES).optional(),
27024
+ /** The model a request maps to when no tier matches its model name. */
27025
+ defaultModel: external_exports.string().min(1).optional(),
27026
+ /** Per-tier overrides of the shipped mapping, matched by substring of the requested model name in `ANTIGRAVITY_TIERS` order. */
27027
+ models: external_exports.strictObject({
27028
+ fable: external_exports.string().min(1).optional(),
27029
+ opus: external_exports.string().min(1).optional(),
27030
+ sonnet: external_exports.string().min(1).optional(),
27031
+ haiku: external_exports.string().min(1).optional()
27032
+ }).optional(),
27033
+ /** The reasoning effort used when the request's own effort is not one the backend accepts. */
27034
+ effort: external_exports.enum(ANTIGRAVITY_EFFORTS).optional(),
27035
+ /** Cloud-specific settings (for `mode: "cloud"`). */
27036
+ cloud: external_exports.strictObject({
27037
+ /** Google Gemini API or custom gateway endpoint. Defaults to `https://generativelanguage.googleapis.com`. */
27038
+ endpoint: external_exports.url().optional(),
27039
+ /** Google Cloud Project ID (when using Vertex AI). */
27040
+ projectId: external_exports.string().min(1).optional(),
27041
+ /** Google Cloud location/region (when using Vertex AI). */
27042
+ location: external_exports.string().min(1).optional()
27043
+ }).optional(),
27044
+ /** Local-specific settings (for `mode: "local"`). */
27045
+ local: external_exports.strictObject({
27046
+ /** Command and arguments to spawn the ACP server process. */
27047
+ command: external_exports.array(external_exports.string().min(1)).min(1).optional(),
27048
+ /** Path to an existing Unix domain socket to connect to instead of spawning a process. */
27049
+ socketPath: external_exports.string().min(1).optional()
27050
+ }).optional()
27051
+ });
27003
27052
  CODEX_TIERS = ["fable", "opus", "sonnet", "haiku"];
27004
27053
  CODEX_EFFORTS = ["none", "low", "medium", "high"];
27005
27054
  CODEX_LOGINS = ["codex-cli", "chatgpt-sign-in"];
@@ -27053,7 +27102,15 @@ var init_schema = __esm({
27053
27102
  env: ProviderEnvSchema.optional(),
27054
27103
  codex: CodexProviderConfigSchema.optional()
27055
27104
  });
27056
- ProviderSchema = external_exports.discriminatedUnion("kind", [HttpProviderSchema, CodexProviderSchema]);
27105
+ AntigravityProviderSchema = external_exports.strictObject({
27106
+ $schema: external_exports.string().optional(),
27107
+ kind: external_exports.literal("antigravity"),
27108
+ displayName: external_exports.string().min(1),
27109
+ credential: ProviderCredentialSchema,
27110
+ env: ProviderEnvSchema.optional(),
27111
+ antigravity: AntigravityProviderConfigSchema.optional()
27112
+ });
27113
+ ProviderSchema = external_exports.discriminatedUnion("kind", [HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema]);
27057
27114
  ConfigProfileSchema = external_exports.strictObject({
27058
27115
  $schema: external_exports.string().optional(),
27059
27116
  description: external_exports.string().optional(),
@@ -27616,7 +27673,7 @@ function daemonIdentity(commandLine, socketPath) {
27616
27673
  function earlierReleaseAllowlistHash(providers, doorOrigin) {
27617
27674
  const entries = /* @__PURE__ */ new Set([EARLIER_RELEASE_ANTHROPIC_UPSTREAM]);
27618
27675
  for (const provider of providers) {
27619
- if (!isCodexProvider(provider)) {
27676
+ if (isHttpProvider(provider)) {
27620
27677
  entries.add(provider.baseUrl);
27621
27678
  }
27622
27679
  }
@@ -33905,11 +33962,33 @@ function formatCredentialSummary(summary) {
33905
33962
  function describeCredential(credential) {
33906
33963
  return formatCredentialSummary(summariseCredential(credential));
33907
33964
  }
33965
+ function isRecord2(value2) {
33966
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
33967
+ }
33968
+ function unpackKeyringToken(raw) {
33969
+ const trimmed = raw.trim();
33970
+ if (!trimmed.startsWith(GO_KEYRING_BASE64_PREFIX)) {
33971
+ return trimmed;
33972
+ }
33973
+ try {
33974
+ const base64Str = trimmed.slice(GO_KEYRING_BASE64_PREFIX.length);
33975
+ const decoded = Buffer.from(base64Str, "base64").toString("utf8");
33976
+ const parsed = JSON.parse(decoded);
33977
+ if (isRecord2(parsed) && isRecord2(parsed.token)) {
33978
+ const accessToken = parsed.token.access_token;
33979
+ if (typeof accessToken === "string" && accessToken.trim() !== "") {
33980
+ return accessToken.trim();
33981
+ }
33982
+ }
33983
+ } catch {
33984
+ }
33985
+ return trimmed;
33986
+ }
33908
33987
  function trySource(source, params) {
33909
33988
  const none = (reason, warn = false) => ({ ok: false, reason, warn });
33910
33989
  if ("env" in source) {
33911
33990
  const value2 = params.env[source.env];
33912
- return value2 === void 0 || value2 === "" ? none("is unset or empty") : { ok: true, token: value2 };
33991
+ return value2 === void 0 || value2 === "" ? none("is unset or empty") : { ok: true, token: unpackKeyringToken(value2) };
33913
33992
  }
33914
33993
  if ("literal" in source) {
33915
33994
  return { ok: true, token: source.literal };
@@ -33925,7 +34004,7 @@ function trySource(source, params) {
33925
34004
  true
33926
34005
  );
33927
34006
  }
33928
- const token2 = read.content.trim();
34007
+ const token2 = unpackKeyringToken(read.content.trim());
33929
34008
  return token2 === "" ? none("is empty") : { ok: true, token: token2 };
33930
34009
  }
33931
34010
  const argv = commandArgv(source);
@@ -33943,7 +34022,7 @@ function trySource(source, params) {
33943
34022
  const outcome = result.status === null ? "could not be run or was killed by a signal" : `exited with status ${String(result.status)}`;
33944
34023
  return none(`${outcome}${stderr === "" ? "" : `: ${stderr}`}`);
33945
34024
  }
33946
- const token = result.stdout.trim();
34025
+ const token = unpackKeyringToken(result.stdout.trim());
33947
34026
  return token === "" ? none("printed no token") : { ok: true, token };
33948
34027
  }
33949
34028
  function warmCommandFor(subject) {
@@ -33987,7 +34066,7 @@ function credentialVariables(target, token) {
33987
34066
  CLAUDE_CODE_OAUTH_TOKEN: target === "oauthToken" ? token : void 0
33988
34067
  };
33989
34068
  }
33990
- var CREDENTIAL_UNAVAILABLE_EXIT, CREDENTIAL_COMMAND_TIMEOUT_MS, CREDENTIAL_INTERACTIVE_TIMEOUT_MS, GROUP_OTHER_PERMISSION_BITS, PERMISSION_BITS2, OCTAL_RADIX2;
34069
+ var CREDENTIAL_UNAVAILABLE_EXIT, CREDENTIAL_COMMAND_TIMEOUT_MS, CREDENTIAL_INTERACTIVE_TIMEOUT_MS, GROUP_OTHER_PERMISSION_BITS, PERMISSION_BITS2, OCTAL_RADIX2, GO_KEYRING_BASE64_PREFIX;
33991
34070
  var init_credential = __esm({
33992
34071
  "src/credential.ts"() {
33993
34072
  "use strict";
@@ -33998,6 +34077,7 @@ var init_credential = __esm({
33998
34077
  GROUP_OTHER_PERMISSION_BITS = 63;
33999
34078
  PERMISSION_BITS2 = 511;
34000
34079
  OCTAL_RADIX2 = 8;
34080
+ GO_KEYRING_BASE64_PREFIX = "go-keyring-base64:";
34001
34081
  }
34002
34082
  });
34003
34083
 
@@ -34007,7 +34087,7 @@ var init_package = __esm({
34007
34087
  "package.json"() {
34008
34088
  package_default = {
34009
34089
  name: "claude-use",
34010
- version: "11.8.2",
34090
+ version: "11.10.0",
34011
34091
  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.",
34012
34092
  license: "MIT",
34013
34093
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -35577,14 +35657,14 @@ function providerJsonPath(paths, name) {
35577
35657
  function providerExists(paths, name) {
35578
35658
  return import_node_fs10.default.existsSync(providerJsonPath(paths, name));
35579
35659
  }
35580
- function isRecord2(value2) {
35660
+ function isRecord3(value2) {
35581
35661
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
35582
35662
  }
35583
35663
  function legacyProviderConversion(raw) {
35584
- if (!isRecord2(raw) || "credential" in raw) {
35664
+ if (!isRecord3(raw) || "credential" in raw) {
35585
35665
  return void 0;
35586
35666
  }
35587
- const env = isRecord2(raw.env) ? raw.env : void 0;
35667
+ const env = isRecord3(raw.env) ? raw.env : void 0;
35588
35668
  const legacyEnvKeys = env === void 0 ? [] : Object.keys(env).filter((key) => LEGACY_ENV_CREDENTIAL_KEYS.includes(key));
35589
35669
  const fields = [...LEGACY_PROVIDER_FIELDS.filter((field) => field in raw), ...legacyEnvKeys.map((key) => `env.${key}`)];
35590
35670
  if (fields.length === 0) {
@@ -35669,11 +35749,20 @@ function listProviderNames(readdir, providersDir) {
35669
35749
  return entries.filter((entry) => entry.endsWith(".json")).map((entry) => entry.slice(0, -".json".length)).sort();
35670
35750
  }
35671
35751
  function describeProviderEndpoint(provider) {
35672
- return isCodexProvider(provider) ? "codex translation daemon" : provider.baseUrl;
35752
+ if (isCodexProvider(provider)) {
35753
+ return "codex translation daemon";
35754
+ }
35755
+ if (isAntigravityProvider(provider)) {
35756
+ return (provider.antigravity?.mode ?? ANTIGRAVITY_DEFAULT_MODE) === "local" ? "antigravity local (ACP daemon)" : "antigravity cloud (Gemini API)";
35757
+ }
35758
+ return provider.baseUrl;
35673
35759
  }
35674
35760
  function isEmptyCodexConfig(config2) {
35675
35761
  return config2 === void 0 || config2.defaultModel === void 0 && config2.effort === void 0 && config2.login === void 0 && (config2.models === void 0 || Object.keys(config2.models).length === 0);
35676
35762
  }
35763
+ function isEmptyAntigravityConfig(config2) {
35764
+ return config2 === void 0 || config2.mode === void 0 && config2.defaultModel === void 0 && config2.effort === void 0 && config2.cloud === void 0 && config2.local === void 0 && (config2.models === void 0 || Object.keys(config2.models).length === 0);
35765
+ }
35677
35766
  function addProvider(paths, name, input2) {
35678
35767
  if (providerExists(paths, name)) {
35679
35768
  throw new ProviderAlreadyExistsError(name);
@@ -35685,19 +35774,25 @@ function addProvider(paths, name, input2) {
35685
35774
  if (kind === "codex" && input2.baseUrl !== void 0) {
35686
35775
  throw new ProviderKindMismatchError("A codex provider has no base URL: the launcher points its sessions at the front-door daemon. Drop --base-url.");
35687
35776
  }
35777
+ if (kind === "antigravity" && input2.baseUrl !== void 0) {
35778
+ throw new ProviderKindMismatchError("An antigravity provider has no base URL: the launcher points its sessions at the front-door daemon. Drop --base-url.");
35779
+ }
35688
35780
  if (kind === "http" && input2.baseUrl === void 0) {
35689
35781
  throw new ProviderKindMismatchError("An http provider needs --base-url.");
35690
35782
  }
35691
- if (kind === "http" && !isEmptyCodexConfig(input2.codex)) {
35783
+ if (kind !== "codex" && !isEmptyCodexConfig(input2.codex)) {
35692
35784
  throw new ProviderKindMismatchError("Codex settings apply only to a codex provider (--kind codex).");
35693
35785
  }
35786
+ if (kind !== "antigravity" && !isEmptyAntigravityConfig(input2.antigravity)) {
35787
+ throw new ProviderKindMismatchError("Antigravity settings apply only to an antigravity provider (--kind antigravity).");
35788
+ }
35694
35789
  const shared = {
35695
35790
  displayName: input2.displayName,
35696
35791
  credential: { sources: input2.sources, ...input2.target === void 0 ? {} : { target: input2.target } },
35697
35792
  ...input2.env === void 0 || Object.keys(input2.env).length === 0 ? {} : { env: input2.env }
35698
35793
  };
35699
35794
  const parsed = ProviderSchema.safeParse(
35700
- kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input2.codex) ? {} : { codex: input2.codex } } : { ...shared, baseUrl: input2.baseUrl }
35795
+ kind === "codex" ? { kind, ...shared, ...isEmptyCodexConfig(input2.codex) ? {} : { codex: input2.codex } } : kind === "antigravity" ? { kind, ...shared, ...isEmptyAntigravityConfig(input2.antigravity) ? {} : { antigravity: input2.antigravity } } : { ...shared, baseUrl: input2.baseUrl }
35701
35796
  );
35702
35797
  if (!parsed.success) {
35703
35798
  throw new ConfigValidationError(providerJsonPath(paths, name), parsed.error.issues);
@@ -35717,8 +35812,14 @@ function updateProvider(paths, name, input2) {
35717
35812
  if (isCodexProvider(existing) && input2.baseUrl !== void 0) {
35718
35813
  throw new ProviderKindMismatchError(`Provider "${name}" is a codex provider, which has no base URL.`);
35719
35814
  }
35815
+ if (isAntigravityProvider(existing) && input2.baseUrl !== void 0) {
35816
+ throw new ProviderKindMismatchError(`Provider "${name}" is an antigravity provider, which has no base URL.`);
35817
+ }
35720
35818
  if (!isCodexProvider(existing) && !isEmptyCodexConfig(input2.codex)) {
35721
- throw new ProviderKindMismatchError(`Provider "${name}" is an http provider; codex settings apply only to a codex provider.`);
35819
+ throw new ProviderKindMismatchError(`Provider "${name}" is not a codex provider; codex settings apply only to a codex provider.`);
35820
+ }
35821
+ if (!isAntigravityProvider(existing) && !isEmptyAntigravityConfig(input2.antigravity)) {
35822
+ throw new ProviderKindMismatchError(`Provider "${name}" is not an antigravity provider; antigravity settings apply only to an antigravity provider.`);
35722
35823
  }
35723
35824
  const shared = {
35724
35825
  ...input2.displayName === void 0 ? {} : { displayName: input2.displayName },
@@ -35737,6 +35838,13 @@ function updateProvider(paths, name, input2) {
35737
35838
  ...existing.codex?.models === void 0 && input2.codex?.models === void 0 ? {} : { models: { ...existing.codex?.models, ...input2.codex?.models } }
35738
35839
  };
35739
35840
  candidate = { ...existing, ...shared, codex: isEmptyCodexConfig(codex) ? void 0 : codex };
35841
+ } else if (isAntigravityProvider(existing)) {
35842
+ const antigravity = {
35843
+ ...existing.antigravity,
35844
+ ...input2.antigravity,
35845
+ ...existing.antigravity?.models === void 0 && input2.antigravity?.models === void 0 ? {} : { models: { ...existing.antigravity?.models, ...input2.antigravity?.models } }
35846
+ };
35847
+ candidate = { ...existing, ...shared, antigravity: isEmptyAntigravityConfig(antigravity) ? void 0 : antigravity };
35740
35848
  } else {
35741
35849
  candidate = { ...existing, ...shared, ...input2.baseUrl === void 0 ? {} : { baseUrl: input2.baseUrl } };
35742
35850
  }
@@ -36974,7 +37082,7 @@ var require_util2 = __commonJS({
36974
37082
  var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
36975
37083
  var { IncomingMessage: IncomingMessage2 } = require("node:http");
36976
37084
  var stream = require("node:stream");
36977
- var net4 = require("node:net");
37085
+ var net5 = require("node:net");
36978
37086
  var { stringify } = require("node:querystring");
36979
37087
  var { EventEmitter: EE2 } = require("node:events");
36980
37088
  var timers = require_timers();
@@ -37123,7 +37231,7 @@ var require_util2 = __commonJS({
37123
37231
  }
37124
37232
  assert2(typeof host === "string");
37125
37233
  const servername = getHostname(host);
37126
- if (net4.isIP(servername)) {
37234
+ if (net5.isIP(servername)) {
37127
37235
  return "";
37128
37236
  }
37129
37237
  return servername;
@@ -38786,7 +38894,7 @@ var require_dispatcher_base = __commonJS({
38786
38894
  var require_connect = __commonJS({
38787
38895
  "node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/core/connect.js"(exports2, module2) {
38788
38896
  "use strict";
38789
- var net4 = require("node:net");
38897
+ var net5 = require("node:net");
38790
38898
  var assert2 = require("node:assert");
38791
38899
  var util2 = require_util2();
38792
38900
  var { InvalidArgumentError: InvalidArgumentError2 } = require_errors();
@@ -38869,7 +38977,7 @@ var require_connect = __commonJS({
38869
38977
  } else {
38870
38978
  assert2(!httpSocket, "httpSocket can only be sent on TLS update");
38871
38979
  port = port || 80;
38872
- socket = net4.connect({
38980
+ socket = net5.connect({
38873
38981
  highWaterMark: 64 * 1024,
38874
38982
  // Same as nodejs fs streams.
38875
38983
  ...options,
@@ -44546,7 +44654,7 @@ var require_client = __commonJS({
44546
44654
  "node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/dispatcher/client.js"(exports2, module2) {
44547
44655
  "use strict";
44548
44656
  var assert2 = require("node:assert");
44549
- var net4 = require("node:net");
44657
+ var net5 = require("node:net");
44550
44658
  var http8 = require("node:http");
44551
44659
  var util2 = require_util2();
44552
44660
  var { ClientStats } = require_stats();
@@ -44701,7 +44809,7 @@ var require_client = __commonJS({
44701
44809
  if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
44702
44810
  throw new InvalidArgumentError2("maxRequestsPerClient must be a positive number");
44703
44811
  }
44704
- if (localAddress != null && (typeof localAddress !== "string" || net4.isIP(localAddress) === 0)) {
44812
+ if (localAddress != null && (typeof localAddress !== "string" || net5.isIP(localAddress) === 0)) {
44705
44813
  throw new InvalidArgumentError2("localAddress must be valid string IP address");
44706
44814
  }
44707
44815
  if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) {
@@ -44881,7 +44989,7 @@ var require_client = __commonJS({
44881
44989
  const idx = hostname3.indexOf("]");
44882
44990
  assert2(idx !== -1);
44883
44991
  const ip2 = hostname3.substring(1, idx);
44884
- assert2(net4.isIPv6(ip2));
44992
+ assert2(net5.isIPv6(ip2));
44885
44993
  hostname3 = ip2;
44886
44994
  }
44887
44995
  client[kConnecting] = true;
@@ -45826,10 +45934,10 @@ var require_socks5_utils = __commonJS({
45826
45934
  "node_modules/.pnpm/undici@7.29.1/node_modules/undici/lib/core/socks5-utils.js"(exports2, module2) {
45827
45935
  "use strict";
45828
45936
  var { Buffer: Buffer3 } = require("node:buffer");
45829
- var net4 = require("node:net");
45937
+ var net5 = require("node:net");
45830
45938
  var { InvalidArgumentError: InvalidArgumentError2 } = require_errors();
45831
45939
  function parseAddress(address) {
45832
- if (net4.isIPv4(address)) {
45940
+ if (net5.isIPv4(address)) {
45833
45941
  const parts = address.split(".").map(Number);
45834
45942
  return {
45835
45943
  type: 1,
@@ -45837,7 +45945,7 @@ var require_socks5_utils = __commonJS({
45837
45945
  buffer: Buffer3.from(parts)
45838
45946
  };
45839
45947
  }
45840
- if (net4.isIPv6(address)) {
45948
+ if (net5.isIPv6(address)) {
45841
45949
  return {
45842
45950
  type: 4,
45843
45951
  // IPv6
@@ -45860,7 +45968,7 @@ var require_socks5_utils = __commonJS({
45860
45968
  if (address.includes(".")) {
45861
45969
  const lastColonIndex = address.lastIndexOf(":");
45862
45970
  const ipv4Part = address.slice(lastColonIndex + 1);
45863
- if (net4.isIPv4(ipv4Part)) {
45971
+ if (net5.isIPv4(ipv4Part)) {
45864
45972
  const octets = ipv4Part.split(".").map(Number);
45865
45973
  const high = (octets[0] << 8 | octets[1]).toString(16);
45866
45974
  const low = (octets[2] << 8 | octets[3]).toString(16);
@@ -63657,10 +63765,10 @@ function resolveLaunch(params) {
63657
63765
  environment
63658
63766
  };
63659
63767
  }
63660
- function runLaunchPlan(plan, spawn5) {
63768
+ function runLaunchPlan(plan, spawn6) {
63661
63769
  try {
63662
63770
  plan.markChildStarted();
63663
- const result = spawn5.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
63771
+ const result = spawn6.spawnSync(plan.bin, plan.args, { stdio: "inherit", env: plan.env });
63664
63772
  if (result.error !== void 0) {
63665
63773
  throw result.error;
63666
63774
  }
@@ -64109,7 +64217,7 @@ function createQuotaRefresher(deps) {
64109
64217
  function createProviderLookup(ports) {
64110
64218
  return (name) => {
64111
64219
  const definition = loadProvider(ports.providersDir, name, ports.fs);
64112
- if (definition === void 0 || isCodexProvider(definition)) {
64220
+ if (definition === void 0 || !isHttpProvider(definition)) {
64113
64221
  return void 0;
64114
64222
  }
64115
64223
  return {
@@ -112410,7 +112518,7 @@ function writeUsageSnapshot(log, snapshot) {
112410
112518
  log(`usage snapshot write failed: ${error63 instanceof Error ? error63.message : String(error63)}`);
112411
112519
  }
112412
112520
  }
112413
- function createCodexRoutePorts(log, signInFile) {
112521
+ function createCodexRoutePorts(log, signInFile, options) {
112414
112522
  const agent = createUpstreamAgent();
112415
112523
  const upstreamFetch = createUpstreamFetch(agent);
112416
112524
  const tempSuffix = `${String(process.pid)}.${(0, import_node_crypto9.randomUUID)()}`;
@@ -112426,9 +112534,11 @@ function createCodexRoutePorts(log, signInFile) {
112426
112534
  "codex-cli": { fetch: upstreamFetch, auth, timers: realTimers, randomId: import_node_crypto9.randomUUID },
112427
112535
  "chatgpt-sign-in": { fetch: upstreamFetch, auth: signIn.auth, timers: realTimers, randomId: import_node_crypto9.randomUUID, target: RESPONSES_API_TARGET }
112428
112536
  },
112429
- writeUsageSnapshot: (snapshot) => {
112430
- writeUsageSnapshot(log, snapshot);
112431
- },
112537
+ ...options?.enableUsageSnapshot === true ? {
112538
+ writeUsageSnapshot: (snapshot) => {
112539
+ writeUsageSnapshot(log, snapshot);
112540
+ }
112541
+ } : {},
112432
112542
  now: () => Date.now(),
112433
112543
  log
112434
112544
  };
@@ -112559,7 +112669,7 @@ function registerCodexCommand(program2, deps) {
112559
112669
  }
112560
112670
 
112561
112671
  // src/frontdoor/commands.ts
112562
- var import_node_crypto21 = require("node:crypto");
112672
+ var import_node_crypto24 = require("node:crypto");
112563
112673
  var import_node_path51 = __toESM(require("node:path"), 1);
112564
112674
  var import_node_fs19 = __toESM(require("node:fs"), 1);
112565
112675
  init_commandDeps();
@@ -114777,7 +114887,7 @@ var LiveTaskSchema = external_exports.strictObject({
114777
114887
  observedAt: external_exports.number()
114778
114888
  });
114779
114889
  var SYSTEM_SUBTYPES = ["task_started", "task_progress", "task_updated", "task_notification", "background_tasks_changed"];
114780
- function isRecord3(value2) {
114890
+ function isRecord4(value2) {
114781
114891
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
114782
114892
  }
114783
114893
  function stringField(record2, field) {
@@ -114794,7 +114904,7 @@ function booleanField(record2, field) {
114794
114904
  }
114795
114905
  function usageOf(record2) {
114796
114906
  const raw = record2.usage;
114797
- if (!isRecord3(raw)) {
114907
+ if (!isRecord4(raw)) {
114798
114908
  return void 0;
114799
114909
  }
114800
114910
  const totalTokens = numberField(raw, "total_tokens");
@@ -114826,7 +114936,7 @@ function bounded(book) {
114826
114936
  return book;
114827
114937
  }
114828
114938
  function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
114829
- if (!isRecord3(payload) || payload.type !== "system") {
114939
+ if (!isRecord4(payload) || payload.type !== "system") {
114830
114940
  return book;
114831
114941
  }
114832
114942
  const subtype = payload.subtype;
@@ -114842,8 +114952,8 @@ function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
114842
114952
  if (subtype === "background_tasks_changed") {
114843
114953
  const tasks = Array.isArray(payload.tasks) ? payload.tasks : [];
114844
114954
  for (const raw of tasks) {
114845
- const taskId2 = isRecord3(raw) ? stringField(raw, "task_id") : void 0;
114846
- if (isRecord3(raw) && taskId2 !== void 0) {
114955
+ const taskId2 = isRecord4(raw) ? stringField(raw, "task_id") : void 0;
114956
+ if (isRecord4(raw) && taskId2 !== void 0) {
114847
114957
  upsert(taskId2, { runId: stringField(raw, "run_id"), taskType: stringField(raw, "task_type"), description: stringField(raw, "description") });
114848
114958
  }
114849
114959
  }
@@ -114866,7 +114976,7 @@ function applyAgentTaskEvent(book, sessionId, payload, observedAt2) {
114866
114976
  } else if (subtype === "task_progress") {
114867
114977
  upsert(taskId, { ...common, subagentType: stringField(payload, "subagent_type"), lastToolName: stringField(payload, "last_tool_name"), usage: usageOf(payload) });
114868
114978
  } else if (subtype === "task_updated") {
114869
- const patch = isRecord3(payload.patch) ? payload.patch : {};
114979
+ const patch = isRecord4(payload.patch) ? payload.patch : {};
114870
114980
  upsert(taskId, { runId: stringField(payload, "run_id"), status: stringField(patch, "status") });
114871
114981
  } else {
114872
114982
  upsert(taskId, { ...common, status: stringField(payload, "status"), outputFile: stringField(payload, "output_file"), summary: stringField(payload, "summary"), usage: usageOf(payload) });
@@ -114948,7 +115058,7 @@ function sessionCreateId(body) {
114948
115058
  const id2 = session.id;
114949
115059
  return typeof id2 === "string" && id2.startsWith(RC_SESSION_ID_PREFIX) ? id2 : void 0;
114950
115060
  }
114951
- function isRecord4(value2) {
115061
+ function isRecord5(value2) {
114952
115062
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
114953
115063
  }
114954
115064
  function parseJsonObject(body) {
@@ -114958,7 +115068,7 @@ function parseJsonObject(body) {
114958
115068
  } catch {
114959
115069
  return void 0;
114960
115070
  }
114961
- return isRecord4(parsed) ? parsed : void 0;
115071
+ return isRecord5(parsed) ? parsed : void 0;
114962
115072
  }
114963
115073
  function nonEmptyString(record2, field) {
114964
115074
  const value2 = record2 === void 0 ? void 0 : record2[field];
@@ -114979,11 +115089,11 @@ function payloadEventsOf(body) {
114979
115089
  }
114980
115090
  const payloads = [];
114981
115091
  for (const event of events) {
114982
- if (!isRecord4(event)) {
115092
+ if (!isRecord5(event)) {
114983
115093
  continue;
114984
115094
  }
114985
115095
  const payload = event.payload;
114986
- if (!isRecord4(payload)) {
115096
+ if (!isRecord5(payload)) {
114987
115097
  continue;
114988
115098
  }
114989
115099
  payloads.push(payload);
@@ -114998,7 +115108,7 @@ function pendingOfControlRequestPayload(payload) {
114998
115108
  if (requestId === void 0) {
114999
115109
  return void 0;
115000
115110
  }
115001
- const request7 = isRecord4(payload.request) ? payload.request : void 0;
115111
+ const request7 = isRecord5(payload.request) ? payload.request : void 0;
115002
115112
  const subtype = nonEmptyString(request7, "subtype");
115003
115113
  const type2 = subtype ?? "control_request";
115004
115114
  let summary = "";
@@ -115015,7 +115125,7 @@ function answeredRequestIdsOfControlResponsePayload(payload) {
115015
115125
  if (payload.type !== "control_response") {
115016
115126
  return [];
115017
115127
  }
115018
- const response = isRecord4(payload.response) ? payload.response : void 0;
115128
+ const response = isRecord5(payload.response) ? payload.response : void 0;
115019
115129
  const id2 = nonEmptyString(response, "request_id") ?? nonEmptyString(payload, "request_id") ?? nonEmptyString(payload, "uuid");
115020
115130
  return id2 === void 0 ? [] : [id2];
115021
115131
  }
@@ -115244,7 +115354,7 @@ function createRcSessionTracker(deps) {
115244
115354
  return;
115245
115355
  }
115246
115356
  entry.sequenceNum = entry.sequenceNum === void 0 || event.sequence_num > entry.sequenceNum ? event.sequence_num : entry.sequenceNum;
115247
- if (!isRecord4(event.payload)) {
115357
+ if (!isRecord5(event.payload)) {
115248
115358
  return;
115249
115359
  }
115250
115360
  entry.liveTasks = applyAgentTaskEvent(entry.liveTasks, sessionId, event.payload, deps.now());
@@ -120122,7 +120232,7 @@ var HTTP_METHODS_UP_TO_V31 = [
120122
120232
  function operationFields(convert) {
120123
120233
  return Object.fromEntries(HTTP_METHODS_UP_TO_V31.map((method) => [method, convert]));
120124
120234
  }
120125
- function isRecord5(value2) {
120235
+ function isRecord6(value2) {
120126
120236
  if (typeof value2 !== "object" || value2 === null) {
120127
120237
  return false;
120128
120238
  }
@@ -120142,7 +120252,7 @@ function setOwn2(object3, key, value2) {
120142
120252
  }
120143
120253
  }
120144
120254
  function cloneValue(value2, seen) {
120145
- if (!(Array.isArray(value2) || isRecord5(value2))) {
120255
+ if (!(Array.isArray(value2) || isRecord6(value2))) {
120146
120256
  return value2;
120147
120257
  }
120148
120258
  const existing = seen.get(value2);
@@ -120165,14 +120275,14 @@ function cloneValue(value2, seen) {
120165
120275
  return out;
120166
120276
  }
120167
120277
  function deepClone(value2) {
120168
- if (!(Array.isArray(value2) || isRecord5(value2))) {
120278
+ if (!(Array.isArray(value2) || isRecord6(value2))) {
120169
120279
  return value2;
120170
120280
  }
120171
120281
  return cloneValue(value2, /* @__PURE__ */ new WeakMap());
120172
120282
  }
120173
120283
  var converting = /* @__PURE__ */ new WeakMap();
120174
120284
  function convertRecord(value2, fields, finish) {
120175
- if (!isRecord5(value2)) {
120285
+ if (!isRecord6(value2)) {
120176
120286
  return deepClone(value2);
120177
120287
  }
120178
120288
  const inProgress = converting.get(value2);
@@ -120198,7 +120308,7 @@ function convertRecord(value2, fields, finish) {
120198
120308
  }
120199
120309
  }
120200
120310
  function mapRecord(value2, convert) {
120201
- if (!isRecord5(value2)) {
120311
+ if (!isRecord6(value2)) {
120202
120312
  return deepClone(value2);
120203
120313
  }
120204
120314
  const out = {};
@@ -120217,7 +120327,7 @@ function mapArray(value2, convert) {
120217
120327
  return value2.map((item) => convert(item)).filter((item) => item !== DROP);
120218
120328
  }
120219
120329
  function getRef(value2) {
120220
- if (isRecord5(value2) && typeof value2.$ref === "string") {
120330
+ if (isRecord6(value2) && typeof value2.$ref === "string") {
120221
120331
  return value2.$ref;
120222
120332
  }
120223
120333
  return void 0;
@@ -120423,7 +120533,7 @@ function convertSchema2(schema) {
120423
120533
  if (schema === false) {
120424
120534
  return { not: {} };
120425
120535
  }
120426
- if (isRecord5(schema) && typeof schema.$ref === "string" && Object.keys(schema).length === 1) {
120536
+ if (isRecord6(schema) && typeof schema.$ref === "string" && Object.keys(schema).length === 1) {
120427
120537
  return { $ref: schema.$ref };
120428
120538
  }
120429
120539
  return convertRecord(schema, SCHEMA_FIELDS, finishSchema);
@@ -120435,7 +120545,7 @@ function resolveSchemeType(name, schemes, seen) {
120435
120545
  return void 0;
120436
120546
  }
120437
120547
  const scheme = schemes[name];
120438
- if (!isRecord5(scheme)) {
120548
+ if (!isRecord6(scheme)) {
120439
120549
  return void 0;
120440
120550
  }
120441
120551
  if (typeof scheme.type === "string") {
@@ -120452,11 +120562,11 @@ function resolveSchemeType(name, schemes, seen) {
120452
120562
  return void 0;
120453
120563
  }
120454
120564
  function createContext(spec) {
120455
- const components = isRecord5(spec) ? spec.components : void 0;
120456
- const pathItems = isRecord5(components) ? components.pathItems : void 0;
120457
- const schemes = isRecord5(components) ? components.securitySchemes : void 0;
120565
+ const components = isRecord6(spec) ? spec.components : void 0;
120566
+ const pathItems = isRecord6(components) ? components.pathItems : void 0;
120567
+ const schemes = isRecord6(components) ? components.securitySchemes : void 0;
120458
120568
  const schemeTypes = /* @__PURE__ */ new Map();
120459
- if (isRecord5(schemes)) {
120569
+ if (isRecord6(schemes)) {
120460
120570
  for (const name of Object.keys(schemes)) {
120461
120571
  const type2 = resolveSchemeType(name, schemes, /* @__PURE__ */ new Set());
120462
120572
  if (type2 !== void 0) {
@@ -120466,7 +120576,7 @@ function createContext(spec) {
120466
120576
  }
120467
120577
  return {
120468
120578
  inlining: /* @__PURE__ */ new Set(),
120469
- pathItems: isRecord5(pathItems) ? pathItems : void 0,
120579
+ pathItems: isRecord6(pathItems) ? pathItems : void 0,
120470
120580
  schemeTypes
120471
120581
  };
120472
120582
  }
@@ -120474,7 +120584,7 @@ function isMutualTls(name, context) {
120474
120584
  return context.schemeTypes.get(name) === "mutualTLS";
120475
120585
  }
120476
120586
  function convertRequirement(value2, context) {
120477
- if (!isRecord5(value2)) {
120587
+ if (!isRecord6(value2)) {
120478
120588
  return deepClone(value2);
120479
120589
  }
120480
120590
  const entries = Object.entries(value2);
@@ -120574,10 +120684,10 @@ function resolvePathItemRef(value2, context) {
120574
120684
  return void 0;
120575
120685
  }
120576
120686
  const target = context.pathItems[name];
120577
- return isRecord5(target) ? [name, target] : void 0;
120687
+ return isRecord6(target) ? [name, target] : void 0;
120578
120688
  }
120579
120689
  function convertPathItem(value2, context) {
120580
- if (!isRecord5(value2)) {
120690
+ if (!isRecord6(value2)) {
120581
120691
  return deepClone(value2);
120582
120692
  }
120583
120693
  const resolved = resolvePathItemRef(value2, context);
@@ -120677,7 +120787,7 @@ function convertExample(value2) {
120677
120787
  });
120678
120788
  }
120679
120789
  function isQuerystringParameter(value2) {
120680
- return isRecord5(value2) && value2.in === "querystring";
120790
+ return isRecord6(value2) && value2.in === "querystring";
120681
120791
  }
120682
120792
  function isRemovedRef(value2, removed) {
120683
120793
  const ref = getRef(value2);
@@ -120693,7 +120803,7 @@ function convertParameterOrHeader2(value2, context) {
120693
120803
  style: (item) => item === "cookie" ? DROP : deepClone(item)
120694
120804
  },
120695
120805
  (out, parameter) => {
120696
- const lostContent = isRecord5(parameter.content) && Object.keys(parameter.content).length > 0 && isRecord5(out.content) && Object.keys(out.content).length === 0;
120806
+ const lostContent = isRecord6(parameter.content) && Object.keys(parameter.content).length > 0 && isRecord6(out.content) && Object.keys(out.content).length === 0;
120697
120807
  return lostContent ? DROP : out;
120698
120808
  }
120699
120809
  );
@@ -120814,7 +120924,7 @@ function convertComponents2(value2, context) {
120814
120924
  });
120815
120925
  }
120816
120926
  function losesEntireContent(value2, mediaTypes) {
120817
- if (!(isRecord5(value2) && isRecord5(value2.content))) {
120927
+ if (!(isRecord6(value2) && isRecord6(value2.content))) {
120818
120928
  return false;
120819
120929
  }
120820
120930
  const entries = Object.values(value2.content);
@@ -120822,7 +120932,7 @@ function losesEntireContent(value2, mediaTypes) {
120822
120932
  }
120823
120933
  function indexRemovedComponentRefs(map2, prefix, mediaTypes, isDirectlyRemoved) {
120824
120934
  const removed = /* @__PURE__ */ new Set();
120825
- if (!isRecord5(map2)) {
120935
+ if (!isRecord6(map2)) {
120826
120936
  return removed;
120827
120937
  }
120828
120938
  const entries = Object.entries(map2);
@@ -120844,12 +120954,12 @@ function indexRemovedComponentRefs(map2, prefix, mediaTypes, isDirectlyRemoved)
120844
120954
  return removed;
120845
120955
  }
120846
120956
  function createContext2(spec) {
120847
- const components = isRecord5(spec) ? spec.components : void 0;
120848
- const mediaTypes = isRecord5(components) && isRecord5(components.mediaTypes) ? components.mediaTypes : void 0;
120957
+ const components = isRecord6(spec) ? spec.components : void 0;
120958
+ const mediaTypes = isRecord6(components) && isRecord6(components.mediaTypes) ? components.mediaTypes : void 0;
120849
120959
  return {
120850
120960
  mediaTypes,
120851
- removedHeaderRefs: indexRemovedComponentRefs(isRecord5(components) ? components.headers : void 0, HEADERS_REF_PREFIX, mediaTypes, () => false),
120852
- removedParameterRefs: indexRemovedComponentRefs(isRecord5(components) ? components.parameters : void 0, PARAMETERS_REF_PREFIX, mediaTypes, isQuerystringParameter)
120961
+ removedHeaderRefs: indexRemovedComponentRefs(isRecord6(components) ? components.headers : void 0, HEADERS_REF_PREFIX, mediaTypes, () => false),
120962
+ removedParameterRefs: indexRemovedComponentRefs(isRecord6(components) ? components.parameters : void 0, PARAMETERS_REF_PREFIX, mediaTypes, isQuerystringParameter)
120853
120963
  };
120854
120964
  }
120855
120965
  function convertJsonSchemaDialect(value2) {
@@ -125802,7 +125912,7 @@ function providerValue(name, provider) {
125802
125912
  name,
125803
125913
  kind: provider.kind ?? "http",
125804
125914
  displayName: provider.displayName,
125805
- ...isCodexProvider(provider) ? provider.codex === void 0 ? {} : { codex: provider.codex } : { baseUrl: provider.baseUrl },
125915
+ ...isCodexProvider(provider) ? provider.codex === void 0 ? {} : { codex: provider.codex } : isAntigravityProvider(provider) ? provider.antigravity === void 0 ? {} : { antigravity: provider.antigravity } : { baseUrl: provider.baseUrl },
125806
125916
  credential: summariseCredential(provider.credential),
125807
125917
  ...provider.env === void 0 ? {} : { env: provider.env }
125808
125918
  };
@@ -125981,7 +126091,7 @@ function createConfigApiRouter(deps) {
125981
126091
  throw new ProviderNotFoundError(input2.name);
125982
126092
  }
125983
126093
  const credential = input2.credential;
125984
- if (input2.baseUrl !== void 0 && !isCodexProvider(existing) && input2.baseUrl !== existing.baseUrl && credential?.sources === void 0) {
126094
+ if (input2.baseUrl !== void 0 && isHttpProvider(existing) && input2.baseUrl !== existing.baseUrl && credential?.sources === void 0) {
125985
126095
  throw new ORPCError("BAD_REQUEST", { message: `Changing the base URL of provider "${input2.name}" requires a credential block in the same call: the stored credential is not sent to a different endpoint.` });
125986
126096
  }
125987
126097
  const cache = credential?.cache === void 0 ? void 0 : mergeCredentialCache(credential.cache === false ? { enabled: false } : { ...credential.cache, enabled: true }, existing.credential.cache);
@@ -127441,6 +127551,604 @@ function translateRequest(body, config2) {
127441
127551
  return { request: request7, toolNames: names };
127442
127552
  }
127443
127553
 
127554
+ // src/antigravity/translate.ts
127555
+ var import_node_crypto20 = require("node:crypto");
127556
+
127557
+ // src/antigravity/signatures.ts
127558
+ var MAX_REMEMBERED = 1024;
127559
+ var signatures = /* @__PURE__ */ new Map();
127560
+ function rememberToolCallSignature(toolUseId, signature) {
127561
+ signatures.set(toolUseId, signature);
127562
+ if (signatures.size > MAX_REMEMBERED) {
127563
+ const oldest = signatures.keys().next();
127564
+ if (oldest.done !== true) {
127565
+ signatures.delete(oldest.value);
127566
+ }
127567
+ }
127568
+ }
127569
+ function toolCallSignatureOf(toolUseId) {
127570
+ return signatures.get(toolUseId);
127571
+ }
127572
+
127573
+ // src/antigravity/translate.ts
127574
+ init_schema();
127575
+ function resolveAntigravityConfig(config2) {
127576
+ const overrides = config2?.models;
127577
+ return {
127578
+ mode: config2?.mode ?? ANTIGRAVITY_DEFAULT_MODE,
127579
+ defaultModel: config2?.defaultModel ?? ANTIGRAVITY_DEFAULT_MODEL,
127580
+ models: {
127581
+ fable: overrides?.fable ?? ANTIGRAVITY_DEFAULT_TIER_MODELS.fable,
127582
+ opus: overrides?.opus ?? ANTIGRAVITY_DEFAULT_TIER_MODELS.opus,
127583
+ sonnet: overrides?.sonnet ?? ANTIGRAVITY_DEFAULT_TIER_MODELS.sonnet,
127584
+ haiku: overrides?.haiku ?? ANTIGRAVITY_DEFAULT_TIER_MODELS.haiku
127585
+ },
127586
+ effort: config2?.effort ?? ANTIGRAVITY_DEFAULT_EFFORT,
127587
+ cloud: {
127588
+ endpoint: config2?.cloud?.endpoint,
127589
+ projectId: config2?.cloud?.projectId,
127590
+ location: config2?.cloud?.location
127591
+ },
127592
+ local: {
127593
+ command: config2?.local?.command,
127594
+ socketPath: config2?.local?.socketPath
127595
+ }
127596
+ };
127597
+ }
127598
+ function mapModel2(requested, config2) {
127599
+ if (requested.startsWith("gemini-") || requested.startsWith("antigravity-")) {
127600
+ return requested;
127601
+ }
127602
+ const lower = requested.toLowerCase();
127603
+ const tier = ANTIGRAVITY_TIERS.find((candidate) => lower.includes(candidate));
127604
+ return tier === void 0 ? config2.defaultModel : config2.models[tier];
127605
+ }
127606
+ var EFFORT_TO_BUDGET = {
127607
+ none: 0,
127608
+ low: 1024,
127609
+ medium: 4096,
127610
+ high: 8192,
127611
+ xhigh: 16384,
127612
+ max: 32768
127613
+ };
127614
+ function mapEffort2(request7, config2) {
127615
+ const requested = request7.output_config?.effort;
127616
+ const level = ANTIGRAVITY_EFFORTS.find((effort) => effort === requested) ?? config2.effort;
127617
+ const budget = EFFORT_TO_BUDGET[level];
127618
+ return budget > 0 ? budget : void 0;
127619
+ }
127620
+ var BILLING_HEADER_LINE2 = /^x-anthropic-billing-header:[^\n]*\n/;
127621
+ function systemToInstruction(system) {
127622
+ if (system === void 0) {
127623
+ return void 0;
127624
+ }
127625
+ const texts = typeof system === "string" ? [system] : system.filter(isTextBlock).map((b) => b.text);
127626
+ const combined = texts.join("\n").replace(BILLING_HEADER_LINE2, "").trim();
127627
+ return combined.length > 0 ? { parts: [{ text: combined }] } : void 0;
127628
+ }
127629
+ var ANTIGRAVITY_TOOL_NAME_LIMIT = 64;
127630
+ var TOOL_NAME_HASH_CHARS2 = 8;
127631
+ function shortToolName2(name, names) {
127632
+ const sanitized = name.replace(/[^a-zA-Z0-9_]/g, "_");
127633
+ if (sanitized === name && name.length <= ANTIGRAVITY_TOOL_NAME_LIMIT) {
127634
+ return name;
127635
+ }
127636
+ let result;
127637
+ if (sanitized.length <= ANTIGRAVITY_TOOL_NAME_LIMIT) {
127638
+ result = sanitized;
127639
+ } else {
127640
+ const hash2 = (0, import_node_crypto20.createHash)("sha256").update(name).digest("hex").slice(0, TOOL_NAME_HASH_CHARS2);
127641
+ const prefix = sanitized.slice(0, ANTIGRAVITY_TOOL_NAME_LIMIT - TOOL_NAME_HASH_CHARS2 - 1);
127642
+ result = `${prefix}_${hash2}`;
127643
+ }
127644
+ names.set(result, name);
127645
+ return result;
127646
+ }
127647
+ var NON_TEXT_TOOL_RESULT2 = "[non-text tool result omitted]";
127648
+ function flattenToolResult2(content) {
127649
+ if (content === void 0) {
127650
+ return "";
127651
+ }
127652
+ if (typeof content === "string") {
127653
+ return content;
127654
+ }
127655
+ return content.map((block2) => isTextBlock(block2) ? block2.text : NON_TEXT_TOOL_RESULT2).join("\n");
127656
+ }
127657
+ function systemReminder2(text2) {
127658
+ return `<system-reminder>
127659
+ ${text2}
127660
+ </system-reminder>`;
127661
+ }
127662
+ function turnBlocks2(message) {
127663
+ const blocks = typeof message.content === "string" ? [{ type: "text", text: message.content }] : message.content;
127664
+ if (message.role !== "system") {
127665
+ return blocks;
127666
+ }
127667
+ return blocks.map((block2) => isTextBlock(block2) ? { ...block2, text: systemReminder2(block2.text) } : block2);
127668
+ }
127669
+ function isRecord7(value2) {
127670
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
127671
+ }
127672
+ function messagesToGeminiContents(messages, names, toolIdToName) {
127673
+ const contents = [];
127674
+ let pendingRole;
127675
+ let pendingParts = [];
127676
+ const flush = () => {
127677
+ if (pendingRole !== void 0 && pendingParts.length > 0) {
127678
+ contents.push({ role: pendingRole, parts: pendingParts });
127679
+ }
127680
+ pendingRole = void 0;
127681
+ pendingParts = [];
127682
+ };
127683
+ const ensureRole = (role) => {
127684
+ if (pendingRole !== role) {
127685
+ flush();
127686
+ pendingRole = role;
127687
+ }
127688
+ return pendingParts;
127689
+ };
127690
+ for (const message of messages) {
127691
+ const defaultRole = message.role === "assistant" ? "model" : "user";
127692
+ for (const block2 of turnBlocks2(message)) {
127693
+ if (isTextBlock(block2)) {
127694
+ if (block2.text.trim() === "") {
127695
+ continue;
127696
+ }
127697
+ ensureRole(defaultRole).push({ text: block2.text });
127698
+ } else if (isImageBlock(block2)) {
127699
+ const { source } = block2;
127700
+ if (source.type === "base64") {
127701
+ ensureRole("user").push({
127702
+ inlineData: {
127703
+ mimeType: source.media_type,
127704
+ data: source.data
127705
+ }
127706
+ });
127707
+ }
127708
+ } else if (isToolUseBlock(block2)) {
127709
+ const sanitizedName = shortToolName2(block2.name, names);
127710
+ toolIdToName.set(block2.id, sanitizedName);
127711
+ const signature = toolCallSignatureOf(block2.id);
127712
+ ensureRole("model").push({
127713
+ functionCall: {
127714
+ name: sanitizedName,
127715
+ args: isRecord7(block2.input) ? block2.input : {}
127716
+ },
127717
+ // The relay remembered the signature the backend attached to this exact call; echoing it back is what the backend requires of a repeated function call.
127718
+ ...signature === void 0 ? {} : { thoughtSignature: signature }
127719
+ });
127720
+ } else if (isToolResultBlock(block2)) {
127721
+ const toolName = toolIdToName.get(block2.tool_use_id) ?? "unknown_tool";
127722
+ ensureRole("user").push({
127723
+ functionResponse: {
127724
+ name: toolName,
127725
+ response: { output: flattenToolResult2(block2.content) }
127726
+ }
127727
+ });
127728
+ }
127729
+ }
127730
+ }
127731
+ flush();
127732
+ return contents;
127733
+ }
127734
+ var EMPTY_SCHEMA = { type: "object", properties: {} };
127735
+ var GEMINI_SCHEMA_KEYS = /* @__PURE__ */ new Set(["type", "format", "description", "nullable", "enum", "anyOf", "items", "properties", "required", "minimum", "maximum", "minItems", "maxItems"]);
127736
+ function describeSchemaValue(node2) {
127737
+ if (!isRecord7(node2)) {
127738
+ return "any value";
127739
+ }
127740
+ const type2 = node2.type;
127741
+ const name = typeof type2 === "string" ? type2 : Array.isArray(type2) && typeof type2[0] === "string" ? type2[0] : "value";
127742
+ if (name === "array") {
127743
+ return `a list of ${describeSchemaValue(node2.items)}`;
127744
+ }
127745
+ return name === "object" ? "an object" : `a ${name}`;
127746
+ }
127747
+ function toGeminiSchema(node2) {
127748
+ if (!isRecord7(node2)) {
127749
+ return node2;
127750
+ }
127751
+ const out = {};
127752
+ const notes = [];
127753
+ let nullable2 = false;
127754
+ for (const [key, value2] of Object.entries(node2)) {
127755
+ if (key === "type" && Array.isArray(value2)) {
127756
+ const named = value2.filter((entry) => entry !== "null");
127757
+ if (named.length > 0 && typeof named[0] === "string") {
127758
+ out.type = named[0];
127759
+ }
127760
+ nullable2 = value2.includes("null");
127761
+ continue;
127762
+ }
127763
+ if (!GEMINI_SCHEMA_KEYS.has(key)) {
127764
+ if (key === "additionalProperties" && value2 !== false) {
127765
+ notes.push(`Each value is ${describeSchemaValue(value2)}.`);
127766
+ } else if (key === "propertyNames" && isRecord7(value2) && typeof value2.pattern === "string") {
127767
+ notes.push(`Keys match ${value2.pattern}.`);
127768
+ }
127769
+ continue;
127770
+ }
127771
+ out[key] = value2;
127772
+ }
127773
+ if (out.type === "null") {
127774
+ delete out.type;
127775
+ }
127776
+ if (nullable2 && out.type !== void 0) {
127777
+ out.nullable = true;
127778
+ }
127779
+ if (notes.length > 0) {
127780
+ const description = typeof out.description === "string" ? out.description : "";
127781
+ out.description = `${description}${description === "" ? "" : " "}${notes.join(" ")}`;
127782
+ }
127783
+ if ("properties" in out && isRecord7(out.properties)) {
127784
+ out.properties = Object.fromEntries(Object.entries(out.properties).map(([name, child]) => [name, toGeminiSchema(child)]));
127785
+ }
127786
+ if ("items" in out) {
127787
+ out.items = toGeminiSchema(out.items);
127788
+ } else if (out.type === "array") {
127789
+ out.items = {};
127790
+ }
127791
+ if (Array.isArray(out.anyOf)) {
127792
+ out.anyOf = out.anyOf.map(toGeminiSchema);
127793
+ }
127794
+ return out;
127795
+ }
127796
+ function mapTools2(tools, names) {
127797
+ if (tools === void 0 || tools.length === 0) {
127798
+ return void 0;
127799
+ }
127800
+ const declarations = tools.map((tool) => {
127801
+ const converted = tool.input_schema === void 0 ? void 0 : toGeminiSchema(tool.input_schema);
127802
+ return {
127803
+ name: shortToolName2(tool.name, names),
127804
+ description: tool.description,
127805
+ parameters: isRecord7(converted) ? converted : EMPTY_SCHEMA
127806
+ };
127807
+ });
127808
+ return [{ functionDeclarations: declarations }];
127809
+ }
127810
+ var EFFORT_SUFFIXES = /* @__PURE__ */ new Set(["low", "medium", "high"]);
127811
+ function effortSuffixOf(level) {
127812
+ if (level === "medium") {
127813
+ return "medium";
127814
+ }
127815
+ return level === "none" || level === "low" ? "low" : "high";
127816
+ }
127817
+ function splitEffortSuffix(model) {
127818
+ const index = model.lastIndexOf("-");
127819
+ if (index === -1) {
127820
+ return void 0;
127821
+ }
127822
+ const suffix = model.slice(index + 1);
127823
+ return EFFORT_SUFFIXES.has(suffix) ? { base: model.slice(0, index), suffix } : void 0;
127824
+ }
127825
+ function completeEffortSuffix(model, request7, config2) {
127826
+ if (splitEffortSuffix(model) !== void 0) {
127827
+ return model;
127828
+ }
127829
+ const configured = [config2.defaultModel, ...Object.values(config2.models)];
127830
+ const effort = request7.output_config?.effort;
127831
+ const level = ANTIGRAVITY_EFFORTS.find((candidate) => candidate === effort) ?? config2.effort;
127832
+ const suffixed = `${model}-${effortSuffixOf(level)}`;
127833
+ return configured.some((entry) => entry === suffixed || splitEffortSuffix(entry)?.base === model) ? suffixed : model;
127834
+ }
127835
+ function translateRequest2(request7, config2) {
127836
+ const toolNames = /* @__PURE__ */ new Map();
127837
+ const toolIdToName = /* @__PURE__ */ new Map();
127838
+ const model = completeEffortSuffix(mapModel2(request7.model ?? "", config2), request7, config2);
127839
+ const thinkingBudget = mapEffort2(request7, config2);
127840
+ const systemInstruction = systemToInstruction(request7.system);
127841
+ const contents = messagesToGeminiContents(request7.messages, toolNames, toolIdToName);
127842
+ const tools = mapTools2(request7.tools, toolNames);
127843
+ const req = {
127844
+ contents,
127845
+ ...systemInstruction === void 0 ? {} : { systemInstruction },
127846
+ ...tools === void 0 ? {} : { tools },
127847
+ ...thinkingBudget !== void 0 ? { generationConfig: { thinkingConfig: { thinkingBudget } } } : {}
127848
+ };
127849
+ return {
127850
+ model,
127851
+ request: req,
127852
+ toolNames
127853
+ };
127854
+ }
127855
+
127856
+ // src/antigravity/cloudUpstream.ts
127857
+ var import_node_crypto21 = require("node:crypto");
127858
+ var CCPA_ENDPOINT = "https://daily-cloudcode-pa.googleapis.com";
127859
+ var CCPA_DEFAULT_PROJECT_ID = "aicode-consumers";
127860
+ var CCPA_USER_AGENT = "antigravity/cli/1.3.5 (aidev_client; os_type=darwin; arch=arm64; cl=998863838; auth_method=consumer)";
127861
+ function isCcpaEndpoint(endpoint) {
127862
+ return endpoint.includes("cloudcode-pa.googleapis.com");
127863
+ }
127864
+ function buildCloudUrl(config2, model) {
127865
+ const { cloud } = config2;
127866
+ if (cloud.projectId !== void 0 && cloud.location !== void 0) {
127867
+ const base2 = cloud.endpoint ?? `https://${cloud.location}-aiplatform.googleapis.com`;
127868
+ return `${base2}/v1/projects/${cloud.projectId}/locations/${cloud.location}/publishers/google/models/${encodeURIComponent(model)}:streamGenerateContent?alt=sse`;
127869
+ }
127870
+ const base = cloud.endpoint ?? CCPA_ENDPOINT;
127871
+ if (isCcpaEndpoint(base)) {
127872
+ return `${base}/v1internal:streamGenerateContent?alt=sse`;
127873
+ }
127874
+ return `${base}/v1beta/models/${encodeURIComponent(model)}:streamGenerateContent?alt=sse`;
127875
+ }
127876
+ function buildCloudHeaders(token, credentialTarget, endpoint) {
127877
+ const headers = {
127878
+ "Content-Type": "application/json",
127879
+ Accept: "text/event-stream"
127880
+ };
127881
+ const target = credentialTarget ?? "bearer";
127882
+ if (target === "apiKey") {
127883
+ headers["x-goog-api-key"] = token;
127884
+ } else {
127885
+ headers.Authorization = `Bearer ${token}`;
127886
+ }
127887
+ const base = endpoint ?? CCPA_ENDPOINT;
127888
+ if (isCcpaEndpoint(base)) {
127889
+ headers["User-Agent"] = CCPA_USER_AGENT;
127890
+ }
127891
+ return headers;
127892
+ }
127893
+ function buildCloudRequestBody(params) {
127894
+ const base = params.config.cloud.endpoint ?? CCPA_ENDPOINT;
127895
+ if (isCcpaEndpoint(base)) {
127896
+ return JSON.stringify({
127897
+ project: params.config.cloud.projectId ?? CCPA_DEFAULT_PROJECT_ID,
127898
+ requestId: `agent/${(0, import_node_crypto21.randomUUID)()}/${String(Date.now())}/1`,
127899
+ request: params.request,
127900
+ model: params.model,
127901
+ userAgent: "antigravity"
127902
+ });
127903
+ }
127904
+ return JSON.stringify(params.request);
127905
+ }
127906
+ function isRecord8(value2) {
127907
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
127908
+ }
127909
+ function isGeminiChunk(value2) {
127910
+ return isRecord8(value2);
127911
+ }
127912
+ var AntigravityUpstreamError = class extends Error {
127913
+ status;
127914
+ retryAfter;
127915
+ constructor(status, message, retryAfter) {
127916
+ super(`Google Antigravity API error (${String(status)}): ${message}`);
127917
+ this.name = "AntigravityUpstreamError";
127918
+ this.status = status;
127919
+ this.retryAfter = retryAfter;
127920
+ }
127921
+ };
127922
+ async function* callCloudAntigravity(params, fetchFn = fetch) {
127923
+ const url2 = buildCloudUrl(params.config, params.model);
127924
+ const headers = buildCloudHeaders(params.token, params.credentialTarget, params.config.cloud.endpoint);
127925
+ const body = buildCloudRequestBody(params);
127926
+ const response = await fetchFn(url2, {
127927
+ method: "POST",
127928
+ headers,
127929
+ body,
127930
+ signal: params.signal
127931
+ });
127932
+ if (!response.ok) {
127933
+ const errorText = await response.text();
127934
+ const retryAfter = response.headers.get("retry-after");
127935
+ throw new AntigravityUpstreamError(response.status, errorText, retryAfter);
127936
+ }
127937
+ if (response.body === null) {
127938
+ return;
127939
+ }
127940
+ const decoder = new TextDecoder("utf-8");
127941
+ let buffer2 = "";
127942
+ const sseDataPrefix = "data:";
127943
+ for await (const rawChunk of response.body) {
127944
+ const chunk = rawChunk instanceof Uint8Array ? rawChunk : Buffer.from(String(rawChunk));
127945
+ buffer2 += decoder.decode(chunk, { stream: true });
127946
+ const lines = buffer2.split("\n");
127947
+ buffer2 = lines.pop() ?? "";
127948
+ for (const line of lines) {
127949
+ const trimmed = line.trim();
127950
+ if (trimmed.startsWith(sseDataPrefix)) {
127951
+ const jsonStr = trimmed.slice(sseDataPrefix.length).trim();
127952
+ if (jsonStr.length > 0) {
127953
+ try {
127954
+ const parsed = JSON.parse(jsonStr);
127955
+ if (isRecord8(parsed)) {
127956
+ const unwrapped = isRecord8(parsed.response) ? parsed.response : parsed;
127957
+ if (isGeminiChunk(unwrapped)) {
127958
+ yield unwrapped;
127959
+ }
127960
+ }
127961
+ } catch {
127962
+ }
127963
+ }
127964
+ }
127965
+ }
127966
+ }
127967
+ }
127968
+
127969
+ // src/antigravity/quota.ts
127970
+ var MS_PER_SECOND8 = 1e3;
127971
+ var DEFAULT_RETRY_AFTER_SECONDS = 60;
127972
+ var PERCENT_MULTIPLIER = 100;
127973
+ var EXHAUSTED_PERCENT = "100";
127974
+ var GEMINI_5H_KEYS = ["gemini-5h", "gemini_5h", "gemini"];
127975
+ var GEMINI_WEEKLY_KEYS = ["gemini-weekly", "gemini_weekly"];
127976
+ var THIRD_PARTY_5H_KEYS = ["3p-5h", "claude-5h", "3p_5h", "claude_5h", "claude"];
127977
+ var THIRD_PARTY_WEEKLY_KEYS = ["3p-weekly", "claude-weekly", "3p_weekly", "claude_weekly"];
127978
+ function findBucket(quota, keys) {
127979
+ for (const key of keys) {
127980
+ const bucket = quota[key];
127981
+ if (bucket !== void 0) {
127982
+ return bucket;
127983
+ }
127984
+ }
127985
+ return void 0;
127986
+ }
127987
+ function calculateUtilization(remainingFraction) {
127988
+ if (remainingFraction === void 0 || !Number.isFinite(remainingFraction)) {
127989
+ return void 0;
127990
+ }
127991
+ const clampedRem = Math.max(0, Math.min(1, remainingFraction));
127992
+ const used = Math.max(0, 1 - clampedRem);
127993
+ return String(Math.round(used * PERCENT_MULTIPLIER));
127994
+ }
127995
+ function calculateResetTimestamp(nowSec, resetInSeconds) {
127996
+ if (resetInSeconds === void 0 || !Number.isFinite(resetInSeconds) || resetInSeconds < 0) {
127997
+ return void 0;
127998
+ }
127999
+ return String(nowSec + Math.ceil(resetInSeconds));
128000
+ }
128001
+ function parseRetryAfterSeconds(raw, defaultSeconds = DEFAULT_RETRY_AFTER_SECONDS) {
128002
+ if (raw === null || raw === void 0 || raw.trim() === "") {
128003
+ return defaultSeconds;
128004
+ }
128005
+ const numeric = Number(raw);
128006
+ if (Number.isFinite(numeric) && numeric > 0) {
128007
+ return Math.ceil(numeric);
128008
+ }
128009
+ const parsedDate = Date.parse(raw);
128010
+ if (!Number.isNaN(parsedDate)) {
128011
+ const diffSec = Math.ceil((parsedDate - Date.now()) / MS_PER_SECOND8);
128012
+ return Math.max(1, diffSec);
128013
+ }
128014
+ return defaultSeconds;
128015
+ }
128016
+ function unifiedAntigravityQuotaHeaders(params) {
128017
+ const rejected = params.rejected === true;
128018
+ const nowSec = Math.floor(params.nowMs / MS_PER_SECOND8);
128019
+ const headers = {
128020
+ "anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed"
128021
+ };
128022
+ const modelLower = (params.model ?? "").toLowerCase();
128023
+ const isGemini = modelLower.includes("gemini");
128024
+ const fiveHourKeys = isGemini ? GEMINI_5H_KEYS : THIRD_PARTY_5H_KEYS;
128025
+ const weeklyKeys = isGemini ? GEMINI_WEEKLY_KEYS : THIRD_PARTY_WEEKLY_KEYS;
128026
+ const quota = params.quota ?? {};
128027
+ const b5h = findBucket(quota, fiveHourKeys);
128028
+ const bWk = findBucket(quota, weeklyKeys);
128029
+ const used5h = calculateUtilization(b5h?.remaining_fraction);
128030
+ const reset5h = calculateResetTimestamp(nowSec, b5h?.reset_in_seconds);
128031
+ const used7d = calculateUtilization(bWk?.remaining_fraction);
128032
+ const reset7d = calculateResetTimestamp(nowSec, bWk?.reset_in_seconds);
128033
+ let earliestResetSec;
128034
+ if (used5h !== void 0 && reset5h !== void 0) {
128035
+ headers["anthropic-ratelimit-unified-5h-utilization"] = used5h;
128036
+ headers["anthropic-ratelimit-unified-5h-reset"] = reset5h;
128037
+ earliestResetSec = Number(reset5h);
128038
+ }
128039
+ if (used7d !== void 0 && reset7d !== void 0) {
128040
+ headers["anthropic-ratelimit-unified-7d-utilization"] = used7d;
128041
+ headers["anthropic-ratelimit-unified-7d-reset"] = reset7d;
128042
+ const reset7dSec = Number(reset7d);
128043
+ earliestResetSec = earliestResetSec === void 0 ? reset7dSec : Math.min(earliestResetSec, reset7dSec);
128044
+ }
128045
+ if (rejected) {
128046
+ const retrySec = params.retryAfterSeconds ?? DEFAULT_RETRY_AFTER_SECONDS;
128047
+ const fallbackReset = String(nowSec + retrySec);
128048
+ if (headers["anthropic-ratelimit-unified-5h-utilization"] === void 0) {
128049
+ headers["anthropic-ratelimit-unified-5h-utilization"] = EXHAUSTED_PERCENT;
128050
+ headers["anthropic-ratelimit-unified-5h-reset"] = fallbackReset;
128051
+ }
128052
+ if (headers["anthropic-ratelimit-unified-7d-utilization"] === void 0) {
128053
+ headers["anthropic-ratelimit-unified-7d-utilization"] = EXHAUSTED_PERCENT;
128054
+ headers["anthropic-ratelimit-unified-7d-reset"] = fallbackReset;
128055
+ }
128056
+ earliestResetSec = earliestResetSec === void 0 ? nowSec + retrySec : Math.min(earliestResetSec, nowSec + retrySec);
128057
+ }
128058
+ if (earliestResetSec !== void 0) {
128059
+ headers["anthropic-ratelimit-unified-reset"] = String(earliestResetSec);
128060
+ }
128061
+ return headers;
128062
+ }
128063
+ function isRecord9(value2) {
128064
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128065
+ }
128066
+ function bucketToEntry(bucket, nowMs) {
128067
+ if (!isRecord9(bucket) || typeof bucket.bucketId !== "string") {
128068
+ return void 0;
128069
+ }
128070
+ const remainingFraction = typeof bucket.remainingFraction === "number" && Number.isFinite(bucket.remainingFraction) ? bucket.remainingFraction : void 0;
128071
+ const resetMs = typeof bucket.resetTime === "string" ? Date.parse(bucket.resetTime) : Number.NaN;
128072
+ const resetInSeconds = Number.isNaN(resetMs) ? void 0 : Math.max(0, Math.ceil((resetMs - nowMs) / MS_PER_SECOND8));
128073
+ if (remainingFraction === void 0 && resetInSeconds === void 0) {
128074
+ return void 0;
128075
+ }
128076
+ return {
128077
+ key: bucket.bucketId,
128078
+ entry: {
128079
+ ...remainingFraction === void 0 ? {} : { remaining_fraction: remainingFraction },
128080
+ ...resetInSeconds === void 0 ? {} : { reset_in_seconds: resetInSeconds }
128081
+ }
128082
+ };
128083
+ }
128084
+ async function fetchAntigravityQuotaSummary(params) {
128085
+ const fetchFn = params.fetchFn ?? fetch;
128086
+ let response;
128087
+ try {
128088
+ response = await fetchFn(`${params.endpoint ?? CCPA_ENDPOINT}/v1internal:retrieveUserQuotaSummary`, {
128089
+ method: "POST",
128090
+ headers: {
128091
+ "Content-Type": "application/json",
128092
+ Authorization: `Bearer ${params.token}`,
128093
+ "User-Agent": CCPA_USER_AGENT
128094
+ },
128095
+ body: JSON.stringify({ project: params.projectId ?? CCPA_DEFAULT_PROJECT_ID })
128096
+ });
128097
+ } catch {
128098
+ return void 0;
128099
+ }
128100
+ if (!response.ok) {
128101
+ return void 0;
128102
+ }
128103
+ let parsed;
128104
+ try {
128105
+ parsed = await response.json();
128106
+ } catch {
128107
+ return void 0;
128108
+ }
128109
+ if (!isRecord9(parsed) || !Array.isArray(parsed.groups)) {
128110
+ return void 0;
128111
+ }
128112
+ const map2 = {};
128113
+ for (const group of parsed.groups) {
128114
+ if (!isRecord9(group) || !Array.isArray(group.buckets)) {
128115
+ continue;
128116
+ }
128117
+ for (const bucket of group.buckets) {
128118
+ const read = bucketToEntry(bucket, params.nowMs);
128119
+ if (read !== void 0) {
128120
+ map2[read.key] = read.entry;
128121
+ }
128122
+ }
128123
+ }
128124
+ return Object.keys(map2).length > 0 ? map2 : void 0;
128125
+ }
128126
+ var ANTIGRAVITY_QUOTA_REFRESH_MS = 6e4;
128127
+ function createCachedAntigravityQuotaSource(params) {
128128
+ let cachedAt = Number.NEGATIVE_INFINITY;
128129
+ let cached2;
128130
+ let refresh;
128131
+ const refreshMs = params.refreshMs ?? ANTIGRAVITY_QUOTA_REFRESH_MS;
128132
+ const run = async () => {
128133
+ const nowMs = params.now();
128134
+ const read = await params.fetchSummary(nowMs);
128135
+ if (read !== void 0) {
128136
+ cached2 = read;
128137
+ }
128138
+ cachedAt = params.now();
128139
+ };
128140
+ return () => {
128141
+ const nowMs = params.now();
128142
+ if (nowMs - cachedAt < refreshMs) {
128143
+ return cached2;
128144
+ }
128145
+ refresh ??= run().finally(() => {
128146
+ refresh = void 0;
128147
+ });
128148
+ return cached2;
128149
+ };
128150
+ }
128151
+
127444
128152
  // src/frontdoor/providerRoute.ts
127445
128153
  init_credential();
127446
128154
  init_providersStore();
@@ -127577,10 +128285,10 @@ function quotaHeaders(upstream) {
127577
128285
  }
127578
128286
  return headers;
127579
128287
  }
127580
- var EXHAUSTED_PERCENT = "100";
128288
+ var EXHAUSTED_PERCENT2 = "100";
127581
128289
  function unifiedQuotaHeaders(upstream, rejected, quotaError) {
127582
128290
  const headers = { "anthropic-ratelimit-unified-status": rejected ? "rejected" : "allowed" };
127583
- const used7d = upstream.get("x-codex-primary-used-percent") ?? (rejected ? EXHAUSTED_PERCENT : null);
128291
+ const used7d = upstream.get("x-codex-primary-used-percent") ?? (rejected ? EXHAUSTED_PERCENT2 : null);
127584
128292
  const reset7d = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
127585
128293
  if (used7d !== null && reset7d !== null) {
127586
128294
  headers["anthropic-ratelimit-unified-7d-utilization"] = used7d;
@@ -127601,17 +128309,17 @@ function unifiedQuotaHeaders(upstream, rejected, quotaError) {
127601
128309
  }
127602
128310
  return headers;
127603
128311
  }
127604
- var MS_PER_SECOND8 = 1e3;
128312
+ var MS_PER_SECOND9 = 1e3;
127605
128313
  function buildUsageSnapshot(upstream, quotaError, nowMs) {
127606
- const used7 = upstream.get("x-codex-primary-used-percent") ?? (quotaError === void 0 ? null : EXHAUSTED_PERCENT);
128314
+ const used7 = upstream.get("x-codex-primary-used-percent") ?? (quotaError === void 0 ? null : EXHAUSTED_PERCENT2);
127607
128315
  const reset7 = upstream.get("x-codex-primary-reset-at") ?? (quotaError?.resets_at === void 0 ? null : String(quotaError.resets_at));
127608
- const sevenDay = used7 !== null && reset7 !== null ? { used_percentage: Number(used7), resets_at: new Date(Number(reset7) * MS_PER_SECOND8).toISOString() } : void 0;
128316
+ const sevenDay = used7 !== null && reset7 !== null ? { used_percentage: Number(used7), resets_at: new Date(Number(reset7) * MS_PER_SECOND9).toISOString() } : void 0;
127609
128317
  let fiveHour;
127610
128318
  if (Number(upstream.get("x-codex-secondary-window-minutes")) > 0) {
127611
128319
  const used5 = upstream.get("x-codex-secondary-used-percent");
127612
128320
  const reset5 = upstream.get("x-codex-secondary-reset-at");
127613
128321
  if (used5 !== null && reset5 !== null) {
127614
- fiveHour = { used_percentage: Number(used5), resets_at: new Date(Number(reset5) * MS_PER_SECOND8).toISOString() };
128322
+ fiveHour = { used_percentage: Number(used5), resets_at: new Date(Number(reset5) * MS_PER_SECOND9).toISOString() };
127615
128323
  }
127616
128324
  }
127617
128325
  if (sevenDay === void 0 && fiveHour === void 0) {
@@ -127843,9 +128551,11 @@ function createCodexRoute(ports) {
127843
128551
  return errorResponse(HTTP_STATUS.badGateway, `codex backend unreachable: ${describeError3(error63)}`);
127844
128552
  }
127845
128553
  const snapshot = (quotaError) => {
127846
- const built = buildUsageSnapshot(upstream.headers, quotaError, ports.now());
127847
- if (built !== void 0) {
127848
- ports.writeUsageSnapshot(built);
128554
+ if (ports.writeUsageSnapshot !== void 0) {
128555
+ const built = buildUsageSnapshot(upstream.headers, quotaError, ports.now());
128556
+ if (built !== void 0) {
128557
+ ports.writeUsageSnapshot(built);
128558
+ }
127849
128559
  }
127850
128560
  };
127851
128561
  if (!upstream.ok || upstream.body === null) {
@@ -128031,6 +128741,602 @@ function createCodexRouteMount(ports, upstreamBase, provider) {
128031
128741
  };
128032
128742
  }
128033
128743
 
128744
+ // src/antigravity/route.ts
128745
+ var import_node_crypto22 = require("node:crypto");
128746
+ init_route();
128747
+
128748
+ // src/antigravity/relay.ts
128749
+ function renderSseFrame2(frame) {
128750
+ return `event: ${frame.event}
128751
+ data: ${JSON.stringify(frame.data)}
128752
+
128753
+ `;
128754
+ }
128755
+ function createAntigravityRelay(params) {
128756
+ const messageId = params.fallbackId();
128757
+ let started = false;
128758
+ let activeBlockType;
128759
+ let currentBlockIndex = -1;
128760
+ let sawToolUse = false;
128761
+ let finished = false;
128762
+ let usage = {
128763
+ input_tokens: 0,
128764
+ cache_creation_input_tokens: 0,
128765
+ cache_read_input_tokens: 0,
128766
+ output_tokens: 0
128767
+ };
128768
+ const frames = [];
128769
+ const ensureStarted = () => {
128770
+ if (!started) {
128771
+ started = true;
128772
+ frames.push({
128773
+ event: "message_start",
128774
+ data: {
128775
+ type: "message_start",
128776
+ message: {
128777
+ id: messageId,
128778
+ type: "message",
128779
+ role: "assistant",
128780
+ model: params.requestedModel,
128781
+ content: [],
128782
+ stop_reason: null,
128783
+ stop_sequence: null,
128784
+ usage: { input_tokens: 0, output_tokens: 0 }
128785
+ }
128786
+ }
128787
+ });
128788
+ }
128789
+ };
128790
+ const closeActiveBlock = () => {
128791
+ if (activeBlockType !== void 0 && currentBlockIndex >= 0) {
128792
+ frames.push({
128793
+ event: "content_block_stop",
128794
+ data: {
128795
+ type: "content_block_stop",
128796
+ index: currentBlockIndex
128797
+ }
128798
+ });
128799
+ activeBlockType = void 0;
128800
+ }
128801
+ };
128802
+ const pushChunk = (chunk) => {
128803
+ frames.length = 0;
128804
+ ensureStarted();
128805
+ if (chunk.usageMetadata !== void 0) {
128806
+ usage = {
128807
+ input_tokens: chunk.usageMetadata.promptTokenCount ?? usage.input_tokens,
128808
+ cache_creation_input_tokens: 0,
128809
+ cache_read_input_tokens: 0,
128810
+ output_tokens: chunk.usageMetadata.candidatesTokenCount ?? usage.output_tokens
128811
+ };
128812
+ }
128813
+ const candidate = chunk.candidates?.[0];
128814
+ if (candidate?.content?.parts !== void 0) {
128815
+ for (const part of candidate.content.parts) {
128816
+ if ("text" in part && typeof part.text === "string" && (part.thoughtSignature === void 0 || part.text.length > 0)) {
128817
+ if (activeBlockType !== "text") {
128818
+ closeActiveBlock();
128819
+ currentBlockIndex += 1;
128820
+ activeBlockType = "text";
128821
+ frames.push({
128822
+ event: "content_block_start",
128823
+ data: {
128824
+ type: "content_block_start",
128825
+ index: currentBlockIndex,
128826
+ content_block: { type: "text", text: "" }
128827
+ }
128828
+ });
128829
+ }
128830
+ frames.push({
128831
+ event: "content_block_delta",
128832
+ data: {
128833
+ type: "content_block_delta",
128834
+ index: currentBlockIndex,
128835
+ delta: { type: "text_delta", text: part.text }
128836
+ }
128837
+ });
128838
+ } else if ("functionCall" in part && part.functionCall !== void 0) {
128839
+ sawToolUse = true;
128840
+ closeActiveBlock();
128841
+ currentBlockIndex += 1;
128842
+ activeBlockType = "tool_use";
128843
+ const callName = part.functionCall.name;
128844
+ const originalName = params.toolNames.get(callName) ?? callName;
128845
+ const callId = params.fallbackId();
128846
+ if (typeof part.thoughtSignature === "string") {
128847
+ rememberToolCallSignature(callId, part.thoughtSignature);
128848
+ }
128849
+ frames.push({
128850
+ event: "content_block_start",
128851
+ data: {
128852
+ type: "content_block_start",
128853
+ index: currentBlockIndex,
128854
+ content_block: {
128855
+ type: "tool_use",
128856
+ id: callId,
128857
+ name: originalName,
128858
+ input: {}
128859
+ }
128860
+ }
128861
+ });
128862
+ const argsJson = JSON.stringify(part.functionCall.args);
128863
+ frames.push({
128864
+ event: "content_block_delta",
128865
+ data: {
128866
+ type: "content_block_delta",
128867
+ index: currentBlockIndex,
128868
+ delta: {
128869
+ type: "input_json_delta",
128870
+ partial_json: argsJson
128871
+ }
128872
+ }
128873
+ });
128874
+ closeActiveBlock();
128875
+ }
128876
+ }
128877
+ }
128878
+ if (candidate?.finishReason !== void 0) {
128879
+ const stopReason = sawToolUse ? "tool_use" : candidate.finishReason === "MAX_TOKENS" ? "max_tokens" : "end_turn";
128880
+ closeActiveBlock();
128881
+ frames.push({
128882
+ event: "message_delta",
128883
+ data: {
128884
+ type: "message_delta",
128885
+ delta: { stop_reason: stopReason, stop_sequence: null },
128886
+ usage
128887
+ }
128888
+ });
128889
+ frames.push({
128890
+ event: "message_stop",
128891
+ data: { type: "message_stop" }
128892
+ });
128893
+ finished = true;
128894
+ }
128895
+ return { frames: [...frames], done: finished };
128896
+ };
128897
+ const finish = () => {
128898
+ frames.length = 0;
128899
+ if (!finished) {
128900
+ ensureStarted();
128901
+ closeActiveBlock();
128902
+ const stopReason = sawToolUse ? "tool_use" : "end_turn";
128903
+ frames.push({
128904
+ event: "message_delta",
128905
+ data: {
128906
+ type: "message_delta",
128907
+ delta: { stop_reason: stopReason, stop_sequence: null },
128908
+ usage
128909
+ }
128910
+ });
128911
+ frames.push({
128912
+ event: "message_stop",
128913
+ data: { type: "message_stop" }
128914
+ });
128915
+ finished = true;
128916
+ }
128917
+ return { frames: [...frames], done: true };
128918
+ };
128919
+ return { pushChunk, finish };
128920
+ }
128921
+
128922
+ // src/antigravity/localUpstream.ts
128923
+ var import_node_child_process6 = require("node:child_process");
128924
+ var import_node_net2 = __toESM(require("node:net"), 1);
128925
+ var import_node_readline2 = __toESM(require("node:readline"), 1);
128926
+ init_zod();
128927
+ var DEFAULT_ACP_COMMAND = ["antigravity-acp"];
128928
+ function connectSocket(socketPath) {
128929
+ const socket = import_node_net2.default.createConnection({ path: socketPath });
128930
+ const rl2 = import_node_readline2.default.createInterface({ input: socket, crlfDelay: Infinity });
128931
+ return {
128932
+ send: (msg) => {
128933
+ socket.write(`${JSON.stringify(msg)}
128934
+ `);
128935
+ },
128936
+ lines: rl2,
128937
+ close: () => {
128938
+ socket.destroy();
128939
+ }
128940
+ };
128941
+ }
128942
+ function spawnProcess(command, signal) {
128943
+ const bin = command[0];
128944
+ if (bin === void 0) {
128945
+ throw new Error("ACP command cannot be empty");
128946
+ }
128947
+ const args = command.slice(1);
128948
+ const proc = (0, import_node_child_process6.spawn)(bin, args, {
128949
+ stdio: ["pipe", "pipe", "inherit"],
128950
+ signal
128951
+ });
128952
+ if (proc.stdin === null || proc.stdout === null) {
128953
+ throw new Error(`Failed to establish stdio pipes with ACP process "${command.join(" ")}"`);
128954
+ }
128955
+ const rl2 = import_node_readline2.default.createInterface({ input: proc.stdout, crlfDelay: Infinity });
128956
+ return {
128957
+ send: (msg) => {
128958
+ proc.stdin?.write(`${JSON.stringify(msg)}
128959
+ `);
128960
+ },
128961
+ lines: rl2,
128962
+ close: () => {
128963
+ try {
128964
+ proc.kill("SIGTERM");
128965
+ } catch {
128966
+ }
128967
+ }
128968
+ };
128969
+ }
128970
+ var AcpStreamMessageSchema = external_exports.looseObject({
128971
+ jsonrpc: external_exports.string().optional(),
128972
+ id: external_exports.union([external_exports.number(), external_exports.string()]).optional(),
128973
+ method: external_exports.string().optional(),
128974
+ params: external_exports.looseObject({
128975
+ delta: external_exports.looseObject({
128976
+ text: external_exports.string().optional(),
128977
+ toolCall: external_exports.looseObject({
128978
+ id: external_exports.string().optional(),
128979
+ name: external_exports.string(),
128980
+ arguments: external_exports.string().optional()
128981
+ }).optional()
128982
+ }).optional(),
128983
+ finishReason: external_exports.string().optional(),
128984
+ chunk: external_exports.looseObject({}).optional()
128985
+ }).optional(),
128986
+ result: external_exports.looseObject({
128987
+ chunk: external_exports.looseObject({}).optional()
128988
+ }).optional()
128989
+ });
128990
+ function isRecord10(value2) {
128991
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128992
+ }
128993
+ function normalizeFinishReason(reason) {
128994
+ if (reason === void 0) {
128995
+ return void 0;
128996
+ }
128997
+ if (reason === "STOP" || reason === "MAX_TOKENS" || reason === "SAFETY" || reason === "RECITATION" || reason === "OTHER") {
128998
+ return reason;
128999
+ }
129000
+ const lower = reason.toLowerCase();
129001
+ if (lower === "stop" || lower === "end_turn") {
129002
+ return "STOP";
129003
+ }
129004
+ if (lower === "max_tokens" || lower === "length") {
129005
+ return "MAX_TOKENS";
129006
+ }
129007
+ return "OTHER";
129008
+ }
129009
+ function parseJsonRecord(raw) {
129010
+ if (raw === void 0) {
129011
+ return {};
129012
+ }
129013
+ try {
129014
+ const parsed = JSON.parse(raw);
129015
+ if (isRecord10(parsed)) {
129016
+ return parsed;
129017
+ }
129018
+ } catch {
129019
+ }
129020
+ return {};
129021
+ }
129022
+ async function* callLocalAntigravity(params) {
129023
+ const { config: config2, signal } = params;
129024
+ let conn;
129025
+ try {
129026
+ if (params.connector !== void 0) {
129027
+ conn = params.connector(config2, signal);
129028
+ } else if (config2.local.socketPath !== void 0) {
129029
+ conn = connectSocket(config2.local.socketPath);
129030
+ } else {
129031
+ const cmd = config2.local.command ?? DEFAULT_ACP_COMMAND;
129032
+ conn = spawnProcess(cmd, signal);
129033
+ }
129034
+ let nextId = 1;
129035
+ const initId = nextId++;
129036
+ conn.send({
129037
+ jsonrpc: "2.0",
129038
+ id: initId,
129039
+ method: "initialize",
129040
+ params: {
129041
+ protocolVersion: "1.0",
129042
+ clientInfo: { name: "agent-shim", version: "1.0" }
129043
+ }
129044
+ });
129045
+ const promptId = nextId++;
129046
+ conn.send({
129047
+ jsonrpc: "2.0",
129048
+ id: promptId,
129049
+ method: "session/prompt",
129050
+ params: {
129051
+ model: params.model,
129052
+ request: params.request
129053
+ }
129054
+ });
129055
+ for await (const line of conn.lines) {
129056
+ if (signal.aborted) {
129057
+ break;
129058
+ }
129059
+ const trimmed = line.trim();
129060
+ if (trimmed.length === 0) {
129061
+ continue;
129062
+ }
129063
+ try {
129064
+ const parsedJson = JSON.parse(trimmed);
129065
+ const parsed = AcpStreamMessageSchema.safeParse(parsedJson);
129066
+ if (!parsed.success) {
129067
+ continue;
129068
+ }
129069
+ const msg = parsed.data;
129070
+ if (msg.params?.chunk !== void 0) {
129071
+ yield msg.params.chunk;
129072
+ } else if (msg.result?.chunk !== void 0) {
129073
+ yield msg.result.chunk;
129074
+ } else if (msg.method === "session/update" && msg.params?.delta !== void 0) {
129075
+ const delta = msg.params.delta;
129076
+ const parts = [];
129077
+ if (delta.text !== void 0 && delta.text.length > 0) {
129078
+ parts.push({ text: delta.text });
129079
+ }
129080
+ if (delta.toolCall !== void 0) {
129081
+ const argsObj = parseJsonRecord(delta.toolCall.arguments);
129082
+ parts.push({ functionCall: { name: delta.toolCall.name, args: argsObj } });
129083
+ }
129084
+ yield {
129085
+ candidates: [
129086
+ {
129087
+ content: { parts },
129088
+ finishReason: normalizeFinishReason(msg.params.finishReason)
129089
+ }
129090
+ ]
129091
+ };
129092
+ }
129093
+ } catch {
129094
+ }
129095
+ }
129096
+ } finally {
129097
+ conn?.close();
129098
+ }
129099
+ }
129100
+
129101
+ // src/antigravity/route.ts
129102
+ function createAntigravityRoute(ports) {
129103
+ const fallbackId = ports.fallbackId ?? (() => (0, import_node_crypto22.randomUUID)());
129104
+ return async (request7) => {
129105
+ await Promise.resolve();
129106
+ if (request7.method !== "POST") {
129107
+ return {
129108
+ status: HTTP_STATUS.badRequest,
129109
+ headers: { "Content-Type": "application/json" },
129110
+ body: JSON.stringify({ type: "error", error: { type: "invalid_request_error", message: "only POST is supported" } })
129111
+ };
129112
+ }
129113
+ const providerName = parseProviderPath(request7.path)?.provider;
129114
+ if (providerName === void 0) {
129115
+ return {
129116
+ status: HTTP_STATUS.notFound,
129117
+ headers: { "Content-Type": "application/json" },
129118
+ body: JSON.stringify({ type: "error", error: { type: "not_found_error", message: "no provider specified in path" } })
129119
+ };
129120
+ }
129121
+ const lookup = ports.loadProvider(providerName);
129122
+ if (!lookup.ok) {
129123
+ return {
129124
+ status: lookup.status,
129125
+ headers: { "Content-Type": "application/json" },
129126
+ body: JSON.stringify({ type: "error", error: { type: "invalid_request_error", message: lookup.message } })
129127
+ };
129128
+ }
129129
+ let parsedJson;
129130
+ try {
129131
+ parsedJson = JSON.parse(request7.body);
129132
+ } catch {
129133
+ return {
129134
+ status: HTTP_STATUS.badRequest,
129135
+ headers: { "Content-Type": "application/json" },
129136
+ body: JSON.stringify({ type: "error", error: { type: "invalid_request_error", message: "malformed JSON body" } })
129137
+ };
129138
+ }
129139
+ const parsed = MessagesRequestSchema.safeParse(parsedJson);
129140
+ if (!parsed.success) {
129141
+ return {
129142
+ status: HTTP_STATUS.badRequest,
129143
+ headers: { "Content-Type": "application/json" },
129144
+ body: JSON.stringify({
129145
+ type: "error",
129146
+ error: {
129147
+ type: "invalid_request_error",
129148
+ message: parsed.error.issues.map((i10) => `${i10.path.join(".")}: ${i10.message}`).join("; ")
129149
+ }
129150
+ })
129151
+ };
129152
+ }
129153
+ const { config: config2, token, credentialTarget } = lookup;
129154
+ const requestedModel = parsed.data.model ?? config2.defaultModel;
129155
+ const translated = translateRequest2(parsed.data, config2);
129156
+ const relay = createAntigravityRelay({
129157
+ requestedModel,
129158
+ toolNames: translated.toolNames,
129159
+ fallbackId
129160
+ });
129161
+ const nowMs = ports.now?.() ?? Date.now();
129162
+ const upstreamChunks2 = config2.mode === "local" ? callLocalAntigravity({
129163
+ config: config2,
129164
+ model: translated.model,
129165
+ request: translated.request,
129166
+ signal: request7.signal,
129167
+ connector: ports.localConnector
129168
+ }) : callCloudAntigravity(
129169
+ {
129170
+ config: config2,
129171
+ model: translated.model,
129172
+ request: translated.request,
129173
+ token,
129174
+ credentialTarget,
129175
+ signal: request7.signal
129176
+ },
129177
+ ports.fetchFn
129178
+ );
129179
+ const iterator = upstreamChunks2[Symbol.asyncIterator]();
129180
+ let firstResult;
129181
+ try {
129182
+ firstResult = await iterator.next();
129183
+ } catch (error63) {
129184
+ if (error63 instanceof AntigravityUpstreamError) {
129185
+ const is429 = error63.status === HTTP_STATUS.tooManyRequests;
129186
+ const retryAfter = is429 ? parseRetryAfterSeconds(error63.retryAfter) : void 0;
129187
+ const quotaHeaders3 = unifiedAntigravityQuotaHeaders({
129188
+ quota: ports.quotaSource?.(),
129189
+ rejected: is429,
129190
+ nowMs,
129191
+ retryAfterSeconds: retryAfter,
129192
+ model: requestedModel
129193
+ });
129194
+ const errorType = is429 ? "rate_limit_error" : "api_error";
129195
+ return {
129196
+ status: error63.status,
129197
+ headers: {
129198
+ "Content-Type": "application/json",
129199
+ ...quotaHeaders3,
129200
+ ...retryAfter !== void 0 ? { "retry-after": String(retryAfter) } : {}
129201
+ },
129202
+ body: JSON.stringify({ type: "error", error: { type: errorType, message: error63.message } })
129203
+ };
129204
+ }
129205
+ const errMsg = error63 instanceof Error ? error63.message : String(error63);
129206
+ return {
129207
+ status: HTTP_STATUS.badGateway,
129208
+ headers: { "Content-Type": "application/json" },
129209
+ body: JSON.stringify({ type: "error", error: { type: "api_error", message: errMsg } })
129210
+ };
129211
+ }
129212
+ const quotaHeaders2 = unifiedAntigravityQuotaHeaders({
129213
+ quota: ports.quotaSource?.(),
129214
+ rejected: false,
129215
+ nowMs,
129216
+ model: requestedModel
129217
+ });
129218
+ const stream = async function* () {
129219
+ try {
129220
+ if (firstResult.done !== true) {
129221
+ const step2 = relay.pushChunk(firstResult.value);
129222
+ for (const frame of step2.frames) {
129223
+ yield renderSseFrame2(frame);
129224
+ }
129225
+ if (!step2.done) {
129226
+ for (; ; ) {
129227
+ if (request7.signal.aborted) {
129228
+ break;
129229
+ }
129230
+ const nextResult = await iterator.next();
129231
+ if (nextResult.done === true) {
129232
+ break;
129233
+ }
129234
+ const nextStep = relay.pushChunk(nextResult.value);
129235
+ for (const frame of nextStep.frames) {
129236
+ yield renderSseFrame2(frame);
129237
+ }
129238
+ if (nextStep.done) {
129239
+ break;
129240
+ }
129241
+ }
129242
+ }
129243
+ }
129244
+ const finalStep = relay.finish();
129245
+ for (const frame of finalStep.frames) {
129246
+ yield renderSseFrame2(frame);
129247
+ }
129248
+ } catch (error63) {
129249
+ if (!request7.signal.aborted) {
129250
+ const errMsg = error63 instanceof Error ? error63.message : String(error63);
129251
+ yield renderSseFrame2({
129252
+ event: "error",
129253
+ data: { type: "error", error: { type: "api_error", message: errMsg } }
129254
+ });
129255
+ }
129256
+ }
129257
+ };
129258
+ return {
129259
+ status: HTTP_STATUS.ok,
129260
+ headers: {
129261
+ "Content-Type": "text/event-stream",
129262
+ "Cache-Control": "no-cache",
129263
+ Connection: "keep-alive",
129264
+ ...quotaHeaders2
129265
+ },
129266
+ body: stream()
129267
+ };
129268
+ };
129269
+ }
129270
+
129271
+ // src/frontdoor/antigravityMount.ts
129272
+ var ANTIGRAVITY_MAX_BODY_BYTES = 67108864;
129273
+ var BodyTooLargeError2 = class extends Error {
129274
+ constructor() {
129275
+ super("request body too large");
129276
+ this.name = "BodyTooLargeError";
129277
+ }
129278
+ };
129279
+ async function readBody3(request7) {
129280
+ const chunks = [];
129281
+ let size = 0;
129282
+ for await (const chunk of request7.body) {
129283
+ if (!Buffer.isBuffer(chunk)) {
129284
+ throw new TypeError("request body chunk was not a Buffer");
129285
+ }
129286
+ size += chunk.length;
129287
+ if (size > ANTIGRAVITY_MAX_BODY_BYTES) {
129288
+ throw new BodyTooLargeError2();
129289
+ }
129290
+ chunks.push(chunk);
129291
+ }
129292
+ return Buffer.concat(chunks).toString("utf8");
129293
+ }
129294
+ async function writeRouteResponse2(routed, response, signal) {
129295
+ response.start(routed.status, routed.headers);
129296
+ if (typeof routed.body === "string") {
129297
+ await response.write(routed.body);
129298
+ response.end();
129299
+ return;
129300
+ }
129301
+ for await (const chunk of routed.body) {
129302
+ if (signal.aborted) {
129303
+ return;
129304
+ }
129305
+ await response.write(chunk);
129306
+ }
129307
+ response.end();
129308
+ }
129309
+ function createAntigravityRouteMount(ports, upstreamBase, provider) {
129310
+ const route = createAntigravityRoute(ports);
129311
+ return {
129312
+ name: `antigravity:${provider}`,
129313
+ headroomEligible: true,
129314
+ headroomUpstream: upstreamBase,
129315
+ serve: async (request7, response) => {
129316
+ let body;
129317
+ try {
129318
+ body = await readBody3(request7);
129319
+ } catch (error63) {
129320
+ const tooLarge = error63 instanceof BodyTooLargeError2;
129321
+ response.start(tooLarge ? HTTP_STATUS.payloadTooLarge : HTTP_STATUS.badRequest, { "Content-Type": "application/json" });
129322
+ await response.write(
129323
+ JSON.stringify({ type: "error", error: { type: "invalid_request_error", message: error63 instanceof Error ? error63.message : String(error63) } })
129324
+ );
129325
+ response.end();
129326
+ request7.body.resume();
129327
+ return;
129328
+ }
129329
+ const path59 = new URL(request7.url, "http://127.0.0.1").pathname;
129330
+ const translated = { method: request7.method, path: path59, body, signal: request7.signal };
129331
+ const routed = await route(translated);
129332
+ if (request7.signal.aborted) {
129333
+ return;
129334
+ }
129335
+ await writeRouteResponse2(routed, response, request7.signal);
129336
+ }
129337
+ };
129338
+ }
129339
+
128034
129340
  // src/frontdoor/passthrough.ts
128035
129341
  var http5 = __toESM(require("node:http"), 1);
128036
129342
  var https4 = __toESM(require("node:https"), 1);
@@ -128195,9 +129501,43 @@ async function scanRequestHead(request7, wholeBody = false) {
128195
129501
  }
128196
129502
 
128197
129503
  // src/frontdoor/providerRoute.ts
129504
+ var isRcSelfHostPath = (path59) => path59 === "/v1/code/sessions" || path59.startsWith("/v1/code/sessions/") || path59 === "/v1/sessions" || path59.startsWith("/v1/sessions/");
129505
+ function scopeSessionProviderPath(request7) {
129506
+ if (request7.session.provider === void 0) {
129507
+ return request7;
129508
+ }
129509
+ const path59 = new URL(request7.url, "http://127.0.0.1").pathname;
129510
+ if (!path59.startsWith("/v1/") || isRcSelfHostPath(path59)) {
129511
+ return request7;
129512
+ }
129513
+ return { ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` };
129514
+ }
128198
129515
  function createProviderRouteResolver(deps) {
128199
- const isRcSelfHostPath = (path59) => path59 === "/v1/code/sessions" || path59.startsWith("/v1/code/sessions/") || path59 === "/v1/sessions" || path59.startsWith("/v1/sessions/");
128200
129516
  const oauthRoute = createPassthroughRoute("anthropic", { baseUrl: `https://${CONNECT_INTERCEPT_HOST}:${String(HTTPS_PORT)}`, stripPrefix: void 0, headroomUpstream: void 0 });
129517
+ const antigravityQuotaSources = /* @__PURE__ */ new Map();
129518
+ const antigravityQuotaOf = (provider, definition, config2) => {
129519
+ const existing = antigravityQuotaSources.get(provider);
129520
+ if (existing !== void 0) {
129521
+ return existing;
129522
+ }
129523
+ const source = createCachedAntigravityQuotaSource({
129524
+ now: () => Date.now(),
129525
+ fetchSummary: async (nowMs) => {
129526
+ const res = resolveCredential({ credential: definition.credential, env: deps.env, port: deps.credentials, subject: `provider ${provider}` });
129527
+ if (!res.ok) {
129528
+ return void 0;
129529
+ }
129530
+ return fetchAntigravityQuotaSummary({
129531
+ token: res.credential.token,
129532
+ endpoint: config2.cloud.endpoint ?? void 0,
129533
+ projectId: config2.cloud.projectId ?? void 0,
129534
+ nowMs
129535
+ });
129536
+ }
129537
+ });
129538
+ antigravityQuotaSources.set(provider, source);
129539
+ return source;
129540
+ };
128201
129541
  const passthroughByTarget = /* @__PURE__ */ new Map();
128202
129542
  const passthroughFor = (name, target) => {
128203
129543
  const key = `${name}\0${target.baseUrl}\0${target.stripPrefix ?? ""}\0${target.headroomUpstream ?? ""}`;
@@ -128216,9 +129556,6 @@ function createProviderRouteResolver(deps) {
128216
129556
  if (deps.rcSelfHostRoute !== void 0 && isRcSelfHostPath(path59)) {
128217
129557
  return { ok: true, route: deps.rcSelfHostRoute };
128218
129558
  }
128219
- if (request7.session.provider !== void 0 && path59.startsWith("/v1/") && !isRcSelfHostPath(path59)) {
128220
- return resolve2({ ...request7, url: `${PROVIDER_PATH_PREFIX}${encodeURIComponent(request7.session.provider)}${request7.url}` });
128221
- }
128222
129559
  return path59.startsWith("/v1/") ? { ok: true, route: oauthRoute } : { ok: false, status: HTTP_STATUS.notFound, message: `no such endpoint: ${path59}` };
128223
129560
  }
128224
129561
  const { provider } = scoped;
@@ -128245,6 +129582,37 @@ function createProviderRouteResolver(deps) {
128245
129582
  )
128246
129583
  };
128247
129584
  }
129585
+ if (isAntigravityProvider(definition)) {
129586
+ const antigravityProvider = definition;
129587
+ const config2 = resolveAntigravityConfig(antigravityProvider.antigravity);
129588
+ return {
129589
+ ok: true,
129590
+ route: createAntigravityRouteMount(
129591
+ {
129592
+ loadProvider: () => {
129593
+ const res = resolveCredential({
129594
+ credential: antigravityProvider.credential,
129595
+ env: deps.env,
129596
+ port: deps.credentials,
129597
+ subject: `provider ${provider}`
129598
+ });
129599
+ if (!res.ok) {
129600
+ return { ok: false, status: HTTP_STATUS.unauthorized, message: res.message };
129601
+ }
129602
+ return {
129603
+ ok: true,
129604
+ config: config2,
129605
+ token: res.credential.token,
129606
+ credentialTarget: antigravityProvider.credential.target
129607
+ };
129608
+ },
129609
+ quotaSource: antigravityQuotaOf(provider, antigravityProvider, config2)
129610
+ },
129611
+ directOrigin2(deps.directPort()),
129612
+ provider
129613
+ )
129614
+ };
129615
+ }
128248
129616
  const httpProvider = definition;
128249
129617
  return {
128250
129618
  ok: true,
@@ -128268,7 +129636,9 @@ function createProviderRouteResolver(deps) {
128268
129636
  }
128269
129637
  });
128270
129638
  return async (request7) => {
128271
- let current = request7;
129639
+ const scopedRequest = scopeSessionProviderPath(request7);
129640
+ const serveScoped = (resolution) => scopedRequest === request7 ? resolution : { ok: true, route: servingRewritten(resolution.route, scopedRequest) };
129641
+ let current = scopedRequest;
128272
129642
  let replay;
128273
129643
  const visited = /* @__PURE__ */ new Set();
128274
129644
  for (; ; ) {
@@ -128284,13 +129654,13 @@ function createProviderRouteResolver(deps) {
128284
129654
  let routes;
128285
129655
  try {
128286
129656
  const definition = providerName === void 0 ? void 0 : loadProvider(deps.providersDir, providerName, deps.fs);
128287
- routes = definition === void 0 || isCodexProvider(definition) ? void 0 : definition.routes;
129657
+ routes = definition === void 0 || !isHttpProvider(definition) ? void 0 : definition.routes;
128288
129658
  } catch {
128289
129659
  routes = void 0;
128290
129660
  }
128291
129661
  if (routes === void 0 || routes.length === 0) {
128292
129662
  const resolution = resolve2(current);
128293
- return resolution.ok && replay !== void 0 ? { ok: true, route: servingRewritten(resolution.route, { ...replay, url: current.url }) } : resolution;
129663
+ return resolution.ok && replay !== void 0 ? { ok: true, route: servingRewritten(resolution.route, { ...replay, url: current.url }) } : resolution.ok ? serveScoped(resolution) : resolution;
128294
129664
  }
128295
129665
  const whole = routes.some((entry) => entry.model !== void 0 || referencesFact(entry.when, "request.hasImage"));
128296
129666
  const snapshot = deps.usageSnapshotOf?.(current.session.identity);
@@ -128302,7 +129672,7 @@ function createProviderRouteResolver(deps) {
128302
129672
  const scan = await scanRequestHead(current, whole);
128303
129673
  if (scan.replayed === void 0) {
128304
129674
  const resolution = resolve2(current);
128305
- return resolution.ok && replay !== void 0 ? { ok: true, route: servingRewritten(resolution.route, { ...replay, url: current.url }) } : resolution;
129675
+ return resolution.ok && replay !== void 0 ? { ok: true, route: servingRewritten(resolution.route, { ...replay, url: current.url }) } : resolution.ok ? serveScoped(resolution) : resolution;
128306
129676
  }
128307
129677
  replay = scan.replayed;
128308
129678
  const requestFacts = {
@@ -128364,7 +129734,7 @@ function attachingProviderCredential(route, deps) {
128364
129734
  init_realFrontDoorPort();
128365
129735
 
128366
129736
  // src/frontdoor/rcCommands.ts
128367
- var import_node_crypto20 = require("node:crypto");
129737
+ var import_node_crypto23 = require("node:crypto");
128368
129738
  init_commandDeps();
128369
129739
  init_cliError();
128370
129740
  init_realPorts();
@@ -128403,15 +129773,15 @@ function readFrontDoorControlMaterial(fsPort, paths, purpose) {
128403
129773
 
128404
129774
  // src/frontdoor/rcLiveUsage.ts
128405
129775
  var RC_RATE_LIMIT_EVENT_TYPE = "rate_limit_event";
128406
- function isRecord6(value2) {
129776
+ function isRecord11(value2) {
128407
129777
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128408
129778
  }
128409
129779
  function rcRateLimitInfoOf(event) {
128410
129780
  const payload = event.envelope.payload;
128411
- if (!isRecord6(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
129781
+ if (!isRecord11(payload) || payload.type !== RC_RATE_LIMIT_EVENT_TYPE) {
128412
129782
  return void 0;
128413
129783
  }
128414
- if (!isRecord6(payload.rate_limit_info)) {
129784
+ if (!isRecord11(payload.rate_limit_info)) {
128415
129785
  return void 0;
128416
129786
  }
128417
129787
  const parsed = RcRateLimitInfoSchema.safeParse(payload.rate_limit_info);
@@ -128445,9 +129815,9 @@ init_account();
128445
129815
  var RC_SELF_HOST_OAUTH_HOST = "platform.claude.com";
128446
129816
  var RC_SELF_HOST_SCOPE_LIST = ["user:profile", "user:inference", "user:sessions:claude_code", "user:mcp_servers", "user:file_upload"];
128447
129817
  var RC_SELF_HOST_OAUTH_TOKEN_TTL_SECONDS = 3600;
128448
- var MS_PER_SECOND9 = 1e3;
129818
+ var MS_PER_SECOND10 = 1e3;
128449
129819
  var HTTP_SERVICE_UNAVAILABLE = 503;
128450
- function isRecord7(value2) {
129820
+ function isRecord12(value2) {
128451
129821
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128452
129822
  }
128453
129823
  function parseJsonObject2(body) {
@@ -128457,7 +129827,7 @@ function parseJsonObject2(body) {
128457
129827
  } catch {
128458
129828
  return void 0;
128459
129829
  }
128460
- return isRecord7(parsed) ? parsed : void 0;
129830
+ return isRecord12(parsed) ? parsed : void 0;
128461
129831
  }
128462
129832
  function growthBookFeatures() {
128463
129833
  return {
@@ -128501,7 +129871,7 @@ function createRcSelfHostLocal(deps) {
128501
129871
  }
128502
129872
  if (method === "POST" && pathname.startsWith("/api/eval/")) {
128503
129873
  await deps.readBody(request7, CONTROL_BODY_CAP_BYTES);
128504
- answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() / MS_PER_SECOND9) });
129874
+ answerServerJson(response, HTTP_STATUS.ok, { features: growthBookFeatures(), dateUpdated: Math.floor(deps.now() / MS_PER_SECOND10) });
128505
129875
  return true;
128506
129876
  }
128507
129877
  if (method === "GET" && pathname === "/api/oauth/profile") {
@@ -128551,7 +129921,7 @@ var RC_SELF_HOST_RECORD_DIR = "rc-selfhost";
128551
129921
  var RC_SELF_HOST_RECORD_FILE = "credential.json";
128552
129922
  var SELF_HOST_EMAIL = "selfhost@agent-shim.invalid";
128553
129923
  var SELF_HOST_SUBSCRIPTION_TYPE = "max";
128554
- function isRecord8(value2) {
129924
+ function isRecord13(value2) {
128555
129925
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128556
129926
  }
128557
129927
  function readJsonObject(fs24, file2) {
@@ -128565,7 +129935,7 @@ function readJsonObject(fs24, file2) {
128565
129935
  } catch {
128566
129936
  return void 0;
128567
129937
  }
128568
- return isRecord8(parsed) ? parsed : void 0;
129938
+ return isRecord13(parsed) ? parsed : void 0;
128569
129939
  }
128570
129940
  function readRcSelfHostRecord(fs24, frontdoorDir) {
128571
129941
  const parsed = readJsonObject(fs24, import_node_path49.default.join(frontdoorDir, RC_SELF_HOST_RECORD_DIR, RC_SELF_HOST_RECORD_FILE));
@@ -128589,7 +129959,7 @@ function mintRcSelfHostCredential(deps) {
128589
129959
  const recordFile = import_node_path49.default.join(recordDir, RC_SELF_HOST_RECORD_FILE);
128590
129960
  const previousRecord = readRcSelfHostRecord(deps.fs, deps.frontdoorDir);
128591
129961
  const existingCredentials = readJsonObject(deps.fs, credentialsFile);
128592
- const existingOauth = isRecord8(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
129962
+ const existingOauth = isRecord13(existingCredentials?.claudeAiOauth) ? existingCredentials.claudeAiOauth : void 0;
128593
129963
  const existingToken = typeof existingOauth?.accessToken === "string" && existingOauth.accessToken !== "" ? existingOauth.accessToken : void 0;
128594
129964
  const existingIsOwn = existingToken !== void 0 && previousRecord?.accessToken === existingToken;
128595
129965
  if (existingToken !== void 0 && !existingIsOwn && !deps.force) {
@@ -128606,7 +129976,7 @@ function mintRcSelfHostCredential(deps) {
128606
129976
  deps.fs.writeFilePrivate(credentialsFile, `${JSON.stringify({ ...existingCredentials, claudeAiOauth: { accessToken, refreshToken, expiresAt: null, scopes: [...RC_SELF_HOST_SCOPE_LIST], subscriptionType: SELF_HOST_SUBSCRIPTION_TYPE, rateLimitTier: null } }, null, 2)}
128607
129977
  `);
128608
129978
  const claudeJson = readJsonObject(deps.fs, claudeJsonFile) ?? {};
128609
- const existingBlock = (value2) => isRecord8(value2) ? value2 : {};
129979
+ const existingBlock = (value2) => isRecord13(value2) ? value2 : {};
128610
129980
  deps.fs.writeFilePrivate(claudeJsonFile, `${JSON.stringify({
128611
129981
  ...claudeJson,
128612
129982
  oauthAccount: {
@@ -128685,12 +130055,12 @@ function eventExcerpt(text2) {
128685
130055
  return text2.length <= RC_PENDING_SUMMARY_EXCERPT_CHARS ? text2 : `${text2.slice(0, RC_PENDING_SUMMARY_EXCERPT_CHARS)}...`;
128686
130056
  }
128687
130057
  var PERCENT_SCALE = 100;
128688
- var MS_PER_SECOND10 = 1e3;
130058
+ var MS_PER_SECOND11 = 1e3;
128689
130059
  function percentOf(fraction) {
128690
130060
  return `${String(Math.round(fraction * PERCENT_SCALE))}%`;
128691
130061
  }
128692
130062
  function resetInstantOf(epochSeconds) {
128693
- return new Date(epochSeconds * MS_PER_SECOND10).toISOString();
130063
+ return new Date(epochSeconds * MS_PER_SECOND11).toISOString();
128694
130064
  }
128695
130065
  function formatRcRateLimitInfo(info) {
128696
130066
  const parts = [info.status];
@@ -128971,8 +130341,8 @@ function registerRcCommand(frontdoor, paths) {
128971
130341
  identitiesDir: paths.identitiesDir,
128972
130342
  frontdoorDir: paths.frontdoorDir,
128973
130343
  identity,
128974
- newUuid: import_node_crypto20.randomUUID,
128975
- randomToken: () => (0, import_node_crypto20.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
130344
+ newUuid: import_node_crypto23.randomUUID,
130345
+ randomToken: () => (0, import_node_crypto23.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
128976
130346
  force: options.force === true,
128977
130347
  now: () => Date.now()
128978
130348
  });
@@ -128993,11 +130363,11 @@ var import_node_path50 = __toESM(require("node:path"), 1);
128993
130363
  function isSafeSessionId(sessionId) {
128994
130364
  return /^[A-Za-z0-9_-]+$/.test(sessionId);
128995
130365
  }
128996
- function isRecord9(value2) {
130366
+ function isRecord14(value2) {
128997
130367
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
128998
130368
  }
128999
130369
  function credentialOfJson(parsed) {
129000
- if (!isRecord9(parsed)) {
130370
+ if (!isRecord14(parsed)) {
129001
130371
  return void 0;
129002
130372
  }
129003
130373
  const { authorization, anthropicVersion, anthropicClientPlatform } = parsed;
@@ -129027,7 +130397,7 @@ function createRcCredentialStore(fs24, dir) {
129027
130397
  } catch {
129028
130398
  return void 0;
129029
130399
  }
129030
- return isRecord9(parsed) ? parsed : void 0;
130400
+ return isRecord14(parsed) ? parsed : void 0;
129031
130401
  };
129032
130402
  return {
129033
130403
  read: (sessionId) => {
@@ -129595,7 +130965,7 @@ init_capability();
129595
130965
  // src/frontdoor/rcSelfHostEndpoints.ts
129596
130966
  var RC_SOURCE_WORKER = "worker";
129597
130967
  var RC_SOURCE_CLIENT = "client";
129598
- function isRecord10(value2) {
130968
+ function isRecord15(value2) {
129599
130969
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
129600
130970
  }
129601
130971
  function parseJsonObject3(body) {
@@ -129605,7 +130975,7 @@ function parseJsonObject3(body) {
129605
130975
  } catch {
129606
130976
  return void 0;
129607
130977
  }
129608
- return isRecord10(parsed) ? parsed : void 0;
130978
+ return isRecord15(parsed) ? parsed : void 0;
129609
130979
  }
129610
130980
  function nonEmptyString2(record2, field) {
129611
130981
  const value2 = record2 === void 0 ? void 0 : record2[field];
@@ -129679,7 +131049,7 @@ async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
129679
131049
  }
129680
131050
  const results = [];
129681
131051
  for (const event of events) {
129682
- if (!isRecord10(event) || !isRecord10(event.payload)) {
131052
+ if (!isRecord15(event) || !isRecord15(event.payload)) {
129683
131053
  await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a teleport write is an object carrying one payload object" } });
129684
131054
  return true;
129685
131055
  }
@@ -129779,7 +131149,7 @@ async function serveRcCompatSessions(ctx, pathname, compatPath) {
129779
131149
  // src/frontdoor/rcSelfHostConversations.ts
129780
131150
  var RC_CONVERSATIONS_PATH_PREFIX = "/v1/code/conversations";
129781
131151
  var RC_CONVERSATION_ID_PREFIX = "conv_";
129782
- function isRecord11(value2) {
131152
+ function isRecord16(value2) {
129783
131153
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
129784
131154
  }
129785
131155
  function parseJsonObject4(body) {
@@ -129789,7 +131159,7 @@ function parseJsonObject4(body) {
129789
131159
  } catch {
129790
131160
  return void 0;
129791
131161
  }
129792
- return isRecord11(parsed) ? parsed : void 0;
131162
+ return isRecord16(parsed) ? parsed : void 0;
129793
131163
  }
129794
131164
  function nonEmptyString3(record2, field) {
129795
131165
  const value2 = record2 === void 0 ? void 0 : record2[field];
@@ -129843,7 +131213,7 @@ async function serveRcConversations(ctx, pathname, method) {
129843
131213
  }
129844
131214
  const results = [];
129845
131215
  for (const event of events) {
129846
- if (!isRecord11(event) || !isRecord11(event.payload)) {
131216
+ if (!isRecord16(event) || !isRecord16(event.payload)) {
129847
131217
  await ctx.answerJson(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
129848
131218
  return;
129849
131219
  }
@@ -129873,7 +131243,7 @@ async function serveRcConversations(ctx, pathname, method) {
129873
131243
  var dns2 = __toESM(require("node:dns"), 1);
129874
131244
  var http6 = __toESM(require("node:http"), 1);
129875
131245
  var https5 = __toESM(require("node:https"), 1);
129876
- var net3 = __toESM(require("node:net"), 1);
131246
+ var net4 = __toESM(require("node:net"), 1);
129877
131247
  var RC_WEB_FETCH_MAX_BYTES = 12582912;
129878
131248
  var RC_WEB_FETCH_DEADLINE_MS = 4e4;
129879
131249
  var RC_WEB_FETCH_MAX_REDIRECTS = 20;
@@ -129914,7 +131284,7 @@ function refused(errorType, errorMessage2) {
129914
131284
  return { kind: "refused", errorType: `${ERROR_PREFIX}${errorType}`, errorMessage: errorMessage2 };
129915
131285
  }
129916
131286
  function isPrivateAddress(address) {
129917
- const version2 = net3.isIP(address);
131287
+ const version2 = net4.isIP(address);
129918
131288
  if (version2 === IP_VERSION_4) {
129919
131289
  const octets = address.split(".").map((part) => Number(part));
129920
131290
  const first = octets[0] ?? -1;
@@ -130000,7 +131370,7 @@ async function checkTarget(url2, deps) {
130000
131370
  const hostname3 = url2.hostname.replace(/^\[|\]$/g, "");
130001
131371
  let addresses;
130002
131372
  try {
130003
- addresses = net3.isIP(hostname3) === 0 ? await deps.lookup(hostname3) : [hostname3];
131373
+ addresses = net4.isIP(hostname3) === 0 ? await deps.lookup(hostname3) : [hostname3];
130004
131374
  } catch {
130005
131375
  return refused("resolve", `${hostname3} did not resolve`);
130006
131376
  }
@@ -130125,7 +131495,7 @@ var RC_COMPAT_SESSIONS_PATH = "/v1/sessions";
130125
131495
  var RC_SESSION_ID_PREFIX2 = "cse_";
130126
131496
  var RC_SELF_HOST_API_BASE_URL = "https://api.anthropic.com";
130127
131497
  var HTTP_CONFLICT = 409;
130128
- var MS_PER_SECOND11 = 1e3;
131498
+ var MS_PER_SECOND12 = 1e3;
130129
131499
  var HTTP_SERVICE_UNAVAILABLE2 = 503;
130130
131500
  var RC_SELF_HOST_WORKER_JWT_TTL_SECONDS = 46800;
130131
131501
  var RC_SELF_HOST_KEEPALIVE_MS = 15e3;
@@ -130136,7 +131506,7 @@ var RC_SELF_HOST_WORKER_EPOCH = 1;
130136
131506
  var RC_STREAM_EVENT_NAME = "client_event";
130137
131507
  var CONFLICT_REASON_HEADER2 = "x-ccr-conflict-reason";
130138
131508
  var CONFLICT_REASON_EPOCH_STALE = "epoch_stale";
130139
- function isRecord12(value2) {
131509
+ function isRecord17(value2) {
130140
131510
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
130141
131511
  }
130142
131512
  function isWebSearchRefusal(value2) {
@@ -130192,7 +131562,7 @@ function presentationRefusal(headers) {
130192
131562
  const bearer = presented.slice("bearer ".length);
130193
131563
  return bearer.slice(0, "bearer ".length).toLowerCase() === "bearer " ? "doubled-scheme-word" : "unrecognised";
130194
131564
  }
130195
- async function readBody3(request7, capBytes) {
131565
+ async function readBody4(request7, capBytes) {
130196
131566
  return await new Promise((resolve2, reject) => {
130197
131567
  const chunks = [];
130198
131568
  let total = 0;
@@ -130220,12 +131590,12 @@ function parseJsonObject5(body) {
130220
131590
  } catch {
130221
131591
  return void 0;
130222
131592
  }
130223
- return isRecord12(parsed) ? parsed : void 0;
131593
+ return isRecord17(parsed) ? parsed : void 0;
130224
131594
  }
130225
131595
  function mintWorkerJwt(randomToken, issuedAt) {
130226
131596
  const encode3 = (value2) => Buffer.from(JSON.stringify(value2), "utf8").toString("base64url");
130227
131597
  const header = encode3({ alg: "HS256", typ: "JWT" });
130228
- const payload = encode3({ exp: Math.floor((issuedAt + RC_SELF_HOST_WORKER_JWT_TTL_SECONDS * MS_PER_SECOND11) / MS_PER_SECOND11), iat: Math.floor(issuedAt / MS_PER_SECOND11) });
131598
+ const payload = encode3({ exp: Math.floor((issuedAt + RC_SELF_HOST_WORKER_JWT_TTL_SECONDS * MS_PER_SECOND12) / MS_PER_SECOND12), iat: Math.floor(issuedAt / MS_PER_SECOND12) });
130229
131599
  return `${header}.${payload}.${Buffer.from(randomToken(), "utf8").toString("base64url")}`;
130230
131600
  }
130231
131601
  function createRcSelfHostSurface(deps) {
@@ -130415,7 +131785,7 @@ data: ${JSON.stringify(envelope)}
130415
131785
  await unauthorized(response, refusal2);
130416
131786
  return;
130417
131787
  }
130418
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
131788
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130419
131789
  const title = nonEmptyString4(body, "title");
130420
131790
  if (title === void 0) {
130421
131791
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "a session update is JSON naming a non-empty title" } });
@@ -130470,7 +131840,7 @@ data: ${JSON.stringify(envelope)}
130470
131840
  return;
130471
131841
  }
130472
131842
  if (workerTail === "" && method === "PUT") {
130473
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
131843
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130474
131844
  const claimedEpoch = numberOf2(body, "worker_epoch");
130475
131845
  if (claimedEpoch !== void 0 && claimedEpoch !== RC_SELF_HOST_WORKER_EPOCH) {
130476
131846
  await epochStale(response);
@@ -130480,24 +131850,24 @@ data: ${JSON.stringify(envelope)}
130480
131850
  if (status !== void 0) {
130481
131851
  session.workerStatus = status;
130482
131852
  }
130483
- if (isRecord12(body?.external_metadata)) {
131853
+ if (isRecord17(body?.external_metadata)) {
130484
131854
  session.externalMetadata = body.external_metadata;
130485
131855
  }
130486
131856
  await answerJson2(response, HTTP_STATUS.ok, {});
130487
131857
  return;
130488
131858
  }
130489
131859
  if (workerTail === "register" && method === "POST") {
130490
- await readBody3(request7.body, CONTROL_BODY_CAP_BYTES);
131860
+ await readBody4(request7.body, CONTROL_BODY_CAP_BYTES);
130491
131861
  await answerJson2(response, HTTP_STATUS.ok, { worker_epoch: RC_SELF_HOST_WORKER_EPOCH });
130492
131862
  return;
130493
131863
  }
130494
131864
  if (workerTail === "heartbeat" && method === "POST") {
130495
- await readBody3(request7.body, CONTROL_BODY_CAP_BYTES);
131865
+ await readBody4(request7.body, CONTROL_BODY_CAP_BYTES);
130496
131866
  await answerJson2(response, HTTP_STATUS.ok, {});
130497
131867
  return;
130498
131868
  }
130499
131869
  if (workerTail === "events" && method === "POST") {
130500
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
131870
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130501
131871
  const claimedEpoch = numberOf2(body, "worker_epoch");
130502
131872
  if (claimedEpoch !== void 0 && claimedEpoch !== RC_SELF_HOST_WORKER_EPOCH) {
130503
131873
  await epochStale(response);
@@ -130510,7 +131880,7 @@ data: ${JSON.stringify(envelope)}
130510
131880
  }
130511
131881
  const results = [];
130512
131882
  for (const event of events) {
130513
- if (!isRecord12(event) || !isRecord12(event.payload)) {
131883
+ if (!isRecord17(event) || !isRecord17(event.payload)) {
130514
131884
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a batch is an object carrying one payload object" } });
130515
131885
  return;
130516
131886
  }
@@ -130526,12 +131896,12 @@ data: ${JSON.stringify(envelope)}
130526
131896
  return;
130527
131897
  }
130528
131898
  if (workerTail === "events/delivery" && method === "POST") {
130529
- await readBody3(request7.body, CONTROL_BODY_CAP_BYTES);
131899
+ await readBody4(request7.body, CONTROL_BODY_CAP_BYTES);
130530
131900
  await answerJson2(response, HTTP_STATUS.ok, {});
130531
131901
  return;
130532
131902
  }
130533
131903
  if (workerTail === "internal-events" && method === "POST") {
130534
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
131904
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130535
131905
  const claimedEpoch = numberOf2(body, "worker_epoch");
130536
131906
  if (claimedEpoch !== void 0 && claimedEpoch !== RC_SELF_HOST_WORKER_EPOCH) {
130537
131907
  await epochStale(response);
@@ -130543,7 +131913,7 @@ data: ${JSON.stringify(envelope)}
130543
131913
  return;
130544
131914
  }
130545
131915
  for (const event of events) {
130546
- if (isRecord12(event)) {
131916
+ if (isRecord17(event)) {
130547
131917
  session.internalEvents.push({ eventId: deps.newUuid(), body: event });
130548
131918
  }
130549
131919
  }
@@ -130566,12 +131936,12 @@ data: ${JSON.stringify(envelope)}
130566
131936
  return;
130567
131937
  }
130568
131938
  if (workerTail === "diagnostics" && method === "POST") {
130569
- await readBody3(request7.body, CONTROL_BODY_CAP_BYTES);
131939
+ await readBody4(request7.body, CONTROL_BODY_CAP_BYTES);
130570
131940
  await answerJson2(response, HTTP_STATUS.ok, {});
130571
131941
  return;
130572
131942
  }
130573
131943
  if (workerTail === "web-fetch" && method === "POST") {
130574
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
131944
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130575
131945
  const target = nonEmptyString4(body, "url");
130576
131946
  if (target === void 0) {
130577
131947
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "a worker web-fetch carries one url" } });
@@ -130594,7 +131964,7 @@ data: ${JSON.stringify(envelope)}
130594
131964
  return;
130595
131965
  }
130596
131966
  if (workerTail === "web-search" && method === "POST") {
130597
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
131967
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130598
131968
  const query = nonEmptyString4(body, "query");
130599
131969
  if (query === void 0) {
130600
131970
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "a worker web-search carries one query" } });
@@ -130631,7 +132001,7 @@ data: ${JSON.stringify(envelope)}
130631
132001
  return;
130632
132002
  }
130633
132003
  if (tail === "events" && method === "POST") {
130634
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
132004
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130635
132005
  const events = body?.events;
130636
132006
  if (!Array.isArray(events) || events.length === 0 || events.length > RC_SELF_HOST_MAX_BATCH_EVENTS) {
130637
132007
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: `a client event write is a non-empty array of at most ${String(RC_SELF_HOST_MAX_BATCH_EVENTS)} events` } });
@@ -130639,7 +132009,7 @@ data: ${JSON.stringify(envelope)}
130639
132009
  }
130640
132010
  const results = [];
130641
132011
  for (const event of events) {
130642
- if (!isRecord12(event) || !isRecord12(event.payload)) {
132012
+ if (!isRecord17(event) || !isRecord17(event.payload)) {
130643
132013
  await answerJson2(response, HTTP_STATUS.badRequest, { type: "error", error: { type: "invalid_request_error", message: "every event in a write is an object carrying one payload object" } });
130644
132014
  return;
130645
132015
  }
@@ -130658,7 +132028,7 @@ data: ${JSON.stringify(envelope)}
130658
132028
  await holdStream(session.conversation, session.id, "clientStreams", () => true, request7, response);
130659
132029
  return;
130660
132030
  }
130661
- if (await serveRcClientChannels({ request: request7, response, host: { id: session.id, clients: session.clients, conversation: session.conversation, writer: { session: session.id, half: "client" } }, answerJson: answerJson2, readBody: readBody3, publish, sweep, now: deps.now, presenceRefreshSeconds: RC_PRESENCE_REFRESH_SECONDS, ...deps.log === void 0 ? {} : { log: deps.log } }, tail, method, RC_SELF_HOST_MAX_BATCH_EVENTS)) {
132031
+ if (await serveRcClientChannels({ request: request7, response, host: { id: session.id, clients: session.clients, conversation: session.conversation, writer: { session: session.id, half: "client" } }, answerJson: answerJson2, readBody: readBody4, publish, sweep, now: deps.now, presenceRefreshSeconds: RC_PRESENCE_REFRESH_SECONDS, ...deps.log === void 0 ? {} : { log: deps.log } }, tail, method, RC_SELF_HOST_MAX_BATCH_EVENTS)) {
130662
132032
  return;
130663
132033
  }
130664
132034
  await answerJson2(response, HTTP_STATUS.notFound, { type: "error", error: { type: "api_error", message: `the self-hosted Remote Control surface serves no path "${tail}"` } });
@@ -130676,11 +132046,11 @@ data: ${JSON.stringify(envelope)}
130676
132046
  return;
130677
132047
  }
130678
132048
  if (pathname === RC_COMPAT_SESSIONS_PATH || pathname.startsWith(`${RC_COMPAT_SESSIONS_PATH}/`)) {
130679
- await serveRcCompatSessions({ request: request7, response, sessions, retireSession, answerJson: answerJson2, readBody: readBody3, credentialRefusal, unauthorized, now: deps.now, ...deps.log === void 0 ? {} : { log: deps.log } }, pathname, RC_COMPAT_SESSIONS_PATH);
132049
+ await serveRcCompatSessions({ request: request7, response, sessions, retireSession, answerJson: answerJson2, readBody: readBody4, credentialRefusal, unauthorized, now: deps.now, ...deps.log === void 0 ? {} : { log: deps.log } }, pathname, RC_COMPAT_SESSIONS_PATH);
130680
132050
  return;
130681
132051
  }
130682
132052
  if (pathname === RC_CONVERSATIONS_PATH_PREFIX || pathname.startsWith(`${RC_CONVERSATIONS_PATH_PREFIX}/`)) {
130683
- await serveRcConversations({ request: request7, response, conversations, answerJson: answerJson2, readBody: readBody3, credentialRefusal, unauthorized, publish, holdStream, sweep, now: deps.now, presenceRefreshSeconds: RC_PRESENCE_REFRESH_SECONDS, maxBatchEvents: RC_SELF_HOST_MAX_BATCH_EVENTS, ...deps.log === void 0 ? {} : { log: deps.log } }, pathname, method);
132053
+ await serveRcConversations({ request: request7, response, conversations, answerJson: answerJson2, readBody: readBody4, credentialRefusal, unauthorized, publish, holdStream, sweep, now: deps.now, presenceRefreshSeconds: RC_PRESENCE_REFRESH_SECONDS, maxBatchEvents: RC_SELF_HOST_MAX_BATCH_EVENTS, ...deps.log === void 0 ? {} : { log: deps.log } }, pathname, method);
130684
132054
  return;
130685
132055
  }
130686
132056
  if (pathname !== RC_SESSIONS_PATH_PREFIX2 && !pathname.startsWith(`${RC_SESSIONS_PATH_PREFIX2}/`)) {
@@ -130694,7 +132064,7 @@ data: ${JSON.stringify(envelope)}
130694
132064
  await unauthorized(response, createRefusal);
130695
132065
  return;
130696
132066
  }
130697
- const body = parseJsonObject5(await readBody3(request7.body, CONTROL_BODY_CAP_BYTES));
132067
+ const body = parseJsonObject5(await readBody4(request7.body, CONTROL_BODY_CAP_BYTES));
130698
132068
  const namedConversation = nonEmptyString4(body, "conversation");
130699
132069
  let conversation;
130700
132070
  if (namedConversation === void 0) {
@@ -130749,7 +132119,7 @@ data: ${JSON.stringify(envelope)}
130749
132119
  await serveSessionPath(sessions.get(id2), tail, request7, response);
130750
132120
  }
130751
132121
  };
130752
- const local = createRcSelfHostLocal({ now: deps.now, credentialRecord: deps.credentialRecord, readBody: readBody3 });
132122
+ const local = createRcSelfHostLocal({ now: deps.now, credentialRecord: deps.credentialRecord, readBody: readBody4 });
130753
132123
  return {
130754
132124
  route,
130755
132125
  local,
@@ -130829,7 +132199,7 @@ function createSseParser() {
130829
132199
  }
130830
132200
  };
130831
132201
  }
130832
- function isRecord13(value2) {
132202
+ function isRecord18(value2) {
130833
132203
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
130834
132204
  }
130835
132205
  function sequenceNumOf(value2) {
@@ -130851,7 +132221,7 @@ function parseRcStreamEnvelope(parsed) {
130851
132221
  } catch {
130852
132222
  return void 0;
130853
132223
  }
130854
- if (!isRecord13(data)) {
132224
+ if (!isRecord18(data)) {
130855
132225
  return void 0;
130856
132226
  }
130857
132227
  const eventType = data.event_type;
@@ -131358,8 +132728,8 @@ function realFrontDoorSupervisorPorts(paths) {
131358
132728
  };
131359
132729
  const rcSelfHostSurface = rcSelfHost ? createRcSelfHostSurface({
131360
132730
  now: () => Date.now(),
131361
- newUuid: import_node_crypto21.randomUUID,
131362
- randomToken: () => (0, import_node_crypto21.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
132731
+ newUuid: import_node_crypto24.randomUUID,
132732
+ randomToken: () => (0, import_node_crypto24.randomBytes)(MINTED_TOKEN_RANDOM_BYTES).toString("base64url"),
131363
132733
  credentialRecord: () => readRcSelfHostRecord(realFarmFs, paths.frontdoorDir),
131364
132734
  webFetch: realRcWebFetch({ allowPrivate: rcWebFetchAllowsPrivateFromEnv(process.env) }),
131365
132735
  log
@@ -131382,7 +132752,7 @@ function realFrontDoorSupervisorPorts(paths) {
131382
132752
  saveSequenceNum: rcCredentialStore.writeCursor,
131383
132753
  dial: rcSelfHost ? lateRcStreamDial(rcSelfHostDialTarget) : realRcStreamDial(),
131384
132754
  fanout: rcFanout,
131385
- newClientId: import_node_crypto21.randomUUID,
132755
+ newClientId: import_node_crypto24.randomUUID,
131386
132756
  backoffMs: RC_STREAM_BACKOFF_MS,
131387
132757
  sleep: async (ms2) => {
131388
132758
  await new Promise((resolve2) => {
@@ -131394,7 +132764,7 @@ function realFrontDoorSupervisorPorts(paths) {
131394
132764
  }
131395
132765
  });
131396
132766
  const routingSnapshots = /* @__PURE__ */ new Map();
131397
- const rcControlToken = (0, import_node_crypto21.randomUUID)();
132767
+ const rcControlToken = (0, import_node_crypto24.randomUUID)();
131398
132768
  const resolveRoute = rcObservingResolver(
131399
132769
  createProviderRouteResolver({
131400
132770
  fs: realFsPort,
@@ -131510,9 +132880,9 @@ function realFrontDoorSupervisorPorts(paths) {
131510
132880
  now: () => Date.now(),
131511
132881
  headroomSocket: () => headroomSocketTarget(realFarmFs, realHeadroomSocketTrust, paths),
131512
132882
  // The per-generation capability the direct listener demands: held only in this process's memory, so a loopback process that discovers the direct port still cannot use it.
131513
- hopSecret: (0, import_node_crypto21.randomUUID)(),
132883
+ hopSecret: (0, import_node_crypto24.randomUUID)(),
131514
132884
  headroomDecision,
131515
- custody: createCredentialCustody(() => (0, import_node_crypto21.randomUUID)()),
132885
+ custody: createCredentialCustody(() => (0, import_node_crypto24.randomUUID)()),
131516
132886
  log
131517
132887
  });
131518
132888
  const onListenerError = (name) => (error63) => {
@@ -131535,9 +132905,9 @@ function realFrontDoorSupervisorPorts(paths) {
131535
132905
  startProviderListener: async (preferredPort) => {
131536
132906
  const authority = loadCa();
131537
132907
  const rcDial = rcSelfHost ? lateRcEventDial(rcSelfHostDialTarget) : realRcEventDial();
131538
- const rcInject = async (sessionId, text2) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto21.randomUUID }, sessionId, text2);
132908
+ const rcInject = async (sessionId, text2) => await injectRcUserMessage({ credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto24.randomUUID }, sessionId, text2);
131539
132909
  const rcAnswer = async (sessionId, requestId, decision) => await answerRcControlRequest({ credentialOf: rcTracker.credentialOf, pendingOf: (id2) => rcTracker.pendingOf(id2), completePending: rcTracker.completePending, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial }, sessionId, requestId, decision);
131540
- const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto21.randomUUID };
132910
+ const rcControlRequestDeps = { credentialOf: rcTracker.credentialOf, noteSequenceNums: rcTracker.noteSequenceNums, dial: rcDial, newUuid: import_node_crypto24.randomUUID };
131541
132911
  const rcInterrupt = async (sessionId) => await interruptRcSession(rcControlRequestDeps, sessionId);
131542
132912
  const rcSetModel = async (sessionId, model) => await setRcSessionModel(rcControlRequestDeps, sessionId, model);
131543
132913
  const rcSetPermissionMode = async (sessionId, mode) => await setRcSessionPermissionMode(rcControlRequestDeps, sessionId, mode);
@@ -131636,7 +133006,7 @@ function realFrontDoorSupervisorPorts(paths) {
131636
133006
  },
131637
133007
  startConnectListener: async (preferredPort) => {
131638
133008
  const wantedTransparentPort = process.env.AGENT_SHIM_TRANSPARENT_SURFACE === void 0 ? void 0 : Number(process.env.AGENT_SHIM_TRANSPARENT_SURFACE);
131639
- const transparentCapability = wantedTransparentPort === void 0 || Number.isNaN(wantedTransparentPort) ? void 0 : (0, import_node_crypto21.randomUUID)();
133009
+ const transparentCapability = wantedTransparentPort === void 0 || Number.isNaN(wantedTransparentPort) ? void 0 : (0, import_node_crypto24.randomUUID)();
131640
133010
  if (transparentCapability !== void 0) {
131641
133011
  writeFrontDoorSession(realFarmFs, paths.frontdoorSessionsDir, { pid: process.pid, startedAt: Date.now(), token: transparentCapability });
131642
133012
  }
@@ -141862,7 +143232,7 @@ function registerCompletionCommand(program2) {
141862
143232
  }
141863
143233
 
141864
143234
  // src/credentialCommand.ts
141865
- var import_node_child_process6 = require("node:child_process");
143235
+ var import_node_child_process7 = require("node:child_process");
141866
143236
  init_commandDeps();
141867
143237
  init_cliError();
141868
143238
  init_credential();
@@ -141922,7 +143292,7 @@ function realCommandPorts(deps) {
141922
143292
  cache: createRealCredentialCache(deps.paths.root),
141923
143293
  platform: process.platform,
141924
143294
  now: () => Date.now(),
141925
- ssh: (host, remoteCommand, input2) => (0, import_node_child_process6.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
143295
+ ssh: (host, remoteCommand, input2) => (0, import_node_child_process7.spawnSync)("ssh", ["--", host, remoteCommand], { input: input2, stdio: ["pipe", "inherit", "inherit"] }).status
141926
143296
  };
141927
143297
  }
141928
143298
  var REMOTE_ROOT_SCRIPT = 'root="${AGENT_SHIM_HOME:-${CLAUDE_USE_HOME:-}}"; if [ -z "$root" ]; then if [ ! -d "$HOME/.agent-shim" ] && [ -d "$HOME/.claude-use" ]; then root="$HOME/.claude-use"; else root="$HOME/.agent-shim"; fi; fi';
@@ -142059,7 +143429,7 @@ function registerDoctorCommand(program2, deps) {
142059
143429
  var import_node_fs22 = __toESM(require("node:fs"), 1);
142060
143430
  var import_node_http4 = __toESM(require("node:http"), 1);
142061
143431
  var import_node_path54 = __toESM(require("node:path"), 1);
142062
- var import_node_child_process7 = require("node:child_process");
143432
+ var import_node_child_process8 = require("node:child_process");
142063
143433
  init_commandDeps();
142064
143434
  init_realFrontDoorPort();
142065
143435
  init_trust();
@@ -142243,7 +143613,7 @@ async function readyOverSocket(socketPath) {
142243
143613
  }
142244
143614
  var HEADROOM_TOOL_NAME = "headroom-ai";
142245
143615
  function readInstalledHeadroomCommit() {
142246
- const toolDir = (0, import_node_child_process7.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
143616
+ const toolDir = (0, import_node_child_process8.spawnSync)("uv", ["tool", "dir"], { encoding: "utf8" });
142247
143617
  if (toolDir.status !== 0) {
142248
143618
  return void 0;
142249
143619
  }
@@ -142287,7 +143657,7 @@ function realSupervisorPorts(paths) {
142287
143657
  }
142288
143658
  const logFd = import_node_fs22.default.openSync(paths.headroomLogPath, "a");
142289
143659
  try {
142290
- const child = (0, import_node_child_process7.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
143660
+ const child = (0, import_node_child_process8.spawn)("headroom", headroomProxyArgs(socketPath, allowlistFile, settings2), {
142291
143661
  detached: true,
142292
143662
  stdio: ["ignore", logFd, logFd],
142293
143663
  env: headroomSpawnEnv(process.env, settings2, trust?.path)
@@ -142327,7 +143697,7 @@ function realSupervisorPorts(paths) {
142327
143697
  },
142328
143698
  ready: readyOverSocket,
142329
143699
  install: (spec) => {
142330
- const result = (0, import_node_child_process7.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
143700
+ const result = (0, import_node_child_process8.spawnSync)("uv", ["tool", "install", spec], { encoding: "utf8", timeout: HEADROOM_INSTALL_TIMEOUT_MS });
142331
143701
  if (result.error !== void 0) {
142332
143702
  const timedOut = "code" in result.error && result.error.code === "ETIMEDOUT";
142333
143703
  return {
@@ -142344,7 +143714,7 @@ function realSupervisorPorts(paths) {
142344
143714
  return result.status === 0 ? { ok: true } : { ok: false, error: `uv tool install exited ${String(result.status)}` };
142345
143715
  },
142346
143716
  headroomVersion: () => {
142347
- const result = (0, import_node_child_process7.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
143717
+ const result = (0, import_node_child_process8.spawnSync)("headroom", ["--version"], { encoding: "utf8" });
142348
143718
  return result.status === 0 ? result.stdout.trim() : void 0;
142349
143719
  },
142350
143720
  installedCommit: readInstalledHeadroomCommit,
@@ -142736,11 +144106,38 @@ function toProviderView(name, provider) {
142736
144106
  name,
142737
144107
  kind: provider.kind ?? "http",
142738
144108
  displayName: provider.displayName,
142739
- ...isCodexProvider(provider) ? provider.codex === void 0 ? {} : { codex: provider.codex } : { baseUrl: provider.baseUrl },
144109
+ ...isCodexProvider(provider) ? provider.codex === void 0 ? {} : { codex: provider.codex } : isAntigravityProvider(provider) ? provider.antigravity === void 0 ? {} : { antigravity: provider.antigravity } : { baseUrl: provider.baseUrl },
142740
144110
  credential: summariseCredential(provider.credential),
142741
144111
  ...provider.env === void 0 ? {} : { env: provider.env }
142742
144112
  };
142743
144113
  }
144114
+ function antigravityConfigFromOptions(options) {
144115
+ if (options.antigravityMode === void 0 && options.antigravityDefaultModel === void 0 && options.antigravityModel === void 0 && options.antigravityEffort === void 0 && options.antigravityEndpoint === void 0 && options.antigravityProjectId === void 0 && options.antigravityLocation === void 0 && options.antigravityCommand === void 0 && options.antigravitySocket === void 0) {
144116
+ return void 0;
144117
+ }
144118
+ const cloud = options.antigravityEndpoint !== void 0 || options.antigravityProjectId !== void 0 || options.antigravityLocation !== void 0 ? {
144119
+ ...options.antigravityEndpoint === void 0 ? {} : { endpoint: options.antigravityEndpoint },
144120
+ ...options.antigravityProjectId === void 0 ? {} : { projectId: options.antigravityProjectId },
144121
+ ...options.antigravityLocation === void 0 ? {} : { location: options.antigravityLocation }
144122
+ } : void 0;
144123
+ const local = options.antigravityCommand !== void 0 || options.antigravitySocket !== void 0 ? {
144124
+ ...options.antigravityCommand === void 0 ? {} : { command: options.antigravityCommand },
144125
+ ...options.antigravitySocket === void 0 ? {} : { socketPath: options.antigravitySocket }
144126
+ } : void 0;
144127
+ const candidate = {
144128
+ ...options.antigravityMode === void 0 ? {} : { mode: options.antigravityMode },
144129
+ ...options.antigravityDefaultModel === void 0 ? {} : { defaultModel: options.antigravityDefaultModel },
144130
+ ...options.antigravityModel === void 0 ? {} : { models: options.antigravityModel },
144131
+ ...options.antigravityEffort === void 0 ? {} : { effort: options.antigravityEffort },
144132
+ ...cloud === void 0 ? {} : { cloud },
144133
+ ...local === void 0 ? {} : { local }
144134
+ };
144135
+ const parsed = AntigravityProviderConfigSchema.safeParse(candidate);
144136
+ if (!parsed.success) {
144137
+ throw new UsageError(`Invalid antigravity settings: ${parsed.error.issues.map((issue2) => `${issue2.path.join(".")}: ${issue2.message}`).join("; ")}`);
144138
+ }
144139
+ return parsed.data;
144140
+ }
142744
144141
  function codexConfigFromOptions(options) {
142745
144142
  if (options.codexDefaultModel === void 0 && options.codexModel === void 0 && options.codexEffort === void 0 && options.codexLogin === void 0) {
142746
144143
  return void 0;
@@ -142772,8 +144169,9 @@ function registerProviderCommand(program2, deps) {
142772
144169
  new Option("--credential-target <target>", "Where the token goes: bearer sets ANTHROPIC_AUTH_TOKEN (default), apiKey sets ANTHROPIC_API_KEY.").choices(
142773
144170
  PROVIDER_CREDENTIAL_TARGETS
142774
144171
  )
142775
- ).option("--env <KEY=VALUE>", "Extra environment entry for the child (repeatable).", collectStringPair).option("--codex-default-model <model>", "Codex providers: the codex model a request maps to when no tier matches.").option("--codex-model <tier=model>", "Codex providers: the codex model one tier (fable, opus, sonnet or haiku) maps to (repeatable).", collectStringPair).addOption(new Option("--codex-effort <effort>", "Codex providers: the reasoning effort when a request asks for none the backend accepts.").choices(CODEX_EFFORTS)).addOption(new Option("--codex-login <login>", "Codex providers: which login the upstream call uses, the Codex CLI's own login or a Sign in with ChatGPT grant from `agent-shim codex login`.").choices(CODEX_LOGINS)).option("--json", "Print the result as JSON.").action((name, options) => {
144172
+ ).option("--env <KEY=VALUE>", "Extra environment entry for the child (repeatable).", collectStringPair).option("--codex-default-model <model>", "Codex providers: the codex model a request maps to when no tier matches.").option("--codex-model <tier=model>", "Codex providers: the codex model one tier (fable, opus, sonnet or haiku) maps to (repeatable).", collectStringPair).addOption(new Option("--codex-effort <effort>", "Codex providers: the reasoning effort when a request asks for none the backend accepts.").choices(CODEX_EFFORTS)).addOption(new Option("--codex-login <login>", "Codex providers: which login the upstream call uses, the Codex CLI's own login or a Sign in with ChatGPT grant from `agent-shim codex login`.").choices(CODEX_LOGINS)).addOption(new Option("--antigravity-mode <mode>", "Antigravity providers: cloud (direct Gemini/Vertex) or local (ACP daemon).").choices(ANTIGRAVITY_MODES)).option("--antigravity-default-model <model>", "Antigravity providers: the model a request maps to when no tier matches.").option("--antigravity-model <tier=model>", "Antigravity providers: the model one tier (fable, opus, sonnet or haiku) maps to (repeatable).", collectStringPair).addOption(new Option("--antigravity-effort <effort>", "Antigravity providers: reasoning effort.").choices(ANTIGRAVITY_EFFORTS)).option("--antigravity-endpoint <url>", "Antigravity cloud providers: custom API endpoint URL.").option("--antigravity-project-id <id>", "Antigravity cloud providers: Google Cloud project ID (for Vertex AI).").option("--antigravity-location <loc>", "Antigravity cloud providers: Google Cloud location (for Vertex AI).").option("--antigravity-command <cmd...>", "Antigravity local providers: command to spawn ACP server.", collectRepeated).option("--antigravity-socket <path>", "Antigravity local providers: path to existing Unix domain socket.").option("--json", "Print the result as JSON.").action((name, options) => {
142776
144173
  const codex = codexConfigFromOptions(options);
144174
+ const antigravity = antigravityConfigFromOptions(options);
142777
144175
  const created = addProvider(paths, name, {
142778
144176
  ...options.kind === void 0 ? {} : { kind: options.kind },
142779
144177
  displayName: options.displayName,
@@ -142781,7 +144179,8 @@ function registerProviderCommand(program2, deps) {
142781
144179
  sources: options.credential,
142782
144180
  ...options.credentialTarget === void 0 ? {} : { target: options.credentialTarget },
142783
144181
  ...options.env === void 0 ? {} : { env: options.env },
142784
- ...codex === void 0 ? {} : { codex }
144182
+ ...codex === void 0 ? {} : { codex },
144183
+ ...antigravity === void 0 ? {} : { antigravity }
142785
144184
  });
142786
144185
  reportMutation(options.json, { action: "created", kind: "provider", name, value: created }, () => {
142787
144186
  console.log(`Created provider "${name}" (${describeProviderEndpoint(created)}, credential ${describeCredential(created.credential)}).`);
@@ -142793,7 +144192,9 @@ function registerProviderCommand(program2, deps) {
142793
144192
  "agent-shim provider add anthropic-api --display-name Anthropic --base-url https://api.anthropic.com --credential-target apiKey --credential keychain:anthropic-api-key",
142794
144193
  "agent-shim provider add local --display-name Local --base-url http://127.0.0.1:4000 --credential literal:dummy",
142795
144194
  "agent-shim provider add codex --kind codex --display-name Codex --credential literal:codex",
142796
- "agent-shim provider add codex --kind codex --display-name Codex --credential literal:codex --codex-model sonnet=gpt-5.6-sol --codex-effort medium"
144195
+ "agent-shim provider add codex --kind codex --display-name Codex --credential literal:codex --codex-model sonnet=gpt-5.6-sol --codex-effort medium",
144196
+ "agent-shim provider add agy-cloud --kind antigravity --display-name Antigravity --credential env:GEMINI_API_KEY",
144197
+ "agent-shim provider add agy-local --kind antigravity --display-name Antigravity --antigravity-mode local --credential literal:placeholder"
142797
144198
  ]
142798
144199
  );
142799
144200
  const providerSet = provider.command("set <name>").description("Update an existing API provider definition.").option("--display-name <name>", "Replace the human-readable name.").option("--base-url <url>", "Replace the base URL (http providers only).").option(
@@ -142804,20 +144205,22 @@ function registerProviderCommand(program2, deps) {
142804
144205
  new Option("--credential-target <target>", "Where the token goes: bearer sets ANTHROPIC_AUTH_TOKEN, apiKey sets ANTHROPIC_API_KEY.").choices(
142805
144206
  PROVIDER_CREDENTIAL_TARGETS
142806
144207
  )
142807
- ).option("--env <KEY=VALUE>", "Add or replace an environment entry for the child (repeatable).", collectStringPair).option("--unset-env <KEY>", "Remove an environment entry (repeatable).", collectRepeated).option("--codex-default-model <model>", "Codex providers: replace the model a request maps to when no tier matches.").option("--codex-model <tier=model>", "Codex providers: set the codex model one tier maps to (repeatable; other tiers are kept).", collectStringPair).addOption(new Option("--codex-effort <effort>", "Codex providers: replace the default reasoning effort.").choices(CODEX_EFFORTS)).addOption(new Option("--codex-login <login>", "Codex providers: replace which login the upstream call uses.").choices(CODEX_LOGINS));
144208
+ ).option("--env <KEY=VALUE>", "Add or replace an environment entry for the child (repeatable).", collectStringPair).option("--unset-env <KEY>", "Remove an environment entry (repeatable).", collectRepeated).option("--codex-default-model <model>", "Codex providers: replace the model a request maps to when no tier matches.").option("--codex-model <tier=model>", "Codex providers: set the codex model one tier maps to (repeatable; other tiers are kept).", collectStringPair).addOption(new Option("--codex-effort <effort>", "Codex providers: replace the default reasoning effort.").choices(CODEX_EFFORTS)).addOption(new Option("--codex-login <login>", "Codex providers: replace which login the upstream call uses.").choices(CODEX_LOGINS)).addOption(new Option("--antigravity-mode <mode>", "Antigravity providers: cloud (direct Gemini/Vertex) or local (ACP daemon).").choices(ANTIGRAVITY_MODES)).option("--antigravity-default-model <model>", "Antigravity providers: the model a request maps to when no tier matches.").option("--antigravity-model <tier=model>", "Antigravity providers: set the model one tier maps to (repeatable; other tiers are kept).", collectStringPair).addOption(new Option("--antigravity-effort <effort>", "Antigravity providers: reasoning effort.").choices(ANTIGRAVITY_EFFORTS)).option("--antigravity-endpoint <url>", "Antigravity cloud providers: custom API endpoint URL.").option("--antigravity-project-id <id>", "Antigravity cloud providers: Google Cloud project ID (for Vertex AI).").option("--antigravity-location <loc>", "Antigravity cloud providers: Google Cloud location (for Vertex AI).").option("--antigravity-command <cmd...>", "Antigravity local providers: command to spawn ACP server.", collectRepeated).option("--antigravity-socket <path>", "Antigravity local providers: path to existing Unix domain socket.");
142808
144209
  addCredentialCacheOptions(providerSet);
142809
144210
  withExamples(
142810
144211
  providerSet.option("--json", "Print the result as JSON.").action((name, allOptions) => {
142811
144212
  const { json: json2, ...options } = allOptions;
142812
144213
  if (Object.entries(allOptions).every(([key, value2]) => key === "json" || value2 === void 0)) {
142813
144214
  throw new UsageError(
142814
- "Nothing to change: pass --display-name, --base-url, --credential, --credential-target, a --credential-cache option, --env, --unset-env, --codex-default-model, --codex-model, --codex-effort or --codex-login."
144215
+ "Nothing to change: pass --display-name, --base-url, --credential, --credential-target, a --credential-cache option, --env, --unset-env, or codex/antigravity settings."
142815
144216
  );
142816
144217
  }
142817
144218
  const codex = codexConfigFromOptions(options);
144219
+ const antigravity = antigravityConfigFromOptions(options);
142818
144220
  const cache = cacheChange(options, readProvider(paths, name)?.credential.cache);
142819
144221
  const updated = updateProvider(paths, name, {
142820
144222
  ...codex === void 0 ? {} : { codex },
144223
+ ...antigravity === void 0 ? {} : { antigravity },
142821
144224
  ...cache === void 0 ? {} : { cache },
142822
144225
  ...options.displayName === void 0 ? {} : { displayName: options.displayName },
142823
144226
  ...options.baseUrl === void 0 ? {} : { baseUrl: options.baseUrl },
@@ -142835,7 +144238,8 @@ function registerProviderCommand(program2, deps) {
142835
144238
  "agent-shim provider set z --env API_TIMEOUT_MS=600000",
142836
144239
  "agent-shim provider set z --credential op:op://vault/z/credential --credential-cache-ttl 12h",
142837
144240
  "agent-shim provider set anthropic-api --credential-target apiKey",
142838
- "agent-shim provider set codex --codex-model haiku=gpt-5.6-terra"
144241
+ "agent-shim provider set codex --codex-model haiku=gpt-5.6-terra",
144242
+ "agent-shim provider set agy --antigravity-model haiku=gemini-2.5-flash"
142839
144243
  ]
142840
144244
  );
142841
144245
  withExamples(
@@ -142873,6 +144277,12 @@ function registerProviderCommand(program2, deps) {
142873
144277
  console.log(`Codex models: ${CODEX_TIERS.map((tier) => `${tier}=${config2.models[tier]}`).join(", ")}, otherwise ${config2.defaultModel}`);
142874
144278
  console.log(`Codex effort: ${config2.effort}`);
142875
144279
  console.log(`Codex login: ${config2.login}`);
144280
+ } else if (isAntigravityProvider(found)) {
144281
+ const config2 = resolveAntigravityConfig(found.antigravity);
144282
+ console.log(`Antigravity mode: ${config2.mode}`);
144283
+ console.log(`Antigravity models: ${ANTIGRAVITY_TIERS.map((tier) => `${tier}=${config2.models[tier]}`).join(", ")}, otherwise ${config2.defaultModel}`);
144284
+ console.log(`Antigravity effort: ${config2.effort}`);
144285
+ console.log(`Endpoint: ${describeProviderEndpoint(found)}`);
142876
144286
  } else {
142877
144287
  console.log(`Base URL: ${found.baseUrl}`);
142878
144288
  }