@cortexkit/opencode-magic-context 0.49.10 → 0.49.12

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 (237) hide show
  1. package/README.md +1 -1
  2. package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +28 -0
  3. package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -0
  4. package/dist/{announcement-hdbkt8v5.js → announcement-g789dmt6.js} +2 -2
  5. package/dist/auto-search-worker.js +4 -4
  6. package/dist/{compaction-marker-candidates-xxz35vwp.js → compaction-marker-candidates-v5c6997n.js} +3 -3
  7. package/dist/compaction-marker-candidates-worker.js +1 -1
  8. package/dist/config/agent-disable.d.ts +14 -0
  9. package/dist/config/agent-disable.d.ts.map +1 -1
  10. package/dist/config/dependency-notes.d.ts +34 -0
  11. package/dist/config/dependency-notes.d.ts.map +1 -0
  12. package/dist/config/schema/magic-context.d.ts.map +1 -1
  13. package/dist/{conflict-warning-hook-w3crzrar.js → conflict-warning-hook-f4x5wed7.js} +8 -8
  14. package/dist/{context-ey3ap3cc.js → context-dam8p201.js} +306 -119
  15. package/dist/{derive-budgets-3nbxsyss.js → derive-budgets-5306b1jt.js} +3 -3
  16. package/dist/embedding-backfill-qbfcbp87.js +21 -0
  17. package/dist/embedding-worker-process.js +2 -2
  18. package/dist/embedding-worker.js +6 -6
  19. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +12 -1
  20. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  21. package/dist/features/magic-context/dreamer/task-config.d.ts +22 -4
  22. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  23. package/dist/features/magic-context/dreamer/task-registry.d.ts +22 -0
  24. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  25. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -1
  26. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  27. package/dist/features/magic-context/memory/embedding-openai.d.ts +32 -0
  28. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  29. package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
  30. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  31. package/dist/features/magic-context/memory/unborn-head.d.ts +34 -0
  32. package/dist/features/magic-context/memory/unborn-head.d.ts.map +1 -0
  33. package/dist/features/magic-context/memory-enabled.d.ts +5 -0
  34. package/dist/features/magic-context/memory-enabled.d.ts.map +1 -0
  35. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  36. package/dist/features/magic-context/search-pool-fixture.d.ts +39 -0
  37. package/dist/features/magic-context/search-pool-fixture.d.ts.map +1 -0
  38. package/dist/features/magic-context/search.d.ts.map +1 -1
  39. package/dist/features/magic-context/storage-tags.d.ts +2 -0
  40. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  41. package/dist/features/magic-context/transform-decision-log.d.ts +57 -2
  42. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  43. package/dist/{history-owner-ty29fz0f.js → history-owner-xp3pngv7.js} +3 -3
  44. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  45. package/dist/hooks/magic-context/compartment-prompt.d.ts +6 -0
  46. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  47. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  48. package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -0
  49. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  50. package/dist/hooks/magic-context/compartment-trigger-error.d.ts +12 -0
  51. package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
  52. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +14 -2
  53. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/pending-materialization.d.ts +2 -0
  56. package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
  57. package/dist/hooks/magic-context/producer-window-guard.d.ts.map +1 -1
  58. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +12 -0
  59. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  60. package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts +58 -0
  61. package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts.map +1 -0
  62. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +7 -0
  63. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  64. package/dist/hooks/magic-context/read-session-db.d.ts +5 -0
  65. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/read-session-raw.d.ts +19 -0
  67. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
  69. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  70. package/dist/hooks/magic-context/render-options.d.ts +21 -0
  71. package/dist/hooks/magic-context/render-options.d.ts.map +1 -0
  72. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/tag-messages.d.ts +4 -0
  74. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  75. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
  76. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  77. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/transform.d.ts +5 -7
  79. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  81. package/dist/{index-21919gcq.js → index-05n6ykca.js} +4 -4
  82. package/dist/{index-q76br5zn.js → index-1d289pq2.js} +26 -21
  83. package/dist/{index-w28y7d0z.js → index-1sarmj9z.js} +15 -15
  84. package/dist/{index-x57ep4fp.js → index-1wwh38fk.js} +323 -121
  85. package/dist/{index-pgy3h49n.js → index-2pgxcncf.js} +4 -4
  86. package/dist/{index-ffa8x2as.js → index-6sytd5w3.js} +18 -13
  87. package/dist/{index-16vwdyy5.js → index-6sz25c3s.js} +3 -3
  88. package/dist/{index-4hb8nt93.js → index-7h8a1xpc.js} +3 -3
  89. package/dist/{index-rg1cezmj.js → index-7zd5asz9.js} +140 -17
  90. package/dist/{index-jw4gbfkv.js → index-8ketfacn.js} +2 -2
  91. package/dist/{index-nenz4gpb.js → index-95s8xaj1.js} +6 -5
  92. package/dist/{index-bmwfzz28.js → index-9vqb5p1s.js} +4 -4
  93. package/dist/{index-0jz47061.js → index-a8bvhwqs.js} +190 -30
  94. package/dist/{index-wpwpn7nj.js → index-b16gpywn.js} +9 -9
  95. package/dist/{index-g7jkrz0x.js → index-bp5083x2.js} +1 -1
  96. package/dist/{index-mp2kghkv.js → index-dyvbsvga.js} +1 -1
  97. package/dist/{index-s178h9z8.js → index-f71thw8j.js} +1 -1
  98. package/dist/{index-kvw6xew3.js → index-fkx2qnvw.js} +2 -2
  99. package/dist/{index-f8cn4xqa.js → index-fwefky9w.js} +18 -5
  100. package/dist/{index-a43xq1pg.js → index-fx90bvjd.js} +5 -5
  101. package/dist/{index-0sahzkwr.js → index-g2q4htwp.js} +46 -2
  102. package/dist/{index-7bjgyaj1.js → index-gf0psee3.js} +243 -135
  103. package/dist/{index-mw7c950g.js → index-gp3kcpc4.js} +1 -1
  104. package/dist/{index-gjvjh960.js → index-hqkczed7.js} +1 -1
  105. package/dist/{index-mvvephtj.js → index-j75v2476.js} +1 -1
  106. package/dist/{index-150zz6fh.js → index-k29z4aqh.js} +1 -1
  107. package/dist/{index-b64n4d0h.js → index-kee4kn5j.js} +1 -1
  108. package/dist/index-ksdyrrav.js +52 -0
  109. package/dist/{index-angx1s0k.js → index-mmfa86mt.js} +16 -6
  110. package/dist/{index-9jvab89d.js → index-n6m03s3n.js} +2 -2
  111. package/dist/{index-q28hsbpg.js → index-nj7yykkx.js} +1 -1
  112. package/dist/{index-ghc9f0n7.js → index-p5y3k4g7.js} +29 -1
  113. package/dist/{index-6k86es2p.js → index-qtbdx42g.js} +54 -25
  114. package/dist/{index-a865mj02.js → index-tdn0zkw4.js} +4 -4
  115. package/dist/{index-0x9cn9w1.js → index-wqs4q74r.js} +8 -8
  116. package/dist/{index-swgpe402.js → index-x2xjyq8f.js} +11 -11
  117. package/dist/{index-a4b0gbyg.js → index-y9f76s3f.js} +1 -1
  118. package/dist/{index-3403gbzj.js → index-yx5kgp2x.js} +288 -127
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +97 -76
  121. package/dist/{logger-wn328tfg.js → logger-jm3sqqzr.js} +2 -2
  122. package/dist/{message-index-bounded-fskdyc81.js → message-index-bounded-nq6rp8xa.js} +16 -16
  123. package/dist/{message-index-6r1x9cqh.js → message-index-df7swgy1.js} +16 -16
  124. package/dist/{message-time-backfill-nb5hhnrt.js → message-time-backfill-qjge9044.js} +3 -3
  125. package/dist/migration-worker.js +11 -11
  126. package/dist/plugin/dream-timer.d.ts.map +1 -1
  127. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  128. package/dist/plugin/tool-registry.d.ts.map +1 -1
  129. package/dist/{project-embedding-registry-vy7sv9jt.js → project-embedding-registry-q0ysjyzc.js} +11 -11
  130. package/dist/raw-ordinal-warmup-worker.js +12 -7
  131. package/dist/{read-session-chunk-zgpvs423.js → read-session-chunk-ax05f7gr.js} +11 -11
  132. package/dist/{read-session-raw-gm6xj30v.js → read-session-raw-m56hc7v2.js} +7 -3
  133. package/dist/{recomp-orchestrator-77xc8wpe.js → recomp-orchestrator-a0mvby4e.js} +29 -29
  134. package/dist/{safe-notification-target-jdynm677.js → safe-notification-target-1szv1k5k.js} +3 -3
  135. package/dist/{search-72fkjwk2.js → search-fm002702.js} +23 -23
  136. package/dist/{send-session-notification-q8ngbap3.js → send-session-notification-y2wg3fkh.js} +6 -6
  137. package/dist/shared/data-path.d.ts +4 -0
  138. package/dist/shared/data-path.d.ts.map +1 -1
  139. package/dist/shared/prompt-surface-runtime.d.ts +5 -0
  140. package/dist/shared/prompt-surface-runtime.d.ts.map +1 -1
  141. package/dist/{storage-tags-35m4gms2.js → storage-tags-yygfb9c8.js} +7 -5
  142. package/dist/{task-config-cgpg0nvh.js → task-config-x3qmayd2.js} +6 -2
  143. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  144. package/dist/{transform-postprocess-phase-r8d406j0.js → transform-postprocess-phase-s84rdf32.js} +29 -29
  145. package/dist/v2/auto-search-worker.js +4 -4
  146. package/dist/v2/{compaction-marker-candidates-a15w3mqh.js → compaction-marker-candidates-1vqwr3s5.js} +2 -2
  147. package/dist/v2/compaction-marker-candidates-worker.js +1 -1
  148. package/dist/v2/{context-z2yagwy4.js → context-x60fa16g.js} +758 -286
  149. package/dist/v2/{derive-budgets-0rmpmxjw.js → derive-budgets-z25jw3py.js} +3 -3
  150. package/dist/v2/embedding-backfill-mbjyza2a.js +20 -0
  151. package/dist/v2/embedding-worker-process.js +1 -1
  152. package/dist/v2/embedding-worker.js +5 -5
  153. package/dist/v2/{history-owner-2cr9py37.js → history-owner-42e16w0n.js} +2 -2
  154. package/dist/v2/hooks/context.d.ts.map +1 -1
  155. package/dist/v2/hooks/dream-manual.d.ts +1 -0
  156. package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
  157. package/dist/v2/hooks/dream-timer.d.ts +3 -1
  158. package/dist/v2/hooks/dream-timer.d.ts.map +1 -1
  159. package/dist/v2/hooks/dream-trigger.d.ts +6 -1
  160. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  161. package/dist/v2/hooks/payload.d.ts +1 -1
  162. package/dist/v2/hooks/payload.d.ts.map +1 -1
  163. package/dist/v2/hooks/transform-decision-binding.d.ts +15 -0
  164. package/dist/v2/hooks/transform-decision-binding.d.ts.map +1 -0
  165. package/dist/v2/hooks/transform-features.d.ts +40 -0
  166. package/dist/v2/hooks/transform-features.d.ts.map +1 -0
  167. package/dist/v2/{logger-te6e1j72.js → logger-7qt02bnb.js} +1 -1
  168. package/dist/v2/{message-index-9ezq6wze.js → message-index-5nayhm1r.js} +15 -15
  169. package/dist/v2/{message-index-bounded-rqc603f2.js → message-index-bounded-pgv1ndpb.js} +15 -15
  170. package/dist/v2/{message-time-backfill-rz1pnpaj.js → message-time-backfill-bsteyc4d.js} +2 -2
  171. package/dist/v2/migration-worker.js +10 -10
  172. package/dist/v2/{project-embedding-registry-ja23aygk.js → project-embedding-registry-jbmjc0p4.js} +12 -10
  173. package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
  174. package/dist/v2/{read-session-chunk-7f87tg2q.js → read-session-chunk-hr3w5bjk.js} +10 -10
  175. package/dist/v2/{read-session-raw-h4azh85b.js → read-session-raw-b3tf6ra1.js} +6 -2
  176. package/dist/v2/recomp-orchestrator-8w3449eb.js +59 -0
  177. package/dist/v2/{safe-notification-target-936374xx.js → safe-notification-target-qg7n2s77.js} +2 -2
  178. package/dist/v2/{search-2td1b1wy.js → search-mhmxgq0e.js} +22 -22
  179. package/dist/v2/{send-session-notification-6n7chhyp.js → send-session-notification-jevgj9fe.js} +5 -5
  180. package/dist/v2/{server-npm52h2q.js → server-05xjtq6c.js} +1 -1
  181. package/dist/v2/{server-s6jqh8bj.js → server-0ppsweh6.js} +1 -1
  182. package/dist/v2/server-0s95v3en.js +49 -0
  183. package/dist/v2/{server-2hxypdx5.js → server-25tg45b4.js} +17 -12
  184. package/dist/v2/{server-44ryn9rb.js → server-2x42esxd.js} +3 -3
  185. package/dist/v2/{server-4qr18rfg.js → server-37ngj8qw.js} +10 -51
  186. package/dist/v2/{server-4zwx20yg.js → server-4c10404h.js} +3 -3
  187. package/dist/v2/{server-23znwjqk.js → server-50mkkhy1.js} +14 -11
  188. package/dist/v2/{server-c9w52qss.js → server-5gvkzzrf.js} +290 -76
  189. package/dist/v2/{server-7dv9wt9r.js → server-6pmqg9m4.js} +1 -1
  190. package/dist/v2/{server-ak7w74j9.js → server-83ygfha2.js} +4 -4
  191. package/dist/v2/{server-4rs8sm06.js → server-9ewkzqgd.js} +5 -5
  192. package/dist/v2/{server-kmapq3v0.js → server-bxpwy6fy.js} +18 -5
  193. package/dist/v2/{server-zrwaj29a.js → server-d8tj10db.js} +25 -20
  194. package/dist/v2/{server-cxsr0ng6.js → server-da07v4xp.js} +1 -1
  195. package/dist/v2/{server-9e5r8y60.js → server-f2xf5gcb.js} +46 -2
  196. package/dist/v2/{server-hn9fb3v0.js → server-f7jfmrrz.js} +2 -2
  197. package/dist/v2/{server-f27he3j1.js → server-fa75w6gp.js} +4 -4
  198. package/dist/v2/{server-njnx39q2.js → server-gvkm8xaj.js} +189 -29
  199. package/dist/v2/{server-ckrb5rm8.js → server-h0410h0v.js} +1 -1
  200. package/dist/v2/{server-nveratm5.js → server-kn9n2qgd.js} +1 -1
  201. package/dist/v2/{server-gc8x2xdb.js → server-m97brnat.js} +9 -9
  202. package/dist/v2/{server-z0rjemg1.js → server-nmrm2rjy.js} +8 -8
  203. package/dist/v2/{server-bx59ezg6.js → server-prg55b7k.js} +16 -6
  204. package/dist/v2/{server-89fcbe37.js → server-pwv4ezb0.js} +1 -1
  205. package/dist/v2/{server-r5p3b1wy.js → server-qd11g795.js} +29 -1
  206. package/dist/v2/{server-988cqjme.js → server-rrqpvwqd.js} +2 -2
  207. package/dist/v2/{server-4easnf78.js → server-sz8jj92q.js} +150 -18
  208. package/dist/v2/{server-7e087rvk.js → server-th4y11y7.js} +16 -16
  209. package/dist/v2/{server-9a6bwc12.js → server-vknbt0gq.js} +255 -135
  210. package/dist/v2/{server-63ha7f0f.js → server-yrvqaswb.js} +1 -1
  211. package/dist/v2/{server-xqf2d2mg.js → server-zs8d0s3b.js} +2 -2
  212. package/dist/v2/server.d.ts.map +1 -1
  213. package/dist/v2/server.js +13 -6
  214. package/dist/v2/{storage-tags-c4zfcxv4.js → storage-tags-a2gq6dw7.js} +6 -4
  215. package/dist/v2/store-reader.d.ts +4 -0
  216. package/dist/v2/store-reader.d.ts.map +1 -1
  217. package/dist/v2/{task-config-x0hq3qfd.js → task-config-nvz8mapa.js} +6 -2
  218. package/dist/v2/{wrapup-orchestrator-wg8dmmm9.js → wrapup-orchestrator-r82y780v.js} +30 -29
  219. package/dist/wrapup-orchestrator-vmt6z3q5.js +47 -0
  220. package/package.json +1 -1
  221. package/src/agents/smart-notes-dreamer-gate.fixture.ts +171 -0
  222. package/src/agents/smart-notes-dreamer-gate.golden.json +245 -0
  223. package/src/agents/smart-notes-dreamer-gate.test.ts +161 -0
  224. package/src/config/agent-disable.ts +13 -0
  225. package/src/config/dependency-notes.test.ts +114 -0
  226. package/src/config/dependency-notes.ts +80 -0
  227. package/src/config/schema/magic-context.ts +23 -14
  228. package/src/features/magic-context/dreamer/task-registry.ts +40 -0
  229. package/src/shared/chunk-vector-writer-guard.test.ts +72 -0
  230. package/src/shared/data-path.test.ts +35 -1
  231. package/src/shared/data-path.ts +57 -1
  232. package/src/shared/prompt-surface-runtime.test.ts +15 -0
  233. package/src/shared/prompt-surface-runtime.ts +12 -0
  234. package/dist/embedding-backfill-3h2m5n0q.js +0 -21
  235. package/dist/v2/embedding-backfill-vr7wdtrf.js +0 -20
  236. package/dist/v2/recomp-orchestrator-s5tdpsbs.js +0 -59
  237. package/dist/wrapup-orchestrator-b1z99yg5.js +0 -47
