@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
|
@@ -21,8 +21,13 @@ import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
|
21
21
|
export interface HarnessLaunch {
|
|
22
22
|
id: HarnessId;
|
|
23
23
|
command: string[];
|
|
24
|
-
/** Extra env the adapter needs (a wrapper path, a log dir,
|
|
24
|
+
/** Extra env the adapter needs (a wrapper path, a log dir, ...). */
|
|
25
25
|
env?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Ambient variables removed before `env` is applied. Saved accounts use this
|
|
28
|
+
* so a host `ANTHROPIC_API_KEY` cannot authenticate the wrong login.
|
|
29
|
+
*/
|
|
30
|
+
stripEnv?: readonly string[];
|
|
26
31
|
/**
|
|
27
32
|
* A binary the launch line SPAWNS but does not exec itself. The `zcode`
|
|
28
33
|
* bridge starts `zcode app-server --stdio`, so `npx` being present says
|
|
@@ -165,6 +165,7 @@ export async function probeHarness(
|
|
|
165
165
|
command: launch.command,
|
|
166
166
|
cwd,
|
|
167
167
|
...(env ? { env } : {}),
|
|
168
|
+
...(launch.stripEnv ? { envDrop: launch.stripEnv } : {}),
|
|
168
169
|
onStderr: (line) => {
|
|
169
170
|
stderrTail = `${stderrTail}${line}\n`.slice(-2_000);
|
|
170
171
|
},
|
|
@@ -32,6 +32,9 @@ const HARNESS_SESSIONS_SQL = `
|
|
|
32
32
|
-- Kabmo's own (omp generates it and both sides use it).
|
|
33
33
|
agent_session_id TEXT NOT NULL DEFAULT '',
|
|
34
34
|
cwd TEXT NOT NULL DEFAULT '',
|
|
35
|
+
-- The saved account whose home spawned this chat. Empty means the host
|
|
36
|
+
-- login, which is what every row written before accounts existed means.
|
|
37
|
+
account_id TEXT NOT NULL DEFAULT '',
|
|
35
38
|
-- What the chat is CALLED. An ACP agent writes no session file, so omp's
|
|
36
39
|
-- JSONL discovery — the thing that names every omp row — has nothing to
|
|
37
40
|
-- read, and every recorded chat drew "Untitled" forever while the user's own
|
|
@@ -60,8 +63,40 @@ const HARNESS_SESSIONS_SQL = `
|
|
|
60
63
|
const HARNESS_SESSIONS_MIGRATIONS = [
|
|
61
64
|
`ALTER TABLE harness_sessions ADD COLUMN title TEXT NOT NULL DEFAULT '';`,
|
|
62
65
|
`ALTER TABLE harness_sessions ADD COLUMN origin TEXT NOT NULL DEFAULT '';`,
|
|
66
|
+
`ALTER TABLE harness_sessions ADD COLUMN account_id TEXT NOT NULL DEFAULT '';`,
|
|
63
67
|
];
|
|
64
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Saved CLI homes for Codex, Claude and Antigravity.
|
|
71
|
+
*
|
|
72
|
+
* A row is a pointer, never a credential: the token stays in the CLI's own file
|
|
73
|
+
* under `home_path`. `identity` is the display copy read from that token, and
|
|
74
|
+
* `verified_at` says when Kabmo last confirmed it, not when it will stay valid.
|
|
75
|
+
*/
|
|
76
|
+
const HARNESS_ACCOUNTS_SQL = `
|
|
77
|
+
CREATE TABLE IF NOT EXISTS harness_accounts (
|
|
78
|
+
id TEXT PRIMARY KEY,
|
|
79
|
+
harness TEXT NOT NULL,
|
|
80
|
+
label TEXT NOT NULL,
|
|
81
|
+
home_path TEXT NOT NULL,
|
|
82
|
+
identity TEXT NOT NULL DEFAULT '{}',
|
|
83
|
+
auth_kind TEXT NOT NULL DEFAULT 'unknown',
|
|
84
|
+
created_at INTEGER NOT NULL,
|
|
85
|
+
updated_at INTEGER NOT NULL,
|
|
86
|
+
verified_at INTEGER NOT NULL DEFAULT 0
|
|
87
|
+
);
|
|
88
|
+
CREATE INDEX IF NOT EXISTS idx_harness_accounts_harness
|
|
89
|
+
ON harness_accounts (harness);
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
/** One active account per harness. An absent row means the host login. */
|
|
93
|
+
const HARNESS_ACCOUNT_SELECTION_SQL = `
|
|
94
|
+
CREATE TABLE IF NOT EXISTS harness_account_selection (
|
|
95
|
+
harness TEXT PRIMARY KEY,
|
|
96
|
+
account_id TEXT NOT NULL
|
|
97
|
+
);
|
|
98
|
+
`;
|
|
99
|
+
|
|
65
100
|
/**
|
|
66
101
|
* What each agent reported, persisted.
|
|
67
102
|
*
|
|
@@ -183,6 +218,8 @@ const ACP_FRAMES_SQL = `
|
|
|
183
218
|
/** Idempotent: created on every database open, like every other feature table. */
|
|
184
219
|
export async function ensureHarnessSchema(db: DbClient): Promise<void> {
|
|
185
220
|
await db.exec(HARNESS_SESSIONS_SQL);
|
|
221
|
+
await db.exec(HARNESS_ACCOUNTS_SQL);
|
|
222
|
+
await db.exec(HARNESS_ACCOUNT_SELECTION_SQL);
|
|
186
223
|
await db.exec(CUSTOM_HARNESSES_SQL);
|
|
187
224
|
await db.exec(HARNESS_PROBES_SQL);
|
|
188
225
|
await db.exec(HARNESS_GOAL_STATE_SQL);
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
import fs from 'node:fs';
|
|
35
35
|
import { AcpProcess } from '@/server/lib/harness/acp/client';
|
|
36
36
|
import { withGatewayCompatibility } from '@/server/lib/harness/acp/gateway-env';
|
|
37
|
-
import { loadHarnessConfig
|
|
37
|
+
import { loadHarnessConfig } from '@/server/lib/harness/config.server';
|
|
38
|
+
import { resolveAccountLaunch } from '@/server/lib/harness/accounts.server';
|
|
38
39
|
import { customHarness, ensureCustomHarnesses } from '@/server/lib/harness/custom.server';
|
|
39
40
|
import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
|
|
40
41
|
import { dshStoreDirs } from '@/server/lib/harness/session-transcript.server';
|
|
@@ -81,7 +82,7 @@ async function localStoreDirs(harness: HarnessId, agentSessionId: string): Promi
|
|
|
81
82
|
|
|
82
83
|
async function defaultLaunch(harness: HarnessId): Promise<HarnessLaunch> {
|
|
83
84
|
await ensureCustomHarnesses();
|
|
84
|
-
return
|
|
85
|
+
return resolveAccountLaunch(harness, await loadHarnessConfig(harness));
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
interface Connection {
|
|
@@ -112,6 +113,7 @@ export function createAgentSessionRemover(deps: AgentSessionRemoverDeps = {}): A
|
|
|
112
113
|
onNotification: () => {},
|
|
113
114
|
onStderr: () => {},
|
|
114
115
|
...(env ? { env } : {}),
|
|
116
|
+
...(launch.stripEnv ? { envDrop: launch.stripEnv } : {}),
|
|
115
117
|
});
|
|
116
118
|
try {
|
|
117
119
|
const init = await proc.initialize(undefined, 60_000);
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
import { AcpProcess } from '@/server/lib/harness/acp/client';
|
|
31
31
|
import { listAllSessions } from '@/server/lib/harness/acp/verbs';
|
|
32
32
|
import { withGatewayCompatibility } from '@/server/lib/harness/acp/gateway-env';
|
|
33
|
-
import { loadHarnessConfig
|
|
33
|
+
import { loadHarnessConfig } from '@/server/lib/harness/config.server';
|
|
34
|
+
import { resolveAccountLaunch } from '@/server/lib/harness/accounts.server';
|
|
34
35
|
import { ensureCustomHarnesses } from '@/server/lib/harness/custom.server';
|
|
35
36
|
import { harnessSessionKnown, importHarnessSession } from '@/server/lib/harness/session-store.server';
|
|
36
37
|
import { sessionsWithoutTranscript } from '@/server/lib/harness/session-transcript.server';
|
|
@@ -44,7 +45,11 @@ import type { AcpSessionInfo } from '@/server/lib/harness/acp/protocol';
|
|
|
44
45
|
import type { HarnessSessionImport } from '@/shared/types/harness';
|
|
45
46
|
|
|
46
47
|
/** One fresh process' worth of listing, disposed whatever happens. */
|
|
47
|
-
async function listOnce(
|
|
48
|
+
async function listOnce(
|
|
49
|
+
command: string[],
|
|
50
|
+
env?: Record<string, string>,
|
|
51
|
+
envDrop?: readonly string[],
|
|
52
|
+
): Promise<AcpSessionInfo[]> {
|
|
48
53
|
let tail = '';
|
|
49
54
|
const proc = new AcpProcess({
|
|
50
55
|
command,
|
|
@@ -54,6 +59,7 @@ async function listOnce(command: string[], env?: Record<string, string>): Promis
|
|
|
54
59
|
// which names nothing a reader can act on.
|
|
55
60
|
onStderr: (line) => { tail = `${tail}${line}\n`.slice(-2_000); },
|
|
56
61
|
...(env ? { env } : {}),
|
|
62
|
+
...(envDrop ? { envDrop } : {}),
|
|
57
63
|
});
|
|
58
64
|
try {
|
|
59
65
|
await proc.initialize(undefined, 60_000);
|
|
@@ -69,14 +75,18 @@ async function listOnce(command: string[], env?: Record<string, string>): Promis
|
|
|
69
75
|
|
|
70
76
|
/** The agent's own session list, with the one retry the transport's shutdown
|
|
71
77
|
* race needs. A real refusal (auth, launch) is never retried. */
|
|
72
|
-
async function listSessions(
|
|
78
|
+
async function listSessions(
|
|
79
|
+
command: string[],
|
|
80
|
+
env?: Record<string, string>,
|
|
81
|
+
envDrop?: readonly string[],
|
|
82
|
+
): Promise<AcpSessionInfo[]> {
|
|
73
83
|
try {
|
|
74
|
-
return await listOnce(command, env);
|
|
84
|
+
return await listOnce(command, env, envDrop);
|
|
75
85
|
} catch (cause) {
|
|
76
86
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
77
87
|
if (!/exited \(code 0\)|has exited/i.test(message)) throw cause;
|
|
78
88
|
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
79
|
-
return await listOnce(command, env);
|
|
89
|
+
return await listOnce(command, env, envDrop);
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
|
|
@@ -110,11 +120,15 @@ export async function importHarnessSessions(id: HarnessId): Promise<HarnessSessi
|
|
|
110
120
|
const configured = await loadHarnessConfig(id);
|
|
111
121
|
let launch;
|
|
112
122
|
try {
|
|
113
|
-
launch =
|
|
123
|
+
launch = await resolveAccountLaunch(id, configured);
|
|
114
124
|
} catch (cause) {
|
|
115
125
|
throw new Error(cause instanceof Error ? cause.message : String(cause));
|
|
116
126
|
}
|
|
117
|
-
const sessions = await listSessions(
|
|
127
|
+
const sessions = await listSessions(
|
|
128
|
+
launch.command,
|
|
129
|
+
withGatewayCompatibility(id, launch.env),
|
|
130
|
+
launch.stripEnv,
|
|
131
|
+
);
|
|
118
132
|
const roots = await workspaceRoots();
|
|
119
133
|
// A session the agent created and never used has no transcript in its own
|
|
120
134
|
// store. Importing it would draw a sidebar row that opens an empty chat, so
|
|
@@ -63,6 +63,17 @@ describe('harness session store', () => {
|
|
|
63
63
|
expect(one?.cwd).toBe('/tmp/project');
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
test('a saved account is stored with the session it spawned', async () => {
|
|
67
|
+
await saveHarnessSession({
|
|
68
|
+
sessionId: 'sess-account',
|
|
69
|
+
harness: 'codex',
|
|
70
|
+
agentSessionId: 'agent-9',
|
|
71
|
+
cwd: '/tmp/project',
|
|
72
|
+
accountId: 'account-1',
|
|
73
|
+
});
|
|
74
|
+
expect((await loadHarnessSession('sess-account'))?.accountId).toBe('account-1');
|
|
75
|
+
});
|
|
76
|
+
|
|
66
77
|
test('a re-spawn UPDATES the row instead of failing on the primary key', async () => {
|
|
67
78
|
await saveHarnessSession({ sessionId: 'sess-1', harness: 'claude', agentSessionId: '', cwd: '/a' });
|
|
68
79
|
await saveHarnessSession({ sessionId: 'sess-1', harness: 'codex', agentSessionId: 'x', cwd: '/b' });
|
|
@@ -194,6 +205,7 @@ describe('session import rows', () => {
|
|
|
194
205
|
harness: 'codex',
|
|
195
206
|
agentSessionId: '',
|
|
196
207
|
cwd: '/work/app',
|
|
208
|
+
accountId: '',
|
|
197
209
|
origin: 'imported',
|
|
198
210
|
});
|
|
199
211
|
const rows = await loadAcpSessions();
|
|
@@ -25,6 +25,8 @@ export interface HarnessSessionRecord {
|
|
|
25
25
|
/** The id the AGENT reported, when it differs from Kabmo's. */
|
|
26
26
|
agentSessionId: string;
|
|
27
27
|
cwd: string;
|
|
28
|
+
/** The saved account whose home spawned this chat; '' for the host login. */
|
|
29
|
+
accountId?: string;
|
|
28
30
|
/** '' for a chat Kabmo spawned; 'imported' for one copied from the agent's
|
|
29
31
|
* own history. Optional on INPUT (a spawn writes no marker). */
|
|
30
32
|
origin?: string;
|
|
@@ -36,14 +38,15 @@ export async function saveHarnessSession(record: HarnessSessionRecord): Promise<
|
|
|
36
38
|
const now = Date.now();
|
|
37
39
|
const db = await getDb();
|
|
38
40
|
await db.run(
|
|
39
|
-
`INSERT INTO harness_sessions (session_id, harness, agent_session_id, cwd, created_at, updated_at)
|
|
40
|
-
VALUES (?, ?, ?, ?, ?, ?)
|
|
41
|
+
`INSERT INTO harness_sessions (session_id, harness, agent_session_id, cwd, account_id, created_at, updated_at)
|
|
42
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
41
43
|
ON CONFLICT(session_id) DO UPDATE SET
|
|
42
44
|
harness = excluded.harness,
|
|
43
45
|
agent_session_id = excluded.agent_session_id,
|
|
44
46
|
cwd = excluded.cwd,
|
|
47
|
+
account_id = excluded.account_id,
|
|
45
48
|
updated_at = excluded.updated_at`,
|
|
46
|
-
[record.sessionId, record.harness, record.agentSessionId, record.cwd, now, now],
|
|
49
|
+
[record.sessionId, record.harness, record.agentSessionId, record.cwd, record.accountId ?? '', now, now],
|
|
47
50
|
);
|
|
48
51
|
}
|
|
49
52
|
|
|
@@ -173,6 +176,8 @@ export interface HarnessSessionRow {
|
|
|
173
176
|
cwd: string;
|
|
174
177
|
/** See {@link HarnessSessionRecord.origin}. */
|
|
175
178
|
origin: string;
|
|
179
|
+
/** See {@link HarnessSessionRecord.accountId}. */
|
|
180
|
+
accountId: string;
|
|
176
181
|
/** What the chat is called: the agent's own title, else the first prompt.
|
|
177
182
|
* Empty when neither exists yet. */
|
|
178
183
|
title: string;
|
|
@@ -201,7 +206,7 @@ export interface HarnessSessionRow {
|
|
|
201
206
|
export async function loadAcpSessions(): Promise<HarnessSessionRow[]> {
|
|
202
207
|
const db = await getDb();
|
|
203
208
|
const rows = (await db.all(
|
|
204
|
-
`SELECT session_id, harness, agent_session_id, cwd, title, origin, created_at, updated_at
|
|
209
|
+
`SELECT session_id, harness, agent_session_id, cwd, account_id, title, origin, created_at, updated_at
|
|
205
210
|
FROM harness_sessions
|
|
206
211
|
WHERE harness <> 'omp-rpc'
|
|
207
212
|
ORDER BY updated_at DESC`,
|
|
@@ -210,6 +215,7 @@ export async function loadAcpSessions(): Promise<HarnessSessionRow[]> {
|
|
|
210
215
|
harness: string;
|
|
211
216
|
agent_session_id: string;
|
|
212
217
|
cwd: string;
|
|
218
|
+
account_id: string | null;
|
|
213
219
|
title: string | null;
|
|
214
220
|
origin: string | null;
|
|
215
221
|
created_at: number;
|
|
@@ -220,6 +226,7 @@ export async function loadAcpSessions(): Promise<HarnessSessionRow[]> {
|
|
|
220
226
|
harness: row.harness,
|
|
221
227
|
agentSessionId: row.agent_session_id,
|
|
222
228
|
cwd: row.cwd,
|
|
229
|
+
accountId: row.account_id ?? '',
|
|
223
230
|
title: row.title ?? '',
|
|
224
231
|
origin: row.origin ?? '',
|
|
225
232
|
createdAt: row.created_at,
|
|
@@ -261,15 +268,23 @@ export async function loadHarnessSessionTitle(sessionId: string): Promise<string
|
|
|
261
268
|
export async function loadHarnessSession(sessionId: string): Promise<HarnessSessionRecord | null> {
|
|
262
269
|
const db = await getDb();
|
|
263
270
|
const row = (await db.get(
|
|
264
|
-
'SELECT session_id, harness, agent_session_id, cwd, origin FROM harness_sessions WHERE session_id = ?',
|
|
271
|
+
'SELECT session_id, harness, agent_session_id, cwd, account_id, origin FROM harness_sessions WHERE session_id = ?',
|
|
265
272
|
[sessionId],
|
|
266
|
-
)) as {
|
|
273
|
+
)) as {
|
|
274
|
+
session_id: string;
|
|
275
|
+
harness: string;
|
|
276
|
+
agent_session_id: string;
|
|
277
|
+
cwd: string;
|
|
278
|
+
account_id: string | null;
|
|
279
|
+
origin: string | null;
|
|
280
|
+
} | null;
|
|
267
281
|
if (!row) return null;
|
|
268
282
|
return {
|
|
269
283
|
sessionId: row.session_id,
|
|
270
284
|
harness: row.harness,
|
|
271
285
|
agentSessionId: row.agent_session_id,
|
|
272
286
|
cwd: row.cwd,
|
|
287
|
+
accountId: row.account_id ?? '',
|
|
273
288
|
origin: row.origin ?? '',
|
|
274
289
|
};
|
|
275
290
|
}
|
|
@@ -29,6 +29,7 @@ import { Database } from 'bun:sqlite';
|
|
|
29
29
|
import fs from 'node:fs';
|
|
30
30
|
import { homedir } from 'node:os';
|
|
31
31
|
import { join } from 'node:path';
|
|
32
|
+
import { antigravityHome } from '@/server/lib/antigravity/home.server';
|
|
32
33
|
import { codexHome, findCodexRollout } from '@/server/lib/harness/codex/transcript.server';
|
|
33
34
|
import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
|
|
34
35
|
|
|
@@ -231,7 +232,7 @@ async function zcodeTranscripts(ids: readonly string[]): Promise<Set<string> | n
|
|
|
231
232
|
* no `steps` row is a session that was opened and never used.
|
|
232
233
|
*/
|
|
233
234
|
async function antigravityTranscripts(ids: readonly string[]): Promise<Set<string> | null> {
|
|
234
|
-
const home =
|
|
235
|
+
const home = antigravityHome();
|
|
235
236
|
const roots = [
|
|
236
237
|
join(home, 'antigravity-cli', 'conversations'),
|
|
237
238
|
join(home, 'antigravity', 'conversations'),
|
|
@@ -25,7 +25,9 @@ import { AcpTranscriptRecorder } from '@/server/lib/harness/acp/session-transcri
|
|
|
25
25
|
import { AcpFrameRecorder } from '@/server/lib/harness/acp/acp-frames.server';
|
|
26
26
|
import { claimPrewarmedAcpSession } from '@/server/lib/harness/acp/prewarm.server';
|
|
27
27
|
import { rememberAgentToken } from '@/server/lib/sessions/agent-token.server';
|
|
28
|
-
import { loadHarnessConfig
|
|
28
|
+
import { loadHarnessConfig } from '@/server/lib/harness/config.server';
|
|
29
|
+
import { resolveAccountLaunch, selectedAccountId } from '@/server/lib/harness/accounts.server';
|
|
30
|
+
import { accountAdapter } from '@/shared/lib/harness/accounts';
|
|
29
31
|
import { sessionLaunchCommand } from '@/server/lib/harness/launch';
|
|
30
32
|
import { resolveDefaultModel, modelProvider } from '@/shared/lib/harness/config';
|
|
31
33
|
import { harnessProbeModels } from '@/server/lib/harness/probe-cache.server';
|
|
@@ -70,6 +72,11 @@ export interface AcpSpawnRequest {
|
|
|
70
72
|
replay?: boolean;
|
|
71
73
|
/** Extra environment for this child only (the agent token and server URL). */
|
|
72
74
|
env?: Record<string, string>;
|
|
75
|
+
/**
|
|
76
|
+
* Saved account to launch. Undefined selects the harness's active account;
|
|
77
|
+
* null means the host login, which is what a pre-account chat resumes on.
|
|
78
|
+
*/
|
|
79
|
+
accountId?: string | null;
|
|
73
80
|
/** A prewarmed (spawned + initialized) agent to adopt instead of spawning. */
|
|
74
81
|
process?: AcpProcess;
|
|
75
82
|
/**
|
|
@@ -114,7 +121,7 @@ async function resolvePicks(
|
|
|
114
121
|
|
|
115
122
|
export async function openAcpSession(
|
|
116
123
|
request: AcpSpawnRequest,
|
|
117
|
-
): Promise<{ session: AcpSession; realSessionId: string }> {
|
|
124
|
+
): Promise<{ session: AcpSession; realSessionId: string; accountId: string | null }> {
|
|
118
125
|
// The USER's launch line, merged over the build's table. A command override is
|
|
119
126
|
// the only way to start an agent installed outside PATH, and an env override is
|
|
120
127
|
// the only provider switch an ACP agent actually honours — Kabmo routes nothing
|
|
@@ -123,9 +130,14 @@ export async function openAcpSession(
|
|
|
123
130
|
// synchronous: load the registry before asking it for a launch line.
|
|
124
131
|
await ensureCustomHarnesses();
|
|
125
132
|
const configured = await loadHarnessConfig(request.harness);
|
|
133
|
+
const accountId = accountAdapter(request.harness)
|
|
134
|
+
? request.accountId === undefined
|
|
135
|
+
? await selectedAccountId(request.harness)
|
|
136
|
+
: request.accountId
|
|
137
|
+
: null;
|
|
126
138
|
let launch;
|
|
127
139
|
try {
|
|
128
|
-
launch =
|
|
140
|
+
launch = await resolveAccountLaunch(request.harness, configured, accountId);
|
|
129
141
|
} catch (cause) {
|
|
130
142
|
throw new HarnessNotLaunchableError(
|
|
131
143
|
request.harness,
|
|
@@ -161,6 +173,7 @@ export async function openAcpSession(
|
|
|
161
173
|
harness: request.harness,
|
|
162
174
|
command: sessionLaunchCommand(request.harness, launch.command),
|
|
163
175
|
...(Object.keys(childEnv).length > 0 ? { env: childEnv } : {}),
|
|
176
|
+
...(launch.stripEnv ? { envDrop: launch.stripEnv } : {}),
|
|
164
177
|
...(request.process ? { process: request.process } : {}),
|
|
165
178
|
model: picks.model,
|
|
166
179
|
thinkingLevel: picks.thinking,
|
|
@@ -212,7 +225,7 @@ export async function openAcpSession(
|
|
|
212
225
|
title,
|
|
213
226
|
});
|
|
214
227
|
}
|
|
215
|
-
return { session, realSessionId };
|
|
228
|
+
return { session, realSessionId, accountId };
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
/** The frames a restore replayed, and only from an ACP session. */
|
|
@@ -223,13 +236,20 @@ export function takeAcpReplayEvents(session: HarnessSession): AgentEvent[] {
|
|
|
223
236
|
export async function startAcpSession(
|
|
224
237
|
request: AcpSpawnRequest,
|
|
225
238
|
): Promise<{ session: HarnessSession; realSessionId: string; adopted: boolean }> {
|
|
239
|
+
const accountId = accountAdapter(request.harness)
|
|
240
|
+
? request.accountId === undefined
|
|
241
|
+
? await selectedAccountId(request.harness)
|
|
242
|
+
: request.accountId
|
|
243
|
+
: null;
|
|
226
244
|
const claimable = request.claimPrewarmed && !request.resumeAgentSessionId && !request.forkAgentSessionId;
|
|
227
245
|
// A warm agent skips the spawn AND the `initialize` handshake; `session/new`
|
|
228
246
|
// and the picks still run, in the same place a cold spawn runs them, so there
|
|
229
247
|
// is one definition of "the session a chat starts in".
|
|
230
|
-
const warm = claimable
|
|
248
|
+
const warm = claimable
|
|
249
|
+
? await claimPrewarmedAcpSession(request.harness, request.cwd, accountId ?? '')
|
|
250
|
+
: null;
|
|
231
251
|
const { session, realSessionId } = await openAcpSession(
|
|
232
|
-
warm ? { ...request, process: warm.process } : request,
|
|
252
|
+
warm ? { ...request, accountId, process: warm.process } : { ...request, accountId },
|
|
233
253
|
);
|
|
234
254
|
// The transcript this session writes for itself. A restore replays the
|
|
235
255
|
// agent's history and persists it itself, so it is the one session that must
|
|
@@ -273,6 +293,7 @@ export async function startAcpSession(
|
|
|
273
293
|
harness: request.harness,
|
|
274
294
|
agentSessionId: realSessionId === request.sessionId ? '' : realSessionId,
|
|
275
295
|
cwd: request.cwd,
|
|
296
|
+
accountId: accountId ?? '',
|
|
276
297
|
}).catch((cause: unknown) => {
|
|
277
298
|
console.error(`[harness] could not record ${request.harness} for session ${realSessionId}:`, cause);
|
|
278
299
|
});
|
|
@@ -22,10 +22,16 @@ const realFetch = Bun.fetch;
|
|
|
22
22
|
const requested: string[] = [];
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Answer per origin: `{ html }` for a page that declares
|
|
26
|
-
* a
|
|
25
|
+
* Answer per origin: `{ html }` for a page that declares its icons, `{ icon }`
|
|
26
|
+
* for a PNG at that URL, `{ icons }` for an arbitrary body per path.
|
|
27
27
|
*/
|
|
28
|
-
function stubHosts(
|
|
28
|
+
function stubHosts(
|
|
29
|
+
hosts: Record<string, {
|
|
30
|
+
html?: string;
|
|
31
|
+
icon?: string;
|
|
32
|
+
icons?: Record<string, { body: string | Uint8Array; mime: string }>;
|
|
33
|
+
}>,
|
|
34
|
+
): void {
|
|
29
35
|
globalThis.fetch = (async (input: RequestInfo | URL) => {
|
|
30
36
|
const url = String(input instanceof Request ? input.url : input);
|
|
31
37
|
requested.push(url);
|
|
@@ -36,6 +42,10 @@ function stubHosts(hosts: Record<string, { html?: string; icon?: string }>): voi
|
|
|
36
42
|
if (url.replace(/\/$/, '') === origin && host.html) {
|
|
37
43
|
return new Response(host.html, { headers: { 'content-type': 'text/html' } });
|
|
38
44
|
}
|
|
45
|
+
const declared = host.icons?.[url.slice(origin.length)];
|
|
46
|
+
if (declared) {
|
|
47
|
+
return new Response(declared.body, { headers: { 'content-type': declared.mime } });
|
|
48
|
+
}
|
|
39
49
|
if (host.icon && url === `${origin}${host.icon}`) {
|
|
40
50
|
return new Response(PNG, { headers: { 'content-type': 'image/png' } });
|
|
41
51
|
}
|
|
@@ -89,3 +99,47 @@ describe('fetchProviderIcon — endpoint host, then base domain', () => {
|
|
|
89
99
|
expect(requested.every((url) => url.startsWith('https://demo.vercel.app'))).toBe(true);
|
|
90
100
|
});
|
|
91
101
|
});
|
|
102
|
+
|
|
103
|
+
describe('fetchProviderIcon — an SVG must be decodable', () => {
|
|
104
|
+
/**
|
|
105
|
+
* The measured case: tokenharbor.ai's icon.svg is well-formed apart from a
|
|
106
|
+
* comment that says `--background`, and Chromium answers the `<img>` with
|
|
107
|
+
* `EncodingError` — initials were drawn although the store said `ok`.
|
|
108
|
+
*/
|
|
109
|
+
test('an SVG comment containing -- is stripped, so the image paints', async () => {
|
|
110
|
+
const svg = '<?xml version="1.0"?><!-- matches --background --><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"></svg>';
|
|
111
|
+
stubHosts({
|
|
112
|
+
'https://tokenharbor.test': {
|
|
113
|
+
html: '<link rel="icon" href="/icon.svg" sizes="any">',
|
|
114
|
+
icons: { '/icon.svg': { body: svg, mime: 'image/svg+xml' } },
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const icon = await fetchProviderIcon('https://tokenharbor.test/v1');
|
|
119
|
+
const text = new TextDecoder().decode(icon?.bytes);
|
|
120
|
+
|
|
121
|
+
expect(icon?.mime).toBe('image/svg+xml');
|
|
122
|
+
expect(text).not.toContain('<!--');
|
|
123
|
+
expect(() => Bun.XML.parse(text)).not.toThrow();
|
|
124
|
+
expect(text).toContain('<svg');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('an SVG that cannot be repaired falls through to the next declared icon', async () => {
|
|
128
|
+
stubHosts({
|
|
129
|
+
'https://gateway.test': {
|
|
130
|
+
html: '<link rel="icon" href="/broken.svg" sizes="any"><link rel="icon" href="/good.png" sizes="192x192">',
|
|
131
|
+
icons: {
|
|
132
|
+
'/broken.svg': { body: '<svg><g></svg>', mime: 'image/svg+xml' },
|
|
133
|
+
'/good.png': { body: PNG, mime: 'image/png' },
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const icon = await fetchProviderIcon('https://gateway.test/v1');
|
|
139
|
+
|
|
140
|
+
expect(icon?.source).toBe('https://gateway.test/good.png');
|
|
141
|
+
expect(icon?.mime).toBe('image/png');
|
|
142
|
+
expect(requested).toContain('https://gateway.test/broken.svg');
|
|
143
|
+
expect(requested).toContain('https://gateway.test/good.png');
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import { getImageMimeFromBytes, looksLikeSvg } from '@/shared/lib/fs/file-kind';
|
|
27
27
|
import { pickIconHrefs, providerIconOrigins } from '@/server/lib/models/provider-icon-parse';
|
|
28
|
+
import { drawableSvg } from '@/server/lib/models/provider-icon-svg';
|
|
28
29
|
|
|
29
30
|
/** Per-request ceiling. A favicon slower than this is not worth the wait. */
|
|
30
31
|
const FETCH_TIMEOUT_MS = 4_000;
|
|
@@ -80,7 +81,14 @@ export async function fetchIconAt(url: string): Promise<ProviderIconBytes | null
|
|
|
80
81
|
const declared = (response.headers.get('content-type') ?? '').toLowerCase();
|
|
81
82
|
// Cheap rejection first: an HTML answer is a page, not a picture.
|
|
82
83
|
if (declared.includes('text/html')) return null;
|
|
83
|
-
if (looksLikeSvg(bytes))
|
|
84
|
+
if (looksLikeSvg(bytes)) {
|
|
85
|
+
// An SVG that a browser cannot decode is not an icon: Chromium rejects an
|
|
86
|
+
// invalid comment (`--` inside `<!-- -->`) with `EncodingError`. Returning
|
|
87
|
+
// null here lets the caller try the site's next declared icon instead of
|
|
88
|
+
// storing a 200 that paints nothing.
|
|
89
|
+
const svg = drawableSvg(bytes);
|
|
90
|
+
return svg ? { bytes: svg, mime: 'image/svg+xml', source: url } : null;
|
|
91
|
+
}
|
|
84
92
|
const sniffed = getImageMimeFromBytes(bytes);
|
|
85
93
|
if (sniffed) return { bytes, mime: sniffed, source: url };
|
|
86
94
|
// A declared image type with no magic match (a format the table does not
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
import type { DbClient } from '@/server/lib/db/client';
|
|
27
|
+
import { drawableSvg } from '@/server/lib/models/provider-icon-svg';
|
|
27
28
|
|
|
28
29
|
const PROVIDER_ICON_SCHEMA_SQL = `
|
|
29
30
|
CREATE TABLE IF NOT EXISTS provider_icons (
|
|
@@ -116,3 +117,63 @@ export async function writeProviderIcon(db: DbClient, icon: StoredProviderIcon):
|
|
|
116
117
|
export async function deleteProviderIcon(db: DbClient, slug: string): Promise<void> {
|
|
117
118
|
await db.run('DELETE FROM provider_icons WHERE slug = ?', [slug]);
|
|
118
119
|
}
|
|
120
|
+
|
|
121
|
+
function sameBytes(left: Uint8Array, right: Uint8Array): boolean {
|
|
122
|
+
if (left.byteLength !== right.byteLength) return false;
|
|
123
|
+
for (let index = 0; index < left.byteLength; index += 1) {
|
|
124
|
+
if (left[index] !== right[index]) return false;
|
|
125
|
+
}
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Repair SVG icons stored before the fetch layer validated them.
|
|
131
|
+
*
|
|
132
|
+
* A site can serve an SVG that is well-formed to a lenient reader and broken to
|
|
133
|
+
* a browser (`--` inside an XML comment is the measured case), and the old code
|
|
134
|
+
* stored those bytes as `status = 'ok'`. The row then served `image/svg+xml`
|
|
135
|
+
* that Chromium rejects, so the provider drew its initials while every API said
|
|
136
|
+
* it had an icon.
|
|
137
|
+
*
|
|
138
|
+
* Sanitized bytes are written back with a NEW `fetched_at`, because that is the
|
|
139
|
+
* version in the icon URL: reusing the old stamp would leave the browser's
|
|
140
|
+
* immutable copy of the undecodable bytes in place. A document that cannot be
|
|
141
|
+
* repaired is deleted, so the normal background pass fetches another candidate.
|
|
142
|
+
*
|
|
143
|
+
* Runs once per database open, after the table exists.
|
|
144
|
+
*/
|
|
145
|
+
export async function repairProviderIconSvgs(db: DbClient): Promise<number> {
|
|
146
|
+
const rows = await db.all<{
|
|
147
|
+
slug: string;
|
|
148
|
+
bytes: Uint8Array | null;
|
|
149
|
+
source: string | null;
|
|
150
|
+
}>(
|
|
151
|
+
"SELECT slug, bytes, source FROM provider_icons WHERE status = 'ok' AND mime = 'image/svg+xml'",
|
|
152
|
+
);
|
|
153
|
+
let repaired = 0;
|
|
154
|
+
for (const row of rows) {
|
|
155
|
+
const bytes = row.bytes;
|
|
156
|
+
if (!bytes) {
|
|
157
|
+
await deleteProviderIcon(db, row.slug);
|
|
158
|
+
repaired += 1;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const drawable = drawableSvg(bytes);
|
|
162
|
+
if (!drawable) {
|
|
163
|
+
await deleteProviderIcon(db, row.slug);
|
|
164
|
+
repaired += 1;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (sameBytes(drawable, bytes)) continue;
|
|
168
|
+
await writeProviderIcon(db, {
|
|
169
|
+
slug: row.slug,
|
|
170
|
+
status: 'ok',
|
|
171
|
+
mime: 'image/svg+xml',
|
|
172
|
+
bytes: drawable,
|
|
173
|
+
...(row.source ? { source: row.source } : {}),
|
|
174
|
+
fetchedAt: Date.now(),
|
|
175
|
+
});
|
|
176
|
+
repaired += 1;
|
|
177
|
+
}
|
|
178
|
+
return repaired;
|
|
179
|
+
}
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
ensureProviderIconSchema,
|
|
20
20
|
readProviderIcon,
|
|
21
21
|
readProviderIconStamps,
|
|
22
|
+
repairProviderIconSvgs,
|
|
22
23
|
writeProviderIcon,
|
|
23
24
|
} from '@/server/lib/models/provider-icon-store.server';
|
|
24
25
|
|
|
@@ -104,4 +105,58 @@ describe('provider_icons', () => {
|
|
|
104
105
|
test('an unknown provider has no row', async () => {
|
|
105
106
|
expect(await readProviderIcon(await getDb(), 'nope')).toBeNull();
|
|
106
107
|
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* tokenharbor.ai's icon.svg says `--background` inside an XML comment: valid
|
|
111
|
+
* to a lenient reader, rejected by Chromium as an image. The old fetch stored
|
|
112
|
+
* those bytes as `ok`, so the row reported an icon that painted nothing.
|
|
113
|
+
*/
|
|
114
|
+
test('a stored SVG a browser rejects is repaired, with a new version', async () => {
|
|
115
|
+
const db = await getDb();
|
|
116
|
+
const broken = '<?xml version="1.0"?><!-- matches --background --><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"></svg>';
|
|
117
|
+
await writeProviderIcon(db, {
|
|
118
|
+
slug: 'token-harbour',
|
|
119
|
+
status: 'ok',
|
|
120
|
+
mime: 'image/svg+xml',
|
|
121
|
+
bytes: new TextEncoder().encode(broken),
|
|
122
|
+
source: 'https://tokenharbor.ai/icon.svg',
|
|
123
|
+
fetchedAt: 1_700_000_000_000,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
expect(await repairProviderIconSvgs(db)).toBe(1);
|
|
127
|
+
|
|
128
|
+
const stored = await readProviderIcon(db, 'token-harbour');
|
|
129
|
+
const text = new TextDecoder().decode(stored?.bytes);
|
|
130
|
+
expect(text).not.toContain('<!--');
|
|
131
|
+
expect(() => Bun.XML.parse(text)).not.toThrow();
|
|
132
|
+
// The icon URL is versioned by `fetchedAt`; keeping the old stamp would
|
|
133
|
+
// leave the browser's immutable copy of the undecodable bytes in place.
|
|
134
|
+
expect(stored?.fetchedAt).toBeGreaterThan(1_700_000_000_000);
|
|
135
|
+
expect(stored?.source).toBe('https://tokenharbor.ai/icon.svg');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('an SVG that cannot be repaired is dropped so the next pass refetches', async () => {
|
|
139
|
+
const db = await getDb();
|
|
140
|
+
await writeProviderIcon(db, {
|
|
141
|
+
slug: 'broken-gateway',
|
|
142
|
+
status: 'ok',
|
|
143
|
+
mime: 'image/svg+xml',
|
|
144
|
+
bytes: new TextEncoder().encode('<svg><g></svg>'),
|
|
145
|
+
fetchedAt: 1,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
expect(await repairProviderIconSvgs(db)).toBe(1);
|
|
149
|
+
expect(await readProviderIcon(db, 'broken-gateway')).toBeNull();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('a decodable SVG is left byte-for-byte alone', async () => {
|
|
153
|
+
const db = await getDb();
|
|
154
|
+
const bytes = new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"></svg>');
|
|
155
|
+
await writeProviderIcon(db, {
|
|
156
|
+
slug: 'kenari', status: 'ok', mime: 'image/svg+xml', bytes, fetchedAt: 42,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(await repairProviderIconSvgs(db)).toBe(0);
|
|
160
|
+
expect((await readProviderIcon(db, 'kenari'))?.fetchedAt).toBe(42);
|
|
161
|
+
});
|
|
107
162
|
});
|