omnigateway 0.15.4 → 0.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +12 -1
  2. package/bin/omni.js +193 -187
  3. package/gateway.js +324 -318
  4. package/package.json +1 -1
  5. package/public/assets/{_app-kgxk7ake.js → _app-hj6zm190.js} +1 -1
  6. package/public/assets/{_app.accounts-3jabfvcs.js → _app.accounts-p4cfzwak.js} +1 -1
  7. package/public/assets/{_app.console-y69399jc.js → _app.console-9b5jsgb2.js} +1 -1
  8. package/public/assets/{_app.database-r5kg3838.js → _app.database-gxm9r50d.js} +1 -1
  9. package/public/assets/{_app.index-22awhb38.js → _app.index-z62y96gv.js} +1 -1
  10. package/public/assets/{_app.keys-7vh81n1w.js → _app.keys-9hcrg2sv.js} +1 -1
  11. package/public/assets/{_app.logs-rssv5a6z.js → _app.logs-wszj7dxd.js} +1 -1
  12. package/public/assets/_app.models-msggftd4.js +1 -0
  13. package/public/assets/{_app.plugins.$pluginId-e4xva5tz.js → _app.plugins.$pluginId-c18d9z9g.js} +1 -1
  14. package/public/assets/{_app.settings-fqzg7wnn.js → _app.settings-1kbbc55c.js} +1 -1
  15. package/public/assets/{_app.usage-32vje0s7.js → _app.usage-j1q7t12v.js} +1 -1
  16. package/public/assets/{client-d3mjj5ey.js → client-85yjh3yc.js} +1 -1
  17. package/public/assets/{index-v31xha7b.js → index-0egbh3rb.js} +1 -1
  18. package/public/assets/{index-f7t0kve8.js → index-330vgx7r.js} +1 -1
  19. package/public/assets/{index-dq2f7yk0.js → index-3a10vc18.js} +1 -1
  20. package/public/assets/{index-nnpqs2w6.js → index-3habqvw2.js} +1 -1
  21. package/public/assets/{index-938qd7p2.js → index-40vm2qxc.js} +1 -1
  22. package/public/assets/{index-sbe0ydnc.js → index-6v3e0r4x.js} +1 -1
  23. package/public/assets/{index-z7c4qz9d.js → index-96zs0ekh.js} +1 -1
  24. package/public/assets/{index-zkt5p0qd.js → index-9pefp4zb.js} +1 -1
  25. package/public/assets/{index-85cnhw3e.js → index-9vqvqrvt.js} +1 -1
  26. package/public/assets/{index-hk28xepa.js → index-dny52xdk.js} +1 -1
  27. package/public/assets/{index-fcew0gga.js → index-e7nx5832.js} +1 -1
  28. package/public/assets/{index-8bewp9z1.js → index-h41dkv54.js} +1 -1
  29. package/public/assets/{index-p9vbm21a.js → index-qkhn11a8.js} +3 -3
  30. package/public/assets/{index-0j7sghrn.js → index-qtdmekxc.js} +1 -1
  31. package/public/assets/{index-d09hs7ex.js → index-ywek2f98.js} +1 -1
  32. package/public/assets/{index-xdyjb1an.js → index-zqfj5xfa.js} +1 -1
  33. package/public/assets/{login-p97b96t9.js → login-55p1x35d.js} +1 -1
  34. package/public/index.html +1 -1
  35. package/public/shared/dashboard-sdk.js +1 -1
  36. package/public/assets/_app.models-82m2f0kr.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnigateway",
3
- "version": "0.15.4",
3
+ "version": "0.15.5",
4
4
  "description": "Self-hosted AI gateway with Anthropic- and OpenAI-compatible APIs, an admin console, and a CLI",
5
5
  "license": "MIT",
6
6
  "author": "Harismawan <mail@harismawan.com>",
