@cortexkit/pi-magic-context 0.49.7 → 0.49.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/auto-search-worker.js +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 +1 -1
  8. package/dist/{index-fhv6ydkq.js → index-18qe4gs1.js} +18 -11
  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-6vjj0555.js → index-54r5vs9w.js} +4 -4
  14. package/dist/{index-8ye22z7k.js → index-6e3yv1jt.js} +4 -4
  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-7ptxvfc5.js → index-asrxgdt4.js} +33 -10
  18. package/dist/{index-34zacc0h.js → index-fdxzpnbj.js} +2 -2
  19. package/dist/{index-gqsfhksw.js → index-gqxsds3q.js} +6 -3
  20. package/dist/{index-x3dcnxh0.js → index-gycf3sp7.js} +5 -1
  21. package/dist/{index-dj784nyr.js → index-hy44m6jc.js} +1 -1
  22. package/dist/{index-mrsarsbh.js → index-jsyjxgfy.js} +25 -24
  23. package/dist/{index-290tzwp1.js → index-kh3jt7t9.js} +1 -1
  24. package/dist/{index-8jpqq2yk.js → index-pdhbj18g.js} +14 -13
  25. package/dist/{index-0d8zqccx.js → index-qc8e13wc.js} +22 -22
  26. package/dist/{index-0eg59y8d.js → index-r8cy8hmq.js} +5 -5
  27. package/dist/{index-6q5mx0cz.js → index-rggtvnbg.js} +38 -28
  28. package/dist/{index-21v1kfs7.js → index-szh001qb.js} +6 -3
  29. package/dist/{index-cyrnv16r.js → index-ta0ed2nc.js} +2 -0
  30. package/dist/{index-0ww9cgfd.js → index-tdhppxwd.js} +9 -9
  31. package/dist/{index-a7fj661j.js → index-v26j81w6.js} +5 -5
  32. package/dist/{index-mcgehvgw.js → index-zzn7qbps.js} +1 -1
  33. package/dist/index.js +109 -86
  34. package/dist/{logger-j6tecd1h.js → logger-qg51hmp7.js} +1 -1
  35. package/dist/{message-index-8rxj3cxh.js → message-index-1wta074c.js} +14 -14
  36. package/dist/{message-index-bounded-e5bv8gzm.js → message-index-bounded-ss3ctdwb.js} +14 -14
  37. package/dist/{message-time-backfill-hmekd2jj.js → message-time-backfill-q9s88zdv.js} +3 -3
  38. package/dist/migration-worker.js +10 -10
  39. package/dist/{project-embedding-registry-z5m4eh3d.js → project-embedding-registry-bxawck58.js} +11 -11
  40. package/dist/raw-ordinal-warmup-worker.js +6 -6
  41. package/dist/{read-session-chunk-sp5adk01.js → read-session-chunk-1jagnq05.js} +9 -9
  42. package/dist/{read-session-raw-s14c7nf3.js → read-session-raw-hm7ptnrh.js} +3 -3
  43. package/dist/{safe-notification-target-vn9kpmv4.js → safe-notification-target-62ty6rvp.js} +2 -2
  44. package/dist/{search-hgfaqytc.js → search-x7cachq0.js} +21 -21
  45. package/dist/{sqlite-f8kh2n10.js → sqlite-adjpy399.js} +3 -1
  46. package/dist/{storage-memory-yf7r98vz.js → storage-memory-axnsk5t1.js} +2 -2
  47. package/dist/{storage-tags-0xk95neb.js → storage-tags-6j5s2q49.js} +5 -5
  48. package/dist/subagent-entry.js +24 -24
  49. package/package.json +1 -1
  50. package/dist/embedding-backfill-vygvr2x4.js +0 -20
