@cortexkit/opencode-magic-context 0.49.48 → 0.49.50

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 (224) hide show
  1. package/dist/{announcement-g789dmt6.js → announcement-9pr71hd5.js} +3 -2
  2. package/dist/auto-search-worker.js +5 -5
  3. package/dist/chunk-embedding-write-worker.js +14 -15
  4. package/dist/{compaction-marker-candidates-dkfp1q9j.js → compaction-marker-candidates-8hazqfvj.js} +2 -3
  5. package/dist/compaction-marker-candidates-worker.js +1 -1
  6. package/dist/{compartment-chunk-embedding-snj51nmg.js → compartment-chunk-embedding-gfd093f8.js} +7 -8
  7. package/dist/config/project-security.d.ts.map +1 -1
  8. package/dist/config/schema/magic-context.d.ts +10 -0
  9. package/dist/config/schema/magic-context.d.ts.map +1 -1
  10. package/dist/{conflict-warning-hook-w1aw6w5t.js → conflict-warning-hook-56qpq7ws.js} +7 -8
  11. package/dist/{context-8r125qv3.js → context-4js5qnnm.js} +61 -49
  12. package/dist/{derive-budgets-nkw09vq7.js → derive-budgets-z53424qx.js} +2 -3
  13. package/dist/embedding-backfill-3wdjzrvs.js +27 -0
  14. package/dist/embedding-worker-process.js +2 -3
  15. package/dist/embedding-worker.js +6 -7
  16. package/dist/features/magic-context/dreamer/docs-proposals.d.ts.map +1 -1
  17. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts +5 -7
  18. package/dist/features/magic-context/dreamer/provider-output-failure.d.ts.map +1 -1
  19. package/dist/features/magic-context/dreamer/task-scheduler.d.ts.map +1 -1
  20. package/dist/features/magic-context/dreamer/verify.d.ts.map +1 -1
  21. package/dist/features/magic-context/memory/embedding-identity.d.ts.map +1 -1
  22. package/dist/features/magic-context/memory/embedding-openai.d.ts +4 -0
  23. package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
  24. package/dist/features/magic-context/memory/embedding-probe.d.ts +10 -0
  25. package/dist/features/magic-context/memory/embedding-probe.d.ts.map +1 -1
  26. package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
  27. package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
  28. package/dist/features/magic-context/storage-db.d.ts +14 -0
  29. package/dist/features/magic-context/storage-db.d.ts.map +1 -1
  30. package/dist/features/magic-context/transform-decision-log.d.ts +2 -0
  31. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  32. package/dist/{history-owner-0z620wgz.js → history-owner-n50e0e8y.js} +2 -3
  33. package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
  34. package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
  35. package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
  36. package/dist/hooks/magic-context/protected-tail-boundary.d.ts +5 -3
  37. package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
  38. package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
  39. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  40. package/dist/{index-rvmhyk89.js → index-07rp6xcn.js} +9 -9
  41. package/dist/{index-txs8tce6.js → index-0k283v27.js} +2 -4
  42. package/dist/{index-ak11t3gm.js → index-0tz2fzpq.js} +1 -1
  43. package/dist/{index-2qbtqg1w.js → index-25tm250q.js} +1 -1
  44. package/dist/{index-h9m41624.js → index-2ny9xwdn.js} +2 -2
  45. package/dist/{index-xa9mmq6c.js → index-36wseasx.js} +1 -1
  46. package/dist/{index-cgzpbz78.js → index-5dptmnvd.js} +5 -5
  47. package/dist/{index-q41sm60t.js → index-5g6npyw5.js} +89 -63
  48. package/dist/{index-qsyx931k.js → index-5t1mr0bt.js} +13 -15
  49. package/dist/{index-jrfre9ah.js → index-82dfe8en.js} +146 -5
  50. package/dist/{index-d4qw2h43.js → index-8d7gkgjs.js} +6 -5
  51. package/dist/{index-gn6gfz4y.js → index-90z05d0p.js} +1 -1
  52. package/dist/{index-trkxkgmd.js → index-97bjd14c.js} +5 -5
  53. package/dist/{index-9wnbnx8f.js → index-a6aqpfp6.js} +1 -1
  54. package/dist/{index-s79g172v.js → index-bamnjp2t.js} +29 -13
  55. package/dist/{index-4wpfbzks.js → index-bkg4hdyh.js} +3 -3
  56. package/dist/{index-gp3kcpc4.js → index-cd3vp8xa.js} +1 -1
  57. package/dist/{index-vk6srk5r.js → index-ct3ettqt.js} +3 -3
  58. package/dist/{index-sd2s4t4p.js → index-cwj6qhmf.js} +2 -2
  59. package/dist/{index-brj6was5.js → index-em92bp7f.js} +2 -2
  60. package/dist/{index-2p37txes.js → index-ga5q492k.js} +1 -1
  61. package/dist/{index-8cfnaagj.js → index-gapnh6tk.js} +2 -4
  62. package/dist/{index-fw42ms3m.js → index-gz001bx7.js} +1 -1
  63. package/dist/{index-zetm0ayn.js → index-h8g08nxs.js} +164 -106
  64. package/dist/{index-qcz1fy7h.js → index-hexdee98.js} +4 -4
  65. package/dist/{index-fgft4qjn.js → index-hkveze74.js} +4 -4
  66. package/dist/{index-smtbdmc3.js → index-hsv31e69.js} +2 -2
  67. package/dist/{index-dj2p8653.js → index-hsyczpn7.js} +2 -2
  68. package/dist/{index-4dpvnp8k.js → index-jjy5a5w0.js} +3 -0
  69. package/dist/{index-1hwn96x1.js → index-kn1bx21r.js} +3 -3
  70. package/dist/{index-t6s0tsp7.js → index-mjh63zvw.js} +3 -3
  71. package/dist/{index-ta87fpfs.js → index-n0twfvah.js} +64 -15
  72. package/dist/{index-nj360hcs.js → index-pb8ysnq2.js} +4 -4
  73. package/dist/{index-jz5bk7xd.js → index-qperbvjn.js} +2 -2
  74. package/dist/{index-25ka1jza.js → index-r9agn061.js} +4 -4
  75. package/dist/{index-hkh8x221.js → index-rbs27k1d.js} +7 -7
  76. package/dist/{index-hacf2tyx.js → index-reyws9fy.js} +1 -1
  77. package/dist/{index-cgsmttyj.js → index-s131svmx.js} +4 -4
  78. package/dist/{index-fxbk7gk3.js → index-tad3can2.js} +1 -1
  79. package/dist/{index-8ka0ne8t.js → index-v4a1pnny.js} +6 -6
  80. package/dist/{index-xh3jyejb.js → index-wr2t8zb0.js} +17 -19
  81. package/dist/{index-q6pjqm49.js → index-z4832qfe.js} +14 -14
  82. package/dist/index.js +54 -56
  83. package/dist/{logger-qwnbcfj9.js → logger-sw7z6sjz.js} +1 -2
  84. package/dist/{message-fts-rowid-map-msffhkve.js → message-fts-rowid-map-kx1bsdyg.js} +4 -5
  85. package/dist/{message-index-bounded-0q7sy04w.js → message-index-bounded-k0ebpy3y.js} +12 -13
  86. package/dist/{message-time-backfill-39bm498k.js → message-time-backfill-hp2jgn49.js} +2 -3
  87. package/dist/migration-worker.js +12 -13
  88. package/dist/plugin/embedding-bootstrap-helpers.d.ts.map +1 -1
  89. package/dist/plugin/embedding-routing.d.ts.map +1 -1
  90. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  91. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  92. package/dist/{project-embedding-registry-r6xfsrbe.js → project-embedding-registry-5dwh5zfn.js} +12 -13
  93. package/dist/raw-ordinal-warmup-worker.js +8 -8
  94. package/dist/{read-session-chunk-7fmg9p5m.js → read-session-chunk-6712p893.js} +10 -11
  95. package/dist/{read-session-raw-x7a9b3jm.js → read-session-raw-04ger9zt.js} +2 -3
  96. package/dist/{recomp-orchestrator-jqa5z4ar.js → recomp-orchestrator-8ebydg5j.js} +31 -32
  97. package/dist/render-dtc4qkq4.js +43 -0
  98. package/dist/{safe-notification-target-wztd7bgk.js → safe-notification-target-mx5khyxf.js} +2 -3
  99. package/dist/{search-archive-df09r8qn.js → search-archive-f6hjbnsa.js} +12 -13
  100. package/dist/{search-kt764afk.js → search-edv0gy1d.js} +24 -25
  101. package/dist/{send-session-notification-j93pn2hn.js → send-session-notification-gamjee2f.js} +5 -6
  102. package/dist/shared/data-path.d.ts +7 -13
  103. package/dist/shared/data-path.d.ts.map +1 -1
  104. package/dist/shared/hidden-model-cooldown.d.ts +23 -0
  105. package/dist/shared/hidden-model-cooldown.d.ts.map +1 -0
  106. package/dist/shared/model-suggestion-retry.d.ts +0 -2
  107. package/dist/shared/model-suggestion-retry.d.ts.map +1 -1
  108. package/dist/shared/provider-response-completion.d.ts +10 -0
  109. package/dist/shared/provider-response-completion.d.ts.map +1 -1
  110. package/dist/shared/rpc-types.d.ts +1 -0
  111. package/dist/shared/rpc-types.d.ts.map +1 -1
  112. package/dist/shared/status-summary.d.ts +1 -0
  113. package/dist/shared/status-summary.d.ts.map +1 -1
  114. package/dist/shared/status-view-check.d.ts.map +1 -1
  115. package/dist/shared/status-view.d.ts +1 -0
  116. package/dist/shared/status-view.d.ts.map +1 -1
  117. package/dist/shared/test-db.d.ts +13 -0
  118. package/dist/shared/test-db.d.ts.map +1 -0
  119. package/dist/{storage-tags-96vyd6ra.js → storage-tags-kdb4qsyq.js} +4 -5
  120. package/dist/test-preload.d.ts +2 -0
  121. package/dist/test-preload.d.ts.map +1 -0
  122. package/dist/{transform-postprocess-phase-a7ety10n.js → transform-postprocess-phase-1bg25094.js} +32 -33
  123. package/dist/v2/auto-search-worker.js +5 -5
  124. package/dist/v2/chunk-embedding-write-worker.js +14 -14
  125. package/dist/v2/{compaction-marker-candidates-y737qb1v.js → compaction-marker-candidates-re14353a.js} +2 -2
  126. package/dist/v2/compaction-marker-candidates-worker.js +1 -1
  127. package/dist/v2/{compartment-chunk-embedding-nj5nrnbj.js → compartment-chunk-embedding-0pxsrzrt.js} +7 -7
  128. package/dist/v2/{context-9x7mnb7x.js → context-qkr7z6d0.js} +99 -63
  129. package/dist/v2/{derive-budgets-b5cgrtp8.js → derive-budgets-w0815q82.js} +3 -3
  130. package/dist/v2/embedding-backfill-x1zpc04f.js +27 -0
  131. package/dist/v2/embedding-worker-process.js +1 -1
  132. package/dist/v2/embedding-worker.js +5 -5
  133. package/dist/v2/hidden-completion.d.ts.map +1 -1
  134. package/dist/v2/{history-owner-fpka43cn.js → history-owner-ep91wgqj.js} +2 -2
  135. package/dist/v2/hooks/context.d.ts.map +1 -1
  136. package/dist/v2/hooks/usage-persist.d.ts +1 -1
  137. package/dist/v2/hooks/usage-persist.d.ts.map +1 -1
  138. package/dist/v2/hooks/usage-reading.d.ts +3 -0
  139. package/dist/v2/hooks/usage-reading.d.ts.map +1 -1
  140. package/dist/v2/{logger-4cj6d03m.js → logger-xnscpj6w.js} +1 -1
  141. package/dist/v2/{message-fts-rowid-map-qe7cpksd.js → message-fts-rowid-map-57jh6xpb.js} +4 -4
  142. package/dist/v2/{message-index-bounded-hctgp22r.js → message-index-bounded-a36rw93p.js} +12 -12
  143. package/dist/v2/{message-time-backfill-0c4h7sg6.js → message-time-backfill-baxebka0.js} +2 -2
  144. package/dist/v2/migration-worker.js +11 -11
  145. package/dist/v2/{project-embedding-registry-ek0cy0d5.js → project-embedding-registry-v2fxrs8b.js} +12 -12
  146. package/dist/v2/raw-ordinal-warmup-worker.js +8 -8
  147. package/dist/v2/{read-session-chunk-zknadvjr.js → read-session-chunk-hzhxvhyv.js} +10 -10
  148. package/dist/v2/{read-session-raw-yss2ev98.js → read-session-raw-3e482h3c.js} +2 -2
  149. package/dist/v2/{recomp-orchestrator-m5w0eqke.js → recomp-orchestrator-yzr49pd0.js} +32 -32
  150. package/dist/v2/{render-89asy54r.js → render-rhaevxv1.js} +21 -21
  151. package/dist/v2/{safe-notification-target-gphhast7.js → safe-notification-target-9r79xnbt.js} +2 -2
  152. package/dist/v2/{search-archive-axz2gbdb.js → search-archive-9924fyk8.js} +12 -12
  153. package/dist/v2/{search-kdtja5rx.js → search-ggvexvv7.js} +23 -23
  154. package/dist/v2/{send-session-notification-na3q825m.js → send-session-notification-95p89k7q.js} +5 -5
  155. package/dist/v2/{server-yyqmvbvv.js → server-016a1whm.js} +161 -102
  156. package/dist/v2/{server-z3tyd1mx.js → server-0k586y7d.js} +3 -3
  157. package/dist/v2/{server-p9s40wfa.js → server-0ms13pc8.js} +3 -0
  158. package/dist/v2/{server-e3m10ds0.js → server-16kfxcxj.js} +4 -4
  159. package/dist/v2/{server-nn4hbymt.js → server-3bfc26r7.js} +9 -9
  160. package/dist/v2/{server-7vb38e51.js → server-3jc6qmdz.js} +1 -1
  161. package/dist/v2/{server-jra7awr5.js → server-3qf9n5ck.js} +11 -11
  162. package/dist/v2/{server-69m30b21.js → server-3yk44ddz.js} +1 -1
  163. package/dist/v2/{server-2gjqhmn9.js → server-4h4acntc.js} +27 -11
  164. package/dist/v2/{server-3schkz95.js → server-58h6rrnx.js} +4 -4
  165. package/dist/v2/{server-af1rmkyn.js → server-5kgesxck.js} +2 -2
  166. package/dist/v2/{server-mfn1yf9d.js → server-7vrtk78d.js} +1 -1
  167. package/dist/v2/{server-27kccwe7.js → server-88yvx6r9.js} +63 -12
  168. package/dist/v2/{server-f0j864ma.js → server-91gb0vh8.js} +1 -1
  169. package/dist/v2/{server-131h608x.js → server-966dq3pd.js} +2 -2
  170. package/dist/v2/{server-jb6tjyeb.js → server-bb6kf05j.js} +23 -20
  171. package/dist/v2/{server-sg2qjkrb.js → server-brsx45r6.js} +6 -4
  172. package/dist/v2/{server-gwxys0d0.js → server-c8z2grq0.js} +1 -1
  173. package/dist/v2/{server-y8n33d9j.js → server-g61hgy1y.js} +4 -4
  174. package/dist/v2/{server-zahgxer8.js → server-jxrqsn84.js} +3 -3
  175. package/dist/v2/{server-2j87594q.js → server-kgq2e2hh.js} +2 -2
  176. package/dist/v2/{server-ddw42d76.js → server-mxsy9h1d.js} +2 -2
  177. package/dist/v2/{server-qmmkhz2z.js → server-np27dgyt.js} +1 -1
  178. package/dist/v2/{server-jqn7q7tm.js → server-q93jdtz8.js} +5 -5
  179. package/dist/v2/{server-dcws5831.js → server-qp5sj6n5.js} +2 -2
  180. package/dist/v2/{server-7be0ersd.js → server-rcchadw0.js} +3 -3
  181. package/dist/v2/{server-b3r080cm.js → server-rz5jnhnv.js} +1 -1
  182. package/dist/v2/{server-zt1m5rwj.js → server-sa1fdt41.js} +1 -1
  183. package/dist/v2/{server-wa4qhryh.js → server-sb55ddgn.js} +5 -4
  184. package/dist/v2/{server-4x7n5qz7.js → server-scp3y4dh.js} +13 -11
  185. package/dist/v2/{server-pej5rnye.js → server-sgn61hht.js} +2 -2
  186. package/dist/v2/{server-ypf1ap0v.js → server-t8n27rbt.js} +1 -1
  187. package/dist/v2/{server-sefxj8k1.js → server-tmf0ayqp.js} +1 -1
  188. package/dist/v2/{server-sr8tf5dt.js → server-vjadwb3j.js} +6 -5
  189. package/dist/v2/{server-bez34e60.js → server-vqq3g1t7.js} +4 -4
  190. package/dist/v2/{server-tpt7bwq8.js → server-ww7xbxxf.js} +1 -1
  191. package/dist/v2/server.js +6 -6
  192. package/dist/v2/{storage-tags-xq8hjqkf.js → storage-tags-rzv7y0n3.js} +4 -4
  193. package/dist/v2/{v2-archive-reader-ky1wqcws.js → v2-archive-reader-5ggewg8q.js} +1 -1
  194. package/dist/v2/{wrapup-orchestrator-6wt67saz.js → wrapup-orchestrator-36c5wyvq.js} +32 -32
  195. package/dist/{v2-archive-reader-665x2x4d.js → v2-archive-reader-gx5ke1d7.js} +1 -1
  196. package/dist/wrapup-orchestrator-ya31knav.js +55 -0
  197. package/package.json +1 -1
  198. package/src/config/index.test.ts +20 -0
  199. package/src/config/project-security.test.ts +5 -1
  200. package/src/config/project-security.ts +4 -0
  201. package/src/config/schema/magic-context.test.ts +43 -0
  202. package/src/config/schema/magic-context.ts +19 -0
  203. package/src/shared/data-path.test.ts +104 -56
  204. package/src/shared/data-path.ts +30 -30
  205. package/src/shared/hidden-model-cooldown.test.ts +117 -0
  206. package/src/shared/hidden-model-cooldown.ts +123 -0
  207. package/src/shared/model-suggestion-retry.test.ts +53 -76
  208. package/src/shared/model-suggestion-retry.ts +38 -53
  209. package/src/shared/provider-response-completion.test.ts +49 -0
  210. package/src/shared/provider-response-completion.ts +64 -0
  211. package/src/shared/rpc-types.ts +1 -0
  212. package/src/shared/startup-maintenance-policy.test.ts +115 -0
  213. package/src/shared/status-detail-text.test.ts +7 -0
  214. package/src/shared/status-summary.ts +3 -0
  215. package/src/shared/status-view-check.ts +1 -0
  216. package/src/shared/status-view.test.ts +15 -0
  217. package/src/shared/status-view.ts +11 -1
  218. package/src/shared/test-db.test.ts +84 -0
  219. package/src/shared/test-db.ts +36 -0
  220. package/dist/embedding-backfill-kpy5shsa.js +0 -28
  221. package/dist/index-g2q4htwp.js +0 -146
  222. package/dist/render-mnqc74ar.js +0 -44
  223. package/dist/v2/embedding-backfill-360efh1t.js +0 -27
  224. package/dist/wrapup-orchestrator-7kmb3jf9.js +0 -56
