omnigateway 0.4.13 → 0.5.1

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 (58) hide show
  1. package/README.md +52 -1
  2. package/bin/omni.js +6970 -6733
  3. package/gateway.js +9440 -8038
  4. package/package.json +1 -1
  5. package/public/assets/{CopyValue-C2DkO9Yz.js → CopyValue-DNNJGDI5.js} +5 -5
  6. package/public/assets/{Field-B79Yxdit.js → Field-B2rnk3JM.js} +1 -1
  7. package/public/assets/{Match-BWa6L0L1.js → Match-CvkEmOIG.js} +1 -1
  8. package/public/assets/{Panel-CoulMx6R.js → Panel-BeQOQoap.js} +2 -2
  9. package/public/assets/Rack-DdhpgQWD.js +316 -0
  10. package/public/assets/{Readout-D1XEfywe.js → Readout-CZfn5JDy.js} +1 -1
  11. package/public/assets/RequestTable-I1TrD689.js +11 -0
  12. package/public/assets/States-2kaQxx-s.js +54 -0
  13. package/public/assets/SummaryDeck-BisdRswW.js +15 -0
  14. package/public/assets/{Toggle-CRrH9nDt.js → Toggle-BvOELhpy.js} +1 -1
  15. package/public/assets/{TokenBreakdown-C2NsJnqO.js → TokenBreakdown-En1JT4tT.js} +1 -1
  16. package/public/assets/WindowChart-Bvbkz9rt.js +11 -0
  17. package/public/assets/_app-a3VUev6k.js +1 -0
  18. package/public/assets/_app.accounts-CYPB-7Xt.js +59 -0
  19. package/public/assets/_app.console-C4x5F3d0.js +44 -0
  20. package/public/assets/_app.database-B-9oB52r.js +24 -0
  21. package/public/assets/_app.index-NBeanmyf.js +62 -0
  22. package/public/assets/_app.keys-DK9jdOqT.js +82 -0
  23. package/public/assets/_app.logs-Dr6fApsE.js +58 -0
  24. package/public/assets/_app.models-CGBQ2QaS.js +148 -0
  25. package/public/assets/_app.plugins._pluginId-DXzhupNH.js +20 -0
  26. package/public/assets/_app.settings-zTFRyxhZ.js +58 -0
  27. package/public/assets/_app.usage-BCCimHY0.js +76 -0
  28. package/public/assets/chevron-right-mGs1is3r.js +1 -0
  29. package/public/assets/client-CQGHWD56.js +39 -0
  30. package/public/assets/index-C3LoGDKu.js +178 -0
  31. package/public/assets/login-bJoYdBqx.js +45 -0
  32. package/public/assets/plus-Bqi8Y2Xd.js +1 -0
  33. package/public/assets/queries-GAue98pY.js +145 -0
  34. package/public/assets/reasons-Du1OBWAM.js +1 -0
  35. package/public/assets/shared-DQOWYTp3.js +77 -0
  36. package/public/assets/stream-Bu-m1Z1Y.js +1 -0
  37. package/public/assets/{trash-2-DwMK-JrZ.js → trash-2-BDA1rQVQ.js} +1 -1
  38. package/public/index.html +3 -3
  39. package/public/shared/dashboard-sdk.js +1 -1
  40. package/public/assets/Rack-HM36SprU.js +0 -314
  41. package/public/assets/States-DtkkMzEu.js +0 -54
  42. package/public/assets/_app-DVpIsUid.js +0 -1
  43. package/public/assets/_app.accounts-64d_cxir.js +0 -64
  44. package/public/assets/_app.console-BBuBmLRI.js +0 -44
  45. package/public/assets/_app.database-J9Ujio8l.js +0 -24
  46. package/public/assets/_app.index-BX4yKEXO.js +0 -62
  47. package/public/assets/_app.keys-2sKwhZJc.js +0 -76
  48. package/public/assets/_app.logs-DuHXYrZU.js +0 -68
  49. package/public/assets/_app.models-B0kTfPtn.js +0 -148
  50. package/public/assets/_app.plugins._pluginId-BOXRBToU.js +0 -20
  51. package/public/assets/_app.settings-DoaOUmc1.js +0 -46
  52. package/public/assets/_app.usage-B5sxB40E.js +0 -83
  53. package/public/assets/index-iCfSaRSG.js +0 -178
  54. package/public/assets/login-B9CJqU--.js +0 -36
  55. package/public/assets/plus-DKapAGoR.js +0 -1
  56. package/public/assets/queries-CX9mStps.js +0 -145
  57. package/public/assets/reasons-Cb8yF4Oy.js +0 -1
  58. package/public/assets/shared-Cct_4xwp.js +0 -84
