@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,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./server-9e5r8y60.js";
3
+ } from "./server-f2xf5gcb.js";
4
4
 
5
5
  // src/shared/write-transaction-timing.ts
6
6
  var SLOW_WRITE_TRANSACTION_THRESHOLD_MS = 1000;
@@ -4,13 +4,13 @@ import {
4
4
  import {
5
5
  importPluginModule,
6
6
  sessionLog2
7
- } from "./server-9e5r8y60.js";
7
+ } from "./server-f2xf5gcb.js";
8
8
  import {
9
9
  isDefaultSessionTitle2
10
- } from "./server-ckrb5rm8.js";
10
+ } from "./server-h0410h0v.js";
11
11
  import {
12
12
  shouldHoldIgnoredNotification
13
- } from "./server-zrwaj29a.js";
13
+ } from "./server-d8tj10db.js";
14
14
  import {
15
15
  getErrorMessage
16
16
  } from "./server-y8v6yerm.js";
@@ -142,7 +142,7 @@ async function sendIgnoredMessageNow(client, sessionId, text, params, forcePersi
142
142
  holdIgnoredNotification({ client, sessionId, text, params, forcePersist }, "during target checks");
143
143
  return "queued";
144
144
  }
145
- const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-936374xx.js"));
145
+ const { waitForSafeNotificationTarget } = await importPluginModule(() => import("./safe-notification-target-qg7n2s77.js"));
146
146
  if (await waitForSafeNotificationTarget(client, sessionId) === "skip") {
147
147
  sessionLog2(sessionId, "notification skipped (session not titled yet)");
148
148
  return "skipped";
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./server-7e087rvk.js";
3
+ } from "./server-th4y11y7.js";
4
4
  import {
5
5
  log2
6
- } from "./server-9e5r8y60.js";
6
+ } from "./server-f2xf5gcb.js";
7
7
  import {
8
8
  isSynapseEmbeddingTruncated,
9
9
  SynapseEmbeddingProvider
10
- } from "./server-988cqjme.js";
10
+ } from "./server-rrqpvwqd.js";
11
11
  import {
12
12
  LocalEmbeddingProvider
13
- } from "./server-44ryn9rb.js";
13
+ } from "./server-2x42esxd.js";
14
14
  import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./server-4easnf78.js";
18
+ } from "./server-sz8jj92q.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./server-qt1qqasc.js";
@@ -4,13 +4,13 @@ import {
4
4
  } from "./server-1zx87sdm.js";
5
5
  import {
6
6
  estimateTokens
7
- } from "./server-s6jqh8bj.js";
7
+ } from "./server-0ppsweh6.js";
8
8
  import {
9
9
  getHarness2
10
10
  } from "./server-pavzsdc6.js";
