omnigateway 0.4.9 → 0.4.11

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 (30) hide show
  1. package/bin/omni.js +163 -25
  2. package/gateway.js +190 -29
  3. package/package.json +1 -1
  4. package/public/assets/{CopyValue-CHZz2PLE.js → CopyValue-By5BAgv7.js} +1 -1
  5. package/public/assets/{Rack-ziQuyb2l.js → Rack-fDZClWZL.js} +2 -2
  6. package/public/assets/States-DtkkMzEu.js +54 -0
  7. package/public/assets/{Toggle-CNnMgEU1.js → Toggle-ClEeOh0F.js} +1 -1
  8. package/public/assets/{TokenBreakdown-hkwYCWT3.js → TokenBreakdown-D70VeZ2N.js} +1 -1
  9. package/public/assets/{_app-BD1K3SGD.js → _app-CDPKnQ72.js} +1 -1
  10. package/public/assets/_app.accounts-Dz0ox4Br.js +64 -0
  11. package/public/assets/{_app.console-BtLYkvSQ.js → _app.console-hPUmmYjp.js} +1 -1
  12. package/public/assets/{_app.database-ByLAAKXX.js → _app.database-DGtP4NdG.js} +2 -2
  13. package/public/assets/_app.index-COcCAmbH.js +62 -0
  14. package/public/assets/{_app.keys-Ce6Xd1RK.js → _app.keys-yTXTbKTA.js} +1 -1
  15. package/public/assets/{_app.logs-CmDNhsU4.js → _app.logs-BhMvO_Fx.js} +4 -4
  16. package/public/assets/{_app.models-mqdU56d8.js → _app.models-0S3rurIl.js} +1 -1
  17. package/public/assets/{_app.plugins._pluginId-C0VWWCD2.js → _app.plugins._pluginId-B-ZDQNPU.js} +1 -1
  18. package/public/assets/_app.settings-DTnFwTeA.js +46 -0
  19. package/public/assets/{_app.usage-BaB40kku.js → _app.usage-C2-VLiq9.js} +4 -4
  20. package/public/assets/{index-C3Fp8XmZ.js → index-COwhxKU7.js} +2 -2
  21. package/public/assets/{login-Bn1s6JI_.js → login-DjfMomJJ.js} +1 -1
  22. package/public/assets/plus-UDQ_BTEr.js +1 -0
  23. package/public/assets/{shared-DtfLcn24.js → shared-Cct_4xwp.js} +1 -1
  24. package/public/assets/{trash-2-B5fBDSkh.js → trash-2-U2ViYZum.js} +1 -1
  25. package/public/index.html +1 -1
  26. package/public/assets/States-Shs8nZi1.js +0 -54
  27. package/public/assets/_app.accounts-BDBEn5vF.js +0 -64
  28. package/public/assets/_app.index-3mAmJsCn.js +0 -62
  29. package/public/assets/_app.settings-BLJ-25xq.js +0 -46
  30. package/public/assets/plus-Cdyfj4uP.js +0 -1
