omnigateway 0.11.4 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +3 -1
  2. package/bin/omni.js +793 -60
  3. package/gateway.js +670 -91
  4. package/package.json +1 -1
  5. package/public/assets/{Chip-roGX6zyg.js → Chip-D4qvhu1D.js} +1 -1
  6. package/public/assets/{CopyValue-FO5yNkRC.js → CopyValue-SnsT2LML.js} +1 -1
  7. package/public/assets/Lamp-DkvXKB-B.js +26 -0
  8. package/public/assets/Rack-CEuCdVXc.js +483 -0
  9. package/public/assets/RequestTable-CSQGt9W_.js +93 -0
  10. package/public/assets/{SummaryDeck-DwRGp7mB.js → SummaryDeck-7ivuca39.js} +1 -1
  11. package/public/assets/Toggle-t82IhqEt.js +39 -0
  12. package/public/assets/{TokenBreakdown-DT7or6C9.js → TokenBreakdown-D1Wtza1y.js} +1 -1
  13. package/public/assets/{WindowChart-C-oJo3fW.js → WindowChart-BeGPsccS.js} +1 -1
  14. package/public/assets/_app.accounts-W1USUo2Q.js +70 -0
  15. package/public/assets/{_app.console-DbM7Zbgu.js → _app.console-BvIGqIe7.js} +2 -2
  16. package/public/assets/{_app.database-Bj4UJUBZ.js → _app.database-CtFJLcfE.js} +4 -4
  17. package/public/assets/_app.index-DigYfob3.js +67 -0
  18. package/public/assets/{_app.keys-BYk7HsiW.js → _app.keys-B1fRMyU-.js} +6 -6
  19. package/public/assets/_app.logs-D73Qcx9S.js +60 -0
  20. package/public/assets/{_app.models-BqdGSdg4.js → _app.models-Dpl1O2RE.js} +9 -9
  21. package/public/assets/{_app.plugins._pluginId-Bf9D8Qiz.js → _app.plugins._pluginId-BNrRTn9l.js} +1 -1
  22. package/public/assets/{_app.settings-TzCc7Sd3.js → _app.settings-tRLrVJoq.js} +4 -4
  23. package/public/assets/_app.usage-D2qlcEp4.js +76 -0
  24. package/public/assets/chevron-down-Bs0tSOyA.js +1 -0
  25. package/public/assets/chevron-right-DSaI1kFo.js +1 -0
  26. package/public/assets/client-BZ_ev12J.js +39 -0
  27. package/public/assets/dist-D03q-60i.js +1 -0
  28. package/public/assets/index-89mqAVmK.js +14 -0
  29. package/public/assets/{login-Dgd5jBoq.js → login-75MYwRdC.js} +2 -2
  30. package/public/assets/plus-BCfjC6nk.js +1 -0
  31. package/public/assets/{preload-helper-CvG2RSKd.js → preload-helper-BPaHpbO_.js} +1 -1
  32. package/public/assets/{shared-wEQ9LHZa.js → shared-Dtkw6SE0.js} +1 -1
  33. package/public/assets/{trash-IE0YvGCJ.js → trash-D4QWzEK_.js} +1 -1
  34. package/public/index.html +4 -4
  35. package/public/assets/Lamp-DsUSnxN4.js +0 -26
  36. package/public/assets/Rack-CSpeYQ1D.js +0 -483
  37. package/public/assets/RequestTable-xpG3dPST.js +0 -11
  38. package/public/assets/Toggle-BTJVC9Se.js +0 -39
  39. package/public/assets/_app.accounts-D8eynNaM.js +0 -59
  40. package/public/assets/_app.index-2hdPR1Le.js +0 -67
  41. package/public/assets/_app.logs-sG1w9y1i.js +0 -58
  42. package/public/assets/_app.usage-XQHmzx-j.js +0 -76
  43. package/public/assets/chevron-right-DgdKbG-g.js +0 -1
  44. package/public/assets/client-B_g7bcxd.js +0 -39
  45. package/public/assets/index-C_8ChaGY.js +0 -14
  46. package/public/assets/plus-UgaZwucC.js +0 -1
@@ -1,10 +1,10 @@
1
- import{Lt as e,M as t,Nt as n,Rt as r,Tt as i,bt as a,lt as o,w as s,zt as c}from"./Lamp-DsUSnxN4.js";import{C as l,D as u,O as d,_ as f,a as p,b as m,i as h,o as g,r as _,t as v,v as y,w as b,x}from"./Panel-CWmOTDAP.js";import{b as S,i as C,r as w,t as T,v as E}from"./Rack-CSpeYQ1D.js";import{t as ee}from"./CopyValue-FO5yNkRC.js";import{n as D,t as O}from"./chevron-right-DgdKbG-g.js";import{t as k}from"./plus-UgaZwucC.js";import{t as A}from"./Toggle-BTJVC9Se.js";import{t as j}from"./Chip-roGX6zyg.js";import{n as M,r as N,t as P}from"./Field-BYBri2NV.js";import{t as F}from"./Meter-stpt3vQu.js";import{i as I,n as L,r as R,t as te}from"./Table-CVDZ69Zx.js";import{Fragment as z,useState as B}from"react";import{Fragment as V,jsx as H,jsxs as U}from"react/jsx-runtime";import W from"styled-components";var G={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};G.node;var ne=S(G),K={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};K.node;var re=S(K);function q(e,t){return e.revokedAt===null?s(e,t)?`active`:`expired`:`revoked`}function ie(e){if(e===null)return``;let t=new Date(e-new Date(e).getTimezoneOffset()*6e4);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16)}function ae(e){let t=e.trim();if(t.length===0)return{at:null};let n=new Date(t).getTime();return Number.isFinite(n)?{at:n}:{problem:`"${e}" is not a date`}}var oe=W.p`
1
+ import{Ct as e,Ht as t,M as n,Rt as r,Ut as i,Wt as a,dt as o,kt as s,w as c}from"./Lamp-DkvXKB-B.js";import{C as l,D as u,O as d,_ as f,a as p,b as m,i as h,o as g,r as _,t as v,v as y,w as b,x}from"./Panel-CWmOTDAP.js";import{A as S,O as C,i as w,r as T,t as E}from"./Rack-CEuCdVXc.js";import{t as ee}from"./CopyValue-SnsT2LML.js";import{t as D}from"./chevron-down-Bs0tSOyA.js";import{t as O}from"./chevron-right-DSaI1kFo.js";import{t as k}from"./plus-BCfjC6nk.js";import{t as A}from"./Toggle-t82IhqEt.js";import{t as j}from"./Chip-D4qvhu1D.js";import{n as M,r as N,t as P}from"./Field-BYBri2NV.js";import{t as F}from"./Meter-stpt3vQu.js";import{i as I,n as L,r as R,t as te}from"./Table-CVDZ69Zx.js";import{Fragment as z,useState as B}from"react";import{Fragment as V,jsx as H,jsxs as U}from"react/jsx-runtime";import W from"styled-components";var G={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};G.node;var ne=S(G),K={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};K.node;var re=S(K);function q(e,t){return e.revokedAt===null?c(e,t)?`active`:`expired`:`revoked`}function ie(e){if(e===null)return``;let t=new Date(e-new Date(e).getTimezoneOffset()*6e4);return Number.isNaN(t.getTime())?``:t.toISOString().slice(0,16)}function ae(e){let t=e.trim();if(t.length===0)return{at:null};let n=new Date(t).getTime();return Number.isFinite(n)?{at:n}:{problem:`"${e}" is not a date`}}var oe=W.p`
2
2
  font-size: 12px;
3
3
  color: ${({theme:e})=>e.color.down};
4
4
  `,se=W.p`
5
5
  font-size: 12px;
6
6
  color: ${({theme:e})=>e.color.warn};
7
- `;function ce({apiKey:t,onOpenChange:n}){let r=e(),[i,a]=B(()=>ie(t?.expiresAt??null)),[o,s]=B(null),c=()=>{if(t===null)return;let e=ae(i);if(`problem`in e){s(e.problem);return}s(null),r.mutate({id:t.id,expiresAt:e.at},{onSuccess:()=>n(!1),onError:e=>s(g(e))})},d=t!==null&&q(t,Date.now())===`expired`;return H(C,{open:t!==null,onOpenChange:n,title:`Edit expiry`,description:t===null?void 0:`When "${t.label}" stops being accepted. Leave it blank for never.`,width:`480px`,footer:U(V,{children:[H(u,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:c,children:r.isPending?`Saving…`:`Save expiry`})]}),children:U(l,{$gap:3,children:[d?H(se,{role:`status`,children:`This key has expired and the gateway is refusing it. Moving the date forward, or clearing it, brings it back.`}):null,H(P,{label:`Expires`,hint:`Your local time. Blank means the key never expires; a date already past expires it now.`,children:e=>H(M,{...e,type:`datetime-local`,value:i,disabled:r.isPending,onChange:e=>a(e.target.value)})}),o===null?null:H(oe,{role:`alert`,children:o})]})})}var J=[{dimension:`requests`,window:`1m`},{dimension:`requests`,window:`5h`},{dimension:`requests`,window:`1w`},{dimension:`tokens`,window:`1m`},{dimension:`tokens`,window:`5h`},{dimension:`tokens`,window:`1w`},{dimension:`spend`,window:`5h`},{dimension:`spend`,window:`1w`},{dimension:`concurrency`,window:null}];function Y(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var le={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},ue={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function X(e){let t=le[e.dimension];return e.window===null?t:`${t} ${ue[e.window]}`}function Z(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function Q(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function de(e){let t=null,n=-1;for(let r of e){let e=Q(r);e!==null&&e>n&&(t=r,n=e)}return t}function $(e){let t={};for(let e of J)t[Y(e)]=``;if(e===null)return t;for(let n of J){let r=n.window===null?e.concurrency:n.dimension===`requests`?e.requests?.[n.window]:n.dimension===`tokens`?e.tokens?.[n.window]:n.window===`1m`?void 0:e.spend?.[n.window];r!=null&&(t[Y(n)]=String(r))}return t}function fe(e){let t={},n={},r={},i;for(let a of J){let o=(e[Y(a)]??``).trim();if(o.length===0)continue;let s=Number(o),c=a.dimension===`spend`;if(!Number.isFinite(s)||s<=0||!c&&!Number.isInteger(s))return{problem:c?`${X(a)} must be an amount above zero, or blank for no limit.`:`${X(a)} must be a whole number above zero, or blank for no limit.`};a.window===null?i=s:a.dimension===`requests`?t[a.window]=s:a.dimension===`tokens`?n[a.window]=s:a.window!==`1m`&&(r[a.window]=s)}return{limits:{...Object.keys(t).length>0?{requests:t}:{},...Object.keys(n).length>0?{tokens:n}:{},...Object.keys(r).length>0?{spend:r}:{},...i===void 0?{}:{concurrency:i}}}}var pe=W.div`
7
+ `;function ce({apiKey:e,onOpenChange:n}){let r=t(),[i,a]=B(()=>ie(e?.expiresAt??null)),[o,s]=B(null),c=()=>{if(e===null)return;let t=ae(i);if(`problem`in t){s(t.problem);return}s(null),r.mutate({id:e.id,expiresAt:t.at},{onSuccess:()=>n(!1),onError:e=>s(g(e))})},d=e!==null&&q(e,Date.now())===`expired`;return H(w,{open:e!==null,onOpenChange:n,title:`Edit expiry`,description:e===null?void 0:`When "${e.label}" stops being accepted. Leave it blank for never.`,width:`480px`,footer:U(V,{children:[H(u,{type:`button`,onClick:()=>n(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:c,children:r.isPending?`Saving…`:`Save expiry`})]}),children:U(l,{$gap:3,children:[d?H(se,{role:`status`,children:`This key has expired and the gateway is refusing it. Moving the date forward, or clearing it, brings it back.`}):null,H(P,{label:`Expires`,hint:`Your local time. Blank means the key never expires; a date already past expires it now.`,children:e=>H(M,{...e,type:`datetime-local`,value:i,disabled:r.isPending,onChange:e=>a(e.target.value)})}),o===null?null:H(oe,{role:`alert`,children:o})]})})}var J=[{dimension:`requests`,window:`1m`},{dimension:`requests`,window:`5h`},{dimension:`requests`,window:`1w`},{dimension:`tokens`,window:`1m`},{dimension:`tokens`,window:`5h`},{dimension:`tokens`,window:`1w`},{dimension:`spend`,window:`5h`},{dimension:`spend`,window:`1w`},{dimension:`concurrency`,window:null}];function Y(e){return e.window===null?e.dimension:`${e.dimension}:${e.window}`}var le={requests:`Requests`,tokens:`Tokens`,spend:`Spend`,concurrency:`Concurrent`},ue={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function X(e){let t=le[e.dimension];return e.window===null?t:`${t} ${ue[e.window]}`}function Z(e,t){return e===`spend`?`$${t<1?t.toFixed(4):t.toFixed(2)}`:t.toLocaleString(`en-US`)}function Q(e){return e.used===null||e.limit<=0?null:Math.max(0,e.used/e.limit)}function de(e){let t=null,n=-1;for(let r of e){let e=Q(r);e!==null&&e>n&&(t=r,n=e)}return t}function $(e){let t={};for(let e of J)t[Y(e)]=``;if(e===null)return t;for(let n of J){let r=n.window===null?e.concurrency:n.dimension===`requests`?e.requests?.[n.window]:n.dimension===`tokens`?e.tokens?.[n.window]:n.window===`1m`?void 0:e.spend?.[n.window];r!=null&&(t[Y(n)]=String(r))}return t}function fe(e){let t={},n={},r={},i;for(let a of J){let o=(e[Y(a)]??``).trim();if(o.length===0)continue;let s=Number(o),c=a.dimension===`spend`;if(!Number.isFinite(s)||s<=0||!c&&!Number.isInteger(s))return{problem:c?`${X(a)} must be an amount above zero, or blank for no limit.`:`${X(a)} must be a whole number above zero, or blank for no limit.`};a.window===null?i=s:a.dimension===`requests`?t[a.window]=s:a.dimension===`tokens`?n[a.window]=s:a.window!==`1m`&&(r[a.window]=s)}return{limits:{...Object.keys(t).length>0?{requests:t}:{},...Object.keys(n).length>0?{tokens:n}:{},...Object.keys(r).length>0?{spend:r}:{},...i===void 0?{}:{concurrency:i}}}}var pe=W.div`
8
8
  display: grid;
9
9
  grid-template-columns: repeat(3, minmax(0, 1fr));
10
10
  gap: ${({theme:e})=>e.space(2)};
@@ -17,7 +17,7 @@ import{Lt as e,M as t,Nt as n,Rt as r,Tt as i,bt as a,lt as o,w as s,zt as c}fro
17
17
  `,_e=W.p`
18
18
  font-size: 12px;
19
19
  color: ${({theme:e})=>e.color.warn};
20
- `;function ve({apiKey:e,onOpenChange:t}){let n=r(),[i,a]=B(()=>$(e?.limits??{})),[o,s]=B(null);return H(C,{open:e!==null,onOpenChange:t,title:`Edit limits`,description:e===null?void 0:`What "${e.label}" may do per minute, per five hours, and per week. Every field is a ceiling; blank is no limit.`,width:`640px`,footer:U(V,{children:[H(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{if(e===null)return;let r=fe(i);if(`problem`in r){s(r.problem);return}s(null),n.mutate({id:e.id,limits:r.limits},{onSuccess:()=>t(!1),onError:e=>s(g(e))})},children:n.isPending?`Saving…`:`Save limits`})]}),children:U(l,{$gap:3,children:[e?.limits===null?H(_e,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,H(he,{draft:i,onChange:a,disabled:n.isPending}),o===null?null:H(ge,{role:`alert`,children:o})]})})}var ye=W.div`
20
+ `;function ve({apiKey:e,onOpenChange:t}){let n=i(),[r,a]=B(()=>$(e?.limits??{})),[o,s]=B(null);return H(w,{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:U(V,{children:[H(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{if(e===null)return;let i=fe(r);if(`problem`in i){s(i.problem);return}s(null),n.mutate({id:e.id,limits:i.limits},{onSuccess:()=>t(!1),onError:e=>s(g(e))})},children:n.isPending?`Saving…`:`Save limits`})]}),children:U(l,{$gap:3,children:[e?.limits===null?H(_e,{role:`status`,children:`The stored limits for this key cannot be read, so the gateway refuses it. Saving here replaces them.`}):null,H(he,{draft:r,onChange:a,disabled:n.isPending}),o===null?null:H(ge,{role:`alert`,children:o})]})})}var ye=W.div`
21
21
  display: flex;
