omnigateway 0.2.0 → 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.
Files changed (47) hide show
  1. package/README.md +94 -7
  2. package/bin/omni.js +4954 -2939
  3. package/gateway.js +3132 -1164
  4. package/package.json +1 -1
  5. package/public/assets/{Chip-BB_5C1Zp.js → Chip-DJwp7gBu.js} +2 -2
  6. package/public/assets/{Confirm-B6aAiVbT.js → Confirm-CVLz9F7a.js} +1 -1
  7. package/public/assets/CopyValue-CNZbWS59.js +27 -0
  8. package/public/assets/{Field-uHZxl4fI.js → Field-BDtp692L.js} +8 -8
  9. package/public/assets/Lamp-B65uWKbW.js +25 -0
  10. package/public/assets/{Meter-DI_BRUKt.js → Meter-BREBUFGX.js} +2 -2
  11. package/public/assets/{Modal-CI6jk2D4.js → Modal-DbydSAlp.js} +8 -8
  12. package/public/assets/Rack-Bbo4JfEX.js +151 -0
  13. package/public/assets/{Readout-BocZ2HXP.js → Readout-CEAoN5hu.js} +9 -5
  14. package/public/assets/{States-Bbiu5cHE.js → States-BEKLros0.js} +10 -10
  15. package/public/assets/{Table-CdPWxYaz.js → Table-BBypbVWj.js} +1 -1
  16. package/public/assets/{Toggle-CiLC67Dw.js → Toggle-BUr71O4J.js} +2 -2
  17. package/public/assets/{TokenBreakdown-B96iPBm9.js → TokenBreakdown-C1ziK9d1.js} +6 -3
  18. package/public/assets/_app-ByQ1bPbe.js +1 -0
  19. package/public/assets/_app.accounts-BTug_Xfo.js +64 -0
  20. package/public/assets/{_app.console-Daz4aKhf.js → _app.console-DKyGL9xx.js} +10 -10
  21. package/public/assets/_app.index-CSw9gmMf.js +62 -0
  22. package/public/assets/_app.keys-07Kbw4RS.js +39 -0
  23. package/public/assets/_app.logs-C9QiV39p.js +32 -0
  24. package/public/assets/_app.models-CDqVrAeF.js +148 -0
  25. package/public/assets/{_app.settings-a0FKyQAi.js → _app.settings-DmUEeTaP.js} +10 -10
  26. package/public/assets/_app.usage-B1WuMGRr.js +83 -0
  27. package/public/assets/catalog-BBKm8Ih8.js +1 -0
  28. package/public/assets/{dist-C-IbPRiV.js → dist-Bka7ErcH.js} +1 -1
  29. package/public/assets/index-DJfb1i4P.js +186 -0
  30. package/public/assets/{login-CTvH_KAd.js → login-DKZYqRh0.js} +8 -8
  31. package/public/assets/queries-D8LJNQpL.js +144 -0
  32. package/public/assets/shared-CIhZ6FCO.js +84 -0
  33. package/public/assets/{trash-2-BcZb-sCT.js → trash-2-CLYNAAJA.js} +1 -1
  34. package/public/index.html +2 -2
  35. package/public/assets/CopyValue-CRQDLo7k.js +0 -27
  36. package/public/assets/Lamp-B-5SjXbG.js +0 -25
  37. package/public/assets/Rack-D1WJswv3.js +0 -151
  38. package/public/assets/_app-BBOF6A0T.js +0 -1
  39. package/public/assets/_app.accounts-BNkhpvaB.js +0 -54
  40. package/public/assets/_app.index-LO6d38oe.js +0 -62
  41. package/public/assets/_app.keys-kBqLqoFf.js +0 -39
  42. package/public/assets/_app.logs-_wYNS47N.js +0 -32
  43. package/public/assets/_app.models-Cjng8ohC.js +0 -144
  44. package/public/assets/_app.usage-D3KtgLrC.js +0 -166
  45. package/public/assets/catalog-C_OQ0icG.js +0 -1
  46. package/public/assets/index-PW6EvVh5.js +0 -170
  47. package/public/assets/queries-D2o-X8Pj.js +0 -144
