@kabmo-labs/kabmo 0.42.0 → 0.42.2

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 (195) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +592 -593
  3. package/dist/client/static/js/{CsvGrid-20k047ht.js → CsvGrid-g6rek8y9.js} +1 -1
  4. package/dist/client/static/js/{DocxView-qpvhfcmg.js → DocxView-41t9ryws.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-178skky8.js → DrawioView-mfxhfz1h.js} +1 -1
  6. package/dist/client/static/js/{ImageView-460th5qa.js → ImageView-bxqw3t4k.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-5cv0dty8.js → LayoutWrapper-zt14rv9m.js} +2 -2
  8. package/dist/client/static/js/{Modal-wks6p4r5.js → Modal-cm35g20x.js} +10 -10
  9. package/dist/client/static/js/{PdfView-y51g03nr.js → PdfView-bek8k888.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-rsmvn7ks.js → SessionsView-gn53zyn7.js} +1 -1
  11. package/dist/client/static/js/{SheetView-z7yvb05v.js → SheetView-vezssf6b.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-yehgzhem.js → SvgPreview-f1qaw73k.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-6zxpcy8b.js → abnfDiagram-O67JEVCF-4qn94h52.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-m98sgh3c.js → architectureDiagram-NJMV4G6O-tbewzdya.js} +3 -3
  16. package/dist/client/static/js/{blockDiagram-BEXU5L5S-cp7rervg.js → blockDiagram-BEXU5L5S-njgnwckz.js} +2 -2
  17. package/dist/client/static/js/{c4Diagram-YGBWAQC7-t31recqm.js → c4Diagram-YGBWAQC7-f58pcvbk.js} +1 -1
  18. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fy8x3dkx.js → classDiagram-v2-NBCMYWYE-52g73vyw.js} +3 -3
  19. package/dist/client/static/js/{cose-bilkent-JH36ORCC-va7ybm9e.js → cose-bilkent-JH36ORCC-ptdnshzh.js} +1 -1
  20. package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +1 -0
  21. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-4k0k429c.js → cynefinDiagram-VND7K2PF-qabfdkzr.js} +1 -1
  22. package/dist/client/static/js/{dagre-6A5THRUB-ykdhxq6t.js → dagre-6A5THRUB-kyf5jetf.js} +2 -2
  23. package/dist/client/static/js/{diagram-22UHCM2B-5nvwx7b6.js → diagram-22UHCM2B-bxrsjtv9.js} +4 -4
  24. package/dist/client/static/js/{diagram-3UASUU5V-hc7zsjgw.js → diagram-3UASUU5V-0f41s00j.js} +1 -1
  25. package/dist/client/static/js/{diagram-ATOU4E4O-97ae07y7.js → diagram-ATOU4E4O-0z1zx9h1.js} +1 -1
  26. package/dist/client/static/js/{diagram-CDSNMT55-b56nnbbs.js → diagram-CDSNMT55-znrmr6bk.js} +3 -3
  27. package/dist/client/static/js/{diagram-MLGK6HIB-37rygr9k.js → diagram-MLGK6HIB-jfe2jhk0.js} +1 -1
  28. package/dist/client/static/js/{diagram-MPIPVDR6-wv3vhhfk.js → diagram-MPIPVDR6-2kaawmwa.js} +1 -1
  29. package/dist/client/static/js/{dockerfile-0efb1z6e.js → dockerfile-12exatm9.js} +1 -1
  30. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-13fv7vxg.js → ebnfDiagram-ZINNZB2B-s5n37rfp.js} +1 -1
  31. package/dist/client/static/js/{elixir-mabagxwa.js → elixir-szk51ehr.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-xam60ktz.js → elk-276RUBZZ-433rd9fp.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-24ctv2ee.js → erDiagram-OPXOYQCR-key6ah0b.js} +2 -2
  34. package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
  35. package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +1 -0
  36. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-766a8fqw.js → ganttDiagram-FUAMR5RP-4efkhmca.js} +2 -2
  37. package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +1 -0
  38. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fmwjkgh6.js → gitGraphDiagram-X574FWY7-ac376y2k.js} +1 -1
  39. package/dist/client/static/js/html-tbz83eke.js +1 -0
  40. package/dist/client/static/js/{index-13xbwcbz.js → index-02543wk3.js} +1 -1
  41. package/dist/client/static/js/{index-sx809d6d.js → index-0e9nkc0g.js} +1 -1
  42. package/dist/client/static/js/{index-1c0pnsjd.js → index-0gbj4270.js} +1 -1
  43. package/dist/client/static/js/{index-z6kpc98a.js → index-0pabfaac.js} +1 -1
  44. package/dist/client/static/js/{index-4mstdh41.js → index-1t5ybx9v.js} +1 -1
  45. package/dist/client/static/js/{index-9vdbnvmk.js → index-1y3rzw6b.js} +1 -1
  46. package/dist/client/static/js/{index-qj34r6d0.js → index-38xv8h4t.js} +1 -1
  47. package/dist/client/static/js/{index-4j8rgr4p.js → index-50mdqev0.js} +1 -1
  48. package/dist/client/static/js/{index-zvazj4va.js → index-5jnvz9hw.js} +1 -1
  49. package/dist/client/static/js/{index-97qst4k9.js → index-77t0nvt1.js} +1 -1
  50. package/dist/client/static/js/{index-x7f5ysch.js → index-7a2efrbj.js} +1 -1
  51. package/dist/client/static/js/{index-yvxa7hd8.js → index-82vk27q1.js} +1 -1
  52. package/dist/client/static/js/{index-nbexks3x.js → index-8k7vjp8b.js} +1 -1
  53. package/dist/client/static/js/{index-sq3r1xhf.js → index-8kbp24xg.js} +1 -1
  54. package/dist/client/static/js/{index-zjydzxhm.js → index-b0v6gwym.js} +2 -2
  55. package/dist/client/static/js/{index-grczkttn.js → index-b42t14wk.js} +7 -7
  56. package/dist/client/static/js/{index-13dr1t1r.js → index-cz50ha6x.js} +23 -23
  57. package/dist/client/static/js/{index-8jqawh3r.js → index-dtj73vs1.js} +1 -1
  58. package/dist/client/static/js/{index-7t63akyt.js → index-dzmar8jr.js} +1 -1
  59. package/dist/client/static/js/{index-2x9eqztp.js → index-f33c4paw.js} +1 -1
  60. package/dist/client/static/js/{index-xxe52zrm.js → index-fb6pw9xb.js} +1 -1
  61. package/dist/client/static/js/{index-6ge6gk9w.js → index-gp57dx2v.js} +1 -1
  62. package/dist/client/static/js/{index-2hpy58d0.js → index-gsxebrq9.js} +2 -2
  63. package/dist/client/static/js/{index-czagykbq.js → index-pxtff3ez.js} +2 -2
  64. package/dist/client/static/js/{index-8hgm0abr.js → index-pzvr1699.js} +187 -183
  65. package/dist/client/static/js/{index-dydwcp3n.js → index-r9db1gsf.js} +1 -1
  66. package/dist/client/static/js/{index-b4y5g48d.js → index-raca8tsh.js} +1 -1
  67. package/dist/client/static/js/{index-95en3p3g.js → index-rf29f3fq.js} +4 -4
  68. package/dist/client/static/js/{index-sz3mxjvy.js → index-s4gv0rpk.js} +1 -1
  69. package/dist/client/static/js/{index-a9t9gdew.js → index-v3f7we4n.js} +4 -4
  70. package/dist/client/static/js/{index-ejdnjh5c.js → index-yjmm73jm.js} +1 -1
  71. package/dist/client/static/js/{index-1rxa9zxp.js → index-ykfd2fyj.js} +1 -1
  72. package/dist/client/static/js/{index-4z4ax55k.js → index-yzda8j2d.js} +6 -6
  73. package/dist/client/static/js/{index-vcn1kcpy.js → index-z78bzryw.js} +3 -3
  74. package/dist/client/static/js/{index-tqycj126.js → index-zndbhb9w.js} +1 -1
  75. package/dist/client/static/js/{index-ka2rc2cr.js → index-zs73zwjz.js} +3 -3
  76. package/dist/client/static/js/{index-xe5cqwnf.js → index-zs7sjv6x.js} +1 -1
  77. package/dist/client/static/js/{index-hzwr5fm9.js → index-zw621xez.js} +3 -3
  78. package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
  79. package/dist/client/static/js/{infoDiagram-VRGFBTTK-tqytmzp1.js → infoDiagram-VRGFBTTK-4e7ej63f.js} +2 -2
  80. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rp77ff6m.js → ishikawaDiagram-OU5B5YK6-k3yet1ec.js} +2 -2
  81. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-c7bxrhf1.js → journeyDiagram-ZHPQQLJL-qe352kyd.js} +2 -2
  82. package/dist/client/static/js/{kanban-definition-PNTS6WVX-j2pxewqq.js → kanban-definition-PNTS6WVX-58hag75n.js} +4 -4
  83. package/dist/client/static/js/{mermaid.core-cqqe1krg.js → mermaid.core-6e89h6vm.js} +2 -2
  84. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-s03k32p9.js → mindmap-definition-NLK3R4M7-ncsam2fm.js} +1 -1
  85. package/dist/client/static/js/one-dark-pro-qmyne0tn.js +1 -0
  86. package/dist/client/static/js/one-light-dj0ecjcj.js +1 -0
  87. package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +1 -0
  88. package/dist/client/static/js/{pegDiagram-GJSIUBJH-dfg2j0zc.js → pegDiagram-GJSIUBJH-b5ckc39d.js} +1 -1
  89. package/dist/client/static/js/{perl-5vxax0nr.js → perl-dtn1fccw.js} +1 -1
  90. package/dist/client/static/js/{php-hgrgdq63.js → php-7av78hch.js} +1 -1
  91. package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +1 -0
  92. package/dist/client/static/js/{pieDiagram-5QR66LMP-pshd1j79.js → pieDiagram-5QR66LMP-s4d47ve8.js} +2 -2
  93. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-cvvvmtk2.js → quadrantDiagram-O4NWA36T-zm0ekvjz.js} +1 -1
  94. package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +1 -0
  95. package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +1 -0
  96. package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +1 -0
  97. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +1 -0
  98. package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +1 -0
  99. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-h53p3sha.js → railroadDiagram-XR7U4H2S-52vdqf53.js} +1 -1
  100. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bdv2fkxd.js → requirementDiagram-PLB6GJNP-7kf8bmk9.js} +1 -1
  101. package/dist/client/static/js/{ruby-8pxcn21w.js → ruby-s2bqr910.js} +1 -1
  102. package/dist/client/static/js/{rust-j80dxgjg.js → rust-q98kssv3.js} +1 -1
  103. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-xqnnvmhy.js → sankeyDiagram-IPEJSGJF-bcb9f54a.js} +1 -1
  104. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3p67305f.js → sequenceDiagram-PO4LG4MO-76ywvj7g.js} +3 -3
  105. package/dist/client/static/js/{sizeCapture-INFHLROL-f87525h7.js → sizeCapture-INFHLROL-p9bsf5dc.js} +1 -1
  106. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-e5st1fy3.js → stateDiagram-v2-GCMORJYK-1ecfb3fs.js} +1 -1
  107. package/dist/client/static/js/{swimlanes-2SLR337P-ceghkbez.js → swimlanes-2SLR337P-2pyjr946.js} +1 -1
  108. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-vc8hvfya.js → swimlanesDiagram-TC7HE7FX-qr5hdxm4.js} +1 -1
  109. package/dist/client/static/js/{timeline-definition-EJHVYXUP-f7evs443.js → timeline-definition-EJHVYXUP-4csxwmn2.js} +3 -3
  110. package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +1 -0
  111. package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +1 -0
  112. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0gpn21p7.js → usecaseDiagram-POWQR4AR-0p1jnbsn.js} +7 -7
  113. package/dist/client/static/js/{vennDiagram-UO4OBE2U-4spzy428.js → vennDiagram-UO4OBE2U-y1hgdet4.js} +2 -2
  114. package/dist/client/static/js/{vue-xm1dxpmy.js → vue-cbqm4bed.js} +1 -1
  115. package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +1 -0
  116. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-745xr2pa.js → wardleyDiagram-VNRHLVJA-p578yrgm.js} +2 -2
  117. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7dr9qwx5.js → xychartDiagram-PMCCYNJV-b08b4ah0.js} +3 -3
  118. package/package.json +1 -1
  119. package/src/cli/lib/commands/session.js +12 -1
  120. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -123
  121. package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +214 -0
  122. package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +126 -0
  123. package/src/client/components/workspace/chat-timeline/UserTurn.tsx +183 -0
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +3 -3
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions.tsx +45 -0
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +14 -4
  127. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +2 -12
  128. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +42 -38
  129. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +25 -21
  130. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +41 -29
  131. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +47 -43
  132. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/parity.test.tsx +136 -0
  133. package/src/client/hooks/chat/timeline/composer-modes.ts +10 -7
  134. package/src/client/hooks/chat/timeline/plan-review-republish.test.ts +121 -0
  135. package/src/client/hooks/chat/timeline/plan-review.ts +12 -3
  136. package/src/server/lib/harness/acp/acp-audit.server.ts +1 -1
  137. package/src/server/lib/harness/acp/session-exit.ts +39 -5
  138. package/src/server/lib/harness/acp/session-turns.ts +67 -12
  139. package/src/server/lib/harness/acp/session.test.ts +61 -0
  140. package/src/server/lib/harness/acp/session.ts +15 -25
  141. package/src/server/lib/harness/acp/turn-outcome.server.test.ts +97 -0
  142. package/src/server/lib/harness/acp/turn-outcome.server.ts +71 -0
  143. package/src/server/lib/harness/acp/turn-silence.ts +52 -0
  144. package/src/server/lib/harness/acp/turn.test.ts +85 -3
  145. package/src/server/lib/harness/acp/turn.ts +62 -4
  146. package/src/server/lib/lifecycle/after-listen.ts +10 -0
  147. package/src/server/lib/omp/rpc/frame-fold-contract.ts +21 -0
  148. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +4 -0
  149. package/src/server/lib/omp/rpc/frame-fold.ts +25 -2
  150. package/src/server/lib/omp/rpc/manager.ts +9 -8
  151. package/src/server/lib/omp/rpc/retry-saga.ts +54 -0
  152. package/src/server/lib/omp/rpc/run-settle.server.ts +38 -5
  153. package/src/server/lib/omp/rpc/run-settle.test.ts +5 -2
  154. package/src/server/lib/omp/rpc/session-commands-dialog.test.ts +6 -20
  155. package/src/server/lib/omp/rpc/session-commands-mapping.test.ts +131 -0
  156. package/src/server/lib/omp/rpc/session-commands.test.ts +95 -116
  157. package/src/server/lib/omp/rpc/session-commands.ts +38 -17
  158. package/src/server/lib/omp/rpc/terminal-settle.test.ts +223 -0
  159. package/src/server/lib/omp/rpc/terminal-settle.ts +127 -29
  160. package/src/server/lib/omp/session/scan.ts +15 -2
  161. package/src/server/lib/omp/session/session-discovery.test.ts +21 -0
  162. package/src/server/lib/sessions/notify.server.test.ts +11 -3
  163. package/src/server/lib/sessions/notify.server.ts +67 -42
  164. package/src/server/lib/sessions/spawn.server.test.ts +5 -1
  165. package/src/server/lib/sessions/spawn.server.ts +8 -3
  166. package/src/server/routes/sessions/answer.test.ts +62 -0
  167. package/src/server/routes/sessions/answer.ts +13 -2
  168. package/src/shared/lib/chat/composer/delegation.ts +11 -7
  169. package/src/shared/lib/chat/export-markdown.ts +19 -0
  170. package/src/shared/lib/chat/orchestration/notice.test.ts +118 -0
  171. package/src/shared/lib/chat/orchestration/notice.ts +183 -0
  172. package/src/shared/lib/chat/timeline/omp-callbacks.ts +6 -1
  173. package/src/shared/lib/chat/timeline/tool-render-mode.ts +3 -3
  174. package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
  175. package/src/shared/lib/omp/session/operator-title.test.ts +21 -0
  176. package/src/shared/lib/omp/session/operator-title.ts +28 -0
  177. package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +0 -1
  178. package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +0 -1
  179. package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +0 -1
  180. package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +0 -1
  181. package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +0 -1
  182. package/dist/client/static/js/html-bwyt0ayy.js +0 -1
  183. package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +0 -1
  184. package/dist/client/static/js/one-dark-pro-9tt0a020.js +0 -1
  185. package/dist/client/static/js/one-light-5fg4r0ra.js +0 -1
  186. package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +0 -1
  187. package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +0 -1
  188. package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +0 -1
  189. package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +0 -1
  190. package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +0 -1
  191. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +0 -1
  192. package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +0 -1
  193. package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +0 -1
  194. package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +0 -1
  195. package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +0 -1
