omnigateway 0.4.13 → 0.5.0
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 +52 -1
- package/bin/omni.js +176 -72
- package/gateway.js +1145 -126
- package/package.json +1 -1
- package/public/assets/{CopyValue-C2DkO9Yz.js → CopyValue-dQWAaTxf.js} +3 -3
- package/public/assets/{Field-B79Yxdit.js → Field-DTQ2LPzA.js} +1 -1
- package/public/assets/{Match-BWa6L0L1.js → Match-C85GObiU.js} +1 -1
- package/public/assets/{Panel-CoulMx6R.js → Panel-CQVz9yeR.js} +2 -2
- package/public/assets/Rack-V32CHmN6.js +316 -0
- package/public/assets/{Readout-D1XEfywe.js → Readout-DJR1qKja.js} +1 -1
- package/public/assets/States-CauIsA0N.js +54 -0
- package/public/assets/{Toggle-CRrH9nDt.js → Toggle-BQI8jz09.js} +1 -1
- package/public/assets/{TokenBreakdown-C2NsJnqO.js → TokenBreakdown-B2_gfuqt.js} +1 -1
- package/public/assets/_app-DzzXdoyU.js +1 -0
- package/public/assets/_app.accounts-owsnxlbn.js +64 -0
- package/public/assets/_app.console-bzKNP_8Y.js +44 -0
- package/public/assets/_app.database-CsJbkedE.js +24 -0
- package/public/assets/_app.index-D4ydl2mY.js +62 -0
- package/public/assets/_app.keys-DKX0smty.js +82 -0
- package/public/assets/_app.logs-CFFsj2zR.js +68 -0
- package/public/assets/_app.models-B0ZxWGHV.js +148 -0
- package/public/assets/{_app.plugins._pluginId-BOXRBToU.js → _app.plugins._pluginId-C5X4B1cE.js} +3 -3
- package/public/assets/{_app.settings-DoaOUmc1.js → _app.settings-Yg_6az-L.js} +4 -4
- package/public/assets/_app.usage-BRIz_GCn.js +83 -0
- package/public/assets/index-DiCU8bLB.js +178 -0
- package/public/assets/{login-B9CJqU--.js → login-B4LoiALI.js} +3 -3
- package/public/assets/plus-xu9reaJp.js +1 -0
- package/public/assets/queries-DuSqKybM.js +145 -0
- package/public/assets/{shared-Cct_4xwp.js → shared-DYkFSPbd.js} +4 -4
- package/public/assets/stream-Dz5HjHBh.js +1 -0
- package/public/assets/{trash-2-DwMK-JrZ.js → trash-2-DbutVvFY.js} +1 -1
- package/public/index.html +3 -3
- package/public/shared/dashboard-sdk.js +1 -1
- package/public/assets/Rack-HM36SprU.js +0 -314
- package/public/assets/States-DtkkMzEu.js +0 -54
- package/public/assets/_app-DVpIsUid.js +0 -1
- package/public/assets/_app.accounts-64d_cxir.js +0 -64
- package/public/assets/_app.console-BBuBmLRI.js +0 -44
- package/public/assets/_app.database-J9Ujio8l.js +0 -24
- package/public/assets/_app.index-BX4yKEXO.js +0 -62
- package/public/assets/_app.keys-2sKwhZJc.js +0 -76
- package/public/assets/_app.logs-DuHXYrZU.js +0 -68
- package/public/assets/_app.models-B0kTfPtn.js +0 -148
- package/public/assets/_app.usage-B5sxB40E.js +0 -83
- package/public/assets/index-iCfSaRSG.js +0 -178
- package/public/assets/plus-DKapAGoR.js +0 -1
- package/public/assets/queries-CX9mStps.js +0 -145
|
@@ -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-DYkFSPbd.js";import{A as u,B as d,G as f,O as p,dt as m,et as h,f as g,g as _,h as v,it as y,l as b,ot as x,r as S,rt as C,tt as w,u as ee,ut as T,v as E}from"./queries-DuSqKybM.js";import{a as D,g as O,o as k,s as te,t as ne}from"./Rack-V32CHmN6.js";import{n as re,r as A,t as ie}from"./CopyValue-dQWAaTxf.js";import{t as j}from"./plus-xu9reaJp.js";import{t as M}from"./trash-2-DbutVvFY.js";import{t as N}from"./Toggle-BQI8jz09.js";import{A as P,C as F,E as I,F as ae,N as oe,O as L,S as se,_ as ce,a as le,b as ue,c as de,d as R,i as z,j as fe,k as pe,l as me,m as he,n as ge,o as _e,r as ve,t as ye,u as be,v as xe,y as Se}from"./States-CauIsA0N.js";import{t as Ce}from"./Chip-BltJSw8A.js";import{i as B,n as V,r as we,t as H}from"./Field-DTQ2LPzA.js";import{t as Te}from"./Meter-stpt3vQu.js";import{t as U}from"./Panel-CQVz9yeR.js";import{i as Ee,n as W,r as G,t as De}from"./Table-CVDZ69Zx.js";import{t as Oe}from"./catalog-BBKm8Ih8.js";import*as ke from"react";import{Fragment as Ae,forwardRef as je,useCallback as Me,useEffect as Ne,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 Pe=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`}]]),Fe=Object.keys(Oe);function Ie(e){return Oe[e].authTypes}function Le(e){return Ie(e).includes(`oauth`)?`oauth`:`apiKey`}var Re={oauth:`Authorize in the browser`,apiKey:`Paste an API key`},Z={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,kilo:`Kilo`,grok:`Grok`,custom:`OpenAI Compatible`},ze={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.`},Be={openai:`http://localhost:1455/auth/callback?code=…`,grok:`http://127.0.0.1:56121/callback?code=…`},Ve=X.ol`
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: ${({theme:e})=>e.space(3)};
|
|
5
|
+
`,He=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
|
+
`,Ue=X.p`
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
color: ${({theme:e})=>e.color.down};
|
|
17
|
+
`,We=X.p`
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
20
|
+
`;function Ge({open:e,credentials:t,onOpenChange:n,onConnected:r}){let[i,a]=K(`anthropic`),[o,s]=K(Le(`anthropic`)),[c,l]=K(``),[u,d]=K(null),[f,p]=K(``),[m,_]=K(``),v=(t??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[y,w]=K(``),[E,D]=K(``),[O,k]=K(`chat_completions`),[ne,re]=K(``),[A,j]=K(null),M=ee(),N=b(),P=g(),F=Me(()=>{d(null),p(``),_(``),w(``),D(``),k(`chat_completions`),re(``),j(null),l(``),M.reset(),N.reset(),P.reset()},[M,N,P]),I=Me(e=>{e||F(),n(e)},[n,F]);return Ne(()=>{if(u===null||u.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await S(u.flowId);if(e)return;if(t.status===`complete`){F(),n(!1),r();return}}catch(t){if(e)return;j(z(t)),d(null);return}e||(i=setTimeout(()=>void t(),u.pollIntervalMs))},i=setTimeout(()=>void t(),u.pollIntervalMs);return()=>{e=!0,clearTimeout(i)}},[u,r,n,F]),J(te,{open:e,onOpenChange:I,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:u===null?Y(q,{children:[J(T,{type:`button`,onClick:()=>I(!1),children:`Cancel`}),J(T,{type:`button`,$variant:`primary`,disabled:M.isPending||P.isPending,onClick:()=>{if(j(null),o===`apiKey`){P.mutate({provider:i,apiKey:ne,label:c.trim()||void 0,...i===`custom`?{endpointId:m,endpointLabel:y,origin:E,protocol:O}:{}},{onSuccess:()=>{F(),n(!1),r()},onError:e=>j(z(e))});return}M.mutate({provider:i,label:c.trim().length===0?Z[i]:c.trim()},{onSuccess:e=>d(e),onError:e=>j(z(e))})},children:o===`apiKey`?P.isPending?`Adding…`:`Add API key`:M.isPending?`Starting…`:`Start authorization`})]}):u.kind===`device`?J(T,{type:`button`,onClick:()=>I(!1),children:`Cancel`}):Y(q,{children:[J(T,{type:`button`,onClick:()=>I(!1),children:`Cancel`}),J(T,{type:`button`,$variant:`primary`,disabled:N.isPending||f.trim().length===0,onClick:()=>{u!==null&&(j(null),N.mutate({flowId:u.flowId,code:f.trim()},{onSuccess:()=>{F(),n(!1),r()},onError:e=>j(z(e))}))},children:N.isPending?`Finishing…`:`Finish connecting`})]}),children:Y(Ve,{children:[u===null?Y(x,{$gap:3,children:[J(H,{label:`Provider`,children:e=>J(B,{...e,value:i,onChange:e=>{let t=e.target.value;a(t),s(Le(t))},children:Fe.map(e=>J(`option`,{value:e,children:Z[e]},e))})}),Ie(i).length>1?J(H,{label:`How to connect`,children:e=>J(B,{...e,value:o,onChange:e=>s(e.target.value),children:Ie(i).map(e=>J(`option`,{value:e,children:Re[e]},e))})}):null,i===`custom`?Y(q,{children:[v.length===0?null:J(H,{label:`Existing endpoint`,children:e=>Y(B,{...e,value:m,onChange:e=>{let t=v.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){_(``),w(``),D(``),k(`chat_completions`);return}_(String(t.providerData.endpointId)),w(String(t.providerData.endpointLabel)),D(String(t.providerData.origin)+String(t.providerData.basePath??``)),k(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[J(`option`,{value:``,children:`Create new endpoint`}),v.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:m,onChange:e=>_(e.target.value)})}),J(H,{label:`Endpoint label`,children:e=>J(V,{...e,value:y,onChange:e=>w(e.target.value)})}),J(H,{label:`Server URL`,children:e=>J(V,{...e,value:E,placeholder:`https://server.example/api`,onChange:e=>D(e.target.value)})}),E.trim().toLowerCase().startsWith(`http://`)?J(Ue,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,J(H,{label:`Protocol`,children:e=>Y(B,{...e,value:O,onChange:e=>k(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:ne,autoComplete:`off`,onChange:e=>re(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(x,{$gap:3,children:[Y(x,{$gap:1,children:[J(h,{children:`Step 1 — authorize`}),J(C,{$gap:2,children:Y(T,{as:`a`,href:u.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[J(Pe,{}),`Open `,Z[i]]})}),J(ie,{value:u.authorizeUrl,label:`Copy authorization link`})]}),u.userCode===null?null:Y(x,{$gap:1,children:[J(h,{children:`Step 2 — enter this code`}),J(He,{children:u.userCode})]}),u.kind===`device`?Y(We,{children:[ze[i],` Waiting for authorization…`]}):J(H,{label:`Authorization code`,hint:ze[i],...A===null?{}:{problem:A},children:e=>J(V,{...e,value:f,autoFocus:!0,placeholder:Be[i]??`code#state`,onChange:e=>p(e.target.value)})})]}),A===null||u?.kind===`pkce`?null:J(Ue,{children:A})]})})}var Ke=[`axis`],qe=je((e,n)=>ke.createElement(t,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Ke,tooltipPayloadSearcher:a,categoricalChartProps:e,ref:n})),Je=X(C)`
|
|
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
|
+
`,Ye={budget:`1 4`,projection:`6 4`},Xe=`projected`;function Ze(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 Qe(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 $e(e,t){let n=t?.windowStartsAt??null;return n===null||e.resetsAt===null?null:n-(e.resetsAt-n)}function et({credentialId:e,windows:t,burn:n,pollIntervalMs:r,now:i}){let a=t.map(e=>{let t=me(n,e.windowType);return{window:e,estimate:t,since:$e(e,t)}}),o=a.map(e=>e.since).filter(e=>e!==null),s=o.length===0?0:Math.min(...o),c=u({credentialId:e,since:s},o.length>0),l=c.data?.samples??[],d=c.data?.gatewayRates??[];return J(x,{$gap:4,children:a.map(e=>J(nt,{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),pollIntervalMs:r,now:i},e.window.windowType))})}function tt(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 ~${P(t.exhaustsAt-n)} before it resets`}function nt({window:t,estimate:a,since:u,samples:d,gatewayRate:f,pollIntervalMs:p,now:m}){let g=_e[t.windowType],_=t.limit===null?`${L(t.used)} used`:`${L(t.used)} of ${L(t.limit)} used`;if(a===void 0||a.stale||he(t,m,p))return Y(x,{$gap:2,children:[Y(C,{$gap:2,$wrap:!0,children:[Y(h,{children:[g,` window`]}),J($,{children:_})]}),J($,{children:`reading is stale`})]});let v=se(Se(d),t),y=v.flatMap(e=>{let t=de(e);return t===null?[]:[{key:`${e.key}-budget`,pace:t}]}),b=ce(t,a),S=Ze([...v,...y.map(e=>({key:e.key,points:[e.pace.from,e.pace.to]})),...b===null?[]:[{key:Xe,points:[b.from,b.to]}]]),ee=new Set(v.map(e=>e.key)),T=Math.max(100,...b===null?[]:[b.from.percent,b.to.percent].map(e=>Math.ceil(e))),E=u===null||t.resetsAt===null?null:Qe(u,t.resetsAt,y);return Y(x,{$gap:2,children:[Y(C,{$gap:2,$wrap:!0,children:[Y(h,{children:[g,` window`]}),J($,{children:_})]}),Y(Je,{children:[Y(Q,{children:[J(h,{children:`Window average`}),J(w,{children:a.ratePerHour===null?`unknown`:`${L(a.ratePerHour)}/h`})]}),Y(Q,{children:[J(h,{children:`Estimate`}),J(w,{children:tt(t,a,m)})]}),Y(Q,{children:[J(h,{children:`Projected`}),J(w,{children:b===null?`unknown`:`${Math.round(b.to.percent)}% of limit by reset`})]}),Y(Q,{children:[J(h,{children:`This gateway accounts for`}),J(w,{children:f?.gatewayRatePerHour===void 0||f.gatewayRatePerHour===null?`unknown`:`${L(f.gatewayRatePerHour)} tokens/h`})]})]}),t.limit===null?J($,{children:`no ceiling reported`}):E===null?J($,{children:`no reset reported`}):v.length===0?J($,{children:`not yet observed`}):Y(q,{children:[J(h,{children:[`Used, this window and the one before`,...y.length===0?[]:[`budget dotted`],...b===null?[]:[`projection dashed`]].join(` · `)}),J(c,{$height:160,children:J(s,{width:`100%`,height:`100%`,children:Y(qe,{data:S,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:E,tickFormatter:e=>I(e,E[1]-E[0]),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,minTickGap:ae(E[1]-E[0])?80:40}),J(l,{domain:[0,T],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=>ee.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:pe(r)}),Y(`div`,{children:[n.value.toFixed(1),`% used`]})]})}}),v.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)),y.map(e=>J(n,{type:`linear`,dataKey:e.key,stroke:`var(--ink-faint)`,strokeWidth:1.5,strokeDasharray:Ye.budget,dot:!1,connectNulls:!0,isAnimationActive:!1},e.key)),b===null?null:J(n,{type:`linear`,dataKey:Xe,stroke:`var(--ink-dim)`,strokeWidth:1.5,strokeDasharray:Ye.projection,dot:!1,connectNulls:!0,isAnimationActive:!1})]})})})]})]})}var rt=[`anthropic`,`openai`,`kimi`,`kilo`,`grok`,`custom`],it={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,kilo:`Kilo`,grok:`Grok`,custom:`OpenAI Compatible`},at=X(U)`
|
|
31
|
+
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
32
|
+
`,ot=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
|
+
`,st=X(we)`
|
|
47
|
+
width: 62px;
|
|
48
|
+
height: 26px;
|
|
49
|
+
`,ct=X.span`
|
|
50
|
+
display: block;
|
|
51
|
+
padding-left: 9px;
|
|
52
|
+
font-size: 11px;
|
|
53
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
54
|
+
`,lt=X.div`
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-columns: 96px 1fr;
|
|
57
|
+
align-items: center;
|
|
58
|
+
min-width: 208px;
|
|
59
|
+
gap: 6px;
|
|
60
|
+
`,ut=X.div`
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
gap: 4px;
|
|
64
|
+
`;function dt(){let e=f();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function ft(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 pt(){let{cadence:e}=D(),t=_(),n=v(e(1e4,`res:credentials`)),r=d(),i=p(),a=E(),{commit:o}=dt(),[s,c]=K(!1),[l,u]=K(null),[f,g]=K(new Set),b=e=>g(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),S=Date.now(),w=t.data??[],ee=R(n.data?.health??[],e=>e.credentialId),O=R(n.data?.quota??[],e=>e.credentialId),te=R(n.data?.burn??[],e=>e.credentialId),ie=r.data?.quotaPollIntervalMs??3e5,P=w.filter(e=>e.enabled).length,F=t.isLoading?`Reading connected accounts…`:w.length===0?`No provider credentials are connected, so every request fails at the router.`:`${P} of ${w.length} accounts are enabled and eligible for routing.`;return Y(q,{children:[J(ne,{legend:`Accounts`,title:`Provider accounts`,summary:F,actions:Y(T,{type:`button`,$variant:`primary`,onClick:()=>c(!0),children:[J(j,{}),`Connect an account`]})}),t.isError?J(U,{legend:`Accounts`,children:J(ge,{error:t.error,onRetry:()=>void t.refetch()})}):t.isLoading?J(U,{legend:`Accounts`,children:J(ve,{rows:5})}):w.length===0?J(U,{legend:`Accounts`,children:J(ye,{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(T,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>c(!0),children:`Connect an account`})})}):J(x,{$gap:4,children:rt.filter(e=>w.some(t=>t.provider===e)).map(e=>{let t=w.filter(t=>t.provider===e);return J(at,{$provider:e,legend:it[e],meta:`${t.length} account${t.length===1?``:`s`}`,flush:!0,children:J(y,{children:Y(De,{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=be(ee.get(e.id)??[],S,e.enabled,e.disabledReason),n=O.get(e.id)??[],r=te.get(e.id)??[],i=ue(n),a=f.has(e.id);return Y(Ae,{children:[Y(Ee,{children:[Y(W,{children:[Y(C,{$gap:2,children:[J(le,{state:t.state,label:t.note===``?`healthy`:t.note}),J(ot,{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}o(e.id,{label:n})}})]}),t.note===``?null:J(ct,{children:t.note})]}),J(W,{children:Y(C,{$gap:1,children:[J(Ce,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:J(h,{children:e.accountEmail})]})}),J(W,{$align:`right`,children:J(st,{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}o(e.id,{tier:n})}})}),J(W,{$align:`right`,children:J(st,{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}o(e.id,{weight:n})}})}),J(W,{$align:`center`,children:J(N,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>o(e.id,{enabled:t})})}),J(W,{children:i.length===0?J(h,{children:`unknown`}):J(ut,{children:i.map(({window:e,fraction:t})=>Y(lt,{children:[J(Te,{fraction:t,label:`${_e[e.windowType]} window, ${Math.round(t*100)}% used`}),J(h,{children:xe(e,S,ie,oe,me(r,e.windowType))})]},e.windowType))})}),J(W,{$align:`right`,$mono:!0,children:fe(t.ttftMs)}),J(W,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:oe(e.expiresAt,S)}),J(W,{$align:`right`,children:Y(C,{$gap:1,$justify:`flex-end`,children:[n.length===0?null:J(m,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":a,"aria-label":`${a?`Hide`:`Show`} quota history for ${e.label}`,title:`${a?`Hide`:`Show`} quota history for ${e.label}`,onClick:()=>b(e.id),children:J(a?A:re,{})}),J(m,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>u(e),children:J(M,{})})]})})]}),a?J(Ee,{children:J(W,{colSpan:9,children:J(et,{credentialId:e.id,windows:n,burn:r,pollIntervalMs:ie,now:S})})}):null]},e.id)})})]})})},e)})}),J(Ge,{open:s,credentials:t.data??[],onOpenChange:c,onConnected:()=>void t.refetch()}),J(k,{open:l!==null,onOpenChange:e=>{e||u(null)},title:`Remove account`,body:l===null?``:`Removing "${l.label}" deletes its stored token. Any model target pointing at ${it[l.provider]} loses this account, and reconnecting means authorizing again.`+ft(l,i.data),confirmLabel:`Remove account`,busy:a.isPending,onConfirm:()=>{l!==null&&a.mutate(l.id,{onSettled:()=>u(null)})}})]})}var mt=pt;export{mt as component};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import{d as e,nt as t,rt as n,t as r}from"./queries-DuSqKybM.js";import{a as i,t as a}from"./Rack-V32CHmN6.js";import{O as o,n as s,r as c,t as l}from"./States-CauIsA0N.js";import{i as u}from"./Field-DTQ2LPzA.js";import{t as d}from"./Panel-CQVz9yeR.js";import{a as f,i as p,r as m}from"./stream-Dz5HjHBh.js";import{useQueryClient as h}from"@tanstack/react-query";import{useLayoutEffect as g,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],k=[{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`}],A=S(n)`
|
|
2
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
`,j=S(u)`
|
|
5
|
+
width: auto;
|
|
6
|
+
`,M=S.div`
|
|
7
|
+
display: grid;
|
|
8
|
+
grid-template-rows: auto minmax(0, 1fr);
|
|
9
|
+
gap: ${({theme:e})=>e.space(4)};
|
|
10
|
+
min-height: 0;
|
|
11
|
+
flex: 1;
|
|
12
|
+
`,N=S(d)`
|
|
13
|
+
min-height: 0;
|
|
14
|
+
|
|
15
|
+
> div {
|
|
16
|
+
display: flex;
|
|
17
|
+
flex: 1;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
min-height: 0;
|
|
20
|
+
}
|
|
21
|
+
`,P=S.div`
|
|
22
|
+
flex: 1;
|
|
23
|
+
min-height: 0;
|
|
24
|
+
overflow-x: auto;
|
|
25
|
+
overflow-y: auto;
|
|
26
|
+
`,F=S.pre`
|
|
27
|
+
margin: 0;
|
|
28
|
+
padding: ${({theme:e})=>e.space(3)};
|
|
29
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
30
|
+
font-size: 12px;
|
|
31
|
+
line-height: 1.65;
|
|
32
|
+
white-space: pre;
|
|
33
|
+
`,I=S.div`
|
|
34
|
+
color: ${({theme:e,$level:t})=>t===`error`?e.color.down:t===`warn`?e.color.warn:t===`debug`?e.color.inkFaint:e.color.ink};
|
|
35
|
+
`,L=S.p`
|
|
36
|
+
margin: 0;
|
|
37
|
+
padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
|
|
38
|
+
border-top: 1px solid ${({theme:e})=>e.color.rule};
|
|
39
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
40
|
+
font-size: 12px;
|
|
41
|
+
`,R=S.code`
|
|
42
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
43
|
+
word-break: break-all;
|
|
44
|
+
`;function z({read:e}){return e.source===`file`?x(L,{children:[`Reading `,b(R,{children:e.path}),`, named by `,b(R,{children:`OMNI_LOG_FILE`}),`. That variable says where the gateway's output is being captured; it does not redirect it.`]}):e.source===`journal`?x(L,{children:[`Reading the systemd journal for `,b(R,{children:`omnigateway.service`}),`. To read a file instead, redirect the gateway's output to one and point `,b(R,{children:`OMNI_LOG_FILE`}),` at the same path.`]}):null}var B=[],V={read:void 0,lines:B};function H(){let{cadence:n}=i(),u=h(),[d,S]=y(200),[C,w]=y(``),E=e(d,C,n(r,p)),L=E.data,[R,H]=y(V),W=R.read===L?R.lines:B,G=_(()=>[...L?.lines??[],...W].slice(-d),[L,W,d]),K=v(null),q=v(!0);return m(p,e=>{let t=e.kind===`frame`?D(e.payload):null;if(t===null){H({read:L,lines:B}),e.kind===`frame`&&f(u,p);return}let n=t.filter(e=>T(e,C));n.length!==0&&H(e=>({read:L,lines:[...e.read===L?e.lines:[],...n].slice(-d)}))}),g(()=>{let e=K.current;e!==null&&q.current&&G.length>0&&(e.scrollTop=e.scrollHeight)},[G]),x(M,{children:[b(a,{legend:`Console`,title:`Gateway output`,summary:E.isLoading?`Reading the gateway's own output…`:`${o(G.length)} lines of what this process is doing. Requests are in Logs; prompt bodies, tokens and keys are never written here.`,actions:x(A,{children:[b(j,{value:C,"aria-label":`Which levels to show`,onChange:e=>w(e.target.value),children:k.map(e=>b(`option`,{value:e.value,children:e.label},e.value))}),b(j,{value:d,"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(N,{legend:`Process output`,meta:L===void 0?void 0:b(t,{children:U(L)}),flush:!0,children:[L===void 0?null:b(z,{read:L}),b(P,{ref:K,"data-testid":`console-terminal`,onScroll:e=>{let t=e.currentTarget;q.current=t.scrollHeight-t.scrollTop-t.clientHeight<=8},children:E.isError?b(s,{error:E.error,onRetry:()=>void E.refetch()}):E.isLoading?b(`div`,{style:{padding:12},children:b(c,{rows:10})}):L!==void 0&&L.source===`none`?b(l,{legend:`Nothing is capturing this gateway`,message:"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."}):G.length===0?b(l,{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(F,{children:G.map((e,t)=>b(I,{$level:e.level,children:e.raw},`${e.at??0}-${t}`))})})]})]})}function U(e){return e.source===`file`?`log file`:e.source===`journal`?`systemd journal`:`not captured`}var W=H;export{W as component};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import{$ as e,I as t,N as n,S as r,U as i,_ as a,a as o,b as s,et as c,it as l,m as u,ot as d,q as f,rt as p,st as m,ut as h}from"./queries-DuSqKybM.js";import{g,o as _,t as v}from"./Rack-V32CHmN6.js";import{M as y,T as b,i as x,j as S,k as C,n as w,r as T,t as E}from"./States-CauIsA0N.js";import{r as D,t as O}from"./Field-DTQ2LPzA.js";import{t as k}from"./Meter-stpt3vQu.js";import{t as A}from"./Panel-CQVz9yeR.js";import{i as j,n as M,r as N,t as P}from"./Table-CVDZ69Zx.js";import{t as F}from"./Readout-DJR1qKja.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
|
+
font-size: 12px;
|
|
3
|
+
color: ${({theme:e})=>e.color.down};
|
|
4
|
+
`,J=U.p`
|
|
5
|
+
font-size: 12px;
|
|
6
|
+
color: ${({theme:e})=>e.color.ok};
|
|
7
|
+
`,Y=U.div`
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
10
|
+
gap: ${({theme:e})=>e.space(3)};
|
|
11
|
+
`;function X(e){let t={};for(let n of K){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 Z({retention:e}){let n=t(),[r,i]=z({}),[a,o]=z(null),[s,l]=z(!1),u={keepLatest:r.keepLatest??(e===void 0?``:String(e.keepLatest)),maxAgeDays:r.maxAgeDays??(e===void 0?``:String(e.maxAgeDays))};return V(A,{legend:`Retention`,actions:V(h,{type:`button`,$size:`sm`,disabled:n.isPending||e===void 0,onClick:()=>{l(!1);let e=X(u);if(!e.ok){o(e.problem);return}o(null),n.mutate(e.policy,{onSuccess:()=>{l(!0),i({})},onError:e=>o(x(e))})},children:n.isPending?`Saving…`:`Save retention`}),children:H(d,{$gap:3,children:[V(Y,{children:K.map(e=>V(O,{label:e.label,hint:e.hint,children:t=>H(p,{$gap:2,children:[V(D,{...t,min:1,max:e.max,step:1,value:u[e.id],onChange:t=>i({...r,[e.id]:t.target.value})}),V(c,{children:e.unit})]})},e.id))}),a===null?null:V(q,{role:`alert`,children:a}),s&&a===null?V(J,{role:`status`,children:`Retention saved.`}):null]})})}function Q(){let e=L();return R(t=>{if(t.adminPasswordChanged){I(`admin-password-changed`);return}e.invalidateQueries()},[e])}var $=U.p`
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
color: ${({theme:e})=>e.color.down};
|
|
14
|
+
`,ee=U.input`
|
|
15
|
+
font-size: 12px;
|
|
16
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
17
|
+
max-width: 40ch;
|
|
18
|
+
`;function te(){let e=i(),t=u(),a=n(),c=Q(),f=s(),g=r(),[v,y]=z(null),[S,D]=z(null),[k,F]=z(null),[I,L]=z(!1),R=e.data??[],B=H(h,{type:`button`,$variant:`primary`,$size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(),children:[V(W,{}),t.isPending?`Copying…`:`Take a snapshot`]}),U=H(d,{$gap:2,children:[H(p,{$gap:2,$wrap:!0,children:[V(O,{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=>V(ee,{...e,type:`file`,accept:`.sqlite,.db,application/octet-stream`,onChange:e=>F(e.target.files?.[0]??null)})}),V(h,{type:`button`,$variant:`danger`,$size:`sm`,disabled:k===null||g.isPending,onClick:()=>L(!0),children:g.isPending?`Replacing…`:`Import`})]}),g.isError?V($,{role:`alert`,children:x(g.error)}):null,a.isError?V($,{role:`alert`,children:x(a.error)}):null,t.isError?V($,{role:`alert`,children:x(t.error)}):null]});return H(A,{legend:`Snapshots`,meta:`${R.length}`,actions:B,footer:U,flush:!0,children:[e.isError?V(w,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?V(`div`,{style:{padding:12},children:V(T,{rows:3})}):R.length===0?V(E,{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:V(h,{type:`button`,$variant:`primary`,$size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(),children:`Take the first snapshot`})}):V(l,{children:H(P,{children:[V(`thead`,{children:H(`tr`,{children:[V(N,{children:`File`}),V(N,{children:`Reason`}),V(N,{$align:`right`,children:`Size`}),V(N,{$align:`right`,children:`Taken`}),V(N,{})]})}),V(`tbody`,{children:R.map(e=>H(j,{children:[V(M,{$mono:!0,children:V(m,{style:{maxWidth:`38ch`,display:`block`},children:e.filename})}),V(M,{children:e.reason}),V(M,{$align:`right`,$mono:!0,children:b(e.sizeBytes)}),V(M,{$align:`right`,$mono:!0,children:C(e.createdAt)}),V(M,{$align:`right`,children:H(p,{$gap:1,$justify:`flex-end`,children:[V(h,{as:`a`,$size:`sm`,href:o(e.id),download:e.filename,children:`Download`}),V(h,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>y(e),children:`Restore`}),V(h,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>D(e),children:`Delete`})]})})]},e.id))})]})}),V(_,{open:v!==null,onOpenChange:e=>{e||y(null)},title:`Restore database`,body:v===null?``:`Replacing the live database with ${v.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:a.isPending,onConfirm:()=>{v!==null&&a.mutate(v.id,{onSuccess:c,onSettled:()=>y(null)})}}),V(_,{open:S!==null,onOpenChange:e=>{e||D(null)},title:`Delete snapshot`,body:S===null?``:`Deleting ${S.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:f.isPending,onConfirm:()=>{S!==null&&f.mutate(S.id,{onSettled:()=>D(null)})}}),V(_,{open:I,onOpenChange:L,title:`Import database`,body:k===null?``:`Replacing the live database with ${k.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:g.isPending,onConfirm:()=>{k!==null&&g.mutate(k,{onSuccess:c,onSettled:()=>L(!1)})}})]})}var ne=U.p`
|
|
19
|
+
font-size: 12px;
|
|
20
|
+
color: ${({theme:e})=>e.color.ok};
|
|
21
|
+
`,re=U.p`
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
color: ${({theme:e})=>e.color.down};
|
|
24
|
+
`;function ie(){let t=a(),n=f(),[r,i]=z(!1),o=t.data,s=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:t.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(h,{type:`button`,$size:`sm`,disabled:n.isPending||o===void 0,onClick:()=>i(!0),children:[V(G,{}),n.isPending?`Compacting…`:`Compact`]}),footer:n.isError?V(re,{role:`alert`,children:x(n.error)}):n.data===void 0?void 0:V(ne,{role:`status`,children:`Compacted, reclaiming ${b(n.data.reclaimedBytes)} in ${S(n.data.durationMs)}.`}),children:t.isError?V(w,{error:t.error,onRetry:()=>void t.refetch()}):o===void 0?V(T,{rows:3}):H(e,{$min:`180px`,$stretch:!0,children:[V(F,{legend:`Database file`,value:b(o.fileBytes),unit:`${o.stats.pageCount} pages of ${b(o.stats.pageSize)}`,trace:V(k,{fraction:s,label:`${y(s,0)} of the file is reclaimable`})}),V(F,{legend:`Reclaimable`,value:b(o.freePageBytes),unit:`${o.stats.freelistCount} free pages`}),V(F,{legend:`Write-ahead log`,value:b(o.walBytes),unit:`folded into every snapshot`}),V(F,{legend:`Captured bodies`,value:b(o.bodiesBytes),unit:`never in a snapshot`}),V(F,{legend:`Snapshots`,value:b(o.snapshots.totalBytes),unit:`${o.snapshots.count} kept`}),V(F,{legend:`Free disk`,value:b(o.freeDiskBytes),unit:o.freeDiskBytes===null?`not readable here`:`on this filesystem`})]})}),V(te,{}),V(Z,{retention:o?.retention}),V(_,{open:r,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:n.isPending,onConfirm:()=>n.mutate(void 0,{onSettled:()=>i(!1)})})]})}var ae=ie;export{ae as component};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import{$ as e,B as t,D as n,K as r,O as i,at as a,et as o,ft as s,g as c,h as l,it as u,ot as d,rt as f,st as p,tt as m,ut as h}from"./queries-DuSqKybM.js";import{a as g,r as _,t as v}from"./Rack-V32CHmN6.js";import{n as y,t as b}from"./TokenBreakdown-B2_gfuqt.js";import{D as x,M as S,N as C,O as w,P as T,a as E,b as D,d as O,g as k,h as ee,j as A,l as j,n as M,o as N,p as P,s as F,t as I,u as L,v as te,x as ne}from"./States-CauIsA0N.js";import{n as re,t as R}from"./Chip-BltJSw8A.js";import{t as z}from"./Meter-stpt3vQu.js";import{t as B}from"./Panel-CQVz9yeR.js";import{i as V,n as H,r as U,t as W}from"./Table-CVDZ69Zx.js";import{t as G}from"./Readout-DJR1qKja.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:e,health:t,quota:n,burn:r,usage:i,quotaPollIntervalMs:a,now:c}){let l=O(t,e=>e.credentialId),d=O(n,e=>e.credentialId),p=O(r,e=>e.credentialId),m=new Map(i.map(e=>[e.key,e])),g={down:0,warn:1,ok:2,idle:3,live:3},_=e.map(e=>{let t=p.get(e.id)??[];return{credential:e,status:L(l.get(e.id)??[],c,e.enabled,e.disabledReason),quota:D(d.get(e.id)??[]),burn:t,exhaustsAt:oe(t),usage:m.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:`${e.length} connected`,flush:!0,actions:q(h,{as:s,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:e.length===0?q(I,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:q(h,{as:s,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):q(u,{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:e,status:t,quota:n,burn:r,usage:i})=>J(V,{children:[q(H,{children:J(f,{$gap:2,children:[q(E,{state:t.state,label:t.note===``?`healthy`:t.note}),J(`div`,{children:[q(X,{children:e.label}),t.note===``?null:q(Z,{children:t.note})]})]})}),q(H,{children:q(re,{provider:e.provider})}),q(H,{$align:`right`,$mono:!0,children:e.tier}),q(H,{children:n.length===0?q(Z,{children:`unknown`}):q(ae,{children:n.map(({window:e,fraction:t})=>J(ie,{children:[q(z,{fraction:t,label:`${N[e.windowType]} window, ${Math.round(t*100)}% used`}),q(o,{children:te(e,c,a,C,j(r,e.windowType))})]},e.windowType))})}),q(H,{$align:`right`,$mono:!0,children:A(t.ttftMs)}),q(H,{$align:`right`,$mono:!0,children:i===void 0?`—`:w(i.requests)}),q(H,{$align:`right`,$mono:!0,children:C(t.lastUsedAt,c)})]},e.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(m)`
|
|
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(h,{as:s,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?q(I,{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(E,{state:k(e),label:ee(e)}),q(m,{$dim:!0,children:x(e.at)}),q(de,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:q(m,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),q(a,{}),P(e)?q(m,{$dim:!0,"aria-label":`processing`,children:q(b,{})}):J(K,{children:[e.errorCode===null?null:q(fe,{children:e.errorCode}),e.attempts>1?J(m,{$dim:!0,children:[e.attempts,`×`]}):null,q(m,{$dim:!0,children:q(y,{tokens:e})}),q(m,{$dim:!0,children:A(e.durationMs)}),q(m,{$dim:!0,children:T(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: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 r=Math.max(1,...[...n.values()].map(e=>e.requests)),i=[...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 q(B,{legend:`Models`,meta:`${e.length} configured`,actions:q(h,{as:s,to:`/models`,$size:`sm`,children:`Edit routing`}),children:e.length===0?q(I,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:q(h,{as:s,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):q(me,{children:i.map(({model:e,used:t})=>{let n=(t?.requests??0)/r,i=[...new Set(e.targets.map(e=>e.provider))];return J(`li`,{children:[J(f,{$gap:2,children:[q(Q,{title:e.id,children:e.id}),e.isAlias?q(R,{children:`alias`}):null,q(R,{$tone:`accent`,children:e.strategy}),q(a,{}),q(m,{$dim:!0,children:w(t?.requests??0)}),q(o,{children:`req`}),q(m,{$dim:!0,children:T(t?.costUsd??0)})]}),J(he,{style:{marginTop:6},title:`${Math.round(n*100)}% of the busiest model`,children:[i.map(e=>q(ge,{$color:`var(--p-${e})`,$grow:n/i.length},e)),q(_e,{$grow:Math.max(0,1-n)})]})]},e.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=ne(r,t),a=F(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:w(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:S(i.errorRate),unit:`${w(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:w(s),unit:q(y,{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:A(i.ttftP50),unit:`p95 ${A(i.ttftP95)}`,trace:q(_,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${A(i.ttftP50)}`})}),q(G,{legend:`Spend`,value:T(i.costUsd),unit:`${w(i.inputTokens+i.outputTokens)} tokens`,trace:q(_,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${T(i.costUsd)} total`})})]})}var $=36e5;function xe(){let{cadence:a}=g(),o=c(),s=l(a(1e4,`res:credentials`)),u=i(),f=n(500,a(1e4,`res:logs`)),p=t(),m=Date.now(),h=Math.floor((m-$)/6e4)*6e4,_=r({groupBy:`credential`,since:h},a(6e4,`res:usage`)),y=o.data??[],b=O(s.data?.health??[],e=>e.credentialId),x=y.filter(e=>L(b.get(e.id)??[],m,e.enabled,e.disabledReason).state===`down`),S=o.isLoading||f.isLoading?`Reading the gateway…`:y.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 ${y.length} accounts are answering. Nothing needs attention.`;return J(K,{children:[q(v,{legend:`Rack`,title:`Gateway`,summary:S}),f.isError?q(B,{legend:`Traffic`,children:q(M,{legend:`The gateway did not answer`,error:f.error,onRetry:()=>void f.refetch()})}):J(d,{$gap:4,children:[q(be,{logs:f.data??[],windowMs:$,now:m}),q(ce,{credentials:y,health:s.data?.health??[],quota:s.data?.quota??[],burn:s.data?.burn??[],usage:_.data??[],quotaPollIntervalMs:p.data?.quotaPollIntervalMs??3e5,now:m}),J(e,{$min:`340px`,$gap:4,children:[q(ve,{models:u.data??[],logs:f.data??[]}),q(pe,{logs:f.data??[]})]})]})]})}var Se=xe;export{Se as component};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import{C as e,O as t,P as n,R as r,dt as i,et as a,it as o,ot as s,p as c,rt as l,st as u,tt as d,ut as f,z as p}from"./queries-DuSqKybM.js";import{g as m,m as h,o as g,s as _,t as v}from"./Rack-V32CHmN6.js";import{n as y,r as b,t as x}from"./CopyValue-dQWAaTxf.js";import{t as S}from"./plus-xu9reaJp.js";import{t as C}from"./Toggle-BQI8jz09.js";import{i as w,k as T,n as E,r as D,t as O}from"./States-CauIsA0N.js";import{t as k}from"./Chip-BltJSw8A.js";import{n as A,r as j,t as M}from"./Field-DTQ2LPzA.js";import{t as N}from"./Meter-stpt3vQu.js";import{t as P}from"./Panel-CQVz9yeR.js";import{i as F,n as I,r as L,t as ee}from"./Table-CVDZ69Zx.js";import{Fragment 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 te=m(`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`}]]),W=[{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 G(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var ne={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},re={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=ne[e.dimension];return e.window===null?t:`${t} ${re[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 ie(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 W)t[G(e)]=``;if(e===null)return t;for(let n of W){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[G(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of W){let o=(e[G(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 ae=U.div`
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
4
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
5
|
+
`,oe=U.p`
|
|
6
|
+
font-size: 11px;
|
|
7
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
+
`;function Z({draft:e,onChange:t,disabled:n=!1}){return H(s,{$gap:2,children:[V(ae,{children:W.map(r=>{let i=G(r);return V(M,{label:K(r),children:a=>V(j,{...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)})}),V(oe,{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 se=U.p`
|
|
9
|
+
font-size: 12px;
|
|
10
|
+
color: ${({theme:e})=>e.color.down};
|
|
11
|
+
`,ce=U.p`
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
color: ${({theme:e})=>e.color.warn};
|
|
14
|
+
`;function le({apiKey:e,onOpenChange:t}){let n=r(),[i,a]=z(()=>Y(e?.limits??{})),[o,c]=z(null);return V(_,{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:H(B,{children:[V(f,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),V(f,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{if(e===null)return;let r=X(i);if(`problem`in r){c(r.problem);return}c(null),n.mutate({id:e.id,limits:r.limits},{onSuccess:()=>t(!1),onError:e=>c(w(e))})},children:n.isPending?`Saving…`:`Save limits`})]}),children:H(s,{$gap:3,children:[e?.limits===null?V(ce,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,V(Z,{draft:i,onChange:a,disabled:n.isPending}),o===null?null:V(se,{role:`alert`,children:o})]})})}var ue=U.div`
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 2px;
|
|
18
|
+
max-height: 190px;
|
|
19
|
+
overflow-y: auto;
|
|
20
|
+
padding: ${({theme:e})=>e.space(1)};
|
|
21
|
+
border: 1px solid ${({theme:e})=>e.color.ruleStrong};
|
|
22
|
+
border-radius: ${({theme:e})=>e.radius.control};
|
|
23
|
+
background: ${({theme:e})=>e.color.panelSunk};
|
|
24
|
+
`,de=U.label`
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
28
|
+
padding: 4px 6px;
|
|
29
|
+
border-radius: 2px;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
32
|
+
font-size: 12px;
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
background: ${({theme:e})=>e.color.panelRaised};
|
|
36
|
+
}
|
|
37
|
+
`,fe=U.p`
|
|
38
|
+
font-size: 11px;
|
|
39
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
40
|
+
`;function Q({configured:e,checked:t,onChange:n,disabled:r}){let i=[...new Set([...e,...t])].sort(),o=(e,r)=>{n(r?[...t,e]:t.filter(t=>t!==e))},s=t.filter(t=>!e.includes(t));return H(`div`,{children:[V(ue,{children:i.map(e=>H(de,{children:[V(`input`,{type:`checkbox`,disabled:r,"aria-label":e,checked:t.includes(e),onChange:t=>o(e,t.target.checked)}),e]},e))}),s.length>0?V(fe,{children:`Some listed models are no longer configured. They stay until you clear them.`}):null,t.length===0?V(a,{children:`With nothing selected this key is allowed no model.`}):null]})}var pe=U.p`
|
|
41
|
+
font-size: 12px;
|
|
42
|
+
color: ${({theme:e})=>e.color.down};
|
|
43
|
+
`;function me({apiKey:e,onOpenChange:n}){let r=p(),i=t(),[o,c]=z(e?.modelAllowlist===null),[u,d]=z(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[m,h]=z(null),g=(i.data??[]).map(e=>e.id);return V(_,{open:e!==null,onOpenChange:n,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:H(B,{children:[V(f,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),V(f,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{e!==null&&(h(null),r.mutate({id:e.id,modelAllowlist:o?null:u},{onSuccess:()=>n(!1),onError:e=>h(w(e))}))},children:r.isPending?`Saving…`:`Save models`})]}),children:H(s,{$gap:3,children:[H(s,{$gap:2,children:[H(l,{$gap:2,children:[V(C,{checked:o,label:`Allow every model`,onCheckedChange:e=>{c(e),e&&d([])}}),V(a,{as:`span`,children:`Allow every model`})]}),o?null:V(Q,{configured:g,checked:u,onChange:d,disabled:r.isPending})]}),m===null?null:V(pe,{role:`alert`,children:m})]})})}var he=U.div`
|
|
44
|
+
display: grid;
|
|
45
|
+
grid-template-columns: minmax(0, 11rem) minmax(0, 12rem) minmax(0, 1fr) minmax(0, 3.5rem);
|
|
46
|
+
align-items: center;
|
|
47
|
+
gap: ${({theme:e})=>e.space(2)} ${({theme:e})=>e.space(4)};
|
|
48
|
+
`,ge=U.span`
|
|
49
|
+
font-size: 11.5px;
|
|
50
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
51
|
+
`,_e=U.p`
|
|
52
|
+
font-size: 11px;
|
|
53
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
54
|
+
`;function ve({label:e,readings:t}){return H(s,{$gap:3,children:[V(he,{children:t.map(t=>{let n=K({dimension:t.dimension,window:t.window}),r=J(t),i=q(t.dimension,t.limit);return H(R,{children:[V(a,{as:`span`,children:n}),V(d,{children:t.used===null?i:`${q(t.dimension,t.used)} of ${i}`}),r===null?V(ge,{children:`in flight now, counted in the gateway process`}):V(N,{fraction:Math.min(1,r),label:`${e}, ${n}, ${Math.round(r*100)}% used`}),V(d,{children:r===null?`—`:`${Math.round(r*100)}%`})]},n)})}),V(_e,{children:`Usage counts completed requests still inside each window. Requests in flight are added by the gateway itself and are not shown here.`})]})}var ye=U.p`
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
color: ${({theme:e})=>e.color.warn};
|
|
57
|
+
`,be=U.p`
|
|
58
|
+
font-size: 11px;
|
|
59
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
60
|
+
`,xe=U.p`
|
|
61
|
+
font-size: 12px;
|
|
62
|
+
color: ${({theme:e})=>e.color.down};
|
|
63
|
+
`,$=U.p`
|
|
64
|
+
font-size: 12px;
|
|
65
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
66
|
+
`,Se=U(f)`
|
|
67
|
+
gap: 4px;
|
|
68
|
+
`;function Ce({open:e,onOpenChange:n}){let r=t(),i=c(),[o,u]=z(``),[p,m]=z(!0),[h,g]=z([]),[v,S]=z(()=>Y({})),[T,E]=z(!1),[D,O]=z(!1),[k,j]=z(null),[N,P]=z(null),F=()=>{u(``),m(!0),g([]),S(Y({})),E(!1),O(!1),j(null),P(null),i.reset()},I=e=>{e||F(),n(e)},L=Object.values(v).filter(e=>e.trim().length>0).length;return V(_,{open:e,onOpenChange:I,title:k===null?`Create an API key`:`Key created`,description:k===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:k===null?H(B,{children:[V(f,{type:`button`,onClick:()=>I(!1),children:`Cancel`}),V(f,{type:`button`,$variant:`primary`,disabled:i.isPending,onClick:()=>{let e=X(v);if(`problem`in e){E(!0),P(e.problem);return}P(null),i.mutate({label:o.trim().length===0?`api key`:o.trim(),modelAllowlist:p?null:h,limits:e.limits,bodyLoggingOptOut:D},{onSuccess:e=>j(e),onError:e=>P(w(e))})},children:i.isPending?`Creating…`:`Create key`})]}):V(f,{type:`button`,$variant:`primary`,onClick:()=>I(!1),children:`I have copied the key`}),children:k===null?H(s,{$gap:3,children:[V(M,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>V(A,{...e,value:o,placeholder:`api key`,onChange:e=>u(e.target.value)})}),H(s,{$gap:2,children:[H(l,{$gap:2,children:[V(C,{checked:p,label:`Allow every model`,onCheckedChange:m}),V(a,{as:`span`,children:`Allow every model`})]}),p?null:H(B,{children:[V(Q,{configured:(r.data??[]).map(e=>e.id),checked:h,onChange:g}),h.length===0?V(ye,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),H(s,{$gap:2,children:[H(l,{$gap:2,children:[H(Se,{type:`button`,$size:`sm`,"aria-expanded":T,onClick:()=>E(e=>!e),children:[V(T?b:y,{}),`Limits`]}),V(a,{as:`span`,children:L===0?`no limits; this key is unbounded`:`${L} limit${L===1?``:`s`} set`})]}),T?V(Z,{draft:v,onChange:S}):null]}),H(s,{$gap:2,children:[H(l,{$gap:2,children:[V(C,{checked:D,label:`Never record this key's bodies`,onCheckedChange:O}),V(a,{as:`span`,children:`Never record this key's bodies`})]}),V(be,{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.`})]}),N===null?null:V(xe,{role:`alert`,children:N})]}):H(s,{$gap:3,children:[V($,{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.`}),V(x,{value:k.key,label:`Copy API key`}),H(l,{$gap:2,children:[V(a,{children:`Label`}),V(d,{children:k.label}),V(a,{children:`Prefix`}),V(d,{children:k.prefix})]})]})})}var we=U(l)`
|
|
69
|
+
gap: 4px;
|
|
70
|
+
flex-wrap: wrap;
|
|
71
|
+
max-width: 34ch;
|
|
72
|
+
`,Te=U.span`
|
|
73
|
+
color: ${({theme:e})=>e.color.inkFaint};
|
|
74
|
+
`,Ee=U.span`
|
|
75
|
+
font-size: 11px;
|
|
76
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
77
|
+
`,De=U.div`
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
align-items: flex-end;
|
|
81
|
+
gap: 2px;
|
|
82
|
+
`;function Oe(e){if(e===null)return`usage not counted here`;let t=J(e);return`${K({dimension:e.dimension,window:e.window})} ${q(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ke(){let t=e(),r=n(),[s,c]=z(!1),[d,p]=z(null),[m,_]=z(null),[x,C]=z(null),[w,A]=z(null),j=t.data??[],M=j.filter(e=>e.revokedAt===null),N=t.isLoading?`Reading issued keys…`:j.length===0?`No keys exist, so nothing can call this gateway yet.`:`${M.length} active key${M.length===1?``:`s`} of ${j.length} ever issued.`;return H(B,{children:[V(v,{legend:`Keys`,title:`Gateway API keys`,summary:N,actions:H(f,{type:`button`,$variant:`primary`,onClick:()=>c(!0),children:[V(S,{}),`Create a key`]})}),V(P,{legend:`Issued keys`,meta:`${j.length}`,flush:!0,children:t.isError?V(E,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?V(`div`,{style:{padding:12},children:V(D,{rows:4})}):j.length===0?V(O,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:V(f,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>c(!0),children:`Create a key`})}):V(o,{children:H(ee,{children:[V(`thead`,{children:H(`tr`,{children:[V(L,{children:`Label`}),V(L,{children:`Prefix`}),V(L,{children:`Allowed models`}),V(L,{$align:`right`,children:`Limits`}),V(L,{$align:`right`,children:`Created`}),V(L,{children:`Body capture`}),V(L,{children:`Status`}),V(L,{})]})}),V(`tbody`,{children:j.map(e=>{let t=x===e.id,n=ie(e.limitUsage);return H(R,{children:[H(F,{children:[V(I,{children:V(u,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),H(I,{$mono:!0,children:[e.prefix,`…`]}),V(I,{children:e.modelAllowlist===null?V(a,{children:`every model`}):e.modelAllowlist.length===0?V(k,{$tone:`down`,children:`no models`}):V(we,{children:e.modelAllowlist.map(e=>V(k,{children:e},e))})}),V(I,{$align:`right`,children:e.limits===null?V(k,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?V(a,{children:`no limits`}):H(De,{children:[H(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),V(Ee,{children:Oe(n)})]})}),V(I,{$align:`right`,$mono:!0,children:T(e.createdAt)}),V(I,{children:e.bodyLoggingOptOut?V(k,{children:`no bodies`}):V(a,{children:`—`})}),V(I,{children:e.revokedAt===null?V(k,{$tone:`ok`,children:`active`}):V(Te,{title:T(e.revokedAt),children:V(k,{children:`revoked`})})}),V(I,{$align:`right`,children:H(l,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:V(i,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} limits for ${e.label}`,title:`${t?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>C(t?null:e.id),children:V(t?b:y,{})}),e.revokedAt===null?H(B,{children:[V(i,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>_(e),children:V(te,{})}),V(i,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>p(e),children:V(h,{})}),V(f,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>A(e),children:`Revoke`})]}):null]})})]}),t?V(F,{children:V(I,{colSpan:8,children:V(ve,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),V(Ce,{open:s,onOpenChange:c}),V(le,{apiKey:d,onOpenChange:e=>{e||p(null)}},d?.id??`none`),V(me,{apiKey:m,onOpenChange:e=>{e||_(null)}},m?.id??`none`),V(g,{open:w!==null,onOpenChange:e=>{e||A(null)},title:`Revoke key`,body:w===null?``:`Revoking "${w.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:()=>{w!==null&&r.mutate(w.id,{onSettled:()=>A(null)})}})]})}var Ae=ke;export{Ae as component};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import{C as e,D as t,et as n,g as r,it as i,j as a,n as ee,ot as o,rt as s,s as te,st as c,tt as ne,ut as re}from"./queries-DuSqKybM.js";import{a as l,s as ie,t as ae}from"./Rack-V32CHmN6.js";import{n as u,r as d,t as f}from"./TokenBreakdown-B2_gfuqt.js";import{A as oe,D as p,I as m,O as h,P as g,a as se,f as _,g as v,h as y,j as b,k as x,n as S,p as C,r as w,t as T}from"./States-CauIsA0N.js";import{n as ce,t as E}from"./Chip-BltJSw8A.js";import{i as D,n as O}from"./Field-DTQ2LPzA.js";import{t as k}from"./Panel-CQVz9yeR.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
|
+
font-size: 12px;
|
|
3
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
4
|
+
max-width: 62ch;
|
|
5
|
+
`,H=R(V)`
|
|
6
|
+
border-left: 2px solid ${({theme:e})=>e.color.ruleStrong};
|
|
7
|
+
padding-left: ${({theme:e})=>e.space(2)};
|
|
8
|
+
`,U=R.h4`
|
|
9
|
+
font-size: 11px;
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
letter-spacing: 0.12em;
|
|
12
|
+
text-transform: uppercase;
|
|
13
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
14
|
+
margin: 0;
|
|
15
|
+
`,W=R.figcaption`
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
19
|
+
flex-wrap: wrap;
|
|
20
|
+
margin-bottom: 4px;
|
|
21
|
+
`,G=R.figure`
|
|
22
|
+
margin: 0;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
`,K=R.pre`
|
|
25
|
+
margin: 0;
|
|
26
|
+
padding: ${({theme:e})=>e.space(2)};
|
|
27
|
+
max-height: 260px;
|
|
28
|
+
overflow: auto;
|
|
29
|
+
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
30
|
+
border-radius: ${({theme:e})=>e.radius.control};
|
|
31
|
+
background: ${({theme:e})=>e.color.panelSunk};
|
|
32
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
+
font-size: 11.5px;
|
|
34
|
+
line-height: 1.5;
|
|
35
|
+
white-space: pre-wrap;
|
|
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:e}){return L(o,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[L(n,{as:`h3`,children:[`Attempt `,e.attempt,` · `,e.provider]}),e.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request sent to the provider`,stage:`post-RTK`,value:e.request}),I(J,{title:`Response from the provider`,value:e.response}),e.streamChunks===null?null:I(J,{title:`Raw stream frames (${h(e.streamChunks.length)})`,value:e.streamChunks})]})}function X({body:e}){let t=e.artifact;if(t===null){let t=z[e.detailState===`ready`?`corrupt`:e.detailState];return L(o,{$gap:1,children:[I(n,{children:t.legend}),I(V,{children:t.message})]})}return L(o,{$gap:3,children:[t.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(o,{$gap:2,children:[L(s,{$gap:2,$wrap:!0,children:[I(n,{as:`h3`,children:`Client`}),t.client.truncated?I(E,{$tone:`warn`,children:`truncated`}):null]}),I(J,{title:`Request from the client`,stage:`pre-RTK`,value:t.client.request}),I(J,{title:`Response returned to the client`,value:t.client.response})]}),t.attempts.map(e=>I(Y,{attempt:e},`${e.attempt}-${e.provider}`)),t.error===null||t.error===void 0?null:I(J,{title:`Error`,value:t.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(S,{error:t.error,onRetry:()=>void t.refetch()}):t.isPending?I(w,{rows:3}):I(X,{body:t.data})})}var fe=[50,100,250,500],pe=R(s)`
|
|
38
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
39
|
+
flex-wrap: wrap;
|
|
40
|
+
`,me=R(O)`
|
|
41
|
+
width: 220px;
|
|
42
|
+
`,Z=R(D)`
|
|
43
|
+
width: auto;
|
|
44
|
+
`,Q=R(k)`
|
|
45
|
+
flex: 1;
|
|
46
|
+
min-height: 0;
|
|
47
|
+
|
|
48
|
+
> div {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex: 1;
|
|
51
|
+
flex-direction: column;
|
|
52
|
+
min-height: 0;
|
|
53
|
+
}
|
|
54
|
+
`,he=R(i)`
|
|
55
|
+
flex: 1;
|
|
56
|
+
min-height: 0;
|
|
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,...C(e)?{"aria-label":`processing`}:{title:d(e)},children:C(e)?I(f,{}):I(u,{tokens:e})})}var ve=R.dl`
|
|
59
|
+
display: grid;
|
|
60
|
+
grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
|
|
61
|
+
gap: 6px ${({theme:e})=>e.space(3)};
|
|
62
|
+
margin: 0;
|
|
63
|
+
font-size: 12.5px;
|
|
64
|
+
`,$=R.dd`
|
|
65
|
+
margin: 0;
|
|
66
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
67
|
+
word-break: break-all;
|
|
68
|
+
`;function ye(){let{cadence:i,live:a}=l(),[u,d]=P(100),[f,D]=P(`all`),[O,k]=P(``),[M,R]=P(null),z=t(u,i(ee,`res:logs`)),B=r(),V=e(),H=te(),U=(z.data??[]).some(C),W=ge(a&&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=>f===`failed`&&!_(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(_).length,X=(z.data??[]).filter(C).length;return L(F,{children:[I(ae,{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:f,"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:u,"aria-label":`How many requests to fetch`,onChange:e=>d(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(S,{error:z.error,onRetry:()=>void z.refetch()}):z.isLoading?I(`div`,{style:{padding:12},children:I(w,{rows:8})}):J.length===0?I(T,{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(e=>L(le,{$selectable:!0,onClick:()=>R(e),children:[I(A,{children:I(se,{state:v(e),label:y(e)})}),I(A,{$align:`right`,$mono:!0,title:x(e.at),children:p(e.at)}),I(A,{$mono:!0,children:I(c,{style:{display:`block`,maxWidth:`20ch`},children:e.requestedModel||`—`})}),I(A,{children:e.resolvedProvider===null?I(n,{children:C(e)?`routing…`:`not routed`}):L(s,{$gap:1,children:[I(ce,{provider:e.resolvedProvider}),I(ne,{$dim:!0,children:e.resolvedModel??`—`})]})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`18ch`},children:e.credentialId===null?`—`:G.get(e.credentialId)??m(e.credentialId)})}),I(A,{children:I(c,{style:{display:`block`,maxWidth:`16ch`},title:e.apiKeyId??void 0,children:e.apiKeyId===null?`—`:K.get(e.apiKeyId)??m(e.apiKeyId)})}),I(A,{$align:`right`,$mono:!0,children:C(e)?`—`:e.attempts}),I(A,{$align:`right`,$mono:!0,children:C(e)?`—`:b(e.ttftMs)}),I(A,{$align:`right`,$mono:!0,children:C(e)?oe(Math.max(0,W-e.at)):b(e.durationMs)}),I(_e,{log:e}),I(A,{$align:`right`,$mono:!0,children:C(e)?`—`:g(e.costUsd)}),I(A,{children:C(e)?I(E,{$tone:`accent`,children:`live`}):e.errorCode===null?I(E,{$tone:`ok`,children:e.status}):I(E,{$tone:`down`,children:e.errorCode})})]},e.id))})]})})}),I(ie,{open:M!==null,onOpenChange:e=>{e||R(null)},title:`Request detail`,width:`760px`,footer:I(re,{type:`button`,onClick:()=>R(null),children:`Close`}),children:M===null?null:L(o,{$gap:3,children:[L(ve,{children:[I(n,{as:`dt`,children:`Request id`}),I($,{children:M.id}),I(n,{as:`dt`,children:`At`}),I($,{children:x(M.at)}),I(n,{as:`dt`,children:`Requested model`}),I($,{children:M.requestedModel||`—`}),I(n,{as:`dt`,children:`Routed to`}),I($,{children:C(M)?`—`:M.resolvedProvider===null?`not routed`:`${M.resolvedProvider} · ${M.resolvedModel??`—`}`}),I(n,{as:`dt`,children:`Account`}),I($,{children:M.credentialId===null?`—`:G.get(M.credentialId)??M.credentialId}),I(n,{as:`dt`,children:`Key`}),I($,{children:M.apiKeyId===null?`—`:K.get(M.apiKeyId)??M.apiKeyId}),I(n,{as:`dt`,children:`Attempts`}),I($,{children:C(M)?`—`:M.attempts}),I(n,{as:`dt`,children:`Status`}),I($,{children:C(M)?`in flight`:M.errorCode===null?M.status:`${M.status} ${M.errorCode}`}),I(n,{as:`dt`,children:`Timing`}),I($,{children:C(M)?`—`:`first token ${b(M.ttftMs)} · total ${b(M.durationMs)}`}),I(n,{as:`dt`,children:`Tokens`}),I($,{children:C(M)?`—`:L(F,{children:[h(M.inputTokens),` in · `,h(M.outputTokens),` out ·`,` `,h(M.cacheReadTokens),` cache read ·`,` `,h(M.cacheWriteTokens),` cache write`]})}),I(n,{as:`dt`,children:`Cost`}),I($,{children:C(M)?`—`:g(M.costUsd)}),I(n,{as:`dt`,children:`RTK compression`}),I($,{children:C(M)?`—`:M.rtkApplied?`${h(M.rtkFilterHits)} hits · ${h(M.rtkOriginalCodeUnits)} → ${h(M.rtkCompressedCodeUnits)} code units · ~${h(M.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),I(n,{as:`dt`,children:`RTK filters`}),I($,{children:M.rtkFilters.length===0?`—`:M.rtkFilters.join(`, `)})]}),M.degradations.length===0?null:L(o,{$gap:1,children:[I(n,{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};
|