omnigateway 0.11.3 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/bin/omni.js +2325 -810
- package/gateway.js +2701 -1340
- package/package.json +2 -4
- package/public/assets/{Chip-iJNHhgJ6.js → Chip-D4qvhu1D.js} +1 -1
- package/public/assets/CopyValue-SnsT2LML.js +27 -0
- package/public/assets/Lamp-DkvXKB-B.js +26 -0
- package/public/assets/Rack-CEuCdVXc.js +483 -0
- package/public/assets/RequestTable-CSQGt9W_.js +93 -0
- package/public/assets/{SummaryDeck-BUMth482.js → SummaryDeck-7ivuca39.js} +1 -1
- package/public/assets/Toggle-t82IhqEt.js +39 -0
- package/public/assets/TokenBreakdown-D1Wtza1y.js +32 -0
- package/public/assets/{WindowChart-UHzWV_Tx.js → WindowChart-BeGPsccS.js} +1 -1
- package/public/assets/_app.accounts-W1USUo2Q.js +70 -0
- package/public/assets/{_app.console-C9P3N79h.js → _app.console-BvIGqIe7.js} +2 -2
- package/public/assets/_app.database-CtFJLcfE.js +24 -0
- package/public/assets/_app.index-DigYfob3.js +67 -0
- package/public/assets/_app.keys-B1fRMyU-.js +92 -0
- package/public/assets/_app.logs-D73Qcx9S.js +60 -0
- package/public/assets/_app.models-Dpl1O2RE.js +148 -0
- package/public/assets/{_app.plugins._pluginId-BaZPH3Oh.js → _app.plugins._pluginId-BNrRTn9l.js} +1 -1
- package/public/assets/{_app.settings-neenlxM-.js → _app.settings-tRLrVJoq.js} +4 -4
- package/public/assets/_app.usage-D2qlcEp4.js +76 -0
- package/public/assets/chevron-down-Bs0tSOyA.js +1 -0
- package/public/assets/chevron-right-DSaI1kFo.js +1 -0
- package/public/assets/client-BZ_ev12J.js +39 -0
- package/public/assets/dist-D03q-60i.js +1 -0
- package/public/assets/index-89mqAVmK.js +14 -0
- package/public/assets/{login-COCaKiJ3.js → login-75MYwRdC.js} +2 -2
- package/public/assets/plus-BCfjC6nk.js +1 -0
- package/public/assets/preload-helper-BPaHpbO_.js +1 -0
- package/public/assets/{shared-CNTPQfFU.js → shared-Dtkw6SE0.js} +1 -1
- package/public/assets/trash-D4QWzEK_.js +1 -0
- package/public/index.html +4 -4
- package/public/shared/chunks/react-DK6rpPfu.js +1 -0
- package/public/shared/chunks/react-dom-Wr82bmbV.js +1 -0
- package/public/shared/dashboard-sdk.js +1 -1
- package/public/shared/react-dom-client.js +5 -5
- package/public/shared/react-dom.js +1 -1
- package/public/shared/react-query.js +1 -1
- package/public/shared/react.js +1 -1
- package/public/shared/styled-components.js +1 -1
- package/public/assets/CopyValue-kMuDjb96.js +0 -27
- package/public/assets/Lamp-lkkWBrFM.js +0 -26
- package/public/assets/Rack-B4L2xB7-.js +0 -483
- package/public/assets/RequestTable-DSmx72OY.js +0 -11
- package/public/assets/Toggle-DAjywMl5.js +0 -39
- package/public/assets/TokenBreakdown-DQuX2IKR.js +0 -33
- package/public/assets/_app.accounts-Dd35v-5U.js +0 -59
- package/public/assets/_app.database-DV09HTfL.js +0 -24
- package/public/assets/_app.index-CJm4vBIM.js +0 -67
- package/public/assets/_app.keys-BJYRaiSr.js +0 -92
- package/public/assets/_app.logs-CwfEU7mb.js +0 -58
- package/public/assets/_app.models-BicZeVmX.js +0 -148
- package/public/assets/_app.usage-CXj0B5qT.js +0 -76
- package/public/assets/chevron-right-f-3aPVhf.js +0 -1
- package/public/assets/client-BAOwDPZ1.js +0 -39
- package/public/assets/index-B8HiPc8p.js +0 -13
- package/public/assets/plus-DLJ5ZcBJ.js +0 -1
- package/public/assets/preload-helper-KDDEULHo.js +0 -1
- package/public/assets/trash-2-C937U0RF.js +0 -1
- package/public/shared/chunks/react-GitiQ0dt.js +0 -1
- package/public/shared/chunks/react-dom-BFxyned6.js +0 -1
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./Lamp-lkkWBrFM.js";import{b as t,y as n}from"./Rack-B4L2xB7-.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";import a,{keyframes as o}from"styled-components";var s=t(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),c=t(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),l=new Intl.NumberFormat(`en-US`);function u(e){return`${l.format(e.inputTokens)} input, ${l.format(e.outputTokens)} output, ${l.format(e.cacheReadTokens)} cache read, ${l.format(e.cacheWriteTokens)} cache write tokens`}var d=a.span`
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
flex-wrap: wrap;
|
|
5
|
-
gap: 6px;
|
|
6
|
-
/* Wrapping happens between the four classes, never inside one: a count
|
|
7
|
-
broken across lines from its own arrow reads as a different number. */
|
|
8
|
-
white-space: nowrap;
|
|
9
|
-
`,f=a.span`
|
|
10
|
-
display: inline-flex;
|
|
11
|
-
align-items: center;
|
|
12
|
-
line-height: 1;
|
|
13
|
-
gap: 2px;
|
|
14
|
-
|
|
15
|
-
svg {
|
|
16
|
-
width: 12px;
|
|
17
|
-
height: 12px;
|
|
18
|
-
stroke-width: 1.75;
|
|
19
|
-
transform: translateY(-1px);
|
|
20
|
-
}
|
|
21
|
-
`,p=o`
|
|
22
|
-
from { clip-path: inset(0 2ch 0 0); }
|
|
23
|
-
to { clip-path: inset(0 0 0 0); }
|
|
24
|
-
`,m=a.span`
|
|
25
|
-
display: inline-block;
|
|
26
|
-
width: 3ch;
|
|
27
|
-
vertical-align: bottom;
|
|
28
|
-
animation: ${p} 1.5s steps(2, end) infinite;
|
|
29
|
-
|
|
30
|
-
@media (prefers-reduced-motion: reduce) {
|
|
31
|
-
animation: none;
|
|
32
|
-
}
|
|
33
|
-
`;function h(){return i(`span`,{"aria-hidden":`true`,children:[`processing`,r(m,{children:`...`})]})}function g({tokens:t}){let a=u(t);return i(d,{role:`img`,"aria-label":a,title:a,children:[i(f,{"aria-hidden":`true`,children:[r(s,{}),e(t.inputTokens)]}),i(f,{"aria-hidden":`true`,children:[r(c,{}),e(t.outputTokens)]}),i(f,{"aria-hidden":`true`,children:[r(n,{}),r(s,{}),e(t.cacheReadTokens)]}),i(f,{"aria-hidden":`true`,children:[r(n,{}),r(c,{}),e(t.cacheWriteTokens)]})]})}export{g as n,u as r,h as t};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import{F as e,I as t,Kt as n,Ot as r,T as i,Tt as a,U as o,Vt as s,W as c,at as l,b as u,c as d,ct as f,d as p,dt as ee,ft as m,h as te,ht as h,j as g,kt as _,n as v,o as y,ot as b,s as x,t as S,v as C,y as w}from"./Lamp-lkkWBrFM.js";import{C as T,D as E,O as D,_ as O,a as k,b as A,i as j,o as M,r as ne,t as N,v as P,x as re}from"./Panel-CWmOTDAP.js";import{_ as F,b as I,i as ie,m as L,r as R,t as z}from"./Rack-B4L2xB7-.js";import{t as B}from"./CopyValue-kMuDjb96.js";import{n as V,t as H}from"./chevron-right-f-3aPVhf.js";import{t as ae}from"./plus-DLJ5ZcBJ.js";import{t as oe}from"./trash-2-C937U0RF.js";import{t as se}from"./Toggle-DAjywMl5.js";import{t as ce}from"./Chip-iJNHhgJ6.js";import{i as U,n as W,r as le,t as G}from"./Field-BYBri2NV.js";import{t as ue}from"./Meter-stpt3vQu.js";import{i as de,n as K,r as q,t as fe}from"./Table-CVDZ69Zx.js";import{n as pe,r as me,t as he}from"./WindowChart-UHzWV_Tx.js";import{Fragment as ge,useCallback as J,useEffect as _e,useState as Y}from"react";import{Fragment as X,jsx as Z,jsxs as Q}from"react/jsx-runtime";import $ from"styled-components";var ve=I(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]);function ye(e){return e?.authTypes??[]}function be(e){return ye(e).includes(`oauth`)?`oauth`:`apiKey`}function xe(e){return e[0]?.id??`anthropic`}var Se={oauth:`Authorize in the browser`,apiKey:`Paste an API key`};function Ce(e){let t=e?.callback;return t===void 0?`code#state`:`${t.uri}?code=…`}var we=$.ol`
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
5
|
-
`,Te=$.div`
|
|
6
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
7
|
-
font-size: 26px;
|
|
8
|
-
letter-spacing: 0.22em;
|
|
9
|
-
text-align: center;
|
|
10
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
11
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
12
|
-
border: 1px solid ${({theme:e})=>e.color.ruleStrong};
|
|
13
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
14
|
-
`,Ee=$.p`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.down};
|
|
17
|
-
`,De=$.p`
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
20
|
-
`;function Oe({open:e,credentials:t,onOpenChange:n,onConnected:i}){let a=r().data??[],[s,u]=Y(()=>xe(a)),d=o(a,s),[p,ee]=Y(()=>be(o(a,xe(a)))),[m,te]=Y(``),h=d?.label??s,[g,_]=Y(null),[v,y]=Y(``),[x,S]=Y(``),C=(t??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[w,D]=Y(``),[k,j]=Y(``),[ne,N]=Y(`chat_completions`),[P,re]=Y(``),[F,I]=Y(null),L=b(),R=l(),z=f(),V=J(()=>{_(null),y(``),S(``),D(``),j(``),N(`chat_completions`),re(``),I(null),te(``),L.reset(),R.reset(),z.reset()},[L,R,z]),H=J(e=>{e||V(),n(e)},[n,V]);return _e(()=>{if(g===null||g.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await c(g.flowId);if(e)return;if(t.status===`complete`){V(),n(!1),i();return}}catch(t){if(e)return;I(M(t)),_(null);return}e||(r=setTimeout(()=>void t(),g.pollIntervalMs))},r=setTimeout(()=>void t(),g.pollIntervalMs);return()=>{e=!0,clearTimeout(r)}},[g,i,n,V]),Z(ie,{open:e,onOpenChange:H,title:`Connect an account`,description:`The gateway stores the resulting token encrypted. It is never shown again after this dialog.`,footer:g===null?Q(X,{children:[Z(E,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),Z(E,{type:`button`,$variant:`primary`,disabled:L.isPending||z.isPending,onClick:()=>{if(I(null),p===`apiKey`){z.mutate({provider:s,apiKey:P,label:m.trim()||void 0,...s===`custom`?{endpointId:x,endpointLabel:w,origin:k,protocol:ne}:{}},{onSuccess:()=>{V(),n(!1),i()},onError:e=>I(M(e))});return}L.mutate({provider:s,label:m.trim().length===0?h:m.trim()},{onSuccess:e=>_(e),onError:e=>I(M(e))})},children:p===`apiKey`?z.isPending?`Adding…`:`Add API key`:L.isPending?`Starting…`:`Start authorization`})]}):g.kind===`device`?Z(E,{type:`button`,onClick:()=>H(!1),children:`Cancel`}):Q(X,{children:[Z(E,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),Z(E,{type:`button`,$variant:`primary`,disabled:R.isPending||v.trim().length===0,onClick:()=>{g!==null&&(I(null),R.mutate({flowId:g.flowId,code:v.trim()},{onSuccess:()=>{V(),n(!1),i()},onError:e=>I(M(e))}))},children:R.isPending?`Finishing…`:`Finish connecting`})]}),children:Q(we,{children:[g===null?Q(T,{$gap:3,children:[Z(G,{label:`Provider`,children:e=>Z(U,{...e,value:s,onChange:e=>{let t=e.target.value;u(t),ee(be(o(a,t)))},children:a.map(e=>Z(`option`,{value:e.id,children:e.label},e.id))})}),ye(d).length>1?Z(G,{label:`How to connect`,children:e=>Z(U,{...e,value:p,onChange:e=>ee(e.target.value),children:ye(d).map(e=>Z(`option`,{value:e,children:Se[e]},e))})}):null,s===`custom`?Q(X,{children:[C.length===0?null:Z(G,{label:`Existing endpoint`,children:e=>Q(U,{...e,value:x,onChange:e=>{let t=C.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){S(``),D(``),j(``),N(`chat_completions`);return}S(String(t.providerData.endpointId)),D(String(t.providerData.endpointLabel)),j(String(t.providerData.origin)+String(t.providerData.basePath??``)),N(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[Z(`option`,{value:``,children:`Create new endpoint`}),C.map(e=>Z(`option`,{value:String(e.providerData.endpointId),children:String(e.providerData.endpointLabel)},String(e.providerData.endpointId)))]})}),Z(G,{label:`Endpoint ID`,children:e=>Z(W,{...e,value:x,onChange:e=>S(e.target.value)})}),Z(G,{label:`Endpoint label`,children:e=>Z(W,{...e,value:w,onChange:e=>D(e.target.value)})}),Z(G,{label:`Server URL`,children:e=>Z(W,{...e,value:k,placeholder:`https://server.example/api`,onChange:e=>j(e.target.value)})}),k.trim().toLowerCase().startsWith(`http://`)?Z(Ee,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,Z(G,{label:`Protocol`,children:e=>Q(U,{...e,value:ne,onChange:e=>N(e.target.value),children:[Z(`option`,{value:`chat_completions`,children:`Chat Completions (/v1/chat/completions)`}),Z(`option`,{value:`responses`,children:`Responses (/v1/responses)`})]})})]}):null,p===`apiKey`?Z(G,{label:`API key`,children:e=>Z(W,{...e,type:`password`,value:P,autoComplete:`off`,onChange:e=>re(e.target.value)})}):null,Z(G,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>Z(W,{...e,value:m,placeholder:h,onChange:e=>te(e.target.value)})})]}):Q(T,{$gap:3,children:[Q(T,{$gap:1,children:[Z(O,{children:`Step 1 — authorize`}),Z(A,{$gap:2,children:Q(E,{as:`a`,href:g.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[Z(ve,{}),`Open `,h]})}),Z(B,{value:g.authorizeUrl,label:`Copy authorization link`})]}),g.userCode===null?null:Q(T,{$gap:1,children:[Z(O,{children:`Step 2 — enter this code`}),Z(Te,{children:g.userCode})]}),g.kind===`device`?Q(De,{children:[d?.pasteHint??``,` Waiting for authorization…`]}):Z(G,{label:`Authorization code`,hint:d?.pasteHint??``,...F===null?{}:{problem:F},children:e=>Z(W,{...e,value:v,autoFocus:!0,placeholder:Ce(d),onChange:e=>y(e.target.value)})})]}),F===null||g?.kind===`pkce`?null:Z(Ee,{children:F})]})})}function ke({credentialId:e,windows:t,burn:n,pollIntervalMs:r,now:i}){let a=t.map(e=>({window:e,estimate:y(n,e.windowType),since:me(u(e))})),o=a.map(e=>e.since).filter(e=>e!==null),s=o.length===0?0:Math.min(...o),c=_({credentialId:e,since:s},o.length>0),l=c.data?.samples??[],d=c.data?.gatewayRates??[],f=c.data?.truncated===!0;return Z(T,{$gap:4,children:a.map(e=>Z(Ae,{window:e.window,estimate:e.estimate,since:e.since,samples:l.filter(t=>t.windowType===e.window.windowType&&t.observedAt>=(e.since??0)),gatewayRate:d.find(t=>t.windowType===e.window.windowType),truncated:f,pollIntervalMs:r,now:i},e.window.windowType))})}function Ae({window:e,estimate:t,since:n,samples:r,gatewayRate:a,truncated:o,pollIntervalMs:s,now:c}){let l=e.limit===null?`${g(e.used)} used`:`${g(e.used)} of ${g(e.limit)} used`,d=i(e,c),f=t===void 0||p(e,c,s)||t.stale&&!d;return Z(pe,{live:u(e),samples:r.map(u),since:n,now:c,truncated:o&&n!==null&&r.length>0&&(r[0]?.observedAt??0)>n,ratePerHourRatio:w(e,t),exhaustsAt:t?.exhaustsAt??null,survives:t?.survives??null,stale:f,rolledOver:d,spent:l,rateText:t?.ratePerHour===void 0||t.ratePerHour===null?`unknown`:`${g(t.ratePerHour)}/h`,extraFact:Z(he,{legend:`This gateway accounts for`,value:a?.gatewayRatePerHour===void 0||a.gatewayRatePerHour===null?`unknown`:`${g(a.gatewayRatePerHour)} tokens/h`})})}var je=$(N)`
|
|
21
|
-
border-left: 3px solid ${({$provider:e})=>L(e)};
|
|
22
|
-
`,Me=$(W)`
|
|
23
|
-
width: 100%;
|
|
24
|
-
min-width: 140px;
|
|
25
|
-
height: 26px;
|
|
26
|
-
font-family: ${({theme:e})=>e.font.sans};
|
|
27
|
-
font-size: 12.5px;
|
|
28
|
-
background: transparent;
|
|
29
|
-
border-color: transparent;
|
|
30
|
-
|
|
31
|
-
&:hover:not(:disabled),
|
|
32
|
-
&:focus {
|
|
33
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
34
|
-
border-color: ${({theme:e})=>e.color.ruleStrong};
|
|
35
|
-
}
|
|
36
|
-
`,Ne=$(le)`
|
|
37
|
-
width: 62px;
|
|
38
|
-
height: 26px;
|
|
39
|
-
`,Pe=$.span`
|
|
40
|
-
display: block;
|
|
41
|
-
padding-left: 9px;
|
|
42
|
-
font-size: 11px;
|
|
43
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
44
|
-
`,Fe=$.div`
|
|
45
|
-
display: grid;
|
|
46
|
-
/* Bar, figure, legend. The figure has a column of its own so the legends stay
|
|
47
|
-
aligned down the stack whether a window reads 4% or 100%. */
|
|
48
|
-
grid-template-columns: 96px 34px 1fr;
|
|
49
|
-
align-items: center;
|
|
50
|
-
min-width: 208px;
|
|
51
|
-
gap: 6px;
|
|
52
|
-
`,Ie=$(P)`
|
|
53
|
-
font-size: 11px;
|
|
54
|
-
text-align: right;
|
|
55
|
-
`,Le=$.div`
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
gap: 4px;
|
|
59
|
-
`;function Re(){let e=n();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function ze(e,t){if(t===void 0)return` The list of models could not be read, so whether any target is pinned to this account is unknown.`;let n=t.filter(t=>t.targets.some(t=>t.credentialId===e.id)).map(e=>e.id);return n.length===0?``:` ${n.length===1?`The model`:`The models`} ${n.join(`, `)} ${n.length===1?`pins a target`:`pin targets`} to this account. Those targets will fail rather than fall back to another account.`}function Be(){let{cadence:n}=F(),i=m(),c=ee(n(1e4,`res:credentials`)),l=s(),u=a(),f=r(),p=h(),{commit:g}=Re(),[_,b]=Y(!1),[w,M]=Y(null),[P,I]=Y(new Set),ie=e=>I(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),L=Date.now(),B=i.data??[],U=f.data??[],W=e=>o(U,e)?.order??1/0,le=[...new Set(B.map(e=>e.provider))].sort((e,t)=>W(e)-W(t)),G=e=>o(U,e)?.label??e,pe=d(c.data?.health??[],e=>e.credentialId),me=d(c.data?.quota??[],e=>e.credentialId),he=d(c.data?.burn??[],e=>e.credentialId),J=l.data?.quotaPollIntervalMs??3e5,_e=B.filter(e=>e.enabled).length,$=i.isLoading?`Reading connected accounts…`:B.length===0?`No provider credentials are connected, so every request fails at the router.`:`${_e} of ${B.length} accounts are enabled and eligible for routing.`;return Q(X,{children:[Z(z,{legend:`Accounts`,title:`Provider accounts`,summary:$,actions:Q(E,{type:`button`,$variant:`primary`,onClick:()=>b(!0),children:[Z(ae,{}),`Connect an account`]})}),i.isError?Z(N,{legend:`Accounts`,children:Z(j,{error:i.error,onRetry:()=>void i.refetch()})}):i.isLoading?Z(N,{legend:`Accounts`,children:Z(k,{rows:5})}):B.length===0?Z(N,{legend:`Accounts`,children:Z(ne,{legend:`Nothing connected`,message:`Connect a provider account to give the router something to dispatch to. Tokens are encrypted at rest and never shown again.`,action:Z(E,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>b(!0),children:`Connect an account`})})}):Z(T,{$gap:4,children:le.map(n=>{let r=B.filter(e=>e.provider===n);return Z(je,{$provider:n,legend:G(n),meta:`${r.length} account${r.length===1?``:`s`}`,flush:!0,children:Z(re,{children:Q(fe,{children:[Z(`thead`,{children:Q(`tr`,{children:[Z(q,{$width:`24%`,children:`Account`}),Z(q,{$width:`20%`,children:`Sign-in`}),Z(q,{$align:`right`,$width:`86px`,children:`Tier`}),Z(q,{$align:`right`,$width:`94px`,children:`Weight`}),Z(q,{$align:`center`,$width:`86px`,children:`Enabled`}),Z(q,{$width:`240px`,children:`Quota`}),Z(q,{$align:`right`,$width:`130px`,children:`Token expires`}),Z(q,{$width:`76px`})]})}),Z(`tbody`,{children:r.map(n=>{let r=x(pe.get(n.id)??[],L,n.enabled,n.disabledReason),i=me.get(n.id)??[],a=he.get(n.id)??[],o=C(i),s=P.has(n.id);return Q(ge,{children:[Q(de,{children:[Q(K,{children:[Q(A,{$gap:2,children:[Z(S,{state:r.state,label:r.note===``?`healthy`:r.note}),Z(Me,{defaultValue:n.label,"aria-label":`Label for ${n.label}`,onBlur:e=>{let t=e.target.value.trim();if(t.length===0||t===n.label){e.target.value=n.label;return}g(n.id,{label:t})}})]}),r.note===``?null:Z(Pe,{children:r.note})]}),Z(K,{children:Q(A,{$gap:1,children:[Z(ce,{children:n.authType===`oauth`?`oauth`:`api key`}),n.accountEmail===null?null:Z(O,{children:n.accountEmail})]})}),Z(K,{$align:`right`,children:Z(Ne,{min:1,step:1,defaultValue:n.tier,"aria-label":`Tier for ${n.label}`,onBlur:e=>{let t=Number(e.target.value);if(!Number.isInteger(t)||t<1||t===n.tier){e.target.value=String(n.tier);return}g(n.id,{tier:t})}})}),Z(K,{$align:`right`,children:Z(Ne,{min:.1,step:.1,defaultValue:n.weight,"aria-label":`Weight for ${n.label}`,onBlur:e=>{let t=Number(e.target.value);if(!Number.isFinite(t)||t<=0||t===n.weight){e.target.value=String(n.weight);return}g(n.id,{weight:t})}})}),Z(K,{$align:`center`,children:Z(se,{checked:n.enabled,label:`Route to ${n.label}`,onCheckedChange:e=>g(n.id,{enabled:e})})}),Z(K,{children:o.length===0?Z(O,{children:`unknown`}):Z(Le,{children:o.map(({window:n,fraction:r})=>Q(Fe,{children:[Z(ue,{fraction:r,label:`${v[n.windowType]} window, ${Math.round(r*100)}% used`}),Z(Ie,{children:e(r,0)}),Z(O,{children:te(n,L,J,t,y(a,n.windowType))})]},n.windowType))})}),Z(K,{$align:`right`,$mono:!0,children:n.expiresAt===null?`never`:t(n.expiresAt,L)}),Z(K,{$align:`right`,children:Q(A,{$gap:1,$justify:`flex-end`,children:[i.length===0?null:Z(D,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":s,"aria-label":`${s?`Hide`:`Show`} quota history for ${n.label}`,title:`${s?`Hide`:`Show`} quota history for ${n.label}`,onClick:()=>ie(n.id),children:Z(s?V:H,{})}),Z(D,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${n.label}`,title:`Remove ${n.label}`,onClick:()=>M(n),children:Z(oe,{})})]})})]}),s?Z(de,{children:Z(K,{colSpan:9,children:Z(ke,{credentialId:n.id,windows:i,burn:a,pollIntervalMs:J,now:L})})}):null]},n.id)})})]})})},n)})}),Z(Oe,{open:_,credentials:i.data??[],onOpenChange:b,onConnected:()=>void i.refetch()}),Z(R,{open:w!==null,onOpenChange:e=>{e||M(null)},title:`Remove account`,body:w===null?``:`Removing "${w.label}" deletes its stored token. Any model target pointing at ${G(w.provider)} loses this account, and reconnecting means authorizing again.`+ze(w,u.data),confirmLabel:`Remove account`,busy:p.isPending,onConfirm:()=>{w!==null&&p.mutate(w.id,{onSettled:()=>M(null)})}})]})}var Ve=Be;export{Ve as component};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import{F as e,Ft as t,Jt as n,K as r,M as i,Mt as a,O as o,P as s,Wt as c,Z as l,_t as u,j as d,pt as f,ut as p,yt as m}from"./Lamp-lkkWBrFM.js";import{C as h,D as g,_,a as v,b as y,g as b,i as x,o as S,r as ee,t as C,w,x as T}from"./Panel-CWmOTDAP.js";import{b as E,r as D,t as O}from"./Rack-B4L2xB7-.js";import{t as k}from"./trash-2-C937U0RF.js";import{r as A,t as j}from"./Field-BYBri2NV.js";import{t as M}from"./Meter-stpt3vQu.js";import{i as N,n as P,r as F,t as I}from"./Table-CVDZ69Zx.js";import{t as L}from"./Readout-BTh732hP.js";import{n as R}from"./reasons-Du1OBWAM.js";import{useQueryClient as z}from"@tanstack/react-query";import{useCallback as B,useState as V}from"react";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import G from"styled-components";var K=E(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),q=E(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),J=[{id:`keepLatest`,label:`Snapshots kept`,hint:`How many survive regardless of age. The newest is always kept, whatever both numbers say.`,unit:`files`,max:100},{id:`maxAgeDays`,label:`Maximum age`,hint:`Older snapshots are pruned after every new one and on the hourly maintenance sweep.`,unit:`days`,max:3650}],Y=G.p`
|
|
2
|
-
font-size: 12px;
|
|
3
|
-
color: ${({theme:e})=>e.color.down};
|
|
4
|
-
`,X=G.p`
|
|
5
|
-
font-size: 12px;
|
|
6
|
-
color: ${({theme:e})=>e.color.ok};
|
|
7
|
-
`,te=G.div`
|
|
8
|
-
display: grid;
|
|
9
|
-
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
10
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
11
|
-
`;function ne(e){let t={};for(let n of J){let r=e[n.id].trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<1)return{ok:!1,problem:`${n.label} must be a whole number of 1 or more.`};if(i>n.max)return{ok:!1,problem:`${n.label} cannot exceed ${n.max}.`};t[n.id]=i}return{ok:!0,policy:t}}function re({retention:e}){let n=t(),[r,i]=V({}),[a,o]=V(null),[s,c]=V(!1),l={keepLatest:r.keepLatest??(e===void 0?``:String(e.keepLatest)),maxAgeDays:r.maxAgeDays??(e===void 0?``:String(e.maxAgeDays))};return U(C,{legend:`Retention`,actions:U(g,{type:`button`,$size:`sm`,disabled:n.isPending||e===void 0,onClick:()=>{c(!1);let e=ne(l);if(!e.ok){o(e.problem);return}o(null),n.mutate(e.policy,{onSuccess:()=>{c(!0),i({})},onError:e=>o(S(e))})},children:n.isPending?`Saving…`:`Save retention`}),children:W(h,{$gap:3,children:[U(te,{children:J.map(e=>U(j,{label:e.label,hint:e.hint,children:t=>W(y,{$gap:2,children:[U(A,{...t,min:1,max:e.max,step:1,value:l[e.id],onChange:t=>i({...r,[e.id]:t.target.value})}),U(_,{children:e.unit})]})},e.id))}),a===null?null:U(Y,{role:`alert`,children:a}),s&&a===null?U(X,{role:`status`,children:`Retention saved.`}):null]})})}function ie(){let e=z();return B(t=>{if(t.adminPasswordChanged){R(`admin-password-changed`);return}e.invalidateQueries()},[e])}var Z=G.p`
|
|
12
|
-
font-size: 12px;
|
|
13
|
-
color: ${({theme:e})=>e.color.down};
|
|
14
|
-
`,ae=G.input`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
17
|
-
max-width: 40ch;
|
|
18
|
-
`;function oe(){let e=c(),t=p(),n=a(),s=ie(),l=u(),d=m(),[f,_]=V(null),[b,E]=V(null),[O,k]=V(null),[A,M]=V(!1),L=e.data??[],R=W(g,{type:`button`,$variant:`primary`,$size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(),children:[U(K,{}),t.isPending?`Copying…`:`Take a snapshot`]}),z=W(h,{$gap:2,children:[W(y,{$gap:2,$wrap:!0,children:[U(j,{label:`Database file to import`,hint:`A snapshot taken from this or another OmniGateway. It is checked for integrity and rejected if it is not one of ours.`,children:e=>U(ae,{...e,type:`file`,accept:`.sqlite,.db,application/octet-stream`,onChange:e=>k(e.target.files?.[0]??null)})}),U(g,{type:`button`,$variant:`danger`,$size:`sm`,disabled:O===null||d.isPending,onClick:()=>M(!0),children:d.isPending?`Replacing…`:`Import`})]}),d.isError?U(Z,{role:`alert`,children:S(d.error)}):null,n.isError?U(Z,{role:`alert`,children:S(n.error)}):null,t.isError?U(Z,{role:`alert`,children:S(t.error)}):null]});return W(C,{legend:`Snapshots`,meta:`${L.length}`,actions:R,footer:z,flush:!0,children:[e.isError?U(x,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?U(`div`,{style:{padding:12},children:U(v,{rows:3})}):L.length===0?U(ee,{legend:`No snapshots`,message:`Nothing has been copied yet, so there is nothing to go back to. Take one before a migration or a settings change you are unsure of.`,action:U(g,{type:`button`,$variant:`primary`,$size:`sm`,disabled:t.isPending,onClick:()=>t.mutate(),children:`Take the first snapshot`})}):U(T,{children:W(I,{children:[U(`thead`,{children:W(`tr`,{children:[U(F,{children:`File`}),U(F,{children:`Reason`}),U(F,{$align:`right`,children:`Size`}),U(F,{$align:`right`,children:`Taken`}),U(F,{})]})}),U(`tbody`,{children:L.map(e=>W(N,{children:[U(P,{$mono:!0,children:U(w,{style:{maxWidth:`38ch`,display:`block`},children:e.filename})}),U(P,{children:e.reason}),U(P,{$align:`right`,$mono:!0,children:o(e.sizeBytes)}),U(P,{$align:`right`,$mono:!0,children:i(e.createdAt)}),U(P,{$align:`right`,children:W(y,{$gap:1,$justify:`flex-end`,children:[U(g,{as:`a`,$size:`sm`,href:r(e.id),download:e.filename,children:`Download`}),U(g,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>_(e),children:`Restore`}),U(g,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>E(e),children:`Delete`})]})})]},e.id))})]})}),U(D,{open:f!==null,onOpenChange:e=>{e||_(null)},title:`Restore database`,body:f===null?``:`Replacing the live database with ${f.filename}. Client requests are refused while the file is swapped, and a copy of the current database is taken first so this can be undone. Captured request bodies are not part of a snapshot and are left where they are.`,confirmLabel:`Restore database`,busy:n.isPending,onConfirm:()=>{f!==null&&n.mutate(f.id,{onSuccess:s,onSettled:()=>_(null)})}}),U(D,{open:b!==null,onOpenChange:e=>{e||E(null)},title:`Delete snapshot`,body:b===null?``:`Deleting ${b.filename} from disk. Download it first if it is the copy you would go back to; there is no other one of it.`,confirmLabel:`Delete snapshot`,busy:l.isPending,onConfirm:()=>{b!==null&&l.mutate(b.id,{onSettled:()=>E(null)})}}),U(D,{open:A,onOpenChange:M,title:`Import database`,body:O===null?``:`Replacing the live database with ${O.name}. It is validated before anything is touched, and a copy of the current database is taken first. If the file carries a different admin password, every session ends and you will be asked to sign in again.`,confirmLabel:`Replace database`,busy:d.isPending,onConfirm:()=>{O!==null&&d.mutate(O,{onSuccess:s,onSettled:()=>M(!1)})}})]})}var Q=G.p`
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
color: ${({theme:e})=>e.color.ok};
|
|
21
|
-
`,$=G.p`
|
|
22
|
-
font-size: 12px;
|
|
23
|
-
color: ${({theme:e})=>e.color.down};
|
|
24
|
-
`;function se(e){try{let{hostname:t,port:n}=new URL(e);return n===``?t:`${t}:${n}`}catch{return e}}function ce(e){try{return new URL(e).pathname.replace(/^\//,``)||`—`}catch{return`—`}}function le(){let t=f(),r=n(),[i,a]=V(!1),c=l(),[u,p]=V(!1),m=t.data,h=m?.engine===`postgres`,_=m===void 0||m.logicalBytes===0?0:m.freePageBytes/m.logicalBytes;return W(H,{children:[U(O,{legend:`Database`,title:`Storage, snapshots, and retention`,summary:t.isLoading?`Measuring the database…`:h?`The Postgres database every replica of this cluster runs from. Back it up with pg_dump; nothing here copies or replaces it.`:`The one SQLite file this gateway runs from, the copies taken of it, and how long they are kept.`}),U(C,{legend:`Size`,meta:m===void 0?void 0:`schema v${m.stats.schemaVersion}`,actions:W(H,{children:[W(g,{type:`button`,$size:`sm`,disabled:c.isPending||m===void 0||m.bodiesBytes===0,onClick:()=>p(!0),children:[U(k,{}),c.isPending?`Clearing…`:`Clear bodies`]}),h?null:W(g,{type:`button`,$size:`sm`,disabled:r.isPending||m===void 0,onClick:()=>a(!0),children:[U(q,{}),r.isPending?`Compacting…`:`Compact`]})]}),footer:r.isError?U($,{role:`alert`,children:S(r.error)}):c.isError?U($,{role:`alert`,children:S(c.error)}):r.data===void 0?c.data===void 0?void 0:U(Q,{role:`status`,children:`Cleared ${d(c.data.removed)} captured bodies.`}):U(Q,{role:`status`,children:`Compacted, reclaiming ${o(r.data.reclaimedBytes)} in ${s(r.data.durationMs)}.`}),children:t.isError?U(x,{error:t.error,onRetry:()=>void t.refetch()}):m===void 0?U(v,{rows:3}):h?W(b,{$min:`180px`,$stretch:!0,children:[U(L,{legend:`Database`,value:o(m.logicalBytes),unit:`${m.stats.pageCount} blocks of ${o(m.stats.pageSize)}`}),U(L,{legend:`Server`,value:se(m.location),unit:`database ${ce(m.location)}`}),U(L,{legend:`Captured bodies`,value:o(m.bodiesBytes),unit:`the request_bodies table`})]}):W(b,{$min:`180px`,$stretch:!0,children:[U(L,{legend:`Database file`,value:o(m.fileBytes),unit:`${m.stats.pageCount} pages of ${o(m.stats.pageSize)}`,trace:U(M,{fraction:_,label:`${e(_,0)} of the file is reclaimable`})}),U(L,{legend:`Reclaimable`,value:o(m.freePageBytes),unit:`${m.stats.freelistCount} free pages`}),U(L,{legend:`Write-ahead log`,value:o(m.walBytes),unit:`folded into every snapshot`}),U(L,{legend:`Captured bodies`,value:o(m.bodiesBytes),unit:`never in a snapshot`}),U(L,{legend:`Snapshots`,value:o(m.snapshots.totalBytes),unit:`${m.snapshots.count} kept`}),U(L,{legend:`Free disk`,value:o(m.freeDiskBytes),unit:m.freeDiskBytes===null?`not readable here`:`on this filesystem`})]})}),U(C,{legend:`Tables`,meta:h?`row counts are the planner's estimates; dead rows await autovacuum`:`size includes each table's indexes`,children:m===void 0?U(v,{rows:4}):W(I,{children:[U(`thead`,{children:W(N,{children:[U(F,{children:`Table`}),U(F,{$align:`right`,children:`Size`}),U(F,{$align:`right`,children:`Rows`}),h?U(F,{$align:`right`,children:`Dead rows`}):null]})}),U(`tbody`,{children:m.tables.map(e=>W(N,{children:[U(P,{children:e.name}),U(P,{$align:`right`,children:o(e.bytes)}),U(P,{$align:`right`,children:d(e.rows)}),h?U(P,{$align:`right`,children:d(e.deadRows??0)}):null]},e.name))})]})}),h?null:W(H,{children:[U(oe,{}),U(re,{retention:m?.retention})]}),U(D,{open:u,onOpenChange:p,title:`Clear every captured body?`,body:`Every stored prompt and completion is deleted. The requests themselves stay in the log, with their bodies marked pruned. There is no undo: bodies are never in a snapshot.`,confirmLabel:`Clear captured bodies`,busy:c.isPending,onConfirm:()=>c.mutate(void 0,{onSettled:()=>p(!1)})}),U(D,{open:i,onOpenChange:a,title:`Compact database`,body:`Running VACUUM rewrites the database to give back its free pages. It holds the write lock for as long as it takes, so requests in flight will wait, and it needs room on disk for a second copy while it runs.`,confirmLabel:`Compact database`,busy:r.isPending,onConfirm:()=>r.mutate(void 0,{onSettled:()=>a(!1)})})]})}var ue=le;export{ue as component};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import{A as e,F as t,I as n,L as r,P as i,Tt as a,Vt as o,Yt as s,bt as c,c as l,dt as u,f as d,ft as f,h as p,i as m,j as h,n as g,o as _,p as v,qt as y,s as b,t as x,u as S,v as C,wt as w,x as T,z as ee}from"./Lamp-lkkWBrFM.js";import{C as E,D,S as O,_ as k,b as A,g as te,i as ne,r as j,t as M,v as N,w as P,x as F}from"./Panel-CWmOTDAP.js";import{_ as re,f as I,m as L,t as ie}from"./Rack-B4L2xB7-.js";import{n as R,t as ae}from"./TokenBreakdown-DQuX2IKR.js";import{n as oe,t as z}from"./Chip-iJNHhgJ6.js";import{t as B}from"./Meter-stpt3vQu.js";import{i as V,n as H,r as U,t as W}from"./Table-CVDZ69Zx.js";import{t as G}from"./Readout-BTh732hP.js";import{useMemo as K}from"react";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";var se=X(P)`
|
|
2
|
-
font-weight: 500;
|
|
3
|
-
display: block;
|
|
4
|
-
max-width: 24ch;
|
|
5
|
-
`,Z=X.span`
|
|
6
|
-
font-size: 11px;
|
|
7
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
8
|
-
`,ce=X.div`
|
|
9
|
-
display: grid;
|
|
10
|
-
grid-template-columns: 72px 1fr;
|
|
11
|
-
align-items: center;
|
|
12
|
-
gap: 6px;
|
|
13
|
-
min-width: 172px;
|
|
14
|
-
`,le=X.div`
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
gap: 4px;
|
|
18
|
-
`;function ue(e){let t=null;for(let n of e)n.stale||n.survives!==!1||n.exhaustsAt===null||(t===null||n.exhaustsAt<t)&&(t=n.exhaustsAt);return t}function de(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function fe({credentials:e,health:t,quota:r,burn:i,usage:a,lastUsed:o,quotaPollIntervalMs:c,now:u}){let d=l(t,e=>e.credentialId),f=l(r,e=>e.credentialId),m=l(i,e=>e.credentialId),v=new Map(a.map(e=>[e.key,e])),y={down:0,warn:1,ok:2,idle:3,live:3},S=e.map(e=>{let t=m.get(e.id)??[];return{credential:e,status:b(d.get(e.id)??[],u,e.enabled,e.disabledReason),quota:C(f.get(e.id)??[]),burn:t,exhaustsAt:ue(t),usage:v.get(e.id)}}).sort((e,t)=>y[e.status.state]-y[t.status.state]||de(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return J(M,{legend:`Accounts`,meta:`${e.length} connected`,flush:!0,actions:J(D,{as:s,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:e.length===0?J(j,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:J(D,{as:s,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):J(F,{children:Y(W,{children:[J(`thead`,{children:Y(`tr`,{children:[J(U,{children:`Account`}),J(U,{children:`Provider`}),J(U,{$align:`right`,children:`Tier`}),J(U,{children:`Quota`}),J(U,{$align:`right`,children:`Requests`}),J(U,{$align:`right`,children:`Last used`})]})}),J(`tbody`,{children:S.map(({credential:e,status:t,quota:r,burn:i,usage:a})=>Y(V,{children:[J(H,{children:Y(A,{$gap:2,children:[J(x,{state:t.state,label:t.note===``?`healthy`:t.note}),Y(`div`,{children:[J(se,{children:e.label}),t.note===``?null:J(Z,{children:t.note})]})]})}),J(H,{children:J(oe,{provider:e.provider})}),J(H,{$align:`right`,$mono:!0,children:e.tier}),J(H,{children:r.length===0?J(Z,{children:`unknown`}):J(le,{children:r.map(({window:e,fraction:t})=>Y(ce,{children:[J(B,{fraction:t,label:`${g[e.windowType]} window, ${Math.round(t*100)}% used`}),J(k,{children:p(e,u,c,n,_(i,e.windowType))})]},e.windowType))})}),J(H,{$align:`right`,$mono:!0,children:a===void 0?`—`:h(a.requests)}),J(H,{$align:`right`,$mono:!0,children:n(o[e.id]??null,u)})]},e.id))})]})})})}var pe=X.ul`
|
|
19
|
-
display: flex;
|
|
20
|
-
flex-direction: column;
|
|
21
|
-
`,me=X.li`
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
25
|
-
padding: 6px ${({theme:e})=>e.space(3)};
|
|
26
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
27
|
-
|
|
28
|
-
&:last-child {
|
|
29
|
-
border-bottom: 0;
|
|
30
|
-
}
|
|
31
|
-
`,he=X(P)`
|
|
32
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
max-width: 30ch;
|
|
35
|
-
`,ge=X(P)`
|
|
36
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
37
|
-
font-size: 11px;
|
|
38
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
39
|
-
max-width: 16ch;
|
|
40
|
-
`,_e=X(N)`
|
|
41
|
-
color: ${({theme:e})=>e.color.down};
|
|
42
|
-
font-size: 11px;
|
|
43
|
-
`;function ve({logs:t,keyNames:n}){let a=t.slice(0,12);return J(M,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:J(D,{as:s,to:`/logs`,$size:`sm`,children:`Open logs`}),children:a.length===0?J(j,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):J(pe,{children:a.map(t=>Y(me,{children:[J(x,{state:v(t),label:d(t)}),J(N,{$dim:!0,children:e(t.at)}),J(he,{title:t.requestedModel,children:t.requestedModel||`—`}),t.resolvedProvider===null?null:J(N,{$dim:!0,style:{color:L(t.resolvedProvider)},children:t.resolvedProvider}),t.apiKeyId===null?null:J(ge,{title:t.apiKeyId,children:n.get(t.apiKeyId)??ee(t.apiKeyId)}),J(O,{}),S(t)?J(N,{$dim:!0,"aria-label":`processing`,children:J(ae,{})}):Y(q,{children:[t.errorCode===null?null:J(_e,{children:t.errorCode}),t.attempts>1?Y(N,{$dim:!0,children:[t.attempts,`×`]}):null,J(N,{$dim:!0,children:J(R,{tokens:t})}),J(N,{$dim:!0,children:i(t.durationMs)}),J(N,{$dim:!0,children:r(t.costUsd)})]})]},t.id))})})}var ye=X.ul`
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: column;
|
|
46
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
47
|
-
`,be=X(P)`
|
|
48
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
49
|
-
font-size: 12.5px;
|
|
50
|
-
`,xe=X.div`
|
|
51
|
-
display: flex;
|
|
52
|
-
height: 5px;
|
|
53
|
-
border-radius: 2px;
|
|
54
|
-
overflow: hidden;
|
|
55
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
56
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
57
|
-
`,Q=X.div`
|
|
58
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
59
|
-
background: ${({$color:e})=>e};
|
|
60
|
-
opacity: 0.8;
|
|
61
|
-
`,Se=X.div`
|
|
62
|
-
flex: ${({$grow:e})=>e} 0 0;
|
|
63
|
-
`;function Ce({models:e,logs:t}){let n=new Map;for(let e of t){let t=n.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,n.set(e.requestedModel,t)}let i=Math.max(1,...[...n.values()].map(e=>e.requests)),a=[...e].map(e=>({model:e,used:n.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return J(M,{legend:`Models`,meta:`${e.length} configured`,actions:J(D,{as:s,to:`/models`,$size:`sm`,children:`Edit routing`}),children:e.length===0?J(j,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:J(D,{as:s,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):J(ye,{children:a.map(({model:e,used:t})=>{let n=(t?.requests??0)/i,a=[...new Set(e.targets.map(e=>e.provider))];return Y(`li`,{children:[Y(A,{$gap:2,children:[J(be,{title:e.id,children:e.id}),e.isAlias?J(z,{children:`alias`}):null,J(z,{$tone:`accent`,children:e.strategy}),J(O,{}),J(N,{$dim:!0,children:h(t?.requests??0)}),J(k,{children:`req`}),J(N,{$dim:!0,children:r(t?.costUsd??0)})]}),Y(xe,{style:{marginTop:6},title:`${Math.round(n*100)}% of the busiest model`,children:[a.map(e=>J(Q,{$color:L(e),$grow:n/a.length},e)),J(Se,{$grow:Math.max(0,1-n)})]})]},e.id)})})})}var we=X.div`
|
|
64
|
-
display: grid;
|
|
65
|
-
grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
|
|
66
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
67
|
-
`;function Te({logs:e,windowMs:n,now:a}){let o=e.filter(e=>a-e.at<=n),s=T(o,n),c=m(o,{now:a,spanMs:n,count:32}),l=s.errorRate>=.25?`down`:s.errorRate>=.05?`warn`:`ok`,u=s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheWriteTokens;return Y(we,{children:[J(G,{legend:`Requests`,value:h(s.requests),unit:`${s.ratePerMin.toFixed(1)}/min`,trace:J(I,{values:c.map(e=>e.total),overlay:c.map(e=>e.errors),label:`${s.requests} requests, ${s.errors} of them failed`})}),J(G,{legend:`Error rate`,value:t(s.errorRate),unit:`${h(s.errors)} failed`,tone:s.requests===0?`ink`:l,trace:J(I,{values:c.map(e=>e.errors),scaleTo:Math.max(...c.map(e=>e.total)),color:`var(--down)`,label:`${s.errors} failed requests against ${s.requests} total`})}),J(G,{legend:`Total tokens`,value:h(u),unit:J(R,{tokens:s}),trace:J(I,{values:c.map(e=>e.tokens),label:`token volume over the window, ${u.toLocaleString(`en-US`)} total`})}),J(G,{legend:`Time to first token`,value:i(s.ttftP50),unit:`p95 ${i(s.ttftP95)}`,trace:J(I,{values:c.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${i(s.ttftP50)}`})}),J(G,{legend:`Spend`,value:r(s.costUsd),unit:`${h(s.inputTokens+s.outputTokens)} tokens`,trace:J(I,{values:c.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${r(s.costUsd)} total`})})]})}var $=36e5;function Ee(){let{cadence:e}=re(),t=f(),n=u(e(1e4,`res:credentials`)),r=a(),i=w(500,e(1e4,`res:logs`)),s=c(),d=o(),p=K(()=>{let e=new Map;for(let t of s.data??[])e.set(t.id,t.label);return e},[s.data]),m=Date.now(),h=Math.floor((m-$)/6e4)*6e4,g=y({groupBy:`credential`,since:h},e(6e4,`res:usage`)),_=t.data??[],v=l(n.data?.health??[],e=>e.credentialId),x=_.filter(e=>b(v.get(e.id)??[],m,e.enabled,e.disabledReason).state===`down`),S=t.isLoading||i.isLoading?`Reading the gateway…`:_.length===0?`No accounts are connected, so every request fails at the router.`:x.length>0?`${x.length} account${x.length===1?` is`:`s are`} out of rotation.`:`All ${_.length} accounts are answering. Nothing needs attention.`;return Y(q,{children:[J(ie,{legend:`Rack`,title:`Gateway`,summary:S}),i.isError?J(M,{legend:`Traffic`,children:J(ne,{legend:`The gateway did not answer`,error:i.error,onRetry:()=>void i.refetch()})}):Y(E,{$gap:4,children:[J(Te,{logs:i.data??[],windowMs:$,now:m}),J(fe,{credentials:_,health:n.data?.health??[],quota:n.data?.quota??[],burn:n.data?.burn??[],usage:g.data??[],lastUsed:n.data?.lastUsed??{},quotaPollIntervalMs:d.data?.quotaPollIntervalMs??3e5,now:m}),Y(te,{$min:`340px`,$gap:4,children:[J(Ce,{models:r.data??[],logs:i.data??[]}),J(ve,{logs:i.data??[],keyNames:p})]})]})]})}var De=Ee;export{De as component};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import{Lt as e,M as t,Nt as n,Rt as r,Tt as i,bt as a,lt as o,w as s,zt as c}from"./Lamp-lkkWBrFM.js";import{C as l,D as u,O as d,_ as f,a as p,b as m,i as h,o as g,r as _,t as v,v as y,w as b,x}from"./Panel-CWmOTDAP.js";import{b as S,i as C,r as w,t as T,v as E}from"./Rack-B4L2xB7-.js";import{t as D}from"./CopyValue-kMuDjb96.js";import{n as O,t as k}from"./chevron-right-f-3aPVhf.js";import{t as A}from"./plus-DLJ5ZcBJ.js";import{t as j}from"./Toggle-DAjywMl5.js";import{t as M}from"./Chip-iJNHhgJ6.js";import{n as N,r as P,t as F}from"./Field-BYBri2NV.js";import{t as I}from"./Meter-stpt3vQu.js";import{i as L,n as R,r as z,t as ee}from"./Table-CVDZ69Zx.js";import{Fragment as B,useState as V}from"react";import{Fragment as H,jsx as U,jsxs as W}from"react/jsx-runtime";import G from"styled-components";var te=S(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),ne=S(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]);function K(e,t){return e.revokedAt===null?s(e,t)?`active`:`expired`:`revoked`}function re(e){if(e===null)return``;let t=new Date(e-new Date(e).getTimezoneOffset()*6e4);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16)}function q(e){let t=e.trim();if(t.length===0)return{at:null};let n=new Date(t).getTime();return Number.isFinite(n)?{at:n}:{problem:`"${e}" is not a date`}}var ie=G.p`
|
|
2
|
-
font-size: 12px;
|
|
3
|
-
color: ${({theme:e})=>e.color.down};
|
|
4
|
-
`,ae=G.p`
|
|
5
|
-
font-size: 12px;
|
|
6
|
-
color: ${({theme:e})=>e.color.warn};
|
|
7
|
-
`;function oe({apiKey:t,onOpenChange:n}){let r=e(),[i,a]=V(()=>re(t?.expiresAt??null)),[o,s]=V(null),c=()=>{if(t===null)return;let e=q(i);if(`problem`in e){s(e.problem);return}s(null),r.mutate({id:t.id,expiresAt:e.at},{onSuccess:()=>n(!1),onError:e=>s(g(e))})},d=t!==null&&K(t,Date.now())===`expired`;return U(C,{open:t!==null,onOpenChange:n,title:`Edit expiry`,description:t===null?void 0:`When "${t.label}" stops being accepted. Leave it blank for never.`,width:`480px`,footer:W(H,{children:[U(u,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:c,children:r.isPending?`Saving…`:`Save expiry`})]}),children:W(l,{$gap:3,children:[d?U(ae,{role:`status`,children:`This key has expired and the gateway is refusing it. Moving the date forward, or clearing it, brings it back.`}):null,U(F,{label:`Expires`,hint:`Your local time. Blank means the key never expires; a date already past expires it now.`,children:e=>U(N,{...e,type:`datetime-local`,value:i,disabled:r.isPending,onChange:e=>a(e.target.value)})}),o===null?null:U(ie,{role:`alert`,children:o})]})})}var J=[{dimension:`requests`,window:`1m`},{dimension:`requests`,window:`5h`},{dimension:`requests`,window:`1w`},{dimension:`tokens`,window:`1m`},{dimension:`tokens`,window:`5h`},{dimension:`tokens`,window:`1w`},{dimension:`spend`,window:`5h`},{dimension:`spend`,window:`1w`},{dimension:`concurrency`,window:null}];function Y(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var se={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},ce={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function X(e){let t=se[e.dimension];return e.window===null?t:`${t} ${ce[e.window]}`}function Z(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function Q(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function le(e){let t=null,n=-1;for(let r of e){let e=Q(r);e!==null&&e>n&&(t=r,n=e)}return t}function $(e){let t={};for(let e of J)t[Y(e)]=``;if(e===null)return t;for(let n of J){let r=n.window===null?e.concurrency:n.dimension===`requests`?e.requests?.[n.window]:n.dimension===`tokens`?e.tokens?.[n.window]:n.window===`1m`?void 0:e.spend?.[n.window];r!=null&&(t[Y(n)]=String(r))}return t}function ue(e){let t={},n={},r={},i;for(let a of J){let o=(e[Y(a)]??``).trim();if(o.length===0)continue;let s=Number(o),c=a.dimension===`spend`;if(!Number.isFinite(s)||s<=0||!c&&!Number.isInteger(s))return{problem:c?`${X(a)} must be an amount above zero, or blank for no limit.`:`${X(a)} must be a whole number above zero, or blank for no limit.`};a.window===null?i=s:a.dimension===`requests`?t[a.window]=s:a.dimension===`tokens`?n[a.window]=s:a.window!==`1m`&&(r[a.window]=s)}return{limits:{...Object.keys(t).length>0?{requests:t}:{},...Object.keys(n).length>0?{tokens:n}:{},...Object.keys(r).length>0?{spend:r}:{},...i===void 0?{}:{concurrency:i}}}}var de=G.div`
|
|
8
|
-
display: grid;
|
|
9
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
10
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
11
|
-
`,fe=G.p`
|
|
12
|
-
font-size: 11px;
|
|
13
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
14
|
-
`;function pe({draft:e,onChange:t,disabled:n=!1}){return W(l,{$gap:2,children:[U(de,{children:J.map(r=>{let i=Y(r);return U(F,{label:X(r),children:a=>U(P,{...a,min:r.dimension===`spend`?void 0:1,step:r.dimension===`spend`?`any`:1,disabled:n,value:e[i]??``,placeholder:`none`,onChange:n=>t({...e,[i]:n.target.value})})},i)})}),U(fe,{children:`Blank means no limit. Token and spend ceilings are debited after a response completes, so a key at its ceiling is refused on its next request rather than its current one. Concurrency counts requests in flight right now and resets when the gateway restarts.`})]})}var me=G.p`
|
|
15
|
-
font-size: 12px;
|
|
16
|
-
color: ${({theme:e})=>e.color.down};
|
|
17
|
-
`,he=G.p`
|
|
18
|
-
font-size: 12px;
|
|
19
|
-
color: ${({theme:e})=>e.color.warn};
|
|
20
|
-
`;function ge({apiKey:e,onOpenChange:t}){let n=r(),[i,a]=V(()=>$(e?.limits??{})),[o,s]=V(null);return U(C,{open:e!==null,onOpenChange:t,title:`Edit limits`,description:e===null?void 0:`What "${e.label}" may do per minute, per five hours, and per week. Every field is a ceiling; blank is no limit.`,width:`640px`,footer:W(H,{children:[U(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{if(e===null)return;let r=ue(i);if(`problem`in r){s(r.problem);return}s(null),n.mutate({id:e.id,limits:r.limits},{onSuccess:()=>t(!1),onError:e=>s(g(e))})},children:n.isPending?`Saving…`:`Save limits`})]}),children:W(l,{$gap:3,children:[e?.limits===null?U(he,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,U(pe,{draft:i,onChange:a,disabled:n.isPending}),o===null?null:U(me,{role:`alert`,children:o})]})})}var _e=G.div`
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
gap: 2px;
|
|
24
|
-
max-height: 190px;
|
|
25
|
-
overflow-y: auto;
|
|
26
|
-
padding: ${({theme:e})=>e.space(1)};
|
|
27
|
-
border: 1px solid ${({theme:e})=>e.color.ruleStrong};
|
|
28
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
29
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
30
|
-
`,ve=G.label`
|
|
31
|
-
display: flex;
|
|
32
|
-
align-items: center;
|
|
33
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
34
|
-
padding: 4px 6px;
|
|
35
|
-
border-radius: 2px;
|
|
36
|
-
cursor: pointer;
|
|
37
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
38
|
-
font-size: 12px;
|
|
39
|
-
|
|
40
|
-
&:hover {
|
|
41
|
-
background: ${({theme:e})=>e.color.panelRaised};
|
|
42
|
-
}
|
|
43
|
-
`,ye=G.p`
|
|
44
|
-
font-size: 11px;
|
|
45
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
46
|
-
`;function be({configured:e,checked:t,onChange:n,disabled:r}){let i=[...new Set([...e,...t])].sort(),a=(e,r)=>{n(r?[...t,e]:t.filter(t=>t!==e))},o=t.filter(t=>!e.includes(t));return W(`div`,{children:[U(_e,{children:i.map(e=>W(ve,{children:[U(`input`,{type:`checkbox`,disabled:r,"aria-label":e,checked:t.includes(e),onChange:t=>a(e,t.target.checked)}),e]},e))}),o.length>0?U(ye,{children:`Some listed models are no longer configured. They stay until you clear them.`}):null,t.length===0?U(f,{children:`With nothing selected this key is allowed no model.`}):null]})}var xe=G.p`
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
color: ${({theme:e})=>e.color.down};
|
|
49
|
-
`;function Se({apiKey:e,onOpenChange:t}){let n=c(),r=i(),[a,o]=V(e?.modelAllowlist===null),[s,d]=V(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[p,h]=V(null),_=(r.data??[]).map(e=>e.id);return U(C,{open:e!==null,onOpenChange:t,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:W(H,{children:[U(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{e!==null&&(h(null),n.mutate({id:e.id,modelAllowlist:a?null:s},{onSuccess:()=>t(!1),onError:e=>h(g(e))}))},children:n.isPending?`Saving…`:`Save models`})]}),children:W(l,{$gap:3,children:[W(l,{$gap:2,children:[W(m,{$gap:2,children:[U(j,{checked:a,label:`Allow every model`,onCheckedChange:e=>{o(e),e&&d([])}}),U(f,{as:`span`,children:`Allow every model`})]}),a?null:U(be,{configured:_,checked:s,onChange:d,disabled:n.isPending})]}),p===null?null:U(xe,{role:`alert`,children:p})]})})}var Ce=G.div`
|
|
50
|
-
display: grid;
|
|
51
|
-
grid-template-columns: minmax(0, 11rem) minmax(0, 12rem) minmax(0, 1fr) minmax(0, 3.5rem);
|
|
52
|
-
align-items: center;
|
|
53
|
-
gap: ${({theme:e})=>e.space(2)} ${({theme:e})=>e.space(4)};
|
|
54
|
-
`,we=G.span`
|
|
55
|
-
font-size: 11.5px;
|
|
56
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
57
|
-
`,Te=G.p`
|
|
58
|
-
font-size: 11px;
|
|
59
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
60
|
-
`;function Ee({label:e,readings:t}){return W(l,{$gap:3,children:[U(Ce,{children:t.map(t=>{let n=X({dimension:t.dimension,window:t.window}),r=Q(t),i=Z(t.dimension,t.limit);return W(B,{children:[U(f,{as:`span`,children:n}),U(y,{children:t.used===null?i:`${Z(t.dimension,t.used)} of ${i}`}),r===null?U(we,{children:`in flight now, counted in the gateway process`}):U(I,{fraction:Math.min(1,r),label:`${e}, ${n}, ${Math.round(r*100)}% used`}),U(y,{children:r===null?`—`:`${Math.round(r*100)}%`})]},n)})}),U(Te,{children:`Usage counts completed requests still inside each window. Requests in flight are added by the gateway itself and are not shown here.`})]})}var De=G.p`
|
|
61
|
-
font-size: 12px;
|
|
62
|
-
color: ${({theme:e})=>e.color.warn};
|
|
63
|
-
`,Oe=G.p`
|
|
64
|
-
font-size: 11px;
|
|
65
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
66
|
-
`,ke=G.p`
|
|
67
|
-
font-size: 12px;
|
|
68
|
-
color: ${({theme:e})=>e.color.down};
|
|
69
|
-
`,Ae=G.p`
|
|
70
|
-
font-size: 12px;
|
|
71
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
72
|
-
`,je=G(u)`
|
|
73
|
-
gap: 4px;
|
|
74
|
-
`;function Me({open:e,onOpenChange:t}){let n=i(),r=o(),[a,s]=V(``),[c,d]=V(!0),[p,h]=V([]),[_,v]=V(()=>$({})),[b,x]=V(!1),[S,w]=V(``),[T,E]=V(!1),[A,M]=V(null),[P,I]=V(null),L=()=>{s(``),d(!0),h([]),v($({})),x(!1),w(``),E(!1),M(null),I(null),r.reset()},R=e=>{e||L(),t(e)},z=Object.values(_).filter(e=>e.trim().length>0).length;return U(C,{open:e,onOpenChange:R,title:A===null?`Create an API key`:`Key created`,description:A===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:A===null?W(H,{children:[U(u,{type:`button`,onClick:()=>R(!1),children:`Cancel`}),U(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{let e=ue(_);if(`problem`in e){x(!0),I(e.problem);return}let t=q(S);if(`problem`in t){I(t.problem);return}I(null),r.mutate({label:a.trim().length===0?`api key`:a.trim(),modelAllowlist:c?null:p,limits:e.limits,bodyLoggingOptOut:T,expiresAt:t.at},{onSuccess:e=>M(e),onError:e=>I(g(e))})},children:r.isPending?`Creating…`:`Create key`})]}):U(u,{type:`button`,$variant:`primary`,onClick:()=>R(!1),children:`I have copied the key`}),children:A===null?W(l,{$gap:3,children:[U(F,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>U(N,{...e,value:a,placeholder:`api key`,onChange:e=>s(e.target.value)})}),W(l,{$gap:2,children:[W(m,{$gap:2,children:[U(j,{checked:c,label:`Allow every model`,onCheckedChange:d}),U(f,{as:`span`,children:`Allow every model`})]}),c?null:W(H,{children:[U(be,{configured:(n.data??[]).map(e=>e.id),checked:p,onChange:h}),p.length===0?U(De,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),W(l,{$gap:2,children:[W(m,{$gap:2,children:[W(je,{type:`button`,$size:`sm`,"aria-expanded":b,onClick:()=>x(e=>!e),children:[U(b?O:k,{}),`Limits`]}),U(f,{as:`span`,children:z===0?`no limits; this key is unbounded`:`${z} limit${z===1?``:`s`} set`})]}),b?U(pe,{draft:_,onChange:v}):null]}),U(F,{label:`Expires`,hint:`Optional. Your local time; blank means the key never expires.`,children:e=>U(N,{...e,type:`datetime-local`,value:S,onChange:e=>w(e.target.value)})}),W(l,{$gap:2,children:[W(m,{$gap:2,children:[U(j,{checked:T,label:`Never record this key's bodies`,onCheckedChange:E}),U(f,{as:`span`,children:`Never record this key's bodies`})]}),U(Oe,{children:`Suppresses body capture for this key whatever the gateway setting says. Choose it for a client whose payloads must not be retained. It cannot be changed after the key is created — issue a new key instead.`})]}),P===null?null:U(ke,{role:`alert`,children:P})]}):W(l,{$gap:3,children:[U(Ae,{children:`This is the only time the key is shown. The gateway keeps a hash, so a lost key has to be replaced rather than recovered.`}),U(D,{value:A.key,label:`Copy API key`}),W(m,{$gap:2,children:[U(f,{children:`Label`}),U(y,{children:A.label}),U(f,{children:`Prefix`}),U(y,{children:A.prefix})]})]})})}var Ne=G(m)`
|
|
75
|
-
gap: 4px;
|
|
76
|
-
flex-wrap: wrap;
|
|
77
|
-
max-width: 34ch;
|
|
78
|
-
`,Pe=G.span`
|
|
79
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
80
|
-
`,Fe=G.span`
|
|
81
|
-
display: block;
|
|
82
|
-
font-size: 11px;
|
|
83
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
84
|
-
`,Ie=G.span`
|
|
85
|
-
font-size: 11px;
|
|
86
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
87
|
-
`,Le=G.div`
|
|
88
|
-
display: flex;
|
|
89
|
-
flex-direction: column;
|
|
90
|
-
align-items: flex-end;
|
|
91
|
-
gap: 2px;
|
|
92
|
-
`;function Re(e){if(e===null)return`usage not counted here`;let t=Q(e);return`${X({dimension:e.dimension,window:e.window})} ${Z(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ze(){let e=a(),r=n(),[i,o]=V(!1),[s,c]=V(null),[l,g]=V(null),[y,S]=V(null),[C,D]=V(null),[j,N]=V(null),P=Date.now(),F=e.data??[],I=F.filter(e=>K(e,P)===`active`),G=e.isLoading?`Reading issued keys…`:F.length===0?`No keys exist, so nothing can call this gateway yet.`:`${I.length} active key${I.length===1?``:`s`} of ${F.length} ever issued.`;return W(H,{children:[U(T,{legend:`Keys`,title:`Gateway API keys`,summary:G,actions:W(u,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[U(A,{}),`Create a key`]})}),U(v,{legend:`Issued keys`,meta:`${F.length}`,flush:!0,children:e.isError?U(h,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?U(`div`,{style:{padding:12},children:U(p,{rows:4})}):F.length===0?U(_,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:U(u,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):U(x,{children:W(ee,{children:[U(`thead`,{children:W(`tr`,{children:[U(z,{children:`Label`}),U(z,{children:`Prefix`}),U(z,{children:`Allowed models`}),U(z,{$align:`right`,children:`Limits`}),U(z,{$align:`right`,children:`Created`}),U(z,{children:`Body capture`}),U(z,{children:`Status`}),U(z,{})]})}),U(`tbody`,{children:F.map(e=>{let n=C===e.id,r=le(e.limitUsage),i=K(e,P);return W(B,{children:[W(L,{children:[U(R,{children:U(b,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),W(R,{$mono:!0,children:[e.prefix,`…`]}),U(R,{children:e.modelAllowlist===null?U(f,{children:`every model`}):e.modelAllowlist.length===0?U(M,{$tone:`down`,children:`no models`}):U(Ne,{children:e.modelAllowlist.map(e=>U(M,{children:e},e))})}),U(R,{$align:`right`,children:e.limits===null?U(M,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?U(f,{children:`no limits`}):W(Le,{children:[W(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),U(Ie,{children:Re(r)})]})}),U(R,{$align:`right`,$mono:!0,children:t(e.createdAt)}),U(R,{children:e.bodyLoggingOptOut?U(M,{children:`no bodies`}):U(f,{children:`—`})}),W(R,{children:[i===`revoked`?U(Pe,{title:t(e.revokedAt??0),children:U(M,{children:`revoked`})}):i===`expired`?U(M,{$tone:`down`,children:`expired`}):U(M,{$tone:`ok`,children:`active`}),e.expiresAt===null?null:W(Fe,{children:[i===`expired`?`expired`:`expires`,` `,t(e.expiresAt)]})]}),U(R,{$align:`right`,children:W(m,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":n,"aria-label":`${n?`Hide`:`Show`} limits for ${e.label}`,title:`${n?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>D(n?null:e.id),children:U(n?O:k,{})}),e.revokedAt===null?W(H,{children:[U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>g(e),children:U(ne,{})}),U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>c(e),children:U(E,{})}),U(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit expiry for ${e.label}`,title:`Edit expiry for ${e.label}`,onClick:()=>S(e),children:U(te,{})}),U(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>N(e),children:`Revoke`})]}):null]})})]}),n?U(L,{children:U(R,{colSpan:8,children:U(Ee,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),U(Me,{open:i,onOpenChange:o}),U(ge,{apiKey:s,onOpenChange:e=>{e||c(null)}},s?.id??`none`),U(Se,{apiKey:l,onOpenChange:e=>{e||g(null)}},l?.id??`none`),U(oe,{apiKey:y,onOpenChange:e=>{e||S(null)}},y?.id??`none`),U(w,{open:j!==null,onOpenChange:e=>{e||N(null)},title:`Revoke key`,body:j===null?``:`Revoking "${j.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:r.isPending,onConfirm:()=>{j!==null&&r.mutate(j.id,{onSettled:()=>N(null)})}})]})}var Be=ze;export{Be as component};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import{At as e,J as t,V as n,bt as r,ft as i,j as a,l as o,u as s,wt as c}from"./Lamp-lkkWBrFM.js";import{C as l,D as u,_ as d,a as f,b as p,i as m,r as h,t as g,x as _}from"./Panel-CWmOTDAP.js";import{_ as v,i as y,t as b}from"./Rack-B4L2xB7-.js";import{t as x}from"./Chip-iJNHhgJ6.js";import{i as S,n as C}from"./Field-BYBri2NV.js";import{i as w,n as T,r as E,t as D}from"./RequestTable-DSmx72OY.js";import{useMemo as O,useState as k}from"react";import{Fragment as A,jsx as j,jsxs as M}from"react/jsx-runtime";import N from"styled-components";var P={none:{legend:`Not captured`,message:`Body capture was not running for this request. It needs OMNI_BODY_LOGGING_ALLOWED in the environment and the body logging setting turned on, and the calling key must not have opted out.`},missing:{legend:`Captured, then lost`,message:`This request was captured, but its artifact is no longer on disk. Retention or the row cap has since pruned it, or something removed the file underneath the gateway.`},corrupt:{legend:`Captured, but unreadable`,message:`This request was captured and the artifact is still on disk, but it failed its checksum or would not decrypt. Changing OMNI_ENCRYPTION_KEY invalidates every artifact written under the old one.`}},F=new Intl.NumberFormat(`en-US`),I=N.p`
|
|
2
|
-
font-size: 12px;
|
|
3
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
4
|
-
max-width: 62ch;
|
|
5
|
-
`,L=N(I)`
|
|
6
|
-
border-left: 2px solid ${({theme:e})=>e.color.ruleStrong};
|
|
7
|
-
padding-left: ${({theme:e})=>e.space(2)};
|
|
8
|
-
`,R=N.h4`
|
|
9
|
-
font-size: 11px;
|
|
10
|
-
font-weight: 600;
|
|
11
|
-
letter-spacing: 0.12em;
|
|
12
|
-
text-transform: uppercase;
|
|
13
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
14
|
-
margin: 0;
|
|
15
|
-
`,z=N.figcaption`
|
|
16
|
-
display: flex;
|
|
17
|
-
align-items: center;
|
|
18
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
19
|
-
flex-wrap: wrap;
|
|
20
|
-
margin-bottom: 4px;
|
|
21
|
-
`,B=N.figure`
|
|
22
|
-
margin: 0;
|
|
23
|
-
min-width: 0;
|
|
24
|
-
`,V=N.pre`
|
|
25
|
-
margin: 0;
|
|
26
|
-
padding: ${({theme:e})=>e.space(2)};
|
|
27
|
-
max-height: 260px;
|
|
28
|
-
overflow: auto;
|
|
29
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
30
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
31
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
32
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
33
|
-
font-size: 11.5px;
|
|
34
|
-
line-height: 1.5;
|
|
35
|
-
white-space: pre-wrap;
|
|
36
|
-
word-break: break-word;
|
|
37
|
-
`;function H(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(t.omitted!==!0||typeof t.reason!=`string`)return null;let n=t.serializedBytes;return{omitted:!0,reason:t.reason,serializedBytes:typeof n==`number`?n:0}}function U({title:e,stage:t,value:n}){let r=H(n);return M(B,{children:[M(z,{children:[j(R,{children:e}),t===void 0?null:j(x,{children:t})]}),r===null?n==null?j(I,{children:`Nothing was recorded for this half — it never happened, or never completed.`}):j(V,{children:JSON.stringify(n,null,2)}):M(I,{children:[`Too large to keep: `,r.reason,`. The payload was`,` `,F.format(r.serializedBytes),` bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace.`]})]})}function W({attempt:e}){return M(l,{$gap:2,children:[M(p,{$gap:2,$wrap:!0,children:[M(d,{as:`h3`,children:[`Attempt `,e.attempt,` · `,e.provider]}),e.truncated?j(x,{$tone:`warn`,children:`truncated`}):null]}),j(U,{title:`Request sent to the provider`,stage:`post-RTK`,value:e.request}),j(U,{title:`Response from the provider`,value:e.response}),e.streamChunks===null?null:j(U,{title:`Raw stream frames (${a(e.streamChunks.length)})`,value:e.streamChunks})]})}function G({body:e}){let t=e.artifact;if(t===null){let t=P[e.detailState===`ready`?`corrupt`:e.detailState];return M(l,{$gap:1,children:[j(d,{children:t.legend}),j(I,{children:t.message})]})}return M(l,{$gap:3,children:[t.attempts.length===0?null:j(L,{children:`The client request below is what arrived at the gateway. Each attempt request is what went upstream after RTK filters ran, so the two are not the same payload — compare them to see what compression actually removed.`}),M(l,{$gap:2,children:[M(p,{$gap:2,$wrap:!0,children:[j(d,{as:`h3`,children:`Client`}),t.client.truncated?j(x,{$tone:`warn`,children:`truncated`}):null]}),j(U,{title:`Request from the client`,stage:`pre-RTK`,value:t.client.request}),j(U,{title:`Response returned to the client`,value:t.client.response})]}),t.attempts.map(e=>j(W,{attempt:e},`${e.attempt}-${e.provider}`)),t.error===null||t.error===void 0?null:j(U,{title:`Error`,value:t.error})]})}function K({requestId:t}){let n=e(t),r=n.data===void 0||n.data.detailState!==`ready`?void 0:`${F.format(n.data.sizeBytes)} bytes on disk`;return j(g,{legend:`Captured bodies`,...r===void 0?{}:{meta:r},...n.data?.truncated===!0?{actions:j(x,{$tone:`warn`,children:`truncated`})}:{},children:n.isError?j(m,{error:n.error,onRetry:()=>void n.refetch()}):n.isPending?j(f,{rows:3}):j(G,{body:n.data})})}var q=[50,100,250,500],J=N(p)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,Y=N(C)`
|
|
41
|
-
width: 220px;
|
|
42
|
-
`,X=N(S)`
|
|
43
|
-
width: auto;
|
|
44
|
-
`,Z=N(g)`
|
|
45
|
-
flex: 1;
|
|
46
|
-
min-height: 0;
|
|
47
|
-
|
|
48
|
-
> div {
|
|
49
|
-
display: flex;
|
|
50
|
-
flex: 1;
|
|
51
|
-
flex-direction: column;
|
|
52
|
-
min-height: 0;
|
|
53
|
-
}
|
|
54
|
-
`,Q=N(_)`
|
|
55
|
-
flex: 1;
|
|
56
|
-
min-height: 0;
|
|
57
|
-
overflow-y: auto;
|
|
58
|
-
`;function $(){let{cadence:e,live:l}=v(),[d,p]=k(100),[g,_]=k(`all`),[x,S]=k(``),[C,N]=k(null),P=c(d,e(n,`res:logs`)),F=i(),I=r(),L=t(),R=(P.data??[]).some(s),z=w(l&&R),B=O(()=>({accounts:new Map((F.data??[]).map(e=>[e.id,e.label])),keys:new Map((I.data??[]).map(e=>[e.id,e.label]))}),[F.data,I.data]),V=E(P.data??[],g,x,B),H=(P.data??[]).filter(o).length,U=(P.data??[]).filter(s).length;return M(A,{children:[j(b,{legend:`Logs`,title:`Recent requests`,summary:P.isLoading?`Reading the request log…`:`${a(P.data?.length??0)} recent requests, ${a(H)} of them failed${U===0?``:`, ${a(U)} still running`}. ${L.data===!0?`Body capture is on: open a request to read what it sent and received.`:`Prompt and response bodies are not being recorded.`}`,actions:M(J,{children:[j(Y,{value:x,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>S(e.target.value)}),M(X,{value:g,"aria-label":`Show which requests`,onChange:e=>_(e.target.value),children:[j(`option`,{value:`all`,children:`All requests`}),j(`option`,{value:`failed`,children:`Failed only`})]}),j(X,{value:d,"aria-label":`How many requests to fetch`,onChange:e=>p(Number(e.target.value)),children:q.map(e=>M(`option`,{value:e,children:[`last `,e]},e))})]})}),j(Z,{legend:`Request log`,meta:`${V.length} shown`,flush:!0,children:P.isError?j(m,{error:P.error,onRetry:()=>void P.refetch()}):P.isLoading?j(`div`,{style:{padding:12},children:j(f,{rows:8})}):V.length===0?j(h,{legend:`Nothing to show`,message:(P.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):j(Q,{"data-testid":`request-log-scroller`,children:j(T,{rows:V,now:z,names:B,onOpen:N})})}),j(y,{open:C!==null,onOpenChange:e=>{e||N(null)},title:`Request detail`,width:`760px`,footer:j(u,{type:`button`,onClick:()=>N(null),children:`Close`}),children:C===null?null:j(D,{log:C,names:B,children:j(K,{requestId:C.id})})})]})}var ee=$;export{ee as component};
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}from"./Lamp-lkkWBrFM.js";import{C as l,D as u,O as d,S as f,_ as p,a as m,b as h,i as g,o as _,r as v,t as y,v as b,w as x}from"./Panel-CWmOTDAP.js";import{b as S,m as C,r as w,t as T}from"./Rack-B4L2xB7-.js";import{t as E}from"./plus-DLJ5ZcBJ.js";import{t as D}from"./trash-2-C937U0RF.js";import{t as O}from"./Toggle-DAjywMl5.js";import{n as ee,t as k}from"./Chip-iJNHhgJ6.js";import{i as A,n as j,r as M,t as N}from"./Field-BYBri2NV.js";import{t as P}from"./Meter-stpt3vQu.js";import{useEffect as te,useId as ne,useState as F}from"react";import{Fragment as I,jsx as L,jsxs as R}from"react/jsx-runtime";import z from"styled-components";var re=S(`play`,[[`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`}]]),ie=S(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),B=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ae={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`},oe=z.li`
|
|
2
|
-
padding: ${({theme:e})=>e.space(2)} 0;
|
|
3
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
4
|
-
|
|
5
|
-
&:last-child {
|
|
6
|
-
border-bottom: 0;
|
|
7
|
-
}
|
|
8
|
-
`,se=z(b)`
|
|
9
|
-
width: 22px;
|
|
10
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
|
-
flex: none;
|
|
12
|
-
`,ce=z(k)`
|
|
13
|
-
border-color: ${({theme:e})=>e.color.ok};
|
|
14
|
-
color: ${({theme:e})=>e.color.ok};
|
|
15
|
-
background: ${({theme:e})=>e.color.okWash};
|
|
16
|
-
`,le=z.div`
|
|
17
|
-
display: grid;
|
|
18
|
-
grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
|
|
19
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
20
|
-
margin-top: ${({theme:e})=>e.space(2)};
|
|
21
|
-
padding-left: 30px;
|
|
22
|
-
`,ue=z.div`
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: 3px;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
`,de=z.div`
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: baseline;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: 6px;
|
|
32
|
-
`,fe=z.li`
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
36
|
-
padding: 5px 0;
|
|
37
|
-
`,pe=z(h)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,V=z.label`
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
gap: 6px;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
font-size: 12.5px;
|
|
46
|
-
`,me=z.p`
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
color: ${({theme:e})=>e.color.down};
|
|
49
|
-
`;function H(e,t,n){return(e[t]??0)*n[t]}function he({modelId:e}){let[t,n]=F({tools:!1,images:!1,reasoning:!1}),[r,i]=F(null),[o,s]=F(null),d=a(),m=c(),g=d.data?.weights,S=()=>{e!==null&&(s(null),m.mutate({modelId:e,need:t},{onSuccess:e=>i(e),onError:e=>{i(null),s(_(e))}}))},C=new Map(B.map(e=>[e,Math.max(1e-4,...(r?.candidates??[]).map(t=>g===void 0?0:Math.abs(H(t.reasons,e,g))))]));return L(y,{legend:`Explain`,meta:e??`no model selected`,actions:R(u,{type:`button`,$size:`sm`,$variant:`primary`,disabled:e===null||m.isPending,onClick:S,children:[L(re,{}),m.isPending?`Ranking…`:`Rank candidates`]}),children:R(l,{$gap:3,children:[R(l,{$gap:1,children:[L(p,{children:`Pretend the request needs`}),R(pe,{children:[R(V,{children:[L(O,{checked:t.tools,label:`Probe request uses tools`,onCheckedChange:e=>n({...t,tools:e})}),`Tools`]}),R(V,{children:[L(O,{checked:t.images,label:`Probe request includes an image`,onCheckedChange:e=>n({...t,images:e})}),`Images`]}),R(V,{children:[L(O,{checked:t.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>n({...t,reasoning:e})}),`Reasoning`]})]})]}),o===null?null:L(me,{children:o}),r===null?L(v,{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.`}):R(l,{$gap:3,children:[R(h,{$gap:2,$wrap:!0,children:[L(k,{$tone:`accent`,children:r.strategy}),r.deterministic?null:L(k,{$tone:`warn`,children:`order varies per request`}),L(f,{}),R(p,{children:[r.candidates.length,` eligible · `,r.excluded.length,` filtered out`]})]}),r.candidates.length===0?L(v,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):L(`ul`,{children:r.candidates.map((e,t)=>R(oe,{children:[R(h,{$gap:2,children:[L(se,{children:t+1}),L(ee,{provider:e.provider}),L(x,{style:{maxWidth:`22ch`},children:e.credentialLabel}),L(b,{$dim:!0,children:e.model}),R(k,{children:[`tier `,e.tier]}),L(f,{}),t===0?L(ce,{children:`would be used`}):null,L(b,{children:e.score.toFixed(2)})]}),g===void 0?null:L(le,{children:B.map(t=>{let n=H(e.reasons,t,g),r=C.get(t)??1;return R(ue,{title:ae[t],children:[R(de,{children:[L(p,{children:t}),L(b,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),L(P,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${t} contributes ${n.toFixed(2)} of ${e.score.toFixed(2)}`})]},t)})})]},`${e.credentialId}:${e.model}`))}),r.excluded.length===0?null:R(l,{$gap:1,children:[L(p,{children:`Filtered out`}),L(`ul`,{children:r.excluded.map(e=>R(fe,{children:[L(b,{$dim:!0,children:e.model}),L(b,{$dim:!0,children:e.credentialId}),L(f,{}),L(k,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}function U(e,t,n){return i(e,t)?.models.find(e=>e.id===n)}function W(e,t,n){let r=i(e,t);return r===void 0?null:r.models.find(e=>e.id===n)?.auth??r.authTypes}var G=[{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.`}],K=0;function q(){return K+=1,`target-${K}`}function J(e,t,n){let r=U(e,t,n)?.pricing;return r===void 0?null:{costInput:String(r.input),costOutput:String(r.output),costCacheRead:String(r.cacheRead),costCacheWrite5m:String(r.cacheWrite5m),costCacheWrite1h:String(r.cacheWrite1h)}}function ge(e,t,n){let r=U(e,t,n)?.limits;return r===void 0?null:{contextWindow:String(r.contextWindow),maxOutputTokens:String(r.maxOutputTokens)}}var _e={oauth:`OAuth`,apiKey:`an API key`};function Y(e){return e.map(e=>_e[e]).join(` or `)}function ve(e){let t=Object.create(null);for(let n of e){let e=t[n.provider]??[];e.includes(n.authType)||e.push(n.authType),t[n.provider]=e}return t}function X(e,t,n,r){let i=r[t];if(i===void 0||i.length===0)return!0;let a=W(e,t,n);return a===null||a.some(e=>i.includes(e))}function ye(e,t,n){let r=i(e,t);return r===void 0?[]:r.models.filter(r=>X(e,t,r.id,n))}function be(e,t,n,r){if(n.trim().length===0||X(e,t,n,r))return null;let i=r[t]??[];return`${t} serves this model to ${Y(W(e,t,n)??[])} only, and every ${t} account here is ${Y(i)}. Requests routed here will fail.`}function xe(t,n){let r={provider:t.provider,endpointId:t.endpointId};return n.filter(t=>e(r,t)).map(e=>({id:e.id,label:e.accountEmail??e.label}))}function Se(e,t,n){return e.length===0||n.length===0||xe(t,n).some(t=>t.id===e)?null:`No connected account has this id. Requests routed here will fail rather than falling back to another account.`}function Ce(e,t){return{...e,endpointId:t,...t===e.endpointId?{}:{credentialId:``}}}function we(e,t,n){return{...t,...n,...J(e,n.provider,n.model)??{},...n.provider===t.provider?{}:{credentialId:``},contextWindow:``,maxOutputTokens:``}}function Te(e,t){let n=t??e[0]?.id??`anthropic`,r=i(e,n)?.defaultModel??``,a=J(e,n,r);return{key:q(),provider:n,endpointId:``,model:r,tier:`1`,weight:`1`,costInput:a?.costInput??`0`,costOutput:a?.costOutput??`0`,costCacheRead:a?.costCacheRead??``,costCacheWrite5m:a?.costCacheWrite5m??``,costCacheWrite1h:a?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,credentialId:``,tools:!0,images:!0,reasoning:!0}}function Ee(e){return{id:``,strategy:`score`,isAlias:!1,targets:[Te(e)]}}function De(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:q(),provider:e.provider,endpointId:e.provider===`custom`?e.endpointId??``:``,model:e.model,tier:String(e.tier),weight:String(e.weight),costInput:String(e.costPerMTok.input),costOutput:String(e.costPerMTok.output),costCacheRead:e.costPerMTok.cacheRead===void 0?``:String(e.costPerMTok.cacheRead),costCacheWrite5m:e.costPerMTok.cacheWrite5m===void 0?``:String(e.costPerMTok.cacheWrite5m),costCacheWrite1h:e.costPerMTok.cacheWrite1h===void 0?``:String(e.costPerMTok.cacheWrite1h),contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),maxOutputTokens:e.maxOutputTokens===void 0?``:String(e.maxOutputTokens),credentialId:e.credentialId??``,tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function Oe(e){let t=e.id.trim();if(t.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 n=[];for(let[t,r]of e.targets.entries()){let e=`Target ${t+1}`,i=r.endpointId.trim(),a=r.credentialId.trim();if(r.provider===`custom`&&i.length===0)return{ok:!1,problem:`${e} needs a custom endpoint.`};let o=r.model.trim();if(o.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let s=Number(r.tier);if(!Number.isInteger(s)||s<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let c=Number(r.weight);if(!Number.isFinite(c)||c<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let l=Number(r.costInput),u=Number(r.costOutput);if(!Number.isFinite(l)||l<0||!Number.isFinite(u)||u<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let d=r.costCacheRead.trim().length>0,f=Number(r.costCacheRead);if(d&&(!Number.isFinite(f)||f<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let p=r.costCacheWrite5m.trim().length>0,m=Number(r.costCacheWrite5m);if(p&&(!Number.isFinite(m)||m<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let h=r.costCacheWrite1h.trim().length>0,g=Number(r.costCacheWrite1h);if(h&&(!Number.isFinite(g)||g<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let _=r.contextWindow.trim().length>0,v=Number(r.contextWindow);if(_&&(!Number.isInteger(v)||v<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let y=r.maxOutputTokens.trim().length>0,b=Number(r.maxOutputTokens);if(y&&(!Number.isInteger(b)||b<1))return{ok:!1,problem:`${e}: the output limit must be a whole number of tokens.`};n.push({provider:r.provider,...r.provider===`custom`?{endpointId:i}:{},model:o,tier:s,weight:c,costPerMTok:{input:l,output:u,...d?{cacheRead:f}:{},...p?{cacheWrite5m:m}:{},...h?{cacheWrite1h:g}:{}},..._?{contextWindow:v}:{},...y?{maxOutputTokens:b}:{},...a.length>0?{credentialId:a}:{},capabilities:{tools:r.tools,images:r.images,reasoning:r.reasoning}})}return{ok:!0,model:{id:t,strategy:e.strategy,isAlias:e.isAlias,targets:n}}}var ke=z.fieldset`
|
|
50
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
51
|
-
border-left: 3px solid ${({$provider:e})=>C(e)};
|
|
52
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
53
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
54
|
-
margin: 0;
|
|
55
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
59
|
-
min-width: 0;
|
|
60
|
-
`,Ae=z.div`
|
|
61
|
-
display: grid;
|
|
62
|
-
grid-template-columns: minmax(140px, 1.4fr) minmax(160px, 2fr) 72px 72px;
|
|
63
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
64
|
-
align-items: end;
|
|
65
|
-
|
|
66
|
-
@media (max-width: 720px) {
|
|
67
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
68
|
-
}
|
|
69
|
-
`,je=z.div`
|
|
70
|
-
display: grid;
|
|
71
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
72
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
73
|
-
align-items: end;
|
|
74
|
-
`,Z=z.div`
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
gap: 4px;
|
|
78
|
-
min-width: 0;
|
|
79
|
-
`,Me=z(h)`
|
|
80
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
81
|
-
flex-wrap: wrap;
|
|
82
|
-
`,Ne=z.p`
|
|
83
|
-
font-size: 11.5px;
|
|
84
|
-
color: ${({theme:e})=>e.color.down};
|
|
85
|
-
margin: 0;
|
|
86
|
-
`,Q=z.label`
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
gap: 6px;
|
|
90
|
-
cursor: pointer;
|
|
91
|
-
`;function Pe({target:e,index:t,onChange:n,onRemove:r,removable:a,catalog:o,endpoints:s,held:c,credentials:m}){let g=ne(),_=i(o,e.provider),v=ye(o,e.provider,c),y=be(o,e.provider,e.model,c),b=xe(e,m),x=Se(e.credentialId,e,m),S=(t,r)=>{n({...e,[t]:r})},C=J(o,e.provider,e.model),w=ge(o,e.provider,e.model),T=t=>{n(we(o,e,t))};return R(ke,{$provider:e.provider,children:[R(h,{$gap:2,children:[R(p,{as:`legend`,children:[`Target `,t+1]}),L(f,{}),L(d,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!a,"aria-label":`Remove target ${t+1}`,title:a?`Remove target ${t+1}`:`A model needs at least one target`,onClick:r,children:L(D,{})})]}),R(Ae,{children:[R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-provider`,children:`Provider`}),R(A,{id:`${g}-provider`,value:e.provider,onChange:t=>{let n=t.target.value,r=i(o,n),a=r?.models.some(t=>t.id===e.model)??!1;T({provider:n,model:a?e.model:r?.defaultModel??``})},children:[o.map(e=>L(`option`,{value:e.id,children:e.label},e.id)),_===void 0?R(`option`,{value:e.provider,children:[e.provider,` (not in the catalog)`]}):null]})]}),e.provider===`custom`?R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-endpoint`,children:`Endpoint`}),R(A,{id:`${g}-endpoint`,value:e.endpointId,onChange:t=>n(Ce(e,t.target.value)),children:[L(`option`,{value:``,children:`Choose endpoint`}),s.map(e=>L(`option`,{value:e.id,children:e.label},e.id))]})]}):null,R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-model`,children:`Provider model`}),L(j,{id:`${g}-model`,list:`${g}-catalog`,value:e.model,placeholder:_?.defaultModel??``,onChange:t=>T({provider:e.provider,model:t.target.value})}),L(`datalist`,{id:`${g}-catalog`,children:v.map(e=>L(`option`,{value:e.id,children:e.label},e.id))}),y===null?null:L(Ne,{role:`note`,children:y})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-tier`,children:`Tier`}),L(M,{id:`${g}-tier`,min:1,step:1,value:e.tier,onChange:e=>S(`tier`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-weight`,children:`Weight`}),L(M,{id:`${g}-weight`,min:0,step:.1,value:e.weight,onChange:e=>S(`weight`,e.target.value)})]})]}),L(l,{$gap:1,children:R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-account`,children:`Account`}),R(A,{id:`${g}-account`,value:e.credentialId,onChange:e=>S(`credentialId`,e.target.value),children:[L(`option`,{value:``,children:`Any account`}),b.map(e=>L(`option`,{value:e.id,children:e.label},e.id)),x===null?null:R(`option`,{value:e.credentialId,children:[e.credentialId,` (removed)`]})]}),x===null?null:L(Ne,{role:`note`,children:x})]})}),R(l,{$gap:1,children:[R(h,{$gap:2,children:[L(p,{children:`Price per million tokens`}),L(f,{}),C===null?L(p,{as:`span`,children:`not in the catalog — price it yourself`}):R(u,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:e.costInput===C.costInput&&e.costOutput===C.costOutput&&e.costCacheRead===C.costCacheRead&&e.costCacheWrite5m===C.costCacheWrite5m&&e.costCacheWrite1h===C.costCacheWrite1h,onClick:()=>n({...e,...C}),children:[L(ie,{}),`Use list price`]})]}),R(je,{children:[R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-in`,children:`Input`}),L(M,{id:`${g}-in`,min:0,step:.01,value:e.costInput,onChange:e=>S(`costInput`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-out`,children:`Output`}),L(M,{id:`${g}-out`,min:0,step:.01,value:e.costOutput,onChange:e=>S(`costOutput`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-cache`,children:`Cache read`}),L(M,{id:`${g}-cache`,min:0,step:.01,placeholder:`same as input`,value:e.costCacheRead,onChange:e=>S(`costCacheRead`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-write5m`,children:`Cache write 5m`}),L(M,{id:`${g}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:e.costCacheWrite5m,onChange:e=>S(`costCacheWrite5m`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-write1h`,children:`Cache write 1h`}),L(M,{id:`${g}-write1h`,min:0,step:.01,placeholder:`2x input`,value:e.costCacheWrite1h,onChange:e=>S(`costCacheWrite1h`,e.target.value)})]})]})]}),R(l,{$gap:1,children:[R(h,{$gap:2,children:[L(p,{children:`Token limits`}),L(f,{}),w===null?L(p,{as:`span`,children:`not in the catalog — state them yourself`}):L(p,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),R(je,{children:[R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-context`,children:`Context window`}),L(M,{id:`${g}-context`,min:1,step:1024,placeholder:w?.contextWindow??`published`,value:e.contextWindow,onChange:e=>S(`contextWindow`,e.target.value)})]}),R(Z,{children:[L(p,{as:`label`,htmlFor:`${g}-maxout`,children:`Max output`}),L(M,{id:`${g}-maxout`,min:1,step:1024,placeholder:w?.maxOutputTokens??`published`,value:e.maxOutputTokens,onChange:e=>S(`maxOutputTokens`,e.target.value)})]})]})]}),R(l,{$gap:1,children:[L(p,{children:`Capabilities`}),R(Me,{children:[R(Q,{children:[L(O,{checked:e.tools,label:`Target ${t+1} supports tools`,onCheckedChange:e=>S(`tools`,e)}),`Tools`]}),R(Q,{children:[L(O,{checked:e.images,label:`Target ${t+1} supports images`,onCheckedChange:e=>S(`images`,e)}),`Images`]}),R(Q,{children:[L(O,{checked:e.reasoning,label:`Target ${t+1} supports reasoning`,onCheckedChange:e=>S(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Fe=z.p`
|
|
92
|
-
font-size: 11.5px;
|
|
93
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
94
|
-
`,Ie=z.p`
|
|
95
|
-
font-size: 12px;
|
|
96
|
-
color: ${({theme:e})=>e.color.down};
|
|
97
|
-
`,Le=z.p`
|
|
98
|
-
font-size: 12px;
|
|
99
|
-
color: ${({theme:e})=>e.color.ok};
|
|
100
|
-
`,Re=z(h)`
|
|
101
|
-
gap: 8px;
|
|
102
|
-
`;function ze({model:e,onSaved:r,onDeleted:i}){let a=t().data??[],[c,d]=F(()=>e===null?Ee(a):De(e)),[m,g]=F(null),[v,b]=F(!1),[x,S]=F(!1),C=n(),T=s(),D=o(),ee=ve(D.data??[]),k=(D.data??[]).filter(e=>e.provider===`custom`).map(e=>({id:String(e.providerData.endpointId??``),label:String(e.providerData.endpointLabel??e.providerData.endpointId??``)})).filter((e,t,n)=>e.id.length>0&&n.findIndex(t=>t.id===e.id)===t),M=e?.id??null;te(()=>{d(e===null?Ee(a):De(e)),g(null),b(!1)},[M]);let P=G.find(e=>e.id===c.strategy);return R(I,{children:[L(y,{legend:e===null?`New model`:`Edit model`,meta:e===null?void 0:e.id,actions:R(I,{children:[e===null?null:L(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>S(!0),children:`Delete`}),L(u,{type:`button`,$variant:`primary`,$size:`sm`,disabled:C.isPending,onClick:()=>{b(!1);let e=Oe(c);if(!e.ok){g(e.problem);return}g(null),C.mutate(e.model,{onSuccess:()=>{b(!0),r(e.model.id)},onError:e=>g(_(e))})},children:C.isPending?`Saving…`:e===null?`Create model`:`Save changes`})]}),children:R(l,{$gap:3,children:[L(N,{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=>L(j,{...t,value:c.id,disabled:e!==null,placeholder:`fast`,onChange:e=>d({...c,id:e.target.value})})}),L(N,{label:`Routing strategy`,children:e=>L(A,{...e,value:c.strategy,onChange:e=>d({...c,strategy:e.target.value}),children:G.map(e=>L(`option`,{value:e.id,children:e.label},e.id))})}),P===void 0?null:L(Fe,{children:P.blurb}),R(Re,{children:[L(O,{checked:c.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>d({...c,isAlias:e})}),R(l,{$gap:0,children:[L(p,{as:`span`,children:`Alias`}),L(Fe,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),R(l,{$gap:2,children:[R(h,{children:[L(p,{children:`Targets`}),L(f,{}),R(u,{type:`button`,$size:`sm`,onClick:()=>d({...c,targets:[...c.targets,Te(a,c.targets.at(-1)?.provider)]}),children:[L(E,{}),`Add target`]})]}),c.targets.map((e,t)=>L(Pe,{target:e,index:t,removable:c.targets.length>1,catalog:a,endpoints:k,held:ee,credentials:D.data??[],onChange:t=>d({...c,targets:c.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>d({...c,targets:c.targets.filter(t=>t.key!==e.key)})},e.key))]}),m===null?null:L(Ie,{role:`alert`,children:m}),v&&m===null?L(Le,{role:`status`,children:`Saved.`}):null]})}),L(w,{open:x,onOpenChange:S,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:T.isPending,onConfirm:()=>{e!==null&&T.mutate(e.id,{onSuccess:()=>{S(!1),i()},onError:e=>{S(!1),g(_(e))}})}})]})}var Be=z.div`
|
|
103
|
-
display: grid;
|
|
104
|
-
grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
|
|
105
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
106
|
-
align-items: start;
|
|
107
|
-
|
|
108
|
-
@media (max-width: 980px) {
|
|
109
|
-
grid-template-columns: minmax(0, 1fr);
|
|
110
|
-
}
|
|
111
|
-
`,Ve=z(l)`
|
|
112
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
113
|
-
min-width: 0;
|
|
114
|
-
`,He=z.button`
|
|
115
|
-
display: flex;
|
|
116
|
-
flex-direction: column;
|
|
117
|
-
gap: 4px;
|
|
118
|
-
width: 100%;
|
|
119
|
-
padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
|
|
120
|
-
text-align: left;
|
|
121
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:`transparent`};
|
|
122
|
-
border: 0;
|
|
123
|
-
border-left: 2px solid
|
|
124
|
-
${({theme:e,$selected:t})=>t?e.color.accent:`transparent`};
|
|
125
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
|
|
128
|
-
&:hover {
|
|
129
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:e.color.panelSunk};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
&:last-child {
|
|
133
|
-
border-bottom: 0;
|
|
134
|
-
}
|
|
135
|
-
`,Ue=z(x)`
|
|
136
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
137
|
-
font-size: 12.5px;
|
|
138
|
-
display: block;
|
|
139
|
-
max-width: 100%;
|
|
140
|
-
`,We=z.div`
|
|
141
|
-
display: flex;
|
|
142
|
-
gap: 2px;
|
|
143
|
-
`,Ge=z.span`
|
|
144
|
-
width: 12px;
|
|
145
|
-
height: 3px;
|
|
146
|
-
border-radius: 1px;
|
|
147
|
-
background: ${({$provider:e})=>C(e)};
|
|
148
|
-
`,$=`\0new`;function Ke(){let e=r(),[t,n]=F(null),i=e.data??[],a=t===$?null:i.find(e=>e.id===t)??null,o=t===$||t===null&&!e.isLoading&&i.length===0;te(()=>{t===null&&i.length!==0&&n(i[0]?.id??null)},[i,t]);let s=e.isLoading?`Reading configured models…`:i.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${i.length} model${i.length===1?``:`s`} routing to ${i.reduce((e,t)=>e+t.targets.length,0)} targets.`;return R(I,{children:[L(T,{legend:`Models`,title:`Virtual models`,summary:s,actions:R(u,{type:`button`,$variant:`primary`,onClick:()=>n($),children:[L(E,{}),`New model`]})}),R(Be,{children:[L(y,{legend:`Configured`,meta:`${i.length}`,flush:!0,children:e.isError?L(g,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?L(`div`,{style:{padding:12},children:L(m,{rows:4})}):i.length===0?L(v,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:L(u,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>n($),children:`New model`})}):L(`div`,{children:i.map(e=>{let r=[...new Set(e.targets.map(e=>e.provider))];return R(He,{type:`button`,$selected:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:[R(h,{$gap:2,style:{width:`100%`},children:[L(Ue,{title:e.id,children:e.id}),L(f,{}),e.isAlias?L(k,{children:`alias`}):null]}),R(h,{$gap:2,style:{width:`100%`},children:[L(We,{children:r.map(e=>L(Ge,{$provider:e,title:e},e))}),L(p,{children:e.strategy}),L(f,{}),R(b,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),R(Ve,{children:[a===null&&!o?L(y,{legend:`Editor`,children:e.isLoading?L(m,{rows:5}):L(v,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):L(ze,{model:a,onSaved:t=>{n(t),e.refetch()},onDeleted:()=>{n(null),e.refetch()}}),L(he,{modelId:a?.id??null})]})]})]})}var qe=Ke;export{qe as component};
|