omnigateway 0.1.6 → 0.1.7
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 +24 -5
- package/bin/omni.js +454 -228
- package/gateway.js +225 -59
- package/package.json +1 -1
- package/public/assets/{Chip-Ccqsb_Mq.js → Chip-C69u2U_b.js} +2 -2
- package/public/assets/{CopyValue-cAwgC1sU.js → CopyValue-CJy2T0H6.js} +1 -1
- package/public/assets/{Field-Devm4K46.js → Field-Sc8mDqJv.js} +1 -1
- package/public/assets/{Lamp-BXSUIAtG.js → Lamp-7jD_9929.js} +2 -2
- package/public/assets/{Meter-Fn8X7t60.js → Meter-C0nUftAa.js} +2 -2
- package/public/assets/{Modal-Dqir9wBz.js → Modal-CiVHSJmm.js} +2 -2
- package/public/assets/Rack-CMqGBP4I.js +147 -0
- package/public/assets/{Readout-BKpOZIGX.js → Readout-Dv2dZWtI.js} +4 -4
- package/public/assets/{States-DBzsiHjQ.js → States-D55MhqMx.js} +10 -10
- package/public/assets/{Table-DPDJeeVc.js → Table-DBB3jdgi.js} +1 -1
- package/public/assets/{Toggle-BhViDMm9.js → Toggle-BoGjb5oi.js} +3 -3
- package/public/assets/_app-p5Mz7sXD.js +1 -0
- package/public/assets/_app.accounts-B5wMO9TH.js +51 -0
- package/public/assets/_app.console-Bka7AkiL.js +25 -0
- package/public/assets/_app.index-MnQuadXb.js +61 -0
- package/public/assets/_app.keys-BX8k8COP.js +39 -0
- package/public/assets/_app.logs-DD-sd4fn.js +33 -0
- package/public/assets/_app.models-CezFNL6y.js +144 -0
- package/public/assets/{_app.settings-DA1aYcR4.js → _app.settings-D1taAt8B.js} +3 -3
- package/public/assets/{_app.usage-DAyYUfIi.js → _app.usage-BRhEvwVr.js} +28 -28
- package/public/assets/index-vCuK1fRQ.js +170 -0
- package/public/assets/{login-DXHM-Noj.js → login-DaC-wVpI.js} +8 -8
- package/public/assets/{queries-BMwc6EvM.js → queries-2E6-CboE.js} +12 -12
- package/public/assets/{trash-2-JF_uX2gE.js → trash-2--aH2iKg-.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/Rack-XtfiZ6GC.js +0 -147
- package/public/assets/_app-B8lqq_ks.js +0 -1
- package/public/assets/_app.accounts-DSMHSYBF.js +0 -51
- package/public/assets/_app.index-DXH5sH41.js +0 -61
- package/public/assets/_app.keys-DdEyVy_b.js +0 -39
- package/public/assets/_app.logs-Camxditb.js +0 -33
- package/public/assets/_app.models-CuD-JtGS.js +0 -144
- package/public/assets/index-BtjyVE1i.js +0 -170
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import{A as e,F as t,G as n,I as r,L as i,M as a,O as o,Ot as s,U as c,V as l,h as u,k as d,kt as f,m as p,qt as m}from"./queries-BMwc6EvM.js";import{t as h}from"./index-BtjyVE1i.js";import{f as g,r as _,t as v}from"./Lamp-BXSUIAtG.js";var y=m(f(),1),b=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),x=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),S=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),C=e=>{let t=S(e);return t.charAt(0).toUpperCase()+t.slice(1)},w={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},T=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},E=(0,y.createContext)({}),D=()=>(0,y.useContext)(E),O=(0,y.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=D()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,y.createElement)(`svg`,{ref:c,...w,width:t??l??w.width,height:t??l??w.height,stroke:e??f,strokeWidth:m,className:b(`lucide`,p,i),...!a&&!T(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,y.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),k=(e,t)=>{let n=(0,y.forwardRef)(({className:n,...r},i)=>(0,y.createElement)(O,{ref:i,iconNode:t,className:b(`lucide-${x(C(e))}`,`lucide-${e}`,n),...r}));return n.displayName=C(e),n},A=k(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),j=k(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),ee=k(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),te=k(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),ne=k(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),re=k(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),ie=k(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),ae=k(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),oe=k(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),se=k(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ce=k(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),M=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),N=new Intl.NumberFormat(`en-US`);function P(e){return Number.isFinite(e)?e<1e4?N.format(Math.round(e)):M.format(e).toLowerCase():`—`}function F(e){return Number.isFinite(e)?e===0?`$0`:e<.01?`$${e.toFixed(4)}`:e<100?`$${e.toFixed(2)}`:`$${M.format(e).toLowerCase()}`:`—`}function I(e){return e==null||!Number.isFinite(e)?`—`:e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/6e4)}m`}function L(e,t=1){return Number.isFinite(e)?`${(e*100).toFixed(t)}%`:`—`}var R=[[6e4,1e3,`s`],[36e5,6e4,`m`],[864e5,36e5,`h`],[1/0,864e5,`d`]];function z(e){let t=Math.abs(e);if(t<1e3)return`0s`;let n=R.find(([e])=>t<e);return n===void 0?`—`:`${Math.floor(t/n[1])}${n[2]}`}function B(e,t=Date.now()){if(e==null||!Number.isFinite(e))return`—`;let n=e-t;return Math.abs(n)<5e3?`just now`:n<0?`${z(n)} ago`:`in ${z(n)}`}function V(e){return new Date(e).toLocaleTimeString(`en-GB`,{hour12:!1})}function H(e){return e==null||!Number.isFinite(e)?`—`:new Date(e).toLocaleString(`en-GB`,{year:`numeric`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1})}function U(e,t=8){return e.length<=t?e:`${e.slice(0,t)}…`}var W=s(),G=(0,y.createContext)(null);function le({children:e}){let[t,n]=(0,y.useState)(!0),r=(0,y.useCallback)(()=>n(e=>!e),[]),i=(0,y.useMemo)(()=>({live:t,toggle:r,cadence:e=>t?e:!1}),[t,r]);return(0,W.jsx)(G,{value:i,children:e})}function K(){return(0,y.use)(G)??{live:!1,toggle:()=>{},cadence:()=>!1}}var ue=l.svg`
|
|
2
|
-
display: block;
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 100%;
|
|
5
|
-
overflow: visible;
|
|
6
|
-
`;function q(e,t,n,r){if(e.length===0)return``;let i=e.length===1?0:t/(e.length-1);return e.map((e,t)=>{let a=t*i,o=n-(r===0?0:e/r*n);return`${t===0?`M`:`L`}${a.toFixed(2)},${o.toFixed(2)}`}).join(` `)}function J({values:e,overlay:t,height:n=28,color:r,overlayColor:i,scaleTo:a,label:o,className:s}){let c=(0,y.useId)(),l=a===void 0?Math.max(1,...e,...t??[]):Math.max(1,a),u=q(e,100,n,l),d=u.length===0?``:`${u} L100,${n} L0,${n} Z`;return(0,W.jsxs)(ue,{className:s,viewBox:`0 0 100 ${n}`,preserveAspectRatio:`none`,role:`img`,"aria-label":o,style:{height:n},children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:c,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:r??`var(--accent)`,stopOpacity:`0.28`}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:r??`var(--accent)`,stopOpacity:`0`})]})}),d.length===0?null:(0,W.jsx)(`path`,{d,fill:`url(#${c})`}),t===void 0?null:(0,W.jsx)(`path`,{d:q(t,100,n,l),fill:`none`,stroke:i??`var(--down)`,strokeWidth:`1.25`,vectorEffect:`non-scaling-stroke`}),(0,W.jsx)(`path`,{d:u,fill:`none`,stroke:r??`var(--accent)`,strokeWidth:`1.5`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`})]})}var de=l.header`
|
|
7
|
-
grid-area: chassis;
|
|
8
|
-
display: flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
11
|
-
height: 48px;
|
|
12
|
-
padding: 0 ${({theme:e})=>e.space(3)};
|
|
13
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
14
|
-
background: ${({theme:e})=>e.color.panel};
|
|
15
|
-
${t}
|
|
16
|
-
position: sticky;
|
|
17
|
-
top: 0;
|
|
18
|
-
z-index: ${({theme:e})=>e.z.chassis};
|
|
19
|
-
`,fe=l.div`
|
|
20
|
-
display: flex;
|
|
21
|
-
align-items: baseline;
|
|
22
|
-
gap: 7px;
|
|
23
|
-
font-stretch: 74%;
|
|
24
|
-
font-weight: 700;
|
|
25
|
-
letter-spacing: 0.2em;
|
|
26
|
-
font-size: 12px;
|
|
27
|
-
text-transform: uppercase;
|
|
28
|
-
flex: none;
|
|
29
|
-
`,pe=l(e)`
|
|
30
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
|
|
33
|
-
@media (max-width: 860px) {
|
|
34
|
-
display: none;
|
|
35
|
-
}
|
|
36
|
-
`,Y=l.div`
|
|
37
|
-
display: flex;
|
|
38
|
-
align-items: baseline;
|
|
39
|
-
gap: 6px;
|
|
40
|
-
padding-left: ${({theme:e})=>e.space(3)};
|
|
41
|
-
border-left: 1px solid ${({theme:e})=>e.color.rule};
|
|
42
|
-
white-space: nowrap;
|
|
43
|
-
`,me=l(Y)`
|
|
44
|
-
width: 96px;
|
|
45
|
-
align-items: center;
|
|
46
|
-
`,he=l.div`
|
|
47
|
-
flex: 1;
|
|
48
|
-
min-width: 0;
|
|
49
|
-
`,ge=l(r)`
|
|
50
|
-
gap: 6px;
|
|
51
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
52
|
-
letter-spacing: 0.08em;
|
|
53
|
-
`,X=[`system`,`light`,`dark`],Z={system:`Match system theme`,light:`Light theme`,dark:`Dark theme`},Q=6e5;function _e(){let e=n(),{live:t,toggle:r,cadence:s}=K(),{mode:c,setMode:l}=h(),f=p(),m=u(200,s(1e4)),b=Date.now(),x=(0,y.useMemo)(()=>(m.data??[]).filter(e=>b-e.at<=Q),[m.data,b]),S=g(x,Q),C=_(x,{now:b,spanMs:Q,count:24}),w=X[(X.indexOf(c)+1)%X.length]??`system`,T=c===`light`?ce:c===`dark`?ae:ie,E=m.isError||S.errorRate>=.25?`down`:S.errorRate>=.05?`warn`:x.length===0?`idle`:`ok`;return(0,W.jsxs)(de,{children:[(0,W.jsxs)(fe,{children:[(0,W.jsx)(v,{state:E,label:m.isError?`gateway unreachable`:`error rate ${L(S.errorRate)}`}),`Omnigateway`]}),(0,W.jsxs)(pe,{children:[(0,W.jsxs)(me,{children:[(0,W.jsx)(o,{children:`req`}),(0,W.jsx)(he,{children:(0,W.jsx)(J,{values:C.map(e=>e.total),overlay:C.map(e=>e.errors),height:22,label:`${S.requests} requests in the last 10 minutes`})})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`rate`}),(0,W.jsx)(d,{children:S.ratePerMin.toFixed(1)}),(0,W.jsx)(o,{children:`/min`})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`err`}),(0,W.jsx)(d,{style:{color:S.errorRate>=.05?`var(--down)`:void 0},children:L(S.errorRate)})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`ttft p50`}),(0,W.jsx)(d,{children:I(S.ttftP50)})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`spend`}),(0,W.jsx)(d,{children:F(S.costUsd)})]})]}),(0,W.jsx)(a,{}),(0,W.jsxs)(ge,{type:`button`,$size:`sm`,onClick:r,"aria-pressed":t,title:t?`Pause polling`:`Resume polling`,children:[(0,W.jsx)(v,{state:t?`ok`:`idle`,label:t?`polling`:`paused`}),t?`LIVE`:`PAUSED`]}),(0,W.jsx)(i,{type:`button`,$variant:`ghost`,$size:`sm`,onClick:()=>l(w),"aria-label":Z[c],title:`${Z[c]} — switch to ${Z[w].toLowerCase()}`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(i,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Sign out`,title:`Sign out`,disabled:f.isPending,onClick:()=>{f.mutate(void 0,{onSuccess:()=>void e({to:`/login`})})},children:(0,W.jsx)(re,{})})]})}var ve=[{to:`/`,label:`Rack`,blurb:`Live state of every account and model`,Icon:A},{to:`/accounts`,label:`Accounts`,blurb:`Provider credentials and their health`,Icon:ee},{to:`/models`,label:`Models`,blurb:`Virtual models, targets, and routing`,Icon:j},{to:`/keys`,label:`Keys`,blurb:`Gateway API keys and their limits`,Icon:ne},{to:`/usage`,label:`Usage`,blurb:`Requests, tokens, and spend over time`,Icon:te},{to:`/logs`,label:`Logs`,blurb:`Recent requests, one row each`,Icon:oe},{to:`/settings`,label:`Settings`,blurb:`Routing weights, retries, retention`,Icon:se}],ye=l.nav`
|
|
54
|
-
grid-area: rail;
|
|
55
|
-
display: flex;
|
|
56
|
-
flex-direction: column;
|
|
57
|
-
gap: 2px;
|
|
58
|
-
padding: ${({theme:e})=>e.space(2)};
|
|
59
|
-
border-right: 1px solid ${({theme:e})=>e.color.rule};
|
|
60
|
-
background: ${({theme:e})=>e.color.panel};
|
|
61
|
-
overflow-y: auto;
|
|
62
|
-
|
|
63
|
-
@media (max-width: 720px) {
|
|
64
|
-
flex-direction: row;
|
|
65
|
-
overflow-x: auto;
|
|
66
|
-
border-right: 0;
|
|
67
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
68
|
-
}
|
|
69
|
-
`,be=l(c)`
|
|
70
|
-
display: flex;
|
|
71
|
-
align-items: center;
|
|
72
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
73
|
-
padding: 7px ${({theme:e})=>e.space(2)};
|
|
74
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
75
|
-
border-left: 2px solid transparent;
|
|
76
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
77
|
-
font-size: 12.5px;
|
|
78
|
-
font-weight: 500;
|
|
79
|
-
white-space: nowrap;
|
|
80
|
-
transition:
|
|
81
|
-
background 120ms ease,
|
|
82
|
-
color 120ms ease;
|
|
83
|
-
|
|
84
|
-
svg {
|
|
85
|
-
width: 15px;
|
|
86
|
-
height: 15px;
|
|
87
|
-
flex: none;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&:hover {
|
|
91
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
92
|
-
color: ${({theme:e})=>e.color.ink};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
&[data-status="active"] {
|
|
96
|
-
background: ${({theme:e})=>e.color.accentWash};
|
|
97
|
-
border-left-color: ${({theme:e})=>e.color.accent};
|
|
98
|
-
color: ${({theme:e})=>e.color.accent};
|
|
99
|
-
}
|
|
100
|
-
`;function $(){return(0,W.jsx)(ye,{"aria-label":`Console sections`,children:ve.map(({to:e,label:t,blurb:n,Icon:r})=>(0,W.jsxs)(be,{to:e,title:n,activeOptions:{exact:e===`/`},children:[(0,W.jsx)(r,{}),t]},e))})}var xe=l.div`
|
|
101
|
-
display: grid;
|
|
102
|
-
grid-template-areas:
|
|
103
|
-
"chassis chassis"
|
|
104
|
-
"rail main";
|
|
105
|
-
grid-template-columns: 168px minmax(0, 1fr);
|
|
106
|
-
grid-template-rows: auto minmax(0, 1fr);
|
|
107
|
-
min-height: 100%;
|
|
108
|
-
|
|
109
|
-
@media (max-width: 720px) {
|
|
110
|
-
grid-template-areas:
|
|
111
|
-
"chassis"
|
|
112
|
-
"rail"
|
|
113
|
-
"main";
|
|
114
|
-
grid-template-columns: minmax(0, 1fr);
|
|
115
|
-
grid-template-rows: auto auto minmax(0, 1fr);
|
|
116
|
-
}
|
|
117
|
-
`,Se=l.main`
|
|
118
|
-
grid-area: main;
|
|
119
|
-
padding: ${({theme:e})=>e.space(4)};
|
|
120
|
-
display: flex;
|
|
121
|
-
flex-direction: column;
|
|
122
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
123
|
-
min-width: 0;
|
|
124
|
-
|
|
125
|
-
@media (max-width: 720px) {
|
|
126
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
127
|
-
}
|
|
128
|
-
`;function Ce({children:e}){return(0,W.jsxs)(xe,{children:[(0,W.jsx)(_e,{}),(0,W.jsx)($,{}),(0,W.jsx)(Se,{children:e})]})}var we=l.div`
|
|
129
|
-
display: flex;
|
|
130
|
-
align-items: flex-end;
|
|
131
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
132
|
-
flex-wrap: wrap;
|
|
133
|
-
`,Te=l.h1`
|
|
134
|
-
font-size: 20px;
|
|
135
|
-
font-weight: 600;
|
|
136
|
-
font-stretch: 88%;
|
|
137
|
-
letter-spacing: -0.01em;
|
|
138
|
-
`,Ee=l.p`
|
|
139
|
-
font-size: 13px;
|
|
140
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
141
|
-
max-width: 68ch;
|
|
142
|
-
`,De=l.div`
|
|
143
|
-
display: flex;
|
|
144
|
-
flex-direction: column;
|
|
145
|
-
gap: 6px;
|
|
146
|
-
min-width: 0;
|
|
147
|
-
`;function Oe({legend:e,title:t,summary:n,actions:r}){return(0,W.jsxs)(we,{children:[(0,W.jsxs)(De,{children:[(0,W.jsx)(o,{children:e}),(0,W.jsx)(Te,{children:t}),(0,W.jsx)(Ee,{children:n})]}),(0,W.jsx)(a,{}),r]})}export{K as a,H as c,B as d,F as f,le as i,I as l,k as m,Ce as n,V as o,U as p,J as r,P as s,Oe as t,L as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ot as e}from"./queries-BMwc6EvM.js";import{o as t}from"./index-BtjyVE1i.js";import{i as n,n as r}from"./Rack-XtfiZ6GC.js";var i=e(),a=()=>(0,i.jsx)(n,{children:(0,i.jsx)(r,{children:(0,i.jsx)(t,{})})});export{a as component};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import{A as e,C as t,I as n,L as r,N as i,O as a,Ot as o,V as s,a as c,b as l,c as u,i as d,j as f,kt as p,l as m,n as h,qt as g,s as _}from"./queries-BMwc6EvM.js";import{a as v,d as y,l as b,m as x,t as S}from"./Rack-XtfiZ6GC.js";import{t as C}from"./CopyValue-cAwgC1sU.js";import{n as w,r as T,t as ee}from"./Toggle-BhViDMm9.js";import{t as E}from"./trash-2-JF_uX2gE.js";import{t as D}from"./Modal-Dqir9wBz.js";import{a as O,d as te,i as ne,n as re,t as k,u as A}from"./Lamp-BXSUIAtG.js";import{t as j}from"./Chip-Ccqsb_Mq.js";import{i as M,n as N,r as P,t as F}from"./Field-Devm4K46.js";import{t as ie}from"./Meter-Fn8X7t60.js";import{a as I,i as L,n as R,r as z,t as B}from"./States-DBzsiHjQ.js";import{i as V,n as H,r as U,t as W}from"./Table-DPDJeeVc.js";import{t as G}from"./catalog-C_OQ0icG.js";var K=x(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),q=g(p(),1),J=o(),ae=Object.keys(G),Y={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`},X={anthropic:`Authorize in the browser, then paste the code Anthropic shows you.`,openai:`Authorize in the browser. When it redirects to localhost, paste the whole URL.`,kimi:`Enter the code on Kimi's device page. This dialog finishes on its own.`},oe=s.ol`
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
5
|
-
`,se=s.div`
|
|
6
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
7
|
-
font-size: 26px;
|
|
8
|
-
letter-spacing: 0.22em;
|
|
9
|
-
text-align: center;
|
|
10
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
11
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
12
|
-
border: 1px solid ${({theme:e})=>e.color.ruleStrong};
|
|
13
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
14
|
-
`,ce=s.p`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.down};
|
|
17
|
-
`,le=s.p`
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
20
|
-
`;function ue({open:t,onOpenChange:r,onConnected:o}){let[s,l]=(0,q.useState)(`anthropic`),[u,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(null),[g,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(null),b=c(),x=d(),S=(0,q.useCallback)(()=>{m(null),_(``),y(null),f(``),b.reset(),x.reset()},[b,x]),w=(0,q.useCallback)(e=>{e||S(),r(e)},[r,S]);return(0,q.useEffect)(()=>{if(p===null||p.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await h(p.flowId);if(e)return;if(t.status===`complete`){S(),r(!1),o();return}}catch(t){if(e)return;y(L(t)),m(null);return}e||(n=setTimeout(()=>void t(),p.pollIntervalMs))},n=setTimeout(()=>void t(),p.pollIntervalMs);return()=>{e=!0,clearTimeout(n)}},[p,o,r,S]),(0,J.jsx)(D,{open:t,onOpenChange:w,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:p===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(n,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(n,{type:`button`,$variant:`primary`,disabled:b.isPending,onClick:()=>{y(null),b.mutate({provider:s,label:u.trim().length===0?Y[s]:u.trim()},{onSuccess:e=>m(e),onError:e=>y(L(e))})},children:b.isPending?`Starting…`:`Start authorization`})]}):p.kind===`device`?(0,J.jsx)(n,{type:`button`,onClick:()=>w(!1),children:`Cancel`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(n,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(n,{type:`button`,$variant:`primary`,disabled:x.isPending||g.trim().length===0,onClick:()=>{p!==null&&(y(null),x.mutate({flowId:p.flowId,code:g.trim()},{onSuccess:()=>{S(),r(!1),o()},onError:e=>y(L(e))}))},children:x.isPending?`Finishing…`:`Finish connecting`})]}),children:(0,J.jsxs)(oe,{children:[p===null?(0,J.jsxs)(i,{$gap:3,children:[(0,J.jsx)(F,{label:`Provider`,children:e=>(0,J.jsx)(M,{...e,value:s,onChange:e=>l(e.target.value),children:ae.map(e=>(0,J.jsx)(`option`,{value:e,children:Y[e]},e))})}),(0,J.jsx)(F,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>(0,J.jsx)(N,{...e,value:u,placeholder:Y[s],onChange:e=>f(e.target.value)})})]}):(0,J.jsxs)(i,{$gap:3,children:[(0,J.jsxs)(i,{$gap:1,children:[(0,J.jsx)(a,{children:`Step 1 — authorize`}),(0,J.jsx)(e,{$gap:2,children:(0,J.jsxs)(n,{as:`a`,href:p.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[(0,J.jsx)(K,{}),`Open `,Y[s]]})}),(0,J.jsx)(C,{value:p.authorizeUrl,label:`Copy authorization link`})]}),p.userCode===null?null:(0,J.jsxs)(i,{$gap:1,children:[(0,J.jsx)(a,{children:`Step 2 — enter this code`}),(0,J.jsx)(se,{children:p.userCode})]}),p.kind===`device`?(0,J.jsxs)(le,{children:[X[s],` Waiting for authorization…`]}):(0,J.jsx)(F,{label:`Authorization code`,hint:X[s],...v===null?{}:{problem:v},children:e=>(0,J.jsx)(N,{...e,value:g,autoFocus:!0,placeholder:s===`openai`?`http://localhost:1455/auth/callback?code=…`:`code#state`,onChange:e=>_(e.target.value)})})]}),v===null||p?.kind===`pkce`?null:(0,J.jsx)(ce,{children:v})]})})}var de=[`anthropic`,`openai`,`kimi`],Z={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`},fe=s(I)`
|
|
21
|
-
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
22
|
-
`,pe=s(N)`
|
|
23
|
-
width: 100%;
|
|
24
|
-
min-width: 140px;
|
|
25
|
-
height: 26px;
|
|
26
|
-
font-family: ${({theme:e})=>e.font.sans};
|
|
27
|
-
font-size: 12.5px;
|
|
28
|
-
background: transparent;
|
|
29
|
-
border-color: transparent;
|
|
30
|
-
|
|
31
|
-
&:hover:not(:disabled),
|
|
32
|
-
&:focus {
|
|
33
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
34
|
-
border-color: ${({theme:e})=>e.color.ruleStrong};
|
|
35
|
-
}
|
|
36
|
-
`,Q=s(P)`
|
|
37
|
-
width: 62px;
|
|
38
|
-
height: 26px;
|
|
39
|
-
`,me=s.span`
|
|
40
|
-
display: block;
|
|
41
|
-
padding-left: 9px;
|
|
42
|
-
font-size: 11px;
|
|
43
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
44
|
-
`,he=s(e)`
|
|
45
|
-
min-width: 130px;
|
|
46
|
-
gap: 6px;
|
|
47
|
-
`,ge=s.div`
|
|
48
|
-
display: flex;
|
|
49
|
-
flex-direction: column;
|
|
50
|
-
gap: 4px;
|
|
51
|
-
`;function $(){let e=t();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function _e(){let{cadence:t}=v(),o=u(),s=_(t(1e4)),c=l(),d=m(),{commit:p}=$(),[h,g]=(0,q.useState)(!1),[x,C]=(0,q.useState)(null),D=Date.now(),M=o.data??[],N=O(s.data?.health??[],e=>e.credentialId),P=O(s.data?.quota??[],e=>e.credentialId),F=c.data?.quotaPollIntervalMs??3e5,L=M.filter(e=>e.enabled).length,G=o.isLoading?`Reading connected accounts…`:M.length===0?`No provider credentials are connected, so every request fails at the router.`:`${L} of ${M.length} accounts are enabled and eligible for routing.`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(S,{legend:`Accounts`,title:`Provider accounts`,summary:G,actions:(0,J.jsxs)(n,{type:`button`,$variant:`primary`,onClick:()=>g(!0),children:[(0,J.jsx)(T,{}),`Connect an account`]})}),o.isError?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(R,{error:o.error,onRetry:()=>void o.refetch()})}):o.isLoading?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(z,{rows:5})}):M.length===0?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(B,{legend:`Nothing connected`,message:`Connect a provider account to give the router something to dispatch to. Tokens are encrypted at rest and never shown again.`,action:(0,J.jsx)(n,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>g(!0),children:`Connect an account`})})}):(0,J.jsx)(i,{$gap:4,children:de.filter(e=>M.some(t=>t.provider===e)).map(t=>{let n=M.filter(e=>e.provider===t);return(0,J.jsx)(fe,{$provider:t,legend:Z[t],meta:`${n.length} account${n.length===1?``:`s`}`,flush:!0,children:(0,J.jsx)(f,{children:(0,J.jsxs)(W,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(U,{$width:`24%`,children:`Account`}),(0,J.jsx)(U,{$width:`20%`,children:`Sign-in`}),(0,J.jsx)(U,{$align:`right`,$width:`86px`,children:`Tier`}),(0,J.jsx)(U,{$align:`right`,$width:`94px`,children:`Weight`}),(0,J.jsx)(U,{$align:`center`,$width:`86px`,children:`Enabled`}),(0,J.jsx)(U,{$width:`160px`,children:`Quota`}),(0,J.jsx)(U,{$align:`right`,$width:`88px`,children:`TTFT`}),(0,J.jsx)(U,{$align:`right`,$width:`130px`,children:`Token expires`}),(0,J.jsx)(U,{$width:`48px`})]})}),(0,J.jsx)(`tbody`,{children:n.map(t=>{let n=ne(N.get(t.id)??[],D,t.enabled,t.disabledReason),i=te(P.get(t.id)??[]);return(0,J.jsxs)(V,{children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(e,{$gap:2,children:[(0,J.jsx)(k,{state:n.state,label:n.note===``?`healthy`:n.note}),(0,J.jsx)(pe,{defaultValue:t.label,"aria-label":`Label for ${t.label}`,onBlur:e=>{let n=e.target.value.trim();if(n.length===0||n===t.label){e.target.value=t.label;return}p(t.id,{label:n})}})]}),n.note===``?null:(0,J.jsx)(me,{children:n.note})]}),(0,J.jsx)(H,{children:(0,J.jsxs)(e,{$gap:1,children:[(0,J.jsx)(j,{children:t.authType===`oauth`?`oauth`:`api key`}),t.accountEmail===null?null:(0,J.jsx)(a,{children:t.accountEmail})]})}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(Q,{min:1,step:1,defaultValue:t.tier,"aria-label":`Tier for ${t.label}`,onBlur:e=>{let n=Number(e.target.value);if(!Number.isInteger(n)||n<1||n===t.tier){e.target.value=String(t.tier);return}p(t.id,{tier:n})}})}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(Q,{min:.1,step:.1,defaultValue:t.weight,"aria-label":`Weight for ${t.label}`,onBlur:e=>{let n=Number(e.target.value);if(!Number.isFinite(n)||n<=0||n===t.weight){e.target.value=String(t.weight);return}p(t.id,{weight:n})}})}),(0,J.jsx)(H,{$align:`center`,children:(0,J.jsx)(ee,{checked:t.enabled,label:`Route to ${t.label}`,onCheckedChange:e=>p(t.id,{enabled:e})})}),(0,J.jsx)(H,{children:i.length===0?(0,J.jsx)(a,{children:`unknown`}):(0,J.jsx)(ge,{children:i.map(({window:e,fraction:t})=>(0,J.jsxs)(he,{children:[(0,J.jsx)(ie,{fraction:t,label:`${re[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,J.jsx)(a,{children:A(e,D,F,y)})]},e.windowType))})}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:b(n.ttftMs)}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:t.expiresAt===null?`never`:y(t.expiresAt,D)}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(r,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${t.label}`,title:`Remove ${t.label}`,onClick:()=>C(t),children:(0,J.jsx)(E,{})})})]},t.id)})})]})})},t)})}),(0,J.jsx)(ue,{open:h,onOpenChange:g,onConnected:()=>void o.refetch()}),(0,J.jsx)(w,{open:x!==null,onOpenChange:e=>{e||C(null)},title:`Remove account`,body:x===null?``:`Removing "${x.label}" deletes its stored token. Any model target pointing at ${Z[x.provider]} loses this account, and reconnecting means authorizing again.`,confirmLabel:`Remove account`,busy:d.isPending,onConfirm:()=>{x!==null&&d.mutate(x.id,{onSettled:()=>C(null)})}})]})}var ve=_e;export{ve as component};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import{A as e,D as t,I as n,M as r,N as i,O as a,Ot as o,P as s,U as c,V as l,b as u,c as d,g as f,h as p,j as m,k as h,s as g,w as _}from"./queries-BMwc6EvM.js";import{a as v,d as y,f as b,l as x,o as S,r as C,s as w,t as ee,u as T}from"./Rack-XtfiZ6GC.js";import{a as E,c as D,d as O,f as k,i as A,l as j,n as M,r as te,s as N,t as P,u as F}from"./Lamp-BXSUIAtG.js";import{n as I,t as L}from"./Chip-Ccqsb_Mq.js";import{t as R}from"./Meter-Fn8X7t60.js";import{a as z,n as B,t as V}from"./States-DBzsiHjQ.js";import{i as H,n as U,r as W,t as G}from"./Table-DPDJeeVc.js";import{t as K}from"./Readout-BKpOZIGX.js";var q=o(),ne=l(s)`
|
|
2
|
-
font-weight: 500;
|
|
3
|
-
display: block;
|
|
4
|
-
max-width: 24ch;
|
|
5
|
-
`,J=l.span`
|
|
6
|
-
font-size: 11px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
`,Y=l.div`
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
gap: 6px;
|
|
12
|
-
width: 118px;
|
|
13
|
-
`,X=l.div`
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
gap: 4px;
|
|
17
|
-
`;function Z({credentials:t,health:r,quota:i,usage:o,quotaPollIntervalMs:s,now:l}){let u=E(r,e=>e.credentialId),d=E(i,e=>e.credentialId),f=new Map(o.map(e=>[e.key,e])),p={down:0,warn:1,ok:2,idle:3,live:3},h=t.map(e=>({credential:e,status:A(u.get(e.id)??[],l,e.enabled,e.disabledReason),quota:O(d.get(e.id)??[]),usage:f.get(e.id)})).sort((e,t)=>p[e.status.state]-p[t.status.state]||e.credential.tier-t.credential.tier);return(0,q.jsx)(z,{legend:`Accounts`,meta:`${t.length} connected`,flush:!0,actions:(0,q.jsx)(n,{as:c,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:t.length===0?(0,q.jsx)(V,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:(0,q.jsx)(n,{as:c,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):(0,q.jsx)(m,{children:(0,q.jsxs)(G,{children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(W,{children:`Account`}),(0,q.jsx)(W,{children:`Provider`}),(0,q.jsx)(W,{$align:`right`,children:`Tier`}),(0,q.jsx)(W,{children:`Quota`}),(0,q.jsx)(W,{$align:`right`,children:`TTFT`}),(0,q.jsx)(W,{$align:`right`,children:`Requests`}),(0,q.jsx)(W,{$align:`right`,children:`Last used`})]})}),(0,q.jsx)(`tbody`,{children:h.map(({credential:t,status:n,quota:r,usage:i})=>(0,q.jsxs)(H,{children:[(0,q.jsx)(U,{children:(0,q.jsxs)(e,{$gap:2,children:[(0,q.jsx)(P,{state:n.state,label:n.note===``?`healthy`:n.note}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(ne,{children:t.label}),n.note===``?null:(0,q.jsx)(J,{children:n.note})]})]})}),(0,q.jsx)(U,{children:(0,q.jsx)(I,{provider:t.provider})}),(0,q.jsx)(U,{$align:`right`,$mono:!0,children:t.tier}),(0,q.jsx)(U,{children:r.length===0?(0,q.jsx)(J,{children:`unknown`}):(0,q.jsx)(X,{children:r.map(({window:e,fraction:t})=>(0,q.jsxs)(Y,{children:[(0,q.jsx)(R,{fraction:t,label:`${M[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,q.jsx)(a,{children:F(e,l,s,y)})]},e.windowType))})}),(0,q.jsx)(U,{$align:`right`,$mono:!0,children:x(n.ttftMs)}),(0,q.jsx)(U,{$align:`right`,$mono:!0,children:i===void 0?`—`:w(i.requests)}),(0,q.jsx)(U,{$align:`right`,$mono:!0,children:y(n.lastUsedAt,l)})]},t.id))})]})})})}var re=l.ul`
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
`,ie=l.li`
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
24
|
-
padding: 6px ${({theme:e})=>e.space(3)};
|
|
25
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
26
|
-
|
|
27
|
-
&:last-child {
|
|
28
|
-
border-bottom: 0;
|
|
29
|
-
}
|
|
30
|
-
`,ae=l(s)`
|
|
31
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
32
|
-
font-size: 12px;
|
|
33
|
-
max-width: 30ch;
|
|
34
|
-
`,oe=l(h)`
|
|
35
|
-
color: ${({theme:e})=>e.color.down};
|
|
36
|
-
font-size: 11px;
|
|
37
|
-
`;function se({logs:e}){let t=e.slice(0,12);return(0,q.jsx)(z,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:(0,q.jsx)(n,{as:c,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?(0,q.jsx)(V,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):(0,q.jsx)(re,{children:t.map(e=>(0,q.jsxs)(ie,{children:[(0,q.jsx)(P,{state:j(e),label:D(e)}),(0,q.jsx)(h,{$dim:!0,children:S(e.at)}),(0,q.jsx)(ae,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:(0,q.jsx)(h,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),(0,q.jsx)(r,{}),N(e)?null:(0,q.jsxs)(q.Fragment,{children:[e.errorCode===null?null:(0,q.jsx)(oe,{children:e.errorCode}),e.attempts>1?(0,q.jsxs)(h,{$dim:!0,children:[e.attempts,`×`]}):null,(0,q.jsx)(h,{$dim:!0,children:x(e.durationMs)}),(0,q.jsx)(h,{$dim:!0,children:b(e.costUsd)})]})]},e.id))})})}var Q=l.ul`
|
|
38
|
-
display: flex;
|
|
39
|
-
flex-direction: column;
|
|
40
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
41
|
-
`,ce=l(s)`
|
|
42
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
43
|
-
font-size: 12.5px;
|
|
44
|
-
`,le=l.div`
|
|
45
|
-
display: flex;
|
|
46
|
-
height: 5px;
|
|
47
|
-
border-radius: 2px;
|
|
48
|
-
overflow: hidden;
|
|
49
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
50
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
51
|
-
`,ue=l.div`
|
|
52
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
53
|
-
background: ${({$color:e})=>e};
|
|
54
|
-
opacity: 0.8;
|
|
55
|
-
`,de=l.div`
|
|
56
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
57
|
-
`;function fe({models:t,logs:i}){let o=new Map;for(let e of i){let t=o.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,o.set(e.requestedModel,t)}let s=Math.max(1,...[...o.values()].map(e=>e.requests)),l=[...t].map(e=>({model:e,used:o.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return(0,q.jsx)(z,{legend:`Models`,meta:`${t.length} configured`,actions:(0,q.jsx)(n,{as:c,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.length===0?(0,q.jsx)(V,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:(0,q.jsx)(n,{as:c,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):(0,q.jsx)(Q,{children:l.map(({model:t,used:n})=>{let i=(n?.requests??0)/s,o=[...new Set(t.targets.map(e=>e.provider))];return(0,q.jsxs)(`li`,{children:[(0,q.jsxs)(e,{$gap:2,children:[(0,q.jsx)(ce,{title:t.id,children:t.id}),t.isAlias?(0,q.jsx)(L,{children:`alias`}):null,(0,q.jsx)(L,{$tone:`accent`,children:t.strategy}),(0,q.jsx)(r,{}),(0,q.jsx)(h,{$dim:!0,children:w(n?.requests??0)}),(0,q.jsx)(a,{children:`req`}),(0,q.jsx)(h,{$dim:!0,children:b(n?.costUsd??0)})]}),(0,q.jsxs)(le,{style:{marginTop:6},title:`${Math.round(i*100)}% of the busiest model`,children:[o.map(e=>(0,q.jsx)(ue,{$color:`var(--p-${e})`,$grow:i/o.length},e)),(0,q.jsx)(de,{$grow:Math.max(0,1-i)})]})]},t.id)})})})}var pe=l.div`
|
|
58
|
-
display: grid;
|
|
59
|
-
grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
|
|
60
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
61
|
-
`;function me({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=k(r,t),a=te(r,{now:n,spanMs:t,count:32}),o=i.errorRate>=.25?`down`:i.errorRate>=.05?`warn`:`ok`;return(0,q.jsxs)(pe,{children:[(0,q.jsx)(K,{legend:`Requests`,value:w(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:(0,q.jsx)(C,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),(0,q.jsx)(K,{legend:`Error rate`,value:T(i.errorRate),unit:`${w(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:(0,q.jsx)(C,{values:a.map(e=>e.errors),scaleTo:Math.max(...a.map(e=>e.total)),color:`var(--down)`,label:`${i.errors} failed requests against ${i.requests} total`})}),(0,q.jsx)(K,{legend:`Time to first token`,value:x(i.ttftP50),unit:`p95 ${x(i.ttftP95)}`,trace:(0,q.jsx)(C,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${x(i.ttftP50)}`})}),(0,q.jsx)(K,{legend:`Spend`,value:b(i.costUsd),unit:`${w(i.inputTokens+i.outputTokens)} tokens`,trace:(0,q.jsx)(C,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${b(i.costUsd)} total`})})]})}var $=36e5;function he(){let{cadence:e}=v(),n=d(),r=g(e(1e4)),a=f(),o=p(500,e(1e4)),s=u(),c=Date.now(),l=Math.floor((c-$)/6e4)*6e4,m=_({groupBy:`credential`,since:l},e(6e4)),h=n.data??[],y=E(r.data?.health??[],e=>e.credentialId),b=h.filter(e=>A(y.get(e.id)??[],c,e.enabled,e.disabledReason).state===`down`),x=n.isLoading||o.isLoading?`Reading the gateway…`:h.length===0?`No accounts are connected, so every request fails at the router.`:b.length>0?`${b.length} account${b.length===1?` is`:`s are`} out of rotation.`:`All ${h.length} accounts are answering. Nothing needs attention.`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(ee,{legend:`Rack`,title:`Gateway`,summary:x}),o.isError?(0,q.jsx)(z,{legend:`Traffic`,children:(0,q.jsx)(B,{legend:`The gateway did not answer`,error:o.error,onRetry:()=>void o.refetch()})}):(0,q.jsxs)(i,{$gap:4,children:[(0,q.jsx)(me,{logs:o.data??[],windowMs:$,now:c}),(0,q.jsx)(Z,{credentials:h,health:r.data?.health??[],quota:r.data?.quota??[],usage:m.data??[],quotaPollIntervalMs:s.data?.quotaPollIntervalMs??3e5,now:c}),(0,q.jsxs)(t,{$min:`340px`,$gap:4,children:[(0,q.jsx)(fe,{models:a.data??[],logs:o.data??[]}),(0,q.jsx)(se,{logs:o.data??[]})]})]})]})}var ge=he;export{ge as component};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{A as e,I as t,N as n,O as r,Ot as i,P as a,V as o,_ as s,f as c,g as l,j as u,k as d,kt as f,o as p,qt as m}from"./queries-BMwc6EvM.js";import{c as h,t as g}from"./Rack-XtfiZ6GC.js";import{t as _}from"./CopyValue-cAwgC1sU.js";import{n as v,r as y,t as b}from"./Toggle-BhViDMm9.js";import{t as x}from"./Modal-Dqir9wBz.js";import{t as S}from"./Chip-Ccqsb_Mq.js";import{n as C,t as w}from"./Field-Devm4K46.js";import{a as T,i as E,n as D,r as O,t as k}from"./States-DBzsiHjQ.js";import{i as A,n as j,r as M,t as N}from"./Table-DPDJeeVc.js";var P=m(f(),1),F=i(),I=o.div`
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: 2px;
|
|
5
|
-
max-height: 190px;
|
|
6
|
-
overflow-y: auto;
|
|
7
|
-
padding: ${({theme:e})=>e.space(1)};
|
|
8
|
-
border: 1px solid ${({theme:e})=>e.color.ruleStrong};
|
|
9
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
10
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
11
|
-
`,L=o.label`
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
15
|
-
padding: 4px 6px;
|
|
16
|
-
border-radius: 2px;
|
|
17
|
-
cursor: pointer;
|
|
18
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
|
|
21
|
-
&:hover {
|
|
22
|
-
background: ${({theme:e})=>e.color.panelRaised};
|
|
23
|
-
}
|
|
24
|
-
`,R=o.p`
|
|
25
|
-
font-size: 12px;
|
|
26
|
-
color: ${({theme:e})=>e.color.warn};
|
|
27
|
-
`,z=o.p`
|
|
28
|
-
font-size: 12px;
|
|
29
|
-
color: ${({theme:e})=>e.color.down};
|
|
30
|
-
`,B=o.p`
|
|
31
|
-
font-size: 12px;
|
|
32
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
33
|
-
`;function V({open:i,onOpenChange:a}){let o=l(),s=p(),[c,u]=(0,P.useState)(``),[f,m]=(0,P.useState)(!0),[h,g]=(0,P.useState)([]),[v,y]=(0,P.useState)(``),[S,T]=(0,P.useState)(null),[D,O]=(0,P.useState)(null),k=()=>{u(``),m(!0),g([]),y(``),T(null),O(null),s.reset()},A=e=>{e||k(),a(e)};return(0,F.jsx)(x,{open:i,onOpenChange:A,title:S===null?`Create an API key`:`Key created`,description:S===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:S===null?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(t,{type:`button`,onClick:()=>A(!1),children:`Cancel`}),(0,F.jsx)(t,{type:`button`,$variant:`primary`,disabled:s.isPending,onClick:()=>{let e=v.trim(),t=e.length===0?null:Number(e);if(t!==null&&(!Number.isInteger(t)||t<1)){O(`The rate limit must be a whole number of requests per minute, or blank for none.`);return}O(null),s.mutate({label:c.trim().length===0?`api key`:c.trim(),modelAllowlist:f?null:h,rateLimitPerMin:t},{onSuccess:e=>T(e),onError:e=>O(E(e))})},children:s.isPending?`Creating…`:`Create key`})]}):(0,F.jsx)(t,{type:`button`,$variant:`primary`,onClick:()=>A(!1),children:`I have copied the key`}),children:S===null?(0,F.jsxs)(n,{$gap:3,children:[(0,F.jsx)(w,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>(0,F.jsx)(C,{...e,value:c,placeholder:`api key`,onChange:e=>u(e.target.value)})}),(0,F.jsxs)(n,{$gap:2,children:[(0,F.jsxs)(e,{$gap:2,children:[(0,F.jsx)(b,{checked:f,label:`Allow every model`,onCheckedChange:m}),(0,F.jsx)(r,{as:`span`,children:`Allow every model`})]}),f?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{children:(o.data??[]).map(e=>(0,F.jsxs)(L,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:h.includes(e.id),onChange:t=>g(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),e.id]},e.id))}),h.length===0?(0,F.jsx)(R,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),(0,F.jsx)(w,{label:`Rate limit`,hint:`Requests per minute for this key. Leave blank for no limit. Counted per process, and reset when the gateway restarts.`,children:e=>(0,F.jsx)(C,{...e,type:`number`,min:1,step:1,value:v,placeholder:`no limit`,onChange:e=>y(e.target.value)})}),D===null?null:(0,F.jsx)(z,{role:`alert`,children:D})]}):(0,F.jsxs)(n,{$gap:3,children:[(0,F.jsx)(B,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),(0,F.jsx)(_,{value:S.key,label:`Copy API key`}),(0,F.jsxs)(e,{$gap:2,children:[(0,F.jsx)(r,{children:`Label`}),(0,F.jsx)(d,{children:S.label}),(0,F.jsx)(r,{children:`Prefix`}),(0,F.jsx)(d,{children:S.prefix})]})]})})}var H=o(e)`
|
|
34
|
-
gap: 4px;
|
|
35
|
-
flex-wrap: wrap;
|
|
36
|
-
max-width: 34ch;
|
|
37
|
-
`,U=o.span`
|
|
38
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
39
|
-
`;function W(){let e=c(),n=s(),[i,o]=(0,P.useState)(!1),[l,d]=(0,P.useState)(null),f=e.data??[],p=f.filter(e=>e.revokedAt===null),m=e.isLoading?`Reading issued keys…`:f.length===0?`No keys exist, so nothing can call this gateway yet.`:`${p.length} active key${p.length===1?``:`s`} of ${f.length} ever issued.`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{legend:`Keys`,title:`Gateway API keys`,summary:m,actions:(0,F.jsxs)(t,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[(0,F.jsx)(y,{}),`Create a key`]})}),(0,F.jsx)(T,{legend:`Issued keys`,meta:`${f.length}`,flush:!0,children:e.isError?(0,F.jsx)(D,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?(0,F.jsx)(`div`,{style:{padding:12},children:(0,F.jsx)(O,{rows:4})}):f.length===0?(0,F.jsx)(k,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:(0,F.jsx)(t,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):(0,F.jsx)(u,{children:(0,F.jsxs)(N,{children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(M,{children:`Label`}),(0,F.jsx)(M,{children:`Prefix`}),(0,F.jsx)(M,{children:`Allowed models`}),(0,F.jsx)(M,{$align:`right`,children:`Rate limit`}),(0,F.jsx)(M,{$align:`right`,children:`Created`}),(0,F.jsx)(M,{children:`Status`}),(0,F.jsx)(M,{})]})}),(0,F.jsx)(`tbody`,{children:f.map(e=>(0,F.jsxs)(A,{children:[(0,F.jsx)(j,{children:(0,F.jsx)(a,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),(0,F.jsxs)(j,{$mono:!0,children:[e.prefix,`…`]}),(0,F.jsx)(j,{children:e.modelAllowlist===null?(0,F.jsx)(r,{children:`every model`}):e.modelAllowlist.length===0?(0,F.jsx)(S,{$tone:`down`,children:`no models`}):(0,F.jsx)(H,{children:e.modelAllowlist.map(e=>(0,F.jsx)(S,{children:e},e))})}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:e.rateLimitPerMin===null?`—`:`${e.rateLimitPerMin}/min`}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:h(e.createdAt)}),(0,F.jsx)(j,{children:e.revokedAt===null?(0,F.jsx)(S,{$tone:`ok`,children:`active`}):(0,F.jsx)(U,{title:h(e.revokedAt),children:(0,F.jsx)(S,{children:`revoked`})})}),(0,F.jsx)(j,{$align:`right`,children:e.revokedAt===null?(0,F.jsx)(t,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>d(e),children:`Revoke`}):null})]},e.id))})]})})}),(0,F.jsx)(V,{open:i,onOpenChange:o}),(0,F.jsx)(v,{open:l!==null,onOpenChange:e=>{e||d(null)},title:`Revoke key`,body:l===null?``:`Revoking "${l.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:n.isPending,onConfirm:()=>{l!==null&&n.mutate(l.id,{onSettled:()=>d(null)})}})]})}var G=W;export{G as component};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{A as e,I as t,N as n,O as r,Ot as i,P as a,V as o,c as s,h as ee,j as c,k as l,kt as u,qt as d,t as f}from"./queries-BMwc6EvM.js";import{a as p,c as m,f as h,l as g,m as _,o as v,p as y,s as b,t as x}from"./Rack-XtfiZ6GC.js";import{t as S}from"./Modal-Dqir9wBz.js";import{c as C,l as w,o as T,s as E,t as D}from"./Lamp-BXSUIAtG.js";import{n as O,t as k}from"./Chip-Ccqsb_Mq.js";import{i as A,n as j}from"./Field-Devm4K46.js";import{a as te,n as ne,r as M,t as N}from"./States-DBzsiHjQ.js";import{i as P,n as F,r as I,t as L}from"./Table-DPDJeeVc.js";var R=_(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),z=_(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),B=_(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),V=d(u(),1),H=i(),U=[50,100,250,500],W=new Intl.NumberFormat(`en-US`);function G(e){return`${W.format(e.inputTokens)} input, ${W.format(e.outputTokens)} output, ${W.format(e.cacheReadTokens)} cache read, ${W.format(e.cacheWriteTokens)} cache write tokens`}var K=o(e)`
|
|
2
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
`,q=o(j)`
|
|
5
|
-
width: 220px;
|
|
6
|
-
`,J=o(A)`
|
|
7
|
-
width: auto;
|
|
8
|
-
`,Y=o.span`
|
|
9
|
-
display: inline-flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
gap: 6px;
|
|
12
|
-
white-space: nowrap;
|
|
13
|
-
`,X=o.span`
|
|
14
|
-
display: inline-flex;
|
|
15
|
-
align-items: center;
|
|
16
|
-
gap: 2px;
|
|
17
|
-
|
|
18
|
-
svg {
|
|
19
|
-
width: 12px;
|
|
20
|
-
height: 12px;
|
|
21
|
-
stroke-width: 1.75;
|
|
22
|
-
}
|
|
23
|
-
`;function re({log:e}){if(E(e))return(0,H.jsx)(F,{$align:`right`,$mono:!0,children:`—`});let t=G(e);return(0,H.jsx)(F,{$align:`right`,$mono:!0,"aria-label":t,title:t,children:(0,H.jsxs)(Y,{"aria-hidden":`true`,children:[(0,H.jsxs)(X,{children:[(0,H.jsx)(R,{}),b(e.inputTokens)]}),(0,H.jsxs)(X,{children:[(0,H.jsx)(z,{}),b(e.outputTokens)]}),(0,H.jsxs)(X,{children:[(0,H.jsx)(B,{}),(0,H.jsx)(R,{}),b(e.cacheReadTokens)]}),(0,H.jsxs)(X,{children:[(0,H.jsx)(B,{}),(0,H.jsx)(z,{}),b(e.cacheWriteTokens)]})]})})}var ie=o.dl`
|
|
24
|
-
display: grid;
|
|
25
|
-
grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
|
|
26
|
-
gap: 6px ${({theme:e})=>e.space(3)};
|
|
27
|
-
margin: 0;
|
|
28
|
-
font-size: 12.5px;
|
|
29
|
-
`,Z=o.dd`
|
|
30
|
-
margin: 0;
|
|
31
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
32
|
-
word-break: break-all;
|
|
33
|
-
`;function Q(){let{cadence:i}=p(),[o,u]=(0,V.useState)(100),[d,_]=(0,V.useState)(`all`),[A,j]=(0,V.useState)(``),[R,z]=(0,V.useState)(null),B=ee(o,i(f)),W=s(),G=(0,V.useMemo)(()=>{let e=new Map;for(let t of W.data??[])e.set(t.id,t.label);return e},[W.data]),Y=A.trim().toLowerCase(),X=(B.data??[]).filter(e=>d===`failed`&&!T(e)?!1:Y.length===0||e.requestedModel.toLowerCase().includes(Y)||(e.resolvedModel??``).toLowerCase().includes(Y)||(e.errorCode??``).toLowerCase().includes(Y)||(e.credentialId===null?``:G.get(e.credentialId)??``).toLowerCase().includes(Y)),Q=(B.data??[]).filter(T).length,$=(B.data??[]).filter(E).length;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(x,{legend:`Logs`,title:`Recent requests`,summary:B.isLoading?`Reading the request log…`:`${b(B.data?.length??0)} recent requests, ${b(Q)} of them failed${$===0?``:`, ${b($)} still running`}. Prompt and response bodies are never recorded.`,actions:(0,H.jsxs)(K,{children:[(0,H.jsx)(q,{value:A,placeholder:`Filter by model, account, or error`,"aria-label":`Filter requests`,onChange:e=>j(e.target.value)}),(0,H.jsxs)(J,{value:d,"aria-label":`Show which requests`,onChange:e=>_(e.target.value),children:[(0,H.jsx)(`option`,{value:`all`,children:`All requests`}),(0,H.jsx)(`option`,{value:`failed`,children:`Failed only`})]}),(0,H.jsx)(J,{value:o,"aria-label":`How many requests to fetch`,onChange:e=>u(Number(e.target.value)),children:U.map(e=>(0,H.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,H.jsx)(te,{legend:`Request log`,meta:`${X.length} shown`,flush:!0,children:B.isError?(0,H.jsx)(ne,{error:B.error,onRetry:()=>void B.refetch()}):B.isLoading?(0,H.jsx)(`div`,{style:{padding:12},children:(0,H.jsx)(M,{rows:8})}):X.length===0?(0,H.jsx)(N,{legend:`Nothing to show`,message:(B.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):(0,H.jsx)(c,{children:(0,H.jsxs)(L,{children:[(0,H.jsx)(`thead`,{children:(0,H.jsxs)(`tr`,{children:[(0,H.jsx)(I,{}),(0,H.jsx)(I,{$align:`right`,children:`Time`}),(0,H.jsx)(I,{children:`Requested`}),(0,H.jsx)(I,{children:`Routed to`}),(0,H.jsx)(I,{children:`Account`}),(0,H.jsx)(I,{$align:`right`,children:`Try`}),(0,H.jsx)(I,{$align:`right`,children:`TTFT`}),(0,H.jsx)(I,{$align:`right`,children:`Total`}),(0,H.jsx)(I,{$align:`right`,children:`Tokens`}),(0,H.jsx)(I,{$align:`right`,children:`Cost`}),(0,H.jsx)(I,{children:`Outcome`})]})}),(0,H.jsx)(`tbody`,{children:X.map(t=>(0,H.jsxs)(P,{$selectable:!0,onClick:()=>z(t),children:[(0,H.jsx)(F,{children:(0,H.jsx)(D,{state:w(t),label:C(t)})}),(0,H.jsx)(F,{$align:`right`,$mono:!0,title:m(t.at),children:v(t.at)}),(0,H.jsx)(F,{$mono:!0,children:(0,H.jsx)(a,{style:{display:`block`,maxWidth:`20ch`},children:t.requestedModel||`—`})}),(0,H.jsx)(F,{children:t.resolvedProvider===null?(0,H.jsx)(r,{children:E(t)?`routing…`:`not routed`}):(0,H.jsxs)(e,{$gap:1,children:[(0,H.jsx)(O,{provider:t.resolvedProvider}),(0,H.jsx)(l,{$dim:!0,children:t.resolvedModel??`—`})]})}),(0,H.jsx)(F,{children:(0,H.jsx)(a,{style:{display:`block`,maxWidth:`18ch`},children:t.credentialId===null?`—`:G.get(t.credentialId)??y(t.credentialId)})}),(0,H.jsx)(F,{$align:`right`,$mono:!0,children:E(t)?`—`:t.attempts}),(0,H.jsx)(F,{$align:`right`,$mono:!0,children:E(t)?`—`:g(t.ttftMs)}),(0,H.jsx)(F,{$align:`right`,$mono:!0,children:E(t)?`—`:g(t.durationMs)}),(0,H.jsx)(re,{log:t}),(0,H.jsx)(F,{$align:`right`,$mono:!0,children:E(t)?`—`:h(t.costUsd)}),(0,H.jsx)(F,{children:E(t)?(0,H.jsx)(k,{$tone:`accent`,children:`live`}):t.errorCode===null?(0,H.jsx)(k,{$tone:`ok`,children:t.status}):(0,H.jsx)(k,{$tone:`down`,children:t.errorCode})})]},t.id))})]})})}),(0,H.jsx)(S,{open:R!==null,onOpenChange:e=>{e||z(null)},title:`Request detail`,width:`600px`,footer:(0,H.jsx)(t,{type:`button`,onClick:()=>z(null),children:`Close`}),children:R===null?null:(0,H.jsxs)(n,{$gap:3,children:[(0,H.jsxs)(ie,{children:[(0,H.jsx)(r,{as:`dt`,children:`Request id`}),(0,H.jsx)(Z,{children:R.id}),(0,H.jsx)(r,{as:`dt`,children:`At`}),(0,H.jsx)(Z,{children:m(R.at)}),(0,H.jsx)(r,{as:`dt`,children:`Requested model`}),(0,H.jsx)(Z,{children:R.requestedModel||`—`}),(0,H.jsx)(r,{as:`dt`,children:`Routed to`}),(0,H.jsx)(Z,{children:E(R)?`—`:R.resolvedProvider===null?`not routed`:`${R.resolvedProvider} · ${R.resolvedModel??`—`}`}),(0,H.jsx)(r,{as:`dt`,children:`Account`}),(0,H.jsx)(Z,{children:R.credentialId===null?`—`:G.get(R.credentialId)??R.credentialId}),(0,H.jsx)(r,{as:`dt`,children:`Key`}),(0,H.jsx)(Z,{children:R.apiKeyId??`—`}),(0,H.jsx)(r,{as:`dt`,children:`Attempts`}),(0,H.jsx)(Z,{children:E(R)?`—`:R.attempts}),(0,H.jsx)(r,{as:`dt`,children:`Status`}),(0,H.jsx)(Z,{children:E(R)?`in flight`:R.errorCode===null?R.status:`${R.status} ${R.errorCode}`}),(0,H.jsx)(r,{as:`dt`,children:`Timing`}),(0,H.jsx)(Z,{children:E(R)?`—`:`first token ${g(R.ttftMs)} · total ${g(R.durationMs)}`}),(0,H.jsx)(r,{as:`dt`,children:`Tokens`}),(0,H.jsx)(Z,{children:E(R)?`—`:(0,H.jsxs)(H.Fragment,{children:[b(R.inputTokens),` in · `,b(R.outputTokens),` out ·`,` `,b(R.cacheReadTokens),` cache read ·`,` `,b(R.cacheWriteTokens),` cache write`]})}),(0,H.jsx)(r,{as:`dt`,children:`Cost`}),(0,H.jsx)(Z,{children:E(R)?`—`:h(R.costUsd)})]}),R.degradations.length===0?null:(0,H.jsxs)(n,{$gap:1,children:[(0,H.jsx)(r,{children:`Capabilities dropped to fit the target`}),(0,H.jsx)(e,{$gap:1,$wrap:!0,children:R.degradations.map(e=>(0,H.jsx)(k,{$tone:`warn`,children:e},e))})]})]})})]})}var $=Q;export{$ as component};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import{A as e,I as t,L as n,M as r,N as i,O as a,Ot as o,P as s,V as c,b as l,d as u,g as d,k as f,kt as p,qt as m,u as h,v as g}from"./queries-BMwc6EvM.js";import{m as _,t as v}from"./Rack-XtfiZ6GC.js";import{n as y,r as b,t as x}from"./Toggle-BhViDMm9.js";import{t as S}from"./trash-2-JF_uX2gE.js";import{n as C,t as w}from"./Chip-Ccqsb_Mq.js";import{i as T,n as E,r as D,t as O}from"./Field-Devm4K46.js";import{t as ee}from"./Meter-Fn8X7t60.js";import{a as k,i as A,n as te,r as j,t as M}from"./States-DBzsiHjQ.js";import{n as ne,r as re,t as N}from"./catalog-C_OQ0icG.js";var P=_(`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=_(`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`}]]),F=m(p(),1),I=o(),L=[`tier`,`health`,`quota`,`cost`,`latency`,`recency`],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 against the other candidates`,latency:`Observed time to first token`,recency:`How long this pair has been idle`},oe=c.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
|
-
`,se=c(f)`
|
|
9
|
-
width: 22px;
|
|
10
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
|
-
flex: none;
|
|
12
|
-
`,ce=c(w)`
|
|
13
|
-
border-color: ${({theme:e})=>e.color.ok};
|
|
14
|
-
color: ${({theme:e})=>e.color.ok};
|
|
15
|
-
background: ${({theme:e})=>e.color.okWash};
|
|
16
|
-
`,le=c.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
|
-
`,ue=c.div`
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: 3px;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
`,de=c.div`
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: baseline;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: 6px;
|
|
32
|
-
`,fe=c.li`
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
36
|
-
padding: 5px 0;
|
|
37
|
-
`,pe=c(e)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,R=c.label`
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
gap: 6px;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
font-size: 12.5px;
|
|
46
|
-
`,z=c.p`
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
color: ${({theme:e})=>e.color.down};
|
|
49
|
-
`;function B(e,t,n){return(e[t]??0)*n[t]}function me({modelId:n}){let[o,c]=(0,F.useState)({tools:!1,images:!1,reasoning:!1}),[d,p]=(0,F.useState)(null),[m,h]=(0,F.useState)(null),g=l(),_=u(),v=g.data?.weights,y=()=>{n!==null&&(h(null),_.mutate({modelId:n,need:o},{onSuccess:e=>p(e),onError:e=>{p(null),h(A(e))}}))},b=new Map(L.map(e=>[e,Math.max(1e-4,...(d?.candidates??[]).map(t=>v===void 0?0:Math.abs(B(t.reasons,e,v))))]));return(0,I.jsx)(k,{legend:`Explain`,meta:n??`no model selected`,actions:(0,I.jsxs)(t,{type:`button`,$size:`sm`,$variant:`primary`,disabled:n===null||_.isPending,onClick:y,children:[(0,I.jsx)(P,{}),_.isPending?`Ranking…`:`Rank candidates`]}),children:(0,I.jsxs)(i,{$gap:3,children:[(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(a,{children:`Pretend the request needs`}),(0,I.jsxs)(pe,{children:[(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:o.tools,label:`Probe request uses tools`,onCheckedChange:e=>c({...o,tools:e})}),`Tools`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:o.images,label:`Probe request includes an image`,onCheckedChange:e=>c({...o,images:e})}),`Images`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:o.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>c({...o,reasoning:e})}),`Reasoning`]})]})]}),m===null?null:(0,I.jsx)(z,{children:m}),d===null?(0,I.jsx)(M,{legend:`Not ranked yet`,message:n===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.`}):(0,I.jsxs)(i,{$gap:3,children:[(0,I.jsxs)(e,{$gap:2,$wrap:!0,children:[(0,I.jsx)(w,{$tone:`accent`,children:d.strategy}),d.deterministic?null:(0,I.jsx)(w,{$tone:`warn`,children:`order varies per request`}),(0,I.jsx)(r,{}),(0,I.jsxs)(a,{children:[d.candidates.length,` eligible · `,d.excluded.length,` filtered out`]})]}),d.candidates.length===0?(0,I.jsx)(M,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):(0,I.jsx)(`ul`,{children:d.candidates.map((t,n)=>(0,I.jsxs)(oe,{children:[(0,I.jsxs)(e,{$gap:2,children:[(0,I.jsx)(se,{children:n+1}),(0,I.jsx)(C,{provider:t.provider}),(0,I.jsx)(s,{style:{maxWidth:`22ch`},children:t.credentialLabel}),(0,I.jsx)(f,{$dim:!0,children:t.model}),(0,I.jsxs)(w,{children:[`tier `,t.tier]}),(0,I.jsx)(r,{}),n===0?(0,I.jsx)(ce,{children:`would be used`}):null,(0,I.jsx)(f,{children:t.score.toFixed(2)})]}),v===void 0?null:(0,I.jsx)(le,{children:L.map(e=>{let n=B(t.reasons,e,v),r=b.get(e)??1;return(0,I.jsxs)(ue,{title:ae[e],children:[(0,I.jsxs)(de,{children:[(0,I.jsx)(a,{children:e}),(0,I.jsx)(f,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),(0,I.jsx)(ee,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${e} contributes ${n.toFixed(2)} of ${t.score.toFixed(2)}`})]},e)})})]},`${t.credentialId}:${t.model}`))}),d.excluded.length===0?null:(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(a,{children:`Filtered out`}),(0,I.jsx)(`ul`,{children:d.excluded.map(e=>(0,I.jsxs)(fe,{children:[(0,I.jsx)(f,{$dim:!0,children:e.model}),(0,I.jsx)(r,{}),(0,I.jsx)(w,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}var V=[{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.`}],H=0;function U(){return H+=1,`target-${H}`}function W(e,t){let n=re(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=ne(e,t);return n===null?null:{contextWindow:String(n.contextWindow),maxOutputTokens:String(n.maxOutputTokens)}}function ge(e,t){return{...e,...t,...W(t.provider,t.model)??{},contextWindow:``,maxOutputTokens:``}}function G(e=`anthropic`){let t=N[e].defaultModel,n=W(e,t);return{key:U(),provider:e,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 K(){return{id:``,strategy:`score`,isAlias:!1,targets:[G()]}}function q(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:U(),provider:e.provider,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 _e(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.model.trim();if(i.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let a=Number(r.tier);if(!Number.isInteger(a)||a<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let o=Number(r.weight);if(!Number.isFinite(o)||o<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let s=Number(r.costInput),c=Number(r.costOutput);if(!Number.isFinite(s)||s<0||!Number.isFinite(c)||c<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let l=r.costCacheRead.trim().length>0,u=Number(r.costCacheRead);if(l&&(!Number.isFinite(u)||u<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let d=r.costCacheWrite5m.trim().length>0,f=Number(r.costCacheWrite5m);if(d&&(!Number.isFinite(f)||f<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let p=r.costCacheWrite1h.trim().length>0,m=Number(r.costCacheWrite1h);if(p&&(!Number.isFinite(m)||m<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let h=r.contextWindow.trim().length>0,g=Number(r.contextWindow);if(h&&(!Number.isInteger(g)||g<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let _=r.maxOutputTokens.trim().length>0,v=Number(r.maxOutputTokens);if(_&&(!Number.isInteger(v)||v<1))return{ok:!1,problem:`${e}: the output limit must be a whole number of tokens.`};n.push({provider:r.provider,model:i,tier:a,weight:o,costPerMTok:{input:s,output:c,...l?{cacheRead:u}:{},...d?{cacheWrite5m:f}:{},...p?{cacheWrite1h:m}:{}},...h?{contextWindow:g}:{},..._?{maxOutputTokens:v}:{},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 ve=Object.keys(N),ye=c.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
|
-
`,be=c.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
|
-
`,J=c.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
|
-
`,Y=c.div`
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
gap: 4px;
|
|
78
|
-
min-width: 0;
|
|
79
|
-
`,xe=c(e)`
|
|
80
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
81
|
-
flex-wrap: wrap;
|
|
82
|
-
`,X=c.label`
|
|
83
|
-
display: flex;
|
|
84
|
-
align-items: center;
|
|
85
|
-
gap: 6px;
|
|
86
|
-
cursor: pointer;
|
|
87
|
-
`;function Se({target:o,index:s,onChange:c,onRemove:l,removable:u}){let d=(0,F.useId)(),f=N[o.provider],p=(e,t)=>{c({...o,[e]:t})},m=W(o.provider,o.model),h=he(o.provider,o.model),g=e=>{c(ge(o,e))};return(0,I.jsxs)(ye,{$provider:o.provider,children:[(0,I.jsxs)(e,{$gap:2,children:[(0,I.jsxs)(a,{as:`legend`,children:[`Target `,s+1]}),(0,I.jsx)(r,{}),(0,I.jsx)(n,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!u,"aria-label":`Remove target ${s+1}`,title:u?`Remove target ${s+1}`:`A model needs at least one target`,onClick:l,children:(0,I.jsx)(S,{})})]}),(0,I.jsxs)(be,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-provider`,children:`Provider`}),(0,I.jsx)(T,{id:`${d}-provider`,value:o.provider,onChange:e=>{let t=e.target.value,n=N[t].models.some(e=>e.id===o.model);g({provider:t,model:n?o.model:N[t].defaultModel})},children:ve.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-model`,children:`Provider model`}),(0,I.jsx)(E,{id:`${d}-model`,list:`${d}-catalog`,value:o.model,placeholder:f.defaultModel,onChange:e=>g({provider:o.provider,model:e.target.value})}),(0,I.jsx)(`datalist`,{id:`${d}-catalog`,children:f.models.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-tier`,children:`Tier`}),(0,I.jsx)(D,{id:`${d}-tier`,min:1,step:1,value:o.tier,onChange:e=>p(`tier`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-weight`,children:`Weight`}),(0,I.jsx)(D,{id:`${d}-weight`,min:0,step:.1,value:o.weight,onChange:e=>p(`weight`,e.target.value)})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsxs)(e,{$gap:2,children:[(0,I.jsx)(a,{children:`Price per million tokens`}),(0,I.jsx)(r,{}),m===null?(0,I.jsx)(a,{as:`span`,children:`not in the catalog — price it yourself`}):(0,I.jsxs)(t,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:o.costInput===m.costInput&&o.costOutput===m.costOutput&&o.costCacheRead===m.costCacheRead&&o.costCacheWrite5m===m.costCacheWrite5m&&o.costCacheWrite1h===m.costCacheWrite1h,onClick:()=>c({...o,...m}),children:[(0,I.jsx)(ie,{}),`Use list price`]})]}),(0,I.jsxs)(J,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-in`,children:`Input`}),(0,I.jsx)(D,{id:`${d}-in`,min:0,step:.01,value:o.costInput,onChange:e=>p(`costInput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-out`,children:`Output`}),(0,I.jsx)(D,{id:`${d}-out`,min:0,step:.01,value:o.costOutput,onChange:e=>p(`costOutput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-cache`,children:`Cache read`}),(0,I.jsx)(D,{id:`${d}-cache`,min:0,step:.01,placeholder:`same as input`,value:o.costCacheRead,onChange:e=>p(`costCacheRead`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-write5m`,children:`Cache write 5m`}),(0,I.jsx)(D,{id:`${d}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:o.costCacheWrite5m,onChange:e=>p(`costCacheWrite5m`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-write1h`,children:`Cache write 1h`}),(0,I.jsx)(D,{id:`${d}-write1h`,min:0,step:.01,placeholder:`2x input`,value:o.costCacheWrite1h,onChange:e=>p(`costCacheWrite1h`,e.target.value)})]})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsxs)(e,{$gap:2,children:[(0,I.jsx)(a,{children:`Token limits`}),(0,I.jsx)(r,{}),h===null?(0,I.jsx)(a,{as:`span`,children:`not in the catalog — state them yourself`}):(0,I.jsx)(a,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),(0,I.jsxs)(J,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-context`,children:`Context window`}),(0,I.jsx)(D,{id:`${d}-context`,min:1,step:1024,placeholder:h?.contextWindow??`published`,value:o.contextWindow,onChange:e=>p(`contextWindow`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(a,{as:`label`,htmlFor:`${d}-maxout`,children:`Max output`}),(0,I.jsx)(D,{id:`${d}-maxout`,min:1,step:1024,placeholder:h?.maxOutputTokens??`published`,value:o.maxOutputTokens,onChange:e=>p(`maxOutputTokens`,e.target.value)})]})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(a,{children:`Capabilities`}),(0,I.jsxs)(xe,{children:[(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:o.tools,label:`Target ${s+1} supports tools`,onCheckedChange:e=>p(`tools`,e)}),`Tools`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:o.images,label:`Target ${s+1} supports images`,onCheckedChange:e=>p(`images`,e)}),`Images`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:o.reasoning,label:`Target ${s+1} supports reasoning`,onCheckedChange:e=>p(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Z=c.p`
|
|
88
|
-
font-size: 11.5px;
|
|
89
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
90
|
-
`,Ce=c.p`
|
|
91
|
-
font-size: 12px;
|
|
92
|
-
color: ${({theme:e})=>e.color.down};
|
|
93
|
-
`,we=c.p`
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
color: ${({theme:e})=>e.color.ok};
|
|
96
|
-
`,Te=c(e)`
|
|
97
|
-
gap: 8px;
|
|
98
|
-
`;function Ee({model:n,onSaved:o,onDeleted:s}){let[c,l]=(0,F.useState)(()=>n===null?K():q(n)),[u,d]=(0,F.useState)(null),[f,p]=(0,F.useState)(!1),[m,_]=(0,F.useState)(!1),v=g(),S=h(),C=n?.id??null;(0,F.useEffect)(()=>{l(n===null?K():q(n)),d(null),p(!1)},[C]);let w=V.find(e=>e.id===c.strategy);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(k,{legend:n===null?`New model`:`Edit model`,meta:n===null?void 0:n.id,actions:(0,I.jsxs)(I.Fragment,{children:[n===null?null:(0,I.jsx)(t,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>_(!0),children:`Delete`}),(0,I.jsx)(t,{type:`button`,$variant:`primary`,$size:`sm`,disabled:v.isPending,onClick:()=>{p(!1);let e=_e(c);if(!e.ok){d(e.problem);return}d(null),v.mutate(e.model,{onSuccess:()=>{p(!0),o(e.model.id)},onError:e=>d(A(e))})},children:v.isPending?`Saving…`:n===null?`Create model`:`Save changes`})]}),children:(0,I.jsxs)(i,{$gap:3,children:[(0,I.jsx)(O,{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=>(0,I.jsx)(E,{...e,value:c.id,disabled:n!==null,placeholder:`fast`,onChange:e=>l({...c,id:e.target.value})})}),(0,I.jsx)(O,{label:`Routing strategy`,children:e=>(0,I.jsx)(T,{...e,value:c.strategy,onChange:e=>l({...c,strategy:e.target.value}),children:V.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),w===void 0?null:(0,I.jsx)(Z,{children:w.blurb}),(0,I.jsxs)(Te,{children:[(0,I.jsx)(x,{checked:c.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>l({...c,isAlias:e})}),(0,I.jsxs)(i,{$gap:0,children:[(0,I.jsx)(a,{as:`span`,children:`Alias`}),(0,I.jsx)(Z,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),(0,I.jsxs)(i,{$gap:2,children:[(0,I.jsxs)(e,{children:[(0,I.jsx)(a,{children:`Targets`}),(0,I.jsx)(r,{}),(0,I.jsxs)(t,{type:`button`,$size:`sm`,onClick:()=>l({...c,targets:[...c.targets,G(c.targets.at(-1)?.provider??`anthropic`)]}),children:[(0,I.jsx)(b,{}),`Add target`]})]}),c.targets.map((e,t)=>(0,I.jsx)(Se,{target:e,index:t,removable:c.targets.length>1,onChange:t=>l({...c,targets:c.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>l({...c,targets:c.targets.filter(t=>t.key!==e.key)})},e.key))]}),u===null?null:(0,I.jsx)(Ce,{role:`alert`,children:u}),f&&u===null?(0,I.jsx)(we,{role:`status`,children:`Saved.`}):null]})}),(0,I.jsx)(y,{open:m,onOpenChange:_,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:S.isPending,onConfirm:()=>{n!==null&&S.mutate(n.id,{onSuccess:()=>{_(!1),s()},onError:e=>{_(!1),d(A(e))}})}})]})}var De=c.div`
|
|
99
|
-
display: grid;
|
|
100
|
-
grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
|
|
101
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
102
|
-
align-items: start;
|
|
103
|
-
|
|
104
|
-
@media (max-width: 980px) {
|
|
105
|
-
grid-template-columns: minmax(0, 1fr);
|
|
106
|
-
}
|
|
107
|
-
`,Oe=c(i)`
|
|
108
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
109
|
-
min-width: 0;
|
|
110
|
-
`,Q=c.button`
|
|
111
|
-
display: flex;
|
|
112
|
-
flex-direction: column;
|
|
113
|
-
gap: 4px;
|
|
114
|
-
width: 100%;
|
|
115
|
-
padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
|
|
116
|
-
text-align: left;
|
|
117
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:`transparent`};
|
|
118
|
-
border: 0;
|
|
119
|
-
border-left: 2px solid
|
|
120
|
-
${({theme:e,$selected:t})=>t?e.color.accent:`transparent`};
|
|
121
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
122
|
-
cursor: pointer;
|
|
123
|
-
|
|
124
|
-
&:hover {
|
|
125
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:e.color.panelSunk};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
&:last-child {
|
|
129
|
-
border-bottom: 0;
|
|
130
|
-
}
|
|
131
|
-
`,ke=c(s)`
|
|
132
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
133
|
-
font-size: 12.5px;
|
|
134
|
-
display: block;
|
|
135
|
-
max-width: 100%;
|
|
136
|
-
`,Ae=c.div`
|
|
137
|
-
display: flex;
|
|
138
|
-
gap: 2px;
|
|
139
|
-
`,je=c.span`
|
|
140
|
-
width: 12px;
|
|
141
|
-
height: 3px;
|
|
142
|
-
border-radius: 1px;
|
|
143
|
-
background: ${({$provider:e})=>`var(--p-${e})`};
|
|
144
|
-
`,$=`\0new`;function Me(){let n=d(),[i,o]=(0,F.useState)(null),s=n.data??[],c=i===$?null:s.find(e=>e.id===i)??null,l=i===$||i===null&&!n.isLoading&&s.length===0;(0,F.useEffect)(()=>{i===null&&s.length!==0&&o(s[0]?.id??null)},[s,i]);let u=n.isLoading?`Reading configured models…`:s.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${s.length} model${s.length===1?``:`s`} routing to ${s.reduce((e,t)=>e+t.targets.length,0)} targets.`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{legend:`Models`,title:`Virtual models`,summary:u,actions:(0,I.jsxs)(t,{type:`button`,$variant:`primary`,onClick:()=>o($),children:[(0,I.jsx)(b,{}),`New model`]})}),(0,I.jsxs)(De,{children:[(0,I.jsx)(k,{legend:`Configured`,meta:`${s.length}`,flush:!0,children:n.isError?(0,I.jsx)(te,{error:n.error,onRetry:()=>void n.refetch()}):n.isLoading?(0,I.jsx)(`div`,{style:{padding:12},children:(0,I.jsx)(j,{rows:4})}):s.length===0?(0,I.jsx)(M,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:(0,I.jsx)(t,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>o($),children:`New model`})}):(0,I.jsx)(`div`,{children:s.map(t=>{let n=[...new Set(t.targets.map(e=>e.provider))];return(0,I.jsxs)(Q,{type:`button`,$selected:t.id===i,"aria-pressed":t.id===i,onClick:()=>o(t.id),children:[(0,I.jsxs)(e,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(ke,{title:t.id,children:t.id}),(0,I.jsx)(r,{}),t.isAlias?(0,I.jsx)(w,{children:`alias`}):null]}),(0,I.jsxs)(e,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(Ae,{children:n.map(e=>(0,I.jsx)(je,{$provider:e,title:e},e))}),(0,I.jsx)(a,{children:t.strategy}),(0,I.jsx)(r,{}),(0,I.jsxs)(f,{$dim:!0,$size:`11px`,children:[t.targets.length,` target`,t.targets.length===1?``:`s`]})]})]},t.id)})})}),(0,I.jsxs)(Oe,{children:[c===null&&!l?(0,I.jsx)(k,{legend:`Editor`,children:n.isLoading?(0,I.jsx)(j,{rows:5}):(0,I.jsx)(M,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):(0,I.jsx)(Ee,{model:c,onSaved:e=>{o(e),n.refetch()},onDeleted:()=>{o(null),n.refetch()}}),(0,I.jsx)(me,{modelId:c?.id??null})]})]})]})}var Ne=Me;export{Ne as component};
|