@cortexkit/opencode-antigravity-auth 3.0.35 → 3.0.37

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 (55) hide show
  1. package/dist/cli.js +6 -1
  2. package/dist/cli.js.map +2 -2
  3. package/dist/cli.meta.json +11 -11
  4. package/dist/index.js +12 -7
  5. package/dist/index.js.map +2 -2
  6. package/dist/index.meta.json +29 -13
  7. package/dist/server.js +624 -581
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
  11. package/dist/src/common-auth-embedded/claustrum/availability.js +2 -0
  12. package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  13. package/dist/src/common-auth-embedded/claustrum/index.js +1 -1
  14. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
  15. package/dist/src/common-auth-embedded/routing-accessor/cache-policy.js +186 -0
  16. package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
  17. package/dist/src/common-auth-embedded/routing-accessor/index.js +1 -0
  18. package/dist/src/common-auth-embedded/source-output.json +41 -25
  19. package/dist/src/ga/server/auth.js +1 -1
  20. package/dist/src/ga/server/auth.js.map +1 -1
  21. package/dist/src/ga/server/index.js +1 -1
  22. package/dist/src/ga/server/index.js.map +1 -1
  23. package/dist/src/ga/tui/host-ga.d.ts +21 -58
  24. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  25. package/dist/src/ga/tui/host-ga.js +122 -230
  26. package/dist/src/ga/tui/host-ga.js.map +1 -1
  27. package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
  28. package/dist/src/plugin/ga-location-services.d.ts +1 -0
  29. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  30. package/dist/src/plugin/ga-location-services.js +88 -52
  31. package/dist/src/plugin/ga-location-services.js.map +1 -1
  32. package/dist/src/plugin/vault-custody.js +6 -6
  33. package/dist/src/plugin/vault-custody.js.map +1 -1
  34. package/dist/src/setup.js +1 -1
  35. package/dist/src/setup.js.map +1 -1
  36. package/dist/tui-build-map.json +1 -1
  37. package/dist/tui-ga-build-map.json +5 -5
  38. package/dist/types/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
  39. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  40. package/dist/types/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
  41. package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
  42. package/dist/types/src/plugin/ga-location-services.d.ts +1 -0
  43. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  44. package/package.json +4 -4
  45. package/src/common-auth-embedded/claustrum/availability.d.ts +1 -0
  46. package/src/common-auth-embedded/claustrum/availability.js +2 -0
  47. package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  48. package/src/common-auth-embedded/claustrum/index.js +1 -1
  49. package/src/common-auth-embedded/routing-accessor/cache-policy.d.ts +51 -0
  50. package/src/common-auth-embedded/routing-accessor/cache-policy.js +186 -0
  51. package/src/common-auth-embedded/routing-accessor/index.d.ts +2 -1
  52. package/src/common-auth-embedded/routing-accessor/index.js +1 -0
  53. package/src/common-auth-embedded/source-output.json +41 -25
  54. package/src/tui-ga-compiled/host-ga.js +122 -238
  55. package/src/tui-ga-raw/host-ga.tsx +189 -306
