@kabmo-labs/kabmo 0.42.2 → 0.43.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.
- package/README.md +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +721 -675
- package/dist/client/static/js/{CsvGrid-g6rek8y9.js → CsvGrid-g67pk2zy.js} +2 -2
- package/dist/client/static/js/{DocxView-41t9ryws.js → DocxView-pyh6p2kb.js} +4 -4
- package/dist/client/static/js/{DrawioView-mfxhfz1h.js → DrawioView-g48r6y2m.js} +2 -2
- package/dist/client/static/js/ImageView-rnzf5tve.js +1 -0
- package/dist/client/static/js/LayoutWrapper-rekrgth6.js +2 -0
- package/dist/client/static/js/Modal-edw446r8.js +59 -0
- package/dist/client/static/js/{PdfView-bek8k888.js → PdfView-6z3cgj37.js} +1 -1
- package/dist/client/static/js/SessionsView-e84tjbcr.js +1 -0
- package/dist/client/static/js/{SheetView-vezssf6b.js → SheetView-64076z1j.js} +13 -13
- package/dist/client/static/js/{SvgPreview-f1qaw73k.js → SvgPreview-dmpgavgd.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-4qn94h52.js → abnfDiagram-O67JEVCF-nfz5z1vw.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-7j23x20s.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-tbewzdya.js → architectureDiagram-NJMV4G6O-jra2jyzw.js} +11 -11
- package/dist/client/static/js/{astro-nn7xg0we.js → astro-dpfdhc5e.js} +1 -1
- package/dist/client/static/js/bash-vv2ysp0a.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-njgnwckz.js → blockDiagram-BEXU5L5S-3szktxam.js} +7 -7
- package/dist/client/static/js/c-8jf64j6h.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-f58pcvbk.js → c4Diagram-YGBWAQC7-xe9vbppt.js} +6 -6
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-52g73vyw.js → classDiagram-v2-NBCMYWYE-egzhj1xn.js} +6 -6
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-ptdnshzh.js → cose-bilkent-JH36ORCC-dfrk1wnr.js} +1 -1
- package/dist/client/static/js/cpp-vh94zee0.js +1 -0
- package/dist/client/static/js/css-p57h1fme.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-me5xnx6a.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-qabfdkzr.js → cynefinDiagram-VND7K2PF-xefpcmpg.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-kyf5jetf.js → dagre-6A5THRUB-vtzjnrt9.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-bxrsjtv9.js → diagram-22UHCM2B-4vvn790v.js} +16 -16
- package/dist/client/static/js/{diagram-3UASUU5V-0f41s00j.js → diagram-3UASUU5V-tmht3bew.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-0z1zx9h1.js → diagram-ATOU4E4O-p5wa5ztx.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-znrmr6bk.js → diagram-CDSNMT55-8myesjfc.js} +5 -5
- package/dist/client/static/js/{diagram-MLGK6HIB-jfe2jhk0.js → diagram-MLGK6HIB-9t3x2d5f.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-2kaawmwa.js → diagram-MPIPVDR6-8ahgnmhy.js} +3 -3
- package/dist/client/static/js/{dockerfile-12exatm9.js → dockerfile-x8aa0543.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-s5n37rfp.js → ebnfDiagram-ZINNZB2B-5semw111.js} +1 -1
- package/dist/client/static/js/{elixir-szk51ehr.js → elixir-5ewfhvfh.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-433rd9fp.js → elk-276RUBZZ-jmhs58ww.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-key6ah0b.js → erDiagram-OPXOYQCR-31wvbpdr.js} +8 -8
- package/dist/client/static/js/{erlang-zwy7cqdk.js → erlang-jqqa3ehb.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-5zbvjj84.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-36ygrbvm.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-4efkhmca.js → ganttDiagram-FUAMR5RP-c2dycjrf.js} +6 -6
- package/dist/client/static/js/gitGraph-4MIJSDKK-tjhkv71w.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ac376y2k.js → gitGraphDiagram-X574FWY7-y4k4pdd8.js} +14 -14
- package/dist/client/static/js/graphql-kesh8gk0.js +1 -0
- package/dist/client/static/js/html-sxpfydga.js +1 -0
- package/dist/client/static/js/{index-e1yz59fa.js → index-0c6vpk89.js} +2 -2
- package/dist/client/static/js/{index-0pabfaac.js → index-0q2qfcjn.js} +1 -1
- package/dist/client/static/js/{index-p0ez6hqd.js → index-181p91hf.js} +1 -1
- package/dist/client/static/js/{index-zs73zwjz.js → index-2b46dzw8.js} +4 -4
- package/dist/client/static/js/{index-02543wk3.js → index-2cbnjc32.js} +2 -2
- package/dist/client/static/js/{index-7a2efrbj.js → index-3588r3wg.js} +2 -2
- package/dist/client/static/js/{index-4cncqz8j.js → index-38v0781h.js} +2 -2
- package/dist/client/static/js/{index-z78bzryw.js → index-48gh56ka.js} +3 -3
- package/dist/client/static/js/{index-0e9nkc0g.js → index-48pb18zj.js} +2 -2
- package/dist/client/static/js/{index-77t0nvt1.js → index-4rv388z7.js} +2 -2
- package/dist/client/static/js/index-52xmdeh2.js +1 -0
- package/dist/client/static/js/{index-5jnvz9hw.js → index-6fpd55cq.js} +2 -2
- package/dist/client/static/js/{index-nh29fkk9.js → index-7dp90ad1.js} +2 -2
- package/dist/client/static/js/{index-yzda8j2d.js → index-8kqepehd.js} +12 -12
- package/dist/client/static/js/{index-raca8tsh.js → index-aar68x31.js} +4 -4
- package/dist/client/static/js/{index-pxtff3ez.js → index-bvjct7sp.js} +2 -2
- package/dist/client/static/js/{index-cz50ha6x.js → index-cgzw43bc.js} +78 -78
- package/dist/client/static/js/{index-50mdqev0.js → index-cje5gg45.js} +1 -1
- package/dist/client/static/js/{index-zndbhb9w.js → index-cjhvtzdd.js} +2 -2
- package/dist/client/static/js/{index-8b3t2y77.js → index-cqnpsw2m.js} +2 -2
- package/dist/client/static/js/{index-r9db1gsf.js → index-dkwhs38j.js} +2 -2
- package/dist/client/static/js/{index-pkes9492.js → index-e7yf273s.js} +2 -2
- package/dist/client/static/js/{index-8kbp24xg.js → index-efra065v.js} +1 -1
- package/dist/client/static/js/index-f77c3ag0.js +479 -0
- package/dist/client/static/js/{index-yjmm73jm.js → index-f7djda1g.js} +2 -2
- package/dist/client/static/js/{index-8k7vjp8b.js → index-fbcg8y95.js} +1 -1
- package/dist/client/static/js/{index-pysqpc5n.js → index-fg965t62.js} +2 -2
- package/dist/client/static/js/{index-qsw5edtk.js → index-fjnkzk12.js} +5 -5
- package/dist/client/static/js/{index-s4gv0rpk.js → index-g3shdymf.js} +1 -1
- package/dist/client/static/js/{index-qx6x4z0y.js → index-gmnmnfm0.js} +2 -2
- package/dist/client/static/js/{index-gp57dx2v.js → index-h5n1btqy.js} +1 -1
- package/dist/client/static/js/{index-r8cc80w5.js → index-jz93j0at.js} +2 -2
- package/dist/client/static/js/{index-dtj73vs1.js → index-kc5znr75.js} +2 -2
- package/dist/client/static/js/index-m1n4v0z7.js +9 -0
- package/dist/client/static/js/{index-1t5ybx9v.js → index-m94f4ngb.js} +3 -3
- package/dist/client/static/js/{index-dfqmwm7j.js → index-m9s9rg5k.js} +2 -2
- package/dist/client/static/js/{index-gsxebrq9.js → index-n9scbxy5.js} +2 -2
- package/dist/client/static/js/{index-zs7sjv6x.js → index-nt7nhchn.js} +1 -1
- package/dist/client/static/js/{index-v3f7we4n.js → index-pt8440xh.js} +22 -22
- package/dist/client/static/js/{index-b42t14wk.js → index-q81rxwh7.js} +35 -35
- package/dist/client/static/js/{index-ktbrmp29.js → index-qhytrsyb.js} +2 -2
- package/dist/client/static/js/index-rn8w29pv.js +2 -0
- package/dist/client/static/js/{index-1y3rzw6b.js → index-s00j9042.js} +1 -1
- package/dist/client/static/js/{index-hga3e13s.js → index-s78n0dtv.js} +2 -2
- package/dist/client/static/js/index-s7rfbydk.js +4 -0
- package/dist/client/static/js/{index-03pyvmcz.js → index-sesghshh.js} +2 -2
- package/dist/client/static/js/{index-ykfd2fyj.js → index-sg6sz3g8.js} +1 -1
- package/dist/client/static/js/index-vcrh95gf.css +1 -0
- package/dist/client/static/js/{index-82vk27q1.js → index-vyw4tbn8.js} +2 -2
- package/dist/client/static/js/{index-dzmar8jr.js → index-w5rw8f7w.js} +1 -1
- package/dist/client/static/js/{index-f33c4paw.js → index-x6v37h3j.js} +1 -1
- package/dist/client/static/js/{index-b0v6gwym.js → index-ycks7gyg.js} +2 -2
- package/dist/client/static/js/{index-hw14rhen.js → index-ynaxep06.js} +2 -2
- package/dist/client/static/js/{index-rab39785.js → index-ys0xpw3q.js} +2 -2
- package/dist/client/static/js/{index-feffxxss.js → index-yvgbr7ek.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-m6qz24p8.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-4e7ej63f.js → infoDiagram-VRGFBTTK-z3pqx7w8.js} +1 -1
- package/dist/client/static/js/ini-1x0ad976.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-k3yet1ec.js → ishikawaDiagram-OU5B5YK6-f5v6z8yr.js} +4 -4
- package/dist/client/static/js/java-3944nq02.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-qe352kyd.js → journeyDiagram-ZHPQQLJL-js1yxatk.js} +5 -5
- package/dist/client/static/js/json-g5ggnd94.js +1 -0
- package/dist/client/static/js/jsx-f6p72qpc.js +1 -0
- package/dist/client/static/js/{julia-2eekpjq8.js → julia-0h9krgsd.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-58hag75n.js → kanban-definition-PNTS6WVX-m0a6069c.js} +5 -5
- package/dist/client/static/js/lua-edn2b3wn.js +1 -0
- package/dist/client/static/js/markdown-9dhg1fax.js +1 -0
- package/dist/client/static/js/{mermaid.core-6e89h6vm.js → mermaid.core-6xvbnm63.js} +6 -6
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-ncsam2fm.js → mindmap-definition-NLK3R4M7-a9f9yzc0.js} +4 -4
- package/dist/client/static/js/one-dark-pro-hteqzfb0.js +1 -0
- package/dist/client/static/js/one-light-dapnh0rs.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-ng6wq5xj.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-b5ckc39d.js → pegDiagram-GJSIUBJH-4v4pf1h1.js} +1 -1
- package/dist/client/static/js/{perl-dtn1fccw.js → perl-rptyx23q.js} +1 -1
- package/dist/client/static/js/{php-7av78hch.js → php-sagvq3wz.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-rf6jhxf6.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-s4d47ve8.js → pieDiagram-5QR66LMP-a54yrmfm.js} +3 -3
- package/dist/client/static/js/properties-fcmj08pv.js +1 -0
- package/dist/client/static/js/python-532d8ezm.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-zm0ekvjz.js → quadrantDiagram-O4NWA36T-1twhvnp2.js} +6 -6
- package/dist/client/static/js/r-ptmdxs2a.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-ygp6hxq4.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-rxgnrb2g.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-xkv52a2p.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-bvcktbqh.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-9c3v7jsq.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-52vdqf53.js → railroadDiagram-XR7U4H2S-83tqfdcy.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-7kf8bmk9.js → requirementDiagram-PLB6GJNP-73e3pzw6.js} +4 -4
- package/dist/client/static/js/{ruby-s2bqr910.js → ruby-9qyx7knh.js} +1 -1
- package/dist/client/static/js/{rust-q98kssv3.js → rust-jds4e4r7.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-bcb9f54a.js → sankeyDiagram-IPEJSGJF-1bzwj6sb.js} +6 -6
- package/dist/client/static/js/{sass-bm32bb5k.js → sass-07rteya0.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-76ywvj7g.js → sequenceDiagram-PO4LG4MO-yh3h988k.js} +19 -19
- package/dist/client/static/js/{sizeCapture-INFHLROL-p9bsf5dc.js → sizeCapture-INFHLROL-1n121yp6.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-1ecfb3fs.js → stateDiagram-v2-GCMORJYK-0tdrzn06.js} +6 -6
- package/dist/client/static/js/{svelte-ztkaww47.js → svelte-w365cpwa.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-2pyjr946.js → swimlanes-2SLR337P-77n1ttdw.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-akjqm31r.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-4csxwmn2.js → timeline-definition-EJHVYXUP-b6r0k3e8.js} +2 -2
- package/dist/client/static/js/treeView-Q6P3EWNA-fb58a7z1.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-ej4qhksx.js +1 -0
- package/dist/client/static/js/typescript-683kkkaw.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0p1jnbsn.js → usecaseDiagram-POWQR4AR-efq58m3m.js} +43 -43
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-y1hgdet4.js → vennDiagram-UO4OBE2U-ad4gvd5r.js} +5 -5
- package/dist/client/static/js/{vue-cbqm4bed.js → vue-d6cesny1.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-mkp0kanv.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-p578yrgm.js → wardleyDiagram-VNRHLVJA-v89tys2p.js} +4 -4
- package/dist/client/static/js/xml-6ct32gys.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-b08b4ah0.js → xychartDiagram-PMCCYNJV-xtgzmknw.js} +5 -5
- package/dist/client/static/js/yaml-1d5m3bfj.js +1 -0
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/app.test.tsx +161 -0
- package/marketplace/plugins/command-runner/src/app.tsx +37 -3
- package/marketplace/plugins/command-runner/src/panel/Glyph.tsx +22 -4
- package/marketplace/plugins/git-forge/package.json +2 -2
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +22 -3
- package/marketplace/plugins/git-forge/src/panel/index.tsx +21 -3
- package/marketplace/plugins/git-forge/src/panel/refresh.test.tsx +192 -0
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +4 -2
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +21 -0
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/RefreshButton.tsx +9 -7
- package/marketplace/plugins/stats/src/app.tsx +15 -1
- package/marketplace/plugins/stats/src/refresh.test.tsx +166 -0
- package/package.json +1 -1
- package/src/client/components/common/anchored-menu/index.tsx +26 -8
- package/src/client/components/common/context-usage-button/McpSection.test.tsx +34 -5
- package/src/client/components/common/context-usage-button/McpSection.tsx +25 -3
- package/src/client/components/common/harness-glyph/brands.ts +3 -0
- package/src/client/components/common/harness-glyph/omo.ts +22 -0
- package/src/client/components/common/server-control/Panel.tsx +24 -86
- package/src/client/components/common/server-control/Row.tsx +98 -0
- package/src/client/components/common/server-control/index.test.tsx +69 -9
- package/src/client/components/layout/VisibilityMenu.tsx +18 -6
- package/src/client/components/layout/new-workspace-host/index.test.tsx +84 -0
- package/src/client/components/layout/new-workspace-host/index.tsx +35 -0
- package/src/client/components/mobile/header-titlebar.test.tsx +38 -3
- package/src/client/components/settings/Sidebar.tsx +2 -1
- package/src/client/components/settings/categories/GitSettings.tsx +31 -0
- package/src/client/components/settings/categories/git-settings/CommitMessageSection.tsx +292 -0
- package/src/client/components/settings/categories/git-settings/IdentitySection.tsx +215 -0
- package/src/client/components/settings/category-content.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +8 -0
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +55 -2
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +13 -1
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +56 -50
- package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +38 -2
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +13 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +50 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +20 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +21 -9
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +1 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +18 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +47 -0
- package/src/client/components/workspace/git-panel/CommitBox.test.tsx +98 -0
- package/src/client/components/workspace/git-panel/CommitBox.tsx +68 -3
- package/src/client/components/workspace/git-panel/index.test.ts +12 -0
- package/src/client/components/workspace/git-panel/index.tsx +20 -1
- package/src/client/components/workspace/repo-picker/index.test.tsx +20 -0
- package/src/client/components/workspace/repo-picker/index.tsx +5 -6
- package/src/client/data/settings/omp-schema.json +134 -8
- package/src/client/hooks/chat/context/mcp.ts +19 -1
- package/src/client/hooks/chat/omp/index.ts +2 -6
- package/src/client/hooks/chat/timeline/jump-rail.ts +1 -0
- package/src/client/hooks/chat/timeline/row-window.test.ts +38 -3
- package/src/client/hooks/chat/timeline/row-window.ts +33 -9
- package/src/client/hooks/chat/timeline/scroll-geometry.ts +19 -1
- package/src/client/hooks/chat/timeline/scroll.ts +15 -0
- package/src/client/hooks/chat/timeline/thinking-open.ts +10 -4
- package/src/client/hooks/workspace/commit-box.test.ts +62 -1
- package/src/client/hooks/workspace/commit-box.ts +94 -2
- package/src/client/hooks/workspace/git-panel-data.ts +15 -7
- package/src/client/hooks/workspace/repo-scope/index.test.ts +10 -3
- package/src/client/hooks/workspace/repo-scope/index.ts +21 -9
- package/src/client/lib/plugins/repo-scope-service.ts +7 -25
- package/src/server/lib/changes/capture-client-write.server.ts +45 -0
- package/src/server/lib/changes/capture.server.ts +20 -5
- package/src/server/lib/chat/session-store.server.ts +22 -1
- package/src/server/lib/db/schema.ts +3 -0
- package/src/server/lib/fs/git-commit-context.test.ts +111 -0
- package/src/server/lib/fs/git-commit-context.ts +85 -0
- package/src/server/lib/fs/git-commit-message.server.ts +251 -0
- package/src/server/lib/fs/git-commit-message.test.ts +211 -0
- package/src/server/lib/fs/git-commit-prompt.test.ts +69 -0
- package/src/server/lib/fs/git-commit-prompt.ts +57 -0
- package/src/server/lib/fs/git-commit-settings.server.ts +42 -0
- package/src/server/lib/fs/git-identity.server.test.ts +129 -0
- package/src/server/lib/fs/git-identity.server.ts +130 -0
- package/src/server/lib/harness/acp/acp-audit.server.ts +13 -62
- package/src/server/lib/harness/acp/acp-frames.server.test.ts +105 -0
- package/src/server/lib/harness/acp/acp-frames.server.ts +217 -0
- package/src/server/lib/harness/acp/acp-raw-messages.server.test.ts +69 -0
- package/src/server/lib/harness/acp/acp-raw-messages.server.ts +129 -0
- package/src/server/lib/harness/acp/acp-telemetry.server.ts +19 -0
- package/src/server/lib/harness/acp/auth.test.ts +69 -0
- package/src/server/lib/harness/acp/auth.ts +71 -0
- package/src/server/lib/harness/acp/background-replay.test.ts +139 -0
- package/src/server/lib/harness/acp/background-replay.ts +87 -0
- package/src/server/lib/harness/acp/background-work.ts +50 -33
- package/src/server/lib/harness/acp/calls.test.ts +68 -0
- package/src/server/lib/harness/acp/calls.ts +13 -0
- package/src/server/lib/harness/acp/client-capabilities.ts +5 -2
- package/src/server/lib/harness/acp/client-fs.test.ts +13 -0
- package/src/server/lib/harness/acp/client-fs.ts +16 -2
- package/src/server/lib/harness/acp/client.ts +22 -23
- package/src/server/lib/harness/acp/commands.test.ts +19 -0
- package/src/server/lib/harness/acp/commands.ts +26 -8
- package/src/server/lib/harness/acp/frames.ts +16 -1
- package/src/server/lib/harness/acp/grants.server.ts +75 -0
- package/src/server/lib/harness/acp/grants.test.ts +65 -0
- package/src/server/lib/harness/acp/grants.ts +79 -0
- package/src/server/lib/harness/acp/one-shot.server.ts +141 -0
- package/src/server/lib/harness/acp/permissions.test.ts +9 -0
- package/src/server/lib/harness/acp/permissions.ts +56 -36
- package/src/server/lib/harness/acp/prompt-files.test.ts +69 -0
- package/src/server/lib/harness/acp/prompt-files.ts +58 -0
- package/src/server/lib/harness/acp/prompt.ts +50 -11
- package/src/server/lib/harness/acp/protocol.ts +20 -1
- package/src/server/lib/harness/acp/raw-listeners.ts +30 -0
- package/src/server/lib/harness/acp/session-approvals.ts +45 -0
- package/src/server/lib/harness/acp/session-config-view.ts +81 -0
- package/src/server/lib/harness/acp/session-config.ts +48 -9
- package/src/server/lib/harness/acp/session-handshake.test.ts +71 -2
- package/src/server/lib/harness/acp/session-handshake.ts +139 -56
- package/src/server/lib/harness/acp/session-intake.test.ts +93 -0
- package/src/server/lib/harness/acp/session-intake.ts +75 -0
- package/src/server/lib/harness/acp/session-lifecycle.ts +50 -0
- package/src/server/lib/harness/acp/session-lost.test.ts +44 -0
- package/src/server/lib/harness/acp/session-lost.ts +34 -0
- package/src/server/lib/harness/acp/session-notify.ts +47 -0
- package/src/server/lib/harness/acp/session-observers.test.ts +4 -4
- package/src/server/lib/harness/acp/session-permissions.test.ts +64 -0
- package/src/server/lib/harness/acp/session-permissions.ts +9 -4
- package/src/server/lib/harness/acp/session-requests.ts +6 -0
- package/src/server/lib/harness/acp/session-roots.server.ts +47 -0
- package/src/server/lib/harness/acp/session-roots.test.ts +31 -0
- package/src/server/lib/harness/acp/session-start.ts +7 -0
- package/src/server/lib/harness/acp/session-turns.ts +11 -0
- package/src/server/lib/harness/acp/session-wiring.ts +100 -0
- package/src/server/lib/harness/acp/session.test-util.ts +36 -2
- package/src/server/lib/harness/acp/session.test.ts +10 -10
- package/src/server/lib/harness/acp/session.ts +149 -139
- package/src/server/lib/harness/acp/tool-calls.ts +27 -15
- package/src/server/lib/harness/acp/tool-identity.test.ts +136 -0
- package/src/server/lib/harness/acp/tool-identity.ts +121 -0
- package/src/server/lib/harness/acp/turn-cancel.test.ts +79 -0
- package/src/server/lib/harness/acp/turn-cancel.ts +61 -0
- package/src/server/lib/harness/acp/turn-dispatch.test.ts +103 -0
- package/src/server/lib/harness/acp/turn-dispatch.ts +61 -0
- package/src/server/lib/harness/acp/turn-queue.ts +43 -0
- package/src/server/lib/harness/acp/turn-verdict.ts +102 -0
- package/src/server/lib/harness/acp/turn.ts +86 -88
- package/src/server/lib/harness/acp/v2.test.ts +9 -0
- package/src/server/lib/harness/acp/v2.ts +13 -0
- package/src/server/lib/harness/acp/verbs.ts +35 -4
- package/src/server/lib/harness/capabilities.ts +11 -0
- package/src/server/lib/harness/launch-table.ts +19 -0
- package/src/server/lib/harness/launch.ts +4 -0
- package/src/server/lib/harness/schema.server.ts +23 -0
- package/src/server/lib/harness/spawn.server.ts +18 -2
- package/src/server/lib/mcp/agent-config.server.test.ts +111 -0
- package/src/server/lib/mcp/agent-config.server.ts +205 -0
- package/src/server/lib/mcp/probe.server.ts +7 -1
- package/src/server/lib/mcp/registry.server.ts +4 -3
- package/src/server/lib/mcp/secrets.server.test.ts +85 -0
- package/src/server/lib/mcp/secrets.server.ts +108 -0
- package/src/server/lib/omp/core/print.server.ts +100 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/session/artifacts.server.test.ts +15 -5
- package/src/server/lib/omp/session/artifacts.server.ts +41 -26
- package/src/server/lib/omp/session/delete.server.ts +5 -0
- package/src/server/lib/omp/session/goal-auditor.server.ts +10 -48
- package/src/server/lib/realtime/topics/session-data.server.ts +6 -14
- package/src/server/routes/fs/git-message.test.ts +101 -0
- package/src/server/routes/fs/git-message.ts +60 -0
- package/src/server/routes/fs/index.ts +2 -0
- package/src/server/routes/omp/artifact.ts +4 -3
- package/src/server/routes/sessions/mcp.test.ts +65 -1
- package/src/server/routes/sessions/mcp.ts +77 -5
- package/src/server/routes/settings/git-identity.test.ts +77 -0
- package/src/server/routes/settings/git-identity.ts +47 -0
- package/src/server/routes/settings/index.ts +2 -0
- package/src/server/routes/telemetry/acp-telemetry.test.ts +149 -0
- package/src/server/routes/telemetry/context.ts +31 -0
- package/src/server/routes/telemetry/raw-messages.ts +34 -0
- package/src/shared/lib/chat/tool/artifact.test.ts +4 -2
- package/src/shared/lib/chat/tool/artifact.ts +6 -1
- package/src/shared/lib/chat/tool/proc-facts.ts +2 -1
- package/src/shared/lib/fs/paths.test.ts +2 -0
- package/src/shared/lib/fs/repo-label.test.ts +22 -1
- package/src/shared/lib/fs/repo-label.ts +29 -0
- package/src/shared/lib/git/commit-prompt.test.ts +47 -0
- package/src/shared/lib/git/commit-prompt.ts +72 -0
- package/src/shared/lib/git/identity.test.ts +46 -0
- package/src/shared/lib/git/identity.ts +70 -0
- package/src/shared/lib/harness/brand-color.ts +3 -0
- package/src/shared/lib/harness/catalog.test.ts +14 -0
- package/src/shared/lib/harness/catalog.ts +9 -1
- package/src/shared/lib/harness/mcp-facts.ts +4 -0
- package/src/shared/lib/harness/provider-facts.test.ts +11 -0
- package/src/shared/lib/harness/provider-facts.ts +14 -0
- package/src/shared/lib/harness/providers.ts +2 -2
- package/src/shared/lib/harness/updates.test.ts +8 -0
- package/src/shared/lib/harness/updates.ts +9 -0
- package/src/shared/lib/omp/session/proc-daemon.ts +124 -0
- package/src/shared/lib/omp/session/proc.test.ts +30 -3
- package/src/shared/lib/omp/session/proc.ts +6 -82
- package/src/shared/lib/omp/session/wait-idle.test.ts +15 -4
- package/src/shared/lib/omp/session/wait-idle.ts +11 -4
- package/src/shared/lib/settings/defaults.ts +5 -0
- package/src/shared/lib/workspace/new-workspace.ts +20 -0
- package/src/shared/types/omp/agent.ts +14 -5
- package/src/shared/types/settings/mcp.ts +2 -2
- package/src/shared/types/settings/state.ts +16 -0
- package/src/test-support/preload.ts +1 -0
- package/dist/client/static/js/ImageView-bxqw3t4k.js +0 -1
- package/dist/client/static/js/LayoutWrapper-zt14rv9m.js +0 -2
- package/dist/client/static/js/Modal-cm35g20x.js +0 -38
- package/dist/client/static/js/SessionsView-gn53zyn7.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +0 -1
- package/dist/client/static/js/bash-fjzhxy10.js +0 -1
- package/dist/client/static/js/c-wqtyezvw.js +0 -1
- package/dist/client/static/js/cpp-y0nzwner.js +0 -1
- package/dist/client/static/js/css-n2waj098.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +0 -1
- package/dist/client/static/js/graphql-gvb7e2eb.js +0 -1
- package/dist/client/static/js/html-tbz83eke.js +0 -1
- package/dist/client/static/js/index-0gbj4270.js +0 -2
- package/dist/client/static/js/index-38xv8h4t.js +0 -1
- package/dist/client/static/js/index-f4vr1c6e.css +0 -1
- package/dist/client/static/js/index-fb6pw9xb.js +0 -2
- package/dist/client/static/js/index-pzvr1699.js +0 -478
- package/dist/client/static/js/index-rf29f3fq.js +0 -9
- package/dist/client/static/js/index-zw621xez.js +0 -4
- package/dist/client/static/js/info-A6RAGUB7-n495k952.js +0 -1
- package/dist/client/static/js/ini-2gvjwh83.js +0 -1
- package/dist/client/static/js/java-1xwcq79s.js +0 -1
- package/dist/client/static/js/json-4pqjabgq.js +0 -1
- package/dist/client/static/js/jsx-wcsss15s.js +0 -1
- package/dist/client/static/js/lua-h7vjcn0h.js +0 -1
- package/dist/client/static/js/markdown-f30jjjh9.js +0 -1
- package/dist/client/static/js/one-dark-pro-qmyne0tn.js +0 -1
- package/dist/client/static/js/one-light-dj0ecjcj.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +0 -1
- package/dist/client/static/js/properties-ymexza6q.js +0 -1
- package/dist/client/static/js/python-31ycwa66.js +0 -1
- package/dist/client/static/js/r-t2nne4xp.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-qr5hdxm4.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +0 -1
- package/dist/client/static/js/typescript-p3syh43m.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +0 -1
- package/dist/client/static/js/xml-4enq788a.js +0 -1
- package/dist/client/static/js/yaml-pjtt3jsc.js +0 -1
|
@@ -32,6 +32,10 @@ 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
|
+
/** Publish the write so the timeline's change journal records it. A write the
|
|
36
|
+
* AGENT performed through this client runs no tool of its own: without this
|
|
37
|
+
* frame its file change never reached the journal or the diff panel. */
|
|
38
|
+
emit?(event: Record<string, unknown> & { type: string }): void;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/** Structurally the `answered: false` branch of the client-request answer. */
|
|
@@ -66,7 +70,7 @@ export async function handleAcpFsRequest(
|
|
|
66
70
|
return refuse(ACP_ERROR.invalidParams, `Path is outside this session's workspace: ${target}`);
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
return method === 'fs/read_text_file' ? read(target, params) : write(target, params);
|
|
73
|
+
return method === 'fs/read_text_file' ? read(target, params) : write(host, target, params);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
async function read(target: string, params: Record<string, unknown>): Promise<AcpFsAnswer> {
|
|
@@ -94,15 +98,25 @@ async function read(target: string, params: Record<string, unknown>): Promise<Ac
|
|
|
94
98
|
return { answered: true, result: { content: lines.slice(start, end).join('\n') } };
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
async function write(target: string, params: Record<string, unknown>): Promise<AcpFsAnswer> {
|
|
101
|
+
async function write(host: AcpFsHost, target: string, params: Record<string, unknown>): Promise<AcpFsAnswer> {
|
|
98
102
|
const content = params.content;
|
|
99
103
|
if (typeof content !== 'string') {
|
|
100
104
|
return refuse(ACP_ERROR.invalidParams, 'content is required');
|
|
101
105
|
}
|
|
106
|
+
// The before side travels with the event: the journal's start-frame snapshot
|
|
107
|
+
// never ran, and reading the file again after this write would report no
|
|
108
|
+
// change at all.
|
|
109
|
+
const before = await Bun.file(target).text().catch(() => null);
|
|
102
110
|
try {
|
|
103
111
|
// `Bun.write` creates missing parent directories, which is the "MUST create
|
|
104
112
|
// the file if it doesn't exist" half of the method.
|
|
105
113
|
await Bun.write(target, content);
|
|
114
|
+
host.emit?.({
|
|
115
|
+
type: 'fs_write',
|
|
116
|
+
path: target,
|
|
117
|
+
...(before !== null ? { before } : {}),
|
|
118
|
+
after: content,
|
|
119
|
+
});
|
|
106
120
|
return { answered: true, result: {} };
|
|
107
121
|
} catch (error) {
|
|
108
122
|
return fileError(target, error);
|
|
@@ -73,7 +73,7 @@ const DEFAULT_REQUEST_TIMEOUT_MS = 60_000;
|
|
|
73
73
|
|
|
74
74
|
export class AcpProcess {
|
|
75
75
|
private readonly stdio: AgentStdio;
|
|
76
|
-
private readonly pending
|
|
76
|
+
private readonly pending: PendingCalls;
|
|
77
77
|
private readonly options: AcpClientOptions;
|
|
78
78
|
private nextId = 1;
|
|
79
79
|
private exited = false;
|
|
@@ -94,6 +94,11 @@ export class AcpProcess {
|
|
|
94
94
|
|
|
95
95
|
constructor(options: AcpClientOptions) {
|
|
96
96
|
this.options = options;
|
|
97
|
+
// A timed-out request is withdrawn from the AGENT too, not only from this
|
|
98
|
+
// table: `$/cancel_request` is the spec's way to say "stop working on it".
|
|
99
|
+
this.pending = new PendingCalls({
|
|
100
|
+
onTimeout: (id) => this.notify('$/cancel_request', { requestId: id }),
|
|
101
|
+
});
|
|
97
102
|
this.sinks = options;
|
|
98
103
|
this.stdio = new AgentStdio(
|
|
99
104
|
{
|
|
@@ -142,14 +147,8 @@ export class AcpProcess {
|
|
|
142
147
|
return this.init;
|
|
143
148
|
}
|
|
144
149
|
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* A prewarmed process is spawned before the session that will own it exists,
|
|
149
|
-
* so its notifications and agent→client requests have nowhere to go until the
|
|
150
|
-
* claim. Attaching here is what makes the warm child indistinguishable from a
|
|
151
|
-
* cold one for the rest of its life.
|
|
152
|
-
*/
|
|
150
|
+
/** Re-bind the frame sinks: a prewarmed process outlives the session that
|
|
151
|
+
* adopts it, so its handlers are attached at the claim. */
|
|
153
152
|
attachSinks(sinks: Pick<AcpClientOptions, 'onNotification' | 'onClientRequest' | 'onExit' | 'onStderr'>): void {
|
|
154
153
|
this.sinks = sinks;
|
|
155
154
|
}
|
|
@@ -159,8 +158,8 @@ export class AcpProcess {
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
// ── protocol verbs ───────────────────────────────────────────────────────
|
|
162
|
-
// Thin delegates to `verbs.ts`: the transport owns framing, the verbs own
|
|
163
|
-
// wire shape.
|
|
161
|
+
// Thin delegates to `verbs.ts`: the transport owns framing, the verbs own
|
|
162
|
+
// the wire shape.
|
|
164
163
|
|
|
165
164
|
newSession(cwd: string, timeoutMs?: number, mcpServers?: AcpMcpServerWire[]) {
|
|
166
165
|
return verbs.newSession(this.call, cwd, timeoutMs, this.protocolVersion, mcpServers);
|
|
@@ -225,6 +224,11 @@ export class AcpProcess {
|
|
|
225
224
|
return verbs.setMode(this.call, sessionId, modeId, timeoutMs);
|
|
226
225
|
}
|
|
227
226
|
|
|
227
|
+
/** Sign this client in with one of the agent's advertised auth methods. */
|
|
228
|
+
authenticate(methodId: string, timeoutMs?: number) {
|
|
229
|
+
return verbs.authenticate(this.call, methodId, timeoutMs);
|
|
230
|
+
}
|
|
231
|
+
|
|
228
232
|
deleteSession(sessionId: string, timeoutMs?: number) {
|
|
229
233
|
return verbs.deleteSession(this.call, sessionId, timeoutMs);
|
|
230
234
|
}
|
|
@@ -261,11 +265,9 @@ export class AcpProcess {
|
|
|
261
265
|
this.rejectAll(new Error('ACP agent disposed'));
|
|
262
266
|
}
|
|
263
267
|
|
|
264
|
-
/** Send a client→agent request and await its result.
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
* turn legitimately runs for minutes, and every other verb takes the default
|
|
268
|
-
* cap. A cap of 0 disables the timer entirely. */
|
|
268
|
+
/** Send a client→agent request and await its result. `timeoutMs` is the turn
|
|
269
|
+
* budget: a prompt passes 0 (a coding turn runs for minutes) and every other
|
|
270
|
+
* verb takes the default cap. */
|
|
269
271
|
private request<T>(method: string, params: unknown, timeoutMs = 0): Promise<T> {
|
|
270
272
|
if (this.exited) return Promise.reject(new Error('ACP agent has exited'));
|
|
271
273
|
const budget = timeoutMs > 0
|
|
@@ -286,9 +288,8 @@ export class AcpProcess {
|
|
|
286
288
|
private write(frame: AcpRequest | AcpNotification | AcpResponse): void {
|
|
287
289
|
if (this.exited) return;
|
|
288
290
|
const line = `${JSON.stringify(frame)}\n`;
|
|
289
|
-
// Serialized: two
|
|
290
|
-
//
|
|
291
|
-
// queue (which would wedge every later frame).
|
|
291
|
+
// Serialized: two interleaved frames would corrupt the stream, and a closed
|
|
292
|
+
// pipe is reported by `exited` rather than thrown into the queue.
|
|
292
293
|
this.writeQueue = this.writeQueue.then(async () => {
|
|
293
294
|
this.stdio.write(line);
|
|
294
295
|
await this.stdio.flush();
|
|
@@ -336,10 +337,8 @@ export class AcpProcess {
|
|
|
336
337
|
// approval dialog works this way, and sending a refusal here would answer
|
|
337
338
|
// the same request twice.
|
|
338
339
|
if (handled && 'deferred' in handled) return;
|
|
339
|
-
// A refusal is REQUIRED
|
|
340
|
-
//
|
|
341
|
-
// travels with it so the agent can distinguish "not implemented" from
|
|
342
|
-
// "that file is gone" and fall back accordingly.
|
|
340
|
+
// A refusal is REQUIRED: an unanswered agent→client call parks the turn.
|
|
341
|
+
// The code travels with it so the agent can fall back accordingly.
|
|
343
342
|
this.respondError(id, handled?.message ?? `Kabmo does not implement ${method}`, handled?.code);
|
|
344
343
|
} catch (error) {
|
|
345
344
|
this.respondError(id, error instanceof Error ? error.message : String(error));
|
|
@@ -61,6 +61,25 @@ function host(): AcpCommandHost & { writes: [string, string | boolean][]; access
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
describe('ACP dispatchCommand', () => {
|
|
64
|
+
test('a steer on an agent with no mid-turn channel is held for the next turn', async () => {
|
|
65
|
+
const stub = host();
|
|
66
|
+
const queued: [string, unknown][] = [];
|
|
67
|
+
stub.queueTurnInput = (message, images) => {
|
|
68
|
+
queued.push([message, images]);
|
|
69
|
+
};
|
|
70
|
+
expect(await dispatchCommand(stub, { type: 'steer', message: 'also do this' })).toEqual({ queued: true });
|
|
71
|
+
expect(queued).toEqual([['also do this', undefined]]);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('a follow-up on an agent with no mid-turn channel is held too', async () => {
|
|
75
|
+
const stub = host();
|
|
76
|
+
const queued: string[] = [];
|
|
77
|
+
stub.queueTurnInput = (message) => {
|
|
78
|
+
queued.push(message);
|
|
79
|
+
};
|
|
80
|
+
expect(await dispatchCommand(stub, { type: 'follow_up', message: 'then that' })).toEqual({ queued: true });
|
|
81
|
+
expect(queued).toEqual(['then that']);
|
|
82
|
+
});
|
|
64
83
|
test('set_model / set_thinking_level / set_mode write the selector ids', async () => {
|
|
65
84
|
const stub = host();
|
|
66
85
|
await dispatchCommand(stub, { type: 'set_model', provider: 'p', modelId: 'n' });
|
|
@@ -46,19 +46,26 @@ export interface AcpCommandHost {
|
|
|
46
46
|
isAlive(): boolean;
|
|
47
47
|
destroyAndWait(): Promise<void>;
|
|
48
48
|
steer(blocks: unknown[], queue: 'steering' | 'followUp'): Promise<unknown>;
|
|
49
|
+
/** Hold an input until the running turn ends (an agent with no steering). */
|
|
50
|
+
queueTurnInput?: (message: string, images: unknown) => void;
|
|
51
|
+
/** The content blocks one prompt sends: text, images and `@path` links. */
|
|
52
|
+
blocksFor?: (message: string, images: unknown) => Promise<unknown[]>;
|
|
49
53
|
/** Record a mid-turn user message in the session's own transcript. */
|
|
50
54
|
recordUserTurn(message: string, images: unknown): void;
|
|
51
55
|
cancelTurn(): void;
|
|
52
56
|
/** Adopt the composer's approval tier. ACP decides approvals in-process. */
|
|
53
57
|
setAccessMode(mode: ApprovalMode): void;
|
|
54
58
|
setConfig(configId: string, value: string | boolean): Promise<unknown>;
|
|
55
|
-
resolvePermission(dialogId: string, confirmed: boolean): unknown;
|
|
59
|
+
resolvePermission(dialogId: string, confirmed: boolean, optionId?: string): unknown;
|
|
56
60
|
webState(): Record<string, unknown>;
|
|
57
61
|
/** The agent's own slash-command list, when it published one. */
|
|
58
62
|
agentCommands: { name: string; description?: string; inputHint?: string }[];
|
|
59
63
|
}
|
|
60
64
|
|
|
61
|
-
/**
|
|
65
|
+
/** A prompt's blocks when the host offers no richer builder: text and images. */
|
|
66
|
+
const defaultBlocks = async (message: string, images: unknown): Promise<unknown[]> => promptBlocks(message, images);
|
|
67
|
+
|
|
68
|
+
/** The command vocabulary the routes already use. */
|
|
62
69
|
export async function dispatchCommand(host: AcpCommandHost, command: Record<string, unknown>): Promise<unknown> {
|
|
63
70
|
if (!host.isAlive()) throw new Error('ACP session is not running');
|
|
64
71
|
const type = typeof command.type === 'string' ? command.type : '';
|
|
@@ -90,9 +97,14 @@ export interface AcpCommandHost {
|
|
|
90
97
|
|
|
91
98
|
case 'steer': {
|
|
92
99
|
const message = String(command.message ?? '');
|
|
93
|
-
const blocks =
|
|
100
|
+
const blocks = await (host.blocksFor ?? defaultBlocks)(message, command.images);
|
|
94
101
|
if (host.capabilities.steerMode !== 'steer') {
|
|
95
|
-
|
|
102
|
+
// No mid-turn channel: hold it for the turn's end instead of dropping
|
|
103
|
+
// the operator's message. ACP has no queue of its own — the second
|
|
104
|
+
// prompt WOULD cancel the first — so the wait belongs here.
|
|
105
|
+
host.queueTurnInput?.(message, command.images);
|
|
106
|
+
host.recordUserTurn(message, command.images);
|
|
107
|
+
return { queued: true };
|
|
96
108
|
}
|
|
97
109
|
const result = await host.steer(blocks, 'steering');
|
|
98
110
|
host.recordUserTurn(message, command.images);
|
|
@@ -101,8 +113,12 @@ export interface AcpCommandHost {
|
|
|
101
113
|
|
|
102
114
|
case 'follow_up': {
|
|
103
115
|
const message = String(command.message ?? '');
|
|
104
|
-
const blocks =
|
|
105
|
-
if (!host.capabilities.steerMode)
|
|
116
|
+
const blocks = await (host.blocksFor ?? defaultBlocks)(message, command.images);
|
|
117
|
+
if (!host.capabilities.steerMode) {
|
|
118
|
+
host.queueTurnInput?.(message, command.images);
|
|
119
|
+
host.recordUserTurn(message, command.images);
|
|
120
|
+
return { queued: true };
|
|
121
|
+
}
|
|
106
122
|
const result = await host.steer(blocks, 'followUp');
|
|
107
123
|
host.recordUserTurn(message, command.images);
|
|
108
124
|
return result;
|
|
@@ -173,10 +189,12 @@ export interface AcpCommandHost {
|
|
|
173
189
|
case 'extension_ui_response': {
|
|
174
190
|
// The approval dialog's answer, in the shape the shared gate sends. The
|
|
175
191
|
// session owns the picking (which option means "allow"), because it is
|
|
176
|
-
// also the side that rendered the options.
|
|
192
|
+
// also the side that rendered the options. `optionId` is the option the
|
|
193
|
+
// operator clicked; `confirmed` is the yes/no fallback.
|
|
177
194
|
const id = typeof command.id === 'string' ? command.id : '';
|
|
195
|
+
const optionId = typeof command.optionId === 'string' ? command.optionId : undefined;
|
|
178
196
|
const confirmed = command.confirmed === true || command.value === 'allow';
|
|
179
|
-
return host.resolvePermission(id, confirmed);
|
|
197
|
+
return host.resolvePermission(id, confirmed, optionId);
|
|
180
198
|
}
|
|
181
199
|
|
|
182
200
|
default:
|
|
@@ -119,9 +119,14 @@ export class AcpFrameMapper {
|
|
|
119
119
|
case 'state_update':
|
|
120
120
|
case 'terminal_update':
|
|
121
121
|
case 'terminal_output_chunk':
|
|
122
|
+
return [];
|
|
123
|
+
// Compaction has no card of its own, but it is a LIVE event the operator
|
|
124
|
+
// must see: a chat that silently spends a minute rewriting its context
|
|
125
|
+
// reads as a hang. `session.compaction` is advertised, so an agent may
|
|
126
|
+
// send these, and a notice is the surface that exists.
|
|
122
127
|
case 'compaction_update':
|
|
123
128
|
case 'compaction_summary_chunk':
|
|
124
|
-
return
|
|
129
|
+
return this.compaction(update);
|
|
125
130
|
case 'usage_update':
|
|
126
131
|
return this.usage(update);
|
|
127
132
|
case 'available_commands_update':
|
|
@@ -279,6 +284,16 @@ export class AcpFrameMapper {
|
|
|
279
284
|
return frames;
|
|
280
285
|
}
|
|
281
286
|
|
|
287
|
+
/** One compaction frame as a notice, or nothing once it is complete. */
|
|
288
|
+
private compaction(update: Record<string, unknown>): AgentEvent[] {
|
|
289
|
+
const failed = typeof update.error === 'string' && update.error.length > 0;
|
|
290
|
+
return [{
|
|
291
|
+
type: 'notice',
|
|
292
|
+
level: failed ? 'warning' : 'info',
|
|
293
|
+
message: failed ? `Compaction failed: ${update.error}` : 'Compacting the conversation…',
|
|
294
|
+
}];
|
|
295
|
+
}
|
|
296
|
+
|
|
282
297
|
private usage(update: Record<string, unknown>): AgentEvent[] {
|
|
283
298
|
const size = typeof update.size === 'number' ? update.size : undefined;
|
|
284
299
|
const used = typeof update.used === 'number' ? update.used : undefined;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Persistence for ACP "always allow" grants.
|
|
8
|
+
*
|
|
9
|
+
* A grant is a decision the operator made about a command, so it must outlive
|
|
10
|
+
* the child that asked: the idle reaper kills an ACP agent after ten minutes and
|
|
11
|
+
* the next prompt adopts (or spawns) another one. Keeping the set in memory made
|
|
12
|
+
* the operator approve the same `bash` line again after every reclaim.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately its own table rather than `session_ui_state`: that blob belongs
|
|
15
|
+
* to the client and the session route REPLACES it wholesale, so a server-side
|
|
16
|
+
* write there would be erased by the next layout save.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { getDb } from '@/server/db.server';
|
|
20
|
+
import type { DbClient } from '@/server/lib/db/client';
|
|
21
|
+
|
|
22
|
+
const GRANTS_SQL = `
|
|
23
|
+
CREATE TABLE IF NOT EXISTS acp_permission_grants (
|
|
24
|
+
session_id TEXT NOT NULL,
|
|
25
|
+
grant_key TEXT NOT NULL,
|
|
26
|
+
created_at INTEGER NOT NULL,
|
|
27
|
+
PRIMARY KEY (session_id, grant_key)
|
|
28
|
+
);
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
/** Create the table on boot; the session routes touch it lazily. */
|
|
32
|
+
export async function ensureAcpGrantSchema(db: DbClient): Promise<void> {
|
|
33
|
+
await db.exec(GRANTS_SQL);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Every key this session has already approved with "always". */
|
|
37
|
+
export async function loadAcpGrants(sessionId: string): Promise<string[]> {
|
|
38
|
+
try {
|
|
39
|
+
const db = await getDb();
|
|
40
|
+
const rows = await db.all<{ grant_key: string }>(
|
|
41
|
+
'SELECT grant_key FROM acp_permission_grants WHERE session_id = ?',
|
|
42
|
+
[sessionId],
|
|
43
|
+
);
|
|
44
|
+
return rows.map((row) => row.grant_key);
|
|
45
|
+
} catch {
|
|
46
|
+
// no-excuse-ok: catch — an unreadable grants table is not a reason to fail
|
|
47
|
+
// the spawn; the operator is asked again, which is the safe direction.
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Remember one "always allow" decision. Best effort: the current turn already
|
|
53
|
+
* holds the in-memory grant, so a failed write only costs a repeat question. */
|
|
54
|
+
export async function saveAcpGrant(sessionId: string, grantKey: string): Promise<void> {
|
|
55
|
+
try {
|
|
56
|
+
const db = await getDb();
|
|
57
|
+
await db.run(
|
|
58
|
+
`INSERT INTO acp_permission_grants (session_id, grant_key, created_at) VALUES (?, ?, ?)
|
|
59
|
+
ON CONFLICT(session_id, grant_key) DO NOTHING`,
|
|
60
|
+
[sessionId, grantKey, Date.now()],
|
|
61
|
+
);
|
|
62
|
+
} catch {
|
|
63
|
+
// no-excuse-ok: catch — see above.
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Drop a deleted chat's grants with the rest of its rows. */
|
|
68
|
+
export async function forgetAcpGrants(sessionId: string): Promise<void> {
|
|
69
|
+
try {
|
|
70
|
+
const db = await getDb();
|
|
71
|
+
await db.run('DELETE FROM acp_permission_grants WHERE session_id = ?', [sessionId]);
|
|
72
|
+
} catch {
|
|
73
|
+
// no-excuse-ok: catch — the delete path reports its own failures.
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* "Always allow" is the operator's standing decision about one CALL, keyed by
|
|
8
|
+
* what the dialog showed — not by a tool-call id that differs on every
|
|
9
|
+
* invocation. A grant that outlived a process is the point; a grant that leaked
|
|
10
|
+
* across kinds (a write covering an exec) would be a security hole.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { describe, expect, test } from 'bun:test';
|
|
14
|
+
import { permissionGrantKey, PermissionGrants } from '@/server/lib/harness/acp/grants';
|
|
15
|
+
import { ensureAcpGrantSchema, loadAcpGrants, saveAcpGrant } from '@/server/lib/harness/acp/grants.server';
|
|
16
|
+
import { getDb } from '@/server/db.server';
|
|
17
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
18
|
+
|
|
19
|
+
describe('permissionGrantKey', () => {
|
|
20
|
+
test('keys on the command the dialog shows', () => {
|
|
21
|
+
expect(permissionGrantKey({ kind: 'execute', rawInput: { command: 'rm -rf build' } })).toBe('execute\u0000rm -rf build');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('keeps kinds apart so a write grant never covers an exec', () => {
|
|
25
|
+
const write = permissionGrantKey({ kind: 'edit', rawInput: { path: '/a.ts' } });
|
|
26
|
+
const read = permissionGrantKey({ kind: 'read', rawInput: { path: '/a.ts' } });
|
|
27
|
+
expect(write).not.toBe(read);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('a call with nothing identifying earns no key', () => {
|
|
31
|
+
expect(permissionGrantKey({ kind: 'execute', title: ' ' })).toBeNull();
|
|
32
|
+
expect(permissionGrantKey(undefined)).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('PermissionGrants', () => {
|
|
37
|
+
test('hydrated keys answer without a dialog', () => {
|
|
38
|
+
const grants = new PermissionGrants();
|
|
39
|
+
grants.hydrate(['execute\u0000make']);
|
|
40
|
+
expect(grants.has('execute\u0000make')).toBe(true);
|
|
41
|
+
expect(grants.has(null)).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('adding a key twice reports the first as the new grant', () => {
|
|
45
|
+
const grants = new PermissionGrants();
|
|
46
|
+
expect(grants.add('k')).toBe(true);
|
|
47
|
+
expect(grants.add('k')).toBe(false);
|
|
48
|
+
expect(grants.snapshot()).toEqual(['k']);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('grant persistence', () => {
|
|
53
|
+
test('a saved grant is read back for the same session, and only that one', async () => {
|
|
54
|
+
await isolateDb();
|
|
55
|
+
try {
|
|
56
|
+
await ensureAcpGrantSchema(await getDb());
|
|
57
|
+
await saveAcpGrant('chat-1', 'execute\u0000make test');
|
|
58
|
+
await saveAcpGrant('chat-1', 'execute\u0000make test');
|
|
59
|
+
expect(await loadAcpGrants('chat-1')).toEqual(['execute\u0000make test']);
|
|
60
|
+
expect(await loadAcpGrants('chat-2')).toEqual([]);
|
|
61
|
+
} finally {
|
|
62
|
+
await releaseDb();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The "always allow" grants of one ACP session.
|
|
8
|
+
*
|
|
9
|
+
* ACP offers `allow_always` beside `allow_once` on a permission request, and
|
|
10
|
+
* ignoring it made every repeated tool call ask again — the agent's own answer
|
|
11
|
+
* to "can I run this script" was thrown away and the operator re-approved the
|
|
12
|
+
* same command for the whole turn.
|
|
13
|
+
*
|
|
14
|
+
* A grant is keyed by what the approval DIALOG showed, not by the tool call id
|
|
15
|
+
* (which is different on every invocation): the tool's kind plus the command or
|
|
16
|
+
* path the agent reported. `reject_always` is deliberately NOT remembered —
|
|
17
|
+
* surfacing every attempt again is the safer mistake, and a refusal the operator
|
|
18
|
+
* has to repeat is never a security hole.
|
|
19
|
+
*
|
|
20
|
+
* The set is per SESSION and hydrated from the database at spawn, so a reload or
|
|
21
|
+
* a reclaimed child does not resurrect the questions.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** A grant is a key plus the option kind it was granted with. */
|
|
25
|
+
export interface PermissionGrant {
|
|
26
|
+
key: string;
|
|
27
|
+
kind: 'allow_always';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The identity a dialog showed: stable across invocations of the same call. */
|
|
31
|
+
export function permissionGrantKey(toolCall: Record<string, unknown> | undefined): string | null {
|
|
32
|
+
if (!toolCall) return null;
|
|
33
|
+
const kind = typeof toolCall.kind === 'string' ? toolCall.kind : 'other';
|
|
34
|
+
const rawInput = toolCall.rawInput && typeof toolCall.rawInput === 'object'
|
|
35
|
+
? toolCall.rawInput as Record<string, unknown>
|
|
36
|
+
: {};
|
|
37
|
+
// The field the dialog renders for a write/edit, plus the fields an exec
|
|
38
|
+
// carries. A title is a last resort: some agents send a constant title, and a
|
|
39
|
+
// grant keyed on nothing must not exist.
|
|
40
|
+
const subject = [
|
|
41
|
+
rawInput.command,
|
|
42
|
+
rawInput.path,
|
|
43
|
+
rawInput.filePath,
|
|
44
|
+
rawInput.file,
|
|
45
|
+
rawInput.target,
|
|
46
|
+
].find((value): value is string => typeof value === 'string' && value.trim().length > 0);
|
|
47
|
+
const title = typeof toolCall.title === 'string' ? toolCall.title.trim() : '';
|
|
48
|
+
const identity = subject ?? title;
|
|
49
|
+
if (!identity) return null;
|
|
50
|
+
return `${kind}\u0000${identity}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The grants one session has earned, in memory. */
|
|
54
|
+
export class PermissionGrants {
|
|
55
|
+
readonly #keys = new Set<string>();
|
|
56
|
+
|
|
57
|
+
/** Adopt the rows read from the database at spawn. */
|
|
58
|
+
hydrate(keys: readonly string[]): void {
|
|
59
|
+
for (const key of keys) this.#keys.add(key);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
has(key: string | null): boolean {
|
|
63
|
+
return key !== null && this.#keys.has(key);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
add(key: string | null): boolean {
|
|
67
|
+
if (key === null || this.#keys.has(key)) return false;
|
|
68
|
+
this.#keys.add(key);
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
clear(): void {
|
|
73
|
+
this.#keys.clear();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
snapshot(): string[] {
|
|
77
|
+
return [...this.#keys];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One disposable ACP turn: spawn the harness, ask one question, read the text.
|
|
8
|
+
*
|
|
9
|
+
* The goal auditor and the commit-message generator both need an answer from
|
|
10
|
+
* the SAME agent the user is talking to — its auth, its model, its config —
|
|
11
|
+
* without creating a chat row, a stream row, a title or a registry entry. This
|
|
12
|
+
* module owns that shape once; a second copy is how one caller would keep the
|
|
13
|
+
* permission gate while the other quietly let the agent edit the repository.
|
|
14
|
+
*
|
|
15
|
+
* `denyTools` is the default because both callers ask for TEXT. ACP has no
|
|
16
|
+
* universal `--no-tools` flag, so the gate is the permission request: every
|
|
17
|
+
* `session/request_permission` is answered `cancelled`, and the prompt tells
|
|
18
|
+
* the agent the supplied context is all it needs. The goal auditor opts out
|
|
19
|
+
* (`denyTools: false`) because its classification prompt is the only thing it
|
|
20
|
+
* ever asks and the agent may need its own tools to read the report.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { AcpSession } from '@/server/lib/harness/acp/session';
|
|
24
|
+
import { loadHarnessConfig, resolveLaunch } from '@/server/lib/harness/config.server';
|
|
25
|
+
import { sessionLaunchCommand } from '@/server/lib/harness/launch';
|
|
26
|
+
import { extractTextFromContent } from '@/shared/lib/omp/session/mapper';
|
|
27
|
+
import type { AcpSessionOptions } from '@/server/lib/harness/acp/session-options';
|
|
28
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
29
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
30
|
+
|
|
31
|
+
export interface AcpOneShotRequest {
|
|
32
|
+
harness: HarnessId;
|
|
33
|
+
cwd: string;
|
|
34
|
+
/** The chat's own model, as the agent resolved it. Null = the agent default. */
|
|
35
|
+
model: { provider: string; modelId: string } | null;
|
|
36
|
+
prompt: string;
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
/** Deny every tool permission request. Default true. */
|
|
39
|
+
denyTools?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type AcpOneShotOutcome =
|
|
43
|
+
| { ok: true; text: string }
|
|
44
|
+
| { ok: false; reason: 'launch' | 'timeout' | 'no-reply' | 'error'; detail?: string };
|
|
45
|
+
|
|
46
|
+
export interface AcpOneShotDeps {
|
|
47
|
+
/** Test seam: a fake session, so the protocol shape can be asserted without
|
|
48
|
+
* spawning an agent. */
|
|
49
|
+
createSession?: (options: AcpSessionOptions, cwd: string) => AcpSession;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const DEFAULT_TIMEOUT_MS = 90_000;
|
|
53
|
+
|
|
54
|
+
export async function runAcpOneShot(
|
|
55
|
+
request: AcpOneShotRequest,
|
|
56
|
+
deps: AcpOneShotDeps = {},
|
|
57
|
+
): Promise<AcpOneShotOutcome> {
|
|
58
|
+
let launch;
|
|
59
|
+
try {
|
|
60
|
+
const configured = await loadHarnessConfig(request.harness);
|
|
61
|
+
launch = resolveLaunch(request.harness, configured);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return {
|
|
64
|
+
ok: false,
|
|
65
|
+
reason: 'launch',
|
|
66
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const create = deps.createSession ?? ((options, cwd) => new AcpSession(options, cwd));
|
|
71
|
+
const session = create(
|
|
72
|
+
{
|
|
73
|
+
harness: request.harness,
|
|
74
|
+
command: sessionLaunchCommand(request.harness, launch.command),
|
|
75
|
+
...(launch.env ? { env: launch.env } : {}),
|
|
76
|
+
model: request.model,
|
|
77
|
+
// A text answer, not a task: the cheapest level the agent offers.
|
|
78
|
+
thinkingLevel: 'off',
|
|
79
|
+
// `always-ask` parks every tool call; the listener below answers it
|
|
80
|
+
// `cancelled`. `yolo` would let the agent edit the repository.
|
|
81
|
+
accessMode: request.denyTools === false ? 'yolo' : 'always-ask',
|
|
82
|
+
},
|
|
83
|
+
request.cwd,
|
|
84
|
+
);
|
|
85
|
+
// A disposable reader: no stream row, no turn settle, no queue, no title.
|
|
86
|
+
session.markStream = () => {};
|
|
87
|
+
session.onTurnEnded = async () => {};
|
|
88
|
+
|
|
89
|
+
const events: AgentEvent[] = [];
|
|
90
|
+
const stopEvents = session.onEvent((event) => events.push(event));
|
|
91
|
+
const ended = Promise.withResolvers<void>();
|
|
92
|
+
let timedOut = false;
|
|
93
|
+
const stopEnd = session.onEvent((event) => {
|
|
94
|
+
if (event.type === 'agent_end') ended.resolve();
|
|
95
|
+
});
|
|
96
|
+
const stopPermissions = request.denyTools === false
|
|
97
|
+
? () => {}
|
|
98
|
+
: session.onEvent((event) => {
|
|
99
|
+
// `session-permissions.ts` emits the permission dialog as an
|
|
100
|
+
// `AgentEvent`; its shape is the dialog, not a union member.
|
|
101
|
+
const record = event as unknown as { type?: string; id?: unknown };
|
|
102
|
+
if (record.type !== 'extension_ui_request') return;
|
|
103
|
+
if (typeof record.id !== 'string' && typeof record.id !== 'number') return;
|
|
104
|
+
session.respond(record.id, { outcome: { outcome: 'cancelled' } });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const timer = setTimeout(() => {
|
|
108
|
+
timedOut = true;
|
|
109
|
+
void session.destroyAndWait();
|
|
110
|
+
ended.resolve();
|
|
111
|
+
}, request.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
await session.start();
|
|
115
|
+
// `synthetic` keeps the one-shot prompt from becoming a session title.
|
|
116
|
+
await session.send({ type: 'prompt', message: request.prompt, synthetic: true });
|
|
117
|
+
await ended.promise;
|
|
118
|
+
if (timedOut) return { ok: false, reason: 'timeout' };
|
|
119
|
+
const message = [...events].reverse().find((event) => event.type === 'message_end')?.message;
|
|
120
|
+
if (!message || typeof message !== 'object' || !('content' in message)) {
|
|
121
|
+
return { ok: false, reason: 'no-reply' };
|
|
122
|
+
}
|
|
123
|
+
const text = extractTextFromContent(message.content).trim();
|
|
124
|
+
return text ? { ok: true, text } : { ok: false, reason: 'no-reply' };
|
|
125
|
+
} catch (error) {
|
|
126
|
+
return {
|
|
127
|
+
ok: false,
|
|
128
|
+
reason: 'error',
|
|
129
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
130
|
+
};
|
|
131
|
+
} finally {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
stopEvents();
|
|
134
|
+
stopEnd();
|
|
135
|
+
stopPermissions();
|
|
136
|
+
// Remove the disposable session from the agent's own history when it
|
|
137
|
+
// advertises `session/delete`. A refusal is not the answer's failure.
|
|
138
|
+
await session.deleteAgentSession().catch(() => false);
|
|
139
|
+
await session.destroyAndWait().catch(() => {});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -63,4 +63,13 @@ describe('allowOption', () => {
|
|
|
63
63
|
expect(allowOption([{ optionId: 'deny', kind: 'reject_once' }])).toBeNull();
|
|
64
64
|
expect(allowOption([])).toBeNull();
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
test('a GRANTED call asks for the standing option first', () => {
|
|
68
|
+
expect(
|
|
69
|
+
allowOption([
|
|
70
|
+
{ optionId: 'once', kind: 'allow_once' },
|
|
71
|
+
{ optionId: 'always', kind: 'allow_always' },
|
|
72
|
+
], 'always'),
|
|
73
|
+
).toBe('always');
|
|
74
|
+
});
|
|
66
75
|
});
|