@cortexkit/pi-magic-context 0.49.56 → 0.49.59

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 (55) hide show
  1. package/dist/auto-search-worker.js +5 -5
  2. package/dist/chunk-embedding-write-worker.js +12 -12
  3. package/dist/{compaction-marker-candidates-9yhrstyb.js → compaction-marker-candidates-nxaamfej.js} +2 -2
  4. package/dist/compaction-marker-candidates-worker.js +1 -1
  5. package/dist/{compartment-chunk-embedding-wg7emg3z.js → compartment-chunk-embedding-avkyp2df.js} +7 -7
  6. package/dist/{embedding-backfill-qde2zywg.js → embedding-backfill-3g3cm51d.js} +12 -12
  7. package/dist/embedding-worker-process.js +1 -1
  8. package/dist/embedding-worker.js +4 -4
  9. package/dist/historian-calibration-extension.js +1 -1
  10. package/dist/{index-j0eagxkz.js → index-1ts77n1b.js} +1 -1
  11. package/dist/{index-9x1jpjeb.js → index-2tk7e0bx.js} +100 -26
  12. package/dist/{index-xssjy4z9.js → index-3s39a1md.js} +1 -1
  13. package/dist/{index-xx1911hb.js → index-453s1hj6.js} +1 -1
  14. package/dist/{index-c3mms4dp.js → index-5hhhxck7.js} +10 -10
  15. package/dist/{index-qm139qq2.js → index-5rcjs14a.js} +2 -2
  16. package/dist/{index-yjgkjkjs.js → index-71rg8j43.js} +1 -1
  17. package/dist/{index-zxm7ckvc.js → index-79xfn84y.js} +2 -2
  18. package/dist/{index-5n3e2gq5.js → index-8gvbskcm.js} +27 -5
  19. package/dist/{index-b1q0h16h.js → index-9cqfbdgb.js} +3 -3
  20. package/dist/{index-ndg15t3x.js → index-cxczethe.js} +4 -4
  21. package/dist/{index-erkb5dee.js → index-e9wkbh8y.js} +8 -8
  22. package/dist/{index-9kaj9ty1.js → index-f4n7tnsf.js} +2 -2
  23. package/dist/{index-nhpvvdhw.js → index-fz4gexgk.js} +11 -3
  24. package/dist/{index-d40ecdbn.js → index-gavj3e6h.js} +4 -4
  25. package/dist/{index-6d0bby9d.js → index-ghp32f9m.js} +2 -2
  26. package/dist/{index-v858d5d1.js → index-jhmz9tgv.js} +1 -1
  27. package/dist/{index-awpx91y5.js → index-k7a8x7ba.js} +1 -1
  28. package/dist/{index-2pptpxq8.js → index-m6kszx0e.js} +4 -4
  29. package/dist/{index-7y60kyea.js → index-pefn1gt5.js} +1 -1
  30. package/dist/{index-jnh7a6a3.js → index-qdy49kwk.js} +4 -4
  31. package/dist/{index-yxeg8zaa.js → index-tm11k42a.js} +9 -4
  32. package/dist/{index-hec3bwev.js → index-txcs0vnj.js} +2 -2
  33. package/dist/{index-625kbnqd.js → index-w4sqw9mf.js} +8 -8
  34. package/dist/{index-rekymyxd.js → index-xan5mt5f.js} +5 -5
  35. package/dist/{index-szn2tac8.js → index-xjhq27z9.js} +1 -1
  36. package/dist/{index-ywmt8sdr.js → index-zgsemyph.js} +26 -11
  37. package/dist/index.js +1172 -373
  38. package/dist/{logger-hhgpkbx1.js → logger-93cnqyh0.js} +1 -1
  39. package/dist/{message-fts-rowid-map-tec2x7qe.js → message-fts-rowid-map-dtbragnt.js} +4 -4
  40. package/dist/{message-index-bounded-ac4qg6aw.js → message-index-bounded-behq385r.js} +9 -9
  41. package/dist/{message-time-backfill-krre2qnb.js → message-time-backfill-8zwv9byv.js} +2 -2
  42. package/dist/migration-worker.js +9 -9
  43. package/dist/{project-embedding-registry-qx2zjbgs.js → project-embedding-registry-63wsm3a8.js} +11 -11
  44. package/dist/raw-ordinal-warmup-worker.js +8 -8
  45. package/dist/{read-session-chunk-jyfcykg4.js → read-session-chunk-ksh32zfv.js} +7 -7
  46. package/dist/{read-session-raw-75dcxtdy.js → read-session-raw-0tytrjye.js} +2 -2
  47. package/dist/{render-gj0nzrg0.js → render-2qed2svq.js} +16 -16
  48. package/dist/{safe-notification-target-8s1xg0q9.js → safe-notification-target-fkyrd95h.js} +2 -2
  49. package/dist/{search-archive-vpxem4pj.js → search-archive-qqj7j1w1.js} +9 -9
  50. package/dist/{search-w12nc025.js → search-vmw1xbqx.js} +19 -19
  51. package/dist/{storage-tags-g0328gwp.js → storage-tags-s0m7e39a.js} +5 -5
  52. package/dist/subagent-entry.js +25 -25
  53. package/dist/tag-snapshot-worker-pi.js +11 -11
  54. package/dist/{v2-archive-reader-r96gp6nc.js → v2-archive-reader-cc7sx6dk.js} +1 -1
  55. package/package.json +3 -1