package/dist/server.js CHANGED
@@ -19494,6 +19494,8 @@ var init_availability = __esm({
19494
19494
  unavailable: "unreachable",
19495
19495
  timeout: "unreachable",
19496
19496
  route_closed: "unreachable",
19497
+ // The daemon refused before forwarding, so the vault never saw the request.
19498
+ route_busy: "unreachable",
19497
19499
  daemon_draining: "unreachable",
19498
19500
  connection_closed: "unreachable",
19499
19501
  connection_dropped: "unreachable",
@@ -25659,6 +25661,7 @@ __export(claustrum_exports, {
25659
25661
  enrollmentAuthority: () => enrollmentAuthority,
25660
25662
  enrollmentName: () => enrollmentName,
25661
25663
  getClaustrumEnrollmentPaths: () => getClaustrumEnrollmentPaths,
25664
+ hasVaultHost: () => hasVaultHost,
25662
25665
  hostEnrollmentPaths: () => hostEnrollmentPaths,
25663
25666
  isCustodyPlaceholder: () => isCustodyPlaceholder,
25664
25667
  isCustodyPlaceholderValue: () => isCustodyPlaceholderValue,
@@ -29926,7 +29929,7 @@ var init_redact2 = __esm({
29926
29929
  });
29927
29930
 
29928
29931
  // src/common-auth-embedded/logger/engine.js
29929
- import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync2, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
29932
+ import { appendFileSync as appendFileSync2, chmodSync as chmodSync2, existsSync as existsSync3, renameSync as renameSync2, statSync as statSync3 } from "node:fs";
29930
29933
  import { open as open8 } from "node:fs/promises";
29931
29934
  import { dirname as dirname14, resolve as resolve13 } from "node:path";
29932
29935
  function chmodPrivate2(path5) {
@@ -29937,10 +29940,10 @@ function chmodPrivate2(path5) {
29937
29940
  }
29938
29941
  function rotateIfNeeded2(f) {
29939
29942
  try {
29940
- if (!(existsSync2(f) && statSync3(f).size >= MAX_BYTES2))
29943
+ if (!(existsSync3(f) && statSync3(f).size >= MAX_BYTES2))
29941
29944
  return;
29942
29945
  for (let i = ROTATE_KEEP2 - 1; i >= 1; i--) {
29943
- if (existsSync2(`${f}.${i}`)) {
29946
+ if (existsSync3(`${f}.${i}`)) {
29944
29947
  const rotated2 = `${f}.${i + 1}`;
29945
29948
  renameSync2(`${f}.${i}`, rotated2);
29946
29949
  chmodPrivate2(rotated2);
@@ -30110,7 +30113,7 @@ function createEngine2(options) {
30110
30113
  }
30111
30114
  try {
30112
30115
  rotateIfNeeded2(file);
30113
- if (existsSync2(file))
30116
+ if (existsSync3(file))
30114
30117
  chmodPrivate2(file);
30115
30118
  appendFileSync2(file, text2, { encoding: "utf8", mode: 384 });
30116
30119
  } catch {
@@ -30873,7 +30876,7 @@ function createOpenCodeVaultCustody(options) {
30873
30876
  const readEnrollment = async () => {
30874
30877
  if (layoutRefusal !== void 0) return unsettled;
30875
30878
  const claustrum = await loadClaustrum();
30876
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
30879
+ if (claustrum.hasVaultHost())
30877
30880
  return {
30878
30881
  state: "unavailable",
30879
30882
  code: "host",
@@ -30901,7 +30904,7 @@ function createOpenCodeVaultCustody(options) {
30901
30904
  const readEnrollmentSnapshot = async () => {
30902
30905
  if (layoutRefusal !== void 0)
30903
30906
  return { authority: "unreadable", status: unsettled };
30904
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
30907
+ if ((await loadClaustrum()).hasVaultHost())
30905
30908
  return { authority: "host", status: await readEnrollment() };
30906
30909
  const enrollment = await enrollmentPaths();
30907
30910
  const identity3 = await enrollmentFilesIdentity(enrollment);
@@ -31148,7 +31151,7 @@ function createOpenCodeVaultCustody(options) {
31148
31151
  },
31149
31152
  async requestAccess() {
31150
31153
  const claustrum = await loadClaustrum();
31151
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
31154
+ if (claustrum.hasVaultHost())
31152
31155
  throw new OpenCodeVaultCustodyError(
31153
31156
  claustrum.VAULT_HOST_CONNECT_REFUSAL
31154
31157
  );
@@ -31156,7 +31159,7 @@ function createOpenCodeVaultCustody(options) {
31156
31159
  },
31157
31160
  async useVault() {
31158
31161
  refuseUnsettled();
31159
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus") return;
31162
+ if ((await loadClaustrum()).hasVaultHost()) return;
31160
31163
  const enrollment = await readEnrollment();
31161
31164
  if (enrollment.state !== "approved")
31162
31165
  throw new OpenCodeVaultCustodyError(
@@ -31168,7 +31171,7 @@ function createOpenCodeVaultCustody(options) {
31168
31171
  async useLocal() {
31169
31172
  refuseUnsettled();
31170
31173
  const claustrum = await loadClaustrum();
31171
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
31174
+ if (claustrum.hasVaultHost())
31172
31175
  throw new OpenCodeVaultCustodyError(
31173
31176
  claustrum.VAULT_HOST_CONNECT_REFUSAL
31174
31177
  );
@@ -31203,7 +31206,7 @@ function createOpenCodeVaultCustody(options) {
31203
31206
  if (layoutRefusal !== void 0)
31204
31207
  return { lines: [`Vault: ${layoutRefusal}`], actions: [] };
31205
31208
  const claustrum = await loadClaustrum();
31206
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
31209
+ if (claustrum.hasVaultHost())
31207
31210
  return { lines: [claustrum.VAULT_HOST_STATUS], actions: [] };
31208
31211
  const status = await custody.status();
31209
31212
  const lines = statusLines(status);
@@ -33271,10 +33274,10 @@ var init_runtime_layout = __esm({
33271
33274
  import {
33272
33275
  appendFileSync as appendFileSync3,
33273
33276
  copyFileSync,
33274
- existsSync as existsSync3,
33277
+ existsSync as existsSync4,
33275
33278
  promises as fs,
33276
33279
  mkdirSync,
33277
- readFileSync,
33280
+ readFileSync as readFileSync2,
33278
33281
  renameSync as renameSync3,
33279
33282
  unlinkSync,
33280
33283
  writeFileSync
@@ -33349,7 +33352,7 @@ function migrateLegacyWindowsConfig() {
33349
33352
  getLegacyWindowsConfigDir(),
33350
33353
  "antigravity-accounts.json"
33351
33354
  );
33352
- if (!existsSync3(legacyPath) || existsSync3(newPath)) {
33355
+ if (!existsSync4(legacyPath) || existsSync4(newPath)) {
33353
33356
  return false;
33354
33357
  }
33355
33358
  try {
@@ -33383,15 +33386,15 @@ function resolveWindowsAccountAnchor(newPath, legacyPath) {
33383
33386
  const standard = resolve16(newPath);
33384
33387
  const legacy = resolve16(legacyPath);
33385
33388
  if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
33386
- const standardPointer = existsSync3(accountStorePointerPath(standard));
33387
- const legacyPointer = existsSync3(accountStorePointerPath(legacy));
33389
+ const standardPointer = existsSync4(accountStorePointerPath(standard));
33390
+ const legacyPointer = existsSync4(accountStorePointerPath(legacy));
33388
33391
  if (standardPointer && legacyPointer) {
33389
33392
  throw new Error(
33390
33393
  `Two migrated account stores exist: one is published at ${newPath} and another at ${legacyPath}. Keep one store and remove the other, then restart OpenCode.`
33391
33394
  );
33392
33395
  }
33393
33396
  if (legacyPointer && !standardPointer) return legacyPath;
33394
- if (!existsSync3(standard) && existsSync3(legacy)) return legacyPath;
33397
+ if (!existsSync4(standard) && existsSync4(legacy)) return legacyPath;
33395
33398
  return newPath;
33396
33399
  }
33397
33400
  function getStoragePathWithMigration() {
@@ -33403,7 +33406,7 @@ function getStoragePathWithMigration() {
33403
33406
  "antigravity-accounts.json"
33404
33407
  );
33405
33408
  const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
33406
- if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve16(anchored)))) {
33409
+ if (resolve16(anchored).toLowerCase() !== resolve16(newPath).toLowerCase() && !existsSync4(accountStorePointerPath(resolve16(anchored)))) {
33407
33410
  log6.info("Using legacy Windows config path (migration failed)", {
33408
33411
  legacyPath,
33409
33412
  newPath
@@ -33424,8 +33427,8 @@ function accountFileForVault(configDir = getConfigDir()) {
33424
33427
  return configured;
33425
33428
  const configuredVault = join15(configDir, "antigravity-auth-vault");
33426
33429
  const legacyVault = join15(legacyDir, "antigravity-auth-vault");
33427
- const configuredPresent = existsSync3(configuredVault);
33428
- const legacyPresent = existsSync3(legacyVault);
33430
+ const configuredPresent = existsSync4(configuredVault);
33431
+ const legacyPresent = existsSync4(legacyVault);
33429
33432
  if (configuredPresent && legacyPresent)
33430
33433
  throw new Error(
33431
33434
  `Two vault folders exist: ${configuredVault} and ${legacyVault}. Keep one vault enrollment before restarting OpenCode.`
@@ -33616,7 +33619,7 @@ var init_storage = __esm({
33616
33619
 
33617
33620
  // src/runtime-paths.ts
33618
33621
  import { createHash as createHash12 } from "node:crypto";
33619
- import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
33622
+ import { existsSync as existsSync5, promises as fs2, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
33620
33623
  import { homedir as homedir5 } from "node:os";
33621
33624
  import { dirname as dirname17, join as join16, resolve as resolve17 } from "node:path";
33622
33625
  function configDirIdentity(path5) {
@@ -33664,7 +33667,7 @@ function decidedAccountStoreAnchor(location) {
33664
33667
  return shared2.storeAnchors.get(`${location.stateHomeDir}\0${location.key}`);
33665
33668
  }
33666
33669
  function currentRuntimeLayout(location = runtimeLayoutLocation()) {
33667
- return decidedRuntimeLayout(location) ?? (existsSync4(join16(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
33670
+ return decidedRuntimeLayout(location) ?? (existsSync5(join16(location.stateHomeDir, RUNTIME_LAYOUT_MARKER_FILE)) ? "state-home" : "legacy");
33668
33671
  }
33669
33672
  function legacyWindowsConfigDir() {
33670
33673
  return join16(
@@ -33718,7 +33721,7 @@ function realPathOrSelf(path5) {
33718
33721
  function folderResolvesToItself(path5) {
33719
33722
  let current = dirname17(path5);
33720
33723
  for (; ; ) {
33721
- if (!existsSync4(current)) {
33724
+ if (!existsSync5(current)) {
33722
33725
  const parent = dirname17(current);
33723
33726
  if (parent === current) return true;
33724
33727
  current = parent;
@@ -33731,7 +33734,7 @@ function folderResolvesToItself(path5) {
33731
33734
  function readForwardedAccountStore(anchor) {
33732
33735
  let text2;
33733
33736
  try {
33734
- text2 = readFileSync2(accountStorePointerPath2(anchor), "utf8");
33737
+ text2 = readFileSync3(accountStorePointerPath2(anchor), "utf8");
33735
33738
  } catch {
33736
33739
  return void 0;
33737
33740
  }
@@ -34773,15 +34776,488 @@ async function registerOpenCode2AuthMethods(ctx, options) {
34773
34776
 
34774
34777
  // src/plugin/ga-location-services.ts
34775
34778
  init_dist();
34776
- init_vault_folder();
34777
34779
  import { randomBytes as randomBytes5 } from "node:crypto";
34778
34780
 
34779
- // src/plugin/account-access.ts
34781
+ // src/ga/server/pool-login.ts
34780
34782
  init_dist();
34781
34783
 
34784
+ // src/auth-method-labels.ts
34785
+ var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
34786
+ var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
34787
+ var OPENCODE2_POOL_RECONNECT_LABEL = "Use existing local Antigravity pool";
34788
+
34789
+ // src/plugin/server.ts
34790
+ import { existsSync as existsSync2, readFileSync } from "node:fs";
34791
+ import { createServer } from "node:http";
34792
+
34782
34793
  // src/constants.ts
34783
34794
  init_dist();
34784
34795
 
34796
+ // src/plugin/server.ts
34797
+ var redirectUri = new URL(ANTIGRAVITY_REDIRECT_URI);
34798
+ var callbackPath = redirectUri.pathname || "/";
34799
+ function isOrbStackDockerHost() {
34800
+ if (!existsSync2("/.dockerenv")) {
34801
+ return false;
34802
+ }
34803
+ try {
34804
+ if (existsSync2("/proc/version")) {
34805
+ const version = readFileSync("/proc/version", "utf8").toLowerCase();
34806
+ if (version.includes("orbstack")) {
34807
+ return true;
34808
+ }
34809
+ }
34810
+ const hostname = process.env.HOSTNAME || "";
34811
+ if (hostname.startsWith("orbstack-") || hostname.endsWith(".orb") || hostname === "orbstack") {
34812
+ return true;
34813
+ }
34814
+ if (existsSync2("/etc/resolv.conf")) {
34815
+ const resolv = readFileSync("/etc/resolv.conf", "utf8");
34816
+ if (resolv.includes("orb.local") || resolv.includes("orbstack")) {
34817
+ return true;
34818
+ }
34819
+ }
34820
+ if (process.platform === "linux" && existsSync2("/.dockerenv")) {
34821
+ if (existsSync2("/run/host-services")) {
34822
+ return true;
34823
+ }
34824
+ }
34825
+ } catch {
34826
+ }
34827
+ return false;
34828
+ }
34829
+ function isWSL() {
34830
+ if (process.platform !== "linux") return false;
34831
+ try {
34832
+ const release2 = readFileSync("/proc/version", "utf8").toLowerCase();
34833
+ return release2.includes("microsoft") || release2.includes("wsl");
34834
+ } catch {
34835
+ return false;
34836
+ }
34837
+ }
34838
+ function isRemoteEnvironment() {
34839
+ if (process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.SSH_CONNECTION) {
34840
+ return true;
34841
+ }
34842
+ if (process.env.REMOTE_CONTAINERS || process.env.CODESPACES) {
34843
+ return true;
34844
+ }
34845
+ return false;
34846
+ }
34847
+ function getBindAddress() {
34848
+ const envBind = process.env.OPENCODE_ANTIGRAVITY_OAUTH_BIND;
34849
+ if (envBind) {
34850
+ return envBind;
34851
+ }
34852
+ if (isOrbStackDockerHost()) {
34853
+ return "127.0.0.1";
34854
+ }
34855
+ if (isWSL() || isRemoteEnvironment()) {
34856
+ return "0.0.0.0";
34857
+ }
34858
+ return "127.0.0.1";
34859
+ }
34860
+ async function startOAuthListener({
34861
+ timeoutMs = 5 * 60 * 1e3
34862
+ } = {}) {
34863
+ const port = redirectUri.port ? Number.parseInt(redirectUri.port, 10) : redirectUri.protocol === "https:" ? 443 : 80;
34864
+ const origin = `${redirectUri.protocol}//${redirectUri.host}`;
34865
+ let settled = false;
34866
+ let resolveCallback;
34867
+ let rejectCallback;
34868
+ let timeoutHandle;
34869
+ const callbackPromise = new Promise((resolve28, reject) => {
34870
+ resolveCallback = (url) => {
34871
+ if (settled) return;
34872
+ settled = true;
34873
+ if (timeoutHandle) clearTimeout(timeoutHandle);
34874
+ resolve28(url);
34875
+ };
34876
+ rejectCallback = (error) => {
34877
+ if (settled) return;
34878
+ settled = true;
34879
+ if (timeoutHandle) clearTimeout(timeoutHandle);
34880
+ reject(error);
34881
+ };
34882
+ });
34883
+ const successResponse = `<!DOCTYPE html>
34884
+ <html lang="en">
34885
+ <head>
34886
+ <meta charset="utf-8" />
34887
+ <meta name="viewport" content="width=device-width, initial-scale=1">
34888
+ <title>Authentication Successful</title>
34889
+ <style>
34890
+ :root {
34891
+ --bg: #FAFAFA;
34892
+ --card-bg: #FFFFFF;
34893
+ --text-primary: #1F2937;
34894
+ --text-secondary: #6B7280;
34895
+ --accent: #2563EB;
34896
+ --success: #10B981;
34897
+ --border: #E5E7EB;
34898
+ }
34899
+ @media (prefers-color-scheme: dark) {
34900
+ :root {
34901
+ --bg: #111827;
34902
+ --card-bg: #1F2937;
34903
+ --text-primary: #F9FAFB;
34904
+ --text-secondary: #9CA3AF;
34905
+ --accent: #3B82F6;
34906
+ --success: #34D399;
34907
+ --border: #374151;
34908
+ }
34909
+ }
34910
+ body {
34911
+ margin: 0;
34912
+ min-height: 100vh;
34913
+ display: flex;
34914
+ align-items: center;
34915
+ justify-content: center;
34916
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
34917
+ background: var(--bg);
34918
+ color: var(--text-primary);
34919
+ padding: 1rem;
34920
+ }
34921
+ .card {
34922
+ background: var(--card-bg);
34923
+ border-radius: 16px;
34924
+ padding: 3rem 2rem;
34925
+ width: 100%;
34926
+ max-width: 400px;
34927
+ text-align: center;
34928
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
34929
+ border: 1px solid var(--border);
34930
+ }
34931
+ .icon-wrapper {
34932
+ width: 64px;
34933
+ height: 64px;
34934
+ background: rgba(16, 185, 129, 0.1);
34935
+ border-radius: 50%;
34936
+ display: flex;
34937
+ align-items: center;
34938
+ justify-content: center;
34939
+ margin: 0 auto 1.5rem;
34940
+ }
34941
+ .icon {
34942
+ width: 32px;
34943
+ height: 32px;
34944
+ color: var(--success);
34945
+ }
34946
+ h1 {
34947
+ font-size: 1.5rem;
34948
+ font-weight: 600;
34949
+ margin: 0 0 0.5rem;
34950
+ letter-spacing: -0.025em;
34951
+ }
34952
+ p {
34953
+ color: var(--text-secondary);
34954
+ font-size: 0.95rem;
34955
+ line-height: 1.5;
34956
+ margin: 0 0 2rem;
34957
+ }
34958
+ .btn {
34959
+ display: inline-flex;
34960
+ align-items: center;
34961
+ justify-content: center;
34962
+ background: var(--text-primary);
34963
+ color: var(--card-bg);
34964
+ font-weight: 500;
34965
+ padding: 0.75rem 1.5rem;
34966
+ border-radius: 8px;
34967
+ text-decoration: none;
34968
+ transition: opacity 0.2s;
34969
+ font-size: 0.95rem;
34970
+ border: none;
34971
+ cursor: pointer;
34972
+ width: 100%;
34973
+ box-sizing: border-box;
34974
+ }
34975
+ .btn:hover {
34976
+ opacity: 0.9;
34977
+ }
34978
+ .sub-text {
34979
+ margin-top: 1rem;
34980
+ font-size: 0.8rem;
34981
+ color: var(--text-secondary);
34982
+ }
34983
+ </style>
34984
+ </head>
34985
+ <body>
34986
+ <div class="card">
34987
+ <div class="icon-wrapper">
34988
+ <svg class="icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
34989
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7" />
34990
+ </svg>
34991
+ </div>
34992
+ <h1>All set!</h1>
34993
+ <p>You've successfully authenticated with Antigravity. You can now return to Opencode.</p>
34994
+ <button class="btn" onclick="closeWindow()">Close this tab</button>
34995
+ <div class="sub-text">Usage Tip: Most browsers block auto-closing. If the button doesn't work, please close the tab manually.</div>
34996
+ </div>
34997
+ <script>
34998
+ function closeWindow() {
34999
+ window.close();
35000
+ // Fallback if window.close() is blocked
35001
+ document.querySelector('.btn').textContent = "Tab cannot be closed automatically";
35002
+ document.querySelector('.btn').style.opacity = "0.5";
35003
+ document.querySelector('.btn').style.cursor = "default";
35004
+ }
35005
+ </script>
35006
+ </body>
35007
+ </html>`;
35008
+ try {
35009
+ timeoutHandle = setTimeout(() => {
35010
+ rejectCallback(new Error("Timed out waiting for OAuth callback"));
35011
+ }, timeoutMs);
35012
+ timeoutHandle.unref?.();
35013
+ const server = createServer((request2, response) => {
35014
+ if (!request2.url) {
35015
+ response.writeHead(400, { "Content-Type": "text/plain" });
35016
+ response.end("Invalid request");
35017
+ return;
35018
+ }
35019
+ const url = new URL(request2.url, origin);
35020
+ if (url.pathname !== callbackPath) {
35021
+ response.writeHead(404, { "Content-Type": "text/plain" });
35022
+ response.end("Not found");
35023
+ return;
35024
+ }
35025
+ response.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
35026
+ response.end(successResponse);
35027
+ resolveCallback(url);
35028
+ setImmediate(() => {
35029
+ server.close();
35030
+ });
35031
+ });
35032
+ const bindAddress = getBindAddress();
35033
+ await new Promise((resolve28, reject) => {
35034
+ const handleError = (error) => {
35035
+ server.off("error", handleError);
35036
+ if (error.code === "EADDRINUSE") {
35037
+ reject(
35038
+ new Error(
35039
+ `Port ${port} is already in use. Another process is occupying this port. Please terminate the process or try again later.`
35040
+ )
35041
+ );
35042
+ return;
35043
+ }
35044
+ reject(error);
35045
+ };
35046
+ server.once("error", handleError);
35047
+ server.listen(port, bindAddress, () => {
35048
+ server.off("error", handleError);
35049
+ resolve28();
35050
+ });
35051
+ });
35052
+ server.on("error", (error) => {
35053
+ rejectCallback(error instanceof Error ? error : new Error(String(error)));
35054
+ });
35055
+ return {
35056
+ waitForCallback: () => callbackPromise,
35057
+ close: () => new Promise((resolve28, reject) => {
35058
+ server.close((error) => {
35059
+ if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
35060
+ reject(error);
35061
+ return;
35062
+ }
35063
+ if (!settled) {
35064
+ rejectCallback(new Error("OAuth listener closed before callback"));
35065
+ }
35066
+ resolve28();
35067
+ });
35068
+ })
35069
+ };
35070
+ } catch (error) {
35071
+ if (timeoutHandle) clearTimeout(timeoutHandle);
35072
+ throw error;
35073
+ }
35074
+ }
35075
+
35076
+ // src/ga/server/pool-login.ts
35077
+ var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
35078
+ var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
35079
+ var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
35080
+ function abortable(pending, signal) {
35081
+ return new Promise((resolve28, reject) => {
35082
+ const abort = () => reject(signal.reason);
35083
+ if (signal.aborted) abort();
35084
+ else signal.addEventListener("abort", abort, { once: true });
35085
+ void pending.then(resolve28, reject).finally(() => {
35086
+ signal.removeEventListener("abort", abort);
35087
+ });
35088
+ });
35089
+ }
35090
+ function createGaPoolLogin(input2) {
35091
+ const shutdown = new AbortController();
35092
+ const listeners = /* @__PURE__ */ new Set();
35093
+ const pending = /* @__PURE__ */ new Set();
35094
+ const track = (work) => {
35095
+ pending.add(work);
35096
+ void work.then(
35097
+ () => pending.delete(work),
35098
+ () => pending.delete(work)
35099
+ );
35100
+ return work;
35101
+ };
35102
+ const admit2 = async () => {
35103
+ try {
35104
+ shutdown.signal.throwIfAborted();
35105
+ if (!input2.local) throw new Error(LOGIN_FAILED);
35106
+ await input2.local.assertAdmission();
35107
+ shutdown.signal.throwIfAborted();
35108
+ } catch {
35109
+ throw new Error(LOGIN_FAILED);
35110
+ }
35111
+ };
35112
+ const close = async (listener) => {
35113
+ try {
35114
+ await listener.close();
35115
+ } finally {
35116
+ listeners.delete(listener);
35117
+ }
35118
+ };
35119
+ const method = {
35120
+ method: {
35121
+ id: GA_POOL_METHOD_ID,
35122
+ type: "oauth",
35123
+ label: OPENCODE2_POOL_AUTH_LABEL
35124
+ },
35125
+ authorize: () => track(
35126
+ (async () => {
35127
+ await admit2();
35128
+ const authorization = await (async () => {
35129
+ try {
35130
+ return await abortable(
35131
+ (input2.oauth?.authorize ?? authorizeAntigravity)(),
35132
+ shutdown.signal
35133
+ );
35134
+ } catch {
35135
+ throw new Error(LOGIN_FAILED);
35136
+ }
35137
+ })();
35138
+ await admit2();
35139
+ const state = new URL(authorization.url).searchParams.get("state");
35140
+ if (!state) throw new Error(LOGIN_FAILED);
35141
+ let listener;
35142
+ let code2;
35143
+ const waitForCode = input2.oauth?.waitForCode;
35144
+ if (waitForCode) {
35145
+ code2 = Promise.resolve().then(() => waitForCode(state));
35146
+ } else {
35147
+ listener = await startOAuthListener();
35148
+ listeners.add(listener);
35149
+ code2 = listener.waitForCallback().then((url) => {
35150
+ if (url.searchParams.get("state") !== state)
35151
+ throw new Error(LOGIN_FAILED);
35152
+ const value = url.searchParams.get("code");
35153
+ if (!value) throw new Error(LOGIN_FAILED);
35154
+ return value;
35155
+ });
35156
+ }
35157
+ void code2.catch(() => {
35158
+ });
35159
+ try {
35160
+ await admit2();
35161
+ } catch (error) {
35162
+ if (listener) await close(listener);
35163
+ throw error;
35164
+ }
35165
+ const ownedListener = listener;
35166
+ const callback = track(
35167
+ (async () => {
35168
+ try {
35169
+ await admit2();
35170
+ const value = await abortable(code2, shutdown.signal);
35171
+ await admit2();
35172
+ const result = await abortable(
35173
+ (input2.oauth?.exchange ?? exchangeAntigravity)(value, state, {
35174
+ signal: shutdown.signal,
35175
+ admit: admit2
35176
+ }),
35177
+ shutdown.signal
35178
+ );
35179
+ await admit2();
35180
+ if (result.type !== "success") throw new Error(LOGIN_FAILED);
35181
+ return result;
35182
+ } catch {
35183
+ throw new Error(LOGIN_FAILED);
35184
+ } finally {
35185
+ if (ownedListener) await close(ownedListener);
35186
+ }
35187
+ })()
35188
+ );
35189
+ void callback.catch(() => {
35190
+ });
35191
+ return {
35192
+ mode: "auto",
35193
+ url: authorization.url,
35194
+ instructions: "Complete Google sign-in in your browser.",
35195
+ callback
35196
+ };
35197
+ })()
35198
+ )
35199
+ };
35200
+ return {
35201
+ method,
35202
+ connectExisting: () => track(
35203
+ (async () => {
35204
+ let stage = "initial-admission";
35205
+ try {
35206
+ await admit2();
35207
+ if (!input2.local?.assertExistingPool) throw new Error(LOGIN_FAILED);
35208
+ stage = "existing-pool-admission";
35209
+ await abortable(
35210
+ track(input2.local.assertExistingPool(admit2)),
35211
+ shutdown.signal
35212
+ );
35213
+ stage = "final-admission";
35214
+ await admit2();
35215
+ stage = "placeholder";
35216
+ return placeholderCredential({
35217
+ integrationID: ANTIGRAVITY_PROVIDER_ID,
35218
+ methodID: GA_POOL_RECONNECT_METHOD_ID,
35219
+ now: Date.now()
35220
+ });
35221
+ } catch (error) {
35222
+ const busy = error instanceof AccountStoreBusyError;
35223
+ try {
35224
+ console.warn(
35225
+ `[antigravity.pool-login] stage=${stage} reason=${busy ? "store-busy" : "store-refusal"}`
35226
+ );
35227
+ } catch {
35228
+ }
35229
+ if (busy) throw new AccountStoreBusyError();
35230
+ throw new Error(LOGIN_FAILED);
35231
+ }
35232
+ })()
35233
+ ),
35234
+ onLogin: (result) => track(
35235
+ (async () => {
35236
+ try {
35237
+ await admit2();
35238
+ await input2.local.persist(result, admit2);
35239
+ await admit2();
35240
+ } catch (error) {
35241
+ if (error instanceof AccountStoreBusyError)
35242
+ throw new AccountStoreBusyError();
35243
+ throw new Error(LOGIN_FAILED);
35244
+ }
35245
+ })()
35246
+ ),
35247
+ async dispose() {
35248
+ shutdown.abort(new Error(LOGIN_FAILED));
35249
+ await Promise.allSettled([...listeners].map(close));
35250
+ while (pending.size) await Promise.allSettled([...pending]);
35251
+ }
35252
+ };
35253
+ }
35254
+
35255
+ // src/plugin/ga-location-services.ts
35256
+ init_vault_folder();
35257
+
35258
+ // src/plugin/account-access.ts
35259
+ init_dist();
35260
+
34785
35261
  // src/plugin/account-blocks.ts
34786
35262
  function present3(value) {
34787
35263
  return value === null ? void 0 : value;
@@ -35851,13 +36327,13 @@ init_dist();
35851
36327
 
35852
36328
  // src/plugin/operator-settings.ts
35853
36329
  import { createHash as createHash13 } from "node:crypto";
35854
- import { existsSync as existsSync7, readFileSync as readFileSync5 } from "node:fs";
36330
+ import { existsSync as existsSync8, readFileSync as readFileSync6 } from "node:fs";
35855
36331
  import { z as z4 } from "zod";
35856
36332
 
35857
36333
  // src/plugin/config/loader.ts
35858
36334
  init_runtime_paths();
35859
36335
  init_logger4();
35860
- import { existsSync as existsSync5, readFileSync as readFileSync3, realpathSync as realpathSync3 } from "node:fs";
36336
+ import { existsSync as existsSync6, readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
35861
36337
  import { homedir as homedir6 } from "node:os";
35862
36338
  import { basename as basename5, dirname as dirname18, join as join18, resolve as resolve18 } from "node:path";
35863
36339
 
@@ -36365,10 +36841,10 @@ function getProjectConfigPath(directory) {
36365
36841
  }
36366
36842
  function loadConfigFile(path5, log17) {
36367
36843
  try {
36368
- if (!existsSync5(path5)) {
36844
+ if (!existsSync6(path5)) {
36369
36845
  return null;
36370
36846
  }
36371
- const content = readFileSync3(path5, "utf-8");
36847
+ const content = readFileSync4(path5, "utf-8");
36372
36848
  const rawConfig = JSON.parse(content);
36373
36849
  const result = AntigravityConfigSchema.partial().safeParse(rawConfig);
36374
36850
  if (!result.success) {
@@ -36473,11 +36949,11 @@ function emptyOperatorSettings() {
36473
36949
  }
36474
36950
 
36475
36951
  // src/plugin/config/writer.ts
36476
- import { existsSync as existsSync6, readFileSync as readFileSync4 } from "node:fs";
36952
+ import { existsSync as existsSync7, readFileSync as readFileSync5 } from "node:fs";
36477
36953
  init_dist();
36478
36954
  import { z as z3 } from "zod";
36479
36955
  async function writeOperatorConfig(options) {
36480
- const target = existsSync6(options.projectConfigPath) ? options.projectConfigPath : options.userConfigPath;
36956
+ const target = existsSync7(options.projectConfigPath) ? options.projectConfigPath : options.userConfigPath;
36481
36957
  await writeOperatorConfigAt(target, options.operator);
36482
36958
  }
36483
36959
  async function writeOperatorConfigAt(target, settings) {
@@ -36503,9 +36979,9 @@ async function writeOperatorConfigAt(target, settings) {
36503
36979
  }
36504
36980
  }
36505
36981
  function readExistingConfig(target) {
36506
- if (!existsSync6(target)) return {};
36982
+ if (!existsSync7(target)) return {};
36507
36983
  try {
36508
- const raw = readFileSync4(target, "utf-8");
36984
+ const raw = readFileSync5(target, "utf-8");
36509
36985
  const parsed = JSON.parse(raw);
36510
36986
  if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
36511
36987
  return parsed;
@@ -36644,7 +37120,7 @@ function acquireLocationOperatorSettings(options) {
36644
37120
  sourcePath: () => projectBound() ? project3.path : user.path,
36645
37121
  async update(mutator) {
36646
37122
  if (disposed) throw new Error("OperatorSettingsController is disposed");
36647
- const target = existsSync7(project3.path) ? project3 : user;
37123
+ const target = existsSync8(project3.path) ? project3 : user;
36648
37124
  const seed = target === project3 ? () => user.read() ?? emptyOperatorSettings() : emptyOperatorSettings;
36649
37125
  const run = target.update(seed, mutator);
36650
37126
  pending = run.catch(() => {
@@ -36665,7 +37141,7 @@ function cloneSettings(settings) {
36665
37141
  }
36666
37142
  function readOperatorFile(path5) {
36667
37143
  try {
36668
- const raw = readFileSync5(path5, "utf-8");
37144
+ const raw = readFileSync6(path5, "utf-8");
36669
37145
  const parsed = JSON.parse(raw);
36670
37146
  if (parsed === null || typeof parsed !== "object" || !("operator" in parsed)) {
36671
37147
  return null;
@@ -36817,7 +37293,7 @@ import { resolve as resolve19 } from "node:path";
36817
37293
  // src/sidebar-state.ts
36818
37294
  init_atomic_write();
36819
37295
  init_file_lock();
36820
- import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync6 } from "node:fs";
37296
+ import { chmodSync as chmodSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync7 } from "node:fs";
36821
37297
  import { homedir as homedir7 } from "node:os";
36822
37298
  import { dirname as dirname19, join as join19 } from "node:path";
36823
37299
 
@@ -36884,7 +37360,7 @@ function getSidebarStateFile() {
36884
37360
  function readSidebarState(path5 = getSidebarStateFile()) {
36885
37361
  let raw;
36886
37362
  try {
36887
- raw = readFileSync6(path5, "utf-8");
37363
+ raw = readFileSync7(path5, "utf-8");
36888
37364
  } catch {
36889
37365
  return { ...DEFAULT_SIDEBAR_STATE };
36890
37366
  }
@@ -36898,7 +37374,7 @@ function readSidebarState(path5 = getSidebarStateFile()) {
36898
37374
  }
36899
37375
  function readSidebarStateVersion(path5) {
36900
37376
  try {
36901
- const parsed = JSON.parse(readFileSync6(path5, "utf-8"));
37377
+ const parsed = JSON.parse(readFileSync7(path5, "utf-8"));
36902
37378
  if (!isObject(parsed)) return;
36903
37379
  const version = parsed.version;
36904
37380
  return typeof version === "number" ? version : void 0;
@@ -39006,9 +39482,9 @@ import { createHash as createHash14 } from "node:crypto";
39006
39482
  // src/plugin/cache/signature-cache.ts
39007
39483
  init_runtime_paths();
39008
39484
  import {
39009
- existsSync as existsSync8,
39485
+ existsSync as existsSync9,
39010
39486
  mkdirSync as mkdirSync4,
39011
- readFileSync as readFileSync7,
39487
+ readFileSync as readFileSync8,
39012
39488
  renameSync as renameSync4,
39013
39489
  unlinkSync as unlinkSync3,
39014
39490
  writeFileSync as writeFileSync2
@@ -39224,10 +39700,10 @@ var SignatureCache = class {
39224
39700
  */
39225
39701
  loadFromDisk() {
39226
39702
  try {
39227
- if (!existsSync8(this.cacheFilePath)) {
39703
+ if (!existsSync9(this.cacheFilePath)) {
39228
39704
  return;
39229
39705
  }
39230
- const content = readFileSync7(this.cacheFilePath, "utf-8");
39706
+ const content = readFileSync8(this.cacheFilePath, "utf-8");
39231
39707
  const data = JSON.parse(content);
39232
39708
  if (data.version !== "1.0") {
39233
39709
  return;
@@ -39258,14 +39734,14 @@ var SignatureCache = class {
39258
39734
  saveToDisk() {
39259
39735
  try {
39260
39736
  const dir = dirname20(this.cacheFilePath);
39261
- if (!existsSync8(dir)) {
39737
+ if (!existsSync9(dir)) {
39262
39738
  mkdirSync4(dir, { recursive: true });
39263
39739
  }
39264
39740
  const now = this.now();
39265
39741
  let existingEntries = {};
39266
- if (existsSync8(this.cacheFilePath)) {
39742
+ if (existsSync9(this.cacheFilePath)) {
39267
39743
  try {
39268
- const content = readFileSync7(this.cacheFilePath, "utf-8");
39744
+ const content = readFileSync8(this.cacheFilePath, "utf-8");
39269
39745
  const data = JSON.parse(content);
39270
39746
  existingEntries = data.entries || {};
39271
39747
  } catch {
@@ -39306,7 +39782,7 @@ var SignatureCache = class {
39306
39782
  try {
39307
39783
  renameSync4(tmpPath, this.cacheFilePath);
39308
39784
  } catch {
39309
- writeFileSync2(this.cacheFilePath, readFileSync7(tmpPath));
39785
+ writeFileSync2(this.cacheFilePath, readFileSync8(tmpPath));
39310
39786
  try {
39311
39787
  unlinkSync3(tmpPath);
39312
39788
  } catch {
@@ -39653,12 +40129,12 @@ function clearSignatureCache(sessionId) {
39653
40129
  }
39654
40130
 
39655
40131
  // src/plugin/image-saver.ts
39656
- import { chmodSync as chmodSync4, existsSync as existsSync9, mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
40132
+ import { chmodSync as chmodSync4, existsSync as existsSync10, mkdirSync as mkdirSync5, writeFileSync as writeFileSync3 } from "node:fs";
39657
40133
  import { homedir as homedir8 } from "node:os";
39658
40134
  import { join as join21 } from "node:path";
39659
40135
  function getImageOutputDir(outputDir) {
39660
40136
  const resolved = outputDir ?? join21(homedir8(), ".opencode", "generated-images");
39661
- if (!existsSync9(resolved)) {
40137
+ if (!existsSync10(resolved)) {
39662
40138
  mkdirSync5(resolved, { recursive: true, mode: 448 });
39663
40139
  }
39664
40140
  chmodSync4(resolved, 448);
@@ -40362,10 +40838,10 @@ init_logger4();
40362
40838
 
40363
40839
  // src/plugin/recovery/storage.ts
40364
40840
  import {
40365
- existsSync as existsSync10,
40841
+ existsSync as existsSync11,
40366
40842
  mkdirSync as mkdirSync7,
40367
40843
  readdirSync as readdirSync2,
40368
- readFileSync as readFileSync8,
40844
+ readFileSync as readFileSync9,
40369
40845
  unlinkSync as unlinkSync4,
40370
40846
  writeFileSync as writeFileSync5
40371
40847
  } from "node:fs";
@@ -40392,15 +40868,15 @@ var THINKING_TYPES = /* @__PURE__ */ new Set([
40392
40868
 
40393
40869
  // src/plugin/recovery/storage.ts
40394
40870
  function getMessageDir(sessionID) {
40395
- if (!existsSync10(MESSAGE_STORAGE)) return "";
40871
+ if (!existsSync11(MESSAGE_STORAGE)) return "";
40396
40872
  const directPath = join24(MESSAGE_STORAGE, sessionID);
40397
- if (existsSync10(directPath)) {
40873
+ if (existsSync11(directPath)) {
40398
40874
  return directPath;
40399
40875
  }
40400
40876
  try {
40401
40877
  for (const dir of readdirSync2(MESSAGE_STORAGE)) {
40402
40878
  const sessionPath = join24(MESSAGE_STORAGE, dir, sessionID);
40403
- if (existsSync10(sessionPath)) {
40879
+ if (existsSync11(sessionPath)) {
40404
40880
  return sessionPath;
40405
40881
  }
40406
40882
  }
@@ -40410,13 +40886,13 @@ function getMessageDir(sessionID) {
40410
40886
  }
40411
40887
  function readMessages(sessionID) {
40412
40888
  const messageDir = getMessageDir(sessionID);
40413
- if (!messageDir || !existsSync10(messageDir)) return [];
40889
+ if (!messageDir || !existsSync11(messageDir)) return [];
40414
40890
  const messages = [];
40415
40891
  try {
40416
40892
  for (const file of readdirSync2(messageDir)) {
40417
40893
  if (!file.endsWith(".json")) continue;
40418
40894
  try {
40419
- const content = readFileSync8(join24(messageDir, file), "utf-8");
40895
+ const content = readFileSync9(join24(messageDir, file), "utf-8");
40420
40896
  messages.push(JSON.parse(content));
40421
40897
  } catch {
40422
40898
  }
@@ -40433,13 +40909,13 @@ function readMessages(sessionID) {
40433
40909
  }
40434
40910
  function readParts(messageID) {
40435
40911
  const partDir = join24(PART_STORAGE, messageID);
40436
- if (!existsSync10(partDir)) return [];
40912
+ if (!existsSync11(partDir)) return [];
40437
40913
  const parts = [];
40438
40914
  try {
40439
40915
  for (const file of readdirSync2(partDir)) {
40440
40916
  if (!file.endsWith(".json")) continue;
40441
40917
  try {
40442
- const content = readFileSync8(join24(partDir, file), "utf-8");
40918
+ const content = readFileSync9(join24(partDir, file), "utf-8");
40443
40919
  parts.push(JSON.parse(content));
40444
40920
  } catch {
40445
40921
  }
@@ -40483,7 +40959,7 @@ function findMessagesWithOrphanThinking(sessionID) {
40483
40959
  function prependThinkingPart(sessionID, messageID) {
40484
40960
  const partDir = join24(PART_STORAGE, messageID);
40485
40961
  try {
40486
- if (!existsSync10(partDir)) {
40962
+ if (!existsSync11(partDir)) {
40487
40963
  mkdirSync7(partDir, { recursive: true });
40488
40964
  }
40489
40965
  const partId = "prt_0000000000_thinking";
@@ -40506,14 +40982,14 @@ function prependThinkingPart(sessionID, messageID) {
40506
40982
  }
40507
40983
  function stripThinkingParts(messageID) {
40508
40984
  const partDir = join24(PART_STORAGE, messageID);
40509
- if (!existsSync10(partDir)) return false;
40985
+ if (!existsSync11(partDir)) return false;
40510
40986
  let anyRemoved = false;
40511
40987
  try {
40512
40988
  for (const file of readdirSync2(partDir)) {
40513
40989
  if (!file.endsWith(".json")) continue;
40514
40990
  try {
40515
40991
  const filePath = join24(partDir, file);
40516
- const content = readFileSync8(filePath, "utf-8");
40992
+ const content = readFileSync9(filePath, "utf-8");
40517
40993
  const part = JSON.parse(content);
40518
40994
  if (THINKING_TYPES.has(part.type)) {
40519
40995
  unlinkSync4(filePath);
@@ -44760,288 +45236,6 @@ function transformAntigravityResponse(...args) {
44760
45236
  return transformAntigravityResponseIn(openCode1WireLocation, ...args);
44761
45237
  }
44762
45238
 
44763
- // src/plugin/server.ts
44764
- import { existsSync as existsSync11, readFileSync as readFileSync9 } from "node:fs";
44765
- import { createServer } from "node:http";
44766
- var redirectUri = new URL(ANTIGRAVITY_REDIRECT_URI);
44767
- var callbackPath = redirectUri.pathname || "/";
44768
- function isOrbStackDockerHost() {
44769
- if (!existsSync11("/.dockerenv")) {
44770
- return false;
44771
- }
44772
- try {
44773
- if (existsSync11("/proc/version")) {
44774
- const version = readFileSync9("/proc/version", "utf8").toLowerCase();
44775
- if (version.includes("orbstack")) {
44776
- return true;
44777
- }
44778
- }
44779
- const hostname = process.env.HOSTNAME || "";
44780
- if (hostname.startsWith("orbstack-") || hostname.endsWith(".orb") || hostname === "orbstack") {
44781
- return true;
44782
- }
44783
- if (existsSync11("/etc/resolv.conf")) {
44784
- const resolv = readFileSync9("/etc/resolv.conf", "utf8");
44785
- if (resolv.includes("orb.local") || resolv.includes("orbstack")) {
44786
- return true;
44787
- }
44788
- }
44789
- if (process.platform === "linux" && existsSync11("/.dockerenv")) {
44790
- if (existsSync11("/run/host-services")) {
44791
- return true;
44792
- }
44793
- }
44794
- } catch {
44795
- }
44796
- return false;
44797
- }
44798
- function isWSL() {
44799
- if (process.platform !== "linux") return false;
44800
- try {
44801
- const release2 = readFileSync9("/proc/version", "utf8").toLowerCase();
44802
- return release2.includes("microsoft") || release2.includes("wsl");
44803
- } catch {
44804
- return false;
44805
- }
44806
- }
44807
- function isRemoteEnvironment() {
44808
- if (process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.SSH_CONNECTION) {
44809
- return true;
44810
- }
44811
- if (process.env.REMOTE_CONTAINERS || process.env.CODESPACES) {
44812
- return true;
44813
- }
44814
- return false;
44815
- }
44816
- function getBindAddress() {
44817
- const envBind = process.env.OPENCODE_ANTIGRAVITY_OAUTH_BIND;
44818
- if (envBind) {
44819
- return envBind;
44820
- }
44821
- if (isOrbStackDockerHost()) {
44822
- return "127.0.0.1";
44823
- }
44824
- if (isWSL() || isRemoteEnvironment()) {
44825
- return "0.0.0.0";
44826
- }
44827
- return "127.0.0.1";
44828
- }
44829
- async function startOAuthListener({
44830
- timeoutMs = 5 * 60 * 1e3
44831
- } = {}) {
44832
- const port = redirectUri.port ? Number.parseInt(redirectUri.port, 10) : redirectUri.protocol === "https:" ? 443 : 80;
44833
- const origin = `${redirectUri.protocol}//${redirectUri.host}`;
44834
- let settled = false;
44835
- let resolveCallback;
44836
- let rejectCallback;
44837
- let timeoutHandle;
44838
- const callbackPromise = new Promise((resolve28, reject) => {
44839
- resolveCallback = (url) => {
44840
- if (settled) return;
44841
- settled = true;
44842
- if (timeoutHandle) clearTimeout(timeoutHandle);
44843
- resolve28(url);
44844
- };
44845
- rejectCallback = (error) => {
44846
- if (settled) return;
44847
- settled = true;
44848
- if (timeoutHandle) clearTimeout(timeoutHandle);
44849
- reject(error);
44850
- };
44851
- });
44852
- const successResponse = `<!DOCTYPE html>
44853
- <html lang="en">
44854
- <head>
44855
- <meta charset="utf-8" />
44856
- <meta name="viewport" content="width=device-width, initial-scale=1">
44857
- <title>Authentication Successful</title>
44858
- <style>
44859
- :root {
44860
- --bg: #FAFAFA;
44861
- --card-bg: #FFFFFF;
44862
- --text-primary: #1F2937;
44863
- --text-secondary: #6B7280;
44864
- --accent: #2563EB;
44865
- --success: #10B981;
44866
- --border: #E5E7EB;
44867
- }
44868
- @media (prefers-color-scheme: dark) {
44869
- :root {
44870
- --bg: #111827;
44871
- --card-bg: #1F2937;
44872
- --text-primary: #F9FAFB;
44873
- --text-secondary: #9CA3AF;
44874
- --accent: #3B82F6;
44875
- --success: #34D399;
44876
- --border: #374151;
44877
- }
44878
- }
44879
- body {
44880
- margin: 0;
44881
- min-height: 100vh;
44882
- display: flex;
44883
- align-items: center;
44884
- justify-content: center;
44885
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
44886
- background: var(--bg);
44887
- color: var(--text-primary);
44888
- padding: 1rem;
44889
- }
44890
- .card {
44891
- background: var(--card-bg);
44892
- border-radius: 16px;
44893
- padding: 3rem 2rem;
44894
- width: 100%;
44895
- max-width: 400px;
44896
- text-align: center;
44897
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
44898
- border: 1px solid var(--border);
44899
- }
44900
- .icon-wrapper {
44901
- width: 64px;
44902
- height: 64px;
44903
- background: rgba(16, 185, 129, 0.1);
44904
- border-radius: 50%;
44905
- display: flex;
44906
- align-items: center;
44907
- justify-content: center;
44908
- margin: 0 auto 1.5rem;
44909
- }
44910
- .icon {
44911
- width: 32px;
44912
- height: 32px;
44913
- color: var(--success);
44914
- }
44915
- h1 {
44916
- font-size: 1.5rem;
44917
- font-weight: 600;
44918
- margin: 0 0 0.5rem;
44919
- letter-spacing: -0.025em;
44920
- }
44921
- p {
44922
- color: var(--text-secondary);
44923
- font-size: 0.95rem;
44924
- line-height: 1.5;
44925
- margin: 0 0 2rem;
44926
- }
44927
- .btn {
44928
- display: inline-flex;
44929
- align-items: center;
44930
- justify-content: center;
44931
- background: var(--text-primary);
44932
- color: var(--card-bg);
44933
- font-weight: 500;
44934
- padding: 0.75rem 1.5rem;
44935
- border-radius: 8px;
44936
- text-decoration: none;
44937
- transition: opacity 0.2s;
44938
- font-size: 0.95rem;
44939
- border: none;
44940
- cursor: pointer;
44941
- width: 100%;
44942
- box-sizing: border-box;
44943
- }
44944
- .btn:hover {
44945
- opacity: 0.9;
44946
- }
44947
- .sub-text {
44948
- margin-top: 1rem;
44949
- font-size: 0.8rem;
44950
- color: var(--text-secondary);
44951
- }
44952
- </style>
44953
- </head>
44954
- <body>
44955
- <div class="card">
44956
- <div class="icon-wrapper">
44957
- <svg class="icon" fill="none" viewBox="0 0 24 24" stroke="currentColor">
44958
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7" />
44959
- </svg>
44960
- </div>
44961
- <h1>All set!</h1>
44962
- <p>You've successfully authenticated with Antigravity. You can now return to Opencode.</p>
44963
- <button class="btn" onclick="closeWindow()">Close this tab</button>
44964
- <div class="sub-text">Usage Tip: Most browsers block auto-closing. If the button doesn't work, please close the tab manually.</div>
44965
- </div>
44966
- <script>
44967
- function closeWindow() {
44968
- window.close();
44969
- // Fallback if window.close() is blocked
44970
- document.querySelector('.btn').textContent = "Tab cannot be closed automatically";
44971
- document.querySelector('.btn').style.opacity = "0.5";
44972
- document.querySelector('.btn').style.cursor = "default";
44973
- }
44974
- </script>
44975
- </body>
44976
- </html>`;
44977
- try {
44978
- timeoutHandle = setTimeout(() => {
44979
- rejectCallback(new Error("Timed out waiting for OAuth callback"));
44980
- }, timeoutMs);
44981
- timeoutHandle.unref?.();
44982
- const server = createServer((request2, response) => {
44983
- if (!request2.url) {
44984
- response.writeHead(400, { "Content-Type": "text/plain" });
44985
- response.end("Invalid request");
44986
- return;
44987
- }
44988
- const url = new URL(request2.url, origin);
44989
- if (url.pathname !== callbackPath) {
44990
- response.writeHead(404, { "Content-Type": "text/plain" });
44991
- response.end("Not found");
44992
- return;
44993
- }
44994
- response.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
44995
- response.end(successResponse);
44996
- resolveCallback(url);
44997
- setImmediate(() => {
44998
- server.close();
44999
- });
45000
- });
45001
- const bindAddress = getBindAddress();
45002
- await new Promise((resolve28, reject) => {
45003
- const handleError = (error) => {
45004
- server.off("error", handleError);
45005
- if (error.code === "EADDRINUSE") {
45006
- reject(
45007
- new Error(
45008
- `Port ${port} is already in use. Another process is occupying this port. Please terminate the process or try again later.`
45009
- )
45010
- );
45011
- return;
45012
- }
45013
- reject(error);
45014
- };
45015
- server.once("error", handleError);
45016
- server.listen(port, bindAddress, () => {
45017
- server.off("error", handleError);
45018
- resolve28();
45019
- });
45020
- });
45021
- server.on("error", (error) => {
45022
- rejectCallback(error instanceof Error ? error : new Error(String(error)));
45023
- });
45024
- return {
45025
- waitForCallback: () => callbackPromise,
45026
- close: () => new Promise((resolve28, reject) => {
45027
- server.close((error) => {
45028
- if (error && error.code !== "ERR_SERVER_NOT_RUNNING") {
45029
- reject(error);
45030
- return;
45031
- }
45032
- if (!settled) {
45033
- rejectCallback(new Error("OAuth listener closed before callback"));
45034
- }
45035
- resolve28();
45036
- });
45037
- })
45038
- };
45039
- } catch (error) {
45040
- if (timeoutHandle) clearTimeout(timeoutHandle);
45041
- throw error;
45042
- }
45043
- }
45044
-
45045
45239
  // src/plugin/session-context.ts
45046
45240
  import { resolve as resolve20 } from "node:path";
45047
45241
  import { pathToFileURL } from "node:url";
@@ -49404,6 +49598,7 @@ function createGaLocationMenu(input2) {
49404
49598
  }),
49405
49599
  ...input2.refreshQuota ? { refreshQuota: input2.refreshQuota } : {},
49406
49600
  ...input2.reauthorize ? { reauthorize: input2.reauthorize } : {},
49601
+ ...input2.login ? { login: input2.login } : {},
49407
49602
  ...input2.vault ? { extras: [input2.vault] } : {}
49408
49603
  });
49409
49604
  }
@@ -50366,55 +50561,62 @@ function createGaLocationServicesFactory(bindings) {
50366
50561
  });
50367
50562
  throw error;
50368
50563
  }
50369
- return {
50370
- runtime,
50371
- localLogin: {
50372
- assertAdmission: assertLocal,
50373
- async assertExistingPool(admit2) {
50374
- await assertLocal();
50375
- await admit2();
50376
- const repository = await getRepository();
50377
- await admit2();
50378
- const opened = await repositoryPromise;
50379
- await admit2();
50380
- if (!opened)
50381
- throw new Error("The local repository was not constructed");
50382
- await assertServingAdmission(opened, bindings.now);
50383
- await admit2();
50384
- const read = await repository.read();
50385
- await admit2();
50386
- if (read.status !== "ready" || !read.rows.some(
50387
- (row) => row.enabled && row.usable && row.credential !== void 0 && !row.torn && !row.unbound && row.invalid === void 0 && row.metadata.status === "present" && accessBlockOf2(row).kind === "none"
50388
- ))
50389
- throw new Error(
50390
- "The existing local Antigravity pool is unavailable"
50391
- );
50392
- await assertServingAdmission(opened, bindings.now);
50393
- await admit2();
50394
- await assertLocal();
50395
- await admit2();
50396
- },
50397
- async persist(result, admit2) {
50398
- await assertLocal();
50399
- await admit2();
50400
- const repository = await getRepository({ admit: admit2 });
50401
- await admit2();
50402
- const opened = await repositoryPromise;
50403
- await admit2();
50404
- if (!opened)
50405
- throw new Error("The local repository was not constructed");
50406
- await assertServingAdmission(opened, bindings.now);
50407
- await admit2();
50408
- const committed = await commitLogins(repository, [result]);
50409
- await admit2();
50410
- if (committed.length !== 1 || committed[0]?.status !== "committed")
50411
- throw new Error(
50412
- "The Antigravity pool login could not be completed."
50413
- );
50414
- await localPipeline?.refreshAccounts();
50415
- await admit2();
50564
+ const localLogin = {
50565
+ assertAdmission: assertLocal,
50566
+ async assertExistingPool(admit2) {
50567
+ await assertLocal();
50568
+ await admit2();
50569
+ const repository = await getRepository();
50570
+ await admit2();
50571
+ const opened = await repositoryPromise;
50572
+ await admit2();
50573
+ if (!opened) throw new Error("The local repository was not constructed");
50574
+ await assertServingAdmission(opened, bindings.now);
50575
+ await admit2();
50576
+ const read = await repository.read();
50577
+ await admit2();
50578
+ if (read.status !== "ready" || !read.rows.some(
50579
+ (row) => row.enabled && row.usable && row.credential !== void 0 && !row.torn && !row.unbound && row.invalid === void 0 && row.metadata.status === "present" && accessBlockOf2(row).kind === "none"
50580
+ ))
50581
+ throw new Error("The existing local Antigravity pool is unavailable");
50582
+ await assertServingAdmission(opened, bindings.now);
50583
+ await admit2();
50584
+ await assertLocal();
50585
+ await admit2();
50586
+ },
50587
+ async persist(result, admit2) {
50588
+ await assertLocal();
50589
+ await admit2();
50590
+ const repository = await getRepository({ admit: admit2 });
50591
+ await admit2();
50592
+ const opened = await repositoryPromise;
50593
+ await admit2();
50594
+ if (!opened) throw new Error("The local repository was not constructed");
50595
+ await assertServingAdmission(opened, bindings.now);
50596
+ await admit2();
50597
+ const committed = await commitLogins(repository, [result]);
50598
+ await admit2();
50599
+ if (committed.length !== 1 || committed[0]?.status !== "committed")
50600
+ throw new Error("The Antigravity pool login could not be completed.");
50601
+ await localPipeline?.refreshAccounts();
50602
+ await admit2();
50603
+ }
50604
+ };
50605
+ const menuLogin = createGaPoolLogin({
50606
+ local: {
50607
+ ...localLogin,
50608
+ async assertAdmission() {
50609
+ if ((await loadCommonAuthClaustrum()).hasVaultHost())
50610
+ throw new Error("Vault authority excludes local sign-in.");
50611
+ await localLogin.assertAdmission();
50416
50612
  }
50417
50613
  },
50614
+ oauth: overrides.oauth
50615
+ });
50616
+ const loginCompletions = /* @__PURE__ */ new Set();
50617
+ return {
50618
+ runtime,
50619
+ localLogin,
50418
50620
  async start(input2) {
50419
50621
  if (closing) throw new Error("The location services are disposed");
50420
50622
  if (started) throw new Error("The location services already started");
@@ -50531,6 +50733,33 @@ function createGaLocationServicesFactory(bindings) {
50531
50733
  repository,
50532
50734
  runtime: location,
50533
50735
  reauthorize: pendingReauthorization,
50736
+ login: {
50737
+ async run(invocation) {
50738
+ const authorization = await menuLogin.method.authorize({});
50739
+ if (authorization.mode !== "auto")
50740
+ throw new Error(
50741
+ "Antigravity sign-in needs a local browser callback."
50742
+ );
50743
+ const completion = authorization.callback.then((result) => menuLogin.onLogin(result)).then(
50744
+ () => {
50745
+ invocation.notify("Account added.", "info");
50746
+ },
50747
+ () => {
50748
+ invocation.notify(
50749
+ "Antigravity sign-in did not complete.",
50750
+ "error"
50751
+ );
50752
+ }
50753
+ ).catch(() => {
50754
+ });
50755
+ loginCompletions.add(completion);
50756
+ void completion.finally(
50757
+ () => loginCompletions.delete(completion)
50758
+ );
50759
+ return `Open ${authorization.url} in your browser and sign in.
50760
+ The account is added when the browser returns here; there is nothing to paste.`;
50761
+ }
50762
+ },
50534
50763
  ...custody ? { vault: custody.menuSection() } : {},
50535
50764
  ...checkQuota ? {
50536
50765
  refreshQuota: async (refs) => {
@@ -50698,6 +50927,7 @@ function createGaLocationServicesFactory(bindings) {
50698
50927
  ]);
50699
50928
  try {
50700
50929
  const resources = Promise.allSettled([
50930
+ menuLogin.dispose().then(() => Promise.allSettled([...loginCompletions])),
50701
50931
  reauthorize?.dispose(),
50702
50932
  localPipeline?.dispose(),
50703
50933
  vaultServices?.dispose()
@@ -52173,198 +52403,9 @@ var ANTIGRAVITY_RPC_DEFINITION = {
52173
52403
 
52174
52404
  // src/ga/server/auth.ts
52175
52405
  init_dist();
52176
-
52177
- // src/auth-method-labels.ts
52178
- var OPENCODE2_POOL_AUTH_LABEL = "Google (antigravity-auth pool, browser)";
52179
- var OPENCODE2_VAULT_AUTH_LABEL = "Use approved Antigravity vault";
52180
- var OPENCODE2_POOL_RECONNECT_LABEL = "Use existing local Antigravity pool";
52181
-
52182
- // src/ga/server/auth.ts
52183
52406
  init_storage();
52184
52407
  init_vault_custody();
52185
52408
  init_vault_folder();
52186
-
52187
- // src/ga/server/pool-login.ts
52188
- init_dist();
52189
- var GA_POOL_METHOD_ID = "antigravity-auth-pool-browser";
52190
- var GA_POOL_RECONNECT_METHOD_ID = "antigravity-auth-pool-reconnect";
52191
- var LOGIN_FAILED = "The Antigravity pool login could not be completed.";
52192
- function abortable(pending, signal) {
52193
- return new Promise((resolve28, reject) => {
52194
- const abort = () => reject(signal.reason);
52195
- if (signal.aborted) abort();
52196
- else signal.addEventListener("abort", abort, { once: true });
52197
- void pending.then(resolve28, reject).finally(() => {
52198
- signal.removeEventListener("abort", abort);
52199
- });
52200
- });
52201
- }
52202
- function createGaPoolLogin(input2) {
52203
- const shutdown = new AbortController();
52204
- const listeners = /* @__PURE__ */ new Set();
52205
- const pending = /* @__PURE__ */ new Set();
52206
- const track = (work) => {
52207
- pending.add(work);
52208
- void work.then(
52209
- () => pending.delete(work),
52210
- () => pending.delete(work)
52211
- );
52212
- return work;
52213
- };
52214
- const admit2 = async () => {
52215
- try {
52216
- shutdown.signal.throwIfAborted();
52217
- if (!input2.local) throw new Error(LOGIN_FAILED);
52218
- await input2.local.assertAdmission();
52219
- shutdown.signal.throwIfAborted();
52220
- } catch {
52221
- throw new Error(LOGIN_FAILED);
52222
- }
52223
- };
52224
- const close = async (listener) => {
52225
- try {
52226
- await listener.close();
52227
- } finally {
52228
- listeners.delete(listener);
52229
- }
52230
- };
52231
- const method = {
52232
- method: {
52233
- id: GA_POOL_METHOD_ID,
52234
- type: "oauth",
52235
- label: OPENCODE2_POOL_AUTH_LABEL
52236
- },
52237
- authorize: () => track(
52238
- (async () => {
52239
- await admit2();
52240
- const authorization = await (async () => {
52241
- try {
52242
- return await abortable(
52243
- (input2.oauth?.authorize ?? authorizeAntigravity)(),
52244
- shutdown.signal
52245
- );
52246
- } catch {
52247
- throw new Error(LOGIN_FAILED);
52248
- }
52249
- })();
52250
- await admit2();
52251
- const state = new URL(authorization.url).searchParams.get("state");
52252
- if (!state) throw new Error(LOGIN_FAILED);
52253
- let listener;
52254
- let code2;
52255
- const waitForCode = input2.oauth?.waitForCode;
52256
- if (waitForCode) {
52257
- code2 = Promise.resolve().then(() => waitForCode(state));
52258
- } else {
52259
- listener = await startOAuthListener();
52260
- listeners.add(listener);
52261
- code2 = listener.waitForCallback().then((url) => {
52262
- if (url.searchParams.get("state") !== state)
52263
- throw new Error(LOGIN_FAILED);
52264
- const value = url.searchParams.get("code");
52265
- if (!value) throw new Error(LOGIN_FAILED);
52266
- return value;
52267
- });
52268
- }
52269
- void code2.catch(() => {
52270
- });
52271
- try {
52272
- await admit2();
52273
- } catch (error) {
52274
- if (listener) await close(listener);
52275
- throw error;
52276
- }
52277
- const ownedListener = listener;
52278
- const callback = track(
52279
- (async () => {
52280
- try {
52281
- await admit2();
52282
- const value = await abortable(code2, shutdown.signal);
52283
- await admit2();
52284
- const result = await abortable(
52285
- (input2.oauth?.exchange ?? exchangeAntigravity)(value, state, {
52286
- signal: shutdown.signal,
52287
- admit: admit2
52288
- }),
52289
- shutdown.signal
52290
- );
52291
- await admit2();
52292
- if (result.type !== "success") throw new Error(LOGIN_FAILED);
52293
- return result;
52294
- } catch {
52295
- throw new Error(LOGIN_FAILED);
52296
- } finally {
52297
- if (ownedListener) await close(ownedListener);
52298
- }
52299
- })()
52300
- );
52301
- void callback.catch(() => {
52302
- });
52303
- return {
52304
- mode: "auto",
52305
- url: authorization.url,
52306
- instructions: "Complete Google sign-in in your browser.",
52307
- callback
52308
- };
52309
- })()
52310
- )
52311
- };
52312
- return {
52313
- method,
52314
- connectExisting: () => track(
52315
- (async () => {
52316
- let stage = "initial-admission";
52317
- try {
52318
- await admit2();
52319
- if (!input2.local?.assertExistingPool) throw new Error(LOGIN_FAILED);
52320
- stage = "existing-pool-admission";
52321
- await abortable(
52322
- track(input2.local.assertExistingPool(admit2)),
52323
- shutdown.signal
52324
- );
52325
- stage = "final-admission";
52326
- await admit2();
52327
- stage = "placeholder";
52328
- return placeholderCredential({
52329
- integrationID: ANTIGRAVITY_PROVIDER_ID,
52330
- methodID: GA_POOL_RECONNECT_METHOD_ID,
52331
- now: Date.now()
52332
- });
52333
- } catch (error) {
52334
- const busy = error instanceof AccountStoreBusyError;
52335
- try {
52336
- console.warn(
52337
- `[antigravity.pool-login] stage=${stage} reason=${busy ? "store-busy" : "store-refusal"}`
52338
- );
52339
- } catch {
52340
- }
52341
- if (busy) throw new AccountStoreBusyError();
52342
- throw new Error(LOGIN_FAILED);
52343
- }
52344
- })()
52345
- ),
52346
- onLogin: (result) => track(
52347
- (async () => {
52348
- try {
52349
- await admit2();
52350
- await input2.local.persist(result, admit2);
52351
- await admit2();
52352
- } catch (error) {
52353
- if (error instanceof AccountStoreBusyError)
52354
- throw new AccountStoreBusyError();
52355
- throw new Error(LOGIN_FAILED);
52356
- }
52357
- })()
52358
- ),
52359
- async dispose() {
52360
- shutdown.abort(new Error(LOGIN_FAILED));
52361
- await Promise.allSettled([...listeners].map(close));
52362
- while (pending.size) await Promise.allSettled([...pending]);
52363
- }
52364
- };
52365
- }
52366
-
52367
- // src/ga/server/auth.ts
52368
52409
  var GA_VAULT_METHOD_ID = "antigravity-vault";
52369
52410
  async function readAuthority() {
52370
52411
  const folder = currentVaultFolder(getStoragePath());
@@ -52384,7 +52425,7 @@ async function registerGaAuthMethods(context, authority = readAuthority, input2
52384
52425
  local: {
52385
52426
  ...local,
52386
52427
  assertAdmission: async () => {
52387
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
52428
+ if ((await loadCommonAuthClaustrum()).hasVaultHost())
52388
52429
  throw new Error("Vault authority excludes local sign-in.");
52389
52430
  await local.assertAdmission();
52390
52431
  }
@@ -53157,7 +53198,7 @@ function createGaRpcActivation(options) {
53157
53198
  const cursor = last ? last.cursor : Math.max(acknowledged, queue2.evictedThrough);
53158
53199
  const claustrum = await loadCommonAuthClaustrum();
53159
53200
  const output2 = {
53160
- ...process.env.CORTEXKIT_VAULT_HOST === "thalamus" ? { vaultHostStatus: claustrum.VAULT_HOST_STATUS } : {},
53201
+ ...claustrum.hasVaultHost() ? { vaultHostStatus: claustrum.VAULT_HOST_STATUS } : {},
53161
53202
  version: ANTIGRAVITY_RPC_VERSION,
53162
53203
  kind: "snapshot",
53163
53204
  generation,
@@ -54843,6 +54884,8 @@ var VAULT_FAILURE_CLASSES2 = Object.freeze({
54843
54884
  unavailable: "unreachable",
54844
54885
  timeout: "unreachable",
54845
54886
  route_closed: "unreachable",
54887
+ // The daemon refused before forwarding, so the vault never saw the request.
54888
+ route_busy: "unreachable",
54846
54889
  daemon_draining: "unreachable",
54847
54890
  connection_closed: "unreachable",
54848
54891
  connection_dropped: "unreachable",
@@ -57379,7 +57422,7 @@ Setup has not completed the OpenCode 2 native Google connection.
57379
57422
  }
57380
57423
  async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
57381
57424
  const claustrum = await loadCommonAuthClaustrum();
57382
- if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
57425
+ if (claustrum.hasVaultHost())
57383
57426
  throw new Error(claustrum.VAULT_HOST_CONNECT_REFUSAL);
57384
57427
  const plugin2 = await createSetupPlugin(
57385
57428
  deps,