@cortexkit/opencode-magic-context 0.48.0 → 0.49.1

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 (304) hide show
  1. package/dist/{announcement-fp14dw0n.js → announcement-hdbkt8v5.js} +1 -1
  2. package/dist/auto-search-worker.js +3 -3
  3. package/dist/config/{mural-model-deprecation.d.ts → deprecated-config.d.ts} +4 -1
  4. package/dist/config/deprecated-config.d.ts.map +1 -0
  5. package/dist/config/index.d.ts.map +1 -1
  6. package/dist/config/project-security.d.ts +2 -2
  7. package/dist/config/schema/magic-context.d.ts +4 -4
  8. package/dist/config/schema/magic-context.d.ts.map +1 -1
  9. package/dist/{conflict-warning-hook-w8cykrnf.js → conflict-warning-hook-asnt6hfc.js} +7 -7
  10. package/dist/{context-m0cy262m.js → context-tfyhtdcs.js} +187 -68
  11. package/dist/{derive-budgets-sg0xsq7s.js → derive-budgets-j4ry8j8n.js} +2 -2
  12. package/dist/embedding-backfill-wyc3ykyf.js +21 -0
  13. package/dist/embedding-worker-process.js +30 -0
  14. package/dist/embedding-worker.js +6 -6
  15. package/dist/features/magic-context/dreamer/task-registry.d.ts +2 -3
  16. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  17. package/dist/features/magic-context/git-commits/search-git-commits.d.ts +2 -0
  18. package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
  19. package/dist/features/magic-context/memory/embedding-worker-client.d.ts +8 -1
  20. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  21. package/dist/features/magic-context/memory/embedding-worker-process.d.ts +2 -0
  22. package/dist/features/magic-context/memory/embedding-worker-process.d.ts.map +1 -0
  23. package/dist/features/magic-context/memory/onnx-telemetry.d.ts +3 -0
  24. package/dist/features/magic-context/memory/onnx-telemetry.d.ts.map +1 -0
  25. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  26. package/dist/features/magic-context/overflow-detection.d.ts +1 -2
  27. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  28. package/dist/features/magic-context/pi-content-decisions.d.ts +1 -1
  29. package/dist/features/magic-context/pi-content-decisions.d.ts.map +1 -1
  30. package/dist/features/magic-context/search-rerank.d.ts +35 -0
  31. package/dist/features/magic-context/search-rerank.d.ts.map +1 -0
  32. package/dist/features/magic-context/search.d.ts +11 -0
  33. package/dist/features/magic-context/search.d.ts.map +1 -1
  34. package/dist/features/magic-context/storage-meta-persisted.d.ts +13 -2
  35. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  36. package/dist/features/magic-context/storage-meta-session.d.ts +1 -1
  37. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  38. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  39. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  40. package/dist/features/magic-context/storage-session-tables.d.ts +2 -0
  41. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  42. package/dist/features/magic-context/storage-tag-identity-revision.d.ts +29 -9
  43. package/dist/features/magic-context/storage-tag-identity-revision.d.ts.map +1 -1
  44. package/dist/features/magic-context/storage-tags.d.ts +9 -0
  45. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  46. package/dist/features/magic-context/storage.d.ts +1 -1
  47. package/dist/features/magic-context/storage.d.ts.map +1 -1
  48. package/dist/features/magic-context/tagger.d.ts +2 -0
  49. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  50. package/dist/features/magic-context/transform-decision-log.d.ts +4 -1
  51. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  52. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +1 -0
  53. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/auto-search-replay.fixture.d.ts +24 -0
  56. package/dist/hooks/magic-context/auto-search-replay.fixture.d.ts.map +1 -0
  57. package/dist/hooks/magic-context/auto-search-runner.d.ts +1 -1
  58. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  59. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +2 -0
  60. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/command-handler.d.ts +2 -0
  62. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/emergency-fail-closed.d.ts +28 -0
  64. package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +1 -0
  67. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/historian-host-runner.d.ts +8 -0
  69. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
  70. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/hook.d.ts +3 -1
  72. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  74. package/dist/hooks/magic-context/latest-thinking-recovery.d.ts +7 -0
  75. package/dist/hooks/magic-context/latest-thinking-recovery.d.ts.map +1 -1
  76. package/dist/hooks/magic-context/lkg-measured-request.d.ts +3 -1
  77. package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/lkg-persist.d.ts +8 -14
  79. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +62 -0
  81. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -0
  82. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +38 -0
  83. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -0
  84. package/dist/hooks/magic-context/lkg-replay.d.ts +3 -1
  85. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  86. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/opaque-thinking.d.ts +12 -0
  88. package/dist/hooks/magic-context/opaque-thinking.d.ts.map +1 -0
  89. package/dist/hooks/magic-context/pass-outcome.d.ts +3 -2
  90. package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/pending-materialization.d.ts +8 -0
  92. package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -0
  93. package/dist/hooks/magic-context/read-session-chunk.d.ts +7 -1
  94. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/read-session-db.d.ts +3 -0
  96. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/read-session-raw.d.ts +35 -0
  98. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  100. package/dist/hooks/magic-context/rust-mode-transform.d.ts +37 -0
  101. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/shared-compartment-boundaries.d.ts +8 -1
  103. package/dist/hooks/magic-context/shared-compartment-boundaries.d.ts.map +1 -1
  104. package/dist/hooks/magic-context/strict-thinking-prefix.d.ts +8 -0
  105. package/dist/hooks/magic-context/strict-thinking-prefix.d.ts.map +1 -0
  106. package/dist/hooks/magic-context/strip-content.d.ts +5 -2
  107. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  108. package/dist/hooks/magic-context/system-date-refresh.d.ts +29 -0
  109. package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -0
  110. package/dist/hooks/magic-context/system-prompt-dates.d.ts +6 -0
  111. package/dist/hooks/magic-context/system-prompt-dates.d.ts.map +1 -0
  112. package/dist/hooks/magic-context/system-prompt-delivery.d.ts +47 -0
  113. package/dist/hooks/magic-context/system-prompt-delivery.d.ts.map +1 -0
  114. package/dist/hooks/magic-context/system-prompt-hash.d.ts +4 -0
  115. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  116. package/dist/hooks/magic-context/tag-messages.d.ts +8 -0
  117. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  118. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +15 -0
  119. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  120. package/dist/hooks/magic-context/transform.d.ts +7 -0
  121. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  122. package/dist/{index-ty64eqcn.js → index-0pjvpfkf.js} +24 -4
  123. package/dist/{index-db7zwa3v.js → index-1bt88epp.js} +93 -9
  124. package/dist/{index-2y0s2hep.js → index-4mjhqadz.js} +1 -1
  125. package/dist/index-6m7rdv7y.js +733 -0
  126. package/dist/{index-k1xb52kd.js → index-6tfxmc4n.js} +11 -11
  127. package/dist/{index-fbv1dn35.js → index-7w18gg78.js} +26 -2
  128. package/dist/{index-7mx8v0pw.js → index-att4bfan.js} +4 -4
  129. package/dist/{index-mmyh6d8f.js → index-eypn4ba6.js} +11 -6
  130. package/dist/{index-q2tqeqde.js → index-fdtkt5r1.js} +1229 -78
  131. package/dist/{index-c43kr12f.js → index-fg00p1cg.js} +42 -40
  132. package/dist/{v2/server-1bc61ans.js → index-fvnzcnww.js} +44 -1
  133. package/dist/index-gbmqa9x9.js +1170 -0
  134. package/dist/{index-knh4y330.js → index-gzky5rva.js} +31 -49
  135. package/dist/{index-0qhce371.js → index-h2wc01qk.js} +2 -2
  136. package/dist/{index-dhwzyd54.js → index-h5zfkjyk.js} +160 -25
  137. package/dist/{index-bhvjj0ys.js → index-k6xvbj2e.js} +255 -1075
  138. package/dist/{index-0w56v4fm.js → index-mw7c950g.js} +1 -1
  139. package/dist/{index-8j7gqj40.js → index-nsjyysj0.js} +6 -2
  140. package/dist/{index-k9nnwad5.js → index-nydv6g8r.js} +44 -7
  141. package/dist/{index-f0h6xwqm.js → index-p0n5ryq8.js} +304 -960
  142. package/dist/{index-pg50n748.js → index-p1hnwfd8.js} +4 -4
  143. package/dist/{index-1qb0z7wa.js → index-qx53vezw.js} +1 -1
  144. package/dist/{index-5zygecde.js → index-r2zcs71c.js} +8 -6
  145. package/dist/{index-cb7emxgj.js → index-rafsaxac.js} +336 -6
  146. package/dist/{index-z8e0psj8.js → index-s7fc0fkn.js} +3 -3
  147. package/dist/{index-14cjxt20.js → index-sfhndpcb.js} +505 -11
  148. package/dist/index-sv0bb7vg.js +6972 -0
  149. package/dist/{index-jcbd3znx.js → index-tqf7yg27.js} +1 -1
  150. package/dist/{index-72nhv486.js → index-vkbqdnkj.js} +2 -2
  151. package/dist/{index-pdecwzrd.js → index-w23dh319.js} +18 -259
  152. package/dist/{index-yq8n9qcb.js → index-xgrwmj82.js} +4 -4
  153. package/dist/{index-0an7742d.js → index-xnanvj3w.js} +1364 -2278
  154. package/dist/{index-eeezr5zz.js → index-z1tjp257.js} +1 -1
  155. package/dist/{index-692jzy0p.js → index-zfzdpeq2.js} +2279 -4061
  156. package/dist/{index-q7h7csab.js → index-zg8yq4ya.js} +34 -749
  157. package/dist/index.d.ts.map +1 -1
  158. package/dist/index.js +241 -76
  159. package/dist/{logger-d3wex3dz.js → logger-ewak5q1s.js} +1 -1
  160. package/dist/{message-index-bounded-7ezbgddp.js → message-index-bounded-hqktkhdy.js} +15 -14
  161. package/dist/{message-time-backfill-brbd63hv.js → message-time-backfill-8x06r9kx.js} +2 -2
  162. package/dist/migration-worker.js +11 -10
  163. package/dist/plugin/hooks/create-session-hooks.d.ts +5 -1
  164. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  165. package/dist/plugin/messages-transform.d.ts.map +1 -1
  166. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  167. package/dist/plugin/tool-registry.d.ts.map +1 -1
  168. package/dist/{project-embedding-registry-7qzptcw7.js → project-embedding-registry-0gv3h6y8.js} +10 -10
  169. package/dist/raw-ordinal-warmup-worker.js +4 -4
  170. package/dist/{read-session-chunk-6k83m4fj.js → read-session-chunk-5mh0bh8y.js} +12 -9
  171. package/dist/{read-session-raw-3g9qy1xa.js → read-session-raw-8sjbc9h0.js} +5 -3
  172. package/dist/{recomp-orchestrator-d3fp1cy0.js → recomp-orchestrator-kpkhkjhq.js} +28 -27
  173. package/dist/{safe-notification-target-5ffqq32m.js → safe-notification-target-q0cyrx3x.js} +2 -2
  174. package/dist/{search-epax1ecv.js → search-p9w39qv4.js} +22 -21
  175. package/dist/{send-session-notification-erecz4y4.js → send-session-notification-xffh3bbe.js} +5 -5
  176. package/dist/shared/auto-search-lifecycle.d.ts +14 -0
  177. package/dist/shared/auto-search-lifecycle.d.ts.map +1 -1
  178. package/dist/shared/logger.d.ts.map +1 -1
  179. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  180. package/dist/shared/models-dev-temperature.d.ts +18 -0
  181. package/dist/shared/models-dev-temperature.d.ts.map +1 -0
  182. package/dist/shared/project-directory-key.d.ts +16 -0
  183. package/dist/shared/project-directory-key.d.ts.map +1 -1
  184. package/dist/shared/storage-file-mutex.d.ts +9 -0
  185. package/dist/shared/storage-file-mutex.d.ts.map +1 -0
  186. package/dist/shared/storage-permissions.d.ts +6 -0
  187. package/dist/shared/storage-permissions.d.ts.map +1 -1
  188. package/dist/shared/subagent-temperature.d.ts +46 -0
  189. package/dist/shared/subagent-temperature.d.ts.map +1 -0
  190. package/dist/shared/window-geometry.d.ts +9 -66
  191. package/dist/shared/window-geometry.d.ts.map +1 -1
  192. package/dist/standalone-plugin-marker.d.ts +8 -0
  193. package/dist/standalone-plugin-marker.d.ts.map +1 -0
  194. package/dist/{storage-tags-d3b0v2ss.js → storage-tags-k0pda32s.js} +6 -4
  195. package/dist/tools/ctx-reduce/constants.d.ts +1 -2
  196. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  197. package/dist/tools/ctx-reduce/tools.d.ts +1 -1
  198. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  199. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  200. package/dist/tools/ctx-search/types.d.ts +1 -0
  201. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  202. package/dist/{transform-postprocess-phase-spcy2qre.js → transform-postprocess-phase-481j5a7z.js} +28 -27
  203. package/dist/v2/auto-search-worker.js +3 -3
  204. package/dist/v2/{context-sf98kstd.js → context-gsdtha5v.js} +1619 -3111
  205. package/dist/v2/{derive-budgets-3vc0y84t.js → derive-budgets-enckmg7y.js} +3 -3
  206. package/dist/v2/embedding-backfill-dbvjbcmm.js +20 -0
  207. package/dist/v2/embedding-worker-process.js +29 -0
  208. package/dist/v2/embedding-worker.js +6 -7
  209. package/dist/v2/hidden-child-native.d.ts.map +1 -1
  210. package/dist/v2/hidden-completion.d.ts +7 -0
  211. package/dist/v2/hidden-completion.d.ts.map +1 -1
  212. package/dist/v2/hooks/context.d.ts.map +1 -1
  213. package/dist/v2/hooks/copied-tag-notation.d.ts +19 -0
  214. package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -0
  215. package/dist/v2/hooks/dream-trigger.d.ts +4 -1
  216. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  217. package/dist/v2/hooks/generate.d.ts +9 -2
  218. package/dist/v2/hooks/generate.d.ts.map +1 -1
  219. package/dist/v2/hooks/payload.d.ts.map +1 -1
  220. package/dist/v2/hooks/system-prompt-response.d.ts +5 -0
  221. package/dist/v2/hooks/system-prompt-response.d.ts.map +1 -0
  222. package/dist/v2/{logger-mxd0ym09.js → logger-pj02s7sr.js} +1 -1
  223. package/dist/v2/{message-index-bounded-dy3s2k1e.js → message-index-bounded-p6v0n8qh.js} +15 -14
  224. package/dist/v2/{message-time-backfill-gtx1pwk1.js → message-time-backfill-cje68egj.js} +2 -2
  225. package/dist/v2/migration-worker.js +11 -10
  226. package/dist/v2/{project-embedding-registry-1tgba5dv.js → project-embedding-registry-nyq7z8y6.js} +11 -12
  227. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  228. package/dist/v2/{read-session-chunk-rh4khdkv.js → read-session-chunk-fhyfe4qa.js} +12 -9
  229. package/dist/v2/{read-session-raw-bsbmf0vj.js → read-session-raw-j8dvp7f4.js} +5 -3
  230. package/dist/v2/recomp-orchestrator-5xy7w136.js +57 -0
  231. package/dist/v2/{safe-notification-target-73ax1p5v.js → safe-notification-target-y3p1hce9.js} +2 -2
  232. package/dist/v2/{search-nzkwrc6n.js → search-j7bakcwa.js} +23 -23
  233. package/dist/v2/{send-session-notification-6km439kn.js → send-session-notification-f6v698r5.js} +5 -5
  234. package/dist/v2/{server-7wwc2nga.js → server-1fszbabv.js} +32 -32
  235. package/dist/v2/{server-k228xhjg.js → server-2htmbqbv.js} +26 -2
  236. package/dist/v2/{server-aan4q8mx.js → server-3t0q2cqx.js} +1 -1
  237. package/dist/v2/{server-686jg6eb.js → server-4c7jt8gq.js} +68 -7
  238. package/dist/v2/{server-xxm59eww.js → server-4enr7s6x.js} +4 -4
  239. package/dist/v2/{server-zxhgvsf9.js → server-676xw7at.js} +1 -1
  240. package/dist/v2/{server-52awr2mw.js → server-6byqfbqf.js} +93 -9
  241. package/dist/v2/{server-e0vdaae2.js → server-6tcrjfw8.js} +4 -4
  242. package/dist/v2/{server-qye6ykf7.js → server-7ekna9zs.js} +2 -2
  243. package/dist/v2/{server-g5r0n3b6.js → server-7h861yms.js} +160 -25
  244. package/dist/v2/{server-k8x2rbxc.js → server-7spkq1y6.js} +3457 -5192
  245. package/dist/v2/{server-8pyt7hev.js → server-7vkj6zhb.js} +34 -749
  246. package/dist/v2/{server-yczc713m.js → server-8xmq9h3f.js} +31 -49
  247. package/dist/v2/{server-sggvvzhb.js → server-bgzy0phk.js} +505 -11
  248. package/dist/v2/server-c7n2ftng.js +6860 -0
  249. package/dist/v2/server-cvgn49tr.js +733 -0
  250. package/dist/v2/{server-zm570tr2.js → server-cw6521wn.js} +232 -7
  251. package/dist/v2/{server-xdfwt6kh.js → server-czb2rkpk.js} +23 -3
  252. package/dist/v2/{server-x2g40a71.js → server-d6g4whc2.js} +21 -15
  253. package/dist/{index-1bc61ans.js → v2/server-fvnzcnww.js} +44 -1
  254. package/dist/v2/{server-4k748ke6.js → server-hb6xhh9q.js} +2 -2
  255. package/dist/v2/{server-gjcr4w98.js → server-kh958yj8.js} +5 -5
  256. package/dist/v2/{server-1r6pmz4f.js → server-kzns2hbz.js} +1 -1
  257. package/dist/v2/{server-psqc7e9n.js → server-mqvtz7wz.js} +1227 -78
  258. package/dist/v2/{server-vqpf3167.js → server-ras2sxnc.js} +135 -15
  259. package/dist/v2/{server-ezhze64f.js → server-s2st631p.js} +4 -4
  260. package/dist/v2/{server-5m3dt5r1.js → server-t4k4qexw.js} +6 -2
  261. package/dist/v2/{server-z2037m6z.js → server-t528t8qm.js} +2 -2
  262. package/dist/v2/{server-v06jcv0w.js → server-vb7pbd9p.js} +18 -259
  263. package/dist/v2/{server-8tqanswc.js → server-zbxjj2mz.js} +331 -4
  264. package/dist/v2/server.d.ts.map +1 -1
  265. package/dist/v2/server.js +150 -6
  266. package/dist/v2/{storage-tags-w4tv77sn.js → storage-tags-5yxrvkaf.js} +6 -4
  267. package/dist/v2/store-reader.d.ts +8 -2
  268. package/dist/v2/store-reader.d.ts.map +1 -1
  269. package/dist/v2/{wrapup-orchestrator-mz7efs7w.js → wrapup-orchestrator-yem5422s.js} +36 -36
  270. package/dist/wrapup-orchestrator-xvrr27ws.js +45 -0
  271. package/package.json +4 -4
  272. package/src/config/{mural-model-deprecation.ts → deprecated-config.ts} +19 -0
  273. package/src/config/index.test.ts +15 -37
  274. package/src/config/index.ts +2 -3
  275. package/src/config/project-security.ts +3 -3
  276. package/src/config/schema/magic-context.ts +11 -7
  277. package/src/features/magic-context/dreamer/task-registry.ts +2 -3
  278. package/src/shared/auto-search-lifecycle.ts +43 -0
  279. package/src/shared/logger.test.ts +38 -0
  280. package/src/shared/logger.ts +10 -2
  281. package/src/shared/models-dev-cache.ts +1 -7
  282. package/src/shared/models-dev-temperature.ts +107 -0
  283. package/src/shared/project-directory-key.test.ts +59 -0
  284. package/src/shared/project-directory-key.ts +20 -0
  285. package/src/shared/sqlite-640-review.test.ts +5 -1
  286. package/src/shared/storage-file-mutex-review.test.ts +162 -0
  287. package/src/shared/storage-file-mutex.ts +130 -0
  288. package/src/shared/storage-permissions.ts +46 -0
  289. package/src/shared/subagent-temperature.test.ts +270 -0
  290. package/src/shared/subagent-temperature.ts +110 -0
  291. package/src/shared/window-geometry.test.ts +102 -236
  292. package/src/shared/window-geometry.ts +23 -413
  293. package/dist/config/mural-model-deprecation.d.ts.map +0 -1
  294. package/dist/embedding-backfill-9rcm1mfy.js +0 -21
  295. package/dist/index-bdckkfw6.js +0 -3261
  296. package/dist/index-mfkzp7qj.js +0 -229
  297. package/dist/v2/embedding-backfill-vn8g1nh1.js +0 -21
  298. package/dist/v2/recomp-orchestrator-az61rfcg.js +0 -57
  299. package/dist/v2/server-2fbhp79z.js +0 -3205
  300. package/dist/v2/server-mfkzp7qj.js +0 -229
  301. package/dist/wrapup-orchestrator-amzta1t4.js +0 -44
  302. package/src/shared/__fixtures__/window-overlay.v1.json +0 -337
  303. /package/dist/{index-2pp04pmg.js → index-69vas84q.js} +0 -0
  304. /package/dist/v2/{index-2pp04pmg.js → index-69vas84q.js} +0 -0