@@ -6,25 +6,23 @@ import {
6
6
  StaleRouteHandleError,
7
7
  SubcClient,
8
8
  isConsumerReconnectTransient
9
- } from "./index-dj2p8653.js";
9
+ } from "./index-hsyczpn7.js";
10
10
  import {
11
11
  getHarness2
12
12
  } from "./index-pavzsdc6.js";
13
13
  import {
14
- getDataDir
15
- } from "./index-g2q4htwp.js";
14
+ getDataDir,
15
+ log2
16
+ } from "./index-82dfe8en.js";
16
17
  import {
17
18
  inRootAsyncContext2
18
19
  } from "./index-gzy5w8ya.js";
19
- import {
20
- log2
21
- } from "./index-jrfre9ah.js";
22
20
  import {
23
21
  buildCanonicalChunkTextFromFts2,
24
22
  loadCompartmentChunkEmbeddingsForSearch2,
25
23
  peekCompartmentChunkSearchPool2,
26
24
  warmCompartmentChunkSearchPool2
27
- } from "./index-qcz1fy7h.js";
25
+ } from "./index-hexdee98.js";
28
26
  import {
29
27
  saveCommitEmbedding,
30
28
  loadProjectCommitEmbeddings,
@@ -40,7 +38,7 @@ import {
40
38
  enqueueShadowEmbeddingItems2,
41
39
  getProjectEmbeddingSnapshot2,
42
40
  embedItemsForProject2
43
- } from "./index-s79g172v.js";
41
+ } from "./index-bamnjp2t.js";
44
42
  import {
45
43
  recordEmbeddingMeasurement
46
44
  } from "./index-2amn2s73.js";
