@lob-ox/core-darwin-x64 0.0.20 → 0.0.21
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/core.cjs +32 -20
- package/package.json +1 -1
- package/ui-react/assets/{InstancesPage-MGpeXK2D.js → InstancesPage-DTy-dQ-L.js} +1 -1
- package/ui-react/assets/{LanPage-BTX10UvJ.js → LanPage-DGGWJGab.js} +1 -1
- package/ui-react/assets/{OverviewPage-CGolWxj5.js → OverviewPage-FLGxQPCE.js} +1 -1
- package/ui-react/assets/{PluginsPage-BjjSXeun.js → PluginsPage-BBfj4bk7.js} +1 -1
- package/ui-react/assets/{RouterPage-UMIiizkg.js → RouterPage-MZBwIV9n.js} +1 -1
- package/ui-react/assets/{SettingsPage-ByUNpMiY.js → SettingsPage-BkG-APXm.js} +1 -1
- package/ui-react/assets/{TasksPage-DCSwnQcl.js → TasksPage-B50BoixQ.js} +1 -1
- package/ui-react/assets/{openExternal-D76TEieU.js → openExternal-Ayshj45y.js} +1 -1
- package/ui-react/assets/{refresh-cw-gnnGR0ej.js → refresh-cw-GKBYw9-E.js} +1 -1
- package/ui-react/assets/{rocket-w_FQq9IU.js → rocket-cmjG68ou.js} +1 -1
- package/ui-react/assets/{supervisor-DouAeDUQ.js → supervisor-DSBgs_XY.js} +1 -1
- package/ui-react/assets/{supervisor-C-lEz0-6.js → supervisor-DWUbDZTX.js} +3 -3
- package/ui-react/assets/{useSupervisorAction-BdLx_DkH.js → useSupervisorAction-U8T1qRbC.js} +1 -1
- package/ui-react/assets/{widgets-GTNEjznx.js → widgets-DV5fuKzB.js} +1 -1
- package/ui-react/supervisor.html +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as e,F as t,I as n,L as r,N as i,O as a,R as o,S as s,U as c,V as l,_ as u,a as d,d as f,f as p,g as m,l as h,n as g,o as _,p as v,t as y,u as b,v as x,x as S,y as C}from"./supervisor-DouAeDUQ.js";import{a as w,i as T,n as E,s as D,t as O}from"./openExternal-D76TEieU.js";import{n as k,t as A}from"./rocket-w_FQq9IU.js";import{t as j}from"./refresh-cw-gnnGR0ej.js";import{t as M}from"./jobs-CrrY4iBU.js";import{l as N,p as P,t as F,u as I}from"./supervisor-C-lEz0-6.js";import{t as L}from"./useSupervisorAction-BdLx_DkH.js";import{a as R,c as z,i as B,o as V,s as H,t as U}from"./widgets-GTNEjznx.js";import{n as W}from"./format-QeaTKFhQ.js";var ee=i(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),te=i(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),ne=i(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),re=i(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),G=c(l(),1),K=o();function q(e){return e?e.status===`rate-limited`||Number(e.percent)>=100:!1}function J(e){return e?q(e.rolling)||q(e.weekly)||q(e.monthly):!1}function Y(e){return e!=null&&Number.isFinite(Number(e))?Number(e)+`%`:`—`}function ie(e){let t=e.body;if(t&&typeof t==`object`){if(typeof t.error==`string`&&t.error)return t.error;if(typeof t.message==`string`&&t.message)return t.message}return e instanceof Error?e.message:String(e)}function X(e,t,n){if(t.length){let n=t.slice(0,3).map(e=>e.key+`(`+e.error+`)`).join(`;`);a.warning(`已添加 `+e+` 个,`+t.length+` 个失败被丢弃:`+n+(t.length>3?` …`:``))}else a.success(`已添加 `+e+` 个 Key(`+n+`)`)}function Z(e){return!e||!Number.isFinite(e)?``:new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function ae(e){return[...e].sort((e,t)=>{let n=e=>e.selected?0:e.usable&&!J(e.quota)?1:2;return n(e)-n(t)})}var Q=`grid-cols-[minmax(0,1fr)_230px_84px]`;function oe({onRegisterActions:t}){let{snap:i}=y(),{busy:a,run:o}=L(),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),f=i.router,p=i.providers;(0,G.useEffect)(()=>(t?.({onAdd:()=>c(!0),onDelete:()=>u(!0)}),()=>t?.(null)),[t]);function m(e,t,n){return o(e,t,{success:n})}let h=p?.providers??[];return(0,K.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,K.jsxs)(U,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border/70 px-5 py-3.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(z,{tone:f?.running?`ok`:`off`,ping:!!f?.running}),(0,K.jsx)(`strong`,{className:`text-xl font-semibold tracking-[-0.01em] text-foreground`,children:f?.running?`路由运行中`:`路由已停止`})]}),(0,K.jsx)(n,{"aria-label":f?.running?`停止路由`:`启动路由`,className:r(`px-1`,f?.running?`text-status-error`:`text-primary`),disabled:a===`sw`,onClick:()=>void m(`sw`,()=>f?.running?d.lifecycleStop(`router`):d.lifecycleStart(`router`),f?.running?`路由已停止`:`路由已启动`),title:f?.running?`停止路由`:`启动路由`,variant:`ghost`,children:f?.running?(0,K.jsx)(k,{className:`size-6`}):(0,K.jsx)(A,{className:`size-6`})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 divide-y divide-border/60 sm:grid-cols-2 sm:divide-y-0 lg:grid-cols-4 lg:divide-x lg:divide-border/60`,children:[(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(P,{className:`size-4`}),label:`总请求 / 失败`,value:W(f?.usage?.requests)+` / `+W(f?.usage?.errors),mono:!0})}),(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(e,{className:`size-4`}),label:`总 Tokens`,value:W(f?.usage?.totalTokens),mono:!0})}),(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(re,{className:`size-4`}),label:`Prompt / Completion`,value:W(f?.usage?.promptTokens)+` / `+W(f?.usage?.completionTokens),mono:!0})}),(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(te,{className:`size-4`}),label:`估算费用`,value:f?.usage?.costUsd?`$`+Number(f.usage.costUsd).toFixed(4):`—`,mono:!0,warn:!f?.usage?.costUsd})})]})]}),h.length?(0,K.jsx)(`div`,{className:`grid gap-4 @min-[900px]:grid-cols-2`,children:h.map(e=>(0,K.jsx)(ce,{p:e,proxyApps:p?.proxyApps??[],busy:a===e.id,onAction:m},e.id))}):(0,K.jsx)(`div`,{className:`grid min-h-[200px] place-items-center rounded-lg border border-dashed border-border text-center`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(P,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`尚未添加供应商`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`点击「添加供应商」录入 API Key / Command Code`})]})}),(0,K.jsx)(fe,{open:s,onOpenChange:c,presets:p?.presets??[],proxyApps:p?.proxyApps??[],onDone:()=>g.refresh()}),(0,K.jsx)(se,{open:l,onOpenChange:u,providers:h})]})}function se({open:e,onOpenChange:r,providers:i}){let[o,c]=(0,G.useState)(null),l=t();async function u(e){if(await l({title:`删除供应商「`+e.name+`」?`,description:`其下全部账号与 Key 将被移除,不可恢复。`,confirmText:`删除`,tone:`destructive`})){c(e.id);try{await d.providerRemove(e.id),a.success(`已删除供应商「`+e.name+`」`),await g.refresh()}catch(e){a.error(String(e))}finally{c(null)}}}return(0,K.jsx)(x,{open:e,onOpenChange:r,children:(0,K.jsxs)(C,{className:`max-w-[440px]`,children:[(0,K.jsx)(S,{children:(0,K.jsx)(s,{children:`删除供应商`})}),(0,K.jsx)(`div`,{className:`grid gap-1.5`,children:i.length?i.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.kind===`proxy`?`反代`:`直连`,` · `,(e.accounts??[]).length,` 账号`]})]}),(0,K.jsxs)(n,{disabled:o===e.id,onClick:()=>void u(e),size:`chip`,variant:`destructive`,children:[o===e.id?(0,K.jsx)(j,{className:`size-3 animate-spin`}):(0,K.jsx)(N,{className:`size-3`}),`删除`]})]},e.id)):(0,K.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`暂无供应商`})}),(0,K.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,K.jsx)(n,{onClick:()=>r(!1),variant:`outline`,children:`关闭`})})]})})}function ce({p:e,proxyApps:t,busy:i,onAction:o}){let s=ae(e.accounts??[]),c=s.find(e=>e.selected)||s.find(e=>e.usable&&!J(e.quota))||s[0],[l,u]=(0,G.useState)(!1),f=e.kind===`proxy`?(t??[]).find(t=>t.id===e.proxyAppId)??null:null,p=e.apiBase||(e.apiPort?`http://127.0.0.1:`+e.apiPort+`/v1`:null);return(0,K.jsxs)(U,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border/70 bg-muted px-5 py-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-sm font-semibold text-foreground`,children:e.name}),e.kind===`proxy`&&f&&f.installed?f.updateAvailable?(0,K.jsxs)(n,{className:`gap-1 rounded-full px-2.5 text-xs text-warning`,disabled:i,onClick:()=>void o(`proxy-upd-`+e.id,async()=>{let t=e.proxyAppId,n=await d.proxyUpdateApply(t);if(n.ok===!1){a.error(n.error||`提交失败`);return}let r=a.loading(`正在更新 `+e.name+` 的全部实例…`),i=await M(()=>d.proxyUpdateStatus(t),{onTick:t=>{let n=t?.steps||[],i=n.filter(e=>e.state===`done`).length;n.length&&a.loading(`正在更新 `+e.name+`…(`+i+`/`+n.length+` 实例)`,{id:r})}}),o=i.snapshot;i.state===`done`?a.success(`更新完成`+(o?.restarted?`(已重启 `+o.restarted+` 个实例)`:``),{id:r}):i.state===`failed`?a.error(`更新失败:`+(i.error||(o?.errors?o.errors+` 个实例失败`:`未知原因`)),{id:r}):i.state===`canceled`?a.warning(`更新已取消`,{id:r}):a.error(`更新未完成:`+(i.error||`超时未完成,可稍后查看`),{id:r}),await g.refresh()},void 0),size:`chip`,title:`检测到新版本,点击更新该应用全部实例`,variant:`outline`,children:[(0,K.jsx)(j,{className:`size-3`}),`更新 v`,f.latest]}):(0,K.jsxs)(n,{className:`gap-1 rounded-full px-2.5 text-xs font-mono text-muted-foreground`,disabled:i,onClick:()=>{o(`proxy-chk-`+e.id,async()=>{let t=await d.proxyUpdateCheck();if(await g.refresh(),!t.ok){a.error(t.error||`版本检测失败`);return}let n=t.versions?.[e.proxyAppId||``]||null,r=f.installed;a.info(n&&n!==r?`发现新版本 v`+n+`,点击版本胶囊更新`:`已是最新版本 v`+r)},void 0)},size:`chip`,title:`检测是否有新版本`,variant:`outline`,children:[`v`,f.installed,(0,K.jsx)(j,{className:r(`size-3`,i&&`animate-spin`)})]}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5`,children:[(0,K.jsxs)(n,{disabled:i,onClick:()=>u(!0),size:`sm`,variant:`outline`,children:[(0,K.jsx)(I,{className:`size-3.5`}),`添加`]}),e.activated?(0,K.jsxs)(n,{disabled:i,onClick:()=>void o(`deact`,()=>d.providerDeactivate(e.id).then(()=>void 0),`已停用供应商(资源已回收)`),size:`sm`,variant:`outline`,children:[(0,K.jsx)(k,{className:`size-3.5`}),`停用`]}):(0,K.jsxs)(n,{disabled:i,onClick:()=>void o(`act`,()=>d.providerActivate(e.id).then(()=>void 0),`已启用供应商`),size:`sm`,variant:`outline`,children:[(0,K.jsx)(A,{className:`size-3.5`}),`启用`]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-5 py-2.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`API 地址`}),(0,K.jsx)(`div`,{className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md border border-border bg-card px-2.5`,children:e.activated&&p?(0,K.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:p}):(0,K.jsx)(`span`,{className:`truncate text-xs text-muted-foreground/70`,children:`服务未启用`})}),e.activated&&p?(0,K.jsxs)(n,{onClick:()=>void F(p||``,`已复制 API 地址`),size:`sm`,title:`复制该供应商 API 地址`,variant:`outline`,children:[(0,K.jsx)(D,{className:`size-3.5`}),`复制`]}):null]}),c?(0,K.jsx)($,{acc:c,busy:i,p:e,onAction:o}):(0,K.jsx)(`div`,{className:`px-5 py-3 text-xs text-muted-foreground`,children:`暂无账号数据`}),s.length?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col border-t border-border/60`,children:[(0,K.jsxs)(`div`,{className:r(`grid items-center gap-2 border-b border-border/60 bg-muted/60 px-5 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,Q),children:[(0,K.jsx)(`span`,{children:`Key`}),(0,K.jsx)(`span`,{className:`text-center`,children:`用量`}),(0,K.jsx)(`span`,{className:`text-center`,children:`操作`})]}),(0,K.jsx)(`div`,{className:`max-h-[288px] min-h-0 overflow-y-auto overscroll-contain`,children:s.map((t,n)=>(0,K.jsx)(`div`,{className:r(n>0&&`border-t border-border/50`),children:(0,K.jsx)(ue,{a:t,p:e,busy:i,onAction:o})},t.keyId))})]}):(0,K.jsx)(`p`,{className:`border-t border-border/60 px-5 py-3 text-xs text-muted-foreground`,children:`暂无 Keys — 点「添加」录入`}),(0,K.jsx)(le,{open:l,onOpenChange:u,p:e})]})}function le({open:e,onOpenChange:r,p:i}){let o=i.accounts??[],c=t(),[l,u]=(0,G.useState)(``),[f,p]=(0,G.useState)(!1),[h,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(``),D=i.kind===`proxy`;(0,G.useEffect)(()=>{e&&b(``)},[e]);async function k(){v(!0);try{let e=await E(()=>d.proxyLoginStart());if(e.ok!==!0){b(``);return}b(w(e));let t=T(e);t&&a.warning(t,{duration:12e3});let n=await d.proxyLoginWait(e.waitMs??18e4);if(!n.ok||!n.apiKey){a.error(n.error||`登录未完成`);return}await d.proxyAddKey(i.id,n.apiKey),a.success(`已通过登录添加账号 `+(n.userName||n.keyName||``)),r(!1),await g.refresh()}catch(e){a.error(String(e))}finally{v(!1)}}async function A(){let e=l.split(/[,;\s]+/).map(e=>e.trim()).filter(Boolean);p(!0);try{if(D){let t=0,n=[],r=``;for(let a of e)try{let e=await d.proxyAddKey(i.id,a);if(t++,e&&e.limited===`credits`){let t=e.account?.limit?.recovery;r=`;其中有账号额度用尽`+(t?.type===`at`&&t.at?`(预计 `+Z(t.at)+` 自动恢复)`:`(等待月度重置后自动恢复)`)}}catch(e){n.push({key:a,error:ie(e)})}X(t,n,`反代账号`+r)}else{let t=await d.providerKeysSet(i.id,{add:e});if(t.ok===!1){a.error(t.error||`添加失败`);return}X(typeof t.added==`number`?t.added:e.length,t.discardedKeys||[],`API Key`)}u(``),r(!1),await g.refresh()}catch(e){a.error(String(e))}finally{p(!1)}}async function j(e){if(await c({title:`移除 Key `+e+`?`,description:`该凭据将从供应商中移除,不可恢复。`,confirmText:`移除`,tone:`destructive`})){p(!0);try{if(D){let t=o.find(t=>t.maskedKey===e||e.startsWith(t.maskedKey));t&&await d.proxyRemoveKey(i.id,t.keyId)}else{let t=await d.providerKeysSet(i.id,{removeMasked:[e]});if(t.ok===!1){a.error(t.error||`移除失败`);return}}a.success(`已移除`),r(!1),await g.refresh()}catch(e){a.error(String(e))}finally{p(!1)}}}return(0,K.jsx)(x,{open:e,onOpenChange:r,children:(0,K.jsxs)(C,{className:`max-w-[440px]`,children:[(0,K.jsx)(S,{children:(0,K.jsxs)(s,{children:[`添加 / 管理 Key — `,i.name]})}),(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[D?(0,K.jsxs)(`div`,{className:`grid gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`一键登录`}),(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:`浏览器打开 Command Code 授权,自动添加账号`})]}),(0,K.jsx)(n,{disabled:h||f,onClick:()=>void k(),size:`sm`,children:h?`等待授权…`:`一键登录`})]}),y?(0,K.jsxs)(`div`,{className:`grid gap-1 border-t border-border/60 pt-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:h?`等待授权中。窗口没弹出或停在空白页时,复制这一行在你的浏览器里打开:`:`本轮授权地址(窗口停在空白页时复制这一行手动打开):`}),(0,K.jsx)(O,{url:y})]}):null]}):null,(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[D?`已录入账号(反代)`:`已录入 API Key`,`(`,o.length,`)`]}),o.length?(0,K.jsx)(`div`,{className:`grid max-h-[180px] gap-1 overflow-auto`,children:o.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 bg-muted/40 px-2.5 py-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`code`,{className:`truncate font-mono text-xs`,children:e.maskedKey}),e.selected?(0,K.jsx)(V,{tone:`ok`,children:`当前`}):null]}),(0,K.jsx)(n,{size:`chip`,variant:`ghost`,className:`text-destructive`,disabled:f,onClick:()=>void j(e.maskedKey),title:`移除该 Key`,children:(0,K.jsx)(N,{className:`size-3.5`})})]},e.keyId))}):(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`尚未录入 `,D?`账号`:`Key`]})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsxs)(m,{className:`text-xs text-muted-foreground`,children:[`添加 `,D?`账号 Key / Command Code`:`API Key`,`(每行一个,支持逗号/分号分隔)`]}),(0,K.jsx)(_,{className:`h-20 resize-none font-mono text-xs`,placeholder:D?`sk-... 或 Command Code,每行一个`:`sk-... 每行一个`,value:l,onChange:e=>u(e.target.value)})]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,K.jsx)(n,{onClick:()=>r(!1),variant:`outline`,children:`取消`}),(0,K.jsx)(n,{disabled:f||!l.trim(),onClick:()=>void A(),children:f?`保存中…`:`添加`})]})]})})}function $({acc:t,busy:i,p:a,onAction:o}){let s=t.quota,c=!!t.selected,l=!!t.locked,u=Y(s?.monthly?.percent);return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-5 py-3`,children:[(0,K.jsxs)(`div`,{className:`grid min-w-[180px] content-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c?l?`当前账号(锁定)`:`当前在用账号`:`选择账号`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(R,{className:`max-w-[150px]`,children:t.maskedKey}),c?(0,K.jsxs)(n,{className:`gap-1 px-2`,disabled:i,onClick:()=>o(`refresh`,()=>d.providerRefresh(a.id).then(()=>void 0),`额度已刷新`),size:`chip`,variant:`outline`,children:[(0,K.jsx)(j,{className:r(`size-3`,i&&`animate-spin`)}),`刷新`]}):null]})]}),(0,K.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-cols-3 items-stretch gap-2`,children:[(0,K.jsx)(H,{icon:(0,K.jsx)(j,{className:`size-3.5`}),label:`5小时`,value:Y(s?.rolling?.percent),danger:q(s?.rolling)}),(0,K.jsx)(H,{icon:(0,K.jsx)(e,{className:`size-3.5`}),label:`每周`,value:Y(s?.weekly?.percent),danger:q(s?.weekly)}),(0,K.jsx)(H,{icon:(0,K.jsx)(P,{className:`size-3.5`}),label:`每月`,value:u,danger:q(s?.monthly)})]})]})}function ue({a:e,p:t,busy:i,onAction:a}){let o=!!e.selected,s=e.instanceStatus===`frozen`?`frozen`:e.status||``,c=e.limit?.kind,l=s===`frozen`||!!c||!o&&J(e.quota),u=c===`credits`?e.limit?.recovery?.type===`at`&&e.limit?.recovery?.at?`额度用尽(预计 ${Z(e.limit.recovery.at)} 月度重置后自动恢复)`:`额度用尽(待月度重置后自动恢复)`:c===`window`?e.limit?.reason??`时间窗额度已用尽(到 resetAt 自动恢复)`:c===`banned`?`账号被封禁`:null,f=W(e.requests||0)+` 次 · `+W(e.totalTokens||0)+` tok`,[p,m]=(0,G.useState)(!1),h;return h=l&&!o?(0,K.jsxs)(n,{size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,onClick:()=>m(!0),title:u??`查看该账号限额情况`,children:[(0,K.jsx)(ee,{className:`size-3.5`}),`限额`]}):o?(0,K.jsxs)(n,{disabled:i,onClick:()=>a(`refresh`,()=>d.providerRefresh(t.id).then(()=>void 0),`额度已刷新`),size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,children:[(0,K.jsx)(j,{className:r(`size-3.5`,i&&`animate-spin`)}),`刷新`]}):(0,K.jsxs)(n,{disabled:i,size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,onClick:()=>{t.kind===`proxy`?a(`sel`,()=>d.proxySelect(t.id,e.keyId).then(()=>void 0),`已切换账号`):a(`use`,()=>d.providerKeyUse(t.id,e.keyId).then(()=>void 0),`已锁定 Key`)},children:[(0,K.jsx)(ne,{className:`size-3.5`}),`切换`]}),(0,K.jsxs)(`div`,{className:r(`grid items-center gap-2 px-5 py-2.5 hover:bg-muted/40`,Q,o&&`bg-muted/60 shadow-[inset_3px_0_0_var(--primary)]`),children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(R,{children:e.maskedKey}),s===`registering`?(0,K.jsx)(V,{tone:`off`,children:`检测中…`}):null,s===`banned`?(0,K.jsx)(V,{tone:`err`,children:`封号`}):null,c===`credits`?(0,K.jsx)(`span`,{title:e.limit?.reason??`额度用尽`,children:(0,K.jsx)(V,{tone:`err`,children:`额度用尽`})}):null,c===`window`?(0,K.jsx)(`span`,{title:e.limit?.reason??`时间窗额度已用尽`,children:(0,K.jsx)(V,{tone:`warn`,children:`窗口用尽`})}):null]}),(0,K.jsx)(`span`,{className:`truncate text-right text-xs tabular-nums text-muted-foreground`,title:f,children:f}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:h}),(0,K.jsx)(de,{open:p,onOpenChange:m,a:e,p:t})]})}function de({open:e,onOpenChange:t,a:r,p:i}){let a=r.quota,o=(()=>{let e=a?.credits?.monthlyCredits,t=a?.monthlyRemaining,n=e!=null&&Number.isFinite(Number(e))?Number(e):t!=null&&Number.isFinite(Number(t))?Number(t):null;return n===null?null:`剩余 $`+n.toFixed(2)})(),c=(e,t,n)=>(0,K.jsxs)(`div`,{className:`grid gap-1 rounded-md border border-border/70 bg-muted/40 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:t}),(0,K.jsx)(V,{tone:q(e)?`err`:`ok`,children:q(e)?`已限额`:`正常`})]}),(0,K.jsx)(`strong`,{className:`text-xl font-semibold tabular-nums text-foreground`,children:Y(e?.percent)}),n?(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:n}):null,e?.resetsAt?(0,K.jsxs)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:[`重置:`,new Date(e.resetsAt).toLocaleString(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})]}):null]});return(0,K.jsx)(x,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`max-w-[420px]`,children:[(0,K.jsx)(S,{children:(0,K.jsx)(s,{children:`限额详情`})}),(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:`账号`}),(0,K.jsx)(`code`,{className:`font-mono`,children:r.maskedKey}),(0,K.jsx)(`span`,{className:`ml-auto text-xs`,children:i.name})]}),a?(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[c(a.rolling,`5小时`),c(a.weekly,`每周`),c(a.monthly,`每月`),a.credits||a.monthlyRemaining!=null?(0,K.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1 rounded-md border border-border/70 bg-muted/40 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`月度额度(Command)`}),a.credits?.belowThreshold?(0,K.jsx)(V,{tone:`warn`,children:`低于充值线`}):a.credits&&Number.isFinite(Number(a.credits.monthlyCredits))&&Number(a.credits.monthlyCredits)<=0?(0,K.jsx)(V,{tone:`err`,children:`额度用尽`}):(0,K.jsx)(V,{tone:`ok`,children:`正常`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:Number(a.monthlyResetAt)>Date.now()?`月度额度预计 ${Z(Number(a.monthlyResetAt))} 重置(随订阅续期)`:`月度额度已于 ${Z(Number(a.monthlyResetAt))} 重置`}),o?(0,K.jsx)(`span`,{className:`text-sm font-semibold tabular-nums text-foreground`,children:o}):null]})]}):null]}):(0,K.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`暂无额度数据 — 点「刷新」获取`}),a?(0,K.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`当前用量统计:`,W(r.requests||0),` 次请求 · `,W(r.totalTokens||0),` tokens`,a.monthly?.resetsAt?`。最迟限额将于月窗口重置后自动解除。`:``]}):null]}),(0,K.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,K.jsx)(n,{onClick:()=>t(!1),variant:`outline`,children:`关闭`})})]})})}function fe({open:e,onOpenChange:t,presets:i,proxyApps:o,onDone:c}){let[l,g]=(0,G.useState)(``),[_,y]=(0,G.useState)(``),[w,T]=(0,G.useState)(``),[E,D]=(0,G.useState)(`preset`),[O,k]=(0,G.useState)(!1);async function A(){if(E===`preset`&&!l){a.error(`请选择供应商`);return}if(E===`proxy`&&!_){a.error(`请选择反代应用`);return}k(!0);try{let e=E===`preset`?await d.providerAdd({presetId:l,name:w||void 0,keys:[]}):await d.providerAdd({kind:`proxy`,appId:_,name:w||void 0,keys:[]});if(e.ok===!1){a.error(e.error||`添加失败`);return}a.success(`已添加供应商,请在卡片上点「添加」录入 Key`),t(!1),T(``),g(``),y(``),c()}catch(e){a.error(String(e))}finally{k(!1)}}let j=(i??[]).find(e=>e.id===l);return(0,K.jsx)(x,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`max-w-[420px]`,children:[(0,K.jsx)(S,{children:(0,K.jsx)(s,{children:`添加供应商`})}),(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[(0,K.jsx)(`div`,{className:`flex gap-1.5 rounded-lg bg-muted p-1`,children:[`preset`,`proxy`].map(e=>(0,K.jsx)(n,{className:r(`flex-1 rounded-md font-medium`,E===e?`bg-card text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-card/60 hover:text-foreground`),onClick:()=>D(e),size:`sm`,variant:`ghost`,children:e===`preset`?`直连预设`:`反代应用`},e))}),E===`preset`?(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(m,{children:`供应商`}),(0,K.jsxs)(h,{value:l,onValueChange:g,children:[(0,K.jsx)(p,{className:`w-full`,children:(0,K.jsx)(v,{placeholder:`-- 选择供应商 --`})}),(0,K.jsx)(b,{children:(i??[]).map(e=>(0,K.jsx)(f,{value:e.id,children:e.name},e.id))})]}),j?.note?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:j.note}):null]}):(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(m,{children:`反代应用`}),(0,K.jsxs)(h,{value:_,onValueChange:y,children:[(0,K.jsx)(p,{className:`w-full`,children:(0,K.jsx)(v,{placeholder:`-- 选择应用 --`})}),(0,K.jsx)(b,{children:(o??[]).map(e=>(0,K.jsx)(f,{value:e.id,children:e.name},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(m,{children:`供应商名称(可选)`}),(0,K.jsx)(u,{placeholder:`自定义名称,如:Open Code ZEN`,value:w,onChange:e=>T(e.target.value)})]}),(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`只添加供应商不填 Key;添加后在供应商卡片上点「添加」录入 API Key。`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,K.jsx)(n,{onClick:()=>t(!1),variant:`outline`,children:`取消`}),(0,K.jsx)(n,{disabled:O,onClick:()=>void A(),children:O?`添加中…`:`添加供应商`})]})]})})}export{oe as RouterPage};
|
|
1
|
+
import{A as e,F as t,I as n,L as r,N as i,O as a,R as o,S as s,U as c,V as l,_ as u,a as d,d as f,f as p,g as m,l as h,n as g,o as _,p as v,t as y,u as b,v as x,x as S,y as C}from"./supervisor-DSBgs_XY.js";import{a as w,i as T,n as E,s as D,t as O}from"./openExternal-Ayshj45y.js";import{n as k,t as A}from"./rocket-cmjG68ou.js";import{t as j}from"./refresh-cw-GKBYw9-E.js";import{t as M}from"./jobs-CrrY4iBU.js";import{l as N,p as P,t as F,u as I}from"./supervisor-DWUbDZTX.js";import{t as L}from"./useSupervisorAction-U8T1qRbC.js";import{a as R,c as z,i as B,o as V,s as H,t as U}from"./widgets-DV5fuKzB.js";import{n as W}from"./format-QeaTKFhQ.js";var ee=i(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),te=i(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),ne=i(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),re=i(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),G=c(l(),1),K=o();function q(e){return e?e.status===`rate-limited`||Number(e.percent)>=100:!1}function J(e){return e?q(e.rolling)||q(e.weekly)||q(e.monthly):!1}function Y(e){return e!=null&&Number.isFinite(Number(e))?Number(e)+`%`:`—`}function ie(e){let t=e.body;if(t&&typeof t==`object`){if(typeof t.error==`string`&&t.error)return t.error;if(typeof t.message==`string`&&t.message)return t.message}return e instanceof Error?e.message:String(e)}function X(e,t,n){if(t.length){let n=t.slice(0,3).map(e=>e.key+`(`+e.error+`)`).join(`;`);a.warning(`已添加 `+e+` 个,`+t.length+` 个失败被丢弃:`+n+(t.length>3?` …`:``))}else a.success(`已添加 `+e+` 个 Key(`+n+`)`)}function Z(e){return!e||!Number.isFinite(e)?``:new Date(e).toLocaleString(`zh-CN`,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function ae(e){return[...e].sort((e,t)=>{let n=e=>e.selected?0:e.usable&&!J(e.quota)?1:2;return n(e)-n(t)})}var Q=`grid-cols-[minmax(0,1fr)_230px_84px]`;function oe({onRegisterActions:t}){let{snap:i}=y(),{busy:a,run:o}=L(),[s,c]=(0,G.useState)(!1),[l,u]=(0,G.useState)(!1),f=i.router,p=i.providers;(0,G.useEffect)(()=>(t?.({onAdd:()=>c(!0),onDelete:()=>u(!0)}),()=>t?.(null)),[t]);function m(e,t,n){return o(e,t,{success:n})}let h=p?.providers??[];return(0,K.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,K.jsxs)(U,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border/70 px-5 py-3.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(z,{tone:f?.running?`ok`:`off`,ping:!!f?.running}),(0,K.jsx)(`strong`,{className:`text-xl font-semibold tracking-[-0.01em] text-foreground`,children:f?.running?`路由运行中`:`路由已停止`})]}),(0,K.jsx)(n,{"aria-label":f?.running?`停止路由`:`启动路由`,className:r(`px-1`,f?.running?`text-status-error`:`text-primary`),disabled:a===`sw`,onClick:()=>void m(`sw`,()=>f?.running?d.lifecycleStop(`router`):d.lifecycleStart(`router`),f?.running?`路由已停止`:`路由已启动`),title:f?.running?`停止路由`:`启动路由`,variant:`ghost`,children:f?.running?(0,K.jsx)(k,{className:`size-6`}):(0,K.jsx)(A,{className:`size-6`})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 divide-y divide-border/60 sm:grid-cols-2 sm:divide-y-0 lg:grid-cols-4 lg:divide-x lg:divide-border/60`,children:[(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(P,{className:`size-4`}),label:`总请求 / 失败`,value:W(f?.usage?.requests)+` / `+W(f?.usage?.errors),mono:!0})}),(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(e,{className:`size-4`}),label:`总 Tokens`,value:W(f?.usage?.totalTokens),mono:!0})}),(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(re,{className:`size-4`}),label:`Prompt / Completion`,value:W(f?.usage?.promptTokens)+` / `+W(f?.usage?.completionTokens),mono:!0})}),(0,K.jsx)(`div`,{className:`px-5 py-3.5`,children:(0,K.jsx)(B,{icon:(0,K.jsx)(te,{className:`size-4`}),label:`估算费用`,value:f?.usage?.costUsd?`$`+Number(f.usage.costUsd).toFixed(4):`—`,mono:!0,warn:!f?.usage?.costUsd})})]})]}),h.length?(0,K.jsx)(`div`,{className:`grid gap-4 @min-[900px]:grid-cols-2`,children:h.map(e=>(0,K.jsx)(ce,{p:e,proxyApps:p?.proxyApps??[],busy:a===e.id,onAction:m},e.id))}):(0,K.jsx)(`div`,{className:`grid min-h-[200px] place-items-center rounded-lg border border-dashed border-border text-center`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(P,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`尚未添加供应商`}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`点击「添加供应商」录入 API Key / Command Code`})]})}),(0,K.jsx)(fe,{open:s,onOpenChange:c,presets:p?.presets??[],proxyApps:p?.proxyApps??[],onDone:()=>g.refresh()}),(0,K.jsx)(se,{open:l,onOpenChange:u,providers:h})]})}function se({open:e,onOpenChange:r,providers:i}){let[o,c]=(0,G.useState)(null),l=t();async function u(e){if(await l({title:`删除供应商「`+e.name+`」?`,description:`其下全部账号与 Key 将被移除,不可恢复。`,confirmText:`删除`,tone:`destructive`})){c(e.id);try{await d.providerRemove(e.id),a.success(`已删除供应商「`+e.name+`」`),await g.refresh()}catch(e){a.error(String(e))}finally{c(null)}}}return(0,K.jsx)(x,{open:e,onOpenChange:r,children:(0,K.jsxs)(C,{className:`max-w-[440px]`,children:[(0,K.jsx)(S,{children:(0,K.jsx)(s,{children:`删除供应商`})}),(0,K.jsx)(`div`,{className:`grid gap-1.5`,children:i.length?i.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,K.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.kind===`proxy`?`反代`:`直连`,` · `,(e.accounts??[]).length,` 账号`]})]}),(0,K.jsxs)(n,{disabled:o===e.id,onClick:()=>void u(e),size:`chip`,variant:`destructive`,children:[o===e.id?(0,K.jsx)(j,{className:`size-3 animate-spin`}):(0,K.jsx)(N,{className:`size-3`}),`删除`]})]},e.id)):(0,K.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`暂无供应商`})}),(0,K.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,K.jsx)(n,{onClick:()=>r(!1),variant:`outline`,children:`关闭`})})]})})}function ce({p:e,proxyApps:t,busy:i,onAction:o}){let s=ae(e.accounts??[]),c=s.find(e=>e.selected)||s.find(e=>e.usable&&!J(e.quota))||s[0],[l,u]=(0,G.useState)(!1),f=e.kind===`proxy`?(t??[]).find(t=>t.id===e.proxyAppId)??null:null,p=e.apiBase||(e.apiPort?`http://127.0.0.1:`+e.apiPort+`/v1`:null);return(0,K.jsxs)(U,{className:`flex min-h-0 flex-col overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border/70 bg-muted px-5 py-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`strong`,{className:`truncate text-sm font-semibold text-foreground`,children:e.name}),e.kind===`proxy`&&f&&f.installed?f.updateAvailable?(0,K.jsxs)(n,{className:`gap-1 rounded-full px-2.5 text-xs text-warning`,disabled:i,onClick:()=>void o(`proxy-upd-`+e.id,async()=>{let t=e.proxyAppId,n=await d.proxyUpdateApply(t);if(n.ok===!1){a.error(n.error||`提交失败`);return}let r=a.loading(`正在更新 `+e.name+` 的全部实例…`),i=await M(()=>d.proxyUpdateStatus(t),{onTick:t=>{let n=t?.steps||[],i=n.filter(e=>e.state===`done`).length;n.length&&a.loading(`正在更新 `+e.name+`…(`+i+`/`+n.length+` 实例)`,{id:r})}}),o=i.snapshot;i.state===`done`?a.success(`更新完成`+(o?.restarted?`(已重启 `+o.restarted+` 个实例)`:``),{id:r}):i.state===`failed`?a.error(`更新失败:`+(i.error||(o?.errors?o.errors+` 个实例失败`:`未知原因`)),{id:r}):i.state===`canceled`?a.warning(`更新已取消`,{id:r}):a.error(`更新未完成:`+(i.error||`超时未完成,可稍后查看`),{id:r}),await g.refresh()},void 0),size:`chip`,title:`检测到新版本,点击更新该应用全部实例`,variant:`outline`,children:[(0,K.jsx)(j,{className:`size-3`}),`更新 v`,f.latest]}):(0,K.jsxs)(n,{className:`gap-1 rounded-full px-2.5 text-xs font-mono text-muted-foreground`,disabled:i,onClick:()=>{o(`proxy-chk-`+e.id,async()=>{let t=await d.proxyUpdateCheck();if(await g.refresh(),!t.ok){a.error(t.error||`版本检测失败`);return}let n=t.versions?.[e.proxyAppId||``]||null,r=f.installed;a.info(n&&n!==r?`发现新版本 v`+n+`,点击版本胶囊更新`:`已是最新版本 v`+r)},void 0)},size:`chip`,title:`检测是否有新版本`,variant:`outline`,children:[`v`,f.installed,(0,K.jsx)(j,{className:r(`size-3`,i&&`animate-spin`)})]}):null]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5`,children:[(0,K.jsxs)(n,{disabled:i,onClick:()=>u(!0),size:`sm`,variant:`outline`,children:[(0,K.jsx)(I,{className:`size-3.5`}),`添加`]}),e.activated?(0,K.jsxs)(n,{disabled:i,onClick:()=>void o(`deact`,()=>d.providerDeactivate(e.id).then(()=>void 0),`已停用供应商(资源已回收)`),size:`sm`,variant:`outline`,children:[(0,K.jsx)(k,{className:`size-3.5`}),`停用`]}):(0,K.jsxs)(n,{disabled:i,onClick:()=>void o(`act`,()=>d.providerActivate(e.id).then(()=>void 0),`已启用供应商`),size:`sm`,variant:`outline`,children:[(0,K.jsx)(A,{className:`size-3.5`}),`启用`]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 px-5 py-2.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`API 地址`}),(0,K.jsx)(`div`,{className:`flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md border border-border bg-card px-2.5`,children:e.activated&&p?(0,K.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:p}):(0,K.jsx)(`span`,{className:`truncate text-xs text-muted-foreground/70`,children:`服务未启用`})}),e.activated&&p?(0,K.jsxs)(n,{onClick:()=>void F(p||``,`已复制 API 地址`),size:`sm`,title:`复制该供应商 API 地址`,variant:`outline`,children:[(0,K.jsx)(D,{className:`size-3.5`}),`复制`]}):null]}),c?(0,K.jsx)($,{acc:c,busy:i,p:e,onAction:o}):(0,K.jsx)(`div`,{className:`px-5 py-3 text-xs text-muted-foreground`,children:`暂无账号数据`}),s.length?(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-col border-t border-border/60`,children:[(0,K.jsxs)(`div`,{className:r(`grid items-center gap-2 border-b border-border/60 bg-muted/60 px-5 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,Q),children:[(0,K.jsx)(`span`,{children:`Key`}),(0,K.jsx)(`span`,{className:`text-center`,children:`用量`}),(0,K.jsx)(`span`,{className:`text-center`,children:`操作`})]}),(0,K.jsx)(`div`,{className:`max-h-[288px] min-h-0 overflow-y-auto overscroll-contain`,children:s.map((t,n)=>(0,K.jsx)(`div`,{className:r(n>0&&`border-t border-border/50`),children:(0,K.jsx)(ue,{a:t,p:e,busy:i,onAction:o})},t.keyId))})]}):(0,K.jsx)(`p`,{className:`border-t border-border/60 px-5 py-3 text-xs text-muted-foreground`,children:`暂无 Keys — 点「添加」录入`}),(0,K.jsx)(le,{open:l,onOpenChange:u,p:e})]})}function le({open:e,onOpenChange:r,p:i}){let o=i.accounts??[],c=t(),[l,u]=(0,G.useState)(``),[f,p]=(0,G.useState)(!1),[h,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(``),D=i.kind===`proxy`;(0,G.useEffect)(()=>{e&&b(``)},[e]);async function k(){v(!0);try{let e=await E(()=>d.proxyLoginStart());if(e.ok!==!0){b(``);return}b(w(e));let t=T(e);t&&a.warning(t,{duration:12e3});let n=await d.proxyLoginWait(e.waitMs??18e4);if(!n.ok||!n.apiKey){a.error(n.error||`登录未完成`);return}await d.proxyAddKey(i.id,n.apiKey),a.success(`已通过登录添加账号 `+(n.userName||n.keyName||``)),r(!1),await g.refresh()}catch(e){a.error(String(e))}finally{v(!1)}}async function A(){let e=l.split(/[,;\s]+/).map(e=>e.trim()).filter(Boolean);p(!0);try{if(D){let t=0,n=[],r=``;for(let a of e)try{let e=await d.proxyAddKey(i.id,a);if(t++,e&&e.limited===`credits`){let t=e.account?.limit?.recovery;r=`;其中有账号额度用尽`+(t?.type===`at`&&t.at?`(预计 `+Z(t.at)+` 自动恢复)`:`(等待月度重置后自动恢复)`)}}catch(e){n.push({key:a,error:ie(e)})}X(t,n,`反代账号`+r)}else{let t=await d.providerKeysSet(i.id,{add:e});if(t.ok===!1){a.error(t.error||`添加失败`);return}X(typeof t.added==`number`?t.added:e.length,t.discardedKeys||[],`API Key`)}u(``),r(!1),await g.refresh()}catch(e){a.error(String(e))}finally{p(!1)}}async function j(e){if(await c({title:`移除 Key `+e+`?`,description:`该凭据将从供应商中移除,不可恢复。`,confirmText:`移除`,tone:`destructive`})){p(!0);try{if(D){let t=o.find(t=>t.maskedKey===e||e.startsWith(t.maskedKey));t&&await d.proxyRemoveKey(i.id,t.keyId)}else{let t=await d.providerKeysSet(i.id,{removeMasked:[e]});if(t.ok===!1){a.error(t.error||`移除失败`);return}}a.success(`已移除`),r(!1),await g.refresh()}catch(e){a.error(String(e))}finally{p(!1)}}}return(0,K.jsx)(x,{open:e,onOpenChange:r,children:(0,K.jsxs)(C,{className:`max-w-[440px]`,children:[(0,K.jsx)(S,{children:(0,K.jsxs)(s,{children:[`添加 / 管理 Key — `,i.name]})}),(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[D?(0,K.jsxs)(`div`,{className:`grid gap-2 rounded-md border border-border/70 bg-muted/40 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`一键登录`}),(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:`浏览器打开 Command Code 授权,自动添加账号`})]}),(0,K.jsx)(n,{disabled:h||f,onClick:()=>void k(),size:`sm`,children:h?`等待授权…`:`一键登录`})]}),y?(0,K.jsxs)(`div`,{className:`grid gap-1 border-t border-border/60 pt-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:h?`等待授权中。窗口没弹出或停在空白页时,复制这一行在你的浏览器里打开:`:`本轮授权地址(窗口停在空白页时复制这一行手动打开):`}),(0,K.jsx)(O,{url:y})]}):null]}):null,(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:[D?`已录入账号(反代)`:`已录入 API Key`,`(`,o.length,`)`]}),o.length?(0,K.jsx)(`div`,{className:`grid max-h-[180px] gap-1 overflow-auto`,children:o.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 bg-muted/40 px-2.5 py-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`code`,{className:`truncate font-mono text-xs`,children:e.maskedKey}),e.selected?(0,K.jsx)(V,{tone:`ok`,children:`当前`}):null]}),(0,K.jsx)(n,{size:`chip`,variant:`ghost`,className:`text-destructive`,disabled:f,onClick:()=>void j(e.maskedKey),title:`移除该 Key`,children:(0,K.jsx)(N,{className:`size-3.5`})})]},e.keyId))}):(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`尚未录入 `,D?`账号`:`Key`]})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsxs)(m,{className:`text-xs text-muted-foreground`,children:[`添加 `,D?`账号 Key / Command Code`:`API Key`,`(每行一个,支持逗号/分号分隔)`]}),(0,K.jsx)(_,{className:`h-20 resize-none font-mono text-xs`,placeholder:D?`sk-... 或 Command Code,每行一个`:`sk-... 每行一个`,value:l,onChange:e=>u(e.target.value)})]})]}),(0,K.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2`,children:[(0,K.jsx)(n,{onClick:()=>r(!1),variant:`outline`,children:`取消`}),(0,K.jsx)(n,{disabled:f||!l.trim(),onClick:()=>void A(),children:f?`保存中…`:`添加`})]})]})})}function $({acc:t,busy:i,p:a,onAction:o}){let s=t.quota,c=!!t.selected,l=!!t.locked,u=Y(s?.monthly?.percent);return(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-5 py-3`,children:[(0,K.jsxs)(`div`,{className:`grid min-w-[180px] content-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c?l?`当前账号(锁定)`:`当前在用账号`:`选择账号`}),(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(R,{className:`max-w-[150px]`,children:t.maskedKey}),c?(0,K.jsxs)(n,{className:`gap-1 px-2`,disabled:i,onClick:()=>o(`refresh`,()=>d.providerRefresh(a.id).then(()=>void 0),`额度已刷新`),size:`chip`,variant:`outline`,children:[(0,K.jsx)(j,{className:r(`size-3`,i&&`animate-spin`)}),`刷新`]}):null]})]}),(0,K.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-cols-3 items-stretch gap-2`,children:[(0,K.jsx)(H,{icon:(0,K.jsx)(j,{className:`size-3.5`}),label:`5小时`,value:Y(s?.rolling?.percent),danger:q(s?.rolling)}),(0,K.jsx)(H,{icon:(0,K.jsx)(e,{className:`size-3.5`}),label:`每周`,value:Y(s?.weekly?.percent),danger:q(s?.weekly)}),(0,K.jsx)(H,{icon:(0,K.jsx)(P,{className:`size-3.5`}),label:`每月`,value:u,danger:q(s?.monthly)})]})]})}function ue({a:e,p:t,busy:i,onAction:a}){let o=!!e.selected,s=e.instanceStatus===`frozen`?`frozen`:e.status||``,c=e.limit?.kind,l=s===`frozen`||!!c||!o&&J(e.quota),u=c===`credits`?e.limit?.recovery?.type===`at`&&e.limit?.recovery?.at?`额度用尽(预计 ${Z(e.limit.recovery.at)} 月度重置后自动恢复)`:`额度用尽(待月度重置后自动恢复)`:c===`window`?e.limit?.reason??`时间窗额度已用尽(到 resetAt 自动恢复)`:c===`banned`?`账号被封禁`:null,f=W(e.requests||0)+` 次 · `+W(e.totalTokens||0)+` tok`,[p,m]=(0,G.useState)(!1),h;return h=l&&!o?(0,K.jsxs)(n,{size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,onClick:()=>m(!0),title:u??`查看该账号限额情况`,children:[(0,K.jsx)(ee,{className:`size-3.5`}),`限额`]}):o?(0,K.jsxs)(n,{disabled:i,onClick:()=>a(`refresh`,()=>d.providerRefresh(t.id).then(()=>void 0),`额度已刷新`),size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,children:[(0,K.jsx)(j,{className:r(`size-3.5`,i&&`animate-spin`)}),`刷新`]}):(0,K.jsxs)(n,{disabled:i,size:`chip`,variant:`outline`,className:`w-[70px] gap-1 px-1.5`,onClick:()=>{t.kind===`proxy`?a(`sel`,()=>d.proxySelect(t.id,e.keyId).then(()=>void 0),`已切换账号`):a(`use`,()=>d.providerKeyUse(t.id,e.keyId).then(()=>void 0),`已锁定 Key`)},children:[(0,K.jsx)(ne,{className:`size-3.5`}),`切换`]}),(0,K.jsxs)(`div`,{className:r(`grid items-center gap-2 px-5 py-2.5 hover:bg-muted/40`,Q,o&&`bg-muted/60 shadow-[inset_3px_0_0_var(--primary)]`),children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(R,{children:e.maskedKey}),s===`registering`?(0,K.jsx)(V,{tone:`off`,children:`检测中…`}):null,s===`banned`?(0,K.jsx)(V,{tone:`err`,children:`封号`}):null,c===`credits`?(0,K.jsx)(`span`,{title:e.limit?.reason??`额度用尽`,children:(0,K.jsx)(V,{tone:`err`,children:`额度用尽`})}):null,c===`window`?(0,K.jsx)(`span`,{title:e.limit?.reason??`时间窗额度已用尽`,children:(0,K.jsx)(V,{tone:`warn`,children:`窗口用尽`})}):null]}),(0,K.jsx)(`span`,{className:`truncate text-right text-xs tabular-nums text-muted-foreground`,title:f,children:f}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:h}),(0,K.jsx)(de,{open:p,onOpenChange:m,a:e,p:t})]})}function de({open:e,onOpenChange:t,a:r,p:i}){let a=r.quota,o=(()=>{let e=a?.credits?.monthlyCredits,t=a?.monthlyRemaining,n=e!=null&&Number.isFinite(Number(e))?Number(e):t!=null&&Number.isFinite(Number(t))?Number(t):null;return n===null?null:`剩余 $`+n.toFixed(2)})(),c=(e,t,n)=>(0,K.jsxs)(`div`,{className:`grid gap-1 rounded-md border border-border/70 bg-muted/40 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:t}),(0,K.jsx)(V,{tone:q(e)?`err`:`ok`,children:q(e)?`已限额`:`正常`})]}),(0,K.jsx)(`strong`,{className:`text-xl font-semibold tabular-nums text-foreground`,children:Y(e?.percent)}),n?(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:n}):null,e?.resetsAt?(0,K.jsxs)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:[`重置:`,new Date(e.resetsAt).toLocaleString(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})]}):null]});return(0,K.jsx)(x,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`max-w-[420px]`,children:[(0,K.jsx)(S,{children:(0,K.jsx)(s,{children:`限额详情`})}),(0,K.jsxs)(`div`,{className:`grid gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,K.jsx)(`span`,{children:`账号`}),(0,K.jsx)(`code`,{className:`font-mono`,children:r.maskedKey}),(0,K.jsx)(`span`,{className:`ml-auto text-xs`,children:i.name})]}),a?(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[c(a.rolling,`5小时`),c(a.weekly,`每周`),c(a.monthly,`每月`),a.credits||a.monthlyRemaining!=null?(0,K.jsxs)(`div`,{className:`col-span-3 flex flex-col gap-1 rounded-md border border-border/70 bg-muted/40 px-3 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`月度额度(Command)`}),a.credits?.belowThreshold?(0,K.jsx)(V,{tone:`warn`,children:`低于充值线`}):a.credits&&Number.isFinite(Number(a.credits.monthlyCredits))&&Number(a.credits.monthlyCredits)<=0?(0,K.jsx)(V,{tone:`err`,children:`额度用尽`}):(0,K.jsx)(V,{tone:`ok`,children:`正常`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] leading-tight text-muted-foreground`,children:Number(a.monthlyResetAt)>Date.now()?`月度额度预计 ${Z(Number(a.monthlyResetAt))} 重置(随订阅续期)`:`月度额度已于 ${Z(Number(a.monthlyResetAt))} 重置`}),o?(0,K.jsx)(`span`,{className:`text-sm font-semibold tabular-nums text-foreground`,children:o}):null]})]}):null]}):(0,K.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`暂无额度数据 — 点「刷新」获取`}),a?(0,K.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`当前用量统计:`,W(r.requests||0),` 次请求 · `,W(r.totalTokens||0),` tokens`,a.monthly?.resetsAt?`。最迟限额将于月窗口重置后自动解除。`:``]}):null]}),(0,K.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,K.jsx)(n,{onClick:()=>t(!1),variant:`outline`,children:`关闭`})})]})})}function fe({open:e,onOpenChange:t,presets:i,proxyApps:o,onDone:c}){let[l,g]=(0,G.useState)(``),[_,y]=(0,G.useState)(``),[w,T]=(0,G.useState)(``),[E,D]=(0,G.useState)(`preset`),[O,k]=(0,G.useState)(!1);async function A(){if(E===`preset`&&!l){a.error(`请选择供应商`);return}if(E===`proxy`&&!_){a.error(`请选择反代应用`);return}k(!0);try{let e=E===`preset`?await d.providerAdd({presetId:l,name:w||void 0,keys:[]}):await d.providerAdd({kind:`proxy`,appId:_,name:w||void 0,keys:[]});if(e.ok===!1){a.error(e.error||`添加失败`);return}a.success(`已添加供应商,请在卡片上点「添加」录入 Key`),t(!1),T(``),g(``),y(``),c()}catch(e){a.error(String(e))}finally{k(!1)}}let j=(i??[]).find(e=>e.id===l);return(0,K.jsx)(x,{open:e,onOpenChange:t,children:(0,K.jsxs)(C,{className:`max-w-[420px]`,children:[(0,K.jsx)(S,{children:(0,K.jsx)(s,{children:`添加供应商`})}),(0,K.jsxs)(`div`,{className:`grid gap-3`,children:[(0,K.jsx)(`div`,{className:`flex gap-1.5 rounded-lg bg-muted p-1`,children:[`preset`,`proxy`].map(e=>(0,K.jsx)(n,{className:r(`flex-1 rounded-md font-medium`,E===e?`bg-card text-foreground shadow-sm`:`bg-transparent text-muted-foreground hover:bg-card/60 hover:text-foreground`),onClick:()=>D(e),size:`sm`,variant:`ghost`,children:e===`preset`?`直连预设`:`反代应用`},e))}),E===`preset`?(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(m,{children:`供应商`}),(0,K.jsxs)(h,{value:l,onValueChange:g,children:[(0,K.jsx)(p,{className:`w-full`,children:(0,K.jsx)(v,{placeholder:`-- 选择供应商 --`})}),(0,K.jsx)(b,{children:(i??[]).map(e=>(0,K.jsx)(f,{value:e.id,children:e.name},e.id))})]}),j?.note?(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:j.note}):null]}):(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(m,{children:`反代应用`}),(0,K.jsxs)(h,{value:_,onValueChange:y,children:[(0,K.jsx)(p,{className:`w-full`,children:(0,K.jsx)(v,{placeholder:`-- 选择应用 --`})}),(0,K.jsx)(b,{children:(o??[]).map(e=>(0,K.jsx)(f,{value:e.id,children:e.name},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,K.jsx)(m,{children:`供应商名称(可选)`}),(0,K.jsx)(u,{placeholder:`自定义名称,如:Open Code ZEN`,value:w,onChange:e=>T(e.target.value)})]}),(0,K.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`只添加供应商不填 Key;添加后在供应商卡片上点「添加」录入 API Key。`})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,K.jsx)(n,{onClick:()=>t(!1),variant:`outline`,children:`取消`}),(0,K.jsx)(n,{disabled:O,onClick:()=>void A(),children:O?`添加中…`:`添加供应商`})]})]})})}export{oe as RouterPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,F as t,I as n,L as r,M as i,O as a,R as o,S as s,T as c,U as l,V as u,_ as d,a as f,d as p,f as m,h,i as g,j as _,l as v,m as y,p as b,s as x,u as S,v as C,w,x as T,y as E}from"./supervisor-DouAeDUQ.js";import{t as D}from"./refresh-cw-gnnGR0ej.js";import{l as O,u as k}from"./supervisor-C-lEz0-6.js";import{t as A}from"./useSupervisorAction-BdLx_DkH.js";import{n as j,o as M,t as N}from"./widgets-GTNEjznx.js";var P=l(u(),1),F=o();function I(){let[e,t]=(0,P.useState)(null),[r,i]=(0,P.useState)(null),[o,s]=(0,P.useState)(null),[c,l]=(0,P.useState)(``),[u,h]=(0,P.useState)(`hide`),{busy:_,run:y}=A(),C=(0,P.useCallback)(async()=>{let[e,n,r,a]=await Promise.all([f.autostart().catch(()=>null),f.lanPanel().catch(()=>null),f.accessKey().catch(()=>null),f.closeAction().catch(()=>null)]);e&&t(e.on),n&&i(n),r&&s(r),a&&h(a.closeAction)},[]);(0,P.useEffect)(()=>{C()},[C]);async function w(e){t(e);try{let n=await f.setAutostart(e);n.ok===!1?(a.error(n.error||`设置失败`),t(!e)):a.success(e?`已开启开机自启(整条服务链)`:`已关闭开机自启`)}catch(n){a.error(String(n)),t(!e)}}async function T(e){i(t=>t&&{...t,enabled:e});try{let t=await f.setLanPanel(e);if(t.ok===!1){a.error(t.error||`设置失败`),i(t=>t&&{...t,enabled:!e});return}i(t),a.success(e?`已开启局域网访问`:`已关闭局域网访问(仅本机)`)}catch(t){a.error(String(t)),i(t=>t&&{...t,enabled:!e})}}async function E(){let e=c.trim();if(e&&e.length<8){a.error(`访问密钥至少 8 位(建议 16+ 位随机串)`);return}await y(`akk`,()=>f.setAccessKey(e),{success:e?`访问密钥已设置`:`访问密钥已清除`,refresh:!1,onDone:()=>{l(``),C()}})&&g(e)}async function D(e){let t=e===`exit`?`exit`:`hide`;h(t),await y(`ca`,()=>f.setCloseAction(t),{success:t===`exit`?`已设为:关闭窗口时退出管家`:`已设为:关闭窗口时隐藏至托盘`,refresh:!1})}return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`启动`,subtitle:`开机行为与偏好`}),(0,F.jsxs)(`div`,{className:`grid gap-4 px-5 py-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`开机自动启动管家`}),(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:`开机登录后自动启动 DeepSeek Harness 管家(本程序)。不会自动启动任何单个实例——实例是否被自动拉起,由各自「进程监控」开关决定。`})]}),e===null?(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):(0,F.jsx)(`span`,{title:`开机自启`,children:(0,F.jsx)(x,{checked:e,onCheckedChange:e=>void w(e)})})]}),(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-6 border-t border-border/60 pt-4`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`关闭窗口时`}),(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:`隐藏至托盘:管家与服务继续在后台运行;退出管家:关闭并停止全部服务。`})]}),(0,F.jsxs)(v,{value:u,onValueChange:e=>void D(e),children:[(0,F.jsx)(m,{className:`w-[150px]`,children:(0,F.jsx)(b,{})}),(0,F.jsxs)(S,{children:[(0,F.jsx)(p,{value:`hide`,children:`隐藏至托盘`}),(0,F.jsx)(p,{value:`exit`,children:`退出管家`})]})]})]})]})]}),(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`访问`}),(0,F.jsxs)(`div`,{className:`grid gap-4 px-5 py-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`管家局域网访问`}),r?r.enabled?(0,F.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`开启后,局域网内设备可通过\xA0`,(r.urls??[]).map((e,t)=>(0,F.jsxs)(`span`,{children:[t>0?`、 `:null,(0,F.jsx)(`code`,{className:`rounded bg-muted px-1 py-px font-mono text-foreground`,children:e})]},e)),`\xA0访问本面板。`]}):(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:`关闭后仅本机可访问,局域网设备不可用。`}):null]}),r===null?(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):(0,F.jsx)(`span`,{title:`局域网访问`,children:(0,F.jsx)(x,{checked:r.enabled,onCheckedChange:e=>void T(e)})})]}),(0,F.jsx)(`div`,{className:`flex items-start justify-between gap-6 border-t border-border/60 pt-4`,children:(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`访问密钥`}),(0,F.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`局域网或公网访问本面板需携带此密钥;本机访问不受影响。留空保存可清除。`,o?.configured?(0,F.jsx)(`span`,{className:`mt-1 block text-status-ok`,children:`当前:已设置`}):(0,F.jsx)(`span`,{className:`mt-1 block text-muted-foreground`,children:`当前:未设置`})]})]})}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(d,{type:`password`,autoComplete:`new-password`,placeholder:`输入 ≥8 位访问密钥(建议随机长串)`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E()},className:`flex-1`}),(0,F.jsx)(n,{variant:`outline`,onClick:()=>l(``),disabled:!c&&!o?.configured,children:`清除`}),(0,F.jsx)(n,{disabled:_===`akk`,onClick:()=>void E(),children:o?.configured?`更新密钥`:`设置密钥`})]})]})]})]})}function L(e){return/^https?:\/\//.test(e.trim())}function R(){let[t,o]=(0,P.useState)(null),[s,l]=(0,P.useState)(`auto`),[u,p]=(0,P.useState)([]),[m,g]=(0,P.useState)(``),[v,b]=(0,P.useState)(``),[x,S]=(0,P.useState)(!1),C=(0,P.useRef)(null),{busy:T,run:E}=A();(0,P.useEffect)(()=>{if(!x||!C.current)return;let e=window.setTimeout(()=>{let e=C.current;e&&e.scrollIntoView({block:`start`,behavior:`smooth`})},320);return()=>window.clearTimeout(e)},[x]);let I=(0,P.useCallback)(async()=>{let e=await f.registry().catch(()=>null);o(e)},[]);(0,P.useEffect)(()=>{I()},[I]),(0,P.useEffect)(()=>{t&&(l(t.mode||`auto`),p((t.candidates??[]).map(e=>e.origin)),g(t.manualOrigin||``))},[t]);let R=()=>{let e=v.trim();if(!L(e)){a.error(`请输入合法的镜像 URL`);return}if(u.includes(e)){a.info(`已在列表中`);return}p(t=>[...t,e]),b(``)};async function B(){let e={mode:s,origins:u};if(s===`manual`){if(!L(m)){a.error(`手动模式需提供合法镜像 URL`);return}e.manualOrigin=m.trim()}await E(`reg`,()=>f.registrySet(e),{success:`已保存镜像配置`,refresh:!1,onDone:()=>void I()})}async function V(){await E(`regr`,()=>f.registryRefresh(),{success:`已探测镜像`,refresh:!1,onDone:()=>void I()})}let H=e=>{let n=(t?.probes??[]).find(t=>t.origin===e);return n&&n.ok?n.latencyMs:null},U=e=>{let n=(t?.registries??[]).find(t=>t.base===e);if(n&&!n.usable)return`形态非法:`+(n.violation||`未知`);let r=(t?.probes??[]).find(t=>t.origin===e);return r&&!r.ok?`不可达:`+(r.error||`未知`):`未探测`};return(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`镜像源`,subtitle:`npm 拉取 / 更新检测共用此源`}),(0,F.jsxs)(`div`,{className:`grid gap-3 px-5 py-4`,children:[(0,F.jsxs)(y,{value:s,onValueChange:e=>l(e),className:`flex gap-3`,children:[(0,F.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 text-sm`,children:[(0,F.jsx)(h,{value:`auto`,id:`reg-auto`}),(0,F.jsx)(`span`,{children:`自动(按延迟选最快)`})]}),(0,F.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 text-sm`,children:[(0,F.jsx)(h,{value:`manual`,id:`reg-manual`}),(0,F.jsx)(`span`,{children:`手动(固定指定)`})]})]}),s===`manual`?(0,F.jsx)(`div`,{className:`grid gap-1.5`,children:(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(d,{placeholder:`https://registry.npmmirror.com`,value:m,onChange:e=>g(e.target.value),className:`flex-1`}),(0,F.jsx)(n,{variant:`outline`,onClick:()=>void z(m),children:`测试`})]})}):null,(0,F.jsxs)(e,{open:x,onOpenChange:S,className:`grid gap-1`,children:[(0,F.jsxs)(c,{ref:C,children:[(0,F.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`候选镜像列表(`,u.length,`)`]}),x?(0,F.jsx)(_,{className:`size-3.5 text-muted-foreground`}):(0,F.jsx)(i,{className:`size-3.5 text-muted-foreground`})]}),x?null:(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 px-3 py-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(M,{tone:`ok`,children:`当前`}),(0,F.jsx)(`code`,{className:`truncate font-mono text-xs text-muted-foreground`,children:t?.origin||`未选择`})]}),t?.origin&&H(t.origin)!=null?(0,F.jsxs)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums`,children:[H(t.origin),`ms`]}):null]}),(0,F.jsx)(w,{children:(0,F.jsx)(`div`,{className:`rounded-md border border-border/70`,children:u.map((e,r)=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/50 px-3 py-1.5 last:border-b-0`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t?.origin===e?(0,F.jsx)(M,{tone:`ok`,children:`当前`}):null,(0,F.jsx)(`code`,{className:`truncate font-mono text-xs text-muted-foreground`,children:e})]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[H(e)==null?(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground/50`,title:U(e),children:`—`}):(0,F.jsxs)(`span`,{className:`text-xs font-medium tabular-nums`,title:`延迟毫秒数(自动探测)`,children:[H(e),(0,F.jsx)(`span`,{className:`text-muted-foreground/60`,children:`ms`})]}),(0,F.jsx)(n,{size:`chip`,variant:`ghost`,onClick:()=>p(t=>t.filter(t=>t!==e)),title:`移除该候选镜像`,children:(0,F.jsx)(O,{className:`size-3.5 text-destructive`})})]})]},r))})})]}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(d,{placeholder:`https://… 添加自定义镜像`,value:v,onChange:e=>b(e.target.value),className:`flex-1`,onKeyDown:e=>{e.key===`Enter`&&R()}}),(0,F.jsxs)(n,{variant:`outline`,onClick:R,children:[(0,F.jsx)(k,{className:`size-4`}),`添加`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsxs)(n,{size:`sm`,disabled:T===`regr`,onClick:()=>void V(),variant:`outline`,children:[(0,F.jsx)(D,{className:r(`size-3.5`,T===`regr`&&`animate-spin`)}),`重新探测`]}),(0,F.jsx)(n,{disabled:T===`reg`,onClick:()=>void B(),children:`保存`})]})]})]})}async function z(e){if(!L(e)){a.error(`请输入合法镜像 URL`);return}a.info(`测试中…`);try{let t=await f.registryProbe(e.replace(/\/+$/,``));t&&t.ok===!0&&typeof t.latencyMs==`number`?a.success(`可达,延迟 `+t.latencyMs+` ms`):t&&typeof t.error==`string`&&t.error?a.error(`探测失败:`+t.error):a.error(`不可达`)}catch(e){a.error(`探测失败:`+(e instanceof Error?e.message:String(e)))}}var B={schema:1,note:`跨语言共享常量(Node 内核 ↔ Rust 桌面壳)的单一来源。Rust 侧 include_str! 编译期嵌入,Node 侧读取;两侧不再各存一份副本,故不可能漂移。范式取自 shell/shell-release/version-vectors.json(本仓已验证的跨语言单源先例)。`,product:{name:`lobox`,cliName:`lobox`,guiBinName:`lobox-shell`,guiCrateName:`lobox-shell`,npmScope:`@lob-ox`,corePkgPrefix:`core-`,shellReleasePkg:`@lob-ox/shell-release`,tauriIdentifier:`dev.bowen.lobox`,tauriProductName:`lobox`},state:{dirName:`lobox`,supervisorSubdir:`supervisor`,shellSubdir:`shell`,legacyHarnessDir:`.dsh`,winBaseEnv:`LOCALAPPDATA`,linuxXdgEnv:`XDG_STATE_HOME`,legacyProductName:`dsh-supervisor`,winFallbackSegments:[`AppData`,`Local`],macosSegments:[`Library`,`Application Support`],linuxFallbackSegments:[`.local`,`state`]},env:{stateRoot:`DSH_SUPERVISOR_HOME`,config:`DSH_SUPERVISOR_CONFIG`,daemon:`DSH_SUPERVISOR_DAEMON`,tray_port:`DSH_SUPERVISOR_TRAY_PORT`,shell_exe:`DSH_SHELL_EXE`,guard_bin:`DSH_GUARD_BIN`,harness_bin:`DSH_BIN`,smoke_pid:`DSH_PID`,canary:`DSH_CANARY`,canary_id:`DSH_CANARY_ID`,canary_allowlist:`DSH_CANARY_ALLOWLIST`,deploy_form:`DSH_DEPLOY_FORM`,ui_dir:`DSH_UI_DIR`,ui_skip_install:`DSH_UI_SKIP_INSTALL`,core_scope:`DSH_CORE_SCOPE`,publish_registry:`DSH_PUBLISH_REGISTRY`,npm_provenance:`DSH_NPM_PROVENANCE`,npmrc:`DSH_NPMRC`,npm_auth_prev:`DSH_NPM_AUTH_PREV`,npm_auth_prev_set:`DSH_NPM_AUTH_PREV_SET`,npm_auth_prevl:`DSH_NPM_AUTH_PREVL`,npm_auth_prevl_set:`DSH_NPM_AUTH_PREVL_SET`,npm_auth_source:`DSH_NPM_AUTH_SOURCE`,npm_auth_tmp:`DSH_NPM_AUTH_TMP`,cred_dir:`DSH_CRED_DIR`,cred_allow_overwrite:`DSH_CRED_ALLOW_OVERWRITE`,cred_force:`DSH_CRED_FORCE`,cred_backup_dir:`DSH_CRED_BACKUP_DIR`,real_home:`DSH_REAL_HOME`,arch_override:`DSH_ARCH_OVERRIDE`,platform_override:`DSH_PLATFORM_OVERRIDE`,esbuild_version:`DSH_ESBUILD_VERSION`,version_lib:`DSH_VERSION_LIB`},proc:{matchGuard:`*lobox*|*lob-ox*|*dsh*`,matchGuardNote:`进程归属判据。必须覆盖三种真实形态:CLI/壳可执行名 lobox、npm scope @lob-ox(连字符,不等于 lobox)、以及旧产品名 dsh 的历史安装。漏任一种都会让无锚点兜底判据对该形态返回非我方。`,matchGui:`lobox-shell`,matchGuiRe:`lobox-shell(\\\\.exe)?`},bridge:{msgKernelUpdateRequest:`lobox:kernel-update-request`,msgKernelUpdateResult:`lobox:kernel-update-result`,msgKernelUpdateProgress:`lobox:kernel-update-progress`,mgmtTokenHeader:`x-lobox-mgmt-token`},net:{apiPort:37360,routerCtlPort:43107,lanCtlPort:43108,deprecatedApiPorts:[36360],dshDefaultPort:3080},runtime:{minNode:`v22.12.0`,npmDefaultRegistry:`https://registry.npmjs.org`},packaging:{seaBundleName:`core.cjs`,seaVersionDefine:`__DSH_VERSION__`,kernelArchiveTemplate:`lobox-{ver}.tar.gz`,kernelReleaseTarballTemplate:`lobox-kernel-{ver}-{plat}.tar.gz`,launcherDirTemplate:`lobox-{ver}-{plat}-{arch}`,installerNsisWinX64Template:`{product}_{ver}_x64-setup.exe`,installerMacosAppTemplate:`{product}.app.tar.gz`,installerDebLinuxX64Template:`{product}_{ver}_amd64.deb`,installerDmgArm64Template:`{product}_{ver}_aarch64.dmg`,installerDmgX64Template:`{product}_{ver}_x64.dmg`},platform:{windowsGuiTask:`Lobox-Shell`,windowsRunValue:`Lobox`,systemdUnitName:`lobox`,systemdUnitFile:`lobox.service`,systemdTemplateAsideSuffix:`.disabled-by-lobox-`,cliBinNames:[`lobox.exe`,`lobox.cmd`,`lobox`]},event:{harness_exited:`harness_exited`,harness_token_captured:`harness_token_captured`,harness_token_missing:`harness_token_missing`,harness_command_missing:`harness_command_missing`,harness_not_installed:`harness_not_installed`,harness_command_bound:`harness_command_bound`,harness_guardian_changed:`harness_guardian_changed`,harness_remote_changed:`harness_remote_changed`,harness_remote_token_changed:`harness_remote_token_changed`,lan_harness_token_updated:`lan_harness_token_updated`,upgrade_stopping_harness:`upgrade_stopping_harness`,shell_update_pending:`shell_update_pending`,shell_update_checked:`shell_update_checked`,shell_restart_requested:`shell_restart_requested`},store:{keyApiAccess:`lobox.apiAccessKey`,cookieLanToken:`lobox_lan_token`}},V=B.bridge.msgKernelUpdateRequest,H=B.bridge.msgKernelUpdateResult,U=B.bridge.msgKernelUpdateProgress,W=12e5;function G(e){return new Promise(t=>{if(!K()){t({ok:!1,error:`内核更新由桌面壳执行:请在桌面壳面板中操作。`});return}let n=`kupd-`+Date.now()+`-`+Math.random().toString(36).slice(2,8),r=Date.now(),i=!1,a=null,o=setTimeout(s,W);function s(){l(a?{ok:!1,error:`桌面壳无响应(更新请求超时;最后一次进度:`+a+`)`}:{ok:!1,error:`桌面壳无响应(更新请求超时)`})}let c=e=>{clearTimeout(o),o=setTimeout(s,Math.max(0,e))},l=e=>{i||(i=!0,window.removeEventListener(`message`,u),clearTimeout(o),t(e))},u=t=>{let i=t.data;if(!(!i||typeof i!=`object`)&&t.source===window.parent&&i.v===2&&(i.type===H||i.type===U)&&i.requestId===n){if(i.type===U){let t=typeof i.status==`string`&&i.status?i.status:null;t&&(a=t),e?.({stage:typeof i.stage==`string`?i.stage:null,status:t,progress:typeof i.progress==`number`?i.progress:null});let n=typeof i.maxWaitMs==`number`?i.maxWaitMs:0;n>0&&c(n-(Date.now()-r));return}l({ok:i.ok===!0,stage:i.stage??null,version:i.version??null,restartUncertain:i.restartUncertain===!0,error:i.error??null})}};window.addEventListener(`message`,u);try{window.parent.postMessage({v:2,type:V,requestId:n},`*`)}catch(e){l({ok:!1,error:String(e)})}})}function K(){try{return window.parent!==window}catch{return!1}}var q=`DeepSeek Harness 管家`,J=`独立于 Harness 运行的系统级守卫:负责启动、存活监测与故障自动重启被监管目标,提供生命周期管理、智能路由、远程控制与多实例沙箱的运维面板。`,Y=e=>e?String(e).replace(/^v/i,``):`—`;function X(){let[e,i]=(0,P.useState)(null),[o,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),[d,p]=(0,P.useState)(`dsh`),[m,h]=(0,P.useState)(``),[g,_]=(0,P.useState)(null),{busy:v,run:y}=A(),b=t(),x=(0,P.useCallback)(async e=>{p(e),h(``),u(!0);try{let t=e===`dsh`?await f.dshChangelog():await f.guardChangelog();h(t||`(无内容)`)}catch(e){h(`加载失败:`+String(e))}},[]),S=(0,P.useCallback)(async()=>{let[e,t,n,r]=await Promise.all([f.guardVersion().catch(()=>null),f.selfUpdateStatus().catch(()=>null),f.shellStatus().catch(()=>null),f.shellCheckUpdate().catch(()=>null)]);e&&i(t=>({...t||{},...e})),t&&t.ok!==!1&&i(e=>({...e||{},...t})),n&&c(e=>({...e||{},version:n.identity?.version||null,capable:n.identity?.selfUpdateCapable===!0,installKind:n.identity?.installKind})),r&&c(e=>({...e||{},latest:r.latest||null,updateAvailable:r.updateAvailable===!0,error:r.error||null}))},[]);(0,P.useEffect)(()=>{S()},[S]);let w=async()=>{await y(`chk`,async()=>{let e=`内核:状态未知`,t=await f.selfUpdateStatus().catch(()=>null);if(t&&t.ok!==!1)i(e=>({...e||{},...t})),e=t.updateAvailable&&t.latest?`内核有新版本 `+Y(t.latest)+`(当前 `+Y(t.installed)+`)`:`内核已是最新(`+Y(t.installed)+`)`;else{let n=await f.guardVersion().catch(()=>null);if(n?.upstream===`git-repo`){let t=await f.guardVersionCheck().catch(()=>null);i(e=>({...e||{},...n||{},...t||{}})),e=t?.updateAvailable?`内核源码仓库有上游更新(当前提交 `+(t.commit||n?.commit||`—`)+`)`:`内核源码仓库已是最新(提交 `+(n?.commit||t?.commit||`—`)+`)`}else e=`内核:`+(t&&t.error||`自更新未配置`)}let n=await f.shellCheckUpdate().catch(()=>null),r=`桌面壳:状态未知`;n&&n.ok!==!1?(c(e=>({...e||{},latest:n.latest||null,updateAvailable:n.updateAvailable===!0,error:null})),r=n.updateAvailable&&n.latest?`桌面壳有新版本 `+Y(n.latest)+`(当前 `+Y(n.installed)+`)`:`桌面壳已是最新(`+Y(n.installed)+`)`):(c(e=>({...e||{},error:n&&n.error||`检测失败`})),r=`桌面壳:`+(n&&n.error||`检测失败`)),t?.updateAvailable&&t?.latest||n?.updateAvailable&&n?.latest?a.warning(e+`;`+r):a.success(e+`;`+r)},{refresh:!1})},O=async()=>{if(!K()){a.error(`内核更新由桌面壳执行:请在桌面壳面板中操作。`);return}await b({title:`发现内核新版本 `+Y(e?.latest)+`,是否立即更新?`,description:`内核将由桌面壳安装,并自动重启守卫。`,confirmText:`更新`})&&await y(`upd`,async()=>{_({status:`已向桌面壳发出更新请求,等待响应…`});let t=await G(_);if(!t.ok){a.error(t.error||`更新失败`);return}let n=Y(t.version||e?.latest);t.restartUncertain?a.warning(`内核已更新至 `+n+`,但守卫可能未自动重启,请手动确认。`):a.success(`内核已更新至 `+n+`,守卫已重启。`)},{refresh:!0,onDone:()=>_(null)})},k=!!(e?.updateAvailable&&e?.latest&&e.latest!==e?.installed),I=!!(o?.updateAvailable&&o?.latest&&o.latest!==o?.version),L=o?.capable===!1;return(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`关于`,subtitle:q,actions:(0,F.jsxs)(n,{size:`sm`,disabled:v===`chk`,onClick:()=>void w(),variant:`outline`,children:[(0,F.jsx)(D,{className:r(`size-3.5`,v===`chk`&&`animate-spin`)}),`检查更新`]})}),(0,F.jsxs)(`div`,{className:`grid gap-3 px-5 py-4`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] items-baseline gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`桌面壳版本`}),(0,F.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-foreground`,children:[Y(o?.version),o?.installKind?(0,F.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,o.installKind,`)`]}):null,I?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(M,{tone:`warn`,children:[`可更新 `,Y(o?.latest)]}),(0,F.jsx)(M,{tone:`off`,children:`请重启桌面壳应用更新`})]}):null,L?(0,F.jsx)(M,{tone:`off`,children:`当前形态不支持自更新`}):null,o?.error?(0,F.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:o.error}):null]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] items-baseline gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`内核版本`}),(0,F.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-foreground`,children:[Y(e?.installed||e?.version),k?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(M,{tone:`warn`,children:[`可更新 `,Y(e?.latest)]}),K()?(0,F.jsxs)(n,{size:`chip`,disabled:v===`upd`,onClick:()=>void O(),variant:`outline`,children:[(0,F.jsx)(D,{className:r(`size-3`,v===`upd`&&`animate-spin`)}),`更新`]}):(0,F.jsx)(M,{tone:`off`,children:`请在桌面壳中更新`})]}):null]})]}),g?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,F.jsx)(D,{className:`size-3 shrink-0 animate-spin`}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:g.status||`桌面壳处理中…`}),typeof g.progress==`number`?(0,F.jsxs)(`span`,{className:`tabular-nums font-medium text-foreground`,children:[Math.round(g.progress*100),`%`]}):null]}):null,(0,F.jsx)(`p`,{className:`border-t border-border/60 pt-3 text-xs leading-relaxed text-muted-foreground`,children:J}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/60 pt-3`,children:[(0,F.jsx)(n,{size:`chip`,variant:`outline`,onClick:()=>void x(`dsh`),children:`DSH 更新日志`}),(0,F.jsx)(n,{size:`chip`,variant:`outline`,onClick:()=>void x(`guard`),children:`管家更新日志`})]})]}),(0,F.jsx)(C,{open:l,onOpenChange:u,children:(0,F.jsxs)(E,{className:`max-w-[560px]`,children:[(0,F.jsx)(T,{children:(0,F.jsx)(s,{children:d===`dsh`?`DeepSeek Harness 更新日志`:`管家更新日志`})}),(0,F.jsx)(`pre`,{className:`max-h-[50vh] overflow-auto whitespace-pre-wrap break-words rounded-md border border-border/60 bg-muted/30 p-3 text-xs leading-relaxed text-foreground`,children:m||`加载中…`})]})})]})}function Z(){return(0,F.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,F.jsx)(I,{}),(0,F.jsx)(R,{}),(0,F.jsx)(X,{})]})}export{Z as SettingsPage};
|
|
1
|
+
import{C as e,F as t,I as n,L as r,M as i,O as a,R as o,S as s,T as c,U as l,V as u,_ as d,a as f,d as p,f as m,h,i as g,j as _,l as v,m as y,p as b,s as x,u as S,v as C,w,x as T,y as E}from"./supervisor-DSBgs_XY.js";import{t as D}from"./refresh-cw-GKBYw9-E.js";import{l as O,u as k}from"./supervisor-DWUbDZTX.js";import{t as A}from"./useSupervisorAction-U8T1qRbC.js";import{n as j,o as M,t as N}from"./widgets-DV5fuKzB.js";var P=l(u(),1),F=o();function I(){let[e,t]=(0,P.useState)(null),[r,i]=(0,P.useState)(null),[o,s]=(0,P.useState)(null),[c,l]=(0,P.useState)(``),[u,h]=(0,P.useState)(`hide`),{busy:_,run:y}=A(),C=(0,P.useCallback)(async()=>{let[e,n,r,a]=await Promise.all([f.autostart().catch(()=>null),f.lanPanel().catch(()=>null),f.accessKey().catch(()=>null),f.closeAction().catch(()=>null)]);e&&t(e.on),n&&i(n),r&&s(r),a&&h(a.closeAction)},[]);(0,P.useEffect)(()=>{C()},[C]);async function w(e){t(e);try{let n=await f.setAutostart(e);n.ok===!1?(a.error(n.error||`设置失败`),t(!e)):a.success(e?`已开启开机自启(整条服务链)`:`已关闭开机自启`)}catch(n){a.error(String(n)),t(!e)}}async function T(e){i(t=>t&&{...t,enabled:e});try{let t=await f.setLanPanel(e);if(t.ok===!1){a.error(t.error||`设置失败`),i(t=>t&&{...t,enabled:!e});return}i(t),a.success(e?`已开启局域网访问`:`已关闭局域网访问(仅本机)`)}catch(t){a.error(String(t)),i(t=>t&&{...t,enabled:!e})}}async function E(){let e=c.trim();if(e&&e.length<8){a.error(`访问密钥至少 8 位(建议 16+ 位随机串)`);return}await y(`akk`,()=>f.setAccessKey(e),{success:e?`访问密钥已设置`:`访问密钥已清除`,refresh:!1,onDone:()=>{l(``),C()}})&&g(e)}async function D(e){let t=e===`exit`?`exit`:`hide`;h(t),await y(`ca`,()=>f.setCloseAction(t),{success:t===`exit`?`已设为:关闭窗口时退出管家`:`已设为:关闭窗口时隐藏至托盘`,refresh:!1})}return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`启动`,subtitle:`开机行为与偏好`}),(0,F.jsxs)(`div`,{className:`grid gap-4 px-5 py-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`开机自动启动管家`}),(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:`开机登录后自动启动 DeepSeek Harness 管家(本程序)。不会自动启动任何单个实例——实例是否被自动拉起,由各自「进程监控」开关决定。`})]}),e===null?(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):(0,F.jsx)(`span`,{title:`开机自启`,children:(0,F.jsx)(x,{checked:e,onCheckedChange:e=>void w(e)})})]}),(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-6 border-t border-border/60 pt-4`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`关闭窗口时`}),(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:`隐藏至托盘:管家与服务继续在后台运行;退出管家:关闭并停止全部服务。`})]}),(0,F.jsxs)(v,{value:u,onValueChange:e=>void D(e),children:[(0,F.jsx)(m,{className:`w-[150px]`,children:(0,F.jsx)(b,{})}),(0,F.jsxs)(S,{children:[(0,F.jsx)(p,{value:`hide`,children:`隐藏至托盘`}),(0,F.jsx)(p,{value:`exit`,children:`退出管家`})]})]})]})]})]}),(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`访问`}),(0,F.jsxs)(`div`,{className:`grid gap-4 px-5 py-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-6`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`管家局域网访问`}),r?r.enabled?(0,F.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`开启后,局域网内设备可通过\xA0`,(r.urls??[]).map((e,t)=>(0,F.jsxs)(`span`,{children:[t>0?`、 `:null,(0,F.jsx)(`code`,{className:`rounded bg-muted px-1 py-px font-mono text-foreground`,children:e})]},e)),`\xA0访问本面板。`]}):(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:`关闭后仅本机可访问,局域网设备不可用。`}):null]}),r===null?(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):(0,F.jsx)(`span`,{title:`局域网访问`,children:(0,F.jsx)(x,{checked:r.enabled,onCheckedChange:e=>void T(e)})})]}),(0,F.jsx)(`div`,{className:`flex items-start justify-between gap-6 border-t border-border/60 pt-4`,children:(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`strong`,{className:`block text-sm font-medium text-foreground`,children:`访问密钥`}),(0,F.jsxs)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:[`局域网或公网访问本面板需携带此密钥;本机访问不受影响。留空保存可清除。`,o?.configured?(0,F.jsx)(`span`,{className:`mt-1 block text-status-ok`,children:`当前:已设置`}):(0,F.jsx)(`span`,{className:`mt-1 block text-muted-foreground`,children:`当前:未设置`})]})]})}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(d,{type:`password`,autoComplete:`new-password`,placeholder:`输入 ≥8 位访问密钥(建议随机长串)`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E()},className:`flex-1`}),(0,F.jsx)(n,{variant:`outline`,onClick:()=>l(``),disabled:!c&&!o?.configured,children:`清除`}),(0,F.jsx)(n,{disabled:_===`akk`,onClick:()=>void E(),children:o?.configured?`更新密钥`:`设置密钥`})]})]})]})]})}function L(e){return/^https?:\/\//.test(e.trim())}function R(){let[t,o]=(0,P.useState)(null),[s,l]=(0,P.useState)(`auto`),[u,p]=(0,P.useState)([]),[m,g]=(0,P.useState)(``),[v,b]=(0,P.useState)(``),[x,S]=(0,P.useState)(!1),C=(0,P.useRef)(null),{busy:T,run:E}=A();(0,P.useEffect)(()=>{if(!x||!C.current)return;let e=window.setTimeout(()=>{let e=C.current;e&&e.scrollIntoView({block:`start`,behavior:`smooth`})},320);return()=>window.clearTimeout(e)},[x]);let I=(0,P.useCallback)(async()=>{let e=await f.registry().catch(()=>null);o(e)},[]);(0,P.useEffect)(()=>{I()},[I]),(0,P.useEffect)(()=>{t&&(l(t.mode||`auto`),p((t.candidates??[]).map(e=>e.origin)),g(t.manualOrigin||``))},[t]);let R=()=>{let e=v.trim();if(!L(e)){a.error(`请输入合法的镜像 URL`);return}if(u.includes(e)){a.info(`已在列表中`);return}p(t=>[...t,e]),b(``)};async function B(){let e={mode:s,origins:u};if(s===`manual`){if(!L(m)){a.error(`手动模式需提供合法镜像 URL`);return}e.manualOrigin=m.trim()}await E(`reg`,()=>f.registrySet(e),{success:`已保存镜像配置`,refresh:!1,onDone:()=>void I()})}async function V(){await E(`regr`,()=>f.registryRefresh(),{success:`已探测镜像`,refresh:!1,onDone:()=>void I()})}let H=e=>{let n=(t?.probes??[]).find(t=>t.origin===e);return n&&n.ok?n.latencyMs:null},U=e=>{let n=(t?.registries??[]).find(t=>t.base===e);if(n&&!n.usable)return`形态非法:`+(n.violation||`未知`);let r=(t?.probes??[]).find(t=>t.origin===e);return r&&!r.ok?`不可达:`+(r.error||`未知`):`未探测`};return(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`镜像源`,subtitle:`npm 拉取 / 更新检测共用此源`}),(0,F.jsxs)(`div`,{className:`grid gap-3 px-5 py-4`,children:[(0,F.jsxs)(y,{value:s,onValueChange:e=>l(e),className:`flex gap-3`,children:[(0,F.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 text-sm`,children:[(0,F.jsx)(h,{value:`auto`,id:`reg-auto`}),(0,F.jsx)(`span`,{children:`自动(按延迟选最快)`})]}),(0,F.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1.5 text-sm`,children:[(0,F.jsx)(h,{value:`manual`,id:`reg-manual`}),(0,F.jsx)(`span`,{children:`手动(固定指定)`})]})]}),s===`manual`?(0,F.jsx)(`div`,{className:`grid gap-1.5`,children:(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(d,{placeholder:`https://registry.npmmirror.com`,value:m,onChange:e=>g(e.target.value),className:`flex-1`}),(0,F.jsx)(n,{variant:`outline`,onClick:()=>void z(m),children:`测试`})]})}):null,(0,F.jsxs)(e,{open:x,onOpenChange:S,className:`grid gap-1`,children:[(0,F.jsxs)(c,{ref:C,children:[(0,F.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`候选镜像列表(`,u.length,`)`]}),x?(0,F.jsx)(_,{className:`size-3.5 text-muted-foreground`}):(0,F.jsx)(i,{className:`size-3.5 text-muted-foreground`})]}),x?null:(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-border/70 px-3 py-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(M,{tone:`ok`,children:`当前`}),(0,F.jsx)(`code`,{className:`truncate font-mono text-xs text-muted-foreground`,children:t?.origin||`未选择`})]}),t?.origin&&H(t.origin)!=null?(0,F.jsxs)(`span`,{className:`shrink-0 text-xs font-medium tabular-nums`,children:[H(t.origin),`ms`]}):null]}),(0,F.jsx)(w,{children:(0,F.jsx)(`div`,{className:`rounded-md border border-border/70`,children:u.map((e,r)=>(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/50 px-3 py-1.5 last:border-b-0`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[t?.origin===e?(0,F.jsx)(M,{tone:`ok`,children:`当前`}):null,(0,F.jsx)(`code`,{className:`truncate font-mono text-xs text-muted-foreground`,children:e})]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[H(e)==null?(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground/50`,title:U(e),children:`—`}):(0,F.jsxs)(`span`,{className:`text-xs font-medium tabular-nums`,title:`延迟毫秒数(自动探测)`,children:[H(e),(0,F.jsx)(`span`,{className:`text-muted-foreground/60`,children:`ms`})]}),(0,F.jsx)(n,{size:`chip`,variant:`ghost`,onClick:()=>p(t=>t.filter(t=>t!==e)),title:`移除该候选镜像`,children:(0,F.jsx)(O,{className:`size-3.5 text-destructive`})})]})]},r))})})]}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(d,{placeholder:`https://… 添加自定义镜像`,value:v,onChange:e=>b(e.target.value),className:`flex-1`,onKeyDown:e=>{e.key===`Enter`&&R()}}),(0,F.jsxs)(n,{variant:`outline`,onClick:R,children:[(0,F.jsx)(k,{className:`size-4`}),`添加`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,F.jsxs)(n,{size:`sm`,disabled:T===`regr`,onClick:()=>void V(),variant:`outline`,children:[(0,F.jsx)(D,{className:r(`size-3.5`,T===`regr`&&`animate-spin`)}),`重新探测`]}),(0,F.jsx)(n,{disabled:T===`reg`,onClick:()=>void B(),children:`保存`})]})]})]})}async function z(e){if(!L(e)){a.error(`请输入合法镜像 URL`);return}a.info(`测试中…`);try{let t=await f.registryProbe(e.replace(/\/+$/,``));t&&t.ok===!0&&typeof t.latencyMs==`number`?a.success(`可达,延迟 `+t.latencyMs+` ms`):t&&typeof t.error==`string`&&t.error?a.error(`探测失败:`+t.error):a.error(`不可达`)}catch(e){a.error(`探测失败:`+(e instanceof Error?e.message:String(e)))}}var B={schema:1,note:`跨语言共享常量(Node 内核 ↔ Rust 桌面壳)的单一来源。Rust 侧 include_str! 编译期嵌入,Node 侧读取;两侧不再各存一份副本,故不可能漂移。范式取自 shell/shell-release/version-vectors.json(本仓已验证的跨语言单源先例)。`,product:{name:`lobox`,cliName:`lobox`,guiBinName:`lobox-shell`,guiCrateName:`lobox-shell`,npmScope:`@lob-ox`,corePkgPrefix:`core-`,shellReleasePkg:`@lob-ox/shell-release`,tauriIdentifier:`dev.bowen.lobox`,tauriProductName:`lobox`},state:{dirName:`lobox`,supervisorSubdir:`supervisor`,shellSubdir:`shell`,legacyHarnessDir:`.dsh`,winBaseEnv:`LOCALAPPDATA`,linuxXdgEnv:`XDG_STATE_HOME`,legacyProductName:`dsh-supervisor`,winFallbackSegments:[`AppData`,`Local`],macosSegments:[`Library`,`Application Support`],linuxFallbackSegments:[`.local`,`state`]},env:{stateRoot:`DSH_SUPERVISOR_HOME`,config:`DSH_SUPERVISOR_CONFIG`,daemon:`DSH_SUPERVISOR_DAEMON`,tray_port:`DSH_SUPERVISOR_TRAY_PORT`,shell_exe:`DSH_SHELL_EXE`,guard_bin:`DSH_GUARD_BIN`,harness_bin:`DSH_BIN`,smoke_pid:`DSH_PID`,canary:`DSH_CANARY`,canary_id:`DSH_CANARY_ID`,canary_allowlist:`DSH_CANARY_ALLOWLIST`,deploy_form:`DSH_DEPLOY_FORM`,ui_dir:`DSH_UI_DIR`,ui_skip_install:`DSH_UI_SKIP_INSTALL`,core_scope:`DSH_CORE_SCOPE`,publish_registry:`DSH_PUBLISH_REGISTRY`,npm_provenance:`DSH_NPM_PROVENANCE`,npmrc:`DSH_NPMRC`,npm_auth_prev:`DSH_NPM_AUTH_PREV`,npm_auth_prev_set:`DSH_NPM_AUTH_PREV_SET`,npm_auth_prevl:`DSH_NPM_AUTH_PREVL`,npm_auth_prevl_set:`DSH_NPM_AUTH_PREVL_SET`,npm_auth_source:`DSH_NPM_AUTH_SOURCE`,npm_auth_tmp:`DSH_NPM_AUTH_TMP`,cred_dir:`DSH_CRED_DIR`,cred_allow_overwrite:`DSH_CRED_ALLOW_OVERWRITE`,cred_force:`DSH_CRED_FORCE`,cred_backup_dir:`DSH_CRED_BACKUP_DIR`,real_home:`DSH_REAL_HOME`,arch_override:`DSH_ARCH_OVERRIDE`,platform_override:`DSH_PLATFORM_OVERRIDE`,esbuild_version:`DSH_ESBUILD_VERSION`,version_lib:`DSH_VERSION_LIB`},proc:{matchGuard:`*lobox*|*lob-ox*|*dsh*`,matchGuardNote:`进程归属判据。必须覆盖三种真实形态:CLI/壳可执行名 lobox、npm scope @lob-ox(连字符,不等于 lobox)、以及旧产品名 dsh 的历史安装。漏任一种都会让无锚点兜底判据对该形态返回非我方。`,matchGui:`lobox-shell`,matchGuiRe:`lobox-shell(\\\\.exe)?`},bridge:{msgKernelUpdateRequest:`lobox:kernel-update-request`,msgKernelUpdateResult:`lobox:kernel-update-result`,msgKernelUpdateProgress:`lobox:kernel-update-progress`,mgmtTokenHeader:`x-lobox-mgmt-token`},net:{apiPort:37360,routerCtlPort:43107,lanCtlPort:43108,deprecatedApiPorts:[36360],dshDefaultPort:3080},runtime:{minNode:`v22.12.0`,npmDefaultRegistry:`https://registry.npmjs.org`},packaging:{seaBundleName:`core.cjs`,seaVersionDefine:`__DSH_VERSION__`,kernelArchiveTemplate:`lobox-{ver}.tar.gz`,kernelReleaseTarballTemplate:`lobox-kernel-{ver}-{plat}.tar.gz`,launcherDirTemplate:`lobox-{ver}-{plat}-{arch}`,installerNsisWinX64Template:`{product}_{ver}_x64-setup.exe`,installerMacosAppTemplate:`{product}.app.tar.gz`,installerDebLinuxX64Template:`{product}_{ver}_amd64.deb`,installerDmgArm64Template:`{product}_{ver}_aarch64.dmg`,installerDmgX64Template:`{product}_{ver}_x64.dmg`},platform:{windowsGuiTask:`Lobox-Shell`,windowsRunValue:`Lobox`,systemdUnitName:`lobox`,systemdUnitFile:`lobox.service`,systemdTemplateAsideSuffix:`.disabled-by-lobox-`,cliBinNames:[`lobox.exe`,`lobox.cmd`,`lobox`]},event:{harness_exited:`harness_exited`,harness_token_captured:`harness_token_captured`,harness_token_missing:`harness_token_missing`,harness_command_missing:`harness_command_missing`,harness_not_installed:`harness_not_installed`,harness_command_bound:`harness_command_bound`,harness_guardian_changed:`harness_guardian_changed`,harness_remote_changed:`harness_remote_changed`,harness_remote_token_changed:`harness_remote_token_changed`,lan_harness_token_updated:`lan_harness_token_updated`,upgrade_stopping_harness:`upgrade_stopping_harness`,shell_update_pending:`shell_update_pending`,shell_update_checked:`shell_update_checked`,shell_restart_requested:`shell_restart_requested`},store:{keyApiAccess:`lobox.apiAccessKey`,cookieLanToken:`lobox_lan_token`}},V=B.bridge.msgKernelUpdateRequest,H=B.bridge.msgKernelUpdateResult,U=B.bridge.msgKernelUpdateProgress,W=12e5;function G(e){return new Promise(t=>{if(!K()){t({ok:!1,error:`内核更新由桌面壳执行:请在桌面壳面板中操作。`});return}let n=`kupd-`+Date.now()+`-`+Math.random().toString(36).slice(2,8),r=Date.now(),i=!1,a=null,o=setTimeout(s,W);function s(){l(a?{ok:!1,error:`桌面壳无响应(更新请求超时;最后一次进度:`+a+`)`}:{ok:!1,error:`桌面壳无响应(更新请求超时)`})}let c=e=>{clearTimeout(o),o=setTimeout(s,Math.max(0,e))},l=e=>{i||(i=!0,window.removeEventListener(`message`,u),clearTimeout(o),t(e))},u=t=>{let i=t.data;if(!(!i||typeof i!=`object`)&&t.source===window.parent&&i.v===2&&(i.type===H||i.type===U)&&i.requestId===n){if(i.type===U){let t=typeof i.status==`string`&&i.status?i.status:null;t&&(a=t),e?.({stage:typeof i.stage==`string`?i.stage:null,status:t,progress:typeof i.progress==`number`?i.progress:null});let n=typeof i.maxWaitMs==`number`?i.maxWaitMs:0;n>0&&c(n-(Date.now()-r));return}l({ok:i.ok===!0,stage:i.stage??null,version:i.version??null,restartUncertain:i.restartUncertain===!0,error:i.error??null})}};window.addEventListener(`message`,u);try{window.parent.postMessage({v:2,type:V,requestId:n},`*`)}catch(e){l({ok:!1,error:String(e)})}})}function K(){try{return window.parent!==window}catch{return!1}}var q=`DeepSeek Harness 管家`,J=`独立于 Harness 运行的系统级守卫:负责启动、存活监测与故障自动重启被监管目标,提供生命周期管理、智能路由、远程控制与多实例沙箱的运维面板。`,Y=e=>e?String(e).replace(/^v/i,``):`—`;function X(){let[e,i]=(0,P.useState)(null),[o,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(!1),[d,p]=(0,P.useState)(`dsh`),[m,h]=(0,P.useState)(``),[g,_]=(0,P.useState)(null),{busy:v,run:y}=A(),b=t(),x=(0,P.useCallback)(async e=>{p(e),h(``),u(!0);try{let t=e===`dsh`?await f.dshChangelog():await f.guardChangelog();h(t||`(无内容)`)}catch(e){h(`加载失败:`+String(e))}},[]),S=(0,P.useCallback)(async()=>{let[e,t,n,r]=await Promise.all([f.guardVersion().catch(()=>null),f.selfUpdateStatus().catch(()=>null),f.shellStatus().catch(()=>null),f.shellCheckUpdate().catch(()=>null)]);e&&i(t=>({...t||{},...e})),t&&t.ok!==!1&&i(e=>({...e||{},...t})),n&&c(e=>({...e||{},version:n.identity?.version||null,capable:n.identity?.selfUpdateCapable===!0,installKind:n.identity?.installKind})),r&&c(e=>({...e||{},latest:r.latest||null,updateAvailable:r.updateAvailable===!0,error:r.error||null}))},[]);(0,P.useEffect)(()=>{S()},[S]);let w=async()=>{await y(`chk`,async()=>{let e=`内核:状态未知`,t=await f.selfUpdateStatus().catch(()=>null);if(t&&t.ok!==!1)i(e=>({...e||{},...t})),e=t.managedBy===`desktop-shell`?`内核 `+Y(t.installed)+`(更新由桌面壳统一执行)`:t.updateAvailable===!0&&t.latest?`内核有新版本 `+Y(t.latest)+`(当前 `+Y(t.installed)+`)`:`内核已是最新(`+Y(t.installed)+`)`;else{let n=await f.guardVersion().catch(()=>null);if(n?.upstream===`git-repo`){let t=await f.guardVersionCheck().catch(()=>null);i(e=>({...e||{},...n||{},...t||{}})),e=t?.updateAvailable?`内核源码仓库有上游更新(当前提交 `+(t.commit||n?.commit||`—`)+`)`:`内核源码仓库已是最新(提交 `+(n?.commit||t?.commit||`—`)+`)`}else e=`内核:`+(t&&t.error||`自更新未配置`)}let n=await f.shellCheckUpdate().catch(()=>null),r=`桌面壳:状态未知`;n&&n.ok!==!1?(c(e=>({...e||{},latest:n.latest||null,updateAvailable:n.updateAvailable===!0,error:null})),r=n.updateAvailable&&n.latest?`桌面壳有新版本 `+Y(n.latest)+`(当前 `+Y(n.installed)+`)`:`桌面壳已是最新(`+Y(n.installed)+`)`):(c(e=>({...e||{},error:n&&n.error||`检测失败`})),r=`桌面壳:`+(n&&n.error||`检测失败`)),t?.updateAvailable&&t?.latest||n?.updateAvailable&&n?.latest?a.warning(e+`;`+r):a.success(e+`;`+r)},{refresh:!1})},O=async()=>{if(!K()){a.error(`内核更新由桌面壳执行:请在桌面壳面板中操作。`);return}await b({title:`发现内核新版本 `+Y(e?.latest)+`,是否立即更新?`,description:`内核将由桌面壳安装,并自动重启守卫。`,confirmText:`更新`})&&await y(`upd`,async()=>{_({status:`已向桌面壳发出更新请求,等待响应…`});let t=await G(_);if(!t.ok){a.error(t.error||`更新失败`);return}let n=Y(t.version||e?.latest);t.restartUncertain?a.warning(`内核已更新至 `+n+`,但守卫可能未自动重启,请手动确认。`):a.success(`内核已更新至 `+n+`,守卫已重启。`)},{refresh:!0,onDone:()=>_(null)})},k=e?.updateAvailable===!0&&!!(e?.latest&&e.latest!==e?.installed),I=!!(o?.updateAvailable&&o?.latest&&o.latest!==o?.version),L=o?.capable===!1;return(0,F.jsxs)(N,{children:[(0,F.jsx)(j,{title:`关于`,subtitle:q,actions:(0,F.jsxs)(n,{size:`sm`,disabled:v===`chk`,onClick:()=>void w(),variant:`outline`,children:[(0,F.jsx)(D,{className:r(`size-3.5`,v===`chk`&&`animate-spin`)}),`检查更新`]})}),(0,F.jsxs)(`div`,{className:`grid gap-3 px-5 py-4`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] items-baseline gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`桌面壳版本`}),(0,F.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-foreground`,children:[Y(o?.version),o?.installKind?(0,F.jsxs)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:[`(`,o.installKind,`)`]}):null,I?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(M,{tone:`warn`,children:[`可更新 `,Y(o?.latest)]}),(0,F.jsx)(M,{tone:`off`,children:`请重启桌面壳应用更新`})]}):null,L?(0,F.jsx)(M,{tone:`off`,children:`当前形态不支持自更新`}):null,o?.error?(0,F.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:o.error}):null]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-[96px_minmax(0,1fr)] items-baseline gap-3`,children:[(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`内核版本`}),(0,F.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-foreground`,children:[Y(e?.installed||e?.version),k?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(M,{tone:`warn`,children:[`可更新 `,Y(e?.latest)]}),K()?(0,F.jsxs)(n,{size:`chip`,disabled:v===`upd`,onClick:()=>void O(),variant:`outline`,children:[(0,F.jsx)(D,{className:r(`size-3`,v===`upd`&&`animate-spin`)}),`更新`]}):(0,F.jsx)(M,{tone:`off`,children:`请在桌面壳中更新`})]}):null]})]}),g?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,F.jsx)(D,{className:`size-3 shrink-0 animate-spin`}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:g.status||`桌面壳处理中…`}),typeof g.progress==`number`?(0,F.jsxs)(`span`,{className:`tabular-nums font-medium text-foreground`,children:[Math.round(g.progress*100),`%`]}):null]}):null,(0,F.jsx)(`p`,{className:`border-t border-border/60 pt-3 text-xs leading-relaxed text-muted-foreground`,children:J}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border/60 pt-3`,children:[(0,F.jsx)(n,{size:`chip`,variant:`outline`,onClick:()=>void x(`dsh`),children:`DSH 更新日志`}),(0,F.jsx)(n,{size:`chip`,variant:`outline`,onClick:()=>void x(`guard`),children:`管家更新日志`})]})]}),(0,F.jsx)(C,{open:l,onOpenChange:u,children:(0,F.jsxs)(E,{className:`max-w-[560px]`,children:[(0,F.jsx)(T,{children:(0,F.jsx)(s,{children:d===`dsh`?`DeepSeek Harness 更新日志`:`管家更新日志`})}),(0,F.jsx)(`pre`,{className:`max-h-[50vh] overflow-auto whitespace-pre-wrap break-words rounded-md border border-border/60 bg-muted/30 p-3 text-xs leading-relaxed text-foreground`,children:m||`加载中…`})]})})]})}function Z(){return(0,F.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,F.jsx)(I,{}),(0,F.jsx)(R,{}),(0,F.jsx)(X,{})]})}export{Z as SettingsPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{I as e,L as t,O as n,R as r,U as i,V as a,a as o}from"./supervisor-
|
|
1
|
+
import{I as e,L as t,O as n,R as r,U as i,V as a,a as o}from"./supervisor-DSBgs_XY.js";import{t as s}from"./refresh-cw-GKBYw9-E.js";import{a as c,f as l,i as u,o as d}from"./supervisor-DWUbDZTX.js";import{o as f,t as p}from"./widgets-DV5fuKzB.js";import{r as m}from"./format-QeaTKFhQ.js";var h=i(a(),1),g=r();function _(){let[r,i]=(0,h.useState)(null),[a,_]=(0,h.useState)(!1),[v,y]=(0,h.useState)(``);async function b(){try{let e=await o.tasks();i(e.tasks)}catch(e){n.error(String(e))}}(0,h.useEffect)(()=>{b()},[]);async function x(){_(!0);try{await b(),n.success(`任务中心已刷新`)}catch{}finally{_(!1)}}let S=[`native`,`instance`,`plugin`,`proxy-app`],C=(r??[]).filter(e=>!v||e.kind===v);return(0,g.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,g.jsx)(e,{className:t(v?`text-muted-foreground hover:bg-muted hover:text-foreground`:`bg-primary/10 text-primary hover:bg-primary/15`),onClick:()=>y(``),size:`sm`,variant:`ghost`,children:`全部`}),S.map(n=>(0,g.jsx)(e,{className:t(v===n?`bg-primary/10 text-primary hover:bg-primary/15`:`text-muted-foreground hover:bg-muted hover:text-foreground`),onClick:()=>y(n),size:`sm`,variant:`ghost`,children:c[n]||n},n))]}),(0,g.jsxs)(e,{onClick:()=>void x(),variant:`outline`,children:[(0,g.jsx)(s,{className:t(`size-4`,a&&`animate-spin`)}),`刷新`]})]}),r?C.length?(0,g.jsx)(`div`,{className:`grid gap-3`,children:C.map(e=>{let n=d[e.state]||{label:e.state,tone:`off`},r=e.from&&e.to&&e.from!==e.to?e.from+` → `+e.to:e.to?`→ `+e.to:``,i=e.steps||[];return(0,g.jsxs)(p,{className:`p-4`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,g.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:c[e.kind]||e.kind}),(0,g.jsx)(f,{tone:`boot`,children:u[e.action]||e.action}),(0,g.jsx)(`strong`,{className:`truncate text-sm text-foreground`,children:e.target.name}),r?(0,g.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:r}):null]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,g.jsx)(f,{tone:n.tone,children:n.label}),(0,g.jsxs)(`span`,{className:`whitespace-nowrap`,children:[m(e.startedAt),e.finishedAt?` ~ `+m(e.finishedAt):``]})]})]}),e.error?(0,g.jsx)(`p`,{className:`mt-2 truncate text-xs text-destructive`,title:e.error,children:e.error}):null,i.length?(0,g.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:i.map((e,n)=>(0,g.jsxs)(`span`,{className:t(`inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs leading-tight`,e.state===`done`&&`bg-success-background text-success`,e.state===`running`&&`bg-primary/10 text-primary`,e.state===`failed`&&`bg-careful-background text-careful`,(!e.state||e.state===`pending`)&&`bg-muted text-muted-foreground`),children:[e.state===`running`?(0,g.jsx)(`span`,{className:`size-1.5 animate-pulse rounded-full bg-primary`}):null,e.name]},n))}):null,e.logTail?.length?(0,g.jsxs)(`details`,{className:`mt-3`,children:[(0,g.jsxs)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground`,children:[`日志(`,e.logTail.length,`)`]}),(0,g.jsx)(`pre`,{className:`mt-2 max-h-[180px] overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/70 p-3 font-mono text-xs leading-relaxed text-muted-foreground`,children:e.logTail.join(`
|
|
2
2
|
`)})]}):null]},e.id)})}):(0,g.jsxs)(`div`,{className:`grid place-items-center rounded-lg border border-dashed border-border py-16 text-center`,children:[(0,g.jsx)(l,{className:`mx-auto mb-3 size-8 text-muted-foreground`}),(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无任务记录。安装 / 升级 / 卸载 / 更新操作完成后会在此显示状态与历史。`})]}):(0,g.jsx)(`div`,{className:`grid place-items-center py-16 text-sm text-muted-foreground`,children:`加载中…`})]})}export{_ as TasksPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as e,O as t,R as n,a as r}from"./supervisor-
|
|
1
|
+
import{N as e,O as t,R as n,a as r}from"./supervisor-DSBgs_XY.js";import{t as i}from"./supervisor-DWUbDZTX.js";var a=e(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),o=e(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]);function s(){let e=String(window.location.hostname||``).toLowerCase();return e===`localhost`||e===`[::1]`||e===`::1`||/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(e)}function c(e){try{return window.open(e,`_blank`,`noopener,noreferrer`)?{ok:!0,confirmed:!0,handedOff:!1,url:e,message:`已在新标签打开`,evidence:{via:`window`}}:{ok:!1,url:e,error:`浏览器拦截了新窗口,请允许弹窗或复制下方地址打开`}}catch(t){return{ok:!1,url:e,error:String(t)}}}async function l(e){return e?s()?r.envOpenUrl(e):c(e):{ok:!1,error:`没有可打开的地址`}}function u(e){if(!e||typeof e!=`object`)return null;let t=typeof e.bin==`string`?e.bin.split(/[\\/]/).pop():null,n=[];t?n.push(t):e.via===`none`&&n.push(`未定出启动对象`),e.via&&n.push(e.via),e.engine&&n.push(`引擎 `+e.engine),e.ownsWindow===!1&&n.push(`退出码不作证据`),e.watch===!0&&n.push(`关掉该窗口即取消本次登录`),e.exitCode!==void 0&&e.exitCode!==null?n.push(`exit `+String(e.exitCode)):e.exitSignal?n.push(`signal `+e.exitSignal):e.error&&n.push(String(e.error));let r=e.diagnostics;if(r&&typeof r==`object`){n.push(`默认项来源 `+(r.default&&r.default.source||`未读出`)),r.pick===`user-preference`?n.push(`按你在环境检测里选的浏览器`):r.pick===`candidate-rank`?n.push(`系统未报默认项,已按候选次序取首个(可在环境检测里改)`):r.pick===`only-installed`?n.push(`本机唯一候选`):r.pick===`none-found`&&n.push(`本机未探到可用浏览器`),r.preference&&r.preference.id&&r.preference.matched===!1&&n.push(`你选的浏览器已不在候选清单,请重选`);let e=Array.isArray(r.found)?r.found:[];n.push(`候选 `+String(e.length)+` 个`+(e.length?`:`+e.map(e=>(e.name||e.via||`?`)+(e.engine?`(`+e.engine+`)`:``)).join(`、`):``));let t=Array.isArray(r.probed)?r.probed:[];!e.length&&t.length&&n.push(`探测读数:`+t.map(e=>e.source+(e.detail?`=`+String(e.detail):``)).join(`、`))}e.via===`isolated`&&n.push(e.isolated===!1?`未隔离(并入既有窗口)`:`隔离窗口`),e.profile&&n.push(`隔离档案 `+e.profile);let i=e.egress;return i&&typeof i==`object`&&i.basis&&n.push(`出网判定 `+i.basis+`(`+(i.host||`未定主机`)+` 代理 `+(i.proxy||`未读出`)+`)`),n.length?n.join(` | `):null}function d(e){return!e||e.isolated!==!1?null:e.isolatedBasis===`cold-profile-blocked`?`本次登录没有用隔离窗口:`+(e.isolatedDetail||`本机直连授权域不通且没有在用代理`)+`。已在现有浏览器窗口打开,登录完成后请手动清理账号;在系统里配好代理即可回到隔离登录。`:e.isolatedBasis===`engine-not-isolatable`?`默认浏览器不支持隔离窗口:本次登录会带现有登录态,换账号请先在该浏览器退出`:`本次登录未使用隔离窗口`+(e.isolatedDetail?`:`+e.isolatedDetail:`,换账号请先在浏览器里退出`)}function f(e){let t=typeof e?.url==`string`&&e.url?e.url:typeof e?.authUrl==`string`?e.authUrl:``;return t.startsWith(`https://`)?t:``}function p(e){let t=typeof e?.url==`string`&&e?.url?e.url:null,n=u(e?.evidence),r=e?.evidence,i=!!r&&(r.via===`isolated`||!!r.egress),a=[typeof e?.message==`string`&&e.message?e.message:null,n].filter(Boolean).join(` | `)||null;return!e||e.ok!==!0?{tier:`failed`,url:t,detail:a,title:e&&e.error||`无法调起系统浏览器,请手动打开下方地址`,reveal:!0}:e.confirmed===!0?{tier:`confirmed`,url:t,detail:a,title:e.message||`已在系统浏览器打开`,reveal:i}:{tier:`handed-off`,url:t,detail:a,reveal:!0,title:`已把地址交给系统,但没拿到窗口出现的证据`+(t?`:没看到浏览器就点下方地址`:``)}}var m=n();function h({url:e}){async function t(){await v(()=>l(e))}function n(){i(e,`地址已复制`)}return(0,m.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,m.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>void t(),title:`在系统浏览器中打开该地址`,className:`shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,m.jsx)(o,{className:`size-3.5`})}),(0,m.jsx)(`button`,{type:`button`,onClick:n,title:`复制地址`,className:`shrink-0 text-muted-foreground transition-colors hover:text-foreground`,children:(0,m.jsx)(a,{className:`size-3.5`})})]})}function g({url:e,detail:t}){return(0,m.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[e?(0,m.jsx)(h,{url:e}):null,t?(0,m.jsx)(`div`,{className:`break-all font-mono text-[10px] text-muted-foreground`,children:t}):null]})}function _(e){let{tier:n,url:r,title:i,detail:a,reveal:o}=p(e),s=o?a:null,c={description:r||s?(0,m.jsx)(g,{url:r,detail:s}):void 0,duration:n===`confirmed`?o?12e3:3e3:2e4};n===`confirmed`?t.success(i,c):n===`handed-off`?t.warning(i,c):t.error(i,c)}async function v(e){try{let t=await e()??{ok:!1,error:`未返回结果`};return _(t),t}catch(e){let t=e.body,n=t&&typeof t==`object`?t:{ok:!1,error:e instanceof Error?e.message:String(e)};return _(n),n}}export{f as a,d as i,v as n,o,l as r,a as s,h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as e}from"./supervisor-
|
|
1
|
+
import{N as e}from"./supervisor-DSBgs_XY.js";var t=e(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{N as e}from"./supervisor-
|
|
1
|
+
import{N as e}from"./supervisor-DSBgs_XY.js";var t=e(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),n=e(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]);export{t as n,n as t};
|