@cortexkit/pi-magic-context 0.49.11 → 0.49.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/auto-search-worker.js +4 -4
  2. package/dist/chunk-embedding-write-worker.js +87 -0
  3. package/dist/{compaction-marker-candidates-n4dphyz4.js → compaction-marker-candidates-k4tqg4jb.js} +2 -2
  4. package/dist/compaction-marker-candidates-worker.js +1 -1
  5. package/dist/embedding-backfill-7kj16fh9.js +21 -0
  6. package/dist/embedding-worker-process.js +1 -1
  7. package/dist/embedding-worker.js +5 -5
  8. package/dist/historian-calibration-extension.js +2 -2
  9. package/dist/{index-ta0ed2nc.js → index-1k729e4f.js} +15 -15
  10. package/dist/index-1mrvw9en.js +225 -0
  11. package/dist/{index-g13fb2sj.js → index-3cnarwf8.js} +4 -4
  12. package/dist/{index-729kkhmf.js → index-46q4e104.js} +1 -1
  13. package/dist/{index-m8aaepft.js → index-53xdqb3d.js} +7 -7
  14. package/dist/{index-szh001qb.js → index-6dz2ed1v.js} +2 -2
  15. package/dist/{index-gqxsds3q.js → index-6ex901g3.js} +187 -27
  16. package/dist/{index-gycf3sp7.js → index-7bqrfyny.js} +46 -2
  17. package/dist/{index-drah07tf.js → index-7qc73yk5.js} +64 -7
  18. package/dist/{index-s9kwv5pp.js → index-7wagp5jp.js} +5 -5
  19. package/dist/{index-8yjhda46.js → index-9jvktm7k.js} +3 -3
  20. package/dist/{index-3veejgp8.js → index-apgwdby5.js} +1 -1
  21. package/dist/{index-0vq6ebae.js → index-aypx5h57.js} +58 -64
  22. package/dist/{index-43zqh10z.js → index-d4dt19md.js} +1 -1
  23. package/dist/{index-fdxzpnbj.js → index-djxc8w8c.js} +1 -1
  24. package/dist/{index-x7426vy4.js → index-ed9d2ded.js} +18 -5
  25. package/dist/{index-kh3jt7t9.js → index-f18ec69t.js} +1 -1
  26. package/dist/{index-4pxydwvg.js → index-g4jf772p.js} +1 -1
  27. package/dist/{index-4vj37yw9.js → index-he9s4qsj.js} +16 -6
  28. package/dist/{index-ttxsmaj5.js → index-jrap43gc.js} +1 -1
  29. package/dist/{index-78c864c8.js → index-nwbhe6qv.js} +324 -254
  30. package/dist/{index-9azmm7cg.js → index-t27xk4r7.js} +10 -10
  31. package/dist/{index-s3c9dskk.js → index-vv1j5cak.js} +8 -8
  32. package/dist/{index-2df03yc3.js → index-wp9q91kn.js} +8 -8
  33. package/dist/{index-xmdkde4v.js → index-y29y2j2w.js} +12 -1
  34. package/dist/index.js +854 -369
  35. package/dist/{logger-qg51hmp7.js → logger-dygt96rn.js} +1 -1
  36. package/dist/{message-index-5zjmsg57.js → message-index-7w179p64.js} +13 -13
  37. package/dist/{message-index-bounded-chgr6dn3.js → message-index-bounded-80n96ehp.js} +13 -13
  38. package/dist/{message-time-backfill-q9s88zdv.js → message-time-backfill-r2ar1qvk.js} +2 -2
  39. package/dist/migration-worker.js +9 -9
  40. package/dist/{project-embedding-registry-dk5axctd.js → project-embedding-registry-52zwmtbn.js} +11 -10
  41. package/dist/raw-ordinal-warmup-worker.js +12 -7
  42. package/dist/{read-session-chunk-3kb7r5pq.js → read-session-chunk-83864b37.js} +8 -8
  43. package/dist/{read-session-raw-hm7ptnrh.js → read-session-raw-azkqjgzg.js} +6 -2
  44. package/dist/{safe-notification-target-62ty6rvp.js → safe-notification-target-2rkvkmw8.js} +2 -2
  45. package/dist/{search-8pczyejh.js → search-hffb8xht.js} +20 -19
  46. package/dist/{storage-tags-zh23ynsh.js → storage-tags-zmf30zqp.js} +6 -4
  47. package/dist/subagent-entry.js +23 -22
  48. package/package.json +2 -2
  49. package/dist/embedding-backfill-1tknh2jn.js +0 -20
  50. /package/dist/{index-69vas84q.js → index-e6xnpach.js} +0 -0
