@cortexkit/opencode-antigravity-auth 3.0.8 → 3.0.9

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 (68) hide show
  1. package/dist/cli.js +96 -15
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +25 -15
  4. package/dist/index.js +256 -69
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +43 -30
  7. package/dist/server.js +261 -72
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
  11. package/dist/src/common-auth-embedded/auth-menu/login.js +14 -11
  12. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
  13. package/dist/src/common-auth-embedded/claustrum/consumer.js +40 -1
  14. package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  15. package/dist/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  16. package/dist/src/common-auth-embedded/claustrum/insula.js +64 -2
  17. package/dist/src/common-auth-embedded/source-output.json +27 -27
  18. package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  19. package/dist/src/plugin/background-vault-quota-refresh.js +8 -1
  20. package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
  21. package/dist/src/plugin/index.d.ts.map +1 -1
  22. package/dist/src/plugin/index.js +1 -0
  23. package/dist/src/plugin/index.js.map +1 -1
  24. package/dist/src/plugin/quota.d.ts +1 -1
  25. package/dist/src/plugin/quota.d.ts.map +1 -1
  26. package/dist/src/plugin/quota.js +17 -5
  27. package/dist/src/plugin/quota.js.map +1 -1
  28. package/dist/src/plugin/shared/vault-request-credentials.d.ts +9 -6
  29. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  30. package/dist/src/plugin/shared/vault-request-credentials.js +9 -4
  31. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  32. package/dist/src/plugin/vault-custody.d.ts +2 -0
  33. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  34. package/dist/src/plugin/vault-custody.js +9 -0
  35. package/dist/src/plugin/vault-custody.js.map +1 -1
  36. package/dist/src/plugin/vault-insula-quota.d.ts +6 -0
  37. package/dist/src/plugin/vault-insula-quota.d.ts.map +1 -0
  38. package/dist/src/plugin/vault-insula-quota.js +50 -0
  39. package/dist/src/plugin/vault-insula-quota.js.map +1 -0
  40. package/dist/src/plugin/vault-quota-outcome.d.ts +1 -1
  41. package/dist/src/plugin/vault-quota-outcome.d.ts.map +1 -1
  42. package/dist/src/plugin/vault-quota-outcome.js.map +1 -1
  43. package/dist/tui-build-map.json +1 -1
  44. package/dist/tui-ga-build-map.json +1 -1
  45. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
  46. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  47. package/dist/types/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  48. package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
  49. package/dist/types/src/plugin/index.d.ts.map +1 -1
  50. package/dist/types/src/plugin/quota.d.ts +1 -1
  51. package/dist/types/src/plugin/quota.d.ts.map +1 -1
  52. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +9 -6
  53. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  54. package/dist/types/src/plugin/vault-custody.d.ts +2 -0
  55. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  56. package/dist/types/src/plugin/vault-insula-quota.d.ts +6 -0
  57. package/dist/types/src/plugin/vault-insula-quota.d.ts.map +1 -0
  58. package/dist/types/src/plugin/vault-quota-outcome.d.ts +1 -1
  59. package/dist/types/src/plugin/vault-quota-outcome.d.ts.map +1 -1
  60. package/package.json +2 -2
  61. package/src/common-auth-embedded/auth-menu/login.d.ts +6 -10
  62. package/src/common-auth-embedded/auth-menu/login.js +14 -11
  63. package/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
  64. package/src/common-auth-embedded/claustrum/consumer.js +40 -1
  65. package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
  66. package/src/common-auth-embedded/claustrum/insula.d.ts +23 -0
  67. package/src/common-auth-embedded/claustrum/insula.js +64 -2
  68. package/src/common-auth-embedded/source-output.json +27 -27
package/dist/cli.js CHANGED
@@ -7228,12 +7228,12 @@ var init_doctor = __esm({
7228
7228
  });
7229
7229
 
7230
7230
  // ../core/dist/common-auth-embedded/auth-menu/login.js
