claude-use 11.22.0 → 11.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -242,7 +242,7 @@ function isTimeZone(name) {
242
242
  return false;
243
243
  }
244
244
  }
245
- var import_node_path2, import_zod, import_trilean, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_TIER_MODELS, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_TIER_MODELS, CodexProviderConfigSchema, ProviderRouteSchema, HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
245
+ var import_node_path2, import_zod, import_trilean, CATEGORY_NAMES, OVERRIDABLE_CATEGORIES, CategoryMapSchema, DURATION_RE, DurationSchema, WhenConditionObjectSchema, WhenSchema, EntryValueSchema, ENTRY_KEY_RE, EntriesSchema, LaunchSchema, CREDENTIAL_TARGETS, PROVIDER_CREDENTIAL_TARGETS, CREDENTIAL_TARGET_VARS, ArgvSchema, CommandSourceOptions, EnvCredentialSourceSchema, FileCredentialSourceSchema, CommandCredentialSourceSchema, OpCredentialSourceSchema, KeychainCredentialSourceSchema, LiteralCredentialSourceSchema, CredentialSourceSchema, RemoteCredentialSourceSchema, CREDENTIAL_CACHE_STORES, CredentialCacheSchema, CredentialSchema, ProviderCredentialSchema, RESERVED_PROVIDER_ENV_KEYS, ProviderEnvSchema, PROVIDER_KINDS, ANTIGRAVITY_MODES, ANTIGRAVITY_TIERS, ANTIGRAVITY_EFFORTS, ANTIGRAVITY_DEFAULT_MODE, ANTIGRAVITY_DEFAULT_MODEL, ANTIGRAVITY_DEFAULT_TIER_MODELS, ANTIGRAVITY_DEFAULT_EFFORT, AntigravityModelTargetSchema, AntigravityProviderConfigSchema, CODEX_TIERS, CODEX_EFFORTS, CODEX_LOGINS, CODEX_DEFAULT_LOGIN, CODEX_DEFAULT_MODEL, CODEX_DEFAULT_TIER_MODELS, CODEX_DEFAULT_EFFORT, CodexProviderConfigSchema, ProviderRouteSchema, HttpProviderSchema, CodexProviderSchema, AntigravityProviderSchema, ProviderSchema, ConfigProfileSchema, POOL_SELECTOR_PREFIX, POOL_NAME_PATTERN, IDENTITY_NAME_PATTERN, PoolNameSchema, SELECTOR_RE, IdentitySelectorSchema, PoolMemberSchema, POOL_PREFERENCES, PoolPreferenceSchema, WHOLE_PERCENT_MAX, CompactAtUtilisationSchema, PoolSchema, WEEKDAYS, AnchorSchema, JOB_WINDOWS, JobTriggerSchema, JobTargetSchema, JobSchema, DirectoryRuleSchema, DirectoryRulesSchema, PortableConfigSchema, HEADROOM_MODES, HEADROOM_CCR_MODES, HEADROOM_ROLLOUT_CHANNELS, INTERCEPT_CHANNELS, READ_MATURATION_CHANNELS, HeadroomGlobalConfigObjectSchema, HeadroomGlobalConfigSchema, HEADROOM_DEFAULT_SOURCE, HEADROOM_DEFAULT_IDLE_SHUTDOWN_MINUTES, FrontDoorGlobalConfigSchema, UPDATE_MODES, UpdateGlobalConfigSchema, GlobalConfigSchema, IdentitySchema, CategoryClassificationSchema, CategoryClassificationOverlaySchema, SHIPPED_CATEGORY_DEFAULTS;
246
246
  var init_schema = __esm({
247
247
  "src/config/schema.ts"() {
248
248
  "use strict";
@@ -343,14 +343,17 @@ var init_schema = __esm({
343
343
  });
344
344
  PROVIDER_KINDS = ["http", "codex", "antigravity"];
345
345
  ANTIGRAVITY_MODES = ["cloud", "local"];
346
+ ANTIGRAVITY_TIERS = ["fable", "opus", "sonnet", "haiku"];
346
347
  ANTIGRAVITY_EFFORTS = ["none", "low", "medium", "high", "xhigh", "max"];
347
348
  ANTIGRAVITY_DEFAULT_MODE = "cloud";
349
+ ANTIGRAVITY_DEFAULT_MODEL = "gemini-3.8-flash-high";
348
350
  ANTIGRAVITY_DEFAULT_TIER_MODELS = Object.freeze({
349
351
  fable: ["gemini-4-argon-high", "claude-opus-5-5-high", "gemini-3.8-flash-high"],
350
352
  opus: ["claude-opus-5-5-high", "gemini-4-argon-high", "gemini-3.8-flash-high"],
351
353
  sonnet: ["claude-sonnet-5-5-medium", "gemini-4-argon-medium", "gemini-3.8-flash-medium"],
352
354
  haiku: ["gemini-3.8-flash-low", "gemini-4-argon-low", "claude-sonnet-5-5-low"]
353
355
  });
356
+ ANTIGRAVITY_DEFAULT_EFFORT = "low";
354
357
  AntigravityModelTargetSchema = import_zod.z.union([import_zod.z.string().min(1), import_zod.z.array(import_zod.z.string().min(1)).min(1)]);
355
358
  AntigravityProviderConfigSchema = import_zod.z.strictObject({
356
359
  /** Operational mode: direct cloud endpoint or local ACP daemon. Defaults to `cloud`. */
@@ -380,14 +383,18 @@ var init_schema = __esm({
380
383
  socketPath: import_zod.z.string().min(1).optional()
381
384
  }).optional()
382
385
  });
386
+ CODEX_TIERS = ["fable", "opus", "sonnet", "haiku"];
383
387
  CODEX_EFFORTS = ["none", "low", "medium", "high"];
384
388
  CODEX_LOGINS = ["codex-cli", "chatgpt-sign-in"];
389
+ CODEX_DEFAULT_LOGIN = "codex-cli";
390
+ CODEX_DEFAULT_MODEL = "gpt-5.6-sol";
385
391
  CODEX_DEFAULT_TIER_MODELS = Object.freeze({
386
392
  fable: "gpt-5.6-sol",
387
393
  opus: "gpt-5.6-sol",
388
394
  sonnet: "gpt-5.6-terra",
389
395
  haiku: "gpt-5.6-luna"
390
396
  });
397
+ CODEX_DEFAULT_EFFORT = "low";
391
398
  CodexProviderConfigSchema = import_zod.z.strictObject({
392
399
  /** The codex model a request maps to when no tier matches its model name. */
393
400
  defaultModel: import_zod.z.string().min(1).optional(),
@@ -624,7 +631,7 @@ function parseIgnoringUnrecognisedKeys(schema, raw) {
624
631
  return second.success ? { success: true, data: second.data, ignored } : { success: false, issues: second.error.issues };
625
632
  }
626
633
  function describeIgnoredKeys(filePath, ignored) {
627
- const places = ignored.map(({ path: path41, keys }) => `${path41.length === 0 ? "" : `${path41.map(String).join(".")}.`}${keys.join(", ")}`);
634
+ const places = ignored.map(({ path: path42, keys }) => `${path42.length === 0 ? "" : `${path42.map(String).join(".")}.`}${keys.join(", ")}`);
628
635
  return `${filePath} has settings this version of agent-shim does not know and ignores: ${places.join("; ")}. A newer release may read them.`;
629
636
  }
630
637
  function noteIgnoredKeys(filePath, ignored) {
@@ -646,9 +653,9 @@ function restoreIgnoredKeys(filePath, value) {
646
653
  return value;
647
654
  }
648
655
  const restored = structuredClone(value);
649
- for (const { path: path41, values } of ignored) {
656
+ for (const { path: path42, values } of ignored) {
650
657
  let holder = restored;
651
- for (const step of path41) {
658
+ for (const step of path42) {
652
659
  holder = isRecord(holder) ? holder[step] : void 0;
653
660
  }
654
661
  if (isRecord(holder)) {
@@ -2928,7 +2935,7 @@ var init_package = __esm({
2928
2935
  "package.json"() {
2929
2936
  package_default = {
2930
2937
  name: "claude-use",
2931
- version: "11.22.0",
2938
+ version: "11.24.0",
2932
2939
  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.",
2933
2940
  license: "MIT",
2934
2941
  author: "Joseph Mearman <joseph@mearman.co.uk>",
@@ -6733,6 +6740,49 @@ var init_providersStore = __esm({
6733
6740
  }
6734
6741
  });
6735
6742
 
6743
+ // src/usage/signIn.ts
6744
+ function claudeCodeKeychainService(configDir) {
6745
+ return `${KEYCHAIN_SERVICE_PREFIX}-${(0, import_node_crypto9.createHash)("sha256").update(configDir).digest("hex").slice(0, KEYCHAIN_SERVICE_HASH_DIGITS)}`;
6746
+ }
6747
+ function keychainHasItem(run, configDir) {
6748
+ return run.run("security", ["find-generic-password", "-s", claudeCodeKeychainService(configDir)]).status === 0;
6749
+ }
6750
+ function decideSignIn(facts) {
6751
+ if (facts.hasCredentialBlock) {
6752
+ return { state: "token", detail: "supplies its own credential through a credential block, so a stored login is not what a launch uses" };
6753
+ }
6754
+ if (facts.keychainItem === true) {
6755
+ return { state: "signed-in", detail: "a login is stored in the macOS Keychain" };
6756
+ }
6757
+ if (facts.credentialsFile) {
6758
+ return { state: "signed-in", detail: `a login is stored in ${CREDENTIALS_FILE}` };
6759
+ }
6760
+ return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
6761
+ }
6762
+ function credentialsFilePath(farmRoot) {
6763
+ return import_node_path26.default.join(farmRoot, CREDENTIALS_FILE);
6764
+ }
6765
+ function identitySignIn(fs13, probe, identity) {
6766
+ const probing = !identity.hasCredentialBlock;
6767
+ return decideSignIn({
6768
+ hasCredentialBlock: identity.hasCredentialBlock,
6769
+ keychainItem: probing && probe.platform === "darwin" && probe.run !== void 0 ? keychainHasItem(probe.run, identity.farmRoot) : void 0,
6770
+ credentialsFile: probing && fs13.lstat(credentialsFilePath(identity.farmRoot)) !== void 0,
6771
+ platform: probe.platform
6772
+ });
6773
+ }
6774
+ var import_node_crypto9, import_node_path26, CREDENTIALS_FILE, KEYCHAIN_SERVICE_PREFIX, KEYCHAIN_SERVICE_HASH_DIGITS;
6775
+ var init_signIn = __esm({
6776
+ "src/usage/signIn.ts"() {
6777
+ "use strict";
6778
+ import_node_crypto9 = require("node:crypto");
6779
+ import_node_path26 = __toESM(require("node:path"), 1);
6780
+ CREDENTIALS_FILE = ".credentials.json";
6781
+ KEYCHAIN_SERVICE_PREFIX = "Claude Code-credentials";
6782
+ KEYCHAIN_SERVICE_HASH_DIGITS = 8;
6783
+ }
6784
+ });
6785
+
6736
6786
  // src/cli/bool.ts
6737
6787
  function parseBoolWord(input) {
6738
6788
  switch (input) {
@@ -6886,10 +6936,10 @@ function commandFilename(ownExecutablePath, commandName) {
6886
6936
  }
6887
6937
  function resolveOwnBinaryCheck(paths, contentSourcePath) {
6888
6938
  const state = readJson(paths.claudeShimFile, ClaudeShimStateSchema);
6889
- const recordedTarget = state === void 0 ? void 0 : import_node_path27.default.resolve(state.targetPath);
6939
+ const recordedTarget = state === void 0 ? void 0 : import_node_path28.default.resolve(state.targetPath);
6890
6940
  let ownStat;
6891
6941
  return (candidate) => {
6892
- if (recordedTarget !== void 0 && import_node_path27.default.resolve(candidate) === recordedTarget) {
6942
+ if (recordedTarget !== void 0 && import_node_path28.default.resolve(candidate) === recordedTarget) {
6893
6943
  return true;
6894
6944
  }
6895
6945
  ownStat ??= statOrUndefined(contentSourcePath);
@@ -6912,22 +6962,22 @@ function statOrUndefined(target) {
6912
6962
  }
6913
6963
  }
6914
6964
  function findPathShadow(params) {
6915
- const resolvedTargetDir = import_node_path27.default.resolve(params.targetDir);
6965
+ const resolvedTargetDir = import_node_path28.default.resolve(params.targetDir);
6916
6966
  for (const dir of params.pathDirs) {
6917
6967
  const found = params.findExecutableInDir(dir, params.targetFilename);
6918
6968
  if (found === void 0) {
6919
6969
  continue;
6920
6970
  }
6921
- return import_node_path27.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
6971
+ return import_node_path28.default.resolve(dir) === resolvedTargetDir ? { status: "ok" } : { status: "shadowed", by: found };
6922
6972
  }
6923
- return params.pathDirs.some((dir) => import_node_path27.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
6973
+ return params.pathDirs.some((dir) => import_node_path28.default.resolve(dir) === resolvedTargetDir) ? { status: "ok" } : { status: "not-on-path" };
6924
6974
  }
6925
- var import_node_fs7, import_node_path27, import_zod19, ClaudeShimStateSchema, nodeLinkFs;
6975
+ var import_node_fs7, import_node_path28, import_zod19, ClaudeShimStateSchema, nodeLinkFs;
6926
6976
  var init_claudeShim = __esm({
6927
6977
  "src/claudeShim.ts"() {
6928
6978
  "use strict";
6929
6979
  import_node_fs7 = __toESM(require("node:fs"), 1);
6930
- import_node_path27 = __toESM(require("node:path"), 1);
6980
+ import_node_path28 = __toESM(require("node:path"), 1);
6931
6981
  import_zod19 = require("zod");
6932
6982
  init_commandDeps();
6933
6983
  init_store();
@@ -7128,7 +7178,7 @@ function ensureFrontDoor(params) {
7128
7178
  if (supervisorPid !== void 0 && !distrusted.has(supervisorPid) && ports.isRunning(supervisorPid)) {
7129
7179
  if (state?.port !== void 0 && state.connectPort !== void 0) {
7130
7180
  if (supervisorPid === params.launcherPid && params.replace !== true && ports.isFrontDoorSupervisor(supervisorPid)) {
7131
- const token = (0, import_node_crypto9.randomUUID)();
7181
+ const token = (0, import_node_crypto10.randomUUID)();
7132
7182
  writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid });
7133
7183
  return { port: state.port, connectPort: state.connectPort, token };
7134
7184
  }
@@ -7142,7 +7192,7 @@ function ensureFrontDoor(params) {
7142
7192
  continue;
7143
7193
  }
7144
7194
  if (verdict.ok) {
7145
- const token = (0, import_node_crypto9.randomUUID)();
7195
+ const token = (0, import_node_crypto10.randomUUID)();
7146
7196
  writeFrontDoorSession(ports.fs, paths.frontdoorSessionsDir, { pid: params.launcherPid, startedAt: ports.now(), token, supervisorPid });
7147
7197
  return { port: state.port, connectPort: state.connectPort, token };
7148
7198
  }
@@ -7195,11 +7245,11 @@ function ensureFrontDoor(params) {
7195
7245
  ports.sleep(FRONTDOOR_LAUNCHER_POLL_MS);
7196
7246
  }
7197
7247
  }
7198
- var import_node_crypto9, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FRONTDOOR_PROBE_ATTEMPTS, FRONTDOOR_EXIT_GRACE_MS, FrontDoorStartError;
7248
+ var import_node_crypto10, FRONTDOOR_START_TIMEOUT_MS, FRONTDOOR_LAUNCHER_POLL_MS, FRONTDOOR_PROBE_ATTEMPTS, FRONTDOOR_EXIT_GRACE_MS, FrontDoorStartError;
7199
7249
  var init_ensure2 = __esm({
7200
7250
  "src/frontdoor/ensure.ts"() {
7201
7251
  "use strict";
7202
- import_node_crypto9 = require("node:crypto");
7252
+ import_node_crypto10 = require("node:crypto");
7203
7253
  init_cliError();
7204
7254
  init_state2();
7205
7255
  init_state();
@@ -7580,7 +7630,7 @@ function buildEnv(params) {
7580
7630
  }
7581
7631
  }
7582
7632
  if (params.provider !== void 0) {
7583
- env.ANTHROPIC_AUTH_TOKEN = void 0;
7633
+ env.ANTHROPIC_AUTH_TOKEN = params.remoteControl ? void 0 : PROVIDER_SESSION_PLACEHOLDER;
7584
7634
  env.ANTHROPIC_API_KEY = void 0;
7585
7635
  env.CLAUDE_CODE_OAUTH_TOKEN = void 0;
7586
7636
  } else if (params.identityCredential !== void 0) {
@@ -7612,7 +7662,7 @@ function buildEnv(params) {
7612
7662
  }
7613
7663
  return env;
7614
7664
  }
7615
- var import_node_path36, LOOPBACK_HOSTS;
7665
+ var import_node_path36, LOOPBACK_HOSTS, PROVIDER_SESSION_PLACEHOLDER;
7616
7666
  var init_flags = __esm({
7617
7667
  "src/launcher/flags.ts"() {
7618
7668
  "use strict";
@@ -7623,6 +7673,7 @@ var init_flags = __esm({
7623
7673
  init_capability();
7624
7674
  init_route();
7625
7675
  LOOPBACK_HOSTS = ["127.0.0.1", "localhost", "::1"];
7676
+ PROVIDER_SESSION_PLACEHOLDER = "agent-shim-provider-session";
7626
7677
  }
7627
7678
  });
7628
7679
 
@@ -7752,13 +7803,43 @@ function withConversation(passthrough, conversation, id) {
7752
7803
  }
7753
7804
  return [...kept, conversation === "start" ? "--session-id" : "--resume", id, ...tail];
7754
7805
  }
7806
+ function hasSettingsArgument(passthrough) {
7807
+ const end = passthrough.indexOf(TERMINATOR2);
7808
+ return (end === -1 ? passthrough : passthrough.slice(0, end)).some((token) => token === "--settings" || token.startsWith("--settings="));
7809
+ }
7755
7810
  function withSupervision(passthrough, supervised) {
7756
- const conversation = supervised.conversation === "as-given" ? passthrough : withConversation(passthrough, supervised.conversation, supervised.sessionId);
7757
- if (supervised.settings === void 0) {
7758
- return conversation;
7811
+ return supervised.conversation === "as-given" ? passthrough : withConversation(passthrough, supervised.conversation, supervised.sessionId);
7812
+ }
7813
+ function withLauncherSettings(passthrough, settings) {
7814
+ if (settings === void 0) {
7815
+ return passthrough;
7759
7816
  }
7760
- const end = conversation.indexOf(TERMINATOR2);
7761
- return end === -1 ? [...conversation, "--settings", supervised.settings] : [...conversation.slice(0, end), "--settings", supervised.settings, ...conversation.slice(end)];
7817
+ const end = passthrough.indexOf(TERMINATOR2);
7818
+ return end === -1 ? [...passthrough, "--settings", settings] : [...passthrough.slice(0, end), "--settings", settings, ...passthrough.slice(end)];
7819
+ }
7820
+ function isRecord15(value) {
7821
+ return typeof value === "object" && value !== null && !Array.isArray(value);
7822
+ }
7823
+ function mergeSettings(parts) {
7824
+ const merged = {};
7825
+ let any = false;
7826
+ for (const part of parts) {
7827
+ if (part === void 0) {
7828
+ continue;
7829
+ }
7830
+ const parsed = JSON.parse(part);
7831
+ if (!isRecord15(parsed)) {
7832
+ throw new Error("a launch's settings part is not a JSON object");
7833
+ }
7834
+ for (const [key, value] of Object.entries(parsed)) {
7835
+ if (key in merged) {
7836
+ throw new Error(`two launch settings parts both set "${key}"`);
7837
+ }
7838
+ merged[key] = value;
7839
+ }
7840
+ any = true;
7841
+ }
7842
+ return any ? JSON.stringify(merged) : void 0;
7762
7843
  }
7763
7844
  var TERMINATOR2, VALUED_CONVERSATION_FLAGS, CONTINUE_FLAGS;
7764
7845
  var init_claudeSession = __esm({
@@ -7771,6 +7852,253 @@ var init_claudeSession = __esm({
7771
7852
  }
7772
7853
  });
7773
7854
 
7855
+ // src/antigravity/cloudUpstream.ts
7856
+ var init_cloudUpstream = __esm({
7857
+ "src/antigravity/cloudUpstream.ts"() {
7858
+ "use strict";
7859
+ }
7860
+ });
7861
+
7862
+ // src/antigravity/quota.ts
7863
+ var SECONDS_PER_HOUR, HOURS_PER_FIVE_HOUR_WINDOW, DAYS_PER_WEEK, HOURS_PER_DAY4, FIVE_HOUR_PERIOD_SECONDS, WEEK_PERIOD_SECONDS;
7864
+ var init_quota = __esm({
7865
+ "src/antigravity/quota.ts"() {
7866
+ "use strict";
7867
+ init_cloudUpstream();
7868
+ SECONDS_PER_HOUR = 3600;
7869
+ HOURS_PER_FIVE_HOUR_WINDOW = 5;
7870
+ DAYS_PER_WEEK = 7;
7871
+ HOURS_PER_DAY4 = 24;
7872
+ FIVE_HOUR_PERIOD_SECONDS = HOURS_PER_FIVE_HOUR_WINDOW * SECONDS_PER_HOUR;
7873
+ WEEK_PERIOD_SECONDS = DAYS_PER_WEEK * HOURS_PER_DAY4 * SECONDS_PER_HOUR;
7874
+ }
7875
+ });
7876
+
7877
+ // src/antigravity/signatures.ts
7878
+ var init_signatures = __esm({
7879
+ "src/antigravity/signatures.ts"() {
7880
+ "use strict";
7881
+ }
7882
+ });
7883
+
7884
+ // src/codex/anthropic.ts
7885
+ var import_zod29, TextBlockSchema, Base64ImageSourceSchema, UrlImageSourceSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultContentBlockSchema, ToolResultBlockSchema, OtherBlockSchema, ContentBlockSchema, MessageSchema, ToolSchema, ToolChoiceSchema, SystemSchema, MessagesRequestSchema, CountTokensRequestSchema;
7886
+ var init_anthropic = __esm({
7887
+ "src/codex/anthropic.ts"() {
7888
+ "use strict";
7889
+ import_zod29 = require("zod");
7890
+ TextBlockSchema = import_zod29.z.looseObject({ type: import_zod29.z.literal("text"), text: import_zod29.z.string() });
7891
+ Base64ImageSourceSchema = import_zod29.z.looseObject({ type: import_zod29.z.literal("base64"), media_type: import_zod29.z.string().min(1), data: import_zod29.z.string() });
7892
+ UrlImageSourceSchema = import_zod29.z.looseObject({ type: import_zod29.z.literal("url"), url: import_zod29.z.string().min(1) });
7893
+ ImageBlockSchema = import_zod29.z.looseObject({
7894
+ type: import_zod29.z.literal("image"),
7895
+ source: import_zod29.z.union([Base64ImageSourceSchema, UrlImageSourceSchema])
7896
+ });
7897
+ ToolUseBlockSchema = import_zod29.z.looseObject({
7898
+ type: import_zod29.z.literal("tool_use"),
7899
+ id: import_zod29.z.string().min(1),
7900
+ name: import_zod29.z.string().min(1),
7901
+ input: import_zod29.z.unknown()
7902
+ });
7903
+ ToolResultContentBlockSchema = import_zod29.z.union([TextBlockSchema, import_zod29.z.looseObject({ type: import_zod29.z.string() })]);
7904
+ ToolResultBlockSchema = import_zod29.z.looseObject({
7905
+ type: import_zod29.z.literal("tool_result"),
7906
+ tool_use_id: import_zod29.z.string().min(1),
7907
+ content: import_zod29.z.union([import_zod29.z.string(), import_zod29.z.array(ToolResultContentBlockSchema)]).optional()
7908
+ });
7909
+ OtherBlockSchema = import_zod29.z.looseObject({ type: import_zod29.z.string() });
7910
+ ContentBlockSchema = import_zod29.z.union([TextBlockSchema, ImageBlockSchema, ToolUseBlockSchema, ToolResultBlockSchema, OtherBlockSchema]);
7911
+ MessageSchema = import_zod29.z.looseObject({
7912
+ role: import_zod29.z.enum(["user", "assistant", "system"]),
7913
+ content: import_zod29.z.union([import_zod29.z.string(), import_zod29.z.array(ContentBlockSchema)])
7914
+ });
7915
+ ToolSchema = import_zod29.z.looseObject({
7916
+ name: import_zod29.z.string().min(1),
7917
+ description: import_zod29.z.string().optional(),
7918
+ input_schema: import_zod29.z.record(import_zod29.z.string(), import_zod29.z.unknown()).optional()
7919
+ });
7920
+ ToolChoiceSchema = import_zod29.z.union([
7921
+ import_zod29.z.looseObject({ type: import_zod29.z.enum(["auto", "none", "any"]) }),
7922
+ import_zod29.z.looseObject({ type: import_zod29.z.literal("tool"), name: import_zod29.z.string().min(1) })
7923
+ ]);
7924
+ SystemSchema = import_zod29.z.union([import_zod29.z.string(), import_zod29.z.array(import_zod29.z.union([TextBlockSchema, OtherBlockSchema]))]);
7925
+ MessagesRequestSchema = import_zod29.z.looseObject({
7926
+ model: import_zod29.z.string().optional(),
7927
+ system: SystemSchema.optional(),
7928
+ messages: import_zod29.z.array(MessageSchema),
7929
+ tools: import_zod29.z.array(ToolSchema).optional(),
7930
+ tool_choice: ToolChoiceSchema.optional(),
7931
+ stream: import_zod29.z.boolean().optional(),
7932
+ /** `user_id` is stable for one Claude Code session and differs between sessions, which is what makes it the right key for both the backend's prompt cache and its session header. */
7933
+ metadata: import_zod29.z.looseObject({ user_id: import_zod29.z.string().optional() }).optional(),
7934
+ /** Claude Code's effort setting. Any string is accepted; the translator honours only the levels the backend understands. */
7935
+ output_config: import_zod29.z.looseObject({ effort: import_zod29.z.string().optional() }).optional()
7936
+ });
7937
+ CountTokensRequestSchema = import_zod29.z.looseObject({
7938
+ system: import_zod29.z.unknown().optional(),
7939
+ messages: import_zod29.z.unknown().optional(),
7940
+ tools: import_zod29.z.unknown().optional()
7941
+ });
7942
+ }
7943
+ });
7944
+
7945
+ // src/antigravity/translate.ts
7946
+ function candidatesOf(target) {
7947
+ return typeof target === "string" ? [target] : target;
7948
+ }
7949
+ function isAntigravityTier(key) {
7950
+ return ANTIGRAVITY_TIERS.some((tier) => tier === key);
7951
+ }
7952
+ function resolveAntigravityConfig(config) {
7953
+ const overrides = config?.models ?? {};
7954
+ const aliases = /* @__PURE__ */ new Map();
7955
+ for (const [key, target] of Object.entries(overrides)) {
7956
+ if (!isAntigravityTier(key)) {
7957
+ aliases.set(key.toLowerCase(), candidatesOf(target));
7958
+ }
7959
+ }
7960
+ const tierModel = (tier) => {
7961
+ const target = overrides[tier];
7962
+ return target === void 0 ? ANTIGRAVITY_DEFAULT_TIER_MODELS[tier] : candidatesOf(target);
7963
+ };
7964
+ return {
7965
+ mode: config?.mode ?? ANTIGRAVITY_DEFAULT_MODE,
7966
+ defaultModel: config?.defaultModel ?? ANTIGRAVITY_DEFAULT_MODEL,
7967
+ models: { fable: tierModel("fable"), opus: tierModel("opus"), sonnet: tierModel("sonnet"), haiku: tierModel("haiku") },
7968
+ aliases,
7969
+ degradeDownTiers: config?.degradeDownTiers ?? false,
7970
+ effort: config?.effort ?? ANTIGRAVITY_DEFAULT_EFFORT,
7971
+ cloud: {
7972
+ endpoint: config?.cloud?.endpoint,
7973
+ projectId: config?.cloud?.projectId,
7974
+ location: config?.cloud?.location
7975
+ },
7976
+ local: {
7977
+ command: config?.local?.command,
7978
+ socketPath: config?.local?.socketPath
7979
+ }
7980
+ };
7981
+ }
7982
+ var init_translate = __esm({
7983
+ "src/antigravity/translate.ts"() {
7984
+ "use strict";
7985
+ init_quota();
7986
+ init_signatures();
7987
+ init_schema();
7988
+ init_anthropic();
7989
+ }
7990
+ });
7991
+
7992
+ // src/codex/translate.ts
7993
+ function resolveCodexConfig(config) {
7994
+ const overrides = config?.models;
7995
+ return {
7996
+ defaultModel: config?.defaultModel ?? CODEX_DEFAULT_MODEL,
7997
+ models: {
7998
+ fable: overrides?.fable ?? CODEX_DEFAULT_TIER_MODELS.fable,
7999
+ opus: overrides?.opus ?? CODEX_DEFAULT_TIER_MODELS.opus,
8000
+ sonnet: overrides?.sonnet ?? CODEX_DEFAULT_TIER_MODELS.sonnet,
8001
+ haiku: overrides?.haiku ?? CODEX_DEFAULT_TIER_MODELS.haiku
8002
+ },
8003
+ effort: config?.effort ?? CODEX_DEFAULT_EFFORT,
8004
+ login: config?.login ?? CODEX_DEFAULT_LOGIN
8005
+ };
8006
+ }
8007
+ var init_translate2 = __esm({
8008
+ "src/codex/translate.ts"() {
8009
+ "use strict";
8010
+ init_schema();
8011
+ init_anthropic();
8012
+ }
8013
+ });
8014
+
8015
+ // src/launcher/modelPicker.ts
8016
+ function joined(parts) {
8017
+ const last = parts[parts.length - 1];
8018
+ return last === void 0 || parts.length === 1 ? last ?? "" : `${parts.slice(0, -1).join(", ")} and ${last}`;
8019
+ }
8020
+ function rowOf2(model, reaches) {
8021
+ const lead = reaches.find((reach) => reach.standing === "first") ?? reaches[0];
8022
+ if (lead === void 0) {
8023
+ throw new Error(`model ${model} is reached by no tier`);
8024
+ }
8025
+ const firsts = reaches.filter((reach) => reach.standing === "first").map((reach) => reach.tier);
8026
+ const fallbacks = reaches.filter((reach) => reach.standing === "fallback").map((reach) => reach.tier);
8027
+ const serves = firsts.length === 0 ? [] : [`Serves the ${joined(firsts)} tier${firsts.length === 1 ? "" : "s"}`];
8028
+ const falls = fallbacks.length === 0 ? [] : [`${serves.length === 0 ? "Fallback" : "fallback"} for ${joined(fallbacks)}`];
8029
+ return { model, label: model, description: [...serves, ...falls].join("; "), behavesAs: TIER_BEHAVES_AS[lead.tier] };
8030
+ }
8031
+ function rowsOfTable(table) {
8032
+ const reachesByModel = /* @__PURE__ */ new Map();
8033
+ for (const [tier, candidates] of table) {
8034
+ candidates.forEach((model, index) => {
8035
+ const reaches = reachesByModel.get(model) ?? [];
8036
+ if (!reaches.some((reach) => reach.tier === tier)) {
8037
+ reaches.push({ tier, standing: index === 0 ? "first" : "fallback" });
8038
+ }
8039
+ reachesByModel.set(model, reaches);
8040
+ });
8041
+ }
8042
+ return [...reachesByModel].map(([model, reaches]) => rowOf2(model, reaches));
8043
+ }
8044
+ function antigravityRows(provider) {
8045
+ const config = resolveAntigravityConfig(provider.antigravity);
8046
+ const tiers = rowsOfTable(ANTIGRAVITY_TIERS.map((tier) => [tier, config.models[tier]]));
8047
+ const behavesAsOf = new Map(tiers.map((row) => [row.model, row.behavesAs]));
8048
+ const aliases = [...config.aliases].flatMap(([alias, candidates]) => {
8049
+ const [first] = candidates;
8050
+ const behavesAs = first === void 0 ? void 0 : behavesAsOf.get(first);
8051
+ return behavesAs === void 0 ? [] : [{ model: alias, label: alias, description: `Alias for ${candidates.join(", then ")}`, behavesAs }];
8052
+ });
8053
+ return [...tiers, ...aliases];
8054
+ }
8055
+ function codexRows(provider) {
8056
+ const config = resolveCodexConfig(provider.codex);
8057
+ return rowsOfTable(CODEX_TIERS.map((tier) => [tier, [config.models[tier]]]));
8058
+ }
8059
+ function httpRows(provider) {
8060
+ const env = provider.env ?? {};
8061
+ const table = CODEX_TIERS.flatMap((tier) => {
8062
+ const model = env[TIER_ENV_VARIABLES[tier]];
8063
+ return model === void 0 || model === "" ? [] : [[tier, [model]]];
8064
+ });
8065
+ return rowsOfTable(table);
8066
+ }
8067
+ function providerModelRows(provider) {
8068
+ if (provider.kind === "codex") {
8069
+ return codexRows(provider);
8070
+ }
8071
+ if (provider.kind === "antigravity") {
8072
+ return antigravityRows(provider);
8073
+ }
8074
+ return httpRows(provider);
8075
+ }
8076
+ function modelPickerSettings(provider) {
8077
+ const options = providerModelRows(provider);
8078
+ return options.length === 0 ? void 0 : JSON.stringify({ modelPicker: { options, replaceBuiltInOptions: true } });
8079
+ }
8080
+ var TIER_BEHAVES_AS, TIER_ENV_VARIABLES;
8081
+ var init_modelPicker = __esm({
8082
+ "src/launcher/modelPicker.ts"() {
8083
+ "use strict";
8084
+ init_translate();
8085
+ init_translate2();
8086
+ init_schema();
8087
+ TIER_BEHAVES_AS = Object.freeze({
8088
+ fable: "claude-fable-5-1",
8089
+ opus: "claude-opus-5-5",
8090
+ sonnet: "claude-sonnet-5-5",
8091
+ haiku: "claude-haiku-5-5"
8092
+ });
8093
+ TIER_ENV_VARIABLES = Object.freeze({
8094
+ fable: "ANTHROPIC_DEFAULT_FABLE_MODEL",
8095
+ opus: "ANTHROPIC_DEFAULT_OPUS_MODEL",
8096
+ sonnet: "ANTHROPIC_DEFAULT_SONNET_MODEL",
8097
+ haiku: "ANTHROPIC_DEFAULT_HAIKU_MODEL"
8098
+ });
8099
+ }
8100
+ });
8101
+
7774
8102
  // src/launcher/pool.ts
7775
8103
  function isResuming(passthrough) {
7776
8104
  const end = passthrough.indexOf(TERMINATOR3);
@@ -8180,7 +8508,7 @@ function decideLaunch(params, readOnly) {
8180
8508
  }
8181
8509
  const pinnedVersion = resolveClaudeVersion({ env, ...parsedArgv.claudeVersion === void 0 ? {} : { flag: parsedArgv.claudeVersion }, ...cascadeLaunch?.claudeVersion === void 0 ? {} : { cascade: cascadeLaunch.claudeVersion } });
8182
8510
  const discovered = params.resolveClaudeBinary(pinnedVersion === void 0 ? void 0 : { version: pinnedVersion.version });
8183
- const flags = resolveLaunchFlags({
8511
+ const requestedFlags = resolveLaunchFlags({
8184
8512
  env,
8185
8513
  ...cascadeLaunch === void 0 ? {} : { cascade: cascadeLaunch },
8186
8514
  flags: {
@@ -8190,10 +8518,21 @@ function decideLaunch(params, readOnly) {
8190
8518
  ...parsedArgv.trackUsage === void 0 ? {} : { trackUsage: parsedArgv.trackUsage }
8191
8519
  }
8192
8520
  });
8521
+ const loginlessProvider = requestedFlags.remoteControl && selectedProvider !== void 0 && farmIdentity !== void 0 && params.hasStoredLogin?.(farmIdentity) === false ? { identity: farmIdentity, provider: selectedProvider.name } : void 0;
8522
+ if (loginlessProvider !== void 0 && !readOnly) {
8523
+ log.info(`agent-shim: identity ${loginlessProvider.identity} has no stored login, so Remote Control, which needs one, is off for this launch; provider ${loginlessProvider.provider} runs without it`);
8524
+ }
8525
+ const flags = loginlessProvider === void 0 ? requestedFlags : { ...requestedFlags, remoteControl: false };
8526
+ const pickerSettings = selectedProvider === void 0 ? void 0 : modelPickerSettings(selectedProvider.definition);
8527
+ const callerSettings = hasSettingsArgument(parsedArgv.rest);
8528
+ if (pickerSettings !== void 0 && callerSettings && !readOnly) {
8529
+ log.info("agent-shim: this launch passes its own --settings, so /model keeps Claude Code's own model names instead of listing the provider's models");
8530
+ }
8531
+ const launcherSettings = mergeSettings([params.supervised?.settings, callerSettings ? void 0 : pickerSettings]);
8193
8532
  const args = buildArgv({
8194
8533
  toolFlags: buildFlagArgs(flags),
8195
8534
  extraFlags: splitExtraFlags(env.CLAUDE_EXTRA_FLAGS),
8196
- passthrough: params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised)
8535
+ passthrough: withLauncherSettings(params.supervised === void 0 ? parsedArgv.rest : withSupervision(parsedArgv.rest, params.supervised), launcherSettings)
8197
8536
  });
8198
8537
  const configDir = configDirEscapeHatchApplies || identityDecision.name === void 0 ? env.CLAUDE_CONFIG_DIR : import_node_path38.default.join(paths.identitiesDir, identityDecision.name);
8199
8538
  const decision = {
@@ -8305,7 +8644,7 @@ function prepareLaunch(params) {
8305
8644
  log.info(`agent-shim: routing through the front door on 127.0.0.1:${String(frontDoor.port)}${resolvedProvider === void 0 ? ` (OAuth via the door's CONNECT surface on 127.0.0.1:${String(frontDoor.connectPort)}, usage recorded)` : ` (provider ${resolvedProvider.name})`}`);
8306
8645
  }
8307
8646
  const frontDoorRelease = frontDoor === void 0 ? void 0 : frontDoorPort?.release;
8308
- const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto10.randomUUID)();
8647
+ const sessionId = params.supervised?.sessionId ?? (0, import_node_crypto11.randomUUID)();
8309
8648
  const finalEnv = buildEnv({
8310
8649
  baseEnv: env,
8311
8650
  configDirEscapeHatch: configDirEscapeHatchApplies,
@@ -8315,7 +8654,8 @@ function prepareLaunch(params) {
8315
8654
  ...identityCredential === void 0 ? {} : { identityCredential },
8316
8655
  ...frontDoor === void 0 ? {} : { frontdoor: frontDoor },
8317
8656
  ...headroom === void 0 ? {} : { headroom },
8318
- sessionId
8657
+ sessionId,
8658
+ remoteControl: resolvedFlags.remoteControl
8319
8659
  });
8320
8660
  const releases = [...headroom === void 0 || headroomPort === void 0 ? [] : [headroomPort.release], ...frontDoorRelease === void 0 ? [] : [frontDoorRelease]];
8321
8661
  const release = () => {
@@ -8337,7 +8677,8 @@ function resolveLaunch(params) {
8337
8677
  ...decided.provider === void 0 ? {} : { provider: decided.provider },
8338
8678
  ...frontDoor ? { frontdoor: { port: 0, connectPort: 0, trustBundlePath: "", sessionToken: "" } } : {},
8339
8679
  ...decided.flags.headroom ? { headroom: { socketPath: "", projectId: "" } } : {},
8340
- sessionId: ""
8680
+ sessionId: "",
8681
+ remoteControl: decided.flags.remoteControl
8341
8682
  });
8342
8683
  const credentialNames = decided.identityCredentialBlock === void 0 ? [] : Object.keys(credentialVariables(decided.identityCredentialBlock.target ?? "bearer", ""));
8343
8684
  const environment = [.../* @__PURE__ */ new Set([...Object.keys(built).filter((name) => built[name] !== env[name]), ...credentialNames])].sort();
@@ -8368,11 +8709,11 @@ function runLaunchPlan(plan, spawn3) {
8368
8709
  function runLauncher(params) {
8369
8710
  params.proc.exit(runLaunchPlan(prepareLaunch(params), params.spawn));
8370
8711
  }
8371
- var import_node_crypto10, import_node_path38;
8712
+ var import_node_crypto11, import_node_path38;
8372
8713
  var init_launcher = __esm({
8373
8714
  "src/launcher.ts"() {
8374
8715
  "use strict";
8375
- import_node_crypto10 = require("node:crypto");
8716
+ import_node_crypto11 = require("node:crypto");
8376
8717
  import_node_path38 = __toESM(require("node:path"), 1);
8377
8718
  init_package();
8378
8719
  init_envBool();
@@ -8384,6 +8725,7 @@ var init_launcher = __esm({
8384
8725
  init_flags();
8385
8726
  init_extraFlags();
8386
8727
  init_claudeSession();
8728
+ init_modelPicker();
8387
8729
  init_pool();
8388
8730
  init_resumeContext();
8389
8731
  init_lock();
@@ -8456,18 +8798,18 @@ function resolveTrustBundle(params) {
8456
8798
  }
8457
8799
  const combined = `${inheritedPem.trimEnd()}
8458
8800
  ${caPem}`;
8459
- const bundle = import_node_path40.default.join(bundlesDir, `${(0, import_node_crypto11.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
8801
+ const bundle = import_node_path40.default.join(bundlesDir, `${(0, import_node_crypto12.createHash)("sha256").update(combined).digest("hex").slice(0, BUNDLE_NAME_HEX_DIGITS)}.pem`);
8460
8802
  if (!fs13.exists(bundle)) {
8461
8803
  fs13.mkdirp(bundlesDir);
8462
8804
  fs13.writeFileAtomic(bundle, combined);
8463
8805
  }
8464
8806
  return { path: bundle };
8465
8807
  }
8466
- var import_node_crypto11, import_node_path40, BUNDLE_NAME_HEX_DIGITS;
8808
+ var import_node_crypto12, import_node_path40, BUNDLE_NAME_HEX_DIGITS;
8467
8809
  var init_trust = __esm({
8468
8810
  "src/frontdoor/trust.ts"() {
8469
8811
  "use strict";
8470
- import_node_crypto11 = require("node:crypto");
8812
+ import_node_crypto12 = require("node:crypto");
8471
8813
  import_node_path40 = __toESM(require("node:path"), 1);
8472
8814
  BUNDLE_NAME_HEX_DIGITS = 16;
8473
8815
  }
@@ -8561,7 +8903,7 @@ function buildFarmRuntime(paths, cwd) {
8561
8903
  ...cliOverride === void 0 ? {} : { cliOverride }
8562
8904
  }).input,
8563
8905
  now: () => Date.now(),
8564
- uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto12.randomUUID)()}`,
8906
+ uniqueSuffix: `${String(process.pid)}.${(0, import_node_crypto13.randomUUID)()}`,
8565
8907
  // Zombie-aware on purpose: a previous launcher that crashed out of a resync without releasing the lock may sit unreaped, still answering signal 0 as alive, and must read as a dead holder so this launch takes the lock over instead of timing out.
8566
8908
  lock: { pid: process.pid, isRunning: realIsProcessRunning, sleep: realSleepSync }
8567
8909
  },
@@ -8587,6 +8929,7 @@ function realPrepareLaunchParams(paths, options) {
8587
8929
  headroom: realHeadroomPort(paths, { spawnDaemon: options.spawnDaemon, cwd: farm.runtime.cwd }),
8588
8930
  frontdoor: realFrontDoorPort(paths, options.spawnDaemon),
8589
8931
  credentials: { ...realCredentialPort, cache: realCredentialCacheEnv(paths) },
8932
+ hasStoredLogin: (identity) => identitySignIn(realFarmFs, { platform: process.platform, run: realRunPort }, { farmRoot: import_node_path41.default.join(paths.identitiesDir, identity), hasCredentialBlock: false }).state !== "signed-out",
8590
8933
  ...farm.directoryIdentity === void 0 ? {} : { directoryPinnedIdentity: farm.directoryIdentity },
8591
8934
  ...farm.directoryConfigProfile === void 0 ? {} : { directoryRuleConfigProfile: farm.directoryConfigProfile },
8592
8935
  ...farm.globalDefaultConfigProfile === void 0 ? {} : { globalDefaultConfigProfile: farm.globalDefaultConfigProfile },
@@ -8643,12 +8986,13 @@ function resolveClaudeLaunch(options) {
8643
8986
  };
8644
8987
  return { resolution: resolveLaunch(realPrepareLaunchParams(paths, { proc, log, spawnDaemon, farm: buildFarmRuntime(paths, options.cwd) })), warnings };
8645
8988
  }
8646
- var import_node_os7, import_node_crypto12, LaunchRefusedError;
8989
+ var import_node_os7, import_node_path41, import_node_crypto13, LaunchRefusedError;
8647
8990
  var init_launchWiring = __esm({
8648
8991
  "src/launchWiring.ts"() {
8649
8992
  "use strict";
8650
8993
  import_node_os7 = __toESM(require("node:os"), 1);
8651
- import_node_crypto12 = require("node:crypto");
8994
+ import_node_path41 = __toESM(require("node:path"), 1);
8995
+ import_node_crypto13 = require("node:crypto");
8652
8996
  init_cliError();
8653
8997
  init_claudeShim();
8654
8998
  init_classify();
@@ -8660,6 +9004,7 @@ var init_launchWiring = __esm({
8660
9004
  init_launchHook();
8661
9005
  init_cascade();
8662
9006
  init_paths();
9007
+ init_signIn();
8663
9008
  init_realPorts();
8664
9009
  LaunchRefusedError = class extends CliError {
8665
9010
  exitCode;
@@ -8861,84 +9206,77 @@ var init_identityClaude = __esm({
8861
9206
  }
8862
9207
  });
8863
9208
 
8864
- // src/antigravity/cloudUpstream.ts
8865
- var init_cloudUpstream = __esm({
8866
- "src/antigravity/cloudUpstream.ts"() {
8867
- "use strict";
8868
- }
8869
- });
8870
-
8871
9209
  // src/usage/providerQuota.ts
8872
- var import_zod29, MS_PER_SECOND7, SECONDS_PER_HOUR, HOURS_PER_DAY4, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
9210
+ var import_zod30, MS_PER_SECOND7, SECONDS_PER_HOUR2, HOURS_PER_DAY5, DAYS_PER_MONTH, ZAI_HOST, ZAI_QUOTA_URL, ZAI_UNIT_HOURS, ZAI_UNIT_MONTHS, ZAI_UNIT_MS, ZaiLimitSchema, ZaiResponseSchema, OPENROUTER_HOST, OPENROUTER_KEY_URL, OPENROUTER_CREDITS_URL, MS_PER_DAY3, OpenRouterKeySchema, OpenRouterCreditsSchema, ANTIGRAVITY_HOST, ANTIGRAVITY_QUOTA_URL, ANTIGRAVITY_USER_URL, FIVE_HOURS2, DAYS_PER_WEEK2, FIVE_HOURS_MS, WEEK_MS, AntigravityBucketSchema, AntigravitySummarySchema, GoogleTokenInfoSchema, AntigravityUserSchema;
8873
9211
  var init_providerQuota = __esm({
8874
9212
  "src/usage/providerQuota.ts"() {
8875
9213
  "use strict";
8876
- import_zod29 = require("zod");
9214
+ import_zod30 = require("zod");
8877
9215
  init_cloudUpstream();
8878
9216
  init_schema2();
8879
9217
  MS_PER_SECOND7 = 1e3;
8880
- SECONDS_PER_HOUR = 3600;
8881
- HOURS_PER_DAY4 = 24;
9218
+ SECONDS_PER_HOUR2 = 3600;
9219
+ HOURS_PER_DAY5 = 24;
8882
9220
  DAYS_PER_MONTH = 30;
8883
9221
  ZAI_HOST = "api.z.ai";
8884
9222
  ZAI_QUOTA_URL = `https://${ZAI_HOST}/api/monitor/usage/quota/limit`;
8885
9223
  ZAI_UNIT_HOURS = 3;
8886
9224
  ZAI_UNIT_MONTHS = 5;
8887
9225
  ZAI_UNIT_MS = /* @__PURE__ */ new Map([
8888
- [ZAI_UNIT_HOURS, SECONDS_PER_HOUR * MS_PER_SECOND7],
8889
- [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7]
9226
+ [ZAI_UNIT_HOURS, SECONDS_PER_HOUR2 * MS_PER_SECOND7],
9227
+ [ZAI_UNIT_MONTHS, DAYS_PER_MONTH * HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7]
8890
9228
  ]);
8891
- ZaiLimitSchema = import_zod29.z.object({
8892
- type: import_zod29.z.string(),
8893
- unit: import_zod29.z.number().int(),
8894
- number: import_zod29.z.number().int().positive(),
8895
- percentage: import_zod29.z.number().nonnegative(),
8896
- nextResetTime: import_zod29.z.number().positive().optional(),
8897
- usage: import_zod29.z.number().nonnegative().optional(),
8898
- currentValue: import_zod29.z.number().nonnegative().optional(),
8899
- remaining: import_zod29.z.number().nonnegative().optional()
9229
+ ZaiLimitSchema = import_zod30.z.object({
9230
+ type: import_zod30.z.string(),
9231
+ unit: import_zod30.z.number().int(),
9232
+ number: import_zod30.z.number().int().positive(),
9233
+ percentage: import_zod30.z.number().nonnegative(),
9234
+ nextResetTime: import_zod30.z.number().positive().optional(),
9235
+ usage: import_zod30.z.number().nonnegative().optional(),
9236
+ currentValue: import_zod30.z.number().nonnegative().optional(),
9237
+ remaining: import_zod30.z.number().nonnegative().optional()
8900
9238
  });
8901
- ZaiResponseSchema = import_zod29.z.object({
8902
- success: import_zod29.z.boolean(),
8903
- msg: import_zod29.z.string().optional(),
8904
- data: import_zod29.z.object({ level: import_zod29.z.string().optional(), limits: import_zod29.z.array(ZaiLimitSchema) })
9239
+ ZaiResponseSchema = import_zod30.z.object({
9240
+ success: import_zod30.z.boolean(),
9241
+ msg: import_zod30.z.string().optional(),
9242
+ data: import_zod30.z.object({ level: import_zod30.z.string().optional(), limits: import_zod30.z.array(ZaiLimitSchema) })
8905
9243
  });
8906
9244
  OPENROUTER_HOST = "openrouter.ai";
8907
9245
  OPENROUTER_KEY_URL = `https://${OPENROUTER_HOST}/api/v1/key`;
8908
9246
  OPENROUTER_CREDITS_URL = `https://${OPENROUTER_HOST}/api/v1/credits`;
8909
- MS_PER_DAY3 = HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7;
8910
- OpenRouterKeySchema = import_zod29.z.object({
8911
- data: import_zod29.z.object({
8912
- limit: import_zod29.z.number().nonnegative().nullable(),
8913
- limit_remaining: import_zod29.z.number().nullable(),
8914
- limit_reset: import_zod29.z.string().nullable(),
8915
- is_free_tier: import_zod29.z.boolean().optional(),
8916
- free_model_daily_requests: import_zod29.z.object({ used: import_zod29.z.number().nonnegative(), limit: import_zod29.z.number().nonnegative(), remaining: import_zod29.z.number() }).optional()
9247
+ MS_PER_DAY3 = HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9248
+ OpenRouterKeySchema = import_zod30.z.object({
9249
+ data: import_zod30.z.object({
9250
+ limit: import_zod30.z.number().nonnegative().nullable(),
9251
+ limit_remaining: import_zod30.z.number().nullable(),
9252
+ limit_reset: import_zod30.z.string().nullable(),
9253
+ is_free_tier: import_zod30.z.boolean().optional(),
9254
+ free_model_daily_requests: import_zod30.z.object({ used: import_zod30.z.number().nonnegative(), limit: import_zod30.z.number().nonnegative(), remaining: import_zod30.z.number() }).optional()
8917
9255
  })
8918
9256
  });
8919
- OpenRouterCreditsSchema = import_zod29.z.object({ data: import_zod29.z.object({ total_credits: import_zod29.z.number().nonnegative(), total_usage: import_zod29.z.number().nonnegative() }) });
9257
+ OpenRouterCreditsSchema = import_zod30.z.object({ data: import_zod30.z.object({ total_credits: import_zod30.z.number().nonnegative(), total_usage: import_zod30.z.number().nonnegative() }) });
8920
9258
  ANTIGRAVITY_HOST = "daily-cloudcode-pa.googleapis.com";
8921
9259
  ANTIGRAVITY_QUOTA_URL = `https://${ANTIGRAVITY_HOST}/v1internal:retrieveUserQuotaSummary`;
8922
9260
  ANTIGRAVITY_USER_URL = `https://${ANTIGRAVITY_HOST}/v1internal:loadCodeAssist`;
8923
9261
  FIVE_HOURS2 = 5;
8924
- DAYS_PER_WEEK = 7;
8925
- FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR * MS_PER_SECOND7;
8926
- WEEK_MS = DAYS_PER_WEEK * HOURS_PER_DAY4 * SECONDS_PER_HOUR * MS_PER_SECOND7;
8927
- AntigravityBucketSchema = import_zod29.z.object({
8928
- bucketId: import_zod29.z.string(),
8929
- remainingFraction: import_zod29.z.number().optional(),
8930
- resetTime: import_zod29.z.string().optional()
9262
+ DAYS_PER_WEEK2 = 7;
9263
+ FIVE_HOURS_MS = FIVE_HOURS2 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9264
+ WEEK_MS = DAYS_PER_WEEK2 * HOURS_PER_DAY5 * SECONDS_PER_HOUR2 * MS_PER_SECOND7;
9265
+ AntigravityBucketSchema = import_zod30.z.object({
9266
+ bucketId: import_zod30.z.string(),
9267
+ remainingFraction: import_zod30.z.number().optional(),
9268
+ resetTime: import_zod30.z.string().optional()
8931
9269
  });
8932
- AntigravitySummarySchema = import_zod29.z.object({ groups: import_zod29.z.array(import_zod29.z.object({ buckets: import_zod29.z.array(AntigravityBucketSchema) })) });
8933
- GoogleTokenInfoSchema = import_zod29.z.object({
8934
- email: import_zod29.z.string().optional(),
8935
- sub: import_zod29.z.string().optional()
9270
+ AntigravitySummarySchema = import_zod30.z.object({ groups: import_zod30.z.array(import_zod30.z.object({ buckets: import_zod30.z.array(AntigravityBucketSchema) })) });
9271
+ GoogleTokenInfoSchema = import_zod30.z.object({
9272
+ email: import_zod30.z.string().optional(),
9273
+ sub: import_zod30.z.string().optional()
8936
9274
  });
8937
- AntigravityUserSchema = import_zod29.z.object({
9275
+ AntigravityUserSchema = import_zod30.z.object({
8938
9276
  /** The code-assist tier context, which defaults to the free tier for every account. */
8939
- currentTier: import_zod29.z.object({ name: import_zod29.z.string().optional(), id: import_zod29.z.string().optional() }).optional(),
9277
+ currentTier: import_zod30.z.object({ name: import_zod30.z.string().optional(), id: import_zod30.z.string().optional() }).optional(),
8940
9278
  /** The account's paid subscription; absent when the account has none. */
8941
- paidTier: import_zod29.z.object({ name: import_zod29.z.string().optional(), id: import_zod29.z.string().optional() }).optional()
9279
+ paidTier: import_zod30.z.object({ name: import_zod30.z.string().optional(), id: import_zod30.z.string().optional() }).optional()
8942
9280
  });
8943
9281
  }
8944
9282
  });
@@ -9951,8 +10289,8 @@ function parseConnectTarget(authority) {
9951
10289
  function isInterceptedHost(host, interceptHosts) {
9952
10290
  return interceptHosts.includes(host);
9953
10291
  }
9954
- function servedByPipeline(path41) {
9955
- return path41?.startsWith(ROUTED_PATH_PREFIX) === true;
10292
+ function servedByPipeline(path42) {
10293
+ return path42?.startsWith(ROUTED_PATH_PREFIX) === true;
9956
10294
  }
9957
10295
  var HOP_BY_HOP_HEADERS = /* @__PURE__ */ new Set([
9958
10296
  "connection",
@@ -10746,11 +11084,11 @@ function createRcSessionTracker(deps) {
10746
11084
  };
10747
11085
  const observeExchange = (request4) => {
10748
11086
  const method = (request4.method ?? "").toUpperCase();
10749
- const path41 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
10750
- if (!path41.startsWith(RC_SESSIONS_PATH_PREFIX)) {
11087
+ const path42 = new URL(request4.url ?? "/", "http://127.0.0.1").pathname;
11088
+ if (!path42.startsWith(RC_SESSIONS_PATH_PREFIX)) {
10751
11089
  return void 0;
10752
11090
  }
10753
- const tail = path41.slice(RC_SESSIONS_PATH_PREFIX.length);
11091
+ const tail = path42.slice(RC_SESSIONS_PATH_PREFIX.length);
10754
11092
  const facts = {
10755
11093
  oauthAuthorization: oauthAuthorizationOf(request4.headers),
10756
11094
  anthropicVersion: singleHeader(request4.headers, "anthropic-version"),
@@ -11140,8 +11478,8 @@ var RC_READ_FILE_ENCODINGS = ["utf-8", "base64"];
11140
11478
  function isRcReadFileEncoding(value) {
11141
11479
  return RC_READ_FILE_ENCODINGS.some((encoding) => encoding === value);
11142
11480
  }
11143
- function buildRcReadFilePayload(requestId, path41, options) {
11144
- return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path41, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
11481
+ function buildRcReadFilePayload(requestId, path42, options) {
11482
+ return buildRcControlRequestPayload(requestId, { subtype: "read_file", path: path42, ...options?.maxBytes === void 0 ? {} : { max_bytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } });
11145
11483
  }
11146
11484
  function buildRcFileSuggestionsPayload(requestId, query) {
11147
11485
  return buildRcControlRequestPayload(requestId, { subtype: "file_suggestions", query });
@@ -11243,15 +11581,15 @@ async function getRcSessionContextUsage(deps, sessionId, detail) {
11243
11581
  const result = await deliverRcClientPayload(deps, sessionId, buildRcGetContextUsagePayload(requestId, detail), `request the context usage of session ${sessionId}`);
11244
11582
  return result.ok ? { ...result, requestId } : result;
11245
11583
  }
11246
- async function readRcSessionFile(deps, sessionId, path41, options) {
11247
- if (path41 === "") {
11584
+ async function readRcSessionFile(deps, sessionId, path42, options) {
11585
+ if (path42 === "") {
11248
11586
  return { ok: false, message: "a read-file write needs a non-empty path: the SDK's own field names the file the worker resolves against the session's cwd, and an empty string names none" };
11249
11587
  }
11250
11588
  if (options?.maxBytes !== void 0 && (!Number.isInteger(options.maxBytes) || options.maxBytes <= 0)) {
11251
11589
  return { ok: false, message: "a read-file write's max-bytes is a positive whole number of bytes: the SDK's own field caps the read, and a zero or negative cap reads nothing" };
11252
11590
  }
11253
11591
  const requestId = deps.newUuid();
11254
- const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path41, options), `read ${path41} from session ${sessionId}`);
11592
+ const result = await deliverRcClientPayload(deps, sessionId, buildRcReadFilePayload(requestId, path42, options), `read ${path42} from session ${sessionId}`);
11255
11593
  return result.ok ? { ...result, requestId } : result;
11256
11594
  }
11257
11595
  async function suggestRcSessionFiles(deps, sessionId, query) {
@@ -11420,11 +11758,11 @@ function createRcControlHandler(deps) {
11420
11758
  path: "read-file",
11421
11759
  read: (body) => {
11422
11760
  const session = bodyString(body, "session");
11423
- const path41 = bodyString(body, "path");
11761
+ const path42 = bodyString(body, "path");
11424
11762
  const maxBytes = "maxBytes" in body ? bodyPositiveInteger(body, "maxBytes") : void 0;
11425
11763
  const encoding = "encoding" in body && isRcReadFileEncoding(body.encoding) ? body.encoding : void 0;
11426
- const refused2 = session === void 0 || path41 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
11427
- return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path41, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
11764
+ const refused2 = session === void 0 || path42 === void 0 || "maxBytes" in body && maxBytes === void 0 || "encoding" in body && encoding === void 0;
11765
+ return refused2 ? { error: `the read-file body must be JSON naming a non-empty session id and path, maxBytes only as a positive whole number or absent, and an encoding the SDK's own type permits (${RC_READ_FILE_ENCODINGS.join(", ")}) or none` } : { session, run: async () => await deps.readFile(session, path42, { ...maxBytes === void 0 ? {} : { maxBytes }, ...encoding === void 0 ? {} : { encoding } }) };
11428
11766
  }
11429
11767
  },
11430
11768
  {
@@ -11734,9 +12072,9 @@ function requestIdOfBody(body) {
11734
12072
  }
11735
12073
  function frontDoorRcControl(transport, token) {
11736
12074
  const headers = { authorization: `Bearer ${token}` };
11737
- const listAnswerOf = async (path41, what) => {
12075
+ const listAnswerOf = async (path42, what) => {
11738
12076
  try {
11739
- return await transport.request({ method: "GET", path: path41, headers });
12077
+ return await transport.request({ method: "GET", path: path42, headers });
11740
12078
  } catch (error) {
11741
12079
  throw new Error(`${what}: could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
11742
12080
  }
@@ -11808,10 +12146,10 @@ function frontDoorRcControl(transport, token) {
11808
12146
  }
11809
12147
  return pending;
11810
12148
  };
11811
- const writeOf = async (path41, body, describeFailure2) => {
12149
+ const writeOf = async (path42, body, describeFailure2) => {
11812
12150
  let answer;
11813
12151
  try {
11814
- answer = await transport.request({ method: "POST", path: path41, headers: { ...headers, "content-type": "application/json" }, body });
12152
+ answer = await transport.request({ method: "POST", path: path42, headers: { ...headers, "content-type": "application/json" }, body });
11815
12153
  } catch (error) {
11816
12154
  return { ok: false, message: `could not reach the front door's control listener: ${error instanceof Error ? error.message : String(error)}` };
11817
12155
  }
@@ -11842,10 +12180,10 @@ function frontDoorRcControl(transport, token) {
11842
12180
  endSession: async (sessionId, reason) => await writeOf(`${CONTROL_PATH_PREFIX}/end-session`, JSON.stringify({ session: sessionId, ...reason === void 0 ? {} : { reason } }), (status, message) => `ending ${sessionId} failed (HTTP ${String(status)}): ${message}`),
11843
12181
  getUsage: async (sessionId, skipBehaviors) => await writeOf(`${CONTROL_PATH_PREFIX}/get-usage`, JSON.stringify({ session: sessionId, ...skipBehaviors === void 0 ? {} : { skipBehaviors } }), (status, message) => `requesting the usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
11844
12182
  getContextUsage: async (sessionId, detail) => await writeOf(`${CONTROL_PATH_PREFIX}/get-context-usage`, JSON.stringify({ session: sessionId, ...detail === void 0 ? {} : { detail } }), (status, message) => `requesting the context usage of ${sessionId} failed (HTTP ${String(status)}): ${message}`),
11845
- readFile: async (sessionId, path41, options) => await writeOf(
12183
+ readFile: async (sessionId, path42, options) => await writeOf(
11846
12184
  `${CONTROL_PATH_PREFIX}/read-file`,
11847
- JSON.stringify({ session: sessionId, path: path41, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
11848
- (status, message) => `reading ${path41} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
12185
+ JSON.stringify({ session: sessionId, path: path42, ...options?.maxBytes === void 0 ? {} : { maxBytes: options.maxBytes }, ...options?.encoding === void 0 ? {} : { encoding: options.encoding } }),
12186
+ (status, message) => `reading ${path42} from ${sessionId} failed (HTTP ${String(status)}): ${message}`
11849
12187
  ),
11850
12188
  fileSuggestions: async (sessionId, query) => await writeOf(`${CONTROL_PATH_PREFIX}/file-suggestions`, JSON.stringify({ session: sessionId, query }), (status, message) => `requesting file suggestions from ${sessionId} failed (HTTP ${String(status)}): ${message}`),
11851
12189
  keepAlive: async (sessionId) => await writeOf(`${CONTROL_PATH_PREFIX}/keep-alive`, JSON.stringify({ session: sessionId }), (status, message) => `keeping ${sessionId} alive failed (HTTP ${String(status)}): ${message}`),
@@ -12004,12 +12342,12 @@ function tlsFacts(options) {
12004
12342
  }
12005
12343
  function realRcEventDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
12006
12344
  const agent = new ExemptTlsAgent();
12007
- const post = async (path41, headers, body) => await new Promise((resolve, reject) => {
12345
+ const post = async (path42, headers, body) => await new Promise((resolve, reject) => {
12008
12346
  const options = {
12009
12347
  host: target.host,
12010
12348
  port: target.port,
12011
12349
  method: "POST",
12012
- path: path41,
12350
+ path: path42,
12013
12351
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
12014
12352
  headers: { ...headers, host: target.servername ?? target.host, "content-length": String(Buffer.byteLength(body, "utf8")) },
12015
12353
  agent
@@ -12074,12 +12412,12 @@ function lateRcStreamDial(resolve) {
12074
12412
  }
12075
12413
  function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_PORT }) {
12076
12414
  const agent = new ExemptTlsAgent();
12077
- const request4 = async (method, path41, headers, body, signal) => await new Promise((resolve, reject) => {
12415
+ const request4 = async (method, path42, headers, body, signal) => await new Promise((resolve, reject) => {
12078
12416
  const options = {
12079
12417
  host: target.host,
12080
12418
  port: target.port,
12081
12419
  method,
12082
- path: path41,
12420
+ path: path42,
12083
12421
  // The Host header names the host whose API this is, not the address dialled: a redirected test dials a loopback stand-in while still speaking to the API host by name, exactly as the forwarded paths present their SNI.
12084
12422
  headers: { ...headers, host: target.servername ?? target.host, ...body === void 0 ? {} : { "content-length": String(Buffer.byteLength(body, "utf8")) } },
12085
12423
  agent,
@@ -12121,9 +12459,9 @@ function realRcStreamDial(target = { host: CONNECT_INTERCEPT_HOST, port: HTTPS_P
12121
12459
  return { status, body: await readAll(response) };
12122
12460
  },
12123
12461
  openStream: async (sessionId, headers, resume, signal) => {
12124
- const path41 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
12462
+ const path42 = resume === void 0 ? `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream` : `/v1/code/sessions/${encodeURIComponent(sessionId)}/events/stream?from_sequence_num=${String(resume.fromSequenceNum)}`;
12125
12463
  const streamHeaders = resume === void 0 ? headers : { ...headers, "last-event-id": String(resume.fromSequenceNum) };
12126
- const { status, response } = await request4("GET", path41, streamHeaders, void 0, signal);
12464
+ const { status, response } = await request4("GET", path42, streamHeaders, void 0, signal);
12127
12465
  if (!isSuccessful2(status)) {
12128
12466
  await readAll(response);
12129
12467
  return { status, chunks: NO_CHUNKS };
@@ -13275,19 +13613,19 @@ function writePools(paths, pools) {
13275
13613
  applyPatch(paths.globalConfigFile, GlobalConfigSchema, { pools }, { defaults: {} });
13276
13614
  }
13277
13615
  function poolCycleOf(pools, name) {
13278
- const walk = (current, path41) => {
13616
+ const walk = (current, path42) => {
13279
13617
  for (const entry of pools[current]?.identities ?? []) {
13280
13618
  const nested = poolNameOf(poolMemberIdentity(entry));
13281
13619
  if (nested === void 0) {
13282
13620
  continue;
13283
13621
  }
13284
13622
  if (nested === name) {
13285
- return [...path41, nested];
13623
+ return [...path42, nested];
13286
13624
  }
13287
- if (path41.includes(nested)) {
13625
+ if (path42.includes(nested)) {
13288
13626
  continue;
13289
13627
  }
13290
- const found = walk(nested, [...path41, nested]);
13628
+ const found = walk(nested, [...path42, nested]);
13291
13629
  if (found !== void 0) {
13292
13630
  return found;
13293
13631
  }
@@ -13409,8 +13747,9 @@ init_cascade();
13409
13747
  init_paths();
13410
13748
  init_realCredentialCache();
13411
13749
  init_providersStore();
13750
+ init_signIn();
13412
13751
  init_realPorts();
13413
- var import_node_path26 = __toESM(require("node:path"), 1);
13752
+ var import_node_path27 = __toESM(require("node:path"), 1);
13414
13753
  var import_zod15 = require("zod");
13415
13754
  init_envBool();
13416
13755
  init_load();
@@ -13478,26 +13817,18 @@ function formatDecision(decision) {
13478
13817
  const eliminatedNote = decision.eliminated !== void 0 && decision.eliminated.length > 0 ? ` [${String(decision.eliminated.length)} more specific rule(s) eliminated by a failing when-condition]` : "";
13479
13818
  return `${decision.relPath}: ${status} \u2014 ${reason}${eliminatedNote}`;
13480
13819
  }
13481
- function parseKeychainServiceName(stderr) {
13482
- const match = /"svce"<blob>="([^"]*)"/.exec(stderr);
13483
- return match?.[1];
13484
- }
13485
13820
  function lookupKeychainService(run, farmRoot) {
13486
- const result = run.run("security", ["find-generic-password", "-a", farmRoot, "-g"]);
13821
+ const serviceName = claudeCodeKeychainService(farmRoot);
13822
+ const result = run.run("security", ["find-generic-password", "-s", serviceName]);
13487
13823
  if (result.status !== 0) {
13488
13824
  return {
13489
13825
  checked: true,
13490
13826
  found: false,
13491
- note: `No Keychain entry found for account "${farmRoot}" (security exited ${result.status === null ? "with no status" : String(result.status)}).`
13827
+ serviceName,
13828
+ note: `No Keychain entry found for service "${serviceName}" (security exited ${result.status === null ? "with no status" : String(result.status)}).`
13492
13829
  };
13493
13830
  }
13494
- const serviceName = parseKeychainServiceName(result.stderr);
13495
- return {
13496
- checked: true,
13497
- found: true,
13498
- ...serviceName === void 0 ? {} : { serviceName },
13499
- note: serviceName === void 0 ? `A Keychain entry was found for account "${farmRoot}" but its service name could not be parsed from security's output.` : `Keychain service name for this identity: "${serviceName}".`
13500
- };
13831
+ return { checked: true, found: true, serviceName, note: `Keychain service name for this identity: "${serviceName}".` };
13501
13832
  }
13502
13833
  var SettingsSecretsShapeSchema = import_zod15.z.looseObject({
13503
13834
  env: import_zod15.z.record(import_zod15.z.string(), import_zod15.z.unknown()).optional(),
@@ -13759,10 +14090,10 @@ function collectCheckReport(params) {
13759
14090
  }).input;
13760
14091
  const providerName = cascadeProviderName(cascade);
13761
14092
  const provider = providerName === void 0 ? void 0 : loadCheckProvider(paths, providerName);
13762
- const farmRoot = identityDecision.name === void 0 ? void 0 : import_node_path26.default.join(paths.identitiesDir, identityDecision.name);
14093
+ const farmRoot = identityDecision.name === void 0 ? void 0 : import_node_path27.default.join(paths.identitiesDir, identityDecision.name);
13763
14094
  const settingsFiles = {
13764
- "settings.json": realFsPort.readFileUtf8(import_node_path26.default.join(claudeHome, "settings.json")),
13765
- "settings.local.json": realFsPort.readFileUtf8(import_node_path26.default.join(claudeHome, "settings.local.json"))
14095
+ "settings.json": realFsPort.readFileUtf8(import_node_path27.default.join(claudeHome, "settings.json")),
14096
+ "settings.local.json": realFsPort.readFileUtf8(import_node_path27.default.join(claudeHome, "settings.local.json"))
13766
14097
  };
13767
14098
  const report = runCheck({
13768
14099
  cwd,
@@ -14063,7 +14394,7 @@ init_store();
14063
14394
 
14064
14395
  // src/identityStore.ts
14065
14396
  var import_node_fs8 = __toESM(require("node:fs"), 1);
14066
- var import_node_path28 = __toESM(require("node:path"), 1);
14397
+ var import_node_path29 = __toESM(require("node:path"), 1);
14067
14398
  init_load();
14068
14399
  init_store();
14069
14400
  init_schema();
@@ -14097,7 +14428,7 @@ var InvalidIdentityNameError = class extends CliError {
14097
14428
  attemptedName;
14098
14429
  };
14099
14430
  function identityJsonPath(paths, name) {
14100
- return import_node_path28.default.join(paths.identitiesDir, name, "identity.json");
14431
+ return import_node_path29.default.join(paths.identitiesDir, name, "identity.json");
14101
14432
  }
14102
14433
  function requireIdentityNames(paths, names) {
14103
14434
  const existing = new Set(listIdentities(paths).map((entry) => entry.name));
@@ -14212,7 +14543,7 @@ function setIdentityCredential(paths, identityName, change) {
14212
14543
  });
14213
14544
  }
14214
14545
  function belongsToIdentity(entry, name) {
14215
- return entry === name || entry === import_node_path28.default.basename(identityLockPath("", name)) || entry.startsWith(`.${name}.scratch.`) || entry.startsWith(`.${name}.previous.`);
14546
+ return entry === name || entry === import_node_path29.default.basename(identityLockPath("", name)) || entry.startsWith(`.${name}.scratch.`) || entry.startsWith(`.${name}.previous.`);
14216
14547
  }
14217
14548
  function removeIdentity(paths, name) {
14218
14549
  if (!identityExists(paths, name)) {
@@ -14220,7 +14551,7 @@ function removeIdentity(paths, name) {
14220
14551
  }
14221
14552
  for (const entry of import_node_fs8.default.readdirSync(paths.identitiesDir)) {
14222
14553
  if (belongsToIdentity(entry, name)) {
14223
- import_node_fs8.default.rmSync(import_node_path28.default.join(paths.identitiesDir, entry), { recursive: true, force: true });
14554
+ import_node_fs8.default.rmSync(import_node_path29.default.join(paths.identitiesDir, entry), { recursive: true, force: true });
14224
14555
  }
14225
14556
  }
14226
14557
  if (readActiveIdentity2(paths) === name) {
@@ -14232,28 +14563,7 @@ function removeIdentity(paths, name) {
14232
14563
  init_realPorts();
14233
14564
  var import_node_fs10 = __toESM(require("node:fs"), 1);
14234
14565
  var import_node_path30 = __toESM(require("node:path"), 1);
14235
-
14236
- // src/usage/signIn.ts
14237
- var import_node_path29 = __toESM(require("node:path"), 1);
14238
- var CREDENTIALS_FILE = ".credentials.json";
14239
- function keychainHasItem(run, account) {
14240
- return run.run("security", ["find-generic-password", "-a", account]).status === 0;
14241
- }
14242
- function decideSignIn(facts) {
14243
- if (facts.hasCredentialBlock) {
14244
- return { state: "token", detail: "supplies its own credential through a credential block, so a stored login is not what a launch uses" };
14245
- }
14246
- if (facts.keychainItem === true) {
14247
- return { state: "signed-in", detail: "a login is stored in the macOS Keychain" };
14248
- }
14249
- if (facts.credentialsFile) {
14250
- return { state: "signed-in", detail: `a login is stored in ${CREDENTIALS_FILE}` };
14251
- }
14252
- return { state: "signed-out", detail: facts.platform === "darwin" ? `no Keychain item and no ${CREDENTIALS_FILE}` : `no ${CREDENTIALS_FILE}` };
14253
- }
14254
- function credentialsFilePath(farmRoot) {
14255
- return import_node_path29.default.join(farmRoot, CREDENTIALS_FILE);
14256
- }
14566
+ init_signIn();
14257
14567
 
14258
14568
  // src/codex/siwcStore.ts
14259
14569
  var import_zod22 = require("zod");
@@ -15594,7 +15904,7 @@ function profileValue(name, paths) {
15594
15904
  function createConfigApiRouter(deps) {
15595
15905
  const authed = doorApiAuth(deps.expectedToken);
15596
15906
  const { paths } = deps;
15597
- const route = (path41, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path41, summary, tags: [CONFIG_API_TAG] }));
15907
+ const route = (path42, summary) => authed.meta((0, import_openapi3.openapi)({ method: "POST", path: path42, summary, tags: [CONFIG_API_TAG] }));
15598
15908
  return {
15599
15909
  config: {
15600
15910
  identity: {
@@ -16884,7 +17194,7 @@ function numberOf(record, field) {
16884
17194
  }
16885
17195
  return void 0;
16886
17196
  }
16887
- function pageOfRcChannel(url, rows, idOf, rowOf2) {
17197
+ function pageOfRcChannel(url, rows, idOf, rowOf3) {
16888
17198
  const query = new URL(url, "http://127.0.0.1").searchParams;
16889
17199
  const anchor = query.get("after_event_id") ?? query.get("cursor");
16890
17200
  const rawLimit = query.get("limit");
@@ -16898,7 +17208,7 @@ function pageOfRcChannel(url, rows, idOf, rowOf2) {
16898
17208
  }
16899
17209
  const page = limit === void 0 ? rows.slice(from) : rows.slice(from, from + limit);
16900
17210
  const last = page[page.length - 1];
16901
- return { data: page.map(rowOf2), ...last === void 0 ? {} : { next_cursor: idOf(last) } };
17211
+ return { data: page.map(rowOf3), ...last === void 0 ? {} : { next_cursor: idOf(last) } };
16902
17212
  }
16903
17213
  async function serveRcClientChannels(ctx, tail, method, maxBatchEvents) {
16904
17214
  const { request: request4, response, host } = ctx;