@@ -7,7 +7,7 @@ import {
7
7
  getMagicContextStorageDir,
8
8
  log2,
9
9
  sessionLog2
10
- } from "./index-gycf3sp7.js";
10
+ } from "./index-7bqrfyny.js";
11
11
  import {
12
12
  piModelRefToCanonical,
13
13
  modelRefLookupOrder,
@@ -20,7 +20,7 @@ import {
20
20
  PER_HARNESS_MODEL_KEYS,
21
21
  ConfigProfilesSchema,
22
22
  MagicContextConfigSchema
23
- } from "./index-ta0ed2nc.js";
23
+ } from "./index-1k729e4f.js";
24
24
  import {
25
25
  MERGED_REASONING_PARTS_PREFIX,
26
26
  decodeMergedReasoningParts,
@@ -56,7 +56,7 @@ import {
56
56
  readRawSessionMessageIdOrdinalsForRange2,
57
57
  readRawSessionMessageById2,
58
58
  readSessionChunk2
59
- } from "./index-m8aaepft.js";
59
+ } from "./index-53xdqb3d.js";
60
60
  import {
61
61
  isRecord,
62
62
  providerVisibleMessage,
@@ -70,10 +70,10 @@ import {
70
70
  getTagNumberByMessageId2,
71
71
  getTagsBySession2,
72
72
  getTagById2
73
- } from "./index-x7426vy4.js";
73
+ } from "./index-ed9d2ded.js";
74
74
  import {
75
75
  estimateTokens
76
- } from "./index-4pxydwvg.js";
76
+ } from "./index-g4jf772p.js";
77
77
  import {
78
78
  inRootAsyncContext2,
79
79
  Database2,
@@ -84,18 +84,18 @@ import {
84
84
  stableStringify,
85
85
  closeQuietly,
86
86
  getTableColumnNames
87
- } from "./index-ttxsmaj5.js";
87
+ } from "./index-jrap43gc.js";
88
88
  import {
89
89
  resolveOpenCodeDbPath,
90
90
  assertOpenCodeStoreGeneration
91
91
  } from "./index-8976mezv.js";
92
92
  import {
93
93
  noteRawSessionSummaryRowWritten2
94
- } from "./index-4vj37yw9.js";
94
+ } from "./index-he9s4qsj.js";
95
95
  import {
96
96
  piHarnessKindFromExecutable,
97
97
  isPidAlive
98
- } from "./index-3veejgp8.js";
98
+ } from "./index-apgwdby5.js";
99
99
  import {
100
100
  BoundedSessionMap,
101
101
  clearLkgFenceProcessState,
@@ -103,20 +103,33 @@ import {
103
103
  clearLkgRecoveryFence,
104
104
  deleteSessionScopedRows,
105
105
  getLastIndexedOrdinal2
106
- } from "./index-s3c9dskk.js";
106
+ } from "./index-vv1j5cak.js";
107
107
  import {
108
108
  SubcClient,
109
109
  connectionFileExists,
110
110
  SYNAPSE_DEFAULT_MODEL,
111
111
  toSynapseLaneDescriptor,
112
112
  SynapseEmbeddingProvider
113
- } from "./index-szh001qb.js";
113
+ } from "./index-6dz2ed1v.js";
114
114
  import {
115
115
  sameProjectDirectory
116
- } from "./index-fdxzpnbj.js";
116
+ } from "./index-djxc8w8c.js";
117
+ import {
118
+ invalidateAutoEmbedSession,
119
+ drainBackgroundBatches,
120
+ markProjectLoadUntrusted2,
121
+ drainProjectEmbeddingIdentityMaintenance2,
122
+ registerProjectEmbedding2,
123
+ registerProjectShadowEmbedding2,
124
+ registerProjectInObservationMode2,
125
+ unregisterProjectShadowEmbedding2,
126
+ unregisterProjectEmbedding2,
127
+ getProjectEmbeddingSnapshot2,
128
+ embedTextForProject2
129
+ } from "./index-nwbhe6qv.js";
117
130
  import {
118
131
  getErrorMessage
119
- } from "./index-9azmm7cg.js";
132
+ } from "./index-t27xk4r7.js";
120
133
  import {
121
134
  V2_MEMORY_CATEGORIES,
122
135
  CATEGORY_PRIORITY,
@@ -130,25 +143,13 @@ import {
130
143
  expandWorkspaceIdentitySetWithAliases,
131
144
  resolveStoredPathWorkspaceIdentity,
132
145
  storedPathBelongsToWorkspace
133
- } from "./index-g13fb2sj.js";
146
+ } from "./index-3cnarwf8.js";
134
147
  import {
135
148
  directoryHasGitMetadata,
136
149
  resolveProjectIdentityForSession,
137
150
  normalizeStoredProjectPath,
138
151
  storedPathBelongsToIdentity
139
- } from "./index-gqxsds3q.js";
140
- import {
141
- drainBackgroundBatches,
142
- markProjectLoadUntrusted2,
143
- drainProjectEmbeddingIdentityMaintenance2,
144
- registerProjectEmbedding2,
145
- registerProjectShadowEmbedding2,
146
- registerProjectInObservationMode2,
147
- unregisterProjectShadowEmbedding2,
148
- unregisterProjectEmbedding2,
149
- getProjectEmbeddingSnapshot2,
150
- embedTextForProject2
151
- } from "./index-78c864c8.js";
152
+ } from "./index-6ex901g3.js";
152
153
  import {
153
154
  getNoteByIdInScope,
154
155
  getNotes,
@@ -165,7 +166,7 @@ import {
165
166
  resolveMemoriesByIdsForSearch2,
166
167
  unifiedSearch2,
167
168
  formatSearchResults2
168
- } from "./index-2df03yc3.js";
169
+ } from "./index-wp9q91kn.js";
169
170
  import {
170
171
  computeCueContentHash,
171
172
  getMuralCueState,
@@ -190,13 +191,13 @@ import {
190
191
  isMarkerCandidateBasisCurrent2,
191
192
  invalidateMarkerCandidateBasis2,
192
193
  readMarkerCandidateBasis2
193
- } from "./index-729kkhmf.js";
194
+ } from "./index-46q4e104.js";
194
195
  import {
195
196
  computeNormalizedHash
196
197
  } from "./index-9x1f96r8.js";
