omnigateway 0.2.2 → 0.4.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.
Files changed (71) hide show
  1. package/README.md +506 -9
  2. package/bin/omni.js +3022 -163
  3. package/gateway.js +4094 -662
  4. package/package.json +1 -1
  5. package/public/assets/{Chip-DJwp7gBu.js → Chip-BltJSw8A.js} +5 -5
  6. package/public/assets/Confirm-gd8Y6snu.js +4 -0
  7. package/public/assets/CopyValue-Dds-Ow9a.js +27 -0
  8. package/public/assets/{Field-BDtp692L.js → Field-D-14HF0x.js} +11 -11
  9. package/public/assets/Lamp-BDf7-dMa.js +25 -0
  10. package/public/assets/Match-CgNxphvS.js +1 -0
  11. package/public/assets/Meter-stpt3vQu.js +14 -0
  12. package/public/assets/Modal-Dj3LvMS9.js +82 -0
  13. package/public/assets/Rack-B4c0dbIb.js +180 -0
  14. package/public/assets/{Readout-CEAoN5hu.js → Readout-Du15WYx0.js} +5 -5
  15. package/public/assets/{States-BEKLros0.js → States-CxLDlCaw.js} +5 -5
  16. package/public/assets/{Table-BBypbVWj.js → Table-CVDZ69Zx.js} +1 -1
  17. package/public/assets/Toggle-DMk46RX2.js +39 -0
  18. package/public/assets/TokenBreakdown-BySwFK6Q.js +31 -0
  19. package/public/assets/_app-Dx_xnlud.js +1 -0
  20. package/public/assets/_app.accounts-DvBYnbfS.js +64 -0
  21. package/public/assets/_app.console-CoaRdkB1.js +44 -0
  22. package/public/assets/_app.database-CES5ec5g.js +39 -0
  23. package/public/assets/_app.index-DwOZe1A-.js +62 -0
  24. package/public/assets/_app.keys-B5HrAu2U.js +76 -0
  25. package/public/assets/_app.logs-NbfIexz0.js +68 -0
  26. package/public/assets/_app.models-B1MdFRtQ.js +148 -0
  27. package/public/assets/_app.plugins._pluginId-ByMziW8p.js +20 -0
  28. package/public/assets/_app.settings-BkDkGkKF.js +46 -0
  29. package/public/assets/_app.usage-DNpM8Nub.js +83 -0
  30. package/public/assets/dist-9ps0Qd15.js +1 -0
  31. package/public/assets/index-gMv8Qs7m.js +178 -0
  32. package/public/assets/login-cCXnl34r.js +36 -0
  33. package/public/assets/matchContext-BOenO3J2.js +1 -0
  34. package/public/assets/plus-fXfUTt6_.js +1 -0
  35. package/public/assets/queries-CIOPbRcE.js +142 -0
  36. package/public/assets/reasons-Cb8yF4Oy.js +1 -0
  37. package/public/assets/shared-B4o-2quR.js +84 -0
  38. package/public/assets/{trash-2-CLYNAAJA.js → trash-2-ZPh3619D.js} +1 -1
  39. package/public/index.html +7 -2
  40. package/public/shared/chunks/jsx-runtime-CznXPbDH.js +1 -0
  41. package/public/shared/chunks/react-GitiQ0dt.js +1 -0
  42. package/public/shared/chunks/react-dom-BTlfKTOo.js +1 -0
  43. package/public/shared/chunks/rolldown-runtime-CbXtAM7H.js +1 -0
  44. package/public/shared/jsx-runtime.js +1 -0
  45. package/public/shared/react-dom-client.js +9 -0
  46. package/public/shared/react-dom.js +1 -0
  47. package/public/shared/react-query.js +1 -0
  48. package/public/shared/react.js +1 -0
  49. package/public/shared/styled-components.js +7 -0
  50. package/public/assets/Confirm-CVLz9F7a.js +0 -4
  51. package/public/assets/CopyValue-CNZbWS59.js +0 -27
  52. package/public/assets/Lamp-B65uWKbW.js +0 -25
  53. package/public/assets/Meter-BREBUFGX.js +0 -14
  54. package/public/assets/Modal-DbydSAlp.js +0 -82
  55. package/public/assets/Rack-Bbo4JfEX.js +0 -151
  56. package/public/assets/Toggle-BUr71O4J.js +0 -39
  57. package/public/assets/TokenBreakdown-C1ziK9d1.js +0 -31
  58. package/public/assets/_app-ByQ1bPbe.js +0 -1
  59. package/public/assets/_app.accounts-BTug_Xfo.js +0 -64
  60. package/public/assets/_app.console-DKyGL9xx.js +0 -44
  61. package/public/assets/_app.index-CSw9gmMf.js +0 -62
  62. package/public/assets/_app.keys-07Kbw4RS.js +0 -39
  63. package/public/assets/_app.logs-C9QiV39p.js +0 -32
  64. package/public/assets/_app.models-CDqVrAeF.js +0 -148
  65. package/public/assets/_app.settings-DmUEeTaP.js +0 -38
  66. package/public/assets/_app.usage-B1WuMGRr.js +0 -83
  67. package/public/assets/dist-Bka7ErcH.js +0 -1
  68. package/public/assets/index-DJfb1i4P.js +0 -186
  69. package/public/assets/login-DKZYqRh0.js +0 -33
  70. package/public/assets/queries-D8LJNQpL.js +0 -144
  71. package/public/assets/shared-CIhZ6FCO.js +0 -84
