@cortexkit/opencode-magic-context 0.49.103 → 0.49.105

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 (166) hide show
  1. package/dist/auto-search-worker.js +5 -5
  2. package/dist/chunk-embedding-write-worker.js +8 -5
  3. package/dist/{context-jk7bgc3s.js → context-wtnrsjkp.js} +116 -139
  4. package/dist/{embedding-backfill-anty7zdf.js → embedding-backfill-kqwx0vhj.js} +6 -6
  5. package/dist/{v2/embedding-cache-dveynq4m.js → embedding-cache-fhdkn9nc.js} +3 -1
  6. package/dist/embedding-worker.js +1 -1
  7. package/dist/features/magic-context/chunk-embedding-write-worker-install-failure.fixture.d.ts +2 -0
  8. package/dist/features/magic-context/chunk-embedding-write-worker-install-failure.fixture.d.ts.map +1 -0
  9. package/dist/features/magic-context/chunk-scope-repair-revision.d.ts +16 -1
  10. package/dist/features/magic-context/chunk-scope-repair-revision.d.ts.map +1 -1
  11. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  12. package/dist/features/magic-context/dreamer/verify-checkout.d.ts +2 -0
  13. package/dist/features/magic-context/dreamer/verify-checkout.d.ts.map +1 -0
  14. package/dist/features/magic-context/memory/embedding-cache.d.ts +1 -0
  15. package/dist/features/magic-context/memory/embedding-cache.d.ts.map +1 -1
  16. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  17. package/dist/features/magic-context/memory/embedding-worker-loop.d.ts +9 -1
  18. package/dist/features/magic-context/memory/embedding-worker-loop.d.ts.map +1 -1
  19. package/dist/features/magic-context/memory/embedding-worker-observer.fixture.d.ts +26 -0
  20. package/dist/features/magic-context/memory/embedding-worker-observer.fixture.d.ts.map +1 -0
  21. package/dist/features/magic-context/message-fts-rowid-map-startup-worker-test-support.d.ts +2 -0
  22. package/dist/features/magic-context/message-fts-rowid-map-startup-worker-test-support.d.ts.map +1 -0
  23. package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
  24. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  25. package/dist/features/magic-context/search-pool-fixture.d.ts +15 -0
  26. package/dist/features/magic-context/search-pool-fixture.d.ts.map +1 -1
  27. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  28. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  29. package/dist/hooks/magic-context/compartment-runner-types.d.ts +4 -1
  30. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  31. package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
  32. package/dist/hooks/magic-context/history-boundary-repair.d.ts +7 -2
  33. package/dist/hooks/magic-context/history-boundary-repair.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +1 -0
  35. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/transform.d.ts +1 -0
  37. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  38. package/dist/{index-3nxhxeeg.js → index-1j4q0bd6.js} +4 -4
  39. package/dist/{index-fd3hkyk1.js → index-42fsf88t.js} +1 -1
  40. package/dist/{v2/server-qbydvfev.js → index-6xg55350.js} +15 -11
  41. package/dist/{index-jjxpmypb.js → index-7z5cvfpg.js} +1 -1
  42. package/dist/{index-jg5whyrd.js → index-8vv7axxg.js} +3 -3
  43. package/dist/{index-42fg6tzz.js → index-92p5yfpp.js} +4 -4
  44. package/dist/{index-7jvc0rhh.js → index-9m2b5mwf.js} +21 -8
  45. package/dist/{index-9mxkvdtp.js → index-a3t1ck7g.js} +8 -8
  46. package/dist/{index-vhx6yph7.js → index-as8bg7eh.js} +367 -115
  47. package/dist/{index-jyj9jg9f.js → index-cxh5g5bt.js} +2 -2
  48. package/dist/{index-vegw385y.js → index-cy5fn70d.js} +89 -1
  49. package/dist/{index-4dywj733.js → index-dzb1yc9w.js} +1 -1
  50. package/dist/{index-t2h3484a.js → index-edafv9d7.js} +5 -5
  51. package/dist/{index-6t6v8prs.js → index-ff1hqh4a.js} +3 -3
  52. package/dist/{index-ke0mkz7g.js → index-g1h1efr0.js} +1 -1
  53. package/dist/{index-f455a0g3.js → index-k37h4yrb.js} +5 -3
  54. package/dist/{index-mes48s7a.js → index-mg6cwqw2.js} +220 -27
  55. package/dist/{index-nyjztqyj.js → index-p5ey52j9.js} +32 -5
  56. package/dist/{index-pw1f07vg.js → index-srpghrje.js} +1 -1
  57. package/dist/{index-4536jdzj.js → index-xzs1fxzz.js} +2 -2
  58. package/dist/{index-hyvxmz3e.js → index-y1875y4h.js} +1 -1
  59. package/dist/{index-4v50y0jr.js → index-ydevzvfs.js} +1 -1
  60. package/dist/{index-ab86c21b.js → index-zj0ra8vs.js} +1 -1
  61. package/dist/index.js +53 -62
  62. package/dist/migration-worker.js +3 -3
  63. package/dist/{project-embedding-registry-4cv7n37m.js → project-embedding-registry-0z0nd73p.js} +5 -5
  64. package/dist/raw-ordinal-warmup-worker.js +2 -2
  65. package/dist/{recomp-orchestrator-vg4cxyp7.js → recomp-orchestrator-zagjzbz5.js} +15 -15
  66. package/dist/{render-f32trg2t.js → render-vwp72qd0.js} +6 -6
  67. package/dist/{search-ygtyb91s.js → search-7e1rcqb7.js} +12 -12
  68. package/dist/{search-archive-yh6xtvrx.js → search-archive-6tr0gcf7.js} +2 -2
  69. package/dist/shared/sqlite-busy-test-support.d.ts +21 -0
  70. package/dist/shared/sqlite-busy-test-support.d.ts.map +1 -0
  71. package/dist/shared/sqlite-write-locker-test-support.d.ts +12 -0
  72. package/dist/shared/sqlite-write-locker-test-support.d.ts.map +1 -1
  73. package/dist/{storage-memory-p91f7b5h.js → storage-memory-24hsvzy8.js} +2 -2
  74. package/dist/{store-wpx314rk.js → store-4eeezg83.js} +2 -2
  75. package/dist/{store-reader-c5fwa9qx.js → store-reader-g8w2wp88.js} +1 -1
  76. package/dist/{transform-postprocess-phase-958fmjs5.js → transform-postprocess-phase-v3p3q2gf.js} +16 -16
  77. package/dist/v2/auto-search-worker.js +5 -5
  78. package/dist/v2/chunk-embedding-write-worker.js +8 -5
  79. package/dist/v2/{context-3g3jvxg8.js → context-fbdac7qt.js} +166 -150
  80. package/dist/v2/{embedding-backfill-ra9gbbs4.js → embedding-backfill-e44pv5db.js} +6 -6
  81. package/dist/{embedding-cache-dveynq4m.js → v2/embedding-cache-fhdkn9nc.js} +3 -1
  82. package/dist/v2/embedding-worker.js +1 -1
  83. package/dist/v2/event-subscription.fixture.d.ts +9 -0
  84. package/dist/v2/event-subscription.fixture.d.ts.map +1 -0
  85. package/dist/v2/hidden-model-activity.d.ts +13 -0
  86. package/dist/v2/hidden-model-activity.d.ts.map +1 -1
  87. package/dist/v2/hooks/context.d.ts +1 -0
  88. package/dist/v2/hooks/context.d.ts.map +1 -1
  89. package/dist/v2/hooks/dream-trigger.d.ts +2 -1
  90. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  91. package/dist/v2/hooks/event-subscription-worker.d.ts +11 -0
  92. package/dist/v2/hooks/event-subscription-worker.d.ts.map +1 -0
  93. package/dist/v2/hooks/types.d.ts +1 -0
  94. package/dist/v2/hooks/types.d.ts.map +1 -1
  95. package/dist/v2/hooks/update-check.d.ts +1 -0
  96. package/dist/v2/hooks/update-check.d.ts.map +1 -1
  97. package/dist/v2/{message-index-bounded-j1sxtefe.js → message-index-bounded-nwqfb1p5.js} +3 -3
  98. package/dist/v2/migration-worker.js +3 -3
  99. package/dist/v2/{project-embedding-registry-gdaqb7h0.js → project-embedding-registry-rhzjnypp.js} +5 -5
  100. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  101. package/dist/v2/{read-session-chunk-p6z3kmdj.js → read-session-chunk-brqatg83.js} +2 -2
  102. package/dist/v2/{recomp-orchestrator-29m3cc5b.js → recomp-orchestrator-1ech6k2n.js} +17 -17
  103. package/dist/v2/{render-jpj43axy.js → render-pfe3smhx.js} +10 -10
  104. package/dist/v2/{search-archive-wbhxp0p1.js → search-archive-r8krrz47.js} +5 -5
  105. package/dist/v2/{search-ybyc7vmx.js → search-sffewrs4.js} +15 -15
  106. package/dist/v2/{server-kx5egpt7.js → server-16115spd.js} +4 -4
  107. package/dist/v2/server-28jqb7s0.js +6 -0
  108. package/dist/v2/{server-qg8jyfxa.js → server-5xx10mqe.js} +1 -1
  109. package/dist/{index-qbydvfev.js → v2/server-6xg55350.js} +15 -11
  110. package/dist/v2/{server-t45hgcsg.js → server-7jw608jk.js} +2 -2
  111. package/dist/v2/{server-8f92sd2r.js → server-7pxjk184.js} +6 -4
  112. package/dist/v2/{server-3mb205v9.js → server-83rjf4df.js} +1 -1
  113. package/dist/v2/{server-df5scn4q.js → server-9t4yjj20.js} +27 -12
  114. package/dist/v2/{server-ga6y57vh.js → server-c32505fr.js} +6 -4
  115. package/dist/v2/{server-8m5wk6aq.js → server-cpb7b1f9.js} +5 -5
  116. package/dist/v2/{server-qdpd8h27.js → server-fn6k1ack.js} +1 -1
  117. package/dist/v2/{server-1qxdyz4p.js → server-ghb2q1z9.js} +2 -2
  118. package/dist/v2/{server-pqgnjf38.js → server-gkb0y83n.js} +32 -5
  119. package/dist/v2/{server-r851hxn5.js → server-hqcdvs2n.js} +13 -13
  120. package/dist/v2/{server-9ms9b75c.js → server-j00jprwm.js} +4 -6
  121. package/dist/v2/{server-xpy46ddq.js → server-jtd5vq5e.js} +3 -3
  122. package/dist/v2/{server-b01a7dhj.js → server-kk2kbzq3.js} +1 -1
  123. package/dist/v2/{server-mc5t7k8v.js → server-ma0qhqg9.js} +1 -1
  124. package/dist/v2/{server-x22jtpna.js → server-n3bfqd0j.js} +4 -2
  125. package/dist/v2/{server-fagcnt6j.js → server-pjvqyg6g.js} +367 -115
  126. package/dist/v2/{server-jrs4gny6.js → server-qtajgx1e.js} +89 -1
  127. package/dist/v2/{server-pw1f07vg.js → server-srpghrje.js} +1 -1
  128. package/dist/v2/server-t104h957.js +177 -0
  129. package/dist/v2/{server-j09jx1n9.js → server-v2r04xds.js} +1 -1
  130. package/dist/v2/{server-7c5p0bh1.js → server-z77hman6.js} +1 -1
  131. package/dist/v2/server.js +31 -40
  132. package/dist/v2/{storage-memory-p91f7b5h.js → storage-memory-24hsvzy8.js} +2 -2
  133. package/dist/v2/{storage-tags-s7nvvyg8.js → storage-tags-ee72g2zv.js} +1 -1
  134. package/dist/v2/{store-mba47sxn.js → store-9rsrj5pt.js} +2 -2
  135. package/dist/v2/{store-reader-w7w8vfsy.js → store-reader-tb0f9621.js} +1 -1
  136. package/dist/v2/store-reader.d.ts +1 -1
  137. package/dist/v2/store-reader.d.ts.map +1 -1
  138. package/dist/v2/tui/index.d.ts.map +1 -1
  139. package/dist/v2/{v2-archive-reader-5njmg3a3.js → v2-archive-reader-0xysfgxh.js} +1 -1
  140. package/dist/v2/{wrapup-orchestrator-ahkq8a61.js → wrapup-orchestrator-8d4ak3x3.js} +17 -17
  141. package/dist/{v2-archive-reader-y38khjax.js → v2-archive-reader-fac1zmhj.js} +1 -1
  142. package/dist/{wrapup-orchestrator-gjqaac65.js → wrapup-orchestrator-wz10b94c.js} +16 -16
  143. package/package.json +1 -1
  144. package/src/config/migrate-config-location.test.ts +41 -29
  145. package/src/shared/model-suggestion-retry.test.ts +137 -90
  146. package/src/shared/off-thread-migration-clock.test.ts +19 -9
  147. package/src/shared/prompt-async-transport.test.ts +125 -42
  148. package/src/shared/rpc-async-probes.test.ts +56 -36
  149. package/src/shared/rpc-client.test.ts +51 -18
  150. package/src/shared/sqlite-acquisition-routing.test.ts +79 -22
  151. package/src/shared/sqlite-busy-budget-review.test.ts +129 -111
  152. package/src/shared/sqlite-busy-test-support.ts +154 -0
  153. package/src/shared/sqlite-foreground-wait.test.ts +213 -156
  154. package/src/shared/sqlite-pass-scope.test.ts +142 -105
  155. package/src/shared/sqlite-turn-deadline.test.ts +149 -124
  156. package/src/shared/sqlite-write-locker-test-support.ts +44 -12
  157. package/src/shared/stable-json-linear.test.ts +29 -11
  158. package/src/shared/startup-maintenance-policy.test.ts +72 -2
  159. package/src/shared/storage-busy.test.ts +45 -18
  160. package/src/shared/storage-file-mutex-review.test.ts +65 -51
  161. package/src/shared/tui-preferences.test.ts +15 -5
  162. package/src/shared/worker-shutdown.test.ts +26 -20
  163. package/src/tui/data/notification-socket.test.ts +220 -108
  164. package/src/v2/tui/index.ts +5 -1
  165. package/src/v2/tui/status-dialog-fallback.test.ts +23 -1
  166. package/dist/v2/server-84w6rvvf.js +0 -14
