omnigateway 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +334 -8
- package/bin/omni.js +1929 -147
- package/gateway.js +3129 -555
- package/package.json +1 -1
- package/public/assets/{Chip-DJwp7gBu.js → Chip-DbKk1ExR.js} +1 -1
- package/public/assets/Confirm-C5DYoI93.js +4 -0
- package/public/assets/CopyValue-CXjietiZ.js +27 -0
- package/public/assets/{Field-BDtp692L.js → Field-B7GOsJf8.js} +1 -1
- package/public/assets/Lamp-QRSv-SqM.js +25 -0
- package/public/assets/{Meter-BREBUFGX.js → Meter-Dngwbpjo.js} +1 -1
- package/public/assets/Modal-DfltaSCz.js +82 -0
- package/public/assets/Rack-D1zBw9SW.js +151 -0
- package/public/assets/{Readout-CEAoN5hu.js → Readout--CQnPjoO.js} +2 -2
- package/public/assets/{States-BEKLros0.js → States-CQFkw1UZ.js} +3 -3
- package/public/assets/{Table-BBypbVWj.js → Table-Ba58Wg4-.js} +1 -1
- package/public/assets/Toggle-DWrWc9-9.js +39 -0
- package/public/assets/TokenBreakdown-CyHJv0O5.js +31 -0
- package/public/assets/_app-CTDgfstQ.js +1 -0
- package/public/assets/_app.accounts-DP6T8z7I.js +64 -0
- package/public/assets/{_app.console-DKyGL9xx.js → _app.console-DYr7TCAl.js} +10 -10
- package/public/assets/_app.database-BzO1S_VR.js +39 -0
- package/public/assets/_app.index-CBt6b-lA.js +62 -0
- package/public/assets/_app.keys-B8HGsPPS.js +76 -0
- package/public/assets/_app.logs-DKsxa2Su.js +68 -0
- package/public/assets/{_app.models-CDqVrAeF.js → _app.models-CZD2UpM-.js} +28 -28
- package/public/assets/_app.settings-B2C1LQIF.js +46 -0
- package/public/assets/_app.usage-CDWUXtZy.js +83 -0
- package/public/assets/dist-IkJ0qg-4.js +1 -0
- package/public/assets/index-ClU3Xqui.js +186 -0
- package/public/assets/login-E3gh2_Cl.js +36 -0
- package/public/assets/plus-DkO4vG-T.js +1 -0
- package/public/assets/queries-BJHk_wso.js +144 -0
- package/public/assets/reasons-Cb8yF4Oy.js +1 -0
- package/public/assets/{shared-CIhZ6FCO.js → shared-Bp35cgFf.js} +7 -7
- package/public/assets/{trash-2-CLYNAAJA.js → trash-2-DTWWI3vA.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/Confirm-CVLz9F7a.js +0 -4
- package/public/assets/CopyValue-CNZbWS59.js +0 -27
- package/public/assets/Lamp-B65uWKbW.js +0 -25
- package/public/assets/Modal-DbydSAlp.js +0 -82
- package/public/assets/Rack-Bbo4JfEX.js +0 -151
- package/public/assets/Toggle-BUr71O4J.js +0 -39
- package/public/assets/TokenBreakdown-C1ziK9d1.js +0 -31
- package/public/assets/_app-ByQ1bPbe.js +0 -1
- package/public/assets/_app.accounts-BTug_Xfo.js +0 -64
- package/public/assets/_app.index-CSw9gmMf.js +0 -62
- package/public/assets/_app.keys-07Kbw4RS.js +0 -39
- package/public/assets/_app.logs-C9QiV39p.js +0 -32
- package/public/assets/_app.settings-DmUEeTaP.js +0 -38
- package/public/assets/_app.usage-B1WuMGRr.js +0 -83
- package/public/assets/dist-Bka7ErcH.js +0 -1
- package/public/assets/index-DJfb1i4P.js +0 -186
- package/public/assets/login-DKZYqRh0.js +0 -33
- package/public/assets/queries-D8LJNQpL.js +0 -144
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import{$t as e,
|
|
1
|
+
import{$t as e,O as t,P as n,Q as r,Qt as i,R as a,X as o,Y as s,_n as c,at as l,et as u,g as d,nt as f,ot as p,tt as m,ut as h,x as g,y as _}from"./queries-BJHk_wso.js";import{r as v}from"./index-ClU3Xqui.js";import{c as y,t as b}from"./Rack-D1zBw9SW.js";import{t as x}from"./plus-DkO4vG-T.js";import{t as S}from"./trash-2-DTWWI3vA.js";import{t as C}from"./Toggle-DWrWc9-9.js";import{t as ee}from"./Confirm-C5DYoI93.js";import{n as w,t as T}from"./Chip-DbKk1ExR.js";import{i as E,n as te,r as D,t as O}from"./Field-B7GOsJf8.js";import{t as k}from"./Meter-Dngwbpjo.js";import{a as A,i as j,n as ne,r as M,t as N}from"./States-CQFkw1UZ.js";import{i as re,n as ie,r as P,t as F}from"./catalog-BBKm8Ih8.js";var ae=y(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),oe=y(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),I=c(e(),1),L=i(),se=[`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=h.li`
|
|
2
2
|
padding: ${({theme:e})=>e.space(2)} 0;
|
|
3
3
|
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
4
4
|
|
|
5
5
|
&:last-child {
|
|
6
6
|
border-bottom: 0;
|
|
7
7
|
}
|
|
8
|
-
`,ue=
|
|
8
|
+
`,ue=h(o)`
|
|
9
9
|
width: 22px;
|
|
10
10
|
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
11
|
flex: none;
|
|
12
|
-
`,de=
|
|
12
|
+
`,de=h(T)`
|
|
13
13
|
border-color: ${({theme:e})=>e.color.ok};
|
|
14
14
|
color: ${({theme:e})=>e.color.ok};
|
|
15
15
|
background: ${({theme:e})=>e.color.okWash};
|
|
16
|
-
`,fe=
|
|
16
|
+
`,fe=h.div`
|
|
17
17
|
display: grid;
|
|
18
18
|
grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
|
|
19
19
|
gap: ${({theme:e})=>e.space(2)};
|
|
20
20
|
margin-top: ${({theme:e})=>e.space(2)};
|
|
21
21
|
padding-left: 30px;
|
|
22
|
-
`,pe=
|
|
22
|
+
`,pe=h.div`
|
|
23
23
|
display: flex;
|
|
24
24
|
flex-direction: column;
|
|
25
25
|
gap: 3px;
|
|
26
26
|
min-width: 0;
|
|
27
|
-
`,me=
|
|
27
|
+
`,me=h.div`
|
|
28
28
|
display: flex;
|
|
29
29
|
align-items: baseline;
|
|
30
30
|
justify-content: space-between;
|
|
31
31
|
gap: 6px;
|
|
32
|
-
`,he=
|
|
32
|
+
`,he=h.li`
|
|
33
33
|
display: flex;
|
|
34
34
|
align-items: center;
|
|
35
35
|
gap: ${({theme:e})=>e.space(2)};
|
|
36
36
|
padding: 5px 0;
|
|
37
|
-
`,ge=
|
|
37
|
+
`,ge=h(r)`
|
|
38
38
|
gap: ${({theme:e})=>e.space(3)};
|
|
39
39
|
flex-wrap: wrap;
|
|
40
|
-
`,R=
|
|
40
|
+
`,R=h.label`
|
|
41
41
|
display: flex;
|
|
42
42
|
align-items: center;
|
|
43
43
|
gap: 6px;
|
|
44
44
|
cursor: pointer;
|
|
45
45
|
font-size: 12.5px;
|
|
46
|
-
`,_e=
|
|
46
|
+
`,_e=h.p`
|
|
47
47
|
font-size: 12px;
|
|
48
48
|
color: ${({theme:e})=>e.color.down};
|
|
49
|
-
`;function z(e,t,n){return(e[t]??0)*n[t]}function ve({modelId:e}){let[n
|
|
49
|
+
`;function z(e,t,n){return(e[t]??0)*n[t]}function ve({modelId:e}){let[t,n]=(0,I.useState)({tools:!1,images:!1,reasoning:!1}),[i,c]=(0,I.useState)(null),[d,p]=(0,I.useState)(null),h=a(),_=g(),v=h.data?.weights,y=()=>{e!==null&&(p(null),_.mutate({modelId:e,need:t},{onSuccess:e=>c(e),onError:e=>{c(null),p(j(e))}}))},b=new Map(se.map(e=>[e,Math.max(1e-4,...(i?.candidates??[]).map(t=>v===void 0?0:Math.abs(z(t.reasons,e,v))))]));return(0,L.jsx)(A,{legend:`Explain`,meta:e??`no model selected`,actions:(0,L.jsxs)(l,{type:`button`,$size:`sm`,$variant:`primary`,disabled:e===null||_.isPending,onClick:y,children:[(0,L.jsx)(ae,{}),_.isPending?`Ranking…`:`Rank candidates`]}),children:(0,L.jsxs)(m,{$gap:3,children:[(0,L.jsxs)(m,{$gap:1,children:[(0,L.jsx)(s,{children:`Pretend the request needs`}),(0,L.jsxs)(ge,{children:[(0,L.jsxs)(R,{children:[(0,L.jsx)(C,{checked:t.tools,label:`Probe request uses tools`,onCheckedChange:e=>n({...t,tools:e})}),`Tools`]}),(0,L.jsxs)(R,{children:[(0,L.jsx)(C,{checked:t.images,label:`Probe request includes an image`,onCheckedChange:e=>n({...t,images:e})}),`Images`]}),(0,L.jsxs)(R,{children:[(0,L.jsx)(C,{checked:t.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>n({...t,reasoning:e})}),`Reasoning`]})]})]}),d===null?null:(0,L.jsx)(_e,{children:d}),i===null?(0,L.jsx)(N,{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.`}):(0,L.jsxs)(m,{$gap:3,children:[(0,L.jsxs)(r,{$gap:2,$wrap:!0,children:[(0,L.jsx)(T,{$tone:`accent`,children:i.strategy}),i.deterministic?null:(0,L.jsx)(T,{$tone:`warn`,children:`order varies per request`}),(0,L.jsx)(u,{}),(0,L.jsxs)(s,{children:[i.candidates.length,` eligible · `,i.excluded.length,` filtered out`]})]}),i.candidates.length===0?(0,L.jsx)(N,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):(0,L.jsx)(`ul`,{children:i.candidates.map((e,t)=>(0,L.jsxs)(le,{children:[(0,L.jsxs)(r,{$gap:2,children:[(0,L.jsx)(ue,{children:t+1}),(0,L.jsx)(w,{provider:e.provider}),(0,L.jsx)(f,{style:{maxWidth:`22ch`},children:e.credentialLabel}),(0,L.jsx)(o,{$dim:!0,children:e.model}),(0,L.jsxs)(T,{children:[`tier `,e.tier]}),(0,L.jsx)(u,{}),t===0?(0,L.jsx)(de,{children:`would be used`}):null,(0,L.jsx)(o,{children:e.score.toFixed(2)})]}),v===void 0?null:(0,L.jsx)(fe,{children:se.map(t=>{let n=z(e.reasons,t,v),r=b.get(t)??1;return(0,L.jsxs)(pe,{title:ce[t],children:[(0,L.jsxs)(me,{children:[(0,L.jsx)(s,{children:t}),(0,L.jsx)(o,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),(0,L.jsx)(k,{fraction:Math.abs(n)/r,height:4,tone:`var(--accent)`,label:`${t} contributes ${n.toFixed(2)} of ${e.score.toFixed(2)}`})]},t)})})]},`${e.credentialId}:${e.model}`))}),i.excluded.length===0?null:(0,L.jsxs)(m,{$gap:1,children:[(0,L.jsx)(s,{children:`Filtered out`}),(0,L.jsx)(`ul`,{children:i.excluded.map(e=>(0,L.jsxs)(he,{children:[(0,L.jsx)(o,{$dim:!0,children:e.model}),(0,L.jsx)(u,{}),(0,L.jsx)(T,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}var B=[{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.`}],V=0;function H(){return V+=1,`target-${V}`}function U(e,t){let n=re(e,t);return n===null?null:{costInput:String(n.input),costOutput:String(n.output),costCacheRead:String(n.cacheRead),costCacheWrite5m:String(n.cacheWrite5m),costCacheWrite1h:String(n.cacheWrite1h)}}function ye(e,t){let n=ie(e,t);return n===null?null:{contextWindow:String(n.contextWindow),maxOutputTokens:String(n.maxOutputTokens)}}var be={oauth:`OAuth`,apiKey:`an API key`};function W(e){return e.map(e=>be[e]).join(` or `)}function xe(e){let t={};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 G(e,t,n){let r=n[e];return r===void 0||r.length===0||P(e,t).some(e=>r.includes(e))}function Se(e,t){return F[e].models.filter(n=>G(e,n.id,t))}function Ce(e,t,n){if(t.trim().length===0||G(e,t,n))return null;let r=n[e]??[];return`${e} serves this model to ${W(P(e,t))} only, and every ${e} account here is ${W(r)}. Requests routed here will fail.`}function we(e,t){return{...e,...t,...U(t.provider,t.model)??{},contextWindow:``,maxOutputTokens:``}}function K(e=`anthropic`){let t=F[e].defaultModel,n=U(e,t);return{key:H(),provider:e,endpointId:``,model:t,tier:`1`,weight:`1`,costInput:n?.costInput??`0`,costOutput:n?.costOutput??`0`,costCacheRead:n?.costCacheRead??``,costCacheWrite5m:n?.costCacheWrite5m??``,costCacheWrite1h:n?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,tools:!0,images:!0,reasoning:!0}}function q(){return{id:``,strategy:`score`,isAlias:!1,targets:[K()]}}function J(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:H(),provider:e.provider,endpointId:e.provider===`custom`?e.endpointId??``:``,model:e.model,tier:String(e.tier),weight:String(e.weight),costInput:String(e.costPerMTok.input),costOutput:String(e.costPerMTok.output),costCacheRead:e.costPerMTok.cacheRead===void 0?``:String(e.costPerMTok.cacheRead),costCacheWrite5m:e.costPerMTok.cacheWrite5m===void 0?``:String(e.costPerMTok.cacheWrite5m),costCacheWrite1h:e.costPerMTok.cacheWrite1h===void 0?``:String(e.costPerMTok.cacheWrite1h),contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),maxOutputTokens:e.maxOutputTokens===void 0?``:String(e.maxOutputTokens),tools:e.capabilities.tools,images:e.capabilities.images,reasoning:e.capabilities.reasoning}))}}function Te(e){let t=e.id.trim();if(t.length===0)return{ok:!1,problem:`Give the model a name clients will ask for.`};if(e.targets.length===0)return{ok:!1,problem:`A model needs at least one target to route to.`};let n=[];for(let[t,r]of e.targets.entries()){let e=`Target ${t+1}`,i=r.endpointId.trim();if(r.provider===`custom`&&i.length===0)return{ok:!1,problem:`${e} needs a custom endpoint.`};let a=r.model.trim();if(a.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let o=Number(r.tier);if(!Number.isInteger(o)||o<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let s=Number(r.weight);if(!Number.isFinite(s)||s<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let c=Number(r.costInput),l=Number(r.costOutput);if(!Number.isFinite(c)||c<0||!Number.isFinite(l)||l<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let u=r.costCacheRead.trim().length>0,d=Number(r.costCacheRead);if(u&&(!Number.isFinite(d)||d<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let f=r.costCacheWrite5m.trim().length>0,p=Number(r.costCacheWrite5m);if(f&&(!Number.isFinite(p)||p<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let m=r.costCacheWrite1h.trim().length>0,h=Number(r.costCacheWrite1h);if(m&&(!Number.isFinite(h)||h<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let g=r.contextWindow.trim().length>0,_=Number(r.contextWindow);if(g&&(!Number.isInteger(_)||_<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let v=r.maxOutputTokens.trim().length>0,y=Number(r.maxOutputTokens);if(v&&(!Number.isInteger(y)||y<1))return{ok:!1,problem:`${e}: the output limit must be a whole number of tokens.`};n.push({provider:r.provider,...r.provider===`custom`?{endpointId:i}:{},model:a,tier:o,weight:s,costPerMTok:{input:c,output:l,...u?{cacheRead:d}:{},...f?{cacheWrite5m:p}:{},...m?{cacheWrite1h:h}:{}},...g?{contextWindow:_}:{},...v?{maxOutputTokens:y}:{},capabilities:{tools:r.tools,images:r.images,reasoning:r.reasoning}})}return{ok:!0,model:{id:t,strategy:e.strategy,isAlias:e.isAlias,targets:n}}}var Ee=Object.keys(F),De=h.fieldset`
|
|
50
50
|
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
51
51
|
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
52
52
|
border-radius: ${({theme:e})=>e.radius.control};
|
|
@@ -57,7 +57,7 @@ import{$t as e,B as t,C as n,Ft as r,H as i,I as a,N as o,P as s,Pt as c,R as l,
|
|
|
57
57
|
flex-direction: column;
|
|
58
58
|
gap: ${({theme:e})=>e.space(3)};
|
|
59
59
|
min-width: 0;
|
|
60
|
-
`,Oe=
|
|
60
|
+
`,Oe=h.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,40 +66,40 @@ import{$t as e,B as t,C as n,Ft as r,H as i,I as a,N as o,P as s,Pt as c,R as l,
|
|
|
66
66
|
@media (max-width: 720px) {
|
|
67
67
|
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
68
68
|
}
|
|
69
|
-
`,Y=
|
|
69
|
+
`,Y=h.div`
|
|
70
70
|
display: grid;
|
|
71
71
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
72
72
|
gap: ${({theme:e})=>e.space(2)};
|
|
73
73
|
align-items: end;
|
|
74
|
-
`,X=
|
|
74
|
+
`,X=h.div`
|
|
75
75
|
display: flex;
|
|
76
76
|
flex-direction: column;
|
|
77
77
|
gap: 4px;
|
|
78
78
|
min-width: 0;
|
|
79
|
-
`,ke=
|
|
79
|
+
`,ke=h(r)`
|
|
80
80
|
gap: ${({theme:e})=>e.space(3)};
|
|
81
81
|
flex-wrap: wrap;
|
|
82
|
-
`,Ae=
|
|
82
|
+
`,Ae=h.p`
|
|
83
83
|
font-size: 11.5px;
|
|
84
84
|
color: ${({theme:e})=>e.color.down};
|
|
85
85
|
margin: 0;
|
|
86
|
-
`,Z=
|
|
86
|
+
`,Z=h.label`
|
|
87
87
|
display: flex;
|
|
88
88
|
align-items: center;
|
|
89
89
|
gap: 6px;
|
|
90
90
|
cursor: pointer;
|
|
91
|
-
`;function je({target:e,index:t,onChange:n,onRemove:
|
|
91
|
+
`;function je({target:e,index:t,onChange:n,onRemove:i,removable:a,endpoints:o,held:c}){let d=(0,I.useId)(),f=F[e.provider],h=Se(e.provider,c),g=Ce(e.provider,e.model,c),_=(t,r)=>{n({...e,[t]:r})},y=U(e.provider,e.model),b=ye(e.provider,e.model),x=t=>{n(we(e,t))};return(0,L.jsxs)(De,{$provider:e.provider,children:[(0,L.jsxs)(r,{$gap:2,children:[(0,L.jsxs)(s,{as:`legend`,children:[`Target `,t+1]}),(0,L.jsx)(u,{}),(0,L.jsx)(p,{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:(0,L.jsx)(S,{})})]}),(0,L.jsxs)(Oe,{children:[(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-provider`,children:`Provider`}),(0,L.jsx)(E,{id:`${d}-provider`,value:e.provider,onChange:t=>{let n=t.target.value,r=F[n].models.some(t=>t.id===e.model);x({provider:n,model:r?e.model:F[n].defaultModel})},children:Ee.map(e=>(0,L.jsx)(`option`,{value:e,children:v[e]},e))})]}),e.provider===`custom`?(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-endpoint`,children:`Endpoint`}),(0,L.jsxs)(E,{id:`${d}-endpoint`,value:e.endpointId,onChange:e=>_(`endpointId`,e.target.value),children:[(0,L.jsx)(`option`,{value:``,children:`Choose endpoint`}),o.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}):null,(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-model`,children:`Provider model`}),(0,L.jsx)(te,{id:`${d}-model`,list:`${d}-catalog`,value:e.model,placeholder:f.defaultModel,onChange:t=>x({provider:e.provider,model:t.target.value})}),(0,L.jsx)(`datalist`,{id:`${d}-catalog`,children:h.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))}),g===null?null:(0,L.jsx)(Ae,{role:`note`,children:g})]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-tier`,children:`Tier`}),(0,L.jsx)(D,{id:`${d}-tier`,min:1,step:1,value:e.tier,onChange:e=>_(`tier`,e.target.value)})]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-weight`,children:`Weight`}),(0,L.jsx)(D,{id:`${d}-weight`,min:0,step:.1,value:e.weight,onChange:e=>_(`weight`,e.target.value)})]})]}),(0,L.jsxs)(m,{$gap:1,children:[(0,L.jsxs)(r,{$gap:2,children:[(0,L.jsx)(s,{children:`Price per million tokens`}),(0,L.jsx)(u,{}),y===null?(0,L.jsx)(s,{as:`span`,children:`not in the catalog — price it yourself`}):(0,L.jsxs)(l,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:e.costInput===y.costInput&&e.costOutput===y.costOutput&&e.costCacheRead===y.costCacheRead&&e.costCacheWrite5m===y.costCacheWrite5m&&e.costCacheWrite1h===y.costCacheWrite1h,onClick:()=>n({...e,...y}),children:[(0,L.jsx)(oe,{}),`Use list price`]})]}),(0,L.jsxs)(Y,{children:[(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-in`,children:`Input`}),(0,L.jsx)(D,{id:`${d}-in`,min:0,step:.01,value:e.costInput,onChange:e=>_(`costInput`,e.target.value)})]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-out`,children:`Output`}),(0,L.jsx)(D,{id:`${d}-out`,min:0,step:.01,value:e.costOutput,onChange:e=>_(`costOutput`,e.target.value)})]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-cache`,children:`Cache read`}),(0,L.jsx)(D,{id:`${d}-cache`,min:0,step:.01,placeholder:`same as input`,value:e.costCacheRead,onChange:e=>_(`costCacheRead`,e.target.value)})]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-write5m`,children:`Cache write 5m`}),(0,L.jsx)(D,{id:`${d}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:e.costCacheWrite5m,onChange:e=>_(`costCacheWrite5m`,e.target.value)})]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-write1h`,children:`Cache write 1h`}),(0,L.jsx)(D,{id:`${d}-write1h`,min:0,step:.01,placeholder:`2x input`,value:e.costCacheWrite1h,onChange:e=>_(`costCacheWrite1h`,e.target.value)})]})]})]}),(0,L.jsxs)(m,{$gap:1,children:[(0,L.jsxs)(r,{$gap:2,children:[(0,L.jsx)(s,{children:`Token limits`}),(0,L.jsx)(u,{}),b===null?(0,L.jsx)(s,{as:`span`,children:`not in the catalog — state them yourself`}):(0,L.jsx)(s,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),(0,L.jsxs)(Y,{children:[(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-context`,children:`Context window`}),(0,L.jsx)(D,{id:`${d}-context`,min:1,step:1024,placeholder:b?.contextWindow??`published`,value:e.contextWindow,onChange:e=>_(`contextWindow`,e.target.value)})]}),(0,L.jsxs)(X,{children:[(0,L.jsx)(s,{as:`label`,htmlFor:`${d}-maxout`,children:`Max output`}),(0,L.jsx)(D,{id:`${d}-maxout`,min:1,step:1024,placeholder:b?.maxOutputTokens??`published`,value:e.maxOutputTokens,onChange:e=>_(`maxOutputTokens`,e.target.value)})]})]})]}),(0,L.jsxs)(m,{$gap:1,children:[(0,L.jsx)(s,{children:`Capabilities`}),(0,L.jsxs)(ke,{children:[(0,L.jsxs)(Z,{children:[(0,L.jsx)(C,{checked:e.tools,label:`Target ${t+1} supports tools`,onCheckedChange:e=>_(`tools`,e)}),`Tools`]}),(0,L.jsxs)(Z,{children:[(0,L.jsx)(C,{checked:e.images,label:`Target ${t+1} supports images`,onCheckedChange:e=>_(`images`,e)}),`Images`]}),(0,L.jsxs)(Z,{children:[(0,L.jsx)(C,{checked:e.reasoning,label:`Target ${t+1} supports reasoning`,onCheckedChange:e=>_(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Q=h.p`
|
|
92
92
|
font-size: 11.5px;
|
|
93
93
|
color: ${({theme:e})=>e.color.inkDim};
|
|
94
|
-
`,Me=
|
|
94
|
+
`,Me=h.p`
|
|
95
95
|
font-size: 12px;
|
|
96
96
|
color: ${({theme:e})=>e.color.down};
|
|
97
|
-
`,Ne=
|
|
97
|
+
`,Ne=h.p`
|
|
98
98
|
font-size: 12px;
|
|
99
99
|
color: ${({theme:e})=>e.color.ok};
|
|
100
|
-
`,Pe=
|
|
100
|
+
`,Pe=h(r)`
|
|
101
101
|
gap: 8px;
|
|
102
|
-
`;function Fe({model:e,onSaved:t,onDeleted:
|
|
102
|
+
`;function Fe({model:e,onSaved:t,onDeleted:i}){let[a,o]=(0,I.useState)(()=>e===null?q():J(e)),[c,f]=(0,I.useState)(null),[p,h]=(0,I.useState)(!1),[g,v]=(0,I.useState)(!1),y=n(),b=_(),S=d(),w=xe(S.data??[]),T=(S.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),D=e?.id??null;(0,I.useEffect)(()=>{o(e===null?q():J(e)),f(null),h(!1)},[D]);let k=B.find(e=>e.id===a.strategy);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{legend:e===null?`New model`:`Edit model`,meta:e===null?void 0:e.id,actions:(0,L.jsxs)(L.Fragment,{children:[e===null?null:(0,L.jsx)(l,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>v(!0),children:`Delete`}),(0,L.jsx)(l,{type:`button`,$variant:`primary`,$size:`sm`,disabled:y.isPending,onClick:()=>{h(!1);let e=Te(a);if(!e.ok){f(e.problem);return}f(null),y.mutate(e.model,{onSuccess:()=>{h(!0),t(e.model.id)},onError:e=>f(j(e))})},children:y.isPending?`Saving…`:e===null?`Create model`:`Save changes`})]}),children:(0,L.jsxs)(m,{$gap:3,children:[(0,L.jsx)(O,{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=>(0,L.jsx)(te,{...t,value:a.id,disabled:e!==null,placeholder:`fast`,onChange:e=>o({...a,id:e.target.value})})}),(0,L.jsx)(O,{label:`Routing strategy`,children:e=>(0,L.jsx)(E,{...e,value:a.strategy,onChange:e=>o({...a,strategy:e.target.value}),children:B.map(e=>(0,L.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),k===void 0?null:(0,L.jsx)(Q,{children:k.blurb}),(0,L.jsxs)(Pe,{children:[(0,L.jsx)(C,{checked:a.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>o({...a,isAlias:e})}),(0,L.jsxs)(m,{$gap:0,children:[(0,L.jsx)(s,{as:`span`,children:`Alias`}),(0,L.jsx)(Q,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),(0,L.jsxs)(m,{$gap:2,children:[(0,L.jsxs)(r,{children:[(0,L.jsx)(s,{children:`Targets`}),(0,L.jsx)(u,{}),(0,L.jsxs)(l,{type:`button`,$size:`sm`,onClick:()=>o({...a,targets:[...a.targets,K(a.targets.at(-1)?.provider??`anthropic`)]}),children:[(0,L.jsx)(x,{}),`Add target`]})]}),a.targets.map((e,t)=>(0,L.jsx)(je,{target:e,index:t,removable:a.targets.length>1,endpoints:T,held:w,onChange:t=>o({...a,targets:a.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>o({...a,targets:a.targets.filter(t=>t.key!==e.key)})},e.key))]}),c===null?null:(0,L.jsx)(Me,{role:`alert`,children:c}),p&&c===null?(0,L.jsx)(Ne,{role:`status`,children:`Saved.`}):null]})}),(0,L.jsx)(ee,{open:g,onOpenChange:v,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:b.isPending,onConfirm:()=>{e!==null&&b.mutate(e.id,{onSuccess:()=>{v(!1),i()},onError:e=>{v(!1),f(j(e))}})}})]})}var Ie=h.div`
|
|
103
103
|
display: grid;
|
|
104
104
|
grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
|
|
105
105
|
gap: ${({theme:e})=>e.space(4)};
|
|
@@ -108,10 +108,10 @@ import{$t as e,B as t,C as n,Ft as r,H as i,I as a,N as o,P as s,Pt as c,R as l,
|
|
|
108
108
|
@media (max-width: 980px) {
|
|
109
109
|
grid-template-columns: minmax(0, 1fr);
|
|
110
110
|
}
|
|
111
|
-
`,Le=
|
|
111
|
+
`,Le=h(m)`
|
|
112
112
|
gap: ${({theme:e})=>e.space(4)};
|
|
113
113
|
min-width: 0;
|
|
114
|
-
`,Re=
|
|
114
|
+
`,Re=h.button`
|
|
115
115
|
display: flex;
|
|
116
116
|
flex-direction: column;
|
|
117
117
|
gap: 4px;
|
|
@@ -132,17 +132,17 @@ import{$t as e,B as t,C as n,Ft as r,H as i,I as a,N as o,P as s,Pt as c,R as l,
|
|
|
132
132
|
&:last-child {
|
|
133
133
|
border-bottom: 0;
|
|
134
134
|
}
|
|
135
|
-
`,ze=
|
|
135
|
+
`,ze=h(f)`
|
|
136
136
|
font-family: ${({theme:e})=>e.font.mono};
|
|
137
137
|
font-size: 12.5px;
|
|
138
138
|
display: block;
|
|
139
139
|
max-width: 100%;
|
|
140
|
-
`,Be=
|
|
140
|
+
`,Be=h.div`
|
|
141
141
|
display: flex;
|
|
142
142
|
gap: 2px;
|
|
143
|
-
`,Ve=
|
|
143
|
+
`,Ve=h.span`
|
|
144
144
|
width: 12px;
|
|
145
145
|
height: 3px;
|
|
146
146
|
border-radius: 1px;
|
|
147
147
|
background: ${({$provider:e})=>`var(--p-${e})`};
|
|
148
|
-
`,$=`\0new`;function He(){let e=
|
|
148
|
+
`,$=`\0new`;function He(){let e=t(),[n,i]=(0,I.useState)(null),a=e.data??[],c=n===$?null:a.find(e=>e.id===n)??null,d=n===$||n===null&&!e.isLoading&&a.length===0;(0,I.useEffect)(()=>{n===null&&a.length!==0&&i(a[0]?.id??null)},[a,n]);let f=e.isLoading?`Reading configured models…`:a.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${a.length} model${a.length===1?``:`s`} routing to ${a.reduce((e,t)=>e+t.targets.length,0)} targets.`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(b,{legend:`Models`,title:`Virtual models`,summary:f,actions:(0,L.jsxs)(l,{type:`button`,$variant:`primary`,onClick:()=>i($),children:[(0,L.jsx)(x,{}),`New model`]})}),(0,L.jsxs)(Ie,{children:[(0,L.jsx)(A,{legend:`Configured`,meta:`${a.length}`,flush:!0,children:e.isError?(0,L.jsx)(ne,{error:e.error,onRetry:()=>void e.refetch()}):e.isLoading?(0,L.jsx)(`div`,{style:{padding:12},children:(0,L.jsx)(M,{rows:4})}):a.length===0?(0,L.jsx)(N,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:(0,L.jsx)(l,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>i($),children:`New model`})}):(0,L.jsx)(`div`,{children:a.map(e=>{let t=[...new Set(e.targets.map(e=>e.provider))];return(0,L.jsxs)(Re,{type:`button`,$selected:e.id===n,"aria-pressed":e.id===n,onClick:()=>i(e.id),children:[(0,L.jsxs)(r,{$gap:2,style:{width:`100%`},children:[(0,L.jsx)(ze,{title:e.id,children:e.id}),(0,L.jsx)(u,{}),e.isAlias?(0,L.jsx)(T,{children:`alias`}):null]}),(0,L.jsxs)(r,{$gap:2,style:{width:`100%`},children:[(0,L.jsx)(Be,{children:t.map(e=>(0,L.jsx)(Ve,{$provider:e,title:e},e))}),(0,L.jsx)(s,{children:e.strategy}),(0,L.jsx)(u,{}),(0,L.jsxs)(o,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),(0,L.jsxs)(Le,{children:[c===null&&!d?(0,L.jsx)(A,{legend:`Editor`,children:e.isLoading?(0,L.jsx)(M,{rows:5}):(0,L.jsx)(N,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):(0,L.jsx)(Fe,{model:c,onSaved:t=>{i(t),e.refetch()},onDeleted:()=>{i(null),e.refetch()}}),(0,L.jsx)(ve,{modelId:c?.id??null})]})]})]})}var Ue=He;export{Ue as component};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import{$t as e,I as t,O as n,Q as r,Qt as i,R as a,X as o,Y as s,_n as c,at as l,c as u,et as d,o as f,tt as p,ut as m}from"./queries-BJHk_wso.js";import{t as h}from"./Rack-D1zBw9SW.js";import{t as g}from"./Toggle-DWrWc9-9.js";import{i as _,n as v,t as y}from"./Field-B7GOsJf8.js";import{t as b}from"./Meter-Dngwbpjo.js";import{a as x,i as S,n as C,r as w}from"./States-CQFkw1UZ.js";var T=c(e(),1),E=i(),D=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],O=m(o)`
|
|
2
|
+
display: block;
|
|
3
|
+
white-space: pre;
|
|
4
|
+
overflow-x: auto;
|
|
5
|
+
padding: 0.75rem;
|
|
6
|
+
background: ${({theme:e})=>e.color.panelSunk};
|
|
7
|
+
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
font-size: 0.8125rem;
|
|
10
|
+
line-height: 1.5;
|
|
11
|
+
`,k=m.div`
|
|
12
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
13
|
+
font-size: 0.8125rem;
|
|
14
|
+
margin-bottom: 0.25rem;
|
|
15
|
+
`,A=m.p`
|
|
16
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
17
|
+
font-size: 0.8125rem;
|
|
18
|
+
margin: 0;
|
|
19
|
+
`,j=m.div`
|
|
20
|
+
display: grid;
|
|
21
|
+
grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
|
|
22
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
23
|
+
`,M=[{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 N(){let[e,t]=(0,T.useState)(`claude`),[i,a]=(0,T.useState)(()=>({claude:{},opencode:{}})),s=n(),c=i[e],u=typeof c.defaultModel==`string`&&c.defaultModel!==``?c:void 0,d=f(e,u),m=D.find(t=>t.id===e);return(0,E.jsx)(x,{legend:`Agent setup`,children:(0,E.jsxs)(p,{children:[(0,E.jsx)(r,{children:D.map(n=>(0,E.jsx)(l,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),(0,E.jsxs)(A,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,(0,E.jsxs)(o,{children:[`omni setup `,e]}),` to write these files directly.`]}),(s.data?.length??0)>0?(0,E.jsx)(j,{children:M.map(t=>(0,E.jsx)(y,{label:t.label,children:n=>(0,E.jsxs)(_,{...n,value:c[t.key]??``,onChange:n=>a(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[(0,E.jsx)(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),s.data?.map(e=>(0,E.jsx)(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,s.isLoading?(0,E.jsx)(w,{rows:2}):d.isError?(0,E.jsx)(C,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?(0,E.jsx)(w,{rows:4}):(s.data?.length??0)===0?(0,E.jsx)(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?(0,E.jsxs)(A,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?(0,E.jsx)(A,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>(0,E.jsxs)(`div`,{children:[(0,E.jsx)(k,{children:e.path}),(0,E.jsx)(O,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?(0,E.jsx)(A,{children:S(d.error)}):null]})})}var P=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Preference for accounts with fewer requests in flight right now.`}],F=[{id:`maxAttempts`,label:`Attempts per request`,hint:`How many candidates dispatch may try before giving up. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`How long a request may take across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures on one account and model before it is taken out of rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Base wait before a tripped account is probed again. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before maintenance prunes them.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often each account's provider is asked for its remaining quota. 0 disables polling. Takes effect on restart.`,unit:`ms`,step:6e4,min:0}],I=m.div`
|
|
24
|
+
display: grid;
|
|
25
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
26
|
+
gap: ${({theme:e})=>e.space(3)};
|
|
27
|
+
`,L=m(p)`
|
|
28
|
+
gap: 6px;
|
|
29
|
+
`,R=m.p`
|
|
30
|
+
font-size: 11px;
|
|
31
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
32
|
+
`,z=m.p`
|
|
33
|
+
font-size: 12px;
|
|
34
|
+
color: ${({theme:e})=>e.color.down};
|
|
35
|
+
`,B=m.p`
|
|
36
|
+
font-size: 12px;
|
|
37
|
+
color: ${({theme:e})=>e.color.ok};
|
|
38
|
+
`,V=m.p`
|
|
39
|
+
font-size: 12px;
|
|
40
|
+
color: ${({theme:e})=>e.color.warn};
|
|
41
|
+
max-width: 72ch;
|
|
42
|
+
|
|
43
|
+
code {
|
|
44
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
45
|
+
}
|
|
46
|
+
`;function H(e){let t={};for(let n of P)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of F)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function U(e){let t={};for(let n of P){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 F){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`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function W(){let e=a(),n=u(),i=t(),[c,f]=(0,T.useState)({}),[m,_]=(0,T.useState)(null),[D,O]=(0,T.useState)(!1);(0,T.useEffect)(()=>{e.data!==void 0&&f(H(e.data))},[e.data]);let k=Math.max(1e-4,...P.map(e=>Math.abs(Number(c[`w.${e.id}`])||0)));return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(h,{legend:`Settings`,title:`Routing and retention`,summary:`These apply to every request the gateway routes. Changes take effect on the next request; nothing is restarted.`,actions:(0,E.jsx)(l,{type:`button`,$variant:`primary`,disabled:i.isPending||e.isLoading,onClick:()=>{O(!1);let e=U(c);if(!e.ok){_(e.problem);return}_(null),i.mutate(e.settings,{onSuccess:()=>O(!0),onError:e=>_(S(e))})},children:i.isPending?`Saving…`:`Save changes`})}),e.isError?(0,E.jsx)(x,{legend:`Settings`,children:(0,E.jsx)(C,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?(0,E.jsx)(x,{legend:`Settings`,children:(0,E.jsx)(w,{rows:6})}):(0,E.jsxs)(p,{$gap:4,children:[(0,E.jsx)(x,{legend:`Scoring weights`,meta:`relative to each other`,footer:(0,E.jsxs)(r,{children:[(0,E.jsx)(s,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),(0,E.jsx)(d,{})]}),children:(0,E.jsx)(I,{children:P.map(e=>{let t=Number(c[`w.${e.id}`])||0;return(0,E.jsxs)(L,{children:[(0,E.jsx)(y,{label:e.label,children:t=>(0,E.jsx)(v,{...t,type:`number`,step:.5,value:c[`w.${e.id}`]??``,onChange:t=>f({...c,[`w.${e.id}`]:t.target.value})})}),(0,E.jsx)(b,{fraction:Math.abs(t)/k,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),(0,E.jsx)(R,{children:e.blurb})]},e.id)})})}),(0,E.jsx)(x,{legend:`Limits`,children:(0,E.jsx)(I,{children:F.map(e=>(0,E.jsx)(L,{children:(0,E.jsx)(y,{label:e.label,hint:e.hint,children:t=>(0,E.jsxs)(r,{$gap:2,children:[(0,E.jsx)(v,{...t,type:`number`,min:e.min,step:e.step,value:c[e.id]??``,onChange:t=>f({...c,[e.id]:t.target.value})}),(0,E.jsx)(s,{children:e.unit})]})})},e.id))})}),(0,E.jsx)(x,{legend:`Historical tool results`,children:(0,E.jsxs)(r,{$gap:3,$align:`start`,children:[(0,E.jsx)(g,{checked:c.rtkEnabled===`true`,onCheckedChange:e=>f({...c,rtkEnabled:String(e)}),label:`Enable RTK compression`}),(0,E.jsx)(R,{children:`Compress recognized historical non-error tool results before provider dispatch. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a built-in detector recognizes a high-confidence shell-output format. Compression is deterministic and lossy. Disabled by default.`})]})}),(0,E.jsx)(x,{legend:`Request and response bodies`,meta:n.data===!0?`permitted by the environment`:`not permitted`,children:(0,E.jsxs)(p,{$gap:3,children:[n.data===!0?null:(0,E.jsxs)(V,{children:[`This gateway was started without `,(0,E.jsx)(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,(0,E.jsx)(`code`,{children:`.env`}),` `,`and restart before turning capture on. Two keys mean an admin session on its own cannot start recording prompts.`]}),(0,E.jsxs)(r,{$gap:3,$align:`start`,children:[(0,E.jsx)(g,{checked:c.bodyLoggingEnabled===`true`,disabled:n.data!==!0,onCheckedChange:e=>f({...c,bodyLoggingEnabled:String(e)}),label:`Capture request and response bodies`}),(0,E.jsx)(R,{children:`Stores what each client sent and what each provider returned, encrypted under OMNI_ENCRYPTION_KEY beside the database. Bearer tokens and API keys are masked first and headers are never captured. Bodies expire on the log retention window above, and the newest 100,000 requests are kept whatever that window says. Off by default.`})]}),(0,E.jsxs)(r,{$gap:3,$align:`start`,children:[(0,E.jsx)(g,{checked:c.bodyLoggingCaptureStreamChunks===`true`,disabled:n.data!==!0||c.bodyLoggingEnabled!==`true`,onCheckedChange:e=>f({...c,bodyLoggingCaptureStreamChunks:String(e)}),label:`Also keep raw stream frames`}),(0,E.jsx)(R,{children:`Retains the raw SSE frames of each attempt as well as the reassembled response. The only way to debug stream framing itself, and by far the most expensive thing capture can store, so it is gated separately rather than implied.`})]})]})}),m===null?null:(0,E.jsx)(z,{role:`alert`,children:m}),D&&m===null?(0,E.jsx)(B,{role:`status`,children:`Settings saved.`}):null,(0,E.jsx)(N,{}),(0,E.jsx)(x,{legend:`Known limits`,children:(0,E.jsxs)(p,{$gap:2,children:[(0,E.jsxs)(r,{$gap:2,children:[(0,E.jsx)(o,{$dim:!0,children:`rate limits`}),(0,E.jsx)(R,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),(0,E.jsxs)(r,{$gap:2,children:[(0,E.jsx)(o,{$dim:!0,children:`logs`}),(0,E.jsx)(R,{children:`Request rows record routing and token counts only. Prompts and responses are written only when body capture above is on, and to a separate encrypted store; credentials are never written to either.`})]})]})})]})]})}var G=W;export{G as component};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import{$ as e,$t as t,C as n,J as r,O as i,Q as a,Qt as o,W as s,X as c,Y as l,_n as u,g as d,nt as f,tt as p,ut as m}from"./queries-BJHk_wso.js";import{i as h,n as g,r as _}from"./index-ClU3Xqui.js";import{a as v,r as y,t as b}from"./Rack-D1zBw9SW.js";import{E as x,O as S,S as C,T as w}from"./Lamp-QRSv-SqM.js";import{a as T,n as E,r as D,t as O}from"./States-CQFkw1UZ.js";import{i as ee,n as k,r as A,t as te}from"./Table-Ba58Wg4-.js";import{t as ne}from"./catalog-BBKm8Ih8.js";import{$ as re,A as j,At as ie,B as ae,C as oe,Ct as M,D as N,Dt as P,E as se,Et as ce,F as le,G as ue,H as de,I as fe,J as F,K as I,L as pe,M as me,Mt as L,N as he,O as ge,Ot as _e,P as ve,Q as ye,R as be,S as xe,St as Se,T as Ce,Tt as we,U as Te,V as Ee,W as De,X as Oe,Y as ke,Z as Ae,_ as je,_t as Me,a as Ne,at as Pe,b as R,bt as z,c as Fe,ct as Ie,d as B,dt as Le,et as Re,f as V,ft as ze,g as Be,gt as Ve,h as He,ht as Ue,i as We,it as Ge,j as Ke,jt as qe,k as Je,kt as Ye,l as Xe,lt as Ze,m as Qe,mt as $e,n as et,nt as tt,o as nt,ot as rt,p as it,pt as at,q as ot,r as st,rt as ct,s as H,st as lt,t as ut,tt as dt,u as ft,ut as pt,v as mt,vt as ht,w as gt,wt as _t,x as U,xt as vt,y as W,yt,z as bt}from"./shared-Bp35cgFf.js";import{t as G}from"./Readout--CQnPjoO.js";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)=>ye(e,`xAxis`,xt(e,t),n),wt=(e,t,n)=>Re(e,`xAxis`,xt(e,t),n),Tt=(e,t,n)=>ye(e,`yAxis`,St(e,t),n),Et=(e,t,n)=>Re(e,`yAxis`,St(e,t),n),Dt=z([Ie,Ct,Tt,wt,Et],(e,t,n,r,i)=>ht(e,`xAxis`)?at(t,r,!1):at(n,i,!1)),Ot=z([dt,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),kt=e=>{var t=Ie(e);return ht(t,`xAxis`)?`yAxis`:`xAxis`},At=(e,t)=>kt(e)===`yAxis`?St(e,t):xt(e,t),jt=(e,t,n)=>re(e,kt(e),At(e,t),n),Mt=z([Ot,jt],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=tt(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=z([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(we)}}),Pt=z([Ie,Ct,Tt,wt,Et,Mt,Pe,Dt,Ot,Ge,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 fn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),K=u(t()),Ft=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],It=[`id`,`baseLine`];function q(){return q=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},q.apply(null,arguments)}function Lt(e,t){if(e==null)return{};var n,r,i=Rt(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 Rt(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 zt(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(!yt(a)||!yt(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return P(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),P(c)?K.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function Bt(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(!yt(a)||!yt(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return P(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),P(c)?K.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function Vt(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?K.createElement(Bt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):K.createElement(zt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Ht(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=Lt(e,Ft),f=s===`vertical`?`vertical`:`horizontal`,p=u??!1,m=fe(),h=d.id,g=d.baseLine,_=Lt(d,It),v=qe(_),y=K.createElement(rt,q({},d,{id:h,baseLine:g,connectNulls:p,stroke:`none`,className:`recharts-area-area`,layout:f})),b=l!==`none`&&K.createElement(rt,q({},v,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:d.points})),x=l!==`none`&&c&&Array.isArray(g)&&K.createElement(rt,q({},v,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:p,fill:`none`,stroke:l,points:g}));return o&&(i||n<1)?K.createElement(Ye,null,K.createElement(`defs`,null,K.createElement(`clipPath`,{id:m},K.createElement(Vt,{alpha:n,points:d.points??[],baseLine:g,layout:f,strokeWidth:d.strokeWidth}))),K.createElement(Ye,{clipPath:`url(#${m})`},y,b,x)):K.createElement(K.Fragment,null,y,b,x)}var Ut=[`id`],Wt=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Gt(){return Gt=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},Gt.apply(null,arguments)}function Kt(e,t){if(e==null)return{};var n,r,i=qt(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 qt(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 Jt(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Jt(Object(n),!0).forEach(function(t){Yt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yt(e,t,n){return(t=Xt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xt(e){var t=Zt(e,`string`);return typeof t==`symbol`?t:t+``}function Zt(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 Qt={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`?[J(J({},e.next),{},{x:M(e.prev.x,e.next.x,t),y:M(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:Ht,xAxisId:0,yAxisId:0,zIndex:ct.area};function $t(e,t){return e&&e!==`none`?e:t}var en=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:$t(r,i),value:Ve(n,t),payload:e}]},tn=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:_e,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Ve(o,t),hide:s,type:u,color:$t(r,a),unit:c,formatter:l,graphicalItemId:d}};return K.createElement(Te,{tooltipEntrySettings:f})});function nn(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=qe(r);return K.createElement(he,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function rn(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 J(J({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return K.createElement(I,{value:t?r:void 0},n)}function an(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=Kt(a,Ut),_=J(J({},ie(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return K.createElement(K.Fragment,null,t?.length>1&&K.createElement(Ye,{clipPath:r?`url(#clipPath-${i})`:void 0},K.createElement(De,{option:m,DefaultShape:Qt.shape,shapeProps:_})),K.createElement(nn,{points:t,props:g,clipPathId:i}))}function on(e,t,n){if(P(e)){var r=P(t)?t:void 0;return M(r,e,n)}if(ce(e)||_t(e)){var i=P(t)?t:void 0;return M(i,0,n)}return e}function sn(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,K.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=bt(m,a),g=Ze(),_=be(r.onAnimationStart,r.onAnimationEnd),v=_.isAnimating,y=_.handleAnimationStart,b=_.handleAnimationEnd,x=h.startValue;if(g==null)return null;var S=Array.isArray(s)&&Array.isArray(x)?ae(x,s,f):Array.isArray(s)?ae(null,s,f):null;return K.createElement(pe,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:y,onAnimationEnd:b,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(S,i,g):a?s:on(s,x,i);return h.syncStepValue(c,i),K.createElement(rn,{showLabels:!v,points:o},r.children,K.createElement(an,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:v||i<1,isEntrance:a}),K.createElement(ot,{label:r.label}))})}function cn(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,K.useRef)(null),a=(0,K.useRef)();return K.createElement(sn,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var ln=class extends K.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=L(`recharts-area`,i),g=f,_=N(n),v=_.r,y=_.strokeWidth,b=ue(n),x=v*2+y,S=s?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return K.createElement(Oe,{zIndex:m},K.createElement(Ye,{className:h},s&&K.createElement(`defs`,null,K.createElement(ge,{clipPathId:g,xAxisId:c,yAxisId:l}),!b&&K.createElement(`clipPath`,{id:`clipPath-dots-${g}`},K.createElement(`rect`,{x:o-x/2,y:a-x/2,width:u+x,height:d+x}))),K.createElement(cn,{needClip:s,clipPathId:g,props:this.props})),K.createElement(Ke,{points:r,mainColor:$t(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}),this.props.isRange&&Array.isArray(p)&&K.createElement(Ke,{points:p,mainColor:$t(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:S}))}};function un(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=Kt(e,Wt),g=pt(),_=Ae(),v=Je(p,m).needClip,y=ze(),b=vt(t=>Pt(t,e.id,y))??{},x=b.points,S=b.isRange,C=b.baseLine,w=me();if(g!==`horizontal`&&g!==`vertical`||w==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var T=w.height,E=w.width,D=w.x,O=w.y;return!x||!x.length?null:K.createElement(ln,Gt({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:C,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:T,hide:l,layout:g,isAnimationActive:u,isRange:S,legendType:d,needClip:v,points:x,stroke:f,width:E,left:D,top:O,xAxisId:p,yAxisId:m}))}var dn=(e,t,n,r,i)=>{var a=n??t;if(P(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function fn(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,_=dn(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=Me(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=Me(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>Me(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:$e({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:$e({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 pn(e){var t=Se(e,Qt),n=ze();return K.createElement(le,{id:t.id,type:`area`},e=>K.createElement(K.Fragment,null,K.createElement(de,{legendPayload:en(t)}),K.createElement(tn,{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(ve,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:Ue(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),K.createElement(un,Gt({},t,{id:e}))))}var Y=K.memo(pn,lt);Y.displayName=`Area`;var mn=[`axis`],hn=(0,K.forwardRef)((e,t)=>K.createElement(oe,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:mn,tooltipPayloadSearcher:ke,categoricalChartProps:e,ref:t})),gn=[`axis`],_n=(0,K.forwardRef)((e,t)=>K.createElement(oe,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:gn,tooltipPayloadSearcher:ke,categoricalChartProps:e,ref:t})),X=o(),vn=53,Z=9,Q=2,yn=m.div`
|
|
2
|
+
display: flex;
|
|
3
|
+
gap: ${Q}px;
|
|
4
|
+
`,bn=m.div`
|
|
5
|
+
display: grid;
|
|
6
|
+
grid-template-rows: repeat(7, ${Z}px);
|
|
7
|
+
gap: ${Q}px;
|
|
8
|
+
padding-top: ${11}px;
|
|
9
|
+
font-size: 9px;
|
|
10
|
+
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
|
+
`,xn=m.div`
|
|
12
|
+
line-height: ${Z}px;
|
|
13
|
+
padding-right: 2px;
|
|
14
|
+
text-align: right;
|
|
15
|
+
`,Sn=m.div`
|
|
16
|
+
display: grid;
|
|
17
|
+
grid-template-columns: repeat(${vn}, ${Z}px);
|
|
18
|
+
gap: ${Q}px;
|
|
19
|
+
height: ${Z}px;
|
|
20
|
+
font-size: 9px;
|
|
21
|
+
color: ${({theme:e})=>e.color.inkFaint};
|
|
22
|
+
`,Cn=m.div`
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
line-height: ${Z}px;
|
|
25
|
+
`,wn=m.div`
|
|
26
|
+
display: grid;
|
|
27
|
+
grid-template-columns: repeat(${vn}, ${Z}px);
|
|
28
|
+
gap: ${Q}px;
|
|
29
|
+
`,Tn=m.div`
|
|
30
|
+
display: grid;
|
|
31
|
+
grid-template-rows: repeat(7, ${Z}px);
|
|
32
|
+
gap: ${Q}px;
|
|
33
|
+
`,En=m.div`
|
|
34
|
+
width: ${Z}px;
|
|
35
|
+
height: ${Z}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
|
+
`,Dn=m(a)`
|
|
47
|
+
gap: ${Q}px;
|
|
48
|
+
`,On=m(c)`
|
|
49
|
+
color: ${({theme:e})=>e.color.inkDim};
|
|
50
|
+
font-size: 11px;
|
|
51
|
+
`;function kn(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 An(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function jn({days:t,now:n}){let[r,i]=(0,K.useState)(`tokens`),[o,s]=(0,K.useState)(null),c=Be(r),u=(0,K.useMemo)(()=>{let e=new Map;for(let n of t){let t=Number(n.key);Number.isFinite(t)&&e.set(W(t),{requests:n.requests,errors:n.errors,costUsd:n.costUsd,inputTokens:n.inputTokens,outputTokens:n.outputTokens,cacheReadTokens:n.cacheReadTokens,cacheWriteTokens:n.cacheWriteTokens,rtkSavedTokens:n.rtkSavedTokens,rtkAppliedRequests:n.rtkAppliedRequests,durationMsSum:n.durationMsSum})}let r=new Date(W(n));r.setDate(r.getDate()+(6-r.getDay())-370);let i=W(n);return Array.from({length:vn},()=>Array.from({length:7},()=>{let t=r.getTime();return r.setDate(r.getDate()+1),{at:t,totals:e.get(t)??Xe,future:t>i}}))},[t,n]),d=u.flat(),f=kn(d.map(e=>c.of({key:``,...e.totals}))),m=d.reduce((e,t)=>ft(e,V(t.totals)),Xe),h=d.reduce((e,t)=>e+ +(t.totals.requests>0),0),g=(e,t)=>`${e}: ${C(t.requests)} requests, ${C(B(t))} tokens, ${S(t.costUsd)}`;return(0,X.jsx)(T,{legend:`Activity`,meta:o===null?`${C(h)} active days`:void 0,actions:(0,X.jsx)(et,{children:We.map(e=>(0,X.jsx)(nt,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:e.label},e.id))}),children:(0,X.jsxs)(p,{$gap:2,children:[(0,X.jsx)(e,{children:(0,X.jsx)(p,{$gap:1,style:{width:611},children:(0,X.jsxs)(yn,{children:[(0,X.jsx)(bn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>(0,X.jsx)(xn,{children:e},t))}),(0,X.jsxs)(p,{$gap:1,children:[(0,X.jsx)(Sn,{"aria-hidden":`true`,children:u.map((e,t)=>{let n=e[0],r=u[t-1]?.[0],i=n!==void 0&&(r===void 0||new Date(r.at).getMonth()!==new Date(n.at).getMonth());return(0,X.jsx)(Cn,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),(0,X.jsx)(wn,{role:`grid`,"aria-label":`${c.label} per day over the last year`,children:u.map(e=>(0,X.jsx)(Tn,{role:`row`,children:e.map(e=>(0,X.jsx)(En,{role:`gridcell`,tabIndex:-1,"aria-label":g(Qe(e.at),e.totals),title:g(Qe(e.at),e.totals),$future:e.future,$level:e.future?0:An(c.of({key:``,...e.totals}),f),onMouseEnter:()=>s(e),onMouseLeave:()=>s(null)},e.at))},e[0]?.at))})]})]})})}),(0,X.jsxs)(a,{$justify:`space-between`,$wrap:!0,children:[(0,X.jsx)(On,{children:o===null?g(`Last 12 months`,m):g(Qe(o.at),o.totals)}),(0,X.jsxs)(a,{$gap:1,children:[(0,X.jsx)(l,{children:`Less`}),(0,X.jsx)(Dn,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>(0,X.jsx)(En,{$level:e,$future:!1},e))}),(0,X.jsx)(l,{children:`More`})]})]})]})})}function Mn({buckets:t,by:n,since:r,until:i,metric:a,names:o}){let s=U(r,i,n),c=new Map,l=new Map;for(let e of t){let t=e.split??`unknown`;c.set(t,ft(c.get(t)??Xe,e));let r=l.get(t)??new Map,i=He(e.key,n);r.set(i,(r.get(i)??0)+a.of(e)),l.set(t,r)}let u=[...c.entries()].sort((e,t)=>a.of(V(t[1]))-a.of(V(e[1])));return(0,X.jsx)(e,{children:(0,X.jsxs)(te,{children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(A,{children:`Key`}),(0,X.jsx)(A,{children:`Trend`}),(0,X.jsx)(A,{$align:`right`,children:`Requests`}),(0,X.jsx)(A,{$align:`right`,children:`Failed`}),(0,X.jsx)(A,{$align:`right`,children:`Tokens`}),(0,X.jsx)(A,{$align:`right`,children:`Mean`}),(0,X.jsx)(A,{$align:`right`,children:`Cost`})]})}),(0,X.jsx)(`tbody`,{children:u.map(([e,t])=>{let n=l.get(e)??new Map,r=e===`unknown`?`Unattributed`:o.get(e)??e;return(0,X.jsxs)(ee,{children:[(0,X.jsx)(k,{children:(0,X.jsx)(f,{style:{display:`block`,maxWidth:`28ch`},children:r})}),(0,X.jsx)(k,{style:{width:120},children:(0,X.jsx)(y,{values:s.map(e=>n.get(e)??0),height:20,label:`${r}: ${a.format(a.of(V(t)))} over the window`})}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(t.requests)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:x(t.requests===0?0:t.errors/t.requests,0)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(B(t))}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:w(t.requests===0?null:t.durationMsSum/t.requests)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:S(t.costUsd)})]},e)})})]})})}var Nn=6,Pn=`__other__`,Fn=`unknown`;function In(e,t){let n=t.get(e);return n===void 0?g.find(t=>ne[t].models.some(t=>t.id===e))??null:n}function Ln(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${h(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Rn({buckets:e,by:t,since:n,until:r,metric:i,providers:a}){let o=[...it(e,i).entries()],s=o.slice(0,Nn),c=o.slice(Nn),l=[];for(let e of[...g,null])s.filter(([t])=>In(t,a)===e).forEach(([t,n],r)=>{l.push({name:t,label:t===Fn?`Unresolved`:t,color:Ln(e,r),totals:n})});c.length>0&&l.push({name:Pn,label:`${c.length} more`,color:`var(--ink-faint)`,totals:c.reduce((e,[,t])=>ft(e,V(t)),Xe)});let u=new Set(s.map(([e])=>e)),d=new Map;for(let n of e){let e=n.split??Fn,r=`${He(n.key,t)} ${u.has(e)?e:Pn}`;d.set(r,(d.get(r)??0)+i.of(n))}let m=U(n,r,t).map(e=>{let t={at:e};for(let n of l)t[n.name]=d.get(`${e} ${n.name}`)??0;return t}),h=new Map(l.map(e=>[e.name,e.label]));return(0,X.jsxs)(p,{$gap:2,children:[(0,X.jsx)(ut,{$height:220,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(hn,{data:m,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(gt,{tickFormatter:e=>i.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),(0,X.jsx)(F,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>{if(e!==!0||n===void 0||n.length===0)return null;let a=n.filter(e=>Number(e.value??0)>0);return(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:R(Number(r),t)}),a.length===0?(0,X.jsx)(`div`,{children:`No ${i.label.toLowerCase()}`}):a.map(e=>(0,X.jsxs)(`div`,{children:[h.get(String(e.dataKey))??String(e.dataKey),` `,i.format(Number(e.value??0))]},String(e.dataKey)))]})}}),l.map(e=>(0,X.jsx)(Y,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),(0,X.jsx)(st,{children:l.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(H,{$color:e.color}),` `,(0,X.jsx)(f,{title:`${e.label}: ${i.format(i.of(V(e.totals)))} ${i.label.toLowerCase()}`,style:{display:`inline-block`,maxWidth:`24ch`,verticalAlign:`bottom`},children:e.label})]},e.name))})]})}var zn=`unknown`;function Bn(e){let t=g.find(t=>t===e);return t===void 0?`var(--ink-faint)`:h(t)}function Vn(e){let t=g.find(t=>t===e);return t===void 0?`Unresolved`:_[t]}function Hn({buckets:e,by:t,since:n,until:r,metric:i}){let a=it(e,i),o=[...g,zn].map(e=>({name:e,totals:a.get(e)})).filter(e=>e.totals!==void 0),s=o.map(e=>e.name),c=U(n,r,t),l=mt(e,c,t,i),u=[...a.values()].reduce((e,t)=>e+t.requests,0);return(0,X.jsxs)(p,{$gap:3,children:[(0,X.jsx)(ut,{$height:200,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(hn,{data:l,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(gt,{tickFormatter:e=>i.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),(0,X.jsx)(F,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:R(Number(r),t)}),n.map(e=>(0,X.jsxs)(`div`,{children:[Vn(String(e.dataKey)),` `,i.format(Number(e.value??0))]},String(e.dataKey)))]})}),s.map(e=>(0,X.jsx)(Y,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:Bn(e),strokeWidth:2,fill:Bn(e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),(0,X.jsx)(st,{children:s.map(e=>(0,X.jsxs)(`span`,{children:[(0,X.jsx)(H,{$color:Bn(e)}),` `,Vn(e)]},e))}),(0,X.jsxs)(te,{children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(A,{children:`Provider`}),(0,X.jsx)(A,{$align:`right`,children:`Share`}),(0,X.jsx)(A,{$align:`right`,children:`Requests`}),(0,X.jsx)(A,{$align:`right`,children:`Failed`}),(0,X.jsx)(A,{$align:`right`,children:`Tokens`}),(0,X.jsx)(A,{$align:`right`,children:`Cost`})]})}),(0,X.jsx)(`tbody`,{children:o.map(({name:e,totals:t})=>(0,X.jsxs)(ee,{children:[(0,X.jsxs)(k,{children:[(0,X.jsx)(H,{$color:Bn(e)}),` `,Vn(e)]}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:x(u===0?0:t.requests/u,0)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(t.requests)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:C(t.errors)}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:C(B(t))}),(0,X.jsx)(k,{$align:`right`,$mono:!0,children:S(t.costUsd)})]},e))})]})]})}var Un=m.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
|
+
`,Wn=m.ol`
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
gap: ${({theme:e})=>e.space(2)};
|
|
60
|
+
`,Gn=m.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
|
+
`,Kn=m.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
|
+
`,qn=m(f)`
|
|
73
|
+
display: block;
|
|
74
|
+
font-family: ${({theme:e})=>e.font.mono};
|
|
75
|
+
font-size: 12px;
|
|
76
|
+
`,Jn=12;function Yn({buckets:e,metric:t,names:n,unknownLabel:r}){let i=new Map;for(let t of e)i.set(t.key,ft(i.get(t.key)??Xe,t));let o=e=>e===`unknown`?r??`Unattributed`:n?.get(e)??e,s=[...i.entries()].map(([e,n])=>({name:o(e),entry:n,value:t.of(V(n))})).sort((e,t)=>t.value-e.value),l=s.slice(0,Jn),u=s.slice(Jn),d=l[0]?.value??0;return(0,X.jsxs)(p,{$gap:3,children:[(0,X.jsx)(Wn,{children:l.map(({name:e,entry:n,value:r})=>(0,X.jsxs)(Un,{children:[(0,X.jsx)(qn,{title:e,children:e}),(0,X.jsx)(Gn,{children:(0,X.jsx)(Kn,{$share:d===0?0:r/d,$fault:n.requests>0&&n.errors===n.requests})}),(0,X.jsxs)(a,{$gap:2,children:[(0,X.jsx)(c,{$size:`12px`,children:t.format(r)}),(0,X.jsx)(c,{$size:`11px`,$dim:!0,children:S(n.costUsd)})]})]},e))}),u.length===0?null:(0,X.jsx)(c,{$size:`11px`,$dim:!0,children:`+ ${u.length} more, ${C(u.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}function $({legend:e,meta:t,actions:n,query:r,empty:i,isEmpty:a,children:o}){return(0,X.jsx)(T,{legend:e,meta:t,actions:n,children:r.isError?(0,X.jsx)(E,{error:r.error,onRetry:r.refetch}):r.isLoading?(0,X.jsx)(D,{rows:4}):a?(0,X.jsx)(O,{legend:i.legend,message:i.message}):o})}var Xn=[{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 Zn({buckets:e,by:t,since:n,until:r}){let i=new Map;for(let n of e)i.set(He(n.key,t),n);let o=U(n,r,t).map(e=>{let t=i.get(e);return{at:e,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,cacheReadTokens:t?.cacheReadTokens??0,cacheWriteTokens:t?.cacheWriteTokens??0}}),s=Xn.map(e=>({...e,value:o.reduce((t,n)=>t+n[e.id],0)})),l=s.reduce((e,t)=>e+t.value,0);return(0,X.jsxs)(p,{$gap:3,children:[(0,X.jsx)(ut,{$height:200,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(hn,{data:o,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`at`,tickFormatter:e=>R(e,t),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(gt,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>C(e)}),(0,X.jsx)(F,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:n,label:r})=>e!==!0||n===void 0||n.length===0?null:(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:R(Number(r),t)}),Xn.map(e=>(0,X.jsxs)(`div`,{children:[e.label,` `,C(Number(n.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),Xn.map(e=>(0,X.jsx)(Y,{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))]})})}),(0,X.jsx)(st,{children:s.map(e=>(0,X.jsxs)(a,{$gap:1,children:[(0,X.jsx)(H,{$color:`var(--accent)`,style:{opacity:e.opacity}}),(0,X.jsx)(`span`,{children:e.label}),(0,X.jsx)(c,{$size:`11px`,children:C(e.value)}),(0,X.jsx)(c,{$size:`11px`,$dim:!0,children:x(l===0?0:e.value/l,0)})]},e.id))})]})}function Qn({buckets:e,by:t,since:n,until:r}){let i=new Map;for(let n of e)i.set(He(n.key,t),n);let a=U(n,r,t).map(e=>{let n=i.get(e);return{at:e,label:R(e,t),requests:n?.requests??0,errors:n?.errors??0,costUsd:n?.costUsd??0,tokens:n===void 0?0:B(n)}});return(0,X.jsxs)(p,{$gap:2,children:[(0,X.jsx)(ut,{$height:220,children:(0,X.jsx)(Le,{width:`100%`,height:`100%`,children:(0,X.jsxs)(_n,{data:a,margin:{top:4,right:4,bottom:4,left:4},children:[(0,X.jsx)(j,{stroke:`var(--rule)`,vertical:!1}),(0,X.jsx)(Ce,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),(0,X.jsx)(gt,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),(0,X.jsx)(F,{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:(0,X.jsxs)(Fe,{children:[(0,X.jsx)(`div`,{children:n.label}),(0,X.jsxs)(`div`,{children:[C(n.requests),` requests`]}),(0,X.jsxs)(`div`,{children:[C(n.errors),` failed`]}),(0,X.jsxs)(`div`,{children:[C(n.tokens),` tokens`]}),(0,X.jsx)(`div`,{children:S(n.costUsd)})]})}}),(0,X.jsx)(Y,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),(0,X.jsx)(se,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),(0,X.jsx)(se,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),(0,X.jsxs)(st,{children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(H,{$color:`var(--accent)`}),` Requests`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(H,{$color:`var(--down)`}),` Failed`]})]})]})}var $n=m.div`
|
|
77
|
+
display: grid;
|
|
78
|
+
grid-template-columns: repeat(
|
|
79
|
+
auto-fit,
|
|
80
|
+
minmax(max(180px, calc((100% - 4 * ${({theme:e})=>e.space(3)}) / 5)), 1fr)
|
|
81
|
+
);
|
|
82
|
+
gap: ${({theme:e})=>e.space(3)};
|
|
83
|
+
`,er=864e5,tr=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function nr(){let{cadence:e}=v(),[t,a]=(0,K.useState)(`24h`),[o,c]=(0,K.useState)(`tokens`),[l,u]=(0,K.useState)(`model`),f=je(t),m=Be(o),h=(0,K.useMemo)(()=>f.grain===`daily`?W(Date.now()-f.ms):Math.floor((Date.now()-f.ms)/6e4)*6e4,[f]),g=(0,K.useMemo)(()=>h+f.ms,[h,f]),_=(0,K.useMemo)(()=>W(Date.now()-371*er),[]),T={since:h,grain:f.grain},E=s({...T,groupBy:f.by},e(6e4)),D=s({...T,groupBy:f.by,splitBy:`provider`},e(6e4)),O=s({...T,groupBy:f.by,splitBy:`model`},e(6e4)),ee=s({...T,groupBy:f.by,splitBy:`apiKey`},e(6e4)),k=s({...T,groupBy:l},e(6e4)),A=s({...T,groupBy:`credential`},e(6e4)),te=s({since:_,grain:`daily`,groupBy:`day`},e(3e5)),ne=n(),re=d(),j=i(),ie=(0,K.useMemo)(()=>{let e=new Map;for(let t of j.data??[])for(let n of t.targets)e.set(n.model,n.provider);return e},[j.data]),ae=(0,K.useMemo)(()=>{let e=new Map;for(let t of ne.data??[])e.set(t.id,t.label);return e},[ne.data]),oe=(0,K.useMemo)(()=>{let e=new Map;for(let t of re.data??[])e.set(t.id,t.label);return e},[re.data]),M=E.data??[],N=xe(M),P=N.inputTokens+N.cacheReadTokens+N.cacheWriteTokens,se=B(N),ce=N.requests===0?0:N.outputTokens/N.requests,le=P===0?0:N.cacheReadTokens/P,ue=P===0?0:N.cacheWriteTokens/P,de=N.requests===0?0:N.costUsd/N.requests,fe=U(h,g,f.by),F=new Map(M.map(e=>[He(e.key,f.by),e])),I=e=>fe.map(e),pe=e=>e>=.25?`down`:e>=.05?`warn`:`ok`,me=N.requests===0?0:N.errors/N.requests,L={legend:`Nothing recorded`,message:`No requests landed in this window. Widen the range, or send traffic through the gateway.`};return(0,X.jsxs)(p,{$gap:4,children:[(0,X.jsx)(b,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:E.isLoading?`Reading usage…`:`${C(N.requests)} requests and ${S(N.costUsd)} over the last ${f.label}.`,actions:(0,X.jsx)(et,{children:Ne.map(e=>(0,X.jsx)(nt,{type:`button`,$size:`sm`,$on:e.id===t,"aria-pressed":e.id===t,onClick:()=>a(e.id),children:e.id},e.id))})}),(0,X.jsxs)($n,{"data-testid":`usage-summary-deck`,children:[(0,X.jsx)(G,{legend:`Requests`,value:C(N.requests),unit:f.label,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.requests??0),overlay:I(e=>F.get(e)?.errors??0),label:`${N.requests} requests, ${N.errors} of them failed`})}),(0,X.jsx)(G,{legend:`Error rate`,value:x(me),unit:`${C(N.errors)} failed`,tone:N.requests===0?`ink`:pe(me),trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.errors/t.requests}),color:`var(--down)`,label:`${N.errors} failed requests against ${N.requests} total`})}),(0,X.jsx)(G,{legend:`Prompt input`,value:C(P),unit:`${C(N.inputTokens)} uncached`,trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return(t?.inputTokens??0)+(t?.cacheReadTokens??0)+(t?.cacheWriteTokens??0)}),label:`${P} prompt input tokens over the window`})}),(0,X.jsx)(G,{legend:`Output`,value:C(N.outputTokens),unit:`mean ${C(ce)}/request`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.outputTokens??0),label:`${N.outputTokens} output tokens over the window`})}),(0,X.jsx)(G,{legend:`Cache reads`,value:C(N.cacheReadTokens),unit:`${x(le,0)} of prompt`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.cacheReadTokens??0),label:`${N.cacheReadTokens} cache-read tokens over the window`})}),(0,X.jsx)(G,{legend:`Cache writes`,value:C(N.cacheWriteTokens),unit:`${x(ue,0)} of prompt`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.cacheWriteTokens??0),label:`${N.cacheWriteTokens} cache-write tokens over the window`})}),(0,X.jsx)(G,{legend:`RTK saved`,value:C(N.rtkSavedTokens),unit:`${C(N.rtkAppliedRequests)} requests`,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.rtkSavedTokens??0),label:`${N.rtkSavedTokens} estimated tokens saved by RTK over the window`})}),(0,X.jsx)(G,{legend:`Mean duration`,value:w(N.requests===0?null:N.durationMsSum/N.requests),unit:`per request`,trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.durationMsSum/t.requests}),color:`var(--ok)`,label:`mean request duration over the window`})}),(0,X.jsx)(G,{legend:`Spend`,value:S(N.costUsd),unit:f.label,trace:(0,X.jsx)(y,{values:I(e=>F.get(e)?.costUsd??0),color:`var(--warn)`,label:`spend over the window, ${S(N.costUsd)} total`})}),(0,X.jsx)(G,{legend:`Cost / request`,value:S(de),unit:`mean`,trace:(0,X.jsx)(y,{values:I(e=>{let t=F.get(e);return t===void 0||t.requests===0?0:t.costUsd/t.requests}),color:`var(--warn)`,label:`${S(de)} mean cost per request over the window`})})]}),(0,X.jsx)($,{legend:`Traffic`,meta:f.by===`hour`?`By hour`:`By day`,query:E,isEmpty:M.length===0,empty:L,children:(0,X.jsx)(Qn,{buckets:M,by:f.by,since:h,until:g})}),(0,X.jsx)(et,{children:We.map(e=>(0,X.jsx)(nt,{type:`button`,$size:`sm`,$on:e.id===o,"aria-pressed":e.id===o,onClick:()=>c(e.id),children:`Rank by ${e.label.toLowerCase()}`},e.id))}),(0,X.jsx)($,{legend:`Traffic by upstream model`,meta:`${m.label}, ${f.by===`hour`?`by hour`:`by day`}`,query:O,isEmpty:(O.data??[]).length===0,empty:L,children:(0,X.jsx)(Rn,{buckets:O.data??[],by:f.by,since:h,until:g,metric:m,providers:ie})}),(0,X.jsxs)(r,{$min:`480px`,$gap:4,children:[(0,X.jsxs)(p,{$gap:4,children:[(0,X.jsx)($,{legend:`Providers`,meta:m.label,query:D,isEmpty:(D.data??[]).length===0,empty:L,children:(0,X.jsx)(Hn,{buckets:D.data??[],by:f.by,since:h,until:g,metric:m})}),(0,X.jsx)(jn,{days:te.data??[],now:Date.now()})]}),(0,X.jsxs)(p,{$gap:4,children:[(0,X.jsx)($,{legend:`Token mix`,meta:C(se),query:E,isEmpty:M.length===0,empty:L,children:(0,X.jsx)(Zn,{buckets:M,by:f.by,since:h,until:g})}),(0,X.jsx)($,{legend:`Models`,meta:tr.find(e=>e.id===l)?.column,query:k,isEmpty:(k.data??[]).length===0,empty:L,actions:(0,X.jsx)(et,{children:tr.map(e=>(0,X.jsx)(nt,{type:`button`,$size:`sm`,$on:e.id===l,"aria-pressed":e.id===l,onClick:()=>u(e.id),children:e.label},e.id))}),children:(0,X.jsx)(Yn,{buckets:k.data??[],metric:m})}),(0,X.jsx)($,{legend:`Accounts`,meta:m.label,query:A,isEmpty:(A.data??[]).length===0,empty:L,children:(0,X.jsx)(Yn,{buckets:A.data??[],metric:m,names:oe,unknownLabel:`No account`})})]})]}),(0,X.jsx)($,{legend:`API keys`,meta:m.label,query:ee,isEmpty:(ee.data??[]).length===0,empty:L,children:(0,X.jsx)(Mn,{buckets:ee.data??[],by:f.by,since:h,until:g,metric:m,names:ae})})]})}var rr=nr;export{rr as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$t as e,Qt as t,_n as n,pt as r}from"./queries-BJHk_wso.js";var i=n(r(),1),a=n(e(),1),o=Object.defineProperty,s=(e,t)=>o(e,`name`,{value:t,configurable:!0});function c(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}s(c,`setRef`);function l(...e){return t=>{let n=!1,r=e.map(e=>{let r=c(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():c(e[t],null)}}}}s(l,`composeRefs`);function u(...e){return a.useCallback(l(...e),e)}s(u,`useComposedRefs`);var d=Object.defineProperty,f=(e,t)=>d(e,`name`,{value:t,configurable:!0});function p(e){let t=a.forwardRef((t,n)=>{let{children:r,...i}=t,o=null,s=!1,c=[];x(r)&&typeof T==`function`&&(r=T(r._payload)),a.Children.forEach(r,e=>{if(y(e)){s=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;x(n)&&typeof T==`function`&&(n=T(n._payload)),o=g(t,n),c.push(o?.props?.children)}else c.push(e)}),o?o=a.cloneElement(o,void 0,c):!s&&a.Children.count(r)===1&&a.isValidElement(r)&&(o=r);let l=o?v(o):void 0,d=u(n,l);if(!o){if(r||r===0)throw Error(s?w(e):C(e));return r}let f=_(i,o.props??{});return o.type!==a.Fragment&&(f.ref=n?d:l),a.cloneElement(o,f)});return t.displayName=`${e}.Slot`,t}f(p,`createSlot`);var m=Symbol.for(`radix.slottable`);function h(e){let t=f(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=m,t}f(h,`createSlottable`);var g=f((e,t)=>{if(`child`in e.props){let t=e.props.child;return a.isValidElement(t)?a.cloneElement(t,void 0,e.props.children(t.props.children)):null}return a.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function _(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}f(_,`mergeProps`);function v(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}f(v,`getElementRef`);function y(e){return a.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===m}f(y,`isSlottable`);var b=Symbol.for(`react.lazy`);function x(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===b&&`_payload`in e&&S(e._payload)}f(x,`isLazyComponent`);function S(e){return typeof e==`object`&&!!e&&`then`in e}f(S,`isPromiseLike`);var C=f(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),w=f(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),T=a.use,E=t(),D=Object.defineProperty,O=(e,t)=>D(e,`name`,{value:t,configurable:!0}),ee=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=p(`Primitive.${t}`),r=a.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,E.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function k(e,t){e&&i.flushSync(()=>e.dispatchEvent(t))}O(k,`dispatchDiscreteCustomEvent`);var A=Object.defineProperty,j=(e,t)=>A(e,`name`,{value:t,configurable:!0});function te(e,t){let n=a.createContext(t);n.displayName=e+`Context`;let r=j(e=>{let{children:t,...r}=e,i=a.useMemo(()=>r,Object.values(r));return(0,E.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:o=!1}=i,s=a.useContext(n);if(s)return s;if(t!==void 0)return t;if(!o)throw Error(`\`${r}\` must be used within \`${e}\``)}return j(i,`useContext`),[r,i]}j(te,`createContext`);function M(e,t=[]){let n=[];function r(t,r){let i=a.createContext(r);i.displayName=t+`Context`;let o=n.length;n=[...n,r];let s=j(t=>{let{scope:n,children:r,...s}=t,c=n?.[e]?.[o]||i,l=a.useMemo(()=>s,Object.values(s));return(0,E.jsx)(c.Provider,{value:l,children:r})},`Provider`);s.displayName=t+`Provider`;function c(n,s,c={}){let{optional:l=!1}=c,u=s?.[e]?.[o]||i,d=a.useContext(u);if(d)return d;if(r!==void 0)return r;if(!l)throw Error(`\`${n}\` must be used within \`${t}\``)}return j(c,`useContext`),[s,c]}j(r,`createContext`);let i=j(()=>{let t=n.map(e=>a.createContext(e));return j(function(n){let r=n?.[e]||t;return a.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,N(i,...t)]}j(M,`createContextScope`);function N(...e){let t=e[0];if(e.length===1)return t;let n=j(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return j(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}j(N,`composeContextScopes`);var P=Object.defineProperty,F=(e,t)=>P(e,`name`,{value:t,configurable:!0}),I=!!(typeof window<`u`&&window.document&&window.document.createElement);function L(e,t,{checkForDefaultPrevented:n=!0}={}){return F(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}F(L,`composeEventHandlers`);function ne(e){if(!I)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}F(ne,`getOwnerWindow`);function R(e){if(!I)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}F(R,`getOwnerDocument`);function z(e,t=!1){let{activeElement:n}=R(e);if(!n?.nodeName)return null;if(B(n)&&n.contentDocument)return z(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=R(n).getElementById(e);if(t)return t}}return n}F(z,`getActiveElement`);function B(e){return e.tagName===`IFRAME`}F(B,`isFrame`);var V=globalThis?.document?a.useLayoutEffect:()=>{},H=Object.defineProperty,U=(e,t)=>H(e,`name`,{value:t,configurable:!0}),W=a.useEffectEvent,G=a.useInsertionEffect;function K(e){if(typeof W==`function`)return W(e);let t=a.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof G==`function`?G(()=>{t.current=e}):V(()=>{t.current=e}),a.useMemo(()=>((...e)=>t.current?.(...e)),[])}U(K,`useEffectEvent`);var q=Object.defineProperty,J=(e,t)=>q(e,`name`,{value:t,configurable:!0}),Y=a.useInsertionEffect||V;function X({prop:e,defaultProp:t,onChange:n=J(()=>{},`onChange`),caller:r}){let[i,o,s]=Z({defaultProp:t,onChange:n}),c=e!==void 0;return[c?e:i,a.useCallback(t=>{if(c){let n=Q(t)?t(e):t;n!==e&&s.current?.(n)}else o(t)},[c,e,o,s])]}J(X,`useControllableState`);function Z({defaultProp:e,onChange:t}){let[n,r]=a.useState(e),i=a.useRef(n),o=a.useRef(t);return Y(()=>{o.current=t},[t]),a.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}J(Z,`useUncontrolledState`);function Q(e){return typeof e==`function`}J(Q,`isFunction`);var $=Symbol(`RADIX:SYNC_STATE`);function re(e,t,n,r){let{prop:i,defaultProp:o,onChange:s,caller:c}=t,l=i!==void 0,u=K(s),d=[{...n,state:o}];r&&d.push(r);let[f,p]=a.useReducer((t,n)=>{if(n.type===$)return{...t,state:n.state};let r=e(t,n);return l&&!Object.is(r.state,t.state)&&u(r.state),r},...d),m=f.state,h=a.useRef(m);a.useEffect(()=>{h.current!==m&&(h.current=m,l||u(m))},[m,h,l]);let g=a.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return a.useEffect(()=>{l&&!Object.is(i,f.state)&&p({type:$,state:i})},[i,f.state,l]),[g,p]}J(re,`useControllableStateReducer`);export{ee as a,u as c,M as i,V as n,k as o,L as r,p as s,X as t};
|