@cortexkit/opencode-magic-context 0.49.11 → 0.49.13

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 (253) 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/chunk-embedding-write-worker.js +89 -0
  7. package/dist/{compaction-marker-candidates-xxz35vwp.js → compaction-marker-candidates-v5c6997n.js} +3 -3
  8. package/dist/compaction-marker-candidates-worker.js +1 -1
  9. package/dist/config/agent-disable.d.ts +14 -0
  10. package/dist/config/agent-disable.d.ts.map +1 -1
  11. package/dist/config/dependency-notes.d.ts +34 -0
  12. package/dist/config/dependency-notes.d.ts.map +1 -0
  13. package/dist/config/schema/agent-overrides.d.ts +12 -12
  14. package/dist/config/schema/magic-context.d.ts +88 -88
  15. package/dist/config/schema/magic-context.d.ts.map +1 -1
  16. package/dist/{conflict-warning-hook-xwkfncav.js → conflict-warning-hook-mgq17yr3.js} +8 -8
  17. package/dist/{context-twz3s0cg.js → context-azqk0vfd.js} +121 -145
  18. package/dist/{derive-budgets-3nbxsyss.js → derive-budgets-zn7yzd2d.js} +3 -3
  19. package/dist/embedding-backfill-5e1t5wha.js +22 -0
  20. package/dist/embedding-worker-process.js +2 -2
  21. package/dist/embedding-worker.js +6 -6
  22. package/dist/features/magic-context/chunk-embedding-write-worker.d.ts +2 -0
  23. package/dist/features/magic-context/chunk-embedding-write-worker.d.ts.map +1 -0
  24. package/dist/features/magic-context/chunk-embedding-writer.d.ts +48 -0
  25. package/dist/features/magic-context/chunk-embedding-writer.d.ts.map +1 -0
  26. package/dist/features/magic-context/compartment-chunk-embedding.d.ts +1 -1
  27. package/dist/features/magic-context/compartment-chunk-embedding.d.ts.map +1 -1
  28. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts +3 -2
  29. package/dist/features/magic-context/dreamer/hidden-single-shot.d.ts.map +1 -1
  30. package/dist/features/magic-context/dreamer/map-memories.d.ts +8 -1
  31. package/dist/features/magic-context/dreamer/map-memories.d.ts.map +1 -1
  32. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts +2 -0
  33. package/dist/features/magic-context/dreamer/retrospective-raw-provider.d.ts.map +1 -1
  34. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts +5 -0
  35. package/dist/features/magic-context/dreamer/storage-dream-runs.d.ts.map +1 -1
  36. package/dist/features/magic-context/dreamer/task-config.d.ts +22 -4
  37. package/dist/features/magic-context/dreamer/task-config.d.ts.map +1 -1
  38. package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
  39. package/dist/features/magic-context/dreamer/task-registry.d.ts +22 -0
  40. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  41. package/dist/features/magic-context/dreamer/task-scheduler.d.ts +4 -1
  42. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  43. package/dist/features/magic-context/dreamer/verify-prompt.d.ts +6 -1
  44. package/dist/features/magic-context/dreamer/verify-prompt.d.ts.map +1 -1
  45. package/dist/features/magic-context/dreamer/verify.d.ts +25 -11
  46. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  47. package/dist/features/magic-context/memory/embedding-openai.d.ts +32 -0
  48. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  49. package/dist/features/magic-context/memory/project-identity.d.ts +1 -0
  50. package/dist/features/magic-context/memory/project-identity.d.ts.map +1 -1
  51. package/dist/features/magic-context/memory/unborn-head.d.ts +34 -0
  52. package/dist/features/magic-context/memory/unborn-head.d.ts.map +1 -0
  53. package/dist/features/magic-context/mural/compress-cues.d.ts +3 -0
  54. package/dist/features/magic-context/mural/compress-cues.d.ts.map +1 -1
  55. package/dist/features/magic-context/project-embedding-registry.d.ts +5 -0
  56. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  57. package/dist/features/magic-context/storage-tags.d.ts +2 -0
  58. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  59. package/dist/{history-owner-ty29fz0f.js → history-owner-xp3pngv7.js} +3 -3
  60. package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/auto-embed-session.d.ts +10 -0
  62. package/dist/hooks/magic-context/auto-embed-session.d.ts.map +1 -0
  63. package/dist/hooks/magic-context/compartment-prompt.d.ts +6 -0
  64. package/dist/hooks/magic-context/compartment-prompt.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -0
  67. package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/compartment-trigger-error.d.ts +12 -0
  69. package/dist/hooks/magic-context/compartment-trigger-error.d.ts.map +1 -0
  70. package/dist/hooks/magic-context/embed-session-state.d.ts +8 -1
  71. package/dist/hooks/magic-context/embed-session-state.d.ts.map +1 -1
  72. package/dist/hooks/magic-context/historian-prompt-fit.d.ts +2 -0
  73. package/dist/hooks/magic-context/historian-prompt-fit.d.ts.map +1 -1
  74. package/dist/hooks/magic-context/hook.d.ts +3 -1
  75. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  76. package/dist/hooks/magic-context/pending-materialization.d.ts +2 -0
  77. package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +12 -0
  79. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts +58 -0
  81. package/dist/hooks/magic-context/raw-exact-ordinal-read.d.ts.map +1 -0
  82. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts +7 -0
  83. package/dist/hooks/magic-context/raw-ordinal-warmup.d.ts.map +1 -1
  84. package/dist/hooks/magic-context/read-session-raw.d.ts +19 -0
  85. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  86. package/dist/hooks/magic-context/recomp-orchestrator.d.ts +2 -0
  87. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  88. package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
  89. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  90. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/transform.d.ts +4 -0
  92. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  93. package/dist/hooks/magic-context/wrapup-orchestrator.d.ts.map +1 -1
  94. package/dist/{index-bzp9s8z2.js → index-1d289pq2.js} +2 -2
  95. package/dist/{index-w28y7d0z.js → index-1sarmj9z.js} +15 -15
  96. package/dist/{index-z7avx6rw.js → index-2jr1smmh.js} +280 -160
  97. package/dist/{index-4ccdr7yw.js → index-3kdm78zp.js} +5 -5
  98. package/dist/{index-9159kk15.js → index-3kx0kg0f.js} +64 -7
  99. package/dist/{index-0jz47061.js → index-a8bvhwqs.js} +190 -30
  100. package/dist/{index-84j7jq8a.js → index-aw1bh90w.js} +10 -10
  101. package/dist/{index-qr1mkc2y.js → index-b16gpywn.js} +9 -9
  102. package/dist/{index-g7jkrz0x.js → index-bp5083x2.js} +1 -1
  103. package/dist/{index-yhrrx7qa.js → index-bxdg2nbt.js} +3 -3
  104. package/dist/{index-0abg88h2.js → index-dgs16axy.js} +4 -4
  105. package/dist/{index-mp2kghkv.js → index-dyvbsvga.js} +1 -1
  106. package/dist/{index-bmwfzz28.js → index-e20m7284.js} +4 -4
  107. package/dist/{index-4jkhhpn1.js → index-e4dsjj1p.js} +3 -3
  108. package/dist/{index-s178h9z8.js → index-f71thw8j.js} +1 -1
  109. package/dist/{index-kvw6xew3.js → index-fkx2qnvw.js} +2 -2
  110. package/dist/{index-f8cn4xqa.js → index-fwefky9w.js} +18 -5
  111. package/dist/{index-0sahzkwr.js → index-g2q4htwp.js} +46 -2
  112. package/dist/{index-mw7c950g.js → index-gp3kcpc4.js} +1 -1
  113. package/dist/{index-g40wgxxt.js → index-hnm8raee.js} +4 -4
  114. package/dist/{index-gjvjh960.js → index-hqkczed7.js} +1 -1
  115. package/dist/{index-mvvephtj.js → index-j75v2476.js} +1 -1
  116. package/dist/{index-150zz6fh.js → index-k29z4aqh.js} +1 -1
  117. package/dist/{index-b64n4d0h.js → index-kee4kn5j.js} +1 -1
  118. package/dist/index-ksdyrrav.js +52 -0
  119. package/dist/{index-angx1s0k.js → index-mmfa86mt.js} +16 -6
  120. package/dist/{index-9jvab89d.js → index-n6m03s3n.js} +2 -2
  121. package/dist/{index-q28hsbpg.js → index-nj7yykkx.js} +1 -1
  122. package/dist/{index-ghc9f0n7.js → index-p5y3k4g7.js} +29 -1
  123. package/dist/{index-xztdf9t7.js → index-qkd9zz0p.js} +17 -17
  124. package/dist/index-saews2s3.js +229 -0
  125. package/dist/{index-kkvxnbt8.js → index-sj89f3b0.js} +62 -33
  126. package/dist/{index-jw4gbfkv.js → index-v10f1rjv.js} +5 -5
  127. package/dist/{index-0j6crjgh.js → index-v13skev1.js} +13 -13
  128. package/dist/{index-hqnggmxn.js → index-wj6ht7nm.js} +547 -179
  129. package/dist/{index-a865mj02.js → index-wk0n1cgt.js} +4 -4
  130. package/dist/{index-q3qck7j2.js → index-wz6mzzb1.js} +6 -5
  131. package/dist/{index-se1w3v2m.js → index-y1qysm3q.js} +332 -256
  132. package/dist/{index-a4b0gbyg.js → index-y9f76s3f.js} +1 -1
  133. package/dist/index.d.ts.map +1 -1
  134. package/dist/index.js +119 -129
  135. package/dist/{logger-wn328tfg.js → logger-jm3sqqzr.js} +2 -2
  136. package/dist/{message-index-bounded-0rbbg9rd.js → message-index-bounded-vm64mqpq.js} +16 -16
  137. package/dist/{message-index-ct5x2kwa.js → message-index-seaqpb7c.js} +16 -16
  138. package/dist/{message-time-backfill-nb5hhnrt.js → message-time-backfill-qjge9044.js} +3 -3
  139. package/dist/migration-worker.js +11 -11
  140. package/dist/plugin/dream-timer.d.ts.map +1 -1
  141. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  142. package/dist/plugin/tool-registry.d.ts.map +1 -1
  143. package/dist/{project-embedding-registry-ft9gh2e2.js → project-embedding-registry-x45bv3qr.js} +12 -11
  144. package/dist/raw-ordinal-warmup-worker.js +12 -7
  145. package/dist/{read-session-chunk-y3hhsbzw.js → read-session-chunk-ax05f7gr.js} +11 -11
  146. package/dist/{read-session-raw-gm6xj30v.js → read-session-raw-m56hc7v2.js} +7 -3
  147. package/dist/recomp-orchestrator-dmbeadwt.js +61 -0
  148. package/dist/{safe-notification-target-jdynm677.js → safe-notification-target-1szv1k5k.js} +3 -3
  149. package/dist/{search-jd8xh721.js → search-5yd5ytzs.js} +25 -24
  150. package/dist/{send-session-notification-vzhj8bsg.js → send-session-notification-24r4esbh.js} +6 -6
  151. package/dist/shared/data-path.d.ts +4 -0
  152. package/dist/shared/data-path.d.ts.map +1 -1
  153. package/dist/shared/model-suggestion-retry.d.ts +2 -0
  154. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  155. package/dist/shared/prompt-async-transport.d.ts.map +1 -1
  156. package/dist/{storage-tags-35m4gms2.js → storage-tags-yygfb9c8.js} +7 -5
  157. package/dist/{task-config-cgpg0nvh.js → task-config-x3qmayd2.js} +6 -2
  158. package/dist/tools/ctx-note/tools.d.ts.map +1 -1
  159. package/dist/{transform-postprocess-phase-pmqxfq4q.js → transform-postprocess-phase-72v86syx.js} +32 -31
  160. package/dist/v2/auto-search-worker.js +4 -4
  161. package/dist/v2/chunk-embedding-write-worker.js +88 -0
  162. package/dist/v2/{compaction-marker-candidates-a15w3mqh.js → compaction-marker-candidates-1vqwr3s5.js} +2 -2
  163. package/dist/v2/compaction-marker-candidates-worker.js +1 -1
  164. package/dist/v2/{context-p1zfcw41.js → context-w055w17c.js} +628 -255
  165. package/dist/v2/{derive-budgets-0rmpmxjw.js → derive-budgets-2zh4gm2c.js} +3 -3
  166. package/dist/v2/embedding-backfill-jmaf8zrr.js +21 -0
  167. package/dist/v2/embedding-worker-process.js +1 -1
  168. package/dist/v2/embedding-worker.js +5 -5
  169. package/dist/v2/{history-owner-2cr9py37.js → history-owner-42e16w0n.js} +2 -2
  170. package/dist/v2/hooks/context.d.ts.map +1 -1
  171. package/dist/v2/hooks/dream-manual.d.ts.map +1 -1
  172. package/dist/v2/hooks/dream-trigger.d.ts +1 -1
  173. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  174. package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
  175. package/dist/v2/hooks/transform-features.d.ts +3 -2
  176. package/dist/v2/hooks/transform-features.d.ts.map +1 -1
  177. package/dist/v2/{logger-te6e1j72.js → logger-7qt02bnb.js} +1 -1
  178. package/dist/v2/{message-index-bounded-7wcbp975.js → message-index-bounded-wepg5723.js} +15 -15
  179. package/dist/v2/{message-index-cjhv92m2.js → message-index-gcmd0ng0.js} +15 -15
  180. package/dist/v2/{message-time-backfill-rz1pnpaj.js → message-time-backfill-bsteyc4d.js} +2 -2
  181. package/dist/v2/migration-worker.js +10 -10
  182. package/dist/v2/{project-embedding-registry-g34gcf74.js → project-embedding-registry-0msp56p8.js} +11 -10
  183. package/dist/v2/raw-ordinal-warmup-worker.js +12 -7
  184. package/dist/v2/{read-session-chunk-8d3v87vr.js → read-session-chunk-hr3w5bjk.js} +10 -10
  185. package/dist/v2/{read-session-raw-h4azh85b.js → read-session-raw-b3tf6ra1.js} +6 -2
  186. package/dist/v2/recomp-orchestrator-ca7qt75a.js +60 -0
  187. package/dist/v2/retrospective-raw-provider.d.ts.map +1 -1
  188. package/dist/v2/{safe-notification-target-936374xx.js → safe-notification-target-qg7n2s77.js} +2 -2
  189. package/dist/v2/{search-a1acjwf8.js → search-c86dcv14.js} +24 -23
  190. package/dist/v2/{send-session-notification-z5mcjdea.js → send-session-notification-8ghn9tnv.js} +5 -5
  191. package/dist/v2/{server-npm52h2q.js → server-05xjtq6c.js} +1 -1
  192. package/dist/v2/{server-s6jqh8bj.js → server-0ppsweh6.js} +1 -1
  193. package/dist/v2/server-0s95v3en.js +49 -0
  194. package/dist/v2/{server-hn9fb3v0.js → server-34kwfsr4.js} +2 -2
  195. package/dist/v2/server-4gn3z5an.js +229 -0
  196. package/dist/v2/{server-kn7skz9r.js → server-6cdy4rc0.js} +3 -3
  197. package/dist/v2/{server-7dv9wt9r.js → server-6pmqg9m4.js} +1 -1
  198. package/dist/v2/{server-7fvmt15t.js → server-b81w6sw3.js} +273 -107
  199. package/dist/v2/{server-kmapq3v0.js → server-bxpwy6fy.js} +18 -5
  200. package/dist/v2/{server-d6t16r89.js → server-d8tj10db.js} +1 -1
  201. package/dist/v2/{server-cxsr0ng6.js → server-da07v4xp.js} +1 -1
  202. package/dist/v2/{server-rxcq4t50.js → server-ef89gdsx.js} +5 -5
  203. package/dist/v2/{server-9e5r8y60.js → server-f2xf5gcb.js} +46 -2
  204. package/dist/v2/{server-83d71zab.js → server-g10mdym6.js} +3 -3
  205. package/dist/v2/{server-njnx39q2.js → server-gvkm8xaj.js} +189 -29
  206. package/dist/v2/{server-ckrb5rm8.js → server-h0410h0v.js} +1 -1
  207. package/dist/v2/{server-sg68np13.js → server-hek6z3w6.js} +330 -254
  208. package/dist/v2/{server-f27he3j1.js → server-k2bzedxk.js} +4 -4
  209. package/dist/v2/{server-wkhfyzpg.js → server-m97brnat.js} +9 -9
  210. package/dist/v2/{server-erfp0xb6.js → server-n8ch9683.js} +16 -16
  211. package/dist/v2/{server-bx59ezg6.js → server-prg55b7k.js} +16 -6
  212. package/dist/v2/{server-89fcbe37.js → server-pwv4ezb0.js} +1 -1
  213. package/dist/v2/{server-r5p3b1wy.js → server-qd11g795.js} +29 -1
  214. package/dist/v2/{server-ewqshbs8.js → server-qhfvvfxj.js} +64 -7
  215. package/dist/v2/{server-988cqjme.js → server-rrqpvwqd.js} +2 -2
  216. package/dist/v2/{server-d3f4g62c.js → server-t4prcjc1.js} +13 -13
  217. package/dist/v2/{server-nveratm5.js → server-tbe1femw.js} +4 -4
  218. package/dist/v2/{server-jc8v585p.js → server-th4y11y7.js} +15 -15
  219. package/dist/v2/{server-h3wc20sv.js → server-vbe4se57.js} +4 -4
  220. package/dist/v2/{server-pbpp8r8h.js → server-xh7jar6k.js} +9 -9
  221. package/dist/v2/{server-63ha7f0f.js → server-yrvqaswb.js} +1 -1
  222. package/dist/v2/{server-5x7kmyz8.js → server-zc3e54vy.js} +10 -51
  223. package/dist/v2/{server-xqf2d2mg.js → server-zs8d0s3b.js} +2 -2
  224. package/dist/v2/server.d.ts.map +1 -1
  225. package/dist/v2/server.js +18 -10
  226. package/dist/v2/{storage-tags-c4zfcxv4.js → storage-tags-a2gq6dw7.js} +6 -4
  227. package/dist/v2/store-reader.d.ts +1 -0
  228. package/dist/v2/store-reader.d.ts.map +1 -1
  229. package/dist/v2/{task-config-x0hq3qfd.js → task-config-nvz8mapa.js} +6 -2
  230. package/dist/v2/{wrapup-orchestrator-87q9d5e2.js → wrapup-orchestrator-e1a2w6jh.js} +31 -29
  231. package/dist/wrapup-orchestrator-2051r6qm.js +48 -0
  232. package/package.json +6 -5
  233. package/src/agents/smart-notes-dreamer-gate.fixture.ts +171 -0
  234. package/src/agents/smart-notes-dreamer-gate.golden.json +245 -0
  235. package/src/agents/smart-notes-dreamer-gate.test.ts +161 -0
  236. package/src/config/agent-disable.ts +13 -0
  237. package/src/config/dependency-notes.test.ts +114 -0
  238. package/src/config/dependency-notes.ts +80 -0
  239. package/src/config/schema/magic-context.ts +23 -14
  240. package/src/features/magic-context/dreamer/task-registry.ts +40 -0
  241. package/src/shared/data-path.test.ts +35 -1
  242. package/src/shared/data-path.ts +57 -1
  243. package/src/shared/model-suggestion-retry.test.ts +34 -0
  244. package/src/shared/model-suggestion-retry.ts +23 -3
  245. package/src/shared/prompt-async-transport.test.ts +1 -1
  246. package/src/shared/prompt-async-transport.ts +16 -3
  247. package/dist/embedding-backfill-fjbfh1dt.js +0 -21
  248. package/dist/recomp-orchestrator-67k45s0b.js +0 -60
  249. package/dist/v2/embedding-backfill-xcw3t6hp.js +0 -20
  250. package/dist/v2/recomp-orchestrator-n0pq36f0.js +0 -59
  251. package/dist/wrapup-orchestrator-jqapepw0.js +0 -47
  252. /package/dist/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
  253. /package/dist/v2/{index-e6xnpach.js → index-b7p25tm0.js} +0 -0