@@ -1,3 +1,19 @@
1
+ import {
2
+ CANONICAL_DREAM_TASKS,
3
+ DREAM_TASK_CAPABILITIES,
4
+ toolLoopDreamTasks,
5
+ formatDreamTaskBacklogs,
6
+ formatDreamTaskFailures,
7
+ processedDreamTaskItems,
8
+ PROJECT_MEMORY_DREAM_TASKS,
9
+ dreamTaskAllowedBySettings,
10
+ leaseKindFor,
11
+ leaseKeyFor,
12
+ isCanonicalDreamTask,
13
+ compareTaskOrder,
14
+ buildDreamTaskRuntimeConfigs2,
15
+ userMemoryCollectionEnabled2
16
+ } from "./index-p5y3k4g7.js";
1
17
  import {
2
18
  getHarness2,
3
19
  harnessOwnsOpenCodeStore2
@@ -6,7 +22,7 @@ import {
6
22
  getDataDir,
7
23
  getMagicContextStorageResolution,
8
24
  getMagicContextStorageDir
9
- } from "./index-0sahzkwr.js";
25
+ } from "./index-g2q4htwp.js";
10
26
  import {
11
27
  sanitizeDiagnosticText,
12
28
  hasShareabilitySensitiveText,
@@ -15,7 +31,7 @@ import {
15
31
  log2,
16
32
  sessionLog2,
17
33
  getLoggerDiagnostics2
18
- } from "./index-mvvephtj.js";
34
+ } from "./index-j75v2476.js";
19
35
  import {
20
36
  resolveOpenCodeDbPath,
21
37
  assertOpenCodeStoreGeneration,
@@ -54,7 +70,7 @@ import {
54
70
  storedPathBelongsToIdentity,
55
71
  beginBootQuietPeriod,
56
72
  scheduleAfterBootQuiet
57
- } from "./index-0jz47061.js";
73
+ } from "./index-a8bvhwqs.js";
58
74
  import {
59
75
  recordSessionProjectIdentity,
60
76
  hasRecordedSessionProjectIdentity,
@@ -81,7 +97,7 @@ import {
81
97
  drainCommitBacklogForProject2,
82
98
  embedSessionCompartmentChunks2,
83
99
  getEmbeddingCoverageStatus2
84
- } from "./index-rg1cezmj.js";
100
+ } from "./index-7zd5asz9.js";
85
101
  import {
86
102
  hasTrustedAbsoluteWall,
87
103
  applyProvenInputFloor,
@@ -93,7 +109,7 @@ import {
93
109
  deriveTriggerBudget2,
94
110
  resolveKnownHistorianContextLimit2,
95
111
  resolveHistorianProducerLimits2
96
- } from "./index-jw4gbfkv.js";
112
+ } from "./index-8ketfacn.js";
97
113
  import {
98
114
  resolveModelCalibration,
99
115
  calibrateBuckets,
@@ -107,7 +123,7 @@ import {
107
123
  estimateTokens,
108
124
  estimateFixedPromptTokens,
109
125
  normalizeText
110
- } from "./index-gjvjh960.js";
126
+ } from "./index-hqkczed7.js";
111
127
  import {
112
128
  protectedToolTokenCount,
113
129
  peelLeadingMcTagNotation,
@@ -144,11 +160,11 @@ import {
144
160
  getDroppedTagsByNumbers2,
145
161
  getMaxDroppedTagNumber2,
146
162
  getTagById2
147
- } from "./index-f8cn4xqa.js";
163
+ } from "./index-fwefky9w.js";
148
164
  import {
149
165
  observeTemporalDecisions,
150
166
  stableStringify
151
- } from "./index-g7jkrz0x.js";
167
+ } from "./index-bp5083x2.js";
152
168
  import {
153
169
  withContentLanguageDirective,
154
170
  parseCron,
@@ -161,13 +177,14 @@ import {
161
177
  DEFAULT_HISTORIAN_TIMEOUT_MS,
162
178
  DEFAULT_LOCAL_EMBEDDING_MODEL,
163
179
  DREAM_TASK_PROMOTION_DEFAULTS
164
- } from "./index-w28y7d0z.js";
180
+ } from "./index-1sarmj9z.js";
165
181
  import {
166
182
  isRawCompactionSummaryInfo2,
167
183
  extractInMemoryMessageViews2,
168
184
  buildInMemoryTailRawMessages2,
185
+ RawOrdinalsNotReady2,
169
186
  runSessionWarmupWorker
170
- } from "./index-angx1s0k.js";
187
+ } from "./index-mmfa86mt.js";
171
188
  import {
172
189
  openCodeDbExists,
173
190
  withReadOnlySessionDb,
@@ -175,7 +192,7 @@ import {
175
192
  latestPersistedMessageForRecovery,
176
193
  latestRealUserTurnIdFromOpenCodeDb,
177
194
  findLastAssistantModelFromOpenCodeDb
178
- } from "./index-q76br5zn.js";
195
+ } from "./index-1d289pq2.js";
179
196
  import {
180
197
  expandToolPart,
181
198
  estimateTrueRawMessageTokens,
@@ -296,24 +313,10 @@ import {
296
313
  readRawSessionMessageById2,
297
314
  readSessionChunk2,
298
315
  readRawSessionSeedTail2
299
- } from "./index-wpwpn7nj.js";
316
+ } from "./index-b16gpywn.js";
300
317
  import {
301
318
  getMeasuredToolDefinitionTokens
302
- } from "./index-9jvab89d.js";
303
- import {
304
- CANONICAL_DREAM_TASKS,
305
- DREAM_TASK_CAPABILITIES,
306
- toolLoopDreamTasks,
307
- formatDreamTaskBacklogs,
308
- formatDreamTaskFailures,
309
- processedDreamTaskItems,
310
- leaseKindFor,
311
- leaseKeyFor,
312
- isCanonicalDreamTask,
313
- compareTaskOrder,
314
- buildDreamTaskRuntimeConfigs2,
315
- userMemoryCollectionEnabled2
316
- } from "./index-ghc9f0n7.js";
319
+ } from "./index-n6m03s3n.js";
317
320
  import {
318
321
  isFailClosedBlockingError,
319
322
  shouldBypassFailClosedBlock,
@@ -327,14 +330,14 @@ import {
327
330
  runSqliteOptimize,
328
331
  openDatabase,
329
332
  openCurrentDatabase
330
- } from "./index-swgpe402.js";
333
+ } from "./index-x2xjyq8f.js";
331
334
  import {
332
335
  registerOwnRpcServerInstance,
333
336
  rpcPortDir,
334
337
  rpcPortFilePath,
335
338
  parseRpcPortFile,
336
339
  inspectProcessesAsync
337
- } from "./index-q28hsbpg.js";
340
+ } from "./index-nj7yykkx.js";
338
341
  import {
339
342
  configureContextDatabasePragmas2
340
343
  } from "./index-fb3zxn06.js";
