@kabmo-labs/kabmo 0.41.0 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +647 -633
  3. package/dist/client/static/js/{CsvGrid-60njj97j.js → CsvGrid-8gdp5b49.js} +2 -2
  4. package/dist/client/static/js/{DocxView-rsv0j46a.js → DocxView-j9sphgra.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-n2g5df3a.js → DrawioView-xsgjc7d8.js} +2 -2
  6. package/dist/client/static/js/ImageView-ve9hc519.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-5mqffvkc.js +2 -0
  8. package/dist/client/static/js/Modal-50whypff.js +38 -0
  9. package/dist/client/static/js/{PdfView-1r7a0qkp.js → PdfView-afd5cg54.js} +1 -1
  10. package/dist/client/static/js/SessionsView-7719nvy0.js +1 -0
  11. package/dist/client/static/js/{SheetView-bt5pp042.js → SheetView-gfzgxb4r.js} +25 -25
  12. package/dist/client/static/js/{SvgPreview-vfmqgmrx.js → SvgPreview-225pkb99.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-8k5hk1yx.js → abnfDiagram-O67JEVCF-z70sk69m.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +1 -0
  15. package/dist/client/static/js/architectureDiagram-NJMV4G6O-pf1gpkje.js +36 -0
  16. package/dist/client/static/js/{astro-0rh34hha.js → astro-nn7xg0we.js} +1 -1
  17. package/dist/client/static/js/bash-fjzhxy10.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-04sbtdth.js → blockDiagram-BEXU5L5S-sr25kbn6.js} +6 -6
  19. package/dist/client/static/js/c-wqtyezvw.js +1 -0
  20. package/dist/client/static/js/c4Diagram-YGBWAQC7-znstpg86.js +38 -0
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-18cc0bsb.js → classDiagram-v2-NBCMYWYE-7n0pdcd8.js} +6 -6
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-dk683zvp.js → cose-bilkent-JH36ORCC-zn3qw4c4.js} +1 -1
  23. package/dist/client/static/js/cpp-y0nzwner.js +1 -0
  24. package/dist/client/static/js/css-a13jmmnc.js +1 -0
  25. package/dist/client/static/js/css-n2waj098.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-m2sx8d8s.js → cynefinDiagram-VND7K2PF-3z41vtzs.js} +2 -2
  28. package/dist/client/static/js/{dagre-6A5THRUB-qf3pr59p.js → dagre-6A5THRUB-5j3zn883.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-twnz23mt.js → diagram-22UHCM2B-ryw1w2kh.js} +10 -10
  30. package/dist/client/static/js/{diagram-3UASUU5V-417bas6t.js → diagram-3UASUU5V-p91q4gkh.js} +1 -1
  31. package/dist/client/static/js/diagram-ATOU4E4O-22dn73g4.js +3 -0
  32. package/dist/client/static/js/diagram-CDSNMT55-589p9n53.js +30 -0
  33. package/dist/client/static/js/{diagram-MLGK6HIB-7a0h1hs3.js → diagram-MLGK6HIB-ezw06wbx.js} +1 -1
  34. package/dist/client/static/js/{diagram-MPIPVDR6-w75bftmd.js → diagram-MPIPVDR6-cfwrsvk1.js} +2 -2
  35. package/dist/client/static/js/{dockerfile-g5qbaeq3.js → dockerfile-r4k7q34y.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-vdzm3tsv.js → ebnfDiagram-ZINNZB2B-3rv2wvbf.js} +1 -1
  37. package/dist/client/static/js/{elixir-gpez1k9m.js → elixir-szk51ehr.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-2fsbb484.js → elk-276RUBZZ-ma40kneq.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-vnkztq7d.js → erDiagram-OPXOYQCR-xwstsfqa.js} +6 -6
  40. package/dist/client/static/js/{erlang-jqqa3ehb.js → erlang-zwy7cqdk.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-evp84v09.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-pbvcch52.js → ganttDiagram-FUAMR5RP-qxyx9tr9.js} +2 -2
  44. package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +1 -0
  45. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-dkvktvzr.js → gitGraphDiagram-X574FWY7-v6sg7bkh.js} +2 -2
  46. package/dist/client/static/js/graphql-gvb7e2eb.js +1 -0
  47. package/dist/client/static/js/html-tbz83eke.js +1 -0
  48. package/dist/client/static/js/index-001vebsp.js +2 -0
  49. package/dist/client/static/js/{index-rc8wrs2a.js → index-03pyvmcz.js} +2 -2
  50. package/dist/client/static/js/index-0nca2nhp.js +1 -0
  51. package/dist/client/static/js/{index-3rymer2w.js → index-0p43qr4k.js} +1 -1
  52. package/dist/client/static/js/{index-amawahyh.js → index-2w9j2nj4.js} +2 -2
  53. package/dist/client/static/js/{index-f8pq132s.js → index-313ctswm.js} +1 -1
  54. package/dist/client/static/js/{index-a4ed3mks.js → index-3d40c0a7.js} +5 -5
  55. package/dist/client/static/js/{index-pn91shfp.js → index-4cncqz8j.js} +2 -2
  56. package/dist/client/static/js/{index-9fnzcg2x.js → index-4y0ayjfx.js} +2 -2
  57. package/dist/client/static/js/index-5599dngt.js +1 -0
  58. package/dist/client/static/js/index-5asf5625.js +4 -0
  59. package/dist/client/static/js/{index-tgper3yy.js → index-6dxs0tvg.js} +2 -2
  60. package/dist/client/static/js/{index-zfykeg7x.js → index-6eq445nn.js} +10 -10
  61. package/dist/client/static/js/index-869bpqcs.js +12 -0
  62. package/dist/client/static/js/{index-zye9309h.js → index-8b3t2y77.js} +2 -2
  63. package/dist/client/static/js/{index-rdqn92tc.js → index-8fvmyv7t.js} +2 -2
  64. package/dist/client/static/js/{index-0xaz2eyv.js → index-8pdz41yh.js} +3 -3
  65. package/dist/client/static/js/{index-ne131hmw.js → index-9hzfvjrb.js} +2 -2
  66. package/dist/client/static/js/{index-xfa5hswh.js → index-9ss64g4g.js} +1 -1
  67. package/dist/client/static/js/{index-yzg9mbsv.js → index-b0v6gwym.js} +2 -2
  68. package/dist/client/static/js/{index-j5ram1ve.js → index-b37ewyvk.js} +2 -2
  69. package/dist/client/static/js/{index-e6qjfcz9.js → index-b3d2k7ec.js} +1 -1
  70. package/dist/client/static/js/{index-6fx2t6y7.js → index-b42t14wk.js} +13 -13
  71. package/dist/client/static/js/{index-pbsm2vw7.js → index-cqaz1281.js} +2 -2
  72. package/dist/client/static/js/{index-pfbyfab5.js → index-df4yxfzd.js} +2 -2
  73. package/dist/client/static/js/{index-yq9vnd1y.js → index-dfqmwm7j.js} +2 -2
  74. package/dist/client/static/js/{index-0c6vpk89.js → index-e1yz59fa.js} +2 -2
  75. package/dist/client/static/js/{index-ce4vytm6.js → index-e6any867.js} +2 -2
  76. package/dist/client/static/js/index-f4vr1c6e.css +1 -0
  77. package/dist/client/static/js/{index-cytks03p.js → index-feffxxss.js} +2 -2
  78. package/dist/client/static/js/{index-c6kx7s6a.js → index-gsxebrq9.js} +2 -2
  79. package/dist/client/static/js/{index-s78n0dtv.js → index-hga3e13s.js} +2 -2
  80. package/dist/client/static/js/{index-ajjq0b8y.js → index-hw14rhen.js} +2 -2
  81. package/dist/client/static/js/{index-sj4y8kj2.js → index-j17h4z6f.js} +2 -2
  82. package/dist/client/static/js/{index-7w3gqw2b.js → index-kh6vp5w5.js} +1 -1
  83. package/dist/client/static/js/{index-djv15k5s.js → index-ktbrmp29.js} +2 -2
  84. package/dist/client/static/js/{index-2z9wrb46.js → index-mphhvgm9.js} +2 -2
  85. package/dist/client/static/js/{index-rebnv57p.js → index-mq6s2faf.js} +2 -2
  86. package/dist/client/static/js/index-mvykbyhe.js +1 -0
  87. package/dist/client/static/js/{index-ngk9h0v9.js → index-nh29fkk9.js} +2 -2
  88. package/dist/client/static/js/{index-gn92c6hp.js → index-p0ez6hqd.js} +2 -2
  89. package/dist/client/static/js/{index-e7yf273s.js → index-pkes9492.js} +2 -2
  90. package/dist/client/static/js/{index-hz177dr2.js → index-pxtff3ez.js} +2 -2
  91. package/dist/client/static/js/{index-fg965t62.js → index-pysqpc5n.js} +2 -2
  92. package/dist/client/static/js/{index-4jk8ngjg.js → index-q3qpm7jn.js} +2 -2
  93. package/dist/client/static/js/{index-55hq7tnj.js → index-qh753ynv.js} +1 -1
  94. package/dist/client/static/js/{index-ntcqyqd5.js → index-qx6x4z0y.js} +2 -2
  95. package/dist/client/static/js/{index-agdbjh5k.js → index-r8cc80w5.js} +2 -2
  96. package/dist/client/static/js/{index-9dnkfpx4.js → index-rab39785.js} +2 -2
  97. package/dist/client/static/js/index-rt6ac0kk.js +478 -0
  98. package/dist/client/static/js/{index-haaz8t7e.js → index-sk9ej289.js} +2 -2
  99. package/dist/client/static/js/{index-ds6a2cx7.js → index-sr7sdm2t.js} +5 -5
  100. package/dist/client/static/js/index-v5dbrq83.js +2 -0
  101. package/dist/client/static/js/index-w5q9ymf4.js +1 -0
  102. package/dist/client/static/js/{index-x2kb1kx5.js → index-x7a5jpvq.js} +3 -3
  103. package/dist/client/static/js/{index-re1xz433.js → index-x7m6dmt4.js} +1 -1
  104. package/dist/client/static/js/index-xsts4pqm.js +314 -0
  105. package/dist/client/static/js/index-y1p3bdsw.js +9 -0
  106. package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
  107. package/dist/client/static/js/{infoDiagram-VRGFBTTK-mh6yks62.js → infoDiagram-VRGFBTTK-0anekyhb.js} +2 -2
  108. package/dist/client/static/js/ini-2gvjwh83.js +1 -0
  109. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-hnfqppnv.js → ishikawaDiagram-OU5B5YK6-zxpmfkjb.js} +2 -2
  110. package/dist/client/static/js/java-1xwcq79s.js +1 -0
  111. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-s4nv1f3q.js → journeyDiagram-ZHPQQLJL-1e86fzra.js} +3 -3
  112. package/dist/client/static/js/json-4pqjabgq.js +1 -0
  113. package/dist/client/static/js/jsx-wcsss15s.js +1 -0
  114. package/dist/client/static/js/{julia-yre4bxb9.js → julia-2eekpjq8.js} +1 -1
  115. package/dist/client/static/js/{kanban-definition-PNTS6WVX-t8kbfefp.js → kanban-definition-PNTS6WVX-e85hhmr1.js} +6 -6
  116. package/dist/client/static/js/lua-h7vjcn0h.js +1 -0
  117. package/dist/client/static/js/markdown-f30jjjh9.js +1 -0
  118. package/dist/client/static/js/{mermaid.core-0784021p.js → mermaid.core-jpcrnzyw.js} +6 -6
  119. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-swkkze8c.js → mindmap-definition-NLK3R4M7-xwy5928e.js} +5 -5
  120. package/dist/client/static/js/one-dark-pro-r0tswz8r.js +1 -0
  121. package/dist/client/static/js/one-light-xzcfrptf.js +1 -0
  122. package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +1 -0
  123. package/dist/client/static/js/{pegDiagram-GJSIUBJH-jqayzh7z.js → pegDiagram-GJSIUBJH-7dy6pw26.js} +1 -1
  124. package/dist/client/static/js/{perl-weeskn1v.js → perl-dtn1fccw.js} +1 -1
  125. package/dist/client/static/js/{php-vf3045p9.js → php-7av78hch.js} +1 -1
  126. package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +1 -0
  127. package/dist/client/static/js/{pieDiagram-5QR66LMP-w03a65ky.js → pieDiagram-5QR66LMP-nrv2t5yn.js} +2 -2
  128. package/dist/client/static/js/properties-ymexza6q.js +1 -0
  129. package/dist/client/static/js/python-31ycwa66.js +1 -0
  130. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-2j7sfa9s.js → quadrantDiagram-O4NWA36T-3nt63xr8.js} +4 -4
  131. package/dist/client/static/js/r-t2nne4xp.js +1 -0
  132. package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +1 -0
  133. package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +1 -0
  134. package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +1 -0
  135. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +1 -0
  136. package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +1 -0
  137. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-jtkkgy34.js → railroadDiagram-XR7U4H2S-evm05hzp.js} +1 -1
  138. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-t85ckjdb.js → requirementDiagram-PLB6GJNP-tzrcmktj.js} +4 -4
  139. package/dist/client/static/js/{ruby-1a2ryzy6.js → ruby-s2bqr910.js} +1 -1
  140. package/dist/client/static/js/{rust-736r0f0v.js → rust-pcvgybk3.js} +1 -1
  141. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-5pfkw8ne.js → sankeyDiagram-IPEJSGJF-jvjd5rz8.js} +2 -2
  142. package/dist/client/static/js/{sass-tq4vw7hd.js → sass-bm32bb5k.js} +1 -1
  143. package/dist/client/static/js/{scss-x7ddw6gb.js → scss-e2dndbfa.js} +1 -1
  144. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-55vs9zv5.js → sequenceDiagram-PO4LG4MO-0zvjwx29.js} +10 -10
  145. package/dist/client/static/js/{sizeCapture-INFHLROL-pzqqd7f4.js → sizeCapture-INFHLROL-6t6g0edv.js} +1 -1
  146. package/dist/client/static/js/sql-bwnasywx.js +1 -0
  147. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-6nhrph8n.js → stateDiagram-v2-GCMORJYK-nb13b23a.js} +6 -6
  148. package/dist/client/static/js/{svelte-0hv6pak2.js → svelte-ztkaww47.js} +1 -1
  149. package/dist/client/static/js/{swimlanes-2SLR337P-6tcnxfbv.js → swimlanes-2SLR337P-ef8vmg6f.js} +1 -1
  150. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-f4sx355z.js +8 -0
  151. package/dist/client/static/js/{timeline-definition-EJHVYXUP-1dz46nt5.js → timeline-definition-EJHVYXUP-3bfph698.js} +3 -3
  152. package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +1 -0
  153. package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +1 -0
  154. package/dist/client/static/js/tsx-zfy727zs.js +1 -0
  155. package/dist/client/static/js/typescript-p3syh43m.js +1 -0
  156. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-b3jfveq6.js → usecaseDiagram-POWQR4AR-vj6yj6tc.js} +29 -29
  157. package/dist/client/static/js/{vennDiagram-UO4OBE2U-dnc3jqvp.js → vennDiagram-UO4OBE2U-9xyyabaq.js} +2 -2
  158. package/dist/client/static/js/{vue-zccj3qa5.js → vue-cbqm4bed.js} +1 -1
  159. package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +1 -0
  160. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-466m8400.js → wardleyDiagram-VNRHLVJA-zpcwgv9d.js} +4 -4
  161. package/dist/client/static/js/xml-4enq788a.js +1 -0
  162. package/dist/client/static/js/xychartDiagram-PMCCYNJV-pdr2rms2.js +7 -0
  163. package/dist/client/static/js/yaml-pjtt3jsc.js +1 -0
  164. package/package.json +1 -1
  165. package/src/cli/lib/commands/session.js +12 -1
  166. package/src/client/components/common/batch-selection/folder-state.ts +2 -2
  167. package/src/client/components/common/server-control/Panel.tsx +16 -5
  168. package/src/client/components/common/server-control/index.test.tsx +63 -9
  169. package/src/client/components/common/session-row/TrailingSlot.tsx +8 -0
  170. package/src/client/components/common/session-row/index.tsx +16 -9
  171. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -1
  172. package/src/client/components/layout/session-sidebar/ClassicView.tsx +13 -0
  173. package/src/client/components/layout/session-sidebar/HarnessFilter.tsx +175 -0
  174. package/src/client/components/layout/session-sidebar/SessionList.tsx +9 -1
  175. package/src/client/components/layout/session-sidebar/SessionsView.tsx +6 -0
  176. package/src/client/components/layout/session-sidebar/harness-filter.test.tsx +173 -0
  177. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +63 -18
  178. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +1 -1
  179. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +21 -12
  180. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -1
  181. package/src/client/components/layout/session-sidebar/modern/index.tsx +11 -2
  182. package/src/client/components/layout/session-sidebar/modern/search-field.test.tsx +96 -0
  183. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +3 -0
  184. package/src/client/components/layout/session-sidebar/variant-props.ts +7 -0
  185. package/src/client/components/mobile/SessionSidebar.tsx +14 -25
  186. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +19 -0
  187. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -1
  188. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +1 -1
  189. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -123
  190. package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +214 -0
  191. package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +126 -0
  192. package/src/client/components/workspace/chat-timeline/UserTurn.tsx +183 -0
  193. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.image.test.ts +147 -0
  194. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +51 -83
  195. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +44 -63
  196. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ReadDirectory.tsx +72 -0
  197. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ReadImage.tsx +51 -0
  198. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/read-test-util.ts +91 -0
  199. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.test.ts +80 -62
  200. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.tsx +15 -33
  201. package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +1 -1
  202. package/src/client/components/workspace/terminal-panel/copy.test.ts +179 -0
  203. package/src/client/components/workspace/terminal-panel/copy.ts +76 -0
  204. package/src/client/components/workspace/terminal-panel/mount.ts +13 -0
  205. package/src/client/data/settings/omp-schema.json +39 -18
  206. package/src/client/hooks/chat/omp/pending-child.test.ts +1 -1
  207. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +61 -0
  208. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +37 -39
  209. package/src/client/hooks/chat/omp/sidebar-filter.ts +62 -0
  210. package/src/client/hooks/chat/timeline/composer-modes.ts +10 -7
  211. package/src/client/hooks/chat/timeline/plan-review-republish.test.ts +121 -0
  212. package/src/client/hooks/chat/timeline/plan-review.ts +12 -3
  213. package/src/client/hooks/chat/timeline/session-changes.test.ts +85 -0
  214. package/src/client/hooks/chat/timeline/session-changes.ts +8 -5
  215. package/src/client/hooks/shell/servers.ts +60 -2
  216. package/src/client/hooks/ui/updates/mobile-flow.ts +56 -0
  217. package/src/client/tailwind.css +58 -0
  218. package/src/server/lib/harness/acp/acp-audit.server.ts +1 -1
  219. package/src/server/lib/harness/acp/commands.test.ts +1 -0
  220. package/src/server/lib/harness/acp/commands.ts +12 -4
  221. package/src/server/lib/harness/acp/replay-transcript.ts +32 -13
  222. package/src/server/lib/harness/acp/session-exit.ts +39 -5
  223. package/src/server/lib/harness/acp/session-transcript.server.test.ts +162 -0
  224. package/src/server/lib/harness/acp/session-transcript.server.ts +350 -0
  225. package/src/server/lib/harness/acp/session-turns.ts +67 -12
  226. package/src/server/lib/harness/acp/session.test.ts +61 -0
  227. package/src/server/lib/harness/acp/session.ts +21 -26
  228. package/src/server/lib/harness/acp/turn-outcome.server.test.ts +97 -0
  229. package/src/server/lib/harness/acp/turn-outcome.server.ts +71 -0
  230. package/src/server/lib/harness/acp/turn-silence.ts +52 -0
  231. package/src/server/lib/harness/acp/turn.test.ts +85 -3
  232. package/src/server/lib/harness/acp/turn.ts +62 -4
  233. package/src/server/lib/harness/schema.server.ts +18 -0
  234. package/src/server/lib/harness/spawn.server.ts +14 -1
  235. package/src/server/lib/lifecycle/after-listen.ts +10 -0
  236. package/src/server/lib/models/provider-icon-fetch.ts +2 -2
  237. package/src/server/lib/models/provider-icon-parse.test.ts +0 -12
  238. package/src/server/lib/models/provider-icon-parse.ts +0 -8
  239. package/src/server/lib/omp/rpc/frame-fold-contract.ts +21 -0
  240. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +4 -0
  241. package/src/server/lib/omp/rpc/frame-fold.test.ts +16 -1
  242. package/src/server/lib/omp/rpc/frame-fold.ts +42 -6
  243. package/src/server/lib/omp/rpc/manager.ts +9 -8
  244. package/src/server/lib/omp/rpc/retry-saga.ts +54 -0
  245. package/src/server/lib/omp/rpc/run-settle.server.ts +38 -5
  246. package/src/server/lib/omp/rpc/run-settle.test.ts +5 -2
  247. package/src/server/lib/omp/rpc/session-commands-dialog.test.ts +6 -20
  248. package/src/server/lib/omp/rpc/session-commands-mapping.test.ts +131 -0
  249. package/src/server/lib/omp/rpc/session-commands.test.ts +95 -116
  250. package/src/server/lib/omp/rpc/session-commands.ts +38 -17
  251. package/src/server/lib/omp/rpc/terminal-settle.test.ts +223 -0
  252. package/src/server/lib/omp/rpc/terminal-settle.ts +127 -29
  253. package/src/server/lib/omp/session/blobs.server.test.ts +34 -0
  254. package/src/server/lib/omp/session/blobs.server.ts +8 -3
  255. package/src/server/lib/omp/session/delete.server.ts +4 -0
  256. package/src/server/lib/omp/session/sidebar-activity.server.test.ts +2 -1
  257. package/src/server/lib/sessions/notify.server.test.ts +11 -3
  258. package/src/server/lib/sessions/notify.server.ts +67 -42
  259. package/src/server/lib/sessions/spawn.server.test.ts +5 -1
  260. package/src/server/lib/sessions/spawn.server.ts +8 -3
  261. package/src/server/routes/agent/harness-command.test.ts +71 -0
  262. package/src/server/routes/agent/harness-command.ts +27 -13
  263. package/src/server/routes/chat/imported.ts +5 -2
  264. package/src/server/routes/chat/live-meta.ts +42 -0
  265. package/src/server/routes/chat/session.test.ts +110 -0
  266. package/src/server/routes/chat/session.ts +31 -34
  267. package/src/server/routes/sessions/answer.test.ts +62 -0
  268. package/src/server/routes/sessions/answer.ts +13 -2
  269. package/src/shared/lib/chat/composer/delegation.ts +11 -7
  270. package/src/shared/lib/chat/export-markdown.ts +19 -0
  271. package/src/shared/lib/chat/orchestration/notice.test.ts +118 -0
  272. package/src/shared/lib/chat/orchestration/notice.ts +183 -0
  273. package/src/shared/lib/chat/timeline/omp-callbacks.ts +6 -1
  274. package/src/shared/lib/chat/transcript-rows.ts +22 -0
  275. package/src/shared/lib/fs/file-kind.test.ts +46 -3
  276. package/src/shared/lib/fs/file-kind.ts +40 -9
  277. package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
  278. package/src/shared/lib/omp/config/schema-releases.test.ts +29 -0
  279. package/src/shared/lib/workspace/harness-filter.test.ts +89 -0
  280. package/src/shared/lib/workspace/harness-filter.ts +75 -0
  281. package/src/{client/lib → shared/lib/workspace}/session-tree.test.ts +1 -1
  282. package/src/shared/lib/workspace/session-visibility.test.ts +71 -0
  283. package/src/shared/lib/workspace/session-visibility.ts +48 -23
  284. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +64 -23
  285. package/src/shared/lib/workspace/sidebar-filter-row.ts +89 -31
  286. package/dist/client/static/js/ImageView-t330jx6y.js +0 -1
  287. package/dist/client/static/js/LayoutWrapper-qp6nsw65.js +0 -2
  288. package/dist/client/static/js/Modal-sbya4ahp.js +0 -38
  289. package/dist/client/static/js/SessionsView-yqs5m8tj.js +0 -1
  290. package/dist/client/static/js/architecture-7GRP2DOG-1wqga929.js +0 -1
  291. package/dist/client/static/js/architectureDiagram-NJMV4G6O-7jcb7fgy.js +0 -36
  292. package/dist/client/static/js/bash-vv2ysp0a.js +0 -1
  293. package/dist/client/static/js/c-67jyc7sg.js +0 -1
  294. package/dist/client/static/js/c4Diagram-YGBWAQC7-vwac9za0.js +0 -38
  295. package/dist/client/static/js/cpp-crfbnwv8.js +0 -1
  296. package/dist/client/static/js/css-2re5mbea.js +0 -1
  297. package/dist/client/static/js/css-983fbv00.js +0 -1
  298. package/dist/client/static/js/cynefin-OW5HDTMX-j2dpdgkh.js +0 -1
  299. package/dist/client/static/js/diagram-ATOU4E4O-n63cpdnx.js +0 -3
  300. package/dist/client/static/js/diagram-CDSNMT55-v86p14dd.js +0 -30
  301. package/dist/client/static/js/eventmodeling-NTZA5JFV-xjvjawd3.js +0 -1
  302. package/dist/client/static/js/flowDiagram-KWPJA3E3-j21f2bfg.js +0 -1
  303. package/dist/client/static/js/gitGraph-4MIJSDKK-r0zbk95f.js +0 -1
  304. package/dist/client/static/js/graphql-npbd9fdx.js +0 -1
  305. package/dist/client/static/js/html-1cpe2xc8.js +0 -1
  306. package/dist/client/static/js/index-1sw00wm0.js +0 -2
  307. package/dist/client/static/js/index-7fwppdkn.js +0 -1
  308. package/dist/client/static/js/index-ae91g8ka.js +0 -9
  309. package/dist/client/static/js/index-b6cyn4hr.js +0 -314
  310. package/dist/client/static/js/index-efn233xp.js +0 -4
  311. package/dist/client/static/js/index-esx3zwnt.js +0 -1
  312. package/dist/client/static/js/index-fbbp5cwj.js +0 -2
  313. package/dist/client/static/js/index-g1cggqgx.js +0 -12
  314. package/dist/client/static/js/index-ghsdzs4m.js +0 -1
  315. package/dist/client/static/js/index-gs7ytgdw.js +0 -474
  316. package/dist/client/static/js/index-jqs23cc7.css +0 -1
  317. package/dist/client/static/js/index-qjsy6p86.js +0 -1
  318. package/dist/client/static/js/info-A6RAGUB7-a8xap43w.js +0 -1
  319. package/dist/client/static/js/ini-df5bw23e.js +0 -1
  320. package/dist/client/static/js/java-8j33rj1p.js +0 -1
  321. package/dist/client/static/js/json-g5ggnd94.js +0 -1
  322. package/dist/client/static/js/jsx-f6p72qpc.js +0 -1
  323. package/dist/client/static/js/lua-bahx6qze.js +0 -1
  324. package/dist/client/static/js/markdown-9dhg1fax.js +0 -1
  325. package/dist/client/static/js/one-dark-pro-h5tmw145.js +0 -1
  326. package/dist/client/static/js/one-light-x7vj1pxr.js +0 -1
  327. package/dist/client/static/js/packet-AYTQ26CC-b5bvg6v1.js +0 -1
  328. package/dist/client/static/js/pie-WAS4IAKB-77ee73zg.js +0 -1
  329. package/dist/client/static/js/properties-49mfnee4.js +0 -1
  330. package/dist/client/static/js/python-qb69wp1s.js +0 -1
  331. package/dist/client/static/js/r-s3mf2tch.js +0 -1
  332. package/dist/client/static/js/radar-RG4KPBEZ-cp79xtvb.js +0 -1
  333. package/dist/client/static/js/railroad-74A4TZTK-dcpgqhcb.js +0 -1
  334. package/dist/client/static/js/railroad-abnf-HS5TGJTU-qasqv686.js +0 -1
  335. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e46908rd.js +0 -1
  336. package/dist/client/static/js/railroad-peg-WCYAUIDC-7009t6bk.js +0 -1
  337. package/dist/client/static/js/sql-aczp05f2.js +0 -1
  338. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-7xrkrkpa.js +0 -8
  339. package/dist/client/static/js/treeView-Q6P3EWNA-tpn62q8j.js +0 -1
  340. package/dist/client/static/js/treemap-WGGIJYW6-w910f1g4.js +0 -1
  341. package/dist/client/static/js/tsx-s1shkfg9.js +0 -1
  342. package/dist/client/static/js/typescript-htx9v6bf.js +0 -1
  343. package/dist/client/static/js/wardley-WFR3VGLG-pt9tq808.js +0 -1
  344. package/dist/client/static/js/xml-wr1dxav5.js +0 -1
  345. package/dist/client/static/js/xychartDiagram-PMCCYNJV-kryrpqp1.js +0 -7
  346. package/dist/client/static/js/yaml-0y9fdskg.js +0 -1
  347. /package/src/{client/lib → shared/lib/workspace}/session-tree.ts +0 -0
