@cortexkit/opencode-magic-context 0.48.0 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/dist/{announcement-fp14dw0n.js → announcement-hdbkt8v5.js} +1 -1
  2. package/dist/auto-search-worker.js +3 -3
  3. package/dist/config/{mural-model-deprecation.d.ts → deprecated-config.d.ts} +4 -1
  4. package/dist/config/deprecated-config.d.ts.map +1 -0
  5. package/dist/config/index.d.ts.map +1 -1
  6. package/dist/config/project-security.d.ts +2 -2
  7. package/dist/config/schema/magic-context.d.ts +4 -4
  8. package/dist/config/schema/magic-context.d.ts.map +1 -1
  9. package/dist/{conflict-warning-hook-w8cykrnf.js → conflict-warning-hook-asnt6hfc.js} +7 -7
  10. package/dist/{context-m0cy262m.js → context-tfyhtdcs.js} +187 -68
  11. package/dist/{derive-budgets-sg0xsq7s.js → derive-budgets-j4ry8j8n.js} +2 -2
  12. package/dist/embedding-backfill-wyc3ykyf.js +21 -0
  13. package/dist/embedding-worker-process.js +30 -0
  14. package/dist/embedding-worker.js +6 -6
  15. package/dist/features/magic-context/dreamer/task-registry.d.ts +2 -3
  16. package/dist/features/magic-context/dreamer/task-registry.d.ts.map +1 -1
  17. package/dist/features/magic-context/git-commits/search-git-commits.d.ts +2 -0
  18. package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -1
  19. package/dist/features/magic-context/memory/embedding-worker-client.d.ts +8 -1
  20. package/dist/features/magic-context/memory/embedding-worker-client.d.ts.map +1 -1
  21. package/dist/features/magic-context/memory/embedding-worker-process.d.ts +2 -0
  22. package/dist/features/magic-context/memory/embedding-worker-process.d.ts.map +1 -0
  23. package/dist/features/magic-context/memory/onnx-telemetry.d.ts +3 -0
  24. package/dist/features/magic-context/memory/onnx-telemetry.d.ts.map +1 -0
  25. package/dist/features/magic-context/message-index.d.ts.map +1 -1
  26. package/dist/features/magic-context/overflow-detection.d.ts +1 -2
  27. package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
  28. package/dist/features/magic-context/pi-content-decisions.d.ts +1 -1
  29. package/dist/features/magic-context/pi-content-decisions.d.ts.map +1 -1
  30. package/dist/features/magic-context/search-rerank.d.ts +35 -0
  31. package/dist/features/magic-context/search-rerank.d.ts.map +1 -0
  32. package/dist/features/magic-context/search.d.ts +11 -0
  33. package/dist/features/magic-context/search.d.ts.map +1 -1
  34. package/dist/features/magic-context/storage-meta-persisted.d.ts +13 -2
  35. package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
  36. package/dist/features/magic-context/storage-meta-session.d.ts +1 -1
  37. package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
  38. package/dist/features/magic-context/storage-meta.d.ts +1 -1
  39. package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
  40. package/dist/features/magic-context/storage-session-tables.d.ts +2 -0
  41. package/dist/features/magic-context/storage-session-tables.d.ts.map +1 -1
  42. package/dist/features/magic-context/storage-tag-identity-revision.d.ts +29 -9
  43. package/dist/features/magic-context/storage-tag-identity-revision.d.ts.map +1 -1
  44. package/dist/features/magic-context/storage-tags.d.ts +9 -0
  45. package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
  46. package/dist/features/magic-context/storage.d.ts +1 -1
  47. package/dist/features/magic-context/storage.d.ts.map +1 -1
  48. package/dist/features/magic-context/tagger.d.ts +2 -0
  49. package/dist/features/magic-context/tagger.d.ts.map +1 -1
  50. package/dist/features/magic-context/transform-decision-log.d.ts +4 -1
  51. package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
  52. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts +1 -0
  53. package/dist/features/magic-context/user-memory/storage-user-memory.d.ts.map +1 -1
  54. package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
  55. package/dist/hooks/magic-context/auto-search-replay.fixture.d.ts +24 -0
  56. package/dist/hooks/magic-context/auto-search-replay.fixture.d.ts.map +1 -0
  57. package/dist/hooks/magic-context/auto-search-runner.d.ts +1 -1
  58. package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
  59. package/dist/hooks/magic-context/auto-search-worker-client.d.ts +2 -0
  60. package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -1
  61. package/dist/hooks/magic-context/command-handler.d.ts +2 -0
  62. package/dist/hooks/magic-context/command-handler.d.ts.map +1 -1
  63. package/dist/hooks/magic-context/emergency-fail-closed.d.ts +28 -0
  64. package/dist/hooks/magic-context/emergency-fail-closed.d.ts.map +1 -1
  65. package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
  66. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +1 -0
  67. package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
  68. package/dist/hooks/magic-context/historian-host-runner.d.ts +8 -0
  69. package/dist/hooks/magic-context/historian-host-runner.d.ts.map +1 -1
  70. package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
  71. package/dist/hooks/magic-context/hook.d.ts +3 -1
  72. package/dist/hooks/magic-context/hook.d.ts.map +1 -1
  73. package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
  74. package/dist/hooks/magic-context/latest-thinking-recovery.d.ts +7 -0
  75. package/dist/hooks/magic-context/latest-thinking-recovery.d.ts.map +1 -1
  76. package/dist/hooks/magic-context/lkg-measured-request.d.ts +3 -1
  77. package/dist/hooks/magic-context/lkg-measured-request.d.ts.map +1 -1
  78. package/dist/hooks/magic-context/lkg-persist.d.ts +8 -14
  79. package/dist/hooks/magic-context/lkg-persist.d.ts.map +1 -1
  80. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts +62 -0
  81. package/dist/hooks/magic-context/lkg-recovery-fence.d.ts.map +1 -0
  82. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts +38 -0
  83. package/dist/hooks/magic-context/lkg-recovery-prefix.d.ts.map +1 -0
  84. package/dist/hooks/magic-context/lkg-replay.d.ts +3 -1
  85. package/dist/hooks/magic-context/lkg-replay.d.ts.map +1 -1
  86. package/dist/hooks/magic-context/lkg-slot.d.ts.map +1 -1
  87. package/dist/hooks/magic-context/opaque-thinking.d.ts +12 -0
  88. package/dist/hooks/magic-context/opaque-thinking.d.ts.map +1 -0
  89. package/dist/hooks/magic-context/pass-outcome.d.ts +3 -2
  90. package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
  91. package/dist/hooks/magic-context/pending-materialization.d.ts +8 -0
  92. package/dist/hooks/magic-context/pending-materialization.d.ts.map +1 -0
  93. package/dist/hooks/magic-context/read-session-chunk.d.ts +7 -1
  94. package/dist/hooks/magic-context/read-session-chunk.d.ts.map +1 -1
  95. package/dist/hooks/magic-context/read-session-db.d.ts +3 -0
  96. package/dist/hooks/magic-context/read-session-db.d.ts.map +1 -1
  97. package/dist/hooks/magic-context/read-session-raw.d.ts +35 -0
  98. package/dist/hooks/magic-context/read-session-raw.d.ts.map +1 -1
  99. package/dist/hooks/magic-context/recomp-orchestrator.d.ts.map +1 -1
  100. package/dist/hooks/magic-context/rust-mode-transform.d.ts +37 -0
  101. package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
  102. package/dist/hooks/magic-context/shared-compartment-boundaries.d.ts +8 -1
  103. package/dist/hooks/magic-context/shared-compartment-boundaries.d.ts.map +1 -1
  104. package/dist/hooks/magic-context/strict-thinking-prefix.d.ts +8 -0
  105. package/dist/hooks/magic-context/strict-thinking-prefix.d.ts.map +1 -0
  106. package/dist/hooks/magic-context/strip-content.d.ts +5 -2
  107. package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
  108. package/dist/hooks/magic-context/system-date-refresh.d.ts +29 -0
  109. package/dist/hooks/magic-context/system-date-refresh.d.ts.map +1 -0
  110. package/dist/hooks/magic-context/system-prompt-dates.d.ts +6 -0
  111. package/dist/hooks/magic-context/system-prompt-dates.d.ts.map +1 -0
  112. package/dist/hooks/magic-context/system-prompt-delivery.d.ts +47 -0
  113. package/dist/hooks/magic-context/system-prompt-delivery.d.ts.map +1 -0
  114. package/dist/hooks/magic-context/system-prompt-hash.d.ts +4 -0
  115. package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
  116. package/dist/hooks/magic-context/tag-messages.d.ts +8 -0
  117. package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
  118. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +15 -0
  119. package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
  120. package/dist/hooks/magic-context/transform.d.ts +7 -0
  121. package/dist/hooks/magic-context/transform.d.ts.map +1 -1
  122. package/dist/{index-ty64eqcn.js → index-0pjvpfkf.js} +24 -4
  123. package/dist/{index-db7zwa3v.js → index-1bt88epp.js} +93 -9
  124. package/dist/{index-2y0s2hep.js → index-4mjhqadz.js} +1 -1
  125. package/dist/index-6m7rdv7y.js +733 -0
  126. package/dist/{index-k1xb52kd.js → index-6tfxmc4n.js} +11 -11
  127. package/dist/{index-fbv1dn35.js → index-7w18gg78.js} +26 -2
  128. package/dist/{index-7mx8v0pw.js → index-att4bfan.js} +4 -4
  129. package/dist/{index-mmyh6d8f.js → index-eypn4ba6.js} +11 -6
  130. package/dist/{index-q2tqeqde.js → index-fdtkt5r1.js} +1229 -78
  131. package/dist/{index-c43kr12f.js → index-fg00p1cg.js} +42 -40
  132. package/dist/{v2/server-1bc61ans.js → index-fvnzcnww.js} +44 -1
  133. package/dist/index-gbmqa9x9.js +1170 -0
  134. package/dist/{index-knh4y330.js → index-gzky5rva.js} +31 -49
  135. package/dist/{index-0qhce371.js → index-h2wc01qk.js} +2 -2
  136. package/dist/{index-dhwzyd54.js → index-h5zfkjyk.js} +160 -25
  137. package/dist/{index-bhvjj0ys.js → index-k6xvbj2e.js} +255 -1075
  138. package/dist/{index-0w56v4fm.js → index-mw7c950g.js} +1 -1
  139. package/dist/{index-8j7gqj40.js → index-nsjyysj0.js} +6 -2
  140. package/dist/{index-k9nnwad5.js → index-nydv6g8r.js} +44 -7
  141. package/dist/{index-f0h6xwqm.js → index-p0n5ryq8.js} +304 -960
  142. package/dist/{index-pg50n748.js → index-p1hnwfd8.js} +4 -4
  143. package/dist/{index-1qb0z7wa.js → index-qx53vezw.js} +1 -1
  144. package/dist/{index-5zygecde.js → index-r2zcs71c.js} +8 -6
  145. package/dist/{index-cb7emxgj.js → index-rafsaxac.js} +336 -6
  146. package/dist/{index-z8e0psj8.js → index-s7fc0fkn.js} +3 -3
  147. package/dist/{index-14cjxt20.js → index-sfhndpcb.js} +505 -11
  148. package/dist/index-sv0bb7vg.js +6972 -0
  149. package/dist/{index-jcbd3znx.js → index-tqf7yg27.js} +1 -1
  150. package/dist/{index-72nhv486.js → index-vkbqdnkj.js} +2 -2
  151. package/dist/{index-pdecwzrd.js → index-w23dh319.js} +18 -259
  152. package/dist/{index-yq8n9qcb.js → index-xgrwmj82.js} +4 -4
  153. package/dist/{index-0an7742d.js → index-xnanvj3w.js} +1364 -2278
  154. package/dist/{index-eeezr5zz.js → index-z1tjp257.js} +1 -1
  155. package/dist/{index-692jzy0p.js → index-zfzdpeq2.js} +2279 -4061
  156. package/dist/{index-q7h7csab.js → index-zg8yq4ya.js} +34 -749
  157. package/dist/index.d.ts.map +1 -1
  158. package/dist/index.js +241 -76
  159. package/dist/{logger-d3wex3dz.js → logger-ewak5q1s.js} +1 -1
  160. package/dist/{message-index-bounded-7ezbgddp.js → message-index-bounded-hqktkhdy.js} +15 -14
  161. package/dist/{message-time-backfill-brbd63hv.js → message-time-backfill-8x06r9kx.js} +2 -2
  162. package/dist/migration-worker.js +11 -10
  163. package/dist/plugin/hooks/create-session-hooks.d.ts +5 -1
  164. package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
  165. package/dist/plugin/messages-transform.d.ts.map +1 -1
  166. package/dist/plugin/rpc-handlers.d.ts.map +1 -1
  167. package/dist/plugin/tool-registry.d.ts.map +1 -1
  168. package/dist/{project-embedding-registry-7qzptcw7.js → project-embedding-registry-0gv3h6y8.js} +10 -10
  169. package/dist/raw-ordinal-warmup-worker.js +4 -4
  170. package/dist/{read-session-chunk-6k83m4fj.js → read-session-chunk-5mh0bh8y.js} +12 -9
  171. package/dist/{read-session-raw-3g9qy1xa.js → read-session-raw-8sjbc9h0.js} +5 -3
  172. package/dist/{recomp-orchestrator-d3fp1cy0.js → recomp-orchestrator-kpkhkjhq.js} +28 -27
  173. package/dist/{safe-notification-target-5ffqq32m.js → safe-notification-target-q0cyrx3x.js} +2 -2
  174. package/dist/{search-epax1ecv.js → search-p9w39qv4.js} +22 -21
  175. package/dist/{send-session-notification-erecz4y4.js → send-session-notification-xffh3bbe.js} +5 -5
  176. package/dist/shared/auto-search-lifecycle.d.ts +14 -0
  177. package/dist/shared/auto-search-lifecycle.d.ts.map +1 -1
  178. package/dist/shared/logger.d.ts.map +1 -1
  179. package/dist/shared/models-dev-cache.d.ts.map +1 -1
  180. package/dist/shared/models-dev-temperature.d.ts +18 -0
  181. package/dist/shared/models-dev-temperature.d.ts.map +1 -0
  182. package/dist/shared/project-directory-key.d.ts +16 -0
  183. package/dist/shared/project-directory-key.d.ts.map +1 -1
  184. package/dist/shared/storage-file-mutex.d.ts +9 -0
  185. package/dist/shared/storage-file-mutex.d.ts.map +1 -0
  186. package/dist/shared/storage-permissions.d.ts +6 -0
  187. package/dist/shared/storage-permissions.d.ts.map +1 -1
  188. package/dist/shared/subagent-temperature.d.ts +46 -0
  189. package/dist/shared/subagent-temperature.d.ts.map +1 -0
  190. package/dist/shared/window-geometry.d.ts +9 -66
  191. package/dist/shared/window-geometry.d.ts.map +1 -1
  192. package/dist/standalone-plugin-marker.d.ts +8 -0
  193. package/dist/standalone-plugin-marker.d.ts.map +1 -0
  194. package/dist/{storage-tags-d3b0v2ss.js → storage-tags-k0pda32s.js} +6 -4
  195. package/dist/tools/ctx-reduce/constants.d.ts +1 -2
  196. package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
  197. package/dist/tools/ctx-reduce/tools.d.ts +1 -1
  198. package/dist/tools/ctx-reduce/tools.d.ts.map +1 -1
  199. package/dist/tools/ctx-search/tools.d.ts.map +1 -1
  200. package/dist/tools/ctx-search/types.d.ts +1 -0
  201. package/dist/tools/ctx-search/types.d.ts.map +1 -1
  202. package/dist/{transform-postprocess-phase-spcy2qre.js → transform-postprocess-phase-481j5a7z.js} +28 -27
  203. package/dist/v2/auto-search-worker.js +3 -3
  204. package/dist/v2/{context-sf98kstd.js → context-gsdtha5v.js} +1619 -3111
  205. package/dist/v2/{derive-budgets-3vc0y84t.js → derive-budgets-enckmg7y.js} +3 -3
  206. package/dist/v2/embedding-backfill-dbvjbcmm.js +20 -0
  207. package/dist/v2/embedding-worker-process.js +29 -0
  208. package/dist/v2/embedding-worker.js +6 -7
  209. package/dist/v2/hidden-child-native.d.ts.map +1 -1
  210. package/dist/v2/hidden-completion.d.ts +7 -0
  211. package/dist/v2/hidden-completion.d.ts.map +1 -1
  212. package/dist/v2/hooks/context.d.ts.map +1 -1
  213. package/dist/v2/hooks/copied-tag-notation.d.ts +19 -0
  214. package/dist/v2/hooks/copied-tag-notation.d.ts.map +1 -0
  215. package/dist/v2/hooks/dream-trigger.d.ts +4 -1
  216. package/dist/v2/hooks/dream-trigger.d.ts.map +1 -1
  217. package/dist/v2/hooks/generate.d.ts +9 -2
  218. package/dist/v2/hooks/generate.d.ts.map +1 -1
  219. package/dist/v2/hooks/payload.d.ts.map +1 -1
  220. package/dist/v2/hooks/system-prompt-response.d.ts +5 -0
  221. package/dist/v2/hooks/system-prompt-response.d.ts.map +1 -0
  222. package/dist/v2/{logger-mxd0ym09.js → logger-pj02s7sr.js} +1 -1
  223. package/dist/v2/{message-index-bounded-dy3s2k1e.js → message-index-bounded-p6v0n8qh.js} +15 -14
  224. package/dist/v2/{message-time-backfill-gtx1pwk1.js → message-time-backfill-cje68egj.js} +2 -2
  225. package/dist/v2/migration-worker.js +11 -10
  226. package/dist/v2/{project-embedding-registry-1tgba5dv.js → project-embedding-registry-nyq7z8y6.js} +11 -12
  227. package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
  228. package/dist/v2/{read-session-chunk-rh4khdkv.js → read-session-chunk-fhyfe4qa.js} +12 -9
  229. package/dist/v2/{read-session-raw-bsbmf0vj.js → read-session-raw-j8dvp7f4.js} +5 -3
  230. package/dist/v2/recomp-orchestrator-5xy7w136.js +57 -0
  231. package/dist/v2/{safe-notification-target-73ax1p5v.js → safe-notification-target-y3p1hce9.js} +2 -2
  232. package/dist/v2/{search-nzkwrc6n.js → search-j7bakcwa.js} +23 -23
  233. package/dist/v2/{send-session-notification-6km439kn.js → send-session-notification-f6v698r5.js} +5 -5
  234. package/dist/v2/{server-7wwc2nga.js → server-1fszbabv.js} +32 -32
  235. package/dist/v2/{server-k228xhjg.js → server-2htmbqbv.js} +26 -2
  236. package/dist/v2/{server-aan4q8mx.js → server-3t0q2cqx.js} +1 -1
  237. package/dist/v2/{server-686jg6eb.js → server-4c7jt8gq.js} +68 -7
  238. package/dist/v2/{server-xxm59eww.js → server-4enr7s6x.js} +4 -4
  239. package/dist/v2/{server-zxhgvsf9.js → server-676xw7at.js} +1 -1
  240. package/dist/v2/{server-52awr2mw.js → server-6byqfbqf.js} +93 -9
  241. package/dist/v2/{server-e0vdaae2.js → server-6tcrjfw8.js} +4 -4
  242. package/dist/v2/{server-qye6ykf7.js → server-7ekna9zs.js} +2 -2
  243. package/dist/v2/{server-g5r0n3b6.js → server-7h861yms.js} +160 -25
  244. package/dist/v2/{server-k8x2rbxc.js → server-7spkq1y6.js} +3457 -5192
  245. package/dist/v2/{server-8pyt7hev.js → server-7vkj6zhb.js} +34 -749
  246. package/dist/v2/{server-yczc713m.js → server-8xmq9h3f.js} +31 -49
  247. package/dist/v2/{server-sggvvzhb.js → server-bgzy0phk.js} +505 -11
  248. package/dist/v2/server-c7n2ftng.js +6860 -0
  249. package/dist/v2/server-cvgn49tr.js +733 -0
  250. package/dist/v2/{server-zm570tr2.js → server-cw6521wn.js} +232 -7
  251. package/dist/v2/{server-xdfwt6kh.js → server-czb2rkpk.js} +23 -3
  252. package/dist/v2/{server-x2g40a71.js → server-d6g4whc2.js} +21 -15
  253. package/dist/{index-1bc61ans.js → v2/server-fvnzcnww.js} +44 -1
  254. package/dist/v2/{server-4k748ke6.js → server-hb6xhh9q.js} +2 -2
  255. package/dist/v2/{server-gjcr4w98.js → server-kh958yj8.js} +5 -5
  256. package/dist/v2/{server-1r6pmz4f.js → server-kzns2hbz.js} +1 -1
  257. package/dist/v2/{server-psqc7e9n.js → server-mqvtz7wz.js} +1227 -78
  258. package/dist/v2/{server-vqpf3167.js → server-ras2sxnc.js} +135 -15
  259. package/dist/v2/{server-ezhze64f.js → server-s2st631p.js} +4 -4
  260. package/dist/v2/{server-5m3dt5r1.js → server-t4k4qexw.js} +6 -2
  261. package/dist/v2/{server-z2037m6z.js → server-t528t8qm.js} +2 -2
  262. package/dist/v2/{server-v06jcv0w.js → server-vb7pbd9p.js} +18 -259
  263. package/dist/v2/{server-8tqanswc.js → server-zbxjj2mz.js} +331 -4
  264. package/dist/v2/server.d.ts.map +1 -1
  265. package/dist/v2/server.js +150 -6
  266. package/dist/v2/{storage-tags-w4tv77sn.js → storage-tags-5yxrvkaf.js} +6 -4
  267. package/dist/v2/store-reader.d.ts +8 -2
  268. package/dist/v2/store-reader.d.ts.map +1 -1
  269. package/dist/v2/{wrapup-orchestrator-mz7efs7w.js → wrapup-orchestrator-yem5422s.js} +36 -36
  270. package/dist/wrapup-orchestrator-xvrr27ws.js +45 -0
  271. package/package.json +4 -4
  272. package/src/config/{mural-model-deprecation.ts → deprecated-config.ts} +19 -0
  273. package/src/config/index.test.ts +15 -37
  274. package/src/config/index.ts +2 -3
  275. package/src/config/project-security.ts +3 -3
  276. package/src/config/schema/magic-context.ts +11 -7
  277. package/src/features/magic-context/dreamer/task-registry.ts +2 -3
  278. package/src/shared/auto-search-lifecycle.ts +43 -0
  279. package/src/shared/logger.test.ts +38 -0
  280. package/src/shared/logger.ts +10 -2
  281. package/src/shared/models-dev-cache.ts +1 -7
  282. package/src/shared/models-dev-temperature.ts +107 -0
  283. package/src/shared/project-directory-key.test.ts +59 -0
  284. package/src/shared/project-directory-key.ts +20 -0
  285. package/src/shared/sqlite-640-review.test.ts +5 -1
  286. package/src/shared/storage-file-mutex-review.test.ts +162 -0
  287. package/src/shared/storage-file-mutex.ts +130 -0
  288. package/src/shared/storage-permissions.ts +46 -0
  289. package/src/shared/subagent-temperature.test.ts +270 -0
  290. package/src/shared/subagent-temperature.ts +110 -0
  291. package/src/shared/window-geometry.test.ts +102 -236
  292. package/src/shared/window-geometry.ts +23 -413
  293. package/dist/config/mural-model-deprecation.d.ts.map +0 -1
  294. package/dist/embedding-backfill-9rcm1mfy.js +0 -21
  295. package/dist/index-bdckkfw6.js +0 -3261
  296. package/dist/index-mfkzp7qj.js +0 -229
  297. package/dist/v2/embedding-backfill-vn8g1nh1.js +0 -21
  298. package/dist/v2/recomp-orchestrator-az61rfcg.js +0 -57
  299. package/dist/v2/server-2fbhp79z.js +0 -3205
  300. package/dist/v2/server-mfkzp7qj.js +0 -229
  301. package/dist/wrapup-orchestrator-amzta1t4.js +0 -44
  302. package/src/shared/__fixtures__/window-overlay.v1.json +0 -337
  303. /package/dist/{index-2pp04pmg.js → index-69vas84q.js} +0 -0
  304. /package/dist/v2/{index-2pp04pmg.js → index-69vas84q.js} +0 -0
