@cortexkit/opencode-antigravity-auth 3.0.14 → 3.0.15

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 (50) hide show
  1. package/dist/cli.js.map +2 -2
  2. package/dist/cli.meta.json +4 -4
  3. package/dist/index.js +211 -33
  4. package/dist/index.js.map +2 -2
  5. package/dist/index.meta.json +8 -8
  6. package/dist/server.js +242 -38
  7. package/dist/server.js.map +3 -3
  8. package/dist/server.meta.json +1 -1
  9. package/dist/src/ga/tui/host-ga.d.ts +55 -2
  10. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  11. package/dist/src/ga/tui/host-ga.js +73 -43
  12. package/dist/src/ga/tui/host-ga.js.map +1 -1
  13. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  14. package/dist/src/plugin/ga-location-services.js +49 -5
  15. package/dist/src/plugin/ga-location-services.js.map +1 -1
  16. package/dist/src/plugin/shared/vault-request-credentials.d.ts +33 -13
  17. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  18. package/dist/src/plugin/shared/vault-request-credentials.js +97 -44
  19. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  20. package/dist/src/tui/quota-layout.d.ts +1 -1
  21. package/dist/src/tui/quota-layout.js +1 -1
  22. package/dist/src/tui/sidebar-frame.d.ts +109 -0
  23. package/dist/src/tui/sidebar-frame.d.ts.map +1 -0
  24. package/dist/src/tui/sidebar-frame.js +244 -0
  25. package/dist/src/tui/sidebar-frame.js.map +1 -0
  26. package/dist/src/tui.d.ts.map +1 -1
  27. package/dist/src/tui.js +11 -251
  28. package/dist/src/tui.js.map +1 -1
  29. package/dist/tui-build-map.json +120 -92
  30. package/dist/tui-ga-build-map.json +22 -8
  31. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  32. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +33 -13
  33. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  34. package/package.json +2 -2
  35. package/src/tui/entry.mjs +19 -1
  36. package/src/tui-compiled/sidebar-projection.js +119 -0
  37. package/src/tui-compiled/tui/quota-layout.js +1 -1
  38. package/src/tui-compiled/tui/sidebar-frame.js +657 -0
  39. package/src/tui-compiled/tui.js +25 -606
  40. package/src/tui-ga-compiled/host-ga.js +116 -124
  41. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +657 -0
  42. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +1 -1
  43. package/src/tui-ga-raw/host-ga.tsx +157 -95
  44. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +603 -0
  45. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +1 -1
  46. package/src/tui-raw/sidebar-projection.js +119 -0
  47. package/src/tui-raw/tui/quota-layout.tsx +1 -1
  48. package/src/tui-raw/tui/sidebar-frame.tsx +603 -0
  49. package/src/tui-raw/tui.tsx +25 -523
  50. package/src/tui.tsx +25 -523
@@ -2518,7 +2518,7 @@
2518
2518
  "format": "esm"
2519
2519
  },
