@kabmo-labs/kabmo 0.49.0 → 0.51.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 +606 -560
- package/dist/client/static/js/{Body-9h5hd351.js → Body-s3nh6vet.js} +3 -3
- package/dist/client/static/js/{CsvGrid-s05k1q18.js → CsvGrid-j4h6cpnn.js} +2 -2
- package/dist/client/static/js/{DocxView-x6sjw5ht.js → DocxView-197x16zq.js} +3 -3
- package/dist/client/static/js/{DrawioView-jashn8sf.js → DrawioView-v6ps0cm5.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-eygzgtyc.js → HtmlPreview-a2t5zngp.js} +1 -1
- package/dist/client/static/js/ImageView-ar7hz7jx.js +1 -0
- package/dist/client/static/js/LayoutWrapper-epef152a.js +2 -0
- package/dist/client/static/js/MergeDiffView-7rwjvzk5.js +1 -0
- package/dist/client/static/js/Modal-9nxt67fm.js +60 -0
- package/dist/client/static/js/{PdfView-syhjmyqf.js → PdfView-gzhcym20.js} +1 -1
- package/dist/client/static/js/SessionsView-3h872gpe.js +1 -0
- package/dist/client/static/js/{SheetView-26r0e506.js → SheetView-baaynkb4.js} +22 -22
- package/dist/client/static/js/{SvgPreview-2fk85jzz.js → SvgPreview-jzcqwwcc.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-fdka7pxr.js → abnfDiagram-O67JEVCF-grb1sfhr.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-3hkq8grc.js +1 -0
- package/dist/client/static/js/architectureDiagram-NJMV4G6O-9084jzwr.js +36 -0
- package/dist/client/static/js/{astro-rn2bvwpm.js → astro-m3fcq2sa.js} +1 -1
- package/dist/client/static/js/bash-n7wcmq3s.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-vpcmd3vx.js → blockDiagram-BEXU5L5S-qqcjrg1b.js} +8 -8
- package/dist/client/static/js/c-ypdp030b.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-1rgpdnbq.js → c4Diagram-YGBWAQC7-gc8fqbpc.js} +3 -3
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fbsejvb9.js → classDiagram-v2-NBCMYWYE-pp6060kq.js} +9 -9
- package/dist/client/static/js/cose-bilkent-JH36ORCC-744ekavk.js +1 -0
- package/dist/client/static/js/cpp-cxwev3gs.js +1 -0
- package/dist/client/static/js/css-6mxcqf8c.js +1 -0
- package/dist/client/static/js/css-9gak6bze.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-9m18e6m5.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-7ta5vbrw.js → cynefinDiagram-VND7K2PF-57dja6g9.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-b8gtt32x.js → dagre-6A5THRUB-de4xrbrw.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-7emepy7h.js → diagram-22UHCM2B-ky3ncyv8.js} +21 -21
- package/dist/client/static/js/diagram-3UASUU5V-zgg82bz9.js +24 -0
- package/dist/client/static/js/{diagram-ATOU4E4O-t113exk3.js → diagram-ATOU4E4O-r4s13e4n.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-pyj3x97y.js → diagram-CDSNMT55-my21t0kq.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-183sgpjh.js → diagram-MLGK6HIB-pvt20jtj.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-fmbj4hcx.js → diagram-MPIPVDR6-as9dk4f3.js} +2 -2
- package/dist/client/static/js/{dockerfile-qay672za.js → dockerfile-3b5caedj.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-eafvfws2.js → ebnfDiagram-ZINNZB2B-tj3hkcj4.js} +1 -1
- package/dist/client/static/js/{elixir-t8bep87c.js → elixir-7q2k61zb.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-573f1vfs.js → elk-276RUBZZ-5e7wczf3.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-4z1r88ej.js → erDiagram-OPXOYQCR-5jje7qrh.js} +12 -12
- package/dist/client/static/js/{erlang-261km7r1.js → erlang-tjsd7n4d.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-d4egnv9v.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-pdeqndnd.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-49jd7msz.js → ganttDiagram-FUAMR5RP-7hresycc.js} +6 -6
- package/dist/client/static/js/gitGraph-4MIJSDKK-grqv890n.js +1 -0
- package/dist/client/static/js/gitGraphDiagram-X574FWY7-8m202jb7.js +106 -0
- package/dist/client/static/js/graphql-6rwdfcnf.js +1 -0
- package/dist/client/static/js/html-p76eszt9.js +1 -0
- package/dist/client/static/js/{index-0w4jqzqk.js → index-0prwdwyb.js} +2 -2
- package/dist/client/static/js/{index-3v8k8ms3.js → index-0y6tstk8.js} +1 -1
- package/dist/client/static/js/index-20hj80g4.js +4 -0
- package/dist/client/static/js/index-21421tq7.js +2 -0
- package/dist/client/static/js/{index-gg910gpv.js → index-254387vg.js} +2 -2
- package/dist/client/static/js/index-2y4gk5q5.js +2 -0
- package/dist/client/static/js/index-3fk8grhz.js +2 -0
- package/dist/client/static/js/index-3rrdmk9m.js +2 -0
- package/dist/client/static/js/{index-rz0tz4hg.js → index-3sz9cztk.js} +1 -1
- package/dist/client/static/js/index-4m2d73m3.css +1 -0
- package/dist/client/static/js/{index-2bf0txsp.js → index-4nvcwtvr.js} +2 -2
- package/dist/client/static/js/index-4ppap7vb.js +9 -0
- package/dist/client/static/js/{index-qs4n116g.js → index-4tbdws4r.js} +2 -2
- package/dist/client/static/js/index-56hy2hcy.js +1 -0
- package/dist/client/static/js/{index-7rmps91t.js → index-60g0e74a.js} +2 -2
- package/dist/client/static/js/{index-zp40g8ah.js → index-7ag37ghj.js} +12 -12
- package/dist/client/static/js/{index-z6y8j93w.js → index-7ehcjb3r.js} +7 -7
- package/dist/client/static/js/index-899yw6fh.js +2 -0
- package/dist/client/static/js/{index-2yzt8h3d.js → index-8pqx5n2p.js} +2 -2
- package/dist/client/static/js/{index-dh060b7r.js → index-91jm3ywm.js} +2 -2
- package/dist/client/static/js/{index-yg083mk0.js → index-9qf2h9jb.js} +6 -6
- package/dist/client/static/js/{index-tcfpzqb9.js → index-9rp7h1nv.js} +20 -20
- package/dist/client/static/js/index-9rr23e0e.js +2 -0
- package/dist/client/static/js/index-9wj4ma9g.js +3 -0
- package/dist/client/static/js/index-awtk0djy.js +1 -0
- package/dist/client/static/js/{index-4dnc1kys.js → index-awz6pyd0.js} +2 -2
- package/dist/client/static/js/index-cvx1vkrx.js +1 -0
- package/dist/client/static/js/{index-c3whkrwa.js → index-cwwg7k5f.js} +33 -33
- package/dist/client/static/js/{index-ykc14gez.js → index-dzatbdws.js} +6 -6
- package/dist/client/static/js/{index-j37m7pn9.js → index-e6ew77ph.js} +2 -2
- package/dist/client/static/js/{index-tb35a328.js → index-ej1va073.js} +2 -2
- package/dist/client/static/js/{index-4ccs971z.js → index-er7pj5k6.js} +2 -2
- package/dist/client/static/js/index-fm0t4pct.js +4 -0
- package/dist/client/static/js/{index-0857zpr0.js → index-g5wp6ksw.js} +2 -2
- package/dist/client/static/js/{index-nzvte8s5.js → index-gy4mtr2e.js} +2 -2
- package/dist/client/static/js/{index-1yq96wpa.js → index-j9y4tjk0.js} +2 -2
- package/dist/client/static/js/{index-7ff9scbm.js → index-kt7c42n7.js} +2 -2
- package/dist/client/static/js/index-ktmb341a.js +468 -0
- package/dist/client/static/js/{index-taev57jw.js → index-m6zncj00.js} +2 -2
- package/dist/client/static/js/{index-dmc82cxb.js → index-mpyd7qxj.js} +2 -2
- package/dist/client/static/js/{index-1p880x6e.js → index-ms80nne4.js} +2 -2
- package/dist/client/static/js/{index-yyjw1ty9.js → index-my856e49.js} +2 -2
- package/dist/client/static/js/{index-pygy21w5.js → index-nnqyew8n.js} +2 -2
- package/dist/client/static/js/{index-qwxawph7.js → index-nt17ejrm.js} +2 -2
- package/dist/client/static/js/index-pvv340b4.js +2 -0
- package/dist/client/static/js/{index-nbm5r9g1.js → index-pxr36neg.js} +2 -2
- package/dist/client/static/js/{index-5ztdqm1w.js → index-q0k1am0g.js} +2 -2
- package/dist/client/static/js/{index-tc6k8qt7.js → index-qrpx4sk1.js} +2 -2
- package/dist/client/static/js/{index-473hk8nb.js → index-r2zsw7nw.js} +9 -9
- package/dist/client/static/js/{index-gaqjrzdb.js → index-rbkvw2xs.js} +2 -2
- package/dist/client/static/js/{index-wbsvg1d9.js → index-scmtzcv1.js} +2 -2
- package/dist/client/static/js/{index-bmaktvm2.js → index-syvkpnc8.js} +1 -1
- package/dist/client/static/js/index-tfqqsj2g.js +1 -0
- package/dist/client/static/js/{index-4z5ram7g.js → index-tj7xr4ta.js} +1 -1
- package/dist/client/static/js/{index-h8hjcdj1.js → index-wvw70pgd.js} +2 -2
- package/dist/client/static/js/{index-5dn4159w.js → index-wxs0x3g1.js} +2 -2
- package/dist/client/static/js/index-x507ndnc.js +314 -0
- package/dist/client/static/js/{index-gr8sqjpz.js → index-x87scjpa.js} +1 -1
- package/dist/client/static/js/{index-s5vegk6q.js → index-xtrsvm0d.js} +2 -2
- package/dist/client/static/js/{index-e8mt8rag.js → index-y1j18rha.js} +2 -2
- package/dist/client/static/js/{index-7dqq7cjp.js → index-yv2ervdj.js} +5 -5
- package/dist/client/static/js/{index-gz7kvpnm.js → index-z2pmt1bc.js} +1 -1
- package/dist/client/static/js/{index-5p8dwr4y.js → index-z446edg9.js} +1 -1
- package/dist/client/static/js/{index-a4636gt1.js → index-zkgqa0c2.js} +2 -2
- package/dist/client/static/js/index-zwbw177x.js +2 -0
- package/dist/client/static/js/info-A6RAGUB7-rzpg7qk1.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-xsar9j6v.js → infoDiagram-VRGFBTTK-5mb5w005.js} +2 -2
- package/dist/client/static/js/ini-kjcpgebh.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-g2rvt9jp.js → ishikawaDiagram-OU5B5YK6-zk7fa0fm.js} +2 -2
- package/dist/client/static/js/java-0bcyv1jt.js +1 -0
- package/dist/client/static/js/javascript-0mqgcvps.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-q95v18zc.js → journeyDiagram-ZHPQQLJL-8jd7b2aw.js} +6 -6
- package/dist/client/static/js/json-mb8k0b1n.js +1 -0
- package/dist/client/static/js/jsx-8p6dqgpq.js +1 -0
- package/dist/client/static/js/{julia-pe5vpc2m.js → julia-nwh5w343.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-2e7m7ds3.js → kanban-definition-PNTS6WVX-yp9rks4k.js} +7 -7
- package/dist/client/static/js/lua-nxnqww9z.js +1 -0
- package/dist/client/static/js/markdown-8gbyxxjd.js +1 -0
- package/dist/client/static/js/mermaid.core-kxsxr8ec.js +12 -0
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-banecvf8.js → mindmap-definition-NLK3R4M7-anx2kj3b.js} +7 -7
- package/dist/client/static/js/one-dark-pro-wyegjr0d.js +1 -0
- package/dist/client/static/js/one-light-kp6c3eqh.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-eac14hsq.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-6erykm1c.js → pegDiagram-GJSIUBJH-9egqyzkc.js} +1 -1
- package/dist/client/static/js/{perl-cc2eqye8.js → perl-wb4wtc9x.js} +1 -1
- package/dist/client/static/js/{php-p9bvnpsv.js → php-9g594k9f.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-a9xqvysf.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-jn1d905q.js → pieDiagram-5QR66LMP-f3dvprbm.js} +3 -3
- package/dist/client/static/js/properties-d5bwhgwz.js +1 -0
- package/dist/client/static/js/python-fdwwjjhh.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-sz4afnp1.js → quadrantDiagram-O4NWA36T-qsghd295.js} +6 -6
- package/dist/client/static/js/r-4d2ygtfj.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-jv2pm0fe.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-j74sc0b6.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-eaf19baz.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d4j5nq31.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-ba862a9p.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-ewzhhth2.js → railroadDiagram-XR7U4H2S-6vmazht2.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-fcs3xd42.js → requirementDiagram-PLB6GJNP-phs0wn1v.js} +6 -6
- package/dist/client/static/js/{ruby-65s2ca5d.js → ruby-c4hxsegh.js} +1 -1
- package/dist/client/static/js/{rust-ec1j2hwy.js → rust-e4whdswc.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-2r829rjf.js → sankeyDiagram-IPEJSGJF-vkktegjk.js} +5 -5
- package/dist/client/static/js/{sass-p6cssgq8.js → sass-6yxywx7t.js} +1 -1
- package/dist/client/static/js/{scss-qfx8wt3b.js → scss-9wz47c6t.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3mnte9tv.js → sequenceDiagram-PO4LG4MO-37e6se72.js} +13 -13
- package/dist/client/static/js/{sizeCapture-INFHLROL-r6hf9265.js → sizeCapture-INFHLROL-3b4nsa4s.js} +1 -1
- package/dist/client/static/js/sql-sd00wgem.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-hm2f0wdb.js → stateDiagram-v2-GCMORJYK-2nnyqs9x.js} +6 -6
- package/dist/client/static/js/{svelte-jz3a190v.js → svelte-mm3jfpje.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-s58xzqhw.js → swimlanes-2SLR337P-eezd46ps.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-h78096xp.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-ezm1c4pz.js → timeline-definition-EJHVYXUP-pz0f2b4h.js} +12 -12
- package/dist/client/static/js/treeView-Q6P3EWNA-e8yb44pd.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-zvdv84vp.js +1 -0
- package/dist/client/static/js/tsx-dk8rpgtw.js +1 -0
- package/dist/client/static/js/typescript-5txwpd9t.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ryvgs5ac.js → usecaseDiagram-POWQR4AR-hvg7a87b.js} +82 -82
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-rd5prsf1.js → vennDiagram-UO4OBE2U-03zh9phs.js} +8 -8
- package/dist/client/static/js/{vue-rv4pea8r.js → vue-rcdqpz7q.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-hbv0cg4s.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-1kt8q8a4.js → wardleyDiagram-VNRHLVJA-xy77th92.js} +4 -4
- package/dist/client/static/js/xml-vtrdnrn6.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-q39bbgq4.js → xychartDiagram-PMCCYNJV-h48448cm.js} +4 -4
- package/dist/client/static/js/yaml-6k1tmwtm.js +1 -0
- package/package.json +2 -1
- package/src/client/components/common/MarkdownRenderer.tsx +31 -34
- package/src/client/components/common/ViewportSelector.tsx +4 -0
- package/src/client/components/common/command-palette/index.tsx +5 -2
- package/src/client/components/common/header-button/index.tsx +10 -2
- package/src/client/components/common/markdown-inline-file.test.tsx +131 -0
- package/src/client/components/common/search-select/OptionList.tsx +164 -0
- package/src/client/components/common/search-select/index.tsx +159 -136
- package/src/client/components/common/search-select/option.ts +16 -0
- package/src/client/components/common/search-select/search-select.test.tsx +61 -2
- package/src/client/components/common/sort-menu/index.tsx +9 -4
- package/src/client/components/layout/session-sidebar/HarnessFilter.tsx +26 -6
- package/src/client/components/layout/session-sidebar/scheduler-modal/ModelFields.tsx +45 -49
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +31 -25
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +40 -101
- 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/agent-settings/DetailPane.tsx +12 -10
- 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/command-settings/DetailPane.tsx +12 -10
- package/src/client/components/settings/categories/dictation-settings/CaptureSection.tsx +13 -18
- package/src/client/components/settings/categories/git-settings/CommitMessageSection.tsx +8 -9
- 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/keyboard-settings/ComposerKeys.tsx +10 -10
- package/src/client/components/settings/categories/mcp-settings/AdvancedSection.tsx +21 -18
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +12 -7
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +11 -11
- package/src/client/components/settings/categories/omp-settings/RoleEditor.test.ts +14 -11
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +17 -16
- package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +11 -9
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +10 -9
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +10 -8
- package/src/client/components/settings/categories/provider-settings/DialectFields.tsx +40 -24
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +13 -9
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +22 -17
- package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +79 -50
- package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +14 -7
- 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 +147 -5
- package/src/client/components/settings/categories/voice-settings/SpeechSettings.tsx +27 -3
- package/src/client/components/settings/categories/voice-settings/speech/EndpointSection.tsx +11 -3
- package/src/client/components/settings/categories/voice-settings/speech/EngineSection.tsx +32 -2
- package/src/client/components/settings/categories/voice-settings/speech/ModelsSection.tsx +277 -0
- package/src/client/components/settings/categories/voice-settings/speech/TestSection.tsx +2 -1
- package/src/client/components/settings/categories/voice-settings/speech/VoiceSection.tsx +123 -50
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +20 -2
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.speech.test.tsx +35 -6
- package/src/client/components/workspace/chat-timeline/SpeechButton.tsx +111 -36
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +21 -6
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +7 -4
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +22 -6
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +17 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +8 -65
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +12 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/registry.test.ts +35 -218
- package/src/client/components/workspace/chat-timeline/tool-renderers/registry.ts +40 -177
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +13 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackToolJson.test.tsx +79 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackToolJson.tsx +86 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +25 -16
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +4 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +11 -4
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.plugin.test.ts +3 -1
- package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +15 -15
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +30 -5
- 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/chat.ts +17 -0
- package/src/client/data/mock/token-usage.ts +53 -10
- package/src/client/data/samples/tools-session.ts +8 -5
- 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/editor/font.test.ts +21 -0
- package/src/client/hooks/editor/font.ts +12 -9
- 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/local-tts-models.ts +164 -0
- package/src/client/hooks/settings/useTokenUsage.ts +7 -2
- package/src/client/hooks/tts/tts-context.ts +6 -0
- package/src/client/hooks/tts/use-tts-player.ts +10 -0
- package/src/client/hooks/ui/markdown-render.ts +9 -1
- package/src/client/hooks/ui/markdown-scoped-links.ts +77 -0
- package/src/client/hooks/ui/open-inline-file.test.ts +144 -0
- package/src/client/hooks/ui/open-inline-file.ts +71 -0
- 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/client/lib/commands/overlays.ts +16 -2
- package/src/client/lib/tts/player.test.ts +61 -0
- package/src/client/lib/tts/player.ts +120 -41
- package/src/client/tailwind.css +16 -0
- package/src/server/lib/antigravity/home.server.ts +27 -0
- package/src/server/lib/chat/normalize-tools.server.test.ts +79 -0
- package/src/server/lib/chat/normalize-tools.server.ts +87 -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 +37 -1
- package/src/server/lib/harness/acp/background-replay.ts +8 -3
- 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/frames-tool-shapes.test.ts +41 -13
- package/src/server/lib/harness/acp/frames-vendor-names.test.ts +209 -0
- package/src/server/lib/harness/acp/frames.test.ts +11 -20
- package/src/server/lib/harness/acp/frames.ts +5 -3
- package/src/server/lib/harness/acp/mapper.ts +5 -41
- 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/replay-transcript.ts +6 -1
- 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/acp/subagent-frames.test.ts +1 -1
- package/src/server/lib/harness/acp/subagent-frames.ts +0 -2
- package/src/server/lib/harness/acp/tool-calls.ts +5 -16
- package/src/server/lib/harness/acp/tool-identity.test.ts +69 -8
- package/src/server/lib/harness/acp/tool-identity.ts +58 -10
- package/src/server/lib/harness/acp/tool-shape.ts +5 -3
- package/src/server/lib/harness/auto-probe.server.ts +2 -2
- package/src/server/lib/harness/codex/transcript.server.test.ts +3 -1
- package/src/server/lib/harness/codex/transcript.server.ts +8 -15
- 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/lifecycle/paths.ts +12 -0
- 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/omp/session/messages.ts +5 -1
- package/src/server/lib/realtime/topics/peer-relay.server.ts +9 -1
- package/src/server/lib/realtime/topics/session.server.ts +5 -1
- 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 +50 -8
- package/src/server/lib/tts/engines/deepgram.ts +30 -9
- 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 +14 -0
- package/src/server/lib/tts/engines/local.ts +53 -0
- package/src/server/lib/tts/engines/openai.ts +21 -4
- package/src/server/lib/tts/engines/sherpa-onnx-node.d.ts +38 -0
- package/src/server/lib/tts/engines/sherpa.test.ts +53 -0
- package/src/server/lib/tts/engines/sherpa.ts +287 -0
- package/src/server/lib/tts/local-models.server.ts +257 -0
- package/src/server/lib/tts/local-request.test.ts +66 -0
- package/src/server/lib/tts/local-request.ts +59 -0
- package/src/server/lib/tts/model-manifest.server.test.ts +71 -0
- package/src/server/lib/tts/model-manifest.server.ts +154 -0
- package/src/server/lib/tts/settings.server.ts +7 -4
- package/src/server/lib/tts/wav.test.ts +37 -0
- package/src/server/lib/tts/wav.ts +43 -0
- 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/chat/session-legacy-tools.test.ts +132 -0
- package/src/server/routes/chat/session.ts +10 -4
- 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/index.ts +2 -0
- package/src/server/routes/tts/models.test.ts +148 -0
- package/src/server/routes/tts/models.ts +89 -0
- package/src/server/routes/tts/speak.test.ts +40 -0
- package/src/shared/lib/chat/tool/normalize.ts +67 -0
- package/src/shared/lib/chat/tool/render-key.test.ts +167 -0
- package/src/shared/lib/chat/tool/render-key.ts +247 -0
- package/src/shared/lib/chat/tool/tool-aliases.test.ts +42 -0
- package/src/shared/lib/chat/tool/tool-aliases.ts +59 -12
- package/src/shared/lib/fs/open-reference.test.ts +64 -0
- package/src/shared/lib/fs/open-reference.ts +74 -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/inline-file.test.ts +100 -0
- package/src/shared/lib/markdown/inline-file.ts +213 -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/omp/session/messages-map.test.ts +2 -1
- package/src/shared/lib/omp/session/messages-parse.ts +3 -2
- package/src/shared/lib/omp/session/parse-message-blocks.ts +14 -0
- package/src/shared/lib/omp/subagent/transcript-client.ts +5 -1
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/tts/engines.test.ts +39 -2
- package/src/shared/lib/tts/engines.ts +87 -61
- package/src/shared/lib/tts/local-models.test.ts +69 -0
- package/src/shared/lib/tts/local-models.ts +200 -0
- package/src/shared/lib/tts/settings.ts +1 -1
- package/src/shared/lib/tts/speakable.test.ts +21 -1
- package/src/shared/lib/tts/speakable.ts +66 -33
- package/src/shared/lib/tts/voices.ts +204 -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/chat.ts +3 -0
- package/src/shared/types/harness.ts +5 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/settings/state.ts +12 -0
- package/src/shared/types/tokenUsage.ts +21 -0
- package/src/shared/types/tool-render.ts +37 -0
- package/src/test-support/preload.ts +9 -0
- package/dist/client/static/js/ImageView-g50pk5pt.js +0 -1
- package/dist/client/static/js/LayoutWrapper-tag0qpts.js +0 -2
- 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/SessionsView-2r1grxxs.js +0 -1
- 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/diagram-3UASUU5V-06nptkzc.js +0 -24
- 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/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-14dgbjsm.js +0 -2
- 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-80fjn77c.js +0 -2
- 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-epzvftkq.js +0 -1
- package/dist/client/static/js/index-fbg5vhhw.js +0 -2
- package/dist/client/static/js/index-mbtenbyc.js +0 -9
- package/dist/client/static/js/index-pv4z2mp2.js +0 -463
- package/dist/client/static/js/index-t522tpxt.js +0 -3
- package/dist/client/static/js/index-xw1bptp5.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/mermaid.core-dzajkp0g.js +0 -12
- 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/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/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/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,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The in-process local speech engine: sherpa-onnx's Node addon, one loaded model
|
|
8
|
+
* per install, synthesizing straight to a WAV buffer.
|
|
9
|
+
*
|
|
10
|
+
* Why this and not a spawned `omp say`: omp ships one local model (Phonon 31M,
|
|
11
|
+
* English, no language input at all), and the requirement here is a model the
|
|
12
|
+
* user picks plus Indonesian. sherpa-onnx runs Supertonic 3 — 31 languages
|
|
13
|
+
* including `id` — at RTF 0.10 on a laptop CPU, measured on this machine.
|
|
14
|
+
*
|
|
15
|
+
* Four behaviours are deliberate and each answers a measured failure:
|
|
16
|
+
*
|
|
17
|
+
* - **The addon is imported lazily.** It is a native binary for the current
|
|
18
|
+
* platform; a static import would make an unsupported platform fail at BOOT
|
|
19
|
+
* instead of at the one click that needs it. That is the documented exception
|
|
20
|
+
* to "static imports for known modules": the module genuinely does not exist
|
|
21
|
+
* everywhere.
|
|
22
|
+
* - **The declared language list is enforced here, not by the runtime.** The
|
|
23
|
+
* runtime accepts any of its 32 codes whatever model is loaded: the
|
|
24
|
+
* English-only Supertonic v1 bundle synthesizes Indonesian text when asked
|
|
25
|
+
* for `lang: "id"`. A model that declares languages refuses anything outside
|
|
26
|
+
* them, with the list in the sentence.
|
|
27
|
+
* - **`es-ES` becomes `es`.** Kabmo's language picker is BCP-47; these models
|
|
28
|
+
* take ISO 639-1.
|
|
29
|
+
* - **A missing model is a refusal, never a fallback to another voice.** Reading
|
|
30
|
+
* an answer in the wrong voice is worse than saying nothing.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import fs from 'fs/promises';
|
|
34
|
+
import path from 'path';
|
|
35
|
+
import type { OfflineTts, SherpaRuntime } from 'sherpa-onnx-node';
|
|
36
|
+
import type { LocalTtsArch, LocalTtsModelInfo } from '@/shared/lib/tts/local-models';
|
|
37
|
+
import { TtsEngineError, type TtsAudio } from '@/server/lib/tts/engines/adapter';
|
|
38
|
+
import { resolveLocalLanguage, resolveLocalVoice } from '@/server/lib/tts/local-request';
|
|
39
|
+
import { encodeWavPcm16 } from '@/server/lib/tts/wav';
|
|
40
|
+
|
|
41
|
+
interface LoadedEngine {
|
|
42
|
+
engine: OfflineTts;
|
|
43
|
+
sampleRate: number;
|
|
44
|
+
voices: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface SherpaState {
|
|
48
|
+
/** The resolved module, once the import succeeded. */
|
|
49
|
+
module: SherpaRuntime | null;
|
|
50
|
+
/** A string once the import failed, so it is reported instead of retried. */
|
|
51
|
+
failure: string | null;
|
|
52
|
+
engines: Map<string, LoadedEngine>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The addon holds native handles and `bun --hot` re-evaluates this module while
|
|
57
|
+
* the handle lives on, so the cache lives on `globalThis` — the same rule the
|
|
58
|
+
* database handle follows.
|
|
59
|
+
*/
|
|
60
|
+
function state(): SherpaState {
|
|
61
|
+
const key = Symbol.for('kabmo.tts.sherpa');
|
|
62
|
+
const holder = globalThis as unknown as Record<symbol, SherpaState | undefined>;
|
|
63
|
+
let value = holder[key];
|
|
64
|
+
if (!value) {
|
|
65
|
+
value = { module: null, failure: null, engines: new Map() };
|
|
66
|
+
holder[key] = value;
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The addon, imported once.
|
|
73
|
+
*
|
|
74
|
+
* A dynamic import with a literal specifier, deliberately: the package's entry
|
|
75
|
+
* loads a platform-specific `.node` binary, and on a platform it does not ship
|
|
76
|
+
* for that throw must happen on the click that needs speech, not while the
|
|
77
|
+
* server boots.
|
|
78
|
+
*/
|
|
79
|
+
async function loadSherpa(): Promise<SherpaRuntime> {
|
|
80
|
+
const current = state();
|
|
81
|
+
if (current.module) return current.module;
|
|
82
|
+
if (current.failure) throw new TtsEngineError(current.failure, false);
|
|
83
|
+
try {
|
|
84
|
+
current.module = await import('sherpa-onnx-node');
|
|
85
|
+
return current.module;
|
|
86
|
+
} catch (error: unknown) {
|
|
87
|
+
current.failure =
|
|
88
|
+
`The ONNX speech runtime could not load (${error instanceof Error ? error.message : 'unknown error'}). `
|
|
89
|
+
+ 'Reinstall Kabmo so its native dependency matches this platform.';
|
|
90
|
+
throw new TtsEngineError(current.failure, false);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Whether this install can run local ONNX speech at all. */
|
|
95
|
+
export async function sherpaRuntime(): Promise<{ available: boolean; reason?: string }> {
|
|
96
|
+
try {
|
|
97
|
+
await loadSherpa();
|
|
98
|
+
return { available: true };
|
|
99
|
+
} catch (error: unknown) {
|
|
100
|
+
return { available: false, reason: error instanceof Error ? error.message : 'The ONNX runtime is unavailable.' };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Every entry name in a model directory — files AND directories, because a
|
|
106
|
+
* Kokoro bundle's `espeak-ng-data/` is a directory the config has to see.
|
|
107
|
+
*/
|
|
108
|
+
export async function modelEntries(dir: string): Promise<string[]> {
|
|
109
|
+
try {
|
|
110
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
111
|
+
return entries.map((entry) => entry.name).sort();
|
|
112
|
+
} catch {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** First existing name from a preference list, so int8 wins over fp32. */
|
|
118
|
+
function pick(files: readonly string[], names: readonly string[]): string | null {
|
|
119
|
+
return names.find((name) => files.includes(name)) ?? null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The runtime config for a model directory.
|
|
124
|
+
*
|
|
125
|
+
* Only the two architectures measured working here are offered. Piper's VITS
|
|
126
|
+
* bundle is NOT one of them: sherpa-onnx ≥ 2.0 ignores `--vits-data-dir` and
|
|
127
|
+
* needs phoneme codepoints from an external phonemizer, and the VITS path
|
|
128
|
+
* segfaults Bun outright (measured on 1.4.5).
|
|
129
|
+
*/
|
|
130
|
+
export function buildLocalConfig(
|
|
131
|
+
dir: string,
|
|
132
|
+
arch: LocalTtsArch,
|
|
133
|
+
files: readonly string[],
|
|
134
|
+
threads = 4,
|
|
135
|
+
): { config: unknown; missing: string[] } {
|
|
136
|
+
const at = (name: string) => path.join(dir, name);
|
|
137
|
+
const missing: string[] = [];
|
|
138
|
+
|
|
139
|
+
if (arch === 'supertonic') {
|
|
140
|
+
const duration = pick(files, ['duration_predictor.int8.onnx', 'duration_predictor.onnx']);
|
|
141
|
+
const encoder = pick(files, ['text_encoder.int8.onnx', 'text_encoder.onnx']);
|
|
142
|
+
const estimator = pick(files, ['vector_estimator.int8.onnx', 'vector_estimator.onnx']);
|
|
143
|
+
const vocoder = pick(files, ['vocoder.int8.onnx', 'vocoder.onnx']);
|
|
144
|
+
const ttsJson = pick(files, ['tts.json']);
|
|
145
|
+
const indexer = pick(files, ['unicode_indexer.bin']);
|
|
146
|
+
const voice = pick(files, ['voice.bin']);
|
|
147
|
+
const required: [string | null, string][] = [
|
|
148
|
+
[duration, 'duration_predictor.onnx'],
|
|
149
|
+
[encoder, 'text_encoder.onnx'],
|
|
150
|
+
[estimator, 'vector_estimator.onnx'],
|
|
151
|
+
[vocoder, 'vocoder.onnx'],
|
|
152
|
+
[ttsJson, 'tts.json'],
|
|
153
|
+
[indexer, 'unicode_indexer.bin'],
|
|
154
|
+
[voice, 'voice.bin'],
|
|
155
|
+
];
|
|
156
|
+
for (const [value, name] of required) if (!value) missing.push(name);
|
|
157
|
+
if (missing.length > 0) return { config: null, missing };
|
|
158
|
+
return {
|
|
159
|
+
missing,
|
|
160
|
+
config: {
|
|
161
|
+
model: {
|
|
162
|
+
supertonic: {
|
|
163
|
+
durationPredictor: at(duration!),
|
|
164
|
+
textEncoder: at(encoder!),
|
|
165
|
+
vectorEstimator: at(estimator!),
|
|
166
|
+
vocoder: at(vocoder!),
|
|
167
|
+
ttsJson: at(ttsJson!),
|
|
168
|
+
unicodeIndexer: at(indexer!),
|
|
169
|
+
voiceStyle: at(voice!),
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
numThreads: threads,
|
|
173
|
+
provider: 'cpu',
|
|
174
|
+
debug: 0,
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const model = pick(files, ['model.int8.onnx', 'model.onnx']);
|
|
180
|
+
const voices = pick(files, ['voices.bin']);
|
|
181
|
+
const tokens = pick(files, ['tokens.txt']);
|
|
182
|
+
const required: [string | null, string][] = [
|
|
183
|
+
[model, 'model.onnx'],
|
|
184
|
+
[voices, 'voices.bin'],
|
|
185
|
+
[tokens, 'tokens.txt'],
|
|
186
|
+
];
|
|
187
|
+
for (const [value, name] of required) if (!value) missing.push(name);
|
|
188
|
+
if (missing.length > 0) return { config: null, missing };
|
|
189
|
+
const lexicons = files.filter((name) => /^lexicon-.*\.txt$/.test(name)).map(at);
|
|
190
|
+
return {
|
|
191
|
+
missing,
|
|
192
|
+
config: {
|
|
193
|
+
model: {
|
|
194
|
+
kokoro: {
|
|
195
|
+
model: at(model!),
|
|
196
|
+
voices: at(voices!),
|
|
197
|
+
tokens: at(tokens!),
|
|
198
|
+
// `dataDir` is ignored from sherpa-onnx 2.0 (measured: it warns and
|
|
199
|
+
// falls back to the lexicon), so the lexicon files are the contract.
|
|
200
|
+
...(lexicons.length > 0 ? { lexicon: lexicons.join(',') } : {}),
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
numThreads: threads,
|
|
204
|
+
provider: 'cpu',
|
|
205
|
+
debug: 0,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** The loaded engine for a directory, or a refusal naming what is missing. */
|
|
211
|
+
async function engineFor(dir: string, arch: LocalTtsArch): Promise<LoadedEngine> {
|
|
212
|
+
const current = state();
|
|
213
|
+
const key = `${arch}:${dir}`;
|
|
214
|
+
const cached = current.engines.get(key);
|
|
215
|
+
if (cached) return cached;
|
|
216
|
+
|
|
217
|
+
const sherpa = await loadSherpa();
|
|
218
|
+
const files = await modelEntries(dir);
|
|
219
|
+
const built = buildLocalConfig(dir, arch, files);
|
|
220
|
+
if (!built.config) {
|
|
221
|
+
throw new TtsEngineError(`This model directory is missing ${built.missing.join(', ')}.`, false);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
let engine: OfflineTts;
|
|
225
|
+
try {
|
|
226
|
+
engine = new sherpa.OfflineTts(built.config);
|
|
227
|
+
} catch (error: unknown) {
|
|
228
|
+
throw new TtsEngineError(
|
|
229
|
+
`The model could not be loaded (${error instanceof Error ? error.message : 'unknown error'}).`,
|
|
230
|
+
false,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const loaded: LoadedEngine = { engine, sampleRate: engine.sampleRate, voices: engine.numSpeakers };
|
|
234
|
+
// One model resident at a time: a loaded graph holds ~150 MB and only the
|
|
235
|
+
// configured model is ever spoken.
|
|
236
|
+
current.engines.clear();
|
|
237
|
+
current.engines.set(key, loaded);
|
|
238
|
+
return loaded;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Sample rate and speaker count, read by loading the model once. */
|
|
242
|
+
export async function probeLocalModel(
|
|
243
|
+
dir: string,
|
|
244
|
+
arch: LocalTtsArch,
|
|
245
|
+
): Promise<{ sampleRate: number; voices: number }> {
|
|
246
|
+
const loaded = await engineFor(dir, arch);
|
|
247
|
+
return { sampleRate: loaded.sampleRate, voices: loaded.voices };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Drop a model's loaded engine, so a removed directory is not still resident. */
|
|
251
|
+
export function forgetLocalModel(dir: string): void {
|
|
252
|
+
const current = state();
|
|
253
|
+
for (const key of [...current.engines.keys()]) {
|
|
254
|
+
if (key.endsWith(`:${dir}`)) current.engines.delete(key);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** One request: an installed model directory, the text, and the two choices. */
|
|
259
|
+
export async function synthesizeWithLocal(input: {
|
|
260
|
+
model: LocalTtsModelInfo;
|
|
261
|
+
dir: string;
|
|
262
|
+
text: string;
|
|
263
|
+
voice: string;
|
|
264
|
+
language: string;
|
|
265
|
+
speed: number;
|
|
266
|
+
}): Promise<TtsAudio> {
|
|
267
|
+
const lang = resolveLocalLanguage(input.model, input.language);
|
|
268
|
+
const loaded = await engineFor(input.dir, input.model.arch);
|
|
269
|
+
const sid = resolveLocalVoice(loaded.voices, input.voice);
|
|
270
|
+
|
|
271
|
+
let audio;
|
|
272
|
+
try {
|
|
273
|
+
audio = loaded.engine.generate({ text: input.text, sid, lang, speed: input.speed });
|
|
274
|
+
} catch (error: unknown) {
|
|
275
|
+
throw new TtsEngineError(
|
|
276
|
+
`Local speech failed (${error instanceof Error ? error.message : 'unknown error'}).`,
|
|
277
|
+
false,
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (!audio || audio.samples.length === 0) {
|
|
281
|
+
throw new TtsEngineError('Local speech returned no audio.', true);
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
bytes: encodeWavPcm16(audio.samples, audio.sampleRate || loaded.sampleRate),
|
|
285
|
+
mimeType: 'audio/wav',
|
|
286
|
+
};
|
|
287
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Installed local speech models: where they live, how one arrives, and how a
|
|
8
|
+
* request finds it.
|
|
9
|
+
*
|
|
10
|
+
* A model is a directory of ONNX weights under `<data>/tts-models/<id>/` plus a
|
|
11
|
+
* `model.json` that states what it is. The manifest is the source of truth for
|
|
12
|
+
* "which languages does this model speak" — deliberately, because the runtime
|
|
13
|
+
* answers that question wrongly (it validates the code against its own list, not
|
|
14
|
+
* the loaded model: the English-only Supertonic v1 bundle synthesizes Indonesian
|
|
15
|
+
* text on request).
|
|
16
|
+
*
|
|
17
|
+
* Installs are long (100–150 MB) and the settings page has to show progress, so
|
|
18
|
+
* the job state is process-wide and readable between requests. A second install
|
|
19
|
+
* of the same id joins the running job instead of starting another download.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import fs from 'fs/promises';
|
|
23
|
+
import path from 'path';
|
|
24
|
+
import { getTtsModelsDir } from '@/server/lib/lifecycle/paths';
|
|
25
|
+
import {
|
|
26
|
+
catalogModel,
|
|
27
|
+
type InstallJob,
|
|
28
|
+
type LocalTtsModelInfo,
|
|
29
|
+
} from '@/shared/lib/tts/local-models';
|
|
30
|
+
import {
|
|
31
|
+
catalogForUrl,
|
|
32
|
+
detectArch,
|
|
33
|
+
modelIdFromUrl,
|
|
34
|
+
writeManifest,
|
|
35
|
+
} from '@/server/lib/tts/model-manifest.server';
|
|
36
|
+
import { modelEntries, probeLocalModel, forgetLocalModel } from '@/server/lib/tts/engines/sherpa';
|
|
37
|
+
|
|
38
|
+
/** A model is 100–150 MB; anything past this is not a speech model. */
|
|
39
|
+
const MAX_ARCHIVE_BYTES = 1_500_000_000;
|
|
40
|
+
/** Extraction of a 150 MB archive on a slow disk is minutes, not seconds. */
|
|
41
|
+
const EXTRACT_TIMEOUT_MS = 300_000;
|
|
42
|
+
|
|
43
|
+
interface InstallState {
|
|
44
|
+
jobs: Map<string, InstallJob>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function state(): InstallState {
|
|
48
|
+
const key = Symbol.for('kabmo.tts.installs');
|
|
49
|
+
const holder = globalThis as unknown as Record<symbol, InstallState | undefined>;
|
|
50
|
+
let value = holder[key];
|
|
51
|
+
if (!value) {
|
|
52
|
+
value = { jobs: new Map() };
|
|
53
|
+
holder[key] = value;
|
|
54
|
+
}
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Live install jobs, for the settings page. */
|
|
59
|
+
export function installJobs(): InstallJob[] {
|
|
60
|
+
return [...state().jobs.values()].sort((a, b) => b.startedAt - a.startedAt);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function setJob(id: string, patch: Partial<InstallJob> & { label: string }): InstallJob {
|
|
64
|
+
const current = state().jobs.get(id);
|
|
65
|
+
const next: InstallJob = {
|
|
66
|
+
id,
|
|
67
|
+
label: patch.label,
|
|
68
|
+
status: patch.status ?? current?.status ?? 'downloading',
|
|
69
|
+
received: patch.received ?? current?.received ?? 0,
|
|
70
|
+
total: patch.total ?? current?.total ?? 0,
|
|
71
|
+
progress: patch.progress ?? current?.progress ?? 0,
|
|
72
|
+
...(patch.error ? { error: patch.error } : {}),
|
|
73
|
+
url: patch.url ?? current?.url,
|
|
74
|
+
startedAt: current?.startedAt ?? Date.now(),
|
|
75
|
+
};
|
|
76
|
+
state().jobs.set(id, next);
|
|
77
|
+
return next;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Stream a URL to a file, reporting bytes as they land. */
|
|
81
|
+
async function download(url: string, target: string, id: string, label: string): Promise<number> {
|
|
82
|
+
const response = await fetch(url, { redirect: 'follow' });
|
|
83
|
+
if (!response.ok) throw new Error(`The download answered HTTP ${response.status}.`);
|
|
84
|
+
const total = Number(response.headers.get('content-length') ?? 0);
|
|
85
|
+
if (total > MAX_ARCHIVE_BYTES) throw new Error('That archive is too large to be a speech model.');
|
|
86
|
+
if (!response.body) throw new Error('The server sent no body.');
|
|
87
|
+
|
|
88
|
+
const handle = await fs.open(target, 'w');
|
|
89
|
+
const reader = response.body.getReader();
|
|
90
|
+
let received = 0;
|
|
91
|
+
try {
|
|
92
|
+
for (;;) {
|
|
93
|
+
const { done, value } = await reader.read();
|
|
94
|
+
if (done) break;
|
|
95
|
+
received += value.byteLength;
|
|
96
|
+
if (received > MAX_ARCHIVE_BYTES) throw new Error('That archive is too large to be a speech model.');
|
|
97
|
+
await handle.write(value);
|
|
98
|
+
setJob(id, {
|
|
99
|
+
label,
|
|
100
|
+
status: 'downloading',
|
|
101
|
+
received,
|
|
102
|
+
total,
|
|
103
|
+
progress: total > 0 ? Math.min(0.99, received / total) : 0,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
} finally {
|
|
107
|
+
await reader.cancel().catch(() => undefined);
|
|
108
|
+
await handle.close();
|
|
109
|
+
}
|
|
110
|
+
if (received === 0) throw new Error('The download was empty.');
|
|
111
|
+
return received;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Extract an archive into `into`, with the platform `tar` (Bun has no bzip2). */
|
|
115
|
+
async function extract(archive: string, into: string): Promise<void> {
|
|
116
|
+
await fs.mkdir(into, { recursive: true });
|
|
117
|
+
const child = Bun.spawn({
|
|
118
|
+
cmd: ['tar', '-xf', archive, '-C', into, '--no-same-owner'],
|
|
119
|
+
stdin: 'ignore',
|
|
120
|
+
stdout: 'ignore',
|
|
121
|
+
stderr: 'pipe',
|
|
122
|
+
env: process.env,
|
|
123
|
+
});
|
|
124
|
+
const stderr = new Response(child.stderr).text().catch(() => '');
|
|
125
|
+
const timer = setTimeout(() => child.kill(), EXTRACT_TIMEOUT_MS);
|
|
126
|
+
try {
|
|
127
|
+
const code = await child.exited;
|
|
128
|
+
if (code !== 0) {
|
|
129
|
+
const detail = (await stderr).trim().split('\n').filter(Boolean).at(-1)?.slice(0, 200);
|
|
130
|
+
throw new Error(`The archive could not be unpacked${detail ? ` — ${detail}` : ''}.`);
|
|
131
|
+
}
|
|
132
|
+
} finally {
|
|
133
|
+
clearTimeout(timer);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The directory that holds the weights: the archive's single top folder, or itself. */
|
|
138
|
+
async function modelRoot(dir: string): Promise<string> {
|
|
139
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
140
|
+
const dirs = entries.filter((entry) => entry.isDirectory());
|
|
141
|
+
const files = entries.filter((entry) => entry.isFile());
|
|
142
|
+
if (dirs.length === 1 && files.length === 0) return path.join(dir, dirs[0]!.name);
|
|
143
|
+
return dir;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Move `from`'s contents into `to`, then drop `from`. */
|
|
147
|
+
async function adopt(from: string, to: string): Promise<void> {
|
|
148
|
+
await fs.rm(to, { recursive: true, force: true });
|
|
149
|
+
await fs.rename(from, to);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Install a model: curated id, or a URL to a `.tar.bz2`/`.tar.gz` bundle.
|
|
154
|
+
*
|
|
155
|
+
* The job is registered BEFORE the first byte arrives, so the settings page can
|
|
156
|
+
* poll a download that has not started writing yet, and a failure leaves a job
|
|
157
|
+
* with its error rather than a silent disappearance.
|
|
158
|
+
*/
|
|
159
|
+
export async function installModel(input: { id?: string; url?: string }): Promise<InstallJob> {
|
|
160
|
+
const curated = input.id ? catalogModel(input.id) : undefined;
|
|
161
|
+
const url = (curated?.sourceUrl ?? input.url ?? '').trim();
|
|
162
|
+
if (!url) throw new Error('Pick a model, or paste a link to one.');
|
|
163
|
+
|
|
164
|
+
let parsed: URL;
|
|
165
|
+
try {
|
|
166
|
+
parsed = new URL(url);
|
|
167
|
+
} catch {
|
|
168
|
+
throw new Error('That is not a link.');
|
|
169
|
+
}
|
|
170
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
|
|
171
|
+
throw new Error('A model link must be http or https.');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const fromCatalog = curated ?? catalogForUrl(url);
|
|
175
|
+
const id = curated?.id ?? modelIdFromUrl(url);
|
|
176
|
+
const label = fromCatalog?.label ?? id;
|
|
177
|
+
const existing = state().jobs.get(id);
|
|
178
|
+
if (existing && existing.status !== 'ready' && existing.status !== 'error') return existing;
|
|
179
|
+
|
|
180
|
+
const job = setJob(id, { label, url, status: 'downloading', received: 0, total: 0, progress: 0 });
|
|
181
|
+
void runInstall({ id, label, url, fromCatalog }).catch((error: unknown) => {
|
|
182
|
+
setJob(id, {
|
|
183
|
+
label,
|
|
184
|
+
url,
|
|
185
|
+
status: 'error',
|
|
186
|
+
error: error instanceof Error ? error.message : 'The install failed.',
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
return job;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function runInstall(input: {
|
|
193
|
+
id: string;
|
|
194
|
+
label: string;
|
|
195
|
+
url: string;
|
|
196
|
+
fromCatalog: LocalTtsModelInfo | undefined;
|
|
197
|
+
}): Promise<void> {
|
|
198
|
+
const root = getTtsModelsDir();
|
|
199
|
+
const staging = path.join(root, `.install-${input.id}-${Date.now()}`);
|
|
200
|
+
const archive = path.join(staging, 'bundle');
|
|
201
|
+
const target = path.join(root, input.id);
|
|
202
|
+
try {
|
|
203
|
+
await fs.mkdir(staging, { recursive: true });
|
|
204
|
+
const bytes = await download(input.url, archive, input.id, input.label);
|
|
205
|
+
|
|
206
|
+
setJob(input.id, { label: input.label, url: input.url, status: 'extracting', received: bytes, progress: 1 });
|
|
207
|
+
const unpacked = path.join(staging, 'unpacked');
|
|
208
|
+
await extract(archive, unpacked);
|
|
209
|
+
const source = await modelRoot(unpacked);
|
|
210
|
+
const entries = await modelEntries(source);
|
|
211
|
+
const arch = detectArch(entries);
|
|
212
|
+
if (!arch) {
|
|
213
|
+
throw new Error(
|
|
214
|
+
'That archive is not a speech model this build can run. It needs either the Supertonic '
|
|
215
|
+
+ 'files (tts.json, voice.bin, duration_predictor/text_encoder/vector_estimator/vocoder) '
|
|
216
|
+
+ 'or the Kokoro ones (model.onnx, voices.bin, tokens.txt).',
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
setJob(input.id, { label: input.label, url: input.url, status: 'probing', received: bytes, progress: 1 });
|
|
221
|
+
await adopt(source, target);
|
|
222
|
+
const probed = await probeLocalModel(target, arch);
|
|
223
|
+
const installedAt = new Date().toISOString();
|
|
224
|
+
const info: LocalTtsModelInfo = {
|
|
225
|
+
id: input.id,
|
|
226
|
+
label: input.fromCatalog?.label ?? input.label,
|
|
227
|
+
arch,
|
|
228
|
+
// A curated bundle states its languages; a pasted one states nothing, and
|
|
229
|
+
// the settings page says so instead of inventing a list.
|
|
230
|
+
languages: input.fromCatalog?.languages ?? [],
|
|
231
|
+
defaultLanguage: input.fromCatalog?.defaultLanguage ?? 'en',
|
|
232
|
+
voices: probed.voices,
|
|
233
|
+
...(input.fromCatalog?.voiceLabels ? { voiceLabels: input.fromCatalog.voiceLabels } : {}),
|
|
234
|
+
sampleRate: probed.sampleRate,
|
|
235
|
+
sizeBytes: bytes,
|
|
236
|
+
sourceUrl: input.url,
|
|
237
|
+
installedAt,
|
|
238
|
+
...(input.fromCatalog?.notes ? { notes: input.fromCatalog.notes } : {}),
|
|
239
|
+
};
|
|
240
|
+
await writeManifest(target, info);
|
|
241
|
+
setJob(input.id, { label: info.label, url: input.url, status: 'ready', received: bytes, progress: 1 });
|
|
242
|
+
} catch (error: unknown) {
|
|
243
|
+
await fs.rm(target, { recursive: true, force: true }).catch(() => undefined);
|
|
244
|
+
throw error;
|
|
245
|
+
} finally {
|
|
246
|
+
await fs.rm(staging, { recursive: true, force: true }).catch(() => undefined);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Remove an installed model, and its loaded engine with it. */
|
|
251
|
+
export async function removeModel(id: string): Promise<void> {
|
|
252
|
+
if (!/^[a-z0-9._-]{1,64}$/.test(id)) throw new Error('That is not a model id.');
|
|
253
|
+
const dir = path.join(getTtsModelsDir(), id);
|
|
254
|
+
forgetLocalModel(dir);
|
|
255
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
256
|
+
state().jobs.delete(id);
|
|
257
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, test } from 'bun:test';
|
|
7
|
+
|
|
8
|
+
import { TtsEngineError } from '@/server/lib/tts/engines/adapter';
|
|
9
|
+
import { baseLanguage, resolveLocalLanguage, resolveLocalVoice } from '@/server/lib/tts/local-request';
|
|
10
|
+
import type { LocalTtsModelInfo } from '@/shared/lib/tts/local-models';
|
|
11
|
+
|
|
12
|
+
const model: LocalTtsModelInfo = {
|
|
13
|
+
id: 'supertonic-3',
|
|
14
|
+
label: 'Supertonic 3',
|
|
15
|
+
arch: 'supertonic',
|
|
16
|
+
languages: ['en', 'id', 'ja'],
|
|
17
|
+
defaultLanguage: 'en',
|
|
18
|
+
voices: 10,
|
|
19
|
+
sampleRate: 44_100,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('language resolution', () => {
|
|
23
|
+
test('BCP-47 becomes the ISO code these models take', () => {
|
|
24
|
+
expect(baseLanguage('es-ES')).toBe('es');
|
|
25
|
+
expect(baseLanguage('pt_BR')).toBe('pt');
|
|
26
|
+
expect(baseLanguage('')).toBe('');
|
|
27
|
+
expect(resolveLocalLanguage(model, 'id-ID')).toBe('id');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('an empty setting uses the model default, not a guess', () => {
|
|
31
|
+
expect(resolveLocalLanguage(model, '')).toBe('en');
|
|
32
|
+
expect(resolveLocalLanguage({ ...model, defaultLanguage: 'id' }, '')).toBe('id');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('a language the model does not declare is refused, with the list', () => {
|
|
36
|
+
let thrown: unknown;
|
|
37
|
+
try {
|
|
38
|
+
resolveLocalLanguage(model, 'th');
|
|
39
|
+
} catch (error: unknown) {
|
|
40
|
+
thrown = error;
|
|
41
|
+
}
|
|
42
|
+
expect(thrown).toBeInstanceOf(TtsEngineError);
|
|
43
|
+
expect((thrown as TtsEngineError).message).toContain('does not speak TH');
|
|
44
|
+
expect((thrown as TtsEngineError).message).toContain('en, id, ja');
|
|
45
|
+
expect((thrown as TtsEngineError).retryable).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('a model that declares nothing passes the code through', () => {
|
|
49
|
+
expect(resolveLocalLanguage({ ...model, languages: [] }, 'th')).toBe('th');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('voice resolution', () => {
|
|
54
|
+
test('an index inside the speaker range is kept; empty means the first', () => {
|
|
55
|
+
expect(resolveLocalVoice(10, '')).toBe(0);
|
|
56
|
+
expect(resolveLocalVoice(10, '0')).toBe(0);
|
|
57
|
+
expect(resolveLocalVoice(10, '9')).toBe(9);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('an index outside the range names the range', () => {
|
|
61
|
+
expect(() => resolveLocalVoice(10, '10')).toThrow(/voices 0–9/);
|
|
62
|
+
expect(() => resolveLocalVoice(3, '7')).toThrow(/voices 0–2/);
|
|
63
|
+
expect(() => resolveLocalVoice(10, 'female')).toThrow(/not one of them/);
|
|
64
|
+
expect(() => resolveLocalVoice(10, '-1')).toThrow(/voices 0–9/);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The two choices a local request carries — a language and a voice — and the
|
|
8
|
+
* refusals that keep them honest.
|
|
9
|
+
*
|
|
10
|
+
* Both rules exist because the runtime does not enforce either: it validates the
|
|
11
|
+
* language code against its own 32-code list rather than the loaded model (the
|
|
12
|
+
* English-only Supertonic v1 bundle synthesizes Indonesian text on request), and
|
|
13
|
+
* it clamps an out-of-range speaker id to 0 instead of reporting it. Reading an
|
|
14
|
+
* answer in the wrong language or the wrong person is the failure both refusals
|
|
15
|
+
* prevent, so the message names what IS available.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { TtsEngineError } from '@/server/lib/tts/engines/adapter';
|
|
19
|
+
import type { LocalTtsModelInfo } from '@/shared/lib/tts/local-models';
|
|
20
|
+
|
|
21
|
+
/** `es-ES` → `es`; '' stays ''. These models take ISO 639-1. */
|
|
22
|
+
export function baseLanguage(language: string): string {
|
|
23
|
+
return language.trim().toLowerCase().split(/[-_]/)[0] ?? '';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The language a request will actually synthesize.
|
|
28
|
+
*
|
|
29
|
+
* A model that declares languages refuses anything else. A model that declares
|
|
30
|
+
* nothing passes the code through — and the settings page says it declared
|
|
31
|
+
* nothing, so the choice is visibly the user's.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveLocalLanguage(model: LocalTtsModelInfo, language: string): string {
|
|
34
|
+
const requested = baseLanguage(language);
|
|
35
|
+
const declared = model.languages;
|
|
36
|
+
if (!requested) return model.defaultLanguage || declared[0] || 'en';
|
|
37
|
+
if (declared.length === 0) return requested;
|
|
38
|
+
if (declared.includes(requested)) return requested;
|
|
39
|
+
throw new TtsEngineError(
|
|
40
|
+
`${model.label} does not speak ${requested.toUpperCase()}. It speaks: ${declared.join(', ')}.`,
|
|
41
|
+
false,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A speaker id inside the model's range, or a refusal naming the range. */
|
|
46
|
+
export function resolveLocalVoice(voices: number, voice: string): number {
|
|
47
|
+
const text = voice.trim();
|
|
48
|
+
if (!text) return 0;
|
|
49
|
+
const sid = Number(text);
|
|
50
|
+
if (!Number.isInteger(sid) || sid < 0 || (voices > 0 && sid >= voices)) {
|
|
51
|
+
throw new TtsEngineError(
|
|
52
|
+
voices > 0
|
|
53
|
+
? `That model has voices 0–${voices - 1}; "${text}" is not one of them.`
|
|
54
|
+
: `"${text}" is not a voice id.`,
|
|
55
|
+
false,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return sid;
|
|
59
|
+
}
|