@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,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/entropy/fingerprint.ts", "../../src/entropy/normal-form.ts"],
4
+ "sourcesContent": ["// Deterministic fingerprints for the entropy meter: canonical call-shape\n// signatures, signature distance (retry churn), Shannon entropy in bits, and\n// the static freedom score of a JSON Schema. Everything here is a pure\n// function of its inputs; the same value always yields the same fingerprint.\n\nimport type { EntropyTrend } from \"./types.js\";\n\nconst SIGNATURE_MAX_KEYS = 32;\nconst SIGNATURE_MAX_DEPTH = 3;\n// Enum cardinality whose freedom saturates at 1.0 (log2 of 64 values).\nconst ENUM_SATURATION_BITS = 6;\n\nconst isPlainRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n// Fixed rounding for every reported metric value. Same inputs, same floats,\n// same six decimal places \u2014 report JSON is byte-stable. Negative zero\n// collapses to zero so single-class entropies compare equal to zero.\nexport const roundMetric = (value: number): number => {\n const rounded = Math.round(value * 1e6) / 1e6;\n return rounded === 0 ? 0 : rounded;\n};\n\n// Code-unit string comparison: locale-independent, so ordering never varies\n// with the host's ICU data.\nexport const compareCodeUnits = (left: string, right: string): number =>\n left < right ? -1 : left > right ? 1 : 0;\n\nconst typeTag = (value: unknown, depth: number): string => {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"arr\";\n switch (typeof value) {\n case \"string\":\n return \"str\";\n case \"number\":\n return \"num\";\n case \"boolean\":\n return \"bool\";\n case \"object\": {\n if (depth >= SIGNATURE_MAX_DEPTH) return \"obj\";\n try {\n const record = value as Record<string, unknown>;\n const keys = Object.keys(record).sort();\n const head = keys\n .slice(0, SIGNATURE_MAX_KEYS)\n .map((key) => `${key}:${typeTag(record[key], depth + 1)}`);\n if (keys.length > SIGNATURE_MAX_KEYS) {\n head.push(`\u2026+${keys.length - SIGNATURE_MAX_KEYS}`);\n }\n return `{${head.join(\",\")}}`;\n } catch {\n return \"obj\";\n }\n }\n default:\n return \"other\";\n }\n};\n\n// Canonical argument-shape signature: sorted parameter names with a bounded\n// value-type tag each. Key order and value contents never matter \u2014 only the\n// shape the model chose.\nexport const shapeSignature = (args: Record<string, unknown>): string => {\n const keys = Object.keys(args).sort();\n const head = keys\n .slice(0, SIGNATURE_MAX_KEYS)\n .map((key) => `${key}:${typeTag(args[key], 1)}`);\n if (keys.length > SIGNATURE_MAX_KEYS) {\n head.push(`\u2026+${keys.length - SIGNATURE_MAX_KEYS}`);\n }\n return `(${head.join(\",\")})`;\n};\n\n// Normalized Levenshtein distance between two signatures, in [0, 1]. Retry\n// churn is the distance between a failed call's shape and the next attempt's.\nexport const signatureDistance = (left: string, right: string): number => {\n if (left === right) return 0;\n const bound = Math.max(left.length, right.length);\n if (bound === 0) return 0;\n let previous: number[] = [];\n for (let index = 0; index <= right.length; index++) {\n previous.push(index);\n }\n for (let index = 1; index <= left.length; index++) {\n const current: number[] = [index];\n for (let inner = 1; inner <= right.length; inner++) {\n const substitution = previous[inner - 1]! + (left[index - 1] === right[inner - 1] ? 0 : 1);\n const insertion = current[inner - 1]! + 1;\n const deletion = previous[inner]! + 1;\n current.push(Math.min(substitution, insertion, deletion));\n }\n previous = current;\n }\n return roundMetric(previous[right.length]! / bound);\n};\n\n// Shannon entropy in bits over a count distribution, rounded to 1e-6.\n// A single class is zero bits; a uniform split over k classes is log2(k).\nexport const shannonEntropyBits = (counts: readonly number[]): number => {\n const total = counts.reduce((sum, value) => sum + value, 0);\n if (total <= 0) return 0;\n let bits = 0;\n for (const count of counts) {\n if (count <= 0) continue;\n const probability = count / total;\n bits += probability * Math.log2(probability);\n }\n return roundMetric(-bits);\n};\n\nconst schemaFreedom = (schema: unknown, depth: number): number => {\n if (depth > SIGNATURE_MAX_DEPTH) return 0.5;\n if (!isPlainRecord(schema)) return 0.5;\n const union = Array.isArray(schema.anyOf)\n ? schema.anyOf\n : Array.isArray(schema.oneOf)\n ? schema.oneOf\n : undefined;\n if (union) {\n const scores = union.map((branch) => schemaFreedom(branch, depth + 1));\n const widest = scores.length > 0 ? Math.max(...scores) : 0;\n return roundMetric(widest + 0.1 * Math.max(0, union.length - 1));\n }\n if (Array.isArray(schema.enum)) {\n return roundMetric(\n Math.min(1, Math.log2(Math.max(1, schema.enum.length)) / ENUM_SATURATION_BITS),\n );\n }\n if (\"const\" in schema) return 0;\n const type = schema.type;\n if (typeof type !== \"string\") return 0.75;\n if (type === \"boolean\") return 0.1;\n if (type === \"number\" || type === \"integer\") return 0.5;\n if (type === \"string\") return 1;\n if (type === \"array\") return roundMetric(0.5 + 0.5 * schemaFreedom(schema.items, depth + 1));\n if (type === \"object\") {\n const properties = schema.properties;\n if (!isPlainRecord(properties)) return 1;\n const keys = Object.keys(properties).sort();\n if (keys.length === 0) return 1;\n const required = Array.isArray(schema.required)\n ? schema.required.filter((entry): entry is string => typeof entry === \"string\")\n : [];\n let score = 0;\n for (const key of keys) {\n score += schemaFreedom(properties[key], depth + 1);\n if (!required.includes(key)) score += 0.25;\n }\n if (schema.additionalProperties !== false) score += 0.5;\n return roundMetric(score);\n }\n return 0.75;\n};\n\n// Static freedom of one action's input schema: free strings dominate, enums\n// shrink with log2 cardinality, literals cost nothing, and optional or\n// open-ended parameters add tax. Computable with an empty corpus, which is\n// what lets the compiler score candidate surfaces before deployment.\nexport const staticFreedomFromSchema = (schema: unknown): number => schemaFreedom(schema, 0);\n\n// Least-squares slope of a score sequence, oldest to newest. The on-demand\n// session trend feeds this per-session scores; a flat or negative slope is\n// the ratchet holding.\nexport const trendFromScores = (scores: readonly number[]): EntropyTrend => {\n const count = scores.length;\n const first = count > 0 ? scores[0] : undefined;\n const last = count > 0 ? scores[count - 1] : undefined;\n let slope = 0;\n if (count >= 2) {\n const meanX = (count - 1) / 2;\n const meanY = scores.reduce((sum, value) => sum + value, 0) / count;\n let numerator = 0;\n let denominator = 0;\n for (let index = 0; index < count; index++) {\n numerator += (index - meanX) * (scores[index]! - meanY);\n denominator += (index - meanX) ** 2;\n }\n slope = denominator > 0 ? numerator / denominator : 0;\n }\n return {\n count,\n ...(first !== undefined ? { first: roundMetric(first) } : {}),\n ...(last !== undefined ? { last: roundMetric(last) } : {}),\n slopePerStep: roundMetric(slope),\n };\n};\n", "// Internal compatibility plans. The declared schema is never rewritten.\n// A proof is a re-derivation from a bounded rule language, not a claim made\n// by an imported artifact. No observation can authorize a new semantic map.\nimport { Value } from \"typebox/value\";\nimport { stableJsonHash } from \"../core/stable-hash.js\";\nimport { shapeSignature } from \"./fingerprint.js\";\n\nexport interface NormalFormEvidenceSummary {\n normalizedCalls: number;\n rulesApplied: number;\n succeeded: number;\n subsequentFailures: number;\n}\n\n// Witness counts are observations, not manufactured task successes. A call\n// can be normalized and still fail authorization, approval, or execution.\nexport const normalFormEvidenceSummary = (\n traces: readonly import(\"./types.js\").EntropyTraceInput[],\n): NormalFormEvidenceSummary => {\n const summary = { normalizedCalls: 0, rulesApplied: 0, succeeded: 0, subsequentFailures: 0 };\n for (const trace of traces) for (const operation of trace.operations) {\n if (!operation.normalization || !isNormalFormWitness(operation.normalization)) continue;\n summary.normalizedCalls++;\n summary.rulesApplied += operation.normalization.rules.length;\n if (operation.outcome === \"succeeded\") summary.succeeded++;\n else summary.subsequentFailures++;\n }\n return summary;\n};\n\nexport const NORMAL_FORM_VERSION = 1 as const;\nexport const MAX_NORMAL_FORM_RULES = 128;\nexport const MAX_NORMAL_FORM_PLANS = 1_000;\nconst RULE_KINDS = [\"key-form\", \"enum-form\", \"numeric-string\", \"optional-null\"] as const;\nexport type NormalFormRuleKind = typeof RULE_KINDS[number];\nexport interface NormalFormRule { kind: NormalFormRuleKind; key: string }\nexport interface NormalFormPlan {\n version: typeof NORMAL_FORM_VERSION;\n ref: string;\n baseSchemaDigest: string;\n rules: NormalFormRule[];\n}\nexport interface NormalFormWitness {\n version: typeof NORMAL_FORM_VERSION;\n baseSchemaDigest: string;\n beforeShape: string;\n afterShape: string;\n rules: NormalFormRule[];\n}\nexport interface NormalFormResult {\n args: Record<string, unknown>;\n witness?: NormalFormWitness;\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\nconst safeKey = (key: string): boolean => key.length <= 128 &&\n ![\"__proto__\", \"prototype\", \"constructor\"].includes(key);\nconst form = (value: string): string | undefined =>\n /^[a-zA-Z][a-zA-Z0-9 _-]*$/.test(value) ? value.toLowerCase().replace(/[ _-]/g, \"\") : undefined;\nconst accepts = (schema: unknown, args: unknown): boolean => {\n try { return isRecord(schema) && Value.Check(schema, args); } catch { return false; }\n};\nconst uniqueForms = (values: readonly string[]): Map<string, string> => {\n const groups = new Map<string, string[]>();\n for (const value of values) {\n const key = form(value);\n if (!key) continue;\n const group = groups.get(key) ?? [];\n group.push(value);\n groups.set(key, group);\n }\n return new Map([...groups].filter(([, group]) => group.length === 1).map(([key, group]) => [key, group[0]!]));\n};\n\n// These four conventions are host-authored compatibility semantics:\n// spelling-only key/enum forms, lossless numeric encoding, and omission of\n// non-nullable optional fields. Open objects and schema combinators are not\n// grounds for inventing an interpretation. Unsupported schemas pass through.\nexport const deriveNormalFormPlan = (ref: string, schema: unknown): NormalFormPlan | undefined => {\n if (!ref || ref.length > 1_024 || !isRecord(schema) || schema.type !== \"object\" ||\n schema.additionalProperties !== false || !isRecord(schema.properties) ||\n [\"patternProperties\", \"oneOf\", \"anyOf\", \"allOf\", \"$ref\", \"if\", \"not\"].some((key) => Object.hasOwn(schema, key))) return undefined;\n const keys = Object.keys(schema.properties).sort();\n if (keys.length > MAX_NORMAL_FORM_RULES || !keys.every(safeKey)) return undefined;\n const required = new Set(Array.isArray(schema.required) ? schema.required : []);\n const forms = new Set(uniqueForms(keys).values());\n const rules: NormalFormRule[] = [];\n for (const key of keys) {\n const property = schema.properties[key];\n if (!isRecord(property)) continue;\n if (forms.has(key)) rules.push({ kind: \"key-form\", key });\n if (!required.has(key) && !accepts(property, null)) rules.push({ kind: \"optional-null\", key });\n if (property.type === \"number\" || property.type === \"integer\") rules.push({ kind: \"numeric-string\", key });\n if (property.type === \"string\" && Array.isArray(property.enum) &&\n property.enum.every((value) => typeof value === \"string\") &&\n uniqueForms(property.enum).size > 0) rules.push({ kind: \"enum-form\", key });\n }\n if (rules.length === 0) return undefined;\n return { version: NORMAL_FORM_VERSION, ref, baseSchemaDigest: stableJsonHash(schema), rules: rules.slice(0, MAX_NORMAL_FORM_RULES) };\n};\n\nconst isRule = (value: unknown): value is NormalFormRule => isRecord(value) &&\n Object.keys(value).length === 2 && typeof value.key === \"string\" && safeKey(value.key) &&\n RULE_KINDS.includes(value.kind as NormalFormRuleKind);\nconst isDigest = (value: unknown): value is string => typeof value === \"string\" && /^[a-f0-9]{64}$/.test(value);\nexport const isNormalFormPlan = (value: unknown): value is NormalFormPlan => isRecord(value) &&\n Object.keys(value).length === 4 && value.version === NORMAL_FORM_VERSION &&\n typeof value.ref === \"string\" && value.ref.length > 0 && value.ref.length <= 1_024 &&\n isDigest(value.baseSchemaDigest) && Array.isArray(value.rules) &&\n value.rules.length > 0 && value.rules.length <= MAX_NORMAL_FORM_RULES && value.rules.every(isRule);\nexport const isNormalFormWitness = (value: unknown): value is NormalFormWitness => isRecord(value) &&\n Object.keys(value).length === 5 && value.version === NORMAL_FORM_VERSION &&\n isDigest(value.baseSchemaDigest) && isDigest(value.beforeShape) && isDigest(value.afterShape) &&\n Array.isArray(value.rules) && value.rules.length > 0 && value.rules.length <= MAX_NORMAL_FORM_RULES && value.rules.every(isRule);\n\nexport const provesNormalFormPlan = (plan: NormalFormPlan, schema: unknown): boolean => {\n if (!isNormalFormPlan(plan)) return false;\n try {\n const derived = deriveNormalFormPlan(plan.ref, schema);\n return derived !== undefined && stableJsonHash(derived) === stableJsonHash(plan);\n } catch { return false; }\n};\n\nexport const applyNormalFormPlan = (\n ref: string,\n schema: unknown,\n args: Record<string, unknown>,\n plan?: NormalFormPlan,\n): NormalFormResult => {\n const unchanged = { args };\n // This early identity law protects every canonical capability, including\n // rare enum members and nullable values. Successful candidates satisfy it\n // too, which establishes idempotence without a corpus-dependent gate.\n if (!plan || plan.ref !== ref || accepts(schema, args) || !provesNormalFormPlan(plan, schema)) return unchanged;\n const properties = (schema as { properties: Record<string, Record<string, unknown>> }).properties;\n const candidate = { ...args };\n const applied: NormalFormRule[] = [];\n const keyRules = plan.rules.filter((rule) => rule.kind === \"key-form\");\n const forms = uniqueForms(keyRules.map((rule) => rule.key));\n const targets = new Set<string>();\n for (const key of Object.keys(args).sort()) {\n if (Object.hasOwn(properties, key)) continue;\n const normalized = form(key);\n const target = normalized ? forms.get(normalized) : undefined;\n if (!target) continue;\n // Never discard a competing canonical value or choose between aliases.\n if (Object.hasOwn(args, target) || targets.has(target)) return unchanged;\n targets.add(target);\n Object.defineProperty(candidate, target, { value: args[key], enumerable: true, configurable: true, writable: true });\n delete candidate[key];\n applied.push({ kind: \"key-form\", key: target });\n }\n for (const rule of plan.rules) {\n if (rule.kind === \"key-form\" || !Object.hasOwn(candidate, rule.key)) continue;\n const value = candidate[rule.key];\n const property = properties[rule.key]!;\n if (accepts(property, value)) continue;\n if (rule.kind === \"optional-null\" && (value === null || value === undefined)) {\n delete candidate[rule.key];\n applied.push(rule);\n } else if (rule.kind === \"numeric-string\" && typeof value === \"string\") {\n const number = Number(value);\n if (Number.isFinite(number) && String(number) === value && accepts(property, number)) {\n candidate[rule.key] = number;\n applied.push(rule);\n }\n } else if (rule.kind === \"enum-form\" && typeof value === \"string\") {\n const normalized = form(value);\n const target = normalized ? uniqueForms(property.enum as string[]).get(normalized) : undefined;\n if (target !== undefined && accepts(property, target)) {\n candidate[rule.key] = target;\n applied.push(rule);\n }\n }\n }\n // A partial repair is not a successful correction. Return original input\n // on every refusal so authoritative validation reports the real failure.\n if (applied.length === 0 || !accepts(schema, candidate)) return unchanged;\n return {\n args: candidate,\n witness: {\n version: NORMAL_FORM_VERSION,\n baseSchemaDigest: plan.baseSchemaDigest,\n beforeShape: stableJsonHash(shapeSignature(args)),\n afterShape: stableJsonHash(shapeSignature(candidate)),\n rules: applied,\n },\n };\n};\n"],
5
+ "mappings": ";;;;;AAOA,IAAM,qBAAqB;AAC3B,IAAM,sBAAsB;AAE5B,IAAM,uBAAuB;AAE7B,IAAM,gBAAgB,CAAC,UACrB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAK9D,IAAM,cAAc,CAAC,UAA0B;AACpD,QAAM,UAAU,KAAK,MAAM,QAAQ,GAAG,IAAI;AAC1C,SAAO,YAAY,IAAI,IAAI;AAC7B;AAIO,IAAM,mBAAmB,CAAC,MAAc,UAC7C,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAEzC,IAAM,UAAU,CAAC,OAAgB,UAA0B;AACzD,MAAI,UAAU,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AG,IAAI;AACtB,gBAAQ,KAAK,IAAI;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAGA,MAAI,QAAQ,WAAW,KAAK,CAAC,QAAQ,QAAQ,SAAS,EAAG,QAAO;AAChE,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS;AAAA,MACT,kBAAkB,KAAK;AAAA,MACvB,aAAa,eAAe,eAAe,IAAI,CAAC;AAAA,MAChD,YAAY,eAAe,eAAe,SAAS,CAAC;AAAA,MACpD,OAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,447 @@
1
+ import {
2
+ compileFabricSummary,
3
+ rawContextTokens
4
+ } from "./chunk-U6CTHPZC.js";
5
+ import {
6
+ compactionRequestBoundsError,
7
+ encodeCompactionRequest
8
+ } from "./chunk-3H7SDWZI.js";
9
+
10
+ // src/agents/thinking-transfer.ts
11
+ var REASONING_CONTENT_SIGNATURE = "reasoning_content";
12
+ var OPENAI_COMPLETIONS_API = "openai-completions";
13
+ var thinkingTransferPolicy = (input) => {
14
+ const { source, target } = input;
15
+ if (source && source.provider === target.provider && (source.api === void 0 || target.api === void 0 || source.api === target.api)) {
16
+ return "preserved";
17
+ }
18
+ if (target.api === OPENAI_COMPLETIONS_API && target.reasoning === true && target.requiresThinkingAsText !== true) {
19
+ return "re-signed";
20
+ }
21
+ return "stripped";
22
+ };
23
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
24
+ var isThinkingPart = (part) => isRecord(part) && part.type === "thinking";
25
+ var translateThinkingForExecutor = (entries, policy) => {
26
+ if (policy === "preserved") {
27
+ return { entries, report: { policy, translated: 0, dropped: 0 } };
28
+ }
29
+ const clone = structuredClone(entries);
30
+ let translated = 0;
31
+ let dropped = 0;
32
+ for (const entry of clone) {
33
+ if (entry.type !== "message") continue;
34
+ const message = entry.message;
35
+ if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
36
+ const kept = [];
37
+ for (const part of message.content) {
38
+ if (isRecord(part) && part.type === "toolCall") {
39
+ delete part.thoughtSignature;
40
+ kept.push(part);
41
+ continue;
42
+ }
43
+ if (!isThinkingPart(part)) {
44
+ kept.push(part);
45
+ continue;
46
+ }
47
+ const text = typeof part.thinking === "string" ? part.thinking : "";
48
+ if (policy === "re-signed" && part.redacted !== true && text.trim().length > 0) {
49
+ part.thinkingSignature = REASONING_CONTENT_SIGNATURE;
50
+ translated += 1;
51
+ kept.push(part);
52
+ continue;
53
+ }
54
+ dropped += 1;
55
+ }
56
+ message.content = kept;
57
+ }
58
+ return { entries: clone, report: { policy, translated, dropped } };
59
+ };
60
+ var THINKING_DIGEST_CUSTOM_TYPE = "pi-fabric-handoff-thinking";
61
+ var MAX_DIGEST_BLOCKS = 8;
62
+ var MAX_DIGEST_LINE = 80;
63
+ var MAX_DIGEST_BYTES = 2048;
64
+ var firstLineOf = (text) => {
65
+ const end = text.indexOf("\n");
66
+ return end === -1 ? text : text.slice(0, end);
67
+ };
68
+ var truncate = (text, max) => text.length > max ? text.slice(0, max) : text;
69
+ var clipUtf8 = (text, maxBytes) => {
70
+ if (Buffer.byteLength(text, "utf8") <= maxBytes) return text;
71
+ let out = "";
72
+ let bytes = 0;
73
+ for (const char of text) {
74
+ const size = Buffer.byteLength(char, "utf8");
75
+ if (bytes + size > maxBytes) break;
76
+ out += char;
77
+ bytes += size;
78
+ }
79
+ return out;
80
+ };
81
+ var buildThinkingDigest = (entries, input) => {
82
+ const blocks = [];
83
+ for (const entry of entries) {
84
+ if (entry.type !== "message") continue;
85
+ const message = entry.message;
86
+ if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
87
+ for (const part of message.content) {
88
+ if (!isThinkingPart(part)) continue;
89
+ const text = typeof part.thinking === "string" ? part.thinking : "";
90
+ const line = truncate(firstLineOf(text).trim(), MAX_DIGEST_LINE);
91
+ if (line) blocks.push({ entryId: entry.id, line });
92
+ }
93
+ }
94
+ if (blocks.length === 0) return void 0;
95
+ const recent = blocks.slice(-MAX_DIGEST_BLOCKS);
96
+ const omitted = blocks.length - recent.length;
97
+ const sourceId = input.source ? `${input.source.provider}/${input.source.modelId}` : "the prior model";
98
+ const targetId = `${input.target.provider}/${input.target.modelId}`;
99
+ const lines = [
100
+ "Prewalk handoff continuity digest (deliberation, not commitments).",
101
+ `Thinking from ${sourceId} was not transferred: ${targetId} cannot replay it (incompatible reasoning channels). Most recent lines:`,
102
+ ...recent.map((block) => `- [entry ${block.entryId}] ${block.line}`)
103
+ ];
104
+ if (omitted > 0) lines.push(`(omitted ${omitted} older thinking blocks)`);
105
+ lines.push("Full thinking remains addressable in the source session by entry id.");
106
+ return {
107
+ content: clipUtf8(lines.join("\n"), MAX_DIGEST_BYTES),
108
+ citedBlocks: recent.length
109
+ };
110
+ };
111
+
112
+ // src/agents/handoff.ts
113
+ import { randomUUID } from "node:crypto";
114
+ import fs from "node:fs";
115
+ import path from "node:path";
116
+ import {
117
+ CURRENT_SESSION_VERSION,
118
+ SessionManager
119
+ } from "@earendil-works/pi-coding-agent";
120
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
121
+ var checkedHandoffCompaction = (value) => {
122
+ if (value === void 0 || value === false) return void 0;
123
+ const input = value === true ? {} : value;
124
+ if (!isRecord2(input)) {
125
+ throw new Error(
126
+ "Invalid agents.handoff compact arguments: compact must be true or an object with instructions/preserve"
127
+ );
128
+ }
129
+ if (input.instructions !== void 0 && typeof input.instructions !== "string") {
130
+ throw new Error("Invalid agents.handoff compact arguments: instructions must be a string");
131
+ }
132
+ if (input.preserve !== void 0 && (!Array.isArray(input.preserve) || input.preserve.some((item) => typeof item !== "string"))) {
133
+ throw new Error(
134
+ "Invalid agents.handoff compact arguments: preserve must be an array of strings"
135
+ );
136
+ }
137
+ const request = {
138
+ ...typeof input.instructions === "string" ? { instructions: input.instructions } : {},
139
+ ...input.preserve !== void 0 ? { preserve: input.preserve } : {}
140
+ };
141
+ const boundsError = compactionRequestBoundsError(request);
142
+ if (boundsError) {
143
+ throw new Error(`Invalid agents.handoff compact arguments: ${boundsError.message}`);
144
+ }
145
+ return request;
146
+ };
147
+ var isToolCall = (value) => isRecord2(value) && value.type === "toolCall" && typeof value.id === "string" && typeof value.name === "string" && isRecord2(value.arguments);
148
+ var activeFabricTurn = (source, outerToolCallId) => {
149
+ const leafId = source.getLeafId();
150
+ const entry = leafId ? source.getEntry(leafId) : void 0;
151
+ if (entry?.type !== "message" || entry.message.role !== "assistant") {
152
+ throw new Error(
153
+ "Trajectory handoff requires the active fabric_exec assistant turn to be the session leaf"
154
+ );
155
+ }
156
+ const content = Array.isArray(entry.message.content) ? entry.message.content : [];
157
+ const toolCalls = content.filter(isToolCall);
158
+ if (!toolCalls.some((call) => call.id === outerToolCallId)) {
159
+ throw new Error(
160
+ "Trajectory handoff could not find the active fabric_exec assistant turn in the Pi session"
161
+ );
162
+ }
163
+ if (toolCalls.length !== 1 || toolCalls[0]?.name !== "fabric_exec") {
164
+ throw new Error(
165
+ "Trajectory handoff requires fabric_exec to be the only top-level tool call in its assistant turn"
166
+ );
167
+ }
168
+ return entry;
169
+ };
170
+ var snapshotHandoffSession = (source, currentModel, outerToolResult, outerToolCallId) => {
171
+ if (outerToolResult.toolCallId !== outerToolCallId || outerToolResult.toolName !== "fabric_exec") {
172
+ throw new Error("Trajectory handoff requires the finalized outer fabric_exec result");
173
+ }
174
+ const active = activeFabricTurn(source, outerToolCallId);
175
+ const sourceSessionFile = source.getSessionFile();
176
+ const branch = source.getBranch();
177
+ let model = currentModel ? { provider: currentModel.provider, modelId: currentModel.id } : void 0;
178
+ let thinkingLevel;
179
+ for (let index = branch.length - 1; index >= 0; index--) {
180
+ const entry = branch[index];
181
+ if (!thinkingLevel && entry?.type === "thinking_level_change") {
182
+ thinkingLevel = entry.thinkingLevel;
183
+ }
184
+ if (!model && entry?.type === "model_change") {
185
+ model = { provider: entry.provider, modelId: entry.modelId };
186
+ }
187
+ if (model && thinkingLevel) break;
188
+ }
189
+ return {
190
+ sourceSessionId: source.getSessionId(),
191
+ ...sourceSessionFile ? { sourceSessionFile } : {},
192
+ sourceBranchLeafId: active.id,
193
+ ...!sourceSessionFile ? { sourceBranch: structuredClone(branch) } : {},
194
+ ...model ? { sourceModel: model } : {},
195
+ ...thinkingLevel ? { sourceThinkingLevel: thinkingLevel } : {},
196
+ outerToolResult: structuredClone(outerToolResult)
197
+ };
198
+ };
199
+ var materializeBranch = (seed, cwd, directory) => {
200
+ if (!seed.sourceBranch) {
201
+ throw new Error("In-memory trajectory handoff is missing its source branch");
202
+ }
203
+ const id = randomUUID();
204
+ const sessionFile = path.join(directory, `handoff-${id}.jsonl`);
205
+ const header = {
206
+ type: "session",
207
+ version: CURRENT_SESSION_VERSION,
208
+ id,
209
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
210
+ cwd,
211
+ ...seed.sourceSessionFile ? { parentSession: seed.sourceSessionFile } : {}
212
+ };
213
+ fs.writeFileSync(
214
+ sessionFile,
215
+ `${[header, ...seed.sourceBranch].map((entry) => JSON.stringify(entry)).join("\n")}
216
+ `,
217
+ { encoding: "utf8", mode: 384, flag: "wx" }
218
+ );
219
+ return SessionManager.open(sessionFile, directory, cwd);
220
+ };
221
+ var forkBranch = (seed, cwd, directory) => {
222
+ if (!seed.sourceSessionFile) return materializeBranch(seed, cwd, directory);
223
+ const fork = SessionManager.open(seed.sourceSessionFile, directory, cwd);
224
+ if (!fork.getEntry(seed.sourceBranchLeafId)) {
225
+ throw new Error(
226
+ `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`
227
+ );
228
+ }
229
+ const sessionFile = fork.createBranchedSession(seed.sourceBranchLeafId);
230
+ if (!sessionFile) {
231
+ throw new Error("Trajectory handoff could not create a persisted Pi session branch");
232
+ }
233
+ return fork;
234
+ };
235
+ var persistedBranch = (seed, cwd, directory) => {
236
+ if (!seed.sourceSessionFile) {
237
+ throw new Error("Persisted trajectory handoff is missing its source session file");
238
+ }
239
+ const source = SessionManager.open(seed.sourceSessionFile, directory, cwd);
240
+ if (!source.getEntry(seed.sourceBranchLeafId)) {
241
+ throw new Error(
242
+ `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`
243
+ );
244
+ }
245
+ return structuredClone(source.getBranch(seed.sourceBranchLeafId));
246
+ };
247
+ var synchronizeSourceSettings = (session, seed) => {
248
+ const context = session.buildSessionContext();
249
+ if (seed.sourceModel && (context.model?.provider !== seed.sourceModel.provider || context.model.modelId !== seed.sourceModel.modelId)) {
250
+ session.appendModelChange(seed.sourceModel.provider, seed.sourceModel.modelId);
251
+ }
252
+ if (seed.sourceThinkingLevel && context.thinkingLevel !== seed.sourceThinkingLevel) {
253
+ session.appendThinkingLevelChange(seed.sourceThinkingLevel);
254
+ }
255
+ };
256
+ var writeHandoffSession = (seed, cwd, directory, transfer, compaction) => {
257
+ fs.mkdirSync(directory, { recursive: true, mode: 448 });
258
+ const policy = transfer ? thinkingTransferPolicy(transfer) : "preserved";
259
+ let session;
260
+ let report;
261
+ let digest;
262
+ if (!transfer || policy === "preserved") {
263
+ session = forkBranch(seed, cwd, directory);
264
+ } else {
265
+ const rawBranch = seed.sourceSessionFile ? persistedBranch(seed, cwd, directory) : structuredClone(seed.sourceBranch ?? (() => {
266
+ throw new Error("Trajectory handoff transfer is missing its source branch");
267
+ })());
268
+ if (policy === "stripped") digest = buildThinkingDigest(rawBranch, transfer);
269
+ const translated = translateThinkingForExecutor(rawBranch, policy);
270
+ report = translated.report;
271
+ session = materializeBranch({ ...seed, sourceBranch: translated.entries }, cwd, directory);
272
+ }
273
+ let compactionOutcome;
274
+ if (compaction) {
275
+ const branchEntries = session.getBranch();
276
+ const customInstructions = compaction.preserve ? encodeCompactionRequest({
277
+ ...compaction.instructions !== void 0 ? { instructions: compaction.instructions } : {},
278
+ preserve: compaction.preserve
279
+ }) : compaction.instructions;
280
+ const tokensBefore = rawContextTokens(branchEntries);
281
+ const compiled = compileFabricSummary(branchEntries, tokensBefore, void 0, customInstructions);
282
+ if ("cancel" in compiled) {
283
+ compactionOutcome = { applied: false, reason: compiled.reason };
284
+ } else {
285
+ session.appendCompaction(
286
+ compiled.compaction.summary,
287
+ compiled.compaction.firstKeptEntryId,
288
+ tokensBefore,
289
+ compiled.compaction.details,
290
+ true
291
+ );
292
+ compactionOutcome = {
293
+ applied: true,
294
+ sections: compiled.compaction.details?.sections ?? [],
295
+ tokensBefore,
296
+ firstKeptEntryId: compiled.compaction.firstKeptEntryId
297
+ };
298
+ }
299
+ }
300
+ synchronizeSourceSettings(session, seed);
301
+ session.appendMessage(seed.outerToolResult);
302
+ if (digest) {
303
+ session.appendCustomMessageEntry(THINKING_DIGEST_CUSTOM_TYPE, digest.content, false, {
304
+ policy,
305
+ citedBlocks: digest.citedBlocks
306
+ });
307
+ }
308
+ session.appendCustomEntry("pi-fabric-handoff", {
309
+ sourceSessionId: seed.sourceSessionId,
310
+ boundary: "fabric_exec_end",
311
+ ...compactionOutcome ? {
312
+ compaction: compactionOutcome.applied ? {
313
+ applied: true,
314
+ sections: compactionOutcome.sections,
315
+ tokensBefore: compactionOutcome.tokensBefore,
316
+ firstKeptEntryId: compactionOutcome.firstKeptEntryId
317
+ } : { applied: false, reason: compactionOutcome.reason }
318
+ } : {},
319
+ ...transfer && report ? {
320
+ thinkingTransfer: {
321
+ policy: report.policy,
322
+ translated: report.translated,
323
+ dropped: report.dropped,
324
+ target: `${transfer.target.provider}/${transfer.target.modelId}`
325
+ }
326
+ } : {}
327
+ });
328
+ const sessionFile = session.getSessionFile();
329
+ if (!sessionFile) throw new Error("Trajectory handoff did not produce a Pi session file");
330
+ fs.chmodSync(sessionFile, 384);
331
+ return sessionFile;
332
+ };
333
+
334
+ // src/topology/peer-settle.ts
335
+ var DEFAULT_PEER_SETTLED_FOR_MS = 3e3;
336
+ var PEER_SETTLE_POLL_MS = 500;
337
+ var peerLabelPrefix = (cwd) => {
338
+ const base = cwd?.split(/[\\/]/).filter(Boolean).at(-1) ?? "";
339
+ const words = base.split(/[^A-Za-z0-9]+/).filter(Boolean);
340
+ if (words.length === 0) return "P";
341
+ if (words.length === 1) return words[0].slice(0, 3).toUpperCase();
342
+ return words.slice(0, 4).map((word) => word[0].toUpperCase()).join("");
343
+ };
344
+ var buildPeerCards = (peers) => [...peers].sort((left, right) => left.startedAt - right.startedAt || left.id.localeCompare(right.id)).map((peer) => ({
345
+ id: peer.id,
346
+ label: peer.label ?? peer.name,
347
+ status: peer.status,
348
+ ...peer.model ? { model: peer.model } : {},
349
+ ...peer.cwd ? { cwd: peer.cwd } : {},
350
+ startedAt: peer.startedAt,
351
+ updatedAt: peer.updatedAt,
352
+ pendingMessages: peer.pendingMessages
353
+ }));
354
+ var matchesSelector = (peer, selector) => {
355
+ const target = selector.trim().toLowerCase();
356
+ if (!target) return false;
357
+ return peer.id.toLowerCase() === target || (peer.label ?? "").toLowerCase() === target || peer.name.toLowerCase() === target;
358
+ };
359
+ var awaitPeerSettle = (options) => {
360
+ const now = options.now ?? (() => Date.now());
361
+ const settledFor = Math.max(0, options.settledForMs ?? DEFAULT_PEER_SETTLED_FOR_MS);
362
+ const pollMs = Math.max(10, options.pollMs ?? PEER_SETTLE_POLL_MS);
363
+ const armedAt = now();
364
+ const initial = options.poll();
365
+ const targets = options.selector !== void 0 ? initial.filter((peer) => matchesSelector(peer, options.selector ?? "")) : [...initial];
366
+ if (options.selector !== void 0 && targets.length === 0) {
367
+ return Promise.resolve({
368
+ ok: false,
369
+ error: `No Fabric peer matches "${options.selector}" on this project mesh`
370
+ });
371
+ }
372
+ if (targets.length === 0) return Promise.resolve({ ok: true });
373
+ const watched = /* @__PURE__ */ new Map();
374
+ for (const peer of targets) {
375
+ watched.set(peer.id, {
376
+ id: peer.id,
377
+ label: peer.label ?? peer.name,
378
+ running: peer.status === "running",
379
+ lastRunningAt: peer.status === "running" ? armedAt : void 0,
380
+ settled: false
381
+ });
382
+ }
383
+ return new Promise((resolve) => {
384
+ let timer;
385
+ let done = false;
386
+ const finish = (result) => {
387
+ if (done) return;
388
+ done = true;
389
+ if (timer) clearInterval(timer);
390
+ options.signal?.removeEventListener("abort", onAbort);
391
+ resolve(result);
392
+ };
393
+ const onAbort = () => finish({ ok: false, error: "cancelled" });
394
+ const tick = () => {
395
+ const snapshot = options.poll();
396
+ const byId = new Map(snapshot.map((peer) => [peer.id, peer]));
397
+ const current = now();
398
+ for (const entry of watched.values()) {
399
+ if (entry.settled) continue;
400
+ const peer = byId.get(entry.id);
401
+ if (!peer) {
402
+ entry.settled = true;
403
+ continue;
404
+ }
405
+ entry.label = peer.label ?? peer.name;
406
+ const running = peer.status === "running";
407
+ if (running) {
408
+ entry.lastRunningAt = current;
409
+ entry.running = true;
410
+ continue;
411
+ }
412
+ entry.running = false;
413
+ const quietSince = entry.lastRunningAt ?? armedAt;
414
+ if (current - quietSince >= settledFor) entry.settled = true;
415
+ }
416
+ const waiting = [...watched.values()].filter((entry) => !entry.settled).map((entry) => ({ label: entry.label, status: entry.running ? "running" : "idle" }));
417
+ if (waiting.length === 0) {
418
+ options.onUpdate?.({ waiting });
419
+ finish({ ok: true });
420
+ return;
421
+ }
422
+ options.onUpdate?.({ waiting });
423
+ };
424
+ if (options.signal) {
425
+ if (options.signal.aborted) {
426
+ finish({ ok: false, error: "cancelled" });
427
+ return;
428
+ }
429
+ options.signal.addEventListener("abort", onAbort, { once: true });
430
+ }
431
+ timer = setInterval(tick, pollMs);
432
+ tick();
433
+ });
434
+ };
435
+
436
+ export {
437
+ thinkingTransferPolicy,
438
+ THINKING_DIGEST_CUSTOM_TYPE,
439
+ buildThinkingDigest,
440
+ checkedHandoffCompaction,
441
+ snapshotHandoffSession,
442
+ writeHandoffSession,
443
+ peerLabelPrefix,
444
+ buildPeerCards,
445
+ awaitPeerSettle
446
+ };
447
+ //# sourceMappingURL=chunk-GXNR6NRU.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/agents/thinking-transfer.ts", "../../src/agents/handoff.ts", "../../src/topology/peer-settle.ts"],
4
+ "sourcesContent": ["import type {\n SessionEntry,\n SessionMessageEntry,\n} from \"@earendil-works/pi-coding-agent\";\n\n// Cross-model thinking transfer for trajectory handoffs.\n//\n// Pi replays stored thinking blocks verbatim per provider: a Codex Responses\n// reasoning item rides as a provider-shaped `thinkingSignature` blob, and the\n// OpenAI-completions transform (pi-ai) uses that blob as the *request field\n// name* when the history is handed to a different provider \u2014 landing prior\n// deliberation in a junk field while the real `reasoning_content` stays\n// empty. Signature-sensitive families (Anthropic) reject foreign signatures\n// outright. This module applies a family-aware policy to the fabric-owned\n// child session at the handoff boundary, where rewriting is safe because the\n// source session (ground truth) is never touched:\n//\n// preserved \u2014 same provider and api family: native replay already works.\n// re-signed \u2014 openai-completions reasoning targets: thinking text is kept\n// and the signature normalized to \"reasoning_content\" so preserve-thinking\n// servers (Kimi, DeepSeek, \u2026) actually receive prior reasoning.\n// stripped \u2014 everything else: thinking blocks and foreign thought\n// signatures are removed so no bogus field or invalid signature is sent;\n// a bounded, entry-id-cited digest keeps continuity instead.\n\ninterface ThinkingTransferSource {\n provider: string;\n modelId: string;\n /** pi-ai transport api of the source model, when the registry resolves it. */\n api?: string | undefined;\n}\n\ninterface ThinkingTransferTarget {\n provider: string;\n modelId: string;\n api?: string | undefined;\n reasoning?: boolean | undefined;\n /** Model replays thinking as visible text; deliberation must not leak there. */\n requiresThinkingAsText?: boolean | undefined;\n}\n\nexport interface ThinkingTransferInput {\n source?: ThinkingTransferSource;\n target: ThinkingTransferTarget;\n}\n\nexport type ThinkingTransferPolicy = \"preserved\" | \"re-signed\" | \"stripped\";\n\nexport interface ThinkingTransferReport {\n policy: ThinkingTransferPolicy;\n translated: number;\n dropped: number;\n}\n\n// Field name pi-ai emits when a thinking block's signature is exactly this\n// string (the opencode-go \"reasoning\" \u2192 \"reasoning_content\" remap proves the\n// convention): the request then carries real prior reasoning content.\nexport const REASONING_CONTENT_SIGNATURE = \"reasoning_content\";\n\nconst OPENAI_COMPLETIONS_API = \"openai-completions\";\n\nexport const thinkingTransferPolicy = (\n input: ThinkingTransferInput,\n): ThinkingTransferPolicy => {\n const { source, target } = input;\n // Same provider with equal or unknown apis: native replay is provider-shipped\n // and the default experience; only an api-proof mismatch transfers.\n if (\n source &&\n source.provider === target.provider &&\n (source.api === undefined || target.api === undefined || source.api === target.api)\n ) {\n return \"preserved\";\n }\n if (\n target.api === OPENAI_COMPLETIONS_API &&\n target.reasoning === true &&\n target.requiresThinkingAsText !== true\n ) {\n return \"re-signed\";\n }\n return \"stripped\";\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isThinkingPart = (part: unknown): part is Record<string, unknown> =>\n isRecord(part) && part.type === \"thinking\";\n\n// Clone-and-rewrite walk over assistant content parts. Also clears foreign\n// `thoughtSignature` artifacts (Google-style reasoning_details), which are as\n// provider-bound as thinking signatures. Callers own the input; the original\n// entries are never mutated.\nexport const translateThinkingForExecutor = (\n entries: SessionEntry[],\n policy: ThinkingTransferPolicy,\n): { entries: SessionEntry[]; report: ThinkingTransferReport } => {\n if (policy === \"preserved\") {\n return { entries, report: { policy, translated: 0, dropped: 0 } };\n }\n const clone = structuredClone(entries);\n let translated = 0;\n let dropped = 0;\n for (const entry of clone) {\n if (entry.type !== \"message\") continue;\n const message = (entry as SessionMessageEntry).message as {\n role?: unknown;\n content?: unknown;\n };\n if (message.role !== \"assistant\" || !Array.isArray(message.content)) continue;\n const kept: unknown[] = [];\n for (const part of message.content as unknown[]) {\n if (isRecord(part) && part.type === \"toolCall\") {\n delete part.thoughtSignature;\n kept.push(part);\n continue;\n }\n if (!isThinkingPart(part)) {\n kept.push(part);\n continue;\n }\n const text = typeof part.thinking === \"string\" ? part.thinking : \"\";\n if (policy === \"re-signed\" && part.redacted !== true && text.trim().length > 0) {\n part.thinkingSignature = REASONING_CONTENT_SIGNATURE;\n translated += 1;\n kept.push(part);\n continue;\n }\n dropped += 1;\n }\n message.content = kept;\n }\n return { entries: clone, report: { policy, translated, dropped } };\n};\n\nexport const THINKING_DIGEST_CUSTOM_TYPE = \"pi-fabric-handoff-thinking\";\n\nconst MAX_DIGEST_BLOCKS = 8;\nconst MAX_DIGEST_LINE = 80;\nconst MAX_DIGEST_BYTES = 2048;\n\nexport interface ThinkingDigest {\n content: string;\n citedBlocks: number;\n}\n\nconst firstLineOf = (text: string): string => {\n const end = text.indexOf(\"\\n\");\n return end === -1 ? text : text.slice(0, end);\n};\n\nconst truncate = (text: string, max: number): string =>\n text.length > max ? text.slice(0, max) : text;\n\nconst clipUtf8 = (text: string, maxBytes: number): string => {\n if (Buffer.byteLength(text, \"utf8\") <= maxBytes) return text;\n let out = \"\";\n let bytes = 0;\n for (const char of text) {\n const size = Buffer.byteLength(char, \"utf8\");\n if (bytes + size > maxBytes) break;\n out += char;\n bytes += size;\n }\n return out;\n};\n\n// Bounded continuity bridge for executors whose reasoning channel cannot\n// accept prior thinking: the newest few first-lines, cited by stable entry id,\n// explicitly labeled as deliberation so they read as context, not style. The\n// full scratchpad remains addressable in the source session.\nexport const buildThinkingDigest = (\n entries: SessionEntry[],\n input: ThinkingTransferInput,\n): ThinkingDigest | undefined => {\n const blocks: Array<{ entryId: string; line: string }> = [];\n for (const entry of entries) {\n if (entry.type !== \"message\") continue;\n const message = (entry as SessionMessageEntry).message as {\n role?: unknown;\n content?: unknown;\n };\n if (message.role !== \"assistant\" || !Array.isArray(message.content)) continue;\n for (const part of message.content as unknown[]) {\n if (!isThinkingPart(part)) continue;\n const text = typeof part.thinking === \"string\" ? part.thinking : \"\";\n const line = truncate(firstLineOf(text).trim(), MAX_DIGEST_LINE);\n if (line) blocks.push({ entryId: entry.id, line });\n }\n }\n if (blocks.length === 0) return undefined;\n const recent = blocks.slice(-MAX_DIGEST_BLOCKS);\n const omitted = blocks.length - recent.length;\n const sourceId = input.source\n ? `${input.source.provider}/${input.source.modelId}`\n : \"the prior model\";\n const targetId = `${input.target.provider}/${input.target.modelId}`;\n const lines = [\n \"Prewalk handoff continuity digest (deliberation, not commitments).\",\n `Thinking from ${sourceId} was not transferred: ${targetId} cannot replay it (incompatible reasoning channels). Most recent lines:`,\n ...recent.map((block) => `- [entry ${block.entryId}] ${block.line}`),\n ];\n if (omitted > 0) lines.push(`(omitted ${omitted} older thinking blocks)`);\n lines.push(\"Full thinking remains addressable in the source session by entry id.\");\n return {\n content: clipUtf8(lines.join(\"\\n\"), MAX_DIGEST_BYTES),\n citedBlocks: recent.length,\n };\n};\n", "import { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport {\n CURRENT_SESSION_VERSION,\n SessionManager,\n type SessionEntry,\n type SessionMessageEntry,\n} from \"@earendil-works/pi-coding-agent\";\nimport { compileFabricSummary, rawContextTokens } from \"../compaction/hook.js\";\nimport {\n compactionRequestBoundsError,\n encodeCompactionRequest,\n} from \"../compaction/instructions.js\";\nimport type {\n AgentSessionSeed,\n AgentToolResultMessage,\n HandoffCompactionRequest,\n} from \"./types.js\";\nimport {\n buildThinkingDigest,\n THINKING_DIGEST_CUSTOM_TYPE,\n thinkingTransferPolicy,\n translateThinkingForExecutor,\n type ThinkingTransferInput,\n type ThinkingTransferReport,\n} from \"./thinking-transfer.js\";\n\ninterface HandoffSessionSource {\n getBranch(): SessionEntry[];\n getEntry(id: string): SessionEntry | undefined;\n getLeafId(): string | null;\n getSessionFile(): string | undefined;\n getSessionId(): string;\n}\n\ninterface CurrentModel {\n provider: string;\n id: string;\n}\n\ntype NativeAssistantMessage = Extract<\n SessionMessageEntry[\"message\"],\n { role: \"assistant\" }\n>;\ntype NativeAssistantEntry = SessionMessageEntry & {\n message: NativeAssistantMessage;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\ninterface HandoffCompactionOutcome {\n applied: boolean;\n reason?: string;\n sections?: string[];\n tokensBefore?: number;\n firstKeptEntryId?: string;\n}\n\n// Validate the model-facing agents.handoff `compact` option against the same\n// bounds as compact.request. Called both when the request is scheduled (inside\n// the guest) and when the boundary runner replays it.\nexport const checkedHandoffCompaction = (\n value: unknown,\n): HandoffCompactionRequest | undefined => {\n if (value === undefined || value === false) return undefined;\n const input = value === true ? {} : value;\n if (!isRecord(input)) {\n throw new Error(\n \"Invalid agents.handoff compact arguments: compact must be true or an object with instructions/preserve\",\n );\n }\n if (input.instructions !== undefined && typeof input.instructions !== \"string\") {\n throw new Error(\"Invalid agents.handoff compact arguments: instructions must be a string\");\n }\n if (\n input.preserve !== undefined &&\n (!Array.isArray(input.preserve) || input.preserve.some((item) => typeof item !== \"string\"))\n ) {\n throw new Error(\n \"Invalid agents.handoff compact arguments: preserve must be an array of strings\",\n );\n }\n const request: HandoffCompactionRequest = {\n ...(typeof input.instructions === \"string\" ? { instructions: input.instructions } : {}),\n ...(input.preserve !== undefined ? { preserve: input.preserve as string[] } : {}),\n };\n const boundsError = compactionRequestBoundsError(request);\n if (boundsError) {\n throw new Error(`Invalid agents.handoff compact arguments: ${boundsError.message}`);\n }\n return request;\n};\n\nconst isToolCall = (value: unknown): value is {\n type: \"toolCall\";\n id: string;\n name: string;\n arguments: Record<string, unknown>;\n} =>\n isRecord(value) &&\n value.type === \"toolCall\" &&\n typeof value.id === \"string\" &&\n typeof value.name === \"string\" &&\n isRecord(value.arguments);\n\nconst activeFabricTurn = (\n source: HandoffSessionSource,\n outerToolCallId: string,\n): NativeAssistantEntry => {\n const leafId = source.getLeafId();\n const entry = leafId ? source.getEntry(leafId) : undefined;\n if (entry?.type !== \"message\" || entry.message.role !== \"assistant\") {\n throw new Error(\n \"Trajectory handoff requires the active fabric_exec assistant turn to be the session leaf\",\n );\n }\n const content = Array.isArray(entry.message.content) ? entry.message.content : [];\n const toolCalls = content.filter(isToolCall);\n if (!toolCalls.some((call) => call.id === outerToolCallId)) {\n throw new Error(\n \"Trajectory handoff could not find the active fabric_exec assistant turn in the Pi session\",\n );\n }\n if (toolCalls.length !== 1 || toolCalls[0]?.name !== \"fabric_exec\") {\n throw new Error(\n \"Trajectory handoff requires fabric_exec to be the only top-level tool call in its assistant turn\",\n );\n }\n return entry as NativeAssistantEntry;\n};\n\nexport const snapshotHandoffSession = (\n source: HandoffSessionSource,\n currentModel: CurrentModel | undefined,\n outerToolResult: AgentToolResultMessage,\n outerToolCallId: string,\n): AgentSessionSeed => {\n if (\n outerToolResult.toolCallId !== outerToolCallId ||\n outerToolResult.toolName !== \"fabric_exec\"\n ) {\n throw new Error(\"Trajectory handoff requires the finalized outer fabric_exec result\");\n }\n const active = activeFabricTurn(source, outerToolCallId);\n const sourceSessionFile = source.getSessionFile();\n const branch = source.getBranch();\n let model = currentModel\n ? { provider: currentModel.provider, modelId: currentModel.id }\n : undefined;\n let thinkingLevel: string | undefined;\n for (let index = branch.length - 1; index >= 0; index--) {\n const entry = branch[index];\n if (!thinkingLevel && entry?.type === \"thinking_level_change\") {\n thinkingLevel = entry.thinkingLevel;\n }\n if (!model && entry?.type === \"model_change\") {\n model = { provider: entry.provider, modelId: entry.modelId };\n }\n if (model && thinkingLevel) break;\n }\n return {\n sourceSessionId: source.getSessionId(),\n ...(sourceSessionFile ? { sourceSessionFile } : {}),\n sourceBranchLeafId: active.id,\n ...(!sourceSessionFile ? { sourceBranch: structuredClone(branch) } : {}),\n ...(model ? { sourceModel: model } : {}),\n ...(thinkingLevel ? { sourceThinkingLevel: thinkingLevel } : {}),\n outerToolResult: structuredClone(outerToolResult),\n };\n};\n\nconst materializeBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionManager => {\n if (!seed.sourceBranch) {\n throw new Error(\"In-memory trajectory handoff is missing its source branch\");\n }\n const id = randomUUID();\n const sessionFile = path.join(directory, `handoff-${id}.jsonl`);\n const header = {\n type: \"session\" as const,\n version: CURRENT_SESSION_VERSION,\n id,\n timestamp: new Date().toISOString(),\n cwd,\n ...(seed.sourceSessionFile ? { parentSession: seed.sourceSessionFile } : {}),\n };\n fs.writeFileSync(\n sessionFile,\n `${[header, ...seed.sourceBranch].map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`,\n { encoding: \"utf8\", mode: 0o600, flag: \"wx\" },\n );\n return SessionManager.open(sessionFile, directory, cwd);\n};\n\nconst forkBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionManager => {\n if (!seed.sourceSessionFile) return materializeBranch(seed, cwd, directory);\n const fork = SessionManager.open(seed.sourceSessionFile, directory, cwd);\n if (!fork.getEntry(seed.sourceBranchLeafId)) {\n throw new Error(\n `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`,\n );\n }\n const sessionFile = fork.createBranchedSession(seed.sourceBranchLeafId);\n if (!sessionFile) {\n throw new Error(\"Trajectory handoff could not create a persisted Pi session branch\");\n }\n return fork;\n};\n\n// File-backed read of the exact branch prefix, cloned so transfer translation\n// never mutates the source session's live entries. Used instead of\n// forkBranch when the executor's reasoning channel differs: createBranchedSession\n// copies raw lines and cannot rewrite foreign thinking signatures.\nconst persistedBranch = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n): SessionEntry[] => {\n if (!seed.sourceSessionFile) {\n throw new Error(\"Persisted trajectory handoff is missing its source session file\");\n }\n const source = SessionManager.open(seed.sourceSessionFile, directory, cwd);\n if (!source.getEntry(seed.sourceBranchLeafId)) {\n throw new Error(\n `Trajectory handoff branch point ${seed.sourceBranchLeafId} is missing from the persisted Pi session`,\n );\n }\n return structuredClone(source.getBranch(seed.sourceBranchLeafId));\n};\n\nconst synchronizeSourceSettings = (\n session: SessionManager,\n seed: AgentSessionSeed,\n): void => {\n const context = session.buildSessionContext();\n if (\n seed.sourceModel &&\n (context.model?.provider !== seed.sourceModel.provider ||\n context.model.modelId !== seed.sourceModel.modelId)\n ) {\n session.appendModelChange(seed.sourceModel.provider, seed.sourceModel.modelId);\n }\n if (seed.sourceThinkingLevel && context.thinkingLevel !== seed.sourceThinkingLevel) {\n session.appendThinkingLevelChange(seed.sourceThinkingLevel);\n }\n};\n\nexport const writeHandoffSession = (\n seed: AgentSessionSeed,\n cwd: string,\n directory: string,\n transfer?: ThinkingTransferInput,\n compaction?: HandoffCompactionRequest,\n): string => {\n fs.mkdirSync(directory, { recursive: true, mode: 0o700 });\n const policy = transfer ? thinkingTransferPolicy(transfer) : \"preserved\";\n let session: SessionManager;\n let report: ThinkingTransferReport | undefined;\n let digest: { content: string; citedBlocks: number } | undefined;\n if (!transfer || policy === \"preserved\") {\n session = forkBranch(seed, cwd, directory);\n } else {\n const rawBranch = seed.sourceSessionFile\n ? persistedBranch(seed, cwd, directory)\n : structuredClone(seed.sourceBranch ?? (() => {\n throw new Error(\"Trajectory handoff transfer is missing its source branch\");\n })());\n if (policy === \"stripped\") digest = buildThinkingDigest(rawBranch, transfer);\n const translated = translateThinkingForExecutor(rawBranch, policy);\n report = translated.report;\n session = materializeBranch({ ...seed, sourceBranch: translated.entries }, cwd, directory);\n }\n // Append the compaction entry before settings sync and the outer tool result\n // so the executor's context opens with the deterministic summary, followed\n // by the kept tail, then the boundary artifacts appended afterwards. The\n // file retains the full raw branch, mirroring Pi's append-only compaction.\n let compactionOutcome: HandoffCompactionOutcome | undefined;\n if (compaction) {\n const branchEntries = session.getBranch();\n const customInstructions = compaction.preserve\n ? encodeCompactionRequest({\n ...(compaction.instructions !== undefined\n ? { instructions: compaction.instructions }\n : {}),\n preserve: compaction.preserve,\n })\n : compaction.instructions;\n const tokensBefore = rawContextTokens(branchEntries);\n const compiled = compileFabricSummary(branchEntries, tokensBefore, undefined, customInstructions);\n if (\"cancel\" in compiled) {\n compactionOutcome = { applied: false, reason: compiled.reason };\n } else {\n session.appendCompaction(\n compiled.compaction.summary,\n compiled.compaction.firstKeptEntryId,\n tokensBefore,\n compiled.compaction.details,\n true,\n );\n compactionOutcome = {\n applied: true,\n sections: compiled.compaction.details?.sections ?? [],\n tokensBefore,\n firstKeptEntryId: compiled.compaction.firstKeptEntryId,\n };\n }\n }\n synchronizeSourceSettings(session, seed);\n session.appendMessage(seed.outerToolResult);\n if (digest) {\n session.appendCustomMessageEntry(THINKING_DIGEST_CUSTOM_TYPE, digest.content, false, {\n policy,\n citedBlocks: digest.citedBlocks,\n });\n }\n session.appendCustomEntry(\"pi-fabric-handoff\", {\n sourceSessionId: seed.sourceSessionId,\n boundary: \"fabric_exec_end\",\n ...(compactionOutcome\n ? {\n compaction: compactionOutcome.applied\n ? {\n applied: true,\n sections: compactionOutcome.sections,\n tokensBefore: compactionOutcome.tokensBefore,\n firstKeptEntryId: compactionOutcome.firstKeptEntryId,\n }\n : { applied: false, reason: compactionOutcome.reason },\n }\n : {}),\n ...(transfer && report\n ? {\n thinkingTransfer: {\n policy: report.policy,\n translated: report.translated,\n dropped: report.dropped,\n target: `${transfer.target.provider}/${transfer.target.modelId}`,\n },\n }\n : {}),\n });\n const sessionFile = session.getSessionFile();\n if (!sessionFile) throw new Error(\"Trajectory handoff did not produce a Pi session file\");\n fs.chmodSync(sessionFile, 0o600);\n return sessionFile;\n};\n", "import type { FabricPeerInfo } from \"./types.js\";\n\n/** Quiet window after a peer's last observed activity before it counts as settled. */\nconst DEFAULT_PEER_SETTLED_FOR_MS = 3_000;\nconst PEER_SETTLE_POLL_MS = 500;\n\n/**\n * Derive a Linear-style label prefix from a project path's basename:\n * \"pi-queue-steer\" -> \"PQS\", \"fabric\" -> \"FAB\". Falls back to \"P\".\n */\nexport const peerLabelPrefix = (cwd: string | undefined): string => {\n\tconst base = cwd?.split(/[\\\\/]/).filter(Boolean).at(-1) ?? \"\";\n\tconst words = base.split(/[^A-Za-z0-9]+/).filter(Boolean);\n\tif (words.length === 0) return \"P\";\n\t// Single-word projects borrow the first letters (\"fabric\" -> \"FAB\"),\n\t// multi-word projects take word initials (\"pi-queue-steer\" -> \"PQS\").\n\tif (words.length === 1) return words[0]!.slice(0, 3).toUpperCase();\n\treturn words\n\t\t.slice(0, 4)\n\t\t.map((word) => word[0]!.toUpperCase())\n\t\t.join(\"\");\n};\n\n/** Snapshot of one root peer session for pickers and status lines. */\nexport interface FabricPeerCard {\n\tid: string;\n\tlabel: string;\n\tstatus: \"idle\" | \"running\";\n\tmodel?: string;\n\tcwd?: string;\n\tstartedAt: number;\n\tupdatedAt: number;\n\tpendingMessages: boolean;\n}\n\n/** Labels are chronological, so creation order is simply label minting order. */\nexport const buildPeerCards = (peers: readonly FabricPeerInfo[]): FabricPeerCard[] =>\n\t[...peers]\n\t\t.sort((left, right) => left.startedAt - right.startedAt || left.id.localeCompare(right.id))\n\t\t.map((peer) => ({\n\t\t\tid: peer.id,\n\t\t\tlabel: peer.label ?? peer.name,\n\t\t\tstatus: peer.status,\n\t\t\t...(peer.model ? { model: peer.model } : {}),\n\t\t\t...(peer.cwd ? { cwd: peer.cwd } : {}),\n\t\t\tstartedAt: peer.startedAt,\n\t\t\tupdatedAt: peer.updatedAt,\n\t\t\tpendingMessages: peer.pendingMessages,\n\t\t}));\n\ninterface PeerSettleProgress {\n\twaiting: Array<{ label: string; status: \"idle\" | \"running\" }>;\n}\n\nexport type PeerSettleResult = { ok: true } | { ok: false; error: string };\n\nexport interface AwaitPeerSettleOptions {\n\t/** Fresh peer snapshot source (typically FabricRuntimeState.peerInfos()). */\n\tpoll: () => FabricPeerInfo[];\n\t/** Peer label (case-insensitive) or exact participant id. Omitted means all peers. */\n\tselector?: string;\n\tsettledForMs?: number;\n\tpollMs?: number;\n\tnow?: () => number;\n\tsignal?: AbortSignal;\n\tonUpdate?: (progress: PeerSettleProgress) => void;\n}\n\nconst matchesSelector = (peer: FabricPeerInfo, selector: string): boolean => {\n\tconst target = selector.trim().toLowerCase();\n\tif (!target) return false;\n\treturn (\n\t\tpeer.id.toLowerCase() === target ||\n\t\t(peer.label ?? \"\").toLowerCase() === target ||\n\t\tpeer.name.toLowerCase() === target\n\t);\n};\n\ninterface WatchedPeer {\n\tid: string;\n\tlabel: string;\n\trunning: boolean;\n\t/** Last time the peer was observed running; undefined when quiet since arming. */\n\tlastRunningAt: number | undefined;\n\tsettled: boolean;\n}\n\n/**\n * Wait until every watched peer has settled: only runs that started after\n * arming delay it (an idle-at-arm peer satisfies once the quiet window\n * passes), and a peer vanishing from the mesh counts as settled since it can\n * no longer conflict.\n */\nexport const awaitPeerSettle = (options: AwaitPeerSettleOptions): Promise<PeerSettleResult> => {\n\tconst now = options.now ?? (() => Date.now());\n\tconst settledFor = Math.max(0, options.settledForMs ?? DEFAULT_PEER_SETTLED_FOR_MS);\n\tconst pollMs = Math.max(10, options.pollMs ?? PEER_SETTLE_POLL_MS);\n\tconst armedAt = now();\n\tconst initial = options.poll();\n\tconst targets =\n\t\toptions.selector !== undefined\n\t\t\t? initial.filter((peer) => matchesSelector(peer, options.selector ?? \"\"))\n\t\t\t: [...initial];\n\tif (options.selector !== undefined && targets.length === 0) {\n\t\treturn Promise.resolve({\n\t\t\tok: false,\n\t\t\terror: `No Fabric peer matches \"${options.selector}\" on this project mesh`,\n\t\t});\n\t}\n\tif (targets.length === 0) return Promise.resolve({ ok: true });\n\n\tconst watched = new Map<string, WatchedPeer>();\n\tfor (const peer of targets) {\n\t\twatched.set(peer.id, {\n\t\t\tid: peer.id,\n\t\t\tlabel: peer.label ?? peer.name,\n\t\t\trunning: peer.status === \"running\",\n\t\t\tlastRunningAt: peer.status === \"running\" ? armedAt : undefined,\n\t\t\tsettled: false,\n\t\t});\n\t}\n\n\treturn new Promise<PeerSettleResult>((resolve) => {\n\t\tlet timer: ReturnType<typeof setInterval> | undefined;\n\t\tlet done = false;\n\t\tconst finish = (result: PeerSettleResult): void => {\n\t\t\tif (done) return;\n\t\t\tdone = true;\n\t\t\tif (timer) clearInterval(timer);\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(result);\n\t\t};\n\t\tconst onAbort = (): void => finish({ ok: false, error: \"cancelled\" });\n\t\tconst tick = (): void => {\n\t\t\tconst snapshot = options.poll();\n\t\t\tconst byId = new Map(snapshot.map((peer) => [peer.id, peer] as const));\n\t\t\tconst current = now();\n\t\t\tfor (const entry of watched.values()) {\n\t\t\t\tif (entry.settled) continue;\n\t\t\t\tconst peer = byId.get(entry.id);\n\t\t\t\tif (!peer) {\n\t\t\t\t\tentry.settled = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tentry.label = peer.label ?? peer.name;\n\t\t\t\tconst running = peer.status === \"running\";\n\t\t\t\tif (running) {\n\t\t\t\t\tentry.lastRunningAt = current;\n\t\t\t\t\tentry.running = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tentry.running = false;\n\t\t\t\tconst quietSince = entry.lastRunningAt ?? armedAt;\n\t\t\t\tif (current - quietSince >= settledFor) entry.settled = true;\n\t\t\t}\n\t\t\tconst waiting = [...watched.values()]\n\t\t\t\t.filter((entry) => !entry.settled)\n\t\t\t\t.map((entry) => ({ label: entry.label, status: entry.running ? \"running\" : \"idle\" }) as const);\n\t\t\tif (waiting.length === 0) {\n\t\t\t\toptions.onUpdate?.({ waiting });\n\t\t\t\tfinish({ ok: true });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.onUpdate?.({ waiting });\n\t\t};\n\t\tif (options.signal) {\n\t\t\tif (options.signal.aborted) {\n\t\t\t\tfinish({ ok: false, error: \"cancelled\" });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\toptions.signal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t}\n\t\ttimer = setInterval(tick, pollMs);\n\t\ttick();\n\t});\n};\n"],
5
+ "mappings": ";;;;;;;;;;AAyDO,IAAM,8BAA8B;AAE3C,IAAM,yBAAyB;AAExB,IAAM,yBAAyB,CACpC,UAC2B;AAC3B,QAAM,EAAE,QAAQ,OAAO,IAAI;AAG3B,MACE,UACA,OAAO,aAAa,OAAO,aAC1B,OAAO,QAAQ,UAAa,OAAO,QAAQ,UAAa,OAAO,QAAQ,OAAO,MAC/E;AACA,WAAO;AAAA,EACT;AACA,MACE,OAAO,QAAQ,0BACf,OAAO,cAAc,QACrB,OAAO,2BAA2B,MA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UAAU;AAChB;AAAA,QACD;AACA,cAAM,UAAU;AAChB,cAAM,aAAa,MAAM,iBAAiB;AAC1C,YAAI,UAAU,cAAc,WAAY,OAAM,UAAU;AAAA,MACzD;AACA,YAAM,UAAU,CAAC,GAAG,QAAQ,OAAO,CAAC,EAClC,OAAO,CAAC,UAAU,CAAC,MAAM,OAAO,EAChC,IAAI,CAAC,WAAW,EAAE,OAAO,MAAM,OAAO,QAAQ,MAAM,UAAU,YAAY,OAAO,EAAW;AAC9F,UAAI,QAAQ,WAAW,GAAG;AACzB,gBAAQ,WAAW,EAAE,QAAQ,CAAC;AAC9B,eAAO,EAAE,IAAI,KAAK,CAAC;AACnB;AAAA,MACD;AACA,cAAQ,WAAW,EAAE,QAAQ,CAAC;AAAA,IAC/B;AACA,QAAI,QAAQ,QAAQ;AACnB,UAAI,QAAQ,OAAO,SAAS;AAC3B,eAAO,EAAE,IAAI,OAAO,OAAO,YAAY,CAAC;AACxC;AAAA,MACD;AACA,cAAQ,OAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAAA,IACjE;AACA,YAAQ,YAAY,MAAM,MAAM;AAChC,SAAK;AAAA,EACN,CAAC;AACF;",
6
+ "names": ["isRecord"]
7
+ }
@@ -0,0 +1,10 @@
1
+ // src/ref-names.ts
2
+ var sanitizeMcpRefPart = (value) => {
3
+ const sanitized = value.replace(/[^A-Za-z0-9_$]/g, "_");
4
+ return /^[A-Za-z_$]/.test(sanitized) ? sanitized : `_${sanitized}`;
5
+ };
6
+
7
+ export {
8
+ sanitizeMcpRefPart
9
+ };
10
+ //# sourceMappingURL=chunk-IGVDD2HT.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/ref-names.ts"],
4
+ "sourcesContent": ["// Identifier-safe shape used by the QuickJS `mcp.<server>.<tool>` proxy, the\n// rendered advisory refs, and the generated guest type declarations. Shared so\n// the provider, the advisory adapter, the declaration renderer, and the\n// transcript ash-replay all agree on how a raw name appears in code. Kept\n// dependency-free so runtime declaration builders and host providers can both\n// import it without pulling in provider dependency graphs.\nexport const sanitizeMcpRefPart = (value: string): string => {\n const sanitized = value.replace(/[^A-Za-z0-9_$]/g, \"_\");\n return /^[A-Za-z_$]/.test(sanitized) ? sanitized : `_${sanitized}`;\n};\n"],
5
+ "mappings": ";AAMO,IAAM,qBAAqB,CAAC,UAA0B;AAC3D,QAAM,YAAY,MAAM,QAAQ,mBAAmB,GAAG;AACtD,SAAO,cAAc,KAAK,SAAS,IAAI,YAAY,IAAI,SAAS;AAClE;",
6
+ "names": []
7
+ }