@cortexkit/opencode-magic-context 0.49.19 → 0.49.21

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 (323) hide show
  1. package/dist/auto-search-worker.js +48 -9
  2. package/dist/chunk-embedding-write-worker.js +30 -23
  3. package/dist/{compaction-marker-candidates-n4krhat4.js → compaction-marker-candidates-31h86ph0.js} +3 -3
  4. package/dist/compaction-marker-candidates-worker.js +2 -2
  5. package/dist/compartment-chunk-embedding-he60aaa2.js +65 -0
  6. package/dist/config/project-security.d.ts.map +1 -1
  7. package/dist/config/schema/magic-context.d.ts +43 -9
  8. package/dist/config/schema/magic-context.d.ts.map +1 -1
  9. package/dist/{conflict-warning-hook-4pmz879v.js → conflict-warning-hook-2r32hyx6.js} +9 -8
  10. package/dist/{context-j31m2dv7.js → context-j7hp43a0.js} +576 -185
  11. package/dist/{derive-budgets-zn7yzd2d.js → derive-budgets-pqybnx09.js} +2 -2
  12. package/dist/embedding-backfill-dtke6tck.js +25 -0
  13. package/dist/embedding-worker-process.js +2 -2
  14. package/dist/embedding-worker.js +6 -6
  15. package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -1
  16. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +44 -1
  17. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  18. package/dist/features/magic-context/dreamer/docs-proposals.d.ts +1 -0
  19. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  22. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +2 -0
  24. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  25. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  26. package/dist/features/magic-context/memory/embedding-local.d.ts +1 -0
  27. package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
  28. package/dist/features/magic-context/memory/embedding-synapse.d.ts.map +1 -1
  29. package/dist/features/magic-context/memory/embedding-worker-client.d.ts +7 -1
  30. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  31. package/dist/features/magic-context/memory/local-embedding-pooling.d.ts +22 -0
  32. package/dist/features/magic-context/memory/local-embedding-pooling.d.ts.map +1 -0
  33. package/dist/features/magic-context/message-index-async.d.ts +7 -2
  34. package/dist/features/magic-context/message-index-async.d.ts.map +1 -1
  35. package/dist/features/magic-context/message-index.d.ts +2 -0
  36. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  37. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  38. package/dist/features/magic-context/project-embedding-registry.d.ts +2 -0
  39. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  40. package/dist/features/magic-context/search-rerank.d.ts +9 -2
  41. package/dist/features/magic-context/search-rerank.d.ts.map +1 -1
  42. package/dist/features/magic-context/search.d.ts +29 -0
  43. package/dist/features/magic-context/search.d.ts.map +1 -1
  44. package/dist/features/magic-context/smart-notes/compiler.d.ts.map +1 -1
  45. package/dist/features/magic-context/storage-db.d.ts +2 -0
  46. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  47. package/dist/features/magic-context/storage-meta-persisted.d.ts +2 -0
  48. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  49. package/dist/features/magic-context/subagent-token-capture.d.ts +20 -0
  50. package/dist/features/magic-context/subagent-token-capture.d.ts.map +1 -1
  51. package/dist/features/magic-context/user-memory/review-user-memories.d.ts.map +1 -1
  52. package/dist/{history-owner-xp3pngv7.js → history-owner-36wp3mkb.js} +2 -2
  53. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/auto-search-hint.d.ts +7 -1
  56. package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +33 -6
  59. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/cache-busting-signals.d.ts +6 -2
  61. package/dist/hooks/magic-context/cache-busting-signals.d.ts.map +1 -1
  62. package/dist/hooks/magic-context/channel2-delivery.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  64. package/dist/hooks/magic-context/compartment-runner-types.d.ts +5 -0
  65. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/compartment-trigger.d.ts +1 -1
  67. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/diagnostic-log-state.d.ts +4 -0
  69. package/dist/hooks/magic-context/diagnostic-log-state.d.ts.map +1 -0
  70. package/dist/hooks/magic-context/execute-reclaim.d.ts +35 -0
  71. package/dist/hooks/magic-context/execute-reclaim.d.ts.map +1 -0
  72. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/hook.d.ts +1 -3
  74. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  75. package/dist/hooks/magic-context/latest-assistant-turn.d.ts +8 -0
  76. package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +5 -0
  78. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -1
  79. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts +3 -0
  80. package/dist/hooks/magic-context/nudge-evaluation-log.d.ts.map +1 -0
  81. package/dist/hooks/magic-context/pending-drop-eligibility.d.ts.map +1 -1
  82. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +4 -0
  83. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  84. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  85. package/dist/hooks/magic-context/served-shape-repair.d.ts +19 -0
  86. package/dist/hooks/magic-context/served-shape-repair.d.ts.map +1 -0
  87. package/dist/hooks/magic-context/strip-content.d.ts +4 -2
  88. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  89. package/dist/hooks/magic-context/system-date-refresh.d.ts +5 -5
  90. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts +10 -0
  92. package/dist/hooks/magic-context/system-prompt-sticky-date.d.ts.map +1 -0
  93. package/dist/hooks/magic-context/tag-content-primitives.d.ts +1 -1
  94. package/dist/hooks/magic-context/tag-content-primitives.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/tag-messages.d.ts +4 -1
  96. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/text-complete.d.ts +1 -1
  98. package/dist/hooks/magic-context/text-complete.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  100. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +21 -6
  101. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/transform.d.ts +2 -2
  103. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  104. package/dist/{index-3esx8tkf.js → index-11gzxvf4.js} +394 -125
  105. package/dist/{index-jn12fvvh.js → index-1gtfne2c.js} +3 -3
  106. package/dist/{index-jhghdnsm.js → index-1kbznkft.js} +521 -214
  107. package/dist/{index-3h4dp9wb.js → index-3svaejkh.js} +5 -5
  108. package/dist/{index-kee4kn5j.js → index-4pnsgvfk.js} +1 -1
  109. package/dist/{index-bjcnntmz.js → index-51rdvtkz.js} +501 -20
  110. package/dist/{v2/server-8cd2j99z.js → index-5kym00ag.js} +32 -13
  111. package/dist/{index-s74zqahq.js → index-66eby7hx.js} +4 -4
  112. package/dist/{index-63k48rv9.js → index-9q1g3c5q.js} +5 -5
  113. package/dist/{index-jrr131e0.js → index-a9zvn5fe.js} +29 -15
  114. package/dist/{index-c5pytzne.js → index-b88dwwrh.js} +1 -1
  115. package/dist/{index-nj7yykkx.js → index-c7phnbvk.js} +1 -1
  116. package/dist/index-cpjk5jd2.js +82 -0
  117. package/dist/{index-c1p88z1y.js → index-ffzhwfzy.js} +4 -4
  118. package/dist/{v2/server-beht37jy.js → index-gzy5w8ya.js} +194 -5
  119. package/dist/{index-j75v2476.js → index-h7tgn49j.js} +12 -15
  120. package/dist/{index-edmpdxcw.js → index-j32jj2t8.js} +5 -5
  121. package/dist/{index-ke416mdc.js → index-j76ah6d7.js} +2 -2
  122. package/dist/{index-s734jcsr.js → index-jfem3dgz.js} +9 -3
  123. package/dist/{index-n37sebck.js → index-jjvbk92s.js} +1 -1
  124. package/dist/{index-4911rn0b.js → index-jmq8kfe7.js} +6 -6
  125. package/dist/{index-rr2bb45z.js → index-kfyb3k6n.js} +2 -2
  126. package/dist/{index-2vxtcb95.js → index-kq5w68dp.js} +2 -2
  127. package/dist/{index-kq82mtg0.js → index-ksq50rg0.js} +3 -3
  128. package/dist/{index-b5vqckbw.js → index-m32esgmj.js} +314 -127
  129. package/dist/{index-9zcsy3hh.js → index-mnhcdfxg.js} +161 -13
  130. package/dist/{index-se4m2g6w.js → index-mnnkgq0q.js} +111 -19
  131. package/dist/{index-p5y3k4g7.js → index-nda0zgna.js} +2 -1
  132. package/dist/{index-wgypt3cs.js → index-nxrsns5x.js} +2466 -1290
  133. package/dist/{index-4s3t0nd0.js → index-qgh1qwjj.js} +2 -2
  134. package/dist/{index-y9f76s3f.js → index-rrv26qjz.js} +1 -1
  135. package/dist/{index-24fezq97.js → index-rxqr723x.js} +5 -5
  136. package/dist/{index-v10f1rjv.js → index-spwjbkc7.js} +1 -1
  137. package/dist/{index-dxmq29t1.js → index-syaazvy2.js} +182 -47
  138. package/dist/{index-k29z4aqh.js → index-t5pck3ss.js} +1 -1
  139. package/dist/{index-6x57ar45.js → index-wfybj1dw.js} +4 -6
  140. package/dist/{index-cf74k5ak.js → index-whcgcfrv.js} +9 -6
  141. package/dist/{index-a6mc0v4d.js → index-x6cbrv9h.js} +3 -3
  142. package/dist/{index-bp5083x2.js → index-x9k3mqrf.js} +1 -1
  143. package/dist/{index-rpxdjkm0.js → index-y76rhsnr.js} +319 -61
  144. package/dist/{index-ze7mvk54.js → index-zy67whjr.js} +95 -59
  145. package/dist/index.js +58 -54
  146. package/dist/{logger-jm3sqqzr.js → logger-94kew5wm.js} +1 -1
  147. package/dist/{message-fts-rowid-map-17s0dfn4.js → message-fts-rowid-map-e79b7b6x.js} +6 -5
  148. package/dist/{message-index-gtpqnj8w.js → message-index-4q8ek2fc.js} +17 -16
  149. package/dist/{message-index-bounded-zyc8h32y.js → message-index-bounded-rydsg9r5.js} +17 -16
  150. package/dist/{message-time-backfill-73mmm76q.js → message-time-backfill-4qva0b4f.js} +3 -3
  151. package/dist/migration-worker.js +13 -12
  152. package/dist/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
  153. package/dist/plugin/embedding-bootstrap.d.ts +4 -1
  154. package/dist/plugin/embedding-bootstrap.d.ts.map +1 -1
  155. package/dist/plugin/hooks/create-session-hooks.d.ts +1 -0
  156. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  157. package/dist/plugin/rpc-handlers.d.ts +8 -0
  158. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  159. package/dist/plugin/subagent-tool-policy.d.ts +9 -0
  160. package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
  161. package/dist/plugin/tool-registry.d.ts.map +1 -1
  162. package/dist/{project-embedding-registry-z74mhqkf.js → project-embedding-registry-hn529988.js} +16 -13
  163. package/dist/raw-ordinal-warmup-worker.js +136 -101
  164. package/dist/{read-session-chunk-jjb48bt9.js → read-session-chunk-t039f0m5.js} +12 -11
  165. package/dist/{read-session-raw-rsc8c7qy.js → read-session-raw-aw6jgvwg.js} +4 -3
  166. package/dist/recomp-orchestrator-hbm53jj5.js +62 -0
  167. package/dist/{safe-notification-target-1szv1k5k.js → safe-notification-target-mkr9yzvr.js} +2 -2
  168. package/dist/search-archive-weh164mh.js +26 -0
  169. package/dist/search-hea079d7.js +50 -0
  170. package/dist/{send-session-notification-6ve0e8p4.js → send-session-notification-gqzkz7da.js} +7 -6
  171. package/dist/shared/logger.d.ts.map +1 -1
  172. package/dist/shared/model-resolution.d.ts +2 -0
  173. package/dist/shared/model-resolution.d.ts.map +1 -1
  174. package/dist/shared/prompt-async-transport.d.ts +3 -0
  175. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  176. package/dist/shared/rpc-types.d.ts +7 -0
  177. package/dist/shared/rpc-types.d.ts.map +1 -1
  178. package/dist/shared/sqlite.d.ts +6 -1
  179. package/dist/shared/sqlite.d.ts.map +1 -1
  180. package/dist/shared/subagent-runner.d.ts +2 -0
  181. package/dist/shared/subagent-runner.d.ts.map +1 -1
  182. package/dist/shared/tag-transcript.d.ts +2 -0
  183. package/dist/shared/tag-transcript.d.ts.map +1 -1
  184. package/dist/shared/worker-shutdown.d.ts +68 -0
  185. package/dist/shared/worker-shutdown.d.ts.map +1 -0
  186. package/dist/shared/worker-shutdown.fixture.d.ts +2 -0
  187. package/dist/shared/worker-shutdown.fixture.d.ts.map +1 -0
  188. package/dist/{sqlite-zf72c52d.js → sqlite-zdgm52sv.js} +5 -1
  189. package/dist/{storage-memory-y3qmy00r.js → storage-memory-e6a7mb0k.js} +2 -2
  190. package/dist/{storage-tags-r7k9tjcv.js → storage-tags-a77q4v77.js} +5 -5
  191. package/dist/{task-config-x3qmayd2.js → task-config-t6bpyka7.js} +2 -2
  192. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  193. package/dist/tools/ctx-search/types.d.ts +1 -0
  194. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  195. package/dist/{transform-postprocess-phase-jj99r7z2.js → transform-postprocess-phase-0b04tm1p.js} +35 -32
  196. package/dist/v2/auto-search-worker.js +48 -9
  197. package/dist/v2/chunk-embedding-write-worker.js +30 -23
  198. package/dist/v2/{compaction-marker-candidates-ebx3388k.js → compaction-marker-candidates-m4vmye3w.js} +3 -3
  199. package/dist/v2/compaction-marker-candidates-worker.js +2 -2
  200. package/dist/v2/compartment-chunk-embedding-8jjmcgeg.js +64 -0
  201. package/dist/v2/{context-y5yamxak.js → context-ea3x7smm.js} +1797 -810
  202. package/dist/v2/{derive-budgets-2zh4gm2c.js → derive-budgets-knf763tt.js} +3 -3
  203. package/dist/v2/embedding-backfill-5e74ae0m.js +24 -0
  204. package/dist/v2/embedding-worker-process.js +2 -2
  205. package/dist/v2/embedding-worker.js +6 -6
  206. package/dist/v2/hidden-child-record.d.ts +2 -0
  207. package/dist/v2/hidden-child-record.d.ts.map +1 -1
  208. package/dist/v2/hidden-completion.d.ts +2 -0
  209. package/dist/v2/hidden-completion.d.ts.map +1 -1
  210. package/dist/v2/hidden-model-activity.d.ts +7 -0
  211. package/dist/v2/hidden-model-activity.d.ts.map +1 -0
  212. package/dist/v2/{history-owner-42e16w0n.js → history-owner-ad0crnrn.js} +2 -2
  213. package/dist/v2/hooks/context.d.ts.map +1 -1
  214. package/dist/v2/hooks/copied-tag-notation.d.ts +1 -1
  215. package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -1
  216. package/dist/v2/hooks/dream-timer.d.ts +2 -0
  217. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  218. package/dist/v2/hooks/embedding-lifecycle.d.ts +7 -0
  219. package/dist/v2/hooks/embedding-lifecycle.d.ts.map +1 -0
  220. package/dist/v2/hooks/generate.d.ts +36 -1
  221. package/dist/v2/hooks/generate.d.ts.map +1 -1
  222. package/dist/v2/hooks/lkg-system.d.ts +35 -4
  223. package/dist/v2/hooks/lkg-system.d.ts.map +1 -1
  224. package/dist/v2/hooks/payload.d.ts +16 -1
  225. package/dist/v2/hooks/payload.d.ts.map +1 -1
  226. package/dist/v2/hooks/store.d.ts +2 -0
  227. package/dist/v2/hooks/store.d.ts.map +1 -1
  228. package/dist/v2/hooks/tools.d.ts +2 -1
  229. package/dist/v2/hooks/tools.d.ts.map +1 -1
  230. package/dist/v2/hooks/transform-features.d.ts +2 -2
  231. package/dist/v2/hooks/transform-features.d.ts.map +1 -1
  232. package/dist/v2/{logger-7qt02bnb.js → logger-p34mjtja.js} +1 -1
  233. package/dist/v2/{message-fts-rowid-map-wfx67gfd.js → message-fts-rowid-map-n8fdg2ja.js} +6 -5
  234. package/dist/v2/{message-index-bounded-spd8r7pj.js → message-index-bounded-8rcd7qq9.js} +17 -16
  235. package/dist/v2/{message-index-8vz2pq76.js → message-index-qz9wdp82.js} +17 -16
  236. package/dist/v2/{message-time-backfill-04t0km1z.js → message-time-backfill-zvthw6xb.js} +3 -3
  237. package/dist/v2/migration-worker.js +13 -12
  238. package/dist/v2/{model-resolution-nx97z3x7.js → model-resolution-280gmqvd.js} +1 -1
  239. package/dist/v2/{project-embedding-registry-gnkj56xp.js → project-embedding-registry-v38q4xd5.js} +16 -13
  240. package/dist/v2/raw-ordinal-warmup-worker.js +136 -101
  241. package/dist/v2/{read-session-chunk-cwkxrmns.js → read-session-chunk-wazfyxcg.js} +12 -11
  242. package/dist/v2/{read-session-raw-yaegtjzh.js → read-session-raw-b70cpwzj.js} +4 -3
  243. package/dist/v2/recomp-orchestrator-b12zaptj.js +61 -0
  244. package/dist/v2/{safe-notification-target-qg7n2s77.js → safe-notification-target-khnzg57c.js} +2 -2
  245. package/dist/v2/search-archive-x64rtz1z.js +25 -0
  246. package/dist/v2/search-hza9x72a.js +49 -0
  247. package/dist/v2/{send-session-notification-3pxn658x.js → send-session-notification-8eqe259v.js} +7 -6
  248. package/dist/v2/{server-45q69hkq.js → server-132h8twc.js} +5 -5
  249. package/dist/v2/{server-h0410h0v.js → server-1bw1wcbp.js} +1 -1
  250. package/dist/v2/{server-271qxsf5.js → server-24g8r2d0.js} +2466 -1290
  251. package/dist/v2/{server-tbe1femw.js → server-29qp8nz4.js} +1 -1
  252. package/dist/v2/{server-gsxjv2q2.js → server-33nqbqkw.js} +182 -47
  253. package/dist/v2/{server-tgnbmwah.js → server-3mz2qh5a.js} +1 -1
  254. package/dist/v2/{server-n1prf1g6.js → server-3vhxy2k5.js} +2 -2
  255. package/dist/v2/{server-xj136kt8.js → server-4kjmrjn4.js} +9 -3
  256. package/dist/v2/{server-34kwfsr4.js → server-53eh1r8r.js} +2 -2
  257. package/dist/{index-8cd2j99z.js → v2/server-5kym00ag.js} +32 -13
  258. package/dist/v2/{server-46neh5fa.js → server-62g58aaz.js} +314 -127
  259. package/dist/v2/{server-f2xf5gcb.js → server-6495nmn9.js} +12 -15
  260. package/dist/v2/{server-a9xqj88f.js → server-6v3cdzsx.js} +4 -4
  261. package/dist/v2/{server-d04vrx0j.js → server-806rzhs6.js} +2 -2
  262. package/dist/v2/{server-qd11g795.js → server-92g7d776.js} +2 -1
  263. package/dist/v2/{server-nj659894.js → server-94wk1ey3.js} +14 -3
  264. package/dist/v2/{server-6tmj0s7j.js → server-ab1g0wn9.js} +4 -6
  265. package/dist/v2/{server-8by8qfec.js → server-ad18djzs.js} +95 -59
  266. package/dist/v2/{server-hy3d3vsx.js → server-bsgd4dk1.js} +2 -2
  267. package/dist/v2/server-cpjk5jd2.js +82 -0
  268. package/dist/v2/{server-g3qma5c0.js → server-d1dzgvwd.js} +2 -2
  269. package/dist/v2/{server-hm38q7r0.js → server-d48x3m4x.js} +5 -5
  270. package/dist/v2/{server-1wy7b9de.js → server-dtp8hcjh.js} +3 -3
  271. package/dist/v2/{server-27gq4mfz.js → server-fa7vtp40.js} +9 -6
  272. package/dist/v2/{server-6pmqg9m4.js → server-gyy4k6mf.js} +1 -1
  273. package/dist/{index-beht37jy.js → v2/server-gzy5w8ya.js} +194 -5
  274. package/dist/v2/{server-bmymkx73.js → server-j8h7bsca.js} +29 -15
  275. package/dist/v2/{server-n37sebck.js → server-jjvbk92s.js} +1 -1
  276. package/dist/v2/{server-da07v4xp.js → server-k3t06fxr.js} +1 -1
  277. package/dist/v2/{server-9hx7g5jp.js → server-m4bfaevz.js} +1197 -1049
  278. package/dist/v2/{server-2ar62dyx.js → server-ppcd1qxh.js} +191 -99
  279. package/dist/v2/{server-rmygf5pn.js → server-qjvk4a9t.js} +2 -2
  280. package/dist/v2/{server-zzkj2fch.js → server-qteg2kt9.js} +5 -5
  281. package/dist/v2/{server-pwv4ezb0.js → server-rqebawx1.js} +2 -2
  282. package/dist/v2/{server-h1v0pyxb.js → server-vr4szghm.js} +501 -20
  283. package/dist/v2/{server-xq7dfjke.js → server-wwaw5npa.js} +5 -5
  284. package/dist/v2/{server-6vdzn1td.js → server-zg5y109h.js} +323 -76
  285. package/dist/v2/server.js +8 -8
  286. package/dist/v2/{sqlite-zf72c52d.js → sqlite-zdgm52sv.js} +5 -1
  287. package/dist/v2/{storage-memory-y3qmy00r.js → storage-memory-e6a7mb0k.js} +2 -2
  288. package/dist/v2/{storage-tags-3wdb8zph.js → storage-tags-q71rnr9f.js} +5 -5
  289. package/dist/v2/store-reader.d.ts +10 -0
  290. package/dist/v2/store-reader.d.ts.map +1 -1
  291. package/dist/v2/{task-config-nvz8mapa.js → task-config-7md27rx8.js} +2 -2
  292. package/dist/v2/{wrapup-orchestrator-embdz8gj.js → wrapup-orchestrator-3ssd5yy1.js} +33 -32
  293. package/dist/wrapup-orchestrator-5vpcd1zx.js +49 -0
  294. package/package.json +2 -2
  295. package/src/config/index.test.ts +72 -6
  296. package/src/config/project-security.ts +15 -0
  297. package/src/config/rerank.test.ts +60 -0
  298. package/src/config/schema/magic-context.ts +57 -0
  299. package/src/shared/logger.test.ts +42 -1
  300. package/src/shared/logger.ts +11 -13
  301. package/src/shared/model-resolution.test.ts +67 -12
  302. package/src/shared/model-resolution.ts +43 -16
  303. package/src/shared/model-suggestion-retry.ts +2 -2
  304. package/src/shared/prompt-async-transport.ts +47 -3
  305. package/src/shared/rpc-types.ts +7 -0
  306. package/src/shared/sqlite-busy-budget-review.test.ts +6 -1
  307. package/src/shared/sqlite-turn-deadline.test.ts +270 -0
  308. package/src/shared/sqlite.ts +239 -9
  309. package/src/shared/subagent-runner.ts +2 -0
  310. package/src/shared/tag-transcript.ts +9 -1
  311. package/src/shared/worker-shutdown-fence.test.ts +87 -0
  312. package/src/shared/worker-shutdown.fixture.ts +25 -0
  313. package/src/shared/worker-shutdown.test.ts +127 -0
  314. package/src/shared/worker-shutdown.ts +160 -0
  315. package/dist/embedding-backfill-fmz50tsy.js +0 -24
  316. package/dist/recomp-orchestrator-999jj4bc.js +0 -61
  317. package/dist/search-archive-6vm0e2f5.js +0 -25
  318. package/dist/search-xsqk1bj4.js +0 -49
  319. package/dist/v2/embedding-backfill-7c7yr69y.js +0 -23
  320. package/dist/v2/recomp-orchestrator-f6m9jr7p.js +0 -60
  321. package/dist/v2/search-archive-wve3tq1k.js +0 -24
  322. package/dist/v2/search-hwg7jfbj.js +0 -48
  323. package/dist/wrapup-orchestrator-whhbjmaz.js +0 -48