@@ -52,7 +50,7 @@ import {
52
50
  isEmbeddingEnabled,
53
51
  embedText,
54
52
  ensureMemoryEmbeddings2
55
- } from "./index-d4qw2h43.js";
53
+ } from "./index-8d7gkgjs.js";
56
54
  import {
57
55
  ModuleMemoryAuthorityError2,
58
56
  getMemoriesByProject2,
@@ -65,36 +63,36 @@ import {
65
63
  sanitizeFtsQuery,
66
64
  searchMemoriesFTS,
67
65
  searchMemoriesFTSUnion
68
- } from "./index-sd2s4t4p.js";
66
+ } from "./index-cwj6qhmf.js";
69
67
  import {
70
68
  matchedSearchSnippet,
71
69
  getIndexedMessageCorpusSize
72
- } from "./index-fgft4qjn.js";
70
+ } from "./index-hkveze74.js";
73
71
  import {
74
72
  getMessageIndexEpoch,
75
73
  isMessageIndexSearchable,
76
74
  withMemoryHintContent,
77
75
  autoSearchRelevance,
78
76
  recordAutoSearchLane
79
- } from "./index-cgsmttyj.js";
77
+ } from "./index-s131svmx.js";
80
78
  import {
81
79
  MESSAGE_FTS_SESSION_FILTER_SQL,
82
80
  withMessageFtsSessionFilter
83
81
  } from "./index-kaqs6h31.js";
