@cortexkit/opencode-antigravity-auth 3.1.9 → 3.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +4 -0
  2. package/dist/cli.js +145 -102
  3. package/dist/cli.js.map +3 -3
  4. package/dist/cli.meta.json +19 -14
  5. package/dist/index.js +320 -230
  6. package/dist/index.js.map +3 -3
  7. package/dist/index.meta.json +22 -17
  8. package/dist/server.js +306 -216
  9. package/dist/server.js.map +3 -3
  10. package/dist/server.meta.json +1 -1
  11. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
  12. package/dist/src/common-auth-embedded/claustrum/custody.js +31 -14
  13. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +6 -1
  14. package/dist/src/common-auth-embedded/setup/process-fence.js +20 -3
  15. package/dist/src/common-auth-embedded/source-output.json +20 -20
  16. package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
  17. package/dist/src/plugin/__fixtures__/release-model-ids.js +1 -0
  18. package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
  19. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  20. package/dist/src/plugin/config/models.d.ts +1 -1
  21. package/dist/src/plugin/config/models.d.ts.map +1 -1
  22. package/dist/src/plugin/config/models.js +10 -5
  23. package/dist/src/plugin/config/models.js.map +1 -1
  24. package/dist/src/plugin/request.js +7 -7
  25. package/dist/src/plugin/request.js.map +1 -1
  26. package/dist/tui-build-map.json +1 -1
  27. package/dist/tui-ga-build-map.json +1 -1
  28. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
  29. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +6 -1
  30. package/dist/types/src/plugin/config/models.d.ts +1 -1
  31. package/dist/types/src/plugin/config/models.d.ts.map +1 -1
  32. package/package.json +2 -2
  33. package/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
  34. package/src/common-auth-embedded/claustrum/custody.js +31 -14
  35. package/src/common-auth-embedded/routing-accessor/index.d.ts +6 -1
  36. package/src/common-auth-embedded/setup/process-fence.js +20 -3
  37. package/src/common-auth-embedded/source-output.json +20 -20
package/dist/cli.js CHANGED
@@ -4047,6 +4047,8 @@ function getResolverAliasMap() {
4047
4047
  }