@@ -8,7 +8,18 @@ import {
8
8
  importPluginModule,
9
9
  writeForwardedLogLine2,
10
10
  log2
11
- } from "./server-5m3dt5r1.js";
11
+ } from "./server-t4k4qexw.js";
12
+ import {
13
+ isOwnRpcServerRecord,
14
+ isPidAlive,
15
+ readProcessProbeEvidence,
16
+ classifyProcessKind,
17
+ isPidIdentityPlausible,
18
+ inspectLivePiProcesses,
19
+ parseRpcPortFile,
20
+ inspectProcessesAsync,
21
+ inspectWindowsProcessesSync
22
+ } from "./server-cvgn49tr.js";
12
23
  import {
13
24
  registerSlowWriteReporter2,
14
25
  registerSqliteDiagnosticSink2,
@@ -24,7 +35,7 @@ import {
24
35
  } from "./server-fb3zxn06.js";
25
36
  import {
26
37
  startMessageFtsRowidMapBackfill
27
- } from "./server-k228xhjg.js";
38
+ } from "./server-2htmbqbv.js";
28
39
  import {
29
40
  LKG_SLOT_CHUNKS_DDL,
30
41
  SESSION_REPLAY_DECISIONS_DDL,
@@ -34,25 +45,24 @@ import {
34
45
  hasPendingMigrations,
35
46
  getMainThreadMigrationBodyCount,
36
47
  runMigrations
37
- } from "./server-e0vdaae2.js";
48
+ } from "./server-6tcrjfw8.js";
38
49
  import {
39
50
  ensureColumn,
40
51
  installV95PerfSchema,
41
52
  installTagIdentityRevisionTrigger
42
- } from "./server-52awr2mw.js";
53
+ } from "./server-6byqfbqf.js";
43
54
  import {
44
55
  resolveOpenCodeDbPath,
45
56
  hasV1MessageTables
46
57
  } from "./server-2ra6pwf3.js";
