omp-fabric 0.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (772) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -0
  3. package/THIRD_PARTY_NOTICES.md +33 -0
  4. package/dist/activity/store.d.ts +32 -0
  5. package/dist/activity/store.d.ts.map +1 -0
  6. package/dist/activity/types.d.ts +104 -0
  7. package/dist/activity/types.d.ts.map +1 -0
  8. package/dist/actors/binding-store.d.ts +17 -0
  9. package/dist/actors/binding-store.d.ts.map +1 -0
  10. package/dist/actors/context.d.ts +13 -0
  11. package/dist/actors/context.d.ts.map +1 -0
  12. package/dist/actors/delivery-policy.d.ts +8 -0
  13. package/dist/actors/delivery-policy.d.ts.map +1 -0
  14. package/dist/actors/directory.d.ts +47 -0
  15. package/dist/actors/directory.d.ts.map +1 -0
  16. package/dist/actors/global-registry.d.ts +47 -0
  17. package/dist/actors/global-registry.d.ts.map +1 -0
  18. package/dist/actors/host-event-observer.d.ts +5 -0
  19. package/dist/actors/host-event-observer.d.ts.map +1 -0
  20. package/dist/actors/host-event-payload.d.ts +14 -0
  21. package/dist/actors/host-event-payload.d.ts.map +1 -0
  22. package/dist/actors/manager.d.ts +175 -0
  23. package/dist/actors/manager.d.ts.map +1 -0
  24. package/dist/actors/predicate.d.ts +7 -0
  25. package/dist/actors/predicate.d.ts.map +1 -0
  26. package/dist/actors/types.d.ts +211 -0
  27. package/dist/actors/types.d.ts.map +1 -0
  28. package/dist/agents/bash-worktree-add.d.ts +24 -0
  29. package/dist/agents/bash-worktree-add.d.ts.map +1 -0
  30. package/dist/agents/budget-ledger.d.ts +88 -0
  31. package/dist/agents/budget-ledger.d.ts.map +1 -0
  32. package/dist/agents/claude-cli.d.ts +32 -0
  33. package/dist/agents/claude-cli.d.ts.map +1 -0
  34. package/dist/agents/claude-cli.js +17 -0
  35. package/dist/agents/claude-cli.js.map +7 -0
  36. package/dist/agents/clone-first-worktree.d.ts +17 -0
  37. package/dist/agents/clone-first-worktree.d.ts.map +1 -0
  38. package/dist/agents/compact-control.d.ts +32 -0
  39. package/dist/agents/compact-control.d.ts.map +1 -0
  40. package/dist/agents/compact-control.js +127 -0
  41. package/dist/agents/compact-control.js.map +7 -0
  42. package/dist/agents/constants.d.ts +5 -0
  43. package/dist/agents/constants.d.ts.map +1 -0
  44. package/dist/agents/cow-clone.d.ts +8 -0
  45. package/dist/agents/cow-clone.d.ts.map +1 -0
  46. package/dist/agents/handoff.d.ts +19 -0
  47. package/dist/agents/handoff.d.ts.map +1 -0
  48. package/dist/agents/manager.d.ts +68 -0
  49. package/dist/agents/manager.d.ts.map +1 -0
  50. package/dist/agents/omp-binary.d.ts +7 -0
  51. package/dist/agents/omp-binary.d.ts.map +1 -0
  52. package/dist/agents/rm.d.ts +15 -0
  53. package/dist/agents/rm.d.ts.map +1 -0
  54. package/dist/agents/semaphore.d.ts +7 -0
  55. package/dist/agents/semaphore.d.ts.map +1 -0
  56. package/dist/agents/session-export.d.ts +9 -0
  57. package/dist/agents/session-export.d.ts.map +1 -0
  58. package/dist/agents/thinking-transfer.d.ts +39 -0
  59. package/dist/agents/thinking-transfer.d.ts.map +1 -0
  60. package/dist/agents/transports/herdr-transport.d.ts +10 -0
  61. package/dist/agents/transports/herdr-transport.d.ts.map +1 -0
  62. package/dist/agents/transports/localterm-transport.d.ts +7 -0
  63. package/dist/agents/transports/localterm-transport.d.ts.map +1 -0
  64. package/dist/agents/transports/process-transport.d.ts +7 -0
  65. package/dist/agents/transports/process-transport.d.ts.map +1 -0
  66. package/dist/agents/transports/process-utils.d.ts +29 -0
  67. package/dist/agents/transports/process-utils.d.ts.map +1 -0
  68. package/dist/agents/transports/screen-transport.d.ts +7 -0
  69. package/dist/agents/transports/screen-transport.d.ts.map +1 -0
  70. package/dist/agents/transports/tmux-transport.d.ts +7 -0
  71. package/dist/agents/transports/tmux-transport.d.ts.map +1 -0
  72. package/dist/agents/types.d.ts +251 -0
  73. package/dist/agents/types.d.ts.map +1 -0
  74. package/dist/agents/veda-cli.d.ts +22 -0
  75. package/dist/agents/veda-cli.d.ts.map +1 -0
  76. package/dist/agents/veda-cli.js +13 -0
  77. package/dist/agents/veda-cli.js.map +7 -0
  78. package/dist/agents/worktree-manager.d.ts +14 -0
  79. package/dist/agents/worktree-manager.d.ts.map +1 -0
  80. package/dist/agents/worktree-paths.d.ts +5 -0
  81. package/dist/agents/worktree-paths.d.ts.map +1 -0
  82. package/dist/async-settlement.d.ts +4 -0
  83. package/dist/async-settlement.d.ts.map +1 -0
  84. package/dist/audit/details.d.ts +82 -0
  85. package/dist/audit/details.d.ts.map +1 -0
  86. package/dist/audit/index.d.ts +4 -0
  87. package/dist/audit/index.d.ts.map +1 -0
  88. package/dist/audit/projection.d.ts +20 -0
  89. package/dist/audit/projection.d.ts.map +1 -0
  90. package/dist/audit/trace.d.ts +95 -0
  91. package/dist/audit/trace.d.ts.map +1 -0
  92. package/dist/capture/catalog.d.ts +29 -0
  93. package/dist/capture/catalog.d.ts.map +1 -0
  94. package/dist/capture/interceptor.d.ts +21 -0
  95. package/dist/capture/interceptor.d.ts.map +1 -0
  96. package/dist/capture/wrapper.d.ts +15 -0
  97. package/dist/capture/wrapper.d.ts.map +1 -0
  98. package/dist/chunks/chunk-2GQC324T.js +5001 -0
  99. package/dist/chunks/chunk-2GQC324T.js.map +7 -0
  100. package/dist/chunks/chunk-2KEWFW56.js +1229 -0
  101. package/dist/chunks/chunk-2KEWFW56.js.map +7 -0
  102. package/dist/chunks/chunk-3J7BKUNG.js +354 -0
  103. package/dist/chunks/chunk-3J7BKUNG.js.map +7 -0
  104. package/dist/chunks/chunk-4A4MVZQW.js +253 -0
  105. package/dist/chunks/chunk-4A4MVZQW.js.map +7 -0
  106. package/dist/chunks/chunk-4HQDSTHN.js +221 -0
  107. package/dist/chunks/chunk-4HQDSTHN.js.map +7 -0
  108. package/dist/chunks/chunk-4LEDA76O.js +688 -0
  109. package/dist/chunks/chunk-4LEDA76O.js.map +7 -0
  110. package/dist/chunks/chunk-5GTPD4BA.js +1318 -0
  111. package/dist/chunks/chunk-5GTPD4BA.js.map +7 -0
  112. package/dist/chunks/chunk-5IWFSDU5.js +87 -0
  113. package/dist/chunks/chunk-5IWFSDU5.js.map +7 -0
  114. package/dist/chunks/chunk-6N4XGAZY.js +21 -0
  115. package/dist/chunks/chunk-6N4XGAZY.js.map +7 -0
  116. package/dist/chunks/chunk-6QBPSZJ5.js +647 -0
  117. package/dist/chunks/chunk-6QBPSZJ5.js.map +7 -0
  118. package/dist/chunks/chunk-6X6WUU2K.js +73 -0
  119. package/dist/chunks/chunk-6X6WUU2K.js.map +7 -0
  120. package/dist/chunks/chunk-7363CD5A.js +38 -0
  121. package/dist/chunks/chunk-7363CD5A.js.map +7 -0
  122. package/dist/chunks/chunk-77FQHHZD.js +231 -0
  123. package/dist/chunks/chunk-77FQHHZD.js.map +7 -0
  124. package/dist/chunks/chunk-7BIA5BJN.js +112 -0
  125. package/dist/chunks/chunk-7BIA5BJN.js.map +7 -0
  126. package/dist/chunks/chunk-7BOAOKWH.js +64 -0
  127. package/dist/chunks/chunk-7BOAOKWH.js.map +7 -0
  128. package/dist/chunks/chunk-7TB7NXSL.js +58 -0
  129. package/dist/chunks/chunk-7TB7NXSL.js.map +7 -0
  130. package/dist/chunks/chunk-7VIQNUPS.js +17 -0
  131. package/dist/chunks/chunk-7VIQNUPS.js.map +7 -0
  132. package/dist/chunks/chunk-CT2AJ2UI.js +225 -0
  133. package/dist/chunks/chunk-CT2AJ2UI.js.map +7 -0
  134. package/dist/chunks/chunk-DLXPTBPL.js +151 -0
  135. package/dist/chunks/chunk-DLXPTBPL.js.map +7 -0
  136. package/dist/chunks/chunk-ED3BRM6P.js +17 -0
  137. package/dist/chunks/chunk-ED3BRM6P.js.map +7 -0
  138. package/dist/chunks/chunk-G2IBGGBM.js +42 -0
  139. package/dist/chunks/chunk-G2IBGGBM.js.map +7 -0
  140. package/dist/chunks/chunk-GKOFZ76R.js +1596 -0
  141. package/dist/chunks/chunk-GKOFZ76R.js.map +7 -0
  142. package/dist/chunks/chunk-HDJBUXDX.js +1102 -0
  143. package/dist/chunks/chunk-HDJBUXDX.js.map +7 -0
  144. package/dist/chunks/chunk-IGVDD2HT.js +10 -0
  145. package/dist/chunks/chunk-IGVDD2HT.js.map +7 -0
  146. package/dist/chunks/chunk-JHKOG5GS.js +187 -0
  147. package/dist/chunks/chunk-JHKOG5GS.js.map +7 -0
  148. package/dist/chunks/chunk-JP4LIZFT.js +1334 -0
  149. package/dist/chunks/chunk-JP4LIZFT.js.map +7 -0
  150. package/dist/chunks/chunk-JSBTB3P6.js +127 -0
  151. package/dist/chunks/chunk-JSBTB3P6.js.map +7 -0
  152. package/dist/chunks/chunk-KAD7UWT2.js +99 -0
  153. package/dist/chunks/chunk-KAD7UWT2.js.map +7 -0
  154. package/dist/chunks/chunk-KIH3KLZU.js +95 -0
  155. package/dist/chunks/chunk-KIH3KLZU.js.map +7 -0
  156. package/dist/chunks/chunk-KIREBD2V.js +2208 -0
  157. package/dist/chunks/chunk-KIREBD2V.js.map +7 -0
  158. package/dist/chunks/chunk-LMAVZN7J.js +8 -0
  159. package/dist/chunks/chunk-LMAVZN7J.js.map +7 -0
  160. package/dist/chunks/chunk-NCPJZXLM.js +57 -0
  161. package/dist/chunks/chunk-NCPJZXLM.js.map +7 -0
  162. package/dist/chunks/chunk-OJZNMROB.js +195 -0
  163. package/dist/chunks/chunk-OJZNMROB.js.map +7 -0
  164. package/dist/chunks/chunk-OPTP4PSE.js +469 -0
  165. package/dist/chunks/chunk-OPTP4PSE.js.map +7 -0
  166. package/dist/chunks/chunk-QPXSCMTG.js +24 -0
  167. package/dist/chunks/chunk-QPXSCMTG.js.map +7 -0
  168. package/dist/chunks/chunk-ROKMBLGN.js +1265 -0
  169. package/dist/chunks/chunk-ROKMBLGN.js.map +7 -0
  170. package/dist/chunks/chunk-SXMWV447.js +2445 -0
  171. package/dist/chunks/chunk-SXMWV447.js.map +7 -0
  172. package/dist/chunks/chunk-T5ZA5YRU.js +786 -0
  173. package/dist/chunks/chunk-T5ZA5YRU.js.map +7 -0
  174. package/dist/chunks/chunk-T6OAX4FO.js +1835 -0
  175. package/dist/chunks/chunk-T6OAX4FO.js.map +7 -0
  176. package/dist/chunks/chunk-U5FYOMG5.js +119 -0
  177. package/dist/chunks/chunk-U5FYOMG5.js.map +7 -0
  178. package/dist/chunks/chunk-UOSJZXJV.js +142 -0
  179. package/dist/chunks/chunk-UOSJZXJV.js.map +7 -0
  180. package/dist/chunks/chunk-UPCARIJP.js +6627 -0
  181. package/dist/chunks/chunk-UPCARIJP.js.map +7 -0
  182. package/dist/chunks/chunk-VPPIJRNZ.js +50 -0
  183. package/dist/chunks/chunk-VPPIJRNZ.js.map +7 -0
  184. package/dist/chunks/chunk-XU5Z4JCQ.js +297 -0
  185. package/dist/chunks/chunk-XU5Z4JCQ.js.map +7 -0
  186. package/dist/chunks/chunk-YWEXP724.js +427 -0
  187. package/dist/chunks/chunk-YWEXP724.js.map +7 -0
  188. package/dist/chunks/chunk-YZZIKJX6.js +60 -0
  189. package/dist/chunks/chunk-YZZIKJX6.js.map +7 -0
  190. package/dist/chunks/chunk-ZNAJDPT7.js +2203 -0
  191. package/dist/chunks/chunk-ZNAJDPT7.js.map +7 -0
  192. package/dist/chunks/chunk-ZTM45GH5.js +163 -0
  193. package/dist/chunks/chunk-ZTM45GH5.js.map +7 -0
  194. package/dist/commands/fabric.d.ts +17 -0
  195. package/dist/commands/fabric.d.ts.map +1 -0
  196. package/dist/compaction/bounds.d.ts +23 -0
  197. package/dist/compaction/bounds.d.ts.map +1 -0
  198. package/dist/compaction/branch-details.d.ts +83 -0
  199. package/dist/compaction/branch-details.d.ts.map +1 -0
  200. package/dist/compaction/branch-summary.d.ts +9 -0
  201. package/dist/compaction/branch-summary.d.ts.map +1 -0
  202. package/dist/compaction/enrichers.d.ts +10 -0
  203. package/dist/compaction/enrichers.d.ts.map +1 -0
  204. package/dist/compaction/hook.d.ts +98 -0
  205. package/dist/compaction/hook.d.ts.map +1 -0
  206. package/dist/compaction/hook.js +19 -0
  207. package/dist/compaction/hook.js.map +7 -0
  208. package/dist/compaction/instructions.d.ts +38 -0
  209. package/dist/compaction/instructions.d.ts.map +1 -0
  210. package/dist/compaction/normalize.d.ts +83 -0
  211. package/dist/compaction/normalize.d.ts.map +1 -0
  212. package/dist/compaction/projections.d.ts +31 -0
  213. package/dist/compaction/projections.d.ts.map +1 -0
  214. package/dist/compaction/qa.d.ts +27 -0
  215. package/dist/compaction/qa.d.ts.map +1 -0
  216. package/dist/compaction/render.d.ts +10 -0
  217. package/dist/compaction/render.d.ts.map +1 -0
  218. package/dist/compaction/threshold.d.ts +5 -0
  219. package/dist/compaction/threshold.d.ts.map +1 -0
  220. package/dist/compaction/trace-events.d.ts +23 -0
  221. package/dist/compaction/trace-events.d.ts.map +1 -0
  222. package/dist/components/catalog.d.ts +25 -0
  223. package/dist/components/catalog.d.ts.map +1 -0
  224. package/dist/components/effect-scope.d.ts +31 -0
  225. package/dist/components/effect-scope.d.ts.map +1 -0
  226. package/dist/components/loader.d.ts +27 -0
  227. package/dist/components/loader.d.ts.map +1 -0
  228. package/dist/components/model-guidance.d.ts +48 -0
  229. package/dist/components/model-guidance.d.ts.map +1 -0
  230. package/dist/components/provider-component.d.ts +31 -0
  231. package/dist/components/provider-component.d.ts.map +1 -0
  232. package/dist/components/supervisor.d.ts +29 -0
  233. package/dist/components/supervisor.d.ts.map +1 -0
  234. package/dist/components/types.d.ts +140 -0
  235. package/dist/components/types.d.ts.map +1 -0
  236. package/dist/config-migrations.d.ts +11 -0
  237. package/dist/config-migrations.d.ts.map +1 -0
  238. package/dist/config.d.ts +269 -0
  239. package/dist/config.d.ts.map +1 -0
  240. package/dist/core/action-registry.d.ts +159 -0
  241. package/dist/core/action-registry.d.ts.map +1 -0
  242. package/dist/core/action-registry.js +17 -0
  243. package/dist/core/action-registry.js.map +7 -0
  244. package/dist/core/action-repair.d.ts +20 -0
  245. package/dist/core/action-repair.d.ts.map +1 -0
  246. package/dist/core/agent-dir.d.ts +2 -0
  247. package/dist/core/agent-dir.d.ts.map +1 -0
  248. package/dist/core/approval-controller.d.ts +30 -0
  249. package/dist/core/approval-controller.d.ts.map +1 -0
  250. package/dist/core/atomic-write.d.ts +15 -0
  251. package/dist/core/atomic-write.d.ts.map +1 -0
  252. package/dist/core/auto-approval-classifier.d.ts +13 -0
  253. package/dist/core/auto-approval-classifier.d.ts.map +1 -0
  254. package/dist/core/call-preview.d.ts +8 -0
  255. package/dist/core/call-preview.d.ts.map +1 -0
  256. package/dist/core/child-tool-allowlist.d.ts +3 -0
  257. package/dist/core/child-tool-allowlist.d.ts.map +1 -0
  258. package/dist/core/compact-controller.d.ts +42 -0
  259. package/dist/core/compact-controller.d.ts.map +1 -0
  260. package/dist/core/core-override-guidance.d.ts +7 -0
  261. package/dist/core/core-override-guidance.d.ts.map +1 -0
  262. package/dist/core/direct-tool-approval.d.ts +19 -0
  263. package/dist/core/direct-tool-approval.d.ts.map +1 -0
  264. package/dist/core/effect-conflict.d.ts +3 -0
  265. package/dist/core/effect-conflict.d.ts.map +1 -0
  266. package/dist/core/file-lock.d.ts +12 -0
  267. package/dist/core/file-lock.d.ts.map +1 -0
  268. package/dist/core/model-resolution.d.ts +62 -0
  269. package/dist/core/model-resolution.d.ts.map +1 -0
  270. package/dist/core/model-usage.d.ts +8 -0
  271. package/dist/core/model-usage.d.ts.map +1 -0
  272. package/dist/core/omp-bash-error.d.ts +11 -0
  273. package/dist/core/omp-bash-error.d.ts.map +1 -0
  274. package/dist/core/omp-tools.d.ts +9 -0
  275. package/dist/core/omp-tools.d.ts.map +1 -0
  276. package/dist/core/provider-bindings.d.ts +47 -0
  277. package/dist/core/provider-bindings.d.ts.map +1 -0
  278. package/dist/core/proxy-contract.d.ts +18 -0
  279. package/dist/core/proxy-contract.d.ts.map +1 -0
  280. package/dist/core/session-context.d.ts +6 -0
  281. package/dist/core/session-context.d.ts.map +1 -0
  282. package/dist/core/skill-block.d.ts +10 -0
  283. package/dist/core/skill-block.d.ts.map +1 -0
  284. package/dist/core/skill-dir.d.ts +4 -0
  285. package/dist/core/skill-dir.d.ts.map +1 -0
  286. package/dist/core/skill-prompt.d.ts +3 -0
  287. package/dist/core/skill-prompt.d.ts.map +1 -0
  288. package/dist/core/skill-references.d.ts +7 -0
  289. package/dist/core/skill-references.d.ts.map +1 -0
  290. package/dist/core/stable-hash.d.ts +3 -0
  291. package/dist/core/stable-hash.d.ts.map +1 -0
  292. package/dist/core/system-guidance.d.ts +12 -0
  293. package/dist/core/system-guidance.d.ts.map +1 -0
  294. package/dist/core/token-math.d.ts +16 -0
  295. package/dist/core/token-math.d.ts.map +1 -0
  296. package/dist/core/tool-ownership.d.ts +52 -0
  297. package/dist/core/tool-ownership.d.ts.map +1 -0
  298. package/dist/core/tool-result-proxy.d.ts +18 -0
  299. package/dist/core/tool-result-proxy.d.ts.map +1 -0
  300. package/dist/entropy/active.d.ts +7 -0
  301. package/dist/entropy/active.d.ts.map +1 -0
  302. package/dist/entropy/compiled-store.d.ts +16 -0
  303. package/dist/entropy/compiled-store.d.ts.map +1 -0
  304. package/dist/entropy/compiled-surface.d.ts +51 -0
  305. package/dist/entropy/compiled-surface.d.ts.map +1 -0
  306. package/dist/entropy/compiler.d.ts +28 -0
  307. package/dist/entropy/compiler.d.ts.map +1 -0
  308. package/dist/entropy/corpus.d.ts +22 -0
  309. package/dist/entropy/corpus.d.ts.map +1 -0
  310. package/dist/entropy/fingerprint.d.ts +9 -0
  311. package/dist/entropy/fingerprint.d.ts.map +1 -0
  312. package/dist/entropy/index.d.ts +15 -0
  313. package/dist/entropy/index.d.ts.map +1 -0
  314. package/dist/entropy/index.js +172 -0
  315. package/dist/entropy/index.js.map +7 -0
  316. package/dist/entropy/meter.d.ts +10 -0
  317. package/dist/entropy/meter.d.ts.map +1 -0
  318. package/dist/entropy/passes.d.ts +13 -0
  319. package/dist/entropy/passes.d.ts.map +1 -0
  320. package/dist/entropy/pool-store.d.ts +15 -0
  321. package/dist/entropy/pool-store.d.ts.map +1 -0
  322. package/dist/entropy/pool.d.ts +41 -0
  323. package/dist/entropy/pool.d.ts.map +1 -0
  324. package/dist/entropy/presentation.d.ts +13 -0
  325. package/dist/entropy/presentation.d.ts.map +1 -0
  326. package/dist/entropy/sessions.d.ts +47 -0
  327. package/dist/entropy/sessions.d.ts.map +1 -0
  328. package/dist/entropy/surface.d.ts +30 -0
  329. package/dist/entropy/surface.d.ts.map +1 -0
  330. package/dist/entropy/trial.d.ts +35 -0
  331. package/dist/entropy/trial.d.ts.map +1 -0
  332. package/dist/entropy/types.d.ts +158 -0
  333. package/dist/entropy/types.d.ts.map +1 -0
  334. package/dist/execution-service.d.ts +63 -0
  335. package/dist/execution-service.d.ts.map +1 -0
  336. package/dist/fabric-exec-arguments.d.ts +5 -0
  337. package/dist/fabric-exec-arguments.d.ts.map +1 -0
  338. package/dist/fabric-exec-tool.d.ts +8 -0
  339. package/dist/fabric-exec-tool.d.ts.map +1 -0
  340. package/dist/fabric-runtime-state.d.ts +90 -0
  341. package/dist/fabric-runtime-state.d.ts.map +1 -0
  342. package/dist/fabric-runtime-state.js +13060 -0
  343. package/dist/fabric-runtime-state.js.map +7 -0
  344. package/dist/fabric-state.d.ts +89 -0
  345. package/dist/fabric-state.d.ts.map +1 -0
  346. package/dist/failure-progress.d.ts +3 -0
  347. package/dist/failure-progress.d.ts.map +1 -0
  348. package/dist/host-compatibility.d.ts +5 -0
  349. package/dist/host-compatibility.d.ts.map +1 -0
  350. package/dist/index.d.ts +6 -0
  351. package/dist/index.d.ts.map +1 -0
  352. package/dist/index.js +5719 -0
  353. package/dist/index.js.map +7 -0
  354. package/dist/lifecycle/broker.d.ts +30 -0
  355. package/dist/lifecycle/broker.d.ts.map +1 -0
  356. package/dist/lifecycle/delivery-scheduler.d.ts +30 -0
  357. package/dist/lifecycle/delivery-scheduler.d.ts.map +1 -0
  358. package/dist/lifecycle/types.d.ts +91 -0
  359. package/dist/lifecycle/types.d.ts.map +1 -0
  360. package/dist/log-tail.d.ts +11 -0
  361. package/dist/log-tail.d.ts.map +1 -0
  362. package/dist/main-agent.d.ts +70 -0
  363. package/dist/main-agent.d.ts.map +1 -0
  364. package/dist/memory/context.d.ts +112 -0
  365. package/dist/memory/context.d.ts.map +1 -0
  366. package/dist/memory/digest.d.ts +48 -0
  367. package/dist/memory/digest.d.ts.map +1 -0
  368. package/dist/memory/digest.js +7 -0
  369. package/dist/memory/digest.js.map +7 -0
  370. package/dist/memory/discovery.d.ts +43 -0
  371. package/dist/memory/discovery.d.ts.map +1 -0
  372. package/dist/memory/discovery.js +23 -0
  373. package/dist/memory/discovery.js.map +7 -0
  374. package/dist/memory/index.d.ts +107 -0
  375. package/dist/memory/index.d.ts.map +1 -0
  376. package/dist/memory/lineage.d.ts +20 -0
  377. package/dist/memory/lineage.d.ts.map +1 -0
  378. package/dist/memory/normalize.d.ts +170 -0
  379. package/dist/memory/normalize.d.ts.map +1 -0
  380. package/dist/memory/normalize.js +22 -0
  381. package/dist/memory/normalize.js.map +7 -0
  382. package/dist/memory/regex.d.ts +19 -0
  383. package/dist/memory/regex.d.ts.map +1 -0
  384. package/dist/memory/search.d.ts +98 -0
  385. package/dist/memory/search.d.ts.map +1 -0
  386. package/dist/memory/search.js +22 -0
  387. package/dist/memory/search.js.map +7 -0
  388. package/dist/memory/tokenize.d.ts +24 -0
  389. package/dist/memory/tokenize.d.ts.map +1 -0
  390. package/dist/mesh/store.d.ts +78 -0
  391. package/dist/mesh/store.d.ts.map +1 -0
  392. package/dist/output-budget.d.ts +12 -0
  393. package/dist/output-budget.d.ts.map +1 -0
  394. package/dist/prewalk/arm.d.ts +8 -0
  395. package/dist/prewalk/arm.d.ts.map +1 -0
  396. package/dist/prewalk/controller.d.ts +60 -0
  397. package/dist/prewalk/controller.d.ts.map +1 -0
  398. package/dist/prewalk/fs-drift.d.ts +19 -0
  399. package/dist/prewalk/fs-drift.d.ts.map +1 -0
  400. package/dist/prewalk/handoff.d.ts +45 -0
  401. package/dist/prewalk/handoff.d.ts.map +1 -0
  402. package/dist/protocol.d.ts +273 -0
  403. package/dist/protocol.d.ts.map +1 -0
  404. package/dist/protocol.js +46 -0
  405. package/dist/protocol.js.map +7 -0
  406. package/dist/providers/agents-actions.d.ts +3 -0
  407. package/dist/providers/agents-actions.d.ts.map +1 -0
  408. package/dist/providers/agents-provider.d.ts +59 -0
  409. package/dist/providers/agents-provider.d.ts.map +1 -0
  410. package/dist/providers/arg-normalization.d.ts +15 -0
  411. package/dist/providers/arg-normalization.d.ts.map +1 -0
  412. package/dist/providers/captured-tools-provider.d.ts +23 -0
  413. package/dist/providers/captured-tools-provider.d.ts.map +1 -0
  414. package/dist/providers/compact-provider.d.ts +14 -0
  415. package/dist/providers/compact-provider.d.ts.map +1 -0
  416. package/dist/providers/components-provider.d.ts +12 -0
  417. package/dist/providers/components-provider.d.ts.map +1 -0
  418. package/dist/providers/mcp-descriptor-cache.d.ts +47 -0
  419. package/dist/providers/mcp-descriptor-cache.d.ts.map +1 -0
  420. package/dist/providers/mcp-provider.d.ts +27 -0
  421. package/dist/providers/mcp-provider.d.ts.map +1 -0
  422. package/dist/providers/memory-provider.d.ts +35 -0
  423. package/dist/providers/memory-provider.d.ts.map +1 -0
  424. package/dist/providers/memory-provider.js +16 -0
  425. package/dist/providers/memory-provider.js.map +7 -0
  426. package/dist/providers/mesh-provider.d.ts +17 -0
  427. package/dist/providers/mesh-provider.d.ts.map +1 -0
  428. package/dist/providers/omp-bash-cwd.d.ts +31 -0
  429. package/dist/providers/omp-bash-cwd.d.ts.map +1 -0
  430. package/dist/providers/omp-tools-provider.d.ts +15 -0
  431. package/dist/providers/omp-tools-provider.d.ts.map +1 -0
  432. package/dist/providers/schema-provider.d.ts +15 -0
  433. package/dist/providers/schema-provider.d.ts.map +1 -0
  434. package/dist/providers/state-provider.d.ts +16 -0
  435. package/dist/providers/state-provider.d.ts.map +1 -0
  436. package/dist/providers/write-diff-limits.d.ts +5 -0
  437. package/dist/providers/write-diff-limits.d.ts.map +1 -0
  438. package/dist/providers/write-preview.d.ts +3 -0
  439. package/dist/providers/write-preview.d.ts.map +1 -0
  440. package/dist/ref-names.d.ts +2 -0
  441. package/dist/ref-names.d.ts.map +1 -0
  442. package/dist/repairs/active.d.ts +7 -0
  443. package/dist/repairs/active.d.ts.map +1 -0
  444. package/dist/repairs/apply.d.ts +7 -0
  445. package/dist/repairs/apply.d.ts.map +1 -0
  446. package/dist/repairs/catalog-digest.d.ts +5 -0
  447. package/dist/repairs/catalog-digest.d.ts.map +1 -0
  448. package/dist/repairs/classify.d.ts +10 -0
  449. package/dist/repairs/classify.d.ts.map +1 -0
  450. package/dist/repairs/compiler.d.ts +33 -0
  451. package/dist/repairs/compiler.d.ts.map +1 -0
  452. package/dist/repairs/promote.d.ts +4 -0
  453. package/dist/repairs/promote.d.ts.map +1 -0
  454. package/dist/repairs/store.d.ts +10 -0
  455. package/dist/repairs/store.d.ts.map +1 -0
  456. package/dist/repairs/types.d.ts +49 -0
  457. package/dist/repairs/types.d.ts.map +1 -0
  458. package/dist/residency/actor-client.d.ts +16 -0
  459. package/dist/residency/actor-client.d.ts.map +1 -0
  460. package/dist/residency/actor-client.js +9 -0
  461. package/dist/residency/actor-client.js.map +7 -0
  462. package/dist/residency/client.d.ts +44 -0
  463. package/dist/residency/client.d.ts.map +1 -0
  464. package/dist/residency/host.d.ts +3 -0
  465. package/dist/residency/host.d.ts.map +1 -0
  466. package/dist/residency/host.js +25 -0
  467. package/dist/residency/host.js.map +7 -0
  468. package/dist/residency/launcher-owner.d.ts +7 -0
  469. package/dist/residency/launcher-owner.d.ts.map +1 -0
  470. package/dist/residency/launcher.d.ts +3 -0
  471. package/dist/residency/launcher.d.ts.map +1 -0
  472. package/dist/residency/launcher.js +152 -0
  473. package/dist/residency/launcher.js.map +7 -0
  474. package/dist/residency/omp-entry.d.ts +3 -0
  475. package/dist/residency/omp-entry.d.ts.map +1 -0
  476. package/dist/residency/omp-entry.js +41 -0
  477. package/dist/residency/omp-entry.js.map +7 -0
  478. package/dist/residency/protocol.d.ts +119 -0
  479. package/dist/residency/protocol.d.ts.map +1 -0
  480. package/dist/run-display.d.ts +3 -0
  481. package/dist/run-display.d.ts.map +1 -0
  482. package/dist/runtime/core-override-guest-types.d.ts +15 -0
  483. package/dist/runtime/core-override-guest-types.d.ts.map +1 -0
  484. package/dist/runtime/core-override-guest-types.js +291 -0
  485. package/dist/runtime/core-override-guest-types.js.map +7 -0
  486. package/dist/runtime/core-tool-properties.d.ts +6 -0
  487. package/dist/runtime/core-tool-properties.d.ts.map +1 -0
  488. package/dist/runtime/dynamic-guest-types.d.ts +3 -0
  489. package/dist/runtime/dynamic-guest-types.d.ts.map +1 -0
  490. package/dist/runtime/dynamic-guest-types.js +226 -0
  491. package/dist/runtime/dynamic-guest-types.js.map +7 -0
  492. package/dist/runtime/guest-code-repair.d.ts +2 -0
  493. package/dist/runtime/guest-code-repair.d.ts.map +1 -0
  494. package/dist/runtime/guest-stack-map.d.ts +11 -0
  495. package/dist/runtime/guest-stack-map.d.ts.map +1 -0
  496. package/dist/runtime/guest-types.d.ts +35 -0
  497. package/dist/runtime/guest-types.d.ts.map +1 -0
  498. package/dist/runtime/guest-types.js +13 -0
  499. package/dist/runtime/guest-types.js.map +7 -0
  500. package/dist/runtime/node-process-child-source.d.ts +2 -0
  501. package/dist/runtime/node-process-child-source.d.ts.map +1 -0
  502. package/dist/runtime/node-process-runtime.d.ts +10 -0
  503. package/dist/runtime/node-process-runtime.d.ts.map +1 -0
  504. package/dist/runtime/node-process-runtime.js +319 -0
  505. package/dist/runtime/node-process-runtime.js.map +7 -0
  506. package/dist/runtime/orchestration.d.ts +3 -0
  507. package/dist/runtime/orchestration.d.ts.map +1 -0
  508. package/dist/runtime/quickjs-runtime.d.ts +24 -0
  509. package/dist/runtime/quickjs-runtime.d.ts.map +1 -0
  510. package/dist/runtime/quickjs-runtime.js +12 -0
  511. package/dist/runtime/quickjs-runtime.js.map +7 -0
  512. package/dist/runtime/type-checker.d.ts +21 -0
  513. package/dist/runtime/type-checker.d.ts.map +1 -0
  514. package/dist/runtime/type-checker.js +15 -0
  515. package/dist/runtime/type-checker.js.map +7 -0
  516. package/dist/runtime-paths.d.ts +7 -0
  517. package/dist/runtime-paths.d.ts.map +1 -0
  518. package/dist/schema/controller.d.ts +35 -0
  519. package/dist/schema/controller.d.ts.map +1 -0
  520. package/dist/schema/types.d.ts +86 -0
  521. package/dist/schema/types.d.ts.map +1 -0
  522. package/dist/schema/workspace.d.ts +19 -0
  523. package/dist/schema/workspace.d.ts.map +1 -0
  524. package/dist/speculation/eligibility.d.ts +22 -0
  525. package/dist/speculation/eligibility.d.ts.map +1 -0
  526. package/dist/speculation/freshness.d.ts +10 -0
  527. package/dist/speculation/freshness.d.ts.map +1 -0
  528. package/dist/speculation/partial-json.d.ts +9 -0
  529. package/dist/speculation/partial-json.d.ts.map +1 -0
  530. package/dist/speculation/scanner.d.ts +13 -0
  531. package/dist/speculation/scanner.d.ts.map +1 -0
  532. package/dist/speculation/scanner.js +182 -0
  533. package/dist/speculation/scanner.js.map +7 -0
  534. package/dist/speculation/store.d.ts +39 -0
  535. package/dist/speculation/store.d.ts.map +1 -0
  536. package/dist/speculation/stream-tap.d.ts +27 -0
  537. package/dist/speculation/stream-tap.d.ts.map +1 -0
  538. package/dist/speculation/types.d.ts +44 -0
  539. package/dist/speculation/types.d.ts.map +1 -0
  540. package/dist/state/complexity.d.ts +13 -0
  541. package/dist/state/complexity.d.ts.map +1 -0
  542. package/dist/state/evidence-runner.d.ts +17 -0
  543. package/dist/state/evidence-runner.d.ts.map +1 -0
  544. package/dist/state/store.d.ts +76 -0
  545. package/dist/state/store.d.ts.map +1 -0
  546. package/dist/state/types.d.ts +165 -0
  547. package/dist/state/types.d.ts.map +1 -0
  548. package/dist/storage/retention.d.ts +22 -0
  549. package/dist/storage/retention.d.ts.map +1 -0
  550. package/dist/thinking.d.ts +19 -0
  551. package/dist/thinking.d.ts.map +1 -0
  552. package/dist/topology/control-plane.d.ts +58 -0
  553. package/dist/topology/control-plane.d.ts.map +1 -0
  554. package/dist/topology/participant-directory.d.ts +33 -0
  555. package/dist/topology/participant-directory.d.ts.map +1 -0
  556. package/dist/topology/peer-settle.d.ts +51 -0
  557. package/dist/topology/peer-settle.d.ts.map +1 -0
  558. package/dist/topology/records.d.ts +6 -0
  559. package/dist/topology/records.d.ts.map +1 -0
  560. package/dist/topology/types.d.ts +89 -0
  561. package/dist/topology/types.d.ts.map +1 -0
  562. package/dist/type-error-guidance.d.ts +3 -0
  563. package/dist/type-error-guidance.d.ts.map +1 -0
  564. package/dist/ui/arc-group.d.ts +17 -0
  565. package/dist/ui/arc-group.d.ts.map +1 -0
  566. package/dist/ui/code-preview-shell.d.ts +26 -0
  567. package/dist/ui/code-preview-shell.d.ts.map +1 -0
  568. package/dist/ui/code-preview.d.ts +53 -0
  569. package/dist/ui/code-preview.d.ts.map +1 -0
  570. package/dist/ui/controller.d.ts +20 -0
  571. package/dist/ui/controller.d.ts.map +1 -0
  572. package/dist/ui/conversation-chrome.d.ts +15 -0
  573. package/dist/ui/conversation-chrome.d.ts.map +1 -0
  574. package/dist/ui/conversation-chrome.js +10 -0
  575. package/dist/ui/conversation-chrome.js.map +7 -0
  576. package/dist/ui/conversation-native-reader.d.ts +106 -0
  577. package/dist/ui/conversation-native-reader.d.ts.map +1 -0
  578. package/dist/ui/conversation-native-reader.js +784 -0
  579. package/dist/ui/conversation-native-reader.js.map +7 -0
  580. package/dist/ui/conversation-queue-store.d.ts +12 -0
  581. package/dist/ui/conversation-queue-store.d.ts.map +1 -0
  582. package/dist/ui/conversation-queue.d.ts +242 -0
  583. package/dist/ui/conversation-queue.d.ts.map +1 -0
  584. package/dist/ui/conversation-render.d.ts +45 -0
  585. package/dist/ui/conversation-render.d.ts.map +1 -0
  586. package/dist/ui/conversation-shortcut.d.ts +3 -0
  587. package/dist/ui/conversation-shortcut.d.ts.map +1 -0
  588. package/dist/ui/conversation-targets.d.ts +7 -0
  589. package/dist/ui/conversation-targets.d.ts.map +1 -0
  590. package/dist/ui/conversation-targets.js +12 -0
  591. package/dist/ui/conversation-targets.js.map +7 -0
  592. package/dist/ui/conversation-transcript.d.ts +25 -0
  593. package/dist/ui/conversation-transcript.d.ts.map +1 -0
  594. package/dist/ui/conversation.d.ts +170 -0
  595. package/dist/ui/conversation.d.ts.map +1 -0
  596. package/dist/ui/conversation.js +1868 -0
  597. package/dist/ui/conversation.js.map +7 -0
  598. package/dist/ui/core-tool-render.d.ts +20 -0
  599. package/dist/ui/core-tool-render.d.ts.map +1 -0
  600. package/dist/ui/dashboard-detail.d.ts +68 -0
  601. package/dist/ui/dashboard-detail.d.ts.map +1 -0
  602. package/dist/ui/dashboard-fabric-graph.d.ts +50 -0
  603. package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -0
  604. package/dist/ui/dashboard-model.d.ts +111 -0
  605. package/dist/ui/dashboard-model.d.ts.map +1 -0
  606. package/dist/ui/dashboard-presentation.d.ts +6 -0
  607. package/dist/ui/dashboard-presentation.d.ts.map +1 -0
  608. package/dist/ui/dashboard.d.ts +188 -0
  609. package/dist/ui/dashboard.d.ts.map +1 -0
  610. package/dist/ui/dashboard.js +4604 -0
  611. package/dist/ui/dashboard.js.map +7 -0
  612. package/dist/ui/diff-background.d.ts +12 -0
  613. package/dist/ui/diff-background.d.ts.map +1 -0
  614. package/dist/ui/dynamic-border.d.ts +8 -0
  615. package/dist/ui/dynamic-border.d.ts.map +1 -0
  616. package/dist/ui/escape-halt.d.ts +11 -0
  617. package/dist/ui/escape-halt.d.ts.map +1 -0
  618. package/dist/ui/fabric-actor-delivery-selector.d.ts +17 -0
  619. package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -0
  620. package/dist/ui/fabric-actor-tool-selector.d.ts +22 -0
  621. package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -0
  622. package/dist/ui/fabric-code-parser.d.ts +8 -0
  623. package/dist/ui/fabric-code-parser.d.ts.map +1 -0
  624. package/dist/ui/fabric-host-event-selector.d.ts +29 -0
  625. package/dist/ui/fabric-host-event-selector.d.ts.map +1 -0
  626. package/dist/ui/fabric-model-selector.d.ts +64 -0
  627. package/dist/ui/fabric-model-selector.d.ts.map +1 -0
  628. package/dist/ui/fabric-render.d.ts +113 -0
  629. package/dist/ui/fabric-render.d.ts.map +1 -0
  630. package/dist/ui/fabric-thinking-selector.d.ts +26 -0
  631. package/dist/ui/fabric-thinking-selector.d.ts.map +1 -0
  632. package/dist/ui/fabric-title-hint.d.ts +2 -0
  633. package/dist/ui/fabric-title-hint.d.ts.map +1 -0
  634. package/dist/ui/format.d.ts +9 -0
  635. package/dist/ui/format.d.ts.map +1 -0
  636. package/dist/ui/highlight.d.ts +69 -0
  637. package/dist/ui/highlight.d.ts.map +1 -0
  638. package/dist/ui/model-picker.d.ts +46 -0
  639. package/dist/ui/model-picker.d.ts.map +1 -0
  640. package/dist/ui/model-picker.js +17 -0
  641. package/dist/ui/model-picker.js.map +7 -0
  642. package/dist/ui/preview-lines.d.ts +16 -0
  643. package/dist/ui/preview-lines.d.ts.map +1 -0
  644. package/dist/ui/row-balance.d.ts +29 -0
  645. package/dist/ui/row-balance.d.ts.map +1 -0
  646. package/dist/ui/settings.d.ts +57 -0
  647. package/dist/ui/settings.d.ts.map +1 -0
  648. package/dist/ui/settings.js +1908 -0
  649. package/dist/ui/settings.js.map +7 -0
  650. package/dist/ui/shiki-language.d.ts +7 -0
  651. package/dist/ui/shiki-language.d.ts.map +1 -0
  652. package/dist/ui/shiki-theme.d.ts +7 -0
  653. package/dist/ui/shiki-theme.d.ts.map +1 -0
  654. package/dist/ui/snapshot.d.ts +7 -0
  655. package/dist/ui/snapshot.d.ts.map +1 -0
  656. package/dist/ui/spinner.d.ts +6 -0
  657. package/dist/ui/spinner.d.ts.map +1 -0
  658. package/dist/ui/state-file-preview.d.ts +13 -0
  659. package/dist/ui/state-file-preview.d.ts.map +1 -0
  660. package/dist/ui/structured.d.ts +9 -0
  661. package/dist/ui/structured.d.ts.map +1 -0
  662. package/dist/ui/symbol-theme.d.ts +3 -0
  663. package/dist/ui/symbol-theme.d.ts.map +1 -0
  664. package/dist/ui/tool-call-timing.d.ts +2 -0
  665. package/dist/ui/tool-call-timing.d.ts.map +1 -0
  666. package/dist/ui/tool-display.d.ts +8 -0
  667. package/dist/ui/tool-display.d.ts.map +1 -0
  668. package/dist/ui/topology.d.ts +162 -0
  669. package/dist/ui/topology.d.ts.map +1 -0
  670. package/dist/ui/transcript-parser.d.ts +18 -0
  671. package/dist/ui/transcript-parser.d.ts.map +1 -0
  672. package/dist/ui/transcript-reader.d.ts +10 -0
  673. package/dist/ui/transcript-reader.d.ts.map +1 -0
  674. package/dist/ui/transcript-sanitization.d.ts +14 -0
  675. package/dist/ui/transcript-sanitization.d.ts.map +1 -0
  676. package/dist/ui/transcript.d.ts +52 -0
  677. package/dist/ui/transcript.d.ts.map +1 -0
  678. package/dist/ui/types.d.ts +84 -0
  679. package/dist/ui/types.d.ts.map +1 -0
  680. package/dist/ui/widget.d.ts +16 -0
  681. package/dist/ui/widget.d.ts.map +1 -0
  682. package/dist/ui/word-diff/alignment.d.ts +6 -0
  683. package/dist/ui/word-diff/alignment.d.ts.map +1 -0
  684. package/dist/ui/word-diff/change-block.d.ts +18 -0
  685. package/dist/ui/word-diff/change-block.d.ts.map +1 -0
  686. package/dist/ui/word-diff/changed-line.d.ts +14 -0
  687. package/dist/ui/word-diff/changed-line.d.ts.map +1 -0
  688. package/dist/ui/word-diff/emphasis.d.ts +9 -0
  689. package/dist/ui/word-diff/emphasis.d.ts.map +1 -0
  690. package/dist/ui/word-diff/line-emphasis.d.ts +7 -0
  691. package/dist/ui/word-diff/line-emphasis.d.ts.map +1 -0
  692. package/dist/ui/word-diff/line-matching.d.ts +10 -0
  693. package/dist/ui/word-diff/line-matching.d.ts.map +1 -0
  694. package/dist/ui/word-diff/line-similarity.d.ts +16 -0
  695. package/dist/ui/word-diff/line-similarity.d.ts.map +1 -0
  696. package/dist/ui/word-diff/normalize.d.ts +3 -0
  697. package/dist/ui/word-diff/normalize.d.ts.map +1 -0
  698. package/dist/ui/word-diff/parse.d.ts +17 -0
  699. package/dist/ui/word-diff/parse.d.ts.map +1 -0
  700. package/dist/ui/word-diff/range-refinement.d.ts +5 -0
  701. package/dist/ui/word-diff/range-refinement.d.ts.map +1 -0
  702. package/dist/ui/word-diff/ranges.d.ts +11 -0
  703. package/dist/ui/word-diff/ranges.d.ts.map +1 -0
  704. package/dist/ui/word-diff/smart-filter.d.ts +3 -0
  705. package/dist/ui/word-diff/smart-filter.d.ts.map +1 -0
  706. package/dist/ui/word-diff/sparse-line-matching.d.ts +25 -0
  707. package/dist/ui/word-diff/sparse-line-matching.d.ts.map +1 -0
  708. package/dist/ui/word-diff/text-boundaries.d.ts +11 -0
  709. package/dist/ui/word-diff/text-boundaries.d.ts.map +1 -0
  710. package/dist/ui/word-diff/token-alignment.d.ts +9 -0
  711. package/dist/ui/word-diff/token-alignment.d.ts.map +1 -0
  712. package/dist/ui/word-diff/token-text-refinement.d.ts +4 -0
  713. package/dist/ui/word-diff/token-text-refinement.d.ts.map +1 -0
  714. package/dist/ui/word-diff/tokens.d.ts +16 -0
  715. package/dist/ui/word-diff/tokens.d.ts.map +1 -0
  716. package/dist/ui/word-diff/types.d.ts +10 -0
  717. package/dist/ui/word-diff/types.d.ts.map +1 -0
  718. package/dist/util.d.ts +3 -0
  719. package/dist/util.d.ts.map +1 -0
  720. package/dist/worker/options.d.ts +3 -0
  721. package/dist/worker/options.d.ts.map +1 -0
  722. package/dist/worker/options.js +104 -0
  723. package/dist/worker/options.js.map +7 -0
  724. package/dist/worker/run-record.d.ts +22 -0
  725. package/dist/worker/run-record.d.ts.map +1 -0
  726. package/dist/worker/run-record.js +123 -0
  727. package/dist/worker/run-record.js.map +7 -0
  728. package/dist/worker/session-export.d.ts +45 -0
  729. package/dist/worker/session-export.d.ts.map +1 -0
  730. package/dist/worker/session-export.js +91 -0
  731. package/dist/worker/session-export.js.map +7 -0
  732. package/dist/worker.d.ts +3 -0
  733. package/dist/worker.d.ts.map +1 -0
  734. package/dist/worker.js +1061 -0
  735. package/dist/worker.js.map +7 -0
  736. package/docs/agents.md +564 -0
  737. package/docs/architecture.md +139 -0
  738. package/docs/audit-trace.md +116 -0
  739. package/docs/certification.md +134 -0
  740. package/docs/compaction.md +332 -0
  741. package/docs/component-calculus.md +191 -0
  742. package/docs/components.md +329 -0
  743. package/docs/configuration.md +478 -0
  744. package/docs/entropy.md +396 -0
  745. package/docs/interface.md +149 -0
  746. package/docs/memory-recall.md +614 -0
  747. package/docs/programmatic-compaction.md +207 -0
  748. package/docs/provider-component-calculus.md +378 -0
  749. package/docs/providers.md +109 -0
  750. package/docs/repairs.md +69 -0
  751. package/docs/residency-runtime.md +82 -0
  752. package/docs/schema-enforcement.md +166 -0
  753. package/docs/skills.md +48 -0
  754. package/docs/speculation.md +132 -0
  755. package/docs/state-layer.md +197 -0
  756. package/package.json +116 -0
  757. package/skills/fabric-advisor/SKILL.md +29 -0
  758. package/skills/fabric-ambient/SKILL.md +44 -0
  759. package/skills/fabric-ambient/references/setup.md +90 -0
  760. package/skills/fabric-council/SKILL.md +94 -0
  761. package/skills/fabric-exec/SKILL.md +123 -0
  762. package/skills/fabric-exec/references/agents.md +211 -0
  763. package/skills/fabric-exec/references/mcp.md +49 -0
  764. package/skills/fabric-exec/references/mesh.md +51 -0
  765. package/skills/fabric-fusion/SKILL.md +332 -0
  766. package/skills/fabric-guide/SKILL.md +28 -0
  767. package/skills/fabric-rlm/SKILL.md +284 -0
  768. package/skills/fabric-schema/SKILL.md +121 -0
  769. package/skills/fabric-spec/SKILL.md +42 -0
  770. package/skills/fabric-supervisor/SKILL.md +37 -0
  771. package/skills/fabric-swarm/SKILL.md +80 -0
  772. package/skills/fabric-workflow/SKILL.md +133 -0
