@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
@@ -3,7 +3,7 @@ import {
3
3
  importPluginModule,
4
4
  writeForwardedLogLine2,
5
5
  log2
6
- } from "./index-8j7gqj40.js";
6
+ } from "./index-nsjyysj0.js";
7
7
  import {
8
8
  harnessOwnsOpenCodeStore2
9
9
  } from "./index-pavzsdc6.js";
@@ -11,6 +11,17 @@ import {
11
11
  getMagicContextStorageDir,
12
12
  getLegacyOpenCodeMagicContextStorageDir
13
13
  } from "./index-0sahzkwr.js";
14
+ import {
15
+ isOwnRpcServerRecord,
16
+ isPidAlive,
17
+ readProcessProbeEvidence,
18
+ classifyProcessKind,
19
+ isPidIdentityPlausible,
20
+ inspectLivePiProcesses,
21
+ parseRpcPortFile,
22
+ inspectProcessesAsync,
23
+ inspectWindowsProcessesSync
24
+ } from "./index-6m7rdv7y.js";
14
25
  import {
15
26
  registerSlowWriteReporter2,
16
27
  registerSqliteDiagnosticSink2,
@@ -26,7 +37,7 @@ import {
26
37
  } from "./index-fb3zxn06.js";
27
38
  import {
28
39
  startMessageFtsRowidMapBackfill
29
- } from "./index-fbv1dn35.js";
40
+ } from "./index-7w18gg78.js";
30
41
  import {
31
42
  LKG_SLOT_CHUNKS_DDL,
32
43
  SESSION_REPLAY_DECISIONS_DDL,
@@ -36,25 +47,24 @@ import {
36
47
  hasPendingMigrations,
37
48
  getMainThreadMigrationBodyCount,
38
49
  runMigrations
39
- } from "./index-7mx8v0pw.js";
50
+ } from "./index-att4bfan.js";
40
51
  import {
41
52
  installTagIdentityRevisionTrigger,
42
53
  ensureColumn,
43
54
  installV95PerfSchema
44
- } from "./index-db7zwa3v.js";
55
+ } from "./index-1bt88epp.js";
45
56
  import {
46
57
  resolveOpenCodeDbPath,
47
58
  hasV1MessageTables
48
59
  } from "./index-58e3y90n.js";
49
60
  import {
50
- canonicalProjectDirectory,
51
61
  bootQuietRemainingMs,
52
62
  scheduleAfterBootQuiet
53
- } from "./index-knh4y330.js";
63
+ } from "./index-gzky5rva.js";
54
64
  import {
55
65
  setDatabase,
56
66
  loadToolDefinitionMeasurements
57
- } from "./index-0qhce371.js";
67
+ } from "./index-h2wc01qk.js";
58
68
  import {
59
69
  getErrorMessage
60
70
  } from "./index-y8v6yerm.js";
@@ -65,13 +75,13 @@ import {
65
75
  copyStorageFileSync,
66
76
  copyStorageTreeSync,
67
77
  tightenStorageTreeSync
68
- } from "./index-1bc61ans.js";
78
+ } from "./index-fvnzcnww.js";
69
79
  import {
70
80
  closeQuietly
71
81
  } from "./index-8ajstryz.js";
72
82
  import {
73
83
  logSlowWriteTransaction
74
- } from "./index-2y0s2hep.js";
84
+ } from "./index-4mjhqadz.js";
75
85
 
76
86
  // src/features/magic-context/fail-closed-block.ts
77
87
  var FAIL_CLOSED_DOCTOR_COMMAND = "npx @cortexkit/magic-context@latest doctor";
