omnigateway 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -7
- package/bin/omni.js +3542 -1826
- package/gateway.js +2430 -824
- package/package.json +1 -1
- package/public/assets/{Chip-C4X8tf5z.js → Chip-DJwp7gBu.js} +2 -2
- package/public/assets/Confirm-CVLz9F7a.js +4 -0
- package/public/assets/{CopyValue-B-uR4Js-.js → CopyValue-CNZbWS59.js} +4 -4
- package/public/assets/{Field-Ct4SeDZD.js → Field-BDtp692L.js} +8 -8
- package/public/assets/Lamp-B65uWKbW.js +25 -0
- package/public/assets/{Meter-COdz0dwY.js → Meter-BREBUFGX.js} +2 -2
- package/public/assets/{Modal-DMFUHQ-A.js → Modal-DbydSAlp.js} +8 -8
- package/public/assets/Rack-Bbo4JfEX.js +151 -0
- package/public/assets/{Readout-Bl2kD9Tl.js → Readout-CEAoN5hu.js} +5 -5
- package/public/assets/{States-D5Memn8D.js → States-BEKLros0.js} +10 -10
- package/public/assets/{Table-DObRatbW.js → Table-BBypbVWj.js} +1 -1
- package/public/assets/{Toggle-Dkjlvck5.js → Toggle-BUr71O4J.js} +2 -2
- package/public/assets/{TokenBreakdown-oXP49ZTa.js → TokenBreakdown-C1ziK9d1.js} +4 -4
- package/public/assets/_app-ByQ1bPbe.js +1 -0
- package/public/assets/_app.accounts-BTug_Xfo.js +64 -0
- package/public/assets/{_app.console-BVVpryIB.js → _app.console-DKyGL9xx.js} +10 -10
- package/public/assets/_app.index-CSw9gmMf.js +62 -0
- package/public/assets/_app.keys-07Kbw4RS.js +39 -0
- package/public/assets/_app.logs-C9QiV39p.js +32 -0
- package/public/assets/_app.models-CDqVrAeF.js +148 -0
- package/public/assets/{_app.settings-BN436vI2.js → _app.settings-DmUEeTaP.js} +10 -10
- package/public/assets/_app.usage-B1WuMGRr.js +83 -0
- package/public/assets/catalog-BBKm8Ih8.js +1 -0
- package/public/assets/{dist-CnzT-Ut2.js → dist-Bka7ErcH.js} +1 -1
- package/public/assets/index-DJfb1i4P.js +186 -0
- package/public/assets/{login-2LpCZOtB.js → login-DKZYqRh0.js} +8 -8
- package/public/assets/queries-D8LJNQpL.js +144 -0
- package/public/assets/shared-CIhZ6FCO.js +84 -0
- package/public/assets/{trash-2-Da6cLgPn.js → trash-2-CLYNAAJA.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/Confirm-BnmH8Gn0.js +0 -4
- package/public/assets/Lamp-CBOwqG5K.js +0 -25
- package/public/assets/Rack-DAbY9x1I.js +0 -151
- package/public/assets/_app-Brc2wQZm.js +0 -1
- package/public/assets/_app.accounts-I9RXUiyi.js +0 -54
- package/public/assets/_app.index-83Ig4FUL.js +0 -62
- package/public/assets/_app.keys-KeP6L4g_.js +0 -39
- package/public/assets/_app.logs-B5oh01Ls.js +0 -32
- package/public/assets/_app.models-BuOFMZUN.js +0 -144
- package/public/assets/_app.usage-C528VOia.js +0 -166
- package/public/assets/catalog-kJ53n_fc.js +0 -1
- package/public/assets/index-CE-KQ-ju.js +0 -172
- package/public/assets/queries-1zRLkX-Q.js +0 -144
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o as e}from"./Rack-Bbo4JfEX.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-DJfb1i4P.js"></script>
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/queries-D8LJNQpL.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/index-Co2s5xMk.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{K as e,Nt as t,V as n}from"./queries-1zRLkX-Q.js";import{h as r}from"./Rack-DAbY9x1I.js";import{t as i}from"./Modal-DMFUHQ-A.js";var a=r(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),o=t(),s=e.p`
|
|
2
|
-
font-size: 13px;
|
|
3
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
4
|
-
`;function c({open:e,onOpenChange:t,title:r,body:a,confirmLabel:c,busy:l,onConfirm:u}){return(0,o.jsx)(i,{open:e,onOpenChange:t,title:r,width:`420px`,footer:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),(0,o.jsx)(n,{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,25 +0,0 @@
|
|
|
1
|
-
import{G as e,K as t,Nt as n,U as r}from"./queries-1zRLkX-Q.js";function i(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 a(e){return e.state===`pending`}function o(e){return e.filter(e=>!a(e))}function s(e){return a(e)?!1:e.status>=400||e.errorCode!==null}var c={ok:`●`,warn:`◐`,down:`○`,idle:`·`,live:`●`};function l(e){return a(e)?`live`:s(e)?`down`:`ok`}function u(e){return a(e)?`in flight`:s(e)?`failed with ${e.status}`:`succeeded`}function d(e,t){let n=o(e),r=[],a=0,c=0,l=0,u=0,d=0,f=0;for(let e of n)s(e)&&(a+=1),e.ttftMs!==null&&Number.isFinite(e.ttftMs)&&r.push(e.ttftMs),c+=e.costUsd,l+=e.inputTokens,u+=e.outputTokens,d+=e.cacheReadTokens,f+=e.cacheWriteTokens;let p=t/6e4;return{requests:n.length,errors:a,errorRate:n.length===0?0:a/n.length,ratePerMin:p<=0?0:n.length/p,ttftP50:i(r,.5),ttftP95:i(r,.95),costUsd:c,inputTokens:l,outputTokens:u,cacheReadTokens:d,cacheWriteTokens:f}}function f(e,t){let n=o(e),{now:r,spanMs:a,count:c}=t,l=a/c,u=r-a,d=Array.from({length:c},(e,t)=>({at:u+t*l,total:0,errors:0,costUsd:0,tokens:0,ttftMs:null})),f=Array.from({length:c},()=>[]);for(let e of n){if(e.at<u||e.at>r)continue;let t=Math.min(c-1,Math.floor((e.at-u)/l)),n=d[t];n!==void 0&&(n.total+=1,n.costUsd+=e.costUsd,n.tokens+=e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheWriteTokens,s(e)&&(n.errors+=1),e.ttftMs!==null&&Number.isFinite(e.ttftMs)&&f[t]?.push(e.ttftMs))}for(let[e,t]of d.entries())t.ttftMs=i(f[e]??[],.5);return d}var p={tokenRejected:`reconnect needed — provider rejected the refresh token`,expiredNoRefresh:`reconnect needed — token expired with nothing to refresh from`};function m(e,t,n,r=null){if(!n){let e=r===`tokenRejected`||r===`expiredNoRefresh`;return{state:e?`down`:`idle`,note:e?p[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,c=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)),c=Math.max(c,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:c}}var h={fiveHour:`5h`,daily:`24h`,weekly:`7d`};function g(e){return Math.max(e,6e4)*3}function _(e,t,n){return e.observedAt<=0||t-e.observedAt>g(n)}function v(e,t,n,r){let i=h[e.windowType];return e.observedAt<=0?`${i} · never observed`:_(e,t,n)?`${i} · stale, read ${r(e.observedAt,t)}`:e.resetsAt===null?i:`${i} · resets ${r(e.resetsAt,t)}`}var y={fiveHour:0,daily:1,weekly:2};function b(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)=>y[e.window.windowType]-y[t.window.windowType])}function x(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 S=n(),C=r`
|
|
2
|
-
0%, 100% { opacity: 1; }
|
|
3
|
-
50% { opacity: 0.28; }
|
|
4
|
-
`,w=e`
|
|
5
|
-
color: ${({theme:e})=>e.color.ok};
|
|
6
|
-
animation: ${C} 1.2s ease-in-out infinite;
|
|
7
|
-
|
|
8
|
-
@media (prefers-reduced-motion: reduce) {
|
|
9
|
-
animation: none;
|
|
10
|
-
}
|
|
11
|
-
`,T={ok:e`
|
|
12
|
-
color: ${({theme:e})=>e.color.ok};
|
|
13
|
-
`,warn:e`
|
|
14
|
-
color: ${({theme:e})=>e.color.warn};
|
|
15
|
-
`,down:e`
|
|
16
|
-
color: ${({theme:e})=>e.color.down};
|
|
17
|
-
`,idle:e`
|
|
18
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
19
|
-
`,live:w},E=t.span`
|
|
20
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
21
|
-
font-size: 12px;
|
|
22
|
-
line-height: 1;
|
|
23
|
-
flex: none;
|
|
24
|
-
${({$state:e})=>T[e]}
|
|
25
|
-
`;function D({state:e,label:t,className:n}){return(0,S.jsx)(E,{$state:e,className:n,role:`img`,"aria-label":t,title:t,children:c[e]})}export{x as a,u as c,b as d,d as f,m as i,l,h as n,s as o,f as r,a as s,D as t,v as u};
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import{B as e,F as t,H as n,J as r,K as i,L as a,M as o,N as s,Nt as c,Pt as l,Qt as u,V as d,X as f,v as p,y as m}from"./queries-1zRLkX-Q.js";import{t as h}from"./index-CE-KQ-ju.js";import{f as g,r as _,t as v}from"./Lamp-CBOwqG5K.js";var y=u(l(),1),b=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),x=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),S=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),C=e=>{let t=S(e);return t.charAt(0).toUpperCase()+t.slice(1)},w={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},T=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},E=(0,y.createContext)({}),D=()=>(0,y.useContext)(E),O=(0,y.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=D()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,y.createElement)(`svg`,{ref:c,...w,width:t??l??w.width,height:t??l??w.height,stroke:e??f,strokeWidth:m,className:b(`lucide`,p,i),...!a&&!T(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,y.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),k=(e,t)=>{let n=(0,y.forwardRef)(({className:n,...r},i)=>(0,y.createElement)(O,{ref:i,iconNode:t,className:b(`lucide-${x(C(e))}`,`lucide-${e}`,n),...r}));return n.displayName=C(e),n},A=k(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),ee=k(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),te=k(`cable`,[[`path`,{d:`M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z`,key:`trhst0`}],[`path`,{d:`M17 21v-2`,key:`ds4u3f`}],[`path`,{d:`M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10`,key:`1mo9zo`}],[`path`,{d:`M21 21v-2`,key:`eo0ou`}],[`path`,{d:`M3 5V3`,key:`1k5hjh`}],[`path`,{d:`M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z`,key:`1dd30t`}],[`path`,{d:`M7 5V3`,key:`1t1388`}]]),ne=k(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),re=k(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),ie=k(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),ae=k(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),oe=k(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),se=k(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),ce=k(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),le=k(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),j=k(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),M=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),N=new Intl.NumberFormat(`en-US`);function P(e){return Number.isFinite(e)?e<1e4?N.format(Math.round(e)):M.format(e).toLowerCase():`—`}function F(e){return Number.isFinite(e)?e===0?`$0`:e<.01?`$${e.toFixed(4)}`:e<100?`$${e.toFixed(2)}`:`$${M.format(e).toLowerCase()}`:`—`}function I(e){return e==null||!Number.isFinite(e)?`—`:e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/6e4)}m`}function L(e,t=1){return Number.isFinite(e)?`${(e*100).toFixed(t)}%`:`—`}var R=[[6e4,1e3,`s`],[36e5,6e4,`m`],[864e5,36e5,`h`],[1/0,864e5,`d`]];function z(e){let t=Math.abs(e);if(t<1e3)return`0s`;let n=R.find(([e])=>t<e);return n===void 0?`—`:`${Math.floor(t/n[1])}${n[2]}`}function B(e,t=Date.now()){if(e==null||!Number.isFinite(e))return`—`;let n=e-t;return Math.abs(n)<5e3?`just now`:n<0?`${z(n)} ago`:`in ${z(n)}`}function V(e){return new Date(e).toLocaleTimeString(`en-GB`,{hour12:!1})}function H(e){return e==null||!Number.isFinite(e)?`—`:new Date(e).toLocaleString(`en-GB`,{year:`numeric`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hour12:!1})}function U(e,t=8){return e.length<=t?e:`${e.slice(0,t)}…`}var W=c(),G=(0,y.createContext)(null);function ue({children:e}){let[t,n]=(0,y.useState)(!0),r=(0,y.useCallback)(()=>n(e=>!e),[]),i=(0,y.useMemo)(()=>({live:t,toggle:r,cadence:e=>t?e:!1}),[t,r]);return(0,W.jsx)(G,{value:i,children:e})}function K(){return(0,y.use)(G)??{live:!1,toggle:()=>{},cadence:()=>!1}}var de=i.svg`
|
|
2
|
-
display: block;
|
|
3
|
-
width: 100%;
|
|
4
|
-
height: 100%;
|
|
5
|
-
overflow: visible;
|
|
6
|
-
`;function q(e,t,n,r){if(e.length===0)return``;let i=e.length===1?0:t/(e.length-1);return e.map((e,t)=>{let a=t*i,o=n-(r===0?0:e/r*n);return`${t===0?`M`:`L`}${a.toFixed(2)},${o.toFixed(2)}`}).join(` `)}function J({values:e,overlay:t,height:n=28,color:r,overlayColor:i,scaleTo:a,label:o,className:s}){let c=(0,y.useId)(),l=a===void 0?Math.max(1,...e,...t??[]):Math.max(1,a),u=q(e,100,n,l),d=u.length===0?``:`${u} L100,${n} L0,${n} Z`;return(0,W.jsxs)(de,{className:s,viewBox:`0 0 100 ${n}`,preserveAspectRatio:`none`,role:`img`,"aria-label":o,style:{height:n},children:[(0,W.jsx)(`defs`,{children:(0,W.jsxs)(`linearGradient`,{id:c,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,W.jsx)(`stop`,{offset:`0%`,stopColor:r??`var(--accent)`,stopOpacity:`0.28`}),(0,W.jsx)(`stop`,{offset:`100%`,stopColor:r??`var(--accent)`,stopOpacity:`0`})]})}),d.length===0?null:(0,W.jsx)(`path`,{d,fill:`url(#${c})`}),t===void 0?null:(0,W.jsx)(`path`,{d:q(t,100,n,l),fill:`none`,stroke:i??`var(--down)`,strokeWidth:`1.25`,vectorEffect:`non-scaling-stroke`}),(0,W.jsx)(`path`,{d:u,fill:`none`,stroke:r??`var(--accent)`,strokeWidth:`1.5`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`})]})}var fe=i.header`
|
|
7
|
-
grid-area: chassis;
|
|
8
|
-
display: flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
11
|
-
height: 48px;
|
|
12
|
-
padding: 0 ${({theme:e})=>e.space(3)};
|
|
13
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
14
|
-
background: ${({theme:e})=>e.color.panel};
|
|
15
|
-
${e}
|
|
16
|
-
position: sticky;
|
|
17
|
-
top: 0;
|
|
18
|
-
z-index: ${({theme:e})=>e.z.chassis};
|
|
19
|
-
`,pe=i.div`
|
|
20
|
-
display: flex;
|
|
21
|
-
align-items: baseline;
|
|
22
|
-
gap: 7px;
|
|
23
|
-
font-stretch: 74%;
|
|
24
|
-
font-weight: 700;
|
|
25
|
-
letter-spacing: 0.2em;
|
|
26
|
-
font-size: 12px;
|
|
27
|
-
text-transform: uppercase;
|
|
28
|
-
flex: none;
|
|
29
|
-
`,me=i(t)`
|
|
30
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
|
|
33
|
-
@media (max-width: 860px) {
|
|
34
|
-
display: none;
|
|
35
|
-
}
|
|
36
|
-
`,Y=i.div`
|
|
37
|
-
display: flex;
|
|
38
|
-
align-items: baseline;
|
|
39
|
-
gap: 6px;
|
|
40
|
-
padding-left: ${({theme:e})=>e.space(3)};
|
|
41
|
-
border-left: 1px solid ${({theme:e})=>e.color.rule};
|
|
42
|
-
white-space: nowrap;
|
|
43
|
-
`,he=i(Y)`
|
|
44
|
-
width: 96px;
|
|
45
|
-
align-items: center;
|
|
46
|
-
`,ge=i.div`
|
|
47
|
-
flex: 1;
|
|
48
|
-
min-width: 0;
|
|
49
|
-
`,_e=i(d)`
|
|
50
|
-
gap: 6px;
|
|
51
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
52
|
-
letter-spacing: 0.08em;
|
|
53
|
-
`,X=[`system`,`light`,`dark`],Z={system:`Match system theme`,light:`Light theme`,dark:`Dark theme`},Q=6e5;function ve(){let e=f(),{live:t,toggle:r,cadence:i}=K(),{mode:c,setMode:l}=h(),u=p(),d=m(200,i(1e4)),b=Date.now(),x=(0,y.useMemo)(()=>(d.data??[]).filter(e=>b-e.at<=Q),[d.data,b]),S=g(x,Q),C=_(x,{now:b,spanMs:Q,count:24}),w=X[(X.indexOf(c)+1)%X.length]??`system`,T=c===`light`?le:c===`dark`?oe:ae,E=d.isError||S.errorRate>=.25?`down`:S.errorRate>=.05?`warn`:x.length===0?`idle`:`ok`;return(0,W.jsxs)(fe,{children:[(0,W.jsxs)(pe,{children:[(0,W.jsx)(v,{state:E,label:d.isError?`gateway unreachable`:`error rate ${L(S.errorRate)}`}),`Omnigateway`]}),(0,W.jsxs)(me,{children:[(0,W.jsxs)(he,{children:[(0,W.jsx)(o,{children:`req`}),(0,W.jsx)(ge,{children:(0,W.jsx)(J,{values:C.map(e=>e.total),overlay:C.map(e=>e.errors),height:22,label:`${S.requests} requests in the last 10 minutes`})})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`rate`}),(0,W.jsx)(s,{children:S.ratePerMin.toFixed(1)}),(0,W.jsx)(o,{children:`/min`})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`err`}),(0,W.jsx)(s,{style:{color:S.errorRate>=.05?`var(--down)`:void 0},children:L(S.errorRate)})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`ttft p50`}),(0,W.jsx)(s,{children:I(S.ttftP50)})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(o,{children:`spend`}),(0,W.jsx)(s,{children:F(S.costUsd)})]})]}),(0,W.jsx)(a,{}),(0,W.jsxs)(_e,{type:`button`,$size:`sm`,onClick:r,"aria-pressed":t,title:t?`Pause polling`:`Resume polling`,children:[(0,W.jsx)(v,{state:t?`ok`:`idle`,label:t?`polling`:`paused`}),t?`LIVE`:`PAUSED`]}),(0,W.jsx)(n,{type:`button`,$variant:`ghost`,$size:`sm`,onClick:()=>l(w),"aria-label":Z[c],title:`${Z[c]} — switch to ${Z[w].toLowerCase()}`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(n,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Sign out`,title:`Sign out`,disabled:u.isPending,onClick:()=>{u.mutate(void 0,{onSuccess:()=>void e({to:`/login`})})},children:(0,W.jsx)(ie,{})})]})}var ye=[{to:`/`,label:`Rack`,blurb:`Live state of every account and model`,Icon:A},{to:`/accounts`,label:`Accounts`,blurb:`Provider credentials and their health`,Icon:te},{to:`/models`,label:`Models`,blurb:`Virtual models, targets, and routing`,Icon:ee},{to:`/keys`,label:`Keys`,blurb:`Gateway API keys and their limits`,Icon:re},{to:`/usage`,label:`Usage`,blurb:`Requests, tokens, and spend over time`,Icon:ne},{to:`/logs`,label:`Logs`,blurb:`Recent requests, one row each`,Icon:se},{to:`/console`,label:`Console`,blurb:`The gateway's own output, as it was printed`,Icon:j},{to:`/settings`,label:`Settings`,blurb:`Routing weights, retries, retention`,Icon:ce}],be=i.nav`
|
|
54
|
-
grid-area: rail;
|
|
55
|
-
display: flex;
|
|
56
|
-
flex-direction: column;
|
|
57
|
-
gap: 2px;
|
|
58
|
-
padding: ${({theme:e})=>e.space(2)};
|
|
59
|
-
border-right: 1px solid ${({theme:e})=>e.color.rule};
|
|
60
|
-
background: ${({theme:e})=>e.color.panel};
|
|
61
|
-
overflow-y: auto;
|
|
62
|
-
|
|
63
|
-
@media (max-width: 720px) {
|
|
64
|
-
flex-direction: row;
|
|
65
|
-
overflow-x: auto;
|
|
66
|
-
border-right: 0;
|
|
67
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
68
|
-
}
|
|
69
|
-
`,xe=i(r)`
|
|
70
|
-
display: flex;
|
|
71
|
-
align-items: center;
|
|
72
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
73
|
-
padding: 7px ${({theme:e})=>e.space(2)};
|
|
74
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
75
|
-
border-left: 2px solid transparent;
|
|
76
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
77
|
-
font-size: 12.5px;
|
|
78
|
-
font-weight: 500;
|
|
79
|
-
white-space: nowrap;
|
|
80
|
-
transition:
|
|
81
|
-
background 120ms ease,
|
|
82
|
-
color 120ms ease;
|
|
83
|
-
|
|
84
|
-
svg {
|
|
85
|
-
width: 15px;
|
|
86
|
-
height: 15px;
|
|
87
|
-
flex: none;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
&:hover {
|
|
91
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
92
|
-
color: ${({theme:e})=>e.color.ink};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
&[data-status="active"] {
|
|
96
|
-
background: ${({theme:e})=>e.color.accentWash};
|
|
97
|
-
border-left-color: ${({theme:e})=>e.color.accent};
|
|
98
|
-
color: ${({theme:e})=>e.color.accent};
|
|
99
|
-
}
|
|
100
|
-
`;function Se(){return(0,W.jsx)(be,{"aria-label":`Console sections`,children:ye.map(({to:e,label:t,blurb:n,Icon:r})=>(0,W.jsxs)(xe,{to:e,title:n,activeOptions:{exact:e===`/`},children:[(0,W.jsx)(r,{}),t]},e))})}var Ce=i.div`
|
|
101
|
-
display: grid;
|
|
102
|
-
grid-template-areas:
|
|
103
|
-
"chassis chassis"
|
|
104
|
-
"rail main";
|
|
105
|
-
grid-template-columns: 168px minmax(0, 1fr);
|
|
106
|
-
grid-template-rows: auto minmax(0, 1fr);
|
|
107
|
-
height: 100vh;
|
|
108
|
-
min-height: 0;
|
|
109
|
-
overflow: hidden;
|
|
110
|
-
|
|
111
|
-
@media (max-width: 720px) {
|
|
112
|
-
grid-template-areas:
|
|
113
|
-
"chassis"
|
|
114
|
-
"rail"
|
|
115
|
-
"main";
|
|
116
|
-
grid-template-columns: minmax(0, 1fr);
|
|
117
|
-
grid-template-rows: auto auto minmax(0, 1fr);
|
|
118
|
-
}
|
|
119
|
-
`,$=i.main`
|
|
120
|
-
grid-area: main;
|
|
121
|
-
padding: ${({theme:e})=>e.space(4)};
|
|
122
|
-
display: flex;
|
|
123
|
-
flex-direction: column;
|
|
124
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
125
|
-
min-width: 0;
|
|
126
|
-
min-height: 0;
|
|
127
|
-
overflow-y: auto;
|
|
128
|
-
|
|
129
|
-
@media (max-width: 720px) {
|
|
130
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
131
|
-
}
|
|
132
|
-
`;function we({children:e}){return(0,W.jsxs)(Ce,{"data-testid":`rack-shell`,children:[(0,W.jsx)(ve,{}),(0,W.jsx)(Se,{}),(0,W.jsx)($,{children:e})]})}var Te=i.div`
|
|
133
|
-
display: flex;
|
|
134
|
-
align-items: flex-end;
|
|
135
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
136
|
-
flex-wrap: wrap;
|
|
137
|
-
`,Ee=i.h1`
|
|
138
|
-
font-size: 20px;
|
|
139
|
-
font-weight: 600;
|
|
140
|
-
font-stretch: 88%;
|
|
141
|
-
letter-spacing: -0.01em;
|
|
142
|
-
`,De=i.p`
|
|
143
|
-
font-size: 13px;
|
|
144
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
145
|
-
max-width: 68ch;
|
|
146
|
-
`,Oe=i.div`
|
|
147
|
-
display: flex;
|
|
148
|
-
flex-direction: column;
|
|
149
|
-
gap: 6px;
|
|
150
|
-
min-width: 0;
|
|
151
|
-
`;function ke({legend:e,title:t,summary:n,actions:r}){return(0,W.jsxs)(Te,{children:[(0,W.jsxs)(Oe,{children:[(0,W.jsx)(o,{children:e}),(0,W.jsx)(Ee,{children:t}),(0,W.jsx)(De,{children:n})]}),(0,W.jsx)(a,{}),r]})}export{K as a,H as c,L as d,B as f,k as h,ue as i,z as l,U as m,we as n,V as o,F as p,J as r,P as s,ke as t,I as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Nt as e}from"./queries-1zRLkX-Q.js";import{o as t}from"./index-CE-KQ-ju.js";import{i as n,n as r}from"./Rack-DAbY9x1I.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{D as e,F as t,H as n,I as r,K as i,M as a,Nt as o,Pt as s,Qt as c,R as l,V as u,d,f,l as p,o as m,p as h,r as g,s as _,w as v}from"./queries-1zRLkX-Q.js";import{a as y,f as b,h as x,t as S,u as C}from"./Rack-DAbY9x1I.js";import{t as w}from"./CopyValue-B-uR4Js-.js";import{n as T,t as E}from"./Confirm-BnmH8Gn0.js";import{t as D}from"./trash-2-Da6cLgPn.js";import{t as O}from"./Modal-DMFUHQ-A.js";import{t as k}from"./Toggle-Dkjlvck5.js";import{a as A,d as j,i as M,n as N,t as P,u as F}from"./Lamp-CBOwqG5K.js";import{t as I}from"./Chip-C4X8tf5z.js";import{i as L,n as R,r as z,t as B}from"./Field-Ct4SeDZD.js";import{t as V}from"./Meter-COdz0dwY.js";import{a as H,i as U,n as ee,r as te,t as ne}from"./States-D5Memn8D.js";import{i as re,n as W,r as G,t as ie}from"./Table-DObRatbW.js";import{t as ae}from"./catalog-kJ53n_fc.js";var oe=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`}]]),K=c(s(),1),q=o(),se=Object.keys(ae),J={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,custom:`OpenAI Compatible`},Y={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.`,custom:`Enter endpoint metadata and API key.`},ce=i.ol`
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
5
|
-
`,le=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
|
-
`,X=i.p`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.down};
|
|
17
|
-
`,ue=i.p`
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
20
|
-
`;function de({open:e,credentials:n,onOpenChange:r,onConnected:i}){let[o,s]=(0,K.useState)(`anthropic`),[c,d]=(0,K.useState)(``),[f,h]=(0,K.useState)(null),[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(``),S=(n??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[C,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(``),[k,A]=(0,K.useState)(`chat_completions`),[j,M]=(0,K.useState)(``),[N,P]=(0,K.useState)(null),F=_(),I=m(),z=p(),V=(0,K.useCallback)(()=>{h(null),y(``),x(``),T(``),D(``),A(`chat_completions`),M(``),P(null),d(``),F.reset(),I.reset(),z.reset()},[F,I,z]),H=(0,K.useCallback)(e=>{e||V(),r(e)},[r,V]);return(0,K.useEffect)(()=>{if(f===null||f.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await g(f.flowId);if(e)return;if(t.status===`complete`){V(),r(!1),i();return}}catch(t){if(e)return;P(U(t)),h(null);return}e||(n=setTimeout(()=>void t(),f.pollIntervalMs))},n=setTimeout(()=>void t(),f.pollIntervalMs);return()=>{e=!0,clearTimeout(n)}},[f,i,r,V]),(0,q.jsx)(O,{open:e,onOpenChange:H,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:f===null?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(u,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),(0,q.jsx)(u,{type:`button`,$variant:`primary`,disabled:F.isPending||z.isPending,onClick:()=>{if(P(null),o===`custom`){z.mutate({provider:o,apiKey:j,endpointId:b,endpointLabel:C,origin:E,protocol:k,label:c.trim()||void 0},{onSuccess:()=>{V(),r(!1),i()},onError:e=>P(U(e))});return}F.mutate({provider:o,label:c.trim().length===0?J[o]:c.trim()},{onSuccess:e=>h(e),onError:e=>P(U(e))})},children:o===`custom`?z.isPending?`Adding…`:`Add API key`:F.isPending?`Starting…`:`Start authorization`})]}):f.kind===`device`?(0,q.jsx)(u,{type:`button`,onClick:()=>H(!1),children:`Cancel`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(u,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),(0,q.jsx)(u,{type:`button`,$variant:`primary`,disabled:I.isPending||v.trim().length===0,onClick:()=>{f!==null&&(P(null),I.mutate({flowId:f.flowId,code:v.trim()},{onSuccess:()=>{V(),r(!1),i()},onError:e=>P(U(e))}))},children:I.isPending?`Finishing…`:`Finish connecting`})]}),children:(0,q.jsxs)(ce,{children:[f===null?(0,q.jsxs)(l,{$gap:3,children:[(0,q.jsx)(B,{label:`Provider`,children:e=>(0,q.jsx)(L,{...e,value:o,onChange:e=>s(e.target.value),children:se.map(e=>(0,q.jsx)(`option`,{value:e,children:J[e]},e))})}),o===`custom`?(0,q.jsxs)(q.Fragment,{children:[S.length===0?null:(0,q.jsx)(B,{label:`Existing endpoint`,children:e=>(0,q.jsxs)(L,{...e,value:b,onChange:e=>{let t=S.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){x(``),T(``),D(``),A(`chat_completions`);return}x(String(t.providerData.endpointId)),T(String(t.providerData.endpointLabel)),D(String(t.providerData.origin)),A(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[(0,q.jsx)(`option`,{value:``,children:`Create new endpoint`}),S.map(e=>(0,q.jsx)(`option`,{value:String(e.providerData.endpointId),children:String(e.providerData.endpointLabel)},String(e.providerData.endpointId)))]})}),(0,q.jsx)(B,{label:`Endpoint ID`,children:e=>(0,q.jsx)(R,{...e,value:b,onChange:e=>x(e.target.value)})}),(0,q.jsx)(B,{label:`Endpoint label`,children:e=>(0,q.jsx)(R,{...e,value:C,onChange:e=>T(e.target.value)})}),(0,q.jsx)(B,{label:`Server origin`,children:e=>(0,q.jsx)(R,{...e,value:E,placeholder:`https://server.example`,onChange:e=>D(e.target.value)})}),E.trim().toLowerCase().startsWith(`http://`)?(0,q.jsx)(X,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,(0,q.jsx)(B,{label:`Protocol`,children:e=>(0,q.jsxs)(L,{...e,value:k,onChange:e=>A(e.target.value),children:[(0,q.jsx)(`option`,{value:`chat_completions`,children:`Chat Completions (/v1/chat/completions)`}),(0,q.jsx)(`option`,{value:`responses`,children:`Responses (/v1/responses)`})]})}),(0,q.jsx)(B,{label:`API key`,children:e=>(0,q.jsx)(R,{...e,type:`password`,value:j,autoComplete:`off`,onChange:e=>M(e.target.value)})})]}):null,(0,q.jsx)(B,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>(0,q.jsx)(R,{...e,value:c,placeholder:J[o],onChange:e=>d(e.target.value)})})]}):(0,q.jsxs)(l,{$gap:3,children:[(0,q.jsxs)(l,{$gap:1,children:[(0,q.jsx)(a,{children:`Step 1 — authorize`}),(0,q.jsx)(t,{$gap:2,children:(0,q.jsxs)(u,{as:`a`,href:f.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[(0,q.jsx)(oe,{}),`Open `,J[o]]})}),(0,q.jsx)(w,{value:f.authorizeUrl,label:`Copy authorization link`})]}),f.userCode===null?null:(0,q.jsxs)(l,{$gap:1,children:[(0,q.jsx)(a,{children:`Step 2 — enter this code`}),(0,q.jsx)(le,{children:f.userCode})]}),f.kind===`device`?(0,q.jsxs)(ue,{children:[Y[o],` Waiting for authorization…`]}):(0,q.jsx)(B,{label:`Authorization code`,hint:Y[o],...N===null?{}:{problem:N},children:e=>(0,q.jsx)(R,{...e,value:v,autoFocus:!0,placeholder:o===`openai`?`http://localhost:1455/auth/callback?code=…`:`code#state`,onChange:e=>y(e.target.value)})})]}),N===null||f?.kind===`pkce`?null:(0,q.jsx)(X,{children:N})]})})}var fe=[`anthropic`,`openai`,`kimi`,`custom`],Z={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,custom:`OpenAI Compatible`},Q=i(H)`
|
|
21
|
-
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
22
|
-
`,pe=i(R)`
|
|
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
|
-
`,$=i(z)`
|
|
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 _e(){let t=e();return{pending:t.isPending,commit:(e,n)=>{t.mutate({id:e,patch:n})}}}function ve(){let{cadence:e}=y(),i=f(),o=d(e(1e4)),s=v(),c=h(),{commit:p}=_e(),[m,g]=(0,K.useState)(!1),[_,x]=(0,K.useState)(null),w=Date.now(),O=i.data??[],L=A(o.data?.health??[],e=>e.credentialId),R=A(o.data?.quota??[],e=>e.credentialId),z=s.data?.quotaPollIntervalMs??3e5,B=O.filter(e=>e.enabled).length,U=i.isLoading?`Reading connected accounts…`:O.length===0?`No provider credentials are connected, so every request fails at the router.`:`${B} of ${O.length} accounts are enabled and eligible for routing.`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(S,{legend:`Accounts`,title:`Provider accounts`,summary:U,actions:(0,q.jsxs)(u,{type:`button`,$variant:`primary`,onClick:()=>g(!0),children:[(0,q.jsx)(T,{}),`Connect an account`]})}),i.isError?(0,q.jsx)(H,{legend:`Accounts`,children:(0,q.jsx)(ee,{error:i.error,onRetry:()=>void i.refetch()})}):i.isLoading?(0,q.jsx)(H,{legend:`Accounts`,children:(0,q.jsx)(te,{rows:5})}):O.length===0?(0,q.jsx)(H,{legend:`Accounts`,children:(0,q.jsx)(ne,{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,q.jsx)(u,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>g(!0),children:`Connect an account`})})}):(0,q.jsx)(l,{$gap:4,children:fe.filter(e=>O.some(t=>t.provider===e)).map(e=>{let i=O.filter(t=>t.provider===e);return(0,q.jsx)(Q,{$provider:e,legend:Z[e],meta:`${i.length} account${i.length===1?``:`s`}`,flush:!0,children:(0,q.jsx)(r,{children:(0,q.jsxs)(ie,{children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(G,{$width:`24%`,children:`Account`}),(0,q.jsx)(G,{$width:`20%`,children:`Sign-in`}),(0,q.jsx)(G,{$align:`right`,$width:`86px`,children:`Tier`}),(0,q.jsx)(G,{$align:`right`,$width:`94px`,children:`Weight`}),(0,q.jsx)(G,{$align:`center`,$width:`86px`,children:`Enabled`}),(0,q.jsx)(G,{$width:`240px`,children:`Quota`}),(0,q.jsx)(G,{$align:`right`,$width:`88px`,children:`TTFT`}),(0,q.jsx)(G,{$align:`right`,$width:`130px`,children:`Token expires`}),(0,q.jsx)(G,{$width:`48px`})]})}),(0,q.jsx)(`tbody`,{children:i.map(e=>{let r=M(L.get(e.id)??[],w,e.enabled,e.disabledReason),i=j(R.get(e.id)??[]);return(0,q.jsxs)(re,{children:[(0,q.jsxs)(W,{children:[(0,q.jsxs)(t,{$gap:2,children:[(0,q.jsx)(P,{state:r.state,label:r.note===``?`healthy`:r.note}),(0,q.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}p(e.id,{label:n})}})]}),r.note===``?null:(0,q.jsx)(me,{children:r.note})]}),(0,q.jsx)(W,{children:(0,q.jsxs)(t,{$gap:1,children:[(0,q.jsx)(I,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:(0,q.jsx)(a,{children:e.accountEmail})]})}),(0,q.jsx)(W,{$align:`right`,children:(0,q.jsx)($,{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}p(e.id,{tier:n})}})}),(0,q.jsx)(W,{$align:`right`,children:(0,q.jsx)($,{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}p(e.id,{weight:n})}})}),(0,q.jsx)(W,{$align:`center`,children:(0,q.jsx)(k,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>p(e.id,{enabled:t})})}),(0,q.jsx)(W,{children:i.length===0?(0,q.jsx)(a,{children:`unknown`}):(0,q.jsx)(ge,{children:i.map(({window:e,fraction:t})=>(0,q.jsxs)(he,{children:[(0,q.jsx)(V,{fraction:t,label:`${N[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,q.jsx)(a,{children:F(e,w,z,b)})]},e.windowType))})}),(0,q.jsx)(W,{$align:`right`,$mono:!0,children:C(r.ttftMs)}),(0,q.jsx)(W,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:b(e.expiresAt,w)}),(0,q.jsx)(W,{$align:`right`,children:(0,q.jsx)(n,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>x(e),children:(0,q.jsx)(D,{})})})]},e.id)})})]})})},e)})}),(0,q.jsx)(de,{open:m,credentials:i.data??[],onOpenChange:g,onConnected:()=>void i.refetch()}),(0,q.jsx)(E,{open:_!==null,onOpenChange:e=>{e||x(null)},title:`Remove account`,body:_===null?``:`Removing "${_.label}" deletes its stored token. Any model target pointing at ${Z[_.provider]} loses this account, and reconnecting means authorizing again.`,confirmLabel:`Remove account`,busy:c.isPending,onConfirm:()=>{_!==null&&c.mutate(_.id,{onSettled:()=>x(null)})}})]})}var ye=ve;export{ye as component};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import{F as e,I as t,J as n,K as r,L as i,M as a,N as o,Nt as s,O as c,R as l,V as u,b as d,d as f,f as p,j as m,w as h,y as g,z as _}from"./queries-1zRLkX-Q.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-DAbY9x1I.js";import{n as D,t as O}from"./TokenBreakdown-oXP49ZTa.js";import{a as k,c as A,d as j,f as M,i as N,l as P,n as F,r as ee,s as te,t as I,u as L}from"./Lamp-CBOwqG5K.js";import{n as R,t as z}from"./Chip-C4X8tf5z.js";import{t as B}from"./Meter-COdz0dwY.js";import{a as V,n as H,t as U}from"./States-D5Memn8D.js";import{i as W,n as G,r as K,t as q}from"./Table-DObRatbW.js";import{t as J}from"./Readout-Bl2kD9Tl.js";var Y=s(),X=r(_)`
|
|
2
|
-
font-weight: 500;
|
|
3
|
-
display: block;
|
|
4
|
-
max-width: 24ch;
|
|
5
|
-
`,Z=r.span`
|
|
6
|
-
font-size: 11px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
`,ne=r.div`
|
|
9
|
-
display: grid;
|
|
10
|
-
grid-template-columns: 72px 1fr;
|
|
11
|
-
align-items: center;
|
|
12
|
-
gap: 6px;
|
|
13
|
-
min-width: 172px;
|
|
14
|
-
`,re=r.div`
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
gap: 4px;
|
|
18
|
-
`;function ie({credentials:r,health:i,quota:o,usage:s,quotaPollIntervalMs:c,now:l}){let d=k(i,e=>e.credentialId),f=k(o,e=>e.credentialId),p=new Map(s.map(e=>[e.key,e])),m={down:0,warn:1,ok:2,idle:3,live:3},h=r.map(e=>({credential:e,status:N(d.get(e.id)??[],l,e.enabled,e.disabledReason),quota:j(f.get(e.id)??[]),usage:p.get(e.id)})).sort((e,t)=>m[e.status.state]-m[t.status.state]||e.credential.tier-t.credential.tier);return(0,Y.jsx)(V,{legend:`Accounts`,meta:`${r.length} connected`,flush:!0,actions:(0,Y.jsx)(u,{as:n,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:r.length===0?(0,Y.jsx)(U,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:(0,Y.jsx)(u,{as:n,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):(0,Y.jsx)(t,{children:(0,Y.jsxs)(q,{children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(K,{children:`Account`}),(0,Y.jsx)(K,{children:`Provider`}),(0,Y.jsx)(K,{$align:`right`,children:`Tier`}),(0,Y.jsx)(K,{children:`Quota`}),(0,Y.jsx)(K,{$align:`right`,children:`TTFT`}),(0,Y.jsx)(K,{$align:`right`,children:`Requests`}),(0,Y.jsx)(K,{$align:`right`,children:`Last used`})]})}),(0,Y.jsx)(`tbody`,{children:h.map(({credential:t,status:n,quota:r,usage:i})=>(0,Y.jsxs)(W,{children:[(0,Y.jsx)(G,{children:(0,Y.jsxs)(e,{$gap:2,children:[(0,Y.jsx)(I,{state:n.state,label:n.note===``?`healthy`:n.note}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(X,{children:t.label}),n.note===``?null:(0,Y.jsx)(Z,{children:n.note})]})]})}),(0,Y.jsx)(G,{children:(0,Y.jsx)(R,{provider:t.provider})}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:t.tier}),(0,Y.jsx)(G,{children:r.length===0?(0,Y.jsx)(Z,{children:`unknown`}):(0,Y.jsx)(re,{children:r.map(({window:e,fraction:t})=>(0,Y.jsxs)(ne,{children:[(0,Y.jsx)(B,{fraction:t,label:`${F[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,Y.jsx)(a,{children:L(e,l,c,b)})]},e.windowType))})}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:E(n.ttftMs)}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:i===void 0?`—`:w(i.requests)}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:b(n.lastUsedAt,l)})]},t.id))})]})})})}var ae=r.ul`
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
`,oe=r.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=r(_)`
|
|
32
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
max-width: 30ch;
|
|
35
|
-
`,ce=r(o)`
|
|
36
|
-
color: ${({theme:e})=>e.color.down};
|
|
37
|
-
font-size: 11px;
|
|
38
|
-
`;function le({logs:e}){let t=e.slice(0,12);return(0,Y.jsx)(V,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:(0,Y.jsx)(u,{as:n,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?(0,Y.jsx)(U,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):(0,Y.jsx)(ae,{children:t.map(e=>(0,Y.jsxs)(oe,{children:[(0,Y.jsx)(I,{state:P(e),label:A(e)}),(0,Y.jsx)(o,{$dim:!0,children:x(e.at)}),(0,Y.jsx)(se,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:(0,Y.jsx)(o,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),(0,Y.jsx)(i,{}),te(e)?(0,Y.jsx)(o,{$dim:!0,"aria-label":`processing`,children:(0,Y.jsx)(O,{})}):(0,Y.jsxs)(Y.Fragment,{children:[e.errorCode===null?null:(0,Y.jsx)(ce,{children:e.errorCode}),e.attempts>1?(0,Y.jsxs)(o,{$dim:!0,children:[e.attempts,`×`]}):null,(0,Y.jsx)(o,{$dim:!0,children:(0,Y.jsx)(D,{tokens:e})}),(0,Y.jsx)(o,{$dim:!0,children:E(e.durationMs)}),(0,Y.jsx)(o,{$dim:!0,children:S(e.costUsd)})]})]},e.id))})})}var ue=r.ul`
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
42
|
-
`,de=r(_)`
|
|
43
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
44
|
-
font-size: 12.5px;
|
|
45
|
-
`,fe=r.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=r.div`
|
|
53
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
54
|
-
background: ${({$color:e})=>e};
|
|
55
|
-
opacity: 0.8;
|
|
56
|
-
`,me=r.div`
|
|
57
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
58
|
-
`;function Q({models:t,logs:r}){let s=new Map;for(let e of r){let t=s.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,s.set(e.requestedModel,t)}let c=Math.max(1,...[...s.values()].map(e=>e.requests)),l=[...t].map(e=>({model:e,used:s.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return(0,Y.jsx)(V,{legend:`Models`,meta:`${t.length} configured`,actions:(0,Y.jsx)(u,{as:n,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.length===0?(0,Y.jsx)(U,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:(0,Y.jsx)(u,{as:n,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):(0,Y.jsx)(ue,{children:l.map(({model:t,used:n})=>{let r=(n?.requests??0)/c,s=[...new Set(t.targets.map(e=>e.provider))];return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(e,{$gap:2,children:[(0,Y.jsx)(de,{title:t.id,children:t.id}),t.isAlias?(0,Y.jsx)(z,{children:`alias`}):null,(0,Y.jsx)(z,{$tone:`accent`,children:t.strategy}),(0,Y.jsx)(i,{}),(0,Y.jsx)(o,{$dim:!0,children:w(n?.requests??0)}),(0,Y.jsx)(a,{children:`req`}),(0,Y.jsx)(o,{$dim:!0,children:S(n?.costUsd??0)})]}),(0,Y.jsxs)(fe,{style:{marginTop:6},title:`${Math.round(r*100)}% of the busiest model`,children:[s.map(e=>(0,Y.jsx)(pe,{$color:`var(--p-${e})`,$grow:r/s.length},e)),(0,Y.jsx)(me,{$grow:Math.max(0,1-r)})]})]},t.id)})})})}var he=r.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=ee(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,Y.jsxs)(he,{children:[(0,Y.jsx)(J,{legend:`Requests`,value:w(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:(0,Y.jsx)(C,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),(0,Y.jsx)(J,{legend:`Error rate`,value:y(i.errorRate),unit:`${w(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:(0,Y.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,Y.jsx)(J,{legend:`Total tokens`,value:w(s),unit:(0,Y.jsx)(D,{tokens:i}),trace:(0,Y.jsx)(C,{values:a.map(e=>e.tokens),label:`token volume over the window, ${s.toLocaleString(`en-US`)} total`})}),(0,Y.jsx)(J,{legend:`Time to first token`,value:E(i.ttftP50),unit:`p95 ${E(i.ttftP95)}`,trace:(0,Y.jsx)(C,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${E(i.ttftP50)}`})}),(0,Y.jsx)(J,{legend:`Spend`,value:S(i.costUsd),unit:`${w(i.inputTokens+i.outputTokens)} tokens`,trace:(0,Y.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:e}=v(),t=p(),n=f(e(1e4)),r=d(),i=g(500,e(1e4)),a=h(),o=Date.now(),s=Math.floor((o-$)/6e4)*6e4,u=c({groupBy:`credential`,since:s},e(6e4)),_=t.data??[],y=k(n.data?.health??[],e=>e.credentialId),b=_.filter(e=>N(y.get(e.id)??[],o,e.enabled,e.disabledReason).state===`down`),x=t.isLoading||i.isLoading?`Reading the gateway…`:_.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 ${_.length} accounts are answering. Nothing needs attention.`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{legend:`Rack`,title:`Gateway`,summary:x}),i.isError?(0,Y.jsx)(V,{legend:`Traffic`,children:(0,Y.jsx)(H,{legend:`The gateway did not answer`,error:i.error,onRetry:()=>void i.refetch()})}):(0,Y.jsxs)(l,{$gap:4,children:[(0,Y.jsx)(ge,{logs:i.data??[],windowMs:$,now:o}),(0,Y.jsx)(ie,{credentials:_,health:n.data?.health??[],quota:n.data?.quota??[],usage:u.data??[],quotaPollIntervalMs:a.data?.quotaPollIntervalMs??3e5,now:o}),(0,Y.jsxs)(m,{$min:`340px`,$gap:4,children:[(0,Y.jsx)(Q,{models:r.data??[],logs:i.data??[]}),(0,Y.jsx)(le,{logs:i.data??[]})]})]})]})}var ve=_e;export{ve as component};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import{F as e,I as t,K as n,M as r,N as i,Nt as a,Pt as o,Qt as s,R as c,V as l,b as u,g as d,u as f,x as p,z as m}from"./queries-1zRLkX-Q.js";import{c as h,t as g}from"./Rack-DAbY9x1I.js";import{t as _}from"./CopyValue-B-uR4Js-.js";import{n as v,t as y}from"./Confirm-BnmH8Gn0.js";import{t as b}from"./Modal-DMFUHQ-A.js";import{t as x}from"./Toggle-Dkjlvck5.js";import{t as S}from"./Chip-C4X8tf5z.js";import{n as C,t as w}from"./Field-Ct4SeDZD.js";import{a as T,i as E,n as D,r as O,t as k}from"./States-D5Memn8D.js";import{i as A,n as j,r as M,t as N}from"./Table-DObRatbW.js";var P=s(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=u(),o=f(),[s,d]=(0,P.useState)(``),[p,m]=(0,P.useState)(!0),[h,g]=(0,P.useState)([]),[v,y]=(0,P.useState)(``),[S,T]=(0,P.useState)(null),[D,O]=(0,P.useState)(null),k=()=>{d(``),m(!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)(l,{type:`button`,onClick:()=>A(!1),children:`Cancel`}),(0,F.jsx)(l,{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:s.trim().length===0?`api key`:s.trim(),modelAllowlist:p?null:h,rateLimitPerMin:t},{onSuccess:e=>T(e),onError:e=>O(E(e))})},children:o.isPending?`Creating…`:`Create key`})]}):(0,F.jsx)(l,{type:`button`,$variant:`primary`,onClick:()=>A(!1),children:`I have copied the key`}),children:S===null?(0,F.jsxs)(c,{$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:s,placeholder:`api key`,onChange:e=>d(e.target.value)})}),(0,F.jsxs)(c,{$gap:2,children:[(0,F.jsxs)(e,{$gap:2,children:[(0,F.jsx)(x,{checked:p,label:`Allow every model`,onCheckedChange:m}),(0,F.jsx)(r,{as:`span`,children:`Allow every model`})]}),p?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)(c,{$gap:3,children:[(0,F.jsx)(B,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),(0,F.jsx)(_,{value:S.key,label:`Copy API key`}),(0,F.jsxs)(e,{$gap:2,children:[(0,F.jsx)(r,{children:`Label`}),(0,F.jsx)(i,{children:S.label}),(0,F.jsx)(r,{children:`Prefix`}),(0,F.jsx)(i,{children:S.prefix})]})]})})}var H=n(e)`
|
|
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 e=d(),n=p(),[i,a]=(0,P.useState)(!1),[o,s]=(0,P.useState)(null),c=e.data??[],u=c.filter(e=>e.revokedAt===null),f=e.isLoading?`Reading issued keys…`:c.length===0?`No keys exist, so nothing can call this gateway yet.`:`${u.length} active key${u.length===1?``:`s`} of ${c.length} ever issued.`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{legend:`Keys`,title:`Gateway API keys`,summary:f,actions:(0,F.jsxs)(l,{type:`button`,$variant:`primary`,onClick:()=>a(!0),children:[(0,F.jsx)(v,{}),`Create a key`]})}),(0,F.jsx)(T,{legend:`Issued keys`,meta:`${c.length}`,flush:!0,children:e.isError?(0,F.jsx)(D,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?(0,F.jsx)(`div`,{style:{padding:12},children:(0,F.jsx)(O,{rows:4})}):c.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)(l,{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:c.map(e=>(0,F.jsxs)(A,{children:[(0,F.jsx)(j,{children:(0,F.jsx)(m,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),(0,F.jsxs)(j,{$mono:!0,children:[e.prefix,`…`]}),(0,F.jsx)(j,{children:e.modelAllowlist===null?(0,F.jsx)(r,{children:`every model`}):e.modelAllowlist.length===0?(0,F.jsx)(S,{$tone:`down`,children:`no models`}):(0,F.jsx)(H,{children:e.modelAllowlist.map(e=>(0,F.jsx)(S,{children:e},e))})}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:e.rateLimitPerMin===null?`—`:`${e.rateLimitPerMin}/min`}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:h(e.createdAt)}),(0,F.jsx)(j,{children:e.revokedAt===null?(0,F.jsx)(S,{$tone:`ok`,children:`active`}):(0,F.jsx)(U,{title:h(e.revokedAt),children:(0,F.jsx)(S,{children:`revoked`})})}),(0,F.jsx)(j,{$align:`right`,children:e.revokedAt===null?(0,F.jsx)(l,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>s(e),children:`Revoke`}):null})]},e.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:n.isPending,onConfirm:()=>{o!==null&&n.mutate(o.id,{onSettled:()=>s(null)})}})]})}var G=W;export{G as component};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import{F as e,I as t,K as n,M as r,N as ee,Nt as i,Pt as a,Qt as o,R as s,V as te,f as ne,g as re,n as c,y as l,z as u}from"./queries-1zRLkX-Q.js";import{a as d,c as f,l as ie,m as p,o as m,p as h,s as g,t as ae,u as _}from"./Rack-DAbY9x1I.js";import{n as v,r as y,t as b}from"./TokenBreakdown-oXP49ZTa.js";import{t as oe}from"./Modal-DMFUHQ-A.js";import{c as x,l as S,o as C,s as w,t as se}from"./Lamp-CBOwqG5K.js";import{n as ce,t as T}from"./Chip-C4X8tf5z.js";import{i as E,n as D}from"./Field-Ct4SeDZD.js";import{a as O,n as k,r as A,t as j}from"./States-D5Memn8D.js";import{i as M,n as N,r as P,t as F}from"./Table-DObRatbW.js";var I=o(a(),1),L=i(),R=[50,100,250,500],z=n(e)`
|
|
2
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
3
|
-
flex-wrap: wrap;
|
|
4
|
-
`,B=n(D)`
|
|
5
|
-
width: 220px;
|
|
6
|
-
`,V=n(E)`
|
|
7
|
-
width: auto;
|
|
8
|
-
`,H=n(O)`
|
|
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,...w(e)?{"aria-label":`processing`}:{title:y(e)},children:w(e)?(0,L.jsx)(b,{}):(0,L.jsx)(v,{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}=d(),[i,a]=(0,I.useState)(100),[o,v]=(0,I.useState)(`all`),[y,b]=(0,I.useState)(``),[E,D]=(0,I.useState)(null),O=l(i,t(c)),K=ne(),q=re(),de=(O.data??[]).some(w),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=y.trim().toLowerCase(),Q=(O.data??[]).filter(e=>o===`failed`&&!C(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=(O.data??[]).filter(C).length,$=(O.data??[]).filter(w).length;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ae,{legend:`Logs`,title:`Recent requests`,summary:O.isLoading?`Reading the request log…`:`${g(O.data?.length??0)} recent requests, ${g(fe)} of them failed${$===0?``:`, ${g($)} still running`}. Prompt and response bodies are never recorded.`,actions:(0,L.jsxs)(z,{children:[(0,L.jsx)(B,{value:y,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>b(e.target.value)}),(0,L.jsxs)(V,{value:o,"aria-label":`Show which requests`,onChange:e=>v(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:i,"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)(H,{legend:`Request log`,meta:`${Q.length} shown`,flush:!0,children:O.isError?(0,L.jsx)(k,{error:O.error,onRetry:()=>void O.refetch()}):O.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:(O.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(t=>(0,L.jsxs)(M,{$selectable:!0,onClick:()=>D(t),children:[(0,L.jsx)(N,{children:(0,L.jsx)(se,{state:S(t),label:x(t)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,title:f(t.at),children:m(t.at)}),(0,L.jsx)(N,{$mono:!0,children:(0,L.jsx)(u,{style:{display:`block`,maxWidth:`20ch`},children:t.requestedModel||`—`})}),(0,L.jsx)(N,{children:t.resolvedProvider===null?(0,L.jsx)(r,{children:w(t)?`routing…`:`not routed`}):(0,L.jsxs)(e,{$gap:1,children:[(0,L.jsx)(ce,{provider:t.resolvedProvider}),(0,L.jsx)(ee,{$dim:!0,children:t.resolvedModel??`—`})]})}),(0,L.jsx)(N,{children:(0,L.jsx)(u,{style:{display:`block`,maxWidth:`18ch`},children:t.credentialId===null?`—`:Y.get(t.credentialId)??p(t.credentialId)})}),(0,L.jsx)(N,{children:(0,L.jsx)(u,{style:{display:`block`,maxWidth:`16ch`},title:t.apiKeyId??void 0,children:t.apiKeyId===null?`—`:X.get(t.apiKeyId)??p(t.apiKeyId)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?`—`:t.attempts}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?`—`:_(t.ttftMs)}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?ie(Math.max(0,J-t.at)):_(t.durationMs)}),(0,L.jsx)(le,{log:t}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?`—`:h(t.costUsd)}),(0,L.jsx)(N,{children:w(t)?(0,L.jsx)(T,{$tone:`accent`,children:`live`}):t.errorCode===null?(0,L.jsx)(T,{$tone:`ok`,children:t.status}):(0,L.jsx)(T,{$tone:`down`,children:t.errorCode})})]},t.id))})]})})}),(0,L.jsx)(oe,{open:E!==null,onOpenChange:e=>{e||D(null)},title:`Request detail`,width:`600px`,footer:(0,L.jsx)(te,{type:`button`,onClick:()=>D(null),children:`Close`}),children:E===null?null:(0,L.jsxs)(s,{$gap:3,children:[(0,L.jsxs)(ue,{children:[(0,L.jsx)(r,{as:`dt`,children:`Request id`}),(0,L.jsx)(G,{children:E.id}),(0,L.jsx)(r,{as:`dt`,children:`At`}),(0,L.jsx)(G,{children:f(E.at)}),(0,L.jsx)(r,{as:`dt`,children:`Requested model`}),(0,L.jsx)(G,{children:E.requestedModel||`—`}),(0,L.jsx)(r,{as:`dt`,children:`Routed to`}),(0,L.jsx)(G,{children:w(E)?`—`:E.resolvedProvider===null?`not routed`:`${E.resolvedProvider} · ${E.resolvedModel??`—`}`}),(0,L.jsx)(r,{as:`dt`,children:`Account`}),(0,L.jsx)(G,{children:E.credentialId===null?`—`:Y.get(E.credentialId)??E.credentialId}),(0,L.jsx)(r,{as:`dt`,children:`Key`}),(0,L.jsx)(G,{children:E.apiKeyId===null?`—`:X.get(E.apiKeyId)??E.apiKeyId}),(0,L.jsx)(r,{as:`dt`,children:`Attempts`}),(0,L.jsx)(G,{children:w(E)?`—`:E.attempts}),(0,L.jsx)(r,{as:`dt`,children:`Status`}),(0,L.jsx)(G,{children:w(E)?`in flight`:E.errorCode===null?E.status:`${E.status} ${E.errorCode}`}),(0,L.jsx)(r,{as:`dt`,children:`Timing`}),(0,L.jsx)(G,{children:w(E)?`—`:`first token ${_(E.ttftMs)} · total ${_(E.durationMs)}`}),(0,L.jsx)(r,{as:`dt`,children:`Tokens`}),(0,L.jsx)(G,{children:w(E)?`—`:(0,L.jsxs)(L.Fragment,{children:[g(E.inputTokens),` in · `,g(E.outputTokens),` out ·`,` `,g(E.cacheReadTokens),` cache read ·`,` `,g(E.cacheWriteTokens),` cache write`]})}),(0,L.jsx)(r,{as:`dt`,children:`Cost`}),(0,L.jsx)(G,{children:w(E)?`—`:h(E.costUsd)}),(0,L.jsx)(r,{as:`dt`,children:`RTK compression`}),(0,L.jsx)(G,{children:w(E)?`—`:E.rtkApplied?`${g(E.rtkFilterHits)} hits · ${g(E.rtkOriginalCodeUnits)} → ${g(E.rtkCompressedCodeUnits)} code units · ~${g(E.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),(0,L.jsx)(r,{as:`dt`,children:`RTK filters`}),(0,L.jsx)(G,{children:E.rtkFilters.length===0?`—`:E.rtkFilters.join(`, `)})]}),E.degradations.length===0?null:(0,L.jsxs)(s,{$gap:1,children:[(0,L.jsx)(r,{children:`Capabilities dropped to fit the target`}),(0,L.jsx)(e,{$gap:1,$wrap:!0,children:E.degradations.map(e=>(0,L.jsx)(T,{$tone:`warn`,children:e},e))})]})]})})]})}var q=K;export{q as component};
|