@@ -346,7 +349,7 @@ import {
346
349
  resolveStoredPathWorkspaceIdentity,
347
350
  storedPathBelongsToWorkspace,
348
351
  computeWorkspaceEpochFingerprint
349
- } from "./index-a865mj02.js";
352
+ } from "./index-tdn0zkw4.js";
350
353
  import {
351
354
  V2_MEMORY_CATEGORIES,
352
355
  CATEGORY_PRIORITY
@@ -354,8 +357,6 @@ import {
354
357
  import {
355
358
  getMagicContextBuiltinCommands,
356
359
  formatConfigParseStatusLine,
357
- COMPACTION_ENABLED_PATH,
358
- isCompactionEnabled,
359
360
  cortexKitUserConfigBasePath,
360
361
  cortexKitProjectConfigBasePath,
361
362
  resolveLegacyConfigSources,
@@ -457,7 +458,7 @@ import {
457
458
  failedInvocationStatus,
458
459
  recordChildInvocation,
459
460
  createPromptAsyncTransport,
460
- promptSurfaceHashMaterial,
461
+ systemPromptFingerprint,
461
462
  createPromptSurfaceRuntime,
462
463
  createPromptSurfaceGuidanceEpochCache,
463
464
  teardownChildSession,
@@ -517,10 +518,11 @@ import {
517
518
  getRawHistoryEligibility,
518
519
  hasRunnableCompartmentWindow,
519
520
  recordHighPressureNoEligibleHead,
521
+ noteTransformPassForExactOrdinalReads,
520
522
  snapRangeToCompartments,
521
523
  getActiveCompartmentRun,
522
524
  startCompartmentAgent
523
- } from "./index-3403gbzj.js";
525
+ } from "./index-yx5kgp2x.js";
524
526
  import {
525
527
  SubcClient,
526
528
  connectionFileExists,
@@ -528,7 +530,7 @@ import {
528
530
  toSynapseLaneDescriptor,
529
531
  formatSynapseLaneDescriptor,
530
532
  SynapseEmbeddingProvider
531
- } from "./index-kvw6xew3.js";
533
+ } from "./index-fkx2qnvw.js";
532
534
  import {
533
535
  BoundedSessionMap,
534
536
  LkgRecoveryFenceError,
@@ -549,7 +551,7 @@ import {
549
551
  indexSingleMessage2,
550
552
  indexMessagesAfterOrdinal2,
551
553
  sweepOrphanedOpenCodeMessageIndexes2
552
- } from "./index-0x9cn9w1.js";
554
+ } from "./index-wqs4q74r.js";
553
555
  import {
554
556
  renderUserFacingFailure,
555
557
  userFacingFailureCode,
@@ -593,7 +595,7 @@ import {
593
595
  readGitFileChangeTimesSince,
594
596
  verificationFileExists,
595
597
  normalizeVerificationFiles
596
- } from "./index-16vwdyy5.js";
598
+ } from "./index-6sz25c3s.js";
597
599
  import {
598
600
  registerNotificationSink2,
599
601
  pushNotification2,
@@ -603,7 +605,7 @@ import {
603
605
  } from "./index-x8a7jmkh.js";
604
606
  import {
605
607
  getLocalEmbeddingNativeMemoryStats
606
- } from "./index-bmwfzz28.js";
608
+ } from "./index-9vqb5p1s.js";
607
609
  import {
608
610
  saveEmbeddingIfHashMatches,
609
611
  invalidateProject2,
@@ -611,7 +613,7 @@ import {
611
613
  } from "./index-4dhv7mqz.js";
612
614
  import {
613
615
  cosineSimilarity
614
- } from "./index-a43xq1pg.js";
616
+ } from "./index-fx90bvjd.js";
615
617
  import {
616
618
  computeCueContentHash,
617
619
  hasMuralCueColumns,
@@ -658,17 +660,17 @@ import {
658
660
  resolveMemoriesByIdsForSearch2,
659
661
  unifiedSearch2,
660
662
  formatSearchResults2
661
- } from "./index-ffa8x2as.js";
663
+ } from "./index-6sytd5w3.js";
662
664
  import {
663
665
  flushIgnoredMessages2,
664
666
  clearIgnoredMessages2,
665
667
  observeIgnoredNotificationEvent2,
666
668
  sendStatusNotification2
667
- } from "./index-pgy3h49n.js";
669
+ } from "./index-2pgxcncf.js";
668
670
  import {
669
671
  setRecompStarting2,
670
672
  setRecompTerminal2
671
- } from "./index-21919gcq.js";
673
+ } from "./index-05n6ykca.js";
672
674
  import {
673
675
  makeToolCompositeKey,
674
676
  searchMessageHistoryOffThread,
@@ -719,17 +721,22 @@ import {
719
721
  abortSessionFailClosed2,
720
722
  evaluateEmergencyFailClosed2,
721
723
  runPostTransformPhase2
722
- } from "./index-6k86es2p.js";
724
+ } from "./index-qtbdx42g.js";
723
725
  import {
724
726
  ANNOUNCEMENT_VERSION2,
725
727
  ANNOUNCEMENT_FEATURES2,
726
728
  ANNOUNCEMENT_FOOTER2,
727
729
  markAnnouncementSeen2,
728
730
  shouldShowAnnouncement2
729
- } from "./index-mw7c950g.js";
731
+ } from "./index-gp3kcpc4.js";
730
732
  import {
731
733
  resolvePromptContext2
732
734
  } from "./index-fmsr7v69.js";