197
198
  import {
198
199
  logSlowWriteTransaction
199
- } from "./index-43zqh10z.js";
200
+ } from "./index-d4dt19md.js";
200
201
  import {
201
202
  ensureStorageDirectorySync,
202
203
  writeStorageFileAtomicSync
@@ -4499,11 +4500,12 @@ class V2StoreReader {
4499
4500
  const head = Math.floor((maxChars - truncationMarker.length) / 2);
4500
4501
  const tail = maxChars - truncationMarker.length - head;
4501
4502
  return this.prepare(`WITH users AS (
4502
- SELECT seq, time_created, data FROM session_message
4503
- WHERE session_id = ? AND type = 'user' AND time_created ${before ? "<=" : ">"} ?
4503
+ SELECT session_id, seq, time_created, data FROM session_message
4504
+ WHERE session_id = ? AND type = 'user' AND time_created ${before ? "<=" : ">"}
4505
+ ?
4504
4506
  ORDER BY time_created ${direction}, seq ${direction} LIMIT ?
4505
4507
  ), texts AS (
4506
- SELECT seq, time_created, CASE
4508
+ SELECT session_id, seq, time_created, CASE
4507
4509
  WHEN json_extract(data, '$.synthetic') = 1 OR json_extract(data, '$.ignored') = 1 THEN ''
4508
4510
  WHEN json_type(data, '$.text') = 'text' THEN json_extract(data, '$.text')
4509
4511
  ELSE COALESCE((SELECT group_concat(json_extract(value, '$.text'), char(10))
@@ -4513,7 +4515,19 @@ class V2StoreReader {
4513
4515
  AND COALESCE(json_extract(value, '$.ignored'), 0) <> 1), '') END AS text
4514
4516
  FROM users WHERE json_valid(data)
4515
4517
  ) SELECT seq, time_created, CASE WHEN length(text) > ?
4516
- THEN substr(text, 1, ?) || ? || substr(text, -?) ELSE text END AS text
4518
+ THEN substr(text, 1, ?) || ? || substr(text, -?) ELSE text END AS text,
4519
+ EXISTS (
4520
+ SELECT 1 FROM session_message assistant_reply
4521
+ WHERE assistant_reply.session_id = texts.session_id
4522
+ AND assistant_reply.type = 'assistant'
4523
+ AND assistant_reply.seq < texts.seq
4524
+ AND EXISTS (
4525
+ SELECT 1 FROM session_message prior_user
4526
+ WHERE prior_user.session_id = texts.session_id
4527
+ AND prior_user.type = 'user'
4528
+ AND prior_user.seq < assistant_reply.seq
4529
+ )
4530
+ ) AS follows_assistant_reply
4517
4531
  FROM texts ORDER BY time_created ${direction}, seq ${direction}`).all(sessionID, boundaryMs, limit, maxChars, head, truncationMarker, tail);
4518
4532
  }
4519
4533
  storedRowsAfter(sessionID, after) {
@@ -4948,31 +4962,6 @@ function clearSession(db, sessionId, rustModuleCleanupAcknowledged = false, perm
4948
4962
  clearUnpublishedAutoSearchNoHints(sessionId);
4949
4963
  logSlowWriteTransaction("clear-session", transactionStartedAt);
4950
4964
  }
4951
- // ../plugin/src/hooks/magic-context/embed-session-state.ts
4952
- var embedPauseBySession = new Set;
4953
- var embedRunStateBySession = new Map;
4954
- var autoEmbedAttemptedBySession = new Set;
4955
- var autoEmbedIdentityBySession = new Map;
4956
- function invalidateAutoEmbedSession(sessionId) {
4957
- autoEmbedAttemptedBySession.delete(sessionId);
4958
- autoEmbedIdentityBySession.delete(sessionId);
4959
- }
4960
- function getEmbedDrainUiStatus(sessionId, progress) {
4961
- if (embedPauseBySession.has(sessionId)) {
4962
- return { status: "paused" };
4963
- }
4964
- const activeRun = embedRunStateBySession.get(sessionId);
4965
- if (activeRun && !activeRun.signal.aborted || progress?.kind === "embed" && progress.phase === "recomp") {
4966
- return { status: "running" };
4967
- }
4968
- if (progress?.kind === "embed" && (progress.phase === "failed" || progress.phase === "skipped") && progress.message) {
4969
- if (/provider/i.test(progress.message)) {
4970
- return { status: "stopped", detail: progress.message };
4971
- }
4972
- }
4973
- return { status: "idle" };
4974
- }
4975
-
4976
4965
  // ../plugin/src/features/magic-context/compartment-lease.ts
4977
4966
  var COMPARTMENT_LEASE_TTL_MS = 5 * 60 * 1000;
4978
4967
  var COMPARTMENT_LEASE_RENEWAL_MS = 60 * 1000;
@@ -5464,6 +5453,9 @@ function requestPendingMaterialization(sessions, sessionId, origin) {
5464
5453
  function pendingMaterializationOrigin(sessions, sessionId) {
5465
5454
  return sessions.has(sessionId) ? origins.get(sessions)?.get(sessionId) ?? "pending_materialization" : "pending_materialization";
5466
5455
  }
5456
+ function hasPendingMaterializationOrigin(sessions, sessionId, origin) {
5457
+ return sessions.has(sessionId) && causes.get(sessions)?.get(sessionId)?.has(origin) === true;
5458
+ }
5467
5459
  function clearPendingMaterialization(sessions, sessionId) {
5468
5460
  sessions.delete(sessionId);
5469
5461
  origins.get(sessions)?.delete(sessionId);
@@ -14395,14 +14387,15 @@ function writeTray(db, sessionId) {
14395
14387
  function createCtxNoteTool(deps) {
14396
14388
  const resolveProject = deps.resolveProjectIdentity ?? resolveProjectIdentityForSession;
14397
14389
  const parameters = structuredClone(ParamsSchema2);
14398
- if (deps.smartNotesEnabled === false) {
14390
+ const smartNoteSurface = deps.smartNotesEnabled !== false && deps.dreamerEnabled !== false;
14391
+ if (!smartNoteSurface) {
14399
14392
  delete parameters.properties.surface_condition;
14400
14393
  parameters.properties.filter.description = NOTES_FILTER_DESCRIPTION;
14401
14394
  }
14402
14395
  return {
14403
14396
  name: "ctx_note",
14404
14397
  label: "Magic Context: Notes",
14405
- description: deps.smartNotesEnabled === false ? withoutSmartNoteText(CTX_NOTE_DESCRIPTION) : CTX_NOTE_DESCRIPTION,
14398
+ description: smartNoteSurface ? CTX_NOTE_DESCRIPTION : withoutSmartNoteText(CTX_NOTE_DESCRIPTION),
14406
14399
  parameters,
14407
14400
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
14408
14401
  params = unwrapImitatedReducedArgs(params, ["action", "content"], {
@@ -15501,13 +15494,14 @@ function registerMagicContextTools(pi, opts) {
15501
15494
  warn: (message) => log2(`[magic-context][pi] config warning: ${message}`)
15502
15495
  });
15503
15496
  const registration = promptSurfaceRuntime.resolveRegistration(opts.promptSurface);
15497
+ const smartNotesAvailable = opts.smartNotesEnabled !== false && opts.dreamerEnabled !== false;
15504
15498
  const surfaceTool = (definition) => {
15505
15499
  const parameters = structuredClone(definition.parameters);
15506
- applyJsonSchemaParameterDescriptions(definition.name, parameters, registration.preset, opts.smartNotesEnabled);
15500
+ applyJsonSchemaParameterDescriptions(definition.name, parameters, registration.preset, smartNotesAvailable ? opts.smartNotesEnabled : false);
15507
15501
  return throwReturnedToolErrors({
15508
15502
  ...definition,
15509
15503
  parameters,
15510
- description: definition.name === "ctx_note" && opts.smartNotesEnabled === false ? withoutSmartNoteText(registration.preset === "light" ? CTX_NOTE_LIGHT_DESCRIPTION : definition.description) : registration.descriptionFor(definition.name, definition.description)
15504
+ description: definition.name === "ctx_note" && !smartNotesAvailable ? withoutSmartNoteText(registration.preset === "light" ? CTX_NOTE_LIGHT_DESCRIPTION : definition.description) : registration.descriptionFor(definition.name, definition.description)
15511
15505
  });
15512
15506
  };
15513
15507
  pi.registerTool(surfaceTool(createCtxSearchTool({
@@ -15536,7 +15530,7 @@ function registerMagicContextTools(pi, opts) {
15536
15530
  if (!opts.sessionScopedToolsDisabled) {
15537
15531
  pi.registerTool(surfaceTool(createCtxNoteTool({
15538
15532
  db: opts.db,
15539
- dreamerEnabled: opts.dreamerEnabled ?? false,
15533
+ dreamerEnabled: opts.dreamerEnabled,
15540
15534
  smartNotesEnabled: opts.smartNotesEnabled,
15541
15535
  resolveDreamerEnabled: opts.resolveDreamerEnabled,
15542
15536
  resolveProjectIdentity
@@ -15560,4 +15554,4 @@ function registerMagicContextTools(pi, opts) {
15560
15554
  }
15561
15555
  }
15562
15556
 
15563
- export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, embedPauseBySession, embedRunStateBySession, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
15557
+ export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, parseJsoncRecovering, detectConfigFile, MIN_PLAUSIBLE_CONTEXT_LIMIT, catalogOutputReserve, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, formatWindowSource, isSaneLimit, resolveOutputReserve, getSdkWindowGeometry, getSdkContextLimit, getSdkOutputLimit, getSdkInputLimit, cortexKitUserConfigBasePath, cortexKitProjectConfigBasePath, migrateMagicContextConfigLocations, getProtectedTokensTierOverrides, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, readSessionMeta, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, queueM0Mutation, getMaxM0MutationId, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getUncoveredCompartmentEndThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, registerLkgPersistence, LKG_SNAPSHOT_ARRAY, LKG_SNAPSHOT_OBJECT, LKG_SNAPSHOT_KEY, LKG_SNAPSHOT_STRING, LKG_SNAPSHOT_NUMBER, LKG_SNAPSHOT_BOOLEAN, LKG_SNAPSHOT_NULL, LKG_SNAPSHOT_UNDEFINED, contentSnapshotValue, signatureForFields, lkgContentFields, lkgContentDigestFromFields, isLegacyLkgDigest, legacyLkgDigestFromFields, lkgFieldsMatchDigest, exactReusablePrefix, incrementalLkgContentDigests, lkgSlotRejection, captureSlot, getInMemorySlot, getSlot, dropSlot, TOOL_SWEEP_SCOPED_MARKER, encodePiContentDecision, decodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, noteTouchedAt, noteNudgePickIndex, formatNoteNudge, systemPromptFingerprint, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, resolvePiRealStableId, isPiContentFallbackId, isPiIndexFallbackId, piContentFallbackIds, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findRestartModelSeedFromBranch, iterateEntriesToRawMessageRange, iterateAsyncEntriesToRawMessageRange, convertEntriesToRawMessages, convertPiAssistantEntryById, convertEntriesToRawMessagePage, countPiRawMessages, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, getTaskScheduleState, getFailingDreamTasks, getSkippedDreamTasks, getMostRecentTaskRunAt, pruneNonCanonicalTaskRows, deleteTaskScheduleRowsForProject, seedTaskScheduleState, writeTaskScheduleState, isRetrospectiveWindowProcessed, recordRetrospectiveWindowProcessed, curateCategoryForMemoryCategory, peekCurateCategoryScope, beginCurateCategoryRun, curateTaskStateAfterSuccess, MEMORY_MURAL_BLOCK, buildMagicContextSection, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, MEMORY_RENDER_FORMAT_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, withCachedM0MemoryIds, readCachedM0MemoryIds, renderBudgetIdentityChanged, renderedBudgetSnapshot, renderedBudgetShrinkReason, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, TEMPORAL_MARKER_REPLAY_PATTERN, temporalMarkerPrefix, renderUserProfileContent, clearInjectionCache, getVisibleMemoryIds, orderHistorianMemories, renderHistorianMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, resetPrefixTrimFallbackState, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, loadPiConfig, loadPiConfigDetailed, unregisterPiProjectEmbeddings, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolvePiOrdinalAlignment, piRawOrdinalOffsetSource, resolvePiOrdinalAlignmentForContext, isPiOrdinalAlignmentUnanchored, clearPiOrdinalAlignmentSession, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-gycf3sp7.js";
3
+ } from "./index-7bqrfyny.js";
4
4
 
5
5
  // ../plugin/src/shared/write-transaction-timing.ts
6
6
  var SLOW_WRITE_TRANSACTION_THRESHOLD_MS = 1000;
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-asrxgdt4.js";
5
5
  import {
6
6
  logSlowWriteTransaction
7
- } from "./index-43zqh10z.js";
7
+ } from "./index-d4dt19md.js";
8
8
 
9
9
  // ../plugin/src/shared/project-directory-key.ts
10
10
  import path from "node:path";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./index-4pxydwvg.js";
3
+ } from "./index-g4jf772p.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./index-0h2mkab2.js";
7
7
  import {
8
8
  sessionLog2
9
- } from "./index-gycf3sp7.js";
9
+ } from "./index-7bqrfyny.js";
10
10
  import {
11
11
  getTagIdentityWriteGeneration2,
12
12
  getSqliteDatabasePath2
@@ -15,7 +15,7 @@ import {
15
15
  jsonHashSink,
16
16
  tagOrderConstraintIndex,
17
17
  tagIdentityRevisionKey
18
- } from "./index-ttxsmaj5.js";
18
+ } from "./index-jrap43gc.js";
19
19
  import {
20
20
  DEFAULT_PROTECTED_TOOLS,
21
21
  normalizeProtectedToolName,
@@ -2533,6 +2533,19 @@ function insertTag2(db, sessionId, messageId, type, byteSize, tagNumber, reasoni
2533
2533
  function updateTagStatus2(db, sessionId, tagId, status) {
2534
2534
  getUpdateTagStatusStatement(db).run(status, sessionId, tagId);
2535
2535
  }
2536
+ var droppedTagStatements = new WeakMap;
2537
+ function markTagDropped2(db, sessionId, tagId, mode) {
2538
+ if (!mode) {
2539
+ updateTagStatus2(db, sessionId, tagId, "dropped");
2540
+ return;
2541
+ }
2542
+ let statement = droppedTagStatements.get(db);
2543
+ if (!statement) {
2544
+ statement = db.prepare("UPDATE tags SET status = ?, drop_mode = ? WHERE session_id = ? AND tag_number = ?");
2545
+ droppedTagStatements.set(db, statement);
2546
+ }
2547
+ statement.run("dropped", mode, sessionId, tagId);
2548
+ }
2536
2549
  var inertWhitespaceStatements = new WeakMap;
2537
2550
  var inertWhitespaceByNumberStatements = new WeakMap;
2538
2551
  function getInertWhitespaceAssistantTagsByNumbers2(db, sessionId, tagNumbers) {
@@ -3197,7 +3210,7 @@ function getNewestToolTagNumbers2(db, sessionId, limit) {
3197
3210
  let statement = newestToolTagNumberStatements.get(db);
3198
3211
  if (!statement) {
3199
3212
  statement = db.prepare(`SELECT tag_number FROM tags
3200
- WHERE session_id = ? AND type = 'tool'
3213
+ WHERE session_id = ? AND +type = 'tool'
3201
3214
  AND typeof(message_id) = 'text'
3202
3215
  AND typeof(status) = 'text'
3203
3216
  AND typeof(byte_size) IN ('integer', 'real')
@@ -3367,4 +3380,4 @@ function deleteToolTagsByOwner(db, sessionId, ownerMsgId) {
3367
3380
  return getDeleteToolTagsByOwnerStatement(db).all(sessionId, ownerMsgId).length;
3368
3381
  }
3369
3382
 
3370
- export { UNKNOWN_FIT_RATIO, resolveDecisionCalibration, hasMeasuredDecisionCalibration, providerMass, localBudget, calibrationForModelKey, historyLocalBudget, adoptedProtectedToolsPolicy, protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, rememberCurrentToolOutputCount, currentReclaimableToolOutputCount, isRecord, TEXT_TAG_IDENTITY_MARKER, PI_FALLBACK_PREFIXES_JSON, contentTagOwnerMessageId, TailHygieneJsonMemo, piJsonHash, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, TODO_STATUSES, TODO_PRIORITIES, TITLE_DONE_STATUSES, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, compareMeasuredTailPrefix, formatTailHygienePrefixMismatch, freezeTailHygieneMeasurement, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, updateTagByteSize2, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, updateTagInputByteSize2, updateTagTokenCount2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, scanTagOwnerDelta2, updateTagInputTokenCount2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, PiTagIdentityConflictError2, getPiMessageTagCandidates2, findPiTagIdentityConflict2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
3383
+ export { UNKNOWN_FIT_RATIO, resolveDecisionCalibration, hasMeasuredDecisionCalibration, providerMass, localBudget, calibrationForModelKey, historyLocalBudget, adoptedProtectedToolsPolicy, protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, rememberCurrentToolOutputCount, currentReclaimableToolOutputCount, isRecord, TEXT_TAG_IDENTITY_MARKER, PI_FALLBACK_PREFIXES_JSON, contentTagOwnerMessageId, TailHygieneJsonMemo, piJsonHash, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, TODO_STATUSES, TODO_PRIORITIES, TITLE_DONE_STATUSES, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, compareMeasuredTailPrefix, formatTailHygienePrefixMismatch, freezeTailHygieneMeasurement, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, updateTagByteSize2, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, updateTagInputByteSize2, updateTagTokenCount2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, scanTagOwnerDelta2, updateTagInputTokenCount2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markTagDropped2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, PiTagIdentityConflictError2, getPiMessageTagCandidates2, findPiTagIdentityConflict2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-gycf3sp7.js";
3
+ } from "./index-7bqrfyny.js";
4
4
 
5
5
  // ../plugin/src/shared/safe-notification-target.ts
6
6
  var DEFAULT_TITLE_RE = /^(New session - |Child session - )\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-gycf3sp7.js";
3
+ } from "./index-7bqrfyny.js";
4
4
 
5
5
  // ../plugin/src/hooks/magic-context/read-session-formatting.ts
6
6
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
@@ -8,7 +8,7 @@ import {
8
8
  } from "./index-399p688g.js";
9
9
  import {
10
10
  log2
11
- } from "./index-gycf3sp7.js";
11
+ } from "./index-7bqrfyny.js";
12
12
 
13
13
  // ../plugin/src/hooks/magic-context/read-session-raw.ts
14
14
  import { isMainThread } from "node:worker_threads";
@@ -91,6 +91,8 @@ function runSessionWarmupWorker(input, options) {
91
91
  finish({ inserted: reply.inserted, measurements: reply.measurements });
92
92
  else if (reply.kind === "orphan-sweep")
93
93
  finish({ orphanSweep: reply.result });
94
+ else if (reply.kind === "exact-ordinal-ids")
95
+ finish({ exactOrdinalIds: reply.ids });
94
96
  else
95
97
  finish({ failure: "worker-error", detail: reply.error });
96
98
  });
@@ -316,7 +318,7 @@ function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWaterma
316
318
  const skip = anchor === after && after ? 0 : ordinal - (floor?.ordinal ?? 0);
317
319
  if (skip > ORDINAL_LOOKUP_LIMIT) {
318
320
  prewarmRawSessionOrdinalsForDb(db, sessionId);
319
- throw new RawOrdinalsNotReady;
321
+ throw new RawOrdinalsNotReady2;
320
322
  }
321
323
  const rawLimit = skip + pageSize + ORDINAL_LOOKUP_LIMIT;
322
324
  const rows = db.prepare(`SELECT id, data, time_created, time_updated, ${EXCLUDED_ROW_SQL} AS excluded
@@ -329,7 +331,7 @@ function readRawMessagePageRows(db, sessionId, afterOrdinal, limit, finalWaterma
329
331
  const eligible = rows.filter((row) => row.excluded !== 1);
330
332
  if (eligible.length <= skip && rows.length === rawLimit) {
331
333
  prewarmRawSessionOrdinalsForDb(db, sessionId);
332
- throw new RawOrdinalsNotReady;
334
+ throw new RawOrdinalsNotReady2;
333
335
  }
334
336
  return eligible.slice(skip, skip + pageSize).filter(isRawMessageRow).map((row, index) => ({
335
337
  ...row,
@@ -417,11 +419,13 @@ function countRawSessionMessageOrdinalsFromDb2(db, sessionId) {
417
419
  )`).get(sessionId);
418
420
  return typeof row?.count === "number" ? row.count : 0;
419
421
  }
422
+ var exactOrdinalScansOnThisThread = 0;
420
423
  function readRawSessionMessageIdOrdinalsForRangeFromDb2(db, sessionId, fromOrdinal, toOrdinal) {
421
424
  const from = Math.max(1, Math.floor(fromOrdinal));
422
425
  const to = Math.floor(toOrdinal);
423
426
  if (to < from)
424
427
  return new Map;
428
+ exactOrdinalScansOnThisThread += 1;
425
429
  const rows = db.prepare(`
426
430
  SELECT id, data FROM message WHERE session_id = ?
427
431
  AND CASE WHEN json_valid(data) THEN NOT (
@@ -437,6 +441,12 @@ function readRawSessionMessageIdOrdinalsForRangeFromDb2(db, sessionId, fromOrdin
437
441
  }
438
442
  return result;
439
443
  }
444
+ function readRawSessionMessageIdsAtOrdinalsFromDb2(db, sessionId, ordinals) {
445
+ return withReadSnapshot(db, () => ordinals.map((ordinal) => [
446
+ ordinal,
447
+ readRawSessionMessageIdOrdinalsForRangeFromDb2(db, sessionId, ordinal, ordinal).keys().next().value ?? null
448
+ ]));
449
+ }
440
450
  function readRawSessionMessageOrdinalPageFromDb2(db, sessionId, after, limit) {
441
451
  const pageSize = Math.max(1, Math.floor(limit));
442
452
  const rows = (after ? db.prepare(`SELECT id, data, time_created
@@ -733,7 +743,7 @@ function extendOrdinalCheckpoints(db, sessionId, scan, limit) {
733
743
  return true;
734
744
  }
735
745
 
736
- class RawOrdinalsNotReady extends Error {
746
+ class RawOrdinalsNotReady2 extends Error {
737
747
  constructor() {
738
748
  super("canonical ordinals are warming off-thread; retry after preparation");
739
749
  }
@@ -782,7 +792,7 @@ function boundedOrdinalPrefix(db, sessionId, through) {
782
792
  ordinalJsonRowsRead += rows.length;
783
793
  if (rows.length > ORDINAL_LOOKUP_LIMIT) {
784
794
  prewarmRawSessionOrdinalsForDb(db, sessionId);
785
- throw new RawOrdinalsNotReady;
795
+ throw new RawOrdinalsNotReady2;
786
796
  }
787
797
  return (floor?.ordinal ?? 0) + rows.reduce((sum, row) => sum + (row.excluded === 1 ? 0 : 1), 0);
788
798
  }
@@ -1245,4 +1255,4 @@ function readRawSessionBoundaryEndpointsFromDb2(db, sessionId, ids, blockIds = [
1245
1255
  }
1246
1256
  }
1247
1257
 
1248
- export { runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb, isStrictGapHealingMessage2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, RAW_SUMMARY_TEXT_MAX_CHARS2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2 };
1258
+ export { runSessionWarmupWorker, prewarmRawSessionOrdinalsForDb, isStrictGapHealingMessage2, readRawSessionMessagesFromDb2, readRawSessionMessagePageFromDb2, RAW_SUMMARY_TEXT_MAX_CHARS2, readRawSessionMessageSummaryPageFromDb2, countRawSessionMessageOrdinalsFromDb2, readRawSessionMessageIdOrdinalsForRangeFromDb2, readRawSessionMessageIdsAtOrdinalsFromDb2, readRawSessionMessageOrdinalPageFromDb2, countStoredRawSessionMessagesFromDb2, readRawSessionTailFromDb2, buildInMemoryTailRawMessages2, readRawSessionMessagePartsByIdFromDb2, forgetRawSessionOrdinalWatermark2, forgetRawSessionSummaryRows2, noteRawSessionSummaryRowWritten2, RawOrdinalsNotReady2, rawOrdinalSummarySeed2, scanRawSessionSummaryRows2, getRawSessionSummaryEpoch2, installRawSessionSummaryScan2, isRawSessionSummaryWarm2, readRawSessionMessageOrdinalByIdFromDb2, readRawSessionMessageByIdFromDb2, hasRawSessionMessageByIdFromDb2, readRawSeedTailFromDb2, readRawSessionBoundaryEndpointsFromDb2 };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./index-gycf3sp7.js";
3
+ } from "./index-7bqrfyny.js";
4
4
 
5
5
  // ../plugin/src/shared/stable-json.ts
6
6
  function stableStringify(value, seen = new WeakSet) {