@@ -1 +1 @@
1
- import{h as e}from"./Rack-D1WJswv3.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};
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-PW6EvVh5.js"></script>
10
- <link rel="modulepreload" crossorigin href="/assets/queries-D2o-X8Pj.js">
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,27 +0,0 @@
1
- import{G as e,L as t,Mt as n,Nt as r,V as i,Zt as a}from"./queries-D2o-X8Pj.js";import{h as o}from"./Rack-D1WJswv3.js";var s=o(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),c=o(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),l=a(r(),1);function u(e){if(e===null||typeof getSelection!=`function`)return!1;let t=getSelection();if(t===null)return!1;try{let n=document.createRange();return n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),!0}catch{return!1}}async function d(e,t){if(typeof navigator<`u`&&navigator.clipboard!==void 0)try{return await navigator.clipboard.writeText(e),`copied`}catch{}let n=u(t??null);if(n&&typeof document.execCommand==`function`)try{if(document.execCommand(`copy`))return`copied`}catch{}return n?`selected`:`failed`}var f=n(),p=e.div`
2
- display: flex;
3
- align-items: stretch;
4
- gap: 0;
5
- border: 1px solid ${({theme:e})=>e.color.ruleStrong};
6
- border-radius: ${({theme:e})=>e.radius.control};
7
- background: ${({theme:e})=>e.color.panelSunk};
8
- overflow: hidden;
9
- `,m=e.code`
10
- flex: 1;
11
- min-width: 0;
12
- padding: 7px 8px;
13
- font-family: ${({theme:e})=>e.font.mono};
14
- font-size: 12px;
15
- word-break: break-all;
16
- user-select: all;
17
- `,h=e(i)`
18
- border: 0;
19
- border-left: 1px solid ${({theme:e})=>e.color.ruleStrong};
20
- border-radius: 0;
21
- height: auto;
22
- width: 32px;
23
- flex: none;
24
- `,g=e.p`
25
- font-size: 11px;
26
- color: ${({theme:e})=>e.color.warn};
27
- `,_={selected:`Your browser would not copy it. The value is selected — copy it with your keyboard.`,failed:`Your browser would not copy it. Select the value and copy it by hand.`};function v({value:e,label:n}){let[r,i]=(0,l.useState)(null),a=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(r!==`copied`)return;let e=setTimeout(()=>i(null),1600);return()=>clearTimeout(e)},[r]);let o=(0,l.useCallback)(()=>{d(e,a.current).then(i)},[e]),u=r===`copied`,v=r===null?void 0:_[r];return(0,f.jsxs)(t,{$gap:1,children:[(0,f.jsxs)(p,{children:[(0,f.jsx)(m,{ref:a,children:e}),(0,f.jsx)(h,{type:`button`,$variant:`ghost`,onClick:o,"aria-label":u?`Copied`:n,title:u?`Copied`:n,children:u?(0,f.jsx)(s,{}):(0,f.jsx)(c,{})})]}),v===void 0?null:(0,f.jsx)(g,{role:`status`,children:v})]})}export{v as t};
@@ -1,25 +0,0 @@
1
- import{G as e,H as t,Mt as n,W as r}from"./queries-D2o-X8Pj.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=t`
2
- 0%, 100% { opacity: 1; }
3
- 50% { opacity: 0.28; }
4
- `,w=r`
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:r`
12
- color: ${({theme:e})=>e.color.ok};
13
- `,warn:r`
14
- color: ${({theme:e})=>e.color.warn};
15
- `,down:r`
16
- color: ${({theme:e})=>e.color.down};
17
- `,idle:r`
18
- color: ${({theme:e})=>e.color.inkFaint};
19
- `,live:w},E=e.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,G as t,I as n,M as r,Mt as i,Nt as a,P as o,V as s,Y as c,Zt as l,_ as u,j as d,q as f,v as p,z as m}from"./queries-D2o-X8Pj.js";import{t as h}from"./index-PW6EvVh5.js";import{f as g,r as _,t as v}from"./Lamp-B-5SjXbG.js";var y=l(a(),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=i(),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=t.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=t.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
- ${m}
16
- position: sticky;
17
- top: 0;
18
- z-index: ${({theme:e})=>e.z.chassis};
19
- `,pe=t.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=t(o)`
30
- gap: ${({theme:e})=>e.space(3)};
31
- overflow: hidden;
32
-
33
- @media (max-width: 860px) {
34
- display: none;
35
- }
36
- `,Y=t.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=t(Y)`
44
- width: 96px;
45
- align-items: center;
46
- `,ge=t.div`
47
- flex: 1;
48
- min-width: 0;
49
- `,_e=t(e)`
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=c(),{live:t,toggle:i,cadence:a}=K(),{mode:o,setMode:l}=h(),f=u(),m=p(200,a(1e4)),b=Date.now(),x=(0,y.useMemo)(()=>(m.data??[]).filter(e=>b-e.at<=Q),[m.data,b]),S=g(x,Q),C=_(x,{now:b,spanMs:Q,count:24}),w=X[(X.indexOf(o)+1)%X.length]??`system`,T=o===`light`?le:o===`dark`?oe:ae,E=m.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:m.isError?`gateway unreachable`:`error rate ${L(S.errorRate)}`}),`Omnigateway`]}),(0,W.jsxs)(me,{children:[(0,W.jsxs)(he,{children:[(0,W.jsx)(d,{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)(d,{children:`rate`}),(0,W.jsx)(r,{children:S.ratePerMin.toFixed(1)}),(0,W.jsx)(d,{children:`/min`})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(d,{children:`err`}),(0,W.jsx)(r,{style:{color:S.errorRate>=.05?`var(--down)`:void 0},children:L(S.errorRate)})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(d,{children:`ttft p50`}),(0,W.jsx)(r,{children:I(S.ttftP50)})]}),(0,W.jsxs)(Y,{children:[(0,W.jsx)(d,{children:`spend`}),(0,W.jsx)(r,{children:F(S.costUsd)})]})]}),(0,W.jsx)(n,{}),(0,W.jsxs)(_e,{type:`button`,$size:`sm`,onClick:i,"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)(s,{type:`button`,$variant:`ghost`,$size:`sm`,onClick:()=>l(w),"aria-label":Z[o],title:`${Z[o]} — switch to ${Z[w].toLowerCase()}`,children:(0,W.jsx)(T,{})}),(0,W.jsx)(s,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Sign out`,title:`Sign out`,disabled:f.isPending,onClick:()=>{f.mutate(void 0,{onSuccess:()=>void e({to:`/login`})})},children:(0,W.jsx)(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=t.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=t(f)`
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=t.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
- `,$=t.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=t.div`
133
- display: flex;
134
- align-items: flex-end;
135
- gap: ${({theme:e})=>e.space(3)};
136
- flex-wrap: wrap;
137
- `,Ee=t.h1`
138
- font-size: 20px;
139
- font-weight: 600;
140
- font-stretch: 88%;
141
- letter-spacing: -0.01em;
142
- `,De=t.p`
143
- font-size: 13px;
144
- color: ${({theme:e})=>e.color.inkDim};
145
- max-width: 68ch;
146
- `,Oe=t.div`
147
- display: flex;
148
- flex-direction: column;
149
- gap: 6px;
150
- min-width: 0;
151
- `;function ke({legend:e,title:t,summary:r,actions:i}){return(0,W.jsxs)(Te,{children:[(0,W.jsxs)(Oe,{children:[(0,W.jsx)(d,{children:e}),(0,W.jsx)(Ee,{children:t}),(0,W.jsx)(De,{children:r})]}),(0,W.jsx)(n,{}),i]})}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{Mt as e}from"./queries-D2o-X8Pj.js";import{o as t}from"./index-PW6EvVh5.js";import{i as n,n as r}from"./Rack-D1WJswv3.js";var i=e(),a=()=>(0,i.jsx)(n,{children:(0,i.jsx)(r,{children:(0,i.jsx)(t,{})})});export{a as component};
@@ -1,54 +0,0 @@
1
- import{B as e,C as t,E as n,F as r,G as i,L as a,Mt as o,Nt as s,P as c,V as l,Zt as u,d,f,j as p,o as m,r as h,s as g,u as _}from"./queries-D2o-X8Pj.js";import{a as v,f as y,h as b,t as x,u as S}from"./Rack-D1WJswv3.js";import{t as C}from"./CopyValue-CRQDLo7k.js";import{n as w,t as T}from"./Confirm-B6aAiVbT.js";import{t as ee}from"./trash-2-BcZb-sCT.js";import{t as E}from"./Modal-CI6jk2D4.js";import{t as D}from"./Toggle-CiLC67Dw.js";import{a as O,d as te,i as ne,n as re,t as k,u as A}from"./Lamp-B-5SjXbG.js";import{t as j}from"./Chip-BB_5C1Zp.js";import{i as M,n as N,r as P,t as F}from"./Field-uHZxl4fI.js";import{t as ie}from"./Meter-DI_BRUKt.js";import{a as I,i as L,n as R,r as z,t as B}from"./States-Bbiu5cHE.js";import{i as V,n as H,r as U,t as W}from"./Table-CdPWxYaz.js";import{t as G}from"./catalog-C_OQ0icG.js";var K=b(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),q=u(s(),1),J=o(),ae=Object.keys(G),Y={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`},X={anthropic:`Authorize in the browser, then paste the code Anthropic shows you.`,openai:`Authorize in the browser. When it redirects to localhost, paste the whole URL.`,kimi:`Enter the code on Kimi's device page. This dialog finishes on its own.`},oe=i.ol`
2
- display: flex;
3
- flex-direction: column;
4
- gap: ${({theme:e})=>e.space(3)};
5
- `,se=i.div`
6
- font-family: ${({theme:e})=>e.font.mono};
7
- font-size: 26px;
8
- letter-spacing: 0.22em;
9
- text-align: center;
10
- padding: ${({theme:e})=>e.space(3)};
11
- background: ${({theme:e})=>e.color.panelSunk};
12
- border: 1px solid ${({theme:e})=>e.color.ruleStrong};
13
- border-radius: ${({theme:e})=>e.radius.control};
14
- `,ce=i.p`
15
- font-size: 12px;
16
- color: ${({theme:e})=>e.color.down};
17
- `,le=i.p`
18
- font-size: 12px;
19
- color: ${({theme:e})=>e.color.inkDim};
20
- `;function ue({open:t,onOpenChange:n,onConnected:r}){let[i,o]=(0,q.useState)(`anthropic`),[s,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(null),[f,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(null),b=g(),x=m(),S=(0,q.useCallback)(()=>{d(null),_(``),y(null),l(``),b.reset(),x.reset()},[b,x]),w=(0,q.useCallback)(e=>{e||S(),n(e)},[n,S]);return(0,q.useEffect)(()=>{if(u===null||u.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await h(u.flowId);if(e)return;if(t.status===`complete`){S(),n(!1),r();return}}catch(t){if(e)return;y(L(t)),d(null);return}e||(i=setTimeout(()=>void t(),u.pollIntervalMs))},i=setTimeout(()=>void t(),u.pollIntervalMs);return()=>{e=!0,clearTimeout(i)}},[u,r,n,S]),(0,J.jsx)(E,{open:t,onOpenChange:w,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:u===null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(e,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(e,{type:`button`,$variant:`primary`,disabled:b.isPending,onClick:()=>{y(null),b.mutate({provider:i,label:s.trim().length===0?Y[i]:s.trim()},{onSuccess:e=>d(e),onError:e=>y(L(e))})},children:b.isPending?`Starting…`:`Start authorization`})]}):u.kind===`device`?(0,J.jsx)(e,{type:`button`,onClick:()=>w(!1),children:`Cancel`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(e,{type:`button`,onClick:()=>w(!1),children:`Cancel`}),(0,J.jsx)(e,{type:`button`,$variant:`primary`,disabled:x.isPending||f.trim().length===0,onClick:()=>{u!==null&&(y(null),x.mutate({flowId:u.flowId,code:f.trim()},{onSuccess:()=>{S(),n(!1),r()},onError:e=>y(L(e))}))},children:x.isPending?`Finishing…`:`Finish connecting`})]}),children:(0,J.jsxs)(oe,{children:[u===null?(0,J.jsxs)(a,{$gap:3,children:[(0,J.jsx)(F,{label:`Provider`,children:e=>(0,J.jsx)(M,{...e,value:i,onChange:e=>o(e.target.value),children:ae.map(e=>(0,J.jsx)(`option`,{value:e,children:Y[e]},e))})}),(0,J.jsx)(F,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>(0,J.jsx)(N,{...e,value:s,placeholder:Y[i],onChange:e=>l(e.target.value)})})]}):(0,J.jsxs)(a,{$gap:3,children:[(0,J.jsxs)(a,{$gap:1,children:[(0,J.jsx)(p,{children:`Step 1 — authorize`}),(0,J.jsx)(c,{$gap:2,children:(0,J.jsxs)(e,{as:`a`,href:u.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[(0,J.jsx)(K,{}),`Open `,Y[i]]})}),(0,J.jsx)(C,{value:u.authorizeUrl,label:`Copy authorization link`})]}),u.userCode===null?null:(0,J.jsxs)(a,{$gap:1,children:[(0,J.jsx)(p,{children:`Step 2 — enter this code`}),(0,J.jsx)(se,{children:u.userCode})]}),u.kind===`device`?(0,J.jsxs)(le,{children:[X[i],` Waiting for authorization…`]}):(0,J.jsx)(F,{label:`Authorization code`,hint:X[i],...v===null?{}:{problem:v},children:e=>(0,J.jsx)(N,{...e,value:f,autoFocus:!0,placeholder:i===`openai`?`http://localhost:1455/auth/callback?code=…`:`code#state`,onChange:e=>_(e.target.value)})})]}),v===null||u?.kind===`pkce`?null:(0,J.jsx)(ce,{children:v})]})})}var de=[`anthropic`,`openai`,`kimi`],Z={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`},fe=i(I)`
21
- border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
22
- `,pe=i(N)`
23
- width: 100%;
24
- min-width: 140px;
25
- height: 26px;
26
- font-family: ${({theme:e})=>e.font.sans};
27
- font-size: 12.5px;
28
- background: transparent;
29
- border-color: transparent;
30
-
31
- &:hover:not(:disabled),
32
- &:focus {
33
- background: ${({theme:e})=>e.color.panelSunk};
34
- border-color: ${({theme:e})=>e.color.ruleStrong};
35
- }
36
- `,Q=i(P)`
37
- width: 62px;
38
- height: 26px;
39
- `,me=i.span`
40
- display: block;
41
- padding-left: 9px;
42
- font-size: 11px;
43
- color: ${({theme:e})=>e.color.inkDim};
44
- `,he=i.div`
45
- display: grid;
46
- grid-template-columns: 96px 1fr;
47
- align-items: center;
48
- min-width: 208px;
49
- gap: 6px;
50
- `,ge=i.div`
51
- display: flex;
52
- flex-direction: column;
53
- gap: 4px;
54
- `;function $(){let e=n();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function _e(){let{cadence:n}=v(),i=d(),o=_(n(1e4)),s=t(),u=f(),{commit:m}=$(),[h,g]=(0,q.useState)(!1),[b,C]=(0,q.useState)(null),E=Date.now(),M=i.data??[],N=O(o.data?.health??[],e=>e.credentialId),P=O(o.data?.quota??[],e=>e.credentialId),F=s.data?.quotaPollIntervalMs??3e5,L=M.filter(e=>e.enabled).length,G=i.isLoading?`Reading connected accounts…`:M.length===0?`No provider credentials are connected, so every request fails at the router.`:`${L} of ${M.length} accounts are enabled and eligible for routing.`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(x,{legend:`Accounts`,title:`Provider accounts`,summary:G,actions:(0,J.jsxs)(e,{type:`button`,$variant:`primary`,onClick:()=>g(!0),children:[(0,J.jsx)(w,{}),`Connect an account`]})}),i.isError?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(R,{error:i.error,onRetry:()=>void i.refetch()})}):i.isLoading?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(z,{rows:5})}):M.length===0?(0,J.jsx)(I,{legend:`Accounts`,children:(0,J.jsx)(B,{legend:`Nothing connected`,message:`Connect a provider account to give the router something to dispatch to. Tokens are encrypted at rest and never shown again.`,action:(0,J.jsx)(e,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>g(!0),children:`Connect an account`})})}):(0,J.jsx)(a,{$gap:4,children:de.filter(e=>M.some(t=>t.provider===e)).map(e=>{let t=M.filter(t=>t.provider===e);return(0,J.jsx)(fe,{$provider:e,legend:Z[e],meta:`${t.length} account${t.length===1?``:`s`}`,flush:!0,children:(0,J.jsx)(r,{children:(0,J.jsxs)(W,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(U,{$width:`24%`,children:`Account`}),(0,J.jsx)(U,{$width:`20%`,children:`Sign-in`}),(0,J.jsx)(U,{$align:`right`,$width:`86px`,children:`Tier`}),(0,J.jsx)(U,{$align:`right`,$width:`94px`,children:`Weight`}),(0,J.jsx)(U,{$align:`center`,$width:`86px`,children:`Enabled`}),(0,J.jsx)(U,{$width:`240px`,children:`Quota`}),(0,J.jsx)(U,{$align:`right`,$width:`88px`,children:`TTFT`}),(0,J.jsx)(U,{$align:`right`,$width:`130px`,children:`Token expires`}),(0,J.jsx)(U,{$width:`48px`})]})}),(0,J.jsx)(`tbody`,{children:t.map(e=>{let t=ne(N.get(e.id)??[],E,e.enabled,e.disabledReason),n=te(P.get(e.id)??[]);return(0,J.jsxs)(V,{children:[(0,J.jsxs)(H,{children:[(0,J.jsxs)(c,{$gap:2,children:[(0,J.jsx)(k,{state:t.state,label:t.note===``?`healthy`:t.note}),(0,J.jsx)(pe,{defaultValue:e.label,"aria-label":`Label for ${e.label}`,onBlur:t=>{let n=t.target.value.trim();if(n.length===0||n===e.label){t.target.value=e.label;return}m(e.id,{label:n})}})]}),t.note===``?null:(0,J.jsx)(me,{children:t.note})]}),(0,J.jsx)(H,{children:(0,J.jsxs)(c,{$gap:1,children:[(0,J.jsx)(j,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:(0,J.jsx)(p,{children:e.accountEmail})]})}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(Q,{min:1,step:1,defaultValue:e.tier,"aria-label":`Tier for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isInteger(n)||n<1||n===e.tier){t.target.value=String(e.tier);return}m(e.id,{tier:n})}})}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(Q,{min:.1,step:.1,defaultValue:e.weight,"aria-label":`Weight for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isFinite(n)||n<=0||n===e.weight){t.target.value=String(e.weight);return}m(e.id,{weight:n})}})}),(0,J.jsx)(H,{$align:`center`,children:(0,J.jsx)(D,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>m(e.id,{enabled:t})})}),(0,J.jsx)(H,{children:n.length===0?(0,J.jsx)(p,{children:`unknown`}):(0,J.jsx)(ge,{children:n.map(({window:e,fraction:t})=>(0,J.jsxs)(he,{children:[(0,J.jsx)(ie,{fraction:t,label:`${re[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,J.jsx)(p,{children:A(e,E,F,y)})]},e.windowType))})}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:S(t.ttftMs)}),(0,J.jsx)(H,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:y(e.expiresAt,E)}),(0,J.jsx)(H,{$align:`right`,children:(0,J.jsx)(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>C(e),children:(0,J.jsx)(ee,{})})})]},e.id)})})]})})},e)})}),(0,J.jsx)(ue,{open:h,onOpenChange:g,onConnected:()=>void i.refetch()}),(0,J.jsx)(T,{open:b!==null,onOpenChange:e=>{e||C(null)},title:`Remove account`,body:b===null?``:`Removing "${b.label}" deletes its stored token. Any model target pointing at ${Z[b.provider]} loses this account, and reconnecting means authorizing again.`,confirmLabel:`Remove account`,busy:u.isPending,onConfirm:()=>{b!==null&&u.mutate(b.id,{onSettled:()=>C(null)})}})]})}var ve=_e;export{ve as component};
@@ -1,62 +0,0 @@
1
- import{A as e,B as t,C as n,D as r,F as i,G as a,I as o,L as s,M as c,Mt as l,P as u,R as d,d as f,j as p,q as m,u as h,v as g,y as _}from"./queries-D2o-X8Pj.js";import{a as v,d as y,f as b,o as x,p as S,r as C,s as w,t as T,u as E}from"./Rack-D1WJswv3.js";import{n as D,t as O}from"./TokenBreakdown-B96iPBm9.js";import{a as k,c as A,d as j,f as M,i as N,l as ee,n as te,r as ne,s as P,t as F,u as I}from"./Lamp-B-5SjXbG.js";import{n as L,t as R}from"./Chip-BB_5C1Zp.js";import{t as z}from"./Meter-DI_BRUKt.js";import{a as B,n as V,t as H}from"./States-Bbiu5cHE.js";import{i as U,n as W,r as G,t as K}from"./Table-CdPWxYaz.js";import{t as q}from"./Readout-BocZ2HXP.js";var J=l(),Y=a(d)`
2
- font-weight: 500;
3
- display: block;
4
- max-width: 24ch;
5
- `,X=a.span`
6
- font-size: 11px;
7
- color: ${({theme:e})=>e.color.inkDim};
8
- `,Z=a.div`
9
- display: grid;
10
- grid-template-columns: 72px 1fr;
11
- align-items: center;
12
- gap: 6px;
13
- min-width: 172px;
14
- `,re=a.div`
15
- display: flex;
16
- flex-direction: column;
17
- gap: 4px;
18
- `;function ie({credentials:e,health:n,quota:r,usage:a,quotaPollIntervalMs:o,now:s}){let c=k(n,e=>e.credentialId),l=k(r,e=>e.credentialId),d=new Map(a.map(e=>[e.key,e])),f={down:0,warn:1,ok:2,idle:3,live:3},h=e.map(e=>({credential:e,status:N(c.get(e.id)??[],s,e.enabled,e.disabledReason),quota:j(l.get(e.id)??[]),usage:d.get(e.id)})).sort((e,t)=>f[e.status.state]-f[t.status.state]||e.credential.tier-t.credential.tier);return(0,J.jsx)(B,{legend:`Accounts`,meta:`${e.length} connected`,flush:!0,actions:(0,J.jsx)(t,{as:m,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:e.length===0?(0,J.jsx)(H,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:(0,J.jsx)(t,{as:m,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):(0,J.jsx)(i,{children:(0,J.jsxs)(K,{children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(G,{children:`Account`}),(0,J.jsx)(G,{children:`Provider`}),(0,J.jsx)(G,{$align:`right`,children:`Tier`}),(0,J.jsx)(G,{children:`Quota`}),(0,J.jsx)(G,{$align:`right`,children:`TTFT`}),(0,J.jsx)(G,{$align:`right`,children:`Requests`}),(0,J.jsx)(G,{$align:`right`,children:`Last used`})]})}),(0,J.jsx)(`tbody`,{children:h.map(({credential:e,status:t,quota:n,usage:r})=>(0,J.jsxs)(U,{children:[(0,J.jsx)(W,{children:(0,J.jsxs)(u,{$gap:2,children:[(0,J.jsx)(F,{state:t.state,label:t.note===``?`healthy`:t.note}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(Y,{children:e.label}),t.note===``?null:(0,J.jsx)(X,{children:t.note})]})]})}),(0,J.jsx)(W,{children:(0,J.jsx)(L,{provider:e.provider})}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:e.tier}),(0,J.jsx)(W,{children:n.length===0?(0,J.jsx)(X,{children:`unknown`}):(0,J.jsx)(re,{children:n.map(({window:e,fraction:t})=>(0,J.jsxs)(Z,{children:[(0,J.jsx)(z,{fraction:t,label:`${te[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,J.jsx)(p,{children:I(e,s,o,b)})]},e.windowType))})}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:E(t.ttftMs)}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:r===void 0?`—`:w(r.requests)}),(0,J.jsx)(W,{$align:`right`,$mono:!0,children:b(t.lastUsedAt,s)})]},e.id))})]})})})}var ae=a.ul`
19
- display: flex;
20
- flex-direction: column;
21
- `,oe=a.li`
22
- display: flex;
23
- align-items: center;
24
- gap: ${({theme:e})=>e.space(2)};
25
- padding: 6px ${({theme:e})=>e.space(3)};
26
- border-bottom: 1px solid ${({theme:e})=>e.color.rule};
27
-
28
- &:last-child {
29
- border-bottom: 0;
30
- }
31
- `,se=a(d)`
32
- font-family: ${({theme:e})=>e.font.mono};
33
- font-size: 12px;
34
- max-width: 30ch;
35
- `,ce=a(c)`
36
- color: ${({theme:e})=>e.color.down};
37
- font-size: 11px;
38
- `;function le({logs:e}){let n=e.slice(0,12);return(0,J.jsx)(B,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:(0,J.jsx)(t,{as:m,to:`/logs`,$size:`sm`,children:`Open logs`}),children:n.length===0?(0,J.jsx)(H,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):(0,J.jsx)(ae,{children:n.map(e=>(0,J.jsxs)(oe,{children:[(0,J.jsx)(F,{state:ee(e),label:A(e)}),(0,J.jsx)(c,{$dim:!0,children:x(e.at)}),(0,J.jsx)(se,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:(0,J.jsx)(c,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),(0,J.jsx)(o,{}),P(e)?(0,J.jsx)(c,{$dim:!0,"aria-label":`processing`,children:(0,J.jsx)(O,{})}):(0,J.jsxs)(J.Fragment,{children:[e.errorCode===null?null:(0,J.jsx)(ce,{children:e.errorCode}),e.attempts>1?(0,J.jsxs)(c,{$dim:!0,children:[e.attempts,`×`]}):null,(0,J.jsx)(c,{$dim:!0,children:(0,J.jsx)(D,{tokens:e})}),(0,J.jsx)(c,{$dim:!0,children:E(e.durationMs)}),(0,J.jsx)(c,{$dim:!0,children:S(e.costUsd)})]})]},e.id))})})}var ue=a.ul`
39
- display: flex;
40
- flex-direction: column;
41
- gap: ${({theme:e})=>e.space(3)};
42
- `,de=a(d)`
43
- font-family: ${({theme:e})=>e.font.mono};
44
- font-size: 12.5px;
45
- `,fe=a.div`
46
- display: flex;
47
- height: 5px;
48
- border-radius: 2px;
49
- overflow: hidden;
50
- background: ${({theme:e})=>e.color.panelSunk};
51
- border: 1px solid ${({theme:e})=>e.color.rule};
52
- `,pe=a.div`
53
- flex: ${({$grow:e})=>e} 0 0;
54
- background: ${({$color:e})=>e};
55
- opacity: 0.8;
56
- `,me=a.div`
57
- flex: ${({$grow:e})=>e} 0 0;
58
- `;function Q({models:e,logs:n}){let r=new Map;for(let e of n){let t=r.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,r.set(e.requestedModel,t)}let i=Math.max(1,...[...r.values()].map(e=>e.requests)),a=[...e].map(e=>({model:e,used:r.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return(0,J.jsx)(B,{legend:`Models`,meta:`${e.length} configured`,actions:(0,J.jsx)(t,{as:m,to:`/models`,$size:`sm`,children:`Edit routing`}),children:e.length===0?(0,J.jsx)(H,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:(0,J.jsx)(t,{as:m,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):(0,J.jsx)(ue,{children:a.map(({model:e,used:t})=>{let n=(t?.requests??0)/i,r=[...new Set(e.targets.map(e=>e.provider))];return(0,J.jsxs)(`li`,{children:[(0,J.jsxs)(u,{$gap:2,children:[(0,J.jsx)(de,{title:e.id,children:e.id}),e.isAlias?(0,J.jsx)(R,{children:`alias`}):null,(0,J.jsx)(R,{$tone:`accent`,children:e.strategy}),(0,J.jsx)(o,{}),(0,J.jsx)(c,{$dim:!0,children:w(t?.requests??0)}),(0,J.jsx)(p,{children:`req`}),(0,J.jsx)(c,{$dim:!0,children:S(t?.costUsd??0)})]}),(0,J.jsxs)(fe,{style:{marginTop:6},title:`${Math.round(n*100)}% of the busiest model`,children:[r.map(e=>(0,J.jsx)(pe,{$color:`var(--p-${e})`,$grow:n/r.length},e)),(0,J.jsx)(me,{$grow:Math.max(0,1-n)})]})]},e.id)})})})}var he=a.div`
59
- display: grid;
60
- grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
61
- gap: ${({theme:e})=>e.space(3)};
62
- `;function ge({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=M(r,t),a=ne(r,{now:n,spanMs:t,count:32}),o=i.errorRate>=.25?`down`:i.errorRate>=.05?`warn`:`ok`,s=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens;return(0,J.jsxs)(he,{children:[(0,J.jsx)(q,{legend:`Requests`,value:w(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:(0,J.jsx)(C,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),(0,J.jsx)(q,{legend:`Error rate`,value:y(i.errorRate),unit:`${w(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:(0,J.jsx)(C,{values:a.map(e=>e.errors),scaleTo:Math.max(...a.map(e=>e.total)),color:`var(--down)`,label:`${i.errors} failed requests against ${i.requests} total`})}),(0,J.jsx)(q,{legend:`Total tokens`,value:w(s),unit:(0,J.jsx)(D,{tokens:i}),trace:(0,J.jsx)(C,{values:a.map(e=>e.tokens),label:`token volume over the window, ${s.toLocaleString(`en-US`)} total`})}),(0,J.jsx)(q,{legend:`Time to first token`,value:E(i.ttftP50),unit:`p95 ${E(i.ttftP95)}`,trace:(0,J.jsx)(C,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${E(i.ttftP50)}`})}),(0,J.jsx)(q,{legend:`Spend`,value:S(i.costUsd),unit:`${w(i.inputTokens+i.outputTokens)} tokens`,trace:(0,J.jsx)(C,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${S(i.costUsd)} total`})})]})}var $=36e5;function _e(){let{cadence:t}=v(),i=f(),a=h(t(1e4)),o=_(),c=g(500,t(1e4)),l=n(),u=Date.now(),d=Math.floor((u-$)/6e4)*6e4,p=r({groupBy:`credential`,since:d},t(6e4)),m=i.data??[],y=k(a.data?.health??[],e=>e.credentialId),b=m.filter(e=>N(y.get(e.id)??[],u,e.enabled,e.disabledReason).state===`down`),x=i.isLoading||c.isLoading?`Reading the gateway…`:m.length===0?`No accounts are connected, so every request fails at the router.`:b.length>0?`${b.length} account${b.length===1?` is`:`s are`} out of rotation.`:`All ${m.length} accounts are answering. Nothing needs attention.`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T,{legend:`Rack`,title:`Gateway`,summary:x}),c.isError?(0,J.jsx)(B,{legend:`Traffic`,children:(0,J.jsx)(V,{legend:`The gateway did not answer`,error:c.error,onRetry:()=>void c.refetch()})}):(0,J.jsxs)(s,{$gap:4,children:[(0,J.jsx)(ge,{logs:c.data??[],windowMs:$,now:u}),(0,J.jsx)(ie,{credentials:m,health:a.data?.health??[],quota:a.data?.quota??[],usage:p.data??[],quotaPollIntervalMs:l.data?.quotaPollIntervalMs??3e5,now:u}),(0,J.jsxs)(e,{$min:`340px`,$gap:4,children:[(0,J.jsx)(Q,{models:o.data??[],logs:c.data??[]}),(0,J.jsx)(le,{logs:c.data??[]})]})]})]})}var ve=_e;export{ve as component};
@@ -1,39 +0,0 @@
1
- import{B as e,F as t,G as n,L as r,M as i,Mt as a,Nt as o,P as s,R as c,Zt as l,b as u,h as d,j as f,l as p,y as m}from"./queries-D2o-X8Pj.js";import{c as h,t as g}from"./Rack-D1WJswv3.js";import{t as _}from"./CopyValue-CRQDLo7k.js";import{n as v,t as y}from"./Confirm-B6aAiVbT.js";import{t as b}from"./Modal-CI6jk2D4.js";import{t as x}from"./Toggle-CiLC67Dw.js";import{t as S}from"./Chip-BB_5C1Zp.js";import{n as C,t as w}from"./Field-uHZxl4fI.js";import{a as T,i as E,n as D,r as O,t as k}from"./States-Bbiu5cHE.js";import{i as A,n as j,r as M,t as N}from"./Table-CdPWxYaz.js";var P=l(o(),1),F=a(),I=n.div`
2
- display: flex;
3
- flex-direction: column;
4
- gap: 2px;
5
- max-height: 190px;
6
- overflow-y: auto;
7
- padding: ${({theme:e})=>e.space(1)};
8
- border: 1px solid ${({theme:e})=>e.color.ruleStrong};
9
- border-radius: ${({theme:e})=>e.radius.control};
10
- background: ${({theme:e})=>e.color.panelSunk};
11
- `,L=n.label`
12
- display: flex;
13
- align-items: center;
14
- gap: ${({theme:e})=>e.space(2)};
15
- padding: 4px 6px;
16
- border-radius: 2px;
17
- cursor: pointer;
18
- font-family: ${({theme:e})=>e.font.mono};
19
- font-size: 12px;
20
-
21
- &:hover {
22
- background: ${({theme:e})=>e.color.panelRaised};
23
- }
24
- `,R=n.p`
25
- font-size: 12px;
26
- color: ${({theme:e})=>e.color.warn};
27
- `,z=n.p`
28
- font-size: 12px;
29
- color: ${({theme:e})=>e.color.down};
30
- `,B=n.p`
31
- font-size: 12px;
32
- color: ${({theme:e})=>e.color.inkDim};
33
- `;function V({open:t,onOpenChange:n}){let a=m(),o=p(),[c,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(!0),[h,g]=(0,P.useState)([]),[v,y]=(0,P.useState)(``),[S,T]=(0,P.useState)(null),[D,O]=(0,P.useState)(null),k=()=>{l(``),d(!0),g([]),y(``),T(null),O(null),o.reset()},A=e=>{e||k(),n(e)};return(0,F.jsx)(b,{open:t,onOpenChange:A,title:S===null?`Create an API key`:`Key created`,description:S===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:S===null?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(e,{type:`button`,onClick:()=>A(!1),children:`Cancel`}),(0,F.jsx)(e,{type:`button`,$variant:`primary`,disabled:o.isPending,onClick:()=>{let e=v.trim(),t=e.length===0?null:Number(e);if(t!==null&&(!Number.isInteger(t)||t<1)){O(`The rate limit must be a whole number of requests per minute, or blank for none.`);return}O(null),o.mutate({label:c.trim().length===0?`api key`:c.trim(),modelAllowlist:u?null:h,rateLimitPerMin:t},{onSuccess:e=>T(e),onError:e=>O(E(e))})},children:o.isPending?`Creating…`:`Create key`})]}):(0,F.jsx)(e,{type:`button`,$variant:`primary`,onClick:()=>A(!1),children:`I have copied the key`}),children:S===null?(0,F.jsxs)(r,{$gap:3,children:[(0,F.jsx)(w,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>(0,F.jsx)(C,{...e,value:c,placeholder:`api key`,onChange:e=>l(e.target.value)})}),(0,F.jsxs)(r,{$gap:2,children:[(0,F.jsxs)(s,{$gap:2,children:[(0,F.jsx)(x,{checked:u,label:`Allow every model`,onCheckedChange:d}),(0,F.jsx)(f,{as:`span`,children:`Allow every model`})]}),u?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{children:(a.data??[]).map(e=>(0,F.jsxs)(L,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:h.includes(e.id),onChange:t=>g(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),e.id]},e.id))}),h.length===0?(0,F.jsx)(R,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),(0,F.jsx)(w,{label:`Rate limit`,hint:`Requests per minute for this key. Leave blank for no limit. Counted per process, and reset when the gateway restarts.`,children:e=>(0,F.jsx)(C,{...e,type:`number`,min:1,step:1,value:v,placeholder:`no limit`,onChange:e=>y(e.target.value)})}),D===null?null:(0,F.jsx)(z,{role:`alert`,children:D})]}):(0,F.jsxs)(r,{$gap:3,children:[(0,F.jsx)(B,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),(0,F.jsx)(_,{value:S.key,label:`Copy API key`}),(0,F.jsxs)(s,{$gap:2,children:[(0,F.jsx)(f,{children:`Label`}),(0,F.jsx)(i,{children:S.label}),(0,F.jsx)(f,{children:`Prefix`}),(0,F.jsx)(i,{children:S.prefix})]})]})})}var H=n(s)`
34
- gap: 4px;
35
- flex-wrap: wrap;
36
- max-width: 34ch;
37
- `,U=n.span`
38
- color: ${({theme:e})=>e.color.inkFaint};
39
- `;function W(){let n=d(),r=u(),[i,a]=(0,P.useState)(!1),[o,s]=(0,P.useState)(null),l=n.data??[],p=l.filter(e=>e.revokedAt===null),m=n.isLoading?`Reading issued keys…`:l.length===0?`No keys exist, so nothing can call this gateway yet.`:`${p.length} active key${p.length===1?``:`s`} of ${l.length} ever issued.`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{legend:`Keys`,title:`Gateway API keys`,summary:m,actions:(0,F.jsxs)(e,{type:`button`,$variant:`primary`,onClick:()=>a(!0),children:[(0,F.jsx)(v,{}),`Create a key`]})}),(0,F.jsx)(T,{legend:`Issued keys`,meta:`${l.length}`,flush:!0,children:n.isError?(0,F.jsx)(D,{error:n.error,onRetry:()=>void n.refetch()}):n.isLoading?(0,F.jsx)(`div`,{style:{padding:12},children:(0,F.jsx)(O,{rows:4})}):l.length===0?(0,F.jsx)(k,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:(0,F.jsx)(e,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>a(!0),children:`Create a key`})}):(0,F.jsx)(t,{children:(0,F.jsxs)(N,{children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(M,{children:`Label`}),(0,F.jsx)(M,{children:`Prefix`}),(0,F.jsx)(M,{children:`Allowed models`}),(0,F.jsx)(M,{$align:`right`,children:`Rate limit`}),(0,F.jsx)(M,{$align:`right`,children:`Created`}),(0,F.jsx)(M,{children:`Status`}),(0,F.jsx)(M,{})]})}),(0,F.jsx)(`tbody`,{children:l.map(t=>(0,F.jsxs)(A,{children:[(0,F.jsx)(j,{children:(0,F.jsx)(c,{style:{maxWidth:`24ch`,display:`block`},children:t.label})}),(0,F.jsxs)(j,{$mono:!0,children:[t.prefix,`…`]}),(0,F.jsx)(j,{children:t.modelAllowlist===null?(0,F.jsx)(f,{children:`every model`}):t.modelAllowlist.length===0?(0,F.jsx)(S,{$tone:`down`,children:`no models`}):(0,F.jsx)(H,{children:t.modelAllowlist.map(e=>(0,F.jsx)(S,{children:e},e))})}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:t.rateLimitPerMin===null?`—`:`${t.rateLimitPerMin}/min`}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:h(t.createdAt)}),(0,F.jsx)(j,{children:t.revokedAt===null?(0,F.jsx)(S,{$tone:`ok`,children:`active`}):(0,F.jsx)(U,{title:h(t.revokedAt),children:(0,F.jsx)(S,{children:`revoked`})})}),(0,F.jsx)(j,{$align:`right`,children:t.revokedAt===null?(0,F.jsx)(e,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>s(t),children:`Revoke`}):null})]},t.id))})]})})}),(0,F.jsx)(V,{open:i,onOpenChange:a}),(0,F.jsx)(y,{open:o!==null,onOpenChange:e=>{e||s(null)},title:`Revoke key`,body:o===null?``:`Revoking "${o.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:r.isPending,onConfirm:()=>{o!==null&&r.mutate(o.id,{onSettled:()=>s(null)})}})]})}var G=W;export{G as component};
@@ -1,32 +0,0 @@
1
- import{B as e,F as t,G as n,L as r,M as i,Mt as a,Nt as o,P as s,R as c,Zt as l,d as ee,h as te,j as u,n as d,v as f}from"./queries-D2o-X8Pj.js";import{a as p,c as m,l as ne,m as h,o as g,p as _,s as v,t as y,u as b}from"./Rack-D1WJswv3.js";import{n as x,r as S,t as C}from"./TokenBreakdown-B96iPBm9.js";import{t as re}from"./Modal-CI6jk2D4.js";import{c as ie,l as ae,o as w,s as T,t as oe}from"./Lamp-B-5SjXbG.js";import{n as se,t as E}from"./Chip-BB_5C1Zp.js";import{i as D,n as O}from"./Field-uHZxl4fI.js";import{a as k,n as ce,r as A,t as j}from"./States-Bbiu5cHE.js";import{i as M,n as N,r as P,t as F}from"./Table-CdPWxYaz.js";var I=l(o(),1),L=a(),R=[50,100,250,500],z=n(s)`
2
- gap: ${({theme:e})=>e.space(2)};
3
- flex-wrap: wrap;
4
- `,B=n(O)`
5
- width: 220px;
6
- `,V=n(D)`
7
- width: auto;
8
- `,H=n(k)`
9
- flex: 1;
10
- min-height: 0;
11
-
12
- > div {
13
- display: flex;
14
- flex: 1;
15
- flex-direction: column;
16
- min-height: 0;
17
- }
18
- `,U=n(t)`
19
- flex: 1;
20
- min-height: 0;
21
- overflow-y: auto;
22
- `;function W(e){let[t,n]=(0,I.useState)(Date.now);return(0,I.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function le({log:e}){return(0,L.jsx)(N,{$align:`right`,$mono:!0,...T(e)?{"aria-label":`processing`}:{title:S(e)},children:T(e)?(0,L.jsx)(C,{}):(0,L.jsx)(x,{tokens:e})})}var ue=n.dl`
23
- display: grid;
24
- grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
25
- gap: 6px ${({theme:e})=>e.space(3)};
26
- margin: 0;
27
- font-size: 12.5px;
28
- `,G=n.dd`
29
- margin: 0;
30
- font-family: ${({theme:e})=>e.font.mono};
31
- word-break: break-all;
32
- `;function K(){let{cadence:t,live:n}=p(),[a,o]=(0,I.useState)(100),[l,x]=(0,I.useState)(`all`),[S,C]=(0,I.useState)(``),[D,O]=(0,I.useState)(null),k=f(a,t(d)),K=ee(),q=te(),de=(k.data??[]).some(T),J=W(n&&de),Y=(0,I.useMemo)(()=>{let e=new Map;for(let t of K.data??[])e.set(t.id,t.label);return e},[K.data]),X=(0,I.useMemo)(()=>{let e=new Map;for(let t of q.data??[])e.set(t.id,t.label);return e},[q.data]),Z=S.trim().toLowerCase(),Q=(k.data??[]).filter(e=>l===`failed`&&!w(e)?!1:Z.length===0||e.requestedModel.toLowerCase().includes(Z)||(e.resolvedModel??``).toLowerCase().includes(Z)||(e.errorCode??``).toLowerCase().includes(Z)||(e.credentialId===null?``:Y.get(e.credentialId)??``).toLowerCase().includes(Z)||(e.apiKeyId===null?``:X.get(e.apiKeyId)??e.apiKeyId).toLowerCase().includes(Z)),fe=(k.data??[]).filter(w).length,$=(k.data??[]).filter(T).length;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(y,{legend:`Logs`,title:`Recent requests`,summary:k.isLoading?`Reading the request log…`:`${v(k.data?.length??0)} recent requests, ${v(fe)} of them failed${$===0?``:`, ${v($)} still running`}. Prompt and response bodies are never recorded.`,actions:(0,L.jsxs)(z,{children:[(0,L.jsx)(B,{value:S,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>C(e.target.value)}),(0,L.jsxs)(V,{value:l,"aria-label":`Show which requests`,onChange:e=>x(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`All requests`}),(0,L.jsx)(`option`,{value:`failed`,children:`Failed only`})]}),(0,L.jsx)(V,{value:a,"aria-label":`How many requests to fetch`,onChange:e=>o(Number(e.target.value)),children:R.map(e=>(0,L.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,L.jsx)(H,{legend:`Request log`,meta:`${Q.length} shown`,flush:!0,children:k.isError?(0,L.jsx)(ce,{error:k.error,onRetry:()=>void k.refetch()}):k.isLoading?(0,L.jsx)(`div`,{style:{padding:12},children:(0,L.jsx)(A,{rows:8})}):Q.length===0?(0,L.jsx)(j,{legend:`Nothing to show`,message:(k.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):(0,L.jsx)(U,{"data-testid":`request-log-scroller`,children:(0,L.jsxs)(F,{children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(P,{}),(0,L.jsx)(P,{$align:`right`,children:`Time`}),(0,L.jsx)(P,{children:`Requested`}),(0,L.jsx)(P,{children:`Routed to`}),(0,L.jsx)(P,{children:`Account`}),(0,L.jsx)(P,{children:`Key`}),(0,L.jsx)(P,{$align:`right`,children:`Try`}),(0,L.jsx)(P,{$align:`right`,children:`TTFT`}),(0,L.jsx)(P,{$align:`right`,children:`Total`}),(0,L.jsx)(P,{$align:`right`,children:`Tokens`}),(0,L.jsx)(P,{$align:`right`,children:`Cost`}),(0,L.jsx)(P,{children:`Outcome`})]})}),(0,L.jsx)(`tbody`,{children:Q.map(e=>(0,L.jsxs)(M,{$selectable:!0,onClick:()=>O(e),children:[(0,L.jsx)(N,{children:(0,L.jsx)(oe,{state:ae(e),label:ie(e)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,title:m(e.at),children:g(e.at)}),(0,L.jsx)(N,{$mono:!0,children:(0,L.jsx)(c,{style:{display:`block`,maxWidth:`20ch`},children:e.requestedModel||`—`})}),(0,L.jsx)(N,{children:e.resolvedProvider===null?(0,L.jsx)(u,{children:T(e)?`routing…`:`not routed`}):(0,L.jsxs)(s,{$gap:1,children:[(0,L.jsx)(se,{provider:e.resolvedProvider}),(0,L.jsx)(i,{$dim:!0,children:e.resolvedModel??`—`})]})}),(0,L.jsx)(N,{children:(0,L.jsx)(c,{style:{display:`block`,maxWidth:`18ch`},children:e.credentialId===null?`—`:Y.get(e.credentialId)??h(e.credentialId)})}),(0,L.jsx)(N,{children:(0,L.jsx)(c,{style:{display:`block`,maxWidth:`16ch`},title:e.apiKeyId??void 0,children:e.apiKeyId===null?`—`:X.get(e.apiKeyId)??h(e.apiKeyId)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?`—`:e.attempts}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?`—`:b(e.ttftMs)}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?ne(Math.max(0,J-e.at)):b(e.durationMs)}),(0,L.jsx)(le,{log:e}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:T(e)?`—`:_(e.costUsd)}),(0,L.jsx)(N,{children:T(e)?(0,L.jsx)(E,{$tone:`accent`,children:`live`}):e.errorCode===null?(0,L.jsx)(E,{$tone:`ok`,children:e.status}):(0,L.jsx)(E,{$tone:`down`,children:e.errorCode})})]},e.id))})]})})}),(0,L.jsx)(re,{open:D!==null,onOpenChange:e=>{e||O(null)},title:`Request detail`,width:`600px`,footer:(0,L.jsx)(e,{type:`button`,onClick:()=>O(null),children:`Close`}),children:D===null?null:(0,L.jsxs)(r,{$gap:3,children:[(0,L.jsxs)(ue,{children:[(0,L.jsx)(u,{as:`dt`,children:`Request id`}),(0,L.jsx)(G,{children:D.id}),(0,L.jsx)(u,{as:`dt`,children:`At`}),(0,L.jsx)(G,{children:m(D.at)}),(0,L.jsx)(u,{as:`dt`,children:`Requested model`}),(0,L.jsx)(G,{children:D.requestedModel||`—`}),(0,L.jsx)(u,{as:`dt`,children:`Routed to`}),(0,L.jsx)(G,{children:T(D)?`—`:D.resolvedProvider===null?`not routed`:`${D.resolvedProvider} · ${D.resolvedModel??`—`}`}),(0,L.jsx)(u,{as:`dt`,children:`Account`}),(0,L.jsx)(G,{children:D.credentialId===null?`—`:Y.get(D.credentialId)??D.credentialId}),(0,L.jsx)(u,{as:`dt`,children:`Key`}),(0,L.jsx)(G,{children:D.apiKeyId===null?`—`:X.get(D.apiKeyId)??D.apiKeyId}),(0,L.jsx)(u,{as:`dt`,children:`Attempts`}),(0,L.jsx)(G,{children:T(D)?`—`:D.attempts}),(0,L.jsx)(u,{as:`dt`,children:`Status`}),(0,L.jsx)(G,{children:T(D)?`in flight`:D.errorCode===null?D.status:`${D.status} ${D.errorCode}`}),(0,L.jsx)(u,{as:`dt`,children:`Timing`}),(0,L.jsx)(G,{children:T(D)?`—`:`first token ${b(D.ttftMs)} · total ${b(D.durationMs)}`}),(0,L.jsx)(u,{as:`dt`,children:`Tokens`}),(0,L.jsx)(G,{children:T(D)?`—`:(0,L.jsxs)(L.Fragment,{children:[v(D.inputTokens),` in · `,v(D.outputTokens),` out ·`,` `,v(D.cacheReadTokens),` cache read ·`,` `,v(D.cacheWriteTokens),` cache write`]})}),(0,L.jsx)(u,{as:`dt`,children:`Cost`}),(0,L.jsx)(G,{children:T(D)?`—`:_(D.costUsd)}),(0,L.jsx)(u,{as:`dt`,children:`RTK compression`}),(0,L.jsx)(G,{children:T(D)?`—`:D.rtkApplied?`${v(D.rtkFilterHits)} hits · ${v(D.rtkOriginalCodeUnits)} → ${v(D.rtkCompressedCodeUnits)} code units · ~${v(D.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),(0,L.jsx)(u,{as:`dt`,children:`RTK filters`}),(0,L.jsx)(G,{children:D.rtkFilters.length===0?`—`:D.rtkFilters.join(`, `)})]}),D.degradations.length===0?null:(0,L.jsxs)(r,{$gap:1,children:[(0,L.jsx)(u,{children:`Capabilities dropped to fit the target`}),(0,L.jsx)(s,{$gap:1,$wrap:!0,children:D.degradations.map(e=>(0,L.jsx)(E,{$tone:`warn`,children:e},e))})]})]})})]})}var q=K;export{q as component};