@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
@@ -486,6 +486,7 @@ async function importPluginModule(load) {
486
486
 
487
487
  // src/shared/logger.ts
488
488
  var isTestEnv = false;
489
+ var syncLogWrites = process.env.MAGIC_CONTEXT_LOG_SYNC === "1";
489
490
  var buffer = [];
490
491
  var flushTimer = null;
491
492
  var FLUSH_INTERVAL_MS = 500;
@@ -630,6 +631,15 @@ function scheduleFlush() {
630
631
  flush();
631
632
  }, FLUSH_INTERVAL_MS);
632
633
  }
634
+ function appendLine(line) {
635
+ buffer.push(line);
636
+ bufferedBytes += Buffer.byteLength(line);
637
+ boundBuffer();
638
+ if (syncLogWrites || buffer.length >= BUFFER_SIZE_LIMIT)
639
+ flush();
640
+ else
641
+ scheduleFlush();
642
+ }
633
643
  var lineForwarder = null;
634
644
  function setLogLineForwarder2(forward) {
635
645
  lineForwarder = forward;
@@ -638,13 +648,7 @@ function writeForwardedLogLine2(line) {
638
648
  if (isTestEnv)
639
649
  return;
640
650
  try {
641
- buffer.push(line);
642
- bufferedBytes += Buffer.byteLength(line);
643
- boundBuffer();
644
- if (buffer.length >= BUFFER_SIZE_LIMIT)
645
- flush();
646
- else
647
- scheduleFlush();
651
+ appendLine(line);
648
652
  } catch {}
649
653
  }
650
654
  function log2(message, data) {
@@ -669,14 +673,7 @@ ${data.stack}` : ""}`)}` : ` ${JSON.stringify(sanitizeConfigValue(data))}`;
669
673
  lineForwarder(line);
670
674
  return;
671
675
  }
672
- buffer.push(line);
673
- bufferedBytes += Buffer.byteLength(line);
674
- boundBuffer();
675
- if (buffer.length >= BUFFER_SIZE_LIMIT) {
676
- flush();
677
- } else {
678
- scheduleFlush();
679
- }
676
+ appendLine(line);
680
677
  } catch {}
681
678
  }
682
679
  function sessionLog2(sessionId, message, data) {
@@ -4,13 +4,13 @@ import {
4
4
  import {
5
5
  importPluginModule,
6
6
  sessionLog2
7
- } from "./server-f2xf5gcb.js";
7
+ } from "./server-6495nmn9.js";
8
8
  import {
9
9
  isDefaultSessionTitle2
10
- } from "./server-h0410h0v.js";
10
+ } from "./server-1bw1wcbp.js";
11
11
  import {
12
12
  shouldHoldIgnoredNotification
13
- } from "./server-n1prf1g6.js";
13
+ } from "./server-3vhxy2k5.js";
14
14
  import {
15
15
  getErrorMessage
16
16
  } from "./server-y8v6yerm.js";
@@ -142,7 +142,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
142
142
  holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "during target checks");
143
143
  return "queued";
144
144
  }
145
- const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-qg7n2s77.js"));
145
+ const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-khnzg57c.js"));
146
146
  if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
147
147
  sessionLog2(sessionId, "notification skipped (session not titled yet)");
148
148
  return "skipped";
@@ -3,11 +3,11 @@ import {
3
3
  } from "./server-51779zs2.js";
4
4
  import {
5
5
  log2
6
- } from "./server-f2xf5gcb.js";
6
+ } from "./server-6495nmn9.js";
7
7
  import {
8
8
  inRootAsyncContext2,
9
9
  getSqliteDatabasePath2
10
- } from "./server-beht37jy.js";
10
+ } from "./server-gzy5w8ya.js";
11
11
 
12
12
  // src/features/magic-context/compaction-marker-candidates.ts
13
13
  import { existsSync, realpathSync } from "node:fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveDreamerTaskModel2
3
- } from "./server-8cd2j99z.js";
3
+ } from "./server-5kym00ag.js";
4
4
  import {
5
5
  isDreamerRunnable
6
6
  } from "./server-0s95v3en.js";
@@ -169,6 +169,7 @@ function buildDreamTaskRuntimeConfigs2(dreamer, harness, language, smartNotesEna
169
169
  schedule: resolved.schedule ?? "",
170
170
  model: resolved.primary,
171
171
  fallbackModels: resolved.fallbacks,
172
+ modelConfigKey: resolved.primary?.sourceConfigKey ?? resolved.fallbacks[0]?.sourceConfigKey,
172
173
  thinkingLevel: harness === "pi" ? resolved.primary?.qualifier : undefined,
173
174
  language,
174
175
  timeoutMinutes: resolved.timeoutMinutes ?? 20,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  log2
3
- } from "./server-f2xf5gcb.js";
3
+ } from "./server-6495nmn9.js";
4
4
  import {
5
5
  setOutputReserveConfig
6
- } from "./server-tbe1femw.js";
6
+ } from "./server-29qp8nz4.js";
7
7
  import {
8
8
  DEFAULT_EXECUTE_THRESHOLD_PERCENTAGE,
9
9
  PROTECTED_TOKENS_MIN,
@@ -11,7 +11,7 @@ import {
11
11
  PER_HARNESS_MODEL_KEYS,
12
12
  ConfigProfilesSchema,
13
13
  MagicContextConfigSchema
14
- } from "./server-271qxsf5.js";
14
+ } from "./server-24g8r2d0.js";
15
15
  import {
16
16
  isCompactionEnabled,
17
17
  migrateLegacyAgentEnabledInMemory
@@ -2439,6 +2439,17 @@ function stripUnsafeProjectConfigFields(projectRaw) {
2439
2439
  warnings.push(`Ignoring ${field} from project config (security: daemon routing and developer-only embedding traffic are user-level settings).`);
2440
2440
  }
2441
2441
  }
2442
+ if ("rerank" in projectRaw) {
2443
+ const rerank = projectRaw.rerank;
2444
+ const off = isPlainObject(rerank) && rerank.provider === "off";
2445
+ const removed = !isPlainObject(rerank) || Object.keys(rerank).some((key) => key !== "provider") || !off;
2446
+ if (off)
2447
+ projectRaw.rerank = { provider: "off" };
2448
+ else
2449
+ delete projectRaw.rerank;
2450
+ if (removed)
2451
+ warnings.push("Ignoring rerank settings from project config (security: projects may only set rerank.provider to off; hosted routing, credentials and limits are user-level only).");
2452
+ }
2442
2453
  const embedding = projectRaw.embedding;
2443
2454
  if (isPlainObject(embedding)) {
2444
2455
  const removed = [];
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./server-tgnbmwah.js";
3
+ } from "./server-3mz2qh5a.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./server-pavzsdc6.js";
7
7
  import {
8
8
  log2
9
- } from "./server-f2xf5gcb.js";
9
+ } from "./server-6495nmn9.js";
10
10
  import {
11
11
  inRootAsyncContext2
12
- } from "./server-beht37jy.js";
12
+ } from "./server-gzy5w8ya.js";
13
13
 
14
14
  // src/features/magic-context/memory/embedding-synapse.ts
15
15
  import { createHash } from "node:crypto";
@@ -1788,7 +1788,6 @@ function getSynapseBatchRequestKey(args) {
1788
1788
  required_fingerprint: args.fingerprint,
1789
1789
  required_epoch: args.tableEpoch,
1790
1790
  allow_equivalent: false,
1791
- accept_declared: false,
1792
1791
  ids: args.items.map((item) => item.id),
1793
1792
  content_sha256: args.items.map((item) => item.contentSha256),
1794
1793
  ...args.purpose === "query" ? { purpose: args.purpose } : {}
@@ -2177,8 +2176,7 @@ class SynapseEmbeddingProvider {
2177
2176
  model: metadata.model,
2178
2177
  required_fingerprint: metadata.fingerprint,
2179
2178
  required_epoch: metadata.table_epoch,
2180
- allow_equivalent: false,
2181
- accept_declared: false
2179
+ allow_equivalent: false
2182
2180
  };
2183
2181
  }
2184
2182
  batchRequest(items, requestKey, purpose) {
@@ -4,13 +4,13 @@ import {
4
4
  withSqliteBackgroundWriter2,
5
5
  withoutSqliteTransformPass2,
6
6
  isTransientSqliteError2
7
- } from "./server-beht37jy.js";
7
+ } from "./server-gzy5w8ya.js";
8
8
  import {
9
9
  DEFAULT_LOCAL_EMBEDDING_MODEL
10
- } from "./server-271qxsf5.js";
10
+ } from "./server-24g8r2d0.js";
11
11
  import {
12
12
  setBootQuietPeriodForTests
13
- } from "./server-rmygf5pn.js";
13
+ } from "./server-qjvk4a9t.js";
14
14
  import {
15
15
  isEmbeddingHostBusy2
16
16
  } from "./server-qt1qqasc.js";
@@ -20,34 +20,37 @@ import {
20
20
  import {
21
21
  sanitizeDiagnosticText,
22
22
  log2
23
- } from "./server-f2xf5gcb.js";
23
+ } from "./server-6495nmn9.js";
24
+ import {
25
+ createWorkerShutdown
26
+ } from "./server-cpjk5jd2.js";
24
27
  import {
25
28
  SYNAPSE_DEFAULT_MODEL,
26
29
  isSynapseEmbeddingTruncated,
27
30
  getSynapseBatchRequestKey,
28
31
  SynapseEmbeddingProvider
29
- } from "./server-6tmj0s7j.js";
32
+ } from "./server-ab1g0wn9.js";
30
33
  import {
31
34
  estimateTokens
32
- } from "./server-tgnbmwah.js";
35
+ } from "./server-3mz2qh5a.js";
33
36
  import {
34
- DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS,
35
- CHUNK_WINDOW_SAFETY_RATIO,
36
- normalizeCompartmentChunkMaxInputTokens,
37
- buildCanonicalChunkTextFromFts,
38
- buildCompartmentSummaryFallbackText,
39
- chunkCanonicalText,
40
- chunkEmbeddingWindowsAreCurrent,
41
- replaceCompartmentChunkEmbeddings,
42
- loadUnembeddedShadowChunkCandidates,
43
- loadUnembeddedCompartmentChunkCandidatesPolite,
44
- recordChunkEmbedBackoff,
45
- chunkWindowSourceKey,
46
- loadUnembeddedSessionChunkCandidatesPolite,
47
- countSessionCompartmentEmbedCoverage,
48
- countSessionCompartmentEmbedCoveragePolite,
49
- countUnembeddedSessionCompartmentsPolite
50
- } from "./server-46neh5fa.js";
37
+ DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2,
38
+ CHUNK_WINDOW_SAFETY_RATIO2,
39
+ normalizeCompartmentChunkMaxInputTokens2,
40
+ buildCanonicalChunkTextFromFts2,
41
+ buildCompartmentSummaryFallbackText2,
42
+ chunkCanonicalText2,
43
+ chunkEmbeddingWindowsAreCurrent2,
44
+ replaceCompartmentChunkEmbeddings2,
45
+ loadUnembeddedShadowChunkCandidates2,
46
+ loadUnembeddedCompartmentChunkCandidatesPolite2,
47
+ recordChunkEmbedBackoff2,
48
+ chunkWindowSourceKey2,
49
+ loadUnembeddedSessionChunkCandidatesPolite2,
50
+ countSessionCompartmentEmbedCoverage2,
51
+ countSessionCompartmentEmbedCoveragePolite2,
52
+ countUnembeddedSessionCompartmentsPolite2
53
+ } from "./server-62g58aaz.js";
51
54
  import {
52
55
  acquireGitSweepLease,
53
56
  renewGitSweepLease,
@@ -55,7 +58,7 @@ import {
55
58
  findMisScopedCompartmentChunkEmbeddingIdsForProject,
56
59
  recordSessionProjectIdentity,
57
60
  repairMisScopedCompartmentChunkEmbeddingsForProject
58
- } from "./server-hy3d3vsx.js";
61
+ } from "./server-bsgd4dk1.js";
59
62
  import {
60
63
  saveEmbeddingIfHashMatches,
61
64
  getMemoryEmbedCoverage,
@@ -65,12 +68,15 @@ import {
65
68
  dominantEmbeddingFailure,
66
69
  embeddingModelsMatch,
67
70
  resolveEmbeddingTextPrefixes,
71
+ getCachedLocalEmbeddingPooling,
72
+ logLocalEmbeddingPoolingDecisionOnce,
73
+ logLocalEmbeddingPoolingUnavailableOnce,
68
74
  getEmbeddingProviderIdentity,
69
75
  LocalEmbeddingProvider
70
- } from "./server-h1v0pyxb.js";
76
+ } from "./server-vr4szghm.js";
71
77
  import {
72
78
  logSlowWriteTransaction
73
- } from "./server-6pmqg9m4.js";
79
+ } from "./server-gyy4k6mf.js";
74
80
 
75
81
  // src/hooks/magic-context/embed-session-state.ts
76
82
  var embedPauseBySession = new Set;
@@ -202,6 +208,7 @@ function createChunkEmbeddingWriter(db) {
202
208
  const entry = new URL(import.meta.url.endsWith(".ts") ? "./chunk-embedding-write-worker.ts" : "./chunk-embedding-write-worker.js", import.meta.url);
203
209
  const timeout = db.prepare("PRAGMA busy_timeout").get().timeout;
204
210
  const worker = inRootAsyncContext2(() => new Worker(entry, { workerData: { path, harness: getHarness2(), timeout } }));
211
+ const shutdown = createWorkerShutdown(worker, "chunk-embedding-writer", timeout + 2000);
205
212
  let pending;
206
213
  let failure;
207
214
  let deadline;
@@ -232,7 +239,7 @@ function createChunkEmbeddingWriter(db) {
232
239
  pending = { resolve, reject };
233
240
  deadline = inRootAsyncContext2(() => setTimeout(() => {
234
241
  fail(new Error("chunk embedding database operation timed out; coverage will be rechecked"));
235
- worker.terminate();
242
+ shutdown.close();
236
243
  }, 30000));
237
244
  deadline.unref();
238
245
  worker.postMessage(message);
@@ -264,7 +271,7 @@ function createChunkEmbeddingWriter(db) {
264
271
  release: (project, holder) => request({ kind: "release", project, holder }),
265
272
  async close() {
266
273
  clearTimeout(deadline);
267
- await worker.terminate();
274
+ await shutdown.close();
268
275
  }
269
276
  };
270
277
  }
@@ -525,7 +532,7 @@ function responseSlots(items, inputCount) {
525
532
  return slots;
526
533
  }
527
534
  function capEmbeddingInput(input, maxInputTokens, purpose) {
528
- const ratio = purpose === "query" ? CHUNK_WINDOW_SAFETY_RATIO : 1;
535
+ const ratio = purpose === "query" ? CHUNK_WINDOW_SAFETY_RATIO2 : 1;
529
536
  const budget = Math.max(1, Math.floor(maxInputTokens * ratio));
530
537
  if (estimateTokens(input) <= budget)
531
538
  return input;
@@ -635,12 +642,12 @@ class OpenAICompatibleEmbeddingProvider {
635
642
  this.truncate = options.truncate?.trim() ?? "";
636
643
  this.rateLimitKey = rateLimitStateKey(this.endpoint, this.apiKey);
637
644
  const maxInputTokensSet = typeof options.maxInputTokens === "number" && Number.isFinite(options.maxInputTokens);
638
- this.maxInputTokens = maxInputTokensSet ? Math.max(1, Math.floor(options.maxInputTokens)) : DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS;
645
+ this.maxInputTokens = maxInputTokensSet ? Math.max(1, Math.floor(options.maxInputTokens)) : DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2;
639
646
  if (!maxInputTokensSet && this.endpoint && this.model) {
640
647
  const warningKey = `${this.endpoint}\x00${this.model}`;
641
648
  if (!maxInputTokensWarnings.has(warningKey)) {
642
649
  maxInputTokensWarnings.add(warningKey);
643
- log2(`[magic-context] embedding.max_input_tokens is not set for openai-compatible model "${sanitizeDiagnosticText(this.model)}"; chunk embeddings use the ${DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS}-token default, which is sized for the bundled local model and splits history into small pieces. Set embedding.max_input_tokens to the model's input limit (changing it re-embeds stored chunks once).`);
650
+ log2(`[magic-context] embedding.max_input_tokens is not set for openai-compatible model "${sanitizeDiagnosticText(this.model)}"; chunk embeddings use the ${DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2}-token default, which is sized for the bundled local model and splits history into small pieces. Set embedding.max_input_tokens to the model's input limit (changing it re-embeds stored chunks once).`);
644
651
  }