@@ -0,0 +1,148 @@
1
+ import{$ as e,F as t,O as n,at as r,et as i,g as a,it as o,lt as s,nt as c,ot as l,ut as u,x as d,y as f,z as p}from"./queries-CIOPbRcE.js";import{r as m}from"./index-gMv8Qs7m.js";import{c as h,t as g}from"./Rack-B4c0dbIb.js";import{t as _}from"./plus-fXfUTt6_.js";import{t as v}from"./trash-2-ZPh3619D.js";import{t as y}from"./Toggle-DMk46RX2.js";import{t as b}from"./Confirm-gd8Y6snu.js";import{n as x,t as S}from"./Chip-BltJSw8A.js";import{i as C,n as w,r as T,t as E}from"./Field-D-14HF0x.js";import{t as D}from"./Meter-stpt3vQu.js";import{a as O,i as k,n as A,r as j,t as M}from"./States-CxLDlCaw.js";import{i as N,n as ee,r as te,t as P}from"./catalog-BBKm8Ih8.js";import{useEffect as ne,useId as re,useState as F}from"react";import{Fragment as I,jsx as L,jsxs as R}from"react/jsx-runtime";import z from"styled-components";var ie=h(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),ae=h(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),B=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],oe={tier:`How preferred this tier is`,health:`Consecutive failures and breaker state`,quota:`Headroom in the tightest window, against how much of it is left`,cost:`Price of this request against the other candidates`,latency:`Observed time to first token`,load:`Requests in flight on this pair right now`},se=z.li`
2
+ padding: ${({theme:e})=>e.space(2)} 0;
3
+ border-bottom: 1px solid ${({theme:e})=>e.color.rule};
4
+
5
+ &:last-child {
6
+ border-bottom: 0;
7
+ }
8
+ `,ce=z(i)`
9
+ width: 22px;
10
+ color: ${({theme:e})=>e.color.inkFaint};
11
+ flex: none;
12
+ `,le=z(S)`
13
+ border-color: ${({theme:e})=>e.color.ok};
14
+ color: ${({theme:e})=>e.color.ok};
15
+ background: ${({theme:e})=>e.color.okWash};
16
+ `,ue=z.div`
17
+ display: grid;
18
+ grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
19
+ gap: ${({theme:e})=>e.space(2)};
20
+ margin-top: ${({theme:e})=>e.space(2)};
21
+ padding-left: 30px;
22
+ `,de=z.div`
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 3px;
26
+ min-width: 0;
27
+ `,fe=z.div`
28
+ display: flex;
29
+ align-items: baseline;
30
+ justify-content: space-between;
31
+ gap: 6px;
32
+ `,pe=z.li`
33
+ display: flex;
34
+ align-items: center;
35
+ gap: ${({theme:e})=>e.space(2)};
36
+ padding: 5px 0;
37
+ `,me=z(c)`
38
+ gap: ${({theme:e})=>e.space(3)};
39
+ flex-wrap: wrap;
40
+ `,V=z.label`
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 6px;
44
+ cursor: pointer;
45
+ font-size: 12.5px;
46
+ `,he=z.p`
47
+ font-size: 12px;
48
+ color: ${({theme:e})=>e.color.down};
49
+ `;function H(e,t,n){return(e[t]??0)*n[t]}function ge({modelId:t}){let[n,a]=F({tools:!1,images:!1,reasoning:!1}),[u,f]=F(null),[m,h]=F(null),g=p(),_=d(),v=g.data?.weights,b=()=>{t!==null&&(h(null),_.mutate({modelId:t,need:n},{onSuccess:e=>f(e),onError:e=>{f(null),h(k(e))}}))},C=new Map(B.map(e=>[e,Math.max(1e-4,...(u?.candidates??[]).map(t=>v===void 0?0:Math.abs(H(t.reasons,e,v))))]));return L(O,{legend:`Explain`,meta:t??`no model selected`,actions:R(s,{type:`button`,$size:`sm`,$variant:`primary`,disabled:t===null||_.isPending,onClick:b,children:[L(ie,{}),_.isPending?`Ranking…`:`Rank candidates`]}),children:R(r,{$gap:3,children:[R(r,{$gap:1,children:[L(e,{children:`Pretend the request needs`}),R(me,{children:[R(V,{children:[L(y,{checked:n.tools,label:`Probe request uses tools`,onCheckedChange:e=>a({...n,tools:e})}),`Tools`]}),R(V,{children:[L(y,{checked:n.images,label:`Probe request includes an image`,onCheckedChange:e=>a({...n,images:e})}),`Images`]}),R(V,{children:[L(y,{checked:n.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>a({...n,reasoning:e})}),`Reasoning`]})]})]}),m===null?null:L(he,{children:m}),u===null?L(M,{legend:`Not ranked yet`,message:t===null?`Select a model to see which account the router would pick for it.`:`Run the ranking to see which account wins, by how much, and what was filtered out.`}):R(r,{$gap:3,children:[R(c,{$gap:2,$wrap:!0,children:[L(S,{$tone:`accent`,children:u.strategy}),u.deterministic?null:L(S,{$tone:`warn`,children:`order varies per request`}),L(o,{}),R(e,{children:[u.candidates.length,` eligible · `,u.excluded.length,` filtered out`]})]}),u.candidates.length===0?L(M,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):L(`ul`,{children:u.candidates.map((t,n)=>R(se,{children:[R(c,{$gap:2,children:[L(ce,{children:n+1}),L(x,{provider:t.provider}),L(l,{style:{maxWidth:`22ch`},children:t.credentialLabel}),L(i,{$dim:!0,children:t.model}),R(S,{children:[`tier `,t.tier]}),L(o,{}),n===0?L(le,{children:`would be used`}):null,L(i,{children:t.score.toFixed(2)})]}),v===void 0?null:L(ue,{children:B.map(n=>{let r=H(t.reasons,n,v),a=C.get(n)??1;return R(de,{title:oe[n],children:[R(fe,{children:[L(e,{children:n}),L(i,{$dim:!0,$size:`10.5px`,children:r.toFixed(2)})]}),L(D,{fraction:Math.abs(r)/a,height:4,tone:`var(--accent)`,label:`${n} contributes ${r.toFixed(2)} of ${t.score.toFixed(2)}`})]},n)})})]},`${t.credentialId}:${t.model}`))}),u.excluded.length===0?null:R(r,{$gap:1,children:[L(e,{children:`Filtered out`}),L(`ul`,{children:u.excluded.map(e=>R(pe,{children:[L(i,{$dim:!0,children:e.model}),L(o,{}),L(S,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}var U=[{id:`score`,label:`Best score`,blurb:`Rank every eligible target by the routing weights and take the best one.`},{id:`priority`,label:`Lowest tier`,blurb:`Always prefer the lowest tier. Score only breaks ties inside a tier.`},{id:`roundRobin`,label:`Round robin`,blurb:`Take whichever eligible target has been idle longest, to spread load evenly.`},{id:`weighted`,label:`Weighted draw`,blurb:`Pick at random, biased by weight. The order differs from request to request.`}],W=0;function G(){return W+=1,`target-${W}`}function K(e,t){let n=N(e,t);return n===null?null:{costInput:String(n.input),costOutput:String(n.output),costCacheRead:String(n.cacheRead),costCacheWrite5m:String(n.cacheWrite5m),costCacheWrite1h:String(n.cacheWrite1h)}}function _e(e,t){let n=ee(e,t);return n===null?null:{contextWindow:String(n.contextWindow),maxOutputTokens:String(n.maxOutputTokens)}}var ve={oauth:`OAuth`,apiKey:`an API key`};function q(e){return e.map(e=>ve[e]).join(` or `)}function ye(e){let t={};for(let n of e){let e=t[n.provider]??[];e.includes(n.authType)||e.push(n.authType),t[n.provider]=e}return t}function J(e,t,n){let r=n[e];return r===void 0||r.length===0||te(e,t).some(e=>r.includes(e))}function be(e,t){return P[e].models.filter(n=>J(e,n.id,t))}function xe(e,t,n){if(t.trim().length===0||J(e,t,n))return null;let r=n[e]??[];return`${e} serves this model to ${q(te(e,t))} only, and every ${e} account here is ${q(r)}. Requests routed here will fail.`}function Se(e,t){return{...e,...t,...K(t.provider,t.model)??{},contextWindow:``,maxOutputTokens:``}}function Y(e=`anthropic`){let t=P[e].defaultModel,n=K(e,t);return{key:G(),provider:e,endpointId:``,model:t,tier:`1`,weight:`1`,costInput:n?.costInput??`0`,costOutput:n?.costOutput??`0`,costCacheRead:n?.costCacheRead??``,costCacheWrite5m:n?.costCacheWrite5m??``,costCacheWrite1h:n?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,tools:!0,images:!0,reasoning:!0}}function X(){return{id:``,strategy:`score`,isAlias:!1,targets:[Y()]}}function Ce(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:G(),provider:e.provider,endpointId:e.provider===`custom`?e.endpointId??``:``,model:e.model,tier:String(e.tier),weight:String(e.weight),costInput:String(e.costPerMTok.input),costOutput:String(e.costPerMTok.output),costCacheRead:e.costPerMTok.cacheRead===void 0?``:String(e.costPerMTok.cacheRead),costCacheWrite5m:e.costPerMTok.cacheWrite5m===void 0?``:String(e.costPerMTok.cacheWrite5m),costCacheWrite1h:e.costPerMTok.cacheWrite1h===void 0?``:String(e.costPerMTok.cacheWrite1h),contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),maxOutputTokens:e.maxOutputTokens===void 0?``:String(e.maxOutputTokens),tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function we(e){let t=e.id.trim();if(t.length===0)return{ok:!1,problem:`Give the model a name clients will ask for.`};if(e.targets.length===0)return{ok:!1,problem:`A model needs at least one target to route to.`};let n=[];for(let[t,r]of e.targets.entries()){let e=`Target ${t+1}`,i=r.endpointId.trim();if(r.provider===`custom`&&i.length===0)return{ok:!1,problem:`${e} needs a custom endpoint.`};let a=r.model.trim();if(a.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let o=Number(r.tier);if(!Number.isInteger(o)||o<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let s=Number(r.weight);if(!Number.isFinite(s)||s<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let c=Number(r.costInput),l=Number(r.costOutput);if(!Number.isFinite(c)||c<0||!Number.isFinite(l)||l<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let u=r.costCacheRead.trim().length>0,d=Number(r.costCacheRead);if(u&&(!Number.isFinite(d)||d<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let f=r.costCacheWrite5m.trim().length>0,p=Number(r.costCacheWrite5m);if(f&&(!Number.isFinite(p)||p<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let m=r.costCacheWrite1h.trim().length>0,h=Number(r.costCacheWrite1h);if(m&&(!Number.isFinite(h)||h<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let g=r.contextWindow.trim().length>0,_=Number(r.contextWindow);if(g&&(!Number.isInteger(_)||_<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let v=r.maxOutputTokens.trim().length>0,y=Number(r.maxOutputTokens);if(v&&(!Number.isInteger(y)||y<1))return{ok:!1,problem:`${e}: the output limit must be a whole number of tokens.`};n.push({provider:r.provider,...r.provider===`custom`?{endpointId:i}:{},model:a,tier:o,weight:s,costPerMTok:{input:c,output:l,...u?{cacheRead:d}:{},...f?{cacheWrite5m:p}:{},...m?{cacheWrite1h:h}:{}},...g?{contextWindow:_}:{},...v?{maxOutputTokens:y}:{},capabilities:{tools:r.tools,images:r.images,reasoning:r.reasoning}})}return{ok:!0,model:{id:t,strategy:e.strategy,isAlias:e.isAlias,targets:n}}}var Te=Object.keys(P),Ee=z.fieldset`
50
+ border: 1px solid ${({theme:e})=>e.color.rule};
51
+ border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
52
+ border-radius: ${({theme:e})=>e.radius.control};
53
+ padding: ${({theme:e})=>e.space(3)};
54
+ margin: 0;
55
+ background: ${({theme:e})=>e.color.panelSunk};
56
+ display: flex;
57
+ flex-direction: column;
58
+ gap: ${({theme:e})=>e.space(3)};
59
+ min-width: 0;
60
+ `,De=z.div`
61
+ display: grid;
62
+ grid-template-columns: minmax(140px, 1.4fr) minmax(160px, 2fr) 72px 72px;
63
+ gap: ${({theme:e})=>e.space(2)};
64
+ align-items: end;
65
+
66
+ @media (max-width: 720px) {
67
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
68
+ }
69
+ `,Oe=z.div`
70
+ display: grid;
71
+ grid-template-columns: repeat(3, minmax(0, 1fr));
72
+ gap: ${({theme:e})=>e.space(2)};
73
+ align-items: end;
74
+ `,Z=z.div`
75
+ display: flex;
76
+ flex-direction: column;
77
+ gap: 4px;
78
+ min-width: 0;
79
+ `,ke=z(c)`
80
+ gap: ${({theme:e})=>e.space(3)};
81
+ flex-wrap: wrap;
82
+ `,Ae=z.p`
83
+ font-size: 11.5px;
84
+ color: ${({theme:e})=>e.color.down};
85
+ margin: 0;
86
+ `,Q=z.label`
87
+ display: flex;
88
+ align-items: center;
89
+ gap: 6px;
90
+ cursor: pointer;
91
+ `;function je({target:t,index:n,onChange:i,onRemove:a,removable:l,endpoints:d,held:f}){let p=re(),h=P[t.provider],g=be(t.provider,f),_=xe(t.provider,t.model,f),b=(e,n)=>{i({...t,[e]:n})},x=K(t.provider,t.model),S=_e(t.provider,t.model),E=e=>{i(Se(t,e))};return R(Ee,{$provider:t.provider,children:[R(c,{$gap:2,children:[R(e,{as:`legend`,children:[`Target `,n+1]}),L(o,{}),L(u,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!l,"aria-label":`Remove target ${n+1}`,title:l?`Remove target ${n+1}`:`A model needs at least one target`,onClick:a,children:L(v,{})})]}),R(De,{children:[R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-provider`,children:`Provider`}),L(C,{id:`${p}-provider`,value:t.provider,onChange:e=>{let n=e.target.value,r=P[n].models.some(e=>e.id===t.model);E({provider:n,model:r?t.model:P[n].defaultModel})},children:Te.map(e=>L(`option`,{value:e,children:m[e]},e))})]}),t.provider===`custom`?R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-endpoint`,children:`Endpoint`}),R(C,{id:`${p}-endpoint`,value:t.endpointId,onChange:e=>b(`endpointId`,e.target.value),children:[L(`option`,{value:``,children:`Choose endpoint`}),d.map(e=>L(`option`,{value:e.id,children:e.label},e.id))]})]}):null,R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-model`,children:`Provider model`}),L(w,{id:`${p}-model`,list:`${p}-catalog`,value:t.model,placeholder:h.defaultModel,onChange:e=>E({provider:t.provider,model:e.target.value})}),L(`datalist`,{id:`${p}-catalog`,children:g.map(e=>L(`option`,{value:e.id,children:e.label},e.id))}),_===null?null:L(Ae,{role:`note`,children:_})]}),R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-tier`,children:`Tier`}),L(T,{id:`${p}-tier`,min:1,step:1,value:t.tier,onChange:e=>b(`tier`,e.target.value)})]}),R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-weight`,children:`Weight`}),L(T,{id:`${p}-weight`,min:0,step:.1,value:t.weight,onChange:e=>b(`weight`,e.target.value)})]})]}),R(r,{$gap:1,children:[R(c,{$gap:2,children:[L(e,{children:`Price per million tokens`}),L(o,{}),x===null?L(e,{as:`span`,children:`not in the catalog — price it yourself`}):R(s,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:t.costInput===x.costInput&&t.costOutput===x.costOutput&&t.costCacheRead===x.costCacheRead&&t.costCacheWrite5m===x.costCacheWrite5m&&t.costCacheWrite1h===x.costCacheWrite1h,onClick:()=>i({...t,...x}),children:[L(ae,{}),`Use list price`]})]}),R(Oe,{children:[R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-in`,children:`Input`}),L(T,{id:`${p}-in`,min:0,step:.01,value:t.costInput,onChange:e=>b(`costInput`,e.target.value)})]}),R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-out`,children:`Output`}),L(T,{id:`${p}-out`,min:0,step:.01,value:t.costOutput,onChange:e=>b(`costOutput`,e.target.value)})]}),R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-cache`,children:`Cache read`}),L(T,{id:`${p}-cache`,min:0,step:.01,placeholder:`same as input`,value:t.costCacheRead,onChange:e=>b(`costCacheRead`,e.target.value)})]}),R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-write5m`,children:`Cache write 5m`}),L(T,{id:`${p}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:t.costCacheWrite5m,onChange:e=>b(`costCacheWrite5m`,e.target.value)})]}),R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-write1h`,children:`Cache write 1h`}),L(T,{id:`${p}-write1h`,min:0,step:.01,placeholder:`2x input`,value:t.costCacheWrite1h,onChange:e=>b(`costCacheWrite1h`,e.target.value)})]})]})]}),R(r,{$gap:1,children:[R(c,{$gap:2,children:[L(e,{children:`Token limits`}),L(o,{}),S===null?L(e,{as:`span`,children:`not in the catalog — state them yourself`}):L(e,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),R(Oe,{children:[R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-context`,children:`Context window`}),L(T,{id:`${p}-context`,min:1,step:1024,placeholder:S?.contextWindow??`published`,value:t.contextWindow,onChange:e=>b(`contextWindow`,e.target.value)})]}),R(Z,{children:[L(e,{as:`label`,htmlFor:`${p}-maxout`,children:`Max output`}),L(T,{id:`${p}-maxout`,min:1,step:1024,placeholder:S?.maxOutputTokens??`published`,value:t.maxOutputTokens,onChange:e=>b(`maxOutputTokens`,e.target.value)})]})]})]}),R(r,{$gap:1,children:[L(e,{children:`Capabilities`}),R(ke,{children:[R(Q,{children:[L(y,{checked:t.tools,label:`Target ${n+1} supports tools`,onCheckedChange:e=>b(`tools`,e)}),`Tools`]}),R(Q,{children:[L(y,{checked:t.images,label:`Target ${n+1} supports images`,onCheckedChange:e=>b(`images`,e)}),`Images`]}),R(Q,{children:[L(y,{checked:t.reasoning,label:`Target ${n+1} supports reasoning`,onCheckedChange:e=>b(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Me=z.p`
92
+ font-size: 11.5px;
93
+ color: ${({theme:e})=>e.color.inkDim};
94
+ `,Ne=z.p`
95
+ font-size: 12px;
96
+ color: ${({theme:e})=>e.color.down};
97
+ `,Pe=z.p`
98
+ font-size: 12px;
99
+ color: ${({theme:e})=>e.color.ok};
100
+ `,Fe=z(c)`
101
+ gap: 8px;
102
+ `;function Ie({model:n,onSaved:i,onDeleted:l}){let[u,d]=F(()=>n===null?X():Ce(n)),[p,m]=F(null),[h,g]=F(!1),[v,x]=F(!1),S=t(),T=f(),D=a(),A=ye(D.data??[]),j=(D.data??[]).filter(e=>e.provider===`custom`).map(e=>({id:String(e.providerData.endpointId??``),label:String(e.providerData.endpointLabel??e.providerData.endpointId??``)})).filter((e,t,n)=>e.id.length>0&&n.findIndex(t=>t.id===e.id)===t),M=n?.id??null;ne(()=>{d(n===null?X():Ce(n)),m(null),g(!1)},[M]);let N=U.find(e=>e.id===u.strategy);return R(I,{children:[L(O,{legend:n===null?`New model`:`Edit model`,meta:n===null?void 0:n.id,actions:R(I,{children:[n===null?null:L(s,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>x(!0),children:`Delete`}),L(s,{type:`button`,$variant:`primary`,$size:`sm`,disabled:S.isPending,onClick:()=>{g(!1);let e=we(u);if(!e.ok){m(e.problem);return}m(null),S.mutate(e.model,{onSuccess:()=>{g(!0),i(e.model.id)},onError:e=>m(k(e))})},children:S.isPending?`Saving…`:n===null?`Create model`:`Save changes`})]}),children:R(r,{$gap:3,children:[L(E,{label:`Model name`,hint:n===null?`What clients send as the model. Anything not listed here is rejected.`:`Fixed once created. To rename, create a model under the new name and delete this one.`,children:e=>L(w,{...e,value:u.id,disabled:n!==null,placeholder:`fast`,onChange:e=>d({...u,id:e.target.value})})}),L(E,{label:`Routing strategy`,children:e=>L(C,{...e,value:u.strategy,onChange:e=>d({...u,strategy:e.target.value}),children:U.map(e=>L(`option`,{value:e.id,children:e.label},e.id))})}),N===void 0?null:L(Me,{children:N.blurb}),R(Fe,{children:[L(y,{checked:u.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>d({...u,isAlias:e})}),R(r,{$gap:0,children:[L(e,{as:`span`,children:`Alias`}),L(Me,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),R(r,{$gap:2,children:[R(c,{children:[L(e,{children:`Targets`}),L(o,{}),R(s,{type:`button`,$size:`sm`,onClick:()=>d({...u,targets:[...u.targets,Y(u.targets.at(-1)?.provider??`anthropic`)]}),children:[L(_,{}),`Add target`]})]}),u.targets.map((e,t)=>L(je,{target:e,index:t,removable:u.targets.length>1,endpoints:j,held:A,onChange:t=>d({...u,targets:u.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>d({...u,targets:u.targets.filter(t=>t.key!==e.key)})},e.key))]}),p===null?null:L(Ne,{role:`alert`,children:p}),h&&p===null?L(Pe,{role:`status`,children:`Saved.`}):null]})}),L(b,{open:v,onOpenChange:x,title:`Delete model`,body:n===null?``:`Deleting "${n.id}" makes it unroutable. Clients asking for it will get a model-unavailable error, and any key allowlisting it keeps a name that no longer resolves.`,confirmLabel:`Delete model`,busy:T.isPending,onConfirm:()=>{n!==null&&T.mutate(n.id,{onSuccess:()=>{x(!1),l()},onError:e=>{x(!1),m(k(e))}})}})]})}var Le=z.div`
103
+ display: grid;
104
+ grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
105
+ gap: ${({theme:e})=>e.space(4)};
106
+ align-items: start;
107
+
108
+ @media (max-width: 980px) {
109
+ grid-template-columns: minmax(0, 1fr);
110
+ }
111
+ `,Re=z(r)`
112
+ gap: ${({theme:e})=>e.space(4)};
113
+ min-width: 0;
114
+ `,ze=z.button`
115
+ display: flex;
116
+ flex-direction: column;
117
+ gap: 4px;
118
+ width: 100%;
119
+ padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
120
+ text-align: left;
121
+ background: ${({theme:e,$selected:t})=>t?e.color.accentWash:`transparent`};
122
+ border: 0;
123
+ border-left: 2px solid
124
+ ${({theme:e,$selected:t})=>t?e.color.accent:`transparent`};
125
+ border-bottom: 1px solid ${({theme:e})=>e.color.rule};
126
+ cursor: pointer;
127
+
128
+ &:hover {
129
+ background: ${({theme:e,$selected:t})=>t?e.color.accentWash:e.color.panelSunk};
130
+ }
131
+
132
+ &:last-child {
133
+ border-bottom: 0;
134
+ }
135
+ `,Be=z(l)`
136
+ font-family: ${({theme:e})=>e.font.mono};
137
+ font-size: 12.5px;
138
+ display: block;
139
+ max-width: 100%;
140
+ `,Ve=z.div`
141
+ display: flex;
142
+ gap: 2px;
143
+ `,He=z.span`
144
+ width: 12px;
145
+ height: 3px;
146
+ border-radius: 1px;
147
+ background: ${({$provider:e})=>`var(--p-${e})`};
148
+ `,$=`\0new`;function Ue(){let t=n(),[r,a]=F(null),l=t.data??[],u=r===$?null:l.find(e=>e.id===r)??null,d=r===$||r===null&&!t.isLoading&&l.length===0;ne(()=>{r===null&&l.length!==0&&a(l[0]?.id??null)},[l,r]);let f=t.isLoading?`Reading configured models…`:l.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${l.length} model${l.length===1?``:`s`} routing to ${l.reduce((e,t)=>e+t.targets.length,0)} targets.`;return R(I,{children:[L(g,{legend:`Models`,title:`Virtual models`,summary:f,actions:R(s,{type:`button`,$variant:`primary`,onClick:()=>a($),children:[L(_,{}),`New model`]})}),R(Le,{children:[L(O,{legend:`Configured`,meta:`${l.length}`,flush:!0,children:t.isError?L(A,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?L(`div`,{style:{padding:12},children:L(j,{rows:4})}):l.length===0?L(M,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:L(s,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>a($),children:`New model`})}):L(`div`,{children:l.map(t=>{let n=[...new Set(t.targets.map(e=>e.provider))];return R(ze,{type:`button`,$selected:t.id===r,"aria-pressed":t.id===r,onClick:()=>a(t.id),children:[R(c,{$gap:2,style:{width:`100%`},children:[L(Be,{title:t.id,children:t.id}),L(o,{}),t.isAlias?L(S,{children:`alias`}):null]}),R(c,{$gap:2,style:{width:`100%`},children:[L(Ve,{children:n.map(e=>L(He,{$provider:e,title:e},e))}),L(e,{children:t.strategy}),L(o,{}),R(i,{$dim:!0,$size:`11px`,children:[t.targets.length,` target`,t.targets.length===1?``:`s`]})]})]},t.id)})})}),R(Re,{children:[u===null&&!d?L(O,{legend:`Editor`,children:t.isLoading?L(j,{rows:5}):L(M,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):L(Ie,{model:u,onSaved:e=>{a(e),t.refetch()},onDeleted:()=>{a(null),t.refetch()}}),L(ge,{modelId:u?.id??null})]})]})]})}var We=Ue;export{We as component};
@@ -0,0 +1,20 @@
1
+ import{J as e,X as t,Y as n,Z as r,at as i,k as a}from"./queries-CIOPbRcE.js";import{a as o,s}from"./index-gMv8Qs7m.js";import{t as c}from"./Rack-B4c0dbIb.js";import{a as l,n as u,r as d,t as f}from"./States-CxLDlCaw.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";var C=/%2e/i;function w(e,t){if(t.length===0)throw TypeError(`plugin api ${e} must not be empty`);if(t.startsWith(`/`))throw TypeError(`plugin api ${e} must be relative to the plugin's own prefix, got ${JSON.stringify(t)}`);if(t.includes(`..`)||C.test(t))throw TypeError(`plugin api ${e} must not escape the plugin's own prefix, got ${JSON.stringify(t)}`)}function T(e,t){if(w(`plugin id`,e),e.includes(`/`))throw TypeError(`plugin api plugin id must be a single path segment, got ${e}`);return w(`path`,t),`/api/plugins/${e}/${t}`}var E=new Map;function D(i){let a=E.get(i);if(a!==void 0)return a;let o={get:(e,t)=>n(T(i,e),t),post:(e,n)=>t(T(i,e),n),put:(e,t)=>r(T(i,e),t),del:t=>e(T(i,t))};return E.set(i,o),o}var O=h(e=>s(()=>import(e),[]));O.Provider;function k(){return _(O)}function A(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function j(e,t,n){return g(async()=>{let r=A(await n(t),e);return{default:()=>r.mount({pluginId:e,api:D(e)})}})}var M=S.p`
2
+ font-size: 13px;
3
+ color: ${({theme:e})=>e.color.down};
4
+ `,N=S.p`
5
+ font-family: ${({theme:e})=>e.font.mono};
6
+ font-size: 12px;
7
+ color: ${({theme:e})=>e.color.inkDim};
8
+ overflow-wrap: anywhere;
9
+ `,P=S.p`
10
+ font-size: 12px;
11
+ color: ${({theme:e})=>e.color.inkDim};
12
+ max-width: 68ch;
13
+ `;function F(e){return e instanceof Error?e.message:typeof e==`string`?e:`The plugin threw a value that is not an error.`}var I=class extends p{state={message:null};static getDerivedStateFromError(e){return{message:F(e)}}componentDidUpdate(e){e.pluginId!==this.props.pluginId&&this.state.message!==null&&this.setState({message:null})}componentDidCatch(e,t){}render(){let{message:e}=this.state;return e===null?this.props.children:b(l,{legend:`Plugin failed`,meta:this.props.pluginId,children:x(i,{$gap:2,children:[x(M,{children:[this.props.pluginName,` stopped rendering.`]}),b(N,{children:e}),b(P,{children:`The rest of the console is unaffected. Reload the page to try this screen again, and report the message above to whoever maintains the plugin.`})]})})}},L=S.p`
14
+ font-size: 13px;
15
+ color: ${({theme:e})=>e.color.warn};
16
+ `,R=S.p`
17
+ font-size: 12px;
18
+ color: ${({theme:e})=>e.color.inkDim};
19
+ max-width: 68ch;
20
+ `;function z({pluginId:e}){let t=a(),n=k(),r=t.data?.find(t=>t.id===e),o=r?.ui??null,s=o?.compatible===!0?o.entry:null,p=v(()=>s===null?null:j(e,s,n),[e,s,n]);if(t.isError)return x(y,{children:[b(c,{legend:`Plugin`,title:`Plugins`,summary:`The installed plugins are unknown.`}),b(u,{legend:`Plugins unavailable`,error:t.error})]});if(r===void 0)return x(y,{children:[b(c,{legend:`Plugin`,title:t.isPending?`Loading…`:e,summary:t.isPending?`Reading the installed plugins.`:`This gateway does not run a plugin with that id.`}),t.isPending?b(d,{}):b(f,{legend:`Not installed`,message:`No plugin with the id ${e} is installed. Install it and restart the gateway.`})]});let h=b(c,{legend:`Plugin`,title:r.nav?.label??r.name,summary:`${r.name} ${r.version}, installed as ${r.id}.`});return o===null?x(y,{children:[h,b(f,{legend:`No interface`,message:`${r.name} runs entirely in the gateway and has no console screen.`})]}):p===null?x(y,{children:[h,b(l,{legend:`Interface unavailable`,meta:r.id,children:x(i,{$gap:2,children:[b(L,{children:o.reason??`This plugin's interface does not match this gateway.`}),b(R,{children:`The plugin's server half is unaffected and keeps running. Update the plugin, or the gateway, so the two agree on a dashboard SDK version.`})]})})]}):x(y,{children:[h,b(I,{pluginId:r.id,pluginName:r.name,children:b(m,{fallback:b(d,{}),children:b(p,{})})})]})}function B(){let{pluginId:e}=o.useParams();return b(z,{pluginId:e})}export{B as component};
@@ -0,0 +1,46 @@
1
+ import{$ as e,L as t,O as n,at as r,c as i,et as a,it as o,lt as s,nt as c,o as l,z as u}from"./queries-CIOPbRcE.js";import{t as d}from"./Rack-B4c0dbIb.js";import{t as f}from"./Toggle-DMk46RX2.js";import{i as p,n as m,t as h}from"./Field-D-14HF0x.js";import{t as g}from"./Meter-stpt3vQu.js";import{a as _,i as v,n as y,r as b}from"./States-CxLDlCaw.js";import{useEffect as x,useState as S}from"react";import{Fragment as C,jsx as w,jsxs as T}from"react/jsx-runtime";import E from"styled-components";var D=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],O=E(a)`
2
+ display: block;
3
+ white-space: pre;
4
+ overflow-x: auto;
5
+ padding: 0.75rem;
6
+ background: ${({theme:e})=>e.color.panelSunk};
7
+ border: 1px solid ${({theme:e})=>e.color.rule};
8
+ border-radius: 4px;
9
+ font-size: 0.8125rem;
10
+ line-height: 1.5;
11
+ `,k=E.div`
12
+ color: ${({theme:e})=>e.color.inkDim};
13
+ font-size: 0.8125rem;
14
+ margin-bottom: 0.25rem;
15
+ `,A=E.p`
16
+ color: ${({theme:e})=>e.color.inkDim};
17
+ font-size: 0.8125rem;
18
+ margin: 0;
19
+ `,j=E.div`
20
+ display: grid;
21
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
22
+ gap: ${({theme:e})=>e.space(2)};
23
+ `,M=[{key:`defaultModel`,label:`Default model`,required:!0},{key:`fableModel`,label:`Fable model`,required:!1},{key:`opusModel`,label:`Opus model`,required:!1},{key:`sonnetModel`,label:`Sonnet model`,required:!1},{key:`haikuModel`,label:`Haiku model`,required:!1}];function N(){let[e,t]=S(`claude`),[i,o]=S(()=>({claude:{},opencode:{}})),u=n(),d=i[e],f=typeof d.defaultModel==`string`&&d.defaultModel!==``?d:void 0,m=l(e,f),g=D.find(t=>t.id===e);return w(_,{legend:`Agent setup`,children:T(r,{children:[w(c,{children:D.map(n=>w(s,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),T(A,{children:[g?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,T(a,{children:[`omni setup `,e]}),` to write these files directly.`]}),(u.data?.length??0)>0?w(j,{children:M.map(t=>w(h,{label:t.label,children:n=>T(p,{...n,value:d[t.key]??``,onChange:n=>o(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[w(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),u.data?.map(e=>w(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,u.isLoading?w(b,{rows:2}):m.isError?w(y,{error:m.error,onRetry:()=>void m.refetch()}):m.isLoading?w(b,{rows:4}):(u.data?.length??0)===0?w(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):f===void 0?T(A,{children:[`Choose a default model to generate `,g?.label,` settings.`]}):m.data===void 0||m.data.length===0?w(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):m.data.map(e=>T(`div`,{children:[w(k,{children:e.path}),w(O,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),m.isError?w(A,{children:v(m.error)}):null]})})}var P=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Preference for accounts with fewer requests in flight right now.`}],F=[{id:`maxAttempts`,label:`Attempts per request`,hint:`How many candidates dispatch may try before giving up. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`How long a request may take across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures on one account and model before it is taken out of rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Base wait before a tripped account is probed again. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before maintenance prunes them.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often each account's provider is asked for its remaining quota. 0 disables polling. Takes effect on restart.`,unit:`ms`,step:6e4,min:0}],I=E.div`
24
+ display: grid;
25
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
26
+ gap: ${({theme:e})=>e.space(3)};
27
+ `,L=E(r)`
28
+ gap: 6px;
29
+ `,R=E.p`
30
+ font-size: 11px;
31
+ color: ${({theme:e})=>e.color.inkDim};
32
+ `,z=E.p`
33
+ font-size: 12px;
34
+ color: ${({theme:e})=>e.color.down};
35
+ `,B=E.p`
36
+ font-size: 12px;
37
+ color: ${({theme:e})=>e.color.ok};
38
+ `,V=E.p`
39
+ font-size: 12px;
40
+ color: ${({theme:e})=>e.color.warn};
41
+ max-width: 72ch;
42
+
43
+ code {
44
+ font-family: ${({theme:e})=>e.font.mono};
45
+ }
46
+ `;function H(e){let t={};for(let n of P)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of F)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function U(e){let t={};for(let n of P){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of F){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function W(){let n=u(),l=i(),p=t(),[E,D]=S({}),[O,k]=S(null),[A,j]=S(!1);x(()=>{n.data!==void 0&&D(H(n.data))},[n.data]);let M=Math.max(1e-4,...P.map(e=>Math.abs(Number(E[`w.${e.id}`])||0)));return T(C,{children:[w(d,{legend:`Settings`,title:`Routing and retention`,summary:`These apply to every request the gateway routes. Changes take effect on the next request; nothing is restarted.`,actions:w(s,{type:`button`,$variant:`primary`,disabled:p.isPending||n.isLoading,onClick:()=>{j(!1);let e=U(E);if(!e.ok){k(e.problem);return}k(null),p.mutate(e.settings,{onSuccess:()=>j(!0),onError:e=>k(v(e))})},children:p.isPending?`Saving…`:`Save changes`})}),n.isError?w(_,{legend:`Settings`,children:w(y,{error:n.error,onRetry:()=>void n.refetch()})}):n.isLoading?w(_,{legend:`Settings`,children:w(b,{rows:6})}):T(r,{$gap:4,children:[w(_,{legend:`Scoring weights`,meta:`relative to each other`,footer:T(c,{children:[w(e,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),w(o,{})]}),children:w(I,{children:P.map(e=>{let t=Number(E[`w.${e.id}`])||0;return T(L,{children:[w(h,{label:e.label,children:t=>w(m,{...t,type:`number`,step:.5,value:E[`w.${e.id}`]??``,onChange:t=>D({...E,[`w.${e.id}`]:t.target.value})})}),w(g,{fraction:Math.abs(t)/M,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),w(R,{children:e.blurb})]},e.id)})})}),w(_,{legend:`Limits`,children:w(I,{children:F.map(t=>w(L,{children:w(h,{label:t.label,hint:t.hint,children:n=>T(c,{$gap:2,children:[w(m,{...n,type:`number`,min:t.min,step:t.step,value:E[t.id]??``,onChange:e=>D({...E,[t.id]:e.target.value})}),w(e,{children:t.unit})]})})},t.id))})}),w(_,{legend:`Historical tool results`,children:T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.rtkEnabled===`true`,onCheckedChange:e=>D({...E,rtkEnabled:String(e)}),label:`Enable RTK compression`}),w(R,{children:`Compress recognized historical non-error tool results before provider dispatch. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a built-in detector recognizes a high-confidence shell-output format. Compression is deterministic and lossy. Disabled by default.`})]})}),w(_,{legend:`Request and response bodies`,meta:l.data===!0?`permitted by the environment`:`not permitted`,children:T(r,{$gap:3,children:[l.data===!0?null:T(V,{children:[`This gateway was started without `,w(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,w(`code`,{children:`.env`}),` `,`and restart before turning capture on. Two keys mean an admin session on its own cannot start recording prompts.`]}),T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.bodyLoggingEnabled===`true`,disabled:l.data!==!0,onCheckedChange:e=>D({...E,bodyLoggingEnabled:String(e)}),label:`Capture request and response bodies`}),w(R,{children:`Stores what each client sent and what each provider returned, encrypted under OMNI_ENCRYPTION_KEY beside the database. Bearer tokens and API keys are masked first and headers are never captured. Bodies expire on the log retention window above, and the newest 100,000 requests are kept whatever that window says. Off by default.`})]}),T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.bodyLoggingCaptureStreamChunks===`true`,disabled:l.data!==!0||E.bodyLoggingEnabled!==`true`,onCheckedChange:e=>D({...E,bodyLoggingCaptureStreamChunks:String(e)}),label:`Also keep raw stream frames`}),w(R,{children:`Retains the raw SSE frames of each attempt as well as the reassembled response. The only way to debug stream framing itself, and by far the most expensive thing capture can store, so it is gated separately rather than implied.`})]})]})}),O===null?null:w(z,{role:`alert`,children:O}),A&&O===null?w(B,{role:`status`,children:`Settings saved.`}):null,w(N,{}),w(_,{legend:`Known limits`,children:T(r,{$gap:2,children:[T(c,{$gap:2,children:[w(a,{$dim:!0,children:`rate limits`}),w(R,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),T(c,{$gap:2,children:[w(a,{$dim:!0,children:`logs`}),w(R,{children:`Request rows record routing and token counts only. Prompts and responses are written only when body capture above is on, and to a separate encrypted store; credentials are never written to either.`})]})]})})]})]})}var G=W;export{G as component};
@@ -0,0 +1,83 @@
1
+ import{$ as e,C as t,G as n,O as r,Q as i,at as a,et as o,g as s,nt as c,ot as l,rt as u}from"./queries-CIOPbRcE.js";import{i as d,n as f,r as p}from"./index-gMv8Qs7m.js";import{a as m,r as h,t as g}from"./Rack-B4c0dbIb.js";import{E as _,O as v,S as y,T as b}from"./Lamp-BDf7-dMa.js";import{a as x,n as S,r as C,t as w}from"./States-CxLDlCaw.js";import{i as T,n as E,r as D,t as O}from"./Table-CVDZ69Zx.js";import{t as ee}from"./catalog-BBKm8Ih8.js";import{$ as te,A as k,At as ne,B as re,C as ie,Ct as A,D as ae,Dt as j,E as oe,Et as M,F as N,G as P,H as se,I as ce,J as le,K as ue,L as de,M as fe,Mt as F,N as I,O as pe,Ot as me,P as L,Q as he,R as ge,S as _e,St as ve,T as ye,Tt as be,U as xe,V as Se,W as Ce,X as we,Y as Te,Z as Ee,_ as De,_t as Oe,a as ke,at as Ae,b as R,bt as je,c as Me,ct as Ne,d as z,dt as Pe,et as Fe,f as B,ft as Ie,g as Le,gt as Re,h as V,ht as ze,i as Be,it as Ve,j as He,jt as Ue,k as We,kt as Ge,l as Ke,lt as qe,m as Je,mt as Ye,n as Xe,nt as Ze,o as Qe,ot as $e,p as et,pt as tt,q as nt,r as rt,rt as it,s as H,st as at,t as ot,tt as st,u as ct,ut as lt,v as ut,vt as dt,w as ft,wt as pt,x as U,xt as mt,y as ht,yt as gt,z as _t}from"./shared-B4o-2quR.js";import{t as W}from"./Readout-Du15WYx0.js";import*as G from"react";import{PureComponent as vt,forwardRef as yt,useMemo as K,useRef as bt,useState as xt}from"react";import{jsx as q,jsxs as J}from"react/jsx-runtime";import Y from"styled-components";function St(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function Ct(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var wt=(e,t,n)=>he(e,`xAxis`,St(e,t),n),Tt=(e,t,n)=>Fe(e,`xAxis`,St(e,t),n),Et=(e,t,n)=>he(e,`yAxis`,Ct(e,t),n),Dt=(e,t,n)=>Fe(e,`yAxis`,Ct(e,t),n),Ot=je([Ne,wt,Et,Tt,Dt],(e,t,n,r,i)=>dt(e,`xAxis`)?tt(t,r,!1):tt(n,i,!1)),kt=je([st,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),At=e=>{var t=Ne(e);return dt(t,`xAxis`)?`yAxis`:`xAxis`},jt=(e,t)=>At(e)===`yAxis`?Ct(e,t):St(e,t),Mt=(e,t,n)=>te(e,At(e),jt(e,t),n),Nt=je([kt,Mt],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=Ze(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),Pt=je([kt,Mt],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(be)}}),Ft=je([Ne,wt,Et,Tt,Dt,Nt,Ae,Ot,kt,Ve,Pt],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return mn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),It=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Lt=[`id`,`baseLine`];function Rt(){return Rt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Rt.apply(null,arguments)}function zt(e,t){if(e==null)return{};var n,r,i=Bt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Bt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Vt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!gt(a)||!gt(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return j(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),j(c)?G.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Ht(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!gt(a)||!gt(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return j(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),j(c)?G.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function Ut(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?G.createElement(Ht,{alpha:t,points:r,baseLine:i,strokeWidth:a}):G.createElement(Vt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Wt(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=zt(e,It),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=ce(),h=d.id,g=d.baseLine,_=zt(d,Lt),v=Ue(_),y=G.createElement($e,Rt({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),b=l!==`none`&&G.createElement($e,Rt({},v,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),x=l!==`none`&&c&&Array.isArray(g)&&G.createElement($e,Rt({},v,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?G.createElement(Ge,null,G.createElement(`defs`,null,G.createElement(`clipPath`,{id:m},G.createElement(Ut,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),G.createElement(Ge,{clipPath:`url(#${m})`},y,b,x)):G.createElement(G.Fragment,null,y,b,x)}var Gt=[`id`],Kt=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function qt(){return qt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qt.apply(null,arguments)}function Jt(e,t){if(e==null)return{};var n,r,i=Yt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Yt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Xt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xt(Object(n),!0).forEach(function(t){Zt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Zt(e,t,n){return(t=Qt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qt(e){var t=$t(e,`string`);return typeof t==`symbol`?t:t+``}function $t(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var en={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:Se,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[X(X({},e.next),{},{x:A(e.prev.x,e.next.x,t),y:A(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:Wt,xAxisId:0,yAxisId:0,zIndex:it.area};function tn(e,t){return e&&e!==`none`?e:t}var nn=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:tn(r,i),value:Re(n,t),payload:e}]},rn=G.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:me,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Re(o,t),hide:s,type:u,color:tn(r,a),unit:c,formatter:l,graphicalItemId:d}};return G.createElement(xe,{tooltipEntrySettings:f})});function an(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=Ue(r);return G.createElement(I,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function on(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return G.createElement(ue,{value:t?r:void 0},n)}function sn(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=Jt(a,Gt),_=X(X({},ne(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return G.createElement(G.Fragment,null,t?.length>1&&G.createElement(Ge,{clipPath:r?`url(#clipPath-${i})`:void 0},G.createElement(Ce,{option:m,DefaultShape:en.shape,shapeProps:_})),G.createElement(an,{points:t,props:g,clipPathId:i}))}function cn(e,t,n){if(j(e)){var r=j(t)?t:void 0;return A(r,e,n)}if(M(e)||pt(e)){var i=j(t)?t:void 0;return A(i,0,n)}return e}function ln(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=K(()=>({points:o,baseLine:s}),[o,s]),h=_t(m,a),g=qe(),_=ge(r.onAnimationStart,r.onAnimationEnd),v=_.isAnimating,y=_.handleAnimationStart,b=_.handleAnimationEnd,x=h.startValue;if(g==null)return null;var S=Array.isArray(s)&&Array.isArray(x)?re(x,s,f):Array.isArray(s)?re(null,s,f):null;return G.createElement(de,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:y,onAnimationEnd:b,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(S,i,g):a?s:cn(s,x,i);return h.syncStepValue(c,i),G.createElement(on,{showLabels:!v,points:o},r.children,G.createElement(sn,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:v||i<1,isEntrance:a}),G.createElement(nt,{label:r.label}))})}function un(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=bt(null),a=bt();return G.createElement(ln,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var dn=class extends vt{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=F(`recharts-area`,i),g=f,_=ae(n),v=_.r,y=_.strokeWidth,b=P(n),x=v*2+y,S=s?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return G.createElement(we,{zIndex:m},G.createElement(Ge,{className:h},s&&G.createElement(`defs`,null,G.createElement(pe,{clipPathId:g,xAxisId:c,yAxisId:l}),!b&&G.createElement(`clipPath`,{id:`clipPath-dots-${g}`},G.createElement(`rect`,{x:o-x/2,y:a-x/2,width:u+x,height:d+x}))),G.createElement(un,{needClip:s,clipPathId:g,props:this.props})),G.createElement(He,{points:r,mainColor:tn(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(p)&&G.createElement(He,{points:p,mainColor:tn(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}};function fn(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=Jt(e,Kt),g=lt(),_=Ee(),v=We(p,m).needClip,y=Ie(),b=mt(t=>Ft(t,e.id,y))??{},x=b.points,S=b.isRange,C=b.baseLine,w=fe();if(g!==`horizontal`&&g!==`vertical`||w==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var T=w.height,E=w.width,D=w.x,O=w.y;return!x||!x.length?null:G.createElement(dn,qt({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:C,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:T,hide:l,layout:g,isAnimationActive:u,isRange:S,legendType:d,needClip:v,points:x,stroke:f,width:E,left:D,top:O,xAxisId:p,yAxisId:m}))}var pn=(e,t,n,r,i)=>{var a=n??t;if(j(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function mn(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=pn(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=Oe(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=Oe(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>Oe(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:Ye({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:Ye({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function hn(e){var t=ve(e,en),n=Ie();return G.createElement(N,{id:t.id,type:`area`},e=>G.createElement(G.Fragment,null,G.createElement(se,{legendPayload:nn(t)}),G.createElement(rn,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),G.createElement(L,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:ze(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),G.createElement(fn,qt({},t,{id:e}))))}var gn=G.memo(hn,at);gn.displayName=`Area`;var _n=[`axis`],vn=yt((e,t)=>G.createElement(ie,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:_n,tooltipPayloadSearcher:Te,categoricalChartProps:e,ref:t})),yn=[`axis`],bn=yt((e,t)=>G.createElement(ie,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yn,tooltipPayloadSearcher:Te,categoricalChartProps:e,ref:t})),xn=53,Z=9,Q=2,Sn=Y.div`
2
+ display: flex;
3
+ gap: ${Q}px;
4
+ `,Cn=Y.div`
5
+ display: grid;
6
+ grid-template-rows: repeat(7, ${Z}px);
7
+ gap: ${Q}px;
8
+ padding-top: ${11}px;
9
+ font-size: 9px;
10
+ color: ${({theme:e})=>e.color.inkFaint};
11
+ `,wn=Y.div`
12
+ line-height: ${Z}px;
13
+ padding-right: 2px;
14
+ text-align: right;
15
+ `,Tn=Y.div`
16
+ display: grid;
17
+ grid-template-columns: repeat(${xn}, ${Z}px);
18
+ gap: ${Q}px;
19
+ height: ${Z}px;
20
+ font-size: 9px;
21
+ color: ${({theme:e})=>e.color.inkFaint};
22
+ `,En=Y.div`
23
+ white-space: nowrap;
24
+ line-height: ${Z}px;
25
+ `,Dn=Y.div`
26
+ display: grid;
27
+ grid-template-columns: repeat(${xn}, ${Z}px);
28
+ gap: ${Q}px;
29
+ `,On=Y.div`
30
+ display: grid;
31
+ grid-template-rows: repeat(7, ${Z}px);
32
+ gap: ${Q}px;
33
+ `,kn=Y.div`
34
+ width: ${Z}px;
35
+ height: ${Z}px;
36
+ border-radius: 2px;
37
+ background: ${({$level:e})=>e===0?`var(--panel-sunk)`:`color-mix(in oklch, var(--accent) ${[0,24,46,70,100][e]??100}%, var(--panel-sunk))`};
38
+ border: 1px solid var(--rule);
39
+ visibility: ${({$future:e})=>e?`hidden`:`visible`};
40
+
41
+ &:hover,
42
+ &:focus-visible {
43
+ outline: 1px solid var(--ink-dim);
44
+ outline-offset: 1px;
45
+ }
46
+ `,An=Y(c)`
47
+ gap: ${Q}px;
48
+ `,jn=Y(o)`
49
+ color: ${({theme:e})=>e.color.inkDim};
50
+ font-size: 11px;
51
+ `;function Mn(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(t.length*e))]??0;return[n(.25),n(.5),n(.75)]}function Nn(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function Pn({days:t,now:n}){let[r,i]=xt(`tokens`),[o,s]=xt(null),l=Le(r),d=K(()=>{let e=new Map;for(let n of t){let t=Number(n.key);Number.isFinite(t)&&e.set(ht(t),{requests:n.requests,errors:n.errors,costUsd:n.costUsd,inputTokens:n.inputTokens,outputTokens:n.outputTokens,cacheReadTokens:n.cacheReadTokens,cacheWriteTokens:n.cacheWriteTokens,rtkSavedTokens:n.rtkSavedTokens,rtkAppliedRequests:n.rtkAppliedRequests,durationMsSum:n.durationMsSum})}let r=new Date(ht(n));r.setDate(r.getDate()+(6-r.getDay())-370);let i=ht(n);return Array.from({length:xn},()=>Array.from({length:7},()=>{let t=r.getTime();return r.setDate(r.getDate()+1),{at:t,totals:e.get(t)??Ke,future:t>i}}))},[t,n]),f=d.flat(),p=Mn(f.map(e=>l.of({key:``,...e.totals}))),m=f.reduce((e,t)=>ct(e,B(t.totals)),Ke),h=f.reduce((e,t)=>e+ +(t.totals.requests>0),0),g=(e,t)=>`${e}: ${y(t.requests)} requests, ${y(z(t))} tokens, ${v(t.costUsd)}`;return q(x,{legend:`Activity`,meta:o===null?`${y(h)} active days`:void 0,actions:q(Xe,{children:Be.map(e=>q(Qe,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:e.label},e.id))}),children:J(a,{$gap:2,children:[q(u,{children:q(a,{$gap:1,style:{width:611},children:J(Sn,{children:[q(Cn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>q(wn,{children:e},t))}),J(a,{$gap:1,children:[q(Tn,{"aria-hidden":`true`,children:d.map((e,t)=>{let n=e[0],r=d[t-1]?.[0],i=n!==void 0&&(r===void 0||new Date(r.at).getMonth()!==new Date(n.at).getMonth());return q(En,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),q(Dn,{role:`grid`,"aria-label":`${l.label} per day over the last year`,children:d.map(e=>q(On,{role:`row`,children:e.map(e=>q(kn,{role:`gridcell`,tabIndex:-1,"aria-label":g(Je(e.at),e.totals),title:g(Je(e.at),e.totals),$future:e.future,$level:e.future?0:Nn(l.of({key:``,...e.totals}),p),onMouseEnter:()=>s(e),onMouseLeave:()=>s(null)},e.at))},e[0]?.at))})]})]})})}),J(c,{$justify:`space-between`,$wrap:!0,children:[q(jn,{children:o===null?g(`Last 12 months`,m):g(Je(o.at),o.totals)}),J(c,{$gap:1,children:[q(e,{children:`Less`}),q(An,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>q(kn,{$level:e,$future:!1},e))}),q(e,{children:`More`})]})]})]})})}function Fn({buckets:e,by:t,since:n,until:r,metric:i,names:a}){let o=U(n,r,t),s=new Map,c=new Map;for(let n of e){let e=n.split??`unknown`;s.set(e,ct(s.get(e)??Ke,n));let r=c.get(e)??new Map,a=V(n.key,t);r.set(a,(r.get(a)??0)+i.of(n)),c.set(e,r)}let d=[...s.entries()].sort((e,t)=>i.of(B(t[1]))-i.of(B(e[1])));return q(u,{children:J(O,{children:[q(`thead`,{children:J(`tr`,{children:[q(D,{children:`Key`}),q(D,{children:`Trend`}),q(D,{$align:`right`,children:`Requests`}),q(D,{$align:`right`,children:`Failed`}),q(D,{$align:`right`,children:`Tokens`}),q(D,{$align:`right`,children:`Mean`}),q(D,{$align:`right`,children:`Cost`})]})}),q(`tbody`,{children:d.map(([e,t])=>{let n=c.get(e)??new Map,r=e===`unknown`?`Unattributed`:a.get(e)??e;return J(T,{children:[q(E,{children:q(l,{style:{display:`block`,maxWidth:`28ch`},children:r})}),q(E,{style:{width:120},children:q(h,{values:o.map(e=>n.get(e)??0),height:20,label:`${r}: ${i.format(i.of(B(t)))} over the window`})}),q(E,{$align:`right`,$mono:!0,children:y(t.requests)}),q(E,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:_(t.requests===0?0:t.errors/t.requests,0)}),q(E,{$align:`right`,$mono:!0,children:y(z(t))}),q(E,{$align:`right`,$mono:!0,children:b(t.requests===0?null:t.durationMsSum/t.requests)}),q(E,{$align:`right`,$mono:!0,children:v(t.costUsd)})]},e)})})]})})}var In=6,Ln=`__other__`,Rn=`unknown`;function zn(e,t){let n=t.get(e);return n===void 0?f.find(t=>ee[t].models.some(t=>t.id===e))??null:n}function Bn(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${d(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Vn({buckets:e,by:t,since:n,until:r,metric:i,providers:o}){let s=[...et(e,i).entries()],c=s.slice(0,In),u=s.slice(In),d=[];for(let e of[...f,null])c.filter(([t])=>zn(t,o)===e).forEach(([t,n],r)=>{d.push({name:t,label:t===Rn?`Unresolved`:t,color:Bn(e,r),totals:n})});u.length>0&&d.push({name:Ln,label:`${u.length} more`,color:`var(--ink-faint)`,totals:u.reduce((e,[,t])=>ct(e,B(t)),Ke)});let p=new Set(c.map(([e])=>e)),m=new Map;for(let n of e){let e=n.split??Rn,r=`${V(n.key,t)} ${p.has(e)?e:Ln}`;m.set(r,(m.get(r)??0)+i.of(n))}let h=U(n,r,t).map(e=>{let t={at:e};for(let n of d)t[n.name]=m.get(`${e} ${n.name}`)??0;return t}),g=new Map(d.map(e=>[e.name,e.label]));return J(a,{$gap:2,children:[q(ot,{$height:220,children:q(Pe,{width:`100%`,height:`100%`,children:J(vn,{data:h,margin:{top:4,right:4,bottom:4,left:4},children:[q(k,{stroke:`var(--rule)`,vertical:!1}),q(ye,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(ft,{tickFormatter:e=>i.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),q(le,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>{if(e!==!0||n===void 0||n.length===0)return null;let a=n.filter(e=>Number(e.value??0)>0);return J(Me,{children:[q(`div`,{children:R(Number(r),t)}),a.length===0?q(`div`,{children:`No ${i.label.toLowerCase()}`}):a.map(e=>J(`div`,{children:[g.get(String(e.dataKey))??String(e.dataKey),` `,i.format(Number(e.value??0))]},String(e.dataKey)))]})}}),d.map(e=>q(gn,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),q(rt,{children:d.map(e=>J(`span`,{children:[q(H,{$color:e.color}),` `,q(l,{title:`${e.label}: ${i.format(i.of(B(e.totals)))} ${i.label.toLowerCase()}`,style:{display:`inline-block`,maxWidth:`24ch`,verticalAlign:`bottom`},children:e.label})]},e.name))})]})}var Hn=`unknown`;function Un(e){let t=f.find(t=>t===e);return t===void 0?`var(--ink-faint)`:d(t)}function Wn(e){let t=f.find(t=>t===e);return t===void 0?`Unresolved`:p[t]}function Gn({buckets:e,by:t,since:n,until:r,metric:i}){let o=et(e,i),s=[...f,Hn].map(e=>({name:e,totals:o.get(e)})).filter(e=>e.totals!==void 0),c=s.map(e=>e.name),l=U(n,r,t),u=ut(e,l,t,i),d=[...o.values()].reduce((e,t)=>e+t.requests,0);return J(a,{$gap:3,children:[q(ot,{$height:200,children:q(Pe,{width:`100%`,height:`100%`,children:J(vn,{data:u,margin:{top:4,right:4,bottom:4,left:4},children:[q(k,{stroke:`var(--rule)`,vertical:!1}),q(ye,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(ft,{tickFormatter:e=>i.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),q(le,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:J(Me,{children:[q(`div`,{children:R(Number(r),t)}),n.map(e=>J(`div`,{children:[Wn(String(e.dataKey)),` `,i.format(Number(e.value??0))]},String(e.dataKey)))]})}),c.map(e=>q(gn,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:Un(e),strokeWidth:2,fill:Un(e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),q(rt,{children:c.map(e=>J(`span`,{children:[q(H,{$color:Un(e)}),` `,Wn(e)]},e))}),J(O,{children:[q(`thead`,{children:J(`tr`,{children:[q(D,{children:`Provider`}),q(D,{$align:`right`,children:`Share`}),q(D,{$align:`right`,children:`Requests`}),q(D,{$align:`right`,children:`Failed`}),q(D,{$align:`right`,children:`Tokens`}),q(D,{$align:`right`,children:`Cost`})]})}),q(`tbody`,{children:s.map(({name:e,totals:t})=>J(T,{children:[J(E,{children:[q(H,{$color:Un(e)}),` `,Wn(e)]}),q(E,{$align:`right`,$mono:!0,children:_(d===0?0:t.requests/d,0)}),q(E,{$align:`right`,$mono:!0,children:y(t.requests)}),q(E,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:y(t.errors)}),q(E,{$align:`right`,$mono:!0,children:y(z(t))}),q(E,{$align:`right`,$mono:!0,children:v(t.costUsd)})]},e))})]})]})}var Kn=Y.li`
52
+ display: grid;
53
+ grid-template-columns: minmax(0, 20ch) 1fr auto;
54
+ align-items: center;
55
+ gap: ${({theme:e})=>e.space(2)};
56
+ `,qn=Y.ol`
57
+ display: flex;
58
+ flex-direction: column;
59
+ gap: ${({theme:e})=>e.space(2)};
60
+ `,Jn=Y.div`
61
+ height: 8px;
62
+ border-radius: 2px;
63
+ background: ${({theme:e})=>e.color.panelSunk};
64
+ border: 1px solid ${({theme:e})=>e.color.rule};
65
+ overflow: hidden;
66
+ `,Yn=Y.div`
67
+ width: ${({$share:e})=>`${Math.max(1.5,e*100)}%`};
68
+ height: 100%;
69
+ border-radius: 0 2px 2px 0;
70
+ background: ${({theme:e,$fault:t})=>t?e.color.down:e.color.accent};
71
+ opacity: 0.85;
72
+ `,Xn=Y(l)`
73
+ display: block;
74
+ font-family: ${({theme:e})=>e.font.mono};
75
+ font-size: 12px;
76
+ `,Zn=12;function Qn({buckets:e,metric:t,names:n,unknownLabel:r}){let i=new Map;for(let t of e)i.set(t.key,ct(i.get(t.key)??Ke,t));let s=e=>e===`unknown`?r??`Unattributed`:n?.get(e)??e,l=[...i.entries()].map(([e,n])=>({name:s(e),entry:n,value:t.of(B(n))})).sort((e,t)=>t.value-e.value),u=l.slice(0,Zn),d=l.slice(Zn),f=u[0]?.value??0;return J(a,{$gap:3,children:[q(qn,{children:u.map(({name:e,entry:n,value:r})=>J(Kn,{children:[q(Xn,{title:e,children:e}),q(Jn,{children:q(Yn,{$share:f===0?0:r/f,$fault:n.requests>0&&n.errors===n.requests})}),J(c,{$gap:2,children:[q(o,{$size:`12px`,children:t.format(r)}),q(o,{$size:`11px`,$dim:!0,children:v(n.costUsd)})]})]},e))}),d.length===0?null:q(o,{$size:`11px`,$dim:!0,children:`+ ${d.length} more, ${y(d.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}function $({legend:e,meta:t,actions:n,query:r,empty:i,isEmpty:a,children:o}){return q(x,{legend:e,meta:t,actions:n,children:r.isError?q(S,{error:r.error,onRetry:r.refetch}):r.isLoading?q(C,{rows:4}):a?q(w,{legend:i.legend,message:i.message}):o})}var $n=[{id:`inputTokens`,label:`Uncached input`,opacity:.95},{id:`outputTokens`,label:`Output`,opacity:.7},{id:`cacheReadTokens`,label:`Cache read`,opacity:.45},{id:`cacheWriteTokens`,label:`Cache write`,opacity:.22}];function er({buckets:e,by:t,since:n,until:r}){let i=new Map;for(let n of e)i.set(V(n.key,t),n);let s=U(n,r,t).map(e=>{let t=i.get(e);return{at:e,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,cacheReadTokens:t?.cacheReadTokens??0,cacheWriteTokens:t?.cacheWriteTokens??0}}),l=$n.map(e=>({...e,value:s.reduce((t,n)=>t+n[e.id],0)})),u=l.reduce((e,t)=>e+t.value,0);return J(a,{$gap:3,children:[q(ot,{$height:200,children:q(Pe,{width:`100%`,height:`100%`,children:J(vn,{data:s,margin:{top:4,right:4,bottom:4,left:4},children:[q(k,{stroke:`var(--rule)`,vertical:!1}),q(ye,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(ft,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>y(e)}),q(le,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:J(Me,{children:[q(`div`,{children:R(Number(r),t)}),$n.map(e=>J(`div`,{children:[e.label,` `,y(Number(n.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),$n.map(e=>q(gn,{type:`monotone`,dataKey:e.id,stackId:`tokens`,stroke:`var(--accent)`,strokeOpacity:e.opacity,strokeWidth:1.5,fill:`var(--accent)`,fillOpacity:e.opacity*.5,isAnimationActive:!1},e.id))]})})}),q(rt,{children:l.map(e=>J(c,{$gap:1,children:[q(H,{$color:`var(--accent)`,style:{opacity:e.opacity}}),q(`span`,{children:e.label}),q(o,{$size:`11px`,children:y(e.value)}),q(o,{$size:`11px`,$dim:!0,children:_(u===0?0:e.value/u,0)})]},e.id))})]})}function tr({buckets:e,by:t,since:n,until:r}){let i=new Map;for(let n of e)i.set(V(n.key,t),n);let o=U(n,r,t).map(e=>{let n=i.get(e);return{at:e,label:R(e,t),requests:n?.requests??0,errors:n?.errors??0,costUsd:n?.costUsd??0,tokens:n===void 0?0:z(n)}});return J(a,{$gap:2,children:[q(ot,{$height:220,children:q(Pe,{width:`100%`,height:`100%`,children:J(bn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[q(k,{stroke:`var(--rule)`,vertical:!1}),q(ye,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(ft,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),q(le,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t})=>{if(e!==!0||t===void 0||t.length===0)return null;let n=t[0]?.payload;return n===void 0?null:J(Me,{children:[q(`div`,{children:n.label}),J(`div`,{children:[y(n.requests),` requests`]}),J(`div`,{children:[y(n.errors),` failed`]}),J(`div`,{children:[y(n.tokens),` tokens`]}),q(`div`,{children:v(n.costUsd)})]})}}),q(gn,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),q(oe,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),q(oe,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),J(rt,{children:[J(`span`,{children:[q(H,{$color:`var(--accent)`}),` Requests`]}),J(`span`,{children:[q(H,{$color:`var(--down)`}),` Failed`]})]})]})}var nr=Y.div`
77
+ display: grid;
78
+ grid-template-columns: repeat(
79
+ auto-fit,
80
+ minmax(max(180px, calc((100% - 4 * ${({theme:e})=>e.space(3)}) / 5)), 1fr)
81
+ );
82
+ gap: ${({theme:e})=>e.space(3)};
83
+ `,rr=864e5,ir=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function ar(){let{cadence:e}=m(),[o,c]=xt(`24h`),[l,u]=xt(`tokens`),[d,f]=xt(`model`),p=De(o),x=Le(l),S=K(()=>p.grain===`daily`?ht(Date.now()-p.ms):Math.floor((Date.now()-p.ms)/6e4)*6e4,[p]),C=K(()=>S+p.ms,[S,p]),w=K(()=>ht(Date.now()-371*rr),[]),T={since:S,grain:p.grain},E=n({...T,groupBy:p.by},e(6e4)),D=n({...T,groupBy:p.by,splitBy:`provider`},e(6e4)),O=n({...T,groupBy:p.by,splitBy:`model`},e(6e4)),ee=n({...T,groupBy:p.by,splitBy:`apiKey`},e(6e4)),te=n({...T,groupBy:d},e(6e4)),k=n({...T,groupBy:`credential`},e(6e4)),ne=n({since:w,grain:`daily`,groupBy:`day`},e(3e5)),re=t(),ie=s(),A=r(),ae=K(()=>{let e=new Map;for(let t of A.data??[])for(let n of t.targets)e.set(n.model,n.provider);return e},[A.data]),j=K(()=>{let e=new Map;for(let t of re.data??[])e.set(t.id,t.label);return e},[re.data]),oe=K(()=>{let e=new Map;for(let t of ie.data??[])e.set(t.id,t.label);return e},[ie.data]),M=E.data??[],N=_e(M),P=N.inputTokens+N.cacheReadTokens+N.cacheWriteTokens,se=z(N),ce=N.requests===0?0:N.outputTokens/N.requests,le=P===0?0:N.cacheReadTokens/P,ue=P===0?0:N.cacheWriteTokens/P,de=N.requests===0?0:N.costUsd/N.requests,fe=U(S,C,p.by),F=new Map(M.map(e=>[V(e.key,p.by),e])),I=e=>fe.map(e),pe=e=>e>=.25?`down`:e>=.05?`warn`:`ok`,me=N.requests===0?0:N.errors/N.requests,L={legend:`Nothing recorded`,message:`No requests landed in this window. Widen the range, or send traffic through the gateway.`};return J(a,{$gap:4,children:[q(g,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:E.isLoading?`Reading usage…`:`${y(N.requests)} requests and ${v(N.costUsd)} over the last ${p.label}.`,actions:q(Xe,{children:ke.map(e=>q(Qe,{type:`button`,$size:`sm`,$on:e.id===o,"aria-pressed":e.id===o,onClick:()=>c(e.id),children:e.id},e.id))})}),J(nr,{"data-testid":`usage-summary-deck`,children:[q(W,{legend:`Requests`,value:y(N.requests),unit:p.label,trace:q(h,{values:I(e=>F.get(e)?.requests??0),overlay:I(e=>F.get(e)?.errors??0),label:`${N.requests} requests, ${N.errors} of them failed`})}),q(W,{legend:`Error rate`,value:_(me),unit:`${y(N.errors)} failed`,tone:N.requests===0?`ink`:pe(me),trace:q(h,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.errors/t.requests}),color:`var(--down)`,label:`${N.errors} failed requests against ${N.requests} total`})}),q(W,{legend:`Prompt input`,value:y(P),unit:`${y(N.inputTokens)} uncached`,trace:q(h,{values:I(e=>{let t=F.get(e);return(t?.inputTokens??0)+(t?.cacheReadTokens??0)+(t?.cacheWriteTokens??0)}),label:`${P} prompt input tokens over the window`})}),q(W,{legend:`Output`,value:y(N.outputTokens),unit:`mean ${y(ce)}/request`,trace:q(h,{values:I(e=>F.get(e)?.outputTokens??0),label:`${N.outputTokens} output tokens over the window`})}),q(W,{legend:`Cache reads`,value:y(N.cacheReadTokens),unit:`${_(le,0)} of prompt`,trace:q(h,{values:I(e=>F.get(e)?.cacheReadTokens??0),label:`${N.cacheReadTokens} cache-read tokens over the window`})}),q(W,{legend:`Cache writes`,value:y(N.cacheWriteTokens),unit:`${_(ue,0)} of prompt`,trace:q(h,{values:I(e=>F.get(e)?.cacheWriteTokens??0),label:`${N.cacheWriteTokens} cache-write tokens over the window`})}),q(W,{legend:`RTK saved`,value:y(N.rtkSavedTokens),unit:`${y(N.rtkAppliedRequests)} requests`,trace:q(h,{values:I(e=>F.get(e)?.rtkSavedTokens??0),label:`${N.rtkSavedTokens} estimated tokens saved by RTK over the window`})}),q(W,{legend:`Mean duration`,value:b(N.requests===0?null:N.durationMsSum/N.requests),unit:`per request`,trace:q(h,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.durationMsSum/t.requests}),color:`var(--ok)`,label:`mean request duration over the window`})}),q(W,{legend:`Spend`,value:v(N.costUsd),unit:p.label,trace:q(h,{values:I(e=>F.get(e)?.costUsd??0),color:`var(--warn)`,label:`spend over the window, ${v(N.costUsd)} total`})}),q(W,{legend:`Cost / request`,value:v(de),unit:`mean`,trace:q(h,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.costUsd/t.requests}),color:`var(--warn)`,label:`${v(de)} mean cost per request over the window`})})]}),q($,{legend:`Traffic`,meta:p.by===`hour`?`By hour`:`By day`,query:E,isEmpty:M.length===0,empty:L,children:q(tr,{buckets:M,by:p.by,since:S,until:C})}),q(Xe,{children:Be.map(e=>q(Qe,{type:`button`,$size:`sm`,$on:e.id===l,"aria-pressed":e.id===l,onClick:()=>u(e.id),children:`Rank by ${e.label.toLowerCase()}`},e.id))}),q($,{legend:`Traffic by upstream model`,meta:`${x.label}, ${p.by===`hour`?`by hour`:`by day`}`,query:O,isEmpty:(O.data??[]).length===0,empty:L,children:q(Vn,{buckets:O.data??[],by:p.by,since:S,until:C,metric:x,providers:ae})}),J(i,{$min:`480px`,$gap:4,children:[J(a,{$gap:4,children:[q($,{legend:`Providers`,meta:x.label,query:D,isEmpty:(D.data??[]).length===0,empty:L,children:q(Gn,{buckets:D.data??[],by:p.by,since:S,until:C,metric:x})}),q(Pn,{days:ne.data??[],now:Date.now()})]}),J(a,{$gap:4,children:[q($,{legend:`Token mix`,meta:y(se),query:E,isEmpty:M.length===0,empty:L,children:q(er,{buckets:M,by:p.by,since:S,until:C})}),q($,{legend:`Models`,meta:ir.find(e=>e.id===d)?.column,query:te,isEmpty:(te.data??[]).length===0,empty:L,actions:q(Xe,{children:ir.map(e=>q(Qe,{type:`button`,$size:`sm`,$on:e.id===d,"aria-pressed":e.id===d,onClick:()=>f(e.id),children:e.label},e.id))}),children:q(Qn,{buckets:te.data??[],metric:x})}),q($,{legend:`Accounts`,meta:x.label,query:k,isEmpty:(k.data??[]).length===0,empty:L,children:q(Qn,{buckets:k.data??[],metric:x,names:oe,unknownLabel:`No account`})})]})]}),q($,{legend:`API keys`,meta:x.label,query:ee,isEmpty:(ee.data??[]).length===0,empty:L,children:q(Fn,{buckets:ee.data??[],by:p.by,since:S,until:C,metric:x,names:j})})]})}var or=ar;export{or as component};
@@ -0,0 +1 @@
1
+ import*as e from"react";import{jsx as t}from"react/jsx-runtime";import*as n from"react-dom";var r=Object.defineProperty,i=(e,t)=>r(e,`name`,{value:t,configurable:!0});function a(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}i(a,`setRef`);function o(...e){return t=>{let n=!1,r=e.map(e=>{let r=a(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():a(e[t],null)}}}}i(o,`composeRefs`);function s(...t){return e.useCallback(o(...t),t)}i(s,`useComposedRefs`);var c=Object.defineProperty,l=(e,t)=>c(e,`name`,{value:t,configurable:!0});function u(t){let n=e.forwardRef((n,r)=>{let{children:i,...a}=n,o=null,c=!1,l=[];v(i)&&typeof S==`function`&&(i=S(i._payload)),e.Children.forEach(i,e=>{if(g(e)){c=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;v(n)&&typeof S==`function`&&(n=S(n._payload)),o=p(t,n),l.push(o?.props?.children)}else l.push(e)}),o?o=e.cloneElement(o,void 0,l):!c&&e.Children.count(i)===1&&e.isValidElement(i)&&(o=i);let u=o?h(o):void 0,d=s(r,u);if(!o){if(i||i===0)throw Error(c?x(t):b(t));return i}let f=m(a,o.props??{});return o.type!==e.Fragment&&(f.ref=r?d:u),e.cloneElement(o,f)});return n.displayName=`${t}.Slot`,n}l(u,`createSlot`);var d=Symbol.for(`radix.slottable`);function f(e){let t=l(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=d,t}l(f,`createSlottable`);var p=l((t,n)=>{if(`child`in t.props){let n=t.props.child;return e.isValidElement(n)?e.cloneElement(n,void 0,t.props.children(n.props.children)):null}return e.isValidElement(n)?n:null},`getSlottableElementFromSlottable`);function m(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}l(m,`mergeProps`);function h(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}l(h,`getElementRef`);function g(t){return e.isValidElement(t)&&typeof t.type==`function`&&`__radixId`in t.type&&t.type.__radixId===d}l(g,`isSlottable`);var _=Symbol.for(`react.lazy`);function v(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===_&&`_payload`in e&&y(e._payload)}l(v,`isLazyComponent`);function y(e){return typeof e==`object`&&!!e&&`then`in e}l(y,`isPromiseLike`);var b=l(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),x=l(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),S=e.use,C=Object.defineProperty,w=(e,t)=>C(e,`name`,{value:t,configurable:!0}),T=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((n,r)=>{let i=u(`Primitive.${r}`),a=e.forwardRef((e,n)=>{let{asChild:a,...o}=e,s=a?i:r;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),t(s,{...o,ref:n})});return a.displayName=`Primitive.${r}`,{...n,[r]:a}},{});function E(e,t){e&&n.flushSync(()=>e.dispatchEvent(t))}w(E,`dispatchDiscreteCustomEvent`);var D=Object.defineProperty,O=(e,t)=>D(e,`name`,{value:t,configurable:!0});function k(n,r){let i=e.createContext(r);i.displayName=n+`Context`;let a=O(n=>{let{children:r,...a}=n,o=e.useMemo(()=>a,Object.values(a));return t(i.Provider,{value:o,children:r})},`Provider`);a.displayName=n+`Provider`;function o(t,a={}){let{optional:o=!1}=a,s=e.useContext(i);if(s)return s;if(r!==void 0)return r;if(!o)throw Error(`\`${t}\` must be used within \`${n}\``)}return O(o,`useContext`),[a,o]}O(k,`createContext`);function A(n,r=[]){let i=[];function a(r,a){let o=e.createContext(a);o.displayName=r+`Context`;let s=i.length;i=[...i,a];let c=O(r=>{let{scope:i,children:a,...c}=r,l=i?.[n]?.[s]||o,u=e.useMemo(()=>c,Object.values(c));return t(l.Provider,{value:u,children:a})},`Provider`);c.displayName=r+`Provider`;function l(t,i,c={}){let{optional:l=!1}=c,u=i?.[n]?.[s]||o,d=e.useContext(u);if(d)return d;if(a!==void 0)return a;if(!l)throw Error(`\`${t}\` must be used within \`${r}\``)}return O(l,`useContext`),[c,l]}O(a,`createContext`);let o=O(()=>{let t=i.map(t=>e.createContext(t));return O(function(r){let i=r?.[n]||t;return e.useMemo(()=>({[`__scope${n}`]:{...r,[n]:i}}),[r,i])},`useScope`)},`createScope`);return o.scopeName=n,[a,j(o,...r)]}O(A,`createContextScope`);function j(...t){let n=t[0];if(t.length===1)return n;let r=O(()=>{let r=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return O(function(t){let i=r.reduce((e,{useScope:n,scopeName:r})=>{let i=n(t)[`__scope${r}`];return{...e,...i}},{});return e.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])},`useComposedScopes`)},`createScope`);return r.scopeName=n.scopeName,r}O(j,`composeContextScopes`);var M=Object.defineProperty,N=(e,t)=>M(e,`name`,{value:t,configurable:!0}),P=!!(typeof window<`u`&&window.document&&window.document.createElement);function F(e,t,{checkForDefaultPrevented:n=!0}={}){return N(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}N(F,`composeEventHandlers`);function I(e){if(!P)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}N(I,`getOwnerWindow`);function L(e){if(!P)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}N(L,`getOwnerDocument`);function R(e,t=!1){let{activeElement:n}=L(e);if(!n?.nodeName)return null;if(z(n)&&n.contentDocument)return R(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=L(n).getElementById(e);if(t)return t}}return n}N(R,`getActiveElement`);function z(e){return e.tagName===`IFRAME`}N(z,`isFrame`);var B=globalThis?.document?e.useLayoutEffect:()=>{},V=Object.defineProperty,H=(e,t)=>V(e,`name`,{value:t,configurable:!0}),U=e.useEffectEvent,W=e.useInsertionEffect;function G(t){if(typeof U==`function`)return U(t);let n=e.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof W==`function`?W(()=>{n.current=t}):B(()=>{n.current=t}),e.useMemo(()=>((...e)=>n.current?.(...e)),[])}H(G,`useEffectEvent`);var K=Object.defineProperty,q=(e,t)=>K(e,`name`,{value:t,configurable:!0}),J=e.useInsertionEffect||B;function Y({prop:t,defaultProp:n,onChange:r=q(()=>{},`onChange`),caller:i}){let[a,o,s]=X({defaultProp:n,onChange:r}),c=t!==void 0;return[c?t:a,e.useCallback(e=>{if(c){let n=Z(e)?e(t):e;n!==t&&s.current?.(n)}else o(e)},[c,t,o,s])]}q(Y,`useControllableState`);function X({defaultProp:t,onChange:n}){let[r,i]=e.useState(t),a=e.useRef(r),o=e.useRef(n);return J(()=>{o.current=n},[n]),e.useEffect(()=>{a.current!==r&&(o.current?.(r),a.current=r)},[r,a]),[r,i,o]}q(X,`useUncontrolledState`);function Z(e){return typeof e==`function`}q(Z,`isFunction`);var Q=Symbol(`RADIX:SYNC_STATE`);function $(t,n,r,i){let{prop:a,defaultProp:o,onChange:s,caller:c}=n,l=a!==void 0,u=G(s),d=[{...r,state:o}];i&&d.push(i);let[f,p]=e.useReducer((e,n)=>{if(n.type===Q)return{...e,state:n.state};let r=t(e,n);return l&&!Object.is(r.state,e.state)&&u(r.state),r},...d),m=f.state,h=e.useRef(m);e.useEffect(()=>{h.current!==m&&(h.current=m,l||u(m))},[m,h,l]);let g=e.useMemo(()=>a===void 0?f:{...f,state:a},[f,a]);return e.useEffect(()=>{l&&!Object.is(a,f.state)&&p({type:Q,state:a})},[a,f.state,l]),[g,p]}q($,`useControllableStateReducer`);export{T as a,s as c,A as i,B as n,E as o,F as r,u as s,Y as t};