@kabmo-labs/kabmo 0.42.0 → 0.42.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +592 -593
  3. package/dist/client/static/js/{CsvGrid-20k047ht.js → CsvGrid-g6rek8y9.js} +1 -1
  4. package/dist/client/static/js/{DocxView-qpvhfcmg.js → DocxView-41t9ryws.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-178skky8.js → DrawioView-mfxhfz1h.js} +1 -1
  6. package/dist/client/static/js/{ImageView-460th5qa.js → ImageView-bxqw3t4k.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-5cv0dty8.js → LayoutWrapper-zt14rv9m.js} +2 -2
  8. package/dist/client/static/js/{Modal-wks6p4r5.js → Modal-cm35g20x.js} +10 -10
  9. package/dist/client/static/js/{PdfView-y51g03nr.js → PdfView-bek8k888.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-rsmvn7ks.js → SessionsView-gn53zyn7.js} +1 -1
  11. package/dist/client/static/js/{SheetView-z7yvb05v.js → SheetView-vezssf6b.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-yehgzhem.js → SvgPreview-f1qaw73k.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-6zxpcy8b.js → abnfDiagram-O67JEVCF-4qn94h52.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-m98sgh3c.js → architectureDiagram-NJMV4G6O-tbewzdya.js} +3 -3
  16. package/dist/client/static/js/{blockDiagram-BEXU5L5S-cp7rervg.js → blockDiagram-BEXU5L5S-njgnwckz.js} +2 -2
  17. package/dist/client/static/js/{c4Diagram-YGBWAQC7-t31recqm.js → c4Diagram-YGBWAQC7-f58pcvbk.js} +1 -1
  18. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fy8x3dkx.js → classDiagram-v2-NBCMYWYE-52g73vyw.js} +3 -3
  19. package/dist/client/static/js/{cose-bilkent-JH36ORCC-va7ybm9e.js → cose-bilkent-JH36ORCC-ptdnshzh.js} +1 -1
  20. package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +1 -0
  21. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-4k0k429c.js → cynefinDiagram-VND7K2PF-qabfdkzr.js} +1 -1
  22. package/dist/client/static/js/{dagre-6A5THRUB-ykdhxq6t.js → dagre-6A5THRUB-kyf5jetf.js} +2 -2
  23. package/dist/client/static/js/{diagram-22UHCM2B-5nvwx7b6.js → diagram-22UHCM2B-bxrsjtv9.js} +4 -4
  24. package/dist/client/static/js/{diagram-3UASUU5V-hc7zsjgw.js → diagram-3UASUU5V-0f41s00j.js} +1 -1
  25. package/dist/client/static/js/{diagram-ATOU4E4O-97ae07y7.js → diagram-ATOU4E4O-0z1zx9h1.js} +1 -1
  26. package/dist/client/static/js/{diagram-CDSNMT55-b56nnbbs.js → diagram-CDSNMT55-znrmr6bk.js} +3 -3
  27. package/dist/client/static/js/{diagram-MLGK6HIB-37rygr9k.js → diagram-MLGK6HIB-jfe2jhk0.js} +1 -1
  28. package/dist/client/static/js/{diagram-MPIPVDR6-wv3vhhfk.js → diagram-MPIPVDR6-2kaawmwa.js} +1 -1
  29. package/dist/client/static/js/{dockerfile-0efb1z6e.js → dockerfile-12exatm9.js} +1 -1
  30. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-13fv7vxg.js → ebnfDiagram-ZINNZB2B-s5n37rfp.js} +1 -1
  31. package/dist/client/static/js/{elixir-mabagxwa.js → elixir-szk51ehr.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-xam60ktz.js → elk-276RUBZZ-433rd9fp.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-24ctv2ee.js → erDiagram-OPXOYQCR-key6ah0b.js} +2 -2
  34. package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
  35. package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +1 -0
  36. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-766a8fqw.js → ganttDiagram-FUAMR5RP-4efkhmca.js} +2 -2
  37. package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +1 -0
  38. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fmwjkgh6.js → gitGraphDiagram-X574FWY7-ac376y2k.js} +1 -1
  39. package/dist/client/static/js/html-tbz83eke.js +1 -0
  40. package/dist/client/static/js/{index-13xbwcbz.js → index-02543wk3.js} +1 -1
  41. package/dist/client/static/js/{index-sx809d6d.js → index-0e9nkc0g.js} +1 -1
  42. package/dist/client/static/js/{index-1c0pnsjd.js → index-0gbj4270.js} +1 -1
  43. package/dist/client/static/js/{index-z6kpc98a.js → index-0pabfaac.js} +1 -1
  44. package/dist/client/static/js/{index-4mstdh41.js → index-1t5ybx9v.js} +1 -1
  45. package/dist/client/static/js/{index-9vdbnvmk.js → index-1y3rzw6b.js} +1 -1
  46. package/dist/client/static/js/{index-qj34r6d0.js → index-38xv8h4t.js} +1 -1
  47. package/dist/client/static/js/{index-4j8rgr4p.js → index-50mdqev0.js} +1 -1
  48. package/dist/client/static/js/{index-zvazj4va.js → index-5jnvz9hw.js} +1 -1
  49. package/dist/client/static/js/{index-97qst4k9.js → index-77t0nvt1.js} +1 -1
  50. package/dist/client/static/js/{index-x7f5ysch.js → index-7a2efrbj.js} +1 -1
  51. package/dist/client/static/js/{index-yvxa7hd8.js → index-82vk27q1.js} +1 -1
  52. package/dist/client/static/js/{index-nbexks3x.js → index-8k7vjp8b.js} +1 -1
  53. package/dist/client/static/js/{index-sq3r1xhf.js → index-8kbp24xg.js} +1 -1
  54. package/dist/client/static/js/{index-zjydzxhm.js → index-b0v6gwym.js} +2 -2
  55. package/dist/client/static/js/{index-grczkttn.js → index-b42t14wk.js} +7 -7
  56. package/dist/client/static/js/{index-13dr1t1r.js → index-cz50ha6x.js} +23 -23
  57. package/dist/client/static/js/{index-8jqawh3r.js → index-dtj73vs1.js} +1 -1
  58. package/dist/client/static/js/{index-7t63akyt.js → index-dzmar8jr.js} +1 -1
  59. package/dist/client/static/js/{index-2x9eqztp.js → index-f33c4paw.js} +1 -1
  60. package/dist/client/static/js/{index-xxe52zrm.js → index-fb6pw9xb.js} +1 -1
  61. package/dist/client/static/js/{index-6ge6gk9w.js → index-gp57dx2v.js} +1 -1
  62. package/dist/client/static/js/{index-2hpy58d0.js → index-gsxebrq9.js} +2 -2
  63. package/dist/client/static/js/{index-czagykbq.js → index-pxtff3ez.js} +2 -2
  64. package/dist/client/static/js/{index-8hgm0abr.js → index-pzvr1699.js} +187 -183
  65. package/dist/client/static/js/{index-dydwcp3n.js → index-r9db1gsf.js} +1 -1
  66. package/dist/client/static/js/{index-b4y5g48d.js → index-raca8tsh.js} +1 -1
  67. package/dist/client/static/js/{index-95en3p3g.js → index-rf29f3fq.js} +4 -4
  68. package/dist/client/static/js/{index-sz3mxjvy.js → index-s4gv0rpk.js} +1 -1
  69. package/dist/client/static/js/{index-a9t9gdew.js → index-v3f7we4n.js} +4 -4
  70. package/dist/client/static/js/{index-ejdnjh5c.js → index-yjmm73jm.js} +1 -1
  71. package/dist/client/static/js/{index-1rxa9zxp.js → index-ykfd2fyj.js} +1 -1
  72. package/dist/client/static/js/{index-4z4ax55k.js → index-yzda8j2d.js} +6 -6
  73. package/dist/client/static/js/{index-vcn1kcpy.js → index-z78bzryw.js} +3 -3
  74. package/dist/client/static/js/{index-tqycj126.js → index-zndbhb9w.js} +1 -1
  75. package/dist/client/static/js/{index-ka2rc2cr.js → index-zs73zwjz.js} +3 -3
  76. package/dist/client/static/js/{index-xe5cqwnf.js → index-zs7sjv6x.js} +1 -1
  77. package/dist/client/static/js/{index-hzwr5fm9.js → index-zw621xez.js} +3 -3
  78. package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
  79. package/dist/client/static/js/{infoDiagram-VRGFBTTK-tqytmzp1.js → infoDiagram-VRGFBTTK-4e7ej63f.js} +2 -2
  80. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rp77ff6m.js → ishikawaDiagram-OU5B5YK6-k3yet1ec.js} +2 -2
  81. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-c7bxrhf1.js → journeyDiagram-ZHPQQLJL-qe352kyd.js} +2 -2
  82. package/dist/client/static/js/{kanban-definition-PNTS6WVX-j2pxewqq.js → kanban-definition-PNTS6WVX-58hag75n.js} +4 -4
  83. package/dist/client/static/js/{mermaid.core-cqqe1krg.js → mermaid.core-6e89h6vm.js} +2 -2
  84. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-s03k32p9.js → mindmap-definition-NLK3R4M7-ncsam2fm.js} +1 -1
  85. package/dist/client/static/js/one-dark-pro-qmyne0tn.js +1 -0
  86. package/dist/client/static/js/one-light-dj0ecjcj.js +1 -0
  87. package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +1 -0
  88. package/dist/client/static/js/{pegDiagram-GJSIUBJH-dfg2j0zc.js → pegDiagram-GJSIUBJH-b5ckc39d.js} +1 -1
  89. package/dist/client/static/js/{perl-5vxax0nr.js → perl-dtn1fccw.js} +1 -1
  90. package/dist/client/static/js/{php-hgrgdq63.js → php-7av78hch.js} +1 -1
  91. package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +1 -0
  92. package/dist/client/static/js/{pieDiagram-5QR66LMP-pshd1j79.js → pieDiagram-5QR66LMP-s4d47ve8.js} +2 -2
  93. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-cvvvmtk2.js → quadrantDiagram-O4NWA36T-zm0ekvjz.js} +1 -1
  94. package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +1 -0
  95. package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +1 -0
  96. package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +1 -0
  97. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +1 -0
  98. package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +1 -0
  99. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-h53p3sha.js → railroadDiagram-XR7U4H2S-52vdqf53.js} +1 -1
  100. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bdv2fkxd.js → requirementDiagram-PLB6GJNP-7kf8bmk9.js} +1 -1
  101. package/dist/client/static/js/{ruby-8pxcn21w.js → ruby-s2bqr910.js} +1 -1
  102. package/dist/client/static/js/{rust-j80dxgjg.js → rust-q98kssv3.js} +1 -1
  103. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-xqnnvmhy.js → sankeyDiagram-IPEJSGJF-bcb9f54a.js} +1 -1
  104. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3p67305f.js → sequenceDiagram-PO4LG4MO-76ywvj7g.js} +3 -3
  105. package/dist/client/static/js/{sizeCapture-INFHLROL-f87525h7.js → sizeCapture-INFHLROL-p9bsf5dc.js} +1 -1
  106. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-e5st1fy3.js → stateDiagram-v2-GCMORJYK-1ecfb3fs.js} +1 -1
  107. package/dist/client/static/js/{swimlanes-2SLR337P-ceghkbez.js → swimlanes-2SLR337P-2pyjr946.js} +1 -1
  108. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-vc8hvfya.js → swimlanesDiagram-TC7HE7FX-qr5hdxm4.js} +1 -1
  109. package/dist/client/static/js/{timeline-definition-EJHVYXUP-f7evs443.js → timeline-definition-EJHVYXUP-4csxwmn2.js} +3 -3
  110. package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +1 -0
  111. package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +1 -0
  112. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0gpn21p7.js → usecaseDiagram-POWQR4AR-0p1jnbsn.js} +7 -7
  113. package/dist/client/static/js/{vennDiagram-UO4OBE2U-4spzy428.js → vennDiagram-UO4OBE2U-y1hgdet4.js} +2 -2
  114. package/dist/client/static/js/{vue-xm1dxpmy.js → vue-cbqm4bed.js} +1 -1
  115. package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +1 -0
  116. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-745xr2pa.js → wardleyDiagram-VNRHLVJA-p578yrgm.js} +2 -2
  117. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7dr9qwx5.js → xychartDiagram-PMCCYNJV-b08b4ah0.js} +3 -3
  118. package/package.json +1 -1
  119. package/src/cli/lib/commands/session.js +12 -1
  120. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -123
  121. package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +214 -0
  122. package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +126 -0
  123. package/src/client/components/workspace/chat-timeline/UserTurn.tsx +183 -0
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +3 -3
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions.tsx +45 -0
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +14 -4
  127. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +2 -12
  128. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +42 -38
  129. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +25 -21
  130. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +41 -29
  131. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +47 -43
  132. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/parity.test.tsx +136 -0
  133. package/src/client/hooks/chat/timeline/composer-modes.ts +10 -7
  134. package/src/client/hooks/chat/timeline/plan-review-republish.test.ts +121 -0
  135. package/src/client/hooks/chat/timeline/plan-review.ts +12 -3
  136. package/src/server/lib/harness/acp/acp-audit.server.ts +1 -1
  137. package/src/server/lib/harness/acp/session-exit.ts +39 -5
  138. package/src/server/lib/harness/acp/session-turns.ts +67 -12
  139. package/src/server/lib/harness/acp/session.test.ts +61 -0
  140. package/src/server/lib/harness/acp/session.ts +15 -25
  141. package/src/server/lib/harness/acp/turn-outcome.server.test.ts +97 -0
  142. package/src/server/lib/harness/acp/turn-outcome.server.ts +71 -0
  143. package/src/server/lib/harness/acp/turn-silence.ts +52 -0
  144. package/src/server/lib/harness/acp/turn.test.ts +85 -3
  145. package/src/server/lib/harness/acp/turn.ts +62 -4
  146. package/src/server/lib/lifecycle/after-listen.ts +10 -0
  147. package/src/server/lib/omp/rpc/frame-fold-contract.ts +21 -0
  148. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +4 -0
  149. package/src/server/lib/omp/rpc/frame-fold.ts +25 -2
  150. package/src/server/lib/omp/rpc/manager.ts +9 -8
  151. package/src/server/lib/omp/rpc/retry-saga.ts +54 -0
  152. package/src/server/lib/omp/rpc/run-settle.server.ts +38 -5
  153. package/src/server/lib/omp/rpc/run-settle.test.ts +5 -2
  154. package/src/server/lib/omp/rpc/session-commands-dialog.test.ts +6 -20
  155. package/src/server/lib/omp/rpc/session-commands-mapping.test.ts +131 -0
  156. package/src/server/lib/omp/rpc/session-commands.test.ts +95 -116
  157. package/src/server/lib/omp/rpc/session-commands.ts +38 -17
  158. package/src/server/lib/omp/rpc/terminal-settle.test.ts +223 -0
  159. package/src/server/lib/omp/rpc/terminal-settle.ts +127 -29
  160. package/src/server/lib/omp/session/scan.ts +15 -2
  161. package/src/server/lib/omp/session/session-discovery.test.ts +21 -0
  162. package/src/server/lib/sessions/notify.server.test.ts +11 -3
  163. package/src/server/lib/sessions/notify.server.ts +67 -42
  164. package/src/server/lib/sessions/spawn.server.test.ts +5 -1
  165. package/src/server/lib/sessions/spawn.server.ts +8 -3
  166. package/src/server/routes/sessions/answer.test.ts +62 -0
  167. package/src/server/routes/sessions/answer.ts +13 -2
  168. package/src/shared/lib/chat/composer/delegation.ts +11 -7
  169. package/src/shared/lib/chat/export-markdown.ts +19 -0
  170. package/src/shared/lib/chat/orchestration/notice.test.ts +118 -0
  171. package/src/shared/lib/chat/orchestration/notice.ts +183 -0
  172. package/src/shared/lib/chat/timeline/omp-callbacks.ts +6 -1
  173. package/src/shared/lib/chat/timeline/tool-render-mode.ts +3 -3
  174. package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
  175. package/src/shared/lib/omp/session/operator-title.test.ts +21 -0
  176. package/src/shared/lib/omp/session/operator-title.ts +28 -0
  177. package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +0 -1
  178. package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +0 -1
  179. package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +0 -1
  180. package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +0 -1
  181. package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +0 -1
  182. package/dist/client/static/js/html-bwyt0ayy.js +0 -1
  183. package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +0 -1
  184. package/dist/client/static/js/one-dark-pro-9tt0a020.js +0 -1
  185. package/dist/client/static/js/one-light-5fg4r0ra.js +0 -1
  186. package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +0 -1
  187. package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +0 -1
  188. package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +0 -1
  189. package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +0 -1
  190. package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +0 -1
  191. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +0 -1
  192. package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +0 -1
  193. package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +0 -1
  194. package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +0 -1
  195. package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +0 -1