84
82
  import {
85
83
  isRecord
86
- } from "./index-4wpfbzks.js";
84
+ } from "./index-bkg4hdyh.js";
87
85
  import {
88
86
  resolveWorkspaceShareCategories,
89
87
  resolveWorkspaceIdentitySet,
90
88
  expandWorkspaceIdentitySetWithAliases,
91
89
  resolveStoredPathWorkspaceIdentity,
92
90
  sourceNameForMemory
93
- } from "./index-nj360hcs.js";
91
+ } from "./index-pb8ysnq2.js";
94
92
  import {
95
93
  getNotes,
96
94
  getActivePrimers
97
- } from "./index-2qbtqg1w.js";
95
+ } from "./index-25tm250q.js";
98
96
  import {
99
97
  isKnownAutocommit
100
98
  } from "./index-8ajstryz.js";
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  getHarness2
3
3
  } from "./index-pavzsdc6.js";
4
- import {
5
- getMagicContextLogPath
6
- } from "./index-g2q4htwp.js";
7
4
  import {
8
5
  sanitizeDiagnosticText,
9
6
  sanitizeConfigValue
@@ -11,8 +8,152 @@ import {
11
8
 
12
9
  // src/shared/logger.ts
13
10
  import * as fs from "node:fs";
11
+ import * as path2 from "node:path";
12
+
13
+ // src/shared/data-path.ts
14
+ import {
15
+ existsSync,
16
+ lstatSync,
17
+ mkdirSync,
18
+ readFileSync,
19
+ readlinkSync,
20
+ realpathSync,
21
+ unlinkSync,
22
+ writeFileSync
23
+ } from "node:fs";
24
+ import * as os from "node:os";
14
25
  import * as path from "node:path";
15
26
 
27
+ // src/shared/test-temp-dir.ts
28
+ var STALE_TEMP_DIR_AGE_MS = 60 * 60 * 1000;
29
+ var registeredTempDirs = new Set;
30
+
31
+ // src/shared/data-path.ts
32
+ function getDataDir() {
33
+ return process.env.XDG_DATA_HOME ?? path.join(os.homedir(), ".local", "share");
34
+ }
35
+ function getMagicContextTempDir(harness = getHarness2()) {
36
+ return path.join(os.tmpdir(), harness, "magic-context");
37
+ }
38
+ function getMagicContextLogPath(harness = getHarness2()) {
39
+ const envPath = process.env.MAGIC_CONTEXT_LOG_PATH?.trim();
40
+ if (envPath)
41
+ return envPath;
42
+ return path.join(getMagicContextTempDir(harness), "magic-context.log");
43
+ }
44
+ function getProjectMagicContextDir(directory) {
45
+ return path.join(directory, ".cortexkit", "magic-context");
46
+ }
47
+ function ensureCortexKitArtifactGitignore(directory) {
48
+ try {
49
+ const artifactDir = getProjectMagicContextDir(directory);
50
+ const gitignorePath = path.join(artifactDir, ".gitignore");
51
+ mkdirSync(artifactDir, { recursive: true });
52
+ if (!existsSync(gitignorePath) || readFileSync(gitignorePath, "utf8") !== `*
53
+ `) {
54
+ writeFileSync(gitignorePath, `*
55
+ `, "utf8");
56
+ }
57
+ const sharedPath = path.join(directory, ".cortexkit", ".gitignore");
58
+ if (!existsSync(sharedPath))
59
+ return;
60
+ const existing = readFileSync(sharedPath).toString("latin1");
61
+ const next = existing.replace(/^# >>> cortexkit:magic-context\r?\n(?:(?!^# (?:>>>|<<<) cortexkit:)[\s\S])*?^# <<< cortexkit:magic-context(?:\r?\n|$)/gm, "");
62
+ if (next === existing)
63
+ return;
64
+ const remaining = Buffer.from(next, "latin1");
65
+ if (remaining.toString("utf8").trim() === "")
66
+ unlinkSync(sharedPath);
67
+ else
68
+ writeFileSync(sharedPath, remaining);
69
+ } catch (error) {
70
+ log2("Failed to ensure project artifact gitignore", { directory, error: String(error) });
71
+ }
72
+ }
73
+ function getProjectMagicContextHistorianDir(directory) {
74
+ return path.join(getProjectMagicContextDir(directory), "historian");
75
+ }
76
+ function getOpenCodeStorageDir() {
77
+ return path.join(getDataDir(), "opencode", "storage");
78
+ }
79
+ function getMagicContextStorageResolution() {
80
+ const testDataDir = process.env.MAGIC_CONTEXT_TEST_DATA_DIR?.trim();
81
+ if (testDataDir) {
82
+ const perTestDataHome = process.env.XDG_DATA_HOME?.trim();
83
+ if (perTestDataHome && path.resolve(perTestDataHome) !== path.resolve(testDataDir)) {
84
+ return {
85
+ path: path.join(perTestDataHome, "cortexkit", "magic-context"),
86
+ source: "test isolation"
87
+ };
88
+ }
89
+ return {
90
+ path: path.join(testDataDir, "cortexkit", "magic-context"),
91
+ source: "test isolation"
92
+ };
93
+ }
94
+ if (false) {}
95
+ const explicitStorageDir = process.env.MAGIC_CONTEXT_STORAGE_DIR?.trim();
96
+ if (explicitStorageDir) {
97
+ if (!path.isAbsolute(explicitStorageDir)) {
98
+ throw new Error("MAGIC_CONTEXT_STORAGE_DIR must be an absolute path");
99
+ }
100
+ return { path: explicitStorageDir, source: "environment override" };
101
+ }
102
+ const xdgDataHome = process.env.XDG_DATA_HOME?.trim();
103
+ if (xdgDataHome) {
104
+ return {
105
+ path: path.join(xdgDataHome, "cortexkit", "magic-context"),
106
+ source: "XDG_DATA_HOME"
107
+ };
108
+ }
109
+ return {
110
+ path: path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context"),
111
+ source: "platform default"
112
+ };
113
+ }
114
+ function getMagicContextStorageDir() {
115
+ return getMagicContextStorageResolution().path;
116
+ }
117
+ function canonicalizeStoragePath(value, seen = new Set) {
118
+ const absolute = path.resolve(value);
119
+ if (seen.has(absolute))
120
+ return absolute;
121
+ seen.add(absolute);
122
+ try {
123
+ return realpathSync.native(absolute);
124
+ } catch {
125
+ try {
126
+ if (lstatSync(absolute).isSymbolicLink()) {
127
+ const target = readlinkSync(absolute);
128
+ const resolvedTarget = path.isAbsolute(target) ? target : path.resolve(path.dirname(absolute), target);
129
+ return canonicalizeStoragePath(resolvedTarget, seen);
130
+ }
131
+ } catch {}
132
+ const parent = path.dirname(absolute);
133
+ if (parent === absolute)
134
+ return absolute;
135
+ const resolvedParent = canonicalizeStoragePath(parent, seen);
136
+ return path.resolve(resolvedParent, path.basename(absolute));
137
+ }
138
+ }
139
+ function isMagicContextStorageOutsideEngram(storageDir = getMagicContextStorageDir(), backupDir = path.join(os.homedir(), ".local", "share", "cortexkit", "magic-context")) {
140
+ const resolvedStorageDir = canonicalizeStoragePath(storageDir);
141
+ const resolvedBackupDir = canonicalizeStoragePath(backupDir);
142
+ const relative2 = path.relative(resolvedBackupDir, resolvedStorageDir);
143
+ return path.isAbsolute(relative2) || relative2 === ".." || relative2.startsWith(`..${path.sep}`);
144
+ }
145
+ var STORAGE_BACKUP_WARNING_CHECKED = Symbol.for("magic-context.storage-backup-warning-checked");
146
+ function claimStorageBackupWarningCheck() {
147
+ const processState = globalThis;
148
+ if (processState[STORAGE_BACKUP_WARNING_CHECKED])
149
+ return false;
150
+ processState[STORAGE_BACKUP_WARNING_CHECKED] = true;
151
+ return true;
152
+ }
153
+ function getLegacyOpenCodeMagicContextStorageDir() {
154
+ return path.join(getOpenCodeStorageDir(), "plugin", "magic-context");
155
+ }
156
+
16
157
  // src/shared/stale-plugin-build.ts
17
158
  import { posix } from "node:path";
18
159
  import { fileURLToPath } from "node:url";
@@ -161,7 +302,7 @@ function recordSwallowedWrite(error) {
161
302
  } catch {}
162
303
  }
163
304
  function ensureDir(filePath) {
164
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
305
+ fs.mkdirSync(path2.dirname(filePath), { recursive: true });
165
306
  }
166
307
  function isMissingFile(error) {
167
308
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
@@ -341,4 +482,4 @@ if (!isTestEnv) {
341
482
  process.on("exit", flush);
342
483
  }
343
484
 
344
- export { registerStalePluginBuildHost, classifyStalePluginBuild, importPluginModule, setLogLineForwarder2, writeForwardedLogLine2, log2, sessionLog2, getLoggerDiagnostics2, flushLogger2, getLogFilePath2 };
485
+ export { getDataDir, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getOpenCodeStorageDir, getMagicContextStorageResolution, getMagicContextStorageDir, isMagicContextStorageOutsideEngram, claimStorageBackupWarningCheck, getLegacyOpenCodeMagicContextStorageDir, registerStalePluginBuildHost, classifyStalePluginBuild, importPluginModule, setLogLineForwarder2, writeForwardedLogLine2, log2, sessionLog2, getLoggerDiagnostics2, flushLogger2, getLogFilePath2 };
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  DEFAULT_LOCAL_EMBEDDING_MODEL
3
- } from "./index-4dpvnp8k.js";
3
+ } from "./index-jjy5a5w0.js";
4
4
  import {
5
5
  log2
6
- } from "./index-jrfre9ah.js";
6
+ } from "./index-82dfe8en.js";
7
7
  import {
8
8
  isSynapseEmbeddingTruncated,
9
9
  SynapseEmbeddingProvider
10
- } from "./index-dj2p8653.js";
10
+ } from "./index-hsyczpn7.js";
11
11
  import {
12
12
  LocalEmbeddingProvider
13
- } from "./index-hkh8x221.js";
13
+ } from "./index-rbs27k1d.js";
14
14
  import {
15
15
  OpenAICompatibleEmbeddingProvider,
16
16
  getProjectEmbeddingSnapshot2,
17
17
  embedBatchForProject2
18
- } from "./index-s79g172v.js";
18
+ } from "./index-bamnjp2t.js";
19
19
  import {
20
20
  isEmbeddingHostBusy2
21
21
  } from "./index-qt1qqasc.js";