2520
2520
  "../core/dist/vault-provider-state.js": {
2521
- "bytes": 17421,
2521
+ "bytes": 24634,
2522
2522
  "imports": [
2523
2523
  {
2524
2524
  "path": "node:fs/promises",
@@ -2534,7 +2534,7 @@
2534
2534
  "format": "esm"
2535
2535
  },
2536
2536
  "../core/dist/vault-account-source.js": {
2537
- "bytes": 17531,
2537
+ "bytes": 18160,
2538
2538
  "imports": [
2539
2539
  {
2540
2540
  "path": "../core/dist/vault-family.js",
@@ -4030,7 +4030,7 @@
4030
4030
  "format": "esm"
4031
4031
  },
4032
4032
  "src/plugin/shared/vault-request-credentials.ts": {
4033
- "bytes": 29239,
4033
+ "bytes": 32268,
4034
4034
  "imports": [
4035
4035
  {
4036
4036
  "path": "../core/dist/index.js",
@@ -6356,7 +6356,7 @@
6356
6356
  "imports": [],
6357
6357
  "exports": [],
6358
6358
  "inputs": {},
6359
- "bytes": 4421813
6359
+ "bytes": 4439498
6360
6360
  },
6361
6361
  "dist/index.js": {
6362
6362
  "imports": [
@@ -7864,10 +7864,10 @@
7864
7864
  "bytesInOutput": 285
7865
7865
  },
7866
7866
  "../core/dist/vault-provider-state.js": {
7867
- "bytesInOutput": 11787
7867
+ "bytesInOutput": 16096
7868
7868
  },
7869
7869
  "../core/dist/vault-account-source.js": {
7870
- "bytesInOutput": 11732
7870
+ "bytesInOutput": 12237
7871
7871
  },
7872
7872
  "../core/dist/vault-enrollment-authority.js": {
7873
7873
  "bytesInOutput": 413
@@ -8041,7 +8041,7 @@
8041
8041
  "bytesInOutput": 31677
8042
8042
  },
8043
8043
  "src/plugin/shared/vault-request-credentials.ts": {
8044
- "bytesInOutput": 15341
8044
+ "bytesInOutput": 16767
8045
8045
  },
8046
8046
  "src/plugin/vault-insula-quota.ts": {
8047
8047
  "bytesInOutput": 1715
@@ -8302,7 +8302,7 @@
8302
8302
  "bytesInOutput": 0
8303
8303
  }
8304
8304
  },
8305
- "bytes": 1984636
8305
+ "bytes": 1990876
8306
8306
  }
8307
8307
  }
8308
8308
  }
package/dist/server.js CHANGED
@@ -26804,6 +26804,124 @@ async function commitVaultProviderState(input2) {
26804
26804
  return { result };
26805
26805
  });
26806
26806
  }
26807
+ async function commitVaultProviderStates(input2) {
26808
+ const { claustrum, fs: fs4, statePath } = input2;
26809
+ input2.signal?.throwIfAborted();
26810
+ const results = new Array(input2.entries.length);
26811
+ const refuse2 = (index, error) => {
26812
+ results[index] = { status: "refused", error };
26813
+ };
26814
+ let pending = [];
26815
+ for (const [index, entry] of input2.entries.entries()) {
26816
+ try {
26817
+ pending.push({
26818
+ index,
26819
+ attribution: pinAttribution(entry.attribution),
26820
+ update: entry.update
26821
+ });
26822
+ } catch (error) {
26823
+ refuse2(index, error);
26824
+ }
26825
+ }
26826
+ const keepBound = (roster, entries) => entries.filter((entry) => {
26827
+ try {
26828
+ assertRosterBinding(roster, entry.attribution, claustrum);
26829
+ return true;
26830
+ } catch (error) {
26831
+ refuse2(entry.index, error);
26832
+ return false;
26833
+ }
26834
+ });
26835
+ if (pending.length > 0)
26836
+ pending = keepBound(await claustrum.readVaultRoster(input2.rosterPath), pending);
26837
+ input2.signal?.throwIfAborted();
26838
+ if (pending.length === 0)
26839
+ return results;
26840
+ await claustrum.mutateVaultRoster(input2.rosterPath, async (roster, rosterLock) => {
26841
+ input2.signal?.throwIfAborted();
26842
+ const bound = keepBound(roster, pending);
26843
+ if (bound.length === 0)
26844
+ return { result: void 0 };
26845
+ await fs4.withLock(statePath, VAULT_PROVIDER_STATE_LOCK, async (stateLock) => {
26846
+ input2.signal?.throwIfAborted();
26847
+ const proofs = await Promise.allSettled(bound.map((entry) => input2.verify(entry.attribution)));
26848
+ input2.signal?.throwIfAborted();
26849
+ const proven = bound.filter((entry, at) => {
26850
+ const proof = proofs[at];
26851
+ if (proof?.status !== "rejected")
26852
+ return true;
26853
+ refuse2(entry.index, proof.reason);
26854
+ return false;
26855
+ });
26856
+ if (proven.length === 0)
26857
+ return;
26858
+ const file = await readVaultProviderState(statePath);
26859
+ input2.signal?.throwIfAborted();
26860
+ const accounts = {
26861
+ ...file.accounts
26862
+ };
26863
+ const written = [];
26864
+ for (const entry of proven) {
26865
+ const identity3 = entry.attribution.accountIdentity;
26866
+ const current = Object.hasOwn(accounts, identity3) ? accounts[identity3] : void 0;
26867
+ try {
26868
+ const requested = entry.update(current);
26869
+ if (isRecord9(requested) && typeof requested.then === "function")
26870
+ throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
26871
+ if (requested === void 0 || requested === null && !current) {
26872
+ results[entry.index] = current ? { status: "unchanged", state: current } : { status: "unchanged" };
26873
+ continue;
26874
+ }
26875
+ if (requested === null) {
26876
+ delete accounts[identity3];
26877
+ written.push(entry);
26878
+ continue;
26879
+ }
26880
+ const next = Object.freeze({
26881
+ observed: Object.freeze({
26882
+ routeId: entry.attribution.routeId,
26883
+ credentialId: entry.attribution.credentialId,
26884
+ recordVersion: entry.attribution.recordVersion
26885
+ }),
26886
+ ...decodeValue(requested, "update", "typed")
26887
+ });
26888
+ accounts[identity3] = next;
26889
+ written.push({ ...entry, next });
26890
+ } catch (error) {
26891
+ refuse2(entry.index, error);
26892
+ }
26893
+ }
26894
+ if (written.length === 0)
26895
+ return;
26896
+ const encoded = encodeVaultProviderState({ ...file, accounts });
26897
+ try {
26898
+ await fs4.writeJsonAtomic(statePath, encoded, {
26899
+ beforeRename: async () => {
26900
+ await rosterLock.assertOwned();
26901
+ await stateLock.assertOwned();
26902
+ input2.signal?.throwIfAborted();
26903
+ }
26904
+ });
26905
+ } catch (error) {
26906
+ let reloaded;
26907
+ try {
26908
+ reloaded = await readVaultProviderState(statePath);
26909
+ } catch {
26910
+ reloaded = void 0;
26911
+ }
26912
+ for (const entry of written) {
26913
+ const state = reloaded && vaultAccountState(reloaded, entry.attribution.accountIdentity);
26914
+ results[entry.index] = state ? { status: "uncertain", error, state } : { status: "uncertain", error };
26915
+ }
26916
+ return;
26917
+ }
26918
+ for (const entry of written)
26919
+ results[entry.index] = entry.next ? { status: "written", state: entry.next } : { status: "cleared" };
26920
+ });
26921
+ return { result: void 0 };
26922
+ });
26923
+ return results;
26924
+ }
26807
26925
 
26808
26926
  // ../core/dist/vault-account-source.js
26809
26927
  function untilAborted2(pending, signal) {
@@ -27060,6 +27178,20 @@ function createAntigravityVaultAccountSource(options) {
27060
27178
  update
27061
27179
  });
27062
27180
  },
