@kabmo-labs/kabmo 0.49.0 → 0.50.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 +601 -557
- package/dist/client/static/js/{Body-9h5hd351.js → Body-pd3nt4xa.js} +3 -3
- package/dist/client/static/js/{CsvGrid-s05k1q18.js → CsvGrid-eksmqv8f.js} +2 -2
- package/dist/client/static/js/{DocxView-x6sjw5ht.js → DocxView-xfx1kt8x.js} +3 -3
- package/dist/client/static/js/{DrawioView-jashn8sf.js → DrawioView-2xyqg9bv.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-eygzgtyc.js → HtmlPreview-ps3f0aa5.js} +1 -1
- package/dist/client/static/js/ImageView-7vse3k6x.js +1 -0
- package/dist/client/static/js/{LayoutWrapper-tag0qpts.js → LayoutWrapper-qdp83fps.js} +2 -2
- package/dist/client/static/js/MergeDiffView-hzsccppq.js +1 -0
- package/dist/client/static/js/Modal-zw9x5b6f.js +60 -0
- package/dist/client/static/js/{PdfView-syhjmyqf.js → PdfView-8fp08jym.js} +1 -1
- package/dist/client/static/js/{SessionsView-2r1grxxs.js → SessionsView-qmgg03fv.js} +1 -1
- package/dist/client/static/js/{SheetView-26r0e506.js → SheetView-g7mstjdp.js} +22 -22
- package/dist/client/static/js/{SvgPreview-2fk85jzz.js → SvgPreview-wsv4h6c6.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-fdka7pxr.js → abnfDiagram-O67JEVCF-1kgm1049.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-g7b64973.js +1 -0
- package/dist/client/static/js/architectureDiagram-NJMV4G6O-mtm210rw.js +36 -0
- package/dist/client/static/js/{astro-rn2bvwpm.js → astro-dszrfwwn.js} +1 -1
- package/dist/client/static/js/bash-z5pe89pt.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-vpcmd3vx.js → blockDiagram-BEXU5L5S-s474vn2w.js} +8 -8
- package/dist/client/static/js/c-fy0fysfw.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-1rgpdnbq.js → c4Diagram-YGBWAQC7-s68v6tc8.js} +3 -3
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fbsejvb9.js → classDiagram-v2-NBCMYWYE-291va3yk.js} +10 -10
- package/dist/client/static/js/cose-bilkent-JH36ORCC-0zg7crdw.js +1 -0
- package/dist/client/static/js/cpp-wam8dze6.js +1 -0
- package/dist/client/static/js/css-ke51m4kc.js +1 -0
- package/dist/client/static/js/css-yryw442h.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-8bscrcct.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-7ta5vbrw.js → cynefinDiagram-VND7K2PF-4gnmn3yc.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-b8gtt32x.js → dagre-6A5THRUB-nxmj6bkg.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-7emepy7h.js → diagram-22UHCM2B-3171dabw.js} +25 -25
- package/dist/client/static/js/{diagram-3UASUU5V-06nptkzc.js → diagram-3UASUU5V-9h1pd6h8.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-t113exk3.js → diagram-ATOU4E4O-ywfrbd6m.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-pyj3x97y.js → diagram-CDSNMT55-t87b4wbk.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-183sgpjh.js → diagram-MLGK6HIB-bzv52p97.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-fmbj4hcx.js → diagram-MPIPVDR6-8f66rp0a.js} +2 -2
- package/dist/client/static/js/{dockerfile-qay672za.js → dockerfile-z3v0km9v.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-eafvfws2.js → ebnfDiagram-ZINNZB2B-3y4w2j6t.js} +1 -1
- package/dist/client/static/js/{elixir-t8bep87c.js → elixir-c701n0qg.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-573f1vfs.js → elk-276RUBZZ-d9d23jch.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-4z1r88ej.js → erDiagram-OPXOYQCR-w4z3501c.js} +12 -12
- package/dist/client/static/js/{erlang-261km7r1.js → erlang-cpw5s1f9.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-pj22bng1.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-9h6g160j.js +1 -0
- package/dist/client/static/js/ganttDiagram-FUAMR5RP-7wcxk4bm.js +292 -0
- package/dist/client/static/js/gitGraph-4MIJSDKK-hgw4jcvk.js +1 -0
- package/dist/client/static/js/gitGraphDiagram-X574FWY7-sdh1hsb1.js +106 -0
- package/dist/client/static/js/graphql-0yv8dc1v.js +1 -0
- package/dist/client/static/js/html-zk3m0az9.js +1 -0
- package/dist/client/static/js/{index-c3whkrwa.js → index-09ap9ncj.js} +30 -30
- package/dist/client/static/js/index-0ff2x5g9.js +1 -0
- package/dist/client/static/js/{index-gg910gpv.js → index-0q39ajgh.js} +2 -2
- package/dist/client/static/js/{index-tb35a328.js → index-144aknp3.js} +2 -2
- package/dist/client/static/js/index-17jy16v3.js +314 -0
- package/dist/client/static/js/{index-j37m7pn9.js → index-1adfks1n.js} +1 -1
- package/dist/client/static/js/{index-4dnc1kys.js → index-1d8v3bvm.js} +2 -2
- package/dist/client/static/js/index-1dx4dqzy.js +4 -0
- package/dist/client/static/js/{index-a4636gt1.js → index-1ec33b1j.js} +2 -2
- package/dist/client/static/js/{index-gr8sqjpz.js → index-1jx4nt2f.js} +1 -1
- package/dist/client/static/js/{index-80fjn77c.js → index-1kjgdyfk.js} +2 -2
- package/dist/client/static/js/{index-h8hjcdj1.js → index-1vfej0gk.js} +2 -2
- package/dist/client/static/js/{index-wbsvg1d9.js → index-2g1ey1c9.js} +2 -2
- package/dist/client/static/js/{index-bmaktvm2.js → index-3rhk4apq.js} +1 -1
- package/dist/client/static/js/{index-2yzt8h3d.js → index-4vaxdt8a.js} +2 -2
- package/dist/client/static/js/{index-fbg5vhhw.js → index-4z3qtazf.js} +2 -2
- package/dist/client/static/js/{index-taev57jw.js → index-56319bht.js} +2 -2
- package/dist/client/static/js/{index-yg083mk0.js → index-5qwgexg6.js} +6 -6
- package/dist/client/static/js/index-779rptb2.js +1 -0
- package/dist/client/static/js/{index-4z5ram7g.js → index-7jdz4jr4.js} +2 -2
- package/dist/client/static/js/{index-2bf0txsp.js → index-7xn7gxgw.js} +2 -2
- package/dist/client/static/js/{index-ykc14gez.js → index-8fk7h2me.js} +5 -5
- package/dist/client/static/js/{index-dh060b7r.js → index-971stdh4.js} +2 -2
- package/dist/client/static/js/{index-t522tpxt.js → index-9jrej3ht.js} +3 -3
- package/dist/client/static/js/index-9ydvkxz1.css +1 -0
- package/dist/client/static/js/{index-473hk8nb.js → index-ajdzvegm.js} +9 -9
- package/dist/client/static/js/{index-nzvte8s5.js → index-ajqmcds5.js} +2 -2
- package/dist/client/static/js/{index-5p8dwr4y.js → index-ap6hv7s7.js} +1 -1
- package/dist/client/static/js/{index-0857zpr0.js → index-aqqj4xxy.js} +2 -2
- package/dist/client/static/js/index-bczhbk01.js +2 -0
- package/dist/client/static/js/{index-z6y8j93w.js → index-bggz63br.js} +7 -7
- package/dist/client/static/js/{index-qwxawph7.js → index-c2mqr5fh.js} +2 -2
- package/dist/client/static/js/{index-4ccs971z.js → index-cm8pa783.js} +2 -2
- package/dist/client/static/js/{index-7rmps91t.js → index-dgkpbrdr.js} +2 -2
- package/dist/client/static/js/{index-epzvftkq.js → index-e471eprg.js} +1 -1
- package/dist/client/static/js/{index-14dgbjsm.js → index-evvmkk2f.js} +1 -1
- package/dist/client/static/js/{index-rz0tz4hg.js → index-frhxbqhg.js} +1 -1
- package/dist/client/static/js/{index-1p880x6e.js → index-gcgsjd3c.js} +2 -2
- package/dist/client/static/js/{index-s5vegk6q.js → index-grkacfv3.js} +2 -2
- package/dist/client/static/js/{index-7ff9scbm.js → index-gws4prmg.js} +2 -2
- package/dist/client/static/js/index-hqhz4eam.js +1 -0
- package/dist/client/static/js/{index-pv4z2mp2.js → index-jr6q69r3.js} +181 -179
- package/dist/client/static/js/{index-dmc82cxb.js → index-jxxewcat.js} +2 -2
- package/dist/client/static/js/{index-gz7kvpnm.js → index-k3vvk28c.js} +1 -1
- package/dist/client/static/js/{index-yyjw1ty9.js → index-k66w6d9b.js} +2 -2
- package/dist/client/static/js/{index-1yq96wpa.js → index-kce86cnw.js} +2 -2
- package/dist/client/static/js/{index-zp40g8ah.js → index-n54jd3aw.js} +12 -12
- package/dist/client/static/js/{index-pygy21w5.js → index-nnqyew8n.js} +2 -2
- package/dist/client/static/js/index-qaxjp73x.js +2 -0
- package/dist/client/static/js/{index-5dn4159w.js → index-qxzyvye9.js} +2 -2
- package/dist/client/static/js/{index-5ztdqm1w.js → index-r2z0a118.js} +2 -2
- package/dist/client/static/js/{index-7dqq7cjp.js → index-r6bm9sth.js} +7 -7
- package/dist/client/static/js/{index-e8mt8rag.js → index-ratbr10x.js} +2 -2
- package/dist/client/static/js/{index-xw1bptp5.js → index-rgneq3zt.js} +2 -2
- package/dist/client/static/js/{index-nbm5r9g1.js → index-svx6rnfs.js} +2 -2
- package/dist/client/static/js/{index-3v8k8ms3.js → index-tew3rd6t.js} +1 -1
- package/dist/client/static/js/index-tfwsch7a.js +4 -0
- package/dist/client/static/js/{index-qs4n116g.js → index-vgwjn4de.js} +2 -2
- package/dist/client/static/js/{index-mbtenbyc.js → index-vn495w82.js} +6 -6
- package/dist/client/static/js/{index-tcfpzqb9.js → index-wbma8kqw.js} +33 -33
- package/dist/client/static/js/{index-gaqjrzdb.js → index-xgbcn89g.js} +2 -2
- package/dist/client/static/js/{index-tc6k8qt7.js → index-xrn2reb5.js} +2 -2
- package/dist/client/static/js/{index-0w4jqzqk.js → index-zhnfq8br.js} +2 -2
- package/dist/client/static/js/index-zsx5vs3j.js +2 -0
- package/dist/client/static/js/info-A6RAGUB7-k0kv05ny.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-xsar9j6v.js → infoDiagram-VRGFBTTK-gtdp0z6p.js} +1 -1
- package/dist/client/static/js/ini-apj95p59.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-g2rvt9jp.js → ishikawaDiagram-OU5B5YK6-c05m0sqq.js} +3 -3
- package/dist/client/static/js/java-khk2v3g4.js +1 -0
- package/dist/client/static/js/javascript-gez6yppm.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-q95v18zc.js → journeyDiagram-ZHPQQLJL-kgk5ygm2.js} +6 -6
- package/dist/client/static/js/json-r78y6e80.js +1 -0
- package/dist/client/static/js/jsx-h7hfj8cz.js +1 -0
- package/dist/client/static/js/{julia-pe5vpc2m.js → julia-w13bz4s1.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-2e7m7ds3.js → kanban-definition-PNTS6WVX-q1w9w68s.js} +6 -6
- package/dist/client/static/js/lua-pat2bzg3.js +1 -0
- package/dist/client/static/js/markdown-545zn05v.js +1 -0
- package/dist/client/static/js/{mermaid.core-dzajkp0g.js → mermaid.core-1rz62j9g.js} +7 -7
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-banecvf8.js → mindmap-definition-NLK3R4M7-3m3w6bnb.js} +8 -8
- package/dist/client/static/js/one-dark-pro-7c942tnw.js +1 -0
- package/dist/client/static/js/one-light-tp8y6c5g.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-ne66q5h9.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-6erykm1c.js → pegDiagram-GJSIUBJH-svd3ex4e.js} +1 -1
- package/dist/client/static/js/{perl-cc2eqye8.js → perl-hcg3hacf.js} +1 -1
- package/dist/client/static/js/{php-p9bvnpsv.js → php-q6hhp84p.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-ej9aysvz.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-jn1d905q.js → pieDiagram-5QR66LMP-2nrkw034.js} +3 -3
- package/dist/client/static/js/properties-9f76xngb.js +1 -0
- package/dist/client/static/js/python-nwerpkfq.js +1 -0
- package/dist/client/static/js/quadrantDiagram-O4NWA36T-4895d1aq.js +7 -0
- package/dist/client/static/js/r-39k5dr2p.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-375pe46t.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-hdgdfsc1.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-2p5ynn4a.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-2p1fxxen.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-g131pt42.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-ewzhhth2.js → railroadDiagram-XR7U4H2S-zj3g9yne.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-fcs3xd42.js → requirementDiagram-PLB6GJNP-727yjvs8.js} +6 -6
- package/dist/client/static/js/{ruby-65s2ca5d.js → ruby-wzqz8vw6.js} +1 -1
- package/dist/client/static/js/{rust-ec1j2hwy.js → rust-r94pgqvf.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-2r829rjf.js → sankeyDiagram-IPEJSGJF-17c7p2pe.js} +5 -5
- package/dist/client/static/js/{sass-p6cssgq8.js → sass-xb3van7h.js} +1 -1
- package/dist/client/static/js/{scss-qfx8wt3b.js → scss-ddg6t3x4.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3mnte9tv.js → sequenceDiagram-PO4LG4MO-wcmbpckr.js} +21 -21
- package/dist/client/static/js/{sizeCapture-INFHLROL-r6hf9265.js → sizeCapture-INFHLROL-nkr57cd6.js} +1 -1
- package/dist/client/static/js/sql-4dcrp3sw.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-hm2f0wdb.js → stateDiagram-v2-GCMORJYK-vd7r8s78.js} +6 -6
- package/dist/client/static/js/{svelte-jz3a190v.js → svelte-wzaxz546.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-s58xzqhw.js → swimlanes-2SLR337P-zhxm05ak.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-myzk2rg0.js +8 -0
- package/dist/client/static/js/timeline-definition-EJHVYXUP-n7gbzhzd.js +120 -0
- package/dist/client/static/js/treeView-Q6P3EWNA-gfztfha9.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-kwtrwq1f.js +1 -0
- package/dist/client/static/js/tsx-dk8rpgtw.js +1 -0
- package/dist/client/static/js/typescript-q0493nmw.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ryvgs5ac.js → usecaseDiagram-POWQR4AR-davsnwkf.js} +82 -82
- package/dist/client/static/js/vennDiagram-UO4OBE2U-gb54bh5k.js +34 -0
- package/dist/client/static/js/{vue-rv4pea8r.js → vue-6zhfw7zx.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-30dnzvww.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-1kt8q8a4.js → wardleyDiagram-VNRHLVJA-sf98cg9t.js} +4 -4
- package/dist/client/static/js/xml-91sb3gt9.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-q39bbgq4.js → xychartDiagram-PMCCYNJV-9nn09k40.js} +4 -4
- package/dist/client/static/js/yaml-ghx4mjw1.js +1 -0
- package/package.json +1 -1
- package/src/client/components/common/header-button/index.tsx +10 -2
- package/src/client/components/settings/apply-side-effects.test.ts +16 -0
- package/src/client/components/settings/apply-side-effects.ts +8 -0
- package/src/client/components/settings/categories/AppearanceSettings.test.tsx +1 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +2 -0
- package/src/client/components/settings/categories/HarnessSettings.tsx +8 -0
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +26 -3
- package/src/client/components/settings/categories/appearance-settings/RightSideSection.test.tsx +97 -0
- package/src/client/components/settings/categories/appearance-settings/RightSideSection.tsx +94 -0
- package/src/client/components/settings/categories/appearance-settings/groups.ts +4 -3
- package/src/client/components/settings/categories/harness-settings/AccountLoginPanel.tsx +224 -0
- package/src/client/components/settings/categories/harness-settings/AccountsPanel.test.tsx +139 -0
- package/src/client/components/settings/categories/harness-settings/AccountsPanel.tsx +349 -0
- package/src/client/components/settings/categories/harness-settings/AddAccountForm.tsx +58 -0
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +33 -0
- package/src/client/components/settings/categories/token-usage-settings/HarnessFilter.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +37 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +10 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.ts +4 -1
- package/src/client/components/settings/categories/usage-settings/providers.ts +28 -0
- package/src/client/components/settings/categories/usage-settings/usage-visibility.test.ts +60 -0
- package/src/client/components/settings/categories/voice-settings/SpeechSettings.test.tsx +40 -0
- package/src/client/components/settings/categories/voice-settings/speech/EndpointSection.tsx +8 -2
- package/src/client/components/settings/categories/voice-settings/speech/VoiceSection.tsx +52 -21
- package/src/client/components/workspace/usage-panel/index.test.tsx +92 -12
- package/src/client/components/workspace/usage-panel/index.tsx +48 -12
- package/src/client/data/mock/token-usage.ts +53 -10
- package/src/client/hooks/chat/timeline/reader-input.ts +53 -1
- package/src/client/hooks/chat/timeline/scroll-activity.test.ts +103 -0
- package/src/client/hooks/chat/timeline/scroll-geometry.ts +9 -4
- package/src/client/hooks/chat/timeline/scroll.ts +19 -2
- package/src/client/hooks/models/harness-accounts.ts +143 -0
- package/src/client/hooks/models/harness-catalog.ts +9 -2
- package/src/client/hooks/models/use-harnesses-controller.ts +12 -0
- package/src/client/hooks/models/use-harnesses.ts +14 -0
- package/src/client/hooks/settings/hide-empty-providers.test.ts +132 -0
- package/src/client/hooks/settings/hide-empty-providers.ts +49 -0
- package/src/client/hooks/settings/useTokenUsage.ts +7 -2
- package/src/client/hooks/workspace/panel-tabs.ts +1 -1
- package/src/client/hooks/workspace/right-side.test.ts +75 -1
- package/src/client/hooks/workspace/right-side.ts +71 -10
- package/src/server/lib/antigravity/home.server.ts +27 -0
- package/src/server/lib/db/schema.ts +5 -1
- package/src/server/lib/harness/account-identity.server.ts +163 -0
- package/src/server/lib/harness/account-login.server.test.ts +151 -0
- package/src/server/lib/harness/account-login.server.ts +232 -0
- package/src/server/lib/harness/accounts.server.ts +339 -0
- package/src/server/lib/harness/accounts.test.ts +147 -0
- package/src/server/lib/harness/acp/background-probe.test.ts +314 -0
- package/src/server/lib/harness/acp/background-probe.ts +288 -0
- package/src/server/lib/harness/acp/background-replay.test.ts +1 -1
- package/src/server/lib/harness/acp/background-work.test.ts +4 -194
- package/src/server/lib/harness/acp/background-work.ts +4 -207
- package/src/server/lib/harness/acp/client.ts +3 -0
- package/src/server/lib/harness/acp/commands.ts +2 -2
- package/src/server/lib/harness/acp/one-shot.server.ts +4 -2
- package/src/server/lib/harness/acp/prewarm.server.ts +21 -16
- package/src/server/lib/harness/acp/session-background.test.ts +2 -1
- package/src/server/lib/harness/acp/session-intake.test.ts +8 -0
- package/src/server/lib/harness/acp/session-intake.ts +12 -3
- package/src/server/lib/harness/acp/session-options.ts +2 -0
- package/src/server/lib/harness/acp/session-process.ts +1 -0
- package/src/server/lib/harness/acp/session-wiring.test.ts +2 -0
- package/src/server/lib/harness/acp/session-wiring.ts +22 -0
- package/src/server/lib/harness/acp/session.ts +3 -3
- package/src/server/lib/harness/acp/stdio.test.ts +52 -0
- package/src/server/lib/harness/acp/stdio.ts +7 -1
- package/src/server/lib/harness/auto-probe.server.ts +2 -2
- package/src/server/lib/harness/launch-table.ts +6 -1
- package/src/server/lib/harness/launch.ts +1 -0
- package/src/server/lib/harness/schema.server.ts +37 -0
- package/src/server/lib/harness/session-delete.server.ts +4 -2
- package/src/server/lib/harness/session-import.server.ts +21 -7
- package/src/server/lib/harness/session-store.server.test.ts +12 -0
- package/src/server/lib/harness/session-store.server.ts +21 -6
- package/src/server/lib/harness/session-transcript.server.ts +2 -1
- package/src/server/lib/harness/spawn.server.ts +27 -6
- package/src/server/lib/models/provider-icon-fetch.test.ts +57 -3
- package/src/server/lib/models/provider-icon-fetch.ts +9 -1
- package/src/server/lib/models/provider-icon-store.server.ts +61 -0
- package/src/server/lib/models/provider-icon-store.test.ts +55 -0
- package/src/server/lib/models/provider-icon-svg.ts +57 -0
- package/src/server/lib/schedule/runtime.server.ts +4 -1
- package/src/server/lib/sessions/dispatch.server.ts +4 -1
- package/src/server/lib/sessions/fork.server.ts +2 -0
- package/src/server/lib/sessions/resolve.server.ts +4 -0
- package/src/server/lib/sessions/spawn.server.ts +4 -2
- package/src/server/lib/tts/engines/adapters.test.ts +33 -0
- package/src/server/lib/tts/engines/elevenlabs.ts +6 -0
- package/src/server/lib/tts/engines/gemini.ts +116 -0
- package/src/server/lib/tts/engines/index.ts +3 -0
- package/src/server/lib/tts/engines/openai.ts +21 -4
- package/src/server/lib/usage/antigravity-quota.test.ts +249 -0
- package/src/server/lib/usage/antigravity-quota.ts +197 -0
- package/src/server/lib/usage/antigravity.test.ts +20 -0
- package/src/server/lib/usage/antigravity.ts +267 -0
- package/src/server/lib/usage/index-harness.test.ts +162 -0
- package/src/server/lib/usage/index-parse.test.ts +1 -0
- package/src/server/lib/usage/index-parse.ts +12 -4
- package/src/server/lib/usage/index-query.server.ts +64 -2
- package/src/server/lib/usage/index-scan.server.ts +68 -152
- package/src/server/lib/usage/index-schema.server.ts +24 -8
- package/src/server/lib/usage/index-schema.test.ts +54 -0
- package/src/server/lib/usage/index-sources.server.ts +54 -0
- package/src/server/lib/usage/providers.server.test.ts +67 -1
- package/src/server/lib/usage/providers.server.ts +82 -3
- package/src/server/lib/usage/sources/claude.server.ts +187 -0
- package/src/server/lib/usage/sources/claude.test.ts +86 -0
- package/src/server/lib/usage/sources/codex.server.ts +155 -0
- package/src/server/lib/usage/sources/codex.test.ts +53 -0
- package/src/server/lib/usage/sources/dsh.server.ts +120 -0
- package/src/server/lib/usage/sources/dsh.test.ts +49 -0
- package/src/server/lib/usage/sources/helpers.ts +191 -0
- package/src/server/lib/usage/sources/jsonl.server.ts +78 -0
- package/src/server/lib/usage/sources/jsonl.test.ts +72 -0
- package/src/server/lib/usage/sources/omp.server.ts +124 -0
- package/src/server/lib/usage/sources/opencode.server.ts +203 -0
- package/src/server/lib/usage/sources/opencode.test.ts +104 -0
- package/src/server/lib/usage/sources/qwen.server.ts +122 -0
- package/src/server/lib/usage/sources/qwen.test.ts +62 -0
- package/src/server/lib/usage/sources/types.ts +53 -0
- package/src/server/lib/usage/sources/zcode.server.ts +131 -0
- package/src/server/lib/usage/sources/zcode.test.ts +87 -0
- package/src/server/routes/agent/harness-command.ts +2 -0
- package/src/server/routes/agent/prewarm.ts +7 -2
- package/src/server/routes/harness/accounts.test.ts +99 -0
- package/src/server/routes/harness/accounts.ts +106 -0
- package/src/server/routes/harness/root.ts +13 -1
- package/src/server/routes/sessions/local-image.ts +2 -2
- package/src/server/routes/telemetry/tokens.test.ts +20 -0
- package/src/server/routes/telemetry/tokens.ts +12 -3
- package/src/server/routes/tts/speak.test.ts +40 -0
- package/src/shared/lib/harness/accounts.test.ts +41 -0
- package/src/shared/lib/harness/accounts.ts +175 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +26 -25
- package/src/shared/lib/markdown/ascii-art.test.ts +154 -0
- package/src/shared/lib/markdown/ascii-art.ts +158 -0
- package/src/shared/lib/markdown/marked.ts +24 -2
- package/src/shared/lib/models/provider/identity.test.ts +34 -0
- package/src/shared/lib/models/provider/identity.ts +28 -0
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/tts/engines.test.ts +12 -0
- package/src/shared/lib/tts/engines.ts +58 -57
- package/src/shared/lib/tts/settings.ts +1 -1
- package/src/shared/lib/tts/voices.ts +98 -0
- package/src/shared/lib/workspace/right-side-hidden.ts +57 -0
- package/src/shared/lib/workspace/session-state/store.ts +7 -5
- package/src/shared/types/harness.ts +5 -0
- package/src/shared/types/settings/state.ts +12 -0
- package/src/shared/types/tokenUsage.ts +21 -0
- package/src/test-support/preload.ts +9 -0
- package/dist/client/static/js/ImageView-g50pk5pt.js +0 -1
- package/dist/client/static/js/MergeDiffView-c4mb8m1w.js +0 -1
- package/dist/client/static/js/Modal-pf9p6m1k.js +0 -59
- package/dist/client/static/js/architecture-7GRP2DOG-ee9wjsht.js +0 -1
- package/dist/client/static/js/architectureDiagram-NJMV4G6O-278nx8rt.js +0 -36
- package/dist/client/static/js/bash-36shcpcw.js +0 -1
- package/dist/client/static/js/c-kxeqssf9.js +0 -1
- package/dist/client/static/js/cose-bilkent-JH36ORCC-ydq7mvy0.js +0 -1
- package/dist/client/static/js/cpp-wtk1s3d7.js +0 -1
- package/dist/client/static/js/css-0a0r6rp3.js +0 -1
- package/dist/client/static/js/css-xhnrhg4e.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-gs16zjqa.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-ftz7zrz5.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-ax0qfmp3.js +0 -1
- package/dist/client/static/js/ganttDiagram-FUAMR5RP-49jd7msz.js +0 -292
- package/dist/client/static/js/gitGraph-4MIJSDKK-3rtkds4s.js +0 -1
- package/dist/client/static/js/gitGraphDiagram-X574FWY7-5p9mgq7n.js +0 -106
- package/dist/client/static/js/graphql-w9ajhndp.js +0 -1
- package/dist/client/static/js/html-krfbq5wp.js +0 -1
- package/dist/client/static/js/index-05n22cg9.js +0 -4
- package/dist/client/static/js/index-2jgx68m0.js +0 -1
- package/dist/client/static/js/index-333rq9yy.js +0 -1
- package/dist/client/static/js/index-38g2eevc.js +0 -314
- package/dist/client/static/js/index-9wc36am3.css +0 -1
- package/dist/client/static/js/index-bvpzzhn2.js +0 -4
- package/dist/client/static/js/index-e19dbqd3.js +0 -2
- package/dist/client/static/js/index-yr3exz70.js +0 -2
- package/dist/client/static/js/index-zdw8bd5t.js +0 -2
- package/dist/client/static/js/index-zyefab6q.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-vr5mxm6f.js +0 -1
- package/dist/client/static/js/ini-zx7x1jj1.js +0 -1
- package/dist/client/static/js/java-bbw6kdcr.js +0 -1
- package/dist/client/static/js/javascript-p2a8rbpw.js +0 -1
- package/dist/client/static/js/json-zh7m2fyg.js +0 -1
- package/dist/client/static/js/jsx-3zyyt0eh.js +0 -1
- package/dist/client/static/js/lua-d656k76a.js +0 -1
- package/dist/client/static/js/markdown-b5w681mm.js +0 -1
- package/dist/client/static/js/one-dark-pro-z965dedc.js +0 -1
- package/dist/client/static/js/one-light-capdx801.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-ncb5xxtn.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-ff8fpvc4.js +0 -1
- package/dist/client/static/js/properties-3c6rmnqp.js +0 -1
- package/dist/client/static/js/python-a3x3zpv1.js +0 -1
- package/dist/client/static/js/quadrantDiagram-O4NWA36T-sz4afnp1.js +0 -7
- package/dist/client/static/js/r-7h3gwype.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-gbj4b1hf.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-ndv5tqgr.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-yjzj09s1.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e6pw7e5z.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-9734dxy4.js +0 -1
- package/dist/client/static/js/sql-7a5vavm0.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-z4pt2kn1.js +0 -8
- package/dist/client/static/js/timeline-definition-EJHVYXUP-ezm1c4pz.js +0 -120
- package/dist/client/static/js/treeView-Q6P3EWNA-rs10d4p5.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-ey6c5x9f.js +0 -1
- package/dist/client/static/js/tsx-4a9b8tqf.js +0 -1
- package/dist/client/static/js/typescript-kas107wb.js +0 -1
- package/dist/client/static/js/vennDiagram-UO4OBE2U-rd5prsf1.js +0 -34
- package/dist/client/static/js/wardley-WFR3VGLG-kd9swrdr.js +0 -1
- package/dist/client/static/js/xml-3g4bdtpa.js +0 -1
- package/dist/client/static/js/yaml-ktxjn917.js +0 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sign-in as a server-side process, with Kabmo drawing the result.
|
|
8
|
+
*
|
|
9
|
+
* The CLI still needs a TTY (it prints a link, reads a code, or both), so this
|
|
10
|
+
* spawns it on a PTY. What it does NOT need is a terminal UI: output is decoded,
|
|
11
|
+
* ANSI is stripped, and the auth URL and the last lines are returned to the
|
|
12
|
+
* settings panel. The user pastes a code back through the same PTY.
|
|
13
|
+
*
|
|
14
|
+
* A job is one account and one process. Starting again replaces a finished job;
|
|
15
|
+
* a running job is returned instead of spawning twice. Cancel kills the tree;
|
|
16
|
+
* a normal exit keeps the final state for the UI to read.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { accountAdapter, type AccountHarness } from '@/shared/lib/harness/accounts';
|
|
20
|
+
import { harnessAccountTarget } from '@/server/lib/harness/accounts.server';
|
|
21
|
+
import { killProcessTree } from '@/server/lib/lifecycle/kill-tree';
|
|
22
|
+
|
|
23
|
+
export type AccountLoginPhase = 'running' | 'done' | 'error' | 'cancelled';
|
|
24
|
+
|
|
25
|
+
export interface AccountLoginView {
|
|
26
|
+
phase: AccountLoginPhase;
|
|
27
|
+
url: string | null;
|
|
28
|
+
/** The most recent sanitized output, one string per line. */
|
|
29
|
+
lines: string[];
|
|
30
|
+
error: string | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface LoginJob {
|
|
34
|
+
accountId: string;
|
|
35
|
+
harness: AccountHarness;
|
|
36
|
+
homePath: string;
|
|
37
|
+
phase: AccountLoginPhase;
|
|
38
|
+
url: string | null;
|
|
39
|
+
raw: string;
|
|
40
|
+
error: string | null;
|
|
41
|
+
child: Bun.Subprocess | null;
|
|
42
|
+
term: Bun.Terminal | null;
|
|
43
|
+
decoder: TextDecoder;
|
|
44
|
+
timeout: NodeJS.Timeout | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare global {
|
|
48
|
+
// eslint-disable-next-line no-var
|
|
49
|
+
var __kabmoAccountLogins: Map<string, LoginJob> | undefined;
|
|
50
|
+
// eslint-disable-next-line no-var
|
|
51
|
+
var __kabmoAccountLoginCleanup: boolean | undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const jobs = (): Map<string, LoginJob> => (globalThis.__kabmoAccountLogins ??= new Map());
|
|
55
|
+
|
|
56
|
+
/** One listener for every job: a detached PTY must not outlive the server. */
|
|
57
|
+
function installExitCleanup(): void {
|
|
58
|
+
if (globalThis.__kabmoAccountLoginCleanup) return;
|
|
59
|
+
globalThis.__kabmoAccountLoginCleanup = true;
|
|
60
|
+
process.once('exit', () => {
|
|
61
|
+
for (const job of jobs().values()) {
|
|
62
|
+
try {
|
|
63
|
+
job.child?.kill();
|
|
64
|
+
} catch {
|
|
65
|
+
// Already gone.
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const MAX_OUTPUT = 64_000;
|
|
71
|
+
const LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
72
|
+
const FORGET_AFTER_MS = 10 * 60 * 1000;
|
|
73
|
+
|
|
74
|
+
/** Strip the terminal control bytes a PTY emits before a line reaches the UI. */
|
|
75
|
+
export function cleanLoginText(text: string): string {
|
|
76
|
+
return text
|
|
77
|
+
.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)/g, '')
|
|
78
|
+
.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g, '')
|
|
79
|
+
.replace(/\x1b[()][A-Z0-9]/g, '')
|
|
80
|
+
.replace(/\r/g, '');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const URL_PATTERN = /https?:\/\/[^\s"'<>]+/g;
|
|
84
|
+
|
|
85
|
+
/** The link a user has to open, preferring an OAuth page over a local server. */
|
|
86
|
+
export function extractLoginUrl(text: string): string | null {
|
|
87
|
+
const urls = [...cleanLoginText(text).matchAll(URL_PATTERN)]
|
|
88
|
+
.map((match) => match[0].replace(/[),.;]+$/, ''))
|
|
89
|
+
.filter((url) => url.length > 8);
|
|
90
|
+
if (urls.length === 0) return null;
|
|
91
|
+
const auth = urls.filter((url) => /authorize|oauth|device|login|signin|auth/i.test(url));
|
|
92
|
+
const notLocal = auth.filter((url) => !/^https?:\/\/(?:localhost|127\.0\.0\.1)[:/]/i.test(url));
|
|
93
|
+
return notLocal.at(-1) ?? auth.at(-1) ?? urls.at(-1) ?? null;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function linesOf(raw: string): string[] {
|
|
97
|
+
return cleanLoginText(raw)
|
|
98
|
+
.split('\n')
|
|
99
|
+
.map((line) => line.trimEnd())
|
|
100
|
+
.filter((line) => line.trim().length > 0)
|
|
101
|
+
.slice(-14);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function viewOf(job: LoginJob): AccountLoginView {
|
|
105
|
+
return {
|
|
106
|
+
phase: job.phase,
|
|
107
|
+
url: job.url,
|
|
108
|
+
lines: linesOf(job.raw),
|
|
109
|
+
error: job.error,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function append(job: LoginJob, bytes: Uint8Array): void {
|
|
114
|
+
job.raw = (job.raw + job.decoder.decode(bytes, { stream: true })).slice(-MAX_OUTPUT);
|
|
115
|
+
job.url = job.url ?? extractLoginUrl(job.raw);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function finish(job: LoginJob, code: number | null): void {
|
|
119
|
+
if (job.phase === 'cancelled') return;
|
|
120
|
+
job.phase = code === 0 ? 'done' : 'error';
|
|
121
|
+
if (code !== 0) job.error = `The sign-in command exited with code ${code ?? 'unknown'}.`;
|
|
122
|
+
job.term?.close();
|
|
123
|
+
job.term = null;
|
|
124
|
+
if (job.timeout) clearTimeout(job.timeout);
|
|
125
|
+
job.timeout = null;
|
|
126
|
+
const timer = setTimeout(() => {
|
|
127
|
+
if (jobs().get(job.accountId) === job) jobs().delete(job.accountId);
|
|
128
|
+
}, FORGET_AFTER_MS);
|
|
129
|
+
timer.unref?.();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface StartAccountLoginOptions {
|
|
133
|
+
/** Test seam: replace the adapter's binary and arguments. */
|
|
134
|
+
command?: readonly string[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export async function startAccountLogin(
|
|
138
|
+
accountId: string,
|
|
139
|
+
options: StartAccountLoginOptions = {},
|
|
140
|
+
): Promise<AccountLoginView> {
|
|
141
|
+
const existing = jobs().get(accountId);
|
|
142
|
+
if (existing && existing.phase === 'running') return viewOf(existing);
|
|
143
|
+
|
|
144
|
+
const target = await harnessAccountTarget(accountId);
|
|
145
|
+
const adapter = accountAdapter(target.harness);
|
|
146
|
+
if (!adapter) throw new Error(`${target.harness} does not support saved accounts.`);
|
|
147
|
+
const command = options.command ?? [adapter.loginBinary, ...adapter.loginArgs];
|
|
148
|
+
const env: Record<string, string | undefined> = { ...Bun.env };
|
|
149
|
+
for (const name of adapter.stripEnv) delete env[name];
|
|
150
|
+
Object.assign(env, adapter.env(target.homePath));
|
|
151
|
+
|
|
152
|
+
const job: LoginJob = {
|
|
153
|
+
accountId,
|
|
154
|
+
harness: target.harness,
|
|
155
|
+
homePath: target.homePath,
|
|
156
|
+
phase: 'running',
|
|
157
|
+
url: null,
|
|
158
|
+
raw: '',
|
|
159
|
+
error: null,
|
|
160
|
+
child: null,
|
|
161
|
+
term: null,
|
|
162
|
+
decoder: new TextDecoder(),
|
|
163
|
+
timeout: null,
|
|
164
|
+
};
|
|
165
|
+
jobs().set(accountId, job);
|
|
166
|
+
|
|
167
|
+
const term = new Bun.Terminal({
|
|
168
|
+
cols: 500,
|
|
169
|
+
rows: 50,
|
|
170
|
+
name: 'xterm-256color',
|
|
171
|
+
data(_term, bytes) {
|
|
172
|
+
append(job, bytes);
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
job.term = term;
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
const child = Bun.spawn({
|
|
179
|
+
cmd: [...command],
|
|
180
|
+
cwd: target.homePath,
|
|
181
|
+
env,
|
|
182
|
+
terminal: term,
|
|
183
|
+
detached: process.platform !== 'win32',
|
|
184
|
+
});
|
|
185
|
+
job.child = child;
|
|
186
|
+
job.timeout = setTimeout(() => {
|
|
187
|
+
job.phase = 'error';
|
|
188
|
+
job.error = 'Sign-in timed out after five minutes.';
|
|
189
|
+
killProcessTree(child.pid, true, 'SIGTERM');
|
|
190
|
+
}, LOGIN_TIMEOUT_MS);
|
|
191
|
+
job.timeout.unref?.();
|
|
192
|
+
void child.exited.then((code) => finish(job, code));
|
|
193
|
+
installExitCleanup();
|
|
194
|
+
} catch (error) {
|
|
195
|
+
job.phase = 'error';
|
|
196
|
+
job.error = error instanceof Error ? error.message : 'Could not start the sign-in command.';
|
|
197
|
+
term.close();
|
|
198
|
+
job.term = null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return viewOf(job);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function accountLoginStatus(accountId: string): AccountLoginView | null {
|
|
205
|
+
const job = jobs().get(accountId);
|
|
206
|
+
return job ? viewOf(job) : null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function submitAccountLoginInput(accountId: string, text: string): AccountLoginView {
|
|
210
|
+
const job = jobs().get(accountId);
|
|
211
|
+
if (!job || job.phase !== 'running' || !job.term) {
|
|
212
|
+
throw new Error('That sign-in is no longer running.');
|
|
213
|
+
}
|
|
214
|
+
job.term.write(`${text}\r`);
|
|
215
|
+
return viewOf(job);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function cancelAccountLogin(accountId: string): void {
|
|
219
|
+
const job = jobs().get(accountId);
|
|
220
|
+
if (!job) return;
|
|
221
|
+
if (job.phase !== 'running') {
|
|
222
|
+
jobs().delete(accountId);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
job.phase = 'cancelled';
|
|
226
|
+
job.error = null;
|
|
227
|
+
if (job.timeout) clearTimeout(job.timeout);
|
|
228
|
+
job.timeout = null;
|
|
229
|
+
if (job.child?.pid) killProcessTree(job.child.pid, true, 'SIGTERM');
|
|
230
|
+
job.term?.close();
|
|
231
|
+
job.term = null;
|
|
232
|
+
}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Saved CLI homes for Codex, Claude and Antigravity.
|
|
8
|
+
*
|
|
9
|
+
* A row is a pointer to a directory the agent itself owns. Kabmo creates the
|
|
10
|
+
* directory with a marker, remembers which account is active, and resolves the
|
|
11
|
+
* launch env from that row. It never stores the token: the CLI writes it.
|
|
12
|
+
*
|
|
13
|
+
* A missing or foreign marker is a refusal, not a directory to reuse. Writing a
|
|
14
|
+
* login into a home this server cannot prove it created is how one account's
|
|
15
|
+
* credential lands in another account's folder.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
|
|
19
|
+
import { join, resolve } from 'node:path';
|
|
20
|
+
import { getDb } from '@/server/db.server';
|
|
21
|
+
import { getDataDir } from '@/server/lib/lifecycle/paths';
|
|
22
|
+
import { forgetProbe } from '@/server/lib/harness/probe-cache.server';
|
|
23
|
+
import { readAccountIdentity } from '@/server/lib/harness/account-identity.server';
|
|
24
|
+
import { resolveLaunch } from '@/server/lib/harness/config.server';
|
|
25
|
+
import type { HarnessLaunch } from '@/server/lib/harness/launch-table';
|
|
26
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
27
|
+
import type { HarnessConfig } from '@/shared/lib/harness/config';
|
|
28
|
+
import {
|
|
29
|
+
accountAdapter,
|
|
30
|
+
accountLoginCommand,
|
|
31
|
+
type AccountHarness,
|
|
32
|
+
type HarnessAccountIdentity,
|
|
33
|
+
type HarnessAccountsState,
|
|
34
|
+
type HarnessAccountView,
|
|
35
|
+
} from '@/shared/lib/harness/accounts';
|
|
36
|
+
|
|
37
|
+
interface AccountRow {
|
|
38
|
+
id: string;
|
|
39
|
+
harness: AccountHarness;
|
|
40
|
+
label: string;
|
|
41
|
+
home_path: string;
|
|
42
|
+
identity: string;
|
|
43
|
+
auth_kind: string;
|
|
44
|
+
created_at: number;
|
|
45
|
+
updated_at: number;
|
|
46
|
+
verified_at: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const ACCOUNT_ID = /^[a-f0-9-]{36}$/;
|
|
50
|
+
|
|
51
|
+
export class HarnessAccountError extends Error {
|
|
52
|
+
constructor(message: string) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = 'HarnessAccountError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
class AccountHomeGoneError extends HarnessAccountError {}
|
|
59
|
+
|
|
60
|
+
function parseIdentity(raw: string): HarnessAccountIdentity {
|
|
61
|
+
try {
|
|
62
|
+
const value: unknown = JSON.parse(raw);
|
|
63
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return {};
|
|
64
|
+
const source = value as Record<string, unknown>;
|
|
65
|
+
return {
|
|
66
|
+
...(typeof source.email === 'string' ? { email: source.email } : {}),
|
|
67
|
+
...(typeof source.subject === 'string' ? { subject: source.subject } : {}),
|
|
68
|
+
...(typeof source.organization === 'string' ? { organization: source.organization } : {}),
|
|
69
|
+
};
|
|
70
|
+
} catch {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function loadRows(): Promise<AccountRow[]> {
|
|
76
|
+
const db = await getDb();
|
|
77
|
+
return db.all<AccountRow>(
|
|
78
|
+
`SELECT id, harness, label, home_path, identity, auth_kind, created_at, updated_at, verified_at
|
|
79
|
+
FROM harness_accounts
|
|
80
|
+
ORDER BY created_at ASC`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function loadRow(id: string): Promise<AccountRow | null> {
|
|
85
|
+
if (!ACCOUNT_ID.test(id)) return null;
|
|
86
|
+
const db = await getDb();
|
|
87
|
+
return (await db.get<AccountRow>(
|
|
88
|
+
`SELECT id, harness, label, home_path, identity, auth_kind, created_at, updated_at, verified_at
|
|
89
|
+
FROM harness_accounts WHERE id = ?`,
|
|
90
|
+
[id],
|
|
91
|
+
)) ?? null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function loadSelected(): Promise<Record<string, string | null>> {
|
|
95
|
+
const db = await getDb();
|
|
96
|
+
const rows = await db.all<{ harness: string; account_id: string }>(
|
|
97
|
+
'SELECT harness, account_id FROM harness_account_selection',
|
|
98
|
+
);
|
|
99
|
+
return Object.fromEntries(rows.map((row) => [row.harness, row.account_id]));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function saveSelection(harness: AccountHarness, accountId: string | null): Promise<void> {
|
|
103
|
+
const db = await getDb();
|
|
104
|
+
if (accountId === null) {
|
|
105
|
+
await db.run('DELETE FROM harness_account_selection WHERE harness = ?', [harness]);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
await db.run(
|
|
109
|
+
'INSERT OR REPLACE INTO harness_account_selection (harness, account_id) VALUES (?, ?)',
|
|
110
|
+
[harness, accountId],
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function homeFor(id: string): string {
|
|
115
|
+
return join(getDataDir(), 'harness-accounts', id);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const markerFor = (id: string) => join(homeFor(id), '.kabmo-account');
|
|
119
|
+
|
|
120
|
+
async function assertHomeOwned(row: AccountRow): Promise<void> {
|
|
121
|
+
if (resolve(row.home_path) !== resolve(homeFor(row.id))) {
|
|
122
|
+
throw new HarnessAccountError(`The home for ${row.label} is outside Kabmo's account storage.`);
|
|
123
|
+
}
|
|
124
|
+
const marker = markerFor(row.id);
|
|
125
|
+
let stored: string;
|
|
126
|
+
try {
|
|
127
|
+
stored = (await readFile(marker, 'utf8')).trim();
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
|
|
130
|
+
throw new HarnessAccountError(`The home for ${row.label} could not be read.`);
|
|
131
|
+
}
|
|
132
|
+
const present = await stat(homeFor(row.id)).then(() => true, () => false);
|
|
133
|
+
if (!present) throw new AccountHomeGoneError(`The home for ${row.label} is gone.`);
|
|
134
|
+
throw new HarnessAccountError(`The home for ${row.label} is missing its Kabmo marker.`);
|
|
135
|
+
}
|
|
136
|
+
if (stored !== row.id) {
|
|
137
|
+
throw new HarnessAccountError(`The home for ${row.label} belongs to a different account.`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function state(rows?: AccountRow[]): Promise<HarnessAccountsState> {
|
|
142
|
+
const all = rows ?? (await loadRows());
|
|
143
|
+
const selected = await loadSelected();
|
|
144
|
+
const loginShell = process.platform === 'win32' ? 'win32' : 'posix';
|
|
145
|
+
const accounts: HarnessAccountView[] = [];
|
|
146
|
+
for (const row of all) {
|
|
147
|
+
const adapter = accountAdapter(row.harness);
|
|
148
|
+
if (!adapter) continue;
|
|
149
|
+
let read;
|
|
150
|
+
try {
|
|
151
|
+
await assertHomeOwned(row);
|
|
152
|
+
read = await readAccountIdentity(row.harness, row.home_path);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
read = {
|
|
155
|
+
identity: {},
|
|
156
|
+
authKind: 'unknown',
|
|
157
|
+
signedIn: false,
|
|
158
|
+
detail: error instanceof Error ? error.message : 'This account home is unavailable.',
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const known = parseIdentity(row.identity);
|
|
162
|
+
accounts.push({
|
|
163
|
+
id: row.id,
|
|
164
|
+
harness: row.harness,
|
|
165
|
+
label: row.label,
|
|
166
|
+
homePath: row.home_path,
|
|
167
|
+
identity: read.signedIn
|
|
168
|
+
? (Object.keys(known).length > 0 ? known : read.identity)
|
|
169
|
+
: {},
|
|
170
|
+
authKind: read.authKind,
|
|
171
|
+
signedIn: read.signedIn,
|
|
172
|
+
detail: read.detail,
|
|
173
|
+
loginCommand: accountLoginCommand(adapter, row.home_path, loginShell),
|
|
174
|
+
createdAt: row.created_at,
|
|
175
|
+
verifiedAt: row.verified_at,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
const ids = new Set(accounts.map((account) => account.id));
|
|
179
|
+
for (const [harness, id] of Object.entries(selected)) {
|
|
180
|
+
if (id && !ids.has(id)) selected[harness] = null;
|
|
181
|
+
}
|
|
182
|
+
return { accounts, selected };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export async function listHarnessAccounts(): Promise<HarnessAccountsState> {
|
|
186
|
+
return state();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Selected account for a harness, or null for the host login. */
|
|
190
|
+
export async function selectedAccountId(harness: string): Promise<string | null> {
|
|
191
|
+
const selected = await loadSelected();
|
|
192
|
+
const id = selected[harness];
|
|
193
|
+
if (!id) return null;
|
|
194
|
+
const row = await loadRow(id);
|
|
195
|
+
return row?.harness === harness ? row.id : null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The launch line a spawn uses, with the selected or named account applied.
|
|
200
|
+
*
|
|
201
|
+
* `accountId` undefined means "the selected account"; null means "the host
|
|
202
|
+
* login" and is what a chat resumed from a pre-account row passes.
|
|
203
|
+
*/
|
|
204
|
+
export async function resolveAccountLaunch(
|
|
205
|
+
harness: string,
|
|
206
|
+
config: HarnessConfig,
|
|
207
|
+
accountId?: string | null,
|
|
208
|
+
): Promise<HarnessLaunch> {
|
|
209
|
+
const launch = resolveLaunch(harness as HarnessId, config);
|
|
210
|
+
const adapter = accountAdapter(harness);
|
|
211
|
+
if (!adapter) return launch;
|
|
212
|
+
const id = accountId === undefined ? await selectedAccountId(harness) : accountId;
|
|
213
|
+
if (!id) return launch;
|
|
214
|
+
const row = await loadRow(id);
|
|
215
|
+
if (!row || row.harness !== harness) {
|
|
216
|
+
throw new HarnessAccountError('The selected account no longer exists.');
|
|
217
|
+
}
|
|
218
|
+
await assertHomeOwned(row);
|
|
219
|
+
return {
|
|
220
|
+
...launch,
|
|
221
|
+
env: { ...(launch.env ?? {}), ...adapter.env(row.home_path) },
|
|
222
|
+
stripEnv: [...new Set([...(launch.stripEnv ?? []), ...adapter.stripEnv])],
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface HarnessAccountTarget {
|
|
227
|
+
id: string;
|
|
228
|
+
harness: AccountHarness;
|
|
229
|
+
label: string;
|
|
230
|
+
homePath: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The home a login process should run in, after the ownership check. */
|
|
234
|
+
export async function harnessAccountTarget(accountId: string): Promise<HarnessAccountTarget> {
|
|
235
|
+
const row = await loadRow(accountId);
|
|
236
|
+
if (!row) throw new HarnessAccountError('That account no longer exists.');
|
|
237
|
+
await assertHomeOwned(row);
|
|
238
|
+
return { id: row.id, harness: row.harness, label: row.label, homePath: row.home_path };
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export async function createHarnessAccount(
|
|
242
|
+
harness: string,
|
|
243
|
+
label?: string,
|
|
244
|
+
): Promise<HarnessAccountsState & { createdId: string }> {
|
|
245
|
+
const adapter = accountAdapter(harness);
|
|
246
|
+
if (!adapter) throw new HarnessAccountError(`${harness} does not support saved accounts.`);
|
|
247
|
+
const id = crypto.randomUUID();
|
|
248
|
+
const home = homeFor(id);
|
|
249
|
+
await mkdir(home, { recursive: true, mode: 0o700 });
|
|
250
|
+
await writeFile(markerFor(id), `${id}\n`, { mode: 0o600 });
|
|
251
|
+
const now = Date.now();
|
|
252
|
+
const db = await getDb();
|
|
253
|
+
const count = await db.get<{ n: number }>(
|
|
254
|
+
'SELECT COUNT(*) AS n FROM harness_accounts WHERE harness = ?',
|
|
255
|
+
[harness],
|
|
256
|
+
);
|
|
257
|
+
const name = label?.trim().slice(0, 80) || `${adapter.label} account ${(count?.n ?? 0) + 1}`;
|
|
258
|
+
await db.run(
|
|
259
|
+
`INSERT INTO harness_accounts
|
|
260
|
+
(id, harness, label, home_path, identity, auth_kind, created_at, updated_at, verified_at)
|
|
261
|
+
VALUES (?, ?, ?, ?, '{}', 'unknown', ?, ?, 0)`,
|
|
262
|
+
[id, harness, name, home, now, now],
|
|
263
|
+
);
|
|
264
|
+
if (!(await selectedAccountId(harness))) await saveSelection(adapter.harness, id);
|
|
265
|
+
await forgetProbe(adapter.harness);
|
|
266
|
+
return { ...(await state()), createdId: id };
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export async function selectHarnessAccount(
|
|
270
|
+
harness: string,
|
|
271
|
+
accountId: string | null,
|
|
272
|
+
): Promise<HarnessAccountsState> {
|
|
273
|
+
const adapter = accountAdapter(harness);
|
|
274
|
+
if (!adapter) throw new HarnessAccountError(`${harness} does not support saved accounts.`);
|
|
275
|
+
if (accountId) {
|
|
276
|
+
const row = await loadRow(accountId);
|
|
277
|
+
if (!row || row.harness !== adapter.harness) {
|
|
278
|
+
throw new HarnessAccountError('That account does not belong to this harness.');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
await saveSelection(adapter.harness, accountId);
|
|
282
|
+
await forgetProbe(adapter.harness);
|
|
283
|
+
return state();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export async function renameHarnessAccount(
|
|
287
|
+
accountId: string,
|
|
288
|
+
label: string,
|
|
289
|
+
): Promise<HarnessAccountsState> {
|
|
290
|
+
const row = await loadRow(accountId);
|
|
291
|
+
if (!row) throw new HarnessAccountError('That account no longer exists.');
|
|
292
|
+
const name = label.trim().slice(0, 80);
|
|
293
|
+
if (!name) throw new HarnessAccountError('An account name cannot be empty.');
|
|
294
|
+
const db = await getDb();
|
|
295
|
+
await db.run('UPDATE harness_accounts SET label = ?, updated_at = ? WHERE id = ?', [
|
|
296
|
+
name,
|
|
297
|
+
Date.now(),
|
|
298
|
+
row.id,
|
|
299
|
+
]);
|
|
300
|
+
return state();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export async function verifyHarnessAccount(
|
|
304
|
+
accountId: string,
|
|
305
|
+
): Promise<HarnessAccountsState & { signedIn: boolean; detail: string }> {
|
|
306
|
+
const row = await loadRow(accountId);
|
|
307
|
+
if (!row) throw new HarnessAccountError('That account no longer exists.');
|
|
308
|
+
const read = await readAccountIdentity(row.harness, row.home_path);
|
|
309
|
+
const db = await getDb();
|
|
310
|
+
await db.run(
|
|
311
|
+
`UPDATE harness_accounts
|
|
312
|
+
SET identity = ?, auth_kind = ?, verified_at = ?, updated_at = ?
|
|
313
|
+
WHERE id = ?`,
|
|
314
|
+
[JSON.stringify(read.identity), read.authKind, Date.now(), Date.now(), row.id],
|
|
315
|
+
);
|
|
316
|
+
await forgetProbe(row.harness);
|
|
317
|
+
return { ...(await state()), signedIn: read.signedIn, detail: read.detail };
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export async function removeHarnessAccount(accountId: string): Promise<HarnessAccountsState> {
|
|
321
|
+
const row = await loadRow(accountId);
|
|
322
|
+
if (!row) throw new HarnessAccountError('That account no longer exists.');
|
|
323
|
+
const home = homeFor(row.id);
|
|
324
|
+
try {
|
|
325
|
+
await assertHomeOwned(row);
|
|
326
|
+
await rm(home, { recursive: true, force: true });
|
|
327
|
+
} catch (error) {
|
|
328
|
+
// A home already gone is a successful removal; a foreign home is not.
|
|
329
|
+
if (!(error instanceof AccountHomeGoneError)) throw error;
|
|
330
|
+
}
|
|
331
|
+
const db = await getDb();
|
|
332
|
+
await db.run('DELETE FROM harness_accounts WHERE id = ?', [row.id]);
|
|
333
|
+
await db.run('DELETE FROM harness_account_selection WHERE harness = ? AND account_id = ?', [
|
|
334
|
+
row.harness,
|
|
335
|
+
row.id,
|
|
336
|
+
]);
|
|
337
|
+
await forgetProbe(row.harness);
|
|
338
|
+
return state();
|
|
339
|
+
}
|