@cortexkit/pi-magic-context 0.49.7 → 0.49.9

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 (52) hide show
  1. package/dist/auto-search-worker.js +6 -6
  2. package/dist/{compaction-marker-candidates-tqcq5n00.js → compaction-marker-candidates-n4dphyz4.js} +3 -3
  3. package/dist/compaction-marker-candidates-worker.js +2 -2
  4. package/dist/embedding-backfill-chva00z3.js +20 -0
  5. package/dist/embedding-worker-process.js +6 -2
  6. package/dist/embedding-worker.js +6 -5
  7. package/dist/historian-calibration-extension.js +3 -2
  8. package/dist/{index-6q5mx0cz.js → index-243wh86p.js} +38 -28
  9. package/dist/{index-0j0zqb4t.js → index-3veejgp8.js} +1 -1
  10. package/dist/{index-0vrkp1jq.js → index-43zqh10z.js} +1 -1
  11. package/dist/{index-r56xgha8.js → index-4pxydwvg.js} +1 -1
  12. package/dist/{index-7mm27xdc.js → index-4vj37yw9.js} +4 -3
  13. package/dist/{index-8ye22z7k.js → index-6e3yv1jt.js} +4 -4
  14. package/dist/index-6x556c2q.js +19 -0
  15. package/dist/{index-dj8hpkz7.js → index-729kkhmf.js} +4 -3
  16. package/dist/{index-gc2749rx.js → index-8yjhda46.js} +9 -6
  17. package/dist/{index-fhv6ydkq.js → index-9vzkrnrf.js} +32 -12
  18. package/dist/{index-7ptxvfc5.js → index-asrxgdt4.js} +33 -10
  19. package/dist/{index-34zacc0h.js → index-fdxzpnbj.js} +2 -2
  20. package/dist/{index-0eg59y8d.js → index-g13fb2sj.js} +5 -5
  21. package/dist/{index-gqsfhksw.js → index-gqxsds3q.js} +6 -3
  22. package/dist/{index-x3dcnxh0.js → index-gycf3sp7.js} +5 -1
  23. package/dist/{index-0ww9cgfd.js → index-h160xxaq.js} +9 -9
  24. package/dist/{index-dj784nyr.js → index-hy44m6jc.js} +1 -1
  25. package/dist/{index-290tzwp1.js → index-kh3jt7t9.js} +1 -1
  26. package/dist/{index-8jpqq2yk.js → index-ns319t8e.js} +14 -13
  27. package/dist/{index-0d8zqccx.js → index-qc8e13wc.js} +22 -22
  28. package/dist/{index-mrsarsbh.js → index-rkwh9kce.js} +25 -24
  29. package/dist/{index-21v1kfs7.js → index-szh001qb.js} +6 -3
  30. package/dist/{index-cyrnv16r.js → index-ta0ed2nc.js} +2 -0
  31. package/dist/{index-mcgehvgw.js → index-ttxsmaj5.js} +31 -16
  32. package/dist/{index-a7fj661j.js → index-v26j81w6.js} +5 -5
  33. package/dist/{index-6vjj0555.js → index-x7426vy4.js} +242 -16
  34. package/dist/index.js +502 -149
  35. package/dist/{logger-j6tecd1h.js → logger-qg51hmp7.js} +1 -1
  36. package/dist/{message-index-bounded-e5bv8gzm.js → message-index-bounded-y1c88n9a.js} +15 -14
  37. package/dist/{message-index-8rxj3cxh.js → message-index-ejaa9may.js} +15 -14
  38. package/dist/{message-time-backfill-hmekd2jj.js → message-time-backfill-q9s88zdv.js} +3 -3
  39. package/dist/migration-worker.js +10 -10
  40. package/dist/{project-embedding-registry-z5m4eh3d.js → project-embedding-registry-bxawck58.js} +11 -11
  41. package/dist/raw-ordinal-warmup-worker.js +6 -6
  42. package/dist/{read-session-chunk-sp5adk01.js → read-session-chunk-4094zemt.js} +10 -9
  43. package/dist/{read-session-raw-s14c7nf3.js → read-session-raw-hm7ptnrh.js} +3 -3
  44. package/dist/{safe-notification-target-vn9kpmv4.js → safe-notification-target-62ty6rvp.js} +2 -2
  45. package/dist/{search-hgfaqytc.js → search-hsr95vex.js} +22 -21
  46. package/dist/{sqlite-f8kh2n10.js → sqlite-adjpy399.js} +3 -1
  47. package/dist/{storage-memory-yf7r98vz.js → storage-memory-axnsk5t1.js} +2 -2
  48. package/dist/{storage-tags-0xk95neb.js → storage-tags-zh23ynsh.js} +5 -5
  49. package/dist/subagent-entry.js +25 -24
  50. package/package.json +1 -1
  51. package/dist/embedding-backfill-vygvr2x4.js +0 -20
  52. /package/dist/{index-zh1jw8qp.js → index-xmdkde4v.js} +0 -0
