@kabmo-labs/kabmo 0.43.0 → 0.44.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 +614 -605
- package/dist/client/static/js/{CsvGrid-3fr85032.js → CsvGrid-1t2q46rg.js} +2 -2
- package/dist/client/static/js/{DocxView-pqbp2fpd.js → DocxView-301hxnwk.js} +4 -4
- package/dist/client/static/js/{DrawioView-m0vecq1m.js → DrawioView-47bwea5t.js} +2 -2
- package/dist/client/static/js/ImageView-68zdx5ex.js +1 -0
- package/dist/client/static/js/LayoutWrapper-vw54s8ra.js +2 -0
- package/dist/client/static/js/{Modal-vnwg4xn3.js → Modal-fb9b4gq6.js} +18 -18
- package/dist/client/static/js/{PdfView-wmg0vk2p.js → PdfView-m64ksepp.js} +1 -1
- package/dist/client/static/js/SessionsView-zyjwhpzm.js +1 -0
- package/dist/client/static/js/{SheetView-rg5gkcd7.js → SheetView-e88sqprx.js} +13 -13
- package/dist/client/static/js/{SvgPreview-wpb7b0ez.js → SvgPreview-hs9a713t.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-4pxqt66j.js → abnfDiagram-O67JEVCF-fnr5kyqk.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-mq93vqx9.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-kwt1va5y.js → architectureDiagram-NJMV4G6O-7v003363.js} +11 -11
- package/dist/client/static/js/{astro-dpfdhc5e.js → astro-t9vjc0mc.js} +1 -1
- package/dist/client/static/js/bash-fjzhxy10.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-hbj5v7n7.js → blockDiagram-BEXU5L5S-k4mwbw3d.js} +5 -5
- package/dist/client/static/js/c-y1y6v00q.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-epfzh8dw.js → c4Diagram-YGBWAQC7-688zq6f4.js} +6 -6
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-kbks4qgz.js → classDiagram-v2-NBCMYWYE-h0s16pxr.js} +5 -5
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-dvdmckrf.js → cose-bilkent-JH36ORCC-qb2t8qq5.js} +1 -1
- package/dist/client/static/js/cpp-9f6zkdd4.js +1 -0
- package/dist/client/static/js/css-g85rwzty.js +1 -0
- package/dist/client/static/js/css-y4y3qtsb.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-qyg5rjr5.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-r084stj5.js → cynefinDiagram-VND7K2PF-syhtcr7b.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-64qc51n1.js → dagre-6A5THRUB-7wgbx6cm.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-70qtb1rm.js → diagram-22UHCM2B-951cmp5h.js} +21 -21
- package/dist/client/static/js/{diagram-3UASUU5V-dgkvnsme.js → diagram-3UASUU5V-mvdbqt7b.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-rnpsp26v.js → diagram-ATOU4E4O-hkvdtgdm.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-26hthh60.js → diagram-CDSNMT55-bkkz35ca.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-nc1s85r5.js → diagram-MLGK6HIB-z6pcrkc3.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-e4dckqhv.js → diagram-MPIPVDR6-mkwf8j4m.js} +1 -1
- package/dist/client/static/js/{dockerfile-rxtyyhr1.js → dockerfile-7gd570bm.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-3w9h8qk7.js → ebnfDiagram-ZINNZB2B-trym26ts.js} +1 -1
- package/dist/client/static/js/{elixir-5ewfhvfh.js → elixir-z77c7tfn.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-httpkyb1.js → elk-276RUBZZ-gkhz67v6.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-3qhvf7se.js → erDiagram-OPXOYQCR-gkyr5cqs.js} +7 -7
- package/dist/client/static/js/{erlang-jqqa3ehb.js → erlang-6vrvh2m6.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-15yz245z.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-n1sapfye.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-t53m50e5.js → ganttDiagram-FUAMR5RP-1qpme6ks.js} +4 -4
- package/dist/client/static/js/gitGraph-4MIJSDKK-xtjwv160.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-b5wn9eht.js → gitGraphDiagram-X574FWY7-wbg3kqak.js} +10 -10
- package/dist/client/static/js/graphql-amk52c95.js +1 -0
- package/dist/client/static/js/html-2y935m7r.js +1 -0
- package/dist/client/static/js/index-07yh7qx0.js +1 -0
- package/dist/client/static/js/{index-kccp6tgd.js → index-1923aj4g.js} +2 -2
- package/dist/client/static/js/{index-kmzd0adv.js → index-19ffgf9a.js} +1 -1
- package/dist/client/static/js/index-204ae4vs.js +2 -0
- package/dist/client/static/js/{index-cqnpsw2m.js → index-22whvfdw.js} +2 -2
- package/dist/client/static/js/{index-dg3b0mfk.js → index-232nsp2c.js} +2 -2
- package/dist/client/static/js/{index-fgyenbv8.js → index-31hntzse.js} +5 -5
- package/dist/client/static/js/{index-7zc1z9z9.js → index-3w845q50.js} +4 -4
- package/dist/client/static/js/{index-gmnmnfm0.js → index-4y4hshcx.js} +2 -2
- package/dist/client/static/js/index-53ysgsd2.js +1 -0
- package/dist/client/static/js/{index-g4rsmakg.js → index-62ng8tkj.js} +3 -3
- package/dist/client/static/js/{index-4banz7gr.js → index-6ah5sj5y.js} +1 -1
- package/dist/client/static/js/{index-tzbzehqd.js → index-6gyk52ff.js} +2 -2
- package/dist/client/static/js/{index-m9s9rg5k.js → index-6s4mrdew.js} +2 -2
- package/dist/client/static/js/index-6t21c6jt.js +2 -0
- package/dist/client/static/js/{index-7dp90ad1.js → index-83pwa9c0.js} +2 -2
- package/dist/client/static/js/{index-f4fqvct6.js → index-8trggh1z.js} +15 -15
- package/dist/client/static/js/{index-ys0xpw3q.js → index-92n96mgd.js} +2 -2
- package/dist/client/static/js/index-ad4x44d6.js +9 -0
- package/dist/client/static/js/{index-s78n0dtv.js → index-as1wptfa.js} +2 -2
- package/dist/client/static/js/{index-j17h4z6f.js → index-barbpakv.js} +2 -2
- package/dist/client/static/js/index-bjqz7swa.js +1 -0
- package/dist/client/static/js/{index-yvgbr7ek.js → index-c3v62nvt.js} +2 -2
- package/dist/client/static/js/{index-zqthmaxq.js → index-cq98p2rb.js} +200 -199
- package/dist/client/static/js/{index-q1gwgmxt.js → index-czedkbmb.js} +2 -2
- package/dist/client/static/js/{index-sesghshh.js → index-dmv2zasz.js} +2 -2
- package/dist/client/static/js/{index-ycks7gyg.js → index-e6rm5xzj.js} +2 -2
- package/dist/client/static/js/{index-2q23dwrs.js → index-ehacfgwm.js} +2 -2
- package/dist/client/static/js/{index-q81rxwh7.js → index-fbpc1wx6.js} +41 -41
- package/dist/client/static/js/{index-qhytrsyb.js → index-fj4k07zt.js} +2 -2
- package/dist/client/static/js/{index-jz93j0at.js → index-gtkhz0hj.js} +2 -2
- package/dist/client/static/js/{index-181p91hf.js → index-hfsvwfgw.js} +2 -2
- package/dist/client/static/js/{index-sk9ej289.js → index-jaqjvk22.js} +2 -2
- package/dist/client/static/js/{index-e7yf273s.js → index-jbkkwa2q.js} +2 -2
- package/dist/client/static/js/{index-38v0781h.js → index-ks23y2cd.js} +2 -2
- package/dist/client/static/js/{index-7z9tz4ze.js → index-kwpaz891.js} +2 -2
- package/dist/client/static/js/{index-0c6vpk89.js → index-n0matkz9.js} +2 -2
- package/dist/client/static/js/index-n6fbd265.js +1 -0
- package/dist/client/static/js/{index-rv4qs3wm.js → index-nqjd3hh5.js} +2 -2
- package/dist/client/static/js/{index-ynaxep06.js → index-nr8s5xm9.js} +2 -2
- package/dist/client/static/js/index-nvevymac.js +2 -0
- package/dist/client/static/js/index-pxm44qfd.js +1 -0
- package/dist/client/static/js/{index-fg965t62.js → index-pysqpc5n.js} +2 -2
- package/dist/client/static/js/index-qf9x7yet.js +1 -0
- package/dist/client/static/js/{index-dkqgmacr.js → index-qkjx6521.js} +4 -4
- package/dist/client/static/js/index-qm92sf9w.js +12 -0
- package/dist/client/static/js/{index-fjnkzk12.js → index-qsw5edtk.js} +5 -5
- package/dist/client/static/js/index-rpzxrr2d.js +1 -0
- package/dist/client/static/js/index-s8bktzpg.js +1 -0
- package/dist/client/static/js/index-sc7r305t.css +1 -0
- package/dist/client/static/js/{index-vmgzhp41.js → index-svmzgtcx.js} +2 -2
- package/dist/client/static/js/{index-k9ws464d.js → index-tr2pkfs6.js} +2 -2
- package/dist/client/static/js/{index-bvjct7sp.js → index-tzdm1y3z.js} +2 -2
- package/dist/client/static/js/{index-r11bbnek.js → index-v5npdwy2.js} +65 -65
- package/dist/client/static/js/{index-wmv3crye.js → index-v7bcgh77.js} +2 -2
- package/dist/client/static/js/index-wytdbvax.js +3 -0
- package/dist/client/static/js/{index-n9scbxy5.js → index-yfjvx4yf.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-e31s2xvj.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-qv7438m3.js → infoDiagram-VRGFBTTK-yebngg8c.js} +1 -1
- package/dist/client/static/js/ini-kemnmt16.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-p1w6zg5y.js → ishikawaDiagram-OU5B5YK6-kh4nqj6q.js} +3 -3
- package/dist/client/static/js/java-caqpfm88.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-ywk6xqxr.js → journeyDiagram-ZHPQQLJL-4khnf8x1.js} +5 -5
- package/dist/client/static/js/json-qn73s8xb.js +1 -0
- package/dist/client/static/js/jsx-bvterpm5.js +1 -0
- package/dist/client/static/js/{julia-0h9krgsd.js → julia-svwxx41e.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-gtrmhggc.js → kanban-definition-PNTS6WVX-snmq3wq4.js} +4 -4
- package/dist/client/static/js/lua-1hcfm8ya.js +1 -0
- package/dist/client/static/js/markdown-n6na4ykv.js +1 -0
- package/dist/client/static/js/{mermaid.core-5s24b4hh.js → mermaid.core-yctw30sk.js} +7 -7
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-3wx7abqn.js → mindmap-definition-NLK3R4M7-atfv66wq.js} +3 -3
- package/dist/client/static/js/one-dark-pro-c1vnxka7.js +1 -0
- package/dist/client/static/js/one-light-mbxx52p5.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-mtzmsrk4.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-yvyqnjya.js → pegDiagram-GJSIUBJH-hpbtxjht.js} +1 -1
- package/dist/client/static/js/{perl-rptyx23q.js → perl-mr0ds2ex.js} +1 -1
- package/dist/client/static/js/{php-sagvq3wz.js → php-5h3wt6tv.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-85nwadmj.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-26x6pj38.js → pieDiagram-5QR66LMP-9zrtkdr2.js} +2 -2
- package/dist/client/static/js/properties-nxcks67c.js +1 -0
- package/dist/client/static/js/python-58p0gqn0.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-qhe8h0j9.js → quadrantDiagram-O4NWA36T-xq970vx1.js} +6 -6
- package/dist/client/static/js/r-eyn8en0g.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-ae3jdajx.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-3m0s7cse.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-pz22c3eb.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-cgqgqq15.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-ts0nmcxb.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-dwy3k2jx.js → railroadDiagram-XR7U4H2S-1g9jchbk.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-hcmgfesg.js → requirementDiagram-PLB6GJNP-ntt088y4.js} +4 -4
- package/dist/client/static/js/{ruby-9qyx7knh.js → ruby-nn836rtq.js} +1 -1
- package/dist/client/static/js/{rust-bmb4ee5w.js → rust-eygk56y5.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s6d3k4zs.js → sankeyDiagram-IPEJSGJF-95k8c5v6.js} +5 -5
- package/dist/client/static/js/{sass-07rteya0.js → sass-c2bk03e4.js} +1 -1
- package/dist/client/static/js/{scss-e2dndbfa.js → scss-qycakpjn.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-0fcmzgdy.js → sequenceDiagram-PO4LG4MO-qfvxrwfa.js} +19 -19
- package/dist/client/static/js/{sizeCapture-INFHLROL-t8fcm7rq.js → sizeCapture-INFHLROL-0m7dc5nd.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-jr80hfeg.js → stateDiagram-v2-GCMORJYK-femwcn7n.js} +5 -5
- package/dist/client/static/js/{svelte-w365cpwa.js → svelte-bfy1rq5g.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-x1ay6w39.js → swimlanes-2SLR337P-5n1qq48r.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-n85hawg8.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-qz0g6msb.js → timeline-definition-EJHVYXUP-vdsj18be.js} +7 -7
- package/dist/client/static/js/treeView-Q6P3EWNA-fvpt3hm8.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-4z9s24je.js +1 -0
- package/dist/client/static/js/tsx-fnzxsv25.js +1 -0
- package/dist/client/static/js/typescript-0ppbqrb6.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-sxzrv8ht.js → usecaseDiagram-POWQR4AR-psjbrprk.js} +43 -43
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-qsqgnjcv.js → vennDiagram-UO4OBE2U-4yn9kac9.js} +7 -7
- package/dist/client/static/js/{vue-d6cesny1.js → vue-0fwtgwj4.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-73mrhkmy.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-rvwxn458.js → wardleyDiagram-VNRHLVJA-js0tbpca.js} +3 -3
- package/dist/client/static/js/xml-v1ytr8qz.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-nb4w7rcg.js → xychartDiagram-PMCCYNJV-svr38ygh.js} +5 -5
- package/dist/client/static/js/yaml-txrqz62t.js +1 -0
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/proc/identity.ts +4 -3
- package/package.json +2 -2
- package/src/client/App.tsx +1 -1
- package/src/client/borders.css +143 -0
- package/src/client/components/common/context-usage-button/Ring.tsx +34 -9
- package/src/client/components/common/context-usage-button/index.test.tsx +19 -2
- package/src/client/components/common/context-usage-button/index.tsx +4 -4
- package/src/client/components/common/header-controls/index.test.tsx +26 -59
- package/src/client/components/common/header-controls/index.tsx +41 -52
- package/src/client/components/common/header-controls/phone-row.test.tsx +265 -0
- package/src/client/components/common/header-controls/plugin-entry.test.tsx +25 -3
- package/src/client/components/common/header-controls/shell-chrome.test.tsx +2 -2
- package/src/client/components/layout/LeftDock.tsx +7 -0
- package/src/client/components/layout/desktop-layout/DesktopOverlays.tsx +51 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +117 -15
- package/src/client/components/layout/desktop-layout/RightColumn.tsx +257 -0
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +23 -24
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +50 -78
- package/src/client/components/layout/desktop-layout/index.tsx +73 -73
- package/src/client/components/layout/session-sidebar/Footer.test.tsx +20 -0
- package/src/client/components/layout/session-sidebar/Footer.tsx +24 -2
- package/src/client/components/layout/session-sidebar/Header.test.ts +10 -0
- package/src/client/components/layout/session-sidebar/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-main-view/Header.test.tsx +2 -3
- package/src/client/components/mobile/mobile-main-view/Header.tsx +12 -10
- package/src/client/components/settings/Modal.tsx +14 -9
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +18 -6
- package/src/client/components/settings/SettingsSidebarList.tsx +2 -1
- package/src/client/components/settings/Sidebar.tsx +6 -4
- package/src/client/components/settings/apply-side-effects.test.ts +17 -0
- package/src/client/components/settings/apply-side-effects.ts +26 -5
- package/src/client/components/settings/band-height.test.tsx +122 -0
- package/src/client/components/settings/categories/AppearanceSettings.test.tsx +144 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +81 -39
- package/src/client/components/settings/categories/ChatSettings.tsx +9 -15
- package/src/client/components/settings/categories/UsageSettings.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/BorderStyleSection.test.tsx +101 -0
- package/src/client/components/settings/categories/appearance-settings/BorderStyleSection.tsx +134 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/EditorFontSection.tsx +5 -5
- package/src/client/components/settings/categories/appearance-settings/EditorIndentSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +6 -6
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/PanelNavSection.tsx +167 -0
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/ThemeSection.tsx +42 -0
- package/src/client/components/settings/categories/appearance-settings/TrayIconSection.tsx +2 -2
- package/src/client/components/settings/categories/appearance-settings/groups.test.ts +47 -0
- package/src/client/components/settings/categories/appearance-settings/groups.ts +95 -0
- package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +31 -14
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/SidebarList.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +2 -1
- package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +2 -1
- package/src/client/components/settings/master-detail/GroupDetail.tsx +38 -0
- package/src/client/components/settings/{categories/chat-settings/SidebarList.tsx → master-detail/GroupSidebar.tsx} +35 -12
- package/src/client/components/settings/master-detail/index.tsx +3 -1
- package/src/client/components/settings/pane-header.ts +25 -0
- package/src/client/components/workspace/browser-toolbar/index.test.tsx +39 -1
- package/src/client/components/workspace/browser-toolbar/index.tsx +53 -17
- package/src/client/components/workspace/chat-timeline/ColumnResizeHandle.tsx +107 -0
- package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +9 -3
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +35 -26
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +6 -0
- package/src/client/components/workspace/chat-timeline/column-resize.test.tsx +292 -0
- package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +5 -3
- 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/TaskResult.tsx +18 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +47 -0
- package/src/client/components/workspace/context-panel/index.tsx +10 -4
- package/src/client/components/workspace/editor/EditorHideButton.tsx +41 -0
- package/src/client/components/workspace/editor/EmptyEditor.tsx +11 -2
- package/src/client/components/workspace/editor/PluginColumn.tsx +11 -1
- package/src/client/components/workspace/editor/Tabs.tsx +8 -0
- package/src/client/components/workspace/editor/editor-hide-button.test.ts +144 -0
- package/src/client/components/workspace/editor/index.tsx +8 -2
- package/src/client/components/workspace/editor/props.ts +9 -0
- package/src/client/components/workspace/file-explorer/RowLabel.test.tsx +90 -0
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +1 -4
- package/src/client/components/workspace/git-panel/commit-modal/CommitRow.test.ts +52 -46
- package/src/client/components/workspace/git-panel/commit-modal/CommitRow.tsx +41 -21
- package/src/client/components/workspace/git-panel/commit-modal/GraphCanvas.tsx +6 -5
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +19 -22
- package/src/client/components/workspace/panel-header/title-policy.test.tsx +62 -0
- package/src/client/components/workspace/panel-header/title-policy.tsx +83 -0
- package/src/client/components/workspace/panel-tabs/Home.density.test.tsx +122 -0
- package/src/client/components/workspace/panel-tabs/Home.test.tsx +137 -0
- package/src/client/components/workspace/panel-tabs/Home.tsx +106 -0
- package/src/client/components/workspace/panel-tabs/TabStrip.test.tsx +221 -0
- package/src/client/components/workspace/panel-tabs/TabStrip.tsx +315 -0
- package/src/client/components/workspace/panel-tabs/index.tsx +97 -0
- package/src/client/components/workspace/panels/builtin.tsx +9 -0
- package/src/client/components/workspace/plan-panel/index.tsx +7 -2
- package/src/client/components/workspace/repo-picker/Modal.tsx +1 -1
- package/src/client/components/workspace/repo-picker/index.test.tsx +32 -8
- package/src/client/components/workspace/repo-picker/index.tsx +2 -2
- package/src/client/components/workspace/search-panel/Body.tsx +7 -1
- package/src/client/components/workspace/search-panel/index.tsx +2 -1
- package/src/client/components/workspace/terminal-panel/Header.tsx +10 -3
- package/src/client/components/workspace/terminal-panel/index.tsx +4 -1
- package/src/client/components/workspace/todo-panel/index.tsx +6 -1
- package/src/client/components/workspace/usage-panel/index.tsx +7 -2
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +43 -4
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +101 -45
- package/src/client/components/workspace/user-browser-panel/TabStrip.tsx +107 -0
- package/src/client/components/workspace/user-browser-panel/index.tsx +31 -6
- package/src/client/glass.test.ts +1 -1
- package/src/client/hooks/browser/use-annotate.ts +6 -5
- package/src/client/hooks/browser/use-user-browser.test.tsx +279 -0
- package/src/client/hooks/browser/use-user-browser.ts +190 -44
- package/src/client/hooks/chat/omp/index.ts +2 -6
- package/src/client/hooks/chat/timeline/column-drag.ts +171 -0
- package/src/client/hooks/chat/timeline/width-mode.test.ts +112 -11
- package/src/client/hooks/chat/timeline/width-mode.ts +91 -18
- package/src/client/hooks/ui/border-style.test.ts +172 -0
- package/src/client/hooks/ui/border-style.ts +60 -0
- package/src/client/hooks/ui/navbar-controls.test.ts +27 -1
- package/src/client/hooks/ui/navbar-controls.ts +95 -20
- package/src/client/hooks/ui/style-attributes.test.ts +2 -0
- package/src/client/hooks/workspace/active-project.ts +46 -0
- package/src/client/hooks/workspace/commit-expansion.test.ts +135 -0
- package/src/client/hooks/workspace/commit-expansion.ts +56 -0
- package/src/client/hooks/workspace/panel-nav.test.ts +102 -0
- package/src/client/hooks/workspace/panel-nav.ts +95 -0
- package/src/client/hooks/workspace/panel-tabs.session.test.tsx +235 -0
- package/src/client/hooks/workspace/panel-tabs.ts +194 -0
- package/src/client/hooks/workspace/right-open-request.ts +53 -0
- package/src/client/hooks/workspace/right-side.test.ts +204 -0
- package/src/client/hooks/workspace/right-side.ts +142 -0
- package/src/client/main.tsx +9 -4
- package/src/client/tailwind.css +6 -0
- package/src/server/lib/assets/shell-attributes.server.ts +26 -10
- package/src/server/lib/assets/shell-attributes.test.ts +26 -0
- 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/db/schema.ts +3 -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 +154 -0
- package/src/server/lib/harness/acp/background-replay.ts +92 -0
- package/src/server/lib/harness/acp/background-work.ts +80 -50
- 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/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/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 +128 -53
- 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 +15 -3
- package/src/server/lib/harness/acp/session-wiring.test.ts +53 -0
- package/src/server/lib/harness/acp/session-wiring.ts +109 -0
- package/src/server/lib/harness/acp/session.test-util.ts +34 -2
- package/src/server/lib/harness/acp/session.test.ts +10 -10
- package/src/server/lib/harness/acp/session.ts +146 -144
- 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/session-lease.server.ts +3 -2
- package/src/server/lib/omp/session/delete.server.ts +3 -0
- package/src/server/lib/omp/session/lease-probe.server.test.ts +82 -0
- package/src/server/lib/omp/session/lease-probe.server.ts +180 -0
- package/src/server/lib/omp/session/ownership.server.test.ts +17 -6
- package/src/server/lib/omp/session/ownership.server.ts +7 -5
- package/src/server/plugins/ssr.ts +6 -3
- package/src/shared/lib/browser/user-tabs.test.ts +165 -0
- package/src/shared/lib/browser/user-tabs.ts +172 -0
- package/src/shared/lib/chat/timeline/width-mode.test.ts +34 -2
- package/src/shared/lib/chat/timeline/width-mode.ts +71 -22
- package/src/shared/lib/commands/catalog.ts +2 -2
- package/src/shared/lib/fs/git-status.test.ts +23 -0
- package/src/shared/lib/fs/git-status.ts +15 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +20 -20
- package/src/shared/lib/settings/defaults.ts +7 -1
- package/src/shared/lib/theme/border-style.test.ts +83 -0
- package/src/shared/lib/theme/border-style.ts +122 -0
- package/src/shared/lib/workspace/keymap.ts +2 -1
- package/src/shared/lib/workspace/panel-nav.test.ts +162 -0
- package/src/shared/lib/workspace/panel-nav.ts +105 -0
- package/src/shared/lib/workspace/panel-tabs-close.test.ts +154 -0
- package/src/shared/lib/workspace/panel-tabs.ts +105 -0
- package/src/shared/lib/workspace/session-state/cache.ts +22 -0
- package/src/shared/lib/workspace/session-state/merge.ts +6 -0
- package/src/shared/lib/workspace/session-state/store.ts +23 -0
- package/src/shared/types/omp/agent.ts +14 -5
- package/src/shared/types/settings/state.ts +50 -3
- package/src/test-support/header-controls-harness.ts +22 -0
- package/src/test-support/peer-harness.ts +2 -2
- package/dist/client/static/js/ImageView-rbejbjwg.js +0 -1
- package/dist/client/static/js/LayoutWrapper-mxfsqh57.js +0 -2
- package/dist/client/static/js/SessionsView-90z2t4qe.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-7j23x20s.js +0 -1
- package/dist/client/static/js/bash-vv2ysp0a.js +0 -1
- package/dist/client/static/js/c-8jf64j6h.js +0 -1
- package/dist/client/static/js/cpp-vh94zee0.js +0 -1
- package/dist/client/static/js/css-a13jmmnc.js +0 -1
- package/dist/client/static/js/css-p57h1fme.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-me5xnx6a.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-5zbvjj84.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-1jat076e.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-tjhkv71w.js +0 -1
- package/dist/client/static/js/graphql-kesh8gk0.js +0 -1
- package/dist/client/static/js/html-sxpfydga.js +0 -1
- package/dist/client/static/js/index-1dwdgp27.js +0 -1
- package/dist/client/static/js/index-8y51kgan.js +0 -3
- package/dist/client/static/js/index-axszsg7a.js +0 -1
- package/dist/client/static/js/index-d8r84zjd.js +0 -12
- package/dist/client/static/js/index-egd0vfey.js +0 -1
- package/dist/client/static/js/index-enb6chty.js +0 -1
- package/dist/client/static/js/index-g3a9j9hf.js +0 -1
- package/dist/client/static/js/index-gwqb7m8g.js +0 -1
- package/dist/client/static/js/index-j60gtvw8.js +0 -1
- package/dist/client/static/js/index-jvs2fvqz.js +0 -2
- package/dist/client/static/js/index-kc3c2gzb.js +0 -1
- package/dist/client/static/js/index-ksph3kpr.js +0 -2
- package/dist/client/static/js/index-qzw4jnnv.js +0 -1
- package/dist/client/static/js/index-tnv3dryk.js +0 -9
- package/dist/client/static/js/index-vcrh95gf.css +0 -1
- package/dist/client/static/js/info-A6RAGUB7-m6qz24p8.js +0 -1
- package/dist/client/static/js/ini-1x0ad976.js +0 -1
- package/dist/client/static/js/java-3944nq02.js +0 -1
- package/dist/client/static/js/json-g5ggnd94.js +0 -1
- package/dist/client/static/js/jsx-f6p72qpc.js +0 -1
- package/dist/client/static/js/lua-edn2b3wn.js +0 -1
- package/dist/client/static/js/markdown-9dhg1fax.js +0 -1
- package/dist/client/static/js/one-dark-pro-3vya9z02.js +0 -1
- package/dist/client/static/js/one-light-1yrwn9my.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-ng6wq5xj.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-rf6jhxf6.js +0 -1
- package/dist/client/static/js/properties-fcmj08pv.js +0 -1
- package/dist/client/static/js/python-532d8ezm.js +0 -1
- package/dist/client/static/js/r-ptmdxs2a.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-ygp6hxq4.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-rxgnrb2g.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-xkv52a2p.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-bvcktbqh.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-9c3v7jsq.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xj123xrp.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-fb58a7z1.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-ej4qhksx.js +0 -1
- package/dist/client/static/js/tsx-zfy727zs.js +0 -1
- package/dist/client/static/js/typescript-683kkkaw.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-mkp0kanv.js +0 -1
- package/dist/client/static/js/xml-6ct32gys.js +0 -1
- package/dist/client/static/js/yaml-1d5m3bfj.js +0 -1
- package/src/server/lib/omp/session/lease-flock.server.ts +0 -117
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The two verdicts a CLOSED assistant message supplies when a turn ends, split
|
|
8
|
+
* out of `turn.ts` so that file stays inside the size ceiling.
|
|
9
|
+
*
|
|
10
|
+
* Both are about what the agent actually sent, not about the envelope's
|
|
11
|
+
* `stopReason`: an agent records the provider's failure on the message, and a
|
|
12
|
+
* message whose blocks render nothing is the same operator-visible failure as no
|
|
13
|
+
* message at all.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { deriveTurnError } from '@/shared/lib/omp/session/turn-error';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The reason the CLOSED message names, when it named one.
|
|
20
|
+
*
|
|
21
|
+
* The same rule as omp's: an agent records `stopReason` / `errorMessage` flat on
|
|
22
|
+
* the assistant message, and reading only the envelope's stop reason threw the
|
|
23
|
+
* provider's own words away — a coordinator was told "the agent ended the turn
|
|
24
|
+
* with an error" over a transcript that said which.
|
|
25
|
+
*/
|
|
26
|
+
export function closedFailure(message: unknown): string | null {
|
|
27
|
+
if (!message || typeof message !== 'object' || Array.isArray(message)) return null;
|
|
28
|
+
const error = deriveTurnError(message as Record<string, unknown>);
|
|
29
|
+
return error?.message?.trim() || null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Does the closed message carry anything the timeline draws? A whitespace-only
|
|
33
|
+
* chunk (or one that carried only an empty text block) opens a message row
|
|
34
|
+
* that renders nothing, which is the same operator-visible failure as no frame
|
|
35
|
+
* at all. Thinking and tool calls are content: they render as their own
|
|
36
|
+
* blocks. */
|
|
37
|
+
export function hasRenderableAnswer(message: unknown): boolean {
|
|
38
|
+
if (!message || typeof message !== 'object' || !('content' in message)) return false;
|
|
39
|
+
const content = message.content;
|
|
40
|
+
if (!Array.isArray(content)) return false;
|
|
41
|
+
return content.some((block) => {
|
|
42
|
+
if (!block || typeof block !== 'object') return false;
|
|
43
|
+
if ('text' in block && typeof block.text === 'string') return block.text.trim().length > 0;
|
|
44
|
+
if ('thinking' in block && typeof block.thinking === 'string') return block.thinking.trim().length > 0;
|
|
45
|
+
return 'type' in block && block.type === 'toolCall';
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** What one finished turn reports as its outcome. */
|
|
50
|
+
export interface TurnVerdict {
|
|
51
|
+
failed: boolean;
|
|
52
|
+
cancelled: boolean;
|
|
53
|
+
reason: string | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The verdict for a closed turn.
|
|
57
|
+
*
|
|
58
|
+
* A prompt that ends with no message and no tool call is a SILENT failure on
|
|
59
|
+
* most agents (measured on pi-acp: it answers `session/prompt` with `{}` and
|
|
60
|
+
* sends no frames when its provider call fails). Whitespace-only chunks are the
|
|
61
|
+
* same failure with a frame attached. Slash commands are exempt — an extension
|
|
62
|
+
* command is answered locally and correctly produces nothing — and a user's Stop
|
|
63
|
+
* is not a failure either.
|
|
64
|
+
*
|
|
65
|
+
* `stopReason: 'error'` is a failure even when the agent DID send a partial
|
|
66
|
+
* message: a v1 agent answers `{stopReason:'error'}` with whatever it streamed,
|
|
67
|
+
* and reading only "did it answer" told a coordinator its failed worker had
|
|
68
|
+
* finished. v2 cannot infer failure from an idle without a stop reason, so the
|
|
69
|
+
* silent-turn rule is gated to `completion === 'response'`. */
|
|
70
|
+
export function turnVerdict(args: {
|
|
71
|
+
closed: unknown;
|
|
72
|
+
abandoned: number;
|
|
73
|
+
result: { stopReason?: string } | undefined;
|
|
74
|
+
reported: boolean;
|
|
75
|
+
stranded: boolean;
|
|
76
|
+
/** The prompt text, to exempt slash commands. */
|
|
77
|
+
promptText: string;
|
|
78
|
+
completion: 'response' | 'state';
|
|
79
|
+
strandedReason: string;
|
|
80
|
+
/** A reason the caller already knows and reported. */
|
|
81
|
+
failure?: string;
|
|
82
|
+
}): TurnVerdict {
|
|
83
|
+
const answered = hasRenderableAnswer(args.closed) || args.abandoned > 0;
|
|
84
|
+
const cancelled = args.result?.stopReason === 'cancelled';
|
|
85
|
+
const slash = args.promptText.trimStart().startsWith('/');
|
|
86
|
+
const failed = !cancelled && !slash
|
|
87
|
+
&& (args.stranded || args.reported || args.result?.stopReason === 'error' || (args.completion === 'response' && !answered));
|
|
88
|
+
const reason = failed
|
|
89
|
+
? (args.failure ?? (args.stranded
|
|
90
|
+
? args.strandedReason
|
|
91
|
+
: closedFailure(args.closed) ?? (args.result?.stopReason === 'error'
|
|
92
|
+
? 'The agent ended the turn with an error'
|
|
93
|
+
: 'The agent ended the turn without sending an answer')))
|
|
94
|
+
: null;
|
|
95
|
+
return { failed, cancelled, reason };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A slash command is answered locally and correctly produces nothing, so the
|
|
99
|
+
* silent-turn verdict never applies to one. */
|
|
100
|
+
export function reasonSuppressed(promptText: string): boolean {
|
|
101
|
+
return promptText.trimStart().startsWith('/');
|
|
102
|
+
}
|
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* The life of an ACP turn: one prompt, its frames, and how it ends.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* each to learn, and a session that also owns spawning, config selectors and
|
|
11
|
-
* client requests buried them:
|
|
9
|
+
* Three rules, each a bug that had to be learned:
|
|
12
10
|
*
|
|
13
11
|
* - **a prompt is CHAINED, never raced.** ACP has no queue: a second
|
|
14
12
|
* `session/prompt` while one is open CANCELS the first (measured, twice).
|
|
@@ -22,7 +20,10 @@ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
|
22
20
|
import { AcpRequestError } from '@/server/lib/harness/acp/calls';
|
|
23
21
|
import { turnEndFrame } from '@/server/lib/harness/acp/frames';
|
|
24
22
|
import { TurnSilence } from '@/server/lib/harness/acp/turn-silence';
|
|
25
|
-
import {
|
|
23
|
+
import { CancelSettle } from '@/server/lib/harness/acp/turn-cancel';
|
|
24
|
+
import { TurnQueue } from '@/server/lib/harness/acp/turn-queue';
|
|
25
|
+
import { promptWithBusyRetry, SESSION_BUSY_WAIT_MS } from '@/server/lib/harness/acp/turn-dispatch';
|
|
26
|
+
import { reasonSuppressed, turnVerdict } from '@/server/lib/harness/acp/turn-verdict';
|
|
26
27
|
|
|
27
28
|
const STRANDED_REASON = 'The agent stopped reporting progress; the turn was closed after a long silence.';
|
|
28
29
|
|
|
@@ -83,9 +84,16 @@ export class AcpTurns {
|
|
|
83
84
|
private awaitingCancellation = false;
|
|
84
85
|
/** The silence ceiling for the open turn — see `turn-silence.ts`. */
|
|
85
86
|
readonly #silence: TurnSilence;
|
|
87
|
+
/** Settles the prompt after a cancel the agent never answered. */
|
|
88
|
+
readonly #cancelSettle: CancelSettle;
|
|
89
|
+
/** Inputs held for an agent with no mid-turn channel. */
|
|
90
|
+
readonly #queue = new TurnQueue();
|
|
91
|
+
readonly #busyWaitMs: number;
|
|
86
92
|
|
|
87
|
-
constructor(private readonly seams: AcpTurnSeams, options: { silenceMs?: number } = {}) {
|
|
93
|
+
constructor(private readonly seams: AcpTurnSeams, options: { silenceMs?: number; busyWaitMs?: number } = {}) {
|
|
88
94
|
this.#silence = new TurnSilence(() => this.strand(), options.silenceMs);
|
|
95
|
+
this.#cancelSettle = new CancelSettle(() => this.seams.abandonPrompt());
|
|
96
|
+
this.#busyWaitMs = options.busyWaitMs ?? SESSION_BUSY_WAIT_MS;
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
/** Any frame from the agent defers the silence ceiling. */
|
|
@@ -111,6 +119,9 @@ export class AcpTurns {
|
|
|
111
119
|
}
|
|
112
120
|
this.seq += 1;
|
|
113
121
|
const turnId = this.seq;
|
|
122
|
+
// A new prompt IS the decision that a cancelled turn is over: free the chain
|
|
123
|
+
// now rather than waiting out the grace window.
|
|
124
|
+
this.#cancelSettle.flush();
|
|
114
125
|
this.promptText = message;
|
|
115
126
|
this.awaitingCancellation = false;
|
|
116
127
|
this.isPromptRunning = true;
|
|
@@ -122,9 +133,18 @@ export class AcpTurns {
|
|
|
122
133
|
const request = (this.request ?? Promise.resolve())
|
|
123
134
|
.catch(() => undefined)
|
|
124
135
|
.then(() => {
|
|
136
|
+
// Stop pressed while this turn queued behind the previous prompt: the
|
|
137
|
+
// flags were cleared, so the prompt must never reach the agent.
|
|
138
|
+
if (!this.isPromptRunning || !this.isStreaming) return undefined;
|
|
125
139
|
this.open = turnId;
|
|
126
140
|
this.seams.resetMapper();
|
|
127
|
-
|
|
141
|
+
// `-32003 session_busy` is the agent still finishing its previous turn,
|
|
142
|
+
// not a failure: wait for it instead of reporting an error the operator
|
|
143
|
+
// can only work around by waiting.
|
|
144
|
+
return promptWithBusyRetry(() => this.seams.prompt(message, images), {
|
|
145
|
+
waitMs: this.#busyWaitMs,
|
|
146
|
+
isActive: () => this.open === turnId && this.isPromptRunning,
|
|
147
|
+
});
|
|
128
148
|
});
|
|
129
149
|
this.request = request;
|
|
130
150
|
void request
|
|
@@ -158,30 +178,60 @@ export class AcpTurns {
|
|
|
158
178
|
return { agentInvoked: true };
|
|
159
179
|
}
|
|
160
180
|
|
|
161
|
-
/**
|
|
162
|
-
* Stop the turn AND close it here.
|
|
181
|
+
/** Stop the turn AND close it here.
|
|
163
182
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* turn is chained behind.
|
|
169
|
-
*/
|
|
183
|
+
* Nothing guarantees the agent answers the cancel, and a session whose agent
|
|
184
|
+
* never does stays `isStreaming` forever — the NEXT prompt is refused as
|
|
185
|
+
* "already processing". The outstanding prompt is settled after a grace
|
|
186
|
+
* window for the same reason: it is what the next turn is chained behind. */
|
|
170
187
|
cancel(): void {
|
|
171
188
|
this.awaitingCancellation = true;
|
|
189
|
+
this.#cancelSettle.disarm();
|
|
172
190
|
if (this.open === null) {
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
// "processing"
|
|
191
|
+
// The prompt is still queued behind the previous request (or was never
|
|
192
|
+
// dispatched): clear the flags or Stop leaves the session permanently
|
|
193
|
+
// "processing", and tell the agent anyway — a cancel with nothing to stop
|
|
194
|
+
// is a no-op, while a prompt that slips out afterwards is what hangs the
|
|
195
|
+
// NEXT send.
|
|
196
|
+
if (this.isPromptRunning || this.isStreaming) {
|
|
197
|
+
this.abandonOnStop();
|
|
198
|
+
this.finish({ stopReason: 'cancelled' });
|
|
199
|
+
}
|
|
176
200
|
this.isPromptRunning = false;
|
|
177
201
|
this.isStreaming = false;
|
|
202
|
+
this.#silence.stop();
|
|
178
203
|
return;
|
|
179
204
|
}
|
|
180
205
|
this.open = null;
|
|
181
206
|
this.#silence.stop();
|
|
182
207
|
this.seams.cancelAgent();
|
|
183
|
-
this.seams.abandonPrompt();
|
|
184
208
|
this.finish({ stopReason: 'cancelled' });
|
|
209
|
+
// A held input is the operator's NEXT intent and must not wait out the
|
|
210
|
+
// grace window; otherwise let the agent end its own turn first.
|
|
211
|
+
if (this.#queue.size > 0) this.seams.abandonPrompt();
|
|
212
|
+
else this.#cancelSettle.arm();
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Hold an input until the running turn ends. */
|
|
216
|
+
queue(message: string, images: unknown): void {
|
|
217
|
+
this.#queue.push({ message, images });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Take the next held input; the SESSION dispatches it, so counters and the
|
|
221
|
+
* run marker stay on its own path. */
|
|
222
|
+
takeQueued(): { message: string; images: unknown } | undefined {
|
|
223
|
+
return this.#queue.shift();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The grace window is still open: a Stop that has not been answered yet. */
|
|
227
|
+
pendingCancel(): boolean {
|
|
228
|
+
return this.#cancelSettle.pending();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** The prompt that a Stop must free, dispatched or still queued. */
|
|
232
|
+
private abandonOnStop(): void {
|
|
233
|
+
this.seams.cancelAgent();
|
|
234
|
+
this.seams.abandonPrompt();
|
|
185
235
|
}
|
|
186
236
|
|
|
187
237
|
/** Is a turn accepting the agent's frames right now? */
|
|
@@ -189,23 +239,18 @@ export class AcpTurns {
|
|
|
189
239
|
return this.open !== null;
|
|
190
240
|
}
|
|
191
241
|
|
|
192
|
-
/**
|
|
193
|
-
* v2's turn boundary: an idle `state_update` ends foreground work.
|
|
242
|
+
/** v2's turn boundary: an idle `state_update` ends foreground work.
|
|
194
243
|
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
* matches the turn id.
|
|
199
|
-
*/
|
|
244
|
+
* `running`/`requires_action` do not open a turn when a prompt is still being
|
|
245
|
+
* inserted; agent-initiated work with no prompt does. Repeats are idempotent
|
|
246
|
+
* because `settle` matches the turn id. */
|
|
200
247
|
onStateUpdate(update: Record<string, unknown>): void {
|
|
201
248
|
if (this.completion !== 'state') return;
|
|
202
249
|
const state = typeof update.state === 'string' ? update.state : '';
|
|
203
250
|
if (state !== 'idle') {
|
|
204
|
-
//
|
|
205
|
-
//
|
|
251
|
+
// A cancelled run's running/requires_action is not a new interval;
|
|
252
|
+
// foreground work with no prompt (a goal) does open one.
|
|
206
253
|
if (this.awaitingCancellation) return;
|
|
207
|
-
// v2 allows foreground work with no prompt (a goal, a follow-up on a
|
|
208
|
-
// background task). Open a turn so its frames are accepted and rendered.
|
|
209
254
|
if (this.open === null && !this.isPromptRunning && !this.isStreaming) this.beginAgentTurn();
|
|
210
255
|
return;
|
|
211
256
|
}
|
|
@@ -270,34 +315,18 @@ export class AcpTurns {
|
|
|
270
315
|
for (const toolCallId of abandoned) {
|
|
271
316
|
this.seams.emit({ type: 'tool_execution_end', toolCallId, isError: true, result: { output: 'Cancelled' } });
|
|
272
317
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// the "silent answer is a failure" rule is a v1 agent behaviour (pi-acp).
|
|
286
|
-
// `stopReason: 'error'` is a failure even when the agent DID send a partial
|
|
287
|
-
// message: a v1 agent answers `{stopReason: 'error'}` with whatever it had
|
|
288
|
-
// streamed, and reading only "did it answer" reported that turn as
|
|
289
|
-
// completed — so a delegated worker whose provider failed mid-answer told
|
|
290
|
-
// its coordinator it had finished.
|
|
291
|
-
const failed = !cancelled && !slash
|
|
292
|
-
&& (stranded || reported || result?.stopReason === 'error' || (this.completion === 'response' && !answered));
|
|
293
|
-
const reason = failed
|
|
294
|
-
? failure ?? (stranded
|
|
295
|
-
? STRANDED_REASON
|
|
296
|
-
: closedFailure(closed) ?? (result?.stopReason === 'error'
|
|
297
|
-
? 'The agent ended the turn with an error'
|
|
298
|
-
: 'The agent ended the turn without sending an answer'))
|
|
299
|
-
: null;
|
|
300
|
-
if (failed && !reported && !slash) {
|
|
318
|
+
const { failed, cancelled, reason } = turnVerdict({
|
|
319
|
+
closed,
|
|
320
|
+
abandoned: abandoned.length,
|
|
321
|
+
result,
|
|
322
|
+
reported,
|
|
323
|
+
stranded,
|
|
324
|
+
promptText: this.promptText,
|
|
325
|
+
completion: this.completion,
|
|
326
|
+
strandedReason: STRANDED_REASON,
|
|
327
|
+
...(failure ? { failure } : {}),
|
|
328
|
+
});
|
|
329
|
+
if (failed && !reported && !reasonSuppressed(this.promptText)) {
|
|
301
330
|
this.seams.emit({
|
|
302
331
|
type: 'prompt_error',
|
|
303
332
|
errorMessage: reason ?? 'The agent ended the turn without sending an answer',
|
|
@@ -316,34 +345,3 @@ export class AcpTurns {
|
|
|
316
345
|
});
|
|
317
346
|
}
|
|
318
347
|
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* The reason the CLOSED message names, when it named one.
|
|
322
|
-
*
|
|
323
|
-
* The same rule as omp's: an agent records `stopReason` / `errorMessage` flat on
|
|
324
|
-
* the assistant message, and reading only the envelope's stop reason threw the
|
|
325
|
-
* provider's own words away — a coordinator was told "the agent ended the turn
|
|
326
|
-
* with an error" over a transcript that said which.
|
|
327
|
-
*/
|
|
328
|
-
function closedFailure(message: unknown): string | null {
|
|
329
|
-
if (!message || typeof message !== 'object' || Array.isArray(message)) return null;
|
|
330
|
-
const error = deriveTurnError(message as Record<string, unknown>);
|
|
331
|
-
return error?.message?.trim() || null;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/** Does the closed message carry anything the timeline draws? A whitespace-only
|
|
335
|
-
* chunk (or one that carried only an empty text block) opens a message row
|
|
336
|
-
* that renders nothing, which is the same operator-visible failure as no frame
|
|
337
|
-
* at all. Thinking and tool calls are content: they render as their own
|
|
338
|
-
* blocks. */
|
|
339
|
-
function hasRenderableAnswer(message: unknown): boolean {
|
|
340
|
-
if (!message || typeof message !== 'object' || !('content' in message)) return false;
|
|
341
|
-
const content = message.content;
|
|
342
|
-
if (!Array.isArray(content)) return false;
|
|
343
|
-
return content.some((block) => {
|
|
344
|
-
if (!block || typeof block !== 'object') return false;
|
|
345
|
-
if ('text' in block && typeof block.text === 'string') return block.text.trim().length > 0;
|
|
346
|
-
if ('thinking' in block && typeof block.thinking === 'string') return block.thinking.trim().length > 0;
|
|
347
|
-
return 'type' in block && block.type === 'toolCall';
|
|
348
|
-
});
|
|
349
|
-
}
|
|
@@ -68,6 +68,15 @@ describe('normalizeInitializeResult', () => {
|
|
|
68
68
|
const v1 = { protocolVersion: 1, agentCapabilities: { loadSession: true } };
|
|
69
69
|
expect(normalizeInitializeResult(v1)).toBe(v1 as never);
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
test('a peer that reports 2 but answers in v1 shape is spoken to as v1', () => {
|
|
73
|
+
const init = normalizeInitializeResult({
|
|
74
|
+
protocolVersion: 2,
|
|
75
|
+
agentCapabilities: { loadSession: true, promptCapabilities: { image: true } },
|
|
76
|
+
});
|
|
77
|
+
expect(init.protocolVersion).toBe(1);
|
|
78
|
+
expect(init.agentCapabilities?.loadSession).toBe(true);
|
|
79
|
+
});
|
|
71
80
|
});
|
|
72
81
|
|
|
73
82
|
describe('normalizeConfigOptions', () => {
|
|
@@ -51,6 +51,15 @@ function advertised(value: unknown): boolean {
|
|
|
51
51
|
export function normalizeInitializeResult(raw: Record<string, unknown>): AcpInitializeResult {
|
|
52
52
|
const version = typeof raw.protocolVersion === 'number' ? raw.protocolVersion : 1;
|
|
53
53
|
if (version !== 2) return raw as unknown as AcpInitializeResult;
|
|
54
|
+
// A peer that REPORTS 2 but answers with v1's keys (`agentCapabilities`, and
|
|
55
|
+
// no `capabilities`) is speaking v1. Reading it as v2 finds no capabilities
|
|
56
|
+
// at all and, worse, sets the turn machine's completion mode to `state` — so
|
|
57
|
+
// the `session/prompt` answer that ends every v1 turn is ignored and the run
|
|
58
|
+
// hangs until the silence ceiling. bb's heuristic is the same: the shape, not
|
|
59
|
+
// the number, decides which generation a result is written in.
|
|
60
|
+
if (asRecord(raw.agentCapabilities) !== undefined && asRecord(raw.capabilities) === undefined) {
|
|
61
|
+
return { ...raw, protocolVersion: 1 } as AcpInitializeResult;
|
|
62
|
+
}
|
|
54
63
|
|
|
55
64
|
const capabilities = asRecord(raw.capabilities) ?? {};
|
|
56
65
|
const session = asRecord(capabilities.session);
|
|
@@ -112,6 +121,10 @@ export function normalizeAuthMethods(value: unknown): AcpInitializeResult['authM
|
|
|
112
121
|
name: asString(method?.name) ?? id,
|
|
113
122
|
...(asString(method?.description) ? { description: asString(method?.description) } : {}),
|
|
114
123
|
...(asString(method?.type) ? { type: asString(method?.type) } : {}),
|
|
124
|
+
...(Array.isArray(method?.args)
|
|
125
|
+
? { args: method.args.filter((arg): arg is string => typeof arg === 'string') }
|
|
126
|
+
: {}),
|
|
127
|
+
...(asRecord(method?.env) ? { env: asRecord(method?.env) as Record<string, string> } : {}),
|
|
115
128
|
}];
|
|
116
129
|
});
|
|
117
130
|
}
|
|
@@ -28,14 +28,20 @@ export type AcpNotify = (method: string, params: unknown) => void;
|
|
|
28
28
|
/** The negotiated major, so a verb can shape its params and normalize its answer. */
|
|
29
29
|
export type AcpDialect = 1 | 2;
|
|
30
30
|
|
|
31
|
+
/** The extra roots one setup request carries, when the agent advertised them. */
|
|
32
|
+
export interface SessionDirs {
|
|
33
|
+
additionalDirectories?: string[];
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
export async function newSession(
|
|
32
37
|
invoke: AcpInvoke,
|
|
33
38
|
cwd: string,
|
|
34
39
|
timeoutMs = 120_000,
|
|
35
40
|
dialect: AcpDialect = 1,
|
|
36
41
|
mcpServers: AcpMcpServerWire[] = [],
|
|
42
|
+
dirs: SessionDirs = {},
|
|
37
43
|
): Promise<AcpSessionNewResult> {
|
|
38
|
-
const result = await invoke<Record<string, unknown>>('session/new', { cwd, mcpServers }, timeoutMs);
|
|
44
|
+
const result = await invoke<Record<string, unknown>>('session/new', { cwd, mcpServers, ...dirs }, timeoutMs);
|
|
39
45
|
return dialect === 2 ? normalizeSessionResult(result) : (result as unknown as AcpSessionNewResult);
|
|
40
46
|
}
|
|
41
47
|
|
|
@@ -45,8 +51,9 @@ export async function loadSession(
|
|
|
45
51
|
cwd: string,
|
|
46
52
|
timeoutMs = 120_000,
|
|
47
53
|
mcpServers: AcpMcpServerWire[] = [],
|
|
54
|
+
dirs: SessionDirs = {},
|
|
48
55
|
): Promise<unknown> {
|
|
49
|
-
return invoke('session/load', { sessionId, cwd, mcpServers }, timeoutMs);
|
|
56
|
+
return invoke('session/load', { sessionId, cwd, mcpServers, ...dirs }, timeoutMs);
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
export async function resumeSession(
|
|
@@ -60,10 +67,11 @@ export async function resumeSession(
|
|
|
60
67
|
* `session/update` frames before the reply. v1 peers replay through
|
|
61
68
|
* `session/load` instead. */
|
|
62
69
|
replayFrom?: { type: 'start' },
|
|
70
|
+
dirs: SessionDirs = {},
|
|
63
71
|
): Promise<unknown> {
|
|
64
72
|
const result = await invoke<Record<string, unknown>>(
|
|
65
73
|
'session/resume',
|
|
66
|
-
{ sessionId, cwd, mcpServers, ...(dialect === 2 && replayFrom ? { replayFrom } : {}) },
|
|
74
|
+
{ sessionId, cwd, mcpServers, ...(dialect === 2 && replayFrom ? { replayFrom } : {}), ...dirs },
|
|
67
75
|
timeoutMs,
|
|
68
76
|
);
|
|
69
77
|
return dialect === 2 ? normalizeSessionResult(result) : result;
|
|
@@ -77,10 +85,11 @@ export async function forkSession(
|
|
|
77
85
|
target?: Record<string, unknown>,
|
|
78
86
|
meta?: Record<string, unknown>,
|
|
79
87
|
mcpServers: AcpMcpServerWire[] = [],
|
|
88
|
+
dirs: SessionDirs = {},
|
|
80
89
|
): Promise<AcpSessionNewResult> {
|
|
81
90
|
return invoke<AcpSessionNewResult>(
|
|
82
91
|
'session/fork',
|
|
83
|
-
{ sessionId, cwd, mcpServers, ...(target ? { target } : {}), ...(meta ? { _meta: meta } : {}) },
|
|
92
|
+
{ sessionId, cwd, mcpServers, ...dirs, ...(target ? { target } : {}), ...(meta ? { _meta: meta } : {}) },
|
|
84
93
|
timeoutMs,
|
|
85
94
|
);
|
|
86
95
|
}
|
|
@@ -187,6 +196,28 @@ export async function setMode(
|
|
|
187
196
|
return invoke('session/set_mode', { sessionId, modeId }, timeoutMs);
|
|
188
197
|
}
|
|
189
198
|
|
|
199
|
+
/** Sign this client in with one of the agent's advertised `authMethods`.
|
|
200
|
+
* `_meta.headless` tells the agent no interactive terminal is attached, so a
|
|
201
|
+
* method that needs one refuses instead of parking the spawn. */
|
|
202
|
+
export async function authenticate(
|
|
203
|
+
invoke: AcpInvoke,
|
|
204
|
+
methodId: string,
|
|
205
|
+
timeoutMs = 120_000,
|
|
206
|
+
): Promise<unknown> {
|
|
207
|
+
return invoke('authenticate', { methodId, _meta: { headless: true } }, timeoutMs);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** `session/set_model`: select a model on an agent that publishes a `models`
|
|
211
|
+
* block instead of a `model` config option (measured on grok). */
|
|
212
|
+
export async function setModel(
|
|
213
|
+
invoke: AcpInvoke,
|
|
214
|
+
sessionId: string,
|
|
215
|
+
modelId: string,
|
|
216
|
+
timeoutMs = 30_000,
|
|
217
|
+
): Promise<unknown> {
|
|
218
|
+
return invoke('session/set_model', { sessionId, modelId }, timeoutMs);
|
|
219
|
+
}
|
|
220
|
+
|
|
190
221
|
/** Remove one session from the agent's own history (`sessionCapabilities.delete`). */
|
|
191
222
|
export async function deleteSession(invoke: AcpInvoke, sessionId: string, timeoutMs = 30_000): Promise<unknown> {
|
|
192
223
|
return invoke('session/delete', { sessionId }, timeoutMs);
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* The per-pid lease that tells the Stats panel which chat an ACP child is.
|
|
8
8
|
*
|
|
9
|
-
* omp's RPC hosts hold an OS
|
|
10
|
-
*
|
|
9
|
+
* omp's RPC hosts hold an OS lock on `~/.omp/run/session-owners/<id>.lock`
|
|
10
|
+
* (`flock` on macOS, an open-file-description lock on Linux since 19.0.1), and
|
|
11
|
+
* the panel reads that descriptor to name a session. An ACP agent holds no
|
|
11
12
|
* such lease: its id lives in Kabmo's `harness_sessions` table and its
|
|
12
13
|
* transcript lives behind the agent, so a panel that only knew argv drew every
|
|
13
14
|
* `claude`/`codex`/`opencode` chat as a bare `npx` row inside Kabmo's own group
|
|
@@ -88,6 +88,9 @@ const SESSION_ROW_DELETES: readonly (readonly [string, string])[] = [
|
|
|
88
88
|
// The per-session MCP overrides and the agent-dir overlay they build. The
|
|
89
89
|
// row is keyed to the id; the directory is removed below.
|
|
90
90
|
['session_mcp_state', 'session_id'],
|
|
91
|
+
// An ACP chat's standing "always allow" decisions. A deleted chat that kept
|
|
92
|
+
// them would re-approve the same commands if its id were ever reused.
|
|
93
|
+
['acp_permission_grants', 'session_id'],
|
|
91
94
|
];
|
|
92
95
|
|
|
93
96
|
async function purgeKabmoRows(db: DbClient, sessionId: string): Promise<number> {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Linux half of the lease probe, pinned against a lock this file takes
|
|
8
|
+
* ITSELF.
|
|
9
|
+
*
|
|
10
|
+
* Linux keeps `flock(2)` and record locks (`F_OFD_SETLK`) in separate spaces, so
|
|
11
|
+
* a probe written with the wrong primitive reports a live lease as free. That is
|
|
12
|
+
* not hypothetical: omp 19.0.1 moved Linux to an open-file-description lock, and
|
|
13
|
+
* a `flock`-based probe — which is what this module used to be — acquired a
|
|
14
|
+
* lease a second process was holding (measured in a container, bun 1.4.4). The
|
|
15
|
+
* failure is silent in the direction that hurts: Kabmo would spawn a second
|
|
16
|
+
* writer on a session another instance owns, and omp forks the session.
|
|
17
|
+
*
|
|
18
|
+
* The holder here is taken with `fcntl` directly, never through the module under
|
|
19
|
+
* test, so a regression to `flock` fails this case instead of passing it
|
|
20
|
+
* tautologically.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { describe, expect, test } from 'bun:test';
|
|
24
|
+
import fs from 'node:fs';
|
|
25
|
+
import os from 'node:os';
|
|
26
|
+
import path from 'node:path';
|
|
27
|
+
import { dlopen, FFIType, ptr } from 'bun:ffi';
|
|
28
|
+
|
|
29
|
+
import { leaseHeldByAnother } from '@/server/lib/omp/session/lease-probe.server';
|
|
30
|
+
|
|
31
|
+
const linuxOnly = process.platform !== 'linux';
|
|
32
|
+
|
|
33
|
+
/** `F_WRLCK`, `F_UNLCK`, `SEEK_SET`, `F_OFD_SETLK` — as `fcntl(2)` names them. */
|
|
34
|
+
const F_WRLCK = 1;
|
|
35
|
+
const F_UNLCK = 2;
|
|
36
|
+
const SEEK_SET = 0;
|
|
37
|
+
const F_OFD_SETLK = 37;
|
|
38
|
+
|
|
39
|
+
const libc = linuxOnly
|
|
40
|
+
? null
|
|
41
|
+
: dlopen('libc.so.6', {
|
|
42
|
+
open: { args: [FFIType.cstring, FFIType.i32], returns: FFIType.i32 },
|
|
43
|
+
close: { args: [FFIType.i32], returns: FFIType.i32 },
|
|
44
|
+
fcntl: { args: [FFIType.i32, FFIType.i32, FFIType.ptr], returns: FFIType.i32 },
|
|
45
|
+
} as const);
|
|
46
|
+
|
|
47
|
+
/** `struct flock` (64-bit Linux) covering the whole file. */
|
|
48
|
+
function lockStruct(type: number): Uint8Array {
|
|
49
|
+
const buffer = new Uint8Array(32);
|
|
50
|
+
const view = new DataView(buffer.buffer);
|
|
51
|
+
view.setInt16(0, type, true);
|
|
52
|
+
view.setInt16(2, SEEK_SET, true);
|
|
53
|
+
view.setBigInt64(8, 0n, true);
|
|
54
|
+
view.setBigInt64(16, 0n, true);
|
|
55
|
+
view.setInt32(24, 0, true);
|
|
56
|
+
return buffer;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
describe('leaseHeldByAnother on Linux', () => {
|
|
60
|
+
test.skipIf(linuxOnly)('sees an open-file-description lock another fcntl call holds', () => {
|
|
61
|
+
if (libc === null) throw new Error('libc unavailable');
|
|
62
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-lease-probe-'));
|
|
63
|
+
const lease = path.join(dir, 'ofd.lock');
|
|
64
|
+
fs.writeFileSync(lease, '');
|
|
65
|
+
|
|
66
|
+
// The probe runs BEFORE any holder: it must not leave a lock of its own
|
|
67
|
+
// behind, or the "held" answer below could come from this process.
|
|
68
|
+
expect(leaseHeldByAnother(lease)).toBe(false);
|
|
69
|
+
|
|
70
|
+
const fd = libc.symbols.open(Buffer.from(`${lease}\0`), 2);
|
|
71
|
+
expect(fd).toBeGreaterThanOrEqual(0);
|
|
72
|
+
try {
|
|
73
|
+
expect(libc.symbols.fcntl(fd, F_OFD_SETLK, ptr(lockStruct(F_WRLCK)))).toBe(0);
|
|
74
|
+
expect(leaseHeldByAnother(lease)).toBe(true);
|
|
75
|
+
libc.symbols.fcntl(fd, F_OFD_SETLK, ptr(lockStruct(F_UNLCK)));
|
|
76
|
+
expect(leaseHeldByAnother(lease)).toBe(false);
|
|
77
|
+
} finally {
|
|
78
|
+
libc.symbols.close(fd);
|
|
79
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|