omp-fabric 0.85.0

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 (772) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -0
  3. package/THIRD_PARTY_NOTICES.md +33 -0
  4. package/dist/activity/store.d.ts +32 -0
  5. package/dist/activity/store.d.ts.map +1 -0
  6. package/dist/activity/types.d.ts +104 -0
  7. package/dist/activity/types.d.ts.map +1 -0
  8. package/dist/actors/binding-store.d.ts +17 -0
  9. package/dist/actors/binding-store.d.ts.map +1 -0
  10. package/dist/actors/context.d.ts +13 -0
  11. package/dist/actors/context.d.ts.map +1 -0
  12. package/dist/actors/delivery-policy.d.ts +8 -0
  13. package/dist/actors/delivery-policy.d.ts.map +1 -0
  14. package/dist/actors/directory.d.ts +47 -0
  15. package/dist/actors/directory.d.ts.map +1 -0
  16. package/dist/actors/global-registry.d.ts +47 -0
  17. package/dist/actors/global-registry.d.ts.map +1 -0
  18. package/dist/actors/host-event-observer.d.ts +5 -0
  19. package/dist/actors/host-event-observer.d.ts.map +1 -0
  20. package/dist/actors/host-event-payload.d.ts +14 -0
  21. package/dist/actors/host-event-payload.d.ts.map +1 -0
  22. package/dist/actors/manager.d.ts +175 -0
  23. package/dist/actors/manager.d.ts.map +1 -0
  24. package/dist/actors/predicate.d.ts +7 -0
  25. package/dist/actors/predicate.d.ts.map +1 -0
  26. package/dist/actors/types.d.ts +211 -0
  27. package/dist/actors/types.d.ts.map +1 -0
  28. package/dist/agents/bash-worktree-add.d.ts +24 -0
  29. package/dist/agents/bash-worktree-add.d.ts.map +1 -0
  30. package/dist/agents/budget-ledger.d.ts +88 -0
  31. package/dist/agents/budget-ledger.d.ts.map +1 -0
  32. package/dist/agents/claude-cli.d.ts +32 -0
  33. package/dist/agents/claude-cli.d.ts.map +1 -0
  34. package/dist/agents/claude-cli.js +17 -0
  35. package/dist/agents/claude-cli.js.map +7 -0
  36. package/dist/agents/clone-first-worktree.d.ts +17 -0
  37. package/dist/agents/clone-first-worktree.d.ts.map +1 -0
  38. package/dist/agents/compact-control.d.ts +32 -0
  39. package/dist/agents/compact-control.d.ts.map +1 -0
  40. package/dist/agents/compact-control.js +127 -0
  41. package/dist/agents/compact-control.js.map +7 -0
  42. package/dist/agents/constants.d.ts +5 -0
  43. package/dist/agents/constants.d.ts.map +1 -0
  44. package/dist/agents/cow-clone.d.ts +8 -0
  45. package/dist/agents/cow-clone.d.ts.map +1 -0
  46. package/dist/agents/handoff.d.ts +19 -0
  47. package/dist/agents/handoff.d.ts.map +1 -0
  48. package/dist/agents/manager.d.ts +68 -0
  49. package/dist/agents/manager.d.ts.map +1 -0
  50. package/dist/agents/omp-binary.d.ts +7 -0
  51. package/dist/agents/omp-binary.d.ts.map +1 -0
  52. package/dist/agents/rm.d.ts +15 -0
  53. package/dist/agents/rm.d.ts.map +1 -0
  54. package/dist/agents/semaphore.d.ts +7 -0
  55. package/dist/agents/semaphore.d.ts.map +1 -0
  56. package/dist/agents/session-export.d.ts +9 -0
  57. package/dist/agents/session-export.d.ts.map +1 -0
  58. package/dist/agents/thinking-transfer.d.ts +39 -0
  59. package/dist/agents/thinking-transfer.d.ts.map +1 -0
  60. package/dist/agents/transports/herdr-transport.d.ts +10 -0
  61. package/dist/agents/transports/herdr-transport.d.ts.map +1 -0
  62. package/dist/agents/transports/localterm-transport.d.ts +7 -0
  63. package/dist/agents/transports/localterm-transport.d.ts.map +1 -0
  64. package/dist/agents/transports/process-transport.d.ts +7 -0
  65. package/dist/agents/transports/process-transport.d.ts.map +1 -0
  66. package/dist/agents/transports/process-utils.d.ts +29 -0
  67. package/dist/agents/transports/process-utils.d.ts.map +1 -0
  68. package/dist/agents/transports/screen-transport.d.ts +7 -0
  69. package/dist/agents/transports/screen-transport.d.ts.map +1 -0
  70. package/dist/agents/transports/tmux-transport.d.ts +7 -0
  71. package/dist/agents/transports/tmux-transport.d.ts.map +1 -0
  72. package/dist/agents/types.d.ts +251 -0
  73. package/dist/agents/types.d.ts.map +1 -0
  74. package/dist/agents/veda-cli.d.ts +22 -0
  75. package/dist/agents/veda-cli.d.ts.map +1 -0
  76. package/dist/agents/veda-cli.js +13 -0
  77. package/dist/agents/veda-cli.js.map +7 -0
  78. package/dist/agents/worktree-manager.d.ts +14 -0
  79. package/dist/agents/worktree-manager.d.ts.map +1 -0
  80. package/dist/agents/worktree-paths.d.ts +5 -0
  81. package/dist/agents/worktree-paths.d.ts.map +1 -0
  82. package/dist/async-settlement.d.ts +4 -0
  83. package/dist/async-settlement.d.ts.map +1 -0
  84. package/dist/audit/details.d.ts +82 -0
  85. package/dist/audit/details.d.ts.map +1 -0
  86. package/dist/audit/index.d.ts +4 -0
  87. package/dist/audit/index.d.ts.map +1 -0
  88. package/dist/audit/projection.d.ts +20 -0
  89. package/dist/audit/projection.d.ts.map +1 -0
  90. package/dist/audit/trace.d.ts +95 -0
  91. package/dist/audit/trace.d.ts.map +1 -0
  92. package/dist/capture/catalog.d.ts +29 -0
  93. package/dist/capture/catalog.d.ts.map +1 -0
  94. package/dist/capture/interceptor.d.ts +21 -0
  95. package/dist/capture/interceptor.d.ts.map +1 -0
  96. package/dist/capture/wrapper.d.ts +15 -0
  97. package/dist/capture/wrapper.d.ts.map +1 -0
  98. package/dist/chunks/chunk-2GQC324T.js +5001 -0
  99. package/dist/chunks/chunk-2GQC324T.js.map +7 -0
  100. package/dist/chunks/chunk-2KEWFW56.js +1229 -0
  101. package/dist/chunks/chunk-2KEWFW56.js.map +7 -0
  102. package/dist/chunks/chunk-3J7BKUNG.js +354 -0
  103. package/dist/chunks/chunk-3J7BKUNG.js.map +7 -0
  104. package/dist/chunks/chunk-4A4MVZQW.js +253 -0
  105. package/dist/chunks/chunk-4A4MVZQW.js.map +7 -0
  106. package/dist/chunks/chunk-4HQDSTHN.js +221 -0
  107. package/dist/chunks/chunk-4HQDSTHN.js.map +7 -0
  108. package/dist/chunks/chunk-4LEDA76O.js +688 -0
  109. package/dist/chunks/chunk-4LEDA76O.js.map +7 -0
  110. package/dist/chunks/chunk-5GTPD4BA.js +1318 -0
  111. package/dist/chunks/chunk-5GTPD4BA.js.map +7 -0
  112. package/dist/chunks/chunk-5IWFSDU5.js +87 -0
  113. package/dist/chunks/chunk-5IWFSDU5.js.map +7 -0
  114. package/dist/chunks/chunk-6N4XGAZY.js +21 -0
  115. package/dist/chunks/chunk-6N4XGAZY.js.map +7 -0
  116. package/dist/chunks/chunk-6QBPSZJ5.js +647 -0
  117. package/dist/chunks/chunk-6QBPSZJ5.js.map +7 -0
  118. package/dist/chunks/chunk-6X6WUU2K.js +73 -0
  119. package/dist/chunks/chunk-6X6WUU2K.js.map +7 -0
  120. package/dist/chunks/chunk-7363CD5A.js +38 -0
  121. package/dist/chunks/chunk-7363CD5A.js.map +7 -0
  122. package/dist/chunks/chunk-77FQHHZD.js +231 -0
  123. package/dist/chunks/chunk-77FQHHZD.js.map +7 -0
  124. package/dist/chunks/chunk-7BIA5BJN.js +112 -0
  125. package/dist/chunks/chunk-7BIA5BJN.js.map +7 -0
  126. package/dist/chunks/chunk-7BOAOKWH.js +64 -0
  127. package/dist/chunks/chunk-7BOAOKWH.js.map +7 -0
  128. package/dist/chunks/chunk-7TB7NXSL.js +58 -0
  129. package/dist/chunks/chunk-7TB7NXSL.js.map +7 -0
  130. package/dist/chunks/chunk-7VIQNUPS.js +17 -0
  131. package/dist/chunks/chunk-7VIQNUPS.js.map +7 -0
  132. package/dist/chunks/chunk-CT2AJ2UI.js +225 -0
  133. package/dist/chunks/chunk-CT2AJ2UI.js.map +7 -0
  134. package/dist/chunks/chunk-DLXPTBPL.js +151 -0
  135. package/dist/chunks/chunk-DLXPTBPL.js.map +7 -0
  136. package/dist/chunks/chunk-ED3BRM6P.js +17 -0
  137. package/dist/chunks/chunk-ED3BRM6P.js.map +7 -0
  138. package/dist/chunks/chunk-G2IBGGBM.js +42 -0
  139. package/dist/chunks/chunk-G2IBGGBM.js.map +7 -0
  140. package/dist/chunks/chunk-GKOFZ76R.js +1596 -0
  141. package/dist/chunks/chunk-GKOFZ76R.js.map +7 -0
  142. package/dist/chunks/chunk-HDJBUXDX.js +1102 -0
  143. package/dist/chunks/chunk-HDJBUXDX.js.map +7 -0
  144. package/dist/chunks/chunk-IGVDD2HT.js +10 -0
  145. package/dist/chunks/chunk-IGVDD2HT.js.map +7 -0
  146. package/dist/chunks/chunk-JHKOG5GS.js +187 -0
  147. package/dist/chunks/chunk-JHKOG5GS.js.map +7 -0
  148. package/dist/chunks/chunk-JP4LIZFT.js +1334 -0
  149. package/dist/chunks/chunk-JP4LIZFT.js.map +7 -0
  150. package/dist/chunks/chunk-JSBTB3P6.js +127 -0
  151. package/dist/chunks/chunk-JSBTB3P6.js.map +7 -0
  152. package/dist/chunks/chunk-KAD7UWT2.js +99 -0
  153. package/dist/chunks/chunk-KAD7UWT2.js.map +7 -0
  154. package/dist/chunks/chunk-KIH3KLZU.js +95 -0
  155. package/dist/chunks/chunk-KIH3KLZU.js.map +7 -0
  156. package/dist/chunks/chunk-KIREBD2V.js +2208 -0
  157. package/dist/chunks/chunk-KIREBD2V.js.map +7 -0
  158. package/dist/chunks/chunk-LMAVZN7J.js +8 -0
  159. package/dist/chunks/chunk-LMAVZN7J.js.map +7 -0
  160. package/dist/chunks/chunk-NCPJZXLM.js +57 -0
  161. package/dist/chunks/chunk-NCPJZXLM.js.map +7 -0
  162. package/dist/chunks/chunk-OJZNMROB.js +195 -0
  163. package/dist/chunks/chunk-OJZNMROB.js.map +7 -0
  164. package/dist/chunks/chunk-OPTP4PSE.js +469 -0
  165. package/dist/chunks/chunk-OPTP4PSE.js.map +7 -0
  166. package/dist/chunks/chunk-QPXSCMTG.js +24 -0
  167. package/dist/chunks/chunk-QPXSCMTG.js.map +7 -0
  168. package/dist/chunks/chunk-ROKMBLGN.js +1265 -0
  169. package/dist/chunks/chunk-ROKMBLGN.js.map +7 -0
  170. package/dist/chunks/chunk-SXMWV447.js +2445 -0
  171. package/dist/chunks/chunk-SXMWV447.js.map +7 -0
  172. package/dist/chunks/chunk-T5ZA5YRU.js +786 -0
  173. package/dist/chunks/chunk-T5ZA5YRU.js.map +7 -0
  174. package/dist/chunks/chunk-T6OAX4FO.js +1835 -0
  175. package/dist/chunks/chunk-T6OAX4FO.js.map +7 -0
  176. package/dist/chunks/chunk-U5FYOMG5.js +119 -0
  177. package/dist/chunks/chunk-U5FYOMG5.js.map +7 -0
  178. package/dist/chunks/chunk-UOSJZXJV.js +142 -0
  179. package/dist/chunks/chunk-UOSJZXJV.js.map +7 -0
  180. package/dist/chunks/chunk-UPCARIJP.js +6627 -0
  181. package/dist/chunks/chunk-UPCARIJP.js.map +7 -0
  182. package/dist/chunks/chunk-VPPIJRNZ.js +50 -0
  183. package/dist/chunks/chunk-VPPIJRNZ.js.map +7 -0
  184. package/dist/chunks/chunk-XU5Z4JCQ.js +297 -0
  185. package/dist/chunks/chunk-XU5Z4JCQ.js.map +7 -0
  186. package/dist/chunks/chunk-YWEXP724.js +427 -0
  187. package/dist/chunks/chunk-YWEXP724.js.map +7 -0
  188. package/dist/chunks/chunk-YZZIKJX6.js +60 -0
  189. package/dist/chunks/chunk-YZZIKJX6.js.map +7 -0
  190. package/dist/chunks/chunk-ZNAJDPT7.js +2203 -0
  191. package/dist/chunks/chunk-ZNAJDPT7.js.map +7 -0
  192. package/dist/chunks/chunk-ZTM45GH5.js +163 -0
  193. package/dist/chunks/chunk-ZTM45GH5.js.map +7 -0
  194. package/dist/commands/fabric.d.ts +17 -0
  195. package/dist/commands/fabric.d.ts.map +1 -0
  196. package/dist/compaction/bounds.d.ts +23 -0
  197. package/dist/compaction/bounds.d.ts.map +1 -0
  198. package/dist/compaction/branch-details.d.ts +83 -0
  199. package/dist/compaction/branch-details.d.ts.map +1 -0
  200. package/dist/compaction/branch-summary.d.ts +9 -0
  201. package/dist/compaction/branch-summary.d.ts.map +1 -0
  202. package/dist/compaction/enrichers.d.ts +10 -0
  203. package/dist/compaction/enrichers.d.ts.map +1 -0
  204. package/dist/compaction/hook.d.ts +98 -0
  205. package/dist/compaction/hook.d.ts.map +1 -0
  206. package/dist/compaction/hook.js +19 -0
  207. package/dist/compaction/hook.js.map +7 -0
  208. package/dist/compaction/instructions.d.ts +38 -0
  209. package/dist/compaction/instructions.d.ts.map +1 -0
  210. package/dist/compaction/normalize.d.ts +83 -0
  211. package/dist/compaction/normalize.d.ts.map +1 -0
  212. package/dist/compaction/projections.d.ts +31 -0
  213. package/dist/compaction/projections.d.ts.map +1 -0
  214. package/dist/compaction/qa.d.ts +27 -0
  215. package/dist/compaction/qa.d.ts.map +1 -0
  216. package/dist/compaction/render.d.ts +10 -0
  217. package/dist/compaction/render.d.ts.map +1 -0
  218. package/dist/compaction/threshold.d.ts +5 -0
  219. package/dist/compaction/threshold.d.ts.map +1 -0
  220. package/dist/compaction/trace-events.d.ts +23 -0
  221. package/dist/compaction/trace-events.d.ts.map +1 -0
  222. package/dist/components/catalog.d.ts +25 -0
  223. package/dist/components/catalog.d.ts.map +1 -0
  224. package/dist/components/effect-scope.d.ts +31 -0
  225. package/dist/components/effect-scope.d.ts.map +1 -0
  226. package/dist/components/loader.d.ts +27 -0
  227. package/dist/components/loader.d.ts.map +1 -0
  228. package/dist/components/model-guidance.d.ts +48 -0
  229. package/dist/components/model-guidance.d.ts.map +1 -0
  230. package/dist/components/provider-component.d.ts +31 -0
  231. package/dist/components/provider-component.d.ts.map +1 -0
  232. package/dist/components/supervisor.d.ts +29 -0
  233. package/dist/components/supervisor.d.ts.map +1 -0
  234. package/dist/components/types.d.ts +140 -0
  235. package/dist/components/types.d.ts.map +1 -0
  236. package/dist/config-migrations.d.ts +11 -0
  237. package/dist/config-migrations.d.ts.map +1 -0
  238. package/dist/config.d.ts +269 -0
  239. package/dist/config.d.ts.map +1 -0
  240. package/dist/core/action-registry.d.ts +159 -0
  241. package/dist/core/action-registry.d.ts.map +1 -0
  242. package/dist/core/action-registry.js +17 -0
  243. package/dist/core/action-registry.js.map +7 -0
  244. package/dist/core/action-repair.d.ts +20 -0
  245. package/dist/core/action-repair.d.ts.map +1 -0
  246. package/dist/core/agent-dir.d.ts +2 -0
  247. package/dist/core/agent-dir.d.ts.map +1 -0
  248. package/dist/core/approval-controller.d.ts +30 -0
  249. package/dist/core/approval-controller.d.ts.map +1 -0
  250. package/dist/core/atomic-write.d.ts +15 -0
  251. package/dist/core/atomic-write.d.ts.map +1 -0
  252. package/dist/core/auto-approval-classifier.d.ts +13 -0
  253. package/dist/core/auto-approval-classifier.d.ts.map +1 -0
  254. package/dist/core/call-preview.d.ts +8 -0
  255. package/dist/core/call-preview.d.ts.map +1 -0
  256. package/dist/core/child-tool-allowlist.d.ts +3 -0
  257. package/dist/core/child-tool-allowlist.d.ts.map +1 -0
  258. package/dist/core/compact-controller.d.ts +42 -0
  259. package/dist/core/compact-controller.d.ts.map +1 -0
  260. package/dist/core/core-override-guidance.d.ts +7 -0
  261. package/dist/core/core-override-guidance.d.ts.map +1 -0
  262. package/dist/core/direct-tool-approval.d.ts +19 -0
  263. package/dist/core/direct-tool-approval.d.ts.map +1 -0
  264. package/dist/core/effect-conflict.d.ts +3 -0
  265. package/dist/core/effect-conflict.d.ts.map +1 -0
  266. package/dist/core/file-lock.d.ts +12 -0
  267. package/dist/core/file-lock.d.ts.map +1 -0
  268. package/dist/core/model-resolution.d.ts +62 -0
  269. package/dist/core/model-resolution.d.ts.map +1 -0
  270. package/dist/core/model-usage.d.ts +8 -0
  271. package/dist/core/model-usage.d.ts.map +1 -0
  272. package/dist/core/omp-bash-error.d.ts +11 -0
  273. package/dist/core/omp-bash-error.d.ts.map +1 -0
  274. package/dist/core/omp-tools.d.ts +9 -0
  275. package/dist/core/omp-tools.d.ts.map +1 -0
  276. package/dist/core/provider-bindings.d.ts +47 -0
  277. package/dist/core/provider-bindings.d.ts.map +1 -0
  278. package/dist/core/proxy-contract.d.ts +18 -0
  279. package/dist/core/proxy-contract.d.ts.map +1 -0
  280. package/dist/core/session-context.d.ts +6 -0
  281. package/dist/core/session-context.d.ts.map +1 -0
  282. package/dist/core/skill-block.d.ts +10 -0
  283. package/dist/core/skill-block.d.ts.map +1 -0
  284. package/dist/core/skill-dir.d.ts +4 -0
  285. package/dist/core/skill-dir.d.ts.map +1 -0
  286. package/dist/core/skill-prompt.d.ts +3 -0
  287. package/dist/core/skill-prompt.d.ts.map +1 -0
  288. package/dist/core/skill-references.d.ts +7 -0
  289. package/dist/core/skill-references.d.ts.map +1 -0
  290. package/dist/core/stable-hash.d.ts +3 -0
  291. package/dist/core/stable-hash.d.ts.map +1 -0
  292. package/dist/core/system-guidance.d.ts +12 -0
  293. package/dist/core/system-guidance.d.ts.map +1 -0
  294. package/dist/core/token-math.d.ts +16 -0
  295. package/dist/core/token-math.d.ts.map +1 -0
  296. package/dist/core/tool-ownership.d.ts +52 -0
  297. package/dist/core/tool-ownership.d.ts.map +1 -0
  298. package/dist/core/tool-result-proxy.d.ts +18 -0
  299. package/dist/core/tool-result-proxy.d.ts.map +1 -0
  300. package/dist/entropy/active.d.ts +7 -0
  301. package/dist/entropy/active.d.ts.map +1 -0
  302. package/dist/entropy/compiled-store.d.ts +16 -0
  303. package/dist/entropy/compiled-store.d.ts.map +1 -0
  304. package/dist/entropy/compiled-surface.d.ts +51 -0
  305. package/dist/entropy/compiled-surface.d.ts.map +1 -0
  306. package/dist/entropy/compiler.d.ts +28 -0
  307. package/dist/entropy/compiler.d.ts.map +1 -0
  308. package/dist/entropy/corpus.d.ts +22 -0
  309. package/dist/entropy/corpus.d.ts.map +1 -0
  310. package/dist/entropy/fingerprint.d.ts +9 -0
  311. package/dist/entropy/fingerprint.d.ts.map +1 -0
  312. package/dist/entropy/index.d.ts +15 -0
  313. package/dist/entropy/index.d.ts.map +1 -0
  314. package/dist/entropy/index.js +172 -0
  315. package/dist/entropy/index.js.map +7 -0
  316. package/dist/entropy/meter.d.ts +10 -0
  317. package/dist/entropy/meter.d.ts.map +1 -0
  318. package/dist/entropy/passes.d.ts +13 -0
  319. package/dist/entropy/passes.d.ts.map +1 -0
  320. package/dist/entropy/pool-store.d.ts +15 -0
  321. package/dist/entropy/pool-store.d.ts.map +1 -0
  322. package/dist/entropy/pool.d.ts +41 -0
  323. package/dist/entropy/pool.d.ts.map +1 -0
  324. package/dist/entropy/presentation.d.ts +13 -0
  325. package/dist/entropy/presentation.d.ts.map +1 -0
  326. package/dist/entropy/sessions.d.ts +47 -0
  327. package/dist/entropy/sessions.d.ts.map +1 -0
  328. package/dist/entropy/surface.d.ts +30 -0
  329. package/dist/entropy/surface.d.ts.map +1 -0
  330. package/dist/entropy/trial.d.ts +35 -0
  331. package/dist/entropy/trial.d.ts.map +1 -0
  332. package/dist/entropy/types.d.ts +158 -0
  333. package/dist/entropy/types.d.ts.map +1 -0
  334. package/dist/execution-service.d.ts +63 -0
  335. package/dist/execution-service.d.ts.map +1 -0
  336. package/dist/fabric-exec-arguments.d.ts +5 -0
  337. package/dist/fabric-exec-arguments.d.ts.map +1 -0
  338. package/dist/fabric-exec-tool.d.ts +8 -0
  339. package/dist/fabric-exec-tool.d.ts.map +1 -0
  340. package/dist/fabric-runtime-state.d.ts +90 -0
  341. package/dist/fabric-runtime-state.d.ts.map +1 -0
  342. package/dist/fabric-runtime-state.js +13060 -0
  343. package/dist/fabric-runtime-state.js.map +7 -0
  344. package/dist/fabric-state.d.ts +89 -0
  345. package/dist/fabric-state.d.ts.map +1 -0
  346. package/dist/failure-progress.d.ts +3 -0
  347. package/dist/failure-progress.d.ts.map +1 -0
  348. package/dist/host-compatibility.d.ts +5 -0
  349. package/dist/host-compatibility.d.ts.map +1 -0
  350. package/dist/index.d.ts +6 -0
  351. package/dist/index.d.ts.map +1 -0
  352. package/dist/index.js +5719 -0
  353. package/dist/index.js.map +7 -0
  354. package/dist/lifecycle/broker.d.ts +30 -0
  355. package/dist/lifecycle/broker.d.ts.map +1 -0
  356. package/dist/lifecycle/delivery-scheduler.d.ts +30 -0
  357. package/dist/lifecycle/delivery-scheduler.d.ts.map +1 -0
  358. package/dist/lifecycle/types.d.ts +91 -0
  359. package/dist/lifecycle/types.d.ts.map +1 -0
  360. package/dist/log-tail.d.ts +11 -0
  361. package/dist/log-tail.d.ts.map +1 -0
  362. package/dist/main-agent.d.ts +70 -0
  363. package/dist/main-agent.d.ts.map +1 -0
  364. package/dist/memory/context.d.ts +112 -0
  365. package/dist/memory/context.d.ts.map +1 -0
  366. package/dist/memory/digest.d.ts +48 -0
  367. package/dist/memory/digest.d.ts.map +1 -0
  368. package/dist/memory/digest.js +7 -0
  369. package/dist/memory/digest.js.map +7 -0
  370. package/dist/memory/discovery.d.ts +43 -0
  371. package/dist/memory/discovery.d.ts.map +1 -0
  372. package/dist/memory/discovery.js +23 -0
  373. package/dist/memory/discovery.js.map +7 -0
  374. package/dist/memory/index.d.ts +107 -0
  375. package/dist/memory/index.d.ts.map +1 -0
  376. package/dist/memory/lineage.d.ts +20 -0
  377. package/dist/memory/lineage.d.ts.map +1 -0
  378. package/dist/memory/normalize.d.ts +170 -0
  379. package/dist/memory/normalize.d.ts.map +1 -0
  380. package/dist/memory/normalize.js +22 -0
  381. package/dist/memory/normalize.js.map +7 -0
  382. package/dist/memory/regex.d.ts +19 -0
  383. package/dist/memory/regex.d.ts.map +1 -0
  384. package/dist/memory/search.d.ts +98 -0
  385. package/dist/memory/search.d.ts.map +1 -0
  386. package/dist/memory/search.js +22 -0
  387. package/dist/memory/search.js.map +7 -0
  388. package/dist/memory/tokenize.d.ts +24 -0
  389. package/dist/memory/tokenize.d.ts.map +1 -0
  390. package/dist/mesh/store.d.ts +78 -0
  391. package/dist/mesh/store.d.ts.map +1 -0
  392. package/dist/output-budget.d.ts +12 -0
  393. package/dist/output-budget.d.ts.map +1 -0
  394. package/dist/prewalk/arm.d.ts +8 -0
  395. package/dist/prewalk/arm.d.ts.map +1 -0
  396. package/dist/prewalk/controller.d.ts +60 -0
  397. package/dist/prewalk/controller.d.ts.map +1 -0
  398. package/dist/prewalk/fs-drift.d.ts +19 -0
  399. package/dist/prewalk/fs-drift.d.ts.map +1 -0
  400. package/dist/prewalk/handoff.d.ts +45 -0
  401. package/dist/prewalk/handoff.d.ts.map +1 -0
  402. package/dist/protocol.d.ts +273 -0
  403. package/dist/protocol.d.ts.map +1 -0
  404. package/dist/protocol.js +46 -0
  405. package/dist/protocol.js.map +7 -0
  406. package/dist/providers/agents-actions.d.ts +3 -0
  407. package/dist/providers/agents-actions.d.ts.map +1 -0
  408. package/dist/providers/agents-provider.d.ts +59 -0
  409. package/dist/providers/agents-provider.d.ts.map +1 -0
  410. package/dist/providers/arg-normalization.d.ts +15 -0
  411. package/dist/providers/arg-normalization.d.ts.map +1 -0
  412. package/dist/providers/captured-tools-provider.d.ts +23 -0
  413. package/dist/providers/captured-tools-provider.d.ts.map +1 -0
  414. package/dist/providers/compact-provider.d.ts +14 -0
  415. package/dist/providers/compact-provider.d.ts.map +1 -0
  416. package/dist/providers/components-provider.d.ts +12 -0
  417. package/dist/providers/components-provider.d.ts.map +1 -0
  418. package/dist/providers/mcp-descriptor-cache.d.ts +47 -0
  419. package/dist/providers/mcp-descriptor-cache.d.ts.map +1 -0
  420. package/dist/providers/mcp-provider.d.ts +27 -0
  421. package/dist/providers/mcp-provider.d.ts.map +1 -0
  422. package/dist/providers/memory-provider.d.ts +35 -0
  423. package/dist/providers/memory-provider.d.ts.map +1 -0
  424. package/dist/providers/memory-provider.js +16 -0
  425. package/dist/providers/memory-provider.js.map +7 -0
  426. package/dist/providers/mesh-provider.d.ts +17 -0
  427. package/dist/providers/mesh-provider.d.ts.map +1 -0
  428. package/dist/providers/omp-bash-cwd.d.ts +31 -0
  429. package/dist/providers/omp-bash-cwd.d.ts.map +1 -0
  430. package/dist/providers/omp-tools-provider.d.ts +15 -0
  431. package/dist/providers/omp-tools-provider.d.ts.map +1 -0
  432. package/dist/providers/schema-provider.d.ts +15 -0
  433. package/dist/providers/schema-provider.d.ts.map +1 -0
  434. package/dist/providers/state-provider.d.ts +16 -0
  435. package/dist/providers/state-provider.d.ts.map +1 -0
  436. package/dist/providers/write-diff-limits.d.ts +5 -0
  437. package/dist/providers/write-diff-limits.d.ts.map +1 -0
  438. package/dist/providers/write-preview.d.ts +3 -0
  439. package/dist/providers/write-preview.d.ts.map +1 -0
  440. package/dist/ref-names.d.ts +2 -0
  441. package/dist/ref-names.d.ts.map +1 -0
  442. package/dist/repairs/active.d.ts +7 -0
  443. package/dist/repairs/active.d.ts.map +1 -0
  444. package/dist/repairs/apply.d.ts +7 -0
  445. package/dist/repairs/apply.d.ts.map +1 -0
  446. package/dist/repairs/catalog-digest.d.ts +5 -0
  447. package/dist/repairs/catalog-digest.d.ts.map +1 -0
  448. package/dist/repairs/classify.d.ts +10 -0
  449. package/dist/repairs/classify.d.ts.map +1 -0
  450. package/dist/repairs/compiler.d.ts +33 -0
  451. package/dist/repairs/compiler.d.ts.map +1 -0
  452. package/dist/repairs/promote.d.ts +4 -0
  453. package/dist/repairs/promote.d.ts.map +1 -0
  454. package/dist/repairs/store.d.ts +10 -0
  455. package/dist/repairs/store.d.ts.map +1 -0
  456. package/dist/repairs/types.d.ts +49 -0
  457. package/dist/repairs/types.d.ts.map +1 -0
  458. package/dist/residency/actor-client.d.ts +16 -0
  459. package/dist/residency/actor-client.d.ts.map +1 -0
  460. package/dist/residency/actor-client.js +9 -0
  461. package/dist/residency/actor-client.js.map +7 -0
  462. package/dist/residency/client.d.ts +44 -0
  463. package/dist/residency/client.d.ts.map +1 -0
  464. package/dist/residency/host.d.ts +3 -0
  465. package/dist/residency/host.d.ts.map +1 -0
  466. package/dist/residency/host.js +25 -0
  467. package/dist/residency/host.js.map +7 -0
  468. package/dist/residency/launcher-owner.d.ts +7 -0
  469. package/dist/residency/launcher-owner.d.ts.map +1 -0
  470. package/dist/residency/launcher.d.ts +3 -0
  471. package/dist/residency/launcher.d.ts.map +1 -0
  472. package/dist/residency/launcher.js +152 -0
  473. package/dist/residency/launcher.js.map +7 -0
  474. package/dist/residency/omp-entry.d.ts +3 -0
  475. package/dist/residency/omp-entry.d.ts.map +1 -0
  476. package/dist/residency/omp-entry.js +41 -0
  477. package/dist/residency/omp-entry.js.map +7 -0
  478. package/dist/residency/protocol.d.ts +119 -0
  479. package/dist/residency/protocol.d.ts.map +1 -0
  480. package/dist/run-display.d.ts +3 -0
  481. package/dist/run-display.d.ts.map +1 -0
  482. package/dist/runtime/core-override-guest-types.d.ts +15 -0
  483. package/dist/runtime/core-override-guest-types.d.ts.map +1 -0
  484. package/dist/runtime/core-override-guest-types.js +291 -0
  485. package/dist/runtime/core-override-guest-types.js.map +7 -0
  486. package/dist/runtime/core-tool-properties.d.ts +6 -0
  487. package/dist/runtime/core-tool-properties.d.ts.map +1 -0
  488. package/dist/runtime/dynamic-guest-types.d.ts +3 -0
  489. package/dist/runtime/dynamic-guest-types.d.ts.map +1 -0
  490. package/dist/runtime/dynamic-guest-types.js +226 -0
  491. package/dist/runtime/dynamic-guest-types.js.map +7 -0
  492. package/dist/runtime/guest-code-repair.d.ts +2 -0
  493. package/dist/runtime/guest-code-repair.d.ts.map +1 -0
  494. package/dist/runtime/guest-stack-map.d.ts +11 -0
  495. package/dist/runtime/guest-stack-map.d.ts.map +1 -0
  496. package/dist/runtime/guest-types.d.ts +35 -0
  497. package/dist/runtime/guest-types.d.ts.map +1 -0
  498. package/dist/runtime/guest-types.js +13 -0
  499. package/dist/runtime/guest-types.js.map +7 -0
  500. package/dist/runtime/node-process-child-source.d.ts +2 -0
  501. package/dist/runtime/node-process-child-source.d.ts.map +1 -0
  502. package/dist/runtime/node-process-runtime.d.ts +10 -0
  503. package/dist/runtime/node-process-runtime.d.ts.map +1 -0
  504. package/dist/runtime/node-process-runtime.js +319 -0
  505. package/dist/runtime/node-process-runtime.js.map +7 -0
  506. package/dist/runtime/orchestration.d.ts +3 -0
  507. package/dist/runtime/orchestration.d.ts.map +1 -0
  508. package/dist/runtime/quickjs-runtime.d.ts +24 -0
  509. package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
  510. package/dist/runtime/quickjs-runtime.js +12 -0
  511. package/dist/runtime/quickjs-runtime.js.map +7 -0
  512. package/dist/runtime/type-checker.d.ts +21 -0
  513. package/dist/runtime/type-checker.d.ts.map +1 -0
  514. package/dist/runtime/type-checker.js +15 -0
  515. package/dist/runtime/type-checker.js.map +7 -0
  516. package/dist/runtime-paths.d.ts +7 -0
  517. package/dist/runtime-paths.d.ts.map +1 -0
  518. package/dist/schema/controller.d.ts +35 -0
  519. package/dist/schema/controller.d.ts.map +1 -0
  520. package/dist/schema/types.d.ts +86 -0
  521. package/dist/schema/types.d.ts.map +1 -0
  522. package/dist/schema/workspace.d.ts +19 -0
  523. package/dist/schema/workspace.d.ts.map +1 -0
  524. package/dist/speculation/eligibility.d.ts +22 -0
  525. package/dist/speculation/eligibility.d.ts.map +1 -0
  526. package/dist/speculation/freshness.d.ts +10 -0
  527. package/dist/speculation/freshness.d.ts.map +1 -0
  528. package/dist/speculation/partial-json.d.ts +9 -0
  529. package/dist/speculation/partial-json.d.ts.map +1 -0
  530. package/dist/speculation/scanner.d.ts +13 -0
  531. package/dist/speculation/scanner.d.ts.map +1 -0
  532. package/dist/speculation/scanner.js +182 -0
  533. package/dist/speculation/scanner.js.map +7 -0
  534. package/dist/speculation/store.d.ts +39 -0
  535. package/dist/speculation/store.d.ts.map +1 -0
  536. package/dist/speculation/stream-tap.d.ts +27 -0
  537. package/dist/speculation/stream-tap.d.ts.map +1 -0
  538. package/dist/speculation/types.d.ts +44 -0
  539. package/dist/speculation/types.d.ts.map +1 -0
  540. package/dist/state/complexity.d.ts +13 -0
  541. package/dist/state/complexity.d.ts.map +1 -0
  542. package/dist/state/evidence-runner.d.ts +17 -0
  543. package/dist/state/evidence-runner.d.ts.map +1 -0
  544. package/dist/state/store.d.ts +76 -0
  545. package/dist/state/store.d.ts.map +1 -0
  546. package/dist/state/types.d.ts +165 -0
  547. package/dist/state/types.d.ts.map +1 -0
  548. package/dist/storage/retention.d.ts +22 -0
  549. package/dist/storage/retention.d.ts.map +1 -0
  550. package/dist/thinking.d.ts +19 -0
  551. package/dist/thinking.d.ts.map +1 -0
  552. package/dist/topology/control-plane.d.ts +58 -0
  553. package/dist/topology/control-plane.d.ts.map +1 -0
  554. package/dist/topology/participant-directory.d.ts +33 -0
  555. package/dist/topology/participant-directory.d.ts.map +1 -0
  556. package/dist/topology/peer-settle.d.ts +51 -0
  557. package/dist/topology/peer-settle.d.ts.map +1 -0
  558. package/dist/topology/records.d.ts +6 -0
  559. package/dist/topology/records.d.ts.map +1 -0
  560. package/dist/topology/types.d.ts +89 -0
  561. package/dist/topology/types.d.ts.map +1 -0
  562. package/dist/type-error-guidance.d.ts +3 -0
  563. package/dist/type-error-guidance.d.ts.map +1 -0
  564. package/dist/ui/arc-group.d.ts +17 -0
  565. package/dist/ui/arc-group.d.ts.map +1 -0
  566. package/dist/ui/code-preview-shell.d.ts +26 -0
  567. package/dist/ui/code-preview-shell.d.ts.map +1 -0
  568. package/dist/ui/code-preview.d.ts +53 -0
  569. package/dist/ui/code-preview.d.ts.map +1 -0
  570. package/dist/ui/controller.d.ts +20 -0
  571. package/dist/ui/controller.d.ts.map +1 -0
  572. package/dist/ui/conversation-chrome.d.ts +15 -0
  573. package/dist/ui/conversation-chrome.d.ts.map +1 -0
  574. package/dist/ui/conversation-chrome.js +10 -0
  575. package/dist/ui/conversation-chrome.js.map +7 -0
  576. package/dist/ui/conversation-native-reader.d.ts +106 -0
  577. package/dist/ui/conversation-native-reader.d.ts.map +1 -0
  578. package/dist/ui/conversation-native-reader.js +784 -0
  579. package/dist/ui/conversation-native-reader.js.map +7 -0
  580. package/dist/ui/conversation-queue-store.d.ts +12 -0
  581. package/dist/ui/conversation-queue-store.d.ts.map +1 -0
  582. package/dist/ui/conversation-queue.d.ts +242 -0
  583. package/dist/ui/conversation-queue.d.ts.map +1 -0
  584. package/dist/ui/conversation-render.d.ts +45 -0
  585. package/dist/ui/conversation-render.d.ts.map +1 -0
  586. package/dist/ui/conversation-shortcut.d.ts +3 -0
  587. package/dist/ui/conversation-shortcut.d.ts.map +1 -0
  588. package/dist/ui/conversation-targets.d.ts +7 -0
  589. package/dist/ui/conversation-targets.d.ts.map +1 -0
  590. package/dist/ui/conversation-targets.js +12 -0
  591. package/dist/ui/conversation-targets.js.map +7 -0
  592. package/dist/ui/conversation-transcript.d.ts +25 -0
  593. package/dist/ui/conversation-transcript.d.ts.map +1 -0
  594. package/dist/ui/conversation.d.ts +170 -0
  595. package/dist/ui/conversation.d.ts.map +1 -0
  596. package/dist/ui/conversation.js +1868 -0
  597. package/dist/ui/conversation.js.map +7 -0
  598. package/dist/ui/core-tool-render.d.ts +20 -0
  599. package/dist/ui/core-tool-render.d.ts.map +1 -0
  600. package/dist/ui/dashboard-detail.d.ts +68 -0
  601. package/dist/ui/dashboard-detail.d.ts.map +1 -0
  602. package/dist/ui/dashboard-fabric-graph.d.ts +50 -0
  603. package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -0
  604. package/dist/ui/dashboard-model.d.ts +111 -0
  605. package/dist/ui/dashboard-model.d.ts.map +1 -0
  606. package/dist/ui/dashboard-presentation.d.ts +6 -0
  607. package/dist/ui/dashboard-presentation.d.ts.map +1 -0
  608. package/dist/ui/dashboard.d.ts +188 -0
  609. package/dist/ui/dashboard.d.ts.map +1 -0
  610. package/dist/ui/dashboard.js +4604 -0
  611. package/dist/ui/dashboard.js.map +7 -0
  612. package/dist/ui/diff-background.d.ts +12 -0
  613. package/dist/ui/diff-background.d.ts.map +1 -0
  614. package/dist/ui/dynamic-border.d.ts +8 -0
  615. package/dist/ui/dynamic-border.d.ts.map +1 -0
  616. package/dist/ui/escape-halt.d.ts +11 -0
  617. package/dist/ui/escape-halt.d.ts.map +1 -0
  618. package/dist/ui/fabric-actor-delivery-selector.d.ts +17 -0
  619. package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -0
  620. package/dist/ui/fabric-actor-tool-selector.d.ts +22 -0
  621. package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -0
  622. package/dist/ui/fabric-code-parser.d.ts +8 -0
  623. package/dist/ui/fabric-code-parser.d.ts.map +1 -0
  624. package/dist/ui/fabric-host-event-selector.d.ts +29 -0
  625. package/dist/ui/fabric-host-event-selector.d.ts.map +1 -0
  626. package/dist/ui/fabric-model-selector.d.ts +64 -0
  627. package/dist/ui/fabric-model-selector.d.ts.map +1 -0
  628. package/dist/ui/fabric-render.d.ts +113 -0
  629. package/dist/ui/fabric-render.d.ts.map +1 -0
  630. package/dist/ui/fabric-thinking-selector.d.ts +26 -0
  631. package/dist/ui/fabric-thinking-selector.d.ts.map +1 -0
  632. package/dist/ui/fabric-title-hint.d.ts +2 -0
  633. package/dist/ui/fabric-title-hint.d.ts.map +1 -0
  634. package/dist/ui/format.d.ts +9 -0
  635. package/dist/ui/format.d.ts.map +1 -0
  636. package/dist/ui/highlight.d.ts +69 -0
  637. package/dist/ui/highlight.d.ts.map +1 -0
  638. package/dist/ui/model-picker.d.ts +46 -0
  639. package/dist/ui/model-picker.d.ts.map +1 -0
  640. package/dist/ui/model-picker.js +17 -0
  641. package/dist/ui/model-picker.js.map +7 -0
  642. package/dist/ui/preview-lines.d.ts +16 -0
  643. package/dist/ui/preview-lines.d.ts.map +1 -0
  644. package/dist/ui/row-balance.d.ts +29 -0
  645. package/dist/ui/row-balance.d.ts.map +1 -0
  646. package/dist/ui/settings.d.ts +57 -0
  647. package/dist/ui/settings.d.ts.map +1 -0
  648. package/dist/ui/settings.js +1908 -0
  649. package/dist/ui/settings.js.map +7 -0
  650. package/dist/ui/shiki-language.d.ts +7 -0
  651. package/dist/ui/shiki-language.d.ts.map +1 -0
  652. package/dist/ui/shiki-theme.d.ts +7 -0
  653. package/dist/ui/shiki-theme.d.ts.map +1 -0
  654. package/dist/ui/snapshot.d.ts +7 -0
  655. package/dist/ui/snapshot.d.ts.map +1 -0
  656. package/dist/ui/spinner.d.ts +6 -0
  657. package/dist/ui/spinner.d.ts.map +1 -0
  658. package/dist/ui/state-file-preview.d.ts +13 -0
  659. package/dist/ui/state-file-preview.d.ts.map +1 -0
  660. package/dist/ui/structured.d.ts +9 -0
  661. package/dist/ui/structured.d.ts.map +1 -0
  662. package/dist/ui/symbol-theme.d.ts +3 -0
  663. package/dist/ui/symbol-theme.d.ts.map +1 -0
  664. package/dist/ui/tool-call-timing.d.ts +2 -0
  665. package/dist/ui/tool-call-timing.d.ts.map +1 -0
  666. package/dist/ui/tool-display.d.ts +8 -0
  667. package/dist/ui/tool-display.d.ts.map +1 -0
  668. package/dist/ui/topology.d.ts +162 -0
  669. package/dist/ui/topology.d.ts.map +1 -0
  670. package/dist/ui/transcript-parser.d.ts +18 -0
  671. package/dist/ui/transcript-parser.d.ts.map +1 -0
  672. package/dist/ui/transcript-reader.d.ts +10 -0
  673. package/dist/ui/transcript-reader.d.ts.map +1 -0
  674. package/dist/ui/transcript-sanitization.d.ts +14 -0
  675. package/dist/ui/transcript-sanitization.d.ts.map +1 -0
  676. package/dist/ui/transcript.d.ts +52 -0
  677. package/dist/ui/transcript.d.ts.map +1 -0
  678. package/dist/ui/types.d.ts +84 -0
  679. package/dist/ui/types.d.ts.map +1 -0
  680. package/dist/ui/widget.d.ts +16 -0
  681. package/dist/ui/widget.d.ts.map +1 -0
  682. package/dist/ui/word-diff/alignment.d.ts +6 -0
  683. package/dist/ui/word-diff/alignment.d.ts.map +1 -0
  684. package/dist/ui/word-diff/change-block.d.ts +18 -0
  685. package/dist/ui/word-diff/change-block.d.ts.map +1 -0
  686. package/dist/ui/word-diff/changed-line.d.ts +14 -0
  687. package/dist/ui/word-diff/changed-line.d.ts.map +1 -0
  688. package/dist/ui/word-diff/emphasis.d.ts +9 -0
  689. package/dist/ui/word-diff/emphasis.d.ts.map +1 -0
  690. package/dist/ui/word-diff/line-emphasis.d.ts +7 -0
  691. package/dist/ui/word-diff/line-emphasis.d.ts.map +1 -0
  692. package/dist/ui/word-diff/line-matching.d.ts +10 -0
  693. package/dist/ui/word-diff/line-matching.d.ts.map +1 -0
  694. package/dist/ui/word-diff/line-similarity.d.ts +16 -0
  695. package/dist/ui/word-diff/line-similarity.d.ts.map +1 -0
  696. package/dist/ui/word-diff/normalize.d.ts +3 -0
  697. package/dist/ui/word-diff/normalize.d.ts.map +1 -0
  698. package/dist/ui/word-diff/parse.d.ts +17 -0
  699. package/dist/ui/word-diff/parse.d.ts.map +1 -0
  700. package/dist/ui/word-diff/range-refinement.d.ts +5 -0
  701. package/dist/ui/word-diff/range-refinement.d.ts.map +1 -0
  702. package/dist/ui/word-diff/ranges.d.ts +11 -0
  703. package/dist/ui/word-diff/ranges.d.ts.map +1 -0
  704. package/dist/ui/word-diff/smart-filter.d.ts +3 -0
  705. package/dist/ui/word-diff/smart-filter.d.ts.map +1 -0
  706. package/dist/ui/word-diff/sparse-line-matching.d.ts +25 -0
  707. package/dist/ui/word-diff/sparse-line-matching.d.ts.map +1 -0
  708. package/dist/ui/word-diff/text-boundaries.d.ts +11 -0
  709. package/dist/ui/word-diff/text-boundaries.d.ts.map +1 -0
  710. package/dist/ui/word-diff/token-alignment.d.ts +9 -0
  711. package/dist/ui/word-diff/token-alignment.d.ts.map +1 -0
  712. package/dist/ui/word-diff/token-text-refinement.d.ts +4 -0
  713. package/dist/ui/word-diff/token-text-refinement.d.ts.map +1 -0
  714. package/dist/ui/word-diff/tokens.d.ts +16 -0
  715. package/dist/ui/word-diff/tokens.d.ts.map +1 -0
  716. package/dist/ui/word-diff/types.d.ts +10 -0
  717. package/dist/ui/word-diff/types.d.ts.map +1 -0
  718. package/dist/util.d.ts +3 -0
  719. package/dist/util.d.ts.map +1 -0
  720. package/dist/worker/options.d.ts +3 -0
  721. package/dist/worker/options.d.ts.map +1 -0
  722. package/dist/worker/options.js +104 -0
  723. package/dist/worker/options.js.map +7 -0
  724. package/dist/worker/run-record.d.ts +22 -0
  725. package/dist/worker/run-record.d.ts.map +1 -0
  726. package/dist/worker/run-record.js +123 -0
  727. package/dist/worker/run-record.js.map +7 -0
  728. package/dist/worker/session-export.d.ts +45 -0
  729. package/dist/worker/session-export.d.ts.map +1 -0
  730. package/dist/worker/session-export.js +91 -0
  731. package/dist/worker/session-export.js.map +7 -0
  732. package/dist/worker.d.ts +3 -0
  733. package/dist/worker.d.ts.map +1 -0
  734. package/dist/worker.js +1061 -0
  735. package/dist/worker.js.map +7 -0
  736. package/docs/agents.md +564 -0
  737. package/docs/architecture.md +139 -0
  738. package/docs/audit-trace.md +116 -0
  739. package/docs/certification.md +134 -0
  740. package/docs/compaction.md +332 -0
  741. package/docs/component-calculus.md +191 -0
  742. package/docs/components.md +329 -0
  743. package/docs/configuration.md +478 -0
  744. package/docs/entropy.md +396 -0
  745. package/docs/interface.md +149 -0
  746. package/docs/memory-recall.md +614 -0
  747. package/docs/programmatic-compaction.md +207 -0
  748. package/docs/provider-component-calculus.md +378 -0
  749. package/docs/providers.md +109 -0
  750. package/docs/repairs.md +69 -0
  751. package/docs/residency-runtime.md +82 -0
  752. package/docs/schema-enforcement.md +166 -0
  753. package/docs/skills.md +48 -0
  754. package/docs/speculation.md +132 -0
  755. package/docs/state-layer.md +197 -0
  756. package/package.json +116 -0
  757. package/skills/fabric-advisor/SKILL.md +29 -0
  758. package/skills/fabric-ambient/SKILL.md +44 -0
  759. package/skills/fabric-ambient/references/setup.md +90 -0
  760. package/skills/fabric-council/SKILL.md +94 -0
  761. package/skills/fabric-exec/SKILL.md +123 -0
  762. package/skills/fabric-exec/references/agents.md +211 -0
  763. package/skills/fabric-exec/references/mcp.md +49 -0
  764. package/skills/fabric-exec/references/mesh.md +51 -0
  765. package/skills/fabric-fusion/SKILL.md +332 -0
  766. package/skills/fabric-guide/SKILL.md +28 -0
  767. package/skills/fabric-rlm/SKILL.md +284 -0
  768. package/skills/fabric-schema/SKILL.md +121 -0
  769. package/skills/fabric-spec/SKILL.md +42 -0
  770. package/skills/fabric-supervisor/SKILL.md +37 -0
  771. package/skills/fabric-swarm/SKILL.md +80 -0
  772. package/skills/fabric-workflow/SKILL.md +133 -0