47
58
  import {
48
- canonicalProjectDirectory,
49
59
  bootQuietRemainingMs,
50
60
  scheduleAfterBootQuiet
51
- } from "./server-yczc713m.js";
61
+ } from "./server-8xmq9h3f.js";
52
62
  import {
53
63
  setDatabase,
54
64
  loadToolDefinitionMeasurements
55
- } from "./server-qye6ykf7.js";
65
+ } from "./server-7ekna9zs.js";
56
66
  import {
57
67
  getErrorMessage
58
68
  } from "./server-y8v6yerm.js";
@@ -63,749 +73,24 @@ import {
63
73
  copyStorageFileSync,
64
74
  copyStorageTreeSync,
65
75
  tightenStorageTreeSync
66
- } from "./server-1bc61ans.js";
76
+ } from "./server-fvnzcnww.js";
67
77
  import {
68
78
  closeQuietly
69
79
  } from "./server-8ajstryz.js";
70
80
  import {
71
81
  logSlowWriteTransaction
72
- } from "./server-aan4q8mx.js";
82
+ } from "./server-3t0q2cqx.js";
73
83
 
74
84
  // src/features/magic-context/storage-db.ts
75
85
  import {
76
86
  existsSync as existsSync2,
77
87
  readdirSync,
78
- readFileSync as readFileSync2,
88
+ readFileSync,
79
89
  rmdirSync,
80
90
  statSync,
81
91
  unlinkSync
82
92
  } from "node:fs";
