omnigateway 0.13.7 → 0.14.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.
@@ -1,39 +0,0 @@
1
- import{_ as e,i as t,y as n}from"./shared-DDpLUhCp.js";import{$ as r,$t as i,F as a,I as o,K as ee,L as s,V as te,W as ne,at as re,et as ie,g as c,it as ae,j as l,l as oe,nt as u,ot as d,r as f,rt as se,tt as p,u as ce}from"./Lamp-Dk9XrTCg.js";import{A as m,C as h,S as g,T as _,b as v,k as y,o as le,r as ue,s as de,x as b,y as x}from"./Panel-CsovmtxF.js";import{D as fe,i as pe,t as me,x as S}from"./Rack-CDUOJkS2.js";import{a as he,i as ge,n as _e,r as ve,t as ye}from"./RequestTable-i3TtCB9m.js";import{t as C}from"./chevron-down-Bb5ZGvwk.js";import{t as w}from"./chevron-right-hwF5mD6-.js";import{i as T,r as E}from"./index-BYDVTknB.js";import{i as be}from"./Field-DG1317zr.js";import{t as D}from"./Meter-stpt3vQu.js";import{i as O,n as k,r as A,t as j}from"./Table-CVDZ69Zx.js";import{n as xe,r as M}from"./WindowChart-Bqbl-KFO.js";import{i as N,n as P,r as Se,t as Ce}from"./SummaryDeck-DrzTQQo5.js";import{Fragment as we,useMemo as F,useState as I}from"react";import{Fragment as Te,jsx as L,jsxs as R}from"react/jsx-runtime";import z from"styled-components";var B=z.div`
2
- display: grid;
3
- grid-template-areas:
4
- "chassis"
5
- "main";
6
- grid-template-columns: minmax(0, 1fr);
7
- grid-template-rows: auto minmax(0, 1fr);
8
- height: 100vh;
9
- min-height: 0;
10
- overflow: hidden;
11
- `,V=z.main`
12
- grid-area: main;
13
- padding: ${({theme:e})=>e.space(4)};
14
- display: flex;
15
- flex-direction: column;
16
- gap: ${({theme:e})=>e.space(4)};
17
- min-width: 0;
18
- min-height: 0;
19
- overflow-y: auto;
20
-
21
- @media (max-width: 720px) {
22
- padding: ${({theme:e})=>e.space(3)};
23
- }
24
- `;function H({children:e}){let{cadence:t}=fe(),n=p(),r=u(200,t(1e4,`res:logs`));return R(B,{"data-testid":`client-shell`,children:[L(S,{logs:r.data??[],logsFailed:r.isError,signOut:{pending:n.isPending,run:()=>{n.mutate(void 0,{onSuccess:()=>window.location.assign(`/login`)})}}}),L(V,{children:e})]})}var U=[20,50,100,250],Ee={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function De({reading:e}){let t=e.window===null?`concurrent requests`:`${e.dimension} ${Ee[e.window]??e.window}`,n=e.dimension===`spend`?s:l,r=e.used===null?null:e.limit===0?1:e.used/e.limit;return R(O,{children:[L(k,{children:t}),L(k,{$align:`right`,$mono:!0,children:e.used===null?L(b,{children:`unknown`}):n(e.used)}),L(k,{$align:`right`,$mono:!0,children:n(e.limit)}),L(k,{children:r===null?null:L(D,{fraction:r,label:`${t}, ${Math.round(Math.min(1,r)*100)}% used`})})]})}function Oe(e){return{observedAt:e.observedAt,windowType:e.windowType,windowMs:e.windowMs,resetsAt:e.resetsAt,usedRatio:e.usedRatio}}function W(e){return{stale:e.stale,rolledOver:e.rolledOver,estimateStale:e.stale||e.rolledOver,survives:e.survives,exhaustsAt:e.exhaustsAt}}var G=z.div`
25
- display: flex;
26
- flex-direction: column;
27
- gap: 4px;
28
- `,K=z.div`
29
- display: grid;
30
- /* Bar, figure, legend — the accounts page's own three columns, so the two
31
- screens read the same way and the legends stay aligned down the stack. */
32
- grid-template-columns: 96px 34px 1fr;
33
- align-items: center;
34
- min-width: 208px;
35
- gap: 6px;
36
- `,q=z(v)`
37
- font-size: 11px;
38
- text-align: right;
39
- `;function ke({windows:e,open:t,onToggle:n}){let r=e[0],i=e.filter(e=>e.usedRatio!==null);return R(O,{children:[L(k,{children:r.label}),L(k,{children:i.length===0?L(b,{children:`unknown`}):L(G,{children:i.map(e=>R(K,{children:[L(D,{fraction:e.usedRatio,label:`${e.label} ${e.windowType} window, ${Math.round(e.usedRatio*100)}% used`}),L(q,{children:a(e.usedRatio,0)}),L(x,{children:c(e,W(e),Date.now(),o)})]},e.windowType))})}),L(k,{$align:`right`,children:L(m,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} quota history for ${r.label}`,title:`${t?`Hide`:`Show`} quota history for ${r.label}`,onClick:n,children:L(t?C:w,{})})})]})}function J(){let{cadence:o,live:c}=fe(),[u,p]=I(`24h`),[m,S]=I(he),[C,w]=I(U[0]),[T,E]=I(null),[D,z]=I(null),B=e(u),V=r().data??null,H=F(()=>B.grain===`daily`?n(Date.now()-B.ms,V):Math.floor((Date.now()-B.ms)/6e4)*6e4,[B,V]),Ee=F(()=>H+B.ms,[H,B]),W=re(),G={since:H,grain:B.grain},K=d({...G,groupBy:B.by},o(6e4,`res:usage`)),q=d({...G,groupBy:`model`},o(6e4,`res:usage`)),J=ie(m,C,o(te,`res:logs`)),Ae=!ne(J.data),je=i(ee.clientLogPages(m,C)),Y=se(6e4),X=Y.data??[],Me=F(()=>{let e=new Map;for(let t of X){let n=e.get(t.provider)??new Map,r=n.get(t.credentialId);r===void 0?n.set(t.credentialId,[t]):r.push(t),e.set(t.provider,n)}return[...e.entries()].map(([e,t])=>[e,[...t.entries()].map(([e,t])=>({credentialId:e,windows:[...t].sort((e,t)=>f[e.windowType]-f[t.windowType])}))])},[X]),Z=X.map(e=>M(Oe(e))).filter(e=>e!==null),Ne=Z.length===0?0:Math.floor(Math.min(...Z)/6e4)*6e4,Pe=ae({since:Ne},D!==null&&Z.length>0),Q=F(()=>(J.data?.pages??[]).flatMap(e=>e.logs),[J.data?.pages]),Fe=ve(c&&Q.some(ce)),Ie=Q.filter(oe).length,$=K.data??[],Le=$.reduce((e,t)=>e+t.requests,0),Re=$.reduce((e,t)=>e+t.costUsd,0);return R(_,{$gap:4,children:[L(me,{legend:`Client`,title:`Your usage`,summary:K.isLoading?`Reading your usage…`:`${l(Le)} requests and ${s(Re)} over the last ${B.label}.`,actions:L(P,{children:t.map(e=>L(Se,{type:`button`,$size:`sm`,$on:e.id===u,"aria-pressed":e.id===u,onClick:()=>p(e.id),children:e.id},e.id))})}),L(ue,{legend:`Your key`,meta:W.data===void 0?void 0:R(v,{$dim:!0,children:[W.data.prefix,`…`]}),children:W.isPending?L(de,{rows:2}):W.isError?L(le,{legend:`Could not read your key`,error:W.error}):R(_,{$gap:2,children:[R(g,{$gap:2,$wrap:!0,children:[L(x,{children:W.data.label}),W.data.bodyLoggingOptOut?L(b,{children:`Request bodies are never stored for this key.`}):null]}),W.data.modelAllowlist===null?L(b,{children:`Every model this gateway serves.`}):W.data.modelAllowlist.length===0?L(b,{children:`No models. This key cannot serve a request.`}):L(g,{$gap:1,$wrap:!0,children:W.data.modelAllowlist.map(e=>L(v,{children:e},e))})]})}),L(Ce,{buckets:$,since:H,until:Ee,by:B.by,rangeLabel:B.label,dayOffsetMinutes:V}),L(N,{legend:`By model`,meta:B.label,query:{isLoading:q.isLoading,isError:q.isError,error:q.error,refetch:()=>void q.refetch()},failure:`Could not read usage`,empty:{legend:`No traffic`,message:`Nothing served in this window.`},isEmpty:(q.data??[]).length===0,children:L(h,{children:R(j,{children:[L(`thead`,{children:R(`tr`,{children:[L(A,{children:`Model`}),L(A,{$align:`right`,children:`Requests`}),L(A,{$align:`right`,children:`Tokens`}),L(A,{$align:`right`,children:`Spend`})]})}),L(`tbody`,{children:(q.data??[]).map(e=>R(O,{children:[L(k,{$mono:!0,children:e.key}),L(k,{$align:`right`,$mono:!0,children:l(e.requests)}),L(k,{$align:`right`,$mono:!0,children:l(e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheWriteTokens)}),L(k,{$align:`right`,$mono:!0,children:s(e.costUsd)})]},e.key))})]})})}),L(N,{legend:`Your limits`,query:{isLoading:W.isLoading,isError:W.isError,error:W.error,refetch:()=>void W.refetch()},failure:`Could not read your limits`,empty:W.data?.limits===null?{legend:`Limits unreadable`,message:`This key's limits could not be read. Requests are refused until an operator repairs it.`}:{legend:`No limits`,message:`This key is not rate limited.`},isEmpty:W.data?.limits===null||(W.data?.limitUsage.length??0)===0,footer:L(b,{children:`Counted from completed requests, so a burst in flight right now may not be included yet.`}),children:L(h,{children:R(j,{children:[L(`thead`,{children:R(`tr`,{children:[L(A,{children:`Limit`}),L(A,{$align:`right`,children:`Used`}),L(A,{$align:`right`,children:`Ceiling`}),L(A,{$width:`30%`,children:`Consumption`})]})}),L(`tbody`,{children:(W.data?.limitUsage??[]).map(e=>L(De,{reading:e},`${e.dimension}:${e.window??`gauge`}`))})]})})}),L(N,{legend:`Provider headroom`,query:{isLoading:Y.isLoading,isError:Y.isError,error:Y.error,refetch:()=>void Y.refetch()},failure:`Could not read provider headroom`,empty:{legend:`No data`,message:`No provider has reported a usage window.`},isEmpty:X.length===0,footer:L(b,{children:`What each account serving this gateway has left. A request is served by whichever account of a provider can take it.`}),children:L(_,{$gap:4,children:Me.map(([e,t])=>R(_,{$gap:1,children:[L(x,{children:e}),L(h,{children:R(j,{children:[L(`thead`,{children:R(`tr`,{children:[L(A,{children:`Account`}),L(A,{$width:`60%`,children:`Quota`}),L(A,{})]})}),L(`tbody`,{children:t.map(({credentialId:e,windows:t})=>R(we,{children:[L(ke,{windows:t,open:D===e,onToggle:()=>z(D===e?null:e)}),D===e?L(O,{children:L(k,{colSpan:3,children:L(_,{$gap:4,children:t.map(e=>{let t=Oe(e),n=M(t),r=(Pe.data?.samples??[]).filter(t=>t.credentialId===e.credentialId&&t.windowType===e.windowType&&t.observedAt>=(n??0));return L(xe,{live:t,samples:r.map(e=>({observedAt:e.observedAt,windowType:e.windowType,windowMs:e.windowMs,resetsAt:e.resetsAt,usedRatio:e.usedRatio})),since:n,now:Date.now(),truncated:Pe.data?.truncated===!0&&n!==null&&r.length>0&&(r[0]?.observedAt??0)>n,ratePerHourRatio:e.ratePerHourRatio,exhaustsAt:e.exhaustsAt,survives:e.survives,stale:e.stale,rolledOver:e.rolledOver,spent:e.usedRatio===null?`no ceiling reported`:`${a(e.usedRatio,0)} used`,rateText:e.ratePerHourRatio===null?`unknown`:`${a(e.ratePerHourRatio,1)}/h`},e.windowType)})})})}):null]},e))})]})})]},e))})}),L(N,{legend:`Recent requests`,meta:`${Q.length} shown`,actions:R(P,{children:[L(ge,{filters:m,onChange:S}),L(be,{value:C,"aria-label":`How many requests per page`,style:{width:`auto`},onChange:e=>w(Number(e.target.value)),children:U.map(e=>R(`option`,{value:e,children:[e,` per page`]},e))})]}),query:{isLoading:J.isLoading,isError:J.isError,error:J.error,refetch:()=>void J.refetch()},failure:`Could not read your requests`,empty:{legend:`No requests`,message:Object.keys(m).length===0?`Nothing served through this key yet.`:`No request served through this key matches these filters.`},isEmpty:Q.length===0,footer:R(g,{$gap:2,$wrap:!0,children:[R(b,{children:[l(Ie),` of the `,l(Q.length),` loaded failed.`]}),J.hasNextPage?L(y,{type:`button`,$size:`sm`,disabled:J.isFetchingNextPage,onClick:()=>void J.fetchNextPage(),children:J.isFetchingNextPage?`Loading…`:`Load older`}):null,Ae?R(Te,{children:[L(b,{children:`Live updates are paused while older pages are loaded.`}),L(y,{type:`button`,$size:`sm`,onClick:je,children:`Back to live`})]}):null]}),children:L(h,{children:L(_e,{rows:Q,now:Fe,onOpen:E})})}),L(pe,{open:T!==null,onOpenChange:e=>{e||E(null)},title:`Request detail`,width:`640px`,footer:L(y,{type:`button`,onClick:()=>E(null),children:`Close`}),children:T===null?null:L(ye,{log:T})})]})}var Ae=()=>L(E,{children:L(T,{children:L(H,{children:L(J,{})})})});export{Ae as component};