735
+ import {
736
+ COMPACTION_ENABLED_PATH,
737
+ isDreamerRunnable,
738
+ isCompactionEnabled
739
+ } from "./index-ksdyrrav.js";
733
740
  import {
734
741
  __toESM
735
742
  } from "./index-22jkk6wg.js";
@@ -761,7 +768,40 @@ import {
761
768
  } from "./index-8ajstryz.js";
762
769
  import {
763
770
  logSlowWriteTransaction
764
- } from "./index-150zz6fh.js";
771
+ } from "./index-k29z4aqh.js";
772
+
773
+ // src/config/dependency-notes.ts
774
+ function scheduledTasks(config) {
775
+ const tasks = config.dreamer?.tasks ?? {};
776
+ return Object.entries(tasks).filter(([, task]) => typeof task?.schedule === "string" && task.schedule.trim() !== "").map(([name]) => name);
777
+ }
778
+ function configDependencyNotes(config) {
779
+ const notes = [];
780
+ const dreamerRunnable = isDreamerRunnable(config);
781
+ const dreamerDisabled = config.dreamer?.disable === true;
782
+ const memoryOff = config.memory?.enabled === false;
783
+ const memoryTasks = scheduledTasks(config).filter((task) => PROJECT_MEMORY_DREAM_TASKS.includes(task));
784
+ if (dreamerRunnable && memoryOff && memoryTasks.length > 0) {
785
+ notes.push(`memory.enabled is false, so these scheduled dreamer tasks do not run for this project, on schedule or through /ctx-dream: ${memoryTasks.join(", ")}. maintain-docs, evaluate-smart-notes and review-user-memories still run.`);
786
+ }
787
+ if (dreamerDisabled && config.smart_notes?.enabled !== false) {
788
+ notes.push("dreamer.disable is true, so smart_notes.enabled has no effect: ctx_note does not offer surface_condition and pending smart notes are not evaluated.");
789
+ }
790
+ const reviewSchedule = config.dreamer?.tasks?.["review-user-memories"]?.schedule;
791
+ if (dreamerDisabled && typeof reviewSchedule === "string" && reviewSchedule.trim() !== "") {
792
+ notes.push("dreamer.disable is true, so dreamer.tasks.review-user-memories.schedule has no effect: the historian does not collect user observations and the <user-profile> block gets no new entries.");
793
+ }
794
+ return notes;
795
+ }
796
+ var loggedNotes = new Set;
797
+ function logConfigDependencyNotesOnce(config, log) {
798
+ const fresh = configDependencyNotes(config).filter((note) => !loggedNotes.has(note));
799
+ for (const note of fresh) {
800
+ loggedNotes.add(note);
801
+ log(`[magic-context] config note: ${note}`);
802
+ }
803
+ return fresh;
804
+ }
765
805
 
766
806
  // src/features/magic-context/dreamer/open-opencode-db.ts
