omnigateway 0.15.4 → 0.15.5

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 (36) hide show
  1. package/README.md +12 -1
  2. package/bin/omni.js +193 -187
  3. package/gateway.js +324 -318
  4. package/package.json +1 -1
  5. package/public/assets/{_app-kgxk7ake.js → _app-hj6zm190.js} +1 -1
  6. package/public/assets/{_app.accounts-3jabfvcs.js → _app.accounts-p4cfzwak.js} +1 -1
  7. package/public/assets/{_app.console-y69399jc.js → _app.console-9b5jsgb2.js} +1 -1
  8. package/public/assets/{_app.database-r5kg3838.js → _app.database-gxm9r50d.js} +1 -1
  9. package/public/assets/{_app.index-22awhb38.js → _app.index-z62y96gv.js} +1 -1
  10. package/public/assets/{_app.keys-7vh81n1w.js → _app.keys-9hcrg2sv.js} +1 -1
  11. package/public/assets/{_app.logs-rssv5a6z.js → _app.logs-wszj7dxd.js} +1 -1
  12. package/public/assets/_app.models-msggftd4.js +1 -0
  13. package/public/assets/{_app.plugins.$pluginId-e4xva5tz.js → _app.plugins.$pluginId-c18d9z9g.js} +1 -1
  14. package/public/assets/{_app.settings-fqzg7wnn.js → _app.settings-1kbbc55c.js} +1 -1
  15. package/public/assets/{_app.usage-32vje0s7.js → _app.usage-j1q7t12v.js} +1 -1
  16. package/public/assets/{client-d3mjj5ey.js → client-85yjh3yc.js} +1 -1
  17. package/public/assets/{index-v31xha7b.js → index-0egbh3rb.js} +1 -1
  18. package/public/assets/{index-f7t0kve8.js → index-330vgx7r.js} +1 -1
  19. package/public/assets/{index-dq2f7yk0.js → index-3a10vc18.js} +1 -1
  20. package/public/assets/{index-nnpqs2w6.js → index-3habqvw2.js} +1 -1
  21. package/public/assets/{index-938qd7p2.js → index-40vm2qxc.js} +1 -1
  22. package/public/assets/{index-sbe0ydnc.js → index-6v3e0r4x.js} +1 -1
  23. package/public/assets/{index-z7c4qz9d.js → index-96zs0ekh.js} +1 -1
  24. package/public/assets/{index-zkt5p0qd.js → index-9pefp4zb.js} +1 -1
  25. package/public/assets/{index-85cnhw3e.js → index-9vqvqrvt.js} +1 -1
  26. package/public/assets/{index-hk28xepa.js → index-dny52xdk.js} +1 -1
  27. package/public/assets/{index-fcew0gga.js → index-e7nx5832.js} +1 -1
  28. package/public/assets/{index-8bewp9z1.js → index-h41dkv54.js} +1 -1
  29. package/public/assets/{index-p9vbm21a.js → index-qkhn11a8.js} +3 -3
  30. package/public/assets/{index-0j7sghrn.js → index-qtdmekxc.js} +1 -1
  31. package/public/assets/{index-d09hs7ex.js → index-ywek2f98.js} +1 -1
  32. package/public/assets/{index-xdyjb1an.js → index-zqfj5xfa.js} +1 -1
  33. package/public/assets/{login-p97b96t9.js → login-55p1x35d.js} +1 -1
  34. package/public/index.html +1 -1
  35. package/public/shared/dashboard-sdk.js +1 -1
  36. package/public/assets/_app.models-82m2f0kr.js +0 -1