@@ -1 +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};
1
+ import{j,x,f}from"/assets/index-qkhn11a8.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};
@@ -1 +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};
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-qkhn11a8.js";import{$e,R}from"/assets/index-330vgx7r.js";import{W}from"/assets/index-3a10vc18.js";import{C}from"/assets/index-e7nx5832.js";import{v,m,de}from"/assets/index-h41dkv54.js";import{re}from"/assets/index-wjqdtafp.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{xr}from"/assets/index-0egbh3rb.js";import"/assets/index-96zs0ekh.js";import{$t,wr,Kn}from"/assets/index-40vm2qxc.js";import{br}from"/assets/index-9vqvqrvt.js";import{Qe}from"/assets/index-qtdmekxc.js";import{Le}from"/assets/index-9pefp4zb.js";import{xt}from"/assets/index-3habqvw2.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};
@@ -1 +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};
1
+ import{se,o,yo,Uo,qo,a,X,I,x,b,k,Ft,Lt,qn,jn,pt,mt}from"/assets/index-qkhn11a8.js";import{R}from"/assets/index-330vgx7r.js";import"/assets/index-h41dkv54.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};
@@ -1 +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};
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-qkhn11a8.js";import{re}from"/assets/index-wjqdtafp.js";import{D}from"/assets/index-ywek2f98.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{m,de}from"/assets/index-h41dkv54.js";import{Ar}from"/assets/index-d0t1fj1y.js";import{xt}from"/assets/index-3habqvw2.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};
@@ -1 +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};
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-qkhn11a8.js";import{C,vt}from"/assets/index-e7nx5832.js";import{re}from"/assets/index-wjqdtafp.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{vr,At}from"/assets/index-zqfj5xfa.js";import{D}from"/assets/index-ywek2f98.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};
@@ -1 +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};
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-qkhn11a8.js";import{$e,tt}from"/assets/index-330vgx7r.js";import{W}from"/assets/index-3a10vc18.js";import{C}from"/assets/index-e7nx5832.js";import{q,l,s,E}from"/assets/index-t1cs42r4.js";import{v,Tr,m,de}from"/assets/index-h41dkv54.js";import{re}from"/assets/index-wjqdtafp.js";import{xr}from"/assets/index-0egbh3rb.js";import{ir,sr,Rt,zn,lr,ur,cr,Wn,Pt,dr,Hn,Vn}from"/assets/index-4dz4bgrb.js";import{Qe}from"/assets/index-qtdmekxc.js";import{Le}from"/assets/index-9pefp4zb.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};
@@ -1 +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};
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-qkhn11a8.js";import{R}from"/assets/index-330vgx7r.js";import"/assets/index-h41dkv54.js";import{C}from"/assets/index-e7nx5832.js";import{fr,pr,mr,hr,gr}from"/assets/index-6v3e0r4x.js";import"/assets/index-t1cs42r4.js";import"/assets/index-zqfj5xfa.js";import"/assets/index-9pefp4zb.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-qkhn11a8.js";import{R,tt}from"/assets/index-330vgx7r.js";import{W}from"/assets/index-3a10vc18.js";import{C,vt}from"/assets/index-e7nx5832.js";import{re}from"/assets/index-wjqdtafp.js";import{v,m,de}from"/assets/index-h41dkv54.js";import{br}from"/assets/index-9vqvqrvt.js";import{Qe}from"/assets/index-qtdmekxc.js";import{xt}from"/assets/index-3habqvw2.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(),p=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)=>p===void 0?0:Math.abs(Se(j.reasons,y,p))))]));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)})]}),p===void 0?null:E(ot,{children:Pe.map((L)=>{let D=Se(y.reasons,L,p),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==null)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:l.contextWindow===void 0?"":String(l.contextWindow),maxOutputTokens:l.maxOutputTokens===void 0?"":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 p=Number(s.tier);if(!Number.isInteger(p)||p<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 u=s.contextWindow.trim().length>0,T=Number(s.contextWindow);if(u&&(!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:p,weight:Q,costPerMTok:{input:G,output:y,...j?{cacheRead:L}:{},...D?{cacheWrite5m:U}:{},...Z?{cacheWrite1h:Y}:{}},...u?{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)),ut=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;"]),pt=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 p=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=(u,T)=>{c({...e,[u]:T})},U=se(w,e.provider,e.model),Z=_e(w,e.provider,e.model),Y=(u)=>{c(ze(w,e,u))};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,{})})]}),_(ut,{children:[_(K,{children:[g(t,{as:"label",htmlFor:`${p}-provider`,children:"Provider"}),g(R,{id:`${p}-provider`,value:e.provider,options:[...w.map((u)=>({value:u.id,label:u.label})),...Q===void 0?[{value:e.provider,label:`${e.provider} (not in the catalog)`}]:[]],onValueChange:(u)=>{let T=u,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:`${p}-endpoint`,children:"Endpoint"}),g(R,{id:`${p}-endpoint`,value:e.endpointId,options:[{value:"",label:"Choose endpoint"},...q.map((u)=>({value:u.id,label:u.label}))],onValueChange:(u)=>c(Be(e,u))})]}):null,_(K,{children:[g(t,{as:"label",htmlFor:`${p}-model`,children:"Provider model"}),g(tt,{id:`${p}-model`,value:e.model,placeholder:Q?.defaultModel??"",suggestions:G.map((u)=>({value:u.id,label:u.id,detail:u.label===u.id?void 0:u.label})),onValueChange:(u)=>Y({provider:e.provider,model:u})}),y===null?null:g(Ve,{role:"note",children:y})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${p}-tier`,children:"Tier"}),g(de,{id:`${p}-tier`,min:1,step:1,value:e.tier,onChange:(u)=>D("tier",u.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${p}-weight`,children:"Weight"}),g(de,{id:`${p}-weight`,min:0,step:0.1,value:e.weight,onChange:(u)=>D("weight",u.target.value)})]})]}),g(r,{$gap:1,children:_(K,{children:[g(t,{as:"label",htmlFor:`${p}-account`,children:"Account"}),g(R,{id:`${p}-account`,value:e.credentialId,options:[{value:"",label:"Any account"},...j.map((u)=>({value:u.id,label:u.label})),...L===null?[]:[{value:e.credentialId,label:`${e.credentialId} (removed)`}]],onValueChange:(u)=>D("credentialId",u)}),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:"Price unavailable — enter your own rates"}):_(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:`${p}-in`,children:"Input"}),g(de,{id:`${p}-in`,min:0,step:0.01,value:e.costInput,onChange:(u)=>D("costInput",u.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${p}-out`,children:"Output"}),g(de,{id:`${p}-out`,min:0,step:0.01,value:e.costOutput,onChange:(u)=>D("costOutput",u.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${p}-cache`,children:"Cache read"}),g(de,{id:`${p}-cache`,min:0,step:0.01,placeholder:"same as input",value:e.costCacheRead,onChange:(u)=>D("costCacheRead",u.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${p}-write5m`,children:"Cache write 5m"}),g(de,{id:`${p}-write5m`,min:0,step:0.01,placeholder:"1.25x input",value:e.costCacheWrite5m,onChange:(u)=>D("costCacheWrite5m",u.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${p}-write1h`,children:"Cache write 1h"}),g(de,{id:`${p}-write1h`,min:0,step:0.01,placeholder:"2x input",value:e.costCacheWrite1h,onChange:(u)=>D("costCacheWrite1h",u.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:`${p}-context`,children:"Context window"}),g(de,{id:`${p}-context`,min:1,step:1024,placeholder:Z?.contextWindow??"published",value:e.contextWindow,onChange:(u)=>D("contextWindow",u.target.value)})]}),_(K,{children:[g(t,{as:"label",htmlFor:`${p}-maxout`,children:"Max output"}),g(de,{id:`${p}-maxout`,min:1,step:1024,placeholder:Z?.maxOutputTokens??"published",value:e.maxOutputTokens,onChange:(u)=>D("maxOutputTokens",u.target.value)})]})]})]}),_(r,{$gap:1,children:[g(t,{children:"Capabilities"}),_(pt,{children:[_(we,{children:[g(W,{checked:e.tools,label:`Target ${a+1} supports tools`,onCheckedChange:(u)=>D("tools",u)}),"Tools"]}),_(we,{children:[g(W,{checked:e.images,label:`Target ${a+1} supports images`,onCheckedChange:(u)=>D("images",u)}),"Images"]}),_(we,{children:[g(W,{checked:e.reasoning,label:`Target ${a+1} supports reasoning`,onCheckedChange:(u)=>D("reasoning",u)}),"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,p]=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),p(!1)},[Z]);let Y=ye.find((T)=>T.id===s.strategy),u=()=>{p(!1);let T=qe(s);if(!T.ok){N(T.problem);return}N(null),y.mutate(T.model,{onSuccess:()=>{p(!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:u,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((p)=>p.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((p)=>A(Pt,{$provider:p,title:p},p))}),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};
@@ -1 +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};
1
+ import{r,A,Y,ke,ct,Or,I,x,b,k,f,Xr}from"/assets/index-qkhn11a8.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};