645
652
  }
646
653
  this.modelId = getEmbeddingProviderIdentity({
@@ -1062,6 +1069,23 @@ var EMBED_SLICE_RETRY_BASE_MS = 250;
1062
1069
  var EMBED_SLOW_FAILURE_NO_RETRY_MS = 1e4;
1063
1070
  var MAX_CONSECUTIVE_FAILED_BATCHES = 3;
1064
1071
  var projectRegistrations = new Map;
1072
+ var projectContextUsers = new Map;
1073
+ function retainProjectEmbedding2(projectIdentity) {
1074
+ projectContextUsers.set(projectIdentity, (projectContextUsers.get(projectIdentity) ?? 0) + 1);
1075
+ let released = false;
1076
+ return () => {
1077
+ if (released)
1078
+ return;
1079
+ released = true;
1080
+ const remaining = (projectContextUsers.get(projectIdentity) ?? 1) - 1;
1081
+ if (remaining > 0) {
1082
+ projectContextUsers.set(projectIdentity, remaining);
1083
+ } else {
1084
+ projectContextUsers.delete(projectIdentity);
1085
+ unregisterProjectEmbedding2(projectIdentity);
1086
+ }
1087
+ };
1088
+ }
1065
1089
  var shadowRegistrations = new Map;
1066
1090
  var shadowQueue = [];
1067
1091
  var shadowWorker = null;
@@ -1229,7 +1253,7 @@ function resolveEmbeddingConfig(config) {
1229
1253
  model: config?.model?.trim() || DEFAULT_LOCAL_EMBEDDING_MODEL,
1230
1254
  local_runtime: config?.local_runtime ?? "auto",
1231
1255
  ...config?.max_input_tokens ? {
1232
- max_input_tokens: normalizeCompartmentChunkMaxInputTokens(config.max_input_tokens)
1256
+ max_input_tokens: normalizeCompartmentChunkMaxInputTokens2(config.max_input_tokens)
1233
1257
  } : {},
1234
1258
  ...config?.local_dtype ? { local_dtype: config.local_dtype } : {}
1235
1259
  };
@@ -1250,7 +1274,7 @@ function resolveEmbeddingConfig(config) {
1250
1274
  ...config.document_prefix !== undefined ? { document_prefix: config.document_prefix } : {},
1251
1275
  ...truncate ? { truncate } : {},
1252
1276
  ...config.max_input_tokens ? {
1253
- max_input_tokens: normalizeCompartmentChunkMaxInputTokens(config.max_input_tokens)
1277
+ max_input_tokens: normalizeCompartmentChunkMaxInputTokens2(config.max_input_tokens)
1254
1278
  } : {}
1255
1279
  };
1256
1280
  }
@@ -1263,7 +1287,7 @@ function resolveEmbeddingConfig(config) {
1263
1287
  return {
1264
1288
  provider: "synapse",
1265
1289
  model: synapse.model?.trim() || "gte-modernbert-base-f16",
1266
- max_input_tokens: normalizeCompartmentChunkMaxInputTokens(descriptor?.max_tokens ?? synapse.max_input_tokens),
1290
+ max_input_tokens: normalizeCompartmentChunkMaxInputTokens2(descriptor?.max_tokens ?? synapse.max_input_tokens),
1267
1291
  ...synapse.synapse_connection_file ? { synapse_connection_file: synapse.synapse_connection_file } : {},
1268
1292
  ...synapse.synapse_fingerprint ? { synapse_fingerprint: synapse.synapse_fingerprint } : {},
1269
1293
  ...typeof synapse.synapse_table_epoch === "number" ? { synapse_table_epoch: synapse.synapse_table_epoch } : {},
@@ -1351,7 +1375,7 @@ function getChunkEmbeddingModelId(config, providerIdentity) {
1351
1375
  const chunkIdentity = {
1352
1376
  providerIdentity,
1353
1377
  chunkerVersion: 2,
1354
- maxInputTokens: normalizeCompartmentChunkMaxInputTokens("max_input_tokens" in config ? config.max_input_tokens : undefined),
1378
+ maxInputTokens: normalizeCompartmentChunkMaxInputTokens2("max_input_tokens" in config ? config.max_input_tokens : undefined),
1355
1379
  truncate: config.provider === "openai-compatible" ? config.truncate ?? "" : ""
1356
1380
  };
1357
1381
  return `${providerIdentity}:chunk:${sha256Prefix(stableStringify(chunkIdentity))}`;
@@ -1677,6 +1701,17 @@ async function drainStaleEmbeddingIdentitiesForProject2(db, projectIdentity, bud
1677
1701
  }
1678
1702
  function registerProjectEmbedding2(db, projectIdentity, config, features, sourceDirectory) {
1679
1703
  const resolvedConfig = resolveEmbeddingConfig(config);
1704
+ if (resolvedConfig.provider === "local") {
1705
+ const pooling = getCachedLocalEmbeddingPooling(resolvedConfig.model?.trim() || DEFAULT_LOCAL_EMBEDDING_MODEL);
1706
+ if (pooling?.status === "unresolved" || !pooling) {
1707
+ logLocalEmbeddingPoolingUnavailableOnce(resolvedConfig.model?.trim() || DEFAULT_LOCAL_EMBEDDING_MODEL, pooling?.reason ?? "pooling metadata has not been resolved by the background embedding bootstrap", log2);
1708
+ } else {
1709
+ logLocalEmbeddingPoolingDecisionOnce(resolvedConfig.model?.trim() || DEFAULT_LOCAL_EMBEDDING_MODEL, pooling, log2);
1710
+ }
1711
+ if (pooling?.status === "unsupported") {
1712
+ return registerProjectInObservationMode2(db, projectIdentity, sourceDirectory, resolvedConfig, pooling ? `local model pooling is unsupported: ${pooling.reason}` : "local model pooling metadata has not been resolved");
1713
+ }
1714
+ }
1680
1715
  const providerIdentity = getEmbeddingProviderIdentity(resolvedConfig);
1681
1716
  const runtimeFingerprint = getRuntimeFingerprint(resolvedConfig);
1682
1717
  const chunkModelId = getChunkEmbeddingModelId(resolvedConfig, providerIdentity);
@@ -1872,7 +1907,7 @@ function shadowBackfillMissingBase(scope, primaryModelId, shadowModelId, project
1872
1907
  }
1873
1908
  function shadowBackfillMissingIds(db, projectIdentity, scope, primaryModelId, shadowModelId, limit, shadowMaxInputTokens) {
1874
1909
  if (scope === "chunk") {
1875
- return loadUnembeddedShadowChunkCandidates(db, projectIdentity, primaryModelId, shadowModelId, limit, shadowMaxInputTokens).map((candidate) => String(candidate.id));
1910
+ return loadUnembeddedShadowChunkCandidates2(db, projectIdentity, primaryModelId, shadowModelId, limit, shadowMaxInputTokens).map((candidate) => String(candidate.id));
1876
1911
  }
1877
1912
  const { sql, params, orderBy } = shadowBackfillMissingBase(scope, primaryModelId, shadowModelId, projectIdentity);
1878
1913
  const rows = db.prepare(`${sql}${orderBy} LIMIT ?`).all(...params, limit);
@@ -1880,7 +1915,7 @@ function shadowBackfillMissingIds(db, projectIdentity, scope, primaryModelId, sh
1880
1915
  }
1881
1916
  function countShadowBackfillMissing(db, projectIdentity, scope, primaryModelId, shadowModelId, shadowMaxInputTokens) {
1882
1917
  if (scope === "chunk") {
1883
- return loadUnembeddedShadowChunkCandidates(db, projectIdentity, primaryModelId, shadowModelId, Number.MAX_SAFE_INTEGER, shadowMaxInputTokens).length;
1918
+ return loadUnembeddedShadowChunkCandidates2(db, projectIdentity, primaryModelId, shadowModelId, Number.MAX_SAFE_INTEGER, shadowMaxInputTokens).length;
1884
1919
  }
1885
1920
  const { sql, params } = shadowBackfillMissingBase(scope, primaryModelId, shadowModelId, projectIdentity);
1886
1921
  return db.prepare(`SELECT COUNT(*) AS count FROM (${sql})`).get(...params).count;
@@ -1889,7 +1924,7 @@ function shadowModelIdForScope(registration, scope) {
1889
1924
  return scope === "chunk" ? registration.chunkModelId : registration.modelId;
1890
1925
  }
1891
1926
  function shadowMaxInputTokensFor(registration) {
1892
- return normalizeCompartmentChunkMaxInputTokens("max_input_tokens" in registration.config ? registration.config.max_input_tokens : undefined);
1927
+ return normalizeCompartmentChunkMaxInputTokens2("max_input_tokens" in registration.config ? registration.config.max_input_tokens : undefined);
1893
1928
  }
1894
1929
  function shadowBackfillCohortFingerprint(db, projectIdentity, scope, primaryModelId) {
1895
1930
  if (scope === "memory") {
@@ -2227,14 +2262,14 @@ async function processShadowQueueItem(item) {
2227
2262
  let ftsMappingIncomplete = false;
2228
2263
  let emptyCanonicalText = false;
2229
2264
  for (const candidate of candidates) {
2230
- const mappedText = buildCanonicalChunkTextFromFts(db, candidate.session_id, candidate.start_message, candidate.end_message);
2265
+ const mappedText = buildCanonicalChunkTextFromFts2(db, candidate.session_id, candidate.start_message, candidate.end_message);
2231
2266
  if (mappedText === null) {
2232
2267
  ftsMappingIncomplete = true;
2233
2268
  } else {
2234
- const text = mappedText || buildCompartmentSummaryFallbackText(db, candidate.id);
2269
+ const text = mappedText || buildCompartmentSummaryFallbackText2(db, candidate.id);
2235
2270
  const shadowMaxInputTokens = shadowMaxInputTokensFor(registration);
2236
- const windows = chunkCanonicalText(text, candidate.start_message, candidate.end_message, shadowMaxInputTokens);
2237
- const windowSourceKey = chunkWindowSourceKey(text, candidate.start_message, candidate.end_message, shadowMaxInputTokens);
2271
+ const windows = chunkCanonicalText2(text, candidate.start_message, candidate.end_message, shadowMaxInputTokens);
2272
+ const windowSourceKey = chunkWindowSourceKey2(text, candidate.start_message, candidate.end_message, shadowMaxInputTokens);
2238
2273
  if (windows.length > 0)
2239
2274
  prepared.push({ candidate, windows, windowSourceKey });
2240
2275
  else
@@ -2275,7 +2310,7 @@ async function processShadowQueueItem(item) {
2275
2310
  ] : [];
2276
2311
  });
2277
2312
  if (rows.length === item.windows.length) {
2278
- replaceCompartmentChunkEmbeddings(db, rows, item.windowSourceKey);
2313
+ replaceCompartmentChunkEmbeddings2(db, rows, item.windowSourceKey);
2279
2314
  writes += 1;
2280
2315
  } else {
2281
2316
  partialVectorSet = true;
@@ -2410,7 +2445,7 @@ function getProjectChunkEmbeddingModelId2(projectIdentity) {
2410
2445
  function getProjectEmbeddingMaxInputTokens2(projectIdentity) {
2411
2446
  const registration = projectRegistrations.get(projectIdentity);
2412
2447
  const configMax = registration?.config && "max_input_tokens" in registration.config ? registration.config.max_input_tokens : undefined;
2413
- return normalizeCompartmentChunkMaxInputTokens(registration?.provider?.maxInputTokens ?? configMax);
2448
+ return normalizeCompartmentChunkMaxInputTokens2(registration?.provider?.maxInputTokens ?? configMax);
2414
2449
  }
2415
2450
  function getOrCreateProjectProvider(registration) {
2416
2451
  if (registration.providerIdentity === OFF_PROVIDER_IDENTITY || registration.observationMode) {
@@ -2668,7 +2703,7 @@ async function embedCompartmentChunkBatch(db, projectIdentity, batchSize, signal
2668
2703
  const priorModels = db.prepare(`SELECT COUNT(*) AS total,
2669
2704
  COALESCE(MAX(model_id = ?), 0) AS current
2670
2705
  FROM compartment_chunk_embeddings WHERE compartment_id = ?`);
2671
- const candidates = await loadUnembeddedCompartmentChunkCandidatesPolite(db, projectIdentity, snapshot.chunkModelId, batchSize, getProjectEmbeddingMaxInputTokens2(projectIdentity), true, (candidate) => {
2706
+ const candidates = await loadUnembeddedCompartmentChunkCandidatesPolite2(db, projectIdentity, snapshot.chunkModelId, batchSize, getProjectEmbeddingMaxInputTokens2(projectIdentity), true, (candidate) => {
2672
2707
  const activity = activeEmbeddingSessions.get(candidate.sessionId);
2673
2708
  if (activity?.project === projectIdentity && activity.model === snapshot.chunkModelId && !embedPauseBySession.has(candidate.sessionId))
2674
2709
  return true;
@@ -2694,27 +2729,27 @@ async function embedCandidateChunkBatch(db, projectIdentity, modelId, candidates
2694
2729
  const prepared = [];
2695
2730
  for (const candidate of candidates) {
2696
2731
  await new Promise((resolve) => setTimeout(resolve, 0));
2697
- const mappedText = buildCanonicalChunkTextFromFts(db, candidate.sessionId, candidate.startMessage, candidate.endMessage);
2732
+ const mappedText = buildCanonicalChunkTextFromFts2(db, candidate.sessionId, candidate.startMessage, candidate.endMessage);
2698
2733
  if (mappedText === null)
2699
2734
  continue;
2700
- const canonicalText = mappedText || buildCompartmentSummaryFallbackText(db, candidate.id);
2735
+ const canonicalText = mappedText || buildCompartmentSummaryFallbackText2(db, candidate.id);
2701
2736
  if (canonicalText.length === 0) {
2702
2737
  if (writer)
2703
2738
  await writer.backoff(candidate, projectIdentity, modelId);
2704
2739
  else
2705
- recordChunkEmbedBackoff(db, candidate, projectIdentity, modelId);
2740
+ recordChunkEmbedBackoff2(db, candidate, projectIdentity, modelId);
2706
2741
  noWork.push(candidate.id);
2707
2742
  continue;
2708
2743
  }
2709
- const windows = chunkCanonicalText(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens);
2710
- if (windows.length === 0 || chunkEmbeddingWindowsAreCurrent(db, candidate.id, modelId, windows, projectIdentity)) {
2744
+ const windows = chunkCanonicalText2(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens);
2745
+ if (windows.length === 0 || chunkEmbeddingWindowsAreCurrent2(db, candidate.id, modelId, windows, projectIdentity)) {
2711
2746
  noWork.push(candidate.id);
2712
2747
  continue;
2713
2748
  }
2714
2749
  prepared.push({
2715
2750
  candidate,
2716
2751
  windows,
2717
- windowSourceKey: chunkWindowSourceKey(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens)
2752
+ windowSourceKey: chunkWindowSourceKey2(canonicalText, candidate.startMessage, candidate.endMessage, maxInputTokens)
2718
2753
  });
2719
2754
  }
2720
2755
  if (prepared.length === 0)
@@ -2778,7 +2813,7 @@ async function embedCandidateChunkBatch(db, projectIdentity, modelId, candidates
2778
2813
  if (writer)
2779
2814
  await writer.replace(rows, item.windowSourceKey);
2780
2815
  else
2781
- replaceCompartmentChunkEmbeddings(db, rows, item.windowSourceKey);
2816
+ replaceCompartmentChunkEmbeddings2(db, rows, item.windowSourceKey);
2782
2817
  persistedIds.add(item.candidate.id);
2783
2818
  enqueueShadowEmbeddingItems2(projectIdentity, "chunk", [
2784
2819
  String(item.candidate.id)
@@ -2806,7 +2841,7 @@ async function embedCandidateChunkBatch(db, projectIdentity, modelId, candidates
2806
2841
  if (writer)
2807
2842
  await writer.backoff(item.candidate, projectIdentity, modelId);
2808
2843
  else
2809
- recordChunkEmbedBackoff(db, item.candidate, projectIdentity, modelId);
2844
+ recordChunkEmbedBackoff2(db, item.candidate, projectIdentity, modelId);
2810
2845
  failed.push(item.candidate.id);
2811
2846
  }
2812
2847
  }
@@ -2880,7 +2915,7 @@ async function embedSessionCompartmentChunks2(db, projectIdentity, sessionId, op
2880
2915
  else
2881
2916
  recordSessionProjectIdentity(db, sessionId, projectIdentity);
2882
2917
  const maxInputTokens = getProjectEmbeddingMaxInputTokens2(projectIdentity);
2883
- const total = writer ? await writer.count(projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens) : await countUnembeddedSessionCompartmentsPolite(db, projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens);
2918
+ const total = writer ? await writer.count(projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens) : await countUnembeddedSessionCompartmentsPolite2(db, projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens);
2884
2919
  const holderId = `session-embed-${randomUUID()}`;
2885
2920
  const lease = writer ? await writer.acquire(projectIdentity, holderId) : acquireGitSweepLease(db, projectIdentity, holderId, { ignoreCooldown: true });
2886
2921
  if (!lease.acquired)
@@ -2923,7 +2958,7 @@ async function embedSessionCompartmentChunks2(db, projectIdentity, sessionId, op
2923
2958
  break;
2924
2959
  }
2925
2960
  }
2926
- const candidates = writer ? await writer.candidates(projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds], maxInputTokens) : await loadUnembeddedSessionChunkCandidatesPolite(db, projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds], maxInputTokens, true);
2961
+ const candidates = writer ? await writer.candidates(projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds], maxInputTokens) : await loadUnembeddedSessionChunkCandidatesPolite2(db, projectIdentity, sessionId, snapshot.chunkModelId, batchSize, [...skipIds, ...failedIds], maxInputTokens, true);
2927
2962
  if (candidates.length === 0)
2928
2963
  break;
2929
2964
  const {
@@ -2973,7 +3008,7 @@ async function embedSessionCompartmentChunks2(db, projectIdentity, sessionId, op
2973
3008
  if (aborted)
2974
3009
  return { status: "aborted", embedded, total, failed: failedIds.length };
2975
3010
  if (providerDown || failedIds.length > 0) {
2976
- const remaining = Math.max(failedIds.length, (writer ? await writer.count(projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens) : await countUnembeddedSessionCompartmentsPolite(db, projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens)) - skipIds.length);
3011
+ const remaining = Math.max(failedIds.length, (writer ? await writer.count(projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens) : await countUnembeddedSessionCompartmentsPolite2(db, projectIdentity, sessionId, snapshot.chunkModelId, maxInputTokens)) - skipIds.length);
2977
3012
  if (remaining > 0) {
2978
3013
  return {
2979
3014
  status: "stalled",
@@ -3001,7 +3036,7 @@ function getEmbeddingCoverageStatus2(db, projectIdentity, sessionId) {
3001
3036
  shadowBackfillStalls: listShadowBackfillStalls2(db, projectIdentity)
3002
3037
  };
3003
3038
  }
3004
- const session = countSessionCompartmentEmbedCoverage(db, projectIdentity, sessionId, snapshot.chunkModelId, getProjectEmbeddingMaxInputTokens2(projectIdentity));
3039
+ const session = countSessionCompartmentEmbedCoverage2(db, projectIdentity, sessionId, snapshot.chunkModelId, getProjectEmbeddingMaxInputTokens2(projectIdentity));
3005
3040
  const memories = snapshot.enabled ? getMemoryEmbedCoverage(db, projectIdentity, snapshot.modelId) : { embedded: 0, total: 0, memoryEnabled: false };
3006
3041
  const gitEnabled = snapshot.gitCommitEnabled;
3007
3042
  const commits = gitEnabled ? {
@@ -3025,7 +3060,7 @@ async function getAutoEmbeddingSessionCoverage2(db, projectIdentity, sessionId)
3025
3060
  if (!snapshot?.historyEnabled || snapshot.chunkModelId === "off") {
3026
3061
  return { enabled: false, embedded: 0, total: 0 };
3027
3062
  }
3028
- const coverage = await countSessionCompartmentEmbedCoveragePolite(db, projectIdentity, sessionId, snapshot.chunkModelId, getProjectEmbeddingMaxInputTokens2(projectIdentity));
3063
+ const coverage = await countSessionCompartmentEmbedCoveragePolite2(db, projectIdentity, sessionId, snapshot.chunkModelId, getProjectEmbeddingMaxInputTokens2(projectIdentity));
3029
3064
  return { enabled: true, ...coverage };
3030
3065
  }
3031
3066
  async function sweepAllRegisteredProjects2(db, batchSize = 10) {
@@ -3093,6 +3128,7 @@ function _resetProjectEmbeddingRegistryForTests2() {
3093
3128
  disposeProvider(registration.provider);
3094
3129
  }
3095
3130
  projectRegistrations.clear();
3131
+ projectContextUsers.clear();
3096
3132
  shadowRegistrations.clear();
3097
3133
  shadowQueue.length = 0;
3098
3134
  pendingShadowBackfills.clear();
@@ -3108,4 +3144,4 @@ function _resetProjectEmbeddingRegistryForTests2() {
3108
3144
  setBootQuietPeriodForTests(null);
3109
3145
  }
3110
3146
 
3111
- export { embedPauseBySession, embedRunStateBySession, activeEmbeddingSessions, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, autoEmbedRetryAfterBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, drainBackgroundBatches, recordEmbeddingMeasurement, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitSha, enforceProjectCap, OpenAICompatibleEmbeddingProvider, describeShadowBackfillWriteRefusal2, listShadowBackfillStalls2, getShadowBackfillStopReason2, markProjectLoadUntrusted2, contentSha2562, drainProjectEmbeddingIdentityMaintenance2, drainStaleEmbeddingIdentitiesForProject2, registerProjectEmbedding2, registerProjectShadowEmbedding2, getShadowEmbeddingMeasurementCohort2, getPrimaryEmbeddingMeasurementCohort2, embedShadowTextForProject2, enqueueShadowEmbeddingItems2, getShadowBackfillRemaining2, flushShadowEmbeddingBacklog2, registerProjectInObservationMode2, unregisterProjectShadowEmbedding2, unregisterProjectEmbedding2, getProjectEmbeddingSnapshot2, installProjectEmbeddingSearchBridge2, getProjectChunkEmbeddingModelId2, getProjectEmbeddingMaxInputTokens2, embedTextForProject2, embedBatchForProject2, embedItemsForProject2, embedUnembeddedMemoriesForProject2, embedUnembeddedMemoriesForProjectOutcome2, drainCommitBacklogForProject2, embedUnembeddedCompartmentChunksForProject2, embedSessionCompartmentChunks2, getEmbeddingCoverageStatus2, getAutoEmbeddingSessionCoverage2, sweepAllRegisteredProjects2, _setTestProviderFactoryForProject2, _resetProjectEmbeddingRegistryForTests2 };
3147
+ export { embedPauseBySession, embedRunStateBySession, activeEmbeddingSessions, autoEmbedAttemptedBySession, autoEmbedIdentityBySession, autoEmbedRetryAfterBySession, invalidateAutoEmbedSession, getEmbedDrainUiStatus, clearEmbedSessionState, drainBackgroundBatches, recordEmbeddingMeasurement, saveCommitEmbedding, loadProjectCommitEmbeddings, loadUnembeddedCommits, countEmbeddedCommits, upsertCommits, getLatestIndexedCommitSha, enforceProjectCap, OpenAICompatibleEmbeddingProvider, describeShadowBackfillWriteRefusal2, listShadowBackfillStalls2, retainProjectEmbedding2, getShadowBackfillStopReason2, markProjectLoadUntrusted2, contentSha2562, drainProjectEmbeddingIdentityMaintenance2, drainStaleEmbeddingIdentitiesForProject2, registerProjectEmbedding2, registerProjectShadowEmbedding2, getShadowEmbeddingMeasurementCohort2, getPrimaryEmbeddingMeasurementCohort2, embedShadowTextForProject2, enqueueShadowEmbeddingItems2, getShadowBackfillRemaining2, flushShadowEmbeddingBacklog2, registerProjectInObservationMode2, unregisterProjectShadowEmbedding2, unregisterProjectEmbedding2, getProjectEmbeddingSnapshot2, installProjectEmbeddingSearchBridge2, getProjectChunkEmbeddingModelId2, getProjectEmbeddingMaxInputTokens2, embedTextForProject2, embedBatchForProject2, embedItemsForProject2, embedUnembeddedMemoriesForProject2, embedUnembeddedMemoriesForProjectOutcome2, drainCommitBacklogForProject2, embedUnembeddedCompartmentChunksForProject2, embedSessionCompartmentChunks2, getEmbeddingCoverageStatus2, getAutoEmbeddingSessionCoverage2, sweepAllRegisteredProjects2, _setTestProviderFactoryForProject2, _resetProjectEmbeddingRegistryForTests2 };
@@ -3,10 +3,10 @@ import {
3
3
  } from "./server-pavzsdc6.js";
4
4
  import {
5
5
  isUserHomeDirectory
6
- } from "./server-rmygf5pn.js";
6
+ } from "./server-qjvk4a9t.js";
7
7
  import {
8
8
  logSlowWriteTransaction
9
- } from "./server-6pmqg9m4.js";
9
+ } from "./server-gyy4k6mf.js";
10
10
 
11
11
  // src/features/magic-context/git-commits/sweep-coordinator.ts
12
12
  var GIT_SWEEP_COOLDOWN_MS = 10 * 60 * 1000;