22
22
  flex-direction: column;
23
23
  gap: 2px;
@@ -46,7 +46,7 @@ import{Lt as e,M as t,Nt as n,Rt as r,Tt as i,bt as a,lt as o,w as s,zt as c}fro
46
46
  `;function Se({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 U(`div`,{children:[H(ye,{children:i.map(e=>U(be,{children:[H(`input`,{type:`checkbox`,disabled:r,"aria-label":e,checked:t.includes(e),onChange:t=>a(e,t.target.checked)}),e]},e))}),o.length>0?H(xe,{children:`Some listed models are no longer configured. They stay until you clear them.`}):null,t.length===0?H(f,{children:`With nothing selected this key is allowed no model.`}):null]})}var Ce=W.p`
47
47
  font-size: 12px;
48
48
  color: ${({theme:e})=>e.color.down};
49
- `;function we({apiKey:e,onOpenChange:t}){let n=c(),r=i(),[a,o]=B(e?.modelAllowlist===null),[s,d]=B(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[p,h]=B(null),_=(r.data??[]).map(e=>e.id);return H(C,{open:e!==null,onOpenChange:t,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:U(V,{children:[H(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{e!==null&&(h(null),n.mutate({id:e.id,modelAllowlist:a?null:s},{onSuccess:()=>t(!1),onError:e=>h(g(e))}))},children:n.isPending?`Saving…`:`Save models`})]}),children:U(l,{$gap:3,children:[U(l,{$gap:2,children:[U(m,{$gap:2,children:[H(A,{checked:a,label:`Allow every model`,onCheckedChange:e=>{o(e),e&&d([])}}),H(f,{as:`span`,children:`Allow every model`})]}),a?null:H(Se,{configured:_,checked:s,onChange:d,disabled:n.isPending})]}),p===null?null:H(Ce,{role:`alert`,children:p})]})})}var Te=W.div`
49
+ `;function we({apiKey:e,onOpenChange:t}){let n=a(),r=s(),[i,o]=B(e?.modelAllowlist===null),[c,d]=B(()=>e?.modelAllowlist===null?[]:e?.modelAllowlist??[]),[p,h]=B(null),_=(r.data??[]).map(e=>e.id);return H(w,{open:e!==null,onOpenChange:t,title:`Edit models`,description:e===null?void 0:`Which models "${e.label}" may ask the gateway for. Sent whole on save.`,width:`640px`,footer:U(V,{children:[H(u,{type:`button`,onClick:()=>t(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:n.isPending,onClick:()=>{e!==null&&(h(null),n.mutate({id:e.id,modelAllowlist:i?null:c},{onSuccess:()=>t(!1),onError:e=>h(g(e))}))},children:n.isPending?`Saving…`:`Save models`})]}),children:U(l,{$gap:3,children:[U(l,{$gap:2,children:[U(m,{$gap:2,children:[H(A,{checked:i,label:`Allow every model`,onCheckedChange:e=>{o(e),e&&d([])}}),H(f,{as:`span`,children:`Allow every model`})]}),i?null:H(Se,{configured:_,checked:c,onChange:d,disabled:n.isPending})]}),p===null?null:H(Ce,{role:`alert`,children:p})]})})}var Te=W.div`
50
50
  display: grid;
51
51
  grid-template-columns: minmax(0, 11rem) minmax(0, 12rem) minmax(0, 1fr) minmax(0, 3.5rem);
52
52
  align-items: center;
@@ -71,7 +71,7 @@ import{Lt as e,M as t,Nt as n,Rt as r,Tt as i,bt as a,lt as o,w as s,zt as c}fro
71
71
  color: ${({theme:e})=>e.color.inkDim};
72
72
  `,Ne=W(u)`
73
73
  gap: 4px;
