autoglm-gui 1.5.2__py3-none-any.whl → 1.5.3__py3-none-any.whl
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.
- AutoGLM_GUI/api/agents.py +2 -2
- AutoGLM_GUI/static/assets/{about-D7r9gCvG.js → about-DTrVqEQH.js} +1 -1
- AutoGLM_GUI/static/assets/{alert-dialog-BKM-yRiQ.js → alert-dialog-B2KxPLtZ.js} +1 -1
- AutoGLM_GUI/static/assets/{chat-k6TTD7PW.js → chat-BkrVbc3X.js} +3 -3
- AutoGLM_GUI/static/assets/{circle-alert-sohSDLhl.js → circle-alert-vnNxOaxv.js} +1 -1
- AutoGLM_GUI/static/assets/{dialog-BgtPh0d5.js → dialog-Cuw3N8_F.js} +1 -1
- AutoGLM_GUI/static/assets/{eye-DLqKbQmg.js → eye-JD1jbm99.js} +1 -1
- AutoGLM_GUI/static/assets/{history-Bv1lfGUU.js → history-CobYdXju.js} +1 -1
- AutoGLM_GUI/static/assets/{index-SysdKciY.js → index-BzP-Te33.js} +2 -2
- AutoGLM_GUI/static/assets/{index-CxWwh1VO.js → index-y1vOOBHH.js} +1 -1
- AutoGLM_GUI/static/assets/{label-DTUnzN4B.js → label-BpCMrXj_.js} +1 -1
- AutoGLM_GUI/static/assets/{logs-BIhnDizW.js → logs-BcsSAeol.js} +1 -1
- AutoGLM_GUI/static/assets/{popover-CikYqu2P.js → popover-BHbCs5Wl.js} +1 -1
- AutoGLM_GUI/static/assets/{scheduled-tasks-B-KBsGbl.js → scheduled-tasks-WvtmRsex.js} +1 -1
- AutoGLM_GUI/static/assets/{textarea-knJZrz77.js → textarea-B84jf3cE.js} +1 -1
- AutoGLM_GUI/static/assets/{workflows-DzcSYwLZ.js → workflows-DhBpqdz_.js} +1 -1
- AutoGLM_GUI/static/index.html +1 -1
- {autoglm_gui-1.5.2.dist-info → autoglm_gui-1.5.3.dist-info}/METADATA +1 -1
- {autoglm_gui-1.5.2.dist-info → autoglm_gui-1.5.3.dist-info}/RECORD +22 -22
- {autoglm_gui-1.5.2.dist-info → autoglm_gui-1.5.3.dist-info}/WHEEL +0 -0
- {autoglm_gui-1.5.2.dist-info → autoglm_gui-1.5.3.dist-info}/entry_points.txt +0 -0
- {autoglm_gui-1.5.2.dist-info → autoglm_gui-1.5.3.dist-info}/licenses/LICENSE +0 -0
AutoGLM_GUI/api/agents.py
CHANGED
|
@@ -168,7 +168,7 @@ async def chat(request: ChatRequest) -> ChatResponse:
|
|
|
168
168
|
acquired = False
|
|
169
169
|
try:
|
|
170
170
|
acquired = await asyncio.to_thread(
|
|
171
|
-
manager.acquire_device, device_id, timeout=None, auto_initialize=
|
|
171
|
+
manager.acquire_device, device_id, timeout=None, auto_initialize=True
|
|
172
172
|
)
|
|
173
173
|
# Use chat context with async agent
|
|
174
174
|
agent = await asyncio.to_thread(
|
|
@@ -247,7 +247,7 @@ async def chat_stream(request: ChatRequest):
|
|
|
247
247
|
device_id,
|
|
248
248
|
timeout=0,
|
|
249
249
|
raise_on_timeout=True,
|
|
250
|
-
auto_initialize=
|
|
250
|
+
auto_initialize=True,
|
|
251
251
|
)
|
|
252
252
|
|
|
253
253
|
try:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as o}from"./index-
|
|
1
|
+
import{j as o}from"./index-BzP-Te33.js";function t(){return o.jsx("div",{className:"p-2",children:o.jsx("h3",{children:"About"})})}export{t as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as u,r as o,j as a,b as r,B as d}from"./index-
|
|
1
|
+
import{o as u,r as o,j as a,b as r,B as d}from"./index-BzP-Te33.js";import{P as g,c as x,b as f,d as m}from"./popover-BHbCs5Wl.js";import{D as p,d as h,e as w,f as j,g as D}from"./dialog-Cuw3N8_F.js";const N=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],b=u("check",N),c=o.createContext(void 0),P=({value:t="",onValueChange:e,children:s})=>{const[n,l]=o.useState(!1);return a.jsx(c.Provider,{value:{value:t,onValueChange:e||(()=>{}),open:n,setOpen:l},children:a.jsx(g,{open:n,onOpenChange:l,children:s})})},C=o.forwardRef(({className:t,children:e,...s},n)=>{if(!o.useContext(c))throw new Error("SelectTrigger must be used within Select");return a.jsx(x,{asChild:!0,children:a.jsxs("button",{ref:n,className:r("flex h-10 w-full items-center justify-between rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-slate-500 focus:outline-none focus:ring-2 focus:ring-slate-950 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus:ring-slate-300",t),...s,children:[e,a.jsx(f,{className:"h-4 w-4 opacity-50"})]})})});C.displayName="SelectTrigger";const V=({placeholder:t})=>{const e=o.useContext(c);if(!e)throw new Error("SelectValue must be used within Select");return a.jsx("span",{className:e.value?"":"text-slate-500",children:e.value||t})},I=({children:t,className:e})=>a.jsx(m,{className:r("w-[var(--radix-popover-trigger-width)] p-1",e),children:t}),O=({value:t,children:e,disabled:s,className:n})=>{const l=o.useContext(c);if(!l)throw new Error("SelectItem must be used within Select");const i=l.value===t;return a.jsxs("div",{role:"option","aria-selected":i,className:r("relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none hover:bg-slate-100 focus:bg-slate-100 dark:hover:bg-slate-800 dark:focus:bg-slate-800",s&&"pointer-events-none opacity-50",n),onClick:()=>{s||(l.onValueChange(t),l.setOpen(!1))},children:[a.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:i&&a.jsx(b,{className:"h-4 w-4"})}),e]})},B=({open:t,onOpenChange:e,children:s})=>a.jsx(p,{open:t,onOpenChange:e,children:s}),v=o.forwardRef(({className:t,...e},s)=>a.jsx(h,{ref:s,className:r("sm:max-w-[425px]",t),...e}));v.displayName="AlertDialogContent";const F=({className:t,...e})=>a.jsx(w,{className:r(t),...e}),H=({className:t,...e})=>a.jsx(D,{className:r(t),...e}),A=o.forwardRef(({className:t,...e},s)=>a.jsx(j,{ref:s,className:r(t),...e}));A.displayName="AlertDialogTitle";const S=o.forwardRef(({className:t,...e},s)=>a.jsx("p",{ref:s,className:r("text-sm text-slate-500 dark:text-slate-400",t),...e}));S.displayName="AlertDialogDescription";const y=o.forwardRef(({className:t,...e},s)=>a.jsx(d,{ref:s,className:r(t),...e}));y.displayName="AlertDialogAction";const k=o.forwardRef(({className:t,...e},s)=>a.jsx(d,{ref:s,variant:"outline",className:r(t),...e}));k.displayName="AlertDialogCancel";export{B as A,P as S,C as a,V as b,I as c,O as d,v as e,F as f,A as g,S as h,H as i,k as j,y as k};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{o as $e,j as a,u as An,r as E,T as en,t as tn,v as nn,B as Ee,f as Hn,w as _x,x as xx,y as Xs,R as Ye,z as _n,A as jc,D as uu,P as Vt,E as _t,G as du,H as Tn,I as Br,b as cr,J as As,K as vx,L as bx,M as yx,N as wx,O as Ex,S as Tr,Q as Pc,U as Sx,V as Nx,W as Cx,X as fu,Y as Tx,Z as Ic,_ as Lc,$ as Rx,a0 as kx,a1 as Ax,a2 as jx,a3 as Px,a4 as Fs,a5 as hu,p as pu,l as mu,q as gu,s as _u,a6 as xu,a7 as Ix,a8 as Lx,a9 as Mx,aa as Dx,ab as Ox,ac as Bx,ad as Fx,ae as Ux,af as Wx,ag as Hx}from"./index-SysdKciY.js";import{L as Yt,T as vu,D as Fo,d as Uo,e as Wo,f as Ho,h as Go,g as zo,C as Ys}from"./dialog-BgtPh0d5.js";import{S as Gx,L as nt,I as ht,P as bu}from"./label-DTUnzN4B.js";import{C as yu,E as mo}from"./eye-DLqKbQmg.js";import{C as kn}from"./circle-alert-sohSDLhl.js";import{C as Mc,a as Dc,P as Us,c as Ws,d as Hs,b as zx}from"./popover-CikYqu2P.js";import{T as wu}from"./textarea-knJZrz77.js";const qx=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],$x=$e("arrow-up-down",qx);const Xx=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Eu=$e("brain",Xx);const Yx=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Su=$e("chevron-left",Yx);const Vx=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Kx=$e("chevron-up",Vx);const Qx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Fr=$e("circle-check",Qx);const Jx=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Zx=$e("cpu",Jx);const ev=[["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"}]],Oc=$e("external-link",ev);const tv=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Bc=$e("eye-off",tv);const nv=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],rv=$e("fingerprint-pattern",nv);const sv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Fc=$e("image",sv);const iv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ov=$e("info",iv);const av=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Ro=$e("layers",av);const lv=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],cv=$e("maximize",lv);const uv=[["path",{d:"M5 12h14",key:"1ays0h"}]],dv=$e("minus",uv);const fv=[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],hv=$e("monitor-play",fv);const pv=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],mv=$e("plug",pv);const gv=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Nu=$e("rotate-ccw",gv);const _v=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Cu=$e("send",_v);const xv=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ko=$e("server",xv);const vv=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Tu=$e("settings",vv);const bv=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Is=$e("smartphone",bv);const yv=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],jr=$e("sparkles",yv);const wv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ru=$e("square",wv);const Ev=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Sv=$e("video",Ev);const Nv=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Cv=$e("wifi-off",Nv);const Tv=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Gs=$e("wifi",Tv);const Rv=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],kv=$e("wrench",Rv);function Uc({isOpen:i,title:n,content:r,onConfirm:o,onCancel:d,confirmText:l="确认",cancelText:_="取消"}){return i?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm animate-in fade-in duration-200",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full overflow-hidden transform transition-all animate-in zoom-in-95 duration-200",onClick:v=>v.stopPropagation(),children:[a.jsxs("div",{className:"p-6",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:n}),a.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[a.jsx("button",{onClick:v=>{v.stopPropagation(),d()},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 transition-colors",children:_}),a.jsx("button",{onClick:v=>{v.stopPropagation(),o()},className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors",children:l})]})]})}):null}function Av({id:i,serial:n,model:r,status:o,connectionType:d,displayName:l,agent:_,isActive:v,onClick:u,onConnectWifi:m,onDisconnectWifi:p,onNameUpdated:x,showToast:y}){const b=An(),N=o==="device",I=d==="usb",A=d==="wifi",D=d==="remote",[M,P]=E.useState(!1),[j,z]=E.useState(!1),[J,q]=E.useState(!1),[$,O]=E.useState(!1),[C,R]=E.useState(""),[re,pe]=E.useState(!1),X=l||r||b.deviceCard.unknownDevice,Y=()=>{if(!N||!_)return"status-agent-none";switch(_.state){case"idle":return"status-agent-idle";case"busy":return"status-agent-busy";case"error":return"status-agent-error";case"initializing":return"status-agent-initializing";default:return"status-agent-none"}},K=()=>{if(!N||!_)return b.deviceCard.statusTooltip.none;switch(_.state){case"idle":return b.deviceCard.statusTooltip.idle;case"busy":return b.deviceCard.statusTooltip.busy;case"error":return b.deviceCard.statusTooltip.error;case"initializing":return b.deviceCard.statusTooltip.initializing;default:return b.deviceCard.statusTooltip.none}},se=te=>{te.stopPropagation(),!(M||!m)&&z(!0)},oe=te=>{te.stopPropagation(),!(M||!p)&&q(!0)},Re=async()=>{z(!1),P(!0);try{m&&await m()}finally{P(!1)}},G=async()=>{q(!1),P(!0);try{p&&await p()}finally{P(!1)}},Q=te=>{te.stopPropagation(),R(l||r||""),O(!0)},ue=async()=>{try{pe(!0);const te=C.trim(),me=await xx(n,te||null);if(!me.success){y&&y(me.error||b.deviceCard.saveNameError,"error");return}O(!1),x&&x(),y&&y(b.deviceCard.saveNameSuccess,"success")}catch(te){console.error("Failed to update device name:",te),y&&y(b.deviceCard.saveNameError,"error")}finally{pe(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:u,role:"button",tabIndex:0,onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&u()},className:`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BzP-Te33.js","assets/index-CV7jGxGm.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as $e,j as a,u as An,r as E,T as en,t as tn,v as nn,B as Ee,f as Hn,w as _x,x as xx,y as Xs,R as Ye,z as _n,A as jc,D as uu,P as Vt,E as _t,G as du,H as Tn,I as Br,b as cr,J as As,K as vx,L as bx,M as yx,N as wx,O as Ex,S as Tr,Q as Pc,U as Sx,V as Nx,W as Cx,X as fu,Y as Tx,Z as Ic,_ as Lc,$ as Rx,a0 as kx,a1 as Ax,a2 as jx,a3 as Px,a4 as Fs,a5 as hu,p as pu,l as mu,q as gu,s as _u,a6 as xu,a7 as Ix,a8 as Lx,a9 as Mx,aa as Dx,ab as Ox,ac as Bx,ad as Fx,ae as Ux,af as Wx,ag as Hx}from"./index-BzP-Te33.js";import{L as Yt,T as vu,D as Fo,d as Uo,e as Wo,f as Ho,h as Go,g as zo,C as Ys}from"./dialog-Cuw3N8_F.js";import{S as Gx,L as nt,I as ht,P as bu}from"./label-BpCMrXj_.js";import{C as yu,E as mo}from"./eye-JD1jbm99.js";import{C as kn}from"./circle-alert-vnNxOaxv.js";import{C as Mc,a as Dc,P as Us,c as Ws,d as Hs,b as zx}from"./popover-BHbCs5Wl.js";import{T as wu}from"./textarea-B84jf3cE.js";const qx=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],$x=$e("arrow-up-down",qx);const Xx=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Eu=$e("brain",Xx);const Yx=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Su=$e("chevron-left",Yx);const Vx=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Kx=$e("chevron-up",Vx);const Qx=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Fr=$e("circle-check",Qx);const Jx=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Zx=$e("cpu",Jx);const ev=[["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"}]],Oc=$e("external-link",ev);const tv=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Bc=$e("eye-off",tv);const nv=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],rv=$e("fingerprint-pattern",nv);const sv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Fc=$e("image",sv);const iv=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ov=$e("info",iv);const av=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Ro=$e("layers",av);const lv=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],cv=$e("maximize",lv);const uv=[["path",{d:"M5 12h14",key:"1ays0h"}]],dv=$e("minus",uv);const fv=[["path",{d:"M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z",key:"vbtd3f"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],hv=$e("monitor-play",fv);const pv=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],mv=$e("plug",pv);const gv=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Nu=$e("rotate-ccw",gv);const _v=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Cu=$e("send",_v);const xv=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ko=$e("server",xv);const vv=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Tu=$e("settings",vv);const bv=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Is=$e("smartphone",bv);const yv=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],jr=$e("sparkles",yv);const wv=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ru=$e("square",wv);const Ev=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Sv=$e("video",Ev);const Nv=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Cv=$e("wifi-off",Nv);const Tv=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Gs=$e("wifi",Tv);const Rv=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],kv=$e("wrench",Rv);function Uc({isOpen:i,title:n,content:r,onConfirm:o,onCancel:d,confirmText:l="确认",cancelText:_="取消"}){return i?a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm animate-in fade-in duration-200",children:a.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-xl shadow-xl max-w-md w-full overflow-hidden transform transition-all animate-in zoom-in-95 duration-200",onClick:v=>v.stopPropagation(),children:[a.jsxs("div",{className:"p-6",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:n}),a.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm leading-relaxed whitespace-pre-wrap",children:r})]}),a.jsxs("div",{className:"bg-gray-50 dark:bg-gray-700/50 px-6 py-4 flex justify-end gap-3",children:[a.jsx("button",{onClick:v=>{v.stopPropagation(),d()},className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 transition-colors",children:_}),a.jsx("button",{onClick:v=>{v.stopPropagation(),o()},className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors",children:l})]})]})}):null}function Av({id:i,serial:n,model:r,status:o,connectionType:d,displayName:l,agent:_,isActive:v,onClick:u,onConnectWifi:m,onDisconnectWifi:p,onNameUpdated:x,showToast:y}){const b=An(),N=o==="device",I=d==="usb",A=d==="wifi",D=d==="remote",[M,P]=E.useState(!1),[j,z]=E.useState(!1),[J,q]=E.useState(!1),[$,O]=E.useState(!1),[C,R]=E.useState(""),[re,pe]=E.useState(!1),X=l||r||b.deviceCard.unknownDevice,Y=()=>{if(!N||!_)return"status-agent-none";switch(_.state){case"idle":return"status-agent-idle";case"busy":return"status-agent-busy";case"error":return"status-agent-error";case"initializing":return"status-agent-initializing";default:return"status-agent-none"}},K=()=>{if(!N||!_)return b.deviceCard.statusTooltip.none;switch(_.state){case"idle":return b.deviceCard.statusTooltip.idle;case"busy":return b.deviceCard.statusTooltip.busy;case"error":return b.deviceCard.statusTooltip.error;case"initializing":return b.deviceCard.statusTooltip.initializing;default:return b.deviceCard.statusTooltip.none}},se=te=>{te.stopPropagation(),!(M||!m)&&z(!0)},oe=te=>{te.stopPropagation(),!(M||!p)&&q(!0)},Re=async()=>{z(!1),P(!0);try{m&&await m()}finally{P(!1)}},G=async()=>{q(!1),P(!0);try{p&&await p()}finally{P(!1)}},Q=te=>{te.stopPropagation(),R(l||r||""),O(!0)},ue=async()=>{try{pe(!0);const te=C.trim(),me=await xx(n,te||null);if(!me.success){y&&y(me.error||b.deviceCard.saveNameError,"error");return}O(!1),x&&x(),y&&y(b.deviceCard.saveNameSuccess,"success")}catch(te){console.error("Failed to update device name:",te),y&&y(b.deviceCard.saveNameError,"error")}finally{pe(!1)}};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{onClick:u,role:"button",tabIndex:0,onKeyDown:te=>{(te.key==="Enter"||te.key===" ")&&u()},className:`
|
|
3
3
|
group relative w-full text-left p-4 rounded-xl transition-all duration-200 cursor-pointer
|
|
4
4
|
border-2
|
|
5
5
|
${v?"bg-slate-50 border-[#1d9bf0] dark:bg-slate-800/50 dark:border-[#1d9bf0]":"bg-white border-transparent hover:border-slate-200 dark:bg-slate-900 dark:hover:border-slate-700"}
|
|
@@ -126,4 +126,4 @@ void main() {
|
|
|
126
126
|
rounded-2xl px-4 py-3 flex items-start gap-2
|
|
127
127
|
${B.success===!1?"bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300"}
|
|
128
128
|
`,children:[a.jsx(Fr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${B.success===!1?"text-red-500":"text-green-500"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"whitespace-pre-wrap",children:B.content}),B.steps!==void 0&&a.jsxs("p",{className:"text-xs mt-2 opacity-60 text-slate-500 dark:text-slate-400",children:[B.steps," steps completed"]})]})]}),B.isStreaming&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500 dark:text-slate-400",children:[a.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"Processing..."]})]}):a.jsxs("div",{className:"max-w-[75%]",children:[a.jsx("div",{className:"chat-bubble-user px-4 py-3",children:a.jsx("p",{className:"whitespace-pre-wrap",children:B.content})}),a.jsx("p",{className:"text-xs text-slate-400 dark:text-slate-500 mt-1 text-right",children:B.timestamp.toLocaleTimeString()})]})},B.id)),a.jsx("div",{ref:O})]}),Y&&a.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-4 flex justify-center",children:a.jsx(Ee,{onClick:Ze,size:"sm",className:"pointer-events-auto shadow-lg bg-[#1d9bf0] text-white hover:bg-[#1a8cd8]","aria-label":l.devicePanel.newMessages,children:l.devicePanel.newMessages})})]}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(wu,{value:u,onChange:B=>m(B.target.value),onKeyDown:Ge,placeholder:d?l.devicePanel.whatToDo:l.devicePanel.configureFirst,disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs(Us,{open:J,onOpenChange:q,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(hu,{className:"w-4 h-4"})})}),a.jsx(Hs,{align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-medium text-sm",children:l.workflows.selectWorkflow}),j.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:l.workflows.empty}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Dr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:j.map(B=>a.jsxs("button",{onClick:()=>ae(B),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsx("div",{className:"font-medium text-sm",children:B.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:B.text})]},B.uuid))})})]})})]})}),a.jsx(nn,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:l.devicePanel.tooltips.workflowButton}),a.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel.tooltips.workflowButtonDesc})]})})]}),p&&a.jsx(Ee,{onClick:te,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat.abortChat,children:y?a.jsx(Yt,{className:"h-4 w-4 animate-spin"}):a.jsx(Ru,{className:"h-4 w-4"})}),!p&&a.jsx(Ee,{onClick:Q,disabled:!u.trim(),size:"icon",variant:"twitter",className:"h-10 w-10 rounded-full flex-shrink-0",children:a.jsx(Cu,{className:"h-4 w-4"})})]})})]}),a.jsx(Nd,{deviceId:i,serial:n,connectionType:o,isVisible:!0})]})}function hy({deviceId:i,deviceSerial:n,deviceName:r,deviceConnectionType:o,isVisible:d}){const l=An(),[_,v]=E.useState([]),[u,m]=E.useState(""),[p,x]=E.useState(!1),[y,b]=E.useState(!1),[N,I]=E.useState(null),A=E.useRef(null),D=E.useRef(null),M=E.useRef(null),[P,j]=E.useState([]),[z,J]=E.useState(!1),[q,$]=E.useState([]),[O,C]=E.useState(!1);E.useEffect(()=>{A.current?.scrollIntoView({behavior:"smooth"})},[_]),E.useEffect(()=>()=>{D.current&&D.current.close()},[]),E.useEffect(()=>{(async()=>{try{const Q=await mu();j(Q.workflows)}catch(Q){console.error("Failed to load workflows:",Q)}})()},[]),E.useEffect(()=>{O&&(async()=>{try{const Q=await pu(n,20,0);$(Q.records)}catch(Q){console.error("Failed to load history:",Q),$([])}})()},[O,n]);const R=G=>{m(G.text),J(!1)},re=G=>{const Q={id:`${G.id}-user`,role:"user",content:G.task_text,timestamp:new Date(G.start_time)},ue={id:`${G.id}-agent`,role:"assistant",content:G.final_message,timestamp:G.end_time?new Date(G.end_time):new Date(G.start_time),steps:[],success:G.success,isStreaming:!1};v([Q,ue]),C(!1)},pe=async()=>{if(confirm(l.history?.clearAllConfirm||"Clear all history?"))try{await gu(n),$([])}catch(G){console.error("Failed to clear history:",G)}},X=async G=>{try{await _u(n,G),$(Q=>Q.filter(ue=>ue.id!==G))}catch(Q){console.error("Failed to delete history item:",Q)}},Y=(G,Q)=>{v(ue=>ue.map(te=>te.id===G?{...te,steps:te.steps?.map(me=>me.id===Q?{...me,isExpanded:!me.isExpanded}:me)}:te))},K=E.useCallback(async()=>{const G=u.trim();if(!G||p)return;const Q={id:Date.now().toString(),role:"user",content:G,timestamp:new Date};v(ae=>[...ae,Q]),m(""),x(!0),I(null);const ue=(Date.now()+1).toString(),te={id:ue,role:"assistant",content:"",timestamp:new Date,steps:[],isStreaming:!0};v(ae=>[...ae,te]);const me=new AbortController;M.current=me;try{const ae=await fetch("/api/layered-agent/chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:G,device_id:i,session_id:i}),signal:me.signal});if(!ae.ok){let ce=`HTTP error! status: ${ae.status}`;try{const ye=await ae.json();ye.detail&&(ce=ye.detail)}catch{}throw new Error(ce)}const Ue=ae.body?.getReader();if(!Ue)throw new Error("No response body");const Ze=new TextDecoder;let Ge="";const B=[];for(;;){const{done:ce,value:ye}=await Ue.read();if(ce)break;Ge+=Ze.decode(ye,{stream:!0});const Be=Ge.split(`
|
|
129
|
-
`);Ge=Be.pop()||"";for(const We of Be)if(We.startsWith("data: "))try{const de=JSON.parse(We.slice(6));if(de.type==="tool_call"){const Se={id:`step-${Date.now()}-${Math.random()}`,type:"tool_call",content:de.tool_name==="chat"?"发送指令给 Phone Agent":de.tool_name==="list_devices"?"获取设备列表":`调用工具: ${de.tool_name}`,toolName:de.tool_name,toolArgs:de.tool_args||{},timestamp:new Date,isExpanded:!0};B.push(Se),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...B]}:Z))}else if(de.type==="tool_result"){const Se={id:`step-${Date.now()}-${Math.random()}`,type:"tool_result",content:de.tool_name==="chat"?"Phone Agent 执行结果":`${de.tool_name} 结果`,toolResult:de.result,timestamp:new Date,isExpanded:!0};B.push(Se),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...B]}:Z))}else if(de.type==="message")v(Se=>Se.map(ee=>ee.id===ue?{...ee,content:de.content}:ee));else if(de.type==="done"){const Se={...te,content:de.content||"",isStreaming:!1,success:de.success,steps:[...B],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Se:Z))}else if(de.type==="error"){const Se={...te,content:`错误: ${de.message}`,isStreaming:!1,success:!1,steps:[...B],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Se:Z)),I(de.message)}}catch(de){console.error("Failed to parse SSE data:",de,We)}}v(ce=>ce.map(ye=>ye.id===ue&&ye.isStreaming?{...ye,isStreaming:!1,success:!0}:ye))}catch(ae){if(ae instanceof Error&&ae.name==="AbortError"){console.log("Chat aborted by user");return}console.error("Chat error:",ae);const Ue=xu(ae);I(Ue),v(Ze=>Ze.map(Ge=>Ge.id===ue?{...Ge,content:`错误: ${Ue}`,isStreaming:!1,success:!1}:Ge))}finally{x(!1),M.current=null}},[u,p,i]),se=E.useCallback(()=>{if(M.current){b(!0);try{M.current.abort(),M.current=null,v(G=>{const Q=G[G.length-1];return Q&&Q.role==="assistant"&&Q.isStreaming?G.map((ue,te)=>te===G.length-1?{...ue,content:ue.content||l.chat?.aborted||"任务已中断",isStreaming:!1,success:!1}:ue):G}),Ix(async()=>{const{abortLayeredAgentChat:G}=await import("./index-SysdKciY.js").then(Q=>Q.aq);return{abortLayeredAgentChat:G}},__vite__mapDeps([0,1])).then(({abortLayeredAgentChat:G})=>{G(i).catch(Q=>console.error("Backend abort failed:",Q))})}catch(G){console.error("Failed to abort chat:",G)}finally{x(!1),b(!1)}}},[l,i]),oe=E.useCallback(async()=>{M.current&&(M.current.abort(),M.current=null),v([]),I(null),D.current&&(D.current.close(),D.current=null);try{await fetch("/api/layered-agent/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:i})})}catch(G){console.warn("Failed to reset backend session:",G)}},[i]),Re=G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),K())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Ys,{className:"flex-1 flex flex-col min-h-0 max-w-2xl overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-purple-500/10",children:a.jsx(Ro,{className:"h-5 w-5 text-purple-500"})}),a.jsxs("div",{children:[a.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"AI Agent"}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[r," • ",l.chatkit?.layeredAgent||"分层代理模式"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hn,{variant:"secondary",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300",children:l.chatkit?.layeredAgent||"分层代理模式"}),a.jsxs(Us,{open:O,onOpenChange:C,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:l.history?.title||"History",children:a.jsx(Fs,{className:"h-4 w-4"})})}),a.jsxs(Hs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history?.title||"History"}),q.length>0&&a.jsx(Ee,{variant:"ghost",size:"sm",onClick:pe,className:"h-7 text-xs",children:l.history?.clearAll||"Clear All"})]}),a.jsx(Dr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:q.length>0?q.map(G=>a.jsx(Fd,{item:G,onSelect:re,onDelete:X},G.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Fs,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history?.noHistory||"No history yet"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history?.noHistoryDescription||"Your completed tasks will appear here"})]})})})]})]}),a.jsx(Ee,{variant:"ghost",size:"icon",onClick:oe,className:"h-8 w-8 rounded-full",title:"重置对话",children:a.jsx(Nu,{className:"h-4 w-4"})})]})]}),N&&a.jsxs("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[a.jsx(kn,{className:"w-4 h-4 flex-shrink-0"}),N]}),a.jsx(Dr,{className:"flex-1 min-h-0",children:a.jsxs("div",{className:"p-4 space-y-4",children:[_.length===0?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center py-12",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-purple-100 dark:bg-purple-900/30 mb-4",children:a.jsx(Ro,{className:"h-8 w-8 text-purple-500"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"分层代理模式"}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400 max-w-xs",children:l.chatkit?.layeredAgentDesc||"决策模型负责规划任务,视觉模型负责执行。你可以看到每一步的执行过程。"})]}):_.map(G=>a.jsx("div",{className:"space-y-2",children:G.role==="user"?a.jsx("div",{className:"flex justify-end",children:a.jsxs("div",{className:"max-w-[80%]",children:[a.jsx("div",{className:"bg-purple-600 text-white px-4 py-2 rounded-2xl rounded-br-sm",children:a.jsx("p",{className:"whitespace-pre-wrap",children:G.content})}),a.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:G.timestamp.toLocaleTimeString()})]})}):a.jsxs("div",{className:"space-y-3",children:[G.steps&&G.steps.length>0&&a.jsx("div",{className:"space-y-2",children:G.steps.map((Q,ue)=>a.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[a.jsxs("button",{onClick:()=>Y(G.id,Q.id),className:"w-full flex items-center justify-between p-3 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium ${Q.type==="tool_call"?"bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"bg-green-100 text-green-600 dark:bg-green-900/30 dark:text-green-400"}`,children:Q.type==="tool_call"?a.jsx(kv,{className:"w-3 h-3"}):a.jsx(Lx,{className:"w-3 h-3"})}),a.jsxs("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Step ",ue+1,": ",Q.content]})]}),Q.isExpanded?a.jsx(Kx,{className:"w-4 h-4 text-slate-400"}):a.jsx(zx,{className:"w-4 h-4 text-slate-400"})]}),Q.isExpanded&&a.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[Q.type==="tool_call"&&Q.toolArgs&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:Q.toolName==="chat"?"发送给 Phone Agent 的指令:":"工具参数:"}),Q.toolName==="chat"?a.jsx("p",{className:"text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:Q.toolArgs.message||JSON.stringify(Q.toolArgs,null,2)}):a.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto",children:JSON.stringify(Q.toolArgs,null,2)})]}),Q.type==="tool_result"&&Q.toolResult&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:"执行结果:"}),a.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto whitespace-pre-wrap",children:typeof Q.toolResult=="string"?Q.toolResult:JSON.stringify(Q.toolResult,null,2)})]})]})]},Q.id))}),G.content&&a.jsx("div",{className:"flex justify-start",children:a.jsx("div",{className:`max-w-[85%] rounded-2xl rounded-tl-sm px-4 py-3 ${G.success===!1?"bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300"}`,children:a.jsxs("div",{className:"flex items-start gap-2",children:[G.success!==void 0&&a.jsx(Fr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${G.success?"text-green-500":"text-red-500"}`}),a.jsx("p",{className:"whitespace-pre-wrap",children:G.content})]})})}),G.isStreaming&&!G.content&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[a.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"正在思考和执行..."]})]})},G.id)),a.jsx("div",{ref:A})]})}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(wu,{value:u,onChange:G=>m(G.target.value),onKeyDown:Re,placeholder:"描述你想要完成的任务... (Cmd+Enter 发送)",disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs(Us,{open:z,onOpenChange:J,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(hu,{className:"w-4 h-4"})})}),a.jsx(Hs,{align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-medium text-sm",children:l.workflows?.selectWorkflow||"Select Workflow"}),P.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:l.workflows?.empty||"No workflows yet"}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Dr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:P.map(G=>a.jsxs("button",{onClick:()=>R(G),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsx("div",{className:"font-medium text-sm",children:G.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:G.text})]},G.uuid))})})]})})]})}),a.jsx(nn,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:l.devicePanel?.tooltips?.workflowButton||"Quick Workflow"}),a.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel?.tooltips?.workflowButtonDesc||"Select a workflow to quickly fill in the task"})]})})]}),p&&a.jsx(Ee,{onClick:se,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat?.abortChat||"中断任务",children:y?a.jsx(Yt,{className:"h-4 w-4 animate-spin"}):a.jsx(Ru,{className:"h-4 w-4"})}),!p&&a.jsx(Ee,{onClick:K,disabled:!u.trim(),size:"icon",className:"h-10 w-10 rounded-full flex-shrink-0 bg-purple-600 hover:bg-purple-700",children:a.jsx(Cu,{className:"h-4 w-4"})})]})})]}),a.jsx(Nd,{deviceId:i,serial:n,connectionType:o,isVisible:d})]})}function py({message:i,type:n="info",onClose:r,duration:o=3e3}){E.useEffect(()=>{const _=setTimeout(()=>{r()},o);return()=>clearTimeout(_)},[o,r]);const d={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500",warning:"bg-amber-500"},l={success:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),warning:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})};return a.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:a.jsxs("div",{className:`${d[n]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[l[n],a.jsx("span",{className:"font-medium",children:i}),a.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const Ar=[{name:"bigmodel",config:{base_url:"https://open.bigmodel.cn/api/paas/v4",model_name:"autoglm-phone"},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{base_url:"https://api-inference.modelscope.cn/v1",model_name:"ZhipuAI/AutoGLM-Phone-9B"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{base_url:"",model_name:"autoglm-phone-9b"}}],my=[{name:"glm",displayName:"GLM Agent",description:"基于 GLM 模型优化,成熟稳定,适合大多数任务",icon:Zx,defaultConfig:{}},{name:"mai",displayName:"MAI Agent",description:"阿里通义团队开发,支持多张历史截图上下文",icon:Eu,defaultConfig:{history_n:3}}],gy=[{name:"bigmodel",config:{decision_base_url:"https://open.bigmodel.cn/api/paas/v4",decision_model_name:"glm-4.7"},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{decision_base_url:"https://api-inference.modelscope.cn/v1",decision_model_name:"Qwen/Qwen3-235B-A22B-Instruct-2507"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{decision_base_url:"",decision_model_name:""}}];function Ty(){const i=An(),n=Mx.useSearch(),r=Dx(),[o,d]=E.useState([]),[l,_]=E.useState(""),[v,u]=E.useState(n.mode||"classic"),[m,p]=E.useState(!1),[x,y]=E.useState({message:"",type:"info",visible:!1}),b=(C,R="info")=>{y({message:C,type:R,visible:!0})},[N,I]=E.useState(null),[A,D]=E.useState(!1),[M,P]=E.useState(!1),[j,z]=E.useState({base_url:Ar[0].config.base_url,model_name:Ar[0].config.model_name,api_key:"",agent_type:"glm",agent_config_params:{},default_max_steps:100,layered_max_turns:50,decision_base_url:"",decision_model_name:"",decision_api_key:""});E.useEffect(()=>{(async()=>{try{const R=await Bx();I({base_url:R.base_url,model_name:R.model_name,api_key:R.api_key||void 0,agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||void 0,default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||void 0,decision_model_name:R.decision_model_name||void 0,decision_api_key:R.decision_api_key||void 0});const re=!R.base_url;z({base_url:re?Ar[0].config.base_url:R.base_url,model_name:re?Ar[0].config.model_name:R.model_name,api_key:R.api_key||"",agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||{},default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||"",decision_model_name:R.decision_model_name||"glm-4.7",decision_api_key:R.decision_api_key||""}),re&&D(!0)}catch(R){console.error("Failed to load config:",R),D(!0)}})()},[]);const J=E.useCallback(async()=>{try{const R=(await Ox()).devices.filter(Y=>Y.state!=="disconnected"),re=new Map,pe=new Map;for(const Y of R)if(Y.serial){const K=pe.get(Y.serial)||[];K.push(Y),pe.set(Y.serial,K)}else re.set(Y.id,Y);Array.from(pe.values()).forEach(Y=>{const se=Y.find(oe=>oe.connection_type==="wifi")||Y[0];re.set(se.id,se)});const X=Array.from(re.values());if(d(X),X.length>0&&!m){const Y=n.serial;if(Y){const K=X.find(se=>se.serial===Y);_(K?K.id:X[0].id)}else l||_(X[0].id);p(!0)}l&&!X.find(Y=>Y.id===l)&&_(X[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}},[l,m,n.serial]);E.useEffect(()=>{const C=setTimeout(()=>{J()},0),R=setInterval(J,3e3);return()=>{clearTimeout(C),clearInterval(R)}},[J]),E.useEffect(()=>{const R=o.find(pe=>pe.id===l)?.serial;if(!m)return;(R!==n.serial||v!==n.mode)&&r({to:"/chat",search:{serial:R,mode:v},replace:!0})},[l,v,o,m,r,n.serial,n.mode]);const q=async()=>{if(!j.base_url){b(i.chat.baseUrlRequired,"error");return}try{await Fx({base_url:j.base_url,model_name:j.model_name||"autoglm-phone-9b",api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),I({base_url:j.base_url,model_name:j.model_name,api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),b(i.toasts.configSaved,"success");try{const C=await Ux();if(C.total===0)console.log("No agents to reinitialize");else if(C.success)b(`Configuration applied to ${C.succeeded.length} device(s)`,"success");else{const R=Object.keys(C.failed).length;b(`Configuration partially applied: ${C.succeeded.length}/${C.total} succeeded, ${R} failed`,"warning")}}catch(C){console.error("Failed to reinitialize agents:",C),b("Configuration saved, but failed to update devices. Please reinitialize manually.","warning")}D(!1)}catch(C){console.error("Failed to save config:",C),b(`Failed to save: ${xu(C)}`,"error")}},$=async C=>{try{const R=await Hx({device_id:C});R.success&&R.device_id?(_(R.device_id),b(i.toasts.wifiConnected,"success")):R.success||b(R.message||R.error||i.toasts.connectionFailed,"error")}catch(R){b(i.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",R)}},O=async C=>{try{const R=await Wx(C);R.success?b(i.toasts.wifiDisconnected,"success"):b(R.message||R.error||i.toasts.disconnectFailed,"error")}catch(R){b(i.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",R)}};return a.jsxs("div",{className:"h-full flex relative min-h-0",children:[x.visible&&a.jsx(py,{message:x.message,type:x.type,onClose:()=>y(C=>({...C,visible:!1}))}),a.jsx(Fo,{open:A,onOpenChange:D,children:a.jsxs(Uo,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[a.jsxs(Wo,{className:"flex-shrink-0",children:[a.jsxs(Ho,{className:"flex items-center gap-2",children:[a.jsx(Tu,{className:"w-5 h-5 text-[#1d9bf0]"}),i.chat.configuration]}),a.jsx(Go,{children:i.chat.configureApi})]}),a.jsxs(qu,{defaultValue:"vision",className:"flex-1 flex flex-col min-h-0",children:[a.jsxs($u,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[a.jsxs(Lr,{value:"vision",children:[a.jsx(mo,{className:"w-4 h-4 mr-2"}),i.chat.visionModelTab]}),a.jsxs(Lr,{value:"decision",children:[a.jsx(Eu,{className:"w-4 h-4 mr-2"}),i.chat.decisionModelTab]})]}),a.jsxs(Mr,{value:"vision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:Ar.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,base_url:C.config.base_url,model_name:C.config.model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.base_url==="")?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:i.chat.getApiKey||"获取 API Key",children:a.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},C.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"base_url",children:[i.chat.baseUrl," *"]}),a.jsx(ht,{id:"base_url",value:j.base_url,onChange:C=>z({...j,base_url:C.target.value}),placeholder:"http://localhost:8080/v1"}),!j.base_url&&a.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[a.jsx(kn,{className:"w-3 h-3"}),i.chat.baseUrlRequired]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"api_key",children:i.chat.apiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(ht,{id:"api_key",type:M?"text":"password",value:j.api_key,onChange:C=>z({...j,api_key:C.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),a.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!M),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:M?a.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"model_name",children:i.chat.modelName}),a.jsx(ht,{id:"model_name",value:j.model_name,onChange:C=>z({...j,model_name:C.target.value}),placeholder:"autoglm-phone-9b"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.agentType||"Agent 类型"}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:my.map(C=>a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,agent_type:C.name,agent_config_params:C.defaultConfig})),className:`text-left p-3 rounded-lg border transition-all ${j.agent_type===C.name?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(C.icon,{className:`w-4 h-4 ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-medium text-sm ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-900 dark:text-slate-100"}`,children:C.displayName})]}),a.jsx("p",{className:`text-xs mt-1 ml-6 ${j.agent_type===C.name?"text-[#1d9bf0]/70":"text-slate-500 dark:text-slate-400"}`,children:C.description})]},C.name))})]}),j.agent_type==="mai"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"history_n",children:i.chat.history_n||"历史记录数量"}),a.jsx(ht,{id:"history_n",type:"number",min:1,max:10,value:j.agent_config_params?.history_n||3,onChange:C=>{const R=parseInt(C.target.value)||3;z(re=>({...re,agent_config_params:{...re.agent_config_params,history_n:R}}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.history_n_hint||"包含的历史截图数量(1-10)"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"default_max_steps",children:i.chat.maxSteps||"最大执行步数"}),a.jsx(ht,{id:"default_max_steps",type:"number",min:1,max:1e3,value:j.default_max_steps,onChange:C=>{const R=parseInt(C.target.value)||100;z(re=>({...re,default_max_steps:Math.min(1e3,Math.max(1,R))}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.maxStepsHint||"单次任务最大执行步数(1-1000)"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"layered_max_turns",children:"分层代理最大轮次"}),a.jsx(ht,{id:"layered_max_turns",type:"number",min:1,value:j.layered_max_turns,onChange:C=>{const R=parseInt(C.target.value)||50;z(re=>({...re,layered_max_turns:Math.max(1,R)}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"分层代理模式的最大轮次(最小值为1)"})]})]}),a.jsxs(Mr,{value:"decision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.jsx("div",{className:"rounded-lg border border-indigo-200 bg-indigo-50 dark:border-indigo-900 dark:bg-indigo-950/30 p-3 text-sm text-indigo-900 dark:text-indigo-100",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(ov,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),a.jsx("div",{children:i.chat.decisionModelHint})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectDecisionPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:gy.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,decision_base_url:C.config.decision_base_url,decision_model_name:C.config.decision_model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.decision_base_url==="")?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-slate-200 dark:border-slate-700 hover:border-indigo-500/50 hover:bg-indigo-50 dark:hover:bg-indigo-950/30"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.decision_base_url==="")?"text-indigo-600 dark:text-indigo-400":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:i.chat.getApiKey||"获取 API Key",children:a.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-indigo-600 dark:group-hover:text-indigo-400 transition-colors"})})]},C.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"decision_base_url",children:[i.chat.decisionBaseUrl," *"]}),a.jsx(ht,{id:"decision_base_url",value:j.decision_base_url,onChange:C=>z({...j,decision_base_url:C.target.value}),placeholder:"http://localhost:8080/v1"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"decision_api_key",children:i.chat.decisionApiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(ht,{id:"decision_api_key",type:M?"text":"password",value:j.decision_api_key,onChange:C=>z({...j,decision_api_key:C.target.value}),placeholder:"sk-...",className:"pr-10"}),a.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!M),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:M?a.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"decision_model_name",children:[i.chat.decisionModelName," *"]}),a.jsx(ht,{id:"decision_model_name",value:j.decision_model_name,onChange:C=>z({...j,decision_model_name:C.target.value}),placeholder:""})]})]})]}),a.jsxs(zo,{className:"sm:justify-between gap-2 flex-shrink-0",children:[a.jsx(Ee,{variant:"outline",onClick:()=>{D(!1),N&&z({base_url:N.base_url,model_name:N.model_name,api_key:N.api_key||"",agent_type:N.agent_type||"glm",agent_config_params:N.agent_config_params||{},default_max_steps:N.default_max_steps||100,layered_max_turns:N.layered_max_turns||50,decision_base_url:N.decision_base_url||"",decision_model_name:N.decision_model_name||"glm-4.7",decision_api_key:N.decision_api_key||""})},children:i.chat.cancel}),a.jsxs(Ee,{onClick:q,variant:"twitter",children:[a.jsx(Fr,{className:"w-4 h-4 mr-2"}),i.chat.saveConfig]})]})]})}),a.jsx(f1,{devices:o,currentDeviceId:l,onSelectDevice:_,onOpenConfig:()=>D(!0),onConnectWifi:$,onDisconnectWifi:O,onRefreshDevices:J,showToast:b}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 relative",children:[a.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:a.jsxs("div",{className:"flex items-center gap-0.5 bg-white/95 dark:bg-slate-800/95 backdrop-blur-sm rounded-full p-1 shadow-lg border border-slate-200 dark:border-slate-700",children:[a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs("button",{onClick:()=>u("classic"),className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="classic"?"bg-slate-900 dark:bg-white text-white dark:text-slate-900 shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[a.jsx(jr,{className:"w-4 h-4"}),i.chatkit?.classicMode||"经典模式"]})}),a.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.classicMode||"经典模式"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.classicModeDesc||"视觉模型直接执行任务"})]})})]}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs("button",{onClick:()=>{u("chatkit")},className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="chatkit"?"bg-indigo-600 text-white shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[a.jsx(Ro,{className:"w-4 h-4"}),i.chatkit?.layeredMode||"分层代理"]})}),a.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.layeredMode||"分层代理"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.layeredModeDesc||"规划层分解任务,执行层独立完成子任务"})]})})]})]})}),a.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4 pt-16",children:o.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mx-auto mb-4",children:a.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),a.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:i.chat.welcomeTitle}),a.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:i.chat.connectDevice})]})}):o.map(C=>a.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${C.id===l?"":"hidden"}`,children:v==="chatkit"?a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(hy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isVisible:C.id===l})}):a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(fy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isConfigured:!!N?.base_url})})},C.serial))})]})]})}export{Ty as component};
|
|
129
|
+
`);Ge=Be.pop()||"";for(const We of Be)if(We.startsWith("data: "))try{const de=JSON.parse(We.slice(6));if(de.type==="tool_call"){const Se={id:`step-${Date.now()}-${Math.random()}`,type:"tool_call",content:de.tool_name==="chat"?"发送指令给 Phone Agent":de.tool_name==="list_devices"?"获取设备列表":`调用工具: ${de.tool_name}`,toolName:de.tool_name,toolArgs:de.tool_args||{},timestamp:new Date,isExpanded:!0};B.push(Se),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...B]}:Z))}else if(de.type==="tool_result"){const Se={id:`step-${Date.now()}-${Math.random()}`,type:"tool_result",content:de.tool_name==="chat"?"Phone Agent 执行结果":`${de.tool_name} 结果`,toolResult:de.result,timestamp:new Date,isExpanded:!0};B.push(Se),v(ee=>ee.map(Z=>Z.id===ue?{...Z,steps:[...B]}:Z))}else if(de.type==="message")v(Se=>Se.map(ee=>ee.id===ue?{...ee,content:de.content}:ee));else if(de.type==="done"){const Se={...te,content:de.content||"",isStreaming:!1,success:de.success,steps:[...B],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Se:Z))}else if(de.type==="error"){const Se={...te,content:`错误: ${de.message}`,isStreaming:!1,success:!1,steps:[...B],timestamp:new Date};v(ee=>ee.map(Z=>Z.id===ue?Se:Z)),I(de.message)}}catch(de){console.error("Failed to parse SSE data:",de,We)}}v(ce=>ce.map(ye=>ye.id===ue&&ye.isStreaming?{...ye,isStreaming:!1,success:!0}:ye))}catch(ae){if(ae instanceof Error&&ae.name==="AbortError"){console.log("Chat aborted by user");return}console.error("Chat error:",ae);const Ue=xu(ae);I(Ue),v(Ze=>Ze.map(Ge=>Ge.id===ue?{...Ge,content:`错误: ${Ue}`,isStreaming:!1,success:!1}:Ge))}finally{x(!1),M.current=null}},[u,p,i]),se=E.useCallback(()=>{if(M.current){b(!0);try{M.current.abort(),M.current=null,v(G=>{const Q=G[G.length-1];return Q&&Q.role==="assistant"&&Q.isStreaming?G.map((ue,te)=>te===G.length-1?{...ue,content:ue.content||l.chat?.aborted||"任务已中断",isStreaming:!1,success:!1}:ue):G}),Ix(async()=>{const{abortLayeredAgentChat:G}=await import("./index-BzP-Te33.js").then(Q=>Q.aq);return{abortLayeredAgentChat:G}},__vite__mapDeps([0,1])).then(({abortLayeredAgentChat:G})=>{G(i).catch(Q=>console.error("Backend abort failed:",Q))})}catch(G){console.error("Failed to abort chat:",G)}finally{x(!1),b(!1)}}},[l,i]),oe=E.useCallback(async()=>{M.current&&(M.current.abort(),M.current=null),v([]),I(null),D.current&&(D.current.close(),D.current=null);try{await fetch("/api/layered-agent/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:i})})}catch(G){console.warn("Failed to reset backend session:",G)}},[i]),Re=G=>{(G.metaKey||G.ctrlKey)&&G.key==="Enter"&&(G.preventDefault(),K())};return a.jsxs("div",{className:"flex-1 flex gap-4 p-4 items-stretch justify-center min-h-0",children:[a.jsxs(Ys,{className:"flex-1 flex flex-col min-h-0 max-w-2xl overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-purple-500/10",children:a.jsx(Ro,{className:"h-5 w-5 text-purple-500"})}),a.jsxs("div",{children:[a.jsx("h2",{className:"font-bold text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"AI Agent"}),a.jsxs("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:[r," • ",l.chatkit?.layeredAgent||"分层代理模式"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Hn,{variant:"secondary",className:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-300",children:l.chatkit?.layeredAgent||"分层代理模式"}),a.jsxs(Us,{open:O,onOpenChange:C,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",title:l.history?.title||"History",children:a.jsx(Fs,{className:"h-4 w-4"})})}),a.jsxs(Hs,{className:"w-96 p-0",align:"end",sideOffset:8,children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-slate-200 dark:border-slate-800",children:[a.jsx("h3",{className:"font-semibold text-sm text-slate-900 dark:text-slate-100",children:l.history?.title||"History"}),q.length>0&&a.jsx(Ee,{variant:"ghost",size:"sm",onClick:pe,className:"h-7 text-xs",children:l.history?.clearAll||"Clear All"})]}),a.jsx(Dr,{className:"h-[400px]",children:a.jsx("div",{className:"p-4 space-y-2",children:q.length>0?q.map(G=>a.jsx(Fd,{item:G,onSelect:re,onDelete:X},G.id)):a.jsxs("div",{className:"text-center py-8",children:[a.jsx(Fs,{className:"h-12 w-12 text-slate-300 dark:text-slate-700 mx-auto mb-3"}),a.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100",children:l.history?.noHistory||"No history yet"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1",children:l.history?.noHistoryDescription||"Your completed tasks will appear here"})]})})})]})]}),a.jsx(Ee,{variant:"ghost",size:"icon",onClick:oe,className:"h-8 w-8 rounded-full",title:"重置对话",children:a.jsx(Nu,{className:"h-4 w-4"})})]})]}),N&&a.jsxs("div",{className:"mx-4 mt-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-xl text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[a.jsx(kn,{className:"w-4 h-4 flex-shrink-0"}),N]}),a.jsx(Dr,{className:"flex-1 min-h-0",children:a.jsxs("div",{className:"p-4 space-y-4",children:[_.length===0?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center py-12",children:[a.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-purple-100 dark:bg-purple-900/30 mb-4",children:a.jsx(Ro,{className:"h-8 w-8 text-purple-500"})}),a.jsx("p",{className:"font-medium text-slate-900 dark:text-slate-100",children:l.chatkit?.title||"分层代理模式"}),a.jsx("p",{className:"mt-1 text-sm text-slate-500 dark:text-slate-400 max-w-xs",children:l.chatkit?.layeredAgentDesc||"决策模型负责规划任务,视觉模型负责执行。你可以看到每一步的执行过程。"})]}):_.map(G=>a.jsx("div",{className:"space-y-2",children:G.role==="user"?a.jsx("div",{className:"flex justify-end",children:a.jsxs("div",{className:"max-w-[80%]",children:[a.jsx("div",{className:"bg-purple-600 text-white px-4 py-2 rounded-2xl rounded-br-sm",children:a.jsx("p",{className:"whitespace-pre-wrap",children:G.content})}),a.jsx("p",{className:"text-xs text-slate-400 mt-1 text-right",children:G.timestamp.toLocaleTimeString()})]})}):a.jsxs("div",{className:"space-y-3",children:[G.steps&&G.steps.length>0&&a.jsx("div",{className:"space-y-2",children:G.steps.map((Q,ue)=>a.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden",children:[a.jsxs("button",{onClick:()=>Y(G.id,Q.id),className:"w-full flex items-center justify-between p-3 hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`flex h-6 w-6 items-center justify-center rounded-full text-xs font-medium ${Q.type==="tool_call"?"bg-blue-100 text-blue-600 dark:bg-blue-900/30 dark:text-blue-400":"bg-green-100 text-green-600 dark:bg-green-900/30 dark:text-green-400"}`,children:Q.type==="tool_call"?a.jsx(kv,{className:"w-3 h-3"}):a.jsx(Lx,{className:"w-3 h-3"})}),a.jsxs("span",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:["Step ",ue+1,": ",Q.content]})]}),Q.isExpanded?a.jsx(Kx,{className:"w-4 h-4 text-slate-400"}):a.jsx(zx,{className:"w-4 h-4 text-slate-400"})]}),Q.isExpanded&&a.jsxs("div",{className:"px-3 pb-3 space-y-2",children:[Q.type==="tool_call"&&Q.toolArgs&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:Q.toolName==="chat"?"发送给 Phone Agent 的指令:":"工具参数:"}),Q.toolName==="chat"?a.jsx("p",{className:"text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:Q.toolArgs.message||JSON.stringify(Q.toolArgs,null,2)}):a.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto",children:JSON.stringify(Q.toolArgs,null,2)})]}),Q.type==="tool_result"&&Q.toolResult&&a.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg p-3 text-sm",children:[a.jsx("p",{className:"text-xs text-slate-500 mb-1 font-medium",children:"执行结果:"}),a.jsx("pre",{className:"text-xs text-slate-600 dark:text-slate-400 overflow-x-auto whitespace-pre-wrap",children:typeof Q.toolResult=="string"?Q.toolResult:JSON.stringify(Q.toolResult,null,2)})]})]})]},Q.id))}),G.content&&a.jsx("div",{className:"flex justify-start",children:a.jsx("div",{className:`max-w-[85%] rounded-2xl rounded-tl-sm px-4 py-3 ${G.success===!1?"bg-red-100 dark:bg-red-900/20 text-red-600 dark:text-red-400":"bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300"}`,children:a.jsxs("div",{className:"flex items-start gap-2",children:[G.success!==void 0&&a.jsx(Fr,{className:`w-5 h-5 flex-shrink-0 mt-0.5 ${G.success?"text-green-500":"text-red-500"}`}),a.jsx("p",{className:"whitespace-pre-wrap",children:G.content})]})})}),G.isStreaming&&!G.content&&a.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[a.jsx(Yt,{className:"w-4 h-4 animate-spin"}),"正在思考和执行..."]})]})},G.id)),a.jsx("div",{ref:A})]})}),a.jsx("div",{className:"p-4 border-t border-slate-200 dark:border-slate-800",children:a.jsxs("div",{className:"flex items-end gap-3",children:[a.jsx(wu,{value:u,onChange:G=>m(G.target.value),onKeyDown:Re,placeholder:"描述你想要完成的任务... (Cmd+Enter 发送)",disabled:p,className:"flex-1 min-h-[40px] max-h-[120px] resize-none",rows:1}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs(Us,{open:z,onOpenChange:J,children:[a.jsx(Ws,{asChild:!0,children:a.jsx(Ee,{variant:"outline",size:"icon",className:"h-10 w-10 flex-shrink-0",children:a.jsx(hu,{className:"w-4 h-4"})})}),a.jsx(Hs,{align:"start",className:"w-72 p-3",children:a.jsxs("div",{className:"space-y-2",children:[a.jsx("h4",{className:"font-medium text-sm",children:l.workflows?.selectWorkflow||"Select Workflow"}),P.length===0?a.jsxs("div",{className:"text-sm text-slate-500 dark:text-slate-400 space-y-1",children:[a.jsx("p",{children:l.workflows?.empty||"No workflows yet"}),a.jsxs("p",{children:["前往"," ",a.jsx("a",{href:"/workflows",className:"text-primary underline",children:"工作流"})," ","页面创建。"]})]}):a.jsx(Dr,{className:"h-64",children:a.jsx("div",{className:"space-y-1",children:P.map(G=>a.jsxs("button",{onClick:()=>R(G),className:"w-full text-left p-2 rounded hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[a.jsx("div",{className:"font-medium text-sm",children:G.name}),a.jsx("div",{className:"text-xs text-slate-500 dark:text-slate-400 line-clamp-2",children:G.text})]},G.uuid))})})]})})]})}),a.jsx(nn,{side:"top",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:l.devicePanel?.tooltips?.workflowButton||"Quick Workflow"}),a.jsx("p",{className:"text-xs opacity-80",children:l.devicePanel?.tooltips?.workflowButtonDesc||"Select a workflow to quickly fill in the task"})]})})]}),p&&a.jsx(Ee,{onClick:se,disabled:y,size:"icon",variant:"destructive",className:"h-10 w-10 rounded-full flex-shrink-0",title:l.chat?.abortChat||"中断任务",children:y?a.jsx(Yt,{className:"h-4 w-4 animate-spin"}):a.jsx(Ru,{className:"h-4 w-4"})}),!p&&a.jsx(Ee,{onClick:K,disabled:!u.trim(),size:"icon",className:"h-10 w-10 rounded-full flex-shrink-0 bg-purple-600 hover:bg-purple-700",children:a.jsx(Cu,{className:"h-4 w-4"})})]})})]}),a.jsx(Nd,{deviceId:i,serial:n,connectionType:o,isVisible:d})]})}function py({message:i,type:n="info",onClose:r,duration:o=3e3}){E.useEffect(()=>{const _=setTimeout(()=>{r()},o);return()=>clearTimeout(_)},[o,r]);const d={success:"bg-green-500",error:"bg-red-500",info:"bg-blue-500",warning:"bg-amber-500"},l={success:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M5 13l4 4L19 7"})}),error:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})}),info:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),warning:a.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})};return a.jsx("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 animate-fade-in-down",children:a.jsxs("div",{className:`${d[n]} text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3 min-w-[300px]`,children:[l[n],a.jsx("span",{className:"font-medium",children:i}),a.jsx("button",{onClick:r,className:"ml-auto hover:bg-white/20 rounded-full p-1 transition-colors",children:a.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]})})}const Ar=[{name:"bigmodel",config:{base_url:"https://open.bigmodel.cn/api/paas/v4",model_name:"autoglm-phone"},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{base_url:"https://api-inference.modelscope.cn/v1",model_name:"ZhipuAI/AutoGLM-Phone-9B"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{base_url:"",model_name:"autoglm-phone-9b"}}],my=[{name:"glm",displayName:"GLM Agent",description:"基于 GLM 模型优化,成熟稳定,适合大多数任务",icon:Zx,defaultConfig:{}},{name:"mai",displayName:"MAI Agent",description:"阿里通义团队开发,支持多张历史截图上下文",icon:Eu,defaultConfig:{history_n:3}}],gy=[{name:"bigmodel",config:{decision_base_url:"https://open.bigmodel.cn/api/paas/v4",decision_model_name:"glm-4.7"},apiKeyUrl:"https://bigmodel.cn/usercenter/proj-mgmt/apikeys"},{name:"modelscope",config:{decision_base_url:"https://api-inference.modelscope.cn/v1",decision_model_name:"Qwen/Qwen3-235B-A22B-Instruct-2507"},apiKeyUrl:"https://www.modelscope.cn/my/myaccesstoken"},{name:"custom",config:{decision_base_url:"",decision_model_name:""}}];function Ty(){const i=An(),n=Mx.useSearch(),r=Dx(),[o,d]=E.useState([]),[l,_]=E.useState(""),[v,u]=E.useState(n.mode||"classic"),[m,p]=E.useState(!1),[x,y]=E.useState({message:"",type:"info",visible:!1}),b=(C,R="info")=>{y({message:C,type:R,visible:!0})},[N,I]=E.useState(null),[A,D]=E.useState(!1),[M,P]=E.useState(!1),[j,z]=E.useState({base_url:Ar[0].config.base_url,model_name:Ar[0].config.model_name,api_key:"",agent_type:"glm",agent_config_params:{},default_max_steps:100,layered_max_turns:50,decision_base_url:"",decision_model_name:"",decision_api_key:""});E.useEffect(()=>{(async()=>{try{const R=await Bx();I({base_url:R.base_url,model_name:R.model_name,api_key:R.api_key||void 0,agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||void 0,default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||void 0,decision_model_name:R.decision_model_name||void 0,decision_api_key:R.decision_api_key||void 0});const re=!R.base_url;z({base_url:re?Ar[0].config.base_url:R.base_url,model_name:re?Ar[0].config.model_name:R.model_name,api_key:R.api_key||"",agent_type:R.agent_type||"glm",agent_config_params:R.agent_config_params||{},default_max_steps:R.default_max_steps||100,layered_max_turns:R.layered_max_turns||50,decision_base_url:R.decision_base_url||"",decision_model_name:R.decision_model_name||"glm-4.7",decision_api_key:R.decision_api_key||""}),re&&D(!0)}catch(R){console.error("Failed to load config:",R),D(!0)}})()},[]);const J=E.useCallback(async()=>{try{const R=(await Ox()).devices.filter(Y=>Y.state!=="disconnected"),re=new Map,pe=new Map;for(const Y of R)if(Y.serial){const K=pe.get(Y.serial)||[];K.push(Y),pe.set(Y.serial,K)}else re.set(Y.id,Y);Array.from(pe.values()).forEach(Y=>{const se=Y.find(oe=>oe.connection_type==="wifi")||Y[0];re.set(se.id,se)});const X=Array.from(re.values());if(d(X),X.length>0&&!m){const Y=n.serial;if(Y){const K=X.find(se=>se.serial===Y);_(K?K.id:X[0].id)}else l||_(X[0].id);p(!0)}l&&!X.find(Y=>Y.id===l)&&_(X[0]?.id||"")}catch(C){console.error("Failed to load devices:",C)}},[l,m,n.serial]);E.useEffect(()=>{const C=setTimeout(()=>{J()},0),R=setInterval(J,3e3);return()=>{clearTimeout(C),clearInterval(R)}},[J]),E.useEffect(()=>{const R=o.find(pe=>pe.id===l)?.serial;if(!m)return;(R!==n.serial||v!==n.mode)&&r({to:"/chat",search:{serial:R,mode:v},replace:!0})},[l,v,o,m,r,n.serial,n.mode]);const q=async()=>{if(!j.base_url){b(i.chat.baseUrlRequired,"error");return}try{await Fx({base_url:j.base_url,model_name:j.model_name||"autoglm-phone-9b",api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),I({base_url:j.base_url,model_name:j.model_name,api_key:j.api_key||void 0,agent_type:j.agent_type,agent_config_params:Object.keys(j.agent_config_params).length>0?j.agent_config_params:void 0,default_max_steps:j.default_max_steps,layered_max_turns:j.layered_max_turns,decision_base_url:j.decision_base_url||void 0,decision_model_name:j.decision_model_name||void 0,decision_api_key:j.decision_api_key||void 0}),b(i.toasts.configSaved,"success");try{const C=await Ux();if(C.total===0)console.log("No agents to reinitialize");else if(C.success)b(`Configuration applied to ${C.succeeded.length} device(s)`,"success");else{const R=Object.keys(C.failed).length;b(`Configuration partially applied: ${C.succeeded.length}/${C.total} succeeded, ${R} failed`,"warning")}}catch(C){console.error("Failed to reinitialize agents:",C),b("Configuration saved, but failed to update devices. Please reinitialize manually.","warning")}D(!1)}catch(C){console.error("Failed to save config:",C),b(`Failed to save: ${xu(C)}`,"error")}},$=async C=>{try{const R=await Hx({device_id:C});R.success&&R.device_id?(_(R.device_id),b(i.toasts.wifiConnected,"success")):R.success||b(R.message||R.error||i.toasts.connectionFailed,"error")}catch(R){b(i.toasts.wifiConnectionError,"error"),console.error("Connect WiFi error:",R)}},O=async C=>{try{const R=await Wx(C);R.success?b(i.toasts.wifiDisconnected,"success"):b(R.message||R.error||i.toasts.disconnectFailed,"error")}catch(R){b(i.toasts.wifiDisconnectError,"error"),console.error("Disconnect WiFi error:",R)}};return a.jsxs("div",{className:"h-full flex relative min-h-0",children:[x.visible&&a.jsx(py,{message:x.message,type:x.type,onClose:()=>y(C=>({...C,visible:!1}))}),a.jsx(Fo,{open:A,onOpenChange:D,children:a.jsxs(Uo,{className:"sm:max-w-md h-[75vh] flex flex-col",children:[a.jsxs(Wo,{className:"flex-shrink-0",children:[a.jsxs(Ho,{className:"flex items-center gap-2",children:[a.jsx(Tu,{className:"w-5 h-5 text-[#1d9bf0]"}),i.chat.configuration]}),a.jsx(Go,{children:i.chat.configureApi})]}),a.jsxs(qu,{defaultValue:"vision",className:"flex-1 flex flex-col min-h-0",children:[a.jsxs($u,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[a.jsxs(Lr,{value:"vision",children:[a.jsx(mo,{className:"w-4 h-4 mr-2"}),i.chat.visionModelTab]}),a.jsxs(Lr,{value:"decision",children:[a.jsx(Eu,{className:"w-4 h-4 mr-2"}),i.chat.decisionModelTab]})]}),a.jsxs(Mr,{value:"vision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:Ar.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,base_url:C.config.base_url,model_name:C.config.model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.base_url==="")?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${j.base_url===C.config.base_url&&(C.name!=="custom"||C.name==="custom"&&j.base_url==="")?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:i.chat.getApiKey||"获取 API Key",children:a.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-[#1d9bf0] transition-colors"})})]},C.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"base_url",children:[i.chat.baseUrl," *"]}),a.jsx(ht,{id:"base_url",value:j.base_url,onChange:C=>z({...j,base_url:C.target.value}),placeholder:"http://localhost:8080/v1"}),!j.base_url&&a.jsxs("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[a.jsx(kn,{className:"w-3 h-3"}),i.chat.baseUrlRequired]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"api_key",children:i.chat.apiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(ht,{id:"api_key",type:M?"text":"password",value:j.api_key,onChange:C=>z({...j,api_key:C.target.value}),placeholder:"Leave empty if not required",className:"pr-10"}),a.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!M),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:M?a.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"model_name",children:i.chat.modelName}),a.jsx(ht,{id:"model_name",value:j.model_name,onChange:C=>z({...j,model_name:C.target.value}),placeholder:"autoglm-phone-9b"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.agentType||"Agent 类型"}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:my.map(C=>a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,agent_type:C.name,agent_config_params:C.defaultConfig})),className:`text-left p-3 rounded-lg border transition-all ${j.agent_type===C.name?"border-[#1d9bf0] bg-[#1d9bf0]/5":"border-slate-200 dark:border-slate-700 hover:border-[#1d9bf0]/50 hover:bg-slate-50 dark:hover:bg-slate-800/50"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(C.icon,{className:`w-4 h-4 ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:`font-medium text-sm ${j.agent_type===C.name?"text-[#1d9bf0]":"text-slate-900 dark:text-slate-100"}`,children:C.displayName})]}),a.jsx("p",{className:`text-xs mt-1 ml-6 ${j.agent_type===C.name?"text-[#1d9bf0]/70":"text-slate-500 dark:text-slate-400"}`,children:C.description})]},C.name))})]}),j.agent_type==="mai"&&a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"history_n",children:i.chat.history_n||"历史记录数量"}),a.jsx(ht,{id:"history_n",type:"number",min:1,max:10,value:j.agent_config_params?.history_n||3,onChange:C=>{const R=parseInt(C.target.value)||3;z(re=>({...re,agent_config_params:{...re.agent_config_params,history_n:R}}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.history_n_hint||"包含的历史截图数量(1-10)"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"default_max_steps",children:i.chat.maxSteps||"最大执行步数"}),a.jsx(ht,{id:"default_max_steps",type:"number",min:1,max:1e3,value:j.default_max_steps,onChange:C=>{const R=parseInt(C.target.value)||100;z(re=>({...re,default_max_steps:Math.min(1e3,Math.max(1,R))}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:i.chat.maxStepsHint||"单次任务最大执行步数(1-1000)"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"layered_max_turns",children:"分层代理最大轮次"}),a.jsx(ht,{id:"layered_max_turns",type:"number",min:1,value:j.layered_max_turns,onChange:C=>{const R=parseInt(C.target.value)||50;z(re=>({...re,layered_max_turns:Math.max(1,R)}))},className:"w-full"}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:"分层代理模式的最大轮次(最小值为1)"})]})]}),a.jsxs(Mr,{value:"decision",className:"space-y-4 mt-4 overflow-y-auto flex-1 min-h-0",children:[a.jsx("div",{className:"rounded-lg border border-indigo-200 bg-indigo-50 dark:border-indigo-900 dark:bg-indigo-950/30 p-3 text-sm text-indigo-900 dark:text-indigo-100",children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx(ov,{className:"mt-0.5 h-4 w-4 flex-shrink-0"}),a.jsx("div",{children:i.chat.decisionModelHint})]})}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{className:"text-sm font-medium",children:i.chat.selectDecisionPreset}),a.jsx("div",{className:"grid grid-cols-1 gap-2",children:gy.map(C=>a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>z(R=>({...R,decision_base_url:C.config.decision_base_url,decision_model_name:C.config.decision_model_name})),className:`w-full text-left p-3 rounded-lg border transition-all ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.decision_base_url==="")?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/50":"border-slate-200 dark:border-slate-700 hover:border-indigo-500/50 hover:bg-indigo-50 dark:hover:bg-indigo-950/30"}`,children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ko,{className:`w-4 h-4 ${j.decision_base_url===C.config.decision_base_url&&(C.name!=="custom"||C.name==="custom"&&j.decision_base_url==="")?"text-indigo-600 dark:text-indigo-400":"text-slate-400 dark:text-slate-500"}`}),a.jsx("span",{className:"font-medium text-sm text-slate-900 dark:text-slate-100",children:i.presetConfigs[C.name].name})]}),a.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400 mt-1 ml-6",children:i.presetConfigs[C.name].description})]}),"apiKeyUrl"in C&&a.jsx("a",{href:C.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",onClick:R=>R.stopPropagation(),className:"absolute top-3 right-3 p-1.5 rounded-md hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors group",title:i.chat.getApiKey||"获取 API Key",children:a.jsx(Oc,{className:"w-3.5 h-3.5 text-slate-400 group-hover:text-indigo-600 dark:group-hover:text-indigo-400 transition-colors"})})]},C.name))})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"decision_base_url",children:[i.chat.decisionBaseUrl," *"]}),a.jsx(ht,{id:"decision_base_url",value:j.decision_base_url,onChange:C=>z({...j,decision_base_url:C.target.value}),placeholder:"http://localhost:8080/v1"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(nt,{htmlFor:"decision_api_key",children:i.chat.decisionApiKey}),a.jsxs("div",{className:"relative",children:[a.jsx(ht,{id:"decision_api_key",type:M?"text":"password",value:j.decision_api_key,onChange:C=>z({...j,decision_api_key:C.target.value}),placeholder:"sk-...",className:"pr-10"}),a.jsx(Ee,{type:"button",variant:"ghost",size:"icon",onClick:()=>P(!M),className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",children:M?a.jsx(Bc,{className:"w-4 h-4 text-slate-400"}):a.jsx(mo,{className:"w-4 h-4 text-slate-400"})})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs(nt,{htmlFor:"decision_model_name",children:[i.chat.decisionModelName," *"]}),a.jsx(ht,{id:"decision_model_name",value:j.decision_model_name,onChange:C=>z({...j,decision_model_name:C.target.value}),placeholder:""})]})]})]}),a.jsxs(zo,{className:"sm:justify-between gap-2 flex-shrink-0",children:[a.jsx(Ee,{variant:"outline",onClick:()=>{D(!1),N&&z({base_url:N.base_url,model_name:N.model_name,api_key:N.api_key||"",agent_type:N.agent_type||"glm",agent_config_params:N.agent_config_params||{},default_max_steps:N.default_max_steps||100,layered_max_turns:N.layered_max_turns||50,decision_base_url:N.decision_base_url||"",decision_model_name:N.decision_model_name||"glm-4.7",decision_api_key:N.decision_api_key||""})},children:i.chat.cancel}),a.jsxs(Ee,{onClick:q,variant:"twitter",children:[a.jsx(Fr,{className:"w-4 h-4 mr-2"}),i.chat.saveConfig]})]})]})}),a.jsx(f1,{devices:o,currentDeviceId:l,onSelectDevice:_,onOpenConfig:()=>D(!0),onConnectWifi:$,onDisconnectWifi:O,onRefreshDevices:J,showToast:b}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 relative",children:[a.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:a.jsxs("div",{className:"flex items-center gap-0.5 bg-white/95 dark:bg-slate-800/95 backdrop-blur-sm rounded-full p-1 shadow-lg border border-slate-200 dark:border-slate-700",children:[a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs("button",{onClick:()=>u("classic"),className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="classic"?"bg-slate-900 dark:bg-white text-white dark:text-slate-900 shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[a.jsx(jr,{className:"w-4 h-4"}),i.chatkit?.classicMode||"经典模式"]})}),a.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.classicMode||"经典模式"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.classicModeDesc||"视觉模型直接执行任务"})]})})]}),a.jsxs(en,{children:[a.jsx(tn,{asChild:!0,children:a.jsxs("button",{onClick:()=>{u("chatkit")},className:`flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-medium transition-all ${v==="chatkit"?"bg-indigo-600 text-white shadow-sm":"text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"}`,children:[a.jsx(Ro,{className:"w-4 h-4"}),i.chatkit?.layeredMode||"分层代理"]})}),a.jsx(nn,{side:"bottom",sideOffset:8,className:"max-w-xs",children:a.jsxs("div",{className:"space-y-1",children:[a.jsx("p",{className:"font-medium",children:i.chatkit?.layeredMode||"分层代理"}),a.jsx("p",{className:"text-xs opacity-80",children:i.chatkit?.layeredModeDesc||"规划层分解任务,执行层独立完成子任务"})]})})]})]})}),a.jsx("div",{className:"flex-1 flex items-stretch justify-center min-h-0 px-4 py-4 pt-16",children:o.length===0?a.jsx("div",{className:"flex-1 flex items-center justify-center bg-slate-50 dark:bg-slate-950",children:a.jsxs("div",{className:"text-center",children:[a.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-slate-100 dark:bg-slate-800 mx-auto mb-4",children:a.jsx("svg",{className:"w-10 h-10 text-slate-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})})}),a.jsx("h3",{className:"text-lg font-semibold text-slate-900 dark:text-slate-100 mb-2",children:i.chat.welcomeTitle}),a.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:i.chat.connectDevice})]})}):o.map(C=>a.jsx("div",{className:`w-full max-w-7xl flex items-stretch justify-center min-h-0 ${C.id===l?"":"hidden"}`,children:v==="chatkit"?a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(hy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isVisible:C.id===l})}):a.jsx("div",{className:"w-full flex items-stretch justify-center",children:a.jsx(fy,{deviceId:C.id,deviceSerial:C.serial,deviceName:C.model,deviceConnectionType:C.connection_type,isConfigured:!!N?.base_url})})},C.serial))})]})]})}export{Ty as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./index-
|
|
1
|
+
import{o as e}from"./index-BzP-Te33.js";const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],o=e("circle-alert",c);export{o as C};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as ae,r as i,j as u,b as S,H as de,z as G,P as F,G as et,y as tt,D as Y,I as oe,al as nt,E as _,A as rt,am as at,ap as ot}from"./index-SysdKciY.js";const it=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pn=ae("loader-circle",it);const ct=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],On=ae("trash-2",ct);const st=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lt=ae("x",st),ut=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("rounded-2xl border border-slate-200 bg-white text-slate-950 shadow-sm dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",e),...t}));ut.displayName="Card";const dt=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("flex flex-col space-y-1.5 p-6",e),...t}));dt.displayName="CardHeader";const ft=i.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:S("text-xl font-semibold leading-none tracking-tight",e),...t}));ft.displayName="CardTitle";const vt=i.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:S("text-sm text-slate-500 dark:text-slate-400",e),...t}));vt.displayName="CardDescription";const mt=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("p-6 pt-0",e),...t}));mt.displayName="CardContent";const pt=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("flex items-center p-6 pt-0",e),...t}));pt.displayName="CardFooter";var Z="focusScope.autoFocusOnMount",q="focusScope.autoFocusOnUnmount",fe={bubbles:!1,cancelable:!0},ht="FocusScope",we=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=e,[c,y]=i.useState(null),h=de(a),m=de(o),f=i.useRef(null),p=G(t,s=>y(s)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let s=function(E){if(g.paused||!c)return;const C=E.target;c.contains(C)?f.current=C:T(f.current,{select:!0})},d=function(E){if(g.paused||!c)return;const C=E.relatedTarget;C!==null&&(c.contains(C)||T(f.current,{select:!0}))},v=function(E){if(document.activeElement===document.body)for(const w of E)w.removedNodes.length>0&&T(c)};document.addEventListener("focusin",s),document.addEventListener("focusout",d);const b=new MutationObserver(v);return c&&b.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",d),b.disconnect()}}},[r,c,g.paused]),i.useEffect(()=>{if(c){me.add(g);const s=document.activeElement;if(!c.contains(s)){const v=new CustomEvent(Z,fe);c.addEventListener(Z,h),c.dispatchEvent(v),v.defaultPrevented||(gt(wt(xe(c)),{select:!0}),document.activeElement===s&&T(c))}return()=>{c.removeEventListener(Z,h),setTimeout(()=>{const v=new CustomEvent(q,fe);c.addEventListener(q,m),c.dispatchEvent(v),v.defaultPrevented||T(s??document.body,{select:!0}),c.removeEventListener(q,m),me.remove(g)},0)}}},[c,h,m,g]);const x=i.useCallback(s=>{if(!n&&!r||g.paused)return;const d=s.key==="Tab"&&!s.altKey&&!s.ctrlKey&&!s.metaKey,v=document.activeElement;if(d&&v){const b=s.currentTarget,[E,C]=yt(b);E&&C?!s.shiftKey&&v===C?(s.preventDefault(),n&&T(E,{select:!0})):s.shiftKey&&v===E&&(s.preventDefault(),n&&T(C,{select:!0})):v===b&&s.preventDefault()}},[n,r,g.paused]);return u.jsx(F.div,{tabIndex:-1,...l,ref:p,onKeyDown:x})});we.displayName=ht;function gt(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(T(r,{select:t}),document.activeElement!==n)return}function yt(e){const t=xe(e),n=ve(t,e),r=ve(t.reverse(),e);return[n,r]}function xe(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ve(e,t){for(const n of e)if(!bt(n,{upTo:t}))return n}function bt(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Et(e){return e instanceof HTMLInputElement&&"select"in e}function T(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Et(e)&&t&&e.select()}}var me=Ct();function Ct(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=pe(e,t),e.unshift(t)},remove(t){e=pe(e,t),e[0]?.resume()}}}function pe(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function wt(e){return e.filter(t=>t.tagName!=="A")}var Q=0;function xt(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??he()),document.body.insertAdjacentElement("beforeend",e[1]??he()),Q++,()=>{Q===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Q--}},[])}function he(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var R=function(){return R=Object.assign||function(t){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},R.apply(this,arguments)};function Se(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}function St(e,t,n){if(n||arguments.length===2)for(var r=0,a=t.length,o;r<a;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var U="right-scroll-bar-position",$="width-before-scroll-bar",Nt="with-scroll-bars-hidden",Rt="--removed-body-scroll-bar-size";function J(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Dt(e,t){var n=i.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=t,n.facade}var kt=typeof window<"u"?i.useLayoutEffect:i.useEffect,ge=new WeakMap;function Tt(e,t){var n=Dt(null,function(r){return e.forEach(function(a){return J(a,r)})});return kt(function(){var r=ge.get(n);if(r){var a=new Set(r),o=new Set(e),l=n.current;a.forEach(function(c){o.has(c)||J(c,null)}),o.forEach(function(c){a.has(c)||J(c,l)})}ge.set(n,e)},[e]),n}function At(e){return e}function Pt(e,t){t===void 0&&(t=At);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var l=t(o,r);return n.push(l),function(){n=n.filter(function(c){return c!==l})}},assignSyncMedium:function(o){for(r=!0;n.length;){var l=n;n=[],l.forEach(o)}n={push:function(c){return o(c)},filter:function(){return n}}},assignMedium:function(o){r=!0;var l=[];if(n.length){var c=n;n=[],c.forEach(o),l=n}var y=function(){var m=l;l=[],m.forEach(o)},h=function(){return Promise.resolve().then(y)};h(),n={push:function(m){l.push(m),h()},filter:function(m){return l=l.filter(m),n}}}};return a}function Ot(e){e===void 0&&(e={});var t=Pt(null);return t.options=R({async:!0,ssr:!1},e),t}var Ne=function(e){var t=e.sideCar,n=Se(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return i.createElement(r,R({},n))};Ne.isSideCarExport=!0;function Mt(e,t){return e.useMedium(t),Ne}var Re=Ot(),ee=function(){},K=i.forwardRef(function(e,t){var n=i.useRef(null),r=i.useState({onScrollCapture:ee,onWheelCapture:ee,onTouchMoveCapture:ee}),a=r[0],o=r[1],l=e.forwardProps,c=e.children,y=e.className,h=e.removeScrollBar,m=e.enabled,f=e.shards,p=e.sideCar,g=e.noRelative,x=e.noIsolation,s=e.inert,d=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,E=e.gapMode,C=Se(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=p,D=Tt([n,t]),k=R(R({},C),a);return i.createElement(i.Fragment,null,m&&i.createElement(w,{sideCar:Re,removeScrollBar:h,shards:f,noRelative:g,noIsolation:x,inert:s,setCallbacks:o,allowPinchZoom:!!d,lockRef:n,gapMode:E}),l?i.cloneElement(i.Children.only(c),R(R({},k),{ref:D})):i.createElement(b,R({},k,{className:y,ref:D}),c))});K.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};K.classNames={fullWidth:$,zeroRight:U};var It=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ft(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=It();return t&&e.setAttribute("nonce",t),e}function _t(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function jt(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Lt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ft())&&(_t(t,n),jt(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wt=function(){var e=Lt();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},De=function(){var e=Wt(),t=function(n){var r=n.styles,a=n.dynamic;return e(r,a),null};return t},Bt={left:0,top:0,right:0,gap:0},te=function(e){return parseInt(e||"",10)||0},Ht=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[te(n),te(r),te(a)]},Ut=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Bt;var t=Ht(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},$t=De(),I="data-scroll-locked",Vt=function(e,t,n,r){var a=e.left,o=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
1
|
+
import{o as ae,r as i,j as u,b as S,H as de,z as G,P as F,G as et,y as tt,D as Y,I as oe,al as nt,E as _,A as rt,am as at,ap as ot}from"./index-BzP-Te33.js";const it=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Pn=ae("loader-circle",it);const ct=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],On=ae("trash-2",ct);const st=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lt=ae("x",st),ut=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("rounded-2xl border border-slate-200 bg-white text-slate-950 shadow-sm dark:border-slate-800 dark:bg-slate-950 dark:text-slate-50",e),...t}));ut.displayName="Card";const dt=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("flex flex-col space-y-1.5 p-6",e),...t}));dt.displayName="CardHeader";const ft=i.forwardRef(({className:e,...t},n)=>u.jsx("h3",{ref:n,className:S("text-xl font-semibold leading-none tracking-tight",e),...t}));ft.displayName="CardTitle";const vt=i.forwardRef(({className:e,...t},n)=>u.jsx("p",{ref:n,className:S("text-sm text-slate-500 dark:text-slate-400",e),...t}));vt.displayName="CardDescription";const mt=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("p-6 pt-0",e),...t}));mt.displayName="CardContent";const pt=i.forwardRef(({className:e,...t},n)=>u.jsx("div",{ref:n,className:S("flex items-center p-6 pt-0",e),...t}));pt.displayName="CardFooter";var Z="focusScope.autoFocusOnMount",q="focusScope.autoFocusOnUnmount",fe={bubbles:!1,cancelable:!0},ht="FocusScope",we=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=e,[c,y]=i.useState(null),h=de(a),m=de(o),f=i.useRef(null),p=G(t,s=>y(s)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let s=function(E){if(g.paused||!c)return;const C=E.target;c.contains(C)?f.current=C:T(f.current,{select:!0})},d=function(E){if(g.paused||!c)return;const C=E.relatedTarget;C!==null&&(c.contains(C)||T(f.current,{select:!0}))},v=function(E){if(document.activeElement===document.body)for(const w of E)w.removedNodes.length>0&&T(c)};document.addEventListener("focusin",s),document.addEventListener("focusout",d);const b=new MutationObserver(v);return c&&b.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",d),b.disconnect()}}},[r,c,g.paused]),i.useEffect(()=>{if(c){me.add(g);const s=document.activeElement;if(!c.contains(s)){const v=new CustomEvent(Z,fe);c.addEventListener(Z,h),c.dispatchEvent(v),v.defaultPrevented||(gt(wt(xe(c)),{select:!0}),document.activeElement===s&&T(c))}return()=>{c.removeEventListener(Z,h),setTimeout(()=>{const v=new CustomEvent(q,fe);c.addEventListener(q,m),c.dispatchEvent(v),v.defaultPrevented||T(s??document.body,{select:!0}),c.removeEventListener(q,m),me.remove(g)},0)}}},[c,h,m,g]);const x=i.useCallback(s=>{if(!n&&!r||g.paused)return;const d=s.key==="Tab"&&!s.altKey&&!s.ctrlKey&&!s.metaKey,v=document.activeElement;if(d&&v){const b=s.currentTarget,[E,C]=yt(b);E&&C?!s.shiftKey&&v===C?(s.preventDefault(),n&&T(E,{select:!0})):s.shiftKey&&v===E&&(s.preventDefault(),n&&T(C,{select:!0})):v===b&&s.preventDefault()}},[n,r,g.paused]);return u.jsx(F.div,{tabIndex:-1,...l,ref:p,onKeyDown:x})});we.displayName=ht;function gt(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(T(r,{select:t}),document.activeElement!==n)return}function yt(e){const t=xe(e),n=ve(t,e),r=ve(t.reverse(),e);return[n,r]}function xe(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ve(e,t){for(const n of e)if(!bt(n,{upTo:t}))return n}function bt(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Et(e){return e instanceof HTMLInputElement&&"select"in e}function T(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Et(e)&&t&&e.select()}}var me=Ct();function Ct(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=pe(e,t),e.unshift(t)},remove(t){e=pe(e,t),e[0]?.resume()}}}function pe(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function wt(e){return e.filter(t=>t.tagName!=="A")}var Q=0;function xt(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??he()),document.body.insertAdjacentElement("beforeend",e[1]??he()),Q++,()=>{Q===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Q--}},[])}function he(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var R=function(){return R=Object.assign||function(t){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},R.apply(this,arguments)};function Se(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(e);a<r.length;a++)t.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(e,r[a])&&(n[r[a]]=e[r[a]]);return n}function St(e,t,n){if(n||arguments.length===2)for(var r=0,a=t.length,o;r<a;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var U="right-scroll-bar-position",$="width-before-scroll-bar",Nt="with-scroll-bars-hidden",Rt="--removed-body-scroll-bar-size";function J(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Dt(e,t){var n=i.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=t,n.facade}var kt=typeof window<"u"?i.useLayoutEffect:i.useEffect,ge=new WeakMap;function Tt(e,t){var n=Dt(null,function(r){return e.forEach(function(a){return J(a,r)})});return kt(function(){var r=ge.get(n);if(r){var a=new Set(r),o=new Set(e),l=n.current;a.forEach(function(c){o.has(c)||J(c,null)}),o.forEach(function(c){a.has(c)||J(c,l)})}ge.set(n,e)},[e]),n}function At(e){return e}function Pt(e,t){t===void 0&&(t=At);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var l=t(o,r);return n.push(l),function(){n=n.filter(function(c){return c!==l})}},assignSyncMedium:function(o){for(r=!0;n.length;){var l=n;n=[],l.forEach(o)}n={push:function(c){return o(c)},filter:function(){return n}}},assignMedium:function(o){r=!0;var l=[];if(n.length){var c=n;n=[],c.forEach(o),l=n}var y=function(){var m=l;l=[],m.forEach(o)},h=function(){return Promise.resolve().then(y)};h(),n={push:function(m){l.push(m),h()},filter:function(m){return l=l.filter(m),n}}}};return a}function Ot(e){e===void 0&&(e={});var t=Pt(null);return t.options=R({async:!0,ssr:!1},e),t}var Ne=function(e){var t=e.sideCar,n=Se(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return i.createElement(r,R({},n))};Ne.isSideCarExport=!0;function Mt(e,t){return e.useMedium(t),Ne}var Re=Ot(),ee=function(){},K=i.forwardRef(function(e,t){var n=i.useRef(null),r=i.useState({onScrollCapture:ee,onWheelCapture:ee,onTouchMoveCapture:ee}),a=r[0],o=r[1],l=e.forwardProps,c=e.children,y=e.className,h=e.removeScrollBar,m=e.enabled,f=e.shards,p=e.sideCar,g=e.noRelative,x=e.noIsolation,s=e.inert,d=e.allowPinchZoom,v=e.as,b=v===void 0?"div":v,E=e.gapMode,C=Se(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=p,D=Tt([n,t]),k=R(R({},C),a);return i.createElement(i.Fragment,null,m&&i.createElement(w,{sideCar:Re,removeScrollBar:h,shards:f,noRelative:g,noIsolation:x,inert:s,setCallbacks:o,allowPinchZoom:!!d,lockRef:n,gapMode:E}),l?i.cloneElement(i.Children.only(c),R(R({},k),{ref:D})):i.createElement(b,R({},k,{className:y,ref:D}),c))});K.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};K.classNames={fullWidth:$,zeroRight:U};var It=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ft(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=It();return t&&e.setAttribute("nonce",t),e}function _t(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function jt(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Lt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ft())&&(_t(t,n),jt(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Wt=function(){var e=Lt();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},De=function(){var e=Wt(),t=function(n){var r=n.styles,a=n.dynamic;return e(r,a),null};return t},Bt={left:0,top:0,right:0,gap:0},te=function(e){return parseInt(e||"",10)||0},Ht=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[te(n),te(r),te(a)]},Ut=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Bt;var t=Ht(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},$t=De(),I="data-scroll-locked",Vt=function(e,t,n,r){var a=e.left,o=e.top,l=e.right,c=e.gap;return n===void 0&&(n="margin"),`
|
|
2
2
|
.`.concat(Nt,` {
|
|
3
3
|
overflow: hidden `).concat(r,`;
|
|
4
4
|
padding-right: `).concat(c,"px ").concat(r,`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as c}from"./index-
|
|
1
|
+
import{o as c}from"./index-BzP-Te33.js";const e=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],n=c("chevron-right",e);const o=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],r=c("eye",o);export{n as C,r as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as K,u as de,r,p as xe,j as e,B as h,f as m,C as E,g as he,q as me,s as ge}from"./index-SysdKciY.js";import{T as F,L as H,C as ue,c as pe,D as je,d as fe,e as ye,f as Ne}from"./dialog-BgtPh0d5.js";import{S as ke,a as be,b as ve,c as we,d as R,A as z,e as B,f as V,g as q,h as I,i as J,j as U,k as X}from"./alert-dialog-BKM-yRiQ.js";import{C as Y,a as G,b as De}from"./popover-CikYqu2P.js";import{E as Se,C as Ce}from"./eye-DLqKbQmg.js";const Pe=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Le=K("bot",Pe);const Ae=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],_e=K("user",Ae);function Fe(){const t=de(),[N,Q]=r.useState([]),[n,k]=r.useState(""),[o,x]=r.useState([]),[W,b]=r.useState(!1),[v,w]=r.useState(!1),[D,g]=r.useState(0),[S,u]=r.useState(0),[Z,p]=r.useState(!1),[ee,j]=r.useState(!1),[f,C]=r.useState(null),[se,P]=r.useState(!1),[i,te]=r.useState(null),[y,L]=r.useState(new Set),ae=20;r.useEffect(()=>{(async()=>{try{const a=await he();Q(a),a.length>0&&!n&&k(a[0].serial)}catch(a){console.error("Failed to load devices:",a)}})()},[n]);const A=r.useCallback(async(s,a=!0)=>{if(s)try{a?(b(!0),u(0)):w(!0);const l=a?0:S,c=await xe(s,ae,l);x(a?c.records:d=>[...d,...c.records]),g(c.total),u(l+c.records.length)}catch(l){console.error("Failed to load history:",l)}finally{b(!1),w(!1)}},[S]);r.useEffect(()=>{n&&A(n,!0)},[n]);const le=()=>{n&&o.length<D&&A(n,!1)},re=async()=>{if(n){try{await me(n),x([]),g(0),u(0)}catch(s){console.error("Failed to clear history:",s)}p(!1)}},ne=async()=>{if(!(!n||!f)){try{await ge(n,f),x(s=>s.filter(a=>a.id!==f)),g(s=>s-1)}catch(s){console.error("Failed to delete record:",s)}j(!1),C(null)}},_=s=>{te(s);const a=new Set;s.messages.forEach(l=>{l.step!==null&&l.step!==void 0&&a.add(l.step)}),L(a),P(!0)},ie=s=>{L(a=>{const l=new Set(a);return l.has(s)?l.delete(s):l.add(s),l})},M=s=>s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:`${(s/6e4).toFixed(1)}min`,ce=s=>{const a=new Date(s),l=new Date,c=a.toDateString()===l.toDateString(),d=new Date(l);d.setDate(d.getDate()-1);const oe=a.toDateString()===d.toDateString(),$=a.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return c?`${t.history.today} ${$}`:oe?`${t.history.yesterday} ${$}`:a.toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},T=s=>({chat:t.historyPage.source.chat,layered:t.historyPage.source.layered,scheduled:t.historyPage.source.scheduled})[s]||s,O=s=>{switch(s){case"chat":return"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300";case"layered":return"bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-300";case"scheduled":return"bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300";default:return"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}};return e.jsxs("div",{className:"container mx-auto p-6 max-w-4xl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold",children:t.historyPage.title}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ke,{value:n,onValueChange:k,children:[e.jsx(be,{className:"w-[200px]",children:e.jsx(ve,{placeholder:t.historyPage.selectDevice})}),e.jsx(we,{children:N.length===0?e.jsx(R,{value:"_none",disabled:!0,children:t.historyPage.noDevices}):N.map(s=>e.jsx(R,{value:s.serial,children:s.model||s.serial},s.serial))})]}),o.length>0&&e.jsxs(h,{variant:"destructive",size:"sm",onClick:()=>p(!0),children:[e.jsx(F,{className:"w-4 h-4 mr-2"}),t.historyPage.clearAll]})]})]}),W?e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsx(H,{className:"w-8 h-8 animate-spin text-slate-400"})}):o.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:t.historyPage.noRecords}),e.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mt-2",children:t.historyPage.noRecordsDesc})]}):e.jsxs("div",{className:"space-y-4",children:[o.map(s=>e.jsx(ue,{className:"hover:shadow-md transition-shadow cursor-pointer",onClick:()=>_(s),children:e.jsx(pe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2 mb-2",children:s.task_text}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400 line-clamp-2 mb-3",children:s.final_message}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[s.success?e.jsxs(m,{variant:"outline",className:"text-green-600 border-green-300 dark:text-green-400 dark:border-green-700",children:[e.jsx(Y,{className:"w-3 h-3 mr-1"}),t.historyPage.success]}):e.jsxs(m,{variant:"outline",className:"text-red-600 border-red-300 dark:text-red-400 dark:border-red-700",children:[e.jsx(G,{className:"w-3 h-3 mr-1"}),t.historyPage.failed]}),e.jsxs(m,{className:O(s.source),children:[T(s.source),s.source_detail&&`: ${s.source_detail}`]}),s.steps>0&&e.jsx("span",{className:"text-slate-500 dark:text-slate-400",children:t.historyPage.steps.replace("{count}",String(s.steps))}),e.jsxs("span",{className:"text-slate-500 dark:text-slate-400 flex items-center",children:[e.jsx(E,{className:"w-3 h-3 mr-1"}),M(s.duration_ms)]}),e.jsx("span",{className:"text-slate-400 dark:text-slate-500",children:ce(s.start_time)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"sm",className:"text-slate-400 hover:text-blue-500",onClick:a=>{a.stopPropagation(),_(s)},children:e.jsx(Se,{className:"w-4 h-4"})}),e.jsx(h,{variant:"ghost",size:"sm",className:"text-slate-400 hover:text-red-500",onClick:a=>{a.stopPropagation(),C(s.id),j(!0)},children:e.jsx(F,{className:"w-4 h-4"})})]})]})})},s.id)),o.length<D&&e.jsx("div",{className:"text-center py-4",children:e.jsx(h,{variant:"outline",onClick:le,disabled:v,children:v?e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-4 h-4 mr-2 animate-spin"}),t.historyPage.loading]}):t.historyPage.loadMore})})]}),e.jsx(z,{open:Z,onOpenChange:p,children:e.jsxs(B,{children:[e.jsxs(V,{children:[e.jsx(q,{children:t.historyPage.clearAll}),e.jsx(I,{children:t.historyPage.clearAllConfirm})]}),e.jsxs(J,{children:[e.jsx(U,{children:t.common.cancel}),e.jsx(X,{onClick:re,children:t.common.confirm})]})]})}),e.jsx(z,{open:ee,onOpenChange:j,children:e.jsxs(B,{children:[e.jsxs(V,{children:[e.jsx(q,{children:t.common.delete}),e.jsx(I,{children:t.historyPage.deleteConfirm})]}),e.jsxs(J,{children:[e.jsx(U,{children:t.common.cancel}),e.jsx(X,{onClick:ne,children:t.common.confirm})]})]})}),e.jsx(je,{open:se,onOpenChange:P,children:e.jsxs(fe,{className:"max-w-2xl max-h-[80vh] flex flex-col overflow-hidden",children:[e.jsx(ye,{className:"flex-shrink-0",children:e.jsxs(Ne,{className:"flex items-center gap-2",children:[i?.success?e.jsx(Y,{className:"w-5 h-5 text-green-500"}):e.jsx(G,{className:"w-5 h-5 text-red-500"}),t.historyPage.detailTitle||"对话详情"]})}),i&&e.jsx("div",{className:"overflow-y-auto max-h-[calc(80vh-120px)] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-slate-50 dark:bg-slate-900 rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 mb-1",children:t.historyPage.taskLabel||"任务"}),e.jsx("p",{className:"text-sm text-slate-900 dark:text-slate-100",children:i.task_text})]}),e.jsx("div",{className:"space-y-3",children:i.messages.length>0?i.messages.map((s,a)=>e.jsx("div",{className:"space-y-2",children:s.role==="user"?e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900 flex items-center justify-center flex-shrink-0",children:e.jsx(_e,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("div",{className:"flex-1 p-3 bg-blue-50 dark:bg-blue-900/30 rounded-lg",children:e.jsx("p",{className:"text-sm text-slate-900 dark:text-slate-100",children:s.content})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-emerald-100 dark:bg-emerald-900 flex items-center justify-center flex-shrink-0",children:e.jsx(Le,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"flex-1 space-y-2",children:[s.step!==null&&s.step!==void 0&&e.jsxs("button",{className:"flex items-center gap-1 text-xs text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200",onClick:()=>ie(s.step),children:[y.has(s.step)?e.jsx(De,{className:"w-3 h-3"}):e.jsx(Ce,{className:"w-3 h-3"}),t.historyPage.stepLabel?.replace("{step}",String(s.step))||`步骤 ${s.step}`]}),s.thinking&&(s.step===null||s.step===void 0||y.has(s.step))&&e.jsxs("div",{className:"p-3 bg-slate-100 dark:bg-slate-800 rounded-lg",children:[e.jsx("p",{className:"text-xs font-medium text-slate-500 dark:text-slate-400 mb-1",children:t.historyPage.thinkingLabel||"思考"}),e.jsx("p",{className:"text-sm text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:s.thinking})]}),s.action&&(s.step===null||s.step===void 0||y.has(s.step))&&e.jsxs("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg",children:[e.jsx("p",{className:"text-xs font-medium text-amber-600 dark:text-amber-400 mb-1",children:t.historyPage.actionLabel||"动作"}),e.jsx("pre",{className:"text-xs text-slate-700 dark:text-slate-300 overflow-x-auto",children:JSON.stringify(s.action,null,2)})]})]})]})},a)):e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 text-center py-4",children:t.historyPage.noMessages||"暂无详细消息记录"})}),e.jsxs("div",{className:`p-3 rounded-lg ${i.success?"bg-green-50 dark:bg-green-900/20":"bg-red-50 dark:bg-red-900/20"}`,children:[e.jsx("p",{className:`text-xs font-medium mb-1 ${i.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:t.historyPage.resultLabel||"结果"}),e.jsx("p",{className:"text-sm text-slate-900 dark:text-slate-100",children:i.final_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-slate-500 dark:text-slate-400 pt-2 border-t border-slate-200 dark:border-slate-700",children:[e.jsx("span",{children:t.historyPage.steps.replace("{count}",String(i.steps))}),e.jsxs("span",{className:"flex items-center",children:[e.jsx(E,{className:"w-3 h-3 mr-1"}),M(i.duration_ms)]}),e.jsx(m,{className:O(i.source),children:T(i.source)})]})]})})]})})]})}export{Fe as component};
|
|
1
|
+
import{o as K,u as de,r,p as xe,j as e,B as h,f as m,C as E,g as he,q as me,s as ge}from"./index-BzP-Te33.js";import{T as F,L as H,C as ue,c as pe,D as je,d as fe,e as ye,f as Ne}from"./dialog-Cuw3N8_F.js";import{S as ke,a as be,b as ve,c as we,d as R,A as z,e as B,f as V,g as q,h as I,i as J,j as U,k as X}from"./alert-dialog-B2KxPLtZ.js";import{C as Y,a as G,b as De}from"./popover-BHbCs5Wl.js";import{E as Se,C as Ce}from"./eye-JD1jbm99.js";const Pe=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Le=K("bot",Pe);const Ae=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],_e=K("user",Ae);function Fe(){const t=de(),[N,Q]=r.useState([]),[n,k]=r.useState(""),[o,x]=r.useState([]),[W,b]=r.useState(!1),[v,w]=r.useState(!1),[D,g]=r.useState(0),[S,u]=r.useState(0),[Z,p]=r.useState(!1),[ee,j]=r.useState(!1),[f,C]=r.useState(null),[se,P]=r.useState(!1),[i,te]=r.useState(null),[y,L]=r.useState(new Set),ae=20;r.useEffect(()=>{(async()=>{try{const a=await he();Q(a),a.length>0&&!n&&k(a[0].serial)}catch(a){console.error("Failed to load devices:",a)}})()},[n]);const A=r.useCallback(async(s,a=!0)=>{if(s)try{a?(b(!0),u(0)):w(!0);const l=a?0:S,c=await xe(s,ae,l);x(a?c.records:d=>[...d,...c.records]),g(c.total),u(l+c.records.length)}catch(l){console.error("Failed to load history:",l)}finally{b(!1),w(!1)}},[S]);r.useEffect(()=>{n&&A(n,!0)},[n]);const le=()=>{n&&o.length<D&&A(n,!1)},re=async()=>{if(n){try{await me(n),x([]),g(0),u(0)}catch(s){console.error("Failed to clear history:",s)}p(!1)}},ne=async()=>{if(!(!n||!f)){try{await ge(n,f),x(s=>s.filter(a=>a.id!==f)),g(s=>s-1)}catch(s){console.error("Failed to delete record:",s)}j(!1),C(null)}},_=s=>{te(s);const a=new Set;s.messages.forEach(l=>{l.step!==null&&l.step!==void 0&&a.add(l.step)}),L(a),P(!0)},ie=s=>{L(a=>{const l=new Set(a);return l.has(s)?l.delete(s):l.add(s),l})},M=s=>s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:`${(s/6e4).toFixed(1)}min`,ce=s=>{const a=new Date(s),l=new Date,c=a.toDateString()===l.toDateString(),d=new Date(l);d.setDate(d.getDate()-1);const oe=a.toDateString()===d.toDateString(),$=a.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"});return c?`${t.history.today} ${$}`:oe?`${t.history.yesterday} ${$}`:a.toLocaleDateString("zh-CN",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},T=s=>({chat:t.historyPage.source.chat,layered:t.historyPage.source.layered,scheduled:t.historyPage.source.scheduled})[s]||s,O=s=>{switch(s){case"chat":return"bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300";case"layered":return"bg-purple-100 text-purple-700 dark:bg-purple-900 dark:text-purple-300";case"scheduled":return"bg-orange-100 text-orange-700 dark:bg-orange-900 dark:text-orange-300";default:return"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300"}};return e.jsxs("div",{className:"container mx-auto p-6 max-w-4xl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold",children:t.historyPage.title}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ke,{value:n,onValueChange:k,children:[e.jsx(be,{className:"w-[200px]",children:e.jsx(ve,{placeholder:t.historyPage.selectDevice})}),e.jsx(we,{children:N.length===0?e.jsx(R,{value:"_none",disabled:!0,children:t.historyPage.noDevices}):N.map(s=>e.jsx(R,{value:s.serial,children:s.model||s.serial},s.serial))})]}),o.length>0&&e.jsxs(h,{variant:"destructive",size:"sm",onClick:()=>p(!0),children:[e.jsx(F,{className:"w-4 h-4 mr-2"}),t.historyPage.clearAll]})]})]}),W?e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsx(H,{className:"w-8 h-8 animate-spin text-slate-400"})}):o.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-slate-500 dark:text-slate-400",children:t.historyPage.noRecords}),e.jsx("p",{className:"text-sm text-slate-400 dark:text-slate-500 mt-2",children:t.historyPage.noRecordsDesc})]}):e.jsxs("div",{className:"space-y-4",children:[o.map(s=>e.jsx(ue,{className:"hover:shadow-md transition-shadow cursor-pointer",onClick:()=>_(s),children:e.jsx(pe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-2 mb-2",children:s.task_text}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400 line-clamp-2 mb-3",children:s.final_message}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[s.success?e.jsxs(m,{variant:"outline",className:"text-green-600 border-green-300 dark:text-green-400 dark:border-green-700",children:[e.jsx(Y,{className:"w-3 h-3 mr-1"}),t.historyPage.success]}):e.jsxs(m,{variant:"outline",className:"text-red-600 border-red-300 dark:text-red-400 dark:border-red-700",children:[e.jsx(G,{className:"w-3 h-3 mr-1"}),t.historyPage.failed]}),e.jsxs(m,{className:O(s.source),children:[T(s.source),s.source_detail&&`: ${s.source_detail}`]}),s.steps>0&&e.jsx("span",{className:"text-slate-500 dark:text-slate-400",children:t.historyPage.steps.replace("{count}",String(s.steps))}),e.jsxs("span",{className:"text-slate-500 dark:text-slate-400 flex items-center",children:[e.jsx(E,{className:"w-3 h-3 mr-1"}),M(s.duration_ms)]}),e.jsx("span",{className:"text-slate-400 dark:text-slate-500",children:ce(s.start_time)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"sm",className:"text-slate-400 hover:text-blue-500",onClick:a=>{a.stopPropagation(),_(s)},children:e.jsx(Se,{className:"w-4 h-4"})}),e.jsx(h,{variant:"ghost",size:"sm",className:"text-slate-400 hover:text-red-500",onClick:a=>{a.stopPropagation(),C(s.id),j(!0)},children:e.jsx(F,{className:"w-4 h-4"})})]})]})})},s.id)),o.length<D&&e.jsx("div",{className:"text-center py-4",children:e.jsx(h,{variant:"outline",onClick:le,disabled:v,children:v?e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"w-4 h-4 mr-2 animate-spin"}),t.historyPage.loading]}):t.historyPage.loadMore})})]}),e.jsx(z,{open:Z,onOpenChange:p,children:e.jsxs(B,{children:[e.jsxs(V,{children:[e.jsx(q,{children:t.historyPage.clearAll}),e.jsx(I,{children:t.historyPage.clearAllConfirm})]}),e.jsxs(J,{children:[e.jsx(U,{children:t.common.cancel}),e.jsx(X,{onClick:re,children:t.common.confirm})]})]})}),e.jsx(z,{open:ee,onOpenChange:j,children:e.jsxs(B,{children:[e.jsxs(V,{children:[e.jsx(q,{children:t.common.delete}),e.jsx(I,{children:t.historyPage.deleteConfirm})]}),e.jsxs(J,{children:[e.jsx(U,{children:t.common.cancel}),e.jsx(X,{onClick:ne,children:t.common.confirm})]})]})}),e.jsx(je,{open:se,onOpenChange:P,children:e.jsxs(fe,{className:"max-w-2xl max-h-[80vh] flex flex-col overflow-hidden",children:[e.jsx(ye,{className:"flex-shrink-0",children:e.jsxs(Ne,{className:"flex items-center gap-2",children:[i?.success?e.jsx(Y,{className:"w-5 h-5 text-green-500"}):e.jsx(G,{className:"w-5 h-5 text-red-500"}),t.historyPage.detailTitle||"对话详情"]})}),i&&e.jsx("div",{className:"overflow-y-auto max-h-[calc(80vh-120px)] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-3 bg-slate-50 dark:bg-slate-900 rounded-lg",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700 dark:text-slate-300 mb-1",children:t.historyPage.taskLabel||"任务"}),e.jsx("p",{className:"text-sm text-slate-900 dark:text-slate-100",children:i.task_text})]}),e.jsx("div",{className:"space-y-3",children:i.messages.length>0?i.messages.map((s,a)=>e.jsx("div",{className:"space-y-2",children:s.role==="user"?e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900 flex items-center justify-center flex-shrink-0",children:e.jsx(_e,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("div",{className:"flex-1 p-3 bg-blue-50 dark:bg-blue-900/30 rounded-lg",children:e.jsx("p",{className:"text-sm text-slate-900 dark:text-slate-100",children:s.content})})]}):e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-emerald-100 dark:bg-emerald-900 flex items-center justify-center flex-shrink-0",children:e.jsx(Le,{className:"w-4 h-4 text-emerald-600 dark:text-emerald-400"})}),e.jsxs("div",{className:"flex-1 space-y-2",children:[s.step!==null&&s.step!==void 0&&e.jsxs("button",{className:"flex items-center gap-1 text-xs text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200",onClick:()=>ie(s.step),children:[y.has(s.step)?e.jsx(De,{className:"w-3 h-3"}):e.jsx(Ce,{className:"w-3 h-3"}),t.historyPage.stepLabel?.replace("{step}",String(s.step))||`步骤 ${s.step}`]}),s.thinking&&(s.step===null||s.step===void 0||y.has(s.step))&&e.jsxs("div",{className:"p-3 bg-slate-100 dark:bg-slate-800 rounded-lg",children:[e.jsx("p",{className:"text-xs font-medium text-slate-500 dark:text-slate-400 mb-1",children:t.historyPage.thinkingLabel||"思考"}),e.jsx("p",{className:"text-sm text-slate-700 dark:text-slate-300 whitespace-pre-wrap",children:s.thinking})]}),s.action&&(s.step===null||s.step===void 0||y.has(s.step))&&e.jsxs("div",{className:"p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg",children:[e.jsx("p",{className:"text-xs font-medium text-amber-600 dark:text-amber-400 mb-1",children:t.historyPage.actionLabel||"动作"}),e.jsx("pre",{className:"text-xs text-slate-700 dark:text-slate-300 overflow-x-auto",children:JSON.stringify(s.action,null,2)})]})]})]})},a)):e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 text-center py-4",children:t.historyPage.noMessages||"暂无详细消息记录"})}),e.jsxs("div",{className:`p-3 rounded-lg ${i.success?"bg-green-50 dark:bg-green-900/20":"bg-red-50 dark:bg-red-900/20"}`,children:[e.jsx("p",{className:`text-xs font-medium mb-1 ${i.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:t.historyPage.resultLabel||"结果"}),e.jsx("p",{className:"text-sm text-slate-900 dark:text-slate-100",children:i.final_message})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-slate-500 dark:text-slate-400 pt-2 border-t border-slate-200 dark:border-slate-700",children:[e.jsx("span",{children:t.historyPage.steps.replace("{count}",String(i.steps))}),e.jsxs("span",{className:"flex items-center",children:[e.jsx(E,{className:"w-3 h-3 mr-1"}),M(i.duration_ms)]}),e.jsx(m,{className:O(i.source),children:T(i.source)})]})]})})]})})]})}export{Fe as component};
|