@kabmo-labs/kabmo 0.37.0 → 0.38.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 (261) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +551 -531
  3. package/dist/client/static/js/{CsvGrid-xb429wvb.js → CsvGrid-t1n057vw.js} +1 -1
  4. package/dist/client/static/js/{DocxView-g58e0bs7.js → DocxView-c9g6teks.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-1j66avvy.js → DrawioView-gd14j54m.js} +1 -1
  6. package/dist/client/static/js/{ImageView-kraqkypn.js → ImageView-57f1ecdp.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-85dhbn62.js → LayoutWrapper-x7srbpz1.js} +2 -2
  8. package/dist/client/static/js/{Modal-f0nfya07.js → Modal-0bn3f77b.js} +15 -15
  9. package/dist/client/static/js/{PdfView-nddkrky9.js → PdfView-cybz0xbj.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-a595m6g1.js → SessionsView-gx5q68tp.js} +1 -1
  11. package/dist/client/static/js/{SheetView-s2p4sk6b.js → SheetView-1kk5y326.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-ppdx4yb9.js → SvgPreview-mp4tk37p.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-5cjzxcaq.js → abnfDiagram-O67JEVCF-78qb3can.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-62mygavm.js → architectureDiagram-NJMV4G6O-n0fr4hb6.js} +2 -2
  16. package/dist/client/static/js/{astro-80bs6hvg.js → astro-p3f5p9p2.js} +1 -1
  17. package/dist/client/static/js/{blockDiagram-BEXU5L5S-s5yz9hcd.js → blockDiagram-BEXU5L5S-2xemfrzh.js} +6 -6
  18. package/dist/client/static/js/c-jkdstn33.js +1 -0
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-rf9xkmrm.js → c4Diagram-YGBWAQC7-zxfdx3eb.js} +2 -2
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-zfm2cj2a.js → classDiagram-v2-NBCMYWYE-z9sasy3k.js} +5 -5
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-fmgpv55e.js → cose-bilkent-JH36ORCC-9byp0czh.js} +1 -1
  22. package/dist/client/static/js/cpp-9d3xdpe3.js +1 -0
  23. package/dist/client/static/js/css-r3wja1ze.js +1 -0
  24. package/dist/client/static/js/css-sebxkh5f.js +1 -0
  25. package/dist/client/static/js/cynefin-OW5HDTMX-w2f2vev7.js +1 -0
  26. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-468r5xc2.js → cynefinDiagram-VND7K2PF-gnm129fx.js} +1 -1
  27. package/dist/client/static/js/{dagre-6A5THRUB-w370qmgj.js → dagre-6A5THRUB-sc5tfv1w.js} +2 -2
  28. package/dist/client/static/js/{diagram-22UHCM2B-sfvfjjsy.js → diagram-22UHCM2B-hq11eek7.js} +7 -7
  29. package/dist/client/static/js/{diagram-3UASUU5V-3r2c8s14.js → diagram-3UASUU5V-7bk532gd.js} +2 -2
  30. package/dist/client/static/js/{diagram-ATOU4E4O-yathy97a.js → diagram-ATOU4E4O-yt8wxttm.js} +2 -2
  31. package/dist/client/static/js/{diagram-CDSNMT55-kk437kxq.js → diagram-CDSNMT55-n3978w6p.js} +1 -1
  32. package/dist/client/static/js/{diagram-MLGK6HIB-qdxfjjhf.js → diagram-MLGK6HIB-004x4gyw.js} +1 -1
  33. package/dist/client/static/js/{diagram-MPIPVDR6-dfqeqa1d.js → diagram-MPIPVDR6-498nt489.js} +1 -1
  34. package/dist/client/static/js/{dockerfile-yxrt509r.js → dockerfile-6hbcmkc8.js} +1 -1
  35. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-s0b0vv4k.js → ebnfDiagram-ZINNZB2B-5fkmymqn.js} +1 -1
  36. package/dist/client/static/js/{elixir-rpa1g4gy.js → elixir-jwphgp8j.js} +1 -1
  37. package/dist/client/static/js/{elk-276RUBZZ-mtpw0spa.js → elk-276RUBZZ-6xrfa2kd.js} +1 -1
  38. package/dist/client/static/js/{erDiagram-OPXOYQCR-agjdsm1b.js → erDiagram-OPXOYQCR-byz4zbkn.js} +4 -4
  39. package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +1 -0
  40. package/dist/client/static/js/flowDiagram-KWPJA3E3-s3fbfwrz.js +1 -0
  41. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-z6ywqqc1.js → ganttDiagram-FUAMR5RP-4fkw1k01.js} +2 -2
  42. package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +1 -0
  43. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-bvbmfw6h.js → gitGraphDiagram-X574FWY7-19g84yw8.js} +2 -2
  44. package/dist/client/static/js/graphql-p4cskvad.js +1 -0
  45. package/dist/client/static/js/html-f26r6vv5.js +1 -0
  46. package/dist/client/static/js/{index-z0frtyje.js → index-0v8b5pzb.js} +4 -4
  47. package/dist/client/static/js/{index-z7qnffwj.js → index-1j1s91c4.js} +1 -1
  48. package/dist/client/static/js/{index-jpkj6vqp.js → index-20vhkcb9.js} +1 -1
  49. package/dist/client/static/js/{index-0j518hqm.js → index-3az1w5f8.js} +2 -2
  50. package/dist/client/static/js/{index-qznwd6g8.js → index-3wpsr2bc.js} +184 -184
  51. package/dist/client/static/js/{index-09gx6edj.js → index-3y6krykq.js} +1 -1
  52. package/dist/client/static/js/{index-we1rpftn.js → index-4jbbdq6n.js} +2 -2
  53. package/dist/client/static/js/{index-ntxm8pw3.js → index-4qt2e84b.js} +2 -2
  54. package/dist/client/static/js/{index-49dhv8ry.js → index-57z8mtmx.js} +2 -2
  55. package/dist/client/static/js/{index-qz8mbxm9.js → index-5gn56236.js} +2 -2
  56. package/dist/client/static/js/{index-9t82sx0w.js → index-6k3e5dph.js} +2 -2
  57. package/dist/client/static/js/{index-es3pt29g.js → index-74scnfpk.js} +1 -1
  58. package/dist/client/static/js/{index-0mvcbbmy.js → index-7kafzae0.js} +9 -9
  59. package/dist/client/static/js/{index-pd0140dx.js → index-89a2702q.js} +1 -1
  60. package/dist/client/static/js/{index-059qyaj0.js → index-8j90mdgz.js} +1 -1
  61. package/dist/client/static/js/{index-zvfvqvn9.js → index-9wd9y6m0.js} +2 -2
  62. package/dist/client/static/js/{index-a0bdavdr.js → index-ashpbfqv.js} +1 -1
  63. package/dist/client/static/js/{index-72t6kqjx.js → index-b9b2nwdd.js} +2 -2
  64. package/dist/client/static/js/{index-8e0s9p45.js → index-baet2nv8.js} +1 -1
  65. package/dist/client/static/js/{index-j7r414hf.js → index-bhng2dax.js} +2 -2
  66. package/dist/client/static/js/{index-21b3zyrd.js → index-cj9193d5.js} +2 -2
  67. package/dist/client/static/js/{index-sezz011q.js → index-dd4q54y0.js} +1 -1
  68. package/dist/client/static/js/{index-xearvz2z.js → index-e3w46vsc.js} +7 -7
  69. package/dist/client/static/js/{index-1tyvk778.js → index-e99ec2f0.js} +1 -1
  70. package/dist/client/static/js/{index-w9zxmev3.js → index-ehnztdd2.js} +1 -1
  71. package/dist/client/static/js/{index-actppd4z.js → index-epbqzayj.js} +2 -2
  72. package/dist/client/static/js/{index-k06med7d.js → index-fghst0kd.js} +12 -12
  73. package/dist/client/static/js/{index-t07b31ny.js → index-fpf1jkwd.js} +3 -3
  74. package/dist/client/static/js/{index-hbtk0c12.js → index-g252205p.js} +2 -2
  75. package/dist/client/static/js/{index-vtbbfwx0.js → index-gr6jng0x.js} +2 -2
  76. package/dist/client/static/js/{index-kzhtmrh0.js → index-gxtgyya0.js} +1 -1
  77. package/dist/client/static/js/index-j314me09.js +1 -0
  78. package/dist/client/static/js/{index-5fn0agag.js → index-jbwns6sc.js} +1 -1
  79. package/dist/client/static/js/{index-cx89yk15.js → index-kdgcbt17.js} +2 -2
  80. package/dist/client/static/js/{index-m87yykre.js → index-m4bjsyj2.js} +5 -5
  81. package/dist/client/static/js/{index-15zn3sns.js → index-nd4p98mc.js} +1 -1
  82. package/dist/client/static/js/{index-nmc30xaz.js → index-pfwd0160.js} +1 -1
  83. package/dist/client/static/js/{index-w7xbfv44.js → index-qn4pkjfh.js} +2 -2
  84. package/dist/client/static/js/{index-0sqa91wb.js → index-qntytvt0.js} +2 -2
  85. package/dist/client/static/js/{index-64mb65wx.js → index-r83kr4s5.js} +2 -2
  86. package/dist/client/static/js/{index-7sa2e8mn.js → index-rgdhyry3.js} +2 -2
  87. package/dist/client/static/js/{index-m3j5yx5f.js → index-sjnnv1gd.js} +4 -4
  88. package/dist/client/static/js/{index-6q80csr0.js → index-t5t71dhp.js} +2 -2
  89. package/dist/client/static/js/{index-z6g74h7g.js → index-vb6t44dw.js} +2 -2
  90. package/dist/client/static/js/{index-a293pdg7.js → index-y3hdv561.js} +2 -2
  91. package/dist/client/static/js/{index-302d35e5.js → index-zj45wj1x.js} +34 -34
  92. package/dist/client/static/js/{index-83ts8zmk.js → index-zw7qjx65.js} +1 -1
  93. package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +1 -0
  94. package/dist/client/static/js/{infoDiagram-VRGFBTTK-58bv28d4.js → infoDiagram-VRGFBTTK-aw6ter0a.js} +1 -1
  95. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-tz6b0caw.js → ishikawaDiagram-OU5B5YK6-62gst5wh.js} +2 -2
  96. package/dist/client/static/js/javascript-nyf39d5r.js +1 -0
  97. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ydamm17a.js → journeyDiagram-ZHPQQLJL-6kgv5a4j.js} +3 -3
  98. package/dist/client/static/js/{julia-v7j460gw.js → julia-237yk557.js} +1 -1
  99. package/dist/client/static/js/{kanban-definition-PNTS6WVX-7jxfsf17.js → kanban-definition-PNTS6WVX-8p3515b7.js} +3 -3
  100. package/dist/client/static/js/lua-86fjqj8v.js +1 -0
  101. package/dist/client/static/js/{mermaid.core-vty0aq6f.js → mermaid.core-b6ga2y8y.js} +6 -6
  102. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-ra4wrts4.js → mindmap-definition-NLK3R4M7-na9e9b4a.js} +2 -2
  103. package/dist/client/static/js/one-dark-pro-xp6ssk4z.js +1 -0
  104. package/dist/client/static/js/one-light-xgab7b02.js +1 -0
  105. package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +1 -0
  106. package/dist/client/static/js/{pegDiagram-GJSIUBJH-ydjcfea9.js → pegDiagram-GJSIUBJH-d1hk7fnq.js} +1 -1
  107. package/dist/client/static/js/{perl-gg4jdkcr.js → perl-dvz4y1tb.js} +1 -1
  108. package/dist/client/static/js/{php-2q8fm6k8.js → php-n6y7dzhm.js} +1 -1
  109. package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +1 -0
  110. package/dist/client/static/js/{pieDiagram-5QR66LMP-wh04y7wp.js → pieDiagram-5QR66LMP-7b9f4x0y.js} +2 -2
  111. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-4mhbag8n.js → quadrantDiagram-O4NWA36T-q4wxgmhg.js} +1 -1
  112. package/dist/client/static/js/radar-RG4KPBEZ-m3tsyfv0.js +1 -0
  113. package/dist/client/static/js/railroad-74A4TZTK-5p202a4q.js +1 -0
  114. package/dist/client/static/js/railroad-abnf-HS5TGJTU-hj0y9tgn.js +1 -0
  115. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-8c5dct8f.js +1 -0
  116. package/dist/client/static/js/railroad-peg-WCYAUIDC-3tx8z65q.js +1 -0
  117. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-pagmr4hc.js → railroadDiagram-XR7U4H2S-jngq1qx4.js} +1 -1
  118. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-jhfhp4eq.js → requirementDiagram-PLB6GJNP-6xph3b72.js} +4 -4
  119. package/dist/client/static/js/{ruby-vag6a82m.js → ruby-7zye3g0e.js} +1 -1
  120. package/dist/client/static/js/{rust-yntkm6hw.js → rust-w6hen2h4.js} +1 -1
  121. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-qrfxzvp3.js → sankeyDiagram-IPEJSGJF-ncfzgdj8.js} +1 -1
  122. package/dist/client/static/js/{sass-kbwea482.js → sass-m0h9yzfb.js} +1 -1
  123. package/dist/client/static/js/{scss-zphrqp25.js → scss-2pwwfkvn.js} +1 -1
  124. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-fpznwnva.js → sequenceDiagram-PO4LG4MO-sqz0yfg0.js} +3 -3
  125. package/dist/client/static/js/{sizeCapture-INFHLROL-3hz930jg.js → sizeCapture-INFHLROL-vt8qp04d.js} +1 -1
  126. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-2m99syxm.js → stateDiagram-v2-GCMORJYK-myjtrmfe.js} +3 -3
  127. package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-x8f8c8hq.js} +1 -1
  128. package/dist/client/static/js/{swimlanes-2SLR337P-hmhd360r.js → swimlanes-2SLR337P-z9vx7z4j.js} +1 -1
  129. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-a8b7z74e.js → swimlanesDiagram-TC7HE7FX-5vha7thx.js} +1 -1
  130. package/dist/client/static/js/{timeline-definition-EJHVYXUP-765y3ssa.js → timeline-definition-EJHVYXUP-z815np57.js} +2 -2
  131. package/dist/client/static/js/treeView-Q6P3EWNA-mf0rb2yv.js +1 -0
  132. package/dist/client/static/js/treemap-WGGIJYW6-0x5gf06b.js +1 -0
  133. package/dist/client/static/js/typescript-5nmrzgkj.js +1 -0
  134. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-rex2j507.js → usecaseDiagram-POWQR4AR-06ntggng.js} +13 -13
  135. package/dist/client/static/js/{vennDiagram-UO4OBE2U-wd51qq26.js → vennDiagram-UO4OBE2U-nmtaf5rp.js} +1 -1
  136. package/dist/client/static/js/{vue-j8vb9d7r.js → vue-myjjd0gd.js} +1 -1
  137. package/dist/client/static/js/wardley-WFR3VGLG-x7ej8dms.js +1 -0
  138. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-6jdqn8f7.js → wardleyDiagram-VNRHLVJA-zgsxmak8.js} +1 -1
  139. package/dist/client/static/js/xml-3dd1pter.js +1 -0
  140. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-kcz8y04e.js → xychartDiagram-PMCCYNJV-8bg9qdra.js} +2 -2
  141. package/package.json +1 -1
  142. package/src/client/components/common/ComposerPicker.tsx +24 -12
  143. package/src/client/components/common/ComposerTextarea.tsx +1 -0
  144. package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +1 -1
  145. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +1 -1
  146. package/src/client/components/workspace/chat-timeline/index.tsx +3 -3
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.test.tsx +210 -0
  148. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +342 -0
  149. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/LooseFieldAsk.tsx +44 -0
  150. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.test.tsx +44 -1
  151. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +10 -5
  152. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/PluginPendingInteractions.test.ts +1 -0
  153. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +19 -0
  154. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/form-picks.ts +52 -0
  155. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +2 -2
  156. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +53 -4
  157. package/src/client/components/workspace/model-dropdown/index.tsx +1 -1
  158. package/src/client/components/workspace/model-dropdown/use-catalog.ts +3 -32
  159. package/src/client/data/settings/omp-schema.json +55 -1
  160. package/src/client/hooks/chat/composer/harness-model-picker.ts +84 -0
  161. package/src/client/hooks/chat/composer/index.ts +26 -6
  162. package/src/client/hooks/chat/timeline/ask-frames.test.ts +80 -7
  163. package/src/client/hooks/chat/timeline/ask-frames.ts +95 -21
  164. package/src/client/hooks/models/use-harnesses.ts +15 -2
  165. package/src/server/lib/auth/agent-gate.server.ts +64 -0
  166. package/src/server/lib/auth/agent-tree-gate.test.ts +121 -0
  167. package/src/server/lib/auth/guard.test.ts +18 -18
  168. package/src/server/lib/auth/guard.ts +15 -11
  169. package/src/server/lib/auth/handover-guard.test.ts +1 -1
  170. package/src/server/lib/changes/attach.server.ts +57 -0
  171. package/src/server/lib/changes/attach.test.ts +94 -0
  172. package/src/server/lib/changes/blobs.server.ts +52 -0
  173. package/src/server/lib/changes/capture-bash.server.ts +171 -0
  174. package/src/server/lib/changes/capture-fs.server.ts +64 -0
  175. package/src/server/lib/changes/capture-races.test.ts +107 -0
  176. package/src/server/lib/changes/capture-runs.test.ts +136 -0
  177. package/src/server/lib/changes/capture-scan.test.ts +157 -0
  178. package/src/server/lib/changes/capture-test-util.ts +46 -0
  179. package/src/server/lib/changes/capture-types.ts +64 -0
  180. package/src/server/lib/changes/capture-write.server.ts +50 -0
  181. package/src/server/lib/changes/capture.server.ts +349 -0
  182. package/src/server/lib/changes/capture.test.ts +293 -0
  183. package/src/server/lib/changes/classify-command.test.ts +172 -0
  184. package/src/server/lib/changes/classify-command.ts +272 -0
  185. package/src/server/lib/changes/classify-git.ts +88 -0
  186. package/src/server/lib/changes/classify-paths.ts +112 -0
  187. package/src/server/lib/changes/classify-tokenize.ts +185 -0
  188. package/src/server/lib/changes/journal.server.ts +185 -0
  189. package/src/server/lib/changes/journal.test.ts +125 -0
  190. package/src/server/lib/changes/merge.test.ts +137 -0
  191. package/src/server/lib/changes/omp-fallback.server.ts +48 -0
  192. package/src/server/lib/changes/omp-fallback.test.ts +75 -0
  193. package/src/server/lib/changes/paths.server.ts +37 -0
  194. package/src/server/lib/changes/purge.server.ts +32 -0
  195. package/src/server/lib/changes/reader.server.ts +350 -0
  196. package/src/server/lib/changes/reader.test.ts +137 -0
  197. package/src/server/lib/changes/records.ts +120 -0
  198. package/src/server/lib/changes/scan.server.ts +139 -0
  199. package/src/server/lib/changes/sessions.server.ts +65 -0
  200. package/src/server/lib/changes/sessions.test.ts +52 -0
  201. package/src/server/lib/harness/register.server.ts +3 -0
  202. package/src/server/lib/omp/rpc/event-fanout.test.ts +58 -0
  203. package/src/server/lib/omp/rpc/event-fanout.ts +19 -0
  204. package/src/server/lib/omp/rpc/manager.ts +4 -3
  205. package/src/server/lib/omp/rpc/session-registration.ts +5 -0
  206. package/src/server/lib/omp/rpc/session-registry.ts +4 -5
  207. package/src/server/lib/omp/session/delete.server.ts +4 -0
  208. package/src/server/lib/sessions/agent-token.server.test.ts +28 -5
  209. package/src/server/lib/sessions/agent-token.server.ts +42 -6
  210. package/src/server/lib/sessions/relation-access.server.test.ts +96 -0
  211. package/src/server/lib/sessions/relation-access.server.ts +71 -0
  212. package/src/server/routes/sessions/changes.ts +1 -1
  213. package/src/shared/lib/chat/ask-form/fields.ts +1 -0
  214. package/src/shared/lib/chat/ask-form/types.ts +6 -0
  215. package/src/shared/lib/chat/ask-questions.ts +56 -3
  216. package/src/shared/lib/chat/composer/delegation.ts +2 -13
  217. package/src/shared/lib/chat/composer/filter.test.ts +39 -0
  218. package/src/shared/lib/chat/composer/filter.ts +23 -13
  219. package/src/shared/lib/chat/composer/harness-model-items.test.ts +54 -0
  220. package/src/shared/lib/chat/composer/harness-model-items.ts +41 -0
  221. package/src/shared/lib/chat/composer/trigger.test.ts +50 -0
  222. package/src/shared/lib/chat/composer/trigger.ts +29 -1
  223. package/src/shared/lib/chat/timeline/changed-files.test.ts +16 -0
  224. package/src/shared/lib/chat/timeline/changed-files.ts +102 -25
  225. package/src/shared/lib/harness/catalog.ts +21 -0
  226. package/src/{client/components/workspace/model-dropdown/harness-models.test.ts → shared/lib/harness/models.test.ts} +1 -1
  227. package/src/shared/lib/models/option.ts +46 -0
  228. package/src/shared/lib/omp/config/schema.test.ts +20 -0
  229. package/src/shared/types/chat.ts +12 -6
  230. package/src/shared/types/omp/agent.ts +9 -0
  231. package/src/shared/types/session-changes.ts +4 -0
  232. package/dist/client/static/js/architecture-7GRP2DOG-7ewrw5vc.js +0 -1
  233. package/dist/client/static/js/c-wkgxb1t1.js +0 -1
  234. package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
  235. package/dist/client/static/js/css-r2nhvzff.js +0 -1
  236. package/dist/client/static/js/css-tf1s0nb7.js +0 -1
  237. package/dist/client/static/js/cynefin-OW5HDTMX-yyyx3px0.js +0 -1
  238. package/dist/client/static/js/eventmodeling-NTZA5JFV-cx3ztxfz.js +0 -1
  239. package/dist/client/static/js/flowDiagram-KWPJA3E3-267mw6sv.js +0 -1
  240. package/dist/client/static/js/gitGraph-4MIJSDKK-eg9r85ak.js +0 -1
  241. package/dist/client/static/js/graphql-skw5krjr.js +0 -1
  242. package/dist/client/static/js/html-pv88ny12.js +0 -1
  243. package/dist/client/static/js/index-tcegdd2t.js +0 -1
  244. package/dist/client/static/js/info-A6RAGUB7-7qhah7fs.js +0 -1
  245. package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
  246. package/dist/client/static/js/lua-ke895s2q.js +0 -1
  247. package/dist/client/static/js/one-dark-pro-2pywnqrh.js +0 -1
  248. package/dist/client/static/js/one-light-vfgdt4wf.js +0 -1
  249. package/dist/client/static/js/packet-AYTQ26CC-ag2g7tbk.js +0 -1
  250. package/dist/client/static/js/pie-WAS4IAKB-nqcyj3x1.js +0 -1
  251. package/dist/client/static/js/radar-RG4KPBEZ-60gby7be.js +0 -1
  252. package/dist/client/static/js/railroad-74A4TZTK-cnkmcjse.js +0 -1
  253. package/dist/client/static/js/railroad-abnf-HS5TGJTU-qgfdnazd.js +0 -1
  254. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-609h6cpx.js +0 -1
  255. package/dist/client/static/js/railroad-peg-WCYAUIDC-xqnytjhg.js +0 -1
  256. package/dist/client/static/js/treeView-Q6P3EWNA-8djqab8k.js +0 -1
  257. package/dist/client/static/js/treemap-WGGIJYW6-hdztnffk.js +0 -1
  258. package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
  259. package/dist/client/static/js/wardley-WFR3VGLG-avby77vv.js +0 -1
  260. package/dist/client/static/js/xml-81hxjjt4.js +0 -1
  261. /package/src/{client/components/workspace/model-dropdown/harness-models.ts → shared/lib/harness/models.ts} +0 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The tree rule, pinned.