4048
4048
  function getQuotaGroupForModel(modelId, hasArgonPool = false) {
4049
4049
  const normalized = modelId.toLowerCase();
4050
+ if (isGeminiNeonModel(normalized))
4051
+ return "gemini";
4050
4052
  if (isGeminiHydrogenModel(normalized))
4051
4053
  return "gemini";
4052
4054
  if (isGeminiCarbonModel(normalized))
@@ -4069,6 +4071,9 @@ function isGeminiCarbonModel(model) {
4069
4071
  function isGeminiHydrogenModel(model) {
4070
4072
  return /^(?:antigravity-)?gemini-4-hydrogen(?:-(?:low|medium|high|xhigh))?$/.test(model.toLowerCase());
4071
4073
  }
4074
+ function isGeminiNeonModel(model) {
4075
+ return /^(?:antigravity-)?gemini-4-neon(?:-(?:low|medium|high|xhigh))?$/i.test(model);
4076
+ }
4072
4077
  var DEFAULT_MODALITIES, MODEL_RELEASE_DATE, DEFAULT_COST, DEFAULT_OPTIONS, ALL_MODEL_DEFINITIONS, RESOLVER_ALIASES, QUOTA_GROUP_BY_MODEL_ID, ANTIGRAVITY_OPENCODE_MODEL_IDS, OPENCODE_MODEL_DEFINITIONS;
4073
4078
  var init_model_registry = __esm({
4074
4079
  "../core/dist/model-registry.js"() {
@@ -4081,6 +4086,18 @@ var init_model_registry = __esm({
4081
4086
  DEFAULT_COST = { input: 0, output: 0 };
4082
4087
  DEFAULT_OPTIONS = {};
4083
4088
  ALL_MODEL_DEFINITIONS = {
4089
+ "antigravity-gemini-4-neon": defineModel("antigravity-gemini-4-neon", {
4090
+ name: "Gemini 4 Neon (Antigravity)",
4091
+ reasoning: true,
4092
+ limit: { context: 1048576, output: 262144 },
4093
+ modalities: DEFAULT_MODALITIES,
4094
+ variants: {
4095
+ low: { thinkingLevel: "low" },
4096
+ medium: { thinkingLevel: "medium" },
4097
+ high: { thinkingLevel: "high" },
4098
+ xhigh: { thinkingLevel: "xhigh" }
4099
+ }
4100
+ }),
4084
4101
  "antigravity-gemini-4-hydrogen": defineModel("antigravity-gemini-4-hydrogen", {
4085
4102
  name: "Gemini 4 Hydrogen (Antigravity)",
4086
4103
  reasoning: true,
@@ -4228,6 +4245,7 @@ var init_model_registry = __esm({
4228
4245
  "antigravity-gemini-4-argon",
4229
4246
  "antigravity-gemini-4-carbon",
4230
4247
  "antigravity-gemini-4-hydrogen",
4248
+ "antigravity-gemini-4-neon",
4231
4249
  "antigravity-gemini-3.8-flash",
4232
4250
  "antigravity-gemini-3.1-flash-image",
4233
4251
  "antigravity-claude-sonnet-5-5",
@@ -6629,7 +6647,7 @@ function writeConsoleLog(level, ...args) {
6629
6647
  }
6630
6648
  function createLogger(module) {
6631
6649
  const service = `antigravity.${module}`;
6632
- const log9 = (level, message, extra) => {
6650
+ const log10 = (level, message, extra) => {
6633
6651
  if (_sink) {
6634
6652
  try {
6635
6653
  _sink({ service, level, message, extra });
@@ -6643,10 +6661,10 @@ function createLogger(module) {
6643
6661
  }
6644
6662
  };
6645
6663
  return {
6646
- debug: (message, extra) => log9("debug", message, extra),
6647
- info: (message, extra) => log9("info", message, extra),
6648
- warn: (message, extra) => log9("warn", message, extra),
6649
- error: (message, extra) => log9("error", message, extra)
6664
+ debug: (message, extra) => log10("debug", message, extra),
6665
+ info: (message, extra) => log10("info", message, extra),
6666
+ warn: (message, extra) => log10("warn", message, extra),
6667
+ error: (message, extra) => log10("error", message, extra)
6650
6668
  };
6651
6669
  }
6652
6670
  var ENV_CONSOLE_LOG, _sink;
@@ -18813,22 +18831,22 @@ function credentialTypeOf(row, family) {
18813
18831
  return notMine;
18814
18832
  if ("classify" in family) {
18815
18833
  const metadata = rowFactsOf(row);
18816
- let type;
18834
+ let type2;
18817
18835
  switch (metadata.authMethod) {
18818
18836
  case "apikey":
18819
- type = "api_key";
18837
+ type2 = "api_key";
18820
18838
  break;
18821
18839
  case "chatgpt":
18822
18840
  case "antigravity":
18823
18841
  case "oauth":
18824
- type = "oauth";
18842
+ type2 = "oauth";
18825
18843
  break;
18826
18844
  default:
18827
18845
  return { kind: "refused", code: "unknown-auth-method" };
18828
18846
  }
18829
18847
  const facts = {
18830
18848
  credentialId: row.id,
18831
- credentialType: type,
18849
+ credentialType: type2,
18832
18850
  categories: row.categories,
18833
18851
  refreshAdapter: row.refreshAdapter,
18834
18852
  ...metadata
@@ -18840,24 +18858,37 @@ function credentialTypeOf(row, family) {
18840
18858
  if (result.kind === "not-mine")
18841
18859
  return notMine;
18842
18860
  if (result.kind === "mine" && typeof result.member === "string")
18843
- return { kind: "mine", type, member: result.member };
18861
+ return { kind: "mine", type: type2, member: result.member };
18844
18862
  if (result.kind === "refused" && typeof result.code === "string" && /^[a-z][a-z0-9-]{0,31}$/.test(result.code) && !result.code.includes("\n") && family.refusalCodes.includes(result.code))
18845
18863
  return { kind: "refused", code: result.code };
18846
18864
  } catch {
18847
18865
  }
18848
18866
  return { kind: "refused", code: "unclassified" };
18849
18867
  }
18850
- if (row.credentialType !== "oauth" && row.credentialType !== "api_key")
18868
+ const type = row.credentialType;
18869
+ if (type === "oauth") {
18870
+ if (row.refreshAdapter !== family.refreshAdapter)
18871
+ return notMine;
18872
+ } else if (type === "api_key") {
18873
+ if (!family.apiKeys || row.refreshAdapter !== void 0)
18874
+ return notMine;
18875
+ } else {
18851
18876
  return notMine;
18852
- if (row.credentialType === "oauth")
18853
- return row.refreshAdapter === family.refreshAdapter ? { kind: "mine", type: "oauth" } : notMine;
18854
- if (row.credentialType === "api_key" && family.apiKeys)
18855
- return row.refreshAdapter === void 0 ? { kind: "mine", type: "api_key" } : notMine;
18856
- return notMine;
18877
+ }
18878
+ const { authMethod } = rowFactsOf(row, { includeProviderIds: false });
18879
+ if (authMethod !== void 0) {
18880
+ const matchesType = type === "oauth" ? authMethod === "chatgpt" || authMethod === "antigravity" || authMethod === "oauth" : authMethod === "apikey";
18881
+ if (!matchesType)
18882
+ return { kind: "refused", code: "unknown-auth-method" };
18883
+ }
18884
+ return { kind: "mine", type };
18857
18885
  }
18858
- function rowFactsOf(row) {
18886
+ function rowFactsOf(row, { includeProviderIds = true } = {}) {
18859
18887
  const metadata = row;
18860
- return { providerIds: metadata.providerIds, authMethod: metadata.authMethod };
18888
+ return {
18889
+ providerIds: includeProviderIds ? metadata.providerIds : void 0,
18890
+ authMethod: metadata.authMethod
18891
+ };
18861
18892
  }
18862
18893
  function grantReachOf(listed) {
18863
18894
  const { grants, grantTuples } = listed;
@@ -19189,14 +19220,15 @@ var init_custody = __esm({
19189
19220
  for (const record3 of skipped)
19190
19221
  this.#logger.warn("skipped malformed vault record", record3);
19191
19222
  const grantReach = grantReachOf(inventory);
19223
+ const classifying = "classify" in this.#family;
19192
19224
  return {
19193
19225
  view: inventory.view,
19194
19226
  credentials: Object.freeze(credentials),
19195
19227
  skipped: Object.freeze(skipped),
19196
- ..."classify" in this.#family && {
19197
- refused: Object.freeze(refused2),
19198
- notMine
19228
+ ...(classifying || refused2.length > 0) && {
19229
+ refused: Object.freeze(refused2)
19199
19230
  },
19231
+ ...classifying && { notMine },
19200
19232
  ...grantReach && { grantReach }
19201
19233
  };
19202
19234
  }
@@ -25476,7 +25508,7 @@ async function prepareVaultFolder(options) {
25476
25508
  const kept = refusals.get(key);
25477
25509
  if (kept)
25478
25510
  return override ? { ...override, refusal: kept } : refused(accountFile, kept);
25479
- const log9 = options.log ?? createLogger4("runtime-layout");
25511
+ const log10 = options.log ?? createLogger4("runtime-layout");
25480
25512
  const version = options.version ?? await pluginPackageVersion().catch(() => "unknown");
25481
25513
  try {
25482
25514
  if (override) {
@@ -25485,11 +25517,11 @@ async function prepareVaultFolder(options) {
25485
25517
  await prepareRuntimeLayout({
25486
25518
  version,
25487
25519
  accountFile,
25488
- log: log9,
25520
+ log: log10,
25489
25521
  ...options.layoutLockWaitMs === void 0 ? {} : { layoutLockWaitMs: options.layoutLockWaitMs }
25490
25522
  });
25491
25523
  if (options.accountStore !== false)
25492
- await prepareAccountStore({ version, log: log9 });
25524
+ await prepareAccountStore({ version, log: log10 });
25493
25525
  } catch (error) {
25494
25526
  const refusal3 = error instanceof RuntimeLayoutRefusal ? error : new RuntimeLayoutRefusal(
25495
25527
  override?.vaultDir ?? runtimeLayoutLocation().stateHomeDir,
@@ -25497,7 +25529,7 @@ async function prepareVaultFolder(options) {
25497
25529
  );
25498
25530
  if (!refusals.has(key)) {
25499
25531
  refusals.set(key, refusal3);
25500
- log9.warn(refusal3.message, {
25532
+ log10.warn(refusal3.message, {
25501
25533
  stateDir: refusal3.stateDir,
25502
25534
  errorClass: refusal3.errorClass
25503
25535
  });
@@ -25618,10 +25650,10 @@ function errorFile(error) {
25618
25650
  ...typeof stage === "string" && stage ? { stage } : {}
25619
25651
  };
25620
25652
  }
25621
- function logCleanupFailure(location, log9, step, error) {
25653
+ function logCleanupFailure(location, log10, step, error) {
25622
25654
  logOnce(
25623
25655
  `${location.key}\0cleanup`,
25624
- () => log9.warn(
25656
+ () => log10.warn(
25625
25657
  "antigravity-auth could not finish removing its old vault files from OpenCode's config folder; it tries again at the next start",
25626
25658
  {
25627
25659
  configDir: location.configDir,
@@ -25650,13 +25682,13 @@ function prepareRuntimeLayout(options) {
25650
25682
  return run;
25651
25683
  }
25652
25684
  async function decide(location, options) {
25653
- const log9 = options.log ?? createLogger4("runtime-layout");
25685
+ const log10 = options.log ?? createLogger4("runtime-layout");
25654
25686
  const stateDir = location.stateHomeDir;
25655
25687
  const markerPath = join14(stateDir, RUNTIME_LAYOUT_MARKER_FILE);
25656
25688
  const files = layoutFiles(location, options.accountFile);
25657
25689
  const fence = options.fence ?? defaultFence(options.version);
25658
25690
  const stateHome = async () => {
25659
- await settleVault(location, options, "state-home", log9);
25691
+ await settleVault(location, options, "state-home", log10);
25660
25692
  return "state-home";
25661
25693
  };
25662
25694
  let marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -25667,7 +25699,7 @@ async function decide(location, options) {
25667
25699
  join14(stateDir, RUNTIME_LAYOUT_MANIFEST_FILE)
25668
25700
  ).catch(() => true);
25669
25701
  if (!manifestLeft) {
25670
- await settleVault(location, options, "state-home", log9);
25702
+ await settleVault(location, options, "state-home", log10);
25671
25703
  return stateHome();
25672
25704
  }
25673
25705
  }
@@ -25679,7 +25711,7 @@ async function decide(location, options) {
25679
25711
  RUNTIME_LAYOUT_LOCK_NAME,
25680
25712
  markerPath,
25681
25713
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
25682
- log9
25714
+ log10
25683
25715
  );
25684
25716
  } catch (error) {
25685
25717
  marker = await readMarker(markerPath, stateDir, files.vault.old);
@@ -25699,7 +25731,7 @@ async function decide(location, options) {
25699
25731
  const legacy = async () => {
25700
25732
  try {
25701
25733
  await lock.assertOwned();
25702
- await settleVault(location, options, "legacy", log9);
25734
+ await settleVault(location, options, "legacy", log10);
25703
25735
  } catch (error) {
25704
25736
  throw new RuntimeLayoutRefusal(stateDir, errorClass(error));
25705
25737
  }
@@ -25713,20 +25745,20 @@ async function decide(location, options) {
25713
25745
  if (!marker.oldFilesRemoved && !aliased)
25714
25746
  await finishOldFiles(location, files, markerPath, marker, lock, {
25715
25747
  fence,
25716
- log: log9,
25748
+ log: log10,
25717
25749
  steps: options.steps,
25718
25750
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile()
25719
25751
  });
25720
25752
  else if (marker.oldFilesRemoved) {
25721
25753
  await refuseReappearedFiles(location, files);
25722
- await removeLeftoverManifest(location, lock, options.steps, log9);
25754
+ await removeLeftoverManifest(location, lock, options.steps, log10);
25723
25755
  }
25724
25756
  return await stateHome();
25725
25757
  }
25726
25758
  if (aliased) {
25727
25759
  logOnce(
25728
25760
  `${location.key}\0aliased`,
25729
- () => log9.warn(
25761
+ () => log10.warn(
25730
25762
  "antigravity-auth keeps its vault files in OpenCode's config folder: its state folder is that same folder",
25731
25763
  { configDir: location.configDir, stateDir }
25732
25764
  )
@@ -25735,14 +25767,14 @@ async function decide(location, options) {
25735
25767
  }
25736
25768
  const gate = await fence();
25737
25769
  if (!gate.open) {
25738
- logDeferral(location, gate.blockers, log9);
25770
+ logDeferral(location, gate.blockers, log10);
25739
25771
  return await legacy();
25740
25772
  }
25741
25773
  let markerStarted = false;
25742
25774
  try {
25743
25775
  const outcome = await moveFiles(location, files, markerPath, lock, {
25744
25776
  fence,
25745
- log: log9,
25777
+ log: log10,
25746
25778
  steps: options.steps,
25747
25779
  destinationPrivate: options.destinationPrivate ?? defaultDestinationPrivate,
25748
25780
  oldSignatureCache: options.oldSignatureCacheFile ?? legacySignatureCacheFile(),
@@ -25751,13 +25783,13 @@ async function decide(location, options) {
25751
25783
  }
25752
25784
  });
25753
25785
  if (outcome.kind === "deferred") {
25754
- logDeferral(location, outcome.blockers, log9);
25786
+ logDeferral(location, outcome.blockers, log10);
25755
25787
  return await legacy();
25756
25788
  }
25757
25789
  if (outcome.kind === "refused") {
25758
25790
  logOnce(
25759
25791
  `${location.key}\0refused`,
25760
- () => log9.warn(
25792
+ () => log10.warn(
25761
25793
  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",
25762
25794
  { reason: outcome.reason, paths: outcome.paths, stateDir }
25763
25795
  )
@@ -25765,7 +25797,7 @@ async function decide(location, options) {
25765
25797
  return await legacy();
25766
25798
  }
25767
25799
  if (outcome.moved)
25768
- log9.info(
25800
+ log10.info(
25769
25801
  "antigravity-auth moved its vault files out of OpenCode's config folder",
25770
25802
  { from: files.vault.old, to: files.vault.next }
25771
25803
  );
@@ -25776,7 +25808,7 @@ async function decide(location, options) {
25776
25808
  return await stateHome();
25777
25809
  logOnce(
25778
25810
  `${location.key}\0failed`,
25779
- () => log9.warn(
25811
+ () => log10.warn(
25780
25812
  "antigravity-auth's vault files stay in OpenCode's config folder: moving them failed; the move is tried again at the next start",
25781
25813
  {
25782
25814
  configDir: location.configDir,
@@ -25825,7 +25857,7 @@ async function prepareAccountStore(options) {
25825
25857
  if (!await localAccountStoreAuthorized()) return void 0;
25826
25858
  const decided = decidedAccountStoreAnchor(location);
25827
25859
  if (decided) return decided;
25828
- const log9 = options.log ?? createLogger4("runtime-layout");
25860
+ const log10 = options.log ?? createLogger4("runtime-layout");
25829
25861
  const runKey = `${location.stateHomeDir}\0${location.key}`;
25830
25862
  let run = processState.storeRuns.get(runKey);
25831
25863
  if (!run) {
@@ -25836,12 +25868,12 @@ async function prepareAccountStore(options) {
25836
25868
  RUNTIME_LAYOUT_LOCK_NAME,
25837
25869
  join14(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE),
25838
25870
  options.layoutLockWaitMs ?? LAYOUT_LOCK_WAIT_MS,
25839
- log9
25871
+ log10
25840
25872
  );
25841
25873
  try {
25842
25874
  await lock.assertOwned();
25843
25875
  if (!await localAccountStoreAuthorized()) return void 0;
25844
- return await settleAccountStore(location, options, log9);
25876
+ return await settleAccountStore(location, options, log10);
25845
25877
  } finally {
25846
25878
  await lock.release();
25847
25879
  }
@@ -25852,20 +25884,20 @@ async function prepareAccountStore(options) {
25852
25884
  }
25853
25885
  return run;
25854
25886
  }
25855
- async function settleAccountStore(location, options, log9) {
25887
+ async function settleAccountStore(location, options, log10) {
25856
25888
  const decided = decidedAccountStoreAnchor(location);
25857
25889
  if (decided) return decided;
25858
- const anchor = await decideAccountStore(location, options, log9);
25890
+ const anchor = await decideAccountStore(location, options, log10);
25859
25891
  setAccountStoreAnchor(location, anchor);
25860
25892
  return anchor;
25861
25893
  }
25862
- async function decideAccountStore(location, options, log9) {
25863
- const keepConfig = () => recordAnchor(location, options, "config", log9);
25894
+ async function decideAccountStore(location, options, log10) {
25895
+ const keepConfig = () => recordAnchor(location, options, "config", log10);
25864
25896
  if (processHasOlderGeneration()) {
25865
25897
  logOnce(
25866
25898
  "older-generation-account-store",
25867
25899
  () => showLog(
25868
- log9,
25900
+ log10,
25869
25901
  "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.",
25870
25902
  { accountStore: "config" }
25871
25903
  )
@@ -25879,7 +25911,7 @@ async function decideAccountStore(location, options, log9) {
25879
25911
  if (!sameSpelling(forward.legacyPath, stateAnchor)) {
25880
25912
  logOnce(
25881
25913
  `${location.key}\0store-forward-elsewhere`,
25882
- () => log9.warn(
25914
+ () => log10.warn(
25883
25915
  "the account store moved to another folder than this process resolved; check XDG_STATE_HOME",
25884
25916
  { movedTo: forward.legacyPath, expected: stateAnchor }
25885
25917
  )
@@ -25890,9 +25922,9 @@ async function decideAccountStore(location, options, log9) {
25890
25922
  options,
25891
25923
  configAnchor,
25892
25924
  stateAnchor,
25893
- log9
25925
+ log10
25894
25926
  );
25895
- return recordAnchor(location, options, "state-home", log9);
25927
+ return recordAnchor(location, options, "state-home", log10);
25896
25928
  }
25897
25929
  if (decidedRuntimeLayout(location) === "legacy") return keepConfig();
25898
25930
  const configStore = await presentAccountStore(configAnchor);
@@ -25904,9 +25936,9 @@ async function decideAccountStore(location, options, log9) {
25904
25936
  `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.`
25905
25937
  );
25906
25938
  }
25907
- if (stateStore) return recordAnchor(location, options, "state-home", log9);
25939
+ if (stateStore) return recordAnchor(location, options, "state-home", log10);
25908
25940
  if (configStore) {
25909
- if (!await storeMovePathResolves(stateAnchor, location, log9))
25941
+ if (!await storeMovePathResolves(stateAnchor, location, log10))
25910
25942
  return keepConfig();
25911
25943
  return moveStore(
25912
25944
  location,
@@ -25914,21 +25946,21 @@ async function decideAccountStore(location, options, log9) {
25914
25946
  configAnchor,
25915
25947
  stateAnchor,
25916
25948
  false,
25917
- log9,
25949
+ log10,
25918
25950
  false
25919
25951
  );
25920
25952
  }
25921
- if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log9))
25953
+ if (await storeArtefacts(stateAnchor) > 0 && !await abandonUnpublishedStore(location, stateAnchor, log10))
25922
25954
  return keepConfig();
25923
- if (!await storeMovePathResolves(stateAnchor, location, log9))
25955
+ if (!await storeMovePathResolves(stateAnchor, location, log10))
25924
25956
  return keepConfig();
25925
- return initializeStore(location, options, stateAnchor, log9);
25957
+ return initializeStore(location, options, stateAnchor, log10);
25926
25958
  }
25927
- function showLog(log9, message, meta) {
25928
- if (log9.log) log9.log(message, meta);
25929
- else log9.info(message, meta);
25959
+ function showLog(log10, message, meta) {
25960
+ if (log10.log) log10.log(message, meta);
25961
+ else log10.info(message, meta);
25930
25962
  }
25931
- async function recordAnchor(location, options, anchor, log9) {
25963
+ async function recordAnchor(location, options, anchor, log10) {
25932
25964
  try {
25933
25965
  await recordProcessAnchor({
25934
25966
  key: location.key,
@@ -25940,32 +25972,32 @@ async function recordAnchor(location, options, anchor, log9) {
25940
25972
  }
25941
25973
  if (anchor === "state-home")
25942
25974
  showLog(
25943
- log9,
25975
+ log10,
25944
25976
  "antigravity-auth keeps its account store in its state folder",
25945
25977
  { accountStore: anchor }
25946
25978
  );
25947
25979
  return anchor;
25948
25980
  }
25949
- async function storeMovePathResolves(stateAnchor, location, log9) {
25981
+ async function storeMovePathResolves(stateAnchor, location, log10) {
25950
25982
  if (folderResolvesToItself(
25951
25983
  join14(location.stateHomeDir, "antigravity-accounts.json")
25952
25984
  ))
25953
25985
  return true;
25954
25986
  logOnce(
25955
25987
  `${location.key}\0store-linked-path`,
25956
- () => log9.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
25988
+ () => log10.warn(ACCOUNT_STORE_LINKED_PATH_MESSAGE, {
25957
25989
  accountStore: stateAnchor,
25958
25990
  stateFolder: location.stateHomeDir
25959
25991
  })
25960
25992
  );
25961
25993
  return false;
25962
25994
  }
25963
- async function storeFenceOpen(location, options, log9) {
25995
+ async function storeFenceOpen(location, options, log10) {
25964
25996
  const gate = await (options.storeFence ?? defaultStoreFence(options.version))();
25965
25997
  if (gate.open) return true;
25966
25998
  logOnce(
25967
25999
  `${location.key}\0store-version-fence`,
25968
- () => log9.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
26000
+ () => log10.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
25969
26001
  configDir: location.configDir,
25970
26002
  blockers: gate.blockers
25971
26003
  })
@@ -25992,7 +26024,7 @@ async function storeArtefacts(anchor) {
25992
26024
  (name) => name === store || name.startsWith(`${pool}.store.`) || name.startsWith(pool) && name.endsWith(".tmp")
25993
26025
  ).length;
25994
26026
  }
25995
- async function abandonUnpublishedStore(location, stateAnchor, log9) {
26027
+ async function abandonUnpublishedStore(location, stateAnchor, log10) {
25996
26028
  const store = await loadCommonAuthStoreModules();
25997
26029
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
25998
26030
  if (binding.status === "bound") return false;
@@ -26003,7 +26035,7 @@ async function abandonUnpublishedStore(location, stateAnchor, log9) {
26003
26035
  });
26004
26036
  await unlink11(accountStorePointerPath(stateAnchor)).catch(() => {
26005
26037
  });
26006
- log9.info(
26038
+ log10.info(
26007
26039
  "antigravity-auth set an unfinished account store aside before starting its move again",
26008
26040
  { configDir: location.configDir, archived }
26009
26041
  );
@@ -26025,9 +26057,9 @@ async function runStoreMove(input) {
26025
26057
  return { status: "pending", reason: outcome.reason };
26026
26058
  return { status: "cancelled" };
26027
26059
  }
26028
- async function moveStore(location, options, source, target, back, log9, forwarded) {
26029
- const keepConfig = () => recordAnchor(location, options, "config", log9);
26030
- if (!await storeFenceOpen(location, options, log9)) return keepConfig();
26060
+ async function moveStore(location, options, source, target, back, log10, forwarded) {
26061
+ const keepConfig = () => recordAnchor(location, options, "config", log10);
26062
+ if (!await storeFenceOpen(location, options, log10)) return keepConfig();
26031
26063
  try {
26032
26064
  const result = await (options.relocate ?? runStoreMove)({
26033
26065
  source,
@@ -26037,7 +26069,7 @@ async function moveStore(location, options, source, target, back, log9, forwarde
26037
26069
  if (result.status !== "completed") {
26038
26070
  logOnce(
26039
26071
  `${location.key}\0store-move-unfinished`,
26040
- () => log9.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
26072
+ () => log10.info(ACCOUNT_STORE_DEFERRED_MESSAGE, {
26041
26073
  configDir: location.configDir,
26042
26074
  reason: result.status === "pending" ? result.reason : result.status
26043
26075
  })
@@ -26045,14 +26077,14 @@ async function moveStore(location, options, source, target, back, log9, forwarde
26045
26077
  return forwarded ? "state-home" : keepConfig();
26046
26078
  }
26047
26079
  showLog(
26048
- log9,
26080
+ log10,
26049
26081
  "antigravity-auth moved the account store out of OpenCode's config folder",
26050
26082
  { from: source, to: target, generation: result.id }
26051
26083
  );
26052
26084
  } catch (error) {
26053
26085
  logOnce(
26054
26086
  `${location.key}\0store-move-failed`,
26055
- () => log9.warn(
26087
+ () => log10.warn(
26056
26088
  "antigravity-auth's account store stays in OpenCode's config folder: moving it failed; the move is tried again at the next start",
26057
26089
  {
26058
26090
  configDir: location.configDir,
@@ -26063,9 +26095,9 @@ async function moveStore(location, options, source, target, back, log9, forwarde
26063
26095
  );
26064
26096
  return forwarded ? "state-home" : keepConfig();
26065
26097
  }
26066
- return recordAnchor(location, options, "state-home", log9);
26098
+ return recordAnchor(location, options, "state-home", log10);
26067
26099
  }
26068
- async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log9) {
26100
+ async function resumeForwardedStore(location, options, configAnchor, stateAnchor, log10) {
26069
26101
  const store = await loadCommonAuthStoreModules();
26070
26102
  const binding = await readAccountStoreBinding(stateAnchor, store, Date.now);
26071
26103
  if (binding.status === "bound") return;
@@ -26076,13 +26108,13 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
26076
26108
  configAnchor,
26077
26109
  stateAnchor,
26078
26110
  false,
26079
- log9,
26111
+ log10,
26080
26112
  true
26081
26113
  );
26082
26114
  } catch (error) {
26083
26115
  logOnce(
26084
26116
  `${location.key}\0store-resume-failed`,
26085
- () => log9.warn(
26117
+ () => log10.warn(
26086
26118
  "antigravity-auth's account store is still moving; it could not be finished at this start",
26087
26119
  {
26088
26120
  configDir: location.configDir,
@@ -26093,9 +26125,9 @@ async function resumeForwardedStore(location, options, configAnchor, stateAnchor
26093
26125
  );
26094
26126
  }
26095
26127
  }
26096
- async function initializeStore(location, options, stateAnchor, log9) {
26097
- const keepConfig = () => recordAnchor(location, options, "config", log9);
26098
- if (!await storeFenceOpen(location, options, log9)) return keepConfig();
26128
+ async function initializeStore(location, options, stateAnchor, log10) {
26129
+ const keepConfig = () => recordAnchor(location, options, "config", log10);
26130
+ if (!await storeFenceOpen(location, options, log10)) return keepConfig();
26099
26131
  try {
26100
26132
  const store = await loadCommonAuthStoreModules();
26101
26133
  const created = await initializeFreshAccountStore(store, {
@@ -26108,7 +26140,7 @@ async function initializeStore(location, options, stateAnchor, log9) {
26108
26140
  } catch (error) {
26109
26141
  logOnce(
26110
26142
  `${location.key}\0store-init-failed`,
26111
- () => log9.warn(
26143
+ () => log10.warn(
26112
26144
  "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",
26113
26145
  {
26114
26146
  configDir: location.configDir,
@@ -26120,13 +26152,13 @@ async function initializeStore(location, options, stateAnchor, log9) {
26120
26152
  return keepConfig();
26121
26153
  }
26122
26154
  showLog(
26123
- log9,
26155
+ log10,
26124
26156
  "antigravity-auth created its account store in its state folder",
26125
26157
  {
26126
26158
  accountStore: stateAnchor
26127
26159
  }
26128
26160
  );
26129
- return recordAnchor(location, options, "state-home", log9);
26161
+ return recordAnchor(location, options, "state-home", log10);
26130
26162
  }
26131
26163
  async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacyAccountFile(runtimeLayoutLocation().configDir)) {
26132
26164
  const forward = {
@@ -26141,10 +26173,10 @@ async function writeStateHomeStoreForward(id, stateAnchor, configAnchor = legacy
26141
26173
  durability: "file-only-on-windows"
26142
26174
  });
26143
26175
  }
26144
- function logDeferral(location, blockers, log9) {
26176
+ function logDeferral(location, blockers, log10) {
26145
26177
  logOnce(
26146
26178
  `${location.key}\0deferred`,
26147
- () => log9.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
26179
+ () => log10.info(RUNTIME_LAYOUT_DEFERRED_MESSAGE, {
26148
26180
  configDir: location.configDir,
26149
26181
  blockers
26150
26182
  })
@@ -26302,13 +26334,13 @@ async function finishOldFiles(location, files, markerPath, marker, layoutLock, i
26302
26334
  if (done) await removeOldVaultFolder(files, layoutLock, input.steps);
26303
26335
  }
26304
26336
  }
26305
- async function removeLeftoverManifest(location, layoutLock, steps, log9) {
26337
+ async function removeLeftoverManifest(location, layoutLock, steps, log10) {
26306
26338
  try {
26307
26339
  await removeManifestOwned(location.stateHomeDir, layoutLock, steps);
26308
26340
  } catch (error) {
26309
26341
  logOnce(
26310
26342
  `${location.key}\0manifest`,
26311
- () => log9.warn(
26343
+ () => log10.warn(
26312
26344
  `antigravity-auth could not remove ${RUNTIME_LAYOUT_MANIFEST_FILE} from its state folder; it tries again at the next start`,
26313
26345
  { stateDir: location.stateHomeDir, errorClass: errorClass(error) }
26314
26346
  )
@@ -26328,7 +26360,7 @@ async function removeOldVaultFolder(files, layoutLock, steps) {
26328
26360
  } catch {
26329
26361
  }
26330
26362
  }
26331
- async function removeOldSignatureCache(location, path2, layoutLock, steps, log9) {
26363
+ async function removeOldSignatureCache(location, path2, layoutLock, steps, log10) {
26332
26364
  try {
26333
26365
  if (!await exists2(path2)) return;
26334
26366
  await beforeRemove(path2, layoutLock, steps);
@@ -26337,7 +26369,7 @@ async function removeOldSignatureCache(location, path2, layoutLock, steps, log9)
26337
26369
  if (error?.code === "ENOENT") return;
26338
26370
  logOnce(
26339
26371
  `${location.key}\0signature-cache`,
26340
- () => log9.warn(
26372
+ () => log10.warn(
26341
26373
  "antigravity-auth could not remove its old signature cache from OpenCode's config folder; it is no longer used and can be deleted",
26342
26374
  { path: path2, errorClass: errorClass(error) }
26343
26375
  )
@@ -26348,7 +26380,7 @@ async function beforeRemove(path2, layoutLock, steps) {
26348
26380
  await steps?.beforeRemove?.(path2);
26349
26381
  await layoutLock.assertOwned();
26350
26382
  }
26351
- async function takeDataLocks(files, log9) {
26383
+ async function takeDataLocks(files, log10) {
26352
26384
  const locks = [];
26353
26385
  try {
26354
26386
  if (await exists2(files.vault.old))
@@ -26358,7 +26390,7 @@ async function takeDataLocks(files, log9) {
26358
26390
  lock.name,
26359
26391
  join14(files.vault.old, lock.file),
26360
26392
  lock.waitMs,
26361
- log9
26393
+ log10
26362
26394
  )
26363
26395
  );
26364
26396
  return locks;
@@ -26709,7 +26741,7 @@ async function ensureOwnerOnlyDir(path2) {
26709
26741
  await mkdir12(path2, { recursive: true, mode: 448 });
26710
26742
  await chmod4(path2, 448);
26711
26743
  }
26712
- async function takeLock(name, path2, waitMs, log9) {
26744
+ async function takeLock(name, path2, waitMs, log10) {
26713
26745
  const fs3 = await loadCommonAuthFs();
26714
26746
  const started = performance.now();
26715
26747
  let announced = false;
@@ -26734,7 +26766,7 @@ async function takeLock(name, path2, waitMs, log9) {
26734
26766
  );
26735
26767
  if (!announced && waited >= LOCK_WAIT_NOTICE_MS) {
26736
26768
  announced = true;
26737
- log9.info(
26769
+ log10.info(
26738
26770
  `antigravity-auth is waiting up to ${Math.round(waitMs / 1e3)} s for the ${name} lock at ${path2}.${lockHolderText(name)}`,
26739
26771
  { lock: name, path: path2 }
26740
26772
  );
@@ -27951,19 +27983,19 @@ function getLegacyLogger() {
27951
27983
  }
27952
27984
  function createLogger4(module) {
27953
27985
  let channel3;
27954
- const log9 = (level, message, extra) => {
27986
+ const log10 = (level, message, extra) => {
27955
27987
  channel3 ??= getLegacyLogger().createLogger(module);
27956
27988
  channel3[level](message, extra);
27957
27989
  };
27958
27990
  return {
27959
- debug: (message, extra) => log9("debug", message, extra),
27960
- info: (message, extra) => log9("info", message, extra),
27991
+ debug: (message, extra) => log10("debug", message, extra),
27992
+ info: (message, extra) => log10("info", message, extra),
27961
27993
  hostInfo: (message, extra) => {
27962
27994
  channel3 ??= getLegacyLogger().createLogger(module);
27963
27995
  channel3.hostInfo?.(message, extra);
27964
27996
  },
27965
- warn: (message, extra) => log9("warn", message, extra),
27966
- error: (message, extra) => log9("error", message, extra)
27997
+ warn: (message, extra) => log10("warn", message, extra),
27998
+ error: (message, extra) => log10("error", message, extra)
27967
27999
  };
27968
28000
  }
27969
28001
  var ENV_CONSOLE_LOG2, LOG_LEVEL_FROM_OPERATOR, legacyClient, legacyLogger;
@@ -31540,9 +31572,11 @@ import { setTimeout as delay2 } from "node:timers/promises";
31540
31572
  import { writeEnrollmentTokenFile as writeEnrollmentTokenFile3 } from "@cortexkit/claustrum-client";
31541
31573
 
31542
31574
  // src/common-auth-embedded/setup/process-fence.js
31575
+ init_logger3();
31543
31576
  import { statSync as statSync6 } from "node:fs";
31544
31577
  import { win32 as win323 } from "node:path";
31545
31578
  var WINDOWS_CIM_TIMEOUT_MS = 45e3;
31579
+ var log9 = createLogger3("setup-process-fence");
31546
31580
  var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 9e4;
31547
31581
  function isFile(file) {
31548
31582
  try {
@@ -31702,14 +31736,23 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
31702
31736
  options.onStep?.({ ...inspection });
31703
31737
  }
31704
31738
  };
31705
- const inspectCim = (args) => {
31739
+ const inspectCim = async (args) => {
31706
31740
  const pwsh = win323.resolve(windowsEnv(env3, "ProgramFiles") ?? "C:\\Program Files", "PowerShell", "7", "pwsh.exe");
31707
31741
  const program = (options.isFile ?? isFile)(pwsh) ? "pwsh" : "powershell";
31708
31742
  const arm64 = (windowsEnv(env3, "PROCESSOR_ARCHITEW6432") ?? windowsEnv(env3, "PROCESSOR_ARCHITECTURE"))?.toUpperCase() === "ARM64";
31709
31743
  const slow = program === "powershell" && arm64;
31710
31744
  if (slow)
31711
31745
  options.onProgress?.("Checking that OpenCode and Pi are not running. Without PowerShell 7 this can take up to a minute on Windows ARM; installing PowerShell 7 makes it fast.");
31712
- return inspect("CIM", program === "pwsh" ? pwsh : win323.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe"), args, slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS, program);
31746
+ const file = program === "pwsh" ? pwsh : win323.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe");
31747
+ const timeoutMs = slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS;
31748
+ const started = performance.now();
31749
+ const result = await inspect("CIM", file, args, timeoutMs, program);
31750
+ const remaining = Math.floor(timeoutMs - (performance.now() - started));
31751
+ if ((result.exitCode === 3221225477 || result.exitCode === -1073741819) && !result.timedOut && !result.signal && !result.spawnError && remaining > 0) {
31752
+ log9.warn("Windows process query crashed with an access violation; retrying once");
31753
+ return inspect("CIM", file, args, remaining, program);
31754
+ }
31755
+ return result;
31713
31756
  };
31714
31757
  try {
31715
31758
  if (windows && options.hostImagesOnly) {