27181
+ commitStates: async (entries, signal) => {
27182
+ assertOpen(signal);
27183
+ if (!options.state)
27184
+ throw new AntigravityVaultSourceError("state-unavailable", "No provider-state sidecar is configured for this vault source");
27185
+ return commitVaultProviderStates({
27186
+ claustrum,
27187
+ fs: options.state.fs,
27188
+ rosterPath: options.rosterPath,
27189
+ statePath: options.state.path,
27190
+ entries,
27191
+ verify: (by) => verifyAttribution(by, signal),
27192
+ signal
27193
+ });
27194
+ },
27063
27195
  decline: async (ref) => {
27064
27196
  assertOpen();
27065
27197
  await consumer.decline(ref.routeId);
@@ -29609,6 +29741,13 @@ function applyDurableSelection(row, metadata) {
29609
29741
  function stateBelongsTo(state, row) {
29610
29742
  return state.observed.routeId === row.route.routeId && state.observed.credentialId === row.route.credentialId;
29611
29743
  }
29744
+ function quotaUpdate(quota) {
29745
+ return (current) => ({
29746
+ ...current?.metadata !== void 0 ? { metadata: current.metadata } : {},
29747
+ quota,
29748
+ ...current?.extensions !== void 0 ? { extensions: current.extensions } : {}
29749
+ });
29750
+ }
29612
29751
  function createVaultSelectionState(options) {
29613
29752
  const now = options.now ?? (() => Date.now());
29614
29753
  const attributions = /* @__PURE__ */ new WeakMap();
@@ -29682,15 +29821,30 @@ function createVaultSelectionState(options) {
29682
29821
  },
29683
29822
  flush: flush2,
29684
29823
  recordQuota(attribution, quota, signal) {
29685
- return options.source.commitState(
29824
+ return options.source.commitState(attribution, quotaUpdate(quota), signal);
29825
+ },
29826
+ async recordQuotas(readings, signal) {
29827
+ const entries = readings.map(({ attribution, quota }) => ({
29686
29828
  attribution,
29687
- (current) => ({
29688
- ...current?.metadata !== void 0 ? { metadata: current.metadata } : {},
29689
- quota,
29690
- ...current?.extensions !== void 0 ? { extensions: current.extensions } : {}
29691
- }),
29692
- signal
29693
- );
29829
+ update: quotaUpdate(quota)
29830
+ }));
29831
+ if (options.source.commitStates)
29832
+ return options.source.commitStates(entries, signal);
29833
+ const results = [];
29834
+ for (const { attribution, update } of entries) {
29835
+ if (signal?.aborted) {
29836
+ results.push({ status: "refused", error: signal.reason });
29837
+ continue;
29838
+ }
29839
+ try {
29840
+ results.push(
29841
+ await options.source.commitState(attribution, update, signal)
29842
+ );
29843
+ } catch (error) {
29844
+ results.push({ status: "refused", error });
29845
+ }
29846
+ }
29847
+ return results;
29694
29848
  }
29695
29849
  };
29696
29850
  }
@@ -29820,8 +29974,15 @@ async function checkVaultQuota(input2) {
29820
29974
  const state = input2.pool.state;
29821
29975
  const rows = [...input2.pool.selector.rows];
29822
29976
  const now = input2.now ?? (() => Date.now());
29977
+ const reportError = (error) => {
29978
+ try {
29979
+ input2.onError?.(error);
29980
+ } catch {
29981
+ }
29982
+ };
29823
29983
  let checked = 0;
29824
29984
  if (state === void 0) input2.onOutcome?.("state-invalid");
29985
+ const readings = [];
29825
29986
  for (const row of rows) {
29826
29987
  if (input2.signal.aborted || state === void 0) break;
29827
29988
  try {
@@ -29841,32 +30002,49 @@ async function checkVaultQuota(input2) {
29841
30002
  input2.onOutcome?.("unattributed");
29842
30003
  continue;
29843
30004
  }
29844
- const reading = vaultQuotaState(answer.quota, answer.observedAt ?? now());
29845
- input2.onStage?.("commit");
29846
- input2.signal.throwIfAborted();
29847
- const result = await state.recordQuota(attribution, reading, input2.signal);
29848
- if (result.status !== "written") {
29849
- input2.onOutcome?.(
29850
- result.status === "uncertain" ? "write-uncertain" : "commit-unchanged",
29851
- result.status === "uncertain" ? result.error : void 0
29852
- );
29853
- continue;
29854
- }
29855
- checked += 1;
29856
- input2.onOutcome?.("recorded");
29857
- const live = input2.pool.selector.rows.find(
29858
- (candidate) => candidate.route.routeId === attribution.routeId && candidate.route.credentialId === attribution.credentialId && candidate.route.accountIdentity === attribution.accountIdentity
29859
- );
29860
- if (live !== void 0) {
29861
- const cached = cachedQuotaOf(reading);
29862
- if (cached !== void 0) live.cachedQuota = cached;
29863
- live.cachedQuotaUpdatedAt = reading.cachedQuotaUpdatedAt ?? void 0;
29864
- }
30005
+ readings.push({
30006
+ attribution,
30007
+ quota: vaultQuotaState(answer.quota, answer.observedAt ?? now())
30008
+ });
29865
30009
  } catch (error) {
29866
- try {
29867
- input2.onError?.(error);
29868
- } catch {
29869
- }
30010
+ reportError(error);
30011
+ }
30012
+ }
30013
+ if (state === void 0 || readings.length === 0 || input2.signal.aborted)
30014
+ return { checked, notChecked: rows.length - checked };
30015
+ let results;
30016
+ try {
30017
+ input2.onStage?.("commit");
30018
+ input2.signal.throwIfAborted();
30019
+ results = await state.recordQuotas(readings, input2.signal);
30020
+ } catch (error) {
30021
+ for (const _ of readings) reportError(error);
30022
+ return { checked, notChecked: rows.length - checked };
30023
+ }
30024
+ for (const [at, { attribution, quota: reading }] of readings.entries()) {
30025
+ const result = results[at];
30026
+ if (result === void 0 || result.status === "refused") {
30027
+ reportError(
30028
+ result === void 0 ? new Error("The provider-state commit returned no result") : result.error
30029
+ );
30030
+ continue;
30031
+ }
30032
+ if (result.status !== "written") {
30033
+ input2.onOutcome?.(
30034
+ result.status === "uncertain" ? "write-uncertain" : "commit-unchanged",
30035
+ result.status === "uncertain" ? result.error : void 0
30036
+ );
30037
+ continue;
30038
+ }
30039
+ checked += 1;
30040
+ input2.onOutcome?.("recorded");
30041
+ const live = input2.pool.selector.rows.find(
30042
+ (candidate) => candidate.route.routeId === attribution.routeId && candidate.route.credentialId === attribution.credentialId && candidate.route.accountIdentity === attribution.accountIdentity
30043
+ );
30044
+ if (live !== void 0) {
30045
+ const cached = cachedQuotaOf(reading);
30046
+ if (cached !== void 0) live.cachedQuota = cached;
30047
+ live.cachedQuotaUpdatedAt = reading.cachedQuotaUpdatedAt ?? void 0;
29870
30048
  }
29871
30049
  }
29872
30050
  return { checked, notChecked: rows.length - checked };
@@ -44964,6 +45142,17 @@ function project2(read, registry, health) {
44964
45142
  });
44965
45143
  return { read, rows, overLimit: null, plan };
44966
45144
  }