@@ -12,17 +12,17 @@ import {
12
12
  } from "./index-0h2mkab2.js";
13
13
  import {
14
14
  sessionLog2
15
- } from "./index-yxeg8zaa.js";
15
+ } from "./index-tm11k42a.js";
16
16
  import {
17
17
  estimateTokens,
18
18
  createTokenCountMemo
19
- } from "./index-7y60kyea.js";
19
+ } from "./index-pefn1gt5.js";
20
20
  import {
21
21
  stableStringify,
22
22
  jsonHashSink,
23
23
  tagOrderConstraintIndex,
24
24
  tagIdentityRevisionKey
25
- } from "./index-v858d5d1.js";
25
+ } from "./index-jhmz9tgv.js";
26
26
  import {
27
27
  getTagIdentityWriteGeneration2,
28
28
  getSqliteDatabasePath2,
@@ -30,7 +30,7 @@ import {
30
30
  } from "./index-2qtx0q6h.js";
31
31
  import {
32
32
  logSlowWriteTransaction
33
- } from "./index-j0eagxkz.js";
33
+ } from "./index-1ts77n1b.js";
34
34
 
35
35
  // ../plugin/src/features/magic-context/overflow-detection.ts
36
36
  var OVERFLOW_PATTERNS = [
@@ -4973,6 +4973,12 @@ var AUTO_SEARCH_NO_HINT_REASONS = new Set([
4973
4973
  "stacked",
4974
4974
  "too-short"
4975
4975
  ]);
4976
+ function isPersistedUsageRow(row) {
4977
+ if (row === null || typeof row !== "object")
4978
+ return false;
4979
+ const r = row;
4980
+ return typeof r.last_context_percentage === "number" && typeof r.last_input_tokens === "number" && typeof r.last_response_time === "number" && (typeof r.last_observed_model_key === "string" || r.last_observed_model_key === null) && (typeof r.last_usage_context_limit === "number" || r.last_usage_context_limit === null) && typeof r.observed_safe_input_tokens === "number";
4981
+ }
4976
4982
  function isPersistedNoteNudgeRow(row) {
4977
4983
  if (row === null || typeof row !== "object")
4978
4984
  return false;
@@ -5047,6 +5053,22 @@ function parseHistorianFailureState(result) {
5047
5053
  lastFailureAt: typeof result.historian_last_failure_at === "number" ? result.historian_last_failure_at : null
5048
5054
  };
5049
5055
  }
5056
+ function loadPersistedUsage(db, sessionId) {
5057
+ const result = db.prepare("SELECT last_context_percentage, last_input_tokens, last_response_time, last_observed_model_key, last_usage_context_limit, observed_safe_input_tokens FROM session_meta WHERE session_id = ?").get(sessionId);
5058
+ if (!isPersistedUsageRow(result) || result.last_context_percentage === 0 && result.last_input_tokens === 0) {
5059
+ return null;
5060
+ }
5061
+ return {
5062
+ usage: {
5063
+ percentage: result.last_context_percentage,
5064
+ inputTokens: result.last_input_tokens
5065
+ },
5066
+ updatedAt: result.last_response_time || Date.now(),
5067
+ lastObservedModelKey: result.last_observed_model_key,
5068
+ lastUsageContextLimit: typeof result.last_usage_context_limit === "number" ? result.last_usage_context_limit : 0,
5069
+ observedSafeInputTokens: result.observed_safe_input_tokens
5070
+ };
5071
+ }
5050
5072
  var DEFAULT_PROTECTED_TAIL_META = {
5051
5073
  priorBoundaryOrdinal: 1,
5052
5074
  protectedTailPolicyVersion: 0,
@@ -6466,4 +6488,4 @@ function resolveEpochFloorForPass(db, sessionId, inputs) {
6466
6488
  return preSnapshotResult(firstObservedMemo, resolvedInputs);
6467
6489
  }
6468
6490
 
6469
- export { detectThinkingBindingMismatch, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, decodeMergedReasoningParts, UNKNOWN_FIT_RATIO, hasMeasuredDecisionCalibration, providerMass, localBudget, calibrationForModelKey, historyLocalBudget, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, adoptedProtectedToolsPolicy, protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, rememberCurrentToolOutputCount, currentReclaimableToolOutputCount, isRecord, TEXT_TAG_IDENTITY_MARKER, PI_FALLBACK_PREFIXES_JSON, contentTagOwnerMessageId, TailHygieneJsonMemo, piJsonHash, estimateImageTokensFromDataUrl, 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, SESSION_META_SELECT_COLUMNS, META_COLUMNS, BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, isSessionMetaRow, getDefaultSessionMeta, ensureSessionMetaRow, toSessionMeta, persistCachedM0, clearCachedM0M1, isRustMarkerAdmissionFenced, ReplayDocumentError, readReplayEnvelope, readReplayDocument, updateReplayDocument, writeReplayDocument, getReasoningRemovalState, modelAcceptsEmptyContent, isAnthropicFamilyRoute, variantChangeBustsProviderCache, isInActiveAnthropicTurn, activeAnthropicTurnStart, hasAnthropicReasoning, isMarkerOnlyText, findLatestAssistantReasoningMutationExemptMessage, DEFAULT_KEEP_REASONING_TOKENS, resolveKeepReasoningTokens, reasoningStepCost, reasoningBudgetCutoff, reasoningTextAndOpaque, opaqueThinkingCost, estimatePartImageTokens, planEmergencyDrop, measureEmergencyTag, tagsSinceReading, 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, normalizeTagSnapshotRow2, 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, getTailHygieneTags2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2, rowWindowMass, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, EMERGENCY_DRAIN_FAILURE_BACKOFF_MS, getProtectedTailDrainBudgetSkip, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, queueAutoSearchHintDecisionRetirement, flushAutoSearchHintDecisionRetirement, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, setNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, getCompactionMarkerPublicationState, compareAndSetCompactionMarkerPublicationState, getDeferredClearedCompactionMarkerState, parseStrippedPlaceholderState, serializeStrippedPlaceholderState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, THINKING_BINDING_STRIP_ORDER_END_MARKER, thinkingBindingRecoveryFrozenId, COMPACTION_OFF_THINKING_FROZEN_PREFIX, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, parseProcessedImageMarkers, serializeProcessedImageMarkers, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, loadPostprocessReplaySnapshot, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, logPiCompactionMarkerClear, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass };
6491
+ export { detectThinkingBindingMismatch, detectLatestTurnThinkingMismatch, isPrefixBoundThinkingModel, detectOverflow, MAX_EXECUTE_THRESHOLD, escalationBands, MERGED_REASONING_PARTS_PREFIX, decodeMergedReasoningParts, UNKNOWN_FIT_RATIO, hasMeasuredDecisionCalibration, providerMass, localBudget, calibrationForModelKey, historyLocalBudget, HYGIENE_PROVIDER_UNITS_VERSION, sessionDecisionCalibration, transitionSessionHygieneUnits, adoptedProtectedToolsPolicy, protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, rememberCurrentToolOutputCount, currentReclaimableToolOutputCount, isRecord, TEXT_TAG_IDENTITY_MARKER, PI_FALLBACK_PREFIXES_JSON, contentTagOwnerMessageId, TailHygieneJsonMemo, piJsonHash, estimateImageTokensFromDataUrl, 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, SESSION_META_SELECT_COLUMNS, META_COLUMNS, BOOLEAN_META_KEYS, NULL_BIND_META_KEYS, isSessionMetaRow, getDefaultSessionMeta, ensureSessionMetaRow, toSessionMeta, persistCachedM0, clearCachedM0M1, isRustMarkerAdmissionFenced, ReplayDocumentError, readReplayEnvelope, readReplayDocument, updateReplayDocument, writeReplayDocument, getReasoningRemovalState, modelAcceptsEmptyContent, isAnthropicFamilyRoute, variantChangeBustsProviderCache, isInActiveAnthropicTurn, activeAnthropicTurnStart, hasAnthropicReasoning, isMarkerOnlyText, findLatestAssistantReasoningMutationExemptMessage, DEFAULT_KEEP_REASONING_TOKENS, resolveKeepReasoningTokens, reasoningStepCost, reasoningBudgetCutoff, reasoningTextAndOpaque, opaqueThinkingCost, estimatePartImageTokens, planEmergencyDrop, measureEmergencyTag, tagsSinceReading, 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, normalizeTagSnapshotRow2, 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, getTailHygieneTags2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2, rowWindowMass, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, isProviderOverflowFailClosedProven, getEmergencyRecoveryArmedAt, describeProtectedTailDrainBudgetSkip, loadPersistedUsage, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, EMERGENCY_DRAIN_FAILURE_BACKOFF_MS, getProtectedTailDrainBudgetSkip, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, queueAutoSearchHintDecisionRetirement, flushAutoSearchHintDecisionRetirement, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, setNoteLastReadAt, getHistorianFailureState, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getPersistedCompactionMarkerState, getCompactionMarkerPublicationState, compareAndSetCompactionMarkerPublicationState, getDeferredClearedCompactionMarkerState, parseStrippedPlaceholderState, serializeStrippedPlaceholderState, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, THINKING_BINDING_STRIP_ORDER_END_MARKER, thinkingBindingRecoveryFrozenId, COMPACTION_OFF_THINKING_FROZEN_PREFIX, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, parseProcessedImageMarkers, serializeProcessedImageMarkers, addProcessedImageStrippedIds, getPendingCompactionMarkerState, getCompactionMarkerHealth, loadPostprocessReplaySnapshot, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, logPiCompactionMarkerClear, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass };
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
139
139
  import("./sqlite-v89bj0yy.js"),
140
140
  import("./store-reader-mmfw2h48.js"),
141
141
  import("./store-0hhs1db3.js"),
142
- import("./read-session-chunk-jyfcykg4.js"),
143
- import("./render-gj0nzrg0.js"),
144
- import("./search-archive-vpxem4pj.js"),
142
+ import("./read-session-chunk-ksh32zfv.js"),
143
+ import("./render-2qed2svq.js"),
144
+ import("./search-archive-qqj7j1w1.js"),
145
145
  import("./expand-attachments-8sxeyj26.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  getTokenEstimatorFingerprint,
3
3
  estimateTokens
4
- } from "./index-7y60kyea.js";
4
+ } from "./index-pefn1gt5.js";
5
5
  import {
6
6
  getHarness2
7
7
  } from "./index-0h2mkab2.js";
8
8
  import {
9
9
  log2
10
- } from "./index-yxeg8zaa.js";
10
+ } from "./index-tm11k42a.js";
11
11
  import {
12
12
  isSynapseEmbeddingTruncated
13
- } from "./index-qm139qq2.js";
13
+ } from "./index-5rcjs14a.js";
14
14
  import {
15
15
  messageFtsOrdinalRangeIsMapped2
16
- } from "./index-6d0bby9d.js";
16
+ } from "./index-ghp32f9m.js";
17
17
  import {
18
18
  isKnownAutocommit
19
19
  } from "./index-nrzkqte4.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./index-7y60kyea.js";
