omnigateway 0.11.0 → 0.11.2

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 (47) hide show
  1. package/README.md +16 -17
  2. package/bin/omni.js +184 -35
  3. package/gateway.js +139 -40
  4. package/package.json +2 -2
  5. package/public/assets/{Chip-CmL-9rw7.js → Chip-77Q04h7S.js} +2 -1
  6. package/public/assets/{CopyValue-CTVbU0O_.js → CopyValue-DDJId-Zo.js} +1 -1
  7. package/public/assets/{Field-DcNu4yw-.js → Field-56pmSGrh.js} +1 -1
  8. package/public/assets/{Lamp-DtHKJH6P.js → Lamp-Drd1fFwQ.js} +7 -7
  9. package/public/assets/{Panel-BlNr9j6-.js → Panel-BV18WuL1.js} +1 -0
  10. package/public/assets/Rack-D3iFlR6e.js +482 -0
  11. package/public/assets/{Readout-D8Ofl3Gz.js → Readout-Dxwka1JI.js} +1 -1
  12. package/public/assets/RequestTable-I395emqH.js +11 -0
  13. package/public/assets/SummaryDeck-pAZ93jBW.js +15 -0
  14. package/public/assets/{Toggle-ChjN-tw1.js → Toggle-y17mtXCV.js} +1 -1
  15. package/public/assets/{TokenBreakdown-BPoXM3JM.js → TokenBreakdown-BIwuEVs8.js} +2 -1
  16. package/public/assets/{WindowChart-BPEsEGFL.js → WindowChart-DWZtz4Ps.js} +2 -2
  17. package/public/assets/{_app-CWXzHdhc.js → _app-0fHLZIC7.js} +1 -1
  18. package/public/assets/_app.accounts-DBlImnPw.js +59 -0
  19. package/public/assets/{_app.console-Bkdallia.js → _app.console-in_iVnep.js} +2 -2
  20. package/public/assets/{_app.database-DxqN1395.js → _app.database-CPj-Juag.js} +4 -4
  21. package/public/assets/_app.index-DGz9njXx.js +67 -0
  22. package/public/assets/_app.keys-C-Fk39-U.js +92 -0
  23. package/public/assets/{_app.logs-DGQD8ZAq.js → _app.logs-C7BhBRjg.js} +3 -3
  24. package/public/assets/{_app.models-D6SV_GVk.js → _app.models-BuiRrOrz.js} +4 -4
  25. package/public/assets/{_app.plugins._pluginId-CJ7ObXXe.js → _app.plugins._pluginId-Bx1LgcDj.js} +1 -1
  26. package/public/assets/_app.settings-s6K98CA2.js +88 -0
  27. package/public/assets/_app.usage-Bp45JtBe.js +76 -0
  28. package/public/assets/{chevron-right-BfnK63GB.js → chevron-right-BE-3EQR5.js} +1 -1
  29. package/public/assets/client-Bl_FA5jI.js +39 -0
  30. package/public/assets/index-nvJxJ9Gp.js +13 -0
  31. package/public/assets/{login-CrJK9wRA.js → login-Qc9iIepG.js} +2 -2
  32. package/public/assets/plus-DhyoE7aH.js +1 -0
  33. package/public/assets/{preload-helper-BknjH67x.js → preload-helper-DYShfVEU.js} +1 -1
  34. package/public/assets/{shared-oTMOLWMT.js → shared-ChaZCaBz.js} +12 -12
  35. package/public/assets/{trash-2-CSkf6ME_.js → trash-2-zGGJ7VE_.js} +1 -1
  36. package/public/index.html +5 -5
  37. package/public/assets/Rack-_A_3zqxC.js +0 -476
  38. package/public/assets/RequestTable-Cokk7wKP.js +0 -11
  39. package/public/assets/SummaryDeck-C0IbqnLz.js +0 -15
  40. package/public/assets/_app.accounts-DKmxz7Tl.js +0 -59
  41. package/public/assets/_app.index-BUqor-qH.js +0 -62
  42. package/public/assets/_app.keys-DMCPEj1g.js +0 -82
  43. package/public/assets/_app.settings-BVimpngR.js +0 -88
  44. package/public/assets/_app.usage-Y2Nkaw0t.js +0 -76
  45. package/public/assets/client-WgQ5A2PD.js +0 -39
  46. package/public/assets/index-BTE8vyBz.js +0 -13
  47. package/public/assets/plus-Cv51cK5k.js +0 -1