@@ -0,0 +1,1868 @@
1
+ import {
2
+ ompSymbolTheme
3
+ } from "../chunks/chunk-G2IBGGBM.js";
4
+ import {
5
+ defaultConversationTarget
6
+ } from "../chunks/chunk-XU5Z4JCQ.js";
7
+ import {
8
+ conversationFooter
9
+ } from "../chunks/chunk-NCPJZXLM.js";
10
+ import {
11
+ isActiveStatus
12
+ } from "../chunks/chunk-QPXSCMTG.js";
13
+ import {
14
+ safeText
15
+ } from "../chunks/chunk-KIH3KLZU.js";
16
+ import {
17
+ terminalSafe,
18
+ unwrapActorEnvelopeText
19
+ } from "../chunks/chunk-DLXPTBPL.js";
20
+
21
+ // src/ui/conversation.ts
22
+ import {
23
+ CURSOR_MARKER,
24
+ Editor,
25
+ fuzzyFilter,
26
+ getKeybindings as getKeybindings2,
27
+ Input,
28
+ Key as Key2,
29
+ matchesKey as matchesKey2,
30
+ truncateToWidth as truncateToWidth2,
31
+ visibleWidth
32
+ } from "@oh-my-pi/pi-tui";
33
+
34
+ // src/ui/conversation-render.ts
35
+ import {
36
+ AssistantMessageComponent,
37
+ BashExecutionComponent,
38
+ BranchSummaryMessageComponent,
39
+ CompactionSummaryMessageComponent,
40
+ ToolExecutionComponent,
41
+ UserMessageComponent
42
+ } from "@oh-my-pi/pi-coding-agent";
43
+ import { wrapTextWithAnsi } from "@oh-my-pi/pi-tui";
44
+ var textOf = (content) => {
45
+ if (typeof content === "string") return content;
46
+ if (!Array.isArray(content)) return "";
47
+ return content.filter(
48
+ (part) => typeof part === "object" && part !== null && part.type === "text" && typeof part.text === "string"
49
+ ).map((part) => part.text).join("\n");
50
+ };
51
+ var safeRender = (component, width, fallback) => {
52
+ try {
53
+ return [...component.render(width)];
54
+ } catch {
55
+ return fallback();
56
+ }
57
+ };
58
+ var FabricConversationTranscriptRenderer = class {
59
+ constructor(tui, theme, rendererOptions = {}) {
60
+ this.tui = tui;
61
+ this.theme = theme;
62
+ this.rendererOptions = rendererOptions;
63
+ }
64
+ disposed = false;
65
+ toolComponents = /* @__PURE__ */ new Map();
66
+ assistantComponents = /* @__PURE__ */ new Map();
67
+ messageComponents = /* @__PURE__ */ new Map();
68
+ invalidate() {
69
+ if (this.disposed) return;
70
+ this.toolComponents.clear();
71
+ this.assistantComponents.clear();
72
+ this.messageComponents.clear();
73
+ this.tui.requestRender();
74
+ }
75
+ dispose() {
76
+ this.disposed = true;
77
+ this.invalidate();
78
+ }
79
+ render(transcript, width, options) {
80
+ if (this.disposed || width <= 0) return [];
81
+ const lines = [];
82
+ if (transcript.messages.length === 0 && !transcript.streaming.partialAssistant && transcript.streaming.tools.length === 0) {
83
+ return [this.theme.fg("dim", "No retained transcript yet; new agent activity will appear here.")];
84
+ }
85
+ if (transcript.hasMore) lines.push(this.theme.fg("dim", "\u2191 older activity available"));
86
+ const renderedTools = /* @__PURE__ */ new Set();
87
+ for (const message of transcript.messages) this.renderMessage(message, width, options, lines, renderedTools);
88
+ if (transcript.streaming.partialAssistant) {
89
+ this.renderAssistant(transcript.streaming.partialAssistant, width, options, lines, renderedTools, true);
90
+ }
91
+ for (const tool of transcript.streaming.tools) {
92
+ if (renderedTools.has(tool.toolCallId)) continue;
93
+ renderedTools.add(tool.toolCallId);
94
+ this.renderTool(tool.toolCallId, tool.toolName, tool.args, tool.result, tool.partial, tool.isError, width, options, lines, true);
95
+ }
96
+ if (transcript.hasNewer) lines.push(this.theme.fg("dim", "\u2193 newer activity available"));
97
+ return lines;
98
+ }
99
+ renderMessage(message, width, options, lines, renderedTools) {
100
+ switch (message.role) {
101
+ case "user": {
102
+ const text = unwrapActorEnvelopeText(textOf(message.content)) ?? textOf(message.content);
103
+ if (text) this.push(lines, safeRender(new UserMessageComponent(terminalSafe(text, false)), width, () => this.fallback(text, width)));
104
+ return;
105
+ }
106
+ case "assistant":
107
+ this.renderAssistant(message, width, options, lines, renderedTools, false);
108
+ return;
109
+ case "toolResult":
110
+ if (typeof message.toolCallId === "string") {
111
+ this.renderTool(message.toolCallId, message.toolName ?? "tool", void 0, message, void 0, message.isError, width, options, lines, false);
112
+ }
113
+ return;
114
+ case "bashExecution":
115
+ this.renderBash(message, width, options, lines);
116
+ return;
117
+ case "custom":
118
+ this.renderCustom(message, width, options, lines);
119
+ return;
120
+ case "compactionSummary":
121
+ this.renderSummary(message, width, options, lines, CompactionSummaryMessageComponent);
122
+ return;
123
+ case "branchSummary":
124
+ this.renderSummary(message, width, options, lines, BranchSummaryMessageComponent);
125
+ return;
126
+ default:
127
+ return;
128
+ }
129
+ }
130
+ renderAssistant(message, width, options, lines, renderedTools, transient) {
131
+ const key = `${message.timestamp}:${options.target.id}:${options.hideThinking === true}`;
132
+ let component = this.assistantComponents.get(key);
133
+ if (!component) {
134
+ component = new AssistantMessageComponent(message, options.hideThinking ?? false);
135
+ this.assistantComponents.set(key, component);
136
+ } else {
137
+ component.updateContent(message, { transient });
138
+ }
139
+ this.push(lines, safeRender(component, width, () => this.fallback(textOf(message.content), width)));
140
+ for (const block of message.content) {
141
+ if (block.type !== "toolCall" || renderedTools.has(block.id)) continue;
142
+ renderedTools.add(block.id);
143
+ this.renderTool(block.id, block.name, block.arguments, void 0, void 0, message.stopReason === "error", width, options, lines, transient);
144
+ }
145
+ }
146
+ renderTool(id, name, args, result, partial, isError, width, options, lines, transient) {
147
+ let component = this.toolComponents.get(`${options.target.id}:${id}`);
148
+ if (!component) {
149
+ const tool = this.rendererOptions.getToolDefinition?.(name);
150
+ component = new ToolExecutionComponent(name, args, { showImages: options.showImages ?? true }, tool, {
151
+ requestRender: () => this.tui.requestRender(),
152
+ requestComponentRender: () => this.tui.requestRender(),
153
+ resetDisplay: () => void 0,
154
+ imageBudget: this.tui.imageBudget
155
+ }, options.target.cwd ?? process.cwd(), id);
156
+ this.toolComponents.set(`${options.target.id}:${id}`, component);
157
+ }
158
+ component.setExpanded(options.toolsExpanded);
159
+ const normalizeResult = (raw) => {
160
+ const record = raw ?? {};
161
+ return {
162
+ content: Array.isArray(record.content) ? record.content : [],
163
+ ...record.details !== void 0 ? { details: record.details } : {},
164
+ ...record.isError !== void 0 ? { isError: record.isError } : {}
165
+ };
166
+ };
167
+ if (args !== void 0) component.updateArgs(args, id);
168
+ if (result !== void 0) component.updateResult(normalizeResult(result), false, id);
169
+ else if (partial !== void 0) component.updateResult(normalizeResult(partial), true, id);
170
+ if (isError) component.seal();
171
+ lines.push(...safeRender(component, width, () => this.fallback(name, width)));
172
+ }
173
+ renderBash(message, width, options, lines) {
174
+ const component = new BashExecutionComponent(message.command, this.tui, message.excludeFromContext);
175
+ component.appendOutput(terminalSafe(message.output ?? "", false));
176
+ component.setComplete(message.exitCode, message.cancelled, { output: message.output ?? "" });
177
+ component.setExpanded(options.toolsExpanded);
178
+ this.push(lines, safeRender(component, width, () => this.fallback(message.command, width)));
179
+ }
180
+ renderCustom(message, width, options, lines) {
181
+ const text = textOf(message.content);
182
+ if (!message.display || !text) return;
183
+ this.push(lines, safeRender(new UserMessageComponent(terminalSafe(text, false), true), width, () => this.fallback(text, width)));
184
+ }
185
+ renderSummary(message, width, options, lines, ComponentClass) {
186
+ const component = new ComponentClass(message);
187
+ if ("setExpanded" in component && typeof component.setExpanded === "function") component.setExpanded(options.toolsExpanded);
188
+ this.push(lines, safeRender(component, width, () => this.fallback(message.summary, width)));
189
+ }
190
+ push(lines, block) {
191
+ lines.push(...block);
192
+ }
193
+ fallback(text, width) {
194
+ return terminalSafe(text, false).split("\n").flatMap((line) => wrapTextWithAnsi(line, Math.max(1, width)).map((item) => this.theme.fg("text", item)));
195
+ }
196
+ };
197
+
198
+ // src/ui/conversation-queue-store.ts
199
+ import { createHash } from "node:crypto";
200
+
201
+ // src/ui/conversation-queue.ts
202
+ import {
203
+ Ellipsis,
204
+ Key,
205
+ getKeybindings,
206
+ matchesKey,
207
+ truncateToWidth
208
+ } from "@oh-my-pi/pi-tui";
209
+ var QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT = "queue-steer:conversation-queue:request:v1";
210
+ var DEQUEUE_FALLBACK = "alt+up";
211
+ var REMOVE_ROW_KEY = "alt+x";
212
+ var PAUSE_ROW_KEY = "alt+p";
213
+ var INDENT_ROW_KEY = "alt+right";
214
+ var OUTDENT_ROW_KEY = "alt+left";
215
+ var TOGGLE_LANE_KEY = "alt+t";
216
+ var NATIVE_LANE_LABEL = {
217
+ steer: "Steering",
218
+ followUp: "Follow-up"
219
+ };
220
+ var NativeQueueState = class {
221
+ items = [];
222
+ nextIdNumber = 1;
223
+ nextSequence = 1;
224
+ enqueue(lane, text, images = []) {
225
+ const prefix = lane === "steer" ? "steer" : "follow-up";
226
+ const item = {
227
+ id: `${prefix}-${this.nextIdNumber++}`,
228
+ lane,
229
+ text,
230
+ images: [...images],
231
+ sequence: this.nextSequence++,
232
+ paused: false
233
+ };
234
+ this.items.push(item);
235
+ return { ...item, images: [...item.images] };
236
+ }
237
+ snapshot() {
238
+ return this.items.map((item) => ({ ...item, images: [...item.images] }));
239
+ }
240
+ peek() {
241
+ const item = this.items[0];
242
+ return item ? { ...item, images: [...item.images] } : void 0;
243
+ }
244
+ get(id) {
245
+ const item = this.items.find((candidate) => candidate.id === id);
246
+ return item ? { ...item, images: [...item.images] } : void 0;
247
+ }
248
+ remove(id) {
249
+ const index = this.items.findIndex((candidate) => candidate.id === id);
250
+ if (index === -1) return void 0;
251
+ const [item] = this.items.splice(index, 1);
252
+ return item ? { ...item, images: [...item.images] } : void 0;
253
+ }
254
+ prepend(item) {
255
+ this.items.unshift({ ...item, images: [...item.images] });
256
+ }
257
+ prependMany(items) {
258
+ for (let index = items.length - 1; index >= 0; index -= 1) {
259
+ const item = items[index];
260
+ if (item) this.items.unshift({ ...item, images: [...item.images] });
261
+ }
262
+ }
263
+ update(id, text) {
264
+ const item = this.items.find((candidate) => candidate.id === id);
265
+ if (!item) return false;
266
+ item.text = text;
267
+ return true;
268
+ }
269
+ setLane(id, lane) {
270
+ const item = this.items.find((candidate) => candidate.id === id);
271
+ if (!item || item.lane === lane) return false;
272
+ item.lane = lane;
273
+ return true;
274
+ }
275
+ setPaused(id, paused) {
276
+ const item = this.items.find((candidate) => candidate.id === id);
277
+ if (!item || (item.paused ?? false) === paused) return false;
278
+ item.paused = paused;
279
+ return true;
280
+ }
281
+ clear() {
282
+ this.items = [];
283
+ }
284
+ get length() {
285
+ return this.items.length;
286
+ }
287
+ };
288
+ var NativeEditSession = class {
289
+ composerDraft;
290
+ currentId;
291
+ drafts = /* @__PURE__ */ new Map();
292
+ constructor(item, composerDraft) {
293
+ this.currentId = item.id;
294
+ this.composerDraft = composerDraft;
295
+ this.drafts.set(item.id, {
296
+ text: item.text,
297
+ lane: item.lane,
298
+ removed: false,
299
+ paused: item.paused ?? false
300
+ });
301
+ }
302
+ get selectedId() {
303
+ return this.currentId;
304
+ }
305
+ capture(text) {
306
+ const draft = this.drafts.get(this.currentId);
307
+ if (draft) draft.text = text;
308
+ }
309
+ select(item, currentText) {
310
+ this.capture(currentText);
311
+ if (!this.drafts.has(item.id)) {
312
+ this.drafts.set(item.id, {
313
+ text: item.text,
314
+ lane: item.lane,
315
+ removed: false,
316
+ paused: item.paused ?? false
317
+ });
318
+ }
319
+ this.currentId = item.id;
320
+ return this.drafts.get(item.id)?.text ?? item.text;
321
+ }
322
+ toggleRemoved(id) {
323
+ const draft = this.drafts.get(id);
324
+ if (!draft) return void 0;
325
+ draft.removed = !draft.removed;
326
+ return draft.removed;
327
+ }
328
+ togglePaused(id) {
329
+ const draft = this.drafts.get(id);
330
+ if (!draft) return void 0;
331
+ draft.paused = !draft.paused;
332
+ return draft.paused;
333
+ }
334
+ setLane(id, lane) {
335
+ const draft = this.drafts.get(id);
336
+ if (!draft) return void 0;
337
+ draft.lane = lane;
338
+ return draft.lane;
339
+ }
340
+ commit(queue, currentText) {
341
+ this.capture(currentText);
342
+ let updated = 0;
343
+ let removed = 0;
344
+ let moved = 0;
345
+ let held = 0;
346
+ let released = 0;
347
+ for (const [id, draft] of this.drafts.entries()) {
348
+ if (draft.removed || !draft.text.trim()) {
349
+ if (queue.remove(id)) removed += 1;
350
+ continue;
351
+ }
352
+ if (queue.update(id, draft.text)) updated += 1;
353
+ if (queue.setLane(id, draft.lane)) moved += 1;
354
+ if (queue.setPaused(id, draft.paused)) {
355
+ if (draft.paused) held += 1;
356
+ else released += 1;
357
+ }
358
+ }
359
+ return { updated, removed, moved, held, released };
360
+ }
361
+ rollbackPositions() {
362
+ }
363
+ laneFor(id) {
364
+ return this.drafts.get(id)?.lane;
365
+ }
366
+ textFor(id) {
367
+ return this.drafts.get(id)?.text;
368
+ }
369
+ pausedFor(id) {
370
+ return this.drafts.get(id)?.paused;
371
+ }
372
+ isRemoved(id) {
373
+ return this.drafts.get(id)?.removed ?? false;
374
+ }
375
+ };
376
+ var errorText = (error) => error instanceof Error ? error.message : String(error ?? "");
377
+ var controlInputRe = /^[/!]/;
378
+ function createConversationQueue(options) {
379
+ const { ompEvents, targetId, theme } = options;
380
+ const notify = (text, kind = "info") => {
381
+ options.onNotify?.(text, kind);
382
+ };
383
+ const requestRender = () => options.requestRender?.();
384
+ const targetLabel = options.targetName ?? targetId;
385
+ let bridge;
386
+ let queue;
387
+ let mode = "native";
388
+ let disposed = false;
389
+ const dispatched = [];
390
+ let externalPending = [];
391
+ let lastSendError;
392
+ let editSession;
393
+ const seenIds = /* @__PURE__ */ new Set();
394
+ const consumedIds = /* @__PURE__ */ new Set();
395
+ const liveTextCounts = /* @__PURE__ */ new Map();
396
+ const emitHandshake = (action) => {
397
+ let claimed = false;
398
+ let settled = false;
399
+ let result;
400
+ const request = {
401
+ version: 1,
402
+ action,
403
+ targetId,
404
+ claim: () => {
405
+ if (claimed) return false;
406
+ claimed = true;
407
+ return true;
408
+ },
409
+ respond: (response) => {
410
+ if (settled) return;
411
+ settled = true;
412
+ result = response;
413
+ }
414
+ };
415
+ ompEvents.emit(QUEUE_STEER_CONVERSATION_QUEUE_REQUEST_EVENT, request);
416
+ return { claimed, result };
417
+ };
418
+ const acquisition = emitHandshake("acquire");
419
+ if (acquisition.claimed && acquisition.result?.ok && acquisition.result.bridge?.version === 1 && acquisition.result.bridge.targetId === targetId) {
420
+ bridge = acquisition.result.bridge;
421
+ mode = "extension";
422
+ } else if (acquisition.claimed && acquisition.result && !acquisition.result.ok) {
423
+ notify(`pi-queue-steer refused the conversation queue for ${targetLabel}: ${acquisition.result.error ?? "unknown error"}`, "error");
424
+ }
425
+ queue = bridge ? bridge.createQueue() : new NativeQueueState();
426
+ const laneLabel = (lane) => bridge ? bridge.laneLabel(lane) : lane === "steer" ? "steer" : "follow-up";
427
+ const isQueueable = (text) => bridge ? bridge.isQueueableSubmission(text) : !controlInputRe.test(text.trim()) && text.trim() !== "";
428
+ const decoratedRow = (item) => ({
429
+ id: item.id,
430
+ lane: editSession?.laneFor?.(item.id) ?? item.lane,
431
+ text: editSession?.textFor?.(item.id) ?? item.text,
432
+ state: "queued",
433
+ paused: editSession?.pausedFor?.(item.id) ?? (item.paused ?? false),
434
+ selected: editSession?.selectedId === item.id,
435
+ removed: editSession?.isRemoved?.(item.id) ?? false
436
+ });
437
+ const orderedRows = () => {
438
+ const held = queue.snapshot().map(decoratedRow);
439
+ const inFlight = [...dispatched, ...externalPending].map((row) => ({
440
+ id: row.id,
441
+ lane: row.lane,
442
+ text: row.text,
443
+ state: "dispatched",
444
+ paused: false,
445
+ selected: false,
446
+ removed: false
447
+ }));
448
+ return [...inFlight, ...held];
449
+ };
450
+ const headBatch = (lane) => {
451
+ const items = queue.snapshot();
452
+ const head = items[0];
453
+ if (!head || head.lane !== lane) return [];
454
+ const batch = [];
455
+ for (const item of items) {
456
+ if (item.lane !== lane) break;
457
+ if (item.paused) break;
458
+ batch.push(item);
459
+ }
460
+ return batch;
461
+ };
462
+ const dequeueKeys = () => {
463
+ const manager = options.keybindings ?? getKeybindings();
464
+ const keys = manager.getKeys("app.message.dequeue");
465
+ return keys.filter((key) => /up$/i.test(key)).map(
466
+ (key) => key.endsWith("Up") ? `${key.slice(0, -2)}Down` : `${key.slice(0, -2)}down`
467
+ );
468
+ };
469
+ const actionMatches = (data, action, fallback) => {
470
+ const manager = options.keybindings;
471
+ if (manager) {
472
+ const keys = manager.getKeys(action);
473
+ if (keys.length === 0) return false;
474
+ return manager.matches(data, action);
475
+ }
476
+ const global = getKeybindings();
477
+ if (global.getKeys(action).length > 0) return global.matches(data, action);
478
+ return fallback(data);
479
+ };
480
+ const startEditing = () => {
481
+ if (!options.editor) {
482
+ notify("Editing queued rows requires the shared editor", "error");
483
+ return false;
484
+ }
485
+ const items = queue.snapshot();
486
+ if (items.length === 0) {
487
+ notify("No queued messages to edit", "info");
488
+ return false;
489
+ }
490
+ const mostRecent = items.reduce((newest, item) => item.sequence > newest.sequence ? item : newest, items[0]);
491
+ editSession = bridge ? bridge.createEditSession(mostRecent, options.editor.getText()) : new NativeEditSession(mostRecent, options.editor.getText());
492
+ options.editor.setText(mostRecent.text);
493
+ notify(`Editing queued ${laneLabel(mostRecent.lane)} row \xB7 enter saves, escape rolls back`, "info");
494
+ requestRender();
495
+ return true;
496
+ };
497
+ const finishEditing = (save) => {
498
+ const session = editSession;
499
+ const editor = options.editor;
500
+ if (!session || !editor) return false;
501
+ const currentText = editor.getText();
502
+ editSession = void 0;
503
+ if (save) {
504
+ const result = session.commit(queue, currentText);
505
+ if (result.removed > 0) notify(`Removed ${result.removed} queued row${result.removed === 1 ? "" : "s"}`, "info");
506
+ if (result.moved > 0) notify(`Changed delivery depth for ${result.moved} row${result.moved === 1 ? "" : "s"}`, "info");
507
+ if (result.held > 0) notify(`Paused ${result.held} row${result.held === 1 ? "" : "s"} \u2014 dispatch stops there until resumed`, "info");
508
+ if (result.released > 0) notify(`Resumed ${result.released} row${result.released === 1 ? "" : "s"}`, "info");
509
+ } else {
510
+ notify("Row edits rolled back", "info");
511
+ }
512
+ editor.setText(session.composerDraft);
513
+ requestRender();
514
+ return true;
515
+ };
516
+ const matchesOptionArrow = (data, direction) => {
517
+ const arrow = direction === "left" ? OUTDENT_ROW_KEY : INDENT_ROW_KEY;
518
+ const wordAlias = direction === "left" ? "alt+b" : "alt+f";
519
+ return matchesKey(data, arrow) && !matchesKey(data, wordAlias);
520
+ };
521
+ const inlineEditorRenderer = () => {
522
+ const editor = options.editor;
523
+ if (!editor?.render) return void 0;
524
+ return (width) => {
525
+ const lines = editor.render(width);
526
+ if (bridge?.extractInlineEditorLines) {
527
+ return bridge.extractInlineEditorLines(lines, editor.paddingX ?? 0);
528
+ }
529
+ return [...lines];
530
+ };
531
+ };
532
+ return {
533
+ targetId,
534
+ get mode() {
535
+ return mode;
536
+ },
537
+ get active() {
538
+ return !disposed && (queue.length > 0 || dispatched.length > 0);
539
+ },
540
+ get editingActive() {
541
+ return editSession !== void 0;
542
+ },
543
+ stage(text, lane) {
544
+ if (disposed) return { ok: false, error: "Queue is disposed" };
545
+ const trimmed = text.trim();
546
+ if (!trimmed) return { ok: false, error: "Nothing to queue" };
547
+ if (!isQueueable(trimmed) || controlInputRe.test(trimmed)) {
548
+ return {
549
+ ok: false,
550
+ error: "Control input (/ commands, ! bash) is Main-only and is not queued from a focused conversation"
551
+ };
552
+ }
553
+ const row = queue.enqueue(lane, text);
554
+ notify(`Queued ${laneLabel(lane)} \u2192 ${targetLabel}`, "info");
555
+ requestRender();
556
+ return { ok: true, id: row.id };
557
+ },
558
+ async submit(lane) {
559
+ if (disposed) return false;
560
+ if (editSession) {
561
+ notify("Finish or cancel row editing before dispatching the queue", "info");
562
+ return false;
563
+ }
564
+ const batch = headBatch(lane);
565
+ if (batch.length === 0) {
566
+ const head = queue.peek();
567
+ if (head?.paused) notify(`The next ${laneLabel(lane)} row is paused \u2014 dispatch holds there`, "info");
568
+ else notify(`No dispatchable queued ${laneLabel(lane)} rows at the timeline head`, "info");
569
+ return false;
570
+ }
571
+ let sent = 0;
572
+ lastSendError = void 0;
573
+ for (const item of batch) {
574
+ if (disposed) return false;
575
+ queue.remove(item.id);
576
+ const pending = { id: item.id, lane, text: item.text };
577
+ dispatched.push(pending);
578
+ requestRender();
579
+ let expectedId;
580
+ try {
581
+ const result = await options.send(item.text, lane);
582
+ const candidate = result;
583
+ const reported = candidate?.messageId ?? candidate?.id;
584
+ if (typeof reported === "string" && reported !== "") expectedId = reported;
585
+ } catch (error) {
586
+ lastSendError = error;
587
+ const pendingIndex = dispatched.indexOf(pending);
588
+ if (pendingIndex < 0 || disposed) return !disposed;
589
+ dispatched.splice(pendingIndex, 1);
590
+ queue.prepend({ ...item });
591
+ notify(`Send failed for ${targetLabel} (${laneLabel(lane)}); row restored to the queue head: ${errorText(error)}`, "error");
592
+ requestRender();
593
+ return false;
594
+ }
595
+ if (expectedId) pending.expectedId = expectedId;
596
+ sent += 1;
597
+ }
598
+ notify(`Accepted ${sent} queued ${laneLabel(lane)} row${sent === 1 ? "" : "s"} \u2192 ${targetLabel} \xB7 awaiting delivery`, "info");
599
+ requestRender();
600
+ return true;
601
+ },
602
+ async dispatch(text, lane) {
603
+ const row = this.stage(text, lane);
604
+ if (!row.ok || !row.id) throw new Error(row.error ?? "Unable to queue input");
605
+ if (!await this.submit(lane)) {
606
+ queue.remove(row.id);
607
+ throw lastSendError ?? new Error("The queue head is paused or held; edit or resume it before sending");
608
+ }
609
+ },
610
+ park(text, lane) {
611
+ const result = this.stage(text, lane);
612
+ if (result.id) queue.setPaused(result.id, true);
613
+ return result;
614
+ },
615
+ cancelEditing() {
616
+ if (editSession) finishEditing(false);
617
+ },
618
+ syncPending(pending) {
619
+ externalPending = [];
620
+ if (!pending) return;
621
+ const own = [...queue.snapshot(), ...dispatched];
622
+ for (const [lane, messages] of [["steer", pending.steering], ["followUp", pending.followUp]]) {
623
+ const remaining = own.filter((row) => row.lane === lane).map((row) => row.text);
624
+ messages.forEach((text, index) => {
625
+ const match = remaining.indexOf(text);
626
+ if (match >= 0) remaining.splice(match, 1);
627
+ else externalPending.push({ id: `native:${lane}:${index}`, lane, text });
628
+ });
629
+ }
630
+ },
631
+ rows: orderedRows,
632
+ render(width) {
633
+ if (disposed || width <= 0) return [];
634
+ const rows = orderedRows();
635
+ if (rows.length === 0) return [];
636
+ if (bridge?.createTimelineWidget && bridge.buildTimelineItems) {
637
+ const visibleRows = [
638
+ ...[...dispatched, ...externalPending].map((row, index) => ({ id: row.id, lane: row.lane, text: row.text, images: [], sequence: index - dispatched.length })),
639
+ ...queue.snapshot()
640
+ ];
641
+ const displayQueue = new Proxy(queue, { get(target, key) {
642
+ if (key === "snapshot") return () => visibleRows;
643
+ const value = Reflect.get(target, key, target);
644
+ return typeof value === "function" ? value.bind(target) : value;
645
+ } });
646
+ const items = bridge.buildTimelineItems(displayQueue, editSession);
647
+ const inline = editSession ? inlineEditorRenderer() : void 0;
648
+ const editingId = editSession?.selectedId;
649
+ const widget = bridge.createTimelineWidget(
650
+ {
651
+ items,
652
+ ...editingId !== void 0 ? { editingId } : {},
653
+ paused: false,
654
+ idle: options.isIdle?.() ?? false,
655
+ ...inline ? { renderInlineEditor: inline } : {}
656
+ },
657
+ theme
658
+ );
659
+ const lines2 = [...widget.render(width)];
660
+ if (dispatched.length > 0) lines2.push(theme.fg("dim", truncateToWidth("Sent rows await child delivery; they cannot be edited locally.", width, "")));
661
+ return lines2;
662
+ }
663
+ const lines = [""];
664
+ const innerWidth = Math.max(0, width - 2);
665
+ const dequeueHint = (options.keybindings ?? getKeybindings()).getKeys("app.message.dequeue").join("/") || DEQUEUE_FALLBACK;
666
+ for (const row of rows) {
667
+ const label = bridge ? bridge.laneLabel(row.lane) : NATIVE_LANE_LABEL[row.lane];
668
+ const marker = row.selected ? "\u203A " : row.paused ? "\u23F8 " : "";
669
+ const note = row.removed ? " \xB7 removed on save" : row.paused ? " \xB7 paused" : "";
670
+ const color = row.state === "dispatched" ? "dim" : bridge ? bridge.laneColor(row.lane) : "dim";
671
+ lines.push(
672
+ ` ${theme.fg(color, truncateToWidth(`${marker}${label}: ${row.text.replace(/\n/g, " ")}${note}`, innerWidth, Ellipsis.Unicode))} `
673
+ );
674
+ }
675
+ const hint = queue.length > 0 ? `\u21B3 ${dequeueHint} to edit queued messages` : "\u21B3 Waiting for child delivery";
676
+ lines.push(` ${theme.fg("dim", truncateToWidth(hint, innerWidth, Ellipsis.Unicode))} `);
677
+ return lines;
678
+ },
679
+ handleInput(data) {
680
+ if (disposed) return false;
681
+ if (!editSession) {
682
+ if (queue.length === 0) return false;
683
+ if (!options.editor?.getText().trim() && matchesKey(data, Key.enter)) {
684
+ const head = queue.peek();
685
+ if (head) {
686
+ queue.setPaused(head.id, false);
687
+ void this.submit(head.lane);
688
+ }
689
+ return true;
690
+ }
691
+ if (actionMatches(data, "app.message.dequeue", (input) => matchesKey(input, DEQUEUE_FALLBACK))) {
692
+ return startEditing();
693
+ }
694
+ return false;
695
+ }
696
+ const session = editSession;
697
+ const editor = options.editor;
698
+ if (actionMatches(data, "app.message.dequeue", (input) => matchesKey(input, DEQUEUE_FALLBACK)) && editor) {
699
+ const ordered = queue.snapshot();
700
+ const index = ordered.findIndex((item) => item.id === session.selectedId);
701
+ const target = index <= 0 ? ordered.at(-1) : ordered[index - 1];
702
+ if (target) editor.setText(session.select(target, editor.getText()));
703
+ requestRender();
704
+ return true;
705
+ }
706
+ const nextKeys = dequeueKeys();
707
+ if (nextKeys.length > 0 && nextKeys.some((key) => matchesKey(data, key)) && editor) {
708
+ const ordered = queue.snapshot();
709
+ const index = ordered.findIndex((item) => item.id === session.selectedId);
710
+ const target = index === -1 || index === ordered.length - 1 ? ordered[0] : ordered[index + 1];
711
+ if (target) editor.setText(session.select(target, editor.getText()));
712
+ requestRender();
713
+ return true;
714
+ }
715
+ if (matchesKey(data, REMOVE_ROW_KEY)) {
716
+ session.toggleRemoved(session.selectedId);
717
+ requestRender();
718
+ return true;
719
+ }
720
+ if (matchesKey(data, PAUSE_ROW_KEY)) {
721
+ session.togglePaused(session.selectedId);
722
+ requestRender();
723
+ return true;
724
+ }
725
+ if (matchesOptionArrow(data, "left")) {
726
+ session.setLane(session.selectedId, "followUp");
727
+ requestRender();
728
+ return true;
729
+ }
730
+ if (matchesOptionArrow(data, "right")) {
731
+ session.setLane(session.selectedId, "steer");
732
+ requestRender();
733
+ return true;
734
+ }
735
+ if (matchesKey(data, TOGGLE_LANE_KEY)) {
736
+ const current = queue.get(session.selectedId)?.lane;
737
+ if (current) session.setLane(session.selectedId, current === "steer" ? "followUp" : "steer");
738
+ requestRender();
739
+ return true;
740
+ }
741
+ if (actionMatches(data, "tui.input.submit", (input) => matchesKey(input, Key.enter)) || actionMatches(data, "app.message.followUp", () => false)) {
742
+ return finishEditing(true);
743
+ }
744
+ if (actionMatches(data, "app.interrupt", (input) => matchesKey(input, Key.escape))) {
745
+ return finishEditing(false);
746
+ }
747
+ editor?.handleInput?.(data);
748
+ return true;
749
+ },
750
+ syncSnapshot(entries) {
751
+ if (disposed || dispatched.length === 0) {
752
+ for (const entry of entries) {
753
+ if (!seenIds.has(entry.id)) seenIds.add(entry.id);
754
+ }
755
+ return 0;
756
+ }
757
+ for (const entry of entries) {
758
+ if (seenIds.has(entry.id)) continue;
759
+ seenIds.add(entry.id);
760
+ if (entry.historical) continue;
761
+ const key = entry.text.trim();
762
+ liveTextCounts.set(key, (liveTextCounts.get(key) ?? 0) + 1);
763
+ }
764
+ let retired = 0;
765
+ const consume = (entry) => {
766
+ consumedIds.add(entry.id);
767
+ if (!entry.historical) {
768
+ const key = entry.text.trim();
769
+ const remaining = (liveTextCounts.get(key) ?? 0) - 1;
770
+ if (remaining > 0) liveTextCounts.set(key, remaining);
771
+ else liveTextCounts.delete(key);
772
+ }
773
+ };
774
+ const frontierEntry = (row) => {
775
+ if (row.expectedId) {
776
+ const match = entries.find((entry) => entry.id === row.expectedId && !consumedIds.has(entry.id));
777
+ if (match) return match;
778
+ }
779
+ for (const entry of entries) {
780
+ if (entry.historical || consumedIds.has(entry.id)) continue;
781
+ if (entry.text.trim() === row.text.trim() && (liveTextCounts.get(entry.text.trim()) ?? 0) > 0) {
782
+ return { id: entry.id, text: entry.text.trim() };
783
+ }
784
+ }
785
+ return void 0;
786
+ };
787
+ for (let index = dispatched.length - 1; index >= 0; index -= 1) {
788
+ const row = dispatched[index];
789
+ if (!row) continue;
790
+ const confirmed = frontierEntry(row);
791
+ if (!confirmed) continue;
792
+ consume(confirmed);
793
+ dispatched.splice(index, 1);
794
+ retired += 1;
795
+ }
796
+ if (retired > 0) {
797
+ notify(`${retired} queued row${retired === 1 ? "" : "s"} confirmed delivered \u2192 ${targetLabel}`, "info");
798
+ requestRender();
799
+ }
800
+ return retired;
801
+ },
802
+ retireAll(reason) {
803
+ if (disposed) return 0;
804
+ const count = queue.length + dispatched.length;
805
+ queue.clear();
806
+ dispatched.length = 0;
807
+ editSession = void 0;
808
+ if (count > 0) {
809
+ const suffix = reason ? ` (${reason})` : "";
810
+ notify(`Retired ${count} queued row${count === 1 ? "" : "s"} for ${targetLabel}${suffix}`, "info");
811
+ requestRender();
812
+ }
813
+ return count;
814
+ },
815
+ pendingCount() {
816
+ if (disposed) return 0;
817
+ return queue.length + dispatched.length;
818
+ },
819
+ dispose({ retain = false } = {}) {
820
+ if (disposed) return;
821
+ disposed = true;
822
+ editSession = void 0;
823
+ if (retain) {
824
+ return;
825
+ }
826
+ queue.clear();
827
+ dispatched.length = 0;
828
+ if (bridge) emitHandshake("release");
829
+ }
830
+ };
831
+ }
832
+
833
+ // src/ui/conversation-queue-store.ts
834
+ var ConversationQueueStore = class {
835
+ slots = /* @__PURE__ */ new Map();
836
+ attach(options) {
837
+ const existing = this.slots.get(options.targetId);
838
+ if (existing) {
839
+ existing.attached = options;
840
+ return existing.queue;
841
+ }
842
+ const slot = { queue: void 0, attached: options, initialized: false, frontier: 0 };
843
+ const attached = () => slot.attached;
844
+ slot.queue = createConversationQueue({
845
+ ...options,
846
+ send: (text, lane) => {
847
+ const current = attached();
848
+ if (!current) return Promise.reject(new Error("Open this conversation to send its queued messages"));
849
+ return current.send(text, lane);
850
+ },
851
+ editor: {
852
+ getText: () => attached()?.editor?.getText() ?? "",
853
+ setText: (text) => attached()?.editor?.setText(text),
854
+ handleInput: (data) => attached()?.editor?.handleInput?.(data),
855
+ render: (width) => attached()?.editor?.render?.(width) ?? [],
856
+ get paddingX() {
857
+ return attached()?.editor?.paddingX ?? 0;
858
+ }
859
+ },
860
+ isIdle: () => attached()?.isIdle?.() ?? true,
861
+ onNotify: (text, kind) => attached()?.onNotify?.(text, kind),
862
+ requestRender: () => attached()?.requestRender?.()
863
+ });
864
+ this.slots.set(options.targetId, slot);
865
+ return slot.queue;
866
+ }
867
+ get(id) {
868
+ return this.slots.get(id)?.queue;
869
+ }
870
+ detach(id) {
871
+ const slot = this.slots.get(id);
872
+ if (!slot) return;
873
+ slot.queue.cancelEditing();
874
+ slot.attached = void 0;
875
+ }
876
+ sync(id, transcript) {
877
+ const slot = this.slots.get(id);
878
+ if (!slot) return;
879
+ let frontier = slot.frontier;
880
+ const occurrences = /* @__PURE__ */ new Map();
881
+ const entries = [];
882
+ for (const message of transcript.messages) {
883
+ if (Number.isFinite(message.timestamp)) frontier = Math.max(frontier, message.timestamp);
884
+ if (message.role !== "user") continue;
885
+ const raw = typeof message.content === "string" ? message.content : message.content.filter((part) => part.type === "text").map((part) => part.text).join("");
886
+ const text = unwrapActorEnvelopeText(raw) ?? raw;
887
+ let identity;
888
+ if (text !== raw) {
889
+ try {
890
+ const envelope = JSON.parse(raw.trim().slice("Fabric actor message from direct:".length));
891
+ if (typeof envelope.id === "string") identity = envelope.id;
892
+ } catch {
893
+ }
894
+ }
895
+ if (!identity) identity = createHash("sha256").update(JSON.stringify([message.timestamp, message.content])).digest("hex");
896
+ const occurrence = occurrences.get(identity) ?? 0;
897
+ occurrences.set(identity, occurrence + 1);
898
+ entries.push({
899
+ id: occurrence === 0 ? identity : `${identity}:${occurrence}`,
900
+ text,
901
+ historical: !slot.initialized || message.timestamp < slot.frontier
902
+ });
903
+ }
904
+ slot.queue.syncSnapshot(entries);
905
+ slot.queue.syncPending(transcript.pendingMessages);
906
+ slot.frontier = frontier;
907
+ slot.initialized = true;
908
+ }
909
+ clear() {
910
+ for (const slot of this.slots.values()) {
911
+ slot.queue.cancelEditing();
912
+ slot.attached = void 0;
913
+ slot.queue.dispose();
914
+ }
915
+ this.slots.clear();
916
+ }
917
+ };
918
+
919
+ // src/ui/conversation.ts
920
+ var STATE_ENTRY_LIMIT = 128;
921
+ var FabricConversationState = class {
922
+ queues = new ConversationQueueStore();
923
+ selectedId;
924
+ epochCounter = 0;
925
+ entries = /* @__PURE__ */ new Map();
926
+ pendingSends = /* @__PURE__ */ new Set();
927
+ get epoch() {
928
+ return this.epochCounter;
929
+ }
930
+ hasPendingSend(id, message) {
931
+ for (const pending of this.pendingSends) {
932
+ if (pending.id === id && pending.message === message) return true;
933
+ }
934
+ return false;
935
+ }
936
+ addPendingSend(pending) {
937
+ this.pendingSends.add(pending);
938
+ }
939
+ /** Acknowledged: drop the pending marker and clear only the exact accepted draft. */
940
+ resolvePendingSend(id, message) {
941
+ for (const pending of this.pendingSends) {
942
+ if (pending.id !== id || pending.message !== message) continue;
943
+ this.pendingSends.delete(pending);
944
+ const entry = this.entries.get(id);
945
+ if (entry && entry.draft === message) entry.draft = "";
946
+ return;
947
+ }
948
+ }
949
+ /** Rejected: drop the pending marker; the raw draft stays untouched. */
950
+ failPendingSend(id, message) {
951
+ for (const pending of this.pendingSends) {
952
+ if (pending.id !== id || pending.message !== message) continue;
953
+ this.pendingSends.delete(pending);
954
+ return;
955
+ }
956
+ }
957
+ /** Live view state for a target; creates (and may evict empty) entries. */
958
+ view(id) {
959
+ const existing = this.entries.get(id);
960
+ if (existing) {
961
+ this.entries.delete(id);
962
+ this.entries.set(id, existing);
963
+ return existing;
964
+ }
965
+ const created = {
966
+ draft: "",
967
+ following: true,
968
+ scroll: 0,
969
+ pageAnchor: void 0,
970
+ toolsExpanded: false,
971
+ lastSeenUpdatedAt: 0
972
+ };
973
+ this.entries.set(id, created);
974
+ this.enforceLimit();
975
+ return created;
976
+ }
977
+ /** Non-mutating lookup; unread checks must never create or evict drafts. */
978
+ peek(id) {
979
+ return this.entries.get(id);
980
+ }
981
+ clear() {
982
+ this.queues.clear();
983
+ this.entries.clear();
984
+ this.pendingSends.clear();
985
+ this.selectedId = void 0;
986
+ this.epochCounter++;
987
+ }
988
+ enforceLimit() {
989
+ while (this.entries.size > STATE_ENTRY_LIMIT) {
990
+ let evicted = false;
991
+ for (const key of this.entries.keys()) {
992
+ if (key === this.selectedId) continue;
993
+ const entry = this.entries.get(key);
994
+ if (entry && entry.draft === "") {
995
+ this.entries.delete(key);
996
+ evicted = true;
997
+ break;
998
+ }
999
+ }
1000
+ if (!evicted) break;
1001
+ }
1002
+ }
1003
+ };
1004
+ var FEEDBACK_TTL_MS = 8e3;
1005
+ var FOLLOW_UP_FALLBACK = ["alt+enter", "ctrl+q"];
1006
+ var TOOLS_EXPAND_FALLBACK = ["ctrl+o"];
1007
+ var conversationEditorTheme = (theme, thinking) => ({
1008
+ symbols: ompSymbolTheme,
1009
+ borderColor: (value) => {
1010
+ const level = thinking();
1011
+ const color = level === "minimal" ? "thinkingMinimal" : level === "low" ? "thinkingLow" : level === "medium" ? "thinkingMedium" : level === "high" ? "thinkingHigh" : level === "xhigh" ? "thinkingXhigh" : level === "max" ? "thinkingMax" : "borderMuted";
1012
+ return theme.fg(color, value);
1013
+ },
1014
+ selectList: {
1015
+ selectedPrefix: (text) => theme.fg("accent", text),
1016
+ selectedText: (text) => theme.fg("accent", text),
1017
+ description: (text) => theme.fg("muted", text),
1018
+ scrollInfo: (text) => theme.fg("muted", text),
1019
+ noMatch: (text) => theme.fg("muted", text),
1020
+ symbols: ompSymbolTheme
1021
+ }
1022
+ });
1023
+ var errorText2 = (error) => {
1024
+ if (error instanceof Error) return error.message;
1025
+ return String(error ?? "");
1026
+ };
1027
+ var isMainTarget = (target) => target?.kind === "main";
1028
+ var FabricConversationView = class {
1029
+ focusState = true;
1030
+ tui;
1031
+ theme;
1032
+ options;
1033
+ state;
1034
+ renderer;
1035
+ editor;
1036
+ pickerInput;
1037
+ pickerRows = [];
1038
+ pickerSelectedId;
1039
+ mode = "conversation";
1040
+ currentId;
1041
+ feedback;
1042
+ stopConfirmId;
1043
+ disposed = false;
1044
+ lastBodyLength = 0;
1045
+ lastBody = [];
1046
+ lastBodyBudget = 1;
1047
+ editorTop = 0;
1048
+ editorHeight = 0;
1049
+ ownsMouseMode = false;
1050
+ constructor(tui, theme, options) {
1051
+ this.tui = tui;
1052
+ this.theme = theme;
1053
+ this.options = options;
1054
+ this.state = options.state;
1055
+ this.renderer = new FabricConversationTranscriptRenderer(tui, theme, {
1056
+ ...options.rendererOptions,
1057
+ imageWidthCells: options.appearance?.imageWidthCells
1058
+ });
1059
+ this.editor = new Editor(conversationEditorTheme(theme, () => this.currentTarget()?.thinking));
1060
+ this.editor.focused = true;
1061
+ this.editor.onChange = (text) => {
1062
+ if (this.currentId && !this.state.queues.get(this.currentId)?.editingActive) this.state.view(this.currentId).draft = text;
1063
+ };
1064
+ const nonMain = this.nonMainTargets();
1065
+ const requested = options.initialTargetId ?? defaultConversationTarget(nonMain, options.state.selectedId)?.id;
1066
+ const requestedTarget = requested ? this.currentTargets().find((candidate) => candidate.id === requested) : void 0;
1067
+ const resolved = requested && requestedTarget && !isMainTarget(requestedTarget) ? requested : nonMain[0]?.id;
1068
+ if (resolved) this.applySelection(resolved, false);
1069
+ if (!this.currentId) this.currentId = nonMain[0]?.id;
1070
+ if (true) {
1071
+ tui.terminal.write("\x1B[?1000h\x1B[?1006h");
1072
+ this.ownsMouseMode = true;
1073
+ }
1074
+ }
1075
+ get focused() {
1076
+ return this.focusState;
1077
+ }
1078
+ set focused(value) {
1079
+ this.focusState = value;
1080
+ if (this.mode === "picker") {
1081
+ if (this.pickerInput) this.pickerInput.focused = value;
1082
+ if (this.editor) this.editor.focused = false;
1083
+ return;
1084
+ }
1085
+ if (this.editor) this.editor.focused = value;
1086
+ }
1087
+ /** Re-focus a target while the view is open; selecting Main closes to the native session. */
1088
+ selectTarget(id) {
1089
+ this.applySelection(id, true);
1090
+ }
1091
+ handleInput(data) {
1092
+ if (this.disposed) return;
1093
+ const mouse = /^\x1b\[<(\d+);(\d+);(\d+)([Mm])$/.exec(data);
1094
+ if (mouse) {
1095
+ const button = Number(mouse[1]);
1096
+ if ((button & 64) !== 0 && mouse[4] === "M") {
1097
+ this.handleMouse({ button, col: Number(mouse[2]) - 1, row: Number(mouse[3]) - 1, release: false, wheel: (button & 1) === 0 ? -1 : 1, motion: false, leftClick: false });
1098
+ }
1099
+ return;
1100
+ }
1101
+ if (this.mode === "picker") {
1102
+ this.handlePickerInput(data);
1103
+ this.tui.requestRender();
1104
+ return;
1105
+ }
1106
+ this.handleConversationInput(data);
1107
+ this.tui.requestRender();
1108
+ }
1109
+ handleMouse(event) {
1110
+ if (this.disposed) return;
1111
+ if (event.wheel !== null) {
1112
+ if (this.mode === "picker") this.movePickerSelection(event.wheel);
1113
+ else this.scrollBy(event.wheel * 3);
1114
+ this.tui.requestRender();
1115
+ }
1116
+ }
1117
+ render(width) {
1118
+ if (this.disposed || width <= 0) return [];
1119
+ const rows = Math.max(1, this.terminalRows());
1120
+ this.markCurrentTargetSeen();
1121
+ this.reconcileEditor();
1122
+ const target = this.currentTarget();
1123
+ const queue = this.mode === "conversation" ? this.currentQueue() : void 0;
1124
+ const transcriptLines = this.mode === "conversation" ? this.transcriptLines(width) : [];
1125
+ let queueLines = queue?.render(width) ?? [];
1126
+ let editorLines = this.mode === "conversation" && !(queue?.editingActive && queue.mode === "extension") ? this.renderEditorLines(width) : [];
1127
+ const editorBudget = Math.min(editorLines.length, Math.max(1, rows - (rows >= 6 ? 3 : 0)));
1128
+ if (editorLines.length > editorBudget) {
1129
+ const cursor = Math.max(0, editorLines.findIndex((line) => line.includes(CURSOR_MARKER)));
1130
+ const start = Math.max(0, Math.min(cursor - Math.floor(editorBudget / 2), editorLines.length - editorBudget));
1131
+ editorLines = editorLines.slice(start, start + editorBudget);
1132
+ }
1133
+ let remaining = rows - editorLines.length;
1134
+ const footer = this.mode === "conversation" ? conversationFooter(target, this.theme, width).slice(0, Math.max(0, remaining - 1)) : [];
1135
+ remaining -= footer.length;
1136
+ const head = [];
1137
+ if (remaining > 0) {
1138
+ head.push(this.breadcrumbLine(width));
1139
+ remaining--;
1140
+ }
1141
+ if (target?.readOnlyReason && remaining > 1) {
1142
+ head.push(this.statusLine(width));
1143
+ remaining--;
1144
+ }
1145
+ const feedback = this.currentFeedbackLine(width);
1146
+ if (feedback !== void 0 && remaining > 1) {
1147
+ head.push(feedback);
1148
+ remaining--;
1149
+ }
1150
+ const hints = this.mode === "conversation" && remaining > 2 ? [this.hintsLine(width)] : [];
1151
+ remaining -= hints.length;
1152
+ const queueBudget = Math.max(0, remaining - 1);
1153
+ if (queueLines.length > queueBudget) {
1154
+ const cursor = queueLines.findIndex((line) => line.includes(CURSOR_MARKER));
1155
+ const start = Math.max(0, Math.min(cursor < 0 ? 0 : cursor - Math.floor(queueBudget / 2), queueLines.length - queueBudget));
1156
+ queueLines = queueLines.slice(start, start + queueBudget);
1157
+ }
1158
+ remaining -= queueLines.length;
1159
+ this.editorTop = rows - editorLines.length - footer.length - hints.length;
1160
+ this.editorHeight = editorLines.length;
1161
+ const body = remaining <= 0 ? [] : this.mode === "picker" ? this.pickerLines(width, remaining) : this.windowBody(transcriptLines, remaining);
1162
+ while (body.length < remaining) body.push("");
1163
+ return [...head, ...body.slice(0, remaining), ...queueLines, ...editorLines, ...footer, ...hints].slice(0, rows).map((line) => visibleWidth(line) <= width ? line : truncateToWidth2(line, width, ""));
1164
+ }
1165
+ invalidate() {
1166
+ this.renderer.invalidate();
1167
+ this.editor?.invalidate();
1168
+ this.pickerInput?.invalidate();
1169
+ }
1170
+ dispose() {
1171
+ if (this.currentId) this.state.queues.detach(this.currentId);
1172
+ this.disposed = true;
1173
+ this.editor = void 0;
1174
+ this.pickerInput = void 0;
1175
+ this.renderer.dispose();
1176
+ if (this.ownsMouseMode) {
1177
+ this.ownsMouseMode = false;
1178
+ this.tui.terminal.write("\x1B[?1000l\x1B[?1006l");
1179
+ }
1180
+ }
1181
+ /** Keep the editor in sync with the shared session draft (e.g. after an ack
1182
+ * that landed while a previous view instance was disposed). */
1183
+ reconcileEditor() {
1184
+ if (this.mode !== "conversation" || !this.editor || !this.currentId) return;
1185
+ if (this.state.queues.get(this.currentId)?.editingActive) return;
1186
+ if (this.state.hasPendingSend(this.currentId, this.editor.getText())) return;
1187
+ const draft = this.state.view(this.currentId).draft;
1188
+ if (this.editor.getText() !== draft) this.editor.setText(draft);
1189
+ }
1190
+ applySelection(id, requestRender) {
1191
+ if (this.currentId && this.currentId !== id) this.state.queues.detach(this.currentId);
1192
+ const target = this.currentTargets().find((candidate) => candidate.id === id);
1193
+ if (!target) {
1194
+ this.feedback = {
1195
+ text: `Unknown target ${safeText(id)}`,
1196
+ kind: "error",
1197
+ at: Date.now()
1198
+ };
1199
+ if (requestRender) this.tui.requestRender();
1200
+ return;
1201
+ }
1202
+ if (isMainTarget(target)) {
1203
+ this.options.close();
1204
+ return;
1205
+ }
1206
+ this.currentId = id;
1207
+ this.state.selectedId = id;
1208
+ const entry = this.state.view(id);
1209
+ entry.lastSeenUpdatedAt = target.updatedAt ?? Date.now();
1210
+ this.stopConfirmId = void 0;
1211
+ this.closePicker();
1212
+ this.feedback = void 0;
1213
+ this.editor?.setText(entry.draft);
1214
+ if (requestRender) this.tui.requestRender();
1215
+ }
1216
+ markCurrentTargetSeen() {
1217
+ if (!this.currentId) return;
1218
+ const target = this.targetById(this.currentId);
1219
+ if (!target?.updatedAt) return;
1220
+ const entry = this.state.view(this.currentId);
1221
+ if (entry.lastSeenUpdatedAt < target.updatedAt) entry.lastSeenUpdatedAt = target.updatedAt;
1222
+ }
1223
+ currentTargets() {
1224
+ return this.options.targets();
1225
+ }
1226
+ nonMainTargets() {
1227
+ return this.currentTargets().filter((target) => !isMainTarget(target));
1228
+ }
1229
+ currentTarget() {
1230
+ return this.currentTargets().find((target) => target.id === this.currentId);
1231
+ }
1232
+ mainTarget() {
1233
+ return this.currentTargets().find((target) => isMainTarget(target));
1234
+ }
1235
+ targetById(id) {
1236
+ return this.currentTargets().find((target) => target.id === id);
1237
+ }
1238
+ terminalRows() {
1239
+ return this.tui.terminal?.rows ?? process.stdout.rows ?? 28;
1240
+ }
1241
+ /**
1242
+ * Respects a configured binding; when an injected manager reports no keys
1243
+ * the binding is unbound (never falls back), and only the default global
1244
+ * manager (no injection) falls back to hard-coded keys.
1245
+ */
1246
+ bindingMatches(data, binding, fallbackKeys) {
1247
+ if (this.options.keybindings) {
1248
+ const keys2 = this.options.keybindings.getKeys(binding);
1249
+ return keys2.length > 0 && this.options.keybindings.matches(data, binding);
1250
+ }
1251
+ const global = getKeybindings2();
1252
+ const keys = global.getKeys(binding);
1253
+ if (keys.length > 0) return global.matches(data, binding);
1254
+ return fallbackKeys.some((key) => matchesKey2(data, key));
1255
+ }
1256
+ bindingHint(binding, fallbackLabel) {
1257
+ const manager = this.options.keybindings ?? getKeybindings2();
1258
+ const keys = manager.getKeys(binding);
1259
+ if (keys.length > 0) return keys.join("/");
1260
+ return this.options.keybindings ? "unbound" : fallbackLabel;
1261
+ }
1262
+ handleConversationInput(data) {
1263
+ const editor = this.editor;
1264
+ if (!editor) return;
1265
+ this.feedback = void 0;
1266
+ if (this.stopConfirmId === void 0 && this.currentQueue()?.handleInput(data)) return;
1267
+ if (this.stopConfirmId !== void 0) {
1268
+ if (matchesKey2(data, Key2.enter)) {
1269
+ const target = this.targetById(this.stopConfirmId);
1270
+ this.stopConfirmId = void 0;
1271
+ if (target) this.dispatchStop(target);
1272
+ return;
1273
+ }
1274
+ if (matchesKey2(data, Key2.escape)) {
1275
+ this.stopConfirmId = void 0;
1276
+ this.feedback = { text: "Stop cancelled", kind: "info", at: Date.now() };
1277
+ return;
1278
+ }
1279
+ this.stopConfirmId = void 0;
1280
+ }
1281
+ if (this.bindingMatches(data, "app.message.followUp", FOLLOW_UP_FALLBACK)) {
1282
+ this.submit("followUp");
1283
+ return;
1284
+ }
1285
+ if (matchesKey2(data, Key2.enter)) {
1286
+ this.submit("steer");
1287
+ return;
1288
+ }
1289
+ if (matchesKey2(data, Key2.ctrl("c"))) {
1290
+ if (editor.getText().length > 0) editor.setText("");
1291
+ return;
1292
+ }
1293
+ if (matchesKey2(data, Key2.escape)) {
1294
+ this.options.close();
1295
+ return;
1296
+ }
1297
+ if (matchesKey2(data, Key2.ctrl("n"))) {
1298
+ this.openPicker();
1299
+ return;
1300
+ }
1301
+ if (matchesKey2(data, "ctrl+tab")) {
1302
+ this.cycleTarget(1);
1303
+ return;
1304
+ }
1305
+ if (matchesKey2(data, "shift+ctrl+tab")) {
1306
+ this.cycleTarget(-1);
1307
+ return;
1308
+ }
1309
+ if (matchesKey2(data, "ctrl+shift+left")) {
1310
+ this.navigateParent();
1311
+ return;
1312
+ }
1313
+ if (matchesKey2(data, "ctrl+shift+right")) {
1314
+ this.navigateFirstChild();
1315
+ return;
1316
+ }
1317
+ if (matchesKey2(data, "alt+left") && editor.getText().length === 0) {
1318
+ this.navigateParent();
1319
+ return;
1320
+ }
1321
+ if (matchesKey2(data, "alt+right") && editor.getText().length === 0) {
1322
+ this.navigateFirstChild();
1323
+ return;
1324
+ }
1325
+ const injectedKeys = this.options.keybindings;
1326
+ const globalKeys = getKeybindings2();
1327
+ const matchesViewport = (data2, action) => (injectedKeys ? injectedKeys.matches(data2, action) : false) || globalKeys.matches(data2, action);
1328
+ if (matchesViewport(data, "tui.editor.jumpBackward")) {
1329
+ this.scrollPrompt(-1);
1330
+ return;
1331
+ }
1332
+ if (matchesViewport(data, "tui.editor.jumpForward")) {
1333
+ this.scrollPrompt(1);
1334
+ return;
1335
+ }
1336
+ if (matchesViewport(data, "tui.editor.cursorUp")) {
1337
+ this.scrollBy(-1);
1338
+ return;
1339
+ }
1340
+ if (matchesViewport(data, "tui.editor.cursorDown")) {
1341
+ this.scrollBy(1);
1342
+ return;
1343
+ }
1344
+ if (matchesViewport(data, "tui.editor.pageUp")) {
1345
+ this.scrollBy(-Math.max(1, this.lastBodyBudget - 2));
1346
+ return;
1347
+ }
1348
+ if (matchesViewport(data, "tui.editor.pageDown")) {
1349
+ this.scrollBy(Math.max(1, this.lastBodyBudget - 2));
1350
+ return;
1351
+ }
1352
+ if (matchesViewport(data, "tui.editor.cursorWordLeft")) {
1353
+ this.scrollBy(-Math.max(1, Math.floor(this.lastBodyBudget / 2)));
1354
+ return;
1355
+ }
1356
+ if (matchesViewport(data, "tui.editor.cursorWordRight")) {
1357
+ this.scrollBy(Math.max(1, Math.floor(this.lastBodyBudget / 2)));
1358
+ return;
1359
+ }
1360
+ if (matchesViewport(data, "tui.editor.cursorLineStart")) {
1361
+ this.scrollToTop();
1362
+ return;
1363
+ }
1364
+ if (matchesViewport(data, "tui.editor.cursorLineEnd")) {
1365
+ this.followLatest();
1366
+ return;
1367
+ }
1368
+ if (this.bindingMatches(data, "app.thinking.toggle", ["ctrl+t"])) {
1369
+ if (this.currentId) {
1370
+ const entry = this.state.view(this.currentId);
1371
+ entry.hideThinking = !(entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false);
1372
+ }
1373
+ return;
1374
+ }
1375
+ if (this.bindingMatches(data, "app.tools.expand", TOOLS_EXPAND_FALLBACK)) {
1376
+ if (this.currentId) {
1377
+ const entry = this.state.view(this.currentId);
1378
+ entry.toolsExpanded = !entry.toolsExpanded;
1379
+ }
1380
+ return;
1381
+ }
1382
+ editor.handleInput(data);
1383
+ }
1384
+ submit(delivery) {
1385
+ const editor = this.editor;
1386
+ const target = this.currentTarget();
1387
+ if (!editor || !target || isMainTarget(target)) return;
1388
+ const raw = editor.getText();
1389
+ if (!raw.trim()) return;
1390
+ if (raw.trim() === "/back") {
1391
+ this.options.close();
1392
+ return;
1393
+ }
1394
+ if (raw.trim() === "/agents") {
1395
+ this.openPicker();
1396
+ return;
1397
+ }
1398
+ if (raw.trim() === "/stop") {
1399
+ if (!target.canStop) {
1400
+ this.feedback = {
1401
+ text: safeText(
1402
+ `Stop unavailable for ${target.name}: the selected target cannot be stopped from here.`
1403
+ ),
1404
+ kind: "error",
1405
+ at: Date.now()
1406
+ };
1407
+ return;
1408
+ }
1409
+ this.stopConfirmId = target.id;
1410
+ this.feedback = {
1411
+ text: safeText(`Press enter again to stop ${target.name} \xB7 esc cancels`),
1412
+ kind: "info",
1413
+ at: Date.now()
1414
+ };
1415
+ return;
1416
+ }
1417
+ if (raw.trim().startsWith("/") || raw.trim().startsWith("!")) {
1418
+ this.feedback = {
1419
+ text: safeText(
1420
+ `Unsupported command "${raw.trim()}" is not forwarded from this view. Supported: /stop /back /agents.`
1421
+ ),
1422
+ kind: "error",
1423
+ at: Date.now()
1424
+ };
1425
+ return;
1426
+ }
1427
+ if (target.readOnlyReason) {
1428
+ this.feedback = {
1429
+ text: safeText(`${target.name} is read-only: ${target.readOnlyReason}`),
1430
+ kind: "error",
1431
+ at: Date.now()
1432
+ };
1433
+ return;
1434
+ }
1435
+ if (delivery === "steer" && !target.canSteer) {
1436
+ this.feedback = {
1437
+ text: safeText(`${target.name} does not accept steering messages right now.`),
1438
+ kind: "error",
1439
+ at: Date.now()
1440
+ };
1441
+ return;
1442
+ }
1443
+ if (delivery === "followUp" && !target.canFollowUp) {
1444
+ this.feedback = {
1445
+ text: safeText(`${target.name} does not accept follow-up messages right now.`),
1446
+ kind: "error",
1447
+ at: Date.now()
1448
+ };
1449
+ return;
1450
+ }
1451
+ const queue = this.currentQueue();
1452
+ if (!queue) return;
1453
+ this.state.queues.sync(target.id, this.options.transcript(target.id, true));
1454
+ if (queue.mode === "extension" && delivery === "followUp" && !isActiveStatus(target.status)) {
1455
+ const parked = queue.park(raw, delivery);
1456
+ if (parked.ok) {
1457
+ this.state.view(target.id).draft = "";
1458
+ editor.setText("");
1459
+ }
1460
+ return;
1461
+ }
1462
+ if (this.state.hasPendingSend(target.id, raw)) return;
1463
+ const pending = { id: target.id, message: raw, delivery };
1464
+ this.state.addPendingSend(pending);
1465
+ const epoch = this.state.epoch;
1466
+ this.feedback = {
1467
+ text: safeText(`Sending ${delivery} \u2192 ${target.name}\u2026`),
1468
+ kind: "info",
1469
+ at: Date.now()
1470
+ };
1471
+ void Promise.resolve().then(() => queue.dispatch(raw, delivery)).then(() => {
1472
+ if (this.state.epoch !== epoch) return;
1473
+ this.state.resolvePendingSend(target.id, raw);
1474
+ if (this.disposed) return;
1475
+ if (this.currentId === target.id && this.editor?.getText() === raw) {
1476
+ this.editor.setText("");
1477
+ }
1478
+ this.feedback = {
1479
+ text: safeText(`Queued ${delivery} \u2192 ${target.name}`),
1480
+ kind: "info",
1481
+ at: Date.now()
1482
+ };
1483
+ this.tui.requestRender();
1484
+ }).catch((error) => {
1485
+ if (this.state.epoch !== epoch) return;
1486
+ this.state.failPendingSend(target.id, raw);
1487
+ if (this.disposed) return;
1488
+ this.feedback = {
1489
+ text: safeText(
1490
+ `Send failed for ${target.name} (${delivery}): ${errorText2(error)}`
1491
+ ),
1492
+ kind: "error",
1493
+ at: Date.now()
1494
+ };
1495
+ this.tui.requestRender();
1496
+ });
1497
+ }
1498
+ dispatchStop(target) {
1499
+ const epoch = this.state.epoch;
1500
+ this.feedback = {
1501
+ text: safeText(`Stopping ${target.name}\u2026`),
1502
+ kind: "info",
1503
+ at: Date.now()
1504
+ };
1505
+ void Promise.resolve().then(() => this.options.stop(target.id)).then(() => {
1506
+ if (this.disposed || epoch !== this.state.epoch) return;
1507
+ this.feedback = {
1508
+ text: safeText(`Stop requested for ${target.name}`),
1509
+ kind: "info",
1510
+ at: Date.now()
1511
+ };
1512
+ this.tui.requestRender();
1513
+ }).catch((error) => {
1514
+ if (this.disposed || epoch !== this.state.epoch) return;
1515
+ this.feedback = {
1516
+ text: safeText(`Stop failed for ${target.name}: ${errorText2(error)}`),
1517
+ kind: "error",
1518
+ at: Date.now()
1519
+ };
1520
+ this.tui.requestRender();
1521
+ });
1522
+ }
1523
+ navigateParent() {
1524
+ const target = this.currentTarget();
1525
+ if (!target) return;
1526
+ const parent = target.parentId ? this.targetById(target.parentId) : void 0;
1527
+ if (parent && !isMainTarget(parent)) {
1528
+ this.applySelection(parent.id, true);
1529
+ return;
1530
+ }
1531
+ this.options.close();
1532
+ }
1533
+ navigateFirstChild() {
1534
+ const target = this.currentTarget();
1535
+ if (!target) return;
1536
+ const child = this.currentTargets().find((candidate) => candidate.parentId === target.id);
1537
+ if (child && !isMainTarget(child)) this.applySelection(child.id, true);
1538
+ }
1539
+ cycleTarget(direction) {
1540
+ const targets = this.nonMainTargets();
1541
+ if (targets.length === 0) return;
1542
+ const index = targets.findIndex((target) => target.id === this.currentId);
1543
+ const nextIndex = index < 0 ? 0 : (index + direction + targets.length) % targets.length;
1544
+ const next = targets[nextIndex];
1545
+ if (next) this.applySelection(next.id, true);
1546
+ }
1547
+ scrollBy(delta) {
1548
+ if (!this.currentId || !Number.isFinite(delta) || delta === 0) return;
1549
+ const entry = this.state.view(this.currentId);
1550
+ const maxScroll = Math.max(0, this.lastBodyLength - this.lastBodyBudget);
1551
+ const position = entry.following ? maxScroll : entry.scroll;
1552
+ const next = position + Math.trunc(delta);
1553
+ entry.following = false;
1554
+ if (next < 0 && this.options.loadOlder(this.currentId)) {
1555
+ entry.pageAnchor = "prepend";
1556
+ entry.anchorLength = this.lastBodyLength;
1557
+ entry.scroll = next;
1558
+ return;
1559
+ }
1560
+ if (next > maxScroll && this.options.loadNewer(this.currentId)) {
1561
+ entry.scroll = next;
1562
+ return;
1563
+ }
1564
+ entry.scroll = Math.max(0, Math.min(next, maxScroll));
1565
+ if (delta > 0 && entry.scroll === maxScroll) entry.following = true;
1566
+ }
1567
+ scrollPrompt(direction) {
1568
+ if (!this.currentId) return;
1569
+ const entry = this.state.view(this.currentId);
1570
+ const position = entry.following ? Math.max(0, this.lastBodyLength - this.lastBodyBudget) : entry.scroll;
1571
+ const prompts = this.lastBody.flatMap((line, index) => line.includes("\x1B]133;A") ? [index] : []);
1572
+ const target = direction < 0 ? prompts.filter((row) => row < position).at(-1) : prompts.find((row) => row > position);
1573
+ this.scrollBy(target === void 0 ? direction * Math.max(1, this.lastBodyBudget) : target - position);
1574
+ }
1575
+ scrollToTop() {
1576
+ if (!this.currentId) return;
1577
+ const entry = this.state.view(this.currentId);
1578
+ entry.following = false;
1579
+ entry.scroll = 0;
1580
+ if (this.options.loadOlder(this.currentId)) entry.pageAnchor = "start";
1581
+ }
1582
+ followLatest() {
1583
+ if (!this.currentId) return;
1584
+ this.options.loadLatest(this.currentId);
1585
+ const entry = this.state.view(this.currentId);
1586
+ entry.following = true;
1587
+ entry.pageAnchor = void 0;
1588
+ entry.anchorLength = void 0;
1589
+ }
1590
+ openPicker() {
1591
+ this.mode = "picker";
1592
+ this.pickerInput = new Input();
1593
+ this.pickerInput.focused = this.focusState;
1594
+ this.pickerInput.onSubmit = () => this.pickSelected();
1595
+ if (this.editor) this.editor.focused = false;
1596
+ this.pickerSelectedId = this.currentId ?? this.nonMainTargets()[0]?.id;
1597
+ this.refreshPicker();
1598
+ }
1599
+ closePicker() {
1600
+ this.mode = "conversation";
1601
+ this.pickerInput = void 0;
1602
+ this.pickerRows = [];
1603
+ this.pickerSelectedId = void 0;
1604
+ if (this.editor) this.editor.focused = this.focusState;
1605
+ }
1606
+ refreshPicker() {
1607
+ const search = this.pickerInput?.getValue() ?? "";
1608
+ const rows = [];
1609
+ const targets = this.currentTargets();
1610
+ const byId = new Map(targets.map((target) => [target.id, target]));
1611
+ const roots = targets.filter(
1612
+ (target) => !target.parentId || !byId.has(target.parentId)
1613
+ );
1614
+ roots.sort(
1615
+ (left, right) => Number(isMainTarget(right)) - Number(isMainTarget(left))
1616
+ );
1617
+ const visited = /* @__PURE__ */ new Set();
1618
+ const pushTree = (target, depth) => {
1619
+ if (visited.has(target.id)) return;
1620
+ visited.add(target.id);
1621
+ rows.push({ target, depth });
1622
+ for (const child of targets) {
1623
+ if (child.parentId === target.id) pushTree(child, depth + 1);
1624
+ }
1625
+ };
1626
+ for (const root of roots) pushTree(root, 0);
1627
+ for (const orphan of targets) {
1628
+ if (!visited.has(orphan.id)) rows.push({ target: orphan, depth: 0 });
1629
+ }
1630
+ const filtered = search.trim() ? fuzzyFilter(rows, search, (row) => `${row.target.kind} ${row.target.name} ${row.target.id}`) : rows;
1631
+ this.pickerRows = filtered;
1632
+ if (!filtered.some((row) => row.target.id === this.pickerSelectedId)) {
1633
+ this.pickerSelectedId = filtered[0]?.target.id;
1634
+ }
1635
+ }
1636
+ pickerSelectedIndex() {
1637
+ const index = this.pickerRows.findIndex((row) => row.target.id === this.pickerSelectedId);
1638
+ return index >= 0 ? index : 0;
1639
+ }
1640
+ movePickerSelection(direction) {
1641
+ if (this.pickerRows.length === 0) return;
1642
+ const index = this.pickerSelectedIndex();
1643
+ const next = (index + direction + this.pickerRows.length) % this.pickerRows.length;
1644
+ this.pickerSelectedId = this.pickerRows[next]?.target.id;
1645
+ }
1646
+ pickSelected() {
1647
+ const row = this.pickerRows.find((candidate) => candidate.target.id === this.pickerSelectedId) ?? this.pickerRows[0];
1648
+ if (!row) {
1649
+ this.closePicker();
1650
+ return;
1651
+ }
1652
+ if (isMainTarget(row.target)) {
1653
+ this.options.close();
1654
+ return;
1655
+ }
1656
+ this.applySelection(row.target.id, true);
1657
+ }
1658
+ handlePickerInput(data) {
1659
+ const input = this.pickerInput;
1660
+ if (!input) {
1661
+ this.closePicker();
1662
+ return;
1663
+ }
1664
+ if (matchesKey2(data, Key2.escape)) {
1665
+ this.closePicker();
1666
+ return;
1667
+ }
1668
+ if (matchesKey2(data, Key2.up)) {
1669
+ this.movePickerSelection(-1);
1670
+ return;
1671
+ }
1672
+ if (matchesKey2(data, Key2.down)) {
1673
+ this.movePickerSelection(1);
1674
+ return;
1675
+ }
1676
+ if (matchesKey2(data, Key2.enter)) {
1677
+ this.pickSelected();
1678
+ return;
1679
+ }
1680
+ input.handleInput(data);
1681
+ this.refreshPicker();
1682
+ }
1683
+ isUnread(target) {
1684
+ if (target.updatedAt === void 0 || target.id === this.currentId) return false;
1685
+ const seen = this.state.peek(target.id)?.lastSeenUpdatedAt ?? 0;
1686
+ return target.updatedAt > seen;
1687
+ }
1688
+ breadcrumbLine(width) {
1689
+ const chain = [];
1690
+ let cursor = this.currentTarget();
1691
+ const guard = /* @__PURE__ */ new Set();
1692
+ while (cursor && !guard.has(cursor.id)) {
1693
+ guard.add(cursor.id);
1694
+ chain.unshift(cursor);
1695
+ cursor = cursor.parentId ? this.targetById(cursor.parentId) : void 0;
1696
+ }
1697
+ if (chain.length === 0) {
1698
+ const main = this.mainTarget();
1699
+ if (main) chain.push(main);
1700
+ }
1701
+ if (chain.length === 0) return truncateToWidth2(this.theme.fg("dim", "Fabric"), width, "");
1702
+ const last = chain[chain.length - 1];
1703
+ const parts = chain.map((target, index) => {
1704
+ const isCurrent = target.id === this.currentId;
1705
+ const name = isMainTarget(target) ? "Main" : safeText(target.name) || target.id;
1706
+ const styled = isCurrent ? this.theme.fg("accent", name) : this.theme.fg("muted", name);
1707
+ return last && index === chain.length - 1 && this.isUnread(last) ? `${styled} \u25CF` : styled;
1708
+ });
1709
+ return truncateToWidth2(parts.join(this.theme.fg("dim", " > ")), width, "");
1710
+ }
1711
+ statusLine(width) {
1712
+ const target = this.currentTarget();
1713
+ if (!target) return "";
1714
+ const parts = [
1715
+ this.theme.fg("muted", target.kind),
1716
+ colorizeStatus(this.theme, target.status)
1717
+ ];
1718
+ if (target.runner) parts.push(this.theme.fg("muted", safeText(target.runner)));
1719
+ if (target.model) parts.push(this.theme.fg("muted", safeText(target.model)));
1720
+ if (target.thinking) parts.push(this.theme.fg("muted", `thinking:${safeText(target.thinking)}`));
1721
+ if (target.readOnlyReason) {
1722
+ parts.push(this.theme.fg("warning", safeText(`read-only: ${target.readOnlyReason}`)));
1723
+ }
1724
+ return truncateToWidth2(parts.join(this.theme.fg("dim", " \xB7 ")), width, "");
1725
+ }
1726
+ currentFeedbackLine(width) {
1727
+ if (this.mode === "picker") return void 0;
1728
+ if (!this.feedback) return void 0;
1729
+ if (Date.now() - this.feedback.at > FEEDBACK_TTL_MS) return void 0;
1730
+ const color = this.feedback.kind === "error" ? "error" : "accent";
1731
+ return truncateToWidth2(this.theme.fg(color, this.feedback.text), width, "");
1732
+ }
1733
+ hintsLine(width) {
1734
+ const followUpKeys = this.bindingHint("app.message.followUp", "alt+enter");
1735
+ const toolsKeys = this.bindingHint("app.tools.expand", "ctrl+o");
1736
+ const hints = this.stopConfirmId !== void 0 ? [this.theme.fg("warning", safeText("enter confirms stop \xB7 esc cancels"))] : [
1737
+ this.theme.fg("dim", "enter"),
1738
+ "steer",
1739
+ this.theme.fg("dim", followUpKeys),
1740
+ "follow-up",
1741
+ this.theme.fg("dim", "ctrl+n"),
1742
+ "targets",
1743
+ this.theme.fg("dim", "pgup/pgdn"),
1744
+ "scroll",
1745
+ this.theme.fg("dim", "esc"),
1746
+ "close"
1747
+ ];
1748
+ const full = [...hints, this.theme.fg("dim", toolsKeys), "tools"].join(" ");
1749
+ return truncateToWidth2(full, width, "");
1750
+ }
1751
+ renderEditorLines(innerWidth) {
1752
+ const editor = this.editor;
1753
+ if (!editor) return [];
1754
+ return [...editor.render(innerWidth)];
1755
+ }
1756
+ currentQueue() {
1757
+ const target = this.currentTarget();
1758
+ if (!target || target.kind === "main" || !this.editor || this.disposed) return void 0;
1759
+ return this.state.queues.attach({
1760
+ targetId: target.id,
1761
+ targetName: target.name,
1762
+ ompEvents: this.options.queueEvents ?? { emit() {
1763
+ } },
1764
+ theme: this.theme,
1765
+ send: (message, delivery) => this.options.send(target.id, message, delivery),
1766
+ editor: {
1767
+ getText: () => this.editor?.getText() ?? "",
1768
+ setText: (text) => this.editor?.setText(text),
1769
+ handleInput: (data) => this.editor?.handleInput(data),
1770
+ render: (width) => [...this.editor?.render(width) ?? []],
1771
+ paddingX: this.options.appearance?.editorPaddingX ?? 0
1772
+ },
1773
+ ...this.options.keybindings ? { keybindings: this.options.keybindings } : {},
1774
+ isIdle: () => !isActiveStatus(this.targetById(target.id)?.status ?? "stopped"),
1775
+ onNotify: (text, kind) => {
1776
+ if (kind === "error" && !this.disposed && this.currentId === target.id) this.feedback = { text: safeText(text), kind, at: Date.now() };
1777
+ },
1778
+ requestRender: () => {
1779
+ if (!this.disposed && this.currentId === target.id) this.tui.requestRender();
1780
+ }
1781
+ });
1782
+ }
1783
+ transcriptLines(innerWidth) {
1784
+ const target = this.currentTarget();
1785
+ if (!target || !this.currentId) return [this.theme.fg("dim", "No target selected.")];
1786
+ const entry = this.state.view(this.currentId);
1787
+ const transcript = this.options.transcript(this.currentId, entry.following);
1788
+ this.state.queues.sync(this.currentId, transcript);
1789
+ return this.renderer.render(transcript, innerWidth, {
1790
+ target,
1791
+ toolsExpanded: entry.toolsExpanded,
1792
+ hideThinking: entry.hideThinking ?? this.options.appearance?.hideThinkingBlock ?? false,
1793
+ showImages: this.options.appearance?.showImages ?? true,
1794
+ outputPad: this.options.appearance?.outputPad ?? 1,
1795
+ ...this.options.appearance?.codeBlockIndent !== void 0 ? { codeBlockIndent: this.options.appearance.codeBlockIndent } : {},
1796
+ codePreviewSettings: this.options.codePreviewSettings
1797
+ });
1798
+ }
1799
+ windowBody(body, budget) {
1800
+ this.lastBodyLength = body.length;
1801
+ this.lastBody = body;
1802
+ this.lastBodyBudget = budget;
1803
+ const entry = this.currentId ? this.state.view(this.currentId) : void 0;
1804
+ if (!entry) return body.slice(0, Math.max(0, budget));
1805
+ const maxScroll = Math.max(0, body.length - budget);
1806
+ if (entry.following) {
1807
+ entry.scroll = maxScroll;
1808
+ } else if (entry.pageAnchor) {
1809
+ entry.scroll = entry.pageAnchor === "prepend" ? entry.scroll + Math.max(0, body.length - (entry.anchorLength ?? body.length)) : entry.pageAnchor === "end" ? maxScroll : 0;
1810
+ entry.pageAnchor = void 0;
1811
+ entry.anchorLength = void 0;
1812
+ }
1813
+ entry.scroll = Math.max(0, Math.min(entry.scroll, maxScroll));
1814
+ return body.slice(entry.scroll, entry.scroll + budget);
1815
+ }
1816
+ pickerLines(innerWidth, budget) {
1817
+ this.refreshPicker();
1818
+ const lines = [this.theme.fg("accent", "Targets \xB7 enter select \xB7 esc cancel")];
1819
+ const input = this.pickerInput;
1820
+ if (input) {
1821
+ for (const line of input.render(innerWidth)) lines.push(line);
1822
+ }
1823
+ const rows = this.pickerRows;
1824
+ const selectedIndex = this.pickerSelectedIndex();
1825
+ const listBudget = Math.max(1, budget - lines.length - 1);
1826
+ const startIndex = Math.max(
1827
+ 0,
1828
+ Math.min(selectedIndex - Math.floor(listBudget / 2), rows.length - listBudget)
1829
+ );
1830
+ const endIndex = Math.min(startIndex + listBudget, rows.length);
1831
+ if (rows.length === 0) lines.push(this.theme.fg("muted", " no matching targets"));
1832
+ for (let i = startIndex; i < endIndex; i++) {
1833
+ const row = rows[i];
1834
+ if (!row) continue;
1835
+ const selected = row.target.id === this.pickerSelectedId;
1836
+ const indent = " ".repeat(row.depth + 1);
1837
+ const marker = selected ? this.theme.fg("accent", "\u2192 ") : " ";
1838
+ const unread = this.isUnread(row.target) ? this.theme.fg("accent", " \u25CF") : "";
1839
+ const label = isMainTarget(row.target) ? "Main (native session)" : `${safeText(row.target.name)} ${this.theme.fg("muted", `(${row.target.kind} \xB7 ${row.target.status})`)}`;
1840
+ lines.push(
1841
+ truncateToWidth2(
1842
+ `${indent}${marker}${selected ? this.theme.fg("accent", label) : label}${unread}`,
1843
+ innerWidth,
1844
+ ""
1845
+ )
1846
+ );
1847
+ }
1848
+ if (rows.length > listBudget) {
1849
+ lines.push(this.theme.fg("muted", ` (${selectedIndex + 1}/${rows.length})`));
1850
+ }
1851
+ return lines.slice(0, budget);
1852
+ }
1853
+ };
1854
+ var colorizeStatus = (theme, status) => {
1855
+ if (status === "completed" || status === "done") return theme.fg("success", status);
1856
+ if (status === "failed" || status === "error" || status === "timed_out") {
1857
+ return theme.fg("error", status);
1858
+ }
1859
+ if (status === "running" || status === "in_progress" || status === "active") {
1860
+ return theme.fg("accent", status);
1861
+ }
1862
+ return theme.fg("muted", status);
1863
+ };
1864
+ export {
1865
+ FabricConversationState,
1866
+ FabricConversationView
1867
+ };
1868
+ //# sourceMappingURL=conversation.js.map