@cortexkit/opencode-antigravity-auth 3.0.22 → 3.0.24

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.
Files changed (60) hide show
  1. package/dist/cli.js +321 -204
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +68 -43
  4. package/dist/index.js +547 -351
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +75 -50
  7. package/dist/server.js +690 -386
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/auth-method-labels.d.ts +1 -0
  11. package/dist/src/auth-method-labels.d.ts.map +1 -1
  12. package/dist/src/auth-method-labels.js +1 -0
  13. package/dist/src/auth-method-labels.js.map +1 -1
  14. package/dist/src/ga/server/auth.d.ts.map +1 -1
  15. package/dist/src/ga/server/auth.js +63 -21
  16. package/dist/src/ga/server/auth.js.map +1 -1
  17. package/dist/src/ga/server/pool-login.d.ts +4 -0
  18. package/dist/src/ga/server/pool-login.d.ts.map +1 -1
  19. package/dist/src/ga/server/pool-login.js +22 -1
  20. package/dist/src/ga/server/pool-login.js.map +1 -1
  21. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  22. package/dist/src/plugin/ga-location-services.js +42 -4
  23. package/dist/src/plugin/ga-location-services.js.map +1 -1
  24. package/dist/src/plugin/shared/request-services.d.ts +3 -0
  25. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  26. package/dist/src/plugin/shared/request-services.js +17 -3
  27. package/dist/src/plugin/shared/request-services.js.map +1 -1
  28. package/dist/src/plugin/shared/vault-routing.d.ts +6 -3
  29. package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
  30. package/dist/src/plugin/shared/vault-routing.js +12 -12
  31. package/dist/src/plugin/shared/vault-routing.js.map +1 -1
  32. package/dist/src/runtime-layout.d.ts.map +1 -1
  33. package/dist/src/runtime-layout.js +14 -3
  34. package/dist/src/runtime-layout.js.map +1 -1
  35. package/dist/src/setup.d.ts.map +1 -1
  36. package/dist/src/setup.js +38 -4
  37. package/dist/src/setup.js.map +1 -1
  38. package/dist/src/vault-folder.d.ts.map +1 -1
  39. package/dist/src/vault-folder.js +51 -14
  40. package/dist/src/vault-folder.js.map +1 -1
  41. package/dist/src/version-fence.d.ts +5 -0
  42. package/dist/src/version-fence.d.ts.map +1 -1
  43. package/dist/src/version-fence.js +64 -7
  44. package/dist/src/version-fence.js.map +1 -1
  45. package/dist/types/src/auth-method-labels.d.ts +1 -0
  46. package/dist/types/src/auth-method-labels.d.ts.map +1 -1
  47. package/dist/types/src/ga/server/auth.d.ts.map +1 -1
  48. package/dist/types/src/ga/server/pool-login.d.ts +4 -0
  49. package/dist/types/src/ga/server/pool-login.d.ts.map +1 -1
  50. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  51. package/dist/types/src/plugin/shared/request-services.d.ts +3 -0
  52. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  53. package/dist/types/src/plugin/shared/vault-routing.d.ts +6 -3
  54. package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
  55. package/dist/types/src/runtime-layout.d.ts.map +1 -1
  56. package/dist/types/src/setup.d.ts.map +1 -1
  57. package/dist/types/src/vault-folder.d.ts.map +1 -1
  58. package/dist/types/src/version-fence.d.ts +5 -0
  59. package/dist/types/src/version-fence.d.ts.map +1 -1
  60. package/package.json +2 -2
package/dist/server.js CHANGED
@@ -1628,10 +1628,10 @@ async function privateDirectory(path5) {
1628
1628
  if (errno(error) !== "EEXIST")
1629
1629
  throw error;
1630
1630
  }
1631
- const stat15 = await lstat2(path5);
1632
- if (!stat15.isDirectory() || stat15.isSymbolicLink())
1631
+ const stat16 = await lstat2(path5);
1632
+ if (!stat16.isDirectory() || stat16.isSymbolicLink())
1633
1633
  throw new AccountMigrationError("successor directory is not a regular directory");
1634
- privateMode(stat15.mode, 448);
1634
+ privateMode(stat16.mode, 448);
1635
1635
  if (windowsPrivateFiles)
1636
1636
  await verifySafeDirectory(path5);
1637
1637
  if (!sameFilesystemPath(await realpath(path5), path5))
@@ -6870,8 +6870,11 @@ var init_account_selector = __esm({
6870
6870
  rateLimitResetTimes: { ...a.rateLimitResetTimes }
6871
6871
  }));
6872
6872
  }
6873
- getEffectiveSoftQuotaThreshold(thresholdPercent) {
6874
- return this.getEnabledAccounts().length > 1 ? thresholdPercent : 100;
6873
+ getEligibleAccounts(excludeIndexes) {
6874
+ return this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && !excludeIndexes?.has(a.index));
6875
+ }
6876
+ getEffectiveSoftQuotaThreshold(thresholdPercent, excludeIndexes) {
6877
+ return this.getEligibleAccounts(excludeIndexes).length > 1 ? thresholdPercent : 100;
6875
6878
  }