@@ -1,4 +1,12 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
1
+ import {
2
+ existsSync,
3
+ lstatSync,
4
+ mkdirSync,
5
+ readFileSync,
6
+ readlinkSync,
7
+ realpathSync,
8
+ writeFileSync,
9
+ } from "node:fs";
2
10
  import * as os from "node:os";
3
11
  import * as path from "node:path";
4
12
  import { getHarness, type HarnessId } from "./harness";
@@ -253,6 +261,54 @@ export function getMagicContextStorageDir(): string {
253
261
  return getMagicContextStorageResolution().path;
254
262
  }
255
263
 
264
+ function canonicalizeStoragePath(value: string, seen = new Set<string>()): string {
265
+ const absolute = path.resolve(value);
266
+ if (seen.has(absolute)) return absolute;
267
+ seen.add(absolute);
268
+
269
+ try {
270
+ return realpathSync.native(absolute);
271
+ } catch {
272
+ try {
273
+ if (lstatSync(absolute).isSymbolicLink()) {
274
+ const target = readlinkSync(absolute);
275
+ const resolvedTarget = path.isAbsolute(target)
276
+ ? target
277
+ : path.resolve(path.dirname(absolute), target);
278
+ return canonicalizeStoragePath(resolvedTarget, seen);
279
+ }
280
+ } catch {
281
+ // The path may not exist yet; resolve the nearest existing parent below.
282
+ }
283
+
284
+ const parent = path.dirname(absolute);
285
+ if (parent === absolute) return absolute;
286
+ const resolvedParent = canonicalizeStoragePath(parent, seen);
287
+ return path.resolve(resolvedParent, path.basename(absolute));
288
+ }
289
+ }
290
+
291
+ /** Whether the resolved store is outside the default CortexKit backup directory. */
292
+ export function isMagicContextStorageOutsideEngram(
293
+ storageDir = getMagicContextStorageDir(),
294
+ backupDir = path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context"),
295
+ ): boolean {
296
+ const resolvedStorageDir = canonicalizeStoragePath(storageDir);
297
+ const resolvedBackupDir = canonicalizeStoragePath(backupDir);
298
+ const relative = path.relative(resolvedBackupDir, resolvedStorageDir);
299
+ return path.isAbsolute(relative) || relative === ".." || relative.startsWith(`..${path.sep}`);
300
+ }
301
+
302
+ const STORAGE_BACKUP_WARNING_CHECKED = Symbol.for("magic-context.storage-backup-warning-checked");
303
+
304
+ /** Claim the process-wide startup check so multiple host entries log at most once. */
305
+ export function claimStorageBackupWarningCheck(): boolean {
306
+ const processState = globalThis as unknown as { [key: symbol]: boolean | undefined };
307
+ if (processState[STORAGE_BACKUP_WARNING_CHECKED]) return false;
308
+ processState[STORAGE_BACKUP_WARNING_CHECKED] = true;
309
+ return true;
310
+ }
311
+
256
312
  let testBackstopStorageDir: string | null = null;
