omnigateway 0.4.13 → 0.5.1
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 +52 -1
- package/bin/omni.js +6970 -6733
- package/gateway.js +9440 -8038
- package/package.json +1 -1
- package/public/assets/{CopyValue-C2DkO9Yz.js → CopyValue-DNNJGDI5.js} +5 -5
- package/public/assets/{Field-B79Yxdit.js → Field-B2rnk3JM.js} +1 -1
- package/public/assets/{Match-BWa6L0L1.js → Match-CvkEmOIG.js} +1 -1
- package/public/assets/{Panel-CoulMx6R.js → Panel-BeQOQoap.js} +2 -2
- package/public/assets/Rack-DdhpgQWD.js +316 -0
- package/public/assets/{Readout-D1XEfywe.js → Readout-CZfn5JDy.js} +1 -1
- package/public/assets/RequestTable-I1TrD689.js +11 -0
- package/public/assets/States-2kaQxx-s.js +54 -0
- package/public/assets/SummaryDeck-BisdRswW.js +15 -0
- package/public/assets/{Toggle-CRrH9nDt.js → Toggle-BvOELhpy.js} +1 -1
- package/public/assets/{TokenBreakdown-C2NsJnqO.js → TokenBreakdown-En1JT4tT.js} +1 -1
- package/public/assets/WindowChart-Bvbkz9rt.js +11 -0
- package/public/assets/_app-a3VUev6k.js +1 -0
- package/public/assets/_app.accounts-CYPB-7Xt.js +59 -0
- package/public/assets/_app.console-C4x5F3d0.js +44 -0
- package/public/assets/_app.database-B-9oB52r.js +24 -0
- package/public/assets/_app.index-NBeanmyf.js +62 -0
- package/public/assets/_app.keys-DK9jdOqT.js +82 -0
- package/public/assets/_app.logs-Dr6fApsE.js +58 -0
- package/public/assets/_app.models-CGBQ2QaS.js +148 -0
- package/public/assets/_app.plugins._pluginId-DXzhupNH.js +20 -0
- package/public/assets/_app.settings-zTFRyxhZ.js +58 -0
- package/public/assets/_app.usage-BCCimHY0.js +76 -0
- package/public/assets/chevron-right-mGs1is3r.js +1 -0
- package/public/assets/client-CQGHWD56.js +39 -0
- package/public/assets/index-C3LoGDKu.js +178 -0
- package/public/assets/login-bJoYdBqx.js +45 -0
- package/public/assets/plus-Bqi8Y2Xd.js +1 -0
- package/public/assets/queries-GAue98pY.js +145 -0
- package/public/assets/reasons-Du1OBWAM.js +1 -0
- package/public/assets/shared-DQOWYTp3.js +77 -0
- package/public/assets/stream-Bu-m1Z1Y.js +1 -0
- package/public/assets/{trash-2-DwMK-JrZ.js → trash-2-BDA1rQVQ.js} +1 -1
- package/public/index.html +3 -3
- package/public/shared/dashboard-sdk.js +1 -1
- package/public/assets/Rack-HM36SprU.js +0 -314
- package/public/assets/States-DtkkMzEu.js +0 -54
- package/public/assets/_app-DVpIsUid.js +0 -1
- package/public/assets/_app.accounts-64d_cxir.js +0 -64
- package/public/assets/_app.console-BBuBmLRI.js +0 -44
- package/public/assets/_app.database-J9Ujio8l.js +0 -24
- package/public/assets/_app.index-BX4yKEXO.js +0 -62
- package/public/assets/_app.keys-2sKwhZJc.js +0 -76
- package/public/assets/_app.logs-DuHXYrZU.js +0 -68
- package/public/assets/_app.models-B0kTfPtn.js +0 -148
- package/public/assets/_app.plugins._pluginId-BOXRBToU.js +0 -20
- package/public/assets/_app.settings-DoaOUmc1.js +0 -46
- package/public/assets/_app.usage-B5sxB40E.js +0 -83
- package/public/assets/index-iCfSaRSG.js +0 -178
- package/public/assets/login-B9CJqU--.js +0 -36
- package/public/assets/plus-DKapAGoR.js +0 -1
- package/public/assets/queries-CX9mStps.js +0 -145
- package/public/assets/reasons-Cb8yF4Oy.js +0 -1
- package/public/assets/shared-Cct_4xwp.js +0 -84
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import{d as e,nt as t,t as n,tt as r}from"./queries-CX9mStps.js";import{a as i,t as a}from"./Rack-HM36SprU.js";import{D as o,n as s,r as c,t as l}from"./States-DtkkMzEu.js";import{i as u}from"./Field-B79Yxdit.js";import{t as d}from"./Panel-CoulMx6R.js";import{useLayoutEffect as f,useRef as p,useState as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";import _ from"styled-components";var v=[100,200,500],y=[{value:``,label:`All levels`},{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warnings and errors`},{value:`error`,label:`Errors only`}],b=_(t)`
|
|
2
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
`,x=_(u)`
|
|
5
|
-
width: auto;
|
|
6
|
-
`,S=_.div`
|
|
7
|
-
display: grid;
|
|
8
|
-
grid-template-rows: auto minmax(0, 1fr);
|
|
9
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
10
|
-
min-height: 0;
|
|
11
|
-
flex: 1;
|
|
12
|
-
`,C=_(d)`
|
|
13
|
-
min-height: 0;
|
|
14
|
-
|
|
15
|
-
> div {
|
|
16
|
-
display: flex;
|
|
17
|
-
flex: 1;
|
|
18
|
-
flex-direction: column;
|
|
19
|
-
min-height: 0;
|
|
20
|
-
}
|
|
21
|
-
`,w=_.div`
|
|
22
|
-
flex: 1;
|
|
23
|
-
min-height: 0;
|
|
24
|
-
overflow-x: auto;
|
|
25
|
-
overflow-y: auto;
|
|
26
|
-
`,T=_.pre`
|
|
27
|
-
margin: 0;
|
|
28
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
29
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
30
|
-
font-size: 12px;
|
|
31
|
-
line-height: 1.65;
|
|
32
|
-
white-space: pre;
|
|
33
|
-
`,E=_.div`
|
|
34
|
-
color: ${({theme:e,$level:t})=>t===`error`?e.color.down:t===`warn`?e.color.warn:t===`debug`?e.color.inkFaint:e.color.ink};
|
|
35
|
-
`,D=_.p`
|
|
36
|
-
margin: 0;
|
|
37
|
-
padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
|
|
38
|
-
border-top: 1px solid ${({theme:e})=>e.color.rule};
|
|
39
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
40
|
-
font-size: 12px;
|
|
41
|
-
`,O=_.code`
|
|
42
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
43
|
-
word-break: break-all;
|
|
44
|
-
`;function k({read:e}){return e.source===`file`?g(D,{children:[`Reading `,h(O,{children:e.path}),`, named by `,h(O,{children:`OMNI_LOG_FILE`}),`. That variable says where the gateway's output is being captured; it does not redirect it.`]}):e.source===`journal`?g(D,{children:[`Reading the systemd journal for `,h(O,{children:`omnigateway.service`}),`. To read a file instead, redirect the gateway's output to one and point `,h(O,{children:`OMNI_LOG_FILE`}),` at the same path.`]}):null}function A(){let{cadence:t}=i(),[u,d]=m(200),[_,D]=m(``),O=e(u,_,t(n)),A=O.data,M=A?.lines??[],N=p(null),P=p(!0);return f(()=>{let e=N.current;e!==null&&P.current&&A!==void 0&&(e.scrollTop=e.scrollHeight)},[A]),g(S,{children:[h(a,{legend:`Console`,title:`Gateway output`,summary:O.isLoading?`Reading the gateway's own output…`:`${o(M.length)} lines of what this process is doing. Requests are in Logs; prompt bodies, tokens and keys are never written here.`,actions:g(b,{children:[h(x,{value:_,"aria-label":`Which levels to show`,onChange:e=>D(e.target.value),children:y.map(e=>h(`option`,{value:e.value,children:e.label},e.value))}),h(x,{value:u,"aria-label":`How many lines to fetch`,onChange:e=>d(Number(e.target.value)),children:v.map(e=>g(`option`,{value:e,children:[`last `,e]},e))})]})}),g(C,{legend:`Process output`,meta:A===void 0?void 0:h(r,{children:j(A)}),flush:!0,children:[A===void 0?null:h(k,{read:A}),h(w,{ref:N,"data-testid":`console-terminal`,onScroll:e=>{let t=e.currentTarget;P.current=t.scrollHeight-t.scrollTop-t.clientHeight<=8},children:O.isError?h(s,{error:O.error,onRetry:()=>void O.refetch()}):O.isLoading?h(`div`,{style:{padding:12},children:h(c,{rows:10})}):A!==void 0&&A.source===`none`?h(l,{legend:`Nothing is capturing this gateway`,message:"Its output is going to a terminal, so there is nothing to read back. To capture it, run the gateway under systemd with `omni service install`, or start it with `omni start`, which redirects output to a file and points OMNI_LOG_FILE at it."}):M.length===0?h(l,{legend:`Nothing to show`,message:_===``?`This log is empty. The gateway writes here when it boots, refreshes a token, or polls a quota.`:`No line in this window is at that level. Widen the filter to see everything.`}):h(T,{children:M.map((e,t)=>h(E,{$level:e.level,children:e.raw},`${e.at??0}-${t}`))})})]})]})}function j(e){return e.source===`file`?`log file`:e.source===`journal`?`systemd journal`:`not captured`}var M=A;export{M as component};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import{$ as e,H as t,I as n,K as r,N as i,Q as a,S as o,_ as s,a as c,at as l,b as u,lt as d,m as f,nt as p,ot as m,rt as h}from"./queries-CX9mStps.js";import{g,o as _,t as v}from"./Rack-HM36SprU.js";import{A as y,O as b,i as x,j as S,n as C,r as w,t as T,w as E}from"./States-DtkkMzEu.js";import{r as D,t as O}from"./Field-B79Yxdit.js";import{t as k}from"./Meter-stpt3vQu.js";import{t as A}from"./Panel-CoulMx6R.js";import{i as j,n as M,r as N,t as P}from"./Table-CVDZ69Zx.js";import{t as F}from"./Readout-D1XEfywe.js";import{n as I}from"./reasons-Cb8yF4Oy.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=g(`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=g(`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
|
-
font-size: 12px;
|
|
3
|
-
color: ${({theme:e})=>e.color.down};
|
|
4
|
-
`,J=U.p`
|
|
5
|
-
font-size: 12px;
|
|
6
|
-
color: ${({theme:e})=>e.color.ok};
|
|
7
|
-
`,Y=U.div`
|
|
8
|
-
display: grid;
|
|
9
|
-
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
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:t}){let r=n(),[i,a]=z({}),[o,s]=z(null),[c,u]=z(!1),f={keepLatest:i.keepLatest??(t===void 0?``:String(t.keepLatest)),maxAgeDays:i.maxAgeDays??(t===void 0?``:String(t.maxAgeDays))};return V(A,{legend:`Retention`,actions:V(d,{type:`button`,$size:`sm`,disabled:r.isPending||t===void 0,onClick:()=>{u(!1);let e=X(f);if(!e.ok){s(e.problem);return}s(null),r.mutate(e.policy,{onSuccess:()=>{u(!0),a({})},onError:e=>s(x(e))})},children:r.isPending?`Saving…`:`Save retention`}),children:H(l,{$gap:3,children:[V(Y,{children:K.map(t=>V(O,{label:t.label,hint:t.hint,children:n=>H(p,{$gap:2,children:[V(D,{...n,min:1,max:t.max,step:1,value:f[t.id],onChange:e=>a({...i,[t.id]:e.target.value})}),V(e,{children:t.unit})]})},t.id))}),o===null?null:V(q,{role:`alert`,children:o}),c&&o===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
|
-
font-size: 12px;
|
|
13
|
-
color: ${({theme:e})=>e.color.down};
|
|
14
|
-
`,ee=U.input`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
17
|
-
max-width: 40ch;
|
|
18
|
-
`;function te(){let e=t(),n=f(),r=i(),a=Q(),s=u(),g=o(),[v,y]=z(null),[S,D]=z(null),[k,F]=z(null),[I,L]=z(!1),R=e.data??[],B=H(d,{type:`button`,$variant:`primary`,$size:`sm`,disabled:n.isPending,onClick:()=>n.mutate(),children:[V(W,{}),n.isPending?`Copying…`:`Take a snapshot`]}),U=H(l,{$gap:2,children:[H(p,{$gap:2,$wrap:!0,children:[V(O,{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(d,{type:`button`,$variant:`danger`,$size:`sm`,disabled:k===null||g.isPending,onClick:()=>L(!0),children:g.isPending?`Replacing…`:`Import`})]}),g.isError?V($,{role:`alert`,children:x(g.error)}):null,r.isError?V($,{role:`alert`,children:x(r.error)}):null,n.isError?V($,{role:`alert`,children:x(n.error)}):null]});return H(A,{legend:`Snapshots`,meta:`${R.length}`,actions:B,footer:U,flush:!0,children:[e.isError?V(C,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?V(`div`,{style:{padding:12},children:V(w,{rows:3})}):R.length===0?V(T,{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(d,{type:`button`,$variant:`primary`,$size:`sm`,disabled:n.isPending,onClick:()=>n.mutate(),children:`Take the first snapshot`})}):V(h,{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(e=>H(j,{children:[V(M,{$mono:!0,children:V(m,{style:{maxWidth:`38ch`,display:`block`},children:e.filename})}),V(M,{children:e.reason}),V(M,{$align:`right`,$mono:!0,children:E(e.sizeBytes)}),V(M,{$align:`right`,$mono:!0,children:b(e.createdAt)}),V(M,{$align:`right`,children:H(p,{$gap:1,$justify:`flex-end`,children:[V(d,{as:`a`,$size:`sm`,href:c(e.id),download:e.filename,children:`Download`}),V(d,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>y(e),children:`Restore`}),V(d,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>D(e),children:`Delete`})]})})]},e.id))})]})}),V(_,{open:v!==null,onOpenChange:e=>{e||y(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:r.isPending,onConfirm:()=>{v!==null&&r.mutate(v.id,{onSuccess:a,onSettled:()=>y(null)})}}),V(_,{open:S!==null,onOpenChange:e=>{e||D(null)},title:`Delete snapshot`,body:S===null?``:`Deleting ${S.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:s.isPending,onConfirm:()=>{S!==null&&s.mutate(S.id,{onSettled:()=>D(null)})}}),V(_,{open:I,onOpenChange:L,title:`Import database`,body:k===null?``:`Replacing the live database with ${k.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:g.isPending,onConfirm:()=>{k!==null&&g.mutate(k,{onSuccess:a,onSettled:()=>L(!1)})}})]})}var ne=U.p`
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
color: ${({theme:e})=>e.color.ok};
|
|
21
|
-
`,re=U.p`
|
|
22
|
-
font-size: 12px;
|
|
23
|
-
color: ${({theme:e})=>e.color.down};
|
|
24
|
-
`;function ie(){let e=s(),t=r(),[n,i]=z(!1),o=e.data,c=o===void 0||o.logicalBytes===0?0:o.freePageBytes/o.logicalBytes;return H(B,{children:[V(v,{legend:`Database`,title:`Storage, snapshots, and retention`,summary:e.isLoading?`Measuring the database…`:`The one SQLite file this gateway runs from, the copies taken of it, and how long they are kept.`}),V(A,{legend:`Size`,meta:o===void 0?void 0:`schema v${o.stats.schemaVersion}`,actions:H(d,{type:`button`,$size:`sm`,disabled:t.isPending||o===void 0,onClick:()=>i(!0),children:[V(G,{}),t.isPending?`Compacting…`:`Compact`]}),footer:t.isError?V(re,{role:`alert`,children:x(t.error)}):t.data===void 0?void 0:V(ne,{role:`status`,children:`Compacted, reclaiming ${E(t.data.reclaimedBytes)} in ${y(t.data.durationMs)}.`}),children:e.isError?V(C,{error:e.error,onRetry:()=>void e.refetch()}):o===void 0?V(w,{rows:3}):H(a,{$min:`180px`,$stretch:!0,children:[V(F,{legend:`Database file`,value:E(o.fileBytes),unit:`${o.stats.pageCount} pages of ${E(o.stats.pageSize)}`,trace:V(k,{fraction:c,label:`${S(c,0)} of the file is reclaimable`})}),V(F,{legend:`Reclaimable`,value:E(o.freePageBytes),unit:`${o.stats.freelistCount} free pages`}),V(F,{legend:`Write-ahead log`,value:E(o.walBytes),unit:`folded into every snapshot`}),V(F,{legend:`Captured bodies`,value:E(o.bodiesBytes),unit:`never in a snapshot`}),V(F,{legend:`Snapshots`,value:E(o.snapshots.totalBytes),unit:`${o.snapshots.count} kept`}),V(F,{legend:`Free disk`,value:E(o.freeDiskBytes),unit:o.freeDiskBytes===null?`not readable here`:`on this filesystem`})]})}),V(te,{}),V(Z,{retention:o?.retention}),V(_,{open:n,onOpenChange:i,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:t.isPending,onConfirm:()=>t.mutate(void 0,{onSettled:()=>i(!1)})})]})}var ae=ie;export{ae as component};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import{$ as e,D as t,G as n,O as r,Q as i,at as a,dt as o,et as s,g as c,h as l,it as u,lt as d,nt as f,ot as p,rt as m,z as h}from"./queries-CX9mStps.js";import{a as g,r as _,t as ee}from"./Rack-HM36SprU.js";import{n as v,t as y}from"./TokenBreakdown-C2NsJnqO.js";import{A as b,D as x,E as S,M as C,N as w,a as T,b as te,d as E,g as D,h as O,j as k,l as A,n as j,o as M,p as N,s as P,t as F,u as I,v as ne,x as re}from"./States-DtkkMzEu.js";import{n as L,t as R}from"./Chip-BltJSw8A.js";import{t as z}from"./Meter-stpt3vQu.js";import{t as B}from"./Panel-CoulMx6R.js";import{i as V,n as H,r as U,t as W}from"./Table-CVDZ69Zx.js";import{t as G}from"./Readout-D1XEfywe.js";import{Fragment as K,jsx as q,jsxs as J}from"react/jsx-runtime";import Y from"styled-components";var X=Y(p)`
|
|
2
|
-
font-weight: 500;
|
|
3
|
-
display: block;
|
|
4
|
-
max-width: 24ch;
|
|
5
|
-
`,Z=Y.span`
|
|
6
|
-
font-size: 11px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
`,ie=Y.div`
|
|
9
|
-
display: grid;
|
|
10
|
-
grid-template-columns: 72px 1fr;
|
|
11
|
-
align-items: center;
|
|
12
|
-
gap: 6px;
|
|
13
|
-
min-width: 172px;
|
|
14
|
-
`,ae=Y.div`
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
gap: 4px;
|
|
18
|
-
`;function oe(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 se(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function ce({credentials:t,health:n,quota:r,burn:i,usage:a,quotaPollIntervalMs:s,now:c}){let l=E(n,e=>e.credentialId),u=E(r,e=>e.credentialId),p=E(i,e=>e.credentialId),h=new Map(a.map(e=>[e.key,e])),g={down:0,warn:1,ok:2,idle:3,live:3},_=t.map(e=>{let t=p.get(e.id)??[];return{credential:e,status:I(l.get(e.id)??[],c,e.enabled,e.disabledReason),quota:te(u.get(e.id)??[]),burn:t,exhaustsAt:oe(t),usage:h.get(e.id)}}).sort((e,t)=>g[e.status.state]-g[t.status.state]||se(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return q(B,{legend:`Accounts`,meta:`${t.length} connected`,flush:!0,actions:q(d,{as:o,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:t.length===0?q(F,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:q(d,{as:o,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):q(m,{children:J(W,{children:[q(`thead`,{children:J(`tr`,{children:[q(U,{children:`Account`}),q(U,{children:`Provider`}),q(U,{$align:`right`,children:`Tier`}),q(U,{children:`Quota`}),q(U,{$align:`right`,children:`TTFT`}),q(U,{$align:`right`,children:`Requests`}),q(U,{$align:`right`,children:`Last used`})]})}),q(`tbody`,{children:_.map(({credential:t,status:n,quota:r,burn:i,usage:a})=>J(V,{children:[q(H,{children:J(f,{$gap:2,children:[q(T,{state:n.state,label:n.note===``?`healthy`:n.note}),J(`div`,{children:[q(X,{children:t.label}),n.note===``?null:q(Z,{children:n.note})]})]})}),q(H,{children:q(L,{provider:t.provider})}),q(H,{$align:`right`,$mono:!0,children:t.tier}),q(H,{children:r.length===0?q(Z,{children:`unknown`}):q(ae,{children:r.map(({window:t,fraction:n})=>J(ie,{children:[q(z,{fraction:n,label:`${M[t.windowType]} window, ${Math.round(n*100)}% used`}),q(e,{children:ne(t,c,s,C,A(i,t.windowType))})]},t.windowType))})}),q(H,{$align:`right`,$mono:!0,children:b(n.ttftMs)}),q(H,{$align:`right`,$mono:!0,children:a===void 0?`—`:x(a.requests)}),q(H,{$align:`right`,$mono:!0,children:C(n.lastUsedAt,c)})]},t.id))})]})})})}var le=Y.ul`
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
`,ue=Y.li`
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
25
|
-
padding: 6px ${({theme:e})=>e.space(3)};
|
|
26
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
27
|
-
|
|
28
|
-
&:last-child {
|
|
29
|
-
border-bottom: 0;
|
|
30
|
-
}
|
|
31
|
-
`,de=Y(p)`
|
|
32
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
max-width: 30ch;
|
|
35
|
-
`,fe=Y(s)`
|
|
36
|
-
color: ${({theme:e})=>e.color.down};
|
|
37
|
-
font-size: 11px;
|
|
38
|
-
`;function pe({logs:e}){let t=e.slice(0,12);return q(B,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:q(d,{as:o,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?q(F,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):q(le,{children:t.map(e=>J(ue,{children:[q(T,{state:D(e),label:O(e)}),q(s,{$dim:!0,children:S(e.at)}),q(de,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:q(s,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),q(u,{}),N(e)?q(s,{$dim:!0,"aria-label":`processing`,children:q(y,{})}):J(K,{children:[e.errorCode===null?null:q(fe,{children:e.errorCode}),e.attempts>1?J(s,{$dim:!0,children:[e.attempts,`×`]}):null,q(s,{$dim:!0,children:q(v,{tokens:e})}),q(s,{$dim:!0,children:b(e.durationMs)}),q(s,{$dim:!0,children:w(e.costUsd)})]})]},e.id))})})}var me=Y.ul`
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
42
|
-
`,Q=Y(p)`
|
|
43
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
44
|
-
font-size: 12.5px;
|
|
45
|
-
`,he=Y.div`
|
|
46
|
-
display: flex;
|
|
47
|
-
height: 5px;
|
|
48
|
-
border-radius: 2px;
|
|
49
|
-
overflow: hidden;
|
|
50
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
51
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
52
|
-
`,ge=Y.div`
|
|
53
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
54
|
-
background: ${({$color:e})=>e};
|
|
55
|
-
opacity: 0.8;
|
|
56
|
-
`,_e=Y.div`
|
|
57
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
58
|
-
`;function ve({models:t,logs:n}){let r=new Map;for(let e of n){let t=r.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,r.set(e.requestedModel,t)}let i=Math.max(1,...[...r.values()].map(e=>e.requests)),a=[...t].map(e=>({model:e,used:r.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return q(B,{legend:`Models`,meta:`${t.length} configured`,actions:q(d,{as:o,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.length===0?q(F,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:q(d,{as:o,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):q(me,{children:a.map(({model:t,used:n})=>{let r=(n?.requests??0)/i,a=[...new Set(t.targets.map(e=>e.provider))];return J(`li`,{children:[J(f,{$gap:2,children:[q(Q,{title:t.id,children:t.id}),t.isAlias?q(R,{children:`alias`}):null,q(R,{$tone:`accent`,children:t.strategy}),q(u,{}),q(s,{$dim:!0,children:x(n?.requests??0)}),q(e,{children:`req`}),q(s,{$dim:!0,children:w(n?.costUsd??0)})]}),J(he,{style:{marginTop:6},title:`${Math.round(r*100)}% of the busiest model`,children:[a.map(e=>q(ge,{$color:`var(--p-${e})`,$grow:r/a.length},e)),q(_e,{$grow:Math.max(0,1-r)})]})]},t.id)})})})}var ye=Y.div`
|
|
59
|
-
display: grid;
|
|
60
|
-
grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
|
|
61
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
62
|
-
`;function be({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=re(r,t),a=P(r,{now:n,spanMs:t,count:32}),o=i.errorRate>=.25?`down`:i.errorRate>=.05?`warn`:`ok`,s=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens;return J(ye,{children:[q(G,{legend:`Requests`,value:x(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:q(_,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),q(G,{legend:`Error rate`,value:k(i.errorRate),unit:`${x(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:q(_,{values:a.map(e=>e.errors),scaleTo:Math.max(...a.map(e=>e.total)),color:`var(--down)`,label:`${i.errors} failed requests against ${i.requests} total`})}),q(G,{legend:`Total tokens`,value:x(s),unit:q(v,{tokens:i}),trace:q(_,{values:a.map(e=>e.tokens),label:`token volume over the window, ${s.toLocaleString(`en-US`)} total`})}),q(G,{legend:`Time to first token`,value:b(i.ttftP50),unit:`p95 ${b(i.ttftP95)}`,trace:q(_,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${b(i.ttftP50)}`})}),q(G,{legend:`Spend`,value:w(i.costUsd),unit:`${x(i.inputTokens+i.outputTokens)} tokens`,trace:q(_,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${w(i.costUsd)} total`})})]})}var $=36e5;function xe(){let{cadence:e}=g(),o=c(),s=l(e(1e4)),u=r(),d=t(500,e(1e4)),f=h(),p=Date.now(),m=Math.floor((p-$)/6e4)*6e4,_=n({groupBy:`credential`,since:m},e(6e4)),v=o.data??[],y=E(s.data?.health??[],e=>e.credentialId),b=v.filter(e=>I(y.get(e.id)??[],p,e.enabled,e.disabledReason).state===`down`),x=o.isLoading||d.isLoading?`Reading the gateway…`:v.length===0?`No accounts are connected, so every request fails at the router.`:b.length>0?`${b.length} account${b.length===1?` is`:`s are`} out of rotation.`:`All ${v.length} accounts are answering. Nothing needs attention.`;return J(K,{children:[q(ee,{legend:`Rack`,title:`Gateway`,summary:x}),d.isError?q(B,{legend:`Traffic`,children:q(j,{legend:`The gateway did not answer`,error:d.error,onRetry:()=>void d.refetch()})}):J(a,{$gap:4,children:[q(be,{logs:d.data??[],windowMs:$,now:p}),q(ce,{credentials:v,health:s.data?.health??[],quota:s.data?.quota??[],burn:s.data?.burn??[],usage:_.data??[],quotaPollIntervalMs:f.data?.quotaPollIntervalMs??3e5,now:p}),J(i,{$min:`340px`,$gap:4,children:[q(ve,{models:u.data??[],logs:d.data??[]}),q(pe,{logs:d.data??[]})]})]})]})}var Se=xe;export{Se as component};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import{$ as e,C as t,O as n,P as r,R as i,at as a,et as o,lt as s,nt as c,ot as l,p as u,rt as d,ut as f}from"./queries-CX9mStps.js";import{m as p,o as m,s as h,t as g}from"./Rack-HM36SprU.js";import{n as _,r as v,t as y}from"./CopyValue-C2DkO9Yz.js";import{t as b}from"./plus-DKapAGoR.js";import{t as x}from"./Toggle-CRrH9nDt.js";import{O as S,i as C,n as w,r as T,t as E}from"./States-DtkkMzEu.js";import{t as D}from"./Chip-BltJSw8A.js";import{n as O,r as k,t as A}from"./Field-B79Yxdit.js";import{t as j}from"./Meter-stpt3vQu.js";import{t as M}from"./Panel-CoulMx6R.js";import{i as N,n as P,r as F,t as I}from"./Table-CVDZ69Zx.js";import{Fragment as L,useState as R}from"react";import{Fragment as z,jsx as B,jsxs as V}from"react/jsx-runtime";import H from"styled-components";var U=[{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 W(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var G={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},ee={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=G[e.dimension];return e.window===null?t:`${t} ${ee[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 te(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 U)t[W(e)]=``;if(e===null)return t;for(let n of U){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[W(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of U){let o=(e[W(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 Z=H.div`
|
|
2
|
-
display: grid;
|
|
3
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
4
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
5
|
-
`,ne=H.p`
|
|
6
|
-
font-size: 11px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
`;function Q({draft:e,onChange:t,disabled:n=!1}){return V(a,{$gap:2,children:[B(Z,{children:U.map(r=>{let i=W(r);return B(A,{label:K(r),children:a=>B(k,{...a,min:r.dimension===`spend`?void 0:1,step:r.dimension===`spend`?`any`:1,disabled:n,value:e[i]??``,placeholder:`none`,onChange:n=>t({...e,[i]:n.target.value})})},i)})}),B(ne,{children:`Blank means no limit. Token and spend ceilings are debited after a response completes, so a key at its ceiling is refused on its next request rather than its current one. Concurrency counts requests in flight right now and resets when the gateway restarts.`})]})}var re=H.p`
|
|
9
|
-
font-size: 12px;
|
|
10
|
-
color: ${({theme:e})=>e.color.down};
|
|
11
|
-
`,ie=H.p`
|
|
12
|
-
font-size: 12px;
|
|
13
|
-
color: ${({theme:e})=>e.color.warn};
|
|
14
|
-
`;function ae({apiKey:e,onOpenChange:t}){let n=i(),[r,o]=R(()=>Y(e?.limits??{})),[c,l]=R(null);return B(h,{open:e!==null,onOpenChange:t,title:`Edit limits`,description:e===null?void 0:`What "${e.label}" may do per minute, per five hours, and per week. Every field is a ceiling; blank is no limit.`,width:`640px`,footer:V(z,{children:[B(s,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),B(s,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{if(e===null)return;let i=X(r);if(`problem`in i){l(i.problem);return}l(null),n.mutate({id:e.id,limits:i.limits},{onSuccess:()=>t(!1),onError:e=>l(C(e))})},children:n.isPending?`Saving…`:`Save limits`})]}),children:V(a,{$gap:3,children:[e?.limits===null?B(ie,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,B(Q,{draft:r,onChange:o,disabled:n.isPending}),c===null?null:B(re,{role:`alert`,children:c})]})})}var oe=H.div`
|
|
15
|
-
display: grid;
|
|
16
|
-
grid-template-columns: minmax(0, 11rem) minmax(0, 12rem) minmax(0, 1fr) minmax(0, 3.5rem);
|
|
17
|
-
align-items: center;
|
|
18
|
-
gap: ${({theme:e})=>e.space(2)} ${({theme:e})=>e.space(4)};
|
|
19
|
-
`,se=H.span`
|
|
20
|
-
font-size: 11.5px;
|
|
21
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
22
|
-
`,ce=H.p`
|
|
23
|
-
font-size: 11px;
|
|
24
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
25
|
-
`;function le({label:t,readings:n}){return V(a,{$gap:3,children:[B(oe,{children:n.map(n=>{let r=K({dimension:n.dimension,window:n.window}),i=J(n),a=q(n.dimension,n.limit);return V(L,{children:[B(e,{as:`span`,children:r}),B(o,{children:n.used===null?a:`${q(n.dimension,n.used)} of ${a}`}),i===null?B(se,{children:`in flight now, counted in the gateway process`}):B(j,{fraction:Math.min(1,i),label:`${t}, ${r}, ${Math.round(i*100)}% used`}),B(o,{children:i===null?`—`:`${Math.round(i*100)}%`})]},r)})}),B(ce,{children:`Usage counts completed requests still inside each window. Requests in flight are added by the gateway itself and are not shown here.`})]})}var ue=H.div`
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
gap: 2px;
|
|
29
|
-
max-height: 190px;
|
|
30
|
-
overflow-y: auto;
|
|
31
|
-
padding: ${({theme:e})=>e.space(1)};
|
|
32
|
-
border: 1px solid ${({theme:e})=>e.color.ruleStrong};
|
|
33
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
34
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
35
|
-
`,de=H.label`
|
|
36
|
-
display: flex;
|
|
37
|
-
align-items: center;
|
|
38
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
39
|
-
padding: 4px 6px;
|
|
40
|
-
border-radius: 2px;
|
|
41
|
-
cursor: pointer;
|
|
42
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
43
|
-
font-size: 12px;
|
|
44
|
-
|
|
45
|
-
&:hover {
|
|
46
|
-
background: ${({theme:e})=>e.color.panelRaised};
|
|
47
|
-
}
|
|
48
|
-
`,fe=H.p`
|
|
49
|
-
font-size: 12px;
|
|
50
|
-
color: ${({theme:e})=>e.color.warn};
|
|
51
|
-
`,pe=H.p`
|
|
52
|
-
font-size: 12px;
|
|
53
|
-
color: ${({theme:e})=>e.color.down};
|
|
54
|
-
`,me=H.p`
|
|
55
|
-
font-size: 12px;
|
|
56
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
57
|
-
`,he=H(s)`
|
|
58
|
-
gap: 4px;
|
|
59
|
-
`,ge=H.p`
|
|
60
|
-
font-size: 11px;
|
|
61
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
62
|
-
`;function _e({open:t,onOpenChange:r}){let i=n(),l=u(),[d,f]=R(``),[p,m]=R(!0),[g,b]=R([]),[S,w]=R(()=>Y({})),[T,E]=R(!1),[D,k]=R(!1),[j,M]=R(null),[N,P]=R(null),F=()=>{f(``),m(!0),b([]),w(Y({})),E(!1),k(!1),M(null),P(null),l.reset()},I=e=>{e||F(),r(e)},L=Object.values(S).filter(e=>e.trim().length>0).length;return B(h,{open:t,onOpenChange:I,title:j===null?`Create an API key`:`Key created`,description:j===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:j===null?V(z,{children:[B(s,{type:`button`,onClick:()=>I(!1),children:`Cancel`}),B(s,{type:`button`,$variant:`primary`,disabled:l.isPending,onClick:()=>{let e=X(S);if(`problem`in e){E(!0),P(e.problem);return}P(null),l.mutate({label:d.trim().length===0?`api key`:d.trim(),modelAllowlist:p?null:g,limits:e.limits,bodyLoggingOptOut:D},{onSuccess:e=>M(e),onError:e=>P(C(e))})},children:l.isPending?`Creating…`:`Create key`})]}):B(s,{type:`button`,$variant:`primary`,onClick:()=>I(!1),children:`I have copied the key`}),children:j===null?V(a,{$gap:3,children:[B(A,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>B(O,{...e,value:d,placeholder:`api key`,onChange:e=>f(e.target.value)})}),V(a,{$gap:2,children:[V(c,{$gap:2,children:[B(x,{checked:p,label:`Allow every model`,onCheckedChange:m}),B(e,{as:`span`,children:`Allow every model`})]}),p?null:V(z,{children:[B(ue,{children:(i.data??[]).map(e=>V(de,{children:[B(`input`,{type:`checkbox`,checked:g.includes(e.id),onChange:t=>b(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),e.id]},e.id))}),g.length===0?B(fe,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),V(a,{$gap:2,children:[V(c,{$gap:2,children:[V(he,{type:`button`,$size:`sm`,"aria-expanded":T,onClick:()=>E(e=>!e),children:[B(T?v:_,{}),`Limits`]}),B(e,{as:`span`,children:L===0?`no limits; this key is unbounded`:`${L} limit${L===1?``:`s`} set`})]}),T?B(Q,{draft:S,onChange:w}):null]}),V(a,{$gap:2,children:[V(c,{$gap:2,children:[B(x,{checked:D,label:`Never record this key's bodies`,onCheckedChange:k}),B(e,{as:`span`,children:`Never record this key's bodies`})]}),B(ge,{children:`Suppresses body capture for this key whatever the gateway setting says. Choose it for a client whose payloads must not be retained. It cannot be changed after the key is created — issue a new key instead.`})]}),N===null?null:B(pe,{role:`alert`,children:N})]}):V(a,{$gap:3,children:[B(me,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),B(y,{value:j.key,label:`Copy API key`}),V(c,{$gap:2,children:[B(e,{children:`Label`}),B(o,{children:j.label}),B(e,{children:`Prefix`}),B(o,{children:j.prefix})]})]})})}var ve=H(c)`
|
|
63
|
-
gap: 4px;
|
|
64
|
-
flex-wrap: wrap;
|
|
65
|
-
max-width: 34ch;
|
|
66
|
-
`,ye=H.span`
|
|
67
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
68
|
-
`,$=H.span`
|
|
69
|
-
font-size: 11px;
|
|
70
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
71
|
-
`,be=H.div`
|
|
72
|
-
display: flex;
|
|
73
|
-
flex-direction: column;
|
|
74
|
-
align-items: flex-end;
|
|
75
|
-
gap: 2px;
|
|
76
|
-
`;function xe(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 Se(){let n=t(),i=r(),[a,o]=R(!1),[u,h]=R(null),[y,x]=R(null),[C,O]=R(null),k=n.data??[],A=k.filter(e=>e.revokedAt===null),j=n.isLoading?`Reading issued keys…`:k.length===0?`No keys exist, so nothing can call this gateway yet.`:`${A.length} active key${A.length===1?``:`s`} of ${k.length} ever issued.`;return V(z,{children:[B(g,{legend:`Keys`,title:`Gateway API keys`,summary:j,actions:V(s,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[B(b,{}),`Create a key`]})}),B(M,{legend:`Issued keys`,meta:`${k.length}`,flush:!0,children:n.isError?B(w,{error:n.error,onRetry:()=>void n.refetch()}):n.isLoading?B(`div`,{style:{padding:12},children:B(T,{rows:4})}):k.length===0?B(E,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:B(s,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):B(d,{children:V(I,{children:[B(`thead`,{children:V(`tr`,{children:[B(F,{children:`Label`}),B(F,{children:`Prefix`}),B(F,{children:`Allowed models`}),B(F,{$align:`right`,children:`Limits`}),B(F,{$align:`right`,children:`Created`}),B(F,{children:`Body capture`}),B(F,{children:`Status`}),B(F,{})]})}),B(`tbody`,{children:k.map(t=>{let n=y===t.id,r=te(t.limitUsage);return V(L,{children:[V(N,{children:[B(P,{children:B(l,{style:{maxWidth:`24ch`,display:`block`},children:t.label})}),V(P,{$mono:!0,children:[t.prefix,`…`]}),B(P,{children:t.modelAllowlist===null?B(e,{children:`every model`}):t.modelAllowlist.length===0?B(D,{$tone:`down`,children:`no models`}):B(ve,{children:t.modelAllowlist.map(e=>B(D,{children:e},e))})}),B(P,{$align:`right`,children:t.limits===null?B(D,{$tone:`down`,children:`unreadable`}):t.limitUsage.length===0?B(e,{children:`no limits`}):V(be,{children:[V(`span`,{children:[t.limitUsage.length,` limit`,t.limitUsage.length===1?``:`s`]}),B($,{children:xe(r)})]})}),B(P,{$align:`right`,$mono:!0,children:S(t.createdAt)}),B(P,{children:t.bodyLoggingOptOut?B(D,{children:`no bodies`}):B(e,{children:`—`})}),B(P,{children:t.revokedAt===null?B(D,{$tone:`ok`,children:`active`}):B(ye,{title:S(t.revokedAt),children:B(D,{children:`revoked`})})}),B(P,{$align:`right`,children:V(c,{$gap:1,$justify:`flex-end`,children:[t.limitUsage.length===0?null:B(f,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":n,"aria-label":`${n?`Hide`:`Show`} limits for ${t.label}`,title:`${n?`Hide`:`Show`} limits for ${t.label}`,onClick:()=>x(n?null:t.id),children:B(n?v:_,{})}),t.revokedAt===null?V(z,{children:[B(f,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${t.label}`,title:`Edit limits for ${t.label}`,onClick:()=>h(t),children:B(p,{})}),B(s,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>O(t),children:`Revoke`})]}):null]})})]}),n?B(N,{children:B(P,{colSpan:8,children:B(le,{label:t.label,readings:t.limitUsage})})}):null]},t.id)})})]})})}),B(_e,{open:a,onOpenChange:o}),B(ae,{apiKey:u,onOpenChange:e=>{e||h(null)}},u?.id??`none`),B(m,{open:C!==null,onOpenChange:e=>{e||O(null)},title:`Revoke key`,body:C===null?``:`Revoking "${C.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:i.isPending,onConfirm:()=>{C!==null&&i.mutate(C.id,{onSettled:()=>O(null)})}})]})}var Ce=Se;export{Ce as component};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import{$ as e,C as t,D as n,at as r,et as i,g as ee,j as a,lt as o,n as te,nt as s,ot as c,rt as l,s as u}from"./queries-CX9mStps.js";import{a as ne,s as re,t as ie}from"./Rack-HM36SprU.js";import{n as d,r as f,t as p}from"./TokenBreakdown-C2NsJnqO.js";import{A as m,D as h,E as g,F as _,N as v,O as y,a as ae,f as b,g as oe,h as se,k as ce,n as x,p as S,r as C,t as w}from"./States-DtkkMzEu.js";import{n as T,t as E}from"./Chip-BltJSw8A.js";import{i as D,n as O}from"./Field-B79Yxdit.js";import{t as k}from"./Panel-CoulMx6R.js";import{i as le,n as A,r as j,t as ue}from"./Table-CVDZ69Zx.js";import{useEffect as M,useMemo as N,useState as P}from"react";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import R from"styled-components";var z={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.`}},B=new Intl.NumberFormat(`en-US`),V=R.p`
|
|
2
|
-
font-size: 12px;
|
|
3
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
4
|
-
max-width: 62ch;
|
|
5
|
-
`,H=R(V)`
|
|
6
|
-
border-left: 2px solid ${({theme:e})=>e.color.ruleStrong};
|
|
7
|
-
padding-left: ${({theme:e})=>e.space(2)};
|
|
8
|
-
`,U=R.h4`
|
|
9
|
-
font-size: 11px;
|
|
10
|
-
font-weight: 600;
|
|
11
|
-
letter-spacing: 0.12em;
|
|
12
|
-
text-transform: uppercase;
|
|
13
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
14
|
-
margin: 0;
|
|
15
|
-
`,W=R.figcaption`
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: center;
|
|
18
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
19
|
-
flex-wrap: wrap;
|
|
20
|
-
margin-bottom: 4px;
|
|
21
|
-
`,G=R.figure`
|
|
22
|
-
margin: 0;
|
|
23
|
-
min-width: 0;
|
|
24
|
-
`,K=R.pre`
|
|
25
|
-
margin: 0;
|
|
26
|
-
padding: ${({theme:e})=>e.space(2)};
|
|
27
|
-
max-height: 260px;
|
|
28
|
-
overflow: auto;
|
|
29
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
30
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
31
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
32
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
-
font-size: 11.5px;
|
|
34
|
-
line-height: 1.5;
|
|
35
|
-
white-space: pre-wrap;
|
|
36
|
-
word-break: break-word;
|
|
37
|
-
`;function q(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(t.omitted!==!0||typeof t.reason!=`string`)return null;let n=t.serializedBytes;return{omitted:!0,reason:t.reason,serializedBytes:typeof n==`number`?n:0}}function J({title:e,stage:t,value:n}){let r=q(n);return L(G,{children:[L(W,{children:[I(U,{children:e}),t===void 0?null:I(E,{children:t})]}),r===null?n==null?I(V,{children:`Nothing was recorded for this half — it never happened, or never completed.`}):I(K,{children:JSON.stringify(n,null,2)}):L(V,{children:[`Too large to keep: `,r.reason,`. The payload was`,` `,B.format(r.serializedBytes),` bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace.`]})]})}function Y({attempt:t}){return L(r,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[L(e,{as:`h3`,children:[`Attempt `,t.attempt,` · `,t.provider]}),t.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request sent to the provider`,stage:`post-RTK`,value:t.request}),I(J,{title:`Response from the provider`,value:t.response}),t.streamChunks===null?null:I(J,{title:`Raw stream frames (${h(t.streamChunks.length)})`,value:t.streamChunks})]})}function X({body:t}){let n=t.artifact;if(n===null){let n=z[t.detailState===`ready`?`corrupt`:t.detailState];return L(r,{$gap:1,children:[I(e,{children:n.legend}),I(V,{children:n.message})]})}return L(r,{$gap:3,children:[n.attempts.length===0?null:I(H,{children:`The client request below is what arrived at the gateway. Each attempt request is what went upstream after RTK filters ran, so the two are not the same payload — compare them to see what compression actually removed.`}),L(r,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[I(e,{as:`h3`,children:`Client`}),n.client.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request from the client`,stage:`pre-RTK`,value:n.client.request}),I(J,{title:`Response returned to the client`,value:n.client.response})]}),n.attempts.map(e=>I(Y,{attempt:e},`${e.attempt}-${e.provider}`)),n.error===null||n.error===void 0?null:I(J,{title:`Error`,value:n.error})]})}function de({requestId:e}){let t=a(e),n=t.data===void 0||t.data.detailState!==`ready`?void 0:`${B.format(t.data.sizeBytes)} bytes on disk`;return I(k,{legend:`Captured bodies`,...n===void 0?{}:{meta:n},...t.data?.truncated===!0?{actions:I(E,{$tone:`warn`,children:`truncated`})}:{},children:t.isError?I(x,{error:t.error,onRetry:()=>void t.refetch()}):t.isPending?I(C,{rows:3}):I(X,{body:t.data})})}var fe=[50,100,250,500],pe=R(s)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,me=R(O)`
|
|
41
|
-
width: 220px;
|
|
42
|
-
`,Z=R(D)`
|
|
43
|
-
width: auto;
|
|
44
|
-
`,Q=R(k)`
|
|
45
|
-
flex: 1;
|
|
46
|
-
min-height: 0;
|
|
47
|
-
|
|
48
|
-
> div {
|
|
49
|
-
display: flex;
|
|
50
|
-
flex: 1;
|
|
51
|
-
flex-direction: column;
|
|
52
|
-
min-height: 0;
|
|
53
|
-
}
|
|
54
|
-
`,he=R(l)`
|
|
55
|
-
flex: 1;
|
|
56
|
-
min-height: 0;
|
|
57
|
-
overflow-y: auto;
|
|
58
|
-
`;function ge(e){let[t,n]=P(Date.now);return M(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function _e({log:e}){return I(A,{$align:`right`,$mono:!0,...S(e)?{"aria-label":`processing`}:{title:f(e)},children:S(e)?I(p,{}):I(d,{tokens:e})})}var ve=R.dl`
|
|
59
|
-
display: grid;
|
|
60
|
-
grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
|
|
61
|
-
gap: 6px ${({theme:e})=>e.space(3)};
|
|
62
|
-
margin: 0;
|
|
63
|
-
font-size: 12.5px;
|
|
64
|
-
`,$=R.dd`
|
|
65
|
-
margin: 0;
|
|
66
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
67
|
-
word-break: break-all;
|
|
68
|
-
`;function ye(){let{cadence:a,live:l}=ne(),[d,f]=P(100),[p,D]=P(`all`),[O,k]=P(``),[M,R]=P(null),z=n(d,a(te)),B=ee(),V=t(),H=u(),U=(z.data??[]).some(S),W=ge(l&&U),G=N(()=>{let e=new Map;for(let t of B.data??[])e.set(t.id,t.label);return e},[B.data]),K=N(()=>{let e=new Map;for(let t of V.data??[])e.set(t.id,t.label);return e},[V.data]),q=O.trim().toLowerCase(),J=(z.data??[]).filter(e=>p===`failed`&&!b(e)?!1:q.length===0||e.requestedModel.toLowerCase().includes(q)||(e.resolvedModel??``).toLowerCase().includes(q)||(e.errorCode??``).toLowerCase().includes(q)||(e.credentialId===null?``:G.get(e.credentialId)??``).toLowerCase().includes(q)||(e.apiKeyId===null?``:K.get(e.apiKeyId)??e.apiKeyId).toLowerCase().includes(q)),Y=(z.data??[]).filter(b).length,X=(z.data??[]).filter(S).length;return L(F,{children:[I(ie,{legend:`Logs`,title:`Recent requests`,summary:z.isLoading?`Reading the request log…`:`${h(z.data?.length??0)} recent requests, ${h(Y)} of them failed${X===0?``:`, ${h(X)} still running`}. ${H.data===!0?`Body capture is on: open a request to read what it sent and received.`:`Prompt and response bodies are not being recorded.`}`,actions:L(pe,{children:[I(me,{value:O,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>k(e.target.value)}),L(Z,{value:p,"aria-label":`Show which requests`,onChange:e=>D(e.target.value),children:[I(`option`,{value:`all`,children:`All requests`}),I(`option`,{value:`failed`,children:`Failed only`})]}),I(Z,{value:d,"aria-label":`How many requests to fetch`,onChange:e=>f(Number(e.target.value)),children:fe.map(e=>L(`option`,{value:e,children:[`last `,e]},e))})]})}),I(Q,{legend:`Request log`,meta:`${J.length} shown`,flush:!0,children:z.isError?I(x,{error:z.error,onRetry:()=>void z.refetch()}):z.isLoading?I(`div`,{style:{padding:12},children:I(C,{rows:8})}):J.length===0?I(w,{legend:`Nothing to show`,message:(z.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):I(he,{"data-testid":`request-log-scroller`,children:L(ue,{children:[I(`thead`,{children:L(`tr`,{children:[I(j,{}),I(j,{$align:`right`,children:`Time`}),I(j,{children:`Requested`}),I(j,{children:`Routed to`}),I(j,{children:`Account`}),I(j,{children:`Key`}),I(j,{$align:`right`,children:`Try`}),I(j,{$align:`right`,children:`TTFT`}),I(j,{$align:`right`,children:`Total`}),I(j,{$align:`right`,children:`Tokens`}),I(j,{$align:`right`,children:`Cost`}),I(j,{children:`Outcome`})]})}),I(`tbody`,{children:J.map(t=>L(le,{$selectable:!0,onClick:()=>R(t),children:[I(A,{children:I(ae,{state:oe(t),label:se(t)})}),I(A,{$align:`right`,$mono:!0,title:y(t.at),children:g(t.at)}),I(A,{$mono:!0,children:I(c,{style:{display:`block`,maxWidth:`20ch`},children:t.requestedModel||`—`})}),I(A,{children:t.resolvedProvider===null?I(e,{children:S(t)?`routing…`:`not routed`}):L(s,{$gap:1,children:[I(T,{provider:t.resolvedProvider}),I(i,{$dim:!0,children:t.resolvedModel??`—`})]})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`18ch`},children:t.credentialId===null?`—`:G.get(t.credentialId)??_(t.credentialId)})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`16ch`},title:t.apiKeyId??void 0,children:t.apiKeyId===null?`—`:K.get(t.apiKeyId)??_(t.apiKeyId)})}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:t.attempts}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:m(t.ttftMs)}),I(A,{$align:`right`,$mono:!0,children:S(t)?ce(Math.max(0,W-t.at)):m(t.durationMs)}),I(_e,{log:t}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:v(t.costUsd)}),I(A,{children:S(t)?I(E,{$tone:`accent`,children:`live`}):t.errorCode===null?I(E,{$tone:`ok`,children:t.status}):I(E,{$tone:`down`,children:t.errorCode})})]},t.id))})]})})}),I(re,{open:M!==null,onOpenChange:e=>{e||R(null)},title:`Request detail`,width:`760px`,footer:I(o,{type:`button`,onClick:()=>R(null),children:`Close`}),children:M===null?null:L(r,{$gap:3,children:[L(ve,{children:[I(e,{as:`dt`,children:`Request id`}),I($,{children:M.id}),I(e,{as:`dt`,children:`At`}),I($,{children:y(M.at)}),I(e,{as:`dt`,children:`Requested model`}),I($,{children:M.requestedModel||`—`}),I(e,{as:`dt`,children:`Routed to`}),I($,{children:S(M)?`—`:M.resolvedProvider===null?`not routed`:`${M.resolvedProvider} · ${M.resolvedModel??`—`}`}),I(e,{as:`dt`,children:`Account`}),I($,{children:M.credentialId===null?`—`:G.get(M.credentialId)??M.credentialId}),I(e,{as:`dt`,children:`Key`}),I($,{children:M.apiKeyId===null?`—`:K.get(M.apiKeyId)??M.apiKeyId}),I(e,{as:`dt`,children:`Attempts`}),I($,{children:S(M)?`—`:M.attempts}),I(e,{as:`dt`,children:`Status`}),I($,{children:S(M)?`in flight`:M.errorCode===null?M.status:`${M.status} ${M.errorCode}`}),I(e,{as:`dt`,children:`Timing`}),I($,{children:S(M)?`—`:`first token ${m(M.ttftMs)} · total ${m(M.durationMs)}`}),I(e,{as:`dt`,children:`Tokens`}),I($,{children:S(M)?`—`:L(F,{children:[h(M.inputTokens),` in · `,h(M.outputTokens),` out ·`,` `,h(M.cacheReadTokens),` cache read ·`,` `,h(M.cacheWriteTokens),` cache write`]})}),I(e,{as:`dt`,children:`Cost`}),I($,{children:S(M)?`—`:v(M.costUsd)}),I(e,{as:`dt`,children:`RTK compression`}),I($,{children:S(M)?`—`:M.rtkApplied?`${h(M.rtkFilterHits)} hits · ${h(M.rtkOriginalCodeUnits)} → ${h(M.rtkCompressedCodeUnits)} code units · ~${h(M.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),I(e,{as:`dt`,children:`RTK filters`}),I($,{children:M.rtkFilters.length===0?`—`:M.rtkFilters.join(`, `)})]}),M.degradations.length===0?null:L(r,{$gap:1,children:[I(e,{children:`Capabilities dropped to fit the target`}),I(s,{$gap:1,$wrap:!0,children:M.degradations.map(e=>I(E,{$tone:`warn`,children:e},e))})]}),I(de,{requestId:M.id})]})})]})}var be=ye;export{be as component};
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import{$ as e,F as t,O as n,at as r,et as i,g as a,it as o,lt as s,nt as c,ot as l,ut as u,x as d,y as f,z as p}from"./queries-CX9mStps.js";import{r as m}from"./index-iCfSaRSG.js";import{g as h,o as g,t as _}from"./Rack-HM36SprU.js";import{t as v}from"./plus-DKapAGoR.js";import{t as y}from"./trash-2-DwMK-JrZ.js";import{t as b}from"./Toggle-CRrH9nDt.js";import{i as x,n as S,r as C,t as w}from"./States-DtkkMzEu.js";import{n as T,t as E}from"./Chip-BltJSw8A.js";import{i as D,n as O,r as k,t as A}from"./Field-B79Yxdit.js";import{t as j}from"./Meter-stpt3vQu.js";import{t as M}from"./Panel-CoulMx6R.js";import{i as N,n as ee,r as P,t as F}from"./catalog-BBKm8Ih8.js";import{useEffect as I,useId as te,useState as L}from"react";import{Fragment as R,jsx as z,jsxs as B}from"react/jsx-runtime";import V from"styled-components";var ne=h(`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`}]]),re=h(`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`}]]),H=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ie={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`},ae=V.li`
|
|
2
|
-
padding: ${({theme:e})=>e.space(2)} 0;
|
|
3
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
4
|
-
|
|
5
|
-
&:last-child {
|
|
6
|
-
border-bottom: 0;
|
|
7
|
-
}
|
|
8
|
-
`,oe=V(i)`
|
|
9
|
-
width: 22px;
|
|
10
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
|
-
flex: none;
|
|
12
|
-
`,se=V(E)`
|
|
13
|
-
border-color: ${({theme:e})=>e.color.ok};
|
|
14
|
-
color: ${({theme:e})=>e.color.ok};
|
|
15
|
-
background: ${({theme:e})=>e.color.okWash};
|
|
16
|
-
`,ce=V.div`
|
|
17
|
-
display: grid;
|
|
18
|
-
grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
|
|
19
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
20
|
-
margin-top: ${({theme:e})=>e.space(2)};
|
|
21
|
-
padding-left: 30px;
|
|
22
|
-
`,le=V.div`
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: 3px;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
`,ue=V.div`
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: baseline;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: 6px;
|
|
32
|
-
`,de=V.li`
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
36
|
-
padding: 5px 0;
|
|
37
|
-
`,fe=V(c)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,U=V.label`
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
gap: 6px;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
font-size: 12.5px;
|
|
46
|
-
`,pe=V.p`
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
color: ${({theme:e})=>e.color.down};
|
|
49
|
-
`;function W(e,t,n){return(e[t]??0)*n[t]}function me({modelId:t}){let[n,a]=L({tools:!1,images:!1,reasoning:!1}),[u,f]=L(null),[m,h]=L(null),g=p(),_=d(),v=g.data?.weights,y=()=>{t!==null&&(h(null),_.mutate({modelId:t,need:n},{onSuccess:e=>f(e),onError:e=>{f(null),h(x(e))}}))},S=new Map(H.map(e=>[e,Math.max(1e-4,...(u?.candidates??[]).map(t=>v===void 0?0:Math.abs(W(t.reasons,e,v))))]));return z(M,{legend:`Explain`,meta:t??`no model selected`,actions:B(s,{type:`button`,$size:`sm`,$variant:`primary`,disabled:t===null||_.isPending,onClick:y,children:[z(ne,{}),_.isPending?`Ranking…`:`Rank candidates`]}),children:B(r,{$gap:3,children:[B(r,{$gap:1,children:[z(e,{children:`Pretend the request needs`}),B(fe,{children:[B(U,{children:[z(b,{checked:n.tools,label:`Probe request uses tools`,onCheckedChange:e=>a({...n,tools:e})}),`Tools`]}),B(U,{children:[z(b,{checked:n.images,label:`Probe request includes an image`,onCheckedChange:e=>a({...n,images:e})}),`Images`]}),B(U,{children:[z(b,{checked:n.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>a({...n,reasoning:e})}),`Reasoning`]})]})]}),m===null?null:z(pe,{children:m}),u===null?z(w,{legend:`Not ranked yet`,message:t===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.`}):B(r,{$gap:3,children:[B(c,{$gap:2,$wrap:!0,children:[z(E,{$tone:`accent`,children:u.strategy}),u.deterministic?null:z(E,{$tone:`warn`,children:`order varies per request`}),z(o,{}),B(e,{children:[u.candidates.length,` eligible · `,u.excluded.length,` filtered out`]})]}),u.candidates.length===0?z(w,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):z(`ul`,{children:u.candidates.map((t,n)=>B(ae,{children:[B(c,{$gap:2,children:[z(oe,{children:n+1}),z(T,{provider:t.provider}),z(l,{style:{maxWidth:`22ch`},children:t.credentialLabel}),z(i,{$dim:!0,children:t.model}),B(E,{children:[`tier `,t.tier]}),z(o,{}),n===0?z(se,{children:`would be used`}):null,z(i,{children:t.score.toFixed(2)})]}),v===void 0?null:z(ce,{children:H.map(n=>{let r=W(t.reasons,n,v),a=S.get(n)??1;return B(le,{title:ie[n],children:[B(ue,{children:[z(e,{children:n}),z(i,{$dim:!0,$size:`10.5px`,children:r.toFixed(2)})]}),z(j,{fraction:Math.abs(r)/a,height:4,tone:`var(--accent)`,label:`${n} contributes ${r.toFixed(2)} of ${t.score.toFixed(2)}`})]},n)})})]},`${t.credentialId}:${t.model}`))}),u.excluded.length===0?null:B(r,{$gap:1,children:[z(e,{children:`Filtered out`}),z(`ul`,{children:u.excluded.map(e=>B(de,{children:[z(i,{$dim:!0,children:e.model}),z(o,{}),z(E,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}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){let n=N(e,t);return n===null?null:{costInput:String(n.input),costOutput:String(n.output),costCacheRead:String(n.cacheRead),costCacheWrite5m:String(n.cacheWrite5m),costCacheWrite1h:String(n.cacheWrite1h)}}function he(e,t){let n=ee(e,t);return n===null?null:{contextWindow:String(n.contextWindow),maxOutputTokens:String(n.maxOutputTokens)}}var ge={oauth:`OAuth`,apiKey:`an API key`};function Y(e){return e.map(e=>ge[e]).join(` or `)}function _e(e){let t={};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){let r=n[e];return r===void 0||r.length===0||P(e,t).some(e=>r.includes(e))}function ve(e,t){return F[e].models.filter(n=>X(e,n.id,t))}function ye(e,t,n){if(t.trim().length===0||X(e,t,n))return null;let r=n[e]??[];return`${e} serves this model to ${Y(P(e,t))} only, and every ${e} account here is ${Y(r)}. Requests routed here will fail.`}function be(e,t){return{...e,...t,...J(t.provider,t.model)??{},contextWindow:``,maxOutputTokens:``}}function xe(e=`anthropic`){let t=F[e].defaultModel,n=J(e,t);return{key:q(),provider:e,endpointId:``,model:t,tier:`1`,weight:`1`,costInput:n?.costInput??`0`,costOutput:n?.costOutput??`0`,costCacheRead:n?.costCacheRead??``,costCacheWrite5m:n?.costCacheWrite5m??``,costCacheWrite1h:n?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,tools:!0,images:!0,reasoning:!0}}function Se(){return{id:``,strategy:`score`,isAlias:!1,targets:[xe()]}}function Ce(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),tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function we(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();if(r.provider===`custom`&&i.length===0)return{ok:!1,problem:`${e} needs a custom endpoint.`};let a=r.model.trim();if(a.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let o=Number(r.tier);if(!Number.isInteger(o)||o<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let s=Number(r.weight);if(!Number.isFinite(s)||s<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let c=Number(r.costInput),l=Number(r.costOutput);if(!Number.isFinite(c)||c<0||!Number.isFinite(l)||l<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let u=r.costCacheRead.trim().length>0,d=Number(r.costCacheRead);if(u&&(!Number.isFinite(d)||d<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let f=r.costCacheWrite5m.trim().length>0,p=Number(r.costCacheWrite5m);if(f&&(!Number.isFinite(p)||p<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let m=r.costCacheWrite1h.trim().length>0,h=Number(r.costCacheWrite1h);if(m&&(!Number.isFinite(h)||h<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let g=r.contextWindow.trim().length>0,_=Number(r.contextWindow);if(g&&(!Number.isInteger(_)||_<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let v=r.maxOutputTokens.trim().length>0,y=Number(r.maxOutputTokens);if(v&&(!Number.isInteger(y)||y<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:a,tier:o,weight:s,costPerMTok:{input:c,output:l,...u?{cacheRead:d}:{},...f?{cacheWrite5m:p}:{},...m?{cacheWrite1h:h}:{}},...g?{contextWindow:_}:{},...v?{maxOutputTokens:y}:{},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 Te=Object.keys(F),Ee=V.fieldset`
|
|
50
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
51
|
-
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
52
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
53
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
54
|
-
margin: 0;
|
|
55
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
59
|
-
min-width: 0;
|
|
60
|
-
`,De=V.div`
|
|
61
|
-
display: grid;
|
|
62
|
-
grid-template-columns: minmax(140px, 1.4fr) minmax(160px, 2fr) 72px 72px;
|
|
63
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
64
|
-
align-items: end;
|
|
65
|
-
|
|
66
|
-
@media (max-width: 720px) {
|
|
67
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
68
|
-
}
|
|
69
|
-
`,Oe=V.div`
|
|
70
|
-
display: grid;
|
|
71
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
72
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
73
|
-
align-items: end;
|
|
74
|
-
`,Z=V.div`
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
gap: 4px;
|
|
78
|
-
min-width: 0;
|
|
79
|
-
`,ke=V(c)`
|
|
80
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
81
|
-
flex-wrap: wrap;
|
|
82
|
-
`,Ae=V.p`
|
|
83
|
-
font-size: 11.5px;
|
|
84
|
-
color: ${({theme:e})=>e.color.down};
|
|
85
|
-
margin: 0;
|
|
86
|
-
`,Q=V.label`
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
gap: 6px;
|
|
90
|
-
cursor: pointer;
|
|
91
|
-
`;function je({target:t,index:n,onChange:i,onRemove:a,removable:l,endpoints:d,held:f}){let p=te(),h=F[t.provider],g=ve(t.provider,f),_=ye(t.provider,t.model,f),v=(e,n)=>{i({...t,[e]:n})},x=J(t.provider,t.model),S=he(t.provider,t.model),C=e=>{i(be(t,e))};return B(Ee,{$provider:t.provider,children:[B(c,{$gap:2,children:[B(e,{as:`legend`,children:[`Target `,n+1]}),z(o,{}),z(u,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!l,"aria-label":`Remove target ${n+1}`,title:l?`Remove target ${n+1}`:`A model needs at least one target`,onClick:a,children:z(y,{})})]}),B(De,{children:[B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-provider`,children:`Provider`}),z(D,{id:`${p}-provider`,value:t.provider,onChange:e=>{let n=e.target.value,r=F[n].models.some(e=>e.id===t.model);C({provider:n,model:r?t.model:F[n].defaultModel})},children:Te.map(e=>z(`option`,{value:e,children:m[e]},e))})]}),t.provider===`custom`?B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-endpoint`,children:`Endpoint`}),B(D,{id:`${p}-endpoint`,value:t.endpointId,onChange:e=>v(`endpointId`,e.target.value),children:[z(`option`,{value:``,children:`Choose endpoint`}),d.map(e=>z(`option`,{value:e.id,children:e.label},e.id))]})]}):null,B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-model`,children:`Provider model`}),z(O,{id:`${p}-model`,list:`${p}-catalog`,value:t.model,placeholder:h.defaultModel,onChange:e=>C({provider:t.provider,model:e.target.value})}),z(`datalist`,{id:`${p}-catalog`,children:g.map(e=>z(`option`,{value:e.id,children:e.label},e.id))}),_===null?null:z(Ae,{role:`note`,children:_})]}),B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-tier`,children:`Tier`}),z(k,{id:`${p}-tier`,min:1,step:1,value:t.tier,onChange:e=>v(`tier`,e.target.value)})]}),B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-weight`,children:`Weight`}),z(k,{id:`${p}-weight`,min:0,step:.1,value:t.weight,onChange:e=>v(`weight`,e.target.value)})]})]}),B(r,{$gap:1,children:[B(c,{$gap:2,children:[z(e,{children:`Price per million tokens`}),z(o,{}),x===null?z(e,{as:`span`,children:`not in the catalog — price it yourself`}):B(s,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:t.costInput===x.costInput&&t.costOutput===x.costOutput&&t.costCacheRead===x.costCacheRead&&t.costCacheWrite5m===x.costCacheWrite5m&&t.costCacheWrite1h===x.costCacheWrite1h,onClick:()=>i({...t,...x}),children:[z(re,{}),`Use list price`]})]}),B(Oe,{children:[B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-in`,children:`Input`}),z(k,{id:`${p}-in`,min:0,step:.01,value:t.costInput,onChange:e=>v(`costInput`,e.target.value)})]}),B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-out`,children:`Output`}),z(k,{id:`${p}-out`,min:0,step:.01,value:t.costOutput,onChange:e=>v(`costOutput`,e.target.value)})]}),B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-cache`,children:`Cache read`}),z(k,{id:`${p}-cache`,min:0,step:.01,placeholder:`same as input`,value:t.costCacheRead,onChange:e=>v(`costCacheRead`,e.target.value)})]}),B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-write5m`,children:`Cache write 5m`}),z(k,{id:`${p}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:t.costCacheWrite5m,onChange:e=>v(`costCacheWrite5m`,e.target.value)})]}),B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-write1h`,children:`Cache write 1h`}),z(k,{id:`${p}-write1h`,min:0,step:.01,placeholder:`2x input`,value:t.costCacheWrite1h,onChange:e=>v(`costCacheWrite1h`,e.target.value)})]})]})]}),B(r,{$gap:1,children:[B(c,{$gap:2,children:[z(e,{children:`Token limits`}),z(o,{}),S===null?z(e,{as:`span`,children:`not in the catalog — state them yourself`}):z(e,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),B(Oe,{children:[B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-context`,children:`Context window`}),z(k,{id:`${p}-context`,min:1,step:1024,placeholder:S?.contextWindow??`published`,value:t.contextWindow,onChange:e=>v(`contextWindow`,e.target.value)})]}),B(Z,{children:[z(e,{as:`label`,htmlFor:`${p}-maxout`,children:`Max output`}),z(k,{id:`${p}-maxout`,min:1,step:1024,placeholder:S?.maxOutputTokens??`published`,value:t.maxOutputTokens,onChange:e=>v(`maxOutputTokens`,e.target.value)})]})]})]}),B(r,{$gap:1,children:[z(e,{children:`Capabilities`}),B(ke,{children:[B(Q,{children:[z(b,{checked:t.tools,label:`Target ${n+1} supports tools`,onCheckedChange:e=>v(`tools`,e)}),`Tools`]}),B(Q,{children:[z(b,{checked:t.images,label:`Target ${n+1} supports images`,onCheckedChange:e=>v(`images`,e)}),`Images`]}),B(Q,{children:[z(b,{checked:t.reasoning,label:`Target ${n+1} supports reasoning`,onCheckedChange:e=>v(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Me=V.p`
|
|
92
|
-
font-size: 11.5px;
|
|
93
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
94
|
-
`,Ne=V.p`
|
|
95
|
-
font-size: 12px;
|
|
96
|
-
color: ${({theme:e})=>e.color.down};
|
|
97
|
-
`,Pe=V.p`
|
|
98
|
-
font-size: 12px;
|
|
99
|
-
color: ${({theme:e})=>e.color.ok};
|
|
100
|
-
`,Fe=V(c)`
|
|
101
|
-
gap: 8px;
|
|
102
|
-
`;function Ie({model:n,onSaved:i,onDeleted:l}){let[u,d]=L(()=>n===null?Se():Ce(n)),[p,m]=L(null),[h,_]=L(!1),[y,S]=L(!1),C=t(),w=f(),T=a(),E=_e(T.data??[]),k=(T.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),j=n?.id??null;I(()=>{d(n===null?Se():Ce(n)),m(null),_(!1)},[j]);let N=G.find(e=>e.id===u.strategy);return B(R,{children:[z(M,{legend:n===null?`New model`:`Edit model`,meta:n===null?void 0:n.id,actions:B(R,{children:[n===null?null:z(s,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>S(!0),children:`Delete`}),z(s,{type:`button`,$variant:`primary`,$size:`sm`,disabled:C.isPending,onClick:()=>{_(!1);let e=we(u);if(!e.ok){m(e.problem);return}m(null),C.mutate(e.model,{onSuccess:()=>{_(!0),i(e.model.id)},onError:e=>m(x(e))})},children:C.isPending?`Saving…`:n===null?`Create model`:`Save changes`})]}),children:B(r,{$gap:3,children:[z(A,{label:`Model name`,hint:n===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=>z(O,{...e,value:u.id,disabled:n!==null,placeholder:`fast`,onChange:e=>d({...u,id:e.target.value})})}),z(A,{label:`Routing strategy`,children:e=>z(D,{...e,value:u.strategy,onChange:e=>d({...u,strategy:e.target.value}),children:G.map(e=>z(`option`,{value:e.id,children:e.label},e.id))})}),N===void 0?null:z(Me,{children:N.blurb}),B(Fe,{children:[z(b,{checked:u.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>d({...u,isAlias:e})}),B(r,{$gap:0,children:[z(e,{as:`span`,children:`Alias`}),z(Me,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),B(r,{$gap:2,children:[B(c,{children:[z(e,{children:`Targets`}),z(o,{}),B(s,{type:`button`,$size:`sm`,onClick:()=>d({...u,targets:[...u.targets,xe(u.targets.at(-1)?.provider??`anthropic`)]}),children:[z(v,{}),`Add target`]})]}),u.targets.map((e,t)=>z(je,{target:e,index:t,removable:u.targets.length>1,endpoints:k,held:E,onChange:t=>d({...u,targets:u.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>d({...u,targets:u.targets.filter(t=>t.key!==e.key)})},e.key))]}),p===null?null:z(Ne,{role:`alert`,children:p}),h&&p===null?z(Pe,{role:`status`,children:`Saved.`}):null]})}),z(g,{open:y,onOpenChange:S,title:`Delete model`,body:n===null?``:`Deleting "${n.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:w.isPending,onConfirm:()=>{n!==null&&w.mutate(n.id,{onSuccess:()=>{S(!1),l()},onError:e=>{S(!1),m(x(e))}})}})]})}var Le=V.div`
|
|
103
|
-
display: grid;
|
|
104
|
-
grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
|
|
105
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
106
|
-
align-items: start;
|
|
107
|
-
|
|
108
|
-
@media (max-width: 980px) {
|
|
109
|
-
grid-template-columns: minmax(0, 1fr);
|
|
110
|
-
}
|
|
111
|
-
`,Re=V(r)`
|
|
112
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
113
|
-
min-width: 0;
|
|
114
|
-
`,ze=V.button`
|
|
115
|
-
display: flex;
|
|
116
|
-
flex-direction: column;
|
|
117
|
-
gap: 4px;
|
|
118
|
-
width: 100%;
|
|
119
|
-
padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
|
|
120
|
-
text-align: left;
|
|
121
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:`transparent`};
|
|
122
|
-
border: 0;
|
|
123
|
-
border-left: 2px solid
|
|
124
|
-
${({theme:e,$selected:t})=>t?e.color.accent:`transparent`};
|
|
125
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
|
|
128
|
-
&:hover {
|
|
129
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:e.color.panelSunk};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
&:last-child {
|
|
133
|
-
border-bottom: 0;
|
|
134
|
-
}
|
|
135
|
-
`,Be=V(l)`
|
|
136
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
137
|
-
font-size: 12.5px;
|
|
138
|
-
display: block;
|
|
139
|
-
max-width: 100%;
|
|
140
|
-
`,Ve=V.div`
|
|
141
|
-
display: flex;
|
|
142
|
-
gap: 2px;
|
|
143
|
-
`,He=V.span`
|
|
144
|
-
width: 12px;
|
|
145
|
-
height: 3px;
|
|
146
|
-
border-radius: 1px;
|
|
147
|
-
background: ${({$provider:e})=>`var(--p-${e})`};
|
|
148
|
-
`,$=`\0new`;function Ue(){let t=n(),[r,a]=L(null),l=t.data??[],u=r===$?null:l.find(e=>e.id===r)??null,d=r===$||r===null&&!t.isLoading&&l.length===0;I(()=>{r===null&&l.length!==0&&a(l[0]?.id??null)},[l,r]);let f=t.isLoading?`Reading configured models…`:l.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${l.length} model${l.length===1?``:`s`} routing to ${l.reduce((e,t)=>e+t.targets.length,0)} targets.`;return B(R,{children:[z(_,{legend:`Models`,title:`Virtual models`,summary:f,actions:B(s,{type:`button`,$variant:`primary`,onClick:()=>a($),children:[z(v,{}),`New model`]})}),B(Le,{children:[z(M,{legend:`Configured`,meta:`${l.length}`,flush:!0,children:t.isError?z(S,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?z(`div`,{style:{padding:12},children:z(C,{rows:4})}):l.length===0?z(w,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:z(s,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>a($),children:`New model`})}):z(`div`,{children:l.map(t=>{let n=[...new Set(t.targets.map(e=>e.provider))];return B(ze,{type:`button`,$selected:t.id===r,"aria-pressed":t.id===r,onClick:()=>a(t.id),children:[B(c,{$gap:2,style:{width:`100%`},children:[z(Be,{title:t.id,children:t.id}),z(o,{}),t.isAlias?z(E,{children:`alias`}):null]}),B(c,{$gap:2,style:{width:`100%`},children:[z(Ve,{children:n.map(e=>z(He,{$provider:e,title:e},e))}),z(e,{children:t.strategy}),z(o,{}),B(i,{$dim:!0,$size:`11px`,children:[t.targets.length,` target`,t.targets.length===1?``:`s`]})]})]},t.id)})})}),B(Re,{children:[u===null&&!d?z(M,{legend:`Editor`,children:t.isLoading?z(C,{rows:5}):z(w,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):z(Ie,{model:u,onSaved:e=>{a(e),t.refetch()},onDeleted:()=>{a(null),t.refetch()}}),z(me,{modelId:u?.id??null})]})]})]})}var We=Ue;export{We as component};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import{J as e,X as t,Y as n,Z as r,at as i,k as a}from"./queries-CX9mStps.js";import{a as o,s}from"./index-iCfSaRSG.js";import{t as c}from"./Rack-HM36SprU.js";import{n as l,r as u,t as d}from"./States-DtkkMzEu.js";import{t as f}from"./Panel-CoulMx6R.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(i){let a=w.get(i);if(a!==void 0)return a;let o={get:(e,t)=>n(C(i,e),t),post:(e,n)=>t(C(i,e),n),put:(e,t)=>r(C(i,e),t),del:t=>e(C(i,t))};return w.set(i,o),o}var E=h(e=>s(()=>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
|
-
font-size: 13px;
|
|
3
|
-
color: ${({theme:e})=>e.color.down};
|
|
4
|
-
`,j=S.p`
|
|
5
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
6
|
-
font-size: 12px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
overflow-wrap: anywhere;
|
|
9
|
-
`,M=S.p`
|
|
10
|
-
font-size: 12px;
|
|
11
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
12
|
-
max-width: 68ch;
|
|
13
|
-
`;function N(e){return e instanceof Error?e.message:typeof e==`string`?e:`The plugin threw a value that is not an error.`}var P=class extends p{state={message:null};static getDerivedStateFromError(e){return{message:N(e)}}componentDidUpdate(e){e.pluginId!==this.props.pluginId&&this.state.message!==null&&this.setState({message:null})}componentDidCatch(e,t){}render(){let{message:e}=this.state;return e===null?this.props.children:b(f,{legend:`Plugin failed`,meta:this.props.pluginId,children:x(i,{$gap:2,children:[x(A,{children:[this.props.pluginName,` stopped rendering.`]}),b(j,{children:e}),b(M,{children:`The rest of the console is unaffected. Reload the page to try this screen again, and report the message above to whoever maintains the plugin.`})]})})}},F=S.p`
|
|
14
|
-
font-size: 13px;
|
|
15
|
-
color: ${({theme:e})=>e.color.warn};
|
|
16
|
-
`,I=S.p`
|
|
17
|
-
font-size: 12px;
|
|
18
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
19
|
-
max-width: 68ch;
|
|
20
|
-
`;function L({pluginId:e}){let t=a(),n=D(),r=t.data?.find(t=>t.id===e),o=r?.ui??null,s=o?.compatible===!0?o.entry:null,p=v(()=>s===null?null:k(e,s,n),[e,s,n]);if(t.isError)return x(y,{children:[b(c,{legend:`Plugin`,title:`Plugins`,summary:`The installed plugins are unknown.`}),b(l,{legend:`Plugins unavailable`,error:t.error})]});if(r===void 0)return x(y,{children:[b(c,{legend:`Plugin`,title:t.isPending?`Loading…`:e,summary:t.isPending?`Reading the installed plugins.`:`This gateway does not run a plugin with that id.`}),t.isPending?b(u,{}):b(d,{legend:`Not installed`,message:`No plugin with the id ${e} is installed. Install it and restart the gateway.`})]});let h=b(c,{legend:`Plugin`,title:r.nav?.label??r.name,summary:`${r.name} ${r.version}, installed as ${r.id}.`});return o===null?x(y,{children:[h,b(d,{legend:`No interface`,message:`${r.name} runs entirely in the gateway and has no console screen.`})]}):p===null?x(y,{children:[h,b(f,{legend:`Interface unavailable`,meta:r.id,children:x(i,{$gap:2,children:[b(F,{children:o.reason??`This plugin's interface does not match this gateway.`}),b(I,{children:`The plugin's server half is unaffected and keeps running. Update the plugin, or the gateway, so the two agree on a dashboard SDK version.`})]})})]}):x(y,{children:[h,b(P,{pluginId:r.id,pluginName:r.name,children:b(m,{fallback:b(u,{}),children:b(p,{})})})]})}function R(){let{pluginId:e}=o.useParams();return b(L,{pluginId:e})}export{R as component};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import{$ as e,L as t,O as n,at as r,c as i,et as a,it as o,lt as s,nt as c,o as l,z as u}from"./queries-CX9mStps.js";import{t as d}from"./Rack-HM36SprU.js";import{t as f}from"./Toggle-CRrH9nDt.js";import{i as p,n as m,r as h}from"./States-DtkkMzEu.js";import{i as g,n as _,t as v}from"./Field-B79Yxdit.js";import{t as y}from"./Meter-stpt3vQu.js";import{t as b}from"./Panel-CoulMx6R.js";import{useEffect as x,useState as S}from"react";import{Fragment as C,jsx as w,jsxs as T}from"react/jsx-runtime";import E from"styled-components";var D=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],O=E(a)`
|
|
2
|
-
display: block;
|
|
3
|
-
white-space: pre;
|
|
4
|
-
overflow-x: auto;
|
|
5
|
-
padding: 0.75rem;
|
|
6
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
7
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
8
|
-
border-radius: 4px;
|
|
9
|
-
font-size: 0.8125rem;
|
|
10
|
-
line-height: 1.5;
|
|
11
|
-
`,k=E.div`
|
|
12
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
13
|
-
font-size: 0.8125rem;
|
|
14
|
-
margin-bottom: 0.25rem;
|
|
15
|
-
`,A=E.p`
|
|
16
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
17
|
-
font-size: 0.8125rem;
|
|
18
|
-
margin: 0;
|
|
19
|
-
`,j=E.div`
|
|
20
|
-
display: grid;
|
|
21
|
-
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
|
|
22
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
23
|
-
`,M=[{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 N(){let[e,t]=S(`claude`),[i,o]=S(()=>({claude:{},opencode:{}})),u=n(),d=i[e],f=typeof d.defaultModel==`string`&&d.defaultModel!==``?d:void 0,_=l(e,f),y=D.find(t=>t.id===e);return w(b,{legend:`Agent setup`,children:T(r,{children:[w(c,{children:D.map(n=>w(s,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),T(A,{children:[y?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,T(a,{children:[`omni setup `,e]}),` to write these files directly.`]}),(u.data?.length??0)>0?w(j,{children:M.map(t=>w(v,{label:t.label,children:n=>T(g,{...n,value:d[t.key]??``,onChange:n=>o(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[w(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),u.data?.map(e=>w(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,u.isLoading?w(h,{rows:2}):_.isError?w(m,{error:_.error,onRetry:()=>void _.refetch()}):_.isLoading?w(h,{rows:4}):(u.data?.length??0)===0?w(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):f===void 0?T(A,{children:[`Choose a default model to generate `,y?.label,` settings.`]}):_.data===void 0||_.data.length===0?w(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):_.data.map(e=>T(`div`,{children:[w(k,{children:e.path}),w(O,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),_.isError?w(A,{children:p(_.error)}):null]})})}var P=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Preference for accounts with fewer requests in flight right now.`}],F=[{id:`maxAttempts`,label:`Attempts per request`,hint:`How many candidates dispatch may try before giving up. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`How long a request may take across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures on one account and model before it is taken out of rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Base wait before a tripped account is probed again. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before maintenance prunes them.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often each account's provider is asked for its remaining quota. 0 disables polling. Takes effect on restart.`,unit:`ms`,step:6e4,min:0}],I=E.div`
|
|
24
|
-
display: grid;
|
|
25
|
-
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
26
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
27
|
-
`,L=E(r)`
|
|
28
|
-
gap: 6px;
|
|
29
|
-
`,R=E.p`
|
|
30
|
-
font-size: 11px;
|
|
31
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
32
|
-
`,z=E.p`
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
color: ${({theme:e})=>e.color.down};
|
|
35
|
-
`,B=E.p`
|
|
36
|
-
font-size: 12px;
|
|
37
|
-
color: ${({theme:e})=>e.color.ok};
|
|
38
|
-
`,V=E.p`
|
|
39
|
-
font-size: 12px;
|
|
40
|
-
color: ${({theme:e})=>e.color.warn};
|
|
41
|
-
max-width: 72ch;
|
|
42
|
-
|
|
43
|
-
code {
|
|
44
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
45
|
-
}
|
|
46
|
-
`;function H(e){let t={};for(let n of P)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of F)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function U(e){let t={};for(let n of P){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 F){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`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function W(){let n=u(),l=i(),g=t(),[E,D]=S({}),[O,k]=S(null),[A,j]=S(!1);x(()=>{n.data!==void 0&&D(H(n.data))},[n.data]);let M=Math.max(1e-4,...P.map(e=>Math.abs(Number(E[`w.${e.id}`])||0)));return T(C,{children:[w(d,{legend:`Settings`,title:`Routing and retention`,summary:`These apply to every request the gateway routes. Changes take effect on the next request; nothing is restarted.`,actions:w(s,{type:`button`,$variant:`primary`,disabled:g.isPending||n.isLoading,onClick:()=>{j(!1);let e=U(E);if(!e.ok){k(e.problem);return}k(null),g.mutate(e.settings,{onSuccess:()=>j(!0),onError:e=>k(p(e))})},children:g.isPending?`Saving…`:`Save changes`})}),n.isError?w(b,{legend:`Settings`,children:w(m,{error:n.error,onRetry:()=>void n.refetch()})}):n.isLoading?w(b,{legend:`Settings`,children:w(h,{rows:6})}):T(r,{$gap:4,children:[w(b,{legend:`Scoring weights`,meta:`relative to each other`,footer:T(c,{children:[w(e,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),w(o,{})]}),children:w(I,{children:P.map(e=>{let t=Number(E[`w.${e.id}`])||0;return T(L,{children:[w(v,{label:e.label,children:t=>w(_,{...t,type:`number`,step:.5,value:E[`w.${e.id}`]??``,onChange:t=>D({...E,[`w.${e.id}`]:t.target.value})})}),w(y,{fraction:Math.abs(t)/M,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),w(R,{children:e.blurb})]},e.id)})})}),w(b,{legend:`Limits`,children:w(I,{children:F.map(t=>w(L,{children:w(v,{label:t.label,hint:t.hint,children:n=>T(c,{$gap:2,children:[w(_,{...n,type:`number`,min:t.min,step:t.step,value:E[t.id]??``,onChange:e=>D({...E,[t.id]:e.target.value})}),w(e,{children:t.unit})]})})},t.id))})}),w(b,{legend:`Historical tool results`,children:T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.rtkEnabled===`true`,onCheckedChange:e=>D({...E,rtkEnabled:String(e)}),label:`Enable RTK compression`}),w(R,{children:`Compress recognized historical non-error tool results before provider dispatch. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a built-in detector recognizes a high-confidence shell-output format. Compression is deterministic and lossy. Disabled by default.`})]})}),w(b,{legend:`Prompt caching`,children:T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.autoCacheEnabled===`true`,onCheckedChange:e=>D({...E,autoCacheEnabled:String(e)}),label:`Add a cache breakpoint when a client sends none`}),w(R,{children:`Anthropic only caches a prompt the request marks, so a client that marks nothing pays full price to resend the same prefix every turn. This marks the end of the system prompt on Anthropic requests that carry no breakpoint of their own. Requests that already mark one are left exactly as they arrived, and prompts too short to be cacheable are skipped. Enabled by default.`})]})}),w(b,{legend:`Request and response bodies`,meta:l.data===!0?`permitted by the environment`:`not permitted`,children:T(r,{$gap:3,children:[l.data===!0?null:T(V,{children:[`This gateway was started without `,w(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,w(`code`,{children:`.env`}),` `,`and restart before turning capture on. Two keys mean an admin session on its own cannot start recording prompts.`]}),T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.bodyLoggingEnabled===`true`,disabled:l.data!==!0,onCheckedChange:e=>D({...E,bodyLoggingEnabled:String(e)}),label:`Capture request and response bodies`}),w(R,{children:`Stores what each client sent and what each provider returned, encrypted under OMNI_ENCRYPTION_KEY beside the database. Bearer tokens and API keys are masked first and headers are never captured. Bodies expire on the log retention window above, and the newest 100,000 requests are kept whatever that window says. Off by default.`})]}),T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.bodyLoggingCaptureStreamChunks===`true`,disabled:l.data!==!0||E.bodyLoggingEnabled!==`true`,onCheckedChange:e=>D({...E,bodyLoggingCaptureStreamChunks:String(e)}),label:`Also keep raw stream frames`}),w(R,{children:`Retains the raw SSE frames of each attempt as well as the reassembled response. The only way to debug stream framing itself, and by far the most expensive thing capture can store, so it is gated separately rather than implied.`})]})]})}),O===null?null:w(z,{role:`alert`,children:O}),A&&O===null?w(B,{role:`status`,children:`Settings saved.`}):null,w(N,{}),w(b,{legend:`Known limits`,children:T(r,{$gap:2,children:[T(c,{$gap:2,children:[w(a,{$dim:!0,children:`rate limits`}),w(R,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),T(c,{$gap:2,children:[w(a,{$dim:!0,children:`logs`}),w(R,{children:`Request rows record routing and token counts only. Prompts and responses are written only when body capture above is on, and to a separate encrypted store; credentials are never written to either.`})]})]})})]})]})}var G=W;export{G as component};
|