omnigateway 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +334 -8
  2. package/bin/omni.js +1929 -147
  3. package/gateway.js +3129 -555
  4. package/package.json +1 -1
  5. package/public/assets/{Chip-DJwp7gBu.js → Chip-DbKk1ExR.js} +1 -1
  6. package/public/assets/Confirm-C5DYoI93.js +4 -0
  7. package/public/assets/CopyValue-CXjietiZ.js +27 -0
  8. package/public/assets/{Field-BDtp692L.js → Field-B7GOsJf8.js} +1 -1
  9. package/public/assets/Lamp-QRSv-SqM.js +25 -0
  10. package/public/assets/{Meter-BREBUFGX.js → Meter-Dngwbpjo.js} +1 -1
  11. package/public/assets/Modal-DfltaSCz.js +82 -0
  12. package/public/assets/Rack-D1zBw9SW.js +151 -0
  13. package/public/assets/{Readout-CEAoN5hu.js → Readout--CQnPjoO.js} +2 -2
  14. package/public/assets/{States-BEKLros0.js → States-CQFkw1UZ.js} +3 -3
  15. package/public/assets/{Table-BBypbVWj.js → Table-Ba58Wg4-.js} +1 -1
  16. package/public/assets/Toggle-DWrWc9-9.js +39 -0
  17. package/public/assets/TokenBreakdown-CyHJv0O5.js +31 -0
  18. package/public/assets/_app-CTDgfstQ.js +1 -0
  19. package/public/assets/_app.accounts-DP6T8z7I.js +64 -0
  20. package/public/assets/{_app.console-DKyGL9xx.js → _app.console-DYr7TCAl.js} +10 -10
  21. package/public/assets/_app.database-BzO1S_VR.js +39 -0
  22. package/public/assets/_app.index-CBt6b-lA.js +62 -0
  23. package/public/assets/_app.keys-B8HGsPPS.js +76 -0
  24. package/public/assets/_app.logs-DKsxa2Su.js +68 -0
  25. package/public/assets/{_app.models-CDqVrAeF.js → _app.models-CZD2UpM-.js} +28 -28
  26. package/public/assets/_app.settings-B2C1LQIF.js +46 -0
  27. package/public/assets/_app.usage-CDWUXtZy.js +83 -0
  28. package/public/assets/dist-IkJ0qg-4.js +1 -0
  29. package/public/assets/index-ClU3Xqui.js +186 -0
  30. package/public/assets/login-E3gh2_Cl.js +36 -0
  31. package/public/assets/plus-DkO4vG-T.js +1 -0
  32. package/public/assets/queries-BJHk_wso.js +144 -0
  33. package/public/assets/reasons-Cb8yF4Oy.js +1 -0
  34. package/public/assets/{shared-CIhZ6FCO.js → shared-Bp35cgFf.js} +7 -7
  35. package/public/assets/{trash-2-CLYNAAJA.js → trash-2-DTWWI3vA.js} +1 -1
  36. package/public/index.html +2 -2
  37. package/public/assets/Confirm-CVLz9F7a.js +0 -4
  38. package/public/assets/CopyValue-CNZbWS59.js +0 -27
  39. package/public/assets/Lamp-B65uWKbW.js +0 -25
  40. package/public/assets/Modal-DbydSAlp.js +0 -82
  41. package/public/assets/Rack-Bbo4JfEX.js +0 -151
  42. package/public/assets/Toggle-BUr71O4J.js +0 -39
  43. package/public/assets/TokenBreakdown-C1ziK9d1.js +0 -31
  44. package/public/assets/_app-ByQ1bPbe.js +0 -1
  45. package/public/assets/_app.accounts-BTug_Xfo.js +0 -64
  46. package/public/assets/_app.index-CSw9gmMf.js +0 -62
  47. package/public/assets/_app.keys-07Kbw4RS.js +0 -39
  48. package/public/assets/_app.logs-C9QiV39p.js +0 -32
  49. package/public/assets/_app.settings-DmUEeTaP.js +0 -38
  50. package/public/assets/_app.usage-B1WuMGRr.js +0 -83
  51. package/public/assets/dist-Bka7ErcH.js +0 -1
  52. package/public/assets/index-DJfb1i4P.js +0 -186
  53. package/public/assets/login-DKZYqRh0.js +0 -33
  54. package/public/assets/queries-D8LJNQpL.js +0 -144