3
+ } from "./index-pefn1gt5.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./index-0h2mkab2.js";
7
7
  import {
8
8
  log2
9
- } from "./index-yxeg8zaa.js";
9
+ } from "./index-tm11k42a.js";
10
10
  import {
11
11
  sanitizeDiagnosticText
12
12
  } from "./index-dnp1jjar.js";
@@ -15,7 +15,7 @@ import {
15
15
  isSynapseEmbeddingTruncated,
16
16
  getSynapseBatchRequestKey,
17
17
  SynapseEmbeddingProvider
18
- } from "./index-qm139qq2.js";
18
+ } from "./index-5rcjs14a.js";
19
19
  import {
20
20
  inRootAsyncContext2,
21
21
  getSqliteDatabasePath2
@@ -43,7 +43,7 @@ import {
43
43
  countSessionCompartmentEmbedCoverage2,
44
44
  countSessionCompartmentEmbedCoveragePolite2,
45
45
  countUnembeddedSessionCompartmentsPolite2
46
- } from "./index-ndg15t3x.js";
46
+ } from "./index-cxczethe.js";
47
47
  import {
48
48
  DEFAULT_LOCAL_EMBEDDING_MODEL
49
49
  } from "./index-vcegxfwg.js";
@@ -56,7 +56,7 @@ import {
56
56
  getEmbeddingProviderIdentity,
57
57
  dominantEmbeddingFailure,
58
58
  LocalEmbeddingProvider
59
- } from "./index-hec3bwev.js";
59
+ } from "./index-txcs0vnj.js";
60
60
  import {
61
61
  embedPauseBySession,
62
62
  activeEmbeddingSessions,
@@ -67,7 +67,7 @@ import {
67
67
  } from "./index-hgd00nas.js";
68
68
  import {
69
69
  setBootQuietPeriodForTests
70
- } from "./index-xx1911hb.js";
70
+ } from "./index-453s1hj6.js";
71
71
  import {
72
72
  isEmbeddingHostBusy2
73
73
  } from "./index-9p40dgkm.js";