8
+ *
9
+ * These cases are the contract the agent token gate relies on: a worker may
10
+ * reach its coordinator, a coordinator may reach its workers, and a sibling is
11
+ * a different branch. The fork case is here because a fork row has a SOURCE
12
+ * edge and no parent edge — a walk that ignored `origin_kind` would let a
13
+ * source's parent address the fork.
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 { ensureSessionRelationsSchema } from '@/server/lib/sessions/schema.server';
20
+ import { resolveAgentAccess } from '@/server/lib/sessions/relation-access.server';
21
+
22
+ async function relation(
23
+ sessionId: string,
24
+ parentSessionId: string | null,
25
+ sourceSessionId: string | null = null,
26
+ ): Promise<void> {
27
+ const db = await getDb();
28
+ await db.run(
29
+ `INSERT INTO session_relations
30
+ (session_id, parent_session_id, source_session_id, origin_kind, created_at)
31
+ VALUES (?, ?, ?, ?, ?)`,
32
+ [sessionId, parentSessionId, sourceSessionId, sourceSessionId ? 'fork' : null, Date.now()],
33
+ );
34
+ }
35
+
36
+ beforeEach(async () => {
37
+ await isolateDb();
38
+ await ensureSessionRelationsSchema(await getDb());
39
+ // C is the orchestrator; W1/W2 are its workers; H1 is W1's helper; F is a fork
40
+ // of W1, which therefore has no parent edge.
41
+ await relation('C', null);
42
+ await relation('W1', 'C');
43
+ await relation('W2', 'C');
44
+ await relation('H1', 'W1');
45
+ await relation('F', null, 'W1');
46
+ });
47
+
48
+ afterEach(async () => {
49
+ await releaseDb();
50
+ });
51
+
52
+ describe('agent access follows the session tree', () => {
53
+ test('a session may act on itself', async () => {
54
+ expect(await resolveAgentAccess('C', 'C')).toBe('self');
55
+ });
56
+
57
+ test('a coordinator may act on its workers and their helpers', async () => {
58
+ expect(await resolveAgentAccess('C', 'W1')).toBe('descendant');
59
+ expect(await resolveAgentAccess('C', 'H1')).toBe('descendant');
60
+ });
61
+
62
+ test('a worker may act on its coordinator and grandparent', async () => {
63
+ expect(await resolveAgentAccess('W1', 'C')).toBe('ancestor');
64
+ expect(await resolveAgentAccess('H1', 'C')).toBe('ancestor');
65
+ expect(await resolveAgentAccess('H1', 'W1')).toBe('ancestor');
66
+ });
67
+
68
+ test('a sibling is a different branch', async () => {
69
+ expect(await resolveAgentAccess('W1', 'W2')).toBeNull();
70
+ expect(await resolveAgentAccess('W2', 'H1')).toBeNull();
71
+ });
72
+
73
+ test('a fork is not reachable through its source', async () => {
74
+ expect(await resolveAgentAccess('C', 'F')).toBeNull();
75
+ expect(await resolveAgentAccess('W1', 'F')).toBeNull();
76
+ });
77
+
78
+ test('an unknown session is not in anyone’s tree', async () => {
79
+ expect(await resolveAgentAccess('X', 'C')).toBeNull();
80
+ expect(await resolveAgentAccess('C', 'X')).toBeNull();
81
+ });
82
+
83
+ test('a session with no relation row is a root', async () => {
84
+ expect(await resolveAgentAccess('ROOT', 'C')).toBeNull();
85
+ expect(await resolveAgentAccess('C', 'ROOT')).toBeNull();
86
+ });
87
+
88
+ test('a cyclic row terminates instead of hanging', async () => {
89
+ // Corrupt data, not a legal tree: the depth guard is what keeps the walk
90
+ // finite. A policy check inside the recursion would hang here.
91
+ const db = await getDb();
92
+ await db.run("UPDATE session_relations SET parent_session_id = 'H1' WHERE session_id = 'C'");
93
+ expect(await resolveAgentAccess('C', 'W2')).toBe('descendant');
94
+ expect(await resolveAgentAccess('W2', 'C')).toBe('ancestor');
95
+ });
96
+ });
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Whether one session's agent token may act on another session.
8
+ *
9
+ * The rule is the TREE, not one id: a session may act on itself, on its
10
+ * ancestors, and on its descendants. That is exactly the two directions the
11
+ * orchestration contract uses — a worker tells its coordinator, a coordinator
12
+ * reads its worker — and nothing else. A sibling is a different branch, and a
13
+ * fork has a source edge rather than a parent edge, so neither is reachable.
14
+ *
15
+ * Why this module exists at all: the gate used to compare the id in the path to
16
+ * the token's session, which refused BOTH directions. With UI authentication
17
+ * off the gate returns before that comparison, so the defect was invisible in
18
+ * the measured three-worker run and fatal on a password-protected console.
19
+ *
20
+ * The walk is two recursive CTEs over `session_relations`, both bounded by a
21
+ * depth guard. The guard is 8, not `MAX_SESSION_DEPTH` (4): 4 is the policy the
22
+ * spawn service enforces, 8 is what stops a corrupt row from looping forever.
23
+ * A policy check inside the recursion would turn bad data into a hang.
24
+ */
25
+
26
+ import { getDb } from '@/server/db.server';
27
+
28
+ export type AgentAccess = 'self' | 'ancestor' | 'descendant' | null;
29
+
30
+ /** How far a walk may go before it is treated as corrupt data, not a tree. */
31
+ const WALK_GUARD = 8;
32
+
33
+ /**
34
+ * The relationship between the caller and the target, or null when the target
35
+ * is outside the caller's tree.
36
+ *
37
+ * A session with no relation row is a root: it may act on itself and on nothing
38
+ * else. A fork row has `parent_session_id = NULL`, so it never appears in
39
+ * either walk — that is the schema, not a special case here.
40
+ */
41
+ export async function resolveAgentAccess(caller: string, target: string): Promise<AgentAccess> {
42
+ if (caller === target) return 'self';
43
+ const db = await getDb();
44
+
45
+ // Down: start at the caller and follow parent edges forward.
46
+ const down = await db.get<{ hit: number }>(
47
+ `WITH RECURSIVE down(id, depth) AS (
48
+ SELECT session_id, 0 FROM session_relations WHERE session_id = ?
49
+ UNION ALL
50
+ SELECT r.session_id, down.depth + 1
51
+ FROM session_relations r JOIN down ON r.parent_session_id = down.id
52
+ WHERE down.depth < ${WALK_GUARD}
53
+ ) SELECT 1 AS hit FROM down WHERE id = ? LIMIT 1`,
54
+ [caller, target],
55
+ );
56
+ if (down) return 'descendant';
57
+
58
+ // Up: start at the caller's parent and follow parent edges backward. Starting
59
+ // at the TARGET's parent would answer the descendant question a second time.
60
+ const up = await db.get<{ hit: number }>(
61
+ `WITH RECURSIVE up(id, depth) AS (
62
+ SELECT parent_session_id, 1 FROM session_relations WHERE session_id = ?
63
+ UNION ALL
64
+ SELECT r.parent_session_id, up.depth + 1
65
+ FROM session_relations r JOIN up ON r.session_id = up.id
66
+ WHERE up.depth < ${WALK_GUARD}
67
+ ) SELECT 1 AS hit FROM up WHERE id = ? LIMIT 1`,
68
+ [caller, target],
69
+ );
70
+ return up ? 'ancestor' : null;
71
+ }
@@ -29,7 +29,7 @@
29
29
  import { json } from '@/server/lib/remix-compat';