@@ -37,6 +37,16 @@ type HotPathScenarioResult = {
37
37
  statCalls: number;
38
38
  };
39
39
 
40
+ type ImmediateWriteScenarioResult = {
41
+ afterLog: string;
42
+ afterForward: string;
43
+ };
44
+
45
+ type BufferedWriteScenarioResult = {
46
+ beforeFlush: string;
47
+ afterFlush: string;
48
+ };
49
+
40
50
  const loggerScenario = `
41
51
  import fs from "node:fs";
42
52
  import * as path from "node:path";
@@ -74,7 +84,19 @@ if (scenario === "hot-path") {
74
84
 
75
85
  const logger = await import(loggerModuleUrl);
76
86
 
77
- if (scenario === "retry") {
87
+ if (scenario === "sync-write") {
88
+ logger.log("synchronous log line");
89
+ const afterLog = fs.existsSync(logPath) ? fs.readFileSync(logPath, "utf8") : "";
90
+ logger.writeForwardedLogLine("forwarded worker line\\n");
91
+ const afterForward = fs.readFileSync(logPath, "utf8");
92
+ console.log(JSON.stringify({ afterLog, afterForward }));
93
+ } else if (scenario === "default-buffering") {
94
+ logger.log("buffered log line");
95
+ const beforeFlush = fs.existsSync(logPath) ? fs.readFileSync(logPath, "utf8") : "";
96
+ logger.flushLogger();
97
+ const afterFlush = fs.readFileSync(logPath, "utf8");
98
+ console.log(JSON.stringify({ beforeFlush, afterFlush }));
99
+ } else if (scenario === "retry") {
78
100
  logger.log("first buffered line");
79
101
  logger.log("second buffered line");
80
102
  logger.flushLogger();
@@ -203,6 +225,8 @@ async function runLoggerScenario<T>(
203
225
  scenario:
204
226
  | "recovery"
205
227
  | "diagnostics"
228
+ | "sync-write"
229
+ | "default-buffering"
206
230
  | "rotation"
207
231
  | "stale-rotation"
208
232
  | "hot-path"
@@ -222,6 +246,7 @@ async function runLoggerScenario<T>(
222
246
  LOGGER_MODULE_URL: new URL("./logger.ts", import.meta.url).href,
223
247
  LOGGER_SCENARIO: scenario,
224
248
  LOGGER_SCENARIO_ROOT: root,
249
+ MAGIC_CONTEXT_LOG_SYNC: scenario === "sync-write" ? "1" : "",
225
250
  },
226
251
  stdout: "pipe",
227
252
  stderr: "pipe",
@@ -236,6 +261,22 @@ async function runLoggerScenario<T>(
236
261
  }
237
262
 
238
263
  describe("logger", () => {
264
+ test("writes local and forwarded lines immediately when sync logging is enabled", async () => {
265
+ const result = await runLoggerScenario<ImmediateWriteScenarioResult>("sync-write");
266
+
267
+ expect(result.afterLog).toContain("synchronous log line");
268
+ expect(result.afterLog).not.toContain("forwarded worker line");
269
+ expect(result.afterForward).toContain("synchronous log line");
270
+ expect(result.afterForward).toContain("forwarded worker line");
271
+ });
272
+
273
+ test("keeps lines buffered before the flush interval by default", async () => {
274
+ const result = await runLoggerScenario<BufferedWriteScenarioResult>("default-buffering");
275
+
276
+ expect(result.beforeFlush).toBe("");
277
+ expect(result.afterFlush).toContain("buffered log line");
278
+ });
279
+
239
280
  test("retries the whole buffered batch after a transient append failure", async () => {
240
281
  const result = await runLoggerScenario<RetryScenarioResult>("retry");
241
282
  expect(result.failed).toBe(1);
@@ -5,6 +5,7 @@ import { sanitizeConfigValue, sanitizeDiagnosticText } from "./redaction";
5
5
  import { stalePluginBuildDiagnostic } from "./stale-plugin-build";
6
6
 
7
7
  const isTestEnv = process.env.NODE_ENV === "test";
8
+ const syncLogWrites = process.env.MAGIC_CONTEXT_LOG_SYNC === "1";
8
9
 
9
10
  let buffer: string[] = [];
10
11
  let flushTimer: ReturnType<typeof setTimeout> | null = null;
@@ -198,6 +199,14 @@ function scheduleFlush(): void {
198
199
  }, FLUSH_INTERVAL_MS);
199
200
  }
200
201
 
202
+ function appendLine(line: string): void {
203
+ buffer.push(line);
204
+ bufferedBytes += Buffer.byteLength(line);
205
+ boundBuffer();
206
+ if (syncLogWrites || buffer.length >= BUFFER_SIZE_LIMIT) flush();
207
+ else scheduleFlush();
208
+ }
209
+
201
210
  // Set inside a worker thread so its lines reach the main thread's log file. The
202
211
  // log path depends on which host (OpenCode or Pi) the main thread registered,
203
212
  // and only the main thread's buffer and flush timer write that file.
@@ -215,11 +224,7 @@ export function setLogLineForwarder(forward: ((line: string) => void) | null): v
215
224
  export function writeForwardedLogLine(line: string): void {
216
225
  if (isTestEnv) return;
217
226
  try {
218
- buffer.push(line);
219
- bufferedBytes += Buffer.byteLength(line);
220
- boundBuffer();
221
- if (buffer.length >= BUFFER_SIZE_LIMIT) flush();
222
- else scheduleFlush();
227
+ appendLine(line);
223
228
  } catch {
224
229
  // Intentional: logging must never throw
225
230
  }
@@ -249,14 +254,7 @@ export function log(message: string, data?: unknown): void {
249
254
  lineForwarder(line);
250
255
  return;
251
256
  }
252
- buffer.push(line);
253
- bufferedBytes += Buffer.byteLength(line);
254
- boundBuffer();
255
- if (buffer.length >= BUFFER_SIZE_LIMIT) {
256
- flush();
257
- } else {
258
- scheduleFlush();
259
- }
257
+ appendLine(line);
260
258
  } catch {
261
259
  // Intentional: logging must never throw
262
260
  }
@@ -118,12 +118,22 @@ describe("model-resolution", () => {
118
118
  // Inheritance is deliberately absent because a fallback model may not support the
119
119
  // qualifier selected for the primary model.
120
120
  expect(resolveHistorianModel(config, "opencode")).toEqual({
121
- primary: { model: "open/primary", qualifier: "primary-only" },
122
- fallbacks: [{ model: "open/fallback" }],
121
+ primary: {
122
+ model: "open/primary",
123
+ qualifier: "primary-only",
124
+ sourceConfigKey: "historian.opencode.model",
125
+ },
126
+ fallbacks: [
127
+ { model: "open/fallback", sourceConfigKey: "historian.opencode.fallback_models" },
128
+ ],
123
129
  });
124
130
  expect(resolveHistorianModel(config, "pi")).toEqual({
125
- primary: { model: "pi/primary", qualifier: "high" },
126
- fallbacks: [{ model: "pi/fallback" }],
131
+ primary: {
132
+ model: "pi/primary",
133
+ qualifier: "high",
134
+ sourceConfigKey: "historian.pi.model",
135
+ },
136
+ fallbacks: [{ model: "pi/fallback", sourceConfigKey: "historian.pi.fallback_models" }],
127
137
  });
128
138
  });
129
139
 
@@ -143,12 +153,32 @@ describe("model-resolution", () => {
143
153
  };
144
154
 
145
155
  expect(resolveHistorianModel(config, "opencode")).toEqual({
146
- primary: { model: "open/code", qualifier: "oc-primary" },
147
- fallbacks: [{ model: "open/fallback", qualifier: "oc-fallback" }],
156
+ primary: {
157
+ model: "open/code",
158
+ qualifier: "oc-primary",
159
+ sourceConfigKey: "historian.opencode.model",
160
+ },
161
+ fallbacks: [
162
+ {
163
+ model: "open/fallback",
164
+ qualifier: "oc-fallback",
165
+ sourceConfigKey: "historian.opencode.fallback_models",
166
+ },
167
+ ],
148
168
  });
149
169
  expect(resolveHistorianModel(config, "pi")).toEqual({
150
- primary: { model: "pi/model", qualifier: "high" },
151
- fallbacks: [{ model: "pi/fallback", qualifier: "max" }],
170
+ primary: {
171
+ model: "pi/model",
172
+ qualifier: "high",
173
+ sourceConfigKey: "historian.pi.model",
174
+ },
175
+ fallbacks: [
176
+ {
177
+ model: "pi/fallback",
178
+ qualifier: "max",
179
+ sourceConfigKey: "historian.pi.fallback_models",
180
+ },
181
+ ],
152
182
  });
153
183
  });
154
184
 
@@ -182,8 +212,18 @@ describe("model-resolution", () => {
182
212
  };
183
213
 
184
214
  expect(resolveHistorianModel(configured, "omp")).toEqual({
185
- primary: { model: "omp/historian", qualifier: "auto" },
186
- fallbacks: [{ model: "omp/historian-fallback", qualifier: "max" }],
215
+ primary: {
216
+ model: "omp/historian",
217
+ qualifier: "auto",
218
+ sourceConfigKey: "historian.omp.model",
219
+ },
220
+ fallbacks: [
221
+ {
222
+ model: "omp/historian-fallback",
223
+ qualifier: "max",
224
+ sourceConfigKey: "historian.omp.fallback_models",
225
+ },
226
+ ],
187
227
  });
188
228
  expect(
189
229
  resolveDreamerTaskModel({ config: configured, harness: "omp", task: "verify" }),
@@ -197,6 +237,7 @@ describe("model-resolution", () => {
197
237
  expect(resolveHistorianModel(piFallback, "omp")?.primary).toEqual({
198
238
  model: "pi/historian",
199
239
  qualifier: "high",
240
+ sourceConfigKey: "historian.pi.model",
200
241
  });
201
242
  expect(
202
243
  resolveDreamerTaskModel({ config: piFallback, harness: "omp", task: "verify" }),
@@ -245,8 +286,22 @@ describe("model-resolution", () => {
245
286
  };
246
287
 
247
288
  expect(resolveDreamerTaskModel({ config, harness: "opencode", task: "curate" })).toEqual({
248
- primary: { model: "open/task", qualifier: "task-variant" },
249
- fallbacks: [{ model: "open/bare" }, { model: "open/qualified", qualifier: "fb" }],
289
+ primary: {
290
+ model: "open/task",
291
+ qualifier: "task-variant",
292
+ sourceConfigKey: "dreamer.opencode.tasks.curate.model",
293
+ },
294
+ fallbacks: [
295
+ {
296
+ model: "open/bare",
297
+ sourceConfigKey: "dreamer.opencode.tasks.curate.fallback_models",
298
+ },
299
+ {
300
+ model: "open/qualified",
301
+ qualifier: "fb",
302
+ sourceConfigKey: "dreamer.opencode.tasks.curate.fallback_models",
303
+ },
304
+ ],
250
305
  schedule: "0 4 * * *",
251
306
  timeoutMinutes: 12,
252
307
  promotionThreshold: 3,
@@ -5,6 +5,8 @@ export interface ResolvedModelEntry {
5
5
  model: string;
6
6
  /** OpenCode variant or Pi thinking level, selected for the active entry only. */
7
7
  qualifier?: string;
8
+ /** Config location that supplied this attempt, for accurate failure diagnostics. */
9
+ sourceConfigKey?: string;
8
10
  }
9
11
 
10
12
  export type ModelInput = string | ResolvedModelEntry;
@@ -35,6 +37,10 @@ function resolveHarnessBlock(
35
37
  return asRecord(selected);
36
38
  }
37
39
 
40
+ function sourceHarness(container: ConfigRecord | undefined, harness: ModelHarness): ModelHarness {
41
+ return harness === "omp" && container?.omp == null ? "pi" : harness;
42
+ }
43
+
38
44
  /**
39
45
  * Collapses the string and object spellings of a harness model entry into the
40
46
  * same model identity. Qualifiers stay separate because they alter an attempt,
@@ -116,14 +122,20 @@ export function resolveHistorianModel(
116
122
  const historian = asRecord(asRecord(config)?.historian);
117
123
  const block = resolveHarnessBlock(historian, harness);
118
124
  if (!block) return { fallbacks: [] };
125
+ const source = `historian.${sourceHarness(historian, harness)}`;
126
+ const primary = resolvePrimaryEntry({
127
+ entry: block.model,
128
+ defaultQualifier: block[harness === "opencode" ? "variant" : "thinking_level"],
129
+ harness,
130
+ });
131
+ const fallbacks = resolveFallbackEntries(block.fallback_models, harness);
119
132
 
120
133
  return {
121
- primary: resolvePrimaryEntry({
122
- entry: block.model,
123
- defaultQualifier: block[harness === "opencode" ? "variant" : "thinking_level"],
124
- harness,
125
- }),
126
- fallbacks: resolveFallbackEntries(block.fallback_models, harness),
134
+ primary: primary ? { ...primary, sourceConfigKey: `${source}.model` } : undefined,
135
+ fallbacks: fallbacks.map((entry) => ({
136
+ ...entry,
137
+ sourceConfigKey: `${source}.fallback_models`,
138
+ })),
127
139
  };
128
140
  }
129
141
 
@@ -171,19 +183,34 @@ export function resolveDreamerTaskModel(args: {
171
183
  harnessBlock[args.harness === "opencode" ? "variant" : "thinking_level"] ??
172
184
  normalizeModelEntry(harnessBlock.model, args.harness)?.qualifier;
173
185
  const taskHasModel = taskBlock !== undefined && hasOwn(taskBlock, "model");
186
+ const taskHasFallbacks = taskBlock !== undefined && hasOwn(taskBlock, "fallback_models");
174
187
  const primarySource = taskHasModel ? taskBlock?.model : harnessBlock.model;
175
- const fallbackSource =
176
- taskBlock !== undefined && hasOwn(taskBlock, "fallback_models")
177
- ? taskBlock.fallback_models
178
- : harnessBlock.fallback_models;
188
+ const fallbackSource = taskHasFallbacks
189
+ ? taskBlock?.fallback_models
190
+ : harnessBlock.fallback_models;
191
+ const source = `dreamer.${sourceHarness(dreamer, args.harness)}`;
192
+ const primary = resolvePrimaryEntry({
193
+ entry: primarySource,
194
+ defaultQualifier: taskQualifier ?? harnessQualifier,
195
+ harness: args.harness,
196
+ });
197
+ const fallbacks = resolveFallbackEntries(fallbackSource, args.harness);
179
198
 
180
199
  return {
181
- primary: resolvePrimaryEntry({
182
- entry: primarySource,
183
- defaultQualifier: taskQualifier ?? harnessQualifier,
184
- harness: args.harness,
185
- }),
186
- fallbacks: resolveFallbackEntries(fallbackSource, args.harness),
200
+ primary: primary
201
+ ? {
202
+ ...primary,
203
+ sourceConfigKey: taskHasModel
204
+ ? `${source}.tasks.${args.task}.model`
205
+ : `${source}.model`,
206
+ }
207
+ : undefined,
208
+ fallbacks: fallbacks.map((entry) => ({
209
+ ...entry,
210
+ sourceConfigKey: taskHasFallbacks
211
+ ? `${source}.tasks.${args.task}.fallback_models`
212
+ : `${source}.fallback_models`,
213
+ })),
187
214
  schedule: readString(schedulingTask?.schedule),
188
215
  timeoutMinutes:
189
216
  typeof taskBlock?.timeout_minutes === "number" ? taskBlock.timeout_minutes : undefined,
@@ -357,7 +357,7 @@ async function promptWithTimeout(
357
357
  // Only a transport that watches the child can say the model is silent.
358
358
  if (!activity.monitored || activity.received) return;
359
359
  silent = true;
360
- controller.abort();
360
+ controller.abort(new ModelProducedNoOutputError(firstOutputTimeoutMs));
361
361
  }, firstOutputTimeoutMs)
362
362
  : undefined;
363
363
  const timeoutError = () =>
@@ -996,7 +996,7 @@ export async function promptSyncWithValidatedOutputRetry<TOutput, TValidated = T
996
996
 
997
997
  if (!cooledPrimary && !quota)
998
998
  log(
999
- `[${callContext}] primary (${explicitPrimaryLabel}) failed validation/prompt: ${shortErr(failure.error)}; trying ${fallbacks.length} fallback(s)`,
999
+ `[${callContext}] primary (${explicitPrimaryLabel}) failed validation/prompt: ${shortErr(failure.error)}; ${fallbacks.length} fallback(s) configured, subject to remaining budget`,
1000
1000
  );
1001
1001
  }
1002
1002
 
@@ -7,7 +7,10 @@ import {
7
7
  releaseBudgetFinalizeChild,
8
8
  TOKEN_BUDGET_FINALIZE_MESSAGE,
9
9
  } from "../features/magic-context/dreamer/token-budget";
10
- import { sumTokensFromChildMessages } from "../features/magic-context/subagent-token-capture";
10
+ import {
11
+ annotateSubagentInvocationError,
12
+ sumTokensFromChildMessages,
13
+ } from "../features/magic-context/subagent-token-capture";
11
14
  import { describeAssistantError } from "./assistant-message-extractor";
12
15
  import { sessionLog } from "./logger";
13
16
  import type { PromptArgs, PromptTransport } from "./model-suggestion-retry";
@@ -60,6 +63,7 @@ export interface PromptAsyncWaitOptions {
60
63
  pollIntervalMs?: number;
61
64
  startGraceMs?: number;
62
65
  tokenBudget?: number;
66
+ modelConfigKey?: string;
63
67
  /** Shared across retries of one child session. */
64
68
  budgetGuard?: ReturnType<typeof createDreamTokenBudget>;
65
69
  onBudgetUpdate?: (
@@ -93,6 +97,19 @@ export function isHostSessionError(error: unknown): boolean {
93
97
  );
94
98
  }
95
99
 
100
+ /** Return the original host error carried by a marked child-session failure. */
101
+ export function hostSessionErrorOf(error: unknown): unknown {
102
+ if (!isHostSessionError(error)) return undefined;
103
+ return (error as { hostError?: unknown }).hostError;
104
+ }
105
+
106
+ function requestModelRef(request: PromptArgs): string | undefined {
107
+ const model = request.body?.model;
108
+ if (model && typeof model.providerID === "string" && typeof model.modelID === "string")
109
+ return `${model.providerID}/${model.modelID}`;
110
+ return undefined;
111
+ }
112
+
96
113
  /** True when the host client can send without waiting and report session status. */
97
114
  export function supportsPromptAsync(client: Client): boolean {
98
115
  const session = sessionApi(client);
@@ -339,11 +356,32 @@ export async function promptAsyncAndWaitForIdle(
339
356
  // retains that provider/model error while this child is actively awaited.
340
357
  activeSessionErrors.set(sessionId, undefined);
341
358
  try {
342
- const sent = await session.promptAsync?.(request);
359
+ let sent: unknown;
360
+ try {
361
+ sent = await session.promptAsync?.(request);
362
+ } catch (error) {
363
+ annotateSubagentInvocationError(error, {
364
+ attemptedModel: requestModelRef(request),
365
+ modelConfigKey: options.modelConfigKey,
366
+ hostError: error,
367
+ });
368
+ throw error;
369
+ }
343
370
  if (sent && typeof sent === "object" && "error" in sent) {
344
371
  const rejection = (sent as { error?: unknown }).error;
345
372
  if (rejection) {
346
- throw new Error(`prompt_async was rejected: ${describeRejection(rejection)}`);
373
+ const error = new Error(
374
+ `prompt_async was rejected: ${describeRejection(rejection)}`,
375
+ {
376
+ cause: rejection,
377
+ },
378
+ );
379
+ annotateSubagentInvocationError(error, {
380
+ attemptedModel: requestModelRef(request),
381
+ modelConfigKey: options.modelConfigKey,
382
+ hostError: rejection,
383
+ });
384
+ throw error;
347
385
  }
348
386
  }
349
387
  let sentAt = Date.now();
@@ -364,6 +402,12 @@ export async function promptAsyncAndWaitForIdle(
364
402
  name: "DreamerProviderOutputFailureError",
365
403
  transient: true,
366
404
  [HOST_SESSION_ERROR]: true,
405
+ hostError,
406
+ });
407
+ annotateSubagentInvocationError(error, {
408
+ attemptedModel: requestModelRef(request),
409
+ modelConfigKey: options.modelConfigKey,
410
+ hostError,
367
411
  });
368
412
  throw error;
369
413
  }
@@ -380,6 +380,7 @@ export interface DebugSessionHolderCount {
380
380
  wireMessages: number;
381
381
  wireContentSnapshots: number;
382
382
  wireEstimatedBytes: number;
383
+ generateReplayBytes: number;
383
384
  }
384
385
 
385
386
  export interface DebugMemoryHolders {
@@ -401,6 +402,12 @@ export interface DebugMemoryHolders {
401
402
  compartmentMirrors: {
402
403
  entries: number;
403
404
  };
405
+ /** OpenCode 2 only: kept copies of each session's last served request, which side
406
+ * questions replay. Zero on other hosts. */
407
+ generateReplay: {
408
+ sessionCount: number;
409
+ estimatedBytes: number;
410
+ };
404
411
  messageIndexQueue: {
405
412
  queueLength: number;
406
413
  reconciliationScheduled: number;
@@ -34,6 +34,7 @@ async function lock(path: string, mode: "read" | "write" | "exclusive", holdMs:
34
34
  "--eval",
35
35
  `import { Database } from "bun:sqlite";
36
36
  const db = new Database(process.argv[1]);
37
+ db.exec("PRAGMA busy_timeout = 5000");
37
38
  db.exec(process.argv[2] === "read" ? "BEGIN; SELECT * FROM result"
38
39
  : process.argv[2] === "write" ? "BEGIN IMMEDIATE" : "BEGIN EXCLUSIVE");
39
40
  console.log("LOCKED");
@@ -51,7 +52,11 @@ async function lock(path: string, mode: "read" | "write" | "exclusive", holdMs:
51
52
  while (!output.includes("LOCKED\n")) {
52
53
  const chunk = await reader.read();
53
54
  if (chunk.done) {
54
- throw new Error(`locker failed: ${await new Response(child.stderr).text()}`);
55
+ const [exitCode, stderr] = await Promise.all([
56
+ child.exited,
57
+ new Response(child.stderr).text(),
58
+ ]);
59
+ throw new Error(`locker failed (exit ${exitCode}): ${stderr.trim() || "<no stderr>"}`);
55
60
  }
56
61
  output += new TextDecoder().decode(chunk.value);
57
62
  }