@cortexkit/opencode-antigravity-auth 3.0.22 → 3.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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))
@@ -8083,7 +8083,7 @@ function writeConsoleLog(level, ...args) {
8083
8083
  }
8084
8084
  function createLogger(module) {
8085
8085
  const service = `antigravity.${module}`;
8086
- const log16 = (level, message, extra) => {
8086
+ const log17 = (level, message, extra) => {
8087
8087
  if (_sink) {
8088
8088
  try {
8089
8089
  _sink({ service, level, message, extra });
@@ -8097,10 +8097,10 @@ function createLogger(module) {
8097
8097
  }
8098
8098
  };
8099
8099
  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)
8100
+ debug: (message, extra) => log17("debug", message, extra),
8101
+ info: (message, extra) => log17("info", message, extra),
8102
+ warn: (message, extra) => log17("warn", message, extra),
8103
+ error: (message, extra) => log17("error", message, extra)
8104
8104
  };
8105
8105
  }
8106
8106
  var ENV_CONSOLE_LOG, _sink;
@@ -25267,13 +25267,13 @@ async function safeRead(path5, privateFile = false, afterReadCheck) {
25267
25267
  let file;
25268
25268
  try {
25269
25269
  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) {
25270
+ const stat16 = await file.stat();
25271
+ if (!stat16.isFile() || privateFile && (stat16.mode & 511) !== 384) {
25272
25272
  throw new PiSlotError("unsafe-path");
25273
25273
  }
25274
25274
  await afterReadCheck?.(path5);
25275
25275
  const current = await lstat5(path5);
25276
- if (!current.isFile() || current.dev !== stat15.dev || current.ino !== stat15.ino) {
25276
+ if (!current.isFile() || current.dev !== stat16.dev || current.ino !== stat16.ino) {
25277
25277
  throw new PiSlotError("unsafe-path");
25278
25278
  }
25279
25279
  const bytes = await file.readFile();
@@ -28694,7 +28694,7 @@ function getAntigravityVersionResolution() {
28694
28694
  return lastResolution ?? { version: getAntigravityVersion(), source: "fallback" };
28695
28695
  }
28696
28696
  async function initAntigravityVersion() {
28697
- const log16 = createLogger("version");
28697
+ const log17 = createLogger("version");
28698
28698
  const fallback = getAntigravityVersion();
28699
28699
  let version;
28700
28700
  let source;
@@ -28708,15 +28708,15 @@ async function initAntigravityVersion() {
28708
28708
  } else {
28709
28709
  source = "fallback";
28710
28710
  setAntigravityVersion(fallback);
28711
- log16.info("version-fetch-failed", { fallback });
28711
+ log17.info("version-fetch-failed", { fallback });
28712
28712
  lastResolution = { version: fallback, source };
28713
28713
  return lastResolution;
28714
28714
  }
28715
28715
  }
28716
28716
  if (version !== fallback) {
28717
- log16.info("version-updated", { version, source, previous: fallback });
28717
+ log17.info("version-updated", { version, source, previous: fallback });
28718
28718
  } else {
28719
- log16.debug("version-unchanged", { version, source });
28719
+ log17.debug("version-unchanged", { version, source });
28720
28720
  }
28721
28721
  setAntigravityVersion(version);
28722
28722
  lastResolution = { version, source };
@@ -28786,13 +28786,6 @@ var init_dist = __esm({
28786
28786
  }
28787
28787
  });
28788
28788
 
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
28789
  // src/common-auth-embedded/fs/private-files.js
28797
28790
  import { randomUUID as randomUUID13 } from "node:crypto";
28798
28791
  import { lstat as lstat6, readFile as readFile8, rename as rename8, unlink as unlink8 } from "node:fs/promises";
@@ -29090,6 +29083,13 @@ var init_private_files2 = __esm({
29090
29083
  }
29091
29084
  });
29092
29085
 
29086
+ // src/common-auth-embedded/logger/capture-sink.js
29087
+ var init_capture_sink2 = __esm({
29088
+ "src/common-auth-embedded/logger/capture-sink.js"() {
29089
+ "use strict";
29090
+ }
29091
+ });
29092
+
29093
29093
  // src/common-auth-embedded/logger/redact.js
29094
29094
  function isError2(value) {
29095
29095
  return value instanceof Error || Object.prototype.toString.call(value) === "[object Error]";
@@ -30917,8 +30917,8 @@ var init_process_heartbeat = __esm({
30917
30917
  });
30918
30918
 
30919
30919
  // src/version-fence.ts
30920
- import { readdir as readdir2, readFile as readFile11 } from "node:fs/promises";
30921
- import { homedir as homedir3 } from "node:os";
30920
+ import { readdir as readdir2, readFile as readFile11, stat as stat9, unlink as unlink9 } from "node:fs/promises";
30921
+ import { homedir as homedir3, uptime } from "node:os";
30922
30922
  import { join as join13 } from "node:path";
30923
30923
  function defaultStateHome() {
30924
30924
  return process.env.XDG_STATE_HOME || join13(homedir3(), ".local", "state");
@@ -31001,13 +31001,18 @@ async function readProcessRecord(path5, pid) {
31001
31001
  return { kind: "gone" };
31002
31002
  return { kind: "unreadable" };
31003
31003
  }
31004
+ let startedAt;
31004
31005
  try {
31005
31006
  const value = JSON.parse(text2);
31007
+ if (isRecord10(value) && typeof value.startedAt === "number" && Number.isFinite(value.startedAt))
31008
+ startedAt = value.startedAt;
31006
31009
  if (value !== null && typeof value === "object" && value.pid === pid && typeof value.version === "string") {
31007
31010
  const layouts = value.layouts;
31008
31011
  const stores = value.stores;
31009
31012
  return {
31010
31013
  kind: "ok",
31014
+ text: text2,
31015
+ startedAt,
31011
31016
  version: value.version,
31012
31017
  ...isRecord10(layouts) ? { layouts } : {},
31013
31018
  ...isRecord10(stores) ? { stores } : {}
@@ -31015,14 +31020,45 @@ async function readProcessRecord(path5, pid) {
31015
31020
  }
31016
31021
  } catch {
31017
31022
  }
31018
- return { kind: "unreadable" };
31023
+ return { kind: "unreadable", text: text2, startedAt };
31019
31024
  }
31020
31025
  function isRecord10(value) {
31021
31026
  return value !== null && typeof value === "object" && !Array.isArray(value);
31022
31027
  }
31028
+ function bootTime(options) {
31029
+ try {
31030
+ return (options.now ?? Date.now)() - (options.uptimeSeconds ?? uptime)() * 1e3;
31031
+ } catch {
31032
+ return Number.NaN;
31033
+ }
31034
+ }
31035
+ async function staleRecord(path5, record3, boot, heartbeat) {
31036
+ if (record3.text === void 0 || !Number.isFinite(boot)) return false;
31037
+ let start = heartbeat ? record3.startedAt : void 0;
31038
+ if (start === void 0) {
31039
+ try {
31040
+ start = (await stat9(path5)).mtimeMs;
31041
+ } catch {
31042
+ return false;
31043
+ }
31044
+ }
31045
+ if (!Number.isFinite(start) || !(start < boot - BOOT_TIME_MARGIN_MS))
31046
+ return false;
31047
+ if (heartbeat) {
31048
+ try {
31049
+ if (await readFile11(path5, "utf8") === record3.text) {
31050
+ await unlink9(path5);
31051
+ log5.debug("Removed stale pre-boot heartbeat", { path: path5 });
31052
+ }
31053
+ } catch {
31054
+ }
31055
+ }
31056
+ return true;
31057
+ }
31023
31058
  async function versionFenceOpen(options) {
31024
31059
  const isAlive = options.isAlive ?? pidAlive;
31025
31060
  const self = options.selfPid ?? process.pid;
31061
+ const boot = bootTime(options);
31026
31062
  const blockers = /* @__PURE__ */ new Map();
31027
31063
  const block = (entry) => {
31028
31064
  const key = entry.pid === "unknown" ? `dir:${entry.detail}` : entry.pid;
@@ -31045,7 +31081,8 @@ async function versionFenceOpen(options) {
31045
31081
  const path5 = join13(heartbeatDir, name);
31046
31082
  const heartbeat = await readProcessRecord(path5, pid);
31047
31083
  if (heartbeat.kind === "gone") continue;
31048
- if (!alive(pid)) continue;
31084
+ const live = alive(pid);
31085
+ if (await staleRecord(path5, heartbeat, boot, true) || !live) continue;
31049
31086
  if (heartbeat.kind === "unreadable") {
31050
31087
  block({ pid, version: "unknown", detail: path5 });
31051
31088
  continue;
@@ -31079,6 +31116,7 @@ async function versionFenceOpen(options) {
31079
31116
  const path5 = join13(dir, name);
31080
31117
  const port = await readProcessRecord(path5, pid);
31081
31118
  if (port.kind === "gone") continue;
31119
+ if (await staleRecord(path5, port, boot, false)) continue;
31082
31120
  const version = port.kind === "ok" ? port.version : "unknown";
31083
31121
  const order = compareVersions(version, options.currentVersion);
31084
31122
  if (order === void 0 || order < 0)
@@ -31091,9 +31129,13 @@ async function versionFenceOpen(options) {
31091
31129
  blockers: [...blockers.values()].sort((a, b) => rank(a) - rank(b))
31092
31130
  };
31093
31131
  }
31132
+ var log5, BOOT_TIME_MARGIN_MS;
31094
31133
  var init_version_fence = __esm({
31095
31134
  "src/version-fence.ts"() {
31096
31135
  "use strict";
31136
+ init_logger4();
31137
+ log5 = createLogger4("version-fence");
31138
+ BOOT_TIME_MARGIN_MS = 3e5;
31097
31139
  }
31098
31140
  });
31099
31141
 
@@ -31124,8 +31166,8 @@ import {
31124
31166
  readFile as readFile12,
31125
31167
  rename as rename10,
31126
31168
  rmdir as rmdir2,
31127
- stat as stat9,
31128
- unlink as unlink9
31169
+ stat as stat10,
31170
+ unlink as unlink10
31129
31171
  } from "node:fs/promises";
31130
31172
  import { basename as basename4, dirname as dirname15, join as join14, resolve as resolve15 } from "node:path";
31131
31173
  function refusalMessage(stateDir, errorClass2) {
@@ -31180,10 +31222,10 @@ function errorFile(error) {
31180
31222
  ...typeof stage === "string" && stage ? { stage } : {}
31181
31223
  };
31182
31224
  }
31183
- function logCleanupFailure(location, log16, step, error) {
31225
+ function logCleanupFailure(location, log17, step, error) {
31184
31226
  logOnce(
31185
31227
  `${location.key}\0cleanup`,
31186
- () => log16.warn(
31228
+ () => log17.warn(
31187
31229
  "antigravity-auth could not finish removing its old vault files from OpenCode's config folder; it tries again at the next start",
31188
31230
  {
31189
31231
  configDir: location.configDir,
@@ -31212,13 +31254,13 @@ function prepareRuntimeLayout(options) {
31212
31254
  return run;
31213
31255
  }
31214
31256
  async function decide(location, options) {
31215
- const log16 = options.log ?? createLogger4("runtime-layout");
31257
+ const log17 = options.log ?? createLogger4("runtime-layout");
31216
31258
  const stateDir = location.stateHomeDir;
31217
31259
  const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
31218
31260
  const files = layoutFiles(location, options.accountFile);
31219
31261
  const fence = options.fence ?? defaultFence(options.version);
31220
31262
  const stateHome = async () => {
31221
- await settleVault(location, options, "state-home", log16);
31263
+ await settleVault(location, options, "state-home", log17);
31222
31264
  return "state-home";
31223
31265
  };
31224
31266
  let marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -31229,7 +31271,7 @@ async function decide(location, options) {
31229
31271
  join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
31230
31272
  ).catch(() => true);
31231
31273
  if (!manifestLeft) {
31232
- await settleVault(location, options, "state-home", log16);
31274
+ await settleVault(location, options, "state-home", log17);
31233
31275
  return stateHome();
31234
31276
  }
31235
31277
  }
@@ -31241,7 +31283,7 @@ async function decide(location, options) {
31241
31283
  RUNTIME_LAYOUT_LOCK_NAME,
31242
31284
  markerPath,
31243
31285
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
31244
- log16
31286
+ log17
31245
31287
  );
31246
31288
  } catch (error) {
31247
31289
  marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -31261,7 +31303,7 @@ async function decide(location, options) {
31261
31303
  const legacy = async () => {
31262
31304
  try {
31263
31305
  await lock.assertOwned();
31264
- await settleVault(location, options, "legacy", log16);
31306
+ await settleVault(location, options, "legacy", log17);
31265
31307
  } catch (error) {
31266
31308
  throw new RuntimeLayoutRefusal(stateDir, errorClass(error));
31267
31309
  }
@@ -31275,20 +31317,20 @@ async function decide(location, options) {
31275
31317
  if (!marker.oldFilesRemoved && !aliased)
31276
31318
  await finishOldFiles(location, files, markerPath, marker, lock, {
31277
31319
  fence,
31278
- log: log16,
31320
+ log: log17,
31279
31321
  steps: options.steps,
31280
31322
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile()
31281
31323
  });
31282
31324
  else if (marker.oldFilesRemoved) {
31283
31325
  await refuseReappearedFiles(location, files);
31284
- await removeLeftoverManifest(location, lock, options.steps, log16);
31326
+ await removeLeftoverManifest(location, lock, options.steps, log17);
31285
31327
  }
31286
31328
  return await stateHome();
31287
31329
  }
31288
31330
  if (aliased) {
31289
31331
  logOnce(
31290
31332
  `${location.key}\0aliased`,
31291
- () => log16.warn(
31333
+ () => log17.warn(
31292
31334
  "antigravity-auth keeps its vault files in OpenCode's config folder: its state folder is that same folder",
31293
31335
  { configDir: location.configDir, stateDir }
31294
31336
  )
@@ -31297,14 +31339,14 @@ async function decide(location, options) {
31297
31339
  }
31298
31340
  const gate = await fence();
31299
31341
  if (!gate.open) {
31300
- logDeferral(location, gate.blockers, log16);
31342
+ logDeferral(location, gate.blockers, log17);
31301
31343
  return await legacy();
31302
31344
  }
31303
31345
  let markerStarted = false;
31304
31346
  try {
31305
31347
  const outcome = await moveFiles(location, files, markerPath, lock, {
31306
31348
  fence,
31307
- log: log16,
31349
+ log: log17,
31308
31350
  steps: options.steps,
31309
31351
  destinationPrivate: options.destinationPrivate ?? defaultDestinationPrivate,
31310
31352
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile(),
@@ -31313,13 +31355,13 @@ async function decide(location, options) {
31313
31355
  }
31314
31356
  });
31315
31357
  if (outcome.kind === "deferred") {
31316
- logDeferral(location, outcome.blockers, log16);
31358
+ logDeferral(location, outcome.blockers, log17);
31317
31359
  return await legacy();
31318
31360
  }
31319
31361
  if (outcome.kind === "refused") {
31320
31362
  logOnce(
31321
31363
  `${location.key}\0refused`,
31322
- () => log16.warn(
31364
+ () => log17.warn(
31323
31365
  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
31366
  { reason: outcome.reason, paths: outcome.paths, stateDir }
31325
31367
  )
@@ -31327,7 +31369,7 @@ async function decide(location, options) {
31327
31369
  return await legacy();
31328
31370
  }
31329
31371
  if (outcome.moved)
31330
- log16.info(
31372
+ log17.info(
31331
31373
  "antigravity-auth moved its vault files out of OpenCode's config folder",
31332
31374
  { from: files.vault.old, to: files.vault.next }
31333
31375
  );
@@ -31338,7 +31380,7 @@ async function decide(location, options) {
31338
31380
  return await stateHome();
31339
31381
  logOnce(
31340
31382
  `${location.key}\0failed`,
31341
- () => log16.warn(
31383
+ () => log17.warn(
31342
31384
  "antigravity-auth's vault files stay in OpenCode's config folder: moving them failed; the move is tried again at the next start",
31343
31385
  {
31344
31386
  configDir: location.configDir,
@@ -31367,8 +31409,12 @@ async function settleVault(location, options, layout, _log) {
31367
31409
  }
31368
31410
  async function localAccountStoreAuthorized() {
31369
31411
  const location = runtimeLayoutLocation();
31412
+ const folder = process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR ? (await Promise.resolve().then(() => (init_vault_folder(), vault_folder_exports))).currentVaultFolder(
31413
+ accountFileForVault(location.configDir)
31414
+ ) : void 0;
31415
+ if (folder?.refusal) return false;
31370
31416
  const claustrum = await loadCommonAuthClaustrum();
31371
- const vaultDir = decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
31417
+ const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
31372
31418
  return await enrollmentAuthority2(
31373
31419
  claustrum.hostEnrollmentPaths({
31374
31420
  stateDir: vaultDir,
@@ -31383,7 +31429,7 @@ async function prepareAccountStore(options) {
31383
31429
  if (!await localAccountStoreAuthorized()) return void 0;
31384
31430
  const decided = decidedAccountStoreAnchor(location);
31385
31431
  if (decided) return decided;
31386
- const log16 = options.log ?? createLogger4("runtime-layout");
31432
+ const log17 = options.log ?? createLogger4("runtime-layout");
31387
31433
  const runKey = `${location.stateHomeDir}\0${location.key}`;
31388
31434
  let run = processState.storeRuns.get(runKey);
31389
31435
  if (!run) {
@@ -31394,12 +31440,12 @@ async function prepareAccountStore(options) {
31394
31440
  RUNTIME_LAYOUT_LOCK_NAME,
31395
31441
  join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
31396
31442
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
31397
- log16
31443
+ log17
31398
31444
  );
31399
31445
  try {
31400
31446
  await lock.assertOwned();
31401
31447
  if (!await localAccountStoreAuthorized()) return void 0;
31402
- return await settleAccountStore(location, options, log16);
31448
+ return await settleAccountStore(location, options, log17);
31403
31449
  } finally {
31404
31450
  await lock.release();
31405
31451
  }
@@ -31410,20 +31456,20 @@ async function prepareAccountStore(options) {
31410
31456
  }
31411
31457
  return run;
31412
31458
  }
31413
- async function settleAccountStore(location, options, log16) {
31459
+ async function settleAccountStore(location, options, log17) {
31414
31460
  const decided = decidedAccountStoreAnchor(location);
31415
31461
  if (decided) return decided;
31416
- const anchor = await decideAccountStore(location, options, log16);
31462
+ const anchor = await decideAccountStore(location, options, log17);
31417
31463
  setAccountStoreAnchor(location, anchor);
31418
31464
  return anchor;
31419
31465
  }
31420
- async function decideAccountStore(location, options, log16) {
31421
- const keepConfig = () => recordAnchor(location, options, "config", log16);
31466
+ async function decideAccountStore(location, options, log17) {
31467
+ const keepConfig = () => recordAnchor(location, options, "config", log17);
31422
31468
  if (processHasOlderGeneration()) {
31423
31469
  logOnce(
31424
31470
  "older-generation-account-store",
31425
31471
  () => showLog(
31426
- log16,
31472
+ log17,
31427
31473
  "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
31474
  { accountStore: "config" }
31429
31475
  )
@@ -31437,7 +31483,7 @@ async function decideAccountStore(location, options, log16) {
31437
31483
  if (!sameSpelling(forward.legacyPath, stateAnchor)) {
31438
31484
  logOnce(
31439
31485
  `${location.key}\0store-forward-elsewhere`,
31440
- () => log16.warn(
31486
+ () => log17.warn(
31441
31487
  "the account store moved to another folder than this process resolved; check XDG_STATE_HOME",
31442
31488
  { movedTo: forward.legacyPath, expected: stateAnchor }
31443
31489
  )
@@ -31448,9 +31494,9 @@ async function decideAccountStore(location, options, log16) {
31448
31494
  options,
31449
31495
  configAnchor,
31450
31496
  stateAnchor,
31451
- log16
31497
+ log17
31452
31498
  );
31453
- return recordAnchor(location, options, "state-home", log16);
31499
+ return recordAnchor(location, options, "state-home", log17);
31454
31500
  }
31455
31501
  if (decidedRuntimeLayout(location) === "legacy") return keepConfig();
31456
31502
  const configStore = await presentAccountStore(configAnchor);
@@ -31462,9 +31508,9 @@ async function decideAccountStore(location, options, log16) {
31462
31508
  `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
31509
  );
31464
31510
  }
31465
- if (stateStore) return recordAnchor(location, options, "state-home", log16);
31511
+ if (stateStore) return recordAnchor(location, options, "state-home", log17);
31466
31512
  if (configStore) {
31467
- if (!await storeMovePathResolves(stateAnchor, location, log16))
31513
+ if (!await storeMovePathResolves(stateAnchor, location, log17))
31468
31514
  return keepConfig();
31469
31515
  return moveStore(
31470
31516
  location,
@@ -31472,21 +31518,21 @@ async function decideAccountStore(location, options, log16) {
31472
31518
  configAnchor,
31473
31519
  stateAnchor,
31474
31520
  false,
31475
- log16,
31521
+ log17,
31476
31522
  false
31477
31523
  );
31478
31524
  }
31479
- if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log16))
31525
+ if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log17))
31480
31526
  return keepConfig();
31481
- if (!await storeMovePathResolves(stateAnchor, location, log16))
31527
+ if (!await storeMovePathResolves(stateAnchor, location, log17))
31482
31528
  return keepConfig();
31483
- return initializeStore(location, options, stateAnchor, log16);
31529
+ return initializeStore(location, options, stateAnchor, log17);
31484
31530
  }
31485
- function showLog(log16, message, meta) {
31486
- if (log16.log) log16.log(message, meta);
31487
- else log16.info(message, meta);
31531
+ function showLog(log17, message, meta) {
31532
+ if (log17.log) log17.log(message, meta);
31533
+ else log17.info(message, meta);
31488
31534
  }
31489
- async function recordAnchor(location, options, anchor, log16) {
31535
+ async function recordAnchor(location, options, anchor, log17) {
31490
31536
  try {
31491
31537
  await recordProcessAnchor({
31492
31538
  key: location.key,
@@ -31498,32 +31544,32 @@ async function recordAnchor(location, options, anchor, log16) {
31498
31544
  }
31499
31545
  if (anchor === "state-home")
31500
31546
  showLog(
31501
- log16,
31547
+ log17,
31502
31548
  "antigravity-auth keeps its account store in its state folder",
31503
31549
  { accountStore: anchor }
31504
31550
  );
31505
31551
  return anchor;
31506
31552
  }
31507
- async function storeMovePathResolves(stateAnchor, location, log16) {
31553
+ async function storeMovePathResolves(stateAnchor, location, log17) {
31508
31554
  if (folderResolvesToItself(
31509
31555
  join14(location.stateHomeDir, "antigravity-accounts.json")
31510
31556
  ))
31511
31557
  return true;
31512
31558
  logOnce(
31513
31559
  `${location.key}\0store-linked-path`,
31514
- () => log16.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
31560
+ () => log17.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
31515
31561
  accountStore: stateAnchor,
31516
31562
  stateFolder: location.stateHomeDir
31517
31563
  })
31518
31564
  );
31519
31565
  return false;
31520
31566
  }
31521
- async function storeFenceOpen(location, options, log16) {
31567
+ async function storeFenceOpen(location, options, log17) {
31522
31568
  const gate = await (options.storeFence ?? defaultStoreFence(options.version))();
31523
31569
  if (gate.open) return true;
31524
31570
  logOnce(
31525
31571
  `${location.key}\0store-version-fence`,
31526
- () => log16.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31572
+ () => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31527
31573
  configDir: location.configDir,
31528
31574
  blockers: gate.blockers
31529
31575
  })
@@ -31550,7 +31596,7 @@ async function storeArtefacts(anchor) {
31550
31596
  (name) => name === store || name.startsWith(`${pool}.store.`) || name.startsWith(pool) && name.endsWith(".tmp")
31551
31597
  ).length;
31552
31598
  }
31553
- async function abandonUnpublishedStore(location, stateAnchor, log16) {
31599
+ async function abandonUnpublishedStore(location, stateAnchor, log17) {
31554
31600
  const store = await loadCommonAuthStoreModules();
31555
31601
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
31556
31602
  if (binding.status === "bound") return false;
@@ -31559,9 +31605,9 @@ async function abandonUnpublishedStore(location, stateAnchor, log16) {
31559
31605
  await rename10(folder, archived).catch((error) => {
31560
31606
  if (error.code !== "ENOENT") throw error;
31561
31607
  });
31562
- await unlink9(accountStorePointerPath(stateAnchor)).catch(() => {
31608
+ await unlink10(accountStorePointerPath(stateAnchor)).catch(() => {
31563
31609
  });
31564
- log16.info(
31610
+ log17.info(
31565
31611
  "antigravity-auth set an unfinished account store aside before starting its move again",
31566
31612
  { configDir: location.configDir, archived }
31567
31613
  );
@@ -31583,9 +31629,9 @@ async function runStoreMove(input2) {
31583
31629
  return { status: "pending", reason: outcome.reason };
31584
31630
  return { status: "cancelled" };
31585
31631
  }
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();
31632
+ async function moveStore(location, options, source, target, back, log17, forwarded) {
31633
+ const keepConfig = () => recordAnchor(location, options, "config", log17);
31634
+ if (!await storeFenceOpen(location, options, log17)) return keepConfig();
31589
31635
  try {
31590
31636
  const result = await (options.relocate ?? runStoreMove)({
31591
31637
  source,
@@ -31595,7 +31641,7 @@ async function moveStore(location, options, source, target, back, log16, forward
31595
31641
  if (result.status !== "completed") {
31596
31642
  logOnce(
31597
31643
  `${location.key}\0store-move-unfinished`,
31598
- () => log16.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31644
+ () => log17.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
31599
31645
  configDir: location.configDir,
31600
31646
  reason: result.status === "pending" ? result.reason : result.status
31601
31647
  })
@@ -31603,14 +31649,14 @@ async function moveStore(location, options, source, target, back, log16, forward
31603
31649
  return forwarded ? "state-home" : keepConfig();
31604
31650
  }
31605
31651
  showLog(
31606
- log16,
31652
+ log17,
31607
31653
  "antigravity-auth moved the account store out of OpenCode's config folder",
31608
31654
  { from: source, to: target, generation: result.id }
31609
31655
  );
31610
31656
  } catch (error) {
31611
31657
  logOnce(
31612
31658
  `${location.key}\0store-move-failed`,
31613
- () => log16.warn(
31659
+ () => log17.warn(
31614
31660
  "antigravity-auth's account store stays in OpenCode's config folder: moving it failed; the move is tried again at the next start",
31615
31661
  {
31616
31662
  configDir: location.configDir,
@@ -31621,9 +31667,9 @@ async function moveStore(location, options, source, target, back, log16, forward
31621
31667
  );
31622
31668
  return forwarded ? "state-home" : keepConfig();
31623
31669
  }
31624
- return recordAnchor(location, options, "state-home", log16);
31670
+ return recordAnchor(location, options, "state-home", log17);
31625
31671
  }
31626
- async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log16) {
31672
+ async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log17) {
31627
31673
  const store = await loadCommonAuthStoreModules();
31628
31674
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
31629
31675
  if (binding.status === "bound") return;
@@ -31634,13 +31680,13 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
31634
31680
  configAnchor,
31635
31681
  stateAnchor,
31636
31682
  false,
31637
- log16,
31683
+ log17,
31638
31684
  true
31639
31685
  );
31640
31686
  } catch (error) {
31641
31687
  logOnce(
31642
31688
  `${location.key}\0store-resume-failed`,
31643
- () => log16.warn(
31689
+ () => log17.warn(
31644
31690
  "antigravity-auth's account store is still moving; it could not be finished at this start",
31645
31691
  {
31646
31692
  configDir: location.configDir,
@@ -31651,9 +31697,9 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
31651
31697
  );
31652
31698
  }
31653
31699
  }
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();
31700
+ async function initializeStore(location, options, stateAnchor, log17) {
31701
+ const keepConfig = () => recordAnchor(location, options, "config", log17);
31702
+ if (!await storeFenceOpen(location, options, log17)) return keepConfig();
31657
31703
  try {
31658
31704
  const store = await loadCommonAuthStoreModules();
31659
31705
  const created = await initializeFreshAccountStore(store, {
@@ -31666,7 +31712,7 @@ async function initializeStore(location, options, stateAnchor, log16) {
31666
31712
  } catch (error) {
31667
31713
  logOnce(
31668
31714
  `${location.key}\0store-init-failed`,
31669
- () => log16.warn(
31715
+ () => log17.warn(
31670
31716
  "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
31717
  {
31672
31718
  configDir: location.configDir,
@@ -31678,13 +31724,13 @@ async function initializeStore(location, options, stateAnchor, log16) {
31678
31724
  return keepConfig();
31679
31725
  }
31680
31726
  showLog(
31681
- log16,
31727
+ log17,
31682
31728
  "antigravity-auth created its account store in its state folder",
31683
31729
  {
31684
31730
  accountStore: stateAnchor
31685
31731
  }
31686
31732
  );
31687
- return recordAnchor(location, options, "state-home", log16);
31733
+ return recordAnchor(location, options, "state-home", log17);
31688
31734
  }
31689
31735
  async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacyAccountFile(runtimeLayoutLocation().configDir)) {
31690
31736
  const forward = {
@@ -31699,10 +31745,10 @@ async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacy
31699
31745
  durability: "file-only-on-windows"
31700
31746
  });
31701
31747
  }
31702
- function logDeferral(location, blockers, log16) {
31748
+ function logDeferral(location, blockers, log17) {
31703
31749
  logOnce(
31704
31750
  `${location.key}\0deferred`,
31705
- () => log16.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
31751
+ () => log17.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
31706
31752
  configDir: location.configDir,
31707
31753
  blockers
31708
31754
  })
@@ -31751,7 +31797,7 @@ async function moveFiles(location, files, markerPath, layoutLock, input2) {
31751
31797
  for (const path5 of listed) {
31752
31798
  if (wanted.has(path5)) continue;
31753
31799
  await layoutLock.assertOwned();
31754
- await unlink9(path5).catch((error) => {
31800
+ await unlink10(path5).catch((error) => {
31755
31801
  if (error.code !== "ENOENT") throw error;
31756
31802
  });
31757
31803
  }
@@ -31860,13 +31906,13 @@ async function finishOldFiles(location, files, markerPath, marker, layoutLock, i
31860
31906
  if (done) await removeOldVaultFolder(files, layoutLock, input2.steps);
31861
31907
  }
31862
31908
  }
31863
- async function removeLeftoverManifest(location, layoutLock, steps, log16) {
31909
+ async function removeLeftoverManifest(location, layoutLock, steps, log17) {
31864
31910
  try {
31865
31911
  await removeManifestOwned(location.stateHomeDir, layoutLock, steps);
31866
31912
  } catch (error) {
31867
31913
  logOnce(
31868
31914
  `${location.key}\0manifest`,
31869
- () => log16.warn(
31915
+ () => log17.warn(
31870
31916
  `antigravity-auth could not remove ${RUNTIME_LAYOUT_MANIFEST_FILE} from its state folder; it tries again at the next start`,
31871
31917
  { stateDir: location.stateHomeDir, errorClass: errorClass(error) }
31872
31918
  )
@@ -31886,16 +31932,16 @@ async function removeOldVaultFolder(files, layoutLock, steps) {
31886
31932
  } catch {
31887
31933
  }
31888
31934
  }
31889
- async function removeOldSignatureCache(location, path5, layoutLock, steps, log16) {
31935
+ async function removeOldSignatureCache(location, path5, layoutLock, steps, log17) {
31890
31936
  try {
31891
31937
  if (!await exists2(path5)) return;
31892
31938
  await beforeRemove(path5, layoutLock, steps);
31893
- await unlink9(path5);
31939
+ await unlink10(path5);
31894
31940
  } catch (error) {
31895
31941
  if (error?.code === "ENOENT") return;
31896
31942
  logOnce(
31897
31943
  `${location.key}\0signature-cache`,
31898
- () => log16.warn(
31944
+ () => log17.warn(
31899
31945
  "antigravity-auth could not remove its old signature cache from OpenCode's config folder; it is no longer used and can be deleted",
31900
31946
  { path: path5, errorClass: errorClass(error) }
31901
31947
  )
@@ -31906,7 +31952,7 @@ async function beforeRemove(path5, layoutLock, steps) {
31906
31952
  await steps?.beforeRemove?.(path5);
31907
31953
  await layoutLock.assertOwned();
31908
31954
  }
31909
- async function takeDataLocks(files, log16) {
31955
+ async function takeDataLocks(files, log17) {
31910
31956
  const locks = [];
31911
31957
  try {
31912
31958
  if (await exists2(files.vault.old))
@@ -31916,7 +31962,7 @@ async function takeDataLocks(files, log16) {
31916
31962
  lock.name,
31917
31963
  join14(files.vault.old, lock.file),
31918
31964
  lock.waitMs,
31919
- log16
31965
+ log17
31920
31966
  )
31921
31967
  );
31922
31968
  return locks;
@@ -31980,6 +32026,7 @@ async function isVaultShapedKeptState(files) {
31980
32026
  return vaultShape && proposedName === OPENCODE_VAULT_ENROLLMENT_NAME;
31981
32027
  }
31982
32028
  async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
32029
+ if (process.env.OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR) return;
31983
32030
  const location = runtimeLayoutLocation();
31984
32031
  const files = layoutFiles(location, accountFile);
31985
32032
  if (resolve15(vaultDir) !== resolve15(files.vault.next)) return;
@@ -31992,7 +32039,7 @@ async function removeMovedVaultStateLeftover(vaultDir, accountFile) {
31992
32039
  if (!marker?.oldDir || marker.oldDir !== location.key) return;
31993
32040
  const leftover = vaultStateFile(files).old;
31994
32041
  if (!await isVaultShapedKeptState(files)) return;
31995
- await unlink9(leftover).catch((error) => {
32042
+ await unlink10(leftover).catch((error) => {
31996
32043
  if (error.code !== "ENOENT") throw error;
31997
32044
  });
31998
32045
  await rmdir2(files.vault.old).catch(() => {
@@ -32038,7 +32085,7 @@ async function physicalAliases(location, files) {
32038
32085
  async function samePhysical(a, b) {
32039
32086
  const id = async (path5) => {
32040
32087
  try {
32041
- const info = await stat9(path5, { bigint: true });
32088
+ const info = await stat10(path5, { bigint: true });
32042
32089
  return info.ino === 0n ? void 0 : `${info.dev}:${info.ino}`;
32043
32090
  } catch (error) {
32044
32091
  const code2 = error.code;
@@ -32128,7 +32175,7 @@ async function unlinkIfIdentical(file, stateDir, guard) {
32128
32175
  if (!same) throw credentialConflict(stateDir, file);
32129
32176
  await guard();
32130
32177
  try {
32131
- await unlink9(file.old);
32178
+ await unlink10(file.old);
32132
32179
  return true;
32133
32180
  } catch (error) {
32134
32181
  if (error.code === "ENOENT") return true;
@@ -32241,7 +32288,7 @@ async function writeManifest(stateDir, paths) {
32241
32288
  );
32242
32289
  }
32243
32290
  async function removeManifest(stateDir) {
32244
- await unlink9(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32291
+ await unlink10(join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)).catch(
32245
32292
  (error) => {
32246
32293
  if (error.code !== "ENOENT") throw error;
32247
32294
  }
@@ -32265,7 +32312,7 @@ async function ensureOwnerOnlyDir(path5) {
32265
32312
  await mkdir13(path5, { recursive: true, mode: 448 });
32266
32313
  await chmod5(path5, 448);
32267
32314
  }
32268
- async function takeLock(name, path5, waitMs, log16) {
32315
+ async function takeLock(name, path5, waitMs, log17) {
32269
32316
  const fs5 = await loadCommonAuthFs();
32270
32317
  const started = performance.now();
32271
32318
  let announced = false;
@@ -32290,7 +32337,7 @@ async function takeLock(name, path5, waitMs, log16) {
32290
32337
  );
32291
32338
  if (!announced && waited >= LOCK_WAIT_NOTICE_MS) {
32292
32339
  announced = true;
32293
- log16.info(
32340
+ log17.info(
32294
32341
  `antigravity-auth is waiting up to ${Math.round(waitMs / 1e3)} s for the ${name} lock at ${path5}.${lockHolderText(name)}`,
32295
32342
  { lock: name, path: path5 }
32296
32343
  );
@@ -32303,7 +32350,7 @@ function lockHolderText(name) {
32303
32350
  }
32304
32351
  async function exists2(path5) {
32305
32352
  try {
32306
- await stat9(path5);
32353
+ await stat10(path5);
32307
32354
  return true;
32308
32355
  } catch (error) {
32309
32356
  const code2 = error.code;
@@ -32438,7 +32485,7 @@ async function ensureGitignore(configDir) {
32438
32485
  `,
32439
32486
  "utf-8"
32440
32487
  );
32441
- log5.info("Created .gitignore in config directory");
32488
+ log6.info("Created .gitignore in config directory");
32442
32489
  } else {
32443
32490
  const suffix = content.endsWith("\n") ? "" : "\n";
32444
32491
  await fs.appendFile(
@@ -32447,12 +32494,12 @@ async function ensureGitignore(configDir) {
32447
32494
  `,
32448
32495
  "utf-8"
32449
32496
  );
32450
- log5.info("Updated .gitignore with missing entries", {
32497
+ log6.info("Updated .gitignore with missing entries", {
32451
32498
  added: missingEntries
32452
32499
  });
32453
32500
  }
32454
32501
  } catch (error) {
32455
- log5.warn("Failed to update .gitignore with account storage entries", {
32502
+ log6.warn("Failed to update .gitignore with account storage entries", {
32456
32503
  error: String(error)
32457
32504
  });
32458
32505
  }
@@ -32487,21 +32534,21 @@ function migrateLegacyWindowsConfig() {
32487
32534
  mkdirSync(newConfigDir, { recursive: true });
32488
32535
  try {
32489
32536
  renameSync3(legacyPath, newPath);
32490
- log5.info("Migrated Windows config via rename", {
32537
+ log6.info("Migrated Windows config via rename", {
32491
32538
  from: legacyPath,
32492
32539
  to: newPath
32493
32540
  });
32494
32541
  } catch {
32495
32542
  copyFileSync(legacyPath, newPath);
32496
32543
  unlinkSync(legacyPath);
32497
- log5.info("Migrated Windows config via copy+delete", {
32544
+ log6.info("Migrated Windows config via copy+delete", {
32498
32545
  from: legacyPath,
32499
32546
  to: newPath
32500
32547
  });
32501
32548
  }
32502
32549
  return true;
32503
32550
  } catch (error) {
32504
- log5.warn("Failed to migrate legacy Windows config, will use legacy path", {
32551
+ log6.warn("Failed to migrate legacy Windows config, will use legacy path", {
32505
32552
  legacyPath,
32506
32553
  newPath,
32507
32554
  error: String(error)
@@ -32534,7 +32581,7 @@ function getStoragePathWithMigration() {
32534
32581
  );
32535
32582
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
32536
32583
  if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
32537
- log5.info("Using legacy Windows config path (migration failed)", {
32584
+ log6.info("Using legacy Windows config path (migration failed)", {
32538
32585
  legacyPath,
32539
32586
  newPath
32540
32587
  });
@@ -32702,18 +32749,18 @@ async function clearAccounts() {
32702
32749
  } catch (error) {
32703
32750
  const code2 = error.code;
32704
32751
  if (code2 !== "ENOENT") {
32705
- log5.error("Failed to clear account storage", { error: String(error) });
32752
+ log6.error("Failed to clear account storage", { error: String(error) });
32706
32753
  }
32707
32754
  }
32708
32755
  }
32709
- var log5, mutateAccountStorage2, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
32756
+ var log6, mutateAccountStorage2, GITIGNORE_ENTRIES, LegacyAccountPoolRetiredError, MIGRATE_COMMAND, UNMIGRATED_ACCOUNT_MESSAGE, ROLLBACK_COMMAND;
32710
32757
  var init_storage = __esm({
32711
32758
  "src/plugin/storage.ts"() {
32712
32759
  "use strict";
32713
32760
  init_dist();
32714
32761
  init_runtime_paths();
32715
32762
  init_logger4();
32716
- log5 = createLogger4("storage");
32763
+ log6 = createLogger4("storage");
32717
32764
  mutateAccountStorage2 = async (path5, mutate) => {
32718
32765
  await assertLegacyPoolInUse(path5);
32719
32766
  return mutateAccountStorage(path5, mutate);
@@ -33657,15 +33704,15 @@ function initLogger3(client) {
33657
33704
  }
33658
33705
  function createLogger4(module) {
33659
33706
  let channel3;
33660
- const log16 = (level, message, extra) => {
33707
+ const log17 = (level, message, extra) => {
33661
33708
  channel3 ??= getLegacyLogger().createLogger(module);
33662
33709
  channel3[level](message, extra);
33663
33710
  };
33664
33711
  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)
33712
+ debug: (message, extra) => log17("debug", message, extra),
33713
+ info: (message, extra) => log17("info", message, extra),
33714
+ warn: (message, extra) => log17("warn", message, extra),
33715
+ error: (message, extra) => log17("error", message, extra)
33669
33716
  };
33670
33717
  }
33671
33718
  var ENV_CONSOLE_LOG2, LOG_LEVEL_FROM_OPERATOR, legacyClient, legacyLogger;
@@ -33689,6 +33736,102 @@ var init_logger4 = __esm({
33689
33736
  }
33690
33737
  });
33691
33738
 
33739
+ // src/vault-folder.ts
33740
+ var vault_folder_exports = {};
33741
+ __export(vault_folder_exports, {
33742
+ __resetVaultFoldersForTest: () => __resetVaultFoldersForTest,
33743
+ currentVaultFolder: () => currentVaultFolder,
33744
+ prepareVaultFolder: () => prepareVaultFolder
33745
+ });
33746
+ import { isAbsolute as isAbsolute3 } from "node:path";
33747
+ function vaultOverride(accountFile) {
33748
+ const kept = refusals.get(overrideRefusalKey);
33749
+ if (kept) return { accountFile, vaultDir: kept.stateDir, refusal: kept };
33750
+ const vaultDir = process.env[OVERRIDE];
33751
+ if (!vaultDir) return void 0;
33752
+ if (isAbsolute3(vaultDir)) return { accountFile, vaultDir };
33753
+ const refusal3 = new RuntimeLayoutRefusal(
33754
+ vaultDir,
33755
+ "relative-vault-dir",
33756
+ `antigravity-auth cannot start: ${OVERRIDE} must be an absolute path. Correct it and restart OpenCode.`
33757
+ );
33758
+ refusals.set(overrideRefusalKey, refusal3);
33759
+ return { accountFile, vaultDir, refusal: refusal3 };
33760
+ }
33761
+ function locationKey() {
33762
+ const location = runtimeLayoutLocation();
33763
+ return `${location.stateHomeDir}\0${location.key}`;
33764
+ }
33765
+ function __resetVaultFoldersForTest() {
33766
+ refusals.clear();
33767
+ }
33768
+ async function prepareVaultFolder(options) {
33769
+ const { accountFile } = options;
33770
+ const override = vaultOverride(accountFile);
33771
+ if (override?.refusal) return override;
33772
+ const key = locationKey();
33773
+ const kept = refusals.get(key);
33774
+ if (kept)
33775
+ return override ? { ...override, refusal: kept } : refused(accountFile, kept);
33776
+ const log17 = options.log ?? createLogger4("runtime-layout");
33777
+ const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
33778
+ try {
33779
+ if (override) {
33780
+ await ensurePrivateDirectory2(override.vaultDir);
33781
+ } else
33782
+ await prepareRuntimeLayout({
33783
+ version,
33784
+ accountFile,
33785
+ log: log17,
33786
+ ...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
33787
+ });
33788
+ if (options.accountStore !== false)
33789
+ await prepareAccountStore({ version, log: log17 });
33790
+ } catch (error) {
33791
+ const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
33792
+ override?.vaultDir ?? runtimeLayoutLocation().stateHomeDir,
33793
+ error instanceof Error ? error.name : typeof error
33794
+ );
33795
+ if (!refusals.has(key)) {
33796
+ refusals.set(key, refusal3);
33797
+ log17.warn(refusal3.message, {
33798
+ stateDir: refusal3.stateDir,
33799
+ errorClass: refusal3.errorClass
33800
+ });
33801
+ }
33802
+ return override ? { ...override, refusal: refusals.get(key) ?? refusal3 } : refused(accountFile, refusals.get(key) ?? refusal3);
33803
+ }
33804
+ return override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
33805
+ }
33806
+ function currentVaultFolder(accountFile) {
33807
+ const override = vaultOverride(accountFile);
33808
+ if (override?.refusal) return override;
33809
+ const kept = refusals.get(locationKey());
33810
+ return kept ? override ? { ...override, refusal: kept } : refused(accountFile, kept) : override ?? { accountFile, vaultDir: getVaultDir(accountFile) };
33811
+ }
33812
+ function refused(accountFile, refusal3) {
33813
+ return { accountFile, vaultDir: getVaultDir(accountFile), refusal: refusal3 };
33814
+ }
33815
+ var refusalsKey, globalState3, refusals, OVERRIDE, overrideRefusalKey;
33816
+ var init_vault_folder = __esm({
33817
+ "src/vault-folder.ts"() {
33818
+ "use strict";
33819
+ init_private_files2();
33820
+ init_logger4();
33821
+ init_process_heartbeat();
33822
+ init_runtime_layout();
33823
+ init_runtime_paths();
33824
+ refusalsKey = /* @__PURE__ */ Symbol.for(
33825
+ "@cortexkit/antigravity-auth/vault-folder-refusals"
33826
+ );
33827
+ globalState3 = globalThis;
33828
+ refusals = globalState3[refusalsKey] ?? /* @__PURE__ */ new Map();
33829
+ globalState3[refusalsKey] = refusals;
33830
+ OVERRIDE = "OPENCODE_ANTIGRAVITY_AUTH_VAULT_DIR";
33831
+ overrideRefusalKey = "invalid-vault-dir-override";
33832
+ }
33833
+ });
33834
+
33692
33835
  // src/ga/server/index.ts
33693
33836
  init_dist();
33694
33837
  import { randomUUID as randomUUID17 } from "node:crypto";
@@ -33808,63 +33951,9 @@ var MAX_RETRY_HOLD_MS = 20 * 60 * 1e3;
33808
33951
 
33809
33952
  // src/plugin/ga-location-services.ts
33810
33953
  init_dist();
33954
+ init_vault_folder();
33811
33955
  import { randomBytes as randomBytes5 } from "node:crypto";
33812
33956
 
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
33957
  // src/plugin/account-access.ts
33869
33958
  init_dist();
33870
33959
 
@@ -34035,7 +34124,7 @@ init_logger4();
34035
34124
  init_dist();
34036
34125
 
34037
34126
  // src/plugin/token.ts
34038
- var log6 = createLogger4("token");
34127
+ var log7 = createLogger4("token");
34039
34128
  function parseOAuthErrorPayload(text2) {
34040
34129
  if (!text2) {
34041
34130
  return {};
@@ -34118,13 +34207,13 @@ async function exchangeRefreshToken(refreshToken, now) {
34118
34207
  const details = [code2, description ?? errorText3].filter(Boolean).join(": ");
34119
34208
  const baseMessage = `Antigravity token refresh failed (${response.status} ${response.statusText})`;
34120
34209
  const message = details ? `${baseMessage} - ${details}` : baseMessage;
34121
- log6.warn("Token refresh failed", {
34210
+ log7.warn("Token refresh failed", {
34122
34211
  status: response.status,
34123
34212
  code: code2,
34124
34213
  details
34125
34214
  });
34126
34215
  if (code2 === "invalid_grant") {
34127
- log6.warn(
34216
+ log7.warn(
34128
34217
  "Google revoked the stored refresh token - reauthentication required"
34129
34218
  );
34130
34219
  invalidateProjectContextCache(refreshToken);
@@ -34180,7 +34269,7 @@ async function refreshAccessToken(auth, _client, _providerId) {
34180
34269
  if (error instanceof AntigravityTokenRefreshError) {
34181
34270
  throw error;
34182
34271
  }
34183
- log6.error("Unexpected token refresh error", { error: String(error) });
34272
+ log7.error("Unexpected token refresh error", { error: String(error) });
34184
34273
  return void 0;
34185
34274
  }
34186
34275
  }
@@ -35452,7 +35541,7 @@ function getUserConfigPath() {
35452
35541
  function getProjectConfigPath(directory) {
35453
35542
  return join18(directory, ".opencode", "antigravity.json");
35454
35543
  }
35455
- function loadConfigFile(path5, log16) {
35544
+ function loadConfigFile(path5, log17) {
35456
35545
  try {
35457
35546
  if (!existsSync5(path5)) {
35458
35547
  return null;
@@ -35461,7 +35550,7 @@ function loadConfigFile(path5, log16) {
35461
35550
  const rawConfig = JSON.parse(content);
35462
35551
  const result = AntigravityConfigSchema.partial().safeParse(rawConfig);
35463
35552
  if (!result.success) {
35464
- log16.warn("Config validation error", {
35553
+ log17.warn("Config validation error", {
35465
35554
  path: path5,
35466
35555
  issues: result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join(", ")
35467
35556
  });
@@ -35470,9 +35559,9 @@ function loadConfigFile(path5, log16) {
35470
35559
  return result.data;
35471
35560
  } catch (error) {
35472
35561
  if (error instanceof SyntaxError) {
35473
- log16.warn("Invalid JSON in config file", { path: path5, error: error.message });
35562
+ log17.warn("Invalid JSON in config file", { path: path5, error: error.message });
35474
35563
  } else {
35475
- log16.warn("Failed to load config file", { path: path5, error: String(error) });
35564
+ log17.warn("Failed to load config file", { path: path5, error: String(error) });
35476
35565
  }
35477
35566
  return null;
35478
35567
  }
@@ -35491,15 +35580,15 @@ function mergeConfigs(base, override) {
35491
35580
  function loadConfig(directory) {
35492
35581
  return loadConfigWithLogger(directory, legacyLog);
35493
35582
  }
35494
- function loadConfigWithLogger(directory, log16) {
35583
+ function loadConfigWithLogger(directory, log17) {
35495
35584
  let config = structuredClone(DEFAULT_CONFIG);
35496
35585
  const userConfigPath = getUserConfigPath();
35497
- const userConfig = loadConfigFile(userConfigPath, log16);
35586
+ const userConfig = loadConfigFile(userConfigPath, log17);
35498
35587
  if (userConfig) {
35499
35588
  config = mergeConfigs(config, userConfig);
35500
35589
  }
35501
35590
  const projectConfigPath = getProjectConfigPath(directory);
35502
- const projectConfig = loadConfigFile(projectConfigPath, log16);
35591
+ const projectConfig = loadConfigFile(projectConfigPath, log17);
35503
35592
  if (projectConfig) {
35504
35593
  config = mergeConfigs(config, projectConfig);
35505
35594
  }
@@ -36448,7 +36537,7 @@ init_dist();
36448
36537
  init_debug();
36449
36538
  init_logger4();
36450
36539
  init_dist();
36451
- var log7 = createLogger4("quota");
36540
+ var log8 = createLogger4("quota");
36452
36541
  function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID, options = {}) {
36453
36542
  const fetchPoolFileQuota = makeFetchAccountQuota(
36454
36543
  client,
@@ -36639,7 +36728,7 @@ async function pushSidebarQuotaSnapshot(getAccounts, backoffUntil = 0, getActive
36639
36728
  );
36640
36729
  } catch (error) {
36641
36730
  ;
36642
- (options.logger ?? log7).debug("sidebar-quota-write-failed", {
36731
+ (options.logger ?? log8).debug("sidebar-quota-write-failed", {
36643
36732
  error: String(error)
36644
36733
  });
36645
36734
  }
@@ -37005,7 +37094,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37005
37094
  let rotatedRefresh;
37006
37095
  if (purpose === "advisory") {
37007
37096
  if (accessTokenExpired(auth)) {
37008
- log7.debug("advisory-quota-skipped-refresh-needed");
37097
+ log8.debug("advisory-quota-skipped-refresh-needed");
37009
37098
  return {
37010
37099
  index,
37011
37100
  email: account.email,
@@ -37017,7 +37106,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37017
37106
  const managedProjectId = parts.managedProjectId ?? account.managedProjectId;
37018
37107
  const projectId = managedProjectId ?? parts.projectId ?? account.projectId;
37019
37108
  if (!projectId) {
37020
- log7.debug("advisory-quota-skipped-project-needed");
37109
+ log8.debug("advisory-quota-skipped-project-needed");
37021
37110
  return {
37022
37111
  index,
37023
37112
  email: account.email,
@@ -37039,7 +37128,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37039
37128
  { timeoutMs: extra.timeoutMs }
37040
37129
  );
37041
37130
  },
37042
- logger: log7
37131
+ logger: log8
37043
37132
  }),
37044
37133
  signal
37045
37134
  );
@@ -37096,7 +37185,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
37096
37185
  managedProjectId,
37097
37186
  projectId: projectContext.effectiveProjectId,
37098
37187
  fetchVia,
37099
- logger: log7
37188
+ logger: log8
37100
37189
  });
37101
37190
  quotaResult = payloads.quota;
37102
37191
  if (quotaResult.error) throw new Error(quotaResult.error);
@@ -39835,8 +39924,8 @@ function createSessionRecoveryHook(ctx, config) {
39835
39924
  if (!sessionID) return false;
39836
39925
  let assistantMsgID = info.id;
39837
39926
  let msgs;
39838
- const log16 = createLogger4("session-recovery");
39839
- log16.debug("Recovery attempt started", {
39927
+ const log17 = createLogger4("session-recovery");
39928
+ log17.debug("Recovery attempt started", {
39840
39929
  errorType,
39841
39930
  sessionID,
39842
39931
  providedMsgID: assistantMsgID ?? "none"
@@ -39856,7 +39945,7 @@ function createSessionRecoveryHook(ctx, config) {
39856
39945
  const m = msgs[i];
39857
39946
  if (m && m.info?.role === "assistant" && m.info?.id) {
39858
39947
  assistantMsgID = m.info.id;
39859
- log16.debug("Found assistant message ID from session messages", {
39948
+ log17.debug("Found assistant message ID from session messages", {
39860
39949
  msgID: assistantMsgID,
39861
39950
  msgIndex: i
39862
39951
  });
@@ -39865,7 +39954,7 @@ function createSessionRecoveryHook(ctx, config) {
39865
39954
  }
39866
39955
  }
39867
39956
  if (!assistantMsgID) {
39868
- log16.debug("No assistant message ID found, cannot recover");
39957
+ log17.debug("No assistant message ID found, cannot recover");
39869
39958
  return false;
39870
39959
  }
39871
39960
  if (processingErrors.has(assistantMsgID)) return false;
@@ -39909,7 +39998,7 @@ function createSessionRecoveryHook(ctx, config) {
39909
39998
  }
39910
39999
  return success;
39911
40000
  } catch (err) {
39912
- log16.error("Recovery failed", { error: String(err) });
40001
+ log17.error("Recovery failed", { error: String(err) });
39913
40002
  return false;
39914
40003
  } finally {
39915
40004
  processingErrors.delete(assistantMsgID);
@@ -39929,7 +40018,7 @@ function createSessionRecoveryHook(ctx, config) {
39929
40018
  // src/plugin/request-helpers.ts
39930
40019
  init_dist();
39931
40020
  init_logger4();
39932
- var log8 = createLogger4("request-helpers");
40021
+ var log9 = createLogger4("request-helpers");
39933
40022
  var ANTIGRAVITY_PREVIEW_LINK = "https://goo.gle/enable-preview-features";
39934
40023
  function appendDescriptionHint(schema, hint) {
39935
40024
  if (!schema || typeof schema !== "object") {
@@ -40354,7 +40443,7 @@ function filterContentArray(contentArray, sessionId, getCachedSignatureFn, isCla
40354
40443
  }
40355
40444
  const existingSignature = item.signature || item.thoughtSignature;
40356
40445
  const signatureInfo = existingSignature ? `foreign signature (${String(existingSignature).length} chars)` : "no signature";
40357
- log8.debug(
40446
+ log9.debug(
40358
40447
  `Injecting plain text sentinel for last-message thinking block with ${signatureInfo}`
40359
40448
  );
40360
40449
  const sentinel2 = { text: "." };
@@ -40866,7 +40955,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
40866
40955
  if (lastBracket > 0) {
40867
40956
  const cleaned = stripped.slice(0, lastBracket + 1);
40868
40957
  const parsed = JSON.parse(cleaned);
40869
- log8.debug("Auto-corrected malformed JSON array", {
40958
+ log9.debug("Auto-corrected malformed JSON array", {
40870
40959
  truncatedChars: stripped.length - cleaned.length
40871
40960
  });
40872
40961
  return recursivelyParseJsonStrings(parsed);
@@ -40880,7 +40969,7 @@ function recursivelyParseJsonStrings(obj, skipParseKeys = SKIP_PARSE_KEYS, curre
40880
40969
  if (lastBrace > 0) {
40881
40970
  const cleaned = stripped.slice(0, lastBrace + 1);
40882
40971
  const parsed = JSON.parse(cleaned);
40883
- log8.debug("Auto-corrected malformed JSON object", {
40972
+ log9.debug("Auto-corrected malformed JSON object", {
40884
40973
  truncatedChars: stripped.length - cleaned.length
40885
40974
  });
40886
40975
  return recursivelyParseJsonStrings(parsed);
@@ -40980,7 +41069,7 @@ function fixToolResponseGrouping(contents) {
40980
41069
  if (orphanResp.functionResponse.name === "unknown_function" && expectedName) {
40981
41070
  orphanResp.functionResponse.name = expectedName;
40982
41071
  }
40983
- log8.debug("Auto-repaired tool ID mismatch", {
41072
+ log9.debug("Auto-repaired tool ID mismatch", {
40984
41073
  mappedFrom: matchedId,
40985
41074
  mappedTo: expectedId,
40986
41075
  functionName: expectedName
@@ -41000,7 +41089,7 @@ function fixToolResponseGrouping(contents) {
41000
41089
  id: expectedId
41001
41090
  }
41002
41091
  };
41003
- log8.debug("Created placeholder response for missing tool", {
41092
+ log9.debug("Created placeholder response for missing tool", {
41004
41093
  id: expectedId,
41005
41094
  name: expectedName
41006
41095
  });
@@ -41318,7 +41407,7 @@ function applyToolPairingFixes(payload, isClaude) {
41318
41407
  );
41319
41408
  payload.contents = fixToolResponseGrouping(contentsWithMatchedIds);
41320
41409
  contentsFixed = true;
41321
- log8.debug("Applied tool pairing fixes to contents[]", {
41410
+ log9.debug("Applied tool pairing fixes to contents[]", {
41322
41411
  originalLength: payload.contents.length
41323
41412
  });
41324
41413
  }
@@ -41327,7 +41416,7 @@ function applyToolPairingFixes(payload, isClaude) {
41327
41416
  payload.messages
41328
41417
  );
41329
41418
  messagesFixed = true;
41330
- log8.debug("Applied tool pairing fixes to messages[]", {
41419
+ log9.debug("Applied tool pairing fixes to messages[]", {
41331
41420
  originalLength: payload.messages.length
41332
41421
  });
41333
41422
  }
@@ -41566,7 +41655,7 @@ init_dist();
41566
41655
  init_dist();
41567
41656
 
41568
41657
  // src/plugin/request.ts
41569
- var log9 = createLogger4("request");
41658
+ var log10 = createLogger4("request");
41570
41659
  var PLUGIN_SESSION_ID = `-${crypto2.randomUUID()}`;
41571
41660
  var DEFAULT_AGY_REQUEST_SESSION = createAgyRequestSessionContext("");
41572
41661
  var sessionDisplayedThinkingHashes = /* @__PURE__ */ new Set();
@@ -42365,7 +42454,7 @@ var openCode1WireLocation = {
42365
42454
  logAntigravityDebugResponse: (context, response, meta) => logAntigravityDebugResponse(context, response, meta),
42366
42455
  logCacheStats: (model, cacheRead, cacheWrite, totalInput) => logCacheStats(model, cacheRead, cacheWrite, totalInput)
42367
42456
  },
42368
- logger: log9,
42457
+ logger: log10,
42369
42458
  sessionFingerprint: () => getSessionFingerprint(),
42370
42459
  displayedThinkingHashes: sessionDisplayedThinkingHashes,
42371
42460
  cacheStats: { last: null }
@@ -43686,7 +43775,7 @@ var AgySessionRegistry = class {
43686
43775
  };
43687
43776
 
43688
43777
  // src/plugin/shared/advisory-repository.ts
43689
- function createAdvisoryRepositoryOwner(repository, log16) {
43778
+ function createAdvisoryRepositoryOwner(repository, log17) {
43690
43779
  const methods = /* @__PURE__ */ new Map();
43691
43780
  const advisoryMethods = /* @__PURE__ */ new Set([
43692
43781
  "updateMetadata",
@@ -43732,7 +43821,7 @@ function createAdvisoryRepositoryOwner(repository, log16) {
43732
43821
  (reason) => !failures.has(reason)
43733
43822
  );
43734
43823
  for (const reason of absorbed) failures.delete(reason);
43735
- log16.debug("post-response-local-write-refused", {
43824
+ log17.debug("post-response-local-write-refused", {
43736
43825
  count: absorbed.length
43737
43826
  });
43738
43827
  if (remaining.length > 0)
@@ -44507,7 +44596,6 @@ function publishResponse(dispatch) {
44507
44596
  }
44508
44597
 
44509
44598
  // src/plugin/shared/vault-routing.ts
44510
- var ROUTING_GROUP_SCOPED_EXHAUSTION = false;
44511
44599
  function hasVaultRoutingAccessor() {
44512
44600
  try {
44513
44601
  return typeof Reflect.get(globalThis, /* @__PURE__ */ Symbol.for("cortexkit.routing")) === "function";
@@ -44525,7 +44613,7 @@ function routingExhaustionFields(scope) {
44525
44613
  window: scope.limitWindow === "five_hour" ? "5h" : "7d"
44526
44614
  };
44527
44615
  }
44528
- function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCOPED_EXHAUSTION, report = reportRouting) {
44616
+ function reportVaultExhaustion(input2, report = reportRouting) {
44529
44617
  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
44618
  return;
44531
44619
  for (const window of input2.quota?.windows ?? []) {
@@ -44533,13 +44621,12 @@ function reportVaultExhaustion(input2, groupScopedExhaustion = ROUTING_GROUP_SCO
44533
44621
  const scope = routingQuotaScope(input2.group, window.window);
44534
44622
  const resetsAt = Date.parse(window.resetTime);
44535
44623
  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
- });
44624
+ report({
44625
+ ...input2.identity,
44626
+ outcome: "exhausted",
44627
+ ...routingExhaustionFields(scope),
44628
+ resetsAt
44629
+ });
44543
44630
  }
44544
44631
  }
44545
44632
  var RATE_LIMIT_HEADERS = [
@@ -44812,7 +44899,7 @@ function sleep4(ms, signal) {
44812
44899
  signal?.addEventListener("abort", onAbort, { once: true });
44813
44900
  });
44814
44901
  }
44815
- function createLocalQuotaRefresh(accountManager, quotaManager, log16) {
44902
+ function createLocalQuotaRefresh(accountManager, quotaManager, log17) {
44816
44903
  return async function refreshQuotaAfterSuccess(account, intervalMinutes, signal) {
44817
44904
  if (intervalMinutes <= 0) return;
44818
44905
  const accountIndex = accountManager.getAccounts().indexOf(account);
@@ -44843,7 +44930,7 @@ function createLocalQuotaRefresh(accountManager, quotaManager, log16) {
44843
44930
  accountManager.requestSaveToDisk();
44844
44931
  }
44845
44932
  } catch (err) {
44846
- log16.debug(
44933
+ log17.debug(
44847
44934
  `quota-refresh-failed ${singleAccount ? quotaManager.hashedLogLabel("account", singleAccount) : `idx-${accountIndex}`}`,
44848
44935
  { error: String(err) }
44849
44936
  );
@@ -44861,7 +44948,7 @@ function createRequestExecutor(deps) {
44861
44948
  wire,
44862
44949
  debug,
44863
44950
  dump,
44864
- logger: log16,
44951
+ logger: log17,
44865
44952
  trackers,
44866
44953
  classifyAccessError,
44867
44954
  notify,
@@ -44880,7 +44967,7 @@ function createRequestExecutor(deps) {
44880
44967
  const reportVault401 = (admission, status) => {
44881
44968
  if (!admission || status !== 401) return;
44882
44969
  void Promise.resolve().then(() => admission.report401(status)).catch((error) => {
44883
- log16.debug("send-admission-401-report-failed", { error: String(error) });
44970
+ log17.debug("send-admission-401-report-failed", { error: String(error) });
44884
44971
  });
44885
44972
  };
44886
44973
  const reportRouting2 = (sessionId, entry) => {
@@ -44888,7 +44975,7 @@ function createRequestExecutor(deps) {
44888
44975
  try {
44889
44976
  onRouting(sessionId, entry);
44890
44977
  } catch (error) {
44891
- log16.debug("routing-report-failed", { sessionId, error: String(error) });
44978
+ log17.debug("routing-report-failed", { sessionId, error: String(error) });
44892
44979
  }
44893
44980
  };
44894
44981
  async function execute(input2, init, options, selectedCredentials, selectedProjectIds, deadline, waitPolicy) {
@@ -45019,7 +45106,7 @@ function createRequestExecutor(deps) {
45019
45106
  const quietMode = config.quiet_mode;
45020
45107
  const toastScope = config.toast_scope;
45021
45108
  const showToast = async (message, variant2) => {
45022
- log16.debug("toast", {
45109
+ log17.debug("toast", {
45023
45110
  message,
45024
45111
  variant: variant2,
45025
45112
  isChildSession: isChildRequest,
@@ -45028,7 +45115,7 @@ function createRequestExecutor(deps) {
45028
45115
  if (quietMode) return;
45029
45116
  if (abortSignal?.aborted) return;
45030
45117
  if (toastScope === "root_only" && isChildRequest) {
45031
- log16.debug("toast-suppressed-child-session", {
45118
+ log17.debug("toast-suppressed-child-session", {
45032
45119
  message,
45033
45120
  variant: variant2,
45034
45121
  parentID: requestSessionIdentity.parentSessionId
@@ -45101,7 +45188,7 @@ function createRequestExecutor(deps) {
45101
45188
  });
45102
45189
  } catch (error) {
45103
45190
  if (error instanceof AntigravityKillswitchError) {
45104
- log16.warn("killswitch-all-excluded", {
45191
+ log17.warn("killswitch-all-excluded", {
45105
45192
  family,
45106
45193
  model,
45107
45194
  threshold: error.thresholdPercent,
@@ -45126,7 +45213,7 @@ function createRequestExecutor(deps) {
45126
45213
  pushDebug(
45127
45214
  `model-unavailable: all ${candidates.length} eligible account(s) skipped`
45128
45215
  );
45129
- log16.warn("model-unavailable-all-accounts", {
45216
+ log17.warn("model-unavailable-all-accounts", {
45130
45217
  family,
45131
45218
  model,
45132
45219
  accounts: candidates.length
@@ -45365,7 +45452,7 @@ function createRequestExecutor(deps) {
45365
45452
  await deadline.wait(() => credentials.saveToDisk());
45366
45453
  } catch (error) {
45367
45454
  checkAborted();
45368
- log16.error("Failed to persist project context", {
45455
+ log17.error("Failed to persist project context", {
45369
45456
  error: String(error)
45370
45457
  });
45371
45458
  }
@@ -45422,7 +45509,7 @@ function createRequestExecutor(deps) {
45422
45509
  await deadline.wait(() => credentials.saveToDisk());
45423
45510
  } catch (error) {
45424
45511
  checkAborted();
45425
- log16.error("Failed to persist refreshed auth", {
45512
+ log17.error("Failed to persist refreshed auth", {
45426
45513
  error: String(error)
45427
45514
  });
45428
45515
  }
@@ -45431,14 +45518,14 @@ function createRequestExecutor(deps) {
45431
45518
  if (credentials.isInvalidGrant(error)) {
45432
45519
  const removed = credentials.removeAccount(account);
45433
45520
  if (removed) {
45434
- log16.warn(
45521
+ log17.warn(
45435
45522
  "Removed revoked account from pool - reauthenticate via `opencode auth login`"
45436
45523
  );
45437
45524
  try {
45438
45525
  await deadline.wait(() => credentials.saveToDiskReplace());
45439
45526
  } catch (persistError) {
45440
45527
  checkAborted();
45441
- log16.error("Failed to persist revoked account removal", {
45528
+ log17.error("Failed to persist revoked account removal", {
45442
45529
  error: String(persistError)
45443
45530
  });
45444
45531
  }
@@ -45448,7 +45535,7 @@ function createRequestExecutor(deps) {
45448
45535
  await deadline.wait(() => credentials.clearStoredAuth());
45449
45536
  } catch (storeError) {
45450
45537
  checkAborted();
45451
- log16.error(
45538
+ log17.error(
45452
45539
  "Failed to clear stored Antigravity OAuth credentials",
45453
45540
  {
45454
45541
  error: String(storeError)
@@ -45842,7 +45929,7 @@ function createRequestExecutor(deps) {
45842
45929
  );
45843
45930
  } catch (error) {
45844
45931
  checkAborted();
45845
- log16.debug("send-admission-401-report-failed", {
45932
+ log17.debug("send-admission-401-report-failed", {
45846
45933
  error: String(error)
45847
45934
  });
45848
45935
  }
@@ -46079,7 +46166,7 @@ function createRequestExecutor(deps) {
46079
46166
  debug.logAntigravityDebugResponse(debugContext, response, {
46080
46167
  note
46081
46168
  });
46082
- log16.info("model-unavailable", {
46169
+ log17.info("model-unavailable", {
46083
46170
  accountIndex: account.index,
46084
46171
  family,
46085
46172
  model,
@@ -46534,11 +46621,11 @@ function createRequestExecutor(deps) {
46534
46621
  cancellation.signal,
46535
46622
  deps.preResponseClock
46536
46623
  );
46537
- log16.debug("pre-response-start", { limitMs: PRE_RESPONSE_DEADLINE_MS });
46624
+ log17.debug("pre-response-start", { limitMs: PRE_RESPONSE_DEADLINE_MS });
46538
46625
  const handoff = createAfterHandoff(
46539
46626
  advisoryWork,
46540
46627
  requestedSignal ? [requestedSignal, shutdown.signal] : [shutdown.signal],
46541
- () => log16.debug("post-response-advisory-work-failed")
46628
+ () => log17.debug("post-response-advisory-work-failed")
46542
46629
  );
46543
46630
  const waitPolicy = {};
46544
46631
  const selectedCredentials = /* @__PURE__ */ new Set();
@@ -46556,7 +46643,7 @@ function createRequestExecutor(deps) {
46556
46643
  ).catch((error) => {
46557
46644
  cancellation.signal.throwIfAborted();
46558
46645
  if (error instanceof PreResponseTimeoutError) {
46559
- log16.debug("pre-response-timeout", { reason: error.reason });
46646
+ log17.debug("pre-response-timeout", { reason: error.reason });
46560
46647
  return waitPolicy.refusal?.() ?? preResponseTimeoutResponse();
46561
46648
  }
46562
46649
  throw error;
@@ -47050,7 +47137,7 @@ init_logger4();
47050
47137
 
47051
47138
  // src/plugin/refresh-queue.ts
47052
47139
  init_logger4();
47053
- var log10 = createLogger4("refresh-queue");
47140
+ var log11 = createLogger4("refresh-queue");
47054
47141
  var DEFAULT_PROACTIVE_REFRESH_CONFIG = {
47055
47142
  enabled: true,
47056
47143
  bufferSeconds: 1800,
@@ -47090,7 +47177,7 @@ var ProactiveRefreshQueue = class {
47090
47177
  "ProactiveRefreshQueue needs a host client or explicit dependencies"
47091
47178
  );
47092
47179
  }
47093
- this.log = log10;
47180
+ this.log = log11;
47094
47181
  this.refresh = (auth) => refreshAccessToken(auth, client, providerId);
47095
47182
  }
47096
47183
  this.config = {
@@ -47399,7 +47486,7 @@ async function buildLocationRuntime(options, scope) {
47399
47486
  sink: options.logSink,
47400
47487
  sinkEnabled: () => config?.config.debug_tui === true
47401
47488
  });
47402
- const log16 = logger3.createLogger("runtime");
47489
+ const log17 = logger3.createLogger("runtime");
47403
47490
  config = createLocationConfig(options.directory, {
47404
47491
  logger: logger3.createLogger("config")
47405
47492
  });
@@ -47516,7 +47603,7 @@ async function buildLocationRuntime(options, scope) {
47516
47603
  queue2.start();
47517
47604
  });
47518
47605
  accountChange = next.catch((error) => {
47519
- log16.warn("account view replacement failed", {
47606
+ log17.warn("account view replacement failed", {
47520
47607
  error: error instanceof Error ? error.message : String(error)
47521
47608
  });
47522
47609
  });
@@ -49253,6 +49340,7 @@ var createGaLocationServices = (input2) => {
49253
49340
  // src/ga/server/index.ts
49254
49341
  init_storage();
49255
49342
  init_process_heartbeat();
49343
+ init_vault_folder();
49256
49344
 
49257
49345
  // src/ga/proxy-guard.ts
49258
49346
  var DOCUMENTED_LOOPBACK_EXCLUSION = "NO_PROXY=127.0.0.1";
@@ -50626,6 +50714,7 @@ var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
50626
50714
  // src/ga/server/auth.ts
50627
50715
  init_storage();
50628
50716
  init_vault_custody();
50717
+ init_vault_folder();
50629
50718
 
50630
50719
  // src/ga/server/pool-login.ts
50631
50720
  init_dist();
@@ -52156,8 +52245,8 @@ async function select2(terminal, items, options) {
52156
52245
  // src/common-auth-embedded/claustrum/enrollment.js
52157
52246
  import { createHash as createHash18, randomBytes as randomBytes6, randomUUID as randomUUID19 } from "node:crypto";
52158
52247
  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";
52248
+ 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";
52249
+ import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as resolve22 } from "node:path";
52161
52250
  import { ClaustrumCredentialError as ClaustrumCredentialError5, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
52162
52251
 
52163
52252
  // src/common-auth-embedded/fs/file-read-cache.js
@@ -52230,7 +52319,7 @@ init_private_files2();
52230
52319
  // src/common-auth-embedded/fs/refresh-file-lock.js
52231
52320
  init_private_files2();
52232
52321
  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";
52322
+ 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
52323
  import { dirname as dirname21, join as join25 } from "node:path";
52235
52324
 
52236
52325
  // src/common-auth-embedded/fs/with-lock.js
@@ -52484,7 +52573,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52484
52573
  };
52485
52574
  }
52486
52575
  try {
52487
- const current = await stat10(lockPath);
52576
+ const current = await stat11(lockPath);
52488
52577
  const legacyExpiry = Number.isFinite(expiresAt) ? expiresAt : current.mtimeMs + options.ttlMs;
52489
52578
  if (legacyExpiry > now())
52490
52579
  return { status: "live" };
@@ -52551,7 +52640,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52551
52640
  if (!sameMarkerDirectory2(created, current))
52552
52641
  return false;
52553
52642
  try {
52554
- await stat10(evictOwnerPath);
52643
+ await stat11(evictOwnerPath);
52555
52644
  return true;
52556
52645
  } catch (error) {
52557
52646
  if (error.code !== "ENOENT")
@@ -52603,7 +52692,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52603
52692
  async function recoverStaleEvictionMarker() {
52604
52693
  let evictStat;
52605
52694
  try {
52606
- evictStat = await stat10(evictPath);
52695
+ evictStat = await stat11(evictPath);
52607
52696
  } catch (error) {
52608
52697
  if (error.code === "ENOENT")
52609
52698
  return "missing";
@@ -52621,7 +52710,7 @@ async function acquireRefreshFileLockWithClock2(options) {
52621
52710
  if (evictStat.mtimeMs + EVICT_TTL > now()) {
52622
52711
  let hasOwner = true;
52623
52712
  try {
52624
- await stat10(evictOwnerPath);
52713
+ await stat11(evictOwnerPath);
52625
52714
  } catch (error) {
52626
52715
  if (error.code === "ENOENT")
52627
52716
  hasOwner = false;
@@ -53023,9 +53112,9 @@ function getClaustrumEnrollmentPaths2(tokenPath) {
53023
53112
  }
53024
53113
  function hostEnrollmentPaths2(input2) {
53025
53114
  const override = input2.override?.trim();
53026
- if (override && !isAbsolute3(override) && !input2.cwd)
53115
+ if (override && !isAbsolute4(override) && !input2.cwd)
53027
53116
  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`);
53117
+ const tokenPath = override ? isAbsolute4(override) ? override : resolve22(input2.cwd, override) : join26(input2.stateDir, `${input2.host}-enrollment.json`);
53029
53118
  return getClaustrumEnrollmentPaths2(tokenPath);
53030
53119
  }
53031
53120
  function isRecord11(value) {
@@ -53210,7 +53299,7 @@ async function refuseWritableAncestor2(parent, options = {}) {
53210
53299
  }
53211
53300
  let privateGroup;
53212
53301
  for (; ; ) {
53213
- const metadata = await stat11(component).catch(() => void 0);
53302
+ const metadata = await stat12(component).catch(() => void 0);
53214
53303
  if (metadata && (metadata.mode & 18) !== 0 && (metadata.mode & 512) === 0) {
53215
53304
  if (privateGroup === void 0) {
53216
53305
  privateGroup = gid !== void 0 && await isPrivateGroup2(uid, gid, options);
@@ -53239,7 +53328,7 @@ async function ensureClaustrumPrivateDirectory2(directory, options = {}, what =
53239
53328
  return;
53240
53329
  }
53241
53330
  await mkdir15(directory, { recursive: true, mode: 448 });
53242
- const metadata = await stat11(directory);
53331
+ const metadata = await stat12(directory);
53243
53332
  const uid = process.geteuid?.();
53244
53333
  if (uid !== void 0 && metadata.uid !== uid) {
53245
53334
  throw new ClaustrumConsumerError2("unsafe-file", `Claustrum ${what} must be owned by the current user`);
@@ -53275,7 +53364,7 @@ async function writeStateAtomic2(path5, state, ancestorOptions = {}) {
53275
53364
  await descriptor?.close().catch(() => {
53276
53365
  });
53277
53366
  if (created)
53278
- await unlink10(temporary).catch(() => {
53367
+ await unlink11(temporary).catch(() => {
53279
53368
  });
53280
53369
  }
53281
53370
  }
@@ -53502,7 +53591,7 @@ var ClaustrumEnrollmentManager2 = class {
53502
53591
  }
53503
53592
  if (refusal3.code === UNSUPPORTED_ENROLLMENT_CODE2) {
53504
53593
  await lock.assertOwned();
53505
- await unlink10(this.#paths.statePath).catch((cause) => {
53594
+ await unlink11(this.#paths.statePath).catch((cause) => {
53506
53595
  if (cause.code !== "ENOENT")
53507
53596
  throw cause;
53508
53597
  });
@@ -53592,7 +53681,7 @@ async function resetClaustrumEnrollmentState2(paths, proposedName) {
53592
53681
  if (state.phase === "pending")
53593
53682
  return "refused-pending";
53594
53683
  await lock.assertOwned();
53595
- await unlink10(paths.statePath);
53684
+ await unlink11(paths.statePath);
53596
53685
  return "reset";
53597
53686
  } finally {
53598
53687
  await lock.release();
@@ -53828,7 +53917,7 @@ function setupPaths(io = {}) {
53828
53917
  }
53829
53918
 
53830
53919
  // src/common-auth-embedded/setup/detect.js
53831
- function stat12(path5, kind) {
53920
+ function stat13(path5, kind) {
53832
53921
  try {
53833
53922
  return statSync5(path5)[kind]();
53834
53923
  } catch {
@@ -53837,12 +53926,12 @@ function stat12(path5, kind) {
53837
53926
  }
53838
53927
  var defaultSetupFileSystem = {
53839
53928
  exists: existsSync12,
53840
- isFile: (path5) => stat12(path5, "isFile"),
53841
- isDirectory: (path5) => stat12(path5, "isDirectory"),
53929
+ isFile: (path5) => stat13(path5, "isFile"),
53930
+ isDirectory: (path5) => stat13(path5, "isDirectory"),
53842
53931
  isExecutable(path5) {
53843
53932
  try {
53844
53933
  accessSync(path5, constants3.X_OK);
53845
- return stat12(path5, "isFile");
53934
+ return stat13(path5, "isFile");
53846
53935
  } catch {
53847
53936
  return false;
53848
53937
  }
@@ -54548,7 +54637,7 @@ import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2,
54548
54637
 
54549
54638
  // src/common-auth-embedded/setup/config-write.js
54550
54639
  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";
54640
+ import { mkdir as mkdir16, open as open11, rename as rename13, stat as stat14, unlink as unlink12 } from "node:fs/promises";
54552
54641
  import { basename as basename7, dirname as dirname23, join as join28 } from "node:path";
54553
54642
  import { setTimeout as delay2 } from "node:timers/promises";
54554
54643
  async function writeHostConfigAtomic(file, content, options = {}) {
@@ -54558,7 +54647,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
54558
54647
  let mode;
54559
54648
  if (!windows2) {
54560
54649
  try {
54561
- mode = (await stat13(file)).mode & 4095;
54650
+ mode = (await stat14(file)).mode & 4095;
54562
54651
  } catch (error) {
54563
54652
  if (error.code !== "ENOENT")
54564
54653
  throw error;
@@ -54594,7 +54683,7 @@ async function writeHostConfigAtomic(file, content, options = {}) {
54594
54683
  }
54595
54684
  } finally {
54596
54685
  if (created)
54597
- await unlink11(stage).catch(() => {
54686
+ await unlink12(stage).catch(() => {
54598
54687
  });
54599
54688
  }
54600
54689
  }
@@ -55036,6 +55125,7 @@ function createV1VaultActivationMethod(input2) {
55036
55125
  // src/setup.ts
55037
55126
  init_vault_custody();
55038
55127
  init_runtime_paths();
55128
+ init_vault_folder();
55039
55129
  var PI_PLACEHOLDER_KEY = "antigravity-vault-custody";
55040
55130
  async function storePresent(anchor) {
55041
55131
  return await pathPresent(accountStorePointerPath(anchor)) || await pathPresent(anchor);
@@ -55404,6 +55494,7 @@ async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
55404
55494
  }
55405
55495
 
55406
55496
  // src/cli.ts
55497
+ init_vault_folder();
55407
55498
  var HELP = `Usage: antigravity-auth <command> [options]
55408
55499
 
55409
55500
  Commands:
@@ -56214,8 +56305,8 @@ function getLocalDevPath(directory) {
56214
56305
  }
56215
56306
  function findPackageJsonUp(startPath) {
56216
56307
  try {
56217
- const stat15 = fs4.statSync(startPath);
56218
- let dir = stat15.isDirectory() ? startPath : path4.dirname(startPath);
56308
+ const stat16 = fs4.statSync(startPath);
56309
+ let dir = stat16.isDirectory() ? startPath : path4.dirname(startPath);
56219
56310
  for (let i = 0; i < 10; i++) {
56220
56311
  const pkgPath = path4.join(dir, "package.json");
56221
56312
  if (fs4.existsSync(pkgPath)) {
@@ -56525,12 +56616,12 @@ function isTuiConnected(sessionId) {
56525
56616
  // src/rpc/rpc-dir.ts
56526
56617
  import { createHash as createHash19 } from "node:crypto";
56527
56618
  import { homedir as homedir13, tmpdir as tmpdir6 } from "node:os";
56528
- import { isAbsolute as isAbsolute4, join as join34, resolve as resolve25 } from "node:path";
56619
+ import { isAbsolute as isAbsolute5, join as join34, resolve as resolve25 } from "node:path";
56529
56620
  var RPC_DIR_ENV = "ANTIGRAVITY_AUTH_RPC_DIR";
56530
56621
  function getRpcDir(projectDirectory) {
56531
56622
  const override = process.env[RPC_DIR_ENV]?.trim();
56532
56623
  if (override) {
56533
- return isAbsolute4(override) ? override : resolve25(projectDirectory, override);
56624
+ return isAbsolute5(override) ? override : resolve25(projectDirectory, override);
56534
56625
  }
56535
56626
  const projectHash = createHash19("sha256").update(resolve25(projectDirectory)).digest("hex").slice(0, 16);
56536
56627
  const stateHome = process.env.XDG_STATE_HOME ?? join34(homedir13(), ".local", "state");
@@ -56545,7 +56636,7 @@ function isSessionId(value) {
56545
56636
  // src/common-auth-embedded/rpc/port-file.js
56546
56637
  init_private_files2();
56547
56638
  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";
56639
+ 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
56640
  import { join as join35, resolve as resolve26 } from "node:path";
56550
56641
  function isProbeablePid(pid) {
56551
56642
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0;
@@ -56570,9 +56661,9 @@ function isUsablePortFileEntry(value, name) {
56570
56661
  const { pid, port, token } = value;
56571
56662
  return isProbeablePid(pid) && filenamePid(name) === pid && typeof port === "number" && Number.isInteger(port) && port >= 1 && port <= 65535 && typeof token === "string" && token.length > 0;
56572
56663
  }
56573
- async function removeCorruptPortFile(portFile, log16) {
56574
- log16?.debug("rpc corrupt port file", { pid: process.pid, portFile });
56575
- await unlink12(portFile).catch(() => {
56664
+ async function removeCorruptPortFile(portFile, log17) {
56665
+ log17?.debug("rpc corrupt port file", { pid: process.pid, portFile });
56666
+ await unlink13(portFile).catch(() => {
56576
56667
  });
56577
56668
  }
56578
56669
  async function writePortFile(dir, entry, options = {}) {
@@ -56610,7 +56701,7 @@ async function writePortFile(dir, entry, options = {}) {
56610
56701
  await handle?.close().catch(() => {
56611
56702
  });
56612
56703
  if (created)
56613
- await unlink12(tmp).catch(() => {
56704
+ await unlink13(tmp).catch(() => {
56614
56705
  });
56615
56706
  }
56616
56707
  return target;
@@ -56624,7 +56715,7 @@ async function writePortFile(dir, entry, options = {}) {
56624
56715
  throw error;
56625
56716
  }
56626
56717
  }
56627
- async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56718
+ async function sweepRpcState(root, activeDir, isManagedDir, log17) {
56628
56719
  let projectDirs;
56629
56720
  try {
56630
56721
  projectDirs = await readdir4(root, { withFileTypes: true });
@@ -56665,16 +56756,16 @@ async function sweepRpcState(root, activeDir, isManagedDir, log16) {
56665
56756
  try {
56666
56757
  parsed = JSON.parse(raw);
56667
56758
  } catch {
56668
- await removeCorruptPortFile(portFile, log16);
56759
+ await removeCorruptPortFile(portFile, log17);
56669
56760
  continue;
56670
56761
  }
56671
56762
  if (!isUsablePortFileEntry(parsed, name)) {
56672
- await removeCorruptPortFile(portFile, log16);
56763
+ await removeCorruptPortFile(portFile, log17);
56673
56764
  continue;
56674
56765
  }
56675
56766
  const entry = parsed;
56676
56767
  if (!pidAlive2(entry.pid))
56677
- await unlink12(portFile).catch(() => {
56768
+ await unlink13(portFile).catch(() => {
56678
56769
  });
56679
56770
  }
56680
56771
  if (resolve26(dir) !== active2)
@@ -56689,7 +56780,7 @@ init_private_files2();
56689
56780
  // src/common-auth-embedded/rpc/rpc-server.js
56690
56781
  init_private_files2();
56691
56782
  import { randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
56692
- import { unlink as unlink13 } from "node:fs/promises";
56783
+ import { unlink as unlink14 } from "node:fs/promises";
56693
56784
  import { createServer as createServer3 } from "node:http";
56694
56785
  import { join as join36 } from "node:path";
56695
56786
  var RpcRequestError = class extends Error {
@@ -56764,7 +56855,7 @@ function tokenOk(header, token) {
56764
56855
  async function startRpcServer(options) {
56765
56856
  if (typeof options.drain === "function" === (typeof options.drainAsync === "function"))
56766
56857
  throw new TypeError("exactly one of drain or drainAsync must be provided");
56767
- const log16 = options.log ?? { warn() {
56858
+ const log17 = options.log ?? { warn() {
56768
56859
  }, debug() {
56769
56860
  } };
56770
56861
  const token = randomBytes7(32).toString("hex");
@@ -56865,7 +56956,7 @@ async function startRpcServer(options) {
56865
56956
  return json(400, { error: "session required" });
56866
56957
  if (sessionId === void 0 && !warnedMissingNotificationSession) {
56867
56958
  warnedMissingNotificationSession = true;
56868
- log16.warn("rpc notification drain missing session id", {
56959
+ log17.warn("rpc notification drain missing session id", {
56869
56960
  pid: process.pid
56870
56961
  });
56871
56962
  }
@@ -56874,7 +56965,7 @@ async function startRpcServer(options) {
56874
56965
  try {
56875
56966
  messages = await options.drainAsync(lastReceivedId, sessionId);
56876
56967
  } catch (error) {
56877
- log16.warn("rpc notification drain failed", {
56968
+ log17.warn("rpc notification drain failed", {
56878
56969
  pid: process.pid,
56879
56970
  error: error instanceof Error ? error.message : String(error)
56880
56971
  });
@@ -56893,20 +56984,20 @@ async function startRpcServer(options) {
56893
56984
  return json(404, { error: "unknown method" });
56894
56985
  } catch (error) {
56895
56986
  if (error instanceof RpcRequestError) {
56896
- log16.debug("rpc request refused", {
56987
+ log17.debug("rpc request refused", {
56897
56988
  pid: process.pid,
56898
56989
  status: error.status
56899
56990
  });
56900
56991
  return json(error.status, { error: error.message });
56901
56992
  }
56902
56993
  if (error instanceof ApplyDeadlineError) {
56903
- log16.warn("rpc apply deadline exceeded", {
56994
+ log17.warn("rpc apply deadline exceeded", {
56904
56995
  pid: process.pid,
56905
56996
  deadlineMs: options.applyDeadlineMs
56906
56997
  });
56907
56998
  return json(504, { error: "handler deadline exceeded" });
56908
56999
  }
56909
- log16.warn("rpc request failed", {
57000
+ log17.warn("rpc request failed", {
56910
57001
  pid: process.pid,
56911
57002
  error: error instanceof Error ? error.message : String(error)
56912
57003
  });
@@ -56926,9 +57017,9 @@ async function startRpcServer(options) {
56926
57017
  server.unref();
56927
57018
  if (options.sweepRoot) {
56928
57019
  try {
56929
- await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir, log16);
57020
+ await sweepRpcState(options.sweepRoot, options.dir, options.isManagedDir, log17);
56930
57021
  } catch (error) {
56931
- log16.warn("rpc state sweep failed", {
57022
+ log17.warn("rpc state sweep failed", {
56932
57023
  pid: process.pid,
56933
57024
  error: error instanceof Error ? error.message : String(error)
56934
57025
  });
@@ -56936,7 +57027,7 @@ async function startRpcServer(options) {
56936
57027
  }
56937
57028
  try {
56938
57029
  await writePortFile(options.dir, { port, token, pid: process.pid }, { secureDir: options.secureDir });
56939
- log16.debug("rpc server pid", {
57030
+ log17.debug("rpc server pid", {
56940
57031
  pid: process.pid,
56941
57032
  rpcPort: port
56942
57033
  });
@@ -56961,7 +57052,7 @@ async function startRpcServer(options) {
56961
57052
  return void 0;
56962
57053
  });
56963
57054
  if (current?.port === port && current.token === token)
56964
- await unlink13(portFile).catch(() => {
57055
+ await unlink14(portFile).catch(() => {
56965
57056
  });
56966
57057
  }
56967
57058
  };
@@ -57036,6 +57127,9 @@ function parsePending(value) {
57036
57127
  };
57037
57128
  }
57038
57129
 
57130
+ // src/plugin/index.ts
57131
+ init_vault_folder();
57132
+
57039
57133
  // src/plugin/oauth-methods.ts
57040
57134
  init_dist();
57041
57135
  import { exec } from "node:child_process";
@@ -58317,10 +58411,10 @@ function toV1AuthCallbackResult(result) {
58317
58411
  };
58318
58412
  }
58319
58413
  var MAX_OAUTH_ACCOUNTS = 10;
58320
- var log11 = createLogger4("oauth-methods");
58321
- async function reportPersistenceFailure(error, client, log16) {
58414
+ var log12 = createLogger4("oauth-methods");
58415
+ async function reportPersistenceFailure(error, client, log17) {
58322
58416
  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", {
58417
+ log17.error("OAuth login persistence failed; aborting login", {
58324
58418
  error: message
58325
58419
  });
58326
58420
  try {
@@ -59157,7 +59251,7 @@ ${verifyUrl}
59157
59251
  }
59158
59252
  });
59159
59253
  } catch (storeError) {
59160
- log11.error(
59254
+ log12.error(
59161
59255
  "Failed to update stored Antigravity OAuth credentials",
59162
59256
  { error: String(storeError) }
59163
59257
  );
@@ -59182,7 +59276,7 @@ ${verifyUrl}
59182
59276
  }
59183
59277
  });
59184
59278
  } catch (storeError) {
59185
- log11.error(
59279
+ log12.error(
59186
59280
  "Failed to clear stored Antigravity OAuth credentials",
59187
59281
  { error: String(storeError) }
59188
59282
  );
@@ -59223,7 +59317,7 @@ Re-authenticating ${refreshEmail || "account"}...
59223
59317
  }
59224
59318
  });
59225
59319
  } catch (storeError) {
59226
- log11.error(
59320
+ log12.error(
59227
59321
  "Failed to clear stored Antigravity OAuth credentials",
59228
59322
  { error: String(storeError) }
59229
59323
  );
@@ -59562,7 +59656,7 @@ ${authorization2.url}
59562
59656
  return await reportPersistenceFailure(
59563
59657
  persistError,
59564
59658
  client,
59565
- log11
59659
+ log12
59566
59660
  );
59567
59661
  }
59568
59662
  const newTotal = existingCount + 1;
@@ -59606,7 +59700,7 @@ ${authorization2.url}
59606
59700
  try {
59607
59701
  await persistAccountPool2([result], false);
59608
59702
  } catch (persistError) {
59609
- return await reportPersistenceFailure(persistError, client, log11);
59703
+ return await reportPersistenceFailure(persistError, client, log12);
59610
59704
  }
59611
59705
  const newTotal = existingCount + 1;
59612
59706
  const toastMessage = existingCount > 0 ? `Added account${result.email ? ` (${result.email})` : ""} - ${newTotal} total` : `Authenticated${result.email ? ` (${result.email})` : ""}`;
@@ -59767,7 +59861,7 @@ import { createHash as createHash21 } from "node:crypto";
59767
59861
  init_debug();
59768
59862
  init_logger4();
59769
59863
  init_storage();
59770
- var log12 = createLogger4("auth-loader");
59864
+ var log13 = createLogger4("auth-loader");
59771
59865
  function refreshTokenIdentity(refreshToken) {
59772
59866
  return createHash21("sha256").update(refreshToken).digest("hex").slice(0, 16);
59773
59867
  }
@@ -59914,7 +60008,7 @@ function createAuthLoader({
59914
60008
  });
59915
60009
  refreshQueue = deps.createStoreRefreshQueue(
59916
60010
  {
59917
- logger: log12,
60011
+ logger: log13,
59918
60012
  refreshToken: (_auth, account) => credentials.refresh(account)
59919
60013
  },
59920
60014
  queueConfig
@@ -60022,7 +60116,7 @@ function createAuthLoader({
60022
60116
  }
60023
60117
  if (opening.status === "ready") {
60024
60118
  if (!isOAuthAuth(auth) && !readAuthority2) {
60025
- log12.warn(
60119
+ log13.warn(
60026
60120
  "The host holds no Antigravity sign-in; the account store is left untouched"
60027
60121
  );
60028
60122
  return {};
@@ -60035,7 +60129,7 @@ function createAuthLoader({
60035
60129
  }
60036
60130
  if (!usesPoolFile(opening)) {
60037
60131
  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", {
60132
+ log13.error("Refusing to start: the account store cannot serve", {
60039
60133
  message
60040
60134
  });
60041
60135
  try {
@@ -60052,7 +60146,7 @@ function createAuthLoader({
60052
60146
  storedAccounts = await deps.loadAccounts();
60053
60147
  } catch (error) {
60054
60148
  if (error instanceof AccountStorageUnreadableError) {
60055
- log12.error("Refusing to start: account storage is unreadable", {
60149
+ log13.error("Refusing to start: account storage is unreadable", {
60056
60150
  path: error.details.path,
60057
60151
  reason: error.details.reason,
60058
60152
  backupPath: error.details.backupPath
@@ -60084,12 +60178,12 @@ function createAuthLoader({
60084
60178
  expires: auth.expires ?? 0
60085
60179
  }
60086
60180
  });
60087
- log12.info("Restored Antigravity OAuth auth from account storage", {
60181
+ log13.info("Restored Antigravity OAuth auth from account storage", {
60088
60182
  reason: drift.reason,
60089
60183
  email: drift.account.email
60090
60184
  });
60091
60185
  } catch (error) {
60092
- log12.warn(
60186
+ log13.warn(
60093
60187
  "Failed to restore Antigravity OAuth auth from account storage",
60094
60188
  { error: String(error) }
60095
60189
  );
@@ -60752,7 +60846,7 @@ init_dist();
60752
60846
  init_debug();
60753
60847
  init_logger4();
60754
60848
  init_vault_request_credentials();
60755
- var log13 = createLogger4("fetch-interceptor");
60849
+ var log14 = createLogger4("fetch-interceptor");
60756
60850
  var defaultAgyTransport = (url, init, options) => fetchWithAgyCliTransport(url, init, options);
60757
60851
  var defaultFetchImpl = (input2, init) => globalThis.fetch(input2, init);
60758
60852
  function poolFileCredentials(accountManager, client, providerId) {
@@ -60805,14 +60899,14 @@ function openCode1EngineCollaborators(common) {
60805
60899
  // the engine calls.
60806
60900
  debug: debug_exports,
60807
60901
  dump: { dumpRequest: dumpGeminiRequest },
60808
- logger: log13,
60902
+ logger: log14,
60809
60903
  classifyAccessError: extractAccountAccessErrorDetails,
60810
60904
  notify: (message, variant) => client.tui.showToast({ body: { message, variant } }),
60811
60905
  onRouting: common.onRouting ?? ((sessionId, entry) => {
60812
60906
  void upsertSidebarActiveRouting(sessionId, entry, {
60813
60907
  authoritative: true
60814
60908
  }).catch((error) => {
60815
- log13.debug("sidebar-routing-upsert-failed", {
60909
+ log14.debug("sidebar-routing-upsert-failed", {
60816
60910
  sessionId,
60817
60911
  error: String(error)
60818
60912
  });
@@ -60838,7 +60932,7 @@ function createFetchInterceptor(context) {
60838
60932
  const refreshQuotaAfterSuccess = createLocalQuotaRefresh(
60839
60933
  accountManager,
60840
60934
  quotaManager,
60841
- log13
60935
+ log14
60842
60936
  );
60843
60937
  const executor = createRequestExecutor({
60844
60938
  assertAdmission: context.assertAdmission,
@@ -60984,7 +61078,7 @@ init_logger4();
60984
61078
  // src/plugin/search.ts
60985
61079
  import crypto3 from "node:crypto";
60986
61080
  init_logger4();
60987
- var log14 = createLogger4("search");
61081
+ var log15 = createLogger4("search");
60988
61082
  var sessionCounter = 0;
60989
61083
  var sessionPrefix = `search-${Date.now().toString(36)}`;
60990
61084
  function generateRequestId() {
@@ -61116,7 +61210,7 @@ ${urlList}`;
61116
61210
  requestType: "agent"
61117
61211
  };
61118
61212
  const url = `${ANTIGRAVITY_ENDPOINT}/v1internal:generateContent`;
61119
- log14.debug("Executing search", {
61213
+ log15.debug("Executing search", {
61120
61214
  query,
61121
61215
  urlCount: urls?.length ?? 0,
61122
61216
  thinking
@@ -61139,7 +61233,7 @@ ${urlList}`;
61139
61233
  );
61140
61234
  if (!response.ok) {
61141
61235
  const errorText3 = await response.text();
61142
- log14.debug("Search API error", {
61236
+ log15.debug("Search API error", {
61143
61237
  status: response.status,
61144
61238
  error: errorText3
61145
61239
  });
@@ -61152,14 +61246,14 @@ ${errorText3}
61152
61246
  Please try again with a different query.`;
61153
61247
  }
61154
61248
  const data = await response.json();
61155
- log14.debug("Search response received", { hasResponse: !!data.response });
61249
+ log15.debug("Search response received", { hasResponse: !!data.response });
61156
61250
  const result = parseSearchResponse(data);
61157
61251
  const formatted = formatSearchResult(result);
61158
- log14.debug("Search response formatted", { resultLength: formatted.length });
61252
+ log15.debug("Search response formatted", { resultLength: formatted.length });
61159
61253
  return formatted;
61160
61254
  } catch (error) {
61161
61255
  const message = error instanceof Error ? error.message : String(error);
61162
- log14.debug("Search execution error", { error: message });
61256
+ log15.debug("Search execution error", { error: message });
61163
61257
  return `## Search Error
61164
61258
 
61165
61259
  Failed to execute search: ${message}. Please try again with a different query.`;
@@ -61167,7 +61261,7 @@ Failed to execute search: ${message}. Please try again with a different query.`;
61167
61261
  }
61168
61262
 
61169
61263
  // src/plugin/google-search-tool.ts
61170
- var log15 = createLogger4("plugin");
61264
+ var log16 = createLogger4("plugin");
61171
61265
  function createGoogleSearchTool({
61172
61266
  getAuth,
61173
61267
  client,
@@ -61189,7 +61283,7 @@ function createGoogleSearchTool({
61189
61283
  if (mayStartLocalWork && !await mayStartLocalWork()) {
61190
61284
  return "Google Search is not available through local credentials while vault custody is active or unreadable.";
61191
61285
  }
61192
- log15.debug("Google Search tool called", {
61286
+ log16.debug("Google Search tool called", {
61193
61287
  query: args.query,
61194
61288
  urlCount: args.urls?.length ?? 0
61195
61289
  });