@e4779/pi-fabric 0.131.4-fork.33 → 0.138.1-fork.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (435) hide show
  1. package/README.md +8 -0
  2. package/dist/actors/context.d.ts.map +1 -1
  3. package/dist/agents/clone-first-worktree.d.ts +2 -0
  4. package/dist/agents/clone-first-worktree.d.ts.map +1 -1
  5. package/dist/agents/completion-inbox.d.ts +2 -1
  6. package/dist/agents/completion-inbox.d.ts.map +1 -1
  7. package/dist/agents/handoff.d.ts.map +1 -1
  8. package/dist/agents/manager.d.ts.map +1 -1
  9. package/dist/agents/worktree-manager.d.ts +4 -1
  10. package/dist/agents/worktree-manager.d.ts.map +1 -1
  11. package/dist/agents/worktree-paths.d.ts +8 -3
  12. package/dist/agents/worktree-paths.d.ts.map +1 -1
  13. package/dist/agents.js +6 -1
  14. package/dist/agents.js.map +1 -1
  15. package/dist/async-settlement.d.ts +1 -1
  16. package/dist/async-settlement.d.ts.map +1 -1
  17. package/dist/audit/details.d.ts.map +1 -1
  18. package/dist/capture/catalog.d.ts +2 -0
  19. package/dist/capture/catalog.d.ts.map +1 -1
  20. package/dist/capture/interceptor.d.ts.map +1 -1
  21. package/dist/chunks/{chunk-7N7IC3Z2.js → chunk-2CD7HLVP.js} +3 -84
  22. package/dist/chunks/chunk-2CD7HLVP.js.map +7 -0
  23. package/dist/chunks/{chunk-7YNE4NB2.js → chunk-2MELFQCQ.js} +2 -2
  24. package/dist/chunks/{chunk-HSEZPCL5.js → chunk-2OC4YJOL.js} +3 -3
  25. package/dist/chunks/{chunk-TXCNZCZP.js → chunk-2QJ4MNS6.js} +2 -2
  26. package/dist/chunks/{chunk-F6A6MQ6G.js → chunk-2WPTD6BI.js} +11 -15
  27. package/dist/chunks/chunk-2WPTD6BI.js.map +7 -0
  28. package/dist/chunks/{chunk-QOEOKW2X.js → chunk-3QH6JAE3.js} +2 -2
  29. package/dist/chunks/chunk-4U47NCP2.js +88 -0
  30. package/dist/chunks/chunk-4U47NCP2.js.map +7 -0
  31. package/dist/chunks/{chunk-OJ4HAALD.js → chunk-5VZEAAHD.js} +10 -9
  32. package/dist/chunks/chunk-5VZEAAHD.js.map +7 -0
  33. package/dist/chunks/{chunk-LKYLD5SN.js → chunk-6HM4TX7L.js} +10 -8
  34. package/dist/chunks/chunk-6HM4TX7L.js.map +7 -0
  35. package/dist/chunks/{chunk-L6H46CPY.js → chunk-6NNL5LOG.js} +2 -2
  36. package/dist/chunks/{chunk-7TB7NXSL.js → chunk-7CIQQOOD.js} +11 -3
  37. package/dist/chunks/{chunk-7TB7NXSL.js.map → chunk-7CIQQOOD.js.map} +2 -2
  38. package/dist/chunks/{chunk-RWKQ5SRW.js → chunk-7ZFPVOV2.js} +2 -2
  39. package/dist/chunks/{chunk-PUBHBEYO.js → chunk-B2FIGOPI.js} +2 -2
  40. package/dist/chunks/{chunk-HRDMBGMY.js → chunk-BLT66VHH.js} +331 -22
  41. package/dist/chunks/chunk-BLT66VHH.js.map +7 -0
  42. package/dist/chunks/{chunk-4WKD3YM3.js → chunk-C3UPHOJW.js} +3 -3
  43. package/dist/chunks/{chunk-G2DZJ5LK.js → chunk-CB72SLHB.js} +451 -134
  44. package/dist/chunks/chunk-CB72SLHB.js.map +7 -0
  45. package/dist/chunks/{chunk-B5L3X3ID.js → chunk-CCJ6PUZJ.js} +1 -1
  46. package/dist/chunks/{chunk-B5L3X3ID.js.map → chunk-CCJ6PUZJ.js.map} +1 -1
  47. package/dist/chunks/{chunk-FK73YJKV.js → chunk-DWM63MAJ.js} +21 -9
  48. package/dist/chunks/chunk-DWM63MAJ.js.map +7 -0
  49. package/dist/chunks/{chunk-56NMRVTV.js → chunk-FFJ7TV66.js} +32 -29
  50. package/dist/chunks/chunk-FFJ7TV66.js.map +7 -0
  51. package/dist/chunks/{chunk-LRSZFYUC.js → chunk-FUMALXYQ.js} +15 -15
  52. package/dist/chunks/chunk-FUMALXYQ.js.map +7 -0
  53. package/dist/chunks/{chunk-TJZYM2SP.js → chunk-G3RQ3HUK.js} +8 -3
  54. package/dist/chunks/{chunk-TJZYM2SP.js.map → chunk-G3RQ3HUK.js.map} +2 -2
  55. package/dist/chunks/{chunk-RAA3FAYZ.js → chunk-GNPTDN6K.js} +2 -2
  56. package/dist/chunks/{chunk-XFOSUGLU.js → chunk-JCGEW5OQ.js} +5 -5
  57. package/dist/chunks/{chunk-CXYJJ3HZ.js → chunk-LJ2MG6U2.js} +3 -3
  58. package/dist/chunks/{chunk-3MOY6WIB.js → chunk-LRBDEAKB.js} +3 -3
  59. package/dist/chunks/{chunk-2RWNVCFD.js → chunk-MPFBOVOD.js} +1 -1
  60. package/dist/chunks/{chunk-2RWNVCFD.js.map → chunk-MPFBOVOD.js.map} +1 -1
  61. package/dist/chunks/{chunk-NQ7IWEIF.js → chunk-MQGRQMVM.js} +2 -2
  62. package/dist/chunks/{chunk-3VK6UGAN.js → chunk-O5SHIUIL.js} +6 -1
  63. package/dist/chunks/chunk-O5SHIUIL.js.map +7 -0
  64. package/dist/chunks/{chunk-U6Y6TKJL.js → chunk-OK2EKY3M.js} +15 -11
  65. package/dist/chunks/chunk-OK2EKY3M.js.map +7 -0
  66. package/dist/chunks/{chunk-DGUXJSYA.js → chunk-OR44GYXD.js} +70 -3
  67. package/dist/chunks/chunk-OR44GYXD.js.map +7 -0
  68. package/dist/chunks/{chunk-DGERP4VL.js → chunk-P4TALNLX.js} +11 -10
  69. package/dist/chunks/chunk-P4TALNLX.js.map +7 -0
  70. package/dist/chunks/{chunk-4BYS4ZLY.js → chunk-PHGPOSCP.js} +267 -71
  71. package/dist/chunks/chunk-PHGPOSCP.js.map +7 -0
  72. package/dist/chunks/{chunk-3XT5WHSG.js → chunk-QAGEWWCJ.js} +260 -59
  73. package/dist/chunks/chunk-QAGEWWCJ.js.map +7 -0
  74. package/dist/chunks/{chunk-WKFRGICG.js → chunk-RBYRHS24.js} +2 -2
  75. package/dist/chunks/{chunk-ZHROHNEE.js → chunk-RFNYH7S7.js} +8 -8
  76. package/dist/chunks/{chunk-VGRUWTMG.js → chunk-RPZJVLML.js} +472 -466
  77. package/dist/chunks/chunk-RPZJVLML.js.map +7 -0
  78. package/dist/chunks/{chunk-H57KPL3V.js → chunk-S2JWFXW5.js} +2 -2
  79. package/dist/chunks/{chunk-LZ2ZXOCU.js → chunk-SSB2JN3I.js} +168 -5
  80. package/dist/chunks/chunk-SSB2JN3I.js.map +7 -0
  81. package/dist/chunks/{chunk-RKJPBTBB.js → chunk-SVQ7ZHEQ.js} +33 -16
  82. package/dist/chunks/chunk-SVQ7ZHEQ.js.map +7 -0
  83. package/dist/chunks/{chunk-MPMEK3IQ.js → chunk-TV5NCPPS.js} +6 -5
  84. package/dist/chunks/chunk-TV5NCPPS.js.map +7 -0
  85. package/dist/chunks/{chunk-XOBLUZMB.js → chunk-UIVMSMSQ.js} +10 -1
  86. package/dist/chunks/chunk-UIVMSMSQ.js.map +7 -0
  87. package/dist/chunks/{chunk-QGTD3LAZ.js → chunk-UYS5VZUU.js} +9 -3
  88. package/dist/chunks/chunk-UYS5VZUU.js.map +7 -0
  89. package/dist/chunks/{chunk-HRVYXRWZ.js → chunk-V5RZK45W.js} +37 -3
  90. package/dist/chunks/chunk-V5RZK45W.js.map +7 -0
  91. package/dist/chunks/{chunk-KIFOEBYJ.js → chunk-VEXCD3RA.js} +2 -2
  92. package/dist/chunks/{chunk-GS67KDMV.js → chunk-VN7AE3EY.js} +2 -2
  93. package/dist/chunks/{chunk-HFDJWLMS.js → chunk-WFGJUVTH.js} +106 -65
  94. package/dist/chunks/chunk-WFGJUVTH.js.map +7 -0
  95. package/dist/chunks/chunk-WMULZZER.js +196 -0
  96. package/dist/chunks/chunk-WMULZZER.js.map +7 -0
  97. package/dist/chunks/{chunk-QNMQJNXE.js → chunk-X4HDI7RT.js} +14 -4
  98. package/dist/chunks/chunk-X4HDI7RT.js.map +7 -0
  99. package/dist/chunks/{chunk-MX53BRAC.js → chunk-XBAOTA4U.js} +2 -2
  100. package/dist/chunks/{chunk-MSDL7U6Q.js → chunk-XQCNVH3Y.js} +4 -4
  101. package/dist/chunks/{chunk-4PBW54I2.js → chunk-YC6NV7FK.js} +88 -54
  102. package/dist/chunks/chunk-YC6NV7FK.js.map +7 -0
  103. package/dist/chunks/{chunk-6GWDGTHC.js → chunk-YLO62DWD.js} +4 -4
  104. package/dist/cli/decisions.js +2 -2
  105. package/dist/cli/mesh.js +3 -3
  106. package/dist/commands/fabric-handler.d.ts.map +1 -1
  107. package/dist/commands/fabric-handler.js +18 -4
  108. package/dist/commands/fabric-handler.js.map +2 -2
  109. package/dist/commands/fabric.d.ts.map +1 -1
  110. package/dist/compaction/branch-summary.d.ts.map +1 -1
  111. package/dist/compaction/claim-events.js +9 -9
  112. package/dist/compaction/hook.d.ts.map +1 -1
  113. package/dist/compaction/hook.js +6 -6
  114. package/dist/compaction/normalize.d.ts +9 -0
  115. package/dist/compaction/normalize.d.ts.map +1 -1
  116. package/dist/compaction/owner.js +7 -7
  117. package/dist/compaction/projections.d.ts +18 -2
  118. package/dist/compaction/projections.d.ts.map +1 -1
  119. package/dist/compaction/qa.d.ts +3 -2
  120. package/dist/compaction/qa.d.ts.map +1 -1
  121. package/dist/compaction/render.d.ts +3 -0
  122. package/dist/compaction/render.d.ts.map +1 -1
  123. package/dist/compaction/threshold.d.ts.map +1 -1
  124. package/dist/compaction/user-activity.d.ts +31 -0
  125. package/dist/compaction/user-activity.d.ts.map +1 -0
  126. package/dist/components/configuration.js +4 -4
  127. package/dist/config.d.ts +13 -6
  128. package/dist/config.d.ts.map +1 -1
  129. package/dist/core/action-registry.d.ts +1 -1
  130. package/dist/core/action-registry.d.ts.map +1 -1
  131. package/dist/core/action-registry.js +10 -9
  132. package/dist/core/approval-controller.d.ts +3 -0
  133. package/dist/core/approval-controller.d.ts.map +1 -1
  134. package/dist/core/atomic-write.d.ts +1 -0
  135. package/dist/core/atomic-write.d.ts.map +1 -1
  136. package/dist/core/attached-monitors.d.ts +39 -0
  137. package/dist/core/attached-monitors.d.ts.map +1 -0
  138. package/dist/core/control-abort.d.ts +3 -0
  139. package/dist/core/control-abort.d.ts.map +1 -0
  140. package/dist/core/crash-guard.d.ts +15 -0
  141. package/dist/core/crash-guard.d.ts.map +1 -0
  142. package/dist/core/execution-guidelines.d.ts +6 -0
  143. package/dist/core/execution-guidelines.d.ts.map +1 -0
  144. package/dist/core/guidance-delivery.d.ts +19 -0
  145. package/dist/core/guidance-delivery.d.ts.map +1 -0
  146. package/dist/core/lifecycle-settlement.d.ts +9 -0
  147. package/dist/core/lifecycle-settlement.d.ts.map +1 -0
  148. package/dist/core/observation-actions.d.ts +9 -0
  149. package/dist/core/observation-actions.d.ts.map +1 -0
  150. package/dist/core/pasted-images.d.ts +12 -0
  151. package/dist/core/pasted-images.d.ts.map +1 -0
  152. package/dist/core/pasted-images.js +139 -0
  153. package/dist/core/pasted-images.js.map +7 -0
  154. package/dist/core/permission-queue.d.ts +32 -0
  155. package/dist/core/permission-queue.d.ts.map +1 -0
  156. package/dist/core/permission-queue.js +104 -0
  157. package/dist/core/permission-queue.js.map +7 -0
  158. package/dist/core/prompt-guidance.d.ts +1 -0
  159. package/dist/core/prompt-guidance.d.ts.map +1 -1
  160. package/dist/core/prompt-guidance.js +52 -3
  161. package/dist/core/prompt-guidance.js.map +3 -3
  162. package/dist/core/provider-operations.js +1 -1
  163. package/dist/core/shell-inbox.d.ts +1 -1
  164. package/dist/core/shell-inbox.d.ts.map +1 -1
  165. package/dist/core/shell-jobs.d.ts +28 -1
  166. package/dist/core/shell-jobs.d.ts.map +1 -1
  167. package/dist/core/shell-monitor.d.ts +1 -0
  168. package/dist/core/shell-monitor.d.ts.map +1 -1
  169. package/dist/durable/worker.js +0 -42
  170. package/dist/durable/worker.js.map +3 -3
  171. package/dist/durable-extension.d.ts +2 -2
  172. package/dist/durable-extension.d.ts.map +1 -1
  173. package/dist/durable-extension.js +215 -1
  174. package/dist/durable-extension.js.map +3 -3
  175. package/dist/entropy/index.d.ts +2 -0
  176. package/dist/entropy/index.d.ts.map +1 -1
  177. package/dist/entropy/index.js +23 -13
  178. package/dist/entropy/pool-store.d.ts +8 -1
  179. package/dist/entropy/pool-store.d.ts.map +1 -1
  180. package/dist/entropy/pool-worker.d.ts +18 -0
  181. package/dist/entropy/pool-worker.d.ts.map +1 -0
  182. package/dist/entropy/pool-writer.d.ts +23 -0
  183. package/dist/entropy/pool-writer.d.ts.map +1 -0
  184. package/dist/entropy/pool.d.ts +11 -0
  185. package/dist/entropy/pool.d.ts.map +1 -1
  186. package/dist/entropy/sessions.d.ts +5 -0
  187. package/dist/entropy/sessions.d.ts.map +1 -1
  188. package/dist/execution-service.d.ts.map +1 -1
  189. package/dist/extension-bootstrap.d.ts.map +1 -1
  190. package/dist/extension-bootstrap.js +19 -19
  191. package/dist/extension.d.ts.map +1 -1
  192. package/dist/fabric-exec-tool.d.ts.map +1 -1
  193. package/dist/fabric-runtime-state.d.ts.map +1 -1
  194. package/dist/fabric-runtime-state.js +534 -261
  195. package/dist/fabric-runtime-state.js.map +4 -4
  196. package/dist/fabric-state.d.ts.map +1 -1
  197. package/dist/index.js +40 -30
  198. package/dist/index.js.map +1 -1
  199. package/dist/jev/client.js +2 -2
  200. package/dist/jev/observation.js +7 -6
  201. package/dist/jev.js +12 -11
  202. package/dist/main-agent.d.ts.map +1 -1
  203. package/dist/managed-host.d.ts +4 -0
  204. package/dist/managed-host.d.ts.map +1 -1
  205. package/dist/memory/discovery.js +6 -6
  206. package/dist/memory/expand-service.d.ts.map +1 -1
  207. package/dist/memory/file-worker.js +9 -8
  208. package/dist/memory/file-worker.js.map +1 -1
  209. package/dist/memory/history-paging.d.ts +9 -0
  210. package/dist/memory/history-paging.d.ts.map +1 -0
  211. package/dist/memory/history-paging.js +164 -0
  212. package/dist/memory/history-paging.js.map +7 -0
  213. package/dist/memory/index.d.ts.map +1 -1
  214. package/dist/memory/normalize.js +5 -5
  215. package/dist/memory/outline-service.d.ts +7 -0
  216. package/dist/memory/outline-service.d.ts.map +1 -0
  217. package/dist/memory/request-cache.d.ts +3 -1
  218. package/dist/memory/request-cache.d.ts.map +1 -1
  219. package/dist/memory/request-context.d.ts +1 -0
  220. package/dist/memory/request-context.d.ts.map +1 -1
  221. package/dist/memory/request-limits.d.ts +2 -0
  222. package/dist/memory/request-limits.d.ts.map +1 -1
  223. package/dist/memory/search.js +7 -6
  224. package/dist/memory/worker-provider.d.ts.map +1 -1
  225. package/dist/memory/worker-provider.js +10 -9
  226. package/dist/memory.d.ts +16 -1
  227. package/dist/memory.d.ts.map +1 -1
  228. package/dist/memory.js +64 -12
  229. package/dist/memory.js.map +1 -1
  230. package/dist/mesh/store.d.ts +2 -1
  231. package/dist/mesh/store.d.ts.map +1 -1
  232. package/dist/programs/host.js +2 -2
  233. package/dist/protocol.d.ts +5 -0
  234. package/dist/protocol.d.ts.map +1 -1
  235. package/dist/protocol.js +1 -1
  236. package/dist/providers/agents-actions.d.ts.map +1 -1
  237. package/dist/providers/agents-message-router.d.ts +1 -0
  238. package/dist/providers/agents-message-router.d.ts.map +1 -1
  239. package/dist/providers/agents-provider.d.ts +2 -0
  240. package/dist/providers/agents-provider.d.ts.map +1 -1
  241. package/dist/providers/jev-provider.js +12 -11
  242. package/dist/providers/memory-provider.d.ts +4 -0
  243. package/dist/providers/memory-provider.d.ts.map +1 -1
  244. package/dist/providers/memory-provider.js +9 -8
  245. package/dist/providers/pi-read-operations.d.ts +24 -0
  246. package/dist/providers/pi-read-operations.d.ts.map +1 -0
  247. package/dist/providers/pi-tools-provider.d.ts +7 -0
  248. package/dist/providers/pi-tools-provider.d.ts.map +1 -1
  249. package/dist/providers/sessions-provider.d.ts +1 -1
  250. package/dist/providers/sessions-provider.d.ts.map +1 -1
  251. package/dist/providers/tasks-provider.d.ts +3 -1
  252. package/dist/providers/tasks-provider.d.ts.map +1 -1
  253. package/dist/residency/actor-client.js +3 -3
  254. package/dist/residency/client.d.ts.map +1 -1
  255. package/dist/residency/host.d.ts.map +1 -1
  256. package/dist/residency/host.js +17 -16
  257. package/dist/residency/launcher.js +1 -1
  258. package/dist/residency/pi-entry.js +17 -16
  259. package/dist/residency/pi-entry.js.map +1 -1
  260. package/dist/residency/protocol.d.ts +2 -0
  261. package/dist/residency/protocol.d.ts.map +1 -1
  262. package/dist/runtime/core-override-guest-types.js +2 -2
  263. package/dist/runtime/cpython-runtime.d.ts.map +1 -1
  264. package/dist/runtime/cpython-runtime.js +7 -6
  265. package/dist/runtime/cpython-runtime.js.map +2 -2
  266. package/dist/runtime/guest-types.d.ts +1 -1
  267. package/dist/runtime/guest-types.d.ts.map +1 -1
  268. package/dist/runtime/guest-types.js +1 -1
  269. package/dist/runtime/monty-runtime.d.ts.map +1 -1
  270. package/dist/runtime/monty-runtime.js +7 -6
  271. package/dist/runtime/monty-runtime.js.map +2 -2
  272. package/dist/runtime/node-process-runtime.d.ts.map +1 -1
  273. package/dist/runtime/node-process-runtime.js +6 -6
  274. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  275. package/dist/runtime/quickjs-runtime.js +4 -4
  276. package/dist/runtime/type-checker.d.ts.map +1 -1
  277. package/dist/runtime/type-checker.js +1 -1
  278. package/dist/runtime/typescript-kernel.js +10 -10
  279. package/dist/runtime-state-builtins.d.ts +2 -0
  280. package/dist/runtime-state-builtins.d.ts.map +1 -1
  281. package/dist/schema/policy.d.ts.map +1 -1
  282. package/dist/speculation/eligibility.d.ts.map +1 -1
  283. package/dist/speculation/store.d.ts.map +1 -1
  284. package/dist/topology/participant-directory.d.ts +1 -0
  285. package/dist/topology/participant-directory.d.ts.map +1 -1
  286. package/dist/topology/peer-presence.d.ts.map +1 -1
  287. package/dist/topology/provider-participants.d.ts +1 -0
  288. package/dist/topology/provider-participants.d.ts.map +1 -1
  289. package/dist/type-error-guidance.js +1 -1
  290. package/dist/ui/code-preview-shell.d.ts +1 -0
  291. package/dist/ui/code-preview-shell.d.ts.map +1 -1
  292. package/dist/ui/controller.d.ts.map +1 -1
  293. package/dist/ui/conversation-chrome.d.ts.map +1 -1
  294. package/dist/ui/conversation-chrome.js +2 -2
  295. package/dist/ui/conversation-feedback.d.ts +8 -0
  296. package/dist/ui/conversation-feedback.d.ts.map +1 -0
  297. package/dist/ui/conversation-latest.d.ts.map +1 -1
  298. package/dist/ui/conversation-native-reader.d.ts.map +1 -1
  299. package/dist/ui/conversation-native-reader.js +3 -3
  300. package/dist/ui/conversation-native-reader.js.map +2 -2
  301. package/dist/ui/conversation-render.d.ts.map +1 -1
  302. package/dist/ui/conversation.d.ts +1 -0
  303. package/dist/ui/conversation.d.ts.map +1 -1
  304. package/dist/ui/conversation.js +139 -86
  305. package/dist/ui/conversation.js.map +4 -4
  306. package/dist/ui/core-tool-render.d.ts.map +1 -1
  307. package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -1
  308. package/dist/ui/dashboard.js +47 -48
  309. package/dist/ui/dashboard.js.map +3 -3
  310. package/dist/ui/fabric-render.d.ts.map +1 -1
  311. package/dist/ui/format.d.ts.map +1 -1
  312. package/dist/ui/highlight.d.ts.map +1 -1
  313. package/dist/ui/permissions.d.ts +18 -0
  314. package/dist/ui/permissions.d.ts.map +1 -0
  315. package/dist/ui/permissions.js +178 -0
  316. package/dist/ui/permissions.js.map +7 -0
  317. package/dist/ui/row-balance.d.ts +1 -1
  318. package/dist/ui/row-balance.d.ts.map +1 -1
  319. package/dist/ui/settings-sections-execution.d.ts.map +1 -1
  320. package/dist/ui/settings-values.d.ts.map +1 -1
  321. package/dist/ui/settings.js +37 -31
  322. package/dist/ui/settings.js.map +2 -2
  323. package/dist/ui/shell-hang-keys.d.ts.map +1 -1
  324. package/dist/ui/shell-tasks.d.ts.map +1 -1
  325. package/dist/ui/shell-tasks.js +28 -11
  326. package/dist/ui/shell-tasks.js.map +2 -2
  327. package/dist/ui/structured.d.ts.map +1 -1
  328. package/dist/ui/tool-display.d.ts +18 -2
  329. package/dist/ui/tool-display.d.ts.map +1 -1
  330. package/dist/ui/truncate.d.ts +3 -0
  331. package/dist/ui/truncate.d.ts.map +1 -0
  332. package/dist/ui/widget.d.ts +7 -2
  333. package/dist/ui/widget.d.ts.map +1 -1
  334. package/dist/verified/context.d.ts +35 -0
  335. package/dist/verified/context.d.ts.map +1 -0
  336. package/dist/verified/execution.d.ts +7 -0
  337. package/dist/verified/execution.d.ts.map +1 -0
  338. package/dist/verified/generated/context.d.ts +6 -0
  339. package/dist/verified/generated/context.js +51 -0
  340. package/dist/verified/generated/execution.d.ts +5 -0
  341. package/dist/verified/generated/execution.js +32 -0
  342. package/dist/verified/generated/manifest.json +34 -3
  343. package/dist/verified/generated/prompt-guidance.d.ts +4 -0
  344. package/dist/verified/generated/prompt-guidance.js +17 -0
  345. package/dist/worker/recovery-watchdog.d.ts +7 -0
  346. package/dist/worker/recovery-watchdog.d.ts.map +1 -1
  347. package/dist/worker/recovery-watchdog.js +66 -4
  348. package/dist/worker/recovery-watchdog.js.map +2 -2
  349. package/dist/worker.js +22 -3
  350. package/dist/worker.js.map +2 -2
  351. package/docs/agents.md +37 -4
  352. package/docs/architecture.md +13 -0
  353. package/docs/background-tasks.md +81 -5
  354. package/docs/benchmarks/cli-resume-2026-11-09.json +1260 -0
  355. package/docs/benchmarks/interactivity-2026-11-09.json +2280 -0
  356. package/docs/benchmarks/resume-latency-2026-11-09.json +12105 -0
  357. package/docs/benchmarks/resume-startup-fix-2026-11-09.json +5452 -0
  358. package/docs/benchmarks/session-memory-2026-11-09.json +1320 -0
  359. package/docs/benchmarks/session-memory-fix-2026-11-09.json +280 -0
  360. package/docs/compaction.md +59 -23
  361. package/docs/configuration.md +53 -11
  362. package/docs/entropy.md +4 -1
  363. package/docs/history-paging.md +99 -0
  364. package/docs/interactivity-investigation.md +109 -0
  365. package/docs/interface.md +2 -2
  366. package/docs/jev.md +1 -1
  367. package/docs/memory-recall.md +42 -1
  368. package/docs/providers.md +24 -1
  369. package/docs/resume-latency-investigation.md +249 -0
  370. package/docs/session-memory-investigation.md +223 -0
  371. package/docs/verified-kernels.md +56 -0
  372. package/package.json +211 -211
  373. package/proofs/context.ts +139 -0
  374. package/proofs/execution.ts +48 -0
  375. package/proofs/index.ts +6 -0
  376. package/proofs/prompt-guidance.ts +38 -0
  377. package/scripts/verified-kernels.ts +1 -1
  378. package/skillsets/python/fabric-council/SKILL.md +31 -21
  379. package/skillsets/python/fabric-exec/SKILL.md +1 -1
  380. package/skillsets/python/fabric-exec/references/agents.md +2 -0
  381. package/skillsets/python/fabric-guide/SKILL.md +1 -0
  382. package/skillsets/python/fabric-memory/SKILL.md +82 -0
  383. package/skillsets/typescript/fabric-council/SKILL.md +26 -17
  384. package/skillsets/typescript/fabric-exec/SKILL.md +3 -2
  385. package/skillsets/typescript/fabric-exec/references/agents.md +1 -0
  386. package/skillsets/typescript/fabric-guide/SKILL.md +1 -0
  387. package/skillsets/typescript/fabric-memory/SKILL.md +87 -0
  388. package/dist/chunks/chunk-3VK6UGAN.js.map +0 -7
  389. package/dist/chunks/chunk-3XT5WHSG.js.map +0 -7
  390. package/dist/chunks/chunk-4BYS4ZLY.js.map +0 -7
  391. package/dist/chunks/chunk-4PBW54I2.js.map +0 -7
  392. package/dist/chunks/chunk-56NMRVTV.js.map +0 -7
  393. package/dist/chunks/chunk-7N7IC3Z2.js.map +0 -7
  394. package/dist/chunks/chunk-DGERP4VL.js.map +0 -7
  395. package/dist/chunks/chunk-DGUXJSYA.js.map +0 -7
  396. package/dist/chunks/chunk-F6A6MQ6G.js.map +0 -7
  397. package/dist/chunks/chunk-FK73YJKV.js.map +0 -7
  398. package/dist/chunks/chunk-G2DZJ5LK.js.map +0 -7
  399. package/dist/chunks/chunk-HFDJWLMS.js.map +0 -7
  400. package/dist/chunks/chunk-HRDMBGMY.js.map +0 -7
  401. package/dist/chunks/chunk-HRVYXRWZ.js.map +0 -7
  402. package/dist/chunks/chunk-LKYLD5SN.js.map +0 -7
  403. package/dist/chunks/chunk-LRSZFYUC.js.map +0 -7
  404. package/dist/chunks/chunk-LZ2ZXOCU.js.map +0 -7
  405. package/dist/chunks/chunk-MPMEK3IQ.js.map +0 -7
  406. package/dist/chunks/chunk-OJ4HAALD.js.map +0 -7
  407. package/dist/chunks/chunk-QGTD3LAZ.js.map +0 -7
  408. package/dist/chunks/chunk-QNMQJNXE.js.map +0 -7
  409. package/dist/chunks/chunk-RKJPBTBB.js.map +0 -7
  410. package/dist/chunks/chunk-U6Y6TKJL.js.map +0 -7
  411. package/dist/chunks/chunk-VGRUWTMG.js.map +0 -7
  412. package/dist/chunks/chunk-XOBLUZMB.js.map +0 -7
  413. package/dist/durable/openai-sse-patch.d.ts +0 -21
  414. package/dist/durable/openai-sse-patch.d.ts.map +0 -1
  415. /package/dist/chunks/{chunk-7YNE4NB2.js.map → chunk-2MELFQCQ.js.map} +0 -0
  416. /package/dist/chunks/{chunk-HSEZPCL5.js.map → chunk-2OC4YJOL.js.map} +0 -0
  417. /package/dist/chunks/{chunk-TXCNZCZP.js.map → chunk-2QJ4MNS6.js.map} +0 -0
  418. /package/dist/chunks/{chunk-QOEOKW2X.js.map → chunk-3QH6JAE3.js.map} +0 -0
  419. /package/dist/chunks/{chunk-L6H46CPY.js.map → chunk-6NNL5LOG.js.map} +0 -0
  420. /package/dist/chunks/{chunk-RWKQ5SRW.js.map → chunk-7ZFPVOV2.js.map} +0 -0
  421. /package/dist/chunks/{chunk-PUBHBEYO.js.map → chunk-B2FIGOPI.js.map} +0 -0
  422. /package/dist/chunks/{chunk-4WKD3YM3.js.map → chunk-C3UPHOJW.js.map} +0 -0
  423. /package/dist/chunks/{chunk-RAA3FAYZ.js.map → chunk-GNPTDN6K.js.map} +0 -0
  424. /package/dist/chunks/{chunk-XFOSUGLU.js.map → chunk-JCGEW5OQ.js.map} +0 -0
  425. /package/dist/chunks/{chunk-CXYJJ3HZ.js.map → chunk-LJ2MG6U2.js.map} +0 -0
  426. /package/dist/chunks/{chunk-3MOY6WIB.js.map → chunk-LRBDEAKB.js.map} +0 -0
  427. /package/dist/chunks/{chunk-NQ7IWEIF.js.map → chunk-MQGRQMVM.js.map} +0 -0
  428. /package/dist/chunks/{chunk-WKFRGICG.js.map → chunk-RBYRHS24.js.map} +0 -0
  429. /package/dist/chunks/{chunk-ZHROHNEE.js.map → chunk-RFNYH7S7.js.map} +0 -0
  430. /package/dist/chunks/{chunk-H57KPL3V.js.map → chunk-S2JWFXW5.js.map} +0 -0
  431. /package/dist/chunks/{chunk-KIFOEBYJ.js.map → chunk-VEXCD3RA.js.map} +0 -0
  432. /package/dist/chunks/{chunk-GS67KDMV.js.map → chunk-VN7AE3EY.js.map} +0 -0
  433. /package/dist/chunks/{chunk-MX53BRAC.js.map → chunk-XBAOTA4U.js.map} +0 -0
  434. /package/dist/chunks/{chunk-MSDL7U6Q.js.map → chunk-XQCNVH3Y.js.map} +0 -0
  435. /package/dist/chunks/{chunk-6GWDGTHC.js.map → chunk-YLO62DWD.js.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  import {
2
+ arcItem,
2
3
  arcItemStyled,
3
4
  captureFabricAgentPreviews,
4
5
  captureFabricCallHeadlinePreviews,
@@ -15,6 +16,7 @@ import {
15
16
  modelReadHint,
16
17
  nestedCallBody,
17
18
  nestedCallTitle,
19
+ pushArcItem,
18
20
  renderAgentToolPreviewLines,
19
21
  renderBoundedLines,
20
22
  renderCoreToolBody,
@@ -28,29 +30,30 @@ import {
28
30
  safeTerminalText,
29
31
  shellBackgroundShortcut,
30
32
  singleCallProgressLine
31
- } from "./chunk-RKJPBTBB.js";
32
- import {
33
- configureHighlighting,
34
- highlightCode,
35
- observePiTheme
36
- } from "./chunk-QNMQJNXE.js";
37
- import {
38
- activeStatuses,
39
- isActiveStatus,
40
- orderAgentsByCreation
41
- } from "./chunk-37NIOSVU.js";
33
+ } from "./chunk-SVQ7ZHEQ.js";
42
34
  import {
43
35
  animationFitsViewport,
44
36
  observeAnimationRows,
45
37
  updateSpinner
46
38
  } from "./chunk-O4A5UOXU.js";
39
+ import {
40
+ configureHighlighting,
41
+ highlightCode,
42
+ observePiTheme
43
+ } from "./chunk-X4HDI7RT.js";
47
44
  import {
48
45
  borderBadge,
49
46
  formatCost,
50
47
  formatDuration,
51
48
  formatTokens,
52
- safeText
53
- } from "./chunk-FK73YJKV.js";
49
+ safeText,
50
+ truncateStyledText
51
+ } from "./chunk-DWM63MAJ.js";
52
+ import {
53
+ activeStatuses,
54
+ isActiveStatus,
55
+ orderAgentsByCreation
56
+ } from "./chunk-37NIOSVU.js";
54
57
  import {
55
58
  repairFabricGuestCode
56
59
  } from "./chunk-VXZZJ44D.js";
@@ -73,12 +76,13 @@ import {
73
76
  filterPrewalkPlanningDirectives,
74
77
  formatSkillsForPrompt,
75
78
  hasPrewalkArmedPrompt,
79
+ hostOutputCeiling,
76
80
  isSelectedNativeMcpTool,
77
81
  prewalkArmedPrompt,
78
82
  resolveFabricIdentity,
79
83
  setModelSafely,
80
84
  withTrajectoryRearmDirective
81
- } from "./chunk-DGUXJSYA.js";
85
+ } from "./chunk-OR44GYXD.js";
82
86
  import {
83
87
  AgentTranscriptReader,
84
88
  isRoutineInternalCall
@@ -91,7 +95,7 @@ import {
91
95
  import {
92
96
  closeScratch,
93
97
  createScratch
94
- } from "./chunk-7YNE4NB2.js";
98
+ } from "./chunk-2MELFQCQ.js";
95
99
  import {
96
100
  resolveAgentDir
97
101
  } from "./chunk-PBDDXBHY.js";
@@ -106,20 +110,20 @@ import {
106
110
  loadFabricConfig,
107
111
  loadFabricConfigForScope,
108
112
  resolveForegroundTools
109
- } from "./chunk-LRSZFYUC.js";
113
+ } from "./chunk-FUMALXYQ.js";
110
114
  import {
111
115
  defaultCodePreviewSettings
112
116
  } from "./chunk-OKOHRXGF.js";
