@kabmo-labs/kabmo 0.47.0 → 0.48.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 +497 -497
- package/dist/client/static/js/Body-3tspyjtk.js +3 -0
- package/dist/client/static/js/{CsvGrid-vfgttmym.js → CsvGrid-3pwsfmxp.js} +2 -2
- package/dist/client/static/js/{DocxView-dc41t6rp.js → DocxView-xcg9jktb.js} +3 -3
- package/dist/client/static/js/{DrawioView-wpwr38d9.js → DrawioView-2q19tgkx.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-23n7t5cs.js → HtmlPreview-92cadvbr.js} +1 -1
- package/dist/client/static/js/ImageView-pr4h38hb.js +1 -0
- package/dist/client/static/js/LayoutWrapper-n4tzhjes.js +2 -0
- package/dist/client/static/js/MergeDiffView-0t15nh9f.js +1 -0
- package/dist/client/static/js/{Modal-dsqhas10.js → Modal-77hgx4dw.js} +20 -20
- package/dist/client/static/js/{PdfView-cpvsbfk0.js → PdfView-gzxhvxe8.js} +1 -1
- package/dist/client/static/js/{SessionsView-s0crtcm8.js → SessionsView-2tdqrvk0.js} +1 -1
- package/dist/client/static/js/{SheetView-n6mst0hq.js → SheetView-w5w2m2de.js} +21 -21
- package/dist/client/static/js/{SvgPreview-g2aqq812.js → SvgPreview-mtk6de6h.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-3vac8sq4.js → abnfDiagram-O67JEVCF-tha4j2fn.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-zs15nydj.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-1nh4htz2.js → architectureDiagram-NJMV4G6O-heep78p6.js} +6 -6
- package/dist/client/static/js/{astro-63zcysj7.js → astro-r4dp34pw.js} +1 -1
- package/dist/client/static/js/bash-8d3wrx5c.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-62z6kaar.js → blockDiagram-BEXU5L5S-6mzgfqh8.js} +5 -5
- package/dist/client/static/js/c-rn3z0csz.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rts5zgx4.js → c4Diagram-YGBWAQC7-sfkcw7g9.js} +4 -4
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-tnpww186.js → classDiagram-v2-NBCMYWYE-v530ny5e.js} +6 -6
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-8vsjbzwa.js → cose-bilkent-JH36ORCC-ybv1ttbx.js} +1 -1
- package/dist/client/static/js/cpp-99ws9nak.js +1 -0
- package/dist/client/static/js/css-narcr42w.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-p3y1b4ap.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-005gc8km.js → cynefinDiagram-VND7K2PF-k8f3z0mm.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-41zsteyd.js → dagre-6A5THRUB-gk0gp124.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-prsm18a1.js → diagram-22UHCM2B-2zh2957c.js} +15 -15
- package/dist/client/static/js/{diagram-3UASUU5V-5nx9wf04.js → diagram-3UASUU5V-bzstt5e2.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-k3d4z3aq.js → diagram-ATOU4E4O-16adx4g0.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-x2c5x5j2.js → diagram-CDSNMT55-1ja98ens.js} +5 -5
- package/dist/client/static/js/{diagram-MLGK6HIB-nvr76jqh.js → diagram-MLGK6HIB-f9nnyjbq.js} +2 -2
- package/dist/client/static/js/{diagram-MPIPVDR6-v1jpzp9p.js → diagram-MPIPVDR6-3qgadfjz.js} +2 -2
- package/dist/client/static/js/{dockerfile-vz6va73h.js → dockerfile-04tc68pq.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-0v4tqr9v.js → ebnfDiagram-ZINNZB2B-022cz603.js} +1 -1
- package/dist/client/static/js/{elixir-80wq7gak.js → elixir-61gbjv6c.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-qfn4r7xj.js → elk-276RUBZZ-2anf1c36.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-cd667n9f.js → erDiagram-OPXOYQCR-ndd27fz1.js} +7 -7
- package/dist/client/static/js/{erlang-vk66vt7q.js → erlang-bh5cbm8m.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-sx2cwkz3.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-dsc17mty.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ps0h3drm.js → ganttDiagram-FUAMR5RP-9gm6hkgn.js} +4 -4
- package/dist/client/static/js/gitGraph-4MIJSDKK-yqhbscsd.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fts23jer.js → gitGraphDiagram-X574FWY7-78bxa67c.js} +8 -8
- package/dist/client/static/js/graphql-tr0jcndy.js +1 -0
- package/dist/client/static/js/html-n8fdvrdk.js +1 -0
- package/dist/client/static/js/index-0e51wknc.js +10 -0
- package/dist/client/static/js/{index-7zedprz3.js → index-13g17wa3.js} +1 -1
- package/dist/client/static/js/index-1hb8fvw9.js +1 -0
- package/dist/client/static/js/{index-1c2jvnyh.js → index-2bsnywea.js} +2 -2
- package/dist/client/static/js/{index-9ab6xaxd.js → index-2n1fgpjv.js} +2 -2
- package/dist/client/static/js/{index-a4h5np9r.js → index-30a8py59.js} +2 -2
- package/dist/client/static/js/{index-e5j5gc4h.js → index-34aq5bz5.js} +2 -2
- package/dist/client/static/js/index-3en15m75.js +2 -0
- package/dist/client/static/js/{index-64p1dncg.js → index-417fbrqk.js} +2 -2
- package/dist/client/static/js/{index-z4530r3c.js → index-45p59fxq.js} +2 -2
- package/dist/client/static/js/index-4n7t26ap.js +2 -0
- package/dist/client/static/js/{index-1whzs9kb.js → index-55pqvh82.js} +2 -2
- package/dist/client/static/js/index-5mpv57fn.js +12 -0
- package/dist/client/static/js/{index-tqgj7rd9.js → index-7pz6n3pg.js} +2 -2
- package/dist/client/static/js/{index-4jzsr1ky.js → index-7whstwc7.js} +2 -2
- package/dist/client/static/js/index-869vdnz8.js +2 -0
- package/dist/client/static/js/{index-52nd4hgm.js → index-8tvrzce0.js} +2 -2
- package/dist/client/static/js/index-9a78xmkk.js +462 -0
- package/dist/client/static/js/{index-33qxg79j.js → index-a58rkn3f.js} +5 -5
- package/dist/client/static/js/{index-9xsf8162.js → index-aa3hmn6j.js} +65 -65
- package/dist/client/static/js/{index-dxkefysk.js → index-aabp7nt6.js} +1 -1
- package/dist/client/static/js/{index-c5hjht5e.js → index-abrrqhne.js} +2 -2
- package/dist/client/static/js/{index-an2wv33f.js → index-ac2q5903.js} +2 -2
- package/dist/client/static/js/index-axtm1aq8.js +2 -0
- package/dist/client/static/js/index-b2cs4c51.js +4 -0
- package/dist/client/static/js/{index-xk1cqjkn.js → index-c250nzm1.js} +3 -3
- package/dist/client/static/js/{index-56rtb871.js → index-dxnkwf39.js} +52 -52
- package/dist/client/static/js/{index-39d8zbkx.js → index-e6ny4gd9.js} +6 -6
- package/dist/client/static/js/index-ebf50mrs.js +9 -0
- package/dist/client/static/js/{index-g4kkapka.js → index-ep6bqcmg.js} +2 -2
- package/dist/client/static/js/{index-396r53n0.js → index-fb2s080r.js} +2 -2
- package/dist/client/static/js/index-fryp0kgf.js +2 -0
- package/dist/client/static/js/{index-evmcc5qh.js → index-g3rg6vsd.js} +2 -2
- package/dist/client/static/js/{index-sa1675y0.js → index-g8rpydkr.js} +2 -2
- package/dist/client/static/js/{index-zhjjpvcc.js → index-gkmn4y1v.js} +1 -1
- package/dist/client/static/js/{index-0dkc6z8e.js → index-gpmcth0x.js} +2 -2
- package/dist/client/static/js/{index-62jgcgfd.js → index-hcmhdpp4.js} +10 -10
- package/dist/client/static/js/{index-fxd8dfj4.js → index-he4k2j91.js} +2 -2
- package/dist/client/static/js/{index-x0xspam4.js → index-hq28918s.js} +2 -2
- package/dist/client/static/js/{index-c63qyysm.js → index-hwzxdwwg.js} +1 -1
- package/dist/client/static/js/{index-4wnzs76g.js → index-jnkc9p53.js} +1 -1
- package/dist/client/static/js/{index-54mkp2r2.js → index-k39be93q.js} +1 -1
- package/dist/client/static/js/{index-y6ke70e6.js → index-kaxvwh07.js} +2 -2
- package/dist/client/static/js/{index-7zeah164.js → index-kjr68pcj.js} +2 -2
- package/dist/client/static/js/{index-cra9mgkq.js → index-m0fatq7c.js} +4 -4
- package/dist/client/static/js/{index-ccgzzydx.js → index-m39gbcxn.js} +1 -1
- package/dist/client/static/js/{index-q4ke39rh.js → index-mqzgf7rw.js} +2 -2
- package/dist/client/static/js/{index-dzeyd153.js → index-pzsp1src.js} +2 -2
- package/dist/client/static/js/{index-n1yr4khe.js → index-qe0vfv6s.js} +1 -1
- package/dist/client/static/js/{index-6009v8jf.js → index-qek9mt5w.js} +1 -1
- package/dist/client/static/js/{index-nkahe229.js → index-qxzj780x.js} +2 -2
- package/dist/client/static/js/{index-cvyqp8nz.css → index-rgxg0azs.css} +1 -1
- package/dist/client/static/js/{index-1d8bxjsz.js → index-rq4dk4tp.js} +4 -4
- package/dist/client/static/js/{index-6d6hxwb5.js → index-seekt5k3.js} +2 -2
- package/dist/client/static/js/{index-gzkzwgzv.js → index-sng4prpr.js} +2 -2
- package/dist/client/static/js/{index-dyc886cc.js → index-t4s10406.js} +2 -2
- package/dist/client/static/js/{index-f2ahkev0.js → index-tzz5gp8a.js} +5 -5
- package/dist/client/static/js/index-vnv9z0a1.js +1 -0
- package/dist/client/static/js/{index-70g527sb.js → index-x7rajphe.js} +2 -2
- package/dist/client/static/js/{index-5f4b44ay.js → index-xny7vsfz.js} +2 -2
- package/dist/client/static/js/index-xr4hjv01.js +2 -0
- package/dist/client/static/js/{index-fjex1y0t.js → index-ya9yqj5w.js} +2 -2
- package/dist/client/static/js/{index-z0fkfphe.js → index-zcgqacvx.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-0sd3zzgg.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-88qbtpq5.js → infoDiagram-VRGFBTTK-bxk0g0pe.js} +2 -2
- package/dist/client/static/js/ini-tnaw7zjy.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-s8bagk00.js → ishikawaDiagram-OU5B5YK6-d1kdkhth.js} +3 -3
- package/dist/client/static/js/java-m4dpc2vw.js +1 -0
- package/dist/client/static/js/javascript-8y26t991.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-hz8z0b9x.js → journeyDiagram-ZHPQQLJL-cahg3zjq.js} +4 -4
- package/dist/client/static/js/json-azm7bdqd.js +1 -0
- package/dist/client/static/js/jsx-p9j1k773.js +1 -0
- package/dist/client/static/js/{julia-dm0j9apa.js → julia-2n5k898q.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-sjjnjb51.js → kanban-definition-PNTS6WVX-nq7t83en.js} +6 -6
- package/dist/client/static/js/lua-hbm9rhz9.js +1 -0
- package/dist/client/static/js/markdown-tk3cd3vs.js +1 -0
- package/dist/client/static/js/{mermaid.core-zvwygxbh.js → mermaid.core-6nw0853j.js} +8 -8
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-kgj8enan.js → mindmap-definition-NLK3R4M7-cm7ykxf2.js} +3 -3
- package/dist/client/static/js/one-dark-pro-2cdc2nk7.js +1 -0
- package/dist/client/static/js/one-light-bt6z4jf0.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-13w2v5bb.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-gxzw1qwa.js → pegDiagram-GJSIUBJH-xwxz8nsq.js} +1 -1
- package/dist/client/static/js/{perl-4jcm2jxv.js → perl-66vb5pz7.js} +1 -1
- package/dist/client/static/js/{php-q32mec74.js → php-4e9we8am.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-swtnysgn.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-pdqwyqcm.js → pieDiagram-5QR66LMP-n910k9th.js} +3 -3
- package/dist/client/static/js/properties-6911ckw7.js +1 -0
- package/dist/client/static/js/python-44cvj250.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-yx2t364p.js → quadrantDiagram-O4NWA36T-dxkwxbqb.js} +6 -6
- package/dist/client/static/js/r-t3sepzm4.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-vtvxkx55.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-5sp2d63r.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-kg706fan.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-4ra1gzx5.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-hms3zpjm.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-800fdzkr.js → railroadDiagram-XR7U4H2S-xb1smt7r.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-vc5rpgtm.js → requirementDiagram-PLB6GJNP-6kb21b9f.js} +6 -6
- package/dist/client/static/js/{ruby-npmpb290.js → ruby-v7nmcvyr.js} +1 -1
- package/dist/client/static/js/{rust-waks43wh.js → rust-5ersd7be.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-ccjk8zgn.js → sankeyDiagram-IPEJSGJF-74z0fskw.js} +4 -4
- package/dist/client/static/js/{sass-502a4r7y.js → sass-h3nvy4c8.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-c0tk7gfn.js → sequenceDiagram-PO4LG4MO-apn6kezn.js} +17 -17
- package/dist/client/static/js/{sizeCapture-INFHLROL-fma9p1vy.js → sizeCapture-INFHLROL-2drzcjb8.js} +1 -1
- package/dist/client/static/js/sql-zdkawqx3.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-d8f24b7j.js → stateDiagram-v2-GCMORJYK-ma09vhby.js} +3 -3
- package/dist/client/static/js/{svelte-c15d0421.js → svelte-dhspkgss.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-sdt7qy36.js → swimlanes-2SLR337P-f6y9xqnx.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-3dwas56m.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-rv8qyr8b.js → timeline-definition-EJHVYXUP-zmcmvq00.js} +5 -5
- package/dist/client/static/js/treeView-Q6P3EWNA-7t5k6rs2.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-w56ry3bg.js +1 -0
- package/dist/client/static/js/tsx-b7eabr17.js +1 -0
- package/dist/client/static/js/typescript-nnkvhwfy.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-w6ew1red.js → usecaseDiagram-POWQR4AR-wfaa019a.js} +24 -24
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-p9axw7ch.js → vennDiagram-UO4OBE2U-46wf2pgd.js} +8 -8
- package/dist/client/static/js/{vue-xpemy62d.js → vue-ffngx2b3.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-rtjb9kgv.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-5ewc8s4p.js → wardleyDiagram-VNRHLVJA-10ph3bzq.js} +4 -4
- package/dist/client/static/js/xml-xy1tw6b2.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7n4gn7k6.js → xychartDiagram-PMCCYNJV-2ba825z9.js} +5 -5
- package/dist/client/static/js/yaml-0fexqg2d.js +1 -0
- package/package.json +1 -1
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +10 -3
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +27 -4
- package/src/client/components/settings/categories/usage-settings/TokenHarborCard.tsx +160 -0
- package/src/client/components/settings/categories/usage-settings/TokenPortalCard.tsx +104 -0
- package/src/client/components/settings/categories/usage-settings/format.ts +35 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +16 -0
- package/src/client/components/settings/categories/usage-settings/providers.ts +26 -4
- package/src/client/components/settings/categories/usage-settings/token-harbor-card.test.tsx +114 -0
- package/src/client/components/settings/categories/usage-settings/token-harbor-hint.test.ts +68 -0
- package/src/client/components/settings/categories/usage-settings/token-portal-card.test.tsx +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +66 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +13 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.tsx +41 -18
- package/src/client/components/workspace/editor/BodyLazy.tsx +40 -0
- package/src/client/components/workspace/editor/index.tsx +2 -2
- package/src/client/data/settings/omp-schema.json +33 -10
- package/src/server/lib/usage/provider-key.ts +18 -0
- package/src/server/lib/usage/providers.server.ts +27 -3
- package/src/server/lib/usage/report.server.ts +24 -0
- package/src/server/lib/usage/token-harbor.test.ts +191 -0
- package/src/server/lib/usage/token-harbor.ts +207 -0
- package/src/server/lib/usage/token-portal.test.ts +140 -0
- package/src/server/lib/usage/token-portal.ts +179 -0
- package/src/server/lib/usage/vendor-http.test.ts +52 -0
- package/src/server/lib/usage/vendor-http.ts +9 -2
- package/src/shared/lib/omp/config/schema-releases.test.ts +22 -0
- package/src/shared/types/settings/usage.ts +89 -2
- package/dist/client/static/js/ImageView-mvjb3qh1.js +0 -1
- package/dist/client/static/js/LayoutWrapper-eenx0hp2.js +0 -2
- package/dist/client/static/js/architecture-7GRP2DOG-b5w9mnn5.js +0 -1
- package/dist/client/static/js/bash-hv3167gh.js +0 -1
- package/dist/client/static/js/c-acmn1zc9.js +0 -1
- package/dist/client/static/js/cpp-v2mqp8j7.js +0 -1
- package/dist/client/static/js/css-x7gyc3ta.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-kdj8rjc1.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-m57b7ytw.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-fasj2gxy.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-wvzsc4ph.js +0 -1
- package/dist/client/static/js/graphql-a4gbqpj9.js +0 -1
- package/dist/client/static/js/html-m0megrvb.js +0 -1
- package/dist/client/static/js/index-3nsrnyqr.js +0 -2
- package/dist/client/static/js/index-4x9p7hf9.js +0 -2
- package/dist/client/static/js/index-9vqkyj58.js +0 -3
- package/dist/client/static/js/index-d2xtbabt.js +0 -2
- package/dist/client/static/js/index-dxp2yvy7.js +0 -2
- package/dist/client/static/js/index-p6s3fz6b.js +0 -12
- package/dist/client/static/js/index-qtd0e38d.js +0 -1
- package/dist/client/static/js/index-x2v1zmth.js +0 -479
- package/dist/client/static/js/index-x9hfvbz6.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-ym2xevn8.js +0 -1
- package/dist/client/static/js/ini-80p6sp79.js +0 -1
- package/dist/client/static/js/java-mm2b3s9b.js +0 -1
- package/dist/client/static/js/javascript-n9w9p97f.js +0 -1
- package/dist/client/static/js/json-fzy76fkw.js +0 -1
- package/dist/client/static/js/jsx-c7v2f8s7.js +0 -1
- package/dist/client/static/js/lua-ppfdxrmv.js +0 -1
- package/dist/client/static/js/markdown-xed7y3ds.js +0 -1
- package/dist/client/static/js/one-dark-pro-mq6sn6a2.js +0 -1
- package/dist/client/static/js/one-light-pt6t6vax.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-01vcsy6x.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-053gzkmh.js +0 -1
- package/dist/client/static/js/properties-8ysbq2n2.js +0 -1
- package/dist/client/static/js/python-4ysexc8s.js +0 -1
- package/dist/client/static/js/r-hrsw5arc.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-bkpby8am.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-67bxrjgw.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-xj9ymacg.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-2xxpbnf6.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-78w88znz.js +0 -1
- package/dist/client/static/js/sql-hd42h8wx.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-rz309qrx.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-g2bkjr4z.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-pj7yw9rw.js +0 -1
- package/dist/client/static/js/tsx-xjp2ds8g.js +0 -1
- package/dist/client/static/js/typescript-yg97da8h.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-c7ekf8r2.js +0 -1
- package/dist/client/static/js/xml-nrb23phz.js +0 -1
- package/dist/client/static/js/yaml-sqs6pjpx.js +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { ComponentChildren } from 'preact';
|
|
2
|
+
import type { TokenHarborUsageReport } from '@/shared/types';
|
|
3
|
+
import { StatCard } from '@/client/components/common/StatCard';
|
|
4
|
+
import {
|
|
5
|
+
formatDate,
|
|
6
|
+
formatUsageAmount,
|
|
7
|
+
} from '@/client/components/settings/categories/usage-settings/format';
|
|
8
|
+
|
|
9
|
+
interface AllowanceBarProps {
|
|
10
|
+
label: string;
|
|
11
|
+
/** Integer percent, or null when the endpoint reported no usable number. */
|
|
12
|
+
percent: number | null;
|
|
13
|
+
/** The provider's own "spent" flag; it outranks the rounded percentage. */
|
|
14
|
+
spent: boolean;
|
|
15
|
+
/** False when this allowance is switched off rather than merely unused. */
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
/** The one sentence that explains this bar's state, when it needs one. */
|
|
18
|
+
children?: ComponentChildren;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* One allowance bar. Same bar and "Used X%" reading as the generic quota rows,
|
|
23
|
+
* so a percentage reads identically wherever it appears in the panel.
|
|
24
|
+
*
|
|
25
|
+
* Focal point is the Pass bar: it decides whether covered models keep working.
|
|
26
|
+
* The only colour outside the palette is the error tint on a spent window, and
|
|
27
|
+
* the bar also states the fact as text (a colour alone would not).
|
|
28
|
+
*/
|
|
29
|
+
function AllowanceBar({ label, percent, spent, enabled = true, children }: AllowanceBarProps) {
|
|
30
|
+
const width = enabled && percent !== null ? Math.min(100, Math.max(0, percent)) : 0;
|
|
31
|
+
const state = !enabled ? 'Off' : spent ? 'Spent' : percent !== null ? `${percent}% used` : 'Not reported';
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className="space-y-1.5">
|
|
35
|
+
<div className="flex items-baseline justify-between gap-2">
|
|
36
|
+
<span className="text-[11px] font-semibold text-ink">{label}</span>
|
|
37
|
+
<span className={`text-[10px] ${spent ? 'text-error' : 'text-ink/60'}`}>{state}</span>
|
|
38
|
+
</div>
|
|
39
|
+
<div
|
|
40
|
+
className="h-1.5 w-full bg-ink/10 rounded-full overflow-hidden"
|
|
41
|
+
{...(enabled
|
|
42
|
+
? {
|
|
43
|
+
role: 'progressbar',
|
|
44
|
+
'aria-label': label,
|
|
45
|
+
'aria-valuemin': 0,
|
|
46
|
+
'aria-valuemax': 100,
|
|
47
|
+
...(percent !== null ? { 'aria-valuenow': width } : {}),
|
|
48
|
+
}
|
|
49
|
+
: {})}
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
className={`h-full rounded-full ${spent ? 'bg-error/70' : enabled ? 'bg-ink/80' : 'bg-ink/20'}`}
|
|
53
|
+
style={{ width: `${width}%` }}
|
|
54
|
+
/>
|
|
55
|
+
</div>
|
|
56
|
+
{children}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface TokenHarborCardProps {
|
|
62
|
+
report: TokenHarborUsageReport;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Token Harbor Pass and free-model allowance, as the percentages it reports. */
|
|
66
|
+
export function TokenHarborCard({ report }: TokenHarborCardProps) {
|
|
67
|
+
const allowance = report.allowance;
|
|
68
|
+
|
|
69
|
+
if (!allowance) {
|
|
70
|
+
return (
|
|
71
|
+
<p className="text-[11px] text-ink/60">
|
|
72
|
+
Token Harbor returned no allowance for this key. Refresh to try again.
|
|
73
|
+
</p>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const { onPlan, activated, resetAt } = allowance;
|
|
78
|
+
const percent = (value: number | null): string => (value === null ? 'n/a' : formatUsageAmount(value, 'percent'));
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<>
|
|
82
|
+
<div className="@container">
|
|
83
|
+
<div className="grid grid-cols-2 @[540px]:grid-cols-4 gap-2.5 items-stretch">
|
|
84
|
+
<StatCard
|
|
85
|
+
value={allowance.planName ?? 'No Pass'}
|
|
86
|
+
label="Plan"
|
|
87
|
+
hint={onPlan ? 'Pass allowance applies' : 'Covered models bill your wallet'}
|
|
88
|
+
/>
|
|
89
|
+
<StatCard
|
|
90
|
+
value={onPlan ? percent(allowance.planUsedPct) : 'n/a'}
|
|
91
|
+
label="Pass week used"
|
|
92
|
+
hint={onPlan ? (allowance.planExhausted ? 'Spent for this window' : 'Of this 7-day window') : 'No Pass to draw on'}
|
|
93
|
+
tone={onPlan ? 'default' : 'muted'}
|
|
94
|
+
/>
|
|
95
|
+
<StatCard
|
|
96
|
+
value={percent(allowance.usedPct)}
|
|
97
|
+
label="Free week used"
|
|
98
|
+
hint={allowance.modelsEnabled ? 'Of this 7-day window' : 'Free models are off'}
|
|
99
|
+
tone="muted"
|
|
100
|
+
/>
|
|
101
|
+
<StatCard
|
|
102
|
+
value={activated && resetAt ? formatDate(resetAt) : 'Not started'}
|
|
103
|
+
label="Resets"
|
|
104
|
+
hint={activated ? 'Pass and free share one window' : 'The window begins with your first request'}
|
|
105
|
+
tone="muted"
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div className="space-y-3">
|
|
111
|
+
<h4 className="text-[10px] font-mono font-semibold uppercase tracking-wider text-muted">Allowance</h4>
|
|
112
|
+
|
|
113
|
+
{onPlan ? (
|
|
114
|
+
<AllowanceBar
|
|
115
|
+
label={allowance.planName ?? 'Pass allowance'}
|
|
116
|
+
percent={allowance.planUsedPct}
|
|
117
|
+
spent={allowance.planExhausted}
|
|
118
|
+
>
|
|
119
|
+
{allowance.planExhausted && (
|
|
120
|
+
<p className="text-[10px] text-ink/70 leading-relaxed">
|
|
121
|
+
Covered calls resume when the window resets. Until then they run only if Keep working after my Pass
|
|
122
|
+
allowance runs out is on in Dashboard, Billing, which bills your wallet at the Pass discount.
|
|
123
|
+
</p>
|
|
124
|
+
)}
|
|
125
|
+
</AllowanceBar>
|
|
126
|
+
) : (
|
|
127
|
+
<p className="text-[10px] text-ink/70 leading-relaxed">
|
|
128
|
+
This account holds no Pass, so there is no Pass allowance to draw. Covered models bill your wallet.
|
|
129
|
+
</p>
|
|
130
|
+
)}
|
|
131
|
+
|
|
132
|
+
<AllowanceBar
|
|
133
|
+
label="Free allowance"
|
|
134
|
+
percent={allowance.usedPct}
|
|
135
|
+
spent={allowance.exhausted}
|
|
136
|
+
enabled={allowance.modelsEnabled}
|
|
137
|
+
>
|
|
138
|
+
{allowance.modelsEnabled ? (
|
|
139
|
+
allowance.freeModels.length > 0 && (
|
|
140
|
+
<p className="text-[10px] text-ink/60 leading-relaxed break-words">
|
|
141
|
+
Free models now: {allowance.freeModels.join(', ')}
|
|
142
|
+
</p>
|
|
143
|
+
)
|
|
144
|
+
) : (
|
|
145
|
+
<p className="text-[10px] text-ink/70 leading-relaxed">
|
|
146
|
+
Free models are switched off for this account, so calls to them are refused whatever the percentage says.
|
|
147
|
+
Turn them back on in the Token Harbor dashboard, under Data and privacy.
|
|
148
|
+
</p>
|
|
149
|
+
)}
|
|
150
|
+
</AllowanceBar>
|
|
151
|
+
|
|
152
|
+
{!activated && (
|
|
153
|
+
<p className="text-[10px] text-ink/60 leading-relaxed">
|
|
154
|
+
The 7-day window starts with this account's first request. Both allowances reset together.
|
|
155
|
+
</p>
|
|
156
|
+
)}
|
|
157
|
+
</div>
|
|
158
|
+
</>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { TokenPortalUsageReport } from '@/shared/types';
|
|
2
|
+
import { StatCard } from '@/client/components/common/StatCard';
|
|
3
|
+
import { formatCurrency } from '@/client/components/settings/categories/usage-settings/format';
|
|
4
|
+
|
|
5
|
+
interface TokenPortalCardProps {
|
|
6
|
+
report: TokenPortalUsageReport;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* TokenPortal's wallet, as `GET /v1/key` reports it.
|
|
11
|
+
*
|
|
12
|
+
* The numbers are the vendor's own money, so they are rendered with the
|
|
13
|
+
* currency it names (Rupiah on the live endpoint) and never as tokens. A key
|
|
14
|
+
* without a cap says "No cap" instead of drawing a 0%-used bar: a cap that was
|
|
15
|
+
* never set is not a quota window.
|
|
16
|
+
*/
|
|
17
|
+
export function TokenPortalCard({ report }: TokenPortalCardProps) {
|
|
18
|
+
const wallet = report.balance;
|
|
19
|
+
|
|
20
|
+
if (!wallet) {
|
|
21
|
+
return (
|
|
22
|
+
<p className="text-[11px] text-ink/60">
|
|
23
|
+
TokenPortal returned no balance for this key. Refresh to try again.
|
|
24
|
+
</p>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const spent = wallet.limit !== null && wallet.limitRemaining !== null
|
|
29
|
+
? Math.max(0, wallet.limit - wallet.limitRemaining)
|
|
30
|
+
: null;
|
|
31
|
+
const percent = wallet.limit !== null && spent !== null && wallet.limit > 0
|
|
32
|
+
? Math.min(100, (spent / wallet.limit) * 100)
|
|
33
|
+
: null;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<div className="@container">
|
|
38
|
+
<div className="grid grid-cols-2 @[540px]:grid-cols-4 gap-2.5 items-stretch">
|
|
39
|
+
<StatCard
|
|
40
|
+
value={formatCurrency(wallet.balance, wallet.currency)}
|
|
41
|
+
label="Credit balance"
|
|
42
|
+
hint={wallet.label ? `Key ${wallet.label}` : `Left on this key, in ${wallet.currency}`}
|
|
43
|
+
/>
|
|
44
|
+
<StatCard
|
|
45
|
+
value={wallet.limit === null ? 'No cap' : formatCurrency(wallet.limit, wallet.currency)}
|
|
46
|
+
label="Key limit"
|
|
47
|
+
hint={wallet.limit === null
|
|
48
|
+
? 'Spending is not capped on this key'
|
|
49
|
+
: spent !== null
|
|
50
|
+
? `${formatCurrency(spent, wallet.currency)} spent`
|
|
51
|
+
: 'Cap set by the operator'}
|
|
52
|
+
tone={wallet.limit === null ? 'muted' : 'default'}
|
|
53
|
+
/>
|
|
54
|
+
<StatCard
|
|
55
|
+
value={wallet.sessionBudget === null ? 'Not set' : formatCurrency(wallet.sessionBudget, wallet.currency)}
|
|
56
|
+
label="Session budget"
|
|
57
|
+
hint={wallet.sessionBudget === null ? 'No per-session cap' : 'Applies to one gateway session'}
|
|
58
|
+
tone="muted"
|
|
59
|
+
/>
|
|
60
|
+
<StatCard
|
|
61
|
+
value={wallet.isFreeTier ? 'Free' : 'Paid'}
|
|
62
|
+
label="Tier"
|
|
63
|
+
hint={wallet.isFreeTier ? 'Free-tier limits apply' : 'No free-tier limit on this key'}
|
|
64
|
+
tone="muted"
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
{percent !== null && spent !== null && (
|
|
70
|
+
<div className="space-y-1.5">
|
|
71
|
+
<div className="flex items-baseline justify-between gap-2">
|
|
72
|
+
<span className="text-[11px] font-semibold text-ink">Key limit used</span>
|
|
73
|
+
<span className="text-[10px] text-ink/60">
|
|
74
|
+
{formatCurrency(spent, wallet.currency)} of {formatCurrency(wallet.limit ?? 0, wallet.currency)}
|
|
75
|
+
</span>
|
|
76
|
+
</div>
|
|
77
|
+
<div
|
|
78
|
+
className="h-1.5 w-full bg-ink/10 rounded-full overflow-hidden"
|
|
79
|
+
role="progressbar"
|
|
80
|
+
aria-label="Key limit used"
|
|
81
|
+
aria-valuemin={0}
|
|
82
|
+
aria-valuemax={100}
|
|
83
|
+
aria-valuenow={Math.round(percent)}
|
|
84
|
+
>
|
|
85
|
+
<div
|
|
86
|
+
className={`h-full rounded-full ${wallet.limitRemaining !== null && wallet.limitRemaining <= 0 ? 'bg-error/70' : 'bg-ink/80'}`}
|
|
87
|
+
style={{ width: `${percent}%` }}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
{wallet.limitRemaining !== null && (
|
|
91
|
+
<p className="text-[10px] text-ink/50">
|
|
92
|
+
{formatCurrency(wallet.limitRemaining, wallet.currency)} left under the cap
|
|
93
|
+
</p>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
|
|
98
|
+
<p className="text-[10px] text-ink/50 leading-relaxed">
|
|
99
|
+
Balance and caps come from TokenPortal’s <span className="font-mono">/v1/key</span> endpoint in
|
|
100
|
+
{' '}{wallet.currency}; top-ups and transaction history live in its console.
|
|
101
|
+
</p>
|
|
102
|
+
</>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
@@ -19,6 +19,8 @@ const dateTimeFormatter = new Intl.DateTimeFormat('id-ID', {
|
|
|
19
19
|
timeStyle: 'short',
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
+
const dateFormatter = new Intl.DateTimeFormat('id-ID', { dateStyle: 'medium' });
|
|
23
|
+
|
|
22
24
|
export function formatRp(value: number): string {
|
|
23
25
|
return rupiahFormatter.format(value);
|
|
24
26
|
}
|
|
@@ -34,6 +36,17 @@ export function formatDateTime(iso: string): string {
|
|
|
34
36
|
return dateTimeFormatter.format(date);
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
/**
|
|
40
|
+
* The date alone, for a reset that is days away and needs no clock time. Derived
|
|
41
|
+
* from its own formatter rather than by cutting `formatDateTime` at a comma: the
|
|
42
|
+
* comma position is locale data, and en-US puts the year after it.
|
|
43
|
+
*/
|
|
44
|
+
export function formatDate(iso: string): string {
|
|
45
|
+
const date = new Date(iso);
|
|
46
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
47
|
+
return dateFormatter.format(date);
|
|
48
|
+
}
|
|
49
|
+
|
|
37
50
|
/** Percentage of `used` out of `total`, clamped to 0–100 for progress bars. */
|
|
38
51
|
export function usedPercent(used: number, total: number): number {
|
|
39
52
|
if (total <= 0) return 0;
|
|
@@ -73,6 +86,26 @@ export function formatUsd(value: number): string {
|
|
|
73
86
|
return `$${usdFormatter.format(value)}`;
|
|
74
87
|
}
|
|
75
88
|
|
|
89
|
+
/**
|
|
90
|
+
* One money amount in the currency the vendor named. IDR and USD delegate to
|
|
91
|
+
* the two formatters above so a Rupiah balance reads identically wherever it
|
|
92
|
+
* appears (the kenari wallet, the TokenPortal wallet); any other ISO code falls
|
|
93
|
+
* back to `Intl` and, if the runtime does not know it, prints the raw number and
|
|
94
|
+
* the code rather than inventing a symbol.
|
|
95
|
+
*/
|
|
96
|
+
export function formatCurrency(value: number, currency: string): string {
|
|
97
|
+
if (!Number.isFinite(value)) return '—';
|
|
98
|
+
const code = currency.trim().toUpperCase();
|
|
99
|
+
if (code === 'IDR') return formatRp(value);
|
|
100
|
+
if (code === 'USD') return formatUsd(value);
|
|
101
|
+
if (!code) return '—';
|
|
102
|
+
try {
|
|
103
|
+
return new Intl.NumberFormat('id-ID', { style: 'currency', currency: code }).format(value);
|
|
104
|
+
} catch {
|
|
105
|
+
return `${formatNumber(value)} ${code}`;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
76
109
|
/**
|
|
77
110
|
* Render one quota amount in its own unit. `percent` amounts arrive as 0..100
|
|
78
111
|
* (omp's `used`/`limit` for percent units), everything else as a raw count.
|
|
@@ -84,6 +117,8 @@ export function formatUsageAmount(value: number, unit: string): string {
|
|
|
84
117
|
return `${new Intl.NumberFormat('id-ID', { maximumFractionDigits: 1 }).format(value)}%`;
|
|
85
118
|
case 'usd':
|
|
86
119
|
return formatUsd(value);
|
|
120
|
+
case 'idr':
|
|
121
|
+
return formatRp(value);
|
|
87
122
|
case 'tokens':
|
|
88
123
|
case 'bytes':
|
|
89
124
|
return formatCompactTokens(value);
|
|
@@ -115,4 +115,20 @@ describe('LimitsSection sections', () => {
|
|
|
115
115
|
expect(headings(dom)).toEqual(['Quota windows']);
|
|
116
116
|
expect(dom.textContent).toContain('No quota source for this provider');
|
|
117
117
|
});
|
|
118
|
+
|
|
119
|
+
test('a provider-supplied empty reason replaces the generic credential copy', () => {
|
|
120
|
+
// Command Code's adapter skips an OAuth login, so "an invalid or expired
|
|
121
|
+
// credential" would send the user to rotate a credential that works.
|
|
122
|
+
const dom = mount(
|
|
123
|
+
<LimitsSection
|
|
124
|
+
providerId="commandcode"
|
|
125
|
+
tracked
|
|
126
|
+
unavailable
|
|
127
|
+
limits={[]}
|
|
128
|
+
emptyReason="needs an API key created in Studio"
|
|
129
|
+
/>,
|
|
130
|
+
);
|
|
131
|
+
expect(dom.textContent).toContain('needs an API key created in Studio');
|
|
132
|
+
expect(dom.textContent).not.toContain('invalid or expired credential');
|
|
133
|
+
});
|
|
118
134
|
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { UsageLimitWindow, UsageProviderSummary, UsageReport } from '@/shared/types';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
formatAmount,
|
|
4
|
+
formatCurrency,
|
|
5
|
+
} from '@/client/components/settings/categories/usage-settings/format';
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* Providers surfaced in the Settings → Usage sidebar and the Usage right panel.
|
|
@@ -31,9 +34,14 @@ function limitHint(limits: UsageLimitWindow[]): string | undefined {
|
|
|
31
34
|
const used = limits.filter((limit) => limit.usedFraction !== undefined);
|
|
32
35
|
if (used.length === 0) {
|
|
33
36
|
// A credit balance has no limit to take a fraction of; the remaining
|
|
34
|
-
// amount IS the whole story
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
// amount IS the whole story — in the currency the window names, because an
|
|
38
|
+
// IDR wallet formatted as USD understates it by four orders of magnitude.
|
|
39
|
+
const credit = limits.find(
|
|
40
|
+
(limit) => (limit.unit === 'usd' || limit.unit === 'idr') && limit.remaining !== undefined,
|
|
41
|
+
);
|
|
42
|
+
if (credit) {
|
|
43
|
+
return `${formatCurrency(credit.remaining ?? 0, credit.unit === 'idr' ? 'IDR' : 'USD')} left`;
|
|
44
|
+
}
|
|
37
45
|
return limits[0]?.label;
|
|
38
46
|
}
|
|
39
47
|
const binding = used.reduce((worst, limit) =>
|
|
@@ -61,8 +69,22 @@ export function buildProviders(report: UsageReport): ProviderEntry[] {
|
|
|
61
69
|
function providerHint(summary: UsageProviderSummary): string {
|
|
62
70
|
const plan = summary.kenari?.quota?.planName;
|
|
63
71
|
if (plan) return plan;
|
|
72
|
+
const wallet = summary.tokenPortal?.balance;
|
|
73
|
+
if (wallet) return formatCurrency(wallet.balance, wallet.currency);
|
|
64
74
|
const balance = summary.deepseek?.balance?.entries[0];
|
|
65
75
|
if (balance) return `${balance.currency} ${formatAmount(balance.totalBalance)}`;
|
|
76
|
+
const harbor = summary.tokenHarbor?.allowance;
|
|
77
|
+
if (harbor) {
|
|
78
|
+
// The Pass percentage is the one that decides whether covered calls keep
|
|
79
|
+
// working, so it is the number the row carries; a window that never started
|
|
80
|
+
// must not read "0%".
|
|
81
|
+
if (!harbor.activated) return `${harbor.planName ?? 'Free'} · not started`;
|
|
82
|
+
if (harbor.onPlan) return `${harbor.planName ?? 'Pass'} · ${harbor.planUsedPct ?? 0}% · 7d`;
|
|
83
|
+
return `${harbor.usedPct ?? 0}% free · 7d`;
|
|
84
|
+
}
|
|
85
|
+
// "No quota reported" would read as a provider with no quota at all; this
|
|
86
|
+
// account HAS quota, and the missing piece is the credential type.
|
|
87
|
+
if (summary.id === 'commandcode' && summary.limitsUnavailable) return 'API key needed';
|
|
66
88
|
return limitHint(summary.limits) ?? 'No quota reported';
|
|
67
89
|
}
|
|
68
90
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Token Harbor card's states are asserted on the DOM, not on the parser:
|
|
8
|
+
* a correct allowance wired to the wrong branch renders a reassuring 0% on a
|
|
9
|
+
* window that has not started, or hides the fact that free models are switched
|
|
10
|
+
* off. Both are the regressions this covers.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
14
|
+
import { Window } from 'happy-dom';
|
|
15
|
+
import { render } from 'preact';
|
|
16
|
+
import { act } from 'preact/test-utils';
|
|
17
|
+
import { TokenHarborCard } from '@/client/components/settings/categories/usage-settings/TokenHarborCard';
|
|
18
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
19
|
+
import type { TokenHarborAllowance } from '@/shared/types';
|
|
20
|
+
|
|
21
|
+
let container: HTMLElement;
|
|
22
|
+
|
|
23
|
+
const allowance = (overrides: Partial<TokenHarborAllowance> = {}): TokenHarborAllowance => ({
|
|
24
|
+
planName: 'Agent Pass',
|
|
25
|
+
onPlan: true,
|
|
26
|
+
planUsedPct: 37,
|
|
27
|
+
planExhausted: false,
|
|
28
|
+
usedPct: 12,
|
|
29
|
+
exhausted: false,
|
|
30
|
+
activated: true,
|
|
31
|
+
resetAt: '2026-11-30T07:45:14.048+00:00',
|
|
32
|
+
periodStartedAt: '2026-11-23T07:45:14.048+00:00',
|
|
33
|
+
periodEndsAt: '2026-11-30T07:45:14.048+00:00',
|
|
34
|
+
freeModels: ['deepseek-v4-flash', 'mimo-v2.6-flash'],
|
|
35
|
+
modelsEnabled: true,
|
|
36
|
+
...overrides,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
function mount(report: TokenHarborAllowance): HTMLElement {
|
|
40
|
+
act(() => render(<TokenHarborCard report={{ allowance: report }} />, container));
|
|
41
|
+
return container;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function bars(dom: HTMLElement): HTMLElement[] {
|
|
45
|
+
return [...dom.querySelectorAll<HTMLElement>('[role="progressbar"]')];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
beforeEach(() => {
|
|
49
|
+
installDomGlobals(new Window());
|
|
50
|
+
container = document.createElement('div');
|
|
51
|
+
document.body.appendChild(container);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterEach(() => {
|
|
55
|
+
act(() => render(null, container));
|
|
56
|
+
container.remove();
|
|
57
|
+
restoreDomGlobals();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('TokenHarborCard allowance bars', () => {
|
|
61
|
+
test('a Pass and the free allowance draw two labelled bars with their percentages', () => {
|
|
62
|
+
const dom = mount(allowance());
|
|
63
|
+
expect(bars(dom).map((bar) => bar.getAttribute('aria-label'))).toEqual(['Agent Pass', 'Free allowance']);
|
|
64
|
+
expect(bars(dom).map((bar) => bar.getAttribute('aria-valuenow'))).toEqual(['37', '12']);
|
|
65
|
+
expect(dom.textContent).toContain('Free models now: deepseek-v4-flash, mimo-v2.6-flash');
|
|
66
|
+
expect(dom.textContent).not.toContain('Spent');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('a spent Pass is stated as text and painted with the error tint', () => {
|
|
70
|
+
const dom = mount(allowance({ planUsedPct: 100, planExhausted: true }));
|
|
71
|
+
expect(dom.textContent).toContain('Spent');
|
|
72
|
+
expect(dom.textContent).toContain('Covered calls resume when the window resets');
|
|
73
|
+
// The panel cannot read the wallet-continuation toggle, so it must name the
|
|
74
|
+
// setting rather than claim calls simply stop.
|
|
75
|
+
expect(dom.textContent).toContain('Keep working after my Pass allowance runs out');
|
|
76
|
+
expect(bars(dom)[0]?.firstElementChild?.className).toContain('bg-error/70');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('an account without a Pass draws no Pass bar and says why', () => {
|
|
80
|
+
const dom = mount(allowance({ onPlan: false, planName: null, planUsedPct: 0 }));
|
|
81
|
+
expect(bars(dom).map((bar) => bar.getAttribute('aria-label'))).toEqual(['Free allowance']);
|
|
82
|
+
expect(dom.textContent).toContain('no Pass allowance to draw');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('a window that never started does not read as a reassuring 0%', () => {
|
|
86
|
+
const dom = mount(allowance({
|
|
87
|
+
activated: false,
|
|
88
|
+
planUsedPct: 0,
|
|
89
|
+
usedPct: 0,
|
|
90
|
+
resetAt: null,
|
|
91
|
+
periodStartedAt: null,
|
|
92
|
+
periodEndsAt: null,
|
|
93
|
+
}));
|
|
94
|
+
expect(dom.textContent).toContain('Not started');
|
|
95
|
+
expect(dom.textContent).toContain('starts with this account');
|
|
96
|
+
expect(dom.textContent).not.toContain('30 Nov');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('free models that are switched off drop the bar value and name the action', () => {
|
|
100
|
+
const dom = mount(allowance({ modelsEnabled: false, usedPct: 4 }));
|
|
101
|
+
// A switched-off allowance is not a progress reading: it carries no
|
|
102
|
+
// progressbar role at all, so a screen reader cannot announce "4%".
|
|
103
|
+
expect(bars(dom).map((bar) => bar.getAttribute('aria-label'))).toEqual(['Agent Pass']);
|
|
104
|
+
expect(dom.textContent).toContain('Off');
|
|
105
|
+
expect(dom.textContent).toContain('switched off');
|
|
106
|
+
expect(dom.textContent).toContain('Data and privacy');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test('a report with no allowance says so instead of drawing empty bars', () => {
|
|
110
|
+
act(() => render(<TokenHarborCard report={{ error: 'Token Harbor rejected the API key' }} />, container));
|
|
111
|
+
expect(bars(container)).toHaveLength(0);
|
|
112
|
+
expect(container.textContent).toContain('returned no allowance');
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Token Harbor sidebar hint. It is the one line the provider list shows, so
|
|
8
|
+
* it has to carry the Pass percentage (the number that decides whether covered
|
|
9
|
+
* calls keep working), and it must not print "0%" for a window that never
|
|
10
|
+
* started — a fresh account would read as "nothing left" instead of "not yet
|
|
11
|
+
* begun". Kept beside `token-harbor-card.test.tsx`, which pins the card itself.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, expect, test } from 'bun:test';
|
|
15
|
+
|
|
16
|
+
import { buildProviders } from '@/client/components/settings/categories/usage-settings/providers';
|
|
17
|
+
import type { TokenHarborAllowance, TokenHarborUsageReport, UsageProviderSummary } from '@/shared/types';
|
|
18
|
+
|
|
19
|
+
const summary = (overrides: Partial<UsageProviderSummary> = {}): UsageProviderSummary =>
|
|
20
|
+
({ id: 'token-harbour', name: 'Token Harbor', credentialSources: [], tracked: true, limits: [], ...overrides }) as UsageProviderSummary;
|
|
21
|
+
|
|
22
|
+
/** A live-shaped allowance; each test overrides the one fact it is about. */
|
|
23
|
+
const tokenHarbor = (overrides: Partial<TokenHarborAllowance> = {}): TokenHarborUsageReport => ({
|
|
24
|
+
allowance: {
|
|
25
|
+
planName: 'Agent Pass',
|
|
26
|
+
onPlan: true,
|
|
27
|
+
planUsedPct: 37,
|
|
28
|
+
planExhausted: false,
|
|
29
|
+
usedPct: 12,
|
|
30
|
+
exhausted: false,
|
|
31
|
+
activated: true,
|
|
32
|
+
resetAt: '2026-11-30T07:45:14.048+00:00',
|
|
33
|
+
periodStartedAt: '2026-11-23T07:45:14.048+00:00',
|
|
34
|
+
periodEndsAt: '2026-11-30T07:45:14.048+00:00',
|
|
35
|
+
freeModels: [],
|
|
36
|
+
modelsEnabled: true,
|
|
37
|
+
...overrides,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function hint(report: TokenHarborUsageReport): string | undefined {
|
|
42
|
+
return buildProviders({
|
|
43
|
+
isMock: false,
|
|
44
|
+
generatedAt: '',
|
|
45
|
+
providers: [summary({ tokenHarbor: report })],
|
|
46
|
+
})[0]?.hint;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe('Token Harbor provider hint', () => {
|
|
50
|
+
test('a Pass row carries the plan, its percentage and the window', () => {
|
|
51
|
+
expect(hint(tokenHarbor())).toBe('Agent Pass · 37% · 7d');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a free-only row reports the free percentage instead of a Pass one', () => {
|
|
55
|
+
expect(hint(tokenHarbor({ onPlan: false, planName: null, planUsedPct: 0 }))).toBe('12% free · 7d');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('a window that never started says so rather than reading "0%"', () => {
|
|
59
|
+
expect(hint(tokenHarbor({
|
|
60
|
+
activated: false,
|
|
61
|
+
planUsedPct: 0,
|
|
62
|
+
usedPct: 0,
|
|
63
|
+
resetAt: null,
|
|
64
|
+
periodStartedAt: null,
|
|
65
|
+
periodEndsAt: null,
|
|
66
|
+
}))).toBe('Agent Pass · not started');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The TokenPortal card's arithmetic is the regression surface: the endpoint's
|
|
8
|
+
* numbers are whole Rupiah, an uncapped key has no quota window (so drawing a
|
|
9
|
+
* 0%-used bar would claim a limit nobody set), and spend is derived from
|
|
10
|
+
* `limit − limit_remaining`, not from `balance`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
14
|
+
import { Window } from 'happy-dom';
|
|
15
|
+
import { render } from 'preact';
|
|
16
|
+
import { act } from 'preact/test-utils';
|
|
17
|
+
import { TokenPortalCard } from '@/client/components/settings/categories/usage-settings/TokenPortalCard';
|
|
18
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
19
|
+
import type { TokenPortalBalance } from '@/shared/types';
|
|
20
|
+
|
|
21
|
+
let container: HTMLElement;
|
|
22
|
+
|
|
23
|
+
const wallet = (overrides: Partial<TokenPortalBalance> = {}): TokenPortalBalance => ({
|
|
24
|
+
label: 'Kabmo',
|
|
25
|
+
currency: 'IDR',
|
|
26
|
+
balance: 8827,
|
|
27
|
+
limit: null,
|
|
28
|
+
limitRemaining: 8827,
|
|
29
|
+
isFreeTier: false,
|
|
30
|
+
sessionBudget: null,
|
|
31
|
+
...overrides,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
function mount(balance: TokenPortalBalance | null): HTMLElement {
|
|
35
|
+
act(() => render(<TokenPortalCard report={balance ? { balance } : { error: 'TokenPortal rejected the API key (HTTP 401).' }} />, container));
|
|
36
|
+
return container;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function text(dom: HTMLElement): string {
|
|
40
|
+
return (dom.textContent ?? '').replace(/\s/g, '');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
installDomGlobals(new Window());
|
|
45
|
+
container = document.createElement('div');
|
|
46
|
+
document.body.appendChild(container);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
act(() => render(null, container));
|
|
51
|
+
container.remove();
|
|
52
|
+
restoreDomGlobals();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('TokenPortalCard wallet', () => {
|
|
56
|
+
test('an uncapped key shows its Rupiah balance and no progress bar', () => {
|
|
57
|
+
const dom = mount(wallet());
|
|
58
|
+
expect(text(dom)).toContain('Rp8.827');
|
|
59
|
+
expect(text(dom)).toContain('Nocap');
|
|
60
|
+
expect(text(dom)).toContain('Notset');
|
|
61
|
+
// A cap nobody set must not become a 0%-used bar.
|
|
62
|
+
expect(dom.querySelectorAll('[role="progressbar"]')).toHaveLength(0);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('a capped key derives spend from limit_remaining and draws the bar', () => {
|
|
66
|
+
const dom = mount(wallet({ balance: 15000, limit: 20000, limitRemaining: 12000 }));
|
|
67
|
+
const bars = [...dom.querySelectorAll<HTMLElement>('[role="progressbar"]')];
|
|
68
|
+
expect(bars).toHaveLength(1);
|
|
69
|
+
expect(bars[0]?.getAttribute('aria-valuenow')).toBe('40');
|
|
70
|
+
expect(text(dom)).toContain('Rp8.000');
|
|
71
|
+
expect(text(dom)).toContain('Rp12.000');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('a free-tier key states the tier in words', () => {
|
|
75
|
+
expect(text(mount(wallet({ isFreeTier: true })))).toContain('Free');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('a missing balance says so instead of rendering an empty wallet', () => {
|
|
79
|
+
expect(text(mount(null))).toContain('returnednobalance');
|
|
80
|
+
});
|
|
81
|
+
});
|