@@ -78,7 +78,7 @@ import {
78
78
  acquireGitSweepLease,
79
79
  renewGitSweepLease,
80
80
  releaseGitSweepLease
81
- } from "./index-zxm7ckvc.js";
81
+ } from "./index-79xfn84y.js";
82
82
  import {
83
83
  saveEmbeddingIfHashMatches,
84
84
  getMemoryEmbedCoverage,
@@ -89,7 +89,7 @@ import {
89
89
  } from "./index-nrzkqte4.js";
90
90
  import {
91
91
  logSlowWriteTransaction
92
- } from "./index-j0eagxkz.js";
92
+ } from "./index-1ts77n1b.js";
93
93
 
94
94
  // ../plugin/src/features/magic-context/memory/embedding-openai.ts
95
95
  import { createHash } from "node:crypto";
@@ -3,10 +3,10 @@ import {
3
3
  } from "./index-8d2z6503.js";
4
4
  import {
5
5
  estimateTokens
6
- } from "./index-7y60kyea.js";
6
+ } from "./index-pefn1gt5.js";
7
7
  import {
8
8
  readRawSessionMessageIdOrdinalsForRange2
9
- } from "./index-rekymyxd.js";
9
+ } from "./index-xan5mt5f.js";
10
10
 
11
11
  // ../plugin/src/tools/ctx-expand/search-archive.ts
12
12
  var archiveReadsOnThisThread = 0;
