omnigateway 0.1.8 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -33
- package/bin/omni.js +1133 -305
- package/gateway.js +3632 -543
- package/package.json +1 -1
- package/public/assets/{Chip-CM9ZMdr9.js → Chip-C4X8tf5z.js} +1 -1
- package/public/assets/Confirm-BnmH8Gn0.js +4 -0
- package/public/assets/{CopyValue-WrOTcHwq.js → CopyValue-B-uR4Js-.js} +5 -5
- package/public/assets/{Field-Br6jKPz8.js → Field-Ct4SeDZD.js} +2 -2
- package/public/assets/Lamp-CBOwqG5K.js +25 -0
- package/public/assets/{Meter-BzMaum0C.js → Meter-COdz0dwY.js} +1 -1
- package/public/assets/Modal-DMFUHQ-A.js +82 -0
- package/public/assets/{Rack-BFWC50ex.js → Rack-DAbY9x1I.js} +23 -19
- package/public/assets/{Readout-DMJs4gYD.js → Readout-Bl2kD9Tl.js} +6 -2
- package/public/assets/{States-BNeCLhZn.js → States-D5Memn8D.js} +4 -4
- package/public/assets/{Table-nOg_lgEJ.js → Table-DObRatbW.js} +1 -1
- package/public/assets/Toggle-Dkjlvck5.js +39 -0
- package/public/assets/TokenBreakdown-oXP49ZTa.js +31 -0
- package/public/assets/_app-Brc2wQZm.js +1 -0
- package/public/assets/_app.accounts-I9RXUiyi.js +54 -0
- package/public/assets/_app.console-BVVpryIB.js +44 -0
- package/public/assets/_app.index-83Ig4FUL.js +62 -0
- package/public/assets/_app.keys-KeP6L4g_.js +39 -0
- package/public/assets/_app.logs-B5oh01Ls.js +32 -0
- package/public/assets/_app.models-BuOFMZUN.js +144 -0
- package/public/assets/_app.settings-BN436vI2.js +38 -0
- package/public/assets/_app.usage-C528VOia.js +166 -0
- package/public/assets/catalog-kJ53n_fc.js +1 -0
- package/public/assets/dist-CnzT-Ut2.js +1 -0
- package/public/assets/index-CE-KQ-ju.js +172 -0
- package/public/assets/{login-BpUl6C5b.js → login-2LpCZOtB.js} +8 -8
- package/public/assets/queries-1zRLkX-Q.js +144 -0
- package/public/assets/{trash-2-DjWP2u19.js → trash-2-Da6cLgPn.js} +1 -1
- package/public/index.html +2 -2
- package/public/assets/Lamp-DO-sRDg2.js +0 -25
- package/public/assets/Modal-lhjr949H.js +0 -82
- package/public/assets/Toggle-DYoCVD37.js +0 -42
- package/public/assets/_app-lXr06Xli.js +0 -1
- package/public/assets/_app.accounts-BTb5vHI_.js +0 -51
- package/public/assets/_app.console-DHUClMsI.js +0 -25
- package/public/assets/_app.index-DZ--9mKU.js +0 -61
- package/public/assets/_app.keys-B-cy-2DS.js +0 -39
- package/public/assets/_app.logs-BQjAIT2P.js +0 -33
- package/public/assets/_app.models-BAmXHlf2.js +0 -144
- package/public/assets/_app.settings-CG8bv_rm.js +0 -34
- package/public/assets/_app.usage-BLrQ2hB8.js +0 -163
- package/public/assets/catalog-C_OQ0icG.js +0 -1
- package/public/assets/index-UAZ0O5y0.js +0 -170
- package/public/assets/queries-D_-Jj9vt.js +0 -144
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,G as n,I as r,L as i,M as a,Mt as o,Nt as s,P as c,R as l,V as u,Zt as d,j as f,m as p,p as m,x as h,y as g}from"./queries-D_-Jj9vt.js";import{m as _,t as v}from"./Rack-BFWC50ex.js";import{n as y,r as b,t as x}from"./Toggle-DYoCVD37.js";import{t as S}from"./trash-2-DjWP2u19.js";import{n as C,t as w}from"./Chip-CM9ZMdr9.js";import{i as T,n as E,r as D,t as O}from"./Field-Br6jKPz8.js";import{t as ee}from"./Meter-BzMaum0C.js";import{a as k,i as A,n as te,r as j,t as M}from"./States-BNeCLhZn.js";import{n as ne,r as re,t as N}from"./catalog-C_OQ0icG.js";var P=_(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),ie=_(`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`}]]),F=d(s(),1),I=o(),L=[`tier`,`health`,`quota`,`cost`,`latency`,`recency`],ae={tier:`How preferred this tier is`,health:`Consecutive failures and breaker state`,quota:`Headroom in the tightest window, against how much of it is left`,cost:`Price against the other candidates`,latency:`Observed time to first token`,recency:`How long this pair has been idle`},oe=n.li`
|
|
2
|
-
padding: ${({theme:e})=>e.space(2)} 0;
|
|
3
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
4
|
-
|
|
5
|
-
&:last-child {
|
|
6
|
-
border-bottom: 0;
|
|
7
|
-
}
|
|
8
|
-
`,se=n(a)`
|
|
9
|
-
width: 22px;
|
|
10
|
-
color: ${({theme:e})=>e.color.inkFaint};
|
|
11
|
-
flex: none;
|
|
12
|
-
`,ce=n(w)`
|
|
13
|
-
border-color: ${({theme:e})=>e.color.ok};
|
|
14
|
-
color: ${({theme:e})=>e.color.ok};
|
|
15
|
-
background: ${({theme:e})=>e.color.okWash};
|
|
16
|
-
`,le=n.div`
|
|
17
|
-
display: grid;
|
|
18
|
-
grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
|
|
19
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
20
|
-
margin-top: ${({theme:e})=>e.space(2)};
|
|
21
|
-
padding-left: 30px;
|
|
22
|
-
`,ue=n.div`
|
|
23
|
-
display: flex;
|
|
24
|
-
flex-direction: column;
|
|
25
|
-
gap: 3px;
|
|
26
|
-
min-width: 0;
|
|
27
|
-
`,de=n.div`
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: baseline;
|
|
30
|
-
justify-content: space-between;
|
|
31
|
-
gap: 6px;
|
|
32
|
-
`,fe=n.li`
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
36
|
-
padding: 5px 0;
|
|
37
|
-
`,pe=n(c)`
|
|
38
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
39
|
-
flex-wrap: wrap;
|
|
40
|
-
`,R=n.label`
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
gap: 6px;
|
|
44
|
-
cursor: pointer;
|
|
45
|
-
font-size: 12.5px;
|
|
46
|
-
`,z=n.p`
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
color: ${({theme:e})=>e.color.down};
|
|
49
|
-
`;function B(e,t,n){return(e[t]??0)*n[t]}function me({modelId:n}){let[o,s]=(0,F.useState)({tools:!1,images:!1,reasoning:!1}),[u,d]=(0,F.useState)(null),[m,h]=(0,F.useState)(null),g=t(),_=p(),v=g.data?.weights,y=()=>{n!==null&&(h(null),_.mutate({modelId:n,need:o},{onSuccess:e=>d(e),onError:e=>{d(null),h(A(e))}}))},b=new Map(L.map(e=>[e,Math.max(1e-4,...(u?.candidates??[]).map(t=>v===void 0?0:Math.abs(B(t.reasons,e,v))))]));return(0,I.jsx)(k,{legend:`Explain`,meta:n??`no model selected`,actions:(0,I.jsxs)(e,{type:`button`,$size:`sm`,$variant:`primary`,disabled:n===null||_.isPending,onClick:y,children:[(0,I.jsx)(P,{}),_.isPending?`Ranking…`:`Rank candidates`]}),children:(0,I.jsxs)(i,{$gap:3,children:[(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(f,{children:`Pretend the request needs`}),(0,I.jsxs)(pe,{children:[(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:o.tools,label:`Probe request uses tools`,onCheckedChange:e=>s({...o,tools:e})}),`Tools`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:o.images,label:`Probe request includes an image`,onCheckedChange:e=>s({...o,images:e})}),`Images`]}),(0,I.jsxs)(R,{children:[(0,I.jsx)(x,{checked:o.reasoning,label:`Probe request asks for reasoning`,onCheckedChange:e=>s({...o,reasoning:e})}),`Reasoning`]})]})]}),m===null?null:(0,I.jsx)(z,{children:m}),u===null?(0,I.jsx)(M,{legend:`Not ranked yet`,message:n===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,I.jsxs)(i,{$gap:3,children:[(0,I.jsxs)(c,{$gap:2,$wrap:!0,children:[(0,I.jsx)(w,{$tone:`accent`,children:u.strategy}),u.deterministic?null:(0,I.jsx)(w,{$tone:`warn`,children:`order varies per request`}),(0,I.jsx)(r,{}),(0,I.jsxs)(f,{children:[u.candidates.length,` eligible · `,u.excluded.length,` filtered out`]})]}),u.candidates.length===0?(0,I.jsx)(M,{legend:`Nothing eligible`,message:`Every target was filtered out. The reasons below say which rule removed each one.`}):(0,I.jsx)(`ul`,{children:u.candidates.map((e,t)=>(0,I.jsxs)(oe,{children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsx)(se,{children:t+1}),(0,I.jsx)(C,{provider:e.provider}),(0,I.jsx)(l,{style:{maxWidth:`22ch`},children:e.credentialLabel}),(0,I.jsx)(a,{$dim:!0,children:e.model}),(0,I.jsxs)(w,{children:[`tier `,e.tier]}),(0,I.jsx)(r,{}),t===0?(0,I.jsx)(ce,{children:`would be used`}):null,(0,I.jsx)(a,{children:e.score.toFixed(2)})]}),v===void 0?null:(0,I.jsx)(le,{children:L.map(t=>{let n=B(e.reasons,t,v),r=b.get(t)??1;return(0,I.jsxs)(ue,{title:ae[t],children:[(0,I.jsxs)(de,{children:[(0,I.jsx)(f,{children:t}),(0,I.jsx)(a,{$dim:!0,$size:`10.5px`,children:n.toFixed(2)})]}),(0,I.jsx)(ee,{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}`))}),u.excluded.length===0?null:(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(f,{children:`Filtered out`}),(0,I.jsx)(`ul`,{children:u.excluded.map(e=>(0,I.jsxs)(fe,{children:[(0,I.jsx)(a,{$dim:!0,children:e.model}),(0,I.jsx)(r,{}),(0,I.jsx)(w,{$tone:e.reason.startsWith(`capability`)?`warn`:`down`,children:e.reason})]},`${e.credentialId}:${e.model}:${e.reason}`))})]})]})]})})}var V=[{id:`score`,label:`Best score`,blurb:`Rank every eligible target by the routing weights and take the best one.`},{id:`priority`,label:`Lowest tier`,blurb:`Always prefer the lowest tier. Score only breaks ties inside a tier.`},{id:`roundRobin`,label:`Round robin`,blurb:`Take whichever eligible target has been idle longest, to spread load evenly.`},{id:`weighted`,label:`Weighted draw`,blurb:`Pick at random, biased by weight. The order differs from request to request.`}],H=0;function U(){return H+=1,`target-${H}`}function W(e,t){let n=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 he(e,t){let n=ne(e,t);return n===null?null:{contextWindow:String(n.contextWindow),maxOutputTokens:String(n.maxOutputTokens)}}function ge(e,t){return{...e,...t,...W(t.provider,t.model)??{},contextWindow:``,maxOutputTokens:``}}function G(e=`anthropic`){let t=N[e].defaultModel,n=W(e,t);return{key:U(),provider:e,model:t,tier:`1`,weight:`1`,costInput:n?.costInput??`0`,costOutput:n?.costOutput??`0`,costCacheRead:n?.costCacheRead??``,costCacheWrite5m:n?.costCacheWrite5m??``,costCacheWrite1h:n?.costCacheWrite1h??``,contextWindow:``,maxOutputTokens:``,tools:!0,images:!0,reasoning:!0}}function K(){return{id:``,strategy:`score`,isAlias:!1,targets:[G()]}}function q(e){return{id:e.id,strategy:e.strategy,isAlias:e.isAlias,targets:e.targets.map(e=>({key:U(),provider:e.provider,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 _e(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.model.trim();if(i.length===0)return{ok:!1,problem:`${e} needs a provider model name.`};let a=Number(r.tier);if(!Number.isInteger(a)||a<1)return{ok:!1,problem:`${e}: tier must be a whole number of 1 or more.`};let o=Number(r.weight);if(!Number.isFinite(o)||o<=0)return{ok:!1,problem:`${e}: weight must be greater than zero.`};let s=Number(r.costInput),c=Number(r.costOutput);if(!Number.isFinite(s)||s<0||!Number.isFinite(c)||c<0)return{ok:!1,problem:`${e}: prices cannot be negative.`};let l=r.costCacheRead.trim().length>0,u=Number(r.costCacheRead);if(l&&(!Number.isFinite(u)||u<0))return{ok:!1,problem:`${e}: the cache-read price cannot be negative.`};let d=r.costCacheWrite5m.trim().length>0,f=Number(r.costCacheWrite5m);if(d&&(!Number.isFinite(f)||f<0))return{ok:!1,problem:`${e}: the 5m cache-write price must be a number of 0 or more.`};let p=r.costCacheWrite1h.trim().length>0,m=Number(r.costCacheWrite1h);if(p&&(!Number.isFinite(m)||m<0))return{ok:!1,problem:`${e}: the 1h cache-write price must be a number of 0 or more.`};let h=r.contextWindow.trim().length>0,g=Number(r.contextWindow);if(h&&(!Number.isInteger(g)||g<1))return{ok:!1,problem:`${e}: the context window must be a whole number of tokens.`};let _=r.maxOutputTokens.trim().length>0,v=Number(r.maxOutputTokens);if(_&&(!Number.isInteger(v)||v<1))return{ok:!1,problem:`${e}: the output limit must be a whole number of tokens.`};n.push({provider:r.provider,model:i,tier:a,weight:o,costPerMTok:{input:s,output:c,...l?{cacheRead:u}:{},...d?{cacheWrite5m:f}:{},...p?{cacheWrite1h:m}:{}},...h?{contextWindow:g}:{},..._?{maxOutputTokens:v}:{},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 ve=Object.keys(N),ye=n.fieldset`
|
|
50
|
-
border: 1px solid ${({theme:e})=>e.color.rule};
|
|
51
|
-
border-left: 3px solid ${({theme:e,$provider:t})=>e.provider[t]};
|
|
52
|
-
border-radius: ${({theme:e})=>e.radius.control};
|
|
53
|
-
padding: ${({theme:e})=>e.space(3)};
|
|
54
|
-
margin: 0;
|
|
55
|
-
background: ${({theme:e})=>e.color.panelSunk};
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
59
|
-
min-width: 0;
|
|
60
|
-
`,be=n.div`
|
|
61
|
-
display: grid;
|
|
62
|
-
grid-template-columns: minmax(140px, 1.4fr) minmax(160px, 2fr) 72px 72px;
|
|
63
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
64
|
-
align-items: end;
|
|
65
|
-
|
|
66
|
-
@media (max-width: 720px) {
|
|
67
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
68
|
-
}
|
|
69
|
-
`,J=n.div`
|
|
70
|
-
display: grid;
|
|
71
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
72
|
-
gap: ${({theme:e})=>e.space(2)};
|
|
73
|
-
align-items: end;
|
|
74
|
-
`,Y=n.div`
|
|
75
|
-
display: flex;
|
|
76
|
-
flex-direction: column;
|
|
77
|
-
gap: 4px;
|
|
78
|
-
min-width: 0;
|
|
79
|
-
`,xe=n(c)`
|
|
80
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
81
|
-
flex-wrap: wrap;
|
|
82
|
-
`,X=n.label`
|
|
83
|
-
display: flex;
|
|
84
|
-
align-items: center;
|
|
85
|
-
gap: 6px;
|
|
86
|
-
cursor: pointer;
|
|
87
|
-
`;function Se({target:t,index:n,onChange:a,onRemove:o,removable:s}){let l=(0,F.useId)(),d=N[t.provider],p=(e,n)=>{a({...t,[e]:n})},m=W(t.provider,t.model),h=he(t.provider,t.model),g=e=>{a(ge(t,e))};return(0,I.jsxs)(ye,{$provider:t.provider,children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsxs)(f,{as:`legend`,children:[`Target `,n+1]}),(0,I.jsx)(r,{}),(0,I.jsx)(u,{type:`button`,$variant:`ghost`,$size:`sm`,disabled:!s,"aria-label":`Remove target ${n+1}`,title:s?`Remove target ${n+1}`:`A model needs at least one target`,onClick:o,children:(0,I.jsx)(S,{})})]}),(0,I.jsxs)(be,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-provider`,children:`Provider`}),(0,I.jsx)(T,{id:`${l}-provider`,value:t.provider,onChange:e=>{let n=e.target.value,r=N[n].models.some(e=>e.id===t.model);g({provider:n,model:r?t.model:N[n].defaultModel})},children:ve.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-model`,children:`Provider model`}),(0,I.jsx)(E,{id:`${l}-model`,list:`${l}-catalog`,value:t.model,placeholder:d.defaultModel,onChange:e=>g({provider:t.provider,model:e.target.value})}),(0,I.jsx)(`datalist`,{id:`${l}-catalog`,children:d.models.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-tier`,children:`Tier`}),(0,I.jsx)(D,{id:`${l}-tier`,min:1,step:1,value:t.tier,onChange:e=>p(`tier`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-weight`,children:`Weight`}),(0,I.jsx)(D,{id:`${l}-weight`,min:0,step:.1,value:t.weight,onChange:e=>p(`weight`,e.target.value)})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsx)(f,{children:`Price per million tokens`}),(0,I.jsx)(r,{}),m===null?(0,I.jsx)(f,{as:`span`,children:`not in the catalog — price it yourself`}):(0,I.jsxs)(e,{type:`button`,$size:`sm`,$variant:`ghost`,disabled:t.costInput===m.costInput&&t.costOutput===m.costOutput&&t.costCacheRead===m.costCacheRead&&t.costCacheWrite5m===m.costCacheWrite5m&&t.costCacheWrite1h===m.costCacheWrite1h,onClick:()=>a({...t,...m}),children:[(0,I.jsx)(ie,{}),`Use list price`]})]}),(0,I.jsxs)(J,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-in`,children:`Input`}),(0,I.jsx)(D,{id:`${l}-in`,min:0,step:.01,value:t.costInput,onChange:e=>p(`costInput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-out`,children:`Output`}),(0,I.jsx)(D,{id:`${l}-out`,min:0,step:.01,value:t.costOutput,onChange:e=>p(`costOutput`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-cache`,children:`Cache read`}),(0,I.jsx)(D,{id:`${l}-cache`,min:0,step:.01,placeholder:`same as input`,value:t.costCacheRead,onChange:e=>p(`costCacheRead`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-write5m`,children:`Cache write 5m`}),(0,I.jsx)(D,{id:`${l}-write5m`,min:0,step:.01,placeholder:`1.25x input`,value:t.costCacheWrite5m,onChange:e=>p(`costCacheWrite5m`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-write1h`,children:`Cache write 1h`}),(0,I.jsx)(D,{id:`${l}-write1h`,min:0,step:.01,placeholder:`2x input`,value:t.costCacheWrite1h,onChange:e=>p(`costCacheWrite1h`,e.target.value)})]})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsxs)(c,{$gap:2,children:[(0,I.jsx)(f,{children:`Token limits`}),(0,I.jsx)(r,{}),h===null?(0,I.jsx)(f,{as:`span`,children:`not in the catalog — state them yourself`}):(0,I.jsx)(f,{as:`span`,children:`left empty, the published figures are used — and for an OpenAI target, the narrower ones its OAuth backend allows`})]}),(0,I.jsxs)(J,{children:[(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-context`,children:`Context window`}),(0,I.jsx)(D,{id:`${l}-context`,min:1,step:1024,placeholder:h?.contextWindow??`published`,value:t.contextWindow,onChange:e=>p(`contextWindow`,e.target.value)})]}),(0,I.jsxs)(Y,{children:[(0,I.jsx)(f,{as:`label`,htmlFor:`${l}-maxout`,children:`Max output`}),(0,I.jsx)(D,{id:`${l}-maxout`,min:1,step:1024,placeholder:h?.maxOutputTokens??`published`,value:t.maxOutputTokens,onChange:e=>p(`maxOutputTokens`,e.target.value)})]})]})]}),(0,I.jsxs)(i,{$gap:1,children:[(0,I.jsx)(f,{children:`Capabilities`}),(0,I.jsxs)(xe,{children:[(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:t.tools,label:`Target ${n+1} supports tools`,onCheckedChange:e=>p(`tools`,e)}),`Tools`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:t.images,label:`Target ${n+1} supports images`,onCheckedChange:e=>p(`images`,e)}),`Images`]}),(0,I.jsxs)(X,{children:[(0,I.jsx)(x,{checked:t.reasoning,label:`Target ${n+1} supports reasoning`,onCheckedChange:e=>p(`reasoning`,e)}),`Reasoning`]})]})]})]})}var Z=n.p`
|
|
88
|
-
font-size: 11.5px;
|
|
89
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
90
|
-
`,Ce=n.p`
|
|
91
|
-
font-size: 12px;
|
|
92
|
-
color: ${({theme:e})=>e.color.down};
|
|
93
|
-
`,we=n.p`
|
|
94
|
-
font-size: 12px;
|
|
95
|
-
color: ${({theme:e})=>e.color.ok};
|
|
96
|
-
`,Te=n(c)`
|
|
97
|
-
gap: 8px;
|
|
98
|
-
`;function Ee({model:t,onSaved:n,onDeleted:a}){let[o,s]=(0,F.useState)(()=>t===null?K():q(t)),[l,u]=(0,F.useState)(null),[d,p]=(0,F.useState)(!1),[g,_]=(0,F.useState)(!1),v=h(),S=m(),C=t?.id??null;(0,F.useEffect)(()=>{s(t===null?K():q(t)),u(null),p(!1)},[C]);let w=V.find(e=>e.id===o.strategy);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(k,{legend:t===null?`New model`:`Edit model`,meta:t===null?void 0:t.id,actions:(0,I.jsxs)(I.Fragment,{children:[t===null?null:(0,I.jsx)(e,{type:`button`,$variant:`danger`,$size:`sm`,onClick:()=>_(!0),children:`Delete`}),(0,I.jsx)(e,{type:`button`,$variant:`primary`,$size:`sm`,disabled:v.isPending,onClick:()=>{p(!1);let e=_e(o);if(!e.ok){u(e.problem);return}u(null),v.mutate(e.model,{onSuccess:()=>{p(!0),n(e.model.id)},onError:e=>u(A(e))})},children:v.isPending?`Saving…`:t===null?`Create model`:`Save changes`})]}),children:(0,I.jsxs)(i,{$gap:3,children:[(0,I.jsx)(O,{label:`Model name`,hint:t===null?`What clients send as the model. Anything not listed here is rejected.`:`Fixed once created. To rename, create a model under the new name and delete this one.`,children:e=>(0,I.jsx)(E,{...e,value:o.id,disabled:t!==null,placeholder:`fast`,onChange:e=>s({...o,id:e.target.value})})}),(0,I.jsx)(O,{label:`Routing strategy`,children:e=>(0,I.jsx)(T,{...e,value:o.strategy,onChange:e=>s({...o,strategy:e.target.value}),children:V.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.label},e.id))})}),w===void 0?null:(0,I.jsx)(Z,{children:w.blurb}),(0,I.jsxs)(Te,{children:[(0,I.jsx)(x,{checked:o.isAlias,label:`This model is an alias for a provider model name`,onCheckedChange:e=>s({...o,isAlias:e})}),(0,I.jsxs)(i,{$gap:0,children:[(0,I.jsx)(f,{as:`span`,children:`Alias`}),(0,I.jsx)(Z,{children:`Mark this when the name mirrors a provider's own model name.`})]})]}),(0,I.jsxs)(i,{$gap:2,children:[(0,I.jsxs)(c,{children:[(0,I.jsx)(f,{children:`Targets`}),(0,I.jsx)(r,{}),(0,I.jsxs)(e,{type:`button`,$size:`sm`,onClick:()=>s({...o,targets:[...o.targets,G(o.targets.at(-1)?.provider??`anthropic`)]}),children:[(0,I.jsx)(b,{}),`Add target`]})]}),o.targets.map((e,t)=>(0,I.jsx)(Se,{target:e,index:t,removable:o.targets.length>1,onChange:t=>s({...o,targets:o.targets.map(n=>n.key===e.key?t:n)}),onRemove:()=>s({...o,targets:o.targets.filter(t=>t.key!==e.key)})},e.key))]}),l===null?null:(0,I.jsx)(Ce,{role:`alert`,children:l}),d&&l===null?(0,I.jsx)(we,{role:`status`,children:`Saved.`}):null]})}),(0,I.jsx)(y,{open:g,onOpenChange:_,title:`Delete model`,body:t===null?``:`Deleting "${t.id}" makes it unroutable. Clients asking for it will get a model-unavailable error, and any key allowlisting it keeps a name that no longer resolves.`,confirmLabel:`Delete model`,busy:S.isPending,onConfirm:()=>{t!==null&&S.mutate(t.id,{onSuccess:()=>{_(!1),a()},onError:e=>{_(!1),u(A(e))}})}})]})}var De=n.div`
|
|
99
|
-
display: grid;
|
|
100
|
-
grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
|
|
101
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
102
|
-
align-items: start;
|
|
103
|
-
|
|
104
|
-
@media (max-width: 980px) {
|
|
105
|
-
grid-template-columns: minmax(0, 1fr);
|
|
106
|
-
}
|
|
107
|
-
`,Oe=n(i)`
|
|
108
|
-
gap: ${({theme:e})=>e.space(4)};
|
|
109
|
-
min-width: 0;
|
|
110
|
-
`,Q=n.button`
|
|
111
|
-
display: flex;
|
|
112
|
-
flex-direction: column;
|
|
113
|
-
gap: 4px;
|
|
114
|
-
width: 100%;
|
|
115
|
-
padding: ${({theme:e})=>`${e.space(2)} ${e.space(3)}`};
|
|
116
|
-
text-align: left;
|
|
117
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:`transparent`};
|
|
118
|
-
border: 0;
|
|
119
|
-
border-left: 2px solid
|
|
120
|
-
${({theme:e,$selected:t})=>t?e.color.accent:`transparent`};
|
|
121
|
-
border-bottom: 1px solid ${({theme:e})=>e.color.rule};
|
|
122
|
-
cursor: pointer;
|
|
123
|
-
|
|
124
|
-
&:hover {
|
|
125
|
-
background: ${({theme:e,$selected:t})=>t?e.color.accentWash:e.color.panelSunk};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
&:last-child {
|
|
129
|
-
border-bottom: 0;
|
|
130
|
-
}
|
|
131
|
-
`,ke=n(l)`
|
|
132
|
-
font-family: ${({theme:e})=>e.font.mono};
|
|
133
|
-
font-size: 12.5px;
|
|
134
|
-
display: block;
|
|
135
|
-
max-width: 100%;
|
|
136
|
-
`,Ae=n.div`
|
|
137
|
-
display: flex;
|
|
138
|
-
gap: 2px;
|
|
139
|
-
`,je=n.span`
|
|
140
|
-
width: 12px;
|
|
141
|
-
height: 3px;
|
|
142
|
-
border-radius: 1px;
|
|
143
|
-
background: ${({$provider:e})=>`var(--p-${e})`};
|
|
144
|
-
`,$=`\0new`;function Me(){let t=g(),[n,i]=(0,F.useState)(null),o=t.data??[],s=n===$?null:o.find(e=>e.id===n)??null,l=n===$||n===null&&!t.isLoading&&o.length===0;(0,F.useEffect)(()=>{n===null&&o.length!==0&&i(o[0]?.id??null)},[o,n]);let u=t.isLoading?`Reading configured models…`:o.length===0?`No virtual models exist yet, so no client request can resolve to an upstream.`:`${o.length} model${o.length===1?``:`s`} routing to ${o.reduce((e,t)=>e+t.targets.length,0)} targets.`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{legend:`Models`,title:`Virtual models`,summary:u,actions:(0,I.jsxs)(e,{type:`button`,$variant:`primary`,onClick:()=>i($),children:[(0,I.jsx)(b,{}),`New model`]})}),(0,I.jsxs)(De,{children:[(0,I.jsx)(k,{legend:`Configured`,meta:`${o.length}`,flush:!0,children:t.isError?(0,I.jsx)(te,{error:t.error,onRetry:()=>void t.refetch()}):t.isLoading?(0,I.jsx)(`div`,{style:{padding:12},children:(0,I.jsx)(j,{rows:4})}):o.length===0?(0,I.jsx)(M,{legend:`No models`,message:`Create a model to give clients something to ask for.`,action:(0,I.jsx)(e,{type:`button`,$size:`sm`,$variant:`primary`,onClick:()=>i($),children:`New model`})}):(0,I.jsx)(`div`,{children:o.map(e=>{let t=[...new Set(e.targets.map(e=>e.provider))];return(0,I.jsxs)(Q,{type:`button`,$selected:e.id===n,"aria-pressed":e.id===n,onClick:()=>i(e.id),children:[(0,I.jsxs)(c,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(ke,{title:e.id,children:e.id}),(0,I.jsx)(r,{}),e.isAlias?(0,I.jsx)(w,{children:`alias`}):null]}),(0,I.jsxs)(c,{$gap:2,style:{width:`100%`},children:[(0,I.jsx)(Ae,{children:t.map(e=>(0,I.jsx)(je,{$provider:e,title:e},e))}),(0,I.jsx)(f,{children:e.strategy}),(0,I.jsx)(r,{}),(0,I.jsxs)(a,{$dim:!0,$size:`11px`,children:[e.targets.length,` target`,e.targets.length===1?``:`s`]})]})]},e.id)})})}),(0,I.jsxs)(Oe,{children:[s===null&&!l?(0,I.jsx)(k,{legend:`Editor`,children:t.isLoading?(0,I.jsx)(j,{rows:5}):(0,I.jsx)(M,{legend:`Nothing selected`,message:`Pick a model on the left to change its targets, or create a new one.`})}):(0,I.jsx)(Ee,{model:s,onSaved:e=>{i(e),t.refetch()},onDeleted:()=>{i(null),t.refetch()}}),(0,I.jsx)(me,{modelId:s?.id??null})]})]})]})}var Ne=Me;export{Ne as component};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,G as n,I as r,L as i,M as a,Mt as o,Nt as s,P as c,S as l,Zt as u,a as d,j as f}from"./queries-D_-Jj9vt.js";import{t as p}from"./Rack-BFWC50ex.js";import{n as m,t as h}from"./Field-Br6jKPz8.js";import{t as g}from"./Meter-BzMaum0C.js";import{a as _,i as v,n as y,r as b}from"./States-BNeCLhZn.js";var x=u(s(),1),S=o(),C=[{id:`claude`,label:`Claude Code`,where:`one profile per model, under ~/.claude/profiles`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],w=n(a)`
|
|
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
|
-
`,T=n.div`
|
|
12
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
13
|
-
font-size: 0.8125rem;
|
|
14
|
-
margin-bottom: 0.25rem;
|
|
15
|
-
`,E=n.p`
|
|
16
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
17
|
-
font-size: 0.8125rem;
|
|
18
|
-
margin: 0;
|
|
19
|
-
`;function D(){let[t,n]=(0,x.useState)(`claude`),r=d(t),o=C.find(e=>e.id===t);return(0,S.jsx)(_,{legend:`Agent setup`,children:(0,S.jsxs)(i,{children:[(0,S.jsx)(c,{children:C.map(r=>(0,S.jsx)(e,{type:`button`,$variant:r.id===t?`primary`:`ghost`,onClick:()=>n(r.id),children:r.label},r.id))}),(0,S.jsxs)(E,{children:[o?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,(0,S.jsxs)(a,{children:[`omni setup `,t]}),` to write these files directly.`]}),r.isError?(0,S.jsx)(y,{error:r.error,onRetry:()=>void r.refetch()}):r.isLoading?(0,S.jsx)(b,{rows:4}):r.data===void 0||r.data.length===0?(0,S.jsx)(E,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):r.data.map(e=>(0,S.jsxs)(`div`,{children:[(0,S.jsx)(T,{children:e.path}),(0,S.jsx)(w,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),r.isError?(0,S.jsx)(E,{children:v(r.error)}):null]})})}var O=[{id:`tier`,label:`Tier`,blurb:`How strongly a lower tier is preferred.`},{id:`health`,label:`Health`,blurb:`Penalty for recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Preference for accounts keeping ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Preference for the cheaper target of the candidates.`},{id:`latency`,label:`Latency`,blurb:`Preference for the faster observed first token.`},{id:`recency`,label:`Recency`,blurb:`Preference for accounts that have been idle.`}],k=[{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 single client request may take across all attempts.`,unit:`ms`,step:1e3,min:1},{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}],A=n.div`
|
|
20
|
-
display: grid;
|
|
21
|
-
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
22
|
-
gap: ${({theme:e})=>e.space(3)};
|
|
23
|
-
`,j=n(i)`
|
|
24
|
-
gap: 6px;
|
|
25
|
-
`,M=n.p`
|
|
26
|
-
font-size: 11px;
|
|
27
|
-
color: ${({theme:e})=>e.color.inkDim};
|
|
28
|
-
`,N=n.p`
|
|
29
|
-
font-size: 12px;
|
|
30
|
-
color: ${({theme:e})=>e.color.down};
|
|
31
|
-
`,P=n.p`
|
|
32
|
-
font-size: 12px;
|
|
33
|
-
color: ${({theme:e})=>e.color.ok};
|
|
34
|
-
`;function F(e){let t={};for(let n of O)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of k)t[n.id]=String(e[n.id]);return t}function I(e){let t={};for(let n of O){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 k){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}}}function L(){let n=t(),o=l(),[s,u]=(0,x.useState)({}),[d,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(!1);(0,x.useEffect)(()=>{n.data!==void 0&&u(F(n.data))},[n.data]);let E=Math.max(1e-4,...O.map(e=>Math.abs(Number(s[`w.${e.id}`])||0)));return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(p,{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,S.jsx)(e,{type:`button`,$variant:`primary`,disabled:o.isPending||n.isLoading,onClick:()=>{T(!1);let e=I(s);if(!e.ok){C(e.problem);return}C(null),o.mutate(e.settings,{onSuccess:()=>T(!0),onError:e=>C(v(e))})},children:o.isPending?`Saving…`:`Save changes`})}),n.isError?(0,S.jsx)(_,{legend:`Settings`,children:(0,S.jsx)(y,{error:n.error,onRetry:()=>void n.refetch()})}):n.isLoading?(0,S.jsx)(_,{legend:`Settings`,children:(0,S.jsx)(b,{rows:6})}):(0,S.jsxs)(i,{$gap:4,children:[(0,S.jsx)(_,{legend:`Scoring weights`,meta:`relative to each other`,footer:(0,S.jsxs)(c,{children:[(0,S.jsx)(f,{children:`A candidate's score is the sum of each term times its weight, then multiplied by the account and target weights.`}),(0,S.jsx)(r,{})]}),children:(0,S.jsx)(A,{children:O.map(e=>{let t=Number(s[`w.${e.id}`])||0;return(0,S.jsxs)(j,{children:[(0,S.jsx)(h,{label:e.label,children:t=>(0,S.jsx)(m,{...t,type:`number`,step:.5,value:s[`w.${e.id}`]??``,onChange:t=>u({...s,[`w.${e.id}`]:t.target.value})})}),(0,S.jsx)(g,{fraction:Math.abs(t)/E,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),(0,S.jsx)(M,{children:e.blurb})]},e.id)})})}),(0,S.jsx)(_,{legend:`Limits`,children:(0,S.jsx)(A,{children:k.map(e=>(0,S.jsx)(j,{children:(0,S.jsx)(h,{label:e.label,hint:e.hint,children:t=>(0,S.jsxs)(c,{$gap:2,children:[(0,S.jsx)(m,{...t,type:`number`,min:e.min,step:e.step,value:s[e.id]??``,onChange:t=>u({...s,[e.id]:t.target.value})}),(0,S.jsx)(f,{children:e.unit})]})})},e.id))})}),d===null?null:(0,S.jsx)(N,{role:`alert`,children:d}),w&&d===null?(0,S.jsx)(P,{role:`status`,children:`Settings saved.`}):null,(0,S.jsx)(D,{}),(0,S.jsx)(_,{legend:`Known limits`,children:(0,S.jsxs)(i,{$gap:2,children:[(0,S.jsxs)(c,{$gap:2,children:[(0,S.jsx)(a,{$dim:!0,children:`rate limits`}),(0,S.jsx)(M,{children:`Per-key rate limits are counted inside one gateway process and reset when it restarts. They are not shared across instances.`})]}),(0,S.jsxs)(c,{$gap:2,children:[(0,S.jsx)(a,{$dim:!0,children:`logs`}),(0,S.jsx)(M,{children:`Request rows record routing and token counts only. Prompts, responses, and credentials are never written.`})]})]})})]})]})}var R=L;export{R as component};
|