@@ -684,14 +684,20 @@ function isEmbeddingWorkerStopNotice(message) {
684
684
  function serveEmbeddingWorker(port, model, options) {
685
685
  const now = options.now ?? (() => performance.now());
686
686
  let queue = Promise.resolve();
687
+ const requests = new Map;
687
688
  let stopping = false;
688
689
  let busySince = null;
689
690
  const refuse = (id) => port.postMessage({ id, loaded: false, error: EMBEDDING_WORKER_STOPPING_ERROR });
691
+ const acknowledgeCancel = (id) => port.postMessage({ id, loaded: false });
690
692
  const handle = async (request) => {
691
- if (stopping)
692
- return refuse(request.id);
693
- busySince = now();
693
+ const { id } = request;
694
+ const cancelled = () => requests.get(id) === true;
694
695
  try {
696
+ if (stopping)
697
+ return refuse(id);
698
+ if (cancelled())
699
+ return acknowledgeCancel(id);
700
+ busySince = now();
695
701
  const loaded = await model.initialize();
696
702
  let vectors;
697
703
  if (loaded && request.texts) {
@@ -701,19 +707,26 @@ function serveEmbeddingWorker(port, model, options) {
701
707
  await new Promise((resolve) => setImmediate(resolve));
702
708
  if (stopping)
703
709
  throw new Error(EMBEDDING_WORKER_STOPPING_ERROR);
710
+ if (cancelled())
711
+ return acknowledgeCancel(id);
704
712
  vectors.push(...await model.embedBatch(request.texts.slice(offset, offset + options.batchSize)));
705
713
  }
706
714
  }
715
+ if (cancelled())
716
+ return acknowledgeCancel(id);
707
717
  port.postMessage({
708
- id: request.id,
718
+ id,
709
719
  loaded,
710
720
  vectors,
711
721
  failure: model.getLastFailureReason(),
712
722
  stats: options.stats?.()
713
723
  }, vectors?.flatMap((vector) => vector ? [vector.buffer] : []) ?? []);
714
724
  } catch (error) {
715
- port.postMessage({ id: request.id, loaded: false, error: String(error) });
725
+ if (cancelled())
726
+ return acknowledgeCancel(id);
727
+ port.postMessage({ id, loaded: false, error: String(error) });
716
728
  } finally {
729
+ requests.delete(id);
717
730
  busySince = null;
718
731
  }
719
732
  };
@@ -743,9 +756,16 @@ function serveEmbeddingWorker(port, model, options) {
743
756
  stop();
744
757
  return;
745
758
  }
759
+ const cancel = message?.cancel;
760
+ if (typeof cancel === "number") {
761
+ if (requests.has(cancel))
762
+ requests.set(cancel, true);
763
+ return;
764
+ }
746
765
  const request = message;
747
766
  if (stopping)
748
767
  return refuse(request.id);
768
+ requests.set(request.id, false);
749
769
  queue = queue.then(() => handle(request));
750
770
  });