@@ -62,6 +62,7 @@ function createProvider(config) {
62
62
  queryInstruction: config.query_instruction,
63
63
  documentPrefix: config.document_prefix,
64
64
  truncate: config.truncate,
65
+ dimensions: config.dimensions,
65
66
  maxInputTokens: config.max_input_tokens
66
67
  });
67
68
  }
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-v0p37hm2.js";
4
4
  import {
5
5
  log2
6
- } from "./index-jrfre9ah.js";
6
+ } from "./index-82dfe8en.js";
7
7
  import {
8
8
  inRootAsyncContext2,
9
9
  getSqliteDatabasePath2
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./index-jrfre9ah.js";
3
+ } from "./index-82dfe8en.js";
4
4
  import {
5
5
  clearEmergencyRecovery
6
- } from "./index-rvmhyk89.js";
6
+ } from "./index-07rp6xcn.js";
7
7
  import {
8
8
  requestPendingMaterialization,
9
9
  dropSlot
10
- } from "./index-ta87fpfs.js";
10
+ } from "./index-n0twfvah.js";
11
11
  import {
12
12
  executeContextRecomp
13
- } from "./index-zetm0ayn.js";
13
+ } from "./index-h8g08nxs.js";
14
14
  import {
15
15
  renderUserFacingFailure,
16
16
  userFacingFailureCode
17
- } from "./index-sd2s4t4p.js";
17
+ } from "./index-cwj6qhmf.js";
18
18
 