@@ -0,0 +1,350 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The transcript an ACP session writes for itself.
8
+ *
9
+ * A chat Kabmo spawns SERVER-SIDE — an orchestration worker, a CLI child — has
10
+ * no tab, and the client is the only writer of `chat_sessions` for an ACP chat.
11
+ * The agent holds the conversation, but `session/load` is the only way to read
12
+ * it back and that needs a dead process. So the frames the driver already
13
+ * receives are folded here, as they stream, into the rows the timeline reads.
14
+ *
15
+ * The store is `acp_transcripts`, NOT `chat_sessions`: a tab that IS open keeps
16
+ * writing the richer row (attachment chips, notice rows) and must not be
17
+ * overwritten by this fallback. The loader prefers `chat_sessions` and reads
18
+ * this table only when that row is empty.
19
+ *
20
+ * The fold is deliberately the same one the reload path uses
21
+ * (`chatMessageFromEvent`), so a recorded row and a replayed row agree.
22
+ */
23
+
24
+ import { getDb } from '@/server/db.server';
25
+ import { chatMessageFromEvent } from '@/server/lib/harness/acp/replay-transcript';
26
+ import { hasAssistantRow } from '@/shared/lib/chat/transcript-rows';
27
+ import {
28
+ pairToolOutputs,
29
+ putToolResult,
30
+ recordToolResult,
31
+ resultDetails,
32
+ type ToolResultHost,
33
+ type ToolResultRecord,
34
+ } from '@/shared/lib/chat/omp/tool-results';
35
+ import { toolResultText } from '@/shared/lib/omp/session/mapper';
36
+ import { extractToolImages } from '@/shared/lib/omp/session/tool-images';
37
+ import type { ChatMessageData } from '@/shared/types/chat';
38
+ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
39
+
40
+ /** One write per burst. A turn emits a frame per chunk; the row is the unit. */
41
+ const FLUSH_DEBOUNCE_MS = 250;
42
+ /** The display attachments an image-only prompt carries. */
43
+ function imageAttachments(images: unknown): ChatMessageData['attachments'] {
44
+ if (!Array.isArray(images)) return undefined;
45
+ const rows = images.flatMap((image) => {
46
+ if (!image || typeof image !== 'object') return [];
47
+ const record = image as { data?: unknown; mimeType?: unknown };
48
+ if (typeof record.data !== 'string' || typeof record.mimeType !== 'string') return [];
49
+ return [{
50
+ name: 'image',
51
+ preview: `data:${record.mimeType};base64,${record.data}`,
52
+ type: record.mimeType,
53
+ }];
54
+ });
55
+ return rows.length > 0 ? rows : undefined;
56
+ }
57
+
58
+ /** The newest row's clock, for deciding which copy is ahead. */
59
+ function lastRowTime(rows: readonly ChatMessageData[]): number {
60
+ let newest = 0;
61
+ for (const row of rows) {
62
+ const time = typeof row.startedAt === 'number'
63
+ ? row.startedAt
64
+ : row.date
65
+ ? Date.parse(row.date)
66
+ : 0;
67
+ if (Number.isFinite(time) && time > newest) newest = time;
68
+ }
69
+ return newest;
70
+ }
71
+
72
+ /** The client-written row, when it exists. */
73
+ async function loadStoredMessages(sessionId: string): Promise<ChatMessageData[]> {
74
+ const db = await getDb();
75
+ const row = await db.get<{ messages: string }>(
76
+ 'SELECT messages FROM chat_sessions WHERE session_id = ?',
77
+ [sessionId],
78
+ );
79
+ if (!row?.messages) return [];
80
+ try {
81
+ const parsed: unknown = JSON.parse(row.messages);
82
+ return Array.isArray(parsed) ? (parsed as ChatMessageData[]) : [];
83
+ } catch {
84
+ return [];
85
+ }
86
+ }
87
+
88
+ /**
89
+ * The recorded rows over the client's row, keeping what only the client has.
90
+ *
91
+ * A tab's copy carries attachment chips and notice rows this fold does not
92
+ * build; replacing it wholesale would drop them. Rows are matched by message
93
+ * id, and a user turn by its text (the composer's optimistic id is local to the
94
+ * tab, so the same prompt has two ids).
95
+ */
96
+ function mergeTranscripts(
97
+ recorded: readonly ChatMessageData[],
98
+ stored: readonly ChatMessageData[],
99
+ ): ChatMessageData[] {
100
+ if (stored.length === 0) return [...recorded];
101
+ const merged = [...stored];
102
+ const indexById = new Map(merged.map((row, index) => [row.id, index]));
103
+ const userIdByText = new Map<string, string>();
104
+ for (const row of merged) {
105
+ if (row.role === 'user' && row.content.trim()) userIdByText.set(row.content.trim(), row.id);
106
+ }
107
+ for (const row of recorded) {
108
+ const existing = indexById.get(row.id);
109
+ if (existing !== undefined) {
110
+ merged[existing] = row;
111
+ continue;
112
+ }
113
+ if (row.role === 'user' && userIdByText.has(row.content.trim())) continue;
114
+ indexById.set(row.id, merged.length);
115
+ merged.push(row);
116
+ if (row.role === 'user' && row.content.trim()) userIdByText.set(row.content.trim(), row.id);
117
+ }
118
+ return merged;
119
+ }
120
+
121
+ /**
122
+ * Fold one session's frames into transcript rows and persist them.
123
+ *
124
+ * One instance per live ACP session. `recordPrompt` is called by the driver
125
+ * (the agent never echoes a live user turn), `record` by `emit`, and `flush`
126
+ * on the turn's end and on process exit.
127
+ */
128
+ export class AcpTranscriptRecorder {
129
+ private readonly rows: ChatMessageData[] = [];
130
+ private readonly indexById = new Map<string, number>();
131
+ private readonly toolResultsRef = { current: new Map<string, ToolResultRecord>() };
132
+ private readonly lastToolMessageRef = { current: null as ChatMessageData | null };
133
+ private readonly host: ToolResultHost = {
134
+ toolResultsRef: this.toolResultsRef,
135
+ lastToolMessageRef: this.lastToolMessageRef,
136
+ };
137
+ private timer: ReturnType<typeof setTimeout> | undefined;
138
+ private dirty = false;
139
+ private promptSeq = 0;
140
+ private disposed = false;
141
+
142
+ constructor(private readonly sessionId: () => string) {}
143
+
144
+ /**
145
+ * Load the rows a previous process recorded for this session.
146
+ *
147
+ * A resumed chat keeps its id, and the recorder starts empty in a new
148
+ * process; without this the first flush would replace the whole conversation
149
+ * with the new turn. Called once, before the first prompt.
150
+ */
151
+ async hydrate(): Promise<void> {
152
+ const recorded = await loadAcpTranscript(this.sessionId());
153
+ const stored = await loadStoredMessages(this.sessionId());
154
+ // The client's row is richer (attachment chips, notices); the recorder's
155
+ // may be ahead (a turn no tab wrote). Take whichever is newer, so the
156
+ // recorder's next flush is a superset of both.
157
+ const base = lastRowTime(stored) > lastRowTime(recorded) ? stored : recorded;
158
+ for (const row of base) this.upsert(row);
159
+ this.dirty = false;
160
+ }
161
+
162
+ /** Record the user turn. The ACP mapper drops live `user_message` frames as
163
+ * receipts for a bubble the composer drew, so this is the only copy. */
164
+ recordPrompt(text: string, images?: unknown): void {
165
+ if (this.disposed) return;
166
+ const content = text.trim();
167
+ if (!content) return;
168
+ const attachments = imageAttachments(images);
169
+ this.upsert({
170
+ id: `prompt-${++this.promptSeq}-${Date.now()}`,
171
+ role: 'user',
172
+ content,
173
+ startedAt: Date.now(),
174
+ ...(attachments ? { attachments } : {}),
175
+ });
176
+ this.schedule();
177
+ }
178
+
179
+ /** Fold one agent frame. Unknown frames are ignored, never guessed at. */
180
+ record(event: AgentEvent): void {
181
+ if (this.disposed) return;
182
+ switch (event.type) {
183
+ case 'user_turn':
184
+ this.recordPrompt(String(event.message ?? ''), event.images);
185
+ return;
186
+ case 'message_start':
187
+ case 'message_update':
188
+ case 'message_end': {
189
+ const message = event.message;
190
+ if (!message || typeof message !== 'object' || Array.isArray(message)) return;
191
+ const record = message as Record<string, unknown>;
192
+ if (record.role === 'toolResult') {
193
+ recordToolResult(record, this.host);
194
+ this.repaint(typeof record.toolCallId === 'string' ? record.toolCallId : undefined);
195
+ return;
196
+ }
197
+ const row = chatMessageFromEvent(event);
198
+ if (!row) return;
199
+ this.upsert(pairToolOutputs(row, this.host));
200
+ if (event.type === 'message_end') this.schedule();
201
+ return;
202
+ }
203
+ case 'tool_execution_start': {
204
+ const callId = typeof event.toolCallId === 'string' ? event.toolCallId : undefined;
205
+ if (!callId) return;
206
+ putToolResult(this.host, callId, { output: '', startedAt: Date.now(), pending: true });
207
+ this.repaint(callId);
208
+ return;
209
+ }
210
+ case 'tool_execution_update': {
211
+ const callId = typeof event.toolCallId === 'string' ? event.toolCallId : undefined;
212
+ if (!callId) return;
213
+ const stored = this.toolResultsRef.current.get(callId);
214
+ const output = typeof event.output === 'string' && event.output.length > 0
215
+ ? event.output
216
+ : toolResultText(event.partialResult);
217
+ const details = resultDetails(event) ?? stored?.details;
218
+ putToolResult(this.host, callId, {
219
+ output: output || stored?.output || '',
220
+ ...(details ? { details } : {}),
221
+ pending: true,
222
+ });
223
+ this.repaint(callId);
224
+ return;
225
+ }
226
+ case 'tool_execution_end': {
227
+ const callId = typeof event.toolCallId === 'string' ? event.toolCallId : undefined;
228
+ if (!callId) return;
229
+ const startedAt = this.toolResultsRef.current.get(callId)?.startedAt;
230
+ const images = extractToolImages(event.result);
231
+ putToolResult(this.host, callId, {
232
+ output: typeof event.output === 'string' && event.output.length > 0
233
+ ? event.output
234
+ : toolResultText(event.result),
235
+ isError: event.isError === true,
236
+ details: resultDetails(event),
237
+ pending: false,
238
+ ...(startedAt !== undefined ? { durationMs: Math.max(0, Date.now() - startedAt) } : {}),
239
+ ...(images.length > 0 ? { images } : {}),
240
+ });
241
+ this.repaint(callId);
242
+ return;
243
+ }
244
+ case 'agent_end':
245
+ void this.flush();
246
+ return;
247
+ default:
248
+ return;
249
+ }
250
+ }
251
+
252
+ /** Persist the rows so far. A no-op when nothing changed. */
253
+ async flush(): Promise<void> {
254
+ if (!this.dirty || this.disposed) return;
255
+ const sessionId = this.sessionId();
256
+ if (!sessionId) return;
257
+ this.dirty = false;
258
+ const stored = await loadStoredMessages(sessionId);
259
+ const rows = mergeTranscripts(this.rows, stored);
260
+ try {
261
+ const db = await getDb();
262
+ await db.run(
263
+ `INSERT INTO acp_transcripts (session_id, messages, updated_at)
264
+ VALUES (?, ?, ?)
265
+ ON CONFLICT(session_id) DO UPDATE SET
266
+ messages = excluded.messages,
267
+ updated_at = excluded.updated_at`,
268
+ [sessionId, JSON.stringify(rows), Date.now()],
269
+ );
270
+ // A turn no tab wrote would otherwise be invisible: the loader prefers
271
+ // `chat_sessions` when it holds an answer. Write it only when this copy is
272
+ // AHEAD, so an open tab's newer (and richer) row is never replaced.
273
+ if (!hasAssistantRow(stored) || lastRowTime(rows) > lastRowTime(stored)) {
274
+ const titleRow = await db.get<{ title: string }>(
275
+ 'SELECT title FROM chat_sessions WHERE session_id = ?',
276
+ [sessionId],
277
+ );
278
+ await db.run(
279
+ `INSERT INTO chat_sessions (session_id, title, messages, updated_at)
280
+ VALUES (?, ?, ?, CURRENT_TIMESTAMP)
281
+ ON CONFLICT(session_id) DO UPDATE SET
282
+ messages = excluded.messages,
283
+ updated_at = CURRENT_TIMESTAMP`,
284
+ [sessionId, titleRow?.title || `Session ${sessionId}`, JSON.stringify(rows)],
285
+ );
286
+ }
287
+ } catch (error) {
288
+ // A failed write is not a lost turn: the next frame retries, and the
289
+ // restore path can replay the agent's own history.
290
+ this.dirty = true;
291
+ console.error('[harness] could not record the ACP transcript:', error);
292
+ }
293
+ }
294
+
295
+ /** Flush the last rows and stop the timer (process exit). */
296
+ dispose(): void {
297
+ if (this.timer !== undefined) clearTimeout(this.timer);
298
+ this.timer = undefined;
299
+ void this.flush();
300
+ this.disposed = true;
301
+ }
302
+
303
+ private upsert(row: ChatMessageData): void {
304
+ const existing = this.indexById.get(row.id);
305
+ if (existing !== undefined) {
306
+ this.rows[existing] = row;
307
+ } else {
308
+ this.indexById.set(row.id, this.rows.length);
309
+ this.rows.push(row);
310
+ }
311
+ this.dirty = true;
312
+ }
313
+
314
+ /** Re-pair the row that owns a call after its result changed. */
315
+ private repaint(callId: string | undefined): void {
316
+ if (!callId) return;
317
+ for (let index = this.rows.length - 1; index >= 0; index -= 1) {
318
+ const row = this.rows[index];
319
+ if (!row.toolCalls?.some((call) => call.id === callId)) continue;
320
+ this.rows[index] = pairToolOutputs(row, this.host);
321
+ this.dirty = true;
322
+ return;
323
+ }
324
+ }
325
+
326
+ private schedule(): void {
327
+ if (this.timer !== undefined) return;
328
+ this.timer = setTimeout(() => {
329
+ this.timer = undefined;
330
+ void this.flush();
331
+ }, FLUSH_DEBOUNCE_MS);
332
+ this.timer.unref?.();
333
+ }
334
+ }
335
+
336
+ /** The recorded rows for a session, or empty when it has none. */
337
+ export async function loadAcpTranscript(sessionId: string): Promise<ChatMessageData[]> {
338
+ const db = await getDb();
339
+ const row = await db.get<{ messages: string }>(
340
+ 'SELECT messages FROM acp_transcripts WHERE session_id = ?',
341
+ [sessionId],
342
+ );
343
+ if (!row?.messages) return [];
344
+ try {
345
+ const parsed: unknown = JSON.parse(row.messages);
346
+ return Array.isArray(parsed) ? (parsed as ChatMessageData[]) : [];
347
+ } catch {
348
+ return [];
349
+ }
350
+ }
@@ -40,7 +40,12 @@ import { saveAcpUsage } from '@/server/lib/harness/acp/acp-telemetry.server';
40
40
  import { lastAssistantText } from '@/server/lib/omp/session/goal-driver.server';