751
771
  }
@@ -1014,6 +1034,13 @@ class EmbeddingWorkerClient {
1014
1034
  this.pending.delete(id);
1015
1035
  signal?.removeEventListener("abort", abort);
1016
1036
  reject(new EmbeddingRequestAbortedError);
1037
+ const request = { cancel: id };
1038
+ try {
1039
+ if (worker instanceof Worker)
1040
+ worker.postMessage(request);
1041
+ else if (worker.connected)
1042
+ worker.send(request, () => {});
1043
+ } catch {}
1017
1044
  if (this.pending.size === 0) {
1018
1045
  worker.unref();
1019
1046
  if (!(worker instanceof Worker))
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  invalidateProject2,
9
9
  invalidateMemory2
10
- } from "./index-qbydvfev.js";
10
+ } from "./index-6xg55350.js";
11
11
  import {
12
12
  computeNormalizedHash
13
13
  } from "./index-2bvekkfy.js";
@@ -75,7 +75,7 @@ import {
75
75
  import {
76
76
  layoutLkgPrefix,
77
77
  assembleLkgPrefix
78
- } from "./index-hyvxmz3e.js";
78
+ } from "./index-y1875y4h.js";
79
79
  import {
80
80
  ensurePrivateStorageDirectorySync,
81
81
  writeStorageFileSync,
@@ -86,7 +86,7 @@ import {
86
86
  import {
87
87
  gaDatabasePath2,
88
88
  V2StoreReader2
89
- } from "./index-ke0mkz7g.js";
89
+ } from "./index-g1h1efr0.js";
90
90
  import {
91
91
  markHostInstructionRow,
92
92
  hostInstructionRowID,
@@ -20,7 +20,7 @@ import {
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./index-vegw385y.js";
23
+ } from "./index-cy5fn70d.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
26
  } from "./index-9awtk18w.js";
@@ -16,7 +16,7 @@ import {
16
16
  } from "./index-jsbgw33b.js";
17
17
  import {
18
18
  scheduleAfterBootQuiet
19
- } from "./index-vegw385y.js";
19
+ } from "./index-cy5fn70d.js";
20
20
  import {
21
21
  cleanSearchText,
22
22
  hintKeywordRelevance,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./index-gzy5w8ya.js";
7
7
  import {
8
8
  managedAuthorityNoteRow
9
- } from "./index-hyvxmz3e.js";
9
+ } from "./index-y1875y4h.js";
10
10
 