@@ -0,0 +1,54 @@
1
+ import{$ as e,lt as t,q as n}from"./queries-CX9mStps.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import a,{css as o,keyframes as s}from"styled-components";var c=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:1}),l=new Intl.NumberFormat(`en-US`);function u(e){return Number.isFinite(e)?e<1e4?l.format(Math.round(e)):c.format(e).toLowerCase():`—`}function ee(e){return Number.isFinite(e)?e===0?`$0`:e<.01?`$${e.toFixed(4)}`:e<100?`$${e.toFixed(2)}`:`$${c.format(e).toLowerCase()}`:`—`}function d(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 f(e,t=1){return Number.isFinite(e)?`${(e*100).toFixed(t)}%`:`—`}var p=[[6e4,1e3,`s`],[36e5,6e4,`m`],[864e5,36e5,`h`],[1/0,864e5,`d`]];function m(e){let t=Math.abs(e);if(t<1e3)return`0s`;let n=p.find(([e])=>t<e);return n===void 0?`—`:`${Math.floor(t/n[1])}${n[2]}`}function h(e,t=Date.now()){if(e==null||!Number.isFinite(e))return`—`;let n=e-t;return Math.abs(n)<5e3?`just now`:n<0?`${m(n)} ago`:`in ${m(n)}`}function g(e){return new Date(e).toLocaleTimeString(`en-GB`,{hour12:!1})}var _=864e5;function v(e,t){let n=new Date(e),r=n.toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`,hour12:!1});return y(t)?`${n.toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`})} ${r}`:r}function y(e){return e>=_}function b(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})}var x=[`B`,`KiB`,`MiB`,`GiB`,`TiB`];function S(e){if(e==null||!Number.isFinite(e))return`—`;if(Math.abs(e)<1024)return`${Math.round(e)} B`;let t=e,n=0;for(;Math.abs(t)>=1024&&n<x.length-1;)t/=1024,n+=1;return`${t.toFixed(1)} ${x[n]}`}function C(e,t=8){return e.length<=t?e:`${e.slice(0,t)}…`}var te={fiveHour:18e6,daily:864e5,weekly:6048e5};function ne(e,t){return t!==null&&t>0?t:te[e]}var w=6e4;function T(e,t){return e===null||t===null?e===t:Math.abs(e-t)<=w}function E(e,t){return t===void 0?`unknown`:e.observedAt>0&&t.stale?`stale`:t.ratePerHour===null||e.limit===null?`unknown`:t.survives===!1&&t.exhaustsAt!==null?`empty`:t.survives===!0?`ok`:`unknown`}function D(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 O(e){return e.state===`pending`}function k(e){return e.filter(e=>!O(e))}function A(e){return O(e)?!1:e.status>=400||e.errorCode!==null}var j={ok:`●`,warn:`◐`,down:`○`,idle:`·`,live:`●`};function M(e){return O(e)?`live`:A(e)?`down`:`ok`}function N(e){return O(e)?`in flight`:A(e)?`failed with ${e.status}`:`succeeded`}function P(e,t){let n=k(e),r=[],i=0,a=0,o=0,s=0,c=0,l=0;for(let e of n)A(e)&&(i+=1),e.ttftMs!==null&&Number.isFinite(e.ttftMs)&&r.push(e.ttftMs),a+=e.costUsd,o+=e.inputTokens,s+=e.outputTokens,c+=e.cacheReadTokens,l+=e.cacheWriteTokens;let u=t/6e4;return{requests:n.length,errors:i,errorRate:n.length===0?0:i/n.length,ratePerMin:u<=0?0:n.length/u,ttftP50:D(r,.5),ttftP95:D(r,.95),costUsd:a,inputTokens:o,outputTokens:s,cacheReadTokens:c,cacheWriteTokens:l}}function F(e,t){let n=k(e),{now:r,spanMs:i,count:a}=t,o=i/a,s=r-i,c=Array.from({length:a},(e,t)=>({at:s+t*o,total:0,errors:0,costUsd:0,tokens:0,ttftMs:null})),l=Array.from({length:a},()=>[]);for(let e of n){if(e.at<s||e.at>r)continue;let t=Math.min(a-1,Math.floor((e.at-s)/o)),n=c[t];n!==void 0&&(n.total+=1,n.costUsd+=e.costUsd,n.tokens+=e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheWriteTokens,A(e)&&(n.errors+=1),e.ttftMs!==null&&Number.isFinite(e.ttftMs)&&l[t]?.push(e.ttftMs))}for(let[e,t]of c.entries())t.ttftMs=D(l[e]??[],.5);return c}var I={tokenRejected:`reconnect needed — provider rejected the refresh token`,expiredNoRefresh:`reconnect needed — token expired with nothing to refresh from`};function L(e,t,n,r=null){if(!n){let e=r===`tokenRejected`||r===`expiredNoRefresh`;return{state:e?`down`:`idle`,note:e?I[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 R={fiveHour:`5h`,daily:`24h`,weekly:`7d`};function z(e){return Math.max(e,6e4)*3}function B(e,t,n){return e.observedAt<=0||t-e.observedAt>z(n)}function V(e,t){return e.find(e=>e.windowType===t)}function H(e,t,n,r,i){let a=R[e.windowType];if(e.observedAt<=0)return`${a} · never observed`;if(B(e,t,n))return`${a} · stale, read ${r(e.observedAt,t)}`;if(e.resetsAt===null)return a;let o=`resets ${r(e.resetsAt,t)}`;return i===void 0||i.stale||i.survives!==!1||i.exhaustsAt===null?`${a} · ${o}`:`${a} · ${i.exhaustsAt<=t?`empty now`:`empty ~${m(i.exhaustsAt-t)}`} · ${o}`}function re(e){let t=e.filter(e=>e.limit!==null&&e.limit>0).sort((e,t)=>e.observedAt-t.observedAt),n=[],r;for(let e of t){let t={at:e.observedAt,percent:Math.min(100,e.used/e.limit*100)},i={resetsAt:e.resetsAt,startsAt:e.resetsAt===null?null:e.resetsAt-ne(e.windowType,e.windowMs)},a=n[n.length-1];a===void 0||r===void 0||!T(e.resetsAt,r.resetsAt)?n.push({key:`window-${n.length}`,points:[t],...i}):(a.points.push(t),a.resetsAt=i.resetsAt,a.startsAt=i.startsAt),r=e}return n}function U(e,t){let{limit:n,used:r,observedAt:i}=t;if(n===null||n<=0)return[...e];let a=e.findLastIndex(e=>T(e.resetsAt,t.resetsAt)),o=e[a];if(o===void 0)return[...e];let s=o.points[o.points.length-1];if(s===void 0||s.at>=i)return[...e];let c={at:i,percent:Math.min(100,r/n*100)};return e.map((e,t)=>t===a?{...e,points:[...e.points,c]}:e)}function W(e){return e.startsAt===null||e.resetsAt===null?null:{from:{at:e.startsAt,percent:0},to:{at:e.resetsAt,percent:100}}}var G=36e5;function K(e,t){let{limit:n,resetsAt:r,observedAt:i,used:a}=e,o=t.ratePerHour;if(n===null||n<=0||r===null||o===null||o<=0)return null;let s=a/n*100,c=o/n*100;return{from:{at:i,percent:s},to:{at:r,percent:s+c*((r-i)/G)}}}var q={fiveHour:0,daily:1,weekly:2};function J(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)=>q[e.window.windowType]-q[t.window.windowType])}function Y(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 X=s`
2
+ 0%, 100% { opacity: 1; }
3
+ 50% { opacity: 0.28; }
4
+ `,ie=o`
5
+ color: ${({theme:e})=>e.color.ok};
6
+ animation: ${X} 1.2s ease-in-out infinite;
7
+
8
+ @media (prefers-reduced-motion: reduce) {
9
+ animation: none;
10
+ }
11
+ `,ae={ok:o`
12
+ color: ${({theme:e})=>e.color.ok};
13
+ `,warn:o`
14
+ color: ${({theme:e})=>e.color.warn};
15
+ `,down:o`
16
+ color: ${({theme:e})=>e.color.down};
17
+ `,idle:o`
18
+ color: ${({theme:e})=>e.color.inkFaint};
19
+ `,live:ie},oe=a.span`
20
+ font-family: ${({theme:e})=>e.font.mono};
21
+ font-size: 12px;
22
+ line-height: 1;
23
+ flex: none;
24
+ ${({$state:e})=>ae[e]}
25
+ `;function se({state:e,label:t,className:n}){return r(oe,{$state:e,className:n,role:`img`,"aria-label":t,title:t,children:j[e]})}var Z=a.div`
26
+ display: flex;
27
+ flex-direction: column;
28
+ align-items: center;
29
+ justify-content: center;
30
+ gap: ${({theme:e})=>e.space(2)};
31
+ padding: ${({theme:e})=>e.space(8)} ${({theme:e})=>e.space(4)};
32
+ text-align: center;
33
+ `,Q=a.p`
34
+ max-width: 44ch;
35
+ font-size: 13px;
36
+ color: ${({theme:e})=>e.color.inkDim};
37
+ `;function ce({legend:t,message:n,action:a}){return i(Z,{children:[r(e,{children:t}),r(Q,{children:n}),a]})}var le=a(Q)`
38
+ color: ${({theme:e})=>e.color.down};
39
+ `;function $(e){return e instanceof n||e instanceof Error?e.message:`The gateway did not answer.`}function ue({legend:n=`Request failed`,error:a,onRetry:o}){return i(Z,{children:[r(e,{children:n}),r(le,{children:$(a)}),o===void 0?null:r(t,{type:`button`,$size:`sm`,onClick:o,children:`Try again`})]})}var de=s`
40
+ 0% { opacity: 0.35; }
41
+ 50% { opacity: 0.7; }
42
+ 100% { opacity: 0.35; }
43
+ `,fe=a.div`
44
+ height: ${({$height:e})=>e??12}px;
45
+ width: ${({$width:e})=>e??`100%`};
46
+ border-radius: 2px;
47
+ background: ${({theme:e})=>e.color.ruleStrong};
48
+ animation: ${de} 1.4s ease-in-out infinite;
49
+ `,pe=a.div`
50
+ display: flex;
51
+ flex-direction: column;
52
+ gap: ${({theme:e})=>e.space(2)};
53
+ padding: ${({theme:e})=>e.space(1)} 0;
54
+ `;function me({rows:e=4}){let t=Array.from({length:e},(e,t)=>`row-${t}:${t%3==0?`72%`:`100%`}`);return r(pe,{"aria-hidden":`true`,children:t.map(e=>r(fe,{$width:e.split(`:`)[1]??`100%`},e))})}export{d as A,E as C,u as D,g as E,C as F,h as M,ee as N,b as O,y as P,U as S,v as T,K as _,se as a,J as b,W as c,Y as d,A as f,M as g,N as h,$ as i,f as j,m as k,V as l,B as m,ue as n,R as o,O as p,me as r,F as s,ce as t,L as u,H as v,S as w,P as x,re as y};
@@ -1,4 +1,4 @@
1
- import{c as e,d as t,f as n,l as r,p as i,u as a}from"./Rack-ziQuyb2l.js";import*as o from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import u from"styled-components";var d=Object.defineProperty,f=(e,t)=>d(e,`name`,{value:t,configurable:!0});function p(e){let[t,n]=o.useState(void 0);return r(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}f(p,`useSize`);var m=Object.defineProperty,h=(e,t)=>m(e,`name`,{value:t,configurable:!0}),g=`Switch`,[_,v]=t(g),[y,b]=_(g);function x(t){let{__scopeSwitch:n,checked:r,children:i,defaultChecked:a,disabled:s,form:l,name:u,onCheckedChange:d,required:f,value:p=`on`,internal_do_not_use_render:m}=t,[h,_]=e({prop:r,defaultProp:a??!1,onChange:d,caller:g}),[v,b]=o.useState(null),[x,S]=o.useState(null),C=o.useRef(!1),[w,T]=o.useReducer(e=>e+1,0),E={checked:h,setChecked:_,disabled:s,control:v,setControl:b,name:u,form:l,value:p,hasConsumerStoppedPropagationRef:C,userInteractionCount:w,onUserInteraction:T,required:f,defaultChecked:a,isFormControl:!v||!!l||!!v.closest(`form`),bubbleInput:x,setBubbleInput:S};return c(y,{scope:n,...E,children:k(m)?m(E):i})}h(x,`SwitchProvider`);var S=`SwitchTrigger`,C=o.forwardRef(h(function({__scopeSwitch:e,onClick:t,...r},s){let{control:l,form:u,value:d,disabled:f,checked:p,required:m,setControl:g,setChecked:_,hasConsumerStoppedPropagationRef:v,onUserInteraction:y,isFormControl:x,bubbleInput:C}=b(S,e),w=i(s,g),T=o.useRef(p);return o.useEffect(()=>{let e=u?l?.ownerDocument.getElementById(u):l?.form;if(e instanceof HTMLFormElement){let t=h(()=>_(T.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[l,u,_]),c(n.button,{type:`button`,role:`switch`,"aria-checked":p,"aria-required":m,"data-state":A(p),"data-disabled":f?``:void 0,disabled:f,value:d,...r,ref:w,onClick:a(t,e=>{y(),_(e=>!e),C&&x&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})})},`SwitchTrigger`)),w=o.forwardRef(h(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:u,value:d,onCheckedChange:f,form:p,...m}=e;return c(x,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:u,required:o,onCheckedChange:f,name:r,form:p,value:d,internal_do_not_use_render:({isFormControl:e})=>l(s,{children:[c(C,{...m,ref:t,__scopeSwitch:n}),e&&c(O,{__scopeSwitch:n})]})})},`Switch`)),T=`SwitchThumb`,E=o.forwardRef(h(function(e,t){let{__scopeSwitch:r,...i}=e,a=b(T,r);return c(n.span,{"data-state":A(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t})},`SwitchThumb`)),D=`SwitchBubbleInput`,O=o.forwardRef(h(function({__scopeSwitch:e,onClick:t,...r},s){let{control:l,hasConsumerStoppedPropagationRef:u,userInteractionCount:d,checked:f,defaultChecked:m,required:h,disabled:g,name:_,value:v,form:y,bubbleInput:x,setBubbleInput:S}=b(D,e),C=i(s,S),w=p(l),T=o.useRef(!1),E=o.useRef(f),O=o.useRef(d);o.useEffect(()=>{let e=x;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=d!==O.current;O.current=d;let i=E.current!==f;E.current=f;let a=!(r&&u.current);if(i&&n){T.current=!r;let t=new Event(`click`,{bubbles:a});n.call(e,f),e.dispatchEvent(t),T.current=!1}},[x,f,u,d]);let k=o.useRef(f);return c(n.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:m??k.current,required:h,disabled:g,name:_,value:v,form:y,...r,tabIndex:-1,ref:C,onClick:a(t,e=>{T.current&&e.stopPropagation()}),style:{...r.style,...w,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function k(e){return typeof e==`function`}h(k,`isFunction`);function A(e){return e?`checked`:`unchecked`}h(A,`getState`);var j=u(w)`
1
+ import{c as e,d as t,f as n,l as r,p as i,u as a}from"./Rack-fDZClWZL.js";import*as o from"react";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import u from"styled-components";var d=Object.defineProperty,f=(e,t)=>d(e,`name`,{value:t,configurable:!0});function p(e){let[t,n]=o.useState(void 0);return r(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}f(p,`useSize`);var m=Object.defineProperty,h=(e,t)=>m(e,`name`,{value:t,configurable:!0}),g=`Switch`,[_,v]=t(g),[y,b]=_(g);function x(t){let{__scopeSwitch:n,checked:r,children:i,defaultChecked:a,disabled:s,form:l,name:u,onCheckedChange:d,required:f,value:p=`on`,internal_do_not_use_render:m}=t,[h,_]=e({prop:r,defaultProp:a??!1,onChange:d,caller:g}),[v,b]=o.useState(null),[x,S]=o.useState(null),C=o.useRef(!1),[w,T]=o.useReducer(e=>e+1,0),E={checked:h,setChecked:_,disabled:s,control:v,setControl:b,name:u,form:l,value:p,hasConsumerStoppedPropagationRef:C,userInteractionCount:w,onUserInteraction:T,required:f,defaultChecked:a,isFormControl:!v||!!l||!!v.closest(`form`),bubbleInput:x,setBubbleInput:S};return c(y,{scope:n,...E,children:k(m)?m(E):i})}h(x,`SwitchProvider`);var S=`SwitchTrigger`,C=o.forwardRef(h(function({__scopeSwitch:e,onClick:t,...r},s){let{control:l,form:u,value:d,disabled:f,checked:p,required:m,setControl:g,setChecked:_,hasConsumerStoppedPropagationRef:v,onUserInteraction:y,isFormControl:x,bubbleInput:C}=b(S,e),w=i(s,g),T=o.useRef(p);return o.useEffect(()=>{let e=u?l?.ownerDocument.getElementById(u):l?.form;if(e instanceof HTMLFormElement){let t=h(()=>_(T.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[l,u,_]),c(n.button,{type:`button`,role:`switch`,"aria-checked":p,"aria-required":m,"data-state":A(p),"data-disabled":f?``:void 0,disabled:f,value:d,...r,ref:w,onClick:a(t,e=>{y(),_(e=>!e),C&&x&&(v.current=e.isPropagationStopped(),v.current||e.stopPropagation())})})},`SwitchTrigger`)),w=o.forwardRef(h(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:u,value:d,onCheckedChange:f,form:p,...m}=e;return c(x,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:u,required:o,onCheckedChange:f,name:r,form:p,value:d,internal_do_not_use_render:({isFormControl:e})=>l(s,{children:[c(C,{...m,ref:t,__scopeSwitch:n}),e&&c(O,{__scopeSwitch:n})]})})},`Switch`)),T=`SwitchThumb`,E=o.forwardRef(h(function(e,t){let{__scopeSwitch:r,...i}=e,a=b(T,r);return c(n.span,{"data-state":A(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t})},`SwitchThumb`)),D=`SwitchBubbleInput`,O=o.forwardRef(h(function({__scopeSwitch:e,onClick:t,...r},s){let{control:l,hasConsumerStoppedPropagationRef:u,userInteractionCount:d,checked:f,defaultChecked:m,required:h,disabled:g,name:_,value:v,form:y,bubbleInput:x,setBubbleInput:S}=b(D,e),C=i(s,S),w=p(l),T=o.useRef(!1),E=o.useRef(f),O=o.useRef(d);o.useEffect(()=>{let e=x;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=d!==O.current;O.current=d;let i=E.current!==f;E.current=f;let a=!(r&&u.current);if(i&&n){T.current=!r;let t=new Event(`click`,{bubbles:a});n.call(e,f),e.dispatchEvent(t),T.current=!1}},[x,f,u,d]);let k=o.useRef(f);return c(n.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:m??k.current,required:h,disabled:g,name:_,value:v,form:y,...r,tabIndex:-1,ref:C,onClick:a(t,e=>{T.current&&e.stopPropagation()}),style:{...r.style,...w,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function k(e){return typeof e==`function`}h(k,`isFunction`);function A(e){return e?`checked`:`unchecked`}h(A,`getState`);var j=u(w)`
2
2
  all: unset;
3
3
  width: 30px;
4
4
  height: 16px;
@@ -1,4 +1,4 @@
1
- import{g as e,h as t}from"./Rack-ziQuyb2l.js";import{E as n}from"./States-Shs8nZi1.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import a,{keyframes as o}from"styled-components";var s=e(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),c=e(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),l=new Intl.NumberFormat(`en-US`);function u(e){return`${l.format(e.inputTokens)} input, ${l.format(e.outputTokens)} output, ${l.format(e.cacheReadTokens)} cache read, ${l.format(e.cacheWriteTokens)} cache write tokens`}var d=a.span`
1
+ import{g as e,h as t}from"./Rack-fDZClWZL.js";import{D as n}from"./States-DtkkMzEu.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import a,{keyframes as o}from"styled-components";var s=e(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),c=e(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),l=new Intl.NumberFormat(`en-US`);function u(e){return`${l.format(e.inputTokens)} input, ${l.format(e.outputTokens)} output, ${l.format(e.cacheReadTokens)} cache read, ${l.format(e.cacheWriteTokens)} cache write tokens`}var d=a.span`
2
2
  display: inline-flex;
3
3
  align-items: center;
4
4
  flex-wrap: wrap;
@@ -1 +1 @@
1
- import{n as e}from"./Match-BWa6L0L1.js";import{i as t,n}from"./Rack-ziQuyb2l.js";import{jsx as r}from"react/jsx-runtime";var i=()=>r(t,{children:r(n,{children:r(e,{})})});export{i as component};
1
+ import{n as e}from"./Match-BWa6L0L1.js";import{i as t,n}from"./Rack-fDZClWZL.js";import{jsx as r}from"react/jsx-runtime";var i=()=>r(t,{children:r(n,{children:r(e,{})})});export{i as component};
@@ -0,0 +1,64 @@
1
+ import{A as e,C as t,E as n,J as r,T as i,Y as a,c as o,dt as s,t as c,w as l}from"./shared-Cct_4xwp.js";import{$ as u,A as d,W as f,at as p,et as m,f as h,g,h as _,l as v,lt as y,nt as b,r as x,rt as S,u as C,ut as w,v as T,z as E}from"./queries-CX9mStps.js";import{a as D,g as O,o as k,s as ee,t as A}from"./Rack-fDZClWZL.js";import{n as te,r as ne,t as re}from"./CopyValue-By5BAgv7.js";import{t as j}from"./plus-UDQ_BTEr.js";import{t as M}from"./trash-2-U2ViYZum.js";import{t as N}from"./Toggle-ClEeOh0F.js";import{A as P,C as F,D as I,M as L,O as ie,P as ae,S as oe,T as se,_ as ce,a as le,b as ue,c as de,d as R,i as z,k as fe,l as pe,m as me,n as he,o as ge,r as _e,t as ve,u as ye,v as be,y as xe}from"./States-DtkkMzEu.js";import{t as Se}from"./Chip-BltJSw8A.js";import{i as B,n as V,r as Ce,t as H}from"./Field-B79Yxdit.js";import{t as we}from"./Meter-stpt3vQu.js";import{t as U}from"./Panel-CoulMx6R.js";import{i as Te,n as W,r as G,t as Ee}from"./Table-CVDZ69Zx.js";import{t as De}from"./catalog-BBKm8Ih8.js";import*as Oe from"react";import{Fragment as ke,forwardRef as Ae,useCallback as je,useEffect as Me,useState as K}from"react";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";var Ne=O(`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`}]]),Pe=Object.keys(De);function Fe(e){return De[e].authTypes}function Ie(e){return Fe(e).includes(`oauth`)?`oauth`:`apiKey`}var Le={oauth:`Authorize in the browser`,apiKey:`Paste an API key`},Z={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,kilo:`Kilo`,grok:`Grok`,custom:`OpenAI Compatible`},Re={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.`,kilo:`Approve the code on Kilo's device page. This dialog finishes on its own.`,grok:`Authorize in the browser. When it redirects to 127.0.0.1, paste the whole URL.`,custom:`Enter endpoint metadata and API key.`},ze={openai:`http://localhost:1455/auth/callback?code=…`,grok:`http://127.0.0.1:56121/callback?code=…`},Be=X.ol`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: ${({theme:e})=>e.space(3)};
5
+ `,Ve=X.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
+ `,He=X.p`
15
+ font-size: 12px;
16
+ color: ${({theme:e})=>e.color.down};
17
+ `,Ue=X.p`
18
+ font-size: 12px;
19
+ color: ${({theme:e})=>e.color.inkDim};
20
+ `;function We({open:e,credentials:t,onOpenChange:n,onConnected:r}){let[i,a]=K(`anthropic`),[o,s]=K(Ie(`anthropic`)),[c,l]=K(``),[d,f]=K(null),[m,g]=K(``),[_,S]=K(``),w=(t??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[T,E]=K(``),[D,O]=K(``),[k,A]=K(`chat_completions`),[te,ne]=K(``),[j,M]=K(null),N=C(),P=v(),F=h(),I=je(()=>{f(null),g(``),S(``),E(``),O(``),A(`chat_completions`),ne(``),M(null),l(``),N.reset(),P.reset(),F.reset()},[N,P,F]),L=je(e=>{e||I(),n(e)},[n,I]);return Me(()=>{if(d===null||d.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await x(d.flowId);if(e)return;if(t.status===`complete`){I(),n(!1),r();return}}catch(t){if(e)return;M(z(t)),f(null);return}e||(i=setTimeout(()=>void t(),d.pollIntervalMs))},i=setTimeout(()=>void t(),d.pollIntervalMs);return()=>{e=!0,clearTimeout(i)}},[d,r,n,I]),J(ee,{open:e,onOpenChange:L,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:d===null?Y(q,{children:[J(y,{type:`button`,onClick:()=>L(!1),children:`Cancel`}),J(y,{type:`button`,$variant:`primary`,disabled:N.isPending||F.isPending,onClick:()=>{if(M(null),o===`apiKey`){F.mutate({provider:i,apiKey:te,label:c.trim()||void 0,...i===`custom`?{endpointId:_,endpointLabel:T,origin:D,protocol:k}:{}},{onSuccess:()=>{I(),n(!1),r()},onError:e=>M(z(e))});return}N.mutate({provider:i,label:c.trim().length===0?Z[i]:c.trim()},{onSuccess:e=>f(e),onError:e=>M(z(e))})},children:o===`apiKey`?F.isPending?`Adding…`:`Add API key`:N.isPending?`Starting…`:`Start authorization`})]}):d.kind===`device`?J(y,{type:`button`,onClick:()=>L(!1),children:`Cancel`}):Y(q,{children:[J(y,{type:`button`,onClick:()=>L(!1),children:`Cancel`}),J(y,{type:`button`,$variant:`primary`,disabled:P.isPending||m.trim().length===0,onClick:()=>{d!==null&&(M(null),P.mutate({flowId:d.flowId,code:m.trim()},{onSuccess:()=>{I(),n(!1),r()},onError:e=>M(z(e))}))},children:P.isPending?`Finishing…`:`Finish connecting`})]}),children:Y(Be,{children:[d===null?Y(p,{$gap:3,children:[J(H,{label:`Provider`,children:e=>J(B,{...e,value:i,onChange:e=>{let t=e.target.value;a(t),s(Ie(t))},children:Pe.map(e=>J(`option`,{value:e,children:Z[e]},e))})}),Fe(i).length>1?J(H,{label:`How to connect`,children:e=>J(B,{...e,value:o,onChange:e=>s(e.target.value),children:Fe(i).map(e=>J(`option`,{value:e,children:Le[e]},e))})}):null,i===`custom`?Y(q,{children:[w.length===0?null:J(H,{label:`Existing endpoint`,children:e=>Y(B,{...e,value:_,onChange:e=>{let t=w.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){S(``),E(``),O(``),A(`chat_completions`);return}S(String(t.providerData.endpointId)),E(String(t.providerData.endpointLabel)),O(String(t.providerData.origin)),A(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[J(`option`,{value:``,children:`Create new endpoint`}),w.map(e=>J(`option`,{value:String(e.providerData.endpointId),children:String(e.providerData.endpointLabel)},String(e.providerData.endpointId)))]})}),J(H,{label:`Endpoint ID`,children:e=>J(V,{...e,value:_,onChange:e=>S(e.target.value)})}),J(H,{label:`Endpoint label`,children:e=>J(V,{...e,value:T,onChange:e=>E(e.target.value)})}),J(H,{label:`Server origin`,children:e=>J(V,{...e,value:D,placeholder:`https://server.example`,onChange:e=>O(e.target.value)})}),D.trim().toLowerCase().startsWith(`http://`)?J(He,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,J(H,{label:`Protocol`,children:e=>Y(B,{...e,value:k,onChange:e=>A(e.target.value),children:[J(`option`,{value:`chat_completions`,children:`Chat Completions (/v1/chat/completions)`}),J(`option`,{value:`responses`,children:`Responses (/v1/responses)`})]})})]}):null,o===`apiKey`?J(H,{label:`API key`,children:e=>J(V,{...e,type:`password`,value:te,autoComplete:`off`,onChange:e=>ne(e.target.value)})}):null,J(H,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>J(V,{...e,value:c,placeholder:Z[i],onChange:e=>l(e.target.value)})})]}):Y(p,{$gap:3,children:[Y(p,{$gap:1,children:[J(u,{children:`Step 1 — authorize`}),J(b,{$gap:2,children:Y(y,{as:`a`,href:d.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[J(Ne,{}),`Open `,Z[i]]})}),J(re,{value:d.authorizeUrl,label:`Copy authorization link`})]}),d.userCode===null?null:Y(p,{$gap:1,children:[J(u,{children:`Step 2 — enter this code`}),J(Ve,{children:d.userCode})]}),d.kind===`device`?Y(Ue,{children:[Re[i],` Waiting for authorization…`]}):J(H,{label:`Authorization code`,hint:Re[i],...j===null?{}:{problem:j},children:e=>J(V,{...e,value:m,autoFocus:!0,placeholder:ze[i]??`code#state`,onChange:e=>g(e.target.value)})})]}),j===null||d?.kind===`pkce`?null:J(He,{children:j})]})})}var Ge=[`axis`],Ke=Ae((e,n)=>Oe.createElement(t,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Ge,tooltipPayloadSearcher:a,categoricalChartProps:e,ref:n})),qe=X(b)`
21
+ gap: ${({theme:e})=>e.space(5)};
22
+ flex-wrap: wrap;
23
+ `,Q=X.div`
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: 2px;
27
+ `,$=X.span`
28
+ font-size: 11.5px;
29
+ color: ${({theme:e})=>e.color.inkDim};
30
+ `,Je={budget:`1 4`,projection:`6 4`},Ye=`projected`;function Xe(e){let t=new Map;for(let{key:n,points:r}of e)for(let e of r){let r=t.get(e.at)??{at:e.at};r[n]=e.percent,t.set(e.at,r)}return[...t.values()].sort((e,t)=>e.at-t.at)}function Ze(e,t,n){return[Math.min(e,...n.map(e=>e.pace.from.at)),Math.max(t,...n.map(e=>e.pace.to.at))]}function Qe(e,t){let n=t?.windowStartsAt??null;return n===null||e.resetsAt===null?null:n-(e.resetsAt-n)}function $e({credentialId:e,windows:t,burn:n,pollIntervalMs:r,now:i}){let a=t.map(e=>{let t=pe(n,e.windowType);return{window:e,estimate:t,since:Qe(e,t)}}),o=a.map(e=>e.since).filter(e=>e!==null),s=o.length===0?0:Math.min(...o),c=d({credentialId:e,since:s},o.length>0),l=c.data?.samples??[],u=c.data?.gatewayRates??[];return J(p,{$gap:4,children:a.map(e=>J(tt,{window:e.window,estimate:e.estimate,since:e.since,samples:l.filter(t=>t.windowType===e.window.windowType&&t.observedAt>=(e.since??0)),gatewayRate:u.find(t=>t.windowType===e.window.windowType),pollIntervalMs:r,now:i},e.window.windowType))})}function et(e,t,n){let r=F(e,t);return r===`ok`?`lasts the window`:r!==`empty`||t.exhaustsAt===null?`unknown`:t.exhaustsAt<=n?`empty now`:`empty ~${fe(t.exhaustsAt-n)} before it resets`}function tt({window:t,estimate:a,since:d,samples:f,gatewayRate:h,pollIntervalMs:g,now:_}){let v=ge[t.windowType],y=t.limit===null?`${I(t.used)} used`:`${I(t.used)} of ${I(t.limit)} used`;if(a===void 0||a.stale||me(t,_,g))return Y(p,{$gap:2,children:[Y(b,{$gap:2,$wrap:!0,children:[Y(u,{children:[v,` window`]}),J($,{children:y})]}),J($,{children:`reading is stale`})]});let x=oe(xe(f),t),S=x.flatMap(e=>{let t=de(e);return t===null?[]:[{key:`${e.key}-budget`,pace:t}]}),C=ce(t,a),w=Xe([...x,...S.map(e=>({key:e.key,points:[e.pace.from,e.pace.to]})),...C===null?[]:[{key:Ye,points:[C.from,C.to]}]]),T=new Set(x.map(e=>e.key)),E=Math.max(100,...C===null?[]:[C.from.percent,C.to.percent].map(e=>Math.ceil(e))),D=d===null||t.resetsAt===null?null:Ze(d,t.resetsAt,S);return Y(p,{$gap:2,children:[Y(b,{$gap:2,$wrap:!0,children:[Y(u,{children:[v,` window`]}),J($,{children:y})]}),Y(qe,{children:[Y(Q,{children:[J(u,{children:`Window average`}),J(m,{children:a.ratePerHour===null?`unknown`:`${I(a.ratePerHour)}/h`})]}),Y(Q,{children:[J(u,{children:`Estimate`}),J(m,{children:et(t,a,_)})]}),Y(Q,{children:[J(u,{children:`Projected`}),J(m,{children:C===null?`unknown`:`${Math.round(C.to.percent)}% of limit by reset`})]}),Y(Q,{children:[J(u,{children:`This gateway accounts for`}),J(m,{children:h?.gatewayRatePerHour===void 0||h.gatewayRatePerHour===null?`unknown`:`${I(h.gatewayRatePerHour)} tokens/h`})]})]}),t.limit===null?J($,{children:`no ceiling reported`}):D===null?J($,{children:`no reset reported`}):x.length===0?J($,{children:`not yet observed`}):Y(q,{children:[J(u,{children:[`Used, this window and the one before`,...S.length===0?[]:[`budget dotted`],...C===null?[]:[`projection dashed`]].join(` · `)}),J(c,{$height:160,children:J(s,{width:`100%`,height:`100%`,children:Y(Ke,{data:w,margin:{top:4,right:8,bottom:4,left:4},children:[J(e,{stroke:`var(--rule)`,vertical:!1}),J(i,{dataKey:`at`,type:`number`,scale:`time`,domain:D,tickFormatter:e=>se(e,D[1]-D[0]),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,minTickGap:ae(D[1]-D[0])?80:40}),J(l,{domain:[0,E],allowDataOverflow:!0,tickFormatter:e=>`${Math.round(e)}%`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(r,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t})=>{if(e!==!0||t===void 0||t.length===0)return null;let n=t.find(e=>T.has(String(e.dataKey)));if(n===void 0||typeof n.value!=`number`)return null;let r=n.payload.at;return Y(o,{children:[J(`div`,{children:ie(r)}),Y(`div`,{children:[n.value.toFixed(1),`% used`]})]})}}),x.map(e=>J(n,{type:`monotone`,dataKey:e.key,stroke:`var(--accent)`,strokeWidth:2,dot:e.points.length===1&&{r:2.5,fill:`var(--accent)`,stroke:`var(--accent)`},connectNulls:!0,isAnimationActive:!1},e.key)),S.map(e=>J(n,{type:`linear`,dataKey:e.key,stroke:`var(--ink-faint)`,strokeWidth:1.5,strokeDasharray:Je.budget,dot:!1,connectNulls:!0,isAnimationActive:!1},e.key)),C===null?null:J(n,{type:`linear`,dataKey:Ye,stroke:`var(--ink-dim)`,strokeWidth:1.5,strokeDasharray:Je.projection,dot:!1,connectNulls:!0,isAnimationActive:!1})]})})})]})]})}var nt=[`anthropic`,`openai`,`kimi`,`kilo`,`grok`,`custom`],rt={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,kilo:`Kilo`,grok:`Grok`,custom:`OpenAI Compatible`},it=X(U)`
31
+ border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
32
+ `,at=X(V)`
33
+ width: 100%;
34
+ min-width: 140px;
35
+ height: 26px;
36
+ font-family: ${({theme:e})=>e.font.sans};
37
+ font-size: 12.5px;
38
+ background: transparent;
39
+ border-color: transparent;
40
+
41
+ &:hover:not(:disabled),
42
+ &:focus {
43
+ background: ${({theme:e})=>e.color.panelSunk};
44
+ border-color: ${({theme:e})=>e.color.ruleStrong};
45
+ }
46
+ `,ot=X(Ce)`
47
+ width: 62px;
48
+ height: 26px;
49
+ `,st=X.span`
50
+ display: block;
51
+ padding-left: 9px;
52
+ font-size: 11px;
53
+ color: ${({theme:e})=>e.color.inkDim};
54
+ `,ct=X.div`
55
+ display: grid;
56
+ grid-template-columns: 96px 1fr;
57
+ align-items: center;
58
+ min-width: 208px;
59
+ gap: 6px;
60
+ `,lt=X.div`
61
+ display: flex;
62
+ flex-direction: column;
63
+ gap: 4px;
64
+ `;function ut(){let e=f();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function dt(){let{cadence:e}=D(),t=g(),n=_(e(1e4)),r=E(),i=T(),{commit:a}=ut(),[o,s]=K(!1),[c,l]=K(null),[d,f]=K(new Set),m=e=>f(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),h=Date.now(),v=t.data??[],x=R(n.data?.health??[],e=>e.credentialId),C=R(n.data?.quota??[],e=>e.credentialId),O=R(n.data?.burn??[],e=>e.credentialId),ee=r.data?.quotaPollIntervalMs??3e5,re=v.filter(e=>e.enabled).length,F=t.isLoading?`Reading connected accounts…`:v.length===0?`No provider credentials are connected, so every request fails at the router.`:`${re} of ${v.length} accounts are enabled and eligible for routing.`;return Y(q,{children:[J(A,{legend:`Accounts`,title:`Provider accounts`,summary:F,actions:Y(y,{type:`button`,$variant:`primary`,onClick:()=>s(!0),children:[J(j,{}),`Connect an account`]})}),t.isError?J(U,{legend:`Accounts`,children:J(he,{error:t.error,onRetry:()=>void t.refetch()})}):t.isLoading?J(U,{legend:`Accounts`,children:J(_e,{rows:5})}):v.length===0?J(U,{legend:`Accounts`,children:J(ve,{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:J(y,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>s(!0),children:`Connect an account`})})}):J(p,{$gap:4,children:nt.filter(e=>v.some(t=>t.provider===e)).map(e=>{let t=v.filter(t=>t.provider===e);return J(it,{$provider:e,legend:rt[e],meta:`${t.length} account${t.length===1?``:`s`}`,flush:!0,children:J(S,{children:Y(Ee,{children:[J(`thead`,{children:Y(`tr`,{children:[J(G,{$width:`24%`,children:`Account`}),J(G,{$width:`20%`,children:`Sign-in`}),J(G,{$align:`right`,$width:`86px`,children:`Tier`}),J(G,{$align:`right`,$width:`94px`,children:`Weight`}),J(G,{$align:`center`,$width:`86px`,children:`Enabled`}),J(G,{$width:`240px`,children:`Quota`}),J(G,{$align:`right`,$width:`88px`,children:`TTFT`}),J(G,{$align:`right`,$width:`130px`,children:`Token expires`}),J(G,{$width:`76px`})]})}),J(`tbody`,{children:t.map(e=>{let t=ye(x.get(e.id)??[],h,e.enabled,e.disabledReason),n=C.get(e.id)??[],r=O.get(e.id)??[],i=ue(n),o=d.has(e.id);return Y(ke,{children:[Y(Te,{children:[Y(W,{children:[Y(b,{$gap:2,children:[J(le,{state:t.state,label:t.note===``?`healthy`:t.note}),J(at,{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}a(e.id,{label:n})}})]}),t.note===``?null:J(st,{children:t.note})]}),J(W,{children:Y(b,{$gap:1,children:[J(Se,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:J(u,{children:e.accountEmail})]})}),J(W,{$align:`right`,children:J(ot,{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}a(e.id,{tier:n})}})}),J(W,{$align:`right`,children:J(ot,{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}a(e.id,{weight:n})}})}),J(W,{$align:`center`,children:J(N,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>a(e.id,{enabled:t})})}),J(W,{children:i.length===0?J(u,{children:`unknown`}):J(lt,{children:i.map(({window:e,fraction:t})=>Y(ct,{children:[J(we,{fraction:t,label:`${ge[e.windowType]} window, ${Math.round(t*100)}% used`}),J(u,{children:be(e,h,ee,L,pe(r,e.windowType))})]},e.windowType))})}),J(W,{$align:`right`,$mono:!0,children:P(t.ttftMs)}),J(W,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:L(e.expiresAt,h)}),J(W,{$align:`right`,children:Y(b,{$gap:1,$justify:`flex-end`,children:[n.length===0?null:J(w,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":o,"aria-label":`${o?`Hide`:`Show`} quota history for ${e.label}`,title:`${o?`Hide`:`Show`} quota history for ${e.label}`,onClick:()=>m(e.id),children:J(o?ne:te,{})}),J(w,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>l(e),children:J(M,{})})]})})]}),o?J(Te,{children:J(W,{colSpan:9,children:J($e,{credentialId:e.id,windows:n,burn:r,pollIntervalMs:ee,now:h})})}):null]},e.id)})})]})})},e)})}),J(We,{open:o,credentials:t.data??[],onOpenChange:s,onConnected:()=>void t.refetch()}),J(k,{open:c!==null,onOpenChange:e=>{e||l(null)},title:`Remove account`,body:c===null?``:`Removing "${c.label}" deletes its stored token. Any model target pointing at ${rt[c.provider]} loses this account, and reconnecting means authorizing again.`,confirmLabel:`Remove account`,busy:i.isPending,onConfirm:()=>{c!==null&&i.mutate(c.id,{onSettled:()=>l(null)})}})]})}var ft=dt;export{ft as component};
@@ -1,4 +1,4 @@
1
- import{d as e,nt as t,t as n,tt as r}from"./queries-CX9mStps.js";import{a as i,t as a}from"./Rack-ziQuyb2l.js";import{E as o,n as s,r as c,t as l}from"./States-Shs8nZi1.js";import{i as u}from"./Field-B79Yxdit.js";import{t as d}from"./Panel-CoulMx6R.js";import{useLayoutEffect as f,useRef as p,useState as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";import _ from"styled-components";var v=[100,200,500],y=[{value:``,label:`All levels`},{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warnings and errors`},{value:`error`,label:`Errors only`}],b=_(t)`
1
+ import{d as e,nt as t,t as n,tt as r}from"./queries-CX9mStps.js";import{a as i,t as a}from"./Rack-fDZClWZL.js";import{D as o,n as s,r as c,t as l}from"./States-DtkkMzEu.js";import{i as u}from"./Field-B79Yxdit.js";import{t as d}from"./Panel-CoulMx6R.js";import{useLayoutEffect as f,useRef as p,useState as m}from"react";import{jsx as h,jsxs as g}from"react/jsx-runtime";import _ from"styled-components";var v=[100,200,500],y=[{value:``,label:`All levels`},{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warnings and errors`},{value:`error`,label:`Errors only`}],b=_(t)`
2
2
  gap: ${({theme:e})=>e.space(2)};
3
3
  flex-wrap: wrap;
4
4
  `,x=_(u)`
@@ -1,4 +1,4 @@
1
- import{$ as e,H as t,I as n,K as r,N as i,Q as a,S as o,_ as s,a as c,at as l,b as u,lt as d,m as f,nt as p,ot as m,rt as h}from"./queries-CX9mStps.js";import{g,o as _,t as v}from"./Rack-ziQuyb2l.js";import{A as y,D as b,i as x,k as S,n as C,r as w,t as T,w as E}from"./States-Shs8nZi1.js";import{r as D,t as O}from"./Field-B79Yxdit.js";import{t as k}from"./Meter-stpt3vQu.js";import{t as A}from"./Panel-CoulMx6R.js";import{i as j,n as M,r as N,t as P}from"./Table-CVDZ69Zx.js";import{t as F}from"./Readout-D1XEfywe.js";import{n as I}from"./reasons-Cb8yF4Oy.js";import{useQueryClient as L}from"@tanstack/react-query";import{useCallback as R,useState as z}from"react";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import U from"styled-components";var W=g(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),G=g(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),K=[{id:`keepLatest`,label:`Snapshots kept`,hint:`How many survive regardless of age. The newest is always kept, whatever both numbers say.`,unit:`files`,max:100},{id:`maxAgeDays`,label:`Maximum age`,hint:`Older snapshots are pruned after every new one and on the hourly maintenance sweep.`,unit:`days`,max:3650}],q=U.p`
1
+ import{$ as e,H as t,I as n,K as r,N as i,Q as a,S as o,_ as s,a as c,at as l,b as u,lt as d,m as f,nt as p,ot as m,rt as h}from"./queries-CX9mStps.js";import{g,o as _,t as v}from"./Rack-fDZClWZL.js";import{A as y,O as b,i as x,j as S,n as C,r as w,t as T,w as E}from"./States-DtkkMzEu.js";import{r as D,t as O}from"./Field-B79Yxdit.js";import{t as k}from"./Meter-stpt3vQu.js";import{t as A}from"./Panel-CoulMx6R.js";import{i as j,n as M,r as N,t as P}from"./Table-CVDZ69Zx.js";import{t as F}from"./Readout-D1XEfywe.js";import{n as I}from"./reasons-Cb8yF4Oy.js";import{useQueryClient as L}from"@tanstack/react-query";import{useCallback as R,useState as z}from"react";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import U from"styled-components";var W=g(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),G=g(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),K=[{id:`keepLatest`,label:`Snapshots kept`,hint:`How many survive regardless of age. The newest is always kept, whatever both numbers say.`,unit:`files`,max:100},{id:`maxAgeDays`,label:`Maximum age`,hint:`Older snapshots are pruned after every new one and on the hourly maintenance sweep.`,unit:`days`,max:3650}],q=U.p`
2
2
  font-size: 12px;
3
3
  color: ${({theme:e})=>e.color.down};
4
4
  `,J=U.p`
@@ -21,4 +21,4 @@ import{$ as e,H as t,I as n,K as r,N as i,Q as a,S as o,_ as s,a as c,at as l,b
21
21
  `,re=U.p`
22
22
  font-size: 12px;
23
23
  color: ${({theme:e})=>e.color.down};
24
- `;function ie(){let e=s(),t=r(),[n,i]=z(!1),o=e.data,c=o===void 0||o.logicalBytes===0?0:o.freePageBytes/o.logicalBytes;return H(B,{children:[V(v,{legend:`Database`,title:`Storage, snapshots, and retention`,summary:e.isLoading?`Measuring the database…`:`The one SQLite file this gateway runs from, the copies taken of it, and how long they are kept.`}),V(A,{legend:`Size`,meta:o===void 0?void 0:`schema v${o.stats.schemaVersion}`,actions:H(d,{type:`button`,$size:`sm`,disabled:t.isPending||o===void 0,onClick:()=>i(!0),children:[V(G,{}),t.isPending?`Compacting…`:`Compact`]}),footer:t.isError?V(re,{role:`alert`,children:x(t.error)}):t.data===void 0?void 0:V(ne,{role:`status`,children:`Compacted, reclaiming ${E(t.data.reclaimedBytes)} in ${S(t.data.durationMs)}.`}),children:e.isError?V(C,{error:e.error,onRetry:()=>void e.refetch()}):o===void 0?V(w,{rows:3}):H(a,{$min:`180px`,$stretch:!0,children:[V(F,{legend:`Database file`,value:E(o.fileBytes),unit:`${o.stats.pageCount} pages of ${E(o.stats.pageSize)}`,trace:V(k,{fraction:c,label:`${y(c,0)} of the file is reclaimable`})}),V(F,{legend:`Reclaimable`,value:E(o.freePageBytes),unit:`${o.stats.freelistCount} free pages`}),V(F,{legend:`Write-ahead log`,value:E(o.walBytes),unit:`folded into every snapshot`}),V(F,{legend:`Captured bodies`,value:E(o.bodiesBytes),unit:`never in a snapshot`}),V(F,{legend:`Snapshots`,value:E(o.snapshots.totalBytes),unit:`${o.snapshots.count} kept`}),V(F,{legend:`Free disk`,value:E(o.freeDiskBytes),unit:o.freeDiskBytes===null?`not readable here`:`on this filesystem`})]})}),V(te,{}),V(Z,{retention:o?.retention}),V(_,{open:n,onOpenChange:i,title:`Compact database`,body:`Running VACUUM rewrites the database to give back its free pages. It holds the write lock for as long as it takes, so requests in flight will wait, and it needs room on disk for a second copy while it runs.`,confirmLabel:`Compact database`,busy:t.isPending,onConfirm:()=>t.mutate(void 0,{onSettled:()=>i(!1)})})]})}var ae=ie;export{ae as component};
24
+ `;function ie(){let e=s(),t=r(),[n,i]=z(!1),o=e.data,c=o===void 0||o.logicalBytes===0?0:o.freePageBytes/o.logicalBytes;return H(B,{children:[V(v,{legend:`Database`,title:`Storage, snapshots, and retention`,summary:e.isLoading?`Measuring the database…`:`The one SQLite file this gateway runs from, the copies taken of it, and how long they are kept.`}),V(A,{legend:`Size`,meta:o===void 0?void 0:`schema v${o.stats.schemaVersion}`,actions:H(d,{type:`button`,$size:`sm`,disabled:t.isPending||o===void 0,onClick:()=>i(!0),children:[V(G,{}),t.isPending?`Compacting…`:`Compact`]}),footer:t.isError?V(re,{role:`alert`,children:x(t.error)}):t.data===void 0?void 0:V(ne,{role:`status`,children:`Compacted, reclaiming ${E(t.data.reclaimedBytes)} in ${y(t.data.durationMs)}.`}),children:e.isError?V(C,{error:e.error,onRetry:()=>void e.refetch()}):o===void 0?V(w,{rows:3}):H(a,{$min:`180px`,$stretch:!0,children:[V(F,{legend:`Database file`,value:E(o.fileBytes),unit:`${o.stats.pageCount} pages of ${E(o.stats.pageSize)}`,trace:V(k,{fraction:c,label:`${S(c,0)} of the file is reclaimable`})}),V(F,{legend:`Reclaimable`,value:E(o.freePageBytes),unit:`${o.stats.freelistCount} free pages`}),V(F,{legend:`Write-ahead log`,value:E(o.walBytes),unit:`folded into every snapshot`}),V(F,{legend:`Captured bodies`,value:E(o.bodiesBytes),unit:`never in a snapshot`}),V(F,{legend:`Snapshots`,value:E(o.snapshots.totalBytes),unit:`${o.snapshots.count} kept`}),V(F,{legend:`Free disk`,value:E(o.freeDiskBytes),unit:o.freeDiskBytes===null?`not readable here`:`on this filesystem`})]})}),V(te,{}),V(Z,{retention:o?.retention}),V(_,{open:n,onOpenChange:i,title:`Compact database`,body:`Running VACUUM rewrites the database to give back its free pages. It holds the write lock for as long as it takes, so requests in flight will wait, and it needs room on disk for a second copy while it runs.`,confirmLabel:`Compact database`,busy:t.isPending,onConfirm:()=>t.mutate(void 0,{onSettled:()=>i(!1)})})]})}var ae=ie;export{ae as component};
@@ -0,0 +1,62 @@
1
+ import{$ as e,D as t,G as n,O as r,Q as i,at as a,dt as o,et as s,g as c,h as l,it as u,lt as d,nt as f,ot as p,rt as m,z as h}from"./queries-CX9mStps.js";import{a as g,r as _,t as ee}from"./Rack-fDZClWZL.js";import{n as v,t as y}from"./TokenBreakdown-D70VeZ2N.js";import{A as b,D as x,E as S,M as C,N as w,a as T,b as te,d as E,g as D,h as O,j as k,l as A,n as j,o as M,p as N,s as P,t as F,u as I,v as ne,x as re}from"./States-DtkkMzEu.js";import{n as L,t as R}from"./Chip-BltJSw8A.js";import{t as z}from"./Meter-stpt3vQu.js";import{t as B}from"./Panel-CoulMx6R.js";import{i as V,n as H,r as U,t as W}from"./Table-CVDZ69Zx.js";import{t as G}from"./Readout-D1XEfywe.js";import{Fragment as K,jsx as q,jsxs as J}from"react/jsx-runtime";import Y from"styled-components";var X=Y(p)`
2
+ font-weight: 500;
3
+ display: block;
4
+ max-width: 24ch;
5
+ `,Z=Y.span`
6
+ font-size: 11px;
7
+ color: ${({theme:e})=>e.color.inkDim};
8
+ `,ie=Y.div`
9
+ display: grid;
10
+ grid-template-columns: 72px 1fr;
11
+ align-items: center;
12
+ gap: 6px;
13
+ min-width: 172px;
14
+ `,ae=Y.div`
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: 4px;
18
+ `;function oe(e){let t=null;for(let n of e)n.stale||n.survives!==!1||n.exhaustsAt===null||(t===null||n.exhaustsAt<t)&&(t=n.exhaustsAt);return t}function se(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function ce({credentials:t,health:n,quota:r,burn:i,usage:a,quotaPollIntervalMs:s,now:c}){let l=E(n,e=>e.credentialId),u=E(r,e=>e.credentialId),p=E(i,e=>e.credentialId),h=new Map(a.map(e=>[e.key,e])),g={down:0,warn:1,ok:2,idle:3,live:3},_=t.map(e=>{let t=p.get(e.id)??[];return{credential:e,status:I(l.get(e.id)??[],c,e.enabled,e.disabledReason),quota:te(u.get(e.id)??[]),burn:t,exhaustsAt:oe(t),usage:h.get(e.id)}}).sort((e,t)=>g[e.status.state]-g[t.status.state]||se(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return q(B,{legend:`Accounts`,meta:`${t.length} connected`,flush:!0,actions:q(d,{as:o,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:t.length===0?q(F,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:q(d,{as:o,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):q(m,{children:J(W,{children:[q(`thead`,{children:J(`tr`,{children:[q(U,{children:`Account`}),q(U,{children:`Provider`}),q(U,{$align:`right`,children:`Tier`}),q(U,{children:`Quota`}),q(U,{$align:`right`,children:`TTFT`}),q(U,{$align:`right`,children:`Requests`}),q(U,{$align:`right`,children:`Last used`})]})}),q(`tbody`,{children:_.map(({credential:t,status:n,quota:r,burn:i,usage:a})=>J(V,{children:[q(H,{children:J(f,{$gap:2,children:[q(T,{state:n.state,label:n.note===``?`healthy`:n.note}),J(`div`,{children:[q(X,{children:t.label}),n.note===``?null:q(Z,{children:n.note})]})]})}),q(H,{children:q(L,{provider:t.provider})}),q(H,{$align:`right`,$mono:!0,children:t.tier}),q(H,{children:r.length===0?q(Z,{children:`unknown`}):q(ae,{children:r.map(({window:t,fraction:n})=>J(ie,{children:[q(z,{fraction:n,label:`${M[t.windowType]} window, ${Math.round(n*100)}% used`}),q(e,{children:ne(t,c,s,C,A(i,t.windowType))})]},t.windowType))})}),q(H,{$align:`right`,$mono:!0,children:b(n.ttftMs)}),q(H,{$align:`right`,$mono:!0,children:a===void 0?`—`:x(a.requests)}),q(H,{$align:`right`,$mono:!0,children:C(n.lastUsedAt,c)})]},t.id))})]})})})}var le=Y.ul`
19
+ display: flex;
20
+ flex-direction: column;
21
+ `,ue=Y.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
+ `,de=Y(p)`
32
+ font-family: ${({theme:e})=>e.font.mono};
33
+ font-size: 12px;
34
+ max-width: 30ch;
35
+ `,fe=Y(s)`
36
+ color: ${({theme:e})=>e.color.down};
37
+ font-size: 11px;
38
+ `;function pe({logs:e}){let t=e.slice(0,12);return q(B,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:q(d,{as:o,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?q(F,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):q(le,{children:t.map(e=>J(ue,{children:[q(T,{state:D(e),label:O(e)}),q(s,{$dim:!0,children:S(e.at)}),q(de,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:q(s,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),q(u,{}),N(e)?q(s,{$dim:!0,"aria-label":`processing`,children:q(y,{})}):J(K,{children:[e.errorCode===null?null:q(fe,{children:e.errorCode}),e.attempts>1?J(s,{$dim:!0,children:[e.attempts,`×`]}):null,q(s,{$dim:!0,children:q(v,{tokens:e})}),q(s,{$dim:!0,children:b(e.durationMs)}),q(s,{$dim:!0,children:w(e.costUsd)})]})]},e.id))})})}var me=Y.ul`
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: ${({theme:e})=>e.space(3)};
42
+ `,Q=Y(p)`
43
+ font-family: ${({theme:e})=>e.font.mono};
44
+ font-size: 12.5px;
45
+ `,he=Y.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
+ `,ge=Y.div`
53
+ flex: ${({$grow:e})=>e} 0 0;
54
+ background: ${({$color:e})=>e};
55
+ opacity: 0.8;
56
+ `,_e=Y.div`
57
+ flex: ${({$grow:e})=>e} 0 0;
58
+ `;function ve({models:t,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=[...t].map(e=>({model:e,used:r.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return q(B,{legend:`Models`,meta:`${t.length} configured`,actions:q(d,{as:o,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.length===0?q(F,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:q(d,{as:o,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):q(me,{children:a.map(({model:t,used:n})=>{let r=(n?.requests??0)/i,a=[...new Set(t.targets.map(e=>e.provider))];return J(`li`,{children:[J(f,{$gap:2,children:[q(Q,{title:t.id,children:t.id}),t.isAlias?q(R,{children:`alias`}):null,q(R,{$tone:`accent`,children:t.strategy}),q(u,{}),q(s,{$dim:!0,children:x(n?.requests??0)}),q(e,{children:`req`}),q(s,{$dim:!0,children:w(n?.costUsd??0)})]}),J(he,{style:{marginTop:6},title:`${Math.round(r*100)}% of the busiest model`,children:[a.map(e=>q(ge,{$color:`var(--p-${e})`,$grow:r/a.length},e)),q(_e,{$grow:Math.max(0,1-r)})]})]},t.id)})})})}var ye=Y.div`
59
+ display: grid;
60
+ grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
61
+ gap: ${({theme:e})=>e.space(3)};
62
+ `;function be({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=re(r,t),a=P(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 J(ye,{children:[q(G,{legend:`Requests`,value:x(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:q(_,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),q(G,{legend:`Error rate`,value:k(i.errorRate),unit:`${x(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:q(_,{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`})}),q(G,{legend:`Total tokens`,value:x(s),unit:q(v,{tokens:i}),trace:q(_,{values:a.map(e=>e.tokens),label:`token volume over the window, ${s.toLocaleString(`en-US`)} total`})}),q(G,{legend:`Time to first token`,value:b(i.ttftP50),unit:`p95 ${b(i.ttftP95)}`,trace:q(_,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${b(i.ttftP50)}`})}),q(G,{legend:`Spend`,value:w(i.costUsd),unit:`${x(i.inputTokens+i.outputTokens)} tokens`,trace:q(_,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${w(i.costUsd)} total`})})]})}var $=36e5;function xe(){let{cadence:e}=g(),o=c(),s=l(e(1e4)),u=r(),d=t(500,e(1e4)),f=h(),p=Date.now(),m=Math.floor((p-$)/6e4)*6e4,_=n({groupBy:`credential`,since:m},e(6e4)),v=o.data??[],y=E(s.data?.health??[],e=>e.credentialId),b=v.filter(e=>I(y.get(e.id)??[],p,e.enabled,e.disabledReason).state===`down`),x=o.isLoading||d.isLoading?`Reading the gateway…`:v.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 ${v.length} accounts are answering. Nothing needs attention.`;return J(K,{children:[q(ee,{legend:`Rack`,title:`Gateway`,summary:x}),d.isError?q(B,{legend:`Traffic`,children:q(j,{legend:`The gateway did not answer`,error:d.error,onRetry:()=>void d.refetch()})}):J(a,{$gap:4,children:[q(be,{logs:d.data??[],windowMs:$,now:p}),q(ce,{credentials:v,health:s.data?.health??[],quota:s.data?.quota??[],burn:s.data?.burn??[],usage:_.data??[],quotaPollIntervalMs:f.data?.quotaPollIntervalMs??3e5,now:p}),J(i,{$min:`340px`,$gap:4,children:[q(ve,{models:u.data??[],logs:d.data??[]}),q(pe,{logs:d.data??[]})]})]})]})}var Se=xe;export{Se as component};
@@ -1,4 +1,4 @@
1
- import{$ as e,C as t,O as n,P as r,R as i,at as a,et as o,lt as s,nt as c,ot as l,p as u,rt as d,ut as f}from"./queries-CX9mStps.js";import{m as p,o as m,s as h,t as g}from"./Rack-ziQuyb2l.js";import{n as _,r as v,t as y}from"./CopyValue-CHZz2PLE.js";import{t as b}from"./plus-Cdyfj4uP.js";import{t as x}from"./Toggle-CNnMgEU1.js";import{D as S,i as C,n as w,r as T,t as E}from"./States-Shs8nZi1.js";import{t as D}from"./Chip-BltJSw8A.js";import{n as O,r as k,t as A}from"./Field-B79Yxdit.js";import{t as j}from"./Meter-stpt3vQu.js";import{t as M}from"./Panel-CoulMx6R.js";import{i as N,n as P,r as F,t as I}from"./Table-CVDZ69Zx.js";import{Fragment as L,useState as R}from"react";import{Fragment as z,jsx as B,jsxs as V}from"react/jsx-runtime";import H from"styled-components";var U=[{dimension:`requests`,window:`1m`},{dimension:`requests`,window:`5h`},{dimension:`requests`,window:`1w`},{dimension:`tokens`,window:`1m`},{dimension:`tokens`,window:`5h`},{dimension:`tokens`,window:`1w`},{dimension:`spend`,window:`5h`},{dimension:`spend`,window:`1w`},{dimension:`concurrency`,window:null}];function W(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var G={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},ee={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=G[e.dimension];return e.window===null?t:`${t} ${ee[e.window]}`}function q(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function J(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function te(e){let t=null,n=-1;for(let r of e){let e=J(r);e!==null&&e>n&&(t=r,n=e)}return t}function Y(e){let t={};for(let e of U)t[W(e)]=``;if(e===null)return t;for(let n of U){let r=n.window===null?e.concurrency:n.dimension===`requests`?e.requests?.[n.window]:n.dimension===`tokens`?e.tokens?.[n.window]:n.window===`1m`?void 0:e.spend?.[n.window];r!=null&&(t[W(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of U){let o=(e[W(a)]??``).trim();if(o.length===0)continue;let s=Number(o),c=a.dimension===`spend`;if(!Number.isFinite(s)||s<=0||!c&&!Number.isInteger(s))return{problem:c?`${K(a)} must be an amount above zero, or blank for no limit.`:`${K(a)} must be a whole number above zero, or blank for no limit.`};a.window===null?i=s:a.dimension===`requests`?t[a.window]=s:a.dimension===`tokens`?n[a.window]=s:a.window!==`1m`&&(r[a.window]=s)}return{limits:{...Object.keys(t).length>0?{requests:t}:{},...Object.keys(n).length>0?{tokens:n}:{},...Object.keys(r).length>0?{spend:r}:{},...i===void 0?{}:{concurrency:i}}}}var Z=H.div`
1
+ import{$ as e,C as t,O as n,P as r,R as i,at as a,et as o,lt as s,nt as c,ot as l,p as u,rt as d,ut as f}from"./queries-CX9mStps.js";import{m as p,o as m,s as h,t as g}from"./Rack-fDZClWZL.js";import{n as _,r as v,t as y}from"./CopyValue-By5BAgv7.js";import{t as b}from"./plus-UDQ_BTEr.js";import{t as x}from"./Toggle-ClEeOh0F.js";import{O as S,i as C,n as w,r as T,t as E}from"./States-DtkkMzEu.js";import{t as D}from"./Chip-BltJSw8A.js";import{n as O,r as k,t as A}from"./Field-B79Yxdit.js";import{t as j}from"./Meter-stpt3vQu.js";import{t as M}from"./Panel-CoulMx6R.js";import{i as N,n as P,r as F,t as I}from"./Table-CVDZ69Zx.js";import{Fragment as L,useState as R}from"react";import{Fragment as z,jsx as B,jsxs as V}from"react/jsx-runtime";import H from"styled-components";var U=[{dimension:`requests`,window:`1m`},{dimension:`requests`,window:`5h`},{dimension:`requests`,window:`1w`},{dimension:`tokens`,window:`1m`},{dimension:`tokens`,window:`5h`},{dimension:`tokens`,window:`1w`},{dimension:`spend`,window:`5h`},{dimension:`spend`,window:`1w`},{dimension:`concurrency`,window:null}];function W(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var G={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},ee={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=G[e.dimension];return e.window===null?t:`${t} ${ee[e.window]}`}function q(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function J(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function te(e){let t=null,n=-1;for(let r of e){let e=J(r);e!==null&&e>n&&(t=r,n=e)}return t}function Y(e){let t={};for(let e of U)t[W(e)]=``;if(e===null)return t;for(let n of U){let r=n.window===null?e.concurrency:n.dimension===`requests`?e.requests?.[n.window]:n.dimension===`tokens`?e.tokens?.[n.window]:n.window===`1m`?void 0:e.spend?.[n.window];r!=null&&(t[W(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of U){let o=(e[W(a)]??``).trim();if(o.length===0)continue;let s=Number(o),c=a.dimension===`spend`;if(!Number.isFinite(s)||s<=0||!c&&!Number.isInteger(s))return{problem:c?`${K(a)} must be an amount above zero, or blank for no limit.`:`${K(a)} must be a whole number above zero, or blank for no limit.`};a.window===null?i=s:a.dimension===`requests`?t[a.window]=s:a.dimension===`tokens`?n[a.window]=s:a.window!==`1m`&&(r[a.window]=s)}return{limits:{...Object.keys(t).length>0?{requests:t}:{},...Object.keys(n).length>0?{tokens:n}:{},...Object.keys(r).length>0?{spend:r}:{},...i===void 0?{}:{concurrency:i}}}}var Z=H.div`
2
2
  display: grid;
3
3
  grid-template-columns: repeat(3, minmax(0, 1fr));
4
4
  gap: ${({theme:e})=>e.space(2)};
@@ -1,4 +1,4 @@
1
- import{$ as e,C as t,D as n,at as r,et as i,g as ee,j as a,lt as o,n as te,nt as s,ot as c,rt as l,s as u}from"./queries-CX9mStps.js";import{a as d,s as ne,t as re}from"./Rack-ziQuyb2l.js";import{n as f,r as p,t as m}from"./TokenBreakdown-hkwYCWT3.js";import{D as h,E as g,M as _,N as v,O as ie,T as ae,a as oe,f as y,g as se,h as ce,k as b,n as x,p as S,r as C,t as w}from"./States-Shs8nZi1.js";import{n as T,t as E}from"./Chip-BltJSw8A.js";import{i as D,n as O}from"./Field-B79Yxdit.js";import{t as k}from"./Panel-CoulMx6R.js";import{i as le,n as A,r as j,t as ue}from"./Table-CVDZ69Zx.js";import{useEffect as M,useMemo as N,useState as P}from"react";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import R from"styled-components";var z={none:{legend:`Not captured`,message:`Body capture was not running for this request. It needs OMNI_BODY_LOGGING_ALLOWED in the environment and the body logging setting turned on, and the calling key must not have opted out.`},missing:{legend:`Captured, then lost`,message:`This request was captured, but its artifact is no longer on disk. Retention or the row cap has since pruned it, or something removed the file underneath the gateway.`},corrupt:{legend:`Captured, but unreadable`,message:`This request was captured and the artifact is still on disk, but it failed its checksum or would not decrypt. Changing OMNI_ENCRYPTION_KEY invalidates every artifact written under the old one.`}},B=new Intl.NumberFormat(`en-US`),V=R.p`
1
+ import{$ as e,C as t,D as n,at as r,et as i,g as ee,j as a,lt as o,n as te,nt as s,ot as c,rt as l,s as u}from"./queries-CX9mStps.js";import{a as ne,s as re,t as ie}from"./Rack-fDZClWZL.js";import{n as d,r as f,t as p}from"./TokenBreakdown-D70VeZ2N.js";import{A as m,D as h,E as g,F as _,N as v,O as y,a as ae,f as b,g as oe,h as se,k as ce,n as x,p as S,r as C,t as w}from"./States-DtkkMzEu.js";import{n as T,t as E}from"./Chip-BltJSw8A.js";import{i as D,n as O}from"./Field-B79Yxdit.js";import{t as k}from"./Panel-CoulMx6R.js";import{i as le,n as A,r as j,t as ue}from"./Table-CVDZ69Zx.js";import{useEffect as M,useMemo as N,useState as P}from"react";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import R from"styled-components";var z={none:{legend:`Not captured`,message:`Body capture was not running for this request. It needs OMNI_BODY_LOGGING_ALLOWED in the environment and the body logging setting turned on, and the calling key must not have opted out.`},missing:{legend:`Captured, then lost`,message:`This request was captured, but its artifact is no longer on disk. Retention or the row cap has since pruned it, or something removed the file underneath the gateway.`},corrupt:{legend:`Captured, but unreadable`,message:`This request was captured and the artifact is still on disk, but it failed its checksum or would not decrypt. Changing OMNI_ENCRYPTION_KEY invalidates every artifact written under the old one.`}},B=new Intl.NumberFormat(`en-US`),V=R.p`
2
2
  font-size: 12px;
3
3
  color: ${({theme:e})=>e.color.inkDim};
4
4
  max-width: 62ch;
@@ -34,7 +34,7 @@ import{$ as e,C as t,D as n,at as r,et as i,g as ee,j as a,lt as o,n as te,nt as
34
34
  line-height: 1.5;
35
35
  white-space: pre-wrap;
36
36
  word-break: break-word;
37
- `;function q(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(t.omitted!==!0||typeof t.reason!=`string`)return null;let n=t.serializedBytes;return{omitted:!0,reason:t.reason,serializedBytes:typeof n==`number`?n:0}}function J({title:e,stage:t,value:n}){let r=q(n);return L(G,{children:[L(W,{children:[I(U,{children:e}),t===void 0?null:I(E,{children:t})]}),r===null?n==null?I(V,{children:`Nothing was recorded for this half — it never happened, or never completed.`}):I(K,{children:JSON.stringify(n,null,2)}):L(V,{children:[`Too large to keep: `,r.reason,`. The payload was`,` `,B.format(r.serializedBytes),` bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace.`]})]})}function Y({attempt:t}){return L(r,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[L(e,{as:`h3`,children:[`Attempt `,t.attempt,` · `,t.provider]}),t.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request sent to the provider`,stage:`post-RTK`,value:t.request}),I(J,{title:`Response from the provider`,value:t.response}),t.streamChunks===null?null:I(J,{title:`Raw stream frames (${g(t.streamChunks.length)})`,value:t.streamChunks})]})}function X({body:t}){let n=t.artifact;if(n===null){let n=z[t.detailState===`ready`?`corrupt`:t.detailState];return L(r,{$gap:1,children:[I(e,{children:n.legend}),I(V,{children:n.message})]})}return L(r,{$gap:3,children:[n.attempts.length===0?null:I(H,{children:`The client request below is what arrived at the gateway. Each attempt request is what went upstream after RTK filters ran, so the two are not the same payload — compare them to see what compression actually removed.`}),L(r,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[I(e,{as:`h3`,children:`Client`}),n.client.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request from the client`,stage:`pre-RTK`,value:n.client.request}),I(J,{title:`Response returned to the client`,value:n.client.response})]}),n.attempts.map(e=>I(Y,{attempt:e},`${e.attempt}-${e.provider}`)),n.error===null||n.error===void 0?null:I(J,{title:`Error`,value:n.error})]})}function de({requestId:e}){let t=a(e),n=t.data===void 0||t.data.detailState!==`ready`?void 0:`${B.format(t.data.sizeBytes)} bytes on disk`;return I(k,{legend:`Captured bodies`,...n===void 0?{}:{meta:n},...t.data?.truncated===!0?{actions:I(E,{$tone:`warn`,children:`truncated`})}:{},children:t.isError?I(x,{error:t.error,onRetry:()=>void t.refetch()}):t.isPending?I(C,{rows:3}):I(X,{body:t.data})})}var fe=[50,100,250,500],pe=R(s)`
37
+ `;function q(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(t.omitted!==!0||typeof t.reason!=`string`)return null;let n=t.serializedBytes;return{omitted:!0,reason:t.reason,serializedBytes:typeof n==`number`?n:0}}function J({title:e,stage:t,value:n}){let r=q(n);return L(G,{children:[L(W,{children:[I(U,{children:e}),t===void 0?null:I(E,{children:t})]}),r===null?n==null?I(V,{children:`Nothing was recorded for this half — it never happened, or never completed.`}):I(K,{children:JSON.stringify(n,null,2)}):L(V,{children:[`Too large to keep: `,r.reason,`. The payload was`,` `,B.format(r.serializedBytes),` bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace.`]})]})}function Y({attempt:t}){return L(r,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[L(e,{as:`h3`,children:[`Attempt `,t.attempt,` · `,t.provider]}),t.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request sent to the provider`,stage:`post-RTK`,value:t.request}),I(J,{title:`Response from the provider`,value:t.response}),t.streamChunks===null?null:I(J,{title:`Raw stream frames (${h(t.streamChunks.length)})`,value:t.streamChunks})]})}function X({body:t}){let n=t.artifact;if(n===null){let n=z[t.detailState===`ready`?`corrupt`:t.detailState];return L(r,{$gap:1,children:[I(e,{children:n.legend}),I(V,{children:n.message})]})}return L(r,{$gap:3,children:[n.attempts.length===0?null:I(H,{children:`The client request below is what arrived at the gateway. Each attempt request is what went upstream after RTK filters ran, so the two are not the same payload — compare them to see what compression actually removed.`}),L(r,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[I(e,{as:`h3`,children:`Client`}),n.client.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request from the client`,stage:`pre-RTK`,value:n.client.request}),I(J,{title:`Response returned to the client`,value:n.client.response})]}),n.attempts.map(e=>I(Y,{attempt:e},`${e.attempt}-${e.provider}`)),n.error===null||n.error===void 0?null:I(J,{title:`Error`,value:n.error})]})}function de({requestId:e}){let t=a(e),n=t.data===void 0||t.data.detailState!==`ready`?void 0:`${B.format(t.data.sizeBytes)} bytes on disk`;return I(k,{legend:`Captured bodies`,...n===void 0?{}:{meta:n},...t.data?.truncated===!0?{actions:I(E,{$tone:`warn`,children:`truncated`})}:{},children:t.isError?I(x,{error:t.error,onRetry:()=>void t.refetch()}):t.isPending?I(C,{rows:3}):I(X,{body:t.data})})}var fe=[50,100,250,500],pe=R(s)`
38
38
  gap: ${({theme:e})=>e.space(2)};
39
39
  flex-wrap: wrap;
40
40
  `,me=R(O)`
@@ -55,7 +55,7 @@ import{$ as e,C as t,D as n,at as r,et as i,g as ee,j as a,lt as o,n as te,nt as
55
55
  flex: 1;
56
56
  min-height: 0;
57
57
  overflow-y: auto;
58
- `;function ge(e){let[t,n]=P(Date.now);return M(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function _e({log:e}){return I(A,{$align:`right`,$mono:!0,...S(e)?{"aria-label":`processing`}:{title:p(e)},children:S(e)?I(m,{}):I(f,{tokens:e})})}var ve=R.dl`
58
+ `;function ge(e){let[t,n]=P(Date.now);return M(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function _e({log:e}){return I(A,{$align:`right`,$mono:!0,...S(e)?{"aria-label":`processing`}:{title:f(e)},children:S(e)?I(p,{}):I(d,{tokens:e})})}var ve=R.dl`
59
59
  display: grid;
60
60
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
61
61
  gap: 6px ${({theme:e})=>e.space(3)};
@@ -65,4 +65,4 @@ import{$ as e,C as t,D as n,at as r,et as i,g as ee,j as a,lt as o,n as te,nt as
65
65
  margin: 0;
66
66
  font-family: ${({theme:e})=>e.font.mono};
67
67
  word-break: break-all;
68
- `;function ye(){let{cadence:a,live:l}=d(),[f,p]=P(100),[m,D]=P(`all`),[O,k]=P(``),[M,R]=P(null),z=n(f,a(te)),B=ee(),V=t(),H=u(),U=(z.data??[]).some(S),W=ge(l&&U),G=N(()=>{let e=new Map;for(let t of B.data??[])e.set(t.id,t.label);return e},[B.data]),K=N(()=>{let e=new Map;for(let t of V.data??[])e.set(t.id,t.label);return e},[V.data]),q=O.trim().toLowerCase(),J=(z.data??[]).filter(e=>m===`failed`&&!y(e)?!1:q.length===0||e.requestedModel.toLowerCase().includes(q)||(e.resolvedModel??``).toLowerCase().includes(q)||(e.errorCode??``).toLowerCase().includes(q)||(e.credentialId===null?``:G.get(e.credentialId)??``).toLowerCase().includes(q)||(e.apiKeyId===null?``:K.get(e.apiKeyId)??e.apiKeyId).toLowerCase().includes(q)),Y=(z.data??[]).filter(y).length,X=(z.data??[]).filter(S).length;return L(F,{children:[I(re,{legend:`Logs`,title:`Recent requests`,summary:z.isLoading?`Reading the request log…`:`${g(z.data?.length??0)} recent requests, ${g(Y)} of them failed${X===0?``:`, ${g(X)} still running`}. ${H.data===!0?`Body capture is on: open a request to read what it sent and received.`:`Prompt and response bodies are not being recorded.`}`,actions:L(pe,{children:[I(me,{value:O,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>k(e.target.value)}),L(Z,{value:m,"aria-label":`Show which requests`,onChange:e=>D(e.target.value),children:[I(`option`,{value:`all`,children:`All requests`}),I(`option`,{value:`failed`,children:`Failed only`})]}),I(Z,{value:f,"aria-label":`How many requests to fetch`,onChange:e=>p(Number(e.target.value)),children:fe.map(e=>L(`option`,{value:e,children:[`last `,e]},e))})]})}),I(Q,{legend:`Request log`,meta:`${J.length} shown`,flush:!0,children:z.isError?I(x,{error:z.error,onRetry:()=>void z.refetch()}):z.isLoading?I(`div`,{style:{padding:12},children:I(C,{rows:8})}):J.length===0?I(w,{legend:`Nothing to show`,message:(z.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):I(he,{"data-testid":`request-log-scroller`,children:L(ue,{children:[I(`thead`,{children:L(`tr`,{children:[I(j,{}),I(j,{$align:`right`,children:`Time`}),I(j,{children:`Requested`}),I(j,{children:`Routed to`}),I(j,{children:`Account`}),I(j,{children:`Key`}),I(j,{$align:`right`,children:`Try`}),I(j,{$align:`right`,children:`TTFT`}),I(j,{$align:`right`,children:`Total`}),I(j,{$align:`right`,children:`Tokens`}),I(j,{$align:`right`,children:`Cost`}),I(j,{children:`Outcome`})]})}),I(`tbody`,{children:J.map(t=>L(le,{$selectable:!0,onClick:()=>R(t),children:[I(A,{children:I(oe,{state:se(t),label:ce(t)})}),I(A,{$align:`right`,$mono:!0,title:h(t.at),children:ae(t.at)}),I(A,{$mono:!0,children:I(c,{style:{display:`block`,maxWidth:`20ch`},children:t.requestedModel||`—`})}),I(A,{children:t.resolvedProvider===null?I(e,{children:S(t)?`routing…`:`not routed`}):L(s,{$gap:1,children:[I(T,{provider:t.resolvedProvider}),I(i,{$dim:!0,children:t.resolvedModel??`—`})]})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`18ch`},children:t.credentialId===null?`—`:G.get(t.credentialId)??v(t.credentialId)})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`16ch`},title:t.apiKeyId??void 0,children:t.apiKeyId===null?`—`:K.get(t.apiKeyId)??v(t.apiKeyId)})}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:t.attempts}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:b(t.ttftMs)}),I(A,{$align:`right`,$mono:!0,children:S(t)?ie(Math.max(0,W-t.at)):b(t.durationMs)}),I(_e,{log:t}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:_(t.costUsd)}),I(A,{children:S(t)?I(E,{$tone:`accent`,children:`live`}):t.errorCode===null?I(E,{$tone:`ok`,children:t.status}):I(E,{$tone:`down`,children:t.errorCode})})]},t.id))})]})})}),I(ne,{open:M!==null,onOpenChange:e=>{e||R(null)},title:`Request detail`,width:`760px`,footer:I(o,{type:`button`,onClick:()=>R(null),children:`Close`}),children:M===null?null:L(r,{$gap:3,children:[L(ve,{children:[I(e,{as:`dt`,children:`Request id`}),I($,{children:M.id}),I(e,{as:`dt`,children:`At`}),I($,{children:h(M.at)}),I(e,{as:`dt`,children:`Requested model`}),I($,{children:M.requestedModel||`—`}),I(e,{as:`dt`,children:`Routed to`}),I($,{children:S(M)?`—`:M.resolvedProvider===null?`not routed`:`${M.resolvedProvider} · ${M.resolvedModel??`—`}`}),I(e,{as:`dt`,children:`Account`}),I($,{children:M.credentialId===null?`—`:G.get(M.credentialId)??M.credentialId}),I(e,{as:`dt`,children:`Key`}),I($,{children:M.apiKeyId===null?`—`:K.get(M.apiKeyId)??M.apiKeyId}),I(e,{as:`dt`,children:`Attempts`}),I($,{children:S(M)?`—`:M.attempts}),I(e,{as:`dt`,children:`Status`}),I($,{children:S(M)?`in flight`:M.errorCode===null?M.status:`${M.status} ${M.errorCode}`}),I(e,{as:`dt`,children:`Timing`}),I($,{children:S(M)?`—`:`first token ${b(M.ttftMs)} · total ${b(M.durationMs)}`}),I(e,{as:`dt`,children:`Tokens`}),I($,{children:S(M)?`—`:L(F,{children:[g(M.inputTokens),` in · `,g(M.outputTokens),` out ·`,` `,g(M.cacheReadTokens),` cache read ·`,` `,g(M.cacheWriteTokens),` cache write`]})}),I(e,{as:`dt`,children:`Cost`}),I($,{children:S(M)?`—`:_(M.costUsd)}),I(e,{as:`dt`,children:`RTK compression`}),I($,{children:S(M)?`—`:M.rtkApplied?`${g(M.rtkFilterHits)} hits · ${g(M.rtkOriginalCodeUnits)} → ${g(M.rtkCompressedCodeUnits)} code units · ~${g(M.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),I(e,{as:`dt`,children:`RTK filters`}),I($,{children:M.rtkFilters.length===0?`—`:M.rtkFilters.join(`, `)})]}),M.degradations.length===0?null:L(r,{$gap:1,children:[I(e,{children:`Capabilities dropped to fit the target`}),I(s,{$gap:1,$wrap:!0,children:M.degradations.map(e=>I(E,{$tone:`warn`,children:e},e))})]}),I(de,{requestId:M.id})]})})]})}var be=ye;export{be as component};
68
+ `;function ye(){let{cadence:a,live:l}=ne(),[d,f]=P(100),[p,D]=P(`all`),[O,k]=P(``),[M,R]=P(null),z=n(d,a(te)),B=ee(),V=t(),H=u(),U=(z.data??[]).some(S),W=ge(l&&U),G=N(()=>{let e=new Map;for(let t of B.data??[])e.set(t.id,t.label);return e},[B.data]),K=N(()=>{let e=new Map;for(let t of V.data??[])e.set(t.id,t.label);return e},[V.data]),q=O.trim().toLowerCase(),J=(z.data??[]).filter(e=>p===`failed`&&!b(e)?!1:q.length===0||e.requestedModel.toLowerCase().includes(q)||(e.resolvedModel??``).toLowerCase().includes(q)||(e.errorCode??``).toLowerCase().includes(q)||(e.credentialId===null?``:G.get(e.credentialId)??``).toLowerCase().includes(q)||(e.apiKeyId===null?``:K.get(e.apiKeyId)??e.apiKeyId).toLowerCase().includes(q)),Y=(z.data??[]).filter(b).length,X=(z.data??[]).filter(S).length;return L(F,{children:[I(ie,{legend:`Logs`,title:`Recent requests`,summary:z.isLoading?`Reading the request log…`:`${h(z.data?.length??0)} recent requests, ${h(Y)} of them failed${X===0?``:`, ${h(X)} still running`}. ${H.data===!0?`Body capture is on: open a request to read what it sent and received.`:`Prompt and response bodies are not being recorded.`}`,actions:L(pe,{children:[I(me,{value:O,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>k(e.target.value)}),L(Z,{value:p,"aria-label":`Show which requests`,onChange:e=>D(e.target.value),children:[I(`option`,{value:`all`,children:`All requests`}),I(`option`,{value:`failed`,children:`Failed only`})]}),I(Z,{value:d,"aria-label":`How many requests to fetch`,onChange:e=>f(Number(e.target.value)),children:fe.map(e=>L(`option`,{value:e,children:[`last `,e]},e))})]})}),I(Q,{legend:`Request log`,meta:`${J.length} shown`,flush:!0,children:z.isError?I(x,{error:z.error,onRetry:()=>void z.refetch()}):z.isLoading?I(`div`,{style:{padding:12},children:I(C,{rows:8})}):J.length===0?I(w,{legend:`Nothing to show`,message:(z.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):I(he,{"data-testid":`request-log-scroller`,children:L(ue,{children:[I(`thead`,{children:L(`tr`,{children:[I(j,{}),I(j,{$align:`right`,children:`Time`}),I(j,{children:`Requested`}),I(j,{children:`Routed to`}),I(j,{children:`Account`}),I(j,{children:`Key`}),I(j,{$align:`right`,children:`Try`}),I(j,{$align:`right`,children:`TTFT`}),I(j,{$align:`right`,children:`Total`}),I(j,{$align:`right`,children:`Tokens`}),I(j,{$align:`right`,children:`Cost`}),I(j,{children:`Outcome`})]})}),I(`tbody`,{children:J.map(t=>L(le,{$selectable:!0,onClick:()=>R(t),children:[I(A,{children:I(ae,{state:oe(t),label:se(t)})}),I(A,{$align:`right`,$mono:!0,title:y(t.at),children:g(t.at)}),I(A,{$mono:!0,children:I(c,{style:{display:`block`,maxWidth:`20ch`},children:t.requestedModel||`—`})}),I(A,{children:t.resolvedProvider===null?I(e,{children:S(t)?`routing…`:`not routed`}):L(s,{$gap:1,children:[I(T,{provider:t.resolvedProvider}),I(i,{$dim:!0,children:t.resolvedModel??`—`})]})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`18ch`},children:t.credentialId===null?`—`:G.get(t.credentialId)??_(t.credentialId)})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`16ch`},title:t.apiKeyId??void 0,children:t.apiKeyId===null?`—`:K.get(t.apiKeyId)??_(t.apiKeyId)})}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:t.attempts}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:m(t.ttftMs)}),I(A,{$align:`right`,$mono:!0,children:S(t)?ce(Math.max(0,W-t.at)):m(t.durationMs)}),I(_e,{log:t}),I(A,{$align:`right`,$mono:!0,children:S(t)?`—`:v(t.costUsd)}),I(A,{children:S(t)?I(E,{$tone:`accent`,children:`live`}):t.errorCode===null?I(E,{$tone:`ok`,children:t.status}):I(E,{$tone:`down`,children:t.errorCode})})]},t.id))})]})})}),I(re,{open:M!==null,onOpenChange:e=>{e||R(null)},title:`Request detail`,width:`760px`,footer:I(o,{type:`button`,onClick:()=>R(null),children:`Close`}),children:M===null?null:L(r,{$gap:3,children:[L(ve,{children:[I(e,{as:`dt`,children:`Request id`}),I($,{children:M.id}),I(e,{as:`dt`,children:`At`}),I($,{children:y(M.at)}),I(e,{as:`dt`,children:`Requested model`}),I($,{children:M.requestedModel||`—`}),I(e,{as:`dt`,children:`Routed to`}),I($,{children:S(M)?`—`:M.resolvedProvider===null?`not routed`:`${M.resolvedProvider} · ${M.resolvedModel??`—`}`}),I(e,{as:`dt`,children:`Account`}),I($,{children:M.credentialId===null?`—`:G.get(M.credentialId)??M.credentialId}),I(e,{as:`dt`,children:`Key`}),I($,{children:M.apiKeyId===null?`—`:K.get(M.apiKeyId)??M.apiKeyId}),I(e,{as:`dt`,children:`Attempts`}),I($,{children:S(M)?`—`:M.attempts}),I(e,{as:`dt`,children:`Status`}),I($,{children:S(M)?`in flight`:M.errorCode===null?M.status:`${M.status} ${M.errorCode}`}),I(e,{as:`dt`,children:`Timing`}),I($,{children:S(M)?`—`:`first token ${m(M.ttftMs)} · total ${m(M.durationMs)}`}),I(e,{as:`dt`,children:`Tokens`}),I($,{children:S(M)?`—`:L(F,{children:[h(M.inputTokens),` in · `,h(M.outputTokens),` out ·`,` `,h(M.cacheReadTokens),` cache read ·`,` `,h(M.cacheWriteTokens),` cache write`]})}),I(e,{as:`dt`,children:`Cost`}),I($,{children:S(M)?`—`:v(M.costUsd)}),I(e,{as:`dt`,children:`RTK compression`}),I($,{children:S(M)?`—`:M.rtkApplied?`${h(M.rtkFilterHits)} hits · ${h(M.rtkOriginalCodeUnits)} → ${h(M.rtkCompressedCodeUnits)} code units · ~${h(M.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),I(e,{as:`dt`,children:`RTK filters`}),I($,{children:M.rtkFilters.length===0?`—`:M.rtkFilters.join(`, `)})]}),M.degradations.length===0?null:L(r,{$gap:1,children:[I(e,{children:`Capabilities dropped to fit the target`}),I(s,{$gap:1,$wrap:!0,children:M.degradations.map(e=>I(E,{$tone:`warn`,children:e},e))})]}),I(de,{requestId:M.id})]})})]})}var be=ye;export{be as component};
@@ -1,4 +1,4 @@
1
- import{$ as e,F as t,O as n,at as r,et as i,g as a,it as o,lt as s,nt as c,ot as l,ut as u,x as d,y as f,z as p}from"./queries-CX9mStps.js";import{r as m}from"./index-C3Fp8XmZ.js";import{g as h,o as g,t as _}from"./Rack-ziQuyb2l.js";import{t as v}from"./plus-Cdyfj4uP.js";import{t as y}from"./trash-2-B5fBDSkh.js";import{t as b}from"./Toggle-CNnMgEU1.js";import{i as x,n as S,r as C,t as w}from"./States-Shs8nZi1.js";import{n as T,t as E}from"./Chip-BltJSw8A.js";import{i as D,n as O,r as k,t as A}from"./Field-B79Yxdit.js";import{t as j}from"./Meter-stpt3vQu.js";import{t as M}from"./Panel-CoulMx6R.js";import{i as N,n as ee,r as P,t as F}from"./catalog-BBKm8Ih8.js";import{useEffect as I,useId as te,useState as L}from"react";import{Fragment as R,jsx as z,jsxs as B}from"react/jsx-runtime";import V from"styled-components";var ne=h(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),re=h(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),H=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ie={tier:`How preferred this tier is`,health:`Consecutive failures and breaker state`,quota:`Headroom in the tightest window, against how much of it is left`,cost:`Price of this request against the other candidates`,latency:`Observed time to first token`,load:`Requests in flight on this pair right now`},ae=V.li`
1
+ import{$ as e,F as t,O as n,at as r,et as i,g as a,it as o,lt as s,nt as c,ot as l,ut as u,x as d,y as f,z as p}from"./queries-CX9mStps.js";import{r as m}from"./index-COwhxKU7.js";import{g as h,o as g,t as _}from"./Rack-fDZClWZL.js";import{t as v}from"./plus-UDQ_BTEr.js";import{t as y}from"./trash-2-U2ViYZum.js";import{t as b}from"./Toggle-ClEeOh0F.js";import{i as x,n as S,r as C,t as w}from"./States-DtkkMzEu.js";import{n as T,t as E}from"./Chip-BltJSw8A.js";import{i as D,n as O,r as k,t as A}from"./Field-B79Yxdit.js";import{t as j}from"./Meter-stpt3vQu.js";import{t as M}from"./Panel-CoulMx6R.js";import{i as N,n as ee,r as P,t as F}from"./catalog-BBKm8Ih8.js";import{useEffect as I,useId as te,useState as L}from"react";import{Fragment as R,jsx as z,jsxs as B}from"react/jsx-runtime";import V from"styled-components";var ne=h(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),re=h(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),H=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ie={tier:`How preferred this tier is`,health:`Consecutive failures and breaker state`,quota:`Headroom in the tightest window, against how much of it is left`,cost:`Price of this request against the other candidates`,latency:`Observed time to first token`,load:`Requests in flight on this pair right now`},ae=V.li`
2
2
  padding: ${({theme:e})=>e.space(2)} 0;
3
3
  border-bottom: 1px solid ${({theme:e})=>e.color.rule};
4
4
 
@@ -1,4 +1,4 @@
1
- import{J as e,X as t,Y as n,Z as r,at as i,k as a}from"./queries-CX9mStps.js";import{a as o,s}from"./index-C3Fp8XmZ.js";import{t as c}from"./Rack-ziQuyb2l.js";import{n as l,r as u,t as d}from"./States-Shs8nZi1.js";import{t as f}from"./Panel-CoulMx6R.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(i){let a=w.get(i);if(a!==void 0)return a;let o={get:(e,t)=>n(C(i,e),t),post:(e,n)=>t(C(i,e),n),put:(e,t)=>r(C(i,e),t),del:t=>e(C(i,t))};return w.set(i,o),o}var E=h(e=>s(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
1
+ import{J as e,X as t,Y as n,Z as r,at as i,k as a}from"./queries-CX9mStps.js";import{a as o,s}from"./index-COwhxKU7.js";import{t as c}from"./Rack-fDZClWZL.js";import{n as l,r as u,t as d}from"./States-DtkkMzEu.js";import{t as f}from"./Panel-CoulMx6R.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(i){let a=w.get(i);if(a!==void 0)return a;let o={get:(e,t)=>n(C(i,e),t),post:(e,n)=>t(C(i,e),n),put:(e,t)=>r(C(i,e),t),del:t=>e(C(i,t))};return w.set(i,o),o}var E=h(e=>s(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
2
2
  font-size: 13px;
3
3
  color: ${({theme:e})=>e.color.down};
4
4
  `,j=S.p`
@@ -0,0 +1,46 @@
1
+ import{$ as e,L as t,O as n,at as r,c as i,et as a,it as o,lt as s,nt as c,o as l,z as u}from"./queries-CX9mStps.js";import{t as d}from"./Rack-fDZClWZL.js";import{t as f}from"./Toggle-ClEeOh0F.js";import{i as p,n as m,r as h}from"./States-DtkkMzEu.js";import{i as g,n as _,t as v}from"./Field-B79Yxdit.js";import{t as y}from"./Meter-stpt3vQu.js";import{t as b}from"./Panel-CoulMx6R.js";import{useEffect as x,useState as S}from"react";import{Fragment as C,jsx as w,jsxs as T}from"react/jsx-runtime";import E from"styled-components";var D=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],O=E(a)`
2
+ display: block;
3
+ white-space: pre;
4
+ overflow-x: auto;
5
+ padding: 0.75rem;
6
+ background: ${({theme:e})=>e.color.panelSunk};
7
+ border: 1px solid ${({theme:e})=>e.color.rule};
8
+ border-radius: 4px;
9
+ font-size: 0.8125rem;
10
+ line-height: 1.5;
11
+ `,k=E.div`
12
+ color: ${({theme:e})=>e.color.inkDim};
13
+ font-size: 0.8125rem;
14
+ margin-bottom: 0.25rem;
15
+ `,A=E.p`
16
+ color: ${({theme:e})=>e.color.inkDim};
17
+ font-size: 0.8125rem;
18
+ margin: 0;
19
+ `,j=E.div`
20
+ display: grid;
21
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
22
+ gap: ${({theme:e})=>e.space(2)};
23
+ `,M=[{key:`defaultModel`,label:`Default model`,required:!0},{key:`fableModel`,label:`Fable model`,required:!1},{key:`opusModel`,label:`Opus model`,required:!1},{key:`sonnetModel`,label:`Sonnet model`,required:!1},{key:`haikuModel`,label:`Haiku model`,required:!1}];function N(){let[e,t]=S(`claude`),[i,o]=S(()=>({claude:{},opencode:{}})),u=n(),d=i[e],f=typeof d.defaultModel==`string`&&d.defaultModel!==``?d:void 0,_=l(e,f),y=D.find(t=>t.id===e);return w(b,{legend:`Agent setup`,children:T(r,{children:[w(c,{children:D.map(n=>w(s,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),T(A,{children:[y?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,T(a,{children:[`omni setup `,e]}),` to write these files directly.`]}),(u.data?.length??0)>0?w(j,{children:M.map(t=>w(v,{label:t.label,children:n=>T(g,{...n,value:d[t.key]??``,onChange:n=>o(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[w(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),u.data?.map(e=>w(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,u.isLoading?w(h,{rows:2}):_.isError?w(m,{error:_.error,onRetry:()=>void _.refetch()}):_.isLoading?w(h,{rows:4}):(u.data?.length??0)===0?w(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):f===void 0?T(A,{children:[`Choose a default model to generate `,y?.label,` settings.`]}):_.data===void 0||_.data.length===0?w(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):_.data.map(e=>T(`div`,{children:[w(k,{children:e.path}),w(O,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),_.isError?w(A,{children:p(_.error)}):null]})})}var P=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Preference for accounts with fewer requests in flight right now.`}],F=[{id:`maxAttempts`,label:`Attempts per request`,hint:`How many candidates dispatch may try before giving up. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`How long a request may take across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures on one account and model before it is taken out of rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Base wait before a tripped account is probed again. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before maintenance prunes them.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often each account's provider is asked for its remaining quota. 0 disables polling. Takes effect on restart.`,unit:`ms`,step:6e4,min:0}],I=E.div`
24
+ display: grid;
25
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
26
+ gap: ${({theme:e})=>e.space(3)};
27
+ `,L=E(r)`
28
+ gap: 6px;
29
+ `,R=E.p`
30
+ font-size: 11px;
31
+ color: ${({theme:e})=>e.color.inkDim};
32
+ `,z=E.p`
33
+ font-size: 12px;
34
+ color: ${({theme:e})=>e.color.down};
35
+ `,B=E.p`
36
+ font-size: 12px;
37
+ color: ${({theme:e})=>e.color.ok};
38
+ `,V=E.p`
39
+ font-size: 12px;
40
+ color: ${({theme:e})=>e.color.warn};
41
+ max-width: 72ch;
42
+
43
+ code {
44
+ font-family: ${({theme:e})=>e.font.mono};
45
+ }
46
+ `;function H(e){let t={};for(let n of P)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of F)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function U(e){let t={};for(let n of P){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of F){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`,autoCacheEnabled:e.autoCacheEnabled===`true`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function W(){let n=u(),l=i(),g=t(),[E,D]=S({}),[O,k]=S(null),[A,j]=S(!1);x(()=>{n.data!==void 0&&D(H(n.data))},[n.data]);let M=Math.max(1e-4,...P.map(e=>Math.abs(Number(E[`w.${e.id}`])||0)));return T(C,{children:[w(d,{legend:`Settings`,title:`Routing and retention`,summary:`These apply to every request the gateway routes. Changes take effect on the next request; nothing is restarted.`,actions:w(s,{type:`button`,$variant:`primary`,disabled:g.isPending||n.isLoading,onClick:()=>{j(!1);let e=U(E);if(!e.ok){k(e.problem);return}k(null),g.mutate(e.settings,{onSuccess:()=>j(!0),onError:e=>k(p(e))})},children:g.isPending?`Saving…`:`Save changes`})}),n.isError?w(b,{legend:`Settings`,children:w(m,{error:n.error,onRetry:()=>void n.refetch()})}):n.isLoading?w(b,{legend:`Settings`,children:w(h,{rows:6})}):T(r,{$gap:4,children:[w(b,{legend:`Scoring weights`,meta:`relative to each other`,footer:T(c,{children:[w(e,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),w(o,{})]}),children:w(I,{children:P.map(e=>{let t=Number(E[`w.${e.id}`])||0;return T(L,{children:[w(v,{label:e.label,children:t=>w(_,{...t,type:`number`,step:.5,value:E[`w.${e.id}`]??``,onChange:t=>D({...E,[`w.${e.id}`]:t.target.value})})}),w(y,{fraction:Math.abs(t)/M,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),w(R,{children:e.blurb})]},e.id)})})}),w(b,{legend:`Limits`,children:w(I,{children:F.map(t=>w(L,{children:w(v,{label:t.label,hint:t.hint,children:n=>T(c,{$gap:2,children:[w(_,{...n,type:`number`,min:t.min,step:t.step,value:E[t.id]??``,onChange:e=>D({...E,[t.id]:e.target.value})}),w(e,{children:t.unit})]})})},t.id))})}),w(b,{legend:`Historical tool results`,children:T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.rtkEnabled===`true`,onCheckedChange:e=>D({...E,rtkEnabled:String(e)}),label:`Enable RTK compression`}),w(R,{children:`Compress recognized historical non-error tool results before provider dispatch. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a built-in detector recognizes a high-confidence shell-output format. Compression is deterministic and lossy. Disabled by default.`})]})}),w(b,{legend:`Prompt caching`,children:T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.autoCacheEnabled===`true`,onCheckedChange:e=>D({...E,autoCacheEnabled:String(e)}),label:`Add a cache breakpoint when a client sends none`}),w(R,{children:`Anthropic only caches a prompt the request marks, so a client that marks nothing pays full price to resend the same prefix every turn. This marks the end of the system prompt on Anthropic requests that carry no breakpoint of their own. Requests that already mark one are left exactly as they arrived, and prompts too short to be cacheable are skipped. Enabled by default.`})]})}),w(b,{legend:`Request and response bodies`,meta:l.data===!0?`permitted by the environment`:`not permitted`,children:T(r,{$gap:3,children:[l.data===!0?null:T(V,{children:[`This gateway was started without `,w(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,w(`code`,{children:`.env`}),` `,`and restart before turning capture on. Two keys mean an admin session on its own cannot start recording prompts.`]}),T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.bodyLoggingEnabled===`true`,disabled:l.data!==!0,onCheckedChange:e=>D({...E,bodyLoggingEnabled:String(e)}),label:`Capture request and response bodies`}),w(R,{children:`Stores what each client sent and what each provider returned, encrypted under OMNI_ENCRYPTION_KEY beside the database. Bearer tokens and API keys are masked first and headers are never captured. Bodies expire on the log retention window above, and the newest 100,000 requests are kept whatever that window says. Off by default.`})]}),T(c,{$gap:3,$align:`start`,children:[w(f,{checked:E.bodyLoggingCaptureStreamChunks===`true`,disabled:l.data!==!0||E.bodyLoggingEnabled!==`true`,onCheckedChange:e=>D({...E,bodyLoggingCaptureStreamChunks:String(e)}),label:`Also keep raw stream frames`}),w(R,{children:`Retains the raw SSE frames of each attempt as well as the reassembled response. The only way to debug stream framing itself, and by far the most expensive thing capture can store, so it is gated separately rather than implied.`})]})]})}),O===null?null:w(z,{role:`alert`,children:O}),A&&O===null?w(B,{role:`status`,children:`Settings saved.`}):null,w(N,{}),w(b,{legend:`Known limits`,children:T(r,{$gap:2,children:[T(c,{$gap:2,children:[w(a,{$dim:!0,children:`rate limits`}),w(R,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),T(c,{$gap:2,children:[w(a,{$dim:!0,children:`logs`}),w(R,{children:`Request rows record routing and token counts only. Prompts and responses are written only when body capture above is on, and to a separate encrypted store; credentials are never written to either.`})]})]})})]})]})}var G=W;export{G as component};