41
41
  import { noteChildOutcome } from '@/server/lib/sessions/notify.server';
42
42
  import { saveSessionAnswer } from '@/server/lib/sessions/answers.server';
43
+ import { transcriptFailure } from '@/server/lib/harness/acp/turn-outcome.server';
44
+ import type { HarnessId } from '@/shared/lib/harness/catalog';
43
45
  import type { AcpTurns, AcpTurnEndInfo } from '@/server/lib/harness/acp/turn';
46
+ import { driveAcpGoalAfterTurn } from '@/server/lib/harness/acp/acp-goal-driver.server';
47
+ import type { AcpGoalHost } from '@/server/lib/harness/acp/acp-goal.server';
48
+ import { assistantTextOf, spawnsBackgroundWork } from '@/server/lib/harness/acp/background-work';
44
49
 
45
50
  /** What a turn reads and moves on the session. */
46
51
  export interface AcpTurnTarget {
@@ -59,6 +64,35 @@ export interface AcpTurnTarget {
59
64
  send(command: Record<string, unknown>): Promise<unknown>;
60
65
  }
61
66
 
67
+ /** What the turn-end bookkeeping moves on the session. */
68
+ export interface AcpTurnEndHost
69
+ extends Omit<AcpTurnTarget, 'runModel' | 'sessionId' | 'isAlive' | 'isBusy' | 'send'>, AcpGoalHost {
70
+ assistantCount: number;
71
+ usage: { endTurn(): void };
72
+ background: { start(baseline: string): void };
73
+ }
74
+
75
+ /**
76
+ * Everything a turn's END moves: the closed message, the durable marker, the
77
+ * queue, the child outcome, the background probe and the goal driver.
78
+ *
79
+ * A turn closed by the SILENCE CEILING is interrupted, not failed — nothing
80
+ * observed it fail — and its reason still travels so a coordinator can act.
81
+ */
82
+ export function endAcpTurn(host: AcpTurnEndHost, info: AcpTurnEndInfo): Promise<void> {
83
+ if (info.closedMessage) host.assistantCount += 1;
84
+ host.usage.endTurn();
85
+ const reported = settleAcpTurn(host, info);
86
+ // A subagent outlives the turn that spawned it: antigravity answers
87
+ // `end_turn` right after `invoke_subagent`, and its completion is held until
88
+ // the next request (upstream #1461). Probe the transcript instead.
89
+ if (!info.cancelled && info.failed !== true && spawnsBackgroundWork(info.message)) {
90
+ host.background.start(assistantTextOf(info.message));
91
+ }
92
+ void driveAcpGoalAfterTurn(host, info.message, { cancelled: info.cancelled === true }).catch(() => {});
93
+ return reported;
94
+ }
95
+
62
96
  /** Open a turn and mark the run live. Returns the ACK, never the turn. */
63
97
  export function beginAcpTurn(
64
98
  target: AcpTurnTarget,
@@ -73,7 +107,10 @@ export function beginAcpTurn(
73
107
  }
74
108
 
75
109
  /** Turn-end bookkeeping: the closed message, the badge, then the queue. */
76
- export function settleAcpTurn(target: AcpTurnTarget, info: AcpTurnEndInfo): void {
110
+ export async function settleAcpTurn(
111
+ target: AcpTurnTarget & { harness: HarnessId },
112
+ info: AcpTurnEndInfo,
113
+ ): Promise<void> {
77
114
  if (info.closedMessage) target.messageCount += 1;
78
115
  // ACP has no transcript to re-read, so the last usage snapshot is what lets
79
116
  // the Context ring answer after a reload or a restart.
@@ -86,30 +123,48 @@ export function settleAcpTurn(target: AcpTurnTarget, info: AcpTurnEndInfo): void
86
123
  totalCost: target.totalCost,
87
124
  runModel: target.runModel,
88
125
  });
126
+ // A turn the envelope calls COMPLETED may still have failed: `omp-acp` answers
127
+ // a provider error as ordinary text and ends the turn normally, so its own
128
+ // transcript is the only record of the failure (see `turn-outcome.server.ts`).
129
+ const recorded = info.failed === true || info.cancelled === true || info.stranded === true
130
+ ? null
131
+ : await transcriptFailure(target.harness, target.sessionId);
132
+ // A turn closed by the silence ceiling is INTERRUPTED, not failed: nothing
133
+ // observed it fail, and the reason still travels so the coordinator can act.
134
+ const status = info.cancelled === true || info.stranded === true
135
+ ? 'interrupted'
136
+ : info.failed === true || recorded !== null
137
+ ? 'failed'
138
+ : 'completed';
89
139
  // A cancelled turn is an `abort` badge; every other ending a `finish` — and a
90
140
  // failed turn carries the agent's own reason, which is the only copy a tab
91
141
  // that never opened the session can read.
92
- const failure = info.failed === true
93
- ? (info.failure?.trim() || 'The agent ended the turn without an answer')
142
+ const failure = status === 'failed'
143
+ ? (info.failure?.trim() || recorded || 'The agent ended the turn without an answer')
94
144
  : null;
95
145
  target.markStream(info.stopReason === 'cancelled' ? 'abort' : 'finish', failure);
96
146
  // Todo/plan/telemetry panels read their own topics; without this signal an
97
147
  // ACP turn's usage and titles never republished (the RPC settle path does it).
98
148
  emitRealtimeSignal('session-data-dirty', target.sessionId);
99
149
  const finalText = lastAssistantText([info.message]);
100
- if (finalText) void saveSessionAnswer(target.sessionId, finalText).catch(() => {});
101
- const status = info.cancelled === true
102
- ? 'interrupted'
103
- : info.failed === true
104
- ? 'failed'
105
- : 'completed';
106
- void noteChildOutcome({
150
+ // Only a real answer is stored as one: on a failed turn the text IS the
151
+ // error, and `session_answers` is what `kabmo session output` prints.
152
+ if (finalText && status === 'completed') {
153
+ void saveSessionAnswer(target.sessionId, finalText).catch(() => {});
154
+ }
155
+ const reported = noteChildOutcome({
107
156
  sessionId: target.sessionId,
108
157
  status,
109
- output: finalText,
110
- ...(status === 'failed' ? { failure: info.failure ?? 'The agent ended the turn without an answer' } : {}),
158
+ // A failed turn's text is the error, not a report: the reason is the detail.
159
+ output: status === 'completed' ? finalText : null,
160
+ ...(status === 'failed'
161
+ ? { failure: failure as string }
162
+ : status === 'interrupted' && info.stranded === true
163
+ ? { failure: info.failure ?? 'The agent stopped reporting progress.' }
164
+ : {}),
111
165
  }).catch((error: unknown) => {
112
166
  console.error('[sessions] could not record an ACP child outcome:', error);
113
167
  });
114
168
  scheduleQueueDelivery(target);
169
+ return reported;
115
170
  }
@@ -14,6 +14,12 @@
14
14
  import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
15
15
  import { isolateDb, releaseDb } from '@/test-support/isolated-db';
16
16
  import { mountSession, notify } from '@/server/lib/harness/acp/session.test-util';
17
+ import { createSessionRelation } from '@/server/lib/sessions/relations.server';
18
+ import { materializeNotice } from '@/server/lib/sessions/notify.server';
19
+ import {
20
+ parseChildOutcomeNotice,
21
+ parseOrchestrationBlock,
22
+ } from '@/shared/lib/chat/orchestration/notice';
17
23
  import type { AcpConfigOption } from '@/server/lib/harness/acp/protocol';
18
24
 
19
25
  // A prompt reaches the title writer (`harness/session-title.server.ts`), which
@@ -231,3 +237,58 @@ describe('ACP model identity', () => {
231
237
  });
232
238
  });
233
239
  });