@@ -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,62 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `GET /api/sessions/:id/answer` — the last closed answer, and why a run failed.
8
+ *
9
+ * The failure half exists because a FAILED run has no answer at all: the
10
+ * command printed "No assistant answer recorded." for a worker whose provider
11
+ * had said exactly why it stopped, so a coordinator had nothing to report and
12
+ * nothing to act on. Both fields are read from their own durable row, so the
13
+ * answer survives a restart and the reason survives the process that wrote it.
14
+ */
15
+
16
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
17
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
18
+ import { getDb } from '@/server/db.server';
19
+ import { getSessionAnswer } from '@/server/routes/sessions/answer';
20
+ import { saveSessionAnswer } from '@/server/lib/sessions/answers.server';
21
+ import { markStreamStatus } from '@/shared/lib/omp/session/stream-state.server';
22
+
23
+ beforeEach(isolateDb);
24
+ afterEach(releaseDb);
25
+
26
+ async function read(sessionId: string): Promise<{ answer: string | null; failure: string | null }> {
27
+ const response = await getSessionAnswer({
28
+ request: new Request(`http://localhost/api/sessions/${sessionId}/answer`),
29
+ params: { sessionId },
30
+ } as never);
31
+ return (await (response as Response).json()) as { answer: string | null; failure: string | null };
32
+ }
33
+
34
+ describe('the session answer route', () => {
35
+ test('a completed run reports its answer and no failure', async () => {
36
+ await saveSessionAnswer('s1', 'all done');
37
+ await markStreamStatus('s1', 'finish');
38
+
39
+ expect(await read('s1')).toMatchObject({ answer: 'all done', failure: null });
40
+ });
41
+
42
+ test('a failed run reports the reason, which is all it has', async () => {
43
+ await markStreamStatus('s1', 'finish', undefined, '400 The model is unavailable');
44
+
45
+ const body = await read('s1');
46
+ expect(body.answer).toBeNull();
47
+ expect(body.failure).toBe('400 The model is unavailable');
48
+ });
49
+
50
+ test('a session that never ran reports neither', async () => {
51
+ expect(await read('never-ran')).toMatchObject({ answer: null, failure: null });
52
+ });
53
+
54
+ test('a new run clears the previous failure', async () => {
55
+ await markStreamStatus('s1', 'finish', undefined, 'boom');
56
+ await markStreamStatus('s1', 'stream');
57
+
58
+ expect((await read('s1')).failure).toBeNull();
59
+ // The row itself is what the route reads; keep the handle honest.
60
+ expect(await getDb()).toBeDefined();
61
+ });
62
+ });
@@ -4,21 +4,32 @@
4
4
  */