45145
+ function readingTime(value) {
45146
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
45147
+ }
45148
+ function newestReadingTime(times) {
45149
+ let newest = null;
45150
+ for (const value of times) {
45151
+ const at = readingTime(value);
45152
+ if (at !== null && (newest === null || at > newest)) newest = at;
45153
+ }
45154
+ return newest;
45155
+ }
44967
45156
  function abortError(signal) {
44968
45157
  return signal.reason instanceof Error ? signal.reason : new Error("The state read was aborted");
44969
45158
  }
@@ -44982,6 +45171,12 @@ function createGaAccountStateSource(options) {
44982
45171
  if (input2.signal.aborted) throw abortError(input2.signal);
44983
45172
  const retiredSelectors = projected2.plan?.commit() ?? [];
44984
45173
  readSeq = options.nextReadSeq?.() ?? readSeq + 1;
45174
+ const checkedAt = newestReadingTime([
45175
+ status.checkedAt,
45176
+ ...read.status === "ready" ? read.rows.map(
45177
+ (row) => row.quota.status === "present" ? row.quota.quota.cachedQuotaUpdatedAt : void 0
45178
+ ) : []
45179
+ ]);
44985
45180
  const answer = {
44986
45181
  readSeq,
44987
45182
  accounts: projected2.overLimit !== null ? { kind: "over-limit", count: projected2.overLimit } : {
@@ -44992,7 +45187,7 @@ function createGaAccountStateSource(options) {
44992
45187
  }))
44993
45188
  },
