omnigateway 0.7.2 → 0.8.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.
- package/README.md +90 -4
- package/bin/omni.js +6874 -4685
- package/gateway.js +17400 -14802
- package/package.json +1 -1
- package/public/assets/{Chip-BOyBT5TP.js → Chip-DG-mqRx0.js} +1 -1
- package/public/assets/{CopyValue-DRHHQlN_.js → CopyValue-CItB094V.js} +1 -1
- package/public/assets/Lamp-Cxp-OxUq.js +25 -0
- package/public/assets/{Rack-D798XvPQ.js → Rack-xBT_6EtM.js} +5 -5
- package/public/assets/{RequestTable-CEBhwDs7.js → RequestTable-CM9mPiMF.js} +1 -1
- package/public/assets/{SummaryDeck-DBCSHihY.js → SummaryDeck-C3ZwZ3ng.js} +1 -1
- package/public/assets/{Toggle-CdCCoDEo.js → Toggle-CmXXn6F3.js} +1 -1
- package/public/assets/{TokenBreakdown-DDI9uTPW.js → TokenBreakdown-COJ643vg.js} +1 -1
- package/public/assets/{WindowChart-C-Y6U3WF.js → WindowChart-BrLf4KCu.js} +1 -1
- package/public/assets/_app.accounts-B-OYO2Yi.js +59 -0
- package/public/assets/_app.console-BOZ1wncA.js +44 -0
- package/public/assets/{_app.database-D0W0pcxC.js → _app.database-B5oHZPbu.js} +4 -4
- package/public/assets/{_app.index-CyxnfhVX.js → _app.index-CB3UFRwF.js} +5 -5
- package/public/assets/{_app.keys-D9qmw9Tj.js → _app.keys-B89CMo3x.js} +2 -2
- package/public/assets/{_app.logs-DtXUZETW.js → _app.logs-CNAnRW07.js} +1 -1
- package/public/assets/{_app.models-CNxwXyFl.js → _app.models-DpRcGhag.js} +4 -4
- package/public/assets/_app.plugins._pluginId-LzBq-Zjj.js +2 -0
- package/public/assets/{_app.plugins._pluginId-87Ox_hkW.js → _app.plugins._pluginId-sYDTZ9Px.js} +1 -1
- package/public/assets/{_app.settings-DjiMSl1Y.js → _app.settings-BV085FpM.js} +4 -4
- package/public/assets/{_app.usage-CZz9raYR.js → _app.usage-CGuOdYun.js} +3 -3
- package/public/assets/{chevron-right-CPoaXYHw.js → chevron-right-BeVtzzum.js} +1 -1
- package/public/assets/{client-CZnyYbay.js → client-Mf5f5R9Z.js} +1 -1
- package/public/assets/index-3lpol4cr.js +13 -0
- package/public/assets/{login-BtlMmyKj.js → login-BpvnkW6i.js} +2 -2
- package/public/assets/{login-dV42ZQIA.js → login-CwYbEKWH.js} +2 -2
- package/public/assets/plus-nHMFjQ2I.js +1 -0
- package/public/assets/{preload-helper-4wSmu2-E.js → preload-helper-8jyVfd2a.js} +1 -1
- package/public/assets/{shared-OJcoRCqT.js → shared-B2Lmnazz.js} +1 -1
- package/public/assets/{stream-CEb81tzM.js → stream-VJMOV03S.js} +1 -1
- package/public/assets/{trash-2-BjpqTubo.js → trash-2-CbjLfrko.js} +1 -1
- package/public/index.html +7 -7
- package/public/shared/dashboard-sdk.js +1 -1
- package/public/assets/Lamp-ZlMzNs5N.js +0 -25
- package/public/assets/_app.accounts-CLLLwN77.js +0 -59
- package/public/assets/_app.console-Dr9qxU7J.js +0 -44
- package/public/assets/_app.plugins._pluginId-CZWipH1n.js +0 -2
- package/public/assets/index-DNSPtYpM.js +0 -13
- package/public/assets/plus-_zo43Lvf.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{D as e,G as t,N as n,Ot as r,P as i,Ut as a,ht as o,j as s,jt as c,pt as l,st as u,ut as d,zt as f}from"./Lamp-Cxp-OxUq.js";import{C as p,D as m,_ as h,a as g,b as _,g as v,i as y,o as b,r as x,t as S,w as C,x as w}from"./Panel-CYQvfI3L.js";import{b as T,r as E,t as D}from"./Rack-xBT_6EtM.js";import{r as O,t as k}from"./Field-DK5zaBVA.js";import{t as A}from"./Meter-stpt3vQu.js";import{i as j,n as M,r as N,t as P}from"./Table-CVDZ69Zx.js";import{t as F}from"./Readout-D6-aurU8.js";import{n as I}from"./reasons-Du1OBWAM.js";import{useQueryClient as L}from"@tanstack/react-query";import{useCallback as R,useState as z}from"react";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import U from"styled-components";var W=T(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),G=T(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),K=[{id:`keepLatest`,label:`Snapshots kept`,hint:`How many survive regardless of age. The newest is always kept, whatever both numbers say.`,unit:`files`,max:100},{id:`maxAgeDays`,label:`Maximum age`,hint:`Older snapshots are pruned after every new one and on the hourly maintenance sweep.`,unit:`days`,max:3650}],q=U.p`
|
|
2
2
|
font-size: 12px;
|
|
3
3
|
color: ${({theme:e})=>e.color.down};
|
|
4
4
|
`,J=U.p`
|
|
@@ -8,17 +8,17 @@ import{At as e,D as t,Dt as n,G as r,Ht as i,N as a,P as o,Rt as s,ht as c,j as
|
|
|
8
8
|
display: grid;
|
|
9
9
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
10
10
|
gap: ${({theme:e})=>e.space(3)};
|
|
11
|
-
`;function X(e){let t={};for(let n of K){let r=e[n.id].trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<1)return{ok:!1,problem:`${n.label} must be a whole number of 1 or more.`};if(i>n.max)return{ok:!1,problem:`${n.label} cannot exceed ${n.max}.`};t[n.id]=i}return{ok:!0,policy:t}}function Z({retention:
|
|
11
|
+
`;function X(e){let t={};for(let n of K){let r=e[n.id].trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<1)return{ok:!1,problem:`${n.label} must be a whole number of 1 or more.`};if(i>n.max)return{ok:!1,problem:`${n.label} cannot exceed ${n.max}.`};t[n.id]=i}return{ok:!0,policy:t}}function Z({retention:e}){let t=c(),[n,r]=z({}),[i,a]=z(null),[o,s]=z(!1),l={keepLatest:n.keepLatest??(e===void 0?``:String(e.keepLatest)),maxAgeDays:n.maxAgeDays??(e===void 0?``:String(e.maxAgeDays))};return V(S,{legend:`Retention`,actions:V(m,{type:`button`,$size:`sm`,disabled:t.isPending||e===void 0,onClick:()=>{s(!1);let e=X(l);if(!e.ok){a(e.problem);return}a(null),t.mutate(e.policy,{onSuccess:()=>{s(!0),r({})},onError:e=>a(b(e))})},children:t.isPending?`Saving…`:`Save retention`}),children:H(p,{$gap:3,children:[V(Y,{children:K.map(e=>V(k,{label:e.label,hint:e.hint,children:t=>H(_,{$gap:2,children:[V(O,{...t,min:1,max:e.max,step:1,value:l[e.id],onChange:t=>r({...n,[e.id]:t.target.value})}),V(h,{children:e.unit})]})},e.id))}),i===null?null:V(q,{role:`alert`,children:i}),o&&i===null?V(J,{role:`status`,children:`Retention saved.`}):null]})})}function Q(){let e=L();return R(t=>{if(t.adminPasswordChanged){I(`admin-password-changed`);return}e.invalidateQueries()},[e])}var $=U.p`
|
|
12
12
|
font-size: 12px;
|
|
13
13
|
color: ${({theme:e})=>e.color.down};
|
|
14
14
|
`,ee=U.input`
|
|
15
15
|
font-size: 12px;
|
|
16
16
|
color: ${({theme:e})=>e.color.inkDim};
|
|
17
17
|
max-width: 40ch;
|
|
18
|
-
`;function te(){let
|
|
18
|
+
`;function te(){let n=f(),i=u(),a=r(),c=Q(),d=l(),h=o(),[v,T]=z(null),[D,O]=z(null),[A,F]=z(null),[I,L]=z(!1),R=n.data??[],B=H(m,{type:`button`,$variant:`primary`,$size:`sm`,disabled:i.isPending,onClick:()=>i.mutate(),children:[V(W,{}),i.isPending?`Copying…`:`Take a snapshot`]}),U=H(p,{$gap:2,children:[H(_,{$gap:2,$wrap:!0,children:[V(k,{label:`Database file to import`,hint:`A snapshot taken from this or another OmniGateway. It is checked for integrity and rejected if it is not one of ours.`,children:e=>V(ee,{...e,type:`file`,accept:`.sqlite,.db,application/octet-stream`,onChange:e=>F(e.target.files?.[0]??null)})}),V(m,{type:`button`,$variant:`danger`,$size:`sm`,disabled:A===null||h.isPending,onClick:()=>L(!0),children:h.isPending?`Replacing…`:`Import`})]}),h.isError?V($,{role:`alert`,children:b(h.error)}):null,a.isError?V($,{role:`alert`,children:b(a.error)}):null,i.isError?V($,{role:`alert`,children:b(i.error)}):null]});return H(S,{legend:`Snapshots`,meta:`${R.length}`,actions:B,footer:U,flush:!0,children:[n.isError?V(y,{error:n.error,onRetry:()=>void n.refetch()}):n.isLoading?V(`div`,{style:{padding:12},children:V(g,{rows:3})}):R.length===0?V(x,{legend:`No snapshots`,message:`Nothing has been copied yet, so there is nothing to go back to. Take one before a migration or a settings change you are unsure of.`,action:V(m,{type:`button`,$variant:`primary`,$size:`sm`,disabled:i.isPending,onClick:()=>i.mutate(),children:`Take the first snapshot`})}):V(w,{children:H(P,{children:[V(`thead`,{children:H(`tr`,{children:[V(N,{children:`File`}),V(N,{children:`Reason`}),V(N,{$align:`right`,children:`Size`}),V(N,{$align:`right`,children:`Taken`}),V(N,{})]})}),V(`tbody`,{children:R.map(n=>H(j,{children:[V(M,{$mono:!0,children:V(C,{style:{maxWidth:`38ch`,display:`block`},children:n.filename})}),V(M,{children:n.reason}),V(M,{$align:`right`,$mono:!0,children:e(n.sizeBytes)}),V(M,{$align:`right`,$mono:!0,children:s(n.createdAt)}),V(M,{$align:`right`,children:H(_,{$gap:1,$justify:`flex-end`,children:[V(m,{as:`a`,$size:`sm`,href:t(n.id),download:n.filename,children:`Download`}),V(m,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>T(n),children:`Restore`}),V(m,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>O(n),children:`Delete`})]})})]},n.id))})]})}),V(E,{open:v!==null,onOpenChange:e=>{e||T(null)},title:`Restore database`,body:v===null?``:`Replacing the live database with ${v.filename}. Client requests are refused while the file is swapped, and a copy of the current database is taken first so this can be undone. Captured request bodies are not part of a snapshot and are left where they are.`,confirmLabel:`Restore database`,busy:a.isPending,onConfirm:()=>{v!==null&&a.mutate(v.id,{onSuccess:c,onSettled:()=>T(null)})}}),V(E,{open:D!==null,onOpenChange:e=>{e||O(null)},title:`Delete snapshot`,body:D===null?``:`Deleting ${D.filename} from disk. Download it first if it is the copy you would go back to; there is no other one of it.`,confirmLabel:`Delete snapshot`,busy:d.isPending,onConfirm:()=>{D!==null&&d.mutate(D.id,{onSettled:()=>O(null)})}}),V(E,{open:I,onOpenChange:L,title:`Import database`,body:A===null?``:`Replacing the live database with ${A.name}. It is validated before anything is touched, and a copy of the current database is taken first. If the file carries a different admin password, every session ends and you will be asked to sign in again.`,confirmLabel:`Replace database`,busy:h.isPending,onConfirm:()=>{A!==null&&h.mutate(A,{onSuccess:c,onSettled:()=>L(!1)})}})]})}var ne=U.p`
|
|
19
19
|
font-size: 12px;
|
|
20
20
|
color: ${({theme:e})=>e.color.ok};
|
|
21
21
|
`,re=U.p`
|
|
22
22
|
font-size: 12px;
|
|
23
23
|
color: ${({theme:e})=>e.color.down};
|
|
24
|
-
`;function ie(){let
|
|
24
|
+
`;function ie(){let t=d(),r=a(),[o,s]=z(!1),c=t.data,l=c===void 0||c.logicalBytes===0?0:c.freePageBytes/c.logicalBytes;return H(B,{children:[V(D,{legend:`Database`,title:`Storage, snapshots, and retention`,summary:t.isLoading?`Measuring the database…`:`The one SQLite file this gateway runs from, the copies taken of it, and how long they are kept.`}),V(S,{legend:`Size`,meta:c===void 0?void 0:`schema v${c.stats.schemaVersion}`,actions:H(m,{type:`button`,$size:`sm`,disabled:r.isPending||c===void 0,onClick:()=>s(!0),children:[V(G,{}),r.isPending?`Compacting…`:`Compact`]}),footer:r.isError?V(re,{role:`alert`,children:b(r.error)}):r.data===void 0?void 0:V(ne,{role:`status`,children:`Compacted, reclaiming ${e(r.data.reclaimedBytes)} in ${n(r.data.durationMs)}.`}),children:t.isError?V(y,{error:t.error,onRetry:()=>void t.refetch()}):c===void 0?V(g,{rows:3}):H(v,{$min:`180px`,$stretch:!0,children:[V(F,{legend:`Database file`,value:e(c.fileBytes),unit:`${c.stats.pageCount} pages of ${e(c.stats.pageSize)}`,trace:V(A,{fraction:l,label:`${i(l,0)} of the file is reclaimable`})}),V(F,{legend:`Reclaimable`,value:e(c.freePageBytes),unit:`${c.stats.freelistCount} free pages`}),V(F,{legend:`Write-ahead log`,value:e(c.walBytes),unit:`folded into every snapshot`}),V(F,{legend:`Captured bodies`,value:e(c.bodiesBytes),unit:`never in a snapshot`}),V(F,{legend:`Snapshots`,value:e(c.snapshots.totalBytes),unit:`${c.snapshots.count} kept`}),V(F,{legend:`Free disk`,value:e(c.freeDiskBytes),unit:c.freeDiskBytes===null?`not readable here`:`on this filesystem`})]})}),V(te,{}),V(Z,{retention:c?.retention}),V(E,{open:o,onOpenChange:s,title:`Compact database`,body:`Running VACUUM rewrites the database to give back its free pages. It holds the write lock for as long as it takes, so requests in flight will wait, and it needs room on disk for a second copy while it runs.`,confirmLabel:`Compact database`,busy:r.isPending,onConfirm:()=>r.mutate(void 0,{onSettled:()=>s(!1)})})]})}var ae=ie;export{ae as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,F as t,
|
|
1
|
+
import{A as e,F as t,Ht as n,I as r,It as i,N as a,P as o,Wt as s,bt as c,c as l,ct as u,f as d,h as f,i as p,k as m,lt as h,n as g,o as _,p as v,s as y,t as b,u as x,v as ee,x as S,xt as C}from"./Lamp-Cxp-OxUq.js";import{C as w,D as T,S as E,_ as D,b as O,g as k,i as A,r as j,t as M,v as N,w as P,x as F}from"./Panel-CYQvfI3L.js";import{_ as I,f as L,m as R,t as z}from"./Rack-xBT_6EtM.js";import{n as B,t as te}from"./TokenBreakdown-COJ643vg.js";import{n as ne,t as V}from"./Chip-DG-mqRx0.js";import{t as re}from"./Meter-stpt3vQu.js";import{i as H,n as U,r as W,t as G}from"./Table-CVDZ69Zx.js";import{t as K}from"./Readout-D6-aurU8.js";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";var ie=X(P)`
|
|
2
2
|
font-weight: 500;
|
|
3
3
|
display: block;
|
|
4
4
|
max-width: 24ch;
|
|
@@ -15,7 +15,7 @@ import{A as e,F as t,Ft as n,I as r,N as i,P as a,Ut as o,Vt as s,bt as c,c as l
|
|
|
15
15
|
display: flex;
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
gap: 4px;
|
|
18
|
-
`;function se(e){let t=null;for(let n of e)n.stale||n.survives!==!1||n.exhaustsAt===null||(t===null||n.exhaustsAt<t)&&(t=n.exhaustsAt);return t}function ce(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function le({credentials:n,health:r,quota:
|
|
18
|
+
`;function se(e){let t=null;for(let n of e)n.stale||n.survives!==!1||n.exhaustsAt===null||(t===null||n.exhaustsAt<t)&&(t=n.exhaustsAt);return t}function ce(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function le({credentials:n,health:r,quota:i,burn:o,usage:c,quotaPollIntervalMs:u,now:d}){let p=l(r,e=>e.credentialId),m=l(i,e=>e.credentialId),h=l(o,e=>e.credentialId),v=new Map(c.map(e=>[e.key,e])),x={down:0,warn:1,ok:2,idle:3,live:3},S=n.map(e=>{let t=h.get(e.id)??[];return{credential:e,status:y(p.get(e.id)??[],d,e.enabled,e.disabledReason),quota:ee(m.get(e.id)??[]),burn:t,exhaustsAt:se(t),usage:v.get(e.id)}}).sort((e,t)=>x[e.status.state]-x[t.status.state]||ce(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return J(M,{legend:`Accounts`,meta:`${n.length} connected`,flush:!0,actions:J(T,{as:s,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:n.length===0?J(j,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:J(T,{as:s,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):J(F,{children:Y(G,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Account`}),J(W,{children:`Provider`}),J(W,{$align:`right`,children:`Tier`}),J(W,{children:`Quota`}),J(W,{$align:`right`,children:`TTFT`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Last used`})]})}),J(`tbody`,{children:S.map(({credential:n,status:r,quota:i,burn:o,usage:s})=>Y(H,{children:[J(U,{children:Y(O,{$gap:2,children:[J(b,{state:r.state,label:r.note===``?`healthy`:r.note}),Y(`div`,{children:[J(ie,{children:n.label}),r.note===``?null:J(Z,{children:r.note})]})]})}),J(U,{children:J(ne,{provider:n.provider})}),J(U,{$align:`right`,$mono:!0,children:n.tier}),J(U,{children:i.length===0?J(Z,{children:`unknown`}):J(oe,{children:i.map(({window:e,fraction:n})=>Y(ae,{children:[J(re,{fraction:n,label:`${g[e.windowType]} window, ${Math.round(n*100)}% used`}),J(D,{children:f(e,d,u,t,_(o,e.windowType))})]},e.windowType))})}),J(U,{$align:`right`,$mono:!0,children:a(r.ttftMs)}),J(U,{$align:`right`,$mono:!0,children:s===void 0?`—`:e(s.requests)}),J(U,{$align:`right`,$mono:!0,children:t(r.lastUsedAt,d)})]},n.id))})]})})})}var ue=X.ul`
|
|
19
19
|
display: flex;
|
|
20
20
|
flex-direction: column;
|
|
21
21
|
`,de=X.li`
|
|
@@ -35,7 +35,7 @@ import{A as e,F as t,Ft as n,I as r,N as i,P as a,Ut as o,Vt as s,bt as c,c as l
|
|
|
35
35
|
`,pe=X(N)`
|
|
36
36
|
color: ${({theme:e})=>e.color.down};
|
|
37
37
|
font-size: 11px;
|
|
38
|
-
`;function me({logs:e}){let t=e.slice(0,12);return J(M,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:J(T,{as:
|
|
38
|
+
`;function me({logs:e}){let t=e.slice(0,12);return J(M,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:J(T,{as:s,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?J(j,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):J(ue,{children:t.map(e=>Y(de,{children:[J(b,{state:v(e),label:d(e)}),J(N,{$dim:!0,children:m(e.at)}),J(fe,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:J(N,{$dim:!0,style:{color:R(e.resolvedProvider)},children:e.resolvedProvider}),J(E,{}),x(e)?J(N,{$dim:!0,"aria-label":`processing`,children:J(te,{})}):Y(q,{children:[e.errorCode===null?null:J(pe,{children:e.errorCode}),e.attempts>1?Y(N,{$dim:!0,children:[e.attempts,`×`]}):null,J(N,{$dim:!0,children:J(B,{tokens:e})}),J(N,{$dim:!0,children:a(e.durationMs)}),J(N,{$dim:!0,children:r(e.costUsd)})]})]},e.id))})})}var Q=X.ul`
|
|
39
39
|
display: flex;
|
|
40
40
|
flex-direction: column;
|
|
41
41
|
gap: ${({theme:e})=>e.space(3)};
|
|
@@ -55,8 +55,8 @@ import{A as e,F as t,Ft as n,I as r,N as i,P as a,Ut as o,Vt as s,bt as c,c as l
|
|
|
55
55
|
opacity: 0.8;
|
|
56
56
|
`,ve=X.div`
|
|
57
57
|
flex: ${({$grow:e})=>e} 0 0;
|
|
58
|
-
`;function ye({models:t,logs:n}){let i=new Map;for(let e of n){let t=i.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,i.set(e.requestedModel,t)}let a=Math.max(1,...[...i.values()].map(e=>e.requests)),
|
|
58
|
+
`;function ye({models:t,logs:n}){let i=new Map;for(let e of n){let t=i.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,i.set(e.requestedModel,t)}let a=Math.max(1,...[...i.values()].map(e=>e.requests)),o=[...t].map(e=>({model:e,used:i.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return J(M,{legend:`Models`,meta:`${t.length} configured`,actions:J(T,{as:s,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.length===0?J(j,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:J(T,{as:s,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):J(Q,{children:o.map(({model:t,used:n})=>{let i=(n?.requests??0)/a,o=[...new Set(t.targets.map(e=>e.provider))];return Y(`li`,{children:[Y(O,{$gap:2,children:[J(he,{title:t.id,children:t.id}),t.isAlias?J(V,{children:`alias`}):null,J(V,{$tone:`accent`,children:t.strategy}),J(E,{}),J(N,{$dim:!0,children:e(n?.requests??0)}),J(D,{children:`req`}),J(N,{$dim:!0,children:r(n?.costUsd??0)})]}),Y(ge,{style:{marginTop:6},title:`${Math.round(i*100)}% of the busiest model`,children:[o.map(e=>J(_e,{$color:R(e),$grow:i/o.length},e)),J(ve,{$grow:Math.max(0,1-i)})]})]},t.id)})})})}var be=X.div`
|
|
59
59
|
display: grid;
|
|
60
60
|
grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
|
|
61
61
|
gap: ${({theme:e})=>e.space(3)};
|
|
62
|
-
`;function xe({logs:t,windowMs:n,now:
|
|
62
|
+
`;function xe({logs:t,windowMs:n,now:i}){let s=t.filter(e=>i-e.at<=n),c=S(s,n),l=p(s,{now:i,spanMs:n,count:32}),u=c.errorRate>=.25?`down`:c.errorRate>=.05?`warn`:`ok`,d=c.inputTokens+c.outputTokens+c.cacheReadTokens+c.cacheWriteTokens;return Y(be,{children:[J(K,{legend:`Requests`,value:e(c.requests),unit:`${c.ratePerMin.toFixed(1)}/min`,trace:J(L,{values:l.map(e=>e.total),overlay:l.map(e=>e.errors),label:`${c.requests} requests, ${c.errors} of them failed`})}),J(K,{legend:`Error rate`,value:o(c.errorRate),unit:`${e(c.errors)} failed`,tone:c.requests===0?`ink`:u,trace:J(L,{values:l.map(e=>e.errors),scaleTo:Math.max(...l.map(e=>e.total)),color:`var(--down)`,label:`${c.errors} failed requests against ${c.requests} total`})}),J(K,{legend:`Total tokens`,value:e(d),unit:J(B,{tokens:c}),trace:J(L,{values:l.map(e=>e.tokens),label:`token volume over the window, ${d.toLocaleString(`en-US`)} total`})}),J(K,{legend:`Time to first token`,value:a(c.ttftP50),unit:`p95 ${a(c.ttftP95)}`,trace:J(L,{values:l.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${a(c.ttftP50)}`})}),J(K,{legend:`Spend`,value:r(c.costUsd),unit:`${e(c.inputTokens+c.outputTokens)} tokens`,trace:J(L,{values:l.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${r(c.costUsd)} total`})})]})}var $=36e5;function Se(){let{cadence:e}=I(),t=h(),r=u(e(1e4,`res:credentials`)),a=C(),o=c(500,e(1e4,`res:logs`)),s=i(),d=Date.now(),f=Math.floor((d-$)/6e4)*6e4,p=n({groupBy:`credential`,since:f},e(6e4,`res:usage`)),m=t.data??[],g=l(r.data?.health??[],e=>e.credentialId),_=m.filter(e=>y(g.get(e.id)??[],d,e.enabled,e.disabledReason).state===`down`),v=t.isLoading||o.isLoading?`Reading the gateway…`:m.length===0?`No accounts are connected, so every request fails at the router.`:_.length>0?`${_.length} account${_.length===1?` is`:`s are`} out of rotation.`:`All ${m.length} accounts are answering. Nothing needs attention.`;return Y(q,{children:[J(z,{legend:`Rack`,title:`Gateway`,summary:v}),o.isError?J(M,{legend:`Traffic`,children:J(A,{legend:`The gateway did not answer`,error:o.error,onRetry:()=>void o.refetch()})}):Y(w,{$gap:4,children:[J(xe,{logs:o.data??[],windowMs:$,now:d}),J(le,{credentials:m,health:r.data?.health??[],quota:r.data?.quota??[],burn:r.data?.burn??[],usage:p.data??[],quotaPollIntervalMs:s.data?.quotaPollIntervalMs??3e5,now:d}),Y(k,{$min:`340px`,$gap:4,children:[J(ye,{models:a.data??[],logs:o.data??[]}),J(me,{logs:o.data??[]})]})]})]})}var Ce=Se;export{Ce as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Nt as e,Pt as t,gt as n,j as r,kt as i,ot as a,xt as o}from"./Lamp-Cxp-OxUq.js";import{C as s,D as c,O as l,_ as u,a as d,b as f,i as p,o as m,r as h,t as g,v as _,w as v,x as y}from"./Panel-CYQvfI3L.js";import{b,i as x,r as S,t as C,v as w}from"./Rack-xBT_6EtM.js";import{t as T}from"./CopyValue-CItB094V.js";import{n as E,t as D}from"./chevron-right-BeVtzzum.js";import{t as O}from"./plus-nHMFjQ2I.js";import{t as k}from"./Toggle-CmXXn6F3.js";import{t as A}from"./Chip-DG-mqRx0.js";import{n as j,r as M,t as N}from"./Field-DK5zaBVA.js";import{t as P}from"./Meter-stpt3vQu.js";import{i as F,n as I,r as L,t as ee}from"./Table-CVDZ69Zx.js";import{Fragment as R,useState as z}from"react";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import U from"styled-components";var te=b(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),W=[{dimension:`requests`,window:`1m`},{dimension:`requests`,window:`5h`},{dimension:`requests`,window:`1w`},{dimension:`tokens`,window:`1m`},{dimension:`tokens`,window:`5h`},{dimension:`tokens`,window:`1w`},{dimension:`spend`,window:`5h`},{dimension:`spend`,window:`1w`},{dimension:`concurrency`,window:null}];function G(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var ne={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},re={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=ne[e.dimension];return e.window===null?t:`${t} ${re[e.window]}`}function q(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function J(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function ie(e){let t=null,n=-1;for(let r of e){let e=J(r);e!==null&&e>n&&(t=r,n=e)}return t}function Y(e){let t={};for(let e of W)t[G(e)]=``;if(e===null)return t;for(let n of W){let r=n.window===null?e.concurrency:n.dimension===`requests`?e.requests?.[n.window]:n.dimension===`tokens`?e.tokens?.[n.window]:n.window===`1m`?void 0:e.spend?.[n.window];r!=null&&(t[G(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of W){let o=(e[G(a)]??``).trim();if(o.length===0)continue;let s=Number(o),c=a.dimension===`spend`;if(!Number.isFinite(s)||s<=0||!c&&!Number.isInteger(s))return{problem:c?`${K(a)} must be an amount above zero, or blank for no limit.`:`${K(a)} must be a whole number above zero, or blank for no limit.`};a.window===null?i=s:a.dimension===`requests`?t[a.window]=s:a.dimension===`tokens`?n[a.window]=s:a.window!==`1m`&&(r[a.window]=s)}return{limits:{...Object.keys(t).length>0?{requests:t}:{},...Object.keys(n).length>0?{tokens:n}:{},...Object.keys(r).length>0?{spend:r}:{},...i===void 0?{}:{concurrency:i}}}}var ae=U.div`
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
4
4
|
gap: ${({theme:e})=>e.space(2)};
|
|
@@ -79,4 +79,4 @@ import{Mt as e,Nt as t,Ot as n,gt as r,j as i,ot as a,xt as o}from"./Lamp-ZlMzNs
|
|
|
79
79
|
flex-direction: column;
|
|
80
80
|
align-items: flex-end;
|
|
81
81
|
gap: 2px;
|
|
82
|
-
`;function Oe(e){if(e===null)return`usage not counted here`;let t=J(e);return`${K({dimension:e.dimension,window:e.window})} ${q(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ke(){let e=
|
|
82
|
+
`;function Oe(e){if(e===null)return`usage not counted here`;let t=J(e);return`${K({dimension:e.dimension,window:e.window})} ${q(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ke(){let e=n(),t=i(),[a,o]=z(!1),[s,m]=z(null),[_,b]=z(null),[x,T]=z(null),[k,j]=z(null),M=e.data??[],N=M.filter(e=>e.revokedAt===null),P=e.isLoading?`Reading issued keys…`:M.length===0?`No keys exist, so nothing can call this gateway yet.`:`${N.length} active key${N.length===1?``:`s`} of ${M.length} ever issued.`;return H(B,{children:[V(C,{legend:`Keys`,title:`Gateway API keys`,summary:P,actions:H(c,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[V(O,{}),`Create a key`]})}),V(g,{legend:`Issued keys`,meta:`${M.length}`,flush:!0,children:e.isError?V(p,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?V(`div`,{style:{padding:12},children:V(d,{rows:4})}):M.length===0?V(h,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:V(c,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):V(y,{children:H(ee,{children:[V(`thead`,{children:H(`tr`,{children:[V(L,{children:`Label`}),V(L,{children:`Prefix`}),V(L,{children:`Allowed models`}),V(L,{$align:`right`,children:`Limits`}),V(L,{$align:`right`,children:`Created`}),V(L,{children:`Body capture`}),V(L,{children:`Status`}),V(L,{})]})}),V(`tbody`,{children:M.map(e=>{let t=x===e.id,n=ie(e.limitUsage);return H(R,{children:[H(F,{children:[V(I,{children:V(v,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),H(I,{$mono:!0,children:[e.prefix,`…`]}),V(I,{children:e.modelAllowlist===null?V(u,{children:`every model`}):e.modelAllowlist.length===0?V(A,{$tone:`down`,children:`no models`}):V(we,{children:e.modelAllowlist.map(e=>V(A,{children:e},e))})}),V(I,{$align:`right`,children:e.limits===null?V(A,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?V(u,{children:`no limits`}):H(De,{children:[H(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),V(Ee,{children:Oe(n)})]})}),V(I,{$align:`right`,$mono:!0,children:r(e.createdAt)}),V(I,{children:e.bodyLoggingOptOut?V(A,{children:`no bodies`}):V(u,{children:`—`})}),V(I,{children:e.revokedAt===null?V(A,{$tone:`ok`,children:`active`}):V(Te,{title:r(e.revokedAt),children:V(A,{children:`revoked`})})}),V(I,{$align:`right`,children:H(f,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} limits for ${e.label}`,title:`${t?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>T(t?null:e.id),children:V(t?E:D,{})}),e.revokedAt===null?H(B,{children:[V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>b(e),children:V(te,{})}),V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>m(e),children:V(w,{})}),V(c,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>j(e),children:`Revoke`})]}):null]})})]}),t?V(F,{children:V(I,{colSpan:8,children:V(ve,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),V(Ce,{open:a,onOpenChange:o}),V(le,{apiKey:s,onOpenChange:e=>{e||m(null)}},s?.id??`none`),V(me,{apiKey:_,onOpenChange:e=>{e||b(null)}},_?.id??`none`),V(S,{open:k!==null,onOpenChange:e=>{e||j(null)},title:`Revoke key`,body:k===null?``:`Revoking "${k.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:t.isPending,onConfirm:()=>{k!==null&&t.mutate(k.id,{onSettled:()=>j(null)})}})]})}var Ae=ke;export{Ae as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,B as t,
|
|
1
|
+
import{A as e,B as t,Et as n,bt as r,gt as i,l as a,lt as o,q as s,u as c}from"./Lamp-Cxp-OxUq.js";import{C as l,D as u,_ as d,a as f,b as p,i as m,r as h,t as g,x as _}from"./Panel-CYQvfI3L.js";import{_ as v,i as y,t as b}from"./Rack-xBT_6EtM.js";import{t as x}from"./Chip-DG-mqRx0.js";import{i as S,n as C}from"./Field-DK5zaBVA.js";import{i as w,n as T,r as E,t as D}from"./RequestTable-CM9mPiMF.js";import{useMemo as O,useState as k}from"react";import{Fragment as A,jsx as j,jsxs as M}from"react/jsx-runtime";import N from"styled-components";var P={none:{legend:`Not captured`,message:`Body capture was not running for this request. It needs OMNI_BODY_LOGGING_ALLOWED in the environment and the body logging setting turned on, and the calling key must not have opted out.`},missing:{legend:`Captured, then lost`,message:`This request was captured, but its artifact is no longer on disk. Retention or the row cap has since pruned it, or something removed the file underneath the gateway.`},corrupt:{legend:`Captured, but unreadable`,message:`This request was captured and the artifact is still on disk, but it failed its checksum or would not decrypt. Changing OMNI_ENCRYPTION_KEY invalidates every artifact written under the old one.`}},F=new Intl.NumberFormat(`en-US`),I=N.p`
|
|
2
2
|
font-size: 12px;
|
|
3
3
|
color: ${({theme:e})=>e.color.inkDim};
|
|
4
4
|
max-width: 62ch;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{At as e,E as t,H as n,It as r,ft as i,lt as a,mt as o,wt as s,xt as c}from"./Lamp-Cxp-OxUq.js";import{C as l,D as u,O as d,S as f,_ as p,a as m,b as h,i as g,o as _,r as v,t as y,v as b,w as x}from"./Panel-CYQvfI3L.js";import{b as S,m as C,r as w,t as T}from"./Rack-xBT_6EtM.js";import{t as E}from"./plus-nHMFjQ2I.js";import{t as D}from"./trash-2-CbjLfrko.js";import{t as O}from"./Toggle-CmXXn6F3.js";import{n as ee,t as k}from"./Chip-DG-mqRx0.js";import{i as A,n as j,r as M,t as N}from"./Field-DK5zaBVA.js";import{t as P}from"./Meter-stpt3vQu.js";import{useEffect as te,useId as ne,useState as F}from"react";import{Fragment as I,jsx as L,jsxs as R}from"react/jsx-runtime";import z from"styled-components";var re=S(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),ie=S(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),B=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ae={tier:`How preferred this tier is`,health:`Consecutive failures and breaker state`,quota:`Headroom in the tightest window, against how much of it is left`,cost:`Price of this request against the other candidates`,latency:`Observed time to first token`,load:`Requests in flight on this pair right now`},oe=z.li`
|
|
2
2
|
padding: ${({theme:e})=>e.space(2)} 0;
|
|
3
3
|
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
4
4
|
|
|
@@ -46,7 +46,7 @@ import{Ct as e,E as t,Ft as n,H as r,ft as i,kt as a,lt as o,mt as s,xt as c}fro
|
|
|
46
46
|
`,me=z.p`
|
|
47
47
|
font-size: 12px;
|
|
48
48
|
color: ${({theme:e})=>e.color.down};
|
|
49
|
-
`;function H(e,t,n){return(e[t]??0)*n[t]}function he({modelId:e}){let[t,
|
|
49
|
+
`;function H(e,t,n){return(e[t]??0)*n[t]}function he({modelId:e}){let[t,n]=F({tools:!1,images:!1,reasoning:!1}),[i,a]=F(null),[s,c]=F(null),d=r(),m=o(),g=d.data?.weights,S=()=>{e!==null&&(c(null),m.mutate({modelId:e,need:t},{onSuccess:e=>a(e),onError:e=>{a(null),c(_(e))}}))},C=new Map(B.map(e=>[e,Math.max(1e-4,...(i?.candidates??[]).map(t=>g===void 0?0:Math.abs(H(t.reasons,e,g))))]));return L(y,{legend:`Explain`,meta:e??`no model selected`,actions:R(u,{type:`button`,$size:`sm`,$variant:`primary`,disabled:e===null||m.isPending,onClick:S,children:[L(re,{}),m.isPending?`Ranking…`:`Rank candidates`]}),children:R(l,{$gap:3,children:[R(l,{$gap:1,children:[L(p,{children:`Pretend the request needs`}),R(pe,{children:[R(V,{children:[L(O,{checked:t.tools,label:`Probe request uses tools`,onCheckedChange:e=>n({...t,tools:e})}),`Tools`]}),R(V,{children:[L(O,{checked:t.images,label:`Probe request includes an image`,onCheckedChange:e=>n({...t,images:e})}),`Images`]}),R(V,{children:[L(O,{checked:t.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>n({...t,reasoning:e})}),`Reasoning`]})]})]}),s===null?null:L(me,{children:s}),i===null?L(v,{legend:`Not ranked yet`,message:e===null?`Select a model to see which account the router would pick for it.`:`Run the ranking to see which account wins, by how much, and what was filtered out.`}):R(l,{$gap:3,children:[R(h,{$gap:2,$wrap:!0,children:[L(k,{$tone:`accent`,children:i.strategy}),i.deterministic?null:L(k,{$tone:`warn`,children:`order varies per request`}),L(f,{}),R(p,{children:[i.candidates.length,` eligible · `,i.excluded.length,` filtered out`]})]}),i.candidates.length===0?L(v,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):L(`ul`,{children:i.candidates.map((e,t)=>R(oe,{children:[R(h,{$gap:2,children:[L(se,{children:t+1}),L(ee,{provider:e.provider}),L(x,{style:{maxWidth:`22ch`},children:e.credentialLabel}),L(b,{$dim:!0,children:e.model}),R(k,{children:[`tier `,e.tier]}),L(f,{}),t===0?L(ce,{children:`would be used`}):null,L(b,{children:e.score.toFixed(2)})]}),g===void 0?null:L(le,{children:B.map(t=>{let n=H(e.reasons,t,g),r=C.get(t)??1;return R(ue,{title:ae[t],children:[R(de,{children:[L(p,{children:t}),L(b,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),L(P,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${t} contributes ${n.toFixed(2)} of ${e.score.toFixed(2)}`})]},t)})})]},`${e.credentialId}:${e.model}`))}),i.excluded.length===0?null:R(l,{$gap:1,children:[L(p,{children:`Filtered out`}),L(`ul`,{children:i.excluded.map(e=>R(fe,{children:[L(b,{$dim:!0,children:e.model}),L(b,{$dim:!0,children:e.credentialId}),L(f,{}),L(k,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}function U(e,t,r){return n(e,t)?.models.find(e=>e.id===r)}function W(e,t,r){let i=n(e,t);return i===void 0?null:i.models.find(e=>e.id===r)?.auth??i.authTypes}var G=[{id:`score`,label:`Best score`,blurb:`Rank every eligible target by the routing weights and take the best one.`},{id:`priority`,label:`Lowest tier`,blurb:`Always prefer the lowest tier. Score only breaks ties inside a tier.`},{id:`roundRobin`,label:`Round robin`,blurb:`Take whichever eligible target has been idle longest, to spread load evenly.`},{id:`weighted`,label:`Weighted draw`,blurb:`Pick at random, biased by weight. The order differs from request to request.`}],K=0;function q(){return K+=1,`target-${K}`}function J(e,t,n){let r=U(e,t,n)?.pricing;return r===void 0?null:{costInput:String(r.input),costOutput:String(r.output),costCacheRead:String(r.cacheRead),costCacheWrite5m:String(r.cacheWrite5m),costCacheWrite1h:String(r.cacheWrite1h)}}function ge(e,t,n){let r=U(e,t,n)?.limits;return r===void 0?null:{contextWindow:String(r.contextWindow),maxOutputTokens:String(r.maxOutputTokens)}}var _e={oauth:`OAuth`,apiKey:`an API key`};function Y(e){return e.map(e=>_e[e]).join(` or `)}function ve(e){let t=Object.create(null);for(let n of e){let e=t[n.provider]??[];e.includes(n.authType)||e.push(n.authType),t[n.provider]=e}return t}function X(e,t,n,r){let i=r[t];if(i===void 0||i.length===0)return!0;let a=W(e,t,n);return a===null||a.some(e=>i.includes(e))}function ye(e,t,r){let i=n(e,t);return i===void 0?[]:i.models.filter(n=>X(e,t,n.id,r))}function be(e,t,n,r){if(n.trim().length===0||X(e,t,n,r))return null;let i=r[t]??[];return`${t} serves this model to ${Y(W(e,t,n)??[])} only, and every ${t} account here is ${Y(i)}. Requests routed here will fail.`}function xe(e,n){let r={provider:e.provider,endpointId:e.endpointId};return n.filter(e=>t(r,e)).map(e=>({id:e.id,label:e.accountEmail??e.label}))}function Se(e,t,n){return e.length===0||n.length===0||xe(t,n).some(t=>t.id===e)?null:`No connected account has this id. Requests routed here will fail rather than falling back to another account.`}function Ce(e,t){return{...e,endpointId:t,...t===e.endpointId?{}:{credentialId:``}}}function we(e,t,n){return{...t,...n,...J(e,n.provider,n.model)??{},...n.provider===t.provider?{}:{credentialId:``},contextWindow:``,maxOutputTokens:``}}function Te(e,t){let r=t??e[0]?.id??`anthropic`,i=n(e,r)?.defaultModel??``,a=J(e,r,i);return{key:q(),provider:r,endpointId:``,model:i,tier:`1`,weight:`1`,costInput:a?.costInput??`0`,costOutput:a?.costOutput??`0`,costCacheRead:a?.costCacheRead??``,costCacheWrite5m:a?.costCacheWrite5m??``,costCacheWrite1h:a?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,credentialId:``,tools:!0,images:!0,reasoning:!0}}function Ee(e){return{id:``,strategy:`score`,isAlias:!1,targets:[Te(e)]}}function De(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:q(),provider:e.provider,endpointId:e.provider===`custom`?e.endpointId??``:``,model:e.model,tier:String(e.tier),weight:String(e.weight),costInput:String(e.costPerMTok.input),costOutput:String(e.costPerMTok.output),costCacheRead:e.costPerMTok.cacheRead===void 0?``:String(e.costPerMTok.cacheRead),costCacheWrite5m:e.costPerMTok.cacheWrite5m===void 0?``:String(e.costPerMTok.cacheWrite5m),costCacheWrite1h:e.costPerMTok.cacheWrite1h===void 0?``:String(e.costPerMTok.cacheWrite1h),contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),maxOutputTokens:e.maxOutputTokens===void 0?``:String(e.maxOutputTokens),credentialId:e.credentialId??``,tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function Oe(e){let t=e.id.trim();if(t.length===0)return{ok:!1,problem:`Give the model a name clients will ask for.`};if(e.targets.length===0)return{ok:!1,problem:`A model needs at least one target to route to.`};let n=[];for(let[t,r]of e.targets.entries()){let e=`Target ${t+1}`,i=r.endpointId.trim(),a=r.credentialId.trim();if(r.provider===`custom`&&i.length===0)return{ok:!1,problem:`${e} needs a custom endpoint.`};let o=r.model.trim();if(o.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let s=Number(r.tier);if(!Number.isInteger(s)||s<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let c=Number(r.weight);if(!Number.isFinite(c)||c<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let l=Number(r.costInput),u=Number(r.costOutput);if(!Number.isFinite(l)||l<0||!Number.isFinite(u)||u<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let d=r.costCacheRead.trim().length>0,f=Number(r.costCacheRead);if(d&&(!Number.isFinite(f)||f<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let p=r.costCacheWrite5m.trim().length>0,m=Number(r.costCacheWrite5m);if(p&&(!Number.isFinite(m)||m<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let h=r.costCacheWrite1h.trim().length>0,g=Number(r.costCacheWrite1h);if(h&&(!Number.isFinite(g)||g<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let _=r.contextWindow.trim().length>0,v=Number(r.contextWindow);if(_&&(!Number.isInteger(v)||v<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let y=r.maxOutputTokens.trim().length>0,b=Number(r.maxOutputTokens);if(y&&(!Number.isInteger(b)||b<1))return{ok:!1,problem:`${e}: the output limit must be a whole number of tokens.`};n.push({provider:r.provider,...r.provider===`custom`?{endpointId:i}:{},model:o,tier:s,weight:c,costPerMTok:{input:l,output:u,...d?{cacheRead:f}:{},...p?{cacheWrite5m:m}:{},...h?{cacheWrite1h:g}:{}},..._?{contextWindow:v}:{},...y?{maxOutputTokens:b}:{},...a.length>0?{credentialId:a}:{},capabilities:{tools:r.tools,images:r.images,reasoning:r.reasoning}})}return{ok:!0,model:{id:t,strategy:e.strategy,isAlias:e.isAlias,targets:n}}}var ke=z.fieldset`
|
|
50
50
|
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
51
51
|
border-left: 3px solid ${({$provider:e})=>C(e)};
|
|
52
52
|
border-radius: ${({theme:e})=>e.radius.control};
|
|
@@ -88,7 +88,7 @@ import{Ct as e,E as t,Ft as n,H as r,ft as i,kt as a,lt as o,mt as s,xt as c}fro
|
|
|
88
88
|
align-items: center;
|
|
89
89
|
gap: 6px;
|
|
90
90
|
cursor: pointer;
|
|
91
|
-
`;function Pe({target:e,index:t,onChange:
|
|
91
|
+
`;function Pe({target:e,index:t,onChange:r,onRemove:i,removable:a,catalog:o,endpoints:s,held:c,credentials:m}){let g=ne(),_=n(o,e.provider),v=ye(o,e.provider,c),y=be(o,e.provider,e.model,c),b=xe(e,m),x=Se(e.credentialId,e,m),S=(t,n)=>{r({...e,[t]:n})},C=J(o,e.provider,e.model),w=ge(o,e.provider,e.model),T=t=>{r(we(o,e,t))};return R(ke,{$provider:e.provider,children:[R(h,{$gap:2,children:[R(p,{as:`legend`,children:[`Target `,t+1]}),L(f,{}),L(d,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!a,"aria-label":`Remove target ${t+1}`,title:a?`Remove target ${t+1}`:`A model needs at least one target`,onClick:i,children:L(D,{})})]}),R(Ae,{children:[R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-provider`,children:`Provider`}),R(A,{id:`${g}-provider`,value:e.provider,onChange:t=>{let r=t.target.value,i=n(o,r),a=i?.models.some(t=>t.id===e.model)??!1;T({provider:r,model:a?e.model:i?.defaultModel??``})},children:[o.map(e=>L(`option`,{value:e.id,children:e.label},e.id)),_===void 0?R(`option`,{value:e.provider,children:[e.provider,` (not in the catalog)`]}):null]})]}),e.provider===`custom`?R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-endpoint`,children:`Endpoint`}),R(A,{id:`${g}-endpoint`,value:e.endpointId,onChange:t=>r(Ce(e,t.target.value)),children:[L(`option`,{value:``,children:`Choose endpoint`}),s.map(e=>L(`option`,{value:e.id,children:e.label},e.id))]})]}):null,R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-model`,children:`Provider model`}),L(j,{id:`${g}-model`,list:`${g}-catalog`,value:e.model,placeholder:_?.defaultModel??``,onChange:t=>T({provider:e.provider,model:t.target.value})}),L(`datalist`,{id:`${g}-catalog`,children:v.map(e=>L(`option`,{value:e.id,children:e.label},e.id))}),y===null?null:L(Ne,{role:`note`,children:y})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-tier`,children:`Tier`}),L(M,{id:`${g}-tier`,min:1,step:1,value:e.tier,onChange:e=>S(`tier`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-weight`,children:`Weight`}),L(M,{id:`${g}-weight`,min:0,step:.1,value:e.weight,onChange:e=>S(`weight`,e.target.value)})]})]}),L(l,{$gap:1,children:R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-account`,children:`Account`}),R(A,{id:`${g}-account`,value:e.credentialId,onChange:e=>S(`credentialId`,e.target.value),children:[L(`option`,{value:``,children:`Any account`}),b.map(e=>L(`option`,{value:e.id,children:e.label},e.id)),x===null?null:R(`option`,{value:e.credentialId,children:[e.credentialId,` (removed)`]})]}),x===null?null:L(Ne,{role:`note`,children:x})]})}),R(l,{$gap:1,children:[R(h,{$gap:2,children:[L(p,{children:`Price per million tokens`}),L(f,{}),C===null?L(p,{as:`span`,children:`not in the catalog — price it yourself`}):R(u,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:e.costInput===C.costInput&&e.costOutput===C.costOutput&&e.costCacheRead===C.costCacheRead&&e.costCacheWrite5m===C.costCacheWrite5m&&e.costCacheWrite1h===C.costCacheWrite1h,onClick:()=>r({...e,...C}),children:[L(ie,{}),`Use list price`]})]}),R(je,{children:[R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-in`,children:`Input`}),L(M,{id:`${g}-in`,min:0,step:.01,value:e.costInput,onChange:e=>S(`costInput`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-out`,children:`Output`}),L(M,{id:`${g}-out`,min:0,step:.01,value:e.costOutput,onChange:e=>S(`costOutput`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-cache`,children:`Cache read`}),L(M,{id:`${g}-cache`,min:0,step:.01,placeholder:`same as input`,value:e.costCacheRead,onChange:e=>S(`costCacheRead`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-write5m`,children:`Cache write 5m`}),L(M,{id:`${g}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:e.costCacheWrite5m,onChange:e=>S(`costCacheWrite5m`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-write1h`,children:`Cache write 1h`}),L(M,{id:`${g}-write1h`,min:0,step:.01,placeholder:`2x input`,value:e.costCacheWrite1h,onChange:e=>S(`costCacheWrite1h`,e.target.value)})]})]})]}),R(l,{$gap:1,children:[R(h,{$gap:2,children:[L(p,{children:`Token limits`}),L(f,{}),w===null?L(p,{as:`span`,children:`not in the catalog — state them yourself`}):L(p,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),R(je,{children:[R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-context`,children:`Context window`}),L(M,{id:`${g}-context`,min:1,step:1024,placeholder:w?.contextWindow??`published`,value:e.contextWindow,onChange:e=>S(`contextWindow`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-maxout`,children:`Max output`}),L(M,{id:`${g}-maxout`,min:1,step:1024,placeholder:w?.maxOutputTokens??`published`,value:e.maxOutputTokens,onChange:e=>S(`maxOutputTokens`,e.target.value)})]})]})]}),R(l,{$gap:1,children:[L(p,{children:`Capabilities`}),R(Me,{children:[R(Q,{children:[L(O,{checked:e.tools,label:`Target ${t+1} supports tools`,onCheckedChange:e=>S(`tools`,e)}),`Tools`]}),R(Q,{children:[L(O,{checked:e.images,label:`Target ${t+1} supports images`,onCheckedChange:e=>S(`images`,e)}),`Images`]}),R(Q,{children:[L(O,{checked:e.reasoning,label:`Target ${t+1} supports reasoning`,onCheckedChange:e=>S(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Fe=z.p`
|
|
92
92
|
font-size: 11.5px;
|
|
93
93
|
color: ${({theme:e})=>e.color.inkDim};
|
|
94
94
|
`,Ie=z.p`
|
|
@@ -99,7 +99,7 @@ import{Ct as e,E as t,Ft as n,H as r,ft as i,kt as a,lt as o,mt as s,xt as c}fro
|
|
|
99
99
|
color: ${({theme:e})=>e.color.ok};
|
|
100
100
|
`,Re=z(h)`
|
|
101
101
|
gap: 8px;
|
|
102
|
-
`;function ze({model:t,onSaved:n,onDeleted:r}){let s
|
|
102
|
+
`;function ze({model:t,onSaved:n,onDeleted:r}){let o=s().data??[],[c,d]=F(()=>t===null?Ee(o):De(t)),[m,g]=F(null),[v,b]=F(!1),[x,S]=F(!1),C=e(),T=i(),D=a(),ee=ve(D.data??[]),k=(D.data??[]).filter(e=>e.provider===`custom`).map(e=>({id:String(e.providerData.endpointId??``),label:String(e.providerData.endpointLabel??e.providerData.endpointId??``)})).filter((e,t,n)=>e.id.length>0&&n.findIndex(t=>t.id===e.id)===t),M=t?.id??null;te(()=>{d(t===null?Ee(o):De(t)),g(null),b(!1)},[M]);let P=G.find(e=>e.id===c.strategy);return R(I,{children:[L(y,{legend:t===null?`New model`:`Edit model`,meta:t===null?void 0:t.id,actions:R(I,{children:[t===null?null:L(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>S(!0),children:`Delete`}),L(u,{type:`button`,$variant:`primary`,$size:`sm`,disabled:C.isPending,onClick:()=>{b(!1);let e=Oe(c);if(!e.ok){g(e.problem);return}g(null),C.mutate(e.model,{onSuccess:()=>{b(!0),n(e.model.id)},onError:e=>g(_(e))})},children:C.isPending?`Saving…`:t===null?`Create model`:`Save changes`})]}),children:R(l,{$gap:3,children:[L(N,{label:`Model name`,hint:t===null?`What clients send as the model. Anything not listed here is rejected.`:`Fixed once created. To rename, create a model under the new name and delete this one.`,children:e=>L(j,{...e,value:c.id,disabled:t!==null,placeholder:`fast`,onChange:e=>d({...c,id:e.target.value})})}),L(N,{label:`Routing strategy`,children:e=>L(A,{...e,value:c.strategy,onChange:e=>d({...c,strategy:e.target.value}),children:G.map(e=>L(`option`,{value:e.id,children:e.label},e.id))})}),P===void 0?null:L(Fe,{children:P.blurb}),R(Re,{children:[L(O,{checked:c.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>d({...c,isAlias:e})}),R(l,{$gap:0,children:[L(p,{as:`span`,children:`Alias`}),L(Fe,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),R(l,{$gap:2,children:[R(h,{children:[L(p,{children:`Targets`}),L(f,{}),R(u,{type:`button`,$size:`sm`,onClick:()=>d({...c,targets:[...c.targets,Te(o,c.targets.at(-1)?.provider)]}),children:[L(E,{}),`Add target`]})]}),c.targets.map((e,t)=>L(Pe,{target:e,index:t,removable:c.targets.length>1,catalog:o,endpoints:k,held:ee,credentials:D.data??[],onChange:t=>d({...c,targets:c.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>d({...c,targets:c.targets.filter(t=>t.key!==e.key)})},e.key))]}),m===null?null:L(Ie,{role:`alert`,children:m}),v&&m===null?L(Le,{role:`status`,children:`Saved.`}):null]})}),L(w,{open:x,onOpenChange:S,title:`Delete model`,body:t===null?``:`Deleting "${t.id}" makes it unroutable. Clients asking for it will get a model-unavailable error, and any key allowlisting it keeps a name that no longer resolves.`,confirmLabel:`Delete model`,busy:T.isPending,onConfirm:()=>{t!==null&&T.mutate(t.id,{onSuccess:()=>{S(!1),r()},onError:e=>{S(!1),g(_(e))}})}})]})}var Be=z.div`
|
|
103
103
|
display: grid;
|
|
104
104
|
grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
|
|
105
105
|
gap: ${({theme:e})=>e.space(4)};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/_app.plugins._pluginId-sYDTZ9Px.js","assets/Lamp-Cxp-OxUq.js","assets/Panel-CYQvfI3L.js","assets/preload-helper-8jyVfd2a.js","assets/Rack-xBT_6EtM.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,r as t,t as n}from"./preload-helper-8jyVfd2a.js";var r=t(`/_app/plugins/$pluginId`)({component:e(()=>n(()=>import(`./_app.plugins._pluginId-sYDTZ9Px.js`),__vite__mapDeps([0,1,2,3,4])),`component`)});export{r as t};
|
package/public/assets/{_app.plugins._pluginId-87Ox_hkW.js → _app.plugins._pluginId-sYDTZ9Px.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ct as e}from"./Lamp-Cxp-OxUq.js";import{t}from"./preload-helper-8jyVfd2a.js";import{C as n,a as r,c as i,d as a,f as o,i as s,l as c,r as l,t as u}from"./Panel-CYQvfI3L.js";import{t as d}from"./Rack-xBT_6EtM.js";import{t as f}from"./_app.plugins._pluginId-LzBq-Zjj.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(e){let t=w.get(e);if(t!==void 0)return t;let n={get:(t,n)=>c(C(e,t),n),post:(t,n)=>a(C(e,t),n),put:(t,n)=>o(C(e,t),n),del:t=>i(C(e,t))};return w.set(e,n),n}var E=h(e=>t(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
|
|
2
2
|
font-size: 13px;
|
|
3
3
|
color: ${({theme:e})=>e.color.down};
|
|
4
4
|
`,j=S.p`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Bt as e,Ft as t,It as n,J as r,K as i,Mt as a,Y as o,xt as s}from"./Lamp-Cxp-OxUq.js";import{C as c,D as l,S as u,_ as d,a as f,b as p,g as m,h,i as g,o as _,t as v,v as y}from"./Panel-CYQvfI3L.js";import{t as ee}from"./Rack-xBT_6EtM.js";import{t as b}from"./Toggle-CmXXn6F3.js";import{i as x,n as S,t as C}from"./Field-DK5zaBVA.js";import{t as te}from"./Meter-stpt3vQu.js";import{n as w}from"./reasons-Du1OBWAM.js";import{useEffect as ne,useId as T,useState as E}from"react";import{Fragment as D,jsx as O,jsxs as k}from"react/jsx-runtime";import A from"styled-components";var j=12,M=A.p`
|
|
2
2
|
font-size: 12px;
|
|
3
3
|
color: ${({theme:e})=>e.color.inkDim};
|
|
4
4
|
max-width: 62ch;
|
|
@@ -12,7 +12,7 @@ import{Ft as e,J as t,K as n,Pt as r,Y as i,jt as a,xt as o,zt as s}from"./Lamp-
|
|
|
12
12
|
max-width: 320px;
|
|
13
13
|
`,F=A(d)`
|
|
14
14
|
color: ${({theme:e})=>e.color.inkDim};
|
|
15
|
-
`;function I(){let e=
|
|
15
|
+
`;function I(){let e=o(),[t,n]=E(``),[r,i]=E(``),[a,s]=E(``),[u,d]=E(null);return k(c,{$gap:2,children:[O(F,{children:`Admin password`}),O(M,{children:`Changing this signs every session out, including this one.`}),k(P,{$gap:2,children:[O(C,{label:`Current password`,children:e=>O(S,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),O(C,{label:`New password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),O(C,{label:`Repeat new password`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:a,onChange:e=>s(e.target.value)})}),O(p,{$gap:2,children:O(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<j){d(`A password must be at least ${j} characters.`);return}if(r!==a){d(`The two new passwords do not match.`);return}d(null),e.mutate({current:t,password:r},{onSuccess:()=>w(`password-changed`),onError:e=>d(_(e))})},disabled:e.isPending||t.length===0||r.length===0,children:`Change password`})})]}),u===null?null:O(N,{role:`alert`,children:u})]})}function L(){let n=e(),r=t(),[i,a]=E(``),[o,s]=E(null),[u,d]=E(null),f=n.data?.viewerConfigured===!0;return k(c,{$gap:2,children:[O(F,{children:`Read-only password`}),k(M,{children:[`Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies.`,` `,n.isPending?`Checking whether one is set…`:f?`One is set. A new one replaces it; withdrawing ends read-only sessions at once.`:`None is set, so nobody can sign in read-only. There is no default password.`]}),k(P,{$gap:2,children:[O(C,{label:f?`Replace read-only password`:`Set read-only password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:i,onChange:e=>a(e.target.value)})}),k(p,{$gap:2,children:[O(l,{type:`button`,$variant:`primary`,onClick:()=>{if(i.length<j){s(`A password must be at least ${j} characters.`);return}s(null),r.mutate(i,{onSuccess:()=>{a(``),d(f?`Read-only password replaced.`:`Read-only access granted.`)},onError:e=>s(_(e))})},disabled:r.isPending||i.length===0,children:f?`Replace`:`Set`}),f?O(l,{type:`button`,$variant:`danger`,onClick:()=>{s(null),r.mutate(null,{onSuccess:()=>d(`Read-only access withdrawn.`),onError:e=>s(_(e))})},disabled:r.isPending,children:`Withdraw access`}):null]})]}),o===null?null:O(N,{role:`alert`,children:o}),u===null||o!==null?null:O(re,{role:`status`,children:u})]})}function R(){return O(v,{legend:`Access`,children:k(c,{$gap:3,children:[O(I,{}),O(h,{}),O(L,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],ie=A(y)`
|
|
16
16
|
display: block;
|
|
17
17
|
white-space: pre;
|
|
18
18
|
overflow-x: auto;
|
|
@@ -34,7 +34,7 @@ import{Ft as e,J as t,K as n,Pt as r,Y as i,jt as a,xt as o,zt as s}from"./Lamp-
|
|
|
34
34
|
display: grid;
|
|
35
35
|
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
|
|
36
36
|
gap: ${({theme:e})=>e.space(2)};
|
|
37
|
-
`,se=[{key:`defaultModel`,label:`Default model`,required:!0},{key:`fableModel`,label:`Fable model`,required:!1},{key:`opusModel`,label:`Opus model`,required:!1},{key:`sonnetModel`,label:`Sonnet model`,required:!1},{key:`haikuModel`,label:`Haiku model`,required:!1}];function V(){let[e,t]=E(`claude`),[r
|
|
37
|
+
`,se=[{key:`defaultModel`,label:`Default model`,required:!0},{key:`fableModel`,label:`Fable model`,required:!1},{key:`opusModel`,label:`Opus model`,required:!1},{key:`sonnetModel`,label:`Sonnet model`,required:!1},{key:`haikuModel`,label:`Haiku model`,required:!1}];function V(){let[e,t]=E(`claude`),[n,r]=E(()=>({claude:{},opencode:{}})),a=s(),o=n[e],u=typeof o.defaultModel==`string`&&o.defaultModel!==``?o:void 0,d=i(e,u),m=z.find(t=>t.id===e);return O(v,{legend:`Agent setup`,children:k(c,{children:[O(p,{children:z.map(n=>O(l,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),k(B,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,k(y,{children:[`omni setup `,e]}),` to write these files directly.`]}),(a.data?.length??0)>0?O(oe,{children:se.map(t=>O(C,{label:t.label,children:n=>k(x,{...n,value:o[t.key]??``,onChange:n=>r(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[O(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),a.data?.map(e=>O(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,a.isLoading?O(f,{rows:2}):d.isError?O(g,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?O(f,{rows:4}):(a.data?.length??0)===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?k(B,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>k(`div`,{children:[O(ae,{children:e.path}),O(ie,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?O(B,{children:_(d.error)}):null]})})}var H={off:`Off`,lite:`Lite — names the lazier option`,full:`Full — the ladder enforced`,ultra:`Ultra — challenges the requirement`},U=[{id:`tier`,label:`Tier`,blurb:`Prefers a lower tier.`},{id:`health`,label:`Health`,blurb:`Penalises recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Prefers accounts ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Prefers the cheaper candidate.`},{id:`latency`,label:`Latency`,blurb:`Prefers the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Prefers accounts with fewer requests in flight.`}],W=[{id:`maxAttempts`,label:`Attempts per request`,hint:`Candidates dispatch may try. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`Across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures before an account and model leaves rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Wait before a tripped account is probed. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before pruning.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often a provider is asked for remaining quota. 0 disables. Needs a restart.`,unit:`ms`,step:6e4,min:0}],G=A.div`
|
|
38
38
|
display: grid;
|
|
39
39
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
40
40
|
gap: ${({theme:e})=>e.space(3)};
|
|
@@ -85,4 +85,4 @@ import{Ft as e,J as t,K as n,Pt as r,Y as i,jt as a,xt as o,zt as s}from"./Lamp-
|
|
|
85
85
|
code {
|
|
86
86
|
font-family: ${({theme:e})=>e.font.mono};
|
|
87
87
|
}
|
|
88
|
-
`;function fe(e){let t={};for(let n of U)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of W)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.ponytailMode=e.ponytailMode,t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function pe(e){let t={};for(let n of U){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of W){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`,autoCacheEnabled:e.autoCacheEnabled===`true`,ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(H,e.ponytailMode)?e.ponytailMode:`off`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function me(){let n
|
|
88
|
+
`;function fe(e){let t={};for(let n of U)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of W)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.ponytailMode=e.ponytailMode,t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function pe(e){let t={};for(let n of U){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of W){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`,autoCacheEnabled:e.autoCacheEnabled===`true`,ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(H,e.ponytailMode)?e.ponytailMode:`off`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function me(){let e=n(),t=r(),i=a(),[o,s]=E({}),[h,b]=E(null),[w,T]=E(!1);ne(()=>{e.data!==void 0&&s(fe(e.data))},[e.data]);let A=Math.max(1e-4,...U.map(e=>Math.abs(Number(o[`w.${e.id}`])||0)));return k(D,{children:[O(ee,{legend:`Settings`,title:`Routing and retention`,summary:`Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.`,actions:O(l,{type:`button`,$variant:`primary`,disabled:i.isPending||e.isLoading,onClick:()=>{T(!1);let e=pe(o);if(!e.ok){b(e.problem);return}b(null),i.mutate(e.settings,{onSuccess:()=>T(!0),onError:e=>b(_(e))})},children:i.isPending?`Saving…`:`Save changes`})}),e.isError?O(v,{legend:`Settings`,children:O(g,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?O(v,{legend:`Settings`,children:O(f,{rows:6})}):k(c,{$gap:4,children:[O(v,{legend:`Scoring weights`,meta:`relative to each other`,footer:k(p,{children:[O(d,{children:`Score is the sum of each term times its weight, then multiplied by the account and target weights.`}),O(u,{})]}),children:O(G,{children:U.map(e=>{let t=Number(o[`w.${e.id}`])||0;return k(K,{children:[O(C,{label:e.label,children:t=>O(S,{...t,type:`number`,step:.5,value:o[`w.${e.id}`]??``,onChange:t=>s({...o,[`w.${e.id}`]:t.target.value})})}),O(te,{fraction:Math.abs(t)/A,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),O(q,{children:e.blurb})]},e.id)})})}),O(v,{legend:`Limits`,children:O(G,{children:W.map(e=>O(K,{children:O(C,{label:e.label,hint:e.hint,children:t=>k(p,{$gap:2,children:[O(S,{...t,type:`number`,min:e.min,step:e.step,value:o[e.id]??``,onChange:t=>s({...o,[e.id]:t.target.value})}),O(d,{children:e.unit})]})})},e.id))})}),k(m,{$min:`380px`,$stretch:!0,children:[O(v,{legend:`Request handling`,meta:`applied before dispatch`,children:k(J,{children:[O(Q,{label:`Enable RTK compression`,checked:o.rtkEnabled===`true`,onCheckedChange:e=>s({...o,rtkEnabled:String(e)}),children:`Compresses recognized historical tool results. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a detector recognizes shell output. Lossy.`}),O(Q,{label:`Add a cache breakpoint when a client sends none`,checked:o.autoCacheEnabled===`true`,onCheckedChange:e=>s({...o,autoCacheEnabled:String(e)}),children:`Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched.`}),O(le,{label:`Lazy senior dev mode`,blurb:`Appends the ponytail ruleset, about 1,240 tokens, to every system prompt. A request already carrying it is left alone.`,children:e=>O(x,{...e,value:o.ponytailMode??`off`,onChange:e=>s({...o,ponytailMode:e.target.value}),children:Object.entries(H).map(([e,t])=>O(`option`,{value:e,children:t},e))})})]})}),O(v,{legend:`Request and response bodies`,meta:t.data===!0?`permitted by the environment`:`not permitted`,children:k(c,{$gap:2,children:[t.data===!0?null:k(de,{children:[`This gateway started without `,O(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,O(`code`,{children:`.env`}),` and restart first.`]}),k(J,{children:[O(Q,{label:`Capture request and response bodies`,checked:o.bodyLoggingEnabled===`true`,disabled:t.data!==!0,onCheckedChange:e=>s({...o,bodyLoggingEnabled:String(e)}),children:`Stores what each client sent and each provider returned, encrypted beside the database. Tokens and keys are masked; headers are never captured. Expires on the log retention window above.`}),O(Q,{label:`Also keep raw stream frames`,checked:o.bodyLoggingCaptureStreamChunks===`true`,disabled:t.data!==!0||o.bodyLoggingEnabled!==`true`,onCheckedChange:e=>s({...o,bodyLoggingCaptureStreamChunks:String(e)}),children:`Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores.`})]})]})})]}),h===null?null:O($,{role:`alert`,children:h}),w&&h===null?O(ue,{role:`status`,children:`Settings saved.`}):null,k(m,{$min:`380px`,$stretch:!0,children:[O(V,{}),O(R,{})]}),O(v,{legend:`Known limits`,children:k(c,{$gap:2,children:[k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`rate limits`}),O(q,{children:`Counted per gateway process and reset when it restarts. Not shared across instances.`})]}),k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`logs`}),O(q,{children:`Request rows record routing and token counts only. Prompts and responses only when body capture is on, to a separate encrypted store. Credentials to neither.`})]})]})})]})]})}var he=me;export{he as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,O as y,Ot as b,P as x,Q as S,R as C,S as w,St as T,T as E,Tt as D,U as ee,V as O,W as te,X as ne,Y as re,Z as ie,_ as ae,_t as oe,a as k,at as se,b as ce,bt as le,c as ue,ct as de,d as fe,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as we,kt as Te,l as A,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,r as Ie,rt as Le,s as j,st as Re,t as ze,tt as Be,u as M,ut as Ve,v as N,vt as P,w as He,wt as Ue,x as We,xt as Ge,y as F,yt as Ke,z as qe}from"./shared-OJcoRCqT.js";import{A as I,Ct as Je,H as Ye,I as L,N as Xe,P as Ze,Vt as R,gt as Qe,lt as $e,xt as et}from"./Lamp-ZlMzNs5N.js";import{C as z,_ as tt,b as B,g as nt,t as rt,v as V,w as it,x as at}from"./Panel-CYQvfI3L.js";import{_ as ot,f as st,m as ct,t as lt}from"./Rack-D798XvPQ.js";import{i as ut,n as H,r as U,t as dt}from"./Table-CVDZ69Zx.js";import{i as W,n as ft,r as pt,t as mt}from"./SummaryDeck-DBCSHihY.js";import*as G from"react";import{PureComponent as ht,forwardRef as gt,useMemo as K,useRef as _t,useState as q}from"react";import{jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";function vt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function yt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var bt=(e,t,n)=>ne(e,`xAxis`,vt(e,t),n),xt=(e,t,n)=>S(e,`xAxis`,vt(e,t),n),St=(e,t,n)=>ne(e,`yAxis`,yt(e,t),n),Ct=(e,t,n)=>S(e,`yAxis`,yt(e,t),n),wt=P([Me,bt,St,xt,Ct],(e,t,n,r,i)=>ve(e,`xAxis`)?pe(t,r,!1):pe(n,i,!1)),Tt=P([e,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Et=e=>{var t=Me(e);return ve(t,`xAxis`)?`yAxis`:`xAxis`},Dt=(e,t)=>Et(e)===`yAxis`?yt(e,t):vt(e,t),Ot=(e,t,n)=>ie(e,Et(e),Dt(e,t),n),kt=P([Tt,Ot],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=me(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),At=P([Tt,Ot],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(a)}}),jt=P([Me,bt,St,xt,Ct,kt,Le,wt,Tt,Ae,At],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return un({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),Mt=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Nt=[`id`,`baseLine`];function Pt(){return Pt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Pt.apply(null,arguments)}function Ft(e,t){if(e==null)return{};var n,r,i=It(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function It(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Lt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!oe(a)||!oe(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return D(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),D(c)?G.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Rt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!oe(a)||!oe(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return D(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),D(c)?G.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function zt(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?G.createElement(Rt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):G.createElement(Lt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Bt(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,c=e.layout,l=e.isRange,u=e.stroke,d=e.connectNulls,f=Ft(e,Mt),p=c===`vertical`?`vertical`:`horizontal`,m=d??!1,h=x(),g=f.id,_=f.baseLine,v=Ft(f,Nt),y=Te(v),b=G.createElement(Se,Pt({},f,{id:g,baseLine:_,connectNulls:m,stroke:`none`,className:`recharts-area-area`,layout:p})),S=u!==`none`&&G.createElement(Se,Pt({},y,{className:`recharts-area-curve`,layout:p,type:f.type,connectNulls:m,fill:`none`,stroke:u,points:f.points})),C=u!==`none`&&l&&Array.isArray(_)&&G.createElement(Se,Pt({},y,{className:`recharts-area-curve`,layout:p,type:f.type,connectNulls:m,fill:`none`,stroke:u,points:_}));return o&&(i||n<1)?G.createElement(s,null,G.createElement(`defs`,null,G.createElement(`clipPath`,{id:h},G.createElement(zt,{alpha:n,points:f.points??[],baseLine:_,layout:p,strokeWidth:f.strokeWidth}))),G.createElement(s,{clipPath:`url(#${h})`},b,S,C)):G.createElement(G.Fragment,null,b,S,C)}var Vt=[`id`],Ht=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Ut(){return Ut=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ut.apply(null,arguments)}function Wt(e,t){if(e==null)return{};var n,r,i=Gt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Gt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Kt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Kt(Object(n),!0).forEach(function(t){qt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qt(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jt(e){var t=Yt(e,`string`);return typeof t==`symbol`?t:t+``}function Yt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Xt={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:qe,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[Z(Z({},e.next),{},{x:Ge(e.prev.x,e.next.x,t),y:Ge(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:Bt,xAxisId:0,yAxisId:0,zIndex:Be.area};function Zt(e,t){return e&&e!==`none`?e:t}var Qt=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:Zt(r,i),value:Oe(n,t),payload:e}]},$t=G.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,u=e.formatter,d=e.tooltipType,f=e.id,p={dataDefinedOnItem:n,getPosition:l,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Oe(o,t),hide:s,type:d,color:Zt(r,a),unit:c,formatter:u,graphicalItemId:f}};return G.createElement(O,{tooltipEntrySettings:p})});function en(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=Te(r);return G.createElement(Ce,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function tn(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return G.createElement(te,{value:t?r:void 0},n)}function nn(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,c=e.isAnimating,l=e.isEntrance,u=a.layout,d=a.type,p=a.stroke,m=a.connectNulls,h=a.isRange,g=a.shape,_=a.id,v=Wt(a,Vt),y=Z(Z({},b(v)),{},{id:_,points:t,connectNulls:m,type:d,baseLine:n,layout:u,stroke:p,isRange:h,animationElapsedTime:o,isAnimating:c,isEntrance:l});return G.createElement(G.Fragment,null,t?.length>1&&G.createElement(s,{clipPath:r?`url(#clipPath-${i})`:void 0},G.createElement(f,{option:g,DefaultShape:Xt.shape,shapeProps:y})),G.createElement(en,{points:t,props:v,clipPathId:i}))}function rn(e,t,n){if(D(e)){var r=D(t)?t:void 0;return Ge(r,e,n)}if(Ue(e)||T(e)){var i=D(t)?t:void 0;return Ge(i,0,n)}return e}function an(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,f=r.animationDuration,m=r.animationEasing,h=r.animationMatchBy,_=r.animationInterpolateFn,v=K(()=>({points:o,baseLine:s}),[o,s]),y=g(v,a),b=Re(),x=p(r.onAnimationStart,r.onAnimationEnd),S=x.isAnimating,w=x.handleAnimationStart,T=x.handleAnimationEnd,E=y.startValue;if(b==null)return null;var D=Array.isArray(s)&&Array.isArray(E)?C(E,s,h):Array.isArray(s)?C(null,s,h):null;return G.createElement(u,{animationInput:v,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:f,animationEasing:m,onAnimationStart:w,onAnimationEnd:T,animationInterpolateFn:_,animationMatchBy:h,layout:b},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?_(D,i,b):a?s:rn(s,E,i);return y.syncStepValue(c,i),G.createElement(tn,{showLabels:!S,points:o},r.children,G.createElement(nn,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:S||i<1,isEntrance:a}),G.createElement(d,{label:r.label}))})}function on(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=_t(null),a=_t();return G.createElement(an,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var sn=class extends ht{render(){var e=this.props,t=e.hide,r=e.dot,i=e.points,a=e.className,o=e.top,l=e.left,u=e.needClip,d=e.xAxisId,f=e.yAxisId,p=e.width,h=e.height,g=e.id,_=e.baseLine,v=e.zIndex;if(t)return null;var y=n(`recharts-area`,a),b=g,x=E(r),S=x.r,C=x.strokeWidth,w=ee(r),T=S*2+C,D=u?`url(#clipPath-${w?``:`dots-`}${b})`:void 0;return G.createElement(m,{zIndex:v},G.createElement(s,{className:y},u&&G.createElement(`defs`,null,G.createElement(c,{clipPathId:b,xAxisId:d,yAxisId:f}),!w&&G.createElement(`clipPath`,{id:`clipPath-dots-${b}`},G.createElement(`rect`,{x:l-T/2,y:o-T/2,width:p+T,height:h+T}))),G.createElement(on,{needClip:u,clipPathId:b,props:this.props})),G.createElement(we,{points:i,mainColor:Zt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}),this.props.isRange&&Array.isArray(_)&&G.createElement(we,{points:_,mainColor:Zt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}))}};function cn(e){var n=e.activeDot,r=e.animationBegin,i=e.animationDuration,a=e.animationEasing,s=e.connectNulls,c=e.dot,l=e.fill,u=e.fillOpacity,d=e.hide,f=e.isAnimationActive,p=e.legendType,m=e.stroke,h=e.xAxisId,g=e.yAxisId,_=Wt(e,Ht),v=de(),y=re(),b=o(h,g).needClip,x=Ve(),S=Ke(t=>jt(t,e.id,x))??{},C=S.points,w=S.isRange,T=S.baseLine,E=t();if(v!==`horizontal`&&v!==`vertical`||E==null||y!==`AreaChart`&&y!==`ComposedChart`)return null;var D=E.height,ee=E.width,O=E.x,te=E.y;return!C||!C.length?null:G.createElement(sn,Ut({},_,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,baseLine:T,connectNulls:s,dot:c,fill:l,fillOpacity:u,height:D,hide:d,layout:v,isAnimationActive:f,isRange:w,legendType:p,needClip:b,points:C,stroke:m,width:ee,left:O,top:te,xAxisId:h,yAxisId:g}))}var ln=(e,t,n,r,i)=>{var a=n??t;if(D(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function un(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=ln(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=be(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=be(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>be(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:ge({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:ge({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function dn(e){var t=le(e,Xt),n=Ve();return G.createElement(v,{id:t.id,type:`area`},e=>G.createElement(G.Fragment,null,G.createElement(r,{legendPayload:Qt(t)}),G.createElement($t,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),G.createElement(_,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:Pe(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),G.createElement(cn,Ut({},t,{id:e}))))}var fn=G.memo(dn,se);fn.displayName=`Area`;var pn=[`axis`],mn=gt((e,t)=>G.createElement(We,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:pn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),hn=[`axis`],gn=gt((e,t)=>G.createElement(We,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:hn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),_n=53,Q=9,$=2,vn=X.div`
|
|
1
|
+
import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,N as v,O as y,Ot as b,P as x,Q as S,R as C,S as w,St as T,T as E,Tt as D,U as ee,V as O,W as te,X as ne,Y as re,Z as ie,_ as ae,_t as oe,a as k,at as se,b as ce,bt as le,c as ue,ct as de,d as fe,dt as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,k as we,kt as Te,l as A,lt as Ee,m as De,mt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,r as Ie,rt as Le,s as j,st as Re,t as ze,tt as Be,u as M,ut as Ve,v as N,vt as P,w as He,wt as Ue,x as We,xt as Ge,y as F,yt as Ke,z as qe}from"./shared-B2Lmnazz.js";import{A as I,H as Je,Ht as L,I as R,N as Ye,P as Xe,gt as Ze,lt as Qe,wt as $e,xt as et}from"./Lamp-Cxp-OxUq.js";import{C as z,_ as tt,b as B,g as nt,t as rt,v as V,w as it,x as at}from"./Panel-CYQvfI3L.js";import{_ as ot,f as st,m as ct,t as lt}from"./Rack-xBT_6EtM.js";import{i as ut,n as H,r as U,t as dt}from"./Table-CVDZ69Zx.js";import{i as W,n as ft,r as pt,t as mt}from"./SummaryDeck-C3ZwZ3ng.js";import*as G from"react";import{PureComponent as ht,forwardRef as gt,useMemo as K,useRef as _t,useState as q}from"react";import{jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";function vt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function yt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var bt=(e,t,n)=>ne(e,`xAxis`,vt(e,t),n),xt=(e,t,n)=>S(e,`xAxis`,vt(e,t),n),St=(e,t,n)=>ne(e,`yAxis`,yt(e,t),n),Ct=(e,t,n)=>S(e,`yAxis`,yt(e,t),n),wt=P([Me,bt,St,xt,Ct],(e,t,n,r,i)=>ve(e,`xAxis`)?pe(t,r,!1):pe(n,i,!1)),Tt=P([e,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),Et=e=>{var t=Me(e);return ve(t,`xAxis`)?`yAxis`:`xAxis`},Dt=(e,t)=>Et(e)===`yAxis`?yt(e,t):vt(e,t),Ot=(e,t,n)=>ie(e,Et(e),Dt(e,t),n),kt=P([Tt,Ot],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=me(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),At=P([Tt,Ot],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(a)}}),jt=P([Me,bt,St,xt,Ct,kt,Le,wt,Tt,Ae,At],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return un({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),Mt=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Nt=[`id`,`baseLine`];function Pt(){return Pt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Pt.apply(null,arguments)}function Ft(e,t){if(e==null)return{};var n,r,i=It(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function It(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Lt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!oe(a)||!oe(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return D(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),D(c)?G.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Rt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!oe(a)||!oe(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return D(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),D(c)?G.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function zt(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?G.createElement(Rt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):G.createElement(Lt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Bt(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,c=e.layout,l=e.isRange,u=e.stroke,d=e.connectNulls,f=Ft(e,Mt),p=c===`vertical`?`vertical`:`horizontal`,m=d??!1,h=x(),g=f.id,_=f.baseLine,v=Ft(f,Nt),y=Te(v),b=G.createElement(Se,Pt({},f,{id:g,baseLine:_,connectNulls:m,stroke:`none`,className:`recharts-area-area`,layout:p})),S=u!==`none`&&G.createElement(Se,Pt({},y,{className:`recharts-area-curve`,layout:p,type:f.type,connectNulls:m,fill:`none`,stroke:u,points:f.points})),C=u!==`none`&&l&&Array.isArray(_)&&G.createElement(Se,Pt({},y,{className:`recharts-area-curve`,layout:p,type:f.type,connectNulls:m,fill:`none`,stroke:u,points:_}));return o&&(i||n<1)?G.createElement(s,null,G.createElement(`defs`,null,G.createElement(`clipPath`,{id:h},G.createElement(zt,{alpha:n,points:f.points??[],baseLine:_,layout:p,strokeWidth:f.strokeWidth}))),G.createElement(s,{clipPath:`url(#${h})`},b,S,C)):G.createElement(G.Fragment,null,b,S,C)}var Vt=[`id`],Ht=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Ut(){return Ut=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ut.apply(null,arguments)}function Wt(e,t){if(e==null)return{};var n,r,i=Gt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Gt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Kt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Kt(Object(n),!0).forEach(function(t){qt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qt(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jt(e){var t=Yt(e,`string`);return typeof t==`symbol`?t:t+``}function Yt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Xt={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:qe,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[Z(Z({},e.next),{},{x:Ge(e.prev.x,e.next.x,t),y:Ge(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:Bt,xAxisId:0,yAxisId:0,zIndex:Be.area};function Zt(e,t){return e&&e!==`none`?e:t}var Qt=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:Zt(r,i),value:Oe(n,t),payload:e}]},$t=G.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,u=e.formatter,d=e.tooltipType,f=e.id,p={dataDefinedOnItem:n,getPosition:l,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Oe(o,t),hide:s,type:d,color:Zt(r,a),unit:c,formatter:u,graphicalItemId:f}};return G.createElement(O,{tooltipEntrySettings:p})});function en(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=Te(r);return G.createElement(Ce,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function tn(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return G.createElement(te,{value:t?r:void 0},n)}function nn(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,c=e.isAnimating,l=e.isEntrance,u=a.layout,d=a.type,p=a.stroke,m=a.connectNulls,h=a.isRange,g=a.shape,_=a.id,v=Wt(a,Vt),y=Z(Z({},b(v)),{},{id:_,points:t,connectNulls:m,type:d,baseLine:n,layout:u,stroke:p,isRange:h,animationElapsedTime:o,isAnimating:c,isEntrance:l});return G.createElement(G.Fragment,null,t?.length>1&&G.createElement(s,{clipPath:r?`url(#clipPath-${i})`:void 0},G.createElement(f,{option:g,DefaultShape:Xt.shape,shapeProps:y})),G.createElement(en,{points:t,props:v,clipPathId:i}))}function rn(e,t,n){if(D(e)){var r=D(t)?t:void 0;return Ge(r,e,n)}if(Ue(e)||T(e)){var i=D(t)?t:void 0;return Ge(i,0,n)}return e}function an(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,f=r.animationDuration,m=r.animationEasing,h=r.animationMatchBy,_=r.animationInterpolateFn,v=K(()=>({points:o,baseLine:s}),[o,s]),y=g(v,a),b=Re(),x=p(r.onAnimationStart,r.onAnimationEnd),S=x.isAnimating,w=x.handleAnimationStart,T=x.handleAnimationEnd,E=y.startValue;if(b==null)return null;var D=Array.isArray(s)&&Array.isArray(E)?C(E,s,h):Array.isArray(s)?C(null,s,h):null;return G.createElement(u,{animationInput:v,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:f,animationEasing:m,onAnimationStart:w,onAnimationEnd:T,animationInterpolateFn:_,animationMatchBy:h,layout:b},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?_(D,i,b):a?s:rn(s,E,i);return y.syncStepValue(c,i),G.createElement(tn,{showLabels:!S,points:o},r.children,G.createElement(nn,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:S||i<1,isEntrance:a}),G.createElement(d,{label:r.label}))})}function on(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=_t(null),a=_t();return G.createElement(an,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var sn=class extends ht{render(){var e=this.props,t=e.hide,r=e.dot,i=e.points,a=e.className,o=e.top,l=e.left,u=e.needClip,d=e.xAxisId,f=e.yAxisId,p=e.width,h=e.height,g=e.id,_=e.baseLine,v=e.zIndex;if(t)return null;var y=n(`recharts-area`,a),b=g,x=E(r),S=x.r,C=x.strokeWidth,w=ee(r),T=S*2+C,D=u?`url(#clipPath-${w?``:`dots-`}${b})`:void 0;return G.createElement(m,{zIndex:v},G.createElement(s,{className:y},u&&G.createElement(`defs`,null,G.createElement(c,{clipPathId:b,xAxisId:d,yAxisId:f}),!w&&G.createElement(`clipPath`,{id:`clipPath-dots-${b}`},G.createElement(`rect`,{x:l-T/2,y:o-T/2,width:p+T,height:h+T}))),G.createElement(on,{needClip:u,clipPathId:b,props:this.props})),G.createElement(we,{points:i,mainColor:Zt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}),this.props.isRange&&Array.isArray(_)&&G.createElement(we,{points:_,mainColor:Zt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:D}))}};function cn(e){var n=e.activeDot,r=e.animationBegin,i=e.animationDuration,a=e.animationEasing,s=e.connectNulls,c=e.dot,l=e.fill,u=e.fillOpacity,d=e.hide,f=e.isAnimationActive,p=e.legendType,m=e.stroke,h=e.xAxisId,g=e.yAxisId,_=Wt(e,Ht),v=de(),y=re(),b=o(h,g).needClip,x=Ve(),S=Ke(t=>jt(t,e.id,x))??{},C=S.points,w=S.isRange,T=S.baseLine,E=t();if(v!==`horizontal`&&v!==`vertical`||E==null||y!==`AreaChart`&&y!==`ComposedChart`)return null;var D=E.height,ee=E.width,O=E.x,te=E.y;return!C||!C.length?null:G.createElement(sn,Ut({},_,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,baseLine:T,connectNulls:s,dot:c,fill:l,fillOpacity:u,height:D,hide:d,layout:v,isAnimationActive:f,isRange:w,legendType:p,needClip:b,points:C,stroke:m,width:ee,left:O,top:te,xAxisId:h,yAxisId:g}))}var ln=(e,t,n,r,i)=>{var a=n??t;if(D(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function un(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=ln(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=be(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=be(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>be(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:ge({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:ge({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function dn(e){var t=le(e,Xt),n=Ve();return G.createElement(v,{id:t.id,type:`area`},e=>G.createElement(G.Fragment,null,G.createElement(r,{legendPayload:Qt(t)}),G.createElement($t,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),G.createElement(_,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:Pe(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),G.createElement(cn,Ut({},t,{id:e}))))}var fn=G.memo(dn,se);fn.displayName=`Area`;var pn=[`axis`],mn=gt((e,t)=>G.createElement(We,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:pn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),hn=[`axis`],gn=gt((e,t)=>G.createElement(We,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:hn,tooltipPayloadSearcher:Fe,categoricalChartProps:e,ref:t})),_n=53,Q=9,$=2,vn=X.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
gap: ${$}px;
|
|
4
4
|
`,yn=X.div`
|
|
@@ -48,7 +48,7 @@ import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l
|
|
|
48
48
|
`,Dn=X(V)`
|
|
49
49
|
color: ${({theme:e})=>e.color.inkDim};
|
|
50
50
|
font-size: 11px;
|
|
51
|
-
`;function On(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(t.length*e))]??0;return[n(.25),n(.5),n(.75)]}function kn(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function An({days:e,now:t}){let[n,r]=q(`tokens`),[i,a]=q(null),o=De(n),s=K(()=>{let n=new Map;for(let t of e){let e=Number(t.key);Number.isFinite(e)&&n.set(ae(e),{requests:t.requests,errors:t.errors,costUsd:t.costUsd,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens,rtkSavedTokens:t.rtkSavedTokens,rtkAppliedRequests:t.rtkAppliedRequests,durationMsSum:t.durationMsSum})}let r=new Date(ae(t));r.setDate(r.getDate()+(6-r.getDay())-370);let i=ae(t);return Array.from({length:_n},()=>Array.from({length:7},()=>{let e=r.getTime();return r.setDate(r.getDate()+1),{at:e,totals:n.get(e)??j,future:e>i}}))},[e,t]),c=s.flat(),l=On(c.map(e=>o.of({key:``,...e.totals}))),u=c.reduce((e,t)=>ue(e,M(t.totals)),j),d=c.reduce((e,t)=>e+ +(t.totals.requests>0),0),f=(e,t)=>`${e}: ${I(t.requests)} requests, ${I(A(t))} tokens, ${
|
|
51
|
+
`;function On(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(t.length*e))]??0;return[n(.25),n(.5),n(.75)]}function kn(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function An({days:e,now:t}){let[n,r]=q(`tokens`),[i,a]=q(null),o=De(n),s=K(()=>{let n=new Map;for(let t of e){let e=Number(t.key);Number.isFinite(e)&&n.set(ae(e),{requests:t.requests,errors:t.errors,costUsd:t.costUsd,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens,rtkSavedTokens:t.rtkSavedTokens,rtkAppliedRequests:t.rtkAppliedRequests,durationMsSum:t.durationMsSum})}let r=new Date(ae(t));r.setDate(r.getDate()+(6-r.getDay())-370);let i=ae(t);return Array.from({length:_n},()=>Array.from({length:7},()=>{let e=r.getTime();return r.setDate(r.getDate()+1),{at:e,totals:n.get(e)??j,future:e>i}}))},[e,t]),c=s.flat(),l=On(c.map(e=>o.of({key:``,...e.totals}))),u=c.reduce((e,t)=>ue(e,M(t.totals)),j),d=c.reduce((e,t)=>e+ +(t.totals.requests>0),0),f=(e,t)=>`${e}: ${I(t.requests)} requests, ${I(A(t))} tokens, ${R(t.costUsd)}`;return J(rt,{legend:`Activity`,meta:i===null?`${I(d)} active days`:void 0,actions:J(ft,{children:Ie.map(e=>J(pt,{type:`button`,$size:`sm`,$on:e.id===n,"aria-pressed":e.id===n,onClick:()=>r(e.id),children:e.label},e.id))}),children:Y(z,{$gap:2,children:[J(at,{children:J(z,{$gap:1,style:{width:611},children:Y(vn,{children:[J(yn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>J(bn,{children:e},t))}),Y(z,{$gap:1,children:[J(xn,{"aria-hidden":`true`,children:s.map((e,t)=>{let n=e[0],r=s[t-1]?.[0],i=n!==void 0&&(r===void 0||new Date(r.at).getMonth()!==new Date(n.at).getMonth());return J(Sn,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),J(Cn,{role:`grid`,"aria-label":`${o.label} per day over the last year`,children:s.map(e=>J(wn,{role:`row`,children:e.map(e=>J(Tn,{role:`gridcell`,tabIndex:-1,"aria-label":f(he(e.at),e.totals),title:f(he(e.at),e.totals),$future:e.future,$level:e.future?0:kn(o.of({key:``,...e.totals}),l),onMouseEnter:()=>a(e),onMouseLeave:()=>a(null)},e.at))},e[0]?.at))})]})]})})}),Y(B,{$justify:`space-between`,$wrap:!0,children:[J(Dn,{children:i===null?f(`Last 12 months`,u):f(he(i.at),i.totals)}),Y(B,{$gap:1,children:[J(tt,{children:`Less`}),J(En,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>J(Tn,{$level:e,$future:!1},e))}),J(tt,{children:`More`})]})]})]})})}function jn({buckets:e,by:t,since:n,until:r,metric:i,names:a}){let o=F(n,r,t),s=new Map,c=new Map;for(let n of e){let e=n.split??`unknown`;s.set(e,ue(s.get(e)??j,n));let r=c.get(e)??new Map,a=Ne(n.key,t);r.set(a,(r.get(a)??0)+i.of(n)),c.set(e,r)}let l=[...s.entries()].sort((e,t)=>i.of(M(t[1]))-i.of(M(e[1])));return J(at,{children:Y(dt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(U,{children:`Key`}),J(U,{children:`Trend`}),J(U,{$align:`right`,children:`Requests`}),J(U,{$align:`right`,children:`Failed`}),J(U,{$align:`right`,children:`Tokens`}),J(U,{$align:`right`,children:`Mean`}),J(U,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:l.map(([e,t])=>{let n=c.get(e)??new Map,r=e===`unknown`?`Unattributed`:a.get(e)??e;return Y(ut,{children:[J(H,{children:J(it,{style:{display:`block`,maxWidth:`28ch`},children:r})}),J(H,{style:{width:120},children:J(st,{values:o.map(e=>n.get(e)??0),height:20,label:`${r}: ${i.format(i.of(M(t)))} over the window`})}),J(H,{$align:`right`,$mono:!0,children:I(t.requests)}),J(H,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:Xe(t.requests===0?0:t.errors/t.requests,0)}),J(H,{$align:`right`,$mono:!0,children:I(A(t))}),J(H,{$align:`right`,$mono:!0,children:Ye(t.requests===0?null:t.durationMsSum/t.requests)}),J(H,{$align:`right`,$mono:!0,children:R(t.costUsd)})]},e)})})]})})}var Mn=6,Nn=`__other__`,Pn=`unknown`;function Fn(e,t,n){let r=n.get(t);return r===void 0?e.find(e=>e.models.some(e=>e.id===t))?.id??null:r}function In(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${ct(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Ln({buckets:e,by:t,since:n,until:r,metric:a,providers:o}){let s=$e().data??[],c=[...fe(e,a).entries()],l=c.slice(0,Mn),u=c.slice(Mn),d=[...new Set(l.map(([e])=>Fn(s,e,o)))].filter(e=>e!==null&&Je(s,e)===void 0).sort(),f=[];for(let e of[...s.map(e=>e.id),...d,null])l.filter(([t])=>Fn(s,t,o)===e).forEach(([t,n],r)=>{f.push({name:t,label:t===Pn?`Unresolved`:t,color:In(e,r),totals:n})});u.length>0&&f.push({name:Nn,label:`${u.length} more`,color:`var(--ink-faint)`,totals:u.reduce((e,[,t])=>ue(e,M(t)),j)});let p=new Set(l.map(([e])=>e)),m=new Map;for(let n of e){let e=n.split??Pn,r=`${Ne(n.key,t)} ${p.has(e)?e:Nn}`;m.set(r,(m.get(r)??0)+a.of(n))}let g=F(n,r,t).map(e=>{let t={at:e};for(let n of f)t[n.name]=m.get(`${e} ${n.name}`)??0;return t}),_=new Map(f.map(e=>[e.name,e.label]));return Y(z,{$gap:2,children:[J(ze,{$height:220,children:J(Ee,{width:`100%`,height:`100%`,children:Y(mn,{data:g,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>{if(e!==!0||n===void 0||n.length===0)return null;let i=n.filter(e=>Number(e.value??0)>0);return Y(je,{children:[J(`div`,{children:N(Number(r),t)}),i.length===0?J(`div`,{children:`No ${a.label.toLowerCase()}`}):i.map(e=>Y(`div`,{children:[_.get(String(e.dataKey))??String(e.dataKey),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}}),f.map(e=>J(fn,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),J(ke,{children:f.map(e=>Y(`span`,{children:[J(k,{$color:e.color}),` `,J(it,{title:`${e.label}: ${a.format(a.of(M(e.totals)))} ${a.label.toLowerCase()}`,style:{display:`inline-block`,maxWidth:`24ch`,verticalAlign:`bottom`},children:e.label})]},e.name))})]})}var Rn=`unknown`;function zn(e,t){return Je(e,t)===void 0?`var(--ink-faint)`:ct(t)}function Bn(e,t){return t===Rn?`Unresolved`:Je(e,t)?.label??t}function Vn({buckets:e,by:t,since:n,until:r,metric:a}){let o=$e().data??[],s=fe(e,a),c=[...s.keys()].filter(e=>e!==Rn&&Je(o,e)===void 0).sort(),l=[...o.map(e=>e.id),...c,Rn].map(e=>({name:e,totals:s.get(e)})).filter(e=>e.totals!==void 0),u=l.map(e=>e.name),d=F(n,r,t),f=_e(e,d,t,a),p=[...s.values()].reduce((e,t)=>e+t.requests,0);return Y(z,{$gap:3,children:[J(ze,{$height:200,children:J(Ee,{width:`100%`,height:`100%`,children:Y(mn,{data:f,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),J(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:Y(je,{children:[J(`div`,{children:N(Number(r),t)}),n.map(e=>Y(`div`,{children:[Bn(o,String(e.dataKey)),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}),u.map(e=>J(fn,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:zn(o,e),strokeWidth:2,fill:zn(o,e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),J(ke,{children:u.map(e=>Y(`span`,{children:[J(k,{$color:zn(o,e)}),` `,Bn(o,e)]},e))}),Y(dt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(U,{children:`Provider`}),J(U,{$align:`right`,children:`Share`}),J(U,{$align:`right`,children:`Requests`}),J(U,{$align:`right`,children:`Failed`}),J(U,{$align:`right`,children:`Tokens`}),J(U,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:l.map(({name:e,totals:t})=>Y(ut,{children:[Y(H,{children:[J(k,{$color:zn(o,e)}),` `,Bn(o,e)]}),J(H,{$align:`right`,$mono:!0,children:Xe(p===0?0:t.requests/p,0)}),J(H,{$align:`right`,$mono:!0,children:I(t.requests)}),J(H,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:I(t.errors)}),J(H,{$align:`right`,$mono:!0,children:I(A(t))}),J(H,{$align:`right`,$mono:!0,children:R(t.costUsd)})]},e))})]})]})}var Hn=X.li`
|
|
52
52
|
display: grid;
|
|
53
53
|
grid-template-columns: minmax(0, 20ch) 1fr auto;
|
|
54
54
|
align-items: center;
|
|
@@ -73,4 +73,4 @@ import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l
|
|
|
73
73
|
display: block;
|
|
74
74
|
font-family: ${({theme:e})=>e.font.mono};
|
|
75
75
|
font-size: 12px;
|
|
76
|
-
`,qn=12;function Jn({buckets:e,metric:t,names:n,unknownLabel:r}){let i=new Map;for(let t of e)i.set(t.key,ue(i.get(t.key)??j,t));let a=e=>e===`unknown`?r??`Unattributed`:n?.get(e)??e,o=[...i.entries()].map(([e,n])=>({name:a(e),entry:n,value:t.of(M(n))})).sort((e,t)=>t.value-e.value),s=o.slice(0,qn),c=o.slice(qn),l=s[0]?.value??0;return Y(z,{$gap:3,children:[J(Un,{children:s.map(({name:e,entry:n,value:r})=>Y(Hn,{children:[J(Kn,{title:e,children:e}),J(Wn,{children:J(Gn,{$share:l===0?0:r/l,$fault:n.requests>0&&n.errors===n.requests})}),Y(B,{$gap:2,children:[J(V,{$size:`12px`,children:t.format(r)}),J(V,{$size:`11px`,$dim:!0,children:
|
|
76
|
+
`,qn=12;function Jn({buckets:e,metric:t,names:n,unknownLabel:r}){let i=new Map;for(let t of e)i.set(t.key,ue(i.get(t.key)??j,t));let a=e=>e===`unknown`?r??`Unattributed`:n?.get(e)??e,o=[...i.entries()].map(([e,n])=>({name:a(e),entry:n,value:t.of(M(n))})).sort((e,t)=>t.value-e.value),s=o.slice(0,qn),c=o.slice(qn),l=s[0]?.value??0;return Y(z,{$gap:3,children:[J(Un,{children:s.map(({name:e,entry:n,value:r})=>Y(Hn,{children:[J(Kn,{title:e,children:e}),J(Wn,{children:J(Gn,{$share:l===0?0:r/l,$fault:n.requests>0&&n.errors===n.requests})}),Y(B,{$gap:2,children:[J(V,{$size:`12px`,children:t.format(r)}),J(V,{$size:`11px`,$dim:!0,children:R(n.costUsd)})]})]},e))}),c.length===0?null:J(V,{$size:`11px`,$dim:!0,children:`+ ${c.length} more, ${I(c.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}var Yn=[{id:`inputTokens`,label:`Uncached input`,opacity:.95},{id:`outputTokens`,label:`Output`,opacity:.7},{id:`cacheReadTokens`,label:`Cache read`,opacity:.45},{id:`cacheWriteTokens`,label:`Cache write`,opacity:.22}];function Xn({buckets:e,by:t,since:n,until:r}){let a=new Map;for(let n of e)a.set(Ne(n.key,t),n);let o=F(n,r,t).map(e=>{let t=a.get(e);return{at:e,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,cacheReadTokens:t?.cacheReadTokens??0,cacheWriteTokens:t?.cacheWriteTokens??0}}),s=Yn.map(e=>({...e,value:o.reduce((t,n)=>t+n[e.id],0)})),c=s.reduce((e,t)=>e+t.value,0);return Y(z,{$gap:3,children:[J(ze,{$height:200,children:J(Ee,{width:`100%`,height:`100%`,children:Y(mn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`at`,tickFormatter:e=>N(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>I(e)}),J(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:Y(je,{children:[J(`div`,{children:N(Number(r),t)}),Yn.map(e=>Y(`div`,{children:[e.label,` `,I(Number(n.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),Yn.map(e=>J(fn,{type:`monotone`,dataKey:e.id,stackId:`tokens`,stroke:`var(--accent)`,strokeOpacity:e.opacity,strokeWidth:1.5,fill:`var(--accent)`,fillOpacity:e.opacity*.5,isAnimationActive:!1},e.id))]})})}),J(ke,{children:s.map(e=>Y(B,{$gap:1,children:[J(k,{$color:`var(--accent)`,style:{opacity:e.opacity}}),J(`span`,{children:e.label}),J(V,{$size:`11px`,children:I(e.value)}),J(V,{$size:`11px`,$dim:!0,children:Xe(c===0?0:e.value/c,0)})]},e.id))})]})}function Zn({buckets:e,by:t,since:n,until:r}){let a=new Map;for(let n of e)a.set(Ne(n.key,t),n);let o=F(n,r,t).map(e=>{let n=a.get(e);return{at:e,label:N(e,t),requests:n?.requests??0,errors:n?.errors??0,costUsd:n?.costUsd??0,tokens:n===void 0?0:A(n)}});return Y(z,{$gap:2,children:[J(ze,{$height:220,children:J(Ee,{width:`100%`,height:`100%`,children:Y(gn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[J(y,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(w,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(h,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t})=>{if(e!==!0||t===void 0||t.length===0)return null;let n=t[0]?.payload;return n===void 0?null:Y(je,{children:[J(`div`,{children:n.label}),Y(`div`,{children:[I(n.requests),` requests`]}),Y(`div`,{children:[I(n.errors),` failed`]}),Y(`div`,{children:[I(n.tokens),` tokens`]}),J(`div`,{children:R(n.costUsd)})]})}}),J(fn,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),J(He,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),J(He,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),Y(ke,{children:[Y(`span`,{children:[J(k,{$color:`var(--accent)`}),` Requests`]}),Y(`span`,{children:[J(k,{$color:`var(--down)`}),` Failed`]})]})]})}var Qn=864e5,$n=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function er(){let{cadence:e}=ot(),[t,n]=q(`24h`),[r,i]=q(`tokens`),[a,o]=q(`model`),s=ye(t),c=De(r),l=K(()=>s.grain===`daily`?ae(Date.now()-s.ms):Math.floor((Date.now()-s.ms)/6e4)*6e4,[s]),u=K(()=>l+s.ms,[l,s]),d=K(()=>ae(Date.now()-371*Qn),[]),f={since:l,grain:s.grain},p=L({...f,groupBy:s.by},e(6e4,`res:usage`)),m=L({...f,groupBy:s.by,splitBy:`provider`},e(6e4,`res:usage`)),h=L({...f,groupBy:s.by,splitBy:`model`},e(6e4,`res:usage`)),g=L({...f,groupBy:s.by,splitBy:`apiKey`},e(6e4,`res:usage`)),_=L({...f,groupBy:a},e(6e4,`res:usage`)),v=L({...f,groupBy:`credential`},e(6e4,`res:usage`)),y=L({since:d,grain:`daily`,groupBy:`day`},e(3e5,`res:usage`)),b=Ze(),x=Qe(),S=et(),C=K(()=>{let e=new Map;for(let t of S.data??[])for(let n of t.targets)e.set(n.model,n.provider);return e},[S.data]),w=K(()=>{let e=new Map;for(let t of b.data??[])e.set(t.id,t.label);return e},[b.data]),T=K(()=>{let e=new Map;for(let t of x.data??[])e.set(t.id,t.label);return e},[x.data]),E=p.data??[],D=ce(E),ee=A(D),O={legend:`Nothing recorded`,message:`No requests landed in this window. Widen the range, or send traffic through the gateway.`};return Y(z,{$gap:4,children:[J(lt,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:p.isLoading?`Reading usage…`:`${I(D.requests)} requests and ${R(D.costUsd)} over the last ${s.label}.`,actions:J(ft,{children:xe.map(e=>J(pt,{type:`button`,$size:`sm`,$on:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:e.id},e.id))})}),J(mt,{buckets:E,since:l,until:u,by:s.by,rangeLabel:s.label}),J(W,{legend:`Traffic`,meta:s.by===`hour`?`By hour`:`By day`,query:p,isEmpty:E.length===0,empty:O,children:J(Zn,{buckets:E,by:s.by,since:l,until:u})}),J(ft,{children:Ie.map(e=>J(pt,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:`Rank by ${e.label.toLowerCase()}`},e.id))}),J(W,{legend:`Traffic by upstream model`,meta:`${c.label}, ${s.by===`hour`?`by hour`:`by day`}`,query:h,isEmpty:(h.data??[]).length===0,empty:O,children:J(Ln,{buckets:h.data??[],by:s.by,since:l,until:u,metric:c,providers:C})}),Y(nt,{$min:`480px`,$gap:4,children:[Y(z,{$gap:4,children:[J(W,{legend:`Providers`,meta:c.label,query:m,isEmpty:(m.data??[]).length===0,empty:O,children:J(Vn,{buckets:m.data??[],by:s.by,since:l,until:u,metric:c})}),J(An,{days:y.data??[],now:Date.now()})]}),Y(z,{$gap:4,children:[J(W,{legend:`Token mix`,meta:I(ee),query:p,isEmpty:E.length===0,empty:O,children:J(Xn,{buckets:E,by:s.by,since:l,until:u})}),J(W,{legend:`Models`,meta:$n.find(e=>e.id===a)?.column,query:_,isEmpty:(_.data??[]).length===0,empty:O,actions:J(ft,{children:$n.map(e=>J(pt,{type:`button`,$size:`sm`,$on:e.id===a,"aria-pressed":e.id===a,onClick:()=>o(e.id),children:e.label},e.id))}),children:J(Jn,{buckets:_.data??[],metric:c})}),J(W,{legend:`Accounts`,meta:c.label,query:v,isEmpty:(v.data??[]).length===0,empty:O,children:J(Jn,{buckets:v.data??[],metric:c,names:T,unknownLabel:`No account`})})]})]}),J(W,{legend:`API keys`,meta:c.label,query:g,isEmpty:(g.data??[]).length===0,empty:O,children:J(jn,{buckets:g.data??[],by:s.by,since:l,until:u,metric:c,names:w})})]})}var tr=er;export{tr as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./Rack-
|
|
1
|
+
import{b as e}from"./Rack-xBT_6EtM.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),n=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t as n,n as t};
|