74
- `;function Pe({open:e,onOpenChange:t}){let n=i(),r=o(),[a,s]=B(``),[c,d]=B(!0),[p,h]=B([]),[_,v]=B(()=>$({})),[b,x]=B(!1),[S,w]=B(``),[T,E]=B(!1),[k,j]=B(null),[N,F]=B(null),I=()=>{s(``),d(!0),h([]),v($({})),x(!1),w(``),E(!1),j(null),F(null),r.reset()},L=e=>{e||I(),t(e)},R=Object.values(_).filter(e=>e.trim().length>0).length;return H(C,{open:e,onOpenChange:L,title:k===null?`Create an API key`:`Key created`,description:k===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:k===null?U(V,{children:[H(u,{type:`button`,onClick:()=>L(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{let e=fe(_);if(`problem`in e){x(!0),F(e.problem);return}let t=ae(S);if(`problem`in t){F(t.problem);return}F(null),r.mutate({label:a.trim().length===0?`api key`:a.trim(),modelAllowlist:c?null:p,limits:e.limits,bodyLoggingOptOut:T,expiresAt:t.at},{onSuccess:e=>j(e),onError:e=>F(g(e))})},children:r.isPending?`Creating…`:`Create key`})]}):H(u,{type:`button`,$variant:`primary`,onClick:()=>L(!1),children:`I have copied the key`}),children:k===null?U(l,{$gap:3,children:[H(P,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>H(M,{...e,value:a,placeholder:`api key`,onChange:e=>s(e.target.value)})}),U(l,{$gap:2,children:[U(m,{$gap:2,children:[H(A,{checked:c,label:`Allow every model`,onCheckedChange:d}),H(f,{as:`span`,children:`Allow every model`})]}),c?null:U(V,{children:[H(Se,{configured:(n.data??[]).map(e=>e.id),checked:p,onChange:h}),p.length===0?H(ke,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),U(l,{$gap:2,children:[U(m,{$gap:2,children:[U(Ne,{type:`button`,$size:`sm`,"aria-expanded":b,onClick:()=>x(e=>!e),children:[H(b?D:O,{}),`Limits`]}),H(f,{as:`span`,children:R===0?`no limits; this key is unbounded`:`${R} limit${R===1?``:`s`} set`})]}),b?H(he,{draft:_,onChange:v}):null]}),H(P,{label:`Expires`,hint:`Optional. Your local time; blank means the key never expires.`,children:e=>H(M,{...e,type:`datetime-local`,value:S,onChange:e=>w(e.target.value)})}),U(l,{$gap:2,children:[U(m,{$gap:2,children:[H(A,{checked:T,label:`Never record this key's bodies`,onCheckedChange:E}),H(f,{as:`span`,children:`Never record this key's bodies`})]}),H(Ae,{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.`})]}),N===null?null:H(je,{role:`alert`,children:N})]}):U(l,{$gap:3,children:[H(Me,{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.`}),H(ee,{value:k.key,label:`Copy API key`}),U(m,{$gap:2,children:[H(f,{children:`Label`}),H(y,{children:k.label}),H(f,{children:`Prefix`}),H(y,{children:k.prefix})]})]})})}var Fe=W(m)`
74
+ `;function Pe({open:e,onOpenChange:t}){let n=s(),r=o(),[i,a]=B(``),[c,d]=B(!0),[p,h]=B([]),[_,v]=B(()=>$({})),[b,x]=B(!1),[S,C]=B(``),[T,E]=B(!1),[k,j]=B(null),[N,F]=B(null),I=()=>{a(``),d(!0),h([]),v($({})),x(!1),C(``),E(!1),j(null),F(null),r.reset()},L=e=>{e||I(),t(e)},R=Object.values(_).filter(e=>e.trim().length>0).length;return H(w,{open:e,onOpenChange:L,title:k===null?`Create an API key`:`Key created`,description:k===null?`Clients send this key as a bearer token or as x-api-key on every /v1 request.`:void 0,footer:k===null?U(V,{children:[H(u,{type:`button`,onClick:()=>L(!1),children:`Cancel`}),H(u,{type:`button`,$variant:`primary`,disabled:r.isPending,onClick:()=>{let e=fe(_);if(`problem`in e){x(!0),F(e.problem);return}let t=ae(S);if(`problem`in t){F(t.problem);return}F(null),r.mutate({label:i.trim().length===0?`api key`:i.trim(),modelAllowlist:c?null:p,limits:e.limits,bodyLoggingOptOut:T,expiresAt:t.at},{onSuccess:e=>j(e),onError:e=>F(g(e))})},children:r.isPending?`Creating…`:`Create key`})]}):H(u,{type:`button`,$variant:`primary`,onClick:()=>L(!1),children:`I have copied the key`}),children:k===null?U(l,{$gap:3,children:[H(P,{label:`Label`,hint:`Names the client this key belongs to, e.g. laptop or CI.`,children:e=>H(M,{...e,value:i,placeholder:`api key`,onChange:e=>a(e.target.value)})}),U(l,{$gap:2,children:[U(m,{$gap:2,children:[H(A,{checked:c,label:`Allow every model`,onCheckedChange:d}),H(f,{as:`span`,children:`Allow every model`})]}),c?null:U(V,{children:[H(Se,{configured:(n.data??[]).map(e=>e.id),checked:p,onChange:h}),p.length===0?H(ke,{children:`With no model selected this key is allowed nothing and every request it makes will be refused.`}):null]})]}),U(l,{$gap:2,children:[U(m,{$gap:2,children:[U(Ne,{type:`button`,$size:`sm`,"aria-expanded":b,onClick:()=>x(e=>!e),children:[H(b?D:O,{}),`Limits`]}),H(f,{as:`span`,children:R===0?`no limits; this key is unbounded`:`${R} limit${R===1?``:`s`} set`})]}),b?H(he,{draft:_,onChange:v}):null]}),H(P,{label:`Expires`,hint:`Optional. Your local time; blank means the key never expires.`,children:e=>H(M,{...e,type:`datetime-local`,value:S,onChange:e=>C(e.target.value)})}),U(l,{$gap:2,children:[U(m,{$gap:2,children:[H(A,{checked:T,label:`Never record this key's bodies`,onCheckedChange:E}),H(f,{as:`span`,children:`Never record this key's bodies`})]}),H(Ae,{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.`})]}),N===null?null:H(je,{role:`alert`,children:N})]}):U(l,{$gap:3,children:[H(Me,{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.`}),H(ee,{value:k.key,label:`Copy API key`}),U(m,{$gap:2,children:[H(f,{children:`Label`}),H(y,{children:k.label}),H(f,{children:`Prefix`}),H(y,{children:k.prefix})]})]})})}var Fe=W(m)`
75
75
  gap: 4px;
76
76
  flex-wrap: wrap;
77
77
  max-width: 34ch;
@@ -89,4 +89,4 @@ import{Lt as e,M as t,Nt as n,Rt as r,Tt as i,bt as a,lt as o,w as s,zt as c}fro
89
89
  flex-direction: column;
90
90
  align-items: flex-end;
91
91
  gap: 2px;
92
- `;function Be(e){if(e===null)return`usage not counted here`;let t=Q(e);return`${X({dimension:e.dimension,window:e.window})} ${Z(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function Ve(){let e=a(),r=n(),[i,o]=B(!1),[s,c]=B(null),[l,g]=B(null),[y,S]=B(null),[C,ee]=B(null),[A,M]=B(null),N=Date.now(),P=e.data??[],F=P.filter(e=>q(e,N)===`active`),W=e.isLoading?`Reading issued keys…`:P.length===0?`No keys exist, so nothing can call this gateway yet.`:`${F.length} active key${F.length===1?``:`s`} of ${P.length} ever issued.`;return U(V,{children:[H(T,{legend:`Keys`,title:`Gateway API keys`,summary:W,actions:U(u,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[H(k,{}),`Create a key`]})}),H(v,{legend:`Issued keys`,meta:`${P.length}`,flush:!0,children:e.isError?H(h,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?H(`div`,{style:{padding:12},children:H(p,{rows:4})}):P.length===0?H(_,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:H(u,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):H(x,{children:U(te,{children:[H(`thead`,{children:U(`tr`,{children:[H(R,{children:`Label`}),H(R,{children:`Prefix`}),H(R,{children:`Allowed models`}),H(R,{$align:`right`,children:`Limits`}),H(R,{$align:`right`,children:`Created`}),H(R,{children:`Body capture`}),H(R,{children:`Status`}),H(R,{})]})}),H(`tbody`,{children:P.map(e=>{let n=C===e.id,r=de(e.limitUsage),i=q(e,N);return U(z,{children:[U(I,{children:[H(L,{children:H(b,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),U(L,{$mono:!0,children:[e.prefix,`…`]}),H(L,{children:e.modelAllowlist===null?H(f,{children:`every model`}):e.modelAllowlist.length===0?H(j,{$tone:`down`,children:`no models`}):H(Fe,{children:e.modelAllowlist.map(e=>H(j,{children:e},e))})}),H(L,{$align:`right`,children:e.limits===null?H(j,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?H(f,{children:`no limits`}):U(ze,{children:[U(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),H(Re,{children:Be(r)})]})}),H(L,{$align:`right`,$mono:!0,children:t(e.createdAt)}),H(L,{children:e.bodyLoggingOptOut?H(j,{children:`no bodies`}):H(f,{children:`—`})}),U(L,{children:[i===`revoked`?H(Ie,{title:t(e.revokedAt??0),children:H(j,{children:`revoked`})}):i===`expired`?H(j,{$tone:`down`,children:`expired`}):H(j,{$tone:`ok`,children:`active`}),e.expiresAt===null?null:U(Le,{children:[i===`expired`?`expired`:`expires`,` `,t(e.expiresAt)]})]}),H(L,{$align:`right`,children:U(m,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:H(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":n,"aria-label":`${n?`Hide`:`Show`} limits for ${e.label}`,title:`${n?`Hide`:`Show`} limits for ${e.label}`,onClick:()=>ee(n?null:e.id),children:H(n?D:O,{})}),e.revokedAt===null?U(V,{children:[H(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>g(e),children:H(re,{})}),H(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>c(e),children:H(E,{})}),H(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit expiry for ${e.label}`,title:`Edit expiry for ${e.label}`,onClick:()=>S(e),children:H(ne,{})}),H(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>M(e),children:`Revoke`})]}):null]})})]}),n?H(I,{children:H(L,{colSpan:8,children:H(Oe,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),H(Pe,{open:i,onOpenChange:o}),H(ve,{apiKey:s,onOpenChange:e=>{e||c(null)}},s?.id??`none`),H(we,{apiKey:l,onOpenChange:e=>{e||g(null)}},l?.id??`none`),H(ce,{apiKey:y,onOpenChange:e=>{e||S(null)}},y?.id??`none`),H(w,{open:A!==null,onOpenChange:e=>{e||M(null)},title:`Revoke key`,body:A===null?``:`Revoking "${A.label}" refuses its next request. The key stays listed so past usage keeps its attribution, and it cannot be un-revoked.`,confirmLabel:`Revoke key`,busy:r.isPending,onConfirm:()=>{A!==null&&r.mutate(A.id,{onSettled:()=>M(null)})}})]})}var He=Ve;export{He as component};
92
+ `;function Be(e){if(e===null)return`usage not counted here`;let t=Q(e);return`${X({dimension:e.dimension,window:e.window})} ${Z(e.dimension,e.limit)}, ${t===null?`—`:Math.round(t*100)}% used`}function Ve(){let t=e(),i=r(),[a,o]=B(!1),[s,c]=B(null),[l,g]=B(null),[y,S]=B(null),[w,ee]=B(null),[A,M]=B(null),N=Date.now(),P=t.data??[],F=P.filter(e=>q(e,N)===`active`),W=t.isLoading?`Reading issued keys…`:P.length===0?`No keys exist, so nothing can call this gateway yet.`:`${F.length} active key${F.length===1?``:`s`} of ${P.length} ever issued.`;return U(V,{children:[H(E,{legend:`Keys`,title:`Gateway API keys`,summary:W,actions:U(u,{type:`button`,$variant:`primary`,onClick:()=>o(!0),children:[H(k,{}),`Create a key`]})}),H(v,{legend:`Issued keys`,meta:`${P.length}`,flush:!0,children:t.isError?H(h,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?H(`div`,{style:{padding:12},children:H(p,{rows:4})}):P.length===0?H(_,{legend:`No keys`,message:`Create a key and give it to a client. The key is shown once, at creation.`,action:H(u,{type:`button`,$variant:`primary`,$size:`sm`,onClick:()=>o(!0),children:`Create a key`})}):H(x,{children:U(te,{children:[H(`thead`,{children:U(`tr`,{children:[H(R,{children:`Label`}),H(R,{children:`Prefix`}),H(R,{children:`Allowed models`}),H(R,{$align:`right`,children:`Limits`}),H(R,{$align:`right`,children:`Created`}),H(R,{children:`Body capture`}),H(R,{children:`Status`}),H(R,{})]})}),H(`tbody`,{children:P.map(e=>{let t=w===e.id,r=de(e.limitUsage),i=q(e,N);return U(z,{children:[U(I,{children:[H(L,{children:H(b,{style:{maxWidth:`24ch`,display:`block`},children:e.label})}),U(L,{$mono:!0,children:[e.prefix,`…`]}),H(L,{children:e.modelAllowlist===null?H(f,{children:`every model`}):e.modelAllowlist.length===0?H(j,{$tone:`down`,children:`no models`}):H(Fe,{children:e.modelAllowlist.map(e=>H(j,{children:e},e))})}),H(L,{$align:`right`,children:e.limits===null?H(j,{$tone:`down`,children:`unreadable`}):e.limitUsage.length===0?H(f,{children:`no limits`}):U(ze,{children:[U(`span`,{children:[e.limitUsage.length,` limit`,e.limitUsage.length===1?``:`s`]}),H(Re,{children:Be(r)})]})}),H(L,{$align:`right`,$mono:!0,children:n(e.createdAt)}),H(L,{children:e.bodyLoggingOptOut?H(j,{children:`no bodies`}):H(f,{children:`—`})}),U(L,{children:[i===`revoked`?H(Ie,{title:n(e.revokedAt??0),children:H(j,{children:`revoked`})}):i===`expired`?H(j,{$tone:`down`,children:`expired`}):H(j,{$tone:`ok`,children:`active`}),e.expiresAt===null?null:U(Le,{children:[i===`expired`?`expired`:`expires`,` `,n(e.expiresAt)]})]}),H(L,{$align:`right`,children:U(m,{$gap:1,$justify:`flex-end`,children:[e.limitUsage.length===0?null:H(d,{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:()=>ee(t?null:e.id),children:H(t?D:O,{})}),e.revokedAt===null?U(V,{children:[H(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit models for ${e.label}`,title:`Edit models for ${e.label}`,onClick:()=>g(e),children:H(re,{})}),H(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit limits for ${e.label}`,title:`Edit limits for ${e.label}`,onClick:()=>c(e),children:H(C,{})}),H(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-label":`Edit expiry for ${e.label}`,title:`Edit expiry for ${e.label}`,onClick:()=>S(e),children:H(ne,{})}),H(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>M(e),children:`Revoke`})]}):null]})})]}),t?H(I,{children:H(L,{colSpan:8,children:H(Oe,{label:e.label,readings:e.limitUsage})})}):null]},e.id)})})]})})}),H(Pe,{open:a,onOpenChange:o}),H(ve,{apiKey:s,onOpenChange:e=>{e||c(null)}},s?.id??`none`),H(we,{apiKey:l,onOpenChange:e=>{e||g(null)}},l?.id??`none`),H(ce,{apiKey:y,onOpenChange:e=>{e||S(null)}},y?.id??`none`),H(T,{open:A!==null,onOpenChange:e=>{e||M(null)},title:`Revoke key`,body:A===null?``:`Revoking "${A.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:i.isPending,onConfirm:()=>{A!==null&&i.mutate(A.id,{onSettled:()=>M(null)})}})]})}var He=Ve;export{He as component};
@@ -0,0 +1,60 @@
1
+ import{Ct as e,Ft as t,K as n,Tt as r,V as i,W as a,Y as o,Zt as s,j as c,l,mt as u,u as d}from"./Lamp-DkvXKB-B.js";import{C as f,D as p,_ as m,a as h,b as g,i as _,r as v,t as y,x as b,y as x}from"./Panel-CWmOTDAP.js";import{D as S,i as C,t as w}from"./Rack-CEuCdVXc.js";import{a as T,i as E,n as D,r as O,t as k}from"./RequestTable-CSQGt9W_.js";import{t as A}from"./Chip-D4qvhu1D.js";import{i as j}from"./Field-BYBri2NV.js";import{useMemo as M,useState as N}from"react";import{Fragment as P,jsx as F,jsxs as I}from"react/jsx-runtime";import L from"styled-components";var R={none:{legend:`Not captured`,message:`Body capture was not running for this request. It needs OMNI_BODY_LOGGING_ALLOWED in the environment and the body logging setting turned on, and the calling key must not have opted out.`},missing:{legend:`Captured, then lost`,message:`This request was captured, but its artifact is no longer on disk. Retention or the row cap has since pruned it, or something removed the file underneath the gateway.`},corrupt:{legend:`Captured, but unreadable`,message:`This request was captured and the artifact is still on disk, but it failed its checksum or would not decrypt. Changing OMNI_ENCRYPTION_KEY invalidates every artifact written under the old one.`}},z=new Intl.NumberFormat(`en-US`),B=L.p`
2
+ font-size: 12px;
3
+ color: ${({theme:e})=>e.color.inkDim};
4
+ max-width: 62ch;
5
+ `,V=L(B)`
6
+ border-left: 2px solid ${({theme:e})=>e.color.ruleStrong};
7
+ padding-left: ${({theme:e})=>e.space(2)};
8
+ `,H=L.h4`
9
+ font-size: 11px;
10
+ font-weight: 600;
11
+ letter-spacing: 0.12em;
12
+ text-transform: uppercase;
13
+ color: ${({theme:e})=>e.color.inkDim};
14
+ margin: 0;
15
+ `,U=L.figcaption`
16
+ display: flex;
17
+ align-items: center;
18
+ gap: ${({theme:e})=>e.space(2)};
19
+ flex-wrap: wrap;
20
+ margin-bottom: 4px;
21
+ `,W=L.figure`
22
+ margin: 0;
23
+ min-width: 0;
24
+ `,G=L.pre`
25
+ margin: 0;
26
+ padding: ${({theme:e})=>e.space(2)};
27
+ max-height: 260px;
28
+ overflow: auto;
29
+ border: 1px solid ${({theme:e})=>e.color.rule};
30
+ border-radius: ${({theme:e})=>e.radius.control};
31
+ background: ${({theme:e})=>e.color.panelSunk};
32
+ font-family: ${({theme:e})=>e.font.mono};
33
+ font-size: 11.5px;
34
+ line-height: 1.5;
35
+ white-space: pre-wrap;
36
+ word-break: break-word;
37
+ `;function K(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(t.omitted!==!0||typeof t.reason!=`string`)return null;let n=t.serializedBytes;return{omitted:!0,reason:t.reason,serializedBytes:typeof n==`number`?n:0}}function q({title:e,stage:t,value:n}){let r=K(n);return I(W,{children:[I(U,{children:[F(H,{children:e}),t===void 0?null:F(A,{children:t})]}),r===null?n==null?F(B,{children:`Nothing was recorded for this half — it never happened, or never completed.`}):F(G,{children:JSON.stringify(n,null,2)}):I(B,{children:[`Too large to keep: `,r.reason,`. The payload was`,` `,z.format(r.serializedBytes),` bytes after structural bounding, so it was replaced by this marker rather than written oversized or dropped without a trace.`]})]})}function J({attempt:e}){return I(f,{$gap:2,children:[I(g,{$gap:2,$wrap:!0,children:[I(m,{as:`h3`,children:[`Attempt `,e.attempt,` · `,e.provider]}),e.truncated?F(A,{$tone:`warn`,children:`truncated`}):null]}),F(q,{title:`Request sent to the provider`,stage:`post-RTK`,value:e.request}),F(q,{title:`Response from the provider`,value:e.response}),e.streamChunks===null?null:F(q,{title:`Raw stream frames (${c(e.streamChunks.length)})`,value:e.streamChunks})]})}function Y({body:e}){let t=e.artifact;if(t===null){let t=R[e.detailState===`ready`?`corrupt`:e.detailState];return I(f,{$gap:1,children:[F(m,{children:t.legend}),F(B,{children:t.message})]})}return I(f,{$gap:3,children:[t.attempts.length===0?null:F(V,{children:`The client request below is what arrived at the gateway. Each attempt request is what went upstream after RTK filters ran, so the two are not the same payload — compare them to see what compression actually removed.`}),I(f,{$gap:2,children:[I(g,{$gap:2,$wrap:!0,children:[F(m,{as:`h3`,children:`Client`}),t.client.truncated?F(A,{$tone:`warn`,children:`truncated`}):null]}),F(q,{title:`Request from the client`,stage:`pre-RTK`,value:t.client.request}),F(q,{title:`Response returned to the client`,value:t.client.response})]}),t.attempts.map(e=>F(J,{attempt:e},`${e.attempt}-${e.provider}`)),t.error===null||t.error===void 0?null:F(q,{title:`Error`,value:t.error})]})}function X({requestId:e}){let n=t(e),r=n.data===void 0||n.data.detailState!==`ready`?void 0:`${z.format(n.data.sizeBytes)} bytes on disk`;return F(y,{legend:`Captured bodies`,...r===void 0?{}:{meta:r},...n.data?.truncated===!0?{actions:F(A,{$tone:`warn`,children:`truncated`})}:{},children:n.isError?F(_,{error:n.error,onRetry:()=>void n.refetch()}):n.isPending?F(h,{rows:3}):F(Y,{body:n.data})})}var Z=[50,100,250,500],Q=L(g)`
38
+ gap: ${({theme:e})=>e.space(2)};
39
+ flex-wrap: wrap;
40
+ `,$=L(j)`
41
+ width: auto;
42
+ `,ee=L(g)`
43
+ justify-content: center;
44
+ gap: ${({theme:e})=>e.space(2)};
45
+ padding: ${({theme:e})=>e.space(3)};
46
+ `,te=L(y)`
47
+ flex: 1;
48
+ min-height: 0;
49
+
50
+ > div {
51
+ display: flex;
52
+ flex: 1;
53
+ flex-direction: column;
54
+ min-height: 0;
55
+ }
56
+ `,ne=L(b)`
57
+ flex: 1;
58
+ min-height: 0;
59
+ overflow-y: auto;
60
+ `;function re(){let{cadence:t,live:f}=S(),[m,g]=N(100),[y,b]=N(T),[A,j]=N(null),L=r(y,m,t(i,`res:logs`)),R=M(()=>(L.data?.pages??[]).flatMap(e=>e.logs),[L.data?.pages]),z=!a(L.data),B=s(n.logPages(y,m)),V=u(),H=e(),U=o(),W=O(f&&R.some(d)),G=M(()=>({accounts:new Map((V.data??[]).map(e=>[e.id,e.label])),keys:new Map((H.data??[]).map(e=>[e.id,e.label]))}),[V.data,H.data]),K=R.filter(l).length,q=R.filter(d).length;return I(P,{children:[F(w,{legend:`Logs`,title:`Recent requests`,summary:L.isLoading?`Reading the request log…`:`${c(R.length)} requests loaded, ${c(K)} of them failed${q===0?``:`, ${c(q)} still running`}. ${U.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:I(Q,{children:[F(E,{filters:y,onChange:b,operator:!0}),F($,{value:m,"aria-label":`How many requests per page`,onChange:e=>g(Number(e.target.value)),children:Z.map(e=>I(`option`,{value:e,children:[e,` per page`]},e))})]})}),F(te,{legend:`Request log`,meta:`${R.length} shown`,flush:!0,children:L.isError?F(_,{error:L.error,onRetry:()=>void L.refetch()}):L.isLoading?F(`div`,{style:{padding:12},children:F(h,{rows:8})}):R.length===0?F(v,{legend:`Nothing to show`,message:Object.keys(y).length===0?`No requests have reached the gateway yet.`:`No request matches these filters. Clear them to see everything.`}):I(ne,{"data-testid":`request-log-scroller`,children:[F(D,{rows:R,now:W,names:G,onOpen:j}),L.hasNextPage||z?I(ee,{children:[L.hasNextPage?F(p,{type:`button`,disabled:L.isFetchingNextPage,onClick:()=>void L.fetchNextPage(),children:L.isFetchingNextPage?`Loading…`:`Load older`}):null,z?I(P,{children:[F(x,{children:`Live updates are paused while older pages are loaded.`}),F(p,{type:`button`,onClick:B,children:`Back to live`})]}):null]}):null]})}),F(C,{open:A!==null,onOpenChange:e=>{e||j(null)},title:`Request detail`,width:`760px`,footer:F(p,{type:`button`,onClick:()=>j(null),children:`Close`}),children:A===null?null:F(k,{log:A,names:G,children:F(X,{requestId:A.id})})})]})}var ie=re;export{ie as component};
@@ -1,4 +1,4 @@
1
- import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}from"./Lamp-DsUSnxN4.js";import{C as l,D as u,O as d,S as f,_ as p,a as m,b as h,i as g,o as _,r as v,t as y,v as b,w as x}from"./Panel-CWmOTDAP.js";import{b as S,m as C,r as w,t as T}from"./Rack-CSpeYQ1D.js";import{t as E}from"./plus-UgaZwucC.js";import{t as D}from"./trash-IE0YvGCJ.js";import{t as O}from"./Toggle-BTJVC9Se.js";import{n as ee,t as k}from"./Chip-roGX6zyg.js";import{i as A,n as j,r as M,t as te}from"./Field-BYBri2NV.js";import{t as N}from"./Meter-stpt3vQu.js";import{useEffect as ne,useId as re,useState as P}from"react";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import R from"styled-components";var ie={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};ie.node;var ae=S(ie),oe={name:`rotate-ccw`,size:24,node:[[`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`}]]};oe.node;var se=S(oe),z=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ce={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`},le=R.li`
1
+ import{D as e,Kt as t,Mt as n,U as r,bt as i,kt as a,mt as o,vt as s,zt as c}from"./Lamp-DkvXKB-B.js";import{C as l,D as u,O as d,S as f,_ as p,a as m,b as h,i as g,o as _,r as v,t as y,v as b,w as x}from"./Panel-CWmOTDAP.js";import{A as S,r as C,t as w,w as T}from"./Rack-CEuCdVXc.js";import{t as E}from"./plus-BCfjC6nk.js";import{t as D}from"./trash-D4QWzEK_.js";import{t as O}from"./Toggle-t82IhqEt.js";import{n as ee,t as k}from"./Chip-D4qvhu1D.js";import{i as A,n as j,r as M,t as te}from"./Field-BYBri2NV.js";import{t as N}from"./Meter-stpt3vQu.js";import{useEffect as ne,useId as re,useState as P}from"react";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import R from"styled-components";var ie={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};ie.node;var ae=S(ie),oe={name:`rotate-ccw`,size:24,node:[[`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`}]]};oe.node;var se=S(oe),z=[`tier`,`health`,`quota`,`cost`,`latency`,`load`],ce={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`},le=R.li`
2
2
  padding: ${({theme:e})=>e.space(2)} 0;
3
3
  border-bottom: 1px solid ${({theme:e})=>e.color.rule};
4
4
 
@@ -46,9 +46,9 @@ import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}fro
46
46
  `,_e=R.p`
47
47
  font-size: 12px;
48
48
  color: ${({theme:e})=>e.color.down};
49
- `;function V(e,t,n){return(e[t]??0)*n[t]}function ve({modelId:e}){let[t,n]=P({tools:!1,images:!1,reasoning:!1}),[r,i]=P(null),[o,s]=P(null),d=a(),m=c(),g=d.data?.weights,S=()=>{e!==null&&(s(null),m.mutate({modelId:e,need:t},{onSuccess:e=>i(e),onError:e=>{i(null),s(_(e))}}))},C=new Map(z.map(e=>[e,Math.max(1e-4,...(r?.candidates??[]).map(t=>g===void 0?0:Math.abs(V(t.reasons,e,g))))]));return I(y,{legend:`Explain`,meta:e??`no model selected`,actions:L(u,{type:`button`,$size:`sm`,$variant:`primary`,disabled:e===null||m.isPending,onClick:S,children:[I(ae,{}),m.isPending?`Ranking…`:`Rank candidates`]}),children:L(l,{$gap:3,children:[L(l,{$gap:1,children:[I(p,{children:`Pretend the request needs`}),L(ge,{children:[L(B,{children:[I(O,{checked:t.tools,label:`Probe request uses tools`,onCheckedChange:e=>n({...t,tools:e})}),`Tools`]}),L(B,{children:[I(O,{checked:t.images,label:`Probe request includes an image`,onCheckedChange:e=>n({...t,images:e})}),`Images`]}),L(B,{children:[I(O,{checked:t.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>n({...t,reasoning:e})}),`Reasoning`]})]})]}),o===null?null:I(_e,{children:o}),r===null?I(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.`}):L(l,{$gap:3,children:[L(h,{$gap:2,$wrap:!0,children:[I(k,{$tone:`accent`,children:r.strategy}),r.deterministic?null:I(k,{$tone:`warn`,children:`order varies per request`}),I(f,{}),L(p,{children:[r.candidates.length,` eligible · `,r.excluded.length,` filtered out`]})]}),r.candidates.length===0?I(v,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):I(`ul`,{children:r.candidates.map((e,t)=>L(le,{children:[L(h,{$gap:2,children:[I(ue,{children:t+1}),I(ee,{provider:e.provider}),I(x,{style:{maxWidth:`22ch`},children:e.credentialLabel}),I(b,{$dim:!0,children:e.model}),L(k,{children:[`tier `,e.tier]}),I(f,{}),t===0?I(de,{children:`would be used`}):null,I(b,{children:e.score.toFixed(2)})]}),g===void 0?null:I(fe,{children:z.map(t=>{let n=V(e.reasons,t,g),r=C.get(t)??1;return L(pe,{title:ce[t],children:[L(me,{children:[I(p,{children:t}),I(b,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),I(N,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${t} contributes ${n.toFixed(2)} of ${e.score.toFixed(2)}`})]},t)})})]},`${e.credentialId}:${e.model}`))}),r.excluded.length===0?null:L(l,{$gap:1,children:[I(p,{children:`Filtered out`}),I(`ul`,{children:r.excluded.map(e=>L(he,{children:[I(b,{$dim:!0,children:e.model}),I(b,{$dim:!0,children:e.credentialId}),I(f,{}),I(k,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}function H(e,t,n){return i(e,t)?.models.find(e=>e.id===n)}function U(e,t,n){let r=i(e,t);return r===void 0?null:r.models.find(e=>e.id===n)?.auth??r.authTypes}var W=[{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.`}],G=0;function K(){return G+=1,`target-${G}`}function q(e,t,n){let r=H(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 ye(e,t,n){let r=H(e,t,n)?.limits;return r===void 0?null:{contextWindow:String(r.contextWindow),maxOutputTokens:String(r.maxOutputTokens)}}var be={oauth:`OAuth`,apiKey:`an API key`};function J(e){return e.map(e=>be[e]).join(` or `)}function xe(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 Y(e,t,n,r){let i=r[t];if(i===void 0||i.length===0)return!0;let a=U(e,t,n);return a===null||a.some(e=>i.includes(e))}function Se(e,t,n){let r=i(e,t);return r===void 0?[]:r.models.filter(r=>Y(e,t,r.id,n))}function Ce(e,t,n,r){if(n.trim().length===0||Y(e,t,n,r))return null;let i=r[t]??[];return`${t} serves this model to ${J(U(e,t,n)??[])} only, and every ${t} account here is ${J(i)}. Requests routed here will fail.`}function we(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 Te(e,t,n){return e.length===0||n.length===0||we(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 Ee(e,t){return{...e,endpointId:t,...t===e.endpointId?{}:{credentialId:``}}}function De(e,t,n){return{...t,...n,...q(e,n.provider,n.model)??{},...n.provider===t.provider?{}:{credentialId:``},contextWindow:``,maxOutputTokens:``}}function Oe(e,t){let n=t??e[0]?.id??`anthropic`,r=i(e,n)?.defaultModel??``,a=q(e,n,r);return{key:K(),provider:n,endpointId:``,model:r,tier:`1`,weight:`1`,costInput:a?.costInput??`0`,costOutput:a?.costOutput??`0`,costCacheRead:a?.costCacheRead??``,costCacheWrite5m:a?.costCacheWrite5m??``,costCacheWrite1h:a?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,credentialId:``,tools:!0,images:!0,reasoning:!0}}function ke(e){return{id:``,strategy:`score`,isAlias:!1,targets:[Oe(e)]}}function Ae(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:K(),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 je(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 Me=R.fieldset`
49
+ `;function V(e,t,n){return(e[t]??0)*n[t]}function ve({modelId:e}){let[n,r]=P({tools:!1,images:!1,reasoning:!1}),[a,o]=P(null),[s,c]=P(null),d=t(),m=i(),g=d.data?.weights,S=()=>{e!==null&&(c(null),m.mutate({modelId:e,need:n},{onSuccess:e=>o(e),onError:e=>{o(null),c(_(e))}}))},C=new Map(z.map(e=>[e,Math.max(1e-4,...(a?.candidates??[]).map(t=>g===void 0?0:Math.abs(V(t.reasons,e,g))))]));return I(y,{legend:`Explain`,meta:e??`no model selected`,actions:L(u,{type:`button`,$size:`sm`,$variant:`primary`,disabled:e===null||m.isPending,onClick:S,children:[I(ae,{}),m.isPending?`Ranking…`:`Rank candidates`]}),children:L(l,{$gap:3,children:[L(l,{$gap:1,children:[I(p,{children:`Pretend the request needs`}),L(ge,{children:[L(B,{children:[I(O,{checked:n.tools,label:`Probe request uses tools`,onCheckedChange:e=>r({...n,tools:e})}),`Tools`]}),L(B,{children:[I(O,{checked:n.images,label:`Probe request includes an image`,onCheckedChange:e=>r({...n,images:e})}),`Images`]}),L(B,{children:[I(O,{checked:n.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>r({...n,reasoning:e})}),`Reasoning`]})]})]}),s===null?null:I(_e,{children:s}),a===null?I(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.`}):L(l,{$gap:3,children:[L(h,{$gap:2,$wrap:!0,children:[I(k,{$tone:`accent`,children:a.strategy}),a.deterministic?null:I(k,{$tone:`warn`,children:`order varies per request`}),I(f,{}),L(p,{children:[a.candidates.length,` eligible · `,a.excluded.length,` filtered out`]})]}),a.candidates.length===0?I(v,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):I(`ul`,{children:a.candidates.map((e,t)=>L(le,{children:[L(h,{$gap:2,children:[I(ue,{children:t+1}),I(ee,{provider:e.provider}),I(x,{style:{maxWidth:`22ch`},children:e.credentialLabel}),I(b,{$dim:!0,children:e.model}),L(k,{children:[`tier `,e.tier]}),I(f,{}),t===0?I(de,{children:`would be used`}):null,I(b,{children:e.score.toFixed(2)})]}),g===void 0?null:I(fe,{children:z.map(t=>{let n=V(e.reasons,t,g),r=C.get(t)??1;return L(pe,{title:ce[t],children:[L(me,{children:[I(p,{children:t}),I(b,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),I(N,{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}`))}),a.excluded.length===0?null:L(l,{$gap:1,children:[I(p,{children:`Filtered out`}),I(`ul`,{children:a.excluded.map(e=>L(he,{children:[I(b,{$dim:!0,children:e.model}),I(b,{$dim:!0,children:e.credentialId}),I(f,{}),I(k,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}function H(e,t,n){return r(e,t)?.models.find(e=>e.id===n)}function U(e,t,n){let i=r(e,t);return i===void 0?null:i.models.find(e=>e.id===n)?.auth??i.authTypes}var W=[{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.`}],G=0;function K(){return G+=1,`target-${G}`}function q(e,t,n){let r=H(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 ye(e,t,n){let r=H(e,t,n)?.limits;return r===void 0?null:{contextWindow:String(r.contextWindow),maxOutputTokens:String(r.maxOutputTokens)}}var be={oauth:`OAuth`,apiKey:`an API key`};function J(e){return e.map(e=>be[e]).join(` or `)}function xe(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 Y(e,t,n,r){let i=r[t];if(i===void 0||i.length===0)return!0;let a=U(e,t,n);return a===null||a.some(e=>i.includes(e))}function Se(e,t,n){let i=r(e,t);return i===void 0?[]:i.models.filter(r=>Y(e,t,r.id,n))}function Ce(e,t,n,r){if(n.trim().length===0||Y(e,t,n,r))return null;let i=r[t]??[];return`${t} serves this model to ${J(U(e,t,n)??[])} only, and every ${t} account here is ${J(i)}. Requests routed here will fail.`}function we(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 Te(e,t,n){return e.length===0||n.length===0||we(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 Ee(e,t){return{...e,endpointId:t,...t===e.endpointId?{}:{credentialId:``}}}function De(e,t,n){return{...t,...n,...q(e,n.provider,n.model)??{},...n.provider===t.provider?{}:{credentialId:``},contextWindow:``,maxOutputTokens:``}}function Oe(e,t){let n=t??e[0]?.id??`anthropic`,i=r(e,n)?.defaultModel??``,a=q(e,n,i);return{key:K(),provider:n,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 X(e){return{id:``,strategy:`score`,isAlias:!1,targets:[Oe(e)]}}function ke(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:K(),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 Ae(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 je=R.fieldset`
50
50
  border: 1px solid ${({theme:e})=>e.color.rule};
51
- border-left: 3px solid ${({$provider:e})=>C(e)};
51
+ border-left: 3px solid ${({$provider:e})=>T(e)};
52
52
  border-radius: ${({theme:e})=>e.radius.control};
53
53
  padding: ${({theme:e})=>e.space(3)};
54
54
  margin: 0;
@@ -57,7 +57,7 @@ import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}fro
57
57
  flex-direction: column;
58
58
  gap: ${({theme:e})=>e.space(3)};
59
59
  min-width: 0;
60
- `,Ne=R.div`
60
+ `,Me=R.div`
61
61
  display: grid;
62
62
  grid-template-columns: minmax(140px, 1.4fr) minmax(160px, 2fr) 72px 72px;
63
63
  gap: ${({theme:e})=>e.space(2)};
@@ -66,7 +66,7 @@ import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}fro
66
66
  @media (max-width: 720px) {
67
67
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
68
68
  }
69
- `,X=R.div`
69
+ `,Ne=R.div`
70
70
  display: grid;
71
71
  grid-template-columns: repeat(3, minmax(0, 1fr));
72
72
  gap: ${({theme:e})=>e.space(2)};
@@ -88,7 +88,7 @@ import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}fro
88
88
  align-items: center;
89
89
  gap: 6px;
90
90
  cursor: pointer;
91
- `;function Ie({target:e,index:t,onChange:n,onRemove:r,removable:a,catalog:o,endpoints:s,held:c,credentials:m}){let g=re(),_=i(o,e.provider),v=Se(o,e.provider,c),y=Ce(o,e.provider,e.model,c),b=we(e,m),x=Te(e.credentialId,e,m),S=(t,r)=>{n({...e,[t]:r})},C=q(o,e.provider,e.model),w=ye(o,e.provider,e.model),T=t=>{n(De(o,e,t))};return L(Me,{$provider:e.provider,children:[L(h,{$gap:2,children:[L(p,{as:`legend`,children:[`Target `,t+1]}),I(f,{}),I(d,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!a,"aria-label":`Remove target ${t+1}`,title:a?`Remove target ${t+1}`:`A model needs at least one target`,onClick:r,children:I(D,{})})]}),L(Ne,{children:[L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-provider`,children:`Provider`}),L(A,{id:`${g}-provider`,value:e.provider,onChange:t=>{let n=t.target.value,r=i(o,n),a=r?.models.some(t=>t.id===e.model)??!1;T({provider:n,model:a?e.model:r?.defaultModel??``})},children:[o.map(e=>I(`option`,{value:e.id,children:e.label},e.id)),_===void 0?L(`option`,{value:e.provider,children:[e.provider,` (not in the catalog)`]}):null]})]}),e.provider===`custom`?L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-endpoint`,children:`Endpoint`}),L(A,{id:`${g}-endpoint`,value:e.endpointId,onChange:t=>n(Ee(e,t.target.value)),children:[I(`option`,{value:``,children:`Choose endpoint`}),s.map(e=>I(`option`,{value:e.id,children:e.label},e.id))]})]}):null,L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-model`,children:`Provider model`}),I(j,{id:`${g}-model`,list:`${g}-catalog`,value:e.model,placeholder:_?.defaultModel??``,onChange:t=>T({provider:e.provider,model:t.target.value})}),I(`datalist`,{id:`${g}-catalog`,children:v.map(e=>I(`option`,{value:e.id,children:e.label},e.id))}),y===null?null:I(Fe,{role:`note`,children:y})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-tier`,children:`Tier`}),I(M,{id:`${g}-tier`,min:1,step:1,value:e.tier,onChange:e=>S(`tier`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-weight`,children:`Weight`}),I(M,{id:`${g}-weight`,min:0,step:.1,value:e.weight,onChange:e=>S(`weight`,e.target.value)})]})]}),I(l,{$gap:1,children:L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-account`,children:`Account`}),L(A,{id:`${g}-account`,value:e.credentialId,onChange:e=>S(`credentialId`,e.target.value),children:[I(`option`,{value:``,children:`Any account`}),b.map(e=>I(`option`,{value:e.id,children:e.label},e.id)),x===null?null:L(`option`,{value:e.credentialId,children:[e.credentialId,` (removed)`]})]}),x===null?null:I(Fe,{role:`note`,children:x})]})}),L(l,{$gap:1,children:[L(h,{$gap:2,children:[I(p,{children:`Price per million tokens`}),I(f,{}),C===null?I(p,{as:`span`,children:`not in the catalog — price it yourself`}):L(u,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:e.costInput===C.costInput&&e.costOutput===C.costOutput&&e.costCacheRead===C.costCacheRead&&e.costCacheWrite5m===C.costCacheWrite5m&&e.costCacheWrite1h===C.costCacheWrite1h,onClick:()=>n({...e,...C}),children:[I(se,{}),`Use list price`]})]}),L(X,{children:[L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-in`,children:`Input`}),I(M,{id:`${g}-in`,min:0,step:.01,value:e.costInput,onChange:e=>S(`costInput`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-out`,children:`Output`}),I(M,{id:`${g}-out`,min:0,step:.01,value:e.costOutput,onChange:e=>S(`costOutput`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-cache`,children:`Cache read`}),I(M,{id:`${g}-cache`,min:0,step:.01,placeholder:`same as input`,value:e.costCacheRead,onChange:e=>S(`costCacheRead`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-write5m`,children:`Cache write 5m`}),I(M,{id:`${g}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:e.costCacheWrite5m,onChange:e=>S(`costCacheWrite5m`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-write1h`,children:`Cache write 1h`}),I(M,{id:`${g}-write1h`,min:0,step:.01,placeholder:`2x input`,value:e.costCacheWrite1h,onChange:e=>S(`costCacheWrite1h`,e.target.value)})]})]})]}),L(l,{$gap:1,children:[L(h,{$gap:2,children:[I(p,{children:`Token limits`}),I(f,{}),w===null?I(p,{as:`span`,children:`not in the catalog — state them yourself`}):I(p,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),L(X,{children:[L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-context`,children:`Context window`}),I(M,{id:`${g}-context`,min:1,step:1024,placeholder:w?.contextWindow??`published`,value:e.contextWindow,onChange:e=>S(`contextWindow`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-maxout`,children:`Max output`}),I(M,{id:`${g}-maxout`,min:1,step:1024,placeholder:w?.maxOutputTokens??`published`,value:e.maxOutputTokens,onChange:e=>S(`maxOutputTokens`,e.target.value)})]})]})]}),L(l,{$gap:1,children:[I(p,{children:`Capabilities`}),L(Pe,{children:[L(Q,{children:[I(O,{checked:e.tools,label:`Target ${t+1} supports tools`,onCheckedChange:e=>S(`tools`,e)}),`Tools`]}),L(Q,{children:[I(O,{checked:e.images,label:`Target ${t+1} supports images`,onCheckedChange:e=>S(`images`,e)}),`Images`]}),L(Q,{children:[I(O,{checked:e.reasoning,label:`Target ${t+1} supports reasoning`,onCheckedChange:e=>S(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Le=R.p`
91
+ `;function Ie({target:e,index:t,onChange:n,onRemove:i,removable:a,catalog:o,endpoints:s,held:c,credentials:m}){let g=re(),_=r(o,e.provider),v=Se(o,e.provider,c),y=Ce(o,e.provider,e.model,c),b=we(e,m),x=Te(e.credentialId,e,m),S=(t,r)=>{n({...e,[t]:r})},C=q(o,e.provider,e.model),w=ye(o,e.provider,e.model),T=t=>{n(De(o,e,t))};return L(je,{$provider:e.provider,children:[L(h,{$gap:2,children:[L(p,{as:`legend`,children:[`Target `,t+1]}),I(f,{}),I(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:I(D,{})})]}),L(Me,{children:[L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-provider`,children:`Provider`}),L(A,{id:`${g}-provider`,value:e.provider,onChange:t=>{let n=t.target.value,i=r(o,n),a=i?.models.some(t=>t.id===e.model)??!1;T({provider:n,model:a?e.model:i?.defaultModel??``})},children:[o.map(e=>I(`option`,{value:e.id,children:e.label},e.id)),_===void 0?L(`option`,{value:e.provider,children:[e.provider,` (not in the catalog)`]}):null]})]}),e.provider===`custom`?L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-endpoint`,children:`Endpoint`}),L(A,{id:`${g}-endpoint`,value:e.endpointId,onChange:t=>n(Ee(e,t.target.value)),children:[I(`option`,{value:``,children:`Choose endpoint`}),s.map(e=>I(`option`,{value:e.id,children:e.label},e.id))]})]}):null,L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-model`,children:`Provider model`}),I(j,{id:`${g}-model`,list:`${g}-catalog`,value:e.model,placeholder:_?.defaultModel??``,onChange:t=>T({provider:e.provider,model:t.target.value})}),I(`datalist`,{id:`${g}-catalog`,children:v.map(e=>I(`option`,{value:e.id,children:e.label},e.id))}),y===null?null:I(Fe,{role:`note`,children:y})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-tier`,children:`Tier`}),I(M,{id:`${g}-tier`,min:1,step:1,value:e.tier,onChange:e=>S(`tier`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-weight`,children:`Weight`}),I(M,{id:`${g}-weight`,min:0,step:.1,value:e.weight,onChange:e=>S(`weight`,e.target.value)})]})]}),I(l,{$gap:1,children:L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-account`,children:`Account`}),L(A,{id:`${g}-account`,value:e.credentialId,onChange:e=>S(`credentialId`,e.target.value),children:[I(`option`,{value:``,children:`Any account`}),b.map(e=>I(`option`,{value:e.id,children:e.label},e.id)),x===null?null:L(`option`,{value:e.credentialId,children:[e.credentialId,` (removed)`]})]}),x===null?null:I(Fe,{role:`note`,children:x})]})}),L(l,{$gap:1,children:[L(h,{$gap:2,children:[I(p,{children:`Price per million tokens`}),I(f,{}),C===null?I(p,{as:`span`,children:`not in the catalog — price it yourself`}):L(u,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:e.costInput===C.costInput&&e.costOutput===C.costOutput&&e.costCacheRead===C.costCacheRead&&e.costCacheWrite5m===C.costCacheWrite5m&&e.costCacheWrite1h===C.costCacheWrite1h,onClick:()=>n({...e,...C}),children:[I(se,{}),`Use list price`]})]}),L(Ne,{children:[L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-in`,children:`Input`}),I(M,{id:`${g}-in`,min:0,step:.01,value:e.costInput,onChange:e=>S(`costInput`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-out`,children:`Output`}),I(M,{id:`${g}-out`,min:0,step:.01,value:e.costOutput,onChange:e=>S(`costOutput`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-cache`,children:`Cache read`}),I(M,{id:`${g}-cache`,min:0,step:.01,placeholder:`same as input`,value:e.costCacheRead,onChange:e=>S(`costCacheRead`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-write5m`,children:`Cache write 5m`}),I(M,{id:`${g}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:e.costCacheWrite5m,onChange:e=>S(`costCacheWrite5m`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-write1h`,children:`Cache write 1h`}),I(M,{id:`${g}-write1h`,min:0,step:.01,placeholder:`2x input`,value:e.costCacheWrite1h,onChange:e=>S(`costCacheWrite1h`,e.target.value)})]})]})]}),L(l,{$gap:1,children:[L(h,{$gap:2,children:[I(p,{children:`Token limits`}),I(f,{}),w===null?I(p,{as:`span`,children:`not in the catalog — state them yourself`}):I(p,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),L(Ne,{children:[L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-context`,children:`Context window`}),I(M,{id:`${g}-context`,min:1,step:1024,placeholder:w?.contextWindow??`published`,value:e.contextWindow,onChange:e=>S(`contextWindow`,e.target.value)})]}),L(Z,{children:[I(p,{as:`label`,htmlFor:`${g}-maxout`,children:`Max output`}),I(M,{id:`${g}-maxout`,min:1,step:1024,placeholder:w?.maxOutputTokens??`published`,value:e.maxOutputTokens,onChange:e=>S(`maxOutputTokens`,e.target.value)})]})]})]}),L(l,{$gap:1,children:[I(p,{children:`Capabilities`}),L(Pe,{children:[L(Q,{children:[I(O,{checked:e.tools,label:`Target ${t+1} supports tools`,onCheckedChange:e=>S(`tools`,e)}),`Tools`]}),L(Q,{children:[I(O,{checked:e.images,label:`Target ${t+1} supports images`,onCheckedChange:e=>S(`images`,e)}),`Images`]}),L(Q,{children:[I(O,{checked:e.reasoning,label:`Target ${t+1} supports reasoning`,onCheckedChange:e=>S(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Le=R.p`
92
92
  font-size: 11.5px;
93
93
  color: ${({theme:e})=>e.color.inkDim};
94
94
  `,Re=R.p`
@@ -99,7 +99,7 @@ import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}fro
99
99
  color: ${({theme:e})=>e.color.ok};
100
100
  `,Be=R(h)`
101
101
  gap: 8px;
102
- `;function Ve({model:e,onSaved:r,onDeleted:i}){let a=t().data??[],[c,d]=P(()=>e===null?ke(a):Ae(e)),[m,g]=P(null),[v,b]=P(!1),[x,S]=P(!1),C=n(),T=s(),D=o(),ee=xe(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;ne(()=>{d(e===null?ke(a):Ae(e)),g(null),b(!1)},[M]);let N=W.find(e=>e.id===c.strategy);return L(F,{children:[I(y,{legend:e===null?`New model`:`Edit model`,meta:e===null?void 0:e.id,actions:L(F,{children:[e===null?null:I(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>S(!0),children:`Delete`}),I(u,{type:`button`,$variant:`primary`,$size:`sm`,disabled:C.isPending,onClick:()=>{b(!1);let e=je(c);if(!e.ok){g(e.problem);return}g(null),C.mutate(e.model,{onSuccess:()=>{b(!0),r(e.model.id)},onError:e=>g(_(e))})},children:C.isPending?`Saving…`:e===null?`Create model`:`Save changes`})]}),children:L(l,{$gap:3,children:[I(te,{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=>I(j,{...t,value:c.id,disabled:e!==null,placeholder:`fast`,onChange:e=>d({...c,id:e.target.value})})}),I(te,{label:`Routing strategy`,children:e=>I(A,{...e,value:c.strategy,onChange:e=>d({...c,strategy:e.target.value}),children:W.map(e=>I(`option`,{value:e.id,children:e.label},e.id))})}),N===void 0?null:I(Le,{children:N.blurb}),L(Be,{children:[I(O,{checked:c.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>d({...c,isAlias:e})}),L(l,{$gap:0,children:[I(p,{as:`span`,children:`Alias`}),I(Le,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),L(l,{$gap:2,children:[L(h,{children:[I(p,{children:`Targets`}),I(f,{}),L(u,{type:`button`,$size:`sm`,onClick:()=>d({...c,targets:[...c.targets,Oe(a,c.targets.at(-1)?.provider)]}),children:[I(E,{}),`Add target`]})]}),c.targets.map((e,t)=>I(Ie,{target:e,index:t,removable:c.targets.length>1,catalog:a,endpoints:k,held:ee,credentials:D.data??[],onChange:t=>d({...c,targets:c.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>d({...c,targets:c.targets.filter(t=>t.key!==e.key)})},e.key))]}),m===null?null:I(Re,{role:`alert`,children:m}),v&&m===null?I(ze,{role:`status`,children:`Saved.`}):null]})}),I(w,{open:x,onOpenChange:S,title:`Delete model`,body:e===null?``:`Deleting "${e.id}" makes it unroutable. Clients asking for it will get a model-unavailable error, and any key allowlisting it keeps a name that no longer resolves.`,confirmLabel:`Delete model`,busy:T.isPending,onConfirm:()=>{e!==null&&T.mutate(e.id,{onSuccess:()=>{S(!1),i()},onError:e=>{S(!1),g(_(e))}})}})]})}var He=R.div`
102
+ `;function Ve({model:e,onSaved:t,onDeleted:r}){let i=n().data??[],[a,d]=P(()=>e===null?X(i):ke(e)),[m,g]=P(null),[v,b]=P(!1),[x,S]=P(!1),w=c(),T=s(),D=o(),ee=xe(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;ne(()=>{d(e===null?X(i):ke(e)),g(null),b(!1)},[M]);let N=W.find(e=>e.id===a.strategy);return L(F,{children:[I(y,{legend:e===null?`New model`:`Edit model`,meta:e===null?void 0:e.id,actions:L(F,{children:[e===null?null:I(u,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>S(!0),children:`Delete`}),I(u,{type:`button`,$variant:`primary`,$size:`sm`,disabled:w.isPending,onClick:()=>{b(!1);let e=Ae(a);if(!e.ok){g(e.problem);return}g(null),w.mutate(e.model,{onSuccess:()=>{b(!0),t(e.model.id)},onError:e=>g(_(e))})},children:w.isPending?`Saving…`:e===null?`Create model`:`Save changes`})]}),children:L(l,{$gap:3,children:[I(te,{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=>I(j,{...t,value:a.id,disabled:e!==null,placeholder:`fast`,onChange:e=>d({...a,id:e.target.value})})}),I(te,{label:`Routing strategy`,children:e=>I(A,{...e,value:a.strategy,onChange:e=>d({...a,strategy:e.target.value}),children:W.map(e=>I(`option`,{value:e.id,children:e.label},e.id))})}),N===void 0?null:I(Le,{children:N.blurb}),L(Be,{children:[I(O,{checked:a.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>d({...a,isAlias:e})}),L(l,{$gap:0,children:[I(p,{as:`span`,children:`Alias`}),I(Le,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),L(l,{$gap:2,children:[L(h,{children:[I(p,{children:`Targets`}),I(f,{}),L(u,{type:`button`,$size:`sm`,onClick:()=>d({...a,targets:[...a.targets,Oe(i,a.targets.at(-1)?.provider)]}),children:[I(E,{}),`Add target`]})]}),a.targets.map((e,t)=>I(Ie,{target:e,index:t,removable:a.targets.length>1,catalog:i,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:I(Re,{role:`alert`,children:m}),v&&m===null?I(ze,{role:`status`,children:`Saved.`}):null]})}),I(C,{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),r()},onError:e=>{S(!1),g(_(e))}})}})]})}var He=R.div`
103
103
  display: grid;
104
104
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
105
105
  gap: ${({theme:e})=>e.space(4)};
@@ -144,5 +144,5 @@ import{D as e,Ot as t,Pt as n,Tt as r,U as i,Vt as a,ft as o,gt as s,vt as c}fro
144
144
  width: 12px;
145
145
  height: 3px;
146
146
  border-radius: 1px;
147
- background: ${({$provider:e})=>C(e)};
148
- `,$=`\0new`;function Je(){let e=r(),[t,n]=P(null),i=e.data??[],a=t===$?null:i.find(e=>e.id===t)??null,o=t===$||t===null&&!e.isLoading&&i.length===0;ne(()=>{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 L(F,{children:[I(T,{legend:`Models`,title:`Virtual models`,summary:s,actions:L(u,{type:`button`,$variant:`primary`,onClick:()=>n($),children:[I(E,{}),`New model`]})}),L(He,{children:[I(y,{legend:`Configured`,meta:`${i.length}`,flush:!0,children:e.isError?I(g,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?I(`div`,{style:{padding:12},children:I(m,{rows:4})}):i.length===0?I(v,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:I(u,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>n($),children:`New model`})}):I(`div`,{children:i.map(e=>{let r=[...new Set(e.targets.map(e=>e.provider))];return L(We,{type:`button`,$selected:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:[L(h,{$gap:2,style:{width:`100%`},children:[I(Ge,{title:e.id,children:e.id}),I(f,{}),e.isAlias?I(k,{children:`alias`}):null]}),L(h,{$gap:2,style:{width:`100%`},children:[I(Ke,{children:r.map(e=>I(qe,{$provider:e,title:e},e))}),I(p,{children:e.strategy}),I(f,{}),L(b,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),L(Ue,{children:[a===null&&!o?I(y,{legend:`Editor`,children:e.isLoading?I(m,{rows:5}):I(v,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):I(Ve,{model:a,onSaved:t=>{n(t),e.refetch()},onDeleted:()=>{n(null),e.refetch()}}),I(ve,{modelId:a?.id??null})]})]})]})}var Ye=Je;export{Ye as component};
147
+ background: ${({$provider:e})=>T(e)};
148
+ `,$=`\0new`;function Je(){let e=a(),[t,n]=P(null),r=e.data??[],i=t===$?null:r.find(e=>e.id===t)??null,o=t===$||t===null&&!e.isLoading&&r.length===0;ne(()=>{t===null&&r.length!==0&&n(r[0]?.id??null)},[r,t]);let s=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 L(F,{children:[I(w,{legend:`Models`,title:`Virtual models`,summary:s,actions:L(u,{type:`button`,$variant:`primary`,onClick:()=>n($),children:[I(E,{}),`New model`]})}),L(He,{children:[I(y,{legend:`Configured`,meta:`${r.length}`,flush:!0,children:e.isError?I(g,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?I(`div`,{style:{padding:12},children:I(m,{rows:4})}):r.length===0?I(v,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:I(u,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>n($),children:`New model`})}):I(`div`,{children:r.map(e=>{let r=[...new Set(e.targets.map(e=>e.provider))];return L(We,{type:`button`,$selected:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:[L(h,{$gap:2,style:{width:`100%`},children:[I(Ge,{title:e.id,children:e.id}),I(f,{}),e.isAlias?I(k,{children:`alias`}):null]}),L(h,{$gap:2,style:{width:`100%`},children:[I(Ke,{children:r.map(e=>I(qe,{$provider:e,title:e},e))}),I(p,{children:e.strategy}),I(f,{}),L(b,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),L(Ue,{children:[i===null&&!o?I(y,{legend:`Editor`,children:e.isLoading?I(m,{rows:5}):I(v,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):I(Ve,{model:i,onSaved:t=>{n(t),e.refetch()},onDeleted:()=>{n(null),e.refetch()}}),I(ve,{modelId:i?.id??null})]})]})]})}var Ye=Je;export{Ye as component};
@@ -1,4 +1,4 @@
1
- import{Dt as e}from"./Lamp-DsUSnxN4.js";import{t}from"./preload-helper-CvG2RSKd.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-CWmOTDAP.js";import{t as d}from"./Rack-CSpeYQ1D.js";import{t as f}from"./index-C_8ChaGY.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{jt as e}from"./Lamp-DkvXKB-B.js";import{t}from"./preload-helper-BPaHpbO_.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-CWmOTDAP.js";import{t as d}from"./Rack-CEuCdVXc.js";import{t as f}from"./index-89mqAVmK.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,Gt as t,It as n,Tt as r,Vt as i,X as a,Y as o,q as s}from"./Lamp-DsUSnxN4.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-CWmOTDAP.js";import{t as b}from"./Rack-CSpeYQ1D.js";import{t as x}from"./Toggle-BTJVC9Se.js";import{i as S,n as C,t as w}from"./Field-BYBri2NV.js";import{t as T}from"./Meter-stpt3vQu.js";import{n as E}from"./reasons-Du1OBWAM.js";import{useEffect as ee,useId as D,useState as O}from"react";import{Fragment as te,jsx as k,jsxs as A}from"react/jsx-runtime";import j from"styled-components";var M=j.p`
1
+ import{Gt as e,J as t,Kt as n,Vt as r,X as i,Xt as a,Z as o,kt as s}from"./Lamp-DkvXKB-B.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-CWmOTDAP.js";import{t as b}from"./Rack-CEuCdVXc.js";import{t as x}from"./Toggle-t82IhqEt.js";import{i as S,n as C,t as w}from"./Field-BYBri2NV.js";import{t as T}from"./Meter-stpt3vQu.js";import{n as E}from"./reasons-Du1OBWAM.js";import{useEffect as ee,useId as D,useState as O}from"react";import{Fragment as te,jsx as k,jsxs as A}from"react/jsx-runtime";import j from"styled-components";var M=j.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,Gt as t,It as n,Tt as r,Vt as i,X as a,Y as o,q as s}from"./Lamp-
12
12
  max-width: 320px;
13
13
  `,I=j(d)`
14
14
  color: ${({theme:e})=>e.color.inkDim};
15
- `;function L(){let e=a(),[t,n]=O(``),[r,i]=O(``),[o,s]=O(``),[u,d]=O(null);return A(c,{$gap:2,children:[k(I,{children:`Admin password`}),k(M,{children:`Changing this signs every session out, including this one.`}),A(F,{$gap:2,children:[k(w,{label:`Current password`,children:e=>k(C,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),k(w,{label:`New password`,hint:`At least 12 characters.`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),k(w,{label:`Repeat new password`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:o,onChange:e=>s(e.target.value)})}),k(p,{$gap:2,children:k(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<12){d(`A password must be at least 12 characters.`);return}if(r!==o){d(`The two new passwords do not match.`);return}d(null),e.mutate({current:t,password:r},{onSuccess:()=>E(`password-changed`),onError:e=>d(_(e))})},disabled:e.isPending||t.length===0||r.length===0,children:`Change password`})})]}),u===null?null:k(N,{role:`alert`,children:u})]})}function R(){let n=t(),r=e(),[i,a]=O(``),[o,s]=O(null),[u,d]=O(null),f=n.data?.viewerConfigured===!0;return A(c,{$gap:2,children:[k(I,{children:`Read-only password`}),A(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.`]}),A(F,{$gap:2,children:[k(w,{label:f?`Replace read-only password`:`Set read-only password`,hint:`At least 12 characters.`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:i,onChange:e=>a(e.target.value)})}),A(p,{$gap:2,children:[k(l,{type:`button`,$variant:`primary`,onClick:()=>{if(i.length<12){s(`A password must be at least 12 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?k(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:k(N,{role:`alert`,children:o}),u===null||o!==null?null:k(P,{role:`status`,children:u})]})}function ne(){return k(v,{legend:`Access`,children:A(c,{$gap:3,children:[k(L,{}),k(h,{}),k(R,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],re=j(y)`
15
+ `;function L(){let e=o(),[t,n]=O(``),[r,i]=O(``),[a,s]=O(``),[u,d]=O(null);return A(c,{$gap:2,children:[k(I,{children:`Admin password`}),k(M,{children:`Changing this signs every session out, including this one.`}),A(F,{$gap:2,children:[k(w,{label:`Current password`,children:e=>k(C,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),k(w,{label:`New password`,hint:`At least 12 characters.`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),k(w,{label:`Repeat new password`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:a,onChange:e=>s(e.target.value)})}),k(p,{$gap:2,children:k(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<12){d(`A password must be at least 12 characters.`);return}if(r!==a){d(`The two new passwords do not match.`);return}d(null),e.mutate({current:t,password:r},{onSuccess:()=>E(`password-changed`),onError:e=>d(_(e))})},disabled:e.isPending||t.length===0||r.length===0,children:`Change password`})})]}),u===null?null:k(N,{role:`alert`,children:u})]})}function R(){let t=a(),n=e(),[r,i]=O(``),[o,s]=O(null),[u,d]=O(null),f=t.data?.viewerConfigured===!0;return A(c,{$gap:2,children:[k(I,{children:`Read-only password`}),A(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.`]}),A(F,{$gap:2,children:[k(w,{label:f?`Replace read-only password`:`Set read-only password`,hint:`At least 12 characters.`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),A(p,{$gap:2,children:[k(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<12){s(`A password must be at least 12 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?k(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]})]}),o===null?null:k(N,{role:`alert`,children:o}),u===null||o!==null?null:k(P,{role:`status`,children:u})]})}function ne(){return k(v,{legend:`Access`,children:A(c,{$gap:3,children:[k(L,{}),k(h,{}),k(R,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],re=j(y)`
16
16
  display: block;
17
17
  white-space: pre;
18
18
  overflow-x: auto;
@@ -34,7 +34,7 @@ import{Bt as e,Gt as t,It as n,Tt as r,Vt as i,X as a,Y as o,q 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
- `,oe=[{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]=O(`claude`),[n,i]=O(()=>({claude:{},opencode:{}})),a=r(),o=n[e],u=typeof o.defaultModel==`string`&&o.defaultModel!==``?o:void 0,d=s(e,u),m=z.find(t=>t.id===e);return k(v,{legend:`Agent setup`,children:A(c,{children:[k(p,{children:z.map(n=>k(l,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),A(B,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,A(y,{children:[`omni setup `,e]}),` to write these files directly.`]}),(a.data?.length??0)>0?k(ae,{children:oe.map(t=>k(w,{label:t.label,children:n=>A(S,{...n,value:o[t.key]??``,onChange:n=>i(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[k(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),a.data?.map(e=>k(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,a.isLoading?k(f,{rows:2}):d.isError?k(g,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?k(f,{rows:4}):(a.data?.length??0)===0?k(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?A(B,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?k(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>A(`div`,{children:[k(ie,{children:e.path}),k(re,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?k(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=j.div`
37
+ `,oe=[{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,n]=O(`claude`),[r,i]=O(()=>({claude:{},opencode:{}})),a=s(),o=r[e],u=typeof o.defaultModel==`string`&&o.defaultModel!==``?o:void 0,d=t(e,u),m=z.find(t=>t.id===e);return k(v,{legend:`Agent setup`,children:A(c,{children:[k(p,{children:z.map(t=>k(l,{type:`button`,$variant:t.id===e?`primary`:`ghost`,onClick:()=>n(t.id),children:t.label},t.id))}),A(B,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,A(y,{children:[`omni setup `,e]}),` to write these files directly.`]}),(a.data?.length??0)>0?k(ae,{children:oe.map(t=>k(w,{label:t.label,children:n=>A(S,{...n,value:o[t.key]??``,onChange:n=>i(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[k(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),a.data?.map(e=>k(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,a.isLoading?k(f,{rows:2}):d.isError?k(g,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?k(f,{rows:4}):(a.data?.length??0)===0?k(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?A(B,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?k(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>A(`div`,{children:[k(ie,{children:e.path}),k(re,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?k(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=j.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,Gt as t,It as n,Tt as r,Vt as i,X as a,Y as o,q as s}from"./Lamp-
85
85
  code {
86
86
  font-family: ${({theme:e})=>e.font.mono};
87
87
  }
88
- `;function de(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 fe(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 pe(){let e=i(),t=o(),r=n(),[a,s]=O({}),[h,x]=O(null),[E,D]=O(!1);ee(()=>{e.data!==void 0&&s(de(e.data))},[e.data]);let j=Math.max(1e-4,...U.map(e=>Math.abs(Number(a[`w.${e.id}`])||0)));return A(te,{children:[k(b,{legend:`Settings`,title:`Routing and retention`,summary:`Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.`,actions:k(l,{type:`button`,$variant:`primary`,disabled:r.isPending||e.isLoading,onClick:()=>{D(!1);let e=fe(a);if(!e.ok){x(e.problem);return}x(null),r.mutate(e.settings,{onSuccess:()=>D(!0),onError:e=>x(_(e))})},children:r.isPending?`Saving…`:`Save changes`})}),e.isError?k(v,{legend:`Settings`,children:k(g,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?k(v,{legend:`Settings`,children:k(f,{rows:6})}):A(c,{$gap:4,children:[k(v,{legend:`Scoring weights`,meta:`relative to each other`,footer:A(p,{children:[k(d,{children:`Score is the sum of each term times its weight, then multiplied by the account and target weights.`}),k(u,{})]}),children:k(G,{children:U.map(e=>{let t=Number(a[`w.${e.id}`])||0;return A(K,{children:[k(w,{label:e.label,children:t=>k(C,{...t,type:`number`,step:.5,value:a[`w.${e.id}`]??``,onChange:t=>s({...a,[`w.${e.id}`]:t.target.value})})}),k(T,{fraction:Math.abs(t)/j,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),k(q,{children:e.blurb})]},e.id)})})}),k(v,{legend:`Limits`,children:k(G,{children:W.map(e=>k(K,{children:k(w,{label:e.label,hint:e.hint,children:t=>A(p,{$gap:2,children:[k(C,{...t,type:`number`,min:e.min,step:e.step,value:a[e.id]??``,onChange:t=>s({...a,[e.id]:t.target.value})}),k(d,{children:e.unit})]})})},e.id))})}),A(m,{$min:`380px`,$stretch:!0,children:[k(v,{legend:`Request handling`,meta:`applied before dispatch`,children:A(J,{children:[k(Q,{label:`Enable RTK compression`,checked:a.rtkEnabled===`true`,onCheckedChange:e=>s({...a,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.`}),k(Q,{label:`Add a cache breakpoint when a client sends none`,checked:a.autoCacheEnabled===`true`,onCheckedChange:e=>s({...a,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.`}),k(ce,{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=>k(S,{...e,value:a.ponytailMode??`off`,onChange:e=>s({...a,ponytailMode:e.target.value}),children:Object.entries(H).map(([e,t])=>k(`option`,{value:e,children:t},e))})})]})}),k(v,{legend:`Request and response bodies`,meta:t.data===!0?`permitted by the environment`:`not permitted`,children:A(c,{$gap:2,children:[t.data===!0?null:A(ue,{children:[`This gateway started without `,k(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,k(`code`,{children:`.env`}),` and restart first.`]}),A(J,{children:[k(Q,{label:`Capture request and response bodies`,checked:a.bodyLoggingEnabled===`true`,disabled:t.data!==!0,onCheckedChange:e=>s({...a,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.`}),k(Q,{label:`Also keep raw stream frames`,checked:a.bodyLoggingCaptureStreamChunks===`true`,disabled:t.data!==!0||a.bodyLoggingEnabled!==`true`,onCheckedChange:e=>s({...a,bodyLoggingCaptureStreamChunks:String(e)}),children:`Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores.`})]})]})})]}),h===null?null:k(le,{role:`alert`,children:h}),E&&h===null?k($,{role:`status`,children:`Settings saved.`}):null,A(m,{$min:`380px`,$stretch:!0,children:[k(V,{}),k(ne,{})]}),k(v,{legend:`Known limits`,children:A(c,{$gap:2,children:[A(p,{$gap:2,$align:`start`,children:[k(y,{$dim:!0,children:`rate limits`}),k(q,{children:`Counted per gateway process and reset when it restarts. Not shared across instances.`})]}),A(p,{$gap:2,$align:`start`,children:[k(y,{$dim:!0,children:`logs`}),k(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 me=pe;export{me as component};
88
+ `;function de(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 fe(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 pe(){let e=n(),t=i(),a=r(),[o,s]=O({}),[h,x]=O(null),[E,D]=O(!1);ee(()=>{e.data!==void 0&&s(de(e.data))},[e.data]);let j=Math.max(1e-4,...U.map(e=>Math.abs(Number(o[`w.${e.id}`])||0)));return A(te,{children:[k(b,{legend:`Settings`,title:`Routing and retention`,summary:`Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.`,actions:k(l,{type:`button`,$variant:`primary`,disabled:a.isPending||e.isLoading,onClick:()=>{D(!1);let e=fe(o);if(!e.ok){x(e.problem);return}x(null),a.mutate(e.settings,{onSuccess:()=>D(!0),onError:e=>x(_(e))})},children:a.isPending?`Saving…`:`Save changes`})}),e.isError?k(v,{legend:`Settings`,children:k(g,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?k(v,{legend:`Settings`,children:k(f,{rows:6})}):A(c,{$gap:4,children:[k(v,{legend:`Scoring weights`,meta:`relative to each other`,footer:A(p,{children:[k(d,{children:`Score is the sum of each term times its weight, then multiplied by the account and target weights.`}),k(u,{})]}),children:k(G,{children:U.map(e=>{let t=Number(o[`w.${e.id}`])||0;return A(K,{children:[k(w,{label:e.label,children:t=>k(C,{...t,type:`number`,step:.5,value:o[`w.${e.id}`]??``,onChange:t=>s({...o,[`w.${e.id}`]:t.target.value})})}),k(T,{fraction:Math.abs(t)/j,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),k(q,{children:e.blurb})]},e.id)})})}),k(v,{legend:`Limits`,children:k(G,{children:W.map(e=>k(K,{children:k(w,{label:e.label,hint:e.hint,children:t=>A(p,{$gap:2,children:[k(C,{...t,type:`number`,min:e.min,step:e.step,value:o[e.id]??``,onChange:t=>s({...o,[e.id]:t.target.value})}),k(d,{children:e.unit})]})})},e.id))})}),A(m,{$min:`380px`,$stretch:!0,children:[k(v,{legend:`Request handling`,meta:`applied before dispatch`,children:A(J,{children:[k(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.`}),k(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.`}),k(ce,{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=>k(S,{...e,value:o.ponytailMode??`off`,onChange:e=>s({...o,ponytailMode:e.target.value}),children:Object.entries(H).map(([e,t])=>k(`option`,{value:e,children:t},e))})})]})}),k(v,{legend:`Request and response bodies`,meta:t.data===!0?`permitted by the environment`:`not permitted`,children:A(c,{$gap:2,children:[t.data===!0?null:A(ue,{children:[`This gateway started without `,k(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,k(`code`,{children:`.env`}),` and restart first.`]}),A(J,{children:[k(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.`}),k(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:k(le,{role:`alert`,children:h}),E&&h===null?k($,{role:`status`,children:`Settings saved.`}):null,A(m,{$min:`380px`,$stretch:!0,children:[k(V,{}),k(ne,{})]}),k(v,{legend:`Known limits`,children:A(c,{$gap:2,children:[A(p,{$gap:2,$align:`start`,children:[k(y,{$dim:!0,children:`rate limits`}),k(q,{children:`Counted per gateway process and reset when it restarts. Not shared across instances.`})]}),A(p,{$gap:2,$align:`start`,children:[k(y,{$dim:!0,children:`logs`}),k(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 me=pe;export{me as component};
@@ -0,0 +1,76 @@
1
+ import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,Mt as v,N as y,O as b,Ot as x,P as S,Q as C,R as w,S as T,St as E,T as D,Tt as O,U as k,V as ee,W as A,X as te,Y as ne,Z as re,_ as ie,_t as ae,a as j,at as oe,b as M,bt as N,c as se,ct as ce,d as P,dt as le,et as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as ge,i as _e,it as ve,j as ye,jt as be,k as xe,kt as Se,l as Ce,lt as we,m as Te,mt as Ee,n as De,nt as Oe,o as ke,ot as Ae,p as je,pt as Me,q as Ne,r as Pe,rt as Fe,s as Ie,st as Le,t as Re,tt as ze,u as F,ut as Be,v as Ve,vt as He,w as Ue,wt as We,x as I,xt as Ge,y as Ke,yt as qe,z as Je}from"./shared-Dtkw6SE0.js";import{$t as L,Ct as Ye,F as Xe,L as R,Mt as Ze,P as Qe,U as $e,gt as et,j as z,kt as tt,mt as nt}from"./Lamp-DkvXKB-B.js";import{C as B,_ as rt,b as V,g as it,t as at,v as H,w as ot,x as st}from"./Panel-CWmOTDAP.js";import{D as ct,S as lt,t as ut,w as dt}from"./Rack-CEuCdVXc.js";import{i as ft,n as U,r as W,t as pt}from"./Table-CVDZ69Zx.js";import{i as G,n as mt,r as ht,t as gt}from"./SummaryDeck-7ivuca39.js";import*as K from"react";import{PureComponent as _t,forwardRef as vt,useMemo as q,useRef as yt,useState as bt}from"react";import{jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";function xt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function St(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var Ct=(e,t,n)=>C(e,`xAxis`,xt(e,t),n),wt=(e,t,n)=>ue(e,`xAxis`,xt(e,t),n),Tt=(e,t,n)=>C(e,`yAxis`,St(e,t),n),Et=(e,t,n)=>ue(e,`yAxis`,St(e,t),n),Dt=N([ce,Ct,Tt,wt,Et],(e,t,n,r,i)=>He(e,`xAxis`)?Me(t,r,!1):Me(n,i,!1)),Ot=N([ze,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),kt=e=>{var t=ce(e);return He(t,`xAxis`)?`yAxis`:`xAxis`},At=(e,t)=>kt(e)===`yAxis`?St(e,t):xt(e,t),jt=(t,n,r)=>e(t,kt(t),At(t,n),r),Mt=N([Ot,jt],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=Oe(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),Nt=N([Ot,jt],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(O)}}),Pt=N([ce,Ct,Tt,wt,Et,Mt,oe,Dt,Ot,ve,Nt],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return pn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),Ft=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],It=[`id`,`baseLine`];function Lt(){return Lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lt.apply(null,arguments)}function Rt(e,t){if(e==null)return{};var n,r,i=zt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function zt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Bt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!qe(a)||!qe(o))return null;var c=t*Math.abs(a-o),l=Math.max(...r.map(e=>e.y||0));return s(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(e=>e.y||0),l)),s(l)?K.createElement(`rect`,{x:a<o?a:a-c,y:0,width:c,height:Math.floor(l+(i?parseInt(`${i}`,10):1))}):null}function Vt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!qe(a)||!qe(o))return null;var c=t*Math.abs(a-o),l=Math.max(...r.map(e=>e.x||0));return s(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(e=>e.x||0),l)),s(l)?K.createElement(`rect`,{x:0,y:a<o?a:a-c,width:l+(i?parseInt(`${i}`,10):1),height:Math.floor(c)}):null}function Ht(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?K.createElement(Vt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):K.createElement(Bt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Ut(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=Rt(e,Ft),f=s===`vertical`?`vertical`:`horizontal`,m=u??!1,h=p(),g=d.id,_=d.baseLine,v=Rt(d,It),y=be(v),b=K.createElement(Ae,Lt({},d,{id:g,baseLine:_,connectNulls:m,stroke:`none`,className:`recharts-area-area`,layout:f})),x=l!==`none`&&K.createElement(Ae,Lt({},y,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:m,fill:`none`,stroke:l,points:d.points})),S=l!==`none`&&c&&Array.isArray(_)&&K.createElement(Ae,Lt({},y,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:m,fill:`none`,stroke:l,points:_}));return o&&(i||n<1)?K.createElement(Se,null,K.createElement(`defs`,null,K.createElement(`clipPath`,{id:h},K.createElement(Ht,{alpha:n,points:d.points??[],baseLine:_,layout:f,strokeWidth:d.strokeWidth}))),K.createElement(Se,{clipPath:`url(#${h})`},b,x,S)):K.createElement(K.Fragment,null,b,x,S)}var Wt=[`id`],Gt=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Kt(){return Kt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Kt.apply(null,arguments)}function qt(e,t){if(e==null)return{};var n,r,i=Jt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Jt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Yt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Yt(Object(n),!0).forEach(function(t){Xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xt(e,t,n){return(t=Zt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zt(e){var t=Qt(e,`string`);return typeof t==`symbol`?t:t+``}function Qt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var $t={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:ee,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[Z(Z({},e.next),{},{x:a(e.prev.x,e.next.x,t),y:a(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:Ut,xAxisId:0,yAxisId:0,zIndex:Fe.area};function en(e,t){return e&&e!==`none`?e:t}var tn=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:en(r,i),value:me(n,t),payload:e}]},nn=K.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:x,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:me(o,t),hide:s,type:u,color:en(r,a),unit:c,formatter:l,graphicalItemId:d}};return K.createElement(k,{tooltipEntrySettings:f})});function rn(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=be(r);return K.createElement(y,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function an(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return K.createElement(h,{value:t?r:void 0},n)}function on(e){var t=e.points,r=e.baseLine,i=e.needClip,a=e.clipPathId,o=e.props,s=e.animationElapsedTime,c=e.isAnimating,l=e.isEntrance,u=o.layout,d=o.type,f=o.stroke,p=o.connectNulls,m=o.isRange,h=o.shape,g=o.id,_=qt(o,Wt),v=Z(Z({},n(_)),{},{id:g,points:t,connectNulls:p,type:d,baseLine:r,layout:u,stroke:f,isRange:m,animationElapsedTime:s,isAnimating:c,isEntrance:l});return K.createElement(K.Fragment,null,t?.length>1&&K.createElement(Se,{clipPath:i?`url(#clipPath-${a})`:void 0},K.createElement(A,{option:h,DefaultShape:$t.shape,shapeProps:v})),K.createElement(rn,{points:t,props:_,clipPathId:a}))}function sn(e,t,n){if(s(e)){var r=s(t)?t:void 0;return a(r,e,n)}if(l(e)||We(e)){var i=s(t)?t:void 0;return a(i,0,n)}return e}function cn(e){var t=e.needClip,n=e.clipPathId,i=e.props,a=e.previousPointsRef,o=e.previousBaselineRef,s=i.points,c=i.baseLine,l=i.isAnimationActive,u=i.animationBegin,d=i.animationDuration,f=i.animationEasing,p=i.animationMatchBy,m=i.animationInterpolateFn,h=q(()=>({points:s,baseLine:c}),[s,c]),_=Je(h,o),v=we(),y=w(i.onAnimationStart,i.onAnimationEnd),b=y.isAnimating,x=y.handleAnimationStart,S=y.handleAnimationEnd,C=_.startValue;if(v==null)return null;var T=Array.isArray(c)&&Array.isArray(C)?r(C,c,p):Array.isArray(c)?r(null,c,p):null;return K.createElement(g,{animationInput:h,animationIdPrefix:`recharts-area-`,items:s,previousItemsRef:a,isAnimationActive:l,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:x,onAnimationEnd:S,animationInterpolateFn:m,animationMatchBy:p,layout:v},(e,r,a)=>{var o=r===1?c:Array.isArray(c)?m(T,r,v):a?c:sn(c,C,r);return _.syncStepValue(o,r),K.createElement(an,{showLabels:!b,points:s},i.children,K.createElement(on,{points:e,baseLine:o,needClip:t,clipPathId:n,props:i,animationElapsedTime:r,isAnimating:b||r<1,isEntrance:a}),K.createElement(Ne,{label:i.label}))})}function ln(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=yt(null),a=yt();return K.createElement(cn,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var un=class extends _t{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,s=e.left,c=e.needClip,l=e.xAxisId,u=e.yAxisId,f=e.width,p=e.height,m=e.id,h=e.baseLine,g=e.zIndex;if(t)return null;var _=v(`recharts-area`,i),y=m,x=o(n),S=x.r,C=x.strokeWidth,w=d(n),T=S*2+C,E=c?`url(#clipPath-${w?``:`dots-`}${y})`:void 0;return K.createElement(te,{zIndex:g},K.createElement(Se,{className:_},c&&K.createElement(`defs`,null,K.createElement(b,{clipPathId:y,xAxisId:l,yAxisId:u}),!w&&K.createElement(`clipPath`,{id:`clipPath-dots-${y}`},K.createElement(`rect`,{x:s-T/2,y:a-T/2,width:f+T,height:p+T}))),K.createElement(ln,{needClip:c,clipPathId:y,props:this.props})),K.createElement(ye,{points:r,mainColor:en(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}),this.props.isRange&&Array.isArray(h)&&K.createElement(ye,{points:h,mainColor:en(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}))}};function dn(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=qt(e,Gt),g=Be(),v=re(),y=xe(p,m).needClip,b=fe(),x=Ge(t=>Pt(t,e.id,b))??{},S=x.points,C=x.isRange,w=x.baseLine,T=_();if(g!==`horizontal`&&g!==`vertical`||T==null||v!==`AreaChart`&&v!==`ComposedChart`)return null;var E=T.height,D=T.width,O=T.x,k=T.y;return!S||!S.length?null:K.createElement(un,Kt({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:w,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:E,hide:l,layout:g,isAnimationActive:u,isRange:C,legendType:d,needClip:y,points:S,stroke:f,width:D,left:O,top:k,xAxisId:p,yAxisId:m}))}var fn=(e,t,n,r,i)=>{var a=n??t;if(s(a))return a;var o=e===`horizontal`?i:r,c=o.scale.domain();if(o.type===`number`){var l=Math.max(c[0],c[1]),u=Math.min(c[0],c[1]);return a===`dataMin`?u:a===`dataMax`||l<0?l:Math.max(Math.min(c[0],c[1]),0)}return a===`dataMin`?c[0]:a===`dataMax`?c[1]:c[0]};function pn(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=fn(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=ae(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=ae(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>ae(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:Ee({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:Ee({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function mn(e){var t=E(e,$t),n=fe();return K.createElement(u,{id:t.id,type:`area`},e=>K.createElement(K.Fragment,null,K.createElement(f,{legendPayload:tn(t)}),K.createElement(nn,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),K.createElement(S,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:ge(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),K.createElement(dn,Kt({},t,{id:e}))))}var hn=K.memo(mn,Le);hn.displayName=`Area`;var gn=[`axis`],_n=vt((e,t)=>K.createElement(i,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:gn,tooltipPayloadSearcher:ne,categoricalChartProps:e,ref:t})),vn=[`axis`],yn=vt((e,t)=>K.createElement(i,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:vn,tooltipPayloadSearcher:ne,categoricalChartProps:e,ref:t})),bn=53,Q=9,$=2,xn=X.div`
2
+ display: flex;
3
+ gap: ${$}px;
4
+ `,Sn=X.div`
5
+ display: grid;
6
+ grid-template-rows: repeat(7, ${Q}px);
7
+ gap: ${$}px;
8
+ padding-top: ${11}px;
9
+ font-size: 9px;
10
+ color: ${({theme:e})=>e.color.inkFaint};
11
+ `,Cn=X.div`
12
+ line-height: ${Q}px;
13
+ padding-right: 2px;
14
+ text-align: right;
15
+ `,wn=X.div`
16
+ display: grid;
17
+ grid-template-columns: repeat(${bn}, ${Q}px);
18
+ gap: ${$}px;
19
+ height: ${Q}px;
20
+ font-size: 9px;
21
+ color: ${({theme:e})=>e.color.inkFaint};
22
+ `,Tn=X.div`
23
+ white-space: nowrap;
24
+ line-height: ${Q}px;
25
+ `,En=X.div`
26
+ display: grid;
27
+ grid-template-columns: repeat(${bn}, ${Q}px);
28
+ gap: ${$}px;
29
+ `,Dn=X.div`
30
+ display: grid;
31
+ grid-template-rows: repeat(7, ${Q}px);
32
+ gap: ${$}px;
33
+ `,On=X.div`
34
+ width: ${Q}px;
35
+ height: ${Q}px;
36
+ border-radius: 2px;
37
+ background: ${({$level:e})=>e===0?`var(--panel-sunk)`:`color-mix(in oklch, var(--accent) ${[0,24,46,70,100][e]??100}%, var(--panel-sunk))`};
38
+ border: 1px solid var(--rule);
39
+ visibility: ${({$future:e})=>e?`hidden`:`visible`};
40
+
41
+ &:hover,
42
+ &:focus-visible {
43
+ outline: 1px solid var(--ink-dim);
44
+ outline-offset: 1px;
45
+ }
46
+ `,kn=X(V)`
47
+ gap: ${$}px;
48
+ `,An=X(H)`
49
+ color: ${({theme:e})=>e.color.inkDim};
50
+ font-size: 11px;
51
+ `;function jn(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(t.length*e))]??0;return[n(.25),n(.5),n(.75)]}function Mn(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function Nn({days:e,now:t,dayOffsetMinutes:n=null}){let[r,i]=bt(`tokens`),[a,o]=bt(null),s=pe(r),c=q(()=>{let r=new Map;for(let t of e){let e=Number(t.key);Number.isFinite(e)&&r.set(Ke(e,n),{requests:t.requests,errors:t.errors,costUsd:t.costUsd,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens,rtkSavedTokens:t.rtkSavedTokens,rtkAppliedRequests:t.rtkAppliedRequests,durationMsSum:t.durationMsSum})}let i=Ke(t,n),a=se(i,6-Te(i,n)-370,n);return Array.from({length:bn},()=>Array.from({length:7},()=>{let e=a;return a=se(a,1,n),{at:e,totals:r.get(e)??Ie,future:e>i}}))},[e,t,n]),l=c.flat(),u=jn(l.map(e=>s.of({key:``,...e.totals}))),d=l.reduce((e,t)=>Ce(e,P(t.totals)),Ie),f=l.reduce((e,t)=>e+ +(t.totals.requests>0),0),p=(e,t)=>`${e}: ${z(t.requests)} requests, ${z(F(t))} tokens, ${R(t.costUsd)}`;return J(at,{legend:`Activity`,meta:a===null?`${z(f)} active days`:void 0,actions:J(mt,{children:Pe.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:e.label},e.id))}),children:Y(B,{$gap:2,children:[J(st,{children:J(B,{$gap:1,style:{width:611},children:Y(xn,{children:[J(Sn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>J(Cn,{children:e},t))}),Y(B,{$gap:1,children:[J(wn,{"aria-hidden":`true`,children:c.map((e,t)=>{let n=e[0],r=c[t-1]?.[0],i=n!==void 0&&(r===void 0||new Date(r.at).getMonth()!==new Date(n.at).getMonth());return J(Tn,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),J(En,{role:`grid`,"aria-label":`${s.label} per day over the last year`,children:c.map(e=>J(Dn,{role:`row`,children:e.map(e=>J(On,{role:`gridcell`,tabIndex:-1,"aria-label":p(je(e.at),e.totals),title:p(je(e.at),e.totals),$future:e.future,$level:e.future?0:Mn(s.of({key:``,...e.totals}),u),onMouseEnter:()=>o(e),onMouseLeave:()=>o(null)},e.at))},e[0]?.at))})]})]})})}),Y(V,{$justify:`space-between`,$wrap:!0,children:[J(An,{children:a===null?p(`Last 12 months`,d):p(je(a.at),a.totals)}),Y(V,{$gap:1,children:[J(rt,{children:`Less`}),J(kn,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>J(On,{$level:e,$future:!1},e))}),J(rt,{children:`More`})]})]})]})})}function Pn({buckets:e,by:t,since:n,until:r,metric:i,names:a,dayOffsetMinutes:o}){let s=I(n,r,t,o),c=new Map,l=new Map;for(let n of e){let e=n.split??`unknown`;c.set(e,Ce(c.get(e)??Ie,n));let r=l.get(e)??new Map,a=he(n.key,t);r.set(a,(r.get(a)??0)+i.of(n)),l.set(e,r)}let u=[...c.entries()].sort((e,t)=>i.of(P(t[1]))-i.of(P(e[1])));return J(st,{children:Y(pt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Key`}),J(W,{children:`Trend`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Failed`}),J(W,{$align:`right`,children:`Tokens`}),J(W,{$align:`right`,children:`Mean`}),J(W,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:u.map(([e,t])=>{let n=l.get(e)??new Map,r=e===`unknown`?`Unattributed`:a.get(e)??e;return Y(ft,{children:[J(U,{children:J(ot,{style:{display:`block`,maxWidth:`28ch`},children:r})}),J(U,{style:{width:120},children:J(lt,{values:s.map(e=>n.get(e)??0),height:20,label:`${r}: ${i.format(i.of(P(t)))} over the window`})}),J(U,{$align:`right`,$mono:!0,children:z(t.requests)}),J(U,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:Xe(t.requests===0?0:t.errors/t.requests,0)}),J(U,{$align:`right`,$mono:!0,children:z(F(t))}),J(U,{$align:`right`,$mono:!0,children:Qe(t.requests===0?null:t.durationMsSum/t.requests)}),J(U,{$align:`right`,$mono:!0,children:R(t.costUsd)})]},e)})})]})})}var Fn=6,In=`__other__`,Ln=`unknown`;function Rn(e,t,n){let r=n.get(t);return r===void 0?e.find(e=>e.models.some(e=>e.id===t))?.id??null:r}function zn(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${dt(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Bn({buckets:e,by:n,since:r,until:i,dayOffsetMinutes:a,metric:o,providers:s}){let c=Ze().data??[],l=[...de(e,o).entries()],u=l.slice(0,Fn),d=l.slice(Fn),f=[...new Set(u.map(([e])=>Rn(c,e,s)))].filter(e=>e!==null&&$e(c,e)===void 0).sort(),p=[];for(let e of[...c.map(e=>e.id),...f,null])u.filter(([t])=>Rn(c,t,s)===e).forEach(([t,n],r)=>{p.push({name:t,label:t===Ln?`Unresolved`:t,color:zn(e,r),totals:n})});d.length>0&&p.push({name:In,label:`${d.length} more`,color:`var(--ink-faint)`,totals:d.reduce((e,[,t])=>Ce(e,P(t)),Ie)});let h=new Set(u.map(([e])=>e)),g=new Map;for(let t of e){let e=t.split??Ln,r=`${he(t.key,n)} ${h.has(e)?e:In}`;g.set(r,(g.get(r)??0)+o.of(t))}let _=I(r,i,n,a).map(e=>{let t={at:e};for(let n of p)t[n.name]=g.get(`${e} ${n.name}`)??0;return t}),v=new Map(p.map(e=>[e.name,e.label]));return Y(B,{$gap:2,children:[J(Re,{$height:220,children:J(le,{width:`100%`,height:`100%`,children:Y(_n,{data:_,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`at`,tickFormatter:e=>M(e,n),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tickFormatter:e=>o.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t,label:r})=>{if(e!==!0||t===void 0||t.length===0)return null;let i=t.filter(e=>Number(e.value??0)>0);return Y(ke,{children:[J(`div`,{children:M(Number(r),n)}),i.length===0?J(`div`,{children:`No ${o.label.toLowerCase()}`}):i.map(e=>Y(`div`,{children:[v.get(String(e.dataKey))??String(e.dataKey),` `,o.format(Number(e.value??0))]},String(e.dataKey)))]})}}),p.map(e=>J(hn,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),J(De,{children:p.map(e=>Y(`span`,{children:[J(j,{$color:e.color}),` `,J(ot,{title:`${e.label}: ${o.format(o.of(P(e.totals)))} ${o.label.toLowerCase()}`,style:{display:`inline-block`,maxWidth:`24ch`,verticalAlign:`bottom`},children:e.label})]},e.name))})]})}var Vn=`unknown`;function Hn(e,t){return $e(e,t)===void 0?`var(--ink-faint)`:dt(t)}function Un(e,t){return t===Vn?`Unresolved`:$e(e,t)?.label??t}function Wn({buckets:e,by:n,since:r,until:i,metric:a,dayOffsetMinutes:o}){let s=Ze().data??[],c=de(e,a),l=[...c.keys()].filter(e=>e!==Vn&&$e(s,e)===void 0).sort(),u=[...s.map(e=>e.id),...l,Vn].map(e=>({name:e,totals:c.get(e)})).filter(e=>e.totals!==void 0),d=u.map(e=>e.name),f=I(r,i,n,o),p=Ve(e,f,n,a),h=[...c.values()].reduce((e,t)=>e+t.requests,0);return Y(B,{$gap:3,children:[J(Re,{$height:200,children:J(le,{width:`100%`,height:`100%`,children:Y(_n,{data:p,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`at`,tickFormatter:e=>M(e,n),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t,label:r})=>e!==!0||t===void 0||t.length===0?null:Y(ke,{children:[J(`div`,{children:M(Number(r),n)}),t.map(e=>Y(`div`,{children:[Un(s,String(e.dataKey)),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}),d.map(e=>J(hn,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:Hn(s,e),strokeWidth:2,fill:Hn(s,e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),J(De,{children:d.map(e=>Y(`span`,{children:[J(j,{$color:Hn(s,e)}),` `,Un(s,e)]},e))}),Y(pt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Provider`}),J(W,{$align:`right`,children:`Share`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Failed`}),J(W,{$align:`right`,children:`Tokens`}),J(W,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:u.map(({name:e,totals:t})=>Y(ft,{children:[Y(U,{children:[J(j,{$color:Hn(s,e)}),` `,Un(s,e)]}),J(U,{$align:`right`,$mono:!0,children:Xe(h===0?0:t.requests/h,0)}),J(U,{$align:`right`,$mono:!0,children:z(t.requests)}),J(U,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:z(t.errors)}),J(U,{$align:`right`,$mono:!0,children:z(F(t))}),J(U,{$align:`right`,$mono:!0,children:R(t.costUsd)})]},e))})]})]})}var Gn=X.li`
52
+ display: grid;
53
+ grid-template-columns: minmax(0, 20ch) 1fr auto;
54
+ align-items: center;
55
+ gap: ${({theme:e})=>e.space(2)};
56
+ `,Kn=X.ol`
57
+ display: flex;
58
+ flex-direction: column;
59
+ gap: ${({theme:e})=>e.space(2)};
60
+ `,qn=X.div`
61
+ height: 8px;
62
+ border-radius: 2px;
63
+ background: ${({theme:e})=>e.color.panelSunk};
64
+ border: 1px solid ${({theme:e})=>e.color.rule};
65
+ overflow: hidden;
66
+ `,Jn=X.div`
67
+ width: ${({$share:e})=>`${Math.max(1.5,e*100)}%`};
68
+ height: 100%;
69
+ border-radius: 0 2px 2px 0;
70
+ background: ${({theme:e,$fault:t})=>t?e.color.down:e.color.accent};
71
+ opacity: 0.85;
72
+ `,Yn=X(ot)`
73
+ display: block;
74
+ font-family: ${({theme:e})=>e.font.mono};
75
+ font-size: 12px;
76
+ `,Xn=12;function Zn({buckets:e,metric:t,names:n,unknownLabel:r}){let i=new Map;for(let t of e)i.set(t.key,Ce(i.get(t.key)??Ie,t));let a=e=>e===`unknown`?r??`Unattributed`:n?.get(e)??e,o=[...i.entries()].map(([e,n])=>({name:a(e),entry:n,value:t.of(P(n))})).sort((e,t)=>t.value-e.value),s=o.slice(0,Xn),c=o.slice(Xn),l=s[0]?.value??0;return Y(B,{$gap:3,children:[J(Kn,{children:s.map(({name:e,entry:n,value:r})=>Y(Gn,{children:[J(Yn,{title:e,children:e}),J(qn,{children:J(Jn,{$share:l===0?0:r/l,$fault:n.requests>0&&n.errors===n.requests})}),Y(V,{$gap:2,children:[J(H,{$size:`12px`,children:t.format(r)}),J(H,{$size:`11px`,$dim:!0,children:R(n.costUsd)})]})]},e))}),c.length===0?null:J(H,{$size:`11px`,$dim:!0,children:`+ ${c.length} more, ${z(c.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}var Qn=[{id:`inputTokens`,label:`Uncached input`,opacity:.95},{id:`outputTokens`,label:`Output`,opacity:.7},{id:`cacheReadTokens`,label:`Cache read`,opacity:.45},{id:`cacheWriteTokens`,label:`Cache write`,opacity:.22}];function $n({buckets:e,by:n,since:r,until:i,dayOffsetMinutes:a}){let o=new Map;for(let t of e)o.set(he(t.key,n),t);let s=I(r,i,n,a).map(e=>{let t=o.get(e);return{at:e,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,cacheReadTokens:t?.cacheReadTokens??0,cacheWriteTokens:t?.cacheWriteTokens??0}}),c=Qn.map(e=>({...e,value:s.reduce((t,n)=>t+n[e.id],0)})),l=c.reduce((e,t)=>e+t.value,0);return Y(B,{$gap:3,children:[J(Re,{$height:200,children:J(le,{width:`100%`,height:`100%`,children:Y(_n,{data:s,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`at`,tickFormatter:e=>M(e,n),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>z(e)}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t,label:r})=>e!==!0||t===void 0||t.length===0?null:Y(ke,{children:[J(`div`,{children:M(Number(r),n)}),Qn.map(e=>Y(`div`,{children:[e.label,` `,z(Number(t.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),Qn.map(e=>J(hn,{type:`monotone`,dataKey:e.id,stackId:`tokens`,stroke:`var(--accent)`,strokeOpacity:e.opacity,strokeWidth:1.5,fill:`var(--accent)`,fillOpacity:e.opacity*.5,isAnimationActive:!1},e.id))]})})}),J(De,{children:c.map(e=>Y(V,{$gap:1,children:[J(j,{$color:`var(--accent)`,style:{opacity:e.opacity}}),J(`span`,{children:e.label}),J(H,{$size:`11px`,children:z(e.value)}),J(H,{$size:`11px`,$dim:!0,children:Xe(l===0?0:e.value/l,0)})]},e.id))})]})}function er({buckets:e,by:n,since:r,until:i,dayOffsetMinutes:a}){let o=new Map;for(let t of e)o.set(he(t.key,n),t);let s=I(r,i,n,a).map(e=>{let t=o.get(e);return{at:e,label:M(e,n),requests:t?.requests??0,errors:t?.errors??0,costUsd:t?.costUsd??0,tokens:t===void 0?0:F(t)}});return Y(B,{$gap:2,children:[J(Re,{$height:220,children:J(le,{width:`100%`,height:`100%`,children:Y(yn,{data:s,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t})=>{if(e!==!0||t===void 0||t.length===0)return null;let n=t[0]?.payload;return n===void 0?null:Y(ke,{children:[J(`div`,{children:n.label}),Y(`div`,{children:[z(n.requests),` requests`]}),Y(`div`,{children:[z(n.errors),` failed`]}),Y(`div`,{children:[z(n.tokens),` tokens`]}),J(`div`,{children:R(n.costUsd)})]})}}),J(hn,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),J(c,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),J(c,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),Y(De,{children:[Y(`span`,{children:[J(j,{$color:`var(--accent)`}),` Requests`]}),Y(`span`,{children:[J(j,{$color:`var(--down)`}),` Failed`]})]})]})}var tr=864e5,nr=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function rr(){let{cadence:e}=ct(),[t,n]=bt(`24h`),[r,i]=bt(`tokens`),[a,o]=bt(`model`),s=ie(t),c=pe(r),l=et().data??null,u=q(()=>s.grain===`daily`?Ke(Date.now()-s.ms,l):Math.floor((Date.now()-s.ms)/6e4)*6e4,[s,l]),d=q(()=>u+s.ms,[u,s]),f=q(()=>Ke(Date.now()-371*tr,l),[l]),p={since:u,grain:s.grain},m=L({...p,groupBy:s.by},e(6e4,`res:usage`)),h=L({...p,groupBy:s.by,splitBy:`provider`},e(6e4,`res:usage`)),g=L({...p,groupBy:s.by,splitBy:`model`},e(6e4,`res:usage`)),_=L({...p,groupBy:s.by,splitBy:`apiKey`},e(6e4,`res:usage`)),v=L({...p,groupBy:a},e(6e4,`res:usage`)),y=L({...p,groupBy:`credential`},e(6e4,`res:usage`)),b=L({since:f,grain:`daily`,groupBy:`day`},e(3e5,`res:usage`)),x=Ye(),S=nt(),C=tt(),w=q(()=>{let e=new Map;for(let t of C.data??[])for(let n of t.targets)e.set(n.model,n.provider);return e},[C.data]),E=q(()=>{let e=new Map;for(let t of x.data??[])e.set(t.id,t.label);return e},[x.data]),D=q(()=>{let e=new Map;for(let t of S.data??[])e.set(t.id,t.label);return e},[S.data]),O=m.data??[],k=T(O),ee=F(k),A={legend:`Nothing recorded`,message:`No requests landed in this window. Widen the range, or send traffic through the gateway.`};return Y(B,{$gap:4,children:[J(ut,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:m.isLoading?`Reading usage…`:`${z(k.requests)} requests and ${R(k.costUsd)} over the last ${s.label}.`,actions:J(mt,{children:_e.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:e.id},e.id))})}),J(gt,{buckets:O,since:u,until:d,by:s.by,rangeLabel:s.label,dayOffsetMinutes:l}),J(G,{legend:`Traffic`,meta:s.by===`hour`?`By hour`:`By day`,query:m,isEmpty:O.length===0,empty:A,children:J(er,{buckets:O,by:s.by,since:u,until:d,dayOffsetMinutes:l})}),J(mt,{children:Pe.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:`Rank by ${e.label.toLowerCase()}`},e.id))}),J(G,{legend:`Traffic by upstream model`,meta:`${c.label}, ${s.by===`hour`?`by hour`:`by day`}`,query:g,isEmpty:(g.data??[]).length===0,empty:A,children:J(Bn,{buckets:g.data??[],by:s.by,since:u,until:d,dayOffsetMinutes:l,metric:c,providers:w})}),Y(it,{$min:`480px`,$gap:4,children:[Y(B,{$gap:4,children:[J(G,{legend:`Providers`,meta:c.label,query:h,isEmpty:(h.data??[]).length===0,empty:A,children:J(Wn,{buckets:h.data??[],by:s.by,since:u,until:d,dayOffsetMinutes:l,metric:c})}),J(Nn,{days:b.data??[],now:Date.now(),dayOffsetMinutes:l})]}),Y(B,{$gap:4,children:[J(G,{legend:`Token mix`,meta:z(ee),query:m,isEmpty:O.length===0,empty:A,children:J($n,{buckets:O,by:s.by,since:u,until:d,dayOffsetMinutes:l})}),J(G,{legend:`Models`,meta:nr.find(e=>e.id===a)?.column,query:v,isEmpty:(v.data??[]).length===0,empty:A,actions:J(mt,{children:nr.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===a,"aria-pressed":e.id===a,onClick:()=>o(e.id),children:e.label},e.id))}),children:J(Zn,{buckets:v.data??[],metric:c})}),J(G,{legend:`Accounts`,meta:c.label,query:y,isEmpty:(y.data??[]).length===0,empty:A,children:J(Zn,{buckets:y.data??[],metric:c,names:D,unknownLabel:`No account`})})]})]}),J(G,{legend:`API keys`,meta:c.label,query:_,isEmpty:(_.data??[]).length===0,empty:A,children:J(Pn,{buckets:_.data??[],by:s.by,since:u,until:d,dayOffsetMinutes:l,metric:c,names:E})})]})}var ir=rr;export{ir as component};
@@ -0,0 +1 @@
1
+ import{A as e}from"./Rack-CEuCdVXc.js";var t={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};t.node;var n=e(t);export{n as t};
@@ -0,0 +1 @@
1
+ import{A as e}from"./Rack-CEuCdVXc.js";var t={name:`chevron-right`,size:24,node:[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]};t.node;var n=e(t);export{n as t};