@aidotnet/server-linux-x64 0.13.3 → 0.13.5
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/bin/astra-server +2 -2
- package/bin/wwwroot/assets/{ClientsPage-CnHLR9_Q.js → ClientsPage-gRSh7_CV.js} +2 -2
- package/bin/wwwroot/assets/{KeyPage-zIb63Of5.js → KeyPage-D77qfw6X.js} +1 -1
- package/bin/wwwroot/assets/{ModelDetailPage-BcXehC4E.js → ModelDetailPage-9WGV08Ir.js} +1 -1
- package/bin/wwwroot/assets/{ModelsPage-BWIb4L9N.js → ModelsPage-ONDK3J08.js} +1 -1
- package/bin/wwwroot/assets/{PluginsPage-BaoJMLzq.js → PluginsPage-nSzZ0q9J.js} +1 -1
- package/bin/wwwroot/assets/{PrivacyPage-BmqVk2pi.js → PrivacyPage-L2K6y0cS.js} +1 -1
- package/bin/wwwroot/assets/{ProviderDetailPage-BLCMpahq.js → ProviderDetailPage-Cb_AXwQV.js} +1 -1
- package/bin/wwwroot/assets/{ProvidersPage-CnBPj_Jb.js → ProvidersPage-D4CaD0A4.js} +1 -1
- package/bin/wwwroot/assets/{SettingsPage-CcEs-Ivi.js → SettingsPage-DxaHksJO.js} +2 -2
- package/bin/wwwroot/assets/{SmartRoutingPage-BEf8F6eE.js → SmartRoutingPage-CAcrEtoz.js} +1 -1
- package/bin/wwwroot/assets/{TokenDetailPage-CnwCepbj.js → TokenDetailPage-DQjS2Rfd.js} +1 -1
- package/bin/wwwroot/assets/{TokenPoolEditor-B5YYbTBI.js → TokenPoolEditor-B_Z5aPHq.js} +1 -1
- package/bin/wwwroot/assets/{TokensPage-IYF5mfUz.js → TokensPage-DI5GW9jT.js} +1 -1
- package/bin/wwwroot/assets/{TracesPage-RdQ1uzTo.js → TracesPage-BLhnQx6x.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelPage-DF3TZ-Mi.js → TrayPanelPage-BVygPKsx.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-ctysAPlQ.js → TrayPanelView-CxRkRjNA.js} +1 -1
- package/bin/wwwroot/assets/{alert-CMMOyMsp.js → alert-BF0mCqUl.js} +3 -3
- package/bin/wwwroot/assets/{arrow-down-rd1gJD55.js → arrow-down-DZLYQSjE.js} +1 -1
- package/bin/wwwroot/assets/{arrow-left-BYi8J86q.js → arrow-left-D_GXSlab.js} +1 -1
- package/bin/wwwroot/assets/{arrow-up-right-DNaPmTcJ.js → arrow-up-right-6yJy6Xdl.js} +1 -1
- package/bin/wwwroot/assets/{checkbox--x0D0yfB.js → checkbox-j5bCl2a6.js} +1 -1
- package/bin/wwwroot/assets/{cloud-download-BkOTPIzF.js → cloud-download-D02pcV_l.js} +1 -1
- package/bin/wwwroot/assets/{confirm-morph-BLco2mdX.js → confirm-morph-DanmNnVF.js} +1 -1
- package/bin/wwwroot/assets/{download-CSRdoXEJ.js → download-DDp7Ezie.js} +1 -1
- package/bin/wwwroot/assets/{ellipsis-BI50R2Bc.js → ellipsis-D10W7mYw.js} +1 -1
- package/bin/wwwroot/assets/{external-link-Bzx5-ExU.js → external-link-DTLyxO14.js} +1 -1
- package/bin/wwwroot/assets/{folder-open-BxXgq-F4.js → folder-open-VpvxiCWo.js} +1 -1
- package/bin/wwwroot/assets/{index-Ck4Qlg9B.js → index-CN0EAD0q.js} +3 -3
- package/bin/wwwroot/assets/{log-out-DzOM9UKH.js → log-out-DOsFUSwe.js} +1 -1
- package/bin/wwwroot/assets/minus-CFFJg-m8.js +1 -0
- package/bin/wwwroot/assets/{overlays-BFrvqpMl.js → overlays-OPtjc9Yr.js} +1 -1
- package/bin/wwwroot/assets/{pencil-BMnmsFVj.js → pencil-Zf5QNEUX.js} +1 -1
- package/bin/wwwroot/assets/{power-CznSHqkx.js → power-B2lC52A0.js} +1 -1
- package/bin/wwwroot/assets/{radio-cards-DNOgi4px.js → radio-cards-DAFCv1Xc.js} +1 -1
- package/bin/wwwroot/assets/{rotate-ccw-Bhx85LK2.js → rotate-ccw-DwTwYkU2.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-BY9yO4Eq.js → sortable.esm-Btakc5-n.js} +1 -1
- package/bin/wwwroot/index.html +3 -3
- package/package.json +1 -1
- package/bin/wwwroot/assets/minus-CYKTpU0K.js +0 -1
package/bin/astra-server
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/bin/astra-server
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 53547968 bytes
|
|
4
|
+
sha256: 8c596e949bc4972ea573da91d84ad7c3044dcdf5b0f408f2e9c2d9e2960e233d
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{Et as e,Fa as t,G as n,Gt as r,H as i,Ht as a,Jt as o,K as s,Kt as c,Lr as l,Mr as u,Na as d,Or as f,Pa as p,Ra as m,Ut as h,Vt as g,Y as _,Yn as v,Yt as y,_ as b,_n as x,bt as S,c as C,ct as w,d as T,dt as ee,ei as E,fn as te,gt as ne,hr as re,jr as ie,m as D,mn as O,n as k,nr as ae,or as oe,ot as A,qt as se,r as j,s as ce,t as M,u as N,v as P,wr as le,xt as F,y as I}from"./alert-
|
|
1
|
+
import{Et as e,Fa as t,G as n,Gt as r,H as i,Ht as a,Jt as o,K as s,Kt as c,Lr as l,Mr as u,Na as d,Or as f,Pa as p,Ra as m,Ut as h,Vt as g,Y as _,Yn as v,Yt as y,_ as b,_n as x,bt as S,c as C,ct as w,d as T,dt as ee,ei as E,fn as te,gt as ne,hr as re,jr as ie,m as D,mn as O,n as k,nr as ae,or as oe,ot as A,qt as se,r as j,s as ce,t as M,u as N,v as P,wr as le,xt as F,y as I}from"./alert-BF0mCqUl.js";import{a as L,gt as R,ht as ue,i as de,o as z,r as B}from"./overlays-OPtjc9Yr.js";import{n as V}from"./ProvidersPage-D4CaD0A4.js";import{t as fe}from"./download-DDp7Ezie.js";import{t as pe}from"./external-link-DTLyxO14.js";import{t as me}from"./folder-open-VpvxiCWo.js";import{a as he,c as H,d as U,f as ge,i as W,l as G,n as _e,o as ve,p as K,r as ye,s as be,t as xe,u as Se}from"./sortable.esm-Btakc5-n.js";import{t as Ce}from"./rotate-ccw-DwTwYkU2.js";import{$ as we,B as Te,L as q,N as Ee,Q as De,R as Oe,S as J,V as ke,X as Ae,b as je,h as Me,v as Y,x as Ne,z as Pe}from"./index-CN0EAD0q.js";var Fe={name:`archive`,size:24,node:[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]};Fe.node;var Ie=F(Fe),Le={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Le.node;var Re=F(Le),ze={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};ze.node;var X=F(ze),Z=m(t(),1),Q=p(),Be=`astra claude`;function Ve(e){return e.reduce((e,t)=>({requests:e.requests+1,inputTokens:e.inputTokens+t.inputTokens,totalInputTokens:e.totalInputTokens+t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,outputTokens:e.outputTokens+t.outputTokens,failed:e.failed+ +(t.status===`error`),estimatedCostNanoUsd:e.estimatedCostNanoUsd+(t.estimatedCostNanoUsd??0)}),{requests:0,inputTokens:0,totalInputTokens:0,outputTokens:0,failed:0,estimatedCostNanoUsd:0})}var He=e=>e.status===`active`&&e.enabled;function Ue(e,t){let n=[e.name||e.id,e.email?`· ${e.email}`:null,e.plan?`· ${e.plan}`:null].filter(Boolean).join(` `);return He(e)?n:`${n} · ${t}`}function We({enabled:e,gatewayEnabled:t}){let{t:n}=w(),{toast:i}=z(),a=De(),o=r(e),s=f(),[l,u]=(0,Z.useState)(null),d=o.data?.mode??`gateway`,p=o.data?.accounts??[],m=o.data?.accountId??null??p.find(He)?.id??null,h=p.find(e=>e.id===m),g=d===`direct`,_=t&&(g||o.data!=null),v=g&&h?.telemetryEnabled===!0,y=c(v?h?.id:null,v),x=s.isPending,S=e=>s.mutate(e,{onError:e=>i(L(e),`error`)});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{title:n(`clients.claudeDirect.modeTitle`),footer:n(`clients.claudeDirect.modeFooter`),children:[(0,Q.jsx)(D,{label:n(`clients.claudeDirect.mode`),detail:n(g?`clients.claudeDirect.directDetail`:`clients.claudeDirect.gatewayDetail`),children:(0,Q.jsx)(b,{ariaLabel:n(`clients.claudeDirect.mode`),value:d,onChange:e=>{if(e===d||x||!o.data)return;let t=m??p.find(He)?.id??null;if(e===`direct`&&!t){i(n(`clients.claudeDirect.needAccountToast`),`error`);return}S({mode:e,accountId:t})},items:[{value:`gateway`,label:n(`clients.claudeDirect.gateway`)},{value:`direct`,label:n(`clients.claudeDirect.direct`)}]})}),(0,Q.jsx)(`p`,{className:`px-4 pb-2 text-[11px] text-[var(--text-muted)]`,children:n(`clients.claudeDirect.modeNote`)})]}),o.isLoading&&(0,Q.jsx)(P,{lines:3}),o.isError&&(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(M,{tone:`danger`,title:n(`clients.claudeDirect.loadFailed`),children:L(o.error)})}),_&&(0,Q.jsx)(`div`,{className:`mb-5`,children:(0,Q.jsx)(M,{tone:`warning`,title:n(`clients.claudeDirect.gatewayOnTitle`),children:n(`clients.claudeDirect.gatewayOnDetail`)})}),o.data&&(0,Q.jsx)(N,{title:n(`clients.claudeDirect.accountsTitle`),footer:n(`clients.claudeDirect.accountsFooter`),children:p.length===0?(0,Q.jsx)(C,{title:n(`clients.claudeDirect.noAccount`),detail:n(`clients.claudeDirect.noAccountDetail`),action:(0,Q.jsx)(j,{variant:`primary`,onClick:()=>a(`/providers`),children:n(`clients.claudeDirect.goProviders`)})}):(0,Q.jsx)(D,{label:n(`clients.claudeDirect.account`),children:(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:n(`clients.claudeDirect.account`),value:m,onChange:e=>{x||e===m||S({mode:d,accountId:e})},options:p.map(e=>({value:e.id,label:Ue(e,n(`clients.claudeDirect.accountDisabledSuffix`,{status:n(`providers.subscription.status.${e.status}`)})),disabled:!He(e)}))})})}),o.data&&g&&h&&(0,Q.jsx)(N,{title:n(`clients.claudeDirect.launchTitle`),footer:n(`clients.claudeDirect.launchNote`),children:(0,Q.jsx)(Ge,{command:Be,copied:l,onCopy:async e=>{await R.copy(e)&&(u(e),i(n(`common.copied`)))}})}),o.data&&g&&h&&(0,Q.jsxs)(N,{title:n(`clients.claudeDirect.statsTitle`),footer:n(`clients.claudeDirect.statsFooter`),children:[(0,Q.jsx)(D,{label:n(`clients.claudeDirect.statsConsent`),detail:n(`clients.claudeDirect.statsConsentDetail`),children:(0,Q.jsx)(I,{label:n(`clients.claudeDirect.statsConsent`),checked:h.telemetryEnabled,disabled:x,onChange:e=>{h&&!x&&S({mode:d,accountId:h.id,telemetryEnabled:e})}})}),v&&(0,Q.jsx)(Ke,{requests:y})]})]})}function Ge({command:e,copied:t,onCopy:n}){let{t:r}=w();return(0,Q.jsx)(D,{label:(0,Q.jsx)(`span`,{className:`font-mono text-[12px] break-all selectable`,children:e}),children:(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(ne,{className:`size-3`}),variant:t===e?`primary`:`glass`,"aria-label":r(`common.copy`),title:r(`common.copy`),onClick:()=>void n(e),children:r(t===e?`common.copied`:`common.copy`)})})}function Ke({requests:e}){let{t,locale:r}=w(),a=e.data??[],o=Ve(a);return e.isLoading?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:3})}):e.isError?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(M,{tone:`danger`,title:t(`clients.claudeDirect.statsFailed`),children:L(e.error)})}):a.length===0?(0,Q.jsx)(C,{icon:(0,Q.jsx)(ke,{className:`size-6`}),title:t(`clients.claudeDirect.statsEmpty`),detail:t(`clients.claudeDirect.statsEmptyDetail`)}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{label:t(`clients.claudeDirect.statsTotals`,{count:_(o.requests)}),detail:t(`clients.claudeDirect.statsInDetail`,{input:_(o.totalInputTokens),cache:_(a.reduce((e,t)=>e+t.cacheReadTokens,0)),output:_(o.outputTokens)})}),(0,Q.jsx)(D,{label:t(`clients.claudeDirect.statsCost`),detail:t(`clients.claudeDirect.statsCostDetail`),children:(0,Q.jsx)(`span`,{className:`num text-[13px]`,children:s(a.some(e=>e.estimatedCostNanoUsd!=null)?o.estimatedCostNanoUsd:null)})}),o.failed>0&&(0,Q.jsx)(D,{label:t(`clients.claudeDirect.statsFailedCount`,{count:_(o.failed)}),children:(0,Q.jsx)(k,{tone:`red`,children:t(`clients.claudeDirect.statusError`)})}),a.map(e=>(0,Q.jsx)(D,{label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.model}),e.status===`error`?(0,Q.jsx)(k,{tone:`red`,children:t(`clients.claudeDirect.statusError`)}):(0,Q.jsx)(k,{tone:`green`,children:t(`status.success`)})]}),detail:(0,Q.jsx)(`span`,{className:`num`,children:[i(e.occurredAtUtc,r),t(`clients.claudeDirect.tokensDetail`,{input:_(e.inputTokens),output:_(e.outputTokens)}),e.durationMs==null?null:n(e.durationMs),e.accountUuid??null].filter(Boolean).join(` · `)}),children:(0,Q.jsx)(`span`,{className:`num text-[13px]`,children:s(e.estimatedCostNanoUsd)})},e.id))]})}function qe({descriptors:e,values:t,onChange:n,enabled:r}){let{t:i}=w(),a=(e,r)=>{let i={...t};r===void 0||r===!1||r===0||r==="default"||r===``?delete i[e]:i[e]=r,n(i)};return(0,Q.jsx)(N,{title:i(`clients.options.title`),footer:i(r?`clients.options.footerEnabled`:`clients.options.footer`),children:e.map(e=>{let n=i(`clients.option.${e.key}`),r=i(`clients.option.${e.key}.hint`),o=t[e.key];return(0,Q.jsxs)(D,{label:n,detail:r,children:[e.type===`bool`&&(0,Q.jsx)(I,{label:n,checked:o===!0,onChange:t=>a(e.key,t)}),e.type===`int`&&(0,Q.jsx)(T,{className:`w-36`,mono:!0,inputMode:`numeric`,"aria-label":n,placeholder:i(`clients.options.unset`),value:typeof o==`number`?String(o):``,onChange:t=>{let n=Number.parseInt(t.target.value.replace(/\D/g,``),10);a(e.key,Number.isFinite(n)?n:void 0)}}),e.type===`enum`&&(0,Q.jsx)(B,{ariaLabel:n,value:typeof o==`string`?o:`default`,onChange:t=>a(e.key,t),options:(e.choices??[]).map(e=>({value:e,label:i(`clients.optionChoice.${e}`)})),className:`w-36`})]},e.key)})})}var Je=[`openai-chat`,`openai-responses`,`anthropic`,`gemini`],Ye=e=>typeof e==`string`&&Je.includes(e);function Xe(e){let t=e?.protocolOverrides,n={};if(!t||typeof t!=`object`)return n;for(let[e,r]of Object.entries(t))Ye(r)&&(n[e]=r);return n}function Ze(e){let t=e?.models;if(!t||typeof t!=`object`)return[];let n=[];for(let e of Object.values(t)){if(!e||typeof e!=`object`)continue;let t=e;typeof t.id==`string`&&t.id&&!n.some(e=>e.id===t.id)&&n.push({id:t.id,name:typeof t.name==`string`&&t.name?t.name:t.id,native:Array.isArray(t.protocols)?t.protocols.filter(Ye):[]})}return n}function Qe(e,t){let n=e.native.find(e=>t.includes(e));return n?{protocol:n,translated:!1}:{protocol:t[0],translated:!0}}var $e=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
|
|
2
2
|
`),et=`auto`,tt=e=>V.find(t=>t.value===e)?.label??e;function nt({models:e,supported:t,values:n,onChange:r,enabled:i}){let{t:a}=w(),o=(e,t)=>{let i={...n};t===et?delete i[e]:i[e]=t,r(i)};return(0,Q.jsx)(N,{title:a(`clients.protocols.title`),footer:a(i?`clients.protocols.footerEnabled`:`clients.protocols.footer`),children:e.map(e=>{let r=Qe(e,t),i=e.native.filter(e=>t.includes(e));return(0,Q.jsx)(D,{label:e.name,detail:i.length>0?a(`clients.protocols.native`,{protocols:i.map(tt).join(` · `)}):a(`clients.protocols.noNative`),children:(0,Q.jsx)(B,{ariaLabel:e.name,className:`w-60`,value:n[e.id]&&t.includes(n[e.id])?n[e.id]:et,onChange:t=>o(e.id,t),options:[{value:et,label:a(r.translated?`clients.protocols.autoTranslated`:`clients.protocols.auto`,{protocol:tt(r.protocol)})},...t.map(e=>({value:e,label:tt(e)}))]})},e.id)})})}function rt(e,t){let n=e?.options,r={};if(!n||typeof n!=`object`)return r;for(let e of t??[]){let t=n[e.key];e.type===`bool`&&t===!0?r[e.key]=!0:(e.type===`int`&&typeof t==`number`&&t>0||e.type===`enum`&&typeof t==`string`&&t!=="default"&&e.choices?.includes(t))&&(r[e.key]=t)}return r}var it=e=>Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`
|
|
3
|
-
`),at=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`];function ot(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of at){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var st=e=>at.map(t=>e[t]??``).join(`
|
|
3
|
+
`),at=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`];function ot(e){let t=e?.models,n={};if(!t||typeof t!=`object`)return n;for(let e of at){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var st=e=>at.map(t=>e[t]??``).join(`
|
|
4
4
|
`),ct=[`sonnet`,`opus`,`haiku`];function lt(e){let t=e?.roleMap,n={};if(!t||typeof t!=`object`)return n;for(let e of ct){let r=t[e];typeof r==`string`&&r.trim()&&(n[e]=r.trim())}return n}var $=e=>ct.map(t=>e[t]??``).join(`
|
|
5
5
|
`),ut=/(^|[-_.:/\s])(haiku|flash|mini|lite|nano|small|fast|air)($|[-_.:/\s])/i;function dt(e){if(e.length===0)return{};let t=t=>e.find(e=>e.toLowerCase().includes(t)),n=e.find(e=>!ut.test(e))??e[0],r=e.find(e=>ut.test(e))??n;return{sonnet:t(`sonnet`)??n,opus:t(`opus`)??t(`sonnet`)??n,haiku:t(`haiku`)??r}}function ft(){let{t:e}=w(),t=De(),{toast:n}=z(),r=we(),i=y(),a=h(),o=(0,Z.useMemo)(()=>new Map((i.data??[]).map(e=>[e.kind,e])),[i.data]),s=mt(i.data).includes(r.kind)?r.kind:`codex`,c=o.get(s);return(0,Z.useEffect)(()=>a.mutate(!1),[]),(0,Q.jsx)(Me,{title:e(`nav.clients`),subtitle:e(`clients.subtitle`),actions:(0,Q.jsx)(j,{icon:(0,Q.jsx)(Oe,{className:`size-3.5`}),loading:a.isPending,onClick:()=>a.mutate(!0,{onSuccess:t=>{let r=t.filter(e=>e.install?.updateAvailable&&e.install.blocker!==`shadowed`).length;n(r>0?e(`clients.updatesFound`,{count:r}):e(`clients.allUpToDate`),r>0?void 0:`success`)},onError:e=>n(L(e),`error`)}),children:e(`clients.checkUpdates`)}),children:(0,Q.jsx)(`div`,{className:`@container mx-auto max-w-[1200px]`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 @3xl:flex-row @3xl:items-start @3xl:gap-5`,children:[(0,Q.jsx)(vt,{clients:i.data,loading:i.isLoading,selected:s,onSelect:e=>t(`/clients/${e}`,{replace:!0})}),(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-[760px] min-w-0 flex-1`,children:[i.isLoading&&(0,Q.jsx)(P,{lines:4}),i.isError&&(0,Q.jsx)(M,{tone:`danger`,title:e(`common.error`),children:L(i.error)}),c&&(0,Q.jsx)(St,{client:c})]})]})})})}var pt=new Set([`opencode`,`pi`,`minimax-code`,`copilot-cli`,`vscode-copilot`,`crush`,`qwen-code`,`droid`,`kimi-code`,`zed`,`vscode-insiders`,`vscodium`,`omp`,`mimo-code`,`deepseek-harness`,`workbuddy`,`workbuddy-ai`,`nextcowork`,`paseo`,`zcode`,`tkcode`,`muse-code`,`codex`,`grok-build`,`hermes-agent`]);function mt(e){let t=(e??[]).filter(e=>!Y.includes(e.kind)).sort((e,t)=>e.name.localeCompare(t.name));return[...Y,...t.map(e=>e.kind)]}var ht=[`installed`,`notInstalled`,`comingSoon`];function gt(e){return e.availability===`coming_soon`?`comingSoon`:e.detection.installed||e.enabled||e.install?.installed?`installed`:`notInstalled`}function _t(e){return e.install?.version??e.detection.version??null}function vt({clients:e,loading:t,selected:n,onSelect:r}){let{t:i}=w(),a=new Map((e??[]).map(e=>[e.kind,e])),o=ht.map(t=>({group:t,items:mt(e).flatMap(e=>{let n=a.get(e);return n&>(n)===t?[n]:[]})})).filter(e=>e.items.length>0);return(0,Q.jsxs)(`nav`,{"aria-label":i(`nav.clients`),className:`card shrink-0 p-1.5 @3xl:sticky @3xl:top-0 @3xl:w-[232px]`,children:[t&&(0,Q.jsx)(P,{lines:6,className:`p-2`}),(0,Q.jsx)(`div`,{className:`flex gap-1 overflow-x-auto @3xl:flex-col @3xl:gap-0 @3xl:overflow-visible`,children:o.map(({group:e,items:t})=>(0,Q.jsxs)(`div`,{className:`contents @3xl:block`,children:[(0,Q.jsxs)(`h3`,{className:`hidden px-2.5 pt-2 pb-1 text-[11px] font-medium text-[var(--text-muted)] @3xl:block`,children:[i(`clients.group.${e}`),` · `,t.length]}),t.map(e=>(0,Q.jsx)(yt,{client:e,active:e.kind===n,onSelect:()=>r(e.kind)},e.kind))]},e))})]})}function yt({client:e,active:t,onSelect:n}){let{t:r}=w(),i=gt(e)!==`installed`,a=_t(e),o=e.install?.blocker===`shadowed`,s=e.install?.updateAvailable&&!o?e.install.latestVersion:null;return(0,Q.jsxs)(`button`,{type:`button`,"aria-label":J(e.kind,e.name),"aria-current":t?`page`:void 0,onClick:n,className:A(`flex shrink-0 items-center gap-2.5 rounded-[var(--radius-control)] px-2.5 py-1.5 text-left transition-colors @3xl:w-full`,t?`bg-[var(--accent-subtle)]`:`hover:bg-[var(--surface-muted)]`),children:[(0,Q.jsx)(`span`,{className:A(`inline-flex`,i&&!t&&`opacity-60`),children:(0,Q.jsx)(je,{kind:e.kind,size:24})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:A(`block truncate text-[13px] whitespace-nowrap`,t&&`font-medium`),children:J(e.kind,e.name)}),a&&(0,Q.jsxs)(`span`,{className:`hidden truncate text-[11px] text-[var(--text-secondary)] @3xl:block`,children:[a,s&&(0,Q.jsxs)(`span`,{className:`text-[var(--warning)]`,children:[` → `,s]})]})]}),e.install?.busy&&(0,Q.jsx)(bt,{}),s&&!e.install?.busy&&(0,Q.jsx)(k,{tone:`orange`,title:r(`clients.updateTo`,{version:s}),children:r(`clients.updateBadge`)}),o&&!e.install?.busy&&(0,Q.jsx)(k,{tone:`orange`,title:r(`clients.shadowed.title`,{version:e.install?.latestVersion??``}),children:r(`clients.shadowedBadge`)}),e.status===`drifted`?(0,Q.jsx)(`span`,{title:r(`clients.drifted`),"aria-label":r(`clients.drifted`),className:`inline-flex`,children:(0,Q.jsx)(ce,{tone:`orange`})}):e.enabled?(0,Q.jsx)(S,{className:`size-3.5 shrink-0 text-[var(--success)]`,strokeWidth:2.5,"aria-label":r(`clients.enabled`)}):null]})}function bt(){return(0,Q.jsx)(Te,{className:`size-3.5 shrink-0 animate-spin text-[var(--text-secondary)] motion-reduce:animate-none`,"aria-hidden":!0})}function xt(e,t){return e.availability===`coming_soon`?(0,Q.jsx)(k,{children:t(`clients.comingSoon`)}):e.status===`drifted`?(0,Q.jsx)(k,{tone:`orange`,children:t(`clients.drifted`)}):e.enabled?(0,Q.jsx)(k,{tone:`green`,children:t(`clients.enabled`)}):(0,Q.jsx)(k,{children:t(`clients.disabled`)})}function St({client:e}){let{t,locale:n}=w(),a=De(),{toast:s,confirm:c}=z(),l=oe(),u=ie(),d=te(),f=x(),p=re(),m=E(),h=o(e.kind,!!e.providerId),[g,_]=(0,Z.useState)(e.selectedModel??null),[v,y]=(0,Z.useState)(e.accountId??``),b=e.tokenId??`default`,[S,C]=(0,Z.useState)(b),T=(m.data??[]).filter(e=>e.enabled||e.id===b).map(e=>({value:e.id,label:e.enabled?e.name:t(`clients.tokenDisabled`,{name:e.name}),disabled:!e.enabled})),[ee,O]=(0,Z.useState)(!1),[A,se]=(0,Z.useState)(!1),[ce,le]=(0,Z.useState)(null),F=e.availability===`coming_soon`,I=J(e.kind,e.name),de=(l.data??[]).filter(e=>e.enabled),V=e.detection.configPaths[0],fe=de.find(t=>t.id===e.providerId),pe=fe?.authScheme===`oauth-subscription`||fe?.authScheme===`plugin`,he=ae(fe?.id,pe),H=e.kind===`claude-desktop`,U=e.kind===`claude-code`,ge=r(U),W=U&&ge.data?.mode===`direct`,G=lt(e.extras),[_e,ve]=(0,Z.useState)(G),K=ct.some(e=>_e[e]),ye=$(_e)!==$(G),be=ot(e.extras),[xe,Se]=(0,Z.useState)(be),Ce=(g??null)!==(e.selectedModel??null)||st(xe)!==st(be),we=U?at.filter(e=>e!==`ANTHROPIC_MODEL`):[],Te=U?e.enabled?t(`clients.modelSlotsFooterEnabled`):t(`clients.modelSlotsFooter`):e.enabled?t(`clients.modelFooterEnabled`):t(`clients.modelFooter`),q=e.options??[],Ee=rt(e.extras,q),[Oe,Ae]=(0,Z.useState)(Ee),Me=it(Oe)!==it(Ee),Y=e.protocols??[],Ne=Y.length>1?Ze(e.extras):[],Pe=Xe(e.extras),[Fe,Le]=(0,Z.useState)(Pe),Re=$e(Fe)!==$e(Pe),ze=H?{...e.extras,roleMap:_e}:U?{...e.extras,models:xe,options:Oe}:q.length>0||Y.length>1?{...e.extras,...q.length>0?{options:Oe}:{},...Y.length>1?{protocolOverrides:Fe}:{}}:void 0;(0,Z.useEffect)(()=>_(e.selectedModel??null),[e.kind,e.selectedModel]),(0,Z.useEffect)(()=>y(e.accountId??``),[e.kind,e.providerId,e.accountId]),(0,Z.useEffect)(()=>C(b),[e.kind,b]),(0,Z.useEffect)(()=>ve(lt(e.extras)),[e.kind,$(G)]);let X=(0,Z.useRef)({});(0,Z.useEffect)(()=>{if(!H||e.enabled||ct.some(e=>G[e]))return;let t=X.current,n=dt(h.data??[]);X.current=n,ve(e=>(!ct.some(t=>e[t])||$(e)===$(t))&&$(e)!==$(n)?n:e)},[e.kind,e.enabled,$(G),(h.data??[]).join(`
|
|
6
6
|
`)]),(0,Z.useEffect)(()=>Se(ot(e.extras)),[e.kind,st(be)]),(0,Z.useEffect)(()=>Ae(rt(e.extras,e.options)),[e.kind,it(Ee)]),(0,Z.useEffect)(()=>Le(Xe(e.extras)),[e.kind,$e(Pe)]);let Be=()=>{e.providerId&&u.mutate({kind:e.kind,providerId:e.providerId,accountId:v},{onSuccess:()=>s(t(`common.saved`),`success`),onError:e=>s(L(e),`error`)})},Ve=async()=>{await c({title:t(`clients.disableConfirm`,{name:I}),detail:t(`clients.disableDetail`),confirmLabel:t(`clients.disable`)})&&d.mutate(e.kind,{onSuccess:async n=>{if(n.drifted.length===0){s(t(`clients.disabledToast`,{name:I}),`success`);return}await c({title:t(`clients.driftTitle`),detail:t(`clients.driftDetail`,{keys:n.drifted.join(`, `)}),confirmLabel:t(`clients.forceRestore`),destructive:!0})&&f.mutate(e.kind,{onSuccess:()=>s(t(`clients.disabledToast`,{name:I}),`success`),onError:e=>s(L(e),`error`)})},onError:e=>s(L(e),`error`)})},He=async()=>{V&&(R.canOpenPaths?await R.openPath(ue(V)):await R.copy(V)&&s(t(`common.copied`)))};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{children:[(0,Q.jsxs)(D,{icon:(0,Q.jsx)(je,{kind:e.kind,size:36}),label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[15px] font-medium`,children:I}),W?(0,Q.jsx)(k,{children:t(`clients.claudeDirect.direct`)}):xt(e,t)]}),detail:F?e.availabilityReason??t(`clients.comingSoonDetail`):[gt(e)===`installed`?t(`clients.detected`,{version:_t(e)??``}):t(`clients.notDetected`),W?null:V].filter(Boolean).join(` · `),className:`py-3`,children:[!F&&(0,Q.jsx)(Ot,{client:e,onOpen:le}),W?(0,Q.jsx)(j,{variant:`primary`,onClick:()=>document.getElementById(At)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.claudeDirect.configure`)}):e.enabled?(0,Q.jsx)(j,{onClick:()=>void Ve(),loading:d.isPending,children:t(`clients.disableRestore`)}):(0,Q.jsx)(j,{variant:`primary`,disabled:F||!e.providerId||H&&!K,onClick:()=>O(!0),title:e.providerId?H&&!K?t(`clients.roleMapRequired`):void 0:t(`clients.pickProviderFirst`),children:t(`clients.enable`)})]}),!W&&e.appliedAt&&(0,Q.jsx)(D,{label:(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`clients.appliedAt`,{time:i(e.appliedAt,n)})})})]}),!F&&!e.enabled&&H&&e.providerId&&!K&&(0,Q.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Q.jsx)(M,{tone:`info`,className:`self-stretch`,title:t(`clients.roleMapHint`)}),(0,Q.jsx)(j,{onClick:()=>document.getElementById(jt)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:t(`clients.roleMapGoto`)})]}),(e.repairs?.length??0)>0&&(0,Q.jsxs)(`div`,{className:`mb-5 flex flex-col items-start gap-2`,children:[(0,Q.jsxs)(M,{tone:`danger`,className:`self-stretch`,title:t(`clients.repair.title`,{name:I}),children:[e.repairs?.map(e=>(0,Q.jsxs)(`span`,{className:`block break-all`,children:[(0,Q.jsx)(`span`,{className:`font-mono`,children:e.file}),` — `,t(`clients.repair.problem.${e.problem}`,{line:e.line})]},e.file)),(0,Q.jsx)(`span`,{className:`block`,children:t(`clients.repair.hint`)})]}),(0,Q.jsx)(j,{variant:`primary`,loading:p.isPending,onClick:()=>p.mutate(e.kind,{onSuccess:()=>s(t(`clients.repair.done`,{name:I}),`success`),onError:e=>s(L(e),`error`)}),children:t(`clients.repair.action`)})]}),!W&&e.warnings.length>0&&(0,Q.jsx)(`div`,{className:`mb-5 flex flex-col gap-2`,children:e.warnings.map((e,t)=>(0,Q.jsx)(M,{tone:`warning`,title:e},t))}),!W&&(0,Q.jsx)(Et,{client:e,providers:l.data??[],loading:l.isLoading,soon:F}),!W&&pe&&(0,Q.jsx)(N,{title:t(`clients.accountTitle`),footer:t(`clients.accountFooter`),children:he.isLoading?(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:2})}):(0,Q.jsxs)(D,{label:t(`clients.account`),children:[(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:t(`clients.account`),value:v,onChange:y,options:[{value:``,label:t(`clients.accountDefault`)},...(he.data??[]).map(e=>({value:e.id,label:(e.displayName||e.id)+(e.status===`active`?``:` · ${t(`providers.subscription.status.${e.status}`)}`)}))]}),v!==(e.accountId??``)&&(0,Q.jsx)(j,{size:`sm`,variant:`primary`,loading:u.isPending,onClick:Be,children:t(`common.apply`)})]})}),!F&&!W&&(0,Q.jsxs)(N,{title:t(`clients.tokenTitle`),footer:e.enabled?t(`clients.tokenFooterEnabled`):t(`clients.tokenFooter`),children:[(0,Q.jsxs)(D,{label:t(`clients.token`),children:[(0,Q.jsx)(B,{className:`max-w-[300px]`,ariaLabel:t(`clients.token`),value:S,onChange:C,options:T}),e.enabled&&S!==b&&(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})]}),(0,Q.jsx)(D,{icon:(0,Q.jsx)(ke,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.manageTokens`),onClick:()=>a(`/tokens`)})]}),!F&&!W&&e.providerId&&H&&(0,Q.jsx)(`div`,{id:jt,children:(0,Q.jsxs)(N,{title:t(`clients.roleMapTitle`),footer:e.enabled?t(`clients.roleMapFooterEnabled`):t(`clients.roleMapFooter`),children:[ct.map(e=>(0,Q.jsx)(D,{label:t(`clients.role.${e}`),children:(0,Q.jsx)(B,{ariaLabel:t(`clients.role.${e}`),value:_e[e]??``,onChange:t=>ve(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&ye&&(0,Q.jsx)(D,{label:K?``:(0,Q.jsx)(`span`,{className:`text-[12px] text-[var(--warning)]`,children:t(`clients.roleMapRequired`)}),children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,disabled:!K,onClick:()=>O(!0),children:t(`common.apply`)})})]})}),!F&&!W&&e.providerId&&!H&&(0,Q.jsxs)(N,{title:t(`clients.modelTitle`),footer:Te,children:[(0,Q.jsx)(D,{label:t(`clients.defaultModel`),children:(0,Q.jsx)(B,{value:g??``,onChange:e=>_(e||null),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})}),we.map(e=>(0,Q.jsx)(D,{label:t(`clients.modelSlot.${e}`),children:(0,Q.jsx)(B,{ariaLabel:t(`clients.modelSlot.${e}`),value:xe[e]??``,onChange:t=>Se(n=>({...n,[e]:t||void 0})),placeholder:t(`clients.modelPlaceholder`),options:[{value:``,label:t(`clients.modelUnset`)},...(h.data??[]).map(e=>({value:e,label:e}))],className:`max-w-[300px]`})},e)),e.enabled&&(U?Ce:(g??null)!==(e.selectedModel??null))&&(0,Q.jsx)(D,{label:``,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&!W&&q.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qe,{descriptors:q,values:Oe,onChange:Ae,enabled:e.enabled}),e.enabled&&Me&&(0,Q.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&Ne.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(nt,{models:Ne,supported:Y,values:Fe,onChange:Le,enabled:e.enabled}),e.enabled&&Re&&(0,Q.jsx)(`div`,{className:`-mt-3 mb-5 flex justify-end`,children:(0,Q.jsx)(j,{size:`sm`,variant:`primary`,onClick:()=>O(!0),children:t(`common.apply`)})})]}),!F&&e.install&&(0,Q.jsx)(Nt,{client:e,onShowLog:()=>le(`log`),onUninstall:()=>le(`uninstall`)}),U&&(0,Q.jsx)(`div`,{id:At,children:(0,Q.jsx)(We,{enabled:U,gatewayEnabled:e.enabled})}),!F&&!W&&(0,Q.jsxs)(N,{title:t(`clients.maintenance`),children:[V&&(0,Q.jsx)(D,{icon:R.canOpenPaths?(0,Q.jsx)(me,{className:`size-4 text-[var(--text-secondary)]`}):(0,Q.jsx)(ne,{className:`size-4 text-[var(--text-secondary)]`}),label:R.canOpenPaths?t(`clients.openConfigDir`):t(`clients.copyConfigPath`),detail:V,onClick:()=>void He()}),(0,Q.jsx)(D,{icon:(0,Q.jsx)(Ie,{className:`size-4 text-[var(--text-secondary)]`}),label:t(`clients.backups`),detail:t(`clients.backupsDetail`),onClick:()=>se(!0)})]}),(0,Q.jsx)(Ft,{open:ee,onOpenChange:O,client:e,model:g,extras:ze,tokenId:S}),(0,Q.jsx)(Rt,{open:A,onOpenChange:se,client:e}),(0,Q.jsx)(Pt,{mode:ce,onClose:()=>le(null),client:e})]})}var Ct={install:`clients.installTitle`,update:`clients.updateTitle`,uninstall:`clients.uninstallTitle`},wt={install:`clients.installedToast`,update:`clients.updatedToast`,uninstall:`clients.uninstalledToast`};function Tt(e,t){return[e.priceKey??e.templateId,t(`providers.modelCount`,{count:e.modelCount}),e.priceMultiplier===1?null:`×${e.priceMultiplier}`].filter(Boolean).join(` · `)}function Et({client:e,providers:t,loading:n,soon:r}){let{t:i}=w(),{toast:a}=z(),o=u(),s=(0,Z.useMemo)(()=>e.bindings??(e.providerId?[{providerId:e.providerId,accountId:e.accountId}]:[]),[e.bindings,e.providerId,e.accountId]),[c,l]=(0,Z.useState)(s);(0,Z.useEffect)(()=>l(s),[s]);let d=(0,Z.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]),f=c.flatMap(e=>{let t=d.get(e.providerId);return t?[{binding:e,provider:t}]:[]}),p=t.filter(e=>e.enabled&&!c.some(t=>t.providerId===e.id)),m=U(Se(H,{activationConstraint:{distance:4}}),Se(be,{coordinateGetter:ye})),h=r||o.isPending,g=(t,n)=>{let r=c;l(t),o.mutate({kind:e.kind,bindings:t},{onSuccess:()=>a(pt.has(e.kind)&&e.enabled?i(`clients.providersModelsSynced`,{client:J(e.kind,e.name)}):n),onError:e=>{l(r),a(L(e),`error`)}})},_=({active:e,over:t})=>{if(!t||e.id===t.id)return;let n=c.findIndex(t=>t.providerId===e.id),r=c.findIndex(e=>e.providerId===t.id);n<0||r<0||g(_e(c,n,r),i(`clients.providerOrderSaved`))},v=e=>g([...c,{providerId:e.id}],i(`clients.providerAdded`,{provider:e.name})),y=e=>g(c.filter(t=>t.providerId!==e.id),i(`clients.providerRemoved`,{provider:e.name})),b=p.map(e=>(0,Q.jsx)(D,{icon:(0,Q.jsx)(Ne,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24}),label:e.name,detail:Tt(e,i),onClick:h?void 0:()=>v(e),children:!r&&(0,Q.jsx)(Pe,{className:`size-4 text-[var(--text-secondary)]`,"aria-label":i(`common.add`)})},e.id));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(N,{title:i(`clients.providerTitle`),footer:i(`clients.providerFooter`),children:[n&&(0,Q.jsx)(`div`,{className:`p-4`,children:(0,Q.jsx)(P,{lines:2})}),!n&&f.length===0&&p.length===0&&(0,Q.jsx)(C,{title:i(`clients.noProviders`),detail:i(`clients.noProvidersDetail`),action:(0,Q.jsx)(Ae,{to:`/providers?new=1`,children:(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(Pe,{className:`size-3.5`}),children:i(`providers.add`)})})}),f.length>0&&(0,Q.jsx)(ve,{sensors:m,collisionDetection:G,onDragEnd:_,children:(0,Q.jsx)(xe,{items:f.map(e=>e.provider.id),strategy:he,children:f.map(({provider:e},t)=>(0,Q.jsx)(Dt,{provider:e,primary:t===0,disabled:h,onRemove:f.length>1?()=>y(e):void 0},e.id))})}),!n&&f.length===0&&b]}),f.length>0&&p.length>0&&(0,Q.jsx)(N,{title:i(`clients.moreProvidersTitle`),children:b})]})}function Dt({provider:e,primary:t,disabled:n,onRemove:r}){let{t:i}=w(),{attributes:a,listeners:o,setNodeRef:s,setActivatorNodeRef:c,transform:l,transition:u,isDragging:d}=W({id:e.id,disabled:n});return(0,Q.jsx)(`div`,{ref:s,style:{transform:ge.Transform.toString(l),transition:u},className:A(d&&`relative z-10 bg-[var(--surface)] shadow-lg`),children:(0,Q.jsx)(D,{icon:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{ref:c,type:`button`,"aria-label":i(`clients.dragToReorder`,{provider:e.name}),title:i(`clients.dragToReorder`,{provider:e.name}),className:`-ml-1 inline-flex cursor-grab touch-none text-[var(--text-muted)] hover:text-[var(--text-secondary)] active:cursor-grabbing disabled:cursor-default disabled:opacity-50`,...a,...o,children:(0,Q.jsx)(K,{className:`size-4`})}),(0,Q.jsx)(Ne,{name:e.name,icon:e.icon,colorKey:e.templateId,size:24})]}),label:(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.name}),t&&(0,Q.jsx)(k,{tone:`accent`,children:i(`clients.primaryProvider`)}),!e.enabled&&(0,Q.jsx)(k,{tone:`orange`,children:i(`clients.providerDisabledBadge`)})]}),detail:Tt(e,i),children:r&&(0,Q.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(ee,{className:`size-3.5`}),"aria-label":i(`clients.removeProvider`,{provider:e.name}),title:i(`clients.removeProvider`,{provider:e.name}),disabled:n,onClick:r})})})}function Ot({client:e,onOpen:t}){let{t:n}=w(),r=e.install;if(!r)return null;let i=r.needsAdmin?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-[var(--warning)]`,children:[(0,Q.jsx)(X,{className:`size-3`,"aria-hidden":!0}),n(`clients.admin.badge`)]}):null,a=r.needsAdmin?n(r.adminAvailable?`clients.admin.tip`:`clients.admin.tipManual`):void 0;return r.busy?(0,Q.jsx)(j,{icon:(0,Q.jsx)(bt,{}),onClick:()=>t(`log`),children:n(`clients.installRunning`)}):r.updateAvailable&&r.updateCommand&&r.latestVersion?(0,Q.jsxs)(j,{icon:(0,Q.jsx)(Re,{className:`size-3.5`}),title:a,onClick:()=>t(`update`),children:[n(`clients.updateTo`,{version:r.latestVersion}),i]}):r.updateAvailable&&r.blocker===`shadowed`?(0,Q.jsx)(j,{icon:(0,Q.jsx)(X,{className:`size-3.5`}),onClick:()=>document.getElementById(kt)?.scrollIntoView({behavior:`smooth`,block:`center`}),children:n(`clients.shadowedBadge`)}):!r.installed&&r.installCommand?(0,Q.jsxs)(j,{icon:(0,Q.jsx)(fe,{className:`size-3.5`}),title:a,onClick:()=>t(`install`),children:[n(`clients.install`),i]}):!r.installed&&r.method===`manual`?(0,Q.jsx)(j,{icon:(0,Q.jsx)(pe,{className:`size-3.5`}),onClick:()=>window.open(r.homepageUrl,`_blank`,`noreferrer`),children:n(`clients.download`)}):null}var kt=`client-shadowed-alert`,At=`claude-direct-panel`,jt=`client-role-map`;function Mt(e,t){return!e.installed||e.uninstallCommand?null:e.method===`npm`?t(`clients.uninstallExternal`,{path:e.executable??``}):e.method===`vscode-extension`?t(`clients.uninstallBuiltIn`):t(`clients.uninstallManual`)}function Nt({client:e,onShowLog:t,onUninstall:n}){let{t:r,locale:a}=w(),o=e.install,s=se(e.kind),c=(e,t=!1)=>(0,Q.jsx)(`span`,{className:A(`text-[13px] tabular-nums selectable`,t&&`text-[var(--text-secondary)]`),children:e}),l=o.blocker===`external-install`?r(`clients.blocker.external-install`,{path:o.executable??``}):o.blocker?r(`clients.blocker.${o.blocker}`):void 0,u=o.otherCopies??[],d=u.find(e=>e.newer);return(0,Q.jsxs)(Q.Fragment,{children:[d&&(0,Q.jsx)(`div`,{id:kt,className:`mb-3`,children:(0,Q.jsx)(M,{tone:`warning`,title:r(`clients.shadowed.title`,{version:d.version}),children:r(`clients.shadowed.detail`,{path:o.executable??``,version:o.version??``,other:d.path,dir:ue(d.path)})})}),!d&&o.notOnPath&&o.executable&&(0,Q.jsx)(`div`,{className:`mb-3`,children:(0,Q.jsx)(M,{tone:`warning`,title:r(`clients.notOnPath.title`),children:r(`clients.notOnPath.detail`,{dir:ue(o.executable)})})}),(0,Q.jsxs)(N,{title:r(`clients.versionTitle`),footer:l,children:[(0,Q.jsx)(D,{label:r(`clients.currentVersion`),detail:o.installed?o.executable:void 0,children:o.installed?c(o.version??r(`clients.versionUnknown`),!o.version):c(r(`clients.notInstalled`),!0)}),u.map(e=>(0,Q.jsxs)(D,{label:r(`clients.otherCopy`),detail:e.path,children:[e.newer&&(0,Q.jsx)(k,{tone:`orange`,children:r(`clients.otherCopyNewer`)}),c(e.version,!e.newer)]},e.path)),(o.method===`npm`||o.method===`script`)&&(0,Q.jsxs)(D,{label:r(`clients.latestVersion`),detail:o.latestError??(o.latestCheckedAt?r(`clients.checkedAt`,{time:i(o.latestCheckedAt,a)}):void 0),children:[o.updateAvailable&&(0,Q.jsx)(k,{tone:`orange`,children:r(`clients.updateBadge`)}),c(o.latestVersion??r(`clients.latestUnknown`),!o.latestVersion)]}),(0,Q.jsx)(D,{label:r(`clients.installMethod`),detail:r(`clients.method.${o.method}`,{package:o.package??``}),children:(0,Q.jsx)(j,{size:`sm`,variant:`plain`,icon:(0,Q.jsx)(pe,{className:`size-3`}),onClick:()=>window.open(o.homepageUrl,`_blank`,`noreferrer`),children:r(`clients.homepage`)})}),o.installed&&(0,Q.jsx)(D,{label:r(`clients.uninstall`),detail:o.uninstallCommand??Mt(o,r),children:o.uninstallCommand&&(0,Q.jsx)(j,{size:`sm`,variant:`destructive`,icon:(0,Q.jsx)(Ee,{className:`size-3`}),disabled:o.busy,onClick:n,children:r(`clients.uninstall`)})}),s.data&&(0,Q.jsx)(D,{icon:(0,Q.jsx)(q,{className:`size-4 text-[var(--text-secondary)]`}),label:r(`clients.installLog`),detail:`${s.data.command} · ${r(`clients.job.${s.data.state}`)}`,onClick:t})]})]})}function Pt({mode:t,onClose:n,client:r}){let{t:i}=w(),{toast:o}=z(),s=d(),c=t!==null,u=se(r.kind,c||!!r.install?.busy),f=l(),p=a(),[m,h]=(0,Z.useState)(!1),g=(0,Z.useRef)(null),_=(0,Z.useRef)(void 0),v=J(r.kind,r.name),y=r.install,b=t===`log`?null:t,x=b===`install`?y?.installCommand:b===`update`?y?.updateCommand:b===`uninstall`?y?.uninstallCommand:null,S=b===`uninstall`,T=u.data,ee=b!==null&&!m&&T?.state!==`running`,E=!!y?.needsAdmin,te=!!y?.adminAvailable,re=T?.state===`failed`&&T.hint===`permission-denied`&&!T.elevated&&te;(0,Z.useEffect)(()=>{c&&h(!1)},[c,t]),(0,Z.useEffect)(()=>{let t=T?.state;_.current===`running`&&t&&t!==`running`&&(s.invalidateQueries({queryKey:e.clients}),t===`succeeded`&&T.hint?o(i(`clients.notEffectiveToast`,{name:v})):t===`succeeded`&&o(i(wt[T.action],{name:v}),`success`)),_.current=t},[T?.state,T?.action,T?.hint,v,s,i,o]),(0,Z.useEffect)(()=>{let e=g.current;e&&(e.scrollTop=e.scrollHeight)},[T?.log.length]);let ie=(e,t)=>f.mutate({kind:r.kind,action:e,elevated:t},{onSuccess:()=>h(!0),onError:e=>o(L(e),`error`)}),D=async e=>{await R.copy(e)&&o(i(`common.copied`))},O=i(Ct[b??T?.action??`install`],{name:v}),k={running:`info`,succeeded:`success`,failed:`danger`,cancelled:`warning`},ae=`rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[12px] break-all whitespace-pre-wrap selectable`,oe=y?.adminFixCommand?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-secondary)]`,children:i(`clients.admin.fixTip`)}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`pre`,{className:A(ae,`min-w-0 flex-1`),children:y.adminFixCommand}),(0,Q.jsx)(j,{size:`sm`,icon:(0,Q.jsx)(ne,{className:`size-3`}),"aria-label":i(`common.copy`),onClick:()=>void D(y.adminFixCommand)})]})]}):null;return(0,Q.jsx)(de,{open:c,onOpenChange:e=>!e&&n(),width:620,title:O,description:ee?i(S?`clients.uninstallRunDetail`:`clients.installRunDetail`):void 0,footer:ee?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:n,children:i(`common.cancel`)}),E&&!te?(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(ne,{className:`size-3.5`}),disabled:!x,onClick:()=>void D(`sudo ${x}`),children:i(`clients.admin.copyCommand`)}):(0,Q.jsx)(j,{variant:S?`destructive`:`primary`,icon:E?(0,Q.jsx)(X,{className:`size-3.5`}):void 0,disabled:!x,loading:f.isPending,onClick:()=>b&&ie(b,E),children:i(E?`clients.admin.start`:S?`clients.uninstall`:`clients.installStart`)})]}):T?.state===`running`?(0,Q.jsxs)(Q.Fragment,{children:[!T.elevated&&(0,Q.jsx)(j,{variant:`destructive`,loading:p.isPending,onClick:()=>p.mutate(r.kind,{onError:e=>o(L(e),`error`)}),children:i(`clients.installStop`)}),(0,Q.jsx)(j,{onClick:n,children:i(`common.close`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{onClick:n,children:i(`common.done`)}),re&&(0,Q.jsx)(j,{variant:`primary`,icon:(0,Q.jsx)(X,{className:`size-3.5`}),loading:f.isPending,onClick:()=>ie(T.action,!0),children:i(`clients.admin.retry`)})]}),children:ee?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[S&&r.enabled&&(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.uninstallRestoreTitle`),children:i(`clients.uninstallRestoreDetail`,{name:v})}),E&&(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.admin.title`),children:i(te?`clients.admin.prompt`:`clients.admin.manual`)}),x?(0,Q.jsx)(`pre`,{className:ae,children:E?`sudo ${x}`:x}):(0,Q.jsx)(M,{tone:`warning`,title:i(`clients.installUnavailable`)}),S?(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.uninstallKeepsData`)}):y?.method===`npm`&&(0,Q.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`clients.installNpmNote`)}),E&&oe]}):T?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(M,{tone:T.state===`succeeded`&&T.hint?`warning`:k[T.state],title:i(T.state===`succeeded`&&T.hint?`clients.job.notEffective`:`clients.job.${T.state}`),children:T.state===`running`&&T.elevated?i(`clients.admin.running`):T.hint?i(`clients.hint.${T.hint}`)+(re?i(`clients.admin.retryHint`):``):void 0}),(0,Q.jsx)(`pre`,{ref:g,className:`scroll max-h-[340px] min-h-[160px] rounded-[var(--radius-control)] border border-[var(--border)] bg-[var(--surface-muted)] px-3 py-2 font-mono text-[11px] leading-relaxed break-all whitespace-pre-wrap selectable`,children:T.log.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ct as e,Fa as t,G as n,H as r,J as i,Pa as a,Q as o,Ra as s,St as c,Tt as l,Y as u,_ as d,ct as f,n as p,q as m,r as h,t as g,wt as _}from"./alert-CMMOyMsp.js";import{A as v,_ as y,k as b}from"./index-Ck4Qlg9B.js";var x=s(t(),1),S=a(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t}=f(),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(``),[l,u]=(0,x.useState)(null),[d,p]=(0,x.useState)(!1),m=(0,x.useCallback)(async n=>{let r=n.trim();if(r){p(!0),u(null);try{a(await e(r)),s(r),T(r)}catch(e){a(null),T(null),u(e instanceof c&&e.status===401?t(`key.invalid`):t(`key.error`,{error:e.message}))}finally{p(!1)}}},[t]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(r(t),m(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(v,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:t(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:t(`key.subtitle`)})]})]}),!i&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m(n)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(b,{label:t(`key.title`),placeholder:t(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:n,"aria-invalid":l?!0:void 0,onChange:e=>r(e.target.value)}),l&&(0,S.jsx)(g,{tone:`danger`,title:l}),(0,S.jsx)(h,{type:`submit`,variant:`primary`,loading:d,disabled:!n.trim(),children:t(`key.submit`)})]}),i&&(0,S.jsx)(D,{info:i,apiKey:o,onForget:()=>{T(null),a(null),r(``)}})]})})}function D({info:e,apiKey:t,onForget:n}){let{t:i,locale:a}=f(),[s,c]=(0,x.useState)(`overview`),l=e.allowedClients==null?i(`key.clientsAny`):e.allowedClients.length===0?i(`key.directOnly`):e.allowedClients.map(e=>y[e]?.name??e).join(`, `),m=[[i(`key.today`),e.usage.today],[i(`key.week`),e.usage.week],[i(`key.month`),e.usage.month],[i(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(p,{tone:`orange`,children:i(`key.disabled`)}),(0,S.jsx)(h,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:n,children:i(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[i(`key.clients`),`: `,l,` · `,i(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(d,{ariaLabel:i(`key.title`),value:s,onChange:c,items:[{value:`overview`,label:i(`key.tab.overview`)},{value:`stats`,label:i(`key.tab.stats`)},{value:`requests`,label:i(`key.tab.requests`)}]})]}),s===`stats`&&(0,S.jsx)(k,{apiKey:t}),s===`requests`&&(0,S.jsx)(M,{apiKey:t}),s===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`key.unlimited`)}),(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.limits.map(e=>{let t=t=>e.metric===`cost`?o(t):u(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),s=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,c=`${i(`tokens.period.${e.period}`)} · ${i(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:c}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":c,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,background:s}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?i(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?i(`key.resets`,{time:r(e.resetsAt,a)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:i(`key.rpm`,{used:e.rpm.used,limit:e.rpm.limit})})]}),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.usage`)}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:m.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:o(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:i(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":i(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${o(e.costUsd)} · ${u(e.requests)} ${i(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=f(),[r,i]=(0,x.useState)(`7d`),[a,s]=(0,x.useState)(null),[c,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return h(null),l(e,r).then(e=>n&&s(e),e=>n&&h(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,r,t]);let _=a?.summary,v=Math.max(...(a?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(d,{ariaLabel:t(`overview.range`),value:r,onChange:i,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),c&&(0,S.jsx)(g,{tone:`danger`,title:c}),!a||!_?!c&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:u(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?m(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:o(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:n(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:a.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${u(e.requests)} ${t(`key.requests`)} · ${o(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:a.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:a.clients.map(e=>({name:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),a.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:a.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(p,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,u(e.count)]})},e.category))})]}),a.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:a.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:n}=f();return t.length===0?null:(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`caption`,{className:`mb-1 text-left text-[12px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.cost`)})]})}),(0,S.jsx)(`tbody`,{children:t.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`max-w-[240px] truncate py-1 text-left font-medium text-[var(--text-secondary)]`,children:e.name}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?m(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:o(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:a}=f(),[s,c]=(0,x.useState)(`all`),[l,m]=(0,x.useState)([]),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await _(e,{before:n,status:s===`failed`?N:void 0});m(e=>n?[...e,...t.items]:t.items),b(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(d,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(g,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:l.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:r(e.time,a),children:i(e.time,a)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(p,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(p,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[u(e.inputTokens,!0),` / `,u(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:o(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[n(e.ttftMs),` / `,n(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(h,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
|
|
1
|
+
import{Ct as e,Fa as t,G as n,H as r,J as i,Pa as a,Q as o,Ra as s,St as c,Tt as l,Y as u,_ as d,ct as f,n as p,q as m,r as h,t as g,wt as _}from"./alert-BF0mCqUl.js";import{A as v,_ as y,k as b}from"./index-CN0EAD0q.js";var x=s(t(),1),S=a(),C=`astra.keyLookup`;function w(){try{return sessionStorage.getItem(C)??``}catch{return``}}function T(e){try{e?sessionStorage.setItem(C,e):sessionStorage.removeItem(C)}catch{}}function E(){let{t}=f(),[n,r]=(0,x.useState)(``),[i,a]=(0,x.useState)(null),[o,s]=(0,x.useState)(``),[l,u]=(0,x.useState)(null),[d,p]=(0,x.useState)(!1),m=(0,x.useCallback)(async n=>{let r=n.trim();if(r){p(!0),u(null);try{a(await e(r)),s(r),T(r)}catch(e){a(null),T(null),u(e instanceof c&&e.status===401?t(`key.invalid`):t(`key.error`,{error:e.message}))}finally{p(!1)}}},[t]);return(0,x.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`key`);e&&window.history.replaceState(null,``,window.location.pathname);let t=e??w();t&&(r(t),m(t))},[]),(0,S.jsx)(`div`,{className:`wallpaper flex min-h-full justify-center overflow-y-auto p-4 sm:items-start sm:py-12`,children:(0,S.jsxs)(`div`,{className:`flex w-full max-w-[720px] flex-col gap-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(v,{className:`size-10 rounded-[12px]`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-[17px] font-medium`,children:t(`key.title`)}),(0,S.jsx)(`p`,{className:`text-[13px] text-[var(--text-secondary)]`,children:t(`key.subtitle`)})]})]}),!i&&(0,S.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m(n)},className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(b,{label:t(`key.title`),placeholder:t(`key.placeholder`),autoFocus:!0,autoComplete:`off`,value:n,"aria-invalid":l?!0:void 0,onChange:e=>r(e.target.value)}),l&&(0,S.jsx)(g,{tone:`danger`,title:l}),(0,S.jsx)(h,{type:`submit`,variant:`primary`,loading:d,disabled:!n.trim(),children:t(`key.submit`)})]}),i&&(0,S.jsx)(D,{info:i,apiKey:o,onForget:()=>{T(null),a(null),r(``)}})]})})}function D({info:e,apiKey:t,onForget:n}){let{t:i,locale:a}=f(),[s,c]=(0,x.useState)(`overview`),l=e.allowedClients==null?i(`key.clientsAny`):e.allowedClients.length===0?i(`key.directOnly`):e.allowedClients.map(e=>y[e]?.name??e).join(`, `),m=[[i(`key.today`),e.usage.today],[i(`key.week`),e.usage.week],[i(`key.month`),e.usage.month],[i(`key.total`),e.usage.total]],g=Math.max(...e.daily.map(e=>e.costUsd),0);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,S.jsx)(`h2`,{className:`text-[15px] font-medium`,children:e.name}),(0,S.jsx)(`code`,{className:`font-mono text-[12px] text-[var(--text-secondary)]`,children:e.keyPrefix}),!e.enabled&&(0,S.jsx)(p,{tone:`orange`,children:i(`key.disabled`)}),(0,S.jsx)(h,{size:`sm`,variant:`plain`,className:`ml-auto`,onClick:n,children:i(`key.forget`)})]}),(0,S.jsxs)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:[i(`key.clients`),`: `,l,` · `,i(`key.timeZone`,{zone:e.timeZone})]}),(0,S.jsx)(d,{ariaLabel:i(`key.title`),value:s,onChange:c,items:[{value:`overview`,label:i(`key.tab.overview`)},{value:`stats`,label:i(`key.tab.stats`)},{value:`requests`,label:i(`key.tab.requests`)}]})]}),s===`stats`&&(0,S.jsx)(k,{apiKey:t}),s===`requests`&&(0,S.jsx)(M,{apiKey:t}),s===`overview`&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.limits`)}),e.limits.length===0&&e.rpm==null&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`key.unlimited`)}),(0,S.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.limits.map(e=>{let t=t=>e.metric===`cost`?o(t):u(t,!0),n=Math.max(0,Math.min(100,Math.round(e.usedPercent))),s=n>=90?`var(--danger)`:n>=70?`var(--warning)`:`var(--accent)`,c=`${i(`tokens.period.${e.period}`)} · ${i(`tokens.metric.${e.metric}`)}`;return(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[12px]`,children:[(0,S.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:c}),(0,S.jsxs)(`span`,{className:`num`,children:[t(e.used),` / `,t(e.limit)]})]}),(0,S.jsx)(`div`,{role:`progressbar`,"aria-label":c,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${n}%`,background:s}})}),(0,S.jsxs)(`div`,{className:`mt-1 text-[11px] text-[var(--text-muted)]`,children:[e.exhausted?i(`key.exhausted`):``,e.exhausted&&e.resetsAt?` · `:``,e.resetsAt?i(`key.resets`,{time:r(e.resetsAt,a)}):``]})]},`${e.metric}:${e.period}`)})}),e.rpm&&(0,S.jsx)(`p`,{className:`num text-[12px] text-[var(--text-secondary)]`,children:i(`key.rpm`,{used:e.rpm.used,limit:e.rpm.limit})})]}),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(`h3`,{className:`text-[13px] font-medium`,children:i(`key.usage`)}),(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:i(`key.tokens`)})]})}),(0,S.jsx)(`tbody`,{children:m.map(([e,t])=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`py-1 text-left font-medium text-[var(--text-secondary)]`,children:e}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:o(t.costUsd)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(t.inputTokens+t.outputTokens,!0)})]},e))})]})}),(0,S.jsx)(`h4`,{className:`mt-2 text-[12px] text-[var(--text-muted)]`,children:i(`key.daily`)}),(0,S.jsx)(`div`,{className:`flex h-24 items-end gap-[2px]`,role:`list`,"aria-label":i(`key.daily`),children:e.daily.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.day} · ${o(e.costUsd)} · ${u(e.requests)} ${i(`key.requests`)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${g>0?Math.max(2,e.costUsd/g*100):2}%`,opacity:e.costUsd>0?1:.25}},e.day))})]})]})]})}var O=[`today`,`7d`,`30d`,`90d`];function k({apiKey:e}){let{t}=f(),[r,i]=(0,x.useState)(`7d`),[a,s]=(0,x.useState)(null),[c,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{let n=!0;return h(null),l(e,r).then(e=>n&&s(e),e=>n&&h(t(`key.error`,{error:e.message}))),()=>{n=!1}},[e,r,t]);let _=a?.summary,v=Math.max(...(a?.series??[]).map(e=>e.requests),0);return(0,S.jsxs)(`section`,{className:`card flex flex-col gap-4 p-5`,children:[(0,S.jsx)(d,{ariaLabel:t(`overview.range`),value:r,onChange:i,items:O.map(e=>({value:e,label:t(`range.${e}`)}))}),c&&(0,S.jsx)(g,{tone:`danger`,title:c}),!a||!_?!c&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:`…`}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,S.jsx)(A,{label:t(`key.stats.requests`),value:u(_.requests)}),(0,S.jsx)(A,{label:t(`key.stats.successRate`),value:_.requests?m(_.successRate):`—`}),(0,S.jsx)(A,{label:t(`key.cost`),value:o(_.costUsd)}),(0,S.jsx)(A,{label:t(`key.stats.avgTtft`),value:n(_.avgTtftMs)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.trend`)}),(0,S.jsx)(`div`,{className:`flex h-20 items-end gap-[2px]`,role:`list`,"aria-label":t(`key.stats.trend`),children:a.series.map(e=>(0,S.jsx)(`div`,{role:`listitem`,title:`${e.bucket} · ${u(e.requests)} ${t(`key.requests`)} · ${o(e.costUsd)}`,className:`flex-1 rounded-t-[2px] bg-[var(--accent)]`,style:{height:`${v>0?Math.max(2,e.requests/v*100):2}%`}},e.bucket))})]}),(0,S.jsx)(j,{title:t(`key.stats.byModel`),rows:a.models.map(e=>({name:e.model??`—`,...e}))}),(0,S.jsx)(j,{title:t(`key.stats.byClient`),rows:a.clients.map(e=>({name:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`),...e}))}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h4`,{className:`mb-2 text-[12px] text-[var(--text-muted)]`,children:t(`key.stats.errors`)}),a.errors.length===0?(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:t(`key.stats.noErrors`)}):(0,S.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:a.errors.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(p,{tone:`orange`,children:[t(`key.category.${e.category}`),` · `,u(e.count)]})},e.category))})]}),a.retentionDays!=null&&(0,S.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:t(`key.stats.retention`,{days:a.retentionDays})})]})]})}function A({label:e,value:t}){return(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`truncate text-[11px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`div`,{className:`num truncate text-[17px] font-semibold`,children:t})]})}function j({title:e,rows:t}){let{t:n}=f();return t.length===0?null:(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`caption`,{className:`mb-1 text-left text-[12px] text-[var(--text-muted)]`,children:e}),(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.requests`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.stats.successRate`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:n(`key.cost`)})]})}),(0,S.jsx)(`tbody`,{children:t.map(e=>(0,S.jsxs)(`tr`,{children:[(0,S.jsx)(`th`,{scope:`row`,className:`max-w-[240px] truncate py-1 text-left font-medium text-[var(--text-secondary)]`,children:e.name}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.requests)}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:e.requests?m(e.successRequests/e.requests):`—`}),(0,S.jsx)(`td`,{className:`num py-1 text-right`,children:u(e.inputTokens+e.outputTokens,!0)}),(0,S.jsx)(`td`,{className:`num py-1 text-right font-semibold`,children:o(e.costUsd)})]},e.name))})]})})}function M({apiKey:e}){let{t,locale:a}=f(),[s,c]=(0,x.useState)(`all`),[l,m]=(0,x.useState)([]),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(null),D=(0,x.useCallback)(async n=>{w(!0),E(null);try{let t=await _(e,{before:n,status:s===`failed`?N:void 0});m(e=>n?[...e,...t.items]:t.items),b(t.nextBefore??null)}catch(e){E(t(`key.error`,{error:e.message}))}finally{w(!1)}},[e,s,t]);return(0,x.useEffect)(()=>{D(null)},[D]),(0,S.jsxs)(`section`,{className:`card flex flex-col gap-3 p-5`,children:[(0,S.jsx)(d,{ariaLabel:t(`key.requests.status`),value:s,onChange:c,items:[{value:`all`,label:t(`key.requests.all`)},{value:`failed`,label:t(`key.requests.failed`)}]}),T&&(0,S.jsx)(g,{tone:`danger`,title:T}),l.length===0&&!C&&!T&&(0,S.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`key.requests.empty`)}),l.length>0&&(0,S.jsx)(`div`,{className:`overflow-x-auto`,children:(0,S.jsxs)(`table`,{className:`w-full text-[12px]`,children:[(0,S.jsx)(`thead`,{children:(0,S.jsxs)(`tr`,{className:`text-[var(--text-muted)]`,children:[(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.time`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.model`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.client`)}),(0,S.jsx)(`th`,{className:`py-1 text-left font-normal`,children:t(`key.requests.status`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.tokens`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.cost`)}),(0,S.jsx)(`th`,{className:`py-1 text-right font-normal`,children:t(`key.requests.latency`)})]})}),(0,S.jsx)(`tbody`,{children:l.map(e=>(0,S.jsxs)(`tr`,{className:`border-t border-[var(--border-subtle)]`,children:[(0,S.jsx)(`td`,{className:`py-1.5 whitespace-nowrap text-[var(--text-secondary)]`,title:r(e.time,a),children:i(e.time,a)}),(0,S.jsx)(`td`,{className:`max-w-[200px] truncate py-1.5 font-mono`,title:e.model??``,children:e.model??`—`}),(0,S.jsx)(`td`,{className:`py-1.5 text-[var(--text-secondary)]`,children:e.client?y[e.client]?.name??e.client:t(`key.stats.direct`)}),(0,S.jsx)(`td`,{className:`py-1.5`,children:e.errorCategory?(0,S.jsx)(p,{tone:`orange`,title:e.httpStatus?`HTTP ${e.httpStatus}`:void 0,children:t(`key.category.${e.errorCategory}`)}):(0,S.jsx)(p,{tone:`green`,children:t(`key.requests.success`)})}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right`,children:[u(e.inputTokens,!0),` / `,u(e.outputTokens,!0)]}),(0,S.jsx)(`td`,{className:`num py-1.5 text-right font-semibold`,children:o(e.costUsd)}),(0,S.jsxs)(`td`,{className:`num py-1.5 text-right text-[var(--text-secondary)]`,children:[n(e.ttftMs),` / `,n(e.totalMs)]})]},e.id))})]})}),v&&(0,S.jsx)(`div`,{children:(0,S.jsx)(h,{size:`sm`,loading:C,onClick:()=>void D(v),children:t(`key.requests.more`)})})]})}var N=`upstream_error,gateway_error,client_cancelled,blocked`;export{E as KeyPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ci as e,Fa as t,H as n,Mn as r,Pa as i,Ra as a,Xn as o,an as s,ct as c,d as l,g as u,in as d,l as f,m as p,n as m,p as h,r as g,rt as _,t as v,u as y,ui as b,v as x,xr as S,y as ee}from"./alert-
|
|
1
|
+
import{Ci as e,Fa as t,H as n,Mn as r,Pa as i,Ra as a,Xn as o,an as s,ct as c,d as l,g as u,in as d,l as f,m as p,n as m,p as h,r as g,rt as _,t as v,u as y,ui as b,v as x,xr as S,y as ee}from"./alert-BF0mCqUl.js";import{a as C,i as w,o as T,r as E}from"./overlays-OPtjc9Yr.js";import{t as D}from"./arrow-left-D_GXSlab.js";import{t as O}from"./pencil-Zf5QNEUX.js";import{t as k}from"./rotate-ccw-DwTwYkU2.js";import{$ as A,N as j,Q as M,X as te,h as N,i as ne,o as P,z as F}from"./index-CN0EAD0q.js";import{t as I}from"./checkbox-j5bCl2a6.js";import{t as L}from"./confirm-morph-DanmNnVF.js";var R=a(t(),1),z=i(),B=[{key:`vision`,label:`cap.vision`},{key:`tools`,label:`cap.tools`},{key:`reasoning`,label:`cap.reasoning`},{key:`promptCache`,label:`cap.promptCache`},{key:`audio`,label:`cap.audio`},{key:`pdf`,label:`cap.pdf`},{key:`structuredOutput`,label:`cap.structuredOutput`}];function V(e){return{displayName:e.displayName,vendor:e.vendor,family:e.family??null,aliases:e.aliases,contextWindow:e.contextWindow??null,maxOutputTokens:e.maxOutputTokens??null,capabilities:e.capabilities,pricing:e.pricing??null,enabled:e.enabled}}function H(){let{t:e,locale:t}=c(),i=M(),{id:a=``}=A(),o=decodeURIComponent(a),s=r(o),f=b(o),w=S(o),E=d(),{toast:O}=T(),j=(0,R.useMemo)(()=>s.data?V(s.data):null,[s.data]),[F,L]=(0,R.useState)(j),[H,G]=(0,R.useState)(``);(0,R.useEffect)(()=>{L(j),G(j?.aliases?.join(`, `)??``)},[j]);let q=(0,z.jsx)(g,{variant:`glass`,icon:(0,z.jsx)(D,{className:`size-4`}),"aria-label":e(`common.back`),onClick:()=>i(`/models`)});if(s.isError)return(0,z.jsx)(N,{title:e(`nav.models`),leading:q,children:(0,z.jsx)(v,{tone:`danger`,title:e(`common.error`),children:C(s.error)})});let J=s.data;if(!J||!F)return(0,z.jsx)(N,{title:``,leading:q,children:(0,z.jsx)(x,{lines:5,className:`mx-auto max-w-[1100px]`})});let Y=e=>L(t=>({...t,...e})),X={...F,aliases:H.split(/[,\n]/).map(e=>e.trim()).filter(Boolean)},Z=JSON.stringify(X)!==JSON.stringify(j),re=new Set(J.userModifiedFields),Q=J.source===`seed`,ie=()=>f.mutate(X,{onSuccess:()=>O(e(`common.saved`),`success`),onError:e=>O(C(e),`error`)}),$=t=>re.has(t)?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,z.jsx)(m,{tone:`orange`,children:e(`models.modified`)}),Q&&(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(k,{className:`size-3`}),title:e(`models.resetField`),"aria-label":e(`models.resetField`),onClick:()=>w.mutate(t,{onSuccess:()=>O(e(`models.fieldReset`)),onError:e=>O(C(e),`error`)})})]}):null;return(0,z.jsx)(N,{title:J.displayName,subtitle:`${J.id} · ${e(`models.source.${J.source}`)} · ${e(`models.updated`,{time:n(J.updatedAt,t)})}`,leading:q,actions:(0,z.jsxs)(z.Fragment,{children:[J.source===`user`&&(0,z.jsx)(K,{label:e(`common.delete`),prompt:e(`models.deleteConfirm`,{id:J.id}),onConfirm:async()=>{await E.mutateAsync(J.id),i(`/models`)}}),Z&&(0,z.jsx)(g,{onClick:()=>{L(j),G(j?.aliases?.join(`, `)??``)},children:e(`common.revert`)}),(0,z.jsx)(g,{variant:`primary`,disabled:!Z,loading:f.isPending,onClick:ie,children:e(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`mx-auto grid max-w-[1100px] gap-x-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(y,{title:e(`models.section.basic`),footer:Q?e(`models.modifiedFooter`):void 0,children:[(0,z.jsx)(U,{label:e(`models.field.displayName`),marker:$(`displayName`),children:(0,z.jsx)(l,{className:`w-60`,"aria-label":e(`models.field.displayName`),value:F.displayName,onChange:e=>Y({displayName:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.vendor`),children:(0,z.jsx)(l,{className:`w-60`,"aria-label":e(`models.field.vendor`),value:F.vendor,onChange:e=>Y({vendor:e.target.value})})}),(0,z.jsx)(U,{label:e(`models.field.family`),marker:$(`family`),children:(0,z.jsx)(l,{className:`w-60`,"aria-label":e(`models.field.family`),value:F.family??``,onChange:e=>Y({family:e.target.value||null})})}),(0,z.jsx)(U,{label:e(`models.field.aliases`),marker:$(`aliases`),children:(0,z.jsx)(l,{className:`w-60 font-mono`,"aria-label":e(`models.field.aliases`),value:H,onChange:e=>G(e.target.value),placeholder:`a, b, c`})}),(0,z.jsx)(U,{label:e(`models.field.contextWindow`),marker:$(`contextWindow`),children:(0,z.jsx)(h,{className:`w-36`,label:e(`models.field.contextWindow`),value:F.contextWindow,onChange:e=>Y({contextWindow:e})})}),(0,z.jsx)(U,{label:e(`models.field.maxOutputTokens`),marker:$(`maxOutputTokens`),children:(0,z.jsx)(h,{className:`w-36`,label:e(`models.field.maxOutputTokens`),value:F.maxOutputTokens,onChange:e=>Y({maxOutputTokens:e})})}),(0,z.jsx)(U,{label:e(`common.enabled`),children:(0,z.jsx)(ee,{checked:F.enabled??!0,label:e(`common.enabled`),onChange:e=>Y({enabled:e})})})]}),(0,z.jsx)(y,{title:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e(`models.section.capabilities`),` `,$(`capabilities`)]}),children:(0,z.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 px-4 py-4`,children:B.map(t=>(0,z.jsx)(I,{label:e(t.label),checked:!!F.capabilities?.[t.key],onCheckedChange:e=>Y({capabilities:{...F.capabilities,[t.key]:e===!0}})},t.key))})}),(0,z.jsx)(W,{model:J}),J.providerOverrides.length>0&&(0,z.jsx)(y,{title:e(`models.section.overrides`),footer:e(`models.overridesFooter`),children:J.providerOverrides.map(e=>(0,z.jsx)(p,{label:(0,z.jsx)(te,{className:`text-[var(--accent)]`,to:`/providers/${e.providerId}`,children:e.providerName}),detail:`${e.modelId} · ${_(e.pricing)}`},e.providerModelId))})]}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(u,{action:$(`pricing`),children:e(`models.section.pricing`)}),(0,z.jsx)(`p`,{className:`mb-3 px-1 text-[12px] text-[var(--text-secondary)]`,children:e(`models.pricingHint`)}),(0,z.jsx)(`div`,{className:`card p-4`,children:(0,z.jsx)(P,{value:F.pricing??null,onChange:e=>Y({pricing:e}),allowEmpty:!0})})]}),(0,z.jsxs)(`section`,{className:`mb-5`,children:[(0,z.jsx)(u,{children:e(`models.section.simulator`)}),(0,z.jsxs)(`div`,{className:`card p-4`,children:[(0,z.jsx)(ne,{modelId:Z?void 0:J.id,pricing:Z?X.pricing:null}),Z&&(0,z.jsx)(`p`,{className:`mt-3 text-[12px] text-[var(--text-muted)]`,children:e(`models.simulatorUnsaved`)})]})]})]})]})})}function U({label:e,marker:t,children:n}){return(0,z.jsx)(p,{label:(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[e,t]}),children:n})}function W({model:e}){let{t}=c(),n=s(e.id),[r,i]=(0,R.useState)(null);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(y,{title:(0,z.jsxs)(`span`,{className:`flex items-center justify-between`,children:[t(`models.section.providerPrices`),(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(F,{className:`size-3.5`}),onClick:()=>i(`new`),children:t(`common.add`)})]}),footer:t(`models.providerPricesFooter`),children:[e.providerPrices.length===0&&(0,z.jsx)(p,{label:(0,z.jsx)(`span`,{className:`text-[12px] text-[var(--text-muted)]`,children:t(`models.noProviderPrices`)})}),e.providerPrices.map(e=>(0,z.jsxs)(p,{label:(0,z.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(`span`,{className:`font-mono text-[12.5px]`,children:e.priceKey}),e.userModified&&(0,z.jsx)(m,{tone:`orange`,children:t(`models.modified`)})]}),detail:[_(e.pricing),e.upstreamModelId,e.pricing.time_windows?.length?t(`models.hasTimeWindows`):null,e.pricing.context_tiers?.length?t(`models.hasTiers`):null].filter(Boolean).join(` · `),children:[(0,z.jsx)(g,{size:`sm`,variant:`plain`,icon:(0,z.jsx)(O,{className:`size-3.5`}),"aria-label":t(`common.edit`),onClick:()=>i(e)}),(0,z.jsx)(K,{label:t(`common.delete`),prompt:t(`models.deletePrice`,{key:e.priceKey}),onConfirm:()=>n.mutateAsync(e.priceKey)})]},e.priceKey))]}),(0,z.jsx)(G,{model:e,editing:r,onClose:()=>i(null)})]})}function G({model:t,editing:n,onClose:r}){let{t:i}=c(),{toast:a}=T(),s=o(),u=e(t.id),d=n===`new`,[p,m]=(0,R.useState)(``),[h,_]=(0,R.useState)(``),[v,y]=(0,R.useState)(null);(0,R.useEffect)(()=>{n&&(n===`new`?(m(``),_(``),y(t.pricing?structuredClone(t.pricing):{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}})):(m(n.priceKey),_(n.upstreamModelId??``),y(structuredClone(n.pricing))))},[n,t.pricing]);let b=new Set(t.providerPrices.map(e=>e.priceKey));return(0,z.jsx)(w,{open:n!==null,onOpenChange:e=>!e&&r(),width:680,title:d?i(`models.addPrice`):i(`models.editPrice`,{key:p}),description:i(`models.priceSheetDetail`),footer:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(g,{onClick:r,children:i(`common.cancel`)}),(0,z.jsx)(g,{variant:`primary`,disabled:!p||!v,loading:u.isPending,onClick:()=>u.mutate({priceKey:p,upstreamModelId:h||null,pricing:v},{onSuccess:()=>{a(i(`common.saved`),`success`),r()},onError:e=>a(C(e),`error`)}),children:i(`common.save`)})]}),children:(0,z.jsxs)(`div`,{className:`grid gap-4`,children:[(0,z.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,z.jsx)(f,{label:i(`providers.priceKey`),children:d?(0,z.jsx)(E,{value:p,onChange:m,placeholder:i(`models.pickPriceKey`),options:(s.data??[]).map(e=>({value:e.priceKey,label:e.label,detail:e.priceKey,disabled:b.has(e.priceKey)}))}):(0,z.jsx)(l,{value:p,disabled:!0,className:`font-mono`})}),(0,z.jsx)(f,{label:i(`models.upstreamId`),hint:i(`models.upstreamIdHint`),children:(0,z.jsx)(l,{className:`font-mono`,value:h,onChange:e=>_(e.target.value),placeholder:t.id})})]}),d&&(0,z.jsx)(l,{className:`font-mono`,"aria-label":i(`models.customPriceKey`),placeholder:i(`models.customPriceKey`),value:p,onChange:e=>m(e.target.value.trim())}),(0,z.jsx)(P,{value:v,onChange:y})]})})}function K({label:e,prompt:t,onConfirm:n}){let{t:r}=c();return(0,z.jsx)(L,{label:e,icon:(0,z.jsx)(j,{className:`size-4`}),prompt:t,confirmLabel:r(`common.delete`),cancelLabel:r(`common.cancel`),pendingLabel:r(`common.deleting`),doneLabel:r(`common.deleted`),errorLabel:r(`common.error`),retryLabel:r(`common.retry`),onConfirm:n})}export{H as ModelDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$t as e,Fa as t,Gr as n,Nn as r,Pa as i,Ra as a,V as o,Wr as s,Z as c,c as l,ct as u,d,h as f,l as p,n as m,nt as h,ot as g,p as _,r as v,t as y,v as b}from"./alert-CMMOyMsp.js";import{a as x,i as S,o as C,r as w}from"./overlays-BFrvqpMl.js";import{t as T}from"./cloud-download-BkOTPIzF.js";import{D as E,H as D,M as O,Q as k,W as A,h as j,j as M,z as N}from"./index-Ck4Qlg9B.js";import{t as P}from"./checkbox--x0D0yfB.js";var F=a(t(),1),I=i();function L(){let{t:e}=u(),t=k(),[n,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),[d,p]=(0,F.useState)(!1),m=(0,F.useRef)(null),h=O(n),g=r(),_=r(h,a),S=(0,F.useMemo)(()=>[...new Set((g.data??[]).map(e=>e.vendor))].sort(),[g.data]);return M(e=>{e===`find`&&m.current?.focus()}),(0,I.jsxs)(j,{title:e(`nav.models`),subtitle:_.data?e(`models.count`,{count:_.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{inputRef:m,className:`w-52`,value:n,onChange:i,placeholder:e(`models.search`)}),(0,I.jsx)(w,{value:a,onChange:o,options:[{value:``,label:e(`models.allVendors`)},...S.map(e=>({value:e,label:e}))]}),(0,I.jsx)(v,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(v,{variant:`primary`,icon:(0,I.jsx)(N,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`models.new`)})]}),children:[_.isLoading&&(0,I.jsx)(b,{lines:5}),_.isError&&(0,I.jsx)(y,{tone:`danger`,title:e(`common.error`),children:x(_.error)}),_.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(A,{className:`size-6`}),title:e(`models.empty`)}),_.data&&_.data.length>0&&(0,I.jsx)(E,{caption:e(`nav.models`),rowKey:`id`,rows:_.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:s,onOpenChange:c,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:d,onOpenChange:p})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:g(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(m,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(m,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,t)=>o(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${c(n.input)} / ${c(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:t,onOpenChange:n,onCreated:r}){let{t:i}=u(),{toast:a}=C(),o=e(),[s,c]=(0,F.useState)(``),[l,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[g,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:t,onOpenChange:n,title:i(`models.new`),description:i(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:!s.trim()||!m.trim(),loading:o.isPending,onClick:()=>o.mutate({id:s.trim(),displayName:l.trim()||s.trim(),vendor:m.trim(),contextWindow:g,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{n(!1),c(``),f(``),r(e.id)},onError:e=>a(x(e),`error`)}),children:i(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.id`),hint:i(`models.field.idHint`),children:(0,I.jsx)(d,{className:`font-mono`,value:s,onChange:e=>c(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.displayName`),children:(0,I.jsx)(d,{value:l,onChange:e=>f(e.target.value)})}),(0,I.jsx)(p,{label:i(`models.field.vendor`),children:(0,I.jsx)(d,{value:m,onChange:e=>h(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.contextWindow`),children:(0,I.jsx)(_,{value:g,onChange:y})}),(0,I.jsx)(p,{label:i(`models.field.inputPrice`),children:(0,I.jsx)(_,{value:b,onChange:w})}),(0,I.jsx)(p,{label:i(`models.field.outputPrice`),children:(0,I.jsx)(_,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=u(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${h(e)||`∅`}\n→\n${h(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:i}=u(),[a,o]=(0,F.useState)(new Set),s=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),c=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},l=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},d=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(m,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(m,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:c(p),onCheckedChange:e=>l(p,e!==!1),"aria-label":i(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.selectedOf`,{n:n.size,total:p.length,models:s.length})})]}),s.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,u=!a.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:c(o),onCheckedChange:e=>l(o,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":u,onClick:()=>d(e),children:[(0,I.jsx)(D,{className:g(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,u&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.groupCount`,{n:r.length})})]}),s&&f(s)]})]}),!s&&u&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>l([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),f(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:r}=u(),{toast:i}=C(),a=n(),o=s(),[c,l]=(0,F.useState)(new Set),d=()=>a.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),f=a.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{t(e),e&&!a.data&&d()},width:720,title:r(`models.sync`),description:r(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{className:`mr-auto`,variant:`plain`,onClick:d,loading:a.isPending,children:r(`common.refresh`)}),(0,I.jsx)(v,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:c.size===0,loading:o.isPending,onClick:()=>o.mutate([...c],{onSuccess:e=>{i(r(`models.sync.applied`,{count:e.applied}),`success`),t(!1),a.reset()},onError:e=>i(x(e),`error`)}),children:r(`models.sync.apply`,{count:c.size})})]}),children:[e&&!a.data&&!a.isPending&&!a.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(v,{variant:`primary`,onClick:d,children:r(`models.sync.check`)})}),a.isPending&&(0,I.jsx)(b,{lines:4}),a.isError&&(0,I.jsx)(y,{tone:`danger`,title:r(`common.error`),children:x(a.error)}),a.data&&f.length===0&&(0,I.jsx)(y,{tone:`success`,title:r(`models.sync.none`)}),f.length>0&&(0,I.jsx)(K,{changes:f,label:e=>e.kind===`new_model`?r(`models.sync.newModel`):e.kind===`price`?r(`models.sync.price`,{key:e.priceKey??``}):r(`models.sync.field`,{field:e.field??``}),checked:c,onChange:l})]})}export{L as ModelsPage};
|
|
1
|
+
import{$t as e,Fa as t,Gr as n,Nn as r,Pa as i,Ra as a,V as o,Wr as s,Z as c,c as l,ct as u,d,h as f,l as p,n as m,nt as h,ot as g,p as _,r as v,t as y,v as b}from"./alert-BF0mCqUl.js";import{a as x,i as S,o as C,r as w}from"./overlays-OPtjc9Yr.js";import{t as T}from"./cloud-download-D02pcV_l.js";import{D as E,H as D,M as O,Q as k,W as A,h as j,j as M,z as N}from"./index-CN0EAD0q.js";import{t as P}from"./checkbox-j5bCl2a6.js";var F=a(t(),1),I=i();function L(){let{t:e}=u(),t=k(),[n,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(!1),[d,p]=(0,F.useState)(!1),m=(0,F.useRef)(null),h=O(n),g=r(),_=r(h,a),S=(0,F.useMemo)(()=>[...new Set((g.data??[]).map(e=>e.vendor))].sort(),[g.data]);return M(e=>{e===`find`&&m.current?.focus()}),(0,I.jsxs)(j,{title:e(`nav.models`),subtitle:_.data?e(`models.count`,{count:_.data.length}):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f,{inputRef:m,className:`w-52`,value:n,onChange:i,placeholder:e(`models.search`)}),(0,I.jsx)(w,{value:a,onChange:o,options:[{value:``,label:e(`models.allVendors`)},...S.map(e=>({value:e,label:e}))]}),(0,I.jsx)(v,{icon:(0,I.jsx)(T,{className:`size-3.5`}),onClick:()=>p(!0),children:e(`models.sync`)}),(0,I.jsx)(v,{variant:`primary`,icon:(0,I.jsx)(N,{className:`size-3.5`}),onClick:()=>c(!0),children:e(`models.new`)})]}),children:[_.isLoading&&(0,I.jsx)(b,{lines:5}),_.isError&&(0,I.jsx)(y,{tone:`danger`,title:e(`common.error`),children:x(_.error)}),_.data?.length===0&&(0,I.jsx)(l,{icon:(0,I.jsx)(A,{className:`size-6`}),title:e(`models.empty`)}),_.data&&_.data.length>0&&(0,I.jsx)(E,{caption:e(`nav.models`),rowKey:`id`,rows:_.data.map(e=>({id:e.id,name:e.displayName,vendor:e.vendor,context:e.contextWindow??0,input:e.pricing?.base.input??0,providerPrices:e.providerPriceKeys.length,m:e})),columns:R(e,e=>t(`/models/${encodeURIComponent(e)}`))}),(0,I.jsx)(z,{open:s,onOpenChange:c,onCreated:e=>t(`/models/${encodeURIComponent(e)}`)}),(0,I.jsx)(q,{open:d,onOpenChange:p})]})}function R(e,t){return[{key:`name`,label:e(`models.col.model`),render:(n,r)=>(0,I.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>t(r.id),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:g(`truncate font-medium hover:text-[var(--accent)]`,!r.m.enabled&&`text-[var(--text-muted)]`),children:r.name}),r.m.source===`user`&&(0,I.jsx)(m,{tone:`accent`,children:e(`models.source.user`)}),r.m.userModifiedFields.length>0&&(0,I.jsx)(m,{tone:`orange`,children:e(`models.modified`)})]}),(0,I.jsx)(`span`,{className:`block truncate font-mono text-[11px] text-[var(--text-muted)]`,children:r.id})]})},{key:`vendor`,label:e(`models.col.vendor`),width:120},{key:`context`,label:e(`models.col.context`),numeric:!0,width:96,render:(e,t)=>o(t.m.contextWindow)},{key:`input`,label:e(`models.col.price`),numeric:!0,width:150,render:(e,t)=>{let n=t.m.pricing?.base;return n?`${c(n.input)} / ${c(n.output)}`:`—`}},{key:`providerPrices`,label:e(`models.col.providerPrices`),numeric:!0,width:130,render:(t,n)=>n.providerPrices?e(`models.providerPriceCount`,{count:n.providerPrices}):`—`}]}function z({open:t,onOpenChange:n,onCreated:r}){let{t:i}=u(),{toast:a}=C(),o=e(),[s,c]=(0,F.useState)(``),[l,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[g,y]=(0,F.useState)(null),[b,w]=(0,F.useState)(null),[T,E]=(0,F.useState)(null);return(0,I.jsx)(S,{open:t,onOpenChange:n,title:i(`models.new`),description:i(`models.newDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{onClick:()=>n(!1),children:i(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:!s.trim()||!m.trim(),loading:o.isPending,onClick:()=>o.mutate({id:s.trim(),displayName:l.trim()||s.trim(),vendor:m.trim(),contextWindow:g,pricing:b!=null||T!=null?{currency:`USD`,unit:`per_1m_tokens`,base:{input:b,output:T}}:null},{onSuccess:e=>{n(!1),c(``),f(``),r(e.id)},onError:e=>a(x(e),`error`)}),children:i(`common.create`)})]}),children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.id`),hint:i(`models.field.idHint`),children:(0,I.jsx)(d,{className:`font-mono`,value:s,onChange:e=>c(e.target.value),placeholder:`my-model-1`})}),(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.displayName`),children:(0,I.jsx)(d,{value:l,onChange:e=>f(e.target.value)})}),(0,I.jsx)(p,{label:i(`models.field.vendor`),children:(0,I.jsx)(d,{value:m,onChange:e=>h(e.target.value),placeholder:`openai`})})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,I.jsx)(p,{label:i(`models.field.contextWindow`),children:(0,I.jsx)(_,{value:g,onChange:y})}),(0,I.jsx)(p,{label:i(`models.field.inputPrice`),children:(0,I.jsx)(_,{value:b,onChange:w})}),(0,I.jsx)(p,{label:i(`models.field.outputPrice`),children:(0,I.jsx)(_,{value:T,onChange:E})})]})]})})}var B=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function V(e,t=``,n=new Map){if(B(e)&&Object.keys(e).length>0)for(let[r,i]of Object.entries(e))V(i,t?`${t}.${r}`:r,n);else e!=null&&n.set(t,e);return n}function H(e,t){let n=V(e),r=V(t);return[...r.keys(),...[...n.keys()].filter(e=>!r.has(e))].filter(e=>JSON.stringify(n.get(e))!==JSON.stringify(r.get(e))).map(e=>({path:e.replace(/^pricing\./,``),before:n.get(e),after:r.get(e)}))}var U=e=>typeof e==`string`?e:JSON.stringify(e),W=4;function G({before:e,after:t}){let{t:n}=u(),r=H(e,t),i=r.length-W;return(0,I.jsxs)(`span`,{className:`flex w-full min-w-0 flex-col gap-0.5 font-mono text-[11px] leading-snug`,title:`${h(e)||`∅`}\n→\n${h(t)||`∅`}`,children:[r.slice(0,W).map(e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5 whitespace-nowrap`,children:[e.path&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:e.path}),e.before!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--danger)] line-through opacity-80`,children:U(e.before)}),e.before!==void 0&&e.after!==void 0&&(0,I.jsx)(`span`,{className:`shrink-0 text-[var(--text-secondary)]`,children:`→`}),e.after!==void 0&&(0,I.jsx)(`span`,{className:`min-w-0 truncate text-[var(--success)]`,children:U(e.after)})]},e.path)),i>0&&(0,I.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:n(`models.sync.more`,{n:i})})]})}function K({changes:e,label:t,checked:n,onChange:r}){let{t:i}=u(),[a,o]=(0,F.useState)(new Set),s=(0,F.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.modelId,[...t.get(n.modelId)??[],n]);return[...t]},[e]),c=e=>{let t=e.filter(e=>n.has(e)).length;return t===0?!1:t===e.length||`indeterminate`},l=(e,t)=>{let i=new Set(n);for(let n of e)t?i.add(n):i.delete(n);r(i)},d=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=e=>(0,I.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1`,children:[(0,I.jsxs)(`span`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(m,{tone:e.kind===`new_model`?`green`:`neutral`,children:t(e)}),e.skippedBecauseUserModified&&(0,I.jsx)(m,{tone:`orange`,children:i(`models.sync.userModified`)})]}),e.kind!==`new_model`&&(0,I.jsx)(G,{before:e.before,after:e.after})]}),p=e.map(e=>e.id);return(0,I.jsx)(`div`,{className:`card max-h-[520px] overflow-auto`,children:(0,I.jsxs)(`ul`,{className:`divide-y divide-[var(--border)]`,children:[(0,I.jsxs)(`li`,{className:`sticky top-0 z-10 flex items-center gap-3 bg-[var(--surface)] px-4 py-2`,children:[(0,I.jsx)(P,{checked:c(p),onCheckedChange:e=>l(p,e!==!1),"aria-label":i(`models.sync.selectAll`)}),(0,I.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.selectedOf`,{n:n.size,total:p.length,models:s.length})})]}),s.map(([e,r])=>{let o=r.map(e=>e.id),s=r.length===1?r[0]:void 0,u=!a.has(e);return(0,I.jsxs)(`li`,{className:`px-4 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:c(o),onCheckedChange:e=>l(o,e!==!1),"aria-label":e,className:`mt-0.5`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[s?(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}):(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 items-center gap-1 text-left`,"aria-expanded":u,onClick:()=>d(e),children:[(0,I.jsx)(D,{className:g(`size-3.5 shrink-0 text-[var(--text-muted)] transition-transform`,u&&`rotate-90`)}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[12px] font-medium`,title:e,children:e}),(0,I.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-[11px] text-[var(--text-muted)]`,children:i(`models.sync.groupCount`,{n:r.length})})]}),s&&f(s)]})]}),!s&&u&&(0,I.jsx)(`ul`,{className:`mt-2 ml-7 flex flex-col gap-2 border-l border-[var(--border)] pl-3`,children:r.map(r=>(0,I.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(P,{checked:n.has(r.id),onCheckedChange:e=>l([r.id],e!==!1),"aria-label":`${e} ${t(r)}`,className:`mt-0.5`}),f(r)]},r.id))})]},e)})]})})}function q({open:e,onOpenChange:t}){let{t:r}=u(),{toast:i}=C(),a=n(),o=s(),[c,l]=(0,F.useState)(new Set),d=()=>a.mutate(void 0,{onSuccess:e=>l(new Set(e.changes.filter(e=>!e.skippedBecauseUserModified).map(e=>e.id)))}),f=a.data?.changes??[];return(0,I.jsxs)(S,{open:e,onOpenChange:e=>{t(e),e&&!a.data&&d()},width:720,title:r(`models.sync`),description:r(`models.syncDetail`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(v,{className:`mr-auto`,variant:`plain`,onClick:d,loading:a.isPending,children:r(`common.refresh`)}),(0,I.jsx)(v,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,I.jsx)(v,{variant:`primary`,disabled:c.size===0,loading:o.isPending,onClick:()=>o.mutate([...c],{onSuccess:e=>{i(r(`models.sync.applied`,{count:e.applied}),`success`),t(!1),a.reset()},onError:e=>i(x(e),`error`)}),children:r(`models.sync.apply`,{count:c.size})})]}),children:[e&&!a.data&&!a.isPending&&!a.isError&&(0,I.jsx)(`div`,{className:`py-6 text-center`,children:(0,I.jsx)(v,{variant:`primary`,onClick:d,children:r(`models.sync.check`)})}),a.isPending&&(0,I.jsx)(b,{lines:4}),a.isError&&(0,I.jsx)(y,{tone:`danger`,title:r(`common.error`),children:x(a.error)}),a.data&&f.length===0&&(0,I.jsx)(y,{tone:`success`,title:r(`models.sync.none`)}),f.length>0&&(0,I.jsx)(K,{changes:f,label:e=>e.kind===`new_model`?r(`models.sync.newModel`):e.kind===`price`?r(`models.sync.price`,{key:e.priceKey??``}):r(`models.sync.field`,{field:e.field??``}),checked:c,onChange:l})]})}export{L as ModelsPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Bn as e,Fa as t,H as n,Hn as r,Jn as i,Kn as a,Nt as o,Pa as s,Pn as c,Ra as l,Rn as u,Sn as d,Tn as f,_ as p,b as m,bt as h,c as g,ct as _,d as v,di as y,f as b,fr as x,h as S,i as C,jn as w,l as T,mt as E,n as D,ot as O,pr as k,r as A,t as j,v as M,xt as N,y as P,zn as F}from"./alert-CMMOyMsp.js";import{a as I,i as L,n as ee,o as R}from"./overlays-BFrvqpMl.js";import{t as z}from"./arrow-down-rd1gJD55.js";import{t as te}from"./download-CSRdoXEJ.js";import{t as ne}from"./ellipsis-BI50R2Bc.js";import{t as re}from"./external-link-Bzx5-ExU.js";import{$ as ie,C as ae,E as B,F as oe,J as se,K as ce,N as V,Q as H,R as U,T as W,et as le,h as ue,w as G,x as de,z as fe}from"./index-Ck4Qlg9B.js";var K={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};K.node;var pe=N(K),q=l(t(),1),J=s(),me=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`},he={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?oe:se,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(de,{name:e,icon:t,size:r})}function Z(){let{t:e}=_(),t=H(),{tab:n}=ie(),r=n===`market`||n===`runtime`?n:`installed`,i=a(),o=y(),{toast:s}=R(),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsxs)(ue,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{icon:(0,J.jsx)(U,{className:`size-3.5`}),onClick:()=>o.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>s(I(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(A,{variant:`primary`,icon:(0,J.jsx)(fe,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[i.data?.off&&(0,J.jsx)(j,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(ae,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(W,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(B,{value:`installed`,children:[e(`plugins.tab.installed`),i.data&&i.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:i.data.plugins.length})]}),(0,J.jsx)(B,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(B,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(G,{value:`installed`,className:`pt-1`,children:[i.isLoading&&(0,J.jsx)(M,{lines:4}),i.isError&&(0,J.jsx)(j,{tone:`danger`,title:e(`common.error`),children:I(i.error)}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins,preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(G,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(G,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:p})})]})]}),(0,J.jsx)(ye,{open:c,onOpenChange:l,onJob:p}),(0,J.jsx)(be,{open:u,onOpenChange:d,onJob:p}),(0,J.jsx)(xe,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=_(),o=u(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),s=w(),c=k(),{toast:l}=R(),d=!!(s.data?.found&&s.data.plugins.some(e=>!e.installed))&&(0,J.jsxs)(`div`,{className:`card flex flex-wrap items-center gap-3 p-4`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a(`plugins.magpie.banner`,{count:s.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(A,{size:`sm`,icon:(0,J.jsx)(te,{className:`size-3.5`}),onClick:i,children:a(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(g,{icon:(0,J.jsx)(E,{className:`size-6`}),title:a(`plugins.empty`),detail:a(`plugins.emptyDetail`),action:(0,J.jsx)(A,{variant:`primary`,onClick:r,children:a(`plugins.browseMarket`)})})})]});let f=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),c.mutate(r,{onError:e=>l(I(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:o.data,preferences:t,onJob:n,onUp:i>0?()=>f(i,-1):void 0,onDown:i<e.length-1?()=>f(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:r,onUp:a,onDown:o}){let{t:s}=_(),l=H(),{toast:u,confirm:d}=R(),f=c(),p=y(),m=x(),h=i(),[g,v]=(0,q.useState)(!1),b=t?.plugins.find(t=>t.spec===e.spec),S=e.middleware,C=e.kinds[0]??`provider`,w=async()=>{await d({title:s(`plugins.removeConfirm`,{name:e.shortName}),detail:s(`plugins.removeDetail`),confirmLabel:s(`common.delete`),destructive:!0})&&m.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>u(I(e),`error`)})},T=[];return S&&!S.error&&T.push((0,J.jsxs)(Q,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:S.hooks.join(`, `),calls:S.calls,micros:S.avgMicros.toFixed(1),failures:S.failures}),S.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:S.lastError})})]},`mw`)),e.agent?.kind&&T.push((0,J.jsx)(Q,{label:s(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),b&&b.provides.length>0&&T.push((0,J.jsxs)(Q,{label:s(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:s(`plugins.provides`,{providers:b.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/providers`),children:s(`plugins.openProviders`)}),Object.entries(b.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[s(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(A,{size:`sm`,onClick:()=>h.mutate({spec:e.spec,provider:t},{onError:e=>u(I(e),`error`)}),children:s(`plugins.useFor`,{provider:t})})]},t)),b.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:s(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:O(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:O(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:C})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(D,{tone:he[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(D,{tone:`orange`,children:s(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[S&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveUp`),title:s(`plugins.moveUp`),disabled:!a,onClick:a,icon:(0,J.jsx)(ce,{className:`size-3.5`})}),(0,J.jsx)(A,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveDown`),title:s(`plugins.moveDown`),disabled:!o,onClick:o,icon:(0,J.jsx)(z,{className:`size-3.5`})})]}),(0,J.jsx)(P,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>f.mutate({spec:e.spec,enabled:t},{onError:e=>u(I(e),`error`)})}),(0,J.jsx)(ee,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ne,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>v(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(U,{className:`size-3.5`}),onSelect:()=>p.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>u(I(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(V,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void w()}]})]})]}),e.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),b?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:b.error}),S?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:S.error})}),e.agent?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.agent.error`,{error:e.agent.error})}),T.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:T})]}),(0,J.jsx)(ve,{plugin:e,open:g,onOpenChange:v})]})}function Q({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function ve({plugin:e,open:t,onOpenChange:n}){let{t:r}=_(),{toast:i}=R(),a=c(),[o,s]=(0,q.useState)(``),[l,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(s(JSON.stringify(e.options??e.optionsExample??{},null,2)),u(null))},[t,e.options,e.optionsExample]);let d=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(I(e),`error`)});return(0,J.jsxs)(L,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(A,{onClick:()=>d(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(A,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));d(e)}catch(e){u(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(m,{mono:!0,rows:14,value:o,invalid:!!l,onChange:e=>(s(e.target.value),u(null)),label:r(`plugins.options`)}),l&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:l})]})}function ye({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=o(),[s,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&c(``)},[e]),(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(A,{variant:`primary`,disabled:!s.trim()||a.isPending,onClick:()=>a.mutate({spec:s.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(T,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(v,{mono:!0,value:s,onChange:e=>c(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(j,{tone:`warning`,title:r(`plugins.trustTitle`),className:`mt-4`,children:r(`plugins.trustDetail`)})]})}function be({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=w(e),o=d(),[s,c]=(0,q.useState)(!1),l=a.data;return(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:l?.path,width:560,footer:(0,J.jsx)(A,{variant:`primary`,disabled:!l?.found||o.isPending,onClick:()=>o.mutate(s,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[a.isLoading&&(0,J.jsx)(M,{lines:3}),l?.error&&(0,J.jsx)(j,{tone:`danger`,title:r(`common.error`),children:l.error}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:l.plugins.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.spec}),e.off&&(0,J.jsx)(D,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(D,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(D,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),l.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(P,{checked:s,onChange:c,label:r(`plugins.magpie.signIns`,{count:l.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function xe({id:e,onClose:t}){let{t:n}=_(),r=F(e).data;return(0,J.jsxs)(L,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(A,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(M,{lines:3}),r&&(0,J.jsx)(C,{language:`text`,children:r.log.length?r.log.join(`
|
|
1
|
+
import{Bn as e,Fa as t,H as n,Hn as r,Jn as i,Kn as a,Nt as o,Pa as s,Pn as c,Ra as l,Rn as u,Sn as d,Tn as f,_ as p,b as m,bt as h,c as g,ct as _,d as v,di as y,f as b,fr as x,h as S,i as C,jn as w,l as T,mt as E,n as D,ot as O,pr as k,r as A,t as j,v as M,xt as N,y as P,zn as F}from"./alert-BF0mCqUl.js";import{a as I,i as L,n as ee,o as R}from"./overlays-OPtjc9Yr.js";import{t as z}from"./arrow-down-DZLYQSjE.js";import{t as te}from"./download-DDp7Ezie.js";import{t as ne}from"./ellipsis-D10W7mYw.js";import{t as re}from"./external-link-DTLyxO14.js";import{$ as ie,C as ae,E as B,F as oe,J as se,K as ce,N as V,Q as H,R as U,T as W,et as le,h as ue,w as G,x as de,z as fe}from"./index-CN0EAD0q.js";var K={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};K.node;var pe=N(K),q=l(t(),1),J=s(),me=/^(?:(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*|github:[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/,Y={provider:`plugins.kind.provider`,middleware:`plugins.kind.middleware`,agent:`plugins.kind.agent`,pi:`plugins.kind.pi`},he={provider:`neutral`,middleware:`accent`,agent:`green`,pi:`orange`};function X({name:e,icon:t,kind:n,size:r=32}){let i=Math.round(r*.28);return t&&/^(https:|data:image\/)/i.test(t)?(0,J.jsx)(`img`,{src:t,alt:``,width:r,height:r,className:`shrink-0 object-contain`,style:{borderRadius:i},draggable:!1}):n===`middleware`||n===`agent`?(0,J.jsx)(`span`,{"aria-hidden":!0,className:`inline-flex shrink-0 items-center justify-center text-white`,style:{width:r,height:r,borderRadius:i,background:n===`middleware`?`#0a84ff`:`#30b0a0`},children:(0,J.jsx)(n===`middleware`?oe:se,{className:`size-[55%]`,strokeWidth:1.75})}):(0,J.jsx)(de,{name:e,icon:t,size:r})}function Z(){let{t:e}=_(),t=H(),{tab:n}=ie(),r=n===`market`||n===`runtime`?n:`installed`,i=a(),o=y(),{toast:s}=R(),[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(null);return(0,J.jsxs)(ue,{title:e(`nav.plugins`),subtitle:e(`plugins.subtitle`),actions:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{icon:(0,J.jsx)(U,{className:`size-3.5`}),onClick:()=>o.mutate(void 0,{onSuccess:e=>p(e.id),onError:e=>s(I(e),`error`)}),disabled:!i.data?.plugins.length,children:e(`plugins.updateAll`)}),(0,J.jsx)(A,{variant:`primary`,icon:(0,J.jsx)(fe,{className:`size-3.5`}),onClick:()=>l(!0),children:e(`plugins.add`)})]}),children:[(0,J.jsxs)(`div`,{className:`mx-auto flex max-w-[1100px] flex-col`,children:[i.data?.off&&(0,J.jsx)(j,{className:`mb-4`,tone:`warning`,title:e(`plugins.off`),children:e(`plugins.offDetail`)}),(0,J.jsxs)(ae,{value:r,onValueChange:e=>t(e===`installed`?`/plugins`:`/plugins/${e}`,{replace:!0}),children:[(0,J.jsxs)(W,{"aria-label":e(`nav.plugins`),children:[(0,J.jsxs)(B,{value:`installed`,children:[e(`plugins.tab.installed`),i.data&&i.data.plugins.length>0&&(0,J.jsx)(`span`,{className:`ml-1.5 tabular-nums opacity-60`,children:i.data.plugins.length})]}),(0,J.jsx)(B,{value:`market`,children:e(`plugins.tab.market`)}),(0,J.jsx)(B,{value:`runtime`,children:e(`plugins.tab.runtime`)})]}),(0,J.jsxs)(G,{value:`installed`,className:`pt-1`,children:[i.isLoading&&(0,J.jsx)(M,{lines:4}),i.isError&&(0,J.jsx)(j,{tone:`danger`,title:e(`common.error`),children:I(i.error)}),i.data&&(0,J.jsx)(ge,{plugins:i.data.plugins,preferences:i.data.preferences,onJob:p,onBrowse:()=>t(`/plugins/market`),onImport:()=>d(!0)})]}),(0,J.jsx)(G,{value:`market`,className:`pt-1`,children:(0,J.jsx)(Se,{installed:i.data?.plugins??[],onJob:p})}),(0,J.jsx)(G,{value:`runtime`,className:`pt-1`,children:(0,J.jsx)(Ce,{onJob:p})})]})]}),(0,J.jsx)(ye,{open:c,onOpenChange:l,onJob:p}),(0,J.jsx)(be,{open:u,onOpenChange:d,onJob:p}),(0,J.jsx)(xe,{id:f,onClose:()=>p(null)})]})}function ge({plugins:e,preferences:t,onJob:n,onBrowse:r,onImport:i}){let{t:a}=_(),o=u(e.some(e=>e.kinds.includes(`provider`)||e.kinds.includes(`pi`))),s=w(),c=k(),{toast:l}=R(),d=!!(s.data?.found&&s.data.plugins.some(e=>!e.installed))&&(0,J.jsxs)(`div`,{className:`card flex flex-wrap items-center gap-3 p-4`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:a(`plugins.magpie.banner`,{count:s.data.plugins.filter(e=>!e.installed).length})}),(0,J.jsx)(A,{size:`sm`,icon:(0,J.jsx)(te,{className:`size-3.5`}),onClick:i,children:a(`plugins.magpie.import`)})]});if(e.length===0)return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(g,{icon:(0,J.jsx)(E,{className:`size-6`}),title:a(`plugins.empty`),detail:a(`plugins.emptyDetail`),action:(0,J.jsx)(A,{variant:`primary`,onClick:r,children:a(`plugins.browseMarket`)})})})]});let f=(t,n)=>{let r=e.map(e=>e.spec),[i]=r.splice(t,1);r.splice(t+n,0,i),c.mutate(r,{onError:e=>l(I(e),`error`)})};return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[d,(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:e.map((r,i)=>(0,J.jsx)(_e,{plugin:r,host:o.data,preferences:t,onJob:n,onUp:i>0?()=>f(i,-1):void 0,onDown:i<e.length-1?()=>f(i,1):void 0},r.spec))}),e.some(e=>e.middleware)&&(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:a(`plugins.orderHint`)})]})}function _e({plugin:e,host:t,preferences:n,onJob:r,onUp:a,onDown:o}){let{t:s}=_(),l=H(),{toast:u,confirm:d}=R(),f=c(),p=y(),m=x(),h=i(),[g,v]=(0,q.useState)(!1),b=t?.plugins.find(t=>t.spec===e.spec),S=e.middleware,C=e.kinds[0]??`provider`,w=async()=>{await d({title:s(`plugins.removeConfirm`,{name:e.shortName}),detail:s(`plugins.removeDetail`),confirmLabel:s(`common.delete`),destructive:!0})&&m.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>u(I(e),`error`)})},T=[];return S&&!S.error&&T.push((0,J.jsxs)(Q,{label:s(`plugins.kind.middleware`),children:[s(`plugins.mw.stats`,{hooks:S.hooks.join(`, `),calls:S.calls,micros:S.avgMicros.toFixed(1),failures:S.failures}),S.lastError&&(0,J.jsx)(`span`,{className:`block text-[var(--danger)]`,children:s(`plugins.mw.lastError`,{error:S.lastError})})]},`mw`)),e.agent?.kind&&T.push((0,J.jsx)(Q,{label:s(`plugins.kind.agent`),children:(0,J.jsx)(`button`,{type:`button`,className:`text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/clients/${e.agent.kind}`),children:s(`plugins.agent.adds`,{name:e.agent.name??e.agent.id??``})})},`agent`)),b&&b.provides.length>0&&T.push((0,J.jsxs)(Q,{label:s(`plugins.kind.provider`),children:[(0,J.jsx)(`span`,{children:s(`plugins.provides`,{providers:b.provides.join(`, `)})}),(0,J.jsx)(`button`,{type:`button`,className:`ml-2 text-[var(--accent)] underline-offset-2 hover:underline`,onClick:()=>l(`/providers`),children:s(`plugins.openProviders`)}),Object.entries(b.servedBy).map(([t,n])=>(0,J.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-2 text-[var(--warning)]`,children:[s(`plugins.servedBy`,{provider:t,other:n}),(0,J.jsx)(A,{size:`sm`,onClick:()=>h.mutate({spec:e.spec,provider:t},{onError:e=>u(I(e),`error`)}),children:s(`plugins.useFor`,{provider:t})})]},t)),b.provides.some(t=>n[t]===e.spec)&&(0,J.jsx)(`span`,{className:`block text-[var(--text-muted)]`,children:s(`plugins.picked`)})]},`provides`)),(0,J.jsxs)(`article`,{className:O(`flex gap-3 px-4 py-3.5`,!e.enabled&&`opacity-70`),children:[(0,J.jsx)(`div`,{className:O(`pt-0.5`,!e.enabled&&`grayscale`),children:(0,J.jsx)(X,{name:e.shortName,icon:e.icon,kind:C})}),(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 basis-56 flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,children:e.shortName}),e.version&&(0,J.jsxs)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:[`v`,e.version]}),e.kinds.map(e=>(0,J.jsx)(D,{tone:he[e],children:s(Y[e])},e)),e.isPath&&(0,J.jsx)(D,{tone:`orange`,children:s(`plugins.local`)})]}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:e.spec,children:e.spec})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[S&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveUp`),title:s(`plugins.moveUp`),disabled:!a,onClick:a,icon:(0,J.jsx)(ce,{className:`size-3.5`})}),(0,J.jsx)(A,{size:`sm`,variant:`plain`,"aria-label":s(`plugins.moveDown`),title:s(`plugins.moveDown`),disabled:!o,onClick:o,icon:(0,J.jsx)(z,{className:`size-3.5`})})]}),(0,J.jsx)(P,{checked:e.enabled,label:s(`plugins.enabled`),onChange:t=>f.mutate({spec:e.spec,enabled:t},{onError:e=>u(I(e),`error`)})}),(0,J.jsx)(ee,{label:s(`common.more`),iconOnly:!0,icon:(0,J.jsx)(ne,{className:`size-4`}),items:[{id:`options`,label:s(`plugins.options`),icon:(0,J.jsx)(pe,{className:`size-3.5`}),onSelect:()=>v(!0)},...e.isPath?[]:[{id:`update`,label:s(`plugins.update`),icon:(0,J.jsx)(U,{className:`size-3.5`}),onSelect:()=>p.mutate(e.spec,{onSuccess:e=>r(e.id),onError:e=>u(I(e),`error`)})}],{id:`remove`,label:s(`common.delete`),icon:(0,J.jsx)(V,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void w()}]})]})]}),e.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:e.error}),b?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.hostCantLoad`),children:b.error}),S?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.mw.error`,{error:S.error})}),e.agent?.error&&(0,J.jsx)(j,{tone:`danger`,title:s(`plugins.cantLoad`),children:s(`plugins.agent.error`,{error:e.agent.error})}),T.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-[var(--surface-muted)] px-3 py-2`,children:T})]}),(0,J.jsx)(ve,{plugin:e,open:g,onOpenChange:v})]})}function Q({label:e,children:t}){return(0,J.jsxs)(`div`,{className:`flex gap-3 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`w-14 shrink-0 text-[var(--text-muted)]`,children:e}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 text-[var(--text-secondary)]`,children:t})]})}function ve({plugin:e,open:t,onOpenChange:n}){let{t:r}=_(),{toast:i}=R(),a=c(),[o,s]=(0,q.useState)(``),[l,u]=(0,q.useState)(null);(0,q.useEffect)(()=>{t&&(s(JSON.stringify(e.options??e.optionsExample??{},null,2)),u(null))},[t,e.options,e.optionsExample]);let d=t=>a.mutate({spec:e.spec,options:t},{onSuccess:()=>(i(r(`plugins.optionsSaved`)),n(!1)),onError:e=>i(I(e),`error`)});return(0,J.jsxs)(L,{open:t,onOpenChange:n,title:r(`plugins.optionsTitle`,{name:e.shortName}),description:e.options?void 0:e.optionsExample?r(`plugins.optionsExample`):r(`plugins.optionsNone`),width:560,footer:(0,J.jsxs)(J.Fragment,{children:[e.options&&(0,J.jsx)(A,{onClick:()=>d(null),children:r(`plugins.optionsClear`)}),(0,J.jsx)(A,{variant:`primary`,onClick:()=>{try{let e=JSON.parse(o||`{}`);if(typeof e!=`object`||!e||Array.isArray(e))throw Error(r(`plugins.optionsObject`));d(e)}catch(e){u(e instanceof Error?e.message:String(e))}},disabled:a.isPending,children:r(`common.save`)})]}),children:[(0,J.jsx)(m,{mono:!0,rows:14,value:o,invalid:!!l,onChange:e=>(s(e.target.value),u(null)),label:r(`plugins.options`)}),l&&(0,J.jsx)(`p`,{className:`mt-2 text-[12px] text-[var(--danger)]`,children:l})]})}function ye({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=o(),[s,c]=(0,q.useState)(``);return(0,q.useEffect)(()=>{e&&c(``)},[e]),(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.addTitle`),description:r(`plugins.addDetail`),footer:(0,J.jsx)(A,{variant:`primary`,disabled:!s.trim()||a.isPending,onClick:()=>a.mutate({spec:s.trim()},{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.install`)}),children:[(0,J.jsx)(T,{label:r(`plugins.spec`),hint:r(`plugins.specHint`),children:(0,J.jsx)(v,{mono:!0,value:s,onChange:e=>c(e.target.value),placeholder:`@astragate-community/middleware-word-guard`,autoFocus:!0})}),(0,J.jsx)(j,{tone:`warning`,title:r(`plugins.trustTitle`),className:`mt-4`,children:r(`plugins.trustDetail`)})]})}function be({open:e,onOpenChange:t,onJob:n}){let{t:r}=_(),{toast:i}=R(),a=w(e),o=d(),[s,c]=(0,q.useState)(!1),l=a.data;return(0,J.jsxs)(L,{open:e,onOpenChange:t,title:r(`plugins.magpie.title`),description:l?.path,width:560,footer:(0,J.jsx)(A,{variant:`primary`,disabled:!l?.found||o.isPending,onClick:()=>o.mutate(s,{onSuccess:e=>(n(e.id),t(!1)),onError:e=>i(I(e),`error`)}),children:r(`plugins.magpie.import`)}),children:[a.isLoading&&(0,J.jsx)(M,{lines:3}),l?.error&&(0,J.jsx)(j,{tone:`danger`,title:r(`common.error`),children:l.error}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] p-0`,children:l.plugins.map(e=>(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[12px]`,children:[(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,children:e.spec}),e.off&&(0,J.jsx)(D,{children:r(`plugins.magpie.off`)}),e.hasOptions&&(0,J.jsx)(D,{tone:`accent`,children:r(`plugins.options`)}),e.installed&&(0,J.jsx)(D,{tone:`green`,children:r(`plugins.installed`)})]},e.spec))}),l.signIns>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,J.jsx)(P,{checked:s,onChange:c,label:r(`plugins.magpie.signIns`,{count:l.signIns})}),(0,J.jsx)(`p`,{className:`text-[12px] text-[var(--text-secondary)]`,children:r(`plugins.magpie.signInsDetail`)})]})]})]})}function xe({id:e,onClose:t}){let{t:n}=_(),r=F(e).data;return(0,J.jsxs)(L,{open:!!e,onOpenChange:e=>!e&&t(),title:n(`plugins.job.title`),description:r?n(r.state===`running`?`plugins.job.running`:r.state===`succeeded`?`plugins.job.done`:`plugins.job.failed`,{target:r.target}):void 0,width:620,footer:(0,J.jsx)(A,{onClick:t,children:n(`common.close`)}),children:[!r&&(0,J.jsx)(M,{lines:3}),r&&(0,J.jsx)(C,{language:`text`,children:r.log.length?r.log.join(`
|
|
2
2
|
`):`…`}),r?.state===`failed`&&r.error&&(0,J.jsx)(j,{tone:`danger`,title:n(`plugins.job.failedTitle`),className:`mt-3`,children:r.error})]})}function Se({installed:t,onJob:n}){let{t:i,locale:a}=_(),{toast:s,confirm:c}=R(),l=e(),u=o(),[d,f]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[v,y]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{let e=setTimeout(()=>h(d.trim()),400);return()=>clearTimeout(e)},[d]);let b=r(m),x=(0,q.useMemo)(()=>new Set(t.map(e=>e.name)),[t]),C=(e,n)=>x.has(n)||t.some(t=>t.spec===e),w=async(e,t)=>{await c({title:i(`plugins.installConfirm`,{name:e}),detail:i(`plugins.trustDetail`),confirmLabel:i(`plugins.install`)})&&u.mutate({spec:e,source:t},{onSuccess:e=>n(e.id),onError:e=>s(I(e),`error`)})},[T,D]=le(),O=T.get(`install`),k=(0,q.useRef)(null);(0,q.useEffect)(()=>{O&&k.current!==O&&(k.current=O,D({},{replace:!0}),me.test(O)?w(O,`market`):s(i(`plugins.linkInvalid`),`error`))},[O]);let A=(l.data??[]).filter(e=>v===`all`||e.kind===v),N=e=>(l.data??[]).filter(t=>e===`all`||t.kind===e).length,P=m.length>=2;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(S,{className:`min-w-[220px] flex-1`,value:d,onChange:f,placeholder:i(`plugins.searchPlaceholder`)}),!P&&(0,J.jsx)(p,{ariaLabel:i(`plugins.kindFilter`),value:v,onChange:y,items:[`all`,`provider`,`middleware`,`agent`].map(e=>({value:e,label:`${i(e===`all`?`plugins.kind.all`:Y[e])} ${N(e)}`}))})]}),P?(0,J.jsxs)(J.Fragment,{children:[b.isLoading&&(0,J.jsx)(M,{lines:3}),b.data?.length===0&&(0,J.jsx)(`div`,{className:`card p-6`,children:(0,J.jsx)(g,{icon:(0,J.jsx)(E,{className:`size-6`}),title:i(`plugins.noResults`)})}),b.data&&b.data.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:b.data.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.spec,icon:(0,J.jsx)(X,{name:e.name,kind:e.kind}),detail:e.description??void 0,tags:[i(Y[e.kind]),e.source===`github`?`★ ${e.stars}`:e.version?`v${e.version}`:``,e.source===`astra`?i(`plugins.origin.astra`):``],installed:C(e.spec,e.name),onInstall:()=>void w(e.spec,e.source===`github`?`github`:e.source===`astra`?`market`:`npm`)},e.spec))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:i(`plugins.searchNote`)})]}):(0,J.jsxs)(J.Fragment,{children:[l.isLoading&&(0,J.jsx)(M,{lines:4}),l.isError&&(0,J.jsx)(j,{tone:`danger`,title:i(`common.error`),children:I(l.error)}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:A.map(e=>(0,J.jsx)($,{title:e.name,subtitle:e.package,icon:(0,J.jsx)(X,{name:e.name,icon:e.icon,kind:e.kind}),detail:e.summary[a]??e.summary.en??e.description??void 0,tags:[i(Y[e.kind]),e.latest?`v${e.latest}`:``,e.origin===`astra`?i(`plugins.origin.astra`):``,e.minAstraVersion?i(`plugins.minVersion`,{version:e.minAstraVersion}):``].filter(Boolean),installed:C(e.package,e.package),onInstall:()=>void w(e.package,`market`)},e.package))}),(0,J.jsx)(`p`,{className:`px-1 text-[12px] text-[var(--text-muted)]`,children:i(`plugins.marketNote`)})]})]})}function $({title:e,subtitle:t,icon:n,detail:r,tags:i,installed:a,onInstall:o}){let{t:s}=_();return(0,J.jsxs)(`div`,{className:`card flex flex-col gap-3 p-4 transition-colors hover:border-[var(--border)]`,children:[(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[n,(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,J.jsx)(`span`,{className:`truncate text-[14px] font-medium`,title:e,children:e}),(0,J.jsx)(`span`,{className:`truncate font-mono text-[11px] text-[var(--text-muted)]`,title:t,children:t})]})]}),(0,J.jsx)(`p`,{className:`line-clamp-2 min-h-[2lh] text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:r??``}),(0,J.jsxs)(`div`,{className:`mt-auto flex items-center gap-1.5`,children:[i.filter(Boolean).map(e=>(0,J.jsx)(D,{children:e},e)),(0,J.jsx)(`span`,{className:`flex-1`}),a?(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-[var(--success)]`,children:[(0,J.jsx)(h,{className:`size-3.5`}),s(`plugins.installed`)]}):(0,J.jsx)(A,{size:`sm`,variant:`primary`,onClick:o,children:s(`plugins.install`)})]})]})}function Ce({onJob:e}){let{t,locale:r}=_(),{toast:i}=R(),o=a(),s=u(),c=f(),l=o.data?.runtime;return(0,J.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:`Bun`}),l&&(0,J.jsx)(D,{tone:l.path?`green`:`neutral`,children:l.path?t(`plugins.bunReady`):t(`plugins.bunMissing`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.bunDetail`)}),l&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[l.path&&(0,J.jsx)(b,{label:t(`plugins.bunPath`),mono:!0,children:l.path}),l.version&&(0,J.jsx)(b,{label:t(`plugins.bunVersion`),mono:!0,children:l.version}),(0,J.jsx)(b,{label:t(`plugins.bunTarget`),mono:!0,children:l.target??t(`plugins.bunNoBuild`)})]}),l?.error&&(0,J.jsx)(j,{tone:`danger`,title:t(`plugins.bunFailed`),children:l.error}),l&&!l.path&&(0,J.jsx)(`div`,{children:(0,J.jsx)(A,{variant:`primary`,disabled:l.downloading||c.isPending||!l.target,onClick:()=>c.mutate(void 0,{onSuccess:t=>e(t.id),onError:e=>i(I(e),`error`)}),children:l.downloading?t(`plugins.bunDownloading`):t(`plugins.bunDownload`,{version:l.version??``})})})]}),(0,J.jsxs)(`section`,{className:`card flex flex-col gap-3 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h3`,{className:`flex-1 text-[14px] font-medium`,children:t(`plugins.host`)}),s.data&&(0,J.jsx)(D,{tone:s.data.running?`green`:`neutral`,children:s.data.running?t(`plugins.hostRunning`):t(`plugins.hostStopped`)})]}),(0,J.jsx)(`p`,{className:`text-[12px] leading-relaxed text-[var(--text-secondary)]`,children:t(`plugins.hostDetail`)}),s.data?.startError&&(0,J.jsx)(j,{tone:`danger`,title:t(`plugins.hostStartFailed`),children:s.data.startError}),s.data?.goneReason&&(0,J.jsx)(j,{tone:`warning`,title:t(`plugins.hostGone`),children:s.data.goneReason}),s.data&&s.data.plugins.length>0&&(0,J.jsx)(`div`,{className:`flex flex-col gap-1`,children:s.data.plugins.map(e=>(0,J.jsx)(b,{label:e.spec,mono:!0,children:e.error?t(`plugins.hostPluginError`,{error:e.error}):e.provides.join(`, `)||`—`},e.spec))}),s.data?.recent&&s.data.recent.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 border-t border-[var(--border-subtle)] pt-3`,children:[(0,J.jsx)(`h4`,{className:`text-[12px] font-medium text-[var(--text-secondary)]`,children:t(`plugins.hostRecent`)}),s.data.recent.map((e,t)=>(0,J.jsxs)(`div`,{className:`flex items-start gap-2 text-[12px]`,children:[(0,J.jsx)(D,{tone:e.variant===`error`?`red`:e.variant===`warning`?`orange`:e.variant===`success`?`green`:`neutral`,children:n(e.at,r)}),(0,J.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.title&&(0,J.jsxs)(`span`,{className:`font-medium`,children:[e.title,` `]}),e.message]})]},t))]})]}),(0,J.jsxs)(`a`,{className:`flex items-center gap-1 px-1 text-[12px] text-[var(--text-muted)] hover:text-[var(--accent)] lg:col-span-2`,href:`https://github.com/astragate-community/astra-gate-plugins`,target:`_blank`,rel:`noreferrer`,children:[(0,J.jsx)(re,{className:`size-3`}),` astragate-community/astra-gate-plugins`]})]})}export{Z as PluginsPage};
|