@cortexkit/opencode-antigravity-auth 3.0.14 → 3.0.16

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 (63) hide show
  1. package/dist/cli.js +257 -57
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +11 -11
  4. package/dist/index.js +468 -90
  5. package/dist/index.js.map +3 -3
  6. package/dist/index.meta.json +14 -14
  7. package/dist/server.js +499 -95
  8. package/dist/server.js.map +3 -3
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/ga/tui/host-ga.d.ts +55 -2
  11. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  12. package/dist/src/ga/tui/host-ga.js +73 -43
  13. package/dist/src/ga/tui/host-ga.js.map +1 -1
  14. package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
  15. package/dist/src/plugin/ga-location-services.js +49 -5
  16. package/dist/src/plugin/ga-location-services.js.map +1 -1
  17. package/dist/src/plugin/shared/vault-request-credentials.d.ts +33 -13
  18. package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  19. package/dist/src/plugin/shared/vault-request-credentials.js +97 -44
  20. package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
  21. package/dist/src/plugin/storage.d.ts +17 -0
  22. package/dist/src/plugin/storage.d.ts.map +1 -1
  23. package/dist/src/plugin/storage.js +44 -10
  24. package/dist/src/plugin/storage.js.map +1 -1
  25. package/dist/src/runtime-paths.d.ts +2 -1
  26. package/dist/src/runtime-paths.d.ts.map +1 -1
  27. package/dist/src/runtime-paths.js +5 -5
  28. package/dist/src/runtime-paths.js.map +1 -1
  29. package/dist/src/tui/quota-layout.d.ts +1 -1
  30. package/dist/src/tui/quota-layout.js +1 -1
  31. package/dist/src/tui/sidebar-frame.d.ts +109 -0
  32. package/dist/src/tui/sidebar-frame.d.ts.map +1 -0
  33. package/dist/src/tui/sidebar-frame.js +244 -0
  34. package/dist/src/tui/sidebar-frame.js.map +1 -0
  35. package/dist/src/tui.d.ts.map +1 -1
  36. package/dist/src/tui.js +11 -251
  37. package/dist/src/tui.js.map +1 -1
  38. package/dist/tui-build-map.json +120 -92
  39. package/dist/tui-ga-build-map.json +22 -8
  40. package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
  41. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +33 -13
  42. package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
  43. package/dist/types/src/plugin/storage.d.ts +17 -0
  44. package/dist/types/src/plugin/storage.d.ts.map +1 -1
  45. package/dist/types/src/runtime-paths.d.ts +2 -1
  46. package/dist/types/src/runtime-paths.d.ts.map +1 -1
  47. package/package.json +2 -2
  48. package/src/tui/entry.mjs +19 -1
  49. package/src/tui-compiled/sidebar-projection.js +119 -0
  50. package/src/tui-compiled/tui/quota-layout.js +1 -1
  51. package/src/tui-compiled/tui/sidebar-frame.js +657 -0
  52. package/src/tui-compiled/tui.js +25 -606
  53. package/src/tui-ga-compiled/host-ga.js +116 -124
  54. package/src/tui-ga-compiled/shared/ced204104a639c9c-sidebar-frame.js +657 -0
  55. package/src/tui-ga-compiled/shared/dd4c9e1a907f8ef0-quota-layout.js +1 -1
  56. package/src/tui-ga-raw/host-ga.tsx +157 -95
  57. package/src/tui-ga-raw/shared/ced204104a639c9c-sidebar-frame.tsx +603 -0
  58. package/src/tui-ga-raw/shared/dd4c9e1a907f8ef0-quota-layout.tsx +1 -1
  59. package/src/tui-raw/sidebar-projection.js +119 -0
  60. package/src/tui-raw/tui/quota-layout.tsx +1 -1
  61. package/src/tui-raw/tui/sidebar-frame.tsx +603 -0
  62. package/src/tui-raw/tui.tsx +25 -523
  63. package/src/tui.tsx +25 -523
package/dist/server.js CHANGED
@@ -14637,14 +14637,52 @@ function decodeAccountStorePointer(value, legacyPath) {
14637
14637
  throw new AccountMigrationError("pointer directory basename differs from its derived generation");
14638
14638
  return { schemaVersion: 1, id, directoryBasename: basename(paths.storeDir) };
14639
14639
  }
