@cortexkit/pi-magic-context 0.49.31 → 0.49.32

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 (30) hide show
  1. package/dist/auto-search-worker.js +4 -4
  2. package/dist/chunk-embedding-write-worker.js +4 -4
  3. package/dist/{compartment-chunk-embedding-pkk5beqp.js → compartment-chunk-embedding-8c85ebce.js} +1 -1
  4. package/dist/{embedding-backfill-v83xh6e8.js → embedding-backfill-rwfmyvze.js} +3 -3
  5. package/dist/{index-kmk3xpf9.js → index-0gymvr5j.js} +47 -7
  6. package/dist/{index-34e3mm36.js → index-87xkw8xm.js} +6 -4
  7. package/dist/{index-4nny4r40.js → index-9xd7qveg.js} +1 -1
  8. package/dist/{index-g026ztby.js → index-c474g0gj.js} +4 -18
  9. package/dist/{index-2nryd8ye.js → index-d0n9yjnc.js} +13 -11
  10. package/dist/{index-sr1ss4f8.js → index-d5q1q700.js} +1 -1
  11. package/dist/{index-v40sm8q6.js → index-drmr22ac.js} +3 -3
  12. package/dist/{index-bpd654bz.js → index-e59j3yq5.js} +414 -11
  13. package/dist/{index-0x1c054v.js → index-eqw9t2ty.js} +1 -1
  14. package/dist/index-nrzkqte4.js +18 -0
  15. package/dist/{index-0s14xaca.js → index-pb3ea2tq.js} +1 -1
  16. package/dist/{index-xvqcqg0r.js → index-r9y6tbbm.js} +6 -4
  17. package/dist/{index-yddeb86g.js → index-wpazxe9x.js} +64 -3
  18. package/dist/{index-0jykn0dw.js → index-xn5yh0pn.js} +65 -2
  19. package/dist/index.js +84 -314
  20. package/dist/{message-index-bounded-7aw556kv.js → message-index-bounded-n30vk21s.js} +4 -4
  21. package/dist/migration-worker.js +6 -5
  22. package/dist/{project-embedding-registry-wwbhm9rf.js → project-embedding-registry-acqb6be4.js} +2 -2
  23. package/dist/raw-ordinal-warmup-worker.js +3 -3
  24. package/dist/{read-session-chunk-xrymr0pp.js → read-session-chunk-ka6dhc77.js} +3 -3
  25. package/dist/{search-archive-5tmg1jyb.js → search-archive-msy2bczx.js} +4 -4
  26. package/dist/{search-dcdmpc62.js → search-qbxrnnjb.js} +9 -9
  27. package/dist/{storage-tags-9qaasrky.js → storage-tags-6409qq18.js} +2 -2
  28. package/dist/subagent-entry.js +12 -12
  29. package/dist/tag-snapshot-worker-pi.js +5 -5
  30. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -263,7 +263,7 @@ import {
263
263
  registerTodoStateLifecycle,
264
264
  syncCtxMemoryToolEnabled,
265
265
  registerMagicContextTools
266
- } from "./index-2nryd8ye.js";
266
+ } from "./index-d0n9yjnc.js";
267
267
  import"./index-4knyh1kt.js";