113
117
  import {
114
118
  compactAtConfiguredThreshold,
115
119
  fabricExecTitleHintCached
116
- } from "./chunk-3VK6UGAN.js";
120
+ } from "./chunk-O5SHIUIL.js";
117
121
  import {
118
122
  fabricWriteBindings
119
123
  } from "./chunk-SZUXWOO7.js";
120
124
  import {
121
125
  FileLockTimeoutError
122
- } from "./chunk-WKFRGICG.js";
126
+ } from "./chunk-RBYRHS24.js";
123
127
  import {
124
128
  ACTION_POLICY_HOOK_NAME_PATTERN,
125
129
  FabricActionPolicyHooks
@@ -135,11 +139,7 @@ import {
135
139
  ApprovalController,
136
140
  FabricAutoApprovalClassifier,
137
141
  FabricSessionApprovals
138
- } from "./chunk-4PBW54I2.js";
139
- import {
140
- getActiveRepairCompiler,
141
- setActiveCompiledSurface
142
- } from "./chunk-TXCNZCZP.js";
142
+ } from "./chunk-YC6NV7FK.js";
143
143
  import {
144
144
  FABRIC_ACTION_POLICY_REGISTER_EVENT,
145
145
  FABRIC_COMPACTION_OWNER_EVENT,
@@ -170,17 +170,14 @@ import {
170
170
  readFabricToolPlacementRequestV1,
171
171
  resolveFabricModelGuidance,
172
172
  snapshotFabricProgramRunRequestV1
173
- } from "./chunk-2RWNVCFD.js";
173
+ } from "./chunk-MPFBOVOD.js";
174
174
  import {
175
175
  normalizeRunDisplay
176
176
  } from "./chunk-OZCJU3PZ.js";
