omnigateway 0.2.0 → 0.2.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/bin/omni.js +527 -228
- package/gateway.js +763 -401
- package/package.json +1 -1
- package/public/assets/{Chip-BB_5C1Zp.js → Chip-C4X8tf5z.js} +1 -1
- package/public/assets/Confirm-BnmH8Gn0.js +4 -0
- package/public/assets/{CopyValue-CRQDLo7k.js → CopyValue-B-uR4Js-.js} +5 -5
- package/public/assets/{Field-uHZxl4fI.js → Field-Ct4SeDZD.js} +2 -2
- package/public/assets/{Lamp-B-5SjXbG.js → Lamp-CBOwqG5K.js} +7 -7
- package/public/assets/{Meter-DI_BRUKt.js → Meter-COdz0dwY.js} +1 -1
- package/public/assets/{Modal-CI6jk2D4.js → Modal-DMFUHQ-A.js} +8 -8
- package/public/assets/{Rack-D1WJswv3.js → Rack-DAbY9x1I.js} +18 -18
- package/public/assets/{Readout-BocZ2HXP.js → Readout-Bl2kD9Tl.js} +6 -2
- package/public/assets/{States-Bbiu5cHE.js → States-D5Memn8D.js} +4 -4
- package/public/assets/{Table-CdPWxYaz.js → Table-DObRatbW.js} +1 -1
- package/public/assets/{Toggle-CiLC67Dw.js → Toggle-Dkjlvck5.js} +1 -1
- package/public/assets/{TokenBreakdown-B96iPBm9.js → TokenBreakdown-oXP49ZTa.js} +5 -2
- package/public/assets/_app-Brc2wQZm.js +1 -0
- package/public/assets/_app.accounts-I9RXUiyi.js +54 -0
- package/public/assets/{_app.console-Daz4aKhf.js → _app.console-BVVpryIB.js} +10 -10
- package/public/assets/_app.index-83Ig4FUL.js +62 -0
- package/public/assets/_app.keys-KeP6L4g_.js +39 -0
- package/public/assets/_app.logs-B5oh01Ls.js +32 -0
- package/public/assets/_app.models-BuOFMZUN.js +144 -0
- package/public/assets/{_app.settings-a0FKyQAi.js → _app.settings-BN436vI2.js} +4 -4
- package/public/assets/_app.usage-C528VOia.js +166 -0
- package/public/assets/catalog-kJ53n_fc.js +1 -0
- package/public/assets/{dist-C-IbPRiV.js → dist-CnzT-Ut2.js} +1 -1
- package/public/assets/index-CE-KQ-ju.js +172 -0
- package/public/assets/{login-CTvH_KAd.js → login-2LpCZOtB.js} +8 -8
- package/public/assets/{queries-D2o-X8Pj.js → queries-1zRLkX-Q.js} +27 -27
- package/public/assets/{trash-2-BcZb-sCT.js → trash-2-Da6cLgPn.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/Confirm-B6aAiVbT.js +0 -4
- package/public/assets/_app-BBOF6A0T.js +0 -1
- package/public/assets/_app.accounts-BNkhpvaB.js +0 -54
- package/public/assets/_app.index-LO6d38oe.js +0 -62
- package/public/assets/_app.keys-kBqLqoFf.js +0 -39
- package/public/assets/_app.logs-_wYNS47N.js +0 -32
- package/public/assets/_app.models-Cjng8ohC.js +0 -144
- package/public/assets/_app.usage-D3KtgLrC.js +0 -166
- package/public/assets/catalog-C_OQ0icG.js +0 -1
- package/public/assets/index-PW6EvVh5.js +0 -170
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e}from"./Rack-
|
|
1
|
+
import{h as e}from"./Rack-DAbY9x1I.js";var t=e(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]);export{t};
|
package/public/index.html
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<!-- Self-hosted, like the fonts: the console contacts no third-party origin. -->
|
|
7
7
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
|
8
8
|
<title>OmniGateway — One endpoint in front of the AI accounts you already pay for.</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/queries-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-CE-KQ-ju.js"></script>
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/queries-1zRLkX-Q.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-Co2s5xMk.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{B as e,G as t,Mt as n}from"./queries-D2o-X8Pj.js";import{h as r}from"./Rack-D1WJswv3.js";import{t as i}from"./Modal-CI6jk2D4.js";var a=r(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),o=n(),s=t.p`
|
|
2
|
-
font-size: 13px;
|
|
3
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
4
|
-
`;function c({open:t,onOpenChange:n,title:r,body:a,confirmLabel:c,busy:l,onConfirm:u}){return(0,o.jsx)(i,{open:t,onOpenChange:n,title:r,width:`420px`,footer:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(e,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),(0,o.jsx)(e,{type:`button`,$variant:`danger`,disabled:l===!0,onClick:u,children:c})]}),children:(0,o.jsx)(s,{children:a})})}export{a as n,c as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Mt as e}from"./queries-D2o-X8Pj.js";import{o as t}from"./index-PW6EvVh5.js";import{i as n,n as r}from"./Rack-D1WJswv3.js";var i=e(),a=()=>(0,i.jsx)(n,{children:(0,i.jsx)(r,{children:(0,i.jsx)(t,{})})});export{a as component};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,E as n,F as r,G as i,L as a,Mt as o,Nt as s,P as c,V as l,Zt as u,d,f,j as p,o as m,r as h,s as g,u as _}from"./queries-D2o-X8Pj.js";import{a as v,f as y,h as b,t as x,u as S}from"./Rack-D1WJswv3.js";import{t as C}from"./CopyValue-CRQDLo7k.js";import{n as w,t as T}from"./Confirm-B6aAiVbT.js";import{t as ee}from"./trash-2-BcZb-sCT.js";import{t as E}from"./Modal-CI6jk2D4.js";import{t as D}from"./Toggle-CiLC67Dw.js";import{a as O,d as te,i as ne,n as re,t as k,u as A}from"./Lamp-B-5SjXbG.js";import{t as j}from"./Chip-BB_5C1Zp.js";import{i as M,n as N,r as P,t as F}from"./Field-uHZxl4fI.js";import{t as ie}from"./Meter-DI_BRUKt.js";import{a as I,i as L,n as R,r as z,t as B}from"./States-Bbiu5cHE.js";import{i as V,n as H,r as U,t as W}from"./Table-CdPWxYaz.js";import{t as G}from"./catalog-C_OQ0icG.js";var K=b(`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=u(s(),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=i.ol`
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
5
|
-
`,se=i.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=i.p`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.down};
|
|
17
|
-
`,le=i.p`
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
20
|
-
`;function ue({open:t,onOpenChange:n,onConnected:r}){let[i,o]=(0,q.useState)(`anthropic`),[s,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(null),[f,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(null),b=g(),x=m(),S=(0,q.useCallback)(()=>{d(null),_(``),y(null),l(``),b.reset(),x.reset()},[b,x]),w=(0,q.useCallback)(e=>{e||S(),n(e)},[n,S]);return(0,q.useEffect)(()=>{if(u===null||u.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await h(u.flowId);if(e)return;if(t.status===`complete`){S(),n(!1),r();return}}catch(t){if(e)return;y(L(t)),d(null);return}e||(i=setTimeout(()=>void t(),u.pollIntervalMs))},i=setTimeout(()=>void t(),u.pollIntervalMs);return()=>{e=!0,clearTimeout(i)}},[u,r,n,S]),(0,J.jsx)(E,{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:u===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(e,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(e,{type:`button`,$variant:`primary`,disabled:b.isPending,onClick:()=>{y(null),b.mutate({provider:i,label:s.trim().length===0?Y[i]:s.trim()},{onSuccess:e=>d(e),onError:e=>y(L(e))})},children:b.isPending?`Starting…`:`Start authorization`})]}):u.kind===`device`?(0,J.jsx)(e,{type:`button`,onClick:()=>w(!1),children:`Cancel`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(e,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(e,{type:`button`,$variant:`primary`,disabled:x.isPending||f.trim().length===0,onClick:()=>{u!==null&&(y(null),x.mutate({flowId:u.flowId,code:f.trim()},{onSuccess:()=>{S(),n(!1),r()},onError:e=>y(L(e))}))},children:x.isPending?`Finishing…`:`Finish connecting`})]}),children:(0,J.jsxs)(oe,{children:[u===null?(0,J.jsxs)(a,{$gap:3,children:[(0,J.jsx)(F,{label:`Provider`,children:e=>(0,J.jsx)(M,{...e,value:i,onChange:e=>o(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:s,placeholder:Y[i],onChange:e=>l(e.target.value)})})]}):(0,J.jsxs)(a,{$gap:3,children:[(0,J.jsxs)(a,{$gap:1,children:[(0,J.jsx)(p,{children:`Step 1 — authorize`}),(0,J.jsx)(c,{$gap:2,children:(0,J.jsxs)(e,{as:`a`,href:u.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[(0,J.jsx)(K,{}),`Open `,Y[i]]})}),(0,J.jsx)(C,{value:u.authorizeUrl,label:`Copy authorization link`})]}),u.userCode===null?null:(0,J.jsxs)(a,{$gap:1,children:[(0,J.jsx)(p,{children:`Step 2 — enter this code`}),(0,J.jsx)(se,{children:u.userCode})]}),u.kind===`device`?(0,J.jsxs)(le,{children:[X[i],` Waiting for authorization…`]}):(0,J.jsx)(F,{label:`Authorization code`,hint:X[i],...v===null?{}:{problem:v},children:e=>(0,J.jsx)(N,{...e,value:f,autoFocus:!0,placeholder:i===`openai`?`http://localhost:1455/auth/callback?code=…`:`code#state`,onChange:e=>_(e.target.value)})})]}),v===null||u?.kind===`pkce`?null:(0,J.jsx)(ce,{children:v})]})})}var de=[`anthropic`,`openai`,`kimi`],Z={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`},fe=i(I)`
|
|
21
|
-
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
22
|
-
`,pe=i(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=i(P)`
|
|
37
|
-
width: 62px;
|
|
38
|
-
height: 26px;
|
|
39
|
-
`,me=i.span`
|
|
40
|
-
display: block;
|
|
41
|
-
padding-left: 9px;
|
|
42
|
-
font-size: 11px;
|
|
43
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
44
|
-
`,he=i.div`
|
|
45
|
-
display: grid;
|
|
46
|
-
grid-template-columns: 96px 1fr;
|
|
47
|
-
align-items: center;
|
|
48
|
-
min-width: 208px;
|
|
49
|
-
gap: 6px;
|
|
50
|
-
`,ge=i.div`
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
gap: 4px;
|
|
54
|
-
`;function $(){let e=n();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function _e(){let{cadence:n}=v(),i=d(),o=_(n(1e4)),s=t(),u=f(),{commit:m}=$(),[h,g]=(0,q.useState)(!1),[b,C]=(0,q.useState)(null),E=Date.now(),M=i.data??[],N=O(o.data?.health??[],e=>e.credentialId),P=O(o.data?.quota??[],e=>e.credentialId),F=s.data?.quotaPollIntervalMs??3e5,L=M.filter(e=>e.enabled).length,G=i.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)(x,{legend:`Accounts`,title:`Provider accounts`,summary:G,actions:(0,J.jsxs)(e,{type:`button`,$variant:`primary`,onClick:()=>g(!0),children:[(0,J.jsx)(w,{}),`Connect an account`]})}),i.isError?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(R,{error:i.error,onRetry:()=>void i.refetch()})}):i.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)(e,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>g(!0),children:`Connect an account`})})}):(0,J.jsx)(a,{$gap:4,children:de.filter(e=>M.some(t=>t.provider===e)).map(e=>{let t=M.filter(t=>t.provider===e);return(0,J.jsx)(fe,{$provider:e,legend:Z[e],meta:`${t.length} account${t.length===1?``:`s`}`,flush:!0,children:(0,J.jsx)(r,{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:`240px`,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:t.map(e=>{let t=ne(N.get(e.id)??[],E,e.enabled,e.disabledReason),n=te(P.get(e.id)??[]);return(0,J.jsxs)(V,{children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(c,{$gap:2,children:[(0,J.jsx)(k,{state:t.state,label:t.note===``?`healthy`:t.note}),(0,J.jsx)(pe,{defaultValue:e.label,"aria-label":`Label for ${e.label}`,onBlur:t=>{let n=t.target.value.trim();if(n.length===0||n===e.label){t.target.value=e.label;return}m(e.id,{label:n})}})]}),t.note===``?null:(0,J.jsx)(me,{children:t.note})]}),(0,J.jsx)(H,{children:(0,J.jsxs)(c,{$gap:1,children:[(0,J.jsx)(j,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:(0,J.jsx)(p,{children:e.accountEmail})]})}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(Q,{min:1,step:1,defaultValue:e.tier,"aria-label":`Tier for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isInteger(n)||n<1||n===e.tier){t.target.value=String(e.tier);return}m(e.id,{tier:n})}})}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(Q,{min:.1,step:.1,defaultValue:e.weight,"aria-label":`Weight for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isFinite(n)||n<=0||n===e.weight){t.target.value=String(e.weight);return}m(e.id,{weight:n})}})}),(0,J.jsx)(H,{$align:`center`,children:(0,J.jsx)(D,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>m(e.id,{enabled:t})})}),(0,J.jsx)(H,{children:n.length===0?(0,J.jsx)(p,{children:`unknown`}):(0,J.jsx)(ge,{children:n.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)(p,{children:A(e,E,F,y)})]},e.windowType))})}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:S(t.ttftMs)}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:y(e.expiresAt,E)}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>C(e),children:(0,J.jsx)(ee,{})})})]},e.id)})})]})})},e)})}),(0,J.jsx)(ue,{open:h,onOpenChange:g,onConnected:()=>void i.refetch()}),(0,J.jsx)(T,{open:b!==null,onOpenChange:e=>{e||C(null)},title:`Remove account`,body:b===null?``:`Removing "${b.label}" deletes its stored token. Any model target pointing at ${Z[b.provider]} loses this account, and reconnecting means authorizing again.`,confirmLabel:`Remove account`,busy:u.isPending,onConfirm:()=>{b!==null&&u.mutate(b.id,{onSettled:()=>C(null)})}})]})}var ve=_e;export{ve as component};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,D as r,F as i,G as a,I as o,L as s,M as c,Mt as l,P as u,R as d,d as f,j as p,q as m,u as h,v as g,y as _}from"./queries-D2o-X8Pj.js";import{a as v,d as y,f as b,o as x,p as S,r as C,s as w,t as T,u as E}from"./Rack-D1WJswv3.js";import{n as D,t as O}from"./TokenBreakdown-B96iPBm9.js";import{a as k,c as A,d as j,f as M,i as N,l as ee,n as te,r as ne,s as P,t as F,u as I}from"./Lamp-B-5SjXbG.js";import{n as L,t as R}from"./Chip-BB_5C1Zp.js";import{t as z}from"./Meter-DI_BRUKt.js";import{a as B,n as V,t as H}from"./States-Bbiu5cHE.js";import{i as U,n as W,r as G,t as K}from"./Table-CdPWxYaz.js";import{t as q}from"./Readout-BocZ2HXP.js";var J=l(),Y=a(d)`
|
|
2
|
-
font-weight: 500;
|
|
3
|
-
display: block;
|
|
4
|
-
max-width: 24ch;
|
|
5
|
-
`,X=a.span`
|
|
6
|
-
font-size: 11px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
`,Z=a.div`
|
|
9
|
-
display: grid;
|
|
10
|
-
grid-template-columns: 72px 1fr;
|
|
11
|
-
align-items: center;
|
|
12
|
-
gap: 6px;
|
|
13
|
-
min-width: 172px;
|
|
14
|
-
`,re=a.div`
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
gap: 4px;
|
|
18
|
-
`;function ie({credentials:e,health:n,quota:r,usage:a,quotaPollIntervalMs:o,now:s}){let c=k(n,e=>e.credentialId),l=k(r,e=>e.credentialId),d=new Map(a.map(e=>[e.key,e])),f={down:0,warn:1,ok:2,idle:3,live:3},h=e.map(e=>({credential:e,status:N(c.get(e.id)??[],s,e.enabled,e.disabledReason),quota:j(l.get(e.id)??[]),usage:d.get(e.id)})).sort((e,t)=>f[e.status.state]-f[t.status.state]||e.credential.tier-t.credential.tier);return(0,J.jsx)(B,{legend:`Accounts`,meta:`${e.length} connected`,flush:!0,actions:(0,J.jsx)(t,{as:m,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:e.length===0?(0,J.jsx)(H,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:(0,J.jsx)(t,{as:m,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):(0,J.jsx)(i,{children:(0,J.jsxs)(K,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(G,{children:`Account`}),(0,J.jsx)(G,{children:`Provider`}),(0,J.jsx)(G,{$align:`right`,children:`Tier`}),(0,J.jsx)(G,{children:`Quota`}),(0,J.jsx)(G,{$align:`right`,children:`TTFT`}),(0,J.jsx)(G,{$align:`right`,children:`Requests`}),(0,J.jsx)(G,{$align:`right`,children:`Last used`})]})}),(0,J.jsx)(`tbody`,{children:h.map(({credential:e,status:t,quota:n,usage:r})=>(0,J.jsxs)(U,{children:[(0,J.jsx)(W,{children:(0,J.jsxs)(u,{$gap:2,children:[(0,J.jsx)(F,{state:t.state,label:t.note===``?`healthy`:t.note}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(Y,{children:e.label}),t.note===``?null:(0,J.jsx)(X,{children:t.note})]})]})}),(0,J.jsx)(W,{children:(0,J.jsx)(L,{provider:e.provider})}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:e.tier}),(0,J.jsx)(W,{children:n.length===0?(0,J.jsx)(X,{children:`unknown`}):(0,J.jsx)(re,{children:n.map(({window:e,fraction:t})=>(0,J.jsxs)(Z,{children:[(0,J.jsx)(z,{fraction:t,label:`${te[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,J.jsx)(p,{children:I(e,s,o,b)})]},e.windowType))})}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:E(t.ttftMs)}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:r===void 0?`—`:w(r.requests)}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:b(t.lastUsedAt,s)})]},e.id))})]})})})}var ae=a.ul`
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
`,oe=a.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
|
-
`,se=a(d)`
|
|
32
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
max-width: 30ch;
|
|
35
|
-
`,ce=a(c)`
|
|
36
|
-
color: ${({theme:e})=>e.color.down};
|
|
37
|
-
font-size: 11px;
|
|
38
|
-
`;function le({logs:e}){let n=e.slice(0,12);return(0,J.jsx)(B,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:(0,J.jsx)(t,{as:m,to:`/logs`,$size:`sm`,children:`Open logs`}),children:n.length===0?(0,J.jsx)(H,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):(0,J.jsx)(ae,{children:n.map(e=>(0,J.jsxs)(oe,{children:[(0,J.jsx)(F,{state:ee(e),label:A(e)}),(0,J.jsx)(c,{$dim:!0,children:x(e.at)}),(0,J.jsx)(se,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:(0,J.jsx)(c,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),(0,J.jsx)(o,{}),P(e)?(0,J.jsx)(c,{$dim:!0,"aria-label":`processing`,children:(0,J.jsx)(O,{})}):(0,J.jsxs)(J.Fragment,{children:[e.errorCode===null?null:(0,J.jsx)(ce,{children:e.errorCode}),e.attempts>1?(0,J.jsxs)(c,{$dim:!0,children:[e.attempts,`×`]}):null,(0,J.jsx)(c,{$dim:!0,children:(0,J.jsx)(D,{tokens:e})}),(0,J.jsx)(c,{$dim:!0,children:E(e.durationMs)}),(0,J.jsx)(c,{$dim:!0,children:S(e.costUsd)})]})]},e.id))})})}var ue=a.ul`
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
42
|
-
`,de=a(d)`
|
|
43
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
44
|
-
font-size: 12.5px;
|
|
45
|
-
`,fe=a.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
|
-
`,pe=a.div`
|
|
53
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
54
|
-
background: ${({$color:e})=>e};
|
|
55
|
-
opacity: 0.8;
|
|
56
|
-
`,me=a.div`
|
|
57
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
58
|
-
`;function Q({models:e,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=[...e].map(e=>({model:e,used:r.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return(0,J.jsx)(B,{legend:`Models`,meta:`${e.length} configured`,actions:(0,J.jsx)(t,{as:m,to:`/models`,$size:`sm`,children:`Edit routing`}),children:e.length===0?(0,J.jsx)(H,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:(0,J.jsx)(t,{as:m,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):(0,J.jsx)(ue,{children:a.map(({model:e,used:t})=>{let n=(t?.requests??0)/i,r=[...new Set(e.targets.map(e=>e.provider))];return(0,J.jsxs)(`li`,{children:[(0,J.jsxs)(u,{$gap:2,children:[(0,J.jsx)(de,{title:e.id,children:e.id}),e.isAlias?(0,J.jsx)(R,{children:`alias`}):null,(0,J.jsx)(R,{$tone:`accent`,children:e.strategy}),(0,J.jsx)(o,{}),(0,J.jsx)(c,{$dim:!0,children:w(t?.requests??0)}),(0,J.jsx)(p,{children:`req`}),(0,J.jsx)(c,{$dim:!0,children:S(t?.costUsd??0)})]}),(0,J.jsxs)(fe,{style:{marginTop:6},title:`${Math.round(n*100)}% of the busiest model`,children:[r.map(e=>(0,J.jsx)(pe,{$color:`var(--p-${e})`,$grow:n/r.length},e)),(0,J.jsx)(me,{$grow:Math.max(0,1-n)})]})]},e.id)})})})}var he=a.div`
|
|
59
|
-
display: grid;
|
|
60
|
-
grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
|
|
61
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
62
|
-
`;function ge({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=M(r,t),a=ne(r,{now:n,spanMs:t,count:32}),o=i.errorRate>=.25?`down`:i.errorRate>=.05?`warn`:`ok`,s=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens;return(0,J.jsxs)(he,{children:[(0,J.jsx)(q,{legend:`Requests`,value:w(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:(0,J.jsx)(C,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),(0,J.jsx)(q,{legend:`Error rate`,value:y(i.errorRate),unit:`${w(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:(0,J.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,J.jsx)(q,{legend:`Total tokens`,value:w(s),unit:(0,J.jsx)(D,{tokens:i}),trace:(0,J.jsx)(C,{values:a.map(e=>e.tokens),label:`token volume over the window, ${s.toLocaleString(`en-US`)} total`})}),(0,J.jsx)(q,{legend:`Time to first token`,value:E(i.ttftP50),unit:`p95 ${E(i.ttftP95)}`,trace:(0,J.jsx)(C,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${E(i.ttftP50)}`})}),(0,J.jsx)(q,{legend:`Spend`,value:S(i.costUsd),unit:`${w(i.inputTokens+i.outputTokens)} tokens`,trace:(0,J.jsx)(C,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${S(i.costUsd)} total`})})]})}var $=36e5;function _e(){let{cadence:t}=v(),i=f(),a=h(t(1e4)),o=_(),c=g(500,t(1e4)),l=n(),u=Date.now(),d=Math.floor((u-$)/6e4)*6e4,p=r({groupBy:`credential`,since:d},t(6e4)),m=i.data??[],y=k(a.data?.health??[],e=>e.credentialId),b=m.filter(e=>N(y.get(e.id)??[],u,e.enabled,e.disabledReason).state===`down`),x=i.isLoading||c.isLoading?`Reading the gateway…`:m.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 ${m.length} accounts are answering. Nothing needs attention.`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T,{legend:`Rack`,title:`Gateway`,summary:x}),c.isError?(0,J.jsx)(B,{legend:`Traffic`,children:(0,J.jsx)(V,{legend:`The gateway did not answer`,error:c.error,onRetry:()=>void c.refetch()})}):(0,J.jsxs)(s,{$gap:4,children:[(0,J.jsx)(ge,{logs:c.data??[],windowMs:$,now:u}),(0,J.jsx)(ie,{credentials:m,health:a.data?.health??[],quota:a.data?.quota??[],usage:p.data??[],quotaPollIntervalMs:l.data?.quotaPollIntervalMs??3e5,now:u}),(0,J.jsxs)(e,{$min:`340px`,$gap:4,children:[(0,J.jsx)(Q,{models:o.data??[],logs:c.data??[]}),(0,J.jsx)(le,{logs:c.data??[]})]})]})]})}var ve=_e;export{ve as component};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{B as e,F as t,G as n,L as r,M as i,Mt as a,Nt as o,P as s,R as c,Zt as l,b as u,h as d,j as f,l as p,y as m}from"./queries-D2o-X8Pj.js";import{c as h,t as g}from"./Rack-D1WJswv3.js";import{t as _}from"./CopyValue-CRQDLo7k.js";import{n as v,t as y}from"./Confirm-B6aAiVbT.js";import{t as b}from"./Modal-CI6jk2D4.js";import{t as x}from"./Toggle-CiLC67Dw.js";import{t as S}from"./Chip-BB_5C1Zp.js";import{n as C,t as w}from"./Field-uHZxl4fI.js";import{a as T,i as E,n as D,r as O,t as k}from"./States-Bbiu5cHE.js";import{i as A,n as j,r as M,t as N}from"./Table-CdPWxYaz.js";var P=l(o(),1),F=a(),I=n.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=n.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=n.p`
|
|
25
|
-
font-size: 12px;
|
|
26
|
-
color: ${({theme:e})=>e.color.warn};
|
|
27
|
-
`,z=n.p`
|
|
28
|
-
font-size: 12px;
|
|
29
|
-
color: ${({theme:e})=>e.color.down};
|
|
30
|
-
`,B=n.p`
|
|
31
|
-
font-size: 12px;
|
|
32
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
33
|
-
`;function V({open:t,onOpenChange:n}){let a=m(),o=p(),[c,l]=(0,P.useState)(``),[u,d]=(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=()=>{l(``),d(!0),g([]),y(``),T(null),O(null),o.reset()},A=e=>{e||k(),n(e)};return(0,F.jsx)(b,{open:t,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)(e,{type:`button`,onClick:()=>A(!1),children:`Cancel`}),(0,F.jsx)(e,{type:`button`,$variant:`primary`,disabled:o.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),o.mutate({label:c.trim().length===0?`api key`:c.trim(),modelAllowlist:u?null:h,rateLimitPerMin:t},{onSuccess:e=>T(e),onError:e=>O(E(e))})},children:o.isPending?`Creating…`:`Create key`})]}):(0,F.jsx)(e,{type:`button`,$variant:`primary`,onClick:()=>A(!1),children:`I have copied the key`}),children:S===null?(0,F.jsxs)(r,{$gap:3,children:[(0,F.jsx)(w,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>(0,F.jsx)(C,{...e,value:c,placeholder:`api key`,onChange:e=>l(e.target.value)})}),(0,F.jsxs)(r,{$gap:2,children:[(0,F.jsxs)(s,{$gap:2,children:[(0,F.jsx)(x,{checked:u,label:`Allow every model`,onCheckedChange:d}),(0,F.jsx)(f,{as:`span`,children:`Allow every model`})]}),u?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{children:(a.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)(r,{$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)(s,{$gap:2,children:[(0,F.jsx)(f,{children:`Label`}),(0,F.jsx)(i,{children:S.label}),(0,F.jsx)(f,{children:`Prefix`}),(0,F.jsx)(i,{children:S.prefix})]})]})})}var H=n(s)`
|
|
34
|
-
gap: 4px;
|
|
35
|
-
flex-wrap: wrap;
|
|
36
|
-
max-width: 34ch;
|
|
37
|
-
`,U=n.span`
|
|
38
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
39
|
-
`;function W(){let n=d(),r=u(),[i,a]=(0,P.useState)(!1),[o,s]=(0,P.useState)(null),l=n.data??[],p=l.filter(e=>e.revokedAt===null),m=n.isLoading?`Reading issued keys…`:l.length===0?`No keys exist, so nothing can call this gateway yet.`:`${p.length} active key${p.length===1?``:`s`} of ${l.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)(e,{type:`button`,$variant:`primary`,onClick:()=>a(!0),children:[(0,F.jsx)(v,{}),`Create a key`]})}),(0,F.jsx)(T,{legend:`Issued keys`,meta:`${l.length}`,flush:!0,children:n.isError?(0,F.jsx)(D,{error:n.error,onRetry:()=>void n.refetch()}):n.isLoading?(0,F.jsx)(`div`,{style:{padding:12},children:(0,F.jsx)(O,{rows:4})}):l.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)(e,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>a(!0),children:`Create a key`})}):(0,F.jsx)(t,{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:l.map(t=>(0,F.jsxs)(A,{children:[(0,F.jsx)(j,{children:(0,F.jsx)(c,{style:{maxWidth:`24ch`,display:`block`},children:t.label})}),(0,F.jsxs)(j,{$mono:!0,children:[t.prefix,`…`]}),(0,F.jsx)(j,{children:t.modelAllowlist===null?(0,F.jsx)(f,{children:`every model`}):t.modelAllowlist.length===0?(0,F.jsx)(S,{$tone:`down`,children:`no models`}):(0,F.jsx)(H,{children:t.modelAllowlist.map(e=>(0,F.jsx)(S,{children:e},e))})}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:t.rateLimitPerMin===null?`—`:`${t.rateLimitPerMin}/min`}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:h(t.createdAt)}),(0,F.jsx)(j,{children:t.revokedAt===null?(0,F.jsx)(S,{$tone:`ok`,children:`active`}):(0,F.jsx)(U,{title:h(t.revokedAt),children:(0,F.jsx)(S,{children:`revoked`})})}),(0,F.jsx)(j,{$align:`right`,children:t.revokedAt===null?(0,F.jsx)(e,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>s(t),children:`Revoke`}):null})]},t.id))})]})})}),(0,F.jsx)(V,{open:i,onOpenChange:a}),(0,F.jsx)(y,{open:o!==null,onOpenChange:e=>{e||s(null)},title:`Revoke key`,body:o===null?``:`Revoking "${o.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:r.isPending,onConfirm:()=>{o!==null&&r.mutate(o.id,{onSettled:()=>s(null)})}})]})}var G=W;export{G as component};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import{B as e,F as t,G as n,L as r,M as i,Mt as a,Nt as o,P as s,R as c,Zt as l,d as ee,h as te,j as u,n as d,v as f}from"./queries-D2o-X8Pj.js";import{a as p,c as m,l as ne,m as h,o as g,p as _,s as v,t as y,u as b}from"./Rack-D1WJswv3.js";import{n as x,r as S,t as C}from"./TokenBreakdown-B96iPBm9.js";import{t as re}from"./Modal-CI6jk2D4.js";import{c as ie,l as ae,o as w,s as T,t as oe}from"./Lamp-B-5SjXbG.js";import{n as se,t as E}from"./Chip-BB_5C1Zp.js";import{i as D,n as O}from"./Field-uHZxl4fI.js";import{a as k,n as ce,r as A,t as j}from"./States-Bbiu5cHE.js";import{i as M,n as N,r as P,t as F}from"./Table-CdPWxYaz.js";var I=l(o(),1),L=a(),R=[50,100,250,500],z=n(s)`
|
|
2
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
`,B=n(O)`
|
|
5
|
-
width: 220px;
|
|
6
|
-
`,V=n(D)`
|
|
7
|
-
width: auto;
|
|
8
|
-
`,H=n(k)`
|
|
9
|
-
flex: 1;
|
|
10
|
-
min-height: 0;
|
|
11
|
-
|
|
12
|
-
> div {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex: 1;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
min-height: 0;
|
|
17
|
-
}
|
|
18
|
-
`,U=n(t)`
|
|
19
|
-
flex: 1;
|
|
20
|
-
min-height: 0;
|
|
21
|
-
overflow-y: auto;
|
|
22
|
-
`;function W(e){let[t,n]=(0,I.useState)(Date.now);return(0,I.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function le({log:e}){return(0,L.jsx)(N,{$align:`right`,$mono:!0,...T(e)?{"aria-label":`processing`}:{title:S(e)},children:T(e)?(0,L.jsx)(C,{}):(0,L.jsx)(x,{tokens:e})})}var ue=n.dl`
|
|
23
|
-
display: grid;
|
|
24
|
-
grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
|
|
25
|
-
gap: 6px ${({theme:e})=>e.space(3)};
|
|
26
|
-
margin: 0;
|
|
27
|
-
font-size: 12.5px;
|
|
28
|
-
`,G=n.dd`
|
|
29
|
-
margin: 0;
|
|
30
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
31
|
-
word-break: break-all;
|
|
32
|
-
`;function K(){let{cadence:t,live:n}=p(),[a,o]=(0,I.useState)(100),[l,x]=(0,I.useState)(`all`),[S,C]=(0,I.useState)(``),[D,O]=(0,I.useState)(null),k=f(a,t(d)),K=ee(),q=te(),de=(k.data??[]).some(T),J=W(n&&de),Y=(0,I.useMemo)(()=>{let e=new Map;for(let t of K.data??[])e.set(t.id,t.label);return e},[K.data]),X=(0,I.useMemo)(()=>{let e=new Map;for(let t of q.data??[])e.set(t.id,t.label);return e},[q.data]),Z=S.trim().toLowerCase(),Q=(k.data??[]).filter(e=>l===`failed`&&!w(e)?!1:Z.length===0||e.requestedModel.toLowerCase().includes(Z)||(e.resolvedModel??``).toLowerCase().includes(Z)||(e.errorCode??``).toLowerCase().includes(Z)||(e.credentialId===null?``:Y.get(e.credentialId)??``).toLowerCase().includes(Z)||(e.apiKeyId===null?``:X.get(e.apiKeyId)??e.apiKeyId).toLowerCase().includes(Z)),fe=(k.data??[]).filter(w).length,$=(k.data??[]).filter(T).length;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(y,{legend:`Logs`,title:`Recent requests`,summary:k.isLoading?`Reading the request log…`:`${v(k.data?.length??0)} recent requests, ${v(fe)} of them failed${$===0?``:`, ${v($)} still running`}. Prompt and response bodies are never recorded.`,actions:(0,L.jsxs)(z,{children:[(0,L.jsx)(B,{value:S,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>C(e.target.value)}),(0,L.jsxs)(V,{value:l,"aria-label":`Show which requests`,onChange:e=>x(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`All requests`}),(0,L.jsx)(`option`,{value:`failed`,children:`Failed only`})]}),(0,L.jsx)(V,{value:a,"aria-label":`How many requests to fetch`,onChange:e=>o(Number(e.target.value)),children:R.map(e=>(0,L.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,L.jsx)(H,{legend:`Request log`,meta:`${Q.length} shown`,flush:!0,children:k.isError?(0,L.jsx)(ce,{error:k.error,onRetry:()=>void k.refetch()}):k.isLoading?(0,L.jsx)(`div`,{style:{padding:12},children:(0,L.jsx)(A,{rows:8})}):Q.length===0?(0,L.jsx)(j,{legend:`Nothing to show`,message:(k.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):(0,L.jsx)(U,{"data-testid":`request-log-scroller`,children:(0,L.jsxs)(F,{children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(P,{}),(0,L.jsx)(P,{$align:`right`,children:`Time`}),(0,L.jsx)(P,{children:`Requested`}),(0,L.jsx)(P,{children:`Routed to`}),(0,L.jsx)(P,{children:`Account`}),(0,L.jsx)(P,{children:`Key`}),(0,L.jsx)(P,{$align:`right`,children:`Try`}),(0,L.jsx)(P,{$align:`right`,children:`TTFT`}),(0,L.jsx)(P,{$align:`right`,children:`Total`}),(0,L.jsx)(P,{$align:`right`,children:`Tokens`}),(0,L.jsx)(P,{$align:`right`,children:`Cost`}),(0,L.jsx)(P,{children:`Outcome`})]})}),(0,L.jsx)(`tbody`,{children:Q.map(e=>(0,L.jsxs)(M,{$selectable:!0,onClick:()=>O(e),children:[(0,L.jsx)(N,{children:(0,L.jsx)(oe,{state:ae(e),label:ie(e)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,title:m(e.at),children:g(e.at)}),(0,L.jsx)(N,{$mono:!0,children:(0,L.jsx)(c,{style:{display:`block`,maxWidth:`20ch`},children:e.requestedModel||`—`})}),(0,L.jsx)(N,{children:e.resolvedProvider===null?(0,L.jsx)(u,{children:T(e)?`routing…`:`not routed`}):(0,L.jsxs)(s,{$gap:1,children:[(0,L.jsx)(se,{provider:e.resolvedProvider}),(0,L.jsx)(i,{$dim:!0,children:e.resolvedModel??`—`})]})}),(0,L.jsx)(N,{children:(0,L.jsx)(c,{style:{display:`block`,maxWidth:`18ch`},children:e.credentialId===null?`—`:Y.get(e.credentialId)??h(e.credentialId)})}),(0,L.jsx)(N,{children:(0,L.jsx)(c,{style:{display:`block`,maxWidth:`16ch`},title:e.apiKeyId??void 0,children:e.apiKeyId===null?`—`:X.get(e.apiKeyId)??h(e.apiKeyId)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?`—`:e.attempts}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?`—`:b(e.ttftMs)}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?ne(Math.max(0,J-e.at)):b(e.durationMs)}),(0,L.jsx)(le,{log:e}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?`—`:_(e.costUsd)}),(0,L.jsx)(N,{children:T(e)?(0,L.jsx)(E,{$tone:`accent`,children:`live`}):e.errorCode===null?(0,L.jsx)(E,{$tone:`ok`,children:e.status}):(0,L.jsx)(E,{$tone:`down`,children:e.errorCode})})]},e.id))})]})})}),(0,L.jsx)(re,{open:D!==null,onOpenChange:e=>{e||O(null)},title:`Request detail`,width:`600px`,footer:(0,L.jsx)(e,{type:`button`,onClick:()=>O(null),children:`Close`}),children:D===null?null:(0,L.jsxs)(r,{$gap:3,children:[(0,L.jsxs)(ue,{children:[(0,L.jsx)(u,{as:`dt`,children:`Request id`}),(0,L.jsx)(G,{children:D.id}),(0,L.jsx)(u,{as:`dt`,children:`At`}),(0,L.jsx)(G,{children:m(D.at)}),(0,L.jsx)(u,{as:`dt`,children:`Requested model`}),(0,L.jsx)(G,{children:D.requestedModel||`—`}),(0,L.jsx)(u,{as:`dt`,children:`Routed to`}),(0,L.jsx)(G,{children:T(D)?`—`:D.resolvedProvider===null?`not routed`:`${D.resolvedProvider} · ${D.resolvedModel??`—`}`}),(0,L.jsx)(u,{as:`dt`,children:`Account`}),(0,L.jsx)(G,{children:D.credentialId===null?`—`:Y.get(D.credentialId)??D.credentialId}),(0,L.jsx)(u,{as:`dt`,children:`Key`}),(0,L.jsx)(G,{children:D.apiKeyId===null?`—`:X.get(D.apiKeyId)??D.apiKeyId}),(0,L.jsx)(u,{as:`dt`,children:`Attempts`}),(0,L.jsx)(G,{children:T(D)?`—`:D.attempts}),(0,L.jsx)(u,{as:`dt`,children:`Status`}),(0,L.jsx)(G,{children:T(D)?`in flight`:D.errorCode===null?D.status:`${D.status} ${D.errorCode}`}),(0,L.jsx)(u,{as:`dt`,children:`Timing`}),(0,L.jsx)(G,{children:T(D)?`—`:`first token ${b(D.ttftMs)} · total ${b(D.durationMs)}`}),(0,L.jsx)(u,{as:`dt`,children:`Tokens`}),(0,L.jsx)(G,{children:T(D)?`—`:(0,L.jsxs)(L.Fragment,{children:[v(D.inputTokens),` in · `,v(D.outputTokens),` out ·`,` `,v(D.cacheReadTokens),` cache read ·`,` `,v(D.cacheWriteTokens),` cache write`]})}),(0,L.jsx)(u,{as:`dt`,children:`Cost`}),(0,L.jsx)(G,{children:T(D)?`—`:_(D.costUsd)}),(0,L.jsx)(u,{as:`dt`,children:`RTK compression`}),(0,L.jsx)(G,{children:T(D)?`—`:D.rtkApplied?`${v(D.rtkFilterHits)} hits · ${v(D.rtkOriginalCodeUnits)} → ${v(D.rtkCompressedCodeUnits)} code units · ~${v(D.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),(0,L.jsx)(u,{as:`dt`,children:`RTK filters`}),(0,L.jsx)(G,{children:D.rtkFilters.length===0?`—`:D.rtkFilters.join(`, `)})]}),D.degradations.length===0?null:(0,L.jsxs)(r,{$gap:1,children:[(0,L.jsx)(u,{children:`Capabilities dropped to fit the target`}),(0,L.jsx)(s,{$gap:1,$wrap:!0,children:D.degradations.map(e=>(0,L.jsx)(E,{$tone:`warn`,children:e},e))})]})]})})]})}var q=K;export{q as component};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,G as n,I as r,L as i,M as a,Mt as o,Nt as s,P as c,R as l,V as u,Zt as d,j as f,m as p,p as m,x as h,y as g}from"./queries-D2o-X8Pj.js";import{h as _,t as v}from"./Rack-D1WJswv3.js";import{n as y,t as b}from"./Confirm-B6aAiVbT.js";import{t as x}from"./trash-2-BcZb-sCT.js";import{t as S}from"./Toggle-CiLC67Dw.js";import{n as C,t as w}from"./Chip-BB_5C1Zp.js";import{i as T,n as E,r as D,t as O}from"./Field-uHZxl4fI.js";import{t as ee}from"./Meter-DI_BRUKt.js";import{a as k,i as A,n as te,r as j,t as M}from"./States-Bbiu5cHE.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=d(s(),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=n.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=n(a)`
|
|
9
|
-
width: 22px;
|
|
10
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
|
-
flex: none;
|
|
12
|
-
`,ce=n(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=n.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=n.div`
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: 3px;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
`,de=n.div`
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: baseline;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: 6px;
|
|
32
|
-
`,fe=n.li`
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
36
|
-
padding: 5px 0;
|
|
37
|
-
`,pe=n(c)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,R=n.label`
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
gap: 6px;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
font-size: 12.5px;
|
|
46
|
-
`,z=n.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,s]=(0,F.useState)({tools:!1,images:!1,reasoning:!1}),[u,d]=(0,F.useState)(null),[m,h]=(0,F.useState)(null),g=t(),_=p(),v=g.data?.weights,y=()=>{n!==null&&(h(null),_.mutate({modelId:n,need:o},{onSuccess:e=>d(e),onError:e=>{d(null),h(A(e))}}))},b=new Map(L.map(e=>[e,Math.max(1e-4,...(u?.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)(e,{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)(f,{children:`Pretend the request needs`}),(0,I.jsxs)(pe,{children:[(0,I.jsxs)(R,{children:[(0,I.jsx)(S,{checked:o.tools,label:`Probe request uses tools`,onCheckedChange:e=>s({...o,tools:e})}),`Tools`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(S,{checked:o.images,label:`Probe request includes an image`,onCheckedChange:e=>s({...o,images:e})}),`Images`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(S,{checked:o.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>s({...o,reasoning:e})}),`Reasoning`]})]})]}),m===null?null:(0,I.jsx)(z,{children:m}),u===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)(c,{$gap:2,$wrap:!0,children:[(0,I.jsx)(w,{$tone:`accent`,children:u.strategy}),u.deterministic?null:(0,I.jsx)(w,{$tone:`warn`,children:`order varies per request`}),(0,I.jsx)(r,{}),(0,I.jsxs)(f,{children:[u.candidates.length,` eligible · `,u.excluded.length,` filtered out`]})]}),u.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:u.candidates.map((e,t)=>(0,I.jsxs)(oe,{children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsx)(se,{children:t+1}),(0,I.jsx)(C,{provider:e.provider}),(0,I.jsx)(l,{style:{maxWidth:`22ch`},children:e.credentialLabel}),(0,I.jsx)(a,{$dim:!0,children:e.model}),(0,I.jsxs)(w,{children:[`tier `,e.tier]}),(0,I.jsx)(r,{}),t===0?(0,I.jsx)(ce,{children:`would be used`}):null,(0,I.jsx)(a,{children:e.score.toFixed(2)})]}),v===void 0?null:(0,I.jsx)(le,{children:L.map(t=>{let n=B(e.reasons,t,v),r=b.get(t)??1;return(0,I.jsxs)(ue,{title:ae[t],children:[(0,I.jsxs)(de,{children:[(0,I.jsx)(f,{children:t}),(0,I.jsx)(a,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),(0,I.jsx)(ee,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${t} contributes ${n.toFixed(2)} of ${e.score.toFixed(2)}`})]},t)})})]},`${e.credentialId}:${e.model}`))}),u.excluded.length===0?null:(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(f,{children:`Filtered out`}),(0,I.jsx)(`ul`,{children:u.excluded.map(e=>(0,I.jsxs)(fe,{children:[(0,I.jsx)(a,{$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=n.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=n.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=n.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=n.div`
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
gap: 4px;
|
|
78
|
-
min-width: 0;
|
|
79
|
-
`,xe=n(c)`
|
|
80
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
81
|
-
flex-wrap: wrap;
|
|
82
|
-
`,X=n.label`
|
|
83
|
-
display: flex;
|
|
84
|
-
align-items: center;
|
|
85
|
-
gap: 6px;
|
|
86
|
-
cursor: pointer;
|
|
87
|
-
`;function Se({target:t,index:n,onChange:a,onRemove:o,removable:s}){let l=(0,F.useId)(),d=N[t.provider],p=(e,n)=>{a({...t,[e]:n})},m=W(t.provider,t.model),h=he(t.provider,t.model),g=e=>{a(ge(t,e))};return(0,I.jsxs)(ye,{$provider:t.provider,children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsxs)(f,{as:`legend`,children:[`Target `,n+1]}),(0,I.jsx)(r,{}),(0,I.jsx)(u,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!s,"aria-label":`Remove target ${n+1}`,title:s?`Remove target ${n+1}`:`A model needs at least one target`,onClick:o,children:(0,I.jsx)(x,{})})]}),(0,I.jsxs)(be,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-provider`,children:`Provider`}),(0,I.jsx)(T,{id:`${l}-provider`,value:t.provider,onChange:e=>{let n=e.target.value,r=N[n].models.some(e=>e.id===t.model);g({provider:n,model:r?t.model:N[n].defaultModel})},children:ve.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-model`,children:`Provider model`}),(0,I.jsx)(E,{id:`${l}-model`,list:`${l}-catalog`,value:t.model,placeholder:d.defaultModel,onChange:e=>g({provider:t.provider,model:e.target.value})}),(0,I.jsx)(`datalist`,{id:`${l}-catalog`,children:d.models.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-tier`,children:`Tier`}),(0,I.jsx)(D,{id:`${l}-tier`,min:1,step:1,value:t.tier,onChange:e=>p(`tier`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-weight`,children:`Weight`}),(0,I.jsx)(D,{id:`${l}-weight`,min:0,step:.1,value:t.weight,onChange:e=>p(`weight`,e.target.value)})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsx)(f,{children:`Price per million tokens`}),(0,I.jsx)(r,{}),m===null?(0,I.jsx)(f,{as:`span`,children:`not in the catalog — price it yourself`}):(0,I.jsxs)(e,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:t.costInput===m.costInput&&t.costOutput===m.costOutput&&t.costCacheRead===m.costCacheRead&&t.costCacheWrite5m===m.costCacheWrite5m&&t.costCacheWrite1h===m.costCacheWrite1h,onClick:()=>a({...t,...m}),children:[(0,I.jsx)(ie,{}),`Use list price`]})]}),(0,I.jsxs)(J,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-in`,children:`Input`}),(0,I.jsx)(D,{id:`${l}-in`,min:0,step:.01,value:t.costInput,onChange:e=>p(`costInput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-out`,children:`Output`}),(0,I.jsx)(D,{id:`${l}-out`,min:0,step:.01,value:t.costOutput,onChange:e=>p(`costOutput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-cache`,children:`Cache read`}),(0,I.jsx)(D,{id:`${l}-cache`,min:0,step:.01,placeholder:`same as input`,value:t.costCacheRead,onChange:e=>p(`costCacheRead`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-write5m`,children:`Cache write 5m`}),(0,I.jsx)(D,{id:`${l}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:t.costCacheWrite5m,onChange:e=>p(`costCacheWrite5m`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-write1h`,children:`Cache write 1h`}),(0,I.jsx)(D,{id:`${l}-write1h`,min:0,step:.01,placeholder:`2x input`,value:t.costCacheWrite1h,onChange:e=>p(`costCacheWrite1h`,e.target.value)})]})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsx)(f,{children:`Token limits`}),(0,I.jsx)(r,{}),h===null?(0,I.jsx)(f,{as:`span`,children:`not in the catalog — state them yourself`}):(0,I.jsx)(f,{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)(f,{as:`label`,htmlFor:`${l}-context`,children:`Context window`}),(0,I.jsx)(D,{id:`${l}-context`,min:1,step:1024,placeholder:h?.contextWindow??`published`,value:t.contextWindow,onChange:e=>p(`contextWindow`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-maxout`,children:`Max output`}),(0,I.jsx)(D,{id:`${l}-maxout`,min:1,step:1024,placeholder:h?.maxOutputTokens??`published`,value:t.maxOutputTokens,onChange:e=>p(`maxOutputTokens`,e.target.value)})]})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(f,{children:`Capabilities`}),(0,I.jsxs)(xe,{children:[(0,I.jsxs)(X,{children:[(0,I.jsx)(S,{checked:t.tools,label:`Target ${n+1} supports tools`,onCheckedChange:e=>p(`tools`,e)}),`Tools`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(S,{checked:t.images,label:`Target ${n+1} supports images`,onCheckedChange:e=>p(`images`,e)}),`Images`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(S,{checked:t.reasoning,label:`Target ${n+1} supports reasoning`,onCheckedChange:e=>p(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Z=n.p`
|
|
88
|
-
font-size: 11.5px;
|
|
89
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
90
|
-
`,Ce=n.p`
|
|
91
|
-
font-size: 12px;
|
|
92
|
-
color: ${({theme:e})=>e.color.down};
|
|
93
|
-
`,we=n.p`
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
color: ${({theme:e})=>e.color.ok};
|
|
96
|
-
`,Te=n(c)`
|
|
97
|
-
gap: 8px;
|
|
98
|
-
`;function Ee({model:t,onSaved:n,onDeleted:a}){let[o,s]=(0,F.useState)(()=>t===null?K():q(t)),[l,u]=(0,F.useState)(null),[d,p]=(0,F.useState)(!1),[g,_]=(0,F.useState)(!1),v=h(),x=m(),C=t?.id??null;(0,F.useEffect)(()=>{s(t===null?K():q(t)),u(null),p(!1)},[C]);let w=V.find(e=>e.id===o.strategy);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(k,{legend:t===null?`New model`:`Edit model`,meta:t===null?void 0:t.id,actions:(0,I.jsxs)(I.Fragment,{children:[t===null?null:(0,I.jsx)(e,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>_(!0),children:`Delete`}),(0,I.jsx)(e,{type:`button`,$variant:`primary`,$size:`sm`,disabled:v.isPending,onClick:()=>{p(!1);let e=_e(o);if(!e.ok){u(e.problem);return}u(null),v.mutate(e.model,{onSuccess:()=>{p(!0),n(e.model.id)},onError:e=>u(A(e))})},children:v.isPending?`Saving…`:t===null?`Create model`:`Save changes`})]}),children:(0,I.jsxs)(i,{$gap:3,children:[(0,I.jsx)(O,{label:`Model name`,hint:t===null?`What clients send as the model. Anything not listed here is rejected.`:`Fixed once created. To rename, create a model under the new name and delete this one.`,children:e=>(0,I.jsx)(E,{...e,value:o.id,disabled:t!==null,placeholder:`fast`,onChange:e=>s({...o,id:e.target.value})})}),(0,I.jsx)(O,{label:`Routing strategy`,children:e=>(0,I.jsx)(T,{...e,value:o.strategy,onChange:e=>s({...o,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)(S,{checked:o.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>s({...o,isAlias:e})}),(0,I.jsxs)(i,{$gap:0,children:[(0,I.jsx)(f,{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)(c,{children:[(0,I.jsx)(f,{children:`Targets`}),(0,I.jsx)(r,{}),(0,I.jsxs)(e,{type:`button`,$size:`sm`,onClick:()=>s({...o,targets:[...o.targets,G(o.targets.at(-1)?.provider??`anthropic`)]}),children:[(0,I.jsx)(y,{}),`Add target`]})]}),o.targets.map((e,t)=>(0,I.jsx)(Se,{target:e,index:t,removable:o.targets.length>1,onChange:t=>s({...o,targets:o.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>s({...o,targets:o.targets.filter(t=>t.key!==e.key)})},e.key))]}),l===null?null:(0,I.jsx)(Ce,{role:`alert`,children:l}),d&&l===null?(0,I.jsx)(we,{role:`status`,children:`Saved.`}):null]})}),(0,I.jsx)(b,{open:g,onOpenChange:_,title:`Delete model`,body:t===null?``:`Deleting "${t.id}" makes it unroutable. Clients asking for it will get a model-unavailable error, and any key allowlisting it keeps a name that no longer resolves.`,confirmLabel:`Delete model`,busy:x.isPending,onConfirm:()=>{t!==null&&x.mutate(t.id,{onSuccess:()=>{_(!1),a()},onError:e=>{_(!1),u(A(e))}})}})]})}var De=n.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=n(i)`
|
|
108
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
109
|
-
min-width: 0;
|
|
110
|
-
`,Q=n.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=n(l)`
|
|
132
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
133
|
-
font-size: 12.5px;
|
|
134
|
-
display: block;
|
|
135
|
-
max-width: 100%;
|
|
136
|
-
`,Ae=n.div`
|
|
137
|
-
display: flex;
|
|
138
|
-
gap: 2px;
|
|
139
|
-
`,je=n.span`
|
|
140
|
-
width: 12px;
|
|
141
|
-
height: 3px;
|
|
142
|
-
border-radius: 1px;
|
|
143
|
-
background: ${({$provider:e})=>`var(--p-${e})`};
|
|
144
|
-
`,$=`\0new`;function Me(){let t=g(),[n,i]=(0,F.useState)(null),o=t.data??[],s=n===$?null:o.find(e=>e.id===n)??null,l=n===$||n===null&&!t.isLoading&&o.length===0;(0,F.useEffect)(()=>{n===null&&o.length!==0&&i(o[0]?.id??null)},[o,n]);let u=t.isLoading?`Reading configured models…`:o.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${o.length} model${o.length===1?``:`s`} routing to ${o.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)(e,{type:`button`,$variant:`primary`,onClick:()=>i($),children:[(0,I.jsx)(y,{}),`New model`]})}),(0,I.jsxs)(De,{children:[(0,I.jsx)(k,{legend:`Configured`,meta:`${o.length}`,flush:!0,children:t.isError?(0,I.jsx)(te,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?(0,I.jsx)(`div`,{style:{padding:12},children:(0,I.jsx)(j,{rows:4})}):o.length===0?(0,I.jsx)(M,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:(0,I.jsx)(e,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>i($),children:`New model`})}):(0,I.jsx)(`div`,{children:o.map(e=>{let t=[...new Set(e.targets.map(e=>e.provider))];return(0,I.jsxs)(Q,{type:`button`,$selected:e.id===n,"aria-pressed":e.id===n,onClick:()=>i(e.id),children:[(0,I.jsxs)(c,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(ke,{title:e.id,children:e.id}),(0,I.jsx)(r,{}),e.isAlias?(0,I.jsx)(w,{children:`alias`}):null]}),(0,I.jsxs)(c,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(Ae,{children:t.map(e=>(0,I.jsx)(je,{$provider:e,title:e},e))}),(0,I.jsx)(f,{children:e.strategy}),(0,I.jsx)(r,{}),(0,I.jsxs)(a,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),(0,I.jsxs)(Oe,{children:[s===null&&!l?(0,I.jsx)(k,{legend:`Editor`,children:t.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:s,onSaved:e=>{i(e),t.refetch()},onDeleted:()=>{i(null),t.refetch()}}),(0,I.jsx)(me,{modelId:s?.id??null})]})]})]})}var Ne=Me;export{Ne as component};
|