5
5
 
6
6
  /**
7
- * GET /api/sessions/:sessionId/answer — the last assistant text a turn closed.
7
+ * GET /api/sessions/:sessionId/answer — the last assistant text a turn closed,
8
+ * and why the run failed when it did.
8
9
  *
9
10
  * ACP has no transcript for `/api/chat/:id` to read after the process dies, so
10
11
  * `kabmo session output` needs this row. A null answer is a real state (the
11
12
  * session has not answered yet), not an error.
13
+ *
14
+ * `failure` rides along because a FAILED run has no answer at all: without it
15
+ * the command printed "No assistant answer recorded." for a worker whose
16
+ * provider had said exactly why, and a coordinator had nothing to report.
12
17
  */
13
18
 
14
19
  import { json } from '@/server/lib/remix-compat';
15
20
  import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
16
21
  import { methodNotAllowed } from '@/server/lib/route-adapter';
17
22
  import { loadSessionAnswer } from '@/server/lib/sessions/answers.server';
23
+ import { loadStreamStates } from '@/shared/lib/omp/session/stream-state.server';
18
24
 
19
25
  export async function getSessionAnswer({ request, params }: LoaderFunctionArgs) {
20
26
  if (request.method !== 'GET') return methodNotAllowed({ request, params });
21
27
  const sessionId = params.sessionId;
22
28
  if (!sessionId) return json({ error: 'Missing session id' }, { status: 400 });
23
- return json({ sessionId, answer: await loadSessionAnswer(sessionId) });
29
+ const states = await loadStreamStates();
30
+ return json({
31
+ sessionId,
32
+ answer: await loadSessionAnswer(sessionId),
33
+ failure: states[sessionId]?.failure ?? null,
34
+ });
24
35
  }
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  import { harnessDescriptor, harnessIdForName, type HarnessId } from '@/shared/lib/harness/catalog';
21
+ import { ORCHESTRATION_CONTRACT } from '@/shared/lib/chat/orchestration/notice';
21
22
 