240
+
241
+ describe('a delegated ACP worker reports its outcome', () => {
242
+ /** The exit hook is private; the suite drives it the way the process does. */
243
+ function exit(
244
+ session: ReturnType<typeof mountSession>['session'],
245
+ stderrTail: string,
246
+ ): Promise<void> {
247
+ return (session as unknown as { onExit: (info: { code: number | null; stderrTail: string }) => Promise<void> })
248
+ .onExit({ code: 1, stderrTail });
249
+ }
250
+
251
+ test('a process that dies mid-turn tells its coordinator, with the stderr tail', async () => {
252
+ const { session, turn } = mountSession();
253
+ await createSessionRelation({ sessionId: 'acp-1', parentSessionId: 'parent-acp' });
254
+ await session.send({ type: 'prompt', message: 'do the work' });
255
+ await turn.started;
256
+
257
+ await exit(session, 'Error: provider exploded');
258
+
259
+ const text = await materializeNotice('parent-acp');
260
+ expect(text).not.toBeNull();
261
+ const block = parseOrchestrationBlock(text ?? '');
262
+ const [entry] = parseChildOutcomeNotice(block?.body ?? '');
263
+ expect(entry?.status).toBe('failed');
264
+ expect(entry?.failure).toContain('provider exploded');
265
+ });
266
+
267
+ test('a turn closed by the silence ceiling is interrupted, with its reason', async () => {
268
+ const { session } = mountSession();
269
+ await createSessionRelation({ sessionId: 'acp-1', parentSessionId: 'parent-acp' });
270
+
271
+ await session.onTurnEnded({
272
+ closedMessage: false,
273
+ stranded: true,
274
+ failed: true,
275
+ failure: 'The agent stopped reporting progress; the turn was closed after a long silence.',
276
+ });
277
+
278
+ const text = await materializeNotice('parent-acp');
279
+ const block = parseOrchestrationBlock(text ?? '');
280
+ const [entry] = parseChildOutcomeNotice(block?.body ?? '');
281
+ // Nothing observed it fail, so it is not reported as a failure.
282
+ expect(entry?.status).toBe('interrupted');
283
+ expect(entry?.failure).toContain('stopped reporting');
284
+ });
285
+
286
+ test('a process that exits between turns reports nothing', async () => {
287
+ const { session } = mountSession();
288
+ await createSessionRelation({ sessionId: 'acp-1', parentSessionId: 'parent-acp' });
289
+
290
+ await exit(session, 'Error: idle crash');
291
+
292
+ expect(await materializeNotice('parent-acp')).toBeNull();
293
+ });
294
+ });
@@ -29,22 +29,19 @@ import { startAcpSession } from '@/server/lib/harness/acp/session-start';
29
29
  import type { AcpConfigOption, AcpId, AcpProtocolVersion, AcpSessionModeState } from '@/server/lib/harness/acp/protocol';