@@ -3,11 +3,11 @@ import {
3
3
  tagRevisionCountSql,
4
4
  tagRevisionKey,
5
5
  TAG_INSERT_CONFLICT_ROWS
6
- } from "./index-v858d5d1.js";
6
+ } from "./index-jhmz9tgv.js";
7
7
  import {
8
8
  getTagsBySession2,
9
9
  getTagsByNumbers2
10
- } from "./index-5n3e2gq5.js";
10
+ } from "./index-8gvbskcm.js";
11
11
  import {
12
12
  inRootAsyncContext2,
13
13
  getSqliteDatabasePath2,
@@ -38,6 +38,14 @@ var PI_CONTEXT_BUDGET = {
38
38
  class PiContextDeadlineError extends Error {
39
39
  }
40
40
 
41
+ class PiHistorianJoinDeadlineError extends PiContextDeadlineError {
42
+ refusal;
43
+ constructor(diagnostic, refusal) {
44
+ super(diagnostic);
45
+ this.refusal = refusal;
46
+ }
47
+ }
48
+
41
49
  class PiContextSupersededError extends Error {
42
50
  origin;
43
51
  constructor(message, origin = "context ownership") {
@@ -1132,4 +1140,4 @@ function ensurePiTagSnapshotReady(db, sessionId, budget, projection) {
1132
1140
  })();
1133
1141
  }
1134
1142
 
1135
- export { PI_CONTEXT_BUDGET, PiContextDeadlineError, PiContextSupersededError, PiContextBudget, encodePiHydrationOperation, PiTagHydrationError, projectPiPassTag, PI_FALLBACK_ROW_COLUMNS, PI_FALLBACK_ROW_PREDICATE, getPiPassTagSnapshotView, getPiActiveTagSnapshotView, readPiFallbackTagRows, prewarmPiTagSnapshot, cancelPiTagSnapshotSession, drainPiTagSnapshotSession, assertPiTagSnapshotReady, ensurePiTagSnapshotReady };
1143
+ export { PI_CONTEXT_BUDGET, PiContextDeadlineError, PiHistorianJoinDeadlineError, PiContextSupersededError, PiContextBudget, encodePiHydrationOperation, PiTagHydrationError, projectPiPassTag, PI_FALLBACK_ROW_COLUMNS, PI_FALLBACK_ROW_PREDICATE, getPiPassTagSnapshotView, getPiActiveTagSnapshotView, readPiFallbackTagRows, prewarmPiTagSnapshot, cancelPiTagSnapshotSession, drainPiTagSnapshotSession, assertPiTagSnapshotReady, ensurePiTagSnapshotReady };
@@ -3,12 +3,12 @@ import {
3
3
  } from "./index-135e8hvg.js";
4
4
  import {
5
5
  log2
6
- } from "./index-yxeg8zaa.js";
6
+ } from "./index-tm11k42a.js";
7
7
  import {
8
8
  ensureColumn,
9
9
  healAllNullColumns,
10
10
  installV95PerfSchema
11
- } from "./index-v858d5d1.js";
11
+ } from "./index-jhmz9tgv.js";
12
12
  import {
13
13
  resolveOpenCodeDbPath,
14
14
  openCodeDbPathExists,
@@ -20,10 +20,10 @@ import {
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./index-xx1911hb.js";
23
+ } from "./index-453s1hj6.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
- } from "./index-j0eagxkz.js";
26
+ } from "./index-1ts77n1b.js";
27
27
 
28
28
  // ../plugin/src/features/magic-context/migrations.ts
29
29
  import { isMainThread } from "node:worker_threads";
@@ -5,10 +5,10 @@ import {
5
5
  } from "./index-2qtx0q6h.js";
6
6
  import {
7
7
  runSessionWarmupWorker
8
- } from "./index-szn2tac8.js";
8
+ } from "./index-xjhq27z9.js";
9
9
  import {
10
10
  logSlowWriteTransaction
11
- } from "./index-j0eagxkz.js";
11
+ } from "./index-1ts77n1b.js";
12
12
 
13
13
  // ../plugin/src/features/magic-context/message-fts-rowid-map.ts
14
14
  import { createHash } from "node:crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./index-yxeg8zaa.js";
3
+ } from "./index-tm11k42a.js";
4
4
  import {
5
5
  isKnownAutocommit
6
6
  } from "./index-nrzkqte4.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-2qtx0q6h.js";
7
7
  import {
8
8
  managedAuthorityNoteRow
9
- } from "./index-d40ecdbn.js";
9
+ } from "./index-gavj3e6h.js";
10
10
 
11
11
  // ../plugin/src/features/magic-context/storage-notes.ts
12
12
  var NOTE_TYPES = new Set(["session", "smart"]);
@@ -6,19 +6,19 @@ import {
6
6
  removeNestedBlocks,
7
7
  hasMeaningfulUserText2,
8
8
  extractTexts2
9
- } from "./index-7y60kyea.js";
9
+ } from "./index-pefn1gt5.js";
10
10
  import {
11
11
  cleanUserText2
12
- } from "./index-rekymyxd.js";
12
+ } from "./index-xan5mt5f.js";
13
13
  import {
14
14
  recordMessageFtsRowid2,
15
15
  recordIndexedMessageTime2,
16
16
  messageFtsOrdinalRangeIsMapped2,
17
17
  deleteUnmappedMessageFtsRows2
18
- } from "./index-6d0bby9d.js";
18
+ } from "./index-ghp32f9m.js";
19
19
  import {
20
20
  logSlowWriteTransaction
21
- } from "./index-j0eagxkz.js";
21
+ } from "./index-1ts77n1b.js";
22
22
 
23
23
  // ../plugin/src/features/magic-context/compression-depth-storage.ts
24
24
  var incrementDepthStatements = new WeakMap;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-yxeg8zaa.js";
3
+ } from "./index-tm11k42a.js";
4
4
 