@@ -18,15 +18,15 @@ var [
18
18
  { Database, registerSqliteDiagnosticSink },
19
19
  { log }
20
20
  ] = await Promise.all([
21
- import("./embedding-backfill-vygvr2x4.js"),
21
+ import("./embedding-backfill-chva00z3.js"),
22
22
  import("./embedding-cache-7rp4gqzr.js"),
23
- import("./storage-memory-yf7r98vz.js"),
24
- import("./project-embedding-registry-z5m4eh3d.js"),
25
- import("./search-hgfaqytc.js"),
23
+ import("./storage-memory-axnsk5t1.js"),
24
+ import("./project-embedding-registry-bxawck58.js"),
25
+ import("./search-x7cachq0.js"),
26
26
  import("./embedding-activity-ew6dshfd.js"),
27
27
  import("./harness-9872e0ym.js"),
28
- import("./sqlite-f8kh2n10.js"),
29
- import("./logger-j6tecd1h.js")
28
+ import("./sqlite-adjpy399.js"),
29
+ import("./logger-qg51hmp7.js")
30
30
  ]);
31
31
  setHarness(input.harness);
32
32
  registerSqliteDiagnosticSink(log, getHarness);
@@ -4,10 +4,10 @@ import {
4
4
  readMarkerCandidateBasis2,
5
5
  prepareMarkerCandidateBasis2,
6
6
  scanMarkerCandidateSnapshot2
7
- } from "./index-dj8hpkz7.js";
7
+ } from "./index-729kkhmf.js";
8
8
  import"./index-399p688g.js";
9
- import"./index-7ptxvfc5.js";
10
- import"./index-x3dcnxh0.js";
9
+ import"./index-asrxgdt4.js";
10
+ import"./index-gycf3sp7.js";
11
11
  import"./index-0h2mkab2.js";
12
12
  export {
13
13
  invalidateMarkerCandidateBasis2 as invalidateMarkerCandidateBasis,
@@ -5,8 +5,8 @@ if (!port)
5
5
  throw new Error("marker candidate worker requires a parent port");
6
6
  port.postMessage({ kind: "accepted" });
7
7
  var [{ Database }, { scanMarkerCandidateSnapshot }] = await Promise.all([
8
- import("./sqlite-f8kh2n10.js"),
9
- import("./compaction-marker-candidates-tqcq5n00.js")
8
+ import("./sqlite-adjpy399.js"),
9
+ import("./compaction-marker-candidates-n4dphyz4.js")
10
10
  ]);
11
11
  var input = workerData;
12
12
  var db;
@@ -0,0 +1,20 @@
1
+ import {
2
+ ensureMemoryEmbeddings2
3
+ } from "./index-v26j81w6.js";
4
+ import"./index-qc8e13wc.js";
5
+ import"./index-9p40dgkm.js";
6
+ import"./index-6e3yv1jt.js";
7
+ import"./index-yhzhdp3m.js";
8
+ import"./index-8yjhda46.js";
9
+ import"./index-szh001qb.js";
10
+ import"./index-ta0ed2nc.js";
11
+ import"./index-gqxsds3q.js";
12
+ import"./index-fdxzpnbj.js";
13
+ import"./index-43zqh10z.js";
14
+ import"./index-4pxydwvg.js";
15
+ import"./index-asrxgdt4.js";
16
+ import"./index-gycf3sp7.js";
17
+ import"./index-0h2mkab2.js";
18
+ export {
19
+ ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
20
+ };
@@ -1,14 +1,18 @@
1
1
  import"./index-0h2mkab2.js";
2
2
  import {
3
3
  log2
4
- } from "./index-x3dcnxh0.js";
4
+ } from "./index-gycf3sp7.js";
5
+ import {
6
+ inRootAsyncContext2
7
+ } from "./index-asrxgdt4.js";
5
8
 
6
9
  // ../plugin/src/features/magic-context/memory/embedding-worker-process.ts
7
10
  import { Worker } from "node:worker_threads";
8
11
  var worker;