30
30
  import { promptBlocks } from '@/server/lib/harness/acp/prompt';
31
31
  import { setAcpConfig, setAcpMode, settlePermissionDialog, stampMessageModel } from '@/server/lib/harness/acp/session-config';
32
- import { beginAcpTurn, settleAcpTurn } from '@/server/lib/harness/acp/session-turns';
33
- import { driveAcpGoalAfterTurn } from '@/server/lib/harness/acp/acp-goal-driver.server';
32
+ import { beginAcpTurn, endAcpTurn } from '@/server/lib/harness/acp/session-turns';
34
33
  import { capabilitiesFrom } from '@/server/lib/harness/launch';
35
34
  import { PendingPermissions } from '@/server/lib/harness/acp/permissions';
36
35
  import { cancelAllAcpPermissions } from '@/server/lib/harness/acp/session-permissions';
37
36
  import { handleSessionNotification } from '@/server/lib/harness/acp/session-notifications';
38
37
  import { AcpUsageMeter, type AcpContextUsage } from '@/server/lib/harness/acp/session-usage';
39
38
  import { handleAcpClientRequest, handleAcpCancelRequest, type AcpClientRequestAnswer } from '@/server/lib/harness/acp/session-requests';
40
- import { acpExitFailureFrames } from '@/server/lib/harness/acp/session-exit';
39
+ import { reportAcpExit } from '@/server/lib/harness/acp/session-exit';
41
40
  import { SessionListeners } from '@/server/lib/harness/acp/session-listeners';