5
5
  // ../plugin/src/hooks/magic-context/read-session-formatting.ts
6
6
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
@@ -3,19 +3,19 @@ import {
3
3
  } from "./index-vcegxfwg.js";
4
4
  import {
5
5
  log2
6
- } from "./index-yxeg8zaa.js";
6
+ } from "./index-tm11k42a.js";
7
7
  import {
8
8
  isSynapseEmbeddingTruncated,
9
9
  SynapseEmbeddingProvider
10
- } from "./index-qm139qq2.js";
10
+ } from "./index-5rcjs14a.js";
11
11
  import {
12
12
  LocalEmbeddingProvider
13
- } from "./index-hec3bwev.js";
13
+ } from "./index-txcs0vnj.js";
14
14
  import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./index-erkb5dee.js";
18
+ } from "./index-e9wkbh8y.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./index-9p40dgkm.js";
@@ -41,6 +41,14 @@ function getMagicContextLogPath(harness = getHarness2()) {
41
41
  return envPath;
42
42
  return path.join(getMagicContextTempDir(harness), "magic-context.log");
43
43
  }
44
+ function getMagicContextHistorianDir(harness = getHarness2()) {
45
+ return path.join(getMagicContextTempDir(harness), "historian");
46
+ }
47
+ function getMagicContextHistorianSessionDir(sessionId, harness = getHarness2()) {
48
+ const safeSessionId = sessionId.replace(/[^a-zA-Z0-9._-]/g, "-");
49
+ const directoryName = /^\.*$/.test(safeSessionId) ? "unknown-session" : safeSessionId;
50
+ return path.join(getMagicContextHistorianDir(harness), directoryName);
51
+ }
44
52
  function getProjectMagicContextDir(directory) {
45
53
  return path.join(directory, ".cortexkit", "magic-context");
46
54
  }
@@ -70,9 +78,6 @@ function ensureCortexKitArtifactGitignore(directory) {
70
78
  log2("Failed to ensure project artifact gitignore", { directory, error: String(error) });
71
79
  }
72
80
  }
73
- function getProjectMagicContextHistorianDir(directory) {
74
- return path.join(getProjectMagicContextDir(directory), "historian");
75
- }
76
81
  function getOpenCodeStorageDir() {
77
82
  return path.join(getDataDir(), "opencode", "storage");
78
83
  }
@@ -482,4 +487,4 @@ if (!isTestEnv) {
482
487
  process.on("exit", flush);
483
488
  }
484
489
 
485
- export { getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, isMagicContextStorageOutsideEngram, claimStorageBackupWarningCheck, getLegacyOpenCodeMagicContextStorageDir, registerStalePluginBuildHost, classifyStalePluginBuild, importPluginModule, setLogLineForwarder2, writeForwardedLogLine2, log2, sessionLog2, getLoggerDiagnostics2, flushLogger2, getLogFilePath2 };
490
+ export { getDataDir, getMagicContextHistorianSessionDir, ensureCortexKitArtifactGitignore, getMagicContextStorageDir, isMagicContextStorageOutsideEngram, claimStorageBackupWarningCheck, getLegacyOpenCodeMagicContextStorageDir, registerStalePluginBuildHost, classifyStalePluginBuild, importPluginModule, setLogLineForwarder2, writeForwardedLogLine2, log2, sessionLog2, getLoggerDiagnostics2, flushLogger2, getLogFilePath2 };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-vcegxfwg.js";
4
4
  import {
5
5
  getSynapseLaneIdentity
6
- } from "./index-qm139qq2.js";
6
+ } from "./index-5rcjs14a.js";
7
7
  import {
8
8
  getHarness2
9
9
  } from "./index-0h2mkab2.js";
@@ -11,7 +11,7 @@ import {
11
11
  getMagicContextStorageDir,
12
12
  importPluginModule,
13
13
  log2
14
- } from "./index-yxeg8zaa.js";
14
+ } from "./index-tm11k42a.js";
15
15
  import {
16
16
  inRootAsyncContext2
17
17
  } from "./index-2qtx0q6h.js";
@@ -8,7 +8,7 @@ import {
8
8
  importPluginModule,
9
9
  writeForwardedLogLine2,
10
10
  log2
11
- } from "./index-yxeg8zaa.js";
11
+ } from "./index-tm11k42a.js";
12
12
  import {
13
13
  inRootAsyncContext2,
14
14
  registerSlowWriteReporter2,
@@ -24,7 +24,7 @@ import {
24
24
  } from "./index-2qtx0q6h.js";
25
25
  import {
26
26
  scheduleAfterBootQuiet
27
- } from "./index-xx1911hb.js";
27
+ } from "./index-453s1hj6.js";
28
28
  import {
29
29
  configureContextDatabasePragmas2
30
30
  } from "./index-fapenpch.js";
@@ -36,7 +36,7 @@ import {
36
36
  } from "./index-wfqysrwq.js";
