omnigateway 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/bin/omni.js +527 -228
  2. package/gateway.js +763 -401
  3. package/package.json +1 -1
  4. package/public/assets/{Chip-BB_5C1Zp.js → Chip-C4X8tf5z.js} +1 -1
  5. package/public/assets/Confirm-BnmH8Gn0.js +4 -0
  6. package/public/assets/{CopyValue-CRQDLo7k.js → CopyValue-B-uR4Js-.js} +5 -5
  7. package/public/assets/{Field-uHZxl4fI.js → Field-Ct4SeDZD.js} +2 -2
  8. package/public/assets/{Lamp-B-5SjXbG.js → Lamp-CBOwqG5K.js} +7 -7
  9. package/public/assets/{Meter-DI_BRUKt.js → Meter-COdz0dwY.js} +1 -1
  10. package/public/assets/{Modal-CI6jk2D4.js → Modal-DMFUHQ-A.js} +8 -8
  11. package/public/assets/{Rack-D1WJswv3.js → Rack-DAbY9x1I.js} +18 -18
  12. package/public/assets/{Readout-BocZ2HXP.js → Readout-Bl2kD9Tl.js} +6 -2
  13. package/public/assets/{States-Bbiu5cHE.js → States-D5Memn8D.js} +4 -4
  14. package/public/assets/{Table-CdPWxYaz.js → Table-DObRatbW.js} +1 -1
  15. package/public/assets/{Toggle-CiLC67Dw.js → Toggle-Dkjlvck5.js} +1 -1
  16. package/public/assets/{TokenBreakdown-B96iPBm9.js → TokenBreakdown-oXP49ZTa.js} +5 -2
  17. package/public/assets/_app-Brc2wQZm.js +1 -0
  18. package/public/assets/_app.accounts-I9RXUiyi.js +54 -0
  19. package/public/assets/{_app.console-Daz4aKhf.js → _app.console-BVVpryIB.js} +10 -10
  20. package/public/assets/_app.index-83Ig4FUL.js +62 -0
  21. package/public/assets/_app.keys-KeP6L4g_.js +39 -0
  22. package/public/assets/_app.logs-B5oh01Ls.js +32 -0
  23. package/public/assets/_app.models-BuOFMZUN.js +144 -0
  24. package/public/assets/{_app.settings-a0FKyQAi.js → _app.settings-BN436vI2.js} +4 -4
  25. package/public/assets/_app.usage-C528VOia.js +166 -0
  26. package/public/assets/catalog-kJ53n_fc.js +1 -0
  27. package/public/assets/{dist-C-IbPRiV.js → dist-CnzT-Ut2.js} +1 -1
  28. package/public/assets/index-CE-KQ-ju.js +172 -0
  29. package/public/assets/{login-CTvH_KAd.js → login-2LpCZOtB.js} +8 -8
  30. package/public/assets/{queries-D2o-X8Pj.js → queries-1zRLkX-Q.js} +27 -27
  31. package/public/assets/{trash-2-BcZb-sCT.js → trash-2-Da6cLgPn.js} +1 -1
  32. package/public/index.html +2 -2
  33. package/public/assets/Confirm-B6aAiVbT.js +0 -4
  34. package/public/assets/_app-BBOF6A0T.js +0 -1
  35. package/public/assets/_app.accounts-BNkhpvaB.js +0 -54
  36. package/public/assets/_app.index-LO6d38oe.js +0 -62
  37. package/public/assets/_app.keys-kBqLqoFf.js +0 -39
  38. package/public/assets/_app.logs-_wYNS47N.js +0 -32
  39. package/public/assets/_app.models-Cjng8ohC.js +0 -144
  40. package/public/assets/_app.usage-D3KtgLrC.js +0 -166
  41. package/public/assets/catalog-C_OQ0icG.js +0 -1
  42. package/public/assets/index-PW6EvVh5.js +0 -170