@@ -4,38 +4,19 @@ import {
4
4
  isCompactionEnabled,
5
5
  getProtectedTokensTierOverrides,
6
6
  loadPluginConfigDetailed,
7
- BoundedSessionMap,
8
7
  historianRunConfig,
9
8
  dreamerRunConfig,
10
9
  pluginConfigReader,
11
10
  withLiveDreamerOutputCap,
12
- renderUserFacingFailure,
13
- userFacingFailureCode,
14
11
  invalidateAutoEmbedSession,
15
12
  acquireCompartmentLease,
16
13
  releaseCompartmentLeaseBestEffort,
17
14
  isCompartmentLeaseHeld,
18
15
  queueM0Mutation,
19
- clearCachedM0M1,
20
16
  getCompartments,
21
17
  getUncoveredCompartmentEndsThrough,
22
- getProtectionWindowForSession,
23
- getChannel2NudgeState,
24
- claimChannel2NudgeState,
25
- casChannel2NudgeClaim,
26
- getOverflowState,
27
- recordOverflowDetected,
28
- recordDetectedContextLimit,
29
- getPersistedCompactionMarkerState,
30
- setPersistedCompactionMarkerState,
31
- getObservedEpochFloor,
32
18
  providerResponseFailed,
33
19
  isSuccessfulProviderCompletion,
34
- lkgProviderInputTotal,
35
- beginV2LkgRequest,
36
- noteLkgProviderResponse,
37
- getSlot,
38
- copySessionStateForClone,
39
20
  gaDatabasePath,
40
21
  RAW_MESSAGE_TYPES,
41
22
  V2StoreReaderPool,
@@ -44,6 +25,17 @@ import {
44
25
  updateSessionMeta,
45
26
  markSessionCleanupPending,
46
27
  clearSession,
28
+ requestPendingMaterialization,
29
+ clearPendingMaterialization,
30
+ bindSystemPromptResponse,
31
+ retirePendingSystemPromptDelivery,
32
+ lkgProviderInputTotal,
33
+ beginV2LkgRequest,
34
+ currentLkgRequestIdentity,
35
+ noteLkgProviderResponse,
36
+ clearLkgMeasuredRequest,
37
+ getSlot,
38
+ copySessionStateForClone,
47
39
  HiddenCompletionRefusal,
48
40
  HIDDEN_HISTORIAN_AGENT,
49
41
  HIDDEN_DREAMER_AGENT,
@@ -67,7 +59,7 @@ import {
67
59
  resetPrefixTrimFallbackState,
68
60
  resolveOpenCodeProtectedTailBoundary,
69
61
  getActiveCompartmentRun
70
- } from "./index-692jzy0p.js";
62
+ } from "./index-zfzdpeq2.js";
71
63
  import"./index-sd3egckz.js";
72
64
  import {
73
65
  getHarness2
@@ -79,7 +71,7 @@ import {
79
71
  import {
80
72
  log2,
81
73
  sessionLog2
82
- } from "./index-8j7gqj40.js";
74
+ } from "./index-nsjyysj0.js";
83
75
  import {
84
76
  isSaneLimit,
85
77
  setOutputReserveConfig,
@@ -89,9 +81,8 @@ import {
89
81
  deriveHistorianChunkTokens2,
90
82
  resolveKnownHistorianContextLimit2,
91
83
  resolveHistorianContextLimit2
92
- } from "./index-pdecwzrd.js";
93
- import"./index-bhvjj0ys.js";
94
- import"./index-mfkzp7qj.js";
84
+ } from "./index-w23dh319.js";
85
+ import"./index-k6xvbj2e.js";
95
86
  import {
96
87
  CANONICAL_DREAM_TASKS,
97
88
  DREAM_TASK_CAPABILITIES,
@@ -114,12 +105,12 @@ import {
114
105
  openDatabaseAsync,
115
106
  isDatabasePersisted,
116
107
  getDatabasePersistenceError
117
- } from "./index-q7h7csab.js";
108
+ } from "./index-zg8yq4ya.js";
118
109
  import {
119
110
  setHomeProjectPermission,
120
111
  resolveProjectIdentityForSession,
121
112
  scheduleAfterBootQuiet
122
- } from "./index-knh4y330.js";
113
+ } from "./index-gzky5rva.js";
123
114
  import {
124
115
  markHostUnservedRow,
125
116
  DreamTokenBudgetExceeded,
@@ -127,55 +118,74 @@ import {
127
118
  recordToolParameters,
128
119
  createDroppedInputGuard,
129
120
  assertExecutableToolInput,
130
- estimateFinalWireInputTokens,
121
+ getProtectionWindowForSession,
122
+ clearCachedM0M1,
123
+ getChannel2NudgeState,
124
+ claimChannel2NudgeState,
125
+ casChannel2NudgeClaim,
126
+ getOverflowState,
127
+ recordOverflowDetected,
128
+ recordDetectedContextLimit,
129
+ getPersistedCompactionMarkerState,
130
+ setPersistedCompactionMarkerState,
131
+ getObservedEpochFloor,
131
132
  detectOverflow,
132
133
  modelAcceptsEmptyContent,
134
+ estimateFinalWireInputTokens,
133
135
  hasRawMessageProvider2,
134
136
  setBoundedRawMessageProvider2,
135
137
  cleanUserText2,
136
138
  readRawSessionMessageIdOrdinalsForRange2,
137
139
  readRawSessionMessageOrdinalById2
138
- } from "./index-bdckkfw6.js";
140
+ } from "./index-sv0bb7vg.js";
139
141
  import {
140
142
  hasMeaningfulUserText2,
141
143
  preloadTokenizer,
142
144
  estimateTokens
143
- } from "./index-1qb0z7wa.js";
144
- import"./index-72nhv486.js";
145
+ } from "./index-qx53vezw.js";
146
+ import"./index-vkbqdnkj.js";
145
147
  import {
146
148
  withSqliteTransformPass2,
147
149
  withoutSqliteTransformPass2,
148
150
  isTransientSqliteError2,
149
151
  withAsyncPrivilegedWriter2
150
152
  } from "./index-kb9nn0a0.js";