37
37
  import {
38
38
  startMessageFtsRowidMapBackfill2
39
- } from "./index-6d0bby9d.js";
39
+ } from "./index-ghp32f9m.js";
40
40
  import {
41
41
  LKG_SLOT_CHUNKS_DDL,
42
42
  SESSION_REPLAY_DECISIONS_DDL,
@@ -46,14 +46,14 @@ import {
46
46
  hasPendingMigrations,
47
47
  getMainThreadMigrationBodyCount,
48
48
  runMigrations
49
- } from "./index-d40ecdbn.js";
49
+ } from "./index-gavj3e6h.js";
50
50
  import {
51
51
  setDatabase,
52
52
  loadToolDefinitionMeasurements,
53
53
  ensureColumn,
54
54
  installV95PerfSchema,
55
55
  installTagIdentityRevisionTrigger
56
- } from "./index-v858d5d1.js";
56
+ } from "./index-jhmz9tgv.js";
57
57
  import {
58
58
  resolveOpenCodeDbPath,
59
59
  hasV1MessageTables
@@ -63,7 +63,7 @@ import {
63
63
  } from "./index-nrzkqte4.js";
64
64
  import {
65
65
  logSlowWriteTransaction
66
- } from "./index-j0eagxkz.js";
66
+ } from "./index-1ts77n1b.js";
67
67
  import {
68
68
  shouldEnforcePrivateStoragePermissions,
69
69
  ensureStorageDirectorySync,
@@ -1787,8 +1787,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1787
1787
  state.running = startMessageFtsRowidMapBackfill2(db, signal).then(async () => {
1788
1788
  if (signal.aborted || !readsOpenCodeStore)
1789
1789
  return;
1790
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-jyfcykg4.js"));
1791
- const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-krre2qnb.js"));
1790
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-ksh32zfv.js"));
1791
+ const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-8zwv9byv.js"));
1792
1792
  if (signal.aborted)
1793
1793
  return;
1794
1794
  await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  log2,
7
7
  sessionLog2
8
- } from "./index-yxeg8zaa.js";
8
+ } from "./index-tm11k42a.js";
9
9
  import {
10
10
  resolveOpenCodeDbPath,
11
11
  assertOpenCodeStoreGeneration,
@@ -33,13 +33,13 @@ import {
33
33
  hasRawSessionMessageByIdFromDb2,
34
34
  readRawSeedTailFromDb2,
35
35
  readRawSessionBoundaryEndpointsFromDb2
36
- } from "./index-szn2tac8.js";
36
+ } from "./index-xjhq27z9.js";
37
37
  import {
38
38
  isRecord,
39
39
  providerVisiblePart,
40
40
  getCandidateToolOwners2,
41
41
  pickNearestPriorOwner2
42
- } from "./index-5n3e2gq5.js";
42
+ } from "./index-8gvbskcm.js";
43
43
  import {
44
44
  OMO_INTERNAL_INITIATOR_MARKER,
45
45
  isSystemDirective,
@@ -54,10 +54,10 @@ import {
54
54
  formatBlock,
55
55
  compactTextForSummary,
56
56
  mergeCommitHashes
57
- } from "./index-7y60kyea.js";
57
+ } from "./index-pefn1gt5.js";
58
58
  import {
59
59
  stableStringify
60
- } from "./index-v858d5d1.js";
60
+ } from "./index-jhmz9tgv.js";
61
61
  import {
62
62
  renderToolTemplate
63
63
  } from "./index-vcegxfwg.js";
@@ -8,7 +8,7 @@ import {
8
8
  } from "./index-8sqebjzk.js";
9
9
  import {
10
10
  log2
11
- } from "./index-yxeg8zaa.js";
11
+ } from "./index-tm11k42a.js";
12
12
  import {
13
13
  reuseWorker
14
14
  } from "./index-wfqysrwq.js";
@@ -9,7 +9,7 @@ import {
9
9
  getMagicContextStorageDir,
10
10
  log2,
11
11
  sessionLog2
12
- } from "./index-yxeg8zaa.js";
12
+ } from "./index-tm11k42a.js";
13
13
  import {
14
14
  isPrefixBoundThinkingModel,
15
15
  MERGED_REASONING_PARTS_PREFIX,
@@ -39,10 +39,10 @@ import {
39
39
  serializeProcessedImageMarkers,
40
40
  getPendingPiCompactionMarkerState,
41
41
  logPiCompactionMarkerClear
42
- } from "./index-5n3e2gq5.js";
42
+ } from "./index-8gvbskcm.js";
43
43
  import {
44
44
  estimateTokens
45
- } from "./index-7y60kyea.js";
45
+ } from "./index-pefn1gt5.js";
46
46
  import {
47
47
  BoundedSessionMap,
48
48
  getTableColumnNames,
@@ -51,7 +51,7 @@ import {
51
51
  tagRevisionKey,
52
52
  tagIdentityRevisionKey,
53
53
  deleteTagIdentityRevisions
54
- } from "./index-v858d5d1.js";
54
+ } from "./index-jhmz9tgv.js";
55
55
  import {
56
56
  prepareCachedStatement2,
57
57
  withSqliteBackgroundWriter2,
@@ -60,23 +60,23 @@ import {
60
60
  import {
61
61
  isPidAlive,
62
62
  readProcessStartTime
63
- } from "./index-625kbnqd.js";
63
+ } from "./index-w4sqw9mf.js";
64
64
  import {
65
65
  withReadOnlySessionDb,
66
66
  expandToolPart,
67
67
  visitRawSessionMessages2,
68
68
  readRawSessionMessageById2
69
- } from "./index-rekymyxd.js";
69
+ } from "./index-xan5mt5f.js";
70
70
  import {
71
71
  gaDatabasePath2,
72
72
  V2StoreReader2
73
73
  } from "./index-nvh6d3bz.js";