6876
6879
  getRequestSessionState(identity3) {
6877
6880
  const now = this.now();
@@ -6974,7 +6977,7 @@ var init_account_selector = __esm({
6974
6977
  const currentIndex = this.getActiveIndex(family, identity3);
6975
6978
  if (currentIndex >= 0 && currentIndex < this.accounts.length) {
6976
6979
  const account = this.accounts[currentIndex] ?? null;
6977
- if (account && account.enabled !== false) {
6980
+ if (account && account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true) {
6978
6981
  return account;
6979
6982
  }
6980
6983
  }
@@ -7017,7 +7020,7 @@ var init_account_selector = __esm({
7017
7020
  }
7018
7021
  getCurrentOrNextForFamily(family, model, strategy = "sticky", pidOffsetEnabled = false, softQuotaThresholdPercent = 100, softQuotaCacheTtlMs = 10 * 60 * 1e3, identity3, excludeIndexes) {
7019
7022
  const quotaKey = getQuotaKey(family, model);
7020
- const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent);
7023
+ const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent, excludeIndexes);
7021
7024
  if (identity3) {
7022
7025
  const pinned = this.getCurrentAccountForFamily(family, identity3);
7023
7026
  if (pinned) {
@@ -7040,7 +7043,7 @@ var init_account_selector = __esm({
7040
7043
  if (strategy === "hybrid") {
7041
7044
  const healthTracker = this.healthTracker;
7042
7045
  const tokenTracker = this.tokenTracker;
7043
- const eligibleAccounts = this.preferAccountOutsideParent(this.accounts.filter((acc) => acc.enabled !== false && !excludeIndexes?.has(acc.index)), family, identity3);
7046
+ const eligibleAccounts = this.preferAccountOutsideParent(this.accounts.filter((acc) => acc.enabled !== false && acc.accountIneligible !== true && acc.verificationRequired !== true && !excludeIndexes?.has(acc.index)), family, identity3);
7044
7047
  const accountsWithMetrics = eligibleAccounts.map((acc) => {
7045
7048
  clearExpiredRateLimits(acc, this.now);
7046
7049
  return {
@@ -7097,10 +7100,10 @@ var init_account_selector = __esm({
7097
7100
  return next;
7098
7101
  }
7099
7102
  getNextForFamily(family, model, softQuotaThresholdPercent = 100, softQuotaCacheTtlMs = 10 * 60 * 1e3, identity3, excludeIndexes) {
7100
- const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent);
7103
+ const effectiveSoftQuotaThreshold = this.getEffectiveSoftQuotaThreshold(softQuotaThresholdPercent, excludeIndexes);
7101
7104
  const allAvailable = this.accounts.filter((account2) => {
7102
7105
  clearExpiredRateLimits(account2, this.now);
7103
- return account2.enabled !== false && !excludeIndexes?.has(account2.index) && !isRateLimitedForFamily(account2, family, this.now, model) && !isOverSoftQuotaThreshold(account2, family, effectiveSoftQuotaThreshold, softQuotaCacheTtlMs, this.now, model) && !this.isAccountCoolingDown(account2);
7106
+ return account2.enabled !== false && account2.accountIneligible !== true && account2.verificationRequired !== true && !excludeIndexes?.has(account2.index) && !isRateLimitedForFamily(account2, family, this.now, model) && !isOverSoftQuotaThreshold(account2, family, effectiveSoftQuotaThreshold, softQuotaCacheTtlMs, this.now, model) && !this.isAccountCoolingDown(account2);
7104
7107
  });
7105
7108
  const available = this.preferAccountOutsideParent(allAvailable, family, identity3);
7106
7109
  if (available.length === 0) {
@@ -7286,7 +7289,7 @@ var init_account_selector = __esm({
7286
7289
  getFreshAccountsForQuota(quotaKey, family, model) {
7287
7290
  return this.accounts.filter((acc) => {
7288
7291
  clearExpiredRateLimits(acc, this.now);
7289
- return acc.enabled !== false && this.isFreshForQuota(acc, quotaKey) && !isRateLimitedForFamily(acc, family, this.now, model) && !this.isAccountCoolingDown(acc);
7292
+ return acc.enabled !== false && acc.accountIneligible !== true && acc.verificationRequired !== true && this.isFreshForQuota(acc, quotaKey) && !isRateLimitedForFamily(acc, family, this.now, model) && !this.isAccountCoolingDown(acc);
7290
7293
  });
7291
7294
  }
7292
7295
  isRateLimited(account, family, model) {
@@ -7422,12 +7425,40 @@ var init_account_selector = __esm({
7422
7425
  }
7423
7426
  return true;
7424
7427
  }
7425
- getMinWaitTimeForFamily(family, model) {
7428
+ /**
7429
+ * Calculates the minimum wait time in milliseconds across eligible accounts
7430
+ * for a given model family (and optional model).
7431
+ *
7432
+ * Note: Returning `0` can mean either:
7433
+ * 1. No eligible candidates exist in the pool, OR
7434
+ * 2. At least one eligible candidate is immediately usable without waiting.
7435
+ * Callers must distinguish "no eligible candidates" from "zero wait time"
7436
+ * by inspecting candidate pool availability / eligibility directly.
7437
+ *
7438
+ * @param family Model family (e.g., 'claude', 'gemini')
7439
+ * @param model Optional model name for per-model rate limits
7440
+ * @param eligibleIndexes Optional set of account indexes permitted for this request
7441
+ * @param includeCooldown Whether to factor in `coolingDownUntil` alongside quota rate limits
7442
+ * @returns Minimum wait duration in milliseconds, or 0 if immediately usable or no candidates
7443
+ */
7444
+ getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown = false) {
7426
7445
  const now = this.now();
7427
- const waits = this.accounts.filter((a) => a.enabled !== false).map((a) => {
7446
+ const waits = this.accounts.filter((a) => {
7447
+ if (a.enabled === false)
7448
+ return false;
7449
+ if (a.accountIneligible === true || a.verificationRequired === true) {
7450
+ return false;
7451
+ }
7452
+ if (eligibleIndexes !== void 0 && eligibleIndexes !== null) {
7453
+ if (!eligibleIndexes.has(a.index))
7454
+ return false;
7455
+ }
7456
+ return true;
7457
+ }).map((a) => {
7428
7458
  clearExpiredRateLimits(a, this.now);
7429
7459
  const modelReset = model ? a.rateLimitResetTimes[getQuotaKey(family, model)] : void 0;
7430
- return Math.max(0, (a.rateLimitResetTimes[family] ?? now) - now, (modelReset ?? now) - now);
7460
+ const cooldownWait = includeCooldown && a.coolingDownUntil !== void 0 && a.coolingDownUntil > now ? a.coolingDownUntil - now : 0;
7461
+ return Math.max(0, (a.rateLimitResetTimes[family] ?? now) - now, (modelReset ?? now) - now, cooldownWait);
7431
7462
  });
7432
7463
  return waits.length > 0 ? Math.min(...waits) : 0;
7433
7464
  }
@@ -7622,36 +7653,42 @@ var init_account_selector = __esm({
7622
7653
  }
7623
7654
  return oldest;
7624
7655
  }
7625
- areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
7656
+ /**
7657
+ * Check whether all eligible accounts (more than 1) are currently over the soft-quota threshold.
7658
+ * Returns false if thresholdPercent >= 100 or if <= 1 eligible account remains.
7659
+ */
7660
+ areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
7626
7661
  if (thresholdPercent >= 100)
7627
7662
  return false;
7628
- const enabled = this.accounts.filter((a) => a.enabled !== false);
7629
- if (enabled.length <= 1)
7663
+ const eligible = this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && (eligibleIndexes == null || eligibleIndexes.has(a.index)));
7664
+ if (eligible.length <= 1)
7630
7665
  return false;
7631
- return enabled.every((a) => isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
7666
+ return eligible.every((a) => isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
7632
7667
  }
7633
7668
  /**
7634
- * Get minimum wait time until any account's soft quota resets.
7635
- * Returns 0 if any account is available (not over threshold).
7636
- * Returns the minimum resetTime across all over-threshold accounts.
7637
- * Returns null if no resetTime data is available.
7669
+ * Get minimum wait time until any eligible account's soft quota resets.
7670
+ * Operates over the eligible subset (enabled, non-ineligible, non-verification-required,
7671
+ * and present in `eligibleIndexes` when provided).
7672
+ * Returns null if no eligible accounts remain or no resetTime data is available.
7673
+ * Returns 0 if only 1 eligible account exists or any eligible account is below threshold.
7674
+ * Returns the minimum resetTime across all over-threshold eligible accounts.
7638
7675
  */
7639
- getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
7676
+ getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
7640
7677
  if (thresholdPercent >= 100)
7641
7678
  return 0;
7642
- const enabled = this.accounts.filter((a) => a.enabled !== false);
7643
- if (enabled.length === 0)
7679
+ const eligible = this.accounts.filter((a) => a.enabled !== false && a.accountIneligible !== true && a.verificationRequired !== true && (eligibleIndexes == null || eligibleIndexes.has(a.index)));
7680
+ if (eligible.length === 0)
7644
7681
  return null;
7645
- if (enabled.length === 1)
7682
+ if (eligible.length === 1)
7646
7683
  return 0;
7647
- const available = enabled.filter((a) => !isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
7684
+ const available = eligible.filter((a) => !isOverSoftQuotaThreshold(a, family, thresholdPercent, cacheTtlMs, this.now, model));
7648
7685
  if (available.length > 0)
7649
7686
  return 0;
7650
7687
  if (!model && family !== "claude")
7651
7688
  return null;
7652
7689
  const now = this.now();
7653
7690
  const waitTimes = [];
7654
- for (const acc of enabled) {
7691
+ for (const acc of eligible) {
7655
7692
  const quotaGroup = resolveQuotaGroup(family, model, acc.cachedQuota);
7656
7693
  const groupData = acc.cachedQuota?.[quotaGroup];
7657
7694
  if (groupData?.resetTime) {
@@ -8083,7 +8120,7 @@ function writeConsoleLog(level, ...args) {
8083
8120
  }
8084
8121
  function createLogger(module) {
8085
8122
  const service = `antigravity.${module}`;
8086
- const log16 = (level, message, extra) => {
8123
+ const log17 = (level, message, extra) => {
8087
8124
  if (_sink) {
8088
8125
  try {
8089
8126
  _sink({ service, level, message, extra });
@@ -8097,10 +8134,10 @@ function createLogger(module) {
8097
8134
  }
8098
8135
  };
8099
8136
  return {
8100
- debug: (message, extra) => log16("debug", message, extra),
8101
- info: (message, extra) => log16("info", message, extra),
8102
- warn: (message, extra) => log16("warn", message, extra),
8103
- error: (message, extra) => log16("error", message, extra)
8137
+ debug: (message, extra) => log17("debug", message, extra),
8138
+ info: (message, extra) => log17("info", message, extra),
8139
+ warn: (message, extra) => log17("warn", message, extra),
8140
+ error: (message, extra) => log17("error", message, extra)
8104
8141
  };
8105
8142
  }
8106
8143
  var ENV_CONSOLE_LOG, _sink;
@@ -9656,8 +9693,24 @@ var init_account_manager = __esm({
9656
9693
  expires: account.expires
9657
9694
  };
9658
9695
  }
9659
- getMinWaitTimeForFamily(family, model) {
9660
- return this.selection.getMinWaitTimeForFamily(family, model);
9696
+ /**
9697
+ * Calculates the minimum wait time in milliseconds across eligible accounts
9698
+ * for a given model family (and optional model).
9699
+ *
9700
+ * Note: Returning `0` can mean either:
9701
+ * 1. No eligible candidates exist in the pool, OR
9702
+ * 2. At least one eligible candidate is immediately usable without waiting.
9703
+ * Callers must distinguish "no eligible candidates" from "zero wait time"
9704
+ * by inspecting candidate pool availability / eligibility directly.
9705
+ *
9706
+ * @param family Model family (e.g., 'claude', 'gemini')
9707
+ * @param model Optional model name for per-model rate limits
9708
+ * @param eligibleIndexes Optional set of account indexes permitted for this request
9709
+ * @param includeCooldown Whether to factor in `coolingDownUntil` alongside quota rate limits
9710
+ * @returns Minimum wait duration in milliseconds, or 0 if immediately usable or no candidates
9711
+ */
9712
+ getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown = false) {
9713
+ return this.selection.getMinWaitTimeForFamily(family, model, eligibleIndexes, includeCooldown);
9661
9714
  }
9662
9715
  getAccounts() {
9663
9716
  return this.selection.getAccounts();
@@ -10000,17 +10053,23 @@ var init_account_manager = __esm({
10000
10053
  getOldestQuotaCacheAge() {
10001
10054
  return this.selection.getOldestQuotaCacheAge();
10002
10055
  }
10003
- areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
10004
- return this.selection.areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model);
10056
+ /**
10057
+ * Check whether all eligible accounts (more than 1) are currently over the soft-quota threshold.
10058
+ * Returns false if thresholdPercent >= 100 or if <= 1 eligible account remains.
10059
+ */
10060
+ areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
10061
+ return this.selection.areAllAccountsOverSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
10005
10062
  }
10006
10063
  /**
10007
- * Get minimum wait time until any account's soft quota resets.
10008
- * Returns 0 if any account is available (not over threshold).
10009
- * Returns the minimum resetTime across all over-threshold accounts.
10010
- * Returns null if no resetTime data is available.
10064
+ * Get minimum wait time until any eligible account's soft quota resets.
10065
+ * Operates over the eligible subset (enabled, non-ineligible, non-verification-required,
10066
+ * and present in `eligibleIndexes` when provided).
10067
+ * Returns null if no eligible accounts remain or no resetTime data is available.
10068
+ * Returns 0 if only 1 eligible account exists or any eligible account is below threshold.
10069
+ * Returns the minimum resetTime across all over-threshold eligible accounts.
10011
10070
  */
10012
- getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model) {
10013
- return this.selection.getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model);
10071
+ getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes) {
10072
+ return this.selection.getMinWaitTimeForSoftQuota(family, thresholdPercent, cacheTtlMs, model, eligibleIndexes);
10014
10073
  }
10015
10074
  };
10016
10075
  }
@@ -25267,13 +25326,13 @@ async function safeRead(path5, privateFile = false, afterReadCheck) {
25267
25326
  let file;
25268
25327
  try {
25269
25328
  file = await open7(path5, constants2.O_RDONLY | constants2.O_NOFOLLOW);
25270
- const stat15 = await file.stat();
25271
- if (!stat15.isFile() || privateFile && (stat15.mode & 511) !== 384) {
25329
+ const stat16 = await file.stat();
25330
+ if (!stat16.isFile() || privateFile && (stat16.mode & 511) !== 384) {
25272
25331
  throw new PiSlotError("unsafe-path");
25273
25332
  }
25274
25333
  await afterReadCheck?.(path5);
25275
25334
  const current = await lstat5(path5);
25276
- if (!current.isFile() || current.dev !== stat15.dev || current.ino !== stat15.ino) {
25335
+ if (!current.isFile() || current.dev !== stat16.dev || current.ino !== stat16.ino) {
25277
25336
  throw new PiSlotError("unsafe-path");
25278
25337
  }
25279
25338
  const bytes = await file.readFile();
@@ -28694,7 +28753,7 @@ function getAntigravityVersionResolution() {
28694
28753
  return lastResolution ?? { version: getAntigravityVersion(), source: "fallback" };
28695
28754
  }
28696
28755
  async function initAntigravityVersion() {
28697
- const log16 = createLogger("version");
28756
+ const log17 = createLogger("version");
28698
28757
  const fallback = getAntigravityVersion();
28699
28758
  let version;
28700
28759
  let source;
@@ -28708,15 +28767,15 @@ async function initAntigravityVersion() {
28708
28767
  } else {
28709
28768
  source = "fallback";
28710
28769
  setAntigravityVersion(fallback);
28711
- log16.info("version-fetch-failed", { fallback });
28770
+ log17.info("version-fetch-failed", { fallback });
28712
28771
  lastResolution = { version: fallback, source };
28713
28772
  return lastResolution;
28714
28773
  }
28715
28774
  }
28716
28775
  if (version !== fallback) {
28717
- log16.info("version-updated", { version, source, previous: fallback });
28776
+ log17.info("version-updated", { version, source, previous: fallback });
28718
28777
  } else {
28719
- log16.debug("version-unchanged", { version, source });
28778
+ log17.debug("version-unchanged", { version, source });
28720
28779
  }
28721
28780
  setAntigravityVersion(version);
28722
28781
  lastResolution = { version, source };
@@ -28786,13 +28845,6 @@ var init_dist = __esm({
28786
28845
  }
28787
28846
  });
28788
28847
 
28789
- // src/common-auth-embedded/logger/capture-sink.js
28790
- var init_capture_sink2 = __esm({
28791
- "src/common-auth-embedded/logger/capture-sink.js"() {
28792
- "use strict";
28793
- }
28794
- });
28795
-
28796
28848
  // src/common-auth-embedded/fs/private-files.js
28797
28849
  import { randomUUID as randomUUID13 } from "node:crypto";
28798
28850
  import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
@@ -29090,6 +29142,13 @@ var init_private_files2 = __esm({
29090
29142
  }
29091
29143
  });
29092
29144
 
29145
+ // src/common-auth-embedded/logger/capture-sink.js
29146
+ var init_capture_sink2 = __esm({
29147
+ "src/common-auth-embedded/logger/capture-sink.js"() {
29148
+ "use strict";
29149
+ }
29150
+ });
29151
+
29093
29152
  // src/common-auth-embedded/logger/redact.js
29094
29153
  function isError2(value) {
29095
29154
  return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
@@ -30917,8 +30976,8 @@ var init_process_heartbeat = __esm({
30917
30976
  });
30918
30977
 
30919
30978
  // src/version-fence.ts
30920
- import { readdir as readdir2, readFile as readFile11 } from "node:fs/promises";
30921
- import { homedir as homedir3 } from "node:os";
30979
+ import { readdir as readdir2, readFile as readFile11, stat as stat9, unlink as unlink9 } from "node:fs/promises";
30980
+ import { homedir as homedir3, uptime } from "node:os";
30922
30981
  import { join as join13 } from "node:path";
30923
30982
  function defaultStateHome() {
30924
30983
  return process.env.XDG_STATE_HOME || join13(homedir3(), ".local", "state");
@@ -31001,13 +31060,18 @@ async function readProcessRecord(path5, pid) {
31001
31060
  return { kind: "gone" };
31002
31061
  return { kind: "unreadable" };
31003
31062
  }
31063
+ let startedAt;
31004
31064
  try {
31005
31065
  const value = JSON.parse(text2);
31066
+ if (isRecord10(value) && typeof value.startedAt === "number" && Number.isFinite(value.startedAt))
31067
+ startedAt = value.startedAt;
31006
31068
  if (value !== null && typeof value === "object" && value.pid === pid && typeof value.version === "string") {
31007
31069
  const layouts = value.layouts;
31008
31070
  const stores = value.stores;
31009
31071
  return {
31010
31072
  kind: "ok",
31073
+ text: text2,
31074
+ startedAt,
31011
31075
  version: value.version,
31012
31076
  ...isRecord10(layouts) ? { layouts } : {},
31013
31077
  ...isRecord10(stores) ? { stores } : {}
@@ -31015,14 +31079,45 @@ async function readProcessRecord(path5, pid) {
31015
31079
  }
31016
31080
  } catch {
31017
31081
  }
31018
- return { kind: "unreadable" };
31082
+ return { kind: "unreadable", text: text2, startedAt };
31019
31083
  }
31020
31084
  function isRecord10(value) {
31021
31085
  return value !== null && typeof value === "object" && !Array.isArray(value);
31022
31086
  }
31087
+ function bootTime(options) {
31088
+ try {
31089
+ return (options.now ?? Date.now)() - (options.uptimeSeconds ?? uptime)() * 1e3;
31090
+ } catch {
31091
+ return Number.NaN;
31092
+ }
31093
+ }
31094
+ async function staleRecord(path5, record3, boot, heartbeat) {
31095
+ if (record3.text === void 0 || !Number.isFinite(boot)) return false;
31096
+ let start = heartbeat ? record3.startedAt : void 0;
31097
+ if (start === void 0) {
31098
+ try {
31099
+ start = (await stat9(path5)).mtimeMs;
31100
+ } catch {
31101
+ return false;
31102
+ }
31103
+ }
31104
+ if (!Number.isFinite(start) || !(start < boot - BOOT_TIME_MARGIN_MS))
31105
+ return false;
31106
+ if (heartbeat) {
31107
+ try {
31108
+ if (await readFile11(path5, "utf8") === record3.text) {
31109
+ await unlink9(path5);
31110
+ log5.debug("Removed stale pre-boot heartbeat", { path: path5 });
31111
+ }
31112
+ } catch {
31113
+ }
31114
+ }
31115
+ return true;
31116
+ }
31023
31117
  async function versionFenceOpen(options) {
31024
31118
  const isAlive = options.isAlive ?? pidAlive;
31025
31119
  const self = options.selfPid ?? process.pid;
31120
+ const boot = bootTime(options);
31026
31121
  const blockers = /* @__PURE__ */ new Map();
31027
31122
  const block = (entry) => {
31028
31123
  const key = entry.pid === "unknown" ? `dir:${entry.detail}` : entry.pid;
@@ -31045,7 +31140,8 @@ async function versionFenceOpen(options) {
31045
31140
  const path5 = join13(heartbeatDir, name);
31046
31141
  const heartbeat = await readProcessRecord(path5, pid);
31047
31142
  if (heartbeat.kind === "gone") continue;
31048
- if (!alive(pid)) continue;
31143
+ const live = alive(pid);
31144
+ if (await staleRecord(path5, heartbeat, boot, true) || !live) continue;
31049
31145
  if (heartbeat.kind === "unreadable") {
31050
31146
  block({ pid, version: "unknown", detail: path5 });
31051
31147
  continue;
@@ -31079,6 +31175,7 @@ async function versionFenceOpen(options) {
31079
31175
  const path5 = join13(dir, name);
31080
31176
  const port = await readProcessRecord(path5, pid);
31081
31177
  if (port.kind === "gone") continue;
31178
+ if (await staleRecord(path5, port, boot, false)) continue;
31082
31179
  const version = port.kind === "ok" ? port.version : "unknown";
31083
31180
  const order = compareVersions(version, options.currentVersion);
31084
31181
  if (order === void 0 || order < 0)
@@ -31091,9 +31188,13 @@ async function versionFenceOpen(options) {
31091
31188
  blockers: [...blockers.values()].sort((a, b) => rank(a) - rank(b))
31092
31189
  };
31093
31190
  }
31191
+ var log5, BOOT_TIME_MARGIN_MS;
31094
31192
  var init_version_fence = __esm({
31095
31193
  "src/version-fence.ts"() {
31096
31194
  "use strict";
31195
+ init_logger4();
31196
+ log5 = createLogger4("version-fence");
31197
+ BOOT_TIME_MARGIN_MS = 3e5;
31097
31198
  }
31098
31199
  });
31099
31200
 
@@ -31124,8 +31225,8 @@ import {
31124
31225
  readFile as readFile12,
31125
31226
  rename as rename10,
31126
31227
  rmdir as rmdir2,
31127
- stat as stat9,
31128
- unlink as unlink9
31228
+ stat as stat10,
31229
+ unlink as unlink10
31129
31230
  } from "node:fs/promises";
31130
31231
  import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve15 } from "node:path";
31131
31232
  function refusalMessage(stateDir, errorClass2) {
@@ -31180,10 +31281,10 @@ function errorFile(error) {
31180
31281
  ...typeof stage === "string" && stage ? { stage } : {}
31181
31282
  };
31182
31283
  }
31183
- function logCleanupFailure(location, log16, step, error) {
31284
+ function logCleanupFailure(location, log17, step, error) {
31184
31285
  logOnce(
31185
31286
  `${location.key}\0cleanup`,
31186
- () => log16.warn(
31287
+ () => log17.warn(
31187
31288
  "antigravity-auth could not finish removing its old vault files from OpenCode's config folder; it tries again at the next start",
31188
31289
  {
31189
31290
  configDir: location.configDir,
@@ -31212,13 +31313,13 @@ function prepareRuntimeLayout(options) {
31212
31313
  return run;
31213
31314
  }
31214
31315
  async function decide(location, options) {
31215
- const log16 = options.log ?? createLogger4("runtime-layout");
31316
+ const log17 = options.log ?? createLogger4("runtime-layout");
31216
31317
  const stateDir = location.stateHomeDir;
31217
31318
  const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
31218
31319
  const files = layoutFiles(location, options.accountFile);
31219
31320
  const fence = options.fence ?? defaultFence(options.version);
31220
31321
  const stateHome = async () => {
31221
- await settleVault(location, options, "state-home", log16);
31322
+ await settleVault(location, options, "state-home", log17);
31222
31323
  return "state-home";
31223
31324
  };
31224
31325
  let marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -31229,7 +31330,7 @@ async function decide(location, options) {
31229
31330
  join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
31230
31331
  ).catch(() => true);
31231
31332
  if (!manifestLeft) {
31232
- await settleVault(location, options, "state-home", log16);
31333
+ await settleVault(location, options, "state-home", log17);
31233
31334
  return stateHome();
31234
31335
  }
31235
31336
  }
@@ -31241,7 +31342,7 @@ async function decide(location, options) {
31241
31342
  RUNTIME_LAYOUT_LOCK_NAME,
31242
31343
  markerPath,
31243
31344
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
31244
- log16
31345
+ log17
31245
31346
  );
31246
31347
  } catch (error) {
31247
31348
  marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -31261,7 +31362,7 @@ async function decide(location, options) {
31261
31362
  const legacy = async () => {
31262
31363
  try {
31263
31364
  await lock.assertOwned();
31264
- await settleVault(location, options, "legacy", log16);
31365
+ await settleVault(location, options, "legacy", log17);
31265
31366
  } catch (error) {
31266
31367
  throw new RuntimeLayoutRefusal(stateDir, errorClass(error));
31267
31368
  }
@@ -31275,20 +31376,20 @@ async function decide(location, options) {
31275
31376
  if (!marker.oldFilesRemoved && !aliased)
31276
31377
  await finishOldFiles(location, files, markerPath, marker, lock, {
31277
31378
  fence,
31278
- log: log16,
31379
+ log: log17,
31279
31380
  steps: options.steps,
31280
31381
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile()
31281
31382
  });
31282
31383
  else if (marker.oldFilesRemoved) {
31283
31384
  await refuseReappearedFiles(location, files);
31284
- await removeLeftoverManifest(location, lock, options.steps, log16);
31385
+ await removeLeftoverManifest(location, lock, options.steps, log17);
31285
31386
  }
31286
31387
  return await stateHome();
31287
31388
  }
31288
31389
  if (aliased) {
31289
31390
  logOnce(
31290
31391
  `${location.key}\0aliased`,
31291
- () => log16.warn(
31392
+ () => log17.warn(
31292
31393
  "antigravity-auth keeps its vault files in OpenCode's config folder: its state folder is that same folder",
31293
31394
  { configDir: location.configDir, stateDir }
31294
31395
  )
@@ -31297,14 +31398,14 @@ async function decide(location, options) {
31297
31398
  }
31298
31399
  const gate = await fence();
31299
31400
  if (!gate.open) {
31300
- logDeferral(location, gate.blockers, log16);
31401
+ logDeferral(location, gate.blockers, log17);
31301
31402
  return await legacy();
31302
31403
  }
31303
31404
  let markerStarted = false;
31304
31405
  try {
31305
31406
  const outcome = await moveFiles(location, files, markerPath, lock, {
31306
31407
  fence,
31307
- log: log16,
31408
+ log: log17,
31308
31409
  steps: options.steps,
31309
31410
  destinationPrivate: options.destinationPrivate ?? defaultDestinationPrivate,
31310
31411
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile(),
@@ -31313,13 +31414,13 @@ async function decide(location, options) {
31313
31414
  }
31314
31415
  });
31315
31416
  if (outcome.kind === "deferred") {
31316
- logDeferral(location, outcome.blockers, log16);
31417
+ logDeferral(location, outcome.blockers, log17);
31317
31418
  return await legacy();
31318
31419
  }
31319
31420
  if (outcome.kind === "refused") {
31320
31421
  logOnce(
31321
31422
  `${location.key}\0refused`,
31322
- () => log16.warn(
31423
+ () => log17.warn(
31323
31424
  outcome.reason === "destination-not-private" ? "antigravity-auth keeps its vault files in OpenCode's config folder: the vault folder in its state folder already exists and is not private to your user. It was left unchanged; remove it if it holds nothing you need, then restart OpenCode." : "antigravity-auth keeps its vault files in OpenCode's config folder: it will not move them",
31324
31425
  { reason: outcome.reason, paths: outcome.paths, stateDir }
31325
31426
  )
@@ -31327,7 +31428,7 @@ async function decide(location, options) {
31327
31428
  return await legacy();
31328
31429
  }
31329
31430
  if (outcome.moved)
31330
- log16.info(
31431
+ log17.info(
31331
31432
  "antigravity-auth moved its vault files out of OpenCode's config folder",
31332
31433
  { from: files.vault.old, to: files.vault.next }
31333
31434
  );
@@ -31338,7 +31439,7 @@ async function decide(location, options) {
31338
31439
  return await stateHome();
31339
31440
  logOnce(
31340
31441
  `${location.key}\0failed`,
31341
- () => log16.warn(
31442
+ () => log17.warn(
31342
31443
  "antigravity-auth's vault files stay in OpenCode's config folder: moving them failed; the move is tried again at the next start",
31343
31444
  {
31344
31445
  configDir: location.configDir,
@@ -31367,8 +31468,12 @@ async function settleVault(location, options, layout, _log) {
31367
31468
  }
31368
31469
  async function localAccountStoreAuthorized() {
31369
31470
  const location = runtimeLayoutLocation();
31471
+ const folder = process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR ? (await Promise.resolve().then(() => (init_vault_folder(), vault_folder_exports))).currentVaultFolder(
31472
+ accountFileForVault(location.configDir)
31473
+ ) : void 0;
31474
+ if (folder?.refusal) return false;
31370
31475
  const claustrum = await loadCommonAuthClaustrum();
31371
- const vaultDir = decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
31476
+ const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
31372
31477
  return await enrollmentAuthority2(
31373
31478
  claustrum.hostEnrollmentPaths({
31374
31479
  stateDir: vaultDir,
@@ -31383,7 +31488,7 @@ async function prepareAccountStore(options) {
31383
31488
  if (!await localAccountStoreAuthorized()) return void 0;
31384
31489
  const decided = decidedAccountStoreAnchor(location);
31385
31490
  if (decided) return decided;
31386
- const log16 = options.log ?? createLogger4("runtime-layout");
31491
+ const log17 = options.log ?? createLogger4("runtime-layout");
31387
31492
  const runKey = `${location.stateHomeDir}\0${location.key}`;
31388
31493
  let run = processState.storeRuns.get(runKey);
31389
31494
  if (!run) {
@@ -31394,12 +31499,12 @@ async function prepareAccountStore(options) {
31394
31499
  RUNTIME_LAYOUT_LOCK_NAME,
31395
31500
  join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
31396
31501
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
31397
- log16
31502
+ log17
31398
31503
  );
31399
31504
  try {
31400
31505
  await lock.assertOwned();
31401
31506
  if (!await localAccountStoreAuthorized()) return void 0;
31402
- return await settleAccountStore(location, options, log16);
31507
+ return await settleAccountStore(location, options, log17);
31403
31508
  } finally {
31404
31509
  await lock.release();
31405
31510
  }
@@ -31410,20 +31515,20 @@ async function prepareAccountStore(options) {
31410
31515
  }
31411
31516
  return run;
31412
31517
  }
31413
- async function settleAccountStore(location, options, log16) {
31518
+ async function settleAccountStore(location, options, log17) {
31414
31519
  const decided = decidedAccountStoreAnchor(location);
31415
31520
  if (decided) return decided;
31416
- const anchor = await decideAccountStore(location, options, log16);
31521
+ const anchor = await decideAccountStore(location, options, log17);
31417
31522
  setAccountStoreAnchor(location, anchor);
31418
31523
  return anchor;
31419
31524
  }
31420
- async function decideAccountStore(location, options, log16) {
31421
- const keepConfig = () => recordAnchor(location, options, "config", log16);
31525
+ async function decideAccountStore(location, options, log17) {
31526
+ const keepConfig = () => recordAnchor(location, options, "config", log17);
31422
31527
  if (processHasOlderGeneration()) {
31423
31528
  logOnce(
31424
31529
  "older-generation-account-store",
31425
31530
  () => showLog(
31426
- log16,
31531
+ log17,
31427
31532
  "antigravity-auth keeps the account store in OpenCode's config folder until OpenCode restarts, because an older version of the plugin ran in this process.",
31428
31533
  { accountStore: "config" }
31429
31534
  )
@@ -31437,7 +31542,7 @@ async function decideAccountStore(location, options, log16) {
31437
31542
  if (!sameSpelling(forward.legacyPath, stateAnchor)) {
31438
31543
  logOnce(
31439
31544
  `${location.key}\0store-forward-elsewhere`,
31440
- () => log16.warn(
31545
+ () => log17.warn(
31441
31546
  "the account store moved to another folder than this process resolved; check XDG_STATE_HOME",
31442
31547
  { movedTo: forward.legacyPath, expected: stateAnchor }
31443
31548
  )
@@ -31448,9 +31553,9 @@ async function decideAccountStore(location, options, log16) {
31448
31553
  options,
31449
31554
  configAnchor,
31450
31555
  stateAnchor,
31451
- log16
31556
+ log17
31452
31557
  );
31453
- return recordAnchor(location, options, "state-home", log16);
31558
+ return recordAnchor(location, options, "state-home", log17);
31454
31559
  }
31455
31560
  if (decidedRuntimeLayout(location) === "legacy") return keepConfig();
31456
31561
  const configStore = await presentAccountStore(configAnchor);
@@ -31462,9 +31567,9 @@ async function decideAccountStore(location, options, log16) {
31462
31567
  `antigravity-auth cannot start: two account stores exist, one at ${configAnchor} and one at ${stateAnchor}, and neither is marked as moved. Keep the one you want and move the other one aside, then restart OpenCode.`
31463
31568
  );
31464
31569
  }
31465
- if (stateStore) return recordAnchor(location, options, "state-home", log16);
31570
+ if (stateStore) return recordAnchor(location, options, "state-home", log17);
31466
31571
  if (configStore) {
31467
- if (!await storeMovePathResolves(stateAnchor, location, log16))
31572
+ if (!await storeMovePathResolves(stateAnchor, location, log17))
31468
31573
  return keepConfig();
31469
31574
  return moveStore(
31470
31575
  location,
@@ -31472,21 +31577,21 @@ async function decideAccountStore(location, options, log16) {
31472
31577
  configAnchor,
31473
31578
  stateAnchor,
31474
31579
  false,
31475
- log16,
31580
+ log17,
31476
31581
  false
31477
31582
  );
31478
31583
  }
31479
- if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log16))
31584
+ if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log17))
31480
31585
  return keepConfig();
31481
- if (!await storeMovePathResolves(stateAnchor, location, log16))
31586
+ if (!await storeMovePathResolves(stateAnchor, location, log17))
31482
31587
  return keepConfig();
31483
- return initializeStore(location, options, stateAnchor, log16);
31588
+ return initializeStore(location, options, stateAnchor, log17);
31484
31589
  }
31485
- function showLog(log16, message, meta) {
31486
- if (log16.log) log16.log(message, meta);
31487
- else log16.info(message, meta);
31590
+ function showLog(log17, message, meta) {
31591
+ if (log17.log) log17.log(message, meta);
31592
+ else log17.info(message, meta);
31488
31593
  }
31489
- async function recordAnchor(location, options, anchor, log16) {
31594
+ async function recordAnchor(location, options, anchor, log17) {
31490
31595
  try {
31491
31596
  await recordProcessAnchor({
31492
31597
  key: location.key,
@@ -31498,32 +31603,32 @@ async function recordAnchor(location, options, anchor, log16) {
31498
31603
  }
31499
31604
  if (anchor === "state-home")
31500
31605
  showLog(
31501
- log16,
31606
+ log17,
31502
31607
  "antigravity-auth keeps its account store in its state folder",
31503
31608
  { accountStore: anchor }
31504
31609
  );
31505
31610
  return anchor;
31506
31611
  }
31507
- async function storeMovePathResolves(stateAnchor, location, log16) {
31612
+ async function storeMovePathResolves(stateAnchor, location, log17) {
31508
31613
  if (folderResolvesToItself(
31509
31614
  join14(location.stateHomeDir, "antigravity-accounts.json")
31510
31615
  ))
31511
31616
  return true;
31512
31617
  logOnce(
31513
31618
  `${location.key}\0store-linked-path`,
31514
- () => log16.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
31619
+ () => log17.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
31515
31620
  accountStore: stateAnchor,
31516
31621
  stateFolder: location.stateHomeDir
31517
31622
  })
31518
31623
  );
31519
31624
  return false;
31520
31625
  }
31521
- async function storeFenceOpen(location, options, log16) {
31626
+ async function storeFenceOpen(location, options, log17) {
31522
31627
  const gate = await (options.storeFence ?? defaultStoreFence(options.version))();
31523
31628
  if (gate.open) return true;
31524
31629
  logOnce(
31525
31630
  `${location.key}\0store-version-fence`,
31526
- () => log16.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31631
+ () => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31527
31632
  configDir: location.configDir,
31528
31633
  blockers: gate.blockers
31529
31634
  })
@@ -31550,7 +31655,7 @@ async function storeArtefacts(anchor) {
31550
31655
  (name) => name === store || name.startsWith(`${pool}.store.`) || name.startsWith(pool) && name.endsWith(".tmp")
31551
31656
  ).length;
31552
31657
  }
31553
- async function abandonUnpublishedStore(location, stateAnchor, log16) {
31658
+ async function abandonUnpublishedStore(location, stateAnchor, log17) {
31554
31659
  const store = await loadCommonAuthStoreModules();
31555
31660
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
31556
31661
  if (binding.status === "bound") return false;
@@ -31559,9 +31664,9 @@ async function abandonUnpublishedStore(location, stateAnchor, log16) {
31559
31664
  await rename10(folder, archived).catch((error) => {
31560
31665
  if (error.code !== "ENOENT") throw error;
31561
31666
  });
31562
- await unlink9(accountStorePointerPath(stateAnchor)).catch(() => {
31667
+ await unlink10(accountStorePointerPath(stateAnchor)).catch(() => {
31563
31668
  });
31564
- log16.info(
31669
+ log17.info(
31565
31670
  "antigravity-auth set an unfinished account store aside before starting its move again",
31566
31671
  { configDir: location.configDir, archived }
31567
31672
  );
@@ -31583,9 +31688,9 @@ async function runStoreMove(input2) {
31583
31688
  return { status: "pending", reason: outcome.reason };
31584
31689
  return { status: "cancelled" };
31585
31690
  }
31586
- async function moveStore(location, options, source, target, back, log16, forwarded) {
31587
- const keepConfig = () => recordAnchor(location, options, "config", log16);
31588
- if (!await storeFenceOpen(location, options, log16)) return keepConfig();
31691
+ async function moveStore(location, options, source, target, back, log17, forwarded) {
31692
+ const keepConfig = () => recordAnchor(location, options, "config", log17);
31693
+ if (!await storeFenceOpen(location, options, log17)) return keepConfig();
31589
31694
  try {
31590
31695
  const result = await (options.relocate ?? runStoreMove)({
31591
31696
  source,
@@ -31595,7 +31700,7 @@ async function moveStore(location, options, source, target, back, log16, forward
31595
31700
  if (result.status !== "completed") {
31596
31701
  logOnce(
31597
31702
  `${location.key}\0store-move-unfinished`,
31598
- () => log16.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31703
+ () => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31599
31704
  configDir: location.configDir,
31600
31705
  reason: result.status === "pending" ? result.reason : result.status
31601
31706
  })
@@ -31603,14 +31708,14 @@ async function moveStore(location, options, source, target, back, log16, forward
31603
31708
  return forwarded ? "state-home" : keepConfig();
31604
31709
  }
31605
31710
  showLog(
31606
- log16,
31711
+ log17,
31607
31712
  "antigravity-auth moved the account store out of OpenCode's config folder",
31608
31713
  { from: source, to: target, generation: result.id }
31609
31714
  );
31610
31715
  } catch (error) {
31611
31716
  logOnce(
31612
31717
  `${location.key}\0store-move-failed`,
31613
- () => log16.warn(
31718
+ () => log17.warn(
31614
31719
  "antigravity-auth's account store stays in OpenCode's config folder: moving it failed; the move is tried again at the next start",
31615
31720
  {
31616
31721
  configDir: location.configDir,
@@ -31621,9 +31726,9 @@ async function moveStore(location, options, source, target, back, log16, forward
31621
31726
  );
31622
31727
  return forwarded ? "state-home" : keepConfig();
31623
31728
  }
31624
- return recordAnchor(location, options, "state-home", log16);
31729
+ return recordAnchor(location, options, "state-home", log17);
31625
31730
  }
31626
- async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log16) {
31731
+ async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log17) {
31627
31732
  const store = await loadCommonAuthStoreModules();
31628
31733
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
31629
31734
  if (binding.status === "bound") return;
@@ -31634,13 +31739,13 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
31634
31739
  configAnchor,
31635
31740
  stateAnchor,
31636
31741
  false,
31637
- log16,
31742
+ log17,
31638
31743
  true
31639
31744
  );
31640
31745
  } catch (error) {
31641
31746
  logOnce(
31642
31747
  `${location.key}\0store-resume-failed`,
31643
- () => log16.warn(
31748
+ () => log17.warn(
31644
31749
  "antigravity-auth's account store is still moving; it could not be finished at this start",
31645
31750
  {
31646
31751
  configDir: location.configDir,
@@ -31651,9 +31756,9 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
31651
31756
  );
31652
31757
  }
31653
31758
  }
31654
- async function initializeStore(location, options, stateAnchor, log16) {
31655
- const keepConfig = () => recordAnchor(location, options, "config", log16);
31656
- if (!await storeFenceOpen(location, options, log16)) return keepConfig();
31759
+ async function initializeStore(location, options, stateAnchor, log17) {
31760
+ const keepConfig = () => recordAnchor(location, options, "config", log17);
31761
+ if (!await storeFenceOpen(location, options, log17)) return keepConfig();
31657
31762
  try {
31658
31763
  const store = await loadCommonAuthStoreModules();
31659
31764
  const created = await initializeFreshAccountStore(store, {
@@ -31666,7 +31771,7 @@ async function initializeStore(location, options, stateAnchor, log16) {
31666
31771
  } catch (error) {
31667
31772
  logOnce(
31668
31773
  `${location.key}\0store-init-failed`,
31669
- () => log16.warn(
31774
+ () => log17.warn(
31670
31775
  "antigravity-auth's account store stays in OpenCode's config folder: creating it in its state folder failed; it is tried again at the next start",
31671
31776
  {
31672
31777
  configDir: location.configDir,
@@ -31678,13 +31783,13 @@ async function initializeStore(location, options, stateAnchor, log16) {
31678
31783
  return keepConfig();
31679
31784
  }
31680
31785
  showLog(
31681
- log16,
31786
+ log17,
31682
31787
  "antigravity-auth created its account store in its state folder",
31683
31788
  {
31684
31789
  accountStore: stateAnchor
31685
31790
  }
31686
31791
  );
31687
- return recordAnchor(location, options, "state-home", log16);
31792
+ return recordAnchor(location, options, "state-home", log17);
31688
31793
  }
31689
31794
  async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacyAccountFile(runtimeLayoutLocation().configDir)) {
31690
31795
  const forward = {
@@ -31699,10 +31804,10 @@ async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacy
31699
31804
  durability: "file-only-on-windows"
31700
31805
  });
31701
31806
  }
31702
- function logDeferral(location, blockers, log16) {
31807
+ function logDeferral(location, blockers, log17) {
31703
31808
  logOnce(
31704
31809
  `${location.key}\0deferred`,
31705
- () => log16.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
31810
+ () => log17.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
31706
31811
  configDir: location.configDir,
31707
31812
  blockers
31708
31813
  })
@@ -31751,7 +31856,7 @@ async function moveFiles(location, files, markerPath, layoutLock, input2) {
31751
31856
  for (const path5 of listed) {
31752
31857
  if (wanted.has(path5)) continue;
31753
31858
  await layoutLock.assertOwned();
31754
- await unlink9(path5).catch((error) => {
31859
+ await unlink10(path5).catch((error) => {
31755
31860
  if (error.code !== "ENOENT") throw error;
31756
31861
  });
31757
31862
  }
@@ -31860,13 +31965,13 @@ async function finishOldFiles(location, files, markerPath, marker, layoutLock, i
31860
31965
  if (done) await removeOldVaultFolder(files, layoutLock, input2.steps);
31861
31966
  }
31862
31967
  }
31863
- async function removeLeftoverManifest(location, layoutLock, steps, log16) {
31968
+ async function removeLeftoverManifest(location, layoutLock, steps, log17) {
31864
31969
  try {
31865
31970
  await removeManifestOwned(location.stateHomeDir, layoutLock, steps);
31866
31971
  } catch (error) {
31867
31972
  logOnce(
31868
31973
  `${location.key}\0manifest`,
31869
- () => log16.warn(
31974
+ () => log17.warn(
31870
31975
  `antigravity-auth could not remove ${RUNTIME_LAYOUT_MANIFEST_FILE} from its state folder; it tries again at the next start`,
31871
31976
  { stateDir: location.stateHomeDir, errorClass: errorClass(error) }
31872
31977
  )
@@ -31886,16 +31991,16 @@ async function removeOldVaultFolder(files, layoutLock, steps) {
31886
31991
  } catch {
31887
31992
  }
31888
31993
  }
31889
- async function removeOldSignatureCache(location, path5, layoutLock, steps, log16) {
31994
+ async function removeOldSignatureCache(location, path5, layoutLock, steps, log17) {
31890
31995
  try {
31891
31996
  if (!await exists2(path5)) return;
31892
31997
  await beforeRemove(path5, layoutLock, steps);
31893
- await unlink9(path5);
31998
+ await unlink10(path5);
31894
31999
  } catch (error) {
31895
32000
  if (error?.code === "ENOENT") return;
31896
32001
  logOnce(
31897
32002
  `${location.key}\0signature-cache`,
31898
- () => log16.warn(
32003
+ () => log17.warn(
31899
32004
  "antigravity-auth could not remove its old signature cache from OpenCode's config folder; it is no longer used and can be deleted",
31900
32005
  { path: path5, errorClass: errorClass(error) }
31901
32006
  )
@@ -31906,7 +32011,7 @@ async function beforeRemove(path5, layoutLock, steps) {
31906
32011
  await steps?.beforeRemove?.(path5);
31907
32012
  await layoutLock.assertOwned();
31908
32013
  }
31909
- async function takeDataLocks(files, log16) {
32014
+ async function takeDataLocks(files, log17) {
31910
32015
  const locks = [];
31911
32016
  try {
31912
32017
  if (await exists2(files.vault.old))
@@ -31916,7 +32021,7 @@ async function takeDataLocks(files, log16) {
31916
32021
  lock.name,
31917
32022
  join14(files.vault.old, lock.file),
31918
32023
  lock.waitMs,
31919
- log16
32024
+ log17
31920
32025
  )
31921
32026
  );
31922
32027
  return locks;
@@ -31980,6 +32085,7 @@ async function isVaultShapedKeptState(files) {
31980
32085
  return vaultShape && proposedName === OPENCODE_VAULT_ENROLLMENT_NAME;
31981
32086
  }
31982
32087
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
32088
+ if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
31983
32089
  const location = runtimeLayoutLocation();
31984
32090
  const files = layoutFiles(location, accountFile);
31985
32091
  if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
@@ -31992,7 +32098,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
31992
32098
  if (!marker?.oldDir || marker.oldDir !== location.key) return;
31993
32099
  const leftover = vaultStateFile(files).old;
31994
32100
  if (!await isVaultShapedKeptState(files)) return;
31995
- await unlink9(leftover).catch((error) => {
32101
+ await unlink10(leftover).catch((error) => {
31996
32102
  if (error.code !== "ENOENT") throw error;
31997
32103
  });
31998
32104
  await rmdir2(files.vault.old).catch(() => {
@@ -32038,7 +32144,7 @@ async function physicalAliases(location, files) {
32038
32144
  async function samePhysical(a, b) {
32039
32145
  const id = async (path5) => {
32040
32146
  try {
32041
- const info = await stat9(path5, { bigint: true });
32147
+ const info = await stat10(path5, { bigint: true });
32042
32148
  return info.ino === 0n ? void 0 : `${info.dev}:${info.ino}`;
32043
32149
  } catch (error) {
32044
32150
  const code2 = error.code;
@@ -32128,7 +32234,7 @@ async function unlinkIfIdentical(file, stateDir, guard) {
32128
32234
  if (!same) throw credentialConflict(stateDir, file);
32129
32235
  await guard();
32130
32236
  try {
32131
- await unlink9(file.old);
32237
+ await unlink10(file.old);
32132
32238
  return true;
32133
32239
  } catch (error) {
32134
32240
  if (error.code === "ENOENT") return true;
@@ -32241,7 +32347,7 @@ async function writeManifest(stateDir, paths) {
32241
32347
  );
32242
32348
  }
32243
32349
  async function removeManifest(stateDir) {
32244
- await unlink9(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32350
+ await unlink10(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32245
32351
  (error) => {
32246
32352
  if (error.code !== "ENOENT") throw error;
32247
32353
  }
@@ -32265,7 +32371,7 @@ async function ensureOwnerOnlyDir(path5) {
32265
32371
  await mkdir13(path5, { recursive: true, mode: 448 });
32266
32372
  await chmod5(path5, 448);
32267
32373
  }
32268
- async function takeLock(name, path5, waitMs, log16) {
32374
+ async function takeLock(name, path5, waitMs, log17) {
32269
32375
  const fs5 = await loadCommonAuthFs();
32270
32376
  const started = performance.now();
32271
32377
  let announced = false;
@@ -32290,7 +32396,7 @@ async function takeLock(name, path5, waitMs, log16) {
32290
32396
  );
32291
32397
  if (!announced && waited >= LOCK_WAIT_NOTICE_MS) {
32292
32398
  announced = true;
32293
- log16.info(
32399
+ log17.info(
32294
32400
  `antigravity-auth is waiting up to ${Math.round(waitMs / 1e3)} s for the ${name} lock at ${path5}.${lockHolderText(name)}`,
32295
32401
  { lock: name, path: path5 }
32296
32402
  );
@@ -32303,7 +32409,7 @@ function lockHolderText(name) {
32303
32409
  }
32304
32410
  async function exists2(path5) {
32305
32411
  try {
32306
- await stat9(path5);
32412
+ await stat10(path5);
32307
32413
  return true;
32308
32414
  } catch (error) {
32309
32415
  const code2 = error.code;
@@ -32438,7 +32544,7 @@ async function ensureGitignore(configDir) {
32438
32544
  `,
32439
32545
  "utf-8"
32440
32546
  );
32441
- log5.info("Created .gitignore in config directory");
32547
+ log6.info("Created .gitignore in config directory");
32442
32548
  } else {
32443
32549
  const suffix = content.endsWith("\n") ? "" : "\n";
32444
32550
  await fs.appendFile(
@@ -32447,12 +32553,12 @@ async function ensureGitignore(configDir) {
32447
32553
  `,
32448
32554
  "utf-8"
32449
32555
  );
32450
- log5.info("Updated .gitignore with missing entries", {
32556
+ log6.info("Updated .gitignore with missing entries", {
32451
32557
  added: missingEntries
32452
32558
  });
32453
32559
  }
32454
32560
  } catch (error) {
32455
- log5.warn("Failed to update .gitignore with account storage entries", {
32561
+ log6.warn("Failed to update .gitignore with account storage entries", {
32456
32562
  error: String(error)
32457
32563
  });
32458
32564
  }
@@ -32487,21 +32593,21 @@ function migrateLegacyWindowsConfig() {
32487
32593
  mkdirSync(newConfigDir, { recursive: true });
32488
32594
  try {
32489
32595
  renameSync3(legacyPath, newPath);
32490
- log5.info("Migrated Windows config via rename", {
32596
+ log6.info("Migrated Windows config via rename", {
32491
32597
  from: legacyPath,
32492
32598
  to: newPath
32493
32599
  });
32494
32600
  } catch {
32495
32601
  copyFileSync(legacyPath, newPath);
32496
32602
  unlinkSync(legacyPath);
32497
- log5.info("Migrated Windows config via copy+delete", {
32603
+ log6.info("Migrated Windows config via copy+delete", {
32498
32604
  from: legacyPath,
32499
32605
  to: newPath
32500
32606
  });
32501
32607
  }
32502
32608
  return true;
32503
32609
  } catch (error) {
32504
- log5.warn("Failed to migrate legacy Windows config, will use legacy path", {
32610
+ log6.warn("Failed to migrate legacy Windows config, will use legacy path", {
32505
32611
  legacyPath,
32506
32612
  newPath,
32507
32613
  error: String(error)
@@ -32534,7 +32640,7 @@ function getStoragePathWithMigration() {
32534
32640
  );
32535
32641
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
32536
32642
  if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
32537
- log5.info("Using legacy Windows config path (migration failed)", {
32643
+ log6.info("Using legacy Windows config path (migration failed)", {
32538
32644
  legacyPath,
32539
32645
  newPath
32540
32646
  });
@@ -32702,18 +32808,18 @@ async function clearAccounts() {
32702
32808
  } catch (error) {
32703
32809
  const code2 = error.code;
32704
32810
  if (code2 !== "ENOENT") {
32705
- log5.error("Failed to clear account storage", { error: String(error) });
32811
+ log6.error("Failed to clear account storage", { error: String(error) });
32706
32812
  }
32707
32813
  }
32708
32814
  }
32709
- var log5, mutateAccountStorage2, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
32815
+ var log6, mutateAccountStorage2, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
32710
32816
  var init_storage = __esm({
32711
32817
  "src/plugin/storage.ts"() {
32712
32818
  "use strict";
32713
32819
  init_dist();
32714
32820
  init_runtime_paths();
32715
32821
  init_logger4();
32716
- log5 = createLogger4("storage");
32822
+ log6 = createLogger4("storage");
32717
32823
  mutateAccountStorage2 = async (path5, mutate) => {
32718
32824
  await assertLegacyPoolInUse(path5);
32719
32825
  return mutateAccountStorage(path5, mutate);
@@ -33657,15 +33763,15 @@ function initLogger3(client) {
33657
33763
  }
33658
33764
  function createLogger4(module) {
33659
33765
  let channel3;
33660
- const log16 = (level, message, extra) => {
33766
+ const log17 = (level, message, extra) => {
33661
33767
  channel3 ??= getLegacyLogger().createLogger(module);
33662
33768
  channel3[level](message, extra);
33663
33769
  };
33664
33770
  return {
33665
- debug: (message, extra) => log16("debug", message, extra),
33666
- info: (message, extra) => log16("info", message, extra),
33667
- warn: (message, extra) => log16("warn", message, extra),
33668
- error: (message, extra) => log16("error", message, extra)
33771
+ debug: (message, extra) => log17("debug", message, extra),
33772
+ info: (message, extra) => log17("info", message, extra),
33773
+ warn: (message, extra) => log17("warn", message, extra),
33774
+ error: (message, extra) => log17("error", message, extra)
33669
33775
  };
33670
33776
  }
33671
33777
  var ENV_CONSOLE_LOG2, LOG_LEVEL_FROM_OPERATOR, legacyClient, legacyLogger;
@@ -33689,6 +33795,102 @@ var init_logger4 = __esm({
33689
33795
  }
33690
33796
  });
33691
33797
 
33798
+ // src/vault-folder.ts
33799
+ var vault_folder_exports = {};
33800
+ __export(vault_folder_exports, {
33801
+ __resetVaultFoldersForTest: () => __resetVaultFoldersForTest,
33802
+ currentVaultFolder: () => currentVaultFolder,
33803
+ prepareVaultFolder: () => prepareVaultFolder
33804
+ });
33805
+ import { isAbsolute as isAbsolute3 } from "node:path";
33806
+ function vaultOverride(accountFile) {
33807
+ const kept = refusals.get(overrideRefusalKey);
33808
+ if (kept) return { accountFile, vaultDir: kept.stateDir, refusal: kept };
33809
+ const vaultDir = process.env[OVERRIDE];
33810
+ if (!vaultDir) return void 0;
33811
+ if (isAbsolute3(vaultDir)) return { accountFile, vaultDir };
33812
+ const refusal3 = new RuntimeLayoutRefusal(
33813
+ vaultDir,
33814
+ "relative-vault-dir",
33815
+ `antigravity-auth cannot start: ${OVERRIDE} must be an absolute path. Correct it and restart OpenCode.`
33816
+ );
33817
+ refusals.set(overrideRefusalKey, refusal3);
33818
+ return { accountFile, vaultDir, refusal: refusal3 };
33819
+ }
33820
+ function locationKey() {
33821
+ const location = runtimeLayoutLocation();
33822
+ return `${location.stateHomeDir}\0${location.key}`;
33823
+ }
33824
+ function __resetVaultFoldersForTest() {
33825
+ refusals.clear();
33826
+ }
33827
+ async function prepareVaultFolder(options) {
33828
+ const { accountFile } = options;
33829
+ const override = vaultOverride(accountFile);
33830
+ if (override?.refusal) return override;
33831
+ const key = locationKey();
33832
+ const kept = refusals.get(key);
33833
+ if (kept)
33834
+ return override ? { ...override, refusal: kept } : refused(accountFile, kept);
33835
+ const log17 = options.log ?? createLogger4("runtime-layout");
33836
+ const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
33837
+ try {
33838
+ if (override) {
33839
+ await ensurePrivateDirectory2(override.vaultDir);
33840
+ } else
33841
+ await prepareRuntimeLayout({
33842
+ version,
33843
+ accountFile,
33844
+ log: log17,
33845
+ ...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
33846
+ });
33847
+ if (options.accountStore !== false)
33848
+ await prepareAccountStore({ version, log: log17 });
33849
+ } catch (error) {
33850
+ const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
33851
+ override?.vaultDir ?? runtimeLayoutLocation().stateHomeDir,
33852
+ error instanceof Error ? error.name : typeof error
33853
+ );
33854
+ if (!refusals.has(key)) {
33855
+ refusals.set(key, refusal3);
33856
+ log17.warn(refusal3.message, {
33857
+ stateDir: refusal3.stateDir,
33858
+ errorClass: refusal3.errorClass
33859
+ });
33860
+ }
33861
+ return override ? { ...override, refusal: refusals.get(key) ?? refusal3 } : refused(accountFile, refusals.get(key) ?? refusal3);
33862
+ }
33863
+ return override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
33864
+ }
33865
+ function currentVaultFolder(accountFile) {
33866
+ const override = vaultOverride(accountFile);
33867
+ if (override?.refusal) return override;
33868
+ const kept = refusals.get(locationKey());
33869
+ return kept ? override ? { ...override, refusal: kept } : refused(accountFile, kept) : override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
33870
+ }
33871
+ function refused(accountFile, refusal3) {
33872
+ return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
33873
+ }
33874
+ var refusalsKey, globalState3, refusals, OVERRIDE, overrideRefusalKey;
33875
+ var init_vault_folder = __esm({
33876
+ "src/vault-folder.ts"() {
33877
+ "use strict";
33878
+ init_private_files2();
33879
+ init_logger4();
33880
+ init_process_heartbeat();
33881
+ init_runtime_layout();
33882
+ init_runtime_paths();
33883
+ refusalsKey = /* @__PURE__ */ Symbol.for(
33884
+ "@cortexkit/antigravity-auth/vault-folder-refusals"
33885
+ );
33886
+ globalState3 = globalThis;
33887
+ refusals = globalState3[refusalsKey] ?? /* @__PURE__ */ new Map();
33888
+ globalState3[refusalsKey] = refusals;
33889
+ OVERRIDE = "OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR";
33890
+ overrideRefusalKey = "invalid-vault-dir-override";
33891
+ }
33892
+ });
33893
+
33692
33894
  // src/ga/server/index.ts
33693
33895
  init_dist();
33694
33896
  import { randomUUID as randomUUID17 } from "node:crypto";
@@ -33808,63 +34010,9 @@ var MAX_RETRY_HOLD_MS = 20 * 60 * 1e3;
33808
34010
 
33809
34011
  // src/plugin/ga-location-services.ts
33810
34012
  init_dist();
34013
+ init_vault_folder();
33811
34014
  import { randomBytes as randomBytes5 } from "node:crypto";
33812
34015
 
33813
- // src/vault-folder.ts
33814
- init_logger4();
33815
- init_process_heartbeat();
33816
- init_runtime_layout();
33817
- init_runtime_paths();
33818
- var refusalsKey = /* @__PURE__ */ Symbol.for(
33819
- "@cortexkit/antigravity-auth/vault-folder-refusals"
33820
- );
33821
- var globalState3 = globalThis;
33822
- var refusals = globalState3[refusalsKey] ?? /* @__PURE__ */ new Map();
33823
- globalState3[refusalsKey] = refusals;
33824
- function locationKey() {
33825
- const location = runtimeLayoutLocation();
33826
- return `${location.stateHomeDir}\0${location.key}`;
33827
- }
33828
- async function prepareVaultFolder(options) {
33829
- const { accountFile } = options;
33830
- const key = locationKey();
33831
- const kept = refusals.get(key);
33832
- if (kept) return refused(accountFile, kept);
33833
- const log16 = options.log ?? createLogger4("runtime-layout");
33834
- const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
33835
- try {
33836
- await prepareRuntimeLayout({
33837
- version,
33838
- accountFile,
33839
- log: log16,
33840
- ...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
33841
- });
33842
- if (options.accountStore !== false)
33843
- await prepareAccountStore({ version, log: log16 });
33844
- } catch (error) {
33845
- const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
33846
- runtimeLayoutLocation().stateHomeDir,
33847
- error instanceof Error ? error.name : typeof error
33848
- );
33849
- if (!refusals.has(key)) {
33850
- refusals.set(key, refusal3);
33851
- log16.warn(refusal3.message, {
33852
- stateDir: refusal3.stateDir,
33853
- errorClass: refusal3.errorClass
33854
- });
33855
- }
33856
- return refused(accountFile, refusals.get(key) ?? refusal3);
33857
- }
33858
- return { accountFile, vaultDir: getVaultDir(accountFile) };
33859
- }
33860
- function currentVaultFolder(accountFile) {
33861
- const kept = refusals.get(locationKey());
33862
- return kept ? refused(accountFile, kept) : { accountFile, vaultDir: getVaultDir(accountFile) };
33863
- }
33864
- function refused(accountFile, refusal3) {
33865
- return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
33866
- }
33867
-
33868
34016
  // src/plugin/account-access.ts
33869
34017
  init_dist();
33870
34018
 
@@ -34035,7 +34183,7 @@ init_logger4();
34035
34183
  init_dist();
34036
34184
 
34037
34185
  // src/plugin/token.ts
34038
- var log6 = createLogger4("token");
34186
+ var log7 = createLogger4("token");
34039
34187
  function parseOAuthErrorPayload(text2) {
34040
34188
  if (!text2) {
34041
34189
  return {};
@@ -34118,13 +34266,13 @@ async function exchangeRefreshToken(refreshToken, now) {
34118
34266
  const details = [code2, description ?? errorText3].filter(Boolean).join(": ");
34119
34267
  const baseMessage = `Antigravity token refresh failed (${response.status} ${response.statusText})`;
34120
34268
  const message = details ? `${baseMessage} - ${details}` : baseMessage;
34121
- log6.warn("Token refresh failed", {
34269
+ log7.warn("Token refresh failed", {
34122
34270
  status: response.status,
34123
34271
  code: code2,
34124
34272
  details
34125
34273
  });
34126
34274
  if (code2 === "invalid_grant") {
34127
- log6.warn(
34275
+ log7.warn(
34128
34276
  "Google revoked the stored refresh token - reauthentication required"
34129
34277
  );
34130
34278
  invalidateProjectContextCache(refreshToken);
@@ -34180,7 +34328,7 @@ async function refreshAccessToken(auth, _client, _providerId) {
34180
34328
  if (error instanceof AntigravityTokenRefreshError) {
34181
34329
  throw error;
34182
34330
  }
34183
- log6.error("Unexpected token refresh error", { error: String(error) });
34331
+ log7.error("Unexpected token refresh error", { error: String(error) });
34184
34332
  return void 0;
34185
34333
  }
34186
34334
  }
@@ -35452,7 +35600,7 @@ function getUserConfigPath() {
35452
35600
  function getProjectConfigPath(directory) {
35453
35601
  return join18(directory, ".opencode", "antigravity.json");
35454
35602
  }
35455
- function loadConfigFile(path5, log16) {
35603
+ function loadConfigFile(path5, log17) {
35456
35604
  try {
35457
35605
  if (!existsSync5(path5)) {
35458
35606
  return null;
@@ -35461,7 +35609,7 @@ function loadConfigFile(path5, log16) {
35461
35609
  const rawConfig = JSON.parse(content);
35462
35610
  const result = AntigravityConfigSchema.partial().safeParse(rawConfig);
35463
35611
  if (!result.success) {
35464
- log16.warn("Config validation error", {
35612
+ log17.warn("Config validation error", {
35465
35613
  path: path5,
35466
35614
  issues: result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join(", ")
35467
35615
  });
@@ -35470,9 +35618,9 @@ function loadConfigFile(path5, log16) {
35470
35618
  return result.data;
35471
35619
  } catch (error) {
35472
35620
  if (error instanceof SyntaxError) {
35473
- log16.warn("Invalid JSON in config file", { path: path5, error: error.message });
35621
+ log17.warn("Invalid JSON in config file", { path: path5, error: error.message });
35474
35622
  } else {
35475
- log16.warn("Failed to load config file", { path: path5, error: String(error) });
35623
+ log17.warn("Failed to load config file", { path: path5, error: String(error) });
35476
35624
  }
35477
35625
  return null;
35478
35626
  }
@@ -35491,15 +35639,15 @@ function mergeConfigs(base, override) {
35491
35639
  function loadConfig(directory) {
35492
35640
  return loadConfigWithLogger(directory, legacyLog);
35493
35641
  }
35494
- function loadConfigWithLogger(directory, log16) {
35642
+ function loadConfigWithLogger(directory, log17) {
35495
35643
  let config = structuredClone(DEFAULT_CONFIG);
35496
35644
  const userConfigPath = getUserConfigPath();
35497
- const userConfig = loadConfigFile(userConfigPath, log16);
35645
+ const userConfig = loadConfigFile(userConfigPath, log17);
35498
35646
  if (userConfig) {
35499
35647
  config = mergeConfigs(config, userConfig);
35500
35648
  }
35501
35649
  const projectConfigPath = getProjectConfigPath(directory);
35502
- const projectConfig = loadConfigFile(projectConfigPath, log16);
35650
+ const projectConfig = loadConfigFile(projectConfigPath, log17);
35503
35651
  if (projectConfig) {
35504
35652
  config = mergeConfigs(config, projectConfig);
35505
35653
  }
@@ -36448,7 +36596,7 @@ init_dist();
36448
36596
  init_debug();
36449
36597
  init_logger4();
36450
36598
  init_dist();
36451
- var log7 = createLogger4("quota");
36599
+ var log8 = createLogger4("quota");
36452
36600
  function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID, options = {}) {
36453
36601
  const fetchPoolFileQuota = makeFetchAccountQuota(
36454
36602
  client,
@@ -36639,7 +36787,7 @@ async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, getActive
36639
36787
  );
36640
36788
  } catch (error) {
36641
36789
  ;
36642
- (options.logger ?? log7).debug("sidebar-quota-write-failed", {
36790
+ (options.logger ?? log8).debug("sidebar-quota-write-failed", {
36643
36791
  error: String(error)
36644
36792
  });
36645
36793
  }
@@ -37005,7 +37153,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37005
37153
  let rotatedRefresh;
37006
37154
  if (purpose === "advisory") {
37007
37155
  if (accessTokenExpired(auth)) {
37008
- log7.debug("advisory-quota-skipped-refresh-needed");
37156
+ log8.debug("advisory-quota-skipped-refresh-needed");
37009
37157
  return {
37010
37158
  index,
37011
37159
  email: account.email,
@@ -37017,7 +37165,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37017
37165
  const managedProjectId = parts.managedProjectId ?? account.managedProjectId;
37018
37166
  const projectId = managedProjectId ?? parts.projectId ?? account.projectId;
37019
37167
  if (!projectId) {
37020
- log7.debug("advisory-quota-skipped-project-needed");
37168
+ log8.debug("advisory-quota-skipped-project-needed");
37021
37169
  return {
37022
37170
  index,
37023
37171
  email: account.email,
@@ -37039,7 +37187,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37039
37187
  { timeoutMs: extra.timeoutMs }
37040
37188
  );
37041
37189
  },
37042
- logger: log7
37190
+ logger: log8
37043
37191
  }),
37044
37192
  signal
37045
37193
  );
@@ -37096,7 +37244,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37096
37244
  managedProjectId,
37097
37245
  projectId: projectContext.effectiveProjectId,
37098
37246
  fetchVia,
37099
- logger: log7
37247
+ logger: log8
37100
37248
  });
37101
37249
  quotaResult = payloads.quota;
37102
37250
  if (quotaResult.error) throw new Error(quotaResult.error);
@@ -39835,8 +39983,8 @@ function createSessionRecoveryHook(ctx, config) {
39835
39983
  if (!sessionID) return false;
39836
39984
  let assistantMsgID = info.id;
39837
39985
  let msgs;
39838
- const log16 = createLogger4("session-recovery");
39839
- log16.debug("Recovery attempt started", {
39986
+ const log17 = createLogger4("session-recovery");
39987
+ log17.debug("Recovery attempt started", {
39840
39988
  errorType,
39841
39989
  sessionID,
39842
39990
  providedMsgID: assistantMsgID ?? "none"
@@ -39856,7 +40004,7 @@ function createSessionRecoveryHook(ctx, config) {
39856
40004
  const m = msgs[i];
39857
40005
  if (m && m.info?.role === "assistant" && m.info?.id) {
39858
40006
  assistantMsgID = m.info.id;
39859
- log16.debug("Found assistant message ID from session messages", {
40007
+ log17.debug("Found assistant message ID from session messages", {
39860
40008
  msgID: assistantMsgID,
39861
40009
  msgIndex: i
39862
40010
  });
@@ -39865,7 +40013,7 @@ function createSessionRecoveryHook(ctx, config) {
39865
40013
  }
39866
40014
  }
39867
40015
  if (!assistantMsgID) {
39868
- log16.debug("No assistant message ID found, cannot recover");
40016
+ log17.debug("No assistant message ID found, cannot recover");
39869
40017
  return false;
39870
40018
  }
39871
40019
  if (processingErrors.has(assistantMsgID)) return false;
@@ -39909,7 +40057,7 @@ function createSessionRecoveryHook(ctx, config) {
39909
40057
  }
39910
40058
  return success;
39911
40059
  } catch (err) {
39912
- log16.error("Recovery failed", { error: String(err) });
40060
+ log17.error("Recovery failed", { error: String(err) });
39913
40061
  return false;
39914
40062
  } finally {
39915
40063
  processingErrors.delete(assistantMsgID);
@@ -39929,7 +40077,7 @@ function createSessionRecoveryHook(ctx, config) {
39929
40077
  // src/plugin/request-helpers.ts
39930
40078
  init_dist();
39931
40079
  init_logger4();
39932
- var log8 = createLogger4("request-helpers");
40080
+ var log9 = createLogger4("request-helpers");
39933
40081
  var ANTIGRAVITY_PREVIEW_LINK = "https://goo.gle/enable-preview-features";
39934
40082
  function appendDescriptionHint(schema, hint) {
39935
40083
  if (!schema || typeof schema !== "object") {
@@ -40354,7 +40502,7 @@ function filterContentArray(contentArray, sessionId, getCachedSignatureFn, isCla
40354
40502
  }
40355
40503
  const existingSignature = item.signature || item.thoughtSignature;
40356
40504
  const signatureInfo = existingSignature ? `foreign signature (${String(existingSignature).length} chars)` : "no signature";
40357
- log8.debug(
40505
+ log9.debug(
40358
40506
  `Injecting plain text sentinel for last-message thinking block with ${signatureInfo}`
40359
40507
  );
40360
40508
  const sentinel2 = { text: "." };
@@ -40866,7 +41014,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
40866
41014
  if (lastBracket > 0) {
40867
41015
  const cleaned = stripped.slice(0, lastBracket + 1);
40868
41016
  const parsed = JSON.parse(cleaned);
40869
- log8.debug("Auto-corrected malformed JSON array", {
41017
+ log9.debug("Auto-corrected malformed JSON array", {
40870
41018
  truncatedChars: stripped.length - cleaned.length
40871
41019
  });
40872
41020
  return recursivelyParseJsonStrings(parsed);
@@ -40880,7 +41028,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
40880
41028
  if (lastBrace > 0) {
40881
41029
  const cleaned = stripped.slice(0, lastBrace + 1);
40882
41030
  const parsed = JSON.parse(cleaned);
40883
- log8.debug("Auto-corrected malformed JSON object", {
41031
+ log9.debug("Auto-corrected malformed JSON object", {
40884
41032
  truncatedChars: stripped.length - cleaned.length
40885
41033
  });
40886
41034
  return recursivelyParseJsonStrings(parsed);
@@ -40980,7 +41128,7 @@ function fixToolResponseGrouping(contents) {
40980
41128
  if (orphanResp.functionResponse.name === "unknown_function" && expectedName) {
40981
41129
  orphanResp.functionResponse.name = expectedName;
40982
41130
  }
40983
- log8.debug("Auto-repaired tool ID mismatch", {
41131
+ log9.debug("Auto-repaired tool ID mismatch", {
40984
41132
  mappedFrom: matchedId,
40985
41133
  mappedTo: expectedId,
40986
41134
  functionName: expectedName
@@ -41000,7 +41148,7 @@ function fixToolResponseGrouping(contents) {
41000
41148
  id: expectedId
41001
41149
  }
41002
41150
  };
41003
- log8.debug("Created placeholder response for missing tool", {
41151
+ log9.debug("Created placeholder response for missing tool", {
41004
41152
  id: expectedId,
41005
41153
  name: expectedName
41006
41154
  });
@@ -41318,7 +41466,7 @@ function applyToolPairingFixes(payload, isClaude) {
41318
41466
  );
41319
41467
  payload.contents = fixToolResponseGrouping(contentsWithMatchedIds);
41320
41468
  contentsFixed = true;
41321
- log8.debug("Applied tool pairing fixes to contents[]", {
41469
+ log9.debug("Applied tool pairing fixes to contents[]", {
41322
41470
  originalLength: payload.contents.length
41323
41471
  });
41324
41472
  }
@@ -41327,7 +41475,7 @@ function applyToolPairingFixes(payload, isClaude) {
41327
41475
  payload.messages
41328
41476
  );
41329
41477
  messagesFixed = true;
41330
- log8.debug("Applied tool pairing fixes to messages[]", {
41478
+ log9.debug("Applied tool pairing fixes to messages[]", {
41331
41479
  originalLength: payload.messages.length
41332
41480
  });
41333
41481
  }
@@ -41566,7 +41714,7 @@ init_dist();
41566
41714
  init_dist();
41567
41715
 
41568
41716
  // src/plugin/request.ts
41569
- var log9 = createLogger4("request");
41717
+ var log10 = createLogger4("request");
41570
41718
  var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
41571
41719
  var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext("");
41572
41720
  var sessionDisplayedThinkingHashes = /* @__PURE__ */ new Set();
@@ -42365,7 +42513,7 @@ var openCode1WireLocation = {
42365
42513
  logAntigravityDebugResponse: (context, response, meta) => logAntigravityDebugResponse(context, response, meta),
42366
42514
  logCacheStats: (model, cacheRead, cacheWrite, totalInput) => logCacheStats(model, cacheRead, cacheWrite, totalInput)
42367
42515
  },
42368
- logger: log9,
42516
+ logger: log10,
42369
42517
  sessionFingerprint: () => getSessionFingerprint(),
42370
42518
  displayedThinkingHashes: sessionDisplayedThinkingHashes,
42371
42519
  cacheStats: { last: null }
@@ -43686,7 +43834,7 @@ var AgySessionRegistry = class {
43686
43834
  };
43687
43835
 
43688
43836
  // src/plugin/shared/advisory-repository.ts
43689
- function createAdvisoryRepositoryOwner(repository, log16) {
43837
+ function createAdvisoryRepositoryOwner(repository, log17) {
43690
43838
  const methods = /* @__PURE__ */ new Map();
43691
43839
  const advisoryMethods = /* @__PURE__ */ new Set([
43692
43840
  "updateMetadata",
@@ -43732,7 +43880,7 @@ function createAdvisoryRepositoryOwner(repository, log16) {
43732
43880
  (reason) => !failures.has(reason)
43733
43881
  );
43734
43882
  for (const reason of absorbed) failures.delete(reason);
43735
- log16.debug("post-response-local-write-refused", {
43883
+ log17.debug("post-response-local-write-refused", {
43736
43884
  count: absorbed.length
43737
43885
  });
43738
43886
  if (remaining.length > 0)
@@ -44507,7 +44655,6 @@ function publishResponse(dispatch) {
44507
44655
  }
44508
44656
 
44509
44657
  // src/plugin/shared/vault-routing.ts
44510
- var ROUTING_GROUP_SCOPED_EXHAUSTION = false;
44511
44658
  function hasVaultRoutingAccessor() {
44512
44659
  try {
44513
44660
  return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
@@ -44525,7 +44672,7 @@ function routingExhaustionFields(scope) {
44525
44672
  window: scope.limitWindow === "five_hour" ? "5h" : "7d"
44526
44673
  };
44527
44674
  }
44528
- function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCOPED_EXHAUSTION, report = reportRouting) {
44675
+ function reportVaultExhaustion(input2, report = reportRouting) {
44529
44676
  if (!hasVaultRoutingAccessor() || input2.signal?.aborted || input2.status !== 429 || input2.reason !== "QUOTA_EXHAUSTED" || !Number.isFinite(input2.observedAt) || (input2.observedAt ?? 0) <= 0 || (input2.observedAt ?? Infinity) > Date.now())
44530
44677
  return;
44531
44678
  for (const window of input2.quota?.windows ?? []) {
@@ -44533,13 +44680,12 @@ function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCO
44533
44680
  const scope = routingQuotaScope(input2.group, window.window);
44534
44681
  const resetsAt = Date.parse(window.resetTime);
44535
44682
  if (!scope || !Number.isFinite(resetsAt) || resetsAt <= Date.now()) continue;
44536
- if (groupScopedExhaustion)
44537
- report({
44538
- ...input2.identity,
44539
- outcome: "exhausted",
44540
- ...routingExhaustionFields(scope),
44541
- resetsAt
44542
- });
44683
+ report({
44684
+ ...input2.identity,
44685
+ outcome: "exhausted",
44686
+ ...routingExhaustionFields(scope),
44687
+ resetsAt
44688
+ });
44543
44689
  }
44544
44690
  }
44545
44691
  var RATE_LIMIT_HEADERS = [
@@ -44812,7 +44958,7 @@ function sleep4(ms, signal) {
44812
44958
  signal?.addEventListener("abort", onAbort, { once: true });
44813
44959
  });
44814
44960
  }
44815
- function createLocalQuotaRefresh(accountManager, quotaManager, log16) {
44961
+ function createLocalQuotaRefresh(accountManager, quotaManager, log17) {
44816
44962
  return async function refreshQuotaAfterSuccess(account, intervalMinutes, signal) {
44817
44963
  if (intervalMinutes <= 0) return;
44818
44964
  const accountIndex = accountManager.getAccounts().indexOf(account);
@@ -44843,7 +44989,7 @@ function createLocalQuotaRefresh(accountManager, quotaManager, log16) {
44843
44989
  accountManager.requestSaveToDisk();
44844
44990
  }
44845
44991
  } catch (err) {
44846
- log16.debug(
44992
+ log17.debug(
44847
44993
  `quota-refresh-failed ${singleAccount ? quotaManager.hashedLogLabel("account", singleAccount) : `idx-${accountIndex}`}`,
44848
44994
  { error: String(err) }
44849
44995
  );
@@ -44861,7 +45007,7 @@ function createRequestExecutor(deps) {
44861
45007
  wire,
44862
45008
  debug,
44863
45009
  dump,
44864
- logger: log16,
45010
+ logger: log17,
44865
45011
  trackers,
44866
45012
  classifyAccessError,
44867
45013
  notify,
@@ -44880,7 +45026,7 @@ function createRequestExecutor(deps) {
44880
45026
  const reportVault401 = (admission, status) => {
44881
45027
  if (!admission || status !== 401) return;
44882
45028
  void Promise.resolve().then(() => admission.report401(status)).catch((error) => {
44883
- log16.debug("send-admission-401-report-failed", { error: String(error) });
45029
+ log17.debug("send-admission-401-report-failed", { error: String(error) });
44884
45030
  });
44885
45031
  };
44886
45032
  const reportRouting2 = (sessionId, entry) => {
@@ -44888,7 +45034,7 @@ function createRequestExecutor(deps) {
44888
45034
  try {
44889
45035
  onRouting(sessionId, entry);
44890
45036
  } catch (error) {
44891
- log16.debug("routing-report-failed", { sessionId, error: String(error) });
45037
+ log17.debug("routing-report-failed", { sessionId, error: String(error) });
44892
45038
  }
44893
45039
  };
44894
45040
  async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy) {
@@ -45019,7 +45165,7 @@ function createRequestExecutor(deps) {
45019
45165
  const quietMode = config.quiet_mode;
45020
45166
  const toastScope = config.toast_scope;
45021
45167
  const showToast = async (message, variant2) => {
45022
- log16.debug("toast", {
45168
+ log17.debug("toast", {
45023
45169
  message,
45024
45170
  variant: variant2,
45025
45171
  isChildSession: isChildRequest,
@@ -45028,7 +45174,7 @@ function createRequestExecutor(deps) {
45028
45174
  if (quietMode) return;
45029
45175
  if (abortSignal?.aborted) return;
45030
45176
  if (toastScope === "root_only" && isChildRequest) {
45031
- log16.debug("toast-suppressed-child-session", {
45177
+ log17.debug("toast-suppressed-child-session", {
45032
45178
  message,
45033
45179
  variant: variant2,
45034
45180
  parentID: requestSessionIdentity.parentSessionId
@@ -45101,7 +45247,7 @@ function createRequestExecutor(deps) {
45101
45247
  });
45102
45248
  } catch (error) {
45103
45249
  if (error instanceof AntigravityKillswitchError) {
45104
- log16.warn("killswitch-all-excluded", {
45250
+ log17.warn("killswitch-all-excluded", {
45105
45251
  family,
45106
45252
  model,
45107
45253
  threshold: error.thresholdPercent,
@@ -45126,7 +45272,7 @@ function createRequestExecutor(deps) {
45126
45272
  pushDebug(
45127
45273
  `model-unavailable: all ${candidates.length} eligible account(s) skipped`
45128
45274
  );
45129
- log16.warn("model-unavailable-all-accounts", {
45275
+ log17.warn("model-unavailable-all-accounts", {
45130
45276
  family,
45131
45277
  model,
45132
45278
  accounts: candidates.length
@@ -45208,18 +45354,32 @@ function createRequestExecutor(deps) {
45208
45354
  const blockedSince = allAccountsBlockedAt;
45209
45355
  const remainingWaitMs = () => maxWaitMs > 0 ? Math.max(0, maxWaitMs - (Date.now() - blockedSince)) : Number.POSITIVE_INFINITY;
45210
45356
  const quotaWins = remainingWaitMs() <= deadline.remainingMs();
45357
+ const eligibleCandidateIndexes = new Set(
45358
+ accountManager.getAccounts().filter(
45359
+ (entry) => entry.enabled !== false && !entry.accountIneligible && !entry.verificationRequired && !excludedIndexes?.has(entry.index)
45360
+ ).map((entry) => entry.index)
45361
+ );
45362
+ if (eligibleCandidateIndexes.size === 0) {
45363
+ waitPolicy.refusal = () => createNativeGoogleErrorResponse({
45364
+ status: 412,
45365
+ reason: "pool_unavailable"
45366
+ });
45367
+ return waitPolicy.refusal();
45368
+ }
45211
45369
  if (accountManager.areAllAccountsOverSoftQuota(
45212
45370
  family,
45213
45371
  config.soft_quota_threshold_percent,
45214
45372
  softQuotaCacheTtlMs,
45215
- model
45373
+ model,
45374
+ eligibleCandidateIndexes
45216
45375
  )) {
45217
45376
  const threshold = config.soft_quota_threshold_percent;
45218
45377
  const softQuotaWaitMs = accountManager.getMinWaitTimeForSoftQuota(
45219
45378
  family,
45220
45379
  threshold,
45221
45380
  softQuotaCacheTtlMs,
45222
- model
45381
+ model,
45382
+ eligibleCandidateIndexes
45223
45383
  );
45224
45384
  waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
45225
45385
  status: 412,
@@ -45251,7 +45411,12 @@ function createRequestExecutor(deps) {
45251
45411
  await sleep4(Math.min(softQuotaWaitMs, remainingWaitMs()), abortSignal);
45252
45412
  continue;
45253
45413
  }
45254
- const minWaitMs = accountManager.getMinWaitTimeForFamily(family, model);
45414
+ const minWaitMs = accountManager.getMinWaitTimeForFamily(
45415
+ family,
45416
+ model,
45417
+ eligibleCandidateIndexes,
45418
+ true
45419
+ );
45255
45420
  const waitMs = minWaitMs || 6e4;
45256
45421
  waitPolicy.refusal = quotaWins ? () => createNativeGoogleErrorResponse({
45257
45422
  status: 412,
@@ -45365,7 +45530,7 @@ function createRequestExecutor(deps) {
45365
45530
  await deadline.wait(() => credentials.saveToDisk());
45366
45531
  } catch (error) {
45367
45532
  checkAborted();
45368
- log16.error("Failed to persist project context", {
45533
+ log17.error("Failed to persist project context", {
45369
45534
  error: String(error)
45370
45535
  });
45371
45536
  }
@@ -45422,7 +45587,7 @@ function createRequestExecutor(deps) {
45422
45587
  await deadline.wait(() => credentials.saveToDisk());
45423
45588
  } catch (error) {
45424
45589
  checkAborted();
45425
- log16.error("Failed to persist refreshed auth", {
45590
+ log17.error("Failed to persist refreshed auth", {
45426
45591
  error: String(error)
45427
45592
  });
45428
45593
  }
@@ -45431,14 +45596,14 @@ function createRequestExecutor(deps) {
45431
45596
  if (credentials.isInvalidGrant(error)) {
45432
45597
  const removed = credentials.removeAccount(account);
45433
45598
  if (removed) {
45434
- log16.warn(
45599
+ log17.warn(
45435
45600
  "Removed revoked account from pool - reauthenticate via `opencode auth login`"
45436
45601
  );
45437
45602
  try {
45438
45603
  await deadline.wait(() => credentials.saveToDiskReplace());
45439
45604
  } catch (persistError) {
45440
45605
  checkAborted();
45441
- log16.error("Failed to persist revoked account removal", {
45606
+ log17.error("Failed to persist revoked account removal", {
45442
45607
  error: String(persistError)
45443
45608
  });
45444
45609
  }
@@ -45448,7 +45613,7 @@ function createRequestExecutor(deps) {
45448
45613
  await deadline.wait(() => credentials.clearStoredAuth());
45449
45614
  } catch (storeError) {
45450
45615
  checkAborted();
45451
- log16.error(
45616
+ log17.error(
45452
45617
  "Failed to clear stored Antigravity OAuth credentials",
45453
45618
  {
45454
45619
  error: String(storeError)
@@ -45842,7 +46007,7 @@ function createRequestExecutor(deps) {
45842
46007
  );
45843
46008
  } catch (error) {
45844
46009
  checkAborted();
45845
- log16.debug("send-admission-401-report-failed", {
46010
+ log17.debug("send-admission-401-report-failed", {
45846
46011
  error: String(error)
45847
46012
  });
45848
46013
  }
@@ -46079,7 +46244,7 @@ function createRequestExecutor(deps) {
46079
46244
  debug.logAntigravityDebugResponse(debugContext, response, {
46080
46245
  note
46081
46246
  });
46082
- log16.info("model-unavailable", {
46247
+ log17.info("model-unavailable", {
46083
46248
  accountIndex: account.index,
46084
46249
  family,
46085
46250
  model,
@@ -46534,11 +46699,11 @@ function createRequestExecutor(deps) {
46534
46699
  cancellation.signal,
46535
46700
  deps.preResponseClock
46536
46701
  );
46537
- log16.debug("pre-response-start", { limitMs: PRE_RESPONSE_DEADLINE_MS });
46702
+ log17.debug("pre-response-start", { limitMs: PRE_RESPONSE_DEADLINE_MS });
46538
46703
  const handoff = createAfterHandoff(
46539
46704
  advisoryWork,
46540
46705
  requestedSignal ? [requestedSignal, shutdown.signal] : [shutdown.signal],
46541
- () => log16.debug("post-response-advisory-work-failed")
46706
+ () => log17.debug("post-response-advisory-work-failed")
46542
46707
  );
46543
46708
  const waitPolicy = {};
46544
46709
  const selectedCredentials = /* @__PURE__ */ new Set();
@@ -46556,7 +46721,7 @@ function createRequestExecutor(deps) {
46556
46721
  ).catch((error) => {
46557
46722
  cancellation.signal.throwIfAborted();
46558
46723
  if (error instanceof PreResponseTimeoutError) {
46559
- log16.debug("pre-response-timeout", { reason: error.reason });
46724
+ log17.debug("pre-response-timeout", { reason: error.reason });
46560
46725
  return waitPolicy.refusal?.() ?? preResponseTimeoutResponse();
46561
46726
  }
46562
46727
  throw error;
@@ -47050,7 +47215,7 @@ init_logger4();
47050
47215
 
47051
47216
  // src/plugin/refresh-queue.ts
47052
47217
  init_logger4();
47053
- var log10 = createLogger4("refresh-queue");
47218
+ var log11 = createLogger4("refresh-queue");
47054
47219
  var DEFAULT_PROACTIVE_REFRESH_CONFIG = {
47055
47220
  enabled: true,
47056
47221
  bufferSeconds: 1800,
@@ -47090,7 +47255,7 @@ var ProactiveRefreshQueue = class {
47090
47255
  "ProactiveRefreshQueue needs a host client or explicit dependencies"
47091
47256
  );
47092
47257
  }
47093
- this.log = log10;
47258
+ this.log = log11;
47094
47259
  this.refresh = (auth) => refreshAccessToken(auth, client, providerId);
47095
47260
  }
47096
47261
  this.config = {
@@ -47399,7 +47564,7 @@ async function buildLocationRuntime(options, scope) {
47399
47564
  sink: options.logSink,
47400
47565
  sinkEnabled: () => config?.config.debug_tui === true
47401
47566
  });
47402
- const log16 = logger3.createLogger("runtime");
47567
+ const log17 = logger3.createLogger("runtime");
47403
47568
  config = createLocationConfig(options.directory, {
47404
47569
  logger: logger3.createLogger("config")
47405
47570
  });
@@ -47516,7 +47681,7 @@ async function buildLocationRuntime(options, scope) {
47516
47681
  queue2.start();
47517
47682
  });
47518
47683
  accountChange = next.catch((error) => {
47519
- log16.warn("account view replacement failed", {
47684
+ log17.warn("account view replacement failed", {
47520
47685
  error: error instanceof Error ? error.message : String(error)
47521
47686
  });
47522
47687
  });
@@ -48707,6 +48872,7 @@ function createGaLocationServicesFactory(bindings) {
48707
48872
  let started = false;
48708
48873
  let disposal;
48709
48874
  let repositoryPromise;
48875
+ let repositoryPromiseLogin = false;
48710
48876
  let servingRepository;
48711
48877
  let localPromise;
48712
48878
  let vaultPromise;
@@ -48758,15 +48924,22 @@ function createGaLocationServicesFactory(bindings) {
48758
48924
  };
48759
48925
  const getRepository = async (login) => {
48760
48926
  await assertLocal();
48761
- repositoryPromise ??= openLocationRepository(
48762
- directory,
48763
- bindings,
48764
- overrides,
48765
- login
48766
- ).catch((error) => {
48767
- repositoryPromise = void 0;
48768
- throw error;
48769
- });
48927
+ if (login && repositoryPromise && !repositoryPromiseLogin) {
48928
+ await repositoryPromise.catch(() => void 0);
48929
+ }
48930
+ if (!repositoryPromise) {
48931
+ repositoryPromiseLogin = Boolean(login);
48932
+ repositoryPromise = openLocationRepository(
48933
+ directory,
48934
+ bindings,
48935
+ overrides,
48936
+ login
48937
+ ).catch((error) => {
48938
+ repositoryPromise = void 0;
48939
+ repositoryPromiseLogin = false;
48940
+ throw error;
48941
+ });
48942
+ }
48770
48943
  const repository = (await repositoryPromise).repository;
48771
48944
  if (!servingRepository) {
48772
48945
  const methods = /* @__PURE__ */ new Map();
@@ -48843,6 +49016,30 @@ function createGaLocationServicesFactory(bindings) {
48843
49016
  runtime,
48844
49017
  localLogin: {
48845
49018
  assertAdmission: assertLocal,
49019
+ async assertExistingPool(admit2) {
49020
+ await assertLocal();
49021
+ await admit2();
49022
+ const repository = await getRepository();
49023
+ await admit2();
49024
+ const opened = await repositoryPromise;
49025
+ await admit2();
49026
+ if (!opened)
49027
+ throw new Error("The local repository was not constructed");
49028
+ await assertServingAdmission(opened, bindings.now);
49029
+ await admit2();
49030
+ const read = await repository.read();
49031
+ await admit2();
49032
+ if (read.status !== "ready" || !read.rows.some(
49033
+ (row) => row.enabled && row.usable && row.credential !== void 0 && !row.torn && !row.unbound && row.invalid === void 0 && row.metadata.status === "present" && accessBlockOf2(row).kind === "none"
49034
+ ))
49035
+ throw new Error(
49036
+ "The existing local Antigravity pool is unavailable"
49037
+ );
49038
+ await assertServingAdmission(opened, bindings.now);
49039
+ await admit2();
49040
+ await assertLocal();
49041
+ await admit2();
49042
+ },
48846
49043
  async persist(result, admit2) {
48847
49044
  await assertLocal();
48848
49045
  await admit2();
@@ -49253,6 +49450,7 @@ var createGaLocationServices = (input2) => {
49253
49450
  // src/ga/server/index.ts
49254
49451
  init_storage();
49255
49452
  init_process_heartbeat();
49453
+ init_vault_folder();
49256
49454
 
49257
49455
  // src/ga/proxy-guard.ts
49258
49456
  var DOCUMENTED_LOOPBACK_EXCLUSION = "NO_PROXY=127.0.0.1";
@@ -50622,14 +50820,17 @@ init_dist();
50622
50820
  // src/auth-method-labels.ts
50623
50821
  var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
50624
50822
  var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
50823
+ var OPENCODE2_POOL_RECONNECT_LABEL = "Use existing local Antigravity pool";
50625
50824
 
50626
50825
  // src/ga/server/auth.ts
50627
50826
  init_storage();
50628
50827
  init_vault_custody();
50828
+ init_vault_folder();
50629
50829
 
50630
50830
  // src/ga/server/pool-login.ts
50631
50831
  init_dist();
50632
50832
  var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
50833
+ var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
50633
50834
  var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
50634
50835
  function abortable(pending, signal) {
50635
50836
  return new Promise((resolve28, reject) => {
@@ -50753,6 +50954,26 @@ function createGaPoolLogin(input2) {
50753
50954
  };
50754
50955
  return {
50755
50956
  method,
50957
+ connectExisting: () => track(
50958
+ (async () => {
50959
+ try {
50960
+ await admit2();
50961
+ if (!input2.local?.assertExistingPool) throw new Error(LOGIN_FAILED);
50962
+ await abortable(
50963
+ track(input2.local.assertExistingPool(admit2)),
50964
+ shutdown.signal
50965
+ );
50966
+ await admit2();
50967
+ return placeholderCredential({
50968
+ integrationID: ANTIGRAVITY_PROVIDER_ID,
50969
+ methodID: GA_POOL_RECONNECT_METHOD_ID,
50970
+ now: Date.now()
50971
+ });
50972
+ } catch {
50973
+ throw new Error(LOGIN_FAILED);
50974
+ }
50975
+ })()
50976
+ ),
50756
50977
  onLogin: (result) => track(
50757
50978
  (async () => {
50758
50979
  try {
@@ -50786,33 +51007,83 @@ async function readAuthority() {
50786
51007
  }
50787
51008
  async function registerGaAuthMethods(context, authority = readAuthority, input2 = {}) {
50788
51009
  const pool = createGaPoolLogin(input2);
50789
- const registration = await registerOpenCode2AuthMethods(context, {
50790
- integrationID: ANTIGRAVITY_PROVIDER_ID,
50791
- methods: [pool.method],
50792
- onLogin: pool.onLogin,
50793
- vault: {
50794
- method: {
50795
- id: GA_VAULT_METHOD_ID,
50796
- type: "oauth",
50797
- label: OPENCODE2_VAULT_AUTH_LABEL
50798
- },
50799
- async activate() {
50800
- if (await authority() !== "vault") {
50801
- throw new Error(
50802
- "Approve Antigravity vault access before activating this connection"
50803
- );
50804
- }
50805
- }
50806
- },
50807
- label: "Antigravity"
50808
- });
51010
+ const registrations = [];
51011
+ try {
51012
+ registrations.push(
51013
+ await registerOpenCode2AuthMethods(context, {
51014
+ integrationID: ANTIGRAVITY_PROVIDER_ID,
51015
+ methods: [pool.method],
51016
+ onLogin: pool.onLogin,
51017
+ vault: {
51018
+ method: {
51019
+ id: GA_VAULT_METHOD_ID,
51020
+ type: "oauth",
51021
+ label: OPENCODE2_VAULT_AUTH_LABEL
51022
+ },
51023
+ async activate() {
51024
+ if (await authority() !== "vault") {
51025
+ throw new Error(
51026
+ "Approve Antigravity vault access before activating this connection"
51027
+ );
51028
+ }
51029
+ }
51030
+ },
51031
+ label: "Antigravity"
51032
+ })
51033
+ );
51034
+ if (input2.local?.assertExistingPool) {
51035
+ registrations.push(
51036
+ await context.integration.transform((editor) => {
51037
+ editor.method.update({
51038
+ integrationID: ANTIGRAVITY_PROVIDER_ID,
51039
+ method: {
51040
+ id: GA_POOL_RECONNECT_METHOD_ID,
51041
+ type: "oauth",
51042
+ label: OPENCODE2_POOL_RECONNECT_LABEL
51043
+ },
51044
+ authorize: async () => {
51045
+ const callback = pool.connectExisting();
51046
+ void callback.catch(() => {
51047
+ });
51048
+ return {
51049
+ mode: "auto",
51050
+ url: "",
51051
+ instructions: "No browser sign-in needed: connect the existing local Antigravity pool without changing its accounts.",
51052
+ callback
51053
+ };
51054
+ },
51055
+ refresh: async (credential) => {
51056
+ if (!isPlaceholderCredential(credential, ANTIGRAVITY_PROVIDER_ID) || credential.methodID !== GA_POOL_RECONNECT_METHOD_ID) {
51057
+ throw new Error(
51058
+ "This login method refreshes only its existing local pool placeholder."
51059
+ );
51060
+ }
51061
+ return pool.connectExisting();
51062
+ },
51063
+ label: () => "Antigravity"
51064
+ });
51065
+ })
51066
+ );
51067
+ }
51068
+ } catch (error) {
51069
+ const stopping = pool.dispose();
51070
+ await Promise.allSettled(
51071
+ registrations.map((registration) => registration.dispose())
51072
+ );
51073
+ await stopping;
51074
+ throw error;
51075
+ }
50809
51076
  let disposal;
50810
51077
  return {
50811
51078
  dispose() {
50812
51079
  disposal ??= (async () => {
50813
51080
  const stopping = pool.dispose();
50814
51081
  try {
50815
- await registration.dispose();
51082
+ const results = await Promise.allSettled(
51083
+ registrations.map((registration) => registration.dispose())
51084
+ );
51085
+ const failure2 = results.find((result) => result.status === "rejected");
51086
+ if (failure2?.status === "rejected") throw failure2.reason;
50816
51087
  } finally {
50817
51088
  await stopping;
50818
51089
  }
@@ -52156,8 +52427,8 @@ async function select2(terminal, items, options) {
52156
52427
  // src/common-auth-embedded/claustrum/enrollment.js
52157
52428
  import { createHash as createHash18, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
52158
52429
  import { constants as fsConstants2 } from "node:fs";
52159
- import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat11, unlink as unlink10 } from "node:fs/promises";
52160
- import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute3, join as join26, resolve as resolve22 } from "node:path";
52430
+ import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat12, unlink as unlink11 } from "node:fs/promises";
52431
+ import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as resolve22 } from "node:path";
52161
52432
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
52162
52433
 
52163
52434
  // src/common-auth-embedded/fs/file-read-cache.js
@@ -52230,7 +52501,7 @@ init_private_files2();
52230
52501
  // src/common-auth-embedded/fs/refresh-file-lock.js
52231
52502
  init_private_files2();
52232
52503
  import { randomUUID as randomUUID18 } from "node:crypto";
52233
- import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat10 } from "node:fs/promises";
52504
+ import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat11 } from "node:fs/promises";
52234
52505
  import { dirname as dirname21, join as join25 } from "node:path";
52235
52506
 
52236
52507
  // src/common-auth-embedded/fs/with-lock.js
@@ -52484,7 +52755,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52484
52755
  };
52485
52756
  }
52486
52757
  try {
52487
- const current = await stat10(lockPath);
52758
+ const current = await stat11(lockPath);
52488
52759
  const legacyExpiry = Number.isFinite(expiresAt) ? expiresAt : current.mtimeMs + options.ttlMs;
52489
52760
  if (legacyExpiry > now())
52490
52761
  return { status: "live" };
@@ -52551,7 +52822,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52551
52822
  if (!sameMarkerDirectory2(created, current))
52552
52823
  return false;
52553
52824
  try {
52554
- await stat10(evictOwnerPath);
52825
+ await stat11(evictOwnerPath);
52555
52826
  return true;
52556
52827
  } catch (error) {
52557
52828
  if (error.code !== "ENOENT")
@@ -52603,7 +52874,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52603
52874
  async function recoverStaleEvictionMarker() {
52604
52875
  let evictStat;
52605
52876
  try {
52606
- evictStat = await stat10(evictPath);
52877
+ evictStat = await stat11(evictPath);
52607
52878
  } catch (error) {
52608
52879
  if (error.code === "ENOENT")
52609
52880
  return "missing";
@@ -52621,7 +52892,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52621
52892
  if (evictStat.mtimeMs + EVICT_TTL > now()) {
52622
52893
  let hasOwner = true;
52623
52894
  try {
52624
- await stat10(evictOwnerPath);
52895
+ await stat11(evictOwnerPath);
52625
52896
  } catch (error) {
52626
52897
  if (error.code === "ENOENT")
52627
52898
  hasOwner = false;
@@ -53023,9 +53294,9 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
53023
53294
  }
53024
53295
  function hostEnrollmentPaths2(input2) {
53025
53296
  const override = input2.override?.trim();
53026
- if (override && !isAbsolute3(override) && !input2.cwd)
53297
+ if (override && !isAbsolute4(override) && !input2.cwd)
53027
53298
  throw new ClaustrumConsumerError2("invalid-state", "A relative Claustrum enrollment override needs a base directory");
53028
- const tokenPath = override ? isAbsolute3(override) ? override : resolve22(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
53299
+ const tokenPath = override ? isAbsolute4(override) ? override : resolve22(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
53029
53300
  return getClaustrumEnrollmentPaths2(tokenPath);
53030
53301
  }
53031
53302
  function isRecord11(value) {
@@ -53210,7 +53481,7 @@ async function refuseWritableAncestor2(parent, options = {}) {
53210
53481
  }
53211
53482
  let privateGroup;
53212
53483
  for (; ; ) {
53213
- const metadata = await stat11(component).catch(() => void 0);
53484
+ const metadata = await stat12(component).catch(() => void 0);
53214
53485
  if (metadata && (metadata.mode & 18) !== 0 && (metadata.mode & 512) === 0) {
53215
53486
  if (privateGroup === void 0) {
53216
53487
  privateGroup = gid !== void 0 && await isPrivateGroup2(uid, gid, options);
@@ -53239,7 +53510,7 @@ async function ensureClaustrumPrivateDirectory2(directory, options = {}, what =
53239
53510
  return;
53240
53511
  }
53241
53512
  await mkdir15(directory, { recursive: true, mode: 448 });
53242
- const metadata = await stat11(directory);
53513
+ const metadata = await stat12(directory);
53243
53514
  const uid = process.geteuid?.();
53244
53515
  if (uid !== void 0 && metadata.uid !== uid) {
53245
53516
  throw new ClaustrumConsumerError2("unsafe-file", `Claustrum ${what} must be owned by the current user`);
@@ -53275,7 +53546,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
53275
53546
  await descriptor?.close().catch(() => {
53276
53547
  });
53277
53548
  if (created)
53278
- await unlink10(temporary).catch(() => {
53549
+ await unlink11(temporary).catch(() => {
53279
53550
  });
53280
53551
  }
53281
53552
  }
@@ -53502,7 +53773,7 @@ var ClaustrumEnrollmentManager2 = class {
53502
53773
  }
53503
53774
  if (refusal3.code === UNSUPPORTED_ENROLLMENT_CODE2) {
53504
53775
  await lock.assertOwned();
53505
- await unlink10(this.#paths.statePath).catch((cause) => {
53776
+ await unlink11(this.#paths.statePath).catch((cause) => {
53506
53777
  if (cause.code !== "ENOENT")
53507
53778
  throw cause;
53508
53779
  });
@@ -53592,7 +53863,7 @@ async function resetClaustrumEnrollmentState2(paths, proposedName) {
53592
53863
  if (state.phase === "pending")
53593
53864
  return "refused-pending";
53594
53865
  await lock.assertOwned();
53595
- await unlink10(paths.statePath);
53866
+ await unlink11(paths.statePath);
53596
53867
  return "reset";
53597
53868
  } finally {
53598
53869
  await lock.release();
@@ -53828,7 +54099,7 @@ function setupPaths(io = {}) {
53828
54099
  }
53829
54100
 
53830
54101
  // src/common-auth-embedded/setup/detect.js
53831
- function stat12(path5, kind) {
54102
+ function stat13(path5, kind) {
53832
54103
  try {
53833
54104
  return statSync5(path5)[kind]();
53834
54105
  } catch {
@@ -53837,12 +54108,12 @@ function stat12(path5, kind) {
53837
54108
  }
53838
54109
  var defaultSetupFileSystem = {
53839
54110
  exists: existsSync12,
53840
- isFile: (path5) => stat12(path5, "isFile"),
53841
- isDirectory: (path5) => stat12(path5, "isDirectory"),
54111
+ isFile: (path5) => stat13(path5, "isFile"),
54112
+ isDirectory: (path5) => stat13(path5, "isDirectory"),
53842
54113
  isExecutable(path5) {
53843
54114
  try {
53844
54115
  accessSync(path5, constants3.X_OK);
53845
- return stat12(path5, "isFile");
54116
+ return stat13(path5, "isFile");
53846
54117
  } catch {
53847
54118
  return false;
53848
54119
  }
@@ -54548,7 +54819,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
54548
54819
 
54549
54820
  // src/common-auth-embedded/setup/config-write.js
54550
54821
  import { randomUUID as randomUUID20 } from "node:crypto";
54551
- import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat13, unlink as unlink11 } from "node:fs/promises";
54822
+ import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat14, unlink as unlink12 } from "node:fs/promises";
54552
54823
  import { basename as basename7, dirname as dirname23, join as join28 } from "node:path";
54553
54824
  import { setTimeout as delay2 } from "node:timers/promises";
54554
54825
  async function writeHostConfigAtomic(file, content, options = {}) {
@@ -54558,7 +54829,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
54558
54829
  let mode;
54559
54830
  if (!windows2) {
54560
54831
  try {
54561
- mode = (await stat13(file)).mode & 4095;
54832
+ mode = (await stat14(file)).mode & 4095;
54562
54833
  } catch (error) {
54563
54834
  if (error.code !== "ENOENT")
54564
54835
  throw error;
@@ -54594,7 +54865,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
54594
54865
  }
54595
54866
  } finally {
54596
54867
  if (created)
54597
- await unlink11(stage).catch(() => {
54868
+ await unlink12(stage).catch(() => {
54598
54869
  });
54599
54870
  }
54600
54871
  }
@@ -55036,6 +55307,7 @@ function createV1VaultActivationMethod(input2) {
55036
55307
  // src/setup.ts
55037
55308
  init_vault_custody();
55038
55309
  init_runtime_paths();
55310
+ init_vault_folder();
55039
55311
  var PI_PLACEHOLDER_KEY = "antigravity-vault-custody";
55040
55312
  async function storePresent(anchor) {
55041
55313
  return await pathPresent(accountStorePointerPath(anchor)) || await pathPresent(anchor);
@@ -55189,6 +55461,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
55189
55461
  }
55190
55462
  };
55191
55463
  let openCodeLogin;
55464
+ let hasLocalPool = false;
55192
55465
  const manifest = JSON.parse(
55193
55466
  await readFile16(new URL("../package.json", import.meta.url), "utf8")
55194
55467
  );
@@ -55244,7 +55517,23 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
55244
55517
  },
55245
55518
  signInLocal: async (host, context) => {
55246
55519
  await assertLocal(host, context);
55247
- if (host === "opencode" && context.opencodeGeneration === "2") return;
55520
+ if (host === "opencode" && context.opencodeGeneration === "2") {
55521
+ if (!forceLogin) {
55522
+ try {
55523
+ const source2 = await deps.accountStore.read(
55524
+ deps.accountStore.legacyPath()
55525
+ );
55526
+ const candidateAccounts = source2.kind === "store" ? source2.accounts : source2.kind === "legacy" ? (await deps.loadAccounts())?.accounts ?? [] : [];
55527
+ if (candidateAccounts.some(
55528
+ (account) => account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true && typeof account.refreshToken === "string" && account.refreshToken.length > 0
55529
+ )) {
55530
+ hasLocalPool = true;
55531
+ }
55532
+ } catch {
55533
+ }
55534
+ }
55535
+ return;
55536
+ }
55248
55537
  const slot = (await nativeAuth(host, context))[provider(host)];
55249
55538
  const source = host === "opencode" ? await deps.accountStore.read(deps.accountStore.legacyPath()) : void 0;
55250
55539
  if (source?.kind === "unavailable") throw new Error(source.reason);
@@ -55256,6 +55545,11 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
55256
55545
  `Using existing local Antigravity login for ${host}.
55257
55546
  `
55258
55547
  );
55548
+ if (host === "opencode" && accounts.some(
55549
+ (account) => account.enabled !== false && account.accountIneligible !== true && account.verificationRequired !== true && typeof account.refreshToken === "string" && account.refreshToken.length > 0
55550
+ )) {
55551
+ hasLocalPool = true;
55552
+ }
55259
55553
  if (host === "opencode" && claustrum.classifyHostSlot(slot, provider(host)) !== "login") {
55260
55554
  const account = accounts[0];
55261
55555
  await writeNativeSlot(
@@ -55286,7 +55580,10 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
55286
55580
  host,
55287
55581
  context
55288
55582
  );
55289
- if (host === "opencode") openCodeLogin = result;
55583
+ if (host === "opencode") {
55584
+ openCodeLogin = result;
55585
+ hasLocalPool = true;
55586
+ }
55290
55587
  },
55291
55588
  beforeRegister: async (host, mode, context) => {
55292
55589
  const needsOpenCode2 = host === "opencode" && context.opencodeGeneration !== "1";
@@ -55310,7 +55607,10 @@ Setup has not completed the OpenCode 2 native Google connection.
55310
55607
  },
55311
55608
  context
55312
55609
  );
55313
- if (needsOpenCode2) nativeNextStep(OPENCODE2_POOL_AUTH_LABEL);
55610
+ if (needsOpenCode2)
55611
+ nativeNextStep(
55612
+ hasLocalPool ? OPENCODE2_POOL_RECONNECT_LABEL : OPENCODE2_POOL_AUTH_LABEL
55613
+ );
55314
55614
  return;
55315
55615
  }
55316
55616
  if (await authority(host) !== "vault")
@@ -55404,6 +55704,7 @@ async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
55404
55704
  }
55405
55705
 
55406
55706
  // src/cli.ts
55707
+ init_vault_folder();
55407
55708
  var HELP = `Usage: antigravity-auth <command> [options]
55408
55709
 
55409
55710
  Commands:
@@ -56214,8 +56515,8 @@ function getLocalDevPath(directory) {
56214
56515
  }
56215
56516
  function findPackageJsonUp(startPath) {
56216
56517
  try {
56217
- const stat15 = fs4.statSync(startPath);
56218
- let dir = stat15.isDirectory() ? startPath : path4.dirname(startPath);
56518
+ const stat16 = fs4.statSync(startPath);
56519
+ let dir = stat16.isDirectory() ? startPath : path4.dirname(startPath);
56219
56520
  for (let i = 0; i < 10; i++) {
56220
56521
  const pkgPath = path4.join(dir, "package.json");
56221
56522
  if (fs4.existsSync(pkgPath)) {
@@ -56525,12 +56826,12 @@ function isTuiConnected(sessionId) {
56525
56826
  // src/rpc/rpc-dir.ts
56526
56827
  import { createHash as createHash19 } from "node:crypto";
56527
56828
  import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
56528
- import { isAbsolute as isAbsolute4, join as join34, resolve as resolve25 } from "node:path";
56829
+ import { isAbsolute as isAbsolute5, join as join34, resolve as resolve25 } from "node:path";
56529
56830
  var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
56530
56831
  function getRpcDir(projectDirectory) {
56531
56832
  const override = process.env[RPC_DIR_ENV]?.trim();
56532
56833
  if (override) {
56533
- return isAbsolute4(override) ? override : resolve25(projectDirectory, override);
56834
+ return isAbsolute5(override) ? override : resolve25(projectDirectory, override);
56534
56835
  }
56535
56836
  const projectHash = createHash19("sha256").update(resolve25(projectDirectory)).digest("hex").slice(0, 16);
56536
56837
  const stateHome = process.env.XDG_STATE_HOME ?? join34(homedir13(), ".local", "state");
@@ -56545,7 +56846,7 @@ function isSessionId(value) {
56545
56846
  // src/common-auth-embedded/rpc/port-file.js
56546
56847
  init_private_files2();
56547
56848
  import { createHash as createHash20, randomUUID as randomUUID21 } from "node:crypto";
56548
- import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat14, unlink as unlink12 } from "node:fs/promises";
56849
+ import { chmod as chmod7, mkdir as mkdir17, open as open12, readdir as readdir4, rename as rename14, rmdir as rmdir3, stat as stat15, unlink as unlink13 } from "node:fs/promises";
56549
56850
  import { join as join35, resolve as resolve26 } from "node:path";
56550
56851
  function isProbeablePid(pid) {
56551
56852
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
@@ -56570,9 +56871,9 @@ function isUsablePortFileEntry(value, name) {
56570
56871
  const { pid, port, token } = value;
56571
56872
  return isProbeablePid(pid) && filenamePid(name) === pid && typeof port === "number" && Number.isInteger(port) && port >= 1 && port <= 65535 && typeof token === "string" && token.length > 0;
56572
56873
  }
56573
- async function removeCorruptPortFile(portFile, log16) {
56574
- log16?.debug("rpc corrupt port file", { pid: process.pid, portFile });
56575
- await unlink12(portFile).catch(() => {
56874
+ async function removeCorruptPortFile(portFile, log17) {
56875
+ log17?.debug("rpc corrupt port file", { pid: process.pid, portFile });
56876
+ await unlink13(portFile).catch(() => {
56576
56877
  });
56577
56878
  }
56578
56879
  async function writePortFile(dir, entry, options = {}) {
@@ -56610,7 +56911,7 @@ async function writePortFile(dir, entry, options = {}) {
56610
56911
  await handle?.close().catch(() => {
56611
56912
  });
56612
56913
  if (created)
56613
- await unlink12(tmp).catch(() => {
56914
+ await unlink13(tmp).catch(() => {
56614
56915
  });
56615
56916
  }
56616
56917
  return target;
@@ -56624,7 +56925,7 @@ async function writePortFile(dir, entry, options = {}) {
56624
56925
  throw error;
56625
56926
  }
56626
56927
  }
56627
- async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56928
+ async function sweepRpcState(root, activeDir, isManagedDir, log17) {
56628
56929
  let projectDirs;
56629
56930
  try {
56630
56931
  projectDirs = await readdir4(root, { withFileTypes: true });
@@ -56665,16 +56966,16 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56665
56966
  try {
56666
56967
  parsed = JSON.parse(raw);
56667
56968
  } catch {
56668
- await removeCorruptPortFile(portFile, log16);
56969
+ await removeCorruptPortFile(portFile, log17);
56669
56970
  continue;
56670
56971
  }
56671
56972
  if (!isUsablePortFileEntry(parsed, name)) {
56672
- await removeCorruptPortFile(portFile, log16);
56973
+ await removeCorruptPortFile(portFile, log17);
56673
56974
  continue;
56674
56975
  }
56675
56976
  const entry = parsed;
56676
56977
  if (!pidAlive2(entry.pid))
56677
- await unlink12(portFile).catch(() => {
56978
+ await unlink13(portFile).catch(() => {
56678
56979
  });
56679
56980
  }
56680
56981
  if (resolve26(dir) !== active2)
@@ -56689,7 +56990,7 @@ init_private_files2();
56689
56990
  // src/common-auth-embedded/rpc/rpc-server.js
56690
56991
  init_private_files2();
56691
56992
  import { randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
56692
- import { unlink as unlink13 } from "node:fs/promises";
56993
+ import { unlink as unlink14 } from "node:fs/promises";
56693
56994
  import { createServer as createServer3 } from "node:http";
56694
56995
  import { join as join36 } from "node:path";
56695
56996
  var RpcRequestError = class extends Error {
@@ -56764,7 +57065,7 @@ function tokenOk(header, token) {
56764
57065
  async function startRpcServer(options) {
56765
57066
  if (typeof options.drain === "function" === (typeof options.drainAsync === "function"))
56766
57067
  throw new TypeError("exactly one of drain or drainAsync must be provided");
56767
- const log16 = options.log ?? { warn() {
57068
+ const log17 = options.log ?? { warn() {
56768
57069
  }, debug() {
56769
57070
  } };
56770
57071
  const token = randomBytes7(32).toString("hex");
@@ -56865,7 +57166,7 @@ async function startRpcServer(options) {
56865
57166
  return json(400, { error: "session required" });
56866
57167
  if (sessionId === void 0 && !warnedMissingNotificationSession) {
56867
57168
  warnedMissingNotificationSession = true;
56868
- log16.warn("rpc notification drain missing session id", {
57169
+ log17.warn("rpc notification drain missing session id", {
56869
57170
  pid: process.pid
56870
57171
  });
56871
57172
  }
@@ -56874,7 +57175,7 @@ async function startRpcServer(options) {
56874
57175
  try {
56875
57176
  messages = await options.drainAsync(lastReceivedId, sessionId);
56876
57177
  } catch (error) {
56877
- log16.warn("rpc notification drain failed", {
57178
+ log17.warn("rpc notification drain failed", {
56878
57179
  pid: process.pid,
56879
57180
  error: error instanceof Error ? error.message : String(error)
56880
57181
  });
@@ -56893,20 +57194,20 @@ async function startRpcServer(options) {
56893
57194
  return json(404, { error: "unknown method" });
56894
57195
  } catch (error) {
56895
57196
  if (error instanceof RpcRequestError) {
56896
- log16.debug("rpc request refused", {
57197
+ log17.debug("rpc request refused", {
56897
57198
  pid: process.pid,
56898
57199
  status: error.status
56899
57200
  });
56900
57201
  return json(error.status, { error: error.message });
56901
57202
  }
56902
57203
  if (error instanceof ApplyDeadlineError) {
56903
- log16.warn("rpc apply deadline exceeded", {
57204
+ log17.warn("rpc apply deadline exceeded", {
56904
57205
  pid: process.pid,
56905
57206
  deadlineMs: options.applyDeadlineMs
56906
57207
  });
56907
57208
  return json(504, { error: "handler deadline exceeded" });
56908
57209
  }
56909
- log16.warn("rpc request failed", {
57210
+ log17.warn("rpc request failed", {
56910
57211
  pid: process.pid,
56911
57212
  error: error instanceof Error ? error.message : String(error)
56912
57213
  });
@@ -56926,9 +57227,9 @@ async function startRpcServer(options) {
56926
57227
  server.unref();
56927
57228
  if (options.sweepRoot) {
56928
57229
  try {
56929
- await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir, log16);
57230
+ await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir, log17);
56930
57231
  } catch (error) {
56931
- log16.warn("rpc state sweep failed", {
57232
+ log17.warn("rpc state sweep failed", {
56932
57233
  pid: process.pid,
56933
57234
  error: error instanceof Error ? error.message : String(error)
56934
57235
  });
@@ -56936,7 +57237,7 @@ async function startRpcServer(options) {
56936
57237
  }
56937
57238
  try {
56938
57239
  await writePortFile(options.dir, { port, token, pid: process.pid }, { secureDir: options.secureDir });
56939
- log16.debug("rpc server pid", {
57240
+ log17.debug("rpc server pid", {
56940
57241
  pid: process.pid,
56941
57242
  rpcPort: port
56942
57243
  });
@@ -56961,7 +57262,7 @@ async function startRpcServer(options) {
56961
57262
  return void 0;
56962
57263
  });
56963
57264
  if (current?.port === port && current.token === token)
56964
- await unlink13(portFile).catch(() => {
57265
+ await unlink14(portFile).catch(() => {
56965
57266
  });
56966
57267
  }
56967
57268
  };
@@ -57036,6 +57337,9 @@ function parsePending(value) {
57036
57337
  };
57037
57338
  }
57038
57339
 
57340
+ // src/plugin/index.ts
57341
+ init_vault_folder();
57342
+
57039
57343
  // src/plugin/oauth-methods.ts
57040
57344
  init_dist();
57041
57345
  import { exec } from "node:child_process";
@@ -58317,10 +58621,10 @@ function toV1AuthCallbackResult(result) {
58317
58621
  };
58318
58622
  }
58319
58623
  var MAX_OAUTH_ACCOUNTS = 10;
58320
- var log11 = createLogger4("oauth-methods");
58321
- async function reportPersistenceFailure(error, client, log16) {
58624
+ var log12 = createLogger4("oauth-methods");
58625
+ async function reportPersistenceFailure(error, client, log17) {
58322
58626
  const message = error instanceof AccountStorageUnreadableError ? `Account storage at ${error.details.path} is unreadable (${error.details.reason}: ${error.details.detail}).${error.details.backupPath ? ` A backup was written to ${error.details.backupPath}. Repair or remove the existing file before retrying.` : " A backup could not be written; repair or remove the existing file before retrying."}` : error instanceof Error ? error.message : String(error);
58323
- log16.error("OAuth login persistence failed; aborting login", {
58627
+ log17.error("OAuth login persistence failed; aborting login", {
58324
58628
  error: message
58325
58629
  });
58326
58630
  try {
@@ -59157,7 +59461,7 @@ ${verifyUrl}
59157
59461
  }
59158
59462
  });
59159
59463
  } catch (storeError) {
59160
- log11.error(
59464
+ log12.error(
59161
59465
  "Failed to update stored Antigravity OAuth credentials",
59162
59466
  { error: String(storeError) }
59163
59467
  );
@@ -59182,7 +59486,7 @@ ${verifyUrl}
59182
59486
  }
59183
59487
  });
59184
59488
  } catch (storeError) {
59185
- log11.error(
59489
+ log12.error(
59186
59490
  "Failed to clear stored Antigravity OAuth credentials",
59187
59491
  { error: String(storeError) }
59188
59492
  );
@@ -59223,7 +59527,7 @@ Re-authenticating ${refreshEmail || "account"}...
59223
59527
  }
59224
59528
  });
59225
59529
  } catch (storeError) {
59226
- log11.error(
59530
+ log12.error(
59227
59531
  "Failed to clear stored Antigravity OAuth credentials",
59228
59532
  { error: String(storeError) }
59229
59533
  );
@@ -59562,7 +59866,7 @@ ${authorization2.url}
59562
59866
  return await reportPersistenceFailure(
59563
59867
  persistError,
59564
59868
  client,
59565
- log11
59869
+ log12
59566
59870
  );
59567
59871
  }
59568
59872
  const newTotal = existingCount + 1;
@@ -59606,7 +59910,7 @@ ${authorization2.url}
59606
59910
  try {
59607
59911
  await persistAccountPool2([result], false);
59608
59912
  } catch (persistError) {
59609
- return await reportPersistenceFailure(persistError, client, log11);
59913
+ return await reportPersistenceFailure(persistError, client, log12);
59610
59914
  }
59611
59915
  const newTotal = existingCount + 1;
59612
59916
  const toastMessage = existingCount > 0 ? `Added account${result.email ? ` (${result.email})` : ""} - ${newTotal} total` : `Authenticated${result.email ? ` (${result.email})` : ""}`;
@@ -59767,7 +60071,7 @@ import { createHash as createHash21 } from "node:crypto";
59767
60071
  init_debug();
59768
60072
  init_logger4();
59769
60073
  init_storage();
59770
- var log12 = createLogger4("auth-loader");
60074
+ var log13 = createLogger4("auth-loader");
59771
60075
  function refreshTokenIdentity(refreshToken) {
59772
60076
  return createHash21("sha256").update(refreshToken).digest("hex").slice(0, 16);
59773
60077
  }
@@ -59914,7 +60218,7 @@ function createAuthLoader({
59914
60218
  });
59915
60219
  refreshQueue = deps.createStoreRefreshQueue(
59916
60220
  {
59917
- logger: log12,
60221
+ logger: log13,
59918
60222
  refreshToken: (_auth, account) => credentials.refresh(account)
59919
60223
  },
59920
60224
  queueConfig
@@ -60022,7 +60326,7 @@ function createAuthLoader({
60022
60326
  }
60023
60327
  if (opening.status === "ready") {
60024
60328
  if (!isOAuthAuth(auth) && !readAuthority2) {
60025
- log12.warn(
60329
+ log13.warn(
60026
60330
  "The host holds no Antigravity sign-in; the account store is left untouched"
60027
60331
  );
60028
60332
  return {};
@@ -60035,7 +60339,7 @@ function createAuthLoader({
60035
60339
  }
60036
60340
  if (!usesPoolFile(opening)) {
60037
60341
  const message = opening.status === "refused" || opening.status === "recovery-required" ? opening.message : "The Antigravity account store cannot be opened";
60038
- log12.error("Refusing to start: the account store cannot serve", {
60342
+ log13.error("Refusing to start: the account store cannot serve", {
60039
60343
  message
60040
60344
  });
60041
60345
  try {
@@ -60052,7 +60356,7 @@ function createAuthLoader({
60052
60356
  storedAccounts = await deps.loadAccounts();
60053
60357
  } catch (error) {
60054
60358
  if (error instanceof AccountStorageUnreadableError) {
60055
- log12.error("Refusing to start: account storage is unreadable", {
60359
+ log13.error("Refusing to start: account storage is unreadable", {
60056
60360
  path: error.details.path,
60057
60361
  reason: error.details.reason,
60058
60362
  backupPath: error.details.backupPath
@@ -60084,12 +60388,12 @@ function createAuthLoader({
60084
60388
  expires: auth.expires ?? 0
60085
60389
  }
60086
60390
  });
60087
- log12.info("Restored Antigravity OAuth auth from account storage", {
60391
+ log13.info("Restored Antigravity OAuth auth from account storage", {
60088
60392
  reason: drift.reason,
60089
60393
  email: drift.account.email
60090
60394
  });
60091
60395
  } catch (error) {
60092
- log12.warn(
60396
+ log13.warn(
60093
60397
  "Failed to restore Antigravity OAuth auth from account storage",
60094
60398
  { error: String(error) }
60095
60399
  );
@@ -60752,7 +61056,7 @@ init_dist();
60752
61056
  init_debug();
60753
61057
  init_logger4();
60754
61058
  init_vault_request_credentials();
60755
- var log13 = createLogger4("fetch-interceptor");
61059
+ var log14 = createLogger4("fetch-interceptor");
60756
61060
  var defaultAgyTransport = (url, init, options) => fetchWithAgyCliTransport(url, init, options);
60757
61061
  var defaultFetchImpl = (input2, init) => globalThis.fetch(input2, init);
60758
61062
  function poolFileCredentials(accountManager, client, providerId) {
@@ -60805,14 +61109,14 @@ function openCode1EngineCollaborators(common) {
60805
61109
  // the engine calls.
60806
61110
  debug: debug_exports,
60807
61111
  dump: { dumpRequest: dumpGeminiRequest },
60808
- logger: log13,
61112
+ logger: log14,
60809
61113
  classifyAccessError: extractAccountAccessErrorDetails,
60810
61114
  notify: (message, variant) => client.tui.showToast({ body: { message, variant } }),
60811
61115
  onRouting: common.onRouting ?? ((sessionId, entry) => {
60812
61116
  void upsertSidebarActiveRouting(sessionId, entry, {
60813
61117
  authoritative: true
60814
61118
  }).catch((error) => {
60815
- log13.debug("sidebar-routing-upsert-failed", {
61119
+ log14.debug("sidebar-routing-upsert-failed", {
60816
61120
  sessionId,
60817
61121
  error: String(error)
60818
61122
  });
@@ -60838,7 +61142,7 @@ function createFetchInterceptor(context) {
60838
61142
  const refreshQuotaAfterSuccess = createLocalQuotaRefresh(
60839
61143
  accountManager,
60840
61144
  quotaManager,
60841
- log13
61145
+ log14
60842
61146
  );
60843
61147
  const executor = createRequestExecutor({
60844
61148
  assertAdmission: context.assertAdmission,
@@ -60984,7 +61288,7 @@ init_logger4();
60984
61288
  // src/plugin/search.ts
60985
61289
  import crypto3 from "node:crypto";
60986
61290
  init_logger4();
60987
- var log14 = createLogger4("search");
61291
+ var log15 = createLogger4("search");
60988
61292
  var sessionCounter = 0;
60989
61293
  var sessionPrefix = `search-${Date.now().toString(36)}`;
60990
61294
  function generateRequestId() {
@@ -61116,7 +61420,7 @@ ${urlList}`;
61116
61420
  requestType: "agent"
61117
61421
  };
61118
61422
  const url = `${ANTIGRAVITY_ENDPOINT}/v1internal:generateContent`;
61119
- log14.debug("Executing search", {
61423
+ log15.debug("Executing search", {
61120
61424
  query,
61121
61425
  urlCount: urls?.length ?? 0,
61122
61426
  thinking
@@ -61139,7 +61443,7 @@ ${urlList}`;
61139
61443
  );
61140
61444
  if (!response.ok) {
61141
61445
  const errorText3 = await response.text();
61142
- log14.debug("Search API error", {
61446
+ log15.debug("Search API error", {
61143
61447
  status: response.status,
61144
61448
  error: errorText3
61145
61449
  });
@@ -61152,14 +61456,14 @@ ${errorText3}
61152
61456
  Please try again with a different query.`;
61153
61457
  }
61154
61458
  const data = await response.json();
61155
- log14.debug("Search response received", { hasResponse: !!data.response });
61459
+ log15.debug("Search response received", { hasResponse: !!data.response });
61156
61460
  const result = parseSearchResponse(data);
61157
61461
  const formatted = formatSearchResult(result);
61158
- log14.debug("Search response formatted", { resultLength: formatted.length });
61462
+ log15.debug("Search response formatted", { resultLength: formatted.length });
61159
61463
  return formatted;
61160
61464
  } catch (error) {
61161
61465
  const message = error instanceof Error ? error.message : String(error);
61162
- log14.debug("Search execution error", { error: message });
61466
+ log15.debug("Search execution error", { error: message });
61163
61467
  return `## Search Error
61164
61468
 
61165
61469
  Failed to execute search: ${message}. Please try again with a different query.`;
@@ -61167,7 +61471,7 @@ Failed to execute search: ${message}. Please try again with a different query.`;
61167
61471
  }
61168
61472
 
61169
61473
  // src/plugin/google-search-tool.ts
61170
- var log15 = createLogger4("plugin");
61474
+ var log16 = createLogger4("plugin");
61171
61475
  function createGoogleSearchTool({
61172
61476
  getAuth,
61173
61477
  client,
@@ -61189,7 +61493,7 @@ function createGoogleSearchTool({
61189
61493
  if (mayStartLocalWork && !await mayStartLocalWork()) {
61190
61494
  return "Google Search is not available through local credentials while vault custody is active or unreadable.";
61191
61495
  }
61192
- log15.debug("Google Search tool called", {
61496
+ log16.debug("Google Search tool called", {
61193
61497
  query: args.query,
61194
61498
  urlCount: args.urls?.length ?? 0
61195
61499
  });