177
177
  import {
178
178
  isFabricExecutionTraceV1,
179
179
  readFabricExecutionTraceV1
180
- } from "./chunk-PUBHBEYO.js";
181
- import {
182
- stableJsonHash
183
- } from "./chunk-3YZUQESG.js";
180
+ } from "./chunk-B2FIGOPI.js";
184
181
  import {
185
182
  FABRIC_ACTOR_PI_HOST_EVENTS
186
183
  } from "./chunk-IIPKG52D.js";
@@ -188,6 +185,13 @@ import {
188
185
  FABRIC_THINKING_BOUNDS_ENV,
189
186
  FABRIC_THINKING_ENTRY_TYPE
190
187
  } from "./chunk-V73NIH6B.js";
188
+ import {
189
+ getActiveRepairCompiler,
190
+ setActiveCompiledSurface
191
+ } from "./chunk-2QJ4MNS6.js";
192
+ import {
193
+ stableJsonHash
194
+ } from "./chunk-3YZUQESG.js";
191
195
  import {
192
196
  readChildToolAllowlist
193
197
  } from "./chunk-6OGYPHNQ.js";
@@ -195,6 +199,19 @@ import {
195
199
  // src/audit/details.ts
196
200
  var FABRIC_EXECUTION_DETAILS_MAX_BYTES = 512 * 1024;
197
201
  var serializedBytes = (value) => Buffer.byteLength(JSON.stringify(value), "utf8");
202
+ var dropUntilFits = (details, items, drop, measured) => {
203
+ let bytes = measured;
204
+ while (bytes > FABRIC_EXECUTION_DETAILS_MAX_BYTES && items.length > 0) {
205
+ let estimate = bytes;
206
+ while (estimate > FABRIC_EXECUTION_DETAILS_MAX_BYTES && items.length > 0) {
207
+ const item = items.pop();
208
+ estimate -= serializedBytes(item) + (items.length > 0 ? 1 : 0);
209
+ drop(item);
210
+ }
211
+ bytes = serializedBytes(details);
212
+ }
213
+ return bytes;
214
+ };
198
215
  var cloneTrace = (trace) => structuredClone(trace);
199
216
  var persistableAudit = (audit) => structuredClone({
200
217
  ref: audit.ref,
@@ -224,8 +241,7 @@ var createFabricPersistedExecutionDetails = (input) => {
224
241
  ...input.outputFormatStartLine !== void 0 ? { outputFormatStartLine: Math.max(0, Math.floor(input.outputFormatStartLine)) } : {},
225
242
  ...input.outputFormatLines !== void 0 ? { outputFormatLines: Math.max(0, Math.floor(input.outputFormatLines)) } : {}
226
243
  };
227
- while (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES && details.audits.length > 0) {
228
- const dropped = details.audits.pop();
244
+ let bytes = dropUntilFits(details, details.audits, (dropped) => {
229
245
  const omitted = details.omittedCalls ?? { count: 0, done: 0 };
230
246
  details.omittedCalls = {
231
247
  count: omitted.count + 1,
@@ -233,23 +249,21 @@ var createFabricPersistedExecutionDetails = (input) => {
233
249
  ...(omitted.internal ?? 0) + Number(isRoutineInternalCall(dropped)) > 0 ? { internal: (omitted.internal ?? 0) + Number(isRoutineInternalCall(dropped)) } : {},
234
250
  ...(omitted.failed ?? 0) + (dropped.success === false ? 1 : 0) > 0 ? { failed: (omitted.failed ?? 0) + (dropped.success === false ? 1 : 0) } : {}
235
251
  };
236
- }
237
- while (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES && details.assessment && details.assessment.operations.length > 0) {
238
- details.assessment.operations.pop();
239
- details.assessment.counts.droppedOperations++;
240
- }
241
- while (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES && details.trace.operations.length > 0) {
242
- details.trace.operations.pop();
252
+ }, serializedBytes(details));
253
+ const assessment = details.assessment;
254
+ if (assessment) {
255
+ bytes = dropUntilFits(details, assessment.operations, () => {
256
+ assessment.counts.droppedOperations++;
257
+ }, bytes);
258
+ }
259
+ bytes = dropUntilFits(details, details.trace.operations, () => {
243
260
  details.trace.counts.droppedOperations++;
244
- }
245
- while (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES && details.phases.length > 0) {
246
- details.phases.pop();
247
- }
248
- while (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES && details.trace.phases.length > 0) {
249
- details.trace.phases.pop();
261
+ }, bytes);
262
+ bytes = dropUntilFits(details, details.phases, () => void 0, bytes);
263
+ bytes = dropUntilFits(details, details.trace.phases, () => {
250
264
  details.trace.counts.droppedValues++;
251
- }
252
- if (serializedBytes(details) > FABRIC_EXECUTION_DETAILS_MAX_BYTES) {
265
+ }, bytes);
266
+ if (bytes > FABRIC_EXECUTION_DETAILS_MAX_BYTES) {
253
267
  delete details.trace.error;
254
268
  details.trace.counts.droppedValues++;
255
269
  }
@@ -496,6 +510,21 @@ var TimingFooter = class {
496
510
  if (!isTimingOnlyRender(this.state)) this.component.invalidate?.();
497
511
  }
498
512
  };
513
+ var BACKGROUND_SHORTCUT = "(ctrl+b to run in background)";
514
+ var BackgroundShortcutFooter = class {
515
+ constructor(component, theme) {
516
+ this.component = component;
517
+ this.theme = theme;
518
+ }
519
+ render(width) {
520
+ const lines = this.component.render(width);
521
+ if (width < 12 || lines.some((line) => line.includes("ctrl+b"))) return lines;
522
+ return [...continueArcGroup(lines), truncateToWidth(this.theme.fg("muted", `\u2570\u2500 ${BACKGROUND_SHORTCUT}`), width, "")];
523
+ }
524
+ invalidate() {
525
+ this.component.invalidate?.();
526
+ }
527
+ };
499
528
  var renderTimedResult = (context, theme, render, label) => {
500
529
  const state = timingState(context);
501
530
  if (!state) return render(context);
@@ -593,7 +622,11 @@ var withCodePreviewShell = (tool, options = {}) => {
593
622
  const originalRenderCall = tool.renderCall;
594
623
  const originalRenderResult = tool.renderResult;
595
624
  const renderCall = (args, theme, context) => originalRenderCall ? originalRenderCall.call(tool, args, theme, context) : new Text(theme.fg("toolTitle", theme.bold(tool.label || tool.name)), 0, 0);
596
- const renderResult = (result, resultOptions, theme, context) => originalRenderResult ? originalRenderResult.call(tool, result, resultOptions, theme, context) : new Container();
625
+ const renderResult = (result, resultOptions, theme, context) => {
626
+ const component = originalRenderResult ? originalRenderResult.call(tool, result, resultOptions, theme, context) : new Container();
627
+ const background = typeof context.args === "object" && context.args !== null && context.args.background === true;
628
+ return options.backgroundShortcut && context.executionStarted && context.isPartial && !background ? new BackgroundShortcutFooter(component, theme) : component;
629
+ };
597
630
  return {
598
631
  ...tool,
599
632
  renderShell: mode === "on" ? "default" : "self",
@@ -832,6 +865,7 @@ var extensionRunnerConstructors = async () => {
832
865
  if (isExtensionRunnerConstructor(Runner)) constructors.add(Runner);
833
866
  }
834
867
  if (constructors.size > 0) return [...constructors];
868
+ if (isCompiledPiBinary()) return inRealmExtensionRunner();
835
869
  const packageRoots = new Set(
836
870
  [process.env.PI_PACKAGE_DIR, hostPackageRoot(), entryRealmPackageRoot()].filter((root) => typeof root === "string" && Boolean(root)).map(realPath)
837
871
  );
@@ -841,17 +875,37 @@ var extensionRunnerConstructors = async () => {
841
875
  constructors.add(Runner);
842
876
  }
843
877
  }
844
- if (constructors.size === 0) {
845
- try {
846
- const hostModule = await import("@earendil-works/pi-coding-agent");
847
- if (hostModule.ExtensionRunner) constructors.add(hostModule.ExtensionRunner);
848
- } catch {
849
- }
878
+ return constructors.size > 0 ? [...constructors] : inRealmExtensionRunner();
879
+ };
880
+ var isCompiledPiBinary = (cli = process.argv[1]) => typeof cli === "string" && /\$bunfs|~BUN|%7EBUN/.test(cli);
881
+ var inRealmExtensionRunner = async () => {
882
+ try {
883
+ const { loadHostSdk } = await import("../core/host-sdk.js");
884
+ const hostModule = await loadHostSdk();
885
+ return isExtensionRunnerConstructor(hostModule.ExtensionRunner) ? [hostModule.ExtensionRunner] : [];
886
+ } catch {
887
+ return [];
850
888
  }
851
- return [...constructors];
852
889
  };
853
890
  var installRegisteredToolCapture = async (options) => {
891
+ const debug = process.env.PI_FABRIC_DEBUG_TOOL_CAPTURE === "1";
892
+ let traces = 0;
893
+ const trace = (event, fields) => {
894
+ if (!debug || traces >= 32) return;
895
+ traces++;
896
+ try {
897
+ console.error(`[pi-fabric tool-capture] ${JSON.stringify({ event, ...fields })}`);
898
+ if (traces === 32) console.error("[pi-fabric tool-capture] diagnostic limit reached");
899
+ } catch {
900
+ }
901
+ };
854
902
  const hubs = (await extensionRunnerConstructors()).map(captureHub);
903
+ trace("install", {
904
+ hubs: hubs.length,
905
+ compiled: isCompiledPiBinary(),
906
+ mappedLoader: typeof globalThis[Symbol.for("pi-fabric.hostSdkLoader")] === "function"
907
+ });
908
+ if (hubs.length === 0) options.catalog.markRunnerUnavailable();
855
909
  const anchorToken = {};
856
910
  Object.defineProperty(options.anchorDefinition, ANCHOR_SYMBOL, {
857
911
  value: anchorToken,
@@ -866,6 +920,7 @@ var installRegisteredToolCapture = async (options) => {
866
920
  const anchor = tools.find(
867
921
  (tool) => tool.definition[ANCHOR_SYMBOL] === anchorToken || definitionDelegatesTo(tool.definition, options.anchorDefinition)
868
922
  );
923
+ trace("refresh", { tools: tools.length, anchor: Boolean(anchor) });
869
924
  if (!anchor) return tools;
870
925
  options.catalog.replace(tools, runner, policy, anchor.sourceInfo.path);
871
926
  options.onCatalogRefresh?.();
@@ -880,6 +935,7 @@ var installRegisteredToolCapture = async (options) => {
880
935
  dispose() {
881
936
  if (disposed) return;
882
937
  disposed = true;
938
+ trace("dispose", { captured: options.catalog.size });
883
939
  for (const hub of hubs) {
884
940
  hub.listeners.delete(listener);
885
941
  hub.restore?.();
@@ -1184,12 +1240,13 @@ function registerFabricCommand(pi, deps) {
1184
1240
  }
1185
1241
  });
1186
1242
  pi.registerCommand("fabric", {
1187
- description: "Open Fabric dashboard, chat or tasks, arm prewalk, reload, or manage agents and actors",
1243
+ description: "Open Fabric dashboard, chat or tasks, background a running workflow, arm prewalk, reload, or manage agents and actors",
1188
1244
  getArgumentCompletions: (argumentPrefix) => {
1189
1245
  const subcommands = [
1190
1246
  "status",
1191
1247
  "dashboard",
1192
1248
  "tasks",
1249
+ "background",
1193
1250
  "chat",
1194
1251
  "focus",
1195
1252
  "settings",
@@ -1213,6 +1270,7 @@ function registerFabricCommand(pi, deps) {
1213
1270
  "kill",
1214
1271
  "repairs",
1215
1272
  "entropy",
1273
+ "permissions",
1216
1274
  "decisions",
1217
1275
  "programs",
1218
1276
  "run"
@@ -1319,12 +1377,34 @@ function registerFabricCommand(pi, deps) {
1319
1377
  },
1320
1378
  // The subcommands load at first use, not while registering the command.
1321
1379
  async handler(argumentsText, context) {
1380
+ const [command, ...args] = argumentsText.trim().split(/\s+/);
1381
+ if (command === "background") {
1382
+ if (args.length) {
1383
+ context.ui.notify("Usage: /fabric background", "warning");
1384
+ return;
1385
+ }
1386
+ const count = state.programTasks.detachWaiting();
1387
+ context.ui.notify(count ? `Fabric: ${count === 1 ? "whole workflow moved" : `${count} whole workflows moved`} to the background. Work continues; completion will be reported. /fabric tasks` : "Fabric: no foreground workflow to background", "info");
1388
+ return;
1389
+ }
1322
1390
  const { runFabricCommand } = await import("../commands/fabric-handler.js");
1323
1391
  await runFabricCommand(pi, deps, commandHost, argumentsText, context);
1324
1392
  }
1325
1393
  });
1326
1394
  }
1327
1395
 
1396
+ // src/core/lifecycle-settlement.ts
1397
+ async function settleLifecyclePublication(publisher, event, payload, interrupted) {
1398
+ const publication = publisher.publishHostLifecycle(event, payload);
1399
+ if (!interrupted) {
1400
+ await publication;
1401
+ return;
1402
+ }
1403
+ void publication.catch((error) => {
1404
+ console.warn(`[pi-fabric] ${event} publication after abort failed: ${error instanceof Error ? error.message : String(error)}`);
1405
+ });
1406
+ }
1407
+
1328
1408
  // src/agents/runner-notice.ts
1329
1409
  var BUILT_IN_RUNNERS = ["pi", "pi-durable", "claude", "veda"];
1330
1410
  var unregisteredRunnerNotice = (runner, registered) => {
@@ -1749,6 +1829,29 @@ var FabricDirectToolApproval = class {
1749
1829
  }
1750
1830
  };
1751
1831
 
1832
+ // src/core/execution-guidelines.ts
1833
+ var schemaDiscipline = "Form a falsifiable hypothesis covering the reported failure and affected paths. Let contrary evidence invalidate the plan. Verify postconditions before declaring success.";
1834
+ var taskDiscipline = "Be ambitious and persistent: work through uncertainty, try alternatives, and verify the result. Treat new requests as additive, not replacements; keep existing work progressing unless explicitly reprioritized.";
1835
+ var fabricExecutionGuidelines = (kernel = "typescript", pythonRuntime = "monty", managedHost = false) => managedHost ? [
1836
+ "Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence.",
1837
+ schemaDiscipline,
1838
+ taskDiscipline
1839
+ ] : [
1840
+ kernel === "python" ? "Batch independent I/O in one `fabric_exec` Python program with `asyncio.gather`; await dependent steps sequentially. Coalesce independent replacements into one `await pi.edit(path=..., edits=[...])`. Inspect findings before choosing dependent reads or edits. Background long-running work when independent tasks can proceed; collect its result before completion. Return JSON-compatible evidence." : "Batch independent I/O in one `fabric_exec` program (`Promise.all` for parallel, sequential `await` for ordered). Coalesce independent replacements from one file snapshot into one `pi.edit({path, edits:[...]})`; use `all:true` only for intentional repeated exact anchors. Inspect findings before choosing dependent reads or edits. Background long-running work when independent tasks can proceed; collect its result before completion.",
1841
+ kernel === "python" ? "Search before reading with `await pi.grep(pattern=..., path=...)` or `await pi.find(pattern=..., path=...)`, then `await pi.read(path=..., offset=..., limit=...)`. Use Python dict syntax, `True`/`False`/`None`, and bounded searches; unbounded reads cap at 2000 lines or 50KB. Read continuation notices when needed." : "Search before reading: use `pi.grep`/`pi.find` to locate relevant lines, then `pi.read({path, offset, limit})` that range. Escape regex metacharacters, or use `literal:true` for exact punctuated text. Keep fan-out search limits small and widen only on misses. An unbounded `pi.read` returns at most 2000 lines or 50KB and, when truncated, ends with a `Use offset=\u2026` continuation notice; reserve whole-file reads for small files you will use in full.",
1842
+ schemaDiscipline,
1843
+ taskDiscipline,
1844
+ "For edits/writes, pass named payloads through top-level `payloads`; each `\u03C0.key` must exactly match a key there; prefer `pi.edit`/`pi.write`. `pi.bash`: no stdin.",
1845
+ "Use `display.name` and objective `display.description`; Fabric pairs them with verified outcomes in deterministic compaction.",
1846
+ ...kernel === "python" && pythonRuntime === "monty" ? ["Monty requires acyclic JSON host arguments. For underscore-prefixed provider/tool names, use `await tools.call(ref=..., args={...})`, not direct attributes. Use `payloads['key']` for private/non-identifier payload keys."] : []
1847
+ ];
1848
+ var fabricOwnedExecutionGuidelines = () => [.../* @__PURE__ */ new Set([
1849
+ ...fabricExecutionGuidelines(),
1850
+ ...fabricExecutionGuidelines("python", "monty"),
1851
+ ...fabricExecutionGuidelines("python", "cpython"),
1852
+ ...fabricExecutionGuidelines("typescript", "monty", true)
1853
+ ])];
1854
+
1752
1855
  // src/fabric-exec-tool.ts
1753
1856
  import { Container as Container2, Text as Text2 } from "@earendil-works/pi-tui";
1754
1857
  import { Type } from "typebox";
@@ -1900,7 +2003,6 @@ var FabricRepeatGuard = class {
1900
2003
  };
1901
2004
 
1902
2005
  // src/ui/row-balance.ts
1903
- import { truncateToWidth as truncateToWidth2 } from "@earendil-works/pi-tui";
1904
2006
  var HiddenRowBorrowingComponent = class {
1905
2007
  constructor(baseLimit, maxLimit, renderLimit, balance) {
1906
2008
  this.baseLimit = baseLimit;
@@ -1932,7 +2034,7 @@ var HiddenRowBorrowingComponent = class {
1932
2034
  }
1933
2035
  this.#cachedWidth = width;
1934
2036
  this.#cachedDeficit = deficit;
1935
- this.#cachedRows = best.map((row) => truncateToWidth2(row, Math.max(1, width)));
2037
+ this.#cachedRows = best.map((row) => truncateStyledText(row, Math.max(1, width)));
1936
2038
  return this.#cachedRows;
1937
2039
  }
1938
2040
  invalidate() {
@@ -2068,17 +2170,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
2068
2170
  label: "Fabric",
2069
2171
  description: managedHost ? "Execute type-checked TypeScript in the managed QuickJS runtime. See the managed execution guidance for authorized tool contracts." : python ? monty ? "Execute Python through Fabric's configured Monty sandbox. Monty runs a Python subset with VM resource limits, no native filesystem/network/environment access, and only host-mediated tools. Each invocation starts fresh. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute Python through Fabric\u2019s configured CPython kernel for Pi core tools, MCP, providers, discovery, and extensions. Each call uses a fresh process. Native execution is trusted code; Schema enforce requires OS isolation. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute code through Fabric's TypeScript kernel: type-checked TypeScript by default, unmodified JavaScript with executor.codemodeProfile native. Both support nativeTools; native mode places Pi-compatible calls on tools and Fabric discovery on fabric.tools. Compose Pi core tools, MCP, Fabric providers, discovery, and extensions. QuickJS is isolated by default; the optional Node/Bun process is an unsafe trusted-code escape hatch. In full code mode, and always in Schema enforce mode, this is the exclusive model tool path.",
2070
2172
  promptSnippet: managedHost ? `Authorized host tools (${managedHost.providers.join(", ") || "none"}) and deterministic computation` : "Pi core tools, MCP, Fabric providers, discovery, and extensions",
2071
- promptGuidelines: managedHost ? [
2072
- "Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence."
2073
- ] : [
2074
- python ? "Batch independent operations in one `fabric_exec` Python program with `asyncio.gather`; await dependent/conditional steps sequentially. Coalesce independent replacements into one `await pi.edit(path=..., edits=[...])`. Return only the compact final JSON-compatible value." : "Batch independent operations in one `fabric_exec` program (`Promise.all` for parallel, sequential `await` for ordered), not one call per tool; keep dependent/conditional steps sequential. Coalesce non-dependent replacements from one file snapshot into one `pi.edit({path, edits:[...]})`; use `all:true` only for intentional repeated exact anchors. Return only the compact final value; intermediate results stay in the sandbox.",
2075
- python ? "Search before reading with `await pi.grep(pattern=..., path=...)` or `await pi.find(pattern=..., path=...)`, then `await pi.read(path=..., offset=..., limit=...)`. Use Python dict syntax, `True`/`False`/`None`, and bounded searches; unbounded reads cap at 2000 lines or 50KB. Read continuation notices when needed." : "Search before reading: use `pi.grep`/`pi.find` to locate relevant lines, then `pi.read({path, offset, limit})` that range. Escape regex metacharacters, or use `literal:true` for exact punctuated text. Keep fan-out search limits small and widen only on misses. An unbounded `pi.read` returns at most 2000 lines or 50KB and, when truncated, ends with a `Use offset=\u2026` continuation notice; reserve whole-file reads for small files you will use in full.",
2076
- "Keep the acceptance ledger in reasoning or concise progress notes (no tool call): define concrete checks, trace execution before editing, implement end to end, then run targeted tests and direct behavioral probes. Confirm requested public symbols, registrations, and configuration entries. Use the smallest checks that cover the ledger; escalate only for failures or cross-cutting risk. Inspect failures and iterate instead of rerunning unchanged passing checks. A build alone is not completion.",
2077
- python ? "For test/probe nonzero exits, use `await pi.bash(command=..., settle=True)` and inspect the returned dict: `r['ok']`, `r['output']`, and `r.get('exitCode')`. Set shell `timeout` in seconds once for long suites. Return decisions and evidence rather than raw logs." : "Amortize round trips without inflating context: batch only independent, bounded work. Keep search\u2192read and edit\u2192verify sequential when an output determines the next action. Use `settle:true` for tests or probes whose nonzero result is evidence rather than an exceptional stop; for a known long suite, set `pi.bash` `timeout` in seconds once instead of retrying a timed-out call. Filter or summarize noisy command output inside the program and return decisions, failures, and evidence\u2014not raw logs or unused intermediate results.",
2078
- "For edits/writes, pass named payloads through top-level `payloads`; each `\u03C0.key` must exactly match a key there; prefer `pi.edit`/`pi.write`. `pi.bash`: no stdin.",
2079
- "Use `display.name` and objective `display.description`; Fabric pairs them with verified outcomes in deterministic compaction.",
2080
- ...monty ? ["Monty requires acyclic JSON host arguments. For underscore-prefixed provider/tool names, use `await tools.call(ref=..., args={...})`, not direct attributes. Use `payloads['key']` for private/non-identifier payload keys."] : []
2081
- ],
2173
+ promptGuidelines: fabricExecutionGuidelines(toolKernel(state), python ? state.config.executor.pythonRuntime : void 0, Boolean(managedHost)),
2082
2174
  // The model-facing schema is intentionally flat: one large `code` string
2083
2175
  // plus scalar/optional params. Do not add nested arrays-of-objects with
2084
2176
  // escaped content here. SOTA models are post-trained on one dominant
@@ -2125,10 +2217,10 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
2125
2217
  })
2126
2218
  ),
2127
2219
  background: Type.Optional(Type.Boolean({
2128
- description: "Run the program as a background task and return at once; its result arrives as a background task event. Use for long workflows (many agents) whose result you do not need before continuing."
2220
+ description: "Run this entire program in the background and return its task handle immediately. Use for long workflows, including waits for required shell or agent results: keep dependent awaits inside this program. Main can do independent work or yield for the completion event instead of opening another foreground wait. Backgrounding is not task completion; do not restart the work or claim success while results are pending."
2129
2221
  })),
2130
2222
  timeout_ms: Type.Optional(Type.Integer({ minimum: 1, description: "Hard whole-script deadline in milliseconds; cannot be extended or paused, capped by executor.maxTimeoutMs." })),
2131
- maxOutputTokens: Type.Optional(Type.Integer({ minimum: 1, description: "Per-call output token budget (estimated at four characters per token), capped by executor.maxOutputChars." })),
2223
+ maxOutputTokens: Type.Optional(Type.Integer({ minimum: 1, description: "Optional per-call output token budget (estimated at four characters per token), capped by executor.maxOutputChars. Omit for full contracts to use the host ceiling; larger results still need projection or paging." })),
2132
2224
  max_output_tokens: Type.Optional(Type.Integer({ minimum: 1, description: "Alias of maxOutputTokens." })),
2133
2225
  display: Type.Optional(
2134
2226
  Type.Union([
@@ -2164,7 +2256,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
2164
2256
  const mode = toolDisplayMode(state);
2165
2257
  const rendererState = context.state;
2166
2258
  const python2 = (rendererState.fabricKernel ?? toolKernel(state)) === "python";
2167
- toolDisplay?.observe(context.toolCallId, "call", context.invalidate);
2259
+ toolDisplay?.observe(context.toolCallId, "call", context);
2168
2260
  const spinner = updateSpinner(
2169
2261
  rendererState.fabricSpinner ??= {},
2170
2262
  context.isPartial,
@@ -2257,7 +2349,7 @@ ${preview}` : ""}${hiddenHint}`,
2257
2349
  delete rendererState.fabricWriteBindingsCode;
2258
2350
  if (renderedKernel !== recordedKernel) context.invalidate();
2259
2351
  }
2260
- toolDisplay?.observe(context.toolCallId, "result", context.invalidate);
2352
+ toolDisplay?.observe(context.toolCallId, "result", context);
2261
2353
  const spinner = updateSpinner(
2262
2354
  rendererState.fabricSpinner ??= {},
2263
2355
  isPartial,
@@ -2354,9 +2446,6 @@ ${preview}` : ""}${hiddenHint}`,
2354
2446
  const audit = audits[0];
2355
2447
  const glyph = audit.success === void 0 ? theme.fg("warning", spinner) : audit.success === false ? theme.fg("error", "\u2717") : theme.fg("dim", "\u203A");
2356
2448
  let text2 = `${glyph} ${nestedCallTitle(audit, theme, context?.invalidate, corePreviewContext)}`;
2357
- if (shellBackgroundShortcut(audit)) {
2358
- text2 += nl + theme.fg("dim", "Ctrl+B twice \xB7 background waiting shell");
2359
- }
2360
2449
  const previewLines = renderAgentToolPreviewLines(audit, theme, {
2361
2450
  expanded,
2362
2451
  showTools: showAgentToolPreview,
@@ -2390,6 +2479,7 @@ ${preview}` : ""}${hiddenHint}`,
2390
2479
  if (previewLines.length > 1) text2 += nl + previewLines.slice(1).join(nl);
2391
2480
  }
2392
2481
  const textLines = text2.split(nl);
2482
+ if (shellBackgroundShortcut(audit)) pushArcItem(textLines, arcItem(theme, "(ctrl+b to run in background)"));
2393
2483
  return trackRows(
2394
2484
  renderBoundedLines(
2395
2485
  textLines,
@@ -2852,7 +2942,8 @@ ${recoveryHint}` : ""}`,
2852
2942
  }),
2853
2943
  {
2854
2944
  mode: codePreviewSettings.toolCallBackground,
2855
- toolCallTiming: codePreviewSettings.toolCallTiming
2945
+ toolCallTiming: codePreviewSettings.toolCallTiming,
2946
+ backgroundShortcut: true
2856
2947
  }
2857
2948
  );
2858
2949
  };
@@ -2878,7 +2969,17 @@ var FabricManagedHost = class {
2878
2969
  if (options.compaction !== void 0 && !["fabric", "pi"].includes(options.compaction)) throw new Error("Invalid managedHost.compaction");
2879
2970
  const maxCpuSliceMs = options.executor?.maxCpuSliceMs ?? 1e3;
2880
2971
  if (!Number.isSafeInteger(maxCpuSliceMs) || maxCpuSliceMs <= 0) throw new Error("managedHost.executor.maxCpuSliceMs must be a positive safe integer");
2881
- this.options = Object.freeze({ ...options, providers: Object.freeze([...options.providers]), foreground: Object.freeze([...foreground]), executor: Object.freeze({ maxCpuSliceMs }) });
2972
+ const maxOutputChars = hostOutputCeiling(
2973
+ options.executor?.maxOutputChars,
2974
+ DEFAULT_FABRIC_CONFIG.executor.maxOutputChars,
2975
+ "managedHost.executor.maxOutputChars"
2976
+ );
2977
+ const maxNestedResultChars = hostOutputCeiling(
2978
+ options.executor?.maxNestedResultChars,
2979
+ DEFAULT_FABRIC_CONFIG.executor.maxNestedResultChars,
2980
+ "managedHost.executor.maxNestedResultChars"
2981
+ );
2982
+ this.options = Object.freeze({ ...options, providers: Object.freeze([...options.providers]), foreground: Object.freeze([...foreground]), executor: Object.freeze({ maxCpuSliceMs, maxOutputChars, maxNestedResultChars }) });
2882
2983
  this.#allowed = new Set(this.options.providers);
2883
2984
  for (const name of this.#allowed) if (!REPLACEABLE.has(name)) throw new Error(`Managed host cannot replace provider: ${name}`);
2884
2985
  }
@@ -2930,6 +3031,8 @@ var FabricManagedHost = class {
2930
3031
  config.executor.kernel = "typescript";
2931
3032
  config.executor.runtime = "quickjs";
2932
3033
  config.executor.maxCpuSliceMs = this.options.executor.maxCpuSliceMs;
3034
+ config.executor.maxOutputChars = this.options.executor.maxOutputChars;
3035
+ config.executor.maxNestedResultChars = this.options.executor.maxNestedResultChars;
2933
3036
  config.foreground = { tools: this.options.foreground.map((name) => ({ name, owner: "managed-host", reason: "human-input" })), maxTools: MAX_FOREGROUND_TOOLS };
2934
3037
  config.mcp.enabled = false;
2935
3038
  config.mcp.allowDynamicServers = false;
@@ -3213,7 +3316,7 @@ var FabricState = class {
3213
3316
  this.prewalk.cancel();
3214
3317
  this.prewalkDrift.clear();
3215
3318
  this.activity.reset();
3216
- this.sessionApprovals.approvedRisks.clear();
3319
+ this.sessionApprovals.clear();
3217
3320
  this.#widgetDismissedAt = 0;
3218
3321
  context.ui.setStatus("fabric-prewalk", void 0);
3219
3322
  const pending = this.#activation;
@@ -3222,6 +3325,7 @@ var FabricState = class {
3222
3325
  if (this.#everActivated) await this.#activate(context, true);
3223
3326
  }
3224
3327
  async initialize(context) {
3328
+ this.sessionApprovals.clear();
3225
3329
  if (!this.#config || this.#cwd !== context.cwd) {
3226
3330
  await this.bootstrap(context);
3227
3331
  } else {
@@ -4126,7 +4230,7 @@ var createDashboardSnapshot = (state, events, context, activityRuns, cache, immu
4126
4230
  };
4127
4231
 
4128
4232
  // src/ui/widget.ts
4129
- import { matchesKey, truncateToWidth as truncateToWidth3, visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
4233
+ import { matchesKey, visibleWidth as visibleWidth2 } from "@earendil-works/pi-tui";
4130
4234
 
4131
4235
  // src/ui/retention.ts
4132
4236
  var WIDGET_FINISHED_RETENTION_MS = 3e4;
@@ -4218,10 +4322,10 @@ var fitLine = (theme, width, lead, flexible, detail, hints) => {
4218
4322
  while (details > 0 && visibleWidth2(compose(flex, details, hintCount)) > width) details--;
4219
4323
  if (flex && visibleWidth2(compose(flex, details, hintCount)) > width) {
4220
4324
  const room = width - visibleWidth2(compose(void 0, details, hintCount)) - visibleWidth2(flexible.gap);
4221
- flex = room >= 6 ? truncateToWidth3(flex, room, "\u2026") : void 0;
4325
+ flex = room >= 6 ? truncateStyledText(flex, room, "\u2026") : void 0;
4222
4326
  }
4223
4327
  while (hintCount > 0 && visibleWidth2(compose(flex, details, hintCount)) > width) hintCount--;
4224
- return truncateToWidth3(compose(flex, details, hintCount), width, "\u2026");
4328
+ return truncateStyledText(compose(flex, details, hintCount), width, "\u2026");
4225
4329
  };
4226
4330
  var treeOrder = (agents) => {
4227
4331
  const ids = new Set(agents.map((agent) => agent.id));
@@ -4290,20 +4394,22 @@ var widgetRowLimit = (maxRows, terminalRows) => {
4290
4394
  var widgetFocusedRowLimit = (maxRows, terminalRows) => widgetRowLimit(maxRows, terminalRows);
4291
4395
  var widgetViewport = (contentRows, budget, offset) => {
4292
4396
  const available = Math.max(0, Math.floor(budget));
4293
- const hasCue = contentRows > available && available > 1;
4397
+ const maxOffset = available > 0 ? Math.max(0, contentRows - available) : 0;
4398
+ const clampedOffset = Math.max(0, Math.min(maxOffset, Math.floor(offset)));
4399
+ const hasCue = clampedOffset < maxOffset && available > 1;
4294
4400
  const windowRows = Math.max(0, available - Number(hasCue));
4295
- const maxOffset = windowRows > 0 ? Math.max(0, contentRows - windowRows) : 0;
4296
- return { windowRows, hasCue, maxOffset, offset: Math.max(0, Math.min(maxOffset, Math.floor(offset))) };
4401
+ return { windowRows, hasCue, maxOffset, offset: clampedOffset };
4297
4402
  };
4298
4403
  var HEADER_ROW = "\0main";
4299
4404
  var FabricWidget = class {
4300
- constructor(theme, snapshot, maxRows, terminalRows, retention = new FabricWidgetRetention(), interaction) {
4405
+ constructor(theme, snapshot, maxRows, terminalRows, retention = new FabricWidgetRetention(), interaction, viewport = { offset: 0 }) {
4301
4406
  this.theme = theme;
4302
4407
  this.snapshot = snapshot;
4303
4408
  this.maxRows = maxRows;
4304
4409
  this.terminalRows = terminalRows;
4305
4410
  this.retention = retention;
4306
4411
  this.interaction = interaction;
4412
+ this.viewport = viewport;
4307
4413
  }
4308
4414
  /** Set by the TUI when the widget gains or loses keyboard focus. */
4309
4415
  focused = false;
@@ -4315,7 +4421,12 @@ var FabricWidget = class {
4315
4421
  /** Rows above the header in the last render: the spacer, or none on a one-row budget. */
4316
4422
  #spacerRows = 1;
4317
4423
  #renderedInteraction;
4318
- #scrollOffset = 0;
4424
+ get #scrollOffset() {
4425
+ return this.viewport.offset;
4426
+ }
4427
+ set #scrollOffset(offset) {
4428
+ this.viewport.offset = offset;
4429
+ }
4319
4430
  #maxScrollOffset = 0;
4320
4431
  #followSelection = false;
4321
4432
  /** Select the row on screen, or the first row; used when focus arrives from the keyboard. */
@@ -4487,9 +4598,9 @@ var FabricWidget = class {
4487
4598
  const label = labels.find((label2) => fits(label2, identityWidth)) ?? labels.find((label2) => fits(label2, Math.min(identityWidth, 8)));
4488
4599
  const headerWidth = label && width >= visibleWidth2(label) + 2 ? width - visibleWidth2(label) - 1 : width;
4489
4600
  const header = headerWidth === width ? lines[0] ?? "" : this.#content(snapshot, width, headerWidth).lines[0] ?? "";
4490
- const boundedHeader = label ? this.#withRightLabel(header, label, width) : truncateToWidth3(header, width);
4491
- const visibleLines = [boundedHeader, ...lines.slice(start, start + capacity).map((line) => truncateToWidth3(line, width))];
4492
- if (viewport.hasCue) visibleLines.push(below > 0 ? truncateToWidth3(this.theme.fg("dim", `\u2193 ${below} more`), width) : "");
4601
+ const boundedHeader = label ? this.#withRightLabel(header, label, width) : truncateStyledText(header, width);
4602
+ const visibleLines = [boundedHeader, ...lines.slice(start, start + capacity).map((line) => truncateStyledText(line, width))];
4603
+ if (viewport.hasCue) visibleLines.push(truncateStyledText(this.theme.fg("dim", `\u2193 ${below} more`), width));
4493
4604
  this.#rows = rows.filter((row) => row.line === 0 || row.line >= start && row.line < start + capacity).map((row) => ({ ...row, line: row.line === 0 ? 0 : row.line - start + 1 }));
4494
4605
  if (rows.length === 0 && this.interaction?.collapseIdle?.()) return [];
4495
4606
  this.#spacerRows = spacer;
@@ -4544,7 +4655,13 @@ var FabricWidget = class {
4544
4655
  }
4545
4656
  if (activeAgents.length > 0) parts.push(`${activeAgents.length} running`);
4546
4657
  if (visibleActors.length > 0) parts.push(`${visibleActors.length} actor${visibleActors.length === 1 ? "" : "s"}`);
4547
- if (liveShells.length > 0) parts.push(`${liveShells.length} shell${liveShells.length === 1 ? "" : "s"}`);
4658
+ const backgroundWork = liveShells.filter((job) => !job.observes);
4659
+ const shellCount = backgroundWork.filter((job) => job.tool !== "fabric_exec").length;
4660
+ const workflowCount = backgroundWork.length - shellCount;
4661
+ const observationCount = liveShells.length - backgroundWork.length;
4662
+ if (shellCount) parts.push(`${shellCount} shell${shellCount === 1 ? "" : "s"}`);
4663
+ if (workflowCount) parts.push(`${workflowCount} workflow${workflowCount === 1 ? "" : "s"}`);
4664
+ if (observationCount) parts.push(`${observationCount} observation${observationCount === 1 ? "" : "s"}`);
4548
4665
  const tokens = totalTokens(snapshot, run);
4549
4666
  if (tokens > 0) parts.push(`${formatTokens(tokens)} tok`);
4550
4667
  const cost = totalCost(snapshot, run);
@@ -4566,6 +4683,27 @@ var FabricWidget = class {
4566
4683
  parts,
4567
4684
  this.#hints(hasRows)
4568
4685
  ));
4686
+ const shownObservations = /* @__PURE__ */ new Set();
4687
+ const pushObservation = (job, prefix) => {
4688
+ shownObservations.add(job.id);
4689
+ rows.push({ id: job.id, kind: "shell", name: safeText(job.description ?? job.command), line: lines.length });
4690
+ const active = job.finishedAt === void 0;
4691
+ const status = job.stopping ? "stopping" : active ? "watching" : job.status === "timed_out" ? "expired" : job.status === "killed" ? "stopped" : "ended";
4692
+ const delivery = job.monitor?.delivery === "wake" ? "wake owner" : "UI only";
4693
+ const remaining = active && job.monitor ? ` \xB7 expires in ${formatDuration(Math.max(0, job.startedAt + job.monitor.timeoutMs - snapshot.now)) || "0s"}` : "";
4694
+ lines.push(fitLine(
4695
+ this.theme,
4696
+ width,
4697
+ `${prefix}${colorStatus(this.theme, job.stopping ? "stopping" : job.status, circle(job.id === marked))} ${this.theme.fg("muted", job.id.slice(0, 8))} ${this.theme.fg("muted", `${status} \xB7 ${delivery}${remaining}`)}`,
4698
+ { text: safeText(job.description ?? `Observe ${job.observes.kind} ${job.observes.id.slice(0, 8)}`), gap: " \xB7 ", color: "dim" },
4699
+ [],
4700
+ []
4701
+ ));
4702
+ };
4703
+ const pushObservations = (kind, id) => {
4704
+ const children = listedShells.filter((job) => job.observes?.kind === kind && job.observes.id === id);
4705
+ children.forEach((job, index) => pushObservation(job, index === children.length - 1 ? " \u2570\u2500 " : " \u251C\u2500 "));
4706
+ };
4569
4707
  const pushParticipant = (agent, kind, prefix = "") => {
4570
4708
  const id = kind === "actor" ? agent.actorId ?? agent.id : agent.id;
4571
4709
  rows.push({
@@ -4576,6 +4714,7 @@ var FabricWidget = class {
4576
4714
  line: lines.length
4577
4715
  });
4578
4716
  lines.push(agentLine(this.theme, agent, snapshot.now, prefix, id === marked, width));
4717
+ pushObservations("participant", agent.id);
4579
4718
  };
4580
4719
  const liveTrees = [];
4581
4720
  const settledTrees = [];
@@ -4601,25 +4740,27 @@ var FabricWidget = class {
4601
4740
  []
4602
4741
  );
4603
4742
  };
4604
- for (const job of listedShells) {
4743
+ for (const job of listedShells.filter((job2) => !job2.observes)) {
4605
4744
  const status = job.stopping ? "stopping" : job.status;
4606
4745
  const label2 = job.monitor && job.finishedAt === void 0 && !job.stopping ? `monitor:${job.monitor.delivery}` : status;
4607
4746
  rows.push({ id: job.id, kind: "shell", name: safeText(job.description ?? job.command), line: lines.length });
4608
4747
  lines.push(shellLine(job, job.id.slice(0, 8), label2, job.id));
4748
+ pushObservations("task", job.id);
4609
4749
  }
4750
+ for (const job of listedShells) if (job.observes && !shownObservations.has(job.id)) pushObservation(job, "");
4610
4751
  return lines;
4611
4752
  }
4612
4753
  #withRightLabel(line, label, width) {
4613
4754
  const labelWidth = visibleWidth2(label);
4614
- if (width < labelWidth + 2) return truncateToWidth3(line, width);
4615
- const left = truncateToWidth3(line, width - labelWidth - 1, "");
4755
+ if (width < labelWidth + 2) return truncateStyledText(line, width);
4756
+ const left = truncateStyledText(line, width - labelWidth - 1, "");
4616
4757
  return `${left}${" ".repeat(width - visibleWidth2(left) - labelWidth)}${this.theme.fg("dim", label)}`;
4617
4758
  }
4618
4759
  };
4619
4760
 
4620
4761
  // src/ui/footer-dock.ts
4621
4762
  import { stripVTControlCharacters } from "node:util";
4622
- import { sliceByColumn, truncateToWidth as truncateToWidth4, visibleWidth as visibleWidth3 } from "@earendil-works/pi-tui";
4763
+ import { sliceByColumn, truncateToWidth as truncateToWidth2, visibleWidth as visibleWidth3 } from "@earendil-works/pi-tui";
4623
4764
  var childrenOf = (node) => {
4624
4765
  const children = node?.children;
4625
4766
  return Array.isArray(children) ? children : [];
@@ -4644,7 +4785,7 @@ var withBorderBadge = (lines, label) => {
4644
4785
  const plain = stripVTControlCharacters(line);
4645
4786
  if (badgeWidth + 6 > width || !/^─+$/.test(plain.slice(-(badgeWidth + 4)))) return lines;
4646
4787
  const next = [...lines];
4647
- next[index] = truncateToWidth4(line, width - badgeWidth - 2, "") + badge + sliceByColumn(line, width - 2, 2);
4788
+ next[index] = truncateToWidth2(line, width - badgeWidth - 2, "") + badge + sliceByColumn(line, width - 2, 2);
4648
4789
  return next;
4649
4790
  };
4650
4791
  var FooterDock = class {
@@ -4848,6 +4989,7 @@ var FabricUiController = class {
4848
4989
  #snapshotCache = new FabricDashboardSnapshotCache();
4849
4990
  #refreshGeneration = 0;
4850
4991
  #widgetRetention = new FabricWidgetRetention();
4992
+ #widgetViewport = { offset: 0 };
4851
4993
  start(context) {
4852
4994
  this.stop();
4853
4995
  this.#context = context;
@@ -4909,6 +5051,7 @@ var FabricUiController = class {
4909
5051
  this.#meshOffset = 0;
4910
5052
  this.#snapshot = emptySnapshot();
4911
5053
  this.#widgetRetention.clear();
5054
+ this.#widgetViewport.offset = 0;
4912
5055
  this.#lastRefreshErrorAt = 0;
4913
5056
  this.#lastRefreshAt = 0;
4914
5057
  this.#dashboardOpen = false;
@@ -5177,7 +5320,8 @@ var FabricUiController = class {
5177
5320
  this.state.config.ui.maxRows,
5178
5321
  () => tui.terminal?.rows ?? process.stdout.rows,
5179
5322
  this.#widgetRetention,
5180
- interaction
5323
+ interaction,
5324
+ this.#widgetViewport
5181
5325
  ),
5182
5326
  onTargetChange: (id) => {
5183
5327
  if (this.#activeConversationReader !== id) this.#suspendConversationReader();
@@ -5637,7 +5781,8 @@ var FabricUiController = class {
5637
5781
  requestRender: () => tui.requestRender(),
5638
5782
  rendered: () => this.#keepWidgetLast(context),
5639
5783
  availableRows: (width) => this.#footerDock?.availableRows(width)
5640
- }
5784
+ },
5785
+ this.#widgetViewport
5641
5786
  );
5642
5787
  const widget = this.#widget;
5643
5788
  const anchor = {
@@ -5710,8 +5855,7 @@ function installFabricEscapeHalt(context, options) {
5710
5855
  }
5711
5856
 
5712
5857
  // src/ui/shell-hang-keys.ts
5713
- var CTRL_B = "";
5714
- var CTRL_K = "\v";
5858
+ import { matchesKey as matchesKey3 } from "@earendil-works/pi-tui";
5715
5859
  var CTRL_B_CHORD_MS = 1e3;
5716
5860
  function installFabricShellHangKeys(context, options) {
5717
5861
  if (context.mode !== "tui" || typeof context.ui.onTerminalInput !== "function") return () => {
@@ -5722,7 +5866,7 @@ function installFabricShellHangKeys(context, options) {
5722
5866
  halted: () => false,
5723
5867
  halt: () => {
5724
5868
  let count = 0;
5725
- for (const job of options.jobs()?.live() ?? []) if (job.options.monitor && job.stop("Main interrupted")) count++;
5869
+ for (const job of options.jobs()?.live() ?? []) if (job.monitorActive && job.stop("Main interrupted")) count++;
5726
5870
  return count;
5727
5871
  }
5728
5872
  });
@@ -5734,12 +5878,13 @@ function installFabricShellHangKeys(context, options) {
5734
5878
  }
5735
5879
  const jobs = options.jobs();
5736
5880
  const shells = jobs?.waiting().length ?? 0;
5737
- const programs = shells === 0 && data === CTRL_B && editorEmpty(context) ? options.programs?.() : void 0;
5881
+ const ctrlB = matchesKey3(data, "ctrl+b");
5882
+ const programs = shells === 0 && ctrlB && editorEmpty(context) ? options.programs?.() : void 0;
5738
5883
  if (!jobs || shells === 0 && !programs?.waiting()) {
5739
5884
  chordArmedAt = 0;
5740
5885
  return void 0;
5741
5886
  }
5742
- if (data === CTRL_B) {
5887
+ if (ctrlB) {
5743
5888
  const now = Date.now();
5744
5889
  if (chordArmedAt > 0 && now - chordArmedAt <= CTRL_B_CHORD_MS) {
5745
5890
  chordArmedAt = 0;
@@ -5767,7 +5912,7 @@ function installFabricShellHangKeys(context, options) {
5767
5912
  return { consume: true };
5768
5913
  }
5769
5914
  chordArmedAt = 0;
5770
- if (data === CTRL_K) {
5915
+ if (matchesKey3(data, "ctrl+k")) {
5771
5916
  const count = jobs.killWaiting();
5772
5917
  if (count > 0) {
5773
5918
  context.ui.notify(
@@ -5794,21 +5939,41 @@ var editorEmpty = (context) => {
5794
5939
 
5795
5940
  // src/ui/tool-display.ts
5796
5941
  var FabricToolDisplayController = class {
5797
- #invalidators = /* @__PURE__ */ new Map();
5942
+ #cards = /* @__PURE__ */ new Map();
5943
+ #invalidators = /* @__PURE__ */ new WeakMap();
5944
+ #sweepAt = SWEEP_MIN_CARDS;
5798
5945
  #pendingRefresh = [];
5799
5946
  #refreshDrainScheduled = false;
5800
- observe(toolCallId, kind, invalidate) {
5801
- const invalidators = this.#invalidators.get(toolCallId) ?? {};
5802
- invalidators[kind] = invalidate;
5803
- this.#invalidators.set(toolCallId, invalidators);
5947
+ observe(toolCallId, kind, { invalidate, state }) {
5948
+ const invalidators = this.#invalidators.get(state);
5949
+ if (invalidators) invalidators[kind] = invalidate;
5950
+ else this.#invalidators.set(state, { [kind]: invalidate });
5951
+ if (this.#cards.get(toolCallId)?.deref() !== state) {
5952
+ this.#cards.set(toolCallId, new WeakRef(state));
5953
+ if (this.#cards.size >= this.#sweepAt) this.#sweep();
5954
+ }
5804
5955
  }
5805
5956
  refresh() {
5806
- for (const { call, result } of this.#invalidators.values()) {
5807
- const invalidate = result ?? call;
5957
+ for (const [toolCallId, card] of this.#cards) {
5958
+ const state = card.deref();
5959
+ const invalidators = state && this.#invalidators.get(state);
5960
+ if (!invalidators) {
5961
+ this.#cards.delete(toolCallId);
5962
+ continue;
5963
+ }
5964
+ const invalidate = invalidators.result ?? invalidators.call;
5808
5965
  if (invalidate) this.#pendingRefresh.push(invalidate);
5809
5966
  }
5810
5967
  this.#scheduleRefreshDrain();
5811
5968
  }
5969
+ // Drop ids whose components Pi has released. Amortized: a sweep runs when
5970
+ // the id map has doubled since the last one.
5971
+ #sweep() {
5972
+ for (const [toolCallId, card] of this.#cards) {
5973
+ if (card.deref() === void 0) this.#cards.delete(toolCallId);
5974
+ }
5975
+ this.#sweepAt = Math.max(SWEEP_MIN_CARDS, this.#cards.size * 2);
5976
+ }
5812
5977
  // Drain a few cards per event-loop turn. invalidate() synchronously runs the
5813
5978
  // card's full renderer pair (updateDisplay in pi's ToolExecutionComponent),
5814
5979
  // so re-rendering a long transcript inside a single keypress froze the UI
@@ -5830,10 +5995,12 @@ var FabricToolDisplayController = class {
5830
5995
  }
5831
5996
  clear() {
5832
5997
  this.#pendingRefresh = [];
5833
- this.#invalidators.clear();
5998
+ this.#cards.clear();
5999
+ this.#sweepAt = SWEEP_MIN_CARDS;
5834
6000
  }
5835
6001
  };
5836
6002
  var REFRESH_CARDS_PER_TICK = 3;
6003
+ var SWEEP_MIN_CARDS = 64;
5837
6004
 
5838
6005
  // src/ui/handoff-completion.ts
5839
6006
  import { Text as Text3 } from "@earendil-works/pi-tui";
@@ -5927,6 +6094,91 @@ var installTerminalTitle = (pi, title) => {
5927
6094
  // src/extension.ts
5928
6095
  import path8 from "node:path";
5929
6096
  import { fileURLToPath } from "node:url";
6097
+
6098
+ // src/core/crash-guard.ts
6099
+ var CONTROL_ABORT = Symbol.for("pi-fabric.control-abort");
6100
+ var GUARD = Symbol.for("pi-fabric.crash-guard");
6101
+ var causes = function* (value) {
6102
+ const seen = /* @__PURE__ */ new Set();
6103
+ for (let current = value, depth = 0; current !== void 0 && current !== null && depth < 8; depth++) {
6104
+ if (seen.has(current)) return;
6105
+ seen.add(current);
6106
+ yield current;
6107
+ if (typeof current !== "object") return;
6108
+ current = current.cause;
6109
+ }
6110
+ };
6111
+ var isFabricControlAbort = (value) => {
6112
+ for (const item of causes(value)) {
6113
+ if (typeof item === "object" && Reflect.get(item, CONTROL_ABORT) === true) return true;
6114
+ }
6115
+ return false;
6116
+ };
6117
+ var normalize = (file) => file.replaceAll("\\", "/");
6118
+ var raisedByFabric = (value, roots) => {
6119
+ for (const item of causes(value)) {
6120
+ const stack = item instanceof Error && typeof item.stack === "string" ? normalize(item.stack) : "";
6121
+ if (!stack) continue;
6122
+ for (const root of roots) {
6123
+ if (stack.includes(`${root}/dist/`) || stack.includes(`${root}/src/`)) return true;
6124
+ }
6125
+ }
6126
+ return false;
6127
+ };
6128
+ var fabricOwnsFailure = (value, roots = guardState()?.roots ?? /* @__PURE__ */ new Set()) => isFabricControlAbort(value) || raisedByFabric(value, roots);
6129
+ var unhandledRejectionMode = () => {
6130
+ const flags = [...process.execArgv, ...(process.env.NODE_OPTIONS ?? "").split(/\s+/)];
6131
+ let mode = "throw";
6132
+ for (const flag of flags) {
6133
+ const match = /^--unhandled-rejections=(.+)$/.exec(flag);
6134
+ if (match) mode = match[1];
6135
+ }
6136
+ return mode;
6137
+ };
6138
+ var describe = (value) => {
6139
+ if (value instanceof Error) return `${value.name}: ${value.message}`;
6140
+ try {
6141
+ return String(value);
6142
+ } catch {
6143
+ return "unprintable value";
6144
+ }
6145
+ };
6146
+ var guardState = () => globalThis[GUARD];
6147
+ function installFabricCrashGuard(packageRoot, log = (line) => console.warn(`[pi-fabric] ${line}`)) {
6148
+ const existing = guardState();
6149
+ if (existing) {
6150
+ existing.roots.add(normalize(packageRoot).replace(/\/+$/, ""));
6151
+ return;
6152
+ }
6153
+ const state = {
6154
+ roots: /* @__PURE__ */ new Set([normalize(packageRoot).replace(/\/+$/, "")]),
6155
+ log,
6156
+ listener: (reason) => {
6157
+ if (fabricOwnsFailure(reason, state.roots)) {
6158
+ try {
6159
+ state.log(`detached work failed: ${describe(reason)}`);
6160
+ } catch {
6161
+ }
6162
+ return;
6163
+ }
6164
+ if (process.listenerCount("unhandledRejection") > 1) return;
6165
+ const mode = unhandledRejectionMode();
6166
+ if (mode === "warn" || mode === "warn-with-error-code" || mode === "none") {
6167
+ if (mode !== "none") process.emitWarning(`Unhandled promise rejection: ${describe(reason)}`, "UnhandledPromiseRejectionWarning");
6168
+ if (mode === "warn-with-error-code") process.exitCode = 1;
6169
+ return;
6170
+ }
6171
+ if (reason instanceof Error) throw reason;
6172
+ const error = new Error(`This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "${describe(reason)}".`);
6173
+ error.code = "ERR_UNHANDLED_REJECTION";
6174
+ throw error;
6175
+ }
6176
+ };
6177
+ globalThis[GUARD] = state;
6178
+ process.on("unhandledRejection", state.listener);
6179
+ }
6180
+
6181
+ // src/extension.ts
5930
6182
  var FABRIC_MANAGED_HOST_VERSION = 2;
5931
6183
  var userPromptText = (event) => event.messageType === "custom" || typeof event.prompt !== "string" ? void 0 : event.prompt;
5932
6184
  function createFabricExtension(entryUrl) {
@@ -5968,7 +6220,15 @@ function createFabricExtension(entryUrl) {
5968
6220
  );
5969
6221
  return;
5970
6222
  }
6223
+ installFabricCrashGuard(path8.resolve(FABRIC_ENTRY_DIR, ".."));
5971
6224
  if (!options.managedHost) registerJevAuth(pi);
6225
+ pi.on("input", async (event, context) => {
6226
+ if (event.source !== "interactive" || !event.text.includes("pi-clipboard-")) return;
6227
+ const { attachPastedImages } = await import("../core/pasted-images.js");
6228
+ const result = await attachPastedImages(event.text, event.images);
6229
+ for (const warning of result.warnings) context.ui.notify(warning, "warning");
6230
+ if (result.changed) return { action: "transform", text: result.text, images: result.images };
6231
+ });
5972
6232
  const codePreviewSettings = defaultCodePreviewSettings();
5973
6233
  const decorateShell = withCodePreviewShell;
5974
6234
  let compatibilityWarningShown = false;
@@ -6004,6 +6264,27 @@ function createFabricExtension(entryUrl) {
6004
6264
  ...FABRIC_ENTRY_IDENTITY ? { entryIdentity: FABRIC_ENTRY_IDENTITY } : {},
6005
6265
  ...options.managedHost ? { managedHost: options.managedHost } : {}
6006
6266
  });
6267
+ let historyPaging;
6268
+ const stopHistoryPaging = () => {
6269
+ historyPaging?.controller.abort();
6270
+ historyPaging = void 0;
6271
+ };
6272
+ const pageHistory = (context) => {
6273
+ const manager = context.sessionManager;
6274
+ if (!state.bootstrapped || state.managedHostOptions || state.config.memory.pageHistory === false || context.signal?.aborted || typeof manager.buildContextEntries !== "function") return Promise.resolve();
6275
+ if (historyPaging?.manager === manager) return historyPaging.pending;
6276
+ stopHistoryPaging();
6277
+ const controller = new AbortController();
6278
+ const signal = context.signal ? AbortSignal.any([controller.signal, context.signal]) : controller.signal;
6279
+ const run = { manager, controller, pending: Promise.resolve() };
6280
+ run.pending = import("../memory/history-paging.js").then((module) => module.pageSessionHistory(manager, signal)).then(() => void 0).catch((error) => {
6281
+ if (!signal.aborted) console.warn(`[pi-fabric] history paging failed: ${error instanceof Error ? error.message : String(error)}`);
6282
+ }).finally(() => {
6283
+ if (historyPaging === run) historyPaging = void 0;
6284
+ });
6285
+ historyPaging = run;
6286
+ return run.pending;
6287
+ };
6007
6288
  const directToolApproval = new FabricDirectToolApproval(
6008
6289
  pi,
6009
6290
  () => state.config,
@@ -6301,6 +6582,8 @@ function createFabricExtension(entryUrl) {
6301
6582
  const createEntropyCaches = (entropy) => ({
6302
6583
  compiler: new entropy.BackgroundEntropyCompiler(),
6303
6584
  observations: new entropy.SessionObservationCache(),
6585
+ // Parses and rewrites the machine-wide pool off the interactive thread.
6586
+ pool: new entropy.ObservationPoolWriter(),
6304
6587
  sessions: new entropy.BackgroundSessionSelector(entropy.machineSessionFilesAsync)
6305
6588
  });
6306
6589
  let entropyCaches;
@@ -6314,7 +6597,6 @@ function createFabricExtension(entryUrl) {
6314
6597
  liveSurfaceSnapshot,
6315
6598
  loadCompiledSurfaceAsync,
6316
6599
  saveCompiledSurfaceAsync,
6317
- updateObservationPoolAsync,
6318
6600
  sessionWindowEvidenceAsync
6319
6601
  } = entropy;
6320
6602
  let retry = false;
@@ -6331,7 +6613,7 @@ function createFabricExtension(entryUrl) {
6331
6613
  const evidence = await sessionWindowEvidenceAsync(files, { windowsOnly: true });
6332
6614
  if (!current()) return false;
6333
6615
  try {
6334
- await updateObservationPoolAsync(agentDir, evidence.observationWindows, caches.observations);
6616
+ await caches.pool.update(agentDir, evidence.observationWindows, caches.observations);
6335
6617
  } catch (error) {
6336
6618
  if (error instanceof FileLockTimeoutError) {
6337
6619
  retry = true;
@@ -6408,15 +6690,19 @@ function createFabricExtension(entryUrl) {
6408
6690
  while (entropyCompileInFlight) await entropyCompileInFlight;
6409
6691
  };
6410
6692
  pi.on("session_start", async (_event, context) => {
6693
+ stopHistoryPaging();
6411
6694
  await sealScope();
6412
6695
  clearEntropyRetry();
6413
6696
  entropyStopping = false;
6414
6697
  entropyLifecycleEpoch += 1;
6698
+ void entropyCaches?.pool.close();
6415
6699
  entropyCaches = void 0;
6416
6700
  entropyEvidenceThisTurn = false;
6417
6701
  entropyCompilePending = void 0;
6418
6702
  pendingHandoffs.clear();
6419
6703
  directToolApproval.clear();
6704
+ state.sessionApprovals.clear();
6705
+ context.ui.setStatus("fabric-permissions", void 0);
6420
6706
  toolDisplay.clear();
6421
6707
  uninstallHaltOnEscape();
6422
6708
  uninstallShellHangKeys();
@@ -6448,6 +6734,7 @@ function createFabricExtension(entryUrl) {
6448
6734
  if (state.shouldEagerlyActivate(context)) await state.ensure(context);
6449
6735
  });
6450
6736
  pi.on("session_tree", async (_event, context) => {
6737
+ stopHistoryPaging();
6451
6738
  state.thinking.invalidate();
6452
6739
  proxyContract.reset();
6453
6740
  refreshProxyLedger(context);
@@ -6462,8 +6749,9 @@ function createFabricExtension(entryUrl) {
6462
6749
  );
6463
6750
  await state.publishHostLifecycle("pi.input", event);
6464
6751
  });
6465
- pi.on("agent_start", async (event) => {
6466
- if (state.initialized) await state.publishHostLifecycle("pi.agent_start", event);
6752
+ pi.on("agent_start", async (event, context) => {
6753
+ await pageHistory(context);
6754
+ if (state.initialized) await settleLifecyclePublication(state, "pi.agent_start", event, context.signal?.aborted === true);
6467
6755
  });
6468
6756
  pi.on("agent_end", async (event, context) => {
6469
6757
  try {
@@ -6471,29 +6759,31 @@ function createFabricExtension(entryUrl) {
6471
6759
  } catch (error) {
6472
6760
  console.warn(`[pi-fabric] thinking revert failed: ${error instanceof Error ? error.message : String(error)}`);
6473
6761
  }
6474
- if (state.initialized) await state.publishHostLifecycle("pi.agent_end", event);
6762
+ if (state.initialized) await settleLifecyclePublication(state, "pi.agent_end", event, context.signal?.aborted === true);
6475
6763
  });
6476
6764
  pi.on("turn_end", async (event, context) => {
6477
6765
  if (state.initialized) state.resetSpeculation();
6478
- if (state.initialized) await state.publishHostLifecycle("pi.turn_end", event);
6766
+ if (state.initialized) await settleLifecyclePublication(state, "pi.turn_end", event, context.signal?.aborted === true);
6479
6767
  if (entropyEvidenceThisTurn) {
6480
6768
  entropyEvidenceThisTurn = false;
6481
6769
  scheduleEntropyCompile(context);
6482
6770
  }
6483
6771
  });
6484
6772
  pi.on("agent_settled", async (event, context) => {
6773
+ const interrupted = event.aborted || context.signal?.aborted === true;
6485
6774
  if (state.managedHostOptions) {
6486
- if (state.config.compaction.engine === "fabric") await compactAtConfiguredThreshold(context, state.config);
6487
- if (state.initialized) await state.publishHostLifecycle("pi.agent_settled", event);
6775
+ if (!interrupted && state.config.compaction.engine === "fabric") await compactAtConfiguredThreshold(context, state.config);
6776
+ if (state.initialized) await settleLifecyclePublication(state, "pi.agent_settled", event, interrupted);
6488
6777
  return;
6489
6778
  }
6490
6779
  if (!state.initialized) {
6491
- if (!compactionOwner()) await compactAtConfiguredThreshold(context, state.config);
6780
+ if (!interrupted && !compactionOwner()) await compactAtConfiguredThreshold(context, state.config);
6492
6781
  return;
6493
6782
  }
6494
6783
  const sessionId = context.sessionManager.getSessionId();
6784
+ if (interrupted) state.compact.cancel();
6495
6785
  const settledInPlace = await settleInPlacePrewalk(state.prewalk, pi, context, {
6496
- compactOnReturn: state.config.prewalk.compactOnReturn,
6786
+ compactOnReturn: !interrupted && state.config.prewalk.compactOnReturn,
6497
6787
  compact: state.compact
6498
6788
  });
6499
6789
  if (!settledInPlace && state.prewalk.settleTask(sessionId)) {
@@ -6508,15 +6798,15 @@ function createFabricExtension(entryUrl) {
6508
6798
  } else {
6509
6799
  state.prewalkDrift.drop(sessionId);
6510
6800
  }
6511
- await state.compact.maybeCommit(context);
6512
- if (!compactionOwner()) {
6801
+ if (!interrupted) await state.compact.maybeCommit(context);
6802
+ if (!interrupted && !compactionOwner()) {
6513
6803
  await compactAtConfiguredThreshold(
6514
6804
  context,
6515
6805
  state.config,
6516
6806
  (trigger, committed) => state.compact.noteAutoCompaction(trigger, committed)
6517
6807
  );
6518
6808
  }
6519
- await state.publishHostLifecycle("pi.agent_settled", event);
6809
+ await settleLifecyclePublication(state, "pi.agent_settled", event, interrupted);
6520
6810
  });
6521
6811
  pi.on("message_start", () => {
6522
6812
  state.speculationTap?.reset();
@@ -6597,7 +6887,7 @@ function createFabricExtension(entryUrl) {
6597
6887
  if (!state.initialized) return;
6598
6888
  if (event.toolName === "fabric_exec") entropyEvidenceThisTurn = true;
6599
6889
  state.noteMainActivity(context);
6600
- if (event.isError) {
6890
+ if (event.isError && !context.signal?.aborted) {
6601
6891
  const classified = classifyToolResult({
6602
6892
  toolName: event.toolName,
6603
6893
  isError: true,
@@ -6613,6 +6903,7 @@ function createFabricExtension(entryUrl) {
6613
6903
  });
6614
6904
  let compactionOwners;
6615
6905
  pi.on("session_compact", async (event, context) => {
6906
+ void pageHistory(context);
6616
6907
  const fabricEngine = !compactionOwner() && (state.bootstrapped ? state.config : DEFAULT_FABRIC_CONFIG).compaction.engine === "fabric";
6617
6908
  const observer = await (compactionOwners ??= import("../compaction/owner.js").then(
6618
6909
  (module) => new module.CompactionOwnerObserver()
@@ -6746,6 +7037,9 @@ function createFabricExtension(entryUrl) {
6746
7037
  defaultFabricExecutionGuidance,
6747
7038
  extensionToolRosterGuidance,
6748
7039
  fabricExecutionKernelGuidance,
7040
+ fabricGuidanceDelivery,
7041
+ relocateFabricGuidelines,
7042
+ stripFabricRuleBullets,
6749
7043
  managedHostExecutionGuidance,
6750
7044
  managedHostKernelGuidance,
6751
7045
  fabricSchemaGuidance
@@ -6754,8 +7048,25 @@ function createFabricExtension(entryUrl) {
6754
7048
  const captureSnapshot = state.bootstrapped ? capturePolicy() : void 0;
6755
7049
  const managedHost = state.managedHostOptions;
6756
7050
  const skillReader = managedHost ? managedHost.skillReader ?? null : void 0;
6757
- const sections = event.systemPromptOptions.forceSystemPrompt === void 0 ? event.systemPromptOptions.sections : void 0;
6758
- const systemPrompt = sections ? "" : restoreSkillsForFullCodePrompt(event.systemPrompt, skills, effectiveFullCodeMode, skillReader);
7051
+ const delivery = fabricGuidanceDelivery(
7052
+ true,
7053
+ event.systemPromptOptions.sections !== void 0,
7054
+ event.systemPromptOptions.forceSystemPrompt !== void 0
7055
+ );
7056
+ const sections = delivery.section ? event.systemPromptOptions.sections : void 0;
7057
+ const ownedExecutionRules = fabricOwnedExecutionGuidelines();
7058
+ const executionRules = relocateFabricGuidelines(
7059
+ event.systemPromptOptions.toolGuidelines,
7060
+ fabricExecutionGuidelines(config.executor.kernel, config.executor.pythonRuntime, Boolean(managedHost)),
7061
+ delivery,
7062
+ ownedExecutionRules
7063
+ );
7064
+ const systemPrompt = sections ? "" : restoreSkillsForFullCodePrompt(
7065
+ stripFabricRuleBullets(event.systemPrompt, ownedExecutionRules),
7066
+ skills,
7067
+ effectiveFullCodeMode,
7068
+ skillReader
7069
+ );
6759
7070
  const prompt = userPromptText(event);
6760
7071
  const skillReferenceGuidance = effectiveFullCodeMode && prompt !== void 0 ? buildSkillReferenceGuidance(prompt, skills, skillReader) : void 0;
6761
7072
  const currentModel = context.model ? `${context.model.provider}/${context.model.id}` : void 0;
@@ -6775,20 +7086,24 @@ function createFabricExtension(entryUrl) {
6775
7086
  const guidance = [
6776
7087
  managedHost ? managedHostKernelGuidance(managedHost) : fabricExecutionKernelGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile),
6777
7088
  resolvedGuidance.slotText,
7089
+ executionRules.text,
6778
7090
  fabricSchemaGuidance(schemaMode),
6779
7091
  overrideGuidance,
6780
7092
  extensionRoster,
6781
7093
  resolvedGuidance.appendText,
6782
7094
  managedHost?.guidance
6783
7095
  ].filter((section) => Boolean(section)).join("\n\n");
7096
+ const catalog = sections ? restoreSkillsForFullCodePrompt(sections.skills ?? "", skills, effectiveFullCodeMode, skillReader).trim() : void 0;
7097
+ const forced = delivery.append ? { systemPrompt: `${systemPrompt}
7098
+
7099
+ ${guidance}` } : {};
6784
7100
  if (sections) {
6785
- const catalog = restoreSkillsForFullCodePrompt("", skills, effectiveFullCodeMode, skillReader).trim();
6786
7101
  if (catalog) sections.skills = catalog;
6787
7102
  sections.fabric = guidance;
6788
7103
  }
6789
- const forced = sections ? {} : { systemPrompt: `${systemPrompt}
6790
-
6791
- ${guidance}` };
7104
+ if (executionRules.remaining !== void 0 && event.systemPromptOptions.toolGuidelines) {
7105
+ event.systemPromptOptions.toolGuidelines.fabric_exec = executionRules.remaining;
7106
+ }
6792
7107
  if (!skillReferenceGuidance) return sections ? void 0 : forced;
6793
7108
  return {
6794
7109
  ...forced,
@@ -6802,8 +7117,7 @@ ${guidance}` };
6802
7117
  });
6803
7118
  pi.on("before_agent_start", (event) => {
6804
7119
  if (!pi.getActiveTools().includes("fabric_exec")) return;
6805
- const prompt = userPromptText(event);
6806
- if (prompt === void 0) return;
7120
+ const prompt = userPromptText(event) ?? "";
6807
7121
  const captureSnapshot = state.cwd ? capturePolicy() : void 0;
6808
7122
  if (!captureSnapshot?.enabled || !captureSnapshot.hideFromModel || !fabricOwnsModelTools()) {
6809
7123
  return;
@@ -6827,11 +7141,12 @@ ${guidance}` };
6827
7141
  };
6828
7142
  });
6829
7143
  registerFabricActorHostEventObservers(pi, (eventName, event, context) => {
6830
- if (!state.initialized) return;
7144
+ if (!state.initialized || context.signal?.aborted || event.type === "agent_settled" && event.aborted) return;
6831
7145
  state.dispatchHostEvent(eventName, event, context);
6832
7146
  });
6833
7147
  installTerminalTitle(pi, fabricTerminalTitle);
6834
7148
  pi.on("session_shutdown", async (_event, context) => {
7149
+ stopHistoryPaging();
6835
7150
  unsubscribeOwner();
6836
7151
  ownerSlot.closed = true;
6837
7152
  ownerSlot.host?.clear();
@@ -6843,6 +7158,7 @@ ${guidance}` };
6843
7158
  }
6844
7159
  await settleEntropyCompiles();
6845
7160
  entropyLifecycleEpoch += 1;
7161
+ void entropyCaches?.pool.close();
6846
7162
  entropyCaches = void 0;
6847
7163
  entropyCompilePending = void 0;
6848
7164
  unsubscribeComponentRegistration();
@@ -6852,6 +7168,7 @@ ${guidance}` };
6852
7168
  unsubscribeHostPolicy();
6853
7169
  unsubscribeProgramRun();
6854
7170
  unsubscribeActionPolicyRegistration();
7171
+ state.sessionApprovals.clear();
6855
7172
  state.actionPolicyHooks.clear();
6856
7173
  unsubscribeQuestionRendererRegistration();
6857
7174
  state.questionRenderers.clear();
@@ -6942,4 +7259,4 @@ export {
6942
7259
  FABRIC_MANAGED_HOST_VERSION,
6943
7260
  createFabricExtension
6944
7261
  };
6945
- //# sourceMappingURL=chunk-G2DZJ5LK.js.map
7262
+ //# sourceMappingURL=chunk-CB72SLHB.js.map