74
74
  import {
75
75
  deleteUnmappedMessageFtsRows2
76
- } from "./index-6d0bby9d.js";
76
+ } from "./index-ghp32f9m.js";
77
77
  import {
78
78
  deleteChunkEmbedBackoffForSession2
79
- } from "./index-ndg15t3x.js";
79
+ } from "./index-cxczethe.js";
80
80
  import {
81
81
  invalidateAutoEmbedSession,
82
82
  drainBackgroundBatches
@@ -84,10 +84,10 @@ import {
84
84
  import {
85
85
  layoutLkgPrefix,
86
86
  assembleLkgPrefix
87
- } from "./index-d40ecdbn.js";
87
+ } from "./index-gavj3e6h.js";
88
88
  import {
89
89
  logSlowWriteTransaction
90
- } from "./index-j0eagxkz.js";
90
+ } from "./index-1ts77n1b.js";
91
91
  import {
92
92
  ensurePrivateStorageDirectorySync,
93
93
  writeStorageFileSync,
@@ -4131,6 +4131,21 @@ function countHistorianRuns(db, sessionId) {
4131
4131
  return 0;
4132
4132
  }
4133
4133
  }
4134
+ function getRecentFailedHistorianRunTimes(db, sessionId, limit) {
4135
+ if (!Number.isInteger(limit) || limit <= 0)
4136
+ return [];
4137
+ try {
4138
+ return db.prepare(`SELECT created_at FROM historian_runs
4139
+ WHERE session_id = ? AND run_kind = 'incremental' AND status = 'failed'
4140
+ AND id > (
4141
+ SELECT COALESCE(MAX(id), 0) FROM historian_runs
4142
+ WHERE session_id = ? AND run_kind = 'incremental' AND status = 'success'
4143
+ )
4144
+ ORDER BY id DESC LIMIT ?`).all(sessionId, sessionId, limit).map((row) => row.created_at);
4145
+ } catch {
4146
+ return [];
4147
+ }
4148
+ }
4134
4149
  function recordHistorianRun(db, input) {
4135
4150
  try {
4136
4151
  const failureReason = input.failureReason == null ? input.status === "failed" ? "provider_error" : null : capHistorianFailureReason(input.failureReason, input.status === "failed" ? "provider_error" : "");
@@ -4686,4 +4701,4 @@ function renderItemByTag2(db, sessionId, number, textIndexDomain = "part", attac
4686
4701
  return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
4687
4702
  }
4688
4703
 
4689
- export { LkgRecoveryFenceError, clearLkgFenceProcessState, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, PI_IDENTITY_FOLD_GUARD_LIMIT, readPiIdentityFoldGuards, writePiIdentityFoldGuards, readSessionActivity, observeSessionActivity, backfillSessionActivity, 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, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, beginServedRequest, noteServedPassPermission, noteServedReplay, countServedRefusal, dropServedRecord, commitServedRequest, 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, withNativeReplayWriteBarrier, 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, renderMessageByOrdinal2, renderVerboseRange2, renderVerboseRangeForTool2, renderItemByTag2 };
4704
+ export { LkgRecoveryFenceError, clearLkgFenceProcessState, lkgFenceRequiresRebuild, lkgRecoveryFenceUnclean, ownsLkgDirtyFence, invalidateCleanLkgRecoveryFence, markLkgRecoveryDirty, rememberUnpublishedAutoSearchNoHint, getUnpublishedAutoSearchNoHint, forgetUnpublishedAutoSearchNoHint, registerAutoSearchWork, cancelAutoSearchWork, PI_IDENTITY_FOLD_GUARD_LIMIT, readPiIdentityFoldGuards, writePiIdentityFoldGuards, readSessionActivity, observeSessionActivity, backfillSessionActivity, 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, getUncoveredCompartmentEndsThrough, isPartialCompartmentEnd, readProjectDocsCanonical, providerResponseFailed, isSuccessfulProviderCompletion, requestPendingMaterialization, pendingMaterializationOrigin, hasPendingMaterializationOrigin, clearPendingMaterialization, recordSystemRefreshOwnership, recordSystemPromptForRequest, recordHeldHeadForRequest, bindSystemPromptResponse, acknowledgeSystemPromptDelivery, deferDeliveredSystemRefresh, clearSystemPromptDelivery, saveLkgSlotToDb, loadPersistedLkgSlot, drainStaleLkgSlots, createDbLkgPersistence, replayLkg, beginServedRequest, noteServedPassPermission, noteServedReplay, countServedRefusal, dropServedRecord, commitServedRequest, 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, withNativeReplayWriteBarrier, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, externalHistorianFailureReason, subprocessExitHistorianFailureReason, countHistorianRuns, getRecentFailedHistorianRunTimes, recordHistorianRun, summarizeImportance, tallyFactsByCategory, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, renderMessageByOrdinal2, renderVerboseRange2, renderVerboseRangeForTool2, renderItemByTag2 };