@e4779/pi-fabric 0.92.17-fork.3

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