42
41
  import {
43
42
  AcpBackgroundProbe,
44
43
  BACKGROUND_LOAD_TIMEOUT_MS,
45
- assistantTextOf,
46
44
  deliverBackgroundNotice,
47
- spawnsBackgroundWork,
48
45
  } from '@/server/lib/harness/acp/background-work';
49
46
  import { acpWebState } from '@/server/lib/harness/acp/session-web-state';
50
47
  import { acpIdleReaper } from '@/server/lib/harness/acp/session-idle';
@@ -79,7 +76,7 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
79
76
  /** Assistant messages the mapper closed, for the same panel. */
80
77
  assistantCount = 0;
81
78
  /** The last `usage_update` the agent reported, or null when it never did. */
82
- private readonly usage = new AcpUsageMeter();
79
+ readonly usage = new AcpUsageMeter();
83
80
  get contextUsage(): AcpContextUsage | null { return this.usage.contextUsage; }
84
81
  get totalCost(): number { return this.usage.totalCost; }
85
82
  get usageTokens(): number { return this.usage.usageTokens; }
@@ -97,7 +94,7 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
97
94
  /** The quiet-window reclaim; the rules live in `session-idle.ts`. */
98
95
  readonly idle: IdleReaper;
99
96
  /** Watches for work that finishes after `end_turn`; see `background-work.ts`. */
