@kabmo-labs/kabmo 0.47.0 → 0.49.0
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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +535 -521
- package/dist/client/static/js/Body-9h5hd351.js +3 -0
- package/dist/client/static/js/{CsvGrid-vfgttmym.js → CsvGrid-s05k1q18.js} +2 -2
- package/dist/client/static/js/{DocxView-dc41t6rp.js → DocxView-x6sjw5ht.js} +22 -22
- package/dist/client/static/js/{DrawioView-wpwr38d9.js → DrawioView-jashn8sf.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-23n7t5cs.js → HtmlPreview-eygzgtyc.js} +1 -1
- package/dist/client/static/js/ImageView-g50pk5pt.js +1 -0
- package/dist/client/static/js/LayoutWrapper-tag0qpts.js +2 -0
- package/dist/client/static/js/MergeDiffView-c4mb8m1w.js +1 -0
- package/dist/client/static/js/Modal-pf9p6m1k.js +59 -0
- package/dist/client/static/js/PdfView-syhjmyqf.js +1 -0
- package/dist/client/static/js/SessionsView-2r1grxxs.js +1 -0
- package/dist/client/static/js/{SheetView-n6mst0hq.js → SheetView-26r0e506.js} +45 -45
- package/dist/client/static/js/{SvgPreview-g2aqq812.js → SvgPreview-2fk85jzz.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-3vac8sq4.js → abnfDiagram-O67JEVCF-fdka7pxr.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-ee9wjsht.js +1 -0
- package/dist/client/static/js/architectureDiagram-NJMV4G6O-278nx8rt.js +36 -0
- package/dist/client/static/js/{astro-63zcysj7.js → astro-rn2bvwpm.js} +1 -1
- package/dist/client/static/js/bash-36shcpcw.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-62z6kaar.js → blockDiagram-BEXU5L5S-vpcmd3vx.js} +9 -9
- package/dist/client/static/js/c-kxeqssf9.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rts5zgx4.js → c4Diagram-YGBWAQC7-1rgpdnbq.js} +4 -4
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-tnpww186.js → classDiagram-v2-NBCMYWYE-fbsejvb9.js} +9 -9
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-8vsjbzwa.js → cose-bilkent-JH36ORCC-ydq7mvy0.js} +1 -1
- package/dist/client/static/js/cpp-wtk1s3d7.js +1 -0
- package/dist/client/static/js/css-0a0r6rp3.js +1 -0
- package/dist/client/static/js/css-xhnrhg4e.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-gs16zjqa.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-005gc8km.js → cynefinDiagram-VND7K2PF-7ta5vbrw.js} +1 -1
- package/dist/client/static/js/dagre-6A5THRUB-b8gtt32x.js +4 -0
- package/dist/client/static/js/{diagram-22UHCM2B-prsm18a1.js → diagram-22UHCM2B-7emepy7h.js} +28 -28
- package/dist/client/static/js/{diagram-3UASUU5V-5nx9wf04.js → diagram-3UASUU5V-06nptkzc.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-k3d4z3aq.js → diagram-ATOU4E4O-t113exk3.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-x2c5x5j2.js → diagram-CDSNMT55-pyj3x97y.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-nvr76jqh.js → diagram-MLGK6HIB-183sgpjh.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-v1jpzp9p.js → diagram-MPIPVDR6-fmbj4hcx.js} +2 -2
- package/dist/client/static/js/{dockerfile-vz6va73h.js → dockerfile-qay672za.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-0v4tqr9v.js → ebnfDiagram-ZINNZB2B-eafvfws2.js} +1 -1
- package/dist/client/static/js/{elixir-80wq7gak.js → elixir-t8bep87c.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-qfn4r7xj.js → elk-276RUBZZ-573f1vfs.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-cd667n9f.js → erDiagram-OPXOYQCR-4z1r88ej.js} +14 -14
- package/dist/client/static/js/{erlang-vk66vt7q.js → erlang-261km7r1.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-ftz7zrz5.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ax0qfmp3.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ps0h3drm.js → ganttDiagram-FUAMR5RP-49jd7msz.js} +5 -5
- package/dist/client/static/js/gitGraph-4MIJSDKK-3rtkds4s.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fts23jer.js → gitGraphDiagram-X574FWY7-5p9mgq7n.js} +26 -26
- package/dist/client/static/js/graphql-w9ajhndp.js +1 -0
- package/dist/client/static/js/html-krfbq5wp.js +1 -0
- package/dist/client/static/js/index-05n22cg9.js +4 -0
- package/dist/client/static/js/{index-fxd8dfj4.js → index-0857zpr0.js} +2 -2
- package/dist/client/static/js/{index-9ab6xaxd.js → index-0w4jqzqk.js} +2 -2
- package/dist/client/static/js/index-14dgbjsm.js +2 -0
- package/dist/client/static/js/{index-q4ke39rh.js → index-1p880x6e.js} +2 -2
- package/dist/client/static/js/{index-e5j5gc4h.js → index-1yq96wpa.js} +2 -2
- package/dist/client/static/js/{index-x0xspam4.js → index-2bf0txsp.js} +2 -2
- package/dist/client/static/js/index-2jgx68m0.js +1 -0
- package/dist/client/static/js/{index-evmcc5qh.js → index-2yzt8h3d.js} +2 -2
- package/dist/client/static/js/{index-ccgzzydx.js → index-333rq9yy.js} +1 -1
- package/dist/client/static/js/{index-9xsf8162.js → index-38g2eevc.js} +80 -80
- package/dist/client/static/js/{index-dxkefysk.js → index-3v8k8ms3.js} +1 -1
- package/dist/client/static/js/index-473hk8nb.js +10 -0
- package/dist/client/static/js/{index-5f4b44ay.js → index-4ccs971z.js} +2 -2
- package/dist/client/static/js/{index-fjex1y0t.js → index-4dnc1kys.js} +2 -2
- package/dist/client/static/js/{index-4jzsr1ky.js → index-4z5ram7g.js} +2 -2
- package/dist/client/static/js/{index-dzeyd153.js → index-5dn4159w.js} +2 -2
- package/dist/client/static/js/{index-54mkp2r2.js → index-5p8dwr4y.js} +1 -1
- package/dist/client/static/js/{index-1c2jvnyh.js → index-5ztdqm1w.js} +2 -2
- package/dist/client/static/js/{index-cra9mgkq.js → index-7dqq7cjp.js} +13 -13
- package/dist/client/static/js/{index-64p1dncg.js → index-7ff9scbm.js} +2 -2
- package/dist/client/static/js/{index-z0fkfphe.js → index-7rmps91t.js} +2 -2
- package/dist/client/static/js/{index-0dkc6z8e.js → index-80fjn77c.js} +2 -2
- package/dist/client/static/js/{index-cvyqp8nz.css → index-9wc36am3.css} +1 -1
- package/dist/client/static/js/{index-y6ke70e6.js → index-a4636gt1.js} +2 -2
- package/dist/client/static/js/{index-c63qyysm.js → index-bmaktvm2.js} +1 -1
- package/dist/client/static/js/index-bvpzzhn2.js +4 -0
- package/dist/client/static/js/{index-56rtb871.js → index-c3whkrwa.js} +58 -58
- package/dist/client/static/js/{index-7zeah164.js → index-dh060b7r.js} +2 -2
- package/dist/client/static/js/{index-hkz2mz34.js → index-dmc82cxb.js} +2 -2
- package/dist/client/static/js/index-e19dbqd3.js +2 -0
- package/dist/client/static/js/{index-g4kkapka.js → index-e8mt8rag.js} +2 -2
- package/dist/client/static/js/index-epzvftkq.js +1 -0
- package/dist/client/static/js/{index-an2wv33f.js → index-fbg5vhhw.js} +2 -2
- package/dist/client/static/js/{index-nkahe229.js → index-gaqjrzdb.js} +2 -2
- package/dist/client/static/js/index-gg910gpv.js +2 -0
- package/dist/client/static/js/{index-n1yr4khe.js → index-gr8sqjpz.js} +1 -1
- package/dist/client/static/js/{index-7zedprz3.js → index-gz7kvpnm.js} +1 -1
- package/dist/client/static/js/{index-70g527sb.js → index-h8hjcdj1.js} +2 -2
- package/dist/client/static/js/{index-4wnzs76g.js → index-j37m7pn9.js} +2 -2
- package/dist/client/static/js/{index-39d8zbkx.js → index-mbtenbyc.js} +6 -6
- package/dist/client/static/js/{index-tqgj7rd9.js → index-nbm5r9g1.js} +2 -2
- package/dist/client/static/js/{index-52nd4hgm.js → index-nzvte8s5.js} +2 -2
- package/dist/client/static/js/index-pv4z2mp2.js +463 -0
- package/dist/client/static/js/{index-c5hjht5e.js → index-pygy21w5.js} +2 -2
- package/dist/client/static/js/{index-sa1675y0.js → index-qs4n116g.js} +2 -2
- package/dist/client/static/js/{index-6d6hxwb5.js → index-qwxawph7.js} +2 -2
- package/dist/client/static/js/index-rz0tz4hg.js +1 -0
- package/dist/client/static/js/{index-gzkzwgzv.js → index-s5vegk6q.js} +2 -2
- package/dist/client/static/js/{index-xk1cqjkn.js → index-t522tpxt.js} +3 -3
- package/dist/client/static/js/{index-a4h5np9r.js → index-taev57jw.js} +2 -2
- package/dist/client/static/js/{index-dyc886cc.js → index-tb35a328.js} +2 -2
- package/dist/client/static/js/{index-396r53n0.js → index-tc6k8qt7.js} +2 -2
- package/dist/client/static/js/{index-62jgcgfd.js → index-tcfpzqb9.js} +36 -36
- package/dist/client/static/js/{index-z4530r3c.js → index-wbsvg1d9.js} +2 -2
- package/dist/client/static/js/index-xw1bptp5.js +2 -0
- package/dist/client/static/js/{index-33qxg79j.js → index-yg083mk0.js} +6 -6
- package/dist/client/static/js/{index-f2ahkev0.js → index-ykc14gez.js} +5 -5
- package/dist/client/static/js/index-yr3exz70.js +2 -0
- package/dist/client/static/js/{index-1whzs9kb.js → index-yyjw1ty9.js} +2 -2
- package/dist/client/static/js/index-z6y8j93w.js +9 -0
- package/dist/client/static/js/index-zdw8bd5t.js +2 -0
- package/dist/client/static/js/index-zp40g8ah.js +12 -0
- package/dist/client/static/js/{index-zhjjpvcc.js → index-zyefab6q.js} +1 -1
- package/dist/client/static/js/info-A6RAGUB7-vr5mxm6f.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-88qbtpq5.js → infoDiagram-VRGFBTTK-xsar9j6v.js} +2 -2
- package/dist/client/static/js/ini-zx7x1jj1.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-s8bagk00.js → ishikawaDiagram-OU5B5YK6-g2rvt9jp.js} +6 -6
- package/dist/client/static/js/java-bbw6kdcr.js +1 -0
- package/dist/client/static/js/javascript-p2a8rbpw.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-hz8z0b9x.js → journeyDiagram-ZHPQQLJL-q95v18zc.js} +5 -5
- package/dist/client/static/js/json-zh7m2fyg.js +1 -0
- package/dist/client/static/js/jsx-3zyyt0eh.js +1 -0
- package/dist/client/static/js/{julia-dm0j9apa.js → julia-pe5vpc2m.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-sjjnjb51.js → kanban-definition-PNTS6WVX-2e7m7ds3.js} +11 -11
- package/dist/client/static/js/lua-d656k76a.js +1 -0
- package/dist/client/static/js/markdown-b5w681mm.js +1 -0
- package/dist/client/static/js/{mermaid.core-zvwygxbh.js → mermaid.core-dzajkp0g.js} +8 -8
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-kgj8enan.js → mindmap-definition-NLK3R4M7-banecvf8.js} +4 -4
- package/dist/client/static/js/one-dark-pro-z965dedc.js +1 -0
- package/dist/client/static/js/one-light-capdx801.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-ncb5xxtn.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-gxzw1qwa.js → pegDiagram-GJSIUBJH-6erykm1c.js} +1 -1
- package/dist/client/static/js/{perl-4jcm2jxv.js → perl-cc2eqye8.js} +1 -1
- package/dist/client/static/js/{php-q32mec74.js → php-p9bvnpsv.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-ff8fpvc4.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-pdqwyqcm.js → pieDiagram-5QR66LMP-jn1d905q.js} +3 -3
- package/dist/client/static/js/properties-3c6rmnqp.js +1 -0
- package/dist/client/static/js/python-a3x3zpv1.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-yx2t364p.js → quadrantDiagram-O4NWA36T-sz4afnp1.js} +6 -6
- package/dist/client/static/js/r-7h3gwype.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-gbj4b1hf.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-ndv5tqgr.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-yjzj09s1.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e6pw7e5z.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-9734dxy4.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-800fdzkr.js → railroadDiagram-XR7U4H2S-ewzhhth2.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-vc5rpgtm.js → requirementDiagram-PLB6GJNP-fcs3xd42.js} +8 -8
- package/dist/client/static/js/{ruby-npmpb290.js → ruby-65s2ca5d.js} +1 -1
- package/dist/client/static/js/{rust-waks43wh.js → rust-ec1j2hwy.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-ccjk8zgn.js → sankeyDiagram-IPEJSGJF-2r829rjf.js} +4 -4
- package/dist/client/static/js/{sass-502a4r7y.js → sass-p6cssgq8.js} +1 -1
- package/dist/client/static/js/{scss-kvev49ga.js → scss-qfx8wt3b.js} +1 -1
- package/dist/client/static/js/sequenceDiagram-PO4LG4MO-3mnte9tv.js +169 -0
- package/dist/client/static/js/{sizeCapture-INFHLROL-fma9p1vy.js → sizeCapture-INFHLROL-r6hf9265.js} +1 -1
- package/dist/client/static/js/sql-7a5vavm0.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-d8f24b7j.js → stateDiagram-v2-GCMORJYK-hm2f0wdb.js} +6 -6
- package/dist/client/static/js/{svelte-c15d0421.js → svelte-jz3a190v.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-sdt7qy36.js → swimlanes-2SLR337P-s58xzqhw.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-z4pt2kn1.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-rv8qyr8b.js → timeline-definition-EJHVYXUP-ezm1c4pz.js} +8 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-rs10d4p5.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-ey6c5x9f.js +1 -0
- package/dist/client/static/js/tsx-4a9b8tqf.js +1 -0
- package/dist/client/static/js/typescript-kas107wb.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-w6ew1red.js → usecaseDiagram-POWQR4AR-ryvgs5ac.js} +48 -48
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-p9axw7ch.js → vennDiagram-UO4OBE2U-rd5prsf1.js} +6 -6
- package/dist/client/static/js/{vue-xpemy62d.js → vue-rv4pea8r.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-kd9swrdr.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-5ewc8s4p.js → wardleyDiagram-VNRHLVJA-1kt8q8a4.js} +4 -4
- package/dist/client/static/js/xml-3g4bdtpa.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7n4gn7k6.js → xychartDiagram-PMCCYNJV-q39bbgq4.js} +4 -4
- package/dist/client/static/js/yaml-ktxjn917.js +1 -0
- package/package.json +1 -1
- package/src/client/components/common/MarkdownRenderer.tsx +29 -28
- package/src/client/components/common/header-controls/index.test.tsx +1 -0
- package/src/client/components/common/header-controls/phone-row.test.tsx +1 -0
- package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -0
- package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -0
- package/src/client/components/layout/ActivityBar.tsx +2 -1
- package/src/client/components/layout/LeftActivityBar.test.ts +1 -0
- package/src/client/components/settings/Modal.tsx +1 -1
- package/src/client/components/settings/Sidebar.tsx +2 -1
- package/src/client/components/settings/apply-side-effects.ts +8 -0
- package/src/client/components/settings/categories/DictationSettings.test.tsx +152 -0
- package/src/client/components/settings/categories/DictationSettings.tsx +76 -0
- package/src/client/components/settings/categories/VoiceSettings.tsx +77 -0
- package/src/client/components/settings/categories/dictation-settings/CaptureSection.tsx +153 -0
- package/src/client/components/settings/categories/dictation-settings/EngineSection.tsx +123 -0
- package/src/client/components/settings/categories/dictation-settings/ExternalSection.tsx +221 -0
- package/src/client/components/settings/categories/dictation-settings/LanguageSection.tsx +73 -0
- package/src/client/components/settings/categories/panel-plugins/InstallForm.tsx +24 -17
- package/src/client/components/settings/categories/panel-plugins/Registries.test.tsx +164 -0
- package/src/client/components/settings/categories/panel-plugins/Registries.tsx +180 -0
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +15 -6
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +10 -3
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +27 -4
- package/src/client/components/settings/categories/usage-settings/TokenHarborCard.tsx +160 -0
- package/src/client/components/settings/categories/usage-settings/TokenPortalCard.tsx +104 -0
- package/src/client/components/settings/categories/usage-settings/format.ts +35 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +16 -0
- package/src/client/components/settings/categories/usage-settings/providers.ts +26 -4
- package/src/client/components/settings/categories/usage-settings/token-harbor-card.test.tsx +114 -0
- package/src/client/components/settings/categories/usage-settings/token-harbor-hint.test.ts +68 -0
- package/src/client/components/settings/categories/usage-settings/token-portal-card.test.tsx +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +66 -0
- package/src/client/components/settings/categories/voice-settings/SpeechSettings.test.tsx +112 -0
- package/src/client/components/settings/categories/voice-settings/SpeechSettings.tsx +84 -0
- package/src/client/components/settings/categories/voice-settings/groups.test.ts +23 -0
- package/src/client/components/settings/categories/voice-settings/groups.ts +48 -0
- package/src/client/components/settings/categories/voice-settings/speech/AutoplaySection.tsx +49 -0
- package/src/client/components/settings/categories/voice-settings/speech/EndpointSection.tsx +161 -0
- package/src/client/components/settings/categories/voice-settings/speech/EngineSection.tsx +108 -0
- package/src/client/components/settings/categories/voice-settings/speech/TestSection.tsx +56 -0
- package/src/client/components/settings/categories/voice-settings/speech/VoiceSection.tsx +157 -0
- package/src/client/components/settings/categories/voice-settings/speech/styles.ts +15 -0
- package/src/client/components/settings/category-content.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.speech.test.tsx +140 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +41 -97
- package/src/client/components/workspace/chat-timeline/AiMessageFooterSheet.tsx +143 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/SpeechButton.tsx +110 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +26 -10
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +13 -8
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +9 -2
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +6 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +18 -7
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +4 -2
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +4 -4
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +19 -11
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +8 -6
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +38 -30
- package/src/client/components/workspace/chat-timeline/chat-input/narrow.test.tsx +185 -0
- package/src/client/components/workspace/chat-timeline/chat-input/paste-attach.test.tsx +194 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +5 -11
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +10 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +2 -7
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/registry.test.ts +38 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/registry.ts +10 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +13 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.tsx +41 -18
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-input.ts +5 -5
- package/src/client/components/workspace/editor/BodyLazy.tsx +40 -0
- package/src/client/components/workspace/editor/index.tsx +2 -2
- package/src/client/data/settings/omp-schema.json +33 -10
- package/src/client/hooks/chat/composer/attachments.ts +18 -2
- package/src/client/hooks/chat/composer/capture.test.ts +282 -0
- package/src/client/hooks/chat/composer/capture.ts +166 -0
- package/src/client/hooks/chat/composer/dictation-settings.ts +53 -0
- package/src/client/hooks/chat/composer/narrow.test.ts +130 -0
- package/src/client/hooks/chat/composer/narrow.ts +82 -0
- package/src/client/hooks/chat/composer/paste-attachments.test.ts +215 -0
- package/src/client/hooks/chat/composer/paste-attachments.ts +173 -0
- package/src/client/hooks/chat/composer/pipeline.ts +16 -3
- package/src/client/hooks/chat/composer/speech-to-text.test.tsx +314 -0
- package/src/client/hooks/chat/composer/speech-to-text.ts +158 -134
- package/src/client/hooks/chat/composer/voice-input.ts +24 -9
- package/src/client/hooks/chat/timeline/scroll.test.ts +44 -3
- package/src/client/hooks/chat/timeline/scroll.ts +31 -14
- package/src/client/hooks/chat/timeline/send-helpers.ts +3 -0
- package/src/client/hooks/chat/timeline/send.ts +5 -1
- package/src/client/hooks/settings/dictation.ts +153 -0
- package/src/client/hooks/settings/speech.ts +170 -0
- package/src/client/hooks/tts/provider.tsx +50 -0
- package/src/client/hooks/tts/tts-context.ts +39 -0
- package/src/client/hooks/tts/use-speech-autoplay.test.tsx +122 -0
- package/src/client/hooks/tts/use-speech-autoplay.ts +106 -0
- package/src/client/hooks/tts/use-tts-player.ts +33 -0
- package/src/client/hooks/ui/markdown-hydration.test.tsx +83 -0
- package/src/client/hooks/ui/markdown-hydration.ts +31 -0
- package/src/client/hooks/ui/markdown-render.ts +119 -0
- package/src/client/hooks/workspace/journal-diff.ts +8 -1
- package/src/client/hooks/workspace/panel-actions.ts +184 -0
- package/src/client/hooks/workspace/panel-registry.ts +6 -139
- package/src/client/hooks/workspace/panel-visibility-menu.ts +2 -1
- package/src/client/lib/plugins/bootstrap.test.ts +1 -0
- package/src/client/lib/tts/player.test.ts +103 -0
- package/src/client/lib/tts/player.ts +213 -0
- package/src/client/tailwind.css +11 -0
- package/src/server/lib/changes/capture-bash.server.ts +6 -3
- package/src/server/lib/changes/capture-fs.server.ts +2 -2
- package/src/server/lib/changes/capture-races.test.ts +33 -1
- package/src/server/lib/changes/capture-scan.test.ts +1 -1
- package/src/server/lib/changes/capture-test-util.ts +1 -1
- package/src/server/lib/changes/capture-types.ts +1 -1
- package/src/server/lib/changes/capture.server.ts +1 -1
- package/src/server/lib/changes/journal-read.server.ts +21 -0
- package/src/server/lib/changes/reader.server.ts +92 -14
- package/src/server/lib/changes/reader.test.ts +99 -0
- package/src/server/lib/changes/records.ts +2 -0
- package/src/server/lib/dictation/capability.server.test.ts +113 -0
- package/src/server/lib/dictation/capability.server.ts +57 -0
- package/src/server/lib/dictation/engines/adapter.ts +147 -0
- package/src/server/lib/dictation/engines/adapters.test.ts +215 -0
- package/src/server/lib/dictation/engines/deepgram.ts +77 -0
- package/src/server/lib/dictation/engines/elevenlabs.ts +44 -0
- package/src/server/lib/dictation/engines/index.ts +55 -0
- package/src/server/lib/dictation/engines/openai.ts +51 -0
- package/src/server/lib/dictation/language.server.test.ts +21 -22
- package/src/server/lib/dictation/language.server.ts +16 -19
- package/src/server/lib/dictation/omp-stt-worker.test.ts +183 -0
- package/src/server/lib/dictation/omp-stt-worker.ts +130 -78
- package/src/server/lib/dictation/settings.server.ts +74 -0
- package/src/server/lib/dictation/speech-frames.test.ts +125 -0
- package/src/server/lib/dictation/speech-frames.ts +146 -0
- package/src/server/lib/dictation/worker-process.ts +122 -0
- package/src/server/lib/harness/acp/calls.ts +20 -0
- package/src/server/lib/harness/acp/client-capabilities.ts +8 -1
- package/src/server/lib/harness/acp/client-fs.ts +17 -5
- package/src/server/lib/harness/acp/client-initialize.test.ts +32 -1
- package/src/server/lib/harness/acp/client-initialize.ts +51 -6
- package/src/server/lib/harness/acp/client-requests.ts +49 -0
- package/src/server/lib/harness/acp/client.ts +33 -36
- package/src/server/lib/harness/acp/frames-rows.test.ts +144 -0
- package/src/server/lib/harness/acp/frames-tool-shapes.test.ts +238 -0
- package/src/server/lib/harness/acp/frames-v2.test.ts +21 -0
- package/src/server/lib/harness/acp/frames.test.ts +3 -15
- package/src/server/lib/harness/acp/frames.ts +43 -67
- package/src/server/lib/harness/acp/grants.ts +20 -5
- package/src/server/lib/harness/acp/mapper.test.ts +40 -1
- package/src/server/lib/harness/acp/mapper.ts +69 -9
- package/src/server/lib/harness/acp/message-rows.ts +219 -0
- package/src/server/lib/harness/acp/prompt.ts +20 -2
- package/src/server/lib/harness/acp/protocol.ts +24 -0
- package/src/server/lib/harness/acp/replay-window.test.ts +66 -0
- package/src/server/lib/harness/acp/replay.ts +33 -8
- package/src/server/lib/harness/acp/session-addressing.test.ts +99 -0
- package/src/server/lib/harness/acp/session-approvals.ts +4 -0
- package/src/server/lib/harness/acp/session-cancel-policy.test.ts +86 -0
- package/src/server/lib/harness/acp/session-close.test.ts +89 -0
- package/src/server/lib/harness/acp/session-config.ts +8 -3
- package/src/server/lib/harness/acp/session-handshake.ts +6 -0
- package/src/server/lib/harness/acp/session-inbound.ts +126 -0
- package/src/server/lib/harness/acp/session-intake.ts +9 -2
- package/src/server/lib/harness/acp/session-lifecycle.ts +25 -0
- package/src/server/lib/harness/acp/session-notifications.ts +36 -0
- package/src/server/lib/harness/acp/session-permissions.ts +22 -1
- package/src/server/lib/harness/acp/session-requests.ts +19 -1
- package/src/server/lib/harness/acp/session-stop.ts +54 -0
- package/src/server/lib/harness/acp/session-wiring.ts +1 -0
- package/src/server/lib/harness/acp/session.test-util.ts +8 -3
- package/src/server/lib/harness/acp/session.ts +75 -75
- package/src/server/lib/harness/acp/stdio.ts +8 -1
- package/src/server/lib/harness/acp/subagent-frames.test.ts +82 -0
- package/src/server/lib/harness/acp/subagent-frames.ts +124 -0
- package/src/server/lib/harness/acp/subagents.test.ts +124 -0
- package/src/server/lib/harness/acp/subagents.ts +182 -0
- package/src/server/lib/harness/acp/tool-calls.ts +115 -45
- package/src/server/lib/harness/acp/tool-identity.test.ts +8 -0
- package/src/server/lib/harness/acp/tool-identity.ts +13 -1
- package/src/server/lib/harness/acp/tool-shape.ts +99 -0
- package/src/server/lib/harness/acp/turn.test.ts +1 -0
- package/src/server/lib/harness/acp/turn.ts +4 -1
- package/src/server/lib/harness/acp/v2.test.ts +21 -1
- package/src/server/lib/harness/acp/v2.ts +6 -1
- package/src/server/lib/lifecycle/paths.ts +22 -0
- package/src/server/lib/omp/session/changes-patch.test.ts +120 -0
- package/src/server/lib/omp/session/changes-patch.ts +190 -0
- package/src/server/lib/omp/session/changes.test.ts +55 -61
- package/src/server/lib/omp/session/changes.ts +79 -127
- package/src/server/lib/omp/session/merge-stored.ts +2 -0
- package/src/server/lib/panels/catalog-offers.server.ts +1 -1
- package/src/server/lib/panels/catalog.server.test.ts +71 -2
- package/src/server/lib/panels/catalog.server.ts +80 -0
- package/src/server/lib/panels/install.server.test.ts +15 -0
- package/src/server/lib/panels/install.server.ts +7 -0
- package/src/server/lib/panels/manifest.test.ts +1 -76
- package/src/server/lib/panels/manifest.ts +3 -60
- package/src/server/lib/panels/marketplace-catalog.server.test.ts +154 -0
- package/src/server/lib/panels/marketplace-catalog.server.ts +131 -0
- package/src/server/lib/panels/offers.server.test.ts +5 -5
- package/src/server/lib/panels/offers.server.ts +20 -2
- package/src/server/lib/panels/registries.server.test.ts +216 -0
- package/src/server/lib/panels/registries.server.ts +118 -0
- package/src/server/lib/panels/registry-cache.server.ts +104 -0
- package/src/server/lib/panels/registry-refresh.server.ts +195 -0
- package/src/server/lib/panels/registry.server.test.ts +2 -2
- package/src/server/lib/panels/registry.server.ts +19 -1
- package/src/server/lib/panels/seed.server.ts +4 -1
- package/src/server/lib/tts/engines/adapter.ts +133 -0
- package/src/server/lib/tts/engines/adapters.test.ts +129 -0
- package/src/server/lib/tts/engines/deepgram.ts +43 -0
- package/src/server/lib/tts/engines/elevenlabs.ts +53 -0
- package/src/server/lib/tts/engines/index.ts +75 -0
- package/src/server/lib/tts/engines/openai.ts +52 -0
- package/src/server/lib/tts/engines/xai.ts +44 -0
- package/src/server/lib/tts/local.server.ts +160 -0
- package/src/server/lib/tts/settings.server.ts +103 -0
- package/src/server/lib/usage/provider-key.ts +18 -0
- package/src/server/lib/usage/providers.server.ts +27 -3
- package/src/server/lib/usage/report.server.ts +24 -0
- package/src/server/lib/usage/token-harbor.test.ts +191 -0
- package/src/server/lib/usage/token-harbor.ts +207 -0
- package/src/server/lib/usage/token-portal.test.ts +140 -0
- package/src/server/lib/usage/token-portal.ts +179 -0
- package/src/server/lib/usage/vendor-http.test.ts +52 -0
- package/src/server/lib/usage/vendor-http.ts +9 -2
- package/src/server/routes/dictation/ws.ts +99 -27
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/panels/install-route.test.ts +110 -0
- package/src/server/routes/panels/install.ts +82 -3
- package/src/server/routes/sessions/index.ts +5 -0
- package/src/server/routes/sessions/local-image.test.ts +94 -0
- package/src/server/routes/sessions/local-image.ts +141 -0
- package/src/server/routes/settings/dictation.test.ts +139 -0
- package/src/server/routes/settings/dictation.ts +86 -0
- package/src/server/routes/settings/index.ts +4 -0
- package/src/server/routes/settings/speech.test.ts +156 -0
- package/src/server/routes/settings/speech.ts +98 -0
- package/src/server/routes/tts/index.ts +11 -0
- package/src/server/routes/tts/speak.test.ts +160 -0
- package/src/server/routes/tts/speak.ts +87 -0
- package/src/shared/lib/chat/attachments.ts +17 -3
- package/src/shared/lib/chat/composer/attachment-labels.test.ts +154 -0
- package/src/shared/lib/chat/composer/attachment-labels.ts +166 -0
- package/src/shared/lib/chat/omp/subagent-card-fold.test.ts +75 -0
- package/src/shared/lib/chat/timeline/changed-files.test.ts +13 -0
- package/src/shared/lib/chat/timeline/changed-files.ts +4 -2
- package/src/shared/lib/chat/timeline/local-image.test.ts +88 -0
- package/src/shared/lib/chat/timeline/local-image.ts +110 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +3 -2
- package/src/shared/lib/chat/timeline/run-signals.ts +2 -2
- package/src/shared/lib/chat/timeline/stream-callbacks.ts +8 -6
- package/src/shared/lib/chat/timeline/stream-coalescer.ts +7 -0
- package/src/shared/lib/chat/timeline/stream.test.ts +3 -1
- package/src/shared/lib/chat/timeline/tool-verbs.test.ts +5 -0
- package/src/shared/lib/chat/timeline/tool-verbs.ts +3 -1
- package/src/shared/lib/chat/todo/parser.test.ts +54 -0
- package/src/shared/lib/chat/todo/parser.ts +56 -0
- package/src/shared/lib/chat/tool/tool-aliases.test.ts +37 -0
- package/src/shared/lib/chat/tool/tool-aliases.ts +75 -0
- package/src/shared/lib/chat/tool/tool-input-path.test.ts +44 -0
- package/src/shared/lib/chat/tool/tool-input-path.ts +47 -0
- package/src/shared/lib/dictation/capability.ts +32 -0
- package/src/shared/lib/dictation/constraints.test.ts +41 -0
- package/src/shared/lib/dictation/constraints.ts +48 -0
- package/src/shared/lib/dictation/engines.test.ts +117 -0
- package/src/shared/lib/dictation/engines.ts +190 -0
- package/src/shared/lib/dictation/gate.test.ts +118 -0
- package/src/shared/lib/dictation/gate.ts +85 -0
- package/src/shared/lib/dictation/languages.test.ts +88 -0
- package/src/shared/lib/dictation/languages.ts +90 -0
- package/src/shared/lib/dictation/models.ts +9 -5
- package/src/shared/lib/dictation/protocol.ts +74 -34
- package/src/shared/lib/dictation/settings.test.ts +94 -0
- package/src/shared/lib/dictation/settings.ts +111 -0
- package/src/shared/lib/dictation/wav.test.ts +66 -0
- package/src/shared/lib/dictation/wav.ts +48 -0
- package/src/shared/lib/fs/journal-unavailable.test.ts +30 -0
- package/src/shared/lib/fs/journal-unavailable.ts +35 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +35 -35
- package/src/shared/lib/net/base-url.test.ts +25 -0
- package/src/shared/lib/net/base-url.ts +29 -0
- package/src/shared/lib/omp/config/schema-extras.ts +9 -8
- package/src/shared/lib/omp/config/schema-releases.test.ts +22 -0
- package/src/shared/lib/omp/session/parse-message-blocks.ts +2 -2
- package/src/shared/lib/panels/plugin-repo.test.ts +113 -0
- package/src/shared/lib/panels/plugin-repo.ts +149 -0
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/tts/capability.ts +16 -0
- package/src/shared/lib/tts/engines.test.ts +79 -0
- package/src/shared/lib/tts/engines.ts +313 -0
- package/src/shared/lib/tts/settings.test.ts +56 -0
- package/src/shared/lib/tts/settings.ts +108 -0
- package/src/shared/lib/tts/speakable.test.ts +76 -0
- package/src/shared/lib/tts/speakable.ts +179 -0
- package/src/shared/types/chat.ts +8 -1
- package/src/shared/types/panels-registry.ts +32 -0
- package/src/shared/types/panels.ts +23 -0
- package/src/shared/types/session-changes.ts +15 -1
- package/src/shared/types/settings/state.ts +25 -0
- package/src/shared/types/settings/usage.ts +89 -2
- package/src/test-support/pristine-globals.ts +5 -0
- package/dist/client/static/js/ImageView-mvjb3qh1.js +0 -1
- package/dist/client/static/js/LayoutWrapper-eenx0hp2.js +0 -2
- package/dist/client/static/js/Modal-dsqhas10.js +0 -59
- package/dist/client/static/js/PdfView-cpvsbfk0.js +0 -1
- package/dist/client/static/js/SessionsView-s0crtcm8.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-b5w9mnn5.js +0 -1
- package/dist/client/static/js/architectureDiagram-NJMV4G6O-1nh4htz2.js +0 -36
- package/dist/client/static/js/bash-hv3167gh.js +0 -1
- package/dist/client/static/js/c-acmn1zc9.js +0 -1
- package/dist/client/static/js/cpp-v2mqp8j7.js +0 -1
- package/dist/client/static/js/css-drfs4n12.js +0 -1
- package/dist/client/static/js/css-x7gyc3ta.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-kdj8rjc1.js +0 -1
- package/dist/client/static/js/dagre-6A5THRUB-41zsteyd.js +0 -4
- package/dist/client/static/js/eventmodeling-NTZA5JFV-m57b7ytw.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-fasj2gxy.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-wvzsc4ph.js +0 -1
- package/dist/client/static/js/graphql-a4gbqpj9.js +0 -1
- package/dist/client/static/js/html-m0megrvb.js +0 -1
- package/dist/client/static/js/index-1d8bxjsz.js +0 -4
- package/dist/client/static/js/index-3nsrnyqr.js +0 -2
- package/dist/client/static/js/index-4x9p7hf9.js +0 -2
- package/dist/client/static/js/index-6009v8jf.js +0 -1
- package/dist/client/static/js/index-9vqkyj58.js +0 -3
- package/dist/client/static/js/index-d2xtbabt.js +0 -2
- package/dist/client/static/js/index-dxp2yvy7.js +0 -2
- package/dist/client/static/js/index-p6s3fz6b.js +0 -12
- package/dist/client/static/js/index-qtd0e38d.js +0 -1
- package/dist/client/static/js/index-x2v1zmth.js +0 -479
- package/dist/client/static/js/index-x9hfvbz6.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-ym2xevn8.js +0 -1
- package/dist/client/static/js/ini-80p6sp79.js +0 -1
- package/dist/client/static/js/java-mm2b3s9b.js +0 -1
- package/dist/client/static/js/javascript-n9w9p97f.js +0 -1
- package/dist/client/static/js/json-fzy76fkw.js +0 -1
- package/dist/client/static/js/jsx-c7v2f8s7.js +0 -1
- package/dist/client/static/js/lua-ppfdxrmv.js +0 -1
- package/dist/client/static/js/markdown-xed7y3ds.js +0 -1
- package/dist/client/static/js/one-dark-pro-mq6sn6a2.js +0 -1
- package/dist/client/static/js/one-light-pt6t6vax.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-01vcsy6x.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-053gzkmh.js +0 -1
- package/dist/client/static/js/properties-8ysbq2n2.js +0 -1
- package/dist/client/static/js/python-4ysexc8s.js +0 -1
- package/dist/client/static/js/r-hrsw5arc.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-bkpby8am.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-67bxrjgw.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-xj9ymacg.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-2xxpbnf6.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-78w88znz.js +0 -1
- package/dist/client/static/js/sequenceDiagram-PO4LG4MO-c0tk7gfn.js +0 -169
- package/dist/client/static/js/sql-hd42h8wx.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-rz309qrx.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-g2bkjr4z.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-pj7yw9rw.js +0 -1
- package/dist/client/static/js/tsx-xjp2ds8g.js +0 -1
- package/dist/client/static/js/typescript-yg97da8h.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-c7ekf8r2.js +0 -1
- package/dist/client/static/js/xml-nrb23phz.js +0 -1
- package/dist/client/static/js/yaml-sqs6pjpx.js +0 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The speech frame codec, pinned against the layout omp's worker actually reads.
|
|
8
|
+
*
|
|
9
|
+
* Every constant here was read out of omp 19.1.1's bundle and then verified on
|
|
10
|
+
* the running worker: a wrong length field, a wrong kind byte or a payload at the
|
|
11
|
+
* wrong offset does not fail loudly — the worker either kills itself or answers a
|
|
12
|
+
* transcript of shifted samples, which reads as "the model is bad" rather than
|
|
13
|
+
* "the transport is bad". So the byte layout is asserted field by field.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
import { SpeechFrameDecoder, encodeSpeechFrame } from '@/server/lib/dictation/speech-frames';
|
|
18
|
+
|
|
19
|
+
function view(bytes: Uint8Array): DataView {
|
|
20
|
+
return new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function decodeOne(bytes: Uint8Array): Record<string, unknown>[] {
|
|
24
|
+
return new SpeechFrameDecoder().push(bytes) as Record<string, unknown>[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe('encodeSpeechFrame', () => {
|
|
28
|
+
test('a header-only frame is length | 0 | JSON', () => {
|
|
29
|
+
const bytes = encodeSpeechFrame({ type: 'ping', id: '7' });
|
|
30
|
+
const json = JSON.stringify({ type: 'ping', id: '7' });
|
|
31
|
+
|
|
32
|
+
expect(view(bytes).getUint32(0, true)).toBe(1 + json.length);
|
|
33
|
+
expect(bytes[4]).toBe(0);
|
|
34
|
+
expect(new TextDecoder().decode(bytes.subarray(5))).toBe(json);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('a Float32Array is hoisted into the payload and named by $pcm', () => {
|
|
38
|
+
const audio = new Float32Array([0.5, -0.25, 1]);
|
|
39
|
+
const bytes = encodeSpeechFrame({ type: 'transcribe', id: '1', modelKey: 'whisper-base', audio });
|
|
40
|
+
|
|
41
|
+
expect(bytes[4]).toBe(1);
|
|
42
|
+
const headerLength = view(bytes).getUint32(5, true);
|
|
43
|
+
const header = JSON.parse(new TextDecoder().decode(bytes.subarray(9, 9 + headerLength)));
|
|
44
|
+
expect(header).toEqual({ type: 'transcribe', id: '1', modelKey: 'whisper-base', $pcm: 'audio' });
|
|
45
|
+
expect(header).not.toHaveProperty('audio');
|
|
46
|
+
// length excludes the 4-byte prefix and includes the kind byte
|
|
47
|
+
expect(view(bytes).getUint32(0, true)).toBe(bytes.length - 4);
|
|
48
|
+
expect(bytes.length - 4).toBe(1 + 4 + headerLength + audio.byteLength);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('the payload is the raw little-endian samples, not JSON', () => {
|
|
52
|
+
const audio = new Float32Array([0.5, -0.25]);
|
|
53
|
+
const bytes = encodeSpeechFrame({ type: 'transcribe', audio });
|
|
54
|
+
const headerLength = view(bytes).getUint32(5, true);
|
|
55
|
+
const payload = new DataView(bytes.buffer, bytes.byteOffset + 9 + headerLength);
|
|
56
|
+
expect(payload.getFloat32(0, true)).toBe(0.5);
|
|
57
|
+
expect(payload.getFloat32(4, true)).toBe(-0.25);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('SpeechFrameDecoder', () => {
|
|
62
|
+
test('round-trips a header frame', () => {
|
|
63
|
+
const frames = decodeOne(encodeSpeechFrame({ type: 'pong', id: '3' }));
|
|
64
|
+
expect(frames).toEqual([{ type: 'pong', id: '3' }]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('round-trips a payload frame and reattaches the samples', () => {
|
|
68
|
+
const audio = new Float32Array([0.1, 0.2, 0.3, 0.4]);
|
|
69
|
+
const frames = decodeOne(encodeSpeechFrame({ type: 'transcribe', id: '9', audio }));
|
|
70
|
+
expect(frames).toHaveLength(1);
|
|
71
|
+
expect(frames[0].id).toBe('9');
|
|
72
|
+
expect(frames[0]).not.toHaveProperty('$pcm');
|
|
73
|
+
expect([...(frames[0].audio as Float32Array)]).toEqual([0.1, 0.2, 0.3, 0.4].map((n) => Math.fround(n)));
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('reassembles a frame split across reads', () => {
|
|
77
|
+
const bytes = encodeSpeechFrame({ type: 'transcribe', id: '1', audio: new Float32Array([1, 2, 3]) });
|
|
78
|
+
const decoder = new SpeechFrameDecoder();
|
|
79
|
+
// Split mid-payload, which is where a real pipe boundary lands.
|
|
80
|
+
expect(decoder.push(bytes.subarray(0, 12))).toEqual([]);
|
|
81
|
+
const frames = decoder.push(bytes.subarray(12));
|
|
82
|
+
expect(frames).toHaveLength(1);
|
|
83
|
+
expect([...(frames[0].audio as Float32Array)]).toEqual([1, 2, 3]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('reads several frames out of one chunk', () => {
|
|
87
|
+
const first = encodeSpeechFrame({ type: 'pong', id: '1' });
|
|
88
|
+
const second = encodeSpeechFrame({ type: 'transcription', id: '2', text: 'halo' });
|
|
89
|
+
const merged = new Uint8Array(first.length + second.length);
|
|
90
|
+
merged.set(first);
|
|
91
|
+
merged.set(second, first.length);
|
|
92
|
+
|
|
93
|
+
const frames = decodeOne(merged);
|
|
94
|
+
expect(frames.map((frame) => frame.type)).toEqual(['pong', 'transcription']);
|
|
95
|
+
expect(frames[1].text).toBe('halo');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('an empty frame is rejected rather than skipped', () => {
|
|
99
|
+
const bytes = new Uint8Array([0, 0, 0, 0]);
|
|
100
|
+
expect(() => decodeOne(bytes)).toThrow('empty frame');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('an unknown kind is rejected rather than guessed', () => {
|
|
104
|
+
const bytes = new Uint8Array(6);
|
|
105
|
+
new DataView(bytes.buffer).setUint32(0, 2, true);
|
|
106
|
+
bytes[4] = 9;
|
|
107
|
+
expect(() => decodeOne(bytes)).toThrow('unknown type 9');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('a payload frame whose header overruns the body is rejected', () => {
|
|
111
|
+
const bytes = new Uint8Array(12);
|
|
112
|
+
new DataView(bytes.buffer).setUint32(0, 8, true);
|
|
113
|
+
bytes[4] = 1;
|
|
114
|
+
new DataView(bytes.buffer).setUint32(5, 99, true);
|
|
115
|
+
expect(() => decodeOne(bytes)).toThrow('overruns frame');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('a decoded payload does not keep the read buffer alive', () => {
|
|
119
|
+
const bytes = encodeSpeechFrame({ type: 'transcribe', audio: new Float32Array([0.5]) });
|
|
120
|
+
const frames = decodeOne(bytes);
|
|
121
|
+
const samples = frames[0].audio as Float32Array;
|
|
122
|
+
// A view into the decoder's buffer would be exactly this length; a copy is 4.
|
|
123
|
+
expect(samples.buffer.byteLength).toBe(4);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The frame codec omp's worker speaks on stdin/stdout, decoded from its own
|
|
8
|
+
* bundle (`packages/coding-agent/src/daemon/modules/speech-frames.ts` in
|
|
9
|
+
* 19.1.1) and verified against the running worker:
|
|
10
|
+
*
|
|
11
|
+
* u32le length | u8 kind | body
|
|
12
|
+
*
|
|
13
|
+
* - `length` EXCLUDES the 4-byte prefix and INCLUDES the kind byte.
|
|
14
|
+
* - kind `0` — header only: `JSON`.
|
|
15
|
+
* - kind `1` — `u32le headerLength | header JSON | Float32LE payload`.
|
|
16
|
+
*
|
|
17
|
+
* A Float32Array field travels as kind 1: the header carries `$pcm: <field>`
|
|
18
|
+
* (and the field itself must be REMOVED from the header), the payload carries
|
|
19
|
+
* the raw little-endian samples. The worker reattaches it after decoding.
|
|
20
|
+
*
|
|
21
|
+
* Measured on omp 19.1.1 with the model already cached: ping answered in 24 ms,
|
|
22
|
+
* a 7 s utterance transcribed in ~0.9 s, and the transcript is byte-identical to
|
|
23
|
+
* the same audio decoded in-process by transformers.js — which is what proves
|
|
24
|
+
* the payload is not being shifted or truncated.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const KIND_HEADER = 0;
|
|
28
|
+
const KIND_PAYLOAD = 1;
|
|
29
|
+
/** Offset of the body: 4-byte length + 1-byte kind. */
|
|
30
|
+
const BODY_OFFSET = 5;
|
|
31
|
+
/** Largest frame omp's decoder accepts. */
|
|
32
|
+
const MAX_FRAME_BYTES = 512 * 1024 * 1024;
|
|
33
|
+
|
|
34
|
+
/** The header field naming the Float32 payload's destination field. */
|
|
35
|
+
const PCM_FIELD = '$pcm';
|
|
36
|
+
|
|
37
|
+
const encoder = new TextEncoder();
|
|
38
|
+
const decoder = new TextDecoder();
|
|
39
|
+
|
|
40
|
+
export interface SpeechFrame {
|
|
41
|
+
type: string;
|
|
42
|
+
id?: string;
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Encode one frame.
|
|
48
|
+
*
|
|
49
|
+
* A `Float32Array` value is moved into the payload and named by `$pcm`, which is
|
|
50
|
+
* the only way the worker accepts audio: sending the array inside the JSON turns
|
|
51
|
+
* it into `{"0":…,"1":…}`, and the worker then fails with
|
|
52
|
+
* `aud.subarray is not a function`.
|
|
53
|
+
*/
|
|
54
|
+
export function encodeSpeechFrame(frame: Record<string, unknown>): Uint8Array {
|
|
55
|
+
for (const [key, value] of Object.entries(frame)) {
|
|
56
|
+
if (!(value instanceof Float32Array)) continue;
|
|
57
|
+
const header: Record<string, unknown> = { ...frame, [PCM_FIELD]: key };
|
|
58
|
+
delete header[key];
|
|
59
|
+
const bytes = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
60
|
+
return withPayload(header, bytes);
|
|
61
|
+
}
|
|
62
|
+
const header = encoder.encode(JSON.stringify(frame));
|
|
63
|
+
const out = new Uint8Array(BODY_OFFSET + header.length);
|
|
64
|
+
new DataView(out.buffer).setUint32(0, 1 + header.length, true);
|
|
65
|
+
out[4] = KIND_HEADER;
|
|
66
|
+
out.set(header, BODY_OFFSET);
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function withPayload(header: Record<string, unknown>, payload: Uint8Array): Uint8Array {
|
|
71
|
+
const json = encoder.encode(JSON.stringify(header));
|
|
72
|
+
const out = new Uint8Array(BODY_OFFSET + 4 + json.length + payload.length);
|
|
73
|
+
const view = new DataView(out.buffer);
|
|
74
|
+
view.setUint32(0, 1 + 4 + json.length + payload.length, true);
|
|
75
|
+
out[4] = KIND_PAYLOAD;
|
|
76
|
+
view.setUint32(BODY_OFFSET, json.length, true);
|
|
77
|
+
out.set(json, BODY_OFFSET + 4);
|
|
78
|
+
out.set(payload, BODY_OFFSET + 4 + json.length);
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A streaming decoder: stdout arrives in arbitrary chunks, and a frame can span
|
|
84
|
+
* two of them (or several frames can arrive in one).
|
|
85
|
+
*
|
|
86
|
+
* A malformed frame throws, because the alternative is silently answering with
|
|
87
|
+
* the wrong transcript — the same choice omp's own decoder makes.
|
|
88
|
+
*/
|
|
89
|
+
export class SpeechFrameDecoder {
|
|
90
|
+
private buffer = new Uint8Array(0);
|
|
91
|
+
|
|
92
|
+
push(chunk: Uint8Array): SpeechFrame[] {
|
|
93
|
+
this.append(chunk);
|
|
94
|
+
const frames: SpeechFrame[] = [];
|
|
95
|
+
let consumed = 0;
|
|
96
|
+
for (;;) {
|
|
97
|
+
if (this.buffer.length - consumed < 4) break;
|
|
98
|
+
const view = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
99
|
+
const length = view.getUint32(consumed, true);
|
|
100
|
+
if (length < 1) throw new Error('speech frame: empty frame');
|
|
101
|
+
if (length > MAX_FRAME_BYTES) throw new Error(`speech frame: ${length} bytes exceeds the frame limit`);
|
|
102
|
+
if (this.buffer.length - consumed - 4 < length) break;
|
|
103
|
+
frames.push(this.decodeAt(view, consumed, length));
|
|
104
|
+
consumed += 4 + length;
|
|
105
|
+
}
|
|
106
|
+
if (consumed > 0) {
|
|
107
|
+
this.buffer = this.buffer.slice(consumed);
|
|
108
|
+
}
|
|
109
|
+
return frames;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private decodeAt(view: DataView, at: number, length: number): SpeechFrame {
|
|
113
|
+
const kind = this.buffer[at + 4];
|
|
114
|
+
const body = this.buffer.subarray(at + BODY_OFFSET, at + 4 + length);
|
|
115
|
+
|
|
116
|
+
if (kind === KIND_HEADER) {
|
|
117
|
+
return JSON.parse(decoder.decode(body)) as SpeechFrame;
|
|
118
|
+
}
|
|
119
|
+
if (kind !== KIND_PAYLOAD) throw new Error(`speech frame: unknown type ${kind}`);
|
|
120
|
+
if (body.length < 4) throw new Error('speech frame: truncated PCM header');
|
|
121
|
+
|
|
122
|
+
const headerLength = view.getUint32(at + BODY_OFFSET, true);
|
|
123
|
+
if (4 + headerLength > body.length) throw new Error('speech frame: PCM header overruns frame');
|
|
124
|
+
const header = JSON.parse(decoder.decode(body.subarray(4, 4 + headerLength))) as Record<string, unknown>;
|
|
125
|
+
const field = header[PCM_FIELD];
|
|
126
|
+
delete header[PCM_FIELD];
|
|
127
|
+
if (typeof field === 'string') {
|
|
128
|
+
// `slice` rather than a view: the decoder's buffer is replaced as frames
|
|
129
|
+
// are consumed, and a view would keep the whole read buffer alive.
|
|
130
|
+
const bytes = body.slice(4 + headerLength);
|
|
131
|
+
header[field] = new Float32Array(bytes.buffer, bytes.byteOffset, Math.floor(bytes.byteLength / 4));
|
|
132
|
+
}
|
|
133
|
+
return header as SpeechFrame;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private append(chunk: Uint8Array): void {
|
|
137
|
+
if (this.buffer.length === 0) {
|
|
138
|
+
this.buffer = chunk.slice();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const merged = new Uint8Array(this.buffer.length + chunk.length);
|
|
142
|
+
merged.set(this.buffer);
|
|
143
|
+
merged.set(chunk, this.buffer.length);
|
|
144
|
+
this.buffer = merged;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `omp __omp_worker_stt` process: spawn it, frame what it says, keep what it
|
|
8
|
+
* complains about.
|
|
9
|
+
*
|
|
10
|
+
* This is the half that has to be right about *processes* — one decoder per
|
|
11
|
+
* child, stderr drained, an exit that belongs to a named handle — so the client
|
|
12
|
+
* above it can be about *requests*. The transport itself is `speech-frames.ts`.
|
|
13
|
+
*
|
|
14
|
+
* Two measured facts shaped it:
|
|
15
|
+
*
|
|
16
|
+
* - **A stale server kills this child.** omp 19's worker reads
|
|
17
|
+
* `Bun.stdin.stream()` and SIGKILLs itself in ~35 ms when that stream is
|
|
18
|
+
* `'ignore'`, which is how a pre-framing Kabmo build spawned it. So `stdin`
|
|
19
|
+
* must be a pipe the client writes frames into.
|
|
20
|
+
* - **A full stderr pipe blocks the child.** Nobody reads stderr in a healthy
|
|
21
|
+
* run, and 64 KB of transformers.js chatter is enough to wedge a decode. The
|
|
22
|
+
* tail is kept anyway, because a worker that dies before answering usually
|
|
23
|
+
* said why.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { Subprocess } from 'bun';
|
|
27
|
+
import { SpeechFrameDecoder, encodeSpeechFrame, type SpeechFrame } from '@/server/lib/dictation/speech-frames';
|
|
28
|
+
|
|
29
|
+
type WorkerChild = Subprocess<'pipe', 'pipe', 'pipe'>;
|
|
30
|
+
|
|
31
|
+
/** How much of the child's stderr to keep for the operator's log. */
|
|
32
|
+
const STDERR_TAIL_BYTES = 2_000;
|
|
33
|
+
|
|
34
|
+
/** What the client sees of a running worker. */
|
|
35
|
+
export interface SttWorkerProcess {
|
|
36
|
+
/** Write one frame; a closed pipe is the exit handler's news, not an error here. */
|
|
37
|
+
send(frame: Record<string, unknown>): void;
|
|
38
|
+
kill(): void;
|
|
39
|
+
/** The last of the child's stderr, for a failure that needs a reason. */
|
|
40
|
+
stderrTail(): string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface SttWorkerHandlers {
|
|
44
|
+
/** One decoded frame from the child. */
|
|
45
|
+
onFrame(frame: SpeechFrame): void;
|
|
46
|
+
/** The child is gone — it exited, or its stream broke. */
|
|
47
|
+
onExit(reason: 'exit' | 'broken', error?: Error): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Start the worker and wire its three pipes.
|
|
52
|
+
*
|
|
53
|
+
* The handlers are bound to THIS process: a child killed a moment ago reports
|
|
54
|
+
* its exit after its replacement has spawned, and a handler that did not know
|
|
55
|
+
* which process it belonged to would tear the replacement down.
|
|
56
|
+
*/
|
|
57
|
+
export function startSttWorkerProcess(bin: string, handlers: SttWorkerHandlers): SttWorkerProcess {
|
|
58
|
+
const child = Bun.spawn({
|
|
59
|
+
cmd: [bin, '__omp_worker_stt'],
|
|
60
|
+
stdin: 'pipe',
|
|
61
|
+
stdout: 'pipe',
|
|
62
|
+
stderr: 'pipe',
|
|
63
|
+
env: process.env,
|
|
64
|
+
onExit: () => handlers.onExit('exit'),
|
|
65
|
+
}) as unknown as WorkerChild;
|
|
66
|
+
|
|
67
|
+
let stderrTail = '';
|
|
68
|
+
|
|
69
|
+
const pump = async () => {
|
|
70
|
+
// One decoder per child: a late chunk from a previous process must not be
|
|
71
|
+
// framed together with the new one's bytes.
|
|
72
|
+
const decoder = new SpeechFrameDecoder();
|
|
73
|
+
const reader = child.stdout.getReader();
|
|
74
|
+
try {
|
|
75
|
+
for (;;) {
|
|
76
|
+
const { done, value } = await reader.read();
|
|
77
|
+
if (done) return;
|
|
78
|
+
for (const frame of decoder.push(value)) handlers.onFrame(frame);
|
|
79
|
+
}
|
|
80
|
+
} catch (error) {
|
|
81
|
+
handlers.onExit('broken', error instanceof Error ? error : new Error(String(error)));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const drainStderr = async () => {
|
|
86
|
+
const reader = child.stderr.getReader();
|
|
87
|
+
const decoder = new TextDecoder();
|
|
88
|
+
try {
|
|
89
|
+
for (;;) {
|
|
90
|
+
const { done, value } = await reader.read();
|
|
91
|
+
if (done) return;
|
|
92
|
+
stderrTail = (stderrTail + decoder.decode(value, { stream: true })).slice(-STDERR_TAIL_BYTES);
|
|
93
|
+
}
|
|
94
|
+
} catch {
|
|
95
|
+
// A closed stream is not a failure of its own; the exit handler reports.
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
void pump();
|
|
100
|
+
void drainStderr();
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
send: (frame) => {
|
|
104
|
+
try {
|
|
105
|
+
child.stdin.write(encodeSpeechFrame(frame));
|
|
106
|
+
// Buffered writes stay ordered; the flush is what puts the frame on the
|
|
107
|
+
// wire before a decode that can take a second.
|
|
108
|
+
void child.stdin.flush();
|
|
109
|
+
} catch {
|
|
110
|
+
// Closed pipe: the exit handler is what reports it.
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
kill: () => {
|
|
114
|
+
try {
|
|
115
|
+
child.kill();
|
|
116
|
+
} catch {
|
|
117
|
+
// already gone
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
stderrTail: () => stderrTail,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import type { AcpId, AcpResponse } from '@/server/lib/harness/acp/protocol';
|
|
20
|
+
import { ACP_ERROR } from '@/server/lib/harness/acp/protocol';
|
|
20
21
|
|
|
21
22
|
/** What the table does when a request's own deadline expires. A timeout is the
|
|
22
23
|
* client's verdict, not the agent's: without telling it, the agent keeps
|
|
@@ -121,4 +122,23 @@ export class PendingCalls {
|
|
|
121
122
|
entry.reject(error);
|
|
122
123
|
}
|
|
123
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Withdraw this session's control calls, returning their ids so the transport
|
|
128
|
+
* can tell the agent (`$/cancel_request`). `session/prompt` is deliberately
|
|
129
|
+
* excluded: cancelling a turn is `session/cancel`'s job, and settling the
|
|
130
|
+
* prompt belongs to the turn machine's grace window.
|
|
131
|
+
*/
|
|
132
|
+
cancelRequestsOf(sessionId: string, exclude: readonly string[] = ['session/prompt']): AcpId[] {
|
|
133
|
+
const ids: AcpId[] = [];
|
|
134
|
+
for (const [id, entry] of this.map) {
|
|
135
|
+
if (exclude.includes(entry.method)) continue;
|
|
136
|
+
if (String(entry.params.sessionId ?? '') !== sessionId) continue;
|
|
137
|
+
this.map.delete(id);
|
|
138
|
+
clearTimeout(entry.timer);
|
|
139
|
+
entry.reject(new AcpRequestError('Request cancelled', ACP_ERROR.cancelled));
|
|
140
|
+
ids.push(id);
|
|
141
|
+
}
|
|
142
|
+
return ids;
|
|
143
|
+
}
|
|
124
144
|
}
|
|
@@ -37,10 +37,17 @@
|
|
|
37
37
|
* `session.compaction` IS advertised: the frame mapper turns a compaction into a
|
|
38
38
|
* notice, which is the surface the timeline already has, so an agent may report
|
|
39
39
|
* one instead of falling back to modelling it as conversation text.
|
|
40
|
+
*
|
|
41
|
+
* `session.plan` and `subagents` are advertised because both now have a
|
|
42
|
+
* consumer: `plan`/`plan_update` feed the Todos panel, and `subagents.ts` +
|
|
43
|
+
* `subagent-frames.ts` track and draw each child the parent announces. The
|
|
44
|
+
* subagents RFD forbids a v1 agent from sending `subagent_update` unless the
|
|
45
|
+
* client advertised it, so the handlers were unreachable before this entry.
|
|
40
46
|
*/
|
|
41
47
|
export const KABMO_CLIENT_CAPABILITIES = {
|
|
42
48
|
fs: { readTextFile: true, writeTextFile: true },
|
|
43
|
-
session: { notices: {}, compaction: {} },
|
|
49
|
+
session: { notices: {}, compaction: {}, plan: {} },
|
|
50
|
+
subagents: {},
|
|
44
51
|
} as const;
|
|
45
52
|
|
|
46
53
|
/** The latest protocol major this client sends; it also speaks v1. */
|
|
@@ -32,6 +32,13 @@ import { ACP_ERROR } from '@/server/lib/harness/acp/protocol';
|
|
|
32
32
|
export interface AcpFsHost {
|
|
33
33
|
readonly cwd: string;
|
|
34
34
|
readonly sessionId: string;
|
|
35
|
+
/** The working directory of an ADDRESSED session: a subagent announced its
|
|
36
|
+
* own `cwd`, and confining its reads to the parent's tree would refuse paths
|
|
37
|
+
* it legitimately owns. Absent means every session shares `cwd`. */
|
|
38
|
+
cwdFor?(sessionId: string | undefined): string;
|
|
39
|
+
/** Whether this client serves the addressed session: itself, or a child it
|
|
40
|
+
* announced. Absent means only `sessionId` itself. */
|
|
41
|
+
owns?(sessionId: string): boolean;
|
|
35
42
|
/** Publish the write so the timeline's change journal records it. A write the
|
|
36
43
|
* AGENT performed through this client runs no tool of its own: without this
|
|
37
44
|
* frame its file change never reached the journal or the diff panel. */
|
|
@@ -53,10 +60,14 @@ export async function handleAcpFsRequest(
|
|
|
53
60
|
params: Record<string, unknown>,
|
|
54
61
|
): Promise<AcpFsAnswer> {
|
|
55
62
|
const requestedSession = params.sessionId;
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
if (
|
|
63
|
+
// A session this client does not serve names something it was never given:
|
|
64
|
+
// a second chat on the same process, or a child nobody announced. Serving it
|
|
65
|
+
// would let that session reach a workspace it does not own.
|
|
66
|
+
if (
|
|
67
|
+
typeof requestedSession === 'string'
|
|
68
|
+
&& requestedSession !== host.sessionId
|
|
69
|
+
&& !host.owns?.(requestedSession)
|
|
70
|
+
) {
|
|
60
71
|
return refuse(ACP_ERROR.invalidParams, `Unknown session: ${requestedSession}`);
|
|
61
72
|
}
|
|
62
73
|
const target = params.path;
|
|
@@ -66,7 +77,8 @@ export async function handleAcpFsRequest(
|
|
|
66
77
|
if (!path.isAbsolute(target)) {
|
|
67
78
|
return refuse(ACP_ERROR.invalidParams, `Path must be absolute: ${target}`);
|
|
68
79
|
}
|
|
69
|
-
|
|
80
|
+
const root = host.cwdFor?.(typeof requestedSession === 'string' ? requestedSession : undefined) ?? host.cwd;
|
|
81
|
+
if (!(await pathHolds(root, target))) {
|
|
70
82
|
return refuse(ACP_ERROR.invalidParams, `Path is outside this session's workspace: ${target}`);
|
|
71
83
|
}
|
|
72
84
|
|
|
@@ -40,7 +40,13 @@ describe('initializeAcpAgent', () => {
|
|
|
40
40
|
protocolVersion: 2,
|
|
41
41
|
capabilities: {},
|
|
42
42
|
info: { name: 'kabmo', version: '0.1' },
|
|
43
|
-
clientCapabilities: {
|
|
43
|
+
clientCapabilities: {
|
|
44
|
+
fs: { readTextFile: true, writeTextFile: true },
|
|
45
|
+
// Advertised because both have a consumer now: `plan` feeds the Todos
|
|
46
|
+
// panel, `subagents` is what lets a v1 agent announce a child at all.
|
|
47
|
+
session: { notices: {}, compaction: {}, plan: {} },
|
|
48
|
+
subagents: {},
|
|
49
|
+
},
|
|
44
50
|
});
|
|
45
51
|
expect(result.protocolVersion).toBe(2);
|
|
46
52
|
expect(result.agentCapabilities?.promptCapabilities?.image).toBe(true);
|
|
@@ -67,4 +73,29 @@ describe('initializeAcpAgent', () => {
|
|
|
67
73
|
}))).rejects.toThrow('ACP agent exited');
|
|
68
74
|
expect(calls).toBe(1);
|
|
69
75
|
});
|
|
76
|
+
|
|
77
|
+
test('does not retry a refusal that is not about the version', async () => {
|
|
78
|
+
// Re-sending `initialize` to an agent that refused for its own reason hid
|
|
79
|
+
// the real error behind a second attempt, and reported the pair as a
|
|
80
|
+
// version problem it was not.
|
|
81
|
+
let calls = 0;
|
|
82
|
+
await expect(initializeAcpAgent(invokeAnswering(async () => {
|
|
83
|
+
calls += 1;
|
|
84
|
+
throw new AcpRequestError('Invalid params: unknown field "capabilities"', -32602);
|
|
85
|
+
}))).rejects.toThrow('Invalid params');
|
|
86
|
+
expect(calls).toBe(1);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('retries when the refusal lists only v1 as supported', async () => {
|
|
90
|
+
const versions: unknown[] = [];
|
|
91
|
+
const result = await initializeAcpAgent(invokeAnswering(async (params) => {
|
|
92
|
+
versions.push(params.protocolVersion);
|
|
93
|
+
if (params.protocolVersion === 2) {
|
|
94
|
+
throw new AcpRequestError('Protocol version not supported', -32602, { requested: 2, supported: [1] });
|
|
95
|
+
}
|
|
96
|
+
return { protocolVersion: 1 };
|
|
97
|
+
}));
|
|
98
|
+
expect(versions).toEqual([2, 1]);
|
|
99
|
+
expect(result.protocolVersion).toBe(1);
|
|
100
|
+
});
|
|
70
101
|
});
|
|
@@ -20,6 +20,13 @@
|
|
|
20
20
|
* is still uninitialized after a failed `initialize`, so one clean v1 retry is
|
|
21
21
|
* allowed and is what keeps such an agent working.
|
|
22
22
|
*
|
|
23
|
+
* **Only a VERSION refusal is retried.** The first version of this retried on
|
|
24
|
+
* any `AcpRequestError`, which re-sent `initialize` to an agent that had refused
|
|
25
|
+
* it for its own reasons (`Invalid params`, a broken config) and reported the
|
|
26
|
+
* second failure as if the version were at fault. The retry now needs evidence
|
|
27
|
+
* that v2 is the problem: the spec's version-mismatch code, a `supported` list
|
|
28
|
+
* that excludes 2, or the adapter's own "unsupported version" wording.
|
|
29
|
+
*
|
|
23
30
|
* The result is normalized into the v1-shaped record the rest of Kabmo reads
|
|
24
31
|
* (`normalizeInitializeResult`); the negotiated major is kept on it.
|
|
25
32
|
*/
|
|
@@ -38,6 +45,9 @@ export type AcpInitializeInvoke = <T>(method: string, params: unknown, timeoutMs
|
|
|
38
45
|
|
|
39
46
|
const CLIENT_INFO = { name: 'kabmo', title: 'Kabmo', version: '0.1' };
|
|
40
47
|
|
|
48
|
+
/** The spec's `-32022`, answered with the majors the agent does support. */
|
|
49
|
+
const UNSUPPORTED_PROTOCOL_VERSION = -32022;
|
|
50
|
+
|
|
41
51
|
/** v1 capabilities for a v1 peer; v2 removed fs/terminal and Kabmo advertises neither. */
|
|
42
52
|
function v1Request(capabilities: Record<string, unknown>): Record<string, unknown> {
|
|
43
53
|
return {
|
|
@@ -58,24 +68,59 @@ function hybridRequest(capabilities: Record<string, unknown>): Record<string, un
|
|
|
58
68
|
};
|
|
59
69
|
}
|
|
60
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Whether a refused `initialize` is a VERSION mismatch, which is the only
|
|
73
|
+
* refusal a v1 retry can fix.
|
|
74
|
+
*/
|
|
75
|
+
export function isVersionRefusal(error: unknown): boolean {
|
|
76
|
+
if (!(error instanceof AcpRequestError)) return false;
|
|
77
|
+
if (error.code === UNSUPPORTED_PROTOCOL_VERSION) return true;
|
|
78
|
+
const data = asRecord(error.data);
|
|
79
|
+
const supported = data?.supported;
|
|
80
|
+
if (Array.isArray(supported)) {
|
|
81
|
+
const versions = supported.filter((value): value is number => typeof value === 'number');
|
|
82
|
+
if (versions.length > 0 && !versions.includes(2)) return true;
|
|
83
|
+
}
|
|
84
|
+
return /unsupported\s+(protocol\s+)?version|protocol version .*not supported/i.test(error.message);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The major this client ASKS for. `KABMO_ACP_PROTOCOL=1` pins every connection
|
|
89
|
+
* to v1 — the kill switch for an adapter that misbehaves under the v2 dialect
|
|
90
|
+
* (which upstream still ships behind an unstable feature). Unset means the
|
|
91
|
+
* hybrid v2 request with a v1 retry.
|
|
92
|
+
*/
|
|
93
|
+
export function acpProtocolPreference(): 1 | 2 {
|
|
94
|
+
return Bun.env.KABMO_ACP_PROTOCOL === '1' ? 1 : 2;
|
|
95
|
+
}
|
|
96
|
+
|
|
61
97
|
export async function initializeAcpAgent(
|
|
62
98
|
request: AcpInitializeInvoke,
|
|
63
99
|
capabilities: Record<string, unknown> = KABMO_CLIENT_CAPABILITIES,
|
|
64
100
|
timeoutMs = 60_000,
|
|
65
101
|
): Promise<AcpInitializeResult> {
|
|
102
|
+
const pinned = acpProtocolPreference();
|
|
66
103
|
let raw: Record<string, unknown>;
|
|
67
104
|
try {
|
|
68
|
-
raw = asRecord(
|
|
105
|
+
raw = asRecord(
|
|
106
|
+
await request<unknown>('initialize', pinned === 1 ? v1Request(capabilities) : hybridRequest(capabilities), timeoutMs),
|
|
107
|
+
) ?? {};
|
|
108
|
+
if (pinned === 1) {
|
|
109
|
+
const result = normalizeInitializeResult(raw);
|
|
110
|
+
assertProtocolVersion(result);
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
69
113
|
} catch (first) {
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
if (!(first
|
|
114
|
+
// A dead process or a timeout has nothing to renegotiate, and neither does
|
|
115
|
+
// an agent that refused for its own reason: re-sending would hide the real
|
|
116
|
+
// error behind a second attempt.
|
|
117
|
+
if (!isVersionRefusal(first)) throw first;
|
|
118
|
+
const firstMessage = first instanceof Error ? first.message : String(first);
|
|
74
119
|
try {
|
|
75
120
|
raw = asRecord(await request<unknown>('initialize', v1Request(capabilities), timeoutMs)) ?? {};
|
|
76
121
|
} catch (retry) {
|
|
77
122
|
const b = retry instanceof Error ? retry.message : String(retry);
|
|
78
|
-
throw new Error(`initialize failed (v2 attempt: ${
|
|
123
|
+
throw new Error(`initialize failed (v2 attempt: ${firstMessage}; v1 attempt: ${b})`);
|
|
79
124
|
}
|
|
80
125
|
}
|
|
81
126
|
const result = normalizeInitializeResult(raw);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Answering a call the AGENT made on this client.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `client.ts` for the per-file ceiling, and because the rule is
|
|
10
|
+
* its own subject: an unanswered agent→client call parks the turn, so every
|
|
11
|
+
* branch here either answers, defers (the approval dialog answers later through
|
|
12
|
+
* `respond`), or refuses WITH a code the agent can act on. Dropping a call is
|
|
13
|
+
* the one outcome this module must never produce.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { AcpId } from '@/server/lib/harness/acp/protocol';
|
|
17
|
+
import type { AcpClientRequestHandler } from '@/server/lib/harness/acp/client';
|
|
18
|
+
|
|
19
|
+
/** The transport seams one answer needs. */
|
|
20
|
+
export interface AgentRequestResponder {
|
|
21
|
+
respond(id: AcpId, result: unknown): void;
|
|
22
|
+
respondError(id: AcpId, message: string, code?: number): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function answerAgentRequest(
|
|
26
|
+
responder: AgentRequestResponder,
|
|
27
|
+
ask: AcpClientRequestHandler | undefined,
|
|
28
|
+
id: AcpId,
|
|
29
|
+
method: string,
|
|
30
|
+
params: unknown,
|
|
31
|
+
): Promise<void> {
|
|
32
|
+
const bag = (params ?? {}) as Record<string, unknown>;
|
|
33
|
+
try {
|
|
34
|
+
const handled = await ask?.(id, method, bag);
|
|
35
|
+
if (handled?.answered) {
|
|
36
|
+
responder.respond(id, handled.result);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// A deferred call is answered LATER through `respond(id, …)` — the approval
|
|
40
|
+
// dialog works this way, and sending a refusal here would answer the same
|
|
41
|
+
// request twice.
|
|
42
|
+
if (handled && 'deferred' in handled) return;
|
|
43
|
+
// A refusal is REQUIRED, and the code travels with it so the agent can fall
|
|
44
|
+
// back (`-32601` is "this client lacks the method", not "it broke").
|
|
45
|
+
responder.respondError(id, handled?.message ?? `Kabmo does not implement ${method}`, handled?.code);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
responder.respondError(id, error instanceof Error ? error.message : String(error));
|
|
48
|
+
}
|
|
49
|
+
}
|