omnigateway 0.8.1 → 0.9.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.
Files changed (47) hide show
  1. package/README.md +7 -0
  2. package/bin/omni.js +23 -2
  3. package/gateway.js +10 -0
  4. package/package.json +1 -1
  5. package/public/assets/{Chip-BZWa7onX.js → Chip-shturdCv.js} +1 -1
  6. package/public/assets/{CopyValue-Cs2JUZQD.js → CopyValue-BGt9RRTL.js} +1 -1
  7. package/public/assets/{Field-DK5zaBVA.js → Field-DcNu4yw-.js} +1 -1
  8. package/public/assets/Lamp-CVGUT2YK.js +25 -0
  9. package/public/assets/{Panel-CYQvfI3L.js → Panel-BlNr9j6-.js} +3 -1
  10. package/public/assets/{Rack-CRuJZY00.js → Rack-BbZyyu2u.js} +5 -5
  11. package/public/assets/{Readout-D6-aurU8.js → Readout-D8Ofl3Gz.js} +1 -1
  12. package/public/assets/{RequestTable-D9hFf4o5.js → RequestTable-huSAoNZg.js} +1 -1
  13. package/public/assets/{SummaryDeck-D29h0rFx.js → SummaryDeck-BPo2bMSC.js} +1 -1
  14. package/public/assets/{Toggle-BIHUR4pS.js → Toggle-C84xs_YB.js} +1 -1
  15. package/public/assets/{TokenBreakdown-D5mQFSfo.js → TokenBreakdown-CmzXuENj.js} +1 -1
  16. package/public/assets/{WindowChart-DVl7kwqb.js → WindowChart-BZzVrxYk.js} +1 -1
  17. package/public/assets/{_app-BWNEo1e-.js → _app-CWXzHdhc.js} +1 -1
  18. package/public/assets/_app.accounts-DMmtkwnl.js +59 -0
  19. package/public/assets/{_app.console-Bvo2fugd.js → _app.console-BBz3kCPV.js} +1 -1
  20. package/public/assets/_app.database-ZvtMVgsh.js +24 -0
  21. package/public/assets/{_app.index-CgI1OrZR.js → _app.index-DKouD-rz.js} +5 -5
  22. package/public/assets/{_app.keys-CcfPhvCD.js → _app.keys-BG9-zfh6.js} +5 -5
  23. package/public/assets/{_app.logs-C8ZiArCn.js → _app.logs-DjinYGYS.js} +2 -2
  24. package/public/assets/{_app.models-nfMWzVb4.js → _app.models-BCfQVuoT.js} +5 -5
  25. package/public/assets/_app.plugins._pluginId-B9k5eqAt.js +2 -0
  26. package/public/assets/{_app.plugins._pluginId-CE8Jknhs.js → _app.plugins._pluginId-Dm48f3wz.js} +1 -1
  27. package/public/assets/{_app.settings-C45FJLeX.js → _app.settings-C42ylcNP.js} +4 -4
  28. package/public/assets/{_app.usage-C5s-DfBV.js → _app.usage-DfPM6eQ-.js} +3 -3
  29. package/public/assets/{chevron-right-B7JOx5ra.js → chevron-right-HI_fK6Gw.js} +1 -1
  30. package/public/assets/client-TUf0nuim.js +39 -0
  31. package/public/assets/index-C66Zn0tX.js +13 -0
  32. package/public/assets/login-DWgivEPK.js +2 -0
  33. package/public/assets/{login-DvRXHEGv.js → login-w-hVstKf.js} +2 -2
  34. package/public/assets/plus-BCf2TPqz.js +1 -0
  35. package/public/assets/{preload-helper-D2sCuvIY.js → preload-helper-Unv7FI91.js} +1 -1
  36. package/public/assets/{shared-BKWNmsjH.js → shared-XRnr7At9.js} +1 -1
  37. package/public/assets/{stream-BUWwtwme.js → stream-3PafhwhZ.js} +1 -1
  38. package/public/assets/{trash-2-rvGFhAn8.js → trash-2-Bq4GaXzx.js} +1 -1
  39. package/public/index.html +8 -8
  40. package/public/assets/Lamp-BHYJpauE.js +0 -25
  41. package/public/assets/_app.accounts-C3Yv991L.js +0 -59
  42. package/public/assets/_app.database-CfWNOIl-.js +0 -24
  43. package/public/assets/_app.plugins._pluginId-ByykviWs.js +0 -2
  44. package/public/assets/client-DvN2dbYV.js +0 -39
  45. package/public/assets/index-BW1O9p6N.js +0 -13
  46. package/public/assets/login-9Ovj_4DV.js +0 -2
  47. package/public/assets/plus-64jUPIDJ.js +0 -1