83
- import { basename, dirname, join as join2, resolve } from "node:path";
84
-
85
- // src/shared/rpc-utils.ts
86
- import { execFile, execFileSync } from "node:child_process";
87
- import { createHash } from "node:crypto";
88
- import { readFileSync } from "node:fs";
89
- import { join } from "node:path";
90
-
91
- // src/shared/pi-executable.ts
92
- var PI_IMAGE_NAMES = new Set(["pi", "pi.cmd", "omp", "oh-my-pi"]);
93
- function piHarnessKindFromExecutable(value) {
94
- const executable = (value ?? "").trim().replace(/^['"]|['"]$/g, "").replaceAll("\\", "/").split("/").at(-1)?.toLowerCase().replace(/\.(?:exe|cmd)$/, "");
95
- if (!executable || !PI_IMAGE_NAMES.has(executable))
96
- return;
97
- return executable === "pi" ? "pi" : "omp";
98
- }
99
-
100
- // src/shared/rpc-utils.ts
101
- var ownRpcServerInstanceIds = new Set;
102
- function registerOwnRpcServerInstance(instanceId) {
103
- ownRpcServerInstanceIds.add(instanceId);
104
- return () => {
105
- ownRpcServerInstanceIds.delete(instanceId);
106
- };
107
- }
108
- function isOwnRpcServerRecord(record) {
109
- return record.pid === process.pid && record.instance_id !== undefined && ownRpcServerInstanceIds.has(record.instance_id);
110
- }
111
- function projectHash(directory) {
112
- return createHash("sha256").update(canonicalProjectDirectory(directory)).digest("hex").slice(0, 16);
113
- }
114
- function rpcPortDir(storageDir, directory) {
115
- return join(storageDir, "rpc", projectHash(directory));
116
- }
117
- function rpcPortFilePath(storageDir, directory, pid = process.pid, instanceId) {
118
- const suffix = instanceId ? `-${instanceId}` : "";
119
- return join(rpcPortDir(storageDir, directory), `port-${pid}${suffix}.json`);
120
- }
121
- function isPidAlive(pid) {
122
- if (!Number.isInteger(pid) || pid <= 0)
123
- return "dead";
124
- if (rpcIdentityPlatform === "win32")
125
- return readWindowsProcess(pid).state;
126
- try {
127
- rpcIdentityProcessKill(pid, 0);
128
- return "alive";
129
- } catch (error) {
130
- return error.code === "ESRCH" ? "dead" : "inconclusive";
131
- }
132
- }
133
- var RPC_IDENTITY_SKEW_TOLERANCE_MS = 120000;
134
- var LINUX_CLOCK_TICKS_PER_SECOND = 100;
135
- var PS_PROBE_TIMEOUT_MS = 1000;
136
- var WINDOWS_CIM_PROBE_TIMEOUT_MS = 5000;
137
- var WINDOWS_PROCESS_SNAPSHOT_TTL_MS = 2000;
138
- var MAX_ANCESTOR_WALK_DEPTH = 16;
139
- var OPEN_CODE_COMMAND_MARKERS = ["opencode", "node", "bun", "electron"];
140
- var WINDOWS_CIM_COMMAND = "Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine,@{Name='CreationDate';Expression={if ($_.CreationDate) { $_.CreationDate.ToUniversalTime().ToString('o') } else { $null }}} | ConvertTo-Json -Compress";
141
- var PROCESS_LIST_MAX_BUFFER_BYTES = 8 * 1024 * 1024;
142
- var PI_HARNESS_ARC_MARKERS = [
143
- "pi-coding-agent",
144
- "oh-my-pi",
145
- "@oh-my-pi",
146
- "cljs/dist",
147
- "dist/bundle/cli"
148
- ];
149
- var rpcIdentityReadFileSync = readFileSync;
150
- var rpcIdentityExecFileSync = execFileSync;
151
- var rpcIdentityProcessKill = process.kill;
152
- var rpcProcessListExecFileSync = execFileSync;
153
- var rpcIdentityPlatform = process.platform;
154
- var rpcIdentityNowMs = () => Date.now();
155
- function parseLinuxProcessStartTime(statContent, uptimeContent) {
156
- const closingCommandName = statContent.lastIndexOf(")");
157
- if (closingCommandName < 0)
158
- return null;
159
- const statFields = statContent.slice(closingCommandName + 1).trim().split(/\s+/);
160
- const startTimeTicks = Number(statFields[19]);
161
- const uptimeSeconds = Number(uptimeContent.trim().split(/\s+/)[0]);
162
- if (!Number.isFinite(startTimeTicks) || startTimeTicks < 0 || !Number.isFinite(uptimeSeconds) || uptimeSeconds < 0) {
163
- return null;
164
- }
165
- const processStartTime = rpcIdentityNowMs() - uptimeSeconds * 1000 + startTimeTicks / LINUX_CLOCK_TICKS_PER_SECOND * 1000;
166
- return Number.isFinite(processStartTime) ? processStartTime : null;
167
- }
168
- function readLinuxProcessStartTime(pid) {
169
- try {
170
- const statContent = String(rpcIdentityReadFileSync(`/proc/${pid}/stat`, "utf8"));
171
- const uptimeContent = String(rpcIdentityReadFileSync("/proc/uptime", "utf8"));
172
- return parseLinuxProcessStartTime(statContent, uptimeContent);
173
- } catch {
174
- return null;
175
- }
176
- }
177
- function readPsProcessStartTime(pid) {
178
- try {
179
- const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "lstart="], {
180
- encoding: "utf8",
181
- timeout: PS_PROBE_TIMEOUT_MS,
182
- stdio: ["ignore", "pipe", "pipe"],
183
- windowsHide: true
184
- });
185
- const processStartTime = Date.parse(String(output).trim());
186
- return Number.isFinite(processStartTime) ? processStartTime : null;
187
- } catch {
188
- return null;
189
- }
190
- }
191
- function readProcessStartTime(pid) {
192
- if (!Number.isInteger(pid) || pid <= 0)
193
- return null;
194
- return rpcIdentityPlatform === "linux" ? readLinuxProcessStartTime(pid) : rpcIdentityPlatform === "win32" ? readWindowsProcessStartTime(pid) : readPsProcessStartTime(pid);
195
- }
196
- function readProcessProbeEvidence(pid) {
197
- return {
198
- startTime: readProcessStartTime(pid),
199
- commandLine: readProcessCommand(pid)
200
- };
201
- }
202
- function readCachedWindowsImageName(pid) {
203
- return rpcIdentityPlatform === "win32" ? windowsProcessFactsCache?.get(pid)?.imageName ?? null : null;
204
- }
205
- var windowsProcessFactsCache = null;
206
- var windowsProcessSnapshotCache = null;
207
- function rememberWindowsProcessFacts(facts) {
208
- windowsProcessFactsCache = new Map(facts.map((fact) => [fact.pid, fact]));
209
- }
210
- function parseCsvLine(line) {
211
- const fields = [];
212
- let field = "";
213
- let quoted = false;
214
- for (let index = 0;index < line.length; index += 1) {
215
- const character = line[index];
216
- if (character === '"') {
217
- if (quoted && line[index + 1] === '"') {
218
- field += '"';
219
- index += 1;
220
- } else {
221
- quoted = !quoted;
222
- }
223
- } else if (character === "," && !quoted) {
224
- fields.push(field);
225
- field = "";
226
- } else {
227
- field += character;
228
- }
229
- }
230
- if (quoted)
231
- return null;
232
- fields.push(field);
233
- return fields;
234
- }
235
- function parseTasklistOutput(output) {
236
- const entries = [];
237
- for (const rawLine of output.split(/\r?\n/)) {
238
- const line = rawLine.trim();
239
- if (!line)
240
- continue;
241
- const fields = parseCsvLine(line);
242
- if (!fields)
243
- continue;
244
- if (fields[1]?.trim().toLowerCase() === "pid") {
245
- continue;
246
- }
247
- const pid = Number(fields[1]);
248
- if (!Number.isInteger(pid) || pid <= 0 || !fields[0])
249
- continue;
250
- entries.push({ pid, command: fields[0] });
251
- }
252
- return entries;
253
- }
254
- function readWindowsProcess(pid) {
255
- try {
256
- const output = rpcIdentityExecFileSync("tasklist", ["/FO", "CSV", "/NH", "/FI", `PID eq ${pid}`], {
257
- encoding: "utf8",
258
- timeout: PS_PROBE_TIMEOUT_MS,
259
- stdio: ["ignore", "pipe", "pipe"],
260
- windowsHide: true
261
- });
262
- const entries = parseTasklistOutput(String(output));
263
- if (entries === null)
264
- return { state: "inconclusive" };
265
- const process2 = entries.find((entry) => entry.pid === pid);
266
- return process2 ? { state: "alive", command: process2.command } : { state: "dead" };
267
- } catch {
268
- return { state: "inconclusive" };
269
- }
270
- }
271
- function readWindowsProcessStartTime(pid) {
272
- const cached = windowsProcessFactsCache?.get(pid);
273
- if (cached)
274
- return cached.startTime;
275
- const snapshot = tryReadWindowsCimSnapshot(rpcIdentityExecFileSync);
276
- if (!snapshot)
277
- return null;
278
- rememberWindowsProcessFacts(snapshot.facts);
279
- return windowsProcessFactsCache?.get(pid)?.startTime ?? null;
280
- }
281
- function readLinuxProcessCommand(pid) {
282
- try {
283
- return String(rpcIdentityReadFileSync(`/proc/${pid}/cmdline`, "utf8"));
284
- } catch {
285
- return null;
286
- }
287
- }
288
- function readPsProcessCommand(pid) {
289
- try {
290
- const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "command="], {
291
- encoding: "utf8",
292
- timeout: PS_PROBE_TIMEOUT_MS,
293
- stdio: ["ignore", "pipe", "pipe"],
294
- windowsHide: true
295
- });
296
- return String(output);
297
- } catch {
298
- return null;
299
- }
300
- }
301
- function readProcessCommand(pid) {
302
- if (!Number.isInteger(pid) || pid <= 0)
303
- return null;
304
- if (rpcIdentityPlatform === "linux")
305
- return readLinuxProcessCommand(pid);
306
- if (rpcIdentityPlatform === "win32") {
307
- const cached = windowsProcessFactsCache?.get(pid);
308
- if (cached?.commandLine)
309
- return cached.commandLine;
310
- return readWindowsProcess(pid).command ?? null;
311
- }
312
- return readPsProcessCommand(pid);
313
- }
314
- function executableName(token) {
315
- return (token ?? "").replace(/^['"]|['"]$/g, "").split("/").at(-1) ?? "";
316
- }
317
- function commandTokens(command) {
318
- return command.toLowerCase().replaceAll("\\", "/").replaceAll("\x00", " ").split(/\s+/).map((token) => token.replace(/^['"]|['"]$/g, "")).filter(Boolean);
319
- }
320
- function commandHasOpenCodeExecutable(tokens) {
321
- return tokens.findIndex((token) => {
322
- const executable = executableName(token).replace(/\.(?:exe|cmd)$/, "");
323
- return executable === "opencode" || executable.endsWith("/opencode");
324
- });
325
- }
326
- function commandHasPiExecutable(tokens) {
327
- for (let index = 0;index < tokens.length; index += 1) {
328
- const executable = executableName(tokens[index]).replace(/\.(?:exe|cmd)$/, "");
329
- if (piHarnessKindFromExecutable(executable) !== undefined)
330
- return true;
331
- if (["node", "bun", "deno"].includes(executable)) {
332
- const script = executableName(tokens[index + 1]).replace(/\.(?:exe|cmd)$/, "");
333
- if (["pi", "pi.js", "pi.mjs", "pi.cjs"].includes(script) || tokens[index + 1]?.includes("pi-coding-agent")) {
334
- return true;
335
- }
336
- }
337
- }
338
- return false;
339
- }
340
- function classifyProcessKind(command) {
341
- if (!command)
342
- return "process";
343
- const tokens = commandTokens(command);
344
- const openCodeIndex = commandHasOpenCodeExecutable(tokens);
345
- if (openCodeIndex >= 0) {
346
- const args = tokens.slice(openCodeIndex + 1);
347
- if (args.some((token) => token === "serve" || token === "--serve" || token.startsWith("--serve="))) {
348
- return "OpenCode server";
349
- }
350
- return "OpenCode instance (TUI/CLI)";
351
- }
352
- return commandHasPiExecutable(tokens) ? "Pi" : "process";
353
- }
354
- function commandLooksLikeOpenCode(command) {
355
- const normalized = command.toLowerCase();
356
- return OPEN_CODE_COMMAND_MARKERS.some((marker) => normalized.includes(marker));
357
- }
358
- var RPC_HOST_PROCESS_MARKERS = [
359
- "opencode",
360
- "openchamber",
361
- "ck-mc",
362
- "magic-context",
363
- "cortexkit",
364
- "electron",
365
- "node",
366
- "bun",
367
- "deno",
368
- "pi-coding-agent",
369
- "oh-my-pi"
370
- ];
371
- function processCannotBeRpcHost(evidence) {
372
- const texts = [evidence.imageName, evidence.commandLine].filter((text) => typeof text === "string" && text.trim().length > 0);
373
- if (texts.length === 0)
374
- return false;
375
- for (const text of texts) {
376
- const normalized = text.toLowerCase();
377
- if (RPC_HOST_PROCESS_MARKERS.some((marker) => normalized.includes(marker)))
378
- return false;
379
- const tokens = commandTokens(text);
380
- if (commandHasPiExecutable(tokens))
381
- return false;
382
- if (tokens.some((token) => piHarnessKindFromExecutable(token) !== undefined))
383
- return false;
384
- }
385
- return true;
386
- }
387
- function isPidIdentityPlausible(record, evidence) {
388
- if (!Number.isInteger(record.pid) || record.pid <= 0)
389
- return "implausible";
390
- if (Number.isFinite(record.started_at) && record.started_at > 0) {
391
- const processStartTime = evidence ? evidence.startTime : readProcessStartTime(record.pid);
392
- if (processStartTime !== null) {
393
- return processStartTime <= record.started_at + RPC_IDENTITY_SKEW_TOLERANCE_MS ? "plausible" : "implausible";
394
- }
395
- const identity = evidence ?? {
396
- commandLine: readProcessCommand(record.pid),
397
- imageName: readCachedWindowsImageName(record.pid)
398
- };
399
- return processCannotBeRpcHost(identity) ? "implausible" : "inconclusive";
400
- }
401
- const command = evidence ? evidence.commandLine : rpcIdentityPlatform === "linux" ? readLinuxProcessCommand(record.pid) : rpcIdentityPlatform === "win32" ? readWindowsProcess(record.pid).command ?? null : readPsProcessCommand(record.pid);
402
- if (command === null)
403
- return "inconclusive";
404
- if (commandLooksLikeOpenCode(command))
405
- return "plausible";
406
- return processCannotBeRpcHost({ commandLine: command, imageName: evidence?.imageName }) ? "implausible" : "inconclusive";
407
- }
408
- function commandLooksLikePiImage(command) {
409
- const tokens = commandTokens(command);
410
- const first = executableName(tokens[0]).replace(/\.(?:exe|cmd)$/, "");
411
- return PI_IMAGE_NAMES.has(first);
412
- }
413
- function commandHasPiHarnessArc(command) {
414
- const normalized = command.trim().toLowerCase().replaceAll("\\", "/").replaceAll("\x00", " ");
415
- if (!normalized)
416
- return false;
417
- const tokens = commandTokens(command);
418
- if (tokens.length === 0)
419
- return false;
420
- const hasArc = PI_HARNESS_ARC_MARKERS.some((marker) => normalized.includes(marker));
421
- const first = executableName(tokens[0]).replace(/\.(?:exe|cmd)$/, "");
422
- if (hasArc && ["pi", "omp", "oh-my-pi", "node", "bun", "deno", "cmd"].includes(first)) {
423
- return true;
424
- }
425
- if (hasArc && PI_HARNESS_ARC_MARKERS.some((marker) => tokens[0].includes(marker))) {
426
- return true;
427
- }
428
- if (["node", "bun", "deno"].includes(first)) {
429
- const script = executableName(tokens[1]).replace(/\.(?:exe|cmd)$/, "");
430
- if (["pi", "pi.js", "pi.mjs", "pi.cjs"].includes(script))
431
- return true;
432
- if (hasArc)
433
- return true;
434
- }
435
- return false;
436
- }
437
- function execProcessList(exec, file, args, timeout = PS_PROBE_TIMEOUT_MS) {
438
- return String(exec(file, [...args], {
439
- encoding: "utf8",
440
- timeout,
441
- maxBuffer: PROCESS_LIST_MAX_BUFFER_BYTES,
442
- stdio: ["ignore", "pipe", "pipe"],
443
- windowsHide: true
444
- }));
445
- }
446
- function parseWindowsCreationDate(value) {
447
- if (value !== null && typeof value === "object" && "value" in value) {
448
- return parseWindowsCreationDate(value.value);
449
- }
450
- if (typeof value === "number" && Number.isFinite(value)) {
451
- return value > 1000000000000 ? value : value * 1000;
452
- }
453
- if (typeof value !== "string")
454
- return null;
455
- const trimmed = value.trim();
456
- if (!trimmed)
457
- return null;
458
- const wmi = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.(\d{6})([+-])(\d{3})$/.exec(trimmed);
459
- if (wmi) {
460
- const utcMs = Date.UTC(Number(wmi[1]), Number(wmi[2]) - 1, Number(wmi[3]), Number(wmi[4]), Number(wmi[5]), Number(wmi[6]), Number(wmi[7]) / 1000);
461
- if (!Number.isFinite(utcMs))
462
- return null;
463
- const offsetMinutes = Number(wmi[9]);
464
- const sign = wmi[8] === "+" ? 1 : -1;
465
- return utcMs - sign * offsetMinutes * 60000;
466
- }
467
- const dotNet = /^\/Date\((-?\d+)\)\/$/.exec(trimmed);
468
- if (dotNet) {
469
- const milliseconds = Number(dotNet[1]);
470
- return Number.isFinite(milliseconds) ? milliseconds : null;
471
- }
472
- const parsed = Date.parse(trimmed);
473
- return Number.isFinite(parsed) ? parsed : null;
474
- }
475
- function parseWindowsCimOutput(output) {
476
- const trimmed = output.trim();
477
- if (!trimmed)
478
- return null;
479
- const bracket = trimmed.indexOf("[");
480
- const brace = trimmed.indexOf("{");
481
- const start = Math.min(bracket === -1 ? Number.POSITIVE_INFINITY : bracket, brace === -1 ? Number.POSITIVE_INFINITY : brace);
482
- if (!Number.isFinite(start))
483
- return null;
484
- let parsed;
485
- try {
486
- parsed = JSON.parse(trimmed.slice(start));
487
- } catch {
488
- return null;
489
- }
490
- if (parsed == null)
491
- return null;
492
- const rows = Array.isArray(parsed) ? parsed : [parsed];
493
- const facts = [];
494
- for (const row of rows) {
495
- if (!row || typeof row !== "object")
496
- continue;
497
- const record = row;
498
- const pid = Number(record.ProcessId);
499
- if (!Number.isInteger(pid) || pid <= 0)
500
- continue;
501
- const parentRaw = record.ParentProcessId;
502
- const parentPid = parentRaw == null || parentRaw === "" ? Number.NaN : Number(parentRaw);
503
- const commandLine = typeof record.CommandLine === "string" ? record.CommandLine : null;
504
- facts.push({
505
- pid,
506
- parentPid: Number.isInteger(parentPid) && parentPid > 0 ? parentPid : null,
507
- commandLine,
508
- imageName: typeof record.Name === "string" ? record.Name : commandLine ? executableName(commandTokens(commandLine)[0]) : null,
509
- startTime: parseWindowsCreationDate(record.CreationDate)
510
- });
511
- }
512
- return facts.length > 0 ? facts : null;
513
- }
514
- function snapshotFromFacts(facts, source) {
515
- const parentByPid = new Map;
516
- for (const fact of facts) {
517
- if (fact.parentPid != null)
518
- parentByPid.set(fact.pid, fact.parentPid);
519
- }
520
- return { facts, parentByPid, source };
521
- }
522
- function tryReadWindowsCimSnapshot(exec) {
523
- try {
524
- const output = execProcessList(exec, "powershell", ["-NoProfile", "-Command", WINDOWS_CIM_COMMAND], WINDOWS_CIM_PROBE_TIMEOUT_MS);
525
- const facts = parseWindowsCimOutput(output);
526
- return facts ? snapshotFromFacts(facts, "cim") : null;
527
- } catch {
528
- return null;
529
- }
530
- }
531
- function tryReadWindowsTasklistSnapshot() {
532
- try {
533
- const output = execProcessList(rpcProcessListExecFileSync, "tasklist", [
534
- "/FO",
535
- "CSV",
536
- "/NH"
537
- ]);
538
- const entries = parseTasklistOutput(output);
539
- if (entries === null)
540
- return null;
541
- const facts = entries.map((entry) => ({
542
- pid: entry.pid,
543
- parentPid: null,
544
- commandLine: null,
545
- imageName: entry.command,
546
- startTime: null
547
- }));
548
- return snapshotFromFacts(facts, "tasklist");
549
- } catch {
550
- return null;
551
- }
552
- }
553
- function readPosixProcessSnapshot() {
554
- const output = execProcessList(rpcProcessListExecFileSync, "ps", ["-axo", "pid=,command="]);
555
- const facts = [];
556
- for (const line of output.split(/\r?\n/)) {
557
- const match = /^\s*(\d+)\s+(.+)$/.exec(line);
558
- if (!match)
559
- continue;
560
- const pid = Number(match[1]);
561
- if (!Number.isInteger(pid) || pid <= 0)
562
- continue;
563
- facts.push({
564
- pid,
565
- parentPid: null,
566
- commandLine: match[2],
567
- imageName: executableName(commandTokens(match[2])[0]),
568
- startTime: null
569
- });
570
- }
571
- return snapshotFromFacts(facts, "ps");
572
- }
573
- function readPosixParentPid(pid) {
574
- try {
575
- const output = execProcessList(rpcProcessListExecFileSync, "ps", [
576
- "-o",
577
- "ppid=",
578
- "-p",
579
- String(pid)
580
- ]);
581
- const match = /^\s*(\d+)\s*$/.exec(output);
582
- if (!match)
583
- return null;
584
- const ppid = Number(match[1]);
585
- return Number.isInteger(ppid) && ppid > 0 ? ppid : null;
586
- } catch {
587
- return null;
588
- }
589
- }
590
- function collectAncestorPids(selfPid, parentByPid, probeParents = true) {
591
- const ancestors = new Set;
592
- let current = selfPid;
593
- for (let depth = 0;depth < MAX_ANCESTOR_WALK_DEPTH; depth += 1) {
594
- let ppid = null;
595
- if (parentByPid.has(current)) {
596
- ppid = parentByPid.get(current) ?? null;
597
- } else if (rpcIdentityPlatform !== "win32" && probeParents) {
598
- ppid = readPosixParentPid(current);
599
- if (ppid == null && current === process.pid && process.ppid > 0) {
600
- ppid = process.ppid;
601
- }
602
- } else if (current === process.pid && process.ppid > 0) {
603
- ppid = process.ppid;
604
- } else {
605
- break;
606
- }
607
- if (ppid == null || ppid <= 0 || ppid === current || ancestors.has(ppid))
608
- break;
609
- ancestors.add(ppid);
610
- current = ppid;
611
- }
612
- return ancestors;
613
- }
614
- function classifyLivePiSnapshot(snapshot, probeParents = true) {
615
- const ancestors = collectAncestorPids(process.pid, snapshot.parentByPid, probeParents);
616
- const processIds = new Set;
617
- const inconclusivePids = new Set;
618
- const skippedAncestorPids = [];
619
- for (const fact of snapshot.facts) {
620
- if (fact.pid === process.pid)
621
- continue;
622
- const command = fact.commandLine ?? fact.imageName ?? "";
623
- const looksLikeHarness = commandHasPiHarnessArc(command) || commandLooksLikePiImage(command);
624
- if (!looksLikeHarness)
625
- continue;
626
- if (ancestors.has(fact.pid)) {
627
- skippedAncestorPids.push(fact.pid);
628
- log2(`[magic-context] Pi process scan: skipping ancestor PID ${fact.pid} (session launcher shim)`);
629
- continue;
630
- }
631
- if (commandHasPiHarnessArc(command)) {
632
- processIds.add(fact.pid);
633
- continue;
634
- }
635
- inconclusivePids.add(fact.pid);
636
- log2(`[magic-context] Pi process scan: PID ${fact.pid} command line is ambiguous (image-name or missing Pi/OMP arc); treating as inconclusive`);
637
- }
638
- skippedAncestorPids.sort((left, right) => left - right);
639
- const verified = [...processIds].sort((left, right) => left - right);
640
- const inconclusive = [...inconclusivePids].sort((left, right) => left - right);
641
- if (verified.length === 0 && inconclusive.length > 0) {
642
- return {
643
- state: "inconclusive",
644
- processIds: [],
645
- inconclusivePids: inconclusive,
646
- ...skippedAncestorPids.length > 0 ? { skippedAncestorPids } : {}
647
- };
648
- }
649
- return {
650
- state: "known",
651
- processIds: verified,
652
- ...inconclusive.length > 0 ? { inconclusivePids: inconclusive } : {},
653
- ...skippedAncestorPids.length > 0 ? { skippedAncestorPids } : {}
654
- };
655
- }
656
- function inspectLivePiProcesses() {
657
- if (false) {}
658
- try {
659
- if (rpcIdentityPlatform === "win32") {
660
- const now = rpcIdentityNowMs();
661
- const cached = windowsProcessSnapshotCache;
662
- const snapshot = cached && now >= cached.at && now - cached.at < WINDOWS_PROCESS_SNAPSHOT_TTL_MS ? cached.snapshot : tryReadWindowsCimSnapshot(rpcProcessListExecFileSync) ?? tryReadWindowsTasklistSnapshot();
663
- if (!snapshot) {
664
- return {
665
- state: "unreadable",
666
- processIds: [],
667
- error: "process list unavailable"
668
- };
669
- }
670
- if (snapshot !== cached?.snapshot)
671
- windowsProcessSnapshotCache = { snapshot, at: now };
672
- rememberWindowsProcessFacts(snapshot.facts);
673
- return classifyLivePiSnapshot(snapshot);
674
- }
675
- return classifyLivePiSnapshot(readPosixProcessSnapshot());
676
- } catch (error) {
677
- return {
678
- state: "unreadable",
679
- processIds: [],
680
- error: error instanceof Error ? error.message : String(error)
681
- };
682
- }
683
- }
684
- function parseRpcPortFile(content, fallbackPid = 0) {
685
- const trimmed = content.trim();
686
- if (!trimmed)
687
- return null;
688
- if (trimmed.startsWith("{")) {
689
- try {
690
- const parsed = JSON.parse(trimmed);
691
- const port = Number(parsed.port);
692
- const pid = Number(parsed.pid);
693
- const startedAt = Number(parsed.started_at);
694
- if (!isValidPort(port) || !Number.isInteger(pid) || pid <= 0)
695
- return null;
696
- return {
697
- port,
698
- pid,
699
- started_at: Number.isFinite(startedAt) ? startedAt : 0,
700
- kind: typeof parsed.kind === "string" ? parsed.kind : undefined,
701
- harness: typeof parsed.harness === "string" ? parsed.harness : undefined,
702
- token: typeof parsed.token === "string" ? parsed.token : undefined,
703
- instance_id: typeof parsed.instance_id === "string" ? parsed.instance_id : undefined
704
- };
705
- } catch {
706
- return null;
707
- }
708
- }
709
- const port = Number.parseInt(trimmed, 10);
710
- if (!isValidPort(port))
711
- return null;
712
- return { port, pid: fallbackPid, started_at: 0 };
713
- }
714
- function isValidPort(port) {
715
- return Number.isInteger(port) && port > 0 && port <= 65535;
716
- }
717
- function snapshotEvidence(fact) {
718
- return {
719
- startTime: fact?.startTime ?? null,
720
- commandLine: fact?.commandLine ?? fact?.imageName ?? null,
721
- ...fact?.imageName ? { imageName: fact.imageName } : {}
722
- };
723
- }
724
- function execProcessListAsync(file, args, timeout) {
725
- return new Promise((resolve, reject) => {
726
- execFile(file, args, { encoding: "utf8", timeout, windowsHide: true, maxBuffer: 8 * 1024 * 1024 }, (error, stdout) => {
727
- if (error)
728
- reject(error);
729
- else
730
- resolve(stdout);
731
- });
732
- });
733
- }
734
- var asyncProcessExec = execProcessListAsync;
735
- var asyncInspection;
736
- var asyncInspectionExpires = 0;
737
- var lastAsyncSnapshot = null;
738
- function inspectProcessesAsync(forceFresh = false) {
739
- if (!forceFresh && asyncInspection && rpcIdentityNowMs() < asyncInspectionExpires)
740
- return asyncInspection;
741
- asyncInspectionExpires = Number.POSITIVE_INFINITY;
742
- asyncInspection = (async () => {
743
- let snapshot = null;
744
- try {
745
- if (rpcIdentityPlatform === "win32") {
746
- try {
747
- const output = await asyncProcessExec("powershell", ["-NoProfile", "-Command", WINDOWS_CIM_COMMAND], WINDOWS_CIM_PROBE_TIMEOUT_MS);
748
- const facts = parseWindowsCimOutput(output);
749
- if (facts)
750
- snapshot = snapshotFromFacts(facts, "cim");
751
- } catch {}
752
- if (!snapshot) {
753
- const entries = parseTasklistOutput(await asyncProcessExec("tasklist", ["/FO", "CSV", "/NH"], PS_PROBE_TIMEOUT_MS));
754
- if (entries)
755
- snapshot = snapshotFromFacts(entries.map(({ pid, command }) => ({
756
- pid,
757
- parentPid: null,
758
- commandLine: null,
759
- imageName: command,
760
- startTime: null
761
- })), "tasklist");
762
- }
763
- } else {
764
- const output = await asyncProcessExec("ps", ["-axo", "pid=,ppid=,lstart=,command="], PS_PROBE_TIMEOUT_MS);
765
- const facts = [];
766
- for (const line of output.split(/\r?\n/)) {
767
- const match = /^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.+)$/.exec(line);
768
- if (!match)
769
- continue;
770
- const startTime = Date.parse(match[3]);
771
- facts.push({
772
- pid: Number(match[1]),
773
- parentPid: Number(match[2]),
774
- commandLine: match[4],
775
- imageName: null,
776
- startTime: Number.isFinite(startTime) ? startTime : null
777
- });
778
- }
779
- snapshot = facts.length > 0 ? snapshotFromFacts(facts, "ps") : null;
780
- }
781
- } catch {}
782
- const fresh = snapshot !== null;
783
- if (snapshot)
784
- lastAsyncSnapshot = snapshot;
785
- else
786
- snapshot = lastAsyncSnapshot;
787
- const byPid = new Map(snapshot?.facts.map((fact) => [fact.pid, fact]));
788
- return {
789
- pi: snapshot ? classifyLivePiSnapshot(snapshot, false) : { state: "unreadable", processIds: [] },
790
- ...fresh && snapshot ? { processSnapshot: { source: snapshot.source, facts: snapshot.facts } } : {},
791
- evidence: (pid) => snapshotEvidence(byPid.get(pid)),
792
- liveness: (pid) => byPid.has(pid) ? "alive" : fresh ? "dead" : "inconclusive"
793
- };
794
- })().finally(() => {
795
- asyncInspectionExpires = rpcIdentityNowMs() + WINDOWS_PROCESS_SNAPSHOT_TTL_MS;
796
- });
797
- return asyncInspection;
798
- }
799
- function inspectWindowsProcessesSync() {
800
- const snapshot = tryReadWindowsCimSnapshot(rpcProcessListExecFileSync) ?? tryReadWindowsTasklistSnapshot();
801
- const byPid = new Map(snapshot?.facts.map((fact) => [fact.pid, fact]));
802
- return {
803
- pi: snapshot ? classifyLivePiSnapshot(snapshot) : { state: "unreadable", processIds: [] },
804
- ...snapshot ? { processSnapshot: { source: snapshot.source, facts: snapshot.facts } } : {},
805
- evidence: (pid) => snapshotEvidence(byPid.get(pid)),
806
- liveness: (pid) => byPid.has(pid) ? "alive" : snapshot ? "dead" : "inconclusive"
807
- };
808
- }
93
+ import { basename, dirname, join, resolve } from "node:path";
809
94
 
810
95
  // src/features/magic-context/context-store-uuid.ts
811
96
  import { randomUUID } from "node:crypto";
@@ -1507,7 +792,7 @@ function resolveDatabasePath(dbPathOverride) {
1507
792
  return { dbDir: dirname(dbPathOverride), dbPath: dbPathOverride };
1508
793
  }
1509
794
  const dbDir = getMagicContextStorageDir();
1510
- return { dbDir, dbPath: join2(dbDir, "context.db") };
795
+ return { dbDir, dbPath: join(dbDir, "context.db") };
1511
796
  }
1512
797
  function isFileBackedPath(dbPath) {
1513
798
  const trimmed = dbPath.trim();
@@ -1517,7 +802,7 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
1517
802
  if (existsSync2(targetDbPath))
1518
803
  return;
1519
804
  const legacyDir = getLegacyOpenCodeMagicContextStorageDir();
1520
- const legacyDbPath = join2(legacyDir, "context.db");
805
+ const legacyDbPath = join(legacyDir, "context.db");
1521
806
  if (!existsSync2(legacyDbPath))
1522
807
  return;
1523
808
  log2(`[magic-context] migrating legacy plugin storage: ${legacyDir} -> ${targetDbDir} (legacy left in place as backup)`);
@@ -1535,7 +820,7 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
1535
820
  }
1536
821
  for (const suffix of ["", "-wal", "-shm"]) {
1537
822
  const src = `${legacyDbPath}${suffix}`;
1538
- const dst = join2(targetDbDir, `context.db${suffix}`);
823
+ const dst = join(targetDbDir, `context.db${suffix}`);
1539
824
  if (existsSync2(src)) {
1540
825
  try {
1541
826
  copyStorageFileSync(src, dst);
@@ -1544,8 +829,8 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
1544
829
  }
1545
830
  }
1546
831
  }
1547
- const legacyModelsDir = join2(legacyDir, "models");
1548
- const targetModelsDir = join2(targetDbDir, "models");
832
+ const legacyModelsDir = join(legacyDir, "models");
833
+ const targetModelsDir = join(targetDbDir, "models");
1549
834
  if (existsSync2(legacyModelsDir) && !existsSync2(targetModelsDir)) {
1550
835
  try {
1551
836
  copyStorageTreeSync(legacyModelsDir, targetModelsDir);
@@ -1600,7 +885,7 @@ function unreadableDiscovery(path, arm) {
1600
885
  var RPC_DISCOVERY_PARSE_GRACE_MS = 10 * 60 * 1000;
1601
886
  var defaultRpcDiscoveryFs = {
1602
887
  readdirSync: (path, options) => options?.withFileTypes ? readdirSync(path, { withFileTypes: true }) : readdirSync(path),
1603
- readFileSync: (path, encoding) => String(readFileSync2(path, encoding)),
888
+ readFileSync: (path, encoding) => String(readFileSync(path, encoding)),
1604
889
  statSync: (path) => ({ mtimeMs: statSync(path).mtimeMs }),
1605
890
  unlinkSync: (path) => unlinkSync(path),
1606
891
  rmdirSync: (path) => rmdirSync(path)
@@ -1663,7 +948,7 @@ function classifyJunkDiscovery(portFile, raw, staleFiles) {
1663
948
  function inspectRpcServerDiscovery(storageDir, processes, options) {
1664
949
  const deadline = options?.deadlineMs === undefined ? Number.POSITIVE_INFINITY : Date.now() + options.deadlineMs;
1665
950
  let progressAt = Date.now() + 3000;
1666
- const rpcRoot = join2(storageDir, "rpc");
951
+ const rpcRoot = join(storageDir, "rpc");
1667
952
  let projectEntries;
1668
953
  try {
1669
954
  projectEntries = rpcDiscoveryFs.readdirSync(rpcRoot, { withFileTypes: true });
@@ -1677,7 +962,7 @@ function inspectRpcServerDiscovery(storageDir, processes, options) {
1677
962
  for (const projectEntry of projectEntries) {
1678
963
  if (!projectEntry.isDirectory())
1679
964
  continue;
1680
- const projectDir = join2(rpcRoot, projectEntry.name);
965
+ const projectDir = join(rpcRoot, projectEntry.name);
1681
966
  let entries;
1682
967
  try {
1683
968
  entries = rpcDiscoveryFs.readdirSync(projectDir);
@@ -1688,7 +973,7 @@ function inspectRpcServerDiscovery(storageDir, processes, options) {
1688
973
  }
1689
974
  for (const entry of entries) {
1690
975
  if (entry === "port" || entry.startsWith("port-") && entry.endsWith(".json")) {
1691
- portFiles.push(join2(projectDir, entry));
976
+ portFiles.push(join(projectDir, entry));
1692
977
  }
1693
978
  }
1694
979
  }
@@ -1814,7 +1099,7 @@ function isDefaultSharedDatabasePath(dbPath) {
1814
1099
  if (!process.env.XDG_DATA_HOME && (process.env.MAGIC_CONTEXT_TEST_DATA_DIR || false)) {
1815
1100
  return false;
1816
1101
  }
1817
- return resolve(dbPath) === resolve(join2(getMagicContextStorageDir(), "context.db"));
1102
+ return resolve(dbPath) === resolve(join(getMagicContextStorageDir(), "context.db"));
1818
1103
  }
1819
1104
  function migrationBlockingPiPids(dbPath, discovery, discoveredPiPids) {
1820
1105
  if (isDefaultSharedDatabasePath(dbPath))
@@ -1913,8 +1198,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1913
1198
  startMessageFtsRowidMapBackfill(db).then(async () => {
1914
1199
  if (!readsOpenCodeStore)
1915
1200
  return;
1916
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-rh4khdkv.js"));
1917
- const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-gtx1pwk1.js"));
1201
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-fhyfe4qa.js"));
1202
+ const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-cje68egj.js"));
1918
1203
  await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
1919
1204
  readPage: readRawSessionMessagePage
1920
1205
  }));
@@ -3405,4 +2690,4 @@ function getDatabasePersistenceError(db) {
3405
2690
  return persistenceErrorByDatabase.get(db) ?? null;
3406
2691
  }
3407
2692
 
3408
- export { FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, formatFailClosedBlockingSummary, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, registerOwnRpcServerInstance, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, inspectProcessesAsync, startBootDeadline, getUnconfirmedMigrationHolders, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, BOOT_SQLITE_BUSY_TIMEOUT_MS, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError };
2693
+ export { FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, formatFailClosedBlockingSummary, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, startBootDeadline, getUnconfirmedMigrationHolders, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, BOOT_SQLITE_BUSY_TIMEOUT_MS, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError };