omnigateway 0.15.3 → 0.15.4
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 +90 -6
- package/bin/omni.js +218 -190
- package/gateway.js +390 -338
- package/package.json +1 -1
- package/public/assets/_app-kgxk7ake.js +1 -0
- package/public/assets/_app.accounts-3jabfvcs.js +1 -0
- package/public/assets/_app.console-y69399jc.js +1 -0
- package/public/assets/_app.database-r5kg3838.js +1 -0
- package/public/assets/_app.index-22awhb38.js +1 -0
- package/public/assets/_app.keys-7vh81n1w.js +1 -0
- package/public/assets/_app.logs-rssv5a6z.js +1 -0
- package/public/assets/_app.models-82m2f0kr.js +1 -0
- package/public/assets/_app.plugins.$pluginId-e4xva5tz.js +1 -0
- package/public/assets/_app.settings-fqzg7wnn.js +1 -0
- package/public/assets/_app.usage-32vje0s7.js +1 -0
- package/public/assets/client-d3mjj5ey.js +1 -0
- package/public/assets/index-0j7sghrn.js +2 -0
- package/public/assets/index-4dz4bgrb.js +2 -0
- package/public/assets/index-85cnhw3e.js +2 -0
- package/public/assets/index-8bewp9z1.js +6 -0
- package/public/assets/index-938qd7p2.js +2 -0
- package/public/assets/index-d09hs7ex.js +2 -0
- package/public/assets/index-d0t1fj1y.js +2 -0
- package/public/assets/index-dq2f7yk0.js +2 -0
- package/public/assets/index-f7t0kve8.js +2 -0
- package/public/assets/index-fcew0gga.js +2 -0
- package/public/assets/index-h3nb7n4d.css +1 -0
- package/public/assets/index-hk28xepa.js +2 -0
- package/public/assets/index-nnpqs2w6.js +2 -0
- package/public/assets/index-p9vbm21a.js +46 -0
- package/public/assets/index-sbe0ydnc.js +2 -0
- package/public/assets/index-t1cs42r4.js +2 -0
- package/public/assets/index-v31xha7b.js +2 -0
- package/public/assets/index-wjqdtafp.js +2 -0
- package/public/assets/index-xdyjb1an.js +2 -0
- package/public/assets/index-z7c4qz9d.js +54 -0
- package/public/assets/index-zkt5p0qd.js +2 -0
- package/public/assets/login-p97b96t9.js +1 -0
- package/public/index.html +5 -13
- package/public/shared/chunks/react-e7vf2dk6.js +2 -0
- package/public/shared/chunks/react-mv7wrde1.js +2 -0
- package/public/shared/chunks/react-ybbhws22.js +2 -0
- package/public/shared/chunks/react-z0w6knjn.js +2 -0
- package/public/shared/dashboard-sdk.js +1 -1
- package/public/shared/jsx-runtime.js +1 -1
- package/public/shared/react-dom-client.js +9 -9
- package/public/shared/react-dom.js +1 -1
- package/public/shared/react-query.js +1 -1
- package/public/shared/react.js +1 -1
- package/public/shared/styled-components.js +5 -6
- package/public/assets/Chip-B2iXmJJC.js +0 -37
- package/public/assets/CopyValue-CWSTp4v8.js +0 -27
- package/public/assets/Field-CUEEy19T.js +0 -60
- package/public/assets/Lamp-CL0i4yaa.js +0 -26
- package/public/assets/Meter-stpt3vQu.js +0 -14
- package/public/assets/Panel-CsovmtxF.js +0 -225
- package/public/assets/Rack-1lijWt5h.js +0 -483
- package/public/assets/Readout-DlT5oxGO.js +0 -31
- package/public/assets/RequestTable-uRTmuPwB.js +0 -93
- package/public/assets/Select-C0c13SKD.js +0 -141
- package/public/assets/SummaryDeck-DnQnRmQ8.js +0 -15
- package/public/assets/Table-CVDZ69Zx.js +0 -38
- package/public/assets/Toggle-BvVa_jla.js +0 -39
- package/public/assets/TokenBreakdown-B8cSaOOr.js +0 -32
- package/public/assets/WindowChart-CaPUJ4GJ.js +0 -11
- package/public/assets/_app-CSru2YTE.js +0 -1
- package/public/assets/_app.accounts-DmJhe6QV.js +0 -70
- package/public/assets/_app.console-DQlcBpSu.js +0 -24
- package/public/assets/_app.database-DoDu8HOG.js +0 -24
- package/public/assets/_app.index-BEeD4XSS.js +0 -67
- package/public/assets/_app.keys-MXvgkBUB.js +0 -120
- package/public/assets/_app.logs-CjUjeVHg.js +0 -46
- package/public/assets/_app.models-mNIL-1oS.js +0 -148
- package/public/assets/_app.plugins._pluginId-CsJXQg6X.js +0 -20
- package/public/assets/_app.settings-CYMwWA8D.js +0 -88
- package/public/assets/_app.usage-Dd33vB8x.js +0 -78
- package/public/assets/chevron-right-ocqzquMZ.js +0 -1
- package/public/assets/client-KUNw8ZtZ.js +0 -48
- package/public/assets/index-B9izdV6t.js +0 -14
- package/public/assets/index-Co2s5xMk.css +0 -1
- package/public/assets/limits-iRyDMg04.js +0 -1
- package/public/assets/login-DrbTJF6e.js +0 -45
- package/public/assets/plus-D_lvSfDL.js +0 -1
- package/public/assets/preload-helper-1xe0b53X.js +0 -1
- package/public/assets/reasons-Du1OBWAM.js +0 -1
- package/public/assets/rotate-ccw-CwTftDdz.js +0 -1
- package/public/assets/shared-HVgLEGgl.js +0 -77
- package/public/assets/trash-CmuxOGpN.js +0 -1
- package/public/shared/chunks/jsx-runtime-CznXPbDH.js +0 -1
- package/public/shared/chunks/react-DK6rpPfu.js +0 -1
- package/public/shared/chunks/react-dom-Wr82bmbV.js +0 -1
- package/public/shared/chunks/rolldown-runtime-CbXtAM7H.js +0 -1
- /package/public/assets/{archivo-latin-ext-standard-normal-7khWdh9v.woff2 → archivo-latin-ext-standard-normal-5717f37059660ca5.woff2} +0 -0
- /package/public/assets/{archivo-latin-standard-normal-DY7AcnAa.woff2 → archivo-latin-standard-normal-e3a28eade21a900c.woff2} +0 -0
- /package/public/assets/{archivo-vietnamese-standard-normal-rJmnGBSt.woff2 → archivo-vietnamese-standard-normal-332e6f66de84927c.woff2} +0 -0
- /package/public/assets/{spline-sans-mono-latin-ext-wght-normal-Dh0aNLWd.woff2 → spline-sans-mono-latin-ext-wght-normal-0ca9a3989044d1f9.woff2} +0 -0
- /package/public/assets/{spline-sans-mono-latin-wght-normal-DlaB5ohX.woff2 → spline-sans-mono-latin-wght-normal-46b7dcafe3e51dbe.woff2} +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j,x,f}from"/assets/index-p9vbm21a.js";import{jsx as o}from"react/jsx-runtime";function i({error:r}){let e=j();return o(f,{legend:"Console unavailable",children:o(x,{legend:"The gateway did not answer",error:r,onRetry:()=>void e.invalidate()})})}export{i as errorComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,P,t,d,o,r,Q,fe,z,pe,Xt,Oo,H,he,ln,un,cn,dn,fn,pn,Rn,Pn,An,Tn,i,a,N,_e,_r,wt,it,bo,Nn,Ct,rr,qr,nr,qe,X,oe,ge,I,h,x,b,J,ee,k,f}from"/assets/index-p9vbm21a.js";import{$e,R}from"/assets/index-f7t0kve8.js";import{W}from"/assets/index-dq2f7yk0.js";import{C}from"/assets/index-fcew0gga.js";import{v,m,de}from"/assets/index-8bewp9z1.js";import{re}from"/assets/index-wjqdtafp.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{xr}from"/assets/index-v31xha7b.js";import"/assets/index-z7c4qz9d.js";import{$t,wr,Kn}from"/assets/index-938qd7p2.js";import{br}from"/assets/index-85cnhw3e.js";import{Qe}from"/assets/index-0j7sghrn.js";import{Le}from"/assets/index-zkt5p0qd.js";import{xt}from"/assets/index-nnpqs2w6.js";var et={name:"external-link",size:24,node:[["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"}]]};et.node;var tt=i(et);var ot={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]};ot.node;var nt=i(ot);var at={name:"refresh-cw",size:24,node:[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]};at.node;var Xe=i(at);import{Fragment as At,useState as ke}from"react";import be from"styled-components";import{useCallback as rt,useEffect as lt,useState as le}from"react";import Ye from"styled-components";import{jsx as T,jsxs as me,Fragment as je}from"react/jsx-runtime";function Je(u){return u?.authTypes??[]}function st(u){return Je(u).includes("oauth")?"oauth":"apiKey"}function dt(u){return u[0]?.id??"anthropic"}var vt={oauth:"Authorize in the browser",apiKey:"Paste an API key"};function kt(u){let A=u?.callback;return A===void 0?"code#state":`${A.uri}?code=…`}var It=Ye.ol.withConfig({displayName:"ConnectDialog__Step"})(["display:flex;flex-direction:column;gap:",";"],({theme:u})=>u.space(3)),St=Ye.div.withConfig({displayName:"ConnectDialog__Code"})(["font-family:",";font-size:26px;letter-spacing:0.22em;text-align:center;padding:",";background:",";border:1px solid ",";border-radius:",";"],({theme:u})=>u.font.mono,({theme:u})=>u.space(3),({theme:u})=>u.color.panelSunk,({theme:u})=>u.color.ruleStrong,({theme:u})=>u.radius.control),ut=Ye.p.withConfig({displayName:"ConnectDialog__Problem"})(["font-size:12px;color:",";"],({theme:u})=>u.color.down),Pt=Ye.p.withConfig({displayName:"ConnectDialog__Waiting"})(["font-size:12px;color:",";"],({theme:u})=>u.color.inkDim);function ct({open:u,credentials:A,credential:S,onOpenChange:M,onConnected:B}){let Y=fe().data??[],[L,K]=le(()=>S?.provider??dt(Y)),O=z(Y,L),[G,ne]=le(()=>S?.authType??st(z(Y,S?.provider??dt(Y)))),[ie,_]=le(()=>S?.label??"");lt(()=>{if(S)K(S.provider),ne(S.authType),_(S.label)},[S]);let ae=O?.label??L,[D,ze]=le(null),[se,Fe]=le(""),[Pe,Ie]=le(""),Be=(A??[]).filter((g,w,U)=>g.provider==="custom"&&U.findIndex((ce)=>ce.provider==="custom"&&ce.providerData.endpointId===g.providerData.endpointId)===w),[Ne,Re]=le(""),[Ee,xe]=le(""),[ue,Se]=le("chat_completions"),[Ve,Ke]=le(""),[Me,j]=le(null),ye=Rn(),Te=An(),Ae=Pn(),ve=rt(()=>{ze(null),Fe(""),Ie(""),Re(""),xe(""),Se("chat_completions"),Ke(""),j(null),_(""),ye.reset(),Te.reset(),Ae.reset()},[ye,Te,Ae]),we=rt((g)=>{if(!g)ve();M(g)},[M,ve]);lt(()=>{if(D===null||D.kind!=="device")return;let g=!1,w=async()=>{try{let ce=await Tn(D.flowId);if(g)return;if(ce.status==="complete"){ve(),M(!1),B();return}}catch(ce){if(g)return;j(h(ce)),ze(null);return}if(!g)U=setTimeout(()=>void w(),D.pollIntervalMs)},U=setTimeout(()=>void w(),D.pollIntervalMs);return()=>{g=!0,clearTimeout(U)}},[D,B,M,ve]);let He=()=>{if(j(null),G==="apiKey"){Ae.mutate({provider:L,apiKey:Ve,label:ie.trim()||void 0,...L==="custom"?{endpointId:Pe,endpointLabel:Ne,origin:Ee,protocol:ue}:{}},{onSuccess:()=>{ve(),M(!1),B()},onError:(g)=>j(h(g))});return}ye.mutate({provider:L,label:ie.trim().length===0?ae:ie.trim(),...S?{credentialId:S.id}:{}},{onSuccess:(g)=>ze(g),onError:(g)=>j(h(g))})},Ue=()=>{if(D===null)return;j(null),Te.mutate({flowId:D.flowId,code:se.trim()},{onSuccess:()=>{ve(),M(!1),B()},onError:(g)=>j(h(g))})};return T(J,{open:u,onOpenChange:we,title:S?`Reconnect ${S.label}`:"Connect an account",description:"The gateway stores the resulting token encrypted. It is never shown again after this dialog.",footer:D===null?me(je,{children:[T(n,{type:"button",onClick:()=>we(!1),children:"Cancel"}),T(n,{type:"button",$variant:"primary",disabled:ye.isPending||Ae.isPending,onClick:He,children:G==="apiKey"?Ae.isPending?"Adding…":"Add API key":ye.isPending?"Starting…":"Start authorization"})]}):D.kind==="device"?T(n,{type:"button",onClick:()=>we(!1),children:"Cancel"}):me(je,{children:[T(n,{type:"button",onClick:()=>we(!1),children:"Cancel"}),T(n,{type:"button",$variant:"primary",disabled:Te.isPending||se.trim().length===0,onClick:Ue,children:Te.isPending?"Finishing…":"Finish connecting"})]}),children:me(It,{children:[D===null?me(r,{$gap:3,children:[S?null:T(m,{label:"Provider",children:(g)=>T(R,{...g,value:L,options:Y.map((w)=>({value:w.id,label:w.label})),onValueChange:(w)=>{let U=w;K(U),ne(st(z(Y,U)))}})}),S?null:Je(O).length>1?T(m,{label:"How to connect",children:(g)=>T(R,{...g,value:G,options:Je(O).map((w)=>({value:w,label:vt[w]})),onValueChange:(w)=>ne(w)})}):null,L==="custom"?me(je,{children:[Be.length===0?null:T(m,{label:"Existing endpoint",children:(g)=>T(R,{...g,value:Pe,options:[{value:"",label:"Create new endpoint"},...Be.map((w)=>({value:String(w.providerData.endpointId),label:String(w.providerData.endpointLabel)}))],onValueChange:(w)=>{let U=Be.find((ce)=>ce.providerData.endpointId===w);if(U===void 0){Ie(""),Re(""),xe(""),Se("chat_completions");return}Ie(String(U.providerData.endpointId)),Re(String(U.providerData.endpointLabel)),xe(String(U.providerData.origin)+String(U.providerData.basePath??"")),Se(U.providerData.protocol==="responses"?"responses":"chat_completions")}})}),T(m,{label:"Endpoint ID",children:(g)=>T(v,{...g,value:Pe,onChange:(w)=>Ie(w.target.value)})}),T(m,{label:"Endpoint label",children:(g)=>T(v,{...g,value:Ne,onChange:(w)=>Re(w.target.value)})}),T(m,{label:"Server URL",children:(g)=>T(v,{...g,value:Ee,placeholder:"https://server.example/api",onChange:(w)=>xe(w.target.value)})}),Ee.trim().toLowerCase().startsWith("http://")?T(ut,{children:"Plaintext transport sends prompts and API keys without TLS."}):null,T(m,{label:"Protocol",children:(g)=>T(R,{...g,value:ue,options:[{value:"chat_completions",label:"Chat Completions (/v1/chat/completions)"},{value:"responses",label:"Responses (/v1/responses)"}],onValueChange:(w)=>Se(w)})})]}):null,G==="apiKey"?T(m,{label:"API key",children:(g)=>T(v,{...g,type:"password",value:Ve,autoComplete:"off",onChange:(w)=>Ke(w.target.value)})}):null,T(m,{label:"Label",hint:"How this account is named in the rack. Defaults to the provider.",children:(g)=>T(v,{...g,value:ie,placeholder:ae,onChange:(w)=>_(w.target.value)})})]}):me(r,{$gap:3,children:[me(r,{$gap:1,children:[T(t,{children:"Step 1 — authorize"}),T(o,{$gap:2,children:me(n,{as:"a",href:D.authorizeUrl,target:"_blank",rel:"noreferrer noopener",$variant:"primary",$size:"sm",children:[T(tt,{}),"Open ",ae]})}),T(xr,{value:D.authorizeUrl,label:"Copy authorization link"})]}),D.userCode===null?null:me(r,{$gap:1,children:[T(t,{children:"Step 2 — enter this code"}),T(St,{children:D.userCode})]}),D.kind==="device"?me(Pt,{children:[O?.pasteHint??""," Waiting for authorization…"]}):T(m,{label:"Authorization code",hint:O?.pasteHint??"",...Me===null?{}:{problem:Me},children:(g)=>T(v,{...g,value:se,autoFocus:!0,placeholder:kt(O),onChange:(w)=>Fe(w.target.value)})})]}),Me===null||D?.kind==="pkce"?null:T(ut,{children:Me})]})})}import{jsx as Ge}from"react/jsx-runtime";function pt({credentialId:u,windows:A,burn:S,pollIntervalMs:M,now:B}){let Y=A.map((_)=>{let ae=Ct(S,_.windowType);return{window:_,estimate:ae,since:$t(qr(_))}}),L=Y.map((_)=>_.since).filter((_)=>_!==null),K=L.length===0?0:Math.min(...L),O=Oo({credentialId:u,since:K},L.length>0),G=O.data?.samples??[],ne=O.data?.gatewayRates??[],ie=O.data?.truncated===!0;return Ge(r,{$gap:4,children:Y.map((_)=>Ge(Rt,{window:_.window,estimate:_.estimate,since:_.since,samples:G.filter((ae)=>ae.windowType===_.window.windowType&&ae.observedAt>=(_.since??0)),gatewayRate:ne.find((ae)=>ae.windowType===_.window.windowType),truncated:ie,pollIntervalMs:M,now:B},_.window.windowType))})}function Rt({window:u,estimate:A,since:S,samples:M,gatewayRate:B,truncated:Y,pollIntervalMs:L,now:K}){let O=u.limit===null?`${a(u.used)} used`:`${a(u.used)} of ${a(u.limit)} used`,G=_r(u,K),ne=A===void 0||bo(u,K,L)||A.stale&&!G;return Ge(wr,{live:qr(u),samples:M.map(qr),since:S,now:K,truncated:Y&&S!==null&&M.length>0&&(M[0]?.observedAt??0)>S,ratePerHourRatio:Nn(u,A),exhaustsAt:A?.exhaustsAt??null,survives:A?.survives??null,stale:ne,rolledOver:G,spent:O,rateText:A?.ratePerHour===void 0||A.ratePerHour===null?"unknown":`${a(A.ratePerHour)}/h`,extraFact:Ge(Kn,{legend:"This gateway accounts for",value:B?.gatewayRatePerHour===void 0||B.gatewayRatePerHour===null?"unknown":`${a(B.gatewayRatePerHour)} tokens/h`})})}import{jsx as Tt}from"react/jsx-runtime";function ht({credential:u,busy:A,onOpenChange:S,onConfirm:M}){let B=dn(u?.id??null),Y=Date.now(),L=(B.data?.credits??[]).filter((G)=>G.status==="available").sort((G,ne)=>(G.expiresAt??Number.POSITIVE_INFINITY)-(ne.expiresAt??Number.POSITIVE_INFINITY))[0],K=B.isError||B.isFetching?0:B.data?.available??0,O=u===null?"":B.isFetching?"Reading the reset credits this account holds…":B.isError?`Could not read reset credits for "${u.label}".`:K===0?`"${u.label}" has no reset credits available.`:`Spend one of ${K} reset ${K===1?"credit":"credits"} on "${u.label}"? Its usage windows go back to zero at the provider, and the credit cannot be returned.`+(L?.expiresAt==null?"":` The credit spent is the one expiring soonest (${_e(L.expiresAt,Y)}).`);return Tt(ee,{open:u!==null,onOpenChange:S,title:"Reset quota",body:O,confirmLabel:"Spend reset",busy:A||L===void 0||K===0,onConfirm:()=>{if(u!==null&&L!==void 0&&K>0)M(u,L.id)}})}import{jsx as c,jsxs as te,Fragment as qt}from"react/jsx-runtime";var _t=be(f).withConfig({displayName:"AccountsBoard__ProviderModule"})(["border-left:3px solid ",";"],({$provider:u})=>oe(u)),Lt=be(v).withConfig({displayName:"AccountsBoard__LabelInput"})(["width:100%;min-width:140px;height:26px;font-family:",";font-size:12.5px;background:transparent;border-color:transparent;&:hover:not(:disabled),&:focus{background:",";border-color:",";}"],({theme:u})=>u.font.sans,({theme:u})=>u.color.panelSunk,({theme:u})=>u.color.ruleStrong),ft=be(de).withConfig({displayName:"AccountsBoard__Small"})(["width:62px;height:26px;"]),Dt=be.span.withConfig({displayName:"AccountsBoard__Note"})(["display:block;padding-left:9px;font-size:11px;color:",";"],({theme:u})=>u.color.inkDim),Bt=be.div.withConfig({displayName:"AccountsBoard__StatusNote"})(["margin:0 0 10px;min-height:16px;font-size:12px;color:",";"],({theme:u})=>u.color.inkDim),Nt=be.p.withConfig({displayName:"AccountsBoard__StatusLine"})(["margin:0;"]),Et=be.ul.withConfig({displayName:"AccountsBoard__RefreshDetail"})(["margin:4px 0 0;padding-left:16px;list-style:disc;"]),Mt=be.div.withConfig({displayName:"AccountsBoard__QuotaCell"})(["display:grid;grid-template-columns:96px 34px 1fr;align-items:center;min-width:208px;gap:6px;"]),Qt=be(d).withConfig({displayName:"AccountsBoard__Percent"})(["font-size:11px;text-align:right;"]),zt=be.div.withConfig({displayName:"AccountsBoard__QuotaStack"})(["display:flex;flex-direction:column;gap:4px;"]);function Ft(){let u=ln();return{pending:u.isPending,commit:(A,S)=>{u.mutate({id:A,patch:S})}}}function Ht(u,A){if(A===void 0)return" The list of models could not be read, so whether any target is pinned to this account is unknown.";let S=A.filter((M)=>M.targets.some((B)=>B.credentialId===u.id)).map((M)=>M.id);if(S.length===0)return"";return` ${S.length===1?"The model":"The models"} ${S.join(", ")} ${S.length===1?"pins a target":"pin targets"} to this account. Those targets will fail rather than fall back to another account.`}function gt(){let{cadence:u}=X(),A=pe(),S=Xt(u(1e4,"res:credentials")),M=he(),B=H(),Y=fe(),L=pn(),K=cn(),O=fn(),[G,ne]=ke(null),ie=un(),{commit:_}=Ft(),[ae,D]=ke(!1),[ze,se]=ke(null),[Fe,Pe]=ke([]),[Ie,Be]=ke(new Set),[Ne,Re]=ke(!1),[Ee,xe]=ke(null),[ue,Se]=ke(null),[Ve,Ke]=ke(new Set),Me=(p)=>Ke((y)=>{let e=new Set(y);if(!e.delete(p))e.add(p);return e}),j=A.data??[],ye=(p)=>j.find((y)=>y.id===p)?.label??p,Te=(p)=>{let y=p[0];if(p.length===1&&y!==void 0){let F=ye(y.credentialId);return y.kind==="refreshed"||y.kind==="coalesced"?`Quota refreshed for ${F}.`:y.kind==="noData"?`No quota data reported for ${F}.`:y.kind==="cooldown"?`Quota refresh is cooling down for ${F}.`:y.kind==="unsupported"?`${F} does not report quota.`:y.kind==="disabled"?`${F} is disabled, so it was not probed.`:`Quota refresh failed for ${F}.`}let e=p.filter((F)=>F.kind==="refreshed"||F.kind==="coalesced").length,Ce=p.filter((F)=>F.kind==="failed").length,De=p.filter((F)=>F.kind==="cooldown").length,Oe=p.length-e-Ce-De;return[`Refreshed ${e} ${e===1?"account":"accounts"}`,Ce===0?null:`${Ce} failed`,De===0?null:`${De} cooling down`,Oe===0?null:`${Oe} skipped`].filter((F)=>F!==null).join("; ").concat(".")},Ae=(p)=>p.filter((y)=>y.kind==="failed"||y.kind==="cooldown"||y.kind==="noData").map((y)=>`${ye(y.credentialId)}: ${y.kind==="failed"?"failed":y.kind==="cooldown"?"cooling down":"no data reported"}`),ve=async(p)=>{if(se(null),Pe([]),p.kind==="all")Re(!0);else Be((y)=>{let e=new Set(y);return e.add(p.credentialId),e});try{let y=await K.mutateAsync(p);se(Te(y.outcomes)),Pe(y.outcomes.length>1?Ae(y.outcomes):[])}catch(y){se(p.kind==="all"?"Quota refresh could not be started.":`Quota refresh could not be started for ${ye(p.credentialId)}.`)}finally{if(Re(!1),p.kind==="one")Be((y)=>{let e=new Set(y);return e.delete(p.credentialId),e})}},we=Date.now(),He=Y.data??[],Ue=(p)=>z(He,p)?.order??Number.POSITIVE_INFINITY,g=[...new Set(j.map((p)=>p.provider))].sort((p,y)=>Ue(p)-Ue(y)),w=(p)=>z(He,p)?.label??p,U=qe(S.data?.health??[],(p)=>p.credentialId),ce=qe(S.data?.quota??[],(p)=>p.credentialId),mt=qe(S.data?.burn??[],(p)=>p.credentialId),Ze=M.data?.quotaPollIntervalMs??300000,bt=j.filter((p)=>p.enabled).length,yt=A.isLoading?"Reading connected accounts…":j.length===0?"No provider credentials are connected, so every request fails at the router.":`${bt} of ${j.length} accounts are enabled and eligible for routing.`;return te(qt,{children:[c(k,{legend:"Accounts",title:"Provider accounts",summary:yt,actions:te(o,{$gap:1,children:[ie?te(n,{type:"button",$variant:"ghost",disabled:Ne||Ie.size>0,onClick:()=>void ve({kind:"all"}),children:[c(Xe,{}),Ne?"Refreshing quota…":"Refresh all quota"]}):null,te(n,{type:"button",$variant:"primary",onClick:()=>D(!0),children:[c(Qe,{}),"Connect an account"]})]})}),te(Bt,{children:[c(Nt,{role:"status","aria-live":"polite",children:ze??""}),Fe.length===0?null:c(Et,{children:Fe.map((p)=>c("li",{children:p},p))})]}),A.isError?c(f,{legend:"Accounts",children:c(x,{error:A.error,onRetry:()=>void A.refetch()})}):A.isLoading?c(f,{legend:"Accounts",children:c(b,{rows:5})}):j.length===0?c(f,{legend:"Accounts",children:c(I,{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:c(n,{type:"button",$variant:"primary",$size:"sm",onClick:()=>D(!0),children:"Connect an account"})})}):c(r,{$gap:4,children:g.map((p)=>{let y=j.filter((e)=>e.provider===p);return c(_t,{$provider:p,legend:w(p),meta:`${y.length} account${y.length===1?"":"s"}`,flush:!0,children:c(Q,{children:te(q,{children:[c("thead",{children:te("tr",{children:[c(l,{$width:"24%",children:"Account"}),c(l,{$width:"20%",children:"Sign-in"}),c(l,{$align:"right",$width:"86px",children:"Tier"}),c(l,{$align:"right",$width:"94px",children:"Weight"}),c(l,{$align:"center",$width:"86px",children:"Enabled"}),c(l,{$width:"240px",children:"Quota"}),c(l,{$align:"right",$width:"130px",children:"Token expires"}),c(l,{$width:"144px"})]})}),c("tbody",{children:y.map((e)=>{let Ce=wt(U.get(e.id)??[],we,e.enabled,e.disabledReason),De=ce.get(e.id)??[],Oe=mt.get(e.id)??[],F=nr(De),We=Ve.has(e.id);return te(At,{children:[te(E,{children:[te(s,{children:[te(o,{$gap:2,children:[c(ge,{state:Ce.state,label:Ce.note===""?"healthy":Ce.note}),c(Lt,{defaultValue:e.label,"aria-label":`Label for ${e.label}`,onBlur:(Z)=>{let V=Z.target.value.trim();if(V.length===0||V===e.label){Z.target.value=e.label;return}_(e.id,{label:V})}})]}),Ce.note===""?null:c(Dt,{children:Ce.note})]}),c(s,{children:te(o,{$gap:1,children:[c(C,{children:e.authType==="oauth"?"oauth":"api key"}),e.accountEmail===null?null:c(t,{children:e.accountEmail})]})}),c(s,{$align:"right",children:c(ft,{min:1,step:1,defaultValue:e.tier,"aria-label":`Tier for ${e.label}`,onBlur:(Z)=>{let V=Number(Z.target.value);if(!Number.isInteger(V)||V<1||V===e.tier){Z.target.value=String(e.tier);return}_(e.id,{tier:V})}})}),c(s,{$align:"right",children:c(ft,{min:0.1,step:0.1,defaultValue:e.weight,"aria-label":`Weight for ${e.label}`,onBlur:(Z)=>{let V=Number(Z.target.value);if(!Number.isFinite(V)||V<=0||V===e.weight){Z.target.value=String(e.weight);return}_(e.id,{weight:V})}})}),c(s,{$align:"center",children:c(W,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:(Z)=>_(e.id,{enabled:Z})})}),c(s,{children:F.length===0?c(t,{children:"unknown"}):c(zt,{children:F.map(({window:Z,fraction:V})=>te(Mt,{children:[c(re,{fraction:V,label:`${it[Z.windowType]} window, ${Math.round(V*100)}% used`}),c(Qt,{children:N(V,0)}),c(t,{children:rr(Z,we,Ze,_e,Ct(Oe,Z.windowType))})]},Z.windowType))})}),c(s,{$align:"right",$mono:!0,children:e.expiresAt===null?"never":_e(e.expiresAt,we)}),c(s,{$align:"right",children:te(o,{$gap:1,$justify:"flex-end",children:[De.length===0?null:c(P,{type:"button",$variant:"ghost",$size:"sm","aria-expanded":We,"aria-label":`${We?"Hide":"Show"} quota history for ${e.label}`,title:`${We?"Hide":"Show"} quota history for ${e.label}`,onClick:()=>Me(e.id),children:We?c($e,{}):c(Le,{})}),ie&&e.authType==="oauth"&&z(He,e.provider)?.quotaResets===!0?c(P,{type:"button",$variant:"ghost",$size:"sm","aria-label":`Reset quota for ${e.label}`,title:`Reset quota for ${e.label}`,onClick:()=>ne(e),children:c(br,{})}):null,ie&&e.authType==="oauth"?c(P,{type:"button",$variant:"ghost",$size:"sm","aria-label":`Reconnect ${e.label}`,title:`Reconnect ${e.label}`,onClick:()=>xe(e),children:c(nt,{})}):null,ie?c(P,{type:"button",$variant:"ghost",$size:"sm",disabled:Ne||Ie.has(e.id),"aria-label":Ie.has(e.id)?`Refreshing quota for ${e.label}`:`Refresh quota for ${e.label}`,title:`Refresh quota for ${e.label}`,onClick:()=>void ve({kind:"one",credentialId:e.id}),children:c(Xe,{})}):null,c(P,{type:"button",$variant:"ghost",$size:"sm","aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>Se(e),children:c(xt,{})})]})})]}),We?c(E,{children:c(s,{colSpan:9,children:c(pt,{credentialId:e.id,windows:De,burn:Oe,pollIntervalMs:Ze,now:we})})}):null]},e.id)})})]})})},p)})}),c(ct,{open:ae||Ee!==null,credentials:A.data??[],credential:Ee,onOpenChange:(p)=>{if(!p)D(!1),xe(null);else D(!0)},onConnected:()=>void A.refetch()}),c(ht,{credential:G,busy:O.isPending,onOpenChange:(p)=>{if(!p)ne(null)},onConfirm:(p,y)=>{se(null),Pe([]),O.mutate({credentialId:p.id,creditId:y},{onSuccess:(e)=>se(e.quotaRefreshed?`Quota reset for ${p.label}.`:`Quota reset for ${p.label}; the meter updates at the next poll.`),onError:()=>se(`Quota reset failed for ${p.label}.`),onSettled:()=>ne(null)})}}),c(ee,{open:ue!==null,onOpenChange:(p)=>{if(!p)Se(null)},title:"Remove account",body:ue===null?"":`Removing "${ue.label}" deletes its stored token. Any model target pointing at ${w(ue.provider)} loses this account, and reconnecting means authorizing again.`+Ht(ue,B.data),confirmLabel:"Remove account",busy:L.isPending,onConfirm:()=>{if(ue===null)return;L.mutate(ue.id,{onSettled:()=>Se(null)})}})]})}var Zo=gt;export{Zo as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{se,o,yo,Uo,qo,a,X,I,x,b,k,Ft,Lt,qn,jn,pt,mt}from"/assets/index-p9vbm21a.js";import{R}from"/assets/index-f7t0kve8.js";import"/assets/index-8bewp9z1.js";import{useQueryClient as z}from"@tanstack/react-query";import{useLayoutEffect as Y,useMemo as Z,useRef as q,useState as T}from"react";import g from"styled-components";var h={debug:10,info:20,warn:30,error:40};function H(e){return typeof e==="string"&&e in h}function G(e,r){if(!H(r))return!0;if(e.level===null)return!0;return h[e.level]>=h[r]}function Q(e){if(typeof e!=="object"||e===null)return null;let{raw:r,at:s,level:u,msg:l}=e;if(typeof r!=="string")return null;if(s!==null&&typeof s!=="number")return null;if(u!==null&&!H(u))return null;if(l!==null&&typeof l!=="string")return null;return{raw:r,at:s,level:u,msg:l}}function V(e){if(typeof e!=="object"||e===null)return null;let{lines:r}=e;if(!Array.isArray(r))return null;let s=[];for(let u of r){let l=Q(u);if(l===null)return null;s.push(l)}return s}import{jsx as n,jsxs as f,Fragment as ue}from"react/jsx-runtime";var ee=[100,200,500],te=[{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"}],ne=g(o).withConfig({displayName:"ConsoleBoard__Controls"})(["gap:",";flex-wrap:wrap;"],({theme:e})=>e.space(2)),v=g(R).withConfig({displayName:"ConsoleBoard__Narrow"})(["width:auto;"]),oe=g.pre.withConfig({displayName:"ConsoleBoard__Lines"})(["margin:0;padding:",";font-family:",";font-size:12px;line-height:1.65;white-space:pre;"],({theme:e})=>e.space(3),({theme:e})=>e.font.mono),re=g.div.withConfig({displayName:"ConsoleBoard__Line"})(["color:",";"],({theme:e,$level:r})=>r==="error"?e.color.down:r==="warn"?e.color.warn:r==="debug"?e.color.inkFaint:e.color.ink),w=g.p.withConfig({displayName:"ConsoleBoard__Hint"})(["margin:0;padding:",";border-top:1px solid ",";color:",";font-size:12px;"],({theme:e})=>`${e.space(2)} ${e.space(3)}`,({theme:e})=>e.color.rule,({theme:e})=>e.color.inkDim),C=g.code.withConfig({displayName:"ConsoleBoard__Path"})(["font-family:",";word-break:break-all;"],({theme:e})=>e.font.mono);function ie({read:e}){if(e.source==="file")return f(w,{children:["Reading ",n(C,{children:e.path}),", named by ",n(C,{children:"OMNI_LOG_FILE"}),". That variable says where the gateway's output is being captured; it does not redirect it."]});if(e.source==="journal")return f(w,{children:["Reading the systemd journal for ",n(C,{children:"omnigateway.service"}),". To read a file instead, redirect the gateway's output to one and point ",n(C,{children:"OMNI_LOG_FILE"})," at the same path."]});if(e.unreachable!==void 0&&e.unreachable.length>0)return f(w,{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((r)=>r.slice(0,8)).join(", "),"."]});return null}var ae={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."},A=[],le={read:void 0,lines:A};function j(){let{cadence:e}=X(),r=z(),[s,u]=T(200),[l,W]=T(""),[N,K]=T(""),S=qo(),O=S.data?.nodes??[],E=O.length>1,c=N===""&&E?"all":N,J=c==="all"?"fleet":E?"process":"single",L=c===""||c==="all"?null:`${Ft}:${c}`,p=Uo(s,l,e(yo,L??Ft),c),i=p.data,[_,D]=T(le),M=_.read===i?_.lines:A,m=Z(()=>[...i?.lines??[],...M].slice(-s),[i,M,s]),F=q(null),U=q(!0),B=(t)=>{if(t.kind!=="frame"&&t.kind!=="gap"&&t.kind!=="closed")return;let d=t.kind==="frame"?V(t.payload):null;if(d===null){if(D({read:i,lines:A}),t.kind==="frame")Lt(r,Ft);return}let P=d.filter((y)=>G(y,l));if(P.length===0)return;D((y)=>({read:i,lines:[...y.read===i?y.lines:[],...P].slice(-s)}))};return qn(Ft,(t)=>{if(L===null)B(t)}),jn(L,B),Y(()=>{let t=F.current;if(t!==null&&U.current&&m.length>0)t.scrollTop=t.scrollHeight},[m]),f(ue,{children:[n(k,{legend:"Console",title:"Gateway output",summary:p.isLoading?"Reading the gateway's own output…":`${a(m.length)} lines of what this process is doing. Requests are in Logs; prompt bodies, tokens and keys are never written here.`,actions:f(ne,{children:[E?n(v,{value:c,"aria-label":"Which process to show",options:[{value:"all",label:"every process"},...O.map((t)=>({value:t.id,label:t.self?`${t.id.slice(0,8)} (this one)`:t.id.slice(0,8)}))],onValueChange:K}):null,n(v,{value:l,"aria-label":"Which levels to show",options:te,onValueChange:W}),n(v,{value:s,"aria-label":"How many lines to fetch",options:ee.map((t)=>({value:String(t),label:`last ${t}`})),onValueChange:(t)=>u(Number(t))})]})}),f(pt,{legend:"Process output",meta:i===void 0?void 0:n(se,{children:de(i)}),flush:!0,children:[i===void 0?null:n(ie,{read:i}),n(mt,{ref:F,"data-testid":"console-terminal",onScroll:(t)=>{let d=t.currentTarget;U.current=d.scrollHeight-d.scrollTop-d.clientHeight<=8},children:p.isError?n(x,{error:p.error,onRetry:()=>void p.refetch()}):p.isLoading||S.isLoading?n("div",{style:{padding:12},children:n(b,{rows:10})}):i!==void 0&&i.source==="none"?n(I,{legend:"Nothing is capturing this gateway",message:ae[J]}):m.length===0?n(I,{legend:"Nothing to show",message:l===""?"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."}):n(oe,{children:m.map((t,d)=>n(re,{$level:t.level,children:t.nodeId===void 0?t.raw:`[${t.nodeId.slice(0,8)}] ${t.raw}`},`${t.at??0}-${d}`))})})]})]})}function de(e){if(e.source==="file")return"log file";if(e.source==="journal")return"systemd journal";if(e.source==="fleet")return"every process, merged";return"not captured"}var Qe=j;export{Qe as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,t,o,r,Ie,Q,M,jo,zo,Wo,Ho,Vo,Ko,Go,Xo,Qo,Yo,i,a,V,N,Ce,xe,I,h,x,b,ee,k,f}from"/assets/index-p9vbm21a.js";import{re}from"/assets/index-wjqdtafp.js";import{D}from"/assets/index-d09hs7ex.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{m,de}from"/assets/index-8bewp9z1.js";import{Ar}from"/assets/index-d0t1fj1y.js";import{xt}from"/assets/index-nnpqs2w6.js";var X={name:"camera",size:24,node:[["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"}]]};X.node;var J=i(X);var K={name:"minimize-2",size:24,node:[["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.node;var Y=i(K);import{useState as se}from"react";import ue from"styled-components";import{useState as G}from"react";import H from"styled-components";import{jsx as z,jsxs as Z}from"react/jsx-runtime";var te=[{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}],he=H.p.withConfig({displayName:"RetentionModule__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),be=H.p.withConfig({displayName:"RetentionModule__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),ye=H.div.withConfig({displayName:"RetentionModule__Fields"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:",";"],({theme:e})=>e.space(3));function ke(e){let c={};for(let y of te){let S=e[y.id].trim(),w=Number(S);if(S.length===0||!Number.isInteger(w)||w<1)return{ok:!1,problem:`${y.label} must be a whole number of 1 or more.`};if(w>y.max)return{ok:!1,problem:`${y.label} cannot exceed ${y.max}.`};c[y.id]=w}return{ok:!0,policy:c}}function oe({retention:e}){let c=Vo(),[y,S]=G({}),[w,R]=G(null),[T,d]=G(!1),v={keepLatest:y.keepLatest??(e===void 0?"":String(e.keepLatest)),maxAgeDays:y.maxAgeDays??(e===void 0?"":String(e.maxAgeDays))},B=()=>{d(!1);let g=ke(v);if(!g.ok){R(g.problem);return}R(null),c.mutate(g.policy,{onSuccess:()=>{d(!0),S({})},onError:(L)=>R(h(L))})};return z(f,{legend:"Retention",actions:z(n,{type:"button",$size:"sm",disabled:c.isPending||e===void 0,onClick:B,children:c.isPending?"Saving…":"Save retention"}),children:Z(r,{$gap:3,children:[z(ye,{children:te.map((g)=>z(m,{label:g.label,hint:g.hint,children:(L)=>Z(o,{$gap:2,children:[z(de,{...L,min:1,max:g.max,step:1,value:v[g.id],onChange:(A)=>S({...y,[g.id]:A.target.value})}),z(t,{children:g.unit})]})},g.id))}),w===null?null:z(he,{role:"alert",children:w}),T&&w===null?z(be,{role:"status",children:"Retention saved."}):null]})})}import{useState as O}from"react";import ae from"styled-components";import{useQueryClient as we}from"@tanstack/react-query";import{useCallback as ve}from"react";function ne(){let e=we();return ve((c)=>{if(c.adminPasswordChanged){Ar("admin-password-changed");return}e.invalidateQueries()},[e])}import{jsx as p,jsxs as _}from"react/jsx-runtime";var j=ae.p.withConfig({displayName:"SnapshotsModule__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),$e=ae.input.withConfig({displayName:"SnapshotsModule__Picker"})(["font-size:12px;color:",";max-width:40ch;"],({theme:e})=>e.color.inkDim);function ie(){let e=Wo(),c=Ho(),y=Qo(),S=ne(),w=Xo(),R=Yo(),[T,d]=O(null),[v,B]=O(null),[g,L]=O(null),[A,F]=O(!1),U=e.data??[],ce=_(n,{type:"button",$variant:"primary",$size:"sm",disabled:c.isPending,onClick:()=>c.mutate(),children:[p(J,{}),c.isPending?"Copying…":"Take a snapshot"]}),fe=_(r,{$gap:2,children:[_(o,{$gap:2,$wrap:!0,children:[p(m,{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:(C)=>p($e,{...C,type:"file",accept:".sqlite,.db,application/octet-stream",onChange:(ge)=>L(ge.target.files?.[0]??null)})}),p(n,{type:"button",$variant:"danger",$size:"sm",disabled:g===null||R.isPending,onClick:()=>F(!0),children:R.isPending?"Replacing…":"Import"})]}),R.isError?p(j,{role:"alert",children:h(R.error)}):null,y.isError?p(j,{role:"alert",children:h(y.error)}):null,c.isError?p(j,{role:"alert",children:h(c.error)}):null]});return _(f,{legend:"Snapshots",meta:`${U.length}`,actions:ce,footer:fe,flush:!0,children:[e.isError?p(x,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?p("div",{style:{padding:12},children:p(b,{rows:3})}):U.length===0?p(I,{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:p(n,{type:"button",$variant:"primary",$size:"sm",disabled:c.isPending,onClick:()=>c.mutate(),children:"Take the first snapshot"})}):p(Q,{children:_(q,{children:[p("thead",{children:_("tr",{children:[p(l,{children:"File"}),p(l,{children:"Reason"}),p(l,{$align:"right",children:"Size"}),p(l,{$align:"right",children:"Taken"}),p(l,{})]})}),p("tbody",{children:U.map((C)=>_(E,{children:[p(s,{$mono:!0,children:p(M,{style:{maxWidth:"38ch",display:"block"},children:C.filename})}),p(s,{children:C.reason}),p(s,{$align:"right",$mono:!0,children:xe(C.sizeBytes)}),p(s,{$align:"right",$mono:!0,children:Ce(C.createdAt)}),p(s,{$align:"right",children:_(o,{$gap:1,$justify:"flex-end",children:[p(n,{as:"a",$size:"sm",href:zo(C.id),download:C.filename,children:"Download"}),p(n,{type:"button",$variant:"danger",$size:"sm",onClick:()=>d(C),children:"Restore"}),p(n,{type:"button",$variant:"danger",$size:"sm",onClick:()=>B(C),children:"Delete"})]})})]},C.id))})]})}),p(ee,{open:T!==null,onOpenChange:(C)=>{if(!C)d(null)},title:"Restore database",body:T===null?"":`Replacing the live database with ${T.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:y.isPending,onConfirm:()=>{if(T===null)return;y.mutate(T.id,{onSuccess:S,onSettled:()=>d(null)})}}),p(ee,{open:v!==null,onOpenChange:(C)=>{if(!C)B(null)},title:"Delete snapshot",body:v===null?"":`Deleting ${v.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:w.isPending,onConfirm:()=>{if(v===null)return;w.mutate(v.id,{onSettled:()=>B(null)})}}),p(ee,{open:A,onOpenChange:F,title:"Import database",body:g===null?"":`Replacing the live database with ${g.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:R.isPending,onConfirm:()=>{if(g===null)return;R.mutate(g,{onSuccess:S,onSettled:()=>F(!1)})}})]})}import{jsx as u,jsxs as P,Fragment as W}from"react/jsx-runtime";var le=ue.p.withConfig({displayName:"DatabaseBoard__Outcome"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),me=ue.p.withConfig({displayName:"DatabaseBoard__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down);function Se(e){try{let{hostname:c,port:y}=new URL(e);return y===""?c:`${c}:${y}`}catch{return e}}function Re(e){try{return new URL(e).pathname.replace(/^\//,"")||"—"}catch{return"—"}}function pe(){let e=jo(),c=Ko(),[y,S]=se(!1),w=Go(),[R,T]=se(!1),d=e.data,v=d?.engine==="postgres",B=d===void 0||d.logicalBytes===0?0:d.freePageBytes/d.logicalBytes;return P(W,{children:[u(k,{legend:"Database",title:"Storage, snapshots, and retention",summary:e.isLoading?"Measuring the database…":v?"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(f,{legend:"Size",meta:d===void 0?void 0:`schema v${d.stats.schemaVersion}`,actions:P(W,{children:[P(n,{type:"button",$size:"sm",disabled:w.isPending||d===void 0||d.bodiesBytes===0,onClick:()=>T(!0),children:[u(xt,{}),w.isPending?"Clearing…":"Clear bodies"]}),v?null:P(n,{type:"button",$size:"sm",disabled:c.isPending||d===void 0,onClick:()=>S(!0),children:[u(Y,{}),c.isPending?"Compacting…":"Compact"]})]}),footer:c.isError?u(me,{role:"alert",children:h(c.error)}):w.isError?u(me,{role:"alert",children:h(w.error)}):c.data!==void 0?u(le,{role:"status",children:`Compacted, reclaiming ${xe(c.data.reclaimedBytes)} in ${V(c.data.durationMs)}.`}):w.data===void 0?void 0:u(le,{role:"status",children:`Cleared ${a(w.data.removed)} captured bodies.`}),children:e.isError?u(x,{error:e.error,onRetry:()=>void e.refetch()}):d===void 0?u(b,{rows:3}):v?P(Ie,{$min:"180px",$stretch:!0,children:[u(D,{legend:"Database",value:xe(d.logicalBytes),unit:`${d.stats.pageCount} blocks of ${xe(d.stats.pageSize)}`}),u(D,{legend:"Server",value:Se(d.location),unit:`database ${Re(d.location)}`}),u(D,{legend:"Captured bodies",value:xe(d.bodiesBytes),unit:"the request_bodies table"})]}):P(Ie,{$min:"180px",$stretch:!0,children:[u(D,{legend:"Database file",value:xe(d.fileBytes),unit:`${d.stats.pageCount} pages of ${xe(d.stats.pageSize)}`,trace:u(re,{fraction:B,label:`${N(B,0)} of the file is reclaimable`})}),u(D,{legend:"Reclaimable",value:xe(d.freePageBytes),unit:`${d.stats.freelistCount} free pages`}),u(D,{legend:"Write-ahead log",value:xe(d.walBytes),unit:"folded into every snapshot"}),u(D,{legend:"Captured bodies",value:xe(d.bodiesBytes),unit:"never in a snapshot"}),u(D,{legend:"Snapshots",value:xe(d.snapshots.totalBytes),unit:`${d.snapshots.count} kept`}),u(D,{legend:"Free disk",value:xe(d.freeDiskBytes),unit:d.freeDiskBytes===null?"not readable here":"on this filesystem"})]})}),u(f,{legend:"Tables",meta:v?"row counts are the planner's estimates; dead rows await autovacuum":"size includes each table's indexes",children:d===void 0?u(b,{rows:4}):P(q,{children:[u("thead",{children:P(E,{children:[u(l,{children:"Table"}),u(l,{$align:"right",children:"Size"}),u(l,{$align:"right",children:"Rows"}),v?u(l,{$align:"right",children:"Dead rows"}):null]})}),u("tbody",{children:d.tables.map((g)=>P(E,{children:[u(s,{children:g.name}),u(s,{$align:"right",children:xe(g.bytes)}),u(s,{$align:"right",children:a(g.rows)}),v?u(s,{$align:"right",children:a(g.deadRows??0)}):null]},g.name))})]})}),v?null:P(W,{children:[u(ie,{}),u(oe,{retention:d?.retention})]}),u(ee,{open:R,onOpenChange:T,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:w.isPending,onConfirm:()=>w.mutate(void 0,{onSettled:()=>T(!1)})}),u(ee,{open:y,onOpenChange:S,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:c.isPending,onConfirm:()=>c.mutate(void 0,{onSettled:()=>S(!1)})})]})}var Tt=pe;export{Tt as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{be,n,t,d,o,r,Ie,S,Q,M,pe,Xt,H,we,he,Ue,Mr,a,w,V,N,_e,Zt,Dt,O,er,tr,$r,Ur,wt,it,Ct,rr,nr,qe,X,oe,ge,K,I,x,k,f}from"/assets/index-p9vbm21a.js";import{C,vt}from"/assets/index-fcew0gga.js";import{re}from"/assets/index-wjqdtafp.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{vr,At}from"/assets/index-xdyjb1an.js";import{D}from"/assets/index-d09hs7ex.js";import{useMemo as It}from"react";import Z from"styled-components";import{jsx as p,jsxs as U}from"react/jsx-runtime";var ft=Z(M).withConfig({displayName:"AccountRack__Label"})(["font-weight:500;display:block;max-width:24ch;"]),nt=Z.span.withConfig({displayName:"AccountRack__Note"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),gt=Z.div.withConfig({displayName:"AccountRack__QuotaCell"})(["display:grid;grid-template-columns:72px 1fr;align-items:center;gap:6px;min-width:172px;"]),yt=Z.div.withConfig({displayName:"AccountRack__QuotaStack"})(["display:flex;flex-direction:column;gap:4px;"]);function ht(e){let h=null;for(let y of e){if(y.stale||y.survives!==!1||y.exhaustsAt===null)continue;if(h===null||y.exhaustsAt<h)h=y.exhaustsAt}return h}function kt(e,h){if(e===null)return h===null?0:1;if(h===null)return-1;return e-h}function st({credentials:e,health:h,quota:y,burn:m,usage:i,lastUsed:u,quotaPollIntervalMs:b,now:_}){let g=qe(h,(c)=>c.credentialId),A=qe(y,(c)=>c.credentialId),j=qe(m,(c)=>c.credentialId),P=new Map(i.map((c)=>[c.key,c])),J={down:0,warn:1,ok:2,idle:3,live:3},z=e.map((c)=>{let v=j.get(c.id)??[];return{credential:c,status:wt(g.get(c.id)??[],_,c.enabled,c.disabledReason),quota:nr(A.get(c.id)??[]),burn:v,exhaustsAt:ht(v),usage:P.get(c.id)}}).sort((c,v)=>J[c.status.state]-J[v.status.state]||kt(c.exhaustsAt,v.exhaustsAt)||c.credential.tier-v.credential.tier);return p(f,{legend:"Accounts",meta:`${e.length} connected`,flush:!0,actions:p(n,{as:be,to:"/accounts",$size:"sm",children:"Manage accounts"}),children:e.length===0?p(I,{legend:"No accounts",message:"The gateway has no provider credentials, so every request will fail. Connect one to start routing.",action:p(n,{as:be,to:"/accounts",$variant:"primary",$size:"sm",children:"Connect an account"})}):p(Q,{children:U(q,{children:[p("thead",{children:U("tr",{children:[p(l,{children:"Account"}),p(l,{children:"Provider"}),p(l,{$align:"right",children:"Tier"}),p(l,{children:"Quota"}),p(l,{$align:"right",children:"Requests"}),p(l,{$align:"right",children:"Last used"})]})}),p("tbody",{children:z.map(({credential:c,status:v,quota:W,burn:pt,usage:at})=>U(E,{children:[p(s,{children:U(o,{$gap:2,children:[p(ge,{state:v.state,label:v.note===""?"healthy":v.note}),U("div",{children:[p(ft,{children:c.label}),v.note===""?null:p(nt,{children:v.note})]})]})}),p(s,{children:p(vt,{provider:c.provider})}),p(s,{$align:"right",$mono:!0,children:c.tier}),p(s,{children:W.length===0?p(nt,{children:"unknown"}):p(yt,{children:W.map(({window:Y,fraction:rt})=>U(gt,{children:[p(re,{fraction:rt,label:`${it[Y.windowType]} window, ${Math.round(rt*100)}% used`}),p(t,{children:rr(Y,_,b,_e,Ct(pt,Y.windowType))})]},Y.windowType))})}),p(s,{$align:"right",$mono:!0,children:at===void 0?"—":a(at.requests)}),p(s,{$align:"right",$mono:!0,children:_e(u[c.id]??null,_)})]},c.id))})]})})})}import F from"styled-components";import{jsx as T,jsxs as tt,Fragment as qt}from"react/jsx-runtime";var Mt=F.ul.withConfig({displayName:"ActivityTail__List"})(["display:flex;flex-direction:column;"]),Tt=F.li.withConfig({displayName:"ActivityTail__Entry"})(["display:flex;align-items:center;gap:",";padding:6px ",";border-bottom:1px solid ",";&:last-child{border-bottom:0;}"],({theme:e})=>e.space(2),({theme:e})=>e.space(3),({theme:e})=>e.color.rule),bt=F(M).withConfig({displayName:"ActivityTail__Model"})(["font-family:",";font-size:12px;max-width:30ch;"],({theme:e})=>e.font.mono),$t=F(M).withConfig({displayName:"ActivityTail__KeyName"})(["font-family:",";font-size:11px;color:",";max-width:16ch;"],({theme:e})=>e.font.mono,({theme:e})=>e.color.inkFaint),xt=F(d).withConfig({displayName:"ActivityTail__Fault"})(["color:",";font-size:11px;"],({theme:e})=>e.color.down);function lt({logs:e,keyNames:h}){let y=e.slice(0,12);return T(f,{legend:"Activity",meta:"most recent first",flush:!0,actions:T(n,{as:be,to:"/logs",$size:"sm",children:"Open logs"}),children:y.length===0?T(I,{legend:"No traffic yet",message:"Point a client at this gateway with an API key and the requests will appear here."}):T(Mt,{children:y.map((m)=>tt(Tt,{children:[T(ge,{state:er(m),label:tr(m)}),T(d,{$dim:!0,children:Zt(m.at)}),T(bt,{title:m.requestedModel,children:m.requestedModel||"—"}),m.resolvedProvider===null?null:T(d,{$dim:!0,style:{color:oe(m.resolvedProvider)},children:m.resolvedProvider}),m.apiKeyId===null?null:T($t,{title:m.apiKeyId,children:h.get(m.apiKeyId)??Dt(m.apiKeyId)}),T(S,{}),O(m)?T(d,{$dim:!0,"aria-label":"processing",children:T(vr,{})}):tt(qt,{children:[m.errorCode===null?null:T(xt,{children:m.errorCode}),m.attempts>1?tt(d,{$dim:!0,children:[m.attempts,"×"]}):null,T(d,{$dim:!0,children:T(At,{tokens:m})}),T(d,{$dim:!0,children:V(m.durationMs)}),T(d,{$dim:!0,children:w(m.costUsd)})]})]},m.id))})})}import G from"styled-components";import{jsx as R,jsxs as et}from"react/jsx-runtime";var Rt=G.ul.withConfig({displayName:"ModelTraffic__List"})(["display:flex;flex-direction:column;gap:",";"],({theme:e})=>e.space(3)),_t=G(M).withConfig({displayName:"ModelTraffic__Name"})(["font-family:",";font-size:12.5px;"],({theme:e})=>e.font.mono),Lt=G.div.withConfig({displayName:"ModelTraffic__ShareTrack"})(["display:flex;height:5px;border-radius:2px;overflow:hidden;background:",";border:1px solid ",";"],({theme:e})=>e.color.panelSunk,({theme:e})=>e.color.rule),Nt=G.div.withConfig({displayName:"ModelTraffic__Segment"})(["flex:"," 0 0;background:",";opacity:0.8;"],({$grow:e})=>e,({$color:e})=>e),St=G.div.withConfig({displayName:"ModelTraffic__Rest"})(["flex:"," 0 0;"],({$grow:e})=>e);function dt({models:e,logs:h}){let y=new Map;for(let u of h){let b=y.get(u.requestedModel)??{requests:0,costUsd:0};b.requests+=1,b.costUsd+=u.costUsd,y.set(u.requestedModel,b)}let m=Math.max(1,...[...y.values()].map((u)=>u.requests)),i=[...e].map((u)=>({model:u,used:y.get(u.id)})).sort((u,b)=>(b.used?.requests??0)-(u.used?.requests??0)).slice(0,8);return R(f,{legend:"Models",meta:`${e.length} configured`,actions:R(n,{as:be,to:"/models",$size:"sm",children:"Edit routing"}),children:e.length===0?R(I,{legend:"No models",message:"Nothing is routable yet. Create a virtual model and point it at one or more provider targets.",action:R(n,{as:be,to:"/models",$variant:"primary",$size:"sm",children:"Create a model"})}):R(Rt,{children:i.map(({model:u,used:b})=>{let _=(b?.requests??0)/m,g=[...new Set(u.targets.map((A)=>A.provider))];return et("li",{children:[et(o,{$gap:2,children:[R(_t,{title:u.id,children:u.id}),u.isAlias?R(C,{children:"alias"}):null,R(C,{$tone:"accent",children:u.strategy}),R(S,{}),R(d,{$dim:!0,children:a(b?.requests??0)}),R(t,{children:"req"}),R(d,{$dim:!0,children:w(b?.costUsd??0)})]}),et(Lt,{style:{marginTop:6},title:`${Math.round(_*100)}% of the busiest model`,children:[g.map((A)=>R(Nt,{$color:oe(A),$grow:_/g.length},A)),R(St,{$grow:Math.max(0,1-_)})]})]},u.id)})})})}import Bt from"styled-components";import{jsx as L,jsxs as Ut}from"react/jsx-runtime";var Pt=Bt.div.withConfig({displayName:"VitalsRow__Deck"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(168px,1fr));gap:",";"],({theme:e})=>e.space(3));function mt({logs:e,windowMs:h,now:y}){let m=e.filter((g)=>y-g.at<=h),i=$r(m,h),u=Ur(m,{now:y,spanMs:h,count:32}),b=i.errorRate>=0.25?"down":i.errorRate>=0.05?"warn":"ok",_=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens;return Ut(Pt,{children:[L(D,{legend:"Requests",value:a(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:L(K,{values:u.map((g)=>g.total),overlay:u.map((g)=>g.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),L(D,{legend:"Error rate",value:N(i.errorRate),unit:`${a(i.errors)} failed`,tone:i.requests===0?"ink":b,trace:L(K,{values:u.map((g)=>g.errors),scaleTo:Math.max(...u.map((g)=>g.total)),color:"var(--down)",label:`${i.errors} failed requests against ${i.requests} total`})}),L(D,{legend:"Total tokens",value:a(_),unit:L(At,{tokens:i}),trace:L(K,{values:u.map((g)=>g.tokens),label:`token volume over the window, ${_.toLocaleString("en-US")} total`})}),L(D,{legend:"Time to first token",value:V(i.ttftP50),unit:`p95 ${V(i.ttftP95)}`,trace:L(K,{values:u.map((g)=>g.ttftMs??0),color:"var(--ok)",label:`median first-token latency, currently ${V(i.ttftP50)}`})}),L(D,{legend:"Spend",value:w(i.costUsd),unit:`${a(i.inputTokens+i.outputTokens)} tokens`,trace:L(K,{values:u.map((g)=>g.costUsd),color:"var(--warn)",label:`spend over the window, ${w(i.costUsd)} total`})})]})}import{jsx as B,jsxs as ot,Fragment as Et}from"react/jsx-runtime";var ut=3600000;function ct(){let{cadence:e}=X(),h=pe(),y=Xt(e(1e4,"res:credentials")),m=H(),i=Mr(500,e(1e4,"res:logs")),u=we(),b=he(),_=It(()=>{let v=new Map;for(let W of u.data??[])v.set(W.id,W.label);return v},[u.data]),g=Date.now(),A=Math.floor((g-ut)/60000)*60000,j=Ue({groupBy:"credential",since:A},e(60000,"res:usage")),P=h.data??[],J=qe(y.data?.health??[],(v)=>v.credentialId),z=P.filter((v)=>wt(J.get(v.id)??[],g,v.enabled,v.disabledReason).state==="down"),c=h.isLoading||i.isLoading?"Reading the gateway…":P.length===0?"No accounts are connected, so every request fails at the router.":z.length>0?`${z.length} account${z.length===1?" is":"s are"} out of rotation.`:`All ${P.length} accounts are answering. Nothing needs attention.`;return ot(Et,{children:[B(k,{legend:"Rack",title:"Gateway",summary:c}),i.isError?B(f,{legend:"Traffic",children:B(x,{legend:"The gateway did not answer",error:i.error,onRetry:()=>void i.refetch()})}):ot(r,{$gap:4,children:[B(mt,{logs:i.data??[],windowMs:ut,now:g}),B(st,{credentials:P,health:y.data?.health??[],quota:y.data?.quota??[],burn:y.data?.burn??[],usage:j.data??[],lastUsed:y.data?.lastUsed??{},quotaPollIntervalMs:b.data?.quotaPollIntervalMs??300000,now:g}),ot(Ie,{$min:"340px",$gap:4,children:[B(dt,{models:m.data??[],logs:i.data??[]}),B(lt,{logs:i.data??[],keyNames:_})]})]})]})}var so=ct;export{so as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,P,t,d,o,r,S,M,H,we,he,Qt,yn,vn,xn,bn,wn,Cn,Sn,i,bt,Ce,Dr,Dn,I,h,x,b,J,ee,k,pt,mt}from"/assets/index-p9vbm21a.js";import{$e,tt}from"/assets/index-f7t0kve8.js";import{W}from"/assets/index-dq2f7yk0.js";import{C}from"/assets/index-fcew0gga.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{v,Tr,m,de}from"/assets/index-8bewp9z1.js";import{re}from"/assets/index-wjqdtafp.js";import{xr}from"/assets/index-v31xha7b.js";import{ir,sr,Rt,zn,lr,ur,cr,Wn,Pt,dr,Hn,Vn}from"/assets/index-4dz4bgrb.js";import{Qe}from"/assets/index-0j7sghrn.js";import{Le}from"/assets/index-zkt5p0qd.js";var Oe={name:"calendar-clock",size:24,node:[["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"}]]};Oe.node;var Ie=i(Oe);var Ke={name:"list-checks",size:24,node:[["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"}]]};Ke.node;var qe=i(Ke);var Ge={name:"shield-check",size:24,node:[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]};Ge.node;var He=i(Ge);import{Fragment as Zt,useState as le}from"react";import me from"styled-components";import{useState as We}from"react";import Ye from"styled-components";function fe(e,u){if(e.revokedAt!==null)return"revoked";return Dn(e,u)?"active":"expired"}function Ue(e){if(e===null)return"";let u=new Date(e-new Date(e).getTimezoneOffset()*60000);if(Number.isNaN(u.getTime()))return"";return u.toISOString().slice(0,16)}function xe(e){let u=e.trim();if(u.length===0)return{at:null};let c=new Date(u).getTime();if(!Number.isFinite(c))return{problem:`"${e}" is not a date`};return{at:c}}import{jsx as ae,jsxs as Ve,Fragment as ht}from"react/jsx-runtime";var gt=Ye.p.withConfig({displayName:"EditExpiryDialog__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),ft=Ye.p.withConfig({displayName:"EditExpiryDialog__Lapsed"})(["font-size:12px;color:",";"],({theme:e})=>e.color.warn);function Xe({apiKey:e,onOpenChange:u}){let c=bn(),[f,g]=We(()=>Ue(e?.expiresAt??null)),[L,y]=We(null),w=()=>{if(e===null)return;let R=xe(f);if("problem"in R){y(R.problem);return}y(null),c.mutate({id:e.id,expiresAt:R.at},{onSuccess:()=>u(!1),onError:(N)=>y(h(N))})},A=e!==null&&fe(e,Date.now())==="expired";return ae(J,{open:e!==null,onOpenChange:u,title:"Edit expiry",description:e===null?void 0:`When "${e.label}" stops being accepted. Leave it blank for never.`,width:"480px",footer:Ve(ht,{children:[ae(n,{type:"button",onClick:()=>u(!1),children:"Cancel"}),ae(n,{type:"button",$variant:"primary",disabled:c.isPending,onClick:w,children:c.isPending?"Saving…":"Save expiry"})]}),children:Ve(r,{$gap:3,children:[A?ae(ft,{role:"status",children:"This key has expired and the gateway is refusing it. Moving the date forward, or clearing it, brings it back."}):null,ae(m,{label:"Expires",hint:"Your local time. Blank means the key never expires; a date already past expires it now.",children:(R)=>ae(v,{...R,type:"datetime-local",value:f,disabled:c.isPending,onChange:(N)=>g(N.target.value)})}),L===null?null:ae(gt,{role:"alert",children:L})]})})}import{useState as Je}from"react";import Me from"styled-components";import{jsx as Z,jsxs as Se,Fragment as vt}from"react/jsx-runtime";var yt=Me.p.withConfig({displayName:"EditGuardrailDialog__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),kt=Me.p.withConfig({displayName:"EditGuardrailDialog__Unset"})(["font-size:12px;color:",";"],({theme:e})=>e.color.warn),wt=Me.p.withConfig({displayName:"EditGuardrailDialog__Note"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),Ct=Me.span.withConfig({displayName:"EditGuardrailDialog__Count"})(["font-size:11px;font-family:",";color:",";"],({theme:e})=>e.font.mono,({$over:e,theme:u})=>e?u.color.down:u.color.inkDim);function Ze({apiKey:e,onOpenChange:u}){let c=wn(),f=he(),[g,L]=Je(()=>e?.guardrailPolicy??""),[y,w]=Je(null),A=g.trim().length,R=A>Dr,N=(V)=>{if(e===null)return;w(null),c.mutate({id:e.id,policy:V},{onSuccess:()=>u(!1),onError:(X)=>w(h(X))})},F=()=>{if(A===0){w("Write a policy, or use Remove policy to stop judging this key.");return}if(R){w(`A policy is at most ${Dr} characters.`);return}N(g)},B=f.data!==void 0&&f.data.guardrailModel===null;return Z(J,{open:e!==null,onOpenChange:u,title:"Edit usage policy",description:e===null?void 0:`What "${e.label}" may be used for. Each request is judged against it by the classifier model before it is routed.`,width:"560px",footer:Se(vt,{children:[e?.guardrailPolicy===null||e===null?null:Z(n,{type:"button",$variant:"danger",disabled:c.isPending,onClick:()=>N(null),children:"Remove policy"}),Z(S,{}),Z(n,{type:"button",onClick:()=>u(!1),children:"Cancel"}),Z(n,{type:"button",$variant:"primary",disabled:c.isPending,onClick:F,children:c.isPending?"Saving…":"Save policy"})]}),children:Se(r,{$gap:3,children:[B?Z(kt,{role:"status",children:"No classifier model is set in Settings, so every request from a key with a policy is refused until one is."}):null,Z(m,{label:"Policy",hint:"Plain language, e.g. Only software engineering and office documents. Refuse roleplay and personal content.",children:(V)=>Z(Tr,{...V,value:g,rows:6,disabled:c.isPending,onChange:(X)=>L(X.target.value)})}),Se(o,{children:[Z(wt,{children:"A guardrail against ordinary misuse, not a security boundary: a determined client can talk a classifier round."}),Z(S,{}),Se(Ct,{$over:R,children:[A," / ",Dr]})]}),y===null?null:Z(yt,{role:"alert",children:y})]})})}import{useState as Ee}from"react";import be from"styled-components";import je from"styled-components";import{jsx as Pe,jsxs as $t}from"react/jsx-runtime";var xt=je.div.withConfig({displayName:"LimitFields__Grid"})(["display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:",";"],({theme:e})=>e.space(2)),St=je.p.withConfig({displayName:"LimitFields__Note"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim);function ye({draft:e,onChange:u,disabled:c=!1}){return $t(r,{$gap:2,children:[Pe(xt,{children:ir.map((f)=>{let g=sr(f);return Pe(m,{label:Rt(f),children:(L)=>Pe(de,{...L,min:f.dimension==="spend"?void 0:1,step:f.dimension==="spend"?"any":1,disabled:c,value:e[g]??"",placeholder:"none",onChange:(y)=>u({...e,[g]:y.target.value})})},g)})}),Pe(St,{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."})]})}import{jsx as G,jsxs as ce,Fragment as At}from"react/jsx-runtime";var Lt=be.p.withConfig({displayName:"EditLimitsDialog__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),Mt=be.p.withConfig({displayName:"EditLimitsDialog__Broken"})(["font-size:12px;color:",";"],({theme:e})=>e.color.warn),Et=be.h3.withConfig({displayName:"EditLimitsDialog__SectionTitle"})(["font-size:12px;font-weight:600;color:",";"],({theme:e})=>e.color.ink),_t=be(r).withConfig({displayName:"EditLimitsDialog__Override"})(["padding-top:",";border-top:1px solid ",";"],({theme:e})=>e.space(2),({theme:e})=>e.color.rule),Dt=be.p.withConfig({displayName:"EditLimitsDialog__Hint"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim);function et({apiKey:e,onOpenChange:u}){let c=vn(),f=H(),[g,L]=Ee(()=>Pt(e?.limits??{})),[y,w]=Ee(()=>Hn(e?.limits??{})),[A,R]=Ee(0),[N,F]=Ee(null),B=(f.data??[]).map((_)=>({value:_.id,label:_.id})),V=(_,T)=>{w((Q)=>Q.map((z)=>z.id===_?{...z,...T}:z))},X=()=>{if(e===null)return;let _=dr(g);if("problem"in _){F(_.problem);return}let T=Vn(y);if("problem"in T){F(T.problem);return}let Q=Object.keys(T.models).length===0?_.limits:{..._.limits,models:T.models};F(null),c.mutate({id:e.id,limits:Q},{onSuccess:()=>u(!1),onError:(z)=>F(h(z))})};return G(J,{open:e!==null,onOpenChange:u,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:ce(At,{children:[G(n,{type:"button",onClick:()=>u(!1),children:"Cancel"}),G(n,{type:"button",$variant:"primary",disabled:c.isPending,onClick:X,children:c.isPending?"Saving…":"Save limits"})]}),children:ce(r,{$gap:3,children:[e?.limits===null?G(Mt,{role:"status",children:"The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them."}):null,G(ye,{draft:g,onChange:L,disabled:c.isPending}),ce(r,{$gap:2,children:[G(Et,{children:"Per-model overrides"}),G(t,{children:"A stricter ceiling for one model, matched exactly against the model a request names. It stacks with the limits above: a request for that model must pass both."}),y.map((_)=>{let T=_.model,Q=T.trim().length===0?"a new model":T,z=T.trim().length>0&&e?.modelAllowlist!==null&&e?.modelAllowlist!==void 0&&!e.modelAllowlist.includes(T);return ce(_t,{$gap:2,role:"group","aria-label":`Override for ${Q}`,children:[ce(o,{$gap:2,$align:"flex-end",children:[G(m,{label:"Model",children:(O)=>G(tt,{...O,disabled:c.isPending,value:_.model,placeholder:"model name",suggestions:B,onValueChange:(j)=>V(_.id,{model:j})})}),G(n,{type:"button",$variant:"ghost",disabled:c.isPending,"aria-label":`Remove override for ${Q}`,onClick:()=>w((O)=>O.filter((j)=>j.id!==_.id)),children:"Remove"})]}),z?ce(Dt,{children:[T," is not in this key's allowed models, so this override applies to no request until it is."]}):null,G(ye,{draft:_.slots,onChange:(O)=>V(_.id,{slots:O}),disabled:c.isPending})]},_.id)}),G("div",{children:G(n,{type:"button",disabled:c.isPending,onClick:()=>{w((_)=>[..._,{id:`added-${A}`,model:"",stored:null,slots:Pt({})}]),R((_)=>_+1)},children:"Add model override"})})]}),N===null?null:G(Lt,{role:"alert",children:N})]})})}import{useState as ze}from"react";import zt from"styled-components";import Be from"styled-components";import{jsx as _e,jsxs as ot}from"react/jsx-runtime";var Nt=Be.div.withConfig({displayName:"ModelPicker__Choices"})(["display:flex;flex-direction:column;gap:2px;max-height:190px;overflow-y:auto;padding:",";border:1px solid ",";border-radius:",";background:",";"],({theme:e})=>e.space(1),({theme:e})=>e.color.ruleStrong,({theme:e})=>e.radius.control,({theme:e})=>e.color.panelSunk),Tt=Be.label.withConfig({displayName:"ModelPicker__Choice"})(["display:flex;align-items:center;gap:",";padding:4px 6px;border-radius:2px;cursor:pointer;font-family:",";font-size:12px;&:hover{background:",";}"],({theme:e})=>e.space(2),({theme:e})=>e.font.mono,({theme:e})=>e.color.panelRaised),Bt=Be.p.withConfig({displayName:"ModelPicker__Hint"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim);function De({configured:e,checked:u,onChange:c,disabled:f}){let g=[...new Set([...e,...u])].sort(),L=(w,A)=>{c(A?[...u,w]:u.filter((R)=>R!==w))},y=u.filter((w)=>!e.includes(w));return ot("div",{children:[_e(Nt,{children:g.map((w)=>ot(Tt,{children:[_e("input",{type:"checkbox",disabled:f,"aria-label":w,checked:u.includes(w),onChange:(A)=>L(w,A.target.checked)}),w]},w))}),y.length>0?_e(Bt,{children:"Some listed models are no longer configured. They stay until you clear them."}):null,u.length===0?_e(t,{children:"With nothing selected this key is allowed no model."}):null]})}import{jsx as se,jsxs as Ae,Fragment as Ot}from"react/jsx-runtime";var Ft=zt.p.withConfig({displayName:"EditModelsDialog__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down);function it({apiKey:e,onOpenChange:u}){let c=xn(),f=H(),[g,L]=ze(e?.modelAllowlist===null),[y,w]=ze(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[A,R]=ze(null),N=(f.data??[]).map((B)=>B.id),F=()=>{if(e===null)return;R(null),c.mutate({id:e.id,modelAllowlist:g?null:y},{onSuccess:()=>u(!1),onError:(B)=>R(h(B))})};return se(J,{open:e!==null,onOpenChange:u,title:"Edit models",description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:"640px",footer:Ae(Ot,{children:[se(n,{type:"button",onClick:()=>u(!1),children:"Cancel"}),se(n,{type:"button",$variant:"primary",disabled:c.isPending,onClick:F,children:c.isPending?"Saving…":"Save models"})]}),children:Ae(r,{$gap:3,children:[Ae(r,{$gap:2,children:[Ae(o,{$gap:2,children:[se(W,{checked:g,label:"Allow every model",onCheckedChange:(B)=>{if(L(B),B)w([])}}),se(t,{as:"span",children:"Allow every model"})]}),g?null:se(De,{configured:N,checked:y,onChange:w,disabled:c.isPending})]}),A===null?null:se(Ft,{role:"alert",children:A})]})})}import{Fragment as It}from"react";import Re from"styled-components";import{jsx as oe,jsxs as Fe}from"react/jsx-runtime";var Kt=Re.div.withConfig({displayName:"LimitMatrix__Grid"})(["display:grid;grid-template-columns:minmax(0,11rem) minmax(0,12rem) minmax(0,1fr) minmax(0,3.5rem);align-items:center;gap:"," ",";"],({theme:e})=>e.space(2),({theme:e})=>e.space(4)),qt=Re.span.withConfig({displayName:"LimitMatrix__Absent"})(["font-size:11.5px;color:",";"],({theme:e})=>e.color.inkDim),Gt=Re.h4.withConfig({displayName:"LimitMatrix__Heading"})(["font-family:",";font-size:12px;font-weight:600;color:",";"],({theme:e})=>e.font.mono,({theme:e})=>e.color.ink),Ht=Re.p.withConfig({displayName:"LimitMatrix__Note"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim);function nt({label:e,readings:u}){let c=lr(u),f=c.some((g)=>g.model!==null);return Fe(r,{$gap:3,children:[c.map((g)=>{let L=g.model??"Every model",y=oe(Ut,{label:e,model:g.model,readings:g.readings},L);return f?Fe(r,{$gap:2,role:"group","aria-label":L,children:[oe(Gt,{children:L}),y]},L):y}),oe(Ht,{children:"Usage counts completed requests still inside each window. Requests in flight are added by the gateway itself and are not shown here. A model's override stacks with the key-wide limits: a request for it must pass both."})]})}function Ut({label:e,model:u,readings:c}){let f=u===null?e:`${e}, ${u}`;return oe(Kt,{children:c.map((g)=>{let L=Rt({dimension:g.dimension,window:g.window}),y=cr(g),w=ur(g.dimension,g.limit);return Fe(It,{children:[oe(t,{as:"span",children:L}),oe(d,{children:g.used===null?w:`${ur(g.dimension,g.used)} of ${w}`}),y===null?oe(qt,{children:"in flight now, counted in the gateway process"}):oe(re,{fraction:Math.min(1,y),label:`${f}, ${L}, ${Math.round(y*100)}% used`}),oe(d,{children:y===null?"—":`${Math.round(y*100)}%`})]},L)})})}import{useState as ie}from"react";import ke from"styled-components";import{jsx as D,jsxs as Y,Fragment as lt}from"react/jsx-runtime";var Wt=ke.p.withConfig({displayName:"MintKeyDialog__Warning"})(["font-size:12px;color:",";"],({theme:e})=>e.color.warn),Vt=ke.p.withConfig({displayName:"MintKeyDialog__Hint"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),Yt=ke.p.withConfig({displayName:"MintKeyDialog__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),Xt=ke.p.withConfig({displayName:"MintKeyDialog__Once"})(["font-size:12px;color:",";"],({theme:e})=>e.color.inkDim),Jt=ke(n).withConfig({displayName:"MintKeyDialog__Disclosure"})(["gap:4px;"]);function rt({open:e,onOpenChange:u}){let c=H(),f=yn(),[g,L]=ie(""),[y,w]=ie(!0),[A,R]=ie([]),[N,F]=ie(()=>Pt({})),[B,V]=ie(!1),[X,_]=ie(""),[T,Q]=ie(!1),[z,O]=ie(null),[j,ne]=ie(null),te=()=>{L(""),w(!0),R([]),F(Pt({})),V(!1),_(""),Q(!1),O(null),ne(null),f.reset()},pe=(a)=>{if(!a)te();u(a)},ue=Object.values(N).filter((a)=>a.trim().length>0).length,Ne=()=>{let a=dr(N);if("problem"in a){V(!0),ne(a.problem);return}let K=xe(X);if("problem"in K){ne(K.problem);return}ne(null),f.mutate({label:g.trim().length===0?"api key":g.trim(),modelAllowlist:y?null:A,limits:a.limits,bodyLoggingOptOut:T,expiresAt:K.at},{onSuccess:(ge)=>O(ge),onError:(ge)=>ne(h(ge))})};return D(J,{open:e,onOpenChange:pe,title:z===null?"Create an API key":"Key created",description:z===null?"Clients send this key as a bearer token or as x-api-key on every /v1 request.":void 0,footer:z===null?Y(lt,{children:[D(n,{type:"button",onClick:()=>pe(!1),children:"Cancel"}),D(n,{type:"button",$variant:"primary",disabled:f.isPending,onClick:Ne,children:f.isPending?"Creating…":"Create key"})]}):D(n,{type:"button",$variant:"primary",onClick:()=>pe(!1),children:"I have copied the key"}),children:z===null?Y(r,{$gap:3,children:[D(m,{label:"Label",hint:"Names the client this key belongs to, e.g. laptop or CI.",children:(a)=>D(v,{...a,value:g,placeholder:"api key",onChange:(K)=>L(K.target.value)})}),Y(r,{$gap:2,children:[Y(o,{$gap:2,children:[D(W,{checked:y,label:"Allow every model",onCheckedChange:w}),D(t,{as:"span",children:"Allow every model"})]}),y?null:Y(lt,{children:[D(De,{configured:(c.data??[]).map((a)=>a.id),checked:A,onChange:R}),A.length===0?D(Wt,{children:"With no model selected this key is allowed nothing and every request it makes will be refused."}):null]})]}),Y(r,{$gap:2,children:[Y(o,{$gap:2,children:[Y(Jt,{type:"button",$size:"sm","aria-expanded":B,onClick:()=>V((a)=>!a),children:[B?D($e,{}):D(Le,{}),"Limits"]}),D(t,{as:"span",children:ue===0?"no limits; this key is unbounded":`${ue} limit${ue===1?"":"s"} set`})]}),B?D(ye,{draft:N,onChange:F}):null]}),D(m,{label:"Expires",hint:"Optional. Your local time; blank means the key never expires.",children:(a)=>D(v,{...a,type:"datetime-local",value:X,onChange:(K)=>_(K.target.value)})}),Y(r,{$gap:2,children:[Y(o,{$gap:2,children:[D(W,{checked:T,label:"Never record this key's bodies",onCheckedChange:Q}),D(t,{as:"span",children:"Never record this key's bodies"})]}),D(Vt,{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."})]}),j===null?null:D(Yt,{role:"alert",children:j})]}):Y(r,{$gap:3,children:[D(Xt,{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."}),D(xr,{value:z.key,label:"Copy API key"}),Y(o,{$gap:2,children:[D(t,{children:"Label"}),D(d,{children:z.label}),D(t,{children:"Prefix"}),D(d,{children:z.prefix})]})]})})}import{jsx as p,jsxs as U,Fragment as st}from"react/jsx-runtime";var at=me(o).withConfig({displayName:"KeysBoard__Allow"})(["gap:4px;flex-wrap:wrap;max-width:34ch;"]),jt=me.span.withConfig({displayName:"KeysBoard__Revoked"})(["color:",";"],({theme:e})=>e.color.inkFaint),eo=me.span.withConfig({displayName:"KeysBoard__Expires"})(["display:block;font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),to=me.span.withConfig({displayName:"KeysBoard__Nearest"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),oo=me.div.withConfig({displayName:"KeysBoard__Summary"})(["display:flex;flex-direction:column;align-items:flex-end;gap:2px;"]);function io(e){if(e===null)return"usage not counted here";let u=cr(e),c=zn(e),f=ur(e.dimension,e.limit);return`${c} ${f}, ${u===null?"—":Math.round(u*100)}% used`}function dt(e,u){if(e===void 0)return null;if(!e.smartRouterEnabled)return"Confidential routing is switched off in Settings; these keys' requests are not screened.";let c=(g,L,y)=>L===null?[`the ${g} model is not set`]:y==="unresolved"?[`the ${g} model does not resolve`]:y==="notLocal"?[`the ${g} model is not local-only`]:[],f=[...c("classifier",e.smartRouterClassifierModel,u?.classifier),...c("local",e.smartRouterLocalModel,u?.local)];if(f.length===0)return null;return`Confidential routing is misconfigured (${f.join(" and ")}); these keys' requests are refused.`}function no(e,u){let f=dt(e,u);return f===null?"Requests from this key are screened for confidential content and answered by the local model when any is found.":`${f} Requests from this key are screened for confidential content and answered by the local model when any is found.`}var lo=me.p.withConfig({displayName:"KeysBoard__Failed"})(["padding:0 ",";font-size:12px;color:",";"],({theme:e})=>e.space(2),({theme:e})=>e.color.down),ro=me.p.withConfig({displayName:"KeysBoard__Inert"})(["padding:0 ",";font-size:12px;color:",";"],({theme:e})=>e.space(2),({theme:e})=>e.color.warn);function ut(){let e=we(),u=he(),c=Qt(),f=Sn(),g=Cn(),[L,y]=le(null),[w,A]=le(!1),[R,N]=le(null),[F,B]=le(null),[V,X]=le(null),[_,T]=le(null),[Q,z]=le(null),[O,j]=le(null),ne=Date.now(),te=e.data??[],pe=te.some((a)=>a.revokedAt===null&&a.smartRouting)?dt(u.data,c.data):null,ue=te.filter((a)=>fe(a,ne)==="active"),Ne=e.isLoading?"Reading issued keys…":te.length===0?"No keys exist, so nothing can call this gateway yet.":`${ue.length} active key${ue.length===1?"":"s"} of ${te.length} ever issued.`;return U(st,{children:[p(k,{legend:"Keys",title:"Gateway API keys",summary:Ne,actions:U(n,{type:"button",$variant:"primary",onClick:()=>A(!0),children:[p(Qe,{}),"Create a key"]})}),pe===null?null:p(ro,{role:"status",children:pe}),L===null?null:p(lo,{role:"alert",children:L}),p(pt,{legend:"Issued keys",meta:`${te.length}`,flush:!0,children:e.isError?p(x,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?p("div",{style:{padding:12},children:p(b,{rows:4})}):te.length===0?p(I,{legend:"No keys",message:"Create a key and give it to a client. The key is shown once, at creation.",action:p(n,{type:"button",$variant:"primary",$size:"sm",onClick:()=>A(!0),children:"Create a key"})}):p(mt,{children:U(q,{children:[p("thead",{children:U("tr",{children:[p(l,{children:"Label"}),p(l,{children:"Prefix"}),p(l,{children:"Allowed models"}),p(l,{$align:"right",children:"Limits"}),p(l,{$align:"right",children:"Created"}),p(l,{children:"Body capture"}),p(l,{children:"Checks"}),p(l,{children:"Status"}),p(l,{})]})}),p("tbody",{children:te.map((a)=>{let K=Q===a.id,ge=Wn(a.limitUsage),Te=fe(a,ne);return U(Zt,{children:[U(E,{children:[p(s,{children:p(M,{style:{maxWidth:"24ch",display:"block"},children:a.label})}),U(s,{$mono:!0,children:[a.prefix,"…"]}),p(s,{children:a.modelAllowlist===null?p(t,{children:"every model"}):a.modelAllowlist.length===0?p(C,{$tone:"down",children:"no models"}):p(at,{children:a.modelAllowlist.map((ve)=>p(C,{children:ve},ve))})}),p(s,{$align:"right",children:a.limits===null?p(C,{$tone:"down",children:"unreadable"}):a.limitUsage.length===0?p(t,{children:"no limits"}):U(oo,{children:[U("span",{children:[a.limitUsage.length," limit",a.limitUsage.length===1?"":"s"]}),p(to,{children:io(ge)})]})}),p(s,{$align:"right",$mono:!0,children:Ce(a.createdAt)}),p(s,{children:a.bodyLoggingOptOut?p(C,{children:"no bodies"}):p(t,{children:"—"})}),p(s,{children:a.guardrailPolicy===null&&!a.smartRouting?p(t,{children:"—"}):U(at,{children:[a.guardrailPolicy===null?null:p(C,{title:a.guardrailPolicy,children:"judged"}),a.smartRouting?p(C,{title:no(u.data,c.data),children:"local-routed"}):null]})}),U(s,{children:[Te==="revoked"?p(jt,{title:Ce(a.revokedAt??0),children:p(C,{children:"revoked"})}):Te==="expired"?p(C,{$tone:"down",children:"expired"}):p(C,{$tone:"ok",children:"active"}),a.expiresAt===null?null:U(eo,{children:[Te==="expired"?"expired":"expires"," ",Ce(a.expiresAt)]})]}),p(s,{$align:"right",children:U(o,{$gap:1,$justify:"flex-end",children:[a.limitUsage.length===0?null:p(P,{type:"button",$variant:"ghost",$size:"sm","aria-expanded":K,"aria-label":`${K?"Hide":"Show"} limits for ${a.label}`,title:`${K?"Hide":"Show"} limits for ${a.label}`,onClick:()=>z(K?null:a.id),children:K?p($e,{}):p(Le,{})}),a.revokedAt===null?U(st,{children:[p(P,{type:"button",$variant:"ghost",$size:"sm","aria-label":`Edit models for ${a.label}`,title:`Edit models for ${a.label}`,onClick:()=>B(a),children:p(qe,{})}),p(P,{type:"button",$variant:"ghost",$size:"sm","aria-label":`Edit limits for ${a.label}`,title:`Edit limits for ${a.label}`,onClick:()=>N(a),children:p(bt,{})}),p(P,{type:"button",$variant:"ghost",$size:"sm","aria-label":`Edit expiry for ${a.label}`,title:`Edit expiry for ${a.label}`,onClick:()=>X(a),children:p(Ie,{})}),p(W,{checked:a.smartRouting,disabled:g.isPending,label:`Confidential routing for ${a.label}`,onCheckedChange:(ve)=>{y(null),g.mutate({id:a.id,enabled:ve},{onError:(ct)=>y(`Could not change confidential routing for "${a.label}": ${h(ct)}`)})}}),p(P,{type:"button",$variant:"ghost",$size:"sm","aria-label":`Edit usage policy for ${a.label}`,title:`Edit usage policy for ${a.label}`,onClick:()=>T(a),children:p(He,{})}),p(n,{type:"button",$variant:"danger",$size:"sm",onClick:()=>j(a),children:"Revoke"})]}):null]})})]}),K?p(E,{children:p(s,{colSpan:9,children:p(nt,{label:a.label,readings:a.limitUsage})})}):null]},a.id)})})]})})}),p(rt,{open:w,onOpenChange:A}),p(et,{apiKey:R,onOpenChange:(a)=>{if(!a)N(null)}},R?.id??"limits-none"),p(it,{apiKey:F,onOpenChange:(a)=>{if(!a)B(null)}},F?.id??"models-none"),p(Xe,{apiKey:V,onOpenChange:(a)=>{if(!a)X(null)}},V?.id??"expiry-none"),p(Ze,{apiKey:_,onOpenChange:(a)=>{if(!a)T(null)}},_?.id??"policy-none"),p(ee,{open:O!==null,onOpenChange:(a)=>{if(!a)j(null)},title:"Revoke key",body:O===null?"":`Revoking "${O.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:"Revoke key",busy:f.isPending,onConfirm:()=>{if(O===null)return;f.mutate(O.id,{onSettled:()=>j(null)})}})]})}var gn=ut;export{gn as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,t,se,o,r,p,pe,we,_o,rt,ot,Yt,Fo,$o,a,O,at,X,I,x,b,J,k,pt,mt,f}from"/assets/index-p9vbm21a.js";import{R}from"/assets/index-f7t0kve8.js";import"/assets/index-8bewp9z1.js";import{C}from"/assets/index-fcew0gga.js";import{fr,pr,mr,hr,gr}from"/assets/index-sbe0ydnc.js";import"/assets/index-t1cs42r4.js";import"/assets/index-xdyjb1an.js";import"/assets/index-zkt5p0qd.js";import{useMemo as G,useRef as Y,useState as M}from"react";import A from"styled-components";import y from"styled-components";import{jsx as i,jsxs as g}from"react/jsx-runtime";var te={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."}},z=new Intl.NumberFormat("en-US"),N=y.p.withConfig({displayName:"BodyArtifact__Note"})(["font-size:12px;color:",";max-width:62ch;"],({theme:e})=>e.color.inkDim),oe=y(N).withConfig({displayName:"BodyArtifact__Caveat"})(["border-left:2px solid ",";padding-left:",";"],({theme:e})=>e.color.ruleStrong,({theme:e})=>e.space(2)),re=y.h4.withConfig({displayName:"BodyArtifact__Heading"})(["font-size:11px;font-weight:600;letter-spacing:0.12em;text-transform:uppercase;color:",";margin:0;"],({theme:e})=>e.color.inkDim),ne=y.figcaption.withConfig({displayName:"BodyArtifact__Caption"})(["display:flex;align-items:center;gap:",";flex-wrap:wrap;margin-bottom:4px;"],({theme:e})=>e.space(2)),ae=y.figure.withConfig({displayName:"BodyArtifact__Figure"})(["margin:0;min-width:0;"]),ie=y.pre.withConfig({displayName:"BodyArtifact__Payload"})(["margin:0;padding:",";max-height:260px;overflow:auto;border:1px solid ",";border-radius:",";background:",";font-family:",";font-size:11.5px;line-height:1.5;white-space:pre-wrap;word-break:break-word;"],({theme:e})=>e.space(2),({theme:e})=>e.color.rule,({theme:e})=>e.radius.control,({theme:e})=>e.color.panelSunk,({theme:e})=>e.font.mono);function le(e){if(e===null||typeof e!=="object"||Array.isArray(e))return null;let s=e;if(s.omitted!==!0||typeof s.reason!=="string")return null;let l=s.serializedBytes;return{omitted:!0,reason:s.reason,serializedBytes:typeof l==="number"?l:0}}function h({title:e,stage:s,value:l}){let w=le(l);return g(ae,{children:[g(ne,{children:[i(re,{children:e}),s===void 0?null:i(C,{children:s})]}),w!==null?g(N,{children:["Too large to keep: ",w.reason,". The payload was"," ",z.format(w.serializedBytes)," bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace."]}):l===null||l===void 0?i(N,{children:"Nothing was recorded for this half — it never happened, or never completed."}):i(ie,{children:JSON.stringify(l,null,2)})]})}function de({attempt:e}){return g(r,{$gap:2,children:[g(o,{$gap:2,$wrap:!0,children:[g(t,{as:"h3",children:["Attempt ",e.attempt," · ",e.provider]}),e.truncated?i(C,{$tone:"warn",children:"truncated"}):null]}),i(h,{title:"Request sent to the provider",stage:"post-RTK",value:e.request}),i(h,{title:"Response from the provider",value:e.response}),e.streamChunks===null?null:i(h,{title:`Raw stream frames (${a(e.streamChunks.length)})`,value:e.streamChunks})]})}function ue({body:e}){let s=e.artifact;if(s===null){let l=te[e.detailState==="ready"?"corrupt":e.detailState];return g(r,{$gap:1,children:[i(t,{children:l.legend}),i(N,{children:l.message})]})}return g(r,{$gap:3,children:[s.attempts.length===0?null:i(oe,{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."}),g(r,{$gap:2,children:[g(o,{$gap:2,$wrap:!0,children:[i(t,{as:"h3",children:"Client"}),s.client.truncated?i(C,{$tone:"warn",children:"truncated"}):null]}),i(h,{title:"Request from the client",stage:"pre-RTK",value:s.client.request}),i(h,{title:"Response returned to the client",value:s.client.response})]}),s.attempts.map((l)=>i(de,{attempt:l},`${l.attempt}-${l.provider}`)),s.error===null||s.error===void 0?null:i(h,{title:"Error",value:s.error})]})}function K({requestId:e}){let s=$o(e),l=s.data===void 0||s.data.detailState!=="ready"?void 0:`${z.format(s.data.sizeBytes)} bytes on disk`;return i(f,{legend:"Captured bodies",...l===void 0?{}:{meta:l},...s.data?.truncated===!0?{actions:i(C,{$tone:"warn",children:"truncated"})}:{},children:s.isError?i(x,{error:s.error,onRetry:()=>void s.refetch()}):s.isPending?i(b,{rows:3}):i(ue,{body:s.data})})}import{jsx as u,jsxs as q,Fragment as ye}from"react/jsx-runtime";var ce=[50,100,250,500],ge=160,me=A(o).withConfig({displayName:"LogsBoard__Controls"})(["gap:",";flex-wrap:wrap;"],({theme:e})=>e.space(2)),fe=A(R).withConfig({displayName:"LogsBoard__Narrow"})(["width:auto;"]),he=A(o).withConfig({displayName:"LogsBoard__More"})(["justify-content:center;gap:",";padding:",";"],({theme:e})=>e.space(2),({theme:e})=>e.space(3));function U(){let{cadence:e,live:s}=X(),[l,w]=M(100),[B,W]=M(fr),[v,S]=M(null),L=Y(!1),c=Fo(B,l,e(rt,"res:logs")),m=G(()=>(c.data?.pages??[]).flatMap((d)=>d.logs),[c.data?.pages]),_=!ot(c.data),j=Yt(p.logPages(B,l)),E=Y(null),V=()=>{E.current?.scrollTo({top:0}),j()},P=pe(),F=we(),Q=_o(),Z=mr(s&&m.some(O)),H=G(()=>({accounts:new Map((P.data??[]).map((d)=>[d.id,d.label])),keys:new Map((F.data??[]).map((d)=>[d.id,d.label]))}),[P.data,F.data]),ee=m.filter(at).length,D=m.filter(O).length;return q(ye,{children:[u(k,{legend:"Logs",title:"Recent requests",summary:c.isLoading?"Reading the request log…":`${a(m.length)} requests loaded, ${a(ee)} of them failed${D===0?"":`, ${a(D)} still running`}. ${Q.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:q(me,{children:[u(pr,{filters:B,onChange:W,operator:!0}),u(fe,{value:l,"aria-label":"How many requests per page",options:ce.map((d)=>({value:String(d),label:`${d} per page`})),onValueChange:(d)=>w(Number(d))}),_?u(n,{type:"button",onClick:V,children:"Back to live"}):null]})}),u(pt,{legend:"Request log",meta:`${m.length} shown`,flush:!0,children:c.isError?u(x,{error:c.error,onRetry:()=>void c.refetch()}):c.isLoading?u("div",{style:{padding:12},children:u(b,{rows:8})}):m.length===0?u(I,{legend:"Nothing to show",message:Object.keys(B).length===0?"No requests have reached the gateway yet.":"No request matches these filters. Clear them to see everything."}):q(mt,{ref:E,"data-testid":"request-log-scroller",onScroll:(d)=>{let T=d.currentTarget;if(T.scrollHeight-T.scrollTop-T.clientHeight>ge)return;if(!c.hasNextPage)return;if(L.current)return;L.current=!0,c.fetchNextPage().finally(()=>{L.current=!1})},children:[u(hr,{rows:m,now:Z,names:H,onOpen:S}),c.isFetchingNextPage||_?q(he,{children:[c.isFetchingNextPage?u(se,{children:"Loading older requests…"}):null,_?u(se,{children:"Live updates are paused while older pages are loaded."}):null]}):null]})}),u(J,{open:v!==null,onOpenChange:(d)=>{if(!d)S(null)},title:"Request detail",width:"760px",footer:u(n,{type:"button",onClick:()=>S(null),children:"Close"}),children:v===null?null:u(gr,{log:v,names:H,children:u(K,{requestId:v.id})})})]})}var We=U;export{We as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,P,t,d,o,r,S,M,fe,z,pe,H,he,mn,hn,gn,i,On,oe,I,h,x,b,ee,k,f}from"/assets/index-p9vbm21a.js";import{R,tt}from"/assets/index-f7t0kve8.js";import{W}from"/assets/index-dq2f7yk0.js";import{C,vt}from"/assets/index-fcew0gga.js";import{re}from"/assets/index-wjqdtafp.js";import{v,m,de}from"/assets/index-8bewp9z1.js";import{br}from"/assets/index-85cnhw3e.js";import{Qe}from"/assets/index-0j7sghrn.js";import{xt}from"/assets/index-nnpqs2w6.js";var Te={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};Te.node;var $e=i(Te);import{useEffect as bt,useState as yt}from"react";import le from"styled-components";import{useState as ge}from"react";import X from"styled-components";import{jsx as E,jsxs as B}from"react/jsx-runtime";var Pe=["tier","health","quota","cost","latency","load"],Xe={tier:"How preferred this tier is",health:"Consecutive failures and breaker state",quota:"Headroom in the tightest window, against how much of it is left",cost:"Price of this request against the other candidates",latency:"Observed time to first token",load:"Requests in flight on this pair right now"},Ye=X.li.withConfig({displayName:"ExplainPanel__Candidate"})(["padding:"," 0;border-bottom:1px solid ",";&:last-child{border-bottom:0;}"],({theme:e})=>e.space(2),({theme:e})=>e.color.rule),Ze=X(d).withConfig({displayName:"ExplainPanel__Rank"})(["width:22px;color:",";flex:none;"],({theme:e})=>e.color.inkFaint),et=X(C).withConfig({displayName:"ExplainPanel__Winner"})(["border-color:",";color:",";background:",";"],({theme:e})=>e.color.ok,({theme:e})=>e.color.ok,({theme:e})=>e.color.okWash),ot=X.div.withConfig({displayName:"ExplainPanel__Terms"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(112px,1fr));gap:",";margin-top:",";padding-left:30px;"],({theme:e})=>e.space(2),({theme:e})=>e.space(2)),nt=X.div.withConfig({displayName:"ExplainPanel__TermCell"})(["display:flex;flex-direction:column;gap:3px;min-width:0;"]),rt=X.div.withConfig({displayName:"ExplainPanel__TermHead"})(["display:flex;align-items:baseline;justify-content:space-between;gap:6px;"]),it=X.li.withConfig({displayName:"ExplainPanel__Excluded"})(["display:flex;align-items:center;gap:",";padding:5px 0;"],({theme:e})=>e.space(2)),at=X(o).withConfig({displayName:"ExplainPanel__Probe"})(["gap:",";flex-wrap:wrap;"],({theme:e})=>e.space(3)),be=X.label.withConfig({displayName:"ExplainPanel__Toggled"})(["display:flex;align-items:center;gap:6px;cursor:pointer;font-size:12.5px;"]),lt=X.p.withConfig({displayName:"ExplainPanel__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down);function Se(e,a,c){return(e[a]??0)*c[a]}function Re({modelId:e}){let[a,c]=ge({tools:!1,images:!1,reasoning:!1}),[l,s]=ge(null),[w,q]=ge(null),N=he(),V=gn(),u=N.data?.weights,Q=()=>{if(e===null)return;q(null),V.mutate({modelId:e,need:a},{onSuccess:(y)=>s(y),onError:(y)=>{s(null),q(h(y))}})},G=new Map(Pe.map((y)=>[y,Math.max(0.0001,...(l?.candidates??[]).map((j)=>u===void 0?0:Math.abs(Se(j.reasons,y,u))))]));return E(f,{legend:"Explain",meta:e??"no model selected",actions:B(n,{type:"button",$size:"sm",$variant:"primary",disabled:e===null||V.isPending,onClick:Q,children:[E($e,{}),V.isPending?"Ranking…":"Rank candidates"]}),children:B(r,{$gap:3,children:[B(r,{$gap:1,children:[E(t,{children:"Pretend the request needs"}),B(at,{children:[B(be,{children:[E(W,{checked:a.tools,label:"Probe request uses tools",onCheckedChange:(y)=>c({...a,tools:y})}),"Tools"]}),B(be,{children:[E(W,{checked:a.images,label:"Probe request includes an image",onCheckedChange:(y)=>c({...a,images:y})}),"Images"]}),B(be,{children:[E(W,{checked:a.reasoning,label:"Probe request asks for reasoning",onCheckedChange:(y)=>c({...a,reasoning:y})}),"Reasoning"]})]})]}),w===null?null:E(lt,{children:w}),l===null?E(I,{legend:"Not ranked yet",message:e===null?"Select a model to see which account the router would pick for it.":"Run the ranking to see which account wins, by how much, and what was filtered out."}):B(r,{$gap:3,children:[B(o,{$gap:2,$wrap:!0,children:[E(C,{$tone:"accent",children:l.strategy}),l.deterministic?null:E(C,{$tone:"warn",children:"order varies per request"}),E(S,{}),B(t,{children:[l.candidates.length," eligible · ",l.excluded.length," filtered out"]})]}),l.candidates.length===0?E(I,{legend:"Nothing eligible",message:"Every target was filtered out. The reasons below say which rule removed each one."}):E("ul",{children:l.candidates.map((y,j)=>B(Ye,{children:[B(o,{$gap:2,children:[E(Ze,{children:j+1}),E(vt,{provider:y.provider}),E(M,{style:{maxWidth:"22ch"},children:y.credentialLabel}),E(d,{$dim:!0,children:y.model}),B(C,{children:["tier ",y.tier]}),E(S,{}),j===0?E(et,{children:"would be used"}):null,E(d,{children:y.score.toFixed(2)})]}),u===void 0?null:E(ot,{children:Pe.map((L)=>{let D=Se(y.reasons,L,u),U=G.get(L)??1;return B(nt,{title:Xe[L],children:[B(rt,{children:[E(t,{children:L}),E(d,{$dim:!0,$size:"10.5px",children:D.toFixed(2)})]}),E(re,{fraction:Math.abs(D)/U,height:4,tone:"var(--accent)",label:`${L} contributes ${D.toFixed(2)} of ${y.score.toFixed(2)}`})]},L)})})]},`${y.credentialId}:${y.model}`))}),l.excluded.length===0?null:B(r,{$gap:1,children:[E(t,{children:"Filtered out"}),E("ul",{children:l.excluded.map((y)=>B(it,{children:[E(d,{$dim:!0,children:y.model}),E(d,{$dim:!0,children:y.credentialId}),E(S,{}),E(C,{$tone:y.reason.startsWith("capability")?"warn":"down",children:y.reason})]},`${y.credentialId}:${y.model}:${y.reason}`))})]})]})]})})}import{useEffect as mt,useState as ce}from"react";import ue from"styled-components";function Ee(e,a,c){return z(e,a)?.models.find((l)=>l.id===c)}function Ie(e,a,c){let l=z(e,a);if(l===void 0)return null;return l.models.find((s)=>s.id===c)?.auth??l.authTypes}var ye=[{id:"score",label:"Best score",blurb:"Rank every eligible target by the routing weights and take the best one."},{id:"priority",label:"Lowest tier",blurb:"Always prefer the lowest tier. Score only breaks ties inside a tier."},{id:"roundRobin",label:"Round robin",blurb:"Take whichever eligible target has been idle longest, to spread load evenly."},{id:"weighted",label:"Weighted draw",blurb:"Pick at random, biased by weight. The order differs from request to request."}],Me=0;function We(){return Me+=1,`target-${Me}`}function se(e,a,c){let l=Ee(e,a,c)?.pricing;if(l===void 0)return null;return{costInput:String(l.input),costOutput:String(l.output),costCacheRead:String(l.cacheRead),costCacheWrite5m:String(l.cacheWrite5m),costCacheWrite1h:String(l.cacheWrite1h)}}function _e(e,a,c){let l=Ee(e,a,c)?.limits;if(l===void 0)return null;return{contextWindow:String(l.contextWindow),maxOutputTokens:String(l.maxOutputTokens)}}var st={oauth:"OAuth",apiKey:"an API key"};function Ne(e){return e.map((a)=>st[a]).join(" or ")}function De(e){let a=Object.create(null);for(let c of e){let l=a[c.provider]??[];if(!l.includes(c.authType))l.push(c.authType);a[c.provider]=l}return a}function Ae(e,a,c,l){let s=l[a];if(s===void 0||s.length===0)return!0;let w=Ie(e,a,c);if(w===null)return!0;return w.some((q)=>s.includes(q))}function Le(e,a,c){let l=z(e,a);if(l===void 0)return[];return l.models.filter((s)=>Ae(e,a,s.id,c))}function Oe(e,a,c,l){if(c.trim().length===0||Ae(e,a,c,l))return null;let s=l[a]??[],w=Ie(e,a,c)??[];return`${a} serves this model to ${Ne(w)} only, and every ${a} account here is ${Ne(s)}. Requests routed here will fail.`}function Ce(e,a){let c={provider:e.provider,endpointId:e.endpointId};return a.filter((l)=>On(c,l)).map((l)=>({id:l.id,label:l.accountEmail??l.label}))}function Fe(e,a,c){if(e.length===0)return null;if(c.length===0)return null;if(Ce(a,c).some((l)=>l.id===e))return null;return"No connected account has this id. Requests routed here will fail rather than falling back to another account."}function Be(e,a){return{...e,endpointId:a,...a===e.endpointId?{}:{credentialId:""}}}function ze(e,a,c){return{...a,...c,...se(e,c.provider,c.model)??{},...c.provider===a.provider?{}:{credentialId:""},contextWindow:"",maxOutputTokens:""}}function ve(e,a){let c=a??(e[0]?.id??"anthropic"),l=z(e,c)?.defaultModel??"",s=se(e,c,l);return{key:We(),provider:c,endpointId:"",model:l,tier:"1",weight:"1",costInput:s?.costInput??"0",costOutput:s?.costOutput??"0",costCacheRead:s?.costCacheRead??"",costCacheWrite5m:s?.costCacheWrite5m??"",costCacheWrite1h:s?.costCacheWrite1h??"",contextWindow:"",maxOutputTokens:"",credentialId:"",tools:!0,images:!0,reasoning:!0}}function xe(e){return{id:"",strategy:"score",isAlias:!1,targets:[ve(e)]}}function ke(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map((a)=>({key:We(),provider:a.provider,endpointId:a.provider==="custom"?a.endpointId??"":"",model:a.model,tier:String(a.tier),weight:String(a.weight),costInput:String(a.costPerMTok.input),costOutput:String(a.costPerMTok.output),costCacheRead:a.costPerMTok.cacheRead===void 0?"":String(a.costPerMTok.cacheRead),costCacheWrite5m:a.costPerMTok.cacheWrite5m===void 0?"":String(a.costPerMTok.cacheWrite5m),costCacheWrite1h:a.costPerMTok.cacheWrite1h===void 0?"":String(a.costPerMTok.cacheWrite1h),contextWindow:a.contextWindow===void 0?"":String(a.contextWindow),maxOutputTokens:a.maxOutputTokens===void 0?"":String(a.maxOutputTokens),credentialId:a.credentialId??"",tools:a.capabilities.tools,images:a.capabilities.images,reasoning:a.capabilities.reasoning}))}}function qe(e){let a=e.id.trim();if(a.length===0)return{ok:!1,problem:"Give the model a name clients will ask for."};if(e.targets.length===0)return{ok:!1,problem:"A model needs at least one target to route to."};let c=[];for(let[l,s]of e.targets.entries()){let w=`Target ${l+1}`,q=s.endpointId.trim(),N=s.credentialId.trim();if(s.provider==="custom"&&q.length===0)return{ok:!1,problem:`${w} needs a custom endpoint.`};let V=s.model.trim();if(V.length===0)return{ok:!1,problem:`${w} needs a provider model name.`};let u=Number(s.tier);if(!Number.isInteger(u)||u<1)return{ok:!1,problem:`${w}: tier must be a whole number of 1 or more.`};let Q=Number(s.weight);if(!Number.isFinite(Q)||Q<=0)return{ok:!1,problem:`${w}: weight must be greater than zero.`};let G=Number(s.costInput),y=Number(s.costOutput);if(!Number.isFinite(G)||G<0||!Number.isFinite(y)||y<0)return{ok:!1,problem:`${w}: prices cannot be negative.`};let j=s.costCacheRead.trim().length>0,L=Number(s.costCacheRead);if(j&&(!Number.isFinite(L)||L<0))return{ok:!1,problem:`${w}: the cache-read price cannot be negative.`};let D=s.costCacheWrite5m.trim().length>0,U=Number(s.costCacheWrite5m);if(D&&(!Number.isFinite(U)||U<0))return{ok:!1,problem:`${w}: the 5m cache-write price must be a number of 0 or more.`};let Z=s.costCacheWrite1h.trim().length>0,Y=Number(s.costCacheWrite1h);if(Z&&(!Number.isFinite(Y)||Y<0))return{ok:!1,problem:`${w}: the 1h cache-write price must be a number of 0 or more.`};let p=s.contextWindow.trim().length>0,T=Number(s.contextWindow);if(p&&(!Number.isInteger(T)||T<1))return{ok:!1,problem:`${w}: the context window must be a whole number of tokens.`};let O=s.maxOutputTokens.trim().length>0,J=Number(s.maxOutputTokens);if(O&&(!Number.isInteger(J)||J<1))return{ok:!1,problem:`${w}: the output limit must be a whole number of tokens.`};c.push({provider:s.provider,...s.provider==="custom"?{endpointId:q}:{},model:V,tier:u,weight:Q,costPerMTok:{input:G,output:y,...j?{cacheRead:L}:{},...D?{cacheWrite5m:U}:{},...Z?{cacheWrite1h:Y}:{}},...p?{contextWindow:T}:{},...O?{maxOutputTokens:J}:{},...N.length>0?{credentialId:N}:{},capabilities:{tools:s.tools,images:s.images,reasoning:s.reasoning}})}return{ok:!0,model:{id:a,strategy:e.strategy,isAlias:e.isAlias,targets:c}}}import{useId as dt}from"react";import ie from"styled-components";import{jsx as g,jsxs as _}from"react/jsx-runtime";var ct=ie.fieldset.withConfig({displayName:"TargetEditor__Frame"})(["border:1px solid ",";border-left:3px solid ",";border-radius:",";padding:",";margin:0;background:",";display:flex;flex-direction:column;gap:",";min-width:0;"],({theme:e})=>e.color.rule,({$provider:e})=>oe(e),({theme:e})=>e.radius.control,({theme:e})=>e.space(3),({theme:e})=>e.color.panelSunk,({theme:e})=>e.space(3)),pt=ie.div.withConfig({displayName:"TargetEditor__Cells"})(["display:grid;grid-template-columns:minmax(140px,1.4fr) minmax(160px,2fr) 72px 72px;gap:",";align-items:end;@media (max-width:720px){grid-template-columns:minmax(0,1fr) minmax(0,1fr);}"],({theme:e})=>e.space(2)),He=ie.div.withConfig({displayName:"TargetEditor__Prices"})(["display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:",";align-items:end;"],({theme:e})=>e.space(2)),K=ie.div.withConfig({displayName:"TargetEditor__Cell"})(["display:flex;flex-direction:column;gap:4px;min-width:0;"]),ut=ie(o).withConfig({displayName:"TargetEditor__Caps"})(["gap:",";flex-wrap:wrap;"],({theme:e})=>e.space(3)),Ve=ie.p.withConfig({displayName:"TargetEditor__Unreachable"})(["font-size:11.5px;color:",";margin:0;"],({theme:e})=>e.color.down),we=ie.label.withConfig({displayName:"TargetEditor__Cap"})(["display:flex;align-items:center;gap:6px;cursor:pointer;"]);function Ue({target:e,index:a,onChange:c,onRemove:l,removable:s,catalog:w,endpoints:q,held:N,credentials:V}){let u=dt(),Q=z(w,e.provider),G=Le(w,e.provider,N),y=Oe(w,e.provider,e.model,N),j=Ce(e,V),L=Fe(e.credentialId,e,V),D=(p,T)=>{c({...e,[p]:T})},U=se(w,e.provider,e.model),Z=_e(w,e.provider,e.model),Y=(p)=>{c(ze(w,e,p))};return _(ct,{$provider:e.provider,children:[_(o,{$gap:2,children:[_(t,{as:"legend",children:["Target ",a+1]}),g(S,{}),g(P,{type:"button",$variant:"ghost",$size:"sm",disabled:!s,"aria-label":`Remove target ${a+1}`,title:s?`Remove target ${a+1}`:"A model needs at least one target",onClick:l,children:g(xt,{})})]}),_(pt,{children:[_(K,{children:[g(t,{as:"label",htmlFor:`${u}-provider`,children:"Provider"}),g(R,{id:`${u}-provider`,value:e.provider,options:[...w.map((p)=>({value:p.id,label:p.label})),...Q===void 0?[{value:e.provider,label:`${e.provider} (not in the catalog)`}]:[]],onValueChange:(p)=>{let T=p,O=z(w,T),J=O?.models.some((ae)=>ae.id===e.model)??!1;Y({provider:T,model:J?e.model:O?.defaultModel??""})}})]}),e.provider==="custom"?_(K,{children:[g(t,{as:"label",htmlFor:`${u}-endpoint`,children:"Endpoint"}),g(R,{id:`${u}-endpoint`,value:e.endpointId,options:[{value:"",label:"Choose endpoint"},...q.map((p)=>({value:p.id,label:p.label}))],onValueChange:(p)=>c(Be(e,p))})]}):null,_(K,{children:[g(t,{as:"label",htmlFor:`${u}-model`,children:"Provider model"}),g(tt,{id:`${u}-model`,value:e.model,placeholder:Q?.defaultModel??"",suggestions:G.map((p)=>({value:p.id,label:p.id,detail:p.label===p.id?void 0:p.label})),onValueChange:(p)=>Y({provider:e.provider,model:p})}),y===null?null:g(Ve,{role:"note",children:y})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${u}-tier`,children:"Tier"}),g(de,{id:`${u}-tier`,min:1,step:1,value:e.tier,onChange:(p)=>D("tier",p.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${u}-weight`,children:"Weight"}),g(de,{id:`${u}-weight`,min:0,step:0.1,value:e.weight,onChange:(p)=>D("weight",p.target.value)})]})]}),g(r,{$gap:1,children:_(K,{children:[g(t,{as:"label",htmlFor:`${u}-account`,children:"Account"}),g(R,{id:`${u}-account`,value:e.credentialId,options:[{value:"",label:"Any account"},...j.map((p)=>({value:p.id,label:p.label})),...L===null?[]:[{value:e.credentialId,label:`${e.credentialId} (removed)`}]],onValueChange:(p)=>D("credentialId",p)}),L===null?null:g(Ve,{role:"note",children:L})]})}),_(r,{$gap:1,children:[_(o,{$gap:2,children:[g(t,{children:"Price per million tokens"}),g(S,{}),U===null?g(t,{as:"span",children:"not in the catalog — price it yourself"}):_(n,{type:"button",$size:"sm",$variant:"ghost",disabled:e.costInput===U.costInput&&e.costOutput===U.costOutput&&e.costCacheRead===U.costCacheRead&&e.costCacheWrite5m===U.costCacheWrite5m&&e.costCacheWrite1h===U.costCacheWrite1h,onClick:()=>c({...e,...U}),children:[g(br,{}),"Use list price"]})]}),_(He,{children:[_(K,{children:[g(t,{as:"label",htmlFor:`${u}-in`,children:"Input"}),g(de,{id:`${u}-in`,min:0,step:0.01,value:e.costInput,onChange:(p)=>D("costInput",p.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${u}-out`,children:"Output"}),g(de,{id:`${u}-out`,min:0,step:0.01,value:e.costOutput,onChange:(p)=>D("costOutput",p.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${u}-cache`,children:"Cache read"}),g(de,{id:`${u}-cache`,min:0,step:0.01,placeholder:"same as input",value:e.costCacheRead,onChange:(p)=>D("costCacheRead",p.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${u}-write5m`,children:"Cache write 5m"}),g(de,{id:`${u}-write5m`,min:0,step:0.01,placeholder:"1.25x input",value:e.costCacheWrite5m,onChange:(p)=>D("costCacheWrite5m",p.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${u}-write1h`,children:"Cache write 1h"}),g(de,{id:`${u}-write1h`,min:0,step:0.01,placeholder:"2x input",value:e.costCacheWrite1h,onChange:(p)=>D("costCacheWrite1h",p.target.value)})]})]})]}),_(r,{$gap:1,children:[_(o,{$gap:2,children:[g(t,{children:"Token limits"}),g(S,{}),Z===null?g(t,{as:"span",children:"not in the catalog — state them yourself"}):g(t,{as:"span",children:"left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows"})]}),_(He,{children:[_(K,{children:[g(t,{as:"label",htmlFor:`${u}-context`,children:"Context window"}),g(de,{id:`${u}-context`,min:1,step:1024,placeholder:Z?.contextWindow??"published",value:e.contextWindow,onChange:(p)=>D("contextWindow",p.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${u}-maxout`,children:"Max output"}),g(de,{id:`${u}-maxout`,min:1,step:1024,placeholder:Z?.maxOutputTokens??"published",value:e.maxOutputTokens,onChange:(p)=>D("maxOutputTokens",p.target.value)})]})]})]}),_(r,{$gap:1,children:[g(t,{children:"Capabilities"}),_(ut,{children:[_(we,{children:[g(W,{checked:e.tools,label:`Target ${a+1} supports tools`,onCheckedChange:(p)=>D("tools",p)}),"Tools"]}),_(we,{children:[g(W,{checked:e.images,label:`Target ${a+1} supports images`,onCheckedChange:(p)=>D("images",p)}),"Images"]}),_(we,{children:[g(W,{checked:e.reasoning,label:`Target ${a+1} supports reasoning`,onCheckedChange:(p)=>D("reasoning",p)}),"Reasoning"]})]})]})]})}import{jsx as F,jsxs as te,Fragment as Ge}from"react/jsx-runtime";var Ke=ue.p.withConfig({displayName:"ModelEditor__Blurb"})(["font-size:11.5px;color:",";"],({theme:e})=>e.color.inkDim),gt=ue.p.withConfig({displayName:"ModelEditor__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),ht=ue.p.withConfig({displayName:"ModelEditor__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),ft=ue(o).withConfig({displayName:"ModelEditor__AliasRow"})(["gap:8px;"]);function je({model:e,onSaved:a,onDeleted:c}){let l=fe().data??[],[s,w]=ce(()=>e===null?xe(l):ke(e)),[q,N]=ce(null),[V,u]=ce(!1),[Q,G]=ce(!1),y=mn(),j=hn(),L=pe(),D=De(L.data??[]),U=(L.data??[]).filter((T)=>T.provider==="custom").map((T)=>({id:String(T.providerData.endpointId??""),label:String(T.providerData.endpointLabel??T.providerData.endpointId??"")})).filter((T,O,J)=>T.id.length>0&&J.findIndex((ae)=>ae.id===T.id)===O),Z=e?.id??null;mt(()=>{w(e===null?xe(l):ke(e)),N(null),u(!1)},[Z]);let Y=ye.find((T)=>T.id===s.strategy),p=()=>{u(!1);let T=qe(s);if(!T.ok){N(T.problem);return}N(null),y.mutate(T.model,{onSuccess:()=>{u(!0),a(T.model.id)},onError:(O)=>N(h(O))})};return te(Ge,{children:[F(f,{legend:e===null?"New model":"Edit model",meta:e===null?void 0:e.id,actions:te(Ge,{children:[e===null?null:F(n,{type:"button",$variant:"danger",$size:"sm",onClick:()=>G(!0),children:"Delete"}),F(n,{type:"button",$variant:"primary",$size:"sm",disabled:y.isPending,onClick:p,children:y.isPending?"Saving…":e===null?"Create model":"Save changes"})]}),children:te(r,{$gap:3,children:[F(m,{label:"Model name",hint:e===null?"What clients send as the model. Anything not listed here is rejected.":"Fixed once created. To rename, create a model under the new name and delete this one.",children:(T)=>F(v,{...T,value:s.id,disabled:e!==null,placeholder:"fast",onChange:(O)=>w({...s,id:O.target.value})})}),F(m,{label:"Routing strategy",children:(T)=>F(R,{...T,value:s.strategy,options:ye.map((O)=>({value:O.id,label:O.label})),onValueChange:(O)=>w({...s,strategy:O})})}),Y===void 0?null:F(Ke,{children:Y.blurb}),te(ft,{children:[F(W,{checked:s.isAlias,label:"This model is an alias for a provider model name",onCheckedChange:(T)=>w({...s,isAlias:T})}),te(r,{$gap:0,children:[F(t,{as:"span",children:"Alias"}),F(Ke,{children:"Mark this when the name mirrors a provider's own model name."})]})]}),te(r,{$gap:2,children:[te(o,{children:[F(t,{children:"Targets"}),F(S,{}),te(n,{type:"button",$size:"sm",onClick:()=>w({...s,targets:[...s.targets,ve(l,s.targets.at(-1)?.provider)]}),children:[F(Qe,{}),"Add target"]})]}),s.targets.map((T,O)=>F(Ue,{target:T,index:O,removable:s.targets.length>1,catalog:l,endpoints:U,held:D,credentials:L.data??[],onChange:(J)=>w({...s,targets:s.targets.map((ae)=>ae.key===T.key?J:ae)}),onRemove:()=>w({...s,targets:s.targets.filter((J)=>J.key!==T.key)})},T.key))]}),q===null?null:F(gt,{role:"alert",children:q}),V&&q===null?F(ht,{role:"status",children:"Saved."}):null]})}),F(ee,{open:Q,onOpenChange:G,title:"Delete model",body:e===null?"":`Deleting "${e.id}" makes it unroutable. Clients asking for it will get a model-unavailable error, and any key allowlisting it keeps a name that no longer resolves.`,confirmLabel:"Delete model",busy:j.isPending,onConfirm:()=>{if(e===null)return;j.mutate(e.id,{onSuccess:()=>{G(!1),c()},onError:(T)=>{G(!1),N(h(T))}})}})]})}import{jsx as A,jsxs as ne,Fragment as St}from"react/jsx-runtime";var Ct=le.div.withConfig({displayName:"ModelsBoard__Split"})(["display:grid;grid-template-columns:minmax(230px,300px) minmax(0,1fr);gap:",";align-items:start;@media (max-width:980px){grid-template-columns:minmax(0,1fr);}"],({theme:e})=>e.space(4)),kt=le(r).withConfig({displayName:"ModelsBoard__Column"})(["gap:",";min-width:0;"],({theme:e})=>e.space(4)),wt=le.button.withConfig({displayName:"ModelsBoard__Entry"})(["display:flex;flex-direction:column;gap:4px;width:100%;padding:",";text-align:left;background:",";border:0;border-left:2px solid ",";border-bottom:1px solid ",";cursor:pointer;&:hover{background:",";}&:last-child{border-bottom:0;}"],({theme:e})=>`${e.space(2)} ${e.space(3)}`,({theme:e,$selected:a})=>a?e.color.accentWash:"transparent",({theme:e,$selected:a})=>a?e.color.accent:"transparent",({theme:e})=>e.color.rule,({theme:e,$selected:a})=>a?e.color.accentWash:e.color.panelSunk),Tt=le(M).withConfig({displayName:"ModelsBoard__Name"})(["font-family:",";font-size:12.5px;display:block;max-width:100%;"],({theme:e})=>e.font.mono),$t=le.div.withConfig({displayName:"ModelsBoard__Bar"})(["display:flex;gap:2px;"]),Pt=le.span.withConfig({displayName:"ModelsBoard__Pip"})(["width:12px;height:3px;border-radius:1px;background:",";"],({$provider:e})=>oe(e)),me="\x00new";function Je(){let e=H(),[a,c]=yt(null),l=e.data??[],s=a===me?null:l.find((N)=>N.id===a)??null,w=a===me||a===null&&!e.isLoading&&l.length===0;bt(()=>{if(a!==null||l.length===0)return;c(l[0]?.id??null)},[l,a]);let q=e.isLoading?"Reading configured models…":l.length===0?"No virtual models exist yet, so no client request can resolve to an upstream.":`${l.length} model${l.length===1?"":"s"} routing to ${l.reduce((N,V)=>N+V.targets.length,0)} targets.`;return ne(St,{children:[A(k,{legend:"Models",title:"Virtual models",summary:q,actions:ne(n,{type:"button",$variant:"primary",onClick:()=>c(me),children:[A(Qe,{}),"New model"]})}),ne(Ct,{children:[A(f,{legend:"Configured",meta:`${l.length}`,flush:!0,children:e.isError?A(x,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?A("div",{style:{padding:12},children:A(b,{rows:4})}):l.length===0?A(I,{legend:"No models",message:"Create a model to give clients something to ask for.",action:A(n,{type:"button",$size:"sm",$variant:"primary",onClick:()=>c(me),children:"New model"})}):A("div",{children:l.map((N)=>{let V=[...new Set(N.targets.map((u)=>u.provider))];return ne(wt,{type:"button",$selected:N.id===a,"aria-pressed":N.id===a,onClick:()=>c(N.id),children:[ne(o,{$gap:2,style:{width:"100%"},children:[A(Tt,{title:N.id,children:N.id}),A(S,{}),N.isAlias?A(C,{children:"alias"}):null]}),ne(o,{$gap:2,style:{width:"100%"},children:[A($t,{children:V.map((u)=>A(Pt,{$provider:u,title:u},u))}),A(t,{children:N.strategy}),A(S,{}),ne(d,{$dim:!0,$size:"11px",children:[N.targets.length," target",N.targets.length===1?"":"s"]})]})]},N.id)})})}),ne(kt,{children:[s===null&&!w?A(f,{legend:"Editor",children:e.isLoading?A(b,{rows:5}):A(I,{legend:"Nothing selected",message:"Pick a model on the left to change its targets, or create a new one."})}):A(je,{model:s,onSaved:(N)=>{c(N),e.refetch()},onDeleted:()=>{c(null),e.refetch()}}),A(Re,{modelId:s?.id??null})]})]})]})}var Oo=Je;export{Oo as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,A,Y,ke,ct,Or,I,x,b,k,f,Xr}from"/assets/index-p9vbm21a.js";import{Suspense as K,useMemo as q}from"react";import M from"styled-components";import{createContext as C,lazy as D,useContext as _}from"react";import{pluginApiPath as s}from"@omnigateway/dashboard-sdk";var h=new Map;function y(n){let t=h.get(n);if(t!==void 0)return t;let i={get:(e,a)=>A(s(n,e),a),post:(e,a)=>Y(s(n,e),a),put:(e,a)=>ke(s(n,e),a),del:(e)=>ct(s(n,e))};return h.set(n,i),i}var L=(n)=>import(n),w=C(L),j=w.Provider;function v(){return _(w)}function R(n,t){let i=n?.default;if(i===void 0||i===null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof i.mount!=="function")throw Error(`plugin ${t} exported a default without a mount function`);return i}function T(n,t,i){return D(async()=>{let e=R(await i(t),n);return{default:()=>e.mount({pluginId:n,api:y(n)})}})}import{Component as E}from"react";import m from"styled-components";import{jsx as g,jsxs as B}from"react/jsx-runtime";var U=m.p.withConfig({displayName:"PluginBoundary__Fault"})(["font-size:13px;color:",";"],({theme:n})=>n.color.down),z=m.p.withConfig({displayName:"PluginBoundary__Detail"})(["font-family:",";font-size:12px;color:",";overflow-wrap:anywhere;"],({theme:n})=>n.font.mono,({theme:n})=>n.color.inkDim),F=m.p.withConfig({displayName:"PluginBoundary__Advice"})(["font-size:12px;color:",";max-width:68ch;"],({theme:n})=>n.color.inkDim);function H(n){if(n instanceof Error)return n.message;if(typeof n==="string")return n;return"The plugin threw a value that is not an error."}class c extends E{state={message:null};static getDerivedStateFromError(n){return{message:H(n)}}componentDidUpdate(n){if(n.pluginId!==this.props.pluginId&&this.state.message!==null)this.setState({message:null})}componentDidCatch(n,t){}render(){let{message:n}=this.state;if(n===null)return this.props.children;return g(f,{legend:"Plugin failed",meta:this.props.pluginId,children:B(r,{$gap:2,children:[B(U,{children:[this.props.pluginName," stopped rendering."]}),g(z,{children:n}),g(F,{children:"The rest of the console is unaffected. Reload the page to try this screen again, and report the message above to whoever maintains the plugin."})]})})}}import{jsx as o,jsxs as u,Fragment as l}from"react/jsx-runtime";var G=M.p.withConfig({displayName:"PluginBoard__Mismatch"})(["font-size:13px;color:",";"],({theme:n})=>n.color.warn),J=M.p.withConfig({displayName:"PluginBoard__Advice"})(["font-size:12px;color:",";max-width:68ch;"],({theme:n})=>n.color.inkDim);function S({pluginId:n}){let t=Or(),i=v(),e=t.data?.find((N)=>N.id===n),a=e?.ui??null,p=a?.compatible===!0?a.entry:null,P=q(()=>p===null?null:T(n,p,i),[n,p,i]);if(t.isError)return u(l,{children:[o(k,{legend:"Plugin",title:"Plugins",summary:"The installed plugins are unknown."}),o(x,{legend:"Plugins unavailable",error:t.error})]});if(e===void 0)return u(l,{children:[o(k,{legend:"Plugin",title:t.isPending?"Loading…":n,summary:t.isPending?"Reading the installed plugins.":"This gateway does not run a plugin with that id."}),t.isPending?o(b,{}):o(I,{legend:"Not installed",message:`No plugin with the id ${n} is installed. Install it and restart the gateway.`})]});let d=o(k,{legend:"Plugin",title:e.nav?.label??e.name,summary:`${e.name} ${e.version}, installed as ${e.id}.`});if(a===null)return u(l,{children:[d,o(I,{legend:"No interface",message:`${e.name} runs entirely in the gateway and has no console screen.`})]});if(P===null)return u(l,{children:[d,o(f,{legend:"Interface unavailable",meta:e.id,children:u(r,{$gap:2,children:[o(G,{children:a.reason??"This plugin's interface does not match this gateway."}),o(J,{children:"The plugin's server half is unaffected and keeps running. Update the plugin, or the gateway, so the two agree on a dashboard SDK version."})]})})]});return u(l,{children:[d,o(c,{pluginId:e.id,pluginName:e.name,children:o(K,{fallback:o(b,{}),children:o(P,{})})})]})}import{jsx as O}from"react/jsx-runtime";function vn(){let{pluginId:n}=Xr.useParams();return O(S,{pluginId:n})}export{vn as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,t,d,o,r,Ie,Mo,S,_t,H,he,Do,Qt,Bo,In,kn,Ln,Nr,Jt,Br,_n,Fr,h,x,b,k,f}from"/assets/index-p9vbm21a.js";import{R,tt}from"/assets/index-f7t0kve8.js";import{W}from"/assets/index-dq2f7yk0.js";import{v,Tr,m}from"/assets/index-8bewp9z1.js";import{re}from"/assets/index-wjqdtafp.js";import{Ar}from"/assets/index-d0t1fj1y.js";import{useEffect as xe,useId as Ce,useState as ee}from"react";import T from"styled-components";import{useState as z}from"react";import V from"styled-components";var I=12;import{jsx as _,jsxs as G}from"react/jsx-runtime";var ie=V.p.withConfig({displayName:"AccessPanel__Blurb"})(["font-size:12px;color:",";max-width:62ch;"],({theme:e})=>e.color.inkDim),se=V.p.withConfig({displayName:"AccessPanel__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),_e=V.p.withConfig({displayName:"AccessPanel__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),le=V(r).withConfig({displayName:"AccessPanel__Form"})(["max-width:320px;"]),de=V(t).withConfig({displayName:"AccessPanel__SubHead"})(["color:",";"],({theme:e})=>e.color.inkDim);function Ae(){let e=kn(),[l,c]=z(""),[C,w]=z(""),[i,g]=z(""),[M,L]=z(null),p=()=>{if(C.length<I){L(`A password must be at least ${I} characters.`);return}if(C!==i){L("The two new passwords do not match.");return}L(null),e.mutate({current:l,password:C},{onSuccess:()=>Ar("password-changed"),onError:(N)=>L(h(N))})};return G(r,{$gap:2,children:[_(de,{children:"Admin password"}),_(ie,{children:"Changing this signs every session out, including this one."}),G(le,{$gap:2,children:[_(m,{label:"Current password",children:(N)=>_(v,{...N,type:"password",autoComplete:"current-password",value:l,onChange:(A)=>c(A.target.value)})}),_(m,{label:"New password",hint:`At least ${I} characters.`,children:(N)=>_(v,{...N,type:"password",autoComplete:"new-password",value:C,onChange:(A)=>w(A.target.value)})}),_(m,{label:"Repeat new password",children:(N)=>_(v,{...N,type:"password",autoComplete:"new-password",value:i,onChange:(A)=>g(A.target.value)})}),_(o,{$gap:2,children:_(n,{type:"button",$variant:"primary",onClick:p,disabled:e.isPending||l.length===0||C.length===0,children:"Change password"})})]}),M===null?null:_(se,{role:"alert",children:M})]})}function Le(){let e=_t(),l=Ln(),[c,C]=z(""),[w,i]=z(null),[g,M]=z(null),L=e.data?.viewerConfigured===!0,p=()=>{if(c.length<I){i(`A password must be at least ${I} characters.`);return}i(null),l.mutate(c,{onSuccess:()=>{C(""),M(L?"Read-only password replaced.":"Read-only access granted.")},onError:(A)=>i(h(A))})},N=()=>{i(null),l.mutate(null,{onSuccess:()=>M("Read-only access withdrawn."),onError:(A)=>i(h(A))})};return G(r,{$gap:2,children:[_(de,{children:"Read-only password"}),G(ie,{children:["Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies."," ",e.isPending?"Checking whether one is set…":L?"One is set. A new one replaces it; withdrawing ends read-only sessions at once.":"None is set, so nobody can sign in read-only. There is no default password."]}),G(le,{$gap:2,children:[_(m,{label:L?"Replace read-only password":"Set read-only password",hint:`At least ${I} characters.`,children:(A)=>_(v,{...A,type:"password",autoComplete:"new-password",value:c,onChange:(O)=>C(O.target.value)})}),G(o,{$gap:2,children:[_(n,{type:"button",$variant:"primary",onClick:p,disabled:l.isPending||c.length===0,children:L?"Replace":"Set"}),L?_(n,{type:"button",$variant:"danger",onClick:N,disabled:l.isPending,children:"Withdraw access"}):null]})]}),w===null?null:_(se,{role:"alert",children:w}),g===null||w!==null?null:_(_e,{role:"status",children:g})]})}function ue(){return _(f,{legend:"Access",children:G(r,{$gap:3,children:[_(Ae,{}),_(Mo,{}),_(Le,{})]})})}import{useState as ce}from"react";import X from"styled-components";import{jsx as P,jsxs as K}from"react/jsx-runtime";var me=[{id:"claude",label:"Claude Code",where:"settings.json under ~/.claude"},{id:"opencode",label:"opencode",where:"opencode.json in your project"}],Ne=X(d).withConfig({displayName:"AgentSetup__Sheet"})(["display:block;white-space:pre;overflow-x:auto;padding:0.75rem;background:",";border:1px solid ",";border-radius:4px;font-size:0.8125rem;line-height:1.5;"],({theme:e})=>e.color.panelSunk,({theme:e})=>e.color.rule),Ee=X.div.withConfig({displayName:"AgentSetup__Path"})(["color:",";font-size:0.8125rem;margin-bottom:0.25rem;"],({theme:e})=>e.color.inkDim),j=X.p.withConfig({displayName:"AgentSetup__Note"})(["color:",";font-size:0.8125rem;margin:0;"],({theme:e})=>e.color.inkDim),Pe=X.div.withConfig({displayName:"AgentSetup__MappingGrid"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));gap:",";"],({theme:e})=>e.space(2)),Te=[{key:"defaultModel",label:"Default model",required:!0},{key:"fableModel",label:"Fable model",required:!1},{key:"opusModel",label:"Opus model",required:!1},{key:"sonnetModel",label:"Sonnet model",required:!1},{key:"haikuModel",label:"Haiku model",required:!1}];function ge(){let[e,l]=ce("claude"),[c,C]=ce(()=>({claude:{},opencode:{}})),w=H(),i=c[e],g=typeof i.defaultModel==="string"&&i.defaultModel!==""?i:void 0,M=Bo(e,g),L=me.find((p)=>p.id===e);return P(f,{legend:"Agent setup",children:K(r,{children:[P(o,{children:me.map((p)=>P(n,{type:"button",$variant:p.id===e?"primary":"ghost",onClick:()=>l(p.id),children:p.label},p.id))}),K(j,{children:[L?.where,". The key is a placeholder — paste your own over it. Or run"," ",K(d,{children:["omni setup ",e]})," to write these files directly."]}),e==="claude"?K(j,{children:["Claude Code cannot read a window from this gateway, so it assumes 200k for a pool id it does not recognise and auto-compacts there. For a pool whose models hold 1M, append"," ",P(d,{children:"[1m]"})," to the model name — ",P(d,{children:"--model 'pool[1m]'"})," — which lifts it per invocation. The suffix is stripped before the request is sent, so the pool id arrives unchanged."]}):null,(w.data?.length??0)>0?P(Pe,{children:Te.map((p)=>P(m,{label:p.label,children:(N)=>P(R,{...N,value:i[p.key]??"",options:[{value:"",label:p.required?"Choose a pool":"Not mapped"},...(w.data??[]).map((A)=>({value:A.id,label:A.id}))],onValueChange:(A)=>C((O)=>({...O,[e]:{...O[e],[p.key]:A||void 0}}))})},p.key))}):null,w.isLoading?P(b,{rows:2}):M.isError?P(x,{error:M.error,onRetry:()=>void M.refetch()}):M.isLoading?P(b,{rows:4}):(w.data?.length??0)===0?P(j,{children:"No virtual models configured yet, so there is nothing to point a client at."}):g===void 0?K(j,{children:["Choose a default model to generate ",L?.label," settings."]}):M.data===void 0||M.data.length===0?P(j,{children:"No virtual models configured yet, so there is nothing to point a client at."}):M.data.map((p)=>K("div",{children:[P(Ee,{children:p.path}),P(Ne,{as:"pre",children:p.contents.trimEnd()})]},p.path)),M.isError?P(j,{children:h(M.error)}):null]})})}import{jsx as a,jsxs as y,Fragment as ze}from"react/jsx-runtime";var Se={off:"Off",lite:"Lite — names the lazier option",full:"Full — the ladder enforced",ultra:"Ultra — challenges the requirement"},J=[{id:"tier",label:"Tier",blurb:"Prefers a lower tier."},{id:"health",label:"Health",blurb:"Penalises recent failures and an open breaker."},{id:"quota",label:"Quota",blurb:"Prefers accounts ahead of their window's burn rate."},{id:"cost",label:"Cost",blurb:"Prefers the cheaper candidate."},{id:"latency",label:"Latency",blurb:"Prefers the faster observed first token."},{id:"load",label:"Load",blurb:"Prefers accounts with fewer requests in flight."}],oe=[{id:"maxAttempts",label:"Attempts per request",hint:"Candidates dispatch may try. 1 disables failover.",unit:"attempts",step:1,min:1},{id:"requestDeadlineMs",label:"Request deadline",hint:"Across all attempts. 0 disables only OmniGateway's deadline.",unit:"ms",step:1000,min:0},{id:"breakerThreshold",label:"Breaker threshold",hint:"Consecutive failures before an account and model leaves rotation.",unit:"failures",step:1,min:1},{id:"breakerCooldownMs",label:"Breaker cooldown",hint:"Wait before a tripped account is probed. Doubles per extra failure.",unit:"ms",step:1000,min:1},{id:"logRetentionDays",label:"Log retention",hint:"How long request rows are kept before pruning.",unit:"days",step:1,min:1},{id:"bodyRetentionDays",label:"Body retention",hint:"Captured bodies only. Never longer than log retention; swept hourly.",unit:"days",step:1,min:1,max:3650},{id:"quotaPollIntervalMs",label:"Quota poll interval",hint:"How often a provider is asked for remaining quota. 0 disables. Needs a restart.",unit:"ms",step:60000,min:0}],Q=T.div.withConfig({displayName:"SettingsBoard__Weights"})(["display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:",";"],({theme:e})=>e.space(3)),D=T(r).withConfig({displayName:"SettingsBoard__Cell"})(["gap:6px;"]),U=T.p.withConfig({displayName:"SettingsBoard__Blurb"})(["font-size:11px;color:",";"],({theme:e})=>e.color.inkDim),te=T.div.withConfig({displayName:"SettingsBoard__Options"})(["display:grid;grid-template-columns:1fr;gap:",";align-items:start;"],({theme:e})=>e.space(2)),ke=T.div.withConfig({displayName:"SettingsBoard__Option"})(["display:grid;grid-template-columns:auto 1fr;column-gap:",";row-gap:4px;align-items:center;padding:",";background:",";border:1px solid ",";border-radius:3px;"],({theme:e})=>e.space(2),({theme:e})=>e.space(2),({theme:e})=>e.color.panelSunk,({theme:e})=>e.color.rule),ae=T(U).withConfig({displayName:"SettingsBoard__OptionBlurb"})(["grid-column:2;"]),Me=T.label.withConfig({displayName:"SettingsBoard__OptionName"})(["font-size:12px;font-weight:600;color:",";cursor:pointer;"],({theme:e})=>e.color.ink),$e=T(ke).withConfig({displayName:"SettingsBoard__Choice"})(["grid-template-columns:1fr;","{grid-column:1;}"],ae);function Be({label:e,children:l,blurb:c}){let C=Ce();return y($e,{children:[a(Me,{htmlFor:C,children:e}),l({id:C}),a(ae,{children:c})]})}function Y({label:e,checked:l,disabled:c,onCheckedChange:C,children:w}){let i=Ce();return y(ke,{children:[a(W,{id:i,checked:l,onCheckedChange:C,label:e,...c===void 0?{}:{disabled:c}}),a(Me,{htmlFor:i,children:e}),a(ae,{children:w})]})}var Oe=T.p.withConfig({displayName:"SettingsBoard__Problem"})(["font-size:12px;color:",";"],({theme:e})=>e.color.down),qe=T.p.withConfig({displayName:"SettingsBoard__Saved"})(["font-size:12px;color:",";"],({theme:e})=>e.color.ok),De=T.span.withConfig({displayName:"SettingsBoard__PolicyCount"})(["font-size:11px;font-family:",";color:",";"],({theme:e})=>e.font.mono,({$over:e,theme:l})=>e?l.color.down:l.color.inkDim),Fe=T.p.withConfig({displayName:"SettingsBoard__Blocked"})(["font-size:12px;color:",";max-width:72ch;code{font-family:",";}"],({theme:e})=>e.color.warn,({theme:e})=>e.font.mono),pe="smart-router-classifier-status",be="smart-router-local-status",fe={ok:null,unset:"Not set; flagged keys' requests are refused.",unresolved:"This model does not resolve.",notLocal:"This model has a target that is not a custom (in-house) endpoint; flagged keys' requests are refused."};function ye(e,l,c,C){let w=(e??"").trim();if(w==="")return C?fe.unset:null;if(c===void 0||c==="unset"||w!==l)return null;return fe[c]}var we=T.p.withConfig({displayName:"SettingsBoard__ModelWarning"})(["font-size:12px;color:",";"],({theme:e})=>e.color.warn);function We(e){let l={};for(let c of J)l[`w.${c.id}`]=String(e.weights[c.id]);for(let c of oe)l[c.id]=String(e[c.id]);return l.rtkEnabled=String(e.rtkEnabled),l.autoCacheEnabled=String(e.autoCacheEnabled),l.ponytailMode=e.ponytailMode,l.bodyLoggingEnabled=String(e.bodyLoggingEnabled),l.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),l.guardrailModel=e.guardrailModel??"",l.guardrailTimeoutMs=String(e.guardrailTimeoutMs),l.guardrailHistoryTurns=String(e.guardrailHistoryTurns),l.smartRouterEnabled=String(e.smartRouterEnabled),l.smartRouterClassifierModel=e.smartRouterClassifierModel??"",l.smartRouterLocalModel=e.smartRouterLocalModel??"",l.smartRouterPolicy=e.smartRouterPolicy,l.smartRouterTimeoutMs=String(e.smartRouterTimeoutMs),l}function He(e){let l={};for(let E of J){let q=(e[`w.${E.id}`]??"").trim(),B=Number(q);if(q.length===0||!Number.isFinite(B))return{ok:!1,problem:`${E.label} must be a number.`};l[E.id]=B}let c={};for(let E of oe){let q=(e[E.id]??"").trim(),B=Number(q);if(q.length===0||!Number.isInteger(B)||B<E.min)return{ok:!1,problem:`${E.label} must be a whole number of ${E.min} or more.`};if(E.max!==void 0&&B>E.max)return{ok:!1,problem:`${E.label} cannot exceed ${E.max}.`};c[E.id]=B}if(c.maxAttempts>10)return{ok:!1,problem:"Attempts per request cannot exceed 10."};let C=(e.guardrailTimeoutMs??"").trim(),w=Number(C);if(C.length===0||!Number.isInteger(w)||w<1||w>Nr)return{ok:!1,problem:`Usage policy check timeout must be a whole number from 1 to ${Nr}.`};let i=(e.guardrailHistoryTurns??"").trim(),g=Number(i);if(i.length===0||!Number.isInteger(g)||g<1||g>Fr)return{ok:!1,problem:`Messages judged must be a whole number from 1 to ${Fr}.`};let M=(e.guardrailModel??"").trim(),L=(e.smartRouterTimeoutMs??"").trim(),p=Number(L);if(L.length===0||!Number.isInteger(p)||p<1||p>Br)return{ok:!1,problem:`Confidential routing timeout must be a whole number from 1 to ${Br}.`};let N=(e.smartRouterPolicy??"").trim();if(N.length===0)return{ok:!1,problem:"Write what counts as confidential, or use Reset to default."};if(N.length>Jt)return{ok:!1,problem:`The confidential policy is at most ${Jt} characters.`};let A=(e.smartRouterClassifierModel??"").trim(),O=(e.smartRouterLocalModel??"").trim();return{ok:!0,settings:{weights:l,...c,rtkEnabled:e.rtkEnabled==="true",autoCacheEnabled:e.autoCacheEnabled==="true",ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(Se,e.ponytailMode)?e.ponytailMode:"off",bodyLoggingEnabled:e.bodyLoggingEnabled==="true",bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks==="true",guardrailModel:M.length===0?null:M,guardrailTimeoutMs:w,guardrailHistoryTurns:g,smartRouterEnabled:e.smartRouterEnabled==="true",smartRouterClassifierModel:A.length===0?null:A,smartRouterLocalModel:O.length===0?null:O,smartRouterPolicy:N,smartRouterTimeoutMs:p}}}function Re(){let e=he(),l=Do(),c=H(),C=Qt(),w=In(),[i,g]=ee({}),[M,L]=ee(null),[p,N]=ee(!1);xe(()=>{if(e.data===void 0)return;g(We(e.data))},[e.data]);let A=Math.max(0.0001,...J.map((s)=>Math.abs(Number(i[`w.${s.id}`])||0))),O=(i.smartRouterPolicy??"").trim().length,E=i.smartRouterEnabled==="true",q=ye(i.smartRouterClassifierModel,e.data?.smartRouterClassifierModel,C.data?.classifier,E),B=ye(i.smartRouterLocalModel,e.data?.smartRouterLocalModel,C.data?.local,E),ne=(s,u,F)=>u===null?s:[s,F].filter((Z)=>Z!==void 0).join(" "),ve=()=>{if(N(!1),e.data===void 0)return;let s=He(i);if(!s.ok){L(s.problem);return}L(null),w.mutate(s.settings,{onSuccess:()=>N(!0),onError:(u)=>L(h(u))})};return y(ze,{children:[a(k,{legend:"Settings",title:"Routing and retention",summary:"Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.",actions:a(n,{type:"button",$variant:"primary",disabled:w.isPending||e.isLoading,onClick:ve,children:w.isPending?"Saving…":"Save changes"})}),e.isError?a(f,{legend:"Settings",children:a(x,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?a(f,{legend:"Settings",children:a(b,{rows:6})}):y(r,{$gap:4,children:[a(f,{legend:"Scoring weights",meta:"relative to each other",footer:y(o,{children:[a(t,{children:"Score is the sum of each term times its weight, then multiplied by the account and target weights."}),a(S,{})]}),children:a(Q,{children:J.map((s)=>{let u=Number(i[`w.${s.id}`])||0;return y(D,{children:[a(m,{label:s.label,children:(F)=>a(v,{...F,type:"number",step:0.5,value:i[`w.${s.id}`]??"",onChange:(Z)=>g({...i,[`w.${s.id}`]:Z.target.value})})}),a(re,{fraction:Math.abs(u)/A,height:4,tone:"var(--accent)",label:`${s.label} weight ${u}`}),a(U,{children:s.blurb})]},s.id)})})}),a(f,{legend:"Limits",children:a(Q,{children:oe.map((s)=>a(D,{children:a(m,{label:s.label,hint:s.hint,children:(u)=>y(o,{$gap:2,children:[a(v,{...u,type:"number",min:s.min,max:s.max,step:s.step,value:i[s.id]??"",onChange:(F)=>g({...i,[s.id]:F.target.value})}),a(t,{children:s.unit})]})})},s.id))})}),y(Ie,{$min:"380px",$stretch:!0,children:[a(f,{legend:"Request handling",meta:"applied before dispatch",children:y(te,{children:[a(Y,{label:"Enable RTK compression",checked:i.rtkEnabled==="true",onCheckedChange:(s)=>g({...i,rtkEnabled:String(s)}),children:"Compresses recognized historical tool results. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a detector recognizes shell output. Lossy."}),a(Y,{label:"Add a cache breakpoint when a client sends none",checked:i.autoCacheEnabled==="true",onCheckedChange:(s)=>g({...i,autoCacheEnabled:String(s)}),children:"Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched."}),a(Be,{label:"Lazy senior dev mode",blurb:"Appends the ponytail ruleset, about 1,240 tokens, to every system prompt. A request already carrying it is left alone.",children:(s)=>a(R,{...s,value:i.ponytailMode??"off",options:Object.entries(Se).map(([u,F])=>({value:u,label:F})),onValueChange:(u)=>g({...i,ponytailMode:u})})})]})}),a(f,{legend:"Request and response bodies",meta:l.data===!0?"permitted by the environment":"not permitted",children:y(r,{$gap:2,children:[l.data===!0?null:y(Fe,{children:["This gateway started without ",a("code",{children:"OMNI_BODY_LOGGING_ALLOWED"}),", so nothing below can record anything. Set it in the installation's ",a("code",{children:".env"})," and restart first."]}),y(te,{children:[a(Y,{label:"Capture request and response bodies",checked:i.bodyLoggingEnabled==="true",disabled:l.data!==!0,onCheckedChange:(s)=>g({...i,bodyLoggingEnabled:String(s)}),children:"Stores what each client sent and each provider returned, encrypted beside the database. Tokens and keys are masked; headers are never captured. Expires on the body retention window above, never later than the request log."}),a(Y,{label:"Also keep raw stream frames",checked:i.bodyLoggingCaptureStreamChunks==="true",disabled:l.data!==!0||i.bodyLoggingEnabled!=="true",onCheckedChange:(s)=>g({...i,bodyLoggingCaptureStreamChunks:String(s)}),children:"Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores."})]})]})})]}),a(f,{legend:"Usage policies",meta:"per-key guardrails",children:y(r,{$gap:2,children:[a(U,{children:"Keys carrying a usage policy have each request judged by this model first. While it is blank, every request from such a key is refused. A guardrail against ordinary misuse, not a security boundary."}),y(Q,{children:[a(D,{children:a(m,{label:"Classifier model",hint:"A configured model, or provider/model. Blank means none.",children:(s)=>a(tt,{...s,placeholder:"none",value:i.guardrailModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,guardrailModel:u})})})}),a(D,{children:a(m,{label:"Check timeout",hint:"A slower check refuses the request it was judging.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Nr,step:1,value:i.guardrailTimeoutMs??"",onChange:(u)=>g({...i,guardrailTimeoutMs:u.target.value})}),a(t,{children:"ms"})]})})}),a(D,{children:a(m,{label:"Messages judged",hint:"How many of the latest human messages are judged together. 1 is the last alone.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Fr,step:1,value:i.guardrailHistoryTurns??"",onChange:(u)=>g({...i,guardrailHistoryTurns:u.target.value})}),a(t,{children:"messages"})]})})})]})]})}),a(f,{legend:"Confidential routing",meta:"per-key, local model",children:y(r,{$gap:3,children:[a(U,{children:"Keys with confidential routing on have each request screened by the classifier model. Requests it judges confidential are answered by the local model instead of the model asked for. Reduces leaks of ordinary confidential content; it is not a security boundary."}),a(te,{children:a(Y,{label:"Enable confidential routing",checked:i.smartRouterEnabled==="true",onCheckedChange:(s)=>g({...i,smartRouterEnabled:String(s)}),children:"Applies only to keys that have it switched on in Keys. While off, no request is screened or rerouted."})}),y(Q,{children:[y(D,{children:[a(m,{label:"Confidential classifier model",hint:"Judges each request. Blank means none.",children:(s)=>a(tt,{...s,"aria-describedby":ne(s["aria-describedby"],q,pe),placeholder:"none",value:i.smartRouterClassifierModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,smartRouterClassifierModel:u})})}),q===null?null:a(we,{id:pe,children:q})]}),y(D,{children:[a(m,{label:"Local model",hint:"Answers requests judged confidential. Blank means none.",children:(s)=>a(tt,{...s,"aria-describedby":ne(s["aria-describedby"],B,be),placeholder:"none",value:i.smartRouterLocalModel??"",suggestions:(c.data??[]).map((u)=>({value:u.id,label:u.id})),onValueChange:(u)=>g({...i,smartRouterLocalModel:u})})}),B===null?null:a(we,{id:be,children:B})]}),a(D,{children:a(m,{label:"Confidential check timeout",hint:"A slower check refuses the request it was screening.",children:(s)=>y(o,{$gap:2,children:[a(v,{...s,type:"number",min:1,max:Br,step:1,value:i.smartRouterTimeoutMs??"",onChange:(u)=>g({...i,smartRouterTimeoutMs:u.target.value})}),a(t,{children:"ms"})]})})})]}),a(U,{children:"Must be a virtual model whose targets are all custom (in-house) endpoints. Requests are refused otherwise."}),a(m,{label:"What counts as confidential",hint:"Plain language. The classifier reads this to decide which requests stay on local hardware.",children:(s)=>a(Tr,{...s,rows:6,value:i.smartRouterPolicy??"",onChange:(u)=>g({...i,smartRouterPolicy:u.target.value})})}),y(o,{$gap:2,children:[a(n,{type:"button",$size:"sm",onClick:()=>g({...i,smartRouterPolicy:_n}),children:"Reset to default"}),a(S,{}),y(De,{$over:O>Jt,children:[O," / ",Jt]})]})]})}),M===null?null:a(Oe,{role:"alert",children:M}),p&&M===null?a(qe,{role:"status",children:"Settings saved."}):null,y(Ie,{$min:"380px",$stretch:!0,children:[a(ge,{}),a(ue,{})]}),a(f,{legend:"Known limits",children:y(r,{$gap:2,children:[y(o,{$gap:2,$align:"start",children:[a(d,{$dim:!0,children:"rate limits"}),a(U,{children:"Counted per gateway process and reset when it restarts. Not shared across instances."})]}),y(o,{$gap:2,$align:"start",children:[a(d,{$dim:!0,children:"logs"}),a(U,{children:"Request rows record routing and token counts only. Prompts and responses only when body capture is on, to a separate encrypted store. Credentials to neither."})]})]})})]})]})}var $t=Re;export{$t as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t,d,o,r,Ie,Q,M,fe,z,pe,H,we,No,Ue,a,w,V,N,X,oe,K,k,f}from"/assets/index-p9vbm21a.js";import{R}from"/assets/index-f7t0kve8.js";import{Se,st,Xe,yr}from"/assets/index-hk28xepa.js";import"/assets/index-8bewp9z1.js";import{g,ye,u,me,F,ue,Re,c,e,y,B,ve,Gn,Ut,lt,qt,_,De,L,Ne,jt,ie,ht,G,U,Xn,Qn,T,zt,Cr,Lo,Wt,Ht,Qr,ce,Tt,Be,te,Pe,Yr,Zr,Vt,Jr,Ro,gt,Sr,eo,to,ro,Ir,oo,no,Et,kr,ao,io,so,lo,uo,co,Ye,Ze,Ae,Te,Mt,Ot,Lr,Yn,je,Kt,fo,Fe,Ee,Po,Zn,Me,ze,po,We,Je,Rr,mo,Oe,Jn,He,Ve,et,yt}from"/assets/index-z7c4qz9d.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import"/assets/index-d09hs7ex.js";import{useMemo as bt,useState as It}from"react";import Fr from"styled-components";import{useMemo as Ka,useState as ia}from"react";import Qe from"styled-components";import{jsx as xe,jsxs as At}from"react/jsx-runtime";var Pt=53,_e=9,ot=2,Ua=Qe.div.withConfig({displayName:"ActivityGrid__Frame"})(["display:flex;gap:","px;"],ot),qa=Qe.div.withConfig({displayName:"ActivityGrid__Weekdays"})(["display:grid;grid-template-rows:repeat(7,","px);gap:","px;padding-top:","px;font-size:9px;color:",";"],_e,ot,_e+ot,({theme:i})=>i.color.inkFaint),za=Qe.div.withConfig({displayName:"ActivityGrid__Weekday"})(["line-height:","px;padding-right:2px;text-align:right;"],_e),Ga=Qe.div.withConfig({displayName:"ActivityGrid__Months"})(["display:grid;grid-template-columns:repeat(",",","px);gap:","px;height:","px;font-size:9px;color:",";"],Pt,_e,ot,_e,({theme:i})=>i.color.inkFaint),_a=Qe.div.withConfig({displayName:"ActivityGrid__Month"})(["white-space:nowrap;line-height:","px;"],_e),Fa=Qe.div.withConfig({displayName:"ActivityGrid__Weeks"})(["display:grid;grid-template-columns:repeat(",",","px);gap:","px;"],Pt,_e,ot),ja=Qe.div.withConfig({displayName:"ActivityGrid__Week"})(["display:grid;grid-template-rows:repeat(7,","px);gap:","px;"],_e,ot),na=Qe.div.withConfig({displayName:"ActivityGrid__Cell"})(["width:","px;height:","px;border-radius:2px;background:",";border:1px solid var(--rule);visibility:",";&:hover,&:focus-visible{outline:1px solid var(--ink-dim);outline-offset:1px;}"],_e,_e,({$level:i})=>i===0?"var(--panel-sunk)":`color-mix(in oklch, var(--accent) ${[0,24,46,70,100][i]??100}%, var(--panel-sunk))`,({$future:i})=>i?"hidden":"visible"),Xa=Qe(o).withConfig({displayName:"ActivityGrid__Scale"})(["gap:","px;"],ot),Va=Qe(d).withConfig({displayName:"ActivityGrid__Readout"})(["color:",";font-size:11px;"],({theme:i})=>i.color.inkDim);function Ya(i){let n=i.filter((m)=>m>0).sort((m,b)=>m-b);if(n.length===0)return[0,0,0];let p=(m)=>n[Math.min(n.length-1,Math.floor(n.length*m))]??0;return[p(0.25),p(0.5),p(0.75)]}function Ha(i,[n,p,m]){if(i<=0)return 0;if(i<=n)return 1;if(i<=p)return 2;if(i<=m)return 3;return 4}function oa({days:i,now:n,dayOffsetMinutes:p=null}){let[m,b]=ia("tokens"),[h,D]=ia(null),x=fo(m),O=Ka(()=>{let v=new Map;for(let A of i){let Z=Number(A.key);if(!Number.isFinite(Z))continue;v.set(Ee(Z,p),{requests:A.requests,errors:A.errors,costUsd:A.costUsd,inputTokens:A.inputTokens,outputTokens:A.outputTokens,cacheReadTokens:A.cacheReadTokens,cacheWriteTokens:A.cacheWriteTokens,rtkSavedTokens:A.rtkSavedTokens,rtkAppliedRequests:A.rtkAppliedRequests,durationMsSum:A.durationMsSum})}let S=Ee(n,p),Y=Po(S,6-Zn(S,p)-(Pt*7-1),p);return Array.from({length:Pt},()=>Array.from({length:7},()=>{let A=Y;return Y=Po(Y,1,p),{at:A,totals:v.get(A)??We,future:A>S}}))},[i,n,p]),P=O.flat(),C=Ya(P.map((v)=>x.of({key:"",...v.totals}))),I=P.reduce((v,S)=>Je(v,Oe(S.totals)),We),W=P.reduce((v,S)=>v+(S.totals.requests>0?1:0),0),j=(v,S)=>`${v}: ${a(S.requests)} requests, ${a(je(S))} tokens, ${w(S.costUsd)}`;return xe(f,{legend:"Activity",meta:h===null?`${a(W)} active days`:void 0,actions:xe(Xe,{children:Kt.map((v)=>xe(st,{type:"button",$size:"sm",$on:v.id===m,"aria-pressed":v.id===m,onClick:()=>b(v.id),children:v.label},v.id))}),children:At(r,{$gap:2,children:[xe(Q,{children:xe(r,{$gap:1,style:{width:Pt*(_e+ot)+28},children:At(Ua,{children:[xe(qa,{"aria-hidden":"true",children:["","Mon","","Wed","","Fri",""].map((v,S)=>xe(za,{children:v},S))}),At(r,{$gap:1,children:[xe(Ga,{"aria-hidden":"true",children:O.map((v,S)=>{let Y=v[0],A=O[S-1]?.[0],Z=Y!==void 0&&(A===void 0||new Date(A.at).getMonth()!==new Date(Y.at).getMonth());return xe(_a,{children:Z&&Y!==void 0?new Date(Y.at).toLocaleDateString("en-GB",{month:"short"}):""},Y?.at??S)})}),xe(Fa,{role:"grid","aria-label":`${x.label} per day over the last year`,children:O.map((v)=>xe(ja,{role:"row",children:v.map((S)=>xe(na,{role:"gridcell",tabIndex:-1,"aria-label":j(po(S.at),S.totals),title:j(po(S.at),S.totals),$future:S.future,$level:S.future?0:Ha(x.of({key:"",...S.totals}),C),onMouseEnter:()=>D(S),onMouseLeave:()=>D(null)},S.at))},v[0]?.at))})]})]})})}),At(o,{$justify:"space-between",$wrap:!0,children:[xe(Va,{children:h===null?j("Last 12 months",I):j(po(h.at),h.totals)}),At(o,{$gap:1,children:[xe(t,{children:"Less"}),xe(Xa,{"aria-hidden":"true",children:[0,1,2,3,4].map((v)=>xe(na,{$level:v,$future:!1},v))}),xe(t,{children:"More"})]})]})]})})}import{jsx as be,jsxs as Yt}from"react/jsx-runtime";function sa({buckets:i,by:n,since:p,until:m,metric:b,names:h,dayOffsetMinutes:D}){let x=Me(p,m,n,D),O=new Map,P=new Map;for(let I of i){let W=I.split??"unknown";O.set(W,Je(O.get(W)??We,I));let j=P.get(W)??new Map,v=Fe(I.key,n);j.set(v,(j.get(v)??0)+b.of(I)),P.set(W,j)}let C=[...O.entries()].sort((I,W)=>b.of(Oe(W[1]))-b.of(Oe(I[1])));return be(Q,{children:Yt(q,{children:[be("thead",{children:Yt("tr",{children:[be(l,{children:"Key"}),be(l,{children:"Trend"}),be(l,{$align:"right",children:"Requests"}),be(l,{$align:"right",children:"Failed"}),be(l,{$align:"right",children:"Tokens"}),be(l,{$align:"right",children:"Mean"}),be(l,{$align:"right",children:"Cost"})]})}),be("tbody",{children:C.map(([I,W])=>{let j=P.get(I)??new Map,v=I==="unknown"?"Unattributed":h.get(I)??I;return Yt(E,{children:[be(s,{children:be(M,{style:{display:"block",maxWidth:"28ch"},children:v})}),be(s,{style:{width:120},children:be(K,{values:x.map((S)=>j.get(S)??0),height:20,label:`${v}: ${b.format(b.of(Oe(W)))} over the window`})}),be(s,{$align:"right",$mono:!0,children:a(W.requests)}),be(s,{$align:"right",$mono:!0,style:W.errors>0?{color:"var(--down)"}:void 0,children:N(W.requests===0?0:W.errors/W.requests,0)}),be(s,{$align:"right",$mono:!0,children:a(je(W))}),be(s,{$align:"right",$mono:!0,children:V(W.requests===0?null:W.durationMsSum/W.requests)}),be(s,{$align:"right",$mono:!0,children:w(W.costUsd)})]},I)})})]})})}import*as ee from"react";import{PureComponent as fr,useMemo as hr,useRef as ka}from"react";function Lt(i,n){var p,m;return(p=(m=i.graphicalItems.cartesianItems.find((b)=>b.id===n))===null||m===void 0?void 0:m.xAxisId)!==null&&p!==void 0?p:Ro}function Bt(i,n){var p,m;return(p=(m=i.graphicalItems.cartesianItems.find((b)=>b.id===n))===null||m===void 0?void 0:m.yAxisId)!==null&&p!==void 0?p:Ro}var la=(i,n,p)=>Ht(i,"xAxis",Lt(i,n),p),da=(i,n,p)=>Wt(i,"xAxis",Lt(i,n),p),ca=(i,n,p)=>Ht(i,"yAxis",Bt(i,n),p),ua=(i,n,p)=>Wt(i,"yAxis",Bt(i,n),p),Za=e([L,la,ca,da,ua],(i,n,p,m,b)=>{if(ve(i,"xAxis"))return lt(n,m,!1);return lt(p,b,!1)}),Ja=(i,n)=>n,Zt=e([Cr,Ja],(i,n)=>i.filter((p)=>p.type==="area").find((p)=>p.id===n)),pa=(i)=>{var n=L(i),p=ve(n,"xAxis");return p?"yAxis":"xAxis"},Qa=(i,n)=>{var p=pa(i);if(p==="yAxis")return Bt(i,n);return Lt(i,n)},ma=(i,n,p)=>Lo(i,pa(i),Qa(i,n),p),er=e([Zt,ma],(i,n)=>{var p;if(i==null||n==null)return;var m=i.stackId,b=zt(i);if(m==null||b==null)return;var h=(p=n[m])===null||p===void 0?void 0:p.stackedData,D=h===null||h===void 0?void 0:h.find((x)=>x.key===b);if(D==null)return;return D.map((x)=>[x[0],x[1]])}),tr=e([Zt,ma],(i,n)=>{if(i==null||i.stackId==null||n==null)return;var p=n[i.stackId];if(p==null)return;return p.graphicalItems.map((m)=>m.dataKey).filter(ue)}),fa=e([L,la,ca,da,ua,er,Xn,Za,Zt,Qn,tr],(i,n,p,m,b,h,D,x,O,P,C)=>{var{chartData:I,dataStartIndex:W,dataEndIndex:j}=D;if(O==null||i!=="horizontal"&&i!=="vertical"||n==null||p==null||m==null||b==null||m.length===0||b.length===0||x==null)return;var v=O.data,S;if(v&&v.length>0)S=v;else S=I===null||I===void 0?void 0:I.slice(W,j+1);if(S==null)return;return ha({layout:i,xAxis:n,yAxis:p,xAxisTicks:m,yAxisTicks:b,dataStartIndex:W,areaSettings:O,stackedData:h,displayedData:S,chartBaseValue:P,bandSize:x,stackDataKeys:C})});import*as $e from"react";var ar=["animationElapsedTime","isAnimating","isEntrance","layout","isRange","stroke","connectNulls"],rr=["id","baseLine"];function Ct(){return Ct=Object.assign?Object.assign.bind():function(i){for(var n=1;n<arguments.length;n++){var p=arguments[n];for(var m in p)({}).hasOwnProperty.call(p,m)&&(i[m]=p[m])}return i},Ct.apply(null,arguments)}function va(i,n){if(i==null)return{};var p,m,b=ir(i,n);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(i);for(m=0;m<h.length;m++)p=h[m],n.indexOf(p)===-1&&{}.propertyIsEnumerable.call(i,p)&&(b[p]=i[p])}return b}function ir(i,n){if(i==null)return{};var p={};for(var m in i)if({}.hasOwnProperty.call(i,m)){if(n.indexOf(m)!==-1)continue;p[m]=i[m]}return p}function nr(i){var n,p,{alpha:m,baseLine:b,points:h,strokeWidth:D}=i,x=(n=h[0])===null||n===void 0?void 0:n.x,O=(p=h[h.length-1])===null||p===void 0?void 0:p.x;if(!y(x)||!y(O))return null;var P=m*Math.abs(x-O),C=Math.max(...h.map((I)=>I.y||0));if(u(b))C=Math.max(b,C);else if(b&&Array.isArray(b)&&b.length)C=Math.max(...b.map((I)=>I.y||0),C);if(u(C))return $e.createElement("rect",{x:x<O?x:x-P,y:0,width:P,height:Math.floor(C+(D?parseInt("".concat(D),10):1))});return null}function or(i){var n,p,{alpha:m,baseLine:b,points:h,strokeWidth:D}=i,x=(n=h[0])===null||n===void 0?void 0:n.y,O=(p=h[h.length-1])===null||p===void 0?void 0:p.y;if(!y(x)||!y(O))return null;var P=m*Math.abs(x-O),C=Math.max(...h.map((I)=>I.x||0));if(u(b))C=Math.max(b,C);else if(b&&Array.isArray(b)&&b.length)C=Math.max(...b.map((I)=>I.x||0),C);if(u(C))return $e.createElement("rect",{x:0,y:x<O?x:x-P,width:C+(D?parseInt("".concat(D),10):1),height:Math.floor(P)});return null}function sr(i){var{alpha:n,layout:p,points:m,baseLine:b,strokeWidth:h}=i;if(p==="vertical")return $e.createElement(or,{alpha:n,points:m,baseLine:b,strokeWidth:h});return $e.createElement(nr,{alpha:n,points:m,baseLine:b,strokeWidth:h})}function ya(i){var n=i.animationElapsedTime,p=n===void 0?1:n,m=i.isAnimating,b=m===void 0?!1:m,h=i.isEntrance,D=h===void 0?!1:h,{layout:x,isRange:O,stroke:P,connectNulls:C}=i,I=va(i,ar),W=x==="vertical"?"vertical":"horizontal",j=C!==null&&C!==void 0?C:!1,v=to(),{id:S,baseLine:Y}=I,A=va(I,rr),Z=ie(A),re=$e.createElement(ht,Ct({},I,{id:S,baseLine:Y,connectNulls:j,stroke:"none",className:"recharts-area-area",layout:W})),le=P!=="none"&&$e.createElement(ht,Ct({},Z,{className:"recharts-area-curve",layout:W,type:I.type,connectNulls:j,fill:"none",stroke:P,points:I.points})),ne=P!=="none"&&O&&Array.isArray(Y)&&$e.createElement(ht,Ct({},Z,{className:"recharts-area-curve",layout:W,type:I.type,connectNulls:j,fill:"none",stroke:P,points:Y}));if(D&&(b||p<1)){var ae;return $e.createElement(te,null,$e.createElement("defs",null,$e.createElement("clipPath",{id:v},$e.createElement(sr,{alpha:p,points:(ae=I.points)!==null&&ae!==void 0?ae:[],baseLine:Y,layout:W,strokeWidth:I.strokeWidth}))),$e.createElement(te,{clipPath:"url(#".concat(v,")")},re,le,ne))}return $e.createElement($e.Fragment,null,re,le,ne)}var lr=["id"],dr=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Dt(){return Dt=Object.assign?Object.assign.bind():function(i){for(var n=1;n<arguments.length;n++){var p=arguments[n];for(var m in p)({}).hasOwnProperty.call(p,m)&&(i[m]=p[m])}return i},Dt.apply(null,arguments)}function ba(i,n){if(i==null)return{};var p,m,b=cr(i,n);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(i);for(m=0;m<h.length;m++)p=h[m],n.indexOf(p)===-1&&{}.propertyIsEnumerable.call(i,p)&&(b[p]=i[p])}return b}function cr(i,n){if(i==null)return{};var p={};for(var m in i)if({}.hasOwnProperty.call(i,m)){if(n.indexOf(m)!==-1)continue;p[m]=i[m]}return p}function ga(i,n){var p=Object.keys(i);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(i);n&&(m=m.filter(function(b){return Object.getOwnPropertyDescriptor(i,b).enumerable})),p.push.apply(p,m)}return p}function vt(i){for(var n=1;n<arguments.length;n++){var p=arguments[n]!=null?arguments[n]:{};n%2?ga(Object(p),!0).forEach(function(m){ur(i,m,p[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(p)):ga(Object(p)).forEach(function(m){Object.defineProperty(i,m,Object.getOwnPropertyDescriptor(p,m))})}return i}function ur(i,n,p){return(n=pr(n))in i?Object.defineProperty(i,n,{value:p,enumerable:!0,configurable:!0,writable:!0}):i[n]=p,i}function pr(i){var n=mr(i,"string");return typeof n=="symbol"?n:n+""}function mr(i,n){if(typeof i!="object"||!i)return i;var p=i[Symbol.toPrimitive];if(p!==void 0){var m=p.call(i,n||"default");if(typeof m!="object")return m;throw TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(i)}var vr=(i,n)=>{if(i==null)return[];if(n===1)return i.flatMap((p)=>p.status==="removed"?[]:[p.next]);return i.flatMap((p)=>{if(p.status==="matched")return[vt(vt({},p.next),{},{x:me(p.prev.x,p.next.x,n),y:me(p.prev.y,p.next.y,n)})];if(p.status==="added")return[p.next];return[]})},xa={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",animationMatchBy:Et,animationInterpolateFn:vr,connectNulls:!1,dot:!1,fill:"#3182bd",fillOpacity:0.6,hide:!1,isAnimationActive:"auto",legendType:"line",stroke:"#3182bd",strokeWidth:1,type:"linear",label:!1,shape:ya,xAxisId:0,yAxisId:0,zIndex:T.area};function Gt(i,n){return i&&i!=="none"?i:n}var gr=(i)=>{var{dataKey:n,name:p,stroke:m,fill:b,legendType:h,hide:D}=i;return[{inactive:D,dataKey:n,type:h,color:Gt(m,b),value:qt(p,n),payload:i}]},br=ee.memo((i)=>{var{dataKey:n,data:p,stroke:m,strokeWidth:b,fill:h,name:D,hide:x,unit:O,formatter:P,tooltipType:C,id:I}=i,W={dataDefinedOnItem:p,getPosition:Re,settings:{stroke:m,strokeWidth:b,fill:h,dataKey:n,nameKey:void 0,name:qt(D,n),hide:x,type:C,color:Gt(m,h),unit:O,formatter:P,graphicalItemId:I}};return ee.createElement(eo,{tooltipEntrySettings:W})});function xr(i){var{clipPathId:n,points:p,props:m}=i,{needClip:b,dot:h,dataKey:D}=m,x=ie(m);return ee.createElement(Jr,{points:p,dot:h,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:D,baseProps:x,needClip:b,clipPathId:n})}function Ar(i){var{showLabels:n,children:p,points:m}=i,b=m.map((h)=>{var D,x,O={x:(D=h.x)!==null&&D!==void 0?D:0,y:(x=h.y)!==null&&x!==void 0?x:0,width:0,lowerWidth:0,upperWidth:0,height:0};return vt(vt({},O),{},{value:h.value,payload:h.payload,parentViewBox:void 0,viewBox:O,fill:void 0})});return ee.createElement(Yr,{value:n?b:void 0},p)}function Tr(i){var{points:n,baseLine:p,needClip:m,clipPathId:b,props:h,animationElapsedTime:D,isAnimating:x,isEntrance:O}=i,{layout:P,type:C,stroke:I,connectNulls:W,isRange:j,shape:v,id:S}=h,Y=ba(h,lr),A=G(Y),Z=vt(vt({},A),{},{id:S,points:n,connectNulls:W,type:C,baseLine:p,layout:P,stroke:I,isRange:j,animationElapsedTime:D,isAnimating:x,isEntrance:O});return ee.createElement(ee.Fragment,null,(n===null||n===void 0?void 0:n.length)>1&&ee.createElement(te,{clipPath:m?"url(#clipPath-".concat(b,")"):void 0},ee.createElement(co,{option:v,DefaultShape:xa.shape,shapeProps:Z})),ee.createElement(xr,{points:n,props:Y,clipPathId:b}))}function Pr(i,n,p){if(u(i)){var m=u(n)?n:void 0;return me(m,i,p)}if(F(i)||ye(i)){var b=u(n)?n:void 0;return me(b,0,p)}return i}function wr(i){var{needClip:n,clipPathId:p,props:m,previousPointsRef:b,previousBaselineRef:h}=i,{points:D,baseLine:x,isAnimationActive:O,animationBegin:P,animationDuration:C,animationEasing:I,animationMatchBy:W,animationInterpolateFn:j}=m,v=hr(()=>({points:D,baseLine:x}),[D,x]),S=ao(v,h),Y=jt(),A=io(m.onAnimationStart,m.onAnimationEnd),{isAnimating:Z,handleAnimationStart:re,handleAnimationEnd:le}=A,ne=S.startValue;if(Y==null)return null;var ae;if(Array.isArray(x)&&Array.isArray(ne))ae=kr(ne,x,W);else if(Array.isArray(x))ae=kr(null,x,W);else ae=null;return ee.createElement(so,{animationInput:v,animationIdPrefix:"recharts-area-",items:D,previousItemsRef:b,isAnimationActive:O,animationBegin:P,animationDuration:C,animationEasing:I,onAnimationStart:re,onAnimationEnd:le,animationInterpolateFn:j,animationMatchBy:W,layout:Y},(ge,he,Ce)=>{var ke;if(he===1)ke=x;else if(Array.isArray(x))ke=j(ae,he,Y);else ke=Ce?x:Pr(x,ne,he);return S.syncStepValue(ke,he),ee.createElement(Ar,{showLabels:!Z,points:D},m.children,ee.createElement(Tr,{points:ge,baseLine:ke,needClip:n,clipPathId:p,props:m,animationElapsedTime:he,isAnimating:Z||he<1,isEntrance:Ce}),ee.createElement(Zr,{label:m.label}))})}function $r(i){var{needClip:n,clipPathId:p,props:m}=i,b=ka(null),h=ka();return ee.createElement(wr,{needClip:n,clipPathId:p,props:m,previousPointsRef:b,previousBaselineRef:h})}class Aa extends fr{render(){var i=this.props,{hide:n,dot:p,points:m,className:b,top:h,left:D,needClip:x,xAxisId:O,yAxisId:P,width:C,height:I,id:W,baseLine:j,zIndex:v}=i;if(n)return null;var S=g("recharts-area",b),Y=W,A=uo(p),{r:Z,strokeWidth:re}=A,le=Vt(p),ne=Z*2+re,ae=x?"url(#clipPath-".concat(le?"":"dots-").concat(Y,")"):void 0;return ee.createElement(ce,{zIndex:v},ee.createElement(te,{className:S},x&&ee.createElement("defs",null,ee.createElement(oo,{clipPathId:Y,xAxisId:O,yAxisId:P}),!le&&ee.createElement("clipPath",{id:"clipPath-dots-".concat(Y)},ee.createElement("rect",{x:D-ne/2,y:h-ne/2,width:C+ne,height:I+ne}))),ee.createElement($r,{needClip:x,clipPathId:Y,props:this.props})),ee.createElement(Sr,{points:m,mainColor:Gt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:ae}),this.props.isRange&&Array.isArray(j)&&ee.createElement(Sr,{points:j,mainColor:Gt(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:ae}))}}function Mr(i){var n,{activeDot:p,animationBegin:m,animationDuration:b,animationEasing:h,connectNulls:D,dot:x,fill:O,fillOpacity:P,hide:C,isAnimationActive:I,legendType:W,stroke:j,xAxisId:v,yAxisId:S}=i,Y=ba(i,dr),A=Ne(),Z=Qr(),re=Ir(v,S),le=re.needClip,ne=_(),ae=(n=c((mt)=>fa(mt,i.id,ne)))!==null&&n!==void 0?n:{},{points:ge,isRange:he,baseLine:Ce}=ae,ke=gt();if(A!=="horizontal"&&A!=="vertical"||ke==null)return null;if(Z!=="AreaChart"&&Z!=="ComposedChart")return null;var{height:qe,width:tt,x:at,y:pt}=ke;if(!ge||!ge.length)return null;return ee.createElement(Aa,Dt({},Y,{activeDot:p,animationBegin:m,animationDuration:b,animationEasing:h,baseLine:Ce,connectNulls:D,dot:x,fill:O,fillOpacity:P,height:qe,hide:C,layout:A,isAnimationActive:I,isRange:he,legendType:W,needClip:le,points:ge,stroke:j,width:tt,left:at,top:pt,xAxisId:v,yAxisId:S}))}var Er=(i,n,p,m,b)=>{var h=p!==null&&p!==void 0?p:n;if(u(h))return h;var D=i==="horizontal"?b:m,x=D.scale.domain();if(D.type==="number"){var O=Math.max(x[0],x[1]),P=Math.min(x[0],x[1]);if(h==="dataMin")return P;if(h==="dataMax")return O;return O<0?O:Math.max(Math.min(x[0],x[1]),0)}if(h==="dataMin")return x[0];if(h==="dataMax")return x[1];return x[0]};function ha(i){var n=i.areaSettings,{connectNulls:p,baseValue:m,dataKey:b}=n,{stackedData:h,layout:D,chartBaseValue:x,xAxis:O,yAxis:P,displayedData:C,dataStartIndex:I,xAxisTicks:W,yAxisTicks:j,bandSize:v,stackDataKeys:S}=i,Y=h&&h.length,A=Er(D,x,m,O,P),Z=D==="horizontal",re=!1,le=C.map((ae,ge)=>{var he,Ce,ke,qe;if(Y)qe=h[I+ge];else{var tt=B(ae,b);if(!Array.isArray(tt))qe=[A,tt];else qe=tt,re=!0}var at=(he=(Ce=qe)===null||Ce===void 0?void 0:Ce[1])!==null&&he!==void 0?he:null,pt=B(ae,b),mt=Y&&pt==null&&S!=null&&S.length>0&&S.every((Ft)=>B(ae,Ft)==null),Nt=at==null||Y&&!p&&pt==null||mt;if(Z){var xt;return{x:Ut({axis:O,ticks:W,bandSize:v,entry:ae,index:ge}),y:Nt?null:(xt=P.scale.map(at))!==null&&xt!==void 0?xt:null,value:qe,payload:ae}}return{x:Nt?null:(ke=O.scale.map(at))!==null&&ke!==void 0?ke:null,y:Ut({axis:P,ticks:j,bandSize:v,entry:ae,index:ge}),value:qe,payload:ae}}),ne;if(Y||re)ne=le.map((ae)=>{var ge,he=Array.isArray(ae.value)?ae.value[0]:null;if(Z){var Ce;return{x:ae.x,y:he!=null&&ae.y!=null?(Ce=P.scale.map(he))!==null&&Ce!==void 0?Ce:null:null,payload:ae.payload}}return{x:he!=null?(ge=O.scale.map(he))!==null&&ge!==void 0?ge:null:null,y:ae.y,payload:ae.payload}});else ne=Z?P.scale.map(A):O.scale.map(A);return{points:le,baseLine:ne!==null&&ne!==void 0?ne:0,isRange:re}}function Nr(i){var n=U(i,xa),p=_();return ee.createElement(ro,{id:n.id,type:"area"},(m)=>ee.createElement(ee.Fragment,null,ee.createElement(no,{legendPayload:gr(n)}),ee.createElement(br,{dataKey:n.dataKey,data:n.data,stroke:n.stroke,strokeWidth:n.strokeWidth,fill:n.fill,name:n.name,hide:n.hide,unit:n.unit,formatter:n.formatter,tooltipType:n.tooltipType,id:m}),ee.createElement(lo,{type:"area",id:m,data:n.data,dataKey:n.dataKey,xAxisId:n.xAxisId,yAxisId:n.yAxisId,zAxisId:0,stackId:Gn(n.stackId),hide:n.hide,barSize:void 0,baseValue:n.baseValue,isPanorama:p,connectNulls:n.connectNulls}),ee.createElement(Mr,Dt({},n,{id:m}))))}var rt=ee.memo(Nr,Ye);rt.displayName="Area";import*as Ta from"react";import{forwardRef as Or}from"react";var Br=["axis"],kt=Or((i,n)=>Ta.createElement(Mt,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Br,tooltipPayloadSearcher:Tt,categoricalChartProps:i,ref:n}));import*as Pa from"react";import{forwardRef as Dr}from"react";var Wr=["axis"],Ca=Dr((i,n)=>Pa.createElement(Mt,{chartName:"ComposedChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Wr,tooltipPayloadSearcher:Tt,categoricalChartProps:i,ref:n}));import{jsx as Ge,jsxs as St}from"react/jsx-runtime";var Sa=6,Ra="__other__",wa="unknown";function Ia(i,n,p){let m=p.get(n);if(m!==void 0)return m;return i.find((b)=>b.models.some((h)=>h.id===n))?.id??null}function Kr(i,n){if(i===null)return"var(--ink-faint)";return`color-mix(in oklch, ${oe(i)} ${Math.max(30,100-n*22)}%, var(--panel))`}function $a({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b,metric:h,providers:D}){let x=fe().data??[],O=[...mo(i,h).entries()],P=O.slice(0,Sa),C=O.slice(Sa),I=[...new Set(P.map(([A])=>Ia(x,A,D)))].filter((A)=>A!==null&&z(x,A)===void 0).sort(),W=[];for(let A of[...x.map((Z)=>Z.id),...I,null])P.filter(([Z])=>Ia(x,Z,D)===A).forEach(([Z,re],le)=>{W.push({name:Z,label:Z===wa?"Unresolved":Z,color:Kr(A,le),totals:re})});if(C.length>0)W.push({name:Ra,label:`${C.length} more`,color:"var(--ink-faint)",totals:C.reduce((A,[,Z])=>Je(A,Oe(Z)),We)});let j=new Set(P.map(([A])=>A)),v=new Map;for(let A of i){let Z=A.split??wa,re=`${Fe(A.key,n)} ${j.has(Z)?Z:Ra}`;v.set(re,(v.get(re)??0)+h.of(A))}let S=Me(p,m,n,b).map((A)=>{let Z={at:A};for(let re of W)Z[re.name]=v.get(`${A} ${re.name}`)??0;return Z}),Y=new Map(W.map((A)=>[A.name,A.label]));return St(r,{$gap:2,children:[Ge(He,{$height:220,children:Ge(De,{width:"100%",height:"100%",children:St(kt,{data:S,margin:{top:4,right:4,bottom:4,left:4},children:[Ge(Pe,{stroke:"var(--rule)",vertical:!1}),Ge(Ae,{dataKey:"at",tickFormatter:(A)=>ze(A,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Ge(Te,{tickFormatter:(A)=>h.format(A),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:40}),Ge(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:A,payload:Z,label:re})=>{if(A!==!0||Z===void 0||Z.length===0)return null;let le=Z.filter((ne)=>Number(ne.value??0)>0);return St(Ve,{children:[Ge("div",{children:ze(Number(re),n)}),le.length===0?Ge("div",{children:`No ${h.label.toLowerCase()}`}):le.map((ne)=>St("div",{children:[Y.get(String(ne.dataKey))??String(ne.dataKey)," ",h.format(Number(ne.value??0))]},String(ne.dataKey)))]})}}),W.map((A)=>Ge(rt,{type:"monotone",dataKey:A.name,stackId:"models",stroke:A.color,strokeWidth:2,fill:A.color,fillOpacity:0.22,isAnimationActive:!1},A.name))]})})}),Ge(yt,{children:W.map((A)=>St("span",{children:[Ge(et,{$color:A.color})," ",Ge(M,{title:`${A.label}: ${h.format(h.of(Oe(A.totals)))} ${h.label.toLowerCase()}`,style:{display:"inline-block",maxWidth:"24ch",verticalAlign:"bottom"},children:A.label})]},A.name))})]})}import{jsx as de,jsxs as it}from"react/jsx-runtime";var Qt="unknown";function _t(i,n){return z(i,n)===void 0?"var(--ink-faint)":oe(n)}function Jt(i,n){if(n===Qt)return"Unresolved";return z(i,n)?.label??n}function Ma({buckets:i,by:n,since:p,until:m,metric:b,dayOffsetMinutes:h}){let D=fe().data??[],x=mo(i,b),O=[...x.keys()].filter((v)=>v!==Qt&&z(D,v)===void 0).sort(),P=[...D.map((v)=>v.id),...O,Qt].map((v)=>({name:v,totals:x.get(v)})).filter((v)=>v.totals!==void 0),C=P.map((v)=>v.name),I=Me(p,m,n,h),W=Jn(i,I,n,b),j=[...x.values()].reduce((v,S)=>v+S.requests,0);return it(r,{$gap:3,children:[de(He,{$height:200,children:de(De,{width:"100%",height:"100%",children:it(kt,{data:W,margin:{top:4,right:4,bottom:4,left:4},children:[de(Pe,{stroke:"var(--rule)",vertical:!1}),de(Ae,{dataKey:"at",tickFormatter:(v)=>ze(v,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),de(Te,{tickFormatter:(v)=>b.format(v),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:48}),de(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:v,payload:S,label:Y})=>{if(v!==!0||S===void 0||S.length===0)return null;return it(Ve,{children:[de("div",{children:ze(Number(Y),n)}),S.map((A)=>it("div",{children:[Jt(D,String(A.dataKey))," ",b.format(Number(A.value??0))]},String(A.dataKey)))]})}}),C.map((v)=>de(rt,{type:"monotone",dataKey:v,stackId:"providers",stroke:_t(D,v),strokeWidth:2,fill:_t(D,v),fillOpacity:0.22,isAnimationActive:!1},v))]})})}),de(yt,{children:C.map((v)=>it("span",{children:[de(et,{$color:_t(D,v)})," ",Jt(D,v)]},v))}),it(q,{children:[de("thead",{children:it("tr",{children:[de(l,{children:"Provider"}),de(l,{$align:"right",children:"Share"}),de(l,{$align:"right",children:"Requests"}),de(l,{$align:"right",children:"Failed"}),de(l,{$align:"right",children:"Tokens"}),de(l,{$align:"right",children:"Cost"})]})}),de("tbody",{children:P.map(({name:v,totals:S})=>it(E,{children:[it(s,{children:[de(et,{$color:_t(D,v)})," ",Jt(D,v)]}),de(s,{$align:"right",$mono:!0,children:N(j===0?0:S.requests/j,0)}),de(s,{$align:"right",$mono:!0,children:a(S.requests)}),de(s,{$align:"right",$mono:!0,style:S.errors>0?{color:"var(--down)"}:void 0,children:a(S.errors)}),de(s,{$align:"right",$mono:!0,children:a(je(S))}),de(s,{$align:"right",$mono:!0,children:w(S.costUsd)})]},v))})]})]})}import Rt from"styled-components";import{jsx as ut,jsxs as ea}from"react/jsx-runtime";var Ur=Rt.li.withConfig({displayName:"RankPanel__Rank"})(["display:grid;grid-template-columns:minmax(0,20ch) 1fr auto;align-items:center;gap:",";"],({theme:i})=>i.space(2)),qr=Rt.ol.withConfig({displayName:"RankPanel__List"})(["display:flex;flex-direction:column;gap:",";"],({theme:i})=>i.space(2)),zr=Rt.div.withConfig({displayName:"RankPanel__Track"})(["height:8px;border-radius:2px;background:",";border:1px solid ",";overflow:hidden;"],({theme:i})=>i.color.panelSunk,({theme:i})=>i.color.rule),Gr=Rt.div.withConfig({displayName:"RankPanel__Fill"})(["width:",";height:100%;border-radius:0 2px 2px 0;background:",";opacity:0.85;"],({$share:i})=>`${Math.max(1.5,i*100)}%`,({theme:i,$fault:n})=>n?i.color.down:i.color.accent),_r=Rt(M).withConfig({displayName:"RankPanel__Name"})(["display:block;font-family:",";font-size:12px;"],({theme:i})=>i.font.mono),Ea=12;function ta({buckets:i,metric:n,names:p,unknownLabel:m}){let b=new Map;for(let C of i)b.set(C.key,Je(b.get(C.key)??We,C));let h=(C)=>C==="unknown"?m??"Unattributed":p?.get(C)??C,D=[...b.entries()].map(([C,I])=>({name:h(C),entry:I,value:n.of(Oe(I))})).sort((C,I)=>I.value-C.value),x=D.slice(0,Ea),O=D.slice(Ea),P=x[0]?.value??0;return ea(r,{$gap:3,children:[ut(qr,{children:x.map(({name:C,entry:I,value:W})=>ea(Ur,{children:[ut(_r,{title:C,children:C}),ut(zr,{children:ut(Gr,{$share:P===0?0:W/P,$fault:I.requests>0&&I.errors===I.requests})}),ea(o,{$gap:2,children:[ut(d,{$size:"12px",children:n.format(W)}),ut(d,{$size:"11px",$dim:!0,children:w(I.costUsd)})]})]},C))}),O.length===0?null:ut(d,{$size:"11px",$dim:!0,children:`+ ${O.length} more, ${a(O.reduce((C,I)=>C+I.entry.requests,0))} requests`})]})}import{jsx as Le,jsxs as wt}from"react/jsx-runtime";var aa=[{id:"inputTokens",label:"Uncached input",opacity:0.95},{id:"outputTokens",label:"Output",opacity:0.7},{id:"cacheReadTokens",label:"Cache read",opacity:0.45},{id:"cacheWriteTokens",label:"Cache write",opacity:0.22}];function Na({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b}){let h=new Map;for(let P of i)h.set(Fe(P.key,n),P);let D=Me(p,m,n,b).map((P)=>{let C=h.get(P);return{at:P,inputTokens:C?.inputTokens??0,outputTokens:C?.outputTokens??0,cacheReadTokens:C?.cacheReadTokens??0,cacheWriteTokens:C?.cacheWriteTokens??0}}),x=aa.map((P)=>({...P,value:D.reduce((C,I)=>C+I[P.id],0)})),O=x.reduce((P,C)=>P+C.value,0);return wt(r,{$gap:3,children:[Le(He,{$height:200,children:Le(De,{width:"100%",height:"100%",children:wt(kt,{data:D,margin:{top:4,right:4,bottom:4,left:4},children:[Le(Pe,{stroke:"var(--rule)",vertical:!1}),Le(Ae,{dataKey:"at",tickFormatter:(P)=>ze(P,n),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Le(Te,{tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:44,tickFormatter:(P)=>a(P)}),Le(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:P,payload:C,label:I})=>{if(P!==!0||C===void 0||C.length===0)return null;return wt(Ve,{children:[Le("div",{children:ze(Number(I),n)}),aa.map((W)=>wt("div",{children:[W.label," ",a(Number(C.find((j)=>j.dataKey===W.id)?.value??0))]},W.id))]})}}),aa.map((P)=>Le(rt,{type:"monotone",dataKey:P.id,stackId:"tokens",stroke:"var(--accent)",strokeOpacity:P.opacity,strokeWidth:1.5,fill:"var(--accent)",fillOpacity:P.opacity*0.5,isAnimationActive:!1},P.id))]})})}),Le(yt,{children:x.map((P)=>wt(o,{$gap:1,children:[Le(et,{$color:"var(--accent)",style:{opacity:P.opacity}}),Le("span",{children:P.label}),Le(d,{$size:"11px",children:a(P.value)}),Le(d,{$size:"11px",$dim:!0,children:N(O===0?0:P.value/O,0)})]},P.id))})]})}import{jsx as Ke,jsxs as nt}from"react/jsx-runtime";function Oa({buckets:i,by:n,since:p,until:m,dayOffsetMinutes:b}){let h=new Map;for(let x of i)h.set(Fe(x.key,n),x);let D=Me(p,m,n,b).map((x)=>{let O=h.get(x);return{at:x,label:ze(x,n),requests:O?.requests??0,errors:O?.errors??0,costUsd:O?.costUsd??0,tokens:O===void 0?0:je(O)}});return nt(r,{$gap:2,children:[Ke(He,{$height:220,children:Ke(De,{width:"100%",height:"100%",children:nt(Ca,{data:D,margin:{top:4,right:4,bottom:4,left:4},children:[Ke(Pe,{stroke:"var(--rule)",vertical:!1}),Ke(Ae,{dataKey:"label",tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",interval:"preserveStartEnd",minTickGap:28}),Ke(Te,{tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:40}),Ke(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:x,payload:O})=>{if(x!==!0||O===void 0||O.length===0)return null;let P=O[0]?.payload;if(P===void 0)return null;return nt(Ve,{children:[Ke("div",{children:P.label}),nt("div",{children:[a(P.requests)," requests"]}),nt("div",{children:[a(P.errors)," failed"]}),nt("div",{children:[a(P.tokens)," tokens"]}),Ke("div",{children:w(P.costUsd)})]})}}),Ke(rt,{type:"monotone",dataKey:"requests",stroke:"none",fill:"var(--accent)",fillOpacity:0.12,isAnimationActive:!1}),Ke(Ze,{type:"monotone",dataKey:"requests",stroke:"var(--accent)",strokeWidth:2,dot:!1,activeDot:{r:4,stroke:"var(--panel)",strokeWidth:2},isAnimationActive:!1}),Ke(Ze,{type:"monotone",dataKey:"errors",stroke:"var(--down)",strokeWidth:2,dot:!1,activeDot:{r:4,stroke:"var(--panel)",strokeWidth:2},isAnimationActive:!1})]})})}),nt(yt,{children:[nt("span",{children:[Ke(et,{$color:"var(--accent)"})," Requests"]}),nt("span",{children:[Ke(et,{$color:"var(--down)"})," Failed"]})]})]})}import{jsx as se,jsxs as $t}from"react/jsx-runtime";var jr=86400000,La=[{id:"requestedModel",label:"As requested",column:"Virtual model"},{id:"model",label:"As served",column:"Upstream model"}],Ba=Fr(R).withConfig({displayName:"UsageBoard__Picker"})(["width:auto;"]);function Da(){let{cadence:i}=X(),[n,p]=It("24h"),[m,b]=It("tokens"),[h,D]=It("model"),[x,O]=It(void 0),[P,C]=It(void 0),I=pe(),W=we(),j=Lr(n),v=fo(m),S=No().data??null,Y=bt(()=>j.grain==="daily"?Ee(Date.now()-j.ms,S):Math.floor((Date.now()-j.ms)/60000)*60000,[j,S]),A=bt(()=>Y+j.ms,[Y,j]),Z=bt(()=>Ee(Date.now()-Yn*jr,S),[S]),re=I.data?.find((J)=>J.id===x),le=W.data?.find((J)=>J.id===P);if(x!==void 0&&I.data!==void 0&&re===void 0)O(void 0);if(P!==void 0&&W.data!==void 0&&le===void 0)C(void 0);let ne={...re===void 0?{}:{credentialId:re.id},...le===void 0?{}:{apiKeyId:le.id}},ae=`${le===void 0?"":` for ${le.label}`}${re===void 0?"":` on ${re.label}`}`,ge={since:Y,grain:j.grain,...ne},he=Ue({...ge,groupBy:j.by},i(60000,"res:usage")),Ce=Ue({...ge,groupBy:j.by,splitBy:"provider"},i(60000,"res:usage")),ke=Ue({...ge,groupBy:j.by,splitBy:"model"},i(60000,"res:usage")),qe=Ue({...ge,groupBy:j.by,splitBy:"apiKey"},i(60000,"res:usage")),tt=Ue({...ge,groupBy:h},i(60000,"res:usage")),at=Ue({...ge,groupBy:"credential"},i(60000,"res:usage")),pt=Ue({since:Z,grain:"daily",groupBy:"day",...ne},i(300000,"res:usage")),mt=H(),Nt=bt(()=>{let J=new Map;for(let ct of mt.data??[])for(let ra of ct.targets)J.set(ra.model,ra.provider);return J},[mt.data]),xt=bt(()=>{let J=new Map;for(let ct of W.data??[])J.set(ct.id,ct.label);return J},[W.data]),Ft=bt(()=>{let J=new Map;for(let ct of I.data??[])J.set(ct.id,ct.label);return J},[I.data]),ft=he.data??[],Xt=Rr(ft),Wa=je(Xt),dt={legend:"Nothing recorded",message:"No requests landed in this window. Widen the range, or send traffic through the gateway."};return $t(r,{$gap:4,children:[se(k,{legend:"Usage",title:"Requests, tokens, and spend",summary:he.isLoading?"Reading usage…":`${a(Xt.requests)} requests and ${w(Xt.costUsd)} over the last ${j.label}${ae}.`,actions:$t(o,{$wrap:!0,children:[se(Ba,{"aria-label":"Account",value:re?.id??"",options:[{value:"",label:"All accounts"},...(I.data??[]).map((J)=>({value:J.id,label:J.label}))],onValueChange:(J)=>O(J||void 0)}),se(Ba,{"aria-label":"Gateway key",value:le?.id??"",options:[{value:"",label:"All keys"},...(W.data??[]).map((J)=>({value:J.id,label:J.label}))],onValueChange:(J)=>C(J||void 0)}),se(Xe,{children:Ot.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===n,"aria-pressed":J.id===n,onClick:()=>p(J.id),children:J.id},J.id))})]})}),se(yr,{buckets:ft,since:Y,until:A,by:j.by,rangeLabel:j.label,dayOffsetMinutes:S}),se(Se,{legend:"Traffic",meta:j.by==="hour"?"By hour":"By day",query:he,isEmpty:ft.length===0,empty:dt,children:se(Oa,{buckets:ft,by:j.by,since:Y,until:A,dayOffsetMinutes:S})}),se(Xe,{children:Kt.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===m,"aria-pressed":J.id===m,onClick:()=>b(J.id),children:`Rank by ${J.label.toLowerCase()}`},J.id))}),se(Se,{legend:"Traffic by upstream model",meta:`${v.label}, ${j.by==="hour"?"by hour":"by day"}`,query:ke,isEmpty:(ke.data??[]).length===0,empty:dt,children:se($a,{buckets:ke.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v,providers:Nt})}),$t(Ie,{$min:"480px",$gap:4,children:[$t(r,{$gap:4,children:[se(Se,{legend:"Providers",meta:v.label,query:Ce,isEmpty:(Ce.data??[]).length===0,empty:dt,children:se(Ma,{buckets:Ce.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v})}),se(oa,{days:pt.data??[],now:Date.now(),dayOffsetMinutes:S})]}),$t(r,{$gap:4,children:[se(Se,{legend:"Token mix",meta:a(Wa),query:he,isEmpty:ft.length===0,empty:dt,children:se(Na,{buckets:ft,by:j.by,since:Y,until:A,dayOffsetMinutes:S})}),se(Se,{legend:"Models",meta:La.find((J)=>J.id===h)?.column,query:tt,isEmpty:(tt.data??[]).length===0,empty:dt,actions:se(Xe,{children:La.map((J)=>se(st,{type:"button",$size:"sm",$on:J.id===h,"aria-pressed":J.id===h,onClick:()=>D(J.id),children:J.label},J.id))}),children:se(ta,{buckets:tt.data??[],metric:v})}),se(Se,{legend:"Accounts",meta:v.label,query:at,isEmpty:(at.data??[]).length===0,empty:dt,children:se(ta,{buckets:at.data??[],metric:v,names:Ft,unknownLabel:"No account"})})]})]}),se(Se,{legend:"API keys",meta:v.label,query:qe,isEmpty:(qe.data??[]).length===0,empty:dt,children:se(sa,{buckets:qe.data??[],by:j.by,since:Y,until:A,dayOffsetMinutes:S,metric:v,names:xt})})]})}var Vo=Da;export{Vo as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n,P,t,d,se,o,r,Q,p,rt,ot,Yt,en,tn,rn,vo,on,nn,an,sn,a,w,N,_e,O,at,wo,or,X,Co,x,b,J,k,Vr,Kr,f}from"/assets/index-p9vbm21a.js";import{$e,R}from"/assets/index-f7t0kve8.js";import{re}from"/assets/index-wjqdtafp.js";import{Se,st,Xe,yr}from"/assets/index-hk28xepa.js";import"/assets/index-8bewp9z1.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{fr,pr,mr,hr,gr}from"/assets/index-sbe0ydnc.js";import"/assets/index-fcew0gga.js";import"/assets/index-xdyjb1an.js";import{Ot,Lr,Ee}from"/assets/index-z7c4qz9d.js";import{$t,wr}from"/assets/index-938qd7p2.js";import"/assets/index-d09hs7ex.js";import{lr}from"/assets/index-4dz4bgrb.js";import{Le}from"/assets/index-zkt5p0qd.js";import ge from"styled-components";import{jsx as me,jsxs as Be}from"react/jsx-runtime";var Oe=ge.div.withConfig({displayName:"ClientShell__Frame"})(['display:grid;grid-template-areas:"chassis" "main";grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);height:100vh;min-height:0;overflow:hidden;']),Qe=ge.main.withConfig({displayName:"ClientShell__Main"})(["grid-area:main;padding:",";display:flex;flex-direction:column;gap:",";min-width:0;min-height:0;overflow-y:auto;@media (max-width:720px){padding:",";}"],({theme:u})=>u.space(4),({theme:u})=>u.space(4),({theme:u})=>u.space(3));function pe({children:u}){let{cadence:y}=X(),A=en(),C=on(200,y(1e4,"res:logs"));return Be(Oe,{"data-testid":"client-shell",children:[me(Co,{logs:C.data??[],logsFailed:C.isError,signOut:{pending:A.isPending,run:()=>{A.mutate(void 0,{onSuccess:()=>window.location.assign("/login")})}}}),me(Qe,{children:u})]})}import{Fragment as he,useMemo as K,useState as U}from"react";import W from"styled-components";import{jsx as e,jsxs as c,Fragment as Ye}from"react/jsx-runtime";var fe=[20,50,100,250],Fe=W(R).withConfig({displayName:"ClientBoard__Narrow"})(["width:auto;"]),De={"1m":"per minute","5h":"per 5 hours","1w":"per week"};function He({reading:u}){let y=u.window===null?"concurrent requests":`${u.dimension} ${De[u.window]??u.window}`,A=u.model===null?y:`${y} for ${u.model}`,C=u.dimension==="spend"?w:a,S=u.used===null?null:u.limit===0?1:u.used/u.limit;return c(E,{children:[e(s,{children:y}),e(s,{$align:"right",$mono:!0,children:u.used===null?e(se,{children:"unknown"}):C(u.used)}),e(s,{$align:"right",$mono:!0,children:C(u.limit)}),e(s,{children:S===null?null:e(re,{fraction:S,label:`${A}, ${Math.round(Math.min(1,S)*100)}% used`})})]})}function ye(u){return{observedAt:u.observedAt,windowType:u.windowType,windowMs:u.windowMs,resetsAt:u.resetsAt,usedRatio:u.usedRatio}}function Ie(u){return{stale:u.stale,rolledOver:u.rolledOver,estimateStale:u.stale||u.rolledOver,survives:u.survives,exhaustsAt:u.exhaustsAt}}var Ue=W.p.withConfig({displayName:"ClientBoard__Policy"})(["font-size:12px;line-height:1.5;color:",";white-space:pre-wrap;overflow-wrap:anywhere;max-width:80ch;"],({theme:u})=>u.color.ink),We=W.div.withConfig({displayName:"ClientBoard__QuotaStack"})(["display:flex;flex-direction:column;gap:4px;"]),ze=W.div.withConfig({displayName:"ClientBoard__QuotaCell"})(["display:grid;grid-template-columns:96px 34px 1fr;align-items:center;min-width:208px;gap:6px;"]),Ge=W(d).withConfig({displayName:"ClientBoard__Percent"})(["font-size:11px;text-align:right;"]);function Ve({windows:u,open:y,onToggle:A}){let C=u[0],S=u.filter((v)=>v.usedRatio!==null);return c(E,{children:[e(s,{children:C.label}),e(s,{children:S.length===0?e(se,{children:"unknown"}):e(We,{children:S.map((v)=>c(ze,{children:[e(re,{fraction:v.usedRatio,label:`${v.label} ${v.windowType} window, ${Math.round(v.usedRatio*100)}% used`}),e(Ge,{children:N(v.usedRatio,0)}),e(t,{children:wo(v,Ie(v),Date.now(),_e)})]},v.windowType))})}),e(s,{$align:"right",children:e(P,{type:"button",$variant:"ghost",$size:"sm","aria-expanded":y,"aria-label":`${y?"Hide":"Show"} quota history for ${C.label}`,title:`${y?"Hide":"Show"} quota history for ${C.label}`,onClick:A,children:y?e($e,{}):e(Le,{})})})]})}function we(){let{cadence:u,live:y}=X(),[A,C]=U("24h"),[S,v]=U(fr),[j,ve]=U(fe[0]),[ee,te]=U(null),[z,Te]=U(null),T=Lr(A),oe=rn().data??null,G=K(()=>T.grain==="daily"?Ee(Date.now()-T.ms,oe):Math.floor((Date.now()-T.ms)/60000)*60000,[T,oe]),Ce=K(()=>G+T.ms,[G,T]),m=tn(),le={since:G,grain:T.grain},de=vo({...le,groupBy:T.by},u(60000,"res:usage")),F=vo({...le,groupBy:"model"},u(60000,"res:usage")),M=nn(S,j,u(rt,"res:logs")),be=!ot(M.data),Re=Yt(p.clientLogPages(S,j)),I=an(60000),V=I.data??[],ue=lr(m.data?.limitUsage??[]),ke=ue.some((i)=>i.model!==null),Me=K(()=>{let i=new Map;for(let g of V){let L=i.get(g.provider)??new Map,B=L.get(g.credentialId);if(B===void 0)L.set(g.credentialId,[g]);else B.push(g);i.set(g.provider,L)}return[...i.entries()].map(([g,L])=>[g,[...L.entries()].map(([B,h])=>({credentialId:B,windows:[...h].sort((Y,H)=>or[Y.windowType]-or[H.windowType])}))])},[V]),ie=V.map((i)=>$t(ye(i))).filter((i)=>i!==null),Ae=ie.length===0?0:Math.floor(Math.min(...ie)/60000)*60000,ce=sn({since:Ae},z!==null&&ie.length>0),D=K(()=>(M.data?.pages??[]).flatMap((i)=>i.logs),[M.data?.pages]),qe=mr(y&&D.some(O)),xe=D.filter(at).length,ne=de.data??[],Ne=ne.reduce((i,g)=>i+g.requests,0),Pe=ne.reduce((i,g)=>i+g.costUsd,0);return c(r,{$gap:4,children:[e(k,{legend:"Client",title:"Your usage",summary:de.isLoading?"Reading your usage…":`${a(Ne)} requests and ${w(Pe)} over the last ${T.label}.`,actions:e(Xe,{children:Ot.map((i)=>e(st,{type:"button",$size:"sm",$on:i.id===A,"aria-pressed":i.id===A,onClick:()=>C(i.id),children:i.id},i.id))})}),e(f,{legend:"Your key",meta:m.data===void 0?void 0:c(d,{$dim:!0,children:[m.data.prefix,"…"]}),children:m.isPending?e(b,{rows:2}):m.isError?e(x,{legend:"Could not read your key",error:m.error}):c(r,{$gap:2,children:[c(o,{$gap:2,$wrap:!0,children:[e(t,{children:m.data.label}),m.data.bodyLoggingOptOut?e(se,{children:"Request bodies are never stored for this key."}):null]}),m.data.modelAllowlist===null?e(se,{children:"Every model this gateway serves."}):m.data.modelAllowlist.length===0?e(se,{children:"No models. This key cannot serve a request."}):e(o,{$gap:1,$wrap:!0,children:m.data.modelAllowlist.map((i)=>e(d,{children:i},i))}),c(se,{children:["Confidential routing: ",m.data.smartRouting?"on":"off"]}),m.data.guardrailPolicy===null?null:c(r,{$gap:1,children:[e(t,{children:"Usage policy"}),e(Ue,{children:m.data.guardrailPolicy}),e(se,{children:"Each request is checked against this before it is served, and the check is billed to this key. Requests outside it are refused."})]})]})}),e(yr,{buckets:ne,since:G,until:Ce,by:T.by,rangeLabel:T.label,dayOffsetMinutes:oe}),e(Se,{legend:"By model",meta:T.label,query:{isLoading:F.isLoading,isError:F.isError,error:F.error,refetch:()=>void F.refetch()},failure:"Could not read usage",empty:{legend:"No traffic",message:"Nothing served in this window."},isEmpty:(F.data??[]).length===0,children:e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Model"}),e(l,{$align:"right",children:"Requests"}),e(l,{$align:"right",children:"Tokens"}),e(l,{$align:"right",children:"Spend"})]})}),e("tbody",{children:(F.data??[]).map((i)=>c(E,{children:[e(s,{$mono:!0,children:i.key}),e(s,{$align:"right",$mono:!0,children:a(i.requests)}),e(s,{$align:"right",$mono:!0,children:a(i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens)}),e(s,{$align:"right",$mono:!0,children:w(i.costUsd)})]},i.key))})]})})}),e(Se,{legend:"Your limits",query:{isLoading:m.isLoading,isError:m.isError,error:m.error,refetch:()=>void m.refetch()},failure:"Could not read your limits",empty:m.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:m.data?.limits===null||(m.data?.limitUsage.length??0)===0,footer:e(se,{children:"Counted from completed requests, so a burst in flight right now may not be included yet."}),children:e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Limit"}),e(l,{$align:"right",children:"Used"}),e(l,{$align:"right",children:"Ceiling"}),e(l,{$width:"30%",children:"Consumption"})]})}),e("tbody",{children:ue.map((i)=>c(he,{children:[ke?e(E,{children:e(l,{scope:"rowgroup",colSpan:4,children:i.model??"Every model"})}):null,i.readings.map((g)=>e(He,{reading:g},`${g.dimension}:${g.window??"gauge"}`))]},i.model??""))})]})})}),e(Se,{legend:"Provider headroom",query:{isLoading:I.isLoading,isError:I.isError,error:I.error,refetch:()=>void I.refetch()},failure:"Could not read provider headroom",empty:{legend:"No data",message:"No provider has reported a usage window."},isEmpty:V.length===0,footer:e(se,{children:"What each account serving this gateway has left. A request is served by whichever account of a provider can take it."}),children:e(r,{$gap:4,children:Me.map(([i,g])=>c(r,{$gap:1,children:[e(t,{children:i}),e(Q,{children:c(q,{children:[e("thead",{children:c("tr",{children:[e(l,{children:"Account"}),e(l,{$width:"60%",children:"Quota"}),e(l,{})]})}),e("tbody",{children:g.map(({credentialId:L,windows:B})=>c(he,{children:[e(Ve,{windows:B,open:z===L,onToggle:()=>Te(z===L?null:L)}),z!==L?null:e(E,{children:e(s,{colSpan:3,children:e(r,{$gap:4,children:B.map((h)=>{let Y=ye(h),H=$t(Y),ae=(ce.data?.samples??[]).filter((_)=>_.credentialId===h.credentialId&&_.windowType===h.windowType&&_.observedAt>=(H??0));return e(wr,{live:Y,samples:ae.map((_)=>({observedAt:_.observedAt,windowType:_.windowType,windowMs:_.windowMs,resetsAt:_.resetsAt,usedRatio:_.usedRatio})),since:H,now:Date.now(),truncated:ce.data?.truncated===!0&&H!==null&&ae.length>0&&(ae[0]?.observedAt??0)>H,ratePerHourRatio:h.ratePerHourRatio,exhaustsAt:h.exhaustsAt,survives:h.survives,stale:h.stale,rolledOver:h.rolledOver,spent:h.usedRatio===null?"no ceiling reported":`${N(h.usedRatio,0)} used`,rateText:h.ratePerHourRatio===null?"unknown":`${N(h.ratePerHourRatio,1)}/h`},h.windowType)})})})})]},L))})]})})]},i))})}),e(Se,{legend:"Recent requests",meta:`${D.length} shown`,actions:c(Xe,{children:[e(pr,{filters:S,onChange:v}),e(Fe,{value:j,"aria-label":"How many requests per page",options:fe.map((i)=>({value:String(i),label:`${i} per page`})),onValueChange:(i)=>ve(Number(i))})]}),query:{isLoading:M.isLoading,isError:M.isError,error:M.error,refetch:()=>void M.refetch()},failure:"Could not read your requests",empty:{legend:"No requests",message:Object.keys(S).length===0?"Nothing served through this key yet.":"No request served through this key matches these filters."},isEmpty:D.length===0,footer:c(o,{$gap:2,$wrap:!0,children:[c(se,{children:[a(xe)," of the ",a(D.length)," loaded failed."]}),M.hasNextPage?e(n,{type:"button",$size:"sm",disabled:M.isFetchingNextPage,onClick:()=>void M.fetchNextPage(),children:M.isFetchingNextPage?"Loading…":"Load older"}):null,be?c(Ye,{children:[e(se,{children:"Live updates are paused while older pages are loaded."}),e(n,{type:"button",$size:"sm",onClick:Re,children:"Back to live"})]}):null]}),children:e(Q,{children:e(hr,{rows:D,now:qe,onOpen:te})})}),e(J,{open:ee!==null,onOpenChange:(i)=>{if(!i)te(null)},title:"Request detail",width:"640px",footer:e(n,{type:"button",onClick:()=>te(null),children:"Close"}),children:ee===null?null:e(gr,{log:ee})})]})}import{jsx as Z}from"react/jsx-runtime";var Bt=()=>Z(Vr,{children:Z(Kr,{children:Z(pe,{children:Z(we,{})})})});export{Bt as component};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var ir=[{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 sr(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var c={requests:"Requests",tokens:"Tokens",spend:"Spend",concurrency:"Concurrent"},f={"1m":"per minute","5h":"per 5 hours","1w":"per week"};function Rt(e){let n=c[e.dimension];return e.window===null?n:`${n} ${f[e.window]}`}function zn(e){let n=Rt({dimension:e.dimension,window:e.window});return e.model===null?n:`${n} for ${e.model}`}function lr(e){let n=[];for(let i of e){let t=n.find((o)=>o.model===i.model);if(t===void 0)n.push({model:i.model,readings:[i]});else t.readings.push(i)}return n}function ur(e,n){if(e==="spend")return`$${n<1?n.toFixed(4):n.toFixed(2)}`;return n.toLocaleString("en-US")}function cr(e){if(e.used===null||e.limit<=0)return null;return Math.max(0,e.used/e.limit)}function Wn(e){let n=null,i=-1;for(let t of e){let o=cr(t);if(o===null)continue;if(o>i)n=t,i=o}return n}function Pt(e){let n={};for(let i of ir)n[sr(i)]="";if(e===null)return n;for(let i of ir){let t=i.window===null?e.concurrency:i.dimension==="requests"?e.requests?.[i.window]:i.dimension==="tokens"?e.tokens?.[i.window]:i.window==="1m"?void 0:e.spend?.[i.window];if(t!==void 0&&t!==null)n[sr(i)]=String(t)}return n}function dr(e){let n={},i={},t={},o;for(let r of ir){let m=(e[sr(r)]??"").trim();if(m.length===0)continue;let s=Number(m),l=r.dimension==="spend";if(!Number.isFinite(s)||s<=0||!l&&!Number.isInteger(s))return{problem:l?`${Rt(r)} must be an amount above zero, or blank for no limit.`:`${Rt(r)} must be a whole number above zero, or blank for no limit.`};if(r.window===null)o=s;else if(r.dimension==="requests")n[r.window]=s;else if(r.dimension==="tokens")i[r.window]=s;else if(r.window!=="1m")t[r.window]=s}return{limits:{...Object.keys(n).length>0?{requests:n}:{},...Object.keys(i).length>0?{tokens:i}:{},...Object.keys(t).length>0?{spend:t}:{},...o===void 0?{}:{concurrency:o}}}}var u=64,a=256;function Hn(e){if(e===null)return[];return Object.entries(e.models??{}).map(([n,i],t)=>({id:`stored-${t}`,model:n,stored:n,slots:Pt(i)}))}function Vn(e){if(e.length>u)return{problem:`A key can override at most ${u} models.`};let n=[],i=new Set;for(let t of e){let o=t.model;if(o.trim().length===0)return{problem:"Each per-model override needs a model."};if(o!==o.trim()&&o!==t.stored)return{problem:`"${o}" has spaces around it, and model names are matched exactly. Remove them.`};if(o.length>a)return{problem:`A model name is at most ${a} characters.`};if(o==="__proto__")return{problem:'"__proto__" cannot be a model name.'};if(i.has(o))return{problem:`${o} is overridden twice; keep one row.`};i.add(o);let d=dr(t.slots);if("problem"in d)return{problem:`${o}: ${d.problem}`};if(Object.keys(d.limits).length===0)return{problem:`The override for ${o} sets no limit. Set one, or remove the override.`};n.push([o,d.limits])}return{models:Object.fromEntries(n)}}
|
|
2
|
+
export{ir,sr,Rt,zn,lr,ur,cr,Wn,Pt,dr,Hn,Vn};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{t}from"/assets/index-p9vbm21a.js";import{useId as s}from"react";import i from"styled-components";import{jsx as d,jsxs as b}from"react/jsx-runtime";var l=`
|
|
2
|
+
width: 100%;
|
|
3
|
+
border-radius: 3px;
|
|
4
|
+
transition: border-color 120ms ease;
|
|
5
|
+
`,v=i.input.withConfig({displayName:"Field__Input"})([""," height:30px;padding:0 8px;background:",";border:1px solid ",";color:",";font-family:",";font-size:12px;&::placeholder{color:",";font-family:",";}&:hover:not(:disabled){border-color:",";}&:disabled{opacity:0.5;}"],l,({theme:o})=>o.color.panelSunk,({theme:o})=>o.color.ruleStrong,({theme:o})=>o.color.ink,({theme:o})=>o.font.mono,({theme:o})=>o.color.inkFaint,({theme:o})=>o.font.sans,({theme:o})=>o.color.accent),Tr=i.textarea.withConfig({displayName:"Field__Textarea"})([""," min-height:120px;padding:6px 8px;resize:vertical;background:",";border:1px solid ",";color:",";font-family:",";font-size:12px;line-height:1.5;&:hover:not(:disabled){border-color:",";}&:disabled{opacity:0.5;}"],l,({theme:o})=>o.color.panelSunk,({theme:o})=>o.color.ruleStrong,({theme:o})=>o.color.ink,({theme:o})=>o.font.sans,({theme:o})=>o.color.accent),c=i.div.withConfig({displayName:"Field__Wrap"})(["display:flex;flex-direction:column;gap:4px;min-width:0;"]),f=i.p.withConfig({displayName:"Field__Hint"})(["font-size:11px;color:",";"],({theme:o})=>o.color.inkDim),g=i.p.withConfig({displayName:"Field__Problem"})(["font-size:11px;color:",";"],({theme:o})=>o.color.down);function m({label:o,hint:n,problem:r,children:a}){let e=s(),p=r!==void 0?`${e}-problem`:n!==void 0?`${e}-hint`:void 0;return b(c,{children:[d(t,{as:"label",htmlFor:e,children:o}),a({id:e,"aria-describedby":p}),r!==void 0?d(g,{id:`${e}-problem`,children:r}):n!==void 0?d(f,{id:`${e}-hint`,children:n}):null]})}var de=i(v).attrs({type:"number",inputMode:"decimal"}).withConfig({displayName:"Field__NumberInput"})(["text-align:right;padding-right:6px;"]);
|
|
6
|
+
export{v,Tr,m,de};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{De,Tt,Be,Pe,Ze,Ae,Te,Mt,He,Ve}from"/assets/index-z7c4qz9d.js";import{t,d,o,r,nt,En,xo,Ce,Nt,Mn,it,Bn,Fn,$n,Un}from"/assets/index-p9vbm21a.js";import*as C from"react";import{forwardRef as E}from"react";var Q=["axis"],R=E((e,n)=>C.createElement(Mt,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Q,tooltipPayloadSearcher:Tt,categoricalChartProps:e,ref:n}));import b from"styled-components";import{jsx as a,jsxs as s,Fragment as H}from"react/jsx-runtime";var _=b(o).withConfig({displayName:"WindowChart__Facts"})(["gap:",";flex-wrap:wrap;"],({theme:e})=>e.space(5)),k=b.div.withConfig({displayName:"WindowChart__Fact"})(["display:flex;flex-direction:column;gap:2px;"]),c=b.span.withConfig({displayName:"WindowChart__Absent"})(["font-size:11.5px;color:",";"],({theme:e})=>e.color.inkDim),P={budget:"1 4",projection:"6 4"},T="projected";function O(e){let n=new Map;for(let{key:l,points:u}of e)for(let m of u){let y=n.get(m.at)??{at:m.at};y[l]=m.percent,n.set(m.at,y)}return[...n.values()].sort((l,u)=>l.at-u.at)}function j(e,n,l){return[Math.min(e,...l.map((u)=>u.pace.from.at)),Math.max(n,...l.map((u)=>u.pace.to.at))]}function $t(e){if(e.resetsAt===null)return null;let n=e.resetsAt-Nt(e.windowType,e.windowMs);return n-(e.resetsAt-n)}function K(e,n){if(n===null)return"unknown";if(e!==null&&n.to.at<e)return"100% of limit before it resets";return`${Math.round(n.to.percent)}% of limit by reset`}function B(e,n){let l=Mn({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});if(l==="ok")return"lasts the window";if(l!=="empty"||e.exhaustsAt===null)return"unknown";if(e.exhaustsAt<=n)return"empty now";return`empty ~${nt(e.exhaustsAt-n)} before it resets`}function wr(e){let{live:n,samples:l,since:u,now:m,stale:y,rolledOver:F,spent:A,truncated:L=!1}=e,x=it[n.windowType];if(y)return s(r,{$gap:2,children:[s(o,{$gap:2,$wrap:!0,children:[s(t,{children:[x," window"]}),a(c,{children:A})]}),a(c,{children:"reading is stale"})]});let g=Fn(Bn(l),n),w=g.flatMap((i)=>{let h=$n(i);return h===null?[]:[{key:`${i.key}-budget`,pace:h}]}),p=Un(n,e.ratePerHourRatio),S=O([...g,...w.map((i)=>({key:i.key,points:[i.pace.from,i.pace.to]})),...p===null?[]:[{key:T,points:[p.from,p.to]}]]),W=new Set(g.map((i)=>i.key)),M=100,f=u===null||n.resetsAt===null?null:j(u,n.resetsAt,w);return s(r,{$gap:2,children:[s(o,{$gap:2,$wrap:!0,children:[s(t,{children:[x," window"]}),a(c,{children:A}),F?a(c,{children:"· rolled over, waiting for the next reading"}):null]}),s(_,{children:[s(k,{children:[a(t,{children:"Window average"}),a(d,{children:e.rateText})]}),s(k,{children:[a(t,{children:"Estimate"}),a(d,{children:B(e,m)})]}),s(k,{children:[a(t,{children:"Projected"}),a(d,{children:K(n.resetsAt,p)})]}),e.extraFact]}),n.usedRatio===null?a(c,{children:"no ceiling reported"}):f===null?a(c,{children:"no reset reported"}):g.length===0?a(c,{children:"not yet observed"}):s(H,{children:[a(t,{children:["Used, this window and the one before",...L?["earliest readings not shown"]:[],...w.length===0?[]:["budget dotted"],...p===null?[]:["projection dashed"]].join(" · ")}),a(He,{$height:160,children:a(De,{width:"100%",height:"100%",children:s(R,{data:S,margin:{top:4,right:8,bottom:4,left:4},children:[a(Pe,{stroke:"var(--rule)",vertical:!1}),a(Ae,{dataKey:"at",type:"number",scale:"time",domain:f,tickFormatter:(i)=>En(i,f[1]-f[0]),tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",minTickGap:xo(f[1]-f[0])?80:40}),a(Te,{domain:[0,M],allowDataOverflow:!0,tickFormatter:(i)=>`${Math.round(i)}%`,tick:{fill:"var(--ink-faint)",fontSize:10},stroke:"var(--rule-strong)",width:40}),a(Be,{cursor:{stroke:"var(--rule-strong)"},content:({active:i,payload:h})=>{if(i!==!0||h===void 0||h.length===0)return null;let v=h.find((D)=>W.has(String(D.dataKey)));if(v===void 0||typeof v.value!=="number")return null;let N=v.payload.at;return s(Ve,{children:[a("div",{children:Ce(N)}),s("div",{children:[v.value.toFixed(1),"% used"]})]})}}),g.map((i)=>a(Ze,{type:"monotone",dataKey:i.key,stroke:"var(--accent)",strokeWidth:2,dot:i.points.length===1?{r:2.5,fill:"var(--accent)",stroke:"var(--accent)"}:!1,connectNulls:!0,isAnimationActive:!1},i.key)),w.map((i)=>a(Ze,{type:"linear",dataKey:i.key,stroke:"var(--ink-faint)",strokeWidth:1.5,strokeDasharray:P.budget,dot:!1,connectNulls:!0,isAnimationActive:!1},i.key)),p===null?null:a(Ze,{type:"linear",dataKey:T,stroke:"var(--ink-dim)",strokeWidth:1.5,strokeDasharray:P.projection,dot:!1,connectNulls:!0,isAnimationActive:!1})]})})})]})]})}function Kn({legend:e,value:n}){return s(k,{children:[a(t,{children:e}),a(d,{children:n})]})}
|
|
2
|
+
export{$t,wr,Kn};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t}from"/assets/index-p9vbm21a.js";import n from"styled-components";import{jsx as e,jsxs as l}from"react/jsx-runtime";var s=n.div.withConfig({displayName:"Readout__Frame"})(["display:flex;flex-direction:column;gap:6px;padding:",";background:",";border:1px solid ",";border-radius:",";min-width:0;"],({theme:o})=>`${o.space(2)} ${o.space(3)}`,({theme:o})=>o.color.panel,({theme:o})=>o.color.rule,({theme:o})=>o.radius.panel),c=n.div.withConfig({displayName:"Readout__Value"})(["display:flex;align-items:baseline;flex-wrap:wrap;gap:4px;font-family:",";font-variant-numeric:tabular-nums;font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:1.1;color:",";"],({theme:o})=>o.font.mono,({theme:o,$tone:a})=>a==="ok"?o.color.ok:a==="warn"?o.color.warn:a==="down"?o.color.down:o.color.ink),u=n.span.withConfig({displayName:"Readout__Unit"})(["font-size:11px;font-weight:400;color:",";"],({theme:o})=>o.color.inkFaint),f=n.div.withConfig({displayName:"Readout__Trace"})(["margin-top:2px;"]);function D({legend:o,value:a,unit:i,tone:r,trace:d,className:p}){return l(s,{className:p,children:[e(t,{children:o}),l(c,{...r===void 0?{}:{$tone:r},children:[e("span",{children:a}),i===void 0?null:e(u,{children:i})]}),d===void 0?null:e(f,{children:d})]})}
|
|
2
|
+
export{D};
|