@@ -337,737 +347,12 @@ function getLastHookInitFailure() {
337
347
  import {
338
348
  existsSync as existsSync2,
339
349
  readdirSync,
340
- readFileSync as readFileSync2,
350
+ readFileSync,
341
351
  rmdirSync,
342
352
  statSync,
343
353
  unlinkSync
344
354
  } from "node:fs";
345
- import { basename, dirname, join as join2, resolve } from "node:path";
346
-
347
- // src/shared/rpc-utils.ts
348
- import { execFile, execFileSync } from "node:child_process";
349
- import { createHash } from "node:crypto";
350
- import { readFileSync } from "node:fs";
351
- import { join } from "node:path";
352
-
353
- // src/shared/pi-executable.ts
354
- var PI_IMAGE_NAMES = new Set(["pi", "pi.cmd", "omp", "oh-my-pi"]);
355
- function piHarnessKindFromExecutable(value) {
356
- const executable = (value ?? "").trim().replace(/^['"]|['"]$/g, "").replaceAll("\\", "/").split("/").at(-1)?.toLowerCase().replace(/\.(?:exe|cmd)$/, "");
357
- if (!executable || !PI_IMAGE_NAMES.has(executable))
358
- return;
359
- return executable === "pi" ? "pi" : "omp";
360
- }
361
-
362
- // src/shared/rpc-utils.ts
363
- var ownRpcServerInstanceIds = new Set;
364
- function registerOwnRpcServerInstance(instanceId) {
365
- ownRpcServerInstanceIds.add(instanceId);
366
- return () => {
367
- ownRpcServerInstanceIds.delete(instanceId);
368
- };
369
- }
370
- function isOwnRpcServerRecord(record) {
371
- return record.pid === process.pid && record.instance_id !== undefined && ownRpcServerInstanceIds.has(record.instance_id);
372
- }
373
- function projectHash(directory) {
374
- return createHash("sha256").update(canonicalProjectDirectory(directory)).digest("hex").slice(0, 16);
375
- }
376
- function rpcPortDir(storageDir, directory) {
377
- return join(storageDir, "rpc", projectHash(directory));
378
- }
379
- function rpcPortFilePath(storageDir, directory, pid = process.pid, instanceId) {
380
- const suffix = instanceId ? `-${instanceId}` : "";
381
- return join(rpcPortDir(storageDir, directory), `port-${pid}${suffix}.json`);
382
- }
383
- function isPidAlive(pid) {
384
- if (!Number.isInteger(pid) || pid <= 0)
385
- return "dead";
386
- if (rpcIdentityPlatform === "win32")
387
- return readWindowsProcess(pid).state;
388
- try {
389
- rpcIdentityProcessKill(pid, 0);
390
- return "alive";
391
- } catch (error) {
392
- return error.code === "ESRCH" ? "dead" : "inconclusive";
393
- }
394
- }
395
- var RPC_IDENTITY_SKEW_TOLERANCE_MS = 120000;
396
- var LINUX_CLOCK_TICKS_PER_SECOND = 100;
397
- var PS_PROBE_TIMEOUT_MS = 1000;
398
- var WINDOWS_CIM_PROBE_TIMEOUT_MS = 5000;
399
- var WINDOWS_PROCESS_SNAPSHOT_TTL_MS = 2000;
400
- var MAX_ANCESTOR_WALK_DEPTH = 16;
401
- var OPEN_CODE_COMMAND_MARKERS = ["opencode", "node", "bun", "electron"];
402
- 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";
403
- var PROCESS_LIST_MAX_BUFFER_BYTES = 8 * 1024 * 1024;
404
- var PI_HARNESS_ARC_MARKERS = [
405
- "pi-coding-agent",
406
- "oh-my-pi",
407
- "@oh-my-pi",
408
- "cljs/dist",
409
- "dist/bundle/cli"
410
- ];
411
- var rpcIdentityReadFileSync = readFileSync;
412
- var rpcIdentityExecFileSync = execFileSync;
413
- var rpcIdentityProcessKill = process.kill;
414
- var rpcProcessListExecFileSync = execFileSync;
415
- var rpcIdentityPlatform = process.platform;
416
- var rpcIdentityNowMs = () => Date.now();
417
- function parseLinuxProcessStartTime(statContent, uptimeContent) {
418
- const closingCommandName = statContent.lastIndexOf(")");
419
- if (closingCommandName < 0)
420
- return null;
421
- const statFields = statContent.slice(closingCommandName + 1).trim().split(/\s+/);
422
- const startTimeTicks = Number(statFields[19]);
423
- const uptimeSeconds = Number(uptimeContent.trim().split(/\s+/)[0]);
424
- if (!Number.isFinite(startTimeTicks) || startTimeTicks < 0 || !Number.isFinite(uptimeSeconds) || uptimeSeconds < 0) {
425
- return null;
426
- }
427
- const processStartTime = rpcIdentityNowMs() - uptimeSeconds * 1000 + startTimeTicks / LINUX_CLOCK_TICKS_PER_SECOND * 1000;
428
- return Number.isFinite(processStartTime) ? processStartTime : null;
429
- }
430
- function readLinuxProcessStartTime(pid) {
431
- try {
432
- const statContent = String(rpcIdentityReadFileSync(`/proc/${pid}/stat`, "utf8"));
433
- const uptimeContent = String(rpcIdentityReadFileSync("/proc/uptime", "utf8"));
434
- return parseLinuxProcessStartTime(statContent, uptimeContent);
435
- } catch {
436
- return null;
437
- }
438
- }
439
- function readPsProcessStartTime(pid) {
440
- try {
441
- const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "lstart="], {
442
- encoding: "utf8",
443
- timeout: PS_PROBE_TIMEOUT_MS,
444
- stdio: ["ignore", "pipe", "pipe"],
445
- windowsHide: true
446
- });
447
- const processStartTime = Date.parse(String(output).trim());
448
- return Number.isFinite(processStartTime) ? processStartTime : null;
449
- } catch {
450
- return null;
451
- }
452
- }
453
- function readProcessStartTime(pid) {
454
- if (!Number.isInteger(pid) || pid <= 0)
455
- return null;
456
- return rpcIdentityPlatform === "linux" ? readLinuxProcessStartTime(pid) : rpcIdentityPlatform === "win32" ? readWindowsProcessStartTime(pid) : readPsProcessStartTime(pid);
457
- }
458
- function readProcessProbeEvidence(pid) {
459
- return {
460
- startTime: readProcessStartTime(pid),
461
- commandLine: readProcessCommand(pid)
462
- };
463
- }
464
- function readCachedWindowsImageName(pid) {
465
- return rpcIdentityPlatform === "win32" ? windowsProcessFactsCache?.get(pid)?.imageName ?? null : null;
466
- }
467
- var windowsProcessFactsCache = null;
468
- var windowsProcessSnapshotCache = null;
469
- function rememberWindowsProcessFacts(facts) {
470
- windowsProcessFactsCache = new Map(facts.map((fact) => [fact.pid, fact]));
471
- }
472
- function parseCsvLine(line) {
473
- const fields = [];
474
- let field = "";
475
- let quoted = false;
476
- for (let index = 0;index < line.length; index += 1) {
477
- const character = line[index];
478
- if (character === '"') {
479
- if (quoted && line[index + 1] === '"') {
480
- field += '"';
481
- index += 1;
482
- } else {
483
- quoted = !quoted;
484
- }
485
- } else if (character === "," && !quoted) {
486
- fields.push(field);
487
- field = "";
488
- } else {
489
- field += character;
490
- }
491
- }
492
- if (quoted)
493
- return null;
494
- fields.push(field);
495
- return fields;
496
- }
497
- function parseTasklistOutput(output) {
498
- const entries = [];
499
- for (const rawLine of output.split(/\r?\n/)) {
500
- const line = rawLine.trim();
501
- if (!line)
502
- continue;
503
- const fields = parseCsvLine(line);
504
- if (!fields)
505
- continue;
506
- if (fields[1]?.trim().toLowerCase() === "pid") {
507
- continue;
508
- }
509
- const pid = Number(fields[1]);
510
- if (!Number.isInteger(pid) || pid <= 0 || !fields[0])
511
- continue;
512
- entries.push({ pid, command: fields[0] });
513
- }
514
- return entries;
515
- }
516
- function readWindowsProcess(pid) {
517
- try {
518
- const output = rpcIdentityExecFileSync("tasklist", ["/FO", "CSV", "/NH", "/FI", `PID eq ${pid}`], {
519
- encoding: "utf8",
520
- timeout: PS_PROBE_TIMEOUT_MS,
521
- stdio: ["ignore", "pipe", "pipe"],
522
- windowsHide: true
523
- });
524
- const entries = parseTasklistOutput(String(output));
525
- if (entries === null)
526
- return { state: "inconclusive" };
527
- const process2 = entries.find((entry) => entry.pid === pid);
528
- return process2 ? { state: "alive", command: process2.command } : { state: "dead" };
529
- } catch {
530
- return { state: "inconclusive" };
531
- }
532
- }
533
- function readWindowsProcessStartTime(pid) {
534
- const cached = windowsProcessFactsCache?.get(pid);
535
- if (cached)
536
- return cached.startTime;
537
- const snapshot = tryReadWindowsCimSnapshot(rpcIdentityExecFileSync);
538
- if (!snapshot)
539
- return null;
540
- rememberWindowsProcessFacts(snapshot.facts);
541
- return windowsProcessFactsCache?.get(pid)?.startTime ?? null;
542
- }
543
- function readLinuxProcessCommand(pid) {
544
- try {
545
- return String(rpcIdentityReadFileSync(`/proc/${pid}/cmdline`, "utf8"));
546
- } catch {
547
- return null;
548
- }
549
- }
550
- function readPsProcessCommand(pid) {
551
- try {
552
- const output = rpcIdentityExecFileSync("ps", ["-p", String(pid), "-o", "command="], {
553
- encoding: "utf8",
554
- timeout: PS_PROBE_TIMEOUT_MS,
555
- stdio: ["ignore", "pipe", "pipe"],
556
- windowsHide: true
557
- });
558
- return String(output);
559
- } catch {
560
- return null;
561
- }
562
- }
563
- function readProcessCommand(pid) {
564
- if (!Number.isInteger(pid) || pid <= 0)
565
- return null;
566
- if (rpcIdentityPlatform === "linux")
567
- return readLinuxProcessCommand(pid);
568
- if (rpcIdentityPlatform === "win32") {
569
- const cached = windowsProcessFactsCache?.get(pid);
570
- if (cached?.commandLine)
571
- return cached.commandLine;
572
- return readWindowsProcess(pid).command ?? null;
573
- }
574
- return readPsProcessCommand(pid);
575
- }
576
- function executableName(token) {
577
- return (token ?? "").replace(/^['"]|['"]$/g, "").split("/").at(-1) ?? "";
578
- }
579
- function commandTokens(command) {
580
- return command.toLowerCase().replaceAll("\\", "/").replaceAll("\x00", " ").split(/\s+/).map((token) => token.replace(/^['"]|['"]$/g, "")).filter(Boolean);
581
- }
582
- function commandHasOpenCodeExecutable(tokens) {
583
- return tokens.findIndex((token) => {
584
- const executable = executableName(token).replace(/\.(?:exe|cmd)$/, "");
585
- return executable === "opencode" || executable.endsWith("/opencode");
586
- });
587
- }
588
- function commandHasPiExecutable(tokens) {
589
- for (let index = 0;index < tokens.length; index += 1) {
590
- const executable = executableName(tokens[index]).replace(/\.(?:exe|cmd)$/, "");
591
- if (piHarnessKindFromExecutable(executable) !== undefined)
592
- return true;
593
- if (["node", "bun", "deno"].includes(executable)) {
594
- const script = executableName(tokens[index + 1]).replace(/\.(?:exe|cmd)$/, "");
595
- if (["pi", "pi.js", "pi.mjs", "pi.cjs"].includes(script) || tokens[index + 1]?.includes("pi-coding-agent")) {
596
- return true;
597
- }
598
- }
599
- }
600
- return false;
601
- }
602
- function classifyProcessKind(command) {
603
- if (!command)
604
- return "process";
605
- const tokens = commandTokens(command);
606
- const openCodeIndex = commandHasOpenCodeExecutable(tokens);
607
- if (openCodeIndex >= 0) {
608
- const args = tokens.slice(openCodeIndex + 1);
609
- if (args.some((token) => token === "serve" || token === "--serve" || token.startsWith("--serve="))) {
610
- return "OpenCode server";
611
- }
612
- return "OpenCode instance (TUI/CLI)";
613
- }
614
- return commandHasPiExecutable(tokens) ? "Pi" : "process";
615
- }
616
- function commandLooksLikeOpenCode(command) {
617
- const normalized = command.toLowerCase();
618
- return OPEN_CODE_COMMAND_MARKERS.some((marker) => normalized.includes(marker));
619
- }
620
- var RPC_HOST_PROCESS_MARKERS = [
621
- "opencode",
622
- "openchamber",
623
- "ck-mc",
624
- "magic-context",
625
- "cortexkit",
626
- "electron",
627
- "node",
628
- "bun",
629
- "deno",
630
- "pi-coding-agent",
631
- "oh-my-pi"
632
- ];
633
- function processCannotBeRpcHost(evidence) {
634
- const texts = [evidence.imageName, evidence.commandLine].filter((text) => typeof text === "string" && text.trim().length > 0);
635
- if (texts.length === 0)
636
- return false;
637
- for (const text of texts) {
638
- const normalized = text.toLowerCase();
639
- if (RPC_HOST_PROCESS_MARKERS.some((marker) => normalized.includes(marker)))
640
- return false;
641
- const tokens = commandTokens(text);
642
- if (commandHasPiExecutable(tokens))
643
- return false;
644
- if (tokens.some((token) => piHarnessKindFromExecutable(token) !== undefined))
645
- return false;
646
- }
647
- return true;
648
- }
649
- function isPidIdentityPlausible(record, evidence) {
650
- if (!Number.isInteger(record.pid) || record.pid <= 0)
651
- return "implausible";
652
- if (Number.isFinite(record.started_at) && record.started_at > 0) {
653
- const processStartTime = evidence ? evidence.startTime : readProcessStartTime(record.pid);
654
- if (processStartTime !== null) {
655
- return processStartTime <= record.started_at + RPC_IDENTITY_SKEW_TOLERANCE_MS ? "plausible" : "implausible";
656
- }
657
- const identity = evidence ?? {
658
- commandLine: readProcessCommand(record.pid),
659
- imageName: readCachedWindowsImageName(record.pid)
660
- };
661
- return processCannotBeRpcHost(identity) ? "implausible" : "inconclusive";
662
- }
663
- const command = evidence ? evidence.commandLine : rpcIdentityPlatform === "linux" ? readLinuxProcessCommand(record.pid) : rpcIdentityPlatform === "win32" ? readWindowsProcess(record.pid).command ?? null : readPsProcessCommand(record.pid);
664
- if (command === null)
665
- return "inconclusive";
666
- if (commandLooksLikeOpenCode(command))
667
- return "plausible";
668
- return processCannotBeRpcHost({ commandLine: command, imageName: evidence?.imageName }) ? "implausible" : "inconclusive";
669
- }
670
- function commandLooksLikePiImage(command) {
671
- const tokens = commandTokens(command);
672
- const first = executableName(tokens[0]).replace(/\.(?:exe|cmd)$/, "");
673
- return PI_IMAGE_NAMES.has(first);
674
- }
675
- function commandHasPiHarnessArc(command) {
676
- const normalized = command.trim().toLowerCase().replaceAll("\\", "/").replaceAll("\x00", " ");
677
- if (!normalized)
678
- return false;
679
- const tokens = commandTokens(command);
680
- if (tokens.length === 0)
681
- return false;
682
- const hasArc = PI_HARNESS_ARC_MARKERS.some((marker) => normalized.includes(marker));
683
- const first = executableName(tokens[0]).replace(/\.(?:exe|cmd)$/, "");
684
- if (hasArc && ["pi", "omp", "oh-my-pi", "node", "bun", "deno", "cmd"].includes(first)) {
685
- return true;
686
- }
687
- if (hasArc && PI_HARNESS_ARC_MARKERS.some((marker) => tokens[0].includes(marker))) {
688
- return true;
689
- }
690
- if (["node", "bun", "deno"].includes(first)) {
691
- const script = executableName(tokens[1]).replace(/\.(?:exe|cmd)$/, "");
692
- if (["pi", "pi.js", "pi.mjs", "pi.cjs"].includes(script))
693
- return true;
694
- if (hasArc)
695
- return true;
696
- }
697
- return false;
698
- }
699
- function execProcessList(exec, file, args, timeout = PS_PROBE_TIMEOUT_MS) {
700
- return String(exec(file, [...args], {
701
- encoding: "utf8",
702
- timeout,
703
- maxBuffer: PROCESS_LIST_MAX_BUFFER_BYTES,
704
- stdio: ["ignore", "pipe", "pipe"],
705
- windowsHide: true
706
- }));
707
- }
708
- function parseWindowsCreationDate(value) {
709
- if (value !== null && typeof value === "object" && "value" in value) {
710
- return parseWindowsCreationDate(value.value);
711
- }
712
- if (typeof value === "number" && Number.isFinite(value)) {
713
- return value > 1000000000000 ? value : value * 1000;
714
- }
715
- if (typeof value !== "string")
716
- return null;
717
- const trimmed = value.trim();
718
- if (!trimmed)
719
- return null;
720
- const wmi = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})\.(\d{6})([+-])(\d{3})$/.exec(trimmed);
721
- if (wmi) {
722
- 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);
723
- if (!Number.isFinite(utcMs))
724
- return null;
725
- const offsetMinutes = Number(wmi[9]);
726
- const sign = wmi[8] === "+" ? 1 : -1;
727
- return utcMs - sign * offsetMinutes * 60000;
728
- }
729
- const dotNet = /^\/Date\((-?\d+)\)\/$/.exec(trimmed);
730
- if (dotNet) {
731
- const milliseconds = Number(dotNet[1]);
732
- return Number.isFinite(milliseconds) ? milliseconds : null;
733
- }
734
- const parsed = Date.parse(trimmed);
735
- return Number.isFinite(parsed) ? parsed : null;
736
- }
737
- function parseWindowsCimOutput(output) {
738
- const trimmed = output.trim();
739
- if (!trimmed)
740
- return null;
741
- const bracket = trimmed.indexOf("[");
742
- const brace = trimmed.indexOf("{");
743
- const start = Math.min(bracket === -1 ? Number.POSITIVE_INFINITY : bracket, brace === -1 ? Number.POSITIVE_INFINITY : brace);
744
- if (!Number.isFinite(start))
745
- return null;
746
- let parsed;
747
- try {
748
- parsed = JSON.parse(trimmed.slice(start));
749
- } catch {
750
- return null;
751
- }
752
- if (parsed == null)
753
- return null;
754
- const rows = Array.isArray(parsed) ? parsed : [parsed];
755
- const facts = [];
756
- for (const row of rows) {
757
- if (!row || typeof row !== "object")
758
- continue;
759
- const record = row;
760
- const pid = Number(record.ProcessId);
761
- if (!Number.isInteger(pid) || pid <= 0)
762
- continue;
763
- const parentRaw = record.ParentProcessId;
764
- const parentPid = parentRaw == null || parentRaw === "" ? Number.NaN : Number(parentRaw);
765
- const commandLine = typeof record.CommandLine === "string" ? record.CommandLine : null;
766
- facts.push({
767
- pid,
768
- parentPid: Number.isInteger(parentPid) && parentPid > 0 ? parentPid : null,
769
- commandLine,
770
- imageName: typeof record.Name === "string" ? record.Name : commandLine ? executableName(commandTokens(commandLine)[0]) : null,
771
- startTime: parseWindowsCreationDate(record.CreationDate)
772
- });
773
- }
774
- return facts.length > 0 ? facts : null;
775
- }
776
- function snapshotFromFacts(facts, source) {
777
- const parentByPid = new Map;
778
- for (const fact of facts) {
779
- if (fact.parentPid != null)
780
- parentByPid.set(fact.pid, fact.parentPid);
781
- }
782
- return { facts, parentByPid, source };
783
- }
784
- function tryReadWindowsCimSnapshot(exec) {
785
- try {
786
- const output = execProcessList(exec, "powershell", ["-NoProfile", "-Command", WINDOWS_CIM_COMMAND], WINDOWS_CIM_PROBE_TIMEOUT_MS);
787
- const facts = parseWindowsCimOutput(output);
788
- return facts ? snapshotFromFacts(facts, "cim") : null;
789
- } catch {
790
- return null;
791
- }
792
- }
793
- function tryReadWindowsTasklistSnapshot() {
794
- try {
795
- const output = execProcessList(rpcProcessListExecFileSync, "tasklist", [
796
- "/FO",
797
- "CSV",
798
- "/NH"
799
- ]);
800
- const entries = parseTasklistOutput(output);
801
- if (entries === null)
802
- return null;
803
- const facts = entries.map((entry) => ({
804
- pid: entry.pid,
805
- parentPid: null,
806
- commandLine: null,
807
- imageName: entry.command,
808
- startTime: null
809
- }));
810
- return snapshotFromFacts(facts, "tasklist");
811
- } catch {
812
- return null;
813
- }
814
- }
815
- function readPosixProcessSnapshot() {
816
- const output = execProcessList(rpcProcessListExecFileSync, "ps", ["-axo", "pid=,command="]);
817
- const facts = [];
818
- for (const line of output.split(/\r?\n/)) {
819
- const match = /^\s*(\d+)\s+(.+)$/.exec(line);
820
- if (!match)
821
- continue;
822
- const pid = Number(match[1]);
823
- if (!Number.isInteger(pid) || pid <= 0)
824
- continue;
825
- facts.push({
826
- pid,
827
- parentPid: null,
828
- commandLine: match[2],
829
- imageName: executableName(commandTokens(match[2])[0]),
830
- startTime: null
831
- });
832
- }
833
- return snapshotFromFacts(facts, "ps");
834
- }
835
- function readPosixParentPid(pid) {
836
- try {
837
- const output = execProcessList(rpcProcessListExecFileSync, "ps", [
838
- "-o",
839
- "ppid=",
840
- "-p",
841
- String(pid)
842
- ]);
843
- const match = /^\s*(\d+)\s*$/.exec(output);
844
- if (!match)
845
- return null;
846
- const ppid = Number(match[1]);
847
- return Number.isInteger(ppid) && ppid > 0 ? ppid : null;
848
- } catch {
849
- return null;
850
- }
851
- }
852
- function collectAncestorPids(selfPid, parentByPid, probeParents = true) {
853
- const ancestors = new Set;
854
- let current = selfPid;
855
- for (let depth = 0;depth < MAX_ANCESTOR_WALK_DEPTH; depth += 1) {
856
- let ppid = null;
857
- if (parentByPid.has(current)) {
858
- ppid = parentByPid.get(current) ?? null;
859
- } else if (rpcIdentityPlatform !== "win32" && probeParents) {
860
- ppid = readPosixParentPid(current);
861
- if (ppid == null && current === process.pid && process.ppid > 0) {
862
- ppid = process.ppid;
863
- }
864
- } else if (current === process.pid && process.ppid > 0) {
865
- ppid = process.ppid;
866
- } else {
867
- break;
868
- }
869
- if (ppid == null || ppid <= 0 || ppid === current || ancestors.has(ppid))
870
- break;
871
- ancestors.add(ppid);
872
- current = ppid;
873
- }
874
- return ancestors;
875
- }
876
- function classifyLivePiSnapshot(snapshot, probeParents = true) {
877
- const ancestors = collectAncestorPids(process.pid, snapshot.parentByPid, probeParents);
878
- const processIds = new Set;
879
- const inconclusivePids = new Set;
880
- const skippedAncestorPids = [];
881
- for (const fact of snapshot.facts) {
882
- if (fact.pid === process.pid)
883
- continue;
884
- const command = fact.commandLine ?? fact.imageName ?? "";
885
- const looksLikeHarness = commandHasPiHarnessArc(command) || commandLooksLikePiImage(command);
886
- if (!looksLikeHarness)
887
- continue;
888
- if (ancestors.has(fact.pid)) {
889
- skippedAncestorPids.push(fact.pid);
890
- log2(`[magic-context] Pi process scan: skipping ancestor PID ${fact.pid} (session launcher shim)`);
891
- continue;
892
- }
893
- if (commandHasPiHarnessArc(command)) {
894
- processIds.add(fact.pid);
895
- continue;
896
- }
897
- inconclusivePids.add(fact.pid);
898
- log2(`[magic-context] Pi process scan: PID ${fact.pid} command line is ambiguous (image-name or missing Pi/OMP arc); treating as inconclusive`);
899
- }
900
- skippedAncestorPids.sort((left, right) => left - right);
901
- const verified = [...processIds].sort((left, right) => left - right);
902
- const inconclusive = [...inconclusivePids].sort((left, right) => left - right);
903
- if (verified.length === 0 && inconclusive.length > 0) {
904
- return {
905
- state: "inconclusive",
906
- processIds: [],
907
- inconclusivePids: inconclusive,
908
- ...skippedAncestorPids.length > 0 ? { skippedAncestorPids } : {}
909
- };
910
- }
911
- return {
912
- state: "known",
913
- processIds: verified,
914
- ...inconclusive.length > 0 ? { inconclusivePids: inconclusive } : {},
915
- ...skippedAncestorPids.length > 0 ? { skippedAncestorPids } : {}
916
- };
917
- }
918
- function inspectLivePiProcesses() {
919
- if (false) {}
920
- try {
921
- if (rpcIdentityPlatform === "win32") {
922
- const now = rpcIdentityNowMs();
923
- const cached = windowsProcessSnapshotCache;
924
- const snapshot = cached && now >= cached.at && now - cached.at < WINDOWS_PROCESS_SNAPSHOT_TTL_MS ? cached.snapshot : tryReadWindowsCimSnapshot(rpcProcessListExecFileSync) ?? tryReadWindowsTasklistSnapshot();
925
- if (!snapshot) {
926
- return {
927
- state: "unreadable",
928
- processIds: [],
929
- error: "process list unavailable"
930
- };
931
- }
932
- if (snapshot !== cached?.snapshot)
933
- windowsProcessSnapshotCache = { snapshot, at: now };
934
- rememberWindowsProcessFacts(snapshot.facts);
935
- return classifyLivePiSnapshot(snapshot);
936
- }
937
- return classifyLivePiSnapshot(readPosixProcessSnapshot());
938
- } catch (error) {
939
- return {
940
- state: "unreadable",
941
- processIds: [],
942
- error: error instanceof Error ? error.message : String(error)
943
- };
944
- }
945
- }
946
- function parseRpcPortFile(content, fallbackPid = 0) {
947
- const trimmed = content.trim();
948
- if (!trimmed)
949
- return null;
950
- if (trimmed.startsWith("{")) {
951
- try {
952
- const parsed = JSON.parse(trimmed);
953
- const port = Number(parsed.port);
954
- const pid = Number(parsed.pid);
955
- const startedAt = Number(parsed.started_at);
956
- if (!isValidPort(port) || !Number.isInteger(pid) || pid <= 0)
957
- return null;
958
- return {
959
- port,
960
- pid,
961
- started_at: Number.isFinite(startedAt) ? startedAt : 0,
962
- kind: typeof parsed.kind === "string" ? parsed.kind : undefined,
963
- harness: typeof parsed.harness === "string" ? parsed.harness : undefined,
964
- token: typeof parsed.token === "string" ? parsed.token : undefined,
965
- instance_id: typeof parsed.instance_id === "string" ? parsed.instance_id : undefined
966
- };
967
- } catch {
968
- return null;
969
- }
970
- }
971
- const port = Number.parseInt(trimmed, 10);
972
- if (!isValidPort(port))
973
- return null;
974
- return { port, pid: fallbackPid, started_at: 0 };
975
- }
976
- function isValidPort(port) {
977
- return Number.isInteger(port) && port > 0 && port <= 65535;
978
- }
979
- function snapshotEvidence(fact) {
980
- return {
981
- startTime: fact?.startTime ?? null,
982
- commandLine: fact?.commandLine ?? fact?.imageName ?? null,
983
- ...fact?.imageName ? { imageName: fact.imageName } : {}
984
- };
985
- }
986
- function execProcessListAsync(file, args, timeout) {
987
- return new Promise((resolve, reject) => {
988
- execFile(file, args, { encoding: "utf8", timeout, windowsHide: true, maxBuffer: 8 * 1024 * 1024 }, (error, stdout) => {
989
- if (error)
990
- reject(error);
991
- else
992
- resolve(stdout);
993
- });
994
- });
995
- }
996
- var asyncProcessExec = execProcessListAsync;
997
- var asyncInspection;
998
- var asyncInspectionExpires = 0;
999
- var lastAsyncSnapshot = null;
1000
- function inspectProcessesAsync(forceFresh = false) {
1001
- if (!forceFresh && asyncInspection && rpcIdentityNowMs() < asyncInspectionExpires)
1002
- return asyncInspection;
1003
- asyncInspectionExpires = Number.POSITIVE_INFINITY;
1004
- asyncInspection = (async () => {
1005
- let snapshot = null;
1006
- try {
1007
- if (rpcIdentityPlatform === "win32") {
1008
- try {
1009
- const output = await asyncProcessExec("powershell", ["-NoProfile", "-Command", WINDOWS_CIM_COMMAND], WINDOWS_CIM_PROBE_TIMEOUT_MS);
1010
- const facts = parseWindowsCimOutput(output);
1011
- if (facts)
1012
- snapshot = snapshotFromFacts(facts, "cim");
1013
- } catch {}
1014
- if (!snapshot) {
1015
- const entries = parseTasklistOutput(await asyncProcessExec("tasklist", ["/FO", "CSV", "/NH"], PS_PROBE_TIMEOUT_MS));
1016
- if (entries)
1017
- snapshot = snapshotFromFacts(entries.map(({ pid, command }) => ({
1018
- pid,
1019
- parentPid: null,
1020
- commandLine: null,
1021
- imageName: command,
1022
- startTime: null
1023
- })), "tasklist");
1024
- }
1025
- } else {
1026
- const output = await asyncProcessExec("ps", ["-axo", "pid=,ppid=,lstart=,command="], PS_PROBE_TIMEOUT_MS);
1027
- const facts = [];
1028
- for (const line of output.split(/\r?\n/)) {
1029
- const match = /^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+(.+)$/.exec(line);
1030
- if (!match)
1031
- continue;
1032
- const startTime = Date.parse(match[3]);
1033
- facts.push({
1034
- pid: Number(match[1]),
1035
- parentPid: Number(match[2]),
1036
- commandLine: match[4],
1037
- imageName: null,
1038
- startTime: Number.isFinite(startTime) ? startTime : null
1039
- });
1040
- }
1041
- snapshot = facts.length > 0 ? snapshotFromFacts(facts, "ps") : null;
1042
- }
1043
- } catch {}
1044
- const fresh = snapshot !== null;
1045
- if (snapshot)
1046
- lastAsyncSnapshot = snapshot;
1047
- else
1048
- snapshot = lastAsyncSnapshot;
1049
- const byPid = new Map(snapshot?.facts.map((fact) => [fact.pid, fact]));
1050
- return {
1051
- pi: snapshot ? classifyLivePiSnapshot(snapshot, false) : { state: "unreadable", processIds: [] },
1052
- ...fresh && snapshot ? { processSnapshot: { source: snapshot.source, facts: snapshot.facts } } : {},
1053
- evidence: (pid) => snapshotEvidence(byPid.get(pid)),
1054
- liveness: (pid) => byPid.has(pid) ? "alive" : fresh ? "dead" : "inconclusive"
1055
- };
1056
- })().finally(() => {
1057
- asyncInspectionExpires = rpcIdentityNowMs() + WINDOWS_PROCESS_SNAPSHOT_TTL_MS;
1058
- });
1059
- return asyncInspection;
1060
- }
1061
- function inspectWindowsProcessesSync() {
1062
- const snapshot = tryReadWindowsCimSnapshot(rpcProcessListExecFileSync) ?? tryReadWindowsTasklistSnapshot();
1063
- const byPid = new Map(snapshot?.facts.map((fact) => [fact.pid, fact]));
1064
- return {
1065
- pi: snapshot ? classifyLivePiSnapshot(snapshot) : { state: "unreadable", processIds: [] },
1066
- ...snapshot ? { processSnapshot: { source: snapshot.source, facts: snapshot.facts } } : {},
1067
- evidence: (pid) => snapshotEvidence(byPid.get(pid)),
1068
- liveness: (pid) => byPid.has(pid) ? "alive" : snapshot ? "dead" : "inconclusive"
1069
- };
1070
- }
355
+ import { basename, dirname, join, resolve } from "node:path";
1071
356
 
1072
357
  // src/features/magic-context/context-store-uuid.ts
1073
358
  import { randomUUID } from "node:crypto";
@@ -1565,7 +850,7 @@ function resolveDatabasePath(dbPathOverride) {
1565
850
  return { dbDir: dirname(dbPathOverride), dbPath: dbPathOverride };
1566
851
  }
1567
852
  const dbDir = getMagicContextStorageDir();
1568
- return { dbDir, dbPath: join2(dbDir, "context.db") };
853
+ return { dbDir, dbPath: join(dbDir, "context.db") };
1569
854
  }
1570
855
  function isFileBackedPath(dbPath) {
1571
856
  const trimmed = dbPath.trim();
@@ -1578,7 +863,7 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
1578
863
  if (existsSync2(targetDbPath))
1579
864
  return;
1580
865
  const legacyDir = getLegacyOpenCodeMagicContextStorageDir();
1581
- const legacyDbPath = join2(legacyDir, "context.db");
866
+ const legacyDbPath = join(legacyDir, "context.db");
1582
867
  if (!existsSync2(legacyDbPath))
1583
868
  return;
1584
869
  log2(`[magic-context] migrating legacy plugin storage: ${legacyDir} -> ${targetDbDir} (legacy left in place as backup)`);
@@ -1596,7 +881,7 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
1596
881
  }
1597
882
  for (const suffix of ["", "-wal", "-shm"]) {
1598
883
  const src = `${legacyDbPath}${suffix}`;
1599
- const dst = join2(targetDbDir, `context.db${suffix}`);
884
+ const dst = join(targetDbDir, `context.db${suffix}`);
1600
885
  if (existsSync2(src)) {
1601
886
  try {
1602
887
  copyStorageFileSync(src, dst);
@@ -1605,8 +890,8 @@ function migrateLegacyStorageIfNeeded(targetDbPath, targetDbDir) {
1605
890
  }
1606
891
  }
1607
892
  }
1608
- const legacyModelsDir = join2(legacyDir, "models");
1609
- const targetModelsDir = join2(targetDbDir, "models");
893
+ const legacyModelsDir = join(legacyDir, "models");
894
+ const targetModelsDir = join(targetDbDir, "models");
1610
895
  if (existsSync2(legacyModelsDir) && !existsSync2(targetModelsDir)) {
1611
896
  try {
1612
897
  copyStorageTreeSync(legacyModelsDir, targetModelsDir);
@@ -1661,7 +946,7 @@ function unreadableDiscovery(path, arm) {
1661
946
  var RPC_DISCOVERY_PARSE_GRACE_MS = 10 * 60 * 1000;
1662
947
  var defaultRpcDiscoveryFs = {
1663
948
  readdirSync: (path, options) => options?.withFileTypes ? readdirSync(path, { withFileTypes: true }) : readdirSync(path),
1664
- readFileSync: (path, encoding) => String(readFileSync2(path, encoding)),
949
+ readFileSync: (path, encoding) => String(readFileSync(path, encoding)),
1665
950
  statSync: (path) => ({ mtimeMs: statSync(path).mtimeMs }),
1666
951
  unlinkSync: (path) => unlinkSync(path),
1667
952
  rmdirSync: (path) => rmdirSync(path)
@@ -1724,7 +1009,7 @@ function classifyJunkDiscovery(portFile, raw, staleFiles) {
1724
1009
  function inspectRpcServerDiscovery(storageDir, processes, options) {
1725
1010
  const deadline = options?.deadlineMs === undefined ? Number.POSITIVE_INFINITY : Date.now() + options.deadlineMs;
1726
1011
  let progressAt = Date.now() + 3000;
1727
- const rpcRoot = join2(storageDir, "rpc");
1012
+ const rpcRoot = join(storageDir, "rpc");
1728
1013
  let projectEntries;
1729
1014
  try {
1730
1015
  projectEntries = rpcDiscoveryFs.readdirSync(rpcRoot, { withFileTypes: true });
@@ -1738,7 +1023,7 @@ function inspectRpcServerDiscovery(storageDir, processes, options) {
1738
1023
  for (const projectEntry of projectEntries) {
1739
1024
  if (!projectEntry.isDirectory())
1740
1025
  continue;
1741
- const projectDir = join2(rpcRoot, projectEntry.name);
1026
+ const projectDir = join(rpcRoot, projectEntry.name);
1742
1027
  let entries;
1743
1028
  try {
1744
1029
  entries = rpcDiscoveryFs.readdirSync(projectDir);
@@ -1749,7 +1034,7 @@ function inspectRpcServerDiscovery(storageDir, processes, options) {
1749
1034
  }
1750
1035
  for (const entry of entries) {
1751
1036
  if (entry === "port" || entry.startsWith("port-") && entry.endsWith(".json")) {
1752
- portFiles.push(join2(projectDir, entry));
1037
+ portFiles.push(join(projectDir, entry));
1753
1038
  }
1754
1039
  }
1755
1040
  }
@@ -1875,7 +1160,7 @@ function isDefaultSharedDatabasePath(dbPath) {
1875
1160
  if (!process.env.XDG_DATA_HOME && (process.env.MAGIC_CONTEXT_TEST_DATA_DIR || false)) {
1876
1161
  return false;
1877
1162
  }
1878
- return resolve(dbPath) === resolve(join2(getMagicContextStorageDir(), "context.db"));
1163
+ return resolve(dbPath) === resolve(join(getMagicContextStorageDir(), "context.db"));
1879
1164
  }
1880
1165
  function migrationBlockingPiPids(dbPath, discovery, discoveredPiPids) {
1881
1166
  if (isDefaultSharedDatabasePath(dbPath))
@@ -1974,8 +1259,8 @@ function finishDatabaseOpen(db, dbPath, explicitDbPath, latestSupportedVersion)
1974
1259
  startMessageFtsRowidMapBackfill(db).then(async () => {
1975
1260
  if (!readsOpenCodeStore)
1976
1261
  return;
1977
- const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-6k83m4fj.js"));
1978
- const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-brbd63hv.js"));
1262
+ const { readRawSessionMessagePage, readRawSessionMessages } = await importPluginModule(() => import("./read-session-chunk-5mh0bh8y.js"));
1263
+ const { startMessageTimeBackfill } = await importPluginModule(() => import("./message-time-backfill-8x06r9kx.js"));
1979
1264
  await startMessageTimeBackfill(db, Object.assign(readRawSessionMessages, {
1980
1265
  readPage: readRawSessionMessagePage
1981
1266
  }));
@@ -3466,4 +2751,4 @@ function getDatabasePersistenceError(db) {
3466
2751
  return persistenceErrorByDatabase.get(db) ?? null;
3467
2752
  }
3468
2753
 
3469
- export { FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, formatFailClosedBlockingSummary, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, createFailClosedController, recordHookInitFailure, clearHookInitFailure, getLastHookInitFailure, registerOwnRpcServerInstance, rpcPortDir, rpcPortFilePath, isPidAlive, parseRpcPortFile, inspectProcessesAsync, startBootDeadline, getUnconfirmedMigrationHolders, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, BOOT_SQLITE_BUSY_TIMEOUT_MS, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError };
2754
+ export { FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, formatFailClosedBlockingSummary, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, resolveAgentNameFromMessages, createFailClosedController, recordHookInitFailure, clearHookInitFailure, getLastHookInitFailure, startBootDeadline, getUnconfirmedMigrationHolders, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, BOOT_SQLITE_BUSY_TIMEOUT_MS, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, runSqliteOptimize, initializeDatabase, openDatabase, openCurrentDatabase, openDatabaseAsync, isDatabasePersisted, getDatabasePersistenceError };