opencode-quota-gui 1.3.1 → 1.3.2

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 (155) hide show
  1. package/README.md +16 -12
  2. package/dist/contracts/build-identity.js +1 -1
  3. package/dist/contracts/card-order.d.ts +2 -0
  4. package/dist/contracts/card-order.js +2 -2
  5. package/dist/contracts/card-visibility.d.ts +2 -1
  6. package/dist/contracts/card-visibility.js +2 -1
  7. package/dist/contracts/dashboard.d.ts +87 -5
  8. package/dist/contracts/dashboard.js +10 -0
  9. package/dist/contracts/dto-guards.d.ts +4 -0
  10. package/dist/contracts/dto-guards.js +29 -7
  11. package/dist/contracts/guards.js +3 -1
  12. package/dist/contracts/identity.d.ts +37 -5
  13. package/dist/contracts/identity.js +43 -0
  14. package/dist/contracts/provider-auto-resume.d.ts +9 -0
  15. package/dist/contracts/provider-auto-resume.js +24 -0
  16. package/dist/contracts/provider-failure.d.ts +22 -0
  17. package/dist/contracts/provider-failure.js +25 -1
  18. package/dist/contracts/row-order.d.ts +13 -0
  19. package/dist/contracts/row-order.js +34 -0
  20. package/dist/contracts/row-visibility.d.ts +53 -0
  21. package/dist/contracts/row-visibility.js +130 -0
  22. package/dist/data/modelsdev-pricing.min.json +1 -1
  23. package/dist/data/modelsdev-temporal.min.json +3 -634
  24. package/dist/gui/aggregation.d.ts +29 -1
  25. package/dist/gui/aggregation.js +157 -4
  26. package/dist/gui/analytics-bridge.d.ts +8 -9
  27. package/dist/gui/analytics-bridge.js +197 -54
  28. package/dist/gui/analytics-engine.d.ts +7 -15
  29. package/dist/gui/analytics-engine.js +246 -106
  30. package/dist/gui/analytics-model.d.ts +7 -0
  31. package/dist/gui/analytics-model.js +75 -9
  32. package/dist/gui/analytics-pricing-upkeep.d.ts +21 -0
  33. package/dist/gui/analytics-pricing-upkeep.js +23 -0
  34. package/dist/gui/analytics-protocol.d.ts +17 -7
  35. package/dist/gui/analytics-protocol.js +1 -0
  36. package/dist/gui/analytics-service.d.ts +10 -0
  37. package/dist/gui/analytics-service.js +30 -9
  38. package/dist/gui/analytics-state.d.ts +30 -5
  39. package/dist/gui/analytics-state.js +46 -7
  40. package/dist/gui/analytics-worker-runtime.d.ts +5 -0
  41. package/dist/gui/analytics-worker-runtime.js +9 -1
  42. package/dist/gui/analytics-worker.js +11 -0
  43. package/dist/gui/config.d.ts +2 -2
  44. package/dist/gui/config.js +46 -5
  45. package/dist/gui/identity.d.ts +6 -20
  46. package/dist/gui/identity.js +6 -54
  47. package/dist/gui/primary-quota-windows.js +55 -34
  48. package/dist/gui/provider-cards.d.ts +12 -8
  49. package/dist/gui/provider-cards.js +12 -53
  50. package/dist/gui/quota-notification-detector.d.ts +25 -2
  51. package/dist/gui/quota-notification-detector.js +60 -5
  52. package/dist/gui/quota-notification-observer.d.ts +1 -1
  53. package/dist/gui/quota-notification-observer.js +5 -1
  54. package/dist/gui/quota-observation.d.ts +4 -0
  55. package/dist/gui/quota-observation.js +18 -0
  56. package/dist/gui/rpc.js +3 -0
  57. package/dist/gui/server.js +6 -1
  58. package/dist/gui/snapshot-service.d.ts +3 -17
  59. package/dist/gui/snapshot-service.js +159 -9
  60. package/dist/gui/sources.js +84 -11
  61. package/dist/gui/temporal-status.d.ts +3 -2
  62. package/dist/gui/temporal-status.js +10 -6
  63. package/dist/gui-experimental.cjs +228 -228
  64. package/dist/lib/accounting-format.d.ts +8 -0
  65. package/dist/lib/accounting-format.js +12 -2
  66. package/dist/lib/anthropic-api-auth.d.ts +7 -0
  67. package/dist/lib/anthropic-api-auth.js +27 -0
  68. package/dist/lib/anthropic-api-rate-limits.d.ts +47 -0
  69. package/dist/lib/anthropic-api-rate-limits.js +92 -0
  70. package/dist/lib/anthropic-oauth-throttle.d.ts +76 -0
  71. package/dist/lib/anthropic-oauth-throttle.js +379 -0
  72. package/dist/lib/anthropic.d.ts +22 -4
  73. package/dist/lib/anthropic.js +498 -180
  74. package/dist/lib/cache-observer-ingestion.js +27 -0
  75. package/dist/lib/cache-observer.d.ts +3 -0
  76. package/dist/lib/cache-observer.js +9 -3
  77. package/dist/lib/cli-show.d.ts +5 -0
  78. package/dist/lib/cli-show.js +16 -5
  79. package/dist/lib/cli-status.js +3 -6
  80. package/dist/lib/config.d.ts +1 -1
  81. package/dist/lib/config.js +64 -2
  82. package/dist/lib/dashboard-visibility.d.ts +5 -0
  83. package/dist/lib/dashboard-visibility.js +11 -10
  84. package/dist/lib/display-sanitize.js +1 -0
  85. package/dist/lib/entries.d.ts +10 -1
  86. package/dist/lib/entries.js +4 -0
  87. package/dist/lib/grouped-entry-normalization.js +1 -1
  88. package/dist/lib/maintainer-announcements.js +2 -2
  89. package/dist/lib/modelsdev-pricing.d.ts +74 -2
  90. package/dist/lib/modelsdev-pricing.js +457 -63
  91. package/dist/lib/modelsdev-temporal.d.ts +6 -0
  92. package/dist/lib/modelsdev-temporal.js +16 -2
  93. package/dist/lib/opencode-config-providers.js +2 -2
  94. package/dist/lib/opencode-storage.d.ts +20 -0
  95. package/dist/lib/opencode-storage.js +89 -2
  96. package/dist/lib/opencode-version-core.d.ts +7 -0
  97. package/dist/lib/opencode-version-core.js +10 -0
  98. package/dist/lib/opencode-warming-refresh.d.ts +19 -0
  99. package/dist/lib/opencode-warming-refresh.js +95 -0
  100. package/dist/lib/provider-metadata.d.ts +11 -3
  101. package/dist/lib/provider-metadata.js +20 -2
  102. package/dist/lib/provider-registration.d.ts +342 -3
  103. package/dist/lib/provider-registration.js +409 -27
  104. package/dist/lib/quota-auto-resume.d.ts +74 -0
  105. package/dist/lib/quota-auto-resume.js +539 -0
  106. package/dist/lib/quota-command-format.js +22 -9
  107. package/dist/lib/quota-identity.d.ts +64 -0
  108. package/dist/lib/quota-identity.js +111 -0
  109. package/dist/lib/quota-providers.js +2 -2
  110. package/dist/lib/quota-render-data.js +2 -2
  111. package/dist/lib/quota-reset-notifications.js +11 -155
  112. package/dist/lib/quota-retry-wait.d.ts +106 -5
  113. package/dist/lib/quota-retry-wait.js +301 -34
  114. package/dist/lib/quota-runtime-context.js +1 -0
  115. package/dist/lib/quota-state-codec.d.ts +2 -0
  116. package/dist/lib/quota-state-codec.js +14 -1
  117. package/dist/lib/quota-state.d.ts +1 -1
  118. package/dist/lib/quota-state.js +60 -28
  119. package/dist/lib/quota-stats.d.ts +26 -0
  120. package/dist/lib/quota-stats.js +19 -1
  121. package/dist/lib/quota-surface-data.js +18 -3
  122. package/dist/lib/quota-telemetry.js +2 -2
  123. package/dist/lib/resolved-auth-identity.d.ts +19 -0
  124. package/dist/lib/resolved-auth-identity.js +44 -0
  125. package/dist/lib/state-file-lock.d.ts +26 -0
  126. package/dist/lib/state-file-lock.js +205 -0
  127. package/dist/lib/toast-format-grouped.js +7 -4
  128. package/dist/lib/tui-compact-format.js +29 -16
  129. package/dist/lib/types.d.ts +20 -0
  130. package/dist/lib/types.js +4 -1
  131. package/dist/plugin.js +67 -1
  132. package/dist/providers/alibaba-coding-plan.js +21 -3
  133. package/dist/providers/alibaba-token-plan.js +9 -5
  134. package/dist/providers/anthropic.d.ts +6 -2
  135. package/dist/providers/anthropic.js +123 -14
  136. package/dist/providers/chutes.js +2 -0
  137. package/dist/providers/claude-agent.js +24 -5
  138. package/dist/providers/copilot.js +5 -4
  139. package/dist/providers/glm-coding-plan-provider.js +30 -23
  140. package/dist/providers/ollama-cloud.js +10 -0
  141. package/dist/providers/openai.js +24 -23
  142. package/dist/providers/opencode-go.js +7 -6
  143. package/dist/providers/opencode-zen.js +1 -1
  144. package/dist/providers/result-helpers.d.ts +4 -2
  145. package/dist/providers/result-helpers.js +5 -1
  146. package/dist/providers/synthetic.js +4 -0
  147. package/dist/providers/xai.js +9 -8
  148. package/dist/rpc.d.ts +8 -0
  149. package/dist/rpc.js +15 -2
  150. package/dist/ui/assets/{index-BcueIm3Z.css → index-6_g1FHs-.css} +1 -1
  151. package/dist/ui/assets/index-sZnGUuML.js +10 -0
  152. package/dist/ui/assets/{popover-4bFSvRZ7.js → popover-C4ZLYe9E.js} +1 -1
  153. package/dist/ui/index.html +2 -2
  154. package/package.json +3 -3
  155. package/dist/ui/assets/index-C6qRSoh8.js +0 -10