268
268
  import {
269
269
  canonicalModelIdentity,
@@ -305,7 +305,7 @@ import {
305
305
  openCurrentDatabase,
306
306
  openDatabaseAsync,
307
307
  closeDatabase
308
- } from "./index-xvqcqg0r.js";
308
+ } from "./index-r9y6tbbm.js";
309
309
  import {
310
310
  sameProjectDirectory,
311
311
  pruneMissingProjectIdentities,
@@ -483,7 +483,7 @@ import {
483
483
  getRawSessionTagKeysThrough2,
484
484
  getLegacyProtectedTailStartOrdinal2,
485
485
  readSessionChunk2
486
- } from "./index-34e3mm36.js";
486
+ } from "./index-87xkw8xm.js";
487
487
  import {
488
488
  UNKNOWN_FIT_RATIO,
489
489
  hasMeasuredDecisionCalibration,
@@ -570,7 +570,7 @@ import {
570
570
  getToolTagNumberByOwner2,
571
571
  getNullOwnerToolTag2,
572
572
  adoptNullOwnerToolTag2
573
- } from "./index-0x1c054v.js";
573
+ } from "./index-eqw9t2ty.js";
574
574
  import {
575
575
  textMentionsRecentCommit,
576
576
  hasMeaningfulUserText2,
@@ -594,18 +594,15 @@ import {
594
594
  guardSqliteTransformPass2,
595
595
  assertTransformWrite2,
596
596
  isTransientSqliteError2,
597
- withAsyncPrivilegedWriter2,
598
- indexCoordinationInput2
597
+ withAsyncPrivilegedWriter2
599
598
  } from "./index-2qtx0q6h.js";
600
599
  import {
601
600
  stableStringify,
602
- closeQuietly,
603
- isKnownAutocommit,
604
601
  getTableColumnNames,
605
602
  observeTemporalDecisions,
606
603
  freezeTemporalDecisions,
607
604
  tagIdentityRevisionKey
608
- } from "./index-g026ztby.js";
605
+ } from "./index-c474g0gj.js";
609
606
  import {
610
607
  BoundedSessionMap,
611
608
  resolveOpenCodeDbPath,
@@ -620,7 +617,6 @@ import {
620
617
  createWorkerShutdown
621
618
  } from "./index-54wmg4rj.js";
622
619
  import {
623
- runSessionWarmupWorker,
624
620
  RAW_SUMMARY_TEXT_MAX_CHARS2
625
621
  } from "./index-6981g1xv.js";
626
622
  import {
@@ -636,7 +632,7 @@ import {
636
632
  replaceCompartmentChunkEmbeddings2,
637
633
  deleteChunkEmbedBackoffForSession2,
638
634
  chunkWindowSourceKey2
639
- } from "./index-kmk3xpf9.js";
635
+ } from "./index-0gymvr5j.js";
640
636
  import {
641
637
  recordSessionProjectIdentity,
642
638
  GIT_SWEEP_LEASE_RENEWAL_MS,
@@ -671,20 +667,13 @@ import {
671
667
  embedSessionCompartmentChunks2,
672
668
  getEmbeddingCoverageStatus2,
673
669
  getAutoEmbeddingSessionCoverage2
674
- } from "./index-0jykn0dw.js";
670
+ } from "./index-xn5yh0pn.js";
675
671
  import {
676
672
  clearCompressionDepth,
677
673
  clearCompressionDepthRange,
678
674
  cleanSearchText,
679
- matchedSearchSnippet,
680
- getMessageIndexSourceIdentity,
681
- isMessageIndexSourceCurrent,
682
- getLastIndexedOrdinal,
683
- getMessageIndexReconciliationStartOrdinal,
684
- isMessageIndexReconciledThrough,
685
- indexSingleMessage,
686
- indexMessagesAfterOrdinal
687
- } from "./index-yddeb86g.js";
675
+ matchedSearchSnippet
676
+ } from "./index-wpazxe9x.js";
688
677
  import {
689
678
  rememberV1HiddenRun
690
679
  } from "./index-6x556c2q.js";
@@ -699,7 +688,7 @@ import {
699
688
  expandWorkspaceIdentitySetWithAliases,
700
689
  sourceNameForMemory,
701
690
  computeWorkspaceEpochFingerprint
702
- } from "./index-0s14xaca.js";
691
+ } from "./index-pb3ea2tq.js";
703
692
  import {
704
693
  configureContextDatabasePragmas2
705
694
  } from "./index-fapenpch.js";
@@ -748,8 +737,14 @@ import {
748
737
  verificationFileExists,
749
738
  normalizeVerificationFiles,
750
739
  indexCommitsForProject,
751
- embedUnembeddedCommits
752
- } from "./index-bpd654bz.js";
740
+ embedUnembeddedCommits,
741
+ getMessageIndexEpoch,
742
+ isMessageIndexSearchable,
743
+ scheduleReconciliation,
744
+ scheduleIncrementalIndex,
745
+ scheduleClearAndReindex,
746
+ clearSessionTracking
747
+ } from "./index-e59j3yq5.js";
753
748
  import {
754
749
  setEmbeddingSessionBusy2,
755
750
  isEmbeddingHostBusy2
@@ -785,7 +780,7 @@ import {
785
780
  } from "./index-wqpjhx1p.js";
786
781
  import {
787
782
  cosineSimilarity
788
- } from "./index-4nny4r40.js";
783
+ } from "./index-9xd7qveg.js";
789
784
  import"./index-6wdwv3a6.js";
790
785
  import {
791
786
  DREAMER_PRIMER_INVESTIGATOR_ALLOWED_TOOLS,
@@ -813,10 +808,10 @@ import {
813
808
  drainPiTagSnapshotSession,
814
809
  assertPiTagSnapshotReady,
815
810
  ensurePiTagSnapshotReady
816
- } from "./index-v40sm8q6.js";
811
+ } from "./index-drmr22ac.js";
817
812
  import"./index-jn44h81p.js";
818
813
  import"./index-1cvyaw9a.js";
819
- import"./index-sr1ss4f8.js";
814
+ import"./index-d5q1q700.js";
820
815
  import {
821
816
  __toESM
822
817
  } from "./index-22jkk6wg.js";