@@ -19,6 +19,7 @@ import { useCallback, useState } from 'preact/hooks';
19
19
  import { memo } from 'preact/compat';
20
20
  import { ToolBody } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody';
21
21
  import { ToolFactChips } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips';
22
+ import { ToolRowActions } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions';
22
23
  import { toolStatusGlyph, STATUS_TONE_CLASS } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph';
23
24
  import { useToolView } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view';
24
25
  import { toolToggleLabel } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label';
@@ -38,41 +39,52 @@ export const TraceRow = memo(function TraceRow({ tool, isOpen, onToggle, default
38
39
  return (
39
40
  <div className="relative pl-4" data-tool-row="trace">
40
41
  {/* The node, drawn ON the section's rail. `-left-px` centres it on the
41
- 1px line the section owns. */}
42
+ 1px line the section owns. `warn` (an aborted call) gets its own
43
+ tone: falling through to the muted node made an interruption look
44
+ like a running or skipped call. */}
42
45
  <span
43
46
  aria-hidden="true"
44
47
  className={`absolute left-0 top-[9px] flex h-2 w-2 items-center justify-center rounded-full ${
45
- status.tone === 'error' ? 'bg-error' : status.tone === 'ok' ? 'bg-ink/45' : 'bg-ink/20'
48
+ status.tone === 'error'
49
+ ? 'bg-error'
50
+ : status.tone === 'warn'
51
+ ? 'bg-warning'
52
+ : status.tone === 'ok'
53
+ ? 'bg-ink/45'
54
+ : 'bg-ink/20'
46
55
  }`}
47
56
  />
48
57
 
49
- <button
50
- type="button"
51
- onClick={handleToggle}
52
- disabled={!view.hasBody || view.alwaysExpanded}
53
- aria-expanded={isExpanded}
54
- aria-label={view.hasBody && !view.alwaysExpanded ? toolToggleLabel(view.header.title, view.subtitle, isExpanded) : undefined}
55
- className={`flex w-full flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md px-1.5 py-1 text-left transition-colors ${
56
- view.hasBody && !view.alwaysExpanded ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
57
- } focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
58
- >
59
- <span className={`shrink-0 self-center ${STATUS_TONE_CLASS[status.tone]}`} aria-hidden="true">
60
- {status.glyph}
61
- </span>
62
- <span className="sr-only">{status.word}</span>
63
- <span className="shrink-0 text-[12px] font-semibold tracking-tight text-ink">{view.header.title}</span>
64
- {/* Subject + facts in ONE clipping row, the way the card's meta line
65
- draws it: without the clip a long chip pair widened the section past
66
- the phone viewport (measured at 390: 455 scrollWidth against 362). */}
67
- <span className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
68
- <span className="min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/45">{view.subtitle}</span>
69
- {view.summary && view.summary.facts.length > 0 && (
70
- <span className="shrink-0">
71
- <ToolFactChips facts={view.summary.facts} max={2} />
72
- </span>
73
- )}
74
- </span>
75
- </button>
58
+ <div className="flex items-center gap-1">
59
+ <button
60
+ type="button"
61
+ onClick={handleToggle}
62
+ disabled={!view.hasBody || view.alwaysExpanded}
63
+ aria-expanded={isExpanded}
64
+ aria-label={view.hasBody && !view.alwaysExpanded ? toolToggleLabel(view.header.title, view.subtitle, isExpanded) : undefined}
65
+ className={`flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md px-1.5 py-1 text-left transition-colors ${
66
+ view.hasBody && !view.alwaysExpanded ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
67
+ } focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
68
+ >
69
+ <span className={`shrink-0 self-center ${STATUS_TONE_CLASS[status.tone]}`} aria-hidden="true">
70
+ {status.glyph}
71
+ </span>
72
+ <span className="sr-only">{status.word}</span>
73
+ <span className="shrink-0 text-[12px] font-semibold tracking-tight text-ink">{view.header.title}</span>
74
+ {/* Subject + facts in ONE clipping row, the way the card's meta line
75
+ draws it: without the clip a long chip pair widened the section past
76
+ the phone viewport (measured at 390: 455 scrollWidth against 362). */}
77
+ <span className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
78
+ <span className="min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/45">{view.subtitle}</span>
79
+ {view.summary && view.summary.facts.length > 0 && (
80
+ <span className="shrink-0">
81
+ <ToolFactChips facts={view.summary.facts} max={2} />
82
+ </span>
83
+ )}
84
+ </span>
85
+ </button>
86
+ <ToolRowActions tool={tool} isReminder={view.isReminder} />
87
+ </div>
76
88
 
77
89
  {isExpanded && view.hasBody && (
78
90
  <div className="mb-1 ml-[3.5px] overflow-hidden border-l border-ink/10 py-2 pl-3 space-y-3 code-surface">
@@ -34,6 +34,7 @@ import { useCallback, useState } from 'preact/hooks';
34
34
  import { memo } from 'preact/compat';
35
35
  import type { ToolCallData } from '@/shared/types';
36
36
  import { ToolBody } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody';
37
+ import { ToolRowActions } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions';
37
38
  import {
38
39
  toolStatusGlyph,
39
40
  type ToolStatusTone,
@@ -134,50 +135,53 @@ export const TuiRow = memo(function TuiRow({ tool, isOpen, onToggle, defaultExpa
134
135
  only — the colours separate the three claims (what ran, on what, how
135
136
  it ended), which is what the terminal does with SGR and what a box
136
137
  would otherwise have to do with borders. */}
137
- <button
138
- type="button"
139
- onClick={handleToggle}
140
- disabled={!canToggle}
141
- aria-expanded={isExpanded}
142
- aria-label={
143
- canToggle ? toolToggleLabel(view.header.title, view.subtitle, isExpanded) : undefined
144
- }
145
- className={`flex w-full flex-wrap items-baseline gap-x-1 gap-y-0 rounded px-1 py-0.5 text-left text-[11.5px] leading-[1.55] transition-colors ${
146
- canToggle ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
147
- } focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
148
- >
149
- <span className={`shrink-0 self-center ${tone}`} aria-hidden="true">
150
- {status.glyph}
151
- </span>
152
- <span className="sr-only">{status.word}</span>
153
- <span className="shrink-0 font-semibold text-info">{view.header.title}</span>
154
- {view.subtitle && (
155
- <>
156
- <span className="shrink-0 text-ink/25">:</span>
157
- <span className="min-w-0 flex-1 truncate text-meta">{view.subtitle}</span>
158
- </>
159
- )}
160
- <span className={`shrink-0 font-semibold ${tone}`}>{`[${status.word.toLowerCase()}]`}</span>
161
- {facts.length > 0 && (
162
- // Facts are the LAST thing on the line and they clip as a unit, so a
163
- // long `exit 1 · 412 B` can never widen the row past the panel —
164
- // measured at 390 the unbounded group ran the section to 459/362.
165
- // The whole group carries the tooltip with every fact, so a clipped
166
- // tail is still recoverable.
167
- <span
168
- className="min-w-0 shrink truncate text-[10.5px]"
169
- title={facts.map((fact) => fact.label).join(' · ')}
170
- >
171
- <span className="text-ink/25">· </span>
172
- <Facts facts={facts} max={HEAD_FACT_LIMIT} />
173
- </span>
174
- )}
175
- {canToggle && (
176
- <span className="ml-auto shrink-0 pl-1 text-ink/40" aria-hidden="true">
177
- {isExpanded ? '▾' : '▸'}
138
+ <div className="flex items-center gap-1">
139
+ <button
140
+ type="button"
141
+ onClick={handleToggle}
142
+ disabled={!canToggle}
143
+ aria-expanded={isExpanded}
144
+ aria-label={
145
+ canToggle ? toolToggleLabel(view.header.title, view.subtitle, isExpanded) : undefined
146
+ }
147
+ className={`flex min-w-0 flex-1 flex-wrap items-baseline gap-x-1 gap-y-0 rounded px-1 py-0.5 text-left text-[11.5px] leading-[1.55] transition-colors ${
148
+ canToggle ? 'cursor-pointer hover:bg-ink/[0.03]' : 'cursor-default'
149
+ } focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`}
150
+ >
151
+ <span className={`shrink-0 self-center ${tone}`} aria-hidden="true">
152
+ {status.glyph}
178
153
  </span>
179
- )}
180
- </button>
154
+ <span className="sr-only">{status.word}</span>
155
+ <span className="shrink-0 font-semibold text-info">{view.header.title}</span>
156
+ {view.subtitle && (
157
+ <>
158
+ <span className="shrink-0 text-ink/25">:</span>
159
+ <span className="min-w-0 flex-1 truncate text-meta">{view.subtitle}</span>
160
+ </>
161
+ )}
162
+ <span className={`shrink-0 font-semibold ${tone}`}>{`[${status.word.toLowerCase()}]`}</span>
163
+ {facts.length > 0 && (
164
+ // Facts are the LAST thing on the line and they clip as a unit, so a
165
+ // long `exit 1 · 412 B` can never widen the row past the panel —
166
+ // measured at 390 the unbounded group ran the section to 459/362.
167
+ // The whole group carries the tooltip with every fact, so a clipped
168
+ // tail is still recoverable.
169
+ <span
170
+ className="min-w-0 shrink truncate text-[10.5px]"
171
+ title={facts.map((fact) => fact.label).join(' · ')}
172
+ >
173
+ <span className="text-ink/25">· </span>
174
+ <Facts facts={facts} max={HEAD_FACT_LIMIT} />
175
+ </span>
176
+ )}
177
+ {canToggle && (
178
+ <span className="ml-auto shrink-0 pl-1 text-ink/40" aria-hidden="true">
179
+ {isExpanded ? '▾' : '▸'}
180
+ </span>
181
+ )}
182
+ </button>
183
+ <ToolRowActions tool={tool} isReminder={view.isReminder} />
184
+ </div>
181
185
 
182
186
  {isExpanded && view.hasBody && (
183
187
  // Indentation, not a frame: the body hangs off the line the way a
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * What every render style must show, whichever frame it draws.
8
+ *
9
+ * A style is a frame, not a capability: the card, the status line, the rail
10
+ * node and the terminal line all render the same call. Three facts used to be
11
+ * card-only, and each one was a silent loss in the other four styles:
12
+ *
13
+ * - a tool with no specialized panel (a custom or plugin tool) had no body at
14
+ * all, because the line styles gated the body on a panel while the card
15
+ * always rendered the generic Input / Diff / Output;
16
+ * - a result omp capped or rewrote had no "Full output" chip, so the truncated
17
+ * copy on screen was the only copy the reader could reach;
18
+ * - a reminder envelope in the result read as an ordinary success.
19
+ *
20
+ * The trace node's `warn` tone is pinned here too: an aborted call used to fall
21
+ * through to the muted node, indistinguishable from a running or skipped one.
22
+ */
23
+
24
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
25
+ import { Window } from 'happy-dom';
26
+ import { h, render } from 'preact';
27
+ import { act } from 'preact/test-utils';
28
+ import { ToolCallingSection } from '@/client/components/workspace/chat-timeline/ToolCallingSection';
29
+ import { SessionStateProvider } from '@/client/components/common/session-state-provider';
30
+ import { primeKabmoSettings } from '@/shared/lib/settings/client';
31
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
32
+ import type { ToolCallData } from '@/shared/types/chat';
33
+
34
+ let container: HTMLElement;
35
+
36
+ beforeAll(() => installDomGlobals(new Window({ url: 'http://localhost/?sessionId=parity' })));
37
+ afterAll(() => restoreDomGlobals());
38
+
39
+ beforeEach(() => {
40
+ container = document.createElement('div');
41
+ document.body.appendChild(container);
42
+ });
43
+
44
+ afterEach(() => {
45
+ render(null, container);
46
+ container.remove();
47
+ });
48
+
49
+ /** A tool the host has no panel for — the generic body is its only body. */
50
+ const CUSTOM_TOOL: ToolCallData = {
51
+ id: 'custom-1',
52
+ type: 'custom',
53
+ name: 'web_fetch',
54
+ title: 'Web Fetch',
55
+ status: 'success',
56
+ input: { url: 'https://example.com' },
57
+ output: 'CUSTOM_OUTPUT_TOKEN',
58
+ } as ToolCallData;
59
+
60
+ /** A result omp capped, with the lossless original behind an artifact id. */
61
+ const ARTIFACT_TOOL: ToolCallData = {
62
+ id: 'artifact-1',
63
+ type: 'bash',
64
+ name: 'bash',
65
+ title: 'Bash',
66
+ status: 'success',
67
+ command: 'seq 1 100000',
68
+ output: 'truncated',
69
+ details: { meta: { limits: { columnTruncated: { artifactId: '42', artifactElidedBytes: 1024 } } } },
70
+ } as ToolCallData;
71
+
72
+ /** The runtime interrupting the call, not its outcome. */
73
+ const REMINDER_TOOL: ToolCallData = {
74
+ id: 'reminder-1',
75
+ type: 'bash',
76
+ name: 'bash',
77
+ title: 'Bash',
78
+ status: 'success',
79
+ command: 'bun test',
80
+ output: '<system-reminder>Every turn MUST end with a tool call.</system-reminder>',
81
+ } as ToolCallData;
82
+
83
+ const ABORTED_TOOL: ToolCallData = {
84
+ id: 'aborted-1',
85
+ type: 'bash',
86
+ name: 'bash',
87
+ title: 'Bash',
88
+ status: 'aborted',
89
+ command: 'bun test',
90
+ output: '',
91
+ } as ToolCallData;
92
+
93
+ async function mount(tools: ToolCallData[], style: string): Promise<HTMLElement> {
94
+ primeKabmoSettings({ kabmo_settings: { toolRenderStyle: style } });
95
+ await act(async () => {
96
+ render(
97
+ h(SessionStateProvider, {
98
+ sessionId: `parity-${style}`,
99
+ children: h(ToolCallingSection, { tools }),
100
+ }),
101
+ container,
102
+ );
103
+ });
104
+ return container;
105
+ }
106
+
107
+ describe.each(['card', 'compact', 'trace', 'minimal', 'tui'])('style parity: %s', (style) => {
108
+ test('a panel-less tool opens its generic body', async () => {
109
+ const el = await mount([CUSTOM_TOOL], style);
110
+ const toggle = el.querySelector('[data-tool-row] button') as HTMLElement;
111
+ expect(toggle.getAttribute('aria-label')).toBe('Expand WEB Fetch');
112
+
113
+ await act(async () => {
114
+ toggle.click();
115
+ });
116
+ expect(el.querySelector('.code-surface')?.textContent).toContain('CUSTOM_OUTPUT_TOKEN');
117
+ });
118
+
119
+ test('a spilled result offers the full output', async () => {
120
+ const el = await mount([ARTIFACT_TOOL], style);
121
+ expect(el.querySelector('[aria-label="Read the full output"]')).not.toBeNull();
122
+ });
123
+
124
+ test('a reminder envelope is flagged', async () => {
125
+ const el = await mount([REMINDER_TOOL], style);
126
+ expect(el.textContent).toContain('Reminder');
127
+ });
128
+ });
129
+
130
+ describe('the trace node tone', () => {
131
+ test('an aborted call takes the warning tone, not the muted one', async () => {
132
+ const el = await mount([ABORTED_TOOL], 'trace');
133
+ const node = el.querySelector('[data-tool-row="trace"] > span[aria-hidden="true"]') as HTMLElement;
134
+ expect(node.className).toContain('bg-warning');
135
+ });
136
+ });
@@ -40,13 +40,16 @@ export function useComposerModes(sessionId: string | null, harness?: string | nu
40
40
  // is picked. `omp-acp` is excluded for the reason `GET /modes` excludes it:
41
41
  // its selectors are default/plan, which the dedicated Plan toggle expresses.
42
42
  const modeChoices = harness && harness !== 'omp-acp' && probe?.modes.length ? probe.modes : undefined;
43
+ const modes = useChatTimelineModes(sessionId, {
44
+ harness,
45
+ ...(modeValues ? { modeValues } : {}),
46
+ ...(modeChoices ? { modeChoices } : {}),
47
+ ...(modeChoices && probe?.currentMode ? { modeCurrent: probe.currentMode } : {}),
48
+ });
43
49
  return {
44
- modes: useChatTimelineModes(sessionId, {
45
- harness,
46
- ...(modeValues ? { modeValues } : {}),
47
- ...(modeChoices ? { modeChoices } : {}),
48
- ...(modeChoices && probe?.currentMode ? { modeCurrent: probe.currentMode } : {}),
49
- }),
50
- planReview: usePlanReview(sessionId),
50
+ modes,
51
+ // The republish probe is a PLAN-MODE question: a proposal can only be
52
+ // parked by that path, so a chat outside plan mode must not dispatch it.
53
+ planReview: usePlanReview(sessionId, modes.plan),
51
54
  };
52
55
  }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The plan-review republish probe is a PLAN-MODE question.
8
+ *
9
+ * A proposal can only be parked by the plan-mode approval path, so a chat that
10
+ * is not in plan mode has nothing to re-send. The probe used to fire on every
11
+ * mount, which made a normal chat dispatch a `/kabmo-mode` prompt every time it
12
+ * was opened — and that prompt re-armed the run (a `stream` row plus
13
+ * `promptRunning` for the 10 s watchdog) over a session that had already
14
+ * finished. Both directions are pinned here: no plan mode, no request; plan
15
+ * mode, one GET then one POST.
16
+ */
17
+
18
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
19
+ import { Window } from 'happy-dom';
20
+ import type { h as PreactH, render as PreactRender } from 'preact';
21
+ import type { act as PreactAct } from 'preact/test-utils';
22
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
23
+ import type { usePlanReview as UsePlanReview, PlanReviewState } from '@/client/hooks/chat/timeline/plan-review';
24
+
25
+ let usePlanReview: typeof UsePlanReview;
26
+ let h: typeof PreactH;
27
+ let render: typeof PreactRender;
28
+ let act: typeof PreactAct;
29
+
30
+ const realFetch = globalThis.fetch;
31
+
32
+ beforeAll(async () => {
33
+ installDomGlobals(new Window({ url: 'http://localhost' }));
34
+ // Static imports cannot work here: Preact binds its environment at module
35
+ // evaluation time, so these must load after the DOM globals are installed.
36
+ ({ usePlanReview } = await import('@/client/hooks/chat/timeline/plan-review'));
37
+ ({ h, render } = await import('preact'));
38
+ ({ act } = await import('preact/test-utils'));
39
+ });
40
+
41
+ afterAll(() => {
42
+ restoreDomGlobals();
43
+ });
44
+
45
+ afterEach(() => {
46
+ globalThis.fetch = realFetch;
47
+ });
48
+
49
+ interface ProbeProps {
50
+ sessionId: string;
51
+ planActive: boolean;
52
+ holder: { current: PlanReviewState | null };
53
+ }
54
+
55
+ function Probe({ sessionId, planActive, holder }: ProbeProps) {
56
+ holder.current = usePlanReview(sessionId, planActive);
57
+ return null;
58
+ }
59
+
60
+ /** Mount the hook and return a re-render that changes its inputs. */
61
+ async function mountProbe(sessionId: string, planActive: boolean) {
62
+ const holder: ProbeProps['holder'] = { current: null };
63
+ const node = document.createElement('div');
64
+ document.body.appendChild(node);
65
+ const draw = async (nextPlanActive: boolean) => {
66
+ await act(async () => {
67
+ render(h(Probe, { sessionId, planActive: nextPlanActive, holder }), node);
68
+ });
69
+ };
70
+ await draw(planActive);
71
+ return { draw, holder };
72
+ }
73
+
74
+ /** Let the effect's fetch chain settle. */
75
+ async function flush(): Promise<void> {
76
+ for (let turn = 0; turn < 20; turn += 1) await Promise.resolve();
77
+ }
78
+
79
+ describe('usePlanReview republish', () => {
80
+ test('a chat outside plan mode never dispatches the probe', async () => {
81
+ const calls: { url: string; method: string }[] = [];
82
+ globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
83
+ calls.push({ url: String(input), method: init?.method ?? 'GET' });
84
+ return new Response(JSON.stringify({ running: true }), { status: 200 });
85
+ }) as typeof fetch;
86
+
87
+ await mountProbe('sess-1', false);
88
+ await flush();
89
+ expect(calls).toEqual([]);
90
+ });
91
+
92
+ test('plan mode probes once: a GET, then the republish POST', async () => {
93
+ const calls: { url: string; method: string; body?: string }[] = [];
94
+ globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
95
+ calls.push({ url: String(input), method: init?.method ?? 'GET', body: init?.body as string | undefined });
96
+ return new Response(JSON.stringify({ running: true }), { status: 200 });
97
+ }) as typeof fetch;
98
+
99
+ await mountProbe('sess-1', true);
100
+ await flush();
101
+ expect(calls.map((call) => call.method)).toEqual(['GET', 'POST']);
102
+ expect(calls[1]?.url).toContain('/api/agent/sess-1');
103
+ expect(calls[1]?.body).toContain('"kabmo_mode"');
104
+ });
105
+
106
+ test('entering plan mode after mount fires the probe', async () => {
107
+ const calls: { method: string }[] = [];
108
+ globalThis.fetch = (async (_input: RequestInfo | URL, init?: RequestInit) => {
109
+ calls.push({ method: init?.method ?? 'GET' });
110
+ return new Response(JSON.stringify({ running: true }), { status: 200 });
111
+ }) as typeof fetch;
112
+
113
+ const probe = await mountProbe('sess-1', false);
114
+ await flush();
115
+ expect(calls).toEqual([]);
116
+
117
+ await probe.draw(true);
118
+ await flush();
119
+ expect(calls.map((call) => call.method)).toEqual(['GET', 'POST']);
120
+ });
121
+ });
@@ -43,7 +43,7 @@ export function proposalFromMarkerPayload(payload: Record<string, unknown>): Pla
43
43
  return { title, planFilePath, planContent };
44
44
  }
45
45
 
46
- export function usePlanReview(sessionId: string | null): PlanReviewState {
46
+ export function usePlanReview(sessionId: string | null, planActive = false): PlanReviewState {
47
47
  const [proposal, setProposal] = useState<PlanProposal | null>(null);
48
48
  const [deciding, setDeciding] = useState(false);
49
49
  const [error, setError] = useState<string | null>(null);
@@ -65,9 +65,18 @@ export function usePlanReview(sessionId: string | null): PlanReviewState {
65
65
  // Kabmo's lazy-spawn path, and opening a finished session to READ it must
66
66
  // not boot an omp process for a question the answer to which is "nothing is
67
67
  // parked" (the same rule the observer-only commands follow).
68
+ //
69
+ // And only while PLAN MODE is active: a proposal can only be parked by the
70
+ // plan-mode approval path, so a chat that is not in plan mode has nothing to
71
+ // re-send. The probe used to fire on every mount, which made a normal chat
72
+ // dispatch a `/kabmo-mode` prompt every time it was opened — and that prompt
73
+ // re-armed the run (a `stream` row plus `promptRunning` for the 10 s
74
+ // watchdog) over a session that had already finished. `planActive` is the
75
+ // live mode state (`useChatTimelineModes`), so entering plan mode still
76
+ // re-probes; leaving it stops the probe.
68
77
  useEffect(() => {
69
78
  const current = sessionId;
70
- if (!current || isPendingSessionId(current)) return;
79
+ if (!current || !planActive || isPendingSessionId(current)) return;
71
80
  let cancelled = false;
72
81
  fetch(`/api/agent/${encodeURIComponent(current)}`)
73
82
  .then((res) => (res.ok ? (res.json() as Promise<{ running?: boolean }>) : null))
@@ -83,7 +92,7 @@ export function usePlanReview(sessionId: string | null): PlanReviewState {
83
92
  return () => {
84
93
  cancelled = true;
85
94
  };
86
- }, [sessionId]);
95
+ }, [sessionId, planActive]);
87
96
 
88
97
  useEffect(() => subscribeClientSignal(KABMO_MODE_SIGNAL, (detail) => {
89
98
  const marker = detail?.marker as ParsedMarker | undefined;
@@ -72,7 +72,7 @@ export async function runAcpGoalAudit(request: AcpGoalAuditRequest): Promise<Goa
72
72
  );
73
73
  // A disposable reader: no stream row, no turn settle, no queue, no title.
74
74
  session.markStream = () => {};
75
- session.onTurnEnded = () => {};
75
+ session.onTurnEnded = async () => {};
76
76
 
77
77
  const events: AgentEvent[] = [];
78
78
  session.onEvent((event) => events.push(event));
@@ -13,19 +13,53 @@
13
13
 
14
14
  import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
15
15
  import type { HarnessId } from '@/shared/lib/harness/catalog';
16
+ import { noteChildOutcome } from '@/server/lib/sessions/notify.server';
16
17
 
17
18
  export interface AcpExitInfo {
18
19
  code: number | null;
19
20
  stderrTail: string;
20
21
  }
21
22
 
22
- export function acpExitFailureFrames(harness: HarnessId, info: AcpExitInfo): AgentEvent[] {
23
+ /** The sentence an exit reports, for the operator AND for a coordinator. */
24
+ export function acpExitFailureMessage(harness: HarnessId, info: AcpExitInfo): string {
23
25
  const detail = info.stderrTail.trim().split('\n').slice(-3).join(' · ');
26
+ return detail || `The ${harness} agent exited (code ${info.code ?? 'signal'})`;
27
+ }
28
+
29
+ export function acpExitFailureFrames(harness: HarnessId, info: AcpExitInfo): AgentEvent[] {
24
30
  return [
25
- {
26
- type: 'prompt_error',
27
- errorMessage: detail || `The ${harness} agent exited (code ${info.code ?? 'signal'})`,
28
- },
31
+ { type: 'prompt_error', errorMessage: acpExitFailureMessage(harness, info) },
29
32
  { type: 'agent_end', isTerminal: true },
30
33
  ];
31
34
  }
35
+
36
+ /** What the exit path reads off the session. */
37
+ export interface AcpExitHost {
38
+ harness: HarnessId;
39
+ sessionId: string;
40
+ isStreaming: boolean;
41
+ isPromptRunning: boolean;
42
+ emit(event: AgentEvent): void;
43
+ }
44
+
45
+ /**
46
+ * The unwelcome exit: show the operator why, and tell a coordinator its worker
47
+ * stopped. The frames reach CLIENTS only, so without the notice a delegated
48
+ * worker that died mid-turn left its coordinator waiting for work that had
49
+ * already ended. Reported only while a turn is OPEN — a process that exits
50
+ * between turns has no outcome to report.
51
+ *
52
+ * Returns the notice write so a caller can await it; the process callback
53
+ * ignores the value.
54
+ */
55
+ export function reportAcpExit(host: AcpExitHost, info: AcpExitInfo): Promise<void> {
56
+ for (const event of acpExitFailureFrames(host.harness, info)) host.emit(event);
57
+ if (!host.isStreaming && !host.isPromptRunning) return Promise.resolve();
58
+ return noteChildOutcome({
59
+ sessionId: host.sessionId,
60
+ status: 'failed',
61
+ failure: acpExitFailureMessage(host.harness, info),
62
+ }).catch((error: unknown) => {
63
+ console.error('[sessions] could not record an ACP child outcome:', error);
64
+ });
65
+ }