7231
- import { execFileSync as defaultExecFileSync, spawn as defaultSpawn } from "node:child_process";
7232
- function openBrowserForMenu(url, platform = process.platform, execFileSync = defaultExecFileSync, spawn2 = defaultSpawn) {
7231
+ import { spawn as defaultSpawn } from "node:child_process";
7232
+ function openBrowserForMenu(url, platform = process.platform, spawn2 = defaultSpawn) {
7233
7233
  try {
7234
7234
  if (platform === "win32") {
7235
7235
  const command = `Start-Process '${url.replaceAll("'", "''")}'`;
7236
- const child = spawn2("powershell.exe", [
7236
+ const child2 = spawn2("powershell.exe", [
7237
7237
  "-NoProfile",
7238
7238
  "-NonInteractive",
7239
7239
  "-WindowStyle",
@@ -7241,17 +7241,18 @@ function openBrowserForMenu(url, platform = process.platform, execFileSync = def
7241
7241
  "-EncodedCommand",
7242
7242
  Buffer.from(command, "utf16le").toString("base64")
7243
7243
  ], { stdio: "ignore", windowsHide: true });
7244
- child.on("error", () => {
7245
- });
7246
- child.unref();
7247
- return child.pid !== void 0;
7248
- } else {
7249
- execFileSync(platform === "darwin" ? "open" : "xdg-open", [url], {
7250
- stdio: "ignore",
7251
- timeout: 3e3
7244
+ child2.on("error", () => {
7252
7245
  });
7246
+ child2.unref();
7247
+ return child2.pid !== void 0;
7253
7248
  }
7254
- return true;
7249
+ const child = spawn2(platform === "darwin" ? "open" : "xdg-open", [url], {
7250
+ stdio: "ignore"
7251
+ });
7252
+ child.on("error", () => {
7253
+ });
7254
+ child.unref();
7255
+ return child.pid !== void 0;
7255
7256
  } catch {
7256
7257
  return false;
7257
7258
  }
@@ -8524,7 +8525,7 @@ function acquireInsulaQuotaSource(transport, tokenPath) {
8524
8525
  }
8525
8526
  };
8526
8527
  }
8527
- var MINUTE, MAX_AGE, sources, attempts, InsulaQuotaSource;
8528
+ var MINUTE, MAX_AGE, COLD_WAIT, sources, attempts, InsulaQuotaSource;
8528
8529
  var init_insula = __esm({
8529
8530
  "../core/dist/common-auth-embedded/claustrum/insula.js"() {
8530
8531
  "use strict";
@@ -8532,12 +8533,16 @@ var init_insula = __esm({
8532
8533
  init_watch();
8533
8534
  MINUTE = 6e4;
8534
8535
  MAX_AGE = 4 * MINUTE;
8536
+ COLD_WAIT = 2 * MINUTE;
8535
8537
  sources = /* @__PURE__ */ new Map();
8536
8538
  attempts = /* @__PURE__ */ new Map();
8537
8539
  InsulaQuotaSource = class {
8538
8540
  transport;
8539
8541
  key;
8540
8542
  #entries = [];
8543
+ #available = false;
8544
+ #completeProviders = /* @__PURE__ */ new Set();
8545
+ #coldSince = /* @__PURE__ */ new Map();
8541
8546
  /** Every usage.get, polled or watch-driven, shares this one slot. */
8542
8547
  #reads = new CoalescedRead(async () => {
8543
8548
  try {
@@ -8545,8 +8550,14 @@ var init_insula = __esm({
8545
8550
  if (!record2(reply) || !Array.isArray(reply.result) || reply.error !== void 0)
8546
8551
  throw new Error("unavailable insula usage");
8547
8552
  this.#entries = reply.result.filter((entry) => record2(entry) && typeof entry.provider === "string");
8553
+ this.#available = this.#entries.length === reply.result.length && (reply.completeProviders === void 0 || Array.isArray(reply.completeProviders) && reply.completeProviders.every((value) => typeof value === "string"));
8554
+ this.#completeProviders = new Set(this.#available && Array.isArray(reply.completeProviders) ? reply.completeProviders : []);
8555
+ for (const provider2 of this.#completeProviders)
8556
+ this.#coldSince.delete(provider2);
8548
8557
  } catch {
8549
8558
  this.#entries = [];
8559
+ this.#available = false;
8560
+ this.#completeProviders.clear();
8550
8561
  }
8551
8562
  }, () => {
8552
8563
  });
@@ -8725,6 +8736,37 @@ var init_insula = __esm({
8725
8736
  }
8726
8737
  return void 0;
8727
8738
  }
8739
+ /** Cache-only background lookup; current() retains its original miss behavior. */
8740
+ lookup(provider2, accountId, now) {
8741
+ if (!this.#available)
8742
+ return { miss: "unreachable" };
8743
+ const entry = this.#entries.find((value) => value.provider === provider2 && typeof value.account === "string" && value.account.trim() === accountId);
8744
+ const errorClass = (entry ?? this.#entries.find((value) => value.provider === provider2 && value.account === void 0 && value.errorClass !== void 0))?.errorClass;
8745
+ if (errorClass === "upstream_failed")
8746
+ return { miss: "upstream-failed" };
8747
+ if (errorClass === "credential_absent" || errorClass === "credential_unusable" || errorClass === "credential_rejected")
8748
+ return { miss: "credential" };
8749
+ if (errorClass !== void 0)
8750
+ return { miss: "unreachable" };
8751
+ if (entry) {
8752
+ const fetchedAt = typeof entry.fetchedAt === "string" ? Date.parse(entry.fetchedAt) : Number.NaN;
8753
+ if (!record2(entry.usage) || !Number.isFinite(fetchedAt))
8754
+ return { miss: "unreachable" };
8755
+ const reading = {
8756
+ entry,
8757
+ context: {
8758
+ fetchedAt,
8759
+ ...typeof entry.source === "string" && { source: entry.source }
8760
+ }
8761
+ };
8762
+ return now >= fetchedAt + MAX_AGE || entry.stale !== void 0 ? { miss: "stale", reading } : { reading };
8763
+ }
8764
+ if (this.#completeProviders.has(provider2))
8765
+ return { miss: "absent" };
8766
+ const since = this.#coldSince.get(provider2) ?? now;
8767
+ this.#coldSince.set(provider2, since);
8768
+ return { miss: now - since >= COLD_WAIT ? "unreachable" : "cold" };
8769
+ }
8728
8770
  };
8729
8771
  }
8730
8772
  });
@@ -10502,6 +10544,7 @@ var init_consumer = __esm({
10502
10544
  #insula;
10503
10545
  #vaultWatch;
10504
10546
  #releaseInsulaWatch;
10547
+ #insulaSkips = /* @__PURE__ */ new Map();
10505
10548
  /** When this instance last completed a discovery, by `now`. */
10506
10549
  #discoveredAt;
10507
10550
  constructor(options) {
@@ -10795,6 +10838,41 @@ var init_consumer = __esm({
10795
10838
  return void 0;
10796
10839
  }
10797
10840
  }
10841
+ /** Cache-only background lookup, preserving the reason a route has no reading. */
10842
+ async lookupInsulaQuotaForRoute(routeId) {
10843
+ const options = this.#options.insula;
10844
+ if (!options || this.#shutdown.signal.aborted || !await this.#active())
10845
+ return { miss: "unreachable" };
10846
+ try {
10847
+ await readClaustrumEnrollmentToken(this.#options.tokenPath);
10848
+ const roster = await readVaultRoster(this.#options.rosterPath);
10849
+ const account = roster?.rows.find((row) => row.routeId === routeId)?.accountIdentity;
10850
+ if (!account || !this.#insula)
10851
+ return { miss: "unreachable" };
10852
+ const result = this.#insula.source.lookup(options.provider, account, (this.#options.now ?? Date.now)());
10853
+ const reading = result.reading && options.normalize(result.reading.entry, result.reading.context);
10854
+ if (result.miss)
10855
+ return { miss: result.miss, ...reading !== void 0 && { reading } };
10856
+ return reading === void 0 ? { miss: "unreachable" } : { reading };
10857
+ } catch {
10858
+ return { miss: "unreachable" };
10859
+ }
10860
+ }
10861
+ /** Skip the fallback poll while insula is cold or its upstream fetch failed. */
10862
+ async pollInsulaQuotaForRoute(routeId, fallback) {
10863
+ const result = await this.lookupInsulaQuotaForRoute(routeId);
10864
+ if (result.miss === "cold" || result.miss === "upstream-failed") {
10865
+ if (this.#insulaSkips.get(routeId) !== result.miss) {
10866
+ this.#insulaSkips.set(routeId, result.miss);
10867
+ this.#logger.warn("skipped insula provider poll", {
10868
+ reason: result.miss
10869
+ });
10870
+ }
10871
+ return void 0;
10872
+ }
10873
+ this.#insulaSkips.delete(routeId);
10874
+ return result.miss ? fallback() : result.reading;
10875
+ }
10798
10876
  #normalizeInsulaQuota(accountIdentity) {
10799
10877
  if (!this.#options.insula || !accountIdentity)
10800
10878
  return void 0;
@@ -17683,6 +17761,7 @@ var ANTIGRAVITY_SCOPES = [
17683
17761
  var ANTIGRAVITY_REDIRECT_URI = "http://localhost:51121/oauth-callback";
17684
17762
  var ANTIGRAVITY_ENDPOINT_DAILY = "https://daily-cloudcode-pa.googleapis.com";
17685
17763
  var ANTIGRAVITY_ENDPOINT_PROD = "https://cloudcode-pa.googleapis.com";
17764
+ var ANTIGRAVITY_QUOTA_ENDPOINT = ANTIGRAVITY_ENDPOINT_DAILY;
17686
17765
  var ANTIGRAVITY_ENDPOINT_FALLBACKS = [
17687
17766
  ANTIGRAVITY_ENDPOINT_DAILY,
17688
17767
  ANTIGRAVITY_ENDPOINT_PROD
@@ -20738,7 +20817,7 @@ async function fetchLegacyModelsFallback(options) {
20738
20817
  const modelsResponse = await fetchAvailableModels({
20739
20818
  accessToken: options.accessToken,
20740
20819
  projectId: options.projectId,
20741
- endpoints: ANTIGRAVITY_ENDPOINT_FALLBACKS,
20820
+ endpoints: [ANTIGRAVITY_QUOTA_ENDPOINT],
20742
20821
  userAgent: buildAntigravityHarnessUserAgent(),
20743
20822
  timeoutMs: 1e4,
20744
20823
  ...options.fetchVia ? { fetchVia: options.fetchVia } : {}
@@ -20767,7 +20846,7 @@ async function fetchQuotaPayloads(options) {
20767
20846
  accessToken,
20768
20847
  managedProjectId,
20769
20848
  projectId,
20770
- endpoints: ANTIGRAVITY_ENDPOINT_FALLBACKS,
20849
+ endpoints: [ANTIGRAVITY_QUOTA_ENDPOINT],
20771
20850
  userAgent: buildAntigravityHarnessUserAgent(),
20772
20851
  timeoutMs: 1e4,
20773
20852
  ...fetchVia ? { fetchVia } : {}
@@ -20872,6 +20951,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
20872
20951
  }),
20873
20952
  signal
20874
20953
  );
20954
+ if (payloads.quota.error) throw new Error(payloads.quota.error);
20875
20955
  return {
20876
20956
  index,
20877
20957
  email: account.email,
@@ -20927,6 +21007,7 @@ function makeFetchAccountQuota(client, providerId, fetchVia) {
20927
21007
  logger: log7
20928
21008
  });
20929
21009
  quotaResult = payloads.quota;
21010
+ if (quotaResult.error) throw new Error(quotaResult.error);
20930
21011
  fellBackToLegacy = payloads.fellBackToLegacy;
20931
21012
  for (const [family, groupQuota] of Object.entries(quotaResult.groups)) {
20932
21013
  const remainingPercent = (groupQuota.remainingFraction ?? 0) * 100;