151
- import"./index-fbv1dn35.js";
153
+ import {
154
+ sameProjectDirectory
155
+ } from "./index-7w18gg78.js";
152
156
  import {
153
157
  deleteChunkEmbedBackoffForSession
154
- } from "./index-pg50n748.js";
158
+ } from "./index-p1hnwfd8.js";
159
+ import"./index-6m7rdv7y.js";
155
160
  import {
161
+ BoundedSessionMap,
156
162
  advanceSessionActivity,
157
163
  backfillSessionActivity
158
- } from "./index-14cjxt20.js";
159
- import"./index-db7zwa3v.js";
164
+ } from "./index-sfhndpcb.js";
165
+ import"./index-1bt88epp.js";
160
166
  import"./index-1zx87sdm.js";
161
167
  import {
168
+ stripPersistedAssistantText,
162
169
  isDroppedToolOutput,
163
170
  evaluateChannel2,
164
171
  reclaimableToolOutputCount,
165
172
  buildChannel2Reminder
166
- } from "./index-k9nnwad5.js";
167
- import"./index-dhwzyd54.js";
173
+ } from "./index-nydv6g8r.js";
174
+ import"./index-h5zfkjyk.js";
168
175
  import"./index-58e3y90n.js";
169
- import"./index-ty64eqcn.js";
176
+ import"./index-0pjvpfkf.js";
170
177
  import {
171
178
  getCurrentToolSetHash,
172
179
  recordToolDefinition
173
- } from "./index-0qhce371.js";
180
+ } from "./index-h2wc01qk.js";
174
181
  import"./index-fr0wbhdn.js";