14640
- async function readPointer(legacyPath) {
14640
+ function decodeAccountStorePointerRecord(value, legacyPath) {
14641
+ if (object(value, "pointer").schemaVersion !== 2)
14642
+ return decodeAccountStorePointer(value, legacyPath);
14643
+ const raw = exact(value, ["schemaVersion", "id", "directoryBasename", "relocatedTo"], "forward");
14644
+ const id = text(raw.id, UUID, "forward source generation");
14645
+ const paths = generationPaths(legacyPath, id);
14646
+ if (raw.directoryBasename !== basename(paths.storeDir))
14647
+ throw new AccountMigrationError("forward directory basename differs from its derived generation");
14648
+ const target = exact(raw.relocatedTo, ["legacyPath", "id"], "forward target");
14649
+ if (typeof target.legacyPath !== "string")
14650
+ throw new AccountMigrationError("forward target path is invalid");
14651
+ const targetId = text(target.id, UUID, "forward target generation");
14652
+ const targetPaths = generationPaths(target.legacyPath, targetId);
14653
+ if (sameFilesystemPath(targetPaths.legacyPath, legacyPath))
14654
+ throw new AccountMigrationError("forward names its own anchor");
14655
+ return {
14656
+ schemaVersion: 2,
14657
+ id,
14658
+ directoryBasename: basename(paths.storeDir),
14659
+ relocatedTo: {
14660
+ legacyPath: targetPaths.legacyPath,
14661
+ id: targetId
14662
+ }
14663
+ };
14664
+ }
14665
+ async function readPointerRecord(legacyPath) {
14641
14666
  const logical = resolveAccountStorePaths(legacyPath);
14642
14667
  if (await exists(logical.storeDir))
14643
14668
  throw new AccountMigrationError("foreign logical store directory is not pointer authority");
14644
14669
  const path5 = accountStorePointerPath(legacyPath);
14645
14670
  if (!await exists(path5))
14646
14671
  return void 0;
14647
- return decodeAccountStorePointer(jsonBytes(await secureRead(path5)), legacyPath);
14672
+ return decodeAccountStorePointerRecord(jsonBytes(await secureRead(path5)), legacyPath);
14673
+ }
14674
+ async function readPointer(legacyPath) {
14675
+ const record3 = await readPointerRecord(legacyPath);
14676
+ if (record3?.schemaVersion === 2)
14677
+ throw new AccountMigrationError(`the account store moved to ${record3.relocatedTo.legacyPath}; this operation does not follow a moved store`);
14678
+ return record3;
14679
+ }
14680
+ async function forwardTarget(legacyPath, forward) {
14681
+ const target = forward.relocatedTo.legacyPath;
14682
+ const published = await readPointerRecord(target);
14683
+ if (published?.schemaVersion !== 1 || published.id !== forward.relocatedTo.id)
14684
+ throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(legacyPath)} names generation ${forward.relocatedTo.id}, which ${accountStorePointerPath(target)} does not publish`);
14685
+ return target;
14648
14686
  }
14649
14687
  async function resolvePublishedAccountStorePaths(legacyPath) {
14650
14688
  const pointer = await readPointer(legacyPath);
@@ -14900,7 +14938,7 @@ function decodeAccountStoreGeneration(value) {
14900
14938
  "sourceKind",
14901
14939
  "initialManifestSha256"
14902
14940
  ], "generation");
14903
- if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent")
14941
+ if (raw.schemaVersion !== 1 || typeof raw.legacyPath !== "string" || raw.sourceKind !== "file" && raw.sourceKind !== "absent" && raw.sourceKind !== "generation")
14904
14942
  throw new AccountMigrationError("generation schema is invalid");
14905
14943
  const id = text(raw.id, UUID, "generation id");
14906
14944
  const paths = generationPaths(raw.legacyPath, id);
@@ -14999,7 +15037,8 @@ function decodeAccountMigrationJournal(value) {
14999
15037
  "verification",
15000
15038
  "retiredSha256",
15001
15039
  "rollback",
15002
- "cancelled"
15040
+ "cancelled",
15041
+ "relocation"
15003
15042
  ], "journal");
15004
15043
  if (raw.schemaVersion !== 1)
15005
15044
  throw new AccountMigrationError("unsupported journal schema");
@@ -15019,10 +15058,10 @@ function decodeAccountMigrationJournal(value) {
15019
15058
  if (phase === void 0)
15020
15059
  throw new AccountMigrationError("journal phase is invalid");
15021
15060
  const sourceKind = raw.sourceKind;
15022
- if (sourceKind !== "file" && sourceKind !== "absent")
15061
+ if (sourceKind !== "file" && sourceKind !== "absent" && sourceKind !== "generation")
15023
15062
  throw new AccountMigrationError("journal source kind is invalid");
15024
- const sourceSha256 = sourceKind === "file" ? text(raw.sourceSha256, SHA256, "journal.sourceSha256") : void 0;
15025
- const captureSha256 = sourceKind === "file" ? text(raw.captureSha256, SHA256, "journal.captureSha256") : void 0;
15063
+ const sourceSha256 = sourceKind !== "absent" ? text(raw.sourceSha256, SHA256, "journal.sourceSha256") : void 0;
15064
+ const captureSha256 = sourceKind !== "absent" ? text(raw.captureSha256, SHA256, "journal.captureSha256") : void 0;
15026
15065
  if (sourceKind === "absent" && Object.hasOwn(raw, "captureSha256"))
15027
15066
  throw new AccountMigrationError("absent source cannot claim a captured file snapshot");
15028
15067
  if (sourceKind === "absent" && Object.hasOwn(raw, "sourceSha256"))
@@ -15039,7 +15078,7 @@ function decodeAccountMigrationJournal(value) {
15039
15078
  const sourceVersion = m.sourceVersion;
15040
15079
  if (sourceVersion !== null && sourceVersion !== 1 && sourceVersion !== 2 && sourceVersion !== 3 && sourceVersion !== 4)
15041
15080
  throw new AccountMigrationError("manifest source version is invalid");
15042
- if (sourceKind === "file" && sourceVersion === null || sourceKind === "absent" && sourceVersion !== null)
15081
+ if (sourceKind === "file" && sourceVersion === null || sourceKind !== "file" && sourceVersion !== null)
15043
15082
  throw new AccountMigrationError("manifest version differs from source kind");
15044
15083
  if (!finite(m.normalizationClock) || !finite(m.effectiveActiveIndex))
15045
15084
  throw new AccountMigrationError("manifest clock or cursor is invalid");
@@ -15069,6 +15108,10 @@ function decodeAccountMigrationJournal(value) {
15069
15108
  schemaVersion: 1
15070
15109
  }) || manifest.effectiveActiveIndex !== 0))
15071
15110
  throw new AccountMigrationError("absent-source manifest must be explicitly empty with no invented cursors");
15111
+ if (sourceKind === "generation" && (accounts.length || !isDeepStrictEqual(encodeRoutingSettings(manifest.routing), {
15112
+ schemaVersion: 1
15113
+ }) || manifest.effectiveActiveIndex !== 0))
15114
+ throw new AccountMigrationError("moved-store manifest must be explicitly empty");
15072
15115
  const effective = accounts.length ? Math.max(0, Math.min(manifest.routing.activeIndex ?? 0, accounts.length - 1)) : 0;
15073
15116
  if (effective !== manifest.effectiveActiveIndex)
15074
15117
  throw new AccountMigrationError("manifest effective cursor differs");
@@ -15116,6 +15159,24 @@ function decodeAccountMigrationJournal(value) {
15116
15159
  throw new AccountMigrationError("absent source cannot claim retired bytes");
15117
15160
  if (retiredSha256 !== void 0 && retiredSha256 !== sourceSha256)
15118
15161
  throw new AccountMigrationError("retired bytes are not associated with source");
15162
+ const relocation = decodeRelocation(raw, sourceKind, paths.legacyPath);
15163
+ if (sourceKind === "generation") {
15164
+ if (retiredSha256 !== void 0)
15165
+ throw new AccountMigrationError("moved source cannot claim retired pool-file bytes");
15166
+ if (relocation === void 0)
15167
+ throw new AccountMigrationError("moved source lacks its relocation evidence");
15168
+ if (operation === "rollback")
15169
+ throw new AccountMigrationError("a moved account store is not rolled back; move it back first with `antigravity-auth store relocate --back --offline`");
15170
+ if (relocation.sourceForwarded && !relocation.sourceTombstoned)
15171
+ throw new AccountMigrationError("source forward precedes its management tombstone");
15172
+ if ((relocation.sourceTombstoned || relocation.sourceForwarded) && (!verification || phase !== "retire" && phase !== "activate"))
15173
+ throw new AccountMigrationError("source tombstone or forward precedes durable verification");
15174
+ if (status === "active" && !relocation.sourceForwarded)
15175
+ throw new AccountMigrationError("active moved store lacks its source forward");
15176
+ if (phase === "activate" && !relocation.sourceForwarded)
15177
+ throw new AccountMigrationError("moved-store activation lacks its source forward");
15178
+ }
15179
+ const retirementRecorded = sourceKind === "file" ? retiredSha256 !== void 0 : sourceKind === "absent" ? raw.sourceAbsenceVerified === true : relocation?.sourceForwarded === true;
15119
15180
  let rollback;
15120
15181
  if (Object.hasOwn(raw, "rollback")) {
15121
15182
  const r = exact(raw.rollback, ["id", "snapshotSha256", "exportSha256", "rows", "successorInactive"], "rollback");
@@ -15141,13 +15202,13 @@ function decodeAccountMigrationJournal(value) {
15141
15202
  throw new AccountMigrationError("verification acknowledged an incomplete import");
15142
15203
  if (operation === "migrate" && (retiredSha256 !== void 0 || raw.sourceAbsenceVerified === true) && (!verification || phase !== "retire" && phase !== "activate"))
15143
15204
  throw new AccountMigrationError("retirement association precedes durable verification");
15144
- if (operation === "migrate" && phase === "activate" && (sourceKind === "file" ? retiredSha256 === void 0 : raw.sourceAbsenceVerified !== true))
15205
+ if (operation === "migrate" && phase === "activate" && !retirementRecorded)
15145
15206
  throw new AccountMigrationError("activation lacks its actual source retirement association");
15146
- if (status === "active" && (operation !== "migrate" || phase !== "activate" || (sourceKind === "file" ? retiredSha256 === void 0 : raw.sourceAbsenceVerified !== true) || rollback !== void 0 || cancelled))
15207
+ if (status === "active" && (operation !== "migrate" || phase !== "activate" || !retirementRecorded || rollback !== void 0 || cancelled))
15147
15208
  throw new AccountMigrationError("active receipt is incomplete");
15148
15209
  if (operation === "rollback" && rollback === void 0 && !cancelled)
15149
15210
  throw new AccountMigrationError("rollback lacks its current-credential snapshot");
15150
- if (operation === "rollback" && !cancelled && (verification === void 0 || (sourceKind === "file" ? retiredSha256 === void 0 : raw.sourceAbsenceVerified !== true)))
15211
+ if (operation === "rollback" && !cancelled && (verification === void 0 || !retirementRecorded))
15151
15212
  throw new AccountMigrationError("rollback lacks the original verified retirement");
15152
15213
  if (status === "inactive" && !cancelled && (operation !== "rollback" || phase !== "activate" || rollback === void 0))
15153
15214
  throw new AccountMigrationError("inactive receipt lacks a completed rollback");
@@ -15171,7 +15232,53 @@ function decodeAccountMigrationJournal(value) {
15171
15232
  ...verification === void 0 ? {} : { verification },
15172
15233
  ...retiredSha256 === void 0 ? {} : { retiredSha256 },
15173
15234
  ...rollback === void 0 ? {} : { rollback },
15174
- ...cancelled ? { cancelled: true } : {}
15235
+ ...cancelled ? { cancelled: true } : {},
15236
+ ...relocation === void 0 ? {} : { relocation }
15237
+ };
15238
+ }
15239
+ function decodeRelocation(raw, sourceKind, legacyPath) {
15240
+ if (!Object.hasOwn(raw, "relocation"))
15241
+ return void 0;
15242
+ if (sourceKind !== "generation")
15243
+ throw new AccountMigrationError("only a moved store records relocation evidence");
15244
+ const r = exact(raw.relocation, ["source", "rows", "sourceTombstoned", "sourceForwarded"], "relocation");
15245
+ const s = exact(r.source, [
15246
+ "legacyPath",
15247
+ "storeDir",
15248
+ "journalId",
15249
+ "configSha256",
15250
+ "stateSha256",
15251
+ "statePresent"
15252
+ ], "relocation source");
15253
+ if (typeof s.legacyPath !== "string")
15254
+ throw new AccountMigrationError("relocation source path is invalid");
15255
+ const journalId = text(s.journalId, UUID, "relocation source journal");
15256
+ const source = generationPaths(s.legacyPath, journalId);
15257
+ if (s.storeDir !== source.storeDir)
15258
+ throw new AccountMigrationError("relocation source association differs");
15259
+ if (sameFilesystemPath(source.legacyPath, legacyPath))
15260
+ throw new AccountMigrationError("relocation source and target share one anchor");
15261
+ if (typeof s.statePresent !== "boolean")
15262
+ throw new AccountMigrationError("relocation state presence is invalid");
15263
+ if (!s.statePresent && Object.hasOwn(s, "stateSha256"))
15264
+ throw new AccountMigrationError("absent source state cannot claim a file hash");
15265
+ const rows = list(r.rows, "relocation rows").map((id) => text(id, UUID, "relocation row id"));
15266
+ if (new Set(rows).size !== rows.length)
15267
+ throw new AccountMigrationError("relocation rows are duplicated");
15268
+ if (typeof r.sourceTombstoned !== "boolean" || typeof r.sourceForwarded !== "boolean")
15269
+ throw new AccountMigrationError("relocation progress flags are invalid");
15270
+ return {
15271
+ source: {
15272
+ legacyPath: source.legacyPath,
15273
+ storeDir: source.storeDir,
15274
+ journalId,
15275
+ configSha256: text(s.configSha256, SHA256, "relocation config hash"),
15276
+ ...s.statePresent ? { stateSha256: text(s.stateSha256, SHA256, "relocation state hash") } : {},
15277
+ statePresent: s.statePresent
15278
+ },
15279
+ rows,
15280
+ sourceTombstoned: r.sourceTombstoned,
15281
+ sourceForwarded: r.sourceForwarded
15175
15282
  };
15176
15283
  }
15177
15284
  function pendingLockFailure(modules, error) {
@@ -15461,6 +15568,8 @@ async function verifyCopies(paths, journal, retired) {
15461
15568
  const capture2 = await secureRead(join(paths.transfersDir, `${journal.id}.capture.json`));
15462
15569
  if (digest(capture2) !== journal.captureSha256 || !isDeepStrictEqual(jsonBytes(capture2), captureJson(journal)))
15463
15570
  throw new AccountMigrationError("journal differs from its exclusive capture snapshot");
15571
+ if (journal.sourceKind === "generation")
15572
+ return verifyRelocationSnapshot(backup, journal);
15464
15573
  const expected = parseLegacyAccountStorage(new TextDecoder("utf-8", { fatal: true }).decode(backup), journal.manifest.normalizationClock);
15465
15574
  if (!isDeepStrictEqual(manifestJson(expected), manifestJson(journal.manifest)))
15466
15575
  throw new AccountMigrationError("captured manifest differs from its verified original source");
@@ -15479,9 +15588,40 @@ function captureJson(journal) {
15479
15588
  sourceKind: journal.sourceKind,
15480
15589
  sourceSha256: journal.sourceSha256,
15481
15590
  manifest: manifestJson(journal.manifest),
15482
- mapping: journal.mapping
15591
+ mapping: journal.mapping,
15592
+ ...journal.relocation === void 0 ? {} : { relocation: { source: journal.relocation.source } }
15483
15593
  };
15484
15594
  }
15595
+ function base64Bytes(value, path5) {
15596
+ if (typeof value !== "string")
15597
+ throw new AccountMigrationError(`${path5} is invalid`);
15598
+ const bytes = Buffer.from(value, "base64");
15599
+ if (bytes.toString("base64") !== value)
15600
+ throw new AccountMigrationError(`${path5} is not canonical base64`);
15601
+ return bytes;
15602
+ }
15603
+ function decodeRelocationSnapshot(value) {
15604
+ const raw = exact(value, ["config", "state", "journal"], "moved snapshot");
15605
+ return {
15606
+ config: base64Bytes(raw.config, "moved snapshot config"),
15607
+ ...Object.hasOwn(raw, "state") ? { state: base64Bytes(raw.state, "moved snapshot state") } : {},
15608
+ journal: base64Bytes(raw.journal, "moved snapshot journal")
15609
+ };
15610
+ }
15611
+ function verifyRelocationSnapshot(backup, journal) {
15612
+ const source = journal.relocation?.source;
15613
+ if (source === void 0)
15614
+ throw new AccountMigrationError("moved source lacks its relocation evidence");
15615
+ const snapshot2 = decodeRelocationSnapshot(jsonBytes(backup));
15616
+ if (digest(snapshot2.config) !== source.configSha256 || snapshot2.state !== void 0 !== source.statePresent || snapshot2.state !== void 0 && digest(snapshot2.state) !== source.stateSha256)
15617
+ throw new AccountMigrationError("moved source snapshot differs from its recorded hashes");
15618
+ const copied = decodeAccountMigrationJournal(jsonBytes(snapshot2.journal));
15619
+ if (copied.id !== source.journalId || copied.legacyPath !== source.legacyPath || copied.storeDir !== source.storeDir || copied.status !== "active")
15620
+ throw new AccountMigrationError("moved source snapshot is not the active source generation");
15621
+ const config = object(jsonBytes(snapshot2.config), "moved source config");
15622
+ if (!isDeepStrictEqual(decodeAccountStoreGeneration(config[ACCOUNT_STORE_GENERATION_SETTINGS_KEY]), generationJson(copied)))
15623
+ throw new AccountMigrationError("moved source snapshot belongs to another generation");
15624
+ }
15485
15625
  async function synchronizedSnapshot(paths, boundary) {
15486
15626
  await syncFile(paths.configPath);
15487
15627
  const statePresent = await exists(paths.statePath);
@@ -15553,7 +15693,7 @@ function receipt(journal) {
15553
15693
  storeDir: journal.storeDir,
15554
15694
  sourceKind: journal.sourceKind,
15555
15695
  durability: journal.verification?.durability ?? accountMigrationDurability(),
15556
- restartRequired: journal.sourceKind === "file" || journal.operation === "rollback"
15696
+ restartRequired: journal.sourceKind !== "absent" || journal.operation === "rollback"
15557
15697
  };
15558
15698
  }
15559
15699
  async function currentSuccessor(store, paths, journal) {
@@ -15637,35 +15777,13 @@ async function trustedCurrentGeneration(store, paths, journal) {
15637
15777
  }
15638
15778
  async function readAccountStoreBinding(legacyPath, modules, now, expectedGeneration) {
15639
15779
  try {
15640
- const paths = await resolvePublishedAccountStorePaths(legacyPath);
15641
- if (!paths)
15642
- return await exists(legacyPath) ? { status: "pending" } : { status: "initialization-required" };
15643
- const journal = await readJournal(paths);
15644
- if (!journal)
15645
- throw new AccountMigrationError("published binding journal missing");
15646
- if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
15647
- throw new AccountMigrationError("bound repository generation differs from pointer");
15648
- if (journal.status === "pending")
15649
- return {
15650
- status: "pending",
15651
- phase: journal.phase,
15652
- operation: journal.operation
15653
- };
15654
- if (journal.status === "inactive")
15655
- return { status: "inactive", id: journal.id };
15656
- if (await exists(legacyPath))
15657
- throw new AccountMigrationError("legacy source was recreated after activation");
15658
- await verifyCopies(paths, journal, true);
15659
- const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
15660
- const pending = settings[MANAGEMENT_SETTINGS_KEY];
15661
- if (pending !== void 0) {
15662
- const record3 = object(pending, "repository management");
15663
- if (record3.kind === "migration")
15664
- return { status: "pending", phase: "activate", operation: "migrate" };
15665
- if (record3.kind !== "clear" && record3.kind !== "replace-pool")
15666
- throw new AccountMigrationError("unknown management owner prevents binding");
15780
+ const record3 = await readPointerRecord(legacyPath);
15781
+ if (record3?.schemaVersion === 2) {
15782
+ if (await exists(legacyPath))
15783
+ throw new AccountMigrationError(`a pool file reappeared at ${legacyPath} after the account store moved to ${record3.relocatedTo.legacyPath}`);
15784
+ return await bindPublishedGeneration(await forwardTarget(legacyPath, record3), modules, now, expectedGeneration, legacyPath);
15667
15785
  }
15668
- return { status: "bound", receipt: receipt(journal), paths };
15786
+ return await bindPublishedGeneration(legacyPath, modules, now, expectedGeneration);
15669
15787
  } catch (error) {
15670
15788
  return {
15671
15789
  status: "error",
@@ -15673,6 +15791,65 @@ async function readAccountStoreBinding(legacyPath, modules, now, expectedGenerat
15673
15791
  };
15674
15792
  }
15675
15793
  }
15794
+ async function assertSourceForwarded(journal, forwardedFrom) {
15795
+ const source = journal.relocation?.source;
15796
+ if (source === void 0)
15797
+ throw new AccountMigrationError("moved source lacks its relocation evidence");
15798
+ const pointer = accountStorePointerPath(source.legacyPath);
15799
+ if (forwardedFrom !== void 0 && forwardedFrom !== source.legacyPath)
15800
+ throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store moved from ${source.legacyPath}`);
15801
+ if (await exists(source.legacyPath))
15802
+ throw new AccountMigrationError(`a pool file reappeared at ${source.legacyPath} after the account store moved to ${journal.legacyPath}`);
15803
+ const record3 = await readPointerRecord(source.legacyPath);
15804
+ if (record3 === void 0)
15805
+ throw new AccountMigrationError(`the forwarding pointer ${pointer} to the moved account store at ${journal.storeDir} is missing; restore it`);
15806
+ if (record3.schemaVersion === 1)
15807
+ throw new AccountMigrationError(`the account store in ${dirname(source.legacyPath)} was reactivated: ${pointer} publishes generation ${record3.id} while the moved store at ${journal.storeDir} is active; restore the forwarding pointer, or run \`antigravity-auth store relocate\``);
15808
+ if (record3.id !== source.journalId || record3.relocatedTo.legacyPath !== journal.legacyPath || record3.relocatedTo.id !== journal.id)
15809
+ throw new AccountMigrationError(`the forwarding pointer ${pointer} names another store than the moved account store at ${journal.storeDir}`);
15810
+ }
15811
+ async function bindPublishedGeneration(legacyPath, modules, now, expectedGeneration, forwardedFrom) {
15812
+ const paths = await resolvePublishedAccountStorePaths(legacyPath);
15813
+ if (!paths) {
15814
+ if (forwardedFrom !== void 0)
15815
+ throw new AccountMigrationError("forwarded anchor publishes no generation");
15816
+ return await exists(legacyPath) ? { status: "pending" } : { status: "initialization-required" };
15817
+ }
15818
+ const journal = await readJournal(paths);
15819
+ if (!journal)
15820
+ throw new AccountMigrationError("published binding journal missing");
15821
+ if (expectedGeneration !== void 0 && journal.id !== expectedGeneration)
15822
+ throw new AccountMigrationError("bound repository generation differs from pointer");
15823
+ if (forwardedFrom !== void 0 && journal.sourceKind !== "generation")
15824
+ throw new AccountMigrationError(`the forwarding pointer ${accountStorePointerPath(forwardedFrom)} leads to a store that was not moved there`);
15825
+ if (journal.sourceKind === "generation" && journal.status === "pending")
15826
+ throw new AccountMigrationError(`a move of the account store to ${journal.storeDir} is unfinished; finish it with the version that started it`);
15827
+ if (journal.status === "pending")
15828
+ return {
15829
+ status: "pending",
15830
+ phase: journal.phase,
15831
+ operation: journal.operation
15832
+ };
15833
+ if (journal.status === "inactive")
15834
+ return { status: "inactive", id: journal.id };
15835
+ if (await exists(legacyPath))
15836
+ throw new AccountMigrationError("legacy source was recreated after activation");
15837
+ await verifyCopies(paths, journal, true);
15838
+ if (journal.sourceKind === "generation")
15839
+ await assertSourceForwarded(journal, forwardedFrom);
15840
+ const settings = await trustedCurrentGeneration(openAdmissionStore(modules, paths, now), paths, journal);
15841
+ const pending = settings[MANAGEMENT_SETTINGS_KEY];
15842
+ if (pending !== void 0) {
15843
+ const record3 = object(pending, "repository management");
15844
+ if (record3.kind === "migration" && record3.id !== journal.id)
15845
+ throw new AccountMigrationError(`the account store at ${paths.storeDir} was moved to generation ${String(record3.id)}, but ${accountStorePointerPath(legacyPath)} publishes the old store again; restore the forwarding pointer, or run \`antigravity-auth store relocate\``);
15846
+ if (record3.kind === "migration")
15847
+ return { status: "pending", phase: "activate", operation: "migrate" };
15848
+ if (record3.kind !== "clear" && record3.kind !== "replace-pool")
15849
+ throw new AccountMigrationError("unknown management owner prevents binding");
15850
+ }
15851
+ return { status: "bound", receipt: receipt(journal), paths };
15852
+ }
15676
15853
  async function readAccountStoreAdmission(legacyPath, modules, now, expectedGeneration) {
15677
15854
  const binding = await readAccountStoreBinding(legacyPath, modules, now, expectedGeneration);
15678
15855
  if (binding.status !== "bound")
@@ -15966,6 +16143,8 @@ function createAccountMigrationFactory(modules) {
15966
16143
  const existing = await readJournal(paths);
15967
16144
  if (!existing)
15968
16145
  throw new AccountMigrationError("published generation journal missing");
16146
+ if (existing.sourceKind === "generation")
16147
+ throw new AccountMigrationError("a moved account store is finished by `antigravity-auth store relocate`, not by migrate");
15969
16148
  if (existing.status === "inactive") {
15970
16149
  previous = existing;
15971
16150
  await modules.fs.withLock(paths.configPath, {
@@ -16141,6 +16320,9 @@ function createAccountRollbackFactory(modules) {
16141
16320
  throw new AccountMigrationError("stopped processes and timers must be explicitly confirmed");
16142
16321
  try {
16143
16322
  return await withParentTopology(modules, options.legacyPath, async () => {
16323
+ const record3 = await readPointerRecord(options.legacyPath);
16324
+ if (record3?.schemaVersion === 2)
16325
+ throw new AccountMigrationError(`the account store moved to ${record3.relocatedTo.legacyPath}; move it back with \`antigravity-auth store relocate --back --offline\` before rolling it back`);
16144
16326
  const paths = await resolvePublishedAccountStorePaths(options.legacyPath);
16145
16327
  if (!paths)
16146
16328
  throw new AccountMigrationError("rollback requires a published generation");
@@ -16153,6 +16335,8 @@ function createAccountRollbackFactory(modules) {
16153
16335
  const initialJournal = await readJournal(paths);
16154
16336
  if (!initialJournal)
16155
16337
  throw new AccountMigrationError("rollback requires an owned migration generation");
16338
+ if (initialJournal.sourceKind === "generation")
16339
+ throw new AccountMigrationError(`this account store was moved here from ${initialJournal.relocation?.source.legacyPath}; move it back with \`antigravity-auth store relocate --back --offline\` before rolling it back`);
16156
16340
  let journal = initialJournal;
16157
16341
  const store = openMigrationStore(modules, paths, options.now, writeObserver(paths, lease, options.onBoundary));
16158
16342
  if (journal.status === "inactive") {
@@ -26804,6 +26988,124 @@ async function commitVaultProviderState(input2) {
26804
26988
  return { result };
26805
26989
  });
26806
26990
  }
26991
+ async function commitVaultProviderStates(input2) {
26992
+ const { claustrum, fs: fs4, statePath } = input2;
26993
+ input2.signal?.throwIfAborted();
26994
+ const results = new Array(input2.entries.length);
26995
+ const refuse2 = (index, error) => {
26996
+ results[index] = { status: "refused", error };
26997
+ };
26998
+ let pending = [];
26999
+ for (const [index, entry] of input2.entries.entries()) {
27000
+ try {
27001
+ pending.push({
27002
+ index,
27003
+ attribution: pinAttribution(entry.attribution),
27004
+ update: entry.update
27005
+ });
27006
+ } catch (error) {
27007
+ refuse2(index, error);
27008
+ }
27009
+ }
27010
+ const keepBound = (roster, entries) => entries.filter((entry) => {
27011
+ try {
27012
+ assertRosterBinding(roster, entry.attribution, claustrum);
27013
+ return true;
27014
+ } catch (error) {
27015
+ refuse2(entry.index, error);
27016
+ return false;
27017
+ }
27018
+ });
27019
+ if (pending.length > 0)
27020
+ pending = keepBound(await claustrum.readVaultRoster(input2.rosterPath), pending);
27021
+ input2.signal?.throwIfAborted();
27022
+ if (pending.length === 0)
27023
+ return results;
27024
+ await claustrum.mutateVaultRoster(input2.rosterPath, async (roster, rosterLock) => {
27025
+ input2.signal?.throwIfAborted();
27026
+ const bound = keepBound(roster, pending);
27027
+ if (bound.length === 0)
27028
+ return { result: void 0 };
27029
+ await fs4.withLock(statePath, VAULT_PROVIDER_STATE_LOCK, async (stateLock) => {
27030
+ input2.signal?.throwIfAborted();
27031
+ const proofs = await Promise.allSettled(bound.map((entry) => input2.verify(entry.attribution)));
27032
+ input2.signal?.throwIfAborted();
27033
+ const proven = bound.filter((entry, at) => {
27034
+ const proof = proofs[at];
27035
+ if (proof?.status !== "rejected")
27036
+ return true;
27037
+ refuse2(entry.index, proof.reason);
27038
+ return false;
27039
+ });
27040
+ if (proven.length === 0)
27041
+ return;
27042
+ const file = await readVaultProviderState(statePath);
27043
+ input2.signal?.throwIfAborted();
27044
+ const accounts = {
27045
+ ...file.accounts
27046
+ };
27047
+ const written = [];
27048
+ for (const entry of proven) {
27049
+ const identity3 = entry.attribution.accountIdentity;
27050
+ const current = Object.hasOwn(accounts, identity3) ? accounts[identity3] : void 0;
27051
+ try {
27052
+ const requested = entry.update(current);
27053
+ if (isRecord9(requested) && typeof requested.then === "function")
27054
+ throw new VaultProviderStateError("invalid-update", "a state update must be synchronous");
27055
+ if (requested === void 0 || requested === null && !current) {
27056
+ results[entry.index] = current ? { status: "unchanged", state: current } : { status: "unchanged" };
27057
+ continue;
27058
+ }
27059
+ if (requested === null) {
27060
+ delete accounts[identity3];
27061
+ written.push(entry);
27062
+ continue;
27063
+ }
27064
+ const next = Object.freeze({
27065
+ observed: Object.freeze({
27066
+ routeId: entry.attribution.routeId,
27067
+ credentialId: entry.attribution.credentialId,
27068
+ recordVersion: entry.attribution.recordVersion
27069
+ }),
27070
+ ...decodeValue(requested, "update", "typed")
27071
+ });
27072
+ accounts[identity3] = next;
27073
+ written.push({ ...entry, next });
27074
+ } catch (error) {
27075
+ refuse2(entry.index, error);
27076
+ }
27077
+ }
27078
+ if (written.length === 0)
27079
+ return;
27080
+ const encoded = encodeVaultProviderState({ ...file, accounts });
27081
+ try {
27082
+ await fs4.writeJsonAtomic(statePath, encoded, {
27083
+ beforeRename: async () => {
27084
+ await rosterLock.assertOwned();
27085
+ await stateLock.assertOwned();
27086
+ input2.signal?.throwIfAborted();
27087
+ }
27088
+ });
27089
+ } catch (error) {
27090
+ let reloaded;
27091
+ try {
27092
+ reloaded = await readVaultProviderState(statePath);
27093
+ } catch {
27094
+ reloaded = void 0;
27095
+ }
27096
+ for (const entry of written) {
27097
+ const state = reloaded && vaultAccountState(reloaded, entry.attribution.accountIdentity);
27098
+ results[entry.index] = state ? { status: "uncertain", error, state } : { status: "uncertain", error };
27099
+ }
27100
+ return;
27101
+ }
27102
+ for (const entry of written)
27103
+ results[entry.index] = entry.next ? { status: "written", state: entry.next } : { status: "cleared" };
27104
+ });
27105
+ return { result: void 0 };
27106
+ });
27107
+ return results;
27108
+ }
26807
27109
 
26808
27110
  // ../core/dist/vault-account-source.js
26809
27111
  function untilAborted2(pending, signal) {
@@ -27060,6 +27362,20 @@ function createAntigravityVaultAccountSource(options) {
27060
27362
  update
27061
27363
  });
27062
27364
  },
27365
+ commitStates: async (entries, signal) => {
27366
+ assertOpen(signal);
27367
+ if (!options.state)
27368
+ throw new AntigravityVaultSourceError("state-unavailable", "No provider-state sidecar is configured for this vault source");
27369
+ return commitVaultProviderStates({
27370
+ claustrum,
27371
+ fs: options.state.fs,
27372
+ rosterPath: options.rosterPath,
27373
+ statePath: options.state.path,
27374
+ entries,
27375
+ verify: (by) => verifyAttribution(by, signal),
27376
+ signal
27377
+ });
27378
+ },
27063
27379
  decline: async (ref) => {
27064
27380
  assertOpen();
27065
27381
  await consumer.decline(ref.routeId);
@@ -28109,23 +28425,37 @@ function migrateLegacyWindowsConfig() {
28109
28425
  return false;
28110
28426
  }
28111
28427
  }
28428
+ function resolveWindowsAccountAnchor(newPath, legacyPath) {
28429
+ const standard = resolve12(newPath);
28430
+ const legacy = resolve12(legacyPath);
28431
+ if (standard.toLowerCase() === legacy.toLowerCase()) return newPath;
28432
+ const standardPointer = existsSync3(accountStorePointerPath(standard));
28433
+ const legacyPointer = existsSync3(accountStorePointerPath(legacy));
28434
+ if (standardPointer && legacyPointer) {
28435
+ throw new Error(
28436
+ `Two migrated account stores exist: one is published at ${newPath} and another at ${legacyPath}. Keep one store and remove the other, then restart OpenCode.`
28437
+ );
28438
+ }
28439
+ if (legacyPointer && !standardPointer) return legacyPath;
28440
+ if (!existsSync3(standard) && existsSync3(legacy)) return legacyPath;
28441
+ return newPath;
28442
+ }
28112
28443
  function getStoragePathWithMigration() {
28113
28444
  const newPath = join10(getConfigDir(), "antigravity-accounts.json");
28114
28445
  if (process.platform === "win32") {
28115
28446
  migrateLegacyWindowsConfig();
28116
- if (!existsSync3(newPath)) {
28117
- const legacyPath = join10(
28118
- getLegacyWindowsConfigDir(),
28119
- "antigravity-accounts.json"
28120
- );
28121
- if (existsSync3(legacyPath)) {
28122
- log5.info("Using legacy Windows config path (migration failed)", {
28123
- legacyPath,
28124
- newPath
28125
- });
28126
- return legacyPath;
28127
- }
28447
+ const legacyPath = join10(
28448
+ getLegacyWindowsConfigDir(),
28449
+ "antigravity-accounts.json"
28450
+ );
28451
+ const anchored = resolveWindowsAccountAnchor(newPath, legacyPath);
28452
+ if (resolve12(anchored).toLowerCase() !== resolve12(newPath).toLowerCase() && !existsSync3(accountStorePointerPath(resolve12(anchored)))) {
28453
+ log5.info("Using legacy Windows config path (migration failed)", {
28454
+ legacyPath,
28455
+ newPath
28456
+ });
28128
28457
  }
28458
+ return anchored;
28129
28459
  }
28130
28460
  return newPath;
28131
28461
  }
@@ -28519,9 +28849,11 @@ function stateHomeLogsDir() {
28519
28849
  }
28520
28850
  function legacyAccountFile(configDir = getConfigDir()) {
28521
28851
  const standard = join12(configDir, ACCOUNT_FILE_NAME);
28522
- if (process.platform !== "win32" || existsSync4(standard)) return standard;
28523
- const windows2 = join12(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME);
28524
- return existsSync4(windows2) ? windows2 : standard;
28852
+ if (process.platform !== "win32") return standard;
28853
+ return resolveWindowsAccountAnchor(
28854
+ standard,
28855
+ join12(legacyWindowsConfigDir(), ACCOUNT_FILE_NAME)
28856
+ );
28525
28857
  }
28526
28858
  function legacyVaultDir(accountFile) {
28527
28859
  return join12(dirname16(accountFile), VAULT_DIR_NAME);
@@ -29609,6 +29941,13 @@ function applyDurableSelection(row, metadata) {
29609
29941
  function stateBelongsTo(state, row) {
29610
29942
  return state.observed.routeId === row.route.routeId && state.observed.credentialId === row.route.credentialId;
29611
29943
  }
29944
+ function quotaUpdate(quota) {
29945
+ return (current) => ({
29946
+ ...current?.metadata !== void 0 ? { metadata: current.metadata } : {},
29947
+ quota,
29948
+ ...current?.extensions !== void 0 ? { extensions: current.extensions } : {}
29949
+ });
29950
+ }
29612
29951
  function createVaultSelectionState(options) {
29613
29952
  const now = options.now ?? (() => Date.now());
29614
29953
  const attributions = /* @__PURE__ */ new WeakMap();
@@ -29682,15 +30021,30 @@ function createVaultSelectionState(options) {
29682
30021
  },
29683
30022
  flush: flush2,
29684
30023
  recordQuota(attribution, quota, signal) {
29685
- return options.source.commitState(
30024
+ return options.source.commitState(attribution, quotaUpdate(quota), signal);
30025
+ },
30026
+ async recordQuotas(readings, signal) {
30027
+ const entries = readings.map(({ attribution, quota }) => ({
29686
30028
  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
- );
30029
+ update: quotaUpdate(quota)
30030
+ }));
30031
+ if (options.source.commitStates)
30032
+ return options.source.commitStates(entries, signal);
30033
+ const results = [];
30034
+ for (const { attribution, update } of entries) {
30035
+ if (signal?.aborted) {
30036
+ results.push({ status: "refused", error: signal.reason });
30037
+ continue;
30038
+ }
30039
+ try {
30040
+ results.push(
30041
+ await options.source.commitState(attribution, update, signal)
30042
+ );
30043
+ } catch (error) {
30044
+ results.push({ status: "refused", error });
30045
+ }
30046
+ }
30047
+ return results;
29694
30048
  }
29695
30049
  };
29696
30050
  }
@@ -29820,8 +30174,15 @@ async function checkVaultQuota(input2) {
29820
30174
  const state = input2.pool.state;
29821
30175
  const rows = [...input2.pool.selector.rows];
29822
30176
  const now = input2.now ?? (() => Date.now());
30177
+ const reportError = (error) => {
30178
+ try {
30179
+ input2.onError?.(error);
30180
+ } catch {
30181
+ }
30182
+ };
29823
30183
  let checked = 0;
29824
30184
  if (state === void 0) input2.onOutcome?.("state-invalid");
30185
+ const readings = [];
29825
30186
  for (const row of rows) {
29826
30187
  if (input2.signal.aborted || state === void 0) break;
29827
30188
  try {
@@ -29841,32 +30202,49 @@ async function checkVaultQuota(input2) {
29841
30202
  input2.onOutcome?.("unattributed");
29842
30203
  continue;
29843
30204
  }
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
- }
30205
+ readings.push({
30206
+ attribution,
30207
+ quota: vaultQuotaState(answer.quota, answer.observedAt ?? now())
30208
+ });
29865
30209
  } catch (error) {
29866
- try {
29867
- input2.onError?.(error);
29868
- } catch {
29869
- }
30210
+ reportError(error);
30211
+ }
30212
+ }
30213
+ if (state === void 0 || readings.length === 0 || input2.signal.aborted)
30214
+ return { checked, notChecked: rows.length - checked };
30215
+ let results;
30216
+ try {
30217
+ input2.onStage?.("commit");
30218
+ input2.signal.throwIfAborted();
30219
+ results = await state.recordQuotas(readings, input2.signal);
30220
+ } catch (error) {
30221
+ for (const _ of readings) reportError(error);
30222
+ return { checked, notChecked: rows.length - checked };
30223
+ }
30224
+ for (const [at, { attribution, quota: reading }] of readings.entries()) {
30225
+ const result = results[at];
30226
+ if (result === void 0 || result.status === "refused") {
30227
+ reportError(
30228
+ result === void 0 ? new Error("The provider-state commit returned no result") : result.error
30229
+ );
30230
+ continue;
30231
+ }
30232
+ if (result.status !== "written") {
30233
+ input2.onOutcome?.(
30234
+ result.status === "uncertain" ? "write-uncertain" : "commit-unchanged",
30235
+ result.status === "uncertain" ? result.error : void 0
30236
+ );
30237
+ continue;
30238
+ }
30239
+ checked += 1;
30240
+ input2.onOutcome?.("recorded");
30241
+ const live = input2.pool.selector.rows.find(
30242
+ (candidate) => candidate.route.routeId === attribution.routeId && candidate.route.credentialId === attribution.credentialId && candidate.route.accountIdentity === attribution.accountIdentity
30243
+ );
30244
+ if (live !== void 0) {
30245
+ const cached = cachedQuotaOf(reading);
30246
+ if (cached !== void 0) live.cachedQuota = cached;
30247
+ live.cachedQuotaUpdatedAt = reading.cachedQuotaUpdatedAt ?? void 0;
29870
30248
  }
29871
30249
  }
29872
30250
  return { checked, notChecked: rows.length - checked };
@@ -44964,6 +45342,17 @@ function project2(read, registry, health) {
44964
45342
  });
44965
45343
  return { read, rows, overLimit: null, plan };
44966
45344
  }
45345
+ function readingTime(value) {
45346
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
45347
+ }
45348
+ function newestReadingTime(times) {
45349
+ let newest = null;
45350
+ for (const value of times) {
45351
+ const at = readingTime(value);
45352
+ if (at !== null && (newest === null || at > newest)) newest = at;
45353
+ }
45354
+ return newest;
45355
+ }
44967
45356
  function abortError(signal) {
44968
45357
  return signal.reason instanceof Error ? signal.reason : new Error("The state read was aborted");
44969
45358
  }
@@ -44982,6 +45371,12 @@ function createGaAccountStateSource(options) {
44982
45371
  if (input2.signal.aborted) throw abortError(input2.signal);
44983
45372
  const retiredSelectors = projected2.plan?.commit() ?? [];
44984
45373
  readSeq = options.nextReadSeq?.() ?? readSeq + 1;
45374
+ const checkedAt = newestReadingTime([
45375
+ status.checkedAt,
45376
+ ...read.status === "ready" ? read.rows.map(
45377
+ (row) => row.quota.status === "present" ? row.quota.quota.cachedQuotaUpdatedAt : void 0
45378
+ ) : []
45379
+ ]);
44985
45380
  const answer = {
44986
45381
  readSeq,
44987
45382
  accounts: projected2.overLimit !== null ? { kind: "over-limit", count: projected2.overLimit } : {
@@ -44992,7 +45387,7 @@ function createGaAccountStateSource(options) {
44992
45387
  }))
44993
45388
  },
44994
45389
  route,
44995
- status,
45390
+ status: { ...status, checkedAt },
44996
45391
  settings
44997
45392
  };
44998
45393
  if (options.observe) {
@@ -45665,9 +46060,16 @@ function createGaVaultStateSource(input2) {
45665
46060
  const overLimit = rows.length > ACCOUNT_LIMIT;
45666
46061
  const quotaOf2 = (row) => {
45667
46062
  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 } : {};
46063
+ const storedQuota = reading ? cachedQuotaOf(reading) : void 0;
46064
+ const [cachedQuota, updatedAt] = storedQuota !== void 0 ? [storedQuota, reading?.cachedQuotaUpdatedAt] : [row.cachedQuota, row.cachedQuotaUpdatedAt];
46065
+ if (cachedQuota === void 0) return {};
46066
+ const at = readingTime(updatedAt);
46067
+ return {
46068
+ cachedQuota,
46069
+ ...at !== null ? { cachedQuotaUpdatedAt: at } : {}
46070
+ };
45670
46071
  };
46072
+ const quotas = rows.map(quotaOf2);
45671
46073
  const answer = {
45672
46074
  readSeq,
45673
46075
  accounts: overLimit ? { kind: "over-limit", count: rows.length } : {
@@ -45679,13 +46081,15 @@ function createGaVaultStateSource(input2) {
45679
46081
  enabled: row.enabled,
45680
46082
  current: false,
45681
46083
  ...row.coolingDownUntil !== void 0 ? { coolingDownUntil: row.coolingDownUntil } : {},
45682
- ...quotaOf2(row)
46084
+ ...quotas[position]
45683
46085
  }
45684
46086
  }))
45685
46087
  },
45686
46088
  route,
45687
46089
  status: {
45688
- checkedAt: null,
46090
+ checkedAt: newestReadingTime(
46091
+ quotas.map((quota) => quota.cachedQuotaUpdatedAt)
46092
+ ),
45689
46093
  quotaBackoffUntil: null,
45690
46094
  routingAuthoritative: true
45691
46095
  },