@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
@@ -25,6 +25,16 @@
25
25
  * - **The badge is written from this frame alone.** `turn_end` fires for every
26
26
  * turn of a multi-turn run and carries no `isTerminal`, so it cannot say the
27
27
  * run is over; `agent_end` is the only frame that knows.
28
+ *
29
+ * The CHILD OUTCOME is reported from here too, and it obeys one rule the rest
30
+ * of the settle does not: a run reports ONCE, at the moment it is genuinely
31
+ * over. omp retries a transient provider failure by itself and keeps the run
32
+ * open across the attempts (`agent_end {isTerminal:false}` between them, no
33
+ * terminal end until the saga resolves), so a coordinator that saw an outcome
34
+ * per attempt would be told a worker failed while that worker was still
35
+ * working. `runOutcomeReported` is the latch that makes a second settle — a
36
+ * synthesized one after lost frames, or the process exit — a no-op, and
37
+ * `auto_retry_*` is what names the reason instead of guessing it.
28
38
  */
29
39
 
30
40
  import {
@@ -38,11 +48,26 @@ import { driveGoalAfterTurn, lastAssistantText } from '@/server/lib/omp/session/
38
48
  import { noteChildOutcome } from '@/server/lib/sessions/notify.server';
39
49
  import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
40
50
  import { publishSidebarStructure } from '@/server/lib/realtime/topics.server';
51
+ import { AGENT_BUSY_REFUSAL_RE } from '@/server/lib/omp/rpc/constants';
52
+ import { deriveTurnError, turnStoppedAbnormally } from '@/shared/lib/omp/session/turn-error';
53
+ import type { ChildOutcomeNotice } from '@/server/lib/sessions/notify.server';
41
54
 
42
55
  /** The wrapper surface a terminal settle touches. */
43
56
  export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
44
57
  /** Abort verdict captured from `message_end` — see `SessionFrameHost.runAborted`. */
45
58
  runAborted: boolean;
59
+ /** The provider failure the run's last settled assistant message carried, in
60
+ * omp's own words. Captured at `message_end` because the terminal frame is
61
+ * compacted (see `endedAborted`). */
62
+ runFailure: string | null;
63
+ /** True between `auto_retry_start` and `auto_retry_end`: omp is inside a
64
+ * retry saga and the run is NOT over. */
65
+ retrySagaOpen: boolean;
66
+ /** The reason the last retry saga closed with, when it closed as a failure. */
67
+ retryFinalError: string | null;
68
+ /** Set once this RUN has told its coordinator how it ended. Cleared at
69
+ * `agent_start`, so a queued follow-up run reports its own outcome. */
70
+ runOutcomeReported: boolean;
46
71
  }
47
72
 
48
73
  /**
@@ -58,11 +83,8 @@ export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
58
83
  * `message_end` (keeping only `messageCount`), and the aborted assistant message
59
84
  * is always among them — measured on 18.16.0, `message_end`
60
85
  * (`role: "assistant"`, `stopReason: "aborted"`) arrives before `agent_end`.
61
- * Reading only the frame therefore reports a stopped run as finished, and the
62
- * settle then titles the session, audits the goal and releases the queue for a
63
- * turn the operator cancelled. 12.7% of the runs in this workstation's own
64
- * session store (494 of 3901) exceed the 1 MiB frame ceiling, so the trimmed
65
- * case is routine, not exotic.
86
+ * 12.7% of the runs in this workstation's own session store (494 of 3901) exceed
87
+ * the 1 MiB frame ceiling, so the trimmed case is routine, not exotic.
66
88
  */
67
89
  function endedAborted(host: TerminalSettleHost, messages: unknown): boolean {
68
90
  if (host.runAborted) return true;
@@ -75,25 +97,58 @@ function endedAborted(host: TerminalSettleHost, messages: unknown): boolean {
75
97
  );
76
98
  }
77
99
 