175
- import"./index-7mx8v0pw.js";
182
+ import"./index-att4bfan.js";
183
+ import"./index-fg00p1cg.js";
176
184
  import"./index-fb3zxn06.js";
177
- import"./index-c43kr12f.js";
178
- import"./index-cb7emxgj.js";
185
+ import {
186
+ renderUserFacingFailure,
187
+ userFacingFailureCode
188
+ } from "./index-rafsaxac.js";
179
189
  import {
180
190
  runSessionProjectBackfill,
181
191
  createLiveSessionState,
@@ -201,6 +211,9 @@ import {
201
211
  measureLkgReplay,
202
212
  STORAGE_BUSY_MESSAGE,
203
213
  StorageBusyRefusalError,
214
+ bindSystemDateRequestIdentity,
215
+ bindSystemDateOutput,
216
+ registerSystemDateRefresh,
204
217
  UnmanagedOverWindowError,
205
218
  UnresolvedHistoryBoundaryError,
206
219
  createTransform,
@@ -221,8 +234,9 @@ import {
221
234
  createCtxReduceTools,
222
235
  createCtxSearchTools,
223
236
  applyJsonSchemaParameterDescriptions,
224
- MagicContextRpcServer
225
- } from "./index-0an7742d.js";
237
+ MagicContextRpcServer,
238
+ subagentTemperature
239
+ } from "./index-xnanvj3w.js";
226
240
  import {
227
241
  createTagger,
228
242
  setCtxReduceRegisteredGlobally,
@@ -230,28 +244,29 @@ import {
230
244
  EmergencyFailClosedError,
231
245
  DegradedPassRefusalError,
232
246
  isSyntheticHeadMessage2
233
- } from "./index-f0h6xwqm.js";
247
+ } from "./index-p0n5ryq8.js";
234
248
  import"./index-qt1qqasc.js";
235
249
  import"./index-4dhv7mqz.js";
236
- import"./index-5zygecde.js";
250
+ import"./index-gbmqa9x9.js";
251
+ import"./index-r2zcs71c.js";
237
252
  import"./index-7jzrrxap.js";
238
253
  import {
239
254
  pushNotification2,
240
255
  isTuiConnected2
241
256
  } from "./index-x8a7jmkh.js";
242
- import"./index-jcbd3znx.js";
243
- import"./index-yq8n9qcb.js";
244
- import"./index-mmyh6d8f.js";
245
- import"./index-0w56v4fm.js";
257
+ import"./index-tqf7yg27.js";
258
+ import"./index-xgrwmj82.js";
259
+ import"./index-fdtkt5r1.js";
260
+ import"./index-eypn4ba6.js";
261
+ import"./index-mw7c950g.js";
246
262
  import {
247
263
  detectConflicts
248
- } from "./index-eeezr5zz.js";
249
- import"./index-q2tqeqde.js";
264
+ } from "./index-z1tjp257.js";
250
265
  import"./index-fmsr7v69.js";