11
11
  // src/features/magic-context/storage-notes.ts
12
12
  var NOTE_TYPES = new Set(["session", "smart"]);
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ import {
47
47
  checkCompactionMarkerConsistency,
48
48
  clearInjectionCache,
49
49
  clearNoteNudgeTriggerOnly
50
- } from "./index-7jvc0rhh.js";
50
+ } from "./index-9m2b5mwf.js";
51
51
  import {
52
52
  withContentLanguageDirective,
53
53
  string,
@@ -147,8 +147,9 @@ import {
147
147
  createCtxSearchTools,
148
148
  parameterDescriptionsFor,
149
149
  MagicContextRpcServer,
150
- applyHiddenSubagentTemperature
151
- } from "./index-mes48s7a.js";
150
+ applyHiddenSubagentTemperature,
151
+ startEventSubscriptionWorker
152
+ } from "./index-mg6cwqw2.js";
152
153
  import {
153
154
  resolveOpenCodeDbPath,
154
155
  openCodeDbPathExists,
@@ -175,7 +176,7 @@ import {
175
176
  beginBootQuietPeriod,
176
177
  bootQuietRemainingMs,
177
178
  scheduleAfterBootQuiet
178
- } from "./index-vegw385y.js";
179
+ } from "./index-cy5fn70d.js";
179
180
  import {
180
181
  BoundedSessionMap,
181
182
  deleteTemporalDecision,
@@ -202,10 +203,10 @@ import {
202
203
  dropServedRecord,
203
204
  registerLkgPersistence,
204
205
  dropSlot
205
- } from "./index-4536jdzj.js";
206
+ } from "./index-xzs1fxzz.js";
206
207
  import {
207
208
  recordSessionProjectIdentity
208
- } from "./index-fd3hkyk1.js";
209
+ } from "./index-42fsf88t.js";
209
210
  import"./index-fb3zxn06.js";