78
- const FAILED_STOP_REASONS: Readonly<Record<string, true>> = { error: true, failed: true, failure: true };
100
+ /**
101
+ * The failure one assistant message names, or null when it did not fail.
102
+ *
103
+ * omp records the reason as FLAT fields on the message (`stopReason` /
104
+ * `errorStatus` / `errorId` / `errorMessage`) — there is no nested `error`
105
+ * object. Reading one (the shape this replaced) is why a worker whose provider
106
+ * answered "400 The model … is currently unavailable" reported to its
107
+ * coordinator as the bare sentence "The run ended with error": the reason was
108
+ * in the transcript the whole time. `deriveTurnError` is the shared read both
109
+ * render paths already use, so the notice and the timeline cannot disagree.
110
+ */
111
+ export function assistantFailure(record: Record<string, unknown>): string | null {
112
+ if (record.role !== 'assistant') return null;
113
+ if (!turnStoppedAbnormally(record)) return null;
114
+ const error = deriveTurnError(record);
115
+ const message = error?.message?.trim();
116
+ if (message) {
117
+ const status = error?.status;
118
+ // Providers usually repeat the status in their own text ("400 The model …"),
119
+ // so prefixing unconditionally printed "400 400 The model …".
120
+ if (status === undefined || message.startsWith(String(status))) return message;
121
+ return `${status} ${message}`;
122
+ }
123
+ const stop = error?.stopReason;
124
+ return stop ? `The turn ended with ${stop}.` : 'The turn ended with an error.';
125
+ }
79
126
 
80
127
  /** The failure a terminal frame reports, or null for a normal stop.
81
128
  *
82
- * Conservative on purpose: only an assistant message's own `error` text or an
83
- * explicit failure stop reason counts. A tool error is not a failed run. */
129
+ * Conservative on purpose: only an assistant message's own error does. A tool
130
+ * error is not a failed run. */
84
131
  function endedFailure(messages: unknown): string | null {
85
132
  if (!Array.isArray(messages)) return null;
86
133
  for (const entry of messages) {
87
134
  if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;
88
- const record = entry as Record<string, unknown>;
89
- const error = typeof record.error === 'string' ? record.error.trim() : '';
90
- if (record.role === 'assistant' && error) return error;
91
- const stop = typeof record.stopReason === 'string' ? record.stopReason : '';
92
- if (FAILED_STOP_REASONS[stop] === true) return `The run ended with ${stop}`;
135
+ const failure = assistantFailure(entry as Record<string, unknown>);
136
+ if (failure) return failure;
93
137
  }
94
138
  return null;
95
139
  }
96
140
 
141
+ /** The one reason the run did not finish normally, from the most reliable
142
+ * source that has one. */
143
+ function runFailureOf(host: TerminalSettleHost, messages: unknown): string | null {
144
+ return host.retryFinalError
145
+ ?? host.runFailure
146
+ ?? endedFailure(messages)
147
+ // A terminal end while a saga is still open: omp gave up without closing it
148
+ // (or closed it with no reason). Silence would be read as success.
149
+ ?? (host.retrySagaOpen ? 'The run ended while omp was still retrying a provider error.' : null);
150
+ }
151
+
97
152
  /**
98
153
  * Write the terminal stream badge from the ending turn's own stopReason.
99
154
  *
@@ -102,7 +157,12 @@ function endedFailure(messages: unknown): string | null {
102
157
  * Re-check the current row and only upgrade `stream` rows, so a `finish`
103
158
  * written here can never clobber a newer run's live `stream`/`abort`.
104
159
  */