19
19
  // src/hooks/magic-context/recomp-orchestrator.ts
20
20
  function resolveLiveModelKey(liveSessionState, sessionId) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sessionLog2
3
- } from "./index-jrfre9ah.js";
3
+ } from "./index-82dfe8en.js";
4
4
  import {
5
5
  isKnownAutocommit
6
6
  } from "./index-8ajstryz.js";
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  estimateTokens
3
- } from "./index-ak11t3gm.js";
3
+ } from "./index-0tz2fzpq.js";
4
4
  import {
5
5
  getHarness2
6
6
  } from "./index-pavzsdc6.js";
7
+ import {
8
+ log2
9
+ } from "./index-82dfe8en.js";
7
10
  import {
8
11
  sanitizeDiagnosticText
9
12
  } from "./index-z4p0ry94.js";
10
- import {
11
- log2
12
- } from "./index-jrfre9ah.js";
13
13
  import {
14
14
  SYNAPSE_DEFAULT_MODEL,
15
15
  isSynapseEmbeddingTruncated,
16
16
  getSynapseBatchRequestKey,
17
17
  SynapseEmbeddingProvider
18
- } from "./index-dj2p8653.js";
18
+ } from "./index-hsyczpn7.js";
19
19
  import {
20
20
  inRootAsyncContext2,
21
21
  getSqliteDatabasePath2
@@ -43,10 +43,10 @@ import {
43
43
  countSessionCompartmentEmbedCoverage2,
44
44
  countSessionCompartmentEmbedCoveragePolite2,
45
45
  countUnembeddedSessionCompartmentsPolite2
46
- } from "./index-qcz1fy7h.js";
46
+ } from "./index-hexdee98.js";
47
47
  import {
48
48
  DEFAULT_LOCAL_EMBEDDING_MODEL
49
- } from "./index-4dpvnp8k.js";
49
+ } from "./index-jjy5a5w0.js";
50
50
  import {
51
51
  embeddingModelsMatch,
52
52
  resolveEmbeddingTextPrefixes,
@@ -56,7 +56,7 @@ import {
56
56
  getEmbeddingProviderIdentity,
57
57
  dominantEmbeddingFailure,
58
58
  LocalEmbeddingProvider
59
- } from "./index-hkh8x221.js";
59
+ } from "./index-rbs27k1d.js";
60
60
  import {
61
61
  embedPauseBySession,
62
62
  activeEmbeddingSessions,
@@ -67,7 +67,7 @@ import {
67
67
  } from "./index-2amn2s73.js";
68
68
  import {
69
69
  setBootQuietPeriodForTests
70
- } from "./index-txs8tce6.js";
70
+ } from "./index-0k283v27.js";
71
71
  import {
72
72
  isEmbeddingHostBusy2
73
73
  } from "./index-qt1qqasc.js";