44994
45189
  route,
44995
- status,
45190
+ status: { ...status, checkedAt },
44996
45191
  settings
44997
45192
  };
44998
45193
  if (options.observe) {
@@ -45665,9 +45860,16 @@ function createGaVaultStateSource(input2) {
45665
45860
  const overLimit = rows.length > ACCOUNT_LIMIT;
45666
45861
  const quotaOf2 = (row) => {
45667
45862
  const reading = stored ? quotaReadingForVaultRoute(row.route, stored) : void 0;
45668
- const cachedQuota = (reading ? cachedQuotaOf(reading) : void 0) ?? row.cachedQuota;
45669
- return cachedQuota !== void 0 ? { cachedQuota } : {};
45863
+ const storedQuota = reading ? cachedQuotaOf(reading) : void 0;
45864
+ const [cachedQuota, updatedAt] = storedQuota !== void 0 ? [storedQuota, reading?.cachedQuotaUpdatedAt] : [row.cachedQuota, row.cachedQuotaUpdatedAt];
45865
+ if (cachedQuota === void 0) return {};
45866
+ const at = readingTime(updatedAt);
45867
+ return {
45868
+ cachedQuota,
45869
+ ...at !== null ? { cachedQuotaUpdatedAt: at } : {}
45870
+ };
45670
45871
  };
45872
+ const quotas = rows.map(quotaOf2);
45671
45873
  const answer = {
45672
45874
  readSeq,
45673
45875
  accounts: overLimit ? { kind: "over-limit", count: rows.length } : {
@@ -45679,13 +45881,15 @@ function createGaVaultStateSource(input2) {
45679
45881
  enabled: row.enabled,
45680
45882
  current: false,
45681
45883
  ...row.coolingDownUntil !== void 0 ? { coolingDownUntil: row.coolingDownUntil } : {},
45682
- ...quotaOf2(row)
45884
+ ...quotas[position]
45683
45885
  }
45684
45886
  }))
45685
45887
  },
45686
45888
  route,
45687
45889
  status: {
45688
- checkedAt: null,
45890
+ checkedAt: newestReadingTime(
45891
+ quotas.map((quota) => quota.cachedQuotaUpdatedAt)
45892
+ ),
45689
45893
  quotaBackoffUntil: null,
45690
45894
  routingAuthoritative: true
45691
45895
  },