100
- private readonly background: AcpBackgroundProbe;
97
+ readonly background: AcpBackgroundProbe;
101
98
  private readonly mapper = new AcpFrameMapper();
102
99
  private readonly events = new SessionListeners();
103
100
  readonly permissions = new PendingPermissions();
@@ -198,6 +195,8 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
198
195
  return this.proc.steer(this.sessionId, blocks, queue);
199
196
  }
200
197
 
198
+ /** Record a mid-turn user message; the ACP mapper drops live user frames. */
199
+ recordUserTurn(message: string, images: unknown): void { this.emit({ type: 'user_turn', message, images }); }
201
200
  /**
202
201
  * The durable run marker (`session_stream_state`), the row the sidebar's
203
202
  * spinner and a reattaching tab's "still running" answer read. A field so a
@@ -208,20 +207,10 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
208
207
  void markStreamStatus(this.sessionId, status, status === 'stream' ? this.runModel : undefined, failure).catch(() => {});
209
208
  };
210
209
 
211
- /** Turn-end bookkeeping the panels read — see `session-turns.ts`. A cancelled
212
- * turn closes the marker as an `abort` badge, every other ending a `finish`.
213
- * The goal driver then audits the closed message and may open the next turn. */
214
- onTurnEnded(info: AcpTurnEndInfo): void {
215
- if (info.closedMessage) this.assistantCount += 1;
216
- this.usage.endTurn();
217
- settleAcpTurn(this, info);
218
- // A subagent outlives the turn that spawned it: antigravity answers
219
- // `end_turn` right after `invoke_subagent`, and its completion is held
220
- // until the next request (upstream #1461). Probe the transcript instead.
221
- if (!info.cancelled && info.failed !== true && spawnsBackgroundWork(info.message)) {
222
- this.background.start(assistantTextOf(info.message));
223
- }
224
- void driveAcpGoalAfterTurn(this, info.message, { cancelled: info.cancelled === true }).catch(() => {});
210
+ /** Turn-end bookkeeping the panels read — see `endAcpTurn`. Returns the
211
+ * child-outcome write, so a caller that must observe it can await it. */
212
+ onTurnEnded(info: AcpTurnEndInfo): Promise<void> {
213
+ return endAcpTurn(this, info);
225
214
  }
226
215
 
227
216
  /** Dispatcher seam: stop the turn and answer every parked approval. */
@@ -281,12 +270,18 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
281
270
  this.background.stop();
282
271
  this.promptCount += 1;
283
272
  this.usage.beginTurn();
284
- return beginAcpTurn(this, this.turns, message, images);
273
+ const ack = beginAcpTurn(this, this.turns, message, images);
274
+ // Only a delivered turn is recorded: a refusal must not leave a user row.
275
+ this.emit({ type: 'user_turn', message, images });
276
+ return ack;
285
277
  }
