omnigateway 0.1.2 → 0.1.4
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 +140 -51
- package/gateway.js +289 -87
- package/package.json +1 -1
- package/public/assets/{Chip-D0YiqYkz.js → Chip-Ccqsb_Mq.js} +2 -2
- package/public/assets/{CopyValue-bzKz2tiJ.js → CopyValue-BhGx7Gy0.js} +5 -5
- package/public/assets/{Field-DdscQ9OO.js → Field-Devm4K46.js} +8 -8
- package/public/assets/Lamp-BXSUIAtG.js +25 -0
- package/public/assets/{Meter-Bm1oQE2U.js → Meter-Fn8X7t60.js} +2 -2
- package/public/assets/{Modal-Crr8uyWt.js → Modal-DOQGdhoM.js} +8 -8
- package/public/assets/{Rack-uDxrjvaz.js → Rack-DnbGnBvz.js} +18 -18
- package/public/assets/{Readout-CYg6UOop.js → Readout-BKpOZIGX.js} +5 -5
- package/public/assets/{States-DPTTYUHL.js → States-DBzsiHjQ.js} +10 -10
- package/public/assets/{Table-LkPaHBsj.js → Table-DPDJeeVc.js} +1 -1
- package/public/assets/{Toggle-D0e4C94X.js → Toggle-CP3RvAAB.js} +3 -3
- package/public/assets/_app-D83powx4.js +1 -0
- package/public/assets/_app.accounts-DR-2t9-7.js +51 -0
- package/public/assets/_app.index-DimCB0Bo.js +61 -0
- package/public/assets/{_app.keys-BNEOjtbu.js → _app.keys-B7kl3CSe.js} +8 -8
- package/public/assets/_app.logs-BjtdzcDY.js +18 -0
- package/public/assets/_app.models-BEECjcLM.js +144 -0
- package/public/assets/{_app.settings-C1gB4w7c.js → _app.settings-DtDIhAAr.js} +6 -6
- package/public/assets/{_app.usage-B0iHKzmI.js → _app.usage-BChnSBbS.js} +28 -28
- package/public/assets/index-C53PiRfb.js +170 -0
- package/public/assets/{login-D-FsWNX8.js → login-BuvJY1Qd.js} +8 -8
- package/public/assets/{queries-vY5lJqBe.js → queries-BMwc6EvM.js} +1 -1
- package/public/assets/{trash-2-Cep_aVLx.js → trash-2-Cq7ldH9D.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/Lamp-WOotyOTd.js +0 -15
- package/public/assets/_app-OSvB-Dv9.js +0 -1
- package/public/assets/_app.accounts-BOE49WyS.js +0 -51
- package/public/assets/_app.index-CTRlqxOq.js +0 -61
- package/public/assets/_app.logs-BxxqeEhM.js +0 -18
- package/public/assets/_app.models-BJi-RGUO.js +0 -144
- package/public/assets/index--dA3FFSN.js +0 -170
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e,F as t,G as n,I as r,N as i,O as a,Ot as o,S as s,V as c,kt as l,p as u,qt as d,x as f}from"./queries-BMwc6EvM.js";import{a as p}from"./index-C53PiRfb.js";import{t as m}from"./Lamp-BXSUIAtG.js";import{n as h,t as g}from"./Field-Devm4K46.js";import{i as _,o as v}from"./States-DBzsiHjQ.js";var y=d(l()),b=o(),x=c.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
5
5
|
min-height: 100vh;
|
|
6
6
|
padding: ${({theme:e})=>e.space(4)};
|
|
7
|
-
`,S=
|
|
7
|
+
`,S=c(v)`
|
|
8
8
|
width: min(380px, 100%);
|
|
9
|
-
`,C=
|
|
9
|
+
`,C=c.div`
|
|
10
10
|
display: flex;
|
|
11
11
|
align-items: center;
|
|
12
12
|
gap: 8px;
|
|
13
13
|
padding: ${({theme:e})=>`${e.space(3)} ${e.space(4)}`};
|
|
14
14
|
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
15
15
|
background: ${({theme:e})=>e.color.panelSunk};
|
|
16
|
-
${
|
|
16
|
+
${t}
|
|
17
17
|
font-stretch: 74%;
|
|
18
18
|
font-weight: 700;
|
|
19
19
|
letter-spacing: 0.2em;
|
|
20
20
|
font-size: 12px;
|
|
21
21
|
text-transform: uppercase;
|
|
22
|
-
`,w=
|
|
22
|
+
`,w=c.form`
|
|
23
23
|
display: flex;
|
|
24
24
|
flex-direction: column;
|
|
25
25
|
gap: ${({theme:e})=>e.space(3)};
|
|
26
26
|
padding: ${({theme:e})=>e.space(4)};
|
|
27
|
-
`,T=
|
|
27
|
+
`,T=c.p`
|
|
28
28
|
font-size: 12.5px;
|
|
29
29
|
color: ${({theme:e})=>e.color.inkDim};
|
|
30
|
-
`,E=
|
|
30
|
+
`,E=c.p`
|
|
31
31
|
font-size: 12px;
|
|
32
32
|
color: ${({theme:e})=>e.color.down};
|
|
33
|
-
`;function D(){let
|
|
33
|
+
`;function D(){let t=n(),{next:o}=p.useSearch(),c=s(),l=u(),d=f(),[v,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(null),M=c.data?.configured===!1,N=l.isPending||d.isPending||c.isLoading,P=()=>{t({to:o?.startsWith(`/`)===!0?o:`/`})};return(0,b.jsx)(x,{children:(0,b.jsxs)(S,{children:[(0,b.jsxs)(C,{children:[(0,b.jsx)(m,{state:c.isError?`down`:`ok`,label:c.isError?`gateway unreachable`:`gateway reachable`}),`Omnigateway`]}),(0,b.jsxs)(w,{onSubmit:e=>{if(e.preventDefault(),j(null),M){if(v!==O){j(`The two passwords do not match.`);return}d.mutate(v,{onSuccess:P,onError:e=>j(_(e))});return}l.mutate(v,{onSuccess:P,onError:()=>j(`That password does not match. Try again.`)})},children:[c.isError?(0,b.jsx)(E,{children:`The gateway is not answering. Check that it is running, then reload.`}):null,(0,b.jsxs)(i,{$gap:1,children:[(0,b.jsx)(a,{children:M?`First run`:`Sign in`}),(0,b.jsx)(T,{children:M?`Set the operator password for this gateway. It is the only account, and it is stored hashed.`:`This console is for the operator of this gateway.`})]}),(0,b.jsx)(g,{label:`Password`,children:e=>(0,b.jsx)(h,{...e,type:`password`,autoFocus:!0,autoComplete:M?`new-password`:`current-password`,value:v,onChange:e=>D(e.target.value)})}),M?(0,b.jsx)(g,{label:`Confirm password`,children:e=>(0,b.jsx)(h,{...e,type:`password`,autoComplete:`new-password`,value:O,onChange:e=>k(e.target.value)})}):null,A===null?null:(0,b.jsx)(E,{role:`alert`,children:A}),(0,b.jsx)(e,{children:(0,b.jsx)(r,{type:`submit`,$variant:`primary`,disabled:N||v.length===0,children:M?`Set password and sign in`:`Sign in`})})]})]})})}export{D as component};
|
|
@@ -141,4 +141,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=
|
|
|
141
141
|
var(--grid-line) 0 1px,
|
|
142
142
|
transparent 1px 4px
|
|
143
143
|
);
|
|
144
|
-
`,$a=class extends Error{status;code;constructor(e,t,n){super(n),this.name=`ApiError`,this.status=e,this.code=t}get isUnauthenticated(){return this.status===401||this.code===`AUTH`}};function eo(e){if(typeof e!=`object`||!e)return!1;let t=e.error;return typeof t!=`object`||!t?!1:typeof t.message==`string`}async function to(e,t={}){let n={method:t.method??`GET`,credentials:`same-origin`,headers:t.body===void 0?{}:{"content-type":`application/json`},...t.body===void 0?{}:{body:JSON.stringify(t.body)},...t.signal===void 0?{}:{signal:t.signal}},r=await fetch(e,n),i=t.accept??[],a=null;if(r.status!==204){let e=await r.text();if(e.length>0)try{a=JSON.parse(e)}catch{a=null}}if(!r.ok&&!i.includes(r.status)){let e=eo(a)?a.error.code??`INTERNAL`:`INTERNAL`,t=eo(a)?a.error.message:`request failed with status ${r.status}`;throw new $a(r.status,String(e),t)}return{status:r.status,data:a}}async function Q(e,t){return(await to(e,t===void 0?{}:{signal:t})).data}async function no(e,t){return(await to(e,{method:`POST`,...t===void 0?{}:{body:t}})).data}async function ro(e,t){return(await to(e,{method:`PUT`,body:t})).data}async function io(e,t){return(await to(e,{method:`PATCH`,body:t})).data}async function ao(e){return(await to(e,{method:`DELETE`})).data}function oo(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r!==void 0&&n.set(e,String(r));let r=n.toString();return r.length===0?e:`${e}?${r}`}var $={status:[`status`],credentials:[`credentials`],credentialHealth:[`credentials`,`health`],models:[`models`],keys:[`keys`],settings:[`settings`],usage:e=>[`usage`,e.grain??`raw`,e.groupBy,e.splitBy??null,e.since,e.until??null],logs:e=>[`logs`,e]};function so(){return P({queryKey:$.status,queryFn:({signal:e})=>Q(`/api/status`,e),staleTime:3e4})}function co(){return P({queryKey:$.credentials,queryFn:async({signal:e})=>(await Q(`/api/credentials`,e)).credentials})}function lo(e=1e4){return P({queryKey:$.credentialHealth,queryFn:({signal:e})=>Q(`/api/credentials/health`,e),refetchInterval:e})}function uo(){return P({queryKey:$.models,queryFn:async({signal:e})=>(await Q(`/api/models`,e)).models})}function fo(){return P({queryKey:$.keys,queryFn:async({signal:e})=>(await Q(`/api/keys`,e)).keys})}function po(){return P({queryKey:$.settings,queryFn:async({signal:e})=>(await Q(`/api/settings`,e)).settings})}function mo(e,t=6e4){return P({queryKey:$.usage(e),queryFn:async({signal:t})=>(await Q(oo(`/api/usage`,{groupBy:e.groupBy,since:e.since,...e.grain===void 0?{}:{grain:e.grain},...e.splitBy===void 0?{}:{splitBy:e.splitBy},...e.until===void 0?{}:{until:e.until}}),t)).rows,refetchInterval:t})}function
|
|
144
|
+
`,$a=class extends Error{status;code;constructor(e,t,n){super(n),this.name=`ApiError`,this.status=e,this.code=t}get isUnauthenticated(){return this.status===401||this.code===`AUTH`}};function eo(e){if(typeof e!=`object`||!e)return!1;let t=e.error;return typeof t!=`object`||!t?!1:typeof t.message==`string`}async function to(e,t={}){let n={method:t.method??`GET`,credentials:`same-origin`,headers:t.body===void 0?{}:{"content-type":`application/json`},...t.body===void 0?{}:{body:JSON.stringify(t.body)},...t.signal===void 0?{}:{signal:t.signal}},r=await fetch(e,n),i=t.accept??[],a=null;if(r.status!==204){let e=await r.text();if(e.length>0)try{a=JSON.parse(e)}catch{a=null}}if(!r.ok&&!i.includes(r.status)){let e=eo(a)?a.error.code??`INTERNAL`:`INTERNAL`,t=eo(a)?a.error.message:`request failed with status ${r.status}`;throw new $a(r.status,String(e),t)}return{status:r.status,data:a}}async function Q(e,t){return(await to(e,t===void 0?{}:{signal:t})).data}async function no(e,t){return(await to(e,{method:`POST`,...t===void 0?{}:{body:t}})).data}async function ro(e,t){return(await to(e,{method:`PUT`,body:t})).data}async function io(e,t){return(await to(e,{method:`PATCH`,body:t})).data}async function ao(e){return(await to(e,{method:`DELETE`})).data}function oo(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r!==void 0&&n.set(e,String(r));let r=n.toString();return r.length===0?e:`${e}?${r}`}var $={status:[`status`],credentials:[`credentials`],credentialHealth:[`credentials`,`health`],models:[`models`],keys:[`keys`],settings:[`settings`],usage:e=>[`usage`,e.grain??`raw`,e.groupBy,e.splitBy??null,e.since,e.until??null],logs:e=>[`logs`,e]};function so(){return P({queryKey:$.status,queryFn:({signal:e})=>Q(`/api/status`,e),staleTime:3e4})}function co(){return P({queryKey:$.credentials,queryFn:async({signal:e})=>(await Q(`/api/credentials`,e)).credentials})}function lo(e=1e4){return P({queryKey:$.credentialHealth,queryFn:({signal:e})=>Q(`/api/credentials/health`,e),refetchInterval:e})}function uo(){return P({queryKey:$.models,queryFn:async({signal:e})=>(await Q(`/api/models`,e)).models})}function fo(){return P({queryKey:$.keys,queryFn:async({signal:e})=>(await Q(`/api/keys`,e)).keys})}function po(){return P({queryKey:$.settings,queryFn:async({signal:e})=>(await Q(`/api/settings`,e)).settings})}function mo(e,t=6e4){return P({queryKey:$.usage(e),queryFn:async({signal:t})=>(await Q(oo(`/api/usage`,{groupBy:e.groupBy,since:e.since,...e.grain===void 0?{}:{grain:e.grain},...e.splitBy===void 0?{}:{splitBy:e.splitBy},...e.until===void 0?{}:{until:e.until}}),t)).rows,refetchInterval:t})}var ho=2e3;function go(e=100,t=ho){return P({queryKey:$.logs(e),queryFn:async({signal:t})=>(await Q(oo(`/api/logs`,{limit:e}),t)).logs,refetchInterval:t})}function _o(){let e=N();return F({mutationFn:e=>no(`/api/login`,{password:e}),onSuccess:()=>e.invalidateQueries()})}function vo(){let e=N();return F({mutationFn:e=>no(`/api/setup`,{password:e}),onSuccess:()=>e.invalidateQueries()})}function yo(){let e=N();return F({mutationFn:()=>no(`/api/logout`),onSuccess:()=>{e.clear()}})}function bo(){let e=N();return F({mutationFn:({id:e,patch:t})=>io(`/api/credentials/${e}`,t),onSuccess:()=>{e.invalidateQueries({queryKey:$.credentials}),e.invalidateQueries({queryKey:$.credentialHealth})}})}function xo(){let e=N();return F({mutationFn:e=>ao(`/api/credentials/${e}`),onSuccess:()=>{e.invalidateQueries({queryKey:$.credentials}),e.invalidateQueries({queryKey:$.credentialHealth})}})}function So(){let e=N();return F({mutationFn:e=>ro(`/api/models/${e.id}`,e),onSuccess:()=>e.invalidateQueries({queryKey:$.models})})}function Co(){let e=N();return F({mutationFn:e=>ao(`/api/models/${e}`),onSuccess:()=>e.invalidateQueries({queryKey:$.models})})}function wo(){return F({mutationFn:({modelId:e,need:t})=>no(`/api/models/${e}/dry-run`,t)})}function To(){let e=N();return F({mutationFn:e=>no(`/api/keys`,e),onSuccess:()=>e.invalidateQueries({queryKey:$.keys})})}function Eo(){let e=N();return F({mutationFn:e=>ao(`/api/keys/${e}`),onSuccess:()=>e.invalidateQueries({queryKey:$.keys})})}function Do(){let e=N();return F({mutationFn:e=>ro(`/api/settings`,e),onSuccess:()=>e.invalidateQueries({queryKey:$.settings})})}function Oo(){return F({mutationFn:e=>no(`/api/connect/start`,e)})}function ko(){let e=N();return F({mutationFn:e=>no(`/api/connect/finish`,e),onSuccess:()=>e.invalidateQueries({queryKey:$.credentials})})}async function Ao(e){let t=await to(`/api/connect/poll`,{method:`POST`,body:{flowId:e},accept:[202]});return t.status===202?{status:`pending`}:t.data}export{dn as $,Ka as A,Pe as At,X as B,E as Bt,bo as C,mt as Ct,Ja as D,Ue as Dt,Q as E,it as Et,Qa as F,T as Ft,En as G,o as Gt,Ta as H,ue as Ht,Ha as I,w as It,vn as J,Tn as K,s as Kt,Ua as L,C as Lt,Ya as M,he as Mt,qa as N,A as Nt,Wa as O,Be as Ot,Za as P,_ as Pt,ln as Q,za as R,S as Rt,so as S,st as St,$a as T,rt as Tt,Vn as U,d as Ut,Z as V,b as Vt,On as W,u as Wt,mn as X,_n as Y,tn as Z,Eo as _,Ot as _t,Oo as a,qt as at,po as b,Et as bt,co as c,Vt as ct,wo as d,jt as dt,en as et,fo as f,At as ft,uo as g,bt as gt,go as h,Dt as ht,ko as i,rn as it,Xa as j,we as jt,Ga as k,Re as kt,xo as l,zt as lt,yo as m,kt as mt,Ao as n,an as nt,To as o,Bt as ot,_o as p,Tt as pt,Sn as q,l as qt,$ as r,nn as rt,lo as s,Ht as st,ho as t,cn as tt,Co as u,Wt as ut,So as v,lt as vt,mo as w,ht as wt,vo as x,xt,Do as y,ft as yt,Ia as z,g as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as e}from"./Rack-
|
|
1
|
+
import{m as e}from"./Rack-DnbGnBvz.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</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-C53PiRfb.js"></script>
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/queries-BMwc6EvM.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-Co2s5xMk.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{B as e,Dt as t,z as n}from"./queries-vY5lJqBe.js";function r(e,t){if(e.length===0)return null;let n=[...e].sort((e,t)=>e-t);return n[Math.min(n.length-1,Math.max(0,Math.ceil(t*n.length)-1))]??null}function i(e){return e.status>=400||e.errorCode!==null}function a(e,t){let n=[],a=0,o=0,s=0,c=0,l=0;for(let t of e)i(t)&&(a+=1),t.ttftMs!==null&&Number.isFinite(t.ttftMs)&&n.push(t.ttftMs),o+=t.costUsd,s+=t.inputTokens,c+=t.outputTokens,l+=t.cacheReadTokens;let u=t/6e4;return{requests:e.length,errors:a,errorRate:e.length===0?0:a/e.length,ratePerMin:u<=0?0:e.length/u,ttftP50:r(n,.5),ttftP95:r(n,.95),costUsd:o,inputTokens:s,outputTokens:c,cacheReadTokens:l}}function o(e,t){let{now:n,spanMs:a,count:o}=t,s=a/o,c=n-a,l=Array.from({length:o},(e,t)=>({at:c+t*s,total:0,errors:0,costUsd:0,ttftMs:null})),u=Array.from({length:o},()=>[]);for(let t of e){if(t.at<c||t.at>n)continue;let e=Math.min(o-1,Math.floor((t.at-c)/s)),r=l[e];r!==void 0&&(r.total+=1,r.costUsd+=t.costUsd,i(t)&&(r.errors+=1),t.ttftMs!==null&&Number.isFinite(t.ttftMs)&&u[e]?.push(t.ttftMs))}for(let[e,t]of l.entries())t.ttftMs=r(u[e]??[],.5);return l}var s={ok:`●`,warn:`◐`,down:`○`,idle:`·`},c={tokenRejected:`reconnect needed — provider rejected the refresh token`,expiredNoRefresh:`reconnect needed — token expired with nothing to refresh from`};function l(e,t,n,r=null){if(!n){let e=r===`tokenRejected`||r===`expiredNoRefresh`;return{state:e?`down`:`idle`,note:e?c[r]:`disabled`,ttftMs:null,lastUsedAt:null,consecutiveFailures:0}}if(e.length===0)return{state:`idle`,note:`unused`,ttftMs:null,lastUsedAt:null,consecutiveFailures:0};let i=`ok`,a=``,o=null,s=null,l=0;for(let n of e){if(n.ewmaTtftMs!==null&&(o=o===null?n.ewmaTtftMs:Math.max(o,n.ewmaTtftMs)),n.lastUsedAt!==null&&(s=s===null?n.lastUsedAt:Math.max(s,n.lastUsedAt)),l=Math.max(l,n.consecutiveFailures),n.breakerState===`open`){i=`down`,a=`breaker open`;continue}if(n.rateLimitedUntil!==null&&n.rateLimitedUntil>t&&i!==`down`){i=`warn`,a=`rate limited`;continue}n.breakerState===`halfOpen`&&i===`ok`&&(i=`warn`,a=`probing`)}return{state:i,note:a,ttftMs:o,lastUsedAt:s,consecutiveFailures:l}}var u={fiveHour:`5h`,daily:`24h`,weekly:`7d`};function d(e){return Math.max(e,6e4)*3}function f(e,t,n){return e.observedAt<=0||t-e.observedAt>d(n)}function p(e,t,n,r){let i=u[e.windowType];return e.observedAt<=0?`${i} · never observed`:f(e,t,n)?`${i} · stale, read ${r(e.observedAt,t)}`:e.resetsAt===null?i:`${i} · resets ${r(e.resetsAt,t)}`}var m={fiveHour:0,daily:1,weekly:2};function h(e){return e.filter(e=>e.limit!==null&&e.limit>0).map(e=>({window:e,fraction:Math.min(1,e.used/e.limit)})).sort((e,t)=>m[e.window.windowType]-m[t.window.windowType])}function g(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i===void 0?n.set(e,[r]):i.push(r)}return n}var _=t(),v={ok:n`
|
|
2
|
-
color: ${({theme:e})=>e.color.ok};
|
|
3
|
-
`,warn:n`
|
|
4
|
-
color: ${({theme:e})=>e.color.warn};
|
|
5
|
-
`,down:n`
|
|
6
|
-
color: ${({theme:e})=>e.color.down};
|
|
7
|
-
`,idle:n`
|
|
8
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
9
|
-
`},y=e.span`
|
|
10
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
11
|
-
font-size: 12px;
|
|
12
|
-
line-height: 1;
|
|
13
|
-
flex: none;
|
|
14
|
-
${({$state:e})=>v[e]}
|
|
15
|
-
`;function b({state:e,label:t,className:n}){return(0,_.jsx)(y,{$state:e,className:n,role:`img`,"aria-label":t,title:t,children:s[e]})}export{g as a,h as c,l as i,a as l,u as n,i as o,o as r,p as s,b as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Dt as e}from"./queries-vY5lJqBe.js";import{o as t}from"./index--dA3FFSN.js";import{i as n,n as r}from"./Rack-uDxrjvaz.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,B as t,D as n,Dt as r,F as i,I as a,Kt as o,M as s,Ot as c,S as l,c as u,i as d,k as f,o as p,r as m,s as h,t as g,y as _}from"./queries-vY5lJqBe.js";import{a as v,d as y,l as b,m as x,t as S}from"./Rack-uDxrjvaz.js";import{t as C}from"./CopyValue-bzKz2tiJ.js";import{n as w,r as T,t as ee}from"./Toggle-D0e4C94X.js";import{t as E}from"./trash-2-Cep_aVLx.js";import{t as D}from"./Modal-Crr8uyWt.js";import{a as O,c as te,i as ne,n as re,s as k,t as A}from"./Lamp-WOotyOTd.js";import{t as j}from"./Chip-D0YiqYkz.js";import{i as M,n as N,r as P,t as F}from"./Field-DdscQ9OO.js";import{t as ie}from"./Meter-Bm1oQE2U.js";import{a as I,i as L,n as R,r as z,t as B}from"./States-DPTTYUHL.js";import{i as V,n as H,r as U,t as W}from"./Table-LkPaHBsj.js";import{t as G}from"./catalog-DVRPlBJJ.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=o(c(),1),J=r(),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=t.ol`
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
5
|
-
`,se=t.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=t.p`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.down};
|
|
17
|
-
`,le=t.p`
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
20
|
-
`;function ue({open:e,onOpenChange:t,onConnected:r}){let[a,o]=(0,q.useState)(`anthropic`),[c,l]=(0,q.useState)(``),[u,p]=(0,q.useState)(null),[h,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(null),b=d(),x=m(),S=(0,q.useCallback)(()=>{p(null),_(``),y(null),l(``),b.reset(),x.reset()},[b,x]),w=(0,q.useCallback)(e=>{e||S(),t(e)},[t,S]);return(0,q.useEffect)(()=>{if(u===null||u.kind!==`device`)return;let e=!1,n=async()=>{try{let n=await g(u.flowId);if(e)return;if(n.status===`complete`){S(),t(!1),r();return}}catch(t){if(e)return;y(L(t)),p(null);return}e||(i=setTimeout(()=>void n(),u.pollIntervalMs))},i=setTimeout(()=>void n(),u.pollIntervalMs);return()=>{e=!0,clearTimeout(i)}},[u,r,t,S]),(0,J.jsx)(D,{open:e,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)(i,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(i,{type:`button`,$variant:`primary`,disabled:b.isPending,onClick:()=>{y(null),b.mutate({provider:a,label:c.trim().length===0?Y[a]:c.trim()},{onSuccess:e=>p(e),onError:e=>y(L(e))})},children:b.isPending?`Starting…`:`Start authorization`})]}):u.kind===`device`?(0,J.jsx)(i,{type:`button`,onClick:()=>w(!1),children:`Cancel`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(i,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(i,{type:`button`,$variant:`primary`,disabled:x.isPending||h.trim().length===0,onClick:()=>{u!==null&&(y(null),x.mutate({flowId:u.flowId,code:h.trim()},{onSuccess:()=>{S(),t(!1),r()},onError:e=>y(L(e))}))},children:x.isPending?`Finishing…`:`Finish connecting`})]}),children:(0,J.jsxs)(oe,{children:[u===null?(0,J.jsxs)(s,{$gap:3,children:[(0,J.jsx)(F,{label:`Provider`,children:e=>(0,J.jsx)(M,{...e,value:a,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:c,placeholder:Y[a],onChange:e=>l(e.target.value)})})]}):(0,J.jsxs)(s,{$gap:3,children:[(0,J.jsxs)(s,{$gap:1,children:[(0,J.jsx)(n,{children:`Step 1 — authorize`}),(0,J.jsx)(f,{$gap:2,children:(0,J.jsxs)(i,{as:`a`,href:u.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[(0,J.jsx)(K,{}),`Open `,Y[a]]})}),(0,J.jsx)(C,{value:u.authorizeUrl,label:`Copy authorization link`})]}),u.userCode===null?null:(0,J.jsxs)(s,{$gap:1,children:[(0,J.jsx)(n,{children:`Step 2 — enter this code`}),(0,J.jsx)(se,{children:u.userCode})]}),u.kind===`device`?(0,J.jsxs)(le,{children:[X[a],` Waiting for authorization…`]}):(0,J.jsx)(F,{label:`Authorization code`,hint:X[a],...v===null?{}:{problem:v},children:e=>(0,J.jsx)(N,{...e,value:h,autoFocus:!0,placeholder:a===`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=t(I)`
|
|
21
|
-
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
22
|
-
`,pe=t(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=t(P)`
|
|
37
|
-
width: 62px;
|
|
38
|
-
height: 26px;
|
|
39
|
-
`,me=t.span`
|
|
40
|
-
display: block;
|
|
41
|
-
padding-left: 9px;
|
|
42
|
-
font-size: 11px;
|
|
43
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
44
|
-
`,he=t(f)`
|
|
45
|
-
min-width: 130px;
|
|
46
|
-
gap: 6px;
|
|
47
|
-
`,ge=t.div`
|
|
48
|
-
display: flex;
|
|
49
|
-
flex-direction: column;
|
|
50
|
-
gap: 4px;
|
|
51
|
-
`;function $(){let e=l();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function _e(){let{cadence:t}=v(),r=h(),o=p(t(1e4)),c=_(),l=u(),{commit:d}=$(),[m,g]=(0,q.useState)(!1),[x,C]=(0,q.useState)(null),D=Date.now(),M=r.data??[],N=O(o.data?.health??[],e=>e.credentialId),P=O(o.data?.quota??[],e=>e.credentialId),F=c.data?.quotaPollIntervalMs??3e5,L=M.filter(e=>e.enabled).length,G=r.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)(i,{type:`button`,$variant:`primary`,onClick:()=>g(!0),children:[(0,J.jsx)(T,{}),`Connect an account`]})}),r.isError?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(R,{error:r.error,onRetry:()=>void r.refetch()})}):r.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)(i,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>g(!0),children:`Connect an account`})})}):(0,J.jsx)(s,{$gap:4,children:de.filter(e=>M.some(t=>t.provider===e)).map(t=>{let r=M.filter(e=>e.provider===t);return(0,J.jsx)(fe,{$provider:t,legend:Z[t],meta:`${r.length} account${r.length===1?``:`s`}`,flush:!0,children:(0,J.jsx)(e,{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:r.map(e=>{let t=ne(N.get(e.id)??[],D,e.enabled,e.disabledReason),r=te(P.get(e.id)??[]);return(0,J.jsxs)(V,{children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(f,{$gap:2,children:[(0,J.jsx)(A,{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}d(e.id,{label:n})}})]}),t.note===``?null:(0,J.jsx)(me,{children:t.note})]}),(0,J.jsx)(H,{children:(0,J.jsxs)(f,{$gap:1,children:[(0,J.jsx)(j,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:(0,J.jsx)(n,{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}d(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}d(e.id,{weight:n})}})}),(0,J.jsx)(H,{$align:`center`,children:(0,J.jsx)(ee,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>d(e.id,{enabled:t})})}),(0,J.jsx)(H,{children:r.length===0?(0,J.jsx)(n,{children:`unknown`}):(0,J.jsx)(ge,{children:r.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)(n,{children:k(e,D,F,y)})]},e.windowType))})}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:b(t.ttftMs)}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:y(e.expiresAt,D)}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(a,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>C(e),children:(0,J.jsx)(E,{})})})]},e.id)})})]})})},t)})}),(0,J.jsx)(ue,{open:m,onOpenChange:g,onConnected:()=>void r.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:l.isPending,onConfirm:()=>{x!==null&&l.mutate(x.id,{onSettled:()=>C(null)})}})]})}var ve=_e;export{ve as component};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import{A as e,B as t,C as n,D as r,Dt as i,E as a,F as o,H as s,M as c,N as l,O as u,h as d,j as f,k as p,m,o as h,s as g,y as _}from"./queries-vY5lJqBe.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 T,u as E}from"./Rack-uDxrjvaz.js";import{a as D,c as O,i as k,l as ee,n as A,o as j,r as M,s as N,t as P}from"./Lamp-WOotyOTd.js";import{n as F,t as I}from"./Chip-D0YiqYkz.js";import{t as L}from"./Meter-Bm1oQE2U.js";import{a as R,n as z,t as B}from"./States-DPTTYUHL.js";import{i as V,n as H,r as U,t as W}from"./Table-LkPaHBsj.js";import{t as G}from"./Readout-CYg6UOop.js";var K=i(),q=t(l)`
|
|
2
|
-
font-weight: 500;
|
|
3
|
-
display: block;
|
|
4
|
-
max-width: 24ch;
|
|
5
|
-
`,J=t.span`
|
|
6
|
-
font-size: 11px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
`,Y=t.div`
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
gap: 6px;
|
|
12
|
-
width: 118px;
|
|
13
|
-
`,te=t.div`
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-direction: column;
|
|
16
|
-
gap: 4px;
|
|
17
|
-
`;function X({credentials:t,health:n,quota:i,usage:a,quotaPollIntervalMs:c,now:l}){let u=D(n,e=>e.credentialId),d=D(i,e=>e.credentialId),f=new Map(a.map(e=>[e.key,e])),m={down:0,warn:1,ok:2,idle:3},h=t.map(e=>({credential:e,status:k(u.get(e.id)??[],l,e.enabled,e.disabledReason),quota:O(d.get(e.id)??[]),usage:f.get(e.id)})).sort((e,t)=>m[e.status.state]-m[t.status.state]||e.credential.tier-t.credential.tier);return(0,K.jsx)(R,{legend:`Accounts`,meta:`${t.length} connected`,flush:!0,actions:(0,K.jsx)(o,{as:s,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:t.length===0?(0,K.jsx)(B,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:(0,K.jsx)(o,{as:s,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):(0,K.jsx)(e,{children:(0,K.jsxs)(W,{children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(U,{children:`Account`}),(0,K.jsx)(U,{children:`Provider`}),(0,K.jsx)(U,{$align:`right`,children:`Tier`}),(0,K.jsx)(U,{children:`Quota`}),(0,K.jsx)(U,{$align:`right`,children:`TTFT`}),(0,K.jsx)(U,{$align:`right`,children:`Requests`}),(0,K.jsx)(U,{$align:`right`,children:`Last used`})]})}),(0,K.jsx)(`tbody`,{children:h.map(({credential:e,status:t,quota:n,usage:i})=>(0,K.jsxs)(V,{children:[(0,K.jsx)(H,{children:(0,K.jsxs)(p,{$gap:2,children:[(0,K.jsx)(P,{state:t.state,label:t.note===``?`healthy`:t.note}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(q,{children:e.label}),t.note===``?null:(0,K.jsx)(J,{children:t.note})]})]})}),(0,K.jsx)(H,{children:(0,K.jsx)(F,{provider:e.provider})}),(0,K.jsx)(H,{$align:`right`,$mono:!0,children:e.tier}),(0,K.jsx)(H,{children:n.length===0?(0,K.jsx)(J,{children:`unknown`}):(0,K.jsx)(te,{children:n.map(({window:e,fraction:t})=>(0,K.jsxs)(Y,{children:[(0,K.jsx)(L,{fraction:t,label:`${A[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,K.jsx)(r,{children:N(e,l,c,y)})]},e.windowType))})}),(0,K.jsx)(H,{$align:`right`,$mono:!0,children:x(t.ttftMs)}),(0,K.jsx)(H,{$align:`right`,$mono:!0,children:i===void 0?`—`:w(i.requests)}),(0,K.jsx)(H,{$align:`right`,$mono:!0,children:y(t.lastUsedAt,l)})]},e.id))})]})})})}var Z=t.ul`
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
`,Q=t.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
|
-
`,ne=t(l)`
|
|
31
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
32
|
-
font-size: 12px;
|
|
33
|
-
max-width: 30ch;
|
|
34
|
-
`,re=t(u)`
|
|
35
|
-
color: ${({theme:e})=>e.color.down};
|
|
36
|
-
font-size: 11px;
|
|
37
|
-
`;function ie({logs:e}){let t=e.slice(0,12);return(0,K.jsx)(R,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:(0,K.jsx)(o,{as:s,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?(0,K.jsx)(B,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):(0,K.jsx)(Z,{children:t.map(e=>(0,K.jsxs)(Q,{children:[(0,K.jsx)(P,{state:j(e)?`down`:`ok`,label:j(e)?`failed with ${e.status}`:`succeeded`}),(0,K.jsx)(u,{$dim:!0,children:S(e.at)}),(0,K.jsx)(ne,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:(0,K.jsx)(u,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),(0,K.jsx)(f,{}),e.errorCode===null?null:(0,K.jsx)(re,{children:e.errorCode}),e.attempts>1?(0,K.jsxs)(u,{$dim:!0,children:[e.attempts,`×`]}):null,(0,K.jsx)(u,{$dim:!0,children:x(e.durationMs)}),(0,K.jsx)(u,{$dim:!0,children:b(e.costUsd)})]},e.id))})})}var ae=t.ul`
|
|
38
|
-
display: flex;
|
|
39
|
-
flex-direction: column;
|
|
40
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
41
|
-
`,oe=t(l)`
|
|
42
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
43
|
-
font-size: 12.5px;
|
|
44
|
-
`,se=t.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
|
-
`,ce=t.div`
|
|
52
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
53
|
-
background: ${({$color:e})=>e};
|
|
54
|
-
opacity: 0.8;
|
|
55
|
-
`,le=t.div`
|
|
56
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
57
|
-
`;function ue({models:e,logs:t}){let n=new Map;for(let e of t){let t=n.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,n.set(e.requestedModel,t)}let i=Math.max(1,...[...n.values()].map(e=>e.requests)),a=[...e].map(e=>({model:e,used:n.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return(0,K.jsx)(R,{legend:`Models`,meta:`${e.length} configured`,actions:(0,K.jsx)(o,{as:s,to:`/models`,$size:`sm`,children:`Edit routing`}),children:e.length===0?(0,K.jsx)(B,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:(0,K.jsx)(o,{as:s,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):(0,K.jsx)(ae,{children:a.map(({model:e,used:t})=>{let n=(t?.requests??0)/i,a=[...new Set(e.targets.map(e=>e.provider))];return(0,K.jsxs)(`li`,{children:[(0,K.jsxs)(p,{$gap:2,children:[(0,K.jsx)(oe,{title:e.id,children:e.id}),e.isAlias?(0,K.jsx)(I,{children:`alias`}):null,(0,K.jsx)(I,{$tone:`accent`,children:e.strategy}),(0,K.jsx)(f,{}),(0,K.jsx)(u,{$dim:!0,children:w(t?.requests??0)}),(0,K.jsx)(r,{children:`req`}),(0,K.jsx)(u,{$dim:!0,children:b(t?.costUsd??0)})]}),(0,K.jsxs)(se,{style:{marginTop:6},title:`${Math.round(n*100)}% of the busiest model`,children:[a.map(e=>(0,K.jsx)(ce,{$color:`var(--p-${e})`,$grow:n/a.length},e)),(0,K.jsx)(le,{$grow:Math.max(0,1-n)})]})]},e.id)})})})}var de=t.div`
|
|
58
|
-
display: grid;
|
|
59
|
-
grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
|
|
60
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
61
|
-
`;function fe({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=ee(r,t),a=M(r,{now:n,spanMs:t,count:32}),o=i.errorRate>=.25?`down`:i.errorRate>=.05?`warn`:`ok`;return(0,K.jsxs)(de,{children:[(0,K.jsx)(G,{legend:`Requests`,value:w(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:(0,K.jsx)(C,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),(0,K.jsx)(G,{legend:`Error rate`,value:E(i.errorRate),unit:`${w(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:(0,K.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,K.jsx)(G,{legend:`Time to first token`,value:x(i.ttftP50),unit:`p95 ${x(i.ttftP95)}`,trace:(0,K.jsx)(C,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${x(i.ttftP50)}`})}),(0,K.jsx)(G,{legend:`Spend`,value:b(i.costUsd),unit:`${w(i.inputTokens+i.outputTokens)} tokens`,trace:(0,K.jsx)(C,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${b(i.costUsd)} total`})})]})}var $=36e5;function pe(){let{cadence:e}=v(),t=g(),r=h(e(1e4)),i=d(),o=m(500,e(1e4)),s=_(),l=Date.now(),u=Math.floor((l-$)/6e4)*6e4,f=n({groupBy:`credential`,since:u},e(6e4)),p=t.data??[],y=D(r.data?.health??[],e=>e.credentialId),b=p.filter(e=>k(y.get(e.id)??[],l,e.enabled,e.disabledReason).state===`down`),x=t.isLoading||o.isLoading?`Reading the gateway…`:p.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 ${p.length} accounts are answering. Nothing needs attention.`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(T,{legend:`Rack`,title:`Gateway`,summary:x}),o.isError?(0,K.jsx)(R,{legend:`Traffic`,children:(0,K.jsx)(z,{legend:`The gateway did not answer`,error:o.error,onRetry:()=>void o.refetch()})}):(0,K.jsxs)(c,{$gap:4,children:[(0,K.jsx)(fe,{logs:o.data??[],windowMs:$,now:l}),(0,K.jsx)(X,{credentials:p,health:r.data?.health??[],quota:r.data?.quota??[],usage:f.data??[],quotaPollIntervalMs:s.data?.quotaPollIntervalMs??3e5,now:l}),(0,K.jsxs)(a,{$min:`340px`,$gap:4,children:[(0,K.jsx)(ue,{models:i.data??[],logs:o.data??[]}),(0,K.jsx)(ie,{logs:o.data??[]})]})]})]})}var me=pe;export{me as component};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{A as e,B as t,D as n,Dt as r,F as i,Kt as a,M as o,N as s,O as c,Ot as l,k as u,m as d,s as f}from"./queries-vY5lJqBe.js";import{a as p,c as m,f as h,l as g,o as _,p as v,s as y,t as b}from"./Rack-uDxrjvaz.js";import{t as x}from"./Modal-Crr8uyWt.js";import{o as S,t as C}from"./Lamp-WOotyOTd.js";import{n as w,t as T}from"./Chip-D0YiqYkz.js";import{i as E,n as D}from"./Field-DdscQ9OO.js";import{a as O,n as k,r as A,t as j}from"./States-DPTTYUHL.js";import{i as M,n as N,r as P,t as F}from"./Table-LkPaHBsj.js";var I=a(l(),1),L=r(),R=[50,100,250,500],z=t(u)`
|
|
2
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
`,B=t(D)`
|
|
5
|
-
width: 220px;
|
|
6
|
-
`,V=t(E)`
|
|
7
|
-
width: auto;
|
|
8
|
-
`,H=t.dl`
|
|
9
|
-
display: grid;
|
|
10
|
-
grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
|
|
11
|
-
gap: 6px ${({theme:e})=>e.space(3)};
|
|
12
|
-
margin: 0;
|
|
13
|
-
font-size: 12.5px;
|
|
14
|
-
`,U=t.dd`
|
|
15
|
-
margin: 0;
|
|
16
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
17
|
-
word-break: break-all;
|
|
18
|
-
`;function W(){let{cadence:t}=p(),[r,a]=(0,I.useState)(100),[l,E]=(0,I.useState)(`all`),[D,W]=(0,I.useState)(``),[G,K]=(0,I.useState)(null),q=d(r,t(1e4)),J=f(),Y=(0,I.useMemo)(()=>{let e=new Map;for(let t of J.data??[])e.set(t.id,t.label);return e},[J.data]),X=D.trim().toLowerCase(),Z=(q.data??[]).filter(e=>l===`failed`&&!S(e)?!1:X.length===0||e.requestedModel.toLowerCase().includes(X)||(e.resolvedModel??``).toLowerCase().includes(X)||(e.errorCode??``).toLowerCase().includes(X)||(e.credentialId===null?``:Y.get(e.credentialId)??``).toLowerCase().includes(X)),Q=(q.data??[]).filter(S).length;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{legend:`Logs`,title:`Recent requests`,summary:q.isLoading?`Reading the request log…`:`${y(q.data?.length??0)} recent requests, ${y(Q)} of them failed. Prompt and response bodies are never recorded.`,actions:(0,L.jsxs)(z,{children:[(0,L.jsx)(B,{value:D,placeholder:`Filter by model, account, or error`,"aria-label":`Filter requests`,onChange:e=>W(e.target.value)}),(0,L.jsxs)(V,{value:l,"aria-label":`Show which requests`,onChange:e=>E(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:r,"aria-label":`How many requests to fetch`,onChange:e=>a(Number(e.target.value)),children:R.map(e=>(0,L.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,L.jsx)(O,{legend:`Request log`,meta:`${Z.length} shown`,flush:!0,children:q.isError?(0,L.jsx)(k,{error:q.error,onRetry:()=>void q.refetch()}):q.isLoading?(0,L.jsx)(`div`,{style:{padding:12},children:(0,L.jsx)(A,{rows:8})}):Z.length===0?(0,L.jsx)(j,{legend:`Nothing to show`,message:(q.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)(e,{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,{$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:Z.map(e=>(0,L.jsxs)(M,{$selectable:!0,onClick:()=>K(e),children:[(0,L.jsx)(N,{children:(0,L.jsx)(C,{state:S(e)?`down`:`ok`,label:S(e)?`failed with ${e.status}`:`succeeded`})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,title:m(e.at),children:_(e.at)}),(0,L.jsx)(N,{$mono:!0,children:(0,L.jsx)(s,{style:{display:`block`,maxWidth:`20ch`},children:e.requestedModel||`—`})}),(0,L.jsx)(N,{children:e.resolvedProvider===null?(0,L.jsx)(n,{children:`not routed`}):(0,L.jsxs)(u,{$gap:1,children:[(0,L.jsx)(w,{provider:e.resolvedProvider}),(0,L.jsx)(c,{$dim:!0,children:e.resolvedModel??`—`})]})}),(0,L.jsx)(N,{children:(0,L.jsx)(s,{style:{display:`block`,maxWidth:`18ch`},children:e.credentialId===null?`—`:Y.get(e.credentialId)??v(e.credentialId)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:e.attempts}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:g(e.ttftMs)}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:g(e.durationMs)}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:y(e.inputTokens+e.outputTokens)}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:h(e.costUsd)}),(0,L.jsx)(N,{children:e.errorCode===null?(0,L.jsx)(T,{$tone:`ok`,children:e.status}):(0,L.jsx)(T,{$tone:`down`,children:e.errorCode})})]},e.id))})]})})}),(0,L.jsx)(x,{open:G!==null,onOpenChange:e=>{e||K(null)},title:`Request detail`,width:`600px`,footer:(0,L.jsx)(i,{type:`button`,onClick:()=>K(null),children:`Close`}),children:G===null?null:(0,L.jsxs)(o,{$gap:3,children:[(0,L.jsxs)(H,{children:[(0,L.jsx)(n,{as:`dt`,children:`Request id`}),(0,L.jsx)(U,{children:G.id}),(0,L.jsx)(n,{as:`dt`,children:`At`}),(0,L.jsx)(U,{children:m(G.at)}),(0,L.jsx)(n,{as:`dt`,children:`Requested model`}),(0,L.jsx)(U,{children:G.requestedModel||`—`}),(0,L.jsx)(n,{as:`dt`,children:`Routed to`}),(0,L.jsx)(U,{children:G.resolvedProvider===null?`not routed`:`${G.resolvedProvider} · ${G.resolvedModel??`—`}`}),(0,L.jsx)(n,{as:`dt`,children:`Account`}),(0,L.jsx)(U,{children:G.credentialId===null?`—`:Y.get(G.credentialId)??G.credentialId}),(0,L.jsx)(n,{as:`dt`,children:`Key`}),(0,L.jsx)(U,{children:G.apiKeyId??`—`}),(0,L.jsx)(n,{as:`dt`,children:`Attempts`}),(0,L.jsx)(U,{children:G.attempts}),(0,L.jsx)(n,{as:`dt`,children:`Status`}),(0,L.jsx)(U,{children:G.errorCode===null?G.status:`${G.status} ${G.errorCode}`}),(0,L.jsx)(n,{as:`dt`,children:`Timing`}),(0,L.jsxs)(U,{children:[`first token `,g(G.ttftMs),` · total `,g(G.durationMs)]}),(0,L.jsx)(n,{as:`dt`,children:`Tokens`}),(0,L.jsxs)(U,{children:[y(G.inputTokens),` in · `,y(G.outputTokens),` out ·`,` `,y(G.cacheReadTokens),` cache read ·`,` `,y(G.cacheWriteTokens),` cache write`]}),(0,L.jsx)(n,{as:`dt`,children:`Cost`}),(0,L.jsx)(U,{children:h(G.costUsd)})]}),G.degradations.length===0?null:(0,L.jsxs)(o,{$gap:1,children:[(0,L.jsx)(n,{children:`Capabilities dropped to fit the target`}),(0,L.jsx)(u,{$gap:1,$wrap:!0,children:G.degradations.map(e=>(0,L.jsx)(T,{$tone:`warn`,children:e},e))})]})]})})]})}var G=W;export{G as component};
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import{B as e,D as t,Dt as n,F as r,I as i,Kt as a,M as o,N as s,O as c,Ot as l,_ as u,h as d,j as f,k as p,l as m,u as h,y as g}from"./queries-vY5lJqBe.js";import{m as _,t as v}from"./Rack-uDxrjvaz.js";import{n as y,r as b,t as x}from"./Toggle-D0e4C94X.js";import{t as S}from"./trash-2-Cep_aVLx.js";import{n as C,t as w}from"./Chip-D0YiqYkz.js";import{i as T,n as E,r as D,t as O}from"./Field-DdscQ9OO.js";import{t as ee}from"./Meter-Bm1oQE2U.js";import{a as k,i as A,n as te,r as j,t as M}from"./States-DPTTYUHL.js";import{n as ne,t as N}from"./catalog-DVRPlBJJ.js";var re=_(`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`}]]),P=_(`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=a(l(),1),I=n(),L=[`tier`,`health`,`quota`,`cost`,`latency`,`recency`],ie={tier:`How preferred this tier is`,health:`Consecutive failures and breaker state`,quota:`Headroom in the tightest window, against how much of it is left`,cost:`Price against the other candidates`,latency:`Observed time to first token`,recency:`How long this pair has been idle`},ae=e.li`
|
|
2
|
-
padding: ${({theme:e})=>e.space(2)} 0;
|
|
3
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
4
|
-
|
|
5
|
-
&:last-child {
|
|
6
|
-
border-bottom: 0;
|
|
7
|
-
}
|
|
8
|
-
`,oe=e(c)`
|
|
9
|
-
width: 22px;
|
|
10
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
|
-
flex: none;
|
|
12
|
-
`,se=e(w)`
|
|
13
|
-
border-color: ${({theme:e})=>e.color.ok};
|
|
14
|
-
color: ${({theme:e})=>e.color.ok};
|
|
15
|
-
background: ${({theme:e})=>e.color.okWash};
|
|
16
|
-
`,ce=e.div`
|
|
17
|
-
display: grid;
|
|
18
|
-
grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
|
|
19
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
20
|
-
margin-top: ${({theme:e})=>e.space(2)};
|
|
21
|
-
padding-left: 30px;
|
|
22
|
-
`,le=e.div`
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: 3px;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
`,ue=e.div`
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: baseline;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: 6px;
|
|
32
|
-
`,de=e.li`
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
36
|
-
padding: 5px 0;
|
|
37
|
-
`,fe=e(p)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,R=e.label`
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
gap: 6px;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
font-size: 12.5px;
|
|
46
|
-
`,z=e.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 V({modelId:e}){let[n,i]=(0,F.useState)({tools:!1,images:!1,reasoning:!1}),[a,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(null),m=g(),_=h(),v=m.data?.weights,y=()=>{e!==null&&(d(null),_.mutate({modelId:e,need:n},{onSuccess:e=>l(e),onError:e=>{l(null),d(A(e))}}))},b=new Map(L.map(e=>[e,Math.max(1e-4,...(a?.candidates??[]).map(t=>v===void 0?0:Math.abs(B(t.reasons,e,v))))]));return(0,I.jsx)(k,{legend:`Explain`,meta:e??`no model selected`,actions:(0,I.jsxs)(r,{type:`button`,$size:`sm`,$variant:`primary`,disabled:e===null||_.isPending,onClick:y,children:[(0,I.jsx)(re,{}),_.isPending?`Ranking…`:`Rank candidates`]}),children:(0,I.jsxs)(o,{$gap:3,children:[(0,I.jsxs)(o,{$gap:1,children:[(0,I.jsx)(t,{children:`Pretend the request needs`}),(0,I.jsxs)(fe,{children:[(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:n.tools,label:`Probe request uses tools`,onCheckedChange:e=>i({...n,tools:e})}),`Tools`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:n.images,label:`Probe request includes an image`,onCheckedChange:e=>i({...n,images:e})}),`Images`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:n.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>i({...n,reasoning:e})}),`Reasoning`]})]})]}),u===null?null:(0,I.jsx)(z,{children:u}),a===null?(0,I.jsx)(M,{legend:`Not ranked yet`,message:e===null?`Select a model to see which account the router would pick for it.`:`Run the ranking to see which account wins, by how much, and what was filtered out.`}):(0,I.jsxs)(o,{$gap:3,children:[(0,I.jsxs)(p,{$gap:2,$wrap:!0,children:[(0,I.jsx)(w,{$tone:`accent`,children:a.strategy}),a.deterministic?null:(0,I.jsx)(w,{$tone:`warn`,children:`order varies per request`}),(0,I.jsx)(f,{}),(0,I.jsxs)(t,{children:[a.candidates.length,` eligible · `,a.excluded.length,` filtered out`]})]}),a.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:a.candidates.map((e,n)=>(0,I.jsxs)(ae,{children:[(0,I.jsxs)(p,{$gap:2,children:[(0,I.jsx)(oe,{children:n+1}),(0,I.jsx)(C,{provider:e.provider}),(0,I.jsx)(s,{style:{maxWidth:`22ch`},children:e.credentialLabel}),(0,I.jsx)(c,{$dim:!0,children:e.model}),(0,I.jsxs)(w,{children:[`tier `,e.tier]}),(0,I.jsx)(f,{}),n===0?(0,I.jsx)(se,{children:`would be used`}):null,(0,I.jsx)(c,{children:e.score.toFixed(2)})]}),v===void 0?null:(0,I.jsx)(ce,{children:L.map(n=>{let r=B(e.reasons,n,v),i=b.get(n)??1;return(0,I.jsxs)(le,{title:ie[n],children:[(0,I.jsxs)(ue,{children:[(0,I.jsx)(t,{children:n}),(0,I.jsx)(c,{$dim:!0,$size:`10.5px`,children:r.toFixed(2)})]}),(0,I.jsx)(ee,{fraction:Math.abs(r)/i,height:4,tone:`var(--accent)`,label:`${n} contributes ${r.toFixed(2)} of ${e.score.toFixed(2)}`})]},n)})})]},`${e.credentialId}:${e.model}`))}),a.excluded.length===0?null:(0,I.jsxs)(o,{$gap:1,children:[(0,I.jsx)(t,{children:`Filtered out`}),(0,I.jsx)(`ul`,{children:a.excluded.map(e=>(0,I.jsxs)(de,{children:[(0,I.jsx)(c,{$dim:!0,children:e.model}),(0,I.jsx)(f,{}),(0,I.jsx)(w,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}var H=[{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.`}],U=0;function W(){return U+=1,`target-${U}`}function G(e,t){let n=ne(e,t);return n===null?null:{costInput:String(n.input),costOutput:String(n.output),costCacheRead:String(n.cacheRead)}}function K(e=`anthropic`){let t=N[e].defaultModel,n=G(e,t);return{key:W(),provider:e,model:t,tier:`1`,weight:`1`,costInput:n?.costInput??`0`,costOutput:n?.costOutput??`0`,costCacheRead:n?.costCacheRead??``,tools:!0,images:!0,reasoning:!0}}function q(){return{id:``,strategy:`score`,isAlias:!1,targets:[K()]}}function J(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:W(),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),tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function pe(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.`};n.push({provider:r.provider,model:i,tier:a,weight:o,costPerMTok:{input:s,output:c,...l?{cacheRead:u}:{}},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 me=Object.keys(N),he=e.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
|
-
`,ge=e.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
|
-
`,_e=e.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=e.div`
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
gap: 4px;
|
|
78
|
-
min-width: 0;
|
|
79
|
-
`,ve=e(p)`
|
|
80
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
81
|
-
flex-wrap: wrap;
|
|
82
|
-
`,X=e.label`
|
|
83
|
-
display: flex;
|
|
84
|
-
align-items: center;
|
|
85
|
-
gap: 6px;
|
|
86
|
-
cursor: pointer;
|
|
87
|
-
`;function ye({target:e,index:n,onChange:a,onRemove:s,removable:c}){let l=(0,F.useId)(),u=N[e.provider],d=(t,n)=>{a({...e,[t]:n})},m=G(e.provider,e.model),h=t=>{a({...e,...t,...G(t.provider,t.model)??{}})};return(0,I.jsxs)(he,{$provider:e.provider,children:[(0,I.jsxs)(p,{$gap:2,children:[(0,I.jsxs)(t,{as:`legend`,children:[`Target `,n+1]}),(0,I.jsx)(f,{}),(0,I.jsx)(i,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!c,"aria-label":`Remove target ${n+1}`,title:c?`Remove target ${n+1}`:`A model needs at least one target`,onClick:s,children:(0,I.jsx)(S,{})})]}),(0,I.jsxs)(ge,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(t,{as:`label`,htmlFor:`${l}-provider`,children:`Provider`}),(0,I.jsx)(T,{id:`${l}-provider`,value:e.provider,onChange:t=>{let n=t.target.value,r=N[n].models.some(t=>t.id===e.model);h({provider:n,model:r?e.model:N[n].defaultModel})},children:me.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(t,{as:`label`,htmlFor:`${l}-model`,children:`Provider model`}),(0,I.jsx)(E,{id:`${l}-model`,list:`${l}-catalog`,value:e.model,placeholder:u.defaultModel,onChange:t=>h({provider:e.provider,model:t.target.value})}),(0,I.jsx)(`datalist`,{id:`${l}-catalog`,children:u.models.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(t,{as:`label`,htmlFor:`${l}-tier`,children:`Tier`}),(0,I.jsx)(D,{id:`${l}-tier`,min:1,step:1,value:e.tier,onChange:e=>d(`tier`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(t,{as:`label`,htmlFor:`${l}-weight`,children:`Weight`}),(0,I.jsx)(D,{id:`${l}-weight`,min:0,step:.1,value:e.weight,onChange:e=>d(`weight`,e.target.value)})]})]}),(0,I.jsxs)(o,{$gap:1,children:[(0,I.jsxs)(p,{$gap:2,children:[(0,I.jsx)(t,{children:`Price per million tokens`}),(0,I.jsx)(f,{}),m===null?(0,I.jsx)(t,{as:`span`,children:`not in the catalog — price it yourself`}):(0,I.jsxs)(r,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:e.costInput===m.costInput&&e.costOutput===m.costOutput&&e.costCacheRead===m.costCacheRead,onClick:()=>a({...e,...m}),children:[(0,I.jsx)(P,{}),`Use list price`]})]}),(0,I.jsxs)(_e,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(t,{as:`label`,htmlFor:`${l}-in`,children:`Input`}),(0,I.jsx)(D,{id:`${l}-in`,min:0,step:.01,value:e.costInput,onChange:e=>d(`costInput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(t,{as:`label`,htmlFor:`${l}-out`,children:`Output`}),(0,I.jsx)(D,{id:`${l}-out`,min:0,step:.01,value:e.costOutput,onChange:e=>d(`costOutput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(t,{as:`label`,htmlFor:`${l}-cache`,children:`Cache read`}),(0,I.jsx)(D,{id:`${l}-cache`,min:0,step:.01,placeholder:`same as input`,value:e.costCacheRead,onChange:e=>d(`costCacheRead`,e.target.value)})]})]})]}),(0,I.jsxs)(o,{$gap:1,children:[(0,I.jsx)(t,{children:`Capabilities`}),(0,I.jsxs)(ve,{children:[(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:e.tools,label:`Target ${n+1} supports tools`,onCheckedChange:e=>d(`tools`,e)}),`Tools`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:e.images,label:`Target ${n+1} supports images`,onCheckedChange:e=>d(`images`,e)}),`Images`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:e.reasoning,label:`Target ${n+1} supports reasoning`,onCheckedChange:e=>d(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Z=e.p`
|
|
88
|
-
font-size: 11.5px;
|
|
89
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
90
|
-
`,be=e.p`
|
|
91
|
-
font-size: 12px;
|
|
92
|
-
color: ${({theme:e})=>e.color.down};
|
|
93
|
-
`,xe=e.p`
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
color: ${({theme:e})=>e.color.ok};
|
|
96
|
-
`,Q=e(p)`
|
|
97
|
-
gap: 8px;
|
|
98
|
-
`;function Se({model:e,onSaved:n,onDeleted:i}){let[a,s]=(0,F.useState)(()=>e===null?q():J(e)),[c,l]=(0,F.useState)(null),[d,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)(!1),v=u(),S=m(),C=e?.id??null;(0,F.useEffect)(()=>{s(e===null?q():J(e)),l(null),h(!1)},[C]);let w=H.find(e=>e.id===a.strategy);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(k,{legend:e===null?`New model`:`Edit model`,meta:e===null?void 0:e.id,actions:(0,I.jsxs)(I.Fragment,{children:[e===null?null:(0,I.jsx)(r,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>_(!0),children:`Delete`}),(0,I.jsx)(r,{type:`button`,$variant:`primary`,$size:`sm`,disabled:v.isPending,onClick:()=>{h(!1);let e=pe(a);if(!e.ok){l(e.problem);return}l(null),v.mutate(e.model,{onSuccess:()=>{h(!0),n(e.model.id)},onError:e=>l(A(e))})},children:v.isPending?`Saving…`:e===null?`Create model`:`Save changes`})]}),children:(0,I.jsxs)(o,{$gap:3,children:[(0,I.jsx)(O,{label:`Model name`,hint:e===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:t=>(0,I.jsx)(E,{...t,value:a.id,disabled:e!==null,placeholder:`fast`,onChange:e=>s({...a,id:e.target.value})})}),(0,I.jsx)(O,{label:`Routing strategy`,children:e=>(0,I.jsx)(T,{...e,value:a.strategy,onChange:e=>s({...a,strategy:e.target.value}),children:H.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)(Q,{children:[(0,I.jsx)(x,{checked:a.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>s({...a,isAlias:e})}),(0,I.jsxs)(o,{$gap:0,children:[(0,I.jsx)(t,{as:`span`,children:`Alias`}),(0,I.jsx)(Z,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),(0,I.jsxs)(o,{$gap:2,children:[(0,I.jsxs)(p,{children:[(0,I.jsx)(t,{children:`Targets`}),(0,I.jsx)(f,{}),(0,I.jsxs)(r,{type:`button`,$size:`sm`,onClick:()=>s({...a,targets:[...a.targets,K(a.targets.at(-1)?.provider??`anthropic`)]}),children:[(0,I.jsx)(b,{}),`Add target`]})]}),a.targets.map((e,t)=>(0,I.jsx)(ye,{target:e,index:t,removable:a.targets.length>1,onChange:t=>s({...a,targets:a.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>s({...a,targets:a.targets.filter(t=>t.key!==e.key)})},e.key))]}),c===null?null:(0,I.jsx)(be,{role:`alert`,children:c}),d&&c===null?(0,I.jsx)(xe,{role:`status`,children:`Saved.`}):null]})}),(0,I.jsx)(y,{open:g,onOpenChange:_,title:`Delete model`,body:e===null?``:`Deleting "${e.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:()=>{e!==null&&S.mutate(e.id,{onSuccess:()=>{_(!1),i()},onError:e=>{_(!1),l(A(e))}})}})]})}var Ce=e.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
|
-
`,we=e(o)`
|
|
108
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
109
|
-
min-width: 0;
|
|
110
|
-
`,Te=e.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
|
-
`,Ee=e(s)`
|
|
132
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
133
|
-
font-size: 12.5px;
|
|
134
|
-
display: block;
|
|
135
|
-
max-width: 100%;
|
|
136
|
-
`,De=e.div`
|
|
137
|
-
display: flex;
|
|
138
|
-
gap: 2px;
|
|
139
|
-
`,Oe=e.span`
|
|
140
|
-
width: 12px;
|
|
141
|
-
height: 3px;
|
|
142
|
-
border-radius: 1px;
|
|
143
|
-
background: ${({$provider:e})=>`var(--p-${e})`};
|
|
144
|
-
`,$=`\0new`;function ke(){let e=d(),[n,i]=(0,F.useState)(null),a=e.data??[],o=n===$?null:a.find(e=>e.id===n)??null,s=n===$||n===null&&!e.isLoading&&a.length===0;(0,F.useEffect)(()=>{n===null&&a.length!==0&&i(a[0]?.id??null)},[a,n]);let l=e.isLoading?`Reading configured models…`:a.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${a.length} model${a.length===1?``:`s`} routing to ${a.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:l,actions:(0,I.jsxs)(r,{type:`button`,$variant:`primary`,onClick:()=>i($),children:[(0,I.jsx)(b,{}),`New model`]})}),(0,I.jsxs)(Ce,{children:[(0,I.jsx)(k,{legend:`Configured`,meta:`${a.length}`,flush:!0,children:e.isError?(0,I.jsx)(te,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?(0,I.jsx)(`div`,{style:{padding:12},children:(0,I.jsx)(j,{rows:4})}):a.length===0?(0,I.jsx)(M,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:(0,I.jsx)(r,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>i($),children:`New model`})}):(0,I.jsx)(`div`,{children:a.map(e=>{let r=[...new Set(e.targets.map(e=>e.provider))];return(0,I.jsxs)(Te,{type:`button`,$selected:e.id===n,"aria-pressed":e.id===n,onClick:()=>i(e.id),children:[(0,I.jsxs)(p,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(Ee,{title:e.id,children:e.id}),(0,I.jsx)(f,{}),e.isAlias?(0,I.jsx)(w,{children:`alias`}):null]}),(0,I.jsxs)(p,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(De,{children:r.map(e=>(0,I.jsx)(Oe,{$provider:e,title:e},e))}),(0,I.jsx)(t,{children:e.strategy}),(0,I.jsx)(f,{}),(0,I.jsxs)(c,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),(0,I.jsxs)(we,{children:[o===null&&!s?(0,I.jsx)(k,{legend:`Editor`,children:e.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)(Se,{model:o,onSaved:t=>{i(t),e.refetch()},onDeleted:()=>{i(null),e.refetch()}}),(0,I.jsx)(V,{modelId:o?.id??null})]})]})]})}var Ae=ke;export{Ae as component};
|