9
12
  process.on("message", (message) => {
10
13
  if (message.entry && !worker) {
11
- worker = new Worker(new URL(message.entry), { workerData: message.data });
14
+ const entry = new URL(message.entry);
15
+ worker = inRootAsyncContext2(() => new Worker(entry, { workerData: message.data }));
12
16
  worker.on("message", (reply) => {
13
17
  const wire = {
14
18
  ...reply,
@@ -3,15 +3,16 @@ import {
3
3
  } from "./index-0h2mkab2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-x3dcnxh0.js";
7
- import"./index-cyrnv16r.js";
8
- import"./index-21v1kfs7.js";
9
- import"./index-r56xgha8.js";
6
+ } from "./index-gycf3sp7.js";
7
+ import"./index-ta0ed2nc.js";
8
+ import"./index-szh001qb.js";
9
+ import"./index-4pxydwvg.js";
10
+ import"./index-asrxgdt4.js";
10
11
  import {
11
12
  resolveLocalEmbeddingWorkerRuntime,
12
13
  getLocalEmbeddingNativeMemoryStats,
13
14
  LocalEmbeddingProvider
14
- } from "./index-gc2749rx.js";
15
+ } from "./index-8yjhda46.js";
15
16
  import {
16
17
  setStoragePrivatePermissionEnforcement
17
18
  } from "./index-81nthk8j.js";
@@ -4,7 +4,7 @@ import {
4
4
  readHostSystemPrompt
5
5
  } from "./index-zh1jw8qp.js";
6
6
  import"./index-0h2mkab2.js";
7
- import"./index-x3dcnxh0.js";
7
+ import"./index-gycf3sp7.js";
8
8
 
9
9
  // src/historian-calibration-extension.ts
10
10
  import { readFileSync } from "node:fs";
@@ -4,7 +4,7 @@ import {
4
4
  renderToolTemplate,
5
5
  resolveModelConfigValue,
6
6
  deriveDefaultProtectedTokens
7
- } from "./index-cyrnv16r.js";
7
+ } from "./index-ta0ed2nc.js";
8
8
  import {
9
9
  getHarness2,
10
10
  harnessOwnsOpenCodeStore2
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  log2,
14
14
  sessionLog2
15
- } from "./index-x3dcnxh0.js";
15
+ } from "./index-gycf3sp7.js";
16
16
  import {
17
17
  resolveDecisionCalibration,
18
18
  calibrationForModelKey,
@@ -21,7 +21,7 @@ import {
21
21
  TAG_SELECT_COLUMNS2,
22
22
  getCandidateToolOwners2,
23
23
  pickNearestPriorOwner2
24
- } from "./index-6vjj0555.js";
24
+ } from "./index-54r5vs9w.js";
25
25
  import {
26
26
  OMO_INTERNAL_INITIATOR_MARKER,
27
27
  isSystemDirective,
@@ -36,15 +36,15 @@ import {
36
36
  formatBlock,
37
37
  compactTextForSummary,
38
38
  mergeCommitHashes
39
- } from "./index-r56xgha8.js";
39
+ } from "./index-4pxydwvg.js";
40
40
  import {
41
41
  Database2,
42
42
  prepareCachedStatement2
43
- } from "./index-7ptxvfc5.js";
43
+ } from "./index-asrxgdt4.js";
44
44
  import {
45
45
  stableStringify,
46
46
  closeQuietly
47
- } from "./index-mcgehvgw.js";
47
+ } from "./index-zzn7qbps.js";
48
48
  import {
49
49
  resolveOpenCodeDbPath,
50
50
  assertOpenCodeStoreGeneration,
@@ -69,10 +69,10 @@ import {
69
69
  hasRawSessionMessageByIdFromDb2,
70
70
  readRawSeedTailFromDb2,
71
71
  readRawSessionBoundaryEndpointsFromDb2
72
- } from "./index-7mm27xdc.js";
72
+ } from "./index-4vj37yw9.js";
73
73
  import {
74
74
  logSlowWriteTransaction
75
- } from "./index-0vrkp1jq.js";
75
+ } from "./index-43zqh10z.js";
76
76
 
77
77
  // ../plugin/src/features/magic-context/overflow-detection.ts