@@ -1 +1 @@
1
- import{n,t,d,o,r,Ie,Mo,S,_t,H,he,Do,Qt,Bo,In,kn,Ln,Nr,Jt,Br,_n,Fr,h,x,b,k,f}from"/assets/index-p9vbm21a.js";import{R,tt}from"/assets/index-f7t0kve8.js";import{W}from"/assets/index-dq2f7yk0.js";import{v,Tr,m}from"/assets/index-8bewp9z1.js";import{re}from"/assets/index-wjqdtafp.js";import{Ar}from"/assets/index-d0t1fj1y.js";import{useEffect as xe,useId as Ce,useState as ee}from"react";import T from"styled-components";import{useState as z}from"react";import V from"styled-components";var I=12;import{jsx as _,jsxs as G}from"react/jsx-runtime";var ie=V.p.withConfig({displayName:"AccessPanel__Blurb"})(["font-size:12px;color:",";max-width:62ch;"],({theme:e})=>e.color.inkDim),se=V.p.withConfig({displayName:"AccessPanel__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),_e=V.p.withConfig({displayName:"AccessPanel__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),le=V(r).withConfig({displayName:"AccessPanel__Form"})(["max-width:320px;"]),de=V(t).withConfig({displayName:"AccessPanel__SubHead"})(["color:",";"],({theme:e})=>e.color.inkDim);function Ae(){let e=kn(),[l,c]=z(""),[C,w]=z(""),[i,g]=z(""),[M,L]=z(null),p=()=>{if(C.length<I){L(`A password must be at least ${I} characters.`);return}if(C!==i){L("The two new passwords do not match.");return}L(null),e.mutate({current:l,password:C},{onSuccess:()=>Ar("password-changed"),onError:(N)=>L(h(N))})};return G(r,{$gap:2,children:[_(de,{children:"Admin password"}),_(ie,{children:"Changing this signs every session out, including this one."}),G(le,{$gap:2,children:[_(m,{label:"Current password",children:(N)=>_(v,{...N,type:"password",autoComplete:"current-password",value:l,onChange:(A)=>c(A.target.value)})}),_(m,{label:"New password",hint:`At least ${I} characters.`,children:(N)=>_(v,{...N,type:"password",autoComplete:"new-password",value:C,onChange:(A)=>w(A.target.value)})}),_(m,{label:"Repeat new password",children:(N)=>_(v,{...N,type:"password",autoComplete:"new-password",value:i,onChange:(A)=>g(A.target.value)})}),_(o,{$gap:2,children:_(n,{type:"button",$variant:"primary",onClick:p,disabled:e.isPending||l.length===0||C.length===0,children:"Change password"})})]}),M===null?null:_(se,{role:"alert",children:M})]})}function Le(){let e=_t(),l=Ln(),[c,C]=z(""),[w,i]=z(null),[g,M]=z(null),L=e.data?.viewerConfigured===!0,p=()=>{if(c.length<I){i(`A password must be at least ${I} characters.`);return}i(null),l.mutate(c,{onSuccess:()=>{C(""),M(L?"Read-only password replaced.":"Read-only access granted.")},onError:(A)=>i(h(A))})},N=()=>{i(null),l.mutate(null,{onSuccess:()=>M("Read-only access withdrawn."),onError:(A)=>i(h(A))})};return G(r,{$gap:2,children:[_(de,{children:"Read-only password"}),G(ie,{children:["Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies."," ",e.isPending?"Checking whether one is set…":L?"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."]}),G(le,{$gap:2,children:[_(m,{label:L?"Replace read-only password":"Set read-only password",hint:`At least ${I} characters.`,children:(A)=>_(v,{...A,type:"password",autoComplete:"new-password",value:c,onChange:(O)=>C(O.target.value)})}),G(o,{$gap:2,children:[_(n,{type:"button",$variant:"primary",onClick:p,disabled:l.isPending||c.length===0,children:L?"Replace":"Set"}),L?_(n,{type:"button",$variant:"danger",onClick:N,disabled:l.isPending,children:"Withdraw access"}):null]})]}),w===null?null:_(se,{role:"alert",children:w}),g===null||w!==null?null:_(_e,{role:"status",children:g})]})}function ue(){return _(f,{legend:"Access",children:G(r,{$gap:3,children:[_(Ae,{}),_(Mo,{}),_(Le,{})]})})}import{useState as ce}from"react";import X from"styled-components";import{jsx as P,jsxs as K}from"react/jsx-runtime";var me=[{id:"claude",label:"Claude Code",where:"settings.json under ~/.claude"},{id:"opencode",label:"opencode",where:"opencode.json in your project"}],Ne=X(d).withConfig({displayName:"AgentSetup__Sheet"})(["display:block;white-space:pre;overflow-x:auto;padding:0.75rem;background:",";border:1px solid ",";border-radius:4px;font-size:0.8125rem;line-height:1.5;"],({theme:e})=>e.color.panelSunk,({theme:e})=>e.color.rule),Ee=X.div.withConfig({displayName:"AgentSetup__Path"})(["color:",";font-size:0.8125rem;margin-bottom:0.25rem;"],({theme:e})=>e.color.inkDim),j=X.p.withConfig({displayName:"AgentSetup__Note"})(["color:",";font-size:0.8125rem;margin:0;"],({theme:e})=>e.color.inkDim),Pe=X.div.withConfig({displayName:"AgentSetup__MappingGrid"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));gap:",";"],({theme:e})=>e.space(2)),Te=[{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 ge(){let[e,l]=ce("claude"),[c,C]=ce(()=>({claude:{},opencode:{}})),w=H(),i=c[e],g=typeof i.defaultModel==="string"&&i.defaultModel!==""?i:void 0,M=Bo(e,g),L=me.find((p)=>p.id===e);return P(f,{legend:"Agent setup",children:K(r,{children:[P(o,{children:me.map((p)=>P(n,{type:"button",$variant:p.id===e?"primary":"ghost",onClick:()=>l(p.id),children:p.label},p.id))}),K(j,{children:[L?.where,". The key is a placeholder — paste your own over it. Or run"," ",K(d,{children:["omni setup ",e]})," to write these files directly."]}),e==="claude"?K(j,{children:["Claude Code cannot read a window from this gateway, so it assumes 200k for a pool id it does not recognise and auto-compacts there. For a pool whose models hold 1M, append"," ",P(d,{children:"[1m]"})," to the model name — ",P(d,{children:"--model 'pool[1m]'"})," — which lifts it per invocation. The suffix is stripped before the request is sent, so the pool id arrives unchanged."]}):null,(w.data?.length??0)>0?P(Pe,{children:Te.map((p)=>P(m,{label:p.label,children:(N)=>P(R,{...N,value:i[p.key]??"",options:[{value:"",label:p.required?"Choose a pool":"Not mapped"},...(w.data??[]).map((A)=>({value:A.id,label:A.id}))],onValueChange:(A)=>C((O)=>({...O,[e]:{...O[e],[p.key]:A||void 0}}))})},p.key))}):null,w.isLoading?P(b,{rows:2}):M.isError?P(x,{error:M.error,onRetry:()=>void M.refetch()}):M.isLoading?P(b,{rows:4}):(w.data?.length??0)===0?P(j,{children:"No virtual models configured yet, so there is nothing to point a client at."}):g===void 0?K(j,{children:["Choose a default model to generate ",L?.label," settings."]}):M.data===void 0||M.data.length===0?P(j,{children:"No virtual models configured yet, so there is nothing to point a client at."}):M.data.map((p)=>K("div",{children:[P(Ee,{children:p.path}),P(Ne,{as:"pre",children:p.contents.trimEnd()})]},p.path)),M.isError?P(j,{children:h(M.error)}):null]})})}import{jsx as a,jsxs as y,Fragment as ze}from"react/jsx-runtime";var Se={off:"Off",lite:"Lite — names the lazier option",full:"Full — the ladder enforced",ultra:"Ultra — challenges the requirement"},J=[{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."}],oe=[{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:1000,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:1000,min:1},{id:"logRetentionDays",label:"Log retention",hint:"How long request rows are kept before pruning.",unit:"days",step:1,min:1},{id:"bodyRetentionDays",label:"Body retention",hint:"Captured bodies only. Never longer than log retention; swept hourly.",unit:"days",step:1,min:1,max:3650},{id:"quotaPollIntervalMs",label:"Quota poll interval",hint:"How often a provider is asked for remaining quota. 0 disables. Needs a restart.",unit:"ms",step:60000,min:0}],Q=T.div.withConfig({displayName:"SettingsBoard__Weights"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:",";"],({theme:e})=>e.space(3)),D=T(r).withConfig({displayName:"SettingsBoard__Cell"})(["gap:6px;"]),U=T.p.withConfig({displayName:"SettingsBoard__Blurb"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),te=T.div.withConfig({displayName:"SettingsBoard__Options"})(["display:grid;grid-template-columns:1fr;gap:",";align-items:start;"],({theme:e})=>e.space(2)),ke=T.div.withConfig({displayName:"SettingsBoard__Option"})(["display:grid;grid-template-columns:auto 1fr;column-gap:",";row-gap:4px;align-items:center;padding:",";background:",";border:1px solid ",";border-radius:3px;"],({theme:e})=>e.space(2),({theme:e})=>e.space(2),({theme:e})=>e.color.panelSunk,({theme:e})=>e.color.rule),ae=T(U).withConfig({displayName:"SettingsBoard__OptionBlurb"})(["grid-column:2;"]),Me=T.label.withConfig({displayName:"SettingsBoard__OptionName"})(["font-size:12px;font-weight:600;color:",";cursor:pointer;"],({theme:e})=>e.color.ink),$e=T(ke).withConfig({displayName:"SettingsBoard__Choice"})(["grid-template-columns:1fr;","{grid-column:1;}"],ae);function Be({label:e,children:l,blurb:c}){let C=Ce();return y($e,{children:[a(Me,{htmlFor:C,children:e}),l({id:C}),a(ae,{children:c})]})}function Y({label:e,checked:l,disabled:c,onCheckedChange:C,children:w}){let i=Ce();return y(ke,{children:[a(W,{id:i,checked:l,onCheckedChange:C,label:e,...c===void 0?{}:{disabled:c}}),a(Me,{htmlFor:i,children:e}),a(ae,{children:w})]})}var Oe=T.p.withConfig({displayName:"SettingsBoard__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),qe=T.p.withConfig({displayName:"SettingsBoard__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),De=T.span.withConfig({displayName:"SettingsBoard__PolicyCount"})(["font-size:11px;font-family:",";color:",";"],({theme:e})=>e.font.mono,({$over:e,theme:l})=>e?l.color.down:l.color.inkDim),Fe=T.p.withConfig({displayName:"SettingsBoard__Blocked"})(["font-size:12px;color:",";max-width:72ch;code{font-family:",";}"],({theme:e})=>e.color.warn,({theme:e})=>e.font.mono),pe="smart-router-classifier-status",be="smart-router-local-status",fe={ok:null,unset:"Not set; flagged keys' requests are refused.",unresolved:"This model does not resolve.",notLocal:"This model has a target that is not a custom (in-house) endpoint; flagged keys' requests are refused."};function ye(e,l,c,C){let w=(e??"").trim();if(w==="")return C?fe.unset:null;if(c===void 0||c==="unset"||w!==l)return null;return fe[c]}var we=T.p.withConfig({displayName:"SettingsBoard__ModelWarning"})(["font-size:12px;color:",";"],({theme:e})=>e.color.warn);function We(e){let l={};for(let c of J)l[`w.${c.id}`]=String(e.weights[c.id]);for(let c of oe)l[c.id]=String(e[c.id]);return l.rtkEnabled=String(e.rtkEnabled),l.autoCacheEnabled=String(e.autoCacheEnabled),l.ponytailMode=e.ponytailMode,l.bodyLoggingEnabled=String(e.bodyLoggingEnabled),l.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),l.guardrailModel=e.guardrailModel??"",l.guardrailTimeoutMs=String(e.guardrailTimeoutMs),l.guardrailHistoryTurns=String(e.guardrailHistoryTurns),l.smartRouterEnabled=String(e.smartRouterEnabled),l.smartRouterClassifierModel=e.smartRouterClassifierModel??"",l.smartRouterLocalModel=e.smartRouterLocalModel??"",l.smartRouterPolicy=e.smartRouterPolicy,l.smartRouterTimeoutMs=String(e.smartRouterTimeoutMs),l}function He(e){let l={};for(let E of J){let q=(e[`w.${E.id}`]??"").trim(),B=Number(q);if(q.length===0||!Number.isFinite(B))return{ok:!1,problem:`${E.label} must be a number.`};l[E.id]=B}let c={};for(let E of oe){let q=(e[E.id]??"").trim(),B=Number(q);if(q.length===0||!Number.isInteger(B)||B<E.min)return{ok:!1,problem:`${E.label} must be a whole number of ${E.min} or more.`};if(E.max!==void 0&&B>E.max)return{ok:!1,problem:`${E.label} cannot exceed ${E.max}.`};c[E.id]=B}if(c.maxAttempts>10)return{ok:!1,problem:"Attempts per request cannot exceed 10."};let C=(e.guardrailTimeoutMs??"").trim(),w=Number(C);if(C.length===0||!Number.isInteger(w)||w<1||w>Nr)return{ok:!1,problem:`Usage policy check timeout must be a whole number from 1 to ${Nr}.`};let i=(e.guardrailHistoryTurns??"").trim(),g=Number(i);if(i.length===0||!Number.isInteger(g)||g<1||g>Fr)return{ok:!1,problem:`Messages judged must be a whole number from 1 to ${Fr}.`};let M=(e.guardrailModel??"").trim(),L=(e.smartRouterTimeoutMs??"").trim(),p=Number(L);if(L.length===0||!Number.isInteger(p)||p<1||p>Br)return{ok:!1,problem:`Confidential routing timeout must be a whole number from 1 to ${Br}.`};let N=(e.smartRouterPolicy??"").trim();if(N.length===0)return{ok:!1,problem:"Write what counts as confidential, or use Reset to default."};if(N.length>Jt)return{ok:!1,problem:`The confidential policy is at most ${Jt} characters.`};let A=(e.smartRouterClassifierModel??"").trim(),O=(e.smartRouterLocalModel??"").trim();return{ok:!0,settings:{weights:l,...c,rtkEnabled:e.rtkEnabled==="true",autoCacheEnabled:e.autoCacheEnabled==="true",ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(Se,e.ponytailMode)?e.ponytailMode:"off",bodyLoggingEnabled:e.bodyLoggingEnabled==="true",bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks==="true",guardrailModel:M.length===0?null:M,guardrailTimeoutMs:w,guardrailHistoryTurns:g,smartRouterEnabled:e.smartRouterEnabled==="true",smartRouterClassifierModel:A.length===0?null:A,smartRouterLocalModel:O.length===0?null:O,smartRouterPolicy:N,smartRouterTimeoutMs:p}}}function Re(){let e=he(),l=Do(),c=H(),C=Qt(),w=In(),[i,g]=ee({}),[M,L]=ee(null),[p,N]=ee(!1);xe(()=>{if(e.data===void 0)return;g(We(e.data))},[e.data]);let A=Math.max(0.0001,...J.map((s)=>Math.abs(Number(i[`w.${s.id}`])||0))),O=(i.smartRouterPolicy??"").trim().length,E=i.smartRouterEnabled==="true",q=ye(i.smartRouterClassifierModel,e.data?.smartRouterClassifierModel,C.data?.classifier,E),B=ye(i.smartRouterLocalModel,e.data?.smartRouterLocalModel,C.data?.local,E),ne=(s,u,F)=>u===null?s:[s,F].filter((Z)=>Z!==void 0).join(" "),ve=()=>{if(N(!1),e.data===void 0)return;let s=He(i);if(!s.ok){L(s.problem);return}L(null),w.mutate(s.settings,{onSuccess:()=>N(!0),onError:(u)=>L(h(u))})};return y(ze,{children:[a(k,{legend:"Settings",title:"Routing and retention",summary:"Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.",actions:a(n,{type:"button",$variant:"primary",disabled:w.isPending||e.isLoading,onClick:ve,children:w.isPending?"Saving…":"Save changes"})}),e.isError?a(f,{legend:"Settings",children:a(x,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?a(f,{legend:"Settings",children:a(b,{rows:6})}):y(r,{$gap:4,children:[a(f,{legend:"Scoring weights",meta:"relative to each other",footer:y(o,{children:[a(t,{children:"Score is the sum of each term times its weight, then multiplied by the account and target weights."}),a(S,{})]}),children:a(Q,{children:J.map((s)=>{let u=Number(i[`w.${s.id}`])||0;return y(D,{children:[a(m,{label:s.label,children:(F)=>a(v,{...F,type:"number",step:0.5,value:i[`w.${s.id}`]??"",onChange:(Z)=>g({...i,[`w.${s.id}`]:Z.target.value})})}),a(re,{fraction:Math.abs(u)/A,height:4,tone:"var(--accent)",label:`${s.label} weight ${u}`}),a(U,{children:s.blurb})]},s.id)})})}),a(f,{legend:"Limits",children:a(Q,{children:oe.map((s)=>a(D,{children:a(m,{label:s.label,hint:s.hint,children:(u)=>y(o,{$gap:2,children:[a(v,{...u,type:"number",min:s.min,max:s.max,step:s.step,value:i[s.id]??"",onChange:(F)=>g({...i,[s.id]:F.target.value})}),a(t,{children:s.unit})]})})},s.id))})}),y(Ie,{$min:"380px",$stretch:!0,children:[a(f,{legend:"Request handling",meta:"applied before dispatch",children:y(te,{children:[a(Y,{label:"Enable RTK compression",checked:i.rtkEnabled==="true",onCheckedChange:(s)=>g({...i,rtkEnabled:String(s)}),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."}),a(Y,{label:"Add a cache breakpoint when a client sends none",checked:i.autoCacheEnabled==="true",onCheckedChange:(s)=>g({...i,autoCacheEnabled:String(s)}),children:"Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched."}),a(Be,{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:(s)=>a(R,{...s,value:i.ponytailMode??"off",options:Object.entries(Se).map(([u,F])=>({value:u,label:F})),onValueChange:(u)=>g({...i,ponytailMode:u})})})]})}),a(f,{legend:"Request and response bodies",meta:l.data===!0?"permitted by the environment":"not permitted",children:y(r,{$gap:2,children:[l.data===!0?null:y(Fe,{children:["This gateway started without ",a("code",{children:"OMNI_BODY_LOGGING_ALLOWED"}),", so nothing below can record anything. Set it in the installation's ",a("code",{children:".env"})," and restart first."]}),y(te,{children:[a(Y,{label:"Capture request and response bodies",checked:i.bodyLoggingEnabled==="true",disabled:l.data!==!0,onCheckedChange:(s)=>g({...i,bodyLoggingEnabled:String(s)}),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 body retention window above, never later than the request log."}),a(Y,{label:"Also keep raw stream frames",checked:i.bodyLoggingCaptureStreamChunks==="true",disabled:l.data!==!0||i.bodyLoggingEnabled!=="true",onCheckedChange:(s)=>g({...i,bodyLoggingCaptureStreamChunks:String(s)}),children:"Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores."})]})]})})]}),a(f,{legend:"Usage policies",meta:"per-key guardrails",children:y(r,{$gap:2,children:[a(U,{children:"Keys carrying a usage policy have each request judged by this model first. While it is blank, every request from such a key is refused. A guardrail against ordinary misuse, not a security boundary."}),y(Q,{children:[a(D,{children:a(m,{label:"Classifier model",hint:"A configured model, or provider/model. Blank means none.",children:(s)=>a(tt,{...s,placeholder:"none",value:i.guardrailModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,guardrailModel:u})})})}),a(D,{children:a(m,{label:"Check timeout",hint:"A slower check refuses the request it was judging.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Nr,step:1,value:i.guardrailTimeoutMs??"",onChange:(u)=>g({...i,guardrailTimeoutMs:u.target.value})}),a(t,{children:"ms"})]})})}),a(D,{children:a(m,{label:"Messages judged",hint:"How many of the latest human messages are judged together. 1 is the last alone.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Fr,step:1,value:i.guardrailHistoryTurns??"",onChange:(u)=>g({...i,guardrailHistoryTurns:u.target.value})}),a(t,{children:"messages"})]})})})]})]})}),a(f,{legend:"Confidential routing",meta:"per-key, local model",children:y(r,{$gap:3,children:[a(U,{children:"Keys with confidential routing on have each request screened by the classifier model. Requests it judges confidential are answered by the local model instead of the model asked for. Reduces leaks of ordinary confidential content; it is not a security boundary."}),a(te,{children:a(Y,{label:"Enable confidential routing",checked:i.smartRouterEnabled==="true",onCheckedChange:(s)=>g({...i,smartRouterEnabled:String(s)}),children:"Applies only to keys that have it switched on in Keys. While off, no request is screened or rerouted."})}),y(Q,{children:[y(D,{children:[a(m,{label:"Confidential classifier model",hint:"Judges each request. Blank means none.",children:(s)=>a(tt,{...s,"aria-describedby":ne(s["aria-describedby"],q,pe),placeholder:"none",value:i.smartRouterClassifierModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,smartRouterClassifierModel:u})})}),q===null?null:a(we,{id:pe,children:q})]}),y(D,{children:[a(m,{label:"Local model",hint:"Answers requests judged confidential. Blank means none.",children:(s)=>a(tt,{...s,"aria-describedby":ne(s["aria-describedby"],B,be),placeholder:"none",value:i.smartRouterLocalModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,smartRouterLocalModel:u})})}),B===null?null:a(we,{id:be,children:B})]}),a(D,{children:a(m,{label:"Confidential check timeout",hint:"A slower check refuses the request it was screening.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Br,step:1,value:i.smartRouterTimeoutMs??"",onChange:(u)=>g({...i,smartRouterTimeoutMs:u.target.value})}),a(t,{children:"ms"})]})})})]}),a(U,{children:"Must be a virtual model whose targets are all custom (in-house) endpoints. Requests are refused otherwise."}),a(m,{label:"What counts as confidential",hint:"Plain language. The classifier reads this to decide which requests stay on local hardware.",children:(s)=>a(Tr,{...s,rows:6,value:i.smartRouterPolicy??"",onChange:(u)=>g({...i,smartRouterPolicy:u.target.value})})}),y(o,{$gap:2,children:[a(n,{type:"button",$size:"sm",onClick:()=>g({...i,smartRouterPolicy:_n}),children:"Reset to default"}),a(S,{}),y(De,{$over:O>Jt,children:[O," / ",Jt]})]})]})}),M===null?null:a(Oe,{role:"alert",children:M}),p&&M===null?a(qe,{role:"status",children:"Settings saved."}):null,y(Ie,{$min:"380px",$stretch:!0,children:[a(ge,{}),a(ue,{})]}),a(f,{legend:"Known limits",children:y(r,{$gap:2,children:[y(o,{$gap:2,$align:"start",children:[a(d,{$dim:!0,children:"rate limits"}),a(U,{children:"Counted per gateway process and reset when it restarts. Not shared across instances."})]}),y(o,{$gap:2,$align:"start",children:[a(d,{$dim:!0,children:"logs"}),a(U,{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 $t=Re;export{$t as component};
1
+ import{n,t,d,o,r,Ie,Mo,S,_t,H,he,Do,Qt,Bo,In,kn,Ln,Nr,Jt,Br,_n,Fr,h,x,b,k,f}from"/assets/index-qkhn11a8.js";import{R,tt}from"/assets/index-330vgx7r.js";import{W}from"/assets/index-3a10vc18.js";import{v,Tr,m}from"/assets/index-h41dkv54.js";import{re}from"/assets/index-wjqdtafp.js";import{Ar}from"/assets/index-d0t1fj1y.js";import{useEffect as xe,useId as Ce,useState as ee}from"react";import T from"styled-components";import{useState as z}from"react";import V from"styled-components";var I=12;import{jsx as _,jsxs as G}from"react/jsx-runtime";var ie=V.p.withConfig({displayName:"AccessPanel__Blurb"})(["font-size:12px;color:",";max-width:62ch;"],({theme:e})=>e.color.inkDim),se=V.p.withConfig({displayName:"AccessPanel__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),_e=V.p.withConfig({displayName:"AccessPanel__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),le=V(r).withConfig({displayName:"AccessPanel__Form"})(["max-width:320px;"]),de=V(t).withConfig({displayName:"AccessPanel__SubHead"})(["color:",";"],({theme:e})=>e.color.inkDim);function Ae(){let e=kn(),[l,c]=z(""),[C,w]=z(""),[i,g]=z(""),[M,L]=z(null),p=()=>{if(C.length<I){L(`A password must be at least ${I} characters.`);return}if(C!==i){L("The two new passwords do not match.");return}L(null),e.mutate({current:l,password:C},{onSuccess:()=>Ar("password-changed"),onError:(N)=>L(h(N))})};return G(r,{$gap:2,children:[_(de,{children:"Admin password"}),_(ie,{children:"Changing this signs every session out, including this one."}),G(le,{$gap:2,children:[_(m,{label:"Current password",children:(N)=>_(v,{...N,type:"password",autoComplete:"current-password",value:l,onChange:(A)=>c(A.target.value)})}),_(m,{label:"New password",hint:`At least ${I} characters.`,children:(N)=>_(v,{...N,type:"password",autoComplete:"new-password",value:C,onChange:(A)=>w(A.target.value)})}),_(m,{label:"Repeat new password",children:(N)=>_(v,{...N,type:"password",autoComplete:"new-password",value:i,onChange:(A)=>g(A.target.value)})}),_(o,{$gap:2,children:_(n,{type:"button",$variant:"primary",onClick:p,disabled:e.isPending||l.length===0||C.length===0,children:"Change password"})})]}),M===null?null:_(se,{role:"alert",children:M})]})}function Le(){let e=_t(),l=Ln(),[c,C]=z(""),[w,i]=z(null),[g,M]=z(null),L=e.data?.viewerConfigured===!0,p=()=>{if(c.length<I){i(`A password must be at least ${I} characters.`);return}i(null),l.mutate(c,{onSuccess:()=>{C(""),M(L?"Read-only password replaced.":"Read-only access granted.")},onError:(A)=>i(h(A))})},N=()=>{i(null),l.mutate(null,{onSuccess:()=>M("Read-only access withdrawn."),onError:(A)=>i(h(A))})};return G(r,{$gap:2,children:[_(de,{children:"Read-only password"}),G(ie,{children:["Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies."," ",e.isPending?"Checking whether one is set…":L?"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."]}),G(le,{$gap:2,children:[_(m,{label:L?"Replace read-only password":"Set read-only password",hint:`At least ${I} characters.`,children:(A)=>_(v,{...A,type:"password",autoComplete:"new-password",value:c,onChange:(O)=>C(O.target.value)})}),G(o,{$gap:2,children:[_(n,{type:"button",$variant:"primary",onClick:p,disabled:l.isPending||c.length===0,children:L?"Replace":"Set"}),L?_(n,{type:"button",$variant:"danger",onClick:N,disabled:l.isPending,children:"Withdraw access"}):null]})]}),w===null?null:_(se,{role:"alert",children:w}),g===null||w!==null?null:_(_e,{role:"status",children:g})]})}function ue(){return _(f,{legend:"Access",children:G(r,{$gap:3,children:[_(Ae,{}),_(Mo,{}),_(Le,{})]})})}import{useState as ce}from"react";import X from"styled-components";import{jsx as P,jsxs as K}from"react/jsx-runtime";var me=[{id:"claude",label:"Claude Code",where:"settings.json under ~/.claude"},{id:"opencode",label:"opencode",where:"opencode.json in your project"}],Ne=X(d).withConfig({displayName:"AgentSetup__Sheet"})(["display:block;white-space:pre;overflow-x:auto;padding:0.75rem;background:",";border:1px solid ",";border-radius:4px;font-size:0.8125rem;line-height:1.5;"],({theme:e})=>e.color.panelSunk,({theme:e})=>e.color.rule),Ee=X.div.withConfig({displayName:"AgentSetup__Path"})(["color:",";font-size:0.8125rem;margin-bottom:0.25rem;"],({theme:e})=>e.color.inkDim),j=X.p.withConfig({displayName:"AgentSetup__Note"})(["color:",";font-size:0.8125rem;margin:0;"],({theme:e})=>e.color.inkDim),Pe=X.div.withConfig({displayName:"AgentSetup__MappingGrid"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));gap:",";"],({theme:e})=>e.space(2)),Te=[{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 ge(){let[e,l]=ce("claude"),[c,C]=ce(()=>({claude:{},opencode:{}})),w=H(),i=c[e],g=typeof i.defaultModel==="string"&&i.defaultModel!==""?i:void 0,M=Bo(e,g),L=me.find((p)=>p.id===e);return P(f,{legend:"Agent setup",children:K(r,{children:[P(o,{children:me.map((p)=>P(n,{type:"button",$variant:p.id===e?"primary":"ghost",onClick:()=>l(p.id),children:p.label},p.id))}),K(j,{children:[L?.where,". The key is a placeholder — paste your own over it. Or run"," ",K(d,{children:["omni setup ",e]})," to write these files directly."]}),e==="claude"?K(j,{children:["Claude Code cannot read a window from this gateway, so it assumes 200k for a pool id it does not recognise and auto-compacts there. For a pool whose models hold 1M, append"," ",P(d,{children:"[1m]"})," to the model name — ",P(d,{children:"--model 'pool[1m]'"})," — which lifts it per invocation. The suffix is stripped before the request is sent, so the pool id arrives unchanged."]}):null,(w.data?.length??0)>0?P(Pe,{children:Te.map((p)=>P(m,{label:p.label,children:(N)=>P(R,{...N,value:i[p.key]??"",options:[{value:"",label:p.required?"Choose a pool":"Not mapped"},...(w.data??[]).map((A)=>({value:A.id,label:A.id}))],onValueChange:(A)=>C((O)=>({...O,[e]:{...O[e],[p.key]:A||void 0}}))})},p.key))}):null,w.isLoading?P(b,{rows:2}):M.isError?P(x,{error:M.error,onRetry:()=>void M.refetch()}):M.isLoading?P(b,{rows:4}):(w.data?.length??0)===0?P(j,{children:"No virtual models configured yet, so there is nothing to point a client at."}):g===void 0?K(j,{children:["Choose a default model to generate ",L?.label," settings."]}):M.data===void 0||M.data.length===0?P(j,{children:"No virtual models configured yet, so there is nothing to point a client at."}):M.data.map((p)=>K("div",{children:[P(Ee,{children:p.path}),P(Ne,{as:"pre",children:p.contents.trimEnd()})]},p.path)),M.isError?P(j,{children:h(M.error)}):null]})})}import{jsx as a,jsxs as y,Fragment as ze}from"react/jsx-runtime";var Se={off:"Off",lite:"Lite — names the lazier option",full:"Full — the ladder enforced",ultra:"Ultra — challenges the requirement"},J=[{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."}],oe=[{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:1000,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:1000,min:1},{id:"logRetentionDays",label:"Log retention",hint:"How long request rows are kept before pruning.",unit:"days",step:1,min:1},{id:"bodyRetentionDays",label:"Body retention",hint:"Captured bodies only. Never longer than log retention; swept hourly.",unit:"days",step:1,min:1,max:3650},{id:"quotaPollIntervalMs",label:"Quota poll interval",hint:"How often a provider is asked for remaining quota. 0 disables. Needs a restart.",unit:"ms",step:60000,min:0}],Q=T.div.withConfig({displayName:"SettingsBoard__Weights"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:",";"],({theme:e})=>e.space(3)),D=T(r).withConfig({displayName:"SettingsBoard__Cell"})(["gap:6px;"]),U=T.p.withConfig({displayName:"SettingsBoard__Blurb"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),te=T.div.withConfig({displayName:"SettingsBoard__Options"})(["display:grid;grid-template-columns:1fr;gap:",";align-items:start;"],({theme:e})=>e.space(2)),ke=T.div.withConfig({displayName:"SettingsBoard__Option"})(["display:grid;grid-template-columns:auto 1fr;column-gap:",";row-gap:4px;align-items:center;padding:",";background:",";border:1px solid ",";border-radius:3px;"],({theme:e})=>e.space(2),({theme:e})=>e.space(2),({theme:e})=>e.color.panelSunk,({theme:e})=>e.color.rule),ae=T(U).withConfig({displayName:"SettingsBoard__OptionBlurb"})(["grid-column:2;"]),Me=T.label.withConfig({displayName:"SettingsBoard__OptionName"})(["font-size:12px;font-weight:600;color:",";cursor:pointer;"],({theme:e})=>e.color.ink),$e=T(ke).withConfig({displayName:"SettingsBoard__Choice"})(["grid-template-columns:1fr;","{grid-column:1;}"],ae);function Be({label:e,children:l,blurb:c}){let C=Ce();return y($e,{children:[a(Me,{htmlFor:C,children:e}),l({id:C}),a(ae,{children:c})]})}function Y({label:e,checked:l,disabled:c,onCheckedChange:C,children:w}){let i=Ce();return y(ke,{children:[a(W,{id:i,checked:l,onCheckedChange:C,label:e,...c===void 0?{}:{disabled:c}}),a(Me,{htmlFor:i,children:e}),a(ae,{children:w})]})}var Oe=T.p.withConfig({displayName:"SettingsBoard__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),qe=T.p.withConfig({displayName:"SettingsBoard__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),De=T.span.withConfig({displayName:"SettingsBoard__PolicyCount"})(["font-size:11px;font-family:",";color:",";"],({theme:e})=>e.font.mono,({$over:e,theme:l})=>e?l.color.down:l.color.inkDim),Fe=T.p.withConfig({displayName:"SettingsBoard__Blocked"})(["font-size:12px;color:",";max-width:72ch;code{font-family:",";}"],({theme:e})=>e.color.warn,({theme:e})=>e.font.mono),pe="smart-router-classifier-status",be="smart-router-local-status",fe={ok:null,unset:"Not set; flagged keys' requests are refused.",unresolved:"This model does not resolve.",notLocal:"This model has a target that is not a custom (in-house) endpoint; flagged keys' requests are refused."};function ye(e,l,c,C){let w=(e??"").trim();if(w==="")return C?fe.unset:null;if(c===void 0||c==="unset"||w!==l)return null;return fe[c]}var we=T.p.withConfig({displayName:"SettingsBoard__ModelWarning"})(["font-size:12px;color:",";"],({theme:e})=>e.color.warn);function We(e){let l={};for(let c of J)l[`w.${c.id}`]=String(e.weights[c.id]);for(let c of oe)l[c.id]=String(e[c.id]);return l.rtkEnabled=String(e.rtkEnabled),l.autoCacheEnabled=String(e.autoCacheEnabled),l.ponytailMode=e.ponytailMode,l.bodyLoggingEnabled=String(e.bodyLoggingEnabled),l.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),l.guardrailModel=e.guardrailModel??"",l.guardrailTimeoutMs=String(e.guardrailTimeoutMs),l.guardrailHistoryTurns=String(e.guardrailHistoryTurns),l.smartRouterEnabled=String(e.smartRouterEnabled),l.smartRouterClassifierModel=e.smartRouterClassifierModel??"",l.smartRouterLocalModel=e.smartRouterLocalModel??"",l.smartRouterPolicy=e.smartRouterPolicy,l.smartRouterTimeoutMs=String(e.smartRouterTimeoutMs),l}function He(e){let l={};for(let E of J){let q=(e[`w.${E.id}`]??"").trim(),B=Number(q);if(q.length===0||!Number.isFinite(B))return{ok:!1,problem:`${E.label} must be a number.`};l[E.id]=B}let c={};for(let E of oe){let q=(e[E.id]??"").trim(),B=Number(q);if(q.length===0||!Number.isInteger(B)||B<E.min)return{ok:!1,problem:`${E.label} must be a whole number of ${E.min} or more.`};if(E.max!==void 0&&B>E.max)return{ok:!1,problem:`${E.label} cannot exceed ${E.max}.`};c[E.id]=B}if(c.maxAttempts>10)return{ok:!1,problem:"Attempts per request cannot exceed 10."};let C=(e.guardrailTimeoutMs??"").trim(),w=Number(C);if(C.length===0||!Number.isInteger(w)||w<1||w>Nr)return{ok:!1,problem:`Usage policy check timeout must be a whole number from 1 to ${Nr}.`};let i=(e.guardrailHistoryTurns??"").trim(),g=Number(i);if(i.length===0||!Number.isInteger(g)||g<1||g>Fr)return{ok:!1,problem:`Messages judged must be a whole number from 1 to ${Fr}.`};let M=(e.guardrailModel??"").trim(),L=(e.smartRouterTimeoutMs??"").trim(),p=Number(L);if(L.length===0||!Number.isInteger(p)||p<1||p>Br)return{ok:!1,problem:`Confidential routing timeout must be a whole number from 1 to ${Br}.`};let N=(e.smartRouterPolicy??"").trim();if(N.length===0)return{ok:!1,problem:"Write what counts as confidential, or use Reset to default."};if(N.length>Jt)return{ok:!1,problem:`The confidential policy is at most ${Jt} characters.`};let A=(e.smartRouterClassifierModel??"").trim(),O=(e.smartRouterLocalModel??"").trim();return{ok:!0,settings:{weights:l,...c,rtkEnabled:e.rtkEnabled==="true",autoCacheEnabled:e.autoCacheEnabled==="true",ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(Se,e.ponytailMode)?e.ponytailMode:"off",bodyLoggingEnabled:e.bodyLoggingEnabled==="true",bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks==="true",guardrailModel:M.length===0?null:M,guardrailTimeoutMs:w,guardrailHistoryTurns:g,smartRouterEnabled:e.smartRouterEnabled==="true",smartRouterClassifierModel:A.length===0?null:A,smartRouterLocalModel:O.length===0?null:O,smartRouterPolicy:N,smartRouterTimeoutMs:p}}}function Re(){let e=he(),l=Do(),c=H(),C=Qt(),w=In(),[i,g]=ee({}),[M,L]=ee(null),[p,N]=ee(!1);xe(()=>{if(e.data===void 0)return;g(We(e.data))},[e.data]);let A=Math.max(0.0001,...J.map((s)=>Math.abs(Number(i[`w.${s.id}`])||0))),O=(i.smartRouterPolicy??"").trim().length,E=i.smartRouterEnabled==="true",q=ye(i.smartRouterClassifierModel,e.data?.smartRouterClassifierModel,C.data?.classifier,E),B=ye(i.smartRouterLocalModel,e.data?.smartRouterLocalModel,C.data?.local,E),ne=(s,u,F)=>u===null?s:[s,F].filter((Z)=>Z!==void 0).join(" "),ve=()=>{if(N(!1),e.data===void 0)return;let s=He(i);if(!s.ok){L(s.problem);return}L(null),w.mutate(s.settings,{onSuccess:()=>N(!0),onError:(u)=>L(h(u))})};return y(ze,{children:[a(k,{legend:"Settings",title:"Routing and retention",summary:"Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.",actions:a(n,{type:"button",$variant:"primary",disabled:w.isPending||e.isLoading,onClick:ve,children:w.isPending?"Saving…":"Save changes"})}),e.isError?a(f,{legend:"Settings",children:a(x,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?a(f,{legend:"Settings",children:a(b,{rows:6})}):y(r,{$gap:4,children:[a(f,{legend:"Scoring weights",meta:"relative to each other",footer:y(o,{children:[a(t,{children:"Score is the sum of each term times its weight, then multiplied by the account and target weights."}),a(S,{})]}),children:a(Q,{children:J.map((s)=>{let u=Number(i[`w.${s.id}`])||0;return y(D,{children:[a(m,{label:s.label,children:(F)=>a(v,{...F,type:"number",step:0.5,value:i[`w.${s.id}`]??"",onChange:(Z)=>g({...i,[`w.${s.id}`]:Z.target.value})})}),a(re,{fraction:Math.abs(u)/A,height:4,tone:"var(--accent)",label:`${s.label} weight ${u}`}),a(U,{children:s.blurb})]},s.id)})})}),a(f,{legend:"Limits",children:a(Q,{children:oe.map((s)=>a(D,{children:a(m,{label:s.label,hint:s.hint,children:(u)=>y(o,{$gap:2,children:[a(v,{...u,type:"number",min:s.min,max:s.max,step:s.step,value:i[s.id]??"",onChange:(F)=>g({...i,[s.id]:F.target.value})}),a(t,{children:s.unit})]})})},s.id))})}),y(Ie,{$min:"380px",$stretch:!0,children:[a(f,{legend:"Request handling",meta:"applied before dispatch",children:y(te,{children:[a(Y,{label:"Enable RTK compression",checked:i.rtkEnabled==="true",onCheckedChange:(s)=>g({...i,rtkEnabled:String(s)}),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."}),a(Y,{label:"Add a cache breakpoint when a client sends none",checked:i.autoCacheEnabled==="true",onCheckedChange:(s)=>g({...i,autoCacheEnabled:String(s)}),children:"Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched."}),a(Be,{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:(s)=>a(R,{...s,value:i.ponytailMode??"off",options:Object.entries(Se).map(([u,F])=>({value:u,label:F})),onValueChange:(u)=>g({...i,ponytailMode:u})})})]})}),a(f,{legend:"Request and response bodies",meta:l.data===!0?"permitted by the environment":"not permitted",children:y(r,{$gap:2,children:[l.data===!0?null:y(Fe,{children:["This gateway started without ",a("code",{children:"OMNI_BODY_LOGGING_ALLOWED"}),", so nothing below can record anything. Set it in the installation's ",a("code",{children:".env"})," and restart first."]}),y(te,{children:[a(Y,{label:"Capture request and response bodies",checked:i.bodyLoggingEnabled==="true",disabled:l.data!==!0,onCheckedChange:(s)=>g({...i,bodyLoggingEnabled:String(s)}),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 body retention window above, never later than the request log."}),a(Y,{label:"Also keep raw stream frames",checked:i.bodyLoggingCaptureStreamChunks==="true",disabled:l.data!==!0||i.bodyLoggingEnabled!=="true",onCheckedChange:(s)=>g({...i,bodyLoggingCaptureStreamChunks:String(s)}),children:"Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores."})]})]})})]}),a(f,{legend:"Usage policies",meta:"per-key guardrails",children:y(r,{$gap:2,children:[a(U,{children:"Keys carrying a usage policy have each request judged by this model first. While it is blank, every request from such a key is refused. A guardrail against ordinary misuse, not a security boundary."}),y(Q,{children:[a(D,{children:a(m,{label:"Classifier model",hint:"A configured model, or provider/model. Blank means none.",children:(s)=>a(tt,{...s,placeholder:"none",value:i.guardrailModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,guardrailModel:u})})})}),a(D,{children:a(m,{label:"Check timeout",hint:"A slower check refuses the request it was judging.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Nr,step:1,value:i.guardrailTimeoutMs??"",onChange:(u)=>g({...i,guardrailTimeoutMs:u.target.value})}),a(t,{children:"ms"})]})})}),a(D,{children:a(m,{label:"Messages judged",hint:"How many of the latest human messages are judged together. 1 is the last alone.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Fr,step:1,value:i.guardrailHistoryTurns??"",onChange:(u)=>g({...i,guardrailHistoryTurns:u.target.value})}),a(t,{children:"messages"})]})})})]})]})}),a(f,{legend:"Confidential routing",meta:"per-key, local model",children:y(r,{$gap:3,children:[a(U,{children:"Keys with confidential routing on have each request screened by the classifier model. Requests it judges confidential are answered by the local model instead of the model asked for. Reduces leaks of ordinary confidential content; it is not a security boundary."}),a(te,{children:a(Y,{label:"Enable confidential routing",checked:i.smartRouterEnabled==="true",onCheckedChange:(s)=>g({...i,smartRouterEnabled:String(s)}),children:"Applies only to keys that have it switched on in Keys. While off, no request is screened or rerouted."})}),y(Q,{children:[y(D,{children:[a(m,{label:"Confidential classifier model",hint:"Judges each request. Blank means none.",children:(s)=>a(tt,{...s,"aria-describedby":ne(s["aria-describedby"],q,pe),placeholder:"none",value:i.smartRouterClassifierModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,smartRouterClassifierModel:u})})}),q===null?null:a(we,{id:pe,children:q})]}),y(D,{children:[a(m,{label:"Local model",hint:"Answers requests judged confidential. Blank means none.",children:(s)=>a(tt,{...s,"aria-describedby":ne(s["aria-describedby"],B,be),placeholder:"none",value:i.smartRouterLocalModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,smartRouterLocalModel:u})})}),B===null?null:a(we,{id:be,children:B})]}),a(D,{children:a(m,{label:"Confidential check timeout",hint:"A slower check refuses the request it was screening.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Br,step:1,value:i.smartRouterTimeoutMs??"",onChange:(u)=>g({...i,smartRouterTimeoutMs:u.target.value})}),a(t,{children:"ms"})]})})})]}),a(U,{children:"Must be a virtual model whose targets are all custom (in-house) endpoints. Requests are refused otherwise."}),a(m,{label:"What counts as confidential",hint:"Plain language. The classifier reads this to decide which requests stay on local hardware.",children:(s)=>a(Tr,{...s,rows:6,value:i.smartRouterPolicy??"",onChange:(u)=>g({...i,smartRouterPolicy:u.target.value})})}),y(o,{$gap:2,children:[a(n,{type:"button",$size:"sm",onClick:()=>g({...i,smartRouterPolicy:_n}),children:"Reset to default"}),a(S,{}),y(De,{$over:O>Jt,children:[O," / ",Jt]})]})]})}),M===null?null:a(Oe,{role:"alert",children:M}),p&&M===null?a(qe,{role:"status",children:"Settings saved."}):null,y(Ie,{$min:"380px",$stretch:!0,children:[a(ge,{}),a(ue,{})]}),a(f,{legend:"Known limits",children:y(r,{$gap:2,children:[y(o,{$gap:2,$align:"start",children:[a(d,{$dim:!0,children:"rate limits"}),a(U,{children:"Counted per gateway process and reset when it restarts. Not shared across instances."})]}),y(o,{$gap:2,$align:"start",children:[a(d,{$dim:!0,children:"logs"}),a(U,{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 $t=Re;export{$t as component};
@@ -1 +1 @@
1
- import{t,d,o,r,Ie,Q,M,fe,z,pe,H,we,No,Ue,a,w,V,N,X,oe,K,k,f}from"/assets/index-p9vbm21a.js";import{R}from"/assets/index-f7t0kve8.js";import{Se,st,Xe,yr}from"/assets/index-hk28xepa.js";import"/assets/index-8bewp9z1.js";import{g,ye,u,me,F,ue,Re,c,e,y,B,ve,Gn,Ut,lt,qt,_,De,L,Ne,jt,ie,ht,G,U,Xn,Qn,T,zt,Cr,Lo,Wt,Ht,Qr,ce,Tt,Be,te,Pe,Yr,Zr,Vt,Jr,Ro,gt,Sr,eo,to,ro,Ir,oo,no,Et,kr,ao,io,so,lo,uo,co,Ye,Ze,Ae,Te,Mt,Ot,Lr,Yn,je,Kt,fo,Fe,Ee,Po,Zn,Me,ze,po,We,Je,Rr,mo,Oe,Jn,He,Ve,et,yt}from"/assets/index-z7c4qz9d.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import"/assets/index-d09hs7ex.js";import{useMemo as bt,useState as It}from"react";import Fr from"styled-components";import{useMemo as Ka,useState as ia}from"react";import Qe from"styled-components";import{jsx as xe,jsxs as At}from"react/jsx-runtime";var Pt=53,_e=9,ot=2,Ua=Qe.div.withConfig({displayName:"ActivityGrid__Frame"})(["display:flex;gap:","px;"],ot),qa=Qe.div.withConfig({displayName:"ActivityGrid__Weekdays"})(["display:grid;grid-template-rows:repeat(7,","px);gap:","px;padding-top:","px;font-size:9px;color:",";"],_e,ot,_e+ot,({theme:i})=>i.color.inkFaint),za=Qe.div.withConfig({displayName:"ActivityGrid__Weekday"})(["line-height:","px;padding-right:2px;text-align:right;"],_e),Ga=Qe.div.withConfig({displayName:"ActivityGrid__Months"})(["display:grid;grid-template-columns:repeat(",",","px);gap:","px;height:","px;font-size:9px;color:",";"],Pt,_e,ot,_e,({theme:i})=>i.color.inkFaint),_a=Qe.div.withConfig({displayName:"ActivityGrid__Month"})(["white-space:nowrap;line-height:","px;"],_e),Fa=Qe.div.withConfig({displayName:"ActivityGrid__Weeks"})(["display:grid;grid-template-columns:repeat(",",","px);gap:","px;"],Pt,_e,ot),ja=Qe.div.withConfig({displayName:"ActivityGrid__Week"})(["display:grid;grid-template-rows:repeat(7,","px);gap:","px;"],_e,ot),na=Qe.div.withConfig({displayName:"ActivityGrid__Cell"})(["width:","px;height:","px;border-radius:2px;background:",";border:1px solid var(--rule);visibility:",";&:hover,&:focus-visible{outline:1px solid var(--ink-dim);outline-offset:1px;}"],_e,_e,({$level:i})=>i===0?"var(--panel-sunk)":`color-mix(in oklch, var(--accent) ${[0,24,46,70,100][i]??100}%, var(--panel-sunk))`,({$future:i})=>i?"hidden":"visible"),Xa=Qe(o).withConfig({displayName:"ActivityGrid__Scale"})(["gap:","px;"],ot),Va=Qe(d).withConfig({displayName:"ActivityGrid__Readout"})(["color:",";font-size:11px;"],({theme:i})=>i.color.inkDim);function Ya(i){let n=i.filter((m)=>m>0).sort((m,b)=>m-b);if(n.length===0)return[0,0,0];let p=(m)=>n[Math.min(n.length-1,Math.floor(n.length*m))]??0;return[p(0.25),p(0.5),p(0.75)]}function Ha(i,[n,p,m]){if(i<=0)return 0;if(i<=n)return 1;if(i<=p)return 2;if(i<=m)return 3;return 4}function oa({days:i,now:n,dayOffsetMinutes:p=null}){let[m,b]=ia("tokens"),[h,D]=ia(null),x=fo(m),O=Ka(()=>{let v=new Map;for(let A of i){let Z=Number(A.key);if(!Number.isFinite(Z))continue;v.set(Ee(Z,p),{requests:A.requests,errors:A.errors,costUsd:A.costUsd,inputTokens:A.inputTokens,outputTokens:A.outputTokens,cacheReadTokens:A.cacheReadTokens,cacheWriteTokens:A.cacheWriteTokens,rtkSavedTokens:A.rtkSavedTokens,rtkAppliedRequests:A.rtkAppliedRequests,durationMsSum:A.durationMsSum})}let S=Ee(n,p),Y=Po(S,6-Zn(S,p)-(Pt*7-1),p);return Array.from({length:Pt},()=>Array.from({length:7},()=>{let A=Y;return Y=Po(Y,1,p),{at:A,totals:v.get(A)??We,future:A>S}}))},[i,n,p]),P=O.flat(),C=Ya(P.map((v)=>x.of({key:"",...v.totals}))),I=P.reduce((v,S)=>Je(v,Oe(S.totals)),We),W=P.reduce((v,S)=>v+(S.totals.requests>0?1:0),0),j=(v,S)=>`${v}: ${a(S.requests)} requests, ${a(je(S))} tokens, ${w(S.costUsd)}`;return xe(f,{legend:"Activity",meta:h===null?`${a(W)} active days`:void 0,actions:xe(Xe,{children:Kt.map((v)=>xe(st,{type:"button",$size:"sm",$on:v.id===m,"aria-pressed":v.id===m,onClick:()=>b(v.id),children:v.label},v.id))}),children:At(r,{$gap:2,children:[xe(Q,{children:xe(r,{$gap:1,style:{width:Pt*(_e+ot)+28},children:At(Ua,{children:[xe(qa,{"aria-hidden":"true",children:["","Mon","","Wed","","Fri",""].map((v,S)=>xe(za,{children:v},S))}),At(r,{$gap:1,children:[xe(Ga,{"aria-hidden":"true",children:O.map((v,S)=>{let Y=v[0],A=O[S-1]?.[0],Z=Y!==void 0&&(A===void 0||new Date(A.at).getMonth()!==new Date(Y.at).getMonth());return xe(_a,{children:Z&&Y!==void 0?new Date(Y.at).toLocaleDateString("en-GB",{month:"short"}):""},Y?.at??S)})}),xe(Fa,{role:"grid","aria-label":`${x.label} per day over the last year`,children:O.map((v)=>xe(ja,{role:"row",children:v.map((S)=>xe(na,{role:"gridcell",tabIndex:-1,"aria-label":j(po(S.at),S.totals),title:j(po(S.at),S.totals),$future:S.future,$level:S.future?0:Ha(x.of({key:"",...S.totals}),C),onMouseEnter:()=>D(S),onMouseLeave:()=>D(null)},S.at))},v[0]?.at))})]})]})})}),At(o,{$justify:"space-between",$wrap:!0,children:[xe(Va,{children:h===null?j("Last 12 months",I):j(po(h.at),h.totals)}),At(o,{$gap:1,children:[xe(t,{children:"Less"}),xe(Xa,{"aria-hidden":"true",children:[0,1,2,3,4].map((v)=>xe(na,{$level:v,$future:!1},v))}),xe(t,{children:"More"})]})]})]})})}import{jsx as be,jsxs as Yt}from"react/jsx-runtime";function sa({buckets:i,by:n,since:p,until:m,metric:b,names:h,dayOffsetMinutes:D}){let x=Me(p,m,n,D),O=new Map,P=new Map;for(let I of i){let W=I.split??"unknown";O.set(W,Je(O.get(W)??We,I));let j=P.get(W)??new Map,v=Fe(I.key,n);j.set(v,(j.get(v)??0)+b.of(I)),P.set(W,j)}let C=[...O.entries()].sort((I,W)=>b.of(Oe(W[1]))-b.of(Oe(I[1])));return be(Q,{children:Yt(q,{children:[be("thead",{children:Yt("tr",{children:[be(l,{children:"Key"}),be(l,{children:"Trend"}),be(l,{$align:"right",children:"Requests"}),be(l,{$align:"right",children:"Failed"}),be(l,{$align:"right",children:"Tokens"}),be(l,{$align:"right",children:"Mean"}),be(l,{$align:"right",children:"Cost"})]})}),be("tbody",{children:C.map(([I,W])=>{let j=P.get(I)??new Map,v=I==="unknown"?"Unattributed":h.get(I)??I;return Yt(E,{children:[be(s,{children:be(M,{style:{display:"block",maxWidth:"28ch"},children:v})}),be(s,{style:{width:120},children:be(K,{values:x.map((S)=>j.get(S)??0),height:20,label:`${v}: ${b.format(b.of(Oe(W)))} over the window`})}),be(s,{$align:"right",$mono:!0,children:a(W.requests)}),be(s,{$align:"right",$mono:!0,style:W.errors>0?{color:"var(--down)"}:void 0,children:N(W.requests===0?0:W.errors/W.requests,0)}),be(s,{$align:"right",$mono:!0,children:a(je(W))}),be(s,{$align:"right",$mono:!0,children:V(W.requests===0?null:W.durationMsSum/W.requests)}),be(s,{$align:"right",$mono:!0,children:w(W.costUsd)})]},I)})})]})})}import*as ee from"react";import{PureComponent as fr,useMemo as hr,useRef as ka}from"react";function Lt(i,n){var p,m;return(p=(m=i.graphicalItems.cartesianItems.find((b)=>b.id===n))===null||m===void 0?void 0:m.xAxisId)!==null&&p!==void 0?p:Ro}function Bt(i,n){var p,m;return(p=(m=i.graphicalItems.cartesianItems.find((b)=>b.id===n))===null||m===void 0?void 0:m.yAxisId)!==null&&p!==void 0?p:Ro}var la=(i,n,p)=>Ht(i,"xAxis",Lt(i,n),p),da=(i,n,p)=>Wt(i,"xAxis",Lt(i,n),p),ca=(i,n,p)=>Ht(i,"yAxis",Bt(i,n),p),ua=(i,n,p)=>Wt(i,"yAxis",Bt(i,n),p),Za=e([L,la,ca,da,ua],(i,n,p,m,b)=>{if(ve(i,"xAxis"))return lt(n,m,!1);return lt(p,b,!1)}),Ja=(i,n)=>n,Zt=e([Cr,Ja],(i,n)=>i.filter((p)=>p.type==="area").find((p)=>p.id===n)),pa=(i)=>{var n=L(i),p=ve(n,"xAxis");return p?"yAxis":"xAxis"},Qa=(i,n)=>{var p=pa(i);if(p==="yAxis")return Bt(i,n);return Lt(i,n)},ma=(i,n,p)=>Lo(i,pa(i),Qa(i,n),p),er=e([Zt,ma],(i,n)=>{var p;if(i==null||n==null)return;var m=i.stackId,b=zt(i);if(m==null||b==null)return;var h=(p=n[m])===null||p===void 0?void 0:p.stackedData,D=h===null||h===void 0?void 0:h.find((x)=>x.key===b);if(D==null)return;return D.map((x)=>[x[0],x[1]])}),tr=e([Zt,ma],(i,n)=>{if(i==null||i.stackId==null||n==null)return;var p=n[i.stackId];if(p==null)return;return p.graphicalItems.map((m)=>m.dataKey).filter(ue)}),fa=e([L,la,ca,da,ua,er,Xn,Za,Zt,Qn,tr],(i,n,p,m,b,h,D,x,O,P,C)=>{var{chartData:I,dataStartIndex:W,dataEndIndex:j}=D;if(O==null||i!=="horizontal"&&i!=="vertical"||n==null||p==null||m==null||b==null||m.length===0||b.length===0||x==null)return;var v=O.data,S;if(v&&v.length>0)S=v;else S=I===null||I===void 0?void 0:I.slice(W,j+1);if(S==null)return;return ha({layout:i,xAxis:n,yAxis:p,xAxisTicks:m,yAxisTicks:b,dataStartIndex:W,areaSettings:O,stackedData:h,displayedData:S,chartBaseValue:P,bandSize:x,stackDataKeys:C})});import*as $e from"react";var ar=["animationElapsedTime","isAnimating","isEntrance","layout","isRange","stroke","connectNulls"],rr=["id","baseLine"];function Ct(){return Ct=Object.assign?Object.assign.bind():function(i){for(var n=1;n<arguments.length;n++){var p=arguments[n];for(var m in p)({}).hasOwnProperty.call(p,m)&&(i[m]=p[m])}return i},Ct.apply(null,arguments)}function va(i,n){if(i==null)return{};var p,m,b=ir(i,n);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(i);for(m=0;m<h.length;m++)p=h[m],n.indexOf(p)===-1&&{}.propertyIsEnumerable.call(i,p)&&(b[p]=i[p])}return b}function ir(i,n){if(i==null)return{};var p={};for(var m in i)if({}.hasOwnProperty.call(i,m)){if(n.indexOf(m)!==-1)continue;p[m]=i[m]}return p}function nr(i){var n,p,{alpha:m,baseLine:b,points:h,strokeWidth:D}=i,x=(n=h[0])===null||n===void 0?void 0:n.x,O=(p=h[h.length-1])===null||p===void 0?void 0:p.x;if(!y(x)||!y(O))return null;var P=m*Math.abs(x-O),C=Math.max(...h.map((I)=>I.y||0));if(u(b))C=Math.max(b,C);else if(b&&Array.isArray(b)&&b.length)C=Math.max(...b.map((I)=>I.y||0),C);if(u(C))return $e.createElement("rect",{x:x<O?x:x-P,y:0,width:P,height:Math.floor(C+(D?parseInt("".concat(D),10):1))});return null}function or(i){var n,p,{alpha:m,baseLine:b,points:h,strokeWidth:D}=i,x=(n=h[0])===null||n===void 0?void 0:n.y,O=(p=h[h.length-1])===null||p===void 0?void 0:p.y;if(!y(x)||!y(O))return null;var P=m*Math.abs(x-O),C=Math.max(...h.map((I)=>I.x||0));if(u(b))C=Math.max(b,C);else if(b&&Array.isArray(b)&&b.length)C=Math.max(...b.map((I)=>I.x||0),C);if(u(C))return $e.createElement("rect",{x:0,y:x<O?x:x-P,width:C+(D?parseInt("".concat(D),10):1),height:Math.floor(P)});return null}function sr(i){var{alpha:n,layout:p,points:m,baseLine:b,strokeWidth:h}=i;if(p==="vertical")return $e.createElement(or,{alpha:n,points:m,baseLine:b,strokeWidth:h});return $e.createElement(nr,{alpha:n,points:m,baseLine:b,strokeWidth:h})}function ya(i){var n=i.animationElapsedTime,p=n===void 0?1:n,m=i.isAnimating,b=m===void 0?!1:m,h=i.isEntrance,D=h===void 0?!1:h,{layout:x,isRange:O,stroke:P,connectNulls:C}=i,I=va(i,ar),W=x==="vertical"?"vertical":"horizontal",j=C!==null&&C!==void 0?C:!1,v=to(),{id:S,baseLine:Y}=I,A=va(I,rr),Z=ie(A),re=$e.createElement(ht,Ct({},I,{id:S,baseLine:Y,connectNulls:j,stroke:"none",className:"recharts-area-area",layout:W})),le=P!=="none"&&$e.createElement(ht,Ct({},Z,{className:"recharts-area-curve",layout:W,type:I.type,connectNulls:j,fill:"none",stroke:P,points:I.points})),ne=P!=="none"&&O&&Array.isArray(Y)&&$e.createElement(ht,Ct({},Z,{className:"recharts-area-curve",layout:W,type:I.type,connectNulls:j,fill:"none",stroke:P,points:Y}));if(D&&(b||p<1)){var ae;return $e.createElement(te,null,$e.createElement("defs",null,$e.createElement("clipPath",{id:v},$e.createElement(sr,{alpha:p,points:(ae=I.points)!==null&&ae!==void 0?ae:[],baseLine:Y,layout:W,strokeWidth:I.strokeWidth}))),$e.createElement(te,{clipPath:"url(#".concat(v,")")},re,le,ne))}return $e.createElement($e.Fragment,null,re,le,ne)}var lr=["id"],dr=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Dt(){return Dt=Object.assign?Object.assign.bind():function(i){for(var n=1;n<arguments.length;n++){var p=arguments[n];for(var m in p)({}).hasOwnProperty.call(p,m)&&(i[m]=p[m])}return i},Dt.apply(null,arguments)}function ba(i,n){if(i==null)return{};var p,m,b=cr(i,n);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(i);for(m=0;m<h.length;m++)p=h[m],n.indexOf(p)===-1&&{}.propertyIsEnumerable.call(i,p)&&(b[p]=i[p])}return b}function cr(i,n){if(i==null)return{};var p={};for(var m in i)if({}.hasOwnProperty.call(i,m)){if(n.indexOf(m)!==-1)continue;p[m]=i[m]}return p}function ga(i,n){var p=Object.keys(i);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(i);n&&(m=m.filter(function(b){return Object.getOwnPropertyDescriptor(i,b).enumerable})),p.push.apply(p,m)}return p}function vt(i){for(var n=1;n<arguments.length;n++){var p=arguments[n]!=null?arguments[n]:{};n%2?ga(Object(p),!0).forEach(function(m){ur(i,m,p[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(p)):ga(Object(p)).forEach(function(m){Object.defineProperty(i,m,Object.getOwnPropertyDescriptor(p,m))})}return i}function ur(i,n,p){return(n=pr(n))in i?Object.defineProperty(i,n,{value:p,enumerable:!0,configurable:!0,writable:!0}):i[n]=p,i}function pr(i){var n=mr(i,"string");return typeof n=="symbol"?n:n+""}function mr(i,n){if(typeof i!="object"||!i)return i;var p=i[Symbol.toPrimitive];if(p!==void 0){var m=p.call(i,n||"default");if(typeof m!="object")return m;throw TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(i)}var vr=(i,n)=>{if(i==null)return[];if(n===1)return i.flatMap((p)=>p.status==="removed"?[]:[p.next]);return i.flatMap((p)=>{if(p.status==="matched")return[vt(vt({},p.next),{},{x:me(p.prev.x,p.next.x,n),y:me(p.prev.y,p.next.y,n)})];if(p.status==="added")return[p.next];return[]})},xa={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",animationMatchBy:Et,animationInterpolateFn:vr,connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:0.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,shape:ya,xAxisId:0,yAxisId:0,zIndex:T.area};function Gt(i,n){return i&&i!=="none"?i:n}var gr=(i)=>{var{dataKey:n,name:p,stroke:m,fill:b,legendType:h,hide:D}=i;return[{inactive:D,dataKey:n,type:h,color:Gt(m,b),value:qt(p,n),payload:i}]},br=ee.memo((i)=>{var{dataKey:n,data:p,stroke:m,strokeWidth:b,fill:h,name:D,hide:x,unit:O,formatter:P,tooltipType:C,id:I}=i,W={dataDefinedOnItem:p,getPosition:Re,settings:{stroke:m,strokeWidth:b,fill:h,dataKey:n,nameKey:void 0,name:qt(D,n),hide:x,type:C,color:Gt(m,h),unit:O,formatter:P,graphicalItemId:I}};return ee.createElement(eo,{tooltipEntrySettings:W})});function xr(i){var{clipPathId:n,points:p,props:m}=i,{needClip:b,dot:h,dataKey:D}=m,x=ie(m);return ee.createElement(Jr,{points:p,dot:h,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:D,baseProps:x,needClip:b,clipPathId:n})}function Ar(i){var{showLabels:n,children:p,points:m}=i,b=m.map((h)=>{var D,x,O={x:(D=h.x)!==null&&D!==void 0?D:0,y:(x=h.y)!==null&&x!==void 0?x:0,width:0,lowerWidth:0,upperWidth:0,height:0};return vt(vt({},O),{},{value:h.value,payload:h.payload,parentViewBox:void 0,viewBox:O,fill:void 0})});return ee.createElement(Yr,{value:n?b:void 0},p)}function Tr(i){var{points:n,baseLine:p,needClip:m,clipPathId:b,props:h,animationElapsedTime:D,isAnimating:x,isEntrance:O}=i,{layout:P,type:C,stroke:I,connectNulls:W,isRange:j,shape:v,id:S}=h,Y=ba(h,lr),A=G(Y),Z=vt(vt({},A),{},{id:S,points:n,connectNulls:W,type:C,baseLine:p,layout:P,stroke:I,isRange:j,animationElapsedTime:D,isAnimating:x,isEntrance:O});return ee.createElement(ee.Fragment,null,(n===null||n===void 0?void 0:n.length)>1&&ee.createElement(te,{clipPath:m?"url(#clipPath-".concat(b,")"):void 0},ee.createElement(co,{option:v,DefaultShape:xa.shape,shapeProps:Z})),ee.createElement(xr,{points:n,props:Y,clipPathId:b}))}function Pr(i,n,p){if(u(i)){var m=u(n)?n:void 0;return me(m,i,p)}if(F(i)||ye(i)){var b=u(n)?n:void 0;return me(b,0,p)}return i}function wr(i){var{needClip:n,clipPathId:p,props:m,previousPointsRef:b,previousBaselineRef:h}=i,{points:D,baseLine:x,isAnimationActive:O,animationBegin:P,animationDuration:C,animationEasing:I,animationMatchBy:W,animationInterpolateFn:j}=m,v=hr(()=>({points:D,baseLine:x}),[D,x]),S=ao(v,h),Y=jt(),A=io(m.onAnimationStart,m.onAnimationEnd),{isAnimating:Z,handleAnimationStart:re,handleAnimationEnd:le}=A,ne=S.startValue;if(Y==null)return null;var ae;if(Array.isArray(x)&&Array.isArray(ne))ae=kr(ne,x,W);else if(Array.isArray(x))ae=kr(null,x,W);else ae=null;return ee.createElement(so,{animationInput:v,animationIdPrefix:"recharts-area-",items:D,previousItemsRef:b,isAnimationActive:O,animationBegin:P,animationDuration:C,animationEasing:I,onAnimationStart:re,onAnimationEnd:le,animationInterpolateFn:j,animationMatchBy:W,layout:Y},(ge,he,Ce)=>{var ke;if(he===1)ke=x;else if(Array.isArray(x))ke=j(ae,he,Y);else ke=Ce?x:Pr(x,ne,he);return S.syncStepValue(ke,he),ee.createElement(Ar,{showLabels:!Z,points:D},m.children,ee.createElement(Tr,{points:ge,baseLine:ke,needClip:n,clipPathId:p,props:m,animationElapsedTime:he,isAnimating:Z||he<1,isEntrance:Ce}),ee.createElement(Zr,{label:m.label}))})}function $r(i){var{needClip:n,clipPathId:p,props:m}=i,b=ka(null),h=ka();return ee.createElement(wr,{needClip:n,clipPathId:p,props:m,previousPointsRef:b,previousBaselineRef:h})}class Aa extends fr{render(){var i=this.props,{hide:n,dot:p,points:m,className:b,top:h,left:D,needClip:x,xAxisId:O,yAxisId:P,width:C,height:I,id:W,baseLine:j,zIndex:v}=i;if(n)return null;var S=g("recharts-area",b),Y=W,A=uo(p),{r:Z,strokeWidth:re}=A,le=Vt(p),ne=Z*2+re,ae=x?"url(#clipPath-".concat(le?"":"dots-").concat(Y,")"):void 0;return ee.createElement(ce,{zIndex:v},ee.createElement(te,{className:S},x&&ee.createElement("defs",null,ee.createElement(oo,{clipPathId:Y,xAxisId:O,yAxisId:P}),!le&&ee.createElement("clipPath",{id:"clipPath-dots-".concat(Y)},ee.createElement("rect",{x:D-ne/2,y:h-ne/2,width:C+ne,height:I+ne}))),ee.createElement($r,{needClip:x,clipPathId:Y,props:this.props})),ee.createElement(Sr,{points:m,mainColor:Gt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:ae}),this.props.isRange&&Array.isArray(j)&&ee.createElement(Sr,{points:j,mainColor:Gt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:ae}))}}function Mr(i){var n,{activeDot:p,animationBegin:m,animationDuration:b,animationEasing:h,connectNulls:D,dot:x,fill:O,fillOpacity:P,hide:C,isAnimationActive:I,legendType:W,stroke:j,xAxisId:v,yAxisId:S}=i,Y=ba(i,dr),A=Ne(),Z=Qr(),re=Ir(v,S),le=re.needClip,ne=_(),ae=(n=c((mt)=>fa(mt,i.id,ne)))!==null&&n!==void 0?n:{},{points:ge,isRange:he,baseLine:Ce}=ae,ke=gt();if(A!=="horizontal"&&A!=="vertical"||ke==null)return null;if(Z!=="AreaChart"&&Z!=="ComposedChart")return null;var{height:qe,width:tt,x:at,y:pt}=ke;if(!ge||!ge.length)return null;return ee.createElement(Aa,Dt({},Y,{activeDot:p,animationBegin:m,animationDuration:b,animationEasing:h,baseLine:Ce,connectNulls:D,dot:x,fill:O,fillOpacity:P,height:qe,hide:C,layout:A,isAnimationActive:I,isRange:he,legendType:W,needClip:le,points:ge,stroke:j,width:tt,left:at,top:pt,xAxisId:v,yAxisId:S}))}var Er=(i,n,p,m,b)=>{var h=p!==null&&p!==void 0?p:n;if(u(h))return h;var D=i==="horizontal"?b:m,x=D.scale.domain();if(D.type==="number"){var O=Math.max(x[0],x[1]),P=Math.min(x[0],x[1]);if(h==="dataMin")return P;if(h==="dataMax")return O;return O<0?O:Math.max(Math.min(x[0],x[1]),0)}if(h==="dataMin")return x[0];if(h==="dataMax")return x[1];return x[0]};function ha(i){var n=i.areaSettings,{connectNulls:p,baseValue:m,dataKey:b}=n,{stackedData:h,layout:D,chartBaseValue:x,xAxis:O,yAxis:P,displayedData:C,dataStartIndex:I,xAxisTicks:W,yAxisTicks:j,bandSize:v,stackDataKeys:S}=i,Y=h&&h.length,A=Er(D,x,m,O,P),Z=D==="horizontal",re=!1,le=C.map((ae,ge)=>{var he,Ce,ke,qe;if(Y)qe=h[I+ge];else{var tt=B(ae,b);if(!Array.isArray(tt))qe=[A,tt];else qe=tt,re=!0}var at=(he=(Ce=qe)===null||Ce===void 0?void 0:Ce[1])!==null&&he!==void 0?he:null,pt=B(ae,b),mt=Y&&pt==null&&S!=null&&S.length>0&&S.every((Ft)=>B(ae,Ft)==null),Nt=at==null||Y&&!p&&pt==null||mt;if(Z){var xt;return{x:Ut({axis:O,ticks:W,bandSize:v,entry:ae,index:ge}),y:Nt?null:(xt=P.scale.map(at))!==null&&xt!==void 0?xt:null,value:qe,payload:ae}}return{x:Nt?null:(ke=O.scale.map(at))!==null&&ke!==void 0?ke:null,y:Ut({axis:P,ticks:j,bandSize:v,entry:ae,index:ge}),value:qe,payload:ae}}),ne;if(Y||re)ne=le.map((ae)=>{var ge,he=Array.isArray(ae.value)?ae.value[0]:null;if(Z){var Ce;return{x:ae.x,y:he!=null&&ae.y!=null?(Ce=P.scale.map(he))!==null&&Ce!==void 0?Ce:null:null,payload:ae.payload}}return{x:he!=null?(ge=O.scale.map(he))!==null&&ge!==void 0?ge:null:null,y:ae.y,payload:ae.payload}});else ne=Z?P.scale.map(A):O.scale.map(A);return{points:le,baseLine:ne!==null&&ne!==void 0?ne:0,isRange:re}}function Nr(i){var n=U(i,xa),p=_();return ee.createElement(ro,{id:n.id,type:"area"},(m)=>ee.createElement(ee.Fragment,null,ee.createElement(no,{legendPayload:gr(n)}),ee.createElement(br,{dataKey:n.dataKey,data:n.data,stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,name:n.name,hide:n.hide,unit:n.unit,formatter:n.formatter,tooltipType:n.tooltipType,id:m}),ee.createElement(lo,{type:"area",id:m,data:n.data,dataKey:n.dataKey,xAxisId:n.xAxisId,yAxisId:n.yAxisId,zAxisId:0,stackId:Gn(n.stackId),hide:n.hide,barSize:void 0,baseValue:n.baseValue,isPanorama:p,connectNulls:n.connectNulls}),ee.createElement(Mr,Dt({},n,{id:m}))))}var rt=ee.memo(Nr,Ye);rt.displayName="Area";import*as Ta from"react";import{forwardRef as Or}from"react";var Br=["axis"],kt=Or((i,n)=>Ta.createElement(Mt,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Br,tooltipPayloadSearcher:Tt,categoricalChartProps:i,ref:n}));import*as Pa from"react";import{forwardRef as Dr}from"react";var Wr=["axis"],Ca=Dr((i,n)=>Pa.createElement(Mt,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Wr,tooltipPayloadSearcher:Tt,categoricalChartProps:i,ref:n}));import{jsx as Ge,jsxs as St}from"react/jsx-runtime";var Sa=6,Ra="__other__",wa="unknown";function Ia(i,n,p){let m=p.get(n);if(m!==void 0)return m;return i.find((b)=>b.models.some((h)=>h.id===n))?.id??null}function Kr(i,n){if(i===null)return"var(--ink-faint)";return`color-mix(in oklch, ${oe(i)} ${Math.max(30,100-n*22)}%, var(--panel))`}function $a({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b,metric:h,providers:D}){let x=fe().data??[],O=[...mo(i,h).entries()],P=O.slice(0,Sa),C=O.slice(Sa),I=[...new Set(P.map(([A])=>Ia(x,A,D)))].filter((A)=>A!==null&&z(x,A)===void 0).sort(),W=[];for(let A of[...x.map((Z)=>Z.id),...I,null])P.filter(([Z])=>Ia(x,Z,D)===A).forEach(([Z,re],le)=>{W.push({name:Z,label:Z===wa?"Unresolved":Z,color:Kr(A,le),totals:re})});if(C.length>0)W.push({name:Ra,label:`${C.length} more`,color:"var(--ink-faint)",totals:C.reduce((A,[,Z])=>Je(A,Oe(Z)),We)});let j=new Set(P.map(([A])=>A)),v=new Map;for(let A of i){let Z=A.split??wa,re=`${Fe(A.key,n)} ${j.has(Z)?Z:Ra}`;v.set(re,(v.get(re)??0)+h.of(A))}let S=Me(p,m,n,b).map((A)=>{let Z={at:A};for(let re of W)Z[re.name]=v.get(`${A} ${re.name}`)??0;return Z}),Y=new Map(W.map((A)=>[A.name,A.label]));return St(r,{$gap:2,children:[Ge(He,{$height:220,children:Ge(De,{width:"100%",height:"100%",children:St(kt,{data:S,margin:{top:4,right:4,bottom:4,left:4},children:[Ge(Pe,{stroke:"var(--rule)",vertical:!1}),Ge(Ae,{dataKey:"at",tickFormatter:(A)=>ze(A,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Ge(Te,{tickFormatter:(A)=>h.format(A),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:40}),Ge(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:A,payload:Z,label:re})=>{if(A!==!0||Z===void 0||Z.length===0)return null;let le=Z.filter((ne)=>Number(ne.value??0)>0);return St(Ve,{children:[Ge("div",{children:ze(Number(re),n)}),le.length===0?Ge("div",{children:`No ${h.label.toLowerCase()}`}):le.map((ne)=>St("div",{children:[Y.get(String(ne.dataKey))??String(ne.dataKey)," ",h.format(Number(ne.value??0))]},String(ne.dataKey)))]})}}),W.map((A)=>Ge(rt,{type:"monotone",dataKey:A.name,stackId:"models",stroke:A.color,strokeWidth:2,fill:A.color,fillOpacity:0.22,isAnimationActive:!1},A.name))]})})}),Ge(yt,{children:W.map((A)=>St("span",{children:[Ge(et,{$color:A.color})," ",Ge(M,{title:`${A.label}: ${h.format(h.of(Oe(A.totals)))} ${h.label.toLowerCase()}`,style:{display:"inline-block",maxWidth:"24ch",verticalAlign:"bottom"},children:A.label})]},A.name))})]})}import{jsx as de,jsxs as it}from"react/jsx-runtime";var Qt="unknown";function _t(i,n){return z(i,n)===void 0?"var(--ink-faint)":oe(n)}function Jt(i,n){if(n===Qt)return"Unresolved";return z(i,n)?.label??n}function Ma({buckets:i,by:n,since:p,until:m,metric:b,dayOffsetMinutes:h}){let D=fe().data??[],x=mo(i,b),O=[...x.keys()].filter((v)=>v!==Qt&&z(D,v)===void 0).sort(),P=[...D.map((v)=>v.id),...O,Qt].map((v)=>({name:v,totals:x.get(v)})).filter((v)=>v.totals!==void 0),C=P.map((v)=>v.name),I=Me(p,m,n,h),W=Jn(i,I,n,b),j=[...x.values()].reduce((v,S)=>v+S.requests,0);return it(r,{$gap:3,children:[de(He,{$height:200,children:de(De,{width:"100%",height:"100%",children:it(kt,{data:W,margin:{top:4,right:4,bottom:4,left:4},children:[de(Pe,{stroke:"var(--rule)",vertical:!1}),de(Ae,{dataKey:"at",tickFormatter:(v)=>ze(v,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),de(Te,{tickFormatter:(v)=>b.format(v),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:48}),de(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:v,payload:S,label:Y})=>{if(v!==!0||S===void 0||S.length===0)return null;return it(Ve,{children:[de("div",{children:ze(Number(Y),n)}),S.map((A)=>it("div",{children:[Jt(D,String(A.dataKey))," ",b.format(Number(A.value??0))]},String(A.dataKey)))]})}}),C.map((v)=>de(rt,{type:"monotone",dataKey:v,stackId:"providers",stroke:_t(D,v),strokeWidth:2,fill:_t(D,v),fillOpacity:0.22,isAnimationActive:!1},v))]})})}),de(yt,{children:C.map((v)=>it("span",{children:[de(et,{$color:_t(D,v)})," ",Jt(D,v)]},v))}),it(q,{children:[de("thead",{children:it("tr",{children:[de(l,{children:"Provider"}),de(l,{$align:"right",children:"Share"}),de(l,{$align:"right",children:"Requests"}),de(l,{$align:"right",children:"Failed"}),de(l,{$align:"right",children:"Tokens"}),de(l,{$align:"right",children:"Cost"})]})}),de("tbody",{children:P.map(({name:v,totals:S})=>it(E,{children:[it(s,{children:[de(et,{$color:_t(D,v)})," ",Jt(D,v)]}),de(s,{$align:"right",$mono:!0,children:N(j===0?0:S.requests/j,0)}),de(s,{$align:"right",$mono:!0,children:a(S.requests)}),de(s,{$align:"right",$mono:!0,style:S.errors>0?{color:"var(--down)"}:void 0,children:a(S.errors)}),de(s,{$align:"right",$mono:!0,children:a(je(S))}),de(s,{$align:"right",$mono:!0,children:w(S.costUsd)})]},v))})]})]})}import Rt from"styled-components";import{jsx as ut,jsxs as ea}from"react/jsx-runtime";var Ur=Rt.li.withConfig({displayName:"RankPanel__Rank"})(["display:grid;grid-template-columns:minmax(0,20ch) 1fr auto;align-items:center;gap:",";"],({theme:i})=>i.space(2)),qr=Rt.ol.withConfig({displayName:"RankPanel__List"})(["display:flex;flex-direction:column;gap:",";"],({theme:i})=>i.space(2)),zr=Rt.div.withConfig({displayName:"RankPanel__Track"})(["height:8px;border-radius:2px;background:",";border:1px solid ",";overflow:hidden;"],({theme:i})=>i.color.panelSunk,({theme:i})=>i.color.rule),Gr=Rt.div.withConfig({displayName:"RankPanel__Fill"})(["width:",";height:100%;border-radius:0 2px 2px 0;background:",";opacity:0.85;"],({$share:i})=>`${Math.max(1.5,i*100)}%`,({theme:i,$fault:n})=>n?i.color.down:i.color.accent),_r=Rt(M).withConfig({displayName:"RankPanel__Name"})(["display:block;font-family:",";font-size:12px;"],({theme:i})=>i.font.mono),Ea=12;function ta({buckets:i,metric:n,names:p,unknownLabel:m}){let b=new Map;for(let C of i)b.set(C.key,Je(b.get(C.key)??We,C));let h=(C)=>C==="unknown"?m??"Unattributed":p?.get(C)??C,D=[...b.entries()].map(([C,I])=>({name:h(C),entry:I,value:n.of(Oe(I))})).sort((C,I)=>I.value-C.value),x=D.slice(0,Ea),O=D.slice(Ea),P=x[0]?.value??0;return ea(r,{$gap:3,children:[ut(qr,{children:x.map(({name:C,entry:I,value:W})=>ea(Ur,{children:[ut(_r,{title:C,children:C}),ut(zr,{children:ut(Gr,{$share:P===0?0:W/P,$fault:I.requests>0&&I.errors===I.requests})}),ea(o,{$gap:2,children:[ut(d,{$size:"12px",children:n.format(W)}),ut(d,{$size:"11px",$dim:!0,children:w(I.costUsd)})]})]},C))}),O.length===0?null:ut(d,{$size:"11px",$dim:!0,children:`+ ${O.length} more, ${a(O.reduce((C,I)=>C+I.entry.requests,0))} requests`})]})}import{jsx as Le,jsxs as wt}from"react/jsx-runtime";var aa=[{id:"inputTokens",label:"Uncached input",opacity:0.95},{id:"outputTokens",label:"Output",opacity:0.7},{id:"cacheReadTokens",label:"Cache read",opacity:0.45},{id:"cacheWriteTokens",label:"Cache write",opacity:0.22}];function Na({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b}){let h=new Map;for(let P of i)h.set(Fe(P.key,n),P);let D=Me(p,m,n,b).map((P)=>{let C=h.get(P);return{at:P,inputTokens:C?.inputTokens??0,outputTokens:C?.outputTokens??0,cacheReadTokens:C?.cacheReadTokens??0,cacheWriteTokens:C?.cacheWriteTokens??0}}),x=aa.map((P)=>({...P,value:D.reduce((C,I)=>C+I[P.id],0)})),O=x.reduce((P,C)=>P+C.value,0);return wt(r,{$gap:3,children:[Le(He,{$height:200,children:Le(De,{width:"100%",height:"100%",children:wt(kt,{data:D,margin:{top:4,right:4,bottom:4,left:4},children:[Le(Pe,{stroke:"var(--rule)",vertical:!1}),Le(Ae,{dataKey:"at",tickFormatter:(P)=>ze(P,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Le(Te,{tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:44,tickFormatter:(P)=>a(P)}),Le(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:P,payload:C,label:I})=>{if(P!==!0||C===void 0||C.length===0)return null;return wt(Ve,{children:[Le("div",{children:ze(Number(I),n)}),aa.map((W)=>wt("div",{children:[W.label," ",a(Number(C.find((j)=>j.dataKey===W.id)?.value??0))]},W.id))]})}}),aa.map((P)=>Le(rt,{type:"monotone",dataKey:P.id,stackId:"tokens",stroke:"var(--accent)",strokeOpacity:P.opacity,strokeWidth:1.5,fill:"var(--accent)",fillOpacity:P.opacity*0.5,isAnimationActive:!1},P.id))]})})}),Le(yt,{children:x.map((P)=>wt(o,{$gap:1,children:[Le(et,{$color:"var(--accent)",style:{opacity:P.opacity}}),Le("span",{children:P.label}),Le(d,{$size:"11px",children:a(P.value)}),Le(d,{$size:"11px",$dim:!0,children:N(O===0?0:P.value/O,0)})]},P.id))})]})}import{jsx as Ke,jsxs as nt}from"react/jsx-runtime";function Oa({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b}){let h=new Map;for(let x of i)h.set(Fe(x.key,n),x);let D=Me(p,m,n,b).map((x)=>{let O=h.get(x);return{at:x,label:ze(x,n),requests:O?.requests??0,errors:O?.errors??0,costUsd:O?.costUsd??0,tokens:O===void 0?0:je(O)}});return nt(r,{$gap:2,children:[Ke(He,{$height:220,children:Ke(De,{width:"100%",height:"100%",children:nt(Ca,{data:D,margin:{top:4,right:4,bottom:4,left:4},children:[Ke(Pe,{stroke:"var(--rule)",vertical:!1}),Ke(Ae,{dataKey:"label",tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Ke(Te,{tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:40}),Ke(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:x,payload:O})=>{if(x!==!0||O===void 0||O.length===0)return null;let P=O[0]?.payload;if(P===void 0)return null;return nt(Ve,{children:[Ke("div",{children:P.label}),nt("div",{children:[a(P.requests)," requests"]}),nt("div",{children:[a(P.errors)," failed"]}),nt("div",{children:[a(P.tokens)," tokens"]}),Ke("div",{children:w(P.costUsd)})]})}}),Ke(rt,{type:"monotone",dataKey:"requests",stroke:"none",fill:"var(--accent)",fillOpacity:0.12,isAnimationActive:!1}),Ke(Ze,{type:"monotone",dataKey:"requests",stroke:"var(--accent)",strokeWidth:2,dot:!1,activeDot:{r:4,stroke:"var(--panel)",strokeWidth:2},isAnimationActive:!1}),Ke(Ze,{type:"monotone",dataKey:"errors",stroke:"var(--down)",strokeWidth:2,dot:!1,activeDot:{r:4,stroke:"var(--panel)",strokeWidth:2},isAnimationActive:!1})]})})}),nt(yt,{children:[nt("span",{children:[Ke(et,{$color:"var(--accent)"})," Requests"]}),nt("span",{children:[Ke(et,{$color:"var(--down)"})," Failed"]})]})]})}import{jsx as se,jsxs as $t}from"react/jsx-runtime";var jr=86400000,La=[{id:"requestedModel",label:"As requested",column:"Virtual model"},{id:"model",label:"As served",column:"Upstream model"}],Ba=Fr(R).withConfig({displayName:"UsageBoard__Picker"})(["width:auto;"]);function Da(){let{cadence:i}=X(),[n,p]=It("24h"),[m,b]=It("tokens"),[h,D]=It("model"),[x,O]=It(void 0),[P,C]=It(void 0),I=pe(),W=we(),j=Lr(n),v=fo(m),S=No().data??null,Y=bt(()=>j.grain==="daily"?Ee(Date.now()-j.ms,S):Math.floor((Date.now()-j.ms)/60000)*60000,[j,S]),A=bt(()=>Y+j.ms,[Y,j]),Z=bt(()=>Ee(Date.now()-Yn*jr,S),[S]),re=I.data?.find((J)=>J.id===x),le=W.data?.find((J)=>J.id===P);if(x!==void 0&&I.data!==void 0&&re===void 0)O(void 0);if(P!==void 0&&W.data!==void 0&&le===void 0)C(void 0);let ne={...re===void 0?{}:{credentialId:re.id},...le===void 0?{}:{apiKeyId:le.id}},ae=`${le===void 0?"":` for ${le.label}`}${re===void 0?"":` on ${re.label}`}`,ge={since:Y,grain:j.grain,...ne},he=Ue({...ge,groupBy:j.by},i(60000,"res:usage")),Ce=Ue({...ge,groupBy:j.by,splitBy:"provider"},i(60000,"res:usage")),ke=Ue({...ge,groupBy:j.by,splitBy:"model"},i(60000,"res:usage")),qe=Ue({...ge,groupBy:j.by,splitBy:"apiKey"},i(60000,"res:usage")),tt=Ue({...ge,groupBy:h},i(60000,"res:usage")),at=Ue({...ge,groupBy:"credential"},i(60000,"res:usage")),pt=Ue({since:Z,grain:"daily",groupBy:"day",...ne},i(300000,"res:usage")),mt=H(),Nt=bt(()=>{let J=new Map;for(let ct of mt.data??[])for(let ra of ct.targets)J.set(ra.model,ra.provider);return J},[mt.data]),xt=bt(()=>{let J=new Map;for(let ct of W.data??[])J.set(ct.id,ct.label);return J},[W.data]),Ft=bt(()=>{let J=new Map;for(let ct of I.data??[])J.set(ct.id,ct.label);return J},[I.data]),ft=he.data??[],Xt=Rr(ft),Wa=je(Xt),dt={legend:"Nothing recorded",message:"No requests landed in this window. Widen the range, or send traffic through the gateway."};return $t(r,{$gap:4,children:[se(k,{legend:"Usage",title:"Requests, tokens, and spend",summary:he.isLoading?"Reading usage…":`${a(Xt.requests)} requests and ${w(Xt.costUsd)} over the last ${j.label}${ae}.`,actions:$t(o,{$wrap:!0,children:[se(Ba,{"aria-label":"Account",value:re?.id??"",options:[{value:"",label:"All accounts"},...(I.data??[]).map((J)=>({value:J.id,label:J.label}))],onValueChange:(J)=>O(J||void 0)}),se(Ba,{"aria-label":"Gateway key",value:le?.id??"",options:[{value:"",label:"All keys"},...(W.data??[]).map((J)=>({value:J.id,label:J.label}))],onValueChange:(J)=>C(J||void 0)}),se(Xe,{children:Ot.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===n,"aria-pressed":J.id===n,onClick:()=>p(J.id),children:J.id},J.id))})]})}),se(yr,{buckets:ft,since:Y,until:A,by:j.by,rangeLabel:j.label,dayOffsetMinutes:S}),se(Se,{legend:"Traffic",meta:j.by==="hour"?"By hour":"By day",query:he,isEmpty:ft.length===0,empty:dt,children:se(Oa,{buckets:ft,by:j.by,since:Y,until:A,dayOffsetMinutes:S})}),se(Xe,{children:Kt.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===m,"aria-pressed":J.id===m,onClick:()=>b(J.id),children:`Rank by ${J.label.toLowerCase()}`},J.id))}),se(Se,{legend:"Traffic by upstream model",meta:`${v.label}, ${j.by==="hour"?"by hour":"by day"}`,query:ke,isEmpty:(ke.data??[]).length===0,empty:dt,children:se($a,{buckets:ke.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v,providers:Nt})}),$t(Ie,{$min:"480px",$gap:4,children:[$t(r,{$gap:4,children:[se(Se,{legend:"Providers",meta:v.label,query:Ce,isEmpty:(Ce.data??[]).length===0,empty:dt,children:se(Ma,{buckets:Ce.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v})}),se(oa,{days:pt.data??[],now:Date.now(),dayOffsetMinutes:S})]}),$t(r,{$gap:4,children:[se(Se,{legend:"Token mix",meta:a(Wa),query:he,isEmpty:ft.length===0,empty:dt,children:se(Na,{buckets:ft,by:j.by,since:Y,until:A,dayOffsetMinutes:S})}),se(Se,{legend:"Models",meta:La.find((J)=>J.id===h)?.column,query:tt,isEmpty:(tt.data??[]).length===0,empty:dt,actions:se(Xe,{children:La.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===h,"aria-pressed":J.id===h,onClick:()=>D(J.id),children:J.label},J.id))}),children:se(ta,{buckets:tt.data??[],metric:v})}),se(Se,{legend:"Accounts",meta:v.label,query:at,isEmpty:(at.data??[]).length===0,empty:dt,children:se(ta,{buckets:at.data??[],metric:v,names:Ft,unknownLabel:"No account"})})]})]}),se(Se,{legend:"API keys",meta:v.label,query:qe,isEmpty:(qe.data??[]).length===0,empty:dt,children:se(sa,{buckets:qe.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v,names:xt})})]})}var Vo=Da;export{Vo as component};
1
+ import{t,d,o,r,Ie,Q,M,fe,z,pe,H,we,No,Ue,a,w,V,N,X,oe,K,k,f}from"/assets/index-qkhn11a8.js";import{R}from"/assets/index-330vgx7r.js";import{Se,st,Xe,yr}from"/assets/index-dny52xdk.js";import"/assets/index-h41dkv54.js";import{g,ye,u,me,F,ue,Re,c,e,y,B,ve,Gn,Ut,lt,qt,_,De,L,Ne,jt,ie,ht,G,U,Xn,Qn,T,zt,Cr,Lo,Wt,Ht,Qr,ce,Tt,Be,te,Pe,Yr,Zr,Vt,Jr,Ro,gt,Sr,eo,to,ro,Ir,oo,no,Et,kr,ao,io,so,lo,uo,co,Ye,Ze,Ae,Te,Mt,Ot,Lr,Yn,je,Kt,fo,Fe,Ee,Po,Zn,Me,ze,po,We,Je,Rr,mo,Oe,Jn,He,Ve,et,yt}from"/assets/index-96zs0ekh.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import"/assets/index-ywek2f98.js";import{useMemo as bt,useState as It}from"react";import Fr from"styled-components";import{useMemo as Ka,useState as ia}from"react";import Qe from"styled-components";import{jsx as xe,jsxs as At}from"react/jsx-runtime";var Pt=53,_e=9,ot=2,Ua=Qe.div.withConfig({displayName:"ActivityGrid__Frame"})(["display:flex;gap:","px;"],ot),qa=Qe.div.withConfig({displayName:"ActivityGrid__Weekdays"})(["display:grid;grid-template-rows:repeat(7,","px);gap:","px;padding-top:","px;font-size:9px;color:",";"],_e,ot,_e+ot,({theme:i})=>i.color.inkFaint),za=Qe.div.withConfig({displayName:"ActivityGrid__Weekday"})(["line-height:","px;padding-right:2px;text-align:right;"],_e),Ga=Qe.div.withConfig({displayName:"ActivityGrid__Months"})(["display:grid;grid-template-columns:repeat(",",","px);gap:","px;height:","px;font-size:9px;color:",";"],Pt,_e,ot,_e,({theme:i})=>i.color.inkFaint),_a=Qe.div.withConfig({displayName:"ActivityGrid__Month"})(["white-space:nowrap;line-height:","px;"],_e),Fa=Qe.div.withConfig({displayName:"ActivityGrid__Weeks"})(["display:grid;grid-template-columns:repeat(",",","px);gap:","px;"],Pt,_e,ot),ja=Qe.div.withConfig({displayName:"ActivityGrid__Week"})(["display:grid;grid-template-rows:repeat(7,","px);gap:","px;"],_e,ot),na=Qe.div.withConfig({displayName:"ActivityGrid__Cell"})(["width:","px;height:","px;border-radius:2px;background:",";border:1px solid var(--rule);visibility:",";&:hover,&:focus-visible{outline:1px solid var(--ink-dim);outline-offset:1px;}"],_e,_e,({$level:i})=>i===0?"var(--panel-sunk)":`color-mix(in oklch, var(--accent) ${[0,24,46,70,100][i]??100}%, var(--panel-sunk))`,({$future:i})=>i?"hidden":"visible"),Xa=Qe(o).withConfig({displayName:"ActivityGrid__Scale"})(["gap:","px;"],ot),Va=Qe(d).withConfig({displayName:"ActivityGrid__Readout"})(["color:",";font-size:11px;"],({theme:i})=>i.color.inkDim);function Ya(i){let n=i.filter((m)=>m>0).sort((m,b)=>m-b);if(n.length===0)return[0,0,0];let p=(m)=>n[Math.min(n.length-1,Math.floor(n.length*m))]??0;return[p(0.25),p(0.5),p(0.75)]}function Ha(i,[n,p,m]){if(i<=0)return 0;if(i<=n)return 1;if(i<=p)return 2;if(i<=m)return 3;return 4}function oa({days:i,now:n,dayOffsetMinutes:p=null}){let[m,b]=ia("tokens"),[h,D]=ia(null),x=fo(m),O=Ka(()=>{let v=new Map;for(let A of i){let Z=Number(A.key);if(!Number.isFinite(Z))continue;v.set(Ee(Z,p),{requests:A.requests,errors:A.errors,costUsd:A.costUsd,inputTokens:A.inputTokens,outputTokens:A.outputTokens,cacheReadTokens:A.cacheReadTokens,cacheWriteTokens:A.cacheWriteTokens,rtkSavedTokens:A.rtkSavedTokens,rtkAppliedRequests:A.rtkAppliedRequests,durationMsSum:A.durationMsSum})}let S=Ee(n,p),Y=Po(S,6-Zn(S,p)-(Pt*7-1),p);return Array.from({length:Pt},()=>Array.from({length:7},()=>{let A=Y;return Y=Po(Y,1,p),{at:A,totals:v.get(A)??We,future:A>S}}))},[i,n,p]),P=O.flat(),C=Ya(P.map((v)=>x.of({key:"",...v.totals}))),I=P.reduce((v,S)=>Je(v,Oe(S.totals)),We),W=P.reduce((v,S)=>v+(S.totals.requests>0?1:0),0),j=(v,S)=>`${v}: ${a(S.requests)} requests, ${a(je(S))} tokens, ${w(S.costUsd)}`;return xe(f,{legend:"Activity",meta:h===null?`${a(W)} active days`:void 0,actions:xe(Xe,{children:Kt.map((v)=>xe(st,{type:"button",$size:"sm",$on:v.id===m,"aria-pressed":v.id===m,onClick:()=>b(v.id),children:v.label},v.id))}),children:At(r,{$gap:2,children:[xe(Q,{children:xe(r,{$gap:1,style:{width:Pt*(_e+ot)+28},children:At(Ua,{children:[xe(qa,{"aria-hidden":"true",children:["","Mon","","Wed","","Fri",""].map((v,S)=>xe(za,{children:v},S))}),At(r,{$gap:1,children:[xe(Ga,{"aria-hidden":"true",children:O.map((v,S)=>{let Y=v[0],A=O[S-1]?.[0],Z=Y!==void 0&&(A===void 0||new Date(A.at).getMonth()!==new Date(Y.at).getMonth());return xe(_a,{children:Z&&Y!==void 0?new Date(Y.at).toLocaleDateString("en-GB",{month:"short"}):""},Y?.at??S)})}),xe(Fa,{role:"grid","aria-label":`${x.label} per day over the last year`,children:O.map((v)=>xe(ja,{role:"row",children:v.map((S)=>xe(na,{role:"gridcell",tabIndex:-1,"aria-label":j(po(S.at),S.totals),title:j(po(S.at),S.totals),$future:S.future,$level:S.future?0:Ha(x.of({key:"",...S.totals}),C),onMouseEnter:()=>D(S),onMouseLeave:()=>D(null)},S.at))},v[0]?.at))})]})]})})}),At(o,{$justify:"space-between",$wrap:!0,children:[xe(Va,{children:h===null?j("Last 12 months",I):j(po(h.at),h.totals)}),At(o,{$gap:1,children:[xe(t,{children:"Less"}),xe(Xa,{"aria-hidden":"true",children:[0,1,2,3,4].map((v)=>xe(na,{$level:v,$future:!1},v))}),xe(t,{children:"More"})]})]})]})})}import{jsx as be,jsxs as Yt}from"react/jsx-runtime";function sa({buckets:i,by:n,since:p,until:m,metric:b,names:h,dayOffsetMinutes:D}){let x=Me(p,m,n,D),O=new Map,P=new Map;for(let I of i){let W=I.split??"unknown";O.set(W,Je(O.get(W)??We,I));let j=P.get(W)??new Map,v=Fe(I.key,n);j.set(v,(j.get(v)??0)+b.of(I)),P.set(W,j)}let C=[...O.entries()].sort((I,W)=>b.of(Oe(W[1]))-b.of(Oe(I[1])));return be(Q,{children:Yt(q,{children:[be("thead",{children:Yt("tr",{children:[be(l,{children:"Key"}),be(l,{children:"Trend"}),be(l,{$align:"right",children:"Requests"}),be(l,{$align:"right",children:"Failed"}),be(l,{$align:"right",children:"Tokens"}),be(l,{$align:"right",children:"Mean"}),be(l,{$align:"right",children:"Cost"})]})}),be("tbody",{children:C.map(([I,W])=>{let j=P.get(I)??new Map,v=I==="unknown"?"Unattributed":h.get(I)??I;return Yt(E,{children:[be(s,{children:be(M,{style:{display:"block",maxWidth:"28ch"},children:v})}),be(s,{style:{width:120},children:be(K,{values:x.map((S)=>j.get(S)??0),height:20,label:`${v}: ${b.format(b.of(Oe(W)))} over the window`})}),be(s,{$align:"right",$mono:!0,children:a(W.requests)}),be(s,{$align:"right",$mono:!0,style:W.errors>0?{color:"var(--down)"}:void 0,children:N(W.requests===0?0:W.errors/W.requests,0)}),be(s,{$align:"right",$mono:!0,children:a(je(W))}),be(s,{$align:"right",$mono:!0,children:V(W.requests===0?null:W.durationMsSum/W.requests)}),be(s,{$align:"right",$mono:!0,children:w(W.costUsd)})]},I)})})]})})}import*as ee from"react";import{PureComponent as fr,useMemo as hr,useRef as ka}from"react";function Lt(i,n){var p,m;return(p=(m=i.graphicalItems.cartesianItems.find((b)=>b.id===n))===null||m===void 0?void 0:m.xAxisId)!==null&&p!==void 0?p:Ro}function Bt(i,n){var p,m;return(p=(m=i.graphicalItems.cartesianItems.find((b)=>b.id===n))===null||m===void 0?void 0:m.yAxisId)!==null&&p!==void 0?p:Ro}var la=(i,n,p)=>Ht(i,"xAxis",Lt(i,n),p),da=(i,n,p)=>Wt(i,"xAxis",Lt(i,n),p),ca=(i,n,p)=>Ht(i,"yAxis",Bt(i,n),p),ua=(i,n,p)=>Wt(i,"yAxis",Bt(i,n),p),Za=e([L,la,ca,da,ua],(i,n,p,m,b)=>{if(ve(i,"xAxis"))return lt(n,m,!1);return lt(p,b,!1)}),Ja=(i,n)=>n,Zt=e([Cr,Ja],(i,n)=>i.filter((p)=>p.type==="area").find((p)=>p.id===n)),pa=(i)=>{var n=L(i),p=ve(n,"xAxis");return p?"yAxis":"xAxis"},Qa=(i,n)=>{var p=pa(i);if(p==="yAxis")return Bt(i,n);return Lt(i,n)},ma=(i,n,p)=>Lo(i,pa(i),Qa(i,n),p),er=e([Zt,ma],(i,n)=>{var p;if(i==null||n==null)return;var m=i.stackId,b=zt(i);if(m==null||b==null)return;var h=(p=n[m])===null||p===void 0?void 0:p.stackedData,D=h===null||h===void 0?void 0:h.find((x)=>x.key===b);if(D==null)return;return D.map((x)=>[x[0],x[1]])}),tr=e([Zt,ma],(i,n)=>{if(i==null||i.stackId==null||n==null)return;var p=n[i.stackId];if(p==null)return;return p.graphicalItems.map((m)=>m.dataKey).filter(ue)}),fa=e([L,la,ca,da,ua,er,Xn,Za,Zt,Qn,tr],(i,n,p,m,b,h,D,x,O,P,C)=>{var{chartData:I,dataStartIndex:W,dataEndIndex:j}=D;if(O==null||i!=="horizontal"&&i!=="vertical"||n==null||p==null||m==null||b==null||m.length===0||b.length===0||x==null)return;var v=O.data,S;if(v&&v.length>0)S=v;else S=I===null||I===void 0?void 0:I.slice(W,j+1);if(S==null)return;return ha({layout:i,xAxis:n,yAxis:p,xAxisTicks:m,yAxisTicks:b,dataStartIndex:W,areaSettings:O,stackedData:h,displayedData:S,chartBaseValue:P,bandSize:x,stackDataKeys:C})});import*as $e from"react";var ar=["animationElapsedTime","isAnimating","isEntrance","layout","isRange","stroke","connectNulls"],rr=["id","baseLine"];function Ct(){return Ct=Object.assign?Object.assign.bind():function(i){for(var n=1;n<arguments.length;n++){var p=arguments[n];for(var m in p)({}).hasOwnProperty.call(p,m)&&(i[m]=p[m])}return i},Ct.apply(null,arguments)}function va(i,n){if(i==null)return{};var p,m,b=ir(i,n);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(i);for(m=0;m<h.length;m++)p=h[m],n.indexOf(p)===-1&&{}.propertyIsEnumerable.call(i,p)&&(b[p]=i[p])}return b}function ir(i,n){if(i==null)return{};var p={};for(var m in i)if({}.hasOwnProperty.call(i,m)){if(n.indexOf(m)!==-1)continue;p[m]=i[m]}return p}function nr(i){var n,p,{alpha:m,baseLine:b,points:h,strokeWidth:D}=i,x=(n=h[0])===null||n===void 0?void 0:n.x,O=(p=h[h.length-1])===null||p===void 0?void 0:p.x;if(!y(x)||!y(O))return null;var P=m*Math.abs(x-O),C=Math.max(...h.map((I)=>I.y||0));if(u(b))C=Math.max(b,C);else if(b&&Array.isArray(b)&&b.length)C=Math.max(...b.map((I)=>I.y||0),C);if(u(C))return $e.createElement("rect",{x:x<O?x:x-P,y:0,width:P,height:Math.floor(C+(D?parseInt("".concat(D),10):1))});return null}function or(i){var n,p,{alpha:m,baseLine:b,points:h,strokeWidth:D}=i,x=(n=h[0])===null||n===void 0?void 0:n.y,O=(p=h[h.length-1])===null||p===void 0?void 0:p.y;if(!y(x)||!y(O))return null;var P=m*Math.abs(x-O),C=Math.max(...h.map((I)=>I.x||0));if(u(b))C=Math.max(b,C);else if(b&&Array.isArray(b)&&b.length)C=Math.max(...b.map((I)=>I.x||0),C);if(u(C))return $e.createElement("rect",{x:0,y:x<O?x:x-P,width:C+(D?parseInt("".concat(D),10):1),height:Math.floor(P)});return null}function sr(i){var{alpha:n,layout:p,points:m,baseLine:b,strokeWidth:h}=i;if(p==="vertical")return $e.createElement(or,{alpha:n,points:m,baseLine:b,strokeWidth:h});return $e.createElement(nr,{alpha:n,points:m,baseLine:b,strokeWidth:h})}function ya(i){var n=i.animationElapsedTime,p=n===void 0?1:n,m=i.isAnimating,b=m===void 0?!1:m,h=i.isEntrance,D=h===void 0?!1:h,{layout:x,isRange:O,stroke:P,connectNulls:C}=i,I=va(i,ar),W=x==="vertical"?"vertical":"horizontal",j=C!==null&&C!==void 0?C:!1,v=to(),{id:S,baseLine:Y}=I,A=va(I,rr),Z=ie(A),re=$e.createElement(ht,Ct({},I,{id:S,baseLine:Y,connectNulls:j,stroke:"none",className:"recharts-area-area",layout:W})),le=P!=="none"&&$e.createElement(ht,Ct({},Z,{className:"recharts-area-curve",layout:W,type:I.type,connectNulls:j,fill:"none",stroke:P,points:I.points})),ne=P!=="none"&&O&&Array.isArray(Y)&&$e.createElement(ht,Ct({},Z,{className:"recharts-area-curve",layout:W,type:I.type,connectNulls:j,fill:"none",stroke:P,points:Y}));if(D&&(b||p<1)){var ae;return $e.createElement(te,null,$e.createElement("defs",null,$e.createElement("clipPath",{id:v},$e.createElement(sr,{alpha:p,points:(ae=I.points)!==null&&ae!==void 0?ae:[],baseLine:Y,layout:W,strokeWidth:I.strokeWidth}))),$e.createElement(te,{clipPath:"url(#".concat(v,")")},re,le,ne))}return $e.createElement($e.Fragment,null,re,le,ne)}var lr=["id"],dr=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Dt(){return Dt=Object.assign?Object.assign.bind():function(i){for(var n=1;n<arguments.length;n++){var p=arguments[n];for(var m in p)({}).hasOwnProperty.call(p,m)&&(i[m]=p[m])}return i},Dt.apply(null,arguments)}function ba(i,n){if(i==null)return{};var p,m,b=cr(i,n);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(i);for(m=0;m<h.length;m++)p=h[m],n.indexOf(p)===-1&&{}.propertyIsEnumerable.call(i,p)&&(b[p]=i[p])}return b}function cr(i,n){if(i==null)return{};var p={};for(var m in i)if({}.hasOwnProperty.call(i,m)){if(n.indexOf(m)!==-1)continue;p[m]=i[m]}return p}function ga(i,n){var p=Object.keys(i);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(i);n&&(m=m.filter(function(b){return Object.getOwnPropertyDescriptor(i,b).enumerable})),p.push.apply(p,m)}return p}function vt(i){for(var n=1;n<arguments.length;n++){var p=arguments[n]!=null?arguments[n]:{};n%2?ga(Object(p),!0).forEach(function(m){ur(i,m,p[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(p)):ga(Object(p)).forEach(function(m){Object.defineProperty(i,m,Object.getOwnPropertyDescriptor(p,m))})}return i}function ur(i,n,p){return(n=pr(n))in i?Object.defineProperty(i,n,{value:p,enumerable:!0,configurable:!0,writable:!0}):i[n]=p,i}function pr(i){var n=mr(i,"string");return typeof n=="symbol"?n:n+""}function mr(i,n){if(typeof i!="object"||!i)return i;var p=i[Symbol.toPrimitive];if(p!==void 0){var m=p.call(i,n||"default");if(typeof m!="object")return m;throw TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(i)}var vr=(i,n)=>{if(i==null)return[];if(n===1)return i.flatMap((p)=>p.status==="removed"?[]:[p.next]);return i.flatMap((p)=>{if(p.status==="matched")return[vt(vt({},p.next),{},{x:me(p.prev.x,p.next.x,n),y:me(p.prev.y,p.next.y,n)})];if(p.status==="added")return[p.next];return[]})},xa={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",animationMatchBy:Et,animationInterpolateFn:vr,connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:0.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,shape:ya,xAxisId:0,yAxisId:0,zIndex:T.area};function Gt(i,n){return i&&i!=="none"?i:n}var gr=(i)=>{var{dataKey:n,name:p,stroke:m,fill:b,legendType:h,hide:D}=i;return[{inactive:D,dataKey:n,type:h,color:Gt(m,b),value:qt(p,n),payload:i}]},br=ee.memo((i)=>{var{dataKey:n,data:p,stroke:m,strokeWidth:b,fill:h,name:D,hide:x,unit:O,formatter:P,tooltipType:C,id:I}=i,W={dataDefinedOnItem:p,getPosition:Re,settings:{stroke:m,strokeWidth:b,fill:h,dataKey:n,nameKey:void 0,name:qt(D,n),hide:x,type:C,color:Gt(m,h),unit:O,formatter:P,graphicalItemId:I}};return ee.createElement(eo,{tooltipEntrySettings:W})});function xr(i){var{clipPathId:n,points:p,props:m}=i,{needClip:b,dot:h,dataKey:D}=m,x=ie(m);return ee.createElement(Jr,{points:p,dot:h,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:D,baseProps:x,needClip:b,clipPathId:n})}function Ar(i){var{showLabels:n,children:p,points:m}=i,b=m.map((h)=>{var D,x,O={x:(D=h.x)!==null&&D!==void 0?D:0,y:(x=h.y)!==null&&x!==void 0?x:0,width:0,lowerWidth:0,upperWidth:0,height:0};return vt(vt({},O),{},{value:h.value,payload:h.payload,parentViewBox:void 0,viewBox:O,fill:void 0})});return ee.createElement(Yr,{value:n?b:void 0},p)}function Tr(i){var{points:n,baseLine:p,needClip:m,clipPathId:b,props:h,animationElapsedTime:D,isAnimating:x,isEntrance:O}=i,{layout:P,type:C,stroke:I,connectNulls:W,isRange:j,shape:v,id:S}=h,Y=ba(h,lr),A=G(Y),Z=vt(vt({},A),{},{id:S,points:n,connectNulls:W,type:C,baseLine:p,layout:P,stroke:I,isRange:j,animationElapsedTime:D,isAnimating:x,isEntrance:O});return ee.createElement(ee.Fragment,null,(n===null||n===void 0?void 0:n.length)>1&&ee.createElement(te,{clipPath:m?"url(#clipPath-".concat(b,")"):void 0},ee.createElement(co,{option:v,DefaultShape:xa.shape,shapeProps:Z})),ee.createElement(xr,{points:n,props:Y,clipPathId:b}))}function Pr(i,n,p){if(u(i)){var m=u(n)?n:void 0;return me(m,i,p)}if(F(i)||ye(i)){var b=u(n)?n:void 0;return me(b,0,p)}return i}function wr(i){var{needClip:n,clipPathId:p,props:m,previousPointsRef:b,previousBaselineRef:h}=i,{points:D,baseLine:x,isAnimationActive:O,animationBegin:P,animationDuration:C,animationEasing:I,animationMatchBy:W,animationInterpolateFn:j}=m,v=hr(()=>({points:D,baseLine:x}),[D,x]),S=ao(v,h),Y=jt(),A=io(m.onAnimationStart,m.onAnimationEnd),{isAnimating:Z,handleAnimationStart:re,handleAnimationEnd:le}=A,ne=S.startValue;if(Y==null)return null;var ae;if(Array.isArray(x)&&Array.isArray(ne))ae=kr(ne,x,W);else if(Array.isArray(x))ae=kr(null,x,W);else ae=null;return ee.createElement(so,{animationInput:v,animationIdPrefix:"recharts-area-",items:D,previousItemsRef:b,isAnimationActive:O,animationBegin:P,animationDuration:C,animationEasing:I,onAnimationStart:re,onAnimationEnd:le,animationInterpolateFn:j,animationMatchBy:W,layout:Y},(ge,he,Ce)=>{var ke;if(he===1)ke=x;else if(Array.isArray(x))ke=j(ae,he,Y);else ke=Ce?x:Pr(x,ne,he);return S.syncStepValue(ke,he),ee.createElement(Ar,{showLabels:!Z,points:D},m.children,ee.createElement(Tr,{points:ge,baseLine:ke,needClip:n,clipPathId:p,props:m,animationElapsedTime:he,isAnimating:Z||he<1,isEntrance:Ce}),ee.createElement(Zr,{label:m.label}))})}function $r(i){var{needClip:n,clipPathId:p,props:m}=i,b=ka(null),h=ka();return ee.createElement(wr,{needClip:n,clipPathId:p,props:m,previousPointsRef:b,previousBaselineRef:h})}class Aa extends fr{render(){var i=this.props,{hide:n,dot:p,points:m,className:b,top:h,left:D,needClip:x,xAxisId:O,yAxisId:P,width:C,height:I,id:W,baseLine:j,zIndex:v}=i;if(n)return null;var S=g("recharts-area",b),Y=W,A=uo(p),{r:Z,strokeWidth:re}=A,le=Vt(p),ne=Z*2+re,ae=x?"url(#clipPath-".concat(le?"":"dots-").concat(Y,")"):void 0;return ee.createElement(ce,{zIndex:v},ee.createElement(te,{className:S},x&&ee.createElement("defs",null,ee.createElement(oo,{clipPathId:Y,xAxisId:O,yAxisId:P}),!le&&ee.createElement("clipPath",{id:"clipPath-dots-".concat(Y)},ee.createElement("rect",{x:D-ne/2,y:h-ne/2,width:C+ne,height:I+ne}))),ee.createElement($r,{needClip:x,clipPathId:Y,props:this.props})),ee.createElement(Sr,{points:m,mainColor:Gt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:ae}),this.props.isRange&&Array.isArray(j)&&ee.createElement(Sr,{points:j,mainColor:Gt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:ae}))}}function Mr(i){var n,{activeDot:p,animationBegin:m,animationDuration:b,animationEasing:h,connectNulls:D,dot:x,fill:O,fillOpacity:P,hide:C,isAnimationActive:I,legendType:W,stroke:j,xAxisId:v,yAxisId:S}=i,Y=ba(i,dr),A=Ne(),Z=Qr(),re=Ir(v,S),le=re.needClip,ne=_(),ae=(n=c((mt)=>fa(mt,i.id,ne)))!==null&&n!==void 0?n:{},{points:ge,isRange:he,baseLine:Ce}=ae,ke=gt();if(A!=="horizontal"&&A!=="vertical"||ke==null)return null;if(Z!=="AreaChart"&&Z!=="ComposedChart")return null;var{height:qe,width:tt,x:at,y:pt}=ke;if(!ge||!ge.length)return null;return ee.createElement(Aa,Dt({},Y,{activeDot:p,animationBegin:m,animationDuration:b,animationEasing:h,baseLine:Ce,connectNulls:D,dot:x,fill:O,fillOpacity:P,height:qe,hide:C,layout:A,isAnimationActive:I,isRange:he,legendType:W,needClip:le,points:ge,stroke:j,width:tt,left:at,top:pt,xAxisId:v,yAxisId:S}))}var Er=(i,n,p,m,b)=>{var h=p!==null&&p!==void 0?p:n;if(u(h))return h;var D=i==="horizontal"?b:m,x=D.scale.domain();if(D.type==="number"){var O=Math.max(x[0],x[1]),P=Math.min(x[0],x[1]);if(h==="dataMin")return P;if(h==="dataMax")return O;return O<0?O:Math.max(Math.min(x[0],x[1]),0)}if(h==="dataMin")return x[0];if(h==="dataMax")return x[1];return x[0]};function ha(i){var n=i.areaSettings,{connectNulls:p,baseValue:m,dataKey:b}=n,{stackedData:h,layout:D,chartBaseValue:x,xAxis:O,yAxis:P,displayedData:C,dataStartIndex:I,xAxisTicks:W,yAxisTicks:j,bandSize:v,stackDataKeys:S}=i,Y=h&&h.length,A=Er(D,x,m,O,P),Z=D==="horizontal",re=!1,le=C.map((ae,ge)=>{var he,Ce,ke,qe;if(Y)qe=h[I+ge];else{var tt=B(ae,b);if(!Array.isArray(tt))qe=[A,tt];else qe=tt,re=!0}var at=(he=(Ce=qe)===null||Ce===void 0?void 0:Ce[1])!==null&&he!==void 0?he:null,pt=B(ae,b),mt=Y&&pt==null&&S!=null&&S.length>0&&S.every((Ft)=>B(ae,Ft)==null),Nt=at==null||Y&&!p&&pt==null||mt;if(Z){var xt;return{x:Ut({axis:O,ticks:W,bandSize:v,entry:ae,index:ge}),y:Nt?null:(xt=P.scale.map(at))!==null&&xt!==void 0?xt:null,value:qe,payload:ae}}return{x:Nt?null:(ke=O.scale.map(at))!==null&&ke!==void 0?ke:null,y:Ut({axis:P,ticks:j,bandSize:v,entry:ae,index:ge}),value:qe,payload:ae}}),ne;if(Y||re)ne=le.map((ae)=>{var ge,he=Array.isArray(ae.value)?ae.value[0]:null;if(Z){var Ce;return{x:ae.x,y:he!=null&&ae.y!=null?(Ce=P.scale.map(he))!==null&&Ce!==void 0?Ce:null:null,payload:ae.payload}}return{x:he!=null?(ge=O.scale.map(he))!==null&&ge!==void 0?ge:null:null,y:ae.y,payload:ae.payload}});else ne=Z?P.scale.map(A):O.scale.map(A);return{points:le,baseLine:ne!==null&&ne!==void 0?ne:0,isRange:re}}function Nr(i){var n=U(i,xa),p=_();return ee.createElement(ro,{id:n.id,type:"area"},(m)=>ee.createElement(ee.Fragment,null,ee.createElement(no,{legendPayload:gr(n)}),ee.createElement(br,{dataKey:n.dataKey,data:n.data,stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,name:n.name,hide:n.hide,unit:n.unit,formatter:n.formatter,tooltipType:n.tooltipType,id:m}),ee.createElement(lo,{type:"area",id:m,data:n.data,dataKey:n.dataKey,xAxisId:n.xAxisId,yAxisId:n.yAxisId,zAxisId:0,stackId:Gn(n.stackId),hide:n.hide,barSize:void 0,baseValue:n.baseValue,isPanorama:p,connectNulls:n.connectNulls}),ee.createElement(Mr,Dt({},n,{id:m}))))}var rt=ee.memo(Nr,Ye);rt.displayName="Area";import*as Ta from"react";import{forwardRef as Or}from"react";var Br=["axis"],kt=Or((i,n)=>Ta.createElement(Mt,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Br,tooltipPayloadSearcher:Tt,categoricalChartProps:i,ref:n}));import*as Pa from"react";import{forwardRef as Dr}from"react";var Wr=["axis"],Ca=Dr((i,n)=>Pa.createElement(Mt,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Wr,tooltipPayloadSearcher:Tt,categoricalChartProps:i,ref:n}));import{jsx as Ge,jsxs as St}from"react/jsx-runtime";var Sa=6,Ra="__other__",wa="unknown";function Ia(i,n,p){let m=p.get(n);if(m!==void 0)return m;return i.find((b)=>b.models.some((h)=>h.id===n))?.id??null}function Kr(i,n){if(i===null)return"var(--ink-faint)";return`color-mix(in oklch, ${oe(i)} ${Math.max(30,100-n*22)}%, var(--panel))`}function $a({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b,metric:h,providers:D}){let x=fe().data??[],O=[...mo(i,h).entries()],P=O.slice(0,Sa),C=O.slice(Sa),I=[...new Set(P.map(([A])=>Ia(x,A,D)))].filter((A)=>A!==null&&z(x,A)===void 0).sort(),W=[];for(let A of[...x.map((Z)=>Z.id),...I,null])P.filter(([Z])=>Ia(x,Z,D)===A).forEach(([Z,re],le)=>{W.push({name:Z,label:Z===wa?"Unresolved":Z,color:Kr(A,le),totals:re})});if(C.length>0)W.push({name:Ra,label:`${C.length} more`,color:"var(--ink-faint)",totals:C.reduce((A,[,Z])=>Je(A,Oe(Z)),We)});let j=new Set(P.map(([A])=>A)),v=new Map;for(let A of i){let Z=A.split??wa,re=`${Fe(A.key,n)} ${j.has(Z)?Z:Ra}`;v.set(re,(v.get(re)??0)+h.of(A))}let S=Me(p,m,n,b).map((A)=>{let Z={at:A};for(let re of W)Z[re.name]=v.get(`${A} ${re.name}`)??0;return Z}),Y=new Map(W.map((A)=>[A.name,A.label]));return St(r,{$gap:2,children:[Ge(He,{$height:220,children:Ge(De,{width:"100%",height:"100%",children:St(kt,{data:S,margin:{top:4,right:4,bottom:4,left:4},children:[Ge(Pe,{stroke:"var(--rule)",vertical:!1}),Ge(Ae,{dataKey:"at",tickFormatter:(A)=>ze(A,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Ge(Te,{tickFormatter:(A)=>h.format(A),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:40}),Ge(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:A,payload:Z,label:re})=>{if(A!==!0||Z===void 0||Z.length===0)return null;let le=Z.filter((ne)=>Number(ne.value??0)>0);return St(Ve,{children:[Ge("div",{children:ze(Number(re),n)}),le.length===0?Ge("div",{children:`No ${h.label.toLowerCase()}`}):le.map((ne)=>St("div",{children:[Y.get(String(ne.dataKey))??String(ne.dataKey)," ",h.format(Number(ne.value??0))]},String(ne.dataKey)))]})}}),W.map((A)=>Ge(rt,{type:"monotone",dataKey:A.name,stackId:"models",stroke:A.color,strokeWidth:2,fill:A.color,fillOpacity:0.22,isAnimationActive:!1},A.name))]})})}),Ge(yt,{children:W.map((A)=>St("span",{children:[Ge(et,{$color:A.color})," ",Ge(M,{title:`${A.label}: ${h.format(h.of(Oe(A.totals)))} ${h.label.toLowerCase()}`,style:{display:"inline-block",maxWidth:"24ch",verticalAlign:"bottom"},children:A.label})]},A.name))})]})}import{jsx as de,jsxs as it}from"react/jsx-runtime";var Qt="unknown";function _t(i,n){return z(i,n)===void 0?"var(--ink-faint)":oe(n)}function Jt(i,n){if(n===Qt)return"Unresolved";return z(i,n)?.label??n}function Ma({buckets:i,by:n,since:p,until:m,metric:b,dayOffsetMinutes:h}){let D=fe().data??[],x=mo(i,b),O=[...x.keys()].filter((v)=>v!==Qt&&z(D,v)===void 0).sort(),P=[...D.map((v)=>v.id),...O,Qt].map((v)=>({name:v,totals:x.get(v)})).filter((v)=>v.totals!==void 0),C=P.map((v)=>v.name),I=Me(p,m,n,h),W=Jn(i,I,n,b),j=[...x.values()].reduce((v,S)=>v+S.requests,0);return it(r,{$gap:3,children:[de(He,{$height:200,children:de(De,{width:"100%",height:"100%",children:it(kt,{data:W,margin:{top:4,right:4,bottom:4,left:4},children:[de(Pe,{stroke:"var(--rule)",vertical:!1}),de(Ae,{dataKey:"at",tickFormatter:(v)=>ze(v,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),de(Te,{tickFormatter:(v)=>b.format(v),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:48}),de(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:v,payload:S,label:Y})=>{if(v!==!0||S===void 0||S.length===0)return null;return it(Ve,{children:[de("div",{children:ze(Number(Y),n)}),S.map((A)=>it("div",{children:[Jt(D,String(A.dataKey))," ",b.format(Number(A.value??0))]},String(A.dataKey)))]})}}),C.map((v)=>de(rt,{type:"monotone",dataKey:v,stackId:"providers",stroke:_t(D,v),strokeWidth:2,fill:_t(D,v),fillOpacity:0.22,isAnimationActive:!1},v))]})})}),de(yt,{children:C.map((v)=>it("span",{children:[de(et,{$color:_t(D,v)})," ",Jt(D,v)]},v))}),it(q,{children:[de("thead",{children:it("tr",{children:[de(l,{children:"Provider"}),de(l,{$align:"right",children:"Share"}),de(l,{$align:"right",children:"Requests"}),de(l,{$align:"right",children:"Failed"}),de(l,{$align:"right",children:"Tokens"}),de(l,{$align:"right",children:"Cost"})]})}),de("tbody",{children:P.map(({name:v,totals:S})=>it(E,{children:[it(s,{children:[de(et,{$color:_t(D,v)})," ",Jt(D,v)]}),de(s,{$align:"right",$mono:!0,children:N(j===0?0:S.requests/j,0)}),de(s,{$align:"right",$mono:!0,children:a(S.requests)}),de(s,{$align:"right",$mono:!0,style:S.errors>0?{color:"var(--down)"}:void 0,children:a(S.errors)}),de(s,{$align:"right",$mono:!0,children:a(je(S))}),de(s,{$align:"right",$mono:!0,children:w(S.costUsd)})]},v))})]})]})}import Rt from"styled-components";import{jsx as ut,jsxs as ea}from"react/jsx-runtime";var Ur=Rt.li.withConfig({displayName:"RankPanel__Rank"})(["display:grid;grid-template-columns:minmax(0,20ch) 1fr auto;align-items:center;gap:",";"],({theme:i})=>i.space(2)),qr=Rt.ol.withConfig({displayName:"RankPanel__List"})(["display:flex;flex-direction:column;gap:",";"],({theme:i})=>i.space(2)),zr=Rt.div.withConfig({displayName:"RankPanel__Track"})(["height:8px;border-radius:2px;background:",";border:1px solid ",";overflow:hidden;"],({theme:i})=>i.color.panelSunk,({theme:i})=>i.color.rule),Gr=Rt.div.withConfig({displayName:"RankPanel__Fill"})(["width:",";height:100%;border-radius:0 2px 2px 0;background:",";opacity:0.85;"],({$share:i})=>`${Math.max(1.5,i*100)}%`,({theme:i,$fault:n})=>n?i.color.down:i.color.accent),_r=Rt(M).withConfig({displayName:"RankPanel__Name"})(["display:block;font-family:",";font-size:12px;"],({theme:i})=>i.font.mono),Ea=12;function ta({buckets:i,metric:n,names:p,unknownLabel:m}){let b=new Map;for(let C of i)b.set(C.key,Je(b.get(C.key)??We,C));let h=(C)=>C==="unknown"?m??"Unattributed":p?.get(C)??C,D=[...b.entries()].map(([C,I])=>({name:h(C),entry:I,value:n.of(Oe(I))})).sort((C,I)=>I.value-C.value),x=D.slice(0,Ea),O=D.slice(Ea),P=x[0]?.value??0;return ea(r,{$gap:3,children:[ut(qr,{children:x.map(({name:C,entry:I,value:W})=>ea(Ur,{children:[ut(_r,{title:C,children:C}),ut(zr,{children:ut(Gr,{$share:P===0?0:W/P,$fault:I.requests>0&&I.errors===I.requests})}),ea(o,{$gap:2,children:[ut(d,{$size:"12px",children:n.format(W)}),ut(d,{$size:"11px",$dim:!0,children:w(I.costUsd)})]})]},C))}),O.length===0?null:ut(d,{$size:"11px",$dim:!0,children:`+ ${O.length} more, ${a(O.reduce((C,I)=>C+I.entry.requests,0))} requests`})]})}import{jsx as Le,jsxs as wt}from"react/jsx-runtime";var aa=[{id:"inputTokens",label:"Uncached input",opacity:0.95},{id:"outputTokens",label:"Output",opacity:0.7},{id:"cacheReadTokens",label:"Cache read",opacity:0.45},{id:"cacheWriteTokens",label:"Cache write",opacity:0.22}];function Na({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b}){let h=new Map;for(let P of i)h.set(Fe(P.key,n),P);let D=Me(p,m,n,b).map((P)=>{let C=h.get(P);return{at:P,inputTokens:C?.inputTokens??0,outputTokens:C?.outputTokens??0,cacheReadTokens:C?.cacheReadTokens??0,cacheWriteTokens:C?.cacheWriteTokens??0}}),x=aa.map((P)=>({...P,value:D.reduce((C,I)=>C+I[P.id],0)})),O=x.reduce((P,C)=>P+C.value,0);return wt(r,{$gap:3,children:[Le(He,{$height:200,children:Le(De,{width:"100%",height:"100%",children:wt(kt,{data:D,margin:{top:4,right:4,bottom:4,left:4},children:[Le(Pe,{stroke:"var(--rule)",vertical:!1}),Le(Ae,{dataKey:"at",tickFormatter:(P)=>ze(P,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Le(Te,{tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:44,tickFormatter:(P)=>a(P)}),Le(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:P,payload:C,label:I})=>{if(P!==!0||C===void 0||C.length===0)return null;return wt(Ve,{children:[Le("div",{children:ze(Number(I),n)}),aa.map((W)=>wt("div",{children:[W.label," ",a(Number(C.find((j)=>j.dataKey===W.id)?.value??0))]},W.id))]})}}),aa.map((P)=>Le(rt,{type:"monotone",dataKey:P.id,stackId:"tokens",stroke:"var(--accent)",strokeOpacity:P.opacity,strokeWidth:1.5,fill:"var(--accent)",fillOpacity:P.opacity*0.5,isAnimationActive:!1},P.id))]})})}),Le(yt,{children:x.map((P)=>wt(o,{$gap:1,children:[Le(et,{$color:"var(--accent)",style:{opacity:P.opacity}}),Le("span",{children:P.label}),Le(d,{$size:"11px",children:a(P.value)}),Le(d,{$size:"11px",$dim:!0,children:N(O===0?0:P.value/O,0)})]},P.id))})]})}import{jsx as Ke,jsxs as nt}from"react/jsx-runtime";function Oa({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b}){let h=new Map;for(let x of i)h.set(Fe(x.key,n),x);let D=Me(p,m,n,b).map((x)=>{let O=h.get(x);return{at:x,label:ze(x,n),requests:O?.requests??0,errors:O?.errors??0,costUsd:O?.costUsd??0,tokens:O===void 0?0:je(O)}});return nt(r,{$gap:2,children:[Ke(He,{$height:220,children:Ke(De,{width:"100%",height:"100%",children:nt(Ca,{data:D,margin:{top:4,right:4,bottom:4,left:4},children:[Ke(Pe,{stroke:"var(--rule)",vertical:!1}),Ke(Ae,{dataKey:"label",tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Ke(Te,{tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:40}),Ke(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:x,payload:O})=>{if(x!==!0||O===void 0||O.length===0)return null;let P=O[0]?.payload;if(P===void 0)return null;return nt(Ve,{children:[Ke("div",{children:P.label}),nt("div",{children:[a(P.requests)," requests"]}),nt("div",{children:[a(P.errors)," failed"]}),nt("div",{children:[a(P.tokens)," tokens"]}),Ke("div",{children:w(P.costUsd)})]})}}),Ke(rt,{type:"monotone",dataKey:"requests",stroke:"none",fill:"var(--accent)",fillOpacity:0.12,isAnimationActive:!1}),Ke(Ze,{type:"monotone",dataKey:"requests",stroke:"var(--accent)",strokeWidth:2,dot:!1,activeDot:{r:4,stroke:"var(--panel)",strokeWidth:2},isAnimationActive:!1}),Ke(Ze,{type:"monotone",dataKey:"errors",stroke:"var(--down)",strokeWidth:2,dot:!1,activeDot:{r:4,stroke:"var(--panel)",strokeWidth:2},isAnimationActive:!1})]})})}),nt(yt,{children:[nt("span",{children:[Ke(et,{$color:"var(--accent)"})," Requests"]}),nt("span",{children:[Ke(et,{$color:"var(--down)"})," Failed"]})]})]})}import{jsx as se,jsxs as $t}from"react/jsx-runtime";var jr=86400000,La=[{id:"requestedModel",label:"As requested",column:"Virtual model"},{id:"model",label:"As served",column:"Upstream model"}],Ba=Fr(R).withConfig({displayName:"UsageBoard__Picker"})(["width:auto;"]);function Da(){let{cadence:i}=X(),[n,p]=It("24h"),[m,b]=It("tokens"),[h,D]=It("model"),[x,O]=It(void 0),[P,C]=It(void 0),I=pe(),W=we(),j=Lr(n),v=fo(m),S=No().data??null,Y=bt(()=>j.grain==="daily"?Ee(Date.now()-j.ms,S):Math.floor((Date.now()-j.ms)/60000)*60000,[j,S]),A=bt(()=>Y+j.ms,[Y,j]),Z=bt(()=>Ee(Date.now()-Yn*jr,S),[S]),re=I.data?.find((J)=>J.id===x),le=W.data?.find((J)=>J.id===P);if(x!==void 0&&I.data!==void 0&&re===void 0)O(void 0);if(P!==void 0&&W.data!==void 0&&le===void 0)C(void 0);let ne={...re===void 0?{}:{credentialId:re.id},...le===void 0?{}:{apiKeyId:le.id}},ae=`${le===void 0?"":` for ${le.label}`}${re===void 0?"":` on ${re.label}`}`,ge={since:Y,grain:j.grain,...ne},he=Ue({...ge,groupBy:j.by},i(60000,"res:usage")),Ce=Ue({...ge,groupBy:j.by,splitBy:"provider"},i(60000,"res:usage")),ke=Ue({...ge,groupBy:j.by,splitBy:"model"},i(60000,"res:usage")),qe=Ue({...ge,groupBy:j.by,splitBy:"apiKey"},i(60000,"res:usage")),tt=Ue({...ge,groupBy:h},i(60000,"res:usage")),at=Ue({...ge,groupBy:"credential"},i(60000,"res:usage")),pt=Ue({since:Z,grain:"daily",groupBy:"day",...ne},i(300000,"res:usage")),mt=H(),Nt=bt(()=>{let J=new Map;for(let ct of mt.data??[])for(let ra of ct.targets)J.set(ra.model,ra.provider);return J},[mt.data]),xt=bt(()=>{let J=new Map;for(let ct of W.data??[])J.set(ct.id,ct.label);return J},[W.data]),Ft=bt(()=>{let J=new Map;for(let ct of I.data??[])J.set(ct.id,ct.label);return J},[I.data]),ft=he.data??[],Xt=Rr(ft),Wa=je(Xt),dt={legend:"Nothing recorded",message:"No requests landed in this window. Widen the range, or send traffic through the gateway."};return $t(r,{$gap:4,children:[se(k,{legend:"Usage",title:"Requests, tokens, and spend",summary:he.isLoading?"Reading usage…":`${a(Xt.requests)} requests and ${w(Xt.costUsd)} over the last ${j.label}${ae}.`,actions:$t(o,{$wrap:!0,children:[se(Ba,{"aria-label":"Account",value:re?.id??"",options:[{value:"",label:"All accounts"},...(I.data??[]).map((J)=>({value:J.id,label:J.label}))],onValueChange:(J)=>O(J||void 0)}),se(Ba,{"aria-label":"Gateway key",value:le?.id??"",options:[{value:"",label:"All keys"},...(W.data??[]).map((J)=>({value:J.id,label:J.label}))],onValueChange:(J)=>C(J||void 0)}),se(Xe,{children:Ot.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===n,"aria-pressed":J.id===n,onClick:()=>p(J.id),children:J.id},J.id))})]})}),se(yr,{buckets:ft,since:Y,until:A,by:j.by,rangeLabel:j.label,dayOffsetMinutes:S}),se(Se,{legend:"Traffic",meta:j.by==="hour"?"By hour":"By day",query:he,isEmpty:ft.length===0,empty:dt,children:se(Oa,{buckets:ft,by:j.by,since:Y,until:A,dayOffsetMinutes:S})}),se(Xe,{children:Kt.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===m,"aria-pressed":J.id===m,onClick:()=>b(J.id),children:`Rank by ${J.label.toLowerCase()}`},J.id))}),se(Se,{legend:"Traffic by upstream model",meta:`${v.label}, ${j.by==="hour"?"by hour":"by day"}`,query:ke,isEmpty:(ke.data??[]).length===0,empty:dt,children:se($a,{buckets:ke.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v,providers:Nt})}),$t(Ie,{$min:"480px",$gap:4,children:[$t(r,{$gap:4,children:[se(Se,{legend:"Providers",meta:v.label,query:Ce,isEmpty:(Ce.data??[]).length===0,empty:dt,children:se(Ma,{buckets:Ce.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v})}),se(oa,{days:pt.data??[],now:Date.now(),dayOffsetMinutes:S})]}),$t(r,{$gap:4,children:[se(Se,{legend:"Token mix",meta:a(Wa),query:he,isEmpty:ft.length===0,empty:dt,children:se(Na,{buckets:ft,by:j.by,since:Y,until:A,dayOffsetMinutes:S})}),se(Se,{legend:"Models",meta:La.find((J)=>J.id===h)?.column,query:tt,isEmpty:(tt.data??[]).length===0,empty:dt,actions:se(Xe,{children:La.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===h,"aria-pressed":J.id===h,onClick:()=>D(J.id),children:J.label},J.id))}),children:se(ta,{buckets:tt.data??[],metric:v})}),se(Se,{legend:"Accounts",meta:v.label,query:at,isEmpty:(at.data??[]).length===0,empty:dt,children:se(ta,{buckets:at.data??[],metric:v,names:Ft,unknownLabel:"No account"})})]})]}),se(Se,{legend:"API keys",meta:v.label,query:qe,isEmpty:(qe.data??[]).length===0,empty:dt,children:se(sa,{buckets:qe.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v,names:xt})})]})}var Vo=Da;export{Vo as component};
@@ -1 +1 @@
1
- import{n,P,t,d,se,o,r,Q,p,rt,ot,Yt,en,tn,rn,vo,on,nn,an,sn,a,w,N,_e,O,at,wo,or,X,Co,x,b,J,k,Vr,Kr,f}from"/assets/index-p9vbm21a.js";import{$e,R}from"/assets/index-f7t0kve8.js";import{re}from"/assets/index-wjqdtafp.js";import{Se,st,Xe,yr}from"/assets/index-hk28xepa.js";import"/assets/index-8bewp9z1.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{fr,pr,mr,hr,gr}from"/assets/index-sbe0ydnc.js";import"/assets/index-fcew0gga.js";import"/assets/index-xdyjb1an.js";import{Ot,Lr,Ee}from"/assets/index-z7c4qz9d.js";import{$t,wr}from"/assets/index-938qd7p2.js";import"/assets/index-d09hs7ex.js";import{lr}from"/assets/index-4dz4bgrb.js";import{Le}from"/assets/index-zkt5p0qd.js";import ge from"styled-components";import{jsx as me,jsxs as Be}from"react/jsx-runtime";var Oe=ge.div.withConfig({displayName:"ClientShell__Frame"})(['display:grid;grid-template-areas:"chassis" "main";grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);height:100vh;min-height:0;overflow:hidden;']),Qe=ge.main.withConfig({displayName:"ClientShell__Main"})(["grid-area:main;padding:",";display:flex;flex-direction:column;gap:",";min-width:0;min-height:0;overflow-y:auto;@media (max-width:720px){padding:",";}"],({theme:u})=>u.space(4),({theme:u})=>u.space(4),({theme:u})=>u.space(3));function pe({children:u}){let{cadence:y}=X(),A=en(),C=on(200,y(1e4,"res:logs"));return Be(Oe,{"data-testid":"client-shell",children:[me(Co,{logs:C.data??[],logsFailed:C.isError,signOut:{pending:A.isPending,run:()=>{A.mutate(void 0,{onSuccess:()=>window.location.assign("/login")})}}}),me(Qe,{children:u})]})}import{Fragment as he,useMemo as K,useState as U}from"react";import W from"styled-components";import{jsx as e,jsxs as c,Fragment as Ye}from"react/jsx-runtime";var fe=[20,50,100,250],Fe=W(R).withConfig({displayName:"ClientBoard__Narrow"})(["width:auto;"]),De={"1m":"per minute","5h":"per 5 hours","1w":"per week"};function He({reading:u}){let y=u.window===null?"concurrent requests":`${u.dimension} ${De[u.window]??u.window}`,A=u.model===null?y:`${y} for ${u.model}`,C=u.dimension==="spend"?w:a,S=u.used===null?null:u.limit===0?1:u.used/u.limit;return c(E,{children:[e(s,{children:y}),e(s,{$align:"right",$mono:!0,children:u.used===null?e(se,{children:"unknown"}):C(u.used)}),e(s,{$align:"right",$mono:!0,children:C(u.limit)}),e(s,{children:S===null?null:e(re,{fraction:S,label:`${A}, ${Math.round(Math.min(1,S)*100)}% used`})})]})}function ye(u){return{observedAt:u.observedAt,windowType:u.windowType,windowMs:u.windowMs,resetsAt:u.resetsAt,usedRatio:u.usedRatio}}function Ie(u){return{stale:u.stale,rolledOver:u.rolledOver,estimateStale:u.stale||u.rolledOver,survives:u.survives,exhaustsAt:u.exhaustsAt}}var Ue=W.p.withConfig({displayName:"ClientBoard__Policy"})(["font-size:12px;line-height:1.5;color:",";white-space:pre-wrap;overflow-wrap:anywhere;max-width:80ch;"],({theme:u})=>u.color.ink),We=W.div.withConfig({displayName:"ClientBoard__QuotaStack"})(["display:flex;flex-direction:column;gap:4px;"]),ze=W.div.withConfig({displayName:"ClientBoard__QuotaCell"})(["display:grid;grid-template-columns:96px 34px 1fr;align-items:center;min-width:208px;gap:6px;"]),Ge=W(d).withConfig({displayName:"ClientBoard__Percent"})(["font-size:11px;text-align:right;"]);function Ve({windows:u,open:y,onToggle:A}){let C=u[0],S=u.filter((v)=>v.usedRatio!==null);return c(E,{children:[e(s,{children:C.label}),e(s,{children:S.length===0?e(se,{children:"unknown"}):e(We,{children:S.map((v)=>c(ze,{children:[e(re,{fraction:v.usedRatio,label:`${v.label} ${v.windowType} window, ${Math.round(v.usedRatio*100)}% used`}),e(Ge,{children:N(v.usedRatio,0)}),e(t,{children:wo(v,Ie(v),Date.now(),_e)})]},v.windowType))})}),e(s,{$align:"right",children:e(P,{type:"button",$variant:"ghost",$size:"sm","aria-expanded":y,"aria-label":`${y?"Hide":"Show"} quota history for ${C.label}`,title:`${y?"Hide":"Show"} quota history for ${C.label}`,onClick:A,children:y?e($e,{}):e(Le,{})})})]})}function we(){let{cadence:u,live:y}=X(),[A,C]=U("24h"),[S,v]=U(fr),[j,ve]=U(fe[0]),[ee,te]=U(null),[z,Te]=U(null),T=Lr(A),oe=rn().data??null,G=K(()=>T.grain==="daily"?Ee(Date.now()-T.ms,oe):Math.floor((Date.now()-T.ms)/60000)*60000,[T,oe]),Ce=K(()=>G+T.ms,[G,T]),m=tn(),le={since:G,grain:T.grain},de=vo({...le,groupBy:T.by},u(60000,"res:usage")),F=vo({...le,groupBy:"model"},u(60000,"res:usage")),M=nn(S,j,u(rt,"res:logs")),be=!ot(M.data),Re=Yt(p.clientLogPages(S,j)),I=an(60000),V=I.data??[],ue=lr(m.data?.limitUsage??[]),ke=ue.some((i)=>i.model!==null),Me=K(()=>{let i=new Map;for(let g of V){let L=i.get(g.provider)??new Map,B=L.get(g.credentialId);if(B===void 0)L.set(g.credentialId,[g]);else B.push(g);i.set(g.provider,L)}return[...i.entries()].map(([g,L])=>[g,[...L.entries()].map(([B,h])=>({credentialId:B,windows:[...h].sort((Y,H)=>or[Y.windowType]-or[H.windowType])}))])},[V]),ie=V.map((i)=>$t(ye(i))).filter((i)=>i!==null),Ae=ie.length===0?0:Math.floor(Math.min(...ie)/60000)*60000,ce=sn({since:Ae},z!==null&&ie.length>0),D=K(()=>(M.data?.pages??[]).flatMap((i)=>i.logs),[M.data?.pages]),qe=mr(y&&D.some(O)),xe=D.filter(at).length,ne=de.data??[],Ne=ne.reduce((i,g)=>i+g.requests,0),Pe=ne.reduce((i,g)=>i+g.costUsd,0);return c(r,{$gap:4,children:[e(k,{legend:"Client",title:"Your usage",summary:de.isLoading?"Reading your usage…":`${a(Ne)} requests and ${w(Pe)} over the last ${T.label}.`,actions:e(Xe,{children:Ot.map((i)=>e(st,{type:"button",$size:"sm",$on:i.id===A,"aria-pressed":i.id===A,onClick:()=>C(i.id),children:i.id},i.id))})}),e(f,{legend:"Your key",meta:m.data===void 0?void 0:c(d,{$dim:!0,children:[m.data.prefix,"…"]}),children:m.isPending?e(b,{rows:2}):m.isError?e(x,{legend:"Could not read your key",error:m.error}):c(r,{$gap:2,children:[c(o,{$gap:2,$wrap:!0,children:[e(t,{children:m.data.label}),m.data.bodyLoggingOptOut?e(se,{children:"Request bodies are never stored for this key."}):null]}),m.data.modelAllowlist===null?e(se,{children:"Every model this gateway serves."}):m.data.modelAllowlist.length===0?e(se,{children:"No models. This key cannot serve a request."}):e(o,{$gap:1,$wrap:!0,children:m.data.modelAllowlist.map((i)=>e(d,{children:i},i))}),c(se,{children:["Confidential routing: ",m.data.smartRouting?"on":"off"]}),m.data.guardrailPolicy===null?null:c(r,{$gap:1,children:[e(t,{children:"Usage policy"}),e(Ue,{children:m.data.guardrailPolicy}),e(se,{children:"Each request is checked against this before it is served, and the check is billed to this key. Requests outside it are refused."})]})]})}),e(yr,{buckets:ne,since:G,until:Ce,by:T.by,rangeLabel:T.label,dayOffsetMinutes:oe}),e(Se,{legend:"By model",meta:T.label,query:{isLoading:F.isLoading,isError:F.isError,error:F.error,refetch:()=>void F.refetch()},failure:"Could not read usage",empty:{legend:"No traffic",message:"Nothing served in this window."},isEmpty:(F.data??[]).length===0,children:e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Model"}),e(l,{$align:"right",children:"Requests"}),e(l,{$align:"right",children:"Tokens"}),e(l,{$align:"right",children:"Spend"})]})}),e("tbody",{children:(F.data??[]).map((i)=>c(E,{children:[e(s,{$mono:!0,children:i.key}),e(s,{$align:"right",$mono:!0,children:a(i.requests)}),e(s,{$align:"right",$mono:!0,children:a(i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens)}),e(s,{$align:"right",$mono:!0,children:w(i.costUsd)})]},i.key))})]})})}),e(Se,{legend:"Your limits",query:{isLoading:m.isLoading,isError:m.isError,error:m.error,refetch:()=>void m.refetch()},failure:"Could not read your limits",empty:m.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:m.data?.limits===null||(m.data?.limitUsage.length??0)===0,footer:e(se,{children:"Counted from completed requests, so a burst in flight right now may not be included yet."}),children:e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Limit"}),e(l,{$align:"right",children:"Used"}),e(l,{$align:"right",children:"Ceiling"}),e(l,{$width:"30%",children:"Consumption"})]})}),e("tbody",{children:ue.map((i)=>c(he,{children:[ke?e(E,{children:e(l,{scope:"rowgroup",colSpan:4,children:i.model??"Every model"})}):null,i.readings.map((g)=>e(He,{reading:g},`${g.dimension}:${g.window??"gauge"}`))]},i.model??""))})]})})}),e(Se,{legend:"Provider headroom",query:{isLoading:I.isLoading,isError:I.isError,error:I.error,refetch:()=>void I.refetch()},failure:"Could not read provider headroom",empty:{legend:"No data",message:"No provider has reported a usage window."},isEmpty:V.length===0,footer:e(se,{children:"What each account serving this gateway has left. A request is served by whichever account of a provider can take it."}),children:e(r,{$gap:4,children:Me.map(([i,g])=>c(r,{$gap:1,children:[e(t,{children:i}),e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Account"}),e(l,{$width:"60%",children:"Quota"}),e(l,{})]})}),e("tbody",{children:g.map(({credentialId:L,windows:B})=>c(he,{children:[e(Ve,{windows:B,open:z===L,onToggle:()=>Te(z===L?null:L)}),z!==L?null:e(E,{children:e(s,{colSpan:3,children:e(r,{$gap:4,children:B.map((h)=>{let Y=ye(h),H=$t(Y),ae=(ce.data?.samples??[]).filter((_)=>_.credentialId===h.credentialId&&_.windowType===h.windowType&&_.observedAt>=(H??0));return e(wr,{live:Y,samples:ae.map((_)=>({observedAt:_.observedAt,windowType:_.windowType,windowMs:_.windowMs,resetsAt:_.resetsAt,usedRatio:_.usedRatio})),since:H,now:Date.now(),truncated:ce.data?.truncated===!0&&H!==null&&ae.length>0&&(ae[0]?.observedAt??0)>H,ratePerHourRatio:h.ratePerHourRatio,exhaustsAt:h.exhaustsAt,survives:h.survives,stale:h.stale,rolledOver:h.rolledOver,spent:h.usedRatio===null?"no ceiling reported":`${N(h.usedRatio,0)} used`,rateText:h.ratePerHourRatio===null?"unknown":`${N(h.ratePerHourRatio,1)}/h`},h.windowType)})})})})]},L))})]})})]},i))})}),e(Se,{legend:"Recent requests",meta:`${D.length} shown`,actions:c(Xe,{children:[e(pr,{filters:S,onChange:v}),e(Fe,{value:j,"aria-label":"How many requests per page",options:fe.map((i)=>({value:String(i),label:`${i} per page`})),onValueChange:(i)=>ve(Number(i))})]}),query:{isLoading:M.isLoading,isError:M.isError,error:M.error,refetch:()=>void M.refetch()},failure:"Could not read your requests",empty:{legend:"No requests",message:Object.keys(S).length===0?"Nothing served through this key yet.":"No request served through this key matches these filters."},isEmpty:D.length===0,footer:c(o,{$gap:2,$wrap:!0,children:[c(se,{children:[a(xe)," of the ",a(D.length)," loaded failed."]}),M.hasNextPage?e(n,{type:"button",$size:"sm",disabled:M.isFetchingNextPage,onClick:()=>void M.fetchNextPage(),children:M.isFetchingNextPage?"Loading…":"Load older"}):null,be?c(Ye,{children:[e(se,{children:"Live updates are paused while older pages are loaded."}),e(n,{type:"button",$size:"sm",onClick:Re,children:"Back to live"})]}):null]}),children:e(Q,{children:e(hr,{rows:D,now:qe,onOpen:te})})}),e(J,{open:ee!==null,onOpenChange:(i)=>{if(!i)te(null)},title:"Request detail",width:"640px",footer:e(n,{type:"button",onClick:()=>te(null),children:"Close"}),children:ee===null?null:e(gr,{log:ee})})]})}import{jsx as Z}from"react/jsx-runtime";var Bt=()=>Z(Vr,{children:Z(Kr,{children:Z(pe,{children:Z(we,{})})})});export{Bt as component};
1
+ import{n,P,t,d,se,o,r,Q,p,rt,ot,Yt,en,tn,rn,vo,on,nn,an,sn,a,w,N,_e,O,at,wo,or,X,Co,x,b,J,k,Vr,Kr,f}from"/assets/index-qkhn11a8.js";import{$e,R}from"/assets/index-330vgx7r.js";import{re}from"/assets/index-wjqdtafp.js";import{Se,st,Xe,yr}from"/assets/index-dny52xdk.js";import"/assets/index-h41dkv54.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{fr,pr,mr,hr,gr}from"/assets/index-6v3e0r4x.js";import"/assets/index-e7nx5832.js";import"/assets/index-zqfj5xfa.js";import{Ot,Lr,Ee}from"/assets/index-96zs0ekh.js";import{$t,wr}from"/assets/index-40vm2qxc.js";import"/assets/index-ywek2f98.js";import{lr}from"/assets/index-4dz4bgrb.js";import{Le}from"/assets/index-9pefp4zb.js";import ge from"styled-components";import{jsx as me,jsxs as Be}from"react/jsx-runtime";var Oe=ge.div.withConfig({displayName:"ClientShell__Frame"})(['display:grid;grid-template-areas:"chassis" "main";grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);height:100vh;min-height:0;overflow:hidden;']),Qe=ge.main.withConfig({displayName:"ClientShell__Main"})(["grid-area:main;padding:",";display:flex;flex-direction:column;gap:",";min-width:0;min-height:0;overflow-y:auto;@media (max-width:720px){padding:",";}"],({theme:u})=>u.space(4),({theme:u})=>u.space(4),({theme:u})=>u.space(3));function pe({children:u}){let{cadence:y}=X(),A=en(),C=on(200,y(1e4,"res:logs"));return Be(Oe,{"data-testid":"client-shell",children:[me(Co,{logs:C.data??[],logsFailed:C.isError,signOut:{pending:A.isPending,run:()=>{A.mutate(void 0,{onSuccess:()=>window.location.assign("/login")})}}}),me(Qe,{children:u})]})}import{Fragment as he,useMemo as K,useState as U}from"react";import W from"styled-components";import{jsx as e,jsxs as c,Fragment as Ye}from"react/jsx-runtime";var fe=[20,50,100,250],Fe=W(R).withConfig({displayName:"ClientBoard__Narrow"})(["width:auto;"]),De={"1m":"per minute","5h":"per 5 hours","1w":"per week"};function He({reading:u}){let y=u.window===null?"concurrent requests":`${u.dimension} ${De[u.window]??u.window}`,A=u.model===null?y:`${y} for ${u.model}`,C=u.dimension==="spend"?w:a,S=u.used===null?null:u.limit===0?1:u.used/u.limit;return c(E,{children:[e(s,{children:y}),e(s,{$align:"right",$mono:!0,children:u.used===null?e(se,{children:"unknown"}):C(u.used)}),e(s,{$align:"right",$mono:!0,children:C(u.limit)}),e(s,{children:S===null?null:e(re,{fraction:S,label:`${A}, ${Math.round(Math.min(1,S)*100)}% used`})})]})}function ye(u){return{observedAt:u.observedAt,windowType:u.windowType,windowMs:u.windowMs,resetsAt:u.resetsAt,usedRatio:u.usedRatio}}function Ie(u){return{stale:u.stale,rolledOver:u.rolledOver,estimateStale:u.stale||u.rolledOver,survives:u.survives,exhaustsAt:u.exhaustsAt}}var Ue=W.p.withConfig({displayName:"ClientBoard__Policy"})(["font-size:12px;line-height:1.5;color:",";white-space:pre-wrap;overflow-wrap:anywhere;max-width:80ch;"],({theme:u})=>u.color.ink),We=W.div.withConfig({displayName:"ClientBoard__QuotaStack"})(["display:flex;flex-direction:column;gap:4px;"]),ze=W.div.withConfig({displayName:"ClientBoard__QuotaCell"})(["display:grid;grid-template-columns:96px 34px 1fr;align-items:center;min-width:208px;gap:6px;"]),Ge=W(d).withConfig({displayName:"ClientBoard__Percent"})(["font-size:11px;text-align:right;"]);function Ve({windows:u,open:y,onToggle:A}){let C=u[0],S=u.filter((v)=>v.usedRatio!==null);return c(E,{children:[e(s,{children:C.label}),e(s,{children:S.length===0?e(se,{children:"unknown"}):e(We,{children:S.map((v)=>c(ze,{children:[e(re,{fraction:v.usedRatio,label:`${v.label} ${v.windowType} window, ${Math.round(v.usedRatio*100)}% used`}),e(Ge,{children:N(v.usedRatio,0)}),e(t,{children:wo(v,Ie(v),Date.now(),_e)})]},v.windowType))})}),e(s,{$align:"right",children:e(P,{type:"button",$variant:"ghost",$size:"sm","aria-expanded":y,"aria-label":`${y?"Hide":"Show"} quota history for ${C.label}`,title:`${y?"Hide":"Show"} quota history for ${C.label}`,onClick:A,children:y?e($e,{}):e(Le,{})})})]})}function we(){let{cadence:u,live:y}=X(),[A,C]=U("24h"),[S,v]=U(fr),[j,ve]=U(fe[0]),[ee,te]=U(null),[z,Te]=U(null),T=Lr(A),oe=rn().data??null,G=K(()=>T.grain==="daily"?Ee(Date.now()-T.ms,oe):Math.floor((Date.now()-T.ms)/60000)*60000,[T,oe]),Ce=K(()=>G+T.ms,[G,T]),m=tn(),le={since:G,grain:T.grain},de=vo({...le,groupBy:T.by},u(60000,"res:usage")),F=vo({...le,groupBy:"model"},u(60000,"res:usage")),M=nn(S,j,u(rt,"res:logs")),be=!ot(M.data),Re=Yt(p.clientLogPages(S,j)),I=an(60000),V=I.data??[],ue=lr(m.data?.limitUsage??[]),ke=ue.some((i)=>i.model!==null),Me=K(()=>{let i=new Map;for(let g of V){let L=i.get(g.provider)??new Map,B=L.get(g.credentialId);if(B===void 0)L.set(g.credentialId,[g]);else B.push(g);i.set(g.provider,L)}return[...i.entries()].map(([g,L])=>[g,[...L.entries()].map(([B,h])=>({credentialId:B,windows:[...h].sort((Y,H)=>or[Y.windowType]-or[H.windowType])}))])},[V]),ie=V.map((i)=>$t(ye(i))).filter((i)=>i!==null),Ae=ie.length===0?0:Math.floor(Math.min(...ie)/60000)*60000,ce=sn({since:Ae},z!==null&&ie.length>0),D=K(()=>(M.data?.pages??[]).flatMap((i)=>i.logs),[M.data?.pages]),qe=mr(y&&D.some(O)),xe=D.filter(at).length,ne=de.data??[],Ne=ne.reduce((i,g)=>i+g.requests,0),Pe=ne.reduce((i,g)=>i+g.costUsd,0);return c(r,{$gap:4,children:[e(k,{legend:"Client",title:"Your usage",summary:de.isLoading?"Reading your usage…":`${a(Ne)} requests and ${w(Pe)} over the last ${T.label}.`,actions:e(Xe,{children:Ot.map((i)=>e(st,{type:"button",$size:"sm",$on:i.id===A,"aria-pressed":i.id===A,onClick:()=>C(i.id),children:i.id},i.id))})}),e(f,{legend:"Your key",meta:m.data===void 0?void 0:c(d,{$dim:!0,children:[m.data.prefix,"…"]}),children:m.isPending?e(b,{rows:2}):m.isError?e(x,{legend:"Could not read your key",error:m.error}):c(r,{$gap:2,children:[c(o,{$gap:2,$wrap:!0,children:[e(t,{children:m.data.label}),m.data.bodyLoggingOptOut?e(se,{children:"Request bodies are never stored for this key."}):null]}),m.data.modelAllowlist===null?e(se,{children:"Every model this gateway serves."}):m.data.modelAllowlist.length===0?e(se,{children:"No models. This key cannot serve a request."}):e(o,{$gap:1,$wrap:!0,children:m.data.modelAllowlist.map((i)=>e(d,{children:i},i))}),c(se,{children:["Confidential routing: ",m.data.smartRouting?"on":"off"]}),m.data.guardrailPolicy===null?null:c(r,{$gap:1,children:[e(t,{children:"Usage policy"}),e(Ue,{children:m.data.guardrailPolicy}),e(se,{children:"Each request is checked against this before it is served, and the check is billed to this key. Requests outside it are refused."})]})]})}),e(yr,{buckets:ne,since:G,until:Ce,by:T.by,rangeLabel:T.label,dayOffsetMinutes:oe}),e(Se,{legend:"By model",meta:T.label,query:{isLoading:F.isLoading,isError:F.isError,error:F.error,refetch:()=>void F.refetch()},failure:"Could not read usage",empty:{legend:"No traffic",message:"Nothing served in this window."},isEmpty:(F.data??[]).length===0,children:e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Model"}),e(l,{$align:"right",children:"Requests"}),e(l,{$align:"right",children:"Tokens"}),e(l,{$align:"right",children:"Spend"})]})}),e("tbody",{children:(F.data??[]).map((i)=>c(E,{children:[e(s,{$mono:!0,children:i.key}),e(s,{$align:"right",$mono:!0,children:a(i.requests)}),e(s,{$align:"right",$mono:!0,children:a(i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens)}),e(s,{$align:"right",$mono:!0,children:w(i.costUsd)})]},i.key))})]})})}),e(Se,{legend:"Your limits",query:{isLoading:m.isLoading,isError:m.isError,error:m.error,refetch:()=>void m.refetch()},failure:"Could not read your limits",empty:m.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:m.data?.limits===null||(m.data?.limitUsage.length??0)===0,footer:e(se,{children:"Counted from completed requests, so a burst in flight right now may not be included yet."}),children:e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Limit"}),e(l,{$align:"right",children:"Used"}),e(l,{$align:"right",children:"Ceiling"}),e(l,{$width:"30%",children:"Consumption"})]})}),e("tbody",{children:ue.map((i)=>c(he,{children:[ke?e(E,{children:e(l,{scope:"rowgroup",colSpan:4,children:i.model??"Every model"})}):null,i.readings.map((g)=>e(He,{reading:g},`${g.dimension}:${g.window??"gauge"}`))]},i.model??""))})]})})}),e(Se,{legend:"Provider headroom",query:{isLoading:I.isLoading,isError:I.isError,error:I.error,refetch:()=>void I.refetch()},failure:"Could not read provider headroom",empty:{legend:"No data",message:"No provider has reported a usage window."},isEmpty:V.length===0,footer:e(se,{children:"What each account serving this gateway has left. A request is served by whichever account of a provider can take it."}),children:e(r,{$gap:4,children:Me.map(([i,g])=>c(r,{$gap:1,children:[e(t,{children:i}),e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Account"}),e(l,{$width:"60%",children:"Quota"}),e(l,{})]})}),e("tbody",{children:g.map(({credentialId:L,windows:B})=>c(he,{children:[e(Ve,{windows:B,open:z===L,onToggle:()=>Te(z===L?null:L)}),z!==L?null:e(E,{children:e(s,{colSpan:3,children:e(r,{$gap:4,children:B.map((h)=>{let Y=ye(h),H=$t(Y),ae=(ce.data?.samples??[]).filter((_)=>_.credentialId===h.credentialId&&_.windowType===h.windowType&&_.observedAt>=(H??0));return e(wr,{live:Y,samples:ae.map((_)=>({observedAt:_.observedAt,windowType:_.windowType,windowMs:_.windowMs,resetsAt:_.resetsAt,usedRatio:_.usedRatio})),since:H,now:Date.now(),truncated:ce.data?.truncated===!0&&H!==null&&ae.length>0&&(ae[0]?.observedAt??0)>H,ratePerHourRatio:h.ratePerHourRatio,exhaustsAt:h.exhaustsAt,survives:h.survives,stale:h.stale,rolledOver:h.rolledOver,spent:h.usedRatio===null?"no ceiling reported":`${N(h.usedRatio,0)} used`,rateText:h.ratePerHourRatio===null?"unknown":`${N(h.ratePerHourRatio,1)}/h`},h.windowType)})})})})]},L))})]})})]},i))})}),e(Se,{legend:"Recent requests",meta:`${D.length} shown`,actions:c(Xe,{children:[e(pr,{filters:S,onChange:v}),e(Fe,{value:j,"aria-label":"How many requests per page",options:fe.map((i)=>({value:String(i),label:`${i} per page`})),onValueChange:(i)=>ve(Number(i))})]}),query:{isLoading:M.isLoading,isError:M.isError,error:M.error,refetch:()=>void M.refetch()},failure:"Could not read your requests",empty:{legend:"No requests",message:Object.keys(S).length===0?"Nothing served through this key yet.":"No request served through this key matches these filters."},isEmpty:D.length===0,footer:c(o,{$gap:2,$wrap:!0,children:[c(se,{children:[a(xe)," of the ",a(D.length)," loaded failed."]}),M.hasNextPage?e(n,{type:"button",$size:"sm",disabled:M.isFetchingNextPage,onClick:()=>void M.fetchNextPage(),children:M.isFetchingNextPage?"Loading…":"Load older"}):null,be?c(Ye,{children:[e(se,{children:"Live updates are paused while older pages are loaded."}),e(n,{type:"button",$size:"sm",onClick:Re,children:"Back to live"})]}):null]}),children:e(Q,{children:e(hr,{rows:D,now:qe,onOpen:te})})}),e(J,{open:ee!==null,onOpenChange:(i)=>{if(!i)te(null)},title:"Request detail",width:"640px",footer:e(n,{type:"button",onClick:()=>te(null),children:"Close"}),children:ee===null?null:e(gr,{log:ee})})]})}import{jsx as Z}from"react/jsx-runtime";var Bt=()=>Z(Vr,{children:Z(Kr,{children:Z(pe,{children:Z(we,{})})})});export{Bt as component};
@@ -1,2 +1,2 @@
1
- import{P,r,i}from"/assets/index-p9vbm21a.js";import{ho}from"/assets/index-f7t0kve8.js";var d={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};d.node;var s=i(d);import{useCallback as C,useEffect as x,useRef as b,useState as w}from"react";import l from"styled-components";function h(e){if(e===null||typeof getSelection!=="function")return!1;let t=getSelection();if(t===null)return!1;try{let o=document.createRange();return o.selectNodeContents(e),t.removeAllRanges(),t.addRange(o),!0}catch{return!1}}async function f(e,t){if(typeof navigator<"u"&&navigator.clipboard!==void 0)try{return await navigator.clipboard.writeText(e),"copied"}catch{}let o=h(t??null);if(o&&typeof document.execCommand==="function")try{if(document.execCommand("copy"))return"copied"}catch{}return o?"selected":"failed"}import{jsx as n,jsxs as y}from"react/jsx-runtime";var k=l.div.withConfig({displayName:"CopyValue__Frame"})(["display:flex;align-items:stretch;gap:0;border:1px solid ",";border-radius:",";background:",";overflow:hidden;"],({theme:e})=>e.color.ruleStrong,({theme:e})=>e.radius.control,({theme:e})=>e.color.panelSunk),T=l.code.withConfig({displayName:"CopyValue__Value"})(["flex:1;min-width:0;padding:7px 8px;font-family:",";font-size:12px;word-break:break-all;user-select:all;"],({theme:e})=>e.font.mono),V=l(P).withConfig({displayName:"CopyValue__Action"})(["border:0;border-left:1px solid ",";border-radius:0;height:auto;width:32px;flex:none;"],({theme:e})=>e.color.ruleStrong),v=l.p.withConfig({displayName:"CopyValue__Hint"})(["font-size:11px;color:",";"],({theme:e})=>e.color.warn),_={selected:"Your browser would not copy it. The value is selected — copy it with your keyboard.",failed:"Your browser would not copy it. Select the value and copy it by hand."};function xr({value:e,label:t}){let[o,a]=w(null),u=b(null);x(()=>{if(o!=="copied")return;let g=setTimeout(()=>a(null),1600);return()=>clearTimeout(g)},[o]);let m=C(()=>{f(e,u.current).then(a)},[e]),c=o==="copied",p=o===null?void 0:_[o];return y(r,{$gap:1,children:[y(k,{children:[n(T,{ref:u,children:e}),n(V,{type:"button",$variant:"ghost",onClick:m,"aria-label":c?"Copied":t,title:c?"Copied":t,children:c?n(ho,{}):n(s,{})})]}),p===void 0?null:n(v,{role:"status",children:p})]})}
1
+ import{P,r,i}from"/assets/index-qkhn11a8.js";import{ho}from"/assets/index-330vgx7r.js";var d={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};d.node;var s=i(d);import{useCallback as C,useEffect as x,useRef as b,useState as w}from"react";import l from"styled-components";function h(e){if(e===null||typeof getSelection!=="function")return!1;let t=getSelection();if(t===null)return!1;try{let o=document.createRange();return o.selectNodeContents(e),t.removeAllRanges(),t.addRange(o),!0}catch{return!1}}async function f(e,t){if(typeof navigator<"u"&&navigator.clipboard!==void 0)try{return await navigator.clipboard.writeText(e),"copied"}catch{}let o=h(t??null);if(o&&typeof document.execCommand==="function")try{if(document.execCommand("copy"))return"copied"}catch{}return o?"selected":"failed"}import{jsx as n,jsxs as y}from"react/jsx-runtime";var k=l.div.withConfig({displayName:"CopyValue__Frame"})(["display:flex;align-items:stretch;gap:0;border:1px solid ",";border-radius:",";background:",";overflow:hidden;"],({theme:e})=>e.color.ruleStrong,({theme:e})=>e.radius.control,({theme:e})=>e.color.panelSunk),T=l.code.withConfig({displayName:"CopyValue__Value"})(["flex:1;min-width:0;padding:7px 8px;font-family:",";font-size:12px;word-break:break-all;user-select:all;"],({theme:e})=>e.font.mono),V=l(P).withConfig({displayName:"CopyValue__Action"})(["border:0;border-left:1px solid ",";border-radius:0;height:auto;width:32px;flex:none;"],({theme:e})=>e.color.ruleStrong),v=l.p.withConfig({displayName:"CopyValue__Hint"})(["font-size:11px;color:",";"],({theme:e})=>e.color.warn),_={selected:"Your browser would not copy it. The value is selected — copy it with your keyboard.",failed:"Your browser would not copy it. Select the value and copy it by hand."};function xr({value:e,label:t}){let[o,a]=w(null),u=b(null);x(()=>{if(o!=="copied")return;let g=setTimeout(()=>a(null),1600);return()=>clearTimeout(g)},[o]);let m=C(()=>{f(e,u.current).then(a)},[e]),c=o==="copied",p=o===null?void 0:_[o];return y(r,{$gap:1,children:[y(k,{children:[n(T,{ref:u,children:e}),n(V,{type:"button",$variant:"ghost",onClick:m,"aria-label":c?"Copied":t,title:c?"Copied":t,children:c?n(ho,{}):n(s,{})})]}),p===void 0?null:n(v,{role:"status",children:p})]})}
2
2
  export{xr};