@@ -5,16 +5,17 @@
5
5
  * `withOpenCodeStorageSnapshot` transaction (identity + metadata + revision
6
6
  * membership + changed-ID payload). Historical extent, the trusted source
7
7
  * `time_updated` cursor, and wall-time frontier freshness are separate: normal
8
- * global refreshes read only the inclusive cursor-overlap delta, scoped reads
9
- * never advance the cursor, and a persisted 7-day repair re-reads the indexed
10
- * extent plus cached scopes. There is no autonomous timer; work is
11
- * request-driven.
8
+ * global refreshes read the inclusive cursor-overlap delta only when the cheap
9
+ * database/WAL signature changed since the last completed revision; an
10
+ * unchanged source skips the projected scan entirely. Scoped reads never
11
+ * advance the cursor, and a persisted 7-day repair re-reads the indexed extent
12
+ * plus cached scopes. There is no autonomous timer; work is request-driven.
12
13
  */
13
14
  import { performance } from "node:perf_hooks";
14
15
  import { encodeAnalyticsGroupQueryKey, isAnalyticsGroupQuery, } from "../contracts/analytics-entity.js";
15
16
  import { isRangeKey, rangeWindow } from "../contracts/ranges.js";
16
17
  import { compareOpenCodeSourceIdentity, rawAssistantRowHasTokenUsage, } from "../lib/opencode-storage.js";
17
- import { createUsageAnalytics, UNKNOWN_PROJECT_ID } from "./aggregation.js";
18
+ import { createUsageAnalytics, messagePositionMs, UNKNOWN_PROJECT_ID, } from "./aggregation.js";
18
19
  import { createAnalyticsIndexes } from "./analytics-indexes.js";
19
20
  import { createAnalyticsModel } from "./analytics-model.js";
20
21
  import { getAnalyticsPricingFingerprint } from "./analytics-pricing-revision.js";
@@ -31,14 +32,6 @@ const MAX_PROJECT_CACHE = 12;
31
32
  /** Bound on in-memory grouped DTOs; keeps detail navigation from growing state. */
32
33
  const MAX_GROUP_CACHE = 24;
33
34
  const PRESENTATION_SAVE_INTERVAL_MS = 60_000;
34
- /**
35
- * Idle grace before the automatic 7d -> 30d extension starts. A zero-delay
36
- * timer only yields one event-loop turn and can immediately queue a long
37
- * synchronous SQL read ahead of foreground navigation.
38
- */
39
- export const ANALYTICS_THIRTY_DAY_EXTENSION_DELAY_MS = 2_000;
40
- /** Bounded busy retries; a later 7d response schedules a fresh attempt. */
41
- const LOW_PRIORITY_EXTENSION_MAX_DEFERRALS = 1;
42
35
  const HOME_PRECOMPUTE_RANGES = ["24h", "7d", "30d"];