@@ -826,6 +821,10 @@ import {
826
821
  import {
827
822
  normalizeProtectedToolName
828
823
  } from "./index-674f6qs2.js";
824
+ import {
825
+ closeQuietly,
826
+ isKnownAutocommit
827
+ } from "./index-nrzkqte4.js";
829
828
  import {
830
829
  logSlowWriteTransaction,
831
830
  WriteTransactionSteps
@@ -3561,7 +3560,7 @@ function startHostStallProfilerSwitch() {
3561
3560
  // package.json
3562
3561
  var package_default = {
3563
3562
  name: "@cortexkit/pi-magic-context",
3564
- version: "0.49.31",
3563
+ version: "0.49.32",
3565
3564
  type: "module",
3566
3565
  description: "Pi and OMP coding agent extension for Magic Context — cross-session memory and context management",
3567
3566
  main: "dist/index.js",
@@ -4370,16 +4369,47 @@ function getDreamTaskBacklog(db, projectPath, task, options = {}) {
4370
4369
  }
4371
4370
  }
4372
4371
  var backlogCaches = new WeakMap;
4372
+ var displayBacklogCaches = new WeakMap;
4373
+ var DISPLAY_BACKLOG_MAX_AGE_MS = 60000;
4373
4374
  function getDreamTaskBacklogs(db, projectPath, tasks = CANONICAL_DREAM_TASKS, options = {}) {
4374
4375
  if (tasks.length === 0)
4375
4376
  return {};
4376
4377
  if (!isKnownAutocommit(db)) {
4377
4378
  backlogCaches.delete(db);
4379
+ displayBacklogCaches.delete(db);
4378
4380
  const result = {};
4379
4381
  for (const task of tasks)
4380
4382
  result[task] = getDreamTaskBacklog(db, projectPath, task, options);
4381
4383
  return result;
4382
4384
  }
4385
+ if (options.display) {
4386
+ let entries = displayBacklogCaches.get(db);
4387
+ if (!entries) {
4388
+ entries = new Map;
4389
+ displayBacklogCaches.set(db, entries);
4390
+ }
4391
+ const optionKey = (value) => value === undefined ? "omitted" : value === null ? "null" : `number:${value}`;
4392
+ const key = JSON.stringify([
4393
+ projectPath,
4394
+ tasks,
4395
+ optionKey(options.lastRunAt),
4396
+ optionKey(options.retrospectiveWatermarkMs)
4397
+ ]);
4398
+ const now = Date.now();
4399
+ const cached = entries.get(key);
4400
+ if (cached && now < cached.expiresAt && now >= cached.expiresAt - DISPLAY_BACKLOG_MAX_AGE_MS)
4401
+ return structuredClone(cached.value);
4402
+ const value = {};
4403
+ for (const task of tasks)
4404
+ value[task] = getDreamTaskBacklog(db, projectPath, task, options);
4405
+ if (entries.size >= 256)
4406
+ entries.delete(entries.keys().next().value);
4407
+ entries.set(key, {
4408
+ expiresAt: now + DISPLAY_BACKLOG_MAX_AGE_MS,
4409
+ value: structuredClone(value)
4410
+ });
4411
+ return value;
4412
+ }
4383
4413
  let cache = backlogCaches.get(db);
4384
4414
  if (!cache) {
4385
4415
  cache = {
@@ -23676,290 +23706,6 @@ function commitPiCompactionModeRecord(db, sessionId, record) {
23676
23706
  // src/context-handler.ts
23677
23707
  import * as crypto3 from "node:crypto";
23678
23708
 
23679
- // ../plugin/src/features/magic-context/message-index-async.ts
23680
- var indexCancellations = new Map;
23681
- var sessionEpochs = new Map;
23682
- var workerMeasurements = new WeakMap;
23683
- function isDatabaseLockedError(error) {
23684
- if (!error || typeof error !== "object")
23685
- return false;
23686
- const e = error;
23687
- if (typeof e.code === "string") {
23688
- if (e.code === "SQLITE_BUSY" || e.code === "SQLITE_LOCKED")
23689
- return true;
23690
- }
23691
- if (typeof e.message === "string") {
23692
- if (/database is locked/i.test(e.message))
23693
- return true;
23694
- if (/sqlite_(busy|locked)/i.test(e.message))
23695
- return true;
23696
- }
23697
- return false;
23698
- }
23699
- var INCREMENTAL_DEBOUNCE_MS = 100;
23700
- var RECONCILIATION_BATCH_SIZE = 100;
23701
-
23702
- class MagicContextMessageIndexHeapHolder {
23703
- reconciledSessions = new Set;
23704
- reconciledSnapshots = new Map;
23705
- stalledSessions = new Set;
23706
- reconciliationScheduledSessions = new Set;
23707
- clearAndReindexScheduledSessions = new Map;
23708
- sessionLocks = new Map;
23709
- incrementalTimers = new Map;
23710
- pendingIncrementalKeys = new Set;
23711
- completedIncrementalKeys = new Set;
23712
- activeReconcilerBuffers = new Map;
23713
- }
23714
- var heapHolder = new MagicContextMessageIndexHeapHolder;
23715
- var PREPARE_RETRY_MS = 60000;
23716
- async function sourceReady(source, sessionId) {
23717
- const prepare = source?.prepare;
23718
- return typeof prepare === "function" ? prepare(sessionId) : true;
23719
- }
23720
- function defer(fn) {
23721
- const immediate = globalThis.setImmediate;
23722
- if (typeof immediate === "function") {
23723
- inRootAsyncContext2(() => immediate(fn));
23724
- return;
23725
- }
23726
- inRootAsyncContext2(() => setTimeout(fn, 0));
23727
- }
23728
- function yieldToEventLoop() {
23729
- return new Promise((resolve) => defer(resolve));
23730
- }
23731
- function runWithSessionLock(sessionId, operation) {
23732
- const previous = heapHolder.sessionLocks.get(sessionId) ?? Promise.resolve();
23733
- const run = previous.catch(() => {
23734
- return;
23735
- }).then(async () => {
23736
- await operation();
23737
- });
23738
- heapHolder.sessionLocks.set(sessionId, run);
23739
- run.finally(() => {
23740
- if (heapHolder.sessionLocks.get(sessionId) === run) {
23741
- heapHolder.sessionLocks.delete(sessionId);
23742
- }
23743
- }).catch(() => {
23744
- return;
23745
- });
23746
- return run;
23747
- }
23748
- function logIndexingError(sessionId, action, error) {
23749
- if (isDatabaseLockedError(error)) {
23750
- sessionLog2(sessionId, `message FTS async ${action} skipped (database busy; will retry on next reconciliation)`);
23751
- return;
23752
- }
23753
- sessionLog2(sessionId, `message FTS async ${action} failed: ${error instanceof Error ? error.message : String(error)}`);
23754
- log2(`[message-index-async] ${action} failed for ${sessionId}:`, error);
23755
- }
23756
- function logReconciliationStall(sessionId, reason) {
23757
- if (heapHolder.stalledSessions.has(sessionId))
23758
- return;
23759
- heapHolder.stalledSessions.add(sessionId);
23760
- sessionLog2(sessionId, `message FTS reconciliation stalled: ${reason}; will retry`);
23761
- }
23762
- async function reconcileSessionIndex(db, sessionId, readMessages) {
23763
- if (!await sourceReady(readMessages, sessionId)) {
23764
- logReconciliationStall(sessionId, "raw message reader is not ready");
23765
- return false;
23766
- }
23767
- await runWithSessionLock(sessionId, async () => {
23768
- if (!readMessages.getRevision && heapHolder.reconciledSessions.has(sessionId))
23769
- return;
23770
- let fallbackSnapshot = null;
23771
- try {
23772
- const fullReader = typeof readMessages === "function" ? readMessages : null;
23773
- const revision = readMessages.getRevision?.(sessionId);
23774
- const previous = heapHolder.reconciledSnapshots.get(sessionId);
23775
- const finalWatermark = previous && revision === previous.revision ? previous.count : revision !== undefined && readMessages.getCountAfterRevision ? previous && revision > previous.revision ? previous.count + readMessages.getCountAfterRevision(sessionId, previous.revision, revision) : readMessages.getCountAfterRevision(sessionId, -1, revision) : readMessages.getCount ? readMessages.getCount(sessionId) : (fallbackSnapshot = fullReader?.(sessionId) ?? []).length;
23776
- let cursor = getMessageIndexReconciliationStartOrdinal(db, sessionId);
23777
- let after = cursor === previous?.count ? previous.after : undefined;
23778
- while (cursor < finalWatermark) {
23779
- const pageEnd = Math.min(finalWatermark, cursor + RECONCILIATION_BATCH_SIZE);
23780
- const messages = readMessages.readPage ? readMessages.readPage(sessionId, cursor, RECONCILIATION_BATCH_SIZE, finalWatermark, after) : (fallbackSnapshot ?? []).filter((message) => message.ordinal > cursor && message.ordinal <= pageEnd);
23781
- const retainedMessages = fallbackSnapshot ?? messages;
23782
- heapHolder.activeReconcilerBuffers.set(sessionId, retainedMessages);
23783
- withSqliteBackgroundWriter2(() => indexMessagesAfterOrdinal(db, sessionId, messages, cursor, pageEnd));
23784
- const nextCursor = getMessageIndexReconciliationStartOrdinal(db, sessionId);
23785
- if (nextCursor <= cursor)
23786
- break;
23787
- cursor = nextCursor;
23788
- const last = messages.at(-1);
23789
- after = last?.ordinal === cursor && typeof last.createdAt === "number" ? { timeCreated: last.createdAt, id: last.id } : undefined;
23790
- if (cursor < finalWatermark) {
23791
- await yieldToEventLoop();
23792
- }
23793
- }
23794
- if (isMessageIndexReconciledThrough(db, sessionId, finalWatermark)) {
23795
- heapHolder.reconciledSessions.add(sessionId);
23796
- if (revision !== undefined) {
23797
- if (!after && finalWatermark > 0 && readMessages.readPage) {
23798
- const last = readMessages.readPage(sessionId, finalWatermark - 1, 1, finalWatermark).at(-1);
23799
- if (last?.ordinal === finalWatermark && typeof last.createdAt === "number")
23800
- after = { timeCreated: last.createdAt, id: last.id };
23801
- }
23802
- heapHolder.reconciledSnapshots.set(sessionId, {
23803
- revision,
23804
- count: finalWatermark,
23805
- after
23806
- });
23807
- }
23808
- } else {
23809
- logReconciliationStall(sessionId, `gap after ordinal ${cursor} (store count ${finalWatermark})`);
23810
- }
23811
- } finally {
23812
- heapHolder.activeReconcilerBuffers.delete(sessionId);
23813
- }
23814
- });
23815
- return true;
23816
- }
23817
- function scheduleReconciliation(db, sessionId, readMessages) {
23818
- if (!readMessages.getRevision && heapHolder.reconciledSessions.has(sessionId) || heapHolder.reconciliationScheduledSessions.has(sessionId)) {
23819
- return;
23820
- }
23821
- heapHolder.reconciliationScheduledSessions.add(sessionId);
23822
- scheduleAfterBootQuiet(() => {
23823
- defer(() => {
23824
- let appendedDuringReconciliation = false;
23825
- const previousSnapshot = heapHolder.reconciledSnapshots.get(sessionId);
23826
- reconcileSessionIndex(db, sessionId, readMessages).then((ran) => {
23827
- if (ran) {
23828
- const snapshot = heapHolder.reconciledSnapshots.get(sessionId);
23829
- appendedDuringReconciliation = snapshot !== undefined && snapshot !== previousSnapshot && readMessages.getRevision !== undefined && readMessages.getRevision(sessionId) !== snapshot.revision;
23830
- return;
23831
- }
23832
- inRootAsyncContext2(() => setTimeout(() => {
23833
- heapHolder.reconciliationScheduledSessions.delete(sessionId);
23834
- scheduleReconciliation(db, sessionId, readMessages);
23835
- }, PREPARE_RETRY_MS)).unref?.();
23836
- }).catch((error) => {
23837
- logReconciliationStall(sessionId, error instanceof Error ? error.message : String(error));
23838
- if (isDatabaseLockedError(error))
23839
- inRootAsyncContext2(() => setTimeout(() => scheduleReconciliation(db, sessionId, readMessages), 1000)).unref();
23840
- }).finally(() => {
23841
- heapHolder.reconciliationScheduledSessions.delete(sessionId);
23842
- if (appendedDuringReconciliation)
23843
- scheduleReconciliation(db, sessionId, readMessages);
23844
- });
23845
- });
23846
- });
23847
- }
23848
- function scheduleIncrementalIndex(db, sessionId, messageId, messageSource) {
23849
- const schedulingKey = `${sessionId}\x00${messageId}`;
23850
- const epoch = sessionEpochs.get(sessionId) ?? 0;
23851
- if (heapHolder.pendingIncrementalKeys.has(schedulingKey))
23852
- return;
23853
- const activeTimer = heapHolder.incrementalTimers.get(schedulingKey);
23854
- if (activeTimer)
23855
- clearTimeout(activeTimer);
23856
- const timer = inRootAsyncContext2(() => setTimeout(() => {
23857
- heapHolder.incrementalTimers.delete(schedulingKey);
23858
- heapHolder.pendingIncrementalKeys.add(schedulingKey);
23859
- const indexMessage = async () => {
23860
- if ((sessionEpochs.get(sessionId) ?? 0) !== epoch || !heapHolder.pendingIncrementalKeys.has(schedulingKey))
23861
- return;
23862
- const message = typeof messageSource === "function" ? messageSource(sessionId, messageId) : messageSource;
23863
- if (!message)
23864
- return;
23865
- const revisionKey = `${schedulingKey}\x00${getMessageIndexSourceIdentity(message)}`;
23866
- if (heapHolder.completedIncrementalKeys.has(revisionKey))
23867
- return;
23868
- const currentWatermark = getLastIndexedOrdinal(db, sessionId);
23869
- if (message.ordinal <= currentWatermark && isMessageIndexSourceCurrent(db, sessionId, message)) {
23870
- heapHolder.completedIncrementalKeys.add(revisionKey);
23871
- return;
23872
- }
23873
- const wasReconciled = heapHolder.reconciledSessions.delete(sessionId);
23874
- await indexSingleMessageOffThread(db, sessionId, message);
23875
- if ((sessionEpochs.get(sessionId) ?? 0) !== epoch || !heapHolder.pendingIncrementalKeys.has(schedulingKey))
23876
- return;
23877
- const finalWatermark = getLastIndexedOrdinal(db, sessionId);
23878
- if (wasReconciled && isMessageIndexReconciledThrough(db, sessionId, finalWatermark)) {
23879
- heapHolder.reconciledSessions.add(sessionId);
23880
- }
23881
- heapHolder.completedIncrementalKeys.add(revisionKey);
23882
- };
23883
- sourceReady(messageSource, sessionId).then((ready) => {
23884
- if ((sessionEpochs.get(sessionId) ?? 0) !== epoch)
23885
- return;
23886
- if (ready)
23887
- return runWithSessionLock(sessionId, indexMessage);
23888
- setTimeout(() => scheduleIncrementalIndex(db, sessionId, messageId, messageSource), PREPARE_RETRY_MS).unref?.();
23889
- }).catch((error) => {
23890
- if ((sessionEpochs.get(sessionId) ?? 0) !== epoch)
23891
- return;
23892
- heapHolder.reconciledSessions.delete(sessionId);
23893
- logIndexingError(sessionId, `incremental index for ${messageId}`, error);
23894
- if (isDatabaseLockedError(error))
23895
- setTimeout(() => scheduleIncrementalIndex(db, sessionId, messageId, messageSource), 1000).unref();
23896
- }).finally(() => {
23897
- if ((sessionEpochs.get(sessionId) ?? 0) === epoch)
23898
- heapHolder.pendingIncrementalKeys.delete(schedulingKey);
23899
- });
23900
- }, INCREMENTAL_DEBOUNCE_MS));
23901
- heapHolder.incrementalTimers.set(schedulingKey, timer);
23902
- }
23903
- async function indexSingleMessageOffThread(db, sessionId, message) {
23904
- const path = getSqliteDatabasePath2(db);
23905
- if (!path)
23906
- return withSqliteBackgroundWriter2(() => indexSingleMessage(db, sessionId, message));
23907
- const cancellation = new Int32Array(new SharedArrayBuffer(4));
23908
- const active = indexCancellations.get(sessionId) ?? new Set;
23909
- active.add(cancellation);
23910
- indexCancellations.set(sessionId, active);
23911
- const result = await runSessionWarmupWorker({
23912
- path,
23913
- sessionId,
23914
- indexMessage: message,
23915
- harness: getHarness2(),
23916
- indexCancellation: cancellation.buffer,
23917
- ...indexCoordinationInput2()
23918
- }, {}).finally(() => {
23919
- active.delete(cancellation);
23920
- if (active.size === 0)
23921
- indexCancellations.delete(sessionId);
23922
- });
23923
- if (!("inserted" in result))
23924
- throw new Error("failure" in result ? result.detail : "unexpected indexing worker reply");
23925
- if (result.measurements) {
23926
- const sessions = workerMeasurements.get(db) ?? new Map;
23927
- sessions.set(sessionId, result.measurements);
23928
- workerMeasurements.set(db, sessions);
23929
- if (result.measurements.skipped)
23930
- log2(`[magic-context] incremental FTS skipped oversized source ${message.id} (${result.measurements.sourceBytes} bytes); identity and progress persisted`);
23931
- }
23932
- return result.inserted;
23933
- }
23934
- function clearSessionTracking(sessionId) {
23935
- sessionEpochs.set(sessionId, (sessionEpochs.get(sessionId) ?? 0) + 1);
23936
- for (const cancellation of indexCancellations.get(sessionId) ?? [])
23937
- Atomics.store(cancellation, 0, 1);
23938
- heapHolder.clearAndReindexScheduledSessions.delete(sessionId);
23939
- heapHolder.reconciledSessions.delete(sessionId);
23940
- heapHolder.reconciledSnapshots.delete(sessionId);
23941
- heapHolder.stalledSessions.delete(sessionId);
23942
- heapHolder.reconciliationScheduledSessions.delete(sessionId);
23943
- heapHolder.sessionLocks.delete(sessionId);
23944
- heapHolder.activeReconcilerBuffers.delete(sessionId);
23945
- const prefix = `${sessionId}\x00`;
23946
- for (const [key, timer] of heapHolder.incrementalTimers) {
23947
- if (key.startsWith(prefix)) {
23948
- clearTimeout(timer);
23949
- heapHolder.incrementalTimers.delete(key);
23950
- }
23951
- }
23952
- for (const key of heapHolder.pendingIncrementalKeys) {
23953
- if (key.startsWith(prefix)) {
23954
- heapHolder.pendingIncrementalKeys.delete(key);
23955
- }
23956
- }
23957
- for (const key of heapHolder.completedIncrementalKeys) {
23958
- if (key.startsWith(prefix))
23959
- heapHolder.completedIncrementalKeys.delete(key);
23960
- }
23961
- }
23962
-
23963
23709
  // ../plugin/src/hooks/magic-context/event-resolvers.ts
23964
23710
  var DEFAULT_CONTEXT_LIMIT = 200000;
23965
23711
  var clampWarnSeen = new Set;
@@ -28887,6 +28633,8 @@ class AutoSearchBusyError extends Error {
28887
28633
  }
28888
28634
  }
28889
28635
  async function searchAutoHint(db, sessionId, projectPath, query, options, entry = new URL(new URL(import.meta.url).pathname.endsWith(".ts") ? "./auto-search-worker.ts" : "./auto-search-worker.js", import.meta.url)) {
28636
+ const messageIndexEpoch = getMessageIndexEpoch(sessionId);
28637
+ const messageIndexWasSearchable = isMessageIndexSearchable(sessionId);
28890
28638
  const {
28891
28639
  rerankConfig: _rerankConfig,
28892
28640
  rerankClient: _rerankClient,
@@ -28895,7 +28643,8 @@ async function searchAutoHint(db, sessionId, projectPath, query, options, entry
28895
28643
  captureRerankLanes: _captureRerankLanes,
28896
28644
  ...hintOptions
28897
28645
  } = options;
28898
- return executeAutoSearchWorker(db, sessionId, projectPath, query, { ...hintOptions, explicitSearch: false, rerank: false }, entry, "search");
28646
+ const results = await executeAutoSearchWorker(db, sessionId, projectPath, query, { ...hintOptions, explicitSearch: false, rerank: false }, entry, "search");
28647
+ return messageIndexWasSearchable && isMessageIndexSearchable(sessionId) && getMessageIndexEpoch(sessionId) === messageIndexEpoch ? results : results.filter((result) => result.source !== "message");
28899
28648
  }
28900
28649
  var pendingBackfills = new WeakMap;
28901
28650
  var searchWorkers = new WeakMap;
@@ -45176,6 +44925,27 @@ function registerPiContextHandler(pi, baseOptions) {
45176
44925
  }
45177
44926
  return s;
45178
44927
  };
44928
+ pi.on("session_tree", (event, ctx) => {
44929
+ if (event.oldLeafId === event.newLeafId)
44930
+ return;
44931
+ const sessionId = resolveSessionId2(ctx);
44932
+ if (!sessionId)
44933
+ return;
44934
+ let entries = [];
44935
+ let offset = 0;
44936
+ scheduleClearAndReindex(baseOptions.db, sessionId, {
44937
+ prepare: async () => {
44938
+ if (resolveSessionId2(ctx) !== sessionId)
44939
+ return false;
44940
+ entries = ctx.sessionManager.getBranch();
44941
+ const alignment = resolvePiOrdinalAlignment(baseOptions.db, sessionId, entries);
44942
+ offset = alignment.offset;
44943
+ return !isPiOrdinalAlignmentUnanchored(alignment);
44944
+ },
44945
+ getCount: () => countPiRawMessages(entries, offset),
44946
+ readPage: (_session, after, limit, watermark) => convertEntriesToRawMessagePage(entries, after, limit, watermark, offset)
44947
+ });
44948
+ });
45179
44949
  pi.on("thinking_level_select", async (event, ctx) => {
45180
44950
  if (event.previousLevel === event.level)
45181
44951
  return;
@@ -51392,7 +51162,7 @@ function buildStatusDetail(pi, ctx, deps, sessionId, state, host = readStatusHos
51392
51162
  enabled: deps.dreamer?.runnable === true,
51393
51163
  scheduleSummary: deps.dreamer?.scheduleSummary ?? null,
51394
51164
  lastRunAt: safeRead(() => getMostRecentTaskRunAt(deps.db, deps.projectIdentity), null),
51395
- backlog: safeRead(() => getDreamTaskBacklogs(deps.db, deps.projectIdentity, CANONICAL_DREAM_TASKS.filter((task) => deps.smartNotesEnabled !== false || task !== "evaluate-smart-notes")), {}),
51165
+ backlog: safeRead(() => getDreamTaskBacklogs(deps.db, deps.projectIdentity, CANONICAL_DREAM_TASKS.filter((task) => deps.smartNotesEnabled !== false || task !== "evaluate-smart-notes"), { display: true }), {}),
51396
51166
  failures: safeRead(() => getFailingDreamTasks(deps.db, deps.projectIdentity).filter((state) => deps.smartNotesEnabled !== false || state.task !== "evaluate-smart-notes"), []),
51397
51167
  skipped: safeRead(() => getSkippedDreamTasks(deps.db, deps.projectIdentity).filter((task) => deps.smartNotesEnabled !== false || task !== "evaluate-smart-notes"), []),
51398
51168
  tickFailure: safeRead(() => getDreamerTickFailure(deps.db), null)
@@ -3,17 +3,17 @@ import {
3
3
  withIndexChunk2,
4
4
  yieldIndexChunk2
5
5
  } from "./index-2qtx0q6h.js";
6
- import"./index-0x1c054v.js";
6
+ import"./index-eqw9t2ty.js";
7
7
  import"./index-my0dn413.js";
8
8
  import"./index-0h2mkab2.js";
9
9
  import"./index-fgs78jyd.js";
10
- import"./index-g026ztby.js";
10
+ import"./index-c474g0gj.js";
11
11
  import"./index-ccanzg8p.js";
12
12
  import"./index-399p688g.js";
13
13
  import"./index-54wmg4rj.js";
14
14
  import"./index-6981g1xv.js";
15
15
  import"./index-23t8ryqw.js";
16
- import"./index-34e3mm36.js";
16
+ import"./index-87xkw8xm.js";
17
17
  import"./index-6x556c2q.js";
18
18
  import {
19
19
  MESSAGE_INDEX_MAX_FTS_BYTES,
@@ -22,7 +22,7 @@ import {
22
22
  markMessageIndexDirty,
23
23
  getIndexableContent,
24
24
  indexSingleMessage
25
- } from "./index-yddeb86g.js";
25
+ } from "./index-wpazxe9x.js";
26
26
  import"./index-bvpar0bg.js";
27
27
  import"./index-hqw0rt9k.js";
28
28
 
@@ -9,22 +9,23 @@ import {
9
9
  import"./index-135e8hvg.js";
10
10
  import {
11
11
  runMigrationsWithRetry
12
- } from "./index-0s14xaca.js";
13
- import {
14
- closeQuietly
15
- } from "./index-g026ztby.js";
12
+ } from "./index-pb3ea2tq.js";
13
+ import"./index-c474g0gj.js";
16
14
  import"./index-23t8ryqw.js";
17
15
  import"./index-48twbev2.js";
18
16
  import {
19
17
  setSqlitePragmaConfig,
20
18
  initializeDatabase
21
- } from "./index-xvqcqg0r.js";
19
+ } from "./index-r9y6tbbm.js";
22
20
  import"./index-fapenpch.js";
23
21
  import"./index-399p688g.js";
24
22
  import"./index-54wmg4rj.js";
25
23
  import"./index-6981g1xv.js";
26
24
  import"./index-bvpar0bg.js";
27
25
  import"./index-my0dn413.js";
26
+ import {
27
+ closeQuietly
28
+ } from "./index-nrzkqte4.js";
28
29
  import"./index-hqw0rt9k.js";
29
30
 
30
31
  // ../plugin/src/features/magic-context/migration-worker.ts
@@ -33,11 +33,11 @@ import {
33
33
  sweepAllRegisteredProjects2,
34
34
  _setTestProviderFactoryForProject2,
35
35
  _resetProjectEmbeddingRegistryForTests2
36
- } from "./index-0jykn0dw.js";
36
+ } from "./index-xn5yh0pn.js";
37
37
  import"./index-9p40dgkm.js";
38
38
  import"./index-yhzhdp3m.js";
39
39
  import"./index-4zemngt7.js";
40
- import"./index-kmk3xpf9.js";
40
+ import"./index-0gymvr5j.js";
41
41
  import"./index-wqpjhx1p.js";
42
42
  import"./index-gwxaz0z5.js";
43
43
  import"./index-ccanzg8p.js";
@@ -51,7 +51,7 @@ async function main() {
51
51
  await runMessageFtsRowidMapBackfill(db);
52
52
  reply = { kind: "fts-rowid-backfill" };
53
53
  } else if (input.searchArchive) {
54
- const { renderSearchArchive } = await import("./search-archive-5tmg1jyb.js");
54
+ const { renderSearchArchive } = await import("./search-archive-msy2bczx.js");
55
55
  const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-g9b1zdn5.js");
56
56
  const archive = input.searchArchive;
57
57
  let raw;
@@ -81,7 +81,7 @@ async function main() {
81
81
  const { setHarness } = await import("./harness-9872e0ym.js");
82
82
  setHarness(input.harness ?? "opencode");
83
83
  const [{ indexMessageInShortChunks }, { configureContextDatabasePragmas }] = await Promise.all([
84
- import("./message-index-bounded-7aw556kv.js"),
84
+ import("./message-index-bounded-n30vk21s.js"),
85
85
  import("./sqlite-context-pragmas-gcgch6qz.js")
86
86
  ]);
87
87
  configureContextDatabasePragmas(db);
@@ -95,7 +95,7 @@ async function main() {
95
95
  measurements: result.measurements
96
96
  };
97
97
  } else if (input.tagRatio !== undefined) {
98
- const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-9qaasrky.js");
98
+ const { scanTagOwnerSummary, scanTagOwnerDelta } = await import("./storage-tags-6409qq18.js");
99
99
  const delta = input.tagState ? scanTagOwnerDelta(db, input.sessionId, input.tagState) : null;
100
100
  if (delta)
101
101
  reply = { kind: "tag-delta", delta };
@@ -36,12 +36,12 @@ import {
36
36
  readSessionChunk2,
37
37
  getRawSessionMessageIdsThrough2,
38
38
  readRawSessionSeedTail2
39
- } from "./index-34e3mm36.js";
40
- import"./index-0x1c054v.js";
39
+ } from "./index-87xkw8xm.js";
40
+ import"./index-eqw9t2ty.js";
41
41
  import"./index-6x556c2q.js";
42
42
  import"./index-ccanzg8p.js";
43
43
  import"./index-23t8ryqw.js";
44
- import"./index-g026ztby.js";
44
+ import"./index-c474g0gj.js";
45
45
  import"./index-6981g1xv.js";
46
46
  import"./index-399p688g.js";
47
47
  import"./index-hqw0rt9k.js";