30
30
  import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
31
31
  import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
32
- import { readSessionChangeDiff, readSessionChangeList, readSessionChangeStats } from '@/server/lib/omp/session/changes';
32
+ import { readSessionChangeDiff, readSessionChangeList, readSessionChangeStats } from '@/server/lib/changes/reader.server';
33
33
 
34
34
  /** GET /api/sessions/:sessionId/changes */
35
35
  export async function getSessionChanges({ params }: LoaderFunctionArgs) {
@@ -53,6 +53,7 @@ export function toQuestions(fields: DraftField[]): AskQuestion[] {
53
53
  const options: AskOption[] = field.options.map((option) => ({
54
54
  label: option.label || option.value,
55
55
  value: option.value,
56
+ ...(option.checked ? { checked: true } : {}),
56
57
  }));
57
58
  if (
58
59
  field.kind === 'choice' &&
@@ -15,6 +15,12 @@ export interface AskOption {
15
15
  preview?: string;
16
16
  /** The control's `value`, when an HTML form spelled one ("Value" in JSON). */
17
17
  value?: string;
18
+ /**
19
+ * A checkbox/radio the `<form>` marks `checked`/`selected`. A multi-select
20
+ * starts with these ON, and sending such a label toggles it OFF — so the UIs
21
+ * must draw the default rather than an empty set.
22
+ */
23
+ checked?: boolean;
18
24
  }
19
25
 
20
26
  export interface AskQuestion {
@@ -59,6 +59,14 @@ export function normalizeAskText(value: string): string {
59
59
  * title starts with followed by ` (` — the shape omp's field-by-field walk
60
60
  * uses for a rejected text answer (`question (Enter a number)`). Longest wins
61
61
  * so `Pick a colour (light)` is not captured by an `Pick a colour` beside it.
62
+ *
63
+ * A prefixed match is the other half: omp titles a field with its CONTEXT (the
64
+ * text between the previous control and this one) followed by the question, so
65
+ * a form with an explanatory paragraph before a field asked
66
+ * `paragraph question` and matched nothing. That frame then reached the
67
+ * modal — the reported "question 2 opens as a dialog" — because the per-field
68
+ * walk claims by title and a context block is common. Matching the suffix
69
+ * keeps the frame on its card.
62
70
  */
63
71
  export function askQuestionForTitle(questions: AskQuestion[], title: unknown): number {
64
72
  if (typeof title !== 'string') return -1;
@@ -69,7 +77,13 @@ export function askQuestionForTitle(questions: AskQuestion[], title: unknown): n
69
77
  for (let index = 0; index < questions.length; index += 1) {
70
78
  const candidate = normalizeAskText(questions[index].question);
71
79
  if (!candidate || candidate.length <= longest) continue;
72
- if (needle === candidate || needle.startsWith(`${candidate} (`)) {
80
+ // Exact, omp's rejected-answer suffix, a context PREFIX, or both at once.
81
+ if (
82
+ needle === candidate ||
83
+ needle.startsWith(`${candidate} (`) ||
84
+ needle.endsWith(` ${candidate}`) ||
85
+ needle.includes(` ${candidate} (`)
86
+ ) {
73
87
  best = index;
74
88
  longest = candidate.length;
75
89
  }
@@ -90,6 +104,7 @@ function readOption(raw: unknown): AskOption | null {
90
104
  label,
91
105
  description: typeof record.description === 'string' ? record.description : undefined,
92
106
  preview: typeof record.preview === 'string' ? record.preview : undefined,
107
+ ...(record.checked === true ? { checked: true } : {}),
93
108
  };
94
109
  }
95
110
 
@@ -109,6 +124,12 @@ export function isAskToolCall(tool: ToolCallData): boolean {
109
124
  * are the fallback key: the question's own options (minus the synthetic
110
125
  * "Other" row) must be exactly the rows the dialog offers (minus omp's "Other"
111
126
  * and multi-select "Done" rows), and there must be at least two of them.
127
+ *
128
+ * A question with ONE row is the exception that needs the same key: a single
129
+ * checkbox has no `Other` row and no second label to make a set, and a
130
+ * context-prefixed title (see `askQuestionForTitle`) used to leave it as the
131
+ * only question with no claim at all. The exact single label is still specific
132
+ * enough to identify it among the open ask's own questions.
112
133
  */
113
134
  export function askQuestionForOptions(questions: AskQuestion[], options: unknown): number {
114
135
  if (!Array.isArray(options)) return -1;
@@ -118,18 +139,50 @@ export function askQuestionForOptions(questions: AskQuestion[], options: unknown
118
139
  .map(normalizeAskText)
119
140
  .filter((label) => label && !isOtherOption(label) && !/done selecting$/.test(label)),
120
141
  );
121
- if (offered.size < 2) return -1;
142
+ if (offered.size === 0) return -1;
122
143
  let best = -1;
123
144
  for (let index = 0; index < questions.length; index += 1) {
124
145
  const labels = questions[index].options
125
146
  .map((option) => normalizeAskText(option.label))
126
147
  .filter((label) => label && !isOtherOption(label));
127
- if (labels.length < 2 || labels.length !== offered.size) continue;
148
+ if (labels.length !== offered.size) continue;
149
+ if (labels.length < 2 && questions[index].options.length !== 1) continue;
128
150
  if (labels.every((label) => offered.has(label))) best = index;
129
151
  }
130
152
  return best;
131
153
  }
132
154
 
155
+ /**
156
+ * Index of the question a per-field dialog belongs to: its title first, then
157
+ * its rows. Both keys are the ones omp and Kabmo must agree on, and a caller
158
+ * that only wants "does this frame belong to this ask" gets one answer.
159
+ */
160
+ export function askQuestionForFrame(questions: AskQuestion[], frame: ExtensionUiDialogRequest): number {
161
+ const byTitle = askQuestionForTitle(questions, frame.title);
162
+ if (byTitle !== -1) return byTitle;
163
+ return askQuestionForOptions(questions, frame.options);
164
+ }
165
+
166
+ /**
167
+ * True when a dialog title shares a distinctive word with the question.
168
+ *
169
+ * The last-resort owner of a field dialog is the only open ask, but that must
170
+ * not swallow an extension picker that happens to arrive while the agent is
171
+ * blocked. Titles that share no content word with any question are treated as
172
+ * someone else's dialog; the words are long enough (`length > 3`) that `the`,
173
+ * `a` or punctuation cannot make a match.
174
+ */
175
+ export function askQuestionSharesText(questions: AskQuestion[], title: unknown): boolean {
176
+ if (typeof title !== 'string') return false;
177
+ const needle = normalizeAskText(title);
178
+ if (!needle) return false;
179
+ return questions.some((question) =>
180
+ normalizeAskText(question.question)
181
+ .split(' ')
182
+ .some((word) => word.length > 3 && needle.includes(word)),
183
+ );
184
+ }
185
+
133
186
  /**
134
187
  * True for an ask omp has given up on — its dialog was withdrawn (a validation
135
188
  * failure, an abort), so no live frame can belong to it and its card renders no
@@ -17,7 +17,7 @@
17
17
  * known agent name.
18
18
  */
19
19
 
20
- import { harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
20
+ import { harnessDescriptor, harnessIdForName, type HarnessId } from '@/shared/lib/harness/catalog';
21
21
 
22
22
  export interface HarnessDelegation {
23
23
  harness: HarnessId;
@@ -51,17 +51,6 @@ export interface ParseDelegationOptions {
51
51
  /** `@harness:<id>[:<model>]` or bare `@<harnessId>`. */
52
52
  const MENTION_RE = /(^|[\s([{])@(?:(harness):)?([a-z0-9][a-z0-9-]*)(?::([^\s#]+))?/gi;
53
53
 
54
- /** The names users type that are not catalog ids. `omp` is the default RPC
55
- * surface; `claude-code` is the vendor's name for the `claude` adapter. */
56
- const HARNESS_ALIASES: Readonly<Record<string, HarnessId>> = {
57
- omp: 'omp-rpc',
58
- 'claude-code': 'claude',
59
- };
60
-
61
- function harnessIdFor(name: string): HarnessId | null {
62
- return HARNESS_ALIASES[name] ?? (harnessDescriptor(name) ? (name as HarnessId) : null);
63
- }
64
-
65
54
  /**
66
55
  * Parse one message. The error list is non-empty when the message cannot be
67
56
  * delegated as written; the caller refuses the send rather than guessing.
@@ -84,7 +73,7 @@ export function parseHarnessMentions(
84
73
  const name = match[3]?.toLowerCase();
85
74
  if (!name) continue;
86
75
  const isBare = namespace === undefined;
87
- const known = harnessIdFor(name);
76
+ const known = harnessIdForName(name);
88
77
  if (namespace && !known) {
89
78
  errors.push({
90
79
  code: 'unknown_harness',
@@ -176,3 +176,42 @@ describe('filterComposerItems — command dispatch', () => {
176
176
  expect(names(filterComposerItems(COMMANDS, trigger))).toEqual(['retry']);
177
177
  });
178
178
  });
179
+
180
+ describe('filterComposerItems — @harness:<id>: model phase', () => {
181
+ const MODELS: ComposerPickItem[] = [
182
+ { id: 'm1', name: 'DeepSeek V4.1 Flash', description: 'kenari-jatis/deepseek-v4.1-flash', kind: 'model', source: 'model', token: 'kenari-jatis/deepseek-v4.1-flash' },
183
+ { id: 'm2', name: 'Claude Fable 5', description: 'kenari/claude-fable-5', kind: 'model', source: 'model', token: 'kenari/claude-fable-5' },
184
+ { id: 'm3', name: 'Opus', description: 'opus', kind: 'model', source: 'model', token: 'opus' },
185
+ ];
186
+ const modelTrigger = (query: string): ComposerTrigger => ({
187
+ kind: 'mention',
188
+ query,
189
+ start: 0,
190
+ end: 17 + query.length,
191
+ phase: 'model',
192
+ replaceFrom: 17,
193
+ harness: 'omp-rpc',
194
+ });
195
+
196
+ test('an empty query lists the whole harness catalogue in order', () => {
197
+ expect(names(filterComposerItems(MODELS, modelTrigger('')))).toEqual([
198
+ 'DeepSeek V4.1 Flash', 'Claude Fable 5', 'Opus',
199
+ ]);
200
+ });
201
+
202
+ test('a model name ranks by the same tiers as every other mention', () => {
203
+ expect(names(filterComposerItems(MODELS, modelTrigger('opus')))).toEqual(['Opus']);
204
+ expect(names(filterComposerItems(MODELS, modelTrigger('claude')))).toEqual(['Claude Fable 5']);
205
+ });
206
+
207
+ test('a provider/value pasted into the tail matches the row description', () => {
208
+ expect(names(filterComposerItems(MODELS, modelTrigger('kenari-jatis/')))).toEqual(['DeepSeek V4.1 Flash']);
209
+ });
210
+
211
+ test('a `file:` prefix does NOT scope the model list to files', () => {
212
+ const rows: ComposerPickItem[] = [
213
+ { id: 'm', name: 'file:model', description: '', kind: 'model', source: 'model', token: 'file:model' },
214
+ ];
215
+ expect(names(filterComposerItems(rows, modelTrigger('file:')))).toEqual(['file:model']);
216
+ });
217
+ });
@@ -37,6 +37,22 @@ function rankComposerItem(
37
37
  return null;
38
38
  }
39
39
 
40
+ function rankMentionItems(items: ComposerPickItem[], rankingQuery: string): ComposerMatchItem[] {
41
+ if (rankingQuery === '') {
42
+ return items.map((item) => ({ ...item, match: null }));
43
+ }
44
+
45
+ const ranked: RankedMatch[] = [];
46
+ items.forEach((item, index) => {
47
+ const score = rankComposerItem(item.name, item.description, rankingQuery);
48
+ if (score) ranked.push({ ...score, index });
49
+ });
50
+
51
+ ranked.sort((a, b) => a.tier - b.tier || a.index - b.index);
52
+
53
+ return ranked.map((entry) => ({ ...items[entry.index], match: entry.match }));
54
+ }
55
+
40
56
  /**
41
57
  * Filter `@` mention items by query, ranked by tier then original order.
42
58
  *
@@ -51,23 +67,17 @@ function filterMentionItems(items: ComposerPickItem[], query: string): ComposerM
51
67
  const pool = fileQuery ? items.filter((item) => item.source === 'file') : items;
52
68
  const rankingQuery = fileQuery ? trimmed.replace(FILE_QUERY_PREFIX_RE, '').trim() : trimmed;
53
69
 
54
- if (rankingQuery === '') {
55
- return pool.map((item) => ({ ...item, match: null }));
56
- }
57
-
58
- const ranked: RankedMatch[] = [];
59
- pool.forEach((item, index) => {
60
- const score = rankComposerItem(item.name, item.description, rankingQuery);
61
- if (score) ranked.push({ ...score, index });
62
- });
63
-
64
- ranked.sort((a, b) => a.tier - b.tier || a.index - b.index);
65
-
66
- return ranked.map((entry) => ({ ...pool[entry.index], match: entry.match }));
70
+ return rankMentionItems(pool, rankingQuery);
67
71
  }
68
72
 
69
73
  /** Dispatch on the trigger: mentions keep their own ranking, commands use omp's. */
70
74
  export function filterComposerItems(items: ComposerPickItem[], trigger: ComposerTrigger): ComposerMatchItem[] {
75
+ // A harness's model list has no `file:` namespace of its own, so it ranks as
76
+ // a plain pool. Reusing the mention ranker keeps exact > prefix > substring >
77
+ // description identical to every other `@` row.
78
+ if (trigger.kind === 'mention' && trigger.phase === 'model') {
79
+ return rankMentionItems(items, trigger.query.trim());
80
+ }
71
81
  if (trigger.kind === 'mention') return filterMentionItems(items, trigger.query);
72
82
  if (trigger.phase === 'args' && trigger.command) {
73
83
  return commandArgumentItems(items, trigger.command, trigger.query);
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `@harness:<id>:` model rows.
8
+ *
9
+ * The token is what `kabmo session spawn --model` receives, so a wrong shape is
10
+ * a wrong model at spawn time — not a cosmetic bug. A harness with providers
11
+ * (omp) needs `provider/id`; an ACP agent that publishes bare values must not
12
+ * gain a `//` or an `unknown/` prefix.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+ import { harnessModelPickItems, harnessModelValue } from '@/shared/lib/chat/composer/harness-model-items';
17
+ import type { AIModelOption } from '@/shared/types';
18
+
19
+ const ompModel: AIModelOption = {
20
+ id: 'deepseek-v4.1-flash',
21
+ name: 'DeepSeek V4.1 Flash',
22
+ provider: 'kenari-jatis',
23
+ contextWindow: 1_000_000,
24
+ };
25
+
26
+ const acpModel: AIModelOption = { id: 'opus', name: 'Opus', provider: '' };
27
+
28
+ describe('harnessModelValue', () => {
29
+ test('joins provider and id for a provider-publishing harness', () => {
30
+ expect(harnessModelValue(ompModel)).toBe('kenari-jatis/deepseek-v4.1-flash');
31
+ });
32
+
33
+ test('leaves a bare ACP value alone', () => {
34
+ expect(harnessModelValue(acpModel)).toBe('opus');
35
+ });
36
+ });
37
+
38
+ describe('harnessModelPickItems', () => {
39
+ test('a row inserts the model value, not the whole mention', () => {
40
+ const [row] = harnessModelPickItems([ompModel], 'omp-rpc');
41
+ if (!row) throw new Error('expected one row');
42
+ expect(row.token).toBe('kenari-jatis/deepseek-v4.1-flash');
43
+ expect(row.name).toBe('DeepSeek V4.1 Flash');
44
+ expect(row.description).toBe('kenari-jatis/deepseek-v4.1-flash · 1000000');
45
+ expect(row.kind).toBe('model');
46
+ expect(row.source).toBe('model');
47
+ });
48
+
49
+ test('ids stay unique per harness and per value', () => {
50
+ const rows = harnessModelPickItems([ompModel, acpModel], 'claude');
51
+ expect(new Set(rows.map((row) => row.id)).size).toBe(2);
52
+ expect(rows[0]?.id).toContain('claude');
53
+ });
54
+ });
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Model rows for the `@harness:<id>:` completion.
8
+ *
9
+ * The token is the value the delegation parser hands to
10
+ * `kabmo session spawn --model`: `<provider>/<id>` for a harness that publishes
11
+ * providers (omp's registry), or the bare id an ACP agent lists. It is NOT
12
+ * `@harness:<id>:<model>` — the trigger already scopes the replacement to the
13
+ * text after the second colon, so inserting the whole mention would duplicate
14
+ * the namespace the user typed.
15
+ */
16
+
17
+ import type { AIModelOption, ComposerPickItem } from '@/shared/types';
18
+
19
+ /** The exact `--model` value for one row. */
20
+ export function harnessModelValue(model: AIModelOption): string {
21
+ return model.provider ? `${model.provider}/${model.id}` : model.id;
22
+ }
23
+
24
+ /** Map one harness's model list into popup rows. */
25
+ export function harnessModelPickItems(
26
+ models: readonly AIModelOption[],
27
+ harness: string,
28
+ ): ComposerPickItem[] {
29
+ return models.map((model) => {
30
+ const value = harnessModelValue(model);
31
+ const context = model.contextWindow ? ` · ${model.contextWindow}` : '';
32
+ return {
33
+ id: `harness-model-${harness}-${value}`,
34
+ name: model.name || model.id,
35
+ description: `${value}${context}`,
36
+ kind: 'model',
37
+ source: 'model',
38
+ token: value,
39
+ };
40
+ });
41
+ }
@@ -192,6 +192,56 @@ describe('detectComposerTrigger — @ mentions', () => {
192
192
  });
193
193
  });
194
194
 
195
+ describe('detectComposerTrigger — @harness:<id>:[model]', () => {
196
+ test('the tail after the second colon is the model query', () => {
197
+ const text = '@harness:omp-rpc:';
198
+ expect(detectComposerTrigger(text, text.length)).toEqual({
199
+ kind: 'mention',
200
+ query: '',
201
+ start: 0,
202
+ end: text.length,
203
+ phase: 'model',
204
+ // Only the text AFTER `harness:<id>:` is replaced.
205
+ replaceFrom: text.length,
206
+ harness: 'omp-rpc',
207
+ });
208
+ });
209
+
210
+ test('a typed model is the query, and a slash stays inside it', () => {
211
+ const text = '@harness:claude:kenari/agnes';
212
+ expect(detectComposerTrigger(text, text.length)).toMatchObject({
213
+ kind: 'mention',
214
+ phase: 'model',
215
+ query: 'kenari/agnes',
216
+ harness: 'claude',
217
+ start: 0,
218
+ replaceFrom: '@harness:claude:'.length,
219
+ });
220
+ });
221
+
222
+ test('the alias resolves to the catalog id, so the rows are the agent’s own', () => {
223
+ const text = '@harness:omp:op';
224
+ expect(detectComposerTrigger(text, text.length)).toMatchObject({ phase: 'model', harness: 'omp-rpc', query: 'op' });
225
+ });
226
+
227
+ test('a bare harness mention is still a name-phase row', () => {
228
+ const text = '@harness:claude';
229
+ expect(detectComposerTrigger(text, text.length)).toMatchObject({ phase: 'name', query: 'harness:claude' });
230
+ });
231
+
232
+ test('accepting a model keeps the mention the user typed', () => {
233
+ const text = '@harness:omp-rpc:ken';
234
+ const trigger = detectComposerTrigger(text, text.length);
235
+ if (!trigger) throw new Error('expected a trigger');
236
+
237
+ const token = 'kenari-jatis/deepseek ';
238
+ expect(insertToken(text, trigger, token)).toEqual({
239
+ value: `@harness:omp-rpc:${token}`,
240
+ caret: `@harness:omp-rpc:${token}`.length,
241
+ });
242
+ });
243
+ });
244
+
195
245
  describe('tokenForItem', () => {
196
246
  const base: ComposerPickItem = {
197
247
  id: 'x',
@@ -1,8 +1,19 @@
1
+ import { harnessIdForName } from '@/shared/lib/harness/catalog';
1
2
  import type { CommandItem, ComposerMatchItem, ComposerPickItem, ComposerTrigger } from '@/shared/types';
2
3
 
3
4
  /** Chars that may legally precede an `@` agent trigger (besides string start). */
4
5
  const AT_PRECEDING_RE = /[\s([{]/;
5
6
 
7
+ /**
8
+ * `@harness:<id>:<model>` — the model tail the popup completes.
9
+ *
10
+ * The namespace is spelled out here rather than reused from the delegation
11
+ * parser: this is a TYPING rule about the token before the caret, and the
12
+ * parser's job is the whole paragraph after send. Both resolve the id through
13
+ * the same catalog alias table, so `@harness:omp:` scopes to `omp-rpc`.
14
+ */
15
+ const SCOPED_HARNESS_MENTION_RE = /^harness:([a-z0-9][a-z0-9-]*):([^\s#]*)$/i;
16
+
6
17
  /** oh-my-pi's `SKILL_NAMESPACE`: skills are addressed as `/skill:<name>`. */
7
18
  export const SKILL_NAMESPACE = 'skill:';
8
19
 
@@ -167,7 +178,24 @@ export function detectComposerTrigger(text: string, caret: number): ComposerTrig
167
178
  if (ch === '@') {
168
179
  if (i === 0 || AT_PRECEDING_RE.test(beforeOnLine[i - 1])) {
169
180
  const at = lineStart + i;
170
- return { kind: 'mention', query: before.slice(at + 1), start: at, end, phase: 'name', replaceFrom: at };
181
+ const mention = beforeOnLine.slice(i + 1);
182
+ const scoped = SCOPED_HARNESS_MENTION_RE.exec(mention);
183
+ if (scoped) {
184
+ const typed = scoped[1] ?? '';
185
+ // The tail after `harness:<id>:` is the model query, and accepting a
186
+ // row replaces ONLY that tail — `start` still names the `@` so the
187
+ // rest of the mention survives.
188
+ return {
189
+ kind: 'mention',
190
+ query: scoped[2] ?? '',
191
+ start: at,
192
+ end,
193
+ phase: 'model',
194
+ replaceFrom: at + 1 + 'harness:'.length + typed.length + 1,
195
+ harness: harnessIdForName(typed) ?? typed.toLowerCase(),
196
+ };
197
+ }
198
+ return { kind: 'mention', query: mention, start: at, end, phase: 'name', replaceFrom: at };
171
199
  }
172
200
  return null;
173
201
  }
@@ -61,6 +61,22 @@ describe('bucketChangesByRun', () => {
61
61
  expect(buckets.get(3)?.map((file) => file.displayPath)).toEqual(['b.ts']);
62
62
  });
63
63
 
64
+ test('a run id wins over the wall-clock window', () => {
65
+ // `runAt` 900 is just before the first window (1000); the change at 2500 is
66
+ // outside every window, but the run id says it belongs to run 1.
67
+ const buckets = bucketChangesByRun(messages, footers, [
68
+ record({ at: 2500, runId: 'r1', runAt: 900, path: '/repo/late.ts', displayPath: 'late.ts' }),
69
+ ]);
70
+ expect(buckets.get(1)?.map((file) => file.displayPath)).toEqual(['late.ts']);
71
+ });
72
+
73
+ test('a late subagent change keeps its run', () => {
74
+ const buckets = bucketChangesByRun(messages, footers, [
75
+ record({ at: 5000, runId: 'r1', runAt: 1000, path: '/repo/late.ts', displayPath: 'late.ts' }),
76
+ ]);
77
+ expect(buckets.get(1)?.map((file) => file.displayPath)).toEqual(['late.ts']);
78
+ });
79
+
64
80
  test('a write outside every window is dropped', () => {
65
81
  const buckets = bucketChangesByRun(messages, footers, [record({ at: 2500 })]);
66
82
  expect(buckets.size).toBe(0);