@@ -0,0 +1,148 @@
1
+ import{C as e,E as t,F as n,H as r,J as i,O as a,ct as o,dt as s,ht as c,lt as l,mt as u,pt as d,vt as f,yt as p}from"./queries-GAue98pY.js";import{r as m}from"./index-C3LoGDKu.js";import{_ as h,s as g,t as _}from"./Rack-DdhpgQWD.js";import{t as v}from"./plus-Bqi8Y2Xd.js";import{t as y}from"./trash-2-BDA1rQVQ.js";import{t as b}from"./Toggle-BvOELhpy.js";import{A as x,i as S,n as C,r as w,t as T}from"./States-2kaQxx-s.js";import{n as E,t as D}from"./Chip-BltJSw8A.js";import{i as O,n as k,r as A,t as ee}from"./Field-B2rnk3JM.js";import{t as j}from"./Meter-stpt3vQu.js";import{t as M}from"./Panel-BeQOQoap.js";import{i as te,n as ne,r as re,t as N}from"./catalog-BBKm8Ih8.js";import{useEffect as P,useId as ie,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 ae=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`}]]),oe=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`}]]),se=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ce={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`},le=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
+ `,ue=z(l)`
9
+ width: 22px;
10
+ color: ${({theme:e})=>e.color.inkFaint};
11
+ flex: none;
12
+ `,de=z(D)`
13
+ border-color: ${({theme:e})=>e.color.ok};
14
+ color: ${({theme:e})=>e.color.ok};
15
+ background: ${({theme:e})=>e.color.okWash};
16
+ `,fe=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
+ `,pe=z.div`
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 3px;
26
+ min-width: 0;
27
+ `,me=z.div`
28
+ display: flex;
29
+ align-items: baseline;
30
+ justify-content: space-between;
31
+ gap: 6px;
32
+ `,he=z.li`
33
+ display: flex;
34
+ align-items: center;
35
+ gap: ${({theme:e})=>e.space(2)};
36
+ padding: 5px 0;
37
+ `,ge=z(s)`
38
+ gap: ${({theme:e})=>e.space(3)};
39
+ flex-wrap: wrap;
40
+ `,B=z.label`
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 6px;
44
+ cursor: pointer;
45
+ font-size: 12.5px;
46
+ `,_e=z.p`
47
+ font-size: 12px;
48
+ color: ${({theme:e})=>e.color.down};
49
+ `;function ve(e,t,n){return(e[t]??0)*n[t]}function ye({modelId:e}){let[t,n]=F({tools:!1,images:!1,reasoning:!1}),[r,p]=F(null),[m,h]=F(null),g=i(),_=a(),v=g.data?.weights,y=()=>{e!==null&&(h(null),_.mutate({modelId:e,need:t},{onSuccess:e=>p(e),onError:e=>{p(null),h(S(e))}}))},x=new Map(se.map(e=>[e,Math.max(1e-4,...(r?.candidates??[]).map(t=>v===void 0?0:Math.abs(ve(t.reasons,e,v))))]));return L(M,{legend:`Explain`,meta:e??`no model selected`,actions:R(f,{type:`button`,$size:`sm`,$variant:`primary`,disabled:e===null||_.isPending,onClick:y,children:[L(ae,{}),_.isPending?`Ranking…`:`Rank candidates`]}),children:R(u,{$gap:3,children:[R(u,{$gap:1,children:[L(o,{children:`Pretend the request needs`}),R(ge,{children:[R(B,{children:[L(b,{checked:t.tools,label:`Probe request uses tools`,onCheckedChange:e=>n({...t,tools:e})}),`Tools`]}),R(B,{children:[L(b,{checked:t.images,label:`Probe request includes an image`,onCheckedChange:e=>n({...t,images:e})}),`Images`]}),R(B,{children:[L(b,{checked:t.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>n({...t,reasoning:e})}),`Reasoning`]})]})]}),m===null?null:L(_e,{children:m}),r===null?L(T,{legend:`Not ranked yet`,message:e===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(u,{$gap:3,children:[R(s,{$gap:2,$wrap:!0,children:[L(D,{$tone:`accent`,children:r.strategy}),r.deterministic?null:L(D,{$tone:`warn`,children:`order varies per request`}),L(d,{}),R(o,{children:[r.candidates.length,` eligible · `,r.excluded.length,` filtered out`]})]}),r.candidates.length===0?L(T,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):L(`ul`,{children:r.candidates.map((e,t)=>R(le,{children:[R(s,{$gap:2,children:[L(ue,{children:t+1}),L(E,{provider:e.provider}),L(c,{style:{maxWidth:`22ch`},children:e.credentialLabel}),L(l,{$dim:!0,children:e.model}),R(D,{children:[`tier `,e.tier]}),L(d,{}),t===0?L(de,{children:`would be used`}):null,L(l,{children:e.score.toFixed(2)})]}),v===void 0?null:L(fe,{children:se.map(t=>{let n=ve(e.reasons,t,v),r=x.get(t)??1;return R(pe,{title:ce[t],children:[R(me,{children:[L(o,{children:t}),L(l,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),L(j,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${t} contributes ${n.toFixed(2)} of ${e.score.toFixed(2)}`})]},t)})})]},`${e.credentialId}:${e.model}`))}),r.excluded.length===0?null:R(u,{$gap:1,children:[L(o,{children:`Filtered out`}),L(`ul`,{children:r.excluded.map(e=>R(he,{children:[L(l,{$dim:!0,children:e.model}),L(l,{$dim:!0,children:e.credentialId}),L(d,{}),L(D,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}var V=[{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.`}],H=0;function U(){return H+=1,`target-${H}`}function W(e,t){let n=te(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 be(e,t){let n=ne(e,t);return n===null?null:{contextWindow:String(n.contextWindow),maxOutputTokens:String(n.maxOutputTokens)}}var xe={oauth:`OAuth`,apiKey:`an API key`};function G(e){return e.map(e=>xe[e]).join(` or `)}function Se(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 K(e,t,n){let r=n[e];return r===void 0||r.length===0||re(e,t).some(e=>r.includes(e))}function Ce(e,t){return N[e].models.filter(n=>K(e,n.id,t))}function we(e,t,n){if(t.trim().length===0||K(e,t,n))return null;let r=n[e]??[];return`${e} serves this model to ${G(re(e,t))} only, and every ${e} account here is ${G(r)}. Requests routed here will fail.`}function q(e,t){let n={provider:e.provider,endpointId:e.endpointId};return t.filter(e=>x(n,e)).map(e=>({id:e.id,label:e.accountEmail??e.label}))}function Te(e,t,n){return e.length===0||n.length===0||q(t,n).some(t=>t.id===e)?null:`No connected account has this id. Requests routed here will fail rather than falling back to another account.`}function Ee(e,t){return{...e,endpointId:t,...t===e.endpointId?{}:{credentialId:``}}}function De(e,t){return{...e,...t,...W(t.provider,t.model)??{},...t.provider===e.provider?{}:{credentialId:``},contextWindow:``,maxOutputTokens:``}}function J(e=`anthropic`){let t=N[e].defaultModel,n=W(e,t);return{key:U(),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:``,credentialId:``,tools:!0,images:!0,reasoning:!0}}function Y(){return{id:``,strategy:`score`,isAlias:!1,targets:[J()]}}function X(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:U(),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),credentialId:e.credentialId??``,tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function Oe(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(),a=r.credentialId.trim();if(r.provider===`custom`&&i.length===0)return{ok:!1,problem:`${e} needs a custom endpoint.`};let o=r.model.trim();if(o.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let s=Number(r.tier);if(!Number.isInteger(s)||s<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let c=Number(r.weight);if(!Number.isFinite(c)||c<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let l=Number(r.costInput),u=Number(r.costOutput);if(!Number.isFinite(l)||l<0||!Number.isFinite(u)||u<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let d=r.costCacheRead.trim().length>0,f=Number(r.costCacheRead);if(d&&(!Number.isFinite(f)||f<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let p=r.costCacheWrite5m.trim().length>0,m=Number(r.costCacheWrite5m);if(p&&(!Number.isFinite(m)||m<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let h=r.costCacheWrite1h.trim().length>0,g=Number(r.costCacheWrite1h);if(h&&(!Number.isFinite(g)||g<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let _=r.contextWindow.trim().length>0,v=Number(r.contextWindow);if(_&&(!Number.isInteger(v)||v<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let y=r.maxOutputTokens.trim().length>0,b=Number(r.maxOutputTokens);if(y&&(!Number.isInteger(b)||b<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:o,tier:s,weight:c,costPerMTok:{input:l,output:u,...d?{cacheRead:f}:{},...p?{cacheWrite5m:m}:{},...h?{cacheWrite1h:g}:{}},..._?{contextWindow:v}:{},...y?{maxOutputTokens:b}:{},...a.length>0?{credentialId:a}:{},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 ke=Object.keys(N),Ae=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
+ `,je=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
+ `,Me=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
+ `,Ne=z(s)`
80
+ gap: ${({theme:e})=>e.space(3)};
81
+ flex-wrap: wrap;
82
+ `,Pe=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 Fe({target:e,index:t,onChange:n,onRemove:r,removable:i,endpoints:a,held:c,credentials:l}){let h=ie(),g=N[e.provider],_=Ce(e.provider,c),v=we(e.provider,e.model,c),x=q(e,l),S=Te(e.credentialId,e,l),C=(t,r)=>{n({...e,[t]:r})},w=W(e.provider,e.model),T=be(e.provider,e.model),E=t=>{n(De(e,t))};return R(Ae,{$provider:e.provider,children:[R(s,{$gap:2,children:[R(o,{as:`legend`,children:[`Target `,t+1]}),L(d,{}),L(p,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!i,"aria-label":`Remove target ${t+1}`,title:i?`Remove target ${t+1}`:`A model needs at least one target`,onClick:r,children:L(y,{})})]}),R(je,{children:[R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-provider`,children:`Provider`}),L(O,{id:`${h}-provider`,value:e.provider,onChange:t=>{let n=t.target.value,r=N[n].models.some(t=>t.id===e.model);E({provider:n,model:r?e.model:N[n].defaultModel})},children:ke.map(e=>L(`option`,{value:e,children:m[e]},e))})]}),e.provider===`custom`?R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-endpoint`,children:`Endpoint`}),R(O,{id:`${h}-endpoint`,value:e.endpointId,onChange:t=>n(Ee(e,t.target.value)),children:[L(`option`,{value:``,children:`Choose endpoint`}),a.map(e=>L(`option`,{value:e.id,children:e.label},e.id))]})]}):null,R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-model`,children:`Provider model`}),L(k,{id:`${h}-model`,list:`${h}-catalog`,value:e.model,placeholder:g.defaultModel,onChange:t=>E({provider:e.provider,model:t.target.value})}),L(`datalist`,{id:`${h}-catalog`,children:_.map(e=>L(`option`,{value:e.id,children:e.label},e.id))}),v===null?null:L(Pe,{role:`note`,children:v})]}),R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-tier`,children:`Tier`}),L(A,{id:`${h}-tier`,min:1,step:1,value:e.tier,onChange:e=>C(`tier`,e.target.value)})]}),R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-weight`,children:`Weight`}),L(A,{id:`${h}-weight`,min:0,step:.1,value:e.weight,onChange:e=>C(`weight`,e.target.value)})]})]}),L(u,{$gap:1,children:R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-account`,children:`Account`}),R(O,{id:`${h}-account`,value:e.credentialId,onChange:e=>C(`credentialId`,e.target.value),children:[L(`option`,{value:``,children:`Any account`}),x.map(e=>L(`option`,{value:e.id,children:e.label},e.id)),S===null?null:R(`option`,{value:e.credentialId,children:[e.credentialId,` (removed)`]})]}),S===null?null:L(Pe,{role:`note`,children:S})]})}),R(u,{$gap:1,children:[R(s,{$gap:2,children:[L(o,{children:`Price per million tokens`}),L(d,{}),w===null?L(o,{as:`span`,children:`not in the catalog — price it yourself`}):R(f,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:e.costInput===w.costInput&&e.costOutput===w.costOutput&&e.costCacheRead===w.costCacheRead&&e.costCacheWrite5m===w.costCacheWrite5m&&e.costCacheWrite1h===w.costCacheWrite1h,onClick:()=>n({...e,...w}),children:[L(oe,{}),`Use list price`]})]}),R(Me,{children:[R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-in`,children:`Input`}),L(A,{id:`${h}-in`,min:0,step:.01,value:e.costInput,onChange:e=>C(`costInput`,e.target.value)})]}),R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-out`,children:`Output`}),L(A,{id:`${h}-out`,min:0,step:.01,value:e.costOutput,onChange:e=>C(`costOutput`,e.target.value)})]}),R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-cache`,children:`Cache read`}),L(A,{id:`${h}-cache`,min:0,step:.01,placeholder:`same as input`,value:e.costCacheRead,onChange:e=>C(`costCacheRead`,e.target.value)})]}),R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-write5m`,children:`Cache write 5m`}),L(A,{id:`${h}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:e.costCacheWrite5m,onChange:e=>C(`costCacheWrite5m`,e.target.value)})]}),R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-write1h`,children:`Cache write 1h`}),L(A,{id:`${h}-write1h`,min:0,step:.01,placeholder:`2x input`,value:e.costCacheWrite1h,onChange:e=>C(`costCacheWrite1h`,e.target.value)})]})]})]}),R(u,{$gap:1,children:[R(s,{$gap:2,children:[L(o,{children:`Token limits`}),L(d,{}),T===null?L(o,{as:`span`,children:`not in the catalog — state them yourself`}):L(o,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),R(Me,{children:[R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-context`,children:`Context window`}),L(A,{id:`${h}-context`,min:1,step:1024,placeholder:T?.contextWindow??`published`,value:e.contextWindow,onChange:e=>C(`contextWindow`,e.target.value)})]}),R(Z,{children:[L(o,{as:`label`,htmlFor:`${h}-maxout`,children:`Max output`}),L(A,{id:`${h}-maxout`,min:1,step:1024,placeholder:T?.maxOutputTokens??`published`,value:e.maxOutputTokens,onChange:e=>C(`maxOutputTokens`,e.target.value)})]})]})]}),R(u,{$gap:1,children:[L(o,{children:`Capabilities`}),R(Ne,{children:[R(Q,{children:[L(b,{checked:e.tools,label:`Target ${t+1} supports tools`,onCheckedChange:e=>C(`tools`,e)}),`Tools`]}),R(Q,{children:[L(b,{checked:e.images,label:`Target ${t+1} supports images`,onCheckedChange:e=>C(`images`,e)}),`Images`]}),R(Q,{children:[L(b,{checked:e.reasoning,label:`Target ${t+1} supports reasoning`,onCheckedChange:e=>C(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Ie=z.p`
92
+ font-size: 11.5px;
93
+ color: ${({theme:e})=>e.color.inkDim};
94
+ `,Le=z.p`
95
+ font-size: 12px;
96
+ color: ${({theme:e})=>e.color.down};
97
+ `,Re=z.p`
98
+ font-size: 12px;
99
+ color: ${({theme:e})=>e.color.ok};
100
+ `,ze=z(s)`
101
+ gap: 8px;
102
+ `;function Be({model:n,onSaved:i,onDeleted:a}){let[c,l]=F(()=>n===null?Y():X(n)),[p,m]=F(null),[h,_]=F(!1),[y,x]=F(!1),C=r(),w=t(),T=e(),E=Se(T.data??[]),D=(T.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),A=n?.id??null;P(()=>{l(n===null?Y():X(n)),m(null),_(!1)},[A]);let j=V.find(e=>e.id===c.strategy);return R(I,{children:[L(M,{legend:n===null?`New model`:`Edit model`,meta:n===null?void 0:n.id,actions:R(I,{children:[n===null?null:L(f,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>x(!0),children:`Delete`}),L(f,{type:`button`,$variant:`primary`,$size:`sm`,disabled:C.isPending,onClick:()=>{_(!1);let e=Oe(c);if(!e.ok){m(e.problem);return}m(null),C.mutate(e.model,{onSuccess:()=>{_(!0),i(e.model.id)},onError:e=>m(S(e))})},children:C.isPending?`Saving…`:n===null?`Create model`:`Save changes`})]}),children:R(u,{$gap:3,children:[L(ee,{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(k,{...e,value:c.id,disabled:n!==null,placeholder:`fast`,onChange:e=>l({...c,id:e.target.value})})}),L(ee,{label:`Routing strategy`,children:e=>L(O,{...e,value:c.strategy,onChange:e=>l({...c,strategy:e.target.value}),children:V.map(e=>L(`option`,{value:e.id,children:e.label},e.id))})}),j===void 0?null:L(Ie,{children:j.blurb}),R(ze,{children:[L(b,{checked:c.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>l({...c,isAlias:e})}),R(u,{$gap:0,children:[L(o,{as:`span`,children:`Alias`}),L(Ie,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),R(u,{$gap:2,children:[R(s,{children:[L(o,{children:`Targets`}),L(d,{}),R(f,{type:`button`,$size:`sm`,onClick:()=>l({...c,targets:[...c.targets,J(c.targets.at(-1)?.provider??`anthropic`)]}),children:[L(v,{}),`Add target`]})]}),c.targets.map((e,t)=>L(Fe,{target:e,index:t,removable:c.targets.length>1,endpoints:D,held:E,credentials:T.data??[],onChange:t=>l({...c,targets:c.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>l({...c,targets:c.targets.filter(t=>t.key!==e.key)})},e.key))]}),p===null?null:L(Le,{role:`alert`,children:p}),h&&p===null?L(Re,{role:`status`,children:`Saved.`}):null]})}),L(g,{open:y,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:w.isPending,onConfirm:()=>{n!==null&&w.mutate(n.id,{onSuccess:()=>{x(!1),a()},onError:e=>{x(!1),m(S(e))}})}})]})}var Ve=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
+ `,He=z(u)`
112
+ gap: ${({theme:e})=>e.space(4)};
113
+ min-width: 0;
114
+ `,Ue=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
+ `,We=z(c)`
136
+ font-family: ${({theme:e})=>e.font.mono};
137
+ font-size: 12.5px;
138
+ display: block;
139
+ max-width: 100%;
140
+ `,Ge=z.div`
141
+ display: flex;
142
+ gap: 2px;
143
+ `,Ke=z.span`
144
+ width: 12px;
145
+ height: 3px;
146
+ border-radius: 1px;
147
+ background: ${({$provider:e})=>`var(--p-${e})`};
148
+ `,$=`\0new`;function qe(){let e=n(),[t,r]=F(null),i=e.data??[],a=t===$?null:i.find(e=>e.id===t)??null,c=t===$||t===null&&!e.isLoading&&i.length===0;P(()=>{t===null&&i.length!==0&&r(i[0]?.id??null)},[i,t]);let u=e.isLoading?`Reading configured models…`:i.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${i.length} model${i.length===1?``:`s`} routing to ${i.reduce((e,t)=>e+t.targets.length,0)} targets.`;return R(I,{children:[L(_,{legend:`Models`,title:`Virtual models`,summary:u,actions:R(f,{type:`button`,$variant:`primary`,onClick:()=>r($),children:[L(v,{}),`New model`]})}),R(Ve,{children:[L(M,{legend:`Configured`,meta:`${i.length}`,flush:!0,children:e.isError?L(C,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?L(`div`,{style:{padding:12},children:L(w,{rows:4})}):i.length===0?L(T,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:L(f,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>r($),children:`New model`})}):L(`div`,{children:i.map(e=>{let n=[...new Set(e.targets.map(e=>e.provider))];return R(Ue,{type:`button`,$selected:e.id===t,"aria-pressed":e.id===t,onClick:()=>r(e.id),children:[R(s,{$gap:2,style:{width:`100%`},children:[L(We,{title:e.id,children:e.id}),L(d,{}),e.isAlias?L(D,{children:`alias`}):null]}),R(s,{$gap:2,style:{width:`100%`},children:[L(Ge,{children:n.map(e=>L(Ke,{$provider:e,title:e},e))}),L(o,{children:e.strategy}),L(d,{}),R(l,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),R(He,{children:[a===null&&!c?L(M,{legend:`Editor`,children:e.isLoading?L(w,{rows:5}):L(T,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):L(Be,{model:a,onSaved:t=>{r(t),e.refetch()},onDeleted:()=>{r(null),e.refetch()}}),L(ye,{modelId:a?.id??null})]})]})]})}var Je=qe;export{Je as component};
@@ -0,0 +1,20 @@
1
+ import{I as e,at as t,it as n,mt as r,ot as i,rt as a}from"./queries-GAue98pY.js";import{a as o,s}from"./index-C3LoGDKu.js";import{t as c}from"./Rack-DdhpgQWD.js";import{n as l,r as u,t as d}from"./States-2kaQxx-s.js";import{t as f}from"./Panel-BeQOQoap.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";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(e){let r=w.get(e);if(r!==void 0)return r;let o={get:(t,r)=>n(C(e,t),r),post:(n,r)=>t(C(e,n),r),put:(t,n)=>i(C(e,t),n),del:t=>a(C(e,t))};return w.set(e,o),o}var E=h(e=>s(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(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 k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
2
+ font-size: 13px;
3
+ color: ${({theme:e})=>e.color.down};
4
+ `,j=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
+ `,M=S.p`
10
+ font-size: 12px;
11
+ color: ${({theme:e})=>e.color.inkDim};
12
+ max-width: 68ch;
13
+ `;function N(e){return e instanceof Error?e.message:typeof e==`string`?e:`The plugin threw a value that is not an error.`}var P=class extends p{state={message:null};static getDerivedStateFromError(e){return{message:N(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(f,{legend:`Plugin failed`,meta:this.props.pluginId,children:x(r,{$gap:2,children:[x(A,{children:[this.props.pluginName,` stopped rendering.`]}),b(j,{children:e}),b(M,{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.`})]})})}},F=S.p`
14
+ font-size: 13px;
15
+ color: ${({theme:e})=>e.color.warn};
16
+ `,I=S.p`
17
+ font-size: 12px;
18
+ color: ${({theme:e})=>e.color.inkDim};
19
+ max-width: 68ch;
20
+ `;function L({pluginId:t}){let n=e(),i=D(),a=n.data?.find(e=>e.id===t),o=a?.ui??null,s=o?.compatible===!0?o.entry:null,p=v(()=>s===null?null:k(t,s,i),[t,s,i]);if(n.isError)return x(y,{children:[b(c,{legend:`Plugin`,title:`Plugins`,summary:`The installed plugins are unknown.`}),b(l,{legend:`Plugins unavailable`,error:n.error})]});if(a===void 0)return x(y,{children:[b(c,{legend:`Plugin`,title:n.isPending?`Loading…`:t,summary:n.isPending?`Reading the installed plugins.`:`This gateway does not run a plugin with that id.`}),n.isPending?b(u,{}):b(d,{legend:`Not installed`,message:`No plugin with the id ${t} is installed. Install it and restart the gateway.`})]});let h=b(c,{legend:`Plugin`,title:a.nav?.label??a.name,summary:`${a.name} ${a.version}, installed as ${a.id}.`});return o===null?x(y,{children:[h,b(d,{legend:`No interface`,message:`${a.name} runs entirely in the gateway and has no console screen.`})]}):p===null?x(y,{children:[h,b(f,{legend:`Interface unavailable`,meta:a.id,children:x(r,{$gap:2,children:[b(F,{children:o.reason??`This plugin's interface does not match this gateway.`}),b(I,{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(P,{pluginId:a.id,pluginName:a.name,children:b(m,{fallback:b(u,{}),children:b(p,{})})})]})}function R(){let{pluginId:e}=o.useParams();return b(L,{pluginId:e})}export{R as component};
@@ -0,0 +1,58 @@
1
+ import{F as e,J as t,Q as n,W as r,c as i,ct as a,dt as o,l as s,lt as c,mt as l,o as u,pt as d,q as f,vt as p}from"./queries-GAue98pY.js";import{t as m}from"./Rack-DdhpgQWD.js";import{t as h}from"./Toggle-BvOELhpy.js";import{i as g,n as _,r as v}from"./States-2kaQxx-s.js";import{i as y,n as b,t as x}from"./Field-B2rnk3JM.js";import{t as S}from"./Meter-stpt3vQu.js";import{t as C}from"./Panel-BeQOQoap.js";import{n as w}from"./reasons-Du1OBWAM.js";import{useEffect as T,useState as E}from"react";import{Fragment as D,jsx as O,jsxs as k}from"react/jsx-runtime";import A from"styled-components";var j=12,M=A.p`
2
+ font-size: 12px;
3
+ color: ${({theme:e})=>e.color.inkDim};
4
+ max-width: 62ch;
5
+ `,N=A.p`
6
+ font-size: 12px;
7
+ color: ${({theme:e})=>e.color.down};
8
+ `,P=A.p`
9
+ font-size: 12px;
10
+ color: ${({theme:e})=>e.color.ok};
11
+ `,F=A(b)`
12
+ width: 260px;
13
+ `;function I(){let e=s(),[t,n]=E(``),[r,i]=E(``),[a,c]=E(``),[u,d]=E(null);return k(l,{$gap:2,children:[O(M,{children:`Changing this signs every session out, including this one, and you will be asked to sign in again with the new password.`}),k(o,{$gap:2,$wrap:!0,$align:`end`,children:[O(x,{label:`Current password`,children:e=>O(F,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),O(x,{label:`New password`,hint:`At least ${j} characters.`,children:e=>O(F,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),O(x,{label:`Repeat new password`,children:e=>O(F,{...e,type:`password`,autoComplete:`new-password`,value:a,onChange:e=>c(e.target.value)})}),O(p,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<j){d(`A password must be at least ${j} characters.`);return}if(r!==a){d(`The two new passwords do not match.`);return}d(null),e.mutate({current:t,password:r},{onSuccess:()=>w(`password-changed`),onError:e=>d(g(e))})},disabled:e.isPending||t.length===0||r.length===0,children:`Change password`})]}),u===null?null:O(N,{role:`alert`,children:u})]})}function L(){let e=n(),t=f(),[r,i]=E(``),[a,s]=E(null),[c,u]=E(null),d=e.data?.viewerConfigured===!0;return k(l,{$gap:2,children:[k(M,{children:[`A second password that signs in to a read-only console: every screen the operator sees, without mutations, snapshot downloads, or request bodies. Hand it to someone who needs to watch this gateway without being able to change it.`,` `,e.isPending?`Reading whether one is set…`:d?`One is set. Entering a new one replaces it; withdrawing it ends any read-only session immediately.`:`None is set, so nobody can sign in read-only. There is no default password.`]}),k(o,{$gap:2,$wrap:!0,$align:`end`,children:[O(x,{label:d?`Replace read-only password`:`Set read-only password`,hint:`At least ${j} characters.`,children:e=>O(F,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),O(p,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<j){s(`A password must be at least ${j} characters.`);return}s(null),t.mutate(r,{onSuccess:()=>{i(``),u(d?`Read-only password replaced.`:`Read-only access granted.`)},onError:e=>s(g(e))})},disabled:t.isPending||r.length===0,children:d?`Replace`:`Set`}),d?O(p,{type:`button`,$variant:`danger`,onClick:()=>{s(null),t.mutate(null,{onSuccess:()=>u(`Read-only access withdrawn.`),onError:e=>s(g(e))})},disabled:t.isPending,children:`Withdraw access`}):null]}),a===null?null:O(N,{role:`alert`,children:a}),c===null||a!==null?null:O(P,{role:`status`,children:c})]})}function R(){return O(C,{legend:`Access`,children:k(l,{$gap:4,children:[O(I,{}),O(L,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],B=A(c)`
14
+ display: block;
15
+ white-space: pre;
16
+ overflow-x: auto;
17
+ padding: 0.75rem;
18
+ background: ${({theme:e})=>e.color.panelSunk};
19
+ border: 1px solid ${({theme:e})=>e.color.rule};
20
+ border-radius: 4px;
21
+ font-size: 0.8125rem;
22
+ line-height: 1.5;
23
+ `,V=A.div`
24
+ color: ${({theme:e})=>e.color.inkDim};
25
+ font-size: 0.8125rem;
26
+ margin-bottom: 0.25rem;
27
+ `,H=A.p`
28
+ color: ${({theme:e})=>e.color.inkDim};
29
+ font-size: 0.8125rem;
30
+ margin: 0;
31
+ `,U=A.div`
32
+ display: grid;
33
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
34
+ gap: ${({theme:e})=>e.space(2)};
35
+ `,W=[{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 G(){let[t,n]=E(`claude`),[r,i]=E(()=>({claude:{},opencode:{}})),a=e(),s=r[t],d=typeof s.defaultModel==`string`&&s.defaultModel!==``?s:void 0,f=u(t,d),m=z.find(e=>e.id===t);return O(C,{legend:`Agent setup`,children:k(l,{children:[O(o,{children:z.map(e=>O(p,{type:`button`,$variant:e.id===t?`primary`:`ghost`,onClick:()=>n(e.id),children:e.label},e.id))}),k(H,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,k(c,{children:[`omni setup `,t]}),` to write these files directly.`]}),(a.data?.length??0)>0?O(U,{children:W.map(e=>O(x,{label:e.label,children:n=>k(y,{...n,value:s[e.key]??``,onChange:n=>i(r=>({...r,[t]:{...r[t],[e.key]:n.target.value||void 0}})),children:[O(`option`,{value:``,children:e.required?`Choose a pool`:`Not mapped`}),a.data?.map(e=>O(`option`,{value:e.id,children:e.id},e.id))]})},e.key))}):null,a.isLoading?O(v,{rows:2}):f.isError?O(_,{error:f.error,onRetry:()=>void f.refetch()}):f.isLoading?O(v,{rows:4}):(a.data?.length??0)===0?O(H,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d===void 0?k(H,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):f.data===void 0||f.data.length===0?O(H,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):f.data.map(e=>k(`div`,{children:[O(V,{children:e.path}),O(B,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),f.isError?O(H,{children:g(f.error)}):null]})})}var K=[{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.`}],q=[{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}],J=A.div`
36
+ display: grid;
37
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
38
+ gap: ${({theme:e})=>e.space(3)};
39
+ `,Y=A(l)`
40
+ gap: 6px;
41
+ `,X=A.p`
42
+ font-size: 11px;
43
+ color: ${({theme:e})=>e.color.inkDim};
44
+ `,Z=A.p`
45
+ font-size: 12px;
46
+ color: ${({theme:e})=>e.color.down};
47
+ `,Q=A.p`
48
+ font-size: 12px;
49
+ color: ${({theme:e})=>e.color.ok};
50
+ `,$=A.p`
51
+ font-size: 12px;
52
+ color: ${({theme:e})=>e.color.warn};
53
+ max-width: 72ch;
54
+
55
+ code {
56
+ font-family: ${({theme:e})=>e.font.mono};
57
+ }
58
+ `;function ee(e){let t={};for(let n of K)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of q)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function te(e){let t={};for(let n of K){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 q){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`,autoCacheEnabled:e.autoCacheEnabled===`true`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function ne(){let e=t(),n=i(),s=r(),[u,f]=E({}),[y,w]=E(null),[A,j]=E(!1);T(()=>{e.data!==void 0&&f(ee(e.data))},[e.data]);let M=Math.max(1e-4,...K.map(e=>Math.abs(Number(u[`w.${e.id}`])||0)));return k(D,{children:[O(m,{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:O(p,{type:`button`,$variant:`primary`,disabled:s.isPending||e.isLoading,onClick:()=>{j(!1);let e=te(u);if(!e.ok){w(e.problem);return}w(null),s.mutate(e.settings,{onSuccess:()=>j(!0),onError:e=>w(g(e))})},children:s.isPending?`Saving…`:`Save changes`})}),e.isError?O(C,{legend:`Settings`,children:O(_,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?O(C,{legend:`Settings`,children:O(v,{rows:6})}):k(l,{$gap:4,children:[O(C,{legend:`Scoring weights`,meta:`relative to each other`,footer:k(o,{children:[O(a,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),O(d,{})]}),children:O(J,{children:K.map(e=>{let t=Number(u[`w.${e.id}`])||0;return k(Y,{children:[O(x,{label:e.label,children:t=>O(b,{...t,type:`number`,step:.5,value:u[`w.${e.id}`]??``,onChange:t=>f({...u,[`w.${e.id}`]:t.target.value})})}),O(S,{fraction:Math.abs(t)/M,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),O(X,{children:e.blurb})]},e.id)})})}),O(C,{legend:`Limits`,children:O(J,{children:q.map(e=>O(Y,{children:O(x,{label:e.label,hint:e.hint,children:t=>k(o,{$gap:2,children:[O(b,{...t,type:`number`,min:e.min,step:e.step,value:u[e.id]??``,onChange:t=>f({...u,[e.id]:t.target.value})}),O(a,{children:e.unit})]})})},e.id))})}),O(C,{legend:`Historical tool results`,children:k(o,{$gap:3,$align:`start`,children:[O(h,{checked:u.rtkEnabled===`true`,onCheckedChange:e=>f({...u,rtkEnabled:String(e)}),label:`Enable RTK compression`}),O(X,{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.`})]})}),O(C,{legend:`Prompt caching`,children:k(o,{$gap:3,$align:`start`,children:[O(h,{checked:u.autoCacheEnabled===`true`,onCheckedChange:e=>f({...u,autoCacheEnabled:String(e)}),label:`Add a cache breakpoint when a client sends none`}),O(X,{children:`Anthropic only caches a prompt the request marks, so a client that marks nothing pays full price to resend the same prefix every turn. This marks the end of the system prompt on Anthropic requests that carry no breakpoint of their own. Requests that already mark one are left exactly as they arrived, and prompts too short to be cacheable are skipped. Enabled by default.`})]})}),O(C,{legend:`Request and response bodies`,meta:n.data===!0?`permitted by the environment`:`not permitted`,children:k(l,{$gap:3,children:[n.data===!0?null:k($,{children:[`This gateway was started without `,O(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,O(`code`,{children:`.env`}),` `,`and restart before turning capture on. Two keys mean an admin session on its own cannot start recording prompts.`]}),k(o,{$gap:3,$align:`start`,children:[O(h,{checked:u.bodyLoggingEnabled===`true`,disabled:n.data!==!0,onCheckedChange:e=>f({...u,bodyLoggingEnabled:String(e)}),label:`Capture request and response bodies`}),O(X,{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.`})]}),k(o,{$gap:3,$align:`start`,children:[O(h,{checked:u.bodyLoggingCaptureStreamChunks===`true`,disabled:n.data!==!0||u.bodyLoggingEnabled!==`true`,onCheckedChange:e=>f({...u,bodyLoggingCaptureStreamChunks:String(e)}),label:`Also keep raw stream frames`}),O(X,{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.`})]})]})}),y===null?null:O(Z,{role:`alert`,children:y}),A&&y===null?O(Q,{role:`status`,children:`Settings saved.`}):null,O(G,{}),O(R,{}),O(C,{legend:`Known limits`,children:k(l,{$gap:2,children:[k(o,{$gap:2,children:[O(c,{$dim:!0,children:`rate limits`}),O(X,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),k(o,{$gap:2,children:[O(c,{$dim:!0,children:`logs`}),O(X,{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 re=ne;export{re as component};
@@ -0,0 +1,76 @@
1
+ import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,O as y,Ot as b,P as x,Q as S,R as C,S as w,St as T,T as E,Tt as D,U as ee,V as O,W as te,X as ne,Y as re,Z as ie,_ as ae,_t as oe,a as k,at as se,b as ce,bt as le,c as ue,ct as de,d as fe,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as we,kt as Te,l as A,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,r as Ie,rt as Le,s as j,st as Re,t as ze,tt as Be,u as M,ut as Ve,v as N,vt as P,w as He,wt as Ue,x as We,xt as Ge,y as F,yt as Ke,z as qe}from"./shared-DQOWYTp3.js";import{A as Je,C as Ye,F as Xe,ct as Ze,dt as Qe,et as I,ft as $e,ht as et,lt as L,mt as R,st as tt}from"./queries-GAue98pY.js";import{i as nt,n as rt,r as it}from"./index-C3LoGDKu.js";import{i as at,o as ot,t as st}from"./Rack-DdhpgQWD.js";import{B as z,L as ct,P as B,R as lt}from"./States-2kaQxx-s.js";import{t as ut}from"./Panel-BeQOQoap.js";import{i as dt,n as V,r as H,t as ft}from"./Table-CVDZ69Zx.js";import{t as pt}from"./catalog-BBKm8Ih8.js";import{i as U,n as mt,r as ht,t as gt}from"./SummaryDeck-BisdRswW.js";import*as W from"react";import{PureComponent as _t,forwardRef as vt,useMemo as G,useRef as yt,useState as K}from"react";import{jsx as q,jsxs as J}from"react/jsx-runtime";import Y from"styled-components";function bt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function xt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var St=(e,t,n)=>ne(e,`xAxis`,bt(e,t),n),Ct=(e,t,n)=>S(e,`xAxis`,bt(e,t),n),wt=(e,t,n)=>ne(e,`yAxis`,xt(e,t),n),Tt=(e,t,n)=>S(e,`yAxis`,xt(e,t),n),Et=P([Me,St,wt,Ct,Tt],(e,t,n,r,i)=>ve(e,`xAxis`)?pe(t,r,!1):pe(n,i,!1)),Dt=P([e,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Ot=e=>{var t=Me(e);return ve(t,`xAxis`)?`yAxis`:`xAxis`},kt=(e,t)=>Ot(e)===`yAxis`?xt(e,t):bt(e,t),At=(e,t,n)=>ie(e,Ot(e),kt(e,t),n),jt=P([Dt,At],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=me(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]])}}}),Mt=P([Dt,At],(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(a)}}),Nt=P([Me,St,wt,Ct,Tt,jt,Le,Et,Dt,Ae,Mt],(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 fn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),Pt=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Ft=[`id`,`baseLine`];function It(){return It=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},It.apply(null,arguments)}function Lt(e,t){if(e==null)return{};var n,r,i=Rt(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 Rt(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 zt(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(!oe(a)||!oe(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return D(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),D(c)?W.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Bt(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(!oe(a)||!oe(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return D(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),D(c)?W.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function Vt(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?W.createElement(Bt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):W.createElement(zt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Ht(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,c=e.layout,l=e.isRange,u=e.stroke,d=e.connectNulls,f=Lt(e,Pt),p=c===`vertical`?`vertical`:`horizontal`,m=d??!1,h=x(),g=f.id,_=f.baseLine,v=Lt(f,Ft),y=Te(v),b=W.createElement(Se,It({},f,{id:g,baseLine:_,connectNulls:m,stroke:`none`,className:`recharts-area-area`,layout:p})),S=u!==`none`&&W.createElement(Se,It({},y,{className:`recharts-area-curve`,layout:p,type:f.type,connectNulls:m,fill:`none`,stroke:u,points:f.points})),C=u!==`none`&&l&&Array.isArray(_)&&W.createElement(Se,It({},y,{className:`recharts-area-curve`,layout:p,type:f.type,connectNulls:m,fill:`none`,stroke:u,points:_}));return o&&(i||n<1)?W.createElement(s,null,W.createElement(`defs`,null,W.createElement(`clipPath`,{id:h},W.createElement(Vt,{alpha:n,points:f.points??[],baseLine:_,layout:p,strokeWidth:f.strokeWidth}))),W.createElement(s,{clipPath:`url(#${h})`},b,S,C)):W.createElement(W.Fragment,null,b,S,C)}var Ut=[`id`],Wt=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Gt(){return Gt=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},Gt.apply(null,arguments)}function Kt(e,t){if(e==null)return{};var n,r,i=qt(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 qt(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 Jt(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?Jt(Object(n),!0).forEach(function(t){Yt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yt(e,t,n){return(t=Xt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xt(e){var t=Zt(e,`string`);return typeof t==`symbol`?t:t+``}function Zt(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 Qt={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:qe,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:Ge(e.prev.x,e.next.x,t),y:Ge(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:Ht,xAxisId:0,yAxisId:0,zIndex:Be.area};function $t(e,t){return e&&e!==`none`?e:t}var en=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:$t(r,i),value:Oe(n,t),payload:e}]},tn=W.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,u=e.formatter,d=e.tooltipType,f=e.id,p={dataDefinedOnItem:n,getPosition:l,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Oe(o,t),hide:s,type:d,color:$t(r,a),unit:c,formatter:u,graphicalItemId:f}};return W.createElement(O,{tooltipEntrySettings:p})});function nn(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=Te(r);return W.createElement(Ce,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function rn(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 W.createElement(te,{value:t?r:void 0},n)}function an(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,c=e.isAnimating,l=e.isEntrance,u=a.layout,d=a.type,p=a.stroke,m=a.connectNulls,h=a.isRange,g=a.shape,_=a.id,v=Kt(a,Ut),y=X(X({},b(v)),{},{id:_,points:t,connectNulls:m,type:d,baseLine:n,layout:u,stroke:p,isRange:h,animationElapsedTime:o,isAnimating:c,isEntrance:l});return W.createElement(W.Fragment,null,t?.length>1&&W.createElement(s,{clipPath:r?`url(#clipPath-${i})`:void 0},W.createElement(f,{option:g,DefaultShape:Qt.shape,shapeProps:y})),W.createElement(nn,{points:t,props:v,clipPathId:i}))}function on(e,t,n){if(D(e)){var r=D(t)?t:void 0;return Ge(r,e,n)}if(Ue(e)||T(e)){var i=D(t)?t:void 0;return Ge(i,0,n)}return e}function sn(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,f=r.animationDuration,m=r.animationEasing,h=r.animationMatchBy,_=r.animationInterpolateFn,v=G(()=>({points:o,baseLine:s}),[o,s]),y=g(v,a),b=Re(),x=p(r.onAnimationStart,r.onAnimationEnd),S=x.isAnimating,w=x.handleAnimationStart,T=x.handleAnimationEnd,E=y.startValue;if(b==null)return null;var D=Array.isArray(s)&&Array.isArray(E)?C(E,s,h):Array.isArray(s)?C(null,s,h):null;return W.createElement(u,{animationInput:v,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:f,animationEasing:m,onAnimationStart:w,onAnimationEnd:T,animationInterpolateFn:_,animationMatchBy:h,layout:b},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?_(D,i,b):a?s:on(s,E,i);return y.syncStepValue(c,i),W.createElement(rn,{showLabels:!S,points:o},r.children,W.createElement(an,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:S||i<1,isEntrance:a}),W.createElement(d,{label:r.label}))})}function cn(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=yt(null),a=yt();return W.createElement(sn,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var ln=class extends _t{render(){var e=this.props,t=e.hide,r=e.dot,i=e.points,a=e.className,o=e.top,l=e.left,u=e.needClip,d=e.xAxisId,f=e.yAxisId,p=e.width,h=e.height,g=e.id,_=e.baseLine,v=e.zIndex;if(t)return null;var y=n(`recharts-area`,a),b=g,x=E(r),S=x.r,C=x.strokeWidth,w=ee(r),T=S*2+C,D=u?`url(#clipPath-${w?``:`dots-`}${b})`:void 0;return W.createElement(m,{zIndex:v},W.createElement(s,{className:y},u&&W.createElement(`defs`,null,W.createElement(c,{clipPathId:b,xAxisId:d,yAxisId:f}),!w&&W.createElement(`clipPath`,{id:`clipPath-dots-${b}`},W.createElement(`rect`,{x:l-T/2,y:o-T/2,width:p+T,height:h+T}))),W.createElement(cn,{needClip:u,clipPathId:b,props:this.props})),W.createElement(we,{points:i,mainColor:$t(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}),this.props.isRange&&Array.isArray(_)&&W.createElement(we,{points:_,mainColor:$t(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}))}};function un(e){var n=e.activeDot,r=e.animationBegin,i=e.animationDuration,a=e.animationEasing,s=e.connectNulls,c=e.dot,l=e.fill,u=e.fillOpacity,d=e.hide,f=e.isAnimationActive,p=e.legendType,m=e.stroke,h=e.xAxisId,g=e.yAxisId,_=Kt(e,Wt),v=de(),y=re(),b=o(h,g).needClip,x=Ve(),S=Ke(t=>Nt(t,e.id,x))??{},C=S.points,w=S.isRange,T=S.baseLine,E=t();if(v!==`horizontal`&&v!==`vertical`||E==null||y!==`AreaChart`&&y!==`ComposedChart`)return null;var D=E.height,ee=E.width,O=E.x,te=E.y;return!C||!C.length?null:W.createElement(ln,Gt({},_,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,baseLine:T,connectNulls:s,dot:c,fill:l,fillOpacity:u,height:D,hide:d,layout:v,isAnimationActive:f,isRange:w,legendType:p,needClip:b,points:C,stroke:m,width:ee,left:O,top:te,xAxisId:h,yAxisId:g}))}var dn=(e,t,n,r,i)=>{var a=n??t;if(D(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 fn(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,_=dn(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=be(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=be(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>be(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:ge({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:ge({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 pn(e){var t=le(e,Qt),n=Ve();return W.createElement(v,{id:t.id,type:`area`},e=>W.createElement(W.Fragment,null,W.createElement(r,{legendPayload:en(t)}),W.createElement(tn,{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}),W.createElement(_,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:Pe(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),W.createElement(un,Gt({},t,{id:e}))))}var Z=W.memo(pn,se);Z.displayName=`Area`;var mn=[`axis`],hn=vt((e,t)=>W.createElement(We,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:mn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),gn=[`axis`],_n=vt((e,t)=>W.createElement(We,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:gn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),vn=53,Q=9,$=2,yn=Y.div`
2
+ display: flex;
3
+ gap: ${$}px;
4
+ `,bn=Y.div`
5
+ display: grid;
6
+ grid-template-rows: repeat(7, ${Q}px);
7
+ gap: ${$}px;
8
+ padding-top: ${11}px;
9
+ font-size: 9px;
10
+ color: ${({theme:e})=>e.color.inkFaint};
11
+ `,xn=Y.div`
12
+ line-height: ${Q}px;
13
+ padding-right: 2px;
14
+ text-align: right;
15
+ `,Sn=Y.div`
16
+ display: grid;
17
+ grid-template-columns: repeat(${vn}, ${Q}px);
18
+ gap: ${$}px;
19
+ height: ${Q}px;
20
+ font-size: 9px;
21
+ color: ${({theme:e})=>e.color.inkFaint};
22
+ `,Cn=Y.div`
23
+ white-space: nowrap;
24
+ line-height: ${Q}px;
25
+ `,wn=Y.div`
26
+ display: grid;
27
+ grid-template-columns: repeat(${vn}, ${Q}px);
28
+ gap: ${$}px;
29
+ `,Tn=Y.div`
30
+ display: grid;
31
+ grid-template-rows: repeat(7, ${Q}px);
32
+ gap: ${$}px;
33
+ `,En=Y.div`
34
+ width: ${Q}px;
35
+ height: ${Q}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
+ `,Dn=Y(Qe)`
47
+ gap: ${$}px;
48
+ `,On=Y(L)`
49
+ color: ${({theme:e})=>e.color.inkDim};
50
+ font-size: 11px;
51
+ `;function kn(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 An(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function jn({days:e,now:t}){let[n,r]=K(`tokens`),[i,a]=K(null),o=De(n),s=G(()=>{let n=new Map;for(let t of e){let e=Number(t.key);Number.isFinite(e)&&n.set(ae(e),{requests:t.requests,errors:t.errors,costUsd:t.costUsd,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens,rtkSavedTokens:t.rtkSavedTokens,rtkAppliedRequests:t.rtkAppliedRequests,durationMsSum:t.durationMsSum})}let r=new Date(ae(t));r.setDate(r.getDate()+(6-r.getDay())-370);let i=ae(t);return Array.from({length:vn},()=>Array.from({length:7},()=>{let e=r.getTime();return r.setDate(r.getDate()+1),{at:e,totals:n.get(e)??j,future:e>i}}))},[e,t]),c=s.flat(),l=kn(c.map(e=>o.of({key:``,...e.totals}))),u=c.reduce((e,t)=>ue(e,M(t.totals)),j),d=c.reduce((e,t)=>e+ +(t.totals.requests>0),0),f=(e,t)=>`${e}: ${B(t.requests)} requests, ${B(A(t))} tokens, ${z(t.costUsd)}`;return q(ut,{legend:`Activity`,meta:i===null?`${B(d)} active days`:void 0,actions:q(mt,{children:Ie.map(e=>q(ht,{type:`button`,$size:`sm`,$on:e.id===n,"aria-pressed":e.id===n,onClick:()=>r(e.id),children:e.label},e.id))}),children:J(R,{$gap:2,children:[q($e,{children:q(R,{$gap:1,style:{width:611},children:J(yn,{children:[q(bn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>q(xn,{children:e},t))}),J(R,{$gap:1,children:[q(Sn,{"aria-hidden":`true`,children:s.map((e,t)=>{let n=e[0],r=s[t-1]?.[0],i=n!==void 0&&(r===void 0||new Date(r.at).getMonth()!==new Date(n.at).getMonth());return q(Cn,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),q(wn,{role:`grid`,"aria-label":`${o.label} per day over the last year`,children:s.map(e=>q(Tn,{role:`row`,children:e.map(e=>q(En,{role:`gridcell`,tabIndex:-1,"aria-label":f(he(e.at),e.totals),title:f(he(e.at),e.totals),$future:e.future,$level:e.future?0:An(o.of({key:``,...e.totals}),l),onMouseEnter:()=>a(e),onMouseLeave:()=>a(null)},e.at))},e[0]?.at))})]})]})})}),J(Qe,{$justify:`space-between`,$wrap:!0,children:[q(On,{children:i===null?f(`Last 12 months`,u):f(he(i.at),i.totals)}),J(Qe,{$gap:1,children:[q(Ze,{children:`Less`}),q(Dn,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>q(En,{$level:e,$future:!1},e))}),q(Ze,{children:`More`})]})]})]})})}function Mn({buckets:e,by:t,since:n,until:r,metric:i,names:a}){let o=F(n,r,t),s=new Map,c=new Map;for(let n of e){let e=n.split??`unknown`;s.set(e,ue(s.get(e)??j,n));let r=c.get(e)??new Map,a=Ne(n.key,t);r.set(a,(r.get(a)??0)+i.of(n)),c.set(e,r)}let l=[...s.entries()].sort((e,t)=>i.of(M(t[1]))-i.of(M(e[1])));return q($e,{children:J(ft,{children:[q(`thead`,{children:J(`tr`,{children:[q(H,{children:`Key`}),q(H,{children:`Trend`}),q(H,{$align:`right`,children:`Requests`}),q(H,{$align:`right`,children:`Failed`}),q(H,{$align:`right`,children:`Tokens`}),q(H,{$align:`right`,children:`Mean`}),q(H,{$align:`right`,children:`Cost`})]})}),q(`tbody`,{children:l.map(([e,t])=>{let n=c.get(e)??new Map,r=e===`unknown`?`Unattributed`:a.get(e)??e;return J(dt,{children:[q(V,{children:q(et,{style:{display:`block`,maxWidth:`28ch`},children:r})}),q(V,{style:{width:120},children:q(at,{values:o.map(e=>n.get(e)??0),height:20,label:`${r}: ${i.format(i.of(M(t)))} over the window`})}),q(V,{$align:`right`,$mono:!0,children:B(t.requests)}),q(V,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:lt(t.requests===0?0:t.errors/t.requests,0)}),q(V,{$align:`right`,$mono:!0,children:B(A(t))}),q(V,{$align:`right`,$mono:!0,children:ct(t.requests===0?null:t.durationMsSum/t.requests)}),q(V,{$align:`right`,$mono:!0,children:z(t.costUsd)})]},e)})})]})})}var Nn=6,Pn=`__other__`,Fn=`unknown`;function In(e,t){let n=t.get(e);return n===void 0?rt.find(t=>pt[t].models.some(t=>t.id===e))??null:n}function Ln(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${nt(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Rn({buckets:e,by:t,since:n,until:r,metric:a,providers:o}){let s=[...fe(e,a).entries()],c=s.slice(0,Nn),l=s.slice(Nn),u=[];for(let e of[...rt,null])c.filter(([t])=>In(t,o)===e).forEach(([t,n],r)=>{u.push({name:t,label:t===Fn?`Unresolved`:t,color:Ln(e,r),totals:n})});l.length>0&&u.push({name:Pn,label:`${l.length} more`,color:`var(--ink-faint)`,totals:l.reduce((e,[,t])=>ue(e,M(t)),j)});let d=new Set(c.map(([e])=>e)),f=new Map;for(let n of e){let e=n.split??Fn,r=`${Ne(n.key,t)} ${d.has(e)?e:Pn}`;f.set(r,(f.get(r)??0)+a.of(n))}let p=F(n,r,t).map(e=>{let t={at:e};for(let n of u)t[n.name]=f.get(`${e} ${n.name}`)??0;return t}),m=new Map(u.map(e=>[e.name,e.label]));return J(R,{$gap:2,children:[q(ze,{$height:220,children:q(Ee,{width:`100%`,height:`100%`,children:J(hn,{data:p,margin:{top:4,right:4,bottom:4,left:4},children:[q(y,{stroke:`var(--rule)`,vertical:!1}),q(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(w,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),q(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>{if(e!==!0||n===void 0||n.length===0)return null;let i=n.filter(e=>Number(e.value??0)>0);return J(je,{children:[q(`div`,{children:N(Number(r),t)}),i.length===0?q(`div`,{children:`No ${a.label.toLowerCase()}`}):i.map(e=>J(`div`,{children:[m.get(String(e.dataKey))??String(e.dataKey),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}}),u.map(e=>q(Z,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),q(ke,{children:u.map(e=>J(`span`,{children:[q(k,{$color:e.color}),` `,q(et,{title:`${e.label}: ${a.format(a.of(M(e.totals)))} ${a.label.toLowerCase()}`,style:{display:`inline-block`,maxWidth:`24ch`,verticalAlign:`bottom`},children:e.label})]},e.name))})]})}var zn=`unknown`;function Bn(e){let t=rt.find(t=>t===e);return t===void 0?`var(--ink-faint)`:nt(t)}function Vn(e){let t=rt.find(t=>t===e);return t===void 0?`Unresolved`:it[t]}function Hn({buckets:e,by:t,since:n,until:r,metric:a}){let o=fe(e,a),s=[...rt,zn].map(e=>({name:e,totals:o.get(e)})).filter(e=>e.totals!==void 0),c=s.map(e=>e.name),l=F(n,r,t),u=_e(e,l,t,a),d=[...o.values()].reduce((e,t)=>e+t.requests,0);return J(R,{$gap:3,children:[q(ze,{$height:200,children:q(Ee,{width:`100%`,height:`100%`,children:J(hn,{data:u,margin:{top:4,right:4,bottom:4,left:4},children:[q(y,{stroke:`var(--rule)`,vertical:!1}),q(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(w,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),q(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:J(je,{children:[q(`div`,{children:N(Number(r),t)}),n.map(e=>J(`div`,{children:[Vn(String(e.dataKey)),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}),c.map(e=>q(Z,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:Bn(e),strokeWidth:2,fill:Bn(e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),q(ke,{children:c.map(e=>J(`span`,{children:[q(k,{$color:Bn(e)}),` `,Vn(e)]},e))}),J(ft,{children:[q(`thead`,{children:J(`tr`,{children:[q(H,{children:`Provider`}),q(H,{$align:`right`,children:`Share`}),q(H,{$align:`right`,children:`Requests`}),q(H,{$align:`right`,children:`Failed`}),q(H,{$align:`right`,children:`Tokens`}),q(H,{$align:`right`,children:`Cost`})]})}),q(`tbody`,{children:s.map(({name:e,totals:t})=>J(dt,{children:[J(V,{children:[q(k,{$color:Bn(e)}),` `,Vn(e)]}),q(V,{$align:`right`,$mono:!0,children:lt(d===0?0:t.requests/d,0)}),q(V,{$align:`right`,$mono:!0,children:B(t.requests)}),q(V,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:B(t.errors)}),q(V,{$align:`right`,$mono:!0,children:B(A(t))}),q(V,{$align:`right`,$mono:!0,children:z(t.costUsd)})]},e))})]})]})}var Un=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
+ `,Wn=Y.ol`
57
+ display: flex;
58
+ flex-direction: column;
59
+ gap: ${({theme:e})=>e.space(2)};
60
+ `,Gn=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
+ `,Kn=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
+ `,qn=Y(et)`
73
+ display: block;
74
+ font-family: ${({theme:e})=>e.font.mono};
75
+ font-size: 12px;
76
+ `,Jn=12;function Yn({buckets:e,metric:t,names:n,unknownLabel:r}){let i=new Map;for(let t of e)i.set(t.key,ue(i.get(t.key)??j,t));let a=e=>e===`unknown`?r??`Unattributed`:n?.get(e)??e,o=[...i.entries()].map(([e,n])=>({name:a(e),entry:n,value:t.of(M(n))})).sort((e,t)=>t.value-e.value),s=o.slice(0,Jn),c=o.slice(Jn),l=s[0]?.value??0;return J(R,{$gap:3,children:[q(Wn,{children:s.map(({name:e,entry:n,value:r})=>J(Un,{children:[q(qn,{title:e,children:e}),q(Gn,{children:q(Kn,{$share:l===0?0:r/l,$fault:n.requests>0&&n.errors===n.requests})}),J(Qe,{$gap:2,children:[q(L,{$size:`12px`,children:t.format(r)}),q(L,{$size:`11px`,$dim:!0,children:z(n.costUsd)})]})]},e))}),c.length===0?null:q(L,{$size:`11px`,$dim:!0,children:`+ ${c.length} more, ${B(c.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}var Xn=[{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 Zn({buckets:e,by:t,since:n,until:r}){let a=new Map;for(let n of e)a.set(Ne(n.key,t),n);let o=F(n,r,t).map(e=>{let t=a.get(e);return{at:e,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,cacheReadTokens:t?.cacheReadTokens??0,cacheWriteTokens:t?.cacheWriteTokens??0}}),s=Xn.map(e=>({...e,value:o.reduce((t,n)=>t+n[e.id],0)})),c=s.reduce((e,t)=>e+t.value,0);return J(R,{$gap:3,children:[q(ze,{$height:200,children:q(Ee,{width:`100%`,height:`100%`,children:J(hn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[q(y,{stroke:`var(--rule)`,vertical:!1}),q(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(w,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>B(e)}),q(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:J(je,{children:[q(`div`,{children:N(Number(r),t)}),Xn.map(e=>J(`div`,{children:[e.label,` `,B(Number(n.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),Xn.map(e=>q(Z,{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(ke,{children:s.map(e=>J(Qe,{$gap:1,children:[q(k,{$color:`var(--accent)`,style:{opacity:e.opacity}}),q(`span`,{children:e.label}),q(L,{$size:`11px`,children:B(e.value)}),q(L,{$size:`11px`,$dim:!0,children:lt(c===0?0:e.value/c,0)})]},e.id))})]})}function Qn({buckets:e,by:t,since:n,until:r}){let a=new Map;for(let n of e)a.set(Ne(n.key,t),n);let o=F(n,r,t).map(e=>{let n=a.get(e);return{at:e,label:N(e,t),requests:n?.requests??0,errors:n?.errors??0,costUsd:n?.costUsd??0,tokens:n===void 0?0:A(n)}});return J(R,{$gap:2,children:[q(ze,{$height:220,children:q(Ee,{width:`100%`,height:`100%`,children:J(_n,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[q(y,{stroke:`var(--rule)`,vertical:!1}),q(i,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),q(w,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),q(h,{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(je,{children:[q(`div`,{children:n.label}),J(`div`,{children:[B(n.requests),` requests`]}),J(`div`,{children:[B(n.errors),` failed`]}),J(`div`,{children:[B(n.tokens),` tokens`]}),q(`div`,{children:z(n.costUsd)})]})}}),q(Z,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),q(He,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),q(He,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),J(ke,{children:[J(`span`,{children:[q(k,{$color:`var(--accent)`}),` Requests`]}),J(`span`,{children:[q(k,{$color:`var(--down)`}),` Failed`]})]})]})}var $n=864e5,er=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function tr(){let{cadence:e}=ot(),[t,n]=K(`24h`),[r,i]=K(`tokens`),[a,o]=K(`model`),s=ye(t),c=De(r),l=G(()=>s.grain===`daily`?ae(Date.now()-s.ms):Math.floor((Date.now()-s.ms)/6e4)*6e4,[s]),u=G(()=>l+s.ms,[l,s]),d=G(()=>ae(Date.now()-371*$n),[]),f={since:l,grain:s.grain},p=I({...f,groupBy:s.by},e(6e4,`res:usage`)),m=I({...f,groupBy:s.by,splitBy:`provider`},e(6e4,`res:usage`)),h=I({...f,groupBy:s.by,splitBy:`model`},e(6e4,`res:usage`)),g=I({...f,groupBy:s.by,splitBy:`apiKey`},e(6e4,`res:usage`)),_=I({...f,groupBy:a},e(6e4,`res:usage`)),v=I({...f,groupBy:`credential`},e(6e4,`res:usage`)),y=I({since:d,grain:`daily`,groupBy:`day`},e(3e5,`res:usage`)),b=Je(),x=Ye(),S=Xe(),C=G(()=>{let e=new Map;for(let t of S.data??[])for(let n of t.targets)e.set(n.model,n.provider);return e},[S.data]),w=G(()=>{let e=new Map;for(let t of b.data??[])e.set(t.id,t.label);return e},[b.data]),T=G(()=>{let e=new Map;for(let t of x.data??[])e.set(t.id,t.label);return e},[x.data]),E=p.data??[],D=ce(E),ee=A(D),O={legend:`Nothing recorded`,message:`No requests landed in this window. Widen the range, or send traffic through the gateway.`};return J(R,{$gap:4,children:[q(st,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:p.isLoading?`Reading usage…`:`${B(D.requests)} requests and ${z(D.costUsd)} over the last ${s.label}.`,actions:q(mt,{children:xe.map(e=>q(ht,{type:`button`,$size:`sm`,$on:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:e.id},e.id))})}),q(gt,{buckets:E,since:l,until:u,by:s.by,rangeLabel:s.label}),q(U,{legend:`Traffic`,meta:s.by===`hour`?`By hour`:`By day`,query:p,isEmpty:E.length===0,empty:O,children:q(Qn,{buckets:E,by:s.by,since:l,until:u})}),q(mt,{children:Ie.map(e=>q(ht,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:`Rank by ${e.label.toLowerCase()}`},e.id))}),q(U,{legend:`Traffic by upstream model`,meta:`${c.label}, ${s.by===`hour`?`by hour`:`by day`}`,query:h,isEmpty:(h.data??[]).length===0,empty:O,children:q(Rn,{buckets:h.data??[],by:s.by,since:l,until:u,metric:c,providers:C})}),J(tt,{$min:`480px`,$gap:4,children:[J(R,{$gap:4,children:[q(U,{legend:`Providers`,meta:c.label,query:m,isEmpty:(m.data??[]).length===0,empty:O,children:q(Hn,{buckets:m.data??[],by:s.by,since:l,until:u,metric:c})}),q(jn,{days:y.data??[],now:Date.now()})]}),J(R,{$gap:4,children:[q(U,{legend:`Token mix`,meta:B(ee),query:p,isEmpty:E.length===0,empty:O,children:q(Zn,{buckets:E,by:s.by,since:l,until:u})}),q(U,{legend:`Models`,meta:er.find(e=>e.id===a)?.column,query:_,isEmpty:(_.data??[]).length===0,empty:O,actions:q(mt,{children:er.map(e=>q(ht,{type:`button`,$size:`sm`,$on:e.id===a,"aria-pressed":e.id===a,onClick:()=>o(e.id),children:e.label},e.id))}),children:q(Yn,{buckets:_.data??[],metric:c})}),q(U,{legend:`Accounts`,meta:c.label,query:v,isEmpty:(v.data??[]).length===0,empty:O,children:q(Yn,{buckets:v.data??[],metric:c,names:T,unknownLabel:`No account`})})]})]}),q(U,{legend:`API keys`,meta:c.label,query:g,isEmpty:(g.data??[]).length===0,empty:O,children:q(Mn,{buckets:g.data??[],by:s.by,since:l,until:u,metric:c,names:w})})]})}var nr=tr;export{nr as component};
@@ -0,0 +1 @@
1
+ import{_ as e}from"./Rack-DdhpgQWD.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),n=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t as n,n as t};
@@ -0,0 +1,39 @@
1
+ import{_ as e,h as t,i as n}from"./shared-DQOWYTp3.js";import{ct as r,d as i,dt as a,f as ee,ft as o,h as te,lt as s,m as ne,mt as c,n as re,p as ie,u as l,ut as u,vt as ae,yt as d}from"./queries-GAue98pY.js";import{c as oe,o as f,r as p,t as se}from"./Rack-DdhpgQWD.js";import{n as ce,t as m}from"./chevron-right-mGs1is3r.js";import{B as h,P as g,R as _,b as v,m as le,n as ue,p as de,r as fe,s as y,z as b}from"./States-2kaQxx-s.js";import{i as x,n as pe}from"./Field-B2rnk3JM.js";import{t as S}from"./Meter-stpt3vQu.js";import{t as me}from"./Panel-BeQOQoap.js";import{i as C,n as w,r as T,t as E}from"./Table-CVDZ69Zx.js";import{n as he,r as ge}from"./WindowChart-Bvbkz9rt.js";import{n as D,t as O}from"./stream-Bu-m1Z1Y.js";import{i as _e,n as ve,r as ye,t as be}from"./RequestTable-I1TrD689.js";import{i as k,n as A,r as xe,t as Se}from"./SummaryDeck-BisdRswW.js";import{Fragment as Ce,useMemo as j,useState as M}from"react";import{jsx as N,jsxs as P}from"react/jsx-runtime";import F from"styled-components";var I=F.div`
2
+ display: grid;
3
+ grid-template-areas:
4
+ "chassis"
5
+ "main";
6
+ grid-template-columns: minmax(0, 1fr);
7
+ grid-template-rows: auto minmax(0, 1fr);
8
+ height: 100vh;
9
+ min-height: 0;
10
+ overflow: hidden;
11
+ `,L=F.main`
12
+ grid-area: main;
13
+ padding: ${({theme:e})=>e.space(4)};
14
+ display: flex;
15
+ flex-direction: column;
16
+ gap: ${({theme:e})=>e.space(4)};
17
+ min-width: 0;
18
+ min-height: 0;
19
+ overflow-y: auto;
20
+
21
+ @media (max-width: 720px) {
22
+ padding: ${({theme:e})=>e.space(3)};
23
+ }
24
+ `;function R({children:e}){let{cadence:t}=f(),n=l(),r=i(200,t(1e4,`res:logs`));return P(I,{"data-testid":`client-shell`,children:[N(p,{logs:r.data??[],logsFailed:r.isError,signOut:{pending:n.isPending,run:()=>{n.mutate(void 0,{onSuccess:()=>window.location.assign(`/login`)})}}}),N(L,{children:e})]})}var z=[20,50,100,250],B={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function we({reading:e}){let t=e.window===null?`concurrent requests`:`${e.dimension} ${B[e.window]??e.window}`,n=e.dimension===`spend`?h:g,r=e.used===null?null:e.limit===0?1:e.used/e.limit;return P(C,{children:[N(w,{children:t}),N(w,{$align:`right`,$mono:!0,children:e.used===null?N(u,{children:`unknown`}):n(e.used)}),N(w,{$align:`right`,$mono:!0,children:n(e.limit)}),N(w,{children:r===null?null:N(S,{fraction:r,label:`${t}, ${Math.round(Math.min(1,r)*100)}% used`})})]})}function V(e){return{observedAt:e.observedAt,windowType:e.windowType,windowMs:e.windowMs,resetsAt:e.resetsAt,usedRatio:e.usedRatio}}function H(e){return{stale:e.stale,rolledOver:e.rolledOver,estimateStale:e.stale||e.rolledOver,survives:e.survives,exhaustsAt:e.exhaustsAt}}var U=F.div`
25
+ display: flex;
26
+ flex-direction: column;
27
+ gap: 4px;
28
+ `,W=F.div`
29
+ display: grid;
30
+ /* Bar, figure, legend — the accounts page's own three columns, so the two
31
+ screens read the same way and the legends stay aligned down the stack. */
32
+ grid-template-columns: 96px 34px 1fr;
33
+ align-items: center;
34
+ min-width: 208px;
35
+ gap: 6px;
36
+ `,G=F(s)`
37
+ font-size: 11px;
38
+ text-align: right;
39
+ `;function Te({windows:e,open:t,onToggle:n}){let i=e[0],a=e.filter(e=>e.usedRatio!==null);return P(C,{children:[N(w,{children:i.label}),N(w,{children:a.length===0?N(u,{children:`unknown`}):N(U,{children:a.map(e=>P(W,{children:[N(S,{fraction:e.usedRatio,label:`${e.label} ${e.windowType} window, ${Math.round(e.usedRatio*100)}% used`}),N(G,{children:_(e.usedRatio,0)}),N(r,{children:v(e,H(e),Date.now(),b)})]},e.windowType))})}),N(w,{$align:`right`,children:N(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} quota history for ${i.label}`,title:`${t?`Hide`:`Show`} quota history for ${i.label}`,onClick:n,children:N(t?ce:m,{})})})]})}function K(){let{cadence:l,live:d}=f(),[p,ce]=M(`24h`),[m,v]=M(`all`),[b,S]=M(``),[D,O]=M(z[0]),[F,I]=M(null),[L,R]=M(null),B=t(p),H=j(()=>B.grain===`daily`?e(Date.now()-B.ms):Math.floor((Date.now()-B.ms)/6e4)*6e4,[B]),U=j(()=>H+B.ms,[H,B]),W=ne(),G={since:H,grain:B.grain},K=te({...G,groupBy:B.by},l(6e4,`res:usage`)),q=te({...G,groupBy:`model`},l(6e4,`res:usage`)),J=i(D,l(re,`res:logs`)),Y=ee(6e4),X=Y.data??[],Ee=j(()=>{let e=new Map;for(let t of X){let n=e.get(t.provider)??new Map,r=n.get(t.credentialId);r===void 0?n.set(t.credentialId,[t]):r.push(t),e.set(t.provider,n)}return[...e.entries()].map(([e,t])=>[e,[...t.entries()].map(([e,t])=>({credentialId:e,windows:[...t].sort((e,t)=>y[e.windowType]-y[t.windowType])}))])},[X]),Z=X.map(e=>ge(V(e))).filter(e=>e!==null),De=Z.length===0?0:Math.floor(Math.min(...Z)/6e4)*6e4,Oe=ie({since:De},L!==null&&Z.length>0),ke=(J.data??[]).some(le),Ae=_e(d&&ke),Q=ye(J.data??[],m,b),je=(J.data??[]).filter(de).length,$=K.data??[],Me=$.reduce((e,t)=>e+t.requests,0),Ne=$.reduce((e,t)=>e+t.costUsd,0);return P(c,{$gap:4,children:[N(se,{legend:`Client`,title:`Your usage`,summary:K.isLoading?`Reading your usage…`:`${g(Me)} requests and ${h(Ne)} over the last ${B.label}.`,actions:N(A,{children:n.map(e=>N(xe,{type:`button`,$size:`sm`,$on:e.id===p,"aria-pressed":e.id===p,onClick:()=>ce(e.id),children:e.id},e.id))})}),N(me,{legend:`Your key`,meta:W.data===void 0?void 0:P(s,{$dim:!0,children:[W.data.prefix,`…`]}),children:W.isPending?N(fe,{rows:2}):W.isError?N(ue,{legend:`Could not read your key`,error:W.error}):P(c,{$gap:2,children:[P(a,{$gap:2,$wrap:!0,children:[N(r,{children:W.data.label}),W.data.bodyLoggingOptOut?N(u,{children:`Request bodies are never stored for this key.`}):null]}),W.data.modelAllowlist===null?N(u,{children:`Every model this gateway serves.`}):W.data.modelAllowlist.length===0?N(u,{children:`No models. This key cannot serve a request.`}):N(a,{$gap:1,$wrap:!0,children:W.data.modelAllowlist.map(e=>N(s,{children:e},e))})]})}),N(Se,{buckets:$,since:H,until:U,by:B.by,rangeLabel:B.label}),N(k,{legend:`By model`,meta:B.label,query:{isLoading:q.isLoading,isError:q.isError,error:q.error,refetch:()=>void q.refetch()},failure:`Could not read usage`,empty:{legend:`No traffic`,message:`Nothing served in this window.`},isEmpty:(q.data??[]).length===0,children:N(o,{children:P(E,{children:[N(`thead`,{children:P(`tr`,{children:[N(T,{children:`Model`}),N(T,{$align:`right`,children:`Requests`}),N(T,{$align:`right`,children:`Tokens`}),N(T,{$align:`right`,children:`Spend`})]})}),N(`tbody`,{children:(q.data??[]).map(e=>P(C,{children:[N(w,{$mono:!0,children:e.key}),N(w,{$align:`right`,$mono:!0,children:g(e.requests)}),N(w,{$align:`right`,$mono:!0,children:g(e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheWriteTokens)}),N(w,{$align:`right`,$mono:!0,children:h(e.costUsd)})]},e.key))})]})})}),N(k,{legend:`Your limits`,query:{isLoading:W.isLoading,isError:W.isError,error:W.error,refetch:()=>void W.refetch()},failure:`Could not read your limits`,empty:W.data?.limits===null?{legend:`Limits unreadable`,message:`This key's limits could not be read. Requests are refused until an operator repairs it.`}:{legend:`No limits`,message:`This key is not rate limited.`},isEmpty:W.data?.limits===null||(W.data?.limitUsage.length??0)===0,footer:N(u,{children:`Counted from completed requests, so a burst in flight right now may not be included yet.`}),children:N(o,{children:P(E,{children:[N(`thead`,{children:P(`tr`,{children:[N(T,{children:`Limit`}),N(T,{$align:`right`,children:`Used`}),N(T,{$align:`right`,children:`Ceiling`}),N(T,{$width:`30%`,children:`Consumption`})]})}),N(`tbody`,{children:(W.data?.limitUsage??[]).map(e=>N(we,{reading:e},`${e.dimension}:${e.window??`gauge`}`))})]})})}),N(k,{legend:`Provider headroom`,query:{isLoading:Y.isLoading,isError:Y.isError,error:Y.error,refetch:()=>void Y.refetch()},failure:`Could not read provider headroom`,empty:{legend:`No data`,message:`No provider has reported a usage window.`},isEmpty:X.length===0,footer:N(u,{children:`What each account serving this gateway has left. A request is served by whichever account of a provider can take it.`}),children:N(c,{$gap:4,children:Ee.map(([e,t])=>P(c,{$gap:1,children:[N(r,{children:e}),N(o,{children:P(E,{children:[N(`thead`,{children:P(`tr`,{children:[N(T,{children:`Account`}),N(T,{$width:`60%`,children:`Quota`}),N(T,{})]})}),N(`tbody`,{children:t.map(({credentialId:e,windows:t})=>P(Ce,{children:[N(Te,{windows:t,open:L===e,onToggle:()=>R(L===e?null:e)}),L===e?N(C,{children:N(w,{colSpan:3,children:N(c,{$gap:4,children:t.map(e=>{let t=V(e),n=ge(t),r=(Oe.data?.samples??[]).filter(t=>t.credentialId===e.credentialId&&t.windowType===e.windowType&&t.observedAt>=(n??0));return N(he,{live:t,samples:r.map(e=>({observedAt:e.observedAt,windowType:e.windowType,windowMs:e.windowMs,resetsAt:e.resetsAt,usedRatio:e.usedRatio})),since:n,now:Date.now(),truncated:Oe.data?.truncated===!0&&n!==null&&r.length>0&&(r[0]?.observedAt??0)>n,ratePerHourRatio:e.ratePerHourRatio,exhaustsAt:e.exhaustsAt,survives:e.survives,stale:e.stale,rolledOver:e.rolledOver,spent:e.usedRatio===null?`no ceiling reported`:`${_(e.usedRatio,0)} used`,rateText:e.ratePerHourRatio===null?`unknown`:`${_(e.ratePerHourRatio,1)}/h`},e.windowType)})})})}):null]},e))})]})})]},e))})}),N(k,{legend:`Recent requests`,meta:`${Q.length} shown`,actions:P(A,{children:[N(pe,{value:b,placeholder:`Filter by model or error`,"aria-label":`Filter requests`,style:{width:200},onChange:e=>S(e.target.value)}),P(x,{value:m,"aria-label":`Show which requests`,style:{width:`auto`},onChange:e=>v(e.target.value),children:[N(`option`,{value:`all`,children:`All requests`}),N(`option`,{value:`failed`,children:`Failed only`})]}),N(x,{value:D,"aria-label":`How many requests to fetch`,style:{width:`auto`},onChange:e=>O(Number(e.target.value)),children:z.map(e=>P(`option`,{value:e,children:[`last `,e]},e))})]}),query:{isLoading:J.isLoading,isError:J.isError,error:J.error,refetch:()=>void J.refetch()},failure:`Could not read your requests`,empty:{legend:`No requests`,message:(J.data??[]).length===0?`Nothing served through this key yet.`:`No request in this window matches the filter. Clear it to see everything.`},isEmpty:Q.length===0,footer:P(u,{children:[g(je),` of the last `,g((J.data??[]).length),` failed.`]}),children:N(o,{children:N(ve,{rows:Q,now:Ae,onOpen:I})})}),N(oe,{open:F!==null,onOpenChange:e=>{e||I(null)},title:`Request detail`,width:`640px`,footer:N(ae,{type:`button`,onClick:()=>I(null),children:`Close`}),children:F===null?null:N(be,{log:F})})]})}var q=()=>N(O,{children:N(D,{children:N(R,{children:N(K,{})})})});export{q as component};