omnigateway 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -17
- package/bin/omni.js +184 -35
- package/gateway.js +139 -40
- package/package.json +2 -2
- package/public/assets/{Chip-CmL-9rw7.js → Chip-77Q04h7S.js} +2 -1
- package/public/assets/{CopyValue-CTVbU0O_.js → CopyValue-DDJId-Zo.js} +1 -1
- package/public/assets/{Field-DcNu4yw-.js → Field-56pmSGrh.js} +1 -1
- package/public/assets/{Lamp-DtHKJH6P.js → Lamp-Drd1fFwQ.js} +7 -7
- package/public/assets/{Panel-BlNr9j6-.js → Panel-BV18WuL1.js} +1 -0
- package/public/assets/Rack-D3iFlR6e.js +482 -0
- package/public/assets/{Readout-D8Ofl3Gz.js → Readout-Dxwka1JI.js} +1 -1
- package/public/assets/RequestTable-I395emqH.js +11 -0
- package/public/assets/SummaryDeck-pAZ93jBW.js +15 -0
- package/public/assets/{Toggle-ChjN-tw1.js → Toggle-y17mtXCV.js} +1 -1
- package/public/assets/{TokenBreakdown-BPoXM3JM.js → TokenBreakdown-BIwuEVs8.js} +2 -1
- package/public/assets/{WindowChart-BPEsEGFL.js → WindowChart-DWZtz4Ps.js} +2 -2
- package/public/assets/{_app-CWXzHdhc.js → _app-0fHLZIC7.js} +1 -1
- package/public/assets/_app.accounts-DBlImnPw.js +59 -0
- package/public/assets/{_app.console-Bkdallia.js → _app.console-in_iVnep.js} +2 -2
- package/public/assets/{_app.database-DxqN1395.js → _app.database-CPj-Juag.js} +4 -4
- package/public/assets/_app.index-DGz9njXx.js +67 -0
- package/public/assets/_app.keys-C-Fk39-U.js +92 -0
- package/public/assets/{_app.logs-DGQD8ZAq.js → _app.logs-C7BhBRjg.js} +3 -3
- package/public/assets/{_app.models-D6SV_GVk.js → _app.models-BuiRrOrz.js} +4 -4
- package/public/assets/{_app.plugins._pluginId-CJ7ObXXe.js → _app.plugins._pluginId-Bx1LgcDj.js} +1 -1
- package/public/assets/_app.settings-s6K98CA2.js +88 -0
- package/public/assets/_app.usage-Bp45JtBe.js +76 -0
- package/public/assets/{chevron-right-BfnK63GB.js → chevron-right-BE-3EQR5.js} +1 -1
- package/public/assets/client-Bl_FA5jI.js +39 -0
- package/public/assets/index-nvJxJ9Gp.js +13 -0
- package/public/assets/{login-CrJK9wRA.js → login-Qc9iIepG.js} +2 -2
- package/public/assets/plus-DhyoE7aH.js +1 -0
- package/public/assets/{preload-helper-BknjH67x.js → preload-helper-DYShfVEU.js} +1 -1
- package/public/assets/{shared-oTMOLWMT.js → shared-ChaZCaBz.js} +12 -12
- package/public/assets/{trash-2-CSkf6ME_.js → trash-2-zGGJ7VE_.js} +1 -1
- package/public/index.html +5 -5
- package/public/assets/Rack-_A_3zqxC.js +0 -476
- package/public/assets/RequestTable-Cokk7wKP.js +0 -11
- package/public/assets/SummaryDeck-C0IbqnLz.js +0 -15
- package/public/assets/_app.accounts-DKmxz7Tl.js +0 -59
- package/public/assets/_app.index-BUqor-qH.js +0 -62
- package/public/assets/_app.keys-DMCPEj1g.js +0 -82
- package/public/assets/_app.settings-BVimpngR.js +0 -88
- package/public/assets/_app.usage-Y2Nkaw0t.js +0 -76
- package/public/assets/client-WgQ5A2PD.js +0 -39
- package/public/assets/index-BTE8vyBz.js +0 -13
- package/public/assets/plus-Cv51cK5k.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,c as t,l as n,o as r,s as i,u as a}from"./Rack-
|
|
1
|
+
import{a as e,c as t,l as n,o as r,s as i,u as a}from"./Rack-D3iFlR6e.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=a(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:i(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=a(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:i(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{
|
|
1
|
+
import{j as e}from"./Lamp-Drd1fFwQ.js";import{b as t,y as n}from"./Rack-D3iFlR6e.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import a,{keyframes as o}from"styled-components";var s=t(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),c=t(`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;
|
|
@@ -9,6 +9,7 @@ import{A as e}from"./Lamp-DtHKJH6P.js";import{b as t,y as n}from"./Rack-_A_3zqxC
|
|
|
9
9
|
`,f=a.span`
|
|
10
10
|
display: inline-flex;
|
|
11
11
|
align-items: center;
|
|
12
|
+
line-height: 1;
|
|
12
13
|
gap: 2px;
|
|
13
14
|
|
|
14
15
|
svg {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e,C as t,E as n,J as r,T as i,Y as a,dt as o,o as s,t as c,w as l}from"./shared-ChaZCaBz.js";import{C as u,E as d,M as f,N as p,R as m,S as h,_ as g,a as _,k as v,m as y,n as b}from"./Lamp-Drd1fFwQ.js";import{C as x,_ as S,b as C,v as w}from"./Panel-BV18WuL1.js";import*as T from"react";import{forwardRef as E}from"react";import{Fragment as D,jsx as O,jsxs as k}from"react/jsx-runtime";import A from"styled-components";var j=[`axis`],M=E((e,n)=>T.createElement(t,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:j,tooltipPayloadSearcher:a,categoricalChartProps:e,ref:n})),N=A(C)`
|
|
2
2
|
gap: ${({theme:e})=>e.space(5)};
|
|
3
3
|
flex-wrap: wrap;
|
|
4
4
|
`,P=A.div`
|
|
@@ -8,4 +8,4 @@ import{C as e,K as t,O as n,S as r,lt as i,o as a,q as o,t as s,w as c,x as l}fr
|
|
|
8
8
|
`,F=A.span`
|
|
9
9
|
font-size: 11.5px;
|
|
10
10
|
color: ${({theme:e})=>e.color.inkDim};
|
|
11
|
-
`,I={budget:`1 4`,projection:`6 4`},L=`projected`;function R(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 z(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 B(e){if(e.resetsAt===null)return null;let t=e.resetsAt-u(e.windowType,e.windowMs);return t-(e.resetsAt-t)}function V(e,t){return t===null?`unknown`:e!==null&&t.to.at<e?`100% of limit before it resets`:`${Math.round(t.to.percent)}% of limit by reset`}function H(e,t){let n=
|
|
11
|
+
`,I={budget:`1 4`,projection:`6 4`},L=`projected`;function R(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 z(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 B(e){if(e.resetsAt===null)return null;let t=e.resetsAt-u(e.windowType,e.windowMs);return t-(e.resetsAt-t)}function V(e,t){return t===null?`unknown`:e!==null&&t.to.at<e?`100% of limit before it resets`:`${Math.round(t.to.percent)}% of limit by reset`}function H(e,t){let n=d({observedAt:e.live.observedAt,limit:e.live.usedRatio===null?null:1},{ratePerHour:e.ratePerHourRatio,exhaustsAt:e.exhaustsAt,survives:e.survives,stale:e.stale||e.rolledOver});return n===`ok`?`lasts the window`:n!==`empty`||e.exhaustsAt===null?`unknown`:e.exhaustsAt<=t?`empty now`:`empty ~${p(e.exhaustsAt-t)} before it resets`}function U(t){let{live:a,samples:u,since:d,now:p,stale:T,rolledOver:E,spent:A,truncated:j=!1}=t,B=b[a.windowType];if(T)return k(x,{$gap:2,children:[k(C,{$gap:2,$wrap:!0,children:[k(S,{children:[B,` window`]}),O(F,{children:A})]}),O(F,{children:`reading is stale`})]});let U=h(g(u),a),W=U.flatMap(e=>{let t=_(e);return t===null?[]:[{key:`${e.key}-budget`,pace:t}]}),G=y(a,t.ratePerHourRatio),K=R([...U,...W.map(e=>({key:e.key,points:[e.pace.from,e.pace.to]})),...G===null?[]:[{key:L,points:[G.from,G.to]}]]),q=new Set(U.map(e=>e.key)),J=d===null||a.resetsAt===null?null:z(d,a.resetsAt,W);return k(x,{$gap:2,children:[k(C,{$gap:2,$wrap:!0,children:[k(S,{children:[B,` window`]}),O(F,{children:A}),E?O(F,{children:`· rolled over, waiting for the next reading`}):null]}),k(N,{children:[k(P,{children:[O(S,{children:`Window average`}),O(w,{children:t.rateText})]}),k(P,{children:[O(S,{children:`Estimate`}),O(w,{children:H(t,p)})]}),k(P,{children:[O(S,{children:`Projected`}),O(w,{children:V(a.resetsAt,G)})]}),t.extraFact]}),a.usedRatio===null?O(F,{children:`no ceiling reported`}):J===null?O(F,{children:`no reset reported`}):U.length===0?O(F,{children:`not yet observed`}):k(D,{children:[O(S,{children:[`Used, this window and the one before`,...j?[`earliest readings not shown`]:[],...W.length===0?[]:[`budget dotted`],...G===null?[]:[`projection dashed`]].join(` · `)}),O(c,{$height:160,children:O(o,{width:`100%`,height:`100%`,children:k(M,{data:K,margin:{top:4,right:8,bottom:4,left:4},children:[O(e,{stroke:`var(--rule)`,vertical:!1}),O(i,{dataKey:`at`,type:`number`,scale:`time`,domain:J,tickFormatter:e=>v(e,J[1]-J[0]),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,minTickGap:m(J[1]-J[0])?80:40}),O(l,{domain:[0,100],allowDataOverflow:!0,tickFormatter:e=>`${Math.round(e)}%`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),O(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=>q.has(String(e.dataKey)));if(n===void 0||typeof n.value!=`number`)return null;let r=n.payload.at;return k(s,{children:[O(`div`,{children:f(r)}),k(`div`,{children:[n.value.toFixed(1),`% used`]})]})}}),U.map(e=>O(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)),W.map(e=>O(n,{type:`linear`,dataKey:e.key,stroke:`var(--ink-faint)`,strokeWidth:1.5,strokeDasharray:I.budget,dot:!1,connectNulls:!0,isAnimationActive:!1},e.key)),G===null?null:O(n,{type:`linear`,dataKey:L,stroke:`var(--ink-dim)`,strokeWidth:1.5,strokeDasharray:I.projection,dot:!1,connectNulls:!0,isAnimationActive:!1})]})})})]})]})}function W({legend:e,value:t}){return k(P,{children:[O(S,{children:e}),O(w,{children:t})]})}export{U as n,B as r,W as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,k as t,t as n}from"./Panel-
|
|
1
|
+
import{i as e,k as t,t as n}from"./Panel-BV18WuL1.js";import{jsx as r}from"react/jsx-runtime";function i({error:i}){let a=t();return r(n,{legend:`Console unavailable`,children:r(e,{legend:`The gateway did not answer`,error:i,onRetry:()=>void a.invalidate()})})}export{i as errorComponent};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{F as e,I as t,Kt as n,Ot as r,T as i,Tt as a,U as o,Vt as s,W as c,at as l,b as u,c as d,ct as f,d as p,dt as ee,ft as m,h as te,ht as h,j as g,kt as _,n as v,o as y,ot as b,s as x,t as S,v as C,y as w}from"./Lamp-Drd1fFwQ.js";import{C as T,D as E,O as D,_ as O,a as k,b as A,i as j,o as M,r as ne,t as N,v as P,x as re}from"./Panel-BV18WuL1.js";import{_ as F,b as I,i as ie,m as L,r as R,t as z}from"./Rack-D3iFlR6e.js";import{t as B}from"./CopyValue-DDJId-Zo.js";import{n as V,t as H}from"./chevron-right-BE-3EQR5.js";import{t as ae}from"./plus-DhyoE7aH.js";import{t as oe}from"./trash-2-zGGJ7VE_.js";import{t as se}from"./Toggle-y17mtXCV.js";import{t as ce}from"./Chip-77Q04h7S.js";import{i as U,n as W,r as le,t as G}from"./Field-56pmSGrh.js";import{t as ue}from"./Meter-stpt3vQu.js";import{i as de,n as K,r as q,t as fe}from"./Table-CVDZ69Zx.js";import{n as pe,r as me,t as he}from"./WindowChart-DWZtz4Ps.js";import{Fragment as ge,useCallback as J,useEffect as _e,useState as Y}from"react";import{Fragment as X,jsx as Z,jsxs as Q}from"react/jsx-runtime";import $ from"styled-components";var ve=I(`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`}]]);function ye(e){return e?.authTypes??[]}function be(e){return ye(e).includes(`oauth`)?`oauth`:`apiKey`}function xe(e){return e[0]?.id??`anthropic`}var Se={oauth:`Authorize in the browser`,apiKey:`Paste an API key`};function Ce(e){let t=e?.callback;return t===void 0?`code#state`:`${t.uri}?code=…`}var we=$.ol`
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: ${({theme:e})=>e.space(3)};
|
|
5
|
+
`,Te=$.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
|
+
`,Ee=$.p`
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
color: ${({theme:e})=>e.color.down};
|
|
17
|
+
`,De=$.p`
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
20
|
+
`;function Oe({open:e,credentials:t,onOpenChange:n,onConnected:i}){let a=r().data??[],[s,u]=Y(()=>xe(a)),d=o(a,s),[p,ee]=Y(()=>be(o(a,xe(a)))),[m,te]=Y(``),h=d?.label??s,[g,_]=Y(null),[v,y]=Y(``),[x,S]=Y(``),C=(t??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[w,D]=Y(``),[k,j]=Y(``),[ne,N]=Y(`chat_completions`),[P,re]=Y(``),[F,I]=Y(null),L=b(),R=l(),z=f(),V=J(()=>{_(null),y(``),S(``),D(``),j(``),N(`chat_completions`),re(``),I(null),te(``),L.reset(),R.reset(),z.reset()},[L,R,z]),H=J(e=>{e||V(),n(e)},[n,V]);return _e(()=>{if(g===null||g.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await c(g.flowId);if(e)return;if(t.status===`complete`){V(),n(!1),i();return}}catch(t){if(e)return;I(M(t)),_(null);return}e||(r=setTimeout(()=>void t(),g.pollIntervalMs))},r=setTimeout(()=>void t(),g.pollIntervalMs);return()=>{e=!0,clearTimeout(r)}},[g,i,n,V]),Z(ie,{open:e,onOpenChange:H,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:g===null?Q(X,{children:[Z(E,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),Z(E,{type:`button`,$variant:`primary`,disabled:L.isPending||z.isPending,onClick:()=>{if(I(null),p===`apiKey`){z.mutate({provider:s,apiKey:P,label:m.trim()||void 0,...s===`custom`?{endpointId:x,endpointLabel:w,origin:k,protocol:ne}:{}},{onSuccess:()=>{V(),n(!1),i()},onError:e=>I(M(e))});return}L.mutate({provider:s,label:m.trim().length===0?h:m.trim()},{onSuccess:e=>_(e),onError:e=>I(M(e))})},children:p===`apiKey`?z.isPending?`Adding…`:`Add API key`:L.isPending?`Starting…`:`Start authorization`})]}):g.kind===`device`?Z(E,{type:`button`,onClick:()=>H(!1),children:`Cancel`}):Q(X,{children:[Z(E,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),Z(E,{type:`button`,$variant:`primary`,disabled:R.isPending||v.trim().length===0,onClick:()=>{g!==null&&(I(null),R.mutate({flowId:g.flowId,code:v.trim()},{onSuccess:()=>{V(),n(!1),i()},onError:e=>I(M(e))}))},children:R.isPending?`Finishing…`:`Finish connecting`})]}),children:Q(we,{children:[g===null?Q(T,{$gap:3,children:[Z(G,{label:`Provider`,children:e=>Z(U,{...e,value:s,onChange:e=>{let t=e.target.value;u(t),ee(be(o(a,t)))},children:a.map(e=>Z(`option`,{value:e.id,children:e.label},e.id))})}),ye(d).length>1?Z(G,{label:`How to connect`,children:e=>Z(U,{...e,value:p,onChange:e=>ee(e.target.value),children:ye(d).map(e=>Z(`option`,{value:e,children:Se[e]},e))})}):null,s===`custom`?Q(X,{children:[C.length===0?null:Z(G,{label:`Existing endpoint`,children:e=>Q(U,{...e,value:x,onChange:e=>{let t=C.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){S(``),D(``),j(``),N(`chat_completions`);return}S(String(t.providerData.endpointId)),D(String(t.providerData.endpointLabel)),j(String(t.providerData.origin)+String(t.providerData.basePath??``)),N(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[Z(`option`,{value:``,children:`Create new endpoint`}),C.map(e=>Z(`option`,{value:String(e.providerData.endpointId),children:String(e.providerData.endpointLabel)},String(e.providerData.endpointId)))]})}),Z(G,{label:`Endpoint ID`,children:e=>Z(W,{...e,value:x,onChange:e=>S(e.target.value)})}),Z(G,{label:`Endpoint label`,children:e=>Z(W,{...e,value:w,onChange:e=>D(e.target.value)})}),Z(G,{label:`Server URL`,children:e=>Z(W,{...e,value:k,placeholder:`https://server.example/api`,onChange:e=>j(e.target.value)})}),k.trim().toLowerCase().startsWith(`http://`)?Z(Ee,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,Z(G,{label:`Protocol`,children:e=>Q(U,{...e,value:ne,onChange:e=>N(e.target.value),children:[Z(`option`,{value:`chat_completions`,children:`Chat Completions (/v1/chat/completions)`}),Z(`option`,{value:`responses`,children:`Responses (/v1/responses)`})]})})]}):null,p===`apiKey`?Z(G,{label:`API key`,children:e=>Z(W,{...e,type:`password`,value:P,autoComplete:`off`,onChange:e=>re(e.target.value)})}):null,Z(G,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>Z(W,{...e,value:m,placeholder:h,onChange:e=>te(e.target.value)})})]}):Q(T,{$gap:3,children:[Q(T,{$gap:1,children:[Z(O,{children:`Step 1 — authorize`}),Z(A,{$gap:2,children:Q(E,{as:`a`,href:g.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[Z(ve,{}),`Open `,h]})}),Z(B,{value:g.authorizeUrl,label:`Copy authorization link`})]}),g.userCode===null?null:Q(T,{$gap:1,children:[Z(O,{children:`Step 2 — enter this code`}),Z(Te,{children:g.userCode})]}),g.kind===`device`?Q(De,{children:[d?.pasteHint??``,` Waiting for authorization…`]}):Z(G,{label:`Authorization code`,hint:d?.pasteHint??``,...F===null?{}:{problem:F},children:e=>Z(W,{...e,value:v,autoFocus:!0,placeholder:Ce(d),onChange:e=>y(e.target.value)})})]}),F===null||g?.kind===`pkce`?null:Z(Ee,{children:F})]})})}function ke({credentialId:e,windows:t,burn:n,pollIntervalMs:r,now:i}){let a=t.map(e=>({window:e,estimate:y(n,e.windowType),since:me(u(e))})),o=a.map(e=>e.since).filter(e=>e!==null),s=o.length===0?0:Math.min(...o),c=_({credentialId:e,since:s},o.length>0),l=c.data?.samples??[],d=c.data?.gatewayRates??[],f=c.data?.truncated===!0;return Z(T,{$gap:4,children:a.map(e=>Z(Ae,{window:e.window,estimate:e.estimate,since:e.since,samples:l.filter(t=>t.windowType===e.window.windowType&&t.observedAt>=(e.since??0)),gatewayRate:d.find(t=>t.windowType===e.window.windowType),truncated:f,pollIntervalMs:r,now:i},e.window.windowType))})}function Ae({window:e,estimate:t,since:n,samples:r,gatewayRate:a,truncated:o,pollIntervalMs:s,now:c}){let l=e.limit===null?`${g(e.used)} used`:`${g(e.used)} of ${g(e.limit)} used`,d=i(e,c),f=t===void 0||p(e,c,s)||t.stale&&!d;return Z(pe,{live:u(e),samples:r.map(u),since:n,now:c,truncated:o&&n!==null&&r.length>0&&(r[0]?.observedAt??0)>n,ratePerHourRatio:w(e,t),exhaustsAt:t?.exhaustsAt??null,survives:t?.survives??null,stale:f,rolledOver:d,spent:l,rateText:t?.ratePerHour===void 0||t.ratePerHour===null?`unknown`:`${g(t.ratePerHour)}/h`,extraFact:Z(he,{legend:`This gateway accounts for`,value:a?.gatewayRatePerHour===void 0||a.gatewayRatePerHour===null?`unknown`:`${g(a.gatewayRatePerHour)} tokens/h`})})}var je=$(N)`
|
|
21
|
+
border-left: 3px solid ${({$provider:e})=>L(e)};
|
|
22
|
+
`,Me=$(W)`
|
|
23
|
+
width: 100%;
|
|
24
|
+
min-width: 140px;
|
|
25
|
+
height: 26px;
|
|
26
|
+
font-family: ${({theme:e})=>e.font.sans};
|
|
27
|
+
font-size: 12.5px;
|
|
28
|
+
background: transparent;
|
|
29
|
+
border-color: transparent;
|
|
30
|
+
|
|
31
|
+
&:hover:not(:disabled),
|
|
32
|
+
&:focus {
|
|
33
|
+
background: ${({theme:e})=>e.color.panelSunk};
|
|
34
|
+
border-color: ${({theme:e})=>e.color.ruleStrong};
|
|
35
|
+
}
|
|
36
|
+
`,Ne=$(le)`
|
|
37
|
+
width: 62px;
|
|
38
|
+
height: 26px;
|
|
39
|
+
`,Pe=$.span`
|
|
40
|
+
display: block;
|
|
41
|
+
padding-left: 9px;
|
|
42
|
+
font-size: 11px;
|
|
43
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
44
|
+
`,Fe=$.div`
|
|
45
|
+
display: grid;
|
|
46
|
+
/* Bar, figure, legend. The figure has a column of its own so the legends stay
|
|
47
|
+
aligned down the stack whether a window reads 4% or 100%. */
|
|
48
|
+
grid-template-columns: 96px 34px 1fr;
|
|
49
|
+
align-items: center;
|
|
50
|
+
min-width: 208px;
|
|
51
|
+
gap: 6px;
|
|
52
|
+
`,Ie=$(P)`
|
|
53
|
+
font-size: 11px;
|
|
54
|
+
text-align: right;
|
|
55
|
+
`,Le=$.div`
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: 4px;
|
|
59
|
+
`;function Re(){let e=n();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function ze(e,t){if(t===void 0)return` The list of models could not be read, so whether any target is pinned to this account is unknown.`;let n=t.filter(t=>t.targets.some(t=>t.credentialId===e.id)).map(e=>e.id);return n.length===0?``:` ${n.length===1?`The model`:`The models`} ${n.join(`, `)} ${n.length===1?`pins a target`:`pin targets`} to this account. Those targets will fail rather than fall back to another account.`}function Be(){let{cadence:n}=F(),i=m(),c=ee(n(1e4,`res:credentials`)),l=s(),u=a(),f=r(),p=h(),{commit:g}=Re(),[_,b]=Y(!1),[w,M]=Y(null),[P,I]=Y(new Set),ie=e=>I(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),L=Date.now(),B=i.data??[],U=f.data??[],W=e=>o(U,e)?.order??1/0,le=[...new Set(B.map(e=>e.provider))].sort((e,t)=>W(e)-W(t)),G=e=>o(U,e)?.label??e,pe=d(c.data?.health??[],e=>e.credentialId),me=d(c.data?.quota??[],e=>e.credentialId),he=d(c.data?.burn??[],e=>e.credentialId),J=l.data?.quotaPollIntervalMs??3e5,_e=B.filter(e=>e.enabled).length,$=i.isLoading?`Reading connected accounts…`:B.length===0?`No provider credentials are connected, so every request fails at the router.`:`${_e} of ${B.length} accounts are enabled and eligible for routing.`;return Q(X,{children:[Z(z,{legend:`Accounts`,title:`Provider accounts`,summary:$,actions:Q(E,{type:`button`,$variant:`primary`,onClick:()=>b(!0),children:[Z(ae,{}),`Connect an account`]})}),i.isError?Z(N,{legend:`Accounts`,children:Z(j,{error:i.error,onRetry:()=>void i.refetch()})}):i.isLoading?Z(N,{legend:`Accounts`,children:Z(k,{rows:5})}):B.length===0?Z(N,{legend:`Accounts`,children:Z(ne,{legend:`Nothing connected`,message:`Connect a provider account to give the router something to dispatch to. Tokens are encrypted at rest and never shown again.`,action:Z(E,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>b(!0),children:`Connect an account`})})}):Z(T,{$gap:4,children:le.map(n=>{let r=B.filter(e=>e.provider===n);return Z(je,{$provider:n,legend:G(n),meta:`${r.length} account${r.length===1?``:`s`}`,flush:!0,children:Z(re,{children:Q(fe,{children:[Z(`thead`,{children:Q(`tr`,{children:[Z(q,{$width:`24%`,children:`Account`}),Z(q,{$width:`20%`,children:`Sign-in`}),Z(q,{$align:`right`,$width:`86px`,children:`Tier`}),Z(q,{$align:`right`,$width:`94px`,children:`Weight`}),Z(q,{$align:`center`,$width:`86px`,children:`Enabled`}),Z(q,{$width:`240px`,children:`Quota`}),Z(q,{$align:`right`,$width:`130px`,children:`Token expires`}),Z(q,{$width:`76px`})]})}),Z(`tbody`,{children:r.map(n=>{let r=x(pe.get(n.id)??[],L,n.enabled,n.disabledReason),i=me.get(n.id)??[],a=he.get(n.id)??[],o=C(i),s=P.has(n.id);return Q(ge,{children:[Q(de,{children:[Q(K,{children:[Q(A,{$gap:2,children:[Z(S,{state:r.state,label:r.note===``?`healthy`:r.note}),Z(Me,{defaultValue:n.label,"aria-label":`Label for ${n.label}`,onBlur:e=>{let t=e.target.value.trim();if(t.length===0||t===n.label){e.target.value=n.label;return}g(n.id,{label:t})}})]}),r.note===``?null:Z(Pe,{children:r.note})]}),Z(K,{children:Q(A,{$gap:1,children:[Z(ce,{children:n.authType===`oauth`?`oauth`:`api key`}),n.accountEmail===null?null:Z(O,{children:n.accountEmail})]})}),Z(K,{$align:`right`,children:Z(Ne,{min:1,step:1,defaultValue:n.tier,"aria-label":`Tier for ${n.label}`,onBlur:e=>{let t=Number(e.target.value);if(!Number.isInteger(t)||t<1||t===n.tier){e.target.value=String(n.tier);return}g(n.id,{tier:t})}})}),Z(K,{$align:`right`,children:Z(Ne,{min:.1,step:.1,defaultValue:n.weight,"aria-label":`Weight for ${n.label}`,onBlur:e=>{let t=Number(e.target.value);if(!Number.isFinite(t)||t<=0||t===n.weight){e.target.value=String(n.weight);return}g(n.id,{weight:t})}})}),Z(K,{$align:`center`,children:Z(se,{checked:n.enabled,label:`Route to ${n.label}`,onCheckedChange:e=>g(n.id,{enabled:e})})}),Z(K,{children:o.length===0?Z(O,{children:`unknown`}):Z(Le,{children:o.map(({window:n,fraction:r})=>Q(Fe,{children:[Z(ue,{fraction:r,label:`${v[n.windowType]} window, ${Math.round(r*100)}% used`}),Z(Ie,{children:e(r,0)}),Z(O,{children:te(n,L,J,t,y(a,n.windowType))})]},n.windowType))})}),Z(K,{$align:`right`,$mono:!0,children:n.expiresAt===null?`never`:t(n.expiresAt,L)}),Z(K,{$align:`right`,children:Q(A,{$gap:1,$justify:`flex-end`,children:[i.length===0?null:Z(D,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":s,"aria-label":`${s?`Hide`:`Show`} quota history for ${n.label}`,title:`${s?`Hide`:`Show`} quota history for ${n.label}`,onClick:()=>ie(n.id),children:Z(s?V:H,{})}),Z(D,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${n.label}`,title:`Remove ${n.label}`,onClick:()=>M(n),children:Z(oe,{})})]})})]}),s?Z(de,{children:Z(K,{colSpan:9,children:Z(ke,{credentialId:n.id,windows:i,burn:a,pollIntervalMs:J,now:L})})}):null]},n.id)})})]})})},n)})}),Z(Oe,{open:_,credentials:i.data??[],onOpenChange:b,onConnected:()=>void i.refetch()}),Z(R,{open:w!==null,onOpenChange:e=>{e||M(null)},title:`Remove account`,body:w===null?``:`Removing "${w.label}" deletes its stored token. Any model target pointing at ${G(w.provider)} loses this account, and reconnecting means authorizing again.`+ze(w,u.data),confirmLabel:`Remove account`,busy:p.isPending,onConfirm:()=>{w!==null&&p.mutate(w.id,{onSettled:()=>M(null)})}})]})}var Ve=Be;export{Ve as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{B as e,Et as t,j as n,st as r}from"./Lamp-Drd1fFwQ.js";import{a as i,b as a,i as o,r as s,t as c,y as ee}from"./Panel-BV18WuL1.js";import{_ as l,t as u}from"./Rack-D3iFlR6e.js";import{a as d,c as f,o as p,s as m}from"./index-nvJxJ9Gp.js";import{i as h}from"./Field-56pmSGrh.js";import{useQueryClient as g}from"@tanstack/react-query";import{useLayoutEffect as te,useMemo as _,useRef as v,useState as y}from"react";import{jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";var C={debug:10,info:20,warn:30,error:40};function w(e){return typeof e==`string`&&e in C}function T(e,t){return!w(t)||e.level===null||C[e.level]>=C[t]}function E(e){if(typeof e!=`object`||!e)return null;let{raw:t,at:n,level:r,msg:i}=e;return typeof t!=`string`||n!==null&&typeof n!=`number`||r!==null&&!w(r)||i!==null&&typeof i!=`string`?null:{raw:t,at:n,level:r,msg:i}}function D(e){if(typeof e!=`object`||!e)return null;let{lines:t}=e;if(!Array.isArray(t))return null;let n=[];for(let e of t){let t=E(e);if(t===null)return null;n.push(t)}return n}var O=[100,200,500],ne=[{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`}],re=S(a)`
|
|
2
2
|
gap: ${({theme:e})=>e.space(2)};
|
|
3
3
|
flex-wrap: wrap;
|
|
4
4
|
`,k=S(h)`
|
|
@@ -41,4 +41,4 @@ import{A as e,Ct as t,at as n,z as r}from"./Lamp-DtHKJH6P.js";import{a as i,b as
|
|
|
41
41
|
`,P=S.code`
|
|
42
42
|
font-family: ${({theme:e})=>e.font.mono};
|
|
43
43
|
word-break: break-all;
|
|
44
|
-
`;function F({read:e}){return e.source===`file`?x(N,{children:[`Reading `,b(P,{children:e.path}),`, named by `,b(P,{children:`OMNI_LOG_FILE`}),`. That variable says where the gateway's output is being captured; it does not redirect it.`]}):e.source===`journal`?x(N,{children:[`Reading the systemd journal for `,b(P,{children:`omnigateway.service`}),`. To read a file instead, redirect the gateway's output to one and point `,b(P,{children:`OMNI_LOG_FILE`}),` at the same path.`]}):e.unreachable!==void 0&&e.unreachable.length>0?x(N,{children:[e.unreachable.length===1?`One process`:`${e.unreachable.length} processes`,` did not answer in time and `,e.unreachable.length===1?`is`:`are`,` not shown:`,` `,e.unreachable.map(e=>e.slice(0,8)).join(`, `),`.`]}):null}var I={single:"Its output is going to a terminal, so there is nothing to read back. To capture it, run the gateway under systemd with `omni service install`, or start it with `omni start`, which redirects output to a file and points OMNI_LOG_FILE at it.",fleet:`No process in this fleet is capturing its own output, so there is nothing to read back. Each one can capture its own — tee its stdout to a file and point OMNI_LOG_FILE at the same path — and this screen will then merge them. For a fleet, ship stdout to a collector instead: Elasticsearch and Kibana, Loki and Grafana, or whatever already reads your containers. This screen shows one process's tail at a time, and a process that is gone takes its log with it.`,process:`This process is not capturing its own output, so there is nothing to read back from it. Tee its stdout to a file and point OMNI_LOG_FILE at the same path, or pick another process.`},L=[],R={read:void 0,lines:L};function z(){let{cadence:a}=l(),c=g(),[h,S]=y(200),[C,w]=y(``),[E,N]=y(``),P=t(),z=P.data?.nodes??[],V=z.length>1,H=E===``&&V?`all`:E,U=H===`all`?`fleet`:V?`process`:`single`,W=H===``||H===`all`?null:`${m}:${H}`,G=
|
|
44
|
+
`;function F({read:e}){return e.source===`file`?x(N,{children:[`Reading `,b(P,{children:e.path}),`, named by `,b(P,{children:`OMNI_LOG_FILE`}),`. That variable says where the gateway's output is being captured; it does not redirect it.`]}):e.source===`journal`?x(N,{children:[`Reading the systemd journal for `,b(P,{children:`omnigateway.service`}),`. To read a file instead, redirect the gateway's output to one and point `,b(P,{children:`OMNI_LOG_FILE`}),` at the same path.`]}):e.unreachable!==void 0&&e.unreachable.length>0?x(N,{children:[e.unreachable.length===1?`One process`:`${e.unreachable.length} processes`,` did not answer in time and `,e.unreachable.length===1?`is`:`are`,` not shown:`,` `,e.unreachable.map(e=>e.slice(0,8)).join(`, `),`.`]}):null}var I={single:"Its output is going to a terminal, so there is nothing to read back. To capture it, run the gateway under systemd with `omni service install`, or start it with `omni start`, which redirects output to a file and points OMNI_LOG_FILE at it.",fleet:`No process in this fleet is capturing its own output, so there is nothing to read back. Each one can capture its own — tee its stdout to a file and point OMNI_LOG_FILE at the same path — and this screen will then merge them. For a fleet, ship stdout to a collector instead: Elasticsearch and Kibana, Loki and Grafana, or whatever already reads your containers. This screen shows one process's tail at a time, and a process that is gone takes its log with it.`,process:`This process is not capturing its own output, so there is nothing to read back from it. Tee its stdout to a file and point OMNI_LOG_FILE at the same path, or pick another process.`},L=[],R={read:void 0,lines:L};function z(){let{cadence:a}=l(),c=g(),[h,S]=y(200),[C,w]=y(``),[E,N]=y(``),P=t(),z=P.data?.nodes??[],V=z.length>1,H=E===``&&V?`all`:E,U=H===`all`?`fleet`:V?`process`:`single`,W=H===``||H===`all`?null:`${m}:${H}`,G=r(h,C,a(e,W??`stream:console`),H),K=G.data,[q,J]=y(R),Y=q.read===K?q.lines:L,X=_(()=>[...K?.lines??[],...Y].slice(-h),[K,Y,h]),Z=v(null),Q=v(!0),$=e=>{if(e.kind!==`frame`&&e.kind!==`gap`&&e.kind!==`closed`)return;let t=e.kind===`frame`?D(e.payload):null;if(t===null){J({read:K,lines:L}),e.kind===`frame`&&f(c,m);return}let n=t.filter(e=>T(e,C));n.length!==0&&J(e=>({read:K,lines:[...e.read===K?e.lines:[],...n].slice(-h)}))};return p(m,e=>{W===null&&$(e)}),d(W,$),te(()=>{let e=Z.current;e!==null&&Q.current&&X.length>0&&(e.scrollTop=e.scrollHeight)},[X]),x(ie,{children:[b(u,{legend:`Console`,title:`Gateway output`,summary:G.isLoading?`Reading the gateway's own output…`:`${n(X.length)} lines of what this process is doing. Requests are in Logs; prompt bodies, tokens and keys are never written here.`,actions:x(re,{children:[V?x(k,{value:H,"aria-label":`Which process to show`,onChange:e=>N(e.target.value),children:[b(`option`,{value:`all`,children:`every process`}),z.map(e=>b(`option`,{value:e.id,children:e.self?`${e.id.slice(0,8)} (this one)`:e.id.slice(0,8)},e.id))]}):null,b(k,{value:C,"aria-label":`Which levels to show`,onChange:e=>w(e.target.value),children:ne.map(e=>b(`option`,{value:e.value,children:e.label},e.value))}),b(k,{value:h,"aria-label":`How many lines to fetch`,onChange:e=>S(Number(e.target.value)),children:O.map(e=>x(`option`,{value:e,children:[`last `,e]},e))})]})}),x(ae,{legend:`Process output`,meta:K===void 0?void 0:b(ee,{children:B(K)}),flush:!0,children:[K===void 0?null:b(F,{read:K}),b(A,{ref:Z,"data-testid":`console-terminal`,onScroll:e=>{let t=e.currentTarget;Q.current=t.scrollHeight-t.scrollTop-t.clientHeight<=8},children:G.isError?b(o,{error:G.error,onRetry:()=>void G.refetch()}):G.isLoading||P.isLoading?b(`div`,{style:{padding:12},children:b(i,{rows:10})}):K!==void 0&&K.source===`none`?b(s,{legend:`Nothing is capturing this gateway`,message:I[U]}):X.length===0?b(s,{legend:`Nothing to show`,message:C===``?`This log is empty. The gateway writes here when it boots, refreshes a token, or polls a quota.`:`No line in this window is at that level. Widen the filter to see everything.`}):b(j,{children:X.map((e,t)=>b(M,{$level:e.level,children:e.nodeId===void 0?e.raw:`[${e.nodeId.slice(0,8)}] ${e.raw}`},`${e.at??0}-${t}`))})})]})]})}function B(e){return e.source===`file`?`log file`:e.source===`journal`?`systemd journal`:e.source===`fleet`?`every process, merged`:`not captured`}var V=z;export{V as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{F as e,Ft as t,Jt as n,K as r,M as i,Mt as a,O as o,P as s,Wt as c,Z as l,_t as u,j as d,pt as f,ut as p,yt as m}from"./Lamp-Drd1fFwQ.js";import{C as h,D as g,_,a as v,b as y,g as b,i as x,o as S,r as ee,t as C,w,x as T}from"./Panel-BV18WuL1.js";import{b as E,r as D,t as O}from"./Rack-D3iFlR6e.js";import{t as k}from"./trash-2-zGGJ7VE_.js";import{r as A,t as j}from"./Field-56pmSGrh.js";import{t as M}from"./Meter-stpt3vQu.js";import{i as N,n as P,r as F,t as I}from"./Table-CVDZ69Zx.js";import{t as L}from"./Readout-Dxwka1JI.js";import{n as R}from"./reasons-Du1OBWAM.js";import{useQueryClient as z}from"@tanstack/react-query";import{useCallback as B,useState as V}from"react";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import G from"styled-components";var K=E(`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`}]]),q=E(`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`}]]),J=[{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}],Y=G.p`
|
|
2
2
|
font-size: 12px;
|
|
3
3
|
color: ${({theme:e})=>e.color.down};
|
|
4
4
|
`,X=G.p`
|
|
@@ -8,17 +8,17 @@ import{A as e,Bt as t,D as n,G as r,Mt as i,N as a,P as o,Wt as s,X as c,ct as l
|
|
|
8
8
|
display: grid;
|
|
9
9
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
10
10
|
gap: ${({theme:e})=>e.space(3)};
|
|
11
|
-
`;function ne(e){let t={};for(let n of J){let r=e[n.id].trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<1)return{ok:!1,problem:`${n.label} must be a whole number of 1 or more.`};if(i>n.max)return{ok:!1,problem:`${n.label} cannot exceed ${n.max}.`};t[n.id]=i}return{ok:!0,policy:t}}function re({retention:e}){let t
|
|
11
|
+
`;function ne(e){let t={};for(let n of J){let r=e[n.id].trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<1)return{ok:!1,problem:`${n.label} must be a whole number of 1 or more.`};if(i>n.max)return{ok:!1,problem:`${n.label} cannot exceed ${n.max}.`};t[n.id]=i}return{ok:!0,policy:t}}function re({retention:e}){let n=t(),[r,i]=V({}),[a,o]=V(null),[s,c]=V(!1),l={keepLatest:r.keepLatest??(e===void 0?``:String(e.keepLatest)),maxAgeDays:r.maxAgeDays??(e===void 0?``:String(e.maxAgeDays))};return U(C,{legend:`Retention`,actions:U(g,{type:`button`,$size:`sm`,disabled:n.isPending||e===void 0,onClick:()=>{c(!1);let e=ne(l);if(!e.ok){o(e.problem);return}o(null),n.mutate(e.policy,{onSuccess:()=>{c(!0),i({})},onError:e=>o(S(e))})},children:n.isPending?`Saving…`:`Save retention`}),children:W(h,{$gap:3,children:[U(te,{children:J.map(e=>U(j,{label:e.label,hint:e.hint,children:t=>W(y,{$gap:2,children:[U(A,{...t,min:1,max:e.max,step:1,value:l[e.id],onChange:t=>i({...r,[e.id]:t.target.value})}),U(_,{children:e.unit})]})},e.id))}),a===null?null:U(Y,{role:`alert`,children:a}),s&&a===null?U(X,{role:`status`,children:`Retention saved.`}):null]})})}function ie(){let e=z();return B(t=>{if(t.adminPasswordChanged){R(`admin-password-changed`);return}e.invalidateQueries()},[e])}var Z=G.p`
|
|
12
12
|
font-size: 12px;
|
|
13
13
|
color: ${({theme:e})=>e.color.down};
|
|
14
14
|
`,ae=G.input`
|
|
15
15
|
font-size: 12px;
|
|
16
16
|
color: ${({theme:e})=>e.color.inkDim};
|
|
17
17
|
max-width: 40ch;
|
|
18
|
-
`;function oe(){let e=
|
|
18
|
+
`;function oe(){let e=c(),t=p(),n=a(),s=ie(),l=u(),d=m(),[f,_]=V(null),[b,E]=V(null),[O,k]=V(null),[A,M]=V(!1),L=e.data??[],R=W(g,{type:`button`,$variant:`primary`,$size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(),children:[U(K,{}),t.isPending?`Copying…`:`Take a snapshot`]}),z=W(h,{$gap:2,children:[W(y,{$gap:2,$wrap:!0,children:[U(j,{label:`Database file to import`,hint:`A snapshot taken from this or another OmniGateway. It is checked for integrity and rejected if it is not one of ours.`,children:e=>U(ae,{...e,type:`file`,accept:`.sqlite,.db,application/octet-stream`,onChange:e=>k(e.target.files?.[0]??null)})}),U(g,{type:`button`,$variant:`danger`,$size:`sm`,disabled:O===null||d.isPending,onClick:()=>M(!0),children:d.isPending?`Replacing…`:`Import`})]}),d.isError?U(Z,{role:`alert`,children:S(d.error)}):null,n.isError?U(Z,{role:`alert`,children:S(n.error)}):null,t.isError?U(Z,{role:`alert`,children:S(t.error)}):null]});return W(C,{legend:`Snapshots`,meta:`${L.length}`,actions:R,footer:z,flush:!0,children:[e.isError?U(x,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?U(`div`,{style:{padding:12},children:U(v,{rows:3})}):L.length===0?U(ee,{legend:`No snapshots`,message:`Nothing has been copied yet, so there is nothing to go back to. Take one before a migration or a settings change you are unsure of.`,action:U(g,{type:`button`,$variant:`primary`,$size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(),children:`Take the first snapshot`})}):U(T,{children:W(I,{children:[U(`thead`,{children:W(`tr`,{children:[U(F,{children:`File`}),U(F,{children:`Reason`}),U(F,{$align:`right`,children:`Size`}),U(F,{$align:`right`,children:`Taken`}),U(F,{})]})}),U(`tbody`,{children:L.map(e=>W(N,{children:[U(P,{$mono:!0,children:U(w,{style:{maxWidth:`38ch`,display:`block`},children:e.filename})}),U(P,{children:e.reason}),U(P,{$align:`right`,$mono:!0,children:o(e.sizeBytes)}),U(P,{$align:`right`,$mono:!0,children:i(e.createdAt)}),U(P,{$align:`right`,children:W(y,{$gap:1,$justify:`flex-end`,children:[U(g,{as:`a`,$size:`sm`,href:r(e.id),download:e.filename,children:`Download`}),U(g,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>_(e),children:`Restore`}),U(g,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>E(e),children:`Delete`})]})})]},e.id))})]})}),U(D,{open:f!==null,onOpenChange:e=>{e||_(null)},title:`Restore database`,body:f===null?``:`Replacing the live database with ${f.filename}. Client requests are refused while the file is swapped, and a copy of the current database is taken first so this can be undone. Captured request bodies are not part of a snapshot and are left where they are.`,confirmLabel:`Restore database`,busy:n.isPending,onConfirm:()=>{f!==null&&n.mutate(f.id,{onSuccess:s,onSettled:()=>_(null)})}}),U(D,{open:b!==null,onOpenChange:e=>{e||E(null)},title:`Delete snapshot`,body:b===null?``:`Deleting ${b.filename} from disk. Download it first if it is the copy you would go back to; there is no other one of it.`,confirmLabel:`Delete snapshot`,busy:l.isPending,onConfirm:()=>{b!==null&&l.mutate(b.id,{onSettled:()=>E(null)})}}),U(D,{open:A,onOpenChange:M,title:`Import database`,body:O===null?``:`Replacing the live database with ${O.name}. It is validated before anything is touched, and a copy of the current database is taken first. If the file carries a different admin password, every session ends and you will be asked to sign in again.`,confirmLabel:`Replace database`,busy:d.isPending,onConfirm:()=>{O!==null&&d.mutate(O,{onSuccess:s,onSettled:()=>M(!1)})}})]})}var Q=G.p`
|
|
19
19
|
font-size: 12px;
|
|
20
20
|
color: ${({theme:e})=>e.color.ok};
|
|
21
21
|
`,$=G.p`
|
|
22
22
|
font-size: 12px;
|
|
23
23
|
color: ${({theme:e})=>e.color.down};
|
|
24
|
-
`;function se(e){try{let{hostname:t,port:n}=new URL(e);return n===``?t:`${t}:${n}`}catch{return e}}function ce(e){try{return new URL(e).pathname.replace(/^\//,``)||`—`}catch{return`—`}}function le(){let t=
|
|
24
|
+
`;function se(e){try{let{hostname:t,port:n}=new URL(e);return n===``?t:`${t}:${n}`}catch{return e}}function ce(e){try{return new URL(e).pathname.replace(/^\//,``)||`—`}catch{return`—`}}function le(){let t=f(),r=n(),[i,a]=V(!1),c=l(),[u,p]=V(!1),m=t.data,h=m?.engine===`postgres`,_=m===void 0||m.logicalBytes===0?0:m.freePageBytes/m.logicalBytes;return W(H,{children:[U(O,{legend:`Database`,title:`Storage, snapshots, and retention`,summary:t.isLoading?`Measuring the database…`:h?`The Postgres database every replica of this cluster runs from. Back it up with pg_dump; nothing here copies or replaces it.`:`The one SQLite file this gateway runs from, the copies taken of it, and how long they are kept.`}),U(C,{legend:`Size`,meta:m===void 0?void 0:`schema v${m.stats.schemaVersion}`,actions:W(H,{children:[W(g,{type:`button`,$size:`sm`,disabled:c.isPending||m===void 0||m.bodiesBytes===0,onClick:()=>p(!0),children:[U(k,{}),c.isPending?`Clearing…`:`Clear bodies`]}),h?null:W(g,{type:`button`,$size:`sm`,disabled:r.isPending||m===void 0,onClick:()=>a(!0),children:[U(q,{}),r.isPending?`Compacting…`:`Compact`]})]}),footer:r.isError?U($,{role:`alert`,children:S(r.error)}):c.isError?U($,{role:`alert`,children:S(c.error)}):r.data===void 0?c.data===void 0?void 0:U(Q,{role:`status`,children:`Cleared ${d(c.data.removed)} captured bodies.`}):U(Q,{role:`status`,children:`Compacted, reclaiming ${o(r.data.reclaimedBytes)} in ${s(r.data.durationMs)}.`}),children:t.isError?U(x,{error:t.error,onRetry:()=>void t.refetch()}):m===void 0?U(v,{rows:3}):h?W(b,{$min:`180px`,$stretch:!0,children:[U(L,{legend:`Database`,value:o(m.logicalBytes),unit:`${m.stats.pageCount} blocks of ${o(m.stats.pageSize)}`}),U(L,{legend:`Server`,value:se(m.location),unit:`database ${ce(m.location)}`}),U(L,{legend:`Captured bodies`,value:o(m.bodiesBytes),unit:`the request_bodies table`})]}):W(b,{$min:`180px`,$stretch:!0,children:[U(L,{legend:`Database file`,value:o(m.fileBytes),unit:`${m.stats.pageCount} pages of ${o(m.stats.pageSize)}`,trace:U(M,{fraction:_,label:`${e(_,0)} of the file is reclaimable`})}),U(L,{legend:`Reclaimable`,value:o(m.freePageBytes),unit:`${m.stats.freelistCount} free pages`}),U(L,{legend:`Write-ahead log`,value:o(m.walBytes),unit:`folded into every snapshot`}),U(L,{legend:`Captured bodies`,value:o(m.bodiesBytes),unit:`never in a snapshot`}),U(L,{legend:`Snapshots`,value:o(m.snapshots.totalBytes),unit:`${m.snapshots.count} kept`}),U(L,{legend:`Free disk`,value:o(m.freeDiskBytes),unit:m.freeDiskBytes===null?`not readable here`:`on this filesystem`})]})}),U(C,{legend:`Tables`,meta:h?`row counts are the planner's estimates; dead rows await autovacuum`:`size includes each table's indexes`,children:m===void 0?U(v,{rows:4}):W(I,{children:[U(`thead`,{children:W(N,{children:[U(F,{children:`Table`}),U(F,{$align:`right`,children:`Size`}),U(F,{$align:`right`,children:`Rows`}),h?U(F,{$align:`right`,children:`Dead rows`}):null]})}),U(`tbody`,{children:m.tables.map(e=>W(N,{children:[U(P,{children:e.name}),U(P,{$align:`right`,children:o(e.bytes)}),U(P,{$align:`right`,children:d(e.rows)}),h?U(P,{$align:`right`,children:d(e.deadRows??0)}):null]},e.name))})]})}),h?null:W(H,{children:[U(oe,{}),U(re,{retention:m?.retention})]}),U(D,{open:u,onOpenChange:p,title:`Clear every captured body?`,body:`Every stored prompt and completion is deleted. The requests themselves stay in the log, with their bodies marked pruned. There is no undo: bodies are never in a snapshot.`,confirmLabel:`Clear captured bodies`,busy:c.isPending,onConfirm:()=>c.mutate(void 0,{onSettled:()=>p(!1)})}),U(D,{open:i,onOpenChange:a,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:r.isPending,onConfirm:()=>r.mutate(void 0,{onSettled:()=>a(!1)})})]})}var ue=le;export{ue as component};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import{A as e,F as t,I as n,L as r,P as i,Tt as a,Vt as o,Yt as s,bt as c,c as l,dt as u,f as d,ft as f,h as p,i as m,j as h,n as g,o as _,p as v,qt as y,s as b,t as x,u as S,v as C,wt as w,x as T,z as ee}from"./Lamp-Drd1fFwQ.js";import{C as E,D,S as O,_ as k,b as A,g as te,i as ne,r as j,t as M,v as N,w as P,x as F}from"./Panel-BV18WuL1.js";import{_ as re,f as I,m as L,t as ie}from"./Rack-D3iFlR6e.js";import{n as R,t as ae}from"./TokenBreakdown-BIwuEVs8.js";import{n as oe,t as z}from"./Chip-77Q04h7S.js";import{t as B}from"./Meter-stpt3vQu.js";import{i as V,n as H,r as U,t as W}from"./Table-CVDZ69Zx.js";import{t as G}from"./Readout-Dxwka1JI.js";import{useMemo as K}from"react";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";var se=X(P)`
|
|
2
|
+
font-weight: 500;
|
|
3
|
+
display: block;
|
|
4
|
+
max-width: 24ch;
|
|
5
|
+
`,Z=X.span`
|
|
6
|
+
font-size: 11px;
|
|
7
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
+
`,ce=X.div`
|
|
9
|
+
display: grid;
|
|
10
|
+
grid-template-columns: 72px 1fr;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: 6px;
|
|
13
|
+
min-width: 172px;
|
|
14
|
+
`,le=X.div`
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 4px;
|
|
18
|
+
`;function ue(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 de(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function fe({credentials:e,health:t,quota:r,burn:i,usage:a,lastUsed:o,quotaPollIntervalMs:c,now:u}){let d=l(t,e=>e.credentialId),f=l(r,e=>e.credentialId),m=l(i,e=>e.credentialId),v=new Map(a.map(e=>[e.key,e])),y={down:0,warn:1,ok:2,idle:3,live:3},S=e.map(e=>{let t=m.get(e.id)??[];return{credential:e,status:b(d.get(e.id)??[],u,e.enabled,e.disabledReason),quota:C(f.get(e.id)??[]),burn:t,exhaustsAt:ue(t),usage:v.get(e.id)}}).sort((e,t)=>y[e.status.state]-y[t.status.state]||de(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return J(M,{legend:`Accounts`,meta:`${e.length} connected`,flush:!0,actions:J(D,{as:s,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:e.length===0?J(j,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:J(D,{as:s,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):J(F,{children:Y(W,{children:[J(`thead`,{children:Y(`tr`,{children:[J(U,{children:`Account`}),J(U,{children:`Provider`}),J(U,{$align:`right`,children:`Tier`}),J(U,{children:`Quota`}),J(U,{$align:`right`,children:`Requests`}),J(U,{$align:`right`,children:`Last used`})]})}),J(`tbody`,{children:S.map(({credential:e,status:t,quota:r,burn:i,usage:a})=>Y(V,{children:[J(H,{children:Y(A,{$gap:2,children:[J(x,{state:t.state,label:t.note===``?`healthy`:t.note}),Y(`div`,{children:[J(se,{children:e.label}),t.note===``?null:J(Z,{children:t.note})]})]})}),J(H,{children:J(oe,{provider:e.provider})}),J(H,{$align:`right`,$mono:!0,children:e.tier}),J(H,{children:r.length===0?J(Z,{children:`unknown`}):J(le,{children:r.map(({window:e,fraction:t})=>Y(ce,{children:[J(B,{fraction:t,label:`${g[e.windowType]} window, ${Math.round(t*100)}% used`}),J(k,{children:p(e,u,c,n,_(i,e.windowType))})]},e.windowType))})}),J(H,{$align:`right`,$mono:!0,children:a===void 0?`—`:h(a.requests)}),J(H,{$align:`right`,$mono:!0,children:n(o[e.id]??null,u)})]},e.id))})]})})})}var pe=X.ul`
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
`,me=X.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
|
+
`,he=X(P)`
|
|
32
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
+
font-size: 12px;
|
|
34
|
+
max-width: 30ch;
|
|
35
|
+
`,ge=X(P)`
|
|
36
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
37
|
+
font-size: 11px;
|
|
38
|
+
color: ${({theme:e})=>e.color.inkFaint};
|
|
39
|
+
max-width: 16ch;
|
|
40
|
+
`,_e=X(N)`
|
|
41
|
+
color: ${({theme:e})=>e.color.down};
|
|
42
|
+
font-size: 11px;
|
|
43
|
+
`;function ve({logs:t,keyNames:n}){let a=t.slice(0,12);return J(M,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:J(D,{as:s,to:`/logs`,$size:`sm`,children:`Open logs`}),children:a.length===0?J(j,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):J(pe,{children:a.map(t=>Y(me,{children:[J(x,{state:v(t),label:d(t)}),J(N,{$dim:!0,children:e(t.at)}),J(he,{title:t.requestedModel,children:t.requestedModel||`—`}),t.resolvedProvider===null?null:J(N,{$dim:!0,style:{color:L(t.resolvedProvider)},children:t.resolvedProvider}),t.apiKeyId===null?null:J(ge,{title:t.apiKeyId,children:n.get(t.apiKeyId)??ee(t.apiKeyId)}),J(O,{}),S(t)?J(N,{$dim:!0,"aria-label":`processing`,children:J(ae,{})}):Y(q,{children:[t.errorCode===null?null:J(_e,{children:t.errorCode}),t.attempts>1?Y(N,{$dim:!0,children:[t.attempts,`×`]}):null,J(N,{$dim:!0,children:J(R,{tokens:t})}),J(N,{$dim:!0,children:i(t.durationMs)}),J(N,{$dim:!0,children:r(t.costUsd)})]})]},t.id))})})}var ye=X.ul`
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
gap: ${({theme:e})=>e.space(3)};
|
|
47
|
+
`,be=X(P)`
|
|
48
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
49
|
+
font-size: 12.5px;
|
|
50
|
+
`,xe=X.div`
|
|
51
|
+
display: flex;
|
|
52
|
+
height: 5px;
|
|
53
|
+
border-radius: 2px;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
background: ${({theme:e})=>e.color.panelSunk};
|
|
56
|
+
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
57
|
+
`,Q=X.div`
|
|
58
|
+
flex: ${({$grow:e})=>e} 0 0;
|
|
59
|
+
background: ${({$color:e})=>e};
|
|
60
|
+
opacity: 0.8;
|
|
61
|
+
`,Se=X.div`
|
|
62
|
+
flex: ${({$grow:e})=>e} 0 0;
|
|
63
|
+
`;function Ce({models:e,logs:t}){let n=new Map;for(let e of t){let t=n.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,n.set(e.requestedModel,t)}let i=Math.max(1,...[...n.values()].map(e=>e.requests)),a=[...e].map(e=>({model:e,used:n.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return J(M,{legend:`Models`,meta:`${e.length} configured`,actions:J(D,{as:s,to:`/models`,$size:`sm`,children:`Edit routing`}),children:e.length===0?J(j,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:J(D,{as:s,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):J(ye,{children:a.map(({model:e,used:t})=>{let n=(t?.requests??0)/i,a=[...new Set(e.targets.map(e=>e.provider))];return Y(`li`,{children:[Y(A,{$gap:2,children:[J(be,{title:e.id,children:e.id}),e.isAlias?J(z,{children:`alias`}):null,J(z,{$tone:`accent`,children:e.strategy}),J(O,{}),J(N,{$dim:!0,children:h(t?.requests??0)}),J(k,{children:`req`}),J(N,{$dim:!0,children:r(t?.costUsd??0)})]}),Y(xe,{style:{marginTop:6},title:`${Math.round(n*100)}% of the busiest model`,children:[a.map(e=>J(Q,{$color:L(e),$grow:n/a.length},e)),J(Se,{$grow:Math.max(0,1-n)})]})]},e.id)})})})}var we=X.div`
|
|
64
|
+
display: grid;
|
|
65
|
+
grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
|
|
66
|
+
gap: ${({theme:e})=>e.space(3)};
|
|
67
|
+
`;function Te({logs:e,windowMs:n,now:a}){let o=e.filter(e=>a-e.at<=n),s=T(o,n),c=m(o,{now:a,spanMs:n,count:32}),l=s.errorRate>=.25?`down`:s.errorRate>=.05?`warn`:`ok`,u=s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheWriteTokens;return Y(we,{children:[J(G,{legend:`Requests`,value:h(s.requests),unit:`${s.ratePerMin.toFixed(1)}/min`,trace:J(I,{values:c.map(e=>e.total),overlay:c.map(e=>e.errors),label:`${s.requests} requests, ${s.errors} of them failed`})}),J(G,{legend:`Error rate`,value:t(s.errorRate),unit:`${h(s.errors)} failed`,tone:s.requests===0?`ink`:l,trace:J(I,{values:c.map(e=>e.errors),scaleTo:Math.max(...c.map(e=>e.total)),color:`var(--down)`,label:`${s.errors} failed requests against ${s.requests} total`})}),J(G,{legend:`Total tokens`,value:h(u),unit:J(R,{tokens:s}),trace:J(I,{values:c.map(e=>e.tokens),label:`token volume over the window, ${u.toLocaleString(`en-US`)} total`})}),J(G,{legend:`Time to first token`,value:i(s.ttftP50),unit:`p95 ${i(s.ttftP95)}`,trace:J(I,{values:c.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${i(s.ttftP50)}`})}),J(G,{legend:`Spend`,value:r(s.costUsd),unit:`${h(s.inputTokens+s.outputTokens)} tokens`,trace:J(I,{values:c.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${r(s.costUsd)} total`})})]})}var $=36e5;function Ee(){let{cadence:e}=re(),t=f(),n=u(e(1e4,`res:credentials`)),r=a(),i=w(500,e(1e4,`res:logs`)),s=c(),d=o(),p=K(()=>{let e=new Map;for(let t of s.data??[])e.set(t.id,t.label);return e},[s.data]),m=Date.now(),h=Math.floor((m-$)/6e4)*6e4,g=y({groupBy:`credential`,since:h},e(6e4,`res:usage`)),_=t.data??[],v=l(n.data?.health??[],e=>e.credentialId),x=_.filter(e=>b(v.get(e.id)??[],m,e.enabled,e.disabledReason).state===`down`),S=t.isLoading||i.isLoading?`Reading the gateway…`:_.length===0?`No accounts are connected, so every request fails at the router.`:x.length>0?`${x.length} account${x.length===1?` is`:`s are`} out of rotation.`:`All ${_.length} accounts are answering. Nothing needs attention.`;return Y(q,{children:[J(ie,{legend:`Rack`,title:`Gateway`,summary:S}),i.isError?J(M,{legend:`Traffic`,children:J(ne,{legend:`The gateway did not answer`,error:i.error,onRetry:()=>void i.refetch()})}):Y(E,{$gap:4,children:[J(Te,{logs:i.data??[],windowMs:$,now:m}),J(fe,{credentials:_,health:n.data?.health??[],quota:n.data?.quota??[],burn:n.data?.burn??[],usage:g.data??[],lastUsed:n.data?.lastUsed??{},quotaPollIntervalMs:d.data?.quotaPollIntervalMs??3e5,now:m}),Y(te,{$min:`340px`,$gap:4,children:[J(Ce,{models:r.data??[],logs:i.data??[]}),J(ve,{logs:i.data??[],keyNames:p})]})]})]})}var De=Ee;export{De as component};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import{Lt as e,M as t,Nt as n,Rt as r,Tt as i,bt as a,lt as o,w as s,zt as c}from"./Lamp-Drd1fFwQ.js";import{C as l,D as u,O as d,_ as f,a as p,b as m,i as h,o as g,r as _,t as v,v as y,w as b,x}from"./Panel-BV18WuL1.js";import{b as S,i as C,r as w,t as T,v as E}from"./Rack-D3iFlR6e.js";import{t as D}from"./CopyValue-DDJId-Zo.js";import{n as O,t as k}from"./chevron-right-BE-3EQR5.js";import{t as A}from"./plus-DhyoE7aH.js";import{t as j}from"./Toggle-y17mtXCV.js";import{t as M}from"./Chip-77Q04h7S.js";import{n as N,r as P,t as F}from"./Field-56pmSGrh.js";import{t as I}from"./Meter-stpt3vQu.js";import{i as L,n as R,r as z,t as ee}from"./Table-CVDZ69Zx.js";import{Fragment as B,useState as V}from"react";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import G from"styled-components";var te=S(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),ne=S(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]);function K(e,t){return e.revokedAt===null?s(e,t)?`active`:`expired`:`revoked`}function re(e){if(e===null)return``;let t=new Date(e-new Date(e).getTimezoneOffset()*6e4);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16)}function q(e){let t=e.trim();if(t.length===0)return{at:null};let n=new Date(t).getTime();return Number.isFinite(n)?{at:n}:{problem:`"${e}" is not a date`}}var ie=G.p`
|
|
2
|
+
font-size: 12px;
|
|
3
|
+
color: ${({theme:e})=>e.color.down};
|
|
4
|
+
`,ae=G.p`
|
|
5
|
+
font-size: 12px;
|
|
6
|
+
color: ${({theme:e})=>e.color.warn};
|
|
7
|
+
`;function oe({apiKey:t,onOpenChange:n}){let r=e(),[i,a]=V(()=>re(t?.expiresAt??null)),[o,s]=V(null),c=()=>{if(t===null)return;let e=q(i);if(`problem`in e){s(e.problem);return}s(null),r.mutate({id:t.id,expiresAt:e.at},{onSuccess:()=>n(!1),onError:e=>s(g(e))})},d=t!==null&&K(t,Date.now())===`expired`;return U(C,{open:t!==null,onOpenChange:n,title:`Edit expiry`,description:t===null?void 0:`When "${t.label}" stops being accepted. Leave it blank for never.`,width:`480px`,footer:W(H,{children:[U(u,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:c,children:r.isPending?`Saving…`:`Save expiry`})]}),children:W(l,{$gap:3,children:[d?U(ae,{role:`status`,children:`This key has expired and the gateway is refusing it. Moving the date forward, or clearing it, brings it back.`}):null,U(F,{label:`Expires`,hint:`Your local time. Blank means the key never expires; a date already past expires it now.`,children:e=>U(N,{...e,type:`datetime-local`,value:i,disabled:r.isPending,onChange:e=>a(e.target.value)})}),o===null?null:U(ie,{role:`alert`,children:o})]})})}var J=[{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 Y(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var se={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},ce={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function X(e){let t=se[e.dimension];return e.window===null?t:`${t} ${ce[e.window]}`}function Z(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function Q(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function le(e){let t=null,n=-1;for(let r of e){let e=Q(r);e!==null&&e>n&&(t=r,n=e)}return t}function $(e){let t={};for(let e of J)t[Y(e)]=``;if(e===null)return t;for(let n of J){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[Y(n)]=String(r))}return t}function ue(e){let t={},n={},r={},i;for(let a of J){let o=(e[Y(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?`${X(a)} must be an amount above zero, or blank for no limit.`:`${X(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 de=G.div`
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
10
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
11
|
+
`,fe=G.p`
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
14
|
+
`;function pe({draft:e,onChange:t,disabled:n=!1}){return W(l,{$gap:2,children:[U(de,{children:J.map(r=>{let i=Y(r);return U(F,{label:X(r),children:a=>U(P,{...a,min:r.dimension===`spend`?void 0:1,step:r.dimension===`spend`?`any`:1,disabled:n,value:e[i]??``,placeholder:`none`,onChange:n=>t({...e,[i]:n.target.value})})},i)})}),U(fe,{children:`Blank means no limit. Token and spend ceilings are debited after a response completes, so a key at its ceiling is refused on its next request rather than its current one. Concurrency counts requests in flight right now and resets when the gateway restarts.`})]})}var me=G.p`
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
color: ${({theme:e})=>e.color.down};
|
|
17
|
+
`,he=G.p`
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
color: ${({theme:e})=>e.color.warn};
|
|
20
|
+
`;function ge({apiKey:e,onOpenChange:t}){let n=r(),[i,a]=V(()=>$(e?.limits??{})),[o,s]=V(null);return U(C,{open:e!==null,onOpenChange:t,title:`Edit limits`,description:e===null?void 0:`What "${e.label}" may do per minute, per five hours, and per week. Every field is a ceiling; blank is no limit.`,width:`640px`,footer:W(H,{children:[U(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{if(e===null)return;let r=ue(i);if(`problem`in r){s(r.problem);return}s(null),n.mutate({id:e.id,limits:r.limits},{onSuccess:()=>t(!1),onError:e=>s(g(e))})},children:n.isPending?`Saving…`:`Save limits`})]}),children:W(l,{$gap:3,children:[e?.limits===null?U(he,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,U(pe,{draft:i,onChange:a,disabled:n.isPending}),o===null?null:U(me,{role:`alert`,children:o})]})})}var _e=G.div`
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: 2px;
|
|
24
|
+
max-height: 190px;
|
|
25
|
+
overflow-y: auto;
|
|
26
|
+
padding: ${({theme:e})=>e.space(1)};
|
|
27
|
+
border: 1px solid ${({theme:e})=>e.color.ruleStrong};
|
|
28
|
+
border-radius: ${({theme:e})=>e.radius.control};
|
|
29
|
+
background: ${({theme:e})=>e.color.panelSunk};
|
|
30
|
+
`,ve=G.label`
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
34
|
+
padding: 4px 6px;
|
|
35
|
+
border-radius: 2px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
|
|
40
|
+
&:hover {
|
|
41
|
+
background: ${({theme:e})=>e.color.panelRaised};
|
|
42
|
+
}
|
|
43
|
+
`,ye=G.p`
|
|
44
|
+
font-size: 11px;
|
|
45
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
46
|
+
`;function be({configured:e,checked:t,onChange:n,disabled:r}){let i=[...new Set([...e,...t])].sort(),a=(e,r)=>{n(r?[...t,e]:t.filter(t=>t!==e))},o=t.filter(t=>!e.includes(t));return W(`div`,{children:[U(_e,{children:i.map(e=>W(ve,{children:[U(`input`,{type:`checkbox`,disabled:r,"aria-label":e,checked:t.includes(e),onChange:t=>a(e,t.target.checked)}),e]},e))}),o.length>0?U(ye,{children:`Some listed models are no longer configured. They stay until you clear them.`}):null,t.length===0?U(f,{children:`With nothing selected this key is allowed no model.`}):null]})}var xe=G.p`
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
color: ${({theme:e})=>e.color.down};
|
|
49
|
+
`;function Se({apiKey:e,onOpenChange:t}){let n=c(),r=i(),[a,o]=V(e?.modelAllowlist===null),[s,d]=V(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[p,h]=V(null),_=(r.data??[]).map(e=>e.id);return U(C,{open:e!==null,onOpenChange:t,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:W(H,{children:[U(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{e!==null&&(h(null),n.mutate({id:e.id,modelAllowlist:a?null:s},{onSuccess:()=>t(!1),onError:e=>h(g(e))}))},children:n.isPending?`Saving…`:`Save models`})]}),children:W(l,{$gap:3,children:[W(l,{$gap:2,children:[W(m,{$gap:2,children:[U(j,{checked:a,label:`Allow every model`,onCheckedChange:e=>{o(e),e&&d([])}}),U(f,{as:`span`,children:`Allow every model`})]}),a?null:U(be,{configured:_,checked:s,onChange:d,disabled:n.isPending})]}),p===null?null:U(xe,{role:`alert`,children:p})]})})}var Ce=G.div`
|
|
50
|
+
display: grid;
|
|
51
|
+
grid-template-columns: minmax(0, 11rem) minmax(0, 12rem) minmax(0, 1fr) minmax(0, 3.5rem);
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: ${({theme:e})=>e.space(2)} ${({theme:e})=>e.space(4)};
|
|
54
|
+
`,we=G.span`
|
|
55
|
+
font-size: 11.5px;
|
|
56
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
57
|
+
`,Te=G.p`
|
|
58
|
+
font-size: 11px;
|
|
59
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
60
|
+
`;function Ee({label:e,readings:t}){return W(l,{$gap:3,children:[U(Ce,{children:t.map(t=>{let n=X({dimension:t.dimension,window:t.window}),r=Q(t),i=Z(t.dimension,t.limit);return W(B,{children:[U(f,{as:`span`,children:n}),U(y,{children:t.used===null?i:`${Z(t.dimension,t.used)} of ${i}`}),r===null?U(we,{children:`in flight now, counted in the gateway process`}):U(I,{fraction:Math.min(1,r),label:`${e}, ${n}, ${Math.round(r*100)}% used`}),U(y,{children:r===null?`—`:`${Math.round(r*100)}%`})]},n)})}),U(Te,{children:`Usage counts completed requests still inside each window. Requests in flight are added by the gateway itself and are not shown here.`})]})}var De=G.p`
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
color: ${({theme:e})=>e.color.warn};
|
|
63
|
+
`,Oe=G.p`
|
|
64
|
+
font-size: 11px;
|
|
65
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
66
|
+
`,ke=G.p`
|
|
67
|
+
font-size: 12px;
|
|
68
|
+
color: ${({theme:e})=>e.color.down};
|
|
69
|
+
`,Ae=G.p`
|
|
70
|
+
font-size: 12px;
|
|
71
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
72
|
+
`,je=G(u)`
|
|
73
|
+
gap: 4px;
|
|
74
|
+
`;function Me({open:e,onOpenChange:t}){let n=i(),r=o(),[a,s]=V(``),[c,d]=V(!0),[p,h]=V([]),[_,v]=V(()=>$({})),[b,x]=V(!1),[S,w]=V(``),[T,E]=V(!1),[A,M]=V(null),[P,I]=V(null),L=()=>{s(``),d(!0),h([]),v($({})),x(!1),w(``),E(!1),M(null),I(null),r.reset()},R=e=>{e||L(),t(e)},z=Object.values(_).filter(e=>e.trim().length>0).length;return U(C,{open:e,onOpenChange:R,title:A===null?`Create an API key`:`Key created`,description:A===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:A===null?W(H,{children:[U(u,{type:`button`,onClick:()=>R(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{let e=ue(_);if(`problem`in e){x(!0),I(e.problem);return}let t=q(S);if(`problem`in t){I(t.problem);return}I(null),r.mutate({label:a.trim().length===0?`api key`:a.trim(),modelAllowlist:c?null:p,limits:e.limits,bodyLoggingOptOut:T,expiresAt:t.at},{onSuccess:e=>M(e),onError:e=>I(g(e))})},children:r.isPending?`Creating…`:`Create key`})]}):U(u,{type:`button`,$variant:`primary`,onClick:()=>R(!1),children:`I have copied the key`}),children:A===null?W(l,{$gap:3,children:[U(F,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>U(N,{...e,value:a,placeholder:`api key`,onChange:e=>s(e.target.value)})}),W(l,{$gap:2,children:[W(m,{$gap:2,children:[U(j,{checked:c,label:`Allow every model`,onCheckedChange:d}),U(f,{as:`span`,children:`Allow every model`})]}),c?null:W(H,{children:[U(be,{configured:(n.data??[]).map(e=>e.id),checked:p,onChange:h}),p.length===0?U(De,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),W(l,{$gap:2,children:[W(m,{$gap:2,children:[W(je,{type:`button`,$size:`sm`,"aria-expanded":b,onClick:()=>x(e=>!e),children:[U(b?O:k,{}),`Limits`]}),U(f,{as:`span`,children:z===0?`no limits; this key is unbounded`:`${z} limit${z===1?``:`s`} set`})]}),b?U(pe,{draft:_,onChange:v}):null]}),U(F,{label:`Expires`,hint:`Optional. Your local time; blank means the key never expires.`,children:e=>U(N,{...e,type:`datetime-local`,value:S,onChange:e=>w(e.target.value)})}),W(l,{$gap:2,children:[W(m,{$gap:2,children:[U(j,{checked:T,label:`Never record this key's bodies`,onCheckedChange:E}),U(f,{as:`span`,children:`Never record this key's bodies`})]}),U(Oe,{children:`Suppresses body capture for this key whatever the gateway setting says. Choose it for a client whose payloads must not be retained. It cannot be changed after the key is created — issue a new key instead.`})]}),P===null?null:U(ke,{role:`alert`,children:P})]}):W(l,{$gap:3,children:[U(Ae,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),U(D,{value:A.key,label:`Copy API key`}),W(m,{$gap:2,children:[U(f,{children:`Label`}),U(y,{children:A.label}),U(f,{children:`Prefix`}),U(y,{children:A.prefix})]})]})})}var Ne=G(m)`
|
|
75
|
+
gap: 4px;
|
|
76
|
+
flex-wrap: wrap;
|
|
77
|
+
max-width: 34ch;
|
|
78
|
+
`,Pe=G.span`
|
|
79
|
+
color: ${({theme:e})=>e.color.inkFaint};
|
|
80
|
+
`,Fe=G.span`
|
|
81
|
+
display: block;
|
|
82
|
+
font-size: 11px;
|
|
83
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
84
|
+
`,Ie=G.span`
|
|
85
|
+
font-size: 11px;
|
|
86
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
87
|
+
`,Le=G.div`
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
align-items: flex-end;
|
|
91
|
+
gap: 2px;
|
|
92
|
+
`;function Re(e){if(e===null)return`usage not counted here`;let t=Q(e);return`${X({dimension:e.dimension,window:e.window})} ${Z(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ze(){let e=a(),r=n(),[i,o]=V(!1),[s,c]=V(null),[l,g]=V(null),[y,S]=V(null),[C,D]=V(null),[j,N]=V(null),P=Date.now(),F=e.data??[],I=F.filter(e=>K(e,P)===`active`),G=e.isLoading?`Reading issued keys…`:F.length===0?`No keys exist, so nothing can call this gateway yet.`:`${I.length} active key${I.length===1?``:`s`} of ${F.length} ever issued.`;return W(H,{children:[U(T,{legend:`Keys`,title:`Gateway API keys`,summary:G,actions:W(u,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[U(A,{}),`Create a key`]})}),U(v,{legend:`Issued keys`,meta:`${F.length}`,flush:!0,children:e.isError?U(h,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?U(`div`,{style:{padding:12},children:U(p,{rows:4})}):F.length===0?U(_,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:U(u,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):U(x,{children:W(ee,{children:[U(`thead`,{children:W(`tr`,{children:[U(z,{children:`Label`}),U(z,{children:`Prefix`}),U(z,{children:`Allowed models`}),U(z,{$align:`right`,children:`Limits`}),U(z,{$align:`right`,children:`Created`}),U(z,{children:`Body capture`}),U(z,{children:`Status`}),U(z,{})]})}),U(`tbody`,{children:F.map(e=>{let n=C===e.id,r=le(e.limitUsage),i=K(e,P);return W(B,{children:[W(L,{children:[U(R,{children:U(b,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),W(R,{$mono:!0,children:[e.prefix,`…`]}),U(R,{children:e.modelAllowlist===null?U(f,{children:`every model`}):e.modelAllowlist.length===0?U(M,{$tone:`down`,children:`no models`}):U(Ne,{children:e.modelAllowlist.map(e=>U(M,{children:e},e))})}),U(R,{$align:`right`,children:e.limits===null?U(M,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?U(f,{children:`no limits`}):W(Le,{children:[W(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),U(Ie,{children:Re(r)})]})}),U(R,{$align:`right`,$mono:!0,children:t(e.createdAt)}),U(R,{children:e.bodyLoggingOptOut?U(M,{children:`no bodies`}):U(f,{children:`—`})}),W(R,{children:[i===`revoked`?U(Pe,{title:t(e.revokedAt??0),children:U(M,{children:`revoked`})}):i===`expired`?U(M,{$tone:`down`,children:`expired`}):U(M,{$tone:`ok`,children:`active`}),e.expiresAt===null?null:W(Fe,{children:[i===`expired`?`expired`:`expires`,` `,t(e.expiresAt)]})]}),U(R,{$align:`right`,children:W(m,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":n,"aria-label":`${n?`Hide`:`Show`} limits for ${e.label}`,title:`${n?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>D(n?null:e.id),children:U(n?O:k,{})}),e.revokedAt===null?W(H,{children:[U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>g(e),children:U(ne,{})}),U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>c(e),children:U(E,{})}),U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit expiry for ${e.label}`,title:`Edit expiry for ${e.label}`,onClick:()=>S(e),children:U(te,{})}),U(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>N(e),children:`Revoke`})]}):null]})})]}),n?U(L,{children:U(R,{colSpan:8,children:U(Ee,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),U(Me,{open:i,onOpenChange:o}),U(ge,{apiKey:s,onOpenChange:e=>{e||c(null)}},s?.id??`none`),U(Se,{apiKey:l,onOpenChange:e=>{e||g(null)}},l?.id??`none`),U(oe,{apiKey:y,onOpenChange:e=>{e||S(null)}},y?.id??`none`),U(w,{open:j!==null,onOpenChange:e=>{e||N(null)},title:`Revoke key`,body:j===null?``:`Revoking "${j.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:r.isPending,onConfirm:()=>{j!==null&&r.mutate(j.id,{onSettled:()=>N(null)})}})]})}var Be=ze;export{Be as component};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{At as e,J as t,V as n,bt as r,ft as i,j as a,l as o,u as s,wt as c}from"./Lamp-Drd1fFwQ.js";import{C as l,D as u,_ as d,a as f,b as p,i as m,r as h,t as g,x as _}from"./Panel-BV18WuL1.js";import{_ as v,i as y,t as b}from"./Rack-D3iFlR6e.js";import{t as x}from"./Chip-77Q04h7S.js";import{i as S,n as C}from"./Field-56pmSGrh.js";import{i as w,n as T,r as E,t as D}from"./RequestTable-I395emqH.js";import{useMemo as O,useState as k}from"react";import{Fragment as A,jsx as j,jsxs as M}from"react/jsx-runtime";import N from"styled-components";var P={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.`}},F=new Intl.NumberFormat(`en-US`),I=N.p`
|
|
2
2
|
font-size: 12px;
|
|
3
3
|
color: ${({theme:e})=>e.color.inkDim};
|
|
4
4
|
max-width: 62ch;
|
|
@@ -34,7 +34,7 @@ import{A as e,B as t,Dt as n,_t as r,l as i,q as a,u as o,ut as s,xt as c}from".
|
|
|
34
34
|
line-height: 1.5;
|
|
35
35
|
white-space: pre-wrap;
|
|
36
36
|
word-break: break-word;
|
|
37
|
-
`;function H(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 U({title:e,stage:t,value:n}){let r=H(n);return M(B,{children:[M(z,{children:[j(R,{children:e}),t===void 0?null:j(x,{children:t})]}),r===null?n==null?j(I,{children:`Nothing was recorded for this half — it never happened, or never completed.`}):j(V,{children:JSON.stringify(n,null,2)}):M(I,{children:[`Too large to keep: `,r.reason,`. The payload was`,` `,F.format(r.serializedBytes),` bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace.`]})]})}function W({attempt:
|
|
37
|
+
`;function H(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 U({title:e,stage:t,value:n}){let r=H(n);return M(B,{children:[M(z,{children:[j(R,{children:e}),t===void 0?null:j(x,{children:t})]}),r===null?n==null?j(I,{children:`Nothing was recorded for this half — it never happened, or never completed.`}):j(V,{children:JSON.stringify(n,null,2)}):M(I,{children:[`Too large to keep: `,r.reason,`. The payload was`,` `,F.format(r.serializedBytes),` bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace.`]})]})}function W({attempt:e}){return M(l,{$gap:2,children:[M(p,{$gap:2,$wrap:!0,children:[M(d,{as:`h3`,children:[`Attempt `,e.attempt,` · `,e.provider]}),e.truncated?j(x,{$tone:`warn`,children:`truncated`}):null]}),j(U,{title:`Request sent to the provider`,stage:`post-RTK`,value:e.request}),j(U,{title:`Response from the provider`,value:e.response}),e.streamChunks===null?null:j(U,{title:`Raw stream frames (${a(e.streamChunks.length)})`,value:e.streamChunks})]})}function G({body:e}){let t=e.artifact;if(t===null){let t=P[e.detailState===`ready`?`corrupt`:e.detailState];return M(l,{$gap:1,children:[j(d,{children:t.legend}),j(I,{children:t.message})]})}return M(l,{$gap:3,children:[t.attempts.length===0?null:j(L,{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.`}),M(l,{$gap:2,children:[M(p,{$gap:2,$wrap:!0,children:[j(d,{as:`h3`,children:`Client`}),t.client.truncated?j(x,{$tone:`warn`,children:`truncated`}):null]}),j(U,{title:`Request from the client`,stage:`pre-RTK`,value:t.client.request}),j(U,{title:`Response returned to the client`,value:t.client.response})]}),t.attempts.map(e=>j(W,{attempt:e},`${e.attempt}-${e.provider}`)),t.error===null||t.error===void 0?null:j(U,{title:`Error`,value:t.error})]})}function K({requestId:t}){let n=e(t),r=n.data===void 0||n.data.detailState!==`ready`?void 0:`${F.format(n.data.sizeBytes)} bytes on disk`;return j(g,{legend:`Captured bodies`,...r===void 0?{}:{meta:r},...n.data?.truncated===!0?{actions:j(x,{$tone:`warn`,children:`truncated`})}:{},children:n.isError?j(m,{error:n.error,onRetry:()=>void n.refetch()}):n.isPending?j(f,{rows:3}):j(G,{body:n.data})})}var q=[50,100,250,500],J=N(p)`
|
|
38
38
|
gap: ${({theme:e})=>e.space(2)};
|
|
39
39
|
flex-wrap: wrap;
|
|
40
40
|
`,Y=N(C)`
|
|
@@ -55,4 +55,4 @@ import{A as e,B as t,Dt as n,_t as r,l as i,q as a,u as o,ut as s,xt as c}from".
|
|
|
55
55
|
flex: 1;
|
|
56
56
|
min-height: 0;
|
|
57
57
|
overflow-y: auto;
|
|
58
|
-
`;function $(){let{cadence:
|
|
58
|
+
`;function $(){let{cadence:e,live:l}=v(),[d,p]=k(100),[g,_]=k(`all`),[x,S]=k(``),[C,N]=k(null),P=c(d,e(n,`res:logs`)),F=i(),I=r(),L=t(),R=(P.data??[]).some(s),z=w(l&&R),B=O(()=>({accounts:new Map((F.data??[]).map(e=>[e.id,e.label])),keys:new Map((I.data??[]).map(e=>[e.id,e.label]))}),[F.data,I.data]),V=E(P.data??[],g,x,B),H=(P.data??[]).filter(o).length,U=(P.data??[]).filter(s).length;return M(A,{children:[j(b,{legend:`Logs`,title:`Recent requests`,summary:P.isLoading?`Reading the request log…`:`${a(P.data?.length??0)} recent requests, ${a(H)} of them failed${U===0?``:`, ${a(U)} still running`}. ${L.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:M(J,{children:[j(Y,{value:x,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>S(e.target.value)}),M(X,{value:g,"aria-label":`Show which requests`,onChange:e=>_(e.target.value),children:[j(`option`,{value:`all`,children:`All requests`}),j(`option`,{value:`failed`,children:`Failed only`})]}),j(X,{value:d,"aria-label":`How many requests to fetch`,onChange:e=>p(Number(e.target.value)),children:q.map(e=>M(`option`,{value:e,children:[`last `,e]},e))})]})}),j(Z,{legend:`Request log`,meta:`${V.length} shown`,flush:!0,children:P.isError?j(m,{error:P.error,onRetry:()=>void P.refetch()}):P.isLoading?j(`div`,{style:{padding:12},children:j(f,{rows:8})}):V.length===0?j(h,{legend:`Nothing to show`,message:(P.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):j(Q,{"data-testid":`request-log-scroller`,children:j(T,{rows:V,now:z,names:B,onOpen:N})})}),j(y,{open:C!==null,onOpenChange:e=>{e||N(null)},title:`Request detail`,width:`760px`,footer:j(u,{type:`button`,onClick:()=>N(null),children:`Close`}),children:C===null?null:j(D,{log:C,names:B,children:j(K,{requestId:C.id})})})]})}var ee=$;export{ee as component};
|