@@ -1,5 +1,9 @@
1
1
  // ../plugin/src/shared/sqlite.ts
2
- import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { AsyncLocalStorage, AsyncResource } from "node:async_hooks";
3
+ var resourceRoot = new AsyncResource("magic-context:root");
4
+ function inRootAsyncContext2(operation) {
5
+ return resourceRoot.runInAsyncScope(operation);
6
+ }
3
7
  var reportSlowPrivilegedWrite;
4
8
  function registerSlowWriteReporter2(reporter) {
5
9
  reportSlowPrivilegedWrite = reporter;
@@ -190,7 +194,7 @@ function installTransactionRouting(db, readonly) {
190
194
  return endWriterTransaction(db, () => nativeExec(sql), sql);
191
195
  if (!/^\s*(?:SELECT|EXPLAIN|PRAGMA|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\b/i.test(sql)) {
192
196
  try {
193
- return withAutocommitTimeout(db, () => nativeExec(sql));
197
+ return withAutocommitTimeout(db, () => nativeExec(sql), false);
194
198
  } finally {
195
199
  if (mayChangeTagIdentity(sql))
196
200
  tagIdentityWriteGeneration += 1;
@@ -332,7 +336,7 @@ function trackSqliteConnection(db, filename, options) {
332
336
  }
333
337
  var TrackedDatabase = new Proxy(DatabaseImpl, {
334
338
  construct(target, args) {
335
- const db = Reflect.construct(target, args, target);
339
+ const db = inRootAsyncContext2(() => Reflect.construct(target, args, target));
336
340
  return trackSqliteConnection(db, args[0], args[1]);
337
341
  }
338
342
  });
@@ -516,29 +520,48 @@ function foregroundWaitLease() {
516
520
  const lease = transformPassScope.getStore();
517
521
  return lease?.active && !admissionScope.getStore() && !backgroundWriterScope.getStore() ? lease : undefined;
518
522
  }
519
- function withAutocommitTimeout(db, operation) {
523
+ function withAutocommitTimeout(db, operation, singleStatement = true) {
520
524
  assertTransformWrite2();
521
525
  const lease = foregroundWaitLease();
522
526
  if (isInTransaction(db))
523
527
  return operation();
524
528
  const scoped = lease || backgroundWriterScope.getStore();
525
529
  const previous = scoped ? pragmaNumber(db, "busy_timeout") : null;
526
- if (scoped)
527
- db.exec(`PRAGMA busy_timeout=${lease ? Math.floor(Math.min(lease.remainingWaitMs, lease.guard?.remainingMs() ?? Infinity)) : SHORT_BUSY_TIMEOUT_MS}`);
528
530
  const started = performance.now();
529
531
  let completed = false;
530
- try {
532
+ const execute = () => {
531
533
  const result = operation();
532
534
  completed = true;
533
535
  return result;
536
+ };
537
+ try {
538
+ if (!scoped)
539
+ return execute();
540
+ if (singleStatement) {
541
+ db.exec("PRAGMA busy_timeout=0");
542
+ try {
543
+ return execute();
544
+ } catch (error) {
545
+ if (!isTransientSqliteError2(error) || isInTransaction(db))
546
+ throw error;
547
+ }
548
+ assertTransformWrite2();
549
+ }
550
+ const timeout = Math.floor(Math.min(lease?.remainingWaitMs ?? SHORT_BUSY_TIMEOUT_MS, lease?.guard?.remainingMs() ?? Infinity));
551
+ db.exec(`PRAGMA busy_timeout=${timeout}`);
552
+ const waitStarted = performance.now();
553
+ try {
554
+ return execute();
555
+ } finally {
556
+ if (lease)
557
+ lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - (performance.now() - waitStarted));
558
+ }
534
559
  } catch (error) {
535
560
  if (lease && isTransientSqliteError2(error))
536
561
  throw new SqliteAcquisitionBusyError(error, "autocommit");
537
562
  throw error;
538
563
  } finally {
539
564
  const elapsed = performance.now() - started;
540
- if (lease)
541
- lease.remainingWaitMs = Math.max(0, lease.remainingWaitMs - elapsed);
542
565
  if (previous !== null)
543
566
  db.exec(`PRAGMA busy_timeout=${previous}`);
544
567
  if (elapsed >= SLOW_WRITER_LOG_MS)
@@ -798,4 +821,4 @@ async function yieldIndexChunk2() {
798
821
  await yieldIndexTurn();
799
822
  }
800
823
 
801
- export { registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, guardSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
824
+ export { inRootAsyncContext2, registerSlowWriteReporter2, registerSqliteDiagnosticSink2, detectSqliteRuntime2, getTagIdentityWriteGeneration2, Database2, getSqliteDatabasePath2, prepareCachedStatement2, withSqliteBackgroundWriter2, withSqliteTransformPass2, withoutSqliteTransformPass2, guardSqliteTransformPass2, assertTransformWrite2, isTransientSqliteError2, beginSqliteWriterAsync2, withAsyncPrivilegedWriter2, withPrivilegedWriter2, indexCoordinationInput2, releaseIndexOwner2, withIndexChunk2, yieldIndexChunk2 };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  withSqliteBackgroundWriter2,
3
3
  withoutSqliteTransformPass2
4
- } from "./index-7ptxvfc5.js";
4
+ } from "./index-asrxgdt4.js";
5
5
  import {
6
6
  logSlowWriteTransaction
7
- } from "./index-0vrkp1jq.js";
7
+ } from "./index-43zqh10z.js";
8
8
 
9
9
  // ../plugin/src/shared/project-directory-key.ts
10
10
  import path from "node:path";
@@ -3,12 +3,12 @@ import {
3
3
  } from "./index-135e8hvg.js";
4
4
  import {
5
5
  log2
6
- } from "./index-x3dcnxh0.js";
6
+ } from "./index-gycf3sp7.js";
7
7
  import {
8
8
  ensureColumn,
9
9
  healAllNullColumns,
10
10
  installV95PerfSchema
11
- } from "./index-mcgehvgw.js";
11
+ } from "./index-ttxsmaj5.js";
12
12
  import {
13
13
  resolveOpenCodeDbPath,
14
14
  openCodeDbPathExists,
@@ -16,14 +16,14 @@ import {
16
16
  } from "./index-8976mezv.js";
17
17
  import {
18
18
  Database2
19
- } from "./index-7ptxvfc5.js";
19
+ } from "./index-asrxgdt4.js";
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./index-gqsfhksw.js";
23
+ } from "./index-gqxsds3q.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
- } from "./index-0vrkp1jq.js";
26
+ } from "./index-43zqh10z.js";
27
27
 
28
28
  // ../plugin/src/features/magic-context/migrations.ts
29
29
  import { isMainThread } from "node:worker_threads";
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  getMagicContextStorageDir,
3
3
  log2
4
- } from "./index-x3dcnxh0.js";
4
+ } from "./index-gycf3sp7.js";
5
+ import {
6
+ inRootAsyncContext2
7
+ } from "./index-asrxgdt4.js";
5
8
  import {
6
9
  projectDirectoryKey
7
- } from "./index-34zacc0h.js";
10
+ } from "./index-fdxzpnbj.js";
8
11
  import {
9
12
  writeStorageFileAtomicSync
10
13
  } from "./index-81nthk8j.js";