@@ -78,7 +78,7 @@ import {
78
78
  acquireGitSweepLease,
79
79
  renewGitSweepLease,
80
80
  releaseGitSweepLease
81
- } from "./index-jz5bk7xd.js";
81
+ } from "./index-qperbvjn.js";
82
82
  import {
83
83
  saveEmbeddingIfHashMatches,
84
84
  getMemoryEmbedCoverage,
@@ -89,7 +89,7 @@ import {
89
89
  } from "./index-8ajstryz.js";
90
90
  import {
91
91
  logSlowWriteTransaction
92
- } from "./index-fxbk7gk3.js";
92
+ } from "./index-tad3can2.js";
93
93
 
94
94
  // src/features/magic-context/memory/embedding-openai.ts
95
95
  import { createHash } from "node:crypto";
@@ -284,6 +284,7 @@ class OpenAICompatibleEmbeddingProvider {
284
284
  queryPrefix;
285
285
  documentPrefix;
286
286
  truncate;
287
+ dimensions;
287
288
  initialized = false;
288
289
  failureTimes = [];
289
290
  circuitOpenUntil = 0;
@@ -303,6 +304,7 @@ class OpenAICompatibleEmbeddingProvider {
303
304
  this.queryPrefix = prefixes.queryPrefix;
304
305
  this.documentPrefix = prefixes.documentPrefix;
305
306
  this.truncate = options.truncate?.trim() ?? "";
307
+ this.dimensions = typeof options.dimensions === "number" && Number.isInteger(options.dimensions) && options.dimensions > 0 ? options.dimensions : undefined;
306
308
  this.rateLimitKey = rateLimitStateKey(this.endpoint, this.apiKey);
307
309
  const maxInputTokensSet = typeof options.maxInputTokens === "number" && Number.isFinite(options.maxInputTokens);
308
310
  this.maxInputTokens = maxInputTokensSet ? Math.max(1, Math.floor(options.maxInputTokens)) : DEFAULT_COMPARTMENT_CHUNK_MAX_INPUT_TOKENS2;
@@ -320,7 +322,8 @@ class OpenAICompatibleEmbeddingProvider {
320
322
  ...this.apiKey ? { api_key: this.apiKey } : {},
321
323
  ...this.inputType ? { input_type: this.inputType } : {},
322
324
  ...options.documentPrefix !== undefined ? { document_prefix: options.documentPrefix } : {},
323
- ...this.truncate ? { truncate: this.truncate } : {}
325
+ ...this.truncate ? { truncate: this.truncate } : {},
326
+ ...this.dimensions ? { dimensions: this.dimensions } : {}
324
327
  });
325
328
  }
326
329
  async initialize() {
@@ -426,7 +429,8 @@ class OpenAICompatibleEmbeddingProvider {
426
429
  model: this.model,
427
430
  input: requestTexts,
428
431
  ...inputTypeForRequest ? { input_type: inputTypeForRequest } : {},
429
- ...this.truncate ? { truncate: this.truncate } : {}
432
+ ...this.truncate ? { truncate: this.truncate } : {},
433
+ ...this.dimensions ? { dimensions: this.dimensions } : {}
430
434
  }),
431
435
  redirect: "error",
432
436
  signal: internalController.signal
@@ -499,6 +503,16 @@ class OpenAICompatibleEmbeddingProvider {
499
503
  results[slot] = Float32Array.from(embedding);
500
504
  }
501
505
  });