78
78
  var OVERFLOW_PATTERNS = [
@@ -4546,13 +4546,20 @@ function readRawSessionMessageOrdinalById2(sessionId, messageId) {
4546
4546
  return null;
4547
4547
  return withReadOnlySessionDb((db) => readRawSessionMessageOrdinalByIdFromDb2(db, sessionId, messageId));
4548
4548
  }
4549
+ function readRawSessionMessageOrderPosition(sessionId, messageId) {
4550
+ const provider = sessionProviders.get(sessionId)?.provider;
4551
+ if (provider) {
4552
+ return provider.readMessageOrderById ? provider.readMessageOrderById(messageId) : provider.readMessageOrdinalById?.(messageId) ?? null;
4553
+ }
4554
+ return readRawSessionMessageOrdinalById2(sessionId, messageId);
4555
+ }
4549
4556
  function compareRawSessionMessageOrder2(sessionId, leftId, rightId) {
4550
4557
  const provider = sessionProviders.get(sessionId)?.provider;
4551
4558
  if (provider) {
4552
- if (!provider.readMessageOrdinalById)
4559
+ if (!provider.readMessageOrderById && !provider.readMessageOrdinalById)
4553
4560
  return null;
4554
- const left = provider.readMessageOrdinalById(leftId);
4555
- const right = provider.readMessageOrdinalById(rightId);
4561
+ const left = readRawSessionMessageOrderPosition(sessionId, leftId);
4562
+ const right = readRawSessionMessageOrderPosition(sessionId, rightId);
4556
4563
  return left === null || right === null ? null : left - right;
4557
4564
  }
4558
4565
  if (!openCodeDbExists())
@@ -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/rpc-utils.ts
6
6
  import { execFile, execFileSync } from "node:child_process";
@@ -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/write-transaction-timing.ts
6
6
  var SLOW_WRITE_TRANSACTION_THRESHOLD_MS = 1000;
@@ -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/hooks/magic-context/read-session-formatting.ts
6
6
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
@@ -1,13 +1,14 @@
1
1
  import {
2
+ inRootAsyncContext2,
2
3
  getSqliteDatabasePath2,
3
4
  releaseIndexOwner2
4
- } from "./index-7ptxvfc5.js";
5
+ } from "./index-asrxgdt4.js";
5
6
  import {
6
7
  registerExitAbort
7
8
  } from "./index-399p688g.js";
8
9
  import {
9
10
  log2
10
- } from "./index-x3dcnxh0.js";
11
+ } from "./index-gycf3sp7.js";
11
12
 
12
13
  // ../plugin/src/hooks/magic-context/read-session-raw.ts
13
14
  import { isMainThread } from "node:worker_threads";
@@ -69,7 +70,7 @@ function runSessionWarmupWorker(input, options) {
69
70
  deadline.unref?.();
70
71
  };
71
72
  try {
72
- worker = new Worker(options.entry ?? defaultEntry(), { workerData: input });
73
+ worker = inRootAsyncContext2(() => new Worker(options.entry ?? defaultEntry(), { workerData: input }));
73
74
  } catch (error) {
74
75
  finish({ failure: "start-failed", detail: String(error) });
75
76
  return;
@@ -1,20 +1,20 @@
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
  sessionLog2
9
- } from "./index-x3dcnxh0.js";
9
+ } from "./index-gycf3sp7.js";
10
10
  import {
11
11
  getTagIdentityWriteGeneration2,
12
12
  getSqliteDatabasePath2
13
- } from "./index-7ptxvfc5.js";
13
+ } from "./index-asrxgdt4.js";
14
14
  import {
15
15
  tagOrderConstraintIndex,
16
16
  tagIdentityRevisionKey
17
- } from "./index-mcgehvgw.js";
17
+ } from "./index-zzn7qbps.js";
18
18
  import {
19
19
  DEFAULT_PROTECTED_TOOLS,
20
20
  normalizeProtectedToolName,
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  getTokenEstimatorFingerprint,
3
3
  estimateTokens
4
- } from "./index-r56xgha8.js";
4
+ } from "./index-4pxydwvg.js";
5
5
  import {
6
6
  getHarness2
7
7
  } from "./index-0h2mkab2.js";