210
211
  import {
211
212
  startBootDeadline,
@@ -216,7 +217,7 @@ import {
216
217
  openDatabaseAsync,
217
218
  isDatabasePersisted,
218
219
  getDatabasePersistenceError
219
- } from "./index-f455a0g3.js";
220
+ } from "./index-k37h4yrb.js";
220
221
  import {
221
222
  registerExitAbort,
222
223
  unregisterExitAbort
@@ -227,7 +228,7 @@ import {
227
228
  forgetRawSessionOrdinalWatermark2
228
229
  } from "./index-jsbgw33b.js";
229
230
  import"./index-geph2sa6.js";
230
- import"./index-hyvxmz3e.js";
231
+ import"./index-y1875y4h.js";
231
232
  import"./index-fr0wbhdn.js";
232
233
  import {
233
234
  preloadTokenizer,
@@ -237,7 +238,7 @@ import"./index-gcf2x04k.js";
237
238
  import {
238
239
  getDefaultSubcConnectionFile,
239
240
  SubcModuleTransport
240
- } from "./index-9mxkvdtp.js";
241
+ } from "./index-a3t1ck7g.js";
241
242
  import"./index-qt1qqasc.js";
242
243
  import"./index-y5f5yg5a.js";
243
244
  import {
@@ -314,19 +315,19 @@ import"./index-1vv1ka4a.js";
314
315
  import {
315
316
  deleteIndexedMessage
316
317
  } from "./index-p8nc9axh.js";
317
- import"./index-ke0mkz7g.js";
318
- import"./index-ab86c21b.js";
318
+ import"./index-g1h1efr0.js";
319
+ import"./index-zj0ra8vs.js";
319
320
  import {
320
321
  pushNotification2
321
322
  } from "./index-y14pawe1.js";
322
- import"./index-nyjztqyj.js";
323
+ import"./index-p5ey52j9.js";
323
324
  import {
324
325
  getEmbeddingCoverageStatus2
325
- } from "./index-vhx6yph7.js";
326
- import"./index-qbydvfev.js";
327
- import"./index-42fg6tzz.js";
328
- import"./index-jyj9jg9f.js";
329
- import"./index-pw1f07vg.js";
326
+ } from "./index-as8bg7eh.js";
327
+ import"./index-6xg55350.js";
328
+ import"./index-92p5yfpp.js";
329
+ import"./index-cxh5g5bt.js";
330
+ import"./index-srpghrje.js";
330
331
  import"./index-qxzk5s30.js";
331
332
  import {
332
333
  recordOpenCodeProvenInputFloor,
@@ -348,13 +349,13 @@ import {
348
349
  armBindingRecoverySafely,
349
350
  collectForeignTextParts,
350
351
  resetDegradedCacheCount2
351
- } from "./index-t2h3484a.js";
352
+ } from "./index-edafv9d7.js";
352
353
  import {
353
354
  scheduleClearAndReindex
354
- } from "./index-4v50y0jr.js";
355
+ } from "./index-ydevzvfs.js";
355
356
  import {
356
357
  runManagedRecomp2
357
- } from "./index-jg5whyrd.js";
358
+ } from "./index-8vv7axxg.js";
358
359
  import {
359
360
  isValidSemver,
360
361
  compareSemverCore
@@ -362,11 +363,11 @@ import {
362
363
  import"./index-fmsr7v69.js";
363
364
  import {
364
365
  runManagedWrapup2
365
- } from "./index-6t6v8prs.js";
366
+ } from "./index-ff1hqh4a.js";
366
367
  import"./index-zh683xh2.js";
367
368
  import"./index-6gd9akdt.js";
368
- import"./index-3nxhxeeg.js";
369
- import"./index-jjxpmypb.js";
369
+ import"./index-1j4q0bd6.js";
370
+ import"./index-7z5cvfpg.js";
370
371
  import {
371
372
  __toESM,
372
373
  __commonJS
@@ -8222,7 +8223,7 @@ var require_src2 = __commonJS(function(exports, module) {
8222
8223
  // package.json
8223
8224
  var package_default = {
8224
8225
  name: "@cortexkit/opencode-magic-context",
8225
- version: "0.49.103",
8226
+ version: "0.49.105",
8226
8227
  type: "module",
8227
8228
  description: "OpenCode plugin for Magic Context — cross-session memory and context management",
8228
8229
  main: "dist/index.js",
@@ -11971,7 +11972,7 @@ async function sendOpenCodeRefusal(client, sessionId, message, refusal) {
11971
11972
  sessionLog2(sessionId, "refusal notice skipped: no terminal viewing the session", refusal.name);
11972
11973
  }
11973
11974
  if (storageBusy) {
11974
- const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-958fmjs5.js"));
11975
+ const { abortSessionFailClosed } = await importPluginModule(() => import("./transform-postprocess-phase-v3p3q2gf.js"));
11975
11976
  await abortSessionFailClosed(client, sessionId);
11976
11977
  }
11977
11978
  }
@@ -12155,6 +12156,7 @@ function registerStandalonePluginMarker(version) {
12155
12156
  import { existsSync as existsSync8, readFileSync as readFileSync7 } from "node:fs";
12156
12157
  import { dirname as dirname4, join as join10 } from "node:path";
12157
12158
  import { fileURLToPath as fileURLToPath2 } from "node:url";
12159
+ var UPDATE_EVENT_TYPES = ["session.execution.succeeded"];
12158
12160
  var cachedPackageInfo;
12159
12161
  function packageInfo() {
12160
12162
  if (cachedPackageInfo)
@@ -12183,45 +12185,34 @@ function formatUpdateAvailableMessage(latest, current) {
12183
12185
  function startUpdateChecks(context, check = (signal) => {
12184
12186
  return packageInfo().development ? Promise.resolve(null) : getLatestVersion("latest", { signal });
12185
12187
  }) {
12186
- const controller = new AbortController;
12187
12188
  let lastCheckAt;
12188
12189
  let loaded = false;
12189
- const done = (async () => {
12190
- try {
12191
- for await (const _event of context.event.subscribe({ signal: controller.signal })) {
12192
- if (controller.signal.aborted)
12193
- break;
12194
- if (loaded && typeof lastCheckAt === "number" && Date.now() - lastCheckAt < 60 * 60 * 1000)
12195
- continue;
12196
- lastCheckAt = await context.storage.get("version-check-at");
12197
- loaded = true;
12198
- if (typeof lastCheckAt === "number" && Date.now() - lastCheckAt < 60 * 60 * 1000)
12199
- continue;
12200
- const now = Date.now();
12201
- await context.storage.set("version-check-at", now);
12202
- lastCheckAt = now;
12203
- const latest = await check(controller.signal);
12204
- const current = packageInfo().version;
12205
- const comparison = latest ? compareSemverCore(latest, current) : null;
12206
- if (latest && !controller.signal.aborted && comparison !== null && comparison > 0) {
12207
- pushNotification2("toast", {
12208
- message: formatUpdateAvailableMessage(latest, current),
12209
- variant: "info"
12210
- });
12211
- }
12212
- }
12213
- } catch (error) {
12214
- if (!controller.signal.aborted)
12215
- log2("[magic-context] v2 update check unavailable", error);
12216
- }
12217
- })();
12218
- return {
12219
- done,
12220
- async dispose() {
12221
- controller.abort();
12222
- await done;
12190
+ return startEventSubscriptionWorker(context.event, UPDATE_EVENT_TYPES, {
12191
+ subscriptionEnded: (error) => log2("[magic-context] v2 update event subscription ended; retrying", error),
12192
+ handlerFailed: (error) => log2("[magic-context] v2 update check unavailable", error)
12193
+ }, async (value, signal) => {
12194
+ if (value?.type !== UPDATE_EVENT_TYPES[0])
12195
+ return false;
12196
+ if (loaded && typeof lastCheckAt === "number" && Date.now() - lastCheckAt < 60 * 60 * 1000)
12197
+ return false;
12198
+ lastCheckAt = await context.storage.get("version-check-at");
12199
+ loaded = true;
12200
+ if (typeof lastCheckAt === "number" && Date.now() - lastCheckAt < 60 * 60 * 1000)
12201
+ return true;
12202
+ const now = Date.now();
12203
+ await context.storage.set("version-check-at", now);
12204
+ lastCheckAt = now;
12205
+ const latest = await check(signal);
12206
+ const current = packageInfo().version;
12207
+ const comparison = latest ? compareSemverCore(latest, current) : null;
12208
+ if (latest && !signal.aborted && comparison !== null && comparison > 0) {
12209
+ pushNotification2("toast", {
12210
+ message: formatUpdateAvailableMessage(latest, current),
12211
+ variant: "info"
12212
+ });
12223
12213
  }
12224
- };
12214
+ return true;
12215
+ });
12225
12216
  }
12226
12217
 
12227
12218
  // src/v2/server.ts
@@ -12241,7 +12232,7 @@ async function setup(context) {
12241
12232
  if (claimStorageBackupWarningCheck() && isMagicContextStorageOutsideEngram(storageDir)) {
12242
12233
  log2(`[magic-context] Magic Context storage is at ${storageDir}, outside the folder Engram backs up (~/.local/share/cortexkit/magic-context). It is not included in CortexKit backups.`);
12243
12234
  }
12244
- const { registerContext } = await import("./context-jk7bgc3s.js");
12235
+ const { registerContext } = await import("./context-wtnrsjkp.js");
12245
12236
  setHarness2("opencode2");
12246
12237
  bindStaleBuildNotice({}, import.meta.url, "opencode2");
12247
12238
  const duties = await registerContext(context);
@@ -9,17 +9,17 @@ import {
9
9
  import"./index-fr0wbhdn.js";
10
10
  import {
11
11
  runMigrationsWithRetry
12
- } from "./index-hyvxmz3e.js";
12
+ } from "./index-y1875y4h.js";
13
13
  import"./index-xtv4d4hv.js";
14
14
  import"./index-58e3y90n.js";
15
15
  import"./index-abhmtj00.js";
16
16
  import"./index-t7st85f5.js";
17
- import"./index-vegw385y.js";
17
+ import"./index-cy5fn70d.js";
18
18
  import"./index-fb3zxn06.js";
19
19
  import {
20
20
  setSqlitePragmaConfig,
21
21
  initializeDatabase
22
- } from "./index-f455a0g3.js";
22
+ } from "./index-k37h4yrb.js";
23
23
  import"./index-8k9qpyjf.js";
24
24
  import"./index-v0p37hm2.js";
25
25
  import"./index-96ztjvkn.js";
@@ -39,16 +39,16 @@ import {
39
39
  sweepAllRegisteredProjects2,
40
40
  _setTestProviderFactoryForProject2,
41
41
  _resetProjectEmbeddingRegistryForTests2
42
- } from "./index-vhx6yph7.js";
43
- import"./index-qbydvfev.js";
42
+ } from "./index-as8bg7eh.js";
43
+ import"./index-6xg55350.js";
44
44
  import"./index-2amn2s73.js";
45
45
  import"./index-qt1qqasc.js";
46
- import"./index-nyjztqyj.js";
46
+ import"./index-p5ey52j9.js";
47
47
  import"./index-r3f85n7y.js";
48
- import"./index-fd3hkyk1.js";
48
+ import"./index-42fsf88t.js";
49
49
  import"./index-1vv1ka4a.js";
50
50
  import"./index-gcf2x04k.js";
51
- import"./index-vegw385y.js";
51
+ import"./index-cy5fn70d.js";
52
52
  import"./index-geph2sa6.js";
53
53
  import"./index-jsbgw33b.js";
54
54
  import"./index-96ztjvkn.js";
@@ -19,7 +19,7 @@ serveWorkerJobs(async (input, port) => {
19
19
  await main();
20
20
  async function main() {
21
21
  if (input.v2ArchiveReader) {
22
- const { serveV2ArchiveReads } = await import("./v2-archive-reader-y38khjax.js");
22
+ const { serveV2ArchiveReads } = await import("./v2-archive-reader-fac1zmhj.js");
23
23
  await serveV2ArchiveReads(port, openConnections);
24
24
  return;
25
25
  }
@@ -51,7 +51,7 @@ serveWorkerJobs(async (input, port) => {
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-yh6xtvrx.js");
54
+ const { renderSearchArchive } = await import("./search-archive-6tr0gcf7.js");
55
55
  const { readRawSessionMessageIdOrdinalsForRangeFromDb } = await import("./read-session-raw-pgc9gxtn.js");
56
56
  const archive = input.searchArchive;
57
57
  let raw;
@@ -7,20 +7,20 @@ import {
7
7
  setRecompTerminal2,
8
8
  buildRecompDeps2,
9
9
  runManagedRecomp2
10
- } from "./index-jg5whyrd.js";
11
- import"./index-7jvc0rhh.js";
10
+ } from "./index-8vv7axxg.js";
11
+ import"./index-9m2b5mwf.js";
12
12
  import"./index-qxzk5s30.js";
13
13
  import"./index-sd3egckz.js";
14
- import"./index-42fg6tzz.js";
15
- import"./index-jyj9jg9f.js";
16
- import"./index-pw1f07vg.js";
17
- import"./index-vhx6yph7.js";
18
- import"./index-qbydvfev.js";
19
- import"./index-4536jdzj.js";
20
- import"./index-ab86c21b.js";
14
+ import"./index-92p5yfpp.js";
15
+ import"./index-cxh5g5bt.js";
16
+ import"./index-srpghrje.js";
17
+ import"./index-as8bg7eh.js";
18
+ import"./index-6xg55350.js";
19
+ import"./index-xzs1fxzz.js";
20
+ import"./index-zj0ra8vs.js";
21
21
  import"./index-p8nc9axh.js";
22
22
  import"./index-2amn2s73.js";
23
- import"./index-ke0mkz7g.js";
23
+ import"./index-g1h1efr0.js";
24
24
  import"./index-h1qh9n8b.js";
25
25
  import"./index-fqth7850.js";
26
26
  import"./index-61a853ky.js";
@@ -31,16 +31,16 @@ import"./index-1zx87sdm.js";
31
31
  import"./index-vdzd98ry.js";
32
32
  import"./index-y14pawe1.js";
33
33
  import"./index-y5f5yg5a.js";
34
- import"./index-nyjztqyj.js";
34
+ import"./index-p5ey52j9.js";
35
35
  import"./index-r3f85n7y.js";
36
- import"./index-fd3hkyk1.js";
36
+ import"./index-42fsf88t.js";
37
37
  import"./index-1vv1ka4a.js";
38
38
  import"./index-gcf2x04k.js";
39
- import"./index-f455a0g3.js";
39
+ import"./index-k37h4yrb.js";
40
40
  import"./index-fb3zxn06.js";
41
- import"./index-hyvxmz3e.js";
41
+ import"./index-y1875y4h.js";
42
42
  import"./index-fr0wbhdn.js";
43
- import"./index-vegw385y.js";
43
+ import"./index-cy5fn70d.js";
44
44
  import"./index-geph2sa6.js";
45
45
  import"./index-8k9qpyjf.js";
46
46
  import"./index-xtv4d4hv.js";
@@ -3,11 +3,11 @@ import {
3
3
  renderVerboseRangeForTool2,
4
4
  renderItemByTag2
5
5
  } from "./index-zh683xh2.js";
6
- import"./index-4536jdzj.js";
7
- import"./index-ab86c21b.js";
6
+ import"./index-xzs1fxzz.js";
7
+ import"./index-zj0ra8vs.js";
8
8
  import"./index-p8nc9axh.js";
9
9
  import"./index-2amn2s73.js";
10
- import"./index-ke0mkz7g.js";
10
+ import"./index-g1h1efr0.js";
11
11
  import"./index-9jqaha1g.js";
12
12
  import"./index-qzfz2tvk.js";
13
13
  import"./index-1zx87sdm.js";
@@ -15,11 +15,11 @@ import"./index-vdzd98ry.js";
15
15
  import"./index-r3f85n7y.js";
16
16
  import"./index-1vv1ka4a.js";
17
17
  import"./index-gcf2x04k.js";
18
- import"./index-f455a0g3.js";
18
+ import"./index-k37h4yrb.js";
19
19
  import"./index-fb3zxn06.js";
20
- import"./index-hyvxmz3e.js";
20
+ import"./index-y1875y4h.js";
21
21
  import"./index-fr0wbhdn.js";
22
- import"./index-vegw385y.js";
22
+ import"./index-cy5fn70d.js";
23
23
  import"./index-geph2sa6.js";
24
24
  import"./index-8k9qpyjf.js";
25
25
  import"./index-xtv4d4hv.js";
@@ -5,15 +5,15 @@ import {
5
5
  resolveMemoriesByIdsForSearch2,
6
6
  unifiedSearch2,
7
7
  formatSearchResults2
8
- } from "./index-9mxkvdtp.js";
9
- import"./index-4v50y0jr.js";
8
+ } from "./index-a3t1ck7g.js";
9
+ import"./index-ydevzvfs.js";
10
10
  import"./index-6gd9akdt.js";
11
- import"./index-42fg6tzz.js";
12
- import"./index-jyj9jg9f.js";
13
- import"./index-pw1f07vg.js";
14
- import"./index-vhx6yph7.js";
15
- import"./index-qbydvfev.js";
16
- import"./index-ab86c21b.js";
11
+ import"./index-92p5yfpp.js";
12
+ import"./index-cxh5g5bt.js";
13
+ import"./index-srpghrje.js";
14
+ import"./index-as8bg7eh.js";
15
+ import"./index-6xg55350.js";
16
+ import"./index-zj0ra8vs.js";
17
17
  import"./index-p8nc9axh.js";
18
18
  import"./index-2amn2s73.js";
19
19
  import"./index-qt1qqasc.js";
@@ -21,14 +21,14 @@ import"./index-9jqaha1g.js";
21
21
  import"./index-qzfz2tvk.js";
22
22
  import"./index-1zx87sdm.js";
23
23
  import"./index-vdzd98ry.js";
24
- import"./index-nyjztqyj.js";
24
+ import"./index-p5ey52j9.js";
25
25
  import"./index-r3f85n7y.js";
26
- import"./index-fd3hkyk1.js";
26
+ import"./index-42fsf88t.js";
27
27
  import"./index-1vv1ka4a.js";
28
28
  import"./index-gcf2x04k.js";
29
- import"./index-hyvxmz3e.js";
29
+ import"./index-y1875y4h.js";
30
30
  import"./index-fr0wbhdn.js";
31
- import"./index-vegw385y.js";
31
+ import"./index-cy5fn70d.js";
32
32
  import"./index-geph2sa6.js";
33
33
  import"./index-xtv4d4hv.js";
34
34
  import"./index-jsbgw33b.js";
@@ -2,8 +2,8 @@ import {
2
2
  unresolvedLiveTailRefusal2,
3
3
  renderSearchArchive2,
4
4
  renderSearchArchiveOffThread2
5
- } from "./index-jjxpmypb.js";
6
- import"./index-3nxhxeeg.js";
5
+ } from "./index-7z5cvfpg.js";
6
+ import"./index-1j4q0bd6.js";
7
7
  import"./index-6gd9akdt.js";
8
8
  import"./index-9jqaha1g.js";
9
9
  import"./index-qzfz2tvk.js";
@@ -0,0 +1,21 @@
1
+ import { Database as NativeDatabase } from "bun:sqlite";
2
+ type Method = "exec" | "prepare" | "run" | "get" | "all" | "values" | "iterate.next";
3
+ /**
4
+ * Install before opening the connection: the router captures the native methods
5
+ * when it opens. Match only the SQL under test. Each matched native call sees a
6
+ * zero timeout so the real lock can return BUSY immediately; `timeouts` records
7
+ * the policy value before that change. Restore the spy after closing the fixture.
8
+ */
9
+ export declare function observeSqliteBusy(matches: (sql: string, method: Method, db: NativeDatabase) => boolean, onAttempt?: (timeout: number, sql: string) => void, onBusy?: (timeout: number, sql: string) => void): {
10
+ timeouts: number[];
11
+ errors: unknown[];
12
+ restore(): void;
13
+ };
14
+ /** Freeze the monotonic clock and advance retry timers one boundary at a time. */
15
+ export declare function startSqliteRetryClock(onSchedule?: (delay: number) => void): {
16
+ elapse(ms: number): void;
17
+ advance(ms: number): Promise<void>;
18
+ restore(): void;
19
+ };
20
+ export {};
21
+ //# sourceMappingURL=sqlite-busy-test-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sqlite-busy-test-support.d.ts","sourceRoot":"","sources":["../../src/shared/sqlite-busy-test-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAyB,MAAM,YAAY,CAAC;AAE/E,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,cAAc,CAAC;AAErF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC7B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,KAAK,OAAO,EACrE,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,EAClD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI;;;;EAqFlD;AAED,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;eAiCvD,MAAM;gBAGC,MAAM;;EAgB/B"}
@@ -2,6 +2,18 @@ export interface SqliteWriteLocker {
2
2
  /** Resolves with the locker's exit code after it has committed and exited. */
3
3
  exited: Promise<number>;
4
4
  }
5
+ type Lock = "write" | "exclusive" | {
6
+ read: string;
7
+ };
5
8
  /** Start the locker and resolve once it reports that it holds the write lock. */
6
9
  export declare function startSqliteWriteLocker(dbPath: string, holdMs: number): Promise<SqliteWriteLocker>;
10
+ /** Keep the lock until release(); an exit code of zero confirms the commit. */
11
+ export declare function startGatedSqliteWriteLocker(dbPath: string, holdMs?: number): Promise<SqliteWriteLocker & {
12
+ release: () => void;
13
+ }>;
14
+ /** Use an exclusive lock to block reads, or a read transaction to block COMMIT in DELETE mode. */
15
+ export declare function startGatedSqliteLocker(dbPath: string, lock: Lock): Promise<SqliteWriteLocker & {
16
+ release: () => void;
17
+ }>;
18
+ export {};
7
19
  //# sourceMappingURL=sqlite-write-locker-test-support.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-write-locker-test-support.d.ts","sourceRoot":"","sources":["../../src/shared/sqlite-write-locker-test-support.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,iBAAiB;IAC9B,8EAA8E;IAC9E,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,iFAAiF;AACjF,wBAAsB,sBAAsB,CACxC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,iBAAiB,CAAC,CAmB5B"}
1
+ {"version":3,"file":"sqlite-write-locker-test-support.d.ts","sourceRoot":"","sources":["../../src/shared/sqlite-write-locker-test-support.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,iBAAiB;IAC9B,8EAA8E;IAC9E,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,KAAK,IAAI,GAAG,OAAO,GAAG,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAuCrD,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAEjG;AAED,+EAA+E;AAC/E,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,SAAI;aAtC5B,MAAM,IAAI;GAwCnD;AAED,kGAAkG;AAClG,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;aA3CvB,MAAM,IAAI;GA6CnD"}
@@ -31,8 +31,8 @@ import {
31
31
  deleteMemory2,
32
32
  getMemoryCount2,
33
33
  getMemoryCountsByStatus2
34
- } from "./index-pw1f07vg.js";
35
- import"./index-qbydvfev.js";
34
+ } from "./index-srpghrje.js";
35
+ import"./index-6xg55350.js";
36
36
  import"./index-fr0wbhdn.js";
37
37
  import"./index-gzy5w8ya.js";
38
38
  export {
@@ -8,8 +8,8 @@ import {
8
8
  readV2RawMessagePagesForConversion2,
9
9
  createV2RawMessageReader2,
10
10
  createV2RawMessageProvider2
11
- } from "./index-4dywj733.js";
12
- import"./index-ke0mkz7g.js";
11
+ } from "./index-dzb1yc9w.js";
12
+ import"./index-g1h1efr0.js";
13
13
  import"./index-8k9qpyjf.js";
14
14
  import"./index-58e3y90n.js";
15
15
  import"./index-2m3t73wk.js";