@@ -1,62 +0,0 @@
1
- import{B as e,H as t,I as n,L as r,M as i,N as a,P as o,Pt as s,R as c,T as l,Y as u,b as d,d as f,f as p,k as m,q as h,y as g,z as _}from"./queries-D8LJNQpL.js";import{a as ee,r as v,t as y}from"./Rack-Bbo4JfEX.js";import{n as b,t as x}from"./TokenBreakdown-C1ziK9d1.js";import{C as S,E as C,T as w,_ as te,a as T,b as E,d as D,f as O,g as k,l as A,m as j,n as M,o as N,r as ne,s as P,t as F,w as I,y as L}from"./Lamp-B65uWKbW.js";import{n as R,t as z}from"./Chip-DJwp7gBu.js";import{t as B}from"./Meter-BREBUFGX.js";import{a as V,n as H,t as U}from"./States-BEKLros0.js";import{i as W,n as G,r as K,t as q}from"./Table-BBypbVWj.js";import{t as J}from"./Readout-CEAoN5hu.js";var Y=s(),X=h(e)`
2
- font-weight: 500;
3
- display: block;
4
- max-width: 24ch;
5
- `,Z=h.span`
6
- font-size: 11px;
7
- color: ${({theme:e})=>e.color.inkDim};
8
- `,re=h.div`
9
- display: grid;
10
- grid-template-columns: 72px 1fr;
11
- align-items: center;
12
- gap: 6px;
13
- min-width: 172px;
14
- `,ie=h.div`
15
- display: flex;
16
- flex-direction: column;
17
- gap: 4px;
18
- `;function ae(e){let t=null;for(let n of e)n.stale||n.survives!==!1||n.exhaustsAt===null||(t===null||n.exhaustsAt<t)&&(t=n.exhaustsAt);return t}function oe(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function se({credentials:e,health:i,quota:o,burn:s,usage:c,quotaPollIntervalMs:l,now:d}){let f=P(i,e=>e.credentialId),p=P(o,e=>e.credentialId),m=P(s,e=>e.credentialId),h=new Map(c.map(e=>[e.key,e])),g={down:0,warn:1,ok:2,idle:3,live:3},_=e.map(e=>{let t=m.get(e.id)??[];return{credential:e,status:N(f.get(e.id)??[],d,e.enabled,e.disabledReason),quota:k(p.get(e.id)??[]),burn:t,exhaustsAt:ae(t),usage:h.get(e.id)}}).sort((e,t)=>g[e.status.state]-g[t.status.state]||oe(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return(0,Y.jsx)(V,{legend:`Accounts`,meta:`${e.length} connected`,flush:!0,actions:(0,Y.jsx)(t,{as:u,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:e.length===0?(0,Y.jsx)(U,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:(0,Y.jsx)(t,{as:u,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):(0,Y.jsx)(r,{children:(0,Y.jsxs)(q,{children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(K,{children:`Account`}),(0,Y.jsx)(K,{children:`Provider`}),(0,Y.jsx)(K,{$align:`right`,children:`Tier`}),(0,Y.jsx)(K,{children:`Quota`}),(0,Y.jsx)(K,{$align:`right`,children:`TTFT`}),(0,Y.jsx)(K,{$align:`right`,children:`Requests`}),(0,Y.jsx)(K,{$align:`right`,children:`Last used`})]})}),(0,Y.jsx)(`tbody`,{children:_.map(({credential:e,status:t,quota:r,burn:i,usage:o})=>(0,Y.jsxs)(W,{children:[(0,Y.jsx)(G,{children:(0,Y.jsxs)(n,{$gap:2,children:[(0,Y.jsx)(F,{state:t.state,label:t.note===``?`healthy`:t.note}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(X,{children:e.label}),t.note===``?null:(0,Y.jsx)(Z,{children:t.note})]})]})}),(0,Y.jsx)(G,{children:(0,Y.jsx)(R,{provider:e.provider})}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:e.tier}),(0,Y.jsx)(G,{children:r.length===0?(0,Y.jsx)(Z,{children:`unknown`}):(0,Y.jsx)(ie,{children:r.map(({window:e,fraction:t})=>(0,Y.jsxs)(re,{children:[(0,Y.jsx)(B,{fraction:t,label:`${M[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,Y.jsx)(a,{children:j(e,d,l,w,T(i,e.windowType))})]},e.windowType))})}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:S(t.ttftMs)}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:o===void 0?`—`:E(o.requests)}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:w(t.lastUsedAt,d)})]},e.id))})]})})})}var ce=h.ul`
19
- display: flex;
20
- flex-direction: column;
21
- `,le=h.li`
22
- display: flex;
23
- align-items: center;
24
- gap: ${({theme:e})=>e.space(2)};
25
- padding: 6px ${({theme:e})=>e.space(3)};
26
- border-bottom: 1px solid ${({theme:e})=>e.color.rule};
27
-
28
- &:last-child {
29
- border-bottom: 0;
30
- }
31
- `,ue=h(e)`
32
- font-family: ${({theme:e})=>e.font.mono};
33
- font-size: 12px;
34
- max-width: 30ch;
35
- `,de=h(o)`
36
- color: ${({theme:e})=>e.color.down};
37
- font-size: 11px;
38
- `;function fe({logs:e}){let n=e.slice(0,12);return(0,Y.jsx)(V,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:(0,Y.jsx)(t,{as:u,to:`/logs`,$size:`sm`,children:`Open logs`}),children:n.length===0?(0,Y.jsx)(U,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):(0,Y.jsx)(ce,{children:n.map(e=>(0,Y.jsxs)(le,{children:[(0,Y.jsx)(F,{state:O(e),label:D(e)}),(0,Y.jsx)(o,{$dim:!0,children:L(e.at)}),(0,Y.jsx)(ue,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:(0,Y.jsx)(o,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),(0,Y.jsx)(c,{}),A(e)?(0,Y.jsx)(o,{$dim:!0,"aria-label":`processing`,children:(0,Y.jsx)(x,{})}):(0,Y.jsxs)(Y.Fragment,{children:[e.errorCode===null?null:(0,Y.jsx)(de,{children:e.errorCode}),e.attempts>1?(0,Y.jsxs)(o,{$dim:!0,children:[e.attempts,`×`]}):null,(0,Y.jsx)(o,{$dim:!0,children:(0,Y.jsx)(b,{tokens:e})}),(0,Y.jsx)(o,{$dim:!0,children:S(e.durationMs)}),(0,Y.jsx)(o,{$dim:!0,children:C(e.costUsd)})]})]},e.id))})})}var pe=h.ul`
39
- display: flex;
40
- flex-direction: column;
41
- gap: ${({theme:e})=>e.space(3)};
42
- `,me=h(e)`
43
- font-family: ${({theme:e})=>e.font.mono};
44
- font-size: 12.5px;
45
- `,Q=h.div`
46
- display: flex;
47
- height: 5px;
48
- border-radius: 2px;
49
- overflow: hidden;
50
- background: ${({theme:e})=>e.color.panelSunk};
51
- border: 1px solid ${({theme:e})=>e.color.rule};
52
- `,he=h.div`
53
- flex: ${({$grow:e})=>e} 0 0;
54
- background: ${({$color:e})=>e};
55
- opacity: 0.8;
56
- `,ge=h.div`
57
- flex: ${({$grow:e})=>e} 0 0;
58
- `;function _e({models:e,logs:r}){let i=new Map;for(let e of r){let t=i.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,i.set(e.requestedModel,t)}let s=Math.max(1,...[...i.values()].map(e=>e.requests)),l=[...e].map(e=>({model:e,used:i.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return(0,Y.jsx)(V,{legend:`Models`,meta:`${e.length} configured`,actions:(0,Y.jsx)(t,{as:u,to:`/models`,$size:`sm`,children:`Edit routing`}),children:e.length===0?(0,Y.jsx)(U,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:(0,Y.jsx)(t,{as:u,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):(0,Y.jsx)(pe,{children:l.map(({model:e,used:t})=>{let r=(t?.requests??0)/s,i=[...new Set(e.targets.map(e=>e.provider))];return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(n,{$gap:2,children:[(0,Y.jsx)(me,{title:e.id,children:e.id}),e.isAlias?(0,Y.jsx)(z,{children:`alias`}):null,(0,Y.jsx)(z,{$tone:`accent`,children:e.strategy}),(0,Y.jsx)(c,{}),(0,Y.jsx)(o,{$dim:!0,children:E(t?.requests??0)}),(0,Y.jsx)(a,{children:`req`}),(0,Y.jsx)(o,{$dim:!0,children:C(t?.costUsd??0)})]}),(0,Y.jsxs)(Q,{style:{marginTop:6},title:`${Math.round(r*100)}% of the busiest model`,children:[i.map(e=>(0,Y.jsx)(he,{$color:`var(--p-${e})`,$grow:r/i.length},e)),(0,Y.jsx)(ge,{$grow:Math.max(0,1-r)})]})]},e.id)})})})}var ve=h.div`
59
- display: grid;
60
- grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
61
- gap: ${({theme:e})=>e.space(3)};
62
- `;function ye({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=te(r,t),a=ne(r,{now:n,spanMs:t,count:32}),o=i.errorRate>=.25?`down`:i.errorRate>=.05?`warn`:`ok`,s=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens;return(0,Y.jsxs)(ve,{children:[(0,Y.jsx)(J,{legend:`Requests`,value:E(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:(0,Y.jsx)(v,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),(0,Y.jsx)(J,{legend:`Error rate`,value:I(i.errorRate),unit:`${E(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:(0,Y.jsx)(v,{values:a.map(e=>e.errors),scaleTo:Math.max(...a.map(e=>e.total)),color:`var(--down)`,label:`${i.errors} failed requests against ${i.requests} total`})}),(0,Y.jsx)(J,{legend:`Total tokens`,value:E(s),unit:(0,Y.jsx)(b,{tokens:i}),trace:(0,Y.jsx)(v,{values:a.map(e=>e.tokens),label:`token volume over the window, ${s.toLocaleString(`en-US`)} total`})}),(0,Y.jsx)(J,{legend:`Time to first token`,value:S(i.ttftP50),unit:`p95 ${S(i.ttftP95)}`,trace:(0,Y.jsx)(v,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${S(i.ttftP50)}`})}),(0,Y.jsx)(J,{legend:`Spend`,value:C(i.costUsd),unit:`${E(i.inputTokens+i.outputTokens)} tokens`,trace:(0,Y.jsx)(v,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${C(i.costUsd)} total`})})]})}var $=36e5;function be(){let{cadence:e}=ee(),t=p(),n=f(e(1e4)),r=d(),a=g(500,e(1e4)),o=l(),s=Date.now(),c=Math.floor((s-$)/6e4)*6e4,u=m({groupBy:`credential`,since:c},e(6e4)),h=t.data??[],v=P(n.data?.health??[],e=>e.credentialId),b=h.filter(e=>N(v.get(e.id)??[],s,e.enabled,e.disabledReason).state===`down`),x=t.isLoading||a.isLoading?`Reading the gateway…`:h.length===0?`No accounts are connected, so every request fails at the router.`:b.length>0?`${b.length} account${b.length===1?` is`:`s are`} out of rotation.`:`All ${h.length} accounts are answering. Nothing needs attention.`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(y,{legend:`Rack`,title:`Gateway`,summary:x}),a.isError?(0,Y.jsx)(V,{legend:`Traffic`,children:(0,Y.jsx)(H,{legend:`The gateway did not answer`,error:a.error,onRetry:()=>void a.refetch()})}):(0,Y.jsxs)(_,{$gap:4,children:[(0,Y.jsx)(ye,{logs:a.data??[],windowMs:$,now:s}),(0,Y.jsx)(se,{credentials:h,health:n.data?.health??[],quota:n.data?.quota??[],burn:n.data?.burn??[],usage:u.data??[],quotaPollIntervalMs:o.data?.quotaPollIntervalMs??3e5,now:s}),(0,Y.jsxs)(i,{$min:`340px`,$gap:4,children:[(0,Y.jsx)(_e,{models:r.data??[],logs:a.data??[]}),(0,Y.jsx)(fe,{logs:a.data??[]})]})]})]})}var xe=be;export{xe as component};
@@ -1,39 +0,0 @@
1
- import{$t as e,B as t,Ft as n,H as r,I as i,L as a,N as o,P as s,Pt as c,S as l,b as u,g as d,q as f,u as p,z as m}from"./queries-D8LJNQpL.js";import{t as h}from"./Rack-Bbo4JfEX.js";import{t as g}from"./CopyValue-CNZbWS59.js";import{n as _,t as v}from"./Confirm-CVLz9F7a.js";import{t as y}from"./Modal-DbydSAlp.js";import{t as b}from"./Toggle-BUr71O4J.js";import{x}from"./Lamp-B65uWKbW.js";import{t as S}from"./Chip-DJwp7gBu.js";import{n as C,t as w}from"./Field-BDtp692L.js";import{a as T,i as E,n as D,r as O,t as k}from"./States-BEKLros0.js";import{i as A,n as j,r as M,t as N}from"./Table-BBypbVWj.js";var P=e(n(),1),F=c(),I=f.div`
2
- display: flex;
3
- flex-direction: column;
4
- gap: 2px;
5
- max-height: 190px;
6
- overflow-y: auto;
7
- padding: ${({theme:e})=>e.space(1)};
8
- border: 1px solid ${({theme:e})=>e.color.ruleStrong};
9
- border-radius: ${({theme:e})=>e.radius.control};
10
- background: ${({theme:e})=>e.color.panelSunk};
11
- `,L=f.label`
12
- display: flex;
13
- align-items: center;
14
- gap: ${({theme:e})=>e.space(2)};
15
- padding: 4px 6px;
16
- border-radius: 2px;
17
- cursor: pointer;
18
- font-family: ${({theme:e})=>e.font.mono};
19
- font-size: 12px;
20
-
21
- &:hover {
22
- background: ${({theme:e})=>e.color.panelRaised};
23
- }
24
- `,R=f.p`
25
- font-size: 12px;
26
- color: ${({theme:e})=>e.color.warn};
27
- `,z=f.p`
28
- font-size: 12px;
29
- color: ${({theme:e})=>e.color.down};
30
- `,B=f.p`
31
- font-size: 12px;
32
- color: ${({theme:e})=>e.color.inkDim};
33
- `;function V({open:e,onOpenChange:t}){let n=u(),a=p(),[c,l]=(0,P.useState)(``),[d,f]=(0,P.useState)(!0),[h,_]=(0,P.useState)([]),[v,x]=(0,P.useState)(``),[S,T]=(0,P.useState)(null),[D,O]=(0,P.useState)(null),k=()=>{l(``),f(!0),_([]),x(``),T(null),O(null),a.reset()},A=e=>{e||k(),t(e)};return(0,F.jsx)(y,{open:e,onOpenChange:A,title:S===null?`Create an API key`:`Key created`,description:S===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:S===null?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(r,{type:`button`,onClick:()=>A(!1),children:`Cancel`}),(0,F.jsx)(r,{type:`button`,$variant:`primary`,disabled:a.isPending,onClick:()=>{let e=v.trim(),t=e.length===0?null:Number(e);if(t!==null&&(!Number.isInteger(t)||t<1)){O(`The rate limit must be a whole number of requests per minute, or blank for none.`);return}O(null),a.mutate({label:c.trim().length===0?`api key`:c.trim(),modelAllowlist:d?null:h,rateLimitPerMin:t},{onSuccess:e=>T(e),onError:e=>O(E(e))})},children:a.isPending?`Creating…`:`Create key`})]}):(0,F.jsx)(r,{type:`button`,$variant:`primary`,onClick:()=>A(!1),children:`I have copied the key`}),children:S===null?(0,F.jsxs)(m,{$gap:3,children:[(0,F.jsx)(w,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>(0,F.jsx)(C,{...e,value:c,placeholder:`api key`,onChange:e=>l(e.target.value)})}),(0,F.jsxs)(m,{$gap:2,children:[(0,F.jsxs)(i,{$gap:2,children:[(0,F.jsx)(b,{checked:d,label:`Allow every model`,onCheckedChange:f}),(0,F.jsx)(o,{as:`span`,children:`Allow every model`})]}),d?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{children:(n.data??[]).map(e=>(0,F.jsxs)(L,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:h.includes(e.id),onChange:t=>_(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),e.id]},e.id))}),h.length===0?(0,F.jsx)(R,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),(0,F.jsx)(w,{label:`Rate limit`,hint:`Requests per minute for this key. Leave blank for no limit. Counted per process, and reset when the gateway restarts.`,children:e=>(0,F.jsx)(C,{...e,type:`number`,min:1,step:1,value:v,placeholder:`no limit`,onChange:e=>x(e.target.value)})}),D===null?null:(0,F.jsx)(z,{role:`alert`,children:D})]}):(0,F.jsxs)(m,{$gap:3,children:[(0,F.jsx)(B,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),(0,F.jsx)(g,{value:S.key,label:`Copy API key`}),(0,F.jsxs)(i,{$gap:2,children:[(0,F.jsx)(o,{children:`Label`}),(0,F.jsx)(s,{children:S.label}),(0,F.jsx)(o,{children:`Prefix`}),(0,F.jsx)(s,{children:S.prefix})]})]})})}var H=f(i)`
34
- gap: 4px;
35
- flex-wrap: wrap;
36
- max-width: 34ch;
37
- `,U=f.span`
38
- color: ${({theme:e})=>e.color.inkFaint};
39
- `;function W(){let e=d(),n=l(),[i,s]=(0,P.useState)(!1),[c,u]=(0,P.useState)(null),f=e.data??[],p=f.filter(e=>e.revokedAt===null),m=e.isLoading?`Reading issued keys…`:f.length===0?`No keys exist, so nothing can call this gateway yet.`:`${p.length} active key${p.length===1?``:`s`} of ${f.length} ever issued.`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{legend:`Keys`,title:`Gateway API keys`,summary:m,actions:(0,F.jsxs)(r,{type:`button`,$variant:`primary`,onClick:()=>s(!0),children:[(0,F.jsx)(_,{}),`Create a key`]})}),(0,F.jsx)(T,{legend:`Issued keys`,meta:`${f.length}`,flush:!0,children:e.isError?(0,F.jsx)(D,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?(0,F.jsx)(`div`,{style:{padding:12},children:(0,F.jsx)(O,{rows:4})}):f.length===0?(0,F.jsx)(k,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:(0,F.jsx)(r,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>s(!0),children:`Create a key`})}):(0,F.jsx)(a,{children:(0,F.jsxs)(N,{children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(M,{children:`Label`}),(0,F.jsx)(M,{children:`Prefix`}),(0,F.jsx)(M,{children:`Allowed models`}),(0,F.jsx)(M,{$align:`right`,children:`Rate limit`}),(0,F.jsx)(M,{$align:`right`,children:`Created`}),(0,F.jsx)(M,{children:`Status`}),(0,F.jsx)(M,{})]})}),(0,F.jsx)(`tbody`,{children:f.map(e=>(0,F.jsxs)(A,{children:[(0,F.jsx)(j,{children:(0,F.jsx)(t,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),(0,F.jsxs)(j,{$mono:!0,children:[e.prefix,`…`]}),(0,F.jsx)(j,{children:e.modelAllowlist===null?(0,F.jsx)(o,{children:`every model`}):e.modelAllowlist.length===0?(0,F.jsx)(S,{$tone:`down`,children:`no models`}):(0,F.jsx)(H,{children:e.modelAllowlist.map(e=>(0,F.jsx)(S,{children:e},e))})}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:e.rateLimitPerMin===null?`—`:`${e.rateLimitPerMin}/min`}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:x(e.createdAt)}),(0,F.jsx)(j,{children:e.revokedAt===null?(0,F.jsx)(S,{$tone:`ok`,children:`active`}):(0,F.jsx)(U,{title:x(e.revokedAt),children:(0,F.jsx)(S,{children:`revoked`})})}),(0,F.jsx)(j,{$align:`right`,children:e.revokedAt===null?(0,F.jsx)(r,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>u(e),children:`Revoke`}):null})]},e.id))})]})})}),(0,F.jsx)(V,{open:i,onOpenChange:s}),(0,F.jsx)(v,{open:c!==null,onOpenChange:e=>{e||u(null)},title:`Revoke key`,body:c===null?``:`Revoking "${c.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:n.isPending,onConfirm:()=>{c!==null&&n.mutate(c.id,{onSettled:()=>u(null)})}})]})}var G=W;export{G as component};
@@ -1,32 +0,0 @@
1
- import{$t as e,B as t,Ft as n,H as ee,I as r,L as i,N as a,P as te,Pt as o,f as ne,g as re,n as ie,q as s,y as c,z as l}from"./queries-D8LJNQpL.js";import{a as u,t as d}from"./Rack-Bbo4JfEX.js";import{n as f,r as p,t as m}from"./TokenBreakdown-C1ziK9d1.js";import{t as h}from"./Modal-DbydSAlp.js";import{C as g,D as _,E as v,S as ae,b as y,c as b,d as oe,f as x,l as S,t as C,x as w,y as T}from"./Lamp-B65uWKbW.js";import{n as se,t as E}from"./Chip-DJwp7gBu.js";import{i as D,n as O}from"./Field-BDtp692L.js";import{a as k,n as A,r as j,t as M}from"./States-BEKLros0.js";import{i as N,n as P,r as F,t as I}from"./Table-BBypbVWj.js";var L=e(n(),1),R=o(),z=[50,100,250,500],B=s(r)`
2
- gap: ${({theme:e})=>e.space(2)};
3
- flex-wrap: wrap;
4
- `,V=s(O)`
5
- width: 220px;
6
- `,H=s(D)`
7
- width: auto;
8
- `,U=s(k)`
9
- flex: 1;
10
- min-height: 0;
11
-
12
- > div {
13
- display: flex;
14
- flex: 1;
15
- flex-direction: column;
16
- min-height: 0;
17
- }
18
- `,W=s(i)`
19
- flex: 1;
20
- min-height: 0;
21
- overflow-y: auto;
22
- `;function G(e){let[t,n]=(0,L.useState)(Date.now);return(0,L.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function ce({log:e}){return(0,R.jsx)(P,{$align:`right`,$mono:!0,...S(e)?{"aria-label":`processing`}:{title:p(e)},children:S(e)?(0,R.jsx)(m,{}):(0,R.jsx)(f,{tokens:e})})}var le=s.dl`
23
- display: grid;
24
- grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
25
- gap: 6px ${({theme:e})=>e.space(3)};
26
- margin: 0;
27
- font-size: 12.5px;
28
- `,K=s.dd`
29
- margin: 0;
30
- font-family: ${({theme:e})=>e.font.mono};
31
- word-break: break-all;
32
- `;function q(){let{cadence:e,live:n}=u(),[i,o]=(0,L.useState)(100),[s,f]=(0,L.useState)(`all`),[p,m]=(0,L.useState)(``),[D,O]=(0,L.useState)(null),k=c(i,e(ie)),q=ne(),J=re(),ue=(k.data??[]).some(S),de=G(n&&ue),Y=(0,L.useMemo)(()=>{let e=new Map;for(let t of q.data??[])e.set(t.id,t.label);return e},[q.data]),X=(0,L.useMemo)(()=>{let e=new Map;for(let t of J.data??[])e.set(t.id,t.label);return e},[J.data]),Z=p.trim().toLowerCase(),Q=(k.data??[]).filter(e=>s===`failed`&&!b(e)?!1:Z.length===0||e.requestedModel.toLowerCase().includes(Z)||(e.resolvedModel??``).toLowerCase().includes(Z)||(e.errorCode??``).toLowerCase().includes(Z)||(e.credentialId===null?``:Y.get(e.credentialId)??``).toLowerCase().includes(Z)||(e.apiKeyId===null?``:X.get(e.apiKeyId)??e.apiKeyId).toLowerCase().includes(Z)),fe=(k.data??[]).filter(b).length,$=(k.data??[]).filter(S).length;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(d,{legend:`Logs`,title:`Recent requests`,summary:k.isLoading?`Reading the request log…`:`${y(k.data?.length??0)} recent requests, ${y(fe)} of them failed${$===0?``:`, ${y($)} still running`}. Prompt and response bodies are never recorded.`,actions:(0,R.jsxs)(B,{children:[(0,R.jsx)(V,{value:p,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>m(e.target.value)}),(0,R.jsxs)(H,{value:s,"aria-label":`Show which requests`,onChange:e=>f(e.target.value),children:[(0,R.jsx)(`option`,{value:`all`,children:`All requests`}),(0,R.jsx)(`option`,{value:`failed`,children:`Failed only`})]}),(0,R.jsx)(H,{value:i,"aria-label":`How many requests to fetch`,onChange:e=>o(Number(e.target.value)),children:z.map(e=>(0,R.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,R.jsx)(U,{legend:`Request log`,meta:`${Q.length} shown`,flush:!0,children:k.isError?(0,R.jsx)(A,{error:k.error,onRetry:()=>void k.refetch()}):k.isLoading?(0,R.jsx)(`div`,{style:{padding:12},children:(0,R.jsx)(j,{rows:8})}):Q.length===0?(0,R.jsx)(M,{legend:`Nothing to show`,message:(k.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):(0,R.jsx)(W,{"data-testid":`request-log-scroller`,children:(0,R.jsxs)(I,{children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(F,{}),(0,R.jsx)(F,{$align:`right`,children:`Time`}),(0,R.jsx)(F,{children:`Requested`}),(0,R.jsx)(F,{children:`Routed to`}),(0,R.jsx)(F,{children:`Account`}),(0,R.jsx)(F,{children:`Key`}),(0,R.jsx)(F,{$align:`right`,children:`Try`}),(0,R.jsx)(F,{$align:`right`,children:`TTFT`}),(0,R.jsx)(F,{$align:`right`,children:`Total`}),(0,R.jsx)(F,{$align:`right`,children:`Tokens`}),(0,R.jsx)(F,{$align:`right`,children:`Cost`}),(0,R.jsx)(F,{children:`Outcome`})]})}),(0,R.jsx)(`tbody`,{children:Q.map(e=>(0,R.jsxs)(N,{$selectable:!0,onClick:()=>O(e),children:[(0,R.jsx)(P,{children:(0,R.jsx)(C,{state:x(e),label:oe(e)})}),(0,R.jsx)(P,{$align:`right`,$mono:!0,title:w(e.at),children:T(e.at)}),(0,R.jsx)(P,{$mono:!0,children:(0,R.jsx)(t,{style:{display:`block`,maxWidth:`20ch`},children:e.requestedModel||`—`})}),(0,R.jsx)(P,{children:e.resolvedProvider===null?(0,R.jsx)(a,{children:S(e)?`routing…`:`not routed`}):(0,R.jsxs)(r,{$gap:1,children:[(0,R.jsx)(se,{provider:e.resolvedProvider}),(0,R.jsx)(te,{$dim:!0,children:e.resolvedModel??`—`})]})}),(0,R.jsx)(P,{children:(0,R.jsx)(t,{style:{display:`block`,maxWidth:`18ch`},children:e.credentialId===null?`—`:Y.get(e.credentialId)??_(e.credentialId)})}),(0,R.jsx)(P,{children:(0,R.jsx)(t,{style:{display:`block`,maxWidth:`16ch`},title:e.apiKeyId??void 0,children:e.apiKeyId===null?`—`:X.get(e.apiKeyId)??_(e.apiKeyId)})}),(0,R.jsx)(P,{$align:`right`,$mono:!0,children:S(e)?`—`:e.attempts}),(0,R.jsx)(P,{$align:`right`,$mono:!0,children:S(e)?`—`:g(e.ttftMs)}),(0,R.jsx)(P,{$align:`right`,$mono:!0,children:S(e)?ae(Math.max(0,de-e.at)):g(e.durationMs)}),(0,R.jsx)(ce,{log:e}),(0,R.jsx)(P,{$align:`right`,$mono:!0,children:S(e)?`—`:v(e.costUsd)}),(0,R.jsx)(P,{children:S(e)?(0,R.jsx)(E,{$tone:`accent`,children:`live`}):e.errorCode===null?(0,R.jsx)(E,{$tone:`ok`,children:e.status}):(0,R.jsx)(E,{$tone:`down`,children:e.errorCode})})]},e.id))})]})})}),(0,R.jsx)(h,{open:D!==null,onOpenChange:e=>{e||O(null)},title:`Request detail`,width:`600px`,footer:(0,R.jsx)(ee,{type:`button`,onClick:()=>O(null),children:`Close`}),children:D===null?null:(0,R.jsxs)(l,{$gap:3,children:[(0,R.jsxs)(le,{children:[(0,R.jsx)(a,{as:`dt`,children:`Request id`}),(0,R.jsx)(K,{children:D.id}),(0,R.jsx)(a,{as:`dt`,children:`At`}),(0,R.jsx)(K,{children:w(D.at)}),(0,R.jsx)(a,{as:`dt`,children:`Requested model`}),(0,R.jsx)(K,{children:D.requestedModel||`—`}),(0,R.jsx)(a,{as:`dt`,children:`Routed to`}),(0,R.jsx)(K,{children:S(D)?`—`:D.resolvedProvider===null?`not routed`:`${D.resolvedProvider} · ${D.resolvedModel??`—`}`}),(0,R.jsx)(a,{as:`dt`,children:`Account`}),(0,R.jsx)(K,{children:D.credentialId===null?`—`:Y.get(D.credentialId)??D.credentialId}),(0,R.jsx)(a,{as:`dt`,children:`Key`}),(0,R.jsx)(K,{children:D.apiKeyId===null?`—`:X.get(D.apiKeyId)??D.apiKeyId}),(0,R.jsx)(a,{as:`dt`,children:`Attempts`}),(0,R.jsx)(K,{children:S(D)?`—`:D.attempts}),(0,R.jsx)(a,{as:`dt`,children:`Status`}),(0,R.jsx)(K,{children:S(D)?`in flight`:D.errorCode===null?D.status:`${D.status} ${D.errorCode}`}),(0,R.jsx)(a,{as:`dt`,children:`Timing`}),(0,R.jsx)(K,{children:S(D)?`—`:`first token ${g(D.ttftMs)} · total ${g(D.durationMs)}`}),(0,R.jsx)(a,{as:`dt`,children:`Tokens`}),(0,R.jsx)(K,{children:S(D)?`—`:(0,R.jsxs)(R.Fragment,{children:[y(D.inputTokens),` in · `,y(D.outputTokens),` out ·`,` `,y(D.cacheReadTokens),` cache read ·`,` `,y(D.cacheWriteTokens),` cache write`]})}),(0,R.jsx)(a,{as:`dt`,children:`Cost`}),(0,R.jsx)(K,{children:S(D)?`—`:v(D.costUsd)}),(0,R.jsx)(a,{as:`dt`,children:`RTK compression`}),(0,R.jsx)(K,{children:S(D)?`—`:D.rtkApplied?`${y(D.rtkFilterHits)} hits · ${y(D.rtkOriginalCodeUnits)} → ${y(D.rtkCompressedCodeUnits)} code units · ~${y(D.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),(0,R.jsx)(a,{as:`dt`,children:`RTK filters`}),(0,R.jsx)(K,{children:D.rtkFilters.length===0?`—`:D.rtkFilters.join(`, `)})]}),D.degradations.length===0?null:(0,R.jsxs)(l,{$gap:1,children:[(0,R.jsx)(a,{children:`Capabilities dropped to fit the target`}),(0,R.jsx)(r,{$gap:1,$wrap:!0,children:D.degradations.map(e=>(0,R.jsx)(E,{$tone:`warn`,children:e},e))})]})]})})]})}var J=q;export{J as component};
@@ -1,38 +0,0 @@
1
- import{$t as e,Ft as t,H as n,I as r,N as i,P as a,Pt as o,R as s,T as c,a as l,b as u,q as d,w as f,z as p}from"./queries-D8LJNQpL.js";import{t as m}from"./Rack-Bbo4JfEX.js";import{t as h}from"./Toggle-BUr71O4J.js";import{i as g,n as _,t as v}from"./Field-BDtp692L.js";import{t as y}from"./Meter-BREBUFGX.js";import{a as b,i as x,n as S,r as C}from"./States-BEKLros0.js";var w=e(t(),1),T=o(),E=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],D=d(a)`
2
- display: block;
3
- white-space: pre;
4
- overflow-x: auto;
5
- padding: 0.75rem;
6
- background: ${({theme:e})=>e.color.panelSunk};
7
- border: 1px solid ${({theme:e})=>e.color.rule};
8
- border-radius: 4px;
9
- font-size: 0.8125rem;
10
- line-height: 1.5;
11
- `,O=d.div`
12
- color: ${({theme:e})=>e.color.inkDim};
13
- font-size: 0.8125rem;
14
- margin-bottom: 0.25rem;
15
- `,k=d.p`
16
- color: ${({theme:e})=>e.color.inkDim};
17
- font-size: 0.8125rem;
18
- margin: 0;
19
- `,A=d.div`
20
- display: grid;
21
- grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
22
- gap: ${({theme:e})=>e.space(2)};
23
- `,j=[{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 M(){let[e,t]=(0,w.useState)(`claude`),[i,o]=(0,w.useState)(()=>({claude:{},opencode:{}})),s=u(),c=i[e],d=typeof c.defaultModel==`string`&&c.defaultModel!==``?c:void 0,f=l(e,d),m=E.find(t=>t.id===e);return(0,T.jsx)(b,{legend:`Agent setup`,children:(0,T.jsxs)(p,{children:[(0,T.jsx)(r,{children:E.map(r=>(0,T.jsx)(n,{type:`button`,$variant:r.id===e?`primary`:`ghost`,onClick:()=>t(r.id),children:r.label},r.id))}),(0,T.jsxs)(k,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,(0,T.jsxs)(a,{children:[`omni setup `,e]}),` to write these files directly.`]}),(s.data?.length??0)>0?(0,T.jsx)(A,{children:j.map(t=>(0,T.jsx)(v,{label:t.label,children:n=>(0,T.jsxs)(g,{...n,value:c[t.key]??``,onChange:n=>o(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[(0,T.jsx)(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),s.data?.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,s.isLoading?(0,T.jsx)(C,{rows:2}):f.isError?(0,T.jsx)(S,{error:f.error,onRetry:()=>void f.refetch()}):f.isLoading?(0,T.jsx)(C,{rows:4}):(s.data?.length??0)===0?(0,T.jsx)(k,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d===void 0?(0,T.jsxs)(k,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):f.data===void 0||f.data.length===0?(0,T.jsx)(k,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):f.data.map(e=>(0,T.jsxs)(`div`,{children:[(0,T.jsx)(O,{children:e.path}),(0,T.jsx)(D,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),f.isError?(0,T.jsx)(k,{children:x(f.error)}):null]})})}var N=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Preference for accounts with fewer requests in flight right now.`}],P=[{id:`maxAttempts`,label:`Attempts per request`,hint:`How many candidates dispatch may try before giving up. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`How long a request may take across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures on one account and model before it is taken out of rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Base wait before a tripped account is probed again. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before maintenance prunes them.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often each account's provider is asked for its remaining quota. 0 disables polling. Takes effect on restart.`,unit:`ms`,step:6e4,min:0}],F=d.div`
24
- display: grid;
25
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
26
- gap: ${({theme:e})=>e.space(3)};
27
- `,I=d(p)`
28
- gap: 6px;
29
- `,L=d.p`
30
- font-size: 11px;
31
- color: ${({theme:e})=>e.color.inkDim};
32
- `,R=d.p`
33
- font-size: 12px;
34
- color: ${({theme:e})=>e.color.down};
35
- `,z=d.p`
36
- font-size: 12px;
37
- color: ${({theme:e})=>e.color.ok};
38
- `;function B(e){let t={};for(let n of N)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of P)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t}function V(e){let t={};for(let n of N){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of P){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`}}}function H(){let e=c(),t=f(),[o,l]=(0,w.useState)({}),[u,d]=(0,w.useState)(null),[g,E]=(0,w.useState)(!1);(0,w.useEffect)(()=>{e.data!==void 0&&l(B(e.data))},[e.data]);let D=Math.max(1e-4,...N.map(e=>Math.abs(Number(o[`w.${e.id}`])||0)));return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(m,{legend:`Settings`,title:`Routing and retention`,summary:`These apply to every request the gateway routes. Changes take effect on the next request; nothing is restarted.`,actions:(0,T.jsx)(n,{type:`button`,$variant:`primary`,disabled:t.isPending||e.isLoading,onClick:()=>{E(!1);let e=V(o);if(!e.ok){d(e.problem);return}d(null),t.mutate(e.settings,{onSuccess:()=>E(!0),onError:e=>d(x(e))})},children:t.isPending?`Saving…`:`Save changes`})}),e.isError?(0,T.jsx)(b,{legend:`Settings`,children:(0,T.jsx)(S,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?(0,T.jsx)(b,{legend:`Settings`,children:(0,T.jsx)(C,{rows:6})}):(0,T.jsxs)(p,{$gap:4,children:[(0,T.jsx)(b,{legend:`Scoring weights`,meta:`relative to each other`,footer:(0,T.jsxs)(r,{children:[(0,T.jsx)(i,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),(0,T.jsx)(s,{})]}),children:(0,T.jsx)(F,{children:N.map(e=>{let t=Number(o[`w.${e.id}`])||0;return(0,T.jsxs)(I,{children:[(0,T.jsx)(v,{label:e.label,children:t=>(0,T.jsx)(_,{...t,type:`number`,step:.5,value:o[`w.${e.id}`]??``,onChange:t=>l({...o,[`w.${e.id}`]:t.target.value})})}),(0,T.jsx)(y,{fraction:Math.abs(t)/D,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),(0,T.jsx)(L,{children:e.blurb})]},e.id)})})}),(0,T.jsx)(b,{legend:`Limits`,children:(0,T.jsx)(F,{children:P.map(e=>(0,T.jsx)(I,{children:(0,T.jsx)(v,{label:e.label,hint:e.hint,children:t=>(0,T.jsxs)(r,{$gap:2,children:[(0,T.jsx)(_,{...t,type:`number`,min:e.min,step:e.step,value:o[e.id]??``,onChange:t=>l({...o,[e.id]:t.target.value})}),(0,T.jsx)(i,{children:e.unit})]})})},e.id))})}),(0,T.jsx)(b,{legend:`Historical tool results`,children:(0,T.jsxs)(r,{$gap:3,$align:`start`,children:[(0,T.jsx)(h,{checked:o.rtkEnabled===`true`,onCheckedChange:e=>l({...o,rtkEnabled:String(e)}),label:`Enable RTK compression`}),(0,T.jsx)(L,{children:`Compress recognized historical non-error tool results before provider dispatch. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a built-in detector recognizes a high-confidence shell-output format. Compression is deterministic and lossy. Disabled by default.`})]})}),u===null?null:(0,T.jsx)(R,{role:`alert`,children:u}),g&&u===null?(0,T.jsx)(z,{role:`status`,children:`Settings saved.`}):null,(0,T.jsx)(M,{}),(0,T.jsx)(b,{legend:`Known limits`,children:(0,T.jsxs)(p,{$gap:2,children:[(0,T.jsxs)(r,{$gap:2,children:[(0,T.jsx)(a,{$dim:!0,children:`rate limits`}),(0,T.jsx)(L,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),(0,T.jsxs)(r,{$gap:2,children:[(0,T.jsx)(a,{$dim:!0,children:`logs`}),(0,T.jsx)(L,{children:`Request rows record routing and token counts only. Prompts, responses, and credentials are never written.`})]})]})})]})]})}var U=H;export{U as component};
@@ -1,83 +0,0 @@
1
- import{$t as e,B as t,Ft as n,I as r,L as i,M as a,N as o,P as s,Pt as c,b as l,f as u,g as d,k as f,q as p,z as m}from"./queries-D8LJNQpL.js";import{i as h,n as g,r as _}from"./index-DJfb1i4P.js";import{a as v,r as y,t as b}from"./Rack-Bbo4JfEX.js";import{C as x,E as S,b as C,w}from"./Lamp-B65uWKbW.js";import{a as T,n as E,r as ee,t as D}from"./States-BEKLros0.js";import{i as O,n as k,r as A,t as te}from"./Table-BBypbVWj.js";import{t as ne}from"./catalog-BBKm8Ih8.js";import{$ as re,A as j,At as ie,B as ae,C as oe,Ct as M,D as N,Dt as P,E as se,Et as ce,F as le,G as ue,H as de,I as fe,J as F,K as I,L as pe,M as me,Mt as L,N as he,O as ge,Ot as _e,P as ve,Q as ye,R as be,S as xe,St as Se,T as Ce,Tt as we,U as Te,V as Ee,W as De,X as Oe,Y as ke,Z as Ae,_ as je,_t as Me,a as Ne,at as Pe,b as R,bt as z,c as Fe,ct as Ie,d as B,dt as Le,et as Re,f as V,ft as ze,g as Be,gt as Ve,h as H,ht as He,i as Ue,it as We,j as Ge,jt as Ke,k as qe,kt as Je,l as U,lt as Ye,m as Xe,mt as Ze,n as Qe,nt as $e,o as et,ot as tt,p as nt,pt as rt,q as it,r as at,rt as ot,s as W,st,t as ct,tt as lt,u as ut,ut as dt,v as ft,vt as pt,w as mt,wt as ht,x as G,xt as gt,y as K,yt as _t,z as vt}from"./shared-CIhZ6FCO.js";import{t as q}from"./Readout-CEAoN5hu.js";function yt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function bt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var xt=(e,t,n)=>ye(e,`xAxis`,yt(e,t),n),St=(e,t,n)=>Re(e,`xAxis`,yt(e,t),n),Ct=(e,t,n)=>ye(e,`yAxis`,bt(e,t),n),wt=(e,t,n)=>Re(e,`yAxis`,bt(e,t),n),Tt=z([Ie,xt,Ct,St,wt],(e,t,n,r,i)=>pt(e,`xAxis`)?rt(t,r,!1):rt(n,i,!1)),Et=z([lt,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Dt=e=>{var t=Ie(e);return pt(t,`xAxis`)?`yAxis`:`xAxis`},Ot=(e,t)=>Dt(e)===`yAxis`?bt(e,t):yt(e,t),kt=(e,t,n)=>re(e,Dt(e),Ot(e,t),n),At=z([Et,kt],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=$e(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),jt=z([Et,kt],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(we)}}),Mt=z([Ie,xt,Ct,St,wt,At,Pe,Tt,Et,We,jt],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return dn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),J=e(n()),Nt=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Pt=[`id`,`baseLine`];function Ft(){return Ft=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ft.apply(null,arguments)}function It(e,t){if(e==null)return{};var n,r,i=Lt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Lt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Rt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!_t(a)||!_t(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return P(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),P(c)?J.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function zt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!_t(a)||!_t(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return P(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),P(c)?J.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function Bt(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?J.createElement(zt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):J.createElement(Rt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Vt(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=It(e,Nt),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=fe(),h=d.id,g=d.baseLine,_=It(d,Pt),v=Ke(_),y=J.createElement(tt,Ft({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),b=l!==`none`&&J.createElement(tt,Ft({},v,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),x=l!==`none`&&c&&Array.isArray(g)&&J.createElement(tt,Ft({},v,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?J.createElement(Je,null,J.createElement(`defs`,null,J.createElement(`clipPath`,{id:m},J.createElement(Bt,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),J.createElement(Je,{clipPath:`url(#${m})`},y,b,x)):J.createElement(J.Fragment,null,y,b,x)}var Ht=[`id`],Ut=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Wt(){return Wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wt.apply(null,arguments)}function Gt(e,t){if(e==null)return{};var n,r,i=Kt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Kt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function qt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?qt(Object(n),!0).forEach(function(t){Jt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Jt(e,t,n){return(t=Yt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Yt(e){var t=Xt(e,`string`);return typeof t==`symbol`?t:t+``}function Xt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Zt={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:Ee,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[Y(Y({},e.next),{},{x:M(e.prev.x,e.next.x,t),y:M(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:Vt,xAxisId:0,yAxisId:0,zIndex:ot.area};function Qt(e,t){return e&&e!==`none`?e:t}var $t=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:Qt(r,i),value:Ve(n,t),payload:e}]},en=J.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:_e,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Ve(o,t),hide:s,type:u,color:Qt(r,a),unit:c,formatter:l,graphicalItemId:d}};return J.createElement(Te,{tooltipEntrySettings:f})});function tn(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=Ke(r);return J.createElement(he,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function nn(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Y(Y({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return J.createElement(I,{value:t?r:void 0},n)}function rn(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=Gt(a,Ht),_=Y(Y({},ie(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return J.createElement(J.Fragment,null,t?.length>1&&J.createElement(Je,{clipPath:r?`url(#clipPath-${i})`:void 0},J.createElement(De,{option:m,DefaultShape:Zt.shape,shapeProps:_})),J.createElement(tn,{points:t,props:g,clipPathId:i}))}function an(e,t,n){if(P(e)){var r=P(t)?t:void 0;return M(r,e,n)}if(ce(e)||ht(e)){var i=P(t)?t:void 0;return M(i,0,n)}return e}function on(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,J.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=vt(m,a),g=Ye(),_=be(r.onAnimationStart,r.onAnimationEnd),v=_.isAnimating,y=_.handleAnimationStart,b=_.handleAnimationEnd,x=h.startValue;if(g==null)return null;var S=Array.isArray(s)&&Array.isArray(x)?ae(x,s,f):Array.isArray(s)?ae(null,s,f):null;return J.createElement(pe,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:y,onAnimationEnd:b,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(S,i,g):a?s:an(s,x,i);return h.syncStepValue(c,i),J.createElement(nn,{showLabels:!v,points:o},r.children,J.createElement(rn,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:v||i<1,isEntrance:a}),J.createElement(it,{label:r.label}))})}function sn(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,J.useRef)(null),a=(0,J.useRef)();return J.createElement(on,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var cn=class extends J.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=L(`recharts-area`,i),g=f,_=N(n),v=_.r,y=_.strokeWidth,b=ue(n),x=v*2+y,S=s?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return J.createElement(Oe,{zIndex:m},J.createElement(Je,{className:h},s&&J.createElement(`defs`,null,J.createElement(ge,{clipPathId:g,xAxisId:c,yAxisId:l}),!b&&J.createElement(`clipPath`,{id:`clipPath-dots-${g}`},J.createElement(`rect`,{x:o-x/2,y:a-x/2,width:u+x,height:d+x}))),J.createElement(sn,{needClip:s,clipPathId:g,props:this.props})),J.createElement(Ge,{points:r,mainColor:Qt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(p)&&J.createElement(Ge,{points:p,mainColor:Qt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}};function ln(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=Gt(e,Ut),g=dt(),_=Ae(),v=qe(p,m).needClip,y=ze(),b=gt(t=>Mt(t,e.id,y))??{},x=b.points,S=b.isRange,C=b.baseLine,w=me();if(g!==`horizontal`&&g!==`vertical`||w==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var T=w.height,E=w.width,ee=w.x,D=w.y;return!x||!x.length?null:J.createElement(cn,Wt({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:C,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:T,hide:l,layout:g,isAnimationActive:u,isRange:S,legendType:d,needClip:v,points:x,stroke:f,width:E,left:ee,top:D,xAxisId:p,yAxisId:m}))}var un=(e,t,n,r,i)=>{var a=n??t;if(P(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function dn(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=un(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=Me(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=Me(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>Me(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:Ze({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:Ze({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function fn(e){var t=Se(e,Zt),n=ze();return J.createElement(le,{id:t.id,type:`area`},e=>J.createElement(J.Fragment,null,J.createElement(de,{legendPayload:$t(t)}),J.createElement(en,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),J.createElement(ve,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:He(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),J.createElement(ln,Wt({},t,{id:e}))))}var pn=J.memo(fn,st);pn.displayName=`Area`;var mn=[`axis`],hn=(0,J.forwardRef)((e,t)=>J.createElement(oe,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:mn,tooltipPayloadSearcher:ke,categoricalChartProps:e,ref:t})),gn=[`axis`],_n=(0,J.forwardRef)((e,t)=>J.createElement(oe,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:gn,tooltipPayloadSearcher:ke,categoricalChartProps:e,ref:t})),X=c(),vn=53,Z=9,Q=2,yn=p.div`
2
- display: flex;
3
- gap: ${Q}px;
4
- `,bn=p.div`
5
- display: grid;
6
- grid-template-rows: repeat(7, ${Z}px);
7
- gap: ${Q}px;
8
- padding-top: ${11}px;
9
- font-size: 9px;
10
- color: ${({theme:e})=>e.color.inkFaint};
11
- `,xn=p.div`
12
- line-height: ${Z}px;
13
- padding-right: 2px;
14
- text-align: right;
15
- `,Sn=p.div`
16
- display: grid;
17
- grid-template-columns: repeat(${vn}, ${Z}px);
18
- gap: ${Q}px;
19
- height: ${Z}px;
20
- font-size: 9px;
21
- color: ${({theme:e})=>e.color.inkFaint};
22
- `,Cn=p.div`
23
- white-space: nowrap;
24
- line-height: ${Z}px;
25
- `,wn=p.div`
26
- display: grid;
27
- grid-template-columns: repeat(${vn}, ${Z}px);
28
- gap: ${Q}px;
29
- `,Tn=p.div`
30
- display: grid;
31
- grid-template-rows: repeat(7, ${Z}px);
32
- gap: ${Q}px;
33
- `,En=p.div`
34
- width: ${Z}px;
35
- height: ${Z}px;
36
- border-radius: 2px;
37
- background: ${({$level:e})=>e===0?`var(--panel-sunk)`:`color-mix(in oklch, var(--accent) ${[0,24,46,70,100][e]??100}%, var(--panel-sunk))`};
38
- border: 1px solid var(--rule);
39
- visibility: ${({$future:e})=>e?`hidden`:`visible`};
40
-
41
- &:hover,
42
- &:focus-visible {
43
- outline: 1px solid var(--ink-dim);
44
- outline-offset: 1px;
45
- }
46
- `,Dn=p(r)`
47
- gap: ${Q}px;
48
- `,On=p(s)`
49
- color: ${({theme:e})=>e.color.inkDim};
50
- font-size: 11px;
51
- `;function kn(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(t.length*e))]??0;return[n(.25),n(.5),n(.75)]}function An(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function jn({days:e,now:t}){let[n,a]=(0,J.useState)(`tokens`),[s,c]=(0,J.useState)(null),l=Be(n),u=(0,J.useMemo)(()=>{let n=new Map;for(let t of e){let e=Number(t.key);Number.isFinite(e)&&n.set(K(e),{requests:t.requests,errors:t.errors,costUsd:t.costUsd,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens,rtkSavedTokens:t.rtkSavedTokens,rtkAppliedRequests:t.rtkAppliedRequests,durationMsSum:t.durationMsSum})}let r=new Date(K(t));r.setDate(r.getDate()+(6-r.getDay())-370);let i=K(t);return Array.from({length:vn},()=>Array.from({length:7},()=>{let e=r.getTime();return r.setDate(r.getDate()+1),{at:e,totals:n.get(e)??U,future:e>i}}))},[e,t]),d=u.flat(),f=kn(d.map(e=>l.of({key:``,...e.totals}))),p=d.reduce((e,t)=>ut(e,V(t.totals)),U),h=d.reduce((e,t)=>e+ +(t.totals.requests>0),0),g=(e,t)=>`${e}: ${C(t.requests)} requests, ${C(B(t))} tokens, ${S(t.costUsd)}`;return(0,X.jsx)(T,{legend:`Activity`,meta:s===null?`${C(h)} active days`:void 0,actions:(0,X.jsx)(Qe,{children:Ue.map(e=>(0,X.jsx)(et,{type:`button`,$size:`sm`,$on:e.id===n,"aria-pressed":e.id===n,onClick:()=>a(e.id),children:e.label},e.id))}),children:(0,X.jsxs)(m,{$gap:2,children:[(0,X.jsx)(i,{children:(0,X.jsx)(m,{$gap:1,style:{width:611},children:(0,X.jsxs)(yn,{children:[(0,X.jsx)(bn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>(0,X.jsx)(xn,{children:e},t))}),(0,X.jsxs)(m,{$gap:1,children:[(0,X.jsx)(Sn,{"aria-hidden":`true`,children:u.map((e,t)=>{let n=e[0],r=u[t-1]?.[0],i=n!==void 0&&(r===void 0||new Date(r.at).getMonth()!==new Date(n.at).getMonth());return(0,X.jsx)(Cn,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),(0,X.jsx)(wn,{role:`grid`,"aria-label":`${l.label} per day over the last year`,children:u.map(e=>(0,X.jsx)(Tn,{role:`row`,children:e.map(e=>(0,X.jsx)(En,{role:`gridcell`,tabIndex:-1,"aria-label":g(Xe(e.at),e.totals),title:g(Xe(e.at),e.totals),$future:e.future,$level:e.future?0:An(l.of({key:``,...e.totals}),f),onMouseEnter:()=>c(e),onMouseLeave:()=>c(null)},e.at))},e[0]?.at))})]})]})})}),(0,X.jsxs)(r,{$justify:`space-between`,$wrap:!0,children:[(0,X.jsx)(On,{children:s===null?g(`Last 12 months`,p):g(Xe(s.at),s.totals)}),(0,X.jsxs)(r,{$gap:1,children:[(0,X.jsx)(o,{children:`Less`}),(0,X.jsx)(Dn,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>(0,X.jsx)(En,{$level:e,$future:!1},e))}),(0,X.jsx)(o,{children:`More`})]})]})]})})}function Mn({buckets:e,by:n,since:r,until:a,metric:o,names:s}){let c=G(r,a,n),l=new Map,u=new Map;for(let t of e){let e=t.split??`unknown`;l.set(e,ut(l.get(e)??U,t));let r=u.get(e)??new Map,i=H(t.key,n);r.set(i,(r.get(i)??0)+o.of(t)),u.set(e,r)}let d=[...l.entries()].sort((e,t)=>o.of(V(t[1]))-o.of(V(e[1])));return(0,X.jsx)(i,{children:(0,X.jsxs)(te,{children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(A,{children:`Key`}),(0,X.jsx)(A,{children:`Trend`}),(0,X.jsx)(A,{$align:`right`,children:`Requests`}),(0,X.jsx)(A,{$align:`right`,children:`Failed`}),(0,X.jsx)(A,{$align:`right`,children:`Tokens`}),(0,X.jsx)(A,{$align:`right`,children:`Mean`}),(0,X.jsx)(A,{$align:`right`,children:`Cost`})]})}),(0,X.jsx)(`tbody`,{children:d.map(([e,n])=>{let r=u.get(e)??new Map,i=e===`unknown`?`Unattributed`:s.get(e)??e;return(0,X.jsxs)(O,{children:[(0,X.jsx)(k,{children:(0,X.jsx)(t,{style:{display:`block`,maxWidth:`28ch`},children:i})}),(0,X.jsx)(k,{style:{width:120},children:(0,X.jsx)(y,{values:c.map(e=>r.get(e)??0),height:20,label:`${i}: ${o.format(o.of(V(n)))} over the window`})}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(n.requests)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,style:n.errors>0?{color:`var(--down)`}:void 0,children:w(n.requests===0?0:n.errors/n.requests,0)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(B(n))}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:x(n.requests===0?null:n.durationMsSum/n.requests)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:S(n.costUsd)})]},e)})})]})})}var Nn=6,Pn=`__other__`,Fn=`unknown`;function In(e,t){let n=t.get(e);return n===void 0?g.find(t=>ne[t].models.some(t=>t.id===e))??null:n}function Ln(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${h(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Rn({buckets:e,by:n,since:r,until:i,metric:a,providers:o}){let s=[...nt(e,a).entries()],c=s.slice(0,Nn),l=s.slice(Nn),u=[];for(let e of[...g,null])c.filter(([t])=>In(t,o)===e).forEach(([t,n],r)=>{u.push({name:t,label:t===Fn?`Unresolved`:t,color:Ln(e,r),totals:n})});l.length>0&&u.push({name:Pn,label:`${l.length} more`,color:`var(--ink-faint)`,totals:l.reduce((e,[,t])=>ut(e,V(t)),U)});let d=new Set(c.map(([e])=>e)),f=new Map;for(let t of e){let e=t.split??Fn,r=`${H(t.key,n)} ${d.has(e)?e:Pn}`;f.set(r,(f.get(r)??0)+a.of(t))}let p=G(r,i,n).map(e=>{let t={at:e};for(let n of u)t[n.name]=f.get(`${e} ${n.name}`)??0;return t}),h=new Map(u.map(e=>[e.name,e.label]));return(0,X.jsxs)(m,{$gap:2,children:[(0,X.jsx)(ct,{$height:220,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(hn,{data:p,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`at`,tickFormatter:e=>R(e,n),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(mt,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),(0,X.jsx)(F,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t,label:r})=>{if(e!==!0||t===void 0||t.length===0)return null;let i=t.filter(e=>Number(e.value??0)>0);return(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:R(Number(r),n)}),i.length===0?(0,X.jsx)(`div`,{children:`No ${a.label.toLowerCase()}`}):i.map(e=>(0,X.jsxs)(`div`,{children:[h.get(String(e.dataKey))??String(e.dataKey),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}}),u.map(e=>(0,X.jsx)(pn,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),(0,X.jsx)(at,{children:u.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(W,{$color:e.color}),` `,(0,X.jsx)(t,{title:`${e.label}: ${a.format(a.of(V(e.totals)))} ${a.label.toLowerCase()}`,style:{display:`inline-block`,maxWidth:`24ch`,verticalAlign:`bottom`},children:e.label})]},e.name))})]})}var zn=`unknown`;function Bn(e){let t=g.find(t=>t===e);return t===void 0?`var(--ink-faint)`:h(t)}function Vn(e){let t=g.find(t=>t===e);return t===void 0?`Unresolved`:_[t]}function Hn({buckets:e,by:t,since:n,until:r,metric:i}){let a=nt(e,i),o=[...g,zn].map(e=>({name:e,totals:a.get(e)})).filter(e=>e.totals!==void 0),s=o.map(e=>e.name),c=G(n,r,t),l=ft(e,c,t,i),u=[...a.values()].reduce((e,t)=>e+t.requests,0);return(0,X.jsxs)(m,{$gap:3,children:[(0,X.jsx)(ct,{$height:200,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(hn,{data:l,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(mt,{tickFormatter:e=>i.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),(0,X.jsx)(F,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:R(Number(r),t)}),n.map(e=>(0,X.jsxs)(`div`,{children:[Vn(String(e.dataKey)),` `,i.format(Number(e.value??0))]},String(e.dataKey)))]})}),s.map(e=>(0,X.jsx)(pn,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:Bn(e),strokeWidth:2,fill:Bn(e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),(0,X.jsx)(at,{children:s.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(W,{$color:Bn(e)}),` `,Vn(e)]},e))}),(0,X.jsxs)(te,{children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(A,{children:`Provider`}),(0,X.jsx)(A,{$align:`right`,children:`Share`}),(0,X.jsx)(A,{$align:`right`,children:`Requests`}),(0,X.jsx)(A,{$align:`right`,children:`Failed`}),(0,X.jsx)(A,{$align:`right`,children:`Tokens`}),(0,X.jsx)(A,{$align:`right`,children:`Cost`})]})}),(0,X.jsx)(`tbody`,{children:o.map(({name:e,totals:t})=>(0,X.jsxs)(O,{children:[(0,X.jsxs)(k,{children:[(0,X.jsx)(W,{$color:Bn(e)}),` `,Vn(e)]}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:w(u===0?0:t.requests/u,0)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(t.requests)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:C(t.errors)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(B(t))}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:S(t.costUsd)})]},e))})]})]})}var Un=p.li`
52
- display: grid;
53
- grid-template-columns: minmax(0, 20ch) 1fr auto;
54
- align-items: center;
55
- gap: ${({theme:e})=>e.space(2)};
56
- `,Wn=p.ol`
57
- display: flex;
58
- flex-direction: column;
59
- gap: ${({theme:e})=>e.space(2)};
60
- `,Gn=p.div`
61
- height: 8px;
62
- border-radius: 2px;
63
- background: ${({theme:e})=>e.color.panelSunk};
64
- border: 1px solid ${({theme:e})=>e.color.rule};
65
- overflow: hidden;
66
- `,Kn=p.div`
67
- width: ${({$share:e})=>`${Math.max(1.5,e*100)}%`};
68
- height: 100%;
69
- border-radius: 0 2px 2px 0;
70
- background: ${({theme:e,$fault:t})=>t?e.color.down:e.color.accent};
71
- opacity: 0.85;
72
- `,qn=p(t)`
73
- display: block;
74
- font-family: ${({theme:e})=>e.font.mono};
75
- font-size: 12px;
76
- `,Jn=12;function Yn({buckets:e,metric:t,names:n,unknownLabel:i}){let a=new Map;for(let t of e)a.set(t.key,ut(a.get(t.key)??U,t));let o=e=>e===`unknown`?i??`Unattributed`:n?.get(e)??e,c=[...a.entries()].map(([e,n])=>({name:o(e),entry:n,value:t.of(V(n))})).sort((e,t)=>t.value-e.value),l=c.slice(0,Jn),u=c.slice(Jn),d=l[0]?.value??0;return(0,X.jsxs)(m,{$gap:3,children:[(0,X.jsx)(Wn,{children:l.map(({name:e,entry:n,value:i})=>(0,X.jsxs)(Un,{children:[(0,X.jsx)(qn,{title:e,children:e}),(0,X.jsx)(Gn,{children:(0,X.jsx)(Kn,{$share:d===0?0:i/d,$fault:n.requests>0&&n.errors===n.requests})}),(0,X.jsxs)(r,{$gap:2,children:[(0,X.jsx)(s,{$size:`12px`,children:t.format(i)}),(0,X.jsx)(s,{$size:`11px`,$dim:!0,children:S(n.costUsd)})]})]},e))}),u.length===0?null:(0,X.jsx)(s,{$size:`11px`,$dim:!0,children:`+ ${u.length} more, ${C(u.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}function $({legend:e,meta:t,actions:n,query:r,empty:i,isEmpty:a,children:o}){return(0,X.jsx)(T,{legend:e,meta:t,actions:n,children:r.isError?(0,X.jsx)(E,{error:r.error,onRetry:r.refetch}):r.isLoading?(0,X.jsx)(ee,{rows:4}):a?(0,X.jsx)(D,{legend:i.legend,message:i.message}):o})}var Xn=[{id:`inputTokens`,label:`Uncached input`,opacity:.95},{id:`outputTokens`,label:`Output`,opacity:.7},{id:`cacheReadTokens`,label:`Cache read`,opacity:.45},{id:`cacheWriteTokens`,label:`Cache write`,opacity:.22}];function Zn({buckets:e,by:t,since:n,until:i}){let a=new Map;for(let n of e)a.set(H(n.key,t),n);let o=G(n,i,t).map(e=>{let t=a.get(e);return{at:e,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,cacheReadTokens:t?.cacheReadTokens??0,cacheWriteTokens:t?.cacheWriteTokens??0}}),c=Xn.map(e=>({...e,value:o.reduce((t,n)=>t+n[e.id],0)})),l=c.reduce((e,t)=>e+t.value,0);return(0,X.jsxs)(m,{$gap:3,children:[(0,X.jsx)(ct,{$height:200,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(hn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(mt,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>C(e)}),(0,X.jsx)(F,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:R(Number(r),t)}),Xn.map(e=>(0,X.jsxs)(`div`,{children:[e.label,` `,C(Number(n.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),Xn.map(e=>(0,X.jsx)(pn,{type:`monotone`,dataKey:e.id,stackId:`tokens`,stroke:`var(--accent)`,strokeOpacity:e.opacity,strokeWidth:1.5,fill:`var(--accent)`,fillOpacity:e.opacity*.5,isAnimationActive:!1},e.id))]})})}),(0,X.jsx)(at,{children:c.map(e=>(0,X.jsxs)(r,{$gap:1,children:[(0,X.jsx)(W,{$color:`var(--accent)`,style:{opacity:e.opacity}}),(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(s,{$size:`11px`,children:C(e.value)}),(0,X.jsx)(s,{$size:`11px`,$dim:!0,children:w(l===0?0:e.value/l,0)})]},e.id))})]})}function Qn({buckets:e,by:t,since:n,until:r}){let i=new Map;for(let n of e)i.set(H(n.key,t),n);let a=G(n,r,t).map(e=>{let n=i.get(e);return{at:e,label:R(e,t),requests:n?.requests??0,errors:n?.errors??0,costUsd:n?.costUsd??0,tokens:n===void 0?0:B(n)}});return(0,X.jsxs)(m,{$gap:2,children:[(0,X.jsx)(ct,{$height:220,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(_n,{data:a,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(mt,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),(0,X.jsx)(F,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t})=>{if(e!==!0||t===void 0||t.length===0)return null;let n=t[0]?.payload;return n===void 0?null:(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:n.label}),(0,X.jsxs)(`div`,{children:[C(n.requests),` requests`]}),(0,X.jsxs)(`div`,{children:[C(n.errors),` failed`]}),(0,X.jsxs)(`div`,{children:[C(n.tokens),` tokens`]}),(0,X.jsx)(`div`,{children:S(n.costUsd)})]})}}),(0,X.jsx)(pn,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),(0,X.jsx)(se,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),(0,X.jsx)(se,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),(0,X.jsxs)(at,{children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(W,{$color:`var(--accent)`}),` Requests`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(W,{$color:`var(--down)`}),` Failed`]})]})]})}var $n=p.div`
77
- display: grid;
78
- grid-template-columns: repeat(
79
- auto-fit,
80
- minmax(max(180px, calc((100% - 4 * ${({theme:e})=>e.space(3)}) / 5)), 1fr)
81
- );
82
- gap: ${({theme:e})=>e.space(3)};
83
- `,er=864e5,tr=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function nr(){let{cadence:e}=v(),[t,n]=(0,J.useState)(`24h`),[r,i]=(0,J.useState)(`tokens`),[o,s]=(0,J.useState)(`model`),c=je(t),p=Be(r),h=(0,J.useMemo)(()=>c.grain===`daily`?K(Date.now()-c.ms):Math.floor((Date.now()-c.ms)/6e4)*6e4,[c]),g=(0,J.useMemo)(()=>h+c.ms,[h,c]),_=(0,J.useMemo)(()=>K(Date.now()-371*er),[]),T={since:h,grain:c.grain},E=f({...T,groupBy:c.by},e(6e4)),ee=f({...T,groupBy:c.by,splitBy:`provider`},e(6e4)),D=f({...T,groupBy:c.by,splitBy:`model`},e(6e4)),O=f({...T,groupBy:c.by,splitBy:`apiKey`},e(6e4)),k=f({...T,groupBy:o},e(6e4)),A=f({...T,groupBy:`credential`},e(6e4)),te=f({since:_,grain:`daily`,groupBy:`day`},e(3e5)),ne=d(),re=u(),j=l(),ie=(0,J.useMemo)(()=>{let e=new Map;for(let t of j.data??[])for(let n of t.targets)e.set(n.model,n.provider);return e},[j.data]),ae=(0,J.useMemo)(()=>{let e=new Map;for(let t of ne.data??[])e.set(t.id,t.label);return e},[ne.data]),oe=(0,J.useMemo)(()=>{let e=new Map;for(let t of re.data??[])e.set(t.id,t.label);return e},[re.data]),M=E.data??[],N=xe(M),P=N.inputTokens+N.cacheReadTokens+N.cacheWriteTokens,se=B(N),ce=N.requests===0?0:N.outputTokens/N.requests,le=P===0?0:N.cacheReadTokens/P,ue=P===0?0:N.cacheWriteTokens/P,de=N.requests===0?0:N.costUsd/N.requests,fe=G(h,g,c.by),F=new Map(M.map(e=>[H(e.key,c.by),e])),I=e=>fe.map(e),pe=e=>e>=.25?`down`:e>=.05?`warn`:`ok`,me=N.requests===0?0:N.errors/N.requests,L={legend:`Nothing recorded`,message:`No requests landed in this window. Widen the range, or send traffic through the gateway.`};return(0,X.jsxs)(m,{$gap:4,children:[(0,X.jsx)(b,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:E.isLoading?`Reading usage…`:`${C(N.requests)} requests and ${S(N.costUsd)} over the last ${c.label}.`,actions:(0,X.jsx)(Qe,{children:Ne.map(e=>(0,X.jsx)(et,{type:`button`,$size:`sm`,$on:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:e.id},e.id))})}),(0,X.jsxs)($n,{"data-testid":`usage-summary-deck`,children:[(0,X.jsx)(q,{legend:`Requests`,value:C(N.requests),unit:c.label,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.requests??0),overlay:I(e=>F.get(e)?.errors??0),label:`${N.requests} requests, ${N.errors} of them failed`})}),(0,X.jsx)(q,{legend:`Error rate`,value:w(me),unit:`${C(N.errors)} failed`,tone:N.requests===0?`ink`:pe(me),trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.errors/t.requests}),color:`var(--down)`,label:`${N.errors} failed requests against ${N.requests} total`})}),(0,X.jsx)(q,{legend:`Prompt input`,value:C(P),unit:`${C(N.inputTokens)} uncached`,trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return(t?.inputTokens??0)+(t?.cacheReadTokens??0)+(t?.cacheWriteTokens??0)}),label:`${P} prompt input tokens over the window`})}),(0,X.jsx)(q,{legend:`Output`,value:C(N.outputTokens),unit:`mean ${C(ce)}/request`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.outputTokens??0),label:`${N.outputTokens} output tokens over the window`})}),(0,X.jsx)(q,{legend:`Cache reads`,value:C(N.cacheReadTokens),unit:`${w(le,0)} of prompt`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.cacheReadTokens??0),label:`${N.cacheReadTokens} cache-read tokens over the window`})}),(0,X.jsx)(q,{legend:`Cache writes`,value:C(N.cacheWriteTokens),unit:`${w(ue,0)} of prompt`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.cacheWriteTokens??0),label:`${N.cacheWriteTokens} cache-write tokens over the window`})}),(0,X.jsx)(q,{legend:`RTK saved`,value:C(N.rtkSavedTokens),unit:`${C(N.rtkAppliedRequests)} requests`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.rtkSavedTokens??0),label:`${N.rtkSavedTokens} estimated tokens saved by RTK over the window`})}),(0,X.jsx)(q,{legend:`Mean duration`,value:x(N.requests===0?null:N.durationMsSum/N.requests),unit:`per request`,trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.durationMsSum/t.requests}),color:`var(--ok)`,label:`mean request duration over the window`})}),(0,X.jsx)(q,{legend:`Spend`,value:S(N.costUsd),unit:c.label,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.costUsd??0),color:`var(--warn)`,label:`spend over the window, ${S(N.costUsd)} total`})}),(0,X.jsx)(q,{legend:`Cost / request`,value:S(de),unit:`mean`,trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.costUsd/t.requests}),color:`var(--warn)`,label:`${S(de)} mean cost per request over the window`})})]}),(0,X.jsx)($,{legend:`Traffic`,meta:c.by===`hour`?`By hour`:`By day`,query:E,isEmpty:M.length===0,empty:L,children:(0,X.jsx)(Qn,{buckets:M,by:c.by,since:h,until:g})}),(0,X.jsx)(Qe,{children:Ue.map(e=>(0,X.jsx)(et,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:`Rank by ${e.label.toLowerCase()}`},e.id))}),(0,X.jsx)($,{legend:`Traffic by upstream model`,meta:`${p.label}, ${c.by===`hour`?`by hour`:`by day`}`,query:D,isEmpty:(D.data??[]).length===0,empty:L,children:(0,X.jsx)(Rn,{buckets:D.data??[],by:c.by,since:h,until:g,metric:p,providers:ie})}),(0,X.jsxs)(a,{$min:`480px`,$gap:4,children:[(0,X.jsxs)(m,{$gap:4,children:[(0,X.jsx)($,{legend:`Providers`,meta:p.label,query:ee,isEmpty:(ee.data??[]).length===0,empty:L,children:(0,X.jsx)(Hn,{buckets:ee.data??[],by:c.by,since:h,until:g,metric:p})}),(0,X.jsx)(jn,{days:te.data??[],now:Date.now()})]}),(0,X.jsxs)(m,{$gap:4,children:[(0,X.jsx)($,{legend:`Token mix`,meta:C(se),query:E,isEmpty:M.length===0,empty:L,children:(0,X.jsx)(Zn,{buckets:M,by:c.by,since:h,until:g})}),(0,X.jsx)($,{legend:`Models`,meta:tr.find(e=>e.id===o)?.column,query:k,isEmpty:(k.data??[]).length===0,empty:L,actions:(0,X.jsx)(Qe,{children:tr.map(e=>(0,X.jsx)(et,{type:`button`,$size:`sm`,$on:e.id===o,"aria-pressed":e.id===o,onClick:()=>s(e.id),children:e.label},e.id))}),children:(0,X.jsx)(Yn,{buckets:k.data??[],metric:p})}),(0,X.jsx)($,{legend:`Accounts`,meta:p.label,query:A,isEmpty:(A.data??[]).length===0,empty:L,children:(0,X.jsx)(Yn,{buckets:A.data??[],metric:p,names:oe,unknownLabel:`No account`})})]})]}),(0,X.jsx)($,{legend:`API keys`,meta:p.label,query:O,isEmpty:(O.data??[]).length===0,empty:L,children:(0,X.jsx)(Mn,{buckets:O.data??[],by:c.by,since:h,until:g,metric:p,names:ae})})]})}var rr=nr;export{rr as component};
@@ -1 +0,0 @@
1
- import{$t as e,Ft as t,Pt as n,X as r}from"./queries-D8LJNQpL.js";var i=e(r(),1),a=e(t(),1),o=Object.defineProperty,s=(e,t)=>o(e,`name`,{value:t,configurable:!0});function c(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}s(c,`setRef`);function l(...e){return t=>{let n=!1,r=e.map(e=>{let r=c(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():c(e[t],null)}}}}s(l,`composeRefs`);function u(...e){return a.useCallback(l(...e),e)}s(u,`useComposedRefs`);var d=Object.defineProperty,f=(e,t)=>d(e,`name`,{value:t,configurable:!0});function p(e){let t=a.forwardRef((t,n)=>{let{children:r,...i}=t,o=null,s=!1,c=[];x(r)&&typeof T==`function`&&(r=T(r._payload)),a.Children.forEach(r,e=>{if(y(e)){s=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;x(n)&&typeof T==`function`&&(n=T(n._payload)),o=g(t,n),c.push(o?.props?.children)}else c.push(e)}),o?o=a.cloneElement(o,void 0,c):!s&&a.Children.count(r)===1&&a.isValidElement(r)&&(o=r);let l=o?v(o):void 0,d=u(n,l);if(!o){if(r||r===0)throw Error(s?w(e):C(e));return r}let f=_(i,o.props??{});return o.type!==a.Fragment&&(f.ref=n?d:l),a.cloneElement(o,f)});return t.displayName=`${e}.Slot`,t}f(p,`createSlot`);var m=Symbol.for(`radix.slottable`);function h(e){let t=f(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=m,t}f(h,`createSlottable`);var g=f((e,t)=>{if(`child`in e.props){let t=e.props.child;return a.isValidElement(t)?a.cloneElement(t,void 0,e.props.children(t.props.children)):null}return a.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function _(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}f(_,`mergeProps`);function v(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}f(v,`getElementRef`);function y(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===m}f(y,`isSlottable`);var b=Symbol.for(`react.lazy`);function x(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===b&&`_payload`in e&&S(e._payload)}f(x,`isLazyComponent`);function S(e){return typeof e==`object`&&!!e&&`then`in e}f(S,`isPromiseLike`);var C=f(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),w=f(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),T=a.use,E=n(),D=Object.defineProperty,O=(e,t)=>D(e,`name`,{value:t,configurable:!0}),ee=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=p(`Primitive.${t}`),r=a.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,E.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function k(e,t){e&&i.flushSync(()=>e.dispatchEvent(t))}O(k,`dispatchDiscreteCustomEvent`);var A=Object.defineProperty,j=(e,t)=>A(e,`name`,{value:t,configurable:!0});function te(e,t){let n=a.createContext(t);n.displayName=e+`Context`;let r=j(e=>{let{children:t,...r}=e,i=a.useMemo(()=>r,Object.values(r));return(0,E.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:o=!1}=i,s=a.useContext(n);if(s)return s;if(t!==void 0)return t;if(!o)throw Error(`\`${r}\` must be used within \`${e}\``)}return j(i,`useContext`),[r,i]}j(te,`createContext`);function M(e,t=[]){let n=[];function r(t,r){let i=a.createContext(r);i.displayName=t+`Context`;let o=n.length;n=[...n,r];let s=j(t=>{let{scope:n,children:r,...s}=t,c=n?.[e]?.[o]||i,l=a.useMemo(()=>s,Object.values(s));return(0,E.jsx)(c.Provider,{value:l,children:r})},`Provider`);s.displayName=t+`Provider`;function c(n,s,c={}){let{optional:l=!1}=c,u=s?.[e]?.[o]||i,d=a.useContext(u);if(d)return d;if(r!==void 0)return r;if(!l)throw Error(`\`${n}\` must be used within \`${t}\``)}return j(c,`useContext`),[s,c]}j(r,`createContext`);let i=j(()=>{let t=n.map(e=>a.createContext(e));return j(function(n){let r=n?.[e]||t;return a.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,N(i,...t)]}j(M,`createContextScope`);function N(...e){let t=e[0];if(e.length===1)return t;let n=j(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return j(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}j(N,`composeContextScopes`);var P=Object.defineProperty,F=(e,t)=>P(e,`name`,{value:t,configurable:!0}),I=!!(typeof window<`u`&&window.document&&window.document.createElement);function L(e,t,{checkForDefaultPrevented:n=!0}={}){return F(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}F(L,`composeEventHandlers`);function ne(e){if(!I)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}F(ne,`getOwnerWindow`);function R(e){if(!I)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}F(R,`getOwnerDocument`);function z(e,t=!1){let{activeElement:n}=R(e);if(!n?.nodeName)return null;if(B(n)&&n.contentDocument)return z(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=R(n).getElementById(e);if(t)return t}}return n}F(z,`getActiveElement`);function B(e){return e.tagName===`IFRAME`}F(B,`isFrame`);var V=globalThis?.document?a.useLayoutEffect:()=>{},H=Object.defineProperty,U=(e,t)=>H(e,`name`,{value:t,configurable:!0}),W=a.useEffectEvent,G=a.useInsertionEffect;function K(e){if(typeof W==`function`)return W(e);let t=a.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof G==`function`?G(()=>{t.current=e}):V(()=>{t.current=e}),a.useMemo(()=>((...e)=>t.current?.(...e)),[])}U(K,`useEffectEvent`);var q=Object.defineProperty,J=(e,t)=>q(e,`name`,{value:t,configurable:!0}),Y=a.useInsertionEffect||V;function X({prop:e,defaultProp:t,onChange:n=J(()=>{},`onChange`),caller:r}){let[i,o,s]=Z({defaultProp:t,onChange:n}),c=e!==void 0;return[c?e:i,a.useCallback(t=>{if(c){let n=Q(t)?t(e):t;n!==e&&s.current?.(n)}else o(t)},[c,e,o,s])]}J(X,`useControllableState`);function Z({defaultProp:e,onChange:t}){let[n,r]=a.useState(e),i=a.useRef(n),o=a.useRef(t);return Y(()=>{o.current=t},[t]),a.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}J(Z,`useUncontrolledState`);function Q(e){return typeof e==`function`}J(Q,`isFunction`);var $=Symbol(`RADIX:SYNC_STATE`);function re(e,t,n,r){let{prop:i,defaultProp:o,onChange:s,caller:c}=t,l=i!==void 0,u=K(s),d=[{...n,state:o}];r&&d.push(r);let[f,p]=a.useReducer((t,n)=>{if(n.type===$)return{...t,state:n.state};let r=e(t,n);return l&&!Object.is(r.state,t.state)&&u(r.state),r},...d),m=f.state,h=a.useRef(m);a.useEffect(()=>{h.current!==m&&(h.current=m,l||u(m))},[m,h,l]);let g=a.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return a.useEffect(()=>{l&&!Object.is(i,f.state)&&p({type:$,state:i})},[i,f.state,l]),[g,p]}J(re,`useControllableStateReducer`);export{ee as a,u as c,M as i,V as n,k as o,L as r,p as s,X as t};