43
36
  /**
44
37
  * Fixed instrumentation labels. Each phase is timed around the operation it
@@ -233,8 +226,8 @@ export function createAnalyticsEngine(options = {}) {
233
226
  let warmIdentityVerification;
234
227
  let warmIdentityVerifiedGeneration = -1;
235
228
  let coverageTrusted = false;
229
+ let provisionalHome;
236
230
  let sidecarNewerThanIndex = false;
237
- let lowPriorityTimer;
238
231
  let closed = false;
239
232
  let closing = false;
240
233
  let closePromise;
@@ -287,6 +280,7 @@ export function createAnalyticsEngine(options = {}) {
287
280
  }
288
281
  const detailSignatures = new Map();
289
282
  const detailCompactions = new Map();
283
+ const detailUserMessages = new Map();
290
284
  const projectSignatures = new Map();
291
285
  const projectCoverage = new Map();
292
286
  const detailCoverage = new Map();
@@ -306,7 +300,7 @@ export function createAnalyticsEngine(options = {}) {
306
300
  }
307
301
  return { index, fingerprint };
308
302
  }
309
- function setRow(row, updatedAtMs, agent) {
303
+ function setRow(row, updatedAtMs) {
310
304
  const { index } = internFingerprint(row);
311
305
  const occurrence = {
312
306
  fingerprintIndex: index,
@@ -314,8 +308,10 @@ export function createAnalyticsEngine(options = {}) {
314
308
  messageID: row.messageID,
315
309
  updatedAtMs,
316
310
  };
317
- if (agent !== undefined)
318
- occurrence.agent = agent;
311
+ if (row.agent !== undefined)
312
+ occurrence.agent = row.agent;
313
+ if (row.variant !== undefined)
314
+ occurrence.variant = row.variant;
319
315
  state.occurrences.set(row.messageID, occurrence);
320
316
  indexes.upsert(occurrence);
321
317
  }
@@ -517,6 +513,7 @@ export function createAnalyticsEngine(options = {}) {
517
513
  fingerprintIndexes.add(occurrence.fingerprintIndex);
518
514
  }
519
515
  const messages = [];
516
+ const excluded = [];
520
517
  for (const messageID of indexes.fingerprintMessages(fingerprintIndexes)) {
521
518
  const occurrence = state.occurrences.get(messageID);
522
519
  if (!occurrence)
@@ -526,8 +523,13 @@ export function createAnalyticsEngine(options = {}) {
526
523
  continue;
527
524
  // Zero-token rows are metadata/activity only; the session DTO is a
528
525
  // usage view, so it must not grow steps, ownership, or pricing work.
529
- if (!rawAssistantRowHasTokenUsage(row))
526
+ // Their position is kept for the focus session so gaps never bridge them.
527
+ if (!rawAssistantRowHasTokenUsage(row)) {
528
+ if (row.sessionID === sessionId) {
529
+ excluded.push({ sessionId, atMs: messagePositionMs(row) });
530
+ }
530
531
  continue;
532
+ }
531
533
  messages.push(row);
532
534
  includedSessionIds.add(occurrence.sessionID);
533
535
  }
@@ -557,6 +559,8 @@ export function createAnalyticsEngine(options = {}) {
557
559
  projects,
558
560
  messages,
559
561
  compactions: detailCompactions.get(sessionId) ?? [],
562
+ userMessages: detailUserMessages.get(sessionId) ?? [],
563
+ excluded,
560
564
  };
561
565
  }
562
566
  function stateHasProject(projectId) {
@@ -896,6 +900,33 @@ export function createAnalyticsEngine(options = {}) {
896
900
  projects: snapshot.projects,
897
901
  };
898
902
  }
903
+ function buildProvisionalHome(atMs) {
904
+ if (provisionalHome)
905
+ return provisionalHome;
906
+ provisionalHome = (async () => {
907
+ const result = await reader.withSnapshot((snapshot) => {
908
+ const provisional = createAnalyticsModel({ timeZone });
909
+ provisional.setMetadata(snapshot.readAllSessionsIndex(), snapshot.readProjectsIndex());
910
+ // A message created before this window but completed within it is missed until the exact pass.
911
+ const rows = snapshot.readCompletedAssistantRows({
912
+ createdSinceMs: rangeWindow("7d", atMs).sinceMs,
913
+ });
914
+ provisional.apply(rows.filter(rawAssistantRowHasTokenUsage), []);
915
+ const data = provisional.home("7d", atMs);
916
+ return {
917
+ generatedAtMs: atMs,
918
+ range: "7d",
919
+ stale: true,
920
+ provisional: true,
921
+ providers: { cards: [], enabledProviders: [], polledAtMs: atMs },
922
+ usage: { ...data.usage, stale: true },
923
+ projects: data.projects,
924
+ };
925
+ });
926
+ return result.status === "ok" ? result.value : undefined;
927
+ })();
928
+ return provisionalHome;
929
+ }
899
930
  /**
900
931
  * Grouped DTOs are cheap to rebuild from the already-owned model and share
901
932
  * Home's certified `nowMs`; only a bounded LRU keeps repeats off the model.
@@ -1019,51 +1050,6 @@ export function createAnalyticsEngine(options = {}) {
1019
1050
  if (changed)
1020
1051
  queuePresentationWrite(atMs);
1021
1052
  }
1022
- /**
1023
- * The UI's default finite view is 7d. After that response is ready, extend
1024
- * once to 30d after a short idle grace. A foreground request that arrives
1025
- * during the grace (or a refresh already in flight) wins: the extension
1026
- * retries at most once, then leaves rescheduling to the next 7d response.
1027
- * This is not preemption; a synchronous SQLite read that has already started
1028
- * still runs to completion. Lifetime is never scheduled automatically.
1029
- */
1030
- function scheduleThirtyDayExtension(range, atMs) {
1031
- if (range !== "7d" || closed || closing || lowPriorityTimer !== undefined)
1032
- return;
1033
- if (coversSince(rangeWindow("30d", atMs).sinceMs, state.extent))
1034
- return;
1035
- const hasPendingRefreshWork = () => refreshPromise !== undefined ||
1036
- pendingGlobal !== undefined ||
1037
- pendingMetadataOnly ||
1038
- pendingDetailSessions.size > 0 ||
1039
- pendingProjectScopes.size > 0;
1040
- let deferrals = 0;
1041
- const arm = () => {
1042
- const timer = setTimeout(() => {
1043
- lowPriorityTimer = undefined;
1044
- if (closed || closing)
1045
- return;
1046
- const scheduledAtMs = now();
1047
- if (coversSince(rangeWindow("30d", scheduledAtMs).sinceMs, state.extent))
1048
- return;
1049
- if (hasPendingRefreshWork()) {
1050
- if (deferrals < LOW_PRIORITY_EXTENSION_MAX_DEFERRALS) {
1051
- deferrals += 1;
1052
- arm();
1053
- }
1054
- return;
1055
- }
1056
- void requestRefresh({
1057
- globalRange: "30d",
1058
- detailSessionIds: [],
1059
- projectScopes: [],
1060
- }).catch(() => { });
1061
- }, ANALYTICS_THIRTY_DAY_EXTENSION_DELAY_MS);
1062
- timer.unref?.();
1063
- lowPriorityTimer = timer;
1064
- };
1065
- arm();
1066
- }
1067
1053
  function buildCandidate(snapshot, job, atMs) {
1068
1054
  const identity = snapshot.identity;
1069
1055
  const comparison = compareOpenCodeSourceIdentity(state.sourceIdentity, identity);
@@ -1079,11 +1065,6 @@ export function createAnalyticsEngine(options = {}) {
1079
1065
  const replaced = comparison === "changed" && !pristine;
1080
1066
  const readHistoricalRows = (params = {}) => measureSync("historicalPayloadRead", () => snapshot.readCompletedAssistantRows(params));
1081
1067
  const readChangedRows = (messageIDs) => measureSync("changedPayloadRead", () => snapshot.readCompletedAssistantRows({ messageIDs }));
1082
- const sessions = measureSync("metadataRead", () => snapshot.readAllSessionsIndex());
1083
- const projects = measureSync("metadataRead", () => snapshot.readProjectsIndex());
1084
- // Stage metadata topology without touching committed indexes until commit.
1085
- const candidateIndexes = createAnalyticsIndexes();
1086
- candidateIndexes.setSessions(sessions);
1087
1068
  const globalRefresh = job.globalRange !== undefined;
1088
1069
  const effectiveExtent = replaced ? undefined : state.extent;
1089
1070
  const priorCursor = replaced ? undefined : state.sourceCursorAtMs;
@@ -1095,17 +1076,55 @@ export function createAnalyticsEngine(options = {}) {
1095
1076
  // A wall-clock rollback can move the inclusive window past unseen
1096
1077
  // source timestamps; reconcile fully rather than skip them.
1097
1078
  (priorCursor !== undefined && atMs < priorCursor));
1079
+ const emptyBaseline = priorCursor === undefined && state.occurrences.size === 0 && !replaced;
1080
+ // A completion timestamp rejected as "future" at one refresh becomes
1081
+ // eligible when wall time reaches it. That row's `time_updated` is already
1082
+ // behind the cursor, so a normal delta cannot see it: force a full identity
1083
+ // projection on that refresh instead of certifying the unchanged signature.
1084
+ const priorFutureCompletionAtMs = replaced ? undefined : state.futureCompletionAtMs;
1085
+ const futureDue = globalRefresh && priorFutureCompletionAtMs !== undefined && atMs >= priorFutureCompletionAtMs;
1086
+ // An unchanged on-disk source (database + WAL stat) cannot contain new,
1087
+ // edited, completed, or removed rows. The revision projection and the
1088
+ // session/project indexes are full table scans, so the persisted state is
1089
+ // reused as-is and the cursor stays authoritative — for a global refresh
1090
+ // and for a scoped-only refresh alike. The signature is captured before
1091
+ // `BEGIN`, so any write it counts is already visible to this snapshot. A
1092
+ // scoped-only refresh never persists the signature: only a global read
1093
+ // advances the cursor, so a newer signature must wait for that read. A due
1094
+ // 7-day repair (or clock rollback) must override the gate, because backdated
1095
+ // edits and deletions are invisible to the delta.
1096
+ const changeSignature = snapshot.changeSignature ?? null;
1097
+ const sourceUnchanged = !repairDue &&
1098
+ !futureDue &&
1099
+ !emptyBaseline &&
1100
+ priorCursor !== undefined &&
1101
+ changeSignature !== null &&
1102
+ state.sourceSignature !== undefined &&
1103
+ changeSignature === state.sourceSignature;
1104
+ const sessions = sourceUnchanged
1105
+ ? state.sessions
1106
+ : measureSync("metadataRead", () => snapshot.readAllSessionsIndex());
1107
+ const projects = sourceUnchanged
1108
+ ? state.projects
1109
+ : measureSync("metadataRead", () => snapshot.readProjectsIndex());
1110
+ // Stage metadata topology without touching committed indexes until commit.
1111
+ const candidateIndexes = createAnalyticsIndexes();
1112
+ candidateIndexes.setSessions(sessions);
1098
1113
  // Establish the source cursor either from a cheap physical frontier (no
1099
1114
  // stored contribution needs membership) or from one full revision
1100
1115
  // projection. Normal refreshes use only the cursor-overlap delta.
1101
1116
  let revisionSnapshot;
1102
1117
  let fullProjection = false;
1118
+ let fullIdentityScan = false;
1103
1119
  let cursorBaseline = false;
1104
1120
  let deltaValid = false;
1105
1121
  let sourceCursorAtMs;
1122
+ let futureCompletionAtMs;
1106
1123
  if (globalRefresh) {
1107
- const emptyBaseline = priorCursor === undefined && state.occurrences.size === 0 && !replaced;
1108
- if (emptyBaseline) {
1124
+ if (sourceUnchanged) {
1125
+ deltaValid = true;
1126
+ }
1127
+ else if (emptyBaseline) {
1109
1128
  const frontier = measureSync("revisionDiscovery", () => snapshot.readMessageRevisionFrontier());
1110
1129
  sourceCursorAtMs =
1111
1130
  frontier.available && frontier.updatedAtAvailable
@@ -1113,7 +1132,7 @@ export function createAnalyticsEngine(options = {}) {
1113
1132
  : null;
1114
1133
  cursorBaseline = true;
1115
1134
  }
1116
- else if (priorCursor !== undefined && !repairDue) {
1135
+ else if (priorCursor !== undefined && !repairDue && !futureDue) {
1117
1136
  revisionSnapshot = measureSync("revisionDiscovery", () => snapshot.readMessageRevisions({
1118
1137
  updatedSinceMs: Math.max(0, priorCursor - ANALYTICS_SOURCE_CURSOR_OVERLAP_MS),
1119
1138
  }));
@@ -1134,36 +1153,68 @@ export function createAnalyticsEngine(options = {}) {
1134
1153
  }
1135
1154
  }
1136
1155
  else {
1156
+ // A due repair/clock rollback re-reads payloads; a future-completion
1157
+ // release only needs the full identity set so the now-eligible row is
1158
+ // fetched by id.
1137
1159
  revisionSnapshot = measureSync("revisionDiscovery", () => snapshot.readMessageRevisions());
1138
1160
  if (!revisionSnapshot.available)
1139
1161
  return "unavailable";
1140
- fullProjection = true;
1162
+ fullIdentityScan = true;
1163
+ fullProjection = repairDue;
1141
1164
  }
1142
1165
  if (revisionSnapshot) {
1143
1166
  fullProjection =
1144
1167
  fullProjection ||
1145
1168
  !revisionSnapshot.updatedAtAvailable ||
1146
1169
  !revisionSnapshot.completedAtAvailable;
1170
+ fullIdentityScan = fullIdentityScan || fullProjection;
1147
1171
  const revisions = revisionSnapshot.revisions;
1148
- if (!fullProjection) {
1172
+ if (!fullIdentityScan) {
1149
1173
  // Deterministic time-then-id order keeps equal timestamps and
1150
1174
  // lexically earlier late commits replayable and idempotent.
1151
1175
  revisions.sort((a, b) => (a.updatedAtMs ?? Number.NEGATIVE_INFINITY) -
1152
1176
  (b.updatedAtMs ?? Number.NEGATIVE_INFINITY) || compareIds(a.messageID, b.messageID));
1153
1177
  }
1154
1178
  let maxUpdated = priorCursor;
1179
+ let earliestFuture;
1155
1180
  for (const revision of revisions) {
1156
1181
  if (revision.updatedAtMs !== null &&
1157
1182
  (maxUpdated === undefined || revision.updatedAtMs > maxUpdated)) {
1158
1183
  maxUpdated = revision.updatedAtMs;
1159
1184
  }
1185
+ if (revisionSnapshot.completedAtAvailable &&
1186
+ revision.type === "assistant" &&
1187
+ revision.completedAtMs !== null &&
1188
+ revision.completedAtMs > atMs &&
1189
+ (earliestFuture === undefined || revision.completedAtMs < earliestFuture)) {
1190
+ earliestFuture = revision.completedAtMs;
1191
+ }
1160
1192
  }
1161
1193
  sourceCursorAtMs =
1162
1194
  revisionSnapshot.updatedAtAvailable && revisionSnapshot.completedAtAvailable
1163
1195
  ? Math.min(maxUpdated ?? 0, atMs)
1164
1196
  : null;
1197
+ if (revisionSnapshot.completedAtAvailable) {
1198
+ if (fullIdentityScan) {
1199
+ futureCompletionAtMs = earliestFuture ?? null;
1200
+ }
1201
+ else {
1202
+ // A delta only proves the future rows it mentions. Keep an older
1203
+ // pending completion until wall time reaches it.
1204
+ const carried = priorFutureCompletionAtMs !== undefined && priorFutureCompletionAtMs > atMs
1205
+ ? priorFutureCompletionAtMs
1206
+ : undefined;
1207
+ futureCompletionAtMs =
1208
+ earliestFuture === undefined
1209
+ ? carried
1210
+ : carried === undefined
1211
+ ? earliestFuture
1212
+ : Math.min(earliestFuture, carried);
1213
+ }
1214
+ }
1165
1215
  }
1166
- deltaValid = !fullProjection && revisionSnapshot !== undefined && !repairDue;
1216
+ deltaValid =
1217
+ sourceUnchanged || (!fullIdentityScan && revisionSnapshot !== undefined && !repairDue);
1167
1218
  }
1168
1219
  const bulkRows = [];
1169
1220
  const bulkMap = new Map();
@@ -1171,7 +1222,7 @@ export function createAnalyticsEngine(options = {}) {
1171
1222
  const changedIds = new Map();
1172
1223
  const removalKeys = new Set();
1173
1224
  const authoritativePayloadIDs = new Set();
1174
- const watermarks = revisionSnapshot !== undefined && !fullProjection && revisionSnapshot.updatedAtAvailable
1225
+ const watermarks = revisionSnapshot !== undefined && !fullIdentityScan && revisionSnapshot.updatedAtAvailable
1175
1226
  ? new Map(revisionSnapshot.revisions.map((revision) => [
1176
1227
  revision.messageID,
1177
1228
  revision.updatedAtMs,
@@ -1188,8 +1239,6 @@ export function createAnalyticsEngine(options = {}) {
1188
1239
  // synthetic occurrence that simply has no transient agent loaded.
1189
1240
  agentProjected: true,
1190
1241
  };
1191
- if (row.agent !== undefined)
1192
- entry.agent = row.agent;
1193
1242
  changedMap.set(key, entry);
1194
1243
  removalKeys.delete(key);
1195
1244
  };
@@ -1288,7 +1337,7 @@ export function createAnalyticsEngine(options = {}) {
1288
1337
  }
1289
1338
  }
1290
1339
  const completedMembership = revisionSnapshot?.completedAtAvailable === true;
1291
- if (fullProjection && !completedMembership && !replaced && nextExtent) {
1340
+ if (fullIdentityScan && !completedMembership && !replaced && nextExtent) {
1292
1341
  // No completion identity: the extent payload read above is authoritative
1293
1342
  // for completion/type membership inside the indexed extent.
1294
1343
  for (const [key, occurrence] of state.occurrences) {
@@ -1304,6 +1353,7 @@ export function createAnalyticsEngine(options = {}) {
1304
1353
  }
1305
1354
  const detailSignatureChanges = [];
1306
1355
  const detailCompactionChanges = [];
1356
+ const detailUserMessageChanges = [];
1307
1357
  const detailCoverageChanges = [];
1308
1358
  const projectSignatureChanges = [];
1309
1359
  const projectCoverageChanges = [];
@@ -1559,9 +1609,37 @@ export function createAnalyticsEngine(options = {}) {
1559
1609
  const idSet = new Set(ids);
1560
1610
  const scopedRevisions = measureSync("revisionDiscovery", () => snapshot.readMessageRevisions({ sessionIDs: ids }));
1561
1611
  const scopedWatermarks = new Map();
1612
+ const focusUserMessages = [];
1562
1613
  if (scopedRevisions.available) {
1614
+ // Explicit reply linkage: an assistant row's stored `parentID` is the
1615
+ // user message it answers. Timing alone cannot separate a reply that
1616
+ // was already running when the input arrived.
1617
+ const repliesByParent = new Map();
1563
1618
  for (const revision of scopedRevisions.revisions) {
1564
1619
  scopedWatermarks.set(revision.messageID, revision.updatedAtMs);
1620
+ if (revision.type.toLowerCase() === "assistant" && revision.parentID !== undefined) {
1621
+ const replies = repliesByParent.get(revision.parentID);
1622
+ if (replies === undefined)
1623
+ repliesByParent.set(revision.parentID, [revision.messageID]);
1624
+ else
1625
+ replies.push(revision.messageID);
1626
+ }
1627
+ }
1628
+ for (const revision of scopedRevisions.revisions) {
1629
+ if (revision.sessionID !== focusId ||
1630
+ revision.type.toLowerCase() !== "user" ||
1631
+ revision.createdAtMs <= 0) {
1632
+ continue;
1633
+ }
1634
+ const replies = repliesByParent.get(revision.messageID);
1635
+ const position = {
1636
+ sessionId: focusId,
1637
+ atMs: revision.createdAtMs,
1638
+ messageId: revision.messageID,
1639
+ };
1640
+ if (replies !== undefined)
1641
+ position.replyMessageIds = replies;
1642
+ focusUserMessages.push(position);
1565
1643
  }
1566
1644
  }
1567
1645
  const signature = sessionRevisionSignature(sessions, ids);
@@ -1673,6 +1751,7 @@ export function createAnalyticsEngine(options = {}) {
1673
1751
  detailCompactionChanges.push([focusId, markers]);
1674
1752
  detailCoverageChanges.push([focusId, { signature: ids.join("\u0001"), untilMs: atMs }]);
1675
1753
  }
1754
+ detailUserMessageChanges.push([focusId, focusUserMessages]);
1676
1755
  detailSignatureChanges.push([focusId, signature]);
1677
1756
  }
1678
1757
  // A full repair must revisit every cached payload outside this refresh's
@@ -1700,7 +1779,7 @@ export function createAnalyticsEngine(options = {}) {
1700
1779
  }
1701
1780
  // Apply the projected revision delta after every payload/membership read.
1702
1781
  // Only a full projection may sweep stored rows as deleted.
1703
- const seenKeys = fullProjection && revisionSnapshot?.completedAtAvailable ? new Set() : undefined;
1782
+ const seenKeys = fullIdentityScan && revisionSnapshot?.completedAtAvailable ? new Set() : undefined;
1704
1783
  const extentSince = nextExtent?.sinceMs;
1705
1784
  const extentUntil = nextExtent?.untilMs ?? atMs;
1706
1785
  if (revisionSnapshot?.completedAtAvailable) {
@@ -1806,7 +1885,7 @@ export function createAnalyticsEngine(options = {}) {
1806
1885
  }
1807
1886
  discoverExternalOwners(read);
1808
1887
  }
1809
- return {
1888
+ const candidate = {
1810
1889
  identity,
1811
1890
  sessions,
1812
1891
  projects,
@@ -1818,12 +1897,21 @@ export function createAnalyticsEngine(options = {}) {
1818
1897
  extentChanged,
1819
1898
  detailSignatures: detailSignatureChanges,
1820
1899
  detailCompactions: detailCompactionChanges,
1900
+ detailUserMessages: detailUserMessageChanges,
1821
1901
  detailCoverageChanges,
1822
1902
  projectSignatures: projectSignatureChanges,
1823
1903
  projectCoverages: projectCoverageChanges,
1904
+ sourceUnchanged,
1824
1905
  ...(globalRefresh ? { sourceCursorAtMs } : {}),
1825
1906
  ...(globalRefresh && (cursorBaseline || fullProjection) ? { repairCompletedAtMs: atMs } : {}),
1826
1907
  };
1908
+ if (globalRefresh && snapshot.changeSignature) {
1909
+ candidate.sourceSignature = snapshot.changeSignature;
1910
+ }
1911
+ if (globalRefresh && futureCompletionAtMs !== undefined) {
1912
+ candidate.futureCompletionAtMs = futureCompletionAtMs;
1913
+ }
1914
+ return candidate;
1827
1915
  }
1828
1916
  /** Drops fingerprint tuples no occurrence references (small periodic GC). */
1829
1917
  function pruneFingerprints() {
@@ -1863,6 +1951,8 @@ export function createAnalyticsEngine(options = {}) {
1863
1951
  const atMs = now();
1864
1952
  const priorSourceCursorAtMs = state.sourceCursorAtMs;
1865
1953
  const priorLastFullRepairAtMs = state.lastFullRepairAtMs;
1954
+ const priorSourceSignature = state.sourceSignature;
1955
+ const priorFutureCompletionAtMs = state.futureCompletionAtMs;
1866
1956
  const priorExtentSinceMs = state.extent?.sinceMs;
1867
1957
  const priorSourceIdentity = state.sourceIdentity;
1868
1958
  if (job.globalRange !== undefined)
@@ -1932,6 +2022,8 @@ export function createAnalyticsEngine(options = {}) {
1932
2022
  state.presentation = undefined;
1933
2023
  state.sourceCursorAtMs = undefined;
1934
2024
  state.lastFullRepairAtMs = undefined;
2025
+ state.sourceSignature = undefined;
2026
+ state.futureCompletionAtMs = undefined;
1935
2027
  warmPresentation = undefined;
1936
2028
  warmSourceIdentity = undefined;
1937
2029
  warmIdentityVerification = undefined;
@@ -1939,6 +2031,7 @@ export function createAnalyticsEngine(options = {}) {
1939
2031
  projectSignatures.clear();
1940
2032
  detailSignatures.clear();
1941
2033
  detailCompactions.clear();
2034
+ detailUserMessages.clear();
1942
2035
  detailCoverage.clear();
1943
2036
  projectCoverage.clear();
1944
2037
  projectFreshAt.clear();
@@ -1955,6 +2048,7 @@ export function createAnalyticsEngine(options = {}) {
1955
2048
  const upserts = [];
1956
2049
  const agentUpserts = [];
1957
2050
  const agentAffectedSessionIds = new Set();
2051
+ const sourceUnchanged = candidate.sourceUnchanged === true;
1958
2052
  let updatedAtChanged = false;
1959
2053
  let occurrenceRemoved = false;
1960
2054
  // The final staged row is the only authoritative payload for a message id:
@@ -1969,7 +2063,7 @@ export function createAnalyticsEngine(options = {}) {
1969
2063
  const key = row.messageID;
1970
2064
  const occurrence = state.occurrences.get(key);
1971
2065
  if (!occurrence) {
1972
- setRow(row, updatedAtMs, row.agent);
2066
+ setRow(row, updatedAtMs);
1973
2067
  upserts.push(row);
1974
2068
  return;
1975
2069
  }
@@ -1980,7 +2074,7 @@ export function createAnalyticsEngine(options = {}) {
1980
2074
  if (!sameContribution) {
1981
2075
  if (oldRow)
1982
2076
  removals.push(oldRow);
1983
- setRow(row, updatedAtMs, row.agent);
2077
+ setRow(row, updatedAtMs);
1984
2078
  upserts.push(row);
1985
2079
  return;
1986
2080
  }
@@ -1988,13 +2082,24 @@ export function createAnalyticsEngine(options = {}) {
1988
2082
  occurrence.updatedAtMs = updatedAtMs;
1989
2083
  updatedAtChanged = true;
1990
2084
  }
1991
- if (agentProjected && row.agent !== occurrence.agent) {
2085
+ // Agent and reasoning effort are detail-only metadata projected by the
2086
+ // same payload read; either changing refreshes the cached session DTO.
2087
+ if (agentProjected &&
2088
+ (row.agent !== occurrence.agent || row.variant !== occurrence.variant)) {
2089
+ // Compact occurrences do not persist agent/variant; filling them from
2090
+ // the first unchanged-source detail read does not change the cached DTO.
2091
+ const wasKnown = occurrence.agent !== undefined || occurrence.variant !== undefined;
1992
2092
  if (row.agent === undefined)
1993
2093
  delete occurrence.agent;
1994
2094
  else
1995
2095
  occurrence.agent = row.agent;
2096
+ if (row.variant === undefined)
2097
+ delete occurrence.variant;
2098
+ else
2099
+ occurrence.variant = row.variant;
1996
2100
  agentUpserts.push(row);
1997
- agentAffectedSessionIds.add(row.sessionID);
2101
+ if (wasKnown || !sourceUnchanged)
2102
+ agentAffectedSessionIds.add(row.sessionID);
1998
2103
  }
1999
2104
  };
2000
2105
  for (const entry of candidate.changedMap.values()) {
@@ -2045,11 +2150,21 @@ export function createAnalyticsEngine(options = {}) {
2045
2150
  if (candidate.repairCompletedAtMs !== undefined) {
2046
2151
  state.lastFullRepairAtMs = candidate.repairCompletedAtMs;
2047
2152
  }
2153
+ if (candidate.sourceSignature !== undefined) {
2154
+ state.sourceSignature = candidate.sourceSignature;
2155
+ }
2156
+ if (candidate.futureCompletionAtMs !== undefined) {
2157
+ if (candidate.futureCompletionAtMs === null)
2158
+ state.futureCompletionAtMs = undefined;
2159
+ else
2160
+ state.futureCompletionAtMs = candidate.futureCompletionAtMs;
2161
+ }
2048
2162
  unavailable = false;
2049
2163
  for (const [focusId, signature] of candidate.detailSignatures) {
2050
2164
  if (signature === "") {
2051
2165
  detailSignatures.delete(focusId);
2052
2166
  detailCompactions.delete(focusId);
2167
+ detailUserMessages.delete(focusId);
2053
2168
  detailCoverage.delete(focusId);
2054
2169
  detailFreshAt.delete(focusId);
2055
2170
  }
@@ -2063,11 +2178,22 @@ export function createAnalyticsEngine(options = {}) {
2063
2178
  }
2064
2179
  const markerChangedFocusIds = new Set();
2065
2180
  for (const [focusId, markers] of candidate.detailCompactions) {
2066
- if (metadataChanged(detailCompactions.get(focusId) ?? [], markers)) {
2181
+ const previous = detailCompactions.get(focusId);
2182
+ if (metadataChanged(previous ?? [], markers) &&
2183
+ (previous !== undefined || !sourceUnchanged)) {
2067
2184
  markerChangedFocusIds.add(focusId);
2068
2185
  }
2069
2186
  detailCompactions.set(focusId, markers);
2070
2187
  }
2188
+ const userMessageChangedFocusIds = new Set();
2189
+ for (const [focusId, messages] of candidate.detailUserMessages) {
2190
+ const previous = detailUserMessages.get(focusId);
2191
+ if (metadataChanged(previous ?? [], messages) &&
2192
+ (previous !== undefined || !sourceUnchanged)) {
2193
+ userMessageChangedFocusIds.add(focusId);
2194
+ }
2195
+ detailUserMessages.set(focusId, messages);
2196
+ }
2071
2197
  for (const [projectId, signature] of candidate.projectSignatures) {
2072
2198
  projectSignatures.set(projectId, signature);
2073
2199
  projectFreshAt.set(projectId, atMs);
@@ -2077,6 +2203,7 @@ export function createAnalyticsEngine(options = {}) {
2077
2203
  }
2078
2204
  trimMap(detailSignatures, MAX_SCOPE_BATCH * 4);
2079
2205
  trimMap(detailCompactions, MAX_SCOPE_BATCH * 4);
2206
+ trimMap(detailUserMessages, MAX_SCOPE_BATCH * 4);
2080
2207
  trimMap(detailCoverage, MAX_SCOPE_BATCH * 4);
2081
2208
  trimMap(detailFreshAt, MAX_SCOPE_BATCH * 4);
2082
2209
  trimMap(projectSignatures, MAX_SCOPE_BATCH * 4);
@@ -2091,15 +2218,18 @@ export function createAnalyticsEngine(options = {}) {
2091
2218
  const cursorChanged = candidate.sourceCursorAtMs !== undefined && state.sourceCursorAtMs !== priorSourceCursorAtMs;
2092
2219
  const repairChanged = candidate.repairCompletedAtMs !== undefined &&
2093
2220
  state.lastFullRepairAtMs !== priorLastFullRepairAtMs;
2221
+ const signatureChanged = candidate.sourceSignature !== undefined && state.sourceSignature !== priorSourceSignature;
2222
+ const futureChanged = candidate.futureCompletionAtMs !== undefined &&
2223
+ state.futureCompletionAtMs !== priorFutureCompletionAtMs;
2094
2224
  const extentSinceChanged = state.extent?.sinceMs !== priorExtentSinceMs;
2095
2225
  const identityEstablished = priorSourceIdentity === undefined && state.sourceIdentity !== undefined;
2096
2226
  let sessionCacheInvalidated = false;
2097
2227
  if (!dataChanged && agentAffectedSessionIds.size > 0) {
2098
2228
  sessionCacheInvalidated = invalidateCachedSessions(agentAffectedSessionIds);
2099
2229
  }
2100
- if (!dataChanged && markerChangedFocusIds.size > 0) {
2230
+ if (!dataChanged && (markerChangedFocusIds.size > 0 || userMessageChangedFocusIds.size > 0)) {
2101
2231
  const affectedSessionIds = new Set();
2102
- for (const focusId of markerChangedFocusIds) {
2232
+ for (const focusId of [...markerChangedFocusIds, ...userMessageChangedFocusIds]) {
2103
2233
  affectedSessionIds.add(focusId);
2104
2234
  for (const sessionId of indexes.treeIds(focusId))
2105
2235
  affectedSessionIds.add(sessionId);
@@ -2153,6 +2283,8 @@ export function createAnalyticsEngine(options = {}) {
2153
2283
  updatedAtChanged ||
2154
2284
  cursorChanged ||
2155
2285
  repairChanged ||
2286
+ signatureChanged ||
2287
+ futureChanged ||
2156
2288
  extentSinceChanged ||
2157
2289
  identityEstablished;
2158
2290
  if (snapshotNeeded) {
@@ -2245,8 +2377,14 @@ export function createAnalyticsEngine(options = {}) {
2245
2377
  return;
2246
2378
  void requestRefresh(job).catch(() => { });
2247
2379
  }
2380
+ async function refreshGlobalOrThrow(range) {
2381
+ await requestRefresh({ globalRange: range, detailSessionIds: [], projectScopes: [] });
2382
+ if (unavailable && state.occurrences.size === 0 && Object.keys(state.sessions).length === 0) {
2383
+ throw new AnalyticsLookupError("unavailable");
2384
+ }
2385
+ }
2248
2386
  return {
2249
- async home(range) {
2387
+ async home(range, exact = false) {
2250
2388
  if (!isRangeKey(range))
2251
2389
  throw new AnalyticsLookupError("bad-request");
2252
2390
  if (closed)
@@ -2280,18 +2418,20 @@ export function createAnalyticsEngine(options = {}) {
2280
2418
  if (stale) {
2281
2419
  requestBackground({ globalRange: range, detailSessionIds: [], projectScopes: [] }, sidecarNewerThanIndex || missingCoverage);
2282
2420
  }
2283
- scheduleThirtyDayExtension(range, atMs);
2284
2421
  return homeSnapshotWithStaleness(current, range, atMs, stale);
2285
2422
  }
2286
2423
  }
2287
2424
  await ensureIndexLoaded();
2288
2425
  if (!coverageTrusted || !coversSince(window.sinceMs, state.extent)) {
2289
- await requestRefresh({ globalRange: range, detailSessionIds: [], projectScopes: [] });
2290
- if (unavailable &&
2426
+ if (!exact &&
2427
+ range === "7d" &&
2291
2428
  state.occurrences.size === 0 &&
2292
- Object.keys(state.sessions).length === 0) {
2293
- throw new AnalyticsLookupError("unavailable");
2429
+ state.extent === undefined) {
2430
+ const provisional = await buildProvisionalHome(atMs);
2431
+ if (provisional !== undefined)
2432
+ return provisional;
2294
2433
  }
2434
+ await refreshGlobalOrThrow(range);
2295
2435
  }
2296
2436
  const stale = isStale(now());
2297
2437
  if (stale) {
@@ -2302,7 +2442,6 @@ export function createAnalyticsEngine(options = {}) {
2302
2442
  const result = deriveHomeSnapshot(range, range !== "lifetime" && certified !== undefined ? certified : atMs);
2303
2443
  cacheHome(range, result, atMs);
2304
2444
  precomputeHomeSnapshots(atMs);
2305
- scheduleThirtyDayExtension(range, atMs);
2306
2445
  return homeSnapshotWithStaleness(result, range, atMs, stale);
2307
2446
  },
2308
2447
  async groups(query) {
@@ -2370,12 +2509,7 @@ export function createAnalyticsEngine(options = {}) {
2370
2509
  return result;
2371
2510
  }
2372
2511
  if (!coverageTrusted || !coversSince(window.sinceMs, state.extent)) {
2373
- await requestRefresh({ globalRange: range, detailSessionIds: [], projectScopes: [] });
2374
- if (unavailable &&
2375
- state.occurrences.size === 0 &&
2376
- Object.keys(state.sessions).length === 0) {
2377
- throw new AnalyticsLookupError("unavailable");
2378
- }
2512
+ await refreshGlobalOrThrow(range);
2379
2513
  }
2380
2514
  const derivationAtMs = groupDerivationAtMs(range, atMs);
2381
2515
  const missingCoverage = !coversSince(window.sinceMs, state.extent);
@@ -2492,7 +2626,10 @@ export function createAnalyticsEngine(options = {}) {
2492
2626
  const ids = indexes.treeIds(sessionId);
2493
2627
  const signature = sessionRevisionSignature(state.sessions, ids);
2494
2628
  const markers = detailCompactions.get(sessionId);
2495
- if (detailSignatures.get(sessionId) !== signature || markers === undefined) {
2629
+ const userMessages = detailUserMessages.get(sessionId);
2630
+ if (detailSignatures.get(sessionId) !== signature ||
2631
+ markers === undefined ||
2632
+ userMessages === undefined) {
2496
2633
  await requestRefresh({ detailSessionIds: [sessionId], projectScopes: [] });
2497
2634
  }
2498
2635
  if (!isDetailFresh(sessionId, now())) {
@@ -2556,17 +2693,19 @@ export function createAnalyticsEngine(options = {}) {
2556
2693
  }
2557
2694
  return false;
2558
2695
  },
2696
+ unpricedRoutes() {
2697
+ if (!modelHydrated || modelDirty)
2698
+ return [];
2699
+ return model.unpricedRoutes();
2700
+ },
2559
2701
  async close() {
2560
2702
  if (closePromise)
2561
2703
  return closePromise;
2562
2704
  if (closed)
2563
2705
  return;
2564
- closing = true;
2565
2706
  closePromise = (async () => {
2566
- if (lowPriorityTimer !== undefined) {
2567
- clearTimeout(lowPriorityTimer);
2568
- lowPriorityTimer = undefined;
2569
- }
2707
+ await refreshPromise?.catch(() => { });
2708
+ closing = true;
2570
2709
  pendingGlobal = undefined;
2571
2710
  pendingMetadataOnly = false;
2572
2711
  pendingDetailSessions.clear();
@@ -2588,6 +2727,7 @@ export function createAnalyticsEngine(options = {}) {
2588
2727
  lastProjectScopes.clear();
2589
2728
  detailSignatures.clear();
2590
2729
  detailCompactions.clear();
2730
+ detailUserMessages.clear();
2591
2731
  detailCoverage.clear();
2592
2732
  projectSignatures.clear();
2593
2733
  projectCoverage.clear();