@@ -0,0 +1,59 @@
1
+ import{A as e,Et as t,F as n,H as r,Ht as i,Lt as a,N as o,P as s,St as c,Tt as l,U as u,b as d,c as f,d as p,ft as ee,h as m,it as te,lt as h,n as g,o as _,ot as v,rt as ne,s as y,t as b,ut as x,v as S,w as C,y as w}from"./Lamp-CVGUT2YK.js";import{C as T,D as E,O as D,_ as O,a as k,b as A,i as re,o as j,r as M,t as N,v as P,x as F}from"./Panel-BlNr9j6-.js";import{_ as I,b as L,i as ie,m as R,r as z,t as B}from"./Rack-BbZyyu2u.js";import{t as V}from"./CopyValue-BGt9RRTL.js";import{n as H,t as ae}from"./chevron-right-HI_fK6Gw.js";import{t as oe}from"./plus-BCf2TPqz.js";import{t as se}from"./trash-2-Bq4GaXzx.js";import{t as ce}from"./Toggle-C84xs_YB.js";import{t as le}from"./Chip-shturdCv.js";import{i as U,n as W,r as ue,t as G}from"./Field-DcNu4yw-.js";import{t as de}from"./Meter-stpt3vQu.js";import{i as fe,n as K,r as q,t as pe}from"./Table-CVDZ69Zx.js";import{n as me,r as he,t as ge}from"./WindowChart-BZzVrxYk.js";import{Fragment as _e,useCallback as J,useEffect as ve,useState as Y}from"react";import{Fragment as X,jsx as Z,jsxs as Q}from"react/jsx-runtime";import $ from"styled-components";var ye=L(`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 be(e){return e?.authTypes??[]}function xe(e){return be(e).includes(`oauth`)?`oauth`:`apiKey`}function Se(e){return e[0]?.id??`anthropic`}var Ce={oauth:`Authorize in the browser`,apiKey:`Paste an API key`};function we(e){let t=e?.callback;return t===void 0?`code#state`:`${t.uri}?code=…`}var Te=$.ol`
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: ${({theme:e})=>e.space(3)};
5
+ `,Ee=$.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
+ `,De=$.p`
15
+ font-size: 12px;
16
+ color: ${({theme:e})=>e.color.down};
17
+ `,Oe=$.p`
18
+ font-size: 12px;
19
+ color: ${({theme:e})=>e.color.inkDim};
20
+ `;function ke({open:e,credentials:t,onOpenChange:n,onConnected:i}){let a=l().data??[],[o,s]=Y(()=>Se(a)),c=r(a,o),[d,f]=Y(()=>xe(r(a,Se(a)))),[p,ee]=Y(``),m=c?.label??o,[h,g]=Y(null),[_,y]=Y(``),[b,x]=Y(``),S=(t??[]).filter((e,t,n)=>e.provider===`custom`&&n.findIndex(t=>t.provider===`custom`&&t.providerData.endpointId===e.providerData.endpointId)===t),[C,w]=Y(``),[D,k]=Y(``),[re,M]=Y(`chat_completions`),[N,P]=Y(``),[F,I]=Y(null),L=te(),R=ne(),z=v(),B=J(()=>{g(null),y(``),x(``),w(``),k(``),M(`chat_completions`),P(``),I(null),ee(``),L.reset(),R.reset(),z.reset()},[L,R,z]),H=J(e=>{e||B(),n(e)},[n,B]);return ve(()=>{if(h===null||h.kind!==`device`)return;let e=!1,t=async()=>{try{let t=await u(h.flowId);if(e)return;if(t.status===`complete`){B(),n(!1),i();return}}catch(t){if(e)return;I(j(t)),g(null);return}e||(r=setTimeout(()=>void t(),h.pollIntervalMs))},r=setTimeout(()=>void t(),h.pollIntervalMs);return()=>{e=!0,clearTimeout(r)}},[h,i,n,B]),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:h===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),d===`apiKey`){z.mutate({provider:o,apiKey:N,label:p.trim()||void 0,...o===`custom`?{endpointId:b,endpointLabel:C,origin:D,protocol:re}:{}},{onSuccess:()=>{B(),n(!1),i()},onError:e=>I(j(e))});return}L.mutate({provider:o,label:p.trim().length===0?m:p.trim()},{onSuccess:e=>g(e),onError:e=>I(j(e))})},children:d===`apiKey`?z.isPending?`Adding…`:`Add API key`:L.isPending?`Starting…`:`Start authorization`})]}):h.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||_.trim().length===0,onClick:()=>{h!==null&&(I(null),R.mutate({flowId:h.flowId,code:_.trim()},{onSuccess:()=>{B(),n(!1),i()},onError:e=>I(j(e))}))},children:R.isPending?`Finishing…`:`Finish connecting`})]}),children:Q(Te,{children:[h===null?Q(T,{$gap:3,children:[Z(G,{label:`Provider`,children:e=>Z(U,{...e,value:o,onChange:e=>{let t=e.target.value;s(t),f(xe(r(a,t)))},children:a.map(e=>Z(`option`,{value:e.id,children:e.label},e.id))})}),be(c).length>1?Z(G,{label:`How to connect`,children:e=>Z(U,{...e,value:d,onChange:e=>f(e.target.value),children:be(c).map(e=>Z(`option`,{value:e,children:Ce[e]},e))})}):null,o===`custom`?Q(X,{children:[S.length===0?null:Z(G,{label:`Existing endpoint`,children:e=>Q(U,{...e,value:b,onChange:e=>{let t=S.find(t=>t.providerData.endpointId===e.target.value);if(t===void 0){x(``),w(``),k(``),M(`chat_completions`);return}x(String(t.providerData.endpointId)),w(String(t.providerData.endpointLabel)),k(String(t.providerData.origin)+String(t.providerData.basePath??``)),M(t.providerData.protocol===`responses`?`responses`:`chat_completions`)},children:[Z(`option`,{value:``,children:`Create new endpoint`}),S.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:b,onChange:e=>x(e.target.value)})}),Z(G,{label:`Endpoint label`,children:e=>Z(W,{...e,value:C,onChange:e=>w(e.target.value)})}),Z(G,{label:`Server URL`,children:e=>Z(W,{...e,value:D,placeholder:`https://server.example/api`,onChange:e=>k(e.target.value)})}),D.trim().toLowerCase().startsWith(`http://`)?Z(De,{children:`Plaintext transport sends prompts and API keys without TLS.`}):null,Z(G,{label:`Protocol`,children:e=>Q(U,{...e,value:re,onChange:e=>M(e.target.value),children:[Z(`option`,{value:`chat_completions`,children:`Chat Completions (/v1/chat/completions)`}),Z(`option`,{value:`responses`,children:`Responses (/v1/responses)`})]})})]}):null,d===`apiKey`?Z(G,{label:`API key`,children:e=>Z(W,{...e,type:`password`,value:N,autoComplete:`off`,onChange:e=>P(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:p,placeholder:m,onChange:e=>ee(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:h.authorizeUrl,target:`_blank`,rel:`noreferrer noopener`,$variant:`primary`,$size:`sm`,children:[Z(ye,{}),`Open `,m]})}),Z(V,{value:h.authorizeUrl,label:`Copy authorization link`})]}),h.userCode===null?null:Q(T,{$gap:1,children:[Z(O,{children:`Step 2 — enter this code`}),Z(Ee,{children:h.userCode})]}),h.kind===`device`?Q(Oe,{children:[c?.pasteHint??``,` Waiting for authorization…`]}):Z(G,{label:`Authorization code`,hint:c?.pasteHint??``,...F===null?{}:{problem:F},children:e=>Z(W,{...e,value:_,autoFocus:!0,placeholder:we(c),onChange:e=>y(e.target.value)})})]}),F===null||h?.kind===`pkce`?null:Z(De,{children:F})]})})}function Ae({credentialId:e,windows:n,burn:r,pollIntervalMs:i,now:a}){let o=n.map(e=>({window:e,estimate:_(r,e.windowType),since:he(d(e))})),s=o.map(e=>e.since).filter(e=>e!==null),c=s.length===0?0:Math.min(...s),l=t({credentialId:e,since:c},s.length>0),u=l.data?.samples??[],f=l.data?.gatewayRates??[];return Z(T,{$gap:4,children:o.map(e=>Z(je,{window:e.window,estimate:e.estimate,since:e.since,samples:u.filter(t=>t.windowType===e.window.windowType&&t.observedAt>=(e.since??0)),gatewayRate:f.find(t=>t.windowType===e.window.windowType),pollIntervalMs:i,now:a},e.window.windowType))})}function je({window:t,estimate:n,since:r,samples:i,gatewayRate:a,pollIntervalMs:o,now:s}){let c=t.limit===null?`${e(t.used)} used`:`${e(t.used)} of ${e(t.limit)} used`,l=C(t,s),u=n===void 0||p(t,s,o)||n.stale&&!l;return Z(me,{live:d(t),samples:i.map(d),since:r,now:s,ratePerHourRatio:w(t,n),exhaustsAt:n?.exhaustsAt??null,survives:n?.survives??null,stale:u,rolledOver:l,spent:c,rateText:n?.ratePerHour===void 0||n.ratePerHour===null?`unknown`:`${e(n.ratePerHour)}/h`,extraFact:Z(ge,{legend:`This gateway accounts for`,value:a?.gatewayRatePerHour===void 0||a.gatewayRatePerHour===null?`unknown`:`${e(a.gatewayRatePerHour)} tokens/h`})})}var Me=$(N)`
21
+ border-left: 3px solid ${({$provider:e})=>R(e)};
22
+ `,Ne=$(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
+ `,Pe=$(ue)`
37
+ width: 62px;
38
+ height: 26px;
39
+ `,Fe=$.span`
40
+ display: block;
41
+ padding-left: 9px;
42
+ font-size: 11px;
43
+ color: ${({theme:e})=>e.color.inkDim};
44
+ `,Ie=$.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
+ `,Le=$(P)`
53
+ font-size: 11px;
54
+ text-align: right;
55
+ `,Re=$.div`
56
+ display: flex;
57
+ flex-direction: column;
58
+ gap: 4px;
59
+ `;function ze(){let e=i();return{pending:e.isPending,commit:(t,n)=>{e.mutate({id:t,patch:n})}}}function Be(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 Ve(){let{cadence:e}=I(),t=x(),i=h(e(1e4,`res:credentials`)),u=a(),d=c(),p=l(),te=ee(),{commit:v}=ze(),[ne,C]=Y(!1),[w,j]=Y(null),[P,L]=Y(new Set),ie=e=>L(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),R=Date.now(),V=t.data??[],U=p.data??[],W=e=>r(U,e)?.order??1/0,ue=[...new Set(V.map(e=>e.provider))].sort((e,t)=>W(e)-W(t)),G=e=>r(U,e)?.label??e,me=f(i.data?.health??[],e=>e.credentialId),he=f(i.data?.quota??[],e=>e.credentialId),ge=f(i.data?.burn??[],e=>e.credentialId),J=u.data?.quotaPollIntervalMs??3e5,ve=V.filter(e=>e.enabled).length,$=t.isLoading?`Reading connected accounts…`:V.length===0?`No provider credentials are connected, so every request fails at the router.`:`${ve} of ${V.length} accounts are enabled and eligible for routing.`;return Q(X,{children:[Z(B,{legend:`Accounts`,title:`Provider accounts`,summary:$,actions:Q(E,{type:`button`,$variant:`primary`,onClick:()=>C(!0),children:[Z(oe,{}),`Connect an account`]})}),t.isError?Z(N,{legend:`Accounts`,children:Z(re,{error:t.error,onRetry:()=>void t.refetch()})}):t.isLoading?Z(N,{legend:`Accounts`,children:Z(k,{rows:5})}):V.length===0?Z(N,{legend:`Accounts`,children:Z(M,{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:()=>C(!0),children:`Connect an account`})})}):Z(T,{$gap:4,children:ue.map(e=>{let t=V.filter(t=>t.provider===e);return Z(Me,{$provider:e,legend:G(e),meta:`${t.length} account${t.length===1?``:`s`}`,flush:!0,children:Z(F,{children:Q(pe,{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:`88px`,children:`TTFT`}),Z(q,{$align:`right`,$width:`130px`,children:`Token expires`}),Z(q,{$width:`76px`})]})}),Z(`tbody`,{children:t.map(e=>{let t=y(me.get(e.id)??[],R,e.enabled,e.disabledReason),r=he.get(e.id)??[],i=ge.get(e.id)??[],a=S(r),c=P.has(e.id);return Q(_e,{children:[Q(fe,{children:[Q(K,{children:[Q(A,{$gap:2,children:[Z(b,{state:t.state,label:t.note===``?`healthy`:t.note}),Z(Ne,{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}v(e.id,{label:n})}})]}),t.note===``?null:Z(Fe,{children:t.note})]}),Z(K,{children:Q(A,{$gap:1,children:[Z(le,{children:e.authType===`oauth`?`oauth`:`api key`}),e.accountEmail===null?null:Z(O,{children:e.accountEmail})]})}),Z(K,{$align:`right`,children:Z(Pe,{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}v(e.id,{tier:n})}})}),Z(K,{$align:`right`,children:Z(Pe,{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}v(e.id,{weight:n})}})}),Z(K,{$align:`center`,children:Z(ce,{checked:e.enabled,label:`Route to ${e.label}`,onCheckedChange:t=>v(e.id,{enabled:t})})}),Z(K,{children:a.length===0?Z(O,{children:`unknown`}):Z(Re,{children:a.map(({window:e,fraction:t})=>Q(Ie,{children:[Z(de,{fraction:t,label:`${g[e.windowType]} window, ${Math.round(t*100)}% used`}),Z(Le,{children:s(t,0)}),Z(O,{children:m(e,R,J,n,_(i,e.windowType))})]},e.windowType))})}),Z(K,{$align:`right`,$mono:!0,children:o(t.ttftMs)}),Z(K,{$align:`right`,$mono:!0,children:e.expiresAt===null?`never`:n(e.expiresAt,R)}),Z(K,{$align:`right`,children:Q(A,{$gap:1,$justify:`flex-end`,children:[r.length===0?null:Z(D,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":c,"aria-label":`${c?`Hide`:`Show`} quota history for ${e.label}`,title:`${c?`Hide`:`Show`} quota history for ${e.label}`,onClick:()=>ie(e.id),children:Z(c?H:ae,{})}),Z(D,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Remove ${e.label}`,title:`Remove ${e.label}`,onClick:()=>j(e),children:Z(se,{})})]})})]}),c?Z(fe,{children:Z(K,{colSpan:9,children:Z(Ae,{credentialId:e.id,windows:r,burn:i,pollIntervalMs:J,now:R})})}):null]},e.id)})})]})})},e)})}),Z(ke,{open:ne,credentials:t.data??[],onOpenChange:C,onConnected:()=>void t.refetch()}),Z(z,{open:w!==null,onOpenChange:e=>{e||j(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.`+Be(w,d.data),confirmLabel:`Remove account`,busy:te.isPending,onConfirm:()=>{w!==null&&te.mutate(w.id,{onSettled:()=>j(null)})}})]})}var He=Ve;export{He as component};
@@ -1,4 +1,4 @@
1
- import{A as e,St as t,it as n,z as r}from"./Lamp-BHYJpauE.js";import{a as i,b as a,i as o,r as s,t as c,y as l}from"./Panel-CYQvfI3L.js";import{_ as u,t as ee}from"./Rack-CRuJZY00.js";import{a as d,i as f,o as p,r as m}from"./stream-BUWwtwme.js";import{i as h}from"./Field-DK5zaBVA.js";import{useQueryClient as g}from"@tanstack/react-query";import{useLayoutEffect as te,useMemo as _,useRef as v,useState as y}from"react";import{jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";var C={debug:10,info:20,warn:30,error:40};function w(e){return typeof e==`string`&&e in C}function T(e,t){return!w(t)||e.level===null||C[e.level]>=C[t]}function E(e){if(typeof e!=`object`||!e)return null;let{raw:t,at:n,level:r,msg:i}=e;return typeof t!=`string`||n!==null&&typeof n!=`number`||r!==null&&!w(r)||i!==null&&typeof i!=`string`?null:{raw:t,at:n,level:r,msg:i}}function D(e){if(typeof e!=`object`||!e)return null;let{lines:t}=e;if(!Array.isArray(t))return null;let n=[];for(let e of t){let t=E(e);if(t===null)return null;n.push(t)}return n}var O=[100,200,500],k=[{value:``,label:`All levels`},{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warnings and errors`},{value:`error`,label:`Errors only`}],ne=S(a)`
1
+ import{A as e,Ct as t,at as n,z as r}from"./Lamp-CVGUT2YK.js";import{a as i,b as a,i as o,r as s,t as c,y as l}from"./Panel-BlNr9j6-.js";import{_ as u,t as ee}from"./Rack-BbZyyu2u.js";import{a as d,i as f,o as p,r as m}from"./stream-3PafhwhZ.js";import{i as h}from"./Field-DcNu4yw-.js";import{useQueryClient as g}from"@tanstack/react-query";import{useLayoutEffect as te,useMemo as _,useRef as v,useState as y}from"react";import{jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";var C={debug:10,info:20,warn:30,error:40};function w(e){return typeof e==`string`&&e in C}function T(e,t){return!w(t)||e.level===null||C[e.level]>=C[t]}function E(e){if(typeof e!=`object`||!e)return null;let{raw:t,at:n,level:r,msg:i}=e;return typeof t!=`string`||n!==null&&typeof n!=`number`||r!==null&&!w(r)||i!==null&&typeof i!=`string`?null:{raw:t,at:n,level:r,msg:i}}function D(e){if(typeof e!=`object`||!e)return null;let{lines:t}=e;if(!Array.isArray(t))return null;let n=[];for(let e of t){let t=E(e);if(t===null)return null;n.push(t)}return n}var O=[100,200,500],k=[{value:``,label:`All levels`},{value:`debug`,label:`Debug and above`},{value:`info`,label:`Info and above`},{value:`warn`,label:`Warnings and errors`},{value:`error`,label:`Errors only`}],ne=S(a)`
2
2
  gap: ${({theme:e})=>e.space(2)};
3
3
  flex-wrap: wrap;
4
4
  `,A=S(h)`
@@ -0,0 +1,24 @@
1
+ import{A as e,Bt as t,D as n,G as r,Mt as i,N as a,P as o,Wt as s,X as c,ct as l,dt as u,gt as d,j as f,kt as p,mt as m}from"./Lamp-CVGUT2YK.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-BlNr9j6-.js";import{b as E,r as D,t as O}from"./Rack-BbZyyu2u.js";import{t as k}from"./trash-2-Bq4GaXzx.js";import{r as A,t as j}from"./Field-DcNu4yw-.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-D8Ofl3Gz.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 t=i(),[n,r]=V({}),[a,o]=V(null),[s,c]=V(!1),l={keepLatest:n.keepLatest??(e===void 0?``:String(e.keepLatest)),maxAgeDays:n.maxAgeDays??(e===void 0?``:String(e.maxAgeDays))};return U(C,{legend:`Retention`,actions:U(g,{type:`button`,$size:`sm`,disabled:t.isPending||e===void 0,onClick:()=>{c(!1);let e=ne(l);if(!e.ok){o(e.problem);return}o(null),t.mutate(e.policy,{onSuccess:()=>{c(!0),r({})},onError:e=>o(S(e))})},children:t.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=>r({...n,[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=t(),i=l(),a=p(),o=ie(),s=m(),c=d(),[u,_]=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:i.isPending,onClick:()=>i.mutate(),children:[U(K,{}),i.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||c.isPending,onClick:()=>M(!0),children:c.isPending?`Replacing…`:`Import`})]}),c.isError?U(Z,{role:`alert`,children:S(c.error)}):null,a.isError?U(Z,{role:`alert`,children:S(a.error)}):null,i.isError?U(Z,{role:`alert`,children:S(i.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:i.isPending,onClick:()=>i.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:n(e.sizeBytes)}),U(P,{$align:`right`,$mono:!0,children:f(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:u!==null,onOpenChange:e=>{e||_(null)},title:`Restore database`,body:u===null?``:`Replacing the live database with ${u.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:a.isPending,onConfirm:()=>{u!==null&&a.mutate(u.id,{onSuccess:o,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:s.isPending,onConfirm:()=>{b!==null&&s.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:c.isPending,onConfirm:()=>{O!==null&&c.mutate(O,{onSuccess:o,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=u(),r=s(),[i,l]=V(!1),d=c(),[f,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:d.isPending||m===void 0||m.bodiesBytes===0,onClick:()=>p(!0),children:[U(k,{}),d.isPending?`Clearing…`:`Clear bodies`]}),h?null:W(g,{type:`button`,$size:`sm`,disabled:r.isPending||m===void 0,onClick:()=>l(!0),children:[U(q,{}),r.isPending?`Compacting…`:`Compact`]})]}),footer:r.isError?U($,{role:`alert`,children:S(r.error)}):d.isError?U($,{role:`alert`,children:S(d.error)}):r.data===void 0?d.data===void 0?void 0:U(Q,{role:`status`,children:`Cleared ${e(d.data.removed)} captured bodies.`}):U(Q,{role:`status`,children:`Compacted, reclaiming ${n(r.data.reclaimedBytes)} in ${a(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:n(m.logicalBytes),unit:`${m.stats.pageCount} blocks of ${n(m.stats.pageSize)}`}),U(L,{legend:`Server`,value:se(m.location),unit:`database ${ce(m.location)}`}),U(L,{legend:`Captured bodies`,value:n(m.bodiesBytes),unit:`the request_bodies table`})]}):W(b,{$min:`180px`,$stretch:!0,children:[U(L,{legend:`Database file`,value:n(m.fileBytes),unit:`${m.stats.pageCount} pages of ${n(m.stats.pageSize)}`,trace:U(M,{fraction:_,label:`${o(_,0)} of the file is reclaimable`})}),U(L,{legend:`Reclaimable`,value:n(m.freePageBytes),unit:`${m.stats.freelistCount} free pages`}),U(L,{legend:`Write-ahead log`,value:n(m.walBytes),unit:`folded into every snapshot`}),U(L,{legend:`Captured bodies`,value:n(m.bodiesBytes),unit:`never in a snapshot`}),U(L,{legend:`Snapshots`,value:n(m.snapshots.totalBytes),unit:`${m.snapshots.count} kept`}),U(L,{legend:`Free disk`,value:n(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(t=>W(N,{children:[U(P,{children:t.name}),U(P,{$align:`right`,children:n(t.bytes)}),U(P,{$align:`right`,children:e(t.rows)}),h?U(P,{$align:`right`,children:e(t.deadRows??0)}):null]},t.name))})]})}),h?null:W(H,{children:[U(oe,{}),U(re,{retention:m?.retention})]}),U(D,{open:f,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:d.isPending,onConfirm:()=>d.mutate(void 0,{onSettled:()=>p(!1)})}),U(D,{open:i,onOpenChange:l,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:()=>l(!1)})})]})}var ue=le;export{ue as component};
@@ -1,4 +1,4 @@
1
- import{A as e,F as t,Ht as n,I as r,It as i,N as a,P as o,Wt as s,bt as c,c as l,ct as u,f as d,h as f,i as p,k as m,lt as h,n as g,o as _,p as v,s as y,t as b,u as x,v as ee,x as S,xt as C}from"./Lamp-BHYJpauE.js";import{C as w,D as T,S as E,_ as D,b as O,g as k,i as A,r as j,t as M,v as N,w as P,x as F}from"./Panel-CYQvfI3L.js";import{_ as I,f as L,m as R,t as z}from"./Rack-CRuJZY00.js";import{n as B,t as te}from"./TokenBreakdown-D5mQFSfo.js";import{n as ne,t as V}from"./Chip-BZWa7onX.js";import{t as re}from"./Meter-stpt3vQu.js";import{i as H,n as U,r as W,t as G}from"./Table-CVDZ69Zx.js";import{t as K}from"./Readout-D6-aurU8.js";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";var ie=X(P)`
1
+ import{A as e,F as t,Gt as n,I as r,Lt as i,N as a,P as o,St as s,Ut as c,c as l,f as u,h as d,i as f,k as p,lt as m,n as h,o as g,p as _,s as v,t as y,u as b,ut as x,v as ee,x as S,xt as C}from"./Lamp-CVGUT2YK.js";import{C as w,D as T,S as E,_ as D,b as O,g as k,i as A,r as j,t as M,v as N,w as P,x as F}from"./Panel-BlNr9j6-.js";import{_ as I,f as L,m as R,t as z}from"./Rack-BbZyyu2u.js";import{n as B,t as te}from"./TokenBreakdown-CmzXuENj.js";import{n as ne,t as V}from"./Chip-shturdCv.js";import{t as re}from"./Meter-stpt3vQu.js";import{i as H,n as U,r as W,t as G}from"./Table-CVDZ69Zx.js";import{t as K}from"./Readout-D8Ofl3Gz.js";import{Fragment as q,jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";var ie=X(P)`
2
2
  font-weight: 500;
3
3
  display: block;
4
4
  max-width: 24ch;
@@ -15,7 +15,7 @@ import{A as e,F as t,Ht as n,I as r,It as i,N as a,P as o,Wt as s,bt as c,c as l
15
15
  display: flex;
16
16
  flex-direction: column;
17
17
  gap: 4px;
18
- `;function se(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 ce(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function le({credentials:n,health:r,quota:i,burn:o,usage:c,quotaPollIntervalMs:u,now:d}){let p=l(r,e=>e.credentialId),m=l(i,e=>e.credentialId),h=l(o,e=>e.credentialId),v=new Map(c.map(e=>[e.key,e])),x={down:0,warn:1,ok:2,idle:3,live:3},S=n.map(e=>{let t=h.get(e.id)??[];return{credential:e,status:y(p.get(e.id)??[],d,e.enabled,e.disabledReason),quota:ee(m.get(e.id)??[]),burn:t,exhaustsAt:se(t),usage:v.get(e.id)}}).sort((e,t)=>x[e.status.state]-x[t.status.state]||ce(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return J(M,{legend:`Accounts`,meta:`${n.length} connected`,flush:!0,actions:J(T,{as:s,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:n.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(T,{as:s,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):J(F,{children:Y(G,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Account`}),J(W,{children:`Provider`}),J(W,{$align:`right`,children:`Tier`}),J(W,{children:`Quota`}),J(W,{$align:`right`,children:`TTFT`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Last used`})]})}),J(`tbody`,{children:S.map(({credential:n,status:r,quota:i,burn:o,usage:s})=>Y(H,{children:[J(U,{children:Y(O,{$gap:2,children:[J(b,{state:r.state,label:r.note===``?`healthy`:r.note}),Y(`div`,{children:[J(ie,{children:n.label}),r.note===``?null:J(Z,{children:r.note})]})]})}),J(U,{children:J(ne,{provider:n.provider})}),J(U,{$align:`right`,$mono:!0,children:n.tier}),J(U,{children:i.length===0?J(Z,{children:`unknown`}):J(oe,{children:i.map(({window:e,fraction:n})=>Y(ae,{children:[J(re,{fraction:n,label:`${g[e.windowType]} window, ${Math.round(n*100)}% used`}),J(D,{children:f(e,d,u,t,_(o,e.windowType))})]},e.windowType))})}),J(U,{$align:`right`,$mono:!0,children:a(r.ttftMs)}),J(U,{$align:`right`,$mono:!0,children:s===void 0?`—`:e(s.requests)}),J(U,{$align:`right`,$mono:!0,children:t(r.lastUsedAt,d)})]},n.id))})]})})})}var ue=X.ul`
18
+ `;function se(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 ce(e,t){return e===null?t===null?0:1:t===null?-1:e-t}function le({credentials:r,health:i,quota:o,burn:s,usage:c,quotaPollIntervalMs:u,now:f}){let p=l(i,e=>e.credentialId),m=l(o,e=>e.credentialId),_=l(s,e=>e.credentialId),b=new Map(c.map(e=>[e.key,e])),x={down:0,warn:1,ok:2,idle:3,live:3},S=r.map(e=>{let t=_.get(e.id)??[];return{credential:e,status:v(p.get(e.id)??[],f,e.enabled,e.disabledReason),quota:ee(m.get(e.id)??[]),burn:t,exhaustsAt:se(t),usage:b.get(e.id)}}).sort((e,t)=>x[e.status.state]-x[t.status.state]||ce(e.exhaustsAt,t.exhaustsAt)||e.credential.tier-t.credential.tier);return J(M,{legend:`Accounts`,meta:`${r.length} connected`,flush:!0,actions:J(T,{as:n,to:`/accounts`,$size:`sm`,children:`Manage accounts`}),children:r.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(T,{as:n,to:`/accounts`,$variant:`primary`,$size:`sm`,children:`Connect an account`})}):J(F,{children:Y(G,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Account`}),J(W,{children:`Provider`}),J(W,{$align:`right`,children:`Tier`}),J(W,{children:`Quota`}),J(W,{$align:`right`,children:`TTFT`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Last used`})]})}),J(`tbody`,{children:S.map(({credential:n,status:r,quota:i,burn:o,usage:s})=>Y(H,{children:[J(U,{children:Y(O,{$gap:2,children:[J(y,{state:r.state,label:r.note===``?`healthy`:r.note}),Y(`div`,{children:[J(ie,{children:n.label}),r.note===``?null:J(Z,{children:r.note})]})]})}),J(U,{children:J(ne,{provider:n.provider})}),J(U,{$align:`right`,$mono:!0,children:n.tier}),J(U,{children:i.length===0?J(Z,{children:`unknown`}):J(oe,{children:i.map(({window:e,fraction:n})=>Y(ae,{children:[J(re,{fraction:n,label:`${h[e.windowType]} window, ${Math.round(n*100)}% used`}),J(D,{children:d(e,f,u,t,g(o,e.windowType))})]},e.windowType))})}),J(U,{$align:`right`,$mono:!0,children:a(r.ttftMs)}),J(U,{$align:`right`,$mono:!0,children:s===void 0?`—`:e(s.requests)}),J(U,{$align:`right`,$mono:!0,children:t(r.lastUsedAt,f)})]},n.id))})]})})})}var ue=X.ul`
19
19
  display: flex;
20
20
  flex-direction: column;
21
21
  `,de=X.li`
@@ -35,7 +35,7 @@ import{A as e,F as t,Ht as n,I as r,It as i,N as a,P as o,Wt as s,bt as c,c as l
35
35
  `,pe=X(N)`
36
36
  color: ${({theme:e})=>e.color.down};
37
37
  font-size: 11px;
38
- `;function me({logs:e}){let t=e.slice(0,12);return J(M,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:J(T,{as:s,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.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(ue,{children:t.map(e=>Y(de,{children:[J(b,{state:v(e),label:d(e)}),J(N,{$dim:!0,children:m(e.at)}),J(fe,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:J(N,{$dim:!0,style:{color:R(e.resolvedProvider)},children:e.resolvedProvider}),J(E,{}),x(e)?J(N,{$dim:!0,"aria-label":`processing`,children:J(te,{})}):Y(q,{children:[e.errorCode===null?null:J(pe,{children:e.errorCode}),e.attempts>1?Y(N,{$dim:!0,children:[e.attempts,`×`]}):null,J(N,{$dim:!0,children:J(B,{tokens:e})}),J(N,{$dim:!0,children:a(e.durationMs)}),J(N,{$dim:!0,children:r(e.costUsd)})]})]},e.id))})})}var Q=X.ul`
38
+ `;function me({logs:e}){let t=e.slice(0,12);return J(M,{legend:`Activity`,meta:`most recent first`,flush:!0,actions:J(T,{as:n,to:`/logs`,$size:`sm`,children:`Open logs`}),children:t.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(ue,{children:t.map(e=>Y(de,{children:[J(y,{state:_(e),label:u(e)}),J(N,{$dim:!0,children:p(e.at)}),J(fe,{title:e.requestedModel,children:e.requestedModel||`—`}),e.resolvedProvider===null?null:J(N,{$dim:!0,style:{color:R(e.resolvedProvider)},children:e.resolvedProvider}),J(E,{}),b(e)?J(N,{$dim:!0,"aria-label":`processing`,children:J(te,{})}):Y(q,{children:[e.errorCode===null?null:J(pe,{children:e.errorCode}),e.attempts>1?Y(N,{$dim:!0,children:[e.attempts,`×`]}):null,J(N,{$dim:!0,children:J(B,{tokens:e})}),J(N,{$dim:!0,children:a(e.durationMs)}),J(N,{$dim:!0,children:r(e.costUsd)})]})]},e.id))})})}var Q=X.ul`
39
39
  display: flex;
40
40
  flex-direction: column;
41
41
  gap: ${({theme:e})=>e.space(3)};
@@ -55,8 +55,8 @@ import{A as e,F as t,Ht as n,I as r,It as i,N as a,P as o,Wt as s,bt as c,c as l
55
55
  opacity: 0.8;
56
56
  `,ve=X.div`
57
57
  flex: ${({$grow:e})=>e} 0 0;
58
- `;function ye({models:t,logs:n}){let i=new Map;for(let e of n){let t=i.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,i.set(e.requestedModel,t)}let a=Math.max(1,...[...i.values()].map(e=>e.requests)),o=[...t].map(e=>({model:e,used:i.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return J(M,{legend:`Models`,meta:`${t.length} configured`,actions:J(T,{as:s,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.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(T,{as:s,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):J(Q,{children:o.map(({model:t,used:n})=>{let i=(n?.requests??0)/a,o=[...new Set(t.targets.map(e=>e.provider))];return Y(`li`,{children:[Y(O,{$gap:2,children:[J(he,{title:t.id,children:t.id}),t.isAlias?J(V,{children:`alias`}):null,J(V,{$tone:`accent`,children:t.strategy}),J(E,{}),J(N,{$dim:!0,children:e(n?.requests??0)}),J(D,{children:`req`}),J(N,{$dim:!0,children:r(n?.costUsd??0)})]}),Y(ge,{style:{marginTop:6},title:`${Math.round(i*100)}% of the busiest model`,children:[o.map(e=>J(_e,{$color:R(e),$grow:i/o.length},e)),J(ve,{$grow:Math.max(0,1-i)})]})]},t.id)})})})}var be=X.div`
58
+ `;function ye({models:t,logs:i}){let a=new Map;for(let e of i){let t=a.get(e.requestedModel)??{requests:0,costUsd:0};t.requests+=1,t.costUsd+=e.costUsd,a.set(e.requestedModel,t)}let o=Math.max(1,...[...a.values()].map(e=>e.requests)),s=[...t].map(e=>({model:e,used:a.get(e.id)})).sort((e,t)=>(t.used?.requests??0)-(e.used?.requests??0)).slice(0,8);return J(M,{legend:`Models`,meta:`${t.length} configured`,actions:J(T,{as:n,to:`/models`,$size:`sm`,children:`Edit routing`}),children:t.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(T,{as:n,to:`/models`,$variant:`primary`,$size:`sm`,children:`Create a model`})}):J(Q,{children:s.map(({model:t,used:n})=>{let i=(n?.requests??0)/o,a=[...new Set(t.targets.map(e=>e.provider))];return Y(`li`,{children:[Y(O,{$gap:2,children:[J(he,{title:t.id,children:t.id}),t.isAlias?J(V,{children:`alias`}):null,J(V,{$tone:`accent`,children:t.strategy}),J(E,{}),J(N,{$dim:!0,children:e(n?.requests??0)}),J(D,{children:`req`}),J(N,{$dim:!0,children:r(n?.costUsd??0)})]}),Y(ge,{style:{marginTop:6},title:`${Math.round(i*100)}% of the busiest model`,children:[a.map(e=>J(_e,{$color:R(e),$grow:i/a.length},e)),J(ve,{$grow:Math.max(0,1-i)})]})]},t.id)})})})}var be=X.div`
59
59
  display: grid;
60
60
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
61
61
  gap: ${({theme:e})=>e.space(3)};
62
- `;function xe({logs:t,windowMs:n,now:i}){let s=t.filter(e=>i-e.at<=n),c=S(s,n),l=p(s,{now:i,spanMs:n,count:32}),u=c.errorRate>=.25?`down`:c.errorRate>=.05?`warn`:`ok`,d=c.inputTokens+c.outputTokens+c.cacheReadTokens+c.cacheWriteTokens;return Y(be,{children:[J(K,{legend:`Requests`,value:e(c.requests),unit:`${c.ratePerMin.toFixed(1)}/min`,trace:J(L,{values:l.map(e=>e.total),overlay:l.map(e=>e.errors),label:`${c.requests} requests, ${c.errors} of them failed`})}),J(K,{legend:`Error rate`,value:o(c.errorRate),unit:`${e(c.errors)} failed`,tone:c.requests===0?`ink`:u,trace:J(L,{values:l.map(e=>e.errors),scaleTo:Math.max(...l.map(e=>e.total)),color:`var(--down)`,label:`${c.errors} failed requests against ${c.requests} total`})}),J(K,{legend:`Total tokens`,value:e(d),unit:J(B,{tokens:c}),trace:J(L,{values:l.map(e=>e.tokens),label:`token volume over the window, ${d.toLocaleString(`en-US`)} total`})}),J(K,{legend:`Time to first token`,value:a(c.ttftP50),unit:`p95 ${a(c.ttftP95)}`,trace:J(L,{values:l.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${a(c.ttftP50)}`})}),J(K,{legend:`Spend`,value:r(c.costUsd),unit:`${e(c.inputTokens+c.outputTokens)} tokens`,trace:J(L,{values:l.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${r(c.costUsd)} total`})})]})}var $=36e5;function Se(){let{cadence:e}=I(),t=h(),r=u(e(1e4,`res:credentials`)),a=C(),o=c(500,e(1e4,`res:logs`)),s=i(),d=Date.now(),f=Math.floor((d-$)/6e4)*6e4,p=n({groupBy:`credential`,since:f},e(6e4,`res:usage`)),m=t.data??[],g=l(r.data?.health??[],e=>e.credentialId),_=m.filter(e=>y(g.get(e.id)??[],d,e.enabled,e.disabledReason).state===`down`),v=t.isLoading||o.isLoading?`Reading the gateway…`:m.length===0?`No accounts are connected, so every request fails at the router.`:_.length>0?`${_.length} account${_.length===1?` is`:`s are`} out of rotation.`:`All ${m.length} accounts are answering. Nothing needs attention.`;return Y(q,{children:[J(z,{legend:`Rack`,title:`Gateway`,summary:v}),o.isError?J(M,{legend:`Traffic`,children:J(A,{legend:`The gateway did not answer`,error:o.error,onRetry:()=>void o.refetch()})}):Y(w,{$gap:4,children:[J(xe,{logs:o.data??[],windowMs:$,now:d}),J(le,{credentials:m,health:r.data?.health??[],quota:r.data?.quota??[],burn:r.data?.burn??[],usage:p.data??[],quotaPollIntervalMs:s.data?.quotaPollIntervalMs??3e5,now:d}),Y(k,{$min:`340px`,$gap:4,children:[J(ye,{models:a.data??[],logs:o.data??[]}),J(me,{logs:o.data??[]})]})]})]})}var Ce=Se;export{Ce as component};
62
+ `;function xe({logs:t,windowMs:n,now:i}){let s=t.filter(e=>i-e.at<=n),c=S(s,n),l=f(s,{now:i,spanMs:n,count:32}),u=c.errorRate>=.25?`down`:c.errorRate>=.05?`warn`:`ok`,d=c.inputTokens+c.outputTokens+c.cacheReadTokens+c.cacheWriteTokens;return Y(be,{children:[J(K,{legend:`Requests`,value:e(c.requests),unit:`${c.ratePerMin.toFixed(1)}/min`,trace:J(L,{values:l.map(e=>e.total),overlay:l.map(e=>e.errors),label:`${c.requests} requests, ${c.errors} of them failed`})}),J(K,{legend:`Error rate`,value:o(c.errorRate),unit:`${e(c.errors)} failed`,tone:c.requests===0?`ink`:u,trace:J(L,{values:l.map(e=>e.errors),scaleTo:Math.max(...l.map(e=>e.total)),color:`var(--down)`,label:`${c.errors} failed requests against ${c.requests} total`})}),J(K,{legend:`Total tokens`,value:e(d),unit:J(B,{tokens:c}),trace:J(L,{values:l.map(e=>e.tokens),label:`token volume over the window, ${d.toLocaleString(`en-US`)} total`})}),J(K,{legend:`Time to first token`,value:a(c.ttftP50),unit:`p95 ${a(c.ttftP95)}`,trace:J(L,{values:l.map(e=>e.ttftMs??0),color:`var(--ok)`,label:`median first-token latency, currently ${a(c.ttftP50)}`})}),J(K,{legend:`Spend`,value:r(c.costUsd),unit:`${e(c.inputTokens+c.outputTokens)} tokens`,trace:J(L,{values:l.map(e=>e.costUsd),color:`var(--warn)`,label:`spend over the window, ${r(c.costUsd)} total`})})]})}var $=36e5;function Se(){let{cadence:e}=I(),t=x(),n=m(e(1e4,`res:credentials`)),r=s(),a=C(500,e(1e4,`res:logs`)),o=i(),u=Date.now(),d=Math.floor((u-$)/6e4)*6e4,f=c({groupBy:`credential`,since:d},e(6e4,`res:usage`)),p=t.data??[],h=l(n.data?.health??[],e=>e.credentialId),g=p.filter(e=>v(h.get(e.id)??[],u,e.enabled,e.disabledReason).state===`down`),_=t.isLoading||a.isLoading?`Reading the gateway…`:p.length===0?`No accounts are connected, so every request fails at the router.`:g.length>0?`${g.length} account${g.length===1?` is`:`s are`} out of rotation.`:`All ${p.length} accounts are answering. Nothing needs attention.`;return Y(q,{children:[J(z,{legend:`Rack`,title:`Gateway`,summary:_}),a.isError?J(M,{legend:`Traffic`,children:J(A,{legend:`The gateway did not answer`,error:a.error,onRetry:()=>void a.refetch()})}):Y(w,{$gap:4,children:[J(xe,{logs:a.data??[],windowMs:$,now:u}),J(le,{credentials:p,health:n.data?.health??[],quota:n.data?.quota??[],burn:n.data?.burn??[],usage:f.data??[],quotaPollIntervalMs:o.data?.quotaPollIntervalMs??3e5,now:u}),Y(k,{$min:`340px`,$gap:4,children:[J(ye,{models:r.data??[],logs:a.data??[]}),J(me,{logs:a.data??[]})]})]})]})}var Ce=Se;export{Ce as component};
@@ -1,4 +1,4 @@
1
- import{Nt as e,Pt as t,gt as n,j as r,kt as i,ot as a,xt as o}from"./Lamp-BHYJpauE.js";import{C as s,D as c,O as l,_ as u,a as d,b as f,i as p,o as m,r as h,t as g,v as _,w as v,x as y}from"./Panel-CYQvfI3L.js";import{b,i as x,r as S,t as C,v as w}from"./Rack-CRuJZY00.js";import{t as T}from"./CopyValue-Cs2JUZQD.js";import{n as E,t as D}from"./chevron-right-B7JOx5ra.js";import{t as O}from"./plus-64jUPIDJ.js";import{t as k}from"./Toggle-BIHUR4pS.js";import{t as A}from"./Chip-BZWa7onX.js";import{n as j,r as M,t as N}from"./Field-DK5zaBVA.js";import{t as P}from"./Meter-stpt3vQu.js";import{i as F,n as I,r as L,t as ee}from"./Table-CVDZ69Zx.js";import{Fragment as R,useState as z}from"react";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import U from"styled-components";var te=b(`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`}]]),W=[{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 G(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var ne={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},re={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=ne[e.dimension];return e.window===null?t:`${t} ${re[e.window]}`}function q(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function J(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function ie(e){let t=null,n=-1;for(let r of e){let e=J(r);e!==null&&e>n&&(t=r,n=e)}return t}function Y(e){let t={};for(let e of W)t[G(e)]=``;if(e===null)return t;for(let n of W){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[G(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of W){let o=(e[G(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?`${K(a)} must be an amount above zero, or blank for no limit.`:`${K(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 ae=U.div`
1
+ import{At as e,Ft as t,Pt as n,St as r,_t as i,j as a,st as o}from"./Lamp-CVGUT2YK.js";import{C as s,D as c,O as l,_ as u,a as d,b as f,i as p,o as m,r as h,t as g,v as _,w as v,x as y}from"./Panel-BlNr9j6-.js";import{b,i as x,r as S,t as C,v as w}from"./Rack-BbZyyu2u.js";import{t as T}from"./CopyValue-BGt9RRTL.js";import{n as E,t as D}from"./chevron-right-HI_fK6Gw.js";import{t as O}from"./plus-BCf2TPqz.js";import{t as k}from"./Toggle-C84xs_YB.js";import{t as A}from"./Chip-shturdCv.js";import{n as j,r as M,t as N}from"./Field-DcNu4yw-.js";import{t as P}from"./Meter-stpt3vQu.js";import{i as F,n as I,r as L,t as ee}from"./Table-CVDZ69Zx.js";import{Fragment as R,useState as z}from"react";import{Fragment as B,jsx as V,jsxs as H}from"react/jsx-runtime";import U from"styled-components";var te=b(`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`}]]),W=[{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 G(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var ne={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},re={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function K(e){let t=ne[e.dimension];return e.window===null?t:`${t} ${re[e.window]}`}function q(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function J(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function ie(e){let t=null,n=-1;for(let r of e){let e=J(r);e!==null&&e>n&&(t=r,n=e)}return t}function Y(e){let t={};for(let e of W)t[G(e)]=``;if(e===null)return t;for(let n of W){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[G(n)]=String(r))}return t}function X(e){let t={},n={},r={},i;for(let a of W){let o=(e[G(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?`${K(a)} must be an amount above zero, or blank for no limit.`:`${K(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 ae=U.div`
2
2
  display: grid;
3
3
  grid-template-columns: repeat(3, minmax(0, 1fr));
4
4
  gap: ${({theme:e})=>e.space(2)};
@@ -11,7 +11,7 @@ import{Nt as e,Pt as t,gt as n,j as r,kt as i,ot as a,xt as o}from"./Lamp-BHYJpa
11
11
  `,ce=U.p`
12
12
  font-size: 12px;
13
13
  color: ${({theme:e})=>e.color.warn};
14
- `;function le({apiKey:t,onOpenChange:n}){let r=e(),[i,a]=z(()=>Y(t?.limits??{})),[o,l]=z(null);return V(x,{open:t!==null,onOpenChange:n,title:`Edit limits`,description:t===null?void 0:`What "${t.label}" may do per minute, per five hours, and per week. Every field is a ceiling; blank is no limit.`,width:`640px`,footer:H(B,{children:[V(c,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{if(t===null)return;let e=X(i);if(`problem`in e){l(e.problem);return}l(null),r.mutate({id:t.id,limits:e.limits},{onSuccess:()=>n(!1),onError:e=>l(m(e))})},children:r.isPending?`Saving…`:`Save limits`})]}),children:H(s,{$gap:3,children:[t?.limits===null?V(ce,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,V(Z,{draft:i,onChange:a,disabled:r.isPending}),o===null?null:V(se,{role:`alert`,children:o})]})})}var ue=U.div`
14
+ `;function le({apiKey:e,onOpenChange:t}){let r=n(),[i,a]=z(()=>Y(e?.limits??{})),[o,l]=z(null);return V(x,{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:H(B,{children:[V(c,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{if(e===null)return;let n=X(i);if(`problem`in n){l(n.problem);return}l(null),r.mutate({id:e.id,limits:n.limits},{onSuccess:()=>t(!1),onError:e=>l(m(e))})},children:r.isPending?`Saving…`:`Save limits`})]}),children:H(s,{$gap:3,children:[e?.limits===null?V(ce,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,V(Z,{draft:i,onChange:a,disabled:r.isPending}),o===null?null:V(se,{role:`alert`,children:o})]})})}var ue=U.div`
15
15
  display: flex;
16
16
  flex-direction: column;
17
17
  gap: 2px;
@@ -40,7 +40,7 @@ import{Nt as e,Pt as t,gt as n,j as r,kt as i,ot as a,xt as o}from"./Lamp-BHYJpa
40
40
  `;function Q({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 H(`div`,{children:[V(ue,{children:i.map(e=>H(de,{children:[V(`input`,{type:`checkbox`,disabled:r,"aria-label":e,checked:t.includes(e),onChange:t=>a(e,t.target.checked)}),e]},e))}),o.length>0?V(fe,{children:`Some listed models are no longer configured. They stay until you clear them.`}):null,t.length===0?V(u,{children:`With nothing selected this key is allowed no model.`}):null]})}var pe=U.p`
41
41
  font-size: 12px;
42
42
  color: ${({theme:e})=>e.color.down};
43
- `;function me({apiKey:e,onOpenChange:n}){let r=t(),i=o(),[a,l]=z(e?.modelAllowlist===null),[d,p]=z(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[h,g]=z(null),_=(i.data??[]).map(e=>e.id);return V(x,{open:e!==null,onOpenChange:n,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:H(B,{children:[V(c,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{e!==null&&(g(null),r.mutate({id:e.id,modelAllowlist:a?null:d},{onSuccess:()=>n(!1),onError:e=>g(m(e))}))},children:r.isPending?`Saving…`:`Save models`})]}),children:H(s,{$gap:3,children:[H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:a,label:`Allow every model`,onCheckedChange:e=>{l(e),e&&p([])}}),V(u,{as:`span`,children:`Allow every model`})]}),a?null:V(Q,{configured:_,checked:d,onChange:p,disabled:r.isPending})]}),h===null?null:V(pe,{role:`alert`,children:h})]})})}var he=U.div`
43
+ `;function me({apiKey:e,onOpenChange:n}){let i=t(),a=r(),[o,l]=z(e?.modelAllowlist===null),[d,p]=z(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[h,g]=z(null),_=(a.data??[]).map(e=>e.id);return V(x,{open:e!==null,onOpenChange:n,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:H(B,{children:[V(c,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:i.isPending,onClick:()=>{e!==null&&(g(null),i.mutate({id:e.id,modelAllowlist:o?null:d},{onSuccess:()=>n(!1),onError:e=>g(m(e))}))},children:i.isPending?`Saving…`:`Save models`})]}),children:H(s,{$gap:3,children:[H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:o,label:`Allow every model`,onCheckedChange:e=>{l(e),e&&p([])}}),V(u,{as:`span`,children:`Allow every model`})]}),o?null:V(Q,{configured:_,checked:d,onChange:p,disabled:i.isPending})]}),h===null?null:V(pe,{role:`alert`,children:h})]})})}var he=U.div`
44
44
  display: grid;
45
45
  grid-template-columns: minmax(0, 11rem) minmax(0, 12rem) minmax(0, 1fr) minmax(0, 3.5rem);
46
46
  align-items: center;
@@ -65,7 +65,7 @@ import{Nt as e,Pt as t,gt as n,j as r,kt as i,ot as a,xt as o}from"./Lamp-BHYJpa
65
65
  color: ${({theme:e})=>e.color.inkDim};
66
66
  `,Se=U(c)`
67
67
  gap: 4px;
68
- `;function Ce({open:e,onOpenChange:t}){let n=o(),r=a(),[i,l]=z(``),[d,p]=z(!0),[h,g]=z([]),[v,y]=z(()=>Y({})),[b,S]=z(!1),[C,w]=z(!1),[O,A]=z(null),[M,P]=z(null),F=()=>{l(``),p(!0),g([]),y(Y({})),S(!1),w(!1),A(null),P(null),r.reset()},I=e=>{e||F(),t(e)},L=Object.values(v).filter(e=>e.trim().length>0).length;return V(x,{open:e,onOpenChange:I,title:O===null?`Create an API key`:`Key created`,description:O===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:O===null?H(B,{children:[V(c,{type:`button`,onClick:()=>I(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{let e=X(v);if(`problem`in e){S(!0),P(e.problem);return}P(null),r.mutate({label:i.trim().length===0?`api key`:i.trim(),modelAllowlist:d?null:h,limits:e.limits,bodyLoggingOptOut:C},{onSuccess:e=>A(e),onError:e=>P(m(e))})},children:r.isPending?`Creating…`:`Create key`})]}):V(c,{type:`button`,$variant:`primary`,onClick:()=>I(!1),children:`I have copied the key`}),children:O===null?H(s,{$gap:3,children:[V(N,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>V(j,{...e,value:i,placeholder:`api key`,onChange:e=>l(e.target.value)})}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:d,label:`Allow every model`,onCheckedChange:p}),V(u,{as:`span`,children:`Allow every model`})]}),d?null:H(B,{children:[V(Q,{configured:(n.data??[]).map(e=>e.id),checked:h,onChange:g}),h.length===0?V(ye,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[H(Se,{type:`button`,$size:`sm`,"aria-expanded":b,onClick:()=>S(e=>!e),children:[V(b?E:D,{}),`Limits`]}),V(u,{as:`span`,children:L===0?`no limits; this key is unbounded`:`${L} limit${L===1?``:`s`} set`})]}),b?V(Z,{draft:v,onChange:y}):null]}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:C,label:`Never record this key's bodies`,onCheckedChange:w}),V(u,{as:`span`,children:`Never record this key's bodies`})]}),V(be,{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.`})]}),M===null?null:V(xe,{role:`alert`,children:M})]}):H(s,{$gap:3,children:[V($,{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.`}),V(T,{value:O.key,label:`Copy API key`}),H(f,{$gap:2,children:[V(u,{children:`Label`}),V(_,{children:O.label}),V(u,{children:`Prefix`}),V(_,{children:O.prefix})]})]})})}var we=U(f)`
68
+ `;function Ce({open:e,onOpenChange:t}){let n=r(),i=o(),[a,l]=z(``),[d,p]=z(!0),[h,g]=z([]),[v,y]=z(()=>Y({})),[b,S]=z(!1),[C,w]=z(!1),[O,A]=z(null),[M,P]=z(null),F=()=>{l(``),p(!0),g([]),y(Y({})),S(!1),w(!1),A(null),P(null),i.reset()},I=e=>{e||F(),t(e)},L=Object.values(v).filter(e=>e.trim().length>0).length;return V(x,{open:e,onOpenChange:I,title:O===null?`Create an API key`:`Key created`,description:O===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:O===null?H(B,{children:[V(c,{type:`button`,onClick:()=>I(!1),children:`Cancel`}),V(c,{type:`button`,$variant:`primary`,disabled:i.isPending,onClick:()=>{let e=X(v);if(`problem`in e){S(!0),P(e.problem);return}P(null),i.mutate({label:a.trim().length===0?`api key`:a.trim(),modelAllowlist:d?null:h,limits:e.limits,bodyLoggingOptOut:C},{onSuccess:e=>A(e),onError:e=>P(m(e))})},children:i.isPending?`Creating…`:`Create key`})]}):V(c,{type:`button`,$variant:`primary`,onClick:()=>I(!1),children:`I have copied the key`}),children:O===null?H(s,{$gap:3,children:[V(N,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>V(j,{...e,value:a,placeholder:`api key`,onChange:e=>l(e.target.value)})}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:d,label:`Allow every model`,onCheckedChange:p}),V(u,{as:`span`,children:`Allow every model`})]}),d?null:H(B,{children:[V(Q,{configured:(n.data??[]).map(e=>e.id),checked:h,onChange:g}),h.length===0?V(ye,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[H(Se,{type:`button`,$size:`sm`,"aria-expanded":b,onClick:()=>S(e=>!e),children:[V(b?E:D,{}),`Limits`]}),V(u,{as:`span`,children:L===0?`no limits; this key is unbounded`:`${L} limit${L===1?``:`s`} set`})]}),b?V(Z,{draft:v,onChange:y}):null]}),H(s,{$gap:2,children:[H(f,{$gap:2,children:[V(k,{checked:C,label:`Never record this key's bodies`,onCheckedChange:w}),V(u,{as:`span`,children:`Never record this key's bodies`})]}),V(be,{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.`})]}),M===null?null:V(xe,{role:`alert`,children:M})]}):H(s,{$gap:3,children:[V($,{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.`}),V(T,{value:O.key,label:`Copy API key`}),H(f,{$gap:2,children:[V(u,{children:`Label`}),V(_,{children:O.label}),V(u,{children:`Prefix`}),V(_,{children:O.prefix})]})]})})}var we=U(f)`
69
69
  gap: 4px;
70
70
  flex-wrap: wrap;
71
71
  max-width: 34ch;
@@ -79,4 +79,4 @@ import{Nt as e,Pt as t,gt as n,j as r,kt as i,ot as a,xt as o}from"./Lamp-BHYJpa
79
79
  flex-direction: column;
80
80
  align-items: flex-end;
81
81
  gap: 2px;
82
- `;function Oe(e){if(e===null)return`usage not counted here`;let t=J(e);return`${K({dimension:e.dimension,window:e.window})} ${q(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ke(){let e=n(),t=i(),[a,o]=z(!1),[s,m]=z(null),[_,b]=z(null),[x,T]=z(null),[k,j]=z(null),M=e.data??[],N=M.filter(e=>e.revokedAt===null),P=e.isLoading?`Reading issued keys…`:M.length===0?`No keys exist, so nothing can call this gateway yet.`:`${N.length} active key${N.length===1?``:`s`} of ${M.length} ever issued.`;return H(B,{children:[V(C,{legend:`Keys`,title:`Gateway API keys`,summary:P,actions:H(c,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[V(O,{}),`Create a key`]})}),V(g,{legend:`Issued keys`,meta:`${M.length}`,flush:!0,children:e.isError?V(p,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?V(`div`,{style:{padding:12},children:V(d,{rows:4})}):M.length===0?V(h,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:V(c,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):V(y,{children:H(ee,{children:[V(`thead`,{children:H(`tr`,{children:[V(L,{children:`Label`}),V(L,{children:`Prefix`}),V(L,{children:`Allowed models`}),V(L,{$align:`right`,children:`Limits`}),V(L,{$align:`right`,children:`Created`}),V(L,{children:`Body capture`}),V(L,{children:`Status`}),V(L,{})]})}),V(`tbody`,{children:M.map(e=>{let t=x===e.id,n=ie(e.limitUsage);return H(R,{children:[H(F,{children:[V(I,{children:V(v,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),H(I,{$mono:!0,children:[e.prefix,`…`]}),V(I,{children:e.modelAllowlist===null?V(u,{children:`every model`}):e.modelAllowlist.length===0?V(A,{$tone:`down`,children:`no models`}):V(we,{children:e.modelAllowlist.map(e=>V(A,{children:e},e))})}),V(I,{$align:`right`,children:e.limits===null?V(A,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?V(u,{children:`no limits`}):H(De,{children:[H(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),V(Ee,{children:Oe(n)})]})}),V(I,{$align:`right`,$mono:!0,children:r(e.createdAt)}),V(I,{children:e.bodyLoggingOptOut?V(A,{children:`no bodies`}):V(u,{children:`—`})}),V(I,{children:e.revokedAt===null?V(A,{$tone:`ok`,children:`active`}):V(Te,{title:r(e.revokedAt),children:V(A,{children:`revoked`})})}),V(I,{$align:`right`,children:H(f,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} limits for ${e.label}`,title:`${t?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>T(t?null:e.id),children:V(t?E:D,{})}),e.revokedAt===null?H(B,{children:[V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>b(e),children:V(te,{})}),V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>m(e),children:V(w,{})}),V(c,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>j(e),children:`Revoke`})]}):null]})})]}),t?V(F,{children:V(I,{colSpan:8,children:V(ve,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),V(Ce,{open:a,onOpenChange:o}),V(le,{apiKey:s,onOpenChange:e=>{e||m(null)}},s?.id??`none`),V(me,{apiKey:_,onOpenChange:e=>{e||b(null)}},_?.id??`none`),V(S,{open:k!==null,onOpenChange:e=>{e||j(null)},title:`Revoke key`,body:k===null?``:`Revoking "${k.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:t.isPending,onConfirm:()=>{k!==null&&t.mutate(k.id,{onSettled:()=>j(null)})}})]})}var Ae=ke;export{Ae as component};
82
+ `;function Oe(e){if(e===null)return`usage not counted here`;let t=J(e);return`${K({dimension:e.dimension,window:e.window})} ${q(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function ke(){let t=i(),n=e(),[r,o]=z(!1),[s,m]=z(null),[_,b]=z(null),[x,T]=z(null),[k,j]=z(null),M=t.data??[],N=M.filter(e=>e.revokedAt===null),P=t.isLoading?`Reading issued keys…`:M.length===0?`No keys exist, so nothing can call this gateway yet.`:`${N.length} active key${N.length===1?``:`s`} of ${M.length} ever issued.`;return H(B,{children:[V(C,{legend:`Keys`,title:`Gateway API keys`,summary:P,actions:H(c,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[V(O,{}),`Create a key`]})}),V(g,{legend:`Issued keys`,meta:`${M.length}`,flush:!0,children:t.isError?V(p,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?V(`div`,{style:{padding:12},children:V(d,{rows:4})}):M.length===0?V(h,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:V(c,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):V(y,{children:H(ee,{children:[V(`thead`,{children:H(`tr`,{children:[V(L,{children:`Label`}),V(L,{children:`Prefix`}),V(L,{children:`Allowed models`}),V(L,{$align:`right`,children:`Limits`}),V(L,{$align:`right`,children:`Created`}),V(L,{children:`Body capture`}),V(L,{children:`Status`}),V(L,{})]})}),V(`tbody`,{children:M.map(e=>{let t=x===e.id,n=ie(e.limitUsage);return H(R,{children:[H(F,{children:[V(I,{children:V(v,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),H(I,{$mono:!0,children:[e.prefix,`…`]}),V(I,{children:e.modelAllowlist===null?V(u,{children:`every model`}):e.modelAllowlist.length===0?V(A,{$tone:`down`,children:`no models`}):V(we,{children:e.modelAllowlist.map(e=>V(A,{children:e},e))})}),V(I,{$align:`right`,children:e.limits===null?V(A,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?V(u,{children:`no limits`}):H(De,{children:[H(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),V(Ee,{children:Oe(n)})]})}),V(I,{$align:`right`,$mono:!0,children:a(e.createdAt)}),V(I,{children:e.bodyLoggingOptOut?V(A,{children:`no bodies`}):V(u,{children:`—`})}),V(I,{children:e.revokedAt===null?V(A,{$tone:`ok`,children:`active`}):V(Te,{title:a(e.revokedAt),children:V(A,{children:`revoked`})})}),V(I,{$align:`right`,children:H(f,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} limits for ${e.label}`,title:`${t?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>T(t?null:e.id),children:V(t?E:D,{})}),e.revokedAt===null?H(B,{children:[V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>b(e),children:V(te,{})}),V(l,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>m(e),children:V(w,{})}),V(c,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>j(e),children:`Revoke`})]}):null]})})]}),t?V(F,{children:V(I,{colSpan:8,children:V(ve,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),V(Ce,{open:r,onOpenChange:o}),V(le,{apiKey:s,onOpenChange:e=>{e||m(null)}},s?.id??`none`),V(me,{apiKey:_,onOpenChange:e=>{e||b(null)}},_?.id??`none`),V(S,{open:k!==null,onOpenChange:e=>{e||j(null)},title:`Revoke key`,body:k===null?``:`Revoking "${k.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:()=>{k!==null&&n.mutate(k.id,{onSettled:()=>j(null)})}})]})}var Ae=ke;export{Ae as component};
@@ -1,4 +1,4 @@
1
- import{A as e,B as t,Et as n,bt as r,gt as i,l as a,lt as o,q as s,u as c}from"./Lamp-BHYJpauE.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-CYQvfI3L.js";import{_ as v,i as y,t as b}from"./Rack-CRuJZY00.js";import{t as x}from"./Chip-BZWa7onX.js";import{i as S,n as C}from"./Field-DK5zaBVA.js";import{i as w,n as T,r as E,t as D}from"./RequestTable-D9hFf4o5.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`
1
+ import{A as e,B as t,Dt as n,_t as r,l as i,q as a,u as o,ut as s,xt as c}from"./Lamp-CVGUT2YK.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-BlNr9j6-.js";import{_ as v,i as y,t as b}from"./Rack-BbZyyu2u.js";import{t as x}from"./Chip-shturdCv.js";import{i as S,n as C}from"./Field-DcNu4yw-.js";import{i as w,n as T,r as E,t as D}from"./RequestTable-huSAoNZg.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
2
  font-size: 12px;
3
3
  color: ${({theme:e})=>e.color.inkDim};
4
4
  max-width: 62ch;
@@ -55,4 +55,4 @@ import{A as e,B as t,Et as n,bt as r,gt as i,l as a,lt as o,q as s,u as c}from".
55
55
  flex: 1;
56
56
  min-height: 0;
57
57
  overflow-y: auto;
58
- `;function $(){let{cadence:n,live:l}=v(),[d,p]=k(100),[g,_]=k(`all`),[x,S]=k(``),[C,N]=k(null),P=r(d,n(t,`res:logs`)),F=o(),I=i(),L=s(),R=(P.data??[]).some(c),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(a).length,U=(P.data??[]).filter(c).length;return M(A,{children:[j(b,{legend:`Logs`,title:`Recent requests`,summary:P.isLoading?`Reading the request log…`:`${e(P.data?.length??0)} recent requests, ${e(H)} of them failed${U===0?``:`, ${e(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};
58
+ `;function $(){let{cadence:n,live:l}=v(),[d,p]=k(100),[g,_]=k(`all`),[x,S]=k(``),[C,N]=k(null),P=c(d,n(t,`res:logs`)),F=s(),I=r(),L=a(),R=(P.data??[]).some(o),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(i).length,U=(P.data??[]).filter(o).length;return M(A,{children:[j(b,{legend:`Logs`,title:`Recent requests`,summary:P.isLoading?`Reading the request log…`:`${e(P.data?.length??0)} recent requests, ${e(H)} of them failed${U===0?``:`, ${e(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,4 +1,4 @@
1
- import{At as e,E as t,H as n,It as r,ft as i,lt as a,mt as o,wt as s,xt as c}from"./Lamp-BHYJpauE.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-CYQvfI3L.js";import{b as S,m as C,r as w,t as T}from"./Rack-CRuJZY00.js";import{t as E}from"./plus-64jUPIDJ.js";import{t as D}from"./trash-2-rvGFhAn8.js";import{t as O}from"./Toggle-BIHUR4pS.js";import{n as ee,t as k}from"./Chip-BZWa7onX.js";import{i as A,n as j,r as M,t as N}from"./Field-DK5zaBVA.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`
1
+ import{E as e,H as t,Lt as n,St as r,Tt as i,ht as a,jt as o,pt as s,ut as c}from"./Lamp-CVGUT2YK.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-BlNr9j6-.js";import{b as S,m as C,r as w,t as T}from"./Rack-BbZyyu2u.js";import{t as E}from"./plus-BCf2TPqz.js";import{t as D}from"./trash-2-Bq4GaXzx.js";import{t as O}from"./Toggle-C84xs_YB.js";import{n as ee,t as k}from"./Chip-shturdCv.js";import{i as A,n as j,r as M,t as N}from"./Field-DcNu4yw-.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
2
  padding: ${({theme:e})=>e.space(2)} 0;
3
3
  border-bottom: 1px solid ${({theme:e})=>e.color.rule};
4
4
 
@@ -46,7 +46,7 @@ import{At as e,E as t,H as n,It as r,ft as i,lt as a,mt as o,wt as s,xt as c}fro
46
46
  `,me=z.p`
47
47
  font-size: 12px;
48
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}),[i,a]=F(null),[s,c]=F(null),d=r(),m=o(),g=d.data?.weights,S=()=>{e!==null&&(c(null),m.mutate({modelId:e,need:t},{onSuccess:e=>a(e),onError:e=>{a(null),c(_(e))}}))},C=new Map(B.map(e=>[e,Math.max(1e-4,...(i?.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`]})]})]}),s===null?null:L(me,{children:s}),i===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:i.strategy}),i.deterministic?null:L(k,{$tone:`warn`,children:`order varies per request`}),L(f,{}),R(p,{children:[i.candidates.length,` eligible · `,i.excluded.length,` filtered out`]})]}),i.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:i.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}`))}),i.excluded.length===0?null:R(l,{$gap:1,children:[L(p,{children:`Filtered out`}),L(`ul`,{children:i.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,r){return n(e,t)?.models.find(e=>e.id===r)}function W(e,t,r){let i=n(e,t);return i===void 0?null:i.models.find(e=>e.id===r)?.auth??i.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,r){let i=n(e,t);return i===void 0?[]:i.models.filter(n=>X(e,t,n.id,r))}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(e,n){let r={provider:e.provider,endpointId:e.endpointId};return n.filter(e=>t(r,e)).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 r=t??e[0]?.id??`anthropic`,i=n(e,r)?.defaultModel??``,a=J(e,r,i);return{key:q(),provider:r,endpointId:``,model:i,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`
49
+ `;function H(e,t,n){return(e[t]??0)*n[t]}function he({modelId:e}){let[t,r]=F({tools:!1,images:!1,reasoning:!1}),[i,o]=F(null),[s,c]=F(null),d=n(),m=a(),g=d.data?.weights,S=()=>{e!==null&&(c(null),m.mutate({modelId:e,need:t},{onSuccess:e=>o(e),onError:e=>{o(null),c(_(e))}}))},C=new Map(B.map(e=>[e,Math.max(1e-4,...(i?.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=>r({...t,tools:e})}),`Tools`]}),R(V,{children:[L(O,{checked:t.images,label:`Probe request includes an image`,onCheckedChange:e=>r({...t,images:e})}),`Images`]}),R(V,{children:[L(O,{checked:t.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>r({...t,reasoning:e})}),`Reasoning`]})]})]}),s===null?null:L(me,{children:s}),i===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:i.strategy}),i.deterministic?null:L(k,{$tone:`warn`,children:`order varies per request`}),L(f,{}),R(p,{children:[i.candidates.length,` eligible · `,i.excluded.length,` filtered out`]})]}),i.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:i.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}`))}),i.excluded.length===0?null:R(l,{$gap:1,children:[L(p,{children:`Filtered out`}),L(`ul`,{children:i.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,n,r){return t(e,n)?.models.find(e=>e.id===r)}function W(e,n,r){let i=t(e,n);return i===void 0?null:i.models.find(e=>e.id===r)?.auth??i.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,n,r){let i=t(e,n);return i===void 0?[]:i.models.filter(t=>X(e,n,t.id,r))}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,n){let r=n??e[0]?.id??`anthropic`,i=t(e,r)?.defaultModel??``,a=J(e,r,i);return{key:q(),provider:r,endpointId:``,model:i,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
50
  border: 1px solid ${({theme:e})=>e.color.rule};
51
51
  border-left: 3px solid ${({$provider:e})=>C(e)};
52
52
  border-radius: ${({theme:e})=>e.radius.control};
@@ -88,7 +88,7 @@ import{At as e,E as t,H as n,It as r,ft as i,lt as a,mt as o,wt as s,xt as c}fro
88
88
  align-items: center;
89
89
  gap: 6px;
90
90
  cursor: pointer;
91
- `;function Pe({target:e,index:t,onChange:r,onRemove:i,removable:a,catalog:o,endpoints:s,held:c,credentials:m}){let g=ne(),_=n(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,n)=>{r({...e,[t]:n})},C=J(o,e.provider,e.model),w=ge(o,e.provider,e.model),T=t=>{r(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:i,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 r=t.target.value,i=n(o,r),a=i?.models.some(t=>t.id===e.model)??!1;T({provider:r,model:a?e.model:i?.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=>r(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:()=>r({...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`
91
+ `;function Pe({target:e,index:n,onChange:r,onRemove:i,removable:a,catalog:o,endpoints:s,held:c,credentials:m}){let g=ne(),_=t(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,n)=>{r({...e,[t]:n})},C=J(o,e.provider,e.model),w=ge(o,e.provider,e.model),T=t=>{r(we(o,e,t))};return R(ke,{$provider:e.provider,children:[R(h,{$gap:2,children:[R(p,{as:`legend`,children:[`Target `,n+1]}),L(f,{}),L(d,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!a,"aria-label":`Remove target ${n+1}`,title:a?`Remove target ${n+1}`:`A model needs at least one target`,onClick:i,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:n=>{let r=n.target.value,i=t(o,r),a=i?.models.some(t=>t.id===e.model)??!1;T({provider:r,model:a?e.model:i?.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=>r(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:()=>r({...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 ${n+1} supports tools`,onCheckedChange:e=>S(`tools`,e)}),`Tools`]}),R(Q,{children:[L(O,{checked:e.images,label:`Target ${n+1} supports images`,onCheckedChange:e=>S(`images`,e)}),`Images`]}),R(Q,{children:[L(O,{checked:e.reasoning,label:`Target ${n+1} supports reasoning`,onCheckedChange:e=>S(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Fe=z.p`
92
92
  font-size: 11.5px;
93
93
  color: ${({theme:e})=>e.color.inkDim};
94
94
  `,Ie=z.p`
@@ -99,7 +99,7 @@ import{At as e,E as t,H as n,It as r,ft as i,lt as a,mt as o,wt as s,xt as c}fro
99
99
  color: ${({theme:e})=>e.color.ok};
100
100
  `,Re=z(h)`
101
101
  gap: 8px;
102
- `;function ze({model:t,onSaved:n,onDeleted:r}){let o=s().data??[],[c,d]=F(()=>t===null?Ee(o):De(t)),[m,g]=F(null),[v,b]=F(!1),[x,S]=F(!1),C=e(),T=i(),D=a(),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=t?.id??null;te(()=>{d(t===null?Ee(o):De(t)),g(null),b(!1)},[M]);let P=G.find(e=>e.id===c.strategy);return R(I,{children:[L(y,{legend:t===null?`New model`:`Edit model`,meta:t===null?void 0:t.id,actions:R(I,{children:[t===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),n(e.model.id)},onError:e=>g(_(e))})},children:C.isPending?`Saving…`:t===null?`Create model`:`Save changes`})]}),children:R(l,{$gap:3,children:[L(N,{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=>L(j,{...e,value:c.id,disabled:t!==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(o,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:o,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: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:T.isPending,onConfirm:()=>{t!==null&&T.mutate(t.id,{onSuccess:()=>{S(!1),r()},onError:e=>{S(!1),g(_(e))}})}})]})}var Be=z.div`
102
+ `;function ze({model:e,onSaved:t,onDeleted:n}){let r=i().data??[],[a,d]=F(()=>e===null?Ee(r):De(e)),[m,g]=F(null),[v,b]=F(!1),[x,S]=F(!1),C=o(),T=s(),D=c(),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(r):De(e)),g(null),b(!1)},[M]);let P=G.find(e=>e.id===a.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(a);if(!e.ok){g(e.problem);return}g(null),C.mutate(e.model,{onSuccess:()=>{b(!0),t(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:a.id,disabled:e!==null,placeholder:`fast`,onChange:e=>d({...a,id:e.target.value})})}),L(N,{label:`Routing strategy`,children:e=>L(A,{...e,value:a.strategy,onChange:e=>d({...a,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:a.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>d({...a,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({...a,targets:[...a.targets,Te(r,a.targets.at(-1)?.provider)]}),children:[L(E,{}),`Add target`]})]}),a.targets.map((e,t)=>L(Pe,{target:e,index:t,removable:a.targets.length>1,catalog:r,endpoints:k,held:ee,credentials:D.data??[],onChange:t=>d({...a,targets:a.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>d({...a,targets:a.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),n()},onError:e=>{S(!1),g(_(e))}})}})]})}var Be=z.div`
103
103
  display: grid;
104
104
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
105
105
  gap: ${({theme:e})=>e.space(4)};
@@ -145,4 +145,4 @@ import{At as e,E as t,H as n,It as r,ft as i,lt as a,mt as o,wt as s,xt as c}fro
145
145
  height: 3px;
146
146
  border-radius: 1px;
147
147
  background: ${({$provider:e})=>C(e)};
148
- `,$=`\0new`;function Ke(){let e=c(),[t,n]=F(null),r=e.data??[],i=t===$?null:r.find(e=>e.id===t)??null,a=t===$||t===null&&!e.isLoading&&r.length===0;te(()=>{t===null&&r.length!==0&&n(r[0]?.id??null)},[r,t]);let o=e.isLoading?`Reading configured models…`:r.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${r.length} model${r.length===1?``:`s`} routing to ${r.reduce((e,t)=>e+t.targets.length,0)} targets.`;return R(I,{children:[L(T,{legend:`Models`,title:`Virtual models`,summary:o,actions:R(u,{type:`button`,$variant:`primary`,onClick:()=>n($),children:[L(E,{}),`New model`]})}),R(Be,{children:[L(y,{legend:`Configured`,meta:`${r.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})}):r.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:r.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:[i===null&&!a?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:i,onSaved:t=>{n(t),e.refetch()},onDeleted:()=>{n(null),e.refetch()}}),L(he,{modelId:i?.id??null})]})]})]})}var qe=Ke;export{qe as component};
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};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/_app.plugins._pluginId-Dm48f3wz.js","assets/Lamp-CVGUT2YK.js","assets/Panel-BlNr9j6-.js","assets/preload-helper-Unv7FI91.js","assets/Rack-BbZyyu2u.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t,t as n}from"./preload-helper-Unv7FI91.js";var r=t(`/_app/plugins/$pluginId`)({component:e(()=>n(()=>import(`./_app.plugins._pluginId-Dm48f3wz.js`),__vite__mapDeps([0,1,2,3,4])),`component`)});export{r as t};
@@ -1,4 +1,4 @@
1
- import{Ct as e}from"./Lamp-BHYJpauE.js";import{t}from"./preload-helper-D2sCuvIY.js";import{C as n,a as r,c as i,d as a,f as o,i as s,l as c,r as l,t as u}from"./Panel-CYQvfI3L.js";import{t as d}from"./Rack-CRuJZY00.js";import{t as f}from"./_app.plugins._pluginId-ByykviWs.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(e){let t=w.get(e);if(t!==void 0)return t;let n={get:(t,n)=>c(C(e,t),n),post:(t,n)=>a(C(e,t),n),put:(t,n)=>o(C(e,t),n),del:t=>i(C(e,t))};return w.set(e,n),n}var E=h(e=>t(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
1
+ import{wt as e}from"./Lamp-CVGUT2YK.js";import{t}from"./preload-helper-Unv7FI91.js";import{C as n,a as r,c as i,d as a,f as o,i as s,l as c,r as l,t as u}from"./Panel-BlNr9j6-.js";import{t as d}from"./Rack-BbZyyu2u.js";import{t as f}from"./_app.plugins._pluginId-B9k5eqAt.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(e){let t=w.get(e);if(t!==void 0)return t;let n={get:(t,n)=>c(C(e,t),n),post:(t,n)=>a(C(e,t),n),put:(t,n)=>o(C(e,t),n),del:t=>i(C(e,t))};return w.set(e,n),n}var E=h(e=>t(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
2
2
  font-size: 13px;
3
3
  color: ${({theme:e})=>e.color.down};
4
4
  `,j=S.p`
@@ -1,4 +1,4 @@
1
- import{Bt as e,Ft as t,It as n,J as r,K as i,Mt as a,Y as o,xt as s}from"./Lamp-BHYJpauE.js";import{C as c,D as l,S as u,_ as d,a as f,b as p,g as m,h,i as g,o as _,t as v,v as y}from"./Panel-CYQvfI3L.js";import{t as ee}from"./Rack-CRuJZY00.js";import{t as b}from"./Toggle-BIHUR4pS.js";import{i as x,n as S,t as C}from"./Field-DK5zaBVA.js";import{t as te}from"./Meter-stpt3vQu.js";import{n as w}from"./reasons-Du1OBWAM.js";import{useEffect as ne,useId as T,useState as E}from"react";import{Fragment as D,jsx as O,jsxs as k}from"react/jsx-runtime";import A from"styled-components";var j=12,M=A.p`
1
+ import{It as e,J as t,K as n,Lt as r,Nt as i,St as a,Vt as o,Y as s}from"./Lamp-CVGUT2YK.js";import{C as c,D as l,S as u,_ as d,a as f,b as p,g as m,h,i as g,o as _,t as v,v as y}from"./Panel-BlNr9j6-.js";import{t as ee}from"./Rack-BbZyyu2u.js";import{t as b}from"./Toggle-C84xs_YB.js";import{i as x,n as S,t as C}from"./Field-DcNu4yw-.js";import{t as te}from"./Meter-stpt3vQu.js";import{n as w}from"./reasons-Du1OBWAM.js";import{useEffect as ne,useId as T,useState as E}from"react";import{Fragment as D,jsx as O,jsxs as k}from"react/jsx-runtime";import A from"styled-components";var j=12,M=A.p`
2
2
  font-size: 12px;
3
3
  color: ${({theme:e})=>e.color.inkDim};
4
4
  max-width: 62ch;
@@ -12,7 +12,7 @@ import{Bt as e,Ft as t,It as n,J as r,K as i,Mt as a,Y as o,xt as s}from"./Lamp-
12
12
  max-width: 320px;
13
13
  `,F=A(d)`
14
14
  color: ${({theme:e})=>e.color.inkDim};
15
- `;function I(){let e=o(),[t,n]=E(``),[r,i]=E(``),[a,s]=E(``),[u,d]=E(null);return k(c,{$gap:2,children:[O(F,{children:`Admin password`}),O(M,{children:`Changing this signs every session out, including this one.`}),k(P,{$gap:2,children:[O(C,{label:`Current password`,children:e=>O(S,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),O(C,{label:`New password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),O(C,{label:`Repeat new password`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:a,onChange:e=>s(e.target.value)})}),O(p,{$gap:2,children:O(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<j){d(`A password must be at least ${j} characters.`);return}if(r!==a){d(`The two new passwords do not match.`);return}d(null),e.mutate({current:t,password:r},{onSuccess:()=>w(`password-changed`),onError:e=>d(_(e))})},disabled:e.isPending||t.length===0||r.length===0,children:`Change password`})})]}),u===null?null:O(N,{role:`alert`,children:u})]})}function L(){let n=e(),r=t(),[i,a]=E(``),[o,s]=E(null),[u,d]=E(null),f=n.data?.viewerConfigured===!0;return k(c,{$gap:2,children:[O(F,{children:`Read-only password`}),k(M,{children:[`Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies.`,` `,n.isPending?`Checking whether one is set…`:f?`One is set. A new one replaces it; withdrawing ends read-only sessions at once.`:`None is set, so nobody can sign in read-only. There is no default password.`]}),k(P,{$gap:2,children:[O(C,{label:f?`Replace read-only password`:`Set read-only password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:i,onChange:e=>a(e.target.value)})}),k(p,{$gap:2,children:[O(l,{type:`button`,$variant:`primary`,onClick:()=>{if(i.length<j){s(`A password must be at least ${j} characters.`);return}s(null),r.mutate(i,{onSuccess:()=>{a(``),d(f?`Read-only password replaced.`:`Read-only access granted.`)},onError:e=>s(_(e))})},disabled:r.isPending||i.length===0,children:f?`Replace`:`Set`}),f?O(l,{type:`button`,$variant:`danger`,onClick:()=>{s(null),r.mutate(null,{onSuccess:()=>d(`Read-only access withdrawn.`),onError:e=>s(_(e))})},disabled:r.isPending,children:`Withdraw access`}):null]})]}),o===null?null:O(N,{role:`alert`,children:o}),u===null||o!==null?null:O(re,{role:`status`,children:u})]})}function R(){return O(v,{legend:`Access`,children:k(c,{$gap:3,children:[O(I,{}),O(h,{}),O(L,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],ie=A(y)`
15
+ `;function I(){let e=s(),[t,n]=E(``),[r,i]=E(``),[a,o]=E(``),[u,d]=E(null);return k(c,{$gap:2,children:[O(F,{children:`Admin password`}),O(M,{children:`Changing this signs every session out, including this one.`}),k(P,{$gap:2,children:[O(C,{label:`Current password`,children:e=>O(S,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),O(C,{label:`New password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),O(C,{label:`Repeat new password`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:a,onChange:e=>o(e.target.value)})}),O(p,{$gap:2,children:O(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<j){d(`A password must be at least ${j} characters.`);return}if(r!==a){d(`The two new passwords do not match.`);return}d(null),e.mutate({current:t,password:r},{onSuccess:()=>w(`password-changed`),onError:e=>d(_(e))})},disabled:e.isPending||t.length===0||r.length===0,children:`Change password`})})]}),u===null?null:O(N,{role:`alert`,children:u})]})}function L(){let t=o(),n=e(),[r,i]=E(``),[a,s]=E(null),[u,d]=E(null),f=t.data?.viewerConfigured===!0;return k(c,{$gap:2,children:[O(F,{children:`Read-only password`}),k(M,{children:[`Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies.`,` `,t.isPending?`Checking whether one is set…`:f?`One is set. A new one replaces it; withdrawing ends read-only sessions at once.`:`None is set, so nobody can sign in read-only. There is no default password.`]}),k(P,{$gap:2,children:[O(C,{label:f?`Replace read-only password`:`Set read-only password`,hint:`At least ${j} characters.`,children:e=>O(S,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),k(p,{$gap:2,children:[O(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<j){s(`A password must be at least ${j} characters.`);return}s(null),n.mutate(r,{onSuccess:()=>{i(``),d(f?`Read-only password replaced.`:`Read-only access granted.`)},onError:e=>s(_(e))})},disabled:n.isPending||r.length===0,children:f?`Replace`:`Set`}),f?O(l,{type:`button`,$variant:`danger`,onClick:()=>{s(null),n.mutate(null,{onSuccess:()=>d(`Read-only access withdrawn.`),onError:e=>s(_(e))})},disabled:n.isPending,children:`Withdraw access`}):null]})]}),a===null?null:O(N,{role:`alert`,children:a}),u===null||a!==null?null:O(re,{role:`status`,children:u})]})}function R(){return O(v,{legend:`Access`,children:k(c,{$gap:3,children:[O(I,{}),O(h,{}),O(L,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],ie=A(y)`
16
16
  display: block;
17
17
  white-space: pre;
18
18
  overflow-x: auto;
@@ -34,7 +34,7 @@ import{Bt as e,Ft as t,It as n,J as r,K as i,Mt as a,Y as o,xt as s}from"./Lamp-
34
34
  display: grid;
35
35
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
36
36
  gap: ${({theme:e})=>e.space(2)};
37
- `,se=[{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 V(){let[e,t]=E(`claude`),[n,r]=E(()=>({claude:{},opencode:{}})),a=s(),o=n[e],u=typeof o.defaultModel==`string`&&o.defaultModel!==``?o:void 0,d=i(e,u),m=z.find(t=>t.id===e);return O(v,{legend:`Agent setup`,children:k(c,{children:[O(p,{children:z.map(n=>O(l,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),k(B,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,k(y,{children:[`omni setup `,e]}),` to write these files directly.`]}),(a.data?.length??0)>0?O(oe,{children:se.map(t=>O(C,{label:t.label,children:n=>k(x,{...n,value:o[t.key]??``,onChange:n=>r(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[O(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),a.data?.map(e=>O(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,a.isLoading?O(f,{rows:2}):d.isError?O(g,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?O(f,{rows:4}):(a.data?.length??0)===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?k(B,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>k(`div`,{children:[O(ae,{children:e.path}),O(ie,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?O(B,{children:_(d.error)}):null]})})}var H={off:`Off`,lite:`Lite — names the lazier option`,full:`Full — the ladder enforced`,ultra:`Ultra — challenges the requirement`},U=[{id:`tier`,label:`Tier`,blurb:`Prefers a lower tier.`},{id:`health`,label:`Health`,blurb:`Penalises recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Prefers accounts ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Prefers the cheaper candidate.`},{id:`latency`,label:`Latency`,blurb:`Prefers the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Prefers accounts with fewer requests in flight.`}],W=[{id:`maxAttempts`,label:`Attempts per request`,hint:`Candidates dispatch may try. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`Across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures before an account and model leaves rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Wait before a tripped account is probed. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before pruning.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often a provider is asked for remaining quota. 0 disables. Needs a restart.`,unit:`ms`,step:6e4,min:0}],G=A.div`
37
+ `,se=[{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 V(){let[e,t]=E(`claude`),[r,i]=E(()=>({claude:{},opencode:{}})),o=a(),s=r[e],u=typeof s.defaultModel==`string`&&s.defaultModel!==``?s:void 0,d=n(e,u),m=z.find(t=>t.id===e);return O(v,{legend:`Agent setup`,children:k(c,{children:[O(p,{children:z.map(n=>O(l,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),k(B,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,k(y,{children:[`omni setup `,e]}),` to write these files directly.`]}),(o.data?.length??0)>0?O(oe,{children:se.map(t=>O(C,{label:t.label,children:n=>k(x,{...n,value:s[t.key]??``,onChange:n=>i(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[O(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),o.data?.map(e=>O(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,o.isLoading?O(f,{rows:2}):d.isError?O(g,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?O(f,{rows:4}):(o.data?.length??0)===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?k(B,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?O(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>k(`div`,{children:[O(ae,{children:e.path}),O(ie,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?O(B,{children:_(d.error)}):null]})})}var H={off:`Off`,lite:`Lite — names the lazier option`,full:`Full — the ladder enforced`,ultra:`Ultra — challenges the requirement`},U=[{id:`tier`,label:`Tier`,blurb:`Prefers a lower tier.`},{id:`health`,label:`Health`,blurb:`Penalises recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Prefers accounts ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Prefers the cheaper candidate.`},{id:`latency`,label:`Latency`,blurb:`Prefers the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Prefers accounts with fewer requests in flight.`}],W=[{id:`maxAttempts`,label:`Attempts per request`,hint:`Candidates dispatch may try. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`Across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures before an account and model leaves rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Wait before a tripped account is probed. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before pruning.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often a provider is asked for remaining quota. 0 disables. Needs a restart.`,unit:`ms`,step:6e4,min:0}],G=A.div`
38
38
  display: grid;
39
39
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
40
40
  gap: ${({theme:e})=>e.space(3)};
@@ -85,4 +85,4 @@ import{Bt as e,Ft as t,It as n,J as r,K as i,Mt as a,Y as o,xt as s}from"./Lamp-
85
85
  code {
86
86
  font-family: ${({theme:e})=>e.font.mono};
87
87
  }
88
- `;function fe(e){let t={};for(let n of U)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of W)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.ponytailMode=e.ponytailMode,t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function pe(e){let t={};for(let n of U){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 W){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`,autoCacheEnabled:e.autoCacheEnabled===`true`,ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(H,e.ponytailMode)?e.ponytailMode:`off`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function me(){let e=n(),t=r(),i=a(),[o,s]=E({}),[h,b]=E(null),[w,T]=E(!1);ne(()=>{e.data!==void 0&&s(fe(e.data))},[e.data]);let A=Math.max(1e-4,...U.map(e=>Math.abs(Number(o[`w.${e.id}`])||0)));return k(D,{children:[O(ee,{legend:`Settings`,title:`Routing and retention`,summary:`Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.`,actions:O(l,{type:`button`,$variant:`primary`,disabled:i.isPending||e.isLoading,onClick:()=>{T(!1);let e=pe(o);if(!e.ok){b(e.problem);return}b(null),i.mutate(e.settings,{onSuccess:()=>T(!0),onError:e=>b(_(e))})},children:i.isPending?`Saving…`:`Save changes`})}),e.isError?O(v,{legend:`Settings`,children:O(g,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?O(v,{legend:`Settings`,children:O(f,{rows:6})}):k(c,{$gap:4,children:[O(v,{legend:`Scoring weights`,meta:`relative to each other`,footer:k(p,{children:[O(d,{children:`Score is the sum of each term times its weight, then multiplied by the account and target weights.`}),O(u,{})]}),children:O(G,{children:U.map(e=>{let t=Number(o[`w.${e.id}`])||0;return k(K,{children:[O(C,{label:e.label,children:t=>O(S,{...t,type:`number`,step:.5,value:o[`w.${e.id}`]??``,onChange:t=>s({...o,[`w.${e.id}`]:t.target.value})})}),O(te,{fraction:Math.abs(t)/A,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),O(q,{children:e.blurb})]},e.id)})})}),O(v,{legend:`Limits`,children:O(G,{children:W.map(e=>O(K,{children:O(C,{label:e.label,hint:e.hint,children:t=>k(p,{$gap:2,children:[O(S,{...t,type:`number`,min:e.min,step:e.step,value:o[e.id]??``,onChange:t=>s({...o,[e.id]:t.target.value})}),O(d,{children:e.unit})]})})},e.id))})}),k(m,{$min:`380px`,$stretch:!0,children:[O(v,{legend:`Request handling`,meta:`applied before dispatch`,children:k(J,{children:[O(Q,{label:`Enable RTK compression`,checked:o.rtkEnabled===`true`,onCheckedChange:e=>s({...o,rtkEnabled:String(e)}),children:`Compresses recognized historical tool results. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a detector recognizes shell output. Lossy.`}),O(Q,{label:`Add a cache breakpoint when a client sends none`,checked:o.autoCacheEnabled===`true`,onCheckedChange:e=>s({...o,autoCacheEnabled:String(e)}),children:`Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched.`}),O(le,{label:`Lazy senior dev mode`,blurb:`Appends the ponytail ruleset, about 1,240 tokens, to every system prompt. A request already carrying it is left alone.`,children:e=>O(x,{...e,value:o.ponytailMode??`off`,onChange:e=>s({...o,ponytailMode:e.target.value}),children:Object.entries(H).map(([e,t])=>O(`option`,{value:e,children:t},e))})})]})}),O(v,{legend:`Request and response bodies`,meta:t.data===!0?`permitted by the environment`:`not permitted`,children:k(c,{$gap:2,children:[t.data===!0?null:k(de,{children:[`This gateway started without `,O(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,O(`code`,{children:`.env`}),` and restart first.`]}),k(J,{children:[O(Q,{label:`Capture request and response bodies`,checked:o.bodyLoggingEnabled===`true`,disabled:t.data!==!0,onCheckedChange:e=>s({...o,bodyLoggingEnabled:String(e)}),children:`Stores what each client sent and each provider returned, encrypted beside the database. Tokens and keys are masked; headers are never captured. Expires on the log retention window above.`}),O(Q,{label:`Also keep raw stream frames`,checked:o.bodyLoggingCaptureStreamChunks===`true`,disabled:t.data!==!0||o.bodyLoggingEnabled!==`true`,onCheckedChange:e=>s({...o,bodyLoggingCaptureStreamChunks:String(e)}),children:`Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores.`})]})]})})]}),h===null?null:O($,{role:`alert`,children:h}),w&&h===null?O(ue,{role:`status`,children:`Settings saved.`}):null,k(m,{$min:`380px`,$stretch:!0,children:[O(V,{}),O(R,{})]}),O(v,{legend:`Known limits`,children:k(c,{$gap:2,children:[k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`rate limits`}),O(q,{children:`Counted per gateway process and reset when it restarts. Not shared across instances.`})]}),k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`logs`}),O(q,{children:`Request rows record routing and token counts only. Prompts and responses only when body capture is on, to a separate encrypted store. Credentials to neither.`})]})]})})]})]})}var he=me;export{he as component};
88
+ `;function fe(e){let t={};for(let n of U)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of W)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.ponytailMode=e.ponytailMode,t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function pe(e){let t={};for(let n of U){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 W){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`,autoCacheEnabled:e.autoCacheEnabled===`true`,ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(H,e.ponytailMode)?e.ponytailMode:`off`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function me(){let e=r(),n=t(),a=i(),[o,s]=E({}),[h,b]=E(null),[w,T]=E(!1);ne(()=>{e.data!==void 0&&s(fe(e.data))},[e.data]);let A=Math.max(1e-4,...U.map(e=>Math.abs(Number(o[`w.${e.id}`])||0)));return k(D,{children:[O(ee,{legend:`Settings`,title:`Routing and retention`,summary:`Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.`,actions:O(l,{type:`button`,$variant:`primary`,disabled:a.isPending||e.isLoading,onClick:()=>{T(!1);let e=pe(o);if(!e.ok){b(e.problem);return}b(null),a.mutate(e.settings,{onSuccess:()=>T(!0),onError:e=>b(_(e))})},children:a.isPending?`Saving…`:`Save changes`})}),e.isError?O(v,{legend:`Settings`,children:O(g,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?O(v,{legend:`Settings`,children:O(f,{rows:6})}):k(c,{$gap:4,children:[O(v,{legend:`Scoring weights`,meta:`relative to each other`,footer:k(p,{children:[O(d,{children:`Score is the sum of each term times its weight, then multiplied by the account and target weights.`}),O(u,{})]}),children:O(G,{children:U.map(e=>{let t=Number(o[`w.${e.id}`])||0;return k(K,{children:[O(C,{label:e.label,children:t=>O(S,{...t,type:`number`,step:.5,value:o[`w.${e.id}`]??``,onChange:t=>s({...o,[`w.${e.id}`]:t.target.value})})}),O(te,{fraction:Math.abs(t)/A,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),O(q,{children:e.blurb})]},e.id)})})}),O(v,{legend:`Limits`,children:O(G,{children:W.map(e=>O(K,{children:O(C,{label:e.label,hint:e.hint,children:t=>k(p,{$gap:2,children:[O(S,{...t,type:`number`,min:e.min,step:e.step,value:o[e.id]??``,onChange:t=>s({...o,[e.id]:t.target.value})}),O(d,{children:e.unit})]})})},e.id))})}),k(m,{$min:`380px`,$stretch:!0,children:[O(v,{legend:`Request handling`,meta:`applied before dispatch`,children:k(J,{children:[O(Q,{label:`Enable RTK compression`,checked:o.rtkEnabled===`true`,onCheckedChange:e=>s({...o,rtkEnabled:String(e)}),children:`Compresses recognized historical tool results. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a detector recognizes shell output. Lossy.`}),O(Q,{label:`Add a cache breakpoint when a client sends none`,checked:o.autoCacheEnabled===`true`,onCheckedChange:e=>s({...o,autoCacheEnabled:String(e)}),children:`Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched.`}),O(le,{label:`Lazy senior dev mode`,blurb:`Appends the ponytail ruleset, about 1,240 tokens, to every system prompt. A request already carrying it is left alone.`,children:e=>O(x,{...e,value:o.ponytailMode??`off`,onChange:e=>s({...o,ponytailMode:e.target.value}),children:Object.entries(H).map(([e,t])=>O(`option`,{value:e,children:t},e))})})]})}),O(v,{legend:`Request and response bodies`,meta:n.data===!0?`permitted by the environment`:`not permitted`,children:k(c,{$gap:2,children:[n.data===!0?null:k(de,{children:[`This gateway started without `,O(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,O(`code`,{children:`.env`}),` and restart first.`]}),k(J,{children:[O(Q,{label:`Capture request and response bodies`,checked:o.bodyLoggingEnabled===`true`,disabled:n.data!==!0,onCheckedChange:e=>s({...o,bodyLoggingEnabled:String(e)}),children:`Stores what each client sent and each provider returned, encrypted beside the database. Tokens and keys are masked; headers are never captured. Expires on the log retention window above.`}),O(Q,{label:`Also keep raw stream frames`,checked:o.bodyLoggingCaptureStreamChunks===`true`,disabled:n.data!==!0||o.bodyLoggingEnabled!==`true`,onCheckedChange:e=>s({...o,bodyLoggingCaptureStreamChunks:String(e)}),children:`Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores.`})]})]})})]}),h===null?null:O($,{role:`alert`,children:h}),w&&h===null?O(ue,{role:`status`,children:`Settings saved.`}):null,k(m,{$min:`380px`,$stretch:!0,children:[O(V,{}),O(R,{})]}),O(v,{legend:`Known limits`,children:k(c,{$gap:2,children:[k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`rate limits`}),O(q,{children:`Counted per gateway process and reset when it restarts. Not shared across instances.`})]}),k(p,{$gap:2,$align:`start`,children:[O(y,{$dim:!0,children:`logs`}),O(q,{children:`Request rows record routing and token counts only. Prompts and responses only when body capture is on, to a separate encrypted store. Credentials to neither.`})]})]})})]})]})}var he=me;export{he as component};