@@ -496,7 +499,7 @@ function bootQuietRemainingMs(now = Date.now()) {
496
499
  return Math.max(0, bootQuietUntilMs - now);
497
500
  }
498
501
  function scheduleAfterBootQuiet(task, additionalDelayMs = 0) {
499
- const timer = setTimeout(task, bootQuietRemainingMs() + Math.max(0, additionalDelayMs));
502
+ const timer = inRootAsyncContext2(() => setTimeout(task, bootQuietRemainingMs() + Math.max(0, additionalDelayMs)));
500
503
  timer.unref?.();
501
504
  return timer;
502
505
  }
@@ -219,7 +219,7 @@ var SECRET_TEXT_PATTERNS = [
219
219
  replacement: "<GITHUB_PAT_REDACTED>"
220
220
  },
221
221
  {
222
- pattern: /\b(?:gh[opsu]|ghr)_[A-Za-z0-9]{30,}/g,
222
+ pattern: /\b(?:gh[opsu]|ghr)_[A-Za-z0-9_-]{30,}/g,
223
223
  replacement: "<GITHUB_TOKEN_REDACTED>"
224
224
  },
225
225
  {
@@ -250,6 +250,10 @@ var SECRET_TEXT_PATTERNS = [
250
250
  pattern: /\b((?:x-)?(?:api-?key|api-?token|auth-?token|access-?token)\s*:\s*)([^\s'"`,;<>]{6,})/gi,
251
251
  replacement: (full, prefix, value) => isNonSecretScalarValue(value) ? full : `${prefix}<REDACTED:api_key>`
252
252
  },
253
+ {
254
+ pattern: /\b((?:api[_-]?key|client[_-]?secret|access[_-]?token|token|secret|password|passwd|pwd)\s*:\s*)([^\s'"`,;<>]{6,})/gi,
255
+ replacement: (full, prefix, value) => isNonSecretScalarValue(value) ? full : `${prefix}<REDACTED:credential>`
256
+ },
253
257
  {
254
258
  pattern: /\b([a-z][a-z0-9+.-]*:\/\/[^\s/:@]+:)([^\s/@]+)(@)/gi,
255
259
  replacement: (_full, prefix, _password, at) => `${prefix}<REDACTED:password>${at}`
@@ -3,29 +3,29 @@ import {
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
5
  getMagicContextStorageDir
6
- } from "./index-x3dcnxh0.js";
6
+ } from "./index-gycf3sp7.js";
7
7
  import {
8
8
  isPidAlive,
9
9
  readProcessStartTime
10
- } from "./index-0j0zqb4t.js";
10
+ } from "./index-3veejgp8.js";
11
11
  import {
12
12
  removeSystemReminders,
13
13
  hasMeaningfulUserText2,
14
14
  extractTexts2
15
- } from "./index-r56xgha8.js";
15
+ } from "./index-4pxydwvg.js";
16
16
  import {
17
17
  withSqliteBackgroundWriter2,
18
18
  withoutSqliteTransformPass2
19
- } from "./index-7ptxvfc5.js";
19
+ } from "./index-asrxgdt4.js";
20
20
  import {
21
21
  recordMessageFtsRowid,
22
22
  recordIndexedMessageTime,
23
23
  messageFtsOrdinalRangeIsMapped,
24
24
  deleteUnmappedMessageFtsRows
25
- } from "./index-34zacc0h.js";
25
+ } from "./index-fdxzpnbj.js";
26
26
  import {
27
27
  deleteChunkEmbedBackoffForSession
28
- } from "./index-8ye22z7k.js";
28
+ } from "./index-6e3yv1jt.js";
29
29
  import {
30
30
  closeQuietly,
31
31
  TAG_TOMBSTONE_OWNER_PREFIX,
@@ -34,13 +34,13 @@ import {
34
34
  tagRevisionKey,
35
35
  tagIdentityRevisionKey,
36
36
  deleteTagIdentityRevisions
37
- } from "./index-mcgehvgw.js";
37
+ } from "./index-ttxsmaj5.js";
38
38
  import {
39
39
  cleanUserText2
40
- } from "./index-fhv6ydkq.js";
40
+ } from "./index-9vzkrnrf.js";
41
41
  import {
42
42
  logSlowWriteTransaction
43
- } from "./index-0vrkp1jq.js";
43
+ } from "./index-43zqh10z.js";
44
44
  import {
45
45
  ensurePrivateStorageDirectorySync,
46
46
  writeStorageFileSync,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withPrivilegedWriter2
3
- } from "./index-7ptxvfc5.js";
3
+ } from "./index-asrxgdt4.js";
4
4
  import {
5
5
  MEMORY_CATEGORY_ORDER_SQL
6
6
  } from "./index-135e8hvg.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-x3dcnxh0.js";