506
+ if (this.dimensions !== undefined) {
507
+ const requested = this.dimensions;
508
+ const returned = results.find((r) => r !== null && r.length !== requested)?.length;
509
+ if (returned !== undefined) {
510
+ const failure = this.failure("invalid_envelope", `requested dimensions=${requested} but endpoint returned ${returned}-dim vectors; the endpoint may not support the dimensions parameter for this model`, false);
511
+ log2(`[magic-context] openai-compatible embedding request failed: ${failure.reason}`);
512
+ this.recordFailure(requestStartedAt, isProbe, failure);
513
+ return Array.from({ length: texts.length }, () => null);
514
+ }
515
+ }
502
516
  if (results.every((r) => r === null)) {
503
517
  const failure = this.failure("invalid_envelope", `response had keys [${responseKeys.join(", ")}] but data[].embedding was absent`, false);
504
518
  log2(`[magic-context] openai-compatible embedding request failed: ${failure.reason}`);
@@ -1256,6 +1270,7 @@ function resolveEmbeddingConfig(config) {
1256
1270
  ...config.query_instruction !== undefined ? { query_instruction: config.query_instruction } : {},
1257
1271
  ...config.document_prefix !== undefined ? { document_prefix: config.document_prefix } : {},
1258
1272
  ...truncate ? { truncate } : {},
1273
+ ...config.dimensions ? { dimensions: config.dimensions } : {},
1259
1274
  ...config.max_input_tokens ? {
1260
1275
  max_input_tokens: normalizeCompartmentChunkMaxInputTokens2(config.max_input_tokens)
1261
1276
  } : {}
@@ -1305,6 +1320,7 @@ function createProvider(config, context) {
1305
1320
  queryInstruction: config.query_instruction,
1306
1321
  documentPrefix: config.document_prefix,
1307
1322
  truncate: config.truncate,
1323
+ dimensions: config.dimensions,
1308
1324
  maxInputTokens: config.max_input_tokens
1309
1325
  });
1310
1326
  }
@@ -4,13 +4,13 @@ import {
4
4
  } from "./index-1zx87sdm.js";
5
5
  import {
6
6
  estimateTokens
7
- } from "./index-ak11t3gm.js";
7
+ } from "./index-0tz2fzpq.js";
8
8
  import {
9
9
  getHarness2
10
10
  } from "./index-pavzsdc6.js";
11
11
  import {
12
12
  sessionLog2
13
- } from "./index-jrfre9ah.js";
13
+ } from "./index-82dfe8en.js";
14
14
  import {
15
15
  getTagIdentityWriteGeneration2,
16
16
  getSqliteDatabasePath2
@@ -20,7 +20,7 @@ import {
20
20
  tagOrderConstraintIndex,
21
21
  stableStringify,
22
22
  stableStringifyHash
23
- } from "./index-9wnbnx8f.js";
23
+ } from "./index-a6aqpfp6.js";
24
24
  import {
25
25
  DEFAULT_PROTECTED_TOOLS,
26
26
  normalizeProtectedToolName,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getMagicContextStorageDir
3
- } from "./index-g2q4htwp.js";
3
+ } from "./index-82dfe8en.js";
4
4
  import {
5
5
  ensureStorageDirectorySync,
6
6
  writeStorageFileAtomicSync
@@ -139,9 +139,9 @@ async function serveV2ArchiveReads2(port, openConnections) {
139
139
  import("./sqlite-zdgm52sv.js"),
140
140
  import("./store-reader-3eh1s1m8.js"),
141
141
  import("./store-h20ny8b8.js"),
142
- import("./read-session-chunk-7fmg9p5m.js"),
143
- import("./render-mnqc74ar.js"),
144
- import("./search-archive-df09r8qn.js"),
142
+ import("./read-session-chunk-6712p893.js"),
143
+ import("./render-dtc4qkq4.js"),
144
+ import("./search-archive-f6hjbnsa.js"),
145
145
  import("./expand-attachments-h33jbgyz.js")
146
146
  ]);
147
147
  const pool = new V2StoreReaderPool;
@@ -7,10 +7,10 @@ import {
7
7
  } from "./index-fr0wbhdn.js";
8
8
  import {
9
9
  sessionLog2
10
- } from "./index-jrfre9ah.js";
10
+ } from "./index-82dfe8en.js";
11
11
  import {
12
12
  embedTextForProject2
13
- } from "./index-s79g172v.js";
13
+ } from "./index-bamnjp2t.js";
14
14
  import {
15
15
  saveEmbeddingIfHashMatches
16
16
  } from "./index-4dhv7mqz.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-pavzsdc6.js";
5
5
  import {
6
6
  log2
7
- } from "./index-jrfre9ah.js";
7
+ } from "./index-82dfe8en.js";
8
8
  import {
9
9
  resolveOpenCodeDbPath,
10
10
  assertOpenCodeStoreGeneration,
@@ -19,7 +19,7 @@ import {
19
19
  import {
20
20
  forgetRawSessionOrdinalWatermark2,
21
21
  forgetRawSessionSummaryRows2
22
- } from "./index-xa9mmq6c.js";
22
+ } from "./index-36wseasx.js";
23
23
  import {
24
24
  closeQuietly
25
25
  } from "./index-8ajstryz.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-jrfre9ah.js";
3
+ } from "./index-82dfe8en.js";
4
4
  import {
5
5
  canonicalProjectDirectory
6
6
  } from "./index-knvkbfvh.js";
@@ -2,12 +2,10 @@ import {
2
2
  getHarness2
3
3
  } from "./index-pavzsdc6.js";
4
4
  import {
5
- getMagicContextStorageDir
6
- } from "./index-g2q4htwp.js";
7
- import {
5
+ getMagicContextStorageDir,
8
6
  log2,
9
7
  sessionLog2
10
- } from "./index-jrfre9ah.js";
8
+ } from "./index-82dfe8en.js";
11
9
  import {
12
10
  localBudget,
13
11
  calibrationForModelKey
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  log2
3
- } from "./index-jrfre9ah.js";
3
+ } from "./index-82dfe8en.js";
4
4
 
5
5
  // src/shared/safe-notification-target.ts
6
6
  var DEFAULT_TITLE_RE = /^(New session - |Child session - )\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;