257
313
  let testBackstopWarned = false;
258
314
 
@@ -40,6 +40,18 @@ function createArgs(model?: { providerID: string; modelID: string }) {
40
40
  }
41
41
 
42
42
  describe("promptSyncWithModelSuggestionRetry", () => {
43
+ test("synchronous prompt completion retains await semantics with cancellation", async () => {
44
+ const prompt = mock(() => undefined);
45
+ const abort = mock(async () => ({}));
46
+
47
+ await promptSyncWithModelSuggestionRetry(createClient(prompt, abort), createArgs(), {
48
+ signal: new AbortController().signal,
49
+ });
50
+
51
+ expect(prompt).toHaveBeenCalledTimes(1);
52
+ expect(abort).not.toHaveBeenCalled();
53
+ });
54
+
43
55
  test("primary succeeds, no fallback iteration", async () => {
44
56
  const prompt = mock(async () => ({}));
45
57
  const client = createClient(prompt);
@@ -799,3 +811,25 @@ test("DeepSeek unsupported-model 400 preserves provider status and message rathe
799
811
  expect((caught as Error).message).not.toContain("no output");
800
812
  expect(getPromptFailureDetail(caught)).toMatchObject({ failureClass: "provider_error" });
801
813
  });
814
+
815
+ test("timeout rejects an uncooperative carrier and aborts its child", async () => {
816
+ const abort = mock(async () => ({}));
817
+ const client = createClient(
818
+ mock(() => new Promise(() => {})),
819
+ abort,
820
+ );
821
+ let timer: ReturnType<typeof setTimeout> | undefined;
822
+ try {
823
+ await expect(
824
+ Promise.race([
825
+ promptSyncWithModelSuggestionRetry(client, createArgs(), { timeoutMs: 10 }),
826
+ new Promise((_, reject) => {
827
+ timer = setTimeout(() => reject(new Error("carrier remained stuck")), 200);
828
+ }),
829
+ ]),
830
+ ).rejects.toThrow("prompt timed out after 10ms");
831
+ expect(abort).toHaveBeenCalledTimes(1);
832
+ } finally {
833
+ clearTimeout(timer);
834
+ }
835
+ });
@@ -248,6 +248,23 @@ function externalAbortMessage(signal: AbortSignal): string {
248
248
  return `prompt aborted by external signal${reason instanceof Error && /^lease_(?:lost|expired):/.test(reason.message) ? `: ${reason.message}` : ""}`;
249
249
  }
250
250
 
251
+ /** A carrier may ignore cancellation; stop waiting without trusting it to reject. */
252
+ export function raceWithSignal<T>(work: Promise<T>, signal?: AbortSignal): Promise<T> {
253
+ // Match await's handling of synchronous completion as well as promises.
254
+ work = Promise.resolve(work);
255
+ if (!signal) return work;
256
+ return new Promise<T>((resolve, reject) => {
257
+ const abort = () => reject(new Error(externalAbortMessage(signal)));
258
+ if (signal.aborted) {
259
+ work.catch(() => {});
260
+ abort();
261
+ return;
262
+ }
263
+ signal.addEventListener("abort", abort, { once: true });
264
+ work.then(resolve, reject).finally(() => signal.removeEventListener("abort", abort));
265
+ });
266
+ }
267
+
251
268
  async function promptWithTimeout(
252
269
  client: Client,
253
270
  args: PromptArgs,
@@ -273,10 +290,13 @@ async function promptWithTimeout(
273
290
 
274
291
  try {
275
292
  const request = { ...args, signal: controller.signal };
276
- if (transport) await transport(request);
293
+ if (transport) await raceWithSignal(transport(request), controller.signal);
277
294
  else {
278
295
  if (!client) throw new Error("Hidden completion transport is unavailable");
279
- await client.session.prompt(request as Parameters<typeof client.session.prompt>[0]);
296
+ await raceWithSignal<unknown>(
297
+ client.session.prompt(request as Parameters<typeof client.session.prompt>[0]),
298
+ controller.signal,
299
+ );
280
300
  }
281
301
  } catch (error) {
282
302
  if (signal?.aborted) {
@@ -676,7 +696,7 @@ async function attemptAndValidate<TOutput, TValidated>(
676
696
 
677
697
  let output: TOutput;
678
698
  try {
679
- output = await options.fetchOutput(args, attempt);
699
+ output = await raceWithSignal(options.fetchOutput(args, attempt), options.signal);
680
700
  } catch (error) {
681
701
  throw {
682
702
  error,
@@ -202,7 +202,7 @@ describe("dreamer budget on an async child", () => {
202
202
  },
203
203
  readChildTokenBudget: (id: string) => {
204
204
  expect(id).toBe("ses-child");
205
- expect(ready).toBe(true);
205
+ if (!ready) return undefined;
206
206
  return { spent: 58, finalizeFired: true };
207
207
  },
208
208
  };
@@ -130,9 +130,22 @@ export function createPromptAsyncTransport(
130
130
  if (!readChildTokenBudget || !session?.prompt) return undefined;
131
131
  return Object.assign(
132
132
  async (request: PromptArgs) => {
133
- await session.prompt?.(request);
134
- const state = readChildTokenBudget(childSessionId);
135
- if (state) options.onBudgetUpdate?.({ ...state, sessionId: childSessionId });
133
+ const previous = readChildTokenBudget(childSessionId);
134
+ const remaining =
135
+ options.tokenBudget === undefined
136
+ ? undefined
137
+ : options.tokenBudget - (previous?.spent ?? 0);
138
+ if ((remaining !== undefined && remaining <= 0) || previous?.finalizeFired)
139
+ throw new DreamTokenBudgetExceeded(childSessionId, previous?.spent ?? 0);
140
+ try {
141
+ await session.prompt?.({
142
+ ...request,
143
+ ...(remaining === undefined ? {} : { tokenBudget: remaining }),
144
+ });
145
+ } finally {
146
+ const state = readChildTokenBudget(childSessionId);
147
+ if (state) options.onBudgetUpdate?.({ ...state, sessionId: childSessionId });
148
+ }
136
149
  },
137
150
  { childSessionId },
138
151
  );
@@ -1,21 +0,0 @@
1
- import {
2
- ensureMemoryEmbeddings2
3
- } from "./index-4ccdr7yw.js";
4
- import"./index-se1w3v2m.js";
5
- import"./index-9159kk15.js";
6
- import"./index-4dhv7mqz.js";
7
- import"./index-qt1qqasc.js";
8
- import"./index-bmwfzz28.js";
9
- import"./index-kvw6xew3.js";
10
- import"./index-0jz47061.js";
11
- import"./index-mp2kghkv.js";
12
- import"./index-w28y7d0z.js";
13
- import"./index-150zz6fh.js";
14
- import"./index-gjvjh960.js";
15
- import"./index-wafzvyhg.js";
16
- import"./index-mvvephtj.js";
17
- import"./index-0sahzkwr.js";
18
- import"./index-pavzsdc6.js";
19
- export {
20
- ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
21
- };
@@ -1,60 +0,0 @@
1
- import {
2
- isRecompFailure2,
3
- isRecompSkip2,
4
- extractRecompReason2,
5
- setRecompStarting2,
6
- setRecompNote2,
7
- setRecompTerminal2,
8
- buildRecompDeps2,
9
- runManagedRecomp2
10
- } from "./index-g40wgxxt.js";
11
- import"./index-z7avx6rw.js";
12
- import"./index-s178h9z8.js";
13
- import"./index-yhrrx7qa.js";
14
- import"./index-0j6crjgh.js";
15
- import"./index-sd3egckz.js";
16
- import"./index-4ccdr7yw.js";
17
- import"./index-n78avt2p.js";
18
- import"./index-se1w3v2m.js";
19
- import"./index-9159kk15.js";
20
- import"./index-4dhv7mqz.js";
21
- import"./index-jw4gbfkv.js";
22
- import"./index-0abg88h2.js";
23
- import"./index-qt1qqasc.js";
24
- import"./index-x8a7jmkh.js";
25
- import"./index-a4b0gbyg.js";
26
- import"./index-bmwfzz28.js";
27
- import"./index-kvw6xew3.js";
28
- import"./index-xztdf9t7.js";
29
- import"./index-a865mj02.js";
30
- import"./index-fb3zxn06.js";
31
- import"./index-fr0wbhdn.js";
32
- import"./index-0jz47061.js";
33
- import"./index-mp2kghkv.js";
34
- import"./index-q28hsbpg.js";
35
- import"./index-qr1mkc2y.js";
36
- import"./index-f8cn4xqa.js";
37
- import"./index-1zx87sdm.js";
38
- import"./index-bzp9s8z2.js";
39
- import"./index-angx1s0k.js";
40
- import"./index-v0p37hm2.js";
41
- import"./index-w28y7d0z.js";
42
- import"./index-9jvab89d.js";
43
- import"./index-g7jkrz0x.js";
44
- import"./index-58e3y90n.js";
45
- import"./index-150zz6fh.js";
46
- import"./index-gjvjh960.js";
47
- import"./index-wafzvyhg.js";
48
- import"./index-mvvephtj.js";
49
- import"./index-0sahzkwr.js";
50
- import"./index-pavzsdc6.js";
51
- export {
52
- buildRecompDeps2 as buildRecompDeps,
53
- extractRecompReason2 as extractRecompReason,
54
- isRecompFailure2 as isRecompFailure,
55
- isRecompSkip2 as isRecompSkip,
56
- runManagedRecomp2 as runManagedRecomp,
57
- setRecompNote2 as setRecompNote,
58
- setRecompStarting2 as setRecompStarting,
59
- setRecompTerminal2 as setRecompTerminal
60
- };
@@ -1,20 +0,0 @@
1
- import {
2
- ensureMemoryEmbeddings2
3
- } from "./server-rxcq4t50.js";
4
- import"./server-sg68np13.js";
5
- import"./server-ewqshbs8.js";
6
- import"./server-4dhv7mqz.js";
7
- import"./server-qt1qqasc.js";
8
- import"./server-83d71zab.js";
9
- import"./server-988cqjme.js";
10
- import"./server-njnx39q2.js";
11
- import"./server-63ha7f0f.js";
12
- import"./server-jc8v585p.js";
13
- import"./server-7dv9wt9r.js";
14
- import"./server-s6jqh8bj.js";
15
- import"./server-wafzvyhg.js";
16
- import"./server-9e5r8y60.js";
17
- import"./server-pavzsdc6.js";
18
- export {
19
- ensureMemoryEmbeddings2 as ensureMemoryEmbeddings
20
- };
@@ -1,59 +0,0 @@
1
- import {
2
- isRecompFailure2,
3
- isRecompSkip2,
4
- extractRecompReason2,
5
- setRecompStarting2,
6
- setRecompNote2,
7
- setRecompTerminal2,
8
- buildRecompDeps2,
9
- runManagedRecomp2
10
- } from "./server-7fvmt15t.js";
11
- import"./server-npm52h2q.js";
12
- import"./server-kn7skz9r.js";
13
- import"./server-d3f4g62c.js";
14
- import"./server-rxcq4t50.js";
15
- import"./server-n78avt2p.js";
16
- import"./server-sg68np13.js";
17
- import"./server-ewqshbs8.js";
18
- import"./server-4dhv7mqz.js";
19
- import"./server-hn9fb3v0.js";
20
- import"./server-h3wc20sv.js";
21
- import"./server-qt1qqasc.js";
22
- import"./server-ckrb5rm8.js";
23
- import"./server-5x7kmyz8.js";
24
- import"./server-nveratm5.js";
25
- import"./server-x8a7jmkh.js";
26
- import"./server-83d71zab.js";
27
- import"./server-988cqjme.js";
28
- import"./server-erfp0xb6.js";
29
- import"./server-fb3zxn06.js";
30
- import"./server-f27he3j1.js";
31
- import"./server-fr0wbhdn.js";
32
- import"./server-njnx39q2.js";
33
- import"./server-63ha7f0f.js";
34
- import"./server-cxsr0ng6.js";
35
- import"./server-wkhfyzpg.js";
36
- import"./server-kmapq3v0.js";
37
- import"./server-1zx87sdm.js";
38
- import"./server-d6t16r89.js";
39
- import"./server-bx59ezg6.js";
40
- import"./server-51779zs2.js";
41
- import"./server-jc8v585p.js";
42
- import"./server-xqf2d2mg.js";
43
- import"./server-89fcbe37.js";
44
- import"./server-2ra6pwf3.js";
45
- import"./server-7dv9wt9r.js";
46
- import"./server-s6jqh8bj.js";
47
- import"./server-wafzvyhg.js";
48
- import"./server-9e5r8y60.js";
49
- import"./server-pavzsdc6.js";
50
- export {
51
- buildRecompDeps2 as buildRecompDeps,
52
- extractRecompReason2 as extractRecompReason,
53
- isRecompFailure2 as isRecompFailure,
54
- isRecompSkip2 as isRecompSkip,
55
- runManagedRecomp2 as runManagedRecomp,
56
- setRecompNote2 as setRecompNote,
57
- setRecompStarting2 as setRecompStarting,
58
- setRecompTerminal2 as setRecompTerminal
59
- };
@@ -1,47 +0,0 @@
1
- import {
2
- runManagedWrapup2
3
- } from "./index-q3qck7j2.js";
4
- import"./index-g40wgxxt.js";
5
- import"./index-z7avx6rw.js";
6
- import"./index-s178h9z8.js";
7
- import"./index-yhrrx7qa.js";
8
- import"./index-0j6crjgh.js";
9
- import"./index-sd3egckz.js";
10
- import"./index-4ccdr7yw.js";
11
- import"./index-n78avt2p.js";
12
- import"./index-se1w3v2m.js";
13
- import"./index-9159kk15.js";
14
- import"./index-4dhv7mqz.js";
15
- import"./index-jw4gbfkv.js";
16
- import"./index-0abg88h2.js";
17
- import"./index-qt1qqasc.js";
18
- import"./index-x8a7jmkh.js";
19
- import"./index-a4b0gbyg.js";
20
- import"./index-bmwfzz28.js";
21
- import"./index-kvw6xew3.js";
22
- import"./index-xztdf9t7.js";
23
- import"./index-a865mj02.js";
24
- import"./index-fb3zxn06.js";
25
- import"./index-fr0wbhdn.js";
26
- import"./index-0jz47061.js";
27
- import"./index-mp2kghkv.js";
28
- import"./index-q28hsbpg.js";
29
- import"./index-qr1mkc2y.js";
30
- import"./index-f8cn4xqa.js";
31
- import"./index-1zx87sdm.js";
32
- import"./index-bzp9s8z2.js";
33
- import"./index-angx1s0k.js";
34
- import"./index-v0p37hm2.js";
35
- import"./index-w28y7d0z.js";
36
- import"./index-9jvab89d.js";
37
- import"./index-g7jkrz0x.js";
38
- import"./index-58e3y90n.js";
39
- import"./index-150zz6fh.js";
40
- import"./index-gjvjh960.js";
41
- import"./index-wafzvyhg.js";
42
- import"./index-mvvephtj.js";
43
- import"./index-0sahzkwr.js";
44
- import"./index-pavzsdc6.js";
45
- export {
46
- runManagedWrapup2 as runManagedWrapup
47
- };
File without changes