767
807
  function openOpenCodeDb() {
@@ -10721,6 +10761,12 @@ function pruneIdleScheduleIdentities(db, now) {
10721
10761
 
10722
10762
  // src/features/magic-context/dreamer/task-scheduler.ts
10723
10763
  var MAX_TASK_RETRIES = 3;
10764
+ function tasksAllowedBySettings(deps) {
10765
+ return deps.tasks.filter((config) => dreamTaskAllowedBySettings(config.task, {
10766
+ projectMemoryEnabled: deps.projectMemoryEnabled,
10767
+ smartNotesEnabled: deps.smartNotesEnabled
10768
+ }));
10769
+ }
10724
10770
  function ensureSeeded(db, projectIdentity, config, now) {
10725
10771
  if (getTaskScheduleState(db, projectIdentity, config.task))
10726
10772
  return;
@@ -10939,16 +10985,17 @@ async function runManualDream(deps) {
10939
10985
  };
10940
10986
  if (!isUsableProjectIdentity(deps.projectIdentity))
10941
10987
  return result;
10988
+ const allowed = tasksAllowedBySettings(deps);
10942
10989
  let selected;
10943
10990
  let forceGate = false;
10944
10991
  if (deps.task) {
10945
- const cfg = deps.tasks.find((t) => t.task === deps.task);
10992
+ const cfg = allowed.find((t) => t.task === deps.task);
10946
10993
  if (!cfg)
10947
10994
  return result;
10948
10995
  selected = [cfg];
10949
10996
  forceGate = true;
10950
10997
  } else {
10951
- selected = deps.tasks.filter((t) => t.schedule.trim() !== "");
10998
+ selected = allowed.filter((t) => t.schedule.trim() !== "");
10952
10999
  }
10953
11000
  if (selected.length === 0)
10954
11001
  return result;
@@ -11015,10 +11062,11 @@ async function runManualDream(deps) {
11015
11062
  async function runDueTasksForProject(deps) {
11016
11063
  if (!isUsableProjectIdentity(deps.projectIdentity))
11017
11064
  return 0;
11018
- if (deps.projectMemoryEnabled === false)
11065
+ const tasks = tasksAllowedBySettings(deps);
11066
+ if (tasks.length === 0)
11019
11067
  return 0;
11020
11068
  const now = deps.now ?? Date.now();
11021
- const due = planDueTasks(deps.db, deps.projectIdentity, deps.tasks, now);
11069
+ const due = planDueTasks(deps.db, deps.projectIdentity, tasks, now);
11022
11070
  if (due.length === 0)
11023
11071
  return 0;
11024
11072
  const gated = [];
@@ -11648,7 +11696,7 @@ function scheduleInitialProjectRun(reg, db) {
11648
11696
  async function runProjectMaintenance(reg, origin, db) {
11649
11697
  const sampled = reg.sampleDreamRun?.();
11650
11698
  const current = sampled ? { ...reg, ...sampled } : reg;
11651
- const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || reg.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
11699
+ const projectMaintenanceEnabled = Boolean(current.dreamerConfig && current.dreamerConfig.disable !== true) || reg.memoryEnabled === true || current.gitCommitIndexing?.enabled === true || reg.historianChildSweep !== undefined;
11652
11700
  if (!projectMaintenanceEnabled)
11653
11701
  return;
11654
11702
  await reg.ensureRegistered(reg.directory, db);
@@ -11659,7 +11707,7 @@ async function runProjectMaintenance(reg, origin, db) {
11659
11707
  log2(`[magic-context] proactively embedded ${embeddedCount} ${embeddedCount === 1 ? "memory" : "memories"} for project ${reg.projectIdentity}`);
11660
11708
  }
11661
11709
  }
11662
- await sweepProject(current, origin, db);
11710
+ await sweepProject(current, origin, db, current.gitCommitIndexing?.enabled === true);
11663
11711
  }
11664
11712
  async function sweepProject(reg, origin, db, gitCommitEnabled) {
11665
11713
  if (!directoryStillExists(reg.directory)) {
@@ -11740,7 +11788,8 @@ async function sweepProject(reg, origin, db, gitCommitEnabled) {
11740
11788
  projectIdentity: reg.projectIdentity,
11741
11789
  tasks: runtimeConfigs,
11742
11790
  executor,
11743
- projectMemoryEnabled: reg.memoryEnabled !== false
11791
+ projectMemoryEnabled: reg.memoryEnabled !== false,
11792
+ smartNotesEnabled: reg.smartNotesEnabled
11744
11793
  });
11745
11794
  if (ran > 0) {
11746
11795
  log2(`[dreamer] timer tick (${origin}) ${reg.projectIdentity} — ran ${ran} task(s)`);
@@ -11864,6 +11913,15 @@ async function sweepGitCommits(args) {
11864
11913
  }
11865
11914
  }
11866
11915
 
11916
+ // src/plugin/dream-timer-module-client.ts
11917
+ function createDreamTimerModuleClient(moduleClient) {
11918
+ if (!moduleClient)
11919
+ return;
11920
+ return {
11921
+ call: (args) => moduleClient.call(args)
11922
+ };
11923
+ }
11924
+
11867
11925
  // src/plugin/embedding-bootstrap.ts
11868
11926
  import { readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
11869
11927
 
@@ -15921,9 +15979,9 @@ function registerRpcHandlers(rpcServer, args) {
15921
15979
  return { count: buildCompartmentCount(db, sessionId, moduleStatus) };
15922
15980
  });
15923
15981
  const buildManagedCtx = async (db) => {
15924
- const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-3nbxsyss.js"));
15982
+ const { deriveHistorianChunkTokens, resolveHistorianContextLimit } = await importPluginModule(() => import("./derive-budgets-5306b1jt.js"));
15925
15983
  const { resolveHistorianModel } = await importPluginModule(() => import("./model-resolution-nx97z3x7.js"));
15926
- const { userMemoryCollectionEnabled } = await importPluginModule(() => import("./task-config-cgpg0nvh.js"));
15984
+ const { userObservationCollectionEnabled, userObservationsRequested } = await importPluginModule(() => import("./task-config-x3qmayd2.js"));
15927
15985
  const DEFAULT_HISTORIAN_TIMEOUT_MS = 10 * 60 * 1000;
15928
15986
  const runConfig = historianRunConfig(config, currentPluginConfigReader(directory)?.poll().effective ?? config);
15929
15987
  const historianModel = resolveHistorianModel(runConfig, "opencode");
@@ -15941,7 +15999,8 @@ function registerRpcHandlers(rpcServer, args) {
15941
15999
  autoPromote: runConfig.memory?.auto_promote ?? true,
15942
16000
  historianModel: historianModel.primary,
15943
16001
  fallbackModels: historianModel.fallbacks,
15944
- userMemoriesEnabled: userMemoryCollectionEnabled(runConfig.dreamer),
16002
+ userMemoriesEnabled: userObservationCollectionEnabled(runConfig.dreamer),
16003
+ userObservationsRequested: userObservationsRequested(runConfig.dreamer),
15945
16004
  historianTwoPass: runConfig.historian?.two_pass === true,
15946
16005
  historianExpandTools: runConfig.historian?.expand_tools,
15947
16006
  getNotificationParams: (sessionId) => getLiveNotificationParams(sessionId, liveSessionState.liveModelBySession, liveSessionState.variantBySession, liveSessionState.agentBySession, runConfig.toast_duration_ms)
@@ -15953,7 +16012,7 @@ function registerRpcHandlers(rpcServer, args) {
15953
16012
  return { ok: false, error: "no session" };
15954
16013
  const readDirectory = args.readSessionDirectory;
15955
16014
  if (readDirectory) {
15956
- const { handoffHistoryWork } = await import("./history-owner-ty29fz0f.js");
16015
+ const { handoffHistoryWork } = await import("./history-owner-xp3pngv7.js");
15957
16016
  const handed = await handoffHistoryWork({
15958
16017
  storageDir: args.storageDir ?? getMagicContextStorageDir(),
15959
16018
  directory,
@@ -15972,8 +16031,8 @@ function registerRpcHandlers(rpcServer, args) {
15972
16031
  const db = readDatabase();
15973
16032
  if (!db)
15974
16033
  return { ok: false, error: "db unavailable" };
15975
- const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-77xc8wpe.js"));
15976
- const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-q8ngbap3.js"));
16034
+ const { runManagedRecomp } = await importPluginModule(() => import("./recomp-orchestrator-a0mvby4e.js"));
16035
+ const { sendIgnoredMessage } = await importPluginModule(() => import("./send-session-notification-y2wg3fkh.js"));
15977
16036
  log2(`[rpc] recomp requested for session ${sessionId}`);
15978
16037
  if (!args.client && !args.hiddenCompletionExecutor) {
15979
16038
  return {
@@ -16031,7 +16090,7 @@ function registerRpcHandlers(rpcServer, args) {
16031
16090
  rpcServer.handle("wrapup", async (params) => {
16032
16091
  const readDirectory = args.readSessionDirectory;
16033
16092
  if (readDirectory && params.sessionId) {
16034
- const { handoffHistoryWork } = await import("./history-owner-ty29fz0f.js");
16093
+ const { handoffHistoryWork } = await import("./history-owner-xp3pngv7.js");
16035
16094
  const sessionId = String(params.sessionId);
16036
16095
  const handed = await handoffHistoryWork({
16037
16096
  storageDir: args.storageDir ?? getMagicContextStorageDir(),
@@ -16057,7 +16116,7 @@ function registerRpcHandlers(rpcServer, args) {
16057
16116
  const db = readDatabase();
16058
16117
  if (!db)
16059
16118
  return { ok: false, error: "db unavailable" };
16060
- const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-b1z99yg5.js"));
16119
+ const { runManagedWrapup } = await importPluginModule(() => import("./wrapup-orchestrator-vmt6z3q5.js"));
16061
16120
  const model = liveSessionState.liveModelBySession.get(sessionId);
16062
16121
  const contextLimit = model ? resolveContextLimit(model.providerID, model.modelID, { db, sessionID: sessionId }) : 128000;
16063
16122
  const ctx = {
@@ -16178,6 +16237,11 @@ var pendingDecisionBySession = new Map;
16178
16237
  var pendingPiDecisionBySession = new Map;
16179
16238
  var lastBoundMessageIdBySession = new Map;
16180
16239
  var scheduledWriteTokensBySession = new Map;
16240
+ var systemHashChangedSessions = new Set;
16241
+ var piSystemHashChangedSessions = new Set;
16242
+ var unbustedPassBySession = new Map;
16243
+ var newestInputAssistantBySession = new Map;
16244
+ var stagedV2DecisionBySession = new Map;
16181
16245
  var writerOverrideForTests = null;
16182
16246
  var retentionOverrideForTests = null;
16183
16247
  function normalizeMaterializeReason(harness, reason, rematerialized) {
@@ -16219,14 +16283,73 @@ function writeRustTransformDecision(args) {
16219
16283
  lkgFrozenReleaseReason: args.lkgFrozenReleaseReason
16220
16284
  });
16221
16285
  }
16222
- function clearOpenCodePendingTransformDecision(sessionId) {
16286
+ function clearOpenCodePendingTransformDecision(sessionId, inputMessages) {
16223
16287
  pendingDecisionBySession.delete(sessionId);
16288
+ unbustedPassBySession.delete(sessionId);
16289
+ if (!inputMessages)
16290
+ return;
16291
+ let newestAssistant = "";
16292
+ for (const message of inputMessages) {
16293
+ const id = message.info?.id;
16294
+ if (message.info?.role !== "assistant" || typeof id !== "string")
16295
+ continue;
16296
+ if (id > newestAssistant)
16297
+ newestAssistant = id;
16298
+ }
16299
+ newestInputAssistantBySession.set(sessionId, newestAssistant);
16224
16300
  }
16225
16301
  function clearTransformDecisionSession(sessionId) {
16226
16302
  pendingDecisionBySession.delete(sessionId);
16227
16303
  pendingPiDecisionBySession.delete(sessionId);
16228
16304
  lastBoundMessageIdBySession.delete(sessionId);
16229
16305
  scheduledWriteTokensBySession.delete(sessionId);
16306
+ systemHashChangedSessions.delete(sessionId);
16307
+ piSystemHashChangedSessions.delete(sessionId);
16308
+ unbustedPassBySession.delete(sessionId);
16309
+ newestInputAssistantBySession.delete(sessionId);
16310
+ stagedV2DecisionBySession.delete(sessionId);
16311
+ }
16312
+ function noteSystemPromptHashChange(sessionId) {
16313
+ systemHashChangedSessions.add(sessionId);
16314
+ }
16315
+ function noteOpenCodeUnbustedPass(sessionId, decision) {
16316
+ unbustedPassBySession.set(sessionId, decision);
16317
+ }
16318
+ var IDLE_EXPIRY_REASONS = new Set([
16319
+ "ttl_idle",
16320
+ "ttl_expiry"
16321
+ ]);
16322
+ function withSystemHashReason(decision) {
16323
+ if (IDLE_EXPIRY_REASONS.has(decision.materializeReason))
16324
+ return decision;
16325
+ return { ...decision, materializeReason: "system_hash" };
16326
+ }
16327
+ function unknownPassDecision() {
16328
+ return {
16329
+ tsMs: Date.now(),
16330
+ decision: "unknown",
16331
+ materialized: false,
16332
+ materializeReason: null,
16333
+ systemHashPrev: null,
16334
+ systemHashNew: null,
16335
+ m0ModelKeyPrev: null,
16336
+ m0ModelKeyNew: null,
16337
+ emergency: false,
16338
+ droppedTokens: 0,
16339
+ droppedCount: 0,
16340
+ inputTokens: 0,
16341
+ bustedThisPass: false
16342
+ };
16343
+ }
16344
+ function takeOpenCodeDecisionForBinding(sessionId, applySystemHashChange) {
16345
+ const pending = pendingDecisionBySession.get(sessionId);
16346
+ const unbusted = unbustedPassBySession.get(sessionId);
16347
+ pendingDecisionBySession.delete(sessionId);
16348
+ unbustedPassBySession.delete(sessionId);
16349
+ if (!applySystemHashChange || !systemHashChangedSessions.has(sessionId))
16350
+ return pending;
16351
+ systemHashChangedSessions.delete(sessionId);
16352
+ return withSystemHashReason(pending ?? unbusted ?? unknownPassDecision());
16230
16353
  }
16231
16354
  function recordPendingTransformDecision(sessionId, decision) {
16232
16355
  if (!decision.bustedThisPass) {
@@ -16236,8 +16359,9 @@ function recordPendingTransformDecision(sessionId, decision) {
16236
16359
  pendingDecisionBySession.set(sessionId, decision);
16237
16360
  }
16238
16361
  function scheduleOpenCodeTransformDecisionWrite(args) {
16239
- const pending = pendingDecisionBySession.get(args.sessionId);
16240
- if (!pending)
16362
+ const newestInput = newestInputAssistantBySession.get(args.sessionId) ?? "";
16363
+ const systemHashChanged = args.messageId > newestInput && systemHashChangedSessions.has(args.sessionId);
16364
+ if (!pendingDecisionBySession.has(args.sessionId) && !systemHashChanged)
16241
16365
  return false;
16242
16366
  if (lastBoundMessageIdBySession.get(args.sessionId) === args.messageId) {
16243
16367
  return false;
@@ -16245,8 +16369,10 @@ function scheduleOpenCodeTransformDecisionWrite(args) {
16245
16369
  const dbPath = getDatabasePath(args.db);
16246
16370
  if (!dbPath)
16247
16371
  return false;
16372
+ const pending = takeOpenCodeDecisionForBinding(args.sessionId, systemHashChanged);
16373
+ if (!pending)
16374
+ return false;
16248
16375
  lastBoundMessageIdBySession.set(args.sessionId, args.messageId);
16249
- pendingDecisionBySession.delete(args.sessionId);
16250
16376
  const token = addScheduledWriteToken(args.sessionId);
16251
16377
  inRootAsyncContext2(() => setTimeout(() => {
16252
16378
  try {
@@ -16265,6 +16391,54 @@ function scheduleOpenCodeTransformDecisionWrite(args) {
16265
16391
  }, 0));
16266
16392
  return true;
16267
16393
  }
16394
+ function stageOpenCodeV2TransformDecision(args) {
16395
+ const systemHashChanged = systemHashChangedSessions.has(args.sessionId);
16396
+ const decision = takeOpenCodeDecisionForBinding(args.sessionId, true);
16397
+ stagedV2DecisionBySession.delete(args.sessionId);
16398
+ if (!decision || args.responseAfterSequence === undefined)
16399
+ return false;
16400
+ if (!decision.bustedThisPass && !systemHashChanged)
16401
+ return false;
16402
+ stagedV2DecisionBySession.set(args.sessionId, {
16403
+ decision,
16404
+ responseAfterSequence: args.responseAfterSequence
16405
+ });
16406
+ return true;
16407
+ }
16408
+ function bindOpenCodeV2TransformDecision(args) {
16409
+ const staged = stagedV2DecisionBySession.get(args.sessionId);
16410
+ if (!staged)
16411
+ return false;
16412
+ const reply = args.firstAssistantAfter(staged.responseAfterSequence);
16413
+ if (!reply || reply.state === "running") {
16414
+ if (args.passStarting)
16415
+ stagedV2DecisionBySession.delete(args.sessionId);
16416
+ return false;
16417
+ }
16418
+ stagedV2DecisionBySession.delete(args.sessionId);
16419
+ if (reply.state === "failed")
16420
+ return false;
16421
+ const dbPath = getDatabasePath(args.db);
16422
+ if (!dbPath)
16423
+ return false;
16424
+ const token = addScheduledWriteToken(args.sessionId);
16425
+ inRootAsyncContext2(() => setTimeout(() => {
16426
+ try {
16427
+ if (!hasScheduledWriteToken(args.sessionId, token))
16428
+ return;
16429
+ writeTransformDecisionBestEffort(dbPath, {
16430
+ ...staged.decision,
16431
+ sessionId: args.sessionId,
16432
+ harness: "opencode2",
16433
+ messageId: reply.id,
16434
+ inputTokens: Number.isFinite(reply.inputTokens) ? reply.inputTokens : staged.decision.inputTokens
16435
+ });
16436
+ } finally {
16437
+ deleteScheduledWriteToken(args.sessionId, token);
16438
+ }
16439
+ }, 0));
16440
+ return true;
16441
+ }
16268
16442
  function addScheduledWriteToken(sessionId) {
16269
16443
  const token = Symbol(sessionId);
16270
16444
  let tokens = scheduledWriteTokensBySession.get(sessionId);
@@ -16745,6 +16919,16 @@ function commitCompactionModeRecord(db, sessionId, record) {
16745
16919
  setCompactionModeRecord(db, sessionId, record);
16746
16920
  }
16747
16921
 
16922
+ // src/hooks/magic-context/compartment-trigger-error.ts
16923
+ function recordCompartmentTriggerError(passOutcome, sessionId, error, log = sessionLog2) {
16924
+ passOutcome.record("compartment-trigger-failure");
16925
+ if (error instanceof RawOrdinalsNotReady2) {
16926
+ log(sessionId, "compartment trigger deferred: raw ordinals not ready; the next pass evaluates it again");
16927
+ return;
16928
+ }
16929
+ log(sessionId, "compartment trigger failed (non-fatal):", error);
16930
+ }
16931
+
16748
16932
  // src/hooks/magic-context/pass-outcome.ts
16749
16933
  var PASS_DEGRADATION_EFFECTS = {
16750
16934
  "store-generation-rebase-failure": "changes-request",
@@ -16807,6 +16991,36 @@ function createPassOutcome() {
16807
16991
  };
16808
16992
  }
16809
16993
 
16994
+ // src/hooks/magic-context/render-options.ts
16995
+ function createM0RenderOptions(controls, contextUsage, modelKey, resolvedContextLimit, projectPath) {
16996
+ return {
16997
+ projectPath: controls.memoryConfig?.enabled ? projectPath : undefined,
16998
+ memoryEnabled: controls.memoryConfig?.enabled,
16999
+ memoryInjectionBudgetTokens: controls.memoryConfig?.injectionBudgetTokens,
17000
+ injectDocs: controls.injectDocs,
17001
+ muralEnabled: controls.muralEnabled,
17002
+ temporalAwareness: controls.experimentalTemporalAwareness,
17003
+ historyBudgetTokens: resolveHistoryBudgetTokens(controls.historyBudgetPercentage, contextUsage, controls.executeThresholdPercentage, modelKey, controls.executeThresholdTokens, resolvedContextLimit),
17004
+ historyBudgetPolicyIdentity: historyBudgetPolicyIdentity(controls.historyBudgetPercentage, controls.executeThresholdPercentage, modelKey, controls.executeThresholdTokens)
17005
+ };
17006
+ }
17007
+ function resolveHistoryBudgetTokens(historyBudgetPercentage, contextUsage, executeThresholdPercentage, modelKey, executeThresholdTokens, resolvedContextLimit) {
17008
+ if (!historyBudgetPercentage)
17009
+ return;
17010
+ let contextLimit = resolvedContextLimit && resolvedContextLimit > 0 ? resolvedContextLimit : 0;
17011
+ if (contextLimit <= 0) {
17012
+ if (contextUsage.percentage <= 0)
17013
+ return;
17014
+ contextLimit = contextUsage.inputTokens / (contextUsage.percentage / 100);
17015
+ }
17016
+ if (!Number.isFinite(contextLimit) || contextLimit <= 0)
17017
+ return;
17018
+ return Math.floor(contextLimit * (resolveExecuteThreshold(executeThresholdPercentage ?? 65, modelKey, 65, {
17019
+ tokensConfig: executeThresholdTokens,
17020
+ contextLimit
17021
+ }) / 100) * historyBudgetPercentage);
17022
+ }
17023
+
16810
17024
  // src/hooks/magic-context/rust-mode-transform.ts
16811
17025
  import { createHash as createHash12, randomUUID as randomUUID6 } from "node:crypto";
16812
17026
 
@@ -23227,6 +23441,7 @@ async function runCompartmentPhaseImpl(args) {
23227
23441
  ensureProjectRegistered: args.ensureProjectRegistered,
23228
23442
  getNotificationParams: args.getNotificationParams,
23229
23443
  experimentalUserMemories: args.experimentalUserMemories,
23444
+ userObservationsRequested: args.userObservationsRequested,
23230
23445
  historianTwoPass: args.historianTwoPass,
23231
23446
  historianExpandTools: args.historianExpandTools,
23232
23447
  memoryEnabled: args.memoryEnabled,
@@ -23268,6 +23483,7 @@ async function runCompartmentPhaseImpl(args) {
23268
23483
  ensureProjectRegistered: args.ensureProjectRegistered,
23269
23484
  getNotificationParams: args.getNotificationParams,
23270
23485
  experimentalUserMemories: args.experimentalUserMemories,
23486
+ userObservationsRequested: args.userObservationsRequested,
23271
23487
  historianTwoPass: args.historianTwoPass,
23272
23488
  historianExpandTools: args.historianExpandTools,
23273
23489
  memoryEnabled: args.memoryEnabled,
@@ -23504,7 +23720,7 @@ function createTransform(deps) {
23504
23720
  return historianRun?.toastDurationMs === undefined ? params : { ...params, toastDurationMs: historianRun.toastDurationMs };
23505
23721
  };
23506
23722
  beginLkgPass(sessionId);
23507
- clearOpenCodePendingTransformDecision(sessionId);
23723
+ clearOpenCodePendingTransformDecision(sessionId, messages);
23508
23724
  const db = deps.db;
23509
23725
  try {
23510
23726
  const tPrepare = performance.now();
@@ -23871,9 +24087,10 @@ function createTransform(deps) {
23871
24087
  const persistedUsageFreshForBoundary = persistedUsageBeforeResets && Date.now() - persistedUsageBeforeResets.updatedAt <= 10 * 60 * 1000 && (persistedUsageBeforeResets.lastObservedModelKey === null || currentModelKeyForBoundary === undefined || piModelRefToCanonical(persistedUsageBeforeResets.lastObservedModelKey) === piModelRefToCanonical(currentModelKeyForBoundary)) && (resolvedContextLimit === undefined || persistedUsageBeforeResets.lastUsageContextLimit === 0 || persistedUsageBeforeResets.lastUsageContextLimit === resolvedContextLimit) ? persistedUsageBeforeResets.usage : null;
23872
24088
  const boundaryUsageForProtectedTail = persistedUsageFreshForBoundary ?? contextUsageEarly;
23873
24089
  const boundaryUsageSource = persistedUsageFreshForBoundary ? "persisted" : "live";
23874
- const historyPolicyIdentity = historyBudgetPolicyIdentity(deps.historyBudgetPercentage, deps.executeThresholdPercentage, currentModelKeyForBoundary, deps.executeThresholdTokens);
23875
24090
  const historyContextLimit = resolvedContextLimit ?? (currentModelKeyForBoundary && persistedUsageBeforeResets?.lastObservedModelKey && piModelRefToCanonical(currentModelKeyForBoundary) === piModelRefToCanonical(persistedUsageBeforeResets.lastObservedModelKey) && persistedUsageBeforeResets.lastUsageContextLimit > 0 ? persistedUsageBeforeResets.lastUsageContextLimit : undefined);
23876
- const historyBudgetTokens = resolveHistoryBudgetTokens(deps.historyBudgetPercentage, contextUsageEarly, deps.executeThresholdPercentage, deps.getModelKey?.(sessionId), deps.executeThresholdTokens, historyContextLimit);
24091
+ const memoryProjectDirectory = compartmentDirectory || process.cwd();
24092
+ const renderOptions = createM0RenderOptions(deps, contextUsageEarly, currentModelKeyForBoundary, historyContextLimit, deps.memoryConfig?.enabled ? resolveProjectIdentityForSession(memoryProjectDirectory, deps.allowHomeProject) : undefined);
24093
+ const { historyBudgetTokens, projectPath: projectIdentity } = renderOptions;
23877
24094
  const emergencyCeilingLimit = thresholdContextLimit ?? 0;
23878
24095
  const emergencyCeilingTokens = Number.isFinite(emergencyCeilingLimit) && emergencyCeilingLimit > 0 ? Math.floor(emergencyCeilingLimit * (effectiveExecuteThresholdPercentage / 100)) : undefined;
23879
24096
  const schedulerDecision = compactionOff ? "defer" : resolveSchedulerDecision(deps.scheduler, sessionMeta, contextUsageEarly, sessionId, deps.getModelKey?.(sessionId), resolvedContextLimit);
@@ -23971,6 +24188,7 @@ function createTransform(deps) {
23971
24188
  fallbackModelId,
23972
24189
  getNotificationParams: () => notificationParams,
23973
24190
  experimentalUserMemories: historianRun?.userMemoriesEnabled ?? deps.experimentalUserMemories,
24191
+ userObservationsRequested: historianRun?.userObservationsRequested ?? deps.userObservationsRequested,
23974
24192
  experimentalTemporalAwareness: deps.experimentalTemporalAwareness,
23975
24193
  historianTwoPass: historianRun?.twoPass ?? deps.historianTwoPass,
23976
24194
  historianExpandTools: historianRun?.expandTools ?? deps.historianExpandTools,
@@ -24007,8 +24225,6 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24007
24225
  });
24008
24226
  }
24009
24227
  logTransformTiming(sessionId, "emergencyRecoveryBlock", tFirstPass);
24010
- const memoryProjectDirectory = compartmentDirectory || process.cwd();
24011
- const projectIdentity = deps.memoryConfig?.enabled ? resolveProjectIdentityForSession(memoryProjectDirectory, deps.allowHomeProject) : undefined;
24012
24228
  if (deps.memoryConfig?.enabled) {
24013
24229
  maybeSendProjectIdentityWarning(deps, sessionId, memoryProjectDirectory, notificationParams);
24014
24230
  }
@@ -24028,6 +24244,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24028
24244
  sessionLog2(sessionId, `tag floor: 0 (full-scan fallback) — no leading wire message resolved a tag across ${messages.length} msgs`);
24029
24245
  }
24030
24246
  const ownerRatio = sessionDecisionCalibration(db, sessionId).proseRatio;
24247
+ noteTransformPassForExactOrdinalReads(sessionId);
24031
24248
  prewarmTagOwners(db, sessionId, ownerRatio);
24032
24249
  const tagOwnersReady = isTagOwnerSummaryReady2(db, sessionId, ownerRatio);
24033
24250
  let triggerBoundarySnapshot;
@@ -24051,8 +24268,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24051
24268
  triggerBoundarySnapshot = triggerResult.boundarySnapshot;
24052
24269
  }
24053
24270
  } catch (error) {
24054
- passOutcome.record("compartment-trigger-failure");
24055
- sessionLog2(sessionId, "compartment trigger failed (non-fatal):", error);
24271
+ recordCompartmentTriggerError(passOutcome, sessionId, error);
24056
24272
  }
24057
24273
  logTransformTiming(sessionId, "compartmentTrigger", tTrigger);
24058
24274
  }
@@ -24243,6 +24459,7 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24243
24459
  safeForBackgroundCompression: historianRunnable && (isCacheBusting || schedulerDecision === "execute"),
24244
24460
  deferredHistoryRefreshSessions,
24245
24461
  experimentalUserMemories: historianRun?.userMemoriesEnabled ?? deps.experimentalUserMemories,
24462
+ userObservationsRequested: historianRun?.userObservationsRequested ?? deps.userObservationsRequested,
24246
24463
  experimentalTemporalAwareness: deps.experimentalTemporalAwareness,
24247
24464
  historianTwoPass: historianRun?.twoPass ?? deps.historianTwoPass,
24248
24465
  historianExpandTools: historianRun?.expandTools ?? deps.historianExpandTools,
@@ -24293,14 +24510,8 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24293
24510
  db,
24294
24511
  sessionId,
24295
24512
  state: sessionMeta,
24296
- projectPath: projectIdentity,
24297
24513
  projectDirectory: sessionDirectory,
24298
- injectDocs: deps.injectDocs,
24299
- memoryEnabled: deps.memoryConfig?.enabled,
24300
- muralEnabled: deps.muralEnabled,
24301
- memoryInjectionBudgetTokens: deps.memoryConfig?.injectionBudgetTokens,
24302
- historyBudgetTokens,
24303
- historyBudgetPolicyIdentity: historyPolicyIdentity,
24514
+ ...renderOptions,
24304
24515
  hardSignals: m0HardSignals
24305
24516
  }).value;
24306
24517
  const protectionCacheBustingPass = !compactionOff && (schedulerDecision === "execute" || isCacheBusting || contextUsage.percentage >= forceMaterializationPercentage || deps.pendingMaterializationSessions.has(sessionId) || canConsumeDeferredLate && deferredMaterializationSessions.has(sessionId) || protectionFoldWillBust);
@@ -24441,16 +24652,9 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24441
24652
  passOutcome,
24442
24653
  historyRefreshSessions: deps.historyRefreshSessions,
24443
24654
  m0M1: {
24444
- projectPath: projectIdentity,
24445
24655
  projectDirectory: sessionDirectory,
24446
- injectDocs: deps.injectDocs,
24447
- memoryEnabled: deps.memoryConfig?.enabled,
24448
- memoryInjectionBudgetTokens: deps.memoryConfig?.injectionBudgetTokens,
24449
- historyBudgetTokens,
24450
- historyBudgetPolicyIdentity: historyPolicyIdentity,
24451
- temporalAwareness: deps.experimentalTemporalAwareness,
24452
- hardSignals: m0HardSignals,
24453
- muralEnabled: deps.muralEnabled
24656
+ ...renderOptions,
24657
+ hardSignals: m0HardSignals
24454
24658
  }
24455
24659
  });
24456
24660
  if (recovery.prefix && !recoveryNormalized) {
@@ -24694,6 +24898,24 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24694
24898
  bustedThisPass: true,
24695
24899
  lkgFrozenReleaseReason: recoveryReleaseReason
24696
24900
  });
24901
+ } else {
24902
+ noteOpenCodeUnbustedPass(sessionId, {
24903
+ tsMs: Date.now(),
24904
+ decision: schedulerDecision,
24905
+ materialized: postTransformResult.materialized,
24906
+ materializeReason: normalizeMaterializeReason("opencode", postTransformResult.materializeReason, postTransformResult.materialized),
24907
+ systemHashPrev: postTransformResult.systemHashPrev,
24908
+ systemHashNew: postTransformResult.systemHashNew,
24909
+ m0ToolSetHashPrev: postTransformResult.m0ToolSetHashPrev,
24910
+ m0ToolSetHashNew: postTransformResult.m0ToolSetHashNew,
24911
+ m0ModelKeyPrev: postTransformResult.m0ModelKeyPrev,
24912
+ m0ModelKeyNew: postTransformResult.m0ModelKeyNew,
24913
+ emergency: postTransformResult.emergency,
24914
+ droppedTokens: postTransformResult.droppedTokens,
24915
+ droppedCount: postTransformResult.droppedCount,
24916
+ inputTokens: contextUsage.inputTokens,
24917
+ bustedThisPass: false
24918
+ });
24697
24919
  }
24698
24920
  logTransformTiming(sessionId, "postTransformPhase", tPostProcess);
24699
24921
  const msgTokens = getMessageTokensCache(sessionId);
@@ -24824,25 +25046,6 @@ Historian previously failed ${historianFailureState.failureCount} time(s), so Ma
24824
25046
  }
24825
25047
  });
24826
25048
  }
24827
- function resolveHistoryBudgetTokens(historyBudgetPercentage, contextUsage, executeThresholdPercentage, modelKey, executeThresholdTokens, resolvedContextLimit) {
24828
- if (!historyBudgetPercentage) {
24829
- return;
24830
- }
24831
- let contextLimit = resolvedContextLimit && resolvedContextLimit > 0 ? resolvedContextLimit : 0;
24832
- if (contextLimit <= 0) {
24833
- if (contextUsage.percentage <= 0) {
24834
- return;
24835
- }
24836
- contextLimit = contextUsage.inputTokens / (contextUsage.percentage / 100);
24837
- }
24838
- if (!Number.isFinite(contextLimit) || contextLimit <= 0) {
24839
- return;
24840
- }
24841
- return Math.floor(contextLimit * (resolveExecuteThreshold(executeThresholdPercentage ?? 65, modelKey, 65, {
24842
- tokensConfig: executeThresholdTokens,
24843
- contextLimit
24844
- }) / 100) * historyBudgetPercentage);
24845
- }
24846
25049
 
24847
25050
  // src/hooks/magic-context/module-client.ts
24848
25051
  function createSubcModuleClient(options) {
@@ -25022,9 +25225,6 @@ function createRustRefusalRecovery(options) {
25022
25225
  };
25023
25226
  }
25024
25227
 
25025
- // src/hooks/magic-context/system-prompt-hash.ts
25026
- import { createHash as createHash13 } from "node:crypto";
25027
-
25028
25228
  // src/hooks/magic-context/system-prompt-dates.ts
25029
25229
  function replaceHostDates(prompt, replace) {
25030
25230
  const fields = /<(plugin-env|environment|env)>[\s\S]*?<\/\1>|Today's date: [^\r\n<]+/g;
@@ -25136,7 +25336,7 @@ function createSystemPromptHashHandler(deps) {
25136
25336
  const dates = systemPromptDates(liveSystemContent, stickyDate);
25137
25337
  const currentDate = dates.live;
25138
25338
  const stableCandidate = dates.stable;
25139
- const stableCandidateHash = createHash13("md5").update(promptSurfaceHashMaterial(stableCandidate, promptSurface.preset)).digest("hex");
25339
+ const stableCandidateHash = systemPromptFingerprint(stableCandidate, promptSurface.preset);
25140
25340
  const contentOrPresetChanged = hasPersistedHash && stableCandidateHash !== previousHash;
25141
25341
  const rewritePermission = systemDateRefreshPermission(deps.historyRefreshSessions, dateRequest);
25142
25342
  let deferredDateRefresh = false;
@@ -25150,7 +25350,7 @@ function createSystemPromptHashHandler(deps) {
25150
25350
  try {
25151
25351
  const content = liveElements.join(`
25152
25352
  `);
25153
- const hash = createHash13("md5").update(promptSurfaceHashMaterial(content, promptSurface.preset)).digest("hex");
25353
+ const hash = systemPromptFingerprint(content, promptSurface.preset);
25154
25354
  updateSessionMeta(deps.db, sessionId, {
25155
25355
  systemPromptHash: hash,
25156
25356
  cachedM0SystemHash: hash,
@@ -25190,7 +25390,7 @@ function createSystemPromptHashHandler(deps) {
25190
25390
  `);
25191
25391
  if (!availability.frozen || !modelKey)
25192
25392
  return;
25193
- const currentHash = createHash13("md5").update(promptSurfaceHashMaterial(systemContent, promptSurface.preset)).digest("hex");
25393
+ const currentHash = systemPromptFingerprint(systemContent, promptSurface.preset);
25194
25394
  recordSystemPromptForRequest(sessionId, currentLkgRequestIdentity(sessionId), currentHash, deps.db, previousHash !== currentHash ? !deps.historyRefreshSessions.has(sessionId) : undefined, deps.historyRefreshSessions, deps.pendingMaterializationSessions);
25195
25395
  if (!sessionMetaEarly) {
25196
25396
  return;
@@ -25198,6 +25398,7 @@ function createSystemPromptHashHandler(deps) {
25198
25398
  const sessionMeta = sessionMetaEarly;
25199
25399
  if (previousHash !== "" && previousHash !== "0" && previousHash !== currentHash) {
25200
25400
  sessionLog2(sessionId, `system prompt hash changed: ${previousHash} → ${currentHash} (len=${systemContent.length}), ${idleCacheExpired ? "adopting on idle-expired request" : requestMessagesFinal ? "adopting on the request whose messages are already final" : "triggering flush"}`);
25401
+ noteSystemPromptHashChange(sessionId);
25201
25402
  if (!adoptSystemChange) {
25202
25403
  deps.historyRefreshSessions.add(sessionId);
25203
25404
  deps.systemPromptRefreshSessions.add(sessionId);
@@ -25968,7 +26169,7 @@ function resolveCtxExpandMode(args, domain) {
25968
26169
  }
25969
26170
 
25970
26171
  // src/tools/ctx-expand/render.ts
25971
- import { createHash as createHash14 } from "node:crypto";
26172
+ import { createHash as createHash13 } from "node:crypto";
25972
26173
  function isRecord4(value) {
25973
26174
  return value !== null && typeof value === "object" && !Array.isArray(value);
25974
26175
  }
@@ -26192,7 +26393,7 @@ function renderItemByTag(db, sessionId, number, textIndexDomain = "part") {
26192
26393
  const index = scoped ? Number(scoped[2]) : 0;
26193
26394
  const piText = message.parts.filter((part) => isRecord4(part) && part.type === "text");
26194
26395
  const part = message.parts[index];
26195
- const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" && createHash14("sha256").update(part.text).digest("hex") === derived[3]) : [];
26396
+ const matching = derived ? piText.filter((part) => isRecord4(part) && typeof part.text === "string" && createHash13("sha256").update(part.text).digest("hex") === derived[3]) : [];
26196
26397
  const selected = derived ? matching[Number(derived[4])] : textIndexDomain === "text" ? piText[index] : part;
26197
26398
  return selected ? renderPartFull(selected) ?? "" : `Tag ${number}'s original text part is no longer in stored history.`;
26198
26399
  }
@@ -27612,12 +27813,13 @@ function parseNoteIds(action, value) {
27612
27813
  }
27613
27814
  function createCtxNoteTool(deps) {
27614
27815
  const { surface_condition: _condition, ...plainArgs } = ctxNoteArgsShape;
27816
+ const smartNoteSurface = deps.smartNotesEnabled !== false && deps.dreamerEnabled !== false;
27615
27817
  return tool3({
27616
- description: deps.smartNotesEnabled === false ? withoutSmartNoteText(CTX_NOTE_DESCRIPTION) : CTX_NOTE_DESCRIPTION,
27617
- args: deps.smartNotesEnabled === false ? {
27818
+ description: smartNoteSurface ? CTX_NOTE_DESCRIPTION : withoutSmartNoteText(CTX_NOTE_DESCRIPTION),
27819
+ args: smartNoteSurface ? ctxNoteArgsShape : {
27618
27820
  ...plainArgs,
27619
27821
  filter: ctxNoteArgsShape.filter.describe(NOTES_FILTER_DESCRIPTION)
27620
- } : ctxNoteArgsShape,
27822
+ },
27621
27823
  async execute(rawArgs, toolContext) {
27622
27824
  const parsedArgs = ctxNoteArgsSchema.safeParse(rawArgs);
27623
27825
  let args = parsedArgs.success ? parsedArgs.data : rawArgs;
@@ -27797,7 +27999,7 @@ function formatCtxReduceReply(stampedCount, selfStampCount = 0) {
27797
27999
  return parts.join(" ");
27798
28000
  }
27799
28001
  // src/tools/ctx-reduce/tools.ts
27800
- import { createHash as createHash15 } from "node:crypto";
28002
+ import { createHash as createHash14 } from "node:crypto";
27801
28003
  import { tool as tool4 } from "@opencode-ai/plugin";
27802
28004
 
27803
28005
  // src/features/magic-context/range-parser.ts
@@ -27861,11 +28063,11 @@ function createCtxReduceTool(deps) {
27861
28063
  const stableId = `oc-${sessionId}-${callId}`;
27862
28064
  if (Buffer.byteLength(stableId) <= 128)
27863
28065
  return stableId;
27864
- return `oc-${createHash15("sha256").update(stableId).digest("hex")}`;
28066
+ return `oc-${createHash14("sha256").update(stableId).digest("hex")}`;
27865
28067
  }
27866
28068
  fallbackCommandSequence += 1;
27867
28069
  const monotonicId = `oc-${sessionId}-${fallbackCommandSequence}`;
27868
- return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${createHash15("sha256").update(monotonicId).digest("hex")}`;
28070
+ return Buffer.byteLength(monotonicId) <= 128 ? monotonicId : `oc-${createHash14("sha256").update(monotonicId).digest("hex")}`;
27869
28071
  };
27870
28072
  return tool4({
27871
28073
  description: CTX_REDUCE_DESCRIPTION,
@@ -28643,4 +28845,4 @@ function applyHiddenSubagentTemperature(input, output, log) {
28643
28845
  output.temperature = temperature;
28644
28846
  }
28645
28847
 
28646
- export { openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, scheduleClearAndReindex, startDreamScheduleTimer, ensureProjectRegisteredFromOpenCodeDirectory, recordOpenCodeProvenInputFloor, resolveOpenCodeProvenInputFloor, resolveContextWindowGeometry, resolveContextLimit, resolveExecuteThresholdDetail, resolveModelKey, resolveSessionId, createScheduler, describeStorageUnavailability, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, maybeDeliverChannel2, armLatestThinkingRecovery, armBindingRecoverySafely, armLatestThinkingRecoveryFromError, lkgReplayLimit, measureLkgReplay, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, bindSystemDateRequestIdentity, bindSystemDateOutput, registerSystemDateRefresh, rustWrapupHistorianFields, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, createCtxExpandTools, CTX_MEMORY_LIST_TOOL_NAME, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createCtxMemoryListTools, CTX_NOTE_DESCRIPTION, withoutSmartNoteText, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer, subagentTemperature, applyHiddenSubagentTemperature };
28848
+ export { logConfigDependencyNotesOnce, openOpenCodeDb, DREAMER_SYSTEM_PROMPT, runSessionProjectBackfill, SMART_NOTE_COMPILER_SYSTEM_PROMPT, createLiveSessionState, RETROSPECTIVE_MAX_USER_MESSAGE_CHARS, RETROSPECTIVE_MESSAGE_TRUNCATION_MARKER, OpenCodeRetrospectiveRawProvider, createDreamTaskExecutor, runManualDream, runDueTasksForProject, scheduleClearAndReindex, startDreamScheduleTimer, createDreamTimerModuleClient, ensureProjectRegisteredFromOpenCodeDirectory, recordOpenCodeProvenInputFloor, resolveOpenCodeProvenInputFloor, resolveContextWindowGeometry, resolveContextLimit, resolveExecuteThresholdDetail, resolveModelKey, resolveSessionId, createScheduler, describeStorageUnavailability, resolveSessionCacheTtl, runEmbedHistoryDrain, pauseEmbedHistoryDrain, formatEmbedStatusText, getSessionProperties, getSessionCreatedInfo, getMessageUpdatedAssistantInfo, getMessageUpdatedInfo, getSessionErrorInfo, getMessageRemovedInfo, summarizeManualDream, createMagicContextCommandHandler, getLiveNotificationParams, createChatMessageHook, createEventHook, createCommandExecuteBeforeHook, createToolExecuteAfterHook, recordHiddenVariantWarning, buildStatusDetail, isDebugRpcEnabled, registerRpcHandlers, clearTransformDecisionSession, scheduleOpenCodeTransformDecisionWrite, stageOpenCodeV2TransformDecision, bindOpenCodeV2TransformDecision, maybeDeliverChannel2, armLatestThinkingRecovery, armBindingRecoverySafely, armLatestThinkingRecoveryFromError, createM0RenderOptions, lkgReplayLimit, measureLkgReplay, STORAGE_BUSY_MESSAGE, StorageBusyRefusalError, bindSystemDateRequestIdentity, bindSystemDateOutput, registerSystemDateRefresh, rustWrapupHistorianFields, UnmanagedOverWindowError, UnresolvedHistoryBoundaryError, clearMessageTokensCache, createTransform, createSubcModuleClient, createModuleToolBackends, createRustRefusalRecovery, createSystemPromptHashHandler, tryMessagesTransformLkgReplay, createMessagesTransformHandler, primaryOnlyToolIds, subagentToolRefusal, guardSubagentTools, hideSubagentTools, createCtxExpandTools, CTX_MEMORY_LIST_TOOL_NAME, CTX_MEMORY_ACTIONS, createCtxMemoryTools, createCtxMemoryListTools, CTX_NOTE_DESCRIPTION, withoutSmartNoteText, createCtxNoteTools, createCtxReduceTools, createCtxSearchTools, parameterDescriptionsFor, applyJsonSchemaParameterDescriptions, MagicContextRpcServer, subagentTemperature, applyHiddenSubagentTemperature };