11
11
  import {
12
12
  sessionLog2
13
- } from "./server-9e5r8y60.js";
13
+ } from "./server-f2xf5gcb.js";
14
14
  import {
15
15
  getTagIdentityWriteGeneration2,
16
16
  getSqliteDatabasePath2
@@ -20,7 +20,7 @@ import {
20
20
  stableStringifyHash,
21
21
  tagOrderConstraintIndex,
22
22
  tagIdentityRevisionKey
23
- } from "./server-89fcbe37.js";
23
+ } from "./server-pwv4ezb0.js";
24
24
  import {
25
25
  DEFAULT_PROTECTED_TOOLS,
26
26
  normalizeProtectedToolName,
@@ -2938,6 +2938,19 @@ function insertTag2(db, sessionId, messageId, type, byteSize, tagNumber, reasoni
2938
2938
  function updateTagStatus2(db, sessionId, tagId, status) {
2939
2939
  getUpdateTagStatusStatement(db).run(status, sessionId, tagId);
2940
2940
  }
2941
+ var droppedTagStatements = new WeakMap;
2942
+ function markTagDropped2(db, sessionId, tagId, mode) {
2943
+ if (!mode) {
2944
+ updateTagStatus2(db, sessionId, tagId, "dropped");
2945
+ return;
2946
+ }
2947
+ let statement = droppedTagStatements.get(db);
2948
+ if (!statement) {
2949
+ statement = db.prepare("UPDATE tags SET status = ?, drop_mode = ? WHERE session_id = ? AND tag_number = ?");
2950
+ droppedTagStatements.set(db, statement);
2951
+ }
2952
+ statement.run("dropped", mode, sessionId, tagId);
2953
+ }
2941
2954
  function markWhitespaceAssistantTagInert2(db, sessionId, tagNumber, contentId) {
2942
2955
  db.prepare(`UPDATE tags
2943
2956
  SET status = 'compacted',
@@ -3663,7 +3676,7 @@ function getNewestToolTagNumbers2(db, sessionId, limit) {
3663
3676
  let statement = newestToolTagNumberStatements.get(db);
3664
3677
  if (!statement) {
3665
3678
  statement = db.prepare(`SELECT tag_number FROM tags
3666
- WHERE session_id = ? AND type = 'tool'
3679
+ WHERE session_id = ? AND +type = 'tool'
3667
3680
  AND typeof(message_id) = 'text'
3668
3681
  AND typeof(status) = 'text'
3669
3682
  AND typeof(byte_size) IN ('integer', 'real')
@@ -3833,4 +3846,4 @@ function deleteToolTagsByOwner(db, sessionId, ownerMsgId) {
3833
3846
  return getDeleteToolTagsByOwnerStatement(db).all(sessionId, ownerMsgId).length;
3834
3847
  }
3835
3848
 
3836
- export { protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, currentReclaimableToolOutputCount, isRecord, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, hasPendingDropOps, getPendingOpsCount, clearPendingOps, removePendingOp, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, cachedTagOwnerRatios2, tagOwnerWarmupState2, scanTagOwnerDelta2, installTagOwnerDelta2, installTagOwnerSummary2, isTagOwnerSummaryReady2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markWhitespaceAssistantTagInert2, getInertWhitespaceAssistantTags2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTailHygieneTags2, getDroppedTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
3849
+ export { protectedToolTagNumbers, protectedToolTokenCount, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isThinkingPart, currentReclaimableToolOutputCount, isRecord, contentTagOwnerMessageId, estimateImageTokensFromDataUrl, estimateToolAttachmentImageTokens, providerVisiblePart, providerVisibleMessage, normalizeTodoStateJson, buildSyntheticTodoPart, computeSyntheticCallId, isSyntheticTodoPart, countRealUserMessages, tailHygieneStructuralSignature, sameTailHygieneStructuralSignature, formatTailHygienePrefixMismatch, refreshTailHygieneBaseline, effectiveTailHygiene, assertTailHygieneContentUnchangedIfEnabled, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, isDroppedToolOutput, toolOutputTokens, decideChannel1, evaluateChannel2, formatChannel1Evaluation, formatChannel2Evaluation, buildChannel2Reminder, buildChannel1Reminder, estimateEmergencyDropReclaimTokens, planEmergencyDrop, measureEmergencyTag, queuePendingOp, queuePendingDropForUnchangedTag, getPendingOps, hasPendingDropOps, getPendingOpsCount, clearPendingOps, removePendingOp, getRecentTagOwnerMessageIds2, getActiveTagTokenAggregate2, AGE_RECLAIM_MIN_TOKENS2, getOldestActiveUnprotectedToolTags2, getActiveToolTagsForAgeReclaim2, getTriggerTagTokenUpperBound2, getActiveTagTokenTotalsByMessage2, getPersistedToolTagAccounting2, getAllStatusTagTokenTotalsFlat2, getReasoningTokenEstimatesByMessage2, tryGetReasoningTokenEstimatesByMessage2, getMaxTagNumberByOwnerMessage2, scanTagOwnerSummary2, cachedTagOwnerRatios2, tagOwnerWarmupState2, scanTagOwnerDelta2, installTagOwnerDelta2, installTagOwnerSummary2, isTagOwnerSummaryReady2, tagTokenCountIsNull2, backfillTagTokenCounts2, insertTag2, updateTagStatus2, markTagDropped2, markWhitespaceAssistantTagInert2, getInertWhitespaceAssistantTags2, getInertWhitespaceAssistantTagsByNumbers2, updateTagDropMode2, updateCavemanDepth2, updateTagMessageId2, hasPiFallbackMessageTags2, findAdoptableFallbackTags2, adoptFallbackTagMessageId2, foldShrunkPartTags2, hasPiFallbackToolOwnerTags2, findPiFallbackToolOwnerTags2, adoptPiFallbackToolOwnerTag2, adoptPiFallbackMessageTag2, markTagsCompactedByMessageIds2, deleteTagsByMessageId2, getMaxTagNumberBySession2, getTagNumberByMessageId2, getAssignableTagNumberByMessageId2, getMinMessageTagNumberForRawId2, deriveTagLoadFloor2, TAG_SELECT_COLUMNS2, getTagsBySession2, getActiveTagsBySession2, getTailHygieneTags2, getDroppedTagsBySession2, getTagsForPendingOperations2, getTagsByNumbers2, getNewestToolTagNumbers2, getDroppedTagsByNumbers2, getMaxDroppedTagNumber2, getTagById2, getTopNBySize2, getToolTagNumberByOwner2, getNullOwnerToolTag2, adoptNullOwnerToolTag2, getCandidateToolOwners2, pickNearestPriorOwner2 };
@@ -1,9 +1,10 @@
1
1
  import {
2
+ getHarness2,
2
3
  harnessOwnsOpenCodeStore2
3
4
  } from "./server-pavzsdc6.js";
4
5
  import {
5
6
  log2
6
- } from "./server-9e5r8y60.js";
7
+ } from "./server-f2xf5gcb.js";
7
8
  import {
8
9
  resolveOpenCodeDbPath,
9
10
  assertOpenCodeStoreGeneration,
@@ -23,20 +24,24 @@ import {
23
24
  function openCodeDbExists() {
24
25
  return harnessOwnsOpenCodeStore2() && openCodeDbPathExists(resolveOpenCodeDbPath());
25
26
  }
26
- var cachedReadOnlyDb = null;
27
- function closeCachedReadOnlyDb() {
28
- if (!cachedReadOnlyDb) {
27
+ var cachedReadOnlyDbs = {
28
+ v1: null,
29
+ v2: null
30
+ };
31
+ function closeCachedReadOnlyDb(generation) {
32
+ const cached = cachedReadOnlyDbs[generation];
33
+ if (!cached) {
29
34
  return;
30
35
  }
31
36
  try {
32
- closeQuietly(cachedReadOnlyDb.db);
37
+ closeQuietly(cached.db);
33
38
  } catch (error) {
34
39
  log2("[magic-context] failed to close cached OpenCode read-only DB:", error);
35
40
  } finally {
36
- cachedReadOnlyDb = null;
41
+ cachedReadOnlyDbs[generation] = null;
37
42
  }
38
43
  }
39
- function getReadOnlySessionDb() {
44
+ function getReadOnlySessionDb(generation = "v1") {
40
45
  if (!harnessOwnsOpenCodeStore2()) {
41
46
  throw new Error("OpenCode session database is not readable from a Pi-compatible process; its history lives in Pi sessions");
42
47
  }
@@ -45,18 +50,19 @@ function getReadOnlySessionDb() {
45
50
  if (!openCodeDbPathExists(resolution)) {
46
51
  throw new Error(`OpenCode session database is unavailable at ${dbPath} (source=${resolution.source})`);
47
52
  }
48
- if (cachedReadOnlyDb?.path === dbPath) {
49
- return cachedReadOnlyDb.db;
53
+ const cached = cachedReadOnlyDbs[generation];
54
+ if (cached?.path === dbPath) {
55
+ return cached.db;
50
56
  }
51
- closeCachedReadOnlyDb();
57
+ closeCachedReadOnlyDb(generation);
52
58
  const db = new Database2(dbPath, { readonly: true });
53
59
  try {
54
- assertOpenCodeStoreGeneration(db, "v1", dbPath);
60
+ assertOpenCodeStoreGeneration(db, generation, dbPath);
55
61
  } catch (error) {
56
62
  closeQuietly(db);
57
63
  throw error;
58
64
  }
59
- cachedReadOnlyDb = { path: dbPath, db };
65
+ cachedReadOnlyDbs[generation] = { path: dbPath, db };
60
66
  clearOpenCodeDbReadFailure();
61
67
  return db;
62
68
  }
@@ -317,15 +323,14 @@ function getMessageTimesFromOpenCodeDb(sessionId, messageIds) {
317
323
  if (messageIds.length === 0 || !harnessOwnsOpenCodeStore2())
318
324
  return result;
319
325
  try {
320
- withReadOnlySessionDb((db) => {
321
- const placeholders = messageIds.map(() => "?").join(",");
322
- const rows = db.prepare(`SELECT id, time_created FROM message WHERE +session_id = ? AND id IN (${placeholders})`).all(sessionId, ...messageIds);
323
- for (const row of rows) {
324
- if (typeof row.id === "string" && typeof row.time_created === "number") {
325
- result.set(row.id, row.time_created);
326
- }
326
+ const placeholders = messageIds.map(() => "?").join(",");
327
+ const rows = getHarness2() === "opencode2" ? getReadOnlySessionDb("v2").prepare(`SELECT id, COALESCE(time_created, json_extract(data, '$.time.created')) AS time_created
328
+ FROM session_message WHERE +session_id = ? AND id IN (${placeholders})`).all(sessionId, ...messageIds) : withReadOnlySessionDb((db) => db.prepare(`SELECT id, time_created FROM message WHERE +session_id = ? AND id IN (${placeholders})`).all(sessionId, ...messageIds));
329
+ for (const row of rows) {
330
+ if (typeof row.id === "string" && typeof row.time_created === "number") {
331
+ result.set(row.id, row.time_created);
327
332
  }
328
- });
333
+ }
329
334
  } catch (error) {
330
335
  logProbeFailureOnce(resolveOpenCodeDbPath(), error);
331
336
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./server-9e5r8y60.js";
3
+ } from "./server-f2xf5gcb.js";
4
4
  import {
5
5
  canonicalProjectDirectory
6
6
  } from "./server-knvkbfvh.js";
@@ -7,7 +7,15 @@ import * as fs from "node:fs";
7
7
  import * as path2 from "node:path";
8
8
 
9
9
  // src/shared/data-path.ts
10
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
10
+ import {
11
+ existsSync,
12
+ lstatSync,
13
+ mkdirSync,
14
+ readFileSync,
15
+ readlinkSync,
16
+ realpathSync,
17
+ writeFileSync
18
+ } from "node:fs";
11
19
  import * as os from "node:os";
12
20
  import * as path from "node:path";
13
21
 
@@ -99,6 +107,42 @@ function getMagicContextStorageResolution() {
99
107
  function getMagicContextStorageDir() {
100
108
  return getMagicContextStorageResolution().path;
101
109
  }
110
+ function canonicalizeStoragePath(value, seen = new Set) {
111
+ const absolute = path.resolve(value);
112
+ if (seen.has(absolute))
113
+ return absolute;
114
+ seen.add(absolute);
115
+ try {
116
+ return realpathSync.native(absolute);
117
+ } catch {
118
+ try {
119
+ if (lstatSync(absolute).isSymbolicLink()) {
120
+ const target = readlinkSync(absolute);
121
+ const resolvedTarget = path.isAbsolute(target) ? target : path.resolve(path.dirname(absolute), target);
122
+ return canonicalizeStoragePath(resolvedTarget, seen);
123
+ }
124
+ } catch {}
125
+ const parent = path.dirname(absolute);
126
+ if (parent === absolute)
127
+ return absolute;
128
+ const resolvedParent = canonicalizeStoragePath(parent, seen);
129
+ return path.resolve(resolvedParent, path.basename(absolute));
130
+ }
131
+ }
132
+ function isMagicContextStorageOutsideEngram(storageDir = getMagicContextStorageDir(), backupDir = path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context")) {
133
+ const resolvedStorageDir = canonicalizeStoragePath(storageDir);
134
+ const resolvedBackupDir = canonicalizeStoragePath(backupDir);
135
+ const relative2 = path.relative(resolvedBackupDir, resolvedStorageDir);
136
+ return path.isAbsolute(relative2) || relative2 === ".." || relative2.startsWith(`..${path.sep}`);
137
+ }
138
+ var STORAGE_BACKUP_WARNING_CHECKED = Symbol.for("magic-context.storage-backup-warning-checked");
139
+ function claimStorageBackupWarningCheck() {
140
+ const processState = globalThis;
141
+ if (processState[STORAGE_BACKUP_WARNING_CHECKED])
142
+ return false;
143
+ processState[STORAGE_BACKUP_WARNING_CHECKED] = true;
144
+ return true;
145
+ }
102
146
  function getLegacyOpenCodeMagicContextStorageDir() {
103
147
  return path.join(getOpenCodeStorageDir(), "plugin", "magic-context");
104
148
  }
@@ -655,4 +699,4 @@ if (!isTestEnv) {
655
699
  process.on("exit", flush);
656
700
  }
657
701
 
658
- export { getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, getLegacyOpenCodeMagicContextStorageDir, sanitizeDiagnosticText, hasShareabilitySensitiveText, registerStalePluginBuildHost, classifyStalePluginBuild, importPluginModule, setLogLineForwarder2, writeForwardedLogLine2, log2, sessionLog2, getLoggerDiagnostics2, flushLogger2, getLogFilePath2 };
702
+ export { getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageDir, isMagicContextStorageOutsideEngram, claimStorageBackupWarningCheck, getLegacyOpenCodeMagicContextStorageDir, sanitizeDiagnosticText, hasShareabilitySensitiveText, registerStalePluginBuildHost, classifyStalePluginBuild, importPluginModule, setLogLineForwarder2, writeForwardedLogLine2, log2, sessionLog2, getLoggerDiagnostics2, flushLogger2, getLogFilePath2 };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  log2
3
- } from "./server-9e5r8y60.js";
3
+ } from "./server-f2xf5gcb.js";
4
4
  import {
5
5
  getSdkWindowGeometry,
6
6
  getSdkContextLimit,
7
7
  getSdkInputLimit
8
- } from "./server-nveratm5.js";
8
+ } from "./server-kn9n2qgd.js";
9
9
  import {
10
10
  localBudget,
11
11
  calibrationForModelKey
@@ -3,12 +3,12 @@ import {
3
3
  } from "./server-fr0wbhdn.js";
4
4
  import {
5
5
  log2
6
- } from "./server-9e5r8y60.js";
6
+ } from "./server-f2xf5gcb.js";
7
7
  import {
8
8
  ensureColumn,
9
9
  healAllNullColumns,
10
10
  installV95PerfSchema
11
- } from "./server-89fcbe37.js";
11
+ } from "./server-pwv4ezb0.js";
12
12
  import {
13
13
  resolveOpenCodeDbPath,
14
14
  openCodeDbPathExists,
@@ -20,10 +20,10 @@ import {
20
20
  import {
21
21
  normalizeStoredProjectPath,
22
22
  storedPathBelongsToIdentity
23
- } from "./server-njnx39q2.js";
23
+ } from "./server-gvkm8xaj.js";
24
24
  import {
25
25
  logSlowWriteTransaction
26
- } from "./server-7dv9wt9r.js";
26
+ } from "./server-6pmqg9m4.js";
27
27
 
28
28
  // src/features/magic-context/migrations.ts
29
29
  import { isMainThread } from "node:worker_threads";