@@ -0,0 +1,54 @@
1
+ import{D as e,F as t,H as n,I as r,K as i,M as a,Nt as o,Pt as s,Qt as c,R as l,V as u,d,f,l as p,o as m,p as h,r as g,s as _,w as v}from"./queries-1zRLkX-Q.js";import{a as y,f as b,h as x,t as S,u as C}from"./Rack-DAbY9x1I.js";import{t as w}from"./CopyValue-B-uR4Js-.js";import{n as T,t as E}from"./Confirm-BnmH8Gn0.js";import{t as D}from"./trash-2-Da6cLgPn.js";import{t as O}from"./Modal-DMFUHQ-A.js";import{t as k}from"./Toggle-Dkjlvck5.js";import{a as A,d as j,i as M,n as N,t as P,u as F}from"./Lamp-CBOwqG5K.js";import{t as I}from"./Chip-C4X8tf5z.js";import{i as L,n as R,r as z,t as B}from"./Field-Ct4SeDZD.js";import{t as V}from"./Meter-COdz0dwY.js";import{a as H,i as U,n as ee,r as te,t as ne}from"./States-D5Memn8D.js";import{i as re,n as W,r as G,t as ie}from"./Table-DObRatbW.js";import{t as ae}from"./catalog-kJ53n_fc.js";var oe=x(`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`}]]),K=c(s(),1),q=o(),se=Object.keys(ae),J={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,custom:`OpenAI Compatible`},Y={anthropic:`Authorize in the browser, then paste the code Anthropic shows you.`,openai:`Authorize in the browser. When it redirects to localhost, paste the whole URL.`,kimi:`Enter the code on Kimi's device page. This dialog finishes on its own.`,custom:`Enter endpoint metadata and API key.`},ce=i.ol`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: ${({theme:e})=>e.space(3)};
5
+ `,le=i.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
+ `,X=i.p`
15
+ font-size: 12px;
16
+ color: ${({theme:e})=>e.color.down};
17
+ `,ue=i.p`
18
+ font-size: 12px;
19
+ color: ${({theme:e})=>e.color.inkDim};
20
+ `;function de({open:e,credentials:n,onOpenChange:r,onConnected:i}){let[o,s]=(0,K.useState)(`anthropic`),[c,d]=(0,K.useState)(``),[f,h]=(0,K.useState)(null),[v,y]=(0,K.useState)(``),[b,x]=(0,K.useState)(``),S=(n??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[C,T]=(0,K.useState)(``),[E,D]=(0,K.useState)(``),[k,A]=(0,K.useState)(`chat_completions`),[j,M]=(0,K.useState)(``),[N,P]=(0,K.useState)(null),F=_(),I=m(),z=p(),V=(0,K.useCallback)(()=>{h(null),y(``),x(``),T(``),D(``),A(`chat_completions`),M(``),P(null),d(``),F.reset(),I.reset(),z.reset()},[F,I,z]),H=(0,K.useCallback)(e=>{e||V(),r(e)},[r,V]);return(0,K.useEffect)(()=>{if(f===null||f.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await g(f.flowId);if(e)return;if(t.status===`complete`){V(),r(!1),i();return}}catch(t){if(e)return;P(U(t)),h(null);return}e||(n=setTimeout(()=>void t(),f.pollIntervalMs))},n=setTimeout(()=>void t(),f.pollIntervalMs);return()=>{e=!0,clearTimeout(n)}},[f,i,r,V]),(0,q.jsx)(O,{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:f===null?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(u,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),(0,q.jsx)(u,{type:`button`,$variant:`primary`,disabled:F.isPending||z.isPending,onClick:()=>{if(P(null),o===`custom`){z.mutate({provider:o,apiKey:j,endpointId:b,endpointLabel:C,origin:E,protocol:k,label:c.trim()||void 0},{onSuccess:()=>{V(),r(!1),i()},onError:e=>P(U(e))});return}F.mutate({provider:o,label:c.trim().length===0?J[o]:c.trim()},{onSuccess:e=>h(e),onError:e=>P(U(e))})},children:o===`custom`?z.isPending?`Adding…`:`Add API key`:F.isPending?`Starting…`:`Start authorization`})]}):f.kind===`device`?(0,q.jsx)(u,{type:`button`,onClick:()=>H(!1),children:`Cancel`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(u,{type:`button`,onClick:()=>H(!1),children:`Cancel`}),(0,q.jsx)(u,{type:`button`,$variant:`primary`,disabled:I.isPending||v.trim().length===0,onClick:()=>{f!==null&&(P(null),I.mutate({flowId:f.flowId,code:v.trim()},{onSuccess:()=>{V(),r(!1),i()},onError:e=>P(U(e))}))},children:I.isPending?`Finishing…`:`Finish connecting`})]}),children:(0,q.jsxs)(ce,{children:[f===null?(0,q.jsxs)(l,{$gap:3,children:[(0,q.jsx)(B,{label:`Provider`,children:e=>(0,q.jsx)(L,{...e,value:o,onChange:e=>s(e.target.value),children:se.map(e=>(0,q.jsx)(`option`,{value:e,children:J[e]},e))})}),o===`custom`?(0,q.jsxs)(q.Fragment,{children:[S.length===0?null:(0,q.jsx)(B,{label:`Existing endpoint`,children:e=>(0,q.jsxs)(L,{...e,value:b,onChange:e=>{let t=S.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){x(``),T(``),D(``),A(`chat_completions`);return}x(String(t.providerData.endpointId)),T(String(t.providerData.endpointLabel)),D(String(t.providerData.origin)),A(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[(0,q.jsx)(`option`,{value:``,children:`Create new endpoint`}),S.map(e=>(0,q.jsx)(`option`,{value:String(e.providerData.endpointId),children:String(e.providerData.endpointLabel)},String(e.providerData.endpointId)))]})}),(0,q.jsx)(B,{label:`Endpoint ID`,children:e=>(0,q.jsx)(R,{...e,value:b,onChange:e=>x(e.target.value)})}),(0,q.jsx)(B,{label:`Endpoint label`,children:e=>(0,q.jsx)(R,{...e,value:C,onChange:e=>T(e.target.value)})}),(0,q.jsx)(B,{label:`Server origin`,children:e=>(0,q.jsx)(R,{...e,value:E,placeholder:`https://server.example`,onChange:e=>D(e.target.value)})}),E.trim().toLowerCase().startsWith(`http://`)?(0,q.jsx)(X,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,(0,q.jsx)(B,{label:`Protocol`,children:e=>(0,q.jsxs)(L,{...e,value:k,onChange:e=>A(e.target.value),children:[(0,q.jsx)(`option`,{value:`chat_completions`,children:`Chat Completions (/v1/chat/completions)`}),(0,q.jsx)(`option`,{value:`responses`,children:`Responses (/v1/responses)`})]})}),(0,q.jsx)(B,{label:`API key`,children:e=>(0,q.jsx)(R,{...e,type:`password`,value:j,autoComplete:`off`,onChange:e=>M(e.target.value)})})]}):null,(0,q.jsx)(B,{label:`Label`,hint:`How this account is named in the rack. Defaults to the provider.`,children:e=>(0,q.jsx)(R,{...e,value:c,placeholder:J[o],onChange:e=>d(e.target.value)})})]}):(0,q.jsxs)(l,{$gap:3,children:[(0,q.jsxs)(l,{$gap:1,children:[(0,q.jsx)(a,{children:`Step 1 — authorize`}),(0,q.jsx)(t,{$gap:2,children:(0,q.jsxs)(u,{as:`a`,href:f.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[(0,q.jsx)(oe,{}),`Open `,J[o]]})}),(0,q.jsx)(w,{value:f.authorizeUrl,label:`Copy authorization link`})]}),f.userCode===null?null:(0,q.jsxs)(l,{$gap:1,children:[(0,q.jsx)(a,{children:`Step 2 — enter this code`}),(0,q.jsx)(le,{children:f.userCode})]}),f.kind===`device`?(0,q.jsxs)(ue,{children:[Y[o],` Waiting for authorization…`]}):(0,q.jsx)(B,{label:`Authorization code`,hint:Y[o],...N===null?{}:{problem:N},children:e=>(0,q.jsx)(R,{...e,value:v,autoFocus:!0,placeholder:o===`openai`?`http://localhost:1455/auth/callback?code=…`:`code#state`,onChange:e=>y(e.target.value)})})]}),N===null||f?.kind===`pkce`?null:(0,q.jsx)(X,{children:N})]})})}var fe=[`anthropic`,`openai`,`kimi`,`custom`],Z={anthropic:`Anthropic`,openai:`OpenAI`,kimi:`Kimi`,custom:`OpenAI Compatible`},Q=i(H)`
21
+ border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
22
+ `,pe=i(R)`
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
+ `,$=i(z)`
37
+ width: 62px;
38
+ height: 26px;
39
+ `,me=i.span`
40
+ display: block;
41
+ padding-left: 9px;
42
+ font-size: 11px;
43
+ color: ${({theme:e})=>e.color.inkDim};
44
+ `,he=i.div`
45
+ display: grid;
46
+ grid-template-columns: 96px 1fr;
47
+ align-items: center;
48
+ min-width: 208px;
49
+ gap: 6px;
50
+ `,ge=i.div`
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 4px;
54
+ `;function _e(){let t=e();return{pending:t.isPending,commit:(e,n)=>{t.mutate({id:e,patch:n})}}}function ve(){let{cadence:e}=y(),i=f(),o=d(e(1e4)),s=v(),c=h(),{commit:p}=_e(),[m,g]=(0,K.useState)(!1),[_,x]=(0,K.useState)(null),w=Date.now(),O=i.data??[],L=A(o.data?.health??[],e=>e.credentialId),R=A(o.data?.quota??[],e=>e.credentialId),z=s.data?.quotaPollIntervalMs??3e5,B=O.filter(e=>e.enabled).length,U=i.isLoading?`Reading connected accounts…`:O.length===0?`No provider credentials are connected, so every request fails at the router.`:`${B} of ${O.length} accounts are enabled and eligible for routing.`;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(S,{legend:`Accounts`,title:`Provider accounts`,summary:U,actions:(0,q.jsxs)(u,{type:`button`,$variant:`primary`,onClick:()=>g(!0),children:[(0,q.jsx)(T,{}),`Connect an account`]})}),i.isError?(0,q.jsx)(H,{legend:`Accounts`,children:(0,q.jsx)(ee,{error:i.error,onRetry:()=>void i.refetch()})}):i.isLoading?(0,q.jsx)(H,{legend:`Accounts`,children:(0,q.jsx)(te,{rows:5})}):O.length===0?(0,q.jsx)(H,{legend:`Accounts`,children:(0,q.jsx)(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:(0,q.jsx)(u,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>g(!0),children:`Connect an account`})})}):(0,q.jsx)(l,{$gap:4,children:fe.filter(e=>O.some(t=>t.provider===e)).map(e=>{let i=O.filter(t=>t.provider===e);return(0,q.jsx)(Q,{$provider:e,legend:Z[e],meta:`${i.length} account${i.length===1?``:`s`}`,flush:!0,children:(0,q.jsx)(r,{children:(0,q.jsxs)(ie,{children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(G,{$width:`24%`,children:`Account`}),(0,q.jsx)(G,{$width:`20%`,children:`Sign-in`}),(0,q.jsx)(G,{$align:`right`,$width:`86px`,children:`Tier`}),(0,q.jsx)(G,{$align:`right`,$width:`94px`,children:`Weight`}),(0,q.jsx)(G,{$align:`center`,$width:`86px`,children:`Enabled`}),(0,q.jsx)(G,{$width:`240px`,children:`Quota`}),(0,q.jsx)(G,{$align:`right`,$width:`88px`,children:`TTFT`}),(0,q.jsx)(G,{$align:`right`,$width:`130px`,children:`Token expires`}),(0,q.jsx)(G,{$width:`48px`})]})}),(0,q.jsx)(`tbody`,{children:i.map(e=>{let r=M(L.get(e.id)??[],w,e.enabled,e.disabledReason),i=j(R.get(e.id)??[]);return(0,q.jsxs)(re,{children:[(0,q.jsxs)(W,{children:[(0,q.jsxs)(t,{$gap:2,children:[(0,q.jsx)(P,{state:r.state,label:r.note===``?`healthy`:r.note}),(0,q.jsx)(pe,{defaultValue:e.label,"aria-label":`Label for ${e.label}`,onBlur:t=>{let n=t.target.value.trim();if(n.length===0||n===e.label){t.target.value=e.label;return}p(e.id,{label:n})}})]}),r.note===``?null:(0,q.jsx)(me,{children:r.note})]}),(0,q.jsx)(W,{children:(0,q.jsxs)(t,{$gap:1,children:[(0,q.jsx)(I,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:(0,q.jsx)(a,{children:e.accountEmail})]})}),(0,q.jsx)(W,{$align:`right`,children:(0,q.jsx)($,{min:1,step:1,defaultValue:e.tier,"aria-label":`Tier for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isInteger(n)||n<1||n===e.tier){t.target.value=String(e.tier);return}p(e.id,{tier:n})}})}),(0,q.jsx)(W,{$align:`right`,children:(0,q.jsx)($,{min:.1,step:.1,defaultValue:e.weight,"aria-label":`Weight for ${e.label}`,onBlur:t=>{let n=Number(t.target.value);if(!Number.isFinite(n)||n<=0||n===e.weight){t.target.value=String(e.weight);return}p(e.id,{weight:n})}})}),(0,q.jsx)(W,{$align:`center`,children:(0,q.jsx)(k,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>p(e.id,{enabled:t})})}),(0,q.jsx)(W,{children:i.length===0?(0,q.jsx)(a,{children:`unknown`}):(0,q.jsx)(ge,{children:i.map(({window:e,fraction:t})=>(0,q.jsxs)(he,{children:[(0,q.jsx)(V,{fraction:t,label:`${N[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,q.jsx)(a,{children:F(e,w,z,b)})]},e.windowType))})}),(0,q.jsx)(W,{$align:`right`,$mono:!0,children:C(r.ttftMs)}),(0,q.jsx)(W,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:b(e.expiresAt,w)}),(0,q.jsx)(W,{$align:`right`,children:(0,q.jsx)(n,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>x(e),children:(0,q.jsx)(D,{})})})]},e.id)})})]})})},e)})}),(0,q.jsx)(de,{open:m,credentials:i.data??[],onOpenChange:g,onConnected:()=>void i.refetch()}),(0,q.jsx)(E,{open:_!==null,onOpenChange:e=>{e||x(null)},title:`Remove account`,body:_===null?``:`Removing "${_.label}" deletes its stored token. Any model target pointing at ${Z[_.provider]} loses this account, and reconnecting means authorizing again.`,confirmLabel:`Remove account`,busy:c.isPending,onConfirm:()=>{_!==null&&c.mutate(_.id,{onSettled:()=>x(null)})}})]})}var ye=ve;export{ye as component};
@@ -1,15 +1,15 @@
1
- import{G as e,Mt as t,N as n,Nt as r,P as i,Zt as a,c as o,t as s}from"./queries-D2o-X8Pj.js";import{a as c,s as l,t as u}from"./Rack-D1WJswv3.js";import{i as d}from"./Field-uHZxl4fI.js";import{a as f,n as p,r as m,t as h}from"./States-Bbiu5cHE.js";var g=a(r(),1),_=t(),v=[100,200,500],y=[{value:``,label:`All levels`},{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warnings and errors`},{value:`error`,label:`Errors only`}],b=e(i)`
1
+ import{F as e,K as t,Nt as n,P as r,Pt as i,Qt as a,c as o,t as s}from"./queries-1zRLkX-Q.js";import{a as c,s as l,t as u}from"./Rack-DAbY9x1I.js";import{i as d}from"./Field-Ct4SeDZD.js";import{a as f,n as p,r as m,t as h}from"./States-D5Memn8D.js";var g=a(i(),1),_=n(),v=[100,200,500],y=[{value:``,label:`All levels`},{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warnings and errors`},{value:`error`,label:`Errors only`}],b=t(e)`
2
2
  gap: ${({theme:e})=>e.space(2)};
3
3
  flex-wrap: wrap;
4
- `,x=e(d)`
4
+ `,x=t(d)`
5
5
  width: auto;
6
- `,S=e.div`
6
+ `,S=t.div`
7
7
  display: grid;
8
8
  grid-template-rows: auto minmax(0, 1fr);
9
9
  gap: ${({theme:e})=>e.space(4)};
10
10
  min-height: 0;
11
11
  flex: 1;
12
- `,C=e(f)`
12
+ `,C=t(f)`
13
13
  min-height: 0;
14
14
 
15
15
  > div {
@@ -18,27 +18,27 @@ import{G as e,Mt as t,N as n,Nt as r,P as i,Zt as a,c as o,t as s}from"./queries
18
18
  flex-direction: column;
19
19
  min-height: 0;
20
20
  }
21
- `,w=e.div`
21
+ `,w=t.div`
22
22
  flex: 1;
23
23
  min-height: 0;
24
24
  overflow-x: auto;
25
25
  overflow-y: auto;
26
- `,T=e.pre`
26
+ `,T=t.pre`
27
27
  margin: 0;
28
28
  padding: ${({theme:e})=>e.space(3)};
29
29
  font-family: ${({theme:e})=>e.font.mono};
30
30
  font-size: 12px;
31
31
  line-height: 1.65;
32
32
  white-space: pre;
33
- `,E=e.div`
33
+ `,E=t.div`
34
34
  color: ${({theme:e,$level:t})=>t===`error`?e.color.down:t===`warn`?e.color.warn:t===`debug`?e.color.inkFaint:e.color.ink};
35
- `,D=e.p`
35
+ `,D=t.p`
36
36
  margin: 0;
37
37
  padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
38
38
  border-top: 1px solid ${({theme:e})=>e.color.rule};
39
39
  color: ${({theme:e})=>e.color.inkDim};
40
40
  font-size: 12px;
41
- `,O=e.code`
41
+ `,O=t.code`
42
42
  font-family: ${({theme:e})=>e.font.mono};
43
43
  word-break: break-all;
44
- `;function k({read:e}){return e.source===`file`?(0,_.jsxs)(D,{children:[`Reading `,(0,_.jsx)(O,{children:e.path}),`, named by `,(0,_.jsx)(O,{children:`OMNI_LOG_FILE`}),`. That variable says where the gateway's output is being captured; it does not redirect it.`]}):e.source===`journal`?(0,_.jsxs)(D,{children:[`Reading the systemd journal for `,(0,_.jsx)(O,{children:`omnigateway.service`}),`. To read a file instead, redirect the gateway's output to one and point `,(0,_.jsx)(O,{children:`OMNI_LOG_FILE`}),` at the same path.`]}):null}function A(){let{cadence:e}=c(),[t,r]=(0,g.useState)(200),[i,a]=(0,g.useState)(``),d=o(t,i,e(s)),f=d.data,D=f?.lines??[],O=(0,g.useRef)(null),A=(0,g.useRef)(!0);return(0,g.useLayoutEffect)(()=>{let e=O.current;e!==null&&A.current&&f!==void 0&&(e.scrollTop=e.scrollHeight)},[f]),(0,_.jsxs)(S,{children:[(0,_.jsx)(u,{legend:`Console`,title:`Gateway output`,summary:d.isLoading?`Reading the gateway's own output…`:`${l(D.length)} lines of what this process is doing. Requests are in Logs; prompt bodies, tokens and keys are never written here.`,actions:(0,_.jsxs)(b,{children:[(0,_.jsx)(x,{value:i,"aria-label":`Which levels to show`,onChange:e=>a(e.target.value),children:y.map(e=>(0,_.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,_.jsx)(x,{value:t,"aria-label":`How many lines to fetch`,onChange:e=>r(Number(e.target.value)),children:v.map(e=>(0,_.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,_.jsxs)(C,{legend:`Process output`,meta:f===void 0?void 0:(0,_.jsx)(n,{children:j(f)}),flush:!0,children:[f===void 0?null:(0,_.jsx)(k,{read:f}),(0,_.jsx)(w,{ref:O,"data-testid":`console-terminal`,onScroll:e=>{let t=e.currentTarget;A.current=t.scrollHeight-t.scrollTop-t.clientHeight<=8},children:d.isError?(0,_.jsx)(p,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?(0,_.jsx)(`div`,{style:{padding:12},children:(0,_.jsx)(m,{rows:10})}):f!==void 0&&f.source===`none`?(0,_.jsx)(h,{legend:`Nothing is capturing this gateway`,message:"Its output is going to a terminal, so there is nothing to read back. To capture it, run the gateway under systemd with `omni service install`, or start it with `omni start`, which redirects output to a file and points OMNI_LOG_FILE at it."}):D.length===0?(0,_.jsx)(h,{legend:`Nothing to show`,message:i===``?`This log is empty. The gateway writes here when it boots, refreshes a token, or polls a quota.`:`No line in this window is at that level. Widen the filter to see everything.`}):(0,_.jsx)(T,{children:D.map((e,t)=>(0,_.jsx)(E,{$level:e.level,children:e.raw},`${e.at??0}-${t}`))})})]})]})}function j(e){return e.source===`file`?`log file`:e.source===`journal`?`systemd journal`:`not captured`}var M=A;export{M as component};
44
+ `;function k({read:e}){return e.source===`file`?(0,_.jsxs)(D,{children:[`Reading `,(0,_.jsx)(O,{children:e.path}),`, named by `,(0,_.jsx)(O,{children:`OMNI_LOG_FILE`}),`. That variable says where the gateway's output is being captured; it does not redirect it.`]}):e.source===`journal`?(0,_.jsxs)(D,{children:[`Reading the systemd journal for `,(0,_.jsx)(O,{children:`omnigateway.service`}),`. To read a file instead, redirect the gateway's output to one and point `,(0,_.jsx)(O,{children:`OMNI_LOG_FILE`}),` at the same path.`]}):null}function A(){let{cadence:e}=c(),[t,n]=(0,g.useState)(200),[i,a]=(0,g.useState)(``),d=o(t,i,e(s)),f=d.data,D=f?.lines??[],O=(0,g.useRef)(null),A=(0,g.useRef)(!0);return(0,g.useLayoutEffect)(()=>{let e=O.current;e!==null&&A.current&&f!==void 0&&(e.scrollTop=e.scrollHeight)},[f]),(0,_.jsxs)(S,{children:[(0,_.jsx)(u,{legend:`Console`,title:`Gateway output`,summary:d.isLoading?`Reading the gateway's own output…`:`${l(D.length)} lines of what this process is doing. Requests are in Logs; prompt bodies, tokens and keys are never written here.`,actions:(0,_.jsxs)(b,{children:[(0,_.jsx)(x,{value:i,"aria-label":`Which levels to show`,onChange:e=>a(e.target.value),children:y.map(e=>(0,_.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,_.jsx)(x,{value:t,"aria-label":`How many lines to fetch`,onChange:e=>n(Number(e.target.value)),children:v.map(e=>(0,_.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,_.jsxs)(C,{legend:`Process output`,meta:f===void 0?void 0:(0,_.jsx)(r,{children:j(f)}),flush:!0,children:[f===void 0?null:(0,_.jsx)(k,{read:f}),(0,_.jsx)(w,{ref:O,"data-testid":`console-terminal`,onScroll:e=>{let t=e.currentTarget;A.current=t.scrollHeight-t.scrollTop-t.clientHeight<=8},children:d.isError?(0,_.jsx)(p,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?(0,_.jsx)(`div`,{style:{padding:12},children:(0,_.jsx)(m,{rows:10})}):f!==void 0&&f.source===`none`?(0,_.jsx)(h,{legend:`Nothing is capturing this gateway`,message:"Its output is going to a terminal, so there is nothing to read back. To capture it, run the gateway under systemd with `omni service install`, or start it with `omni start`, which redirects output to a file and points OMNI_LOG_FILE at it."}):D.length===0?(0,_.jsx)(h,{legend:`Nothing to show`,message:i===``?`This log is empty. The gateway writes here when it boots, refreshes a token, or polls a quota.`:`No line in this window is at that level. Widen the filter to see everything.`}):(0,_.jsx)(T,{children:D.map((e,t)=>(0,_.jsx)(E,{$level:e.level,children:e.raw},`${e.at??0}-${t}`))})})]})]})}function j(e){return e.source===`file`?`log file`:e.source===`journal`?`systemd journal`:`not captured`}var M=A;export{M as component};
@@ -0,0 +1,62 @@
1
+ import{F as e,I as t,J as n,K as r,L as i,M as a,N as o,Nt as s,O as c,R as l,V as u,b as d,d as f,f as p,j as m,w as h,y as g,z as _}from"./queries-1zRLkX-Q.js";import{a as v,d as y,f as b,o as x,p as S,r as C,s as w,t as T,u as E}from"./Rack-DAbY9x1I.js";import{n as D,t as O}from"./TokenBreakdown-oXP49ZTa.js";import{a as k,c as A,d as j,f as M,i as N,l as P,n as F,r as ee,s as te,t as I,u as L}from"./Lamp-CBOwqG5K.js";import{n as R,t as z}from"./Chip-C4X8tf5z.js";import{t as B}from"./Meter-COdz0dwY.js";import{a as V,n as H,t as U}from"./States-D5Memn8D.js";import{i as W,n as G,r as K,t as q}from"./Table-DObRatbW.js";import{t as J}from"./Readout-Bl2kD9Tl.js";var Y=s(),X=r(_)`
2
+ font-weight: 500;
3
+ display: block;
4
+ max-width: 24ch;
5
+ `,Z=r.span`
6
+ font-size: 11px;
7
+ color: ${({theme:e})=>e.color.inkDim};
8
+ `,ne=r.div`
9
+ display: grid;
10
+ grid-template-columns: 72px 1fr;
11
+ align-items: center;
12
+ gap: 6px;
13
+ min-width: 172px;
14
+ `,re=r.div`
15
+ display: flex;
16
+ flex-direction: column;
17
+ gap: 4px;
18
+ `;function ie({credentials:r,health:i,quota:o,usage:s,quotaPollIntervalMs:c,now:l}){let d=k(i,e=>e.credentialId),f=k(o,e=>e.credentialId),p=new Map(s.map(e=>[e.key,e])),m={down:0,warn:1,ok:2,idle:3,live:3},h=r.map(e=>({credential:e,status:N(d.get(e.id)??[],l,e.enabled,e.disabledReason),quota:j(f.get(e.id)??[]),usage:p.get(e.id)})).sort((e,t)=>m[e.status.state]-m[t.status.state]||e.credential.tier-t.credential.tier);return(0,Y.jsx)(V,{legend:`Accounts`,meta:`${r.length} connected`,flush:!0,actions:(0,Y.jsx)(u,{as:n,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:r.length===0?(0,Y.jsx)(U,{legend:`No accounts`,message:`The gateway has no provider credentials, so every request will fail. Connect one to start routing.`,action:(0,Y.jsx)(u,{as:n,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):(0,Y.jsx)(t,{children:(0,Y.jsxs)(q,{children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(K,{children:`Account`}),(0,Y.jsx)(K,{children:`Provider`}),(0,Y.jsx)(K,{$align:`right`,children:`Tier`}),(0,Y.jsx)(K,{children:`Quota`}),(0,Y.jsx)(K,{$align:`right`,children:`TTFT`}),(0,Y.jsx)(K,{$align:`right`,children:`Requests`}),(0,Y.jsx)(K,{$align:`right`,children:`Last used`})]})}),(0,Y.jsx)(`tbody`,{children:h.map(({credential:t,status:n,quota:r,usage:i})=>(0,Y.jsxs)(W,{children:[(0,Y.jsx)(G,{children:(0,Y.jsxs)(e,{$gap:2,children:[(0,Y.jsx)(I,{state:n.state,label:n.note===``?`healthy`:n.note}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(X,{children:t.label}),n.note===``?null:(0,Y.jsx)(Z,{children:n.note})]})]})}),(0,Y.jsx)(G,{children:(0,Y.jsx)(R,{provider:t.provider})}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:t.tier}),(0,Y.jsx)(G,{children:r.length===0?(0,Y.jsx)(Z,{children:`unknown`}):(0,Y.jsx)(re,{children:r.map(({window:e,fraction:t})=>(0,Y.jsxs)(ne,{children:[(0,Y.jsx)(B,{fraction:t,label:`${F[e.windowType]} window, ${Math.round(t*100)}% used`}),(0,Y.jsx)(a,{children:L(e,l,c,b)})]},e.windowType))})}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:E(n.ttftMs)}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:i===void 0?`—`:w(i.requests)}),(0,Y.jsx)(G,{$align:`right`,$mono:!0,children:b(n.lastUsedAt,l)})]},t.id))})]})})})}var ae=r.ul`
19
+ display: flex;
20
+ flex-direction: column;
21
+ `,oe=r.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
+ `,se=r(_)`
32
+ font-family: ${({theme:e})=>e.font.mono};
33
+ font-size: 12px;
34
+ max-width: 30ch;
35
+ `,ce=r(o)`
36
+ color: ${({theme:e})=>e.color.down};
37
+ font-size: 11px;
38
+ `;function le({logs:e}){let t=e.slice(0,12);return(0,Y.jsx)(V,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:(0,Y.jsx)(u,{as:n,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.length===0?(0,Y.jsx)(U,{legend:`No traffic yet`,message:`Point a client at this gateway with an API key and the requests will appear here.`}):(0,Y.jsx)(ae,{children:t.map(e=>(0,Y.jsxs)(oe,{children:[(0,Y.jsx)(I,{state:P(e),label:A(e)}),(0,Y.jsx)(o,{$dim:!0,children:x(e.at)}),(0,Y.jsx)(se,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:(0,Y.jsx)(o,{$dim:!0,style:{color:`var(--p-${e.resolvedProvider})`},children:e.resolvedProvider}),(0,Y.jsx)(i,{}),te(e)?(0,Y.jsx)(o,{$dim:!0,"aria-label":`processing`,children:(0,Y.jsx)(O,{})}):(0,Y.jsxs)(Y.Fragment,{children:[e.errorCode===null?null:(0,Y.jsx)(ce,{children:e.errorCode}),e.attempts>1?(0,Y.jsxs)(o,{$dim:!0,children:[e.attempts,`×`]}):null,(0,Y.jsx)(o,{$dim:!0,children:(0,Y.jsx)(D,{tokens:e})}),(0,Y.jsx)(o,{$dim:!0,children:E(e.durationMs)}),(0,Y.jsx)(o,{$dim:!0,children:S(e.costUsd)})]})]},e.id))})})}var ue=r.ul`
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: ${({theme:e})=>e.space(3)};
42
+ `,de=r(_)`
43
+ font-family: ${({theme:e})=>e.font.mono};
44
+ font-size: 12.5px;
45
+ `,fe=r.div`
46
+ display: flex;
47
+ height: 5px;
48
+ border-radius: 2px;
49
+ overflow: hidden;
50
+ background: ${({theme:e})=>e.color.panelSunk};
51
+ border: 1px solid ${({theme:e})=>e.color.rule};
52
+ `,pe=r.div`
53
+ flex: ${({$grow:e})=>e} 0 0;
54
+ background: ${({$color:e})=>e};
55
+ opacity: 0.8;
56
+ `,me=r.div`
57
+ flex: ${({$grow:e})=>e} 0 0;
58
+ `;function Q({models:t,logs:r}){let s=new Map;for(let e of r){let t=s.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,s.set(e.requestedModel,t)}let c=Math.max(1,...[...s.values()].map(e=>e.requests)),l=[...t].map(e=>({model:e,used:s.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return(0,Y.jsx)(V,{legend:`Models`,meta:`${t.length} configured`,actions:(0,Y.jsx)(u,{as:n,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.length===0?(0,Y.jsx)(U,{legend:`No models`,message:`Nothing is routable yet. Create a virtual model and point it at one or more provider targets.`,action:(0,Y.jsx)(u,{as:n,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):(0,Y.jsx)(ue,{children:l.map(({model:t,used:n})=>{let r=(n?.requests??0)/c,s=[...new Set(t.targets.map(e=>e.provider))];return(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(e,{$gap:2,children:[(0,Y.jsx)(de,{title:t.id,children:t.id}),t.isAlias?(0,Y.jsx)(z,{children:`alias`}):null,(0,Y.jsx)(z,{$tone:`accent`,children:t.strategy}),(0,Y.jsx)(i,{}),(0,Y.jsx)(o,{$dim:!0,children:w(n?.requests??0)}),(0,Y.jsx)(a,{children:`req`}),(0,Y.jsx)(o,{$dim:!0,children:S(n?.costUsd??0)})]}),(0,Y.jsxs)(fe,{style:{marginTop:6},title:`${Math.round(r*100)}% of the busiest model`,children:[s.map(e=>(0,Y.jsx)(pe,{$color:`var(--p-${e})`,$grow:r/s.length},e)),(0,Y.jsx)(me,{$grow:Math.max(0,1-r)})]})]},t.id)})})})}var he=r.div`
59
+ display: grid;
60
+ grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
61
+ gap: ${({theme:e})=>e.space(3)};
62
+ `;function ge({logs:e,windowMs:t,now:n}){let r=e.filter(e=>n-e.at<=t),i=M(r,t),a=ee(r,{now:n,spanMs:t,count:32}),o=i.errorRate>=.25?`down`:i.errorRate>=.05?`warn`:`ok`,s=i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheWriteTokens;return(0,Y.jsxs)(he,{children:[(0,Y.jsx)(J,{legend:`Requests`,value:w(i.requests),unit:`${i.ratePerMin.toFixed(1)}/min`,trace:(0,Y.jsx)(C,{values:a.map(e=>e.total),overlay:a.map(e=>e.errors),label:`${i.requests} requests, ${i.errors} of them failed`})}),(0,Y.jsx)(J,{legend:`Error rate`,value:y(i.errorRate),unit:`${w(i.errors)} failed`,tone:i.requests===0?`ink`:o,trace:(0,Y.jsx)(C,{values:a.map(e=>e.errors),scaleTo:Math.max(...a.map(e=>e.total)),color:`var(--down)`,label:`${i.errors} failed requests against ${i.requests} total`})}),(0,Y.jsx)(J,{legend:`Total tokens`,value:w(s),unit:(0,Y.jsx)(D,{tokens:i}),trace:(0,Y.jsx)(C,{values:a.map(e=>e.tokens),label:`token volume over the window, ${s.toLocaleString(`en-US`)} total`})}),(0,Y.jsx)(J,{legend:`Time to first token`,value:E(i.ttftP50),unit:`p95 ${E(i.ttftP95)}`,trace:(0,Y.jsx)(C,{values:a.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${E(i.ttftP50)}`})}),(0,Y.jsx)(J,{legend:`Spend`,value:S(i.costUsd),unit:`${w(i.inputTokens+i.outputTokens)} tokens`,trace:(0,Y.jsx)(C,{values:a.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${S(i.costUsd)} total`})})]})}var $=36e5;function _e(){let{cadence:e}=v(),t=p(),n=f(e(1e4)),r=d(),i=g(500,e(1e4)),a=h(),o=Date.now(),s=Math.floor((o-$)/6e4)*6e4,u=c({groupBy:`credential`,since:s},e(6e4)),_=t.data??[],y=k(n.data?.health??[],e=>e.credentialId),b=_.filter(e=>N(y.get(e.id)??[],o,e.enabled,e.disabledReason).state===`down`),x=t.isLoading||i.isLoading?`Reading the gateway…`:_.length===0?`No accounts are connected, so every request fails at the router.`:b.length>0?`${b.length} account${b.length===1?` is`:`s are`} out of rotation.`:`All ${_.length} accounts are answering. Nothing needs attention.`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(T,{legend:`Rack`,title:`Gateway`,summary:x}),i.isError?(0,Y.jsx)(V,{legend:`Traffic`,children:(0,Y.jsx)(H,{legend:`The gateway did not answer`,error:i.error,onRetry:()=>void i.refetch()})}):(0,Y.jsxs)(l,{$gap:4,children:[(0,Y.jsx)(ge,{logs:i.data??[],windowMs:$,now:o}),(0,Y.jsx)(ie,{credentials:_,health:n.data?.health??[],quota:n.data?.quota??[],usage:u.data??[],quotaPollIntervalMs:a.data?.quotaPollIntervalMs??3e5,now:o}),(0,Y.jsxs)(m,{$min:`340px`,$gap:4,children:[(0,Y.jsx)(Q,{models:r.data??[],logs:i.data??[]}),(0,Y.jsx)(le,{logs:i.data??[]})]})]})]})}var ve=_e;export{ve as component};
@@ -0,0 +1,39 @@
1
+ import{F as e,I as t,K as n,M as r,N as i,Nt as a,Pt as o,Qt as s,R as c,V as l,b as u,g as d,u as f,x as p,z as m}from"./queries-1zRLkX-Q.js";import{c as h,t as g}from"./Rack-DAbY9x1I.js";import{t as _}from"./CopyValue-B-uR4Js-.js";import{n as v,t as y}from"./Confirm-BnmH8Gn0.js";import{t as b}from"./Modal-DMFUHQ-A.js";import{t as x}from"./Toggle-Dkjlvck5.js";import{t as S}from"./Chip-C4X8tf5z.js";import{n as C,t as w}from"./Field-Ct4SeDZD.js";import{a as T,i as E,n as D,r as O,t as k}from"./States-D5Memn8D.js";import{i as A,n as j,r as M,t as N}from"./Table-DObRatbW.js";var P=s(o(),1),F=a(),I=n.div`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 2px;
5
+ max-height: 190px;
6
+ overflow-y: auto;
7
+ padding: ${({theme:e})=>e.space(1)};
8
+ border: 1px solid ${({theme:e})=>e.color.ruleStrong};
9
+ border-radius: ${({theme:e})=>e.radius.control};
10
+ background: ${({theme:e})=>e.color.panelSunk};
11
+ `,L=n.label`
12
+ display: flex;
13
+ align-items: center;
14
+ gap: ${({theme:e})=>e.space(2)};
15
+ padding: 4px 6px;
16
+ border-radius: 2px;
17
+ cursor: pointer;
18
+ font-family: ${({theme:e})=>e.font.mono};
19
+ font-size: 12px;
20
+
21
+ &:hover {
22
+ background: ${({theme:e})=>e.color.panelRaised};
23
+ }
24
+ `,R=n.p`
25
+ font-size: 12px;
26
+ color: ${({theme:e})=>e.color.warn};
27
+ `,z=n.p`
28
+ font-size: 12px;
29
+ color: ${({theme:e})=>e.color.down};
30
+ `,B=n.p`
31
+ font-size: 12px;
32
+ color: ${({theme:e})=>e.color.inkDim};
33
+ `;function V({open:t,onOpenChange:n}){let a=u(),o=f(),[s,d]=(0,P.useState)(``),[p,m]=(0,P.useState)(!0),[h,g]=(0,P.useState)([]),[v,y]=(0,P.useState)(``),[S,T]=(0,P.useState)(null),[D,O]=(0,P.useState)(null),k=()=>{d(``),m(!0),g([]),y(``),T(null),O(null),o.reset()},A=e=>{e||k(),n(e)};return(0,F.jsx)(b,{open:t,onOpenChange:A,title:S===null?`Create an API key`:`Key created`,description:S===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:S===null?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(l,{type:`button`,onClick:()=>A(!1),children:`Cancel`}),(0,F.jsx)(l,{type:`button`,$variant:`primary`,disabled:o.isPending,onClick:()=>{let e=v.trim(),t=e.length===0?null:Number(e);if(t!==null&&(!Number.isInteger(t)||t<1)){O(`The rate limit must be a whole number of requests per minute, or blank for none.`);return}O(null),o.mutate({label:s.trim().length===0?`api key`:s.trim(),modelAllowlist:p?null:h,rateLimitPerMin:t},{onSuccess:e=>T(e),onError:e=>O(E(e))})},children:o.isPending?`Creating…`:`Create key`})]}):(0,F.jsx)(l,{type:`button`,$variant:`primary`,onClick:()=>A(!1),children:`I have copied the key`}),children:S===null?(0,F.jsxs)(c,{$gap:3,children:[(0,F.jsx)(w,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>(0,F.jsx)(C,{...e,value:s,placeholder:`api key`,onChange:e=>d(e.target.value)})}),(0,F.jsxs)(c,{$gap:2,children:[(0,F.jsxs)(e,{$gap:2,children:[(0,F.jsx)(x,{checked:p,label:`Allow every model`,onCheckedChange:m}),(0,F.jsx)(r,{as:`span`,children:`Allow every model`})]}),p?null:(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{children:(a.data??[]).map(e=>(0,F.jsxs)(L,{children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:h.includes(e.id),onChange:t=>g(n=>t.target.checked?[...n,e.id]:n.filter(t=>t!==e.id))}),e.id]},e.id))}),h.length===0?(0,F.jsx)(R,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),(0,F.jsx)(w,{label:`Rate limit`,hint:`Requests per minute for this key. Leave blank for no limit. Counted per process, and reset when the gateway restarts.`,children:e=>(0,F.jsx)(C,{...e,type:`number`,min:1,step:1,value:v,placeholder:`no limit`,onChange:e=>y(e.target.value)})}),D===null?null:(0,F.jsx)(z,{role:`alert`,children:D})]}):(0,F.jsxs)(c,{$gap:3,children:[(0,F.jsx)(B,{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.`}),(0,F.jsx)(_,{value:S.key,label:`Copy API key`}),(0,F.jsxs)(e,{$gap:2,children:[(0,F.jsx)(r,{children:`Label`}),(0,F.jsx)(i,{children:S.label}),(0,F.jsx)(r,{children:`Prefix`}),(0,F.jsx)(i,{children:S.prefix})]})]})})}var H=n(e)`
34
+ gap: 4px;
35
+ flex-wrap: wrap;
36
+ max-width: 34ch;
37
+ `,U=n.span`
38
+ color: ${({theme:e})=>e.color.inkFaint};
39
+ `;function W(){let e=d(),n=p(),[i,a]=(0,P.useState)(!1),[o,s]=(0,P.useState)(null),c=e.data??[],u=c.filter(e=>e.revokedAt===null),f=e.isLoading?`Reading issued keys…`:c.length===0?`No keys exist, so nothing can call this gateway yet.`:`${u.length} active key${u.length===1?``:`s`} of ${c.length} ever issued.`;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(g,{legend:`Keys`,title:`Gateway API keys`,summary:f,actions:(0,F.jsxs)(l,{type:`button`,$variant:`primary`,onClick:()=>a(!0),children:[(0,F.jsx)(v,{}),`Create a key`]})}),(0,F.jsx)(T,{legend:`Issued keys`,meta:`${c.length}`,flush:!0,children:e.isError?(0,F.jsx)(D,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?(0,F.jsx)(`div`,{style:{padding:12},children:(0,F.jsx)(O,{rows:4})}):c.length===0?(0,F.jsx)(k,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:(0,F.jsx)(l,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>a(!0),children:`Create a key`})}):(0,F.jsx)(t,{children:(0,F.jsxs)(N,{children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(M,{children:`Label`}),(0,F.jsx)(M,{children:`Prefix`}),(0,F.jsx)(M,{children:`Allowed models`}),(0,F.jsx)(M,{$align:`right`,children:`Rate limit`}),(0,F.jsx)(M,{$align:`right`,children:`Created`}),(0,F.jsx)(M,{children:`Status`}),(0,F.jsx)(M,{})]})}),(0,F.jsx)(`tbody`,{children:c.map(e=>(0,F.jsxs)(A,{children:[(0,F.jsx)(j,{children:(0,F.jsx)(m,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),(0,F.jsxs)(j,{$mono:!0,children:[e.prefix,`…`]}),(0,F.jsx)(j,{children:e.modelAllowlist===null?(0,F.jsx)(r,{children:`every model`}):e.modelAllowlist.length===0?(0,F.jsx)(S,{$tone:`down`,children:`no models`}):(0,F.jsx)(H,{children:e.modelAllowlist.map(e=>(0,F.jsx)(S,{children:e},e))})}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:e.rateLimitPerMin===null?`—`:`${e.rateLimitPerMin}/min`}),(0,F.jsx)(j,{$align:`right`,$mono:!0,children:h(e.createdAt)}),(0,F.jsx)(j,{children:e.revokedAt===null?(0,F.jsx)(S,{$tone:`ok`,children:`active`}):(0,F.jsx)(U,{title:h(e.revokedAt),children:(0,F.jsx)(S,{children:`revoked`})})}),(0,F.jsx)(j,{$align:`right`,children:e.revokedAt===null?(0,F.jsx)(l,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>s(e),children:`Revoke`}):null})]},e.id))})]})})}),(0,F.jsx)(V,{open:i,onOpenChange:a}),(0,F.jsx)(y,{open:o!==null,onOpenChange:e=>{e||s(null)},title:`Revoke key`,body:o===null?``:`Revoking "${o.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:n.isPending,onConfirm:()=>{o!==null&&n.mutate(o.id,{onSettled:()=>s(null)})}})]})}var G=W;export{G as component};
@@ -0,0 +1,32 @@
1
+ import{F as e,I as t,K as n,M as r,N as ee,Nt as i,Pt as a,Qt as o,R as s,V as te,f as ne,g as re,n as c,y as l,z as u}from"./queries-1zRLkX-Q.js";import{a as d,c as f,l as ie,m as p,o as m,p as h,s as g,t as ae,u as _}from"./Rack-DAbY9x1I.js";import{n as v,r as y,t as b}from"./TokenBreakdown-oXP49ZTa.js";import{t as oe}from"./Modal-DMFUHQ-A.js";import{c as x,l as S,o as C,s as w,t as se}from"./Lamp-CBOwqG5K.js";import{n as ce,t as T}from"./Chip-C4X8tf5z.js";import{i as E,n as D}from"./Field-Ct4SeDZD.js";import{a as O,n as k,r as A,t as j}from"./States-D5Memn8D.js";import{i as M,n as N,r as P,t as F}from"./Table-DObRatbW.js";var I=o(a(),1),L=i(),R=[50,100,250,500],z=n(e)`
2
+ gap: ${({theme:e})=>e.space(2)};
3
+ flex-wrap: wrap;
4
+ `,B=n(D)`
5
+ width: 220px;
6
+ `,V=n(E)`
7
+ width: auto;
8
+ `,H=n(O)`
9
+ flex: 1;
10
+ min-height: 0;
11
+
12
+ > div {
13
+ display: flex;
14
+ flex: 1;
15
+ flex-direction: column;
16
+ min-height: 0;
17
+ }
18
+ `,U=n(t)`
19
+ flex: 1;
20
+ min-height: 0;
21
+ overflow-y: auto;
22
+ `;function W(e){let[t,n]=(0,I.useState)(Date.now);return(0,I.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function le({log:e}){return(0,L.jsx)(N,{$align:`right`,$mono:!0,...w(e)?{"aria-label":`processing`}:{title:y(e)},children:w(e)?(0,L.jsx)(b,{}):(0,L.jsx)(v,{tokens:e})})}var ue=n.dl`
23
+ display: grid;
24
+ grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
25
+ gap: 6px ${({theme:e})=>e.space(3)};
26
+ margin: 0;
27
+ font-size: 12.5px;
28
+ `,G=n.dd`
29
+ margin: 0;
30
+ font-family: ${({theme:e})=>e.font.mono};
31
+ word-break: break-all;
32
+ `;function K(){let{cadence:t,live:n}=d(),[i,a]=(0,I.useState)(100),[o,v]=(0,I.useState)(`all`),[y,b]=(0,I.useState)(``),[E,D]=(0,I.useState)(null),O=l(i,t(c)),K=ne(),q=re(),de=(O.data??[]).some(w),J=W(n&&de),Y=(0,I.useMemo)(()=>{let e=new Map;for(let t of K.data??[])e.set(t.id,t.label);return e},[K.data]),X=(0,I.useMemo)(()=>{let e=new Map;for(let t of q.data??[])e.set(t.id,t.label);return e},[q.data]),Z=y.trim().toLowerCase(),Q=(O.data??[]).filter(e=>o===`failed`&&!C(e)?!1:Z.length===0||e.requestedModel.toLowerCase().includes(Z)||(e.resolvedModel??``).toLowerCase().includes(Z)||(e.errorCode??``).toLowerCase().includes(Z)||(e.credentialId===null?``:Y.get(e.credentialId)??``).toLowerCase().includes(Z)||(e.apiKeyId===null?``:X.get(e.apiKeyId)??e.apiKeyId).toLowerCase().includes(Z)),fe=(O.data??[]).filter(C).length,$=(O.data??[]).filter(w).length;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ae,{legend:`Logs`,title:`Recent requests`,summary:O.isLoading?`Reading the request log…`:`${g(O.data?.length??0)} recent requests, ${g(fe)} of them failed${$===0?``:`, ${g($)} still running`}. Prompt and response bodies are never recorded.`,actions:(0,L.jsxs)(z,{children:[(0,L.jsx)(B,{value:y,placeholder:`Filter by model, account, key, or error`,"aria-label":`Filter requests`,onChange:e=>b(e.target.value)}),(0,L.jsxs)(V,{value:o,"aria-label":`Show which requests`,onChange:e=>v(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`All requests`}),(0,L.jsx)(`option`,{value:`failed`,children:`Failed only`})]}),(0,L.jsx)(V,{value:i,"aria-label":`How many requests to fetch`,onChange:e=>a(Number(e.target.value)),children:R.map(e=>(0,L.jsxs)(`option`,{value:e,children:[`last `,e]},e))})]})}),(0,L.jsx)(H,{legend:`Request log`,meta:`${Q.length} shown`,flush:!0,children:O.isError?(0,L.jsx)(k,{error:O.error,onRetry:()=>void O.refetch()}):O.isLoading?(0,L.jsx)(`div`,{style:{padding:12},children:(0,L.jsx)(A,{rows:8})}):Q.length===0?(0,L.jsx)(j,{legend:`Nothing to show`,message:(O.data?.length??0)===0?`No requests have reached the gateway yet.`:`No request in this window matches the filter. Clear it to see everything.`}):(0,L.jsx)(U,{"data-testid":`request-log-scroller`,children:(0,L.jsxs)(F,{children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(P,{}),(0,L.jsx)(P,{$align:`right`,children:`Time`}),(0,L.jsx)(P,{children:`Requested`}),(0,L.jsx)(P,{children:`Routed to`}),(0,L.jsx)(P,{children:`Account`}),(0,L.jsx)(P,{children:`Key`}),(0,L.jsx)(P,{$align:`right`,children:`Try`}),(0,L.jsx)(P,{$align:`right`,children:`TTFT`}),(0,L.jsx)(P,{$align:`right`,children:`Total`}),(0,L.jsx)(P,{$align:`right`,children:`Tokens`}),(0,L.jsx)(P,{$align:`right`,children:`Cost`}),(0,L.jsx)(P,{children:`Outcome`})]})}),(0,L.jsx)(`tbody`,{children:Q.map(t=>(0,L.jsxs)(M,{$selectable:!0,onClick:()=>D(t),children:[(0,L.jsx)(N,{children:(0,L.jsx)(se,{state:S(t),label:x(t)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,title:f(t.at),children:m(t.at)}),(0,L.jsx)(N,{$mono:!0,children:(0,L.jsx)(u,{style:{display:`block`,maxWidth:`20ch`},children:t.requestedModel||`—`})}),(0,L.jsx)(N,{children:t.resolvedProvider===null?(0,L.jsx)(r,{children:w(t)?`routing…`:`not routed`}):(0,L.jsxs)(e,{$gap:1,children:[(0,L.jsx)(ce,{provider:t.resolvedProvider}),(0,L.jsx)(ee,{$dim:!0,children:t.resolvedModel??`—`})]})}),(0,L.jsx)(N,{children:(0,L.jsx)(u,{style:{display:`block`,maxWidth:`18ch`},children:t.credentialId===null?`—`:Y.get(t.credentialId)??p(t.credentialId)})}),(0,L.jsx)(N,{children:(0,L.jsx)(u,{style:{display:`block`,maxWidth:`16ch`},title:t.apiKeyId??void 0,children:t.apiKeyId===null?`—`:X.get(t.apiKeyId)??p(t.apiKeyId)})}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?`—`:t.attempts}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?`—`:_(t.ttftMs)}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?ie(Math.max(0,J-t.at)):_(t.durationMs)}),(0,L.jsx)(le,{log:t}),(0,L.jsx)(N,{$align:`right`,$mono:!0,children:w(t)?`—`:h(t.costUsd)}),(0,L.jsx)(N,{children:w(t)?(0,L.jsx)(T,{$tone:`accent`,children:`live`}):t.errorCode===null?(0,L.jsx)(T,{$tone:`ok`,children:t.status}):(0,L.jsx)(T,{$tone:`down`,children:t.errorCode})})]},t.id))})]})})}),(0,L.jsx)(oe,{open:E!==null,onOpenChange:e=>{e||D(null)},title:`Request detail`,width:`600px`,footer:(0,L.jsx)(te,{type:`button`,onClick:()=>D(null),children:`Close`}),children:E===null?null:(0,L.jsxs)(s,{$gap:3,children:[(0,L.jsxs)(ue,{children:[(0,L.jsx)(r,{as:`dt`,children:`Request id`}),(0,L.jsx)(G,{children:E.id}),(0,L.jsx)(r,{as:`dt`,children:`At`}),(0,L.jsx)(G,{children:f(E.at)}),(0,L.jsx)(r,{as:`dt`,children:`Requested model`}),(0,L.jsx)(G,{children:E.requestedModel||`—`}),(0,L.jsx)(r,{as:`dt`,children:`Routed to`}),(0,L.jsx)(G,{children:w(E)?`—`:E.resolvedProvider===null?`not routed`:`${E.resolvedProvider} · ${E.resolvedModel??`—`}`}),(0,L.jsx)(r,{as:`dt`,children:`Account`}),(0,L.jsx)(G,{children:E.credentialId===null?`—`:Y.get(E.credentialId)??E.credentialId}),(0,L.jsx)(r,{as:`dt`,children:`Key`}),(0,L.jsx)(G,{children:E.apiKeyId===null?`—`:X.get(E.apiKeyId)??E.apiKeyId}),(0,L.jsx)(r,{as:`dt`,children:`Attempts`}),(0,L.jsx)(G,{children:w(E)?`—`:E.attempts}),(0,L.jsx)(r,{as:`dt`,children:`Status`}),(0,L.jsx)(G,{children:w(E)?`in flight`:E.errorCode===null?E.status:`${E.status} ${E.errorCode}`}),(0,L.jsx)(r,{as:`dt`,children:`Timing`}),(0,L.jsx)(G,{children:w(E)?`—`:`first token ${_(E.ttftMs)} · total ${_(E.durationMs)}`}),(0,L.jsx)(r,{as:`dt`,children:`Tokens`}),(0,L.jsx)(G,{children:w(E)?`—`:(0,L.jsxs)(L.Fragment,{children:[g(E.inputTokens),` in · `,g(E.outputTokens),` out ·`,` `,g(E.cacheReadTokens),` cache read ·`,` `,g(E.cacheWriteTokens),` cache write`]})}),(0,L.jsx)(r,{as:`dt`,children:`Cost`}),(0,L.jsx)(G,{children:w(E)?`—`:h(E.costUsd)}),(0,L.jsx)(r,{as:`dt`,children:`RTK compression`}),(0,L.jsx)(G,{children:w(E)?`—`:E.rtkApplied?`${g(E.rtkFilterHits)} hits · ${g(E.rtkOriginalCodeUnits)} → ${g(E.rtkCompressedCodeUnits)} code units · ~${g(E.rtkEstimatedTokensSaved)} tokens saved`:`not applied`}),(0,L.jsx)(r,{as:`dt`,children:`RTK filters`}),(0,L.jsx)(G,{children:E.rtkFilters.length===0?`—`:E.rtkFilters.join(`, `)})]}),E.degradations.length===0?null:(0,L.jsxs)(s,{$gap:1,children:[(0,L.jsx)(r,{children:`Capabilities dropped to fit the target`}),(0,L.jsx)(e,{$gap:1,$wrap:!0,children:E.degradations.map(e=>(0,L.jsx)(T,{$tone:`warn`,children:e},e))})]})]})})]})}var q=K;export{q as component};
@@ -0,0 +1,144 @@
1
+ import{F as e,H as t,K as n,L as r,M as i,N as a,Nt as o,Pt as s,Qt as c,R as l,S as u,V as d,b as f,f as p,h as m,m as h,w as g,z as _}from"./queries-1zRLkX-Q.js";import{r as v}from"./index-CE-KQ-ju.js";import{h as y,t as b}from"./Rack-DAbY9x1I.js";import{n as x,t as ee}from"./Confirm-BnmH8Gn0.js";import{t as S}from"./trash-2-Da6cLgPn.js";import{t as C}from"./Toggle-Dkjlvck5.js";import{n as w,t as T}from"./Chip-C4X8tf5z.js";import{i as E,n as D,r as O,t as k}from"./Field-Ct4SeDZD.js";import{t as te}from"./Meter-COdz0dwY.js";import{a as A,i as j,n as ne,r as M,t as N}from"./States-D5Memn8D.js";import{n as re,r as P,t as F}from"./catalog-kJ53n_fc.js";var ie=y(`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`}]]),ae=y(`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`}]]),I=c(s(),1),L=o(),R=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],oe={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`},se=n.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
+ `,ce=n(a)`
9
+ width: 22px;
10
+ color: ${({theme:e})=>e.color.inkFaint};
11
+ flex: none;
12
+ `,le=n(T)`
13
+ border-color: ${({theme:e})=>e.color.ok};
14
+ color: ${({theme:e})=>e.color.ok};
15
+ background: ${({theme:e})=>e.color.okWash};
16
+ `,ue=n.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
+ `,de=n.div`
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: 3px;
26
+ min-width: 0;
27
+ `,fe=n.div`
28
+ display: flex;
29
+ align-items: baseline;
30
+ justify-content: space-between;
31
+ gap: 6px;
32
+ `,pe=n.li`
33
+ display: flex;
34
+ align-items: center;
35
+ gap: ${({theme:e})=>e.space(2)};
36
+ padding: 5px 0;
37
+ `,me=n(e)`
38
+ gap: ${({theme:e})=>e.space(3)};
39
+ flex-wrap: wrap;
40
+ `,z=n.label`
41
+ display: flex;
42
+ align-items: center;
43
+ gap: 6px;
44
+ cursor: pointer;
45
+ font-size: 12.5px;
46
+ `,he=n.p`
47
+ font-size: 12px;
48
+ color: ${({theme:e})=>e.color.down};
49
+ `;function B(e,t,n){return(e[t]??0)*n[t]}function ge({modelId:t}){let[n,o]=(0,I.useState)({tools:!1,images:!1,reasoning:!1}),[s,c]=(0,I.useState)(null),[u,f]=(0,I.useState)(null),p=g(),h=m(),v=p.data?.weights,y=()=>{t!==null&&(f(null),h.mutate({modelId:t,need:n},{onSuccess:e=>c(e),onError:e=>{c(null),f(j(e))}}))},b=new Map(R.map(e=>[e,Math.max(1e-4,...(s?.candidates??[]).map(t=>v===void 0?0:Math.abs(B(t.reasons,e,v))))]));return(0,L.jsx)(A,{legend:`Explain`,meta:t??`no model selected`,actions:(0,L.jsxs)(d,{type:`button`,$size:`sm`,$variant:`primary`,disabled:t===null||h.isPending,onClick:y,children:[(0,L.jsx)(ie,{}),h.isPending?`Ranking…`:`Rank candidates`]}),children:(0,L.jsxs)(l,{$gap:3,children:[(0,L.jsxs)(l,{$gap:1,children:[(0,L.jsx)(i,{children:`Pretend the request needs`}),(0,L.jsxs)(me,{children:[(0,L.jsxs)(z,{children:[(0,L.jsx)(C,{checked:n.tools,label:`Probe request uses tools`,onCheckedChange:e=>o({...n,tools:e})}),`Tools`]}),(0,L.jsxs)(z,{children:[(0,L.jsx)(C,{checked:n.images,label:`Probe request includes an image`,onCheckedChange:e=>o({...n,images:e})}),`Images`]}),(0,L.jsxs)(z,{children:[(0,L.jsx)(C,{checked:n.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>o({...n,reasoning:e})}),`Reasoning`]})]})]}),u===null?null:(0,L.jsx)(he,{children:u}),s===null?(0,L.jsx)(N,{legend:`Not ranked yet`,message:t===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.`}):(0,L.jsxs)(l,{$gap:3,children:[(0,L.jsxs)(e,{$gap:2,$wrap:!0,children:[(0,L.jsx)(T,{$tone:`accent`,children:s.strategy}),s.deterministic?null:(0,L.jsx)(T,{$tone:`warn`,children:`order varies per request`}),(0,L.jsx)(r,{}),(0,L.jsxs)(i,{children:[s.candidates.length,` eligible · `,s.excluded.length,` filtered out`]})]}),s.candidates.length===0?(0,L.jsx)(N,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):(0,L.jsx)(`ul`,{children:s.candidates.map((t,n)=>(0,L.jsxs)(se,{children:[(0,L.jsxs)(e,{$gap:2,children:[(0,L.jsx)(ce,{children:n+1}),(0,L.jsx)(w,{provider:t.provider}),(0,L.jsx)(_,{style:{maxWidth:`22ch`},children:t.credentialLabel}),(0,L.jsx)(a,{$dim:!0,children:t.model}),(0,L.jsxs)(T,{children:[`tier `,t.tier]}),(0,L.jsx)(r,{}),n===0?(0,L.jsx)(le,{children:`would be used`}):null,(0,L.jsx)(a,{children:t.score.toFixed(2)})]}),v===void 0?null:(0,L.jsx)(ue,{children:R.map(e=>{let n=B(t.reasons,e,v),r=b.get(e)??1;return(0,L.jsxs)(de,{title:oe[e],children:[(0,L.jsxs)(fe,{children:[(0,L.jsx)(i,{children:e}),(0,L.jsx)(a,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),(0,L.jsx)(te,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${e} contributes ${n.toFixed(2)} of ${t.score.toFixed(2)}`})]},e)})})]},`${t.credentialId}:${t.model}`))}),s.excluded.length===0?null:(0,L.jsxs)(l,{$gap:1,children:[(0,L.jsx)(i,{children:`Filtered out`}),(0,L.jsx)(`ul`,{children:s.excluded.map(e=>(0,L.jsxs)(pe,{children:[(0,L.jsx)(a,{$dim:!0,children:e.model}),(0,L.jsx)(r,{}),(0,L.jsx)(T,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}var V=[{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.`}],H=0;function U(){return H+=1,`target-${H}`}function W(e,t){let n=P(e,t);return n===null?null:{costInput:String(n.input),costOutput:String(n.output),costCacheRead:String(n.cacheRead),costCacheWrite5m:String(n.cacheWrite5m),costCacheWrite1h:String(n.cacheWrite1h)}}function _e(e,t){let n=re(e,t);return n===null?null:{contextWindow:String(n.contextWindow),maxOutputTokens:String(n.maxOutputTokens)}}function ve(e,t){return{...e,...t,...W(t.provider,t.model)??{},contextWindow:``,maxOutputTokens:``}}function G(e=`anthropic`){let t=F[e].defaultModel,n=W(e,t);return{key:U(),provider:e,endpointId:``,model:t,tier:`1`,weight:`1`,costInput:n?.costInput??`0`,costOutput:n?.costOutput??`0`,costCacheRead:n?.costCacheRead??``,costCacheWrite5m:n?.costCacheWrite5m??``,costCacheWrite1h:n?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,tools:!0,images:!0,reasoning:!0}}function K(){return{id:``,strategy:`score`,isAlias:!1,targets:[G()]}}function q(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:U(),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),tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function ye(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();if(r.provider===`custom`&&i.length===0)return{ok:!1,problem:`${e} needs a custom endpoint.`};let a=r.model.trim();if(a.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let o=Number(r.tier);if(!Number.isInteger(o)||o<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let s=Number(r.weight);if(!Number.isFinite(s)||s<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let c=Number(r.costInput),l=Number(r.costOutput);if(!Number.isFinite(c)||c<0||!Number.isFinite(l)||l<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let u=r.costCacheRead.trim().length>0,d=Number(r.costCacheRead);if(u&&(!Number.isFinite(d)||d<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let f=r.costCacheWrite5m.trim().length>0,p=Number(r.costCacheWrite5m);if(f&&(!Number.isFinite(p)||p<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let m=r.costCacheWrite1h.trim().length>0,h=Number(r.costCacheWrite1h);if(m&&(!Number.isFinite(h)||h<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let g=r.contextWindow.trim().length>0,_=Number(r.contextWindow);if(g&&(!Number.isInteger(_)||_<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let v=r.maxOutputTokens.trim().length>0,y=Number(r.maxOutputTokens);if(v&&(!Number.isInteger(y)||y<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:a,tier:o,weight:s,costPerMTok:{input:c,output:l,...u?{cacheRead:d}:{},...f?{cacheWrite5m:p}:{},...m?{cacheWrite1h:h}:{}},...g?{contextWindow:_}:{},...v?{maxOutputTokens:y}:{},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 be=Object.keys(F),xe=n.fieldset`
50
+ border: 1px solid ${({theme:e})=>e.color.rule};
51
+ border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
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
+ `,Se=n.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
+ `,J=n.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
+ `,Y=n.div`
75
+ display: flex;
76
+ flex-direction: column;
77
+ gap: 4px;
78
+ min-width: 0;
79
+ `,Ce=n(e)`
80
+ gap: ${({theme:e})=>e.space(3)};
81
+ flex-wrap: wrap;
82
+ `,X=n.label`
83
+ display: flex;
84
+ align-items: center;
85
+ gap: 6px;
86
+ cursor: pointer;
87
+ `;function we({target:n,index:a,onChange:o,onRemove:s,removable:c,endpoints:u}){let f=(0,I.useId)(),p=F[n.provider],m=(e,t)=>{o({...n,[e]:t})},h=W(n.provider,n.model),g=_e(n.provider,n.model),_=e=>{o(ve(n,e))};return(0,L.jsxs)(xe,{$provider:n.provider,children:[(0,L.jsxs)(e,{$gap:2,children:[(0,L.jsxs)(i,{as:`legend`,children:[`Target `,a+1]}),(0,L.jsx)(r,{}),(0,L.jsx)(t,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!c,"aria-label":`Remove target ${a+1}`,title:c?`Remove target ${a+1}`:`A model needs at least one target`,onClick:s,children:(0,L.jsx)(S,{})})]}),(0,L.jsxs)(Se,{children:[(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-provider`,children:`Provider`}),(0,L.jsx)(E,{id:`${f}-provider`,value:n.provider,onChange:e=>{let t=e.target.value,r=F[t].models.some(e=>e.id===n.model);_({provider:t,model:r?n.model:F[t].defaultModel})},children:be.map(e=>(0,L.jsx)(`option`,{value:e,children:v[e]},e))})]}),n.provider===`custom`?(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-endpoint`,children:`Endpoint`}),(0,L.jsxs)(E,{id:`${f}-endpoint`,value:n.endpointId,onChange:e=>m(`endpointId`,e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:`Choose endpoint`}),u.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}):null,(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-model`,children:`Provider model`}),(0,L.jsx)(D,{id:`${f}-model`,list:`${f}-catalog`,value:n.model,placeholder:p.defaultModel,onChange:e=>_({provider:n.provider,model:e.target.value})}),(0,L.jsx)(`datalist`,{id:`${f}-catalog`,children:p.models.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-tier`,children:`Tier`}),(0,L.jsx)(O,{id:`${f}-tier`,min:1,step:1,value:n.tier,onChange:e=>m(`tier`,e.target.value)})]}),(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-weight`,children:`Weight`}),(0,L.jsx)(O,{id:`${f}-weight`,min:0,step:.1,value:n.weight,onChange:e=>m(`weight`,e.target.value)})]})]}),(0,L.jsxs)(l,{$gap:1,children:[(0,L.jsxs)(e,{$gap:2,children:[(0,L.jsx)(i,{children:`Price per million tokens`}),(0,L.jsx)(r,{}),h===null?(0,L.jsx)(i,{as:`span`,children:`not in the catalog — price it yourself`}):(0,L.jsxs)(d,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:n.costInput===h.costInput&&n.costOutput===h.costOutput&&n.costCacheRead===h.costCacheRead&&n.costCacheWrite5m===h.costCacheWrite5m&&n.costCacheWrite1h===h.costCacheWrite1h,onClick:()=>o({...n,...h}),children:[(0,L.jsx)(ae,{}),`Use list price`]})]}),(0,L.jsxs)(J,{children:[(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-in`,children:`Input`}),(0,L.jsx)(O,{id:`${f}-in`,min:0,step:.01,value:n.costInput,onChange:e=>m(`costInput`,e.target.value)})]}),(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-out`,children:`Output`}),(0,L.jsx)(O,{id:`${f}-out`,min:0,step:.01,value:n.costOutput,onChange:e=>m(`costOutput`,e.target.value)})]}),(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-cache`,children:`Cache read`}),(0,L.jsx)(O,{id:`${f}-cache`,min:0,step:.01,placeholder:`same as input`,value:n.costCacheRead,onChange:e=>m(`costCacheRead`,e.target.value)})]}),(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-write5m`,children:`Cache write 5m`}),(0,L.jsx)(O,{id:`${f}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:n.costCacheWrite5m,onChange:e=>m(`costCacheWrite5m`,e.target.value)})]}),(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-write1h`,children:`Cache write 1h`}),(0,L.jsx)(O,{id:`${f}-write1h`,min:0,step:.01,placeholder:`2x input`,value:n.costCacheWrite1h,onChange:e=>m(`costCacheWrite1h`,e.target.value)})]})]})]}),(0,L.jsxs)(l,{$gap:1,children:[(0,L.jsxs)(e,{$gap:2,children:[(0,L.jsx)(i,{children:`Token limits`}),(0,L.jsx)(r,{}),g===null?(0,L.jsx)(i,{as:`span`,children:`not in the catalog — state them yourself`}):(0,L.jsx)(i,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),(0,L.jsxs)(J,{children:[(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-context`,children:`Context window`}),(0,L.jsx)(O,{id:`${f}-context`,min:1,step:1024,placeholder:g?.contextWindow??`published`,value:n.contextWindow,onChange:e=>m(`contextWindow`,e.target.value)})]}),(0,L.jsxs)(Y,{children:[(0,L.jsx)(i,{as:`label`,htmlFor:`${f}-maxout`,children:`Max output`}),(0,L.jsx)(O,{id:`${f}-maxout`,min:1,step:1024,placeholder:g?.maxOutputTokens??`published`,value:n.maxOutputTokens,onChange:e=>m(`maxOutputTokens`,e.target.value)})]})]})]}),(0,L.jsxs)(l,{$gap:1,children:[(0,L.jsx)(i,{children:`Capabilities`}),(0,L.jsxs)(Ce,{children:[(0,L.jsxs)(X,{children:[(0,L.jsx)(C,{checked:n.tools,label:`Target ${a+1} supports tools`,onCheckedChange:e=>m(`tools`,e)}),`Tools`]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(C,{checked:n.images,label:`Target ${a+1} supports images`,onCheckedChange:e=>m(`images`,e)}),`Images`]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(C,{checked:n.reasoning,label:`Target ${a+1} supports reasoning`,onCheckedChange:e=>m(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Z=n.p`
88
+ font-size: 11.5px;
89
+ color: ${({theme:e})=>e.color.inkDim};
90
+ `,Te=n.p`
91
+ font-size: 12px;
92
+ color: ${({theme:e})=>e.color.down};
93
+ `,Ee=n.p`
94
+ font-size: 12px;
95
+ color: ${({theme:e})=>e.color.ok};
96
+ `,De=n(e)`
97
+ gap: 8px;
98
+ `;function Oe({model:t,onSaved:n,onDeleted:a}){let[o,s]=(0,I.useState)(()=>t===null?K():q(t)),[c,f]=(0,I.useState)(null),[m,g]=(0,I.useState)(!1),[_,v]=(0,I.useState)(!1),y=u(),b=h(),S=(p().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),w=t?.id??null;(0,I.useEffect)(()=>{s(t===null?K():q(t)),f(null),g(!1)},[w]);let T=V.find(e=>e.id===o.strategy);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{legend:t===null?`New model`:`Edit model`,meta:t===null?void 0:t.id,actions:(0,L.jsxs)(L.Fragment,{children:[t===null?null:(0,L.jsx)(d,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>v(!0),children:`Delete`}),(0,L.jsx)(d,{type:`button`,$variant:`primary`,$size:`sm`,disabled:y.isPending,onClick:()=>{g(!1);let e=ye(o);if(!e.ok){f(e.problem);return}f(null),y.mutate(e.model,{onSuccess:()=>{g(!0),n(e.model.id)},onError:e=>f(j(e))})},children:y.isPending?`Saving…`:t===null?`Create model`:`Save changes`})]}),children:(0,L.jsxs)(l,{$gap:3,children:[(0,L.jsx)(k,{label:`Model name`,hint:t===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:e=>(0,L.jsx)(D,{...e,value:o.id,disabled:t!==null,placeholder:`fast`,onChange:e=>s({...o,id:e.target.value})})}),(0,L.jsx)(k,{label:`Routing strategy`,children:e=>(0,L.jsx)(E,{...e,value:o.strategy,onChange:e=>s({...o,strategy:e.target.value}),children:V.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),T===void 0?null:(0,L.jsx)(Z,{children:T.blurb}),(0,L.jsxs)(De,{children:[(0,L.jsx)(C,{checked:o.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>s({...o,isAlias:e})}),(0,L.jsxs)(l,{$gap:0,children:[(0,L.jsx)(i,{as:`span`,children:`Alias`}),(0,L.jsx)(Z,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),(0,L.jsxs)(l,{$gap:2,children:[(0,L.jsxs)(e,{children:[(0,L.jsx)(i,{children:`Targets`}),(0,L.jsx)(r,{}),(0,L.jsxs)(d,{type:`button`,$size:`sm`,onClick:()=>s({...o,targets:[...o.targets,G(o.targets.at(-1)?.provider??`anthropic`)]}),children:[(0,L.jsx)(x,{}),`Add target`]})]}),o.targets.map((e,t)=>(0,L.jsx)(we,{target:e,index:t,removable:o.targets.length>1,endpoints:S,onChange:t=>s({...o,targets:o.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>s({...o,targets:o.targets.filter(t=>t.key!==e.key)})},e.key))]}),c===null?null:(0,L.jsx)(Te,{role:`alert`,children:c}),m&&c===null?(0,L.jsx)(Ee,{role:`status`,children:`Saved.`}):null]})}),(0,L.jsx)(ee,{open:_,onOpenChange:v,title:`Delete model`,body:t===null?``:`Deleting "${t.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:b.isPending,onConfirm:()=>{t!==null&&b.mutate(t.id,{onSuccess:()=>{v(!1),a()},onError:e=>{v(!1),f(j(e))}})}})]})}var Q=n.div`
99
+ display: grid;
100
+ grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
101
+ gap: ${({theme:e})=>e.space(4)};
102
+ align-items: start;
103
+
104
+ @media (max-width: 980px) {
105
+ grid-template-columns: minmax(0, 1fr);
106
+ }
107
+ `,ke=n(l)`
108
+ gap: ${({theme:e})=>e.space(4)};
109
+ min-width: 0;
110
+ `,Ae=n.button`
111
+ display: flex;
112
+ flex-direction: column;
113
+ gap: 4px;
114
+ width: 100%;
115
+ padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
116
+ text-align: left;
117
+ background: ${({theme:e,$selected:t})=>t?e.color.accentWash:`transparent`};
118
+ border: 0;
119
+ border-left: 2px solid
120
+ ${({theme:e,$selected:t})=>t?e.color.accent:`transparent`};
121
+ border-bottom: 1px solid ${({theme:e})=>e.color.rule};
122
+ cursor: pointer;
123
+
124
+ &:hover {
125
+ background: ${({theme:e,$selected:t})=>t?e.color.accentWash:e.color.panelSunk};
126
+ }
127
+
128
+ &:last-child {
129
+ border-bottom: 0;
130
+ }
131
+ `,je=n(_)`
132
+ font-family: ${({theme:e})=>e.font.mono};
133
+ font-size: 12.5px;
134
+ display: block;
135
+ max-width: 100%;
136
+ `,Me=n.div`
137
+ display: flex;
138
+ gap: 2px;
139
+ `,Ne=n.span`
140
+ width: 12px;
141
+ height: 3px;
142
+ border-radius: 1px;
143
+ background: ${({$provider:e})=>`var(--p-${e})`};
144
+ `,$=`\0new`;function Pe(){let t=f(),[n,o]=(0,I.useState)(null),s=t.data??[],c=n===$?null:s.find(e=>e.id===n)??null,l=n===$||n===null&&!t.isLoading&&s.length===0;(0,I.useEffect)(()=>{n===null&&s.length!==0&&o(s[0]?.id??null)},[s,n]);let u=t.isLoading?`Reading configured models…`:s.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${s.length} model${s.length===1?``:`s`} routing to ${s.reduce((e,t)=>e+t.targets.length,0)} targets.`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{legend:`Models`,title:`Virtual models`,summary:u,actions:(0,L.jsxs)(d,{type:`button`,$variant:`primary`,onClick:()=>o($),children:[(0,L.jsx)(x,{}),`New model`]})}),(0,L.jsxs)(Q,{children:[(0,L.jsx)(A,{legend:`Configured`,meta:`${s.length}`,flush:!0,children:t.isError?(0,L.jsx)(ne,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?(0,L.jsx)(`div`,{style:{padding:12},children:(0,L.jsx)(M,{rows:4})}):s.length===0?(0,L.jsx)(N,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:(0,L.jsx)(d,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>o($),children:`New model`})}):(0,L.jsx)(`div`,{children:s.map(t=>{let s=[...new Set(t.targets.map(e=>e.provider))];return(0,L.jsxs)(Ae,{type:`button`,$selected:t.id===n,"aria-pressed":t.id===n,onClick:()=>o(t.id),children:[(0,L.jsxs)(e,{$gap:2,style:{width:`100%`},children:[(0,L.jsx)(je,{title:t.id,children:t.id}),(0,L.jsx)(r,{}),t.isAlias?(0,L.jsx)(T,{children:`alias`}):null]}),(0,L.jsxs)(e,{$gap:2,style:{width:`100%`},children:[(0,L.jsx)(Me,{children:s.map(e=>(0,L.jsx)(Ne,{$provider:e,title:e},e))}),(0,L.jsx)(i,{children:t.strategy}),(0,L.jsx)(r,{}),(0,L.jsxs)(a,{$dim:!0,$size:`11px`,children:[t.targets.length,` target`,t.targets.length===1?``:`s`]})]})]},t.id)})})}),(0,L.jsxs)(ke,{children:[c===null&&!l?(0,L.jsx)(A,{legend:`Editor`,children:t.isLoading?(0,L.jsx)(M,{rows:5}):(0,L.jsx)(N,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):(0,L.jsx)(Oe,{model:c,onSaved:e=>{o(e),t.refetch()},onDeleted:()=>{o(null),t.refetch()}}),(0,L.jsx)(ge,{modelId:c?.id??null})]})]})]})}var Fe=Pe;export{Fe as component};
@@ -1,4 +1,4 @@
1
- import{B as e,C as t,G as n,I as r,L as i,M as a,Mt as o,Nt as s,P as c,S as l,Zt as u,a as d,j as f,y as p}from"./queries-D2o-X8Pj.js";import{t as m}from"./Rack-D1WJswv3.js";import{t as h}from"./Toggle-CiLC67Dw.js";import{i as g,n as _,t as v}from"./Field-uHZxl4fI.js";import{t as y}from"./Meter-DI_BRUKt.js";import{a as b,i as x,n as S,r as C}from"./States-Bbiu5cHE.js";var w=u(s(),1),T=o(),E=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],D=n(a)`
1
+ import{C as e,F as t,K as n,L as r,M as i,N as a,Nt as o,Pt as s,Qt as c,R as l,V as u,a as d,b as f,w as p}from"./queries-1zRLkX-Q.js";import{t as m}from"./Rack-DAbY9x1I.js";import{t as h}from"./Toggle-Dkjlvck5.js";import{i as g,n as _,t as v}from"./Field-Ct4SeDZD.js";import{t as y}from"./Meter-COdz0dwY.js";import{a as b,i as x,n as S,r as C}from"./States-D5Memn8D.js";var w=c(s(),1),T=o(),E=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],D=n(a)`
2
2
  display: block;
3
3
  white-space: pre;
4
4
  overflow-x: auto;
@@ -20,11 +20,11 @@ import{B as e,C as t,G as n,I as r,L as i,M as a,Mt as o,Nt as s,P as c,S as l,Z
20
20
  display: grid;
21
21
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
22
22
  gap: ${({theme:e})=>e.space(2)};
23
- `,j=[{key:`defaultModel`,label:`Default model`,required:!0},{key:`fableModel`,label:`Fable model`,required:!1},{key:`opusModel`,label:`Opus model`,required:!1},{key:`sonnetModel`,label:`Sonnet model`,required:!1},{key:`haikuModel`,label:`Haiku model`,required:!1}];function M(){let[t,n]=(0,w.useState)(`claude`),[r,o]=(0,w.useState)(()=>({claude:{},opencode:{}})),s=p(),l=r[t],u=typeof l.defaultModel==`string`&&l.defaultModel!==``?l:void 0,f=d(t,u),m=E.find(e=>e.id===t);return(0,T.jsx)(b,{legend:`Agent setup`,children:(0,T.jsxs)(i,{children:[(0,T.jsx)(c,{children:E.map(r=>(0,T.jsx)(e,{type:`button`,$variant:r.id===t?`primary`:`ghost`,onClick:()=>n(r.id),children:r.label},r.id))}),(0,T.jsxs)(k,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,(0,T.jsxs)(a,{children:[`omni setup `,t]}),` to write these files directly.`]}),(s.data?.length??0)>0?(0,T.jsx)(A,{children:j.map(e=>(0,T.jsx)(v,{label:e.label,children:n=>(0,T.jsxs)(g,{...n,value:l[e.key]??``,onChange:n=>o(r=>({...r,[t]:{...r[t],[e.key]:n.target.value||void 0}})),children:[(0,T.jsx)(`option`,{value:``,children:e.required?`Choose a pool`:`Not mapped`}),s.data?.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.id},e.id))]})},e.key))}):null,s.isLoading?(0,T.jsx)(C,{rows:2}):f.isError?(0,T.jsx)(S,{error:f.error,onRetry:()=>void f.refetch()}):f.isLoading?(0,T.jsx)(C,{rows:4}):(s.data?.length??0)===0?(0,T.jsx)(k,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?(0,T.jsxs)(k,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):f.data===void 0||f.data.length===0?(0,T.jsx)(k,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):f.data.map(e=>(0,T.jsxs)(`div`,{children:[(0,T.jsx)(O,{children:e.path}),(0,T.jsx)(D,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),f.isError?(0,T.jsx)(k,{children:x(f.error)}):null]})})}var N=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`recency`,label:`Recency`,blurb:`Preference for accounts that have been idle.`}],P=[{id:`maxAttempts`,label:`Attempts per request`,hint:`How many candidates dispatch may try before giving up. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`How long a request may take across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures on one account and model before it is taken out of rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Base wait before a tripped account is probed again. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before maintenance prunes them.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often each account's provider is asked for its remaining quota. 0 disables polling. Takes effect on restart.`,unit:`ms`,step:6e4,min:0}],F=n.div`
23
+ `,j=[{key:`defaultModel`,label:`Default model`,required:!0},{key:`fableModel`,label:`Fable model`,required:!1},{key:`opusModel`,label:`Opus model`,required:!1},{key:`sonnetModel`,label:`Sonnet model`,required:!1},{key:`haikuModel`,label:`Haiku model`,required:!1}];function M(){let[e,n]=(0,w.useState)(`claude`),[r,i]=(0,w.useState)(()=>({claude:{},opencode:{}})),o=f(),s=r[e],c=typeof s.defaultModel==`string`&&s.defaultModel!==``?s:void 0,p=d(e,c),m=E.find(t=>t.id===e);return(0,T.jsx)(b,{legend:`Agent setup`,children:(0,T.jsxs)(l,{children:[(0,T.jsx)(t,{children:E.map(t=>(0,T.jsx)(u,{type:`button`,$variant:t.id===e?`primary`:`ghost`,onClick:()=>n(t.id),children:t.label},t.id))}),(0,T.jsxs)(k,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,(0,T.jsxs)(a,{children:[`omni setup `,e]}),` to write these files directly.`]}),(o.data?.length??0)>0?(0,T.jsx)(A,{children:j.map(t=>(0,T.jsx)(v,{label:t.label,children:n=>(0,T.jsxs)(g,{...n,value:s[t.key]??``,onChange:n=>i(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[(0,T.jsx)(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),o.data?.map(e=>(0,T.jsx)(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,o.isLoading?(0,T.jsx)(C,{rows:2}):p.isError?(0,T.jsx)(S,{error:p.error,onRetry:()=>void p.refetch()}):p.isLoading?(0,T.jsx)(C,{rows:4}):(o.data?.length??0)===0?(0,T.jsx)(k,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):c===void 0?(0,T.jsxs)(k,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):p.data===void 0||p.data.length===0?(0,T.jsx)(k,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):p.data.map(e=>(0,T.jsxs)(`div`,{children:[(0,T.jsx)(O,{children:e.path}),(0,T.jsx)(D,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),p.isError?(0,T.jsx)(k,{children:x(p.error)}):null]})})}var N=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Preference for accounts with fewer requests in flight right now.`}],P=[{id:`maxAttempts`,label:`Attempts per request`,hint:`How many candidates dispatch may try before giving up. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`How long a request may take across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures on one account and model before it is taken out of rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Base wait before a tripped account is probed again. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before maintenance prunes them.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often each account's provider is asked for its remaining quota. 0 disables polling. Takes effect on restart.`,unit:`ms`,step:6e4,min:0}],F=n.div`
24
24
  display: grid;
25
25
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
26
26
  gap: ${({theme:e})=>e.space(3)};
27
- `,I=n(i)`
27
+ `,I=n(l)`
28
28
  gap: 6px;
29
29
  `,L=n.p`
30
30
  font-size: 11px;
@@ -35,4 +35,4 @@ import{B as e,C as t,G as n,I as r,L as i,M as a,Mt as o,Nt as s,P as c,S as l,Z
35
35
  `,z=n.p`
36
36
  font-size: 12px;
37
37
  color: ${({theme:e})=>e.color.ok};
38
- `;function B(e){let t={};for(let n of N)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of P)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t}function V(e){let t={};for(let n of N){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of P){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`}}}function H(){let n=t(),o=l(),[s,u]=(0,w.useState)({}),[d,p]=(0,w.useState)(null),[g,E]=(0,w.useState)(!1);(0,w.useEffect)(()=>{n.data!==void 0&&u(B(n.data))},[n.data]);let D=Math.max(1e-4,...N.map(e=>Math.abs(Number(s[`w.${e.id}`])||0)));return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(m,{legend:`Settings`,title:`Routing and retention`,summary:`These apply to every request the gateway routes. Changes take effect on the next request; nothing is restarted.`,actions:(0,T.jsx)(e,{type:`button`,$variant:`primary`,disabled:o.isPending||n.isLoading,onClick:()=>{E(!1);let e=V(s);if(!e.ok){p(e.problem);return}p(null),o.mutate(e.settings,{onSuccess:()=>E(!0),onError:e=>p(x(e))})},children:o.isPending?`Saving…`:`Save changes`})}),n.isError?(0,T.jsx)(b,{legend:`Settings`,children:(0,T.jsx)(S,{error:n.error,onRetry:()=>void n.refetch()})}):n.isLoading?(0,T.jsx)(b,{legend:`Settings`,children:(0,T.jsx)(C,{rows:6})}):(0,T.jsxs)(i,{$gap:4,children:[(0,T.jsx)(b,{legend:`Scoring weights`,meta:`relative to each other`,footer:(0,T.jsxs)(c,{children:[(0,T.jsx)(f,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),(0,T.jsx)(r,{})]}),children:(0,T.jsx)(F,{children:N.map(e=>{let t=Number(s[`w.${e.id}`])||0;return(0,T.jsxs)(I,{children:[(0,T.jsx)(v,{label:e.label,children:t=>(0,T.jsx)(_,{...t,type:`number`,step:.5,value:s[`w.${e.id}`]??``,onChange:t=>u({...s,[`w.${e.id}`]:t.target.value})})}),(0,T.jsx)(y,{fraction:Math.abs(t)/D,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),(0,T.jsx)(L,{children:e.blurb})]},e.id)})})}),(0,T.jsx)(b,{legend:`Limits`,children:(0,T.jsx)(F,{children:P.map(e=>(0,T.jsx)(I,{children:(0,T.jsx)(v,{label:e.label,hint:e.hint,children:t=>(0,T.jsxs)(c,{$gap:2,children:[(0,T.jsx)(_,{...t,type:`number`,min:e.min,step:e.step,value:s[e.id]??``,onChange:t=>u({...s,[e.id]:t.target.value})}),(0,T.jsx)(f,{children:e.unit})]})})},e.id))})}),(0,T.jsx)(b,{legend:`Historical tool results`,children:(0,T.jsxs)(c,{$gap:3,$align:`start`,children:[(0,T.jsx)(h,{checked:s.rtkEnabled===`true`,onCheckedChange:e=>u({...s,rtkEnabled:String(e)}),label:`Enable RTK compression`}),(0,T.jsx)(L,{children:`Compress recognized historical non-error tool results before provider dispatch. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a built-in detector recognizes a high-confidence shell-output format. Compression is deterministic and lossy. Disabled by default.`})]})}),d===null?null:(0,T.jsx)(R,{role:`alert`,children:d}),g&&d===null?(0,T.jsx)(z,{role:`status`,children:`Settings saved.`}):null,(0,T.jsx)(M,{}),(0,T.jsx)(b,{legend:`Known limits`,children:(0,T.jsxs)(i,{$gap:2,children:[(0,T.jsxs)(c,{$gap:2,children:[(0,T.jsx)(a,{$dim:!0,children:`rate limits`}),(0,T.jsx)(L,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),(0,T.jsxs)(c,{$gap:2,children:[(0,T.jsx)(a,{$dim:!0,children:`logs`}),(0,T.jsx)(L,{children:`Request rows record routing and token counts only. Prompts, responses, and credentials are never written.`})]})]})})]})]})}var U=H;export{U as component};
38
+ `;function B(e){let t={};for(let n of N)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of P)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t}function V(e){let t={};for(let n of N){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of P){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`}}}function H(){let n=p(),o=e(),[s,c]=(0,w.useState)({}),[d,f]=(0,w.useState)(null),[g,E]=(0,w.useState)(!1);(0,w.useEffect)(()=>{n.data!==void 0&&c(B(n.data))},[n.data]);let D=Math.max(1e-4,...N.map(e=>Math.abs(Number(s[`w.${e.id}`])||0)));return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(m,{legend:`Settings`,title:`Routing and retention`,summary:`These apply to every request the gateway routes. Changes take effect on the next request; nothing is restarted.`,actions:(0,T.jsx)(u,{type:`button`,$variant:`primary`,disabled:o.isPending||n.isLoading,onClick:()=>{E(!1);let e=V(s);if(!e.ok){f(e.problem);return}f(null),o.mutate(e.settings,{onSuccess:()=>E(!0),onError:e=>f(x(e))})},children:o.isPending?`Saving…`:`Save changes`})}),n.isError?(0,T.jsx)(b,{legend:`Settings`,children:(0,T.jsx)(S,{error:n.error,onRetry:()=>void n.refetch()})}):n.isLoading?(0,T.jsx)(b,{legend:`Settings`,children:(0,T.jsx)(C,{rows:6})}):(0,T.jsxs)(l,{$gap:4,children:[(0,T.jsx)(b,{legend:`Scoring weights`,meta:`relative to each other`,footer:(0,T.jsxs)(t,{children:[(0,T.jsx)(i,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),(0,T.jsx)(r,{})]}),children:(0,T.jsx)(F,{children:N.map(e=>{let t=Number(s[`w.${e.id}`])||0;return(0,T.jsxs)(I,{children:[(0,T.jsx)(v,{label:e.label,children:t=>(0,T.jsx)(_,{...t,type:`number`,step:.5,value:s[`w.${e.id}`]??``,onChange:t=>c({...s,[`w.${e.id}`]:t.target.value})})}),(0,T.jsx)(y,{fraction:Math.abs(t)/D,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),(0,T.jsx)(L,{children:e.blurb})]},e.id)})})}),(0,T.jsx)(b,{legend:`Limits`,children:(0,T.jsx)(F,{children:P.map(e=>(0,T.jsx)(I,{children:(0,T.jsx)(v,{label:e.label,hint:e.hint,children:n=>(0,T.jsxs)(t,{$gap:2,children:[(0,T.jsx)(_,{...n,type:`number`,min:e.min,step:e.step,value:s[e.id]??``,onChange:t=>c({...s,[e.id]:t.target.value})}),(0,T.jsx)(i,{children:e.unit})]})})},e.id))})}),(0,T.jsx)(b,{legend:`Historical tool results`,children:(0,T.jsxs)(t,{$gap:3,$align:`start`,children:[(0,T.jsx)(h,{checked:s.rtkEnabled===`true`,onCheckedChange:e=>c({...s,rtkEnabled:String(e)}),label:`Enable RTK compression`}),(0,T.jsx)(L,{children:`Compress recognized historical non-error tool results before provider dispatch. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a built-in detector recognizes a high-confidence shell-output format. Compression is deterministic and lossy. Disabled by default.`})]})}),d===null?null:(0,T.jsx)(R,{role:`alert`,children:d}),g&&d===null?(0,T.jsx)(z,{role:`status`,children:`Settings saved.`}):null,(0,T.jsx)(M,{}),(0,T.jsx)(b,{legend:`Known limits`,children:(0,T.jsxs)(l,{$gap:2,children:[(0,T.jsxs)(t,{$gap:2,children:[(0,T.jsx)(a,{$dim:!0,children:`rate limits`}),(0,T.jsx)(L,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),(0,T.jsxs)(t,{$gap:2,children:[(0,T.jsx)(a,{$dim:!0,children:`logs`}),(0,T.jsx)(L,{children:`Request rows record routing and token counts only. Prompts, responses, and credentials are never written.`})]})]})})]})]})}var U=H;export{U as component};