22
23
  export interface HarnessDelegation {
23
24
  harness: HarnessId;
@@ -158,12 +159,14 @@ export function delegationCommand(delegation: HarnessDelegation, index: number):
158
159
  */
159
160
  export function formatDelegationPrompt(plan: DelegationPlan): string {
160
161
  const lines = [
161
- '[kabmo orchestration contract]',
162
+ ORCHESTRATION_CONTRACT.open,
162
163
  'You are the orchestrator for this message. Start each worker below with the exact command,',
163
164
  'then end your turn. A worker sees nothing of this conversation: its TASK is the whole brief.',
164
- 'Kabmo adds the dispatched-worker preamble and sends each worker outcome back as a new',
165
- 'message. Do not poll, do not resend the same task, and do not delegate work that is not',
166
- 'listed here unless the user asks.',
165
+ '',
166
+ 'Kabmo sends a worker outcome back as ONE message, when that worker is done. A worker that',
167
+ 'is still retrying a provider error reports nothing until it stops, so silence is not a',
168
+ 'result. Do not poll, do not resend a task, and do not delegate work that is not listed',
169
+ 'here unless the user asks.',
167
170
  '',
168
171
  'Workers:',
169
172
  ];
@@ -177,9 +180,10 @@ export function formatDelegationPrompt(plan: DelegationPlan): string {
177
180
  });
178
181
  lines.push(
179
182
  '',
180
- 'When a worker finishes, read its output with `kabmo session output <id>` and report the',
181
- 'result to the user. Reconcile conflicting reports; do not relay one verbatim.',
182
- '[/kabmo orchestration contract]',
183
+ 'When an outcome arrives, report it to the user. A completed worker carries its report; a',
184
+ 'failed one carries the reason it gave — report that failure, never resend the task.',
185
+ 'Reconcile conflicting reports; do not relay one verbatim.',
186
+ ORCHESTRATION_CONTRACT.close,
183
187
  );
184
188
  if (plan.orchestratorText) lines.push('', plan.orchestratorText);
185
189
  return lines.join('\n');
@@ -18,6 +18,7 @@
18
18
 
19
19
  import type { AgentActionData, ChatMessageData, ToolCallData } from '@/shared/types';
20
20
  import { isNoticeRow, messageAnswerText } from '@/shared/lib/chat/notice-row';
21
+ import { parseOrchestrationBlock } from '@/shared/lib/chat/orchestration/notice';
21
22
 
22
23
  export interface SessionMarkdownInput {
23
24
  id: string;
@@ -84,11 +85,29 @@ function toolCallBlock(call: ToolCallData | AgentActionData): string[] {
84
85
  return lines;
85
86
  }
86
87
 
88
+ /** The heading an injected prompt exports under. Kabmo wrote it, so it is not
89
+ * filed as the operator's own turn — the same distinction the timeline draws
90
+ * with a card. */
91
+ const ORCHESTRATION_HEADING: Record<string, string> = {
92
+ contract: '## Orchestration',
93
+ worker: '## Worker brief',
94
+ outcome: '## Worker outcome',
95
+ };
96
+
87
97
  function messageBlock(msg: ChatMessageData): string[] {
88
98
  if (isNoticeRow(msg)) {
89
99
  return ['## System notice', '', quote(msg.notice)];
90
100
  }
91
101
 
102
+ const injected = msg.role === 'user' ? parseOrchestrationBlock(messageAnswerText(msg)) : null;
103
+ if (injected) {
104
+ const lines = [ORCHESTRATION_HEADING[injected.kind] ?? '## Orchestration', '', injected.body];
105
+ // The operator's own words stay their turn, exactly as the timeline keeps
106
+ // their bubble beside the card.
107
+ if (injected.rest) lines.push('', '## User', '', injected.rest);
108
+ return lines;
109
+ }
110
+
92
111
  const heading = msg.role === 'user' ? '## User' : '## Assistant';
93
112
  const lines: string[] = [heading];
94
113
  const content = messageAnswerText(msg).trim();
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The injected-prompt envelope, and the outcome format both ends read.
8
+ *
9
+ * The reason this is a shared module and not two copies: the server WRITES the
10
+ * text a coordinator receives and the client PARSES it back into a card. A
11
+ * format that only one side knew would render a worker report as the
12
+ * operator's own message, which is exactly the bug this replaced.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+ import {
17
+ CHILD_OUTCOME,
18
+ ORCHESTRATION_CONTRACT,
19
+ WORKER_BRIEF,
20
+ parseChildOutcomeNotice,
21
+ parseOrchestrationBlock,
22
+ renderChildOutcomeNotice,
23
+ } from '@/shared/lib/chat/orchestration/notice';
24
+
25
+ describe('parseOrchestrationBlock', () => {
26
+ test('leaves anything a human wrote alone', () => {
27
+ expect(parseOrchestrationBlock('fix the sidebar, please')).toBeNull();
28
+ // A marker in the MIDDLE of prose is content, not an envelope.
29
+ expect(parseOrchestrationBlock('see [kabmo child outcome] handling')).toBeNull();
30
+ });
31
+
32
+ test('splits the contract from the words the operator typed', () => {
33
+ const text = [
34
+ ORCHESTRATION_CONTRACT.open,
35
+ 'You are the orchestrator for this message.',
36
+ ORCHESTRATION_CONTRACT.close,
37
+ '',
38
+ 'koordinasikan timnya',
39
+ ].join('\n');
40
+ const block = parseOrchestrationBlock(text);
41
+ expect(block?.kind).toBe('contract');
42
+ expect(block?.body).toBe('You are the orchestrator for this message.');
43
+ expect(block?.rest).toBe('koordinasikan timnya');
44
+ });
45
+
46
+ test('a worker brief is one block with no operator text', () => {
47
+ const text = `${WORKER_BRIEF.open}\nYou are session c1.\n\nTASK\ncheck the log\n${WORKER_BRIEF.close}`;
48
+ const block = parseOrchestrationBlock(text);
49
+ expect(block?.kind).toBe('worker');
50
+ expect(block?.body).toContain('check the log');
51
+ expect(block?.rest).toBe('');
52
+ });
53
+
54
+ test('an unterminated marker stays prose', () => {
55
+ // A truncated write must not swallow the rest of the message.
56
+ const text = `${ORCHESTRATION_CONTRACT.open}\nhalf a contract`;
57
+ expect(parseOrchestrationBlock(text)).toBeNull();
58
+ });
59
+ });
60
+
61
+ describe('child outcome notices', () => {
62
+ test('one worker round-trips with its reason intact', () => {
63
+ const text = renderChildOutcomeNotice([
64
+ {
65
+ sessionId: 'c1',
66
+ title: 'Agent 1',
67
+ status: 'failed',
68
+ failure: '400 The model agnes-2-5-flash:free is currently unavailable.',
69
+ },
70
+ ]);
71
+ expect(text.startsWith(CHILD_OUTCOME.open)).toBe(true);
72
+ const block = parseOrchestrationBlock(text);
73
+ expect(block?.kind).toBe('outcome');
74
+ const [entry] = parseChildOutcomeNotice(block?.body ?? '');
75
+ expect(entry).toEqual({
76
+ sessionId: 'c1',
77
+ title: 'Agent 1',
78
+ status: 'failed',
79
+ failure: '400 The model agnes-2-5-flash:free is currently unavailable.',
80
+ });
81
+ });
82
+
83
+ test('a completed worker carries its whole output, newlines included', () => {
84
+ const output = '**Report**\n\n- did one thing\n- did another';
85
+ const body = parseOrchestrationBlock(
86
+ renderChildOutcomeNotice([{ sessionId: 'c1', status: 'completed', output }]),
87
+ );
88
+ const [entry] = parseChildOutcomeNotice(body?.body ?? '');
89
+ expect(entry?.output).toBe(output);
90
+ expect(entry?.failure).toBeUndefined();
91
+ });
92
+
93
+ test('a batch keeps every worker, in order', () => {
94
+ const body = parseOrchestrationBlock(
95
+ renderChildOutcomeNotice([
96
+ { sessionId: 'c1', status: 'completed', output: 'first' },
97
+ { sessionId: 'c2', status: 'interrupted' },
98
+ ]),
99
+ );
100
+ const entries = parseChildOutcomeNotice(body?.body ?? '');
101
+ expect(entries.map((entry) => entry.sessionId)).toEqual(['c1', 'c2']);
102
+ expect(entries[1]?.failure).toContain('interrupted');
103
+ });
104
+
105
+ test('a failure states the next step so the task is not resent', () => {
106
+ const text = renderChildOutcomeNotice([{ sessionId: 'c9', status: 'failed', failure: 'boom' }]);
107
+ expect(text).toContain('instead of resending');
108
+ // A failed run has no assistant answer, so `session output` would print
109
+ // nothing — the reason above is the detail.
110
+ expect(text).not.toContain('kabmo session output');
111
+ });
112
+
113
+ test('an unclassifiable status reads as failed, and a blank chunk is dropped', () => {
114
+ const entries = parseChildOutcomeNotice('session: c1\nstatus: weird\nreason: x\n---\nno session here');
115
+ expect(entries).toHaveLength(1);
116
+ expect(entries[0]?.status).toBe('failed');
117
+ });
118
+ });