105
- async function markEndStatus(sessionId: string, host: TerminalSettleHost, messages: unknown): Promise<void> {
160
+ async function markEndStatus(
161
+ sessionId: string,
162
+ host: TerminalSettleHost,
163
+ messages: unknown,
164
+ failure: string | null,
165
+ ): Promise<void> {
106
166
  if (!sessionId) return;
107
167
  const current = await loadStreamStatuses();
108
168
  if (current[sessionId] !== 'stream') return;
@@ -110,7 +170,7 @@ async function markEndStatus(sessionId: string, host: TerminalSettleHost, messag
110
170
  await markStreamStatus(sessionId, 'abort');
111
171
  return;
112
172
  }
113
- await markStreamStatus(sessionId, 'finish', undefined, endedFailure(messages));
173
+ await markStreamStatus(sessionId, 'finish', undefined, failure);
114
174
  }
115
175
 
116
176
  /**
@@ -118,31 +178,68 @@ async function markEndStatus(sessionId: string, host: TerminalSettleHost, messag
118
178
  *
119
179
  * A refused prompt opens no turn, so no `agent_end` will ever settle it. The
120
180
  * check lives here because this module already owns the outcome vocabulary.
181
+ *
182
+ * A refusal for BUSY is not an outcome: the session is streaming (often
183
+ * mid-retry), nothing was delivered, and Kabmo's queue re-sends. Reporting it
184
+ * told a coordinator its worker had failed while the worker was still running.
121
185
  */
122
186
  export function noteRefusedPrompt(
123
187
  event: { type?: string; success?: unknown; command?: unknown; error?: unknown },
124
188
  sessionId: string,
125
- ): void {
126
- if (event.type !== 'response' || event.success !== false || event.command !== 'prompt' || !sessionId) return;
127
- void noteChildOutcome({
128
- sessionId,
129
- status: 'failed',
130
- failure: typeof event.error === 'string' ? event.error : 'Prompt failed',
131
- }).catch((error: unknown) => {
189
+ ): Promise<void> {
190
+ if (event.type !== 'response' || event.success !== false || event.command !== 'prompt' || !sessionId) {
191
+ return Promise.resolve();
192
+ }
193
+ const failure = typeof event.error === 'string' ? event.error : 'Prompt failed';
194
+ if (AGENT_BUSY_REFUSAL_RE.test(failure)) return Promise.resolve();
195
+ return noteChildOutcome({ sessionId, status: 'failed', failure }).catch((error: unknown) => {
132
196
  console.error('[sessions] could not record a refused prompt:', error);
133
197
  });
134
198
  }
135
199
 
136
- /** Run the side effects a terminal run end owns. */
137
- export function settleTerminalRun(host: TerminalSettleHost, messages: unknown): void {
200
+ /**
201
+ * Report a run that ended WITHOUT a terminal frame.
202
+ *
203
+ * Two paths reach this: omp answered `get_state` with `isSettled` after its
204
+ * frame stream stopped (`run-settle.server.ts`), and the omp process exited
205
+ * mid-run. Neither can produce the frame that normally carries the outcome, so
206
+ * without this a coordinator is never told — the worker simply goes quiet, and
207
+ * "no news" is indistinguishable from "still retrying".
208
+ *
209
+ * Never a success: nothing here observed the run finish, and claiming one is
210
+ * the false completion this exists to remove.
211
+ */
212
+ export function noteRunEndedWithoutFrame(
213
+ host: { sessionId: string; runOutcomeReported: boolean },
214
+ status: Extract<ChildOutcomeNotice['status'], 'failed' | 'interrupted'>,
215
+ failure: string,
216
+ ): Promise<void> {
217
+ if (!host.sessionId || host.runOutcomeReported) return Promise.resolve();
218
+ host.runOutcomeReported = true;
219
+ return noteChildOutcome({ sessionId: host.sessionId, status, failure }).catch((error: unknown) => {
220
+ console.error('[sessions] could not record a child outcome:', error);
221
+ });
222
+ }
223
+
224
+ /**
225
+ * Run the side effects a terminal run end owns.
226
+ *
227
+ * Returns the outcome write, so a caller that must observe it (a test, or a
228
+ * shutdown path that wants the row durable) can await it. The frame fold
229
+ * deliberately does not: a settle must never block the frame stream.
230
+ */
231
+ export function settleTerminalRun(host: TerminalSettleHost, messages: unknown): Promise<void> {
138
232
  const aborted = endedAborted(host, messages);
139
- const failure = aborted ? null : endedFailure(messages);
140
- if (host.sessionId) void markEndStatus(host.sessionId, host, messages);
233
+ const failure = aborted ? null : runFailureOf(host, messages);
234
+ if (host.sessionId) void markEndStatus(host.sessionId, host, messages, failure);
141
235
  // Delegation is reported here, not from the route: this frame is the only
142
236
  // moment that knows a run genuinely ended, and a synthetic `run-settle`
143
- // reconcile must report the same outcome as a real `agent_end`.
144
- if (host.sessionId) {
145
- void noteChildOutcome({
237
+ // reconcile must report the same outcome as a real `agent_end`. Exactly once
238
+ // per run — see the module header.
239
+ let reported: Promise<void> = Promise.resolve();
240
+ if (host.sessionId && !host.runOutcomeReported) {
241
+ host.runOutcomeReported = true;
242
+ reported = noteChildOutcome({
146
243
  sessionId: host.sessionId,
147
244
  status: aborted ? 'interrupted' : failure ? 'failed' : 'completed',
148
245
  output: aborted ? null : lastAssistantText(messages),
@@ -175,4 +272,5 @@ export function settleTerminalRun(host: TerminalSettleHost, messages: unknown):
175
272
  // The final answer appended after the last tool call; the sidebar's ordering
176
273
  // and time-ago labels catch up on it the same way.
177
274
  publishSidebarStructure();
275
+ return reported;
178
276
  }
@@ -118,6 +118,40 @@ describe('readBlobImage', () => {
118
118
  expect(image?.bytes).toEqual(JPEG_BYTES);
119
119
  });
120
120
 
121
+ test('a WEBP blob is labelled from its RIFF/WEBP tag', async () => {
122
+ // A `read` of a `.webp` answers with an image block, and omp externalizes it
123
+ // to the store; the tag at offset 8 is the only evidence left once the
124
+ // sibling link is pruned.
125
+ const hash = 'e'.repeat(64);
126
+ const webpBytes = Buffer.from([0x52, 0x49, 0x46, 0x46, 0x20, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50]);
127
+ await fsp.writeFile(path.join(getBlobStoreDir(), hash), webpBytes);
128
+ const image = await readBlobImage(hash);
129
+ expect(image?.mimeType).toBe('image/webp');
130
+ expect(image?.bytes).toEqual(webpBytes);
131
+ });
132
+
133
+ test('an SVG blob is labelled from its own text', async () => {
134
+ // No magic table catches an SVG; it used to answer
135
+ // `application/octet-stream`, which no browser paints.
136
+ const hash = 'f'.repeat(64);
137
+ const svgBytes = Buffer.from('<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"/>');
138
+ await fsp.writeFile(path.join(getBlobStoreDir(), hash), svgBytes);
139
+ const image = await readBlobImage(hash);
140
+ expect(image?.mimeType).toBe('image/svg+xml');
141
+ expect(image?.bytes).toEqual(svgBytes);
142
+ });
143
+
144
+ test('an SVG whose head the text check rejects still answers from its link', async () => {
145
+ // A document that opens with a comment or a doctype is not recognised from
146
+ // the first tag; the hardlink omp writes beside the blob is the fallback.
147
+ const hash = '9'.repeat(64);
148
+ const svgBytes = Buffer.from('<!-- exported --><svg xmlns="http://www.w3.org/2000/svg"/>');
149
+ await fsp.writeFile(path.join(getBlobStoreDir(), hash), svgBytes);
150
+ await fsp.writeFile(path.join(getBlobStoreDir(), `${hash}.svg`), svgBytes);
151
+ const image = await readBlobImage(hash);
152
+ expect(image?.mimeType).toBe('image/svg+xml');
153
+ });
154
+
121
155
  test('a missing blob yields null', async () => {
122
156
  expect(await readBlobImage('d'.repeat(64))).toBeNull();
123
157
  });
@@ -28,7 +28,7 @@ import * as fsp from 'node:fs/promises';
28
28
  import { existsSync } from 'node:fs';
29
29
  import * as path from 'node:path';
30
30
  import { getAgentDir } from '@/server/lib/omp/core/paths';
31
- import { getImageMimeFromBytes, getImageMimeType } from '@/shared/lib/fs/file-kind';
31
+ import { getImageMimeFromBytes, getPaintableImageMimeType } from '@/shared/lib/fs/file-kind';
32
32
 
33
33
  const BLOB_PREFIX = 'blob:sha256:';
34
34
 
@@ -77,7 +77,7 @@ export async function readBlobRef(ref: string): Promise<Buffer | null> {
77
77
  }
78
78
 
79
79
  /** Extensions omp writes onto a blob's hardlink beside it (`mimeToExtension`). */
80
- const BLOB_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'bmp', 'tiff', 'ico'];
80
+ const BLOB_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'bmp', 'tiff', 'ico', 'svg'];
81
81
 
82
82
  /**
83
83
  * A blob's bytes plus the content type to serve them with, or null when the
@@ -89,6 +89,11 @@ const BLOB_IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'bmp
89
89
  * has the bytes, and a wrong `content-type` makes a browser download the image
90
90
  * instead of painting it. `image/jpeg` is the honest answer for a `.png` that
91
91
  * omp converted on read (measured: a 96×96 PNG read came back as a JPEG blob).
92
+ *
93
+ * An SVG has no magic signature, which is why the sniff reads its head as text
94
+ * (`looksLikeSvg`); `svg` is also in the link list, for a document that opens
95
+ * with a comment or a doctype the head check does not accept. Without either,
96
+ * an SVG blob was labelled `application/octet-stream` and painted nothing.
92
97
  */
93
98
  export async function readBlobImage(hash: string): Promise<{ bytes: Buffer; mimeType: string } | null> {
94
99
  const bytes = await readBlob(hash);
@@ -100,7 +105,7 @@ export async function readBlobImage(hash: string): Promise<{ bytes: Buffer; mime
100
105
  const dir = getBlobStoreDir();
101
106
  for (const ext of BLOB_IMAGE_EXTENSIONS) {
102
107
  if (!existsSync(path.join(dir, `${hash}.${ext}`))) continue;
103
- const byExtension = getImageMimeType(`x.${ext}`);
108
+ const byExtension = getPaintableImageMimeType(`x.${ext}`);
104
109
  if (byExtension) return { bytes, mimeType: byExtension };
105
110
  }
106
111
 
@@ -70,6 +70,10 @@ const SESSION_ROW_DELETES: readonly (readonly [string, string])[] = [
70
70
  ['queued_messages', 'session_id'],
71
71
  ['prompt_history', 'session_id'],
72
72
  ['chat_sessions', 'session_id'],
73
+ // The server-side recorder's fallback for a chat no tab ever wrote. It is a
74
+ // second copy of the same conversation, so a delete that left it behind would
75
+ // resurrect the transcript on the next open.
76
+ ['acp_transcripts', 'session_id'],
73
77
  ['files', 'session_id'],
74
78
  // An ACP chat has no transcript for the scan to lose: `harness_sessions` IS
75
79
  // its row, so leaving it behind both refused the delete as "not found" (nothing
@@ -26,6 +26,7 @@
26
26
 
27
27
  import { afterAll, afterEach, describe, expect, test } from 'bun:test';
28
28
  import fs from 'fs';
29
+ import * as os from 'os';
29
30
  import * as path from 'path';
30
31
 
31
32
  import { loadSidebarActivity } from '@/server/lib/omp/session/sidebar-activity.server';
@@ -43,7 +44,7 @@ const previousAgentDir = process.env.PI_CODING_AGENT_DIR;
43
44
  * path, so they are cleared before and after.
44
45
  */
45
46
  function useAgentDir(): string {
46
- const dir = fs.mkdtempSync(path.join(fs.realpathSync('/tmp'), 'kabmo-activity-'));
47
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-activity-'));
47
48
  tempDirs.push(dir);
48
49
  process.env.PI_CODING_AGENT_DIR = dir;
49
50
  clearSessionFileCaches();
@@ -25,6 +25,10 @@ import {
25
25
  noteChildOutcome,
26
26
  } from '@/server/lib/sessions/notify.server';
27
27
  import { listQueue } from '@/server/lib/queue/store.server';
28
+ import {
29
+ parseChildOutcomeNotice,
30
+ parseOrchestrationBlock,
31
+ } from '@/shared/lib/chat/orchestration/notice';
28
32
 
29
33
  const parents = new Set<string>();
30
34
 
@@ -57,9 +61,13 @@ describe('child outcome notices', () => {
57
61
  await noteChildOutcome({ sessionId: 'c2', status: 'completed', output: 'second done' });
58
62
 
59
63
  const text = await materializeNotice('p');
60
- expect(text).toContain('Child session updates');
61
- expect(text).toContain('c1');
62
- expect(text).toContain('c2');
64
+ expect(text).not.toBeNull();
65
+ // The body is the shared envelope, so the coordinator's message and the
66
+ // timeline card are built from the same text.
67
+ const block = parseOrchestrationBlock(text ?? '');
68
+ const entries = parseChildOutcomeNotice(block?.body ?? '');
69
+ expect(entries.map((entry) => entry.sessionId)).toEqual(['c1', 'c2']);
70
+ expect(entries[0]?.output).toBe('first done');
63
71
  expect(await listQueue('p')).toHaveLength(1);
64
72
  });
65
73
 
@@ -16,6 +16,10 @@
16
16
  * Only a delegated child notifies. A fork has no parent edge; a child whose
17
17
  * `parentNotifications` is `off` or whose outcome is filtered by `stuck` writes
18
18
  * nothing.
19
+ *
20
+ * The TEXT is built by `renderChildOutcomeNotice` in shared code, because the
21
+ * timeline parses the same envelope back into a card. A second copy of the
22
+ * format here would drift the moment either side changed.
19
23
  */
20
24
 
21
25
  import { getDb } from '@/server/db.server';
@@ -24,21 +28,19 @@ import { deliverQueueNow } from '@/server/lib/queue/delivery.server';
24
28
  import { getSessionRelation } from '@/server/lib/sessions/relations.server';
25
29
  import { isSessionArchived } from '@/server/lib/sessions/resolve.server';
26
30
  import { ensureSessionLive } from '@/server/lib/sessions/dispatch.server';
31
+ import { findSessionFileById } from '@/server/lib/omp/session/locator';
32
+ import { loadSessionTitle } from '@/server/lib/omp/session/messages';
33
+ import {
34
+ renderChildOutcomeNotice,
35
+ type ChildOutcomeEntry,
36
+ } from '@/shared/lib/chat/orchestration/notice';
27
37
 
28
38
  export const NOTICE_WINDOW_MS = 2_000;
29
39
  const OUTPUT_EXCERPT_LIMIT = 4_000;
30
40
  const TRUNCATION_MARKER = '\n\n[... output truncated ...]';
31
41
  const COALESCE_KEY = 'child-outcomes';
32
42
 
33
- export interface ChildOutcomeNotice {
34
- sessionId: string;
35
- title?: string | null;
36
- status: 'completed' | 'failed' | 'interrupted';
37
- /** The child's final assistant text, when the transport could read it. */
38
- output?: string | null;
39
- /** Why it failed or was interrupted, when known. */
40
- failure?: string | null;
41
- }
43
+ export type ChildOutcomeNotice = ChildOutcomeEntry;
42
44
 
43
45
  interface NoticeRow {
44
46
  id: string;
@@ -66,38 +68,23 @@ function excerpt(text: string | null | undefined): string {
66
68
  return `${trimmed.slice(0, keep).trimEnd()}${TRUNCATION_MARKER}`;
67
69
  }
68
70
 
69
- function describe(item: ChildOutcomeNotice): string {
70
- const title = item.title?.trim();
71
- return title ? `"${title}" (${item.sessionId})` : item.sessionId;
72
- }
73
-
74
- function oneLine(text: string): string {
75
- return text.replace(/\s+/g, ' ').trim();
76
- }
77
-
78
- function renderOutcome(item: ChildOutcomeNotice): string {
79
- const label = describe(item);
80
- if (item.status === 'completed') {
81
- return `Child session ${label} completed:\n\n${excerpt(item.output)}`;
71
+ /** The child's own title, so the coordinator reads a name instead of a UUID.
72
+ * Best-effort: an ACP child has no omp file, and a missing title is not a
73
+ * reason to withhold the outcome. */
74
+ async function titleOf(sessionId: string): Promise<string | null> {
75
+ try {
76
+ const file = await findSessionFileById(sessionId);
77
+ if (!file) return null;
78
+ const title = (await loadSessionTitle(file))?.trim();
79
+ // A worker's first prompt is Kabmo's own brief, so an auto-title derived
80
+ // from it is the brief's first line — measured as
81
+ // `title: [kabmo dispatched worker]` in a real coordinator's notice. That
82
+ // names nothing; the session id below it already identifies the worker.
83
+ if (!title || /^\[kabmo /.test(title)) return null;
84
+ return title;
85
+ } catch {
86
+ return null;
82
87
  }
83
- const reason =
84
- item.status === 'interrupted'
85
- ? item.failure || 'it was interrupted'
86
- : item.failure || 'it failed';
87
- return `Child session ${label} ${reason}.\n\nReview the session before deciding the next step.`;
88
- }
89
-
90
- /** One notice body, for one child or a coalesced batch. */
91
- export function renderChildOutcomeNotice(items: readonly ChildOutcomeNotice[]): string {
92
- if (items.length === 1 && items[0]) return renderOutcome(items[0]);
93
- const lines = items.map((item) => {
94
- const label = describe(item);
95
- if (item.status === 'completed') {
96
- return `- ${label} completed: ${oneLine(excerpt(item.output))}`;
97
- }
98
- return `- ${label} ${item.failure || item.status}.`;
99
- });
100
- return `Child session updates:\n\n${lines.join('\n')}`;
101
88
  }
102
89
 
103
90
  function mergeOutcome(
@@ -142,7 +129,12 @@ export async function noteChildOutcome(outcome: ChildOutcomeNotice): Promise<voi
142
129
  const previous = existing
143
130
  ? (JSON.parse(existing.state) as ChildOutcomeNotice[])
144
131
  : [];
145
- const state = JSON.stringify(mergeOutcome(previous, outcome));
132
+ const entry: ChildOutcomeNotice = {
133
+ ...outcome,
134
+ title: outcome.title ?? (await titleOf(outcome.sessionId)),
135
+ output: outcome.status === 'completed' ? excerpt(outcome.output) : null,
136
+ };
137
+ const state = JSON.stringify(mergeOutcome(previous, entry));
146
138
  await db.run(
147
139
  `INSERT INTO session_notices
148
140
  (id, parent_session_id, coalesce_key, state, send_at, created_at, updated_at)
@@ -208,5 +200,38 @@ export async function flushNotice(parentSessionId: string): Promise<void> {
208
200
  const text = await materializeNotice(parentSessionId);
209
201
  if (text === null) return;
210
202
  const session = await ensureSessionLive(parentSessionId);
211
- if (session) await deliverQueueNow(session);
203
+ if (!session) {
204
+ // The row is durable and the parent's queue panel shows it, but nothing
205
+ // will deliver it until that session can be resumed. Say so: a coordinator
206
+ // that never hears from a worker is otherwise indistinguishable from one
207
+ // that is still working.
208
+ console.error(
209
+ `[sessions] child outcomes for ${parentSessionId} are queued but the session could not be resumed`,
210
+ );
211
+ return;
212
+ }
213
+ await deliverQueueNow(session);
214
+ }
215
+
216
+ /**
217
+ * Deliver every notice a PREVIOUS process left behind.
218
+ *
219
+ * The window lives in a timer, and a timer dies with the process: a child that
220
+ * finished during a restart (or a `bun --hot` reload) left its outcome in
221
+ * `session_notices` with nothing to flush it, so the coordinator waited for a
222
+ * message that was already written. Runs once, after the listener is up.
223
+ */
224
+ export async function drainPendingNotices(): Promise<void> {
225
+ const db = await getDb();
226
+ const rows = await db.all<{ parent_session_id: string }>(
227
+ 'SELECT DISTINCT parent_session_id FROM session_notices',
228
+ );
229
+ for (const row of rows) {
230
+ await flushNotice(row.parent_session_id).catch((error) => {
231
+ console.error(
232
+ `[sessions] could not deliver a stranded child outcome to ${row.parent_session_id}:`,
233
+ error instanceof Error ? error.message : error,
234
+ );
235
+ });
236
+ }
212
237
  }
@@ -98,9 +98,13 @@ describe('spawnChildSession', () => {
98
98
  });
99
99
  expect(child.sent).toHaveLength(1);
100
100
  expect(child.sent[0]).toMatchObject({ type: 'prompt' });
101
+ // The whole opening turn is Kabmo's framing, so the TASK rides INSIDE the
102
+ // envelope: the timeline draws one card for it instead of a user bubble
103
+ // quoting a preamble the operator never typed.
101
104
  expect(String(child.sent[0].message)).toStartWith('[kabmo dispatched worker]');
102
105
  expect(String(child.sent[0].message)).toContain('your coordinator is session parent');
103
- expect(String(child.sent[0].message)).toEndWith('TASK\nreview this');
106
+ expect(String(child.sent[0].message)).toContain('TASK\nreview this');
107
+ expect(String(child.sent[0].message)).toEndWith('[/kabmo dispatched worker]');
104
108
  expect(await getSessionRelation('child')).toMatchObject({
105
109
  parentSessionId: 'parent',
106
110
  lifecycleOwnerSessionId: 'parent',
@@ -30,6 +30,7 @@ import { getLiveSession, harnessOfSession, startNewRpcSession } from '@/server/l
30
30
  import { harnessProbeModels } from '@/server/lib/harness/probe-cache.server';
31
31
  import { getDb } from '@/server/db.server';
32
32
  import { harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
33
+ import { WORKER_BRIEF } from '@/shared/lib/chat/orchestration/notice';
33
34
  import type { SelectedModel } from '@/shared/types/models';
34
35
  import type { AgentImage } from '@/shared/types/omp/agent';
35
36
  import { MAX_SESSION_DEPTH } from '@/server/lib/sessions/relation-types';
@@ -205,10 +206,14 @@ async function resolveSpawnModel(
205
206
  }
206
207
 
207
208
  /** What a child receives before its task: identity, the one control verb, and
208
- * the completion rule. Kabmo, not the orchestrator, writes this. */
209
+ * the completion rule. Kabmo, not the orchestrator, writes this.
210
+ *
211
+ * The TASK rides INSIDE the envelope: the whole opening turn is Kabmo's
212
+ * framing, so the timeline draws one card for it instead of a user bubble
213
+ * quoting a preamble the operator never typed. */
209
214
  function dispatchedWorkerPrompt(parentSessionId: string, sessionId: string, task: string): string {
210
215
  return [
211
- '[kabmo dispatched worker]',
216
+ WORKER_BRIEF.open,
212
217
  `You are session ${sessionId}; your coordinator is session ${parentSessionId}.`,
213
218
  'The coordinator cannot see this chat.',
214
219
  '',
@@ -219,10 +224,10 @@ function dispatchedWorkerPrompt(parentSessionId: string, sessionId: string, task
219
224
  '',
220
225
  'Do only this task. When you finish, your final message is your report: what you did,',
221
226
  'what you found, what is left. Do not send a separate acknowledgement.',
222
- '[/kabmo dispatched worker]',
223
227
  '',
224
228
  'TASK',
225
229
  task,
230
+ WORKER_BRIEF.close,
226
231
  ].join('\n');
227
232
  }
228
233
 
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Who may be replayed into Kabmo's transcript.
8
+ *
9
+ * The gate used to be `origin === 'imported'`, which assumed every chat Kabmo
10
+ * spawned had a client-written transcript. A child spawned SERVER-SIDE (an
11
+ * orchestration worker, a CLI child) has no tab, so that assumption left its
12
+ * timeline empty. The gate is now the local transcript itself.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+ import { restoreEligible } from '@/server/routes/agent/harness-command';
17
+ import { hasAssistantRow } from '@/shared/lib/chat/transcript-rows';
18
+ import type { HarnessSessionRecord } from '@/server/lib/harness/session-store.server';
19
+
20
+ function record(overrides: Partial<HarnessSessionRecord> = {}): HarnessSessionRecord {
21
+ return {
22
+ sessionId: 'child-1',
23
+ harness: 'claude',
24
+ agentSessionId: 'child-1',
25
+ cwd: '/work',
26
+ origin: '',
27
+ ...overrides,
28
+ };
29
+ }
30
+
31
+ describe('restoreEligible', () => {
32
+ test('a spawned child with no local transcript is eligible', () => {
33
+ expect(restoreEligible(record(), [])).toBe(true);
34
+ });
35
+
36
+ test('an imported chat is eligible', () => {
37
+ expect(restoreEligible(record({ origin: 'imported' }), [])).toBe(true);
38
+ });
39
+
40
+ test('a user-only row is not a transcript yet', () => {
41
+ expect(restoreEligible(record(), [{ role: 'user', content: 'do the task' }])).toBe(true);
42
+ });
43
+
44
+ test('a local assistant row is a transcript and is not replayed', () => {
45
+ expect(restoreEligible(record(), [
46
+ { role: 'user', content: 'do the task' },
47
+ { role: 'ai', content: 'done' },
48
+ ])).toBe(false);
49
+ });
50
+
51
+ test('omp owns its own transcript and is never replayed', () => {
52
+ expect(restoreEligible(record({ harness: 'omp-rpc' }), [])).toBe(false);
53
+ });
54
+
55
+ test('a record with no cwd cannot be resumed', () => {
56
+ expect(restoreEligible(record({ cwd: '' }), [])).toBe(false);
57
+ });
58
+
59
+ test('no record is not eligible', () => {
60
+ expect(restoreEligible(null, [])).toBe(false);
61
+ });
62
+ });
63
+
64
+ describe('hasAssistantRow', () => {
65
+ test('recognises both spellings of the assistant role', () => {
66
+ expect(hasAssistantRow([{ role: 'ai' }])).toBe(true);
67
+ expect(hasAssistantRow([{ role: 'assistant' }])).toBe(true);
68
+ expect(hasAssistantRow([{ role: 'user' }])).toBe(false);
69
+ expect(hasAssistantRow(null)).toBe(false);
70
+ });
71
+ });