@@ -1,59 +0,0 @@
1
- import{A as e,Et as t,F as n,H as r,Ht as i,Lt as a,P as o,St as s,Tt as c,U as l,b as u,c as d,d as f,ft as p,h as m,it as ee,lt as h,n as g,o as _,ot as v,rt as te,s as y,t as ne,ut as b,v as x,w as S,y as C}from"./Lamp-DtHKJH6P.js";import{C as w,D as T,O as E,_ as D,a as O,b as k,i as A,o as j,r as re,t as M,v as N,x as ie}from"./Panel-BlNr9j6-.js";import{_ as P,b as F,i as ae,m as I,r as L,t as R}from"./Rack-_A_3zqxC.js";import{t as z}from"./CopyValue-CTVbU0O_.js";import{n as B,t as V}from"./chevron-right-BfnK63GB.js";import{t as oe}from"./plus-Cv51cK5k.js";import{t as se}from"./trash-2-CSkf6ME_.js";import{t as ce}from"./Toggle-ChjN-tw1.js";import{t as le}from"./Chip-CmL-9rw7.js";import{i as H,n as U,r as ue,t as W}from"./Field-DcNu4yw-.js";import{t as de}from"./Meter-stpt3vQu.js";import{i as fe,n as G,r as K,t as pe}from"./Table-CVDZ69Zx.js";import{n as me,r as he,t as ge}from"./WindowChart-BPEsEGFL.js";import{Fragment as _e,useCallback as q,useEffect as ve,useState as J}from"react";import{Fragment as Y,jsx as X,jsxs as Z}from"react/jsx-runtime";import Q from"styled-components";var ye=F(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]);function $(e){return e?.authTypes??[]}function be(e){return $(e).includes(`oauth`)?`oauth`:`apiKey`}function xe(e){return e[0]?.id??`anthropic`}var Se={oauth:`Authorize in the browser`,apiKey:`Paste an API key`};function Ce(e){let t=e?.callback;return t===void 0?`code#state`:`${t.uri}?code=…`}var we=Q.ol`
2
- display: flex;
3
- flex-direction: column;
4
- gap: ${({theme:e})=>e.space(3)};
5
- `,Te=Q.div`
6
- font-family: ${({theme:e})=>e.font.mono};
7
- font-size: 26px;
8
- letter-spacing: 0.22em;
9
- text-align: center;
10
- padding: ${({theme:e})=>e.space(3)};
11
- background: ${({theme:e})=>e.color.panelSunk};
12
- border: 1px solid ${({theme:e})=>e.color.ruleStrong};
13
- border-radius: ${({theme:e})=>e.radius.control};
14
- `,Ee=Q.p`
15
- font-size: 12px;
16
- color: ${({theme:e})=>e.color.down};
17
- `,De=Q.p`
18
- font-size: 12px;
19
- color: ${({theme:e})=>e.color.inkDim};
20
- `;function Oe({open:e,credentials:t,onOpenChange:n,onConnected:i}){let a=c().data??[],[o,s]=J(()=>xe(a)),u=r(a,o),[d,f]=J(()=>be(r(a,xe(a)))),[p,m]=J(``),h=u?.label??o,[g,_]=J(null),[y,ne]=J(``),[b,x]=J(``),S=(t??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[C,E]=J(``),[O,A]=J(``),[re,M]=J(`chat_completions`),[N,ie]=J(``),[P,F]=J(null),I=ee(),L=te(),R=v(),B=q(()=>{_(null),ne(``),x(``),E(``),A(``),M(`chat_completions`),ie(``),F(null),m(``),I.reset(),L.reset(),R.reset()},[I,L,R]),V=q(e=>{e||B(),n(e)},[n,B]);return ve(()=>{if(g===null||g.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await l(g.flowId);if(e)return;if(t.status===`complete`){B(),n(!1),i();return}}catch(t){if(e)return;F(j(t)),_(null);return}e||(r=setTimeout(()=>void t(),g.pollIntervalMs))},r=setTimeout(()=>void t(),g.pollIntervalMs);return()=>{e=!0,clearTimeout(r)}},[g,i,n,B]),X(ae,{open:e,onOpenChange:V,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:g===null?Z(Y,{children:[X(T,{type:`button`,onClick:()=>V(!1),children:`Cancel`}),X(T,{type:`button`,$variant:`primary`,disabled:I.isPending||R.isPending,onClick:()=>{if(F(null),d===`apiKey`){R.mutate({provider:o,apiKey:N,label:p.trim()||void 0,...o===`custom`?{endpointId:b,endpointLabel:C,origin:O,protocol:re}:{}},{onSuccess:()=>{B(),n(!1),i()},onError:e=>F(j(e))});return}I.mutate({provider:o,label:p.trim().length===0?h:p.trim()},{onSuccess:e=>_(e),onError:e=>F(j(e))})},children:d===`apiKey`?R.isPending?`Adding…`:`Add API key`:I.isPending?`Starting…`:`Start authorization`})]}):g.kind===`device`?X(T,{type:`button`,onClick:()=>V(!1),children:`Cancel`}):Z(Y,{children:[X(T,{type:`button`,onClick:()=>V(!1),children:`Cancel`}),X(T,{type:`button`,$variant:`primary`,disabled:L.isPending||y.trim().length===0,onClick:()=>{g!==null&&(F(null),L.mutate({flowId:g.flowId,code:y.trim()},{onSuccess:()=>{B(),n(!1),i()},onError:e=>F(j(e))}))},children:L.isPending?`Finishing…`:`Finish connecting`})]}),children:Z(we,{children:[g===null?Z(w,{$gap:3,children:[X(W,{label:`Provider`,children:e=>X(H,{...e,value:o,onChange:e=>{let t=e.target.value;s(t),f(be(r(a,t)))},children:a.map(e=>X(`option`,{value:e.id,children:e.label},e.id))})}),$(u).length>1?X(W,{label:`How to connect`,children:e=>X(H,{...e,value:d,onChange:e=>f(e.target.value),children:$(u).map(e=>X(`option`,{value:e,children:Se[e]},e))})}):null,o===`custom`?Z(Y,{children:[S.length===0?null:X(W,{label:`Existing endpoint`,children:e=>Z(H,{...e,value:b,onChange:e=>{let t=S.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){x(``),E(``),A(``),M(`chat_completions`);return}x(String(t.providerData.endpointId)),E(String(t.providerData.endpointLabel)),A(String(t.providerData.origin)+String(t.providerData.basePath??``)),M(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[X(`option`,{value:``,children:`Create new endpoint`}),S.map(e=>X(`option`,{value:String(e.providerData.endpointId),children:String(e.providerData.endpointLabel)},String(e.providerData.endpointId)))]})}),X(W,{label:`Endpoint ID`,children:e=>X(U,{...e,value:b,onChange:e=>x(e.target.value)})}),X(W,{label:`Endpoint label`,children:e=>X(U,{...e,value:C,onChange:e=>E(e.target.value)})}),X(W,{label:`Server URL`,children:e=>X(U,{...e,value:O,placeholder:`https://server.example/api`,onChange:e=>A(e.target.value)})}),O.trim().toLowerCase().startsWith(`http://`)?X(Ee,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,X(W,{label:`Protocol`,children:e=>Z(H,{...e,value:re,onChange:e=>M(e.target.value),children:[X(`option`,{value:`chat_completions`,children:`Chat Completions (/v1/chat/completions)`}),X(`option`,{value:`responses`,children:`Responses (/v1/responses)`})]})})]}):null,d===`apiKey`?X(W,{label:`API key`,children:e=>X(U,{...e,type:`password`,value:N,autoComplete:`off`,onChange:e=>ie(e.target.value)})}):null,X(W,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>X(U,{...e,value:p,placeholder:h,onChange:e=>m(e.target.value)})})]}):Z(w,{$gap:3,children:[Z(w,{$gap:1,children:[X(D,{children:`Step 1 — authorize`}),X(k,{$gap:2,children:Z(T,{as:`a`,href:g.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[X(ye,{}),`Open `,h]})}),X(z,{value:g.authorizeUrl,label:`Copy authorization link`})]}),g.userCode===null?null:Z(w,{$gap:1,children:[X(D,{children:`Step 2 — enter this code`}),X(Te,{children:g.userCode})]}),g.kind===`device`?Z(De,{children:[u?.pasteHint??``,` Waiting for authorization…`]}):X(W,{label:`Authorization code`,hint:u?.pasteHint??``,...P===null?{}:{problem:P},children:e=>X(U,{...e,value:y,autoFocus:!0,placeholder:Ce(u),onChange:e=>ne(e.target.value)})})]}),P===null||g?.kind===`pkce`?null:X(Ee,{children:P})]})})}function ke({credentialId:e,windows:n,burn:r,pollIntervalMs:i,now:a}){let o=n.map(e=>({window:e,estimate:_(r,e.windowType),since:he(u(e))})),s=o.map(e=>e.since).filter(e=>e!==null),c=s.length===0?0:Math.min(...s),l=t({credentialId:e,since:c},s.length>0),d=l.data?.samples??[],f=l.data?.gatewayRates??[];return X(w,{$gap:4,children:o.map(e=>X(Ae,{window:e.window,estimate:e.estimate,since:e.since,samples:d.filter(t=>t.windowType===e.window.windowType&&t.observedAt>=(e.since??0)),gatewayRate:f.find(t=>t.windowType===e.window.windowType),pollIntervalMs:i,now:a},e.window.windowType))})}function Ae({window:t,estimate:n,since:r,samples:i,gatewayRate:a,pollIntervalMs:o,now:s}){let c=t.limit===null?`${e(t.used)} used`:`${e(t.used)} of ${e(t.limit)} used`,l=S(t,s),d=n===void 0||f(t,s,o)||n.stale&&!l;return X(me,{live:u(t),samples:i.map(u),since:r,now:s,ratePerHourRatio:C(t,n),exhaustsAt:n?.exhaustsAt??null,survives:n?.survives??null,stale:d,rolledOver:l,spent:c,rateText:n?.ratePerHour===void 0||n.ratePerHour===null?`unknown`:`${e(n.ratePerHour)}/h`,extraFact:X(ge,{legend:`This gateway accounts for`,value:a?.gatewayRatePerHour===void 0||a.gatewayRatePerHour===null?`unknown`:`${e(a.gatewayRatePerHour)} tokens/h`})})}var je=Q(M)`
21
- border-left: 3px solid ${({$provider:e})=>I(e)};
22
- `,Me=Q(U)`
23
- width: 100%;
24
- min-width: 140px;
25
- height: 26px;
26
- font-family: ${({theme:e})=>e.font.sans};
27
- font-size: 12.5px;
28
- background: transparent;
29
- border-color: transparent;
30
-
31
- &:hover:not(:disabled),
32
- &:focus {
33
- background: ${({theme:e})=>e.color.panelSunk};
34
- border-color: ${({theme:e})=>e.color.ruleStrong};
35
- }
36
- `,Ne=Q(ue)`
37
- width: 62px;
38
- height: 26px;
39
- `,Pe=Q.span`
40
- display: block;
41
- padding-left: 9px;
42
- font-size: 11px;
43
- color: ${({theme:e})=>e.color.inkDim};
44
- `,Fe=Q.div`
45
- display: grid;
46
- /* Bar, figure, legend. The figure has a column of its own so the legends stay
47
- aligned down the stack whether a window reads 4% or 100%. */
48
- grid-template-columns: 96px 34px 1fr;
49
- align-items: center;
50
- min-width: 208px;
51
- gap: 6px;
52
- `,Ie=Q(N)`
53
- font-size: 11px;
54
- text-align: right;
55
- `,Le=Q.div`
56
- display: flex;
57
- flex-direction: column;
58
- gap: 4px;
59
- `;function Re(){let e=i();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function ze(e,t){if(t===void 0)return` The list of models could not be read, so whether any target is pinned to this account is unknown.`;let n=t.filter(t=>t.targets.some(t=>t.credentialId===e.id)).map(e=>e.id);return n.length===0?``:` ${n.length===1?`The model`:`The models`} ${n.join(`, `)} ${n.length===1?`pins a target`:`pin targets`} to this account. Those targets will fail rather than fall back to another account.`}function Be(){let{cadence:e}=P(),t=b(),i=h(e(1e4,`res:credentials`)),l=a(),u=s(),f=c(),ee=p(),{commit:v}=Re(),[te,S]=J(!1),[C,j]=J(null),[N,F]=J(new Set),ae=e=>F(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),I=Date.now(),z=t.data??[],H=f.data??[],U=e=>r(H,e)?.order??1/0,ue=[...new Set(z.map(e=>e.provider))].sort((e,t)=>U(e)-U(t)),W=e=>r(H,e)?.label??e,me=d(i.data?.health??[],e=>e.credentialId),he=d(i.data?.quota??[],e=>e.credentialId),ge=d(i.data?.burn??[],e=>e.credentialId),q=l.data?.quotaPollIntervalMs??3e5,ve=z.filter(e=>e.enabled).length,Q=t.isLoading?`Reading connected accounts…`:z.length===0?`No provider credentials are connected, so every request fails at the router.`:`${ve} of ${z.length} accounts are enabled and eligible for routing.`;return Z(Y,{children:[X(R,{legend:`Accounts`,title:`Provider accounts`,summary:Q,actions:Z(T,{type:`button`,$variant:`primary`,onClick:()=>S(!0),children:[X(oe,{}),`Connect an account`]})}),t.isError?X(M,{legend:`Accounts`,children:X(A,{error:t.error,onRetry:()=>void t.refetch()})}):t.isLoading?X(M,{legend:`Accounts`,children:X(O,{rows:5})}):z.length===0?X(M,{legend:`Accounts`,children:X(re,{legend:`Nothing connected`,message:`Connect a provider account to give the router something to dispatch to. Tokens are encrypted at rest and never shown again.`,action:X(T,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>S(!0),children:`Connect an account`})})}):X(w,{$gap:4,children:ue.map(e=>{let t=z.filter(t=>t.provider===e);return X(je,{$provider:e,legend:W(e),meta:`${t.length} account${t.length===1?``:`s`}`,flush:!0,children:X(ie,{children:Z(pe,{children:[X(`thead`,{children:Z(`tr`,{children:[X(K,{$width:`24%`,children:`Account`}),X(K,{$width:`20%`,children:`Sign-in`}),X(K,{$align:`right`,$width:`86px`,children:`Tier`}),X(K,{$align:`right`,$width:`94px`,children:`Weight`}),X(K,{$align:`center`,$width:`86px`,children:`Enabled`}),X(K,{$width:`240px`,children:`Quota`}),X(K,{$align:`right`,$width:`130px`,children:`Token expires`}),X(K,{$width:`76px`})]})}),X(`tbody`,{children:t.map(e=>{let t=y(me.get(e.id)??[],I,e.enabled,e.disabledReason),r=he.get(e.id)??[],i=ge.get(e.id)??[],a=x(r),s=N.has(e.id);return Z(_e,{children:[Z(fe,{children:[Z(G,{children:[Z(k,{$gap:2,children:[X(ne,{state:t.state,label:t.note===``?`healthy`:t.note}),X(Me,{defaultValue:e.label,"aria-label":`Label for ${e.label}`,onBlur:t=>{let n=t.target.value.trim();if(n.length===0||n===e.label){t.target.value=e.label;return}v(e.id,{label:n})}})]}),t.note===``?null:X(Pe,{children:t.note})]}),X(G,{children:Z(k,{$gap:1,children:[X(le,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:X(D,{children:e.accountEmail})]})}),X(G,{$align:`right`,children:X(Ne,{min:1,step:1,defaultValue:e.tier,"aria-label":`Tier for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isInteger(n)||n<1||n===e.tier){t.target.value=String(e.tier);return}v(e.id,{tier:n})}})}),X(G,{$align:`right`,children:X(Ne,{min:.1,step:.1,defaultValue:e.weight,"aria-label":`Weight for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isFinite(n)||n<=0||n===e.weight){t.target.value=String(e.weight);return}v(e.id,{weight:n})}})}),X(G,{$align:`center`,children:X(ce,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>v(e.id,{enabled:t})})}),X(G,{children:a.length===0?X(D,{children:`unknown`}):X(Le,{children:a.map(({window:e,fraction:t})=>Z(Fe,{children:[X(de,{fraction:t,label:`${g[e.windowType]} window, ${Math.round(t*100)}% used`}),X(Ie,{children:o(t,0)}),X(D,{children:m(e,I,q,n,_(i,e.windowType))})]},e.windowType))})}),X(G,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:n(e.expiresAt,I)}),X(G,{$align:`right`,children:Z(k,{$gap:1,$justify:`flex-end`,children:[r.length===0?null:X(E,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":s,"aria-label":`${s?`Hide`:`Show`} quota history for ${e.label}`,title:`${s?`Hide`:`Show`} quota history for ${e.label}`,onClick:()=>ae(e.id),children:X(s?B:V,{})}),X(E,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>j(e),children:X(se,{})})]})})]}),s?X(fe,{children:X(G,{colSpan:9,children:X(ke,{credentialId:e.id,windows:r,burn:i,pollIntervalMs:q,now:I})})}):null]},e.id)})})]})})},e)})}),X(Oe,{open:te,credentials:t.data??[],onOpenChange:S,onConnected:()=>void t.refetch()}),X(L,{open:C!==null,onOpenChange:e=>{e||j(null)},title:`Remove account`,body:C===null?``:`Removing "${C.label}" deletes its stored token. Any model target pointing at ${W(C.provider)} loses this account, and reconnecting means authorizing again.`+ze(C,u.data),confirmLabel:`Remove account`,busy:ee.isPending,onConfirm:()=>{C!==null&&ee.mutate(C.id,{onSettled:()=>j(null)})}})]})}var Ve=Be;export{Ve as component};
@@ -1,62 +0,0 @@
1
- import{A as e,F as t,Gt as n,I as r,Lt as i,N as a,P as o,St as s,Ut as c,c as l,f as u,h as d,i as f,k as p,lt as m,n as h,o as g,p as _,s as v,t as y,u as b,ut as x,v as ee,x as S,xt as C}from"./Lamp-DtHKJH6P.js";import{C as w,D as T,S as E,_ as D,b as O,g as k,i as A,r as j,t as M,v as N,w as P,x as F}from"./Panel-BlNr9j6-.js";import{_ as I,f as L,m as R,t as z}from"./Rack-_A_3zqxC.js";import{n as B,t as te}from"./TokenBreakdown-BPoXM3JM.js";import{n as ne,t as V}from"./Chip-CmL-9rw7.js";import{t as re}from"./Meter-stpt3vQu.js";import{i as H,n as U,r as W,t as G}from"./Table-CVDZ69Zx.js";import{t as K}from"./Readout-D8Ofl3Gz.js";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";var ie=X(P)`
2
- font-weight: 500;
3
- display: block;
4
- max-width: 24ch;
5
- `,Z=X.span`
6
- font-size: 11px;
7
- color: ${({theme:e})=>e.color.inkDim};
8
- `,ae=X.div`
9
- display: grid;
10
- grid-template-columns: 72px 1fr;
11
- align-items: center;
12
- gap: 6px;
13
- min-width: 172px;
14
- `,oe=X.div`
15
- display: flex;
16
- flex-direction: column;
17
- gap: 4px;
18
- `;function se(e){let t=null;for(let n of e)n.stale||n.survives!==!1||n.exhaustsAt===null||(t===null||n.exhaustsAt<t)&&(t=n.exhaustsAt);return t}function ce(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function le({credentials:r,health:i,quota:a,burn:o,usage:s,lastUsed:c,quotaPollIntervalMs:u,now:f}){let p=l(i,e=>e.credentialId),m=l(a,e=>e.credentialId),_=l(o,e=>e.credentialId),b=new Map(s.map(e=>[e.key,e])),x={down:0,warn:1,ok:2,idle:3,live:3},S=r.map(e=>{let t=_.get(e.id)??[];return{credential:e,status:v(p.get(e.id)??[],f,e.enabled,e.disabledReason),quota:ee(m.get(e.id)??[]),burn:t,exhaustsAt:se(t),usage:b.get(e.id)}}).sort((e,t)=>x[e.status.state]-x[t.status.state]||ce(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return J(M,{legend:`Accounts`,meta:`${r.length} connected`,flush:!0,actions:J(T,{as:n,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:r.length===0?J(j,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:J(T,{as:n,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):J(F,{children:Y(G,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Account`}),J(W,{children:`Provider`}),J(W,{$align:`right`,children:`Tier`}),J(W,{children:`Quota`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Last used`})]})}),J(`tbody`,{children:S.map(({credential:n,status:r,quota:i,burn:a,usage:o})=>Y(H,{children:[J(U,{children:Y(O,{$gap:2,children:[J(y,{state:r.state,label:r.note===``?`healthy`:r.note}),Y(`div`,{children:[J(ie,{children:n.label}),r.note===``?null:J(Z,{children:r.note})]})]})}),J(U,{children:J(ne,{provider:n.provider})}),J(U,{$align:`right`,$mono:!0,children:n.tier}),J(U,{children:i.length===0?J(Z,{children:`unknown`}):J(oe,{children:i.map(({window:e,fraction:n})=>Y(ae,{children:[J(re,{fraction:n,label:`${h[e.windowType]} window, ${Math.round(n*100)}% used`}),J(D,{children:d(e,f,u,t,g(a,e.windowType))})]},e.windowType))})}),J(U,{$align:`right`,$mono:!0,children:o===void 0?`—`:e(o.requests)}),J(U,{$align:`right`,$mono:!0,children:t(c[n.id]??null,f)})]},n.id))})]})})})}var ue=X.ul`
19
- display: flex;
20
- flex-direction: column;
21
- `,de=X.li`
22
- display: flex;
23
- align-items: center;
24
- gap: ${({theme:e})=>e.space(2)};
25
- padding: 6px ${({theme:e})=>e.space(3)};
26
- border-bottom: 1px solid ${({theme:e})=>e.color.rule};
27
-
28
- &:last-child {
29
- border-bottom: 0;
30
- }
31
- `,fe=X(P)`
32
- font-family: ${({theme:e})=>e.font.mono};
33
- font-size: 12px;
34
- max-width: 30ch;
35
- `,pe=X(N)`
36
- color: ${({theme:e})=>e.color.down};
37
- font-size: 11px;
38
- `;function me({logs:e}){let t=e.slice(0,12);return J(M,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:J(T,{as:n,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?J(j,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):J(ue,{children:t.map(e=>Y(de,{children:[J(y,{state:_(e),label:u(e)}),J(N,{$dim:!0,children:p(e.at)}),J(fe,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:J(N,{$dim:!0,style:{color:R(e.resolvedProvider)},children:e.resolvedProvider}),J(E,{}),b(e)?J(N,{$dim:!0,"aria-label":`processing`,children:J(te,{})}):Y(q,{children:[e.errorCode===null?null:J(pe,{children:e.errorCode}),e.attempts>1?Y(N,{$dim:!0,children:[e.attempts,`×`]}):null,J(N,{$dim:!0,children:J(B,{tokens:e})}),J(N,{$dim:!0,children:a(e.durationMs)}),J(N,{$dim:!0,children:r(e.costUsd)})]})]},e.id))})})}var Q=X.ul`
39
- display: flex;
40
- flex-direction: column;
41
- gap: ${({theme:e})=>e.space(3)};
42
- `,he=X(P)`
43
- font-family: ${({theme:e})=>e.font.mono};
44
- font-size: 12.5px;
45
- `,ge=X.div`
46
- display: flex;
47
- height: 5px;
48
- border-radius: 2px;
49
- overflow: hidden;
50
- background: ${({theme:e})=>e.color.panelSunk};
51
- border: 1px solid ${({theme:e})=>e.color.rule};
52
- `,_e=X.div`
53
- flex: ${({$grow:e})=>e} 0 0;
54
- background: ${({$color:e})=>e};
55
- opacity: 0.8;
56
- `,ve=X.div`
57
- flex: ${({$grow:e})=>e} 0 0;
58
- `;function ye({models:t,logs:i}){let a=new Map;for(let e of i){let t=a.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,a.set(e.requestedModel,t)}let o=Math.max(1,...[...a.values()].map(e=>e.requests)),s=[...t].map(e=>({model:e,used:a.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return J(M,{legend:`Models`,meta:`${t.length} configured`,actions:J(T,{as:n,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.length===0?J(j,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:J(T,{as:n,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):J(Q,{children:s.map(({model:t,used:n})=>{let i=(n?.requests??0)/o,a=[...new Set(t.targets.map(e=>e.provider))];return Y(`li`,{children:[Y(O,{$gap:2,children:[J(he,{title:t.id,children:t.id}),t.isAlias?J(V,{children:`alias`}):null,J(V,{$tone:`accent`,children:t.strategy}),J(E,{}),J(N,{$dim:!0,children:e(n?.requests??0)}),J(D,{children:`req`}),J(N,{$dim:!0,children:r(n?.costUsd??0)})]}),Y(ge,{style:{marginTop:6},title:`${Math.round(i*100)}% of the busiest model`,children:[a.map(e=>J(_e,{$color:R(e),$grow:i/a.length},e)),J(ve,{$grow:Math.max(0,1-i)})]})]},t.id)})})})}var be=X.div`
59
- display: grid;
60
- grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
61
- gap: ${({theme:e})=>e.space(3)};
62
- `;function xe({logs:t,windowMs:n,now:i}){let s=t.filter(e=>i-e.at<=n),c=S(s,n),l=f(s,{now:i,spanMs:n,count:32}),u=c.errorRate>=.25?`down`:c.errorRate>=.05?`warn`:`ok`,d=c.inputTokens+c.outputTokens+c.cacheReadTokens+c.cacheWriteTokens;return Y(be,{children:[J(K,{legend:`Requests`,value:e(c.requests),unit:`${c.ratePerMin.toFixed(1)}/min`,trace:J(L,{values:l.map(e=>e.total),overlay:l.map(e=>e.errors),label:`${c.requests} requests, ${c.errors} of them failed`})}),J(K,{legend:`Error rate`,value:o(c.errorRate),unit:`${e(c.errors)} failed`,tone:c.requests===0?`ink`:u,trace:J(L,{values:l.map(e=>e.errors),scaleTo:Math.max(...l.map(e=>e.total)),color:`var(--down)`,label:`${c.errors} failed requests against ${c.requests} total`})}),J(K,{legend:`Total tokens`,value:e(d),unit:J(B,{tokens:c}),trace:J(L,{values:l.map(e=>e.tokens),label:`token volume over the window, ${d.toLocaleString(`en-US`)} total`})}),J(K,{legend:`Time to first token`,value:a(c.ttftP50),unit:`p95 ${a(c.ttftP95)}`,trace:J(L,{values:l.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${a(c.ttftP50)}`})}),J(K,{legend:`Spend`,value:r(c.costUsd),unit:`${e(c.inputTokens+c.outputTokens)} tokens`,trace:J(L,{values:l.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${r(c.costUsd)} total`})})]})}var $=36e5;function Se(){let{cadence:e}=I(),t=x(),n=m(e(1e4,`res:credentials`)),r=s(),a=C(500,e(1e4,`res:logs`)),o=i(),u=Date.now(),d=Math.floor((u-$)/6e4)*6e4,f=c({groupBy:`credential`,since:d},e(6e4,`res:usage`)),p=t.data??[],h=l(n.data?.health??[],e=>e.credentialId),g=p.filter(e=>v(h.get(e.id)??[],u,e.enabled,e.disabledReason).state===`down`),_=t.isLoading||a.isLoading?`Reading the gateway…`:p.length===0?`No accounts are connected, so every request fails at the router.`:g.length>0?`${g.length} account${g.length===1?` is`:`s are`} out of rotation.`:`All ${p.length} accounts are answering. Nothing needs attention.`;return Y(q,{children:[J(z,{legend:`Rack`,title:`Gateway`,summary:_}),a.isError?J(M,{legend:`Traffic`,children:J(A,{legend:`The gateway did not answer`,error:a.error,onRetry:()=>void a.refetch()})}):Y(w,{$gap:4,children:[J(xe,{logs:a.data??[],windowMs:$,now:u}),J(le,{credentials:p,health:n.data?.health??[],quota:n.data?.quota??[],burn:n.data?.burn??[],usage:f.data??[],lastUsed:n.data?.lastUsed??{},quotaPollIntervalMs:o.data?.quotaPollIntervalMs??3e5,now:u}),Y(k,{$min:`340px`,$gap:4,children:[J(ye,{models:r.data??[],logs:a.data??[]}),J(me,{logs:a.data??[]})]})]})]})}var Ce=Se;export{Ce as component};
@@ -1,82 +0,0 @@
1
- import{At as e,Ft as t,Pt as n,St as r,_t as i,j as a,st as o}from"./Lamp-DtHKJH6P.js";import{C as s,D as c,O as l,_ as u,a as d,b as f,i as p,o as m,r as h,t as g,v as _,w as v,x as y}from"./Panel-BlNr9j6-.js";import{b,i as x,r as S,t as C,v as w}from"./Rack-_A_3zqxC.js";import{t as T}from"./CopyValue-CTVbU0O_.js";import{n as E,t as D}from"./chevron-right-BfnK63GB.js";import{t as O}from"./plus-Cv51cK5k.js";import{t as k}from"./Toggle-ChjN-tw1.js";import{t as A}from"./Chip-CmL-9rw7.js";import{n as j,r as M,t as N}from"./Field-DcNu4yw-.js";import{t as P}from"./Meter-stpt3vQu.js";import{i as F,n as I,r as L,t as ee}from"./Table-CVDZ69Zx.js";import{Fragment as R,useState as z}from"react";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import U from"styled-components";var te=b(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),W=[{dimension:`requests`,window:`1m`},{dimension:`requests`,window:`5h`},{dimension:`requests`,window:`1w`},{dimension:`tokens`,window:`1m`},{dimension:`tokens`,window:`5h`},{dimension:`tokens`,window:`1w`},{dimension:`spend`,window:`5h`},{dimension:`spend`,window:`1w`},{dimension:`concurrency`,window:null}];function G(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var ne={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},re={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=ne[e.dimension];return e.window===null?t:`${t} ${re[e.window]}`}function q(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function J(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function ie(e){let t=null,n=-1;for(let r of e){let e=J(r);e!==null&&e>n&&(t=r,n=e)}return t}function Y(e){let t={};for(let e of W)t[G(e)]=``;if(e===null)return t;for(let n of W){let r=n.window===null?e.concurrency:n.dimension===`requests`?e.requests?.[n.window]:n.dimension===`tokens`?e.tokens?.[n.window]:n.window===`1m`?void 0:e.spend?.[n.window];r!=null&&(t[G(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of W){let o=(e[G(a)]??``).trim();if(o.length===0)continue;let s=Number(o),c=a.dimension===`spend`;if(!Number.isFinite(s)||s<=0||!c&&!Number.isInteger(s))return{problem:c?`${K(a)} must be an amount above zero, or blank for no limit.`:`${K(a)} must be a whole number above zero, or blank for no limit.`};a.window===null?i=s:a.dimension===`requests`?t[a.window]=s:a.dimension===`tokens`?n[a.window]=s:a.window!==`1m`&&(r[a.window]=s)}return{limits:{...Object.keys(t).length>0?{requests:t}:{},...Object.keys(n).length>0?{tokens:n}:{},...Object.keys(r).length>0?{spend:r}:{},...i===void 0?{}:{concurrency:i}}}}var ae=U.div`
2
- display: grid;
3
- grid-template-columns: repeat(3, minmax(0, 1fr));
4
- gap: ${({theme:e})=>e.space(2)};
5
- `,oe=U.p`
6
- font-size: 11px;
7
- color: ${({theme:e})=>e.color.inkDim};
8
- `;function Z({draft:e,onChange:t,disabled:n=!1}){return H(s,{$gap:2,children:[V(ae,{children:W.map(r=>{let i=G(r);return V(N,{label:K(r),children:a=>V(M,{...a,min:r.dimension===`spend`?void 0:1,step:r.dimension===`spend`?`any`:1,disabled:n,value:e[i]??``,placeholder:`none`,onChange:n=>t({...e,[i]:n.target.value})})},i)})}),V(oe,{children:`Blank means no limit. Token and spend ceilings are debited after a response completes, so a key at its ceiling is refused on its next request rather than its current one. Concurrency counts requests in flight right now and resets when the gateway restarts.`})]})}var se=U.p`
9
- font-size: 12px;
10
- color: ${({theme:e})=>e.color.down};
11
- `,ce=U.p`
12
- font-size: 12px;
13
- color: ${({theme:e})=>e.color.warn};
14
- `;function le({apiKey:e,onOpenChange:t}){let r=n(),[i,a]=z(()=>Y(e?.limits??{})),[o,l]=z(null);return V(x,{open:e!==null,onOpenChange:t,title:`Edit limits`,description:e===null?void 0:`What "${e.label}" may do per minute, per five hours, and per week. Every field is a ceiling; blank is no limit.`,width:`640px`,footer:H(B,{children:[V(c,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{if(e===null)return;let n=X(i);if(`problem`in n){l(n.problem);return}l(null),r.mutate({id:e.id,limits:n.limits},{onSuccess:()=>t(!1),onError:e=>l(m(e))})},children:r.isPending?`Saving…`:`Save limits`})]}),children:H(s,{$gap:3,children:[e?.limits===null?V(ce,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,V(Z,{draft:i,onChange:a,disabled:r.isPending}),o===null?null:V(se,{role:`alert`,children:o})]})})}var ue=U.div`
15
- display: flex;
16
- flex-direction: column;
17
- gap: 2px;
18
- max-height: 190px;
19
- overflow-y: auto;
20
- padding: ${({theme:e})=>e.space(1)};
21
- border: 1px solid ${({theme:e})=>e.color.ruleStrong};
22
- border-radius: ${({theme:e})=>e.radius.control};
23
- background: ${({theme:e})=>e.color.panelSunk};
24
- `,de=U.label`
25
- display: flex;
26
- align-items: center;
27
- gap: ${({theme:e})=>e.space(2)};
28
- padding: 4px 6px;
29
- border-radius: 2px;
30
- cursor: pointer;
31
- font-family: ${({theme:e})=>e.font.mono};
32
- font-size: 12px;
33
-
34
- &:hover {
35
- background: ${({theme:e})=>e.color.panelRaised};
36
- }
37
- `,fe=U.p`
38
- font-size: 11px;
39
- color: ${({theme:e})=>e.color.inkDim};
40
- `;function Q({configured:e,checked:t,onChange:n,disabled:r}){let i=[...new Set([...e,...t])].sort(),a=(e,r)=>{n(r?[...t,e]:t.filter(t=>t!==e))},o=t.filter(t=>!e.includes(t));return H(`div`,{children:[V(ue,{children:i.map(e=>H(de,{children:[V(`input`,{type:`checkbox`,disabled:r,"aria-label":e,checked:t.includes(e),onChange:t=>a(e,t.target.checked)}),e]},e))}),o.length>0?V(fe,{children:`Some listed models are no longer configured. They stay until you clear them.`}):null,t.length===0?V(u,{children:`With nothing selected this key is allowed no model.`}):null]})}var pe=U.p`
41
- font-size: 12px;
42
- color: ${({theme:e})=>e.color.down};
43
- `;function me({apiKey:e,onOpenChange:n}){let i=t(),a=r(),[o,l]=z(e?.modelAllowlist===null),[d,p]=z(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[h,g]=z(null),_=(a.data??[]).map(e=>e.id);return V(x,{open:e!==null,onOpenChange:n,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:H(B,{children:[V(c,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:i.isPending,onClick:()=>{e!==null&&(g(null),i.mutate({id:e.id,modelAllowlist:o?null:d},{onSuccess:()=>n(!1),onError:e=>g(m(e))}))},children:i.isPending?`Saving…`:`Save models`})]}),children:H(s,{$gap:3,children:[H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:o,label:`Allow every model`,onCheckedChange:e=>{l(e),e&&p([])}}),V(u,{as:`span`,children:`Allow every model`})]}),o?null:V(Q,{configured:_,checked:d,onChange:p,disabled:i.isPending})]}),h===null?null:V(pe,{role:`alert`,children:h})]})})}var he=U.div`
44
- display: grid;
45
- grid-template-columns: minmax(0, 11rem) minmax(0, 12rem) minmax(0, 1fr) minmax(0, 3.5rem);
46
- align-items: center;
47
- gap: ${({theme:e})=>e.space(2)} ${({theme:e})=>e.space(4)};
48
- `,ge=U.span`
49
- font-size: 11.5px;
50
- color: ${({theme:e})=>e.color.inkDim};
51
- `,_e=U.p`
52
- font-size: 11px;
53
- color: ${({theme:e})=>e.color.inkDim};
54
- `;function ve({label:e,readings:t}){return H(s,{$gap:3,children:[V(he,{children:t.map(t=>{let n=K({dimension:t.dimension,window:t.window}),r=J(t),i=q(t.dimension,t.limit);return H(R,{children:[V(u,{as:`span`,children:n}),V(_,{children:t.used===null?i:`${q(t.dimension,t.used)} of ${i}`}),r===null?V(ge,{children:`in flight now, counted in the gateway process`}):V(P,{fraction:Math.min(1,r),label:`${e}, ${n}, ${Math.round(r*100)}% used`}),V(_,{children:r===null?`—`:`${Math.round(r*100)}%`})]},n)})}),V(_e,{children:`Usage counts completed requests still inside each window. Requests in flight are added by the gateway itself and are not shown here.`})]})}var ye=U.p`
55
- font-size: 12px;
56
- color: ${({theme:e})=>e.color.warn};
57
- `,be=U.p`
58
- font-size: 11px;
59
- color: ${({theme:e})=>e.color.inkDim};
60
- `,xe=U.p`
61
- font-size: 12px;
62
- color: ${({theme:e})=>e.color.down};
63
- `,$=U.p`
64
- font-size: 12px;
65
- color: ${({theme:e})=>e.color.inkDim};
66
- `,Se=U(c)`
67
- gap: 4px;
68
- `;function Ce({open:e,onOpenChange:t}){let n=r(),i=o(),[a,l]=z(``),[d,p]=z(!0),[h,g]=z([]),[v,y]=z(()=>Y({})),[b,S]=z(!1),[C,w]=z(!1),[O,A]=z(null),[M,P]=z(null),F=()=>{l(``),p(!0),g([]),y(Y({})),S(!1),w(!1),A(null),P(null),i.reset()},I=e=>{e||F(),t(e)},L=Object.values(v).filter(e=>e.trim().length>0).length;return V(x,{open:e,onOpenChange:I,title:O===null?`Create an API key`:`Key created`,description:O===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:O===null?H(B,{children:[V(c,{type:`button`,onClick:()=>I(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:i.isPending,onClick:()=>{let e=X(v);if(`problem`in e){S(!0),P(e.problem);return}P(null),i.mutate({label:a.trim().length===0?`api key`:a.trim(),modelAllowlist:d?null:h,limits:e.limits,bodyLoggingOptOut:C},{onSuccess:e=>A(e),onError:e=>P(m(e))})},children:i.isPending?`Creating…`:`Create key`})]}):V(c,{type:`button`,$variant:`primary`,onClick:()=>I(!1),children:`I have copied the key`}),children:O===null?H(s,{$gap:3,children:[V(N,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>V(j,{...e,value:a,placeholder:`api key`,onChange:e=>l(e.target.value)})}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:d,label:`Allow every model`,onCheckedChange:p}),V(u,{as:`span`,children:`Allow every model`})]}),d?null:H(B,{children:[V(Q,{configured:(n.data??[]).map(e=>e.id),checked:h,onChange:g}),h.length===0?V(ye,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[H(Se,{type:`button`,$size:`sm`,"aria-expanded":b,onClick:()=>S(e=>!e),children:[V(b?E:D,{}),`Limits`]}),V(u,{as:`span`,children:L===0?`no limits; this key is unbounded`:`${L} limit${L===1?``:`s`} set`})]}),b?V(Z,{draft:v,onChange:y}):null]}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:C,label:`Never record this key's bodies`,onCheckedChange:w}),V(u,{as:`span`,children:`Never record this key's bodies`})]}),V(be,{children:`Suppresses body capture for this key whatever the gateway setting says. Choose it for a client whose payloads must not be retained. It cannot be changed after the key is created — issue a new key instead.`})]}),M===null?null:V(xe,{role:`alert`,children:M})]}):H(s,{$gap:3,children:[V($,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),V(T,{value:O.key,label:`Copy API key`}),H(f,{$gap:2,children:[V(u,{children:`Label`}),V(_,{children:O.label}),V(u,{children:`Prefix`}),V(_,{children:O.prefix})]})]})})}var we=U(f)`
69
- gap: 4px;
70
- flex-wrap: wrap;
71
- max-width: 34ch;
72
- `,Te=U.span`
73
- color: ${({theme:e})=>e.color.inkFaint};
74
- `,Ee=U.span`
75
- font-size: 11px;
76
- color: ${({theme:e})=>e.color.inkDim};
77
- `,De=U.div`
78
- display: flex;
79
- flex-direction: column;
80
- align-items: flex-end;
81
- gap: 2px;
82
- `;function Oe(e){if(e===null)return`usage not counted here`;let t=J(e);return`${K({dimension:e.dimension,window:e.window})} ${q(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ke(){let t=i(),n=e(),[r,o]=z(!1),[s,m]=z(null),[_,b]=z(null),[x,T]=z(null),[k,j]=z(null),M=t.data??[],N=M.filter(e=>e.revokedAt===null),P=t.isLoading?`Reading issued keys…`:M.length===0?`No keys exist, so nothing can call this gateway yet.`:`${N.length} active key${N.length===1?``:`s`} of ${M.length} ever issued.`;return H(B,{children:[V(C,{legend:`Keys`,title:`Gateway API keys`,summary:P,actions:H(c,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[V(O,{}),`Create a key`]})}),V(g,{legend:`Issued keys`,meta:`${M.length}`,flush:!0,children:t.isError?V(p,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?V(`div`,{style:{padding:12},children:V(d,{rows:4})}):M.length===0?V(h,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:V(c,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):V(y,{children:H(ee,{children:[V(`thead`,{children:H(`tr`,{children:[V(L,{children:`Label`}),V(L,{children:`Prefix`}),V(L,{children:`Allowed models`}),V(L,{$align:`right`,children:`Limits`}),V(L,{$align:`right`,children:`Created`}),V(L,{children:`Body capture`}),V(L,{children:`Status`}),V(L,{})]})}),V(`tbody`,{children:M.map(e=>{let t=x===e.id,n=ie(e.limitUsage);return H(R,{children:[H(F,{children:[V(I,{children:V(v,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),H(I,{$mono:!0,children:[e.prefix,`…`]}),V(I,{children:e.modelAllowlist===null?V(u,{children:`every model`}):e.modelAllowlist.length===0?V(A,{$tone:`down`,children:`no models`}):V(we,{children:e.modelAllowlist.map(e=>V(A,{children:e},e))})}),V(I,{$align:`right`,children:e.limits===null?V(A,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?V(u,{children:`no limits`}):H(De,{children:[H(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),V(Ee,{children:Oe(n)})]})}),V(I,{$align:`right`,$mono:!0,children:a(e.createdAt)}),V(I,{children:e.bodyLoggingOptOut?V(A,{children:`no bodies`}):V(u,{children:`—`})}),V(I,{children:e.revokedAt===null?V(A,{$tone:`ok`,children:`active`}):V(Te,{title:a(e.revokedAt),children:V(A,{children:`revoked`})})}),V(I,{$align:`right`,children:H(f,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} limits for ${e.label}`,title:`${t?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>T(t?null:e.id),children:V(t?E:D,{})}),e.revokedAt===null?H(B,{children:[V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>b(e),children:V(te,{})}),V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>m(e),children:V(w,{})}),V(c,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>j(e),children:`Revoke`})]}):null]})})]}),t?V(F,{children:V(I,{colSpan:8,children:V(ve,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),V(Ce,{open:r,onOpenChange:o}),V(le,{apiKey:s,onOpenChange:e=>{e||m(null)}},s?.id??`none`),V(me,{apiKey:_,onOpenChange:e=>{e||b(null)}},_?.id??`none`),V(S,{open:k!==null,onOpenChange:e=>{e||j(null)},title:`Revoke key`,body:k===null?``:`Revoking "${k.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:n.isPending,onConfirm:()=>{k!==null&&n.mutate(k.id,{onSettled:()=>j(null)})}})]})}var Ae=ke;export{Ae as component};
@@ -1,88 +0,0 @@
1
- import{It as e,J as t,K as n,Lt as r,Nt as i,St as a,Vt as o,Y as s}from"./Lamp-DtHKJH6P.js";import{C as c,D as l,S as u,_ as d,a as f,b as p,g as m,h,i as g,o as _,t as v,v as y}from"./Panel-BlNr9j6-.js";import{t as ee}from"./Rack-_A_3zqxC.js";import{t as b}from"./Toggle-ChjN-tw1.js";import{i as x,n as S,t as C}from"./Field-DcNu4yw-.js";import{t as te}from"./Meter-stpt3vQu.js";import{n as w}from"./reasons-Du1OBWAM.js";import{useEffect as ne,useId 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
- `,re=A.p`
9
- font-size: 12px;
10
- color: ${({theme:e})=>e.color.ok};
11
- `,P=A(c)`
12
- max-width: 320px;
13
- `,F=A(d)`
14
- color: ${({theme:e})=>e.color.inkDim};
15
- `;function I(){let e=s(),[t,n]=E(``),[r,i]=E(``),[a,o]=E(``),[u,d]=E(null);return k(c,{$gap:2,children:[O(F,{children:`Admin password`}),O(M,{children:`Changing this signs every session out, including this one.`}),k(P,{$gap:2,children:[O(C,{label:`Current password`,children:e=>O(S,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),O(C,{label:`New password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),O(C,{label:`Repeat new password`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:a,onChange:e=>o(e.target.value)})}),O(p,{$gap:2,children:O(l,{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(_(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 t=o(),n=e(),[r,i]=E(``),[a,s]=E(null),[u,d]=E(null),f=t.data?.viewerConfigured===!0;return k(c,{$gap:2,children:[O(F,{children:`Read-only password`}),k(M,{children:[`Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies.`,` `,t.isPending?`Checking whether one is set…`:f?`One is set. A new one replaces it; withdrawing ends read-only sessions at once.`:`None is set, so nobody can sign in read-only. There is no default password.`]}),k(P,{$gap:2,children:[O(C,{label:f?`Replace read-only password`:`Set read-only password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),k(p,{$gap:2,children:[O(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<j){s(`A password must be at least ${j} characters.`);return}s(null),n.mutate(r,{onSuccess:()=>{i(``),d(f?`Read-only password replaced.`:`Read-only access granted.`)},onError:e=>s(_(e))})},disabled:n.isPending||r.length===0,children:f?`Replace`:`Set`}),f?O(l,{type:`button`,$variant:`danger`,onClick:()=>{s(null),n.mutate(null,{onSuccess:()=>d(`Read-only access withdrawn.`),onError:e=>s(_(e))})},disabled:n.isPending,children:`Withdraw access`}):null]})]}),a===null?null:O(N,{role:`alert`,children:a}),u===null||a!==null?null:O(re,{role:`status`,children:u})]})}function R(){return O(v,{legend:`Access`,children:k(c,{$gap:3,children:[O(I,{}),O(h,{}),O(L,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],ie=A(y)`
16
- display: block;
17
- white-space: pre;
18
- overflow-x: auto;
19
- padding: 0.75rem;
20
- background: ${({theme:e})=>e.color.panelSunk};
21
- border: 1px solid ${({theme:e})=>e.color.rule};
22
- border-radius: 4px;
23
- font-size: 0.8125rem;
24
- line-height: 1.5;
25
- `,ae=A.div`
26
- color: ${({theme:e})=>e.color.inkDim};
27
- font-size: 0.8125rem;
28
- margin-bottom: 0.25rem;
29
- `,B=A.p`
30
- color: ${({theme:e})=>e.color.inkDim};
31
- font-size: 0.8125rem;
32
- margin: 0;
33
- `,oe=A.div`
34
- display: grid;
35
- grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
36
- gap: ${({theme:e})=>e.space(2)};
37
- `,se=[{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 V(){let[e,t]=E(`claude`),[r,i]=E(()=>({claude:{},opencode:{}})),o=a(),s=r[e],u=typeof s.defaultModel==`string`&&s.defaultModel!==``?s:void 0,d=n(e,u),m=z.find(t=>t.id===e);return O(v,{legend:`Agent setup`,children:k(c,{children:[O(p,{children:z.map(n=>O(l,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),k(B,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,k(y,{children:[`omni setup `,e]}),` to write these files directly.`]}),(o.data?.length??0)>0?O(oe,{children:se.map(t=>O(C,{label:t.label,children:n=>k(x,{...n,value:s[t.key]??``,onChange:n=>i(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[O(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),o.data?.map(e=>O(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,o.isLoading?O(f,{rows:2}):d.isError?O(g,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?O(f,{rows:4}):(o.data?.length??0)===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?k(B,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>k(`div`,{children:[O(ae,{children:e.path}),O(ie,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?O(B,{children:_(d.error)}):null]})})}var H={off:`Off`,lite:`Lite — names the lazier option`,full:`Full — the ladder enforced`,ultra:`Ultra — challenges the requirement`},U=[{id:`tier`,label:`Tier`,blurb:`Prefers a lower tier.`},{id:`health`,label:`Health`,blurb:`Penalises recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Prefers accounts ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Prefers the cheaper candidate.`},{id:`latency`,label:`Latency`,blurb:`Prefers the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Prefers accounts with fewer requests in flight.`}],W=[{id:`maxAttempts`,label:`Attempts per request`,hint:`Candidates dispatch may try. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`Across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures before an account and model leaves rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Wait before a tripped account is probed. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before pruning.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often a provider is asked for remaining quota. 0 disables. Needs a restart.`,unit:`ms`,step:6e4,min:0}],G=A.div`
38
- display: grid;
39
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
40
- gap: ${({theme:e})=>e.space(3)};
41
- `,K=A(c)`
42
- gap: 6px;
43
- `,q=A.p`
44
- font-size: 11px;
45
- color: ${({theme:e})=>e.color.inkDim};
46
- `,J=A.div`
47
- display: grid;
48
- grid-template-columns: 1fr;
49
- gap: ${({theme:e})=>e.space(2)};
50
- align-items: start;
51
- `,Y=A.div`
52
- display: grid;
53
- grid-template-columns: auto 1fr;
54
- column-gap: ${({theme:e})=>e.space(2)};
55
- row-gap: 4px;
56
- align-items: center;
57
- padding: ${({theme:e})=>e.space(2)};
58
- background: ${({theme:e})=>e.color.panelSunk};
59
- border: 1px solid ${({theme:e})=>e.color.rule};
60
- border-radius: 3px;
61
- `,X=A(q)`
62
- grid-column: 2;
63
- `,Z=A.label`
64
- font-size: 12px;
65
- font-weight: 600;
66
- color: ${({theme:e})=>e.color.ink};
67
- cursor: pointer;
68
- `,ce=A(Y)`
69
- grid-template-columns: 1fr;
70
-
71
- ${X} {
72
- grid-column: 1;
73
- }
74
- `;function le({label:e,children:t,blurb:n}){let r=T();return k(ce,{children:[O(Z,{htmlFor:r,children:e}),t({id:r}),O(X,{children:n})]})}function Q({label:e,checked:t,disabled:n,onCheckedChange:r,children:i}){let a=T();return k(Y,{children:[O(b,{id:a,checked:t,onCheckedChange:r,label:e,...n===void 0?{}:{disabled:n}}),O(Z,{htmlFor:a,children:e}),O(X,{children:i})]})}var $=A.p`
75
- font-size: 12px;
76
- color: ${({theme:e})=>e.color.down};
77
- `,ue=A.p`
78
- font-size: 12px;
79
- color: ${({theme:e})=>e.color.ok};
80
- `,de=A.p`
81
- font-size: 12px;
82
- color: ${({theme:e})=>e.color.warn};
83
- max-width: 72ch;
84
-
85
- code {
86
- font-family: ${({theme:e})=>e.font.mono};
87
- }
88
- `;function fe(e){let t={};for(let n of U)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of W)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.ponytailMode=e.ponytailMode,t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function pe(e){let t={};for(let n of U){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 W){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`,ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(H,e.ponytailMode)?e.ponytailMode:`off`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function me(){let e=r(),n=t(),a=i(),[o,s]=E({}),[h,b]=E(null),[w,T]=E(!1);ne(()=>{e.data!==void 0&&s(fe(e.data))},[e.data]);let A=Math.max(1e-4,...U.map(e=>Math.abs(Number(o[`w.${e.id}`])||0)));return k(D,{children:[O(ee,{legend:`Settings`,title:`Routing and retention`,summary:`Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.`,actions:O(l,{type:`button`,$variant:`primary`,disabled:a.isPending||e.isLoading,onClick:()=>{T(!1);let e=pe(o);if(!e.ok){b(e.problem);return}b(null),a.mutate(e.settings,{onSuccess:()=>T(!0),onError:e=>b(_(e))})},children:a.isPending?`Saving…`:`Save changes`})}),e.isError?O(v,{legend:`Settings`,children:O(g,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?O(v,{legend:`Settings`,children:O(f,{rows:6})}):k(c,{$gap:4,children:[O(v,{legend:`Scoring weights`,meta:`relative to each other`,footer:k(p,{children:[O(d,{children:`Score is the sum of each term times its weight, then multiplied by the account and target weights.`}),O(u,{})]}),children:O(G,{children:U.map(e=>{let t=Number(o[`w.${e.id}`])||0;return k(K,{children:[O(C,{label:e.label,children:t=>O(S,{...t,type:`number`,step:.5,value:o[`w.${e.id}`]??``,onChange:t=>s({...o,[`w.${e.id}`]:t.target.value})})}),O(te,{fraction:Math.abs(t)/A,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),O(q,{children:e.blurb})]},e.id)})})}),O(v,{legend:`Limits`,children:O(G,{children:W.map(e=>O(K,{children:O(C,{label:e.label,hint:e.hint,children:t=>k(p,{$gap:2,children:[O(S,{...t,type:`number`,min:e.min,step:e.step,value:o[e.id]??``,onChange:t=>s({...o,[e.id]:t.target.value})}),O(d,{children:e.unit})]})})},e.id))})}),k(m,{$min:`380px`,$stretch:!0,children:[O(v,{legend:`Request handling`,meta:`applied before dispatch`,children:k(J,{children:[O(Q,{label:`Enable RTK compression`,checked:o.rtkEnabled===`true`,onCheckedChange:e=>s({...o,rtkEnabled:String(e)}),children:`Compresses recognized historical tool results. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a detector recognizes shell output. Lossy.`}),O(Q,{label:`Add a cache breakpoint when a client sends none`,checked:o.autoCacheEnabled===`true`,onCheckedChange:e=>s({...o,autoCacheEnabled:String(e)}),children:`Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched.`}),O(le,{label:`Lazy senior dev mode`,blurb:`Appends the ponytail ruleset, about 1,240 tokens, to every system prompt. A request already carrying it is left alone.`,children:e=>O(x,{...e,value:o.ponytailMode??`off`,onChange:e=>s({...o,ponytailMode:e.target.value}),children:Object.entries(H).map(([e,t])=>O(`option`,{value:e,children:t},e))})})]})}),O(v,{legend:`Request and response bodies`,meta:n.data===!0?`permitted by the environment`:`not permitted`,children:k(c,{$gap:2,children:[n.data===!0?null:k(de,{children:[`This gateway 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 first.`]}),k(J,{children:[O(Q,{label:`Capture request and response bodies`,checked:o.bodyLoggingEnabled===`true`,disabled:n.data!==!0,onCheckedChange:e=>s({...o,bodyLoggingEnabled:String(e)}),children:`Stores what each client sent and each provider returned, encrypted beside the database. Tokens and keys are masked; headers are never captured. Expires on the log retention window above.`}),O(Q,{label:`Also keep raw stream frames`,checked:o.bodyLoggingCaptureStreamChunks===`true`,disabled:n.data!==!0||o.bodyLoggingEnabled!==`true`,onCheckedChange:e=>s({...o,bodyLoggingCaptureStreamChunks:String(e)}),children:`Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores.`})]})]})})]}),h===null?null:O($,{role:`alert`,children:h}),w&&h===null?O(ue,{role:`status`,children:`Settings saved.`}):null,k(m,{$min:`380px`,$stretch:!0,children:[O(V,{}),O(R,{})]}),O(v,{legend:`Known limits`,children:k(c,{$gap:2,children:[k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`rate limits`}),O(q,{children:`Counted per gateway process and reset when it restarts. Not shared across instances.`})]}),k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`logs`}),O(q,{children:`Request rows record routing and token counts only. Prompts and responses only when body capture is on, to a separate encrypted store. Credentials to neither.`})]})]})})]})]})}var he=me;export{he as component};
@@ -1,76 +0,0 @@
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-oTMOLWMT.js";import{A as I,H as Je,I as L,N as Ye,P as Xe,St as Ze,Tt as Qe,Ut as R,_t as $e,ut as et}from"./Lamp-DtHKJH6P.js";import{C as z,_ as tt,b as B,g as nt,t as rt,v as V,w as it,x as at}from"./Panel-BlNr9j6-.js";import{_ as ot,f as st,m as ct,t as lt}from"./Rack-_A_3zqxC.js";import{i as ut,n as H,r as U,t as dt}from"./Table-CVDZ69Zx.js";import{i as W,n as ft,r as pt,t as mt}from"./SummaryDeck-C0IbqnLz.js";import*as G from"react";import{PureComponent as ht,forwardRef as gt,useMemo as K,useRef as _t,useState as q}from"react";import{jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";function vt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function yt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var bt=(e,t,n)=>ne(e,`xAxis`,vt(e,t),n),xt=(e,t,n)=>S(e,`xAxis`,vt(e,t),n),St=(e,t,n)=>ne(e,`yAxis`,yt(e,t),n),Ct=(e,t,n)=>S(e,`yAxis`,yt(e,t),n),wt=P([Me,bt,St,xt,Ct],(e,t,n,r,i)=>ve(e,`xAxis`)?pe(t,r,!1):pe(n,i,!1)),Tt=P([e,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Et=e=>{var t=Me(e);return ve(t,`xAxis`)?`yAxis`:`xAxis`},Dt=(e,t)=>Et(e)===`yAxis`?yt(e,t):vt(e,t),Ot=(e,t,n)=>ie(e,Et(e),Dt(e,t),n),kt=P([Tt,Ot],(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]])}}}),At=P([Tt,Ot],(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)}}),jt=P([Me,bt,St,xt,Ct,kt,Le,wt,Tt,Ae,At],(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 un({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),Mt=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Nt=[`id`,`baseLine`];function Pt(){return Pt=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},Pt.apply(null,arguments)}function Ft(e,t){if(e==null)return{};var n,r,i=It(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 It(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 Lt(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)?G.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Rt(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)?G.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function zt(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?G.createElement(Rt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):G.createElement(Lt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Bt(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=Ft(e,Mt),p=c===`vertical`?`vertical`:`horizontal`,m=d??!1,h=x(),g=f.id,_=f.baseLine,v=Ft(f,Nt),y=Te(v),b=G.createElement(Se,Pt({},f,{id:g,baseLine:_,connectNulls:m,stroke:`none`,className:`recharts-area-area`,layout:p})),S=u!==`none`&&G.createElement(Se,Pt({},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(_)&&G.createElement(Se,Pt({},y,{className:`recharts-area-curve`,layout:p,type:f.type,connectNulls:m,fill:`none`,stroke:u,points:_}));return o&&(i||n<1)?G.createElement(s,null,G.createElement(`defs`,null,G.createElement(`clipPath`,{id:h},G.createElement(zt,{alpha:n,points:f.points??[],baseLine:_,layout:p,strokeWidth:f.strokeWidth}))),G.createElement(s,{clipPath:`url(#${h})`},b,S,C)):G.createElement(G.Fragment,null,b,S,C)}var Vt=[`id`],Ht=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Ut(){return Ut=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},Ut.apply(null,arguments)}function Wt(e,t){if(e==null)return{};var n,r,i=Gt(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 Gt(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 Kt(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 Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Kt(Object(n),!0).forEach(function(t){qt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qt(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jt(e){var t=Yt(e,`string`);return typeof t==`symbol`?t:t+``}function Yt(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 Xt={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`?[Z(Z({},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:Bt,xAxisId:0,yAxisId:0,zIndex:Be.area};function Zt(e,t){return e&&e!==`none`?e:t}var Qt=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:Zt(r,i),value:Oe(n,t),payload:e}]},$t=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,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:Zt(r,a),unit:c,formatter:u,graphicalItemId:f}};return G.createElement(O,{tooltipEntrySettings:p})});function en(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=Te(r);return G.createElement(Ce,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function tn(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 Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return G.createElement(te,{value:t?r:void 0},n)}function nn(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=Wt(a,Vt),y=Z(Z({},b(v)),{},{id:_,points:t,connectNulls:m,type:d,baseLine:n,layout:u,stroke:p,isRange:h,animationElapsedTime:o,isAnimating:c,isEntrance:l});return G.createElement(G.Fragment,null,t?.length>1&&G.createElement(s,{clipPath:r?`url(#clipPath-${i})`:void 0},G.createElement(f,{option:g,DefaultShape:Xt.shape,shapeProps:y})),G.createElement(en,{points:t,props:v,clipPathId:i}))}function rn(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 an(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=K(()=>({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 G.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:rn(s,E,i);return y.syncStepValue(c,i),G.createElement(tn,{showLabels:!S,points:o},r.children,G.createElement(nn,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:S||i<1,isEntrance:a}),G.createElement(d,{label:r.label}))})}function on(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=_t(null),a=_t();return G.createElement(an,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var sn=class extends ht{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 G.createElement(m,{zIndex:v},G.createElement(s,{className:y},u&&G.createElement(`defs`,null,G.createElement(c,{clipPathId:b,xAxisId:d,yAxisId:f}),!w&&G.createElement(`clipPath`,{id:`clipPath-dots-${b}`},G.createElement(`rect`,{x:l-T/2,y:o-T/2,width:p+T,height:h+T}))),G.createElement(on,{needClip:u,clipPathId:b,props:this.props})),G.createElement(we,{points:i,mainColor:Zt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}),this.props.isRange&&Array.isArray(_)&&G.createElement(we,{points:_,mainColor:Zt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}))}};function cn(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,_=Wt(e,Ht),v=de(),y=re(),b=o(h,g).needClip,x=Ve(),S=Ke(t=>jt(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:G.createElement(sn,Ut({},_,{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 ln=(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 un(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,_=ln(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 dn(e){var t=le(e,Xt),n=Ve();return G.createElement(v,{id:t.id,type:`area`},e=>G.createElement(G.Fragment,null,G.createElement(r,{legendPayload:Qt(t)}),G.createElement($t,{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(_,{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}),G.createElement(cn,Ut({},t,{id:e}))))}var fn=G.memo(dn,se);fn.displayName=`Area`;var pn=[`axis`],mn=gt((e,t)=>G.createElement(We,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:pn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),hn=[`axis`],gn=gt((e,t)=>G.createElement(We,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:hn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),_n=53,Q=9,$=2,vn=X.div`
2
- display: flex;
3
- gap: ${$}px;
4
- `,yn=X.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
- `,bn=X.div`
12
- line-height: ${Q}px;
13
- padding-right: 2px;
14
- text-align: right;
15
- `,xn=X.div`
16
- display: grid;
17
- grid-template-columns: repeat(${_n}, ${Q}px);
18
- gap: ${$}px;
19
- height: ${Q}px;
20
- font-size: 9px;
21
- color: ${({theme:e})=>e.color.inkFaint};
22
- `,Sn=X.div`
23
- white-space: nowrap;
24
- line-height: ${Q}px;
25
- `,Cn=X.div`
26
- display: grid;
27
- grid-template-columns: repeat(${_n}, ${Q}px);
28
- gap: ${$}px;
29
- `,wn=X.div`
30
- display: grid;
31
- grid-template-rows: repeat(7, ${Q}px);
32
- gap: ${$}px;
33
- `,Tn=X.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
- `,En=X(B)`
47
- gap: ${$}px;
48
- `,Dn=X(V)`
49
- color: ${({theme:e})=>e.color.inkDim};
50
- font-size: 11px;
51
- `;function On(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 kn(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function An({days:e,now:t}){let[n,r]=q(`tokens`),[i,a]=q(null),o=De(n),s=K(()=>{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:_n},()=>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=On(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}: ${I(t.requests)} requests, ${I(A(t))} tokens, ${L(t.costUsd)}`;return J(rt,{legend:`Activity`,meta:i===null?`${I(d)} active days`:void 0,actions:J(ft,{children:Ie.map(e=>J(pt,{type:`button`,$size:`sm`,$on:e.id===n,"aria-pressed":e.id===n,onClick:()=>r(e.id),children:e.label},e.id))}),children:Y(z,{$gap:2,children:[J(at,{children:J(z,{$gap:1,style:{width:611},children:Y(vn,{children:[J(yn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>J(bn,{children:e},t))}),Y(z,{$gap:1,children:[J(xn,{"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 J(Sn,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),J(Cn,{role:`grid`,"aria-label":`${o.label} per day over the last year`,children:s.map(e=>J(wn,{role:`row`,children:e.map(e=>J(Tn,{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:kn(o.of({key:``,...e.totals}),l),onMouseEnter:()=>a(e),onMouseLeave:()=>a(null)},e.at))},e[0]?.at))})]})]})})}),Y(B,{$justify:`space-between`,$wrap:!0,children:[J(Dn,{children:i===null?f(`Last 12 months`,u):f(he(i.at),i.totals)}),Y(B,{$gap:1,children:[J(tt,{children:`Less`}),J(En,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>J(Tn,{$level:e,$future:!1},e))}),J(tt,{children:`More`})]})]})]})})}function jn({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 J(at,{children:Y(dt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(U,{children:`Key`}),J(U,{children:`Trend`}),J(U,{$align:`right`,children:`Requests`}),J(U,{$align:`right`,children:`Failed`}),J(U,{$align:`right`,children:`Tokens`}),J(U,{$align:`right`,children:`Mean`}),J(U,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:l.map(([e,t])=>{let n=c.get(e)??new Map,r=e===`unknown`?`Unattributed`:a.get(e)??e;return Y(ut,{children:[J(H,{children:J(it,{style:{display:`block`,maxWidth:`28ch`},children:r})}),J(H,{style:{width:120},children:J(st,{values:o.map(e=>n.get(e)??0),height:20,label:`${r}: ${i.format(i.of(M(t)))} over the window`})}),J(H,{$align:`right`,$mono:!0,children:I(t.requests)}),J(H,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:Xe(t.requests===0?0:t.errors/t.requests,0)}),J(H,{$align:`right`,$mono:!0,children:I(A(t))}),J(H,{$align:`right`,$mono:!0,children:Ye(t.requests===0?null:t.durationMsSum/t.requests)}),J(H,{$align:`right`,$mono:!0,children:L(t.costUsd)})]},e)})})]})})}var Mn=6,Nn=`__other__`,Pn=`unknown`;function Fn(e,t,n){let r=n.get(t);return r===void 0?e.find(e=>e.models.some(e=>e.id===t))?.id??null:r}function In(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${ct(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Ln({buckets:e,by:t,since:n,until:r,metric:a,providers:o}){let s=Qe().data??[],c=[...fe(e,a).entries()],l=c.slice(0,Mn),u=c.slice(Mn),d=[...new Set(l.map(([e])=>Fn(s,e,o)))].filter(e=>e!==null&&Je(s,e)===void 0).sort(),f=[];for(let e of[...s.map(e=>e.id),...d,null])l.filter(([t])=>Fn(s,t,o)===e).forEach(([t,n],r)=>{f.push({name:t,label:t===Pn?`Unresolved`:t,color:In(e,r),totals:n})});u.length>0&&f.push({name:Nn,label:`${u.length} more`,color:`var(--ink-faint)`,totals:u.reduce((e,[,t])=>ue(e,M(t)),j)});let p=new Set(l.map(([e])=>e)),m=new Map;for(let n of e){let e=n.split??Pn,r=`${Ne(n.key,t)} ${p.has(e)?e:Nn}`;m.set(r,(m.get(r)??0)+a.of(n))}let g=F(n,r,t).map(e=>{let t={at:e};for(let n of f)t[n.name]=m.get(`${e} ${n.name}`)??0;return t}),_=new Map(f.map(e=>[e.name,e.label]));return Y(z,{$gap:2,children:[J(ze,{$height:220,children:J(Ee,{width:`100%`,height:`100%`,children:Y(mn,{data:g,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(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 Y(je,{children:[J(`div`,{children:N(Number(r),t)}),i.length===0?J(`div`,{children:`No ${a.label.toLowerCase()}`}):i.map(e=>Y(`div`,{children:[_.get(String(e.dataKey))??String(e.dataKey),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}}),f.map(e=>J(fn,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),J(ke,{children:f.map(e=>Y(`span`,{children:[J(k,{$color:e.color}),` `,J(it,{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 Rn=`unknown`;function zn(e,t){return Je(e,t)===void 0?`var(--ink-faint)`:ct(t)}function Bn(e,t){return t===Rn?`Unresolved`:Je(e,t)?.label??t}function Vn({buckets:e,by:t,since:n,until:r,metric:a}){let o=Qe().data??[],s=fe(e,a),c=[...s.keys()].filter(e=>e!==Rn&&Je(o,e)===void 0).sort(),l=[...o.map(e=>e.id),...c,Rn].map(e=>({name:e,totals:s.get(e)})).filter(e=>e.totals!==void 0),u=l.map(e=>e.name),d=F(n,r,t),f=_e(e,d,t,a),p=[...s.values()].reduce((e,t)=>e+t.requests,0);return Y(z,{$gap:3,children:[J(ze,{$height:200,children:J(Ee,{width:`100%`,height:`100%`,children:Y(mn,{data:f,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),J(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:Y(je,{children:[J(`div`,{children:N(Number(r),t)}),n.map(e=>Y(`div`,{children:[Bn(o,String(e.dataKey)),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}),u.map(e=>J(fn,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:zn(o,e),strokeWidth:2,fill:zn(o,e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),J(ke,{children:u.map(e=>Y(`span`,{children:[J(k,{$color:zn(o,e)}),` `,Bn(o,e)]},e))}),Y(dt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(U,{children:`Provider`}),J(U,{$align:`right`,children:`Share`}),J(U,{$align:`right`,children:`Requests`}),J(U,{$align:`right`,children:`Failed`}),J(U,{$align:`right`,children:`Tokens`}),J(U,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:l.map(({name:e,totals:t})=>Y(ut,{children:[Y(H,{children:[J(k,{$color:zn(o,e)}),` `,Bn(o,e)]}),J(H,{$align:`right`,$mono:!0,children:Xe(p===0?0:t.requests/p,0)}),J(H,{$align:`right`,$mono:!0,children:I(t.requests)}),J(H,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:I(t.errors)}),J(H,{$align:`right`,$mono:!0,children:I(A(t))}),J(H,{$align:`right`,$mono:!0,children:L(t.costUsd)})]},e))})]})]})}var Hn=X.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
- `,Un=X.ol`
57
- display: flex;
58
- flex-direction: column;
59
- gap: ${({theme:e})=>e.space(2)};
60
- `,Wn=X.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
- `,Gn=X.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
- `,Kn=X(it)`
73
- display: block;
74
- font-family: ${({theme:e})=>e.font.mono};
75
- font-size: 12px;
76
- `,qn=12;function Jn({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,qn),c=o.slice(qn),l=s[0]?.value??0;return Y(z,{$gap:3,children:[J(Un,{children:s.map(({name:e,entry:n,value:r})=>Y(Hn,{children:[J(Kn,{title:e,children:e}),J(Wn,{children:J(Gn,{$share:l===0?0:r/l,$fault:n.requests>0&&n.errors===n.requests})}),Y(B,{$gap:2,children:[J(V,{$size:`12px`,children:t.format(r)}),J(V,{$size:`11px`,$dim:!0,children:L(n.costUsd)})]})]},e))}),c.length===0?null:J(V,{$size:`11px`,$dim:!0,children:`+ ${c.length} more, ${I(c.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}var Yn=[{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 Xn({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=Yn.map(e=>({...e,value:o.reduce((t,n)=>t+n[e.id],0)})),c=s.reduce((e,t)=>e+t.value,0);return Y(z,{$gap:3,children:[J(ze,{$height:200,children:J(Ee,{width:`100%`,height:`100%`,children:Y(mn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>I(e)}),J(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:Y(je,{children:[J(`div`,{children:N(Number(r),t)}),Yn.map(e=>Y(`div`,{children:[e.label,` `,I(Number(n.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),Yn.map(e=>J(fn,{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))]})})}),J(ke,{children:s.map(e=>Y(B,{$gap:1,children:[J(k,{$color:`var(--accent)`,style:{opacity:e.opacity}}),J(`span`,{children:e.label}),J(V,{$size:`11px`,children:I(e.value)}),J(V,{$size:`11px`,$dim:!0,children:Xe(c===0?0:e.value/c,0)})]},e.id))})]})}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 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 Y(z,{$gap:2,children:[J(ze,{$height:220,children:J(Ee,{width:`100%`,height:`100%`,children:Y(gn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(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:Y(je,{children:[J(`div`,{children:n.label}),Y(`div`,{children:[I(n.requests),` requests`]}),Y(`div`,{children:[I(n.errors),` failed`]}),Y(`div`,{children:[I(n.tokens),` tokens`]}),J(`div`,{children:L(n.costUsd)})]})}}),J(fn,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),J(He,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),J(He,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),Y(ke,{children:[Y(`span`,{children:[J(k,{$color:`var(--accent)`}),` Requests`]}),Y(`span`,{children:[J(k,{$color:`var(--down)`}),` Failed`]})]})]})}var Qn=864e5,$n=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function er(){let{cadence:e}=ot(),[t,n]=q(`24h`),[r,i]=q(`tokens`),[a,o]=q(`model`),s=ye(t),c=De(r),l=K(()=>s.grain===`daily`?ae(Date.now()-s.ms):Math.floor((Date.now()-s.ms)/6e4)*6e4,[s]),u=K(()=>l+s.ms,[l,s]),d=K(()=>ae(Date.now()-371*Qn),[]),f={since:l,grain:s.grain},p=R({...f,groupBy:s.by},e(6e4,`res:usage`)),m=R({...f,groupBy:s.by,splitBy:`provider`},e(6e4,`res:usage`)),h=R({...f,groupBy:s.by,splitBy:`model`},e(6e4,`res:usage`)),g=R({...f,groupBy:s.by,splitBy:`apiKey`},e(6e4,`res:usage`)),_=R({...f,groupBy:a},e(6e4,`res:usage`)),v=R({...f,groupBy:`credential`},e(6e4,`res:usage`)),y=R({since:d,grain:`daily`,groupBy:`day`},e(3e5,`res:usage`)),b=$e(),x=et(),S=Ze(),C=K(()=>{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=K(()=>{let e=new Map;for(let t of b.data??[])e.set(t.id,t.label);return e},[b.data]),T=K(()=>{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 Y(z,{$gap:4,children:[J(lt,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:p.isLoading?`Reading usage…`:`${I(D.requests)} requests and ${L(D.costUsd)} over the last ${s.label}.`,actions:J(ft,{children:xe.map(e=>J(pt,{type:`button`,$size:`sm`,$on:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:e.id},e.id))})}),J(mt,{buckets:E,since:l,until:u,by:s.by,rangeLabel:s.label}),J(W,{legend:`Traffic`,meta:s.by===`hour`?`By hour`:`By day`,query:p,isEmpty:E.length===0,empty:O,children:J(Zn,{buckets:E,by:s.by,since:l,until:u})}),J(ft,{children:Ie.map(e=>J(pt,{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))}),J(W,{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:J(Ln,{buckets:h.data??[],by:s.by,since:l,until:u,metric:c,providers:C})}),Y(nt,{$min:`480px`,$gap:4,children:[Y(z,{$gap:4,children:[J(W,{legend:`Providers`,meta:c.label,query:m,isEmpty:(m.data??[]).length===0,empty:O,children:J(Vn,{buckets:m.data??[],by:s.by,since:l,until:u,metric:c})}),J(An,{days:y.data??[],now:Date.now()})]}),Y(z,{$gap:4,children:[J(W,{legend:`Token mix`,meta:I(ee),query:p,isEmpty:E.length===0,empty:O,children:J(Xn,{buckets:E,by:s.by,since:l,until:u})}),J(W,{legend:`Models`,meta:$n.find(e=>e.id===a)?.column,query:_,isEmpty:(_.data??[]).length===0,empty:O,actions:J(ft,{children:$n.map(e=>J(pt,{type:`button`,$size:`sm`,$on:e.id===a,"aria-pressed":e.id===a,onClick:()=>o(e.id),children:e.label},e.id))}),children:J(Jn,{buckets:_.data??[],metric:c})}),J(W,{legend:`Accounts`,meta:c.label,query:v,isEmpty:(v.data??[]).length===0,empty:O,children:J(Jn,{buckets:v.data??[],metric:c,names:T,unknownLabel:`No account`})})]})]}),J(W,{legend:`API keys`,meta:c.label,query:g,isEmpty:(g.data??[]).length===0,empty:O,children:J(jn,{buckets:g.data??[],by:s.by,since:l,until:u,metric:c,names:w})})]})}var tr=er;export{tr as component};
@@ -1,39 +0,0 @@
1
- import{_ as e,h as t,i as n}from"./shared-oTMOLWMT.js";import{$ as r,A as i,B as ee,F as a,I as o,P as s,Q as c,Z as te,et as ne,g as l,l as re,nt as u,r as d,tt as ie,u as ae}from"./Lamp-DtHKJH6P.js";import{C as f,D as oe,O as se,_ as p,a as ce,b as m,i as le,t as ue,v as h,x as g,y as _}from"./Panel-BlNr9j6-.js";import{_ as de,d as v,i as fe,t as pe}from"./Rack-_A_3zqxC.js";import{n as me,t as y}from"./chevron-right-BfnK63GB.js";import{i as b,r as x}from"./index-BTE8vyBz.js";import{i as S,n as he}from"./Field-DcNu4yw-.js";import{t as C}from"./Meter-stpt3vQu.js";import{i as w,n as T,r as E,t as D}from"./Table-CVDZ69Zx.js";import{n as ge,r as O}from"./WindowChart-BPEsEGFL.js";import{i as _e,n as ve,r as ye,t as be}from"./RequestTable-Cokk7wKP.js";import{i as k,n as A,r as xe,t as Se}from"./SummaryDeck-C0IbqnLz.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}=de(),n=te(),r=c(200,t(1e4,`res:logs`));return P(I,{"data-testid":`client-shell`,children:[N(v,{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`?o:i,r=e.used===null?null:e.limit===0?1:e.used/e.limit;return P(w,{children:[N(T,{children:t}),N(T,{$align:`right`,$mono:!0,children:e.used===null?N(_,{children:`unknown`}):n(e.used)}),N(T,{$align:`right`,$mono:!0,children:n(e.limit)}),N(T,{children:r===null?null:N(C,{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(h)`
37
- font-size: 11px;
38
- text-align: right;
39
- `;function Te({windows:e,open:t,onToggle:n}){let r=e[0],i=e.filter(e=>e.usedRatio!==null);return P(w,{children:[N(T,{children:r.label}),N(T,{children:i.length===0?N(_,{children:`unknown`}):N(U,{children:i.map(e=>P(W,{children:[N(C,{fraction:e.usedRatio,label:`${e.label} ${e.windowType} window, ${Math.round(e.usedRatio*100)}% used`}),N(G,{children:s(e.usedRatio,0)}),N(p,{children:l(e,H(e),Date.now(),a)})]},e.windowType))})}),N(T,{$align:`right`,children:N(se,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} quota history for ${r.label}`,title:`${t?`Hide`:`Show`} quota history for ${r.label}`,onClick:n,children:N(t?me:y,{})})})]})}function K(){let{cadence:a,live:te}=de(),[l,se]=M(`24h`),[v,me]=M(`all`),[y,b]=M(``),[x,C]=M(z[0]),[F,I]=M(null),[L,R]=M(null),B=t(l),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=ie(),G={since:H,grain:B.grain},K=u({...G,groupBy:B.by},a(6e4,`res:usage`)),q=u({...G,groupBy:`model`},a(6e4,`res:usage`)),J=c(x,a(ee,`res:logs`)),Y=r(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)=>d[e.windowType]-d[t.windowType])}))])},[X]),Z=X.map(e=>O(V(e))).filter(e=>e!==null),De=Z.length===0?0:Math.floor(Math.min(...Z)/6e4)*6e4,Oe=ne({since:De},L!==null&&Z.length>0),ke=(J.data??[]).some(ae),Ae=_e(te&&ke),Q=ye(J.data??[],v,y),je=(J.data??[]).filter(re).length,$=K.data??[],Me=$.reduce((e,t)=>e+t.requests,0),Ne=$.reduce((e,t)=>e+t.costUsd,0);return P(f,{$gap:4,children:[N(pe,{legend:`Client`,title:`Your usage`,summary:K.isLoading?`Reading your usage…`:`${i(Me)} requests and ${o(Ne)} over the last ${B.label}.`,actions:N(A,{children:n.map(e=>N(xe,{type:`button`,$size:`sm`,$on:e.id===l,"aria-pressed":e.id===l,onClick:()=>se(e.id),children:e.id},e.id))})}),N(ue,{legend:`Your key`,meta:W.data===void 0?void 0:P(h,{$dim:!0,children:[W.data.prefix,`…`]}),children:W.isPending?N(ce,{rows:2}):W.isError?N(le,{legend:`Could not read your key`,error:W.error}):P(f,{$gap:2,children:[P(m,{$gap:2,$wrap:!0,children:[N(p,{children:W.data.label}),W.data.bodyLoggingOptOut?N(_,{children:`Request bodies are never stored for this key.`}):null]}),W.data.modelAllowlist===null?N(_,{children:`Every model this gateway serves.`}):W.data.modelAllowlist.length===0?N(_,{children:`No models. This key cannot serve a request.`}):N(m,{$gap:1,$wrap:!0,children:W.data.modelAllowlist.map(e=>N(h,{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(g,{children:P(D,{children:[N(`thead`,{children:P(`tr`,{children:[N(E,{children:`Model`}),N(E,{$align:`right`,children:`Requests`}),N(E,{$align:`right`,children:`Tokens`}),N(E,{$align:`right`,children:`Spend`})]})}),N(`tbody`,{children:(q.data??[]).map(e=>P(w,{children:[N(T,{$mono:!0,children:e.key}),N(T,{$align:`right`,$mono:!0,children:i(e.requests)}),N(T,{$align:`right`,$mono:!0,children:i(e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheWriteTokens)}),N(T,{$align:`right`,$mono:!0,children:o(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(_,{children:`Counted from completed requests, so a burst in flight right now may not be included yet.`}),children:N(g,{children:P(D,{children:[N(`thead`,{children:P(`tr`,{children:[N(E,{children:`Limit`}),N(E,{$align:`right`,children:`Used`}),N(E,{$align:`right`,children:`Ceiling`}),N(E,{$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(_,{children:`What each account serving this gateway has left. A request is served by whichever account of a provider can take it.`}),children:N(f,{$gap:4,children:Ee.map(([e,t])=>P(f,{$gap:1,children:[N(p,{children:e}),N(g,{children:P(D,{children:[N(`thead`,{children:P(`tr`,{children:[N(E,{children:`Account`}),N(E,{$width:`60%`,children:`Quota`}),N(E,{})]})}),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(w,{children:N(T,{colSpan:3,children:N(f,{$gap:4,children:t.map(e=>{let t=V(e),n=O(t),r=(Oe.data?.samples??[]).filter(t=>t.credentialId===e.credentialId&&t.windowType===e.windowType&&t.observedAt>=(n??0));return N(ge,{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`:`${s(e.usedRatio,0)} used`,rateText:e.ratePerHourRatio===null?`unknown`:`${s(e.ratePerHourRatio,1)}/h`},e.windowType)})})})}):null]},e))})]})})]},e))})}),N(k,{legend:`Recent requests`,meta:`${Q.length} shown`,actions:P(A,{children:[N(he,{value:y,placeholder:`Filter by model or error`,"aria-label":`Filter requests`,style:{width:200},onChange:e=>b(e.target.value)}),P(S,{value:v,"aria-label":`Show which requests`,style:{width:`auto`},onChange:e=>me(e.target.value),children:[N(`option`,{value:`all`,children:`All requests`}),N(`option`,{value:`failed`,children:`Failed only`})]}),N(S,{value:x,"aria-label":`How many requests to fetch`,style:{width:`auto`},onChange:e=>C(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(_,{children:[i(je),` of the last `,i((J.data??[]).length),` failed.`]}),children:N(g,{children:N(ve,{rows:Q,now:Ae,onOpen:I})})}),N(fe,{open:F!==null,onOpenChange:e=>{e||I(null)},title:`Request detail`,width:`640px`,footer:N(oe,{type:`button`,onClick:()=>I(null),children:`Close`}),children:F===null?null:N(be,{log:F})})]})}var q=()=>N(x,{children:N(b,{children:N(R,{children:N(K,{})})})});export{q as component};