286
278
 
287
279
  private onNotification(method: string, params: Record<string, unknown>): void {
288
280
  // A long turn emits no commands but plenty of `session/update` frames.
289
281
  this.idle.reset();
282
+ // The same frames are the only evidence a turn is still alive: ACP has no
283
+ // probe, so the silence ceiling is what bounds a wedged agent.
284
+ this.turns.noteActivity();
290
285
  // `$/cancel_request` names an agent→client request the agent no longer
291
286
  // wants; the approval it parks is answered `cancelled`.
292
287
  if (handleAcpCancelRequest(this, method, params)) return;
@@ -308,14 +303,14 @@ export class AcpSession implements HarnessSession, AcpCommandHost {
308
303
  return handleAcpClientRequest(this, id, method, params);
309
304
  }
310
305
 
311
- private onExit(info: { code: number | null; stderrTail: string }): void {
306
+ /** The agent's process is gone — see `reportAcpExit`; returns its notice write. */
307
+ private onExit(info: { code: number | null; stderrTail: string }): Promise<void> {
312
308
  this.destroyed = true;
313
309
  this.background.stop();
314
310
  this.idle.stop();
315
- if (!this.closing) {
316
- for (const event of acpExitFailureFrames(this.harness, info)) this.emit(event);
317
- }
311
+ const reported = this.closing ? Promise.resolve() : reportAcpExit(this, info);
318
312
  this.destroyHook?.();
313
+ return reported;
319
314
  }
320
315
 
321
316
  destroy(): void { void this.destroyAndWait(); }