3
+ } from "./index-gycf3sp7.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$/;
@@ -2,8 +2,9 @@ import {
2
2
  getHarness2
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
+ inRootAsyncContext2,
5
6
  isTransientSqliteError2
6
- } from "./index-7ptxvfc5.js";
7
+ } from "./index-asrxgdt4.js";
7
8
  import {
8
9
  PROMOTABLE_CATEGORIES,
9
10
  CATEGORY_DEFAULT_TTL
@@ -13,7 +14,7 @@ import {
13
14
  sanitizeDiagnosticText,
14
15
  log2,
15
16
  sessionLog2
16
- } from "./index-x3dcnxh0.js";
17
+ } from "./index-gycf3sp7.js";
17
18
  import {
18
19
  resolveWorkspaceShareCategories,
19
20
  resolveWorkspaceIdentitySet,
@@ -21,17 +22,17 @@ import {
21
22
  resolveStoredPathWorkspaceIdentity,
22
23
  sourceNameForMemory,
23
24
  managedAuthorityNoteRow
24
- } from "./index-0eg59y8d.js";
25
+ } from "./index-g13fb2sj.js";
25
26
  import {
26
27
  isKnownAutocommit
27
- } from "./index-mcgehvgw.js";
28
+ } from "./index-ttxsmaj5.js";
28
29
  import {
29
30
  SubcClient
30
- } from "./index-21v1kfs7.js";
31
+ } from "./index-szh001qb.js";
31
32
  import {
32
33
  buildCanonicalChunkTextFromFts,
33
34
  loadCompartmentChunkEmbeddingsForSearch
34
- } from "./index-8ye22z7k.js";
35
+ } from "./index-6e3yv1jt.js";
35
36
  import {
36
37
  recordEmbeddingMeasurement,
37
38
  saveCommitEmbedding,
@@ -49,7 +50,7 @@ import {
49
50
  getProjectEmbeddingSnapshot2,
50
51
  embedTextForProject2,
51
52
  embedItemsForProject2
52
- } from "./index-0d8zqccx.js";
53
+ } from "./index-qc8e13wc.js";
53
54
  import {
54
55
  saveEmbeddingIfHashMatches,
55
56
  getProjectEmbeddings2
@@ -59,7 +60,7 @@ import {
59
60
  isEmbeddingEnabled,
60
61
  embedText,
61
62
  ensureMemoryEmbeddings2
62
- } from "./index-a7fj661j.js";
63
+ } from "./index-v26j81w6.js";
63
64
  import {
64
65
  getMemorySelectColumns2,
65
66
  isMemoryRow2,
@@ -73,10 +74,10 @@ import {
73
74
  getMemoryById2,
74
75
  updateMemorySeenCount2,
75
76
  updateMemoryRetrievalCount2
76
- } from "./index-dj784nyr.js";
77
+ } from "./index-hy44m6jc.js";
77
78
  import {
78
79
  getIndexedMessageCorpusSize2
79
- } from "./index-0ww9cgfd.js";
80
+ } from "./index-h160xxaq.js";
80
81
  import {
81
82
  computeNormalizedHash
82
83
  } from "./index-9x1f96r8.js";