@@ -0,0 +1,1229 @@
1
+ import {
2
+ compareLexical,
3
+ foldSessionDigest,
4
+ lexicalTermCounts,
5
+ normalizeMemoryPhrase,
6
+ planMemoryQuery,
7
+ tokenizeLexical
8
+ } from "./chunk-U5FYOMG5.js";
9
+ import {
10
+ DEFAULT_MEMORY_INDEX_PRIVACY,
11
+ normalizeSession
12
+ } from "./chunk-6QBPSZJ5.js";
13
+
14
+ // src/memory/index.ts
15
+ import crypto2 from "node:crypto";
16
+ import fs2 from "node:fs";
17
+ import path from "node:path";
18
+
19
+ // src/memory/lineage.ts
20
+ import crypto from "node:crypto";
21
+ import fs from "node:fs";
22
+ var fingerprint = (branches, leafId, ids) => crypto.createHash("sha256").update(JSON.stringify({ branches, leafId, ids })).digest("hex");
23
+ var readPersistedNodes = (sessionFile) => {
24
+ let content;
25
+ try {
26
+ content = fs.readFileSync(sessionFile, "utf8");
27
+ } catch {
28
+ return [];
29
+ }
30
+ const nodes = [];
31
+ let ordinal = 0;
32
+ for (const line of content.split("\n")) {
33
+ if (!line.trim()) continue;
34
+ let raw;
35
+ try {
36
+ raw = JSON.parse(line);
37
+ } catch {
38
+ continue;
39
+ }
40
+ if (raw.type === "session") continue;
41
+ if (typeof raw.id === "string" && (raw.parentId === null || typeof raw.parentId === "string")) {
42
+ nodes.push({ id: raw.id, parentId: raw.parentId, ordinal });
43
+ }
44
+ ordinal += 1;
45
+ }
46
+ return nodes;
47
+ };
48
+ var allLineage = () => ({
49
+ branches: "all",
50
+ leafId: null,
51
+ entryOrdinals: null,
52
+ fingerprint: fingerprint("all", null, []),
53
+ coverageReasons: []
54
+ });
55
+ var reconstructSessionLineage = (sessionFile, branches, liveBranch) => {
56
+ if (branches === "all") return allLineage();
57
+ const nodes = readPersistedNodes(sessionFile);
58
+ const byId = new Map(nodes.map((node) => [node.id, node]));
59
+ const liveIds = liveBranch?.entries.flatMap((entry) => {
60
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) return [];
61
+ const id = entry.id;
62
+ return typeof id === "string" ? [id] : [];
63
+ });
64
+ const leafId = liveBranch ? liveBranch.leafId : nodes[nodes.length - 1]?.id ?? null;
65
+ const path2 = [];
66
+ const reasons = /* @__PURE__ */ new Set();
67
+ if (liveIds) {
68
+ for (const id of liveIds) {
69
+ const node = byId.get(id);
70
+ if (node) path2.push(node);
71
+ }
72
+ } else {
73
+ const seen = /* @__PURE__ */ new Set();
74
+ let current = leafId ? byId.get(leafId) : void 0;
75
+ while (current) {
76
+ if (seen.has(current.id)) {
77
+ reasons.add("invalid_parent_graph");
78
+ break;
79
+ }
80
+ seen.add(current.id);
81
+ path2.push(current);
82
+ current = current.parentId ? byId.get(current.parentId) : void 0;
83
+ }
84
+ path2.reverse();
85
+ }
86
+ const ids = liveIds ?? path2.map((node) => node.id);
87
+ return {
88
+ branches: "active",
89
+ leafId,
90
+ entryOrdinals: new Set(path2.map((node) => node.ordinal)),
91
+ fingerprint: fingerprint("active", leafId, ids),
92
+ coverageReasons: [...reasons].sort()
93
+ };
94
+ };
95
+
96
+ // src/memory/index.ts
97
+ var MEMORY_CACHE_VERSION = 6;
98
+ var DEFAULT_HOT_SESSIONS = 50;
99
+ var DEFAULT_MAX_COLD_VOCABULARY_BYTES = 512 * 1024;
100
+ var DEFAULT_MAX_COLD_CACHE_BYTES = 1024 * 1024;
101
+ var DEFAULT_MAX_SYNC_SESSIONS = 1e4;
102
+ var DEFAULT_MAX_SYNC_SOURCE_BYTES = 512 * 1024 * 1024;
103
+ var DEFAULT_MAX_CACHE_CLEANUP_FILES = 1e5;
104
+ var cacheBaseName = (sessionFile) => {
105
+ const hash = crypto2.createHash("sha1").update(sessionFile).digest("hex").slice(0, 16);
106
+ const safeBase = path.basename(sessionFile).replace(/[^a-zA-Z0-9._-]/g, "_");
107
+ return `${hash}-${safeBase}`;
108
+ };
109
+ var cacheModeSuffix = (branches) => branches === "all" ? ".all" : "";
110
+ var shardPathForSession = (sessionFile, indexDir, branches = "active") => path.join(indexDir, `${cacheBaseName(sessionFile)}${cacheModeSuffix(branches)}.json`);
111
+ var digestPathForSession = (sessionFile, indexDir, branches = "active") => path.join(indexDir, `${cacheBaseName(sessionFile)}${cacheModeSuffix(branches)}.digest.json`);
112
+ var policyPrivacy = (options) => `thinking:${options.indexThinking ?? DEFAULT_MEMORY_INDEX_PRIVACY.indexThinking};tool-output:${options.indexToolOutput ?? DEFAULT_MEMORY_INDEX_PRIVACY.indexToolOutput}`;
113
+ var shardPolicy = (options, lineage) => `entry:${options.maxEntryChars};branches:${lineage.branches};lineage:${lineage.fingerprint};${policyPrivacy(options)}`;
114
+ var digestPolicy = (options, lineage) => `vocab:${options.maxColdVocabularyBytes ?? DEFAULT_MAX_COLD_VOCABULARY_BYTES};cache:${options.maxColdCacheBytes ?? DEFAULT_MAX_COLD_CACHE_BYTES};branches:${lineage.branches};lineage:${lineage.fingerprint};${policyPrivacy(options)}`;
115
+ var resolveLineage = (sessionFile, options) => reconstructSessionLineage(
116
+ sessionFile,
117
+ options.branches ?? "active",
118
+ options.liveBranchForFile?.(sessionFile)
119
+ );
120
+ var normalizationOptions = (options, lineage) => ({
121
+ lineage,
122
+ indexThinking: options.indexThinking ?? DEFAULT_MEMORY_INDEX_PRIVACY.indexThinking,
123
+ indexToolOutput: options.indexToolOutput ?? DEFAULT_MEMORY_INDEX_PRIVACY.indexToolOutput
124
+ });
125
+ var readShardFile = (filePath, maxBytes = DEFAULT_MAX_SYNC_SOURCE_BYTES) => {
126
+ try {
127
+ const stat = fs2.statSync(filePath);
128
+ if (!stat.isFile() || stat.size > maxBytes) return null;
129
+ const parsed = JSON.parse(fs2.readFileSync(filePath, "utf8"));
130
+ if (parsed.cacheVersion !== MEMORY_CACHE_VERSION || parsed.kind !== "shard" || typeof parsed.sessionFile !== "string" || typeof parsed.sessionId !== "string" || typeof parsed.sourceHash !== "string" || parsed.sourceHash.length !== 64 || parsed.branches !== "active" && parsed.branches !== "all" || typeof parsed.lineageFingerprint !== "string" || parsed.lineageFingerprint.length !== 64 || typeof parsed.policy !== "string" || typeof parsed.cacheBytes !== "number" || parsed.cacheBytes !== stat.size || typeof parsed.cacheSourceRatio !== "number" || typeof parsed.totalEntryCount !== "number" || typeof parsed.indexCoverage !== "object" || parsed.indexCoverage === null || typeof parsed.indexCoverage.complete !== "boolean" || !Array.isArray(parsed.indexCoverage.reasons) || !parsed.indexCoverage.reasons.every((reason) => typeof reason === "string") || !Array.isArray(parsed.entries) || !parsed.entries.every((entry) => entry !== null && typeof entry === "object" && typeof entry.index === "number" && typeof entry.sessionFile === "string" && typeof entry.text === "string")) return null;
131
+ return parsed;
132
+ } catch {
133
+ return null;
134
+ }
135
+ };
136
+ var readDigestFile = (filePath, maxBytes = DEFAULT_MAX_COLD_CACHE_BYTES) => {
137
+ try {
138
+ const stat = fs2.statSync(filePath);
139
+ if (!stat.isFile() || stat.size > maxBytes) return null;
140
+ const parsed = JSON.parse(fs2.readFileSync(filePath, "utf8"));
141
+ if (parsed.cacheVersion !== MEMORY_CACHE_VERSION || parsed.kind !== "digest" || typeof parsed.sessionId !== "string" || typeof parsed.file !== "string" || typeof parsed.sourceHash !== "string" || parsed.sourceHash.length !== 64 || parsed.branches !== "active" && parsed.branches !== "all" || typeof parsed.lineageFingerprint !== "string" || parsed.lineageFingerprint.length !== 64 || typeof parsed.policy !== "string" || typeof parsed.cacheBytes !== "number" || parsed.cacheBytes !== stat.size || typeof parsed.cacheSourceRatio !== "number" || !Array.isArray(parsed.filesTouched) || !Array.isArray(parsed.vocabulary) || !parsed.vocabulary.every((term, index) => typeof term === "string" && (index === 0 || parsed.vocabulary[index - 1] < term)) || !Array.isArray(parsed.addresses) || !parsed.addresses.every((address) => Array.isArray(address) && address.length === 10 && typeof address[0] === "number" && (address[1] === null || typeof address[1] === "string") && (address[2] === null || typeof address[2] === "string") && (address[3] === null || typeof address[3] === "string") && (address[4] === null || typeof address[4] === "string") && (address[5] === null || typeof address[5] === "number") && (address[6] === null || typeof address[6] === "string") && (address[7] === null || typeof address[7] === "string") && (address[8] === null || typeof address[8] === "string") && (address[9] === null || address[9] === "succeeded" || address[9] === "failed" || address[9] === "aborted" || address[9] === "timed_out")) || typeof parsed.indexCoverage !== "object" || parsed.indexCoverage === null || typeof parsed.indexCoverage.complete !== "boolean" || typeof parsed.indexCoverage.vocabularyBytes !== "number" || !Array.isArray(parsed.indexCoverage.reasons) || !parsed.indexCoverage.reasons.every((reason) => typeof reason === "string") || typeof parsed.mtime !== "number" || typeof parsed.size !== "number") return null;
142
+ return parsed;
143
+ } catch {
144
+ return null;
145
+ }
146
+ };
147
+ var serializedBytes = (value) => Buffer.byteLength(JSON.stringify(value), "utf8");
148
+ var applyCacheMetrics = (value) => {
149
+ let previous = -1;
150
+ for (let iteration = 0; iteration < 5; iteration += 1) {
151
+ const bytes = serializedBytes(value);
152
+ value.cacheBytes = bytes;
153
+ value.cacheSourceRatio = value.size === 0 ? 0 : Number((bytes / value.size).toFixed(6));
154
+ if (bytes === previous) break;
155
+ previous = bytes;
156
+ }
157
+ value.cacheBytes = serializedBytes(value);
158
+ value.cacheSourceRatio = value.size === 0 ? 0 : Number((value.cacheBytes / value.size).toFixed(6));
159
+ return value;
160
+ };
161
+ var writeCacheFile = (filePath, value) => {
162
+ try {
163
+ fs2.mkdirSync(path.dirname(filePath), { recursive: true, mode: 448 });
164
+ try {
165
+ fs2.chmodSync(path.dirname(filePath), 448);
166
+ } catch {
167
+ }
168
+ fs2.writeFileSync(filePath, JSON.stringify(value), { encoding: "utf8", mode: 384 });
169
+ try {
170
+ fs2.chmodSync(filePath, 384);
171
+ } catch {
172
+ }
173
+ return true;
174
+ } catch {
175
+ return false;
176
+ }
177
+ };
178
+ var removeCacheFile = (filePath) => {
179
+ try {
180
+ fs2.rmSync(filePath, { force: true, recursive: true });
181
+ } catch {
182
+ }
183
+ };
184
+ var fingerprintSource = (file) => {
185
+ try {
186
+ const content = fs2.readFileSync(file);
187
+ const stat = fs2.statSync(file);
188
+ if (!stat.isFile()) return null;
189
+ return {
190
+ mtime: stat.mtimeMs,
191
+ size: stat.size,
192
+ sourceHash: crypto2.createHash("sha256").update(content).digest("hex")
193
+ };
194
+ } catch {
195
+ return null;
196
+ }
197
+ };
198
+ var isCacheFresh = (cache, state, policy) => cache !== null && cache.mtime === state.mtime && cache.size === state.size && cache.sourceHash === state.sourceHash && cache.policy === policy;
199
+ var missingShard = (ref, lineage, reason = "source_unavailable") => ({
200
+ cacheVersion: MEMORY_CACHE_VERSION,
201
+ kind: "shard",
202
+ sessionFile: ref.file,
203
+ sessionId: ref.id,
204
+ mtime: 0,
205
+ size: 0,
206
+ sourceHash: "",
207
+ branches: lineage.branches,
208
+ lineageFingerprint: lineage.fingerprint,
209
+ policy: reason,
210
+ cacheBytes: 0,
211
+ cacheSourceRatio: 0,
212
+ entries: [],
213
+ totalEntryCount: 0,
214
+ indexCoverage: { complete: false, reasons: [reason] },
215
+ tier: "hot",
216
+ indexReason: reason
217
+ });
218
+ var loadShard = (ref, options) => {
219
+ const lineage = resolveLineage(ref.file, options);
220
+ const filePath = shardPathForSession(ref.file, options.indexDir, lineage.branches);
221
+ const state = fingerprintSource(ref.file);
222
+ if (!state) {
223
+ removeCacheFile(filePath);
224
+ return missingShard(ref, lineage);
225
+ }
226
+ const policy = shardPolicy(options, lineage);
227
+ const cached = readShardFile(
228
+ filePath,
229
+ options.maxSyncSourceBytes ?? DEFAULT_MAX_SYNC_SOURCE_BYTES
230
+ );
231
+ if (isCacheFresh(cached, state, policy) && cached?.sessionFile === ref.file) return cached;
232
+ if (fs2.existsSync(filePath)) removeCacheFile(filePath);
233
+ const { entries, header, indexCoverage } = normalizeSession(
234
+ ref.file,
235
+ options.maxEntryChars,
236
+ normalizationOptions(options, lineage)
237
+ );
238
+ const finalState = fingerprintSource(ref.file);
239
+ const finalLineage = resolveLineage(ref.file, options);
240
+ if (!finalState || finalState.sourceHash !== state.sourceHash || finalLineage.fingerprint !== lineage.fingerprint) {
241
+ removeCacheFile(filePath);
242
+ return missingShard(
243
+ ref,
244
+ finalLineage,
245
+ finalState?.sourceHash === state.sourceHash ? "lineage_changed_during_index" : "source_changed_during_index"
246
+ );
247
+ }
248
+ const shard = applyCacheMetrics({
249
+ cacheVersion: MEMORY_CACHE_VERSION,
250
+ kind: "shard",
251
+ sessionFile: ref.file,
252
+ sessionId: header?.sessionId ?? ref.id,
253
+ ...state,
254
+ branches: lineage.branches,
255
+ lineageFingerprint: lineage.fingerprint,
256
+ policy,
257
+ cacheBytes: 0,
258
+ cacheSourceRatio: 0,
259
+ entries,
260
+ totalEntryCount: entries.length,
261
+ indexCoverage,
262
+ tier: "hot"
263
+ });
264
+ writeCacheFile(filePath, shard);
265
+ return shard;
266
+ };
267
+ var hydrateShard = (ref, options, entryRange) => {
268
+ const lineage = resolveLineage(ref.file, options);
269
+ const state = fingerprintSource(ref.file);
270
+ if (!state) return { ...missingShard(ref, lineage), tier: "cold" };
271
+ const { entries, header, indexCoverage } = normalizeSession(
272
+ ref.file,
273
+ options.maxEntryChars,
274
+ normalizationOptions(options, lineage)
275
+ );
276
+ const finalState = fingerprintSource(ref.file);
277
+ const finalLineage = resolveLineage(ref.file, options);
278
+ if (!finalState || finalState.sourceHash !== state.sourceHash || finalLineage.fingerprint !== lineage.fingerprint) {
279
+ return {
280
+ ...missingShard(
281
+ ref,
282
+ finalLineage,
283
+ finalState?.sourceHash === state.sourceHash ? "lineage_changed_during_index" : "source_changed_during_index"
284
+ ),
285
+ tier: "cold"
286
+ };
287
+ }
288
+ const selected = entryRange ? entries.filter((entry) => entry.index >= entryRange.first && entry.index <= entryRange.last) : entries;
289
+ return {
290
+ cacheVersion: MEMORY_CACHE_VERSION,
291
+ kind: "shard",
292
+ sessionFile: ref.file,
293
+ sessionId: header?.sessionId ?? ref.id,
294
+ ...state,
295
+ branches: lineage.branches,
296
+ lineageFingerprint: lineage.fingerprint,
297
+ policy: shardPolicy(options, lineage),
298
+ cacheBytes: 0,
299
+ cacheSourceRatio: 0,
300
+ entries: selected,
301
+ totalEntryCount: entries.length,
302
+ indexCoverage,
303
+ tier: "cold"
304
+ };
305
+ };
306
+ var missingDigest = (ref, lineage, reason = "source_unavailable") => ({
307
+ cacheVersion: MEMORY_CACHE_VERSION,
308
+ kind: "digest",
309
+ sessionId: ref.id,
310
+ file: ref.file,
311
+ cwd: ref.cwd,
312
+ firstTs: null,
313
+ lastTs: null,
314
+ entryCount: 0,
315
+ filesTouched: [],
316
+ toolHistogram: {},
317
+ errorCount: 0,
318
+ vocabulary: [],
319
+ addresses: [],
320
+ indexCoverage: { complete: false, vocabularyBytes: 2, reasons: [reason] },
321
+ mtime: 0,
322
+ size: 0,
323
+ sourceHash: "",
324
+ branches: lineage.branches,
325
+ lineageFingerprint: lineage.fingerprint,
326
+ policy: reason,
327
+ cacheBytes: 0,
328
+ cacheSourceRatio: 0
329
+ });
330
+ var maxFittingPrefix = (values, fits) => {
331
+ let low = 0;
332
+ let high = values.length;
333
+ while (low < high) {
334
+ const middle = Math.ceil((low + high) / 2);
335
+ if (fits(values.slice(0, middle))) low = middle;
336
+ else high = middle - 1;
337
+ }
338
+ return values.slice(0, low);
339
+ };
340
+ var fitDigestCache = (digest, maxBytes) => {
341
+ applyCacheMetrics(digest);
342
+ if (digest.cacheBytes <= maxBytes) return digest;
343
+ digest.indexCoverage.complete = false;
344
+ if (!digest.indexCoverage.reasons.includes("max_cold_cache_bytes")) {
345
+ digest.indexCoverage.reasons.push("max_cold_cache_bytes");
346
+ }
347
+ digest.addresses = maxFittingPrefix(digest.addresses, (addresses) => {
348
+ digest.addresses = addresses;
349
+ applyCacheMetrics(digest);
350
+ return digest.cacheBytes <= maxBytes;
351
+ });
352
+ applyCacheMetrics(digest);
353
+ if (digest.cacheBytes <= maxBytes) return digest;
354
+ digest.vocabulary = maxFittingPrefix(digest.vocabulary, (vocabulary) => {
355
+ digest.vocabulary = vocabulary;
356
+ digest.indexCoverage.vocabularyBytes = serializedBytes(vocabulary);
357
+ applyCacheMetrics(digest);
358
+ return digest.cacheBytes <= maxBytes;
359
+ });
360
+ digest.indexCoverage.vocabularyBytes = serializedBytes(digest.vocabulary);
361
+ return applyCacheMetrics(digest);
362
+ };
363
+ var loadDigest = (ref, options) => {
364
+ const lineage = resolveLineage(ref.file, options);
365
+ const filePath = digestPathForSession(ref.file, options.indexDir, lineage.branches);
366
+ const state = fingerprintSource(ref.file);
367
+ if (!state) {
368
+ removeCacheFile(filePath);
369
+ return missingDigest(ref, lineage);
370
+ }
371
+ const policy = digestPolicy(options, lineage);
372
+ const maxCacheBytes = options.maxColdCacheBytes ?? DEFAULT_MAX_COLD_CACHE_BYTES;
373
+ const cached = readDigestFile(filePath, maxCacheBytes);
374
+ if (isCacheFresh(cached, state, policy) && cached?.file === ref.file && serializedBytes(cached) <= maxCacheBytes) return cached;
375
+ if (fs2.existsSync(filePath)) removeCacheFile(filePath);
376
+ const { entries, header, indexCoverage } = normalizeSession(
377
+ ref.file,
378
+ Number.MAX_SAFE_INTEGER,
379
+ normalizationOptions(options, lineage)
380
+ );
381
+ const finalState = fingerprintSource(ref.file);
382
+ const finalLineage = resolveLineage(ref.file, options);
383
+ if (!finalState || finalState.sourceHash !== state.sourceHash || finalLineage.fingerprint !== lineage.fingerprint) {
384
+ removeCacheFile(filePath);
385
+ return missingDigest(
386
+ ref,
387
+ finalLineage,
388
+ finalState?.sourceHash === state.sourceHash ? "lineage_changed_during_index" : "source_changed_during_index"
389
+ );
390
+ }
391
+ const digest = foldSessionDigest({
392
+ sessionId: header?.sessionId ?? ref.id,
393
+ file: ref.file,
394
+ cwd: header?.cwd ?? ref.cwd,
395
+ entries,
396
+ maxVocabularyBytes: options.maxColdVocabularyBytes ?? DEFAULT_MAX_COLD_VOCABULARY_BYTES,
397
+ normalizationCoverage: indexCoverage
398
+ });
399
+ const persisted = fitDigestCache({
400
+ cacheVersion: MEMORY_CACHE_VERSION,
401
+ kind: "digest",
402
+ ...digest,
403
+ ...state,
404
+ branches: lineage.branches,
405
+ lineageFingerprint: lineage.fingerprint,
406
+ policy,
407
+ cacheBytes: 0,
408
+ cacheSourceRatio: 0
409
+ }, maxCacheBytes);
410
+ if (persisted.cacheBytes <= maxCacheBytes) writeCacheFile(filePath, persisted);
411
+ return persisted;
412
+ };
413
+ var compareRefsByRecency = (left, right) => {
414
+ if (right.mtime !== left.mtime) return right.mtime - left.mtime;
415
+ return compareLexical(left.file, right.file);
416
+ };
417
+ var classifySessionTiers = (refs, hotSessions = DEFAULT_HOT_SESSIONS) => {
418
+ const sorted = [...refs].sort(compareRefsByRecency);
419
+ const hot = new Set(sorted.slice(0, Math.max(0, Math.floor(hotSessions))).map((ref) => ref.file));
420
+ return new Map(sorted.map((ref) => [ref.file, hot.has(ref.file) ? "hot" : "cold"]));
421
+ };
422
+ var cleanupCacheDirectory = (indexDir, branchesToClean, maxFiles, maxBytes) => {
423
+ let directory;
424
+ try {
425
+ directory = fs2.opendirSync(indexDir);
426
+ } catch {
427
+ return { complete: true, reasons: [] };
428
+ }
429
+ let inspected = 0;
430
+ let inspectedBytes = 0;
431
+ try {
432
+ while (true) {
433
+ const entry = directory.readSync();
434
+ if (!entry) return { complete: true, reasons: [] };
435
+ if (!entry.name.endsWith(".json")) continue;
436
+ if (inspected >= maxFiles) {
437
+ return { complete: false, reasons: ["cache_cleanup_budget"] };
438
+ }
439
+ inspected += 1;
440
+ const cacheFile = path.join(indexDir, entry.name);
441
+ if (!entry.isFile()) {
442
+ removeCacheFile(cacheFile);
443
+ continue;
444
+ }
445
+ let cacheBytes;
446
+ try {
447
+ cacheBytes = fs2.statSync(cacheFile).size;
448
+ } catch {
449
+ removeCacheFile(cacheFile);
450
+ continue;
451
+ }
452
+ if (inspectedBytes + cacheBytes > maxBytes) {
453
+ return { complete: false, reasons: ["cache_cleanup_budget"] };
454
+ }
455
+ inspectedBytes += cacheBytes;
456
+ try {
457
+ const parsed = JSON.parse(fs2.readFileSync(cacheFile, "utf8"));
458
+ const kind = parsed.kind;
459
+ const source = kind === "shard" && typeof parsed.sessionFile === "string" ? parsed.sessionFile : kind === "digest" && typeof parsed.file === "string" ? parsed.file : null;
460
+ const branches = parsed.branches === "active" || parsed.branches === "all" ? parsed.branches : null;
461
+ if (branches !== null && branches !== branchesToClean) continue;
462
+ const expected = source && branches && kind === "shard" ? shardPathForSession(source, indexDir, branches) : source && branches && kind === "digest" ? digestPathForSession(source, indexDir, branches) : null;
463
+ const structurallyValid = kind === "shard" ? readShardFile(cacheFile, cacheBytes) !== null : kind === "digest" ? readDigestFile(cacheFile, cacheBytes) !== null : false;
464
+ if (parsed.cacheVersion !== MEMORY_CACHE_VERSION || source === null || expected !== cacheFile || !fs2.existsSync(source) || !structurallyValid) removeCacheFile(cacheFile);
465
+ } catch {
466
+ removeCacheFile(cacheFile);
467
+ }
468
+ }
469
+ } finally {
470
+ directory.closeSync();
471
+ }
472
+ };
473
+ var sourceSize = (file) => {
474
+ try {
475
+ const stat = fs2.statSync(file);
476
+ return stat.isFile() ? stat.size : null;
477
+ } catch {
478
+ return null;
479
+ }
480
+ };
481
+ var loadTieredIndex = (refs, allRefs, options, hydrate = false, entryRange) => {
482
+ const cleanup = cleanupCacheDirectory(
483
+ options.indexDir,
484
+ options.branches ?? "active",
485
+ options.maxCacheCleanupFiles ?? DEFAULT_MAX_CACHE_CLEANUP_FILES,
486
+ options.maxSyncSourceBytes ?? DEFAULT_MAX_SYNC_SOURCE_BYTES
487
+ );
488
+ const tierRefs = allRefs.length > 0 ? allRefs : refs;
489
+ const tiers = classifySessionTiers(tierRefs, options.hotSessions ?? DEFAULT_HOT_SESSIONS);
490
+ const maxSessions = options.maxSyncSessions ?? DEFAULT_MAX_SYNC_SESSIONS;
491
+ const maxSourceBytes = options.maxSyncSourceBytes ?? DEFAULT_MAX_SYNC_SOURCE_BYTES;
492
+ const shards = [];
493
+ const digests = [];
494
+ const reasons = new Set(cleanup.reasons);
495
+ let indexedSessions = 0;
496
+ let incompleteSessions = 0;
497
+ let processedSessions = 0;
498
+ let processedSourceBytes = 0;
499
+ for (const ref of refs) {
500
+ const size = sourceSize(ref.file);
501
+ if (size === null) {
502
+ reasons.add("source_unavailable");
503
+ continue;
504
+ }
505
+ if (processedSessions >= maxSessions) {
506
+ reasons.add("max_sync_sessions");
507
+ continue;
508
+ }
509
+ const tier = tiers.get(ref.file) ?? "cold";
510
+ const sourceWorkBytes = size * (hydrate && tier === "cold" ? 6 : 3);
511
+ if (processedSourceBytes + sourceWorkBytes > maxSourceBytes) {
512
+ reasons.add("max_sync_source_bytes");
513
+ continue;
514
+ }
515
+ processedSessions += 1;
516
+ processedSourceBytes += sourceWorkBytes;
517
+ try {
518
+ if (hydrate) {
519
+ if (tier === "cold") loadDigest(ref, options);
520
+ const shard = hydrateShard(ref, options, entryRange);
521
+ shards.push(shard);
522
+ if (shard.sourceHash) indexedSessions += 1;
523
+ else reasons.add(shard.indexReason ?? "source_unavailable");
524
+ if (shard.sourceHash && !shard.indexCoverage.complete) {
525
+ incompleteSessions += 1;
526
+ for (const reason of shard.indexCoverage.reasons) reasons.add(reason);
527
+ }
528
+ } else if (tier === "hot") {
529
+ const shard = loadShard(ref, options);
530
+ removeCacheFile(digestPathForSession(
531
+ ref.file,
532
+ options.indexDir,
533
+ options.branches ?? "active"
534
+ ));
535
+ shards.push(shard);
536
+ if (shard.sourceHash) indexedSessions += 1;
537
+ else reasons.add(shard.indexReason ?? "source_unavailable");
538
+ if (shard.sourceHash && !shard.indexCoverage.complete) {
539
+ incompleteSessions += 1;
540
+ for (const reason of shard.indexCoverage.reasons) reasons.add(reason);
541
+ }
542
+ } else {
543
+ const digest = loadDigest(ref, options);
544
+ removeCacheFile(shardPathForSession(
545
+ ref.file,
546
+ options.indexDir,
547
+ options.branches ?? "active"
548
+ ));
549
+ digests.push(digest);
550
+ if (digest.sourceHash) indexedSessions += 1;
551
+ if (!digest.indexCoverage.complete) {
552
+ incompleteSessions += 1;
553
+ for (const reason of digest.indexCoverage.reasons) reasons.add(reason);
554
+ }
555
+ }
556
+ } catch {
557
+ reasons.add("index_error");
558
+ }
559
+ }
560
+ const eligibleSessions = refs.length;
561
+ const staleSessions = eligibleSessions - indexedSessions;
562
+ return {
563
+ shards,
564
+ digests,
565
+ refs,
566
+ tiers,
567
+ coverage: {
568
+ complete: cleanup.complete && staleSessions === 0 && incompleteSessions === 0,
569
+ indexedSessions,
570
+ eligibleSessions,
571
+ staleSessions,
572
+ incompleteSessions,
573
+ reasons: [...reasons].sort(compareLexical)
574
+ }
575
+ };
576
+ };
577
+ var matchesFilters = (entry, filters) => {
578
+ if (filters.role !== void 0 && entry.role !== filters.role) return false;
579
+ if (filters.tool !== void 0 && entry.toolName !== filters.tool) return false;
580
+ if (filters.ref !== void 0 && entry.ref !== filters.ref) return false;
581
+ if (filters.provider !== void 0 && entry.provider !== filters.provider) return false;
582
+ if (filters.action !== void 0 && entry.action !== filters.action) return false;
583
+ if (filters.outcome !== void 0 && entry.outcome !== filters.outcome) return false;
584
+ if (filters.since !== void 0 && entry.timestamp !== null && entry.timestamp < filters.since) return false;
585
+ if (filters.until !== void 0 && entry.timestamp !== null && entry.timestamp > filters.until) return false;
586
+ return true;
587
+ };
588
+ var bm25Score = (shards, terms, filters, candidateLimit = Number.MAX_SAFE_INTEGER) => {
589
+ const queryTerms = [...new Set(terms.flatMap((term) => tokenizeLexical(term)))];
590
+ const matching = [];
591
+ for (const shard of shards) {
592
+ for (const entry of shard.entries) {
593
+ if (matchesFilters(entry, filters) && matching.length < candidateLimit) {
594
+ matching.push({ entry, mtime: shard.mtime, counts: lexicalTermCounts(entry.text) });
595
+ }
596
+ }
597
+ }
598
+ if (matching.length === 0 || queryTerms.length === 0) return [];
599
+ const lengths = matching.map((item) => Math.max(1, [...item.counts.values()].reduce((a, b) => a + b, 0)));
600
+ const averageLength = lengths.reduce((sum, length) => sum + length, 0) / matching.length;
601
+ const documentFrequency = /* @__PURE__ */ new Map();
602
+ for (const item of matching) {
603
+ for (const term of queryTerms) {
604
+ if ((item.counts.get(term) ?? 0) > 0) {
605
+ documentFrequency.set(term, (documentFrequency.get(term) ?? 0) + 1);
606
+ }
607
+ }
608
+ }
609
+ const K = 1.2;
610
+ const B = 0.75;
611
+ const results = [];
612
+ for (let index = 0; index < matching.length; index += 1) {
613
+ const item = matching[index];
614
+ let score = 0;
615
+ let matchedTerms = 0;
616
+ for (const term of queryTerms) {
617
+ const tf = item.counts.get(term) ?? 0;
618
+ if (tf === 0) continue;
619
+ matchedTerms += 1;
620
+ const df = documentFrequency.get(term) ?? 0;
621
+ const idf = Math.log((matching.length - df + 0.5) / (df + 0.5) + 1);
622
+ const normalized = tf * (K + 1) / (tf + K * (1 - B + B * (lengths[index] / averageLength)));
623
+ score += idf * normalized;
624
+ }
625
+ if (score > 0) {
626
+ results.push({ entry: item.entry, sessionMtime: item.mtime, score, matchedTerms });
627
+ }
628
+ }
629
+ results.sort((left, right) => {
630
+ if (right.score !== left.score) return right.score - left.score;
631
+ if (right.sessionMtime !== left.sessionMtime) return right.sessionMtime - left.sessionMtime;
632
+ if (left.entry.index !== right.entry.index) return left.entry.index - right.entry.index;
633
+ return compareLexical(left.entry.sessionFile, right.entry.sessionFile);
634
+ });
635
+ return results;
636
+ };
637
+ var recentEntries = (shards, filters, limit) => {
638
+ const all = [];
639
+ for (const shard of shards) {
640
+ for (const entry of shard.entries) {
641
+ if (matchesFilters(entry, filters)) all.push({ entry, sessionMtime: shard.mtime });
642
+ }
643
+ }
644
+ all.sort((left, right) => {
645
+ if (right.sessionMtime !== left.sessionMtime) return right.sessionMtime - left.sessionMtime;
646
+ if (left.entry.index !== right.entry.index) return left.entry.index - right.entry.index;
647
+ return compareLexical(left.entry.sessionFile, right.entry.sessionFile);
648
+ });
649
+ return all.slice(0, Math.max(0, limit));
650
+ };
651
+
652
+ // src/memory/regex.ts
653
+ import { Worker } from "node:worker_threads";
654
+ var WORKER_SOURCE = String.raw`
655
+ const { parentPort } = require("node:worker_threads");
656
+ parentPort.on("message", ({ pattern, haystacks }) => {
657
+ try {
658
+ const regex = new RegExp(pattern, "iu");
659
+ const matched = [];
660
+ for (let index = 0; index < haystacks.length; index += 1) {
661
+ if (regex.test(haystacks[index])) matched.push(index);
662
+ }
663
+ parentPort.postMessage({ matched });
664
+ } catch (error) {
665
+ parentPort.postMessage({
666
+ error: {
667
+ code: "invalid_regex",
668
+ message: error instanceof Error ? error.message : String(error),
669
+ },
670
+ });
671
+ }
672
+ });
673
+ `;
674
+ var executeBoundedRegex = async (pattern, haystacks, limits) => {
675
+ const patternBytes = Buffer.byteLength(pattern, "utf8");
676
+ if (patternBytes > limits.maxPatternBytes) {
677
+ return {
678
+ complete: false,
679
+ matched: [],
680
+ error: {
681
+ code: "regex_pattern_too_large",
682
+ message: `Regex pattern is ${patternBytes} bytes; limit is ${limits.maxPatternBytes}.`
683
+ }
684
+ };
685
+ }
686
+ return new Promise((resolve) => {
687
+ let worker;
688
+ try {
689
+ worker = new Worker(WORKER_SOURCE, {
690
+ eval: true,
691
+ resourceLimits: { maxOldGenerationSizeMb: 16, maxYoungGenerationSizeMb: 4 }
692
+ });
693
+ } catch (error) {
694
+ resolve({
695
+ complete: false,
696
+ matched: [],
697
+ error: {
698
+ code: "regex_worker_error",
699
+ message: error instanceof Error ? error.message : String(error)
700
+ }
701
+ });
702
+ return;
703
+ }
704
+ let settled = false;
705
+ const finish = (result) => {
706
+ if (settled) return;
707
+ settled = true;
708
+ clearTimeout(timer);
709
+ void worker.terminate();
710
+ resolve(result);
711
+ };
712
+ const timer = setTimeout(() => {
713
+ finish({
714
+ complete: false,
715
+ matched: [],
716
+ error: {
717
+ code: "regex_timeout",
718
+ message: `Regex execution exceeded ${limits.timeoutMs} ms.`
719
+ }
720
+ });
721
+ }, limits.timeoutMs);
722
+ worker.once("message", (message) => {
723
+ const record = message;
724
+ if (record.error) {
725
+ finish({ complete: false, matched: [], error: record.error });
726
+ return;
727
+ }
728
+ if (Array.isArray(record.matched) && record.matched.every((value) => Number.isInteger(value))) {
729
+ finish({ complete: true, matched: record.matched });
730
+ return;
731
+ }
732
+ finish({
733
+ complete: false,
734
+ matched: [],
735
+ error: { code: "regex_worker_error", message: "Regex worker returned an invalid result." }
736
+ });
737
+ });
738
+ worker.once("error", (error) => {
739
+ finish({
740
+ complete: false,
741
+ matched: [],
742
+ error: {
743
+ code: "regex_worker_error",
744
+ message: error instanceof Error ? error.message : String(error)
745
+ }
746
+ });
747
+ });
748
+ worker.postMessage({ pattern, haystacks });
749
+ });
750
+ };
751
+
752
+ // src/memory/search.ts
753
+ var DEFAULT_REGEX_MAX_PATTERN_BYTES = 1024;
754
+ var DEFAULT_REGEX_MAX_HAYSTACK_TERMS = 2e4;
755
+ var DEFAULT_REGEX_MAX_HAYSTACK_BYTES = 2 * 1024 * 1024;
756
+ var DEFAULT_REGEX_TIMEOUT_MS = 250;
757
+ var DEFAULT_SEARCH_MAX_CANDIDATE_ENTRIES = 5e4;
758
+ var DEFAULT_SEARCH_MAX_CANDIDATE_DIGESTS = 1e4;
759
+ var DEFAULT_SEARCH_MAX_CANDIDATE_ITEMS = 1e4;
760
+ var segmentStartRoles = /* @__PURE__ */ new Set(["user", "bashExecution", "compaction"]);
761
+ var matchesFilters2 = (entry, filters) => {
762
+ if (filters.role !== void 0 && entry.role !== filters.role) return false;
763
+ if (filters.tool !== void 0 && entry.toolName !== filters.tool) return false;
764
+ if (filters.ref !== void 0 && entry.ref !== filters.ref) return false;
765
+ if (filters.provider !== void 0 && entry.provider !== filters.provider) return false;
766
+ if (filters.action !== void 0 && entry.action !== filters.action) return false;
767
+ if (filters.outcome !== void 0 && entry.outcome !== filters.outcome) return false;
768
+ if (filters.since !== void 0 && entry.timestamp !== null && entry.timestamp < filters.since) return false;
769
+ if (filters.until !== void 0 && entry.timestamp !== null && entry.timestamp > filters.until) return false;
770
+ return true;
771
+ };
772
+ var addressMatchesFilters = (address, filters) => {
773
+ if (filters.role !== void 0 && address[3] !== filters.role) return false;
774
+ if (filters.tool !== void 0 && address[4] !== filters.tool) return false;
775
+ if (filters.ref !== void 0 && address[6] !== filters.ref) return false;
776
+ if (filters.provider !== void 0 && address[7] !== filters.provider) return false;
777
+ if (filters.action !== void 0 && address[8] !== filters.action) return false;
778
+ if (filters.outcome !== void 0 && address[9] !== filters.outcome) return false;
779
+ if (filters.since !== void 0 && address[5] !== null && address[5] < filters.since) return false;
780
+ if (filters.until !== void 0 && address[5] !== null && address[5] > filters.until) return false;
781
+ return true;
782
+ };
783
+ var hasFilters = (filters) => Object.keys(filters).length > 0;
784
+ var lexicalProvenanceWeight = (entry, filters) => {
785
+ if (filters.tool !== void 0 || filters.ref !== void 0 || filters.provider !== void 0 || filters.action !== void 0 || filters.outcome !== void 0) return 1;
786
+ if (entry.toolName === null && entry.role === "assistant") return 2.5;
787
+ if (entry.toolName === null && entry.role === "user") return 2.25;
788
+ if (entry.toolName === null && (entry.role === "compactionSummary" || entry.role === "custom")) return 1.5;
789
+ if (entry.role === "toolResult" || entry.role === "fabricOperation") return 0.75;
790
+ if (entry.toolName !== null) return 0.7;
791
+ return 1;
792
+ };
793
+ var sortLocated = (located) => {
794
+ located.sort((left, right) => {
795
+ if (right.score !== left.score) return right.score - left.score;
796
+ if (right.sessionMtime !== left.sessionMtime) return right.sessionMtime - left.sessionMtime;
797
+ if (left.entry.index !== right.entry.index) return left.entry.index - right.entry.index;
798
+ return compareLexical(left.entry.sessionFile, right.entry.sessionFile);
799
+ });
800
+ };
801
+ var filteredEntryCount = (shards, filters) => {
802
+ let count = 0;
803
+ for (const shard of shards) {
804
+ for (const entry of shard.entries) if (matchesFilters2(entry, filters)) count += 1;
805
+ }
806
+ return count;
807
+ };
808
+ var collectTermMatches = (shards, terms, filters, maxEntries, match) => {
809
+ const scored = bm25Score(shards, terms, filters, maxEntries);
810
+ const selected = match === "all" ? scored.filter((item) => item.matchedTerms === terms.length) : scored;
811
+ return selected.map((item) => ({
812
+ entry: item.entry,
813
+ matched: true,
814
+ sessionMtime: item.sessionMtime,
815
+ score: item.score * lexicalProvenanceWeight(item.entry, filters)
816
+ }));
817
+ };
818
+ var collectPhraseMatches = (shards, phrase, filters, maxEntries) => {
819
+ const located = [];
820
+ let inspected = 0;
821
+ outer: for (const shard of shards) {
822
+ for (const entry of shard.entries) {
823
+ if (!matchesFilters2(entry, filters)) continue;
824
+ if (inspected >= maxEntries) break outer;
825
+ inspected += 1;
826
+ if (!normalizeMemoryPhrase(entry.text).includes(phrase)) continue;
827
+ located.push({
828
+ entry,
829
+ matched: true,
830
+ sessionMtime: shard.mtime,
831
+ score: lexicalProvenanceWeight(entry, filters)
832
+ });
833
+ }
834
+ }
835
+ sortLocated(located);
836
+ return located;
837
+ };
838
+ var collectRecent = (shards, filters, maxEntries, score = 0) => recentEntries(shards, filters, maxEntries).map((item) => ({
839
+ entry: item.entry,
840
+ matched: true,
841
+ sessionMtime: item.sessionMtime,
842
+ score
843
+ }));
844
+ var digestStructuralMatchCount = (digest, filters) => hasFilters(filters) ? digest.addresses.filter((address) => addressMatchesFilters(address, filters)).length : 0;
845
+ var digestCanMatchFilters = (digest, filters) => !hasFilters(filters) || digestStructuralMatchCount(digest, filters) > 0;
846
+ var toDigestHit = (digest, score, matchedTerms, matchedStructuralEntries = 0) => ({
847
+ sessionId: digest.sessionId,
848
+ sessionFile: digest.file,
849
+ sourceHash: digest.sourceHash,
850
+ branches: digest.branches,
851
+ lineageFingerprint: digest.lineageFingerprint,
852
+ cwd: digest.cwd,
853
+ lastTs: digest.lastTs,
854
+ sessionMtime: digest.mtime,
855
+ score,
856
+ tier: "cold",
857
+ matchedTerms,
858
+ matchedStructuralEntries
859
+ });
860
+ var scoreDigestTerms = (digests, terms, filters, maxDigests, match) => {
861
+ if (digests.length === 0 || terms.length === 0) return { hits: [], complete: true };
862
+ const candidates = [];
863
+ let matchingDigests = 0;
864
+ for (const digest of digests) {
865
+ if (!digestCanMatchFilters(digest, filters)) continue;
866
+ const vocabulary = new Set(digest.vocabulary);
867
+ const matches = terms.filter((term) => vocabulary.has(term));
868
+ if (matches.length === 0 || match === "all" && matches.length !== terms.length) continue;
869
+ matchingDigests += 1;
870
+ if (candidates.length < maxDigests) {
871
+ candidates.push({
872
+ digest,
873
+ matches,
874
+ structuralMatches: digestStructuralMatchCount(digest, filters)
875
+ });
876
+ }
877
+ }
878
+ const documentFrequency = /* @__PURE__ */ new Map();
879
+ for (const candidate of candidates) {
880
+ for (const term of candidate.matches) {
881
+ documentFrequency.set(term, (documentFrequency.get(term) ?? 0) + 1);
882
+ }
883
+ }
884
+ const hits = candidates.map((candidate) => {
885
+ const score = candidate.matches.reduce((total, term) => {
886
+ const df = documentFrequency.get(term) ?? 0;
887
+ return total + Math.log((candidates.length - df + 0.5) / (df + 0.5) + 1);
888
+ }, 0);
889
+ return toDigestHit(
890
+ candidate.digest,
891
+ score,
892
+ candidate.matches.length,
893
+ candidate.structuralMatches
894
+ );
895
+ });
896
+ return { hits, complete: matchingDigests <= maxDigests };
897
+ };
898
+ var collectRegexTargets = (shards, digests, filters, maxTerms, maxBytes) => {
899
+ const haystacks = [];
900
+ const targets = [];
901
+ let bytes = 0;
902
+ let complete = true;
903
+ const reasons = /* @__PURE__ */ new Set();
904
+ const append = (haystack, target) => {
905
+ const nextBytes = Buffer.byteLength(haystack, "utf8");
906
+ if (haystacks.length >= maxTerms) {
907
+ complete = false;
908
+ reasons.add("regex_max_haystack_terms");
909
+ return false;
910
+ }
911
+ if (bytes + nextBytes > maxBytes) {
912
+ complete = false;
913
+ reasons.add("regex_max_haystack_bytes");
914
+ return false;
915
+ }
916
+ haystacks.push(haystack);
917
+ targets.push(target);
918
+ bytes += nextBytes;
919
+ return true;
920
+ };
921
+ outer: for (const shard of shards) {
922
+ for (const entry of shard.entries) {
923
+ if (!matchesFilters2(entry, filters)) continue;
924
+ if (!append(entry.text, { kind: "hot", shard, entry })) break outer;
925
+ }
926
+ }
927
+ if (complete) {
928
+ outer: for (const digest of digests) {
929
+ if (!digestCanMatchFilters(digest, filters)) continue;
930
+ for (const term of digest.vocabulary) {
931
+ if (!append(term, { kind: "cold", digest })) break outer;
932
+ }
933
+ }
934
+ }
935
+ return { haystacks, targets, complete, reasons: [...reasons].sort(compareLexical) };
936
+ };
937
+ var searchRegex = async (shards, digests, pattern, filters, query) => {
938
+ const limits = query.regexLimits ?? {
939
+ maxPatternBytes: DEFAULT_REGEX_MAX_PATTERN_BYTES,
940
+ maxHaystackTerms: DEFAULT_REGEX_MAX_HAYSTACK_TERMS,
941
+ maxHaystackBytes: DEFAULT_REGEX_MAX_HAYSTACK_BYTES,
942
+ timeoutMs: DEFAULT_REGEX_TIMEOUT_MS
943
+ };
944
+ const collected = collectRegexTargets(
945
+ shards,
946
+ digests,
947
+ filters,
948
+ limits.maxHaystackTerms,
949
+ limits.maxHaystackBytes
950
+ );
951
+ const execution = await executeBoundedRegex(pattern, collected.haystacks, {
952
+ maxPatternBytes: limits.maxPatternBytes,
953
+ timeoutMs: limits.timeoutMs
954
+ });
955
+ if (!execution.complete) {
956
+ return {
957
+ located: [],
958
+ digestHits: [],
959
+ coverage: { complete: false, reasons: [execution.error.code], error: execution.error }
960
+ };
961
+ }
962
+ const located = [];
963
+ const coldMatches = /* @__PURE__ */ new Map();
964
+ for (const index of execution.matched) {
965
+ const target = collected.targets[index];
966
+ if (!target) continue;
967
+ if (target.kind === "hot") {
968
+ located.push({
969
+ entry: target.entry,
970
+ matched: true,
971
+ sessionMtime: target.shard.mtime,
972
+ score: lexicalProvenanceWeight(target.entry, filters)
973
+ });
974
+ } else {
975
+ coldMatches.set(target.digest, (coldMatches.get(target.digest) ?? 0) + 1);
976
+ }
977
+ }
978
+ const reasons = new Set(collected.reasons);
979
+ if (coldMatches.size > 0 && hasFilters(filters)) {
980
+ reasons.add("cold_structural_filter_requires_hydration");
981
+ }
982
+ return {
983
+ located,
984
+ digestHits: [...coldMatches].map(([digest, count]) => toDigestHit(digest, count, count, digestStructuralMatchCount(digest, filters))),
985
+ coverage: {
986
+ complete: collected.complete && reasons.size === 0,
987
+ reasons: [...reasons].sort(compareLexical)
988
+ }
989
+ };
990
+ };
991
+ var sortDigestHits = (hits) => {
992
+ hits.sort((left, right) => {
993
+ if (right.score !== left.score) return right.score - left.score;
994
+ if (right.sessionMtime !== left.sessionMtime) return right.sessionMtime - left.sessionMtime;
995
+ return compareLexical(left.sessionFile, right.sessionFile);
996
+ });
997
+ };
998
+ var searchMemoryIndex = async (shards, digests, query) => {
999
+ const filters = query.filters ?? {};
1000
+ const plan = planMemoryQuery(
1001
+ query.query,
1002
+ query.queryMode ?? "literal",
1003
+ query.queryMatch ?? "any"
1004
+ );
1005
+ const limits = query.candidateLimits ?? {
1006
+ maxEntries: DEFAULT_SEARCH_MAX_CANDIDATE_ENTRIES,
1007
+ maxDigests: DEFAULT_SEARCH_MAX_CANDIDATE_DIGESTS,
1008
+ maxItems: DEFAULT_SEARCH_MAX_CANDIDATE_ITEMS
1009
+ };
1010
+ const maxEntries = Math.max(1, Math.floor(limits.maxEntries));
1011
+ const maxDigests = Math.max(1, Math.floor(limits.maxDigests));
1012
+ const maxItems = Math.max(1, Math.floor(limits.maxItems));
1013
+ let located;
1014
+ let digestHits = [];
1015
+ let queryCoverage = { complete: true, reasons: [] };
1016
+ const structurallyFiltered = hasFilters(filters);
1017
+ const matchMode = plan.kind === "browse" ? structurallyFiltered ? "structural" : "browse" : structurallyFiltered ? "combined" : plan.kind === "regex" ? "regex" : plan.kind === "phrase" ? "phrase" : "lexical";
1018
+ const markOnlyMatches = plan.kind !== "browse" || structurallyFiltered;
1019
+ const coverageReasons = /* @__PURE__ */ new Set();
1020
+ if (plan.kind === "browse") {
1021
+ const eligibleEntries = filteredEntryCount(shards, filters);
1022
+ located = collectRecent(shards, filters, maxEntries, structurallyFiltered ? 1 : 0);
1023
+ if (eligibleEntries > maxEntries) coverageReasons.add("candidate_entry_budget");
1024
+ let eligibleDigests = 0;
1025
+ for (const digest of digests) {
1026
+ if (!digestCanMatchFilters(digest, filters)) continue;
1027
+ eligibleDigests += 1;
1028
+ if (digestHits.length < maxDigests) {
1029
+ const structuralMatches = digestStructuralMatchCount(digest, filters);
1030
+ digestHits.push(toDigestHit(
1031
+ digest,
1032
+ structurallyFiltered ? 1 : 0,
1033
+ 0,
1034
+ structuralMatches
1035
+ ));
1036
+ }
1037
+ }
1038
+ if (eligibleDigests > maxDigests) coverageReasons.add("candidate_digest_budget");
1039
+ } else if (plan.kind === "regex") {
1040
+ const regexResult = await searchRegex(shards, digests, plan.pattern, filters, query);
1041
+ located = regexResult.located.slice(0, maxEntries);
1042
+ digestHits = regexResult.digestHits.slice(0, maxDigests);
1043
+ queryCoverage = regexResult.coverage;
1044
+ if (regexResult.located.length > maxEntries) coverageReasons.add("candidate_entry_budget");
1045
+ if (regexResult.digestHits.length > maxDigests) coverageReasons.add("candidate_digest_budget");
1046
+ sortLocated(located);
1047
+ } else if (plan.kind === "phrase") {
1048
+ const eligibleEntries = filteredEntryCount(shards, filters);
1049
+ located = collectPhraseMatches(shards, plan.phrase, filters, maxEntries);
1050
+ if (eligibleEntries > maxEntries) coverageReasons.add("candidate_entry_budget");
1051
+ const digestResult = scoreDigestTerms(digests, plan.terms, filters, maxDigests, "all");
1052
+ digestHits = digestResult.hits;
1053
+ if (!digestResult.complete) coverageReasons.add("candidate_digest_budget");
1054
+ if (digestHits.length > 0) coverageReasons.add("cold_phrase_requires_hydration");
1055
+ if (digestHits.length > 0 && hasFilters(filters)) {
1056
+ coverageReasons.add("cold_structural_filter_requires_hydration");
1057
+ }
1058
+ } else {
1059
+ const eligibleEntries = filteredEntryCount(shards, filters);
1060
+ located = collectTermMatches(shards, plan.terms, filters, maxEntries, plan.match);
1061
+ if (eligibleEntries > maxEntries) coverageReasons.add("candidate_entry_budget");
1062
+ const digestResult = scoreDigestTerms(digests, plan.terms, filters, maxDigests, plan.match);
1063
+ digestHits = digestResult.hits;
1064
+ if (!digestResult.complete) coverageReasons.add("candidate_digest_budget");
1065
+ if (digestHits.length > 0 && plan.match === "all" && plan.terms.length > 1) {
1066
+ coverageReasons.add("cold_all_terms_requires_hydration");
1067
+ }
1068
+ if (digestHits.length > 0 && hasFilters(filters)) {
1069
+ coverageReasons.add("cold_structural_filter_requires_hydration");
1070
+ }
1071
+ }
1072
+ sortDigestHits(digestHits);
1073
+ for (const reason of queryCoverage.reasons) coverageReasons.add(reason);
1074
+ queryCoverage = {
1075
+ ...queryCoverage,
1076
+ complete: queryCoverage.complete && coverageReasons.size === 0,
1077
+ reasons: [...coverageReasons].sort(compareLexical)
1078
+ };
1079
+ return groupIntoResults(
1080
+ shards,
1081
+ located,
1082
+ digestHits,
1083
+ markOnlyMatches,
1084
+ matchMode,
1085
+ maxItems,
1086
+ queryCoverage
1087
+ );
1088
+ };
1089
+ var searchShards = (shards, query) => searchMemoryIndex(shards, [], query);
1090
+ var groupIntoResults = (shards, located, digestHits, markOnlyMatches, matchMode, maxItems, queryCoverage) => {
1091
+ if (located.length === 0 && digestHits.length === 0) {
1092
+ return {
1093
+ matchMode,
1094
+ matchedCount: 0,
1095
+ totalMatches: 0,
1096
+ totalItems: 0,
1097
+ segmentCount: 0,
1098
+ segments: [],
1099
+ digestHits: [],
1100
+ items: [],
1101
+ queryCoverage
1102
+ };
1103
+ }
1104
+ const shardsByFile = new Map(shards.map((shard) => [shard.sessionFile, shard]));
1105
+ const sessionOrder = [];
1106
+ const matchedBySession = /* @__PURE__ */ new Map();
1107
+ const scores = /* @__PURE__ */ new Map();
1108
+ for (const item of located) {
1109
+ if (!matchedBySession.has(item.entry.sessionFile)) sessionOrder.push(item.entry.sessionFile);
1110
+ const set = matchedBySession.get(item.entry.sessionFile) ?? /* @__PURE__ */ new Set();
1111
+ set.add(item.entry.index);
1112
+ matchedBySession.set(item.entry.sessionFile, set);
1113
+ scores.set(`${item.entry.sessionFile}\0${item.entry.index}`, item.score);
1114
+ }
1115
+ const segments = [];
1116
+ for (const file of sessionOrder) {
1117
+ const shard = shardsByFile.get(file);
1118
+ const matchedSet = matchedBySession.get(file);
1119
+ if (!shard || !matchedSet) continue;
1120
+ let current = [];
1121
+ let currentStart = 0;
1122
+ const flush = () => {
1123
+ if (current.length === 0) return;
1124
+ const entries = current.map((entry) => {
1125
+ const matched = matchedSet.has(entry.index);
1126
+ return {
1127
+ entry,
1128
+ matched,
1129
+ marker: markOnlyMatches ? matched ? ">" : " " : ">",
1130
+ score: matched ? scores.get(`${file}\0${entry.index}`) ?? 0 : 0
1131
+ };
1132
+ });
1133
+ const matchedEntries = entries.filter((entry) => entry.matched);
1134
+ if (markOnlyMatches && matchedEntries.length === 0) {
1135
+ current = [];
1136
+ return;
1137
+ }
1138
+ const lastIndex = current[current.length - 1].index;
1139
+ const range = lastIndex === currentStart ? `#${currentStart}` : `#${currentStart}-#${lastIndex}`;
1140
+ const score = Math.max(
1141
+ 0,
1142
+ ...matchedEntries.map((item) => scores.get(`${file}\0${item.entry.index}`) ?? 0)
1143
+ );
1144
+ segments.push({
1145
+ sessionId: shard.sessionId,
1146
+ sessionFile: shard.sessionFile,
1147
+ sourceHash: shard.sourceHash,
1148
+ branches: shard.branches,
1149
+ lineageFingerprint: shard.lineageFingerprint,
1150
+ sessionMtime: shard.mtime,
1151
+ range,
1152
+ entryRange: { first: currentStart, last: lastIndex },
1153
+ entries,
1154
+ exactMatches: matchedEntries.map(({ entry }) => ({
1155
+ index: entry.index,
1156
+ entryId: entry.entryId,
1157
+ operationAddress: entry.operationAddress ?? null
1158
+ })),
1159
+ matchedCount: matchedEntries.length,
1160
+ score,
1161
+ tier: shard.tier ?? "hot"
1162
+ });
1163
+ current = [];
1164
+ };
1165
+ for (const entry of shard.entries) {
1166
+ if (current.length > 0 && entry.role !== null && segmentStartRoles.has(entry.role)) flush();
1167
+ if (current.length === 0) currentStart = entry.index;
1168
+ current.push(entry);
1169
+ }
1170
+ flush();
1171
+ }
1172
+ const items = [
1173
+ ...segments.map((segment) => ({ kind: "entry", segment })),
1174
+ ...digestHits.map((digest) => ({ kind: "digest", digest }))
1175
+ ];
1176
+ items.sort(compareSearchItems);
1177
+ const candidateItemsExceeded = items.length > maxItems;
1178
+ const limitedItems = items.slice(0, maxItems);
1179
+ const limitedSegments = limitedItems.filter((item) => item.kind === "entry").map((item) => item.segment);
1180
+ const limitedDigests = limitedItems.filter((item) => item.kind === "digest").map((item) => item.digest);
1181
+ const matchedCount = limitedSegments.reduce((sum, segment) => sum + segment.matchedCount, 0) + limitedDigests.length;
1182
+ const finalCoverage = candidateItemsExceeded ? {
1183
+ ...queryCoverage,
1184
+ complete: false,
1185
+ reasons: [.../* @__PURE__ */ new Set([...queryCoverage.reasons, "candidate_item_budget"])].sort(compareLexical)
1186
+ } : queryCoverage;
1187
+ return {
1188
+ matchMode,
1189
+ matchedCount,
1190
+ totalMatches: matchedCount,
1191
+ totalItems: limitedItems.length,
1192
+ segmentCount: limitedSegments.length,
1193
+ segments: limitedSegments,
1194
+ digestHits: limitedDigests,
1195
+ items: limitedItems,
1196
+ queryCoverage: finalCoverage
1197
+ };
1198
+ };
1199
+ var compareSearchItems = (left, right) => {
1200
+ const leftValue = left.kind === "entry" ? left.segment : left.digest;
1201
+ const rightValue = right.kind === "entry" ? right.segment : right.digest;
1202
+ if (rightValue.score !== leftValue.score) return rightValue.score - leftValue.score;
1203
+ if (rightValue.sessionMtime !== leftValue.sessionMtime) return rightValue.sessionMtime - leftValue.sessionMtime;
1204
+ if (left.kind !== right.kind) return left.kind === "entry" ? -1 : 1;
1205
+ if (left.kind === "entry" && right.kind === "entry") {
1206
+ const leftIndex = left.segment.entries[0]?.entry.index ?? 0;
1207
+ const rightIndex = right.segment.entries[0]?.entry.index ?? 0;
1208
+ if (leftIndex !== rightIndex) return leftIndex - rightIndex;
1209
+ return compareLexical(left.segment.sessionFile, right.segment.sessionFile);
1210
+ }
1211
+ if (left.kind === "digest" && right.kind === "digest") {
1212
+ return compareLexical(left.digest.sessionFile, right.digest.sessionFile);
1213
+ }
1214
+ return 0;
1215
+ };
1216
+
1217
+ export {
1218
+ reconstructSessionLineage,
1219
+ DEFAULT_HOT_SESSIONS,
1220
+ fingerprintSource,
1221
+ loadTieredIndex,
1222
+ DEFAULT_REGEX_MAX_PATTERN_BYTES,
1223
+ DEFAULT_REGEX_MAX_HAYSTACK_TERMS,
1224
+ DEFAULT_REGEX_MAX_HAYSTACK_BYTES,
1225
+ DEFAULT_REGEX_TIMEOUT_MS,
1226
+ searchMemoryIndex,
1227
+ searchShards
1228
+ };
1229
+ //# sourceMappingURL=chunk-2KEWFW56.js.map