8
8
  import {
9
9
  log2
10
- } from "./index-x3dcnxh0.js";
10
+ } from "./index-gycf3sp7.js";
11
11
  import {
12
12
  isSynapseEmbeddingTruncated
13
- } from "./index-21v1kfs7.js";
13
+ } from "./index-szh001qb.js";
14
14
  import {
15
15
  messageFtsOrdinalRangeIsMapped
16
- } from "./index-34zacc0h.js";
16
+ } from "./index-fdxzpnbj.js";
17
17
 
18
18
  // ../plugin/src/features/magic-context/compartment-chunk-embedding.ts
19
19
  import { createHash } from "node:crypto";
@@ -3,10 +3,11 @@ import {
3
3
  } from "./index-399p688g.js";
4
4
  import {
5
5
  log2
6
- } from "./index-x3dcnxh0.js";
6
+ } from "./index-gycf3sp7.js";
7
7
  import {
8
+ inRootAsyncContext2,
8
9
  getSqliteDatabasePath2
9
- } from "./index-7ptxvfc5.js";
10
+ } from "./index-asrxgdt4.js";
10
11
 
11
12
  // ../plugin/src/features/magic-context/compaction-marker-candidates.ts
12
13
  import { existsSync, realpathSync } from "node:fs";
@@ -152,7 +153,7 @@ function runCandidateWorker(path, sessionId, options) {
152
153
  timer.unref?.();
153
154
  };
154
155
  try {
155
- worker = new Worker(entry, { workerData: { path, sessionId } });
156
+ worker = inRootAsyncContext2(() => new Worker(entry, { workerData: { path, sessionId } }));
156
157
  workers.add(worker);
157
158
  worker.unref();
158
159
  deadline(options.acceptMs ?? 2000);
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./index-cyrnv16r.js";
3
+ } from "./index-ta0ed2nc.js";
4
4
  import {
5
5
  getSynapseLaneIdentity
6
- } from "./index-21v1kfs7.js";
6
+ } from "./index-szh001qb.js";
7
7
  import {
8
8
  getHarness2
9
9
  } from "./index-0h2mkab2.js";
@@ -11,7 +11,10 @@ import {
11
11
  getMagicContextStorageDir,
12
12
  importPluginModule,
13
13
  log2
14
- } from "./index-x3dcnxh0.js";
14
+ } from "./index-gycf3sp7.js";
15
+ import {
16
+ inRootAsyncContext2
17
+ } from "./index-asrxgdt4.js";
15
18
  import {
16
19
  computeNormalizedHash
17
20
  } from "./index-9x1f96r8.js";
@@ -307,7 +310,7 @@ class EmbeddingWorkerClient {
307
310
  start() {
308
311
  if (this.startPromise)
309
312
  return this.startPromise;
310
- this.startPromise = this.startOwner().finally(() => {
313
+ this.startPromise = inRootAsyncContext2(() => this.startOwner()).finally(() => {
311
314
  this.startPromise = null;
312
315
  });
313
316
  return this.startPromise;
@@ -556,10 +559,10 @@ async function acquireModelLoadLock(lockPath) {
556
559
  }
557
560
  function startLockHeartbeat(lockPath) {
558
561
  const HEARTBEAT_MS = Math.floor(STALE_LOCK_MS / 3);
559
- const timer = setInterval(() => {
562
+ const timer = inRootAsyncContext2(() => setInterval(() => {
560
563
  writeStorageFileAsync(lockPath, `pid=${process.pid} alive=${Date.now()}
561
564
  `).catch(() => {});
562
- }, HEARTBEAT_MS);
565
+ }, HEARTBEAT_MS));
563
566
  timer.unref?.();
564
567
  return () => clearInterval(timer);
565
568
  }
@@ -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";
@@ -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}`
@@ -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";