@@ -612,8 +613,8 @@ var USER_FACING_FAILURES = {
612
613
  },
613
614
  history_boundary_unresolved: {
614
615
  code: "MC-H04",
615
- sentence: "This request was not sent: the message that marks where this session's history summary ends is missing from the OpenCode store, and without it the request is larger than the model's context window.",
616
- action: "Run /ctx-recomp to rebuild the history summary."
616
+ sentence: "This request was not sent: Magic Context could not safely place the history summary boundary in the loaded conversation, and the untrimmed request is larger than the model's context window.",
617
+ action: "Reopen this session in its current project directory, then run /ctx-recomp to rebuild the history summary. A model with a larger context window can also help."
617
618
  },
618
619
  history_over_window_unmanaged: {
619
620
  code: "MC-H06",
@@ -2153,7 +2154,7 @@ var connections = new Map;
2153
2154
  async function connect(connectionFile) {
2154
2155
  let connection = connections.get(connectionFile);
2155
2156
  if (!connection) {
2156
- connection = SubcClient.connect({ connectionFile });
2157
+ connection = inRootAsyncContext2(() => SubcClient.connect({ connectionFile }));
2157
2158
  connections.set(connectionFile, connection);
2158
2159
  connection.catch(() => connections.delete(connectionFile));
2159
2160
  }
@@ -4,25 +4,26 @@ import {
4
4
  import {
5
5
  sanitizeDiagnosticText,
6
6
  log2
7
- } from "./index-x3dcnxh0.js";
7
+ } from "./index-gycf3sp7.js";
8
8
  import {
9
9
  isUserHomeDirectory,
10
10
  setBootQuietPeriodForTests
11
- } from "./index-gqsfhksw.js";
11
+ } from "./index-gqxsds3q.js";
12
12
  import {
13
+ inRootAsyncContext2,
13
14
  withSqliteBackgroundWriter2,
14
15
  withoutSqliteTransformPass2,
15
16
  isTransientSqliteError2
16
- } from "./index-7ptxvfc5.js";
17
+ } from "./index-asrxgdt4.js";
17
18
  import {
18
19
  estimateTokens
19
- } from "./index-r56xgha8.js";
20
+ } from "./index-4pxydwvg.js";
20
21
  import {
21
22
  SYNAPSE_DEFAULT_MODEL,
22
23
  isSynapseEmbeddingTruncated,
23
24
  getSynapseBatchRequestKey,
24
25
  SynapseEmbeddingProvider
25
- } from "./index-21v1kfs7.js";
26
+ } from "./index-szh001qb.js";
26
27
  import {
27
28
  CHUNK_WINDOW_SAFETY_RATIO,
28
29
  normalizeCompartmentChunkMaxInputTokens,
@@ -39,10 +40,17 @@ import {
39
40
  countSessionCompartmentEmbedCoverage,
40
41
  countSessionCompartmentEmbedCoveragePolite,
41
42
  countUnembeddedSessionCompartmentsPolite
42
- } from "./index-8ye22z7k.js";
43
+ } from "./index-6e3yv1jt.js";
43
44
  import {
44
45
  DEFAULT_LOCAL_EMBEDDING_MODEL
45
- } from "./index-cyrnv16r.js";
46
+ } from "./index-ta0ed2nc.js";
47
+ import {
48
+ embeddingModelsMatch,
49
+ resolveEmbeddingTextPrefixes,
50
+ getEmbeddingProviderIdentity,
51
+ dominantEmbeddingFailure,
52
+ LocalEmbeddingProvider
53
+ } from "./index-8yjhda46.js";
46
54
  import {
47
55
  isEmbeddingHostBusy2
48
56
  } from "./index-9p40dgkm.js";
@@ -51,16 +59,9 @@ import {
51
59
  getMemoryEmbedCoverage,
52
60
  invalidateProject2
53
61
  } from "./index-yhzhdp3m.js";
54
- import {
55
- embeddingModelsMatch,
56
- resolveEmbeddingTextPrefixes,
57
- getEmbeddingProviderIdentity,
58
- dominantEmbeddingFailure,
59
- LocalEmbeddingProvider
60
- } from "./index-gc2749rx.js";
61
62
  import {
62
63
  logSlowWriteTransaction
63
- } from "./index-0vrkp1jq.js";
64
+ } from "./index-43zqh10z.js";
64
65
 
65
66
  // ../plugin/src/features/magic-context/session-project-storage.ts
66
67
  var SESSION_CHUNK_REPAIR_BATCH_SIZE = 100;
@@ -1012,7 +1013,6 @@ function listShadowBackfillStalls2(db, projectIdentity) {
1012
1013
  }
1013
1014
  return stalls;
1014
1015
  }
1015
-
1016
1016
  // ../plugin/src/features/magic-context/project-embedding-registry.ts
1017
1017
  var OFF_PROVIDER_IDENTITY = "embedding-provider:off";
1018
1018
  var SWEEP_MAX_WALL_CLOCK_MS = 10 * 60 * 1000;
@@ -2604,12 +2604,12 @@ async function drainCommitBacklogForProject2(db, projectIdentity, deadline) {
2604
2604
  }
2605
2605
  let total = 0;
2606
2606
  let leaseLost = false;
2607
- const renewal = setInterval(() => {
2607
+ const renewal = inRootAsyncContext2(() => setInterval(() => {
2608
2608
  try {
2609
2609
  if (!renewGitSweepLease(db, projectIdentity, holderId))
2610
2610
  leaseLost = true;
2611
2611
  } catch {}
2612
- }, SESSION_EMBED_LEASE_RENEWAL_MS);
2612
+ }, SESSION_EMBED_LEASE_RENEWAL_MS));
2613
2613
  renewal.unref?.();
2614
2614
  try {
2615
2615
  while (!leaseLost && !isEmbeddingHostBusy2() && Date.now() < deadline && total < COMMIT_DRAIN_MAX_PER_SWEEP) {
@@ -2773,12 +2773,12 @@ async function drainCompartmentChunkBacklogForProject(db, projectIdentity, deadl
2773
2773
  }
2774
2774
  let total = 0;
2775
2775
  let leaseLost = false;
2776
- const renewal = setInterval(() => {
2776
+ const renewal = inRootAsyncContext2(() => setInterval(() => {
2777
2777
  try {
2778
2778
  if (!renewGitSweepLease(db, projectIdentity, holderId))
2779
2779
  leaseLost = true;
2780
2780
  } catch {}
2781
- }, SESSION_EMBED_LEASE_RENEWAL_MS);
2781
+ }, SESSION_EMBED_LEASE_RENEWAL_MS));
2782
2782
  renewal.unref?.();
2783
2783
  try {
2784
2784
  while (!leaseLost && !isEmbeddingHostBusy2() && Date.now() < deadline && total < CHUNK_DRAIN_MAX_PER_SWEEP) {
@@ -2819,14 +2819,14 @@ async function embedSessionCompartmentChunks2(db, projectIdentity, sessionId, op
2819
2819
  drainAbort.abort();
2820
2820
  else
2821
2821
  options?.signal?.addEventListener("abort", forwardCallerAbort, { once: true });
2822
- const renewal = setInterval(() => {
2822
+ const renewal = inRootAsyncContext2(() => setInterval(() => {
2823
2823
  try {
2824
2824
  if (!renewGitSweepLease(db, projectIdentity, holderId)) {
2825
2825
  leaseLost = true;
2826
2826
  drainAbort.abort();
2827
2827
  }
2828
2828
  } catch {}
2829
- }, SESSION_EMBED_LEASE_RENEWAL_MS);
2829
+ }, SESSION_EMBED_LEASE_RENEWAL_MS));
2830
2830
  renewal.unref?.();
2831
2831
  const batchSize = Math.max(1, options?.batchSize ?? CHUNK_DRAIN_BATCH_SIZE);
2832
2832
  const skipIds = [];
@@ -7,7 +7,7 @@ import {
7
7
  getMagicContextStorageDir,
8
8
  log2,
9
9
  sessionLog2
10
- } from "./index-x3dcnxh0.js";
10
+ } from "./index-gycf3sp7.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-cyrnv16r.js";
23
+ } from "./index-ta0ed2nc.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-fhv6ydkq.js";
59
+ } from "./index-9vzkrnrf.js";
60
60
  import {
61
61
  isRecord,
62
62
  providerVisibleMessage,
@@ -70,31 +70,32 @@ import {
70
70
  getTagNumberByMessageId2,
71
71
  getTagsBySession2,
72
72
  getTagById2
73
- } from "./index-6vjj0555.js";
73
+ } from "./index-x7426vy4.js";
74
74
  import {
75
75
  estimateTokens
76
- } from "./index-r56xgha8.js";
76
+ } from "./index-4pxydwvg.js";
77
77
  import {
78
+ inRootAsyncContext2,
78
79
  Database2,
79
80
  withSqliteBackgroundWriter2,
80
81
  withoutSqliteTransformPass2
81
- } from "./index-7ptxvfc5.js";
82
+ } from "./index-asrxgdt4.js";
82
83
  import {
83
84
  stableStringify,
84
85
  closeQuietly,
85
86
  getTableColumnNames
86
- } from "./index-mcgehvgw.js";
87
+ } from "./index-ttxsmaj5.js";
87
88
  import {
88
89
  resolveOpenCodeDbPath,
89
90
  assertOpenCodeStoreGeneration
90
91
  } from "./index-8976mezv.js";
91
92
  import {
92
93
  noteRawSessionSummaryRowWritten2
93
- } from "./index-7mm27xdc.js";
94
+ } from "./index-4vj37yw9.js";
94
95
  import {
95
96
  piHarnessKindFromExecutable,
96
97
  isPidAlive
97
- } from "./index-0j0zqb4t.js";
98
+ } from "./index-3veejgp8.js";
98
99
  import {
99
100
  BoundedSessionMap,
100
101
  clearLkgFenceProcessState,
@@ -102,20 +103,20 @@ import {
102
103
  clearLkgRecoveryFence,
103
104
  deleteSessionScopedRows,
104
105
  getLastIndexedOrdinal2
105
- } from "./index-0ww9cgfd.js";
106
+ } from "./index-h160xxaq.js";
106
107
  import {
107
108
  SubcClient,
108
109
  connectionFileExists,
109
110
  SYNAPSE_DEFAULT_MODEL,
110
111
  toSynapseLaneDescriptor,
111
112
  SynapseEmbeddingProvider
112
- } from "./index-21v1kfs7.js";
113
+ } from "./index-szh001qb.js";
113
114
  import {
114
115
  sameProjectDirectory
115
- } from "./index-34zacc0h.js";
116
+ } from "./index-fdxzpnbj.js";
116
117
  import {
117
118
  getErrorMessage
118
- } from "./index-6q5mx0cz.js";
119
+ } from "./index-243wh86p.js";
119
120
  import {
120
121
  V2_MEMORY_CATEGORIES,
121
122
  CATEGORY_PRIORITY,
@@ -129,13 +130,13 @@ import {
129
130
  expandWorkspaceIdentitySetWithAliases,
130
131
  resolveStoredPathWorkspaceIdentity,
131
132
  storedPathBelongsToWorkspace
132
- } from "./index-0eg59y8d.js";
133
+ } from "./index-g13fb2sj.js";
133
134
  import {
134
135
  directoryHasGitMetadata,
135
136
  resolveProjectIdentityForSession,
136
137
  normalizeStoredProjectPath,
137
138
  storedPathBelongsToIdentity
138
- } from "./index-gqsfhksw.js";
139
+ } from "./index-gqxsds3q.js";
139
140
  import {
140
141
  drainBackgroundBatches,
141
142
  markProjectLoadUntrusted2,
@@ -147,7 +148,7 @@ import {
147
148
  unregisterProjectEmbedding2,
148
149
  getProjectEmbeddingSnapshot2,
149
150
  embedTextForProject2
150
- } from "./index-0d8zqccx.js";
151
+ } from "./index-qc8e13wc.js";
151
152
  import {
152
153
  getNoteByIdInScope,
153
154
  getNotes,
@@ -164,7 +165,7 @@ import {
164
165
  resolveMemoriesByIdsForSearch2,
165
166
  unifiedSearch2,
166
167
  formatSearchResults2
167
- } from "./index-8jpqq2yk.js";
168
+ } from "./index-ns319t8e.js";
168
169
  import {
169
170
  computeCueContentHash,
170
171
  getMuralCueState,
@@ -180,7 +181,7 @@ import {
180
181
  supersededMemory2,
181
182
  mergeMemoryStats2,
182
183
  archiveMemory2
183
- } from "./index-dj784nyr.js";
184
+ } from "./index-hy44m6jc.js";
184
185
  import {
185
186
  saveEmbedding,
186
187
  invalidateMemory2
@@ -189,13 +190,13 @@ import {
189
190
  isMarkerCandidateBasisCurrent2,
190
191
  invalidateMarkerCandidateBasis2,
191
192
  readMarkerCandidateBasis2
192
- } from "./index-dj8hpkz7.js";
193
+ } from "./index-729kkhmf.js";
193
194
  import {
194
195
  computeNormalizedHash
195
196
  } from "./index-9x1f96r8.js";
196
197
  import {
197
198
  logSlowWriteTransaction
198
- } from "./index-0vrkp1jq.js";
199
+ } from "./index-43zqh10z.js";
199
200
  import {
200
201
  ensureStorageDirectorySync,
201
202
  writeStorageFileAtomicSync
@@ -4212,7 +4213,7 @@ var V2_MESSAGE_PAGE_SQL = `WITH bounds AS (
4212
4213
  SELECT seq FROM session_message
4213
4214
  WHERE session_id = ? AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS})
4214
4215
  ORDER BY seq ASC LIMIT 1 OFFSET ?
4215
- ), -1) END AS after_seq,
4216
+ ), (SELECT MAX(seq) FROM session_message WHERE session_id = ?), -1) END AS after_seq,
4216
4217
  COALESCE((
4217
4218
  SELECT seq FROM session_message
4218
4219
  WHERE session_id = ? AND type IN (${RAW_MESSAGE_TYPE_PARAMETERS})
@@ -4414,7 +4415,7 @@ class V2StoreReader {
4414
4415
  }
4415
4416
  }
4416
4417
  const maximumSeq = Number.MAX_SAFE_INTEGER;
4417
- const rows = this.prepare(V2_MESSAGE_PAGE_SQL).all(afterOrdinal, sessionID, ...RAW_MESSAGE_TYPES, Math.max(0, afterOrdinal - 1), sessionID, ...RAW_MESSAGE_TYPES, finalWatermark - 1, maximumSeq, sessionID, ...RAW_MESSAGE_TYPES, pageSize);
4418
+ const rows = this.prepare(V2_MESSAGE_PAGE_SQL).all(afterOrdinal, sessionID, ...RAW_MESSAGE_TYPES, Math.max(0, afterOrdinal - 1), sessionID, sessionID, ...RAW_MESSAGE_TYPES, finalWatermark - 1, maximumSeq, sessionID, ...RAW_MESSAGE_TYPES, pageSize);
4418
4419
  return rows.map(decode);
4419
4420
  });
4420
4421
  }
@@ -11063,10 +11064,10 @@ async function probeWakePlaneCatalog() {
11063
11064
  if (!await connectionFileExists(file)) {
11064
11065
  throw new Error("subc connection is not configured");
11065
11066
  }
11066
- const client = await SubcClient.connect({
11067
+ const client = await inRootAsyncContext2(() => SubcClient.connect({
11067
11068
  connectionFile: file,
11068
11069
  handshakeTimeoutMs: WAKE_PLANE_HANDSHAKE_TIMEOUT_MS
11069
- });
11070
+ }));
11070
11071
  try {
11071
11072
  return await client.catalogList();
11072
11073
  } finally {
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./index-r56xgha8.js";
3
+ } from "./index-4pxydwvg.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./index-0h2mkab2.js";
7
7
  import {
8
8
  log2
9
- } from "./index-x3dcnxh0.js";
9
+ } from "./index-gycf3sp7.js";
10
+ import {
11
+ inRootAsyncContext2
12
+ } from "./index-asrxgdt4.js";
10
13
 
11
14
  // ../plugin/src/features/magic-context/memory/embedding-synapse.ts
12
15
  import { createHash } from "node:crypto";
@@ -1921,7 +1924,7 @@ async function getSharedClient(options) {
1921
1924
  if (sharedClientPromise && sharedClientFile === options.connectionFile)
1922
1925
  return sharedClientPromise;
1923
1926
  sharedClientFile = options.connectionFile;
1924
- sharedClientPromise = SubcClient.connect({ connectionFile: options.connectionFile }).then((client) => {
1927
+ sharedClientPromise = inRootAsyncContext2(() => SubcClient.connect({ connectionFile: options.connectionFile })).then((client) => {
1925
1928
  sharedClient = client;
1926
1929
  return client;
1927
1930
  });