251
266
  import {
252
267
  getErrorMessage
253
268
  } from "./index-y8v6yerm.js";
254
- import"./index-2y0s2hep.js";
269
+ import"./index-4mjhqadz.js";
255
270
 
256
271
  // src/hooks/magic-context/history-boundary-repair.ts
257
272
  function readBaseline(db, sessionId) {
@@ -944,6 +959,11 @@ function toolStateContent(state) {
944
959
  `);
945
960
  }
946
961
 
962
+ // src/v2/hooks/copied-tag-notation.ts
963
+ function stripCopiedTagNotation(text) {
964
+ return text.includes("§") ? stripPersistedAssistantText(text) : text;
965
+ }
966
+
947
967
  // src/v2/hooks/payload.ts
948
968
  var HEAD_IDS = ["__magic_context_v2_m0__", "__magic_context_v2_m1__"];
949
969
  var HOST_CONTENT_TYPES = new Set([
@@ -1160,6 +1180,8 @@ function adaptPayload(draft, admittedIDs = new Set) {
1160
1180
  if (paired.has(content))
1161
1181
  continue;
1162
1182
  const part = callParts.get(content) ?? (content.type === "tool-result" ? nativeTool(undefined, { part: content, message }) : clonePreservingInstances(content));
1183
+ if (message.role === "assistant" && part.type === "text" && typeof part.text === "string")
1184
+ part.text = stripCopiedTagNotation(part.text);
1163
1185
  if (message.id && admittedIDs.has(message.id))
1164
1186
  part.synthetic = true;
1165
1187
  parts.push(part);
@@ -2213,7 +2235,7 @@ function createNativeHiddenChildren(host, removeSession, options) {
2213
2235
  return;
2214
2236
  }
2215
2237
  const directory = stored.location?.directory;
2216
- if (options.directory !== undefined && directory !== undefined && directory !== options.directory) {
2238
+ if (options.directory !== undefined && directory !== undefined && !sameProjectDirectory(directory, options.directory)) {
2217
2239
  throw new HiddenCompletionRefusal("hidden_prompt_unrecognized", `hidden child ${sessionID} is bound to ${directory}, not to this instance's ${options.directory}`, true);
2218
2240
  }
2219
2241
  if (stored.parentID === parentID || parentDroppedNoted)
@@ -2684,6 +2706,26 @@ async function createV2HiddenCompletionExecutor(host, options) {
2684
2706
  throw new Error("Hidden completion prompt aborted");
2685
2707
  }
2686
2708
  const requested = await validateVariant(requestModel(request, run.child.model));
2709
+ if (run.identity.kind !== "dreamer-task" && request.body.temperature === undefined) {
2710
+ const configured = options.historianTemperature?.();
2711
+ if (typeof configured === "number" && Number.isFinite(configured))
2712
+ request = { ...request, body: { ...request.body, temperature: configured } };
2713
+ }
2714
+ if (typeof request.body.temperature === "number") {
2715
+ let metadata;
2716
+ try {
2717
+ const listed = await options.modelCatalog?.();
2718
+ const rows = Array.isArray(listed) ? listed : listed?.data;
2719
+ metadata = rows?.find((row) => row?.providerID === requested.providerID && (row?.id === requested.modelID || row?.modelID === requested.modelID));
2720
+ } catch {}
2721
+ const temperature = subagentTemperature(modelKey(requested), metadata, request.body.temperature, (message) => note(message));
2722
+ const body = { ...request.body };
2723
+ if (temperature === undefined)
2724
+ delete body.temperature;
2725
+ else
2726
+ body.temperature = temperature;
2727
+ request = { ...request, body };
2728
+ }
2687
2729
  if (run.retired) {
2688
2730
  run.child = await lifecycle.create(run.identity, run.role, requested);
2689
2731
  run.failed = false;
@@ -3281,7 +3323,7 @@ async function sessionInThisLocation(context, sessionID) {
3281
3323
  } catch {
3282
3324
  return false;
3283
3325
  }
3284
- return location?.directory === context.location.directory && (location.workspaceID ?? "") === (context.location.workspaceID ?? "");
3326
+ return location?.directory !== undefined && sameProjectDirectory(location.directory, context.location.directory) && (location.workspaceID ?? "") === (context.location.workspaceID ?? "");
3285
3327
  }
3286
3328
  function startDreamTrigger(context, args) {
3287
3329
  const controller = new AbortController;
@@ -3348,13 +3390,28 @@ function startDreamTrigger(context, args) {
3348
3390
  }
3349
3391
 
3350
3392
  // src/v2/hooks/generate.ts
3393
+ function generateReplayAnchor(messages) {
3394
+ let index = messages.length - 1;
3395
+ while (index >= 0 && !messages[index]?.id)
3396
+ index--;
3397
+ if (index < 0)
3398
+ return;
3399
+ const id = messages.at(index)?.id;
3400
+ if (!id)
3401
+ return;
3402
+ return { id, tail: clonePreservingInstances(messages.slice(index + 1)) };
3403
+ }
3404
+
3351
3405
  class V2GenerateReplay {
3352
3406
  prefixes = new Map;
3353
3407
  capture(draft, anchor) {
3354
- if (!anchor)
3408
+ if (!anchor) {
3409
+ this.prefixes.delete(draft.sessionID);
3410
+ sessionLog2(draft.sessionID, "generate replay capture skipped: no-anchor");
3355
3411
  return;
3412
+ }
3356
3413
  this.prefixes.set(draft.sessionID, {
3357
- anchor,
3414
+ anchor: clonePreservingInstances(anchor),
3358
3415
  model: `${draft.model.providerID}/${draft.model.id}`,
3359
3416
  agent: draft.agent,
3360
3417
  system: clonePreservingInstances(draft.system),
@@ -3367,12 +3424,23 @@ class V2GenerateReplay {
3367
3424
  }
3368
3425
  apply(draft) {
3369
3426
  const prefix = this.prefixes.get(draft.sessionID);
3370
- if (!prefix || prefix.model !== `${draft.model.providerID}/${draft.model.id}` || prefix.agent !== draft.agent)
3427
+ const skip = (reason) => {
3428
+ sessionLog2(draft.sessionID, `generate replay apply skipped: ${reason}`);
3371
3429
  return false;
3372
- const index = draft.messages.findIndex((message) => message.id === prefix.anchor);
3430
+ };
3431
+ if (!prefix)
3432
+ return skip("no-prefix");
3433
+ if (prefix.model !== `${draft.model.providerID}/${draft.model.id}`)
3434
+ return skip("model-mismatch");
3435
+ if (prefix.agent !== draft.agent)
3436
+ return skip("agent-mismatch");
3437
+ const index = draft.messages.findIndex((message) => message.id === prefix.anchor.id);
3373
3438
  if (index < 0)
3374
- return false;
3375
- const tail = draft.messages.slice(index + 1);
3439
+ return skip("anchor-not-found");
3440
+ const end = index + 1 + prefix.anchor.tail.length;
3441
+ if (JSON.stringify(draft.messages.slice(index + 1, end)) !== JSON.stringify(prefix.anchor.tail))
3442
+ return skip("anchor-tail-mismatch");
3443
+ const tail = draft.messages.slice(end);
3376
3444
  draft.messages.splice(0, draft.messages.length, ...clonePreservingInstances(prefix.messages), ...tail);
3377
3445
  draft.system.splice(0, draft.system.length, ...clonePreservingInstances(prefix.system));
3378
3446
  draft.tools = clonePreservingInstances(prefix.tools);
@@ -3924,6 +3992,24 @@ function createV2RawMessageProvider(reader, sessionID) {
3924
3992
  };
3925
3993
  }
3926
3994
 
3995
+ // src/v2/hooks/system-prompt-response.ts
3996
+ function bindV2SystemPromptResponse(sessionId, reader) {
3997
+ const request = currentLkgRequestIdentity(sessionId);
3998
+ if (request?.kind !== "v2" || request.responseAfterSequence === undefined)
3999
+ return;
4000
+ const first = reader.assistantSince(sessionId, request.responseAfterSequence)[0];
4001
+ if (!first)
4002
+ return;
4003
+ const createdAt = first.data.time?.created ?? first.time_created;
4004
+ if (typeof createdAt !== "number")
4005
+ return;
4006
+ bindSystemPromptResponse(sessionId, request, {
4007
+ responseId: first.id,
4008
+ createdAt,
4009
+ modelKey: first.data.model?.providerID && first.data.model?.id ? `${first.data.model.providerID}/${first.data.model.id}` : undefined
4010
+ });
4011
+ }
4012
+
3927
4013
  // src/v2/hooks/tools.ts
3928
4014
  import { tool } from "@opencode-ai/plugin";
3929
4015
  async function registerTools(context, db, config, rustToolBackends, isInternalChild) {
@@ -3948,7 +4034,7 @@ async function registerTools(context, db, config, rustToolBackends, isInternalCh
3948
4034
  smartNotesEnabled: config.smart_notes.enabled,
3949
4035
  ...rustToolBackends ? { rustToolBackends } : {}
3950
4036
  }),
3951
- ...createCtxSearchTools(project),
4037
+ ...createCtxSearchTools({ ...project, rerankConnectionFile: config.subc?.connection_file }),
3952
4038
  ...config.memory.enabled ? {
3953
4039
  ...createCtxMemoryTools({
3954
4040
  ...project,
@@ -4244,8 +4330,16 @@ async function applyV2SystemPrompt(systemPrompt, draft) {
4244
4330
  }
4245
4331
  })));
4246
4332
  const system = { system: draft.system.map((part) => String(part.text ?? "")) };
4333
+ bindSystemDateOutput(system.system, () => {
4334
+ draft.system.splice(0, draft.system.length, ...system.system.map((text, index) => ({
4335
+ ...draft.system[index],
4336
+ type: "text",
4337
+ text
4338
+ })));
4339
+ });
4247
4340
  await systemPrompt.handler({
4248
4341
  sessionID: draft.sessionID,
4342
+ dateRefreshRequest: draft,
4249
4343
  model: { providerID: draft.model.providerID, modelID: draft.model.id }
4250
4344
  }, system);
4251
4345
  const originals = [...draft.system];
@@ -4419,6 +4513,7 @@ async function registerContext(context) {
4419
4513
  keepSubagents: config.keep_subagents === true,
4420
4514
  ensureAgent: () => hiddenAgentsReady ??= context.agent.reload(),
4421
4515
  modelCatalog: () => Promise.resolve(context.model.list()),
4516
+ historianTemperature: () => config.historian?.temperature,
4422
4517
  openReader: openStoreReader
4423
4518
  });
4424
4519
  };
@@ -4494,6 +4589,7 @@ async function registerContext(context) {
4494
4589
  const agents = new Map;
4495
4590
  const sessionDirectories = new Map;
4496
4591
  const historyRefreshSessions = new Set;
4592
+ registerSystemDateRefresh(historyRefreshSessions);
4497
4593
  const pendingMaterializationSessions = new Set;
4498
4594
  const lastHeuristicsTurnId = new Map;
4499
4595
  const restoredRows = new RestoredRowCache;
@@ -4615,6 +4711,11 @@ async function registerContext(context) {
4615
4711
  try {
4616
4712
  const latest = reader.latestAssistant(draft.sessionID);
4617
4713
  latestLkgResponseIds.set(draft.sessionID, latest?.id);
4714
+ try {
4715
+ bindV2SystemPromptResponse(draft.sessionID, reader);
4716
+ } catch (error) {
4717
+ sessionLog2(draft.sessionID, "v2 response ownership unavailable; keeping system identity pending", error);
4718
+ }
4618
4719
  if (latest)
4619
4720
  noteLkgProviderResponse({
4620
4721
  sessionId: draft.sessionID,
@@ -4728,7 +4829,9 @@ async function registerContext(context) {
4728
4829
  continue;
4729
4830
  }
4730
4831
  if (event.type === "session.deleted") {
4832
+ clearLkgMeasuredRequest(sessionID);
4731
4833
  deletedSessions.add(sessionID);
4834
+ transform?.clearSessionLogState(sessionID);
4732
4835
  if (db) {
4733
4836
  markSessionCleanupPending(db, sessionID);
4734
4837
  clearSession(db, sessionID);
@@ -4743,7 +4846,7 @@ async function registerContext(context) {
4743
4846
  agents.delete(sessionID);
4744
4847
  channel1.delete(sessionID);
4745
4848
  historyRefreshSessions.delete(sessionID);
4746
- pendingMaterializationSessions.delete(sessionID);
4849
+ clearPendingMaterialization(pendingMaterializationSessions, sessionID);
4747
4850
  lastHeuristicsTurnId.delete(sessionID);
4748
4851
  restoredRows.forget(sessionID);
4749
4852
  await nativeFoldReplay?.forget(sessionID);
@@ -4855,6 +4958,7 @@ async function registerContext(context) {
4855
4958
  const systemAtEntry = structuredClone(draft.system);
4856
4959
  const slotAtEntry = getSlot(draft.sessionID);
4857
4960
  const restoreLkgSystem = () => {
4961
+ retirePendingSystemPromptDelivery(draft.sessionID);
4858
4962
  if (!lkgSystems.restore(draft.sessionID, getSlot(draft.sessionID), systemAtEntry, draft.system)) {
4859
4963
  sessionLog2(draft.sessionID, "lkg_system_state_mismatch");
4860
4964
  throw new Error("LKG system identity is unavailable or changed");
@@ -4987,6 +5091,18 @@ async function registerContext(context) {
4987
5091
  injectionEnabled: config.system_prompt_injection.enabled,
4988
5092
  injectionSkipSignatures: config.system_prompt_injection.skip_signatures
4989
5093
  });
5094
+ let responseAfterSequence;
5095
+ try {
5096
+ const responseReader = openStoreReader();
5097
+ try {
5098
+ responseAfterSequence = responseReader.latestSequence(draft.sessionID);
5099
+ } finally {
5100
+ responseReader.close();
5101
+ }
5102
+ } catch (error) {
5103
+ sessionLog2(draft.sessionID, "v2 response boundary unavailable; no system delivery acknowledgement", error);
5104
+ }
5105
+ beginV2LkgRequest(draft.sessionID, `${draft.model.providerID}/${draft.model.id}`, latestLkgResponseIds.get(draft.sessionID), responseAfterSequence);
4990
5106
  await applyV2SystemPrompt(systemPrompt, draft);
4991
5107
  await preloadTokenizer();
4992
5108
  passDuties ??= createChatMessageHook({
@@ -5018,6 +5134,7 @@ async function registerContext(context) {
5018
5134
  contextUsageMap: usage,
5019
5135
  compactionOff,
5020
5136
  storeGeneration: "v2",
5137
+ normalizeRestoredAssistantText: stripCopiedTagNotation,
5021
5138
  hostCleanupCompactionMarkers: () => ({
5022
5139
  verified: true,
5023
5140
  removedLineages: 0,
@@ -5095,7 +5212,7 @@ async function registerContext(context) {
5095
5212
  const boundaryRepair = !rustModeModuleClient && db && !compactionOff ? checkHistoryBoundary(db, reader, draft.sessionID) : undefined;
5096
5213
  if (boundaryRepair?.kind === "repaired" || boundaryRepair?.kind === "baseline-reset") {
5097
5214
  historyRefreshSessions.add(draft.sessionID);
5098
- pendingMaterializationSessions.add(draft.sessionID);
5215
+ requestPendingMaterialization(pendingMaterializationSessions, draft.sessionID, "boundary_repair");
5099
5216
  }
5100
5217
  const incoming = cut && draft.messages.find((message) => message.id === cut.id);
5101
5218
  postFold = cut !== undefined;
@@ -5113,7 +5230,7 @@ async function registerContext(context) {
5113
5230
  }
5114
5231
  if (nativeRestored && nativeFoldReplay?.sourceChanged(draft.sessionID)) {
5115
5232
  historyRefreshSessions.add(draft.sessionID);
5116
- pendingMaterializationSessions.add(draft.sessionID);
5233
+ requestPendingMaterialization(pendingMaterializationSessions, draft.sessionID, "host_history_change");
5117
5234
  }
5118
5235
  if (cut && incoming && nativeRestored) {
5119
5236
  const present = new Set(draft.messages.flatMap((message) => message.id ? [message.id] : []));
@@ -5131,7 +5248,7 @@ async function registerContext(context) {
5131
5248
  onHard: (reason) => {
5132
5249
  sessionLog2(draft.sessionID, `HARD reason=${reason}`);
5133
5250
  materialize(draft);
5134
- pendingMaterializationSessions.add(draft.sessionID);
5251
+ requestPendingMaterialization(pendingMaterializationSessions, draft.sessionID, "host_compaction");
5135
5252
  }
5136
5253
  });
5137
5254
  checkpoint = structuredClone(identity.rendered ?? incoming);
@@ -5167,7 +5284,7 @@ async function registerContext(context) {
5167
5284
  }
5168
5285
  }
5169
5286
  const mapped = adaptPayload(draft, admitted);
5170
- beginV2LkgRequest(draft.sessionID, `${draft.model.providerID}/${draft.model.id}`, latestLkgResponseIds.get(draft.sessionID));
5287
+ bindSystemDateRequestIdentity(mapped, draft);
5171
5288
  await createMessagesTransformHandler({
5172
5289
  magicContext: { "experimental.chat.messages.transform": transform },
5173
5290
  compactionOff,
@@ -5262,10 +5379,12 @@ ${baseline}
5262
5379
  }
5263
5380
  };
5264
5381
  await context.session.hook("context", (draft) => withSqliteTransformPass2(async () => {
5265
- const anchor = draft.messages.at(-1)?.id;
5382
+ const anchor = generateReplayAnchor(draft.messages);
5266
5383
  await runManagedContext(draft);
5267
- if (!compactionOff && draft.messages.some((message) => message.id === HEAD_IDS[0] || message.content.some((part) => typeof part.text === "string" && part.text.includes("<session-history>"))))
5384
+ if (!compactionOff)
5268
5385
  generateReplay.capture(draft, anchor);
5386
+ else
5387
+ sessionLog2(draft.sessionID, "generate replay capture skipped: compaction-disabled");
5269
5388
  }));
5270
5389
  await context.session.hook("generate", async (draft) => {
5271
5390
  if (!compactionOff && !deletedSessions.has(draft.sessionID))
@@ -5,9 +5,9 @@ import {
5
5
  resolveHistorianProducerLimits2,
6
6
  resolveHistorianContextLimit2,
7
7
  producerSourceLocalBudget2
8
- } from "./index-pdecwzrd.js";
8
+ } from "./index-w23dh319.js";
9
9
  import"./index-1zx87sdm.js";
10
- import"./index-8j7gqj40.js";
10
+ import"./index-nsjyysj0.js";
11
11
  import"./index-0sahzkwr.js";
12
12
  import"./index-pavzsdc6.js";
13
13
  export {
@@ -0,0 +1,21 @@
1
+ import {
2
+ ensureMemoryEmbeddings2
3
+ } from "./index-r2zcs71c.js";
4
+ import"./index-fg00p1cg.js";
5
+ import"./index-p1hnwfd8.js";
6
+ import"./index-4dhv7mqz.js";
7
+ import"./index-qt1qqasc.js";
8
+ import"./index-gbmqa9x9.js";
9
+ import"./index-vkbqdnkj.js";
10
+ import"./index-gzky5rva.js";
11
+ import"./index-7w18gg78.js";
12
+ import"./index-k6xvbj2e.js";
13
+ import"./index-qx53vezw.js";
14
+ import"./index-4mjhqadz.js";
15
+ import"./index-kb9nn0a0.js";
16
+ import"./index-nsjyysj0.js";
17
+ import"./index-0sahzkwr.js";
18
+ import"./index-pavzsdc6.js";
19
+ export {
20
+ ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
21
+ };
@@ -0,0 +1,30 @@
1
+ import"./index-pavzsdc6.js";
2
+ import"./index-0sahzkwr.js";
3
+ import {
4
+ log2
5
+ } from "./index-nsjyysj0.js";
6
+
7
+ // src/features/magic-context/memory/embedding-worker-process.ts
8
+ import { Worker } from "node:worker_threads";
9
+ var worker;
10
+ process.on("message", (message) => {
11
+ if (message.entry && !worker) {
12
+ worker = new Worker(new URL(message.entry), { workerData: message.data });
13
+ worker.on("message", (reply) => {
14
+ const wire = {
15
+ ...reply,
16
+ vectors: reply.vectors?.map((vector) => vector === null ? null : Buffer.from(vector.buffer, vector.byteOffset, vector.byteLength).toString("base64"))
17
+ };
18
+ if (process.connected)
19
+ process.send?.(wire);
20
+ });
21
+ worker.on("error", (error) => {
22
+ log2("[magic-context] embedding worker failed:", error);
23
+ process.exit(1);
24
+ });
25
+ worker.on("exit", (code) => process.exit(code));
26
+ } else {
27
+ worker?.postMessage(message);
28
+ }
29
+ });
30
+ process.on("disconnect", () => process.exit(0));
@@ -4,18 +4,18 @@ import {
4
4
  import"./index-0sahzkwr.js";
5
5
  import {
6
6
  log2
7
- } from "./index-8j7gqj40.js";
7
+ } from "./index-nsjyysj0.js";
8
+ import"./index-k6xvbj2e.js";
9
+ import"./index-vkbqdnkj.js";
10
+ import"./index-qx53vezw.js";
8
11
  import {
9
12
  resolveLocalEmbeddingWorkerRuntime,
10
13
  getLocalEmbeddingNativeMemoryStats,
11
14
  LocalEmbeddingProvider
12
- } from "./index-bhvjj0ys.js";
13
- import"./index-mfkzp7qj.js";
14
- import"./index-72nhv486.js";
15
- import"./index-1qb0z7wa.js";
15
+ } from "./index-gbmqa9x9.js";
16
16
  import {
17
17
  setStoragePrivatePermissionEnforcement
18
- } from "./index-1bc61ans.js";
18
+ } from "./index-fvnzcnww.js";
19
19
 
20
20
  // src/features/magic-context/memory/embedding-worker.ts
21
21
  import { parentPort, workerData } from "node:worker_threads";
@@ -11,10 +11,9 @@ import type { CurateMemoryCategory } from "./curate-category-rotation";
11
11
  export declare const CANONICAL_DREAM_TASKS: readonly ["map-memories", "verify", "verify-broad", "curate", "compress-cues", "classify-memories", "retrospective", "maintain-docs", "evaluate-smart-notes", "review-user-memories", "promote-primers", "refresh-primers"];
12
12
  export type DreamTaskName = (typeof CANONICAL_DREAM_TASKS)[number];
13
13
  export declare function availableDreamTasks(smartNotesEnabled?: boolean): DreamTaskName[];
14
- /** Prompt-token ceilings informed by docs/reports/dreamer-token-usage.md.
14
+ /** Prompt-token ceilings leave headroom for repeated tool-loop prompt sends.
15
15
  * Completed Gemini run usage predicts 20-memory mapping/verification batches
16
- * at about 70% of their allowance
17
- * (docs/reports/verify-token-budget-2026-09-30.md); curate and other tasks retain
16
+ * at about 70% of their ceiling; curate and other tasks retain
18
17
  * their separate allowances. */
19
18
  export declare const DREAM_TOOL_LOOP_TOKEN_BUDGETS: {
20
19
  readonly "map-memories": 2500000;
@@ -1 +1 @@
1
- {"version":3,"file":"task-registry.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-registry.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"task-registry.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/dreamer/task-registry.ts"],"names":[],"mappings":"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"}