omnigateway 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -7
- package/bin/omni.js +4954 -2939
- package/gateway.js +3132 -1164
- package/package.json +1 -1
- package/public/assets/{Chip-BB_5C1Zp.js → Chip-DJwp7gBu.js} +2 -2
- package/public/assets/{Confirm-B6aAiVbT.js → Confirm-CVLz9F7a.js} +1 -1
- package/public/assets/CopyValue-CNZbWS59.js +27 -0
- package/public/assets/{Field-uHZxl4fI.js → Field-BDtp692L.js} +8 -8
- package/public/assets/Lamp-B65uWKbW.js +25 -0
- package/public/assets/{Meter-DI_BRUKt.js → Meter-BREBUFGX.js} +2 -2
- package/public/assets/{Modal-CI6jk2D4.js → Modal-DbydSAlp.js} +8 -8
- package/public/assets/Rack-Bbo4JfEX.js +151 -0
- package/public/assets/{Readout-BocZ2HXP.js → Readout-CEAoN5hu.js} +9 -5
- package/public/assets/{States-Bbiu5cHE.js → States-BEKLros0.js} +10 -10
- package/public/assets/{Table-CdPWxYaz.js → Table-BBypbVWj.js} +1 -1
- package/public/assets/{Toggle-CiLC67Dw.js → Toggle-BUr71O4J.js} +2 -2
- package/public/assets/{TokenBreakdown-B96iPBm9.js → TokenBreakdown-C1ziK9d1.js} +6 -3
- package/public/assets/_app-ByQ1bPbe.js +1 -0
- package/public/assets/_app.accounts-BTug_Xfo.js +64 -0
- package/public/assets/{_app.console-Daz4aKhf.js → _app.console-DKyGL9xx.js} +10 -10
- package/public/assets/_app.index-CSw9gmMf.js +62 -0
- package/public/assets/_app.keys-07Kbw4RS.js +39 -0
- package/public/assets/_app.logs-C9QiV39p.js +32 -0
- package/public/assets/_app.models-CDqVrAeF.js +148 -0
- package/public/assets/{_app.settings-a0FKyQAi.js → _app.settings-DmUEeTaP.js} +10 -10
- package/public/assets/_app.usage-B1WuMGRr.js +83 -0
- package/public/assets/catalog-BBKm8Ih8.js +1 -0
- package/public/assets/{dist-C-IbPRiV.js → dist-Bka7ErcH.js} +1 -1
- package/public/assets/index-DJfb1i4P.js +186 -0
- package/public/assets/{login-CTvH_KAd.js → login-DKZYqRh0.js} +8 -8
- package/public/assets/queries-D8LJNQpL.js +144 -0
- package/public/assets/shared-CIhZ6FCO.js +84 -0
- package/public/assets/{trash-2-BcZb-sCT.js → trash-2-CLYNAAJA.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/CopyValue-CRQDLo7k.js +0 -27
- package/public/assets/Lamp-B-5SjXbG.js +0 -25
- package/public/assets/Rack-D1WJswv3.js +0 -151
- package/public/assets/_app-BBOF6A0T.js +0 -1
- package/public/assets/_app.accounts-BNkhpvaB.js +0 -54
- package/public/assets/_app.index-LO6d38oe.js +0 -62
- package/public/assets/_app.keys-kBqLqoFf.js +0 -39
- package/public/assets/_app.logs-_wYNS47N.js +0 -32
- package/public/assets/_app.models-Cjng8ohC.js +0 -144
- package/public/assets/_app.usage-D3KtgLrC.js +0 -166
- package/public/assets/catalog-C_OQ0icG.js +0 -1
- package/public/assets/index-PW6EvVh5.js +0 -170
- package/public/assets/queries-D2o-X8Pj.js +0 -144
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
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
2
|
display: block;
|
|
3
3
|
white-space: pre;
|
|
4
4
|
overflow-x: auto;
|
|
@@ -8,31 +8,31 @@ import{B as e,C as t,G as n,I as r,L as i,M as a,Mt as o,Nt as s,P as c,S as l,Z
|
|
|
8
8
|
border-radius: 4px;
|
|
9
9
|
font-size: 0.8125rem;
|
|
10
10
|
line-height: 1.5;
|
|
11
|
-
`,O=
|
|
11
|
+
`,O=d.div`
|
|
12
12
|
color: ${({theme:e})=>e.color.inkDim};
|
|
13
13
|
font-size: 0.8125rem;
|
|
14
14
|
margin-bottom: 0.25rem;
|
|
15
|
-
`,k=
|
|
15
|
+
`,k=d.p`
|
|
16
16
|
color: ${({theme:e})=>e.color.inkDim};
|
|
17
17
|
font-size: 0.8125rem;
|
|
18
18
|
margin: 0;
|
|
19
|
-
`,A=
|
|
19
|
+
`,A=d.div`
|
|
20
20
|
display: grid;
|
|
21
21
|
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
|
|
22
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[t
|
|
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
24
|
display: grid;
|
|
25
25
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
26
26
|
gap: ${({theme:e})=>e.space(3)};
|
|
27
|
-
`,I=
|
|
27
|
+
`,I=d(p)`
|
|
28
28
|
gap: 6px;
|
|
29
|
-
`,L=
|
|
29
|
+
`,L=d.p`
|
|
30
30
|
font-size: 11px;
|
|
31
31
|
color: ${({theme:e})=>e.color.inkDim};
|
|
32
|
-
`,R=
|
|
32
|
+
`,R=d.p`
|
|
33
33
|
font-size: 12px;
|
|
34
34
|
color: ${({theme:e})=>e.color.down};
|
|
35
|
-
`,z=
|
|
35
|
+
`,z=d.p`
|
|
36
36
|
font-size: 12px;
|
|
37
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
|
|
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};
|
|
@@ -0,0 +1,83 @@
|
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={anthropic:{defaultModel:`claude-opus-5`,authTypes:[`oauth`,`apiKey`],models:[{id:`claude-fable-5`,label:`Claude Fable 5`,pricing:{input:10,output:50,cacheRead:1,cacheWrite5m:12.5,cacheWrite1h:20},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`claude-opus-5`,label:`Claude Opus 5`,pricing:{input:5,output:25,cacheRead:.5,cacheWrite5m:6.25,cacheWrite1h:10},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`claude-sonnet-5`,label:`Claude Sonnet 5`,pricing:{input:3,output:15,cacheRead:.3,cacheWrite5m:3.75,cacheWrite1h:6},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`claude-haiku-4-5`,label:`Claude Haiku 4.5`,pricing:{input:1,output:5,cacheRead:.1,cacheWrite5m:1.25,cacheWrite1h:2},limits:{contextWindow:2e5,maxOutputTokens:64e3},reasoningForm:`budget`}]},openai:{defaultModel:`gpt-5.6`,authTypes:[`oauth`,`apiKey`],models:[{id:`gpt-5.6`,label:`GPT-5.6 — routes to Sol`,pricing:{input:5,output:30,cacheRead:.5,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:922e3,maxOutputTokens:128e3},oauthLimits:{contextWindow:272e3,maxOutputTokens:128e3}},{id:`gpt-5.6-sol`,label:`GPT-5.6 Sol — deepest reasoning`,pricing:{input:5,output:30,cacheRead:.5,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:922e3,maxOutputTokens:128e3},oauthLimits:{contextWindow:272e3,maxOutputTokens:128e3}},{id:`gpt-5.6-terra`,label:`GPT-5.6 Terra — balanced`,pricing:{input:2,output:12,cacheRead:.2,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:922e3,maxOutputTokens:128e3},oauthLimits:{contextWindow:272e3,maxOutputTokens:128e3}},{id:`gpt-5.6-luna`,label:`GPT-5.6 Luna — fastest`,pricing:{input:.2,output:1.2,cacheRead:.02,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:922e3,maxOutputTokens:128e3},oauthLimits:{contextWindow:272e3,maxOutputTokens:128e3}}]},kimi:{defaultModel:`k3-256k`,authTypes:[`oauth`,`apiKey`],models:[{id:`k3-256k`,label:`Kimi K3 — 256K`,pricing:{input:3,output:15,cacheRead:.3,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:131072}},{id:`k3`,label:`Kimi K3 — up to 1M`,pricing:{input:3,output:15,cacheRead:.3,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1048576,maxOutputTokens:131072}},{id:`kimi-for-coding`,label:`Kimi K2.7 Code`,pricing:{input:.95,output:4,cacheRead:.19,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:131072}},{id:`kimi-for-coding-highspeed`,label:`Kimi K2.7 Code — High Speed`,pricing:{input:.95,output:8,cacheRead:.19,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:131072}}]},kilo:{defaultModel:`anthropic/claude-sonnet-5`,authTypes:[`oauth`,`apiKey`],models:[{id:`anthropic/claude-fable-5`,label:`Claude Fable 5`,pricing:{input:10,output:50,cacheRead:1,cacheWrite5m:12.5,cacheWrite1h:12.5},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`anthropic/claude-opus-5`,label:`Claude Opus 5`,pricing:{input:5,output:25,cacheRead:.5,cacheWrite5m:6.25,cacheWrite1h:6.25},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`anthropic/claude-sonnet-5`,label:`Claude Sonnet 5`,pricing:{input:2,output:10,cacheRead:.2,cacheWrite5m:2.5,cacheWrite1h:2.5},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`anthropic/claude-haiku-4.5`,label:`Claude Haiku 4.5`,pricing:{input:1,output:5,cacheRead:.1,cacheWrite5m:1.25,cacheWrite1h:1.25},limits:{contextWindow:2e5,maxOutputTokens:64e3}},{id:`openai/gpt-5.6-sol`,label:`GPT-5.6 Sol`,pricing:{input:5,output:30,cacheRead:.5,cacheWrite5m:6.25,cacheWrite1h:6.25},limits:{contextWindow:105e4,maxOutputTokens:128e3}},{id:`openai/gpt-5.6-terra`,label:`GPT-5.6 Terra`,pricing:{input:2,output:12,cacheRead:.2,cacheWrite5m:2.5,cacheWrite1h:2.5},limits:{contextWindow:105e4,maxOutputTokens:128e3}},{id:`openai/gpt-5.6-luna`,label:`GPT-5.6 Luna`,pricing:{input:.2,output:1.2,cacheRead:.02,cacheWrite5m:.25,cacheWrite1h:.25},limits:{contextWindow:105e4,maxOutputTokens:128e3}},{id:`google/gemini-3.1-pro-preview`,label:`Gemini 3.1 Pro Preview`,pricing:{input:2,output:12,cacheRead:.2,cacheWrite5m:.375,cacheWrite1h:.375},limits:{contextWindow:1048576,maxOutputTokens:65536}},{id:`google/gemini-3.7-flash`,label:`Gemini 3.7 Flash`,pricing:{input:.75,output:3.75,cacheRead:.075,cacheWrite5m:.041667,cacheWrite1h:.041667},limits:{contextWindow:1048576,maxOutputTokens:65536}},{id:`moonshotai/kimi-k3`,label:`Kimi K3`,pricing:{input:3,output:15,cacheRead:.3,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1048576,maxOutputTokens:131072}},{id:`nvidia/nemotron-3-ultra-550b-a55b:free`,label:`Nemotron 3 Ultra 550B — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:65536},auth:[`apiKey`]},{id:`nvidia/nemotron-3.5-lightning:free`,label:`Nemotron 3.5 Lightning — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:65536},auth:[`apiKey`]},{id:`dots-studio/dots-3-note-preview:free`,label:`Dots 3 Note Preview — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:512e3,maxOutputTokens:512e3},auth:[`apiKey`]},{id:`cohere/north-mini-code:free`,label:`North Mini Code — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:256e3,maxOutputTokens:64e3},auth:[`apiKey`]},{id:`nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free`,label:`Nemotron 3 Nano Omni 30B Reasoning — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:256e3,maxOutputTokens:65536},auth:[`apiKey`]},{id:`stepfun/step-3.7-flash:free`,label:`Step 3.7 Flash — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:262144},auth:[`apiKey`]},{id:`nvidia/nemotron-3-super-120b-a12b:free`,label:`Nemotron 3 Super 120B — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:262144},auth:[`apiKey`]},{id:`tencent/hy3:free`,label:`Tencent HY3 — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:128e3},auth:[`apiKey`]},{id:`poolside/laguna-s-2.1:free`,label:`Laguna S 2.1 — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:32768},auth:[`apiKey`]},{id:`poolside/laguna-xs-2.1:free`,label:`Laguna XS 2.1 — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:32768},auth:[`apiKey`]},{id:`liquid/lfm-2.5-2.6b:free`,label:`LFM 2.5 2.6B — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:128e3,maxOutputTokens:8192},auth:[`apiKey`]},{id:`nvidia/nemotron-3.5-content-safety:free`,label:`Nemotron 3.5 Content Safety — free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:128e3,maxOutputTokens:8192},auth:[`apiKey`]},{id:`kilo-auto/frontier`,label:`Kilo Auto — Frontier`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:128e3},auth:[`apiKey`]},{id:`kilo-auto/balanced`,label:`Kilo Auto — Balanced`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:65536},auth:[`apiKey`]},{id:`kilo-auto/efficient`,label:`Kilo Auto — Efficient`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:65536},auth:[`apiKey`]},{id:`kilo-auto/small`,label:`Kilo Auto — Small`,pricing:{input:.05,output:.4,cacheRead:.005,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:262144,maxOutputTokens:32768},auth:[`apiKey`]},{id:`kilo-auto/free`,label:`Kilo Auto — Free`,pricing:{input:0,output:0,cacheRead:0,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:256e3,maxOutputTokens:1e4},auth:[`apiKey`]}]},grok:{defaultModel:`grok-4.6`,authTypes:[`oauth`,`apiKey`],models:[{id:`grok-4.6`,label:`Grok 4.6`,pricing:{input:2,output:6,cacheRead:.5,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:5e5,maxOutputTokens:128e3}},{id:`grok-4.5`,label:`Grok 4.5`,pricing:{input:2,output:6,cacheRead:.3,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:5e5,maxOutputTokens:128e3}},{id:`grok-4.3`,label:`Grok 4.3`,pricing:{input:1.25,output:2.5,cacheRead:.2,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`grok-4.20-0309-reasoning`,label:`Grok 4.20 — reasoning`,pricing:{input:1.25,output:2.5,cacheRead:.2,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`grok-4.20-0309-non-reasoning`,label:`Grok 4.20 — non-reasoning`,pricing:{input:1.25,output:2.5,cacheRead:.2,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:128e3}},{id:`grok-4.20-multi-agent-0309`,label:`Grok 4.20 — multi-agent`,pricing:{input:1.25,output:2.5,cacheRead:.2,cacheWrite5m:0,cacheWrite1h:0},limits:{contextWindow:1e6,maxOutputTokens:128e3}}]},custom:{defaultModel:``,authTypes:[`apiKey`],models:[]}};function t(t,n){return e[t]?.models.find(e=>e.id===n)?.pricing??null}function n(t,n){let r=e[t];return r.models.find(e=>e.id===n)?.auth??r.authTypes}function r(t,n,r=`apiKey`){let i=e[t]?.models.find(e=>e.id===n);return i===void 0?null:(r===`oauth`?i.oauthLimits:void 0)??i.limits}export{t as i,r as n,n as r,e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|