@kingsoftcloud/agentkit-personal-assistant 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -3,4 +3,4 @@
3
3
  `),r=[],n=0,a=o=>{o.length!==0&&(r.push({type:"paragraph",text:o.join(`
4
4
  `)}),o.length=0)},s=[];for(;n<d.length;){let o=d[n],f=Mt.exec(o);if(f){a(s);let R=[];for(n+=1;n<d.length&&!/^```\s*$/u.test(d[n]);)R.push(d[n]),n+=1;n+=1,r.push({type:"code",lang:f[1]||"",text:R.join(`
5
5
  `)});continue}if(o.trim()===""){a(s),n+=1;continue}let p=$t.exec(o);if(p){a(s),r.push({type:"heading",level:p[1].length,text:p[2].trim()}),n+=1;continue}if(jt.test(o)){a(s),r.push({type:"rule"}),n+=1;continue}let E=Ge.exec(o);if(E){a(s);let R=[E[1]];for(n+=1;n<d.length&&Ge.test(d[n]);)R.push(Ge.exec(d[n])[1]),n+=1;r.push({type:"quote",text:R.join(`
6
- `)});continue}let D=pt.exec(o),S=ft.exec(o);if(D||S){a(s);let R={type:S?"ordered":"unordered",items:[],start:S?Number(S[1]):1};for(;n<d.length;){let N=pt.exec(d[n]),T=ft.exec(d[n]);if(!N&&!T)break;R.items.push((N?N[1]:T[2]).trim()),n+=1}r.push(R);continue}s.push(o),n+=1}return a(s),r}function Ht(t){let g=typeof t=="string"?t:"",d=[],r=a=>{a&&d.push({type:"text",text:a})},n=g;for(;n.length>0;){let a=/^`([^`]+)`/u.exec(n);if(a){d.push({type:"code",text:a[1]}),n=n.slice(a[0].length);continue}let s=/^\*\*([^*\n]+)\*\*/u.exec(n)||/^__([^_\n]+)__/u.exec(n);if(s){d.push({type:"strong",text:s[1]}),n=n.slice(s[0].length);continue}let o=/^\*([^*\s][^*\n]*)\*/u.exec(n)||/^_([^_\s][^_\n]*)_/u.exec(n);if(o){d.push({type:"em",text:o[1]}),n=n.slice(o[0].length);continue}let f=/^\[([^\]]+)\]\(([^)\s]+)\)/u.exec(n);if(f){d.push({type:"link",text:f[1],href:f[2]}),n=n.slice(f[0].length);continue}let p=n.slice(1).search(/[`*_[\]\n]/u),E=p<0?n.length:p+1;r(n.slice(0,E)),n=n.slice(E)}return d.reduce((a,s)=>{let o=a[a.length-1];return s.type==="text"&&o&&o.type==="text"?a[a.length-1]={type:"text",text:o.text+s.text}:a.push(s),a},[])}function gt(t,g,d={}){let r=Wt(g);if(r.length===0)return null;let n=(a,s)=>Ht(a).map((o,f)=>{let p=`${s}-i${f}`;return o.type==="code"?t("code",{key:p,style:d.inlineCode},o.text):o.type==="strong"?t("strong",{key:p},o.text):o.type==="em"?t("em",{key:p},o.text):o.type==="link"?/^(https?:|mailto:|cloud-file:)/iu.test(o.href)?t("a",{key:p,href:o.href,target:"_blank",rel:"noreferrer noopener",style:d.link},o.text):t("span",{key:p},o.text):t("span",{key:p},o.text)});return r.map((a,s)=>{let o=`b${s}`;if(a.type==="code")return t("pre",{key:o,style:d.codeBlock},t("code",null,a.text));if(a.type==="heading")return t("div",{key:o,style:{...d.heading,...a.level<=2?d.headingStrong:null}},n(a.text,o));if(a.type==="rule")return t("hr",{key:o,style:d.rule});if(a.type==="quote")return t("blockquote",{key:o,style:d.quote},n(a.text,o));if(a.type==="unordered"||a.type==="ordered"){let f=a.type==="ordered"?"ol":"ul";return t(f,{key:o,style:d.list,start:a.type==="ordered"&&a.start!==1?a.start:void 0},a.items.map((p,E)=>t("li",{key:`${o}-l${E}`},n(p,`${o}-l${E}`))))}return t("p",{key:o,style:d.paragraph},n(a.text,o))})}var qt="\u6709\u4EC0\u4E48\u53EF\u4EE5\u5E2E\u4F60\uFF1F",Kt=new Set(["DSH_SESSION_BUSY","DSH_TURN_TIMEOUT"]),bt={RUNTIME_PROCESS_INTERRUPTED:"\u4E91\u7535\u8111\u91CD\u542F\uFF0C\u4EFB\u52A1\u88AB\u4E2D\u65AD",DSH_SESSION_CONTROLLER_UNAVAILABLE:"\u4E91\u7AEF\u8FDE\u63A5\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",DSH_TURN_NOT_ACCEPTED:"\u4E91\u7AEF\u6CA1\u6709\u63A5\u53D7\u8FD9\u4E00\u8F6E\u5BF9\u8BDD\uFF0C\u8BF7\u91CD\u65B0\u53D1\u9001",DSH_SESSION_NOT_FOUND:"\u4F1A\u8BDD\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5220\u9664"},Vt=t=>{let g=String(t||"").trim();return g?bt[g]?bt[g]:/^[A-Z][A-Z0-9_]{5,}$/u.test(g)?"\u4E91\u7AEF\u6CA1\u6709\u5B8C\u6210\u8FD9\u4E00\u8F6E\uFF0C\u8BF7\u91CD\u8BD5":g.slice(0,160):"\u8BF7\u68C0\u67E5\u4EFB\u52A1\u72B6\u6001\u540E\u91CD\u8BD5"},Yt=400,Qt=8,yt=1500,I={page:{flex:"1 1 0px",height:"100%",maxHeight:"100%",minHeight:0,minWidth:0,overflow:"hidden",boxSizing:"border-box",display:"flex",flexDirection:"column",fontSize:13,color:"var(--dsw-alias-label-primary, #17202c)",background:"var(--dsw-alias-bg-layer-1, #fff)"},header:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--dsw-alias-border-default, #d8dee8)",flex:"none"},title:{margin:0,fontSize:14,fontWeight:600},status:{color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12},spacer:{marginLeft:"auto"},ghost:{border:"1px solid var(--dsw-alias-border-default, #d8dee8)",background:"transparent",color:"inherit",borderRadius:8,padding:"5px 10px",cursor:"pointer",font:"inherit",fontSize:12},scroller:{flex:"1 1 0px",minHeight:0,minWidth:0,overflowY:"auto",overflowX:"hidden",overscrollBehavior:"contain",boxSizing:"border-box",padding:"20px 16px 8px"},thread:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:14},row:{display:"flex",flexDirection:"column",gap:4,alignItems:"flex-start"},rowUser:{display:"flex",flexDirection:"column",gap:4,alignItems:"flex-end"},who:{fontSize:11,color:"var(--dsw-alias-label-secondary, #536174)"},bubble:{maxWidth:"86%",padding:"9px 12px",borderRadius:12,lineHeight:1.7,overflowWrap:"anywhere",display:"flex",flexDirection:"column",gap:8,background:"color-mix(in srgb, currentColor 5%, transparent)"},paragraph:{margin:0,whiteSpace:"pre-wrap"},heading:{fontWeight:600,fontSize:13.5},headingStrong:{fontSize:15},list:{margin:0,paddingLeft:20,display:"flex",flexDirection:"column",gap:4},codeBlock:{margin:0,padding:"10px 12px",borderRadius:8,overflowX:"auto",fontSize:12,lineHeight:1.65,background:"color-mix(in srgb, currentColor 9%, transparent)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},inlineCode:{padding:"1px 5px",borderRadius:5,fontSize:12,background:"color-mix(in srgb, currentColor 9%, transparent)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},quote:{margin:0,paddingLeft:10,borderLeft:"3px solid var(--dsw-alias-border-default, #d8dee8)",color:"var(--dsw-alias-label-secondary, #536174)"},rule:{border:"none",borderTop:"1px solid var(--dsw-alias-border-default, #d8dee8)",margin:"2px 0",width:"100%"},link:{color:"#2f6bff",textDecoration:"none"},bubbleUser:{maxWidth:"86%",padding:"9px 12px",borderRadius:12,lineHeight:1.7,whiteSpace:"pre-wrap",overflowWrap:"anywhere",background:"color-mix(in srgb, #2f6bff 12%, transparent)"},pulse:{animation:"pa-awaiting 1.2s ease-in-out infinite"},step:{fontSize:12,color:"var(--dsw-alias-label-secondary, #536174)",lineHeight:1.7,overflowWrap:"anywhere"},centered:{flex:1,display:"grid",placeItems:"center",padding:24,textAlign:"center"},centeredInner:{maxWidth:420,display:"flex",flexDirection:"column",gap:10,alignItems:"center"},composer:{flex:"0 0 auto",minWidth:0,boxSizing:"border-box",padding:"8px 16px 14px"},composerInner:{maxWidth:720,minWidth:0,margin:"0 auto",display:"flex",flexDirection:"column",gap:6,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:16,padding:"10px 10px 8px 12px",background:"var(--dsw-alias-bg-layer-1, #fff)"},textarea:{flex:1,width:"100%",minWidth:0,boxSizing:"border-box",minHeight:24,maxHeight:200,resize:"none",border:"none",outline:"none",background:"transparent",color:"inherit",font:"inherit",fontSize:13,lineHeight:1.7},composerBar:{display:"flex",alignItems:"center",gap:8},iconButton:{flex:"none",width:28,height:28,display:"grid",placeItems:"center",cursor:"pointer",border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:999,background:"transparent",color:"var(--dsw-alias-label-secondary, #536174)",padding:0},send:{flex:"none",width:28,height:28,display:"grid",placeItems:"center",border:"none",borderRadius:999,cursor:"pointer",padding:0,background:"var(--dsw-alias-label-primary, #17202c)",color:"var(--dsw-alias-bg-layer-1, #fff)"},sendDisabled:{background:"var(--dsw-alias-border-default, #d8dee8)",color:"var(--dsw-alias-label-secondary, #536174)",cursor:"default"},sendQueued:{flex:"none",width:28,height:28,display:"grid",placeItems:"center",borderRadius:999,cursor:"pointer",padding:0,border:"1px dashed var(--dsw-alias-label-primary, #17202c)",background:"transparent",color:"var(--dsw-alias-label-primary, #17202c)"},queueBadge:{flex:"none",borderRadius:999,padding:"1px 8px",fontSize:11,lineHeight:"18px",background:"color-mix(in srgb, #946200 14%, transparent)",color:"#946200"},queueBubble:{maxWidth:"86%",padding:"9px 12px",borderRadius:12,lineHeight:1.7,whiteSpace:"pre-wrap",overflowWrap:"anywhere",border:"1px dashed color-mix(in srgb, currentColor 35%, transparent)",background:"color-mix(in srgb, currentColor 4%, transparent)",color:"var(--dsw-alias-label-secondary, #536174)"},queueRow:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",justifyContent:"flex-end"},queueHint:{fontSize:11,color:"var(--dsw-alias-label-secondary, #536174)"},queueCancel:{border:"none",background:"transparent",cursor:"pointer",padding:"2px 4px",borderRadius:6,color:"var(--dsw-alias-label-secondary, #536174)",display:"inline-flex",alignItems:"center",gap:3,font:"inherit",fontSize:11},queueNotice:{maxWidth:720,margin:"0 auto 6px",fontSize:12,color:"#946200",lineHeight:1.6},attach:{flex:"none",display:"flex",alignItems:"center",gap:6,padding:"3px 8px 3px 4px",borderRadius:8,background:"var(--dsw-alias-bg-layer-2, #f4f6fa)",fontSize:11,maxWidth:180},attachName:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},attachThumb:{width:20,height:20,borderRadius:4,objectFit:"cover",flex:"none"},attachRow:{display:"flex",flexWrap:"wrap",gap:6}},ae=t=>typeof t=="string"?t:"",Xt=t=>t("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},t("path",{d:"M12 19V5M5 12l7-7 7 7"})),Gt=t=>t("svg",{width:15,height:15,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round","aria-hidden":!0},t("path",{d:"M12 5v14M5 12h14"})),ht=t=>t("svg",{width:10,height:10,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round","aria-hidden":!0},t("path",{d:"M6 6l12 12M18 6L6 18"}));function mt({React:t,request:g,scope:d,onOpenComputer:r=null}={}){if(!t)return"\u4E2A\u4EBA\u52A9\u7406\u5BF9\u8BDD\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:n,useCallback:a,useEffect:s,useRef:o,useState:f}=t,[p,E]=f("loading"),[D,S]=f(""),[R,N]=f([]),[T,$]=f(""),[ee,v]=f([]),[ge,X]=f(""),[Y,O]=f([]),B=o(null),[W,L]=f(!1),[M,te]=f(!1),[Be,_e]=f(""),[ne,xe]=f([]),[we,q]=f(""),ie=o(0),G=o(new Map),z=o([]),ve=o(!1),K=o(null),Se=o(!1);Se.current=W;let P=o(!1);P.current=M;let de=o("loading");de.current=p;let he=o(0),C=o(!0),Ie=o(null),ue=o(!0),j=o("");j.current=T;let V=a(async(c,h={})=>{if(typeof g!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return g(c,h)},[g]),w=a(c=>{!Array.isArray(c)||c.length===0||v(h=>{let i=[...h];for(let u of c)if(!(!u||typeof u!="object")){if(u.type==="message"){let y=ae(u.id)||`local-${i.length}`,x=ae(u.role)||"assistant",k=ae(u.text),fe=i.findIndex(me=>me.id===y),F={id:y,role:x,text:k,done:u.done!==!1,clientTurnId:u.clientTurnId,status:"accepted"};if(fe>=0)i[fe]={...i[fe],...F};else if(x==="user"){let me=i.findIndex(Me=>Me.role==="user"&&u.clientTurnId&&Me.clientTurnId===u.clientTurnId);me>=0?i[me]={...F}:i.push(F)}else i.push(F)}else if(u.type==="delta"){let y=ae(u.id)||`local-${i.length}`,x=i.findIndex(k=>k.id===y);x>=0?i[x]={...i[x],text:i[x].text+ae(u.text)}:i.push({id:y,role:"assistant",text:ae(u.text),done:!1})}else if(u.type==="step"&&ae(u.text)){let y={id:ae(u.id),role:"step",text:ae(u.text),done:!0},x=i.findIndex(k=>k.id===y.id);x>=0?i[x]=y:i.push(y)}}return i})},[]),re=a(async c=>{if(!c)return;let h=j.current;if(h&&h!==c&&z.current.length>0){let u=z.current.length;z.current=[],xe([]),K.current&&(clearTimeout(K.current),K.current=null),q(`\u5DF2\u5207\u6362\u4F1A\u8BDD\uFF0C${u} \u6761\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001\uFF0C\u5DF2\u53D6\u6D88`)}else h&&h!==c&&q("");j.current=c;let i=++he.current;$(c),E("loading"),S(""),ie.current=0,ue.current=!0,v([]);try{let u=await V("personal-assistant.session.snapshot",{sessionId:c});if(!C.current||j.current!==c||i!==he.current)return;ie.current=Number(u?.cursor)||0;let y=Array.isArray(u?.messages)?u.messages:[];v(y.map((x,k)=>({id:ae(x?.id)||`history-${k}`,role:ae(x?.role)||"assistant",text:ae(x?.text),done:!0}))),te(u.turns?.some(x=>["queued","running"].includes(x.status))||!1),E("ready")}catch(u){if(!C.current||i!==he.current)return;E("error"),S(u?.message||"\u65E0\u6CD5\u8BFB\u53D6\u4F1A\u8BDD\u5185\u5BB9")}},[V]),ce=a(async()=>{if(E("loading"),S(""),!!C.current)try{let c=await V("personal-assistant.sessions.list");if(!C.current)return;let h=Array.isArray(c?.sessions)?c.sessions:[];if(N(h),h.length>0){await re(ae(h[0].sessionId));return}let i=await V("personal-assistant.session.create",{});if(!C.current)return;let u=ae(i?.sessionId);N(u?[{sessionId:u,title:ae(i?.title)||"\u65B0\u4F1A\u8BDD"}]:[]),await re(u)}catch(c){if(!C.current)return;E("error"),S(c?.message||"\u4F1A\u8BDD\u901A\u9053\u6682\u65F6\u4E0D\u53EF\u7528")}},[V,re]);s(()=>(C.current=!0,ce(),()=>{C.current=!1,K.current&&(clearTimeout(K.current),K.current=null)}),[ce]),s(()=>{if(p!=="ready"||!T)return;let c=!1,h=null,i=async()=>{try{let u=await V("personal-assistant.session.events",{sessionId:T,cursor:ie.current});if(c)return;if(ie.current=Number(u?.cursor??ie.current)||0,w(u?.events),Array.isArray(u.turns)){te(u.turns.some(F=>["queued","running"].includes(F.status)));let y=u.turns.findLast(F=>["queued","running"].includes(F.status)),x={cloud_computer:"\u64CD\u4F5C\u4E91\u7535\u8111",cloud_workspace:"\u5904\u7406\u4E91\u7AEF\u6587\u4EF6",cloud_bash:"\u6267\u884C\u4E91\u7AEF\u547D\u4EE4",cloud_run_code:"\u8FD0\u884C\u4E91\u7AEF\u4EE3\u7801",assistant_schedule:"\u8BBE\u7F6E\u4E91\u7AEF\u4EFB\u52A1"},k=y?.progress?.tool;_e(k?`${y.progress.state==="running"?"\u6B63\u5728":"\u5DF2\u5B8C\u6210"}${x[k]||(k.startsWith("cloud_browser_")?"\u64CD\u4F5C\u4E91\u7AEF\u6D4F\u89C8\u5668":"\u6267\u884C\u5DE5\u5177")}`:"");let fe=u.turns.filter(F=>["failed","interrupted","cancelled"].includes(F.status)&&!Kt.has(String(F.error||""))).map(F=>({type:"step",id:`turn-status-${F.turnId}`,text:`\u4EFB\u52A1${F.status==="failed"?"\u5931\u8D25":"\u5DF2\u4E2D\u65AD"}\uFF1A${Vt(F.error)}`}));w(fe)}S("")}catch(u){if(!c){if(u.code==="SESSION_CURSOR_STALE"){re(T);return}S(u.message||"\u4E91\u7AEF\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u6B63\u5728\u6062\u590D\uFF1B\u4EFB\u52A1\u4E0D\u4F1A\u6539\u5230\u672C\u673A\u6267\u884C")}}c||(h=setTimeout(i,600))};return h=setTimeout(i,200),()=>{c=!0,clearTimeout(h)}},[p,T,V,w,re]),s(()=>{let c=Ie.current;c&&ue.current&&(c.scrollTop=c.scrollHeight)},[ee,M]);let Fe=async c=>{let h=Array.from(c.target.files||[]);c.target.value="";let i=[];for(let u of h.slice(0,4)){if(!u||u.size>512*1024){S("\u6BCF\u4E2A\u9644\u4EF6\u6700\u591A 512 KiB\uFF0C\u8BF7\u5148\u538B\u7F29\u6216\u62C6\u5206\u6587\u4EF6");continue}let y=await new Promise(x=>{let k=new FileReader;k.onload=()=>x(String(k.result||"")),k.onerror=()=>x(""),k.readAsDataURL(u)});y&&i.push({id:`${Date.now()}-${u.name}`,name:u.name,mimeType:u.type||"application/octet-stream",size:u.size,dataUrl:y})}i.length&&O(u=>[...u,...i].slice(0,4))},be=c=>{z.current=c,xe(c)},Ce=()=>{K.current&&(clearTimeout(K.current),K.current=null)},oe=c=>Number(c?.status)===409||/SESSION_BUSY|active turn|正忙|处理中/u.test(`${c?.code||""} ${c?.message||""}`),Pe=async(c,{restoreDraft:h=!1}={})=>{G.current.set(c.clientTurnId,c),ue.current=!0,L(!0),S(""),te(!0),v(u=>u.some(y=>y.clientTurnId===c.clientTurnId)?u.map(y=>y.clientTurnId===c.clientTurnId?{...y,status:"pending"}:y):[...u,{id:`local-user-${c.clientTurnId}`,clientTurnId:c.clientTurnId,role:"user",text:c.text,done:!1,status:"pending"}]);let i=c;try{let u=Array.isArray(i.attachments)?i.attachments:[];if(u.length===0&&Array.isArray(i.uploads)&&i.uploads.length>0){let x=[];for(let k of i.uploads)x.push(await V("personal-assistant.file.upload",{sessionId:i.sessionId,name:k.name,dataUrl:k.dataUrl}));u=x.map(({path:k,name:fe,mediaType:F,bytes:me})=>({path:k,name:fe,mediaType:F,bytes:me})),i={...i,attachments:u,uploads:[]},G.current.set(i.clientTurnId,i)}let y=await V("personal-assistant.turn.submit",{sessionId:i.sessionId,text:i.text,clientTurnId:i.clientTurnId,attachments:u});return C.current?(G.current.delete(i.clientTurnId),v(x=>x.map(k=>k.clientTurnId===i.clientTurnId?{...k,status:"accepted",turnId:y.turnId}:k)),{ok:!0,item:i}):{ok:!0,item:i}}catch(u){return C.current?(te(oe(u)),h&&!oe(u)&&X(y=>y||i.text),v(y=>y.map(x=>x.clientTurnId===i.clientTurnId?{...x,status:"failed",failure:u.message||"\u53D1\u9001\u7ED3\u679C\u5F85\u786E\u8BA4\uFF0C\u91CD\u8BD5\u5C06\u590D\u7528\u539F\u6807\u8BC6"}:x)),{ok:!1,failure:u,item:i}):{ok:!1,failure:u,item:i}}finally{C.current&&L(!1)}},ye=(c,h)=>{let i=(c.attempts||0)+1;if(G.current.delete(c.clientTurnId),v(y=>y.filter(x=>x.clientTurnId!==c.clientTurnId)),i>Qt){q(`\u6392\u961F\u6D88\u606F\u591A\u6B21\u672A\u53D1\u51FA\uFF08${h?.message||"\u4E91\u7535\u8111\u4ECD\u5FD9"}\uFF09\uFF0C\u5DF2\u653E\u56DE\u8F93\u5165\u6846\uFF0C\u8BF7\u624B\u52A8\u91CD\u8BD5`),X(y=>y||c.text);return}be([{...c,attempts:i},...z.current]);let u=(yt*Math.min(i,3)/1e3).toFixed(1);q(`\u4E91\u7535\u8111\u4ECD\u5728\u5904\u7406\u4E0A\u4E00\u8F6E\uFF0C\u6D88\u606F\u5DF2\u6392\u961F\uFF0C\u7EA6 ${u} \u79D2\u540E\u81EA\u52A8\u91CD\u53D1`),Ce(),K.current=setTimeout(()=>{K.current=null,U(!0)},yt*Math.min(i,3))},U=async c=>{let h=j.current;if(ve.current||!C.current||de.current!=="ready"||!h||Se.current||!c&&P.current)return!1;let i=z.current[0];if(!i)return!1;if(i.sessionId!==h)return be([]),q("\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001"),!1;ve.current=!0,be(z.current.slice(1));try{let u=await Pe(i);return u.ok?!0:(oe(u.failure)?ye(u.item||i,u.failure):q(`\u6392\u961F\u6D88\u606F\u53D1\u9001\u5931\u8D25\uFF1A${u.failure?.message||"\u8BF7\u70B9\u51FB\u91CD\u8BD5"}`),!1)}finally{ve.current=!1}},pe=c=>{G.current.delete(c),be(z.current.filter(h=>h.clientTurnId!==c)),q("\u5DF2\u64A4\u56DE\u6392\u961F\u6D88\u606F")},De=async(c=null)=>{if(p!=="ready"||!T)return;if(c){W||Pe(c,{restoreDraft:!0});return}let h=ge.trim()||(Y.length?"\u8BF7\u67E5\u770B\u9644\u4EF6\u3002":"");if(!h)return;let i=Y.map(({name:y,mimeType:x,size:k,dataUrl:fe})=>({name:y,mimeType:x,size:k,dataUrl:fe}));if(W||M){be([...z.current,{clientTurnId:crypto.randomUUID(),text:h,sessionId:T,uploads:i,attempts:0,queuedAt:Date.now()}]),ue.current=!0,X(""),O([]),S(""),q("");return}X(""),O([]),S(""),q("");let u=await Pe({clientTurnId:crypto.randomUUID(),text:h,sessionId:T,uploads:i,attempts:0},{restoreDraft:!0});!u.ok&&oe(u.failure)&&ye(u.item,u.failure)};s(()=>{if(p!=="ready"||!T||W||M||ne.length===0)return;let c=setTimeout(()=>{U(!1)},Yt);return()=>clearTimeout(c)},[p,T,W,M,ne]),s(()=>{if(ne.length===0||typeof window>"u"||typeof window.addEventListener!="function")return;let c=h=>{h.preventDefault(),h.returnValue=""};return window.addEventListener("beforeunload",c),()=>window.removeEventListener("beforeunload",c)},[ne.length]);let ze=n("header",{style:I.header},n("h1",{style:I.title},"\u4E2A\u4EBA\u52A9\u7406"),n("span",{style:I.status},p==="ready"?"\u4E91\u7AEF\u5E38\u9A7B\uFF0C\u5173\u6389\u7A97\u53E3\u4E5F\u4F1A\u7EE7\u7EED":p==="loading"?"\u6B63\u5728\u8FDE\u63A5\u2026":"\u8FDE\u63A5\u4E0D\u53EF\u7528"),n("span",{style:I.spacer}),r?n("button",{type:"button",onClick:r,"aria-label":"\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",title:"\u6253\u5F00\u6216\u91CD\u65B0\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",style:{...I.ghost,display:"inline-flex",alignItems:"center",gap:6}},n("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,"aria-hidden":!0},n("rect",{x:3,y:4,width:18,height:13,rx:2}),n("path",{d:"M8 21h8M12 17v4"})),"\u4E91\u7535\u8111"):null);return n("section",{"data-personal-assistant-conversation":"true",style:I.page,onClick:async c=>{let h=c.target.closest?.('a[href^="cloud-file:"]');if(h){c.preventDefault();try{let i=await V("personal-assistant.file.download",{sessionId:T,path:decodeURIComponent(h.getAttribute("href").slice(11))}),u=Uint8Array.from(atob(i.data),k=>k.charCodeAt(0)),y=URL.createObjectURL(new Blob([u],{type:"application/octet-stream"})),x=document.createElement("a");x.href=y,x.download=i.name,x.click(),setTimeout(()=>URL.revokeObjectURL(y),1e3)}catch(i){S(i.message||"\u4E91\u7AEF\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}}}},ze,n("style",null,"@keyframes pa-awaiting { 0%, 100% { opacity: 0.35 } 50% { opacity: 1 } }"),D&&ee.length>0?n("div",{role:"alert",style:{padding:"8px 16px",background:"#fff0d6"}},D):null,n("div",{ref:Ie,"data-personal-assistant-messages":"true",style:I.scroller,onScroll:c=>{let h=c.currentTarget;ue.current=h.scrollHeight-h.clientHeight-h.scrollTop<64}},n("div",{style:I.thread},ee.length===0?n("div",{style:{...I.status,paddingTop:40,textAlign:"center"}},p==="error"?n("div",{style:{...I.centeredInner,margin:"0 auto"}},n("strong",null,"\u6682\u65F6\u8FDE\u4E0D\u4E0A\u4E2A\u4EBA\u52A9\u7406"),n("span",null,D||"\u8BF7\u7A0D\u540E\u91CD\u8BD5"),n("button",{style:I.ghost,onClick:()=>{ce()}},"\u91CD\u8BD5")):p==="loading"?"\u6B63\u5728\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406\u2026":qt):null,ee.map(c=>{if(c.role==="step")return n("div",{key:c.id,style:I.step},`\xB7 ${c.text}`);let h=c.role==="user";return n("div",{key:c.id,style:h?I.rowUser:I.row},n("span",{style:I.who},h?"\u4F60":"\u52A9\u7406"),n("div",{style:h?I.bubbleUser:I.bubble},h?c.text||"\u2026":gt(n,c.text||"",I)||"\u2026"),c.status==="failed"?n("button",{onClick:()=>{De(G.current.get(c.clientTurnId))},disabled:W},`${c.failure} \xB7 \u91CD\u8BD5\u53D1\u9001`):null)}),M?n("div",{key:"awaiting",style:I.row},n("span",{style:I.who},"\u52A9\u7406"),n("div",{style:{...I.bubble,color:"var(--dsw-alias-label-secondary, #536174)"}},n("span",{style:I.pulse},Be||"\u6B63\u5728\u5904\u7406\u2026"))):null,ne.map(c=>n("div",{key:`queued-${c.clientTurnId}`,style:I.rowUser},n("span",{style:I.who},"\u4F60 \xB7 \u6392\u961F\u4E2D"),n("div",{style:I.queueBubble},`${c.text}${c.uploads?.length?`\uFF08${c.uploads.length} \u4E2A\u9644\u4EF6\u5F85\u53D1\uFF09`:""}`),n("div",{style:I.queueRow},n("span",{style:I.queueHint},c.attempts?"\u4E91\u7535\u8111\u4ECD\u5728\u5904\u7406\u4E0A\u4E00\u8F6E\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u53D1":"\u5DF2\u6392\u961F\uFF0C\u672C\u8F6E\u7ED3\u675F\u540E\u53D1\u9001"),n("button",{type:"button","aria-label":`\u64A4\u56DE\u6392\u961F\u6D88\u606F\uFF1A${c.text.slice(0,24)}`,title:"\u64A4\u56DE\u8FD9\u6761\u6392\u961F\u6D88\u606F",style:I.queueCancel,onClick:()=>pe(c.clientTurnId)},ht(n),"\u64A4\u56DE")))))),n("div",{"data-personal-assistant-composer":"true",style:I.composer},we?n("div",{role:"status",style:I.queueNotice},we):null,n("div",{style:I.composerInner},Y.length>0?n("div",{style:I.attachRow},Y.map(c=>n("span",{key:c.id,style:I.attach},c.mimeType.startsWith("image/")?n("img",{src:c.dataUrl,alt:"",style:I.attachThumb}):null,n("span",{style:I.attachName},c.name),n("button",{"aria-label":`\u79FB\u9664 ${c.name}`,style:{...I.iconButton,width:16,height:16,border:"none"},onClick:()=>O(h=>h.filter(i=>i.id!==c.id))},ht(n))))):null,n("textarea",{"aria-label":"\u7ED9\u4E2A\u4EBA\u52A9\u7406\u53D1\u6D88\u606F",value:ge,rows:1,style:I.textarea,placeholder:p!=="ready"?"\u4E91\u7AEF\u6682\u672A\u8FDE\u63A5\uFF0C\u53EF\u5148\u5199\u4E0B\u6D88\u606F":W||M?"\u672C\u8F6E\u8FDB\u884C\u4E2D\uFF1A\u73B0\u5728\u53D1\u9001\u4F1A\u6392\u961F\uFF0C\u672C\u8F6E\u7ED3\u675F\u540E\u81EA\u52A8\u53D1\u51FA":"\u7ED9\u4E2A\u4EBA\u52A9\u7406\u53D1\u6D88\u606F\uFF0CEnter \u53D1\u9001\uFF0CShift+Enter \u6362\u884C",onChange:c=>X(c.target.value),onKeyDown:c=>{p==="ready"&&c.key==="Enter"&&!c.shiftKey&&!c.nativeEvent?.isComposing&&(c.preventDefault(),De())}}),n("div",{style:I.composerBar},n("button",{"aria-label":"\u6DFB\u52A0\u9644\u4EF6",style:I.iconButton,disabled:p!=="ready"||W,title:"\u4E0A\u4F20\u5230\u4E91\u7535\u8111\uFF1A\u6700\u591A 4 \u4E2A\u6587\u4EF6\uFF0C\u6BCF\u4E2A 512 KiB",onClick:()=>B.current?.click()},Gt(n)),n("input",{ref:B,type:"file",multiple:!0,accept:"image/*,.txt,.md,.json,.pdf",style:{display:"none"},onChange:Fe}),n("span",{style:I.spacer}),ne.length>0?n("span",{role:"status",style:I.queueBadge},`\u6392\u961F\u4E2D ${ne.length}`):null,n("button",{"aria-label":ne.length>0?`\u53D1\u9001\u6D88\u606F\uFF08\u6392\u961F\u4E2D ${ne.length} \u6761\uFF09`:"\u53D1\u9001\u6D88\u606F",title:W||M?"\u672C\u8F6E\u8FDB\u884C\u4E2D\uFF1A\u53D1\u9001\u540E\u4F1A\u6392\u961F\uFF0C\u672C\u8F6E\u7ED3\u675F\u540E\u81EA\u52A8\u53D1\u51FA":"\u53D1\u9001\u6D88\u606F",disabled:p!=="ready"||!ge.trim()&&Y.length===0,style:p!=="ready"||!ge.trim()&&Y.length===0?{...I.send,...I.sendDisabled}:W||M?I.sendQueued:I.send,onClick:()=>{De()}},Xt(n))))))}var xt="personal-assistant-computer",Zt="personal-assistant",wt="\u5F53\u524D Studio \u7684\u539F\u751F\u4FA7\u680F\u7EC4\u4EF6\u9700\u8981\u66F4\u65B0\uFF0C\u8BF7\u5B89\u88C5\u672C\u6B21\u968F\u63D2\u4EF6\u63D0\u4F9B\u7684\u5BBF\u4E3B\u7EC4\u4EF6\u5305\u3002",Jt=()=>Object.assign(new Error(wt),{code:"PERSONAL_ASSISTANT_NATIVE_SIDEBAR_REQUIRED"});function en(t){return t.workbench.render(t)}function vt({sidebarRight:t,slots:g,panelId:d=Zt}={}){let r=typeof t?.registerPanelSurface=="function"&&typeof t?.openPanelTab=="function"&&typeof t?.setPanelExpanded=="function"&&typeof g?.inject=="function"&&typeof g?.register=="function",n=new Set,a,s=!1,o=Object.freeze({binding:void 0}),f=()=>{o=Object.freeze({binding:a});for(let R of[...n])R()},p=()=>{if(!r)throw Jt();if(s)throw new Error("\u4E91\u7535\u8111\u5DE5\u4F5C\u9762\u677F\u5DF2\u5173\u95ED")},E,D,S={available:r,unavailableReason:r?null:wt,subscribe:R=>(n.add(R),()=>n.delete(R)),getSnapshot:()=>o,bind(R,N){if(p(),!R?.agentId||!R?.botId||typeof N!="function")throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");a&&(a.scope.agentId!==R.agentId||a.scope.botId!==R.botId)&&(E(),E=t.registerPanelSurface(d)),a=Object.freeze({scope:Object.freeze({...R}),request:N}),f(),S.open()},open(){p(),a&&t.openPanelTab(d,xt)},collapse(){p(),t.setPanelExpanded(d,!1)},dispose(){s||(s=!0,D?.(),E?.(),n.clear())}};return r&&(E=t.registerPanelSurface(d),D=g.inject("sidebar.right.panel.tab",()=>g.register({name:"sidebar.right.panel.tab",key:xt,inject:()=>({workbench:S})},en))),S}function St({React:t,workbench:g,Panel:d,active:r=!0,fullscreen:n=!1}){let{createElement:a,useSyncExternalStore:s}=t,o=s(g.subscribe,g.getSnapshot,g.getSnapshot);if(!r||!o.binding)return null;let{scope:f,request:p}=o.binding;return a(d,{key:`${f.agentId}:${f.botId}:${f.sessionId||""}`,request:p,initialBotId:f.botId,initialSessionId:f.sessionId,agentId:f.agentId,variant:"native-tab",active:r,nativeFullscreen:n})}var tn="__directory__";function Ze(t){if(!Array.isArray(t)||t.length>128)throw new TypeError("\u52A9\u7406\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");let g=new Set;return t.map(d=>{let r=String(d?.botId||"").trim(),n=String(d?.displayName||r).trim();if(!r||r.length>64||/[\u0000-\u001f]/u.test(r)||r===tn||g.has(r)||!n||n.length>256)throw new TypeError("\u52A9\u7406\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");return g.add(r),{botId:r,displayName:r==="default"&&n==="Personal Assistant"?"\u9ED8\u8BA4\u52A9\u7406":r==="researcher"&&n==="Researcher"?"\u7814\u7A76\u52A9\u7406":n}})}function Je(t,g=""){let d=Ze(t),r=String(g||"").trim(),n=r?d.find(a=>a.botId===r):d.find(a=>a.botId==="default")||(d.length===1?d[0]:void 0);if(!n)throw Object.assign(new Error("\u4E91\u7AEF\u52A9\u7406\u7ED1\u5B9A\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),{code:"PERSONAL_ASSISTANT_BINDING_UNAVAILABLE"});return n.botId}var tt=class extends Error{constructor(){super("Personal Assistant gateway is not connected"),this.name="PersonalAssistantGatewayUnavailableError",this.code="PERSONAL_ASSISTANT_GATEWAY_UNAVAILABLE"}};var At=Object.freeze(["slots","connection","sidebarRight"]),et="personal-assistant",xn=Object.freeze({enabled:!1,autoConnect:!1}),Ve="personal-assistant-computer",je="2026-10-28T07:36:38.478Z",It=12e3,Ne;function Rt(t){Ne=t}var H={background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #17202c)",border:"1px solid var(--dsw-alias-border-default, #d8dee8)"},Et=t=>typeof t?.message=="string"&&t.message&&!/^(fetch failed|Failed to fetch)$/u.test(t.message)?t.message.slice(0,180):"\u4E91\u7535\u8111\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",Tt=t=>t?.code==="PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE"&&Number(t?.status)===409?"\u5F53\u524D\u4E91\u7AEF\u7248\u672C\u5C1A\u4E0D\u652F\u6301\u52A9\u7406\u5217\u8868\uFF0C\u8BF7\u66F4\u65B0\u4E91\u7AEF\u52A9\u7406\u540E\u91CD\u8BD5":"\u8FDE\u63A5\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",nn=t=>Number(t?.status)===409&&["PERSONAL_ASSISTANT_DIRECTORY_UNSUPPORTED","PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE"].includes(t?.code),rn={Control:"Control_L",Meta:"Super_L",Alt:"Alt_L",Shift:"Shift_L",Enter:"Return",Escape:"Escape",Tab:"Tab",Backspace:"BackSpace",Delete:"Delete",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right"," ":"space"};function kt({request:t,initialBotId:g="",openInSidebar:d=null,variant:r="page",nativeFullscreen:n=!1}={}){let a=Ne||globalThis.React;if(!a)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:s,useEffect:o,useRef:f,useState:p}=a,[E,D]=p(null),[S,R]=p([]),[N,T]=p(""),[$,ee]=p(null),[v,ge]=p(!1),[X,Y]=p(g),[O,B]=p("loading"),[W,L]=p(""),[M,te]=p(!0),[Be,_e]=p(0),[ne,xe]=p(0),[we,q]=p("observe"),[ie,G]=p(null),[z,ve]=p(""),[K,Se]=p(""),P=f(null),de=f(null),he=f(null),C=f(null),Ie=f(null),ue=f(null),j=f(null),V=f(n);V.current=n;let w=f({mounted:!0,socket:null,generation:0,frameEpoch:0,session:null,suspended:!1,resuming:!1,pendingInputs:[],display:{width:1280,height:800},readOnly:!0,botId:X,config:null,reconnect:null,firstFrame:null,receivedSeq:-1,pendingFrame:null,decoding:!1,frames:0,lastMove:0,pressed:new Set,buttons:new Set,composition:!1,retries:0,taskId:"",mode:"control",frameMetadata:null,reconnectAllowed:!1});w.current.botId=X;let re=async(e,l={})=>{if(typeof t!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return t(e,l)},ce=e=>{let l=w.current;return l.socket?.readyState!==1?!1:(l.socket.send(JSON.stringify(e)),!0)},Fe=()=>{let e=w.current;for(let l of e.pressed)P.current?.input({type:"key",action:"up",key:l});for(let l of e.buttons)P.current?.input({type:"button",action:"up",button:l});e.pressed.clear(),e.buttons.clear()},be=()=>{for(let e of w.current.buttons)P.current?.input({type:"button",action:"up",button:e});w.current.buttons.clear()};P.current||(P.current=st({send:ce,changed:e=>{let l=w.current;l.controlPhase=e.phase,l.readOnly=e.readOnly,l.controlEpoch=e.controlEpoch,e.readOnly&&j.current&&(j.current.style.visibility="hidden"),e.phase==="observe"&&(l.pressed.clear(),l.buttons.clear()),l.mounted&&(te(e.readOnly),q(e.phase))},failed:e=>{w.current.mounted&&L(e)}})),de.current||(de.current=it({send:ce,controlEpoch:()=>P.current?.snapshot?.controlEpoch}));let Ce=()=>{Fe(),P.current.release(),w.current.pressed.clear(),w.current.buttons.clear()},oe=()=>{let e=w.current;e.pointerFrame&&cancelAnimationFrame(e.pointerFrame),e.pointerFrame=null;let l=e.lastPointer;e.lastPointer=null,l&&(!e.readOnly||e.controlPhase==="acquiring")&&(!e.sentPointer||l.x!==e.sentPointer.x||l.y!==e.sentPointer.y)&&(P.current.input({type:"pointermove",...l}),e.sentPointer=l)},Pe=()=>{clearTimeout(w.current.reconnect),clearTimeout(w.current.firstFrame),w.current.reconnect=null,w.current.firstFrame=null},ye=(e=!0)=>{let l=w.current;l.reconnectAllowed=!1,Pe(),Ce(),l.generation+=1,de.current?.rejectAll();try{ce({type:"close"}),l.socket?.close(1e3,"panel closed")}catch{}P.current.reset({readOnly:!0}),l.lastDrawnFrame=null,l.socket=null,l.session=null,l.pendingFrame=null,l.frameMetadata=null,l.readOnly=!0,Ie.current?.blur(),l.suspended=!1,l.resuming=!1,l.pendingInputs=[],l.frameEpoch++,e&&l.mounted&&(B(l.config?.configured?"idle":"unconfigured"),te(!0))},U=e=>{ye(!1),te(!0),B("closed"),L(e?.reason==="lease-lost"||Number(e?.status)===409?"\u63A7\u5236\u79DF\u7EA6\u5DF2\u5931\u6548\uFF0C\u684C\u9762\u8FDE\u63A5\u5DF2\u5173\u95ED\uFF1B\u8BF7\u91CD\u65B0\u8FDE\u63A5\u6216\u9009\u62E9\u53EA\u8BFB\u65C1\u89C2":e?.code==="DESKTOP_SESSION_NOT_FOUND"||Number(e?.status)===404?"\u684C\u9762\u4F1A\u8BDD\u5DF2\u7ED3\u675F\uFF08\u53EF\u80FD\u56E0\u7A7A\u95F2\u8D85\u65F6\uFF09\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5":"\u684C\u9762\u8FDE\u63A5\u5DF2\u7ED3\u675F\uFF0C\u53EF\u91CD\u65B0\u8FDE\u63A5\u4E91\u7535\u8111")},pe=e=>{let l=w.current;if(e.type!=="pointermove"&&oe(),l.suspended||l.resuming){if(e.type==="pointermove")return!1;let A=l.mode==="control";if(A){if(l.pendingInputs.length>=32)return ye(),L("\u6062\u590D\u671F\u95F4\u8F93\u5165\u8FC7\u5FEB\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5"),!1;l.pendingInputs.push(e)}return l.resuming||y(),A}return!l.session||l.socket?.readyState!==1?(L("\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8F93\u5165\u672A\u53D1\u9001"),!1):P.current.input(e)},De=e=>{w.current.mounted&&(Se(e),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{w.current.mounted&&Se("")},4e3))},ze=e=>{let l=!1;for(let A of e)l=pe(A)||l;return l},c=async()=>{let e=/Mac|iPhone|iPad/u.test(String(globalThis.navigator?.platform||""))?"Meta":"Control";if(!w.current.pressed.has("_copyShortcut")){w.current.pressed.add("_copyShortcut");try{ze([{type:"key",action:"down",key:e},{type:"key",action:"down",key:"c"},{type:"key",action:"up",key:"c"},{type:"key",action:"up",key:e}]),await new Promise(l=>setTimeout(l,150))}finally{w.current.pressed.delete("_copyShortcut")}}return ut({readCloud:()=>de.current.read(),notify:De})},h=()=>dt({readLocal:()=>Xe(),writeCloud:e=>de.current.write(e),sendKeys:ze,notify:De}),i=async()=>{let e=w.current;if(!e.decoding){e.decoding=!0;try{for(;e.pendingFrame;){let l=e.pendingFrame;e.pendingFrame=null;let A;try{if(A=await createImageBitmap(new Blob([l.bytes],{type:"image/jpeg"})),!e.mounted||e.suspended||l.frameEpoch!==e.frameEpoch||l.generation!==e.generation||l.seq<e.receivedSeq||!C.current)continue;e.lastDrawnFrame=l;let b=C.current,J=b.getBoundingClientRect(),le=Math.max(1,globalThis.devicePixelRatio||1);b.width=Math.max(1,Math.round(J.width*le)),b.height=Math.max(1,Math.round(J.height*le));let Q=b.getContext("2d"),se=e.display,Le=Math.min(b.width/se.width,b.height/se.height),ke=se.width*Le,_=se.height*Le;Q.clearRect(0,0,b.width,b.height),Q.drawImage(A,(b.width-ke)/2,(b.height-_)/2,ke,_);let Ae=e.firstFrame!==null;e.frames+=1,clearTimeout(e.firstFrame),e.firstFrame=null,e.retries=0,Ae&&L(""),B(e.readOnly?"readonly":"ready"),_e(0)}catch{e.mounted&&L("\u684C\u9762\u5E27\u65E0\u6CD5\u89E3\u7801\uFF0C\u8BF7\u91CD\u8BD5")}finally{A?.close()}}}finally{e.decoding=!1}}},u=e=>{let l=w.current;clearTimeout(l.firstFrame),l.firstFrame=null,l.suspended=!0,l.resuming=!1,l.readOnly=!0,l.pendingInputs=[],l.frameEpoch++,l.pendingFrame=null,l.frameMetadata=null,l.pressed.clear(),l.buttons.clear(),l.frames=0,xe(0),te(!0),B("dormant"),L(e?.leaseReleased===!1?"\u5DF2\u7A7A\u95F2\uFF0C\u753B\u9762\u5DF2\u6682\u505C\uFF1B\u63A7\u5236\u6743\u4ECD\u7531\u5916\u90E8\u4EFB\u52A1\u7BA1\u7406":"\u5DF2\u7A7A\u95F2\uFF0C\u63A7\u5236\u6743\u5DF2\u91CA\u653E\uFF1B\u64CD\u4F5C\u684C\u9762\u5373\u53EF\u6062\u590D")},y=()=>{let e=w.current;if(e.resuming||!e.suspended)return;if(e.socket?.readyState!==1){x(e.mode,!1,e.pendingInputs);return}e.resuming=!0,B("resuming"),L("\u6B63\u5728\u6062\u590D\u684C\u9762\u5E76\u68C0\u67E5\u63A7\u5236\u6743\uFF0C\u8BF7\u7A0D\u5019\u3002"),ce({type:"resume",mode:e.mode,activity:!0});let l=e.generation,A=e.socket;e.firstFrame=setTimeout(()=>{e.mounted&&e.generation===l&&e.firstFrame!==null&&A.close(4e3,"resume frame timeout")},It)},x=async(e="read",l=!1,A=[])=>{let b=w.current,J=String(b.botId||"").trim();if(!b.config?.configured){B("unconfigured");return}if(!J||!b.bots?.some(Q=>Q.botId===J)){L("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");return}ye(!1),b.pendingInputs=A,b.resuming=A.length>0;let le=++b.generation;b.reconnectAllowed=!0,l||(b.retries=0),b.mode=e,b.taskId||=`studio-desktop-${globalThis.crypto.randomUUID()}`,b.receivedSeq=-1,b.frameMetadata=null,B(l?"reconnecting":"connecting"),L("\u9996\u6B21\u6216\u4F11\u7720\u540E\u8FDE\u63A5\u53EF\u80FD\u9700\u8981\u6570\u79D2\uFF0C\u8BF7\u7A0D\u5019\u3002");try{let Q=await re("personal-assistant.desktop.ticket",{agentId:b.config.agentId,botId:J,mode:e==="observe"?"control":e});if(!b.mounted||le!==b.generation)return;let se=new WebSocket(Q.wsUrl,["agentkit.personal-assistant.desktop.v1",`agentkit.desktop.ticket.${Q.ticket}`]);se.binaryType="arraybuffer",b.socket=se;let Le=()=>b.mounted&&b.generation===le;se.onopen=()=>{if(!Le()){se.close();return}ce({type:"open",botId:J,taskId:b.taskId,mode:e,...Q.leaseId?{leaseId:Q.leaseId}:{}}),b.firstFrame=setTimeout(()=>{Le()&&(L("\u4E91\u7535\u8111\u54CD\u5E94\u8F83\u6162\uFF0C\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5"),se.close(4e3,"first frame timeout"))},It)},se.onmessage=ke=>{if(!Le())return;if(typeof ke.data!="string"){let Ae=b.frameMetadata;b.frameMetadata=null;let Ue=ke.data;if(!Ae||!Number.isSafeInteger(Ae.seq)||Ae.seq<=b.receivedSeq||!(Ue instanceof ArrayBuffer)||Ue.byteLength===0||Ue.byteLength>307200||b.suspended)return;b.receivedSeq=Ae.seq,b.pendingFrame={bytes:Ue,seq:Ae.seq,generation:le,frameEpoch:b.frameEpoch},i();return}let _;try{_=JSON.parse(ke.data)}catch{return}if(_.type==="ready"){b.suspended=!1,b.resuming=!1,b.receivedSeq=-1,b.session=_.sessionId,b.readOnly=!!_.readOnly,b.display=Qe(_.display),b.mode=e,P.current.reset(_);let Ae=b.pendingInputs;if(b.pendingInputs=[],b.readOnly)b.pressed.clear(),b.buttons.clear();else for(let Ue of Ae)P.current.input(Ue);te(b.readOnly),L("\u4E91\u7535\u8111\u5DF2\u8FDE\u63A5\uFF0C\u6B63\u5728\u51C6\u5907\u684C\u9762\u753B\u9762");return}if(_.type==="control"){P.current.accept(_),L("");return}if(_.type==="idle"){u(_);return}if(_.type==="frame"){_.unchanged||(b.frameMetadata=_);return}if(_.type==="clipboard.response"){de.current?.accept(_);return}if(_.type==="closed"){_.retryable!==!0&&U(_);return}if(_.type==="error"){if(Number.isSafeInteger(_.controlEpoch)&&_.controlEpoch<b.controlEpoch)return;if(L(_.message||_.code||"\u4E91\u7535\u8111\u8BF7\u6C42\u5931\u8D25"),b.handoffSupported&&_.recoverable===!0){P.current.reject(_);return}if(_.recoverable===!0&&Number(_.status)===409){_.code==="DESKTOP_SESSION_IDLE"?u():(b.pendingInputs=[],b.readOnly=!0,b.pressed.clear(),b.buttons.clear(),te(!0),B("readonly"));return}if(Number(_.status)===409&&e==="control"&&!b.session){x(w.current.handoffSupported?"observe":"read");return}[404,409].includes(Number(_.status))||_.code==="DESKTOP_SESSION_NOT_FOUND"?U(_):b.session||(B("error"),ye(!1))}},se.onerror=()=>{Le()&&L("\u684C\u9762\u901A\u9053\u6682\u65F6\u65AD\u5F00\uFF0C\u6B63\u5728\u91CD\u8FDE")},se.onclose=ke=>{if(!Le())return;if(b.suspended&&ke.code!==1e3){clearTimeout(b.firstFrame),b.firstFrame=null,b.socket=null,B("dormant");return}if(b.session=null,clearTimeout(b.firstFrame),b.firstFrame=null,!b.reconnectAllowed||ke.code===1e3){U();return}if(document.hidden){B("hidden");return}let _=++b.retries;if(_e(_),_>5){b.reconnectAllowed=!1,B("error"),L("\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7535\u8111\uFF0C\u8BF7\u68C0\u67E5\u5B9E\u4F8B\u72B6\u6001\u6216\u7F51\u7EDC\u540E\u91CD\u8BD5");return}B("reconnecting"),b.reconnect=setTimeout(()=>{x(e,!0,b.pendingInputs)},Math.min(8e3,1e3*2**(_-1)))}}catch(Q){b.mounted&&le===b.generation&&(B("error"),L(Tt(Q)))}},k=async e=>{if(e?.aborted)return null;try{let l=await re("personal-assistant.desktop.status");return l&&typeof l=="object"?l:null}catch(l){return l?.code==="PERSONAL_ASSISTANT_OPERATION_UNAVAILABLE"||l?.status===404?null:{configured:!1,reason:"unavailable",detail:Et(l),candidates:[]}}},fe=async e=>{if(!z){ve(e),L(e==="create"?"\u6B63\u5728\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406\uFF0C\u53EF\u80FD\u9700\u8981\u51E0\u5206\u949F\u2026":"\u6B63\u5728\u83B7\u53D6\u4E91\u7AEF\u8FDE\u63A5\u51ED\u8BC1\u2026");try{await re(`personal-assistant.desktop.${e}`),L(""),await F()}catch(l){L(Et(l)),G(await k().catch(()=>null))}finally{ve("")}}},F=async(e,l=!1)=>{ye(!1),B("loading"),L(""),T(""),ee(null);try{let A=await re("personal-assistant.configuration");if(e?.aborted||!w.current.mounted)return;if(w.current.config=A,D(A),!A.configured){let Q=await k(e);if(e?.aborted||!w.current.mounted)return;if(w.current.bots=[],R([]),Y(""),G(Q),B("unconfigured"),Q?.configured&&!l){await F(e,!0);return}return}G(null);let b=await re("personal-assistant.bots.list");if(e?.aborted||!w.current.mounted)return;if(b.directoryAvailable!==!0)throw Object.assign(new Error("directory unavailable"),{code:"PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE",status:409});let J=Ze(b.bots);w.current.bots=J,w.current.handoffSupported=b.features?.includes("desktop-handoff/v1")===!0,R(J);let le=J.length?Je(J,g||A.botId):"";w.current.botId=le,Y(le),B(J.length?"idle":"empty"),le&&["computer","native-tab"].includes(r)&&x(w.current.handoffSupported?"observe":"read")}catch(A){if(e?.aborted||!w.current.mounted)return;Number.isInteger(A?.closeCode)&&A.closeCode>=1e3&&A.closeCode<=4999&&ee(A.closeCode),w.current.bots=[],R([]),Y(""),B("directory-error"),T(nn(A)?"\u4E91\u7AEF\u52A9\u7406\u9700\u8981\u66F4\u65B0\uFF0C\u8BF7\u66F4\u65B0\u540E\u91CD\u65B0\u8FDE\u63A5\u3002":Tt(A))}};o(()=>{let e=w.current;e.mounted=!0;let l=new AbortController;F(l.signal);let A=setInterval(()=>{e.mounted&&xe(e.frames),e.frames=0},1e3),b=()=>{document.hidden?(Ce(),ce({type:"pause"})):e.socket?.readyState===1?ce({type:"resume"}):e.reconnectAllowed&&e.config?.configured&&e.session===null&&e.socket&&x(e.mode,!0)},J=typeof ResizeObserver=="function"?new ResizeObserver(()=>{e.lastDrawnFrame&&(e.pendingFrame=e.lastDrawnFrame,i())}):null;C.current&&J?.observe(C.current);let le=()=>Ce(),Q=se=>{ue.current?.contains(se.target)||Ce()};return document.addEventListener("visibilitychange",b),window.addEventListener("blur",le),document.addEventListener("pointerdown",Q,!0),()=>{e.mounted=!1,J?.disconnect(),e.pointerFrame&&cancelAnimationFrame(e.pointerFrame),l.abort(),ye(!1),clearInterval(A),document.removeEventListener("visibilitychange",b),window.removeEventListener("blur",le),document.removeEventListener("pointerdown",Q,!0)}},[t]);let me=e=>ot({clientX:e.clientX,clientY:e.clientY,rect:C.current.getBoundingClientRect(),display:w.current.display}),Me=e=>{e.preventDefault();let l=w.current,A=[1,2,3][e.button]||1;e.type==="pointerdown"?(Ie.current?.focus(),C.current?.setPointerCapture(e.pointerId),pe({type:"button",action:"down",button:A,...me(e)})&&l.buttons.add(A)):(pe({type:"button",action:"up",button:A,...me(e)}),l.buttons.delete(A),C.current?.hasPointerCapture(e.pointerId)&&C.current.releasePointerCapture(e.pointerId))},We=e=>{if(w.current.composition||e.isComposing||e.nativeEvent?.isComposing||e.key==="Process"||e.key==="Unidentified")return;if(lt(e)){e.preventDefault(),h();return}if(ct(e)){e.preventDefault(),e.type==="keydown"&&!e.repeat&&c();return}let l=e.ctrlKey||e.metaKey||e.altKey;if(e.key.length===1&&!l||e.key==="Escape"&&V.current)return;e.preventDefault();let A=rn[e.key]||e.key;/^[A-Za-z0-9_]+$/u.test(A)&&(e.type==="keydown"?!e.repeat&&pe({type:"key",action:"down",key:A})&&w.current.pressed.add(A):(pe({type:"key",action:"up",key:A}),w.current.pressed.delete(A)))},Ye={loading:"\u6B63\u5728\u68C0\u67E5\u52A9\u7406\u72B6\u6001",idle:"\u51C6\u5907\u8FDE\u63A5",dormant:"\u5DF2\u7A7A\u95F2",resuming:"\u6B63\u5728\u6062\u590D\u684C\u9762",unconfigured:"\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A",empty:"\u6682\u65F6\u6CA1\u6709\u53EF\u7528\u52A9\u7406","directory-error":"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u52A9\u7406\u5217\u8868",connecting:"\u6B63\u5728\u542F\u52A8\u4E91\u7535\u8111",readonly:"\u53EA\u8BFB\u65C1\u89C2",ready:"\u6B63\u5728\u63A7\u5236\u4E91\u7535\u8111",reconnecting:"\u6B63\u5728\u6062\u590D\u8FDE\u63A5",hidden:"\u753B\u9762\u5DF2\u6682\u505C",closed:"\u684C\u9762\u8FDE\u63A5\u5DF2\u7ED3\u675F",error:"\u8FDE\u63A5\u6682\u65F6\u4E0D\u53EF\u7528"}[O],Ee={...H,borderRadius:6,padding:"7px 12px",cursor:"pointer",font:"inherit"},Z=["ready","readonly","hidden","reconnecting","dormant","resuming"].includes(O),Oe=S.length>0,Te=ie?.reason||"",Ct=Array.isArray(ie?.candidates)?ie.candidates.length:0,Dt=Te==="needs-create"?"\u8FD8\u6CA1\u6709\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406":Te==="credential-unavailable"?"\u6B63\u5728\u6062\u590D\u4E2A\u4EBA\u52A9\u7406\u7684\u8FDE\u63A5\u51ED\u8BC1":Te==="unavailable"?"\u6682\u65F6\u65E0\u6CD5\u81EA\u52A8\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406":"\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A",Ot=Te==="needs-create"?"\u4E91\u8D26\u53F7\u4E0B\u8FD8\u6CA1\u6709\u4E2A\u4EBA\u52A9\u7406\u5B9E\u4F8B\uFF0C\u521B\u5EFA\u540E\u5373\u53EF\u5728\u8FD9\u91CC\u8FDE\u63A5\u4E13\u5C5E\u4E91\u7535\u8111\u3002":Te==="credential-unavailable"?"\u4E91\u7AEF\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u8FDE\u63A5\u51ED\u8BC1\uFF0C\u53EF\u4EE5\u91CD\u65B0\u83B7\u53D6\u3002":Te==="unavailable"?ie?.detail||"\u8BF7\u68C0\u67E5\u4E91\u7AEF\u767B\u5F55\u72B6\u6001\u540E\u91CD\u8BD5\u3002":"\u5F00\u901A\u5B8C\u6210\u540E\uFF0C\u5373\u53EF\u5728\u8FD9\u91CC\u8FDE\u63A5\u4E13\u5C5E\u4E91\u7535\u8111\u3002",Lt=O==="unconfigured"?Dt:O==="empty"?"\u52A9\u7406\u6B63\u5728\u51C6\u5907\u4E2D":O==="directory-error"?"\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406":"\u6B63\u5728\u68C0\u67E5\u52A9\u7406\u72B6\u6001",Nt=O==="unconfigured"?Ot:O==="empty"?"\u4E91\u7AEF\u521D\u59CB\u5316\u5B8C\u6210\u540E\uFF0C\u53EF\u7528\u52A9\u7406\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002":O==="directory-error"?N:"\u8BF7\u7A0D\u5019",He=r==="computer"||r==="native-tab",nt=s("div",{ref:ue,"data-personal-assistant-desktop-card":He?"true":void 0,style:{position:"relative",background:"var(--dsw-alias-bg-layer-2, #f1f3f6)",...He?{width:"100%",aspectRatio:`${w.current.display.width} / ${w.current.display.height}`,flex:"none",minWidth:0,borderRadius:14,overflow:"hidden",boxShadow:"0 0 0 1px var(--dsw-alias-border-default, #d8dee8), 0 8px 28px #1018280d"}:{flex:1,minHeight:240}}},["dormant","resuming"].includes(O)?s("div",{role:"status",style:{position:"absolute",inset:0,zIndex:1,pointerEvents:"none",display:"grid",placeItems:"center",padding:16,textAlign:"center",background:"color-mix(in srgb, var(--dsw-alias-bg-layer-1, #fff) 82%, transparent)",color:"var(--dsw-alias-label-primary, #17202c)"}},O==="dormant"?"\u5DF2\u7A7A\u95F2\uFF0C\u64CD\u4F5C\u684C\u9762\u5373\u53EF\u6062\u590D":"\u6B63\u5728\u6062\u590D\u684C\u9762\u2026"):null,s("canvas",{ref:C,"aria-label":"\u4E91\u7535\u8111\u684C\u9762",tabIndex:Z?0:-1,onPointerDown:Me,onPointerUp:Me,onPointerCancel:be,onLostPointerCapture:be,onPointerLeave:()=>{j.current&&(j.current.style.visibility="hidden")},onPointerMove:e=>{let l=w.current,A=e.nativeEvent?.getCoalescedEvents?.().at(-1)||e;if(j.current){let b=C.current.getBoundingClientRect();j.current.style.transform=`translate(${A.clientX-b.left}px, ${A.clientY-b.top}px)`,j.current.style.visibility=l.readOnly?"hidden":"visible"}l.lastPointer=me(A),l.pointerFrame||(l.pointerFrame=requestAnimationFrame(()=>{l.mounted&&oe()}))},onContextMenu:e=>e.preventDefault(),onWheel:e=>{e.preventDefault(),pe({type:"wheel",deltaY:e.deltaY/100,deltaX:e.deltaX/100})},onKeyDown:We,onKeyUp:We,style:{...He?{position:"absolute",inset:0}:{},width:"100%",height:"100%",display:"block",visibility:Z?"visible":"hidden",pointerEvents:Z?"auto":"none",touchAction:"none",cursor:M?"default":"none"}}),s("div",{ref:j,"aria-hidden":!0,style:{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",zIndex:2,width:18,height:22}},s("svg",{viewBox:"0 0 18 22",width:18,height:22},s("path",{d:"M1 1v16l4-4 3 7 3-1-3-7h6z",fill:"#fff",stroke:"#162033",strokeWidth:1.2}))),Z?null:s("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,padding:16,textAlign:"center"}},s("h2",{style:{margin:0,fontSize:18,fontWeight:500}},Oe?Ye:Lt),s("p",{style:{margin:0,maxWidth:380,lineHeight:1.7,color:"var(--dsw-alias-label-secondary, #536174)"}},Oe?W||"\u8FDE\u63A5\u540E\u5373\u53EF\u4F7F\u7528\u4E91\u7AEF\u684C\u9762\uFF0C\u5173\u95ED\u9762\u677F\u4F1A\u91CA\u653E\u672C\u6B21\u63A7\u5236\u3002":Nt),!Oe&&O!=="loading"?s("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",alignItems:"center"}},O==="unconfigured"&&Te==="needs-create"?s("button",{style:Ee,disabled:!!z,onClick:()=>{fe("create")}},z==="create"?"\u6B63\u5728\u521B\u5EFA\u2026":"\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406"):null,O==="unconfigured"&&(Te==="credential-unavailable"||Ct>0)?s("button",{style:Ee,disabled:!!z,onClick:()=>{fe("connect")}},z==="connect"?"\u6B63\u5728\u83B7\u53D6\u2026":Te==="credential-unavailable"?"\u91CD\u65B0\u83B7\u53D6\u8FDE\u63A5\u51ED\u8BC1":"\u8FDE\u63A5\u5DF2\u53D1\u73B0\u7684\u4E2A\u4EBA\u52A9\u7406"):null,s("button",{style:{...Ee,background:"transparent"},disabled:!!z,onClick:()=>{F()}},"\u68C0\u67E5\u5F00\u901A\u72B6\u6001"),z?s("span",{role:"status",style:{color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12}},"\u5904\u7406\u4E2D\uFF0C\u8BF7\u7A0D\u5019\u2026"):null):null),s("input",{ref:Ie,"aria-label":"\u4E91\u7535\u8111\u6587\u672C\u8F93\u5165",autoComplete:"off",disabled:!Z||M&&!P.current.snapshot.available&&!(w.current.mode==="control"&&["dormant","resuming"].includes(O)),tabIndex:-1,style:{position:"absolute",width:1,height:1,opacity:0,left:0,top:0},onKeyDown:We,onKeyUp:We,onCompositionStart:()=>{w.current.composition=!0},onCompositionEnd:e=>{w.current.composition=!1;let l=e.currentTarget.value;e.currentTarget.value="",l&&pe({type:"text",text:l})},onInput:e=>{if(w.current.composition||e.nativeEvent?.isComposing)return;let l=e.currentTarget.value;e.currentTarget.value="",l&&pe({type:"text",text:l})}})),$e="var(--dsw-alias-label-secondary, #536174)",dn={...Ee,background:"transparent",color:"inherit",border:H.border},rt={...Ee,borderRadius:999,padding:"7px 16px",border:"none",fontWeight:500,background:"var(--dsw-alias-label-primary, #17202c)",color:"var(--dsw-alias-bg-layer-1, #fff)"};return He?s("section",{"data-personal-assistant-computer":"true",style:{...H,border:"none",height:"100%",minHeight:0,minWidth:0,display:"flex",flexDirection:"column",background:"var(--dsw-alias-bg-base, #fff)",color:"inherit",fontSize:13}},r!=="native-tab"?s("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:H.border}},s("strong",{style:{fontWeight:500}},"\u4E91\u7535\u8111"),s("span",{role:"status","aria-live":"polite",style:{color:$e,fontSize:12}},Ye),null):null,M&&Z&&!P.current.snapshot.available?s("div",{role:"alert",style:{background:"#fff0d6",color:"#763c00",padding:"8px 12px"}},"\u53EA\u8BFB\u65C1\u89C2\uFF1A\u9F20\u6807\u548C\u952E\u76D8\u4E0D\u4F1A\u53D1\u9001\u5230\u4E91\u7535\u8111"):null,s("div",{"data-personal-assistant-desktop-layout":"true",style:{flex:1,minHeight:0,minWidth:0,overflow:"auto",display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:"20px 16px 12px",boxSizing:"border-box"}},s("div",{"data-personal-assistant-desktop-stack":"true",style:{width:"100%",maxWidth:1280,margin:"auto 0",display:"flex",flexDirection:"column",alignItems:"center",gap:12,flex:"none"}},nt,Z||Oe?s("div",{"data-personal-assistant-control-capsule":"true",role:"status","aria-live":"polite",style:{display:"flex",flexWrap:"wrap",justifyContent:"center",alignItems:"center",gap:6,width:"fit-content",maxWidth:"100%",boxSizing:"border-box",padding:"7px 12px",borderRadius:999,background:"var(--dsw-alias-bg-layer-1, #fff)",border:H.border,boxShadow:"0 1px 4px #10182808",lineHeight:1.5}},!Z&&Oe?s("button",{style:rt,disabled:["connecting","resuming"].includes(O),onClick:()=>{x(w.current.handoffSupported?"observe":"read")}},O==="connecting"?"\u6B63\u5728\u542F\u52A8\u2026":"\u91CD\u65B0\u8FDE\u63A5"):null,Z&&M?s("span",{style:{color:$e,fontSize:12}},we==="acquiring"?"\u6B63\u5728\u63A5\u7BA1\u2026":we==="releasing"?"\u6B63\u5728\u4EA4\u8FD8\u2026":"\u52A9\u7406\u6B63\u5728\u4F7F\u7528 \xB7 \u70B9\u753B\u9762\u5373\u53EF\u63A5\u7BA1"):null,Z&&M&&P.current.snapshot.available?s("button",{style:{...rt,padding:"3px 9px",fontSize:11},onClick:()=>P.current.acquire()},"\u63A5\u7BA1"):null,Z&&!M?s("span",{style:{color:$e,fontSize:12}},"\u60A8\u62E5\u6709\u63A7\u5236\u6743 \xB7 \u70B9\u753B\u9762\u5916\u91CA\u653E"):null,Z&&W?s("span",{style:{color:$e,fontSize:12}},W):null,Z&&K?s("span",{role:"status","aria-live":"polite",style:{color:$e,fontSize:12}},K):null):null),s("details",{style:{alignSelf:"flex-end",color:"var(--dsw-alias-label-tertiary, #76808e)",fontSize:11,opacity:.8,maxWidth:"100%",overflowWrap:"anywhere"}},s("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),s("small",{"data-personal-assistant-build":je},`\u6784\u5EFA ${je}`)))):s("section",{"data-personal-assistant-panel":"true",style:{...H,border:"none",height:"100%",minHeight:0,display:"flex",flexDirection:"column",fontSize:13}},s("header",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center",padding:12,borderBottom:H.border}},s("strong",{style:{fontWeight:500,marginRight:8}},"\u4E2A\u4EBA\u52A9\u7406"),Oe&&["idle","closed","error"].includes(O)?s("button",{style:Ee,onClick:()=>{F()}},"\u5237\u65B0\u52A9\u7406\u5217\u8868"):null,typeof d=="function"?s("button",{style:Ee,onClick:d},"\u653E\u5230\u53F3\u4FA7\u680F"):null,Oe?s("button",{style:Ee,disabled:["connecting","resuming"].includes(O),onClick:()=>O==="dormant"?y():void x(w.current.handoffSupported?"observe":"control")},O==="dormant"?"\u6062\u590D\u753B\u9762":M&&O==="readonly"?"\u7533\u8BF7\u63A7\u5236":Z?"\u91CD\u65B0\u8FDE\u63A5":"\u8FDE\u63A5\u4E91\u7535\u8111"):null,Oe?s("button",{style:Ee,disabled:O==="connecting",onClick:()=>{x("read")}},"\u53EA\u8BFB\u65C1\u89C2"):null,Z?s("span",{role:"status","aria-live":"polite",style:{marginLeft:"auto",color:"var(--dsw-alias-label-secondary, #536174)"}},Ye):null),O==="readonly"?s("div",{role:"alert",style:{background:"#fff0d6",color:"#763c00",padding:"8px 12px"}},"\u5F53\u524D\u4E3A\u53EA\u8BFB\u65C1\u89C2\uFF0C\u9F20\u6807\u548C\u952E\u76D8\u8F93\u5165\u4E0D\u4F1A\u53D1\u9001\uFF1B\u53EF\u7533\u8BF7\u63A7\u5236"):null,Z&&W?s("div",{role:"status",style:{padding:"8px 12px"}},W):null,nt,s("footer",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:12,padding:"7px 12px",color:"var(--dsw-alias-label-secondary, #536174)",borderTop:H.border}},s("details",{open:v,onToggle:e=>ge(e.currentTarget.open)},s("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),$?s("div",{style:{paddingTop:8}},`\u76EE\u5F55\u8FDE\u63A5\u5173\u95ED\u7801\uFF1A${$}`):null,s("div",{style:{paddingTop:8,lineHeight:1.8,overflowWrap:"anywhere"}},s("div",null,`\u4E91\u7AEF\u5B9E\u4F8B\uFF1A${E?.agentId||"\u672A\u5F00\u901A"}`),s("div",null,`\u8FDE\u63A5\u6807\u8BC6\uFF1A${X||"\u672A\u8FDE\u63A5"}`),s("div",null,`\u753B\u9762\u5E27\u7387\uFF1A${ne} fps`),s("div",null,"\u5FEB\u6377\u952E\u4F1A\u8F6C\u53D1\u5230\u4E91\u7535\u8111\uFF1BEsc \u4F18\u5148\u9000\u51FA\u5168\u5C4F"))),s("small",{"data-personal-assistant-build":je,style:{opacity:.75}},`\u6784\u5EFA ${je}`)))}function on({request:t,nativeWorkbench:g}={}){let d=Ne||globalThis.React;if(!d)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:r,useEffect:n,useState:a,useCallback:s}=d,[o,f]=a(null),[p,E]=a(""),[D,S]=a(0);n(()=>{let N=!1;return f(null),E(""),(async()=>{try{let T=await t("personal-assistant.configuration");if(!T.configured)throw new Error("\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A\uFF0C\u8BF7\u5148\u5728\u8BBE\u7F6E\u4E2D\u8FDE\u63A5\u4E91\u7AEF\u5B9E\u4F8B");let $=await t("personal-assistant.bots.list");if($.directoryAvailable!==!0)throw new Error("\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");let ee=Je($.bots,T.botId||$.primaryBotId);N||f({agentId:T.agentId,botId:ee})}catch(T){N||E(T.message||"\u4E91\u7AEF\u52A9\u7406\u6682\u4E0D\u53EF\u7528")}})(),()=>{N=!0}},[t,D]);let R=s((N,T={})=>{if(!o)throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");if(T.agentId&&T.agentId!==o.agentId)throw new Error("\u4E91\u7AEF\u5B9E\u4F8B\u4E0D\u4E00\u81F4");if(N!=="personal-assistant.bots.list"&&T.botId&&T.botId!==o.botId)throw new Error("\u4E91\u7AEF\u52A9\u7406\u4E0D\u4E00\u81F4");return t(N,{...T,...o})},[t,o?.agentId,o?.botId]);return n(()=>{o&&g?.available?g.bind(o,R):o&&E(g?.unavailableReason||"\u5F53\u524D\u5BBF\u4E3B\u9700\u8981\u66F4\u65B0\u539F\u751F\u4FA7\u680F\u7EC4\u4EF6")},[g,R,o?.agentId,o?.botId]),o?g?.available?r("div",{key:`${o.agentId}:${o.botId}`,"data-personal-assistant-home":"true","data-agent-id":o.agentId,"data-bot-id":o.botId,style:{flex:"1 1 0px",height:"100%",maxHeight:"100%",minHeight:0,minWidth:0,overflow:"hidden",boxSizing:"border-box",display:"flex",flexDirection:"column"}},r(mt,{React:d,request:R,scope:o,onOpenComputer:()=>g.open()})):r("div",{role:"alert",style:{padding:24}},"\u5F53\u524D\u5BBF\u4E3B\u5C1A\u672A\u63D0\u4F9B\u539F\u751F\u4E91\u7535\u8111\u4FA7\u680F\uFF0C\u8BF7\u66F4\u65B0 Studio \u540E\u91CD\u65B0\u6253\u5F00\u3002"):r("div",{role:"status",style:{padding:24}},p||"\u6B63\u5728\u8FDE\u63A5\u4E91\u7AEF\u4E2A\u4EBA\u52A9\u7406\u2026",p?r("button",{onClick:()=>S(N=>N+1)},"\u91CD\u65B0\u8FDE\u63A5"):null)}var m={page:{padding:"2px 2px 28px",display:"flex",flexDirection:"column",gap:18,maxWidth:700,fontSize:13,color:"var(--dsw-alias-label-primary, #17202c)"},title:{margin:0,fontSize:18,fontWeight:600,letterSpacing:"-0.01em"},lede:{margin:0,color:"var(--dsw-alias-label-secondary, #536174)",fontSize:13,lineHeight:1.7},card:{border:H.border,borderRadius:12,overflow:"hidden"},row:{display:"flex",gap:16,padding:"12px 14px",borderTop:"1px solid var(--dsw-alias-border-default, #d8dee8)",alignItems:"flex-start"},rowFirst:{display:"flex",gap:16,padding:"12px 14px",alignItems:"flex-start"},label:{width:116,flex:"none",color:"var(--dsw-alias-label-secondary, #536174)",fontSize:13,lineHeight:1.7},value:{flex:1,minWidth:0,fontSize:13,lineHeight:1.7,overflowWrap:"anywhere"},mono:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12},actions:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},button:{...H,borderRadius:8,padding:"6px 11px",cursor:"pointer",font:"inherit",fontSize:13},note:{color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12,lineHeight:1.7},badge:{display:"inline-block",borderRadius:999,padding:"1px 8px",fontSize:12,lineHeight:1.7},badgeOk:{background:"color-mix(in srgb, #067647 12%, transparent)",color:"#067647"},badgeIdle:{background:"color-mix(in srgb, #946200 14%, transparent)",color:"#946200"},badgeError:{background:"color-mix(in srgb, #b42318 12%, transparent)",color:"#b42318"},dangerButton:{...H,borderRadius:8,padding:"6px 11px",cursor:"pointer",font:"inherit",fontSize:13,color:"#b42318",border:"1px solid color-mix(in srgb, #b42318 35%, transparent)",background:"transparent"},confirmBox:{border:"1px solid color-mix(in srgb, #b42318 30%, transparent)",borderRadius:12,padding:"12px 14px",display:"flex",flexDirection:"column",gap:10,background:"color-mix(in srgb, #b42318 4%, transparent)"},dangerInput:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"6px 9px",font:"inherit",fontSize:12,width:"100%",maxWidth:360,boxSizing:"border-box"},danger:{...H,borderRadius:8,padding:"6px 11px",cursor:"pointer",font:"inherit",fontSize:13,color:"#fff",border:"1px solid #b42318",background:"#b42318"},dangerDisabled:{...H,borderRadius:8,padding:"6px 11px",cursor:"not-allowed",font:"inherit",fontSize:13,color:"#fff",border:"1px solid color-mix(in srgb, #b42318 35%, transparent)",background:"color-mix(in srgb, #b42318 35%, transparent)"},success:{color:"#067647",fontSize:12,lineHeight:1.7},input:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"6px 9px",font:"inherit",fontSize:12,width:"100%",maxWidth:360,boxSizing:"border-box"},textarea:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"6px 9px",font:"inherit",fontSize:12,width:"100%",minHeight:76,resize:"vertical",boxSizing:"border-box"},envRow:{display:"flex",gap:6,alignItems:"center",marginBottom:6,flexWrap:"wrap"},envKey:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"5px 8px",font:"inherit",fontSize:12,width:190,boxSizing:"border-box"},envValue:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"5px 8px",font:"inherit",fontSize:12,width:220,boxSizing:"border-box"},tinyButton:{...H,borderRadius:8,padding:"4px 8px",cursor:"pointer",font:"inherit",fontSize:12}};function sn({request:t,openComputer:g=null}={}){let d=Ne||globalThis.React;if(!d)return"\u8BBE\u7F6E\u9875\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00 Studio";let{createElement:r,useEffect:n,useState:a,useCallback:s}=d,[o,f]=a(null),[p,E]=a(null),[D,S]=a(""),[R,N]=a(!1),[T,$]=a(""),[ee,v]=a(!1),[ge,X]=a(""),[Y,O]=a(!1),[B,W]=a(""),[L,M]=a(null),[te,Be]=a(null),[_e,ne]=a(""),[xe,we]=a(""),[q,ie]=a(""),[G,z]=a([]),[ve,K]=a([]),[Se,P]=a(""),[de,he]=a(""),[C,Ie]=a(!1),ue=s(async()=>{N(!0),S("");let h=Date.now();try{let i=await t("personal-assistant.configuration");if(f(i),i?.configured){let u=await t("personal-assistant.bots.list");E(Array.isArray(u?.bots)?u.bots:[]);try{let y=await t("personal-assistant.settings.inspect");M(y),ne(y?.model||""),we(y?.prompt||""),ie(y?.runtime?.version||""),z((y?.environmentVariables||[]).map(k=>({...k,saved:!0,dirty:!1}))),K([]),P("");let x=await t("personal-assistant.settings.versions",{currentVersion:y?.runtime?.version||""}).catch(k=>(P(k?.message||"\u6682\u65F6\u8BFB\u4E0D\u5230\u53EF\u5347\u7EA7\u7684\u7248\u672C"),null));Be(x)}catch(y){M(null),Be(null),P(y?.message||"\u8BFB\u53D6\u4E91\u7AEF\u914D\u7F6E\u5931\u8D25")}}else E([]),M(null),Be(null);$(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 ${Date.now()-h} ms`)}catch(i){S(i?.message||"\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25"),$(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 \u5931\u8D25`)}finally{N(!1)}},[t]),j=o?.agentId||"",V=!!j&&ge.trim()===j,w=s(async()=>{if(V){O(!0),S("");try{await t("personal-assistant.desktop.destroy",{confirmAgentId:j}),v(!1),X(""),W("\u4E2A\u4EBA\u52A9\u7406\u5DF2\u5173\u95ED\uFF1A\u4E91\u7AEF\u5B9E\u4F8B\u5DF2\u5220\u9664\uFF0C\u5173\u8054\u7684\u4E91\u8D44\u6E90\u8BA2\u5355\u6B63\u5728\u91CA\u653E\uFF0C\u672C\u673A\u7ED1\u5B9A\u5DF2\u6E05\u9664\u3002"),f({configured:!1}),E([]),$("")}catch(h){let i=String(h?.message||"");S(/更新 Studio|云连接服务/iu.test(i)?"\u5F53\u524D Studio \u7248\u672C\u8FD8\u4E0D\u652F\u6301\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406\uFF0C\u8BF7\u66F4\u65B0 Studio \u540E\u91CD\u8BD5\u3002":i||"\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{O(!1)}}},[j,V,t]),re=(h,i)=>z(u=>u.map((y,x)=>x===h?{...y,...i,dirty:!0}:y)),ce=()=>z(h=>[...h,{key:"",value:"",sensitive:!1,saved:!1,dirty:!0}]),Fe=h=>{let i=G[h];i&&(z(u=>u.filter((y,x)=>x!==h)),i.saved&&i.key&&K(u=>u.includes(i.key)?u:[...u,i.key]))},be=L?.recordSource==="studio",Ce=s(async()=>{if(!(!be||C)){Ie(!0),P(""),he("");try{let h=G.filter(i=>i.dirty===!0||i.saved!==!0).map(i=>({key:String(i.key||"").trim(),value:String(i.value||""),sensitive:i.sensitive===!0}));await t("personal-assistant.settings.update",{model:_e.trim(),prompt:xe,runtimeVersion:q,environmentVariables:h,deleteKeys:ve}),he(`\u5DF2\u63D0\u4EA4\u4E91\u7AEF\u66F4\u65B0\uFF08\u7248\u672C ${q}\uFF09\uFF0C\u4E2A\u4EBA\u52A9\u7406\u6B63\u5728\u5E94\u7528\u65B0\u914D\u7F6E\uFF0C\u901A\u5E38 1\u20132 \u5206\u949F\u5B8C\u6210\uFF0C\u671F\u95F4\u4E91\u7535\u8111\u4F1A\u77ED\u6682\u91CD\u8FDE\u3002`),K([]);try{let i=await t("personal-assistant.settings.inspect");M(i),ne(i?.model||""),we(i?.prompt||""),ie(i?.runtime?.version||q),z((i?.environmentVariables||[]).map(u=>({...u,saved:!0,dirty:!1})))}catch{}}catch(h){P(h?.message||"\u4FDD\u5B58\u914D\u7F6E\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{Ie(!1)}}},[be,ve,G,_e,xe,t,C,q]);n(()=>{ue()},[ue]);let oe=o?.configured===!0,Pe=o===null?"\u68C0\u67E5\u4E2D":oe?"\u5DF2\u5F00\u901A":"\u5C1A\u672A\u5F00\u901A",ye={...m.badge,...o===null?m.badgeIdle:oe?m.badgeOk:m.badgeIdle},U=(h,i,u=!1)=>r("div",{style:u?m.rowFirst:m.row},r("div",{style:m.label},h),r("div",{style:m.value},i)),pe={...m.note,display:"inline-flex",gap:4,alignItems:"center"},De={...m.actions,marginTop:6},ze={display:"flex",flexDirection:"column",gap:8},c=()=>{if(!L)return r("div",{style:m.card},U("\u4E91\u7AEF\u914D\u7F6E",r("div",{style:m.note},C?"\u8BFB\u53D6\u4E2D\u2026":Se||"\u6682\u65F6\u8BFB\u4E0D\u5230\u4E91\u7AEF\u914D\u7F6E\uFF1B\u8BF7\u70B9\u4E0B\u65B9\u201C\u68C0\u67E5\u8FDE\u63A5\u201D\u91CD\u8BD5"),!0));if(L.recordSource!=="studio")return r("div",{style:m.card},U("\u4E91\u7AEF\u914D\u7F6E",r("div",{style:m.note},"\u8FD9\u4E2A\u4E2A\u4EBA\u52A9\u7406\u662F\u7528\u65E7\u7248 Studio \u521B\u5EFA\u7684\uFF0C\u672C\u673A\u6CA1\u6709\u8BB0\u5F55\u5B83\u7684\u914D\u7F6E\u6E05\u5355\uFF0C\u6682\u65F6\u4E0D\u80FD\u5728\u7EBF\u4FEE\u6539\u3002\u53EF\u4EE5\u5173\u95ED\u540E\u91CD\u65B0\u521B\u5EFA\uFF1B\u7B49\u4E91\u7AEF\u5E73\u53F0\u63D0\u4F9B\u8BFB\u53D6\u63A5\u53E3\u540E\u5373\u53EF\u76F4\u63A5\u7F16\u8F91\u3002"),!0));let h=te&&te.catalogAvailable?r("select",{style:m.input,value:q,disabled:C,"aria-label":"\u8FD0\u884C\u65F6\u7248\u672C",onChange:y=>ie(String(y?.target?.value??""))},te.versions.map(y=>r("option",{key:y.version,value:y.version},y.version===L.runtime?.version?`${y.version}\uFF08\u5F53\u524D\uFF09`:y.version))):r("div",{style:m.note},`${L.runtime?.version||q||"\u672A\u77E5\u7248\u672C"} \xB7 \u4E91\u7AEF\u8FD8\u6CA1\u6709\u53D1\u5E03\u53EF\u5347\u7EA7\u7248\u672C`),i=r("div",null,G.length?G.map((y,x)=>r("div",{key:`env-${x}`,style:m.envRow},r("input",{style:m.envKey,value:y.key,placeholder:"KEY","aria-label":"\u73AF\u5883\u53D8\u91CF\u540D",disabled:C||y.saved===!0,onChange:k=>re(x,{key:String(k?.target?.value??"")})}),r("input",{style:m.envValue,value:y.value,"aria-label":"\u73AF\u5883\u53D8\u91CF\u503C",type:y.sensitive===!0?"password":"text",disabled:C,placeholder:y.saved===!0&&y.sensitive===!0?"\u5DF2\u4FDD\u5B58\uFF08\u7559\u7A7A\u4E0D\u4FEE\u6539\uFF09":"VALUE",onChange:k=>re(x,{value:String(k?.target?.value??"")})}),r("label",{style:pe},r("input",{type:"checkbox",checked:y.sensitive===!0,disabled:C,onChange:k=>re(x,{sensitive:k?.target?.checked===!0})}),"\u654F\u611F"),r("button",{style:m.tinyButton,disabled:C,onClick:()=>Fe(x)},"\u5220\u9664"))):r("div",{style:m.note},"\u8FD8\u6CA1\u6709\u914D\u7F6E\u73AF\u5883\u53D8\u91CF"),r("div",{style:De},r("button",{style:m.tinyButton,disabled:C,onClick:ce},"\u6DFB\u52A0\u53D8\u91CF"),r("span",{style:m.note},"\u5DF2\u4FDD\u5B58\u7684\u654F\u611F\u503C\u4E0D\u4F1A\u56DE\u663E\uFF0C\u7559\u7A7A\u8868\u793A\u4E0D\u4FEE\u6539\uFF1B\u5220\u9664\u540E\u4FDD\u5B58\u751F\u6548"))),u=r("div",{style:ze},de?r("div",{style:m.success},de):null,Se?r("div",{style:{...m.note,color:"#b42318"}},Se):null,r("div",{style:m.actions},r("button",{style:m.button,disabled:C,onClick:()=>{Ce()}},C?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58\u914D\u7F6E"),r("span",{style:m.note},"\u4FDD\u5B58\u4F1A\u63D0\u4EA4\u4E00\u6B21\u4E91\u7AEF\u66F4\u65B0\uFF0C\u7531\u4E91\u7AEF\u6EDA\u52A8\u5E94\u7528")));return r("div",{style:m.card},U("\u4E91\u7AEF\u914D\u7F6E",r("div",{style:m.note},"\u6A21\u578B\u3001\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3001\u8FD0\u884C\u65F6\u7248\u672C\u548C\u73AF\u5883\u53D8\u91CF\u4FDD\u5B58\u5728\u4E91\u7AEF\u5B9E\u4F8B\u3002\u4FDD\u5B58\u65F6\u63D0\u4EA4\u4E00\u6B21\u4E91\u7AEF\u66F4\u65B0\uFF0C\u7531\u4E91\u7AEF\u6EDA\u52A8\u5E94\u7528\u5230\u5B9E\u4F8B\uFF0C\u4E0D\u9700\u8981\u672C\u673A\u91CD\u542F\u3002"),!0),U("\u6A21\u578B",r("input",{style:m.input,value:_e,disabled:C,placeholder:"\u4F8B\u5982 deepseek-v4.1-flash-1017","aria-label":"\u6A21\u578B\u540D\u79F0",onChange:y=>ne(String(y?.target?.value??""))})),U("\u7CFB\u7EDF\u63D0\u793A\u8BCD",r("textarea",{style:m.textarea,value:xe,disabled:C,"aria-label":"\u7CFB\u7EDF\u63D0\u793A\u8BCD",onChange:y=>we(String(y?.target?.value??""))})),U("\u8FD0\u884C\u65F6\u7248\u672C",h),U("\u73AF\u5883\u53D8\u91CF",i),U("\u4FDD\u5B58",u))};return r("section",{"data-personal-assistant-settings":"true",style:m.page},r("div",null,r("h1",{style:m.title},"\u4E2A\u4EBA\u52A9\u7406"),r("p",{style:{...m.lede,marginTop:6}},"\u4E91\u7AEF\u6301\u7EED\u8FD0\u884C\u7684\u52A9\u7406\uFF0C\u5E26\u4E00\u53F0\u72EC\u7ACB\u4E91\u7535\u8111\u3002\u5173\u6389\u7A97\u53E3\u5B83\u4E5F\u5728\u5DE5\u4F5C\uFF1B\u5BF9\u8BDD\u4E0E\u4E91\u7535\u8111\u5728\u5DE6\u4FA7\u300C\u4E2A\u4EBA\u52A9\u7406\u300D\u9875\u3002")),D?r("div",{role:"alert",style:{...m.note,color:"#b42318",background:"color-mix(in srgb, #b42318 8%, transparent)",border:"1px solid color-mix(in srgb, #b42318 25%, transparent)",borderRadius:10,padding:"9px 12px"}},D):null,r("div",{style:m.card},U("\u72B6\u6001",r("span",null,r("span",{style:ye},Pe),T?r("span",{style:m.note},`\u3000\u4E0A\u6B21\u68C0\u67E5 ${T}`):null),!0),U("\u4E91\u7AEF\u5B9E\u4F8B",o?.agentId?r("span",{style:m.mono},o.agentId):r("span",{style:m.note},oe?"\u672A\u8FD4\u56DE\u5B9E\u4F8B\u6807\u8BC6":"\u5F00\u901A\u540E\u7531 Studio \u7ED1\u5B9A")),U("\u7F51\u5173",o?.gatewayUrl?r("span",{style:m.mono},o.gatewayUrl):r("span",{style:m.note},"\u7531 Studio Host \u914D\u7F6E")),U("\u52A9\u7406\u8FDE\u63A5",r("span",{style:m.note},p===null?"\u68C0\u67E5\u4E2D":p.length?"\u5DF2\u8FDE\u63A5\u4F60\u7684\u52A9\u7406":"\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA")),U("\u8BB0\u5FC6",r("div",null,r("div",{style:m.mono},"/workspace/assistant-state"),r("div",{style:m.note},"\u8BB0\u5FC6\u3001\u4F1A\u8BDD\u4E0E\u5B9A\u65F6\u4EFB\u52A1\u968F\u4E91\u7535\u8111\u6301\u4E45\u4FDD\u5B58\uFF0C\u6362\u8BBE\u5907\u4E5F\u5728"))),U("\u4E91\u7AEF\u80FD\u529B",r("div",null,r("div",null,"\u9ED8\u8BA4\u5F00\u542F\uFF1A\u4E91\u7AEF\u547D\u4EE4\u6267\u884C\u3001\u4E91\u7AEF\u6D4F\u89C8\u5668"),r("div",{style:m.note},"\u90FD\u8DD1\u5728\u9694\u79BB\u5DE5\u4F5C\u533A\uFF1A\u8BFB\u4E0D\u5230\u672C\u673A\u6587\u4EF6\u4E0E\u51ED\u8BC1\uFF0C\u4E0D\u80FD\u8BBF\u95EE\u5185\u7F51\u4E0E\u672C\u673A\u5730\u5740\uFF1B\u654F\u611F\u64CD\u4F5C\u4F1A\u5148\u8BF7\u4F60\u786E\u8BA4"))),U("\u63D2\u4EF6\u7248\u672C",r("span",{style:m.note},`\u6784\u5EFA ${je}`))),oe?c():null,oe||B?r("div",{style:m.card},U("\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406",r("div",{style:{display:"flex",flexDirection:"column",gap:8}},r("div",{style:m.note},"\u5173\u95ED\u4F1A\u5220\u9664\u4E91\u7AEF\u5B9E\u4F8B\uFF08\u4E91\u7535\u8111 Pod\uFF09\u548C\u4E91\u7AEF\u52A9\u7406\u6570\u636E\uFF0C\u5E76\u91CA\u653E\u5173\u8054\u7684\u4E91\u8D44\u6E90\u8BA2\u5355\uFF1B\u672C\u673A\u7ED1\u5B9A\u4E5F\u4F1A\u4E00\u5E76\u6E05\u9664\uFF0C\u4E4B\u540E\u53EF\u91CD\u65B0\u521B\u5EFA\u3002"),B?r("div",{style:m.success},B):null,ee?r("div",{style:m.confirmBox},r("div",{style:{...m.note,color:"#b42318"}},"\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002\u8BF7\u8F93\u5165\u4E0A\u65B9\u300C\u4E91\u7AEF\u5B9E\u4F8B\u300D\u7684\u6807\u8BC6\u4EE5\u786E\u8BA4\u5173\u95ED\uFF1A"),r("input",{style:m.dangerInput,value:ge,placeholder:j||"ar-\u2026","aria-label":"\u8F93\u5165\u4E91\u7AEF\u5B9E\u4F8B\u6807\u8BC6\u4EE5\u786E\u8BA4\u5173\u95ED",disabled:Y,onChange:h=>X(String(h?.target?.value??""))}),r("div",{style:m.actions},r("button",{style:V&&!Y?m.danger:m.dangerDisabled,disabled:!V||Y,onClick:()=>{w()}},Y?"\u6B63\u5728\u5173\u95ED\u2026":"\u786E\u8BA4\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406"),r("button",{style:m.button,disabled:Y,onClick:()=>{v(!1),X("")}},"\u53D6\u6D88"))):r("div",{style:m.actions},r("button",{style:m.dangerButton,disabled:!oe||Y,onClick:()=>{v(!0),X(""),W("")}},"\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406"),r("span",{style:m.note},oe?"\u9700\u8981\u8F93\u5165\u5B9E\u4F8B\u6807\u8BC6\u4E8C\u6B21\u786E\u8BA4":"\u5F53\u524D\u6CA1\u6709\u5DF2\u5F00\u901A\u7684\u4E2A\u4EBA\u52A9\u7406"))),!0)):null,r("div",{style:m.actions},r("button",{style:m.button,disabled:R,onClick:()=>{ue()}},R?"\u6B63\u5728\u68C0\u67E5\u2026":"\u68C0\u67E5\u8FDE\u63A5"),r("span",{style:m.note},"\u68C0\u67E5\u4F1A\u8BFB\u53D6\u5F00\u901A\u72B6\u6001\u5E76\u62C9\u53D6\u4E00\u6B21\u52A9\u7406\u5217\u8868\uFF0C\u4E0D\u4F1A\u542F\u52A8\u4E91\u7535\u8111")))}function an({size:t}={}){let g=Ne,d=Number(t)>0?Number(t):16;return g?.createElement?g.createElement("svg",{width:d,height:d,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block"}},g.createElement("path",{d:"M3.4 3.2h9.2a1.3 1.3 0 0 1 1.3 1.3H7.7l-2.9 2.3v-2.3H3.4a1.3 1.3 0 0 1-1.3-1.3V4.5a1.3 1.3 0 0 1 1.3-1.3z"}),g.createElement("path",{d:"M8.1 5.6l.62 1.46 1.46.62-1.46.62L8.1 9.76l-.62-1.46-1.46-.62 1.46-.62z"})):"\u52A9"}function ln({size:t}={}){let g=Ne,d=Number(t)>0?Number(t):16;return g?.createElement?g.createElement("svg",{width:d,height:d,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",flex:"0 0 auto"}},g.createElement("rect",{x:2.2,y:3.4,width:11.6,height:7.4,rx:1.4}),g.createElement("path",{d:"M6.6 13.4h2.8"}),g.createElement("path",{d:"M8 10.8v2.6"})):null}function cn(){let t=Ne,g=ln({size:15});return!t?.createElement||!g?"\u4E91\u7535\u8111":t.createElement("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",lineHeight:1}},g,t.createElement("span",null,"\u4E91\u7535\u8111"))}function _t(t){if(!t?.slots?.inject||!t.slots.register)throw new TypeError("Personal Assistant client requires the public DSH slots service");let g=async(a,s={})=>{if(!t.connection?.rpc?.call)throw new tt;let o=await t.connection.rpc.call("/api","personal-assistant",{operation:a,payload:s});if(!o?.ok)throw Object.assign(new Error(o?.error?.message||"Studio Host \u8BF7\u6C42\u5931\u8D25"),{code:o?.error?.code,status:o?.error?.details?.status,closeCode:o?.error?.details?.closeCode});return o.value},d=(a,s)=>{try{let o=()=>a();return typeof t.effect=="function"?t.effect(o,s):o()}catch(o){try{console.warn(`[personal-assistant] ${s} \u6CE8\u518C\u5931\u8D25`,o)}catch{}return}},r=vt({sidebarRight:t.sidebarRight,slots:t.slots});r&&(r.render=a=>St({...a,React:Ne||globalThis.React,workbench:r,Panel:kt}),d(()=>()=>r.dispose(),"personal-assistant: native workbench")),d(()=>t.slots.inject("main",()=>t.slots.register({name:"main",key:et,inject:()=>({request:g,nativeWorkbench:r})},on)),"personal-assistant: main panel"),d(()=>t.slots.inject("sidebar.panellist",()=>t.slots.register({name:"sidebar.panellist",id:et,order:90,label:"\u4E2A\u4EBA\u52A9\u7406"},an)),"personal-assistant: sidebar row"),d(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:`${et}-settings`,order:196,label:"\u4E2A\u4EBA\u52A9\u7406",inject:()=>({request:g})},sn)),"personal-assistant: settings section"),typeof t.inject=="function"&&d(()=>t.inject(["sidebarRightTabs"],a=>{let s=[],o=f=>{typeof f=="function"&&s.push(f)};try{let f=a.sidebarRightTabs;if(f===void 0||typeof f.register!="function")return;o(f.register({id:Ve,kind:Ve,title:()=>"\u4E91\u7535\u8111",guide:[{order:20,title:()=>"\u4E91\u7535\u8111",description:()=>"\u4E2A\u4EBA\u52A9\u7406\u7684\u4E91\u7AEF\u7535\u8111\u753B\u9762\uFF0C\u53EF\u83B7\u53D6\u63A7\u5236\u6743"}]})),o(a.slots.inject("sidebar.right.pane.tab",()=>a.slots.register({name:"sidebar.right.pane.tab",key:Ve,inject:()=>({request:g})},p=>kt({...p,variant:"computer"})))),o(a.slots.inject("sidebar.right.pane.tab.title",()=>a.slots.register({name:"sidebar.right.pane.tab.title",key:Ve},cn)))}catch(f){try{console.warn("[personal-assistant] \u53F3\u4FA7\u680F\u6CE8\u518C\u5931\u8D25",f)}catch{}}return()=>{for(let f of s.reverse())f()}}),"personal-assistant: right tab")}window.__ModuleLoader__.load({id:"@kingsoftcloud/agentkit-personal-assistant",factory:t=>(Rt(t("react")),{name:"agentkit-personal-assistant",inject:At,apply:_t})});})();
6
+ `)});continue}let D=pt.exec(o),S=ft.exec(o);if(D||S){a(s);let R={type:S?"ordered":"unordered",items:[],start:S?Number(S[1]):1};for(;n<d.length;){let N=pt.exec(d[n]),T=ft.exec(d[n]);if(!N&&!T)break;R.items.push((N?N[1]:T[2]).trim()),n+=1}r.push(R);continue}s.push(o),n+=1}return a(s),r}function Ht(t){let g=typeof t=="string"?t:"",d=[],r=a=>{a&&d.push({type:"text",text:a})},n=g;for(;n.length>0;){let a=/^`([^`]+)`/u.exec(n);if(a){d.push({type:"code",text:a[1]}),n=n.slice(a[0].length);continue}let s=/^\*\*([^*\n]+)\*\*/u.exec(n)||/^__([^_\n]+)__/u.exec(n);if(s){d.push({type:"strong",text:s[1]}),n=n.slice(s[0].length);continue}let o=/^\*([^*\s][^*\n]*)\*/u.exec(n)||/^_([^_\s][^_\n]*)_/u.exec(n);if(o){d.push({type:"em",text:o[1]}),n=n.slice(o[0].length);continue}let f=/^\[([^\]]+)\]\(([^)\s]+)\)/u.exec(n);if(f){d.push({type:"link",text:f[1],href:f[2]}),n=n.slice(f[0].length);continue}let p=n.slice(1).search(/[`*_[\]\n]/u),E=p<0?n.length:p+1;r(n.slice(0,E)),n=n.slice(E)}return d.reduce((a,s)=>{let o=a[a.length-1];return s.type==="text"&&o&&o.type==="text"?a[a.length-1]={type:"text",text:o.text+s.text}:a.push(s),a},[])}function gt(t,g,d={}){let r=Wt(g);if(r.length===0)return null;let n=(a,s)=>Ht(a).map((o,f)=>{let p=`${s}-i${f}`;return o.type==="code"?t("code",{key:p,style:d.inlineCode},o.text):o.type==="strong"?t("strong",{key:p},o.text):o.type==="em"?t("em",{key:p},o.text):o.type==="link"?/^(https?:|mailto:|cloud-file:)/iu.test(o.href)?t("a",{key:p,href:o.href,target:"_blank",rel:"noreferrer noopener",style:d.link},o.text):t("span",{key:p},o.text):t("span",{key:p},o.text)});return r.map((a,s)=>{let o=`b${s}`;if(a.type==="code")return t("pre",{key:o,style:d.codeBlock},t("code",null,a.text));if(a.type==="heading")return t("div",{key:o,style:{...d.heading,...a.level<=2?d.headingStrong:null}},n(a.text,o));if(a.type==="rule")return t("hr",{key:o,style:d.rule});if(a.type==="quote")return t("blockquote",{key:o,style:d.quote},n(a.text,o));if(a.type==="unordered"||a.type==="ordered"){let f=a.type==="ordered"?"ol":"ul";return t(f,{key:o,style:d.list,start:a.type==="ordered"&&a.start!==1?a.start:void 0},a.items.map((p,E)=>t("li",{key:`${o}-l${E}`},n(p,`${o}-l${E}`))))}return t("p",{key:o,style:d.paragraph},n(a.text,o))})}var qt="\u6709\u4EC0\u4E48\u53EF\u4EE5\u5E2E\u4F60\uFF1F",Kt=new Set(["DSH_SESSION_BUSY","DSH_TURN_TIMEOUT"]),bt={RUNTIME_PROCESS_INTERRUPTED:"\u4E91\u7535\u8111\u91CD\u542F\uFF0C\u4EFB\u52A1\u88AB\u4E2D\u65AD",DSH_SESSION_CONTROLLER_UNAVAILABLE:"\u4E91\u7AEF\u8FDE\u63A5\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",DSH_TURN_NOT_ACCEPTED:"\u4E91\u7AEF\u6CA1\u6709\u63A5\u53D7\u8FD9\u4E00\u8F6E\u5BF9\u8BDD\uFF0C\u8BF7\u91CD\u65B0\u53D1\u9001",DSH_SESSION_NOT_FOUND:"\u4F1A\u8BDD\u4E0D\u5B58\u5728\u6216\u5DF2\u88AB\u5220\u9664"},Vt=t=>{let g=String(t||"").trim();return g?bt[g]?bt[g]:/^[A-Z][A-Z0-9_]{5,}$/u.test(g)?"\u4E91\u7AEF\u6CA1\u6709\u5B8C\u6210\u8FD9\u4E00\u8F6E\uFF0C\u8BF7\u91CD\u8BD5":g.slice(0,160):"\u8BF7\u68C0\u67E5\u4EFB\u52A1\u72B6\u6001\u540E\u91CD\u8BD5"},Yt=400,Qt=8,yt=1500,I={page:{flex:"1 1 0px",height:"100%",maxHeight:"100%",minHeight:0,minWidth:0,overflow:"hidden",boxSizing:"border-box",display:"flex",flexDirection:"column",fontSize:13,color:"var(--dsw-alias-label-primary, #17202c)",background:"var(--dsw-alias-bg-layer-1, #fff)"},header:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--dsw-alias-border-default, #d8dee8)",flex:"none"},title:{margin:0,fontSize:14,fontWeight:600},status:{color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12},spacer:{marginLeft:"auto"},ghost:{border:"1px solid var(--dsw-alias-border-default, #d8dee8)",background:"transparent",color:"inherit",borderRadius:8,padding:"5px 10px",cursor:"pointer",font:"inherit",fontSize:12},scroller:{flex:"1 1 0px",minHeight:0,minWidth:0,overflowY:"auto",overflowX:"hidden",overscrollBehavior:"contain",boxSizing:"border-box",padding:"20px 16px 8px"},thread:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:14},row:{display:"flex",flexDirection:"column",gap:4,alignItems:"flex-start"},rowUser:{display:"flex",flexDirection:"column",gap:4,alignItems:"flex-end"},who:{fontSize:11,color:"var(--dsw-alias-label-secondary, #536174)"},bubble:{maxWidth:"86%",padding:"9px 12px",borderRadius:12,lineHeight:1.7,overflowWrap:"anywhere",display:"flex",flexDirection:"column",gap:8,background:"color-mix(in srgb, currentColor 5%, transparent)"},paragraph:{margin:0,whiteSpace:"pre-wrap"},heading:{fontWeight:600,fontSize:13.5},headingStrong:{fontSize:15},list:{margin:0,paddingLeft:20,display:"flex",flexDirection:"column",gap:4},codeBlock:{margin:0,padding:"10px 12px",borderRadius:8,overflowX:"auto",fontSize:12,lineHeight:1.65,background:"color-mix(in srgb, currentColor 9%, transparent)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},inlineCode:{padding:"1px 5px",borderRadius:5,fontSize:12,background:"color-mix(in srgb, currentColor 9%, transparent)",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},quote:{margin:0,paddingLeft:10,borderLeft:"3px solid var(--dsw-alias-border-default, #d8dee8)",color:"var(--dsw-alias-label-secondary, #536174)"},rule:{border:"none",borderTop:"1px solid var(--dsw-alias-border-default, #d8dee8)",margin:"2px 0",width:"100%"},link:{color:"#2f6bff",textDecoration:"none"},bubbleUser:{maxWidth:"86%",padding:"9px 12px",borderRadius:12,lineHeight:1.7,whiteSpace:"pre-wrap",overflowWrap:"anywhere",background:"color-mix(in srgb, #2f6bff 12%, transparent)"},pulse:{animation:"pa-awaiting 1.2s ease-in-out infinite"},step:{fontSize:12,color:"var(--dsw-alias-label-secondary, #536174)",lineHeight:1.7,overflowWrap:"anywhere"},centered:{flex:1,display:"grid",placeItems:"center",padding:24,textAlign:"center"},centeredInner:{maxWidth:420,display:"flex",flexDirection:"column",gap:10,alignItems:"center"},composer:{flex:"0 0 auto",minWidth:0,boxSizing:"border-box",padding:"8px 16px 14px"},composerInner:{maxWidth:720,minWidth:0,margin:"0 auto",display:"flex",flexDirection:"column",gap:6,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:16,padding:"10px 10px 8px 12px",background:"var(--dsw-alias-bg-layer-1, #fff)"},textarea:{flex:1,width:"100%",minWidth:0,boxSizing:"border-box",minHeight:24,maxHeight:200,resize:"none",border:"none",outline:"none",background:"transparent",color:"inherit",font:"inherit",fontSize:13,lineHeight:1.7},composerBar:{display:"flex",alignItems:"center",gap:8},iconButton:{flex:"none",width:28,height:28,display:"grid",placeItems:"center",cursor:"pointer",border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:999,background:"transparent",color:"var(--dsw-alias-label-secondary, #536174)",padding:0},send:{flex:"none",width:28,height:28,display:"grid",placeItems:"center",border:"none",borderRadius:999,cursor:"pointer",padding:0,background:"var(--dsw-alias-label-primary, #17202c)",color:"var(--dsw-alias-bg-layer-1, #fff)"},sendDisabled:{background:"var(--dsw-alias-border-default, #d8dee8)",color:"var(--dsw-alias-label-secondary, #536174)",cursor:"default"},sendQueued:{flex:"none",width:28,height:28,display:"grid",placeItems:"center",borderRadius:999,cursor:"pointer",padding:0,border:"1px dashed var(--dsw-alias-label-primary, #17202c)",background:"transparent",color:"var(--dsw-alias-label-primary, #17202c)"},queueBadge:{flex:"none",borderRadius:999,padding:"1px 8px",fontSize:11,lineHeight:"18px",background:"color-mix(in srgb, #946200 14%, transparent)",color:"#946200"},queueBubble:{maxWidth:"86%",padding:"9px 12px",borderRadius:12,lineHeight:1.7,whiteSpace:"pre-wrap",overflowWrap:"anywhere",border:"1px dashed color-mix(in srgb, currentColor 35%, transparent)",background:"color-mix(in srgb, currentColor 4%, transparent)",color:"var(--dsw-alias-label-secondary, #536174)"},queueRow:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",justifyContent:"flex-end"},queueHint:{fontSize:11,color:"var(--dsw-alias-label-secondary, #536174)"},queueCancel:{border:"none",background:"transparent",cursor:"pointer",padding:"2px 4px",borderRadius:6,color:"var(--dsw-alias-label-secondary, #536174)",display:"inline-flex",alignItems:"center",gap:3,font:"inherit",fontSize:11},queueNotice:{maxWidth:720,margin:"0 auto 6px",fontSize:12,color:"#946200",lineHeight:1.6},attach:{flex:"none",display:"flex",alignItems:"center",gap:6,padding:"3px 8px 3px 4px",borderRadius:8,background:"var(--dsw-alias-bg-layer-2, #f4f6fa)",fontSize:11,maxWidth:180},attachName:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},attachThumb:{width:20,height:20,borderRadius:4,objectFit:"cover",flex:"none"},attachRow:{display:"flex",flexWrap:"wrap",gap:6}},ae=t=>typeof t=="string"?t:"",Xt=t=>t("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},t("path",{d:"M12 19V5M5 12l7-7 7 7"})),Gt=t=>t("svg",{width:15,height:15,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round","aria-hidden":!0},t("path",{d:"M12 5v14M5 12h14"})),ht=t=>t("svg",{width:10,height:10,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.4,strokeLinecap:"round","aria-hidden":!0},t("path",{d:"M6 6l12 12M18 6L6 18"}));function mt({React:t,request:g,scope:d,onOpenComputer:r=null}={}){if(!t)return"\u4E2A\u4EBA\u52A9\u7406\u5BF9\u8BDD\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:n,useCallback:a,useEffect:s,useRef:o,useState:f}=t,[p,E]=f("loading"),[D,S]=f(""),[R,N]=f([]),[T,$]=f(""),[ee,v]=f([]),[ge,X]=f(""),[Y,L]=f([]),B=o(null),[W,O]=f(!1),[M,te]=f(!1),[Be,_e]=f(""),[ne,xe]=f([]),[we,q]=f(""),ie=o(0),G=o(new Map),U=o([]),ve=o(!1),K=o(null),Se=o(!1);Se.current=W;let P=o(!1);P.current=M;let de=o("loading");de.current=p;let he=o(0),C=o(!0),Ie=o(null),ue=o(!0),j=o("");j.current=T;let V=a(async(c,h={})=>{if(typeof g!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return g(c,h)},[g]),w=a(c=>{!Array.isArray(c)||c.length===0||v(h=>{let i=[...h];for(let u of c)if(!(!u||typeof u!="object")){if(u.type==="message"){let y=ae(u.id)||`local-${i.length}`,x=ae(u.role)||"assistant",k=ae(u.text),fe=i.findIndex(me=>me.id===y),F={id:y,role:x,text:k,done:u.done!==!1,clientTurnId:u.clientTurnId,status:"accepted"};if(fe>=0)i[fe]={...i[fe],...F};else if(x==="user"){let me=i.findIndex(Me=>Me.role==="user"&&u.clientTurnId&&Me.clientTurnId===u.clientTurnId);me>=0?i[me]={...F}:i.push(F)}else i.push(F)}else if(u.type==="delta"){let y=ae(u.id)||`local-${i.length}`,x=i.findIndex(k=>k.id===y);x>=0?i[x]={...i[x],text:i[x].text+ae(u.text)}:i.push({id:y,role:"assistant",text:ae(u.text),done:!1})}else if(u.type==="step"&&ae(u.text)){let y={id:ae(u.id),role:"step",text:ae(u.text),done:!0},x=i.findIndex(k=>k.id===y.id);x>=0?i[x]=y:i.push(y)}}return i})},[]),re=a(async c=>{if(!c)return;let h=j.current;if(h&&h!==c&&U.current.length>0){let u=U.current.length;U.current=[],xe([]),K.current&&(clearTimeout(K.current),K.current=null),q(`\u5DF2\u5207\u6362\u4F1A\u8BDD\uFF0C${u} \u6761\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001\uFF0C\u5DF2\u53D6\u6D88`)}else h&&h!==c&&q("");j.current=c;let i=++he.current;$(c),E("loading"),S(""),ie.current=0,ue.current=!0,v([]);try{let u=await V("personal-assistant.session.snapshot",{sessionId:c});if(!C.current||j.current!==c||i!==he.current)return;ie.current=Number(u?.cursor)||0;let y=Array.isArray(u?.messages)?u.messages:[];v(y.map((x,k)=>({id:ae(x?.id)||`history-${k}`,role:ae(x?.role)||"assistant",text:ae(x?.text),done:!0}))),te(u.turns?.some(x=>["queued","running"].includes(x.status))||!1),E("ready")}catch(u){if(!C.current||i!==he.current)return;E("error"),S(u?.message||"\u65E0\u6CD5\u8BFB\u53D6\u4F1A\u8BDD\u5185\u5BB9")}},[V]),ce=a(async()=>{if(E("loading"),S(""),!!C.current)try{let c=await V("personal-assistant.sessions.list");if(!C.current)return;let h=Array.isArray(c?.sessions)?c.sessions:[];if(N(h),h.length>0){await re(ae(h[0].sessionId));return}let i=await V("personal-assistant.session.create",{});if(!C.current)return;let u=ae(i?.sessionId);N(u?[{sessionId:u,title:ae(i?.title)||"\u65B0\u4F1A\u8BDD"}]:[]),await re(u)}catch(c){if(!C.current)return;E("error"),S(c?.message||"\u4F1A\u8BDD\u901A\u9053\u6682\u65F6\u4E0D\u53EF\u7528")}},[V,re]);s(()=>(C.current=!0,ce(),()=>{C.current=!1,K.current&&(clearTimeout(K.current),K.current=null)}),[ce]),s(()=>{if(p!=="ready"||!T)return;let c=!1,h=null,i=async()=>{try{let u=await V("personal-assistant.session.events",{sessionId:T,cursor:ie.current});if(c)return;if(ie.current=Number(u?.cursor??ie.current)||0,w(u?.events),Array.isArray(u.turns)){te(u.turns.some(F=>["queued","running"].includes(F.status)));let y=u.turns.findLast(F=>["queued","running"].includes(F.status)),x={cloud_computer:"\u64CD\u4F5C\u4E91\u7535\u8111",cloud_workspace:"\u5904\u7406\u4E91\u7AEF\u6587\u4EF6",cloud_bash:"\u6267\u884C\u4E91\u7AEF\u547D\u4EE4",cloud_run_code:"\u8FD0\u884C\u4E91\u7AEF\u4EE3\u7801",assistant_schedule:"\u8BBE\u7F6E\u4E91\u7AEF\u4EFB\u52A1"},k=y?.progress?.tool;_e(k?`${y.progress.state==="running"?"\u6B63\u5728":"\u5DF2\u5B8C\u6210"}${x[k]||(k.startsWith("cloud_browser_")?"\u64CD\u4F5C\u4E91\u7AEF\u6D4F\u89C8\u5668":"\u6267\u884C\u5DE5\u5177")}`:"");let fe=u.turns.filter(F=>["failed","interrupted","cancelled"].includes(F.status)&&!Kt.has(String(F.error||""))).map(F=>({type:"step",id:`turn-status-${F.turnId}`,text:`\u4EFB\u52A1${F.status==="failed"?"\u5931\u8D25":"\u5DF2\u4E2D\u65AD"}\uFF1A${Vt(F.error)}`}));w(fe)}S("")}catch(u){if(!c){if(u.code==="SESSION_CURSOR_STALE"){re(T);return}S(u.message||"\u4E91\u7AEF\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u6B63\u5728\u6062\u590D\uFF1B\u4EFB\u52A1\u4E0D\u4F1A\u6539\u5230\u672C\u673A\u6267\u884C")}}c||(h=setTimeout(i,600))};return h=setTimeout(i,200),()=>{c=!0,clearTimeout(h)}},[p,T,V,w,re]),s(()=>{let c=Ie.current;c&&ue.current&&(c.scrollTop=c.scrollHeight)},[ee,M]);let Fe=async c=>{let h=Array.from(c.target.files||[]);c.target.value="";let i=[];for(let u of h.slice(0,4)){if(!u||u.size>512*1024){S("\u6BCF\u4E2A\u9644\u4EF6\u6700\u591A 512 KiB\uFF0C\u8BF7\u5148\u538B\u7F29\u6216\u62C6\u5206\u6587\u4EF6");continue}let y=await new Promise(x=>{let k=new FileReader;k.onload=()=>x(String(k.result||"")),k.onerror=()=>x(""),k.readAsDataURL(u)});y&&i.push({id:`${Date.now()}-${u.name}`,name:u.name,mimeType:u.type||"application/octet-stream",size:u.size,dataUrl:y})}i.length&&L(u=>[...u,...i].slice(0,4))},be=c=>{U.current=c,xe(c)},Ce=()=>{K.current&&(clearTimeout(K.current),K.current=null)},oe=c=>Number(c?.status)===409||/SESSION_BUSY|active turn|正忙|处理中/u.test(`${c?.code||""} ${c?.message||""}`),Pe=async(c,{restoreDraft:h=!1}={})=>{G.current.set(c.clientTurnId,c),ue.current=!0,O(!0),S(""),te(!0),v(u=>u.some(y=>y.clientTurnId===c.clientTurnId)?u.map(y=>y.clientTurnId===c.clientTurnId?{...y,status:"pending"}:y):[...u,{id:`local-user-${c.clientTurnId}`,clientTurnId:c.clientTurnId,role:"user",text:c.text,done:!1,status:"pending"}]);let i=c;try{let u=Array.isArray(i.attachments)?i.attachments:[];if(u.length===0&&Array.isArray(i.uploads)&&i.uploads.length>0){let x=[];for(let k of i.uploads)x.push(await V("personal-assistant.file.upload",{sessionId:i.sessionId,name:k.name,dataUrl:k.dataUrl}));u=x.map(({path:k,name:fe,mediaType:F,bytes:me})=>({path:k,name:fe,mediaType:F,bytes:me})),i={...i,attachments:u,uploads:[]},G.current.set(i.clientTurnId,i)}let y=await V("personal-assistant.turn.submit",{sessionId:i.sessionId,text:i.text,clientTurnId:i.clientTurnId,attachments:u});return C.current?(G.current.delete(i.clientTurnId),v(x=>x.map(k=>k.clientTurnId===i.clientTurnId?{...k,status:"accepted",turnId:y.turnId}:k)),{ok:!0,item:i}):{ok:!0,item:i}}catch(u){return C.current?(te(oe(u)),h&&!oe(u)&&X(y=>y||i.text),v(y=>y.map(x=>x.clientTurnId===i.clientTurnId?{...x,status:"failed",failure:u.message||"\u53D1\u9001\u7ED3\u679C\u5F85\u786E\u8BA4\uFF0C\u91CD\u8BD5\u5C06\u590D\u7528\u539F\u6807\u8BC6"}:x)),{ok:!1,failure:u,item:i}):{ok:!1,failure:u,item:i}}finally{C.current&&O(!1)}},ye=(c,h)=>{let i=(c.attempts||0)+1;if(G.current.delete(c.clientTurnId),v(y=>y.filter(x=>x.clientTurnId!==c.clientTurnId)),i>Qt){q(`\u6392\u961F\u6D88\u606F\u591A\u6B21\u672A\u53D1\u51FA\uFF08${h?.message||"\u4E91\u7535\u8111\u4ECD\u5FD9"}\uFF09\uFF0C\u5DF2\u653E\u56DE\u8F93\u5165\u6846\uFF0C\u8BF7\u624B\u52A8\u91CD\u8BD5`),X(y=>y||c.text);return}be([{...c,attempts:i},...U.current]);let u=(yt*Math.min(i,3)/1e3).toFixed(1);q(`\u4E91\u7535\u8111\u4ECD\u5728\u5904\u7406\u4E0A\u4E00\u8F6E\uFF0C\u6D88\u606F\u5DF2\u6392\u961F\uFF0C\u7EA6 ${u} \u79D2\u540E\u81EA\u52A8\u91CD\u53D1`),Ce(),K.current=setTimeout(()=>{K.current=null,z(!0)},yt*Math.min(i,3))},z=async c=>{let h=j.current;if(ve.current||!C.current||de.current!=="ready"||!h||Se.current||!c&&P.current)return!1;let i=U.current[0];if(!i)return!1;if(i.sessionId!==h)return be([]),q("\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001"),!1;ve.current=!0,be(U.current.slice(1));try{let u=await Pe(i);return u.ok?!0:(oe(u.failure)?ye(u.item||i,u.failure):q(`\u6392\u961F\u6D88\u606F\u53D1\u9001\u5931\u8D25\uFF1A${u.failure?.message||"\u8BF7\u70B9\u51FB\u91CD\u8BD5"}`),!1)}finally{ve.current=!1}},pe=c=>{G.current.delete(c),be(U.current.filter(h=>h.clientTurnId!==c)),q("\u5DF2\u64A4\u56DE\u6392\u961F\u6D88\u606F")},De=async(c=null)=>{if(p!=="ready"||!T)return;if(c){W||Pe(c,{restoreDraft:!0});return}let h=ge.trim()||(Y.length?"\u8BF7\u67E5\u770B\u9644\u4EF6\u3002":"");if(!h)return;let i=Y.map(({name:y,mimeType:x,size:k,dataUrl:fe})=>({name:y,mimeType:x,size:k,dataUrl:fe}));if(W||M){be([...U.current,{clientTurnId:crypto.randomUUID(),text:h,sessionId:T,uploads:i,attempts:0,queuedAt:Date.now()}]),ue.current=!0,X(""),L([]),S(""),q("");return}X(""),L([]),S(""),q("");let u=await Pe({clientTurnId:crypto.randomUUID(),text:h,sessionId:T,uploads:i,attempts:0},{restoreDraft:!0});!u.ok&&oe(u.failure)&&ye(u.item,u.failure)};s(()=>{if(p!=="ready"||!T||W||M||ne.length===0)return;let c=setTimeout(()=>{z(!1)},Yt);return()=>clearTimeout(c)},[p,T,W,M,ne]),s(()=>{if(ne.length===0||typeof window>"u"||typeof window.addEventListener!="function")return;let c=h=>{h.preventDefault(),h.returnValue=""};return window.addEventListener("beforeunload",c),()=>window.removeEventListener("beforeunload",c)},[ne.length]);let ze=n("header",{style:I.header},n("h1",{style:I.title},"\u4E2A\u4EBA\u52A9\u7406"),n("span",{style:I.status},p==="ready"?"\u4E91\u7AEF\u5E38\u9A7B\uFF0C\u5173\u6389\u7A97\u53E3\u4E5F\u4F1A\u7EE7\u7EED":p==="loading"?"\u6B63\u5728\u8FDE\u63A5\u2026":"\u8FDE\u63A5\u4E0D\u53EF\u7528"),n("span",{style:I.spacer}),r?n("button",{type:"button",onClick:r,"aria-label":"\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",title:"\u6253\u5F00\u6216\u91CD\u65B0\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",style:{...I.ghost,display:"inline-flex",alignItems:"center",gap:6}},n("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,"aria-hidden":!0},n("rect",{x:3,y:4,width:18,height:13,rx:2}),n("path",{d:"M8 21h8M12 17v4"})),"\u4E91\u7535\u8111"):null);return n("section",{"data-personal-assistant-conversation":"true",style:I.page,onClick:async c=>{let h=c.target.closest?.('a[href^="cloud-file:"]');if(h){c.preventDefault();try{let i=await V("personal-assistant.file.download",{sessionId:T,path:decodeURIComponent(h.getAttribute("href").slice(11))}),u=Uint8Array.from(atob(i.data),k=>k.charCodeAt(0)),y=URL.createObjectURL(new Blob([u],{type:"application/octet-stream"})),x=document.createElement("a");x.href=y,x.download=i.name,x.click(),setTimeout(()=>URL.revokeObjectURL(y),1e3)}catch(i){S(i.message||"\u4E91\u7AEF\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}}}},ze,n("style",null,"@keyframes pa-awaiting { 0%, 100% { opacity: 0.35 } 50% { opacity: 1 } }"),D&&ee.length>0?n("div",{role:"alert",style:{padding:"8px 16px",background:"#fff0d6"}},D):null,n("div",{ref:Ie,"data-personal-assistant-messages":"true",style:I.scroller,onScroll:c=>{let h=c.currentTarget;ue.current=h.scrollHeight-h.clientHeight-h.scrollTop<64}},n("div",{style:I.thread},ee.length===0?n("div",{style:{...I.status,paddingTop:40,textAlign:"center"}},p==="error"?n("div",{style:{...I.centeredInner,margin:"0 auto"}},n("strong",null,"\u6682\u65F6\u8FDE\u4E0D\u4E0A\u4E2A\u4EBA\u52A9\u7406"),n("span",null,D||"\u8BF7\u7A0D\u540E\u91CD\u8BD5"),n("button",{style:I.ghost,onClick:()=>{ce()}},"\u91CD\u8BD5")):p==="loading"?"\u6B63\u5728\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406\u2026":qt):null,ee.map(c=>{if(c.role==="step")return n("div",{key:c.id,style:I.step},`\xB7 ${c.text}`);let h=c.role==="user";return n("div",{key:c.id,style:h?I.rowUser:I.row},n("span",{style:I.who},h?"\u4F60":"\u52A9\u7406"),n("div",{style:h?I.bubbleUser:I.bubble},h?c.text||"\u2026":gt(n,c.text||"",I)||"\u2026"),c.status==="failed"?n("button",{onClick:()=>{De(G.current.get(c.clientTurnId))},disabled:W},`${c.failure} \xB7 \u91CD\u8BD5\u53D1\u9001`):null)}),M?n("div",{key:"awaiting",style:I.row},n("span",{style:I.who},"\u52A9\u7406"),n("div",{style:{...I.bubble,color:"var(--dsw-alias-label-secondary, #536174)"}},n("span",{style:I.pulse},Be||"\u6B63\u5728\u5904\u7406\u2026"))):null,ne.map(c=>n("div",{key:`queued-${c.clientTurnId}`,style:I.rowUser},n("span",{style:I.who},"\u4F60 \xB7 \u6392\u961F\u4E2D"),n("div",{style:I.queueBubble},`${c.text}${c.uploads?.length?`\uFF08${c.uploads.length} \u4E2A\u9644\u4EF6\u5F85\u53D1\uFF09`:""}`),n("div",{style:I.queueRow},n("span",{style:I.queueHint},c.attempts?"\u4E91\u7535\u8111\u4ECD\u5728\u5904\u7406\u4E0A\u4E00\u8F6E\uFF0C\u7A0D\u540E\u81EA\u52A8\u91CD\u53D1":"\u5DF2\u6392\u961F\uFF0C\u672C\u8F6E\u7ED3\u675F\u540E\u53D1\u9001"),n("button",{type:"button","aria-label":`\u64A4\u56DE\u6392\u961F\u6D88\u606F\uFF1A${c.text.slice(0,24)}`,title:"\u64A4\u56DE\u8FD9\u6761\u6392\u961F\u6D88\u606F",style:I.queueCancel,onClick:()=>pe(c.clientTurnId)},ht(n),"\u64A4\u56DE")))))),n("div",{"data-personal-assistant-composer":"true",style:I.composer},we?n("div",{role:"status",style:I.queueNotice},we):null,n("div",{style:I.composerInner},Y.length>0?n("div",{style:I.attachRow},Y.map(c=>n("span",{key:c.id,style:I.attach},c.mimeType.startsWith("image/")?n("img",{src:c.dataUrl,alt:"",style:I.attachThumb}):null,n("span",{style:I.attachName},c.name),n("button",{"aria-label":`\u79FB\u9664 ${c.name}`,style:{...I.iconButton,width:16,height:16,border:"none"},onClick:()=>L(h=>h.filter(i=>i.id!==c.id))},ht(n))))):null,n("textarea",{"aria-label":"\u7ED9\u4E2A\u4EBA\u52A9\u7406\u53D1\u6D88\u606F",value:ge,rows:1,style:I.textarea,placeholder:p!=="ready"?"\u4E91\u7AEF\u6682\u672A\u8FDE\u63A5\uFF0C\u53EF\u5148\u5199\u4E0B\u6D88\u606F":W||M?"\u672C\u8F6E\u8FDB\u884C\u4E2D\uFF1A\u73B0\u5728\u53D1\u9001\u4F1A\u6392\u961F\uFF0C\u672C\u8F6E\u7ED3\u675F\u540E\u81EA\u52A8\u53D1\u51FA":"\u7ED9\u4E2A\u4EBA\u52A9\u7406\u53D1\u6D88\u606F\uFF0CEnter \u53D1\u9001\uFF0CShift+Enter \u6362\u884C",onChange:c=>X(c.target.value),onKeyDown:c=>{p==="ready"&&c.key==="Enter"&&!c.shiftKey&&!c.nativeEvent?.isComposing&&(c.preventDefault(),De())}}),n("div",{style:I.composerBar},n("button",{"aria-label":"\u6DFB\u52A0\u9644\u4EF6",style:I.iconButton,disabled:p!=="ready"||W,title:"\u4E0A\u4F20\u5230\u4E91\u7535\u8111\uFF1A\u6700\u591A 4 \u4E2A\u6587\u4EF6\uFF0C\u6BCF\u4E2A 512 KiB",onClick:()=>B.current?.click()},Gt(n)),n("input",{ref:B,type:"file",multiple:!0,accept:"image/*,.txt,.md,.json,.pdf",style:{display:"none"},onChange:Fe}),n("span",{style:I.spacer}),ne.length>0?n("span",{role:"status",style:I.queueBadge},`\u6392\u961F\u4E2D ${ne.length}`):null,n("button",{"aria-label":ne.length>0?`\u53D1\u9001\u6D88\u606F\uFF08\u6392\u961F\u4E2D ${ne.length} \u6761\uFF09`:"\u53D1\u9001\u6D88\u606F",title:W||M?"\u672C\u8F6E\u8FDB\u884C\u4E2D\uFF1A\u53D1\u9001\u540E\u4F1A\u6392\u961F\uFF0C\u672C\u8F6E\u7ED3\u675F\u540E\u81EA\u52A8\u53D1\u51FA":"\u53D1\u9001\u6D88\u606F",disabled:p!=="ready"||!ge.trim()&&Y.length===0,style:p!=="ready"||!ge.trim()&&Y.length===0?{...I.send,...I.sendDisabled}:W||M?I.sendQueued:I.send,onClick:()=>{De()}},Xt(n))))))}var xt="personal-assistant-computer",Zt="personal-assistant",wt="\u5F53\u524D Studio \u7684\u539F\u751F\u4FA7\u680F\u7EC4\u4EF6\u9700\u8981\u66F4\u65B0\uFF0C\u8BF7\u5B89\u88C5\u672C\u6B21\u968F\u63D2\u4EF6\u63D0\u4F9B\u7684\u5BBF\u4E3B\u7EC4\u4EF6\u5305\u3002",Jt=()=>Object.assign(new Error(wt),{code:"PERSONAL_ASSISTANT_NATIVE_SIDEBAR_REQUIRED"});function en(t){return t.workbench.render(t)}function vt({sidebarRight:t,slots:g,panelId:d=Zt}={}){let r=typeof t?.registerPanelSurface=="function"&&typeof t?.openPanelTab=="function"&&typeof t?.setPanelExpanded=="function"&&typeof g?.inject=="function"&&typeof g?.register=="function",n=new Set,a,s=!1,o=Object.freeze({binding:void 0}),f=()=>{o=Object.freeze({binding:a});for(let R of[...n])R()},p=()=>{if(!r)throw Jt();if(s)throw new Error("\u4E91\u7535\u8111\u5DE5\u4F5C\u9762\u677F\u5DF2\u5173\u95ED")},E,D,S={available:r,unavailableReason:r?null:wt,subscribe:R=>(n.add(R),()=>n.delete(R)),getSnapshot:()=>o,bind(R,N){if(p(),!R?.agentId||!R?.botId||typeof N!="function")throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");a&&(a.scope.agentId!==R.agentId||a.scope.botId!==R.botId)&&(E(),E=t.registerPanelSurface(d)),a=Object.freeze({scope:Object.freeze({...R}),request:N}),f(),S.open()},open(){p(),a&&t.openPanelTab(d,xt)},collapse(){p(),t.setPanelExpanded(d,!1)},dispose(){s||(s=!0,D?.(),E?.(),n.clear())}};return r&&(E=t.registerPanelSurface(d),D=g.inject("sidebar.right.panel.tab",()=>g.register({name:"sidebar.right.panel.tab",key:xt,inject:()=>({workbench:S})},en))),S}function St({React:t,workbench:g,Panel:d,active:r=!0,fullscreen:n=!1}){let{createElement:a,useSyncExternalStore:s}=t,o=s(g.subscribe,g.getSnapshot,g.getSnapshot);if(!r||!o.binding)return null;let{scope:f,request:p}=o.binding;return a(d,{key:`${f.agentId}:${f.botId}:${f.sessionId||""}`,request:p,initialBotId:f.botId,initialSessionId:f.sessionId,agentId:f.agentId,variant:"native-tab",active:r,nativeFullscreen:n})}var tn="__directory__";function Ze(t){if(!Array.isArray(t)||t.length>128)throw new TypeError("\u52A9\u7406\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");let g=new Set;return t.map(d=>{let r=String(d?.botId||"").trim(),n=String(d?.displayName||r).trim();if(!r||r.length>64||/[\u0000-\u001f]/u.test(r)||r===tn||g.has(r)||!n||n.length>256)throw new TypeError("\u52A9\u7406\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");return g.add(r),{botId:r,displayName:r==="default"&&n==="Personal Assistant"?"\u9ED8\u8BA4\u52A9\u7406":r==="researcher"&&n==="Researcher"?"\u7814\u7A76\u52A9\u7406":n}})}function Je(t,g=""){let d=Ze(t),r=String(g||"").trim(),n=r?d.find(a=>a.botId===r):d.find(a=>a.botId==="default")||(d.length===1?d[0]:void 0);if(!n)throw Object.assign(new Error("\u4E91\u7AEF\u52A9\u7406\u7ED1\u5B9A\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"),{code:"PERSONAL_ASSISTANT_BINDING_UNAVAILABLE"});return n.botId}var tt=class extends Error{constructor(){super("Personal Assistant gateway is not connected"),this.name="PersonalAssistantGatewayUnavailableError",this.code="PERSONAL_ASSISTANT_GATEWAY_UNAVAILABLE"}};var At=Object.freeze(["slots","connection","sidebarRight"]),et="personal-assistant",xn=Object.freeze({enabled:!1,autoConnect:!1}),Ve="personal-assistant-computer",je="2026-10-28T07:46:14.215Z",It=12e3,Ne;function Rt(t){Ne=t}var H={background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #17202c)",border:"1px solid var(--dsw-alias-border-default, #d8dee8)"},Et=t=>typeof t?.message=="string"&&t.message&&!/^(fetch failed|Failed to fetch)$/u.test(t.message)?t.message.slice(0,180):"\u4E91\u7535\u8111\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",Tt=t=>t?.code==="PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE"&&Number(t?.status)===409?"\u5F53\u524D\u4E91\u7AEF\u7248\u672C\u5C1A\u4E0D\u652F\u6301\u52A9\u7406\u5217\u8868\uFF0C\u8BF7\u66F4\u65B0\u4E91\u7AEF\u52A9\u7406\u540E\u91CD\u8BD5":"\u8FDE\u63A5\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5",nn=t=>Number(t?.status)===409&&["PERSONAL_ASSISTANT_DIRECTORY_UNSUPPORTED","PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE"].includes(t?.code),rn={Control:"Control_L",Meta:"Super_L",Alt:"Alt_L",Shift:"Shift_L",Enter:"Return",Escape:"Escape",Tab:"Tab",Backspace:"BackSpace",Delete:"Delete",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right"," ":"space"};function kt({request:t,initialBotId:g="",openInSidebar:d=null,variant:r="page",nativeFullscreen:n=!1}={}){let a=Ne||globalThis.React;if(!a)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:s,useEffect:o,useRef:f,useState:p}=a,[E,D]=p(null),[S,R]=p([]),[N,T]=p(""),[$,ee]=p(null),[v,ge]=p(!1),[X,Y]=p(g),[L,B]=p("loading"),[W,O]=p(""),[M,te]=p(!0),[Be,_e]=p(0),[ne,xe]=p(0),[we,q]=p("observe"),[ie,G]=p(null),[U,ve]=p(""),[K,Se]=p(""),P=f(null),de=f(null),he=f(null),C=f(null),Ie=f(null),ue=f(null),j=f(null),V=f(n);V.current=n;let w=f({mounted:!0,socket:null,generation:0,frameEpoch:0,session:null,suspended:!1,resuming:!1,pendingInputs:[],display:{width:1280,height:800},readOnly:!0,botId:X,config:null,reconnect:null,firstFrame:null,receivedSeq:-1,pendingFrame:null,decoding:!1,frames:0,lastMove:0,pressed:new Set,buttons:new Set,composition:!1,retries:0,taskId:"",mode:"control",frameMetadata:null,reconnectAllowed:!1});w.current.botId=X;let re=async(e,l={})=>{if(typeof t!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return t(e,l)},ce=e=>{let l=w.current;return l.socket?.readyState!==1?!1:(l.socket.send(JSON.stringify(e)),!0)},Fe=()=>{let e=w.current;for(let l of e.pressed)P.current?.input({type:"key",action:"up",key:l});for(let l of e.buttons)P.current?.input({type:"button",action:"up",button:l});e.pressed.clear(),e.buttons.clear()},be=()=>{for(let e of w.current.buttons)P.current?.input({type:"button",action:"up",button:e});w.current.buttons.clear()};P.current||(P.current=st({send:ce,changed:e=>{let l=w.current;l.controlPhase=e.phase,l.readOnly=e.readOnly,l.controlEpoch=e.controlEpoch,e.readOnly&&j.current&&(j.current.style.visibility="hidden"),e.phase==="observe"&&(l.pressed.clear(),l.buttons.clear()),l.mounted&&(te(e.readOnly),q(e.phase))},failed:e=>{w.current.mounted&&O(e)}})),de.current||(de.current=it({send:ce,controlEpoch:()=>P.current?.snapshot?.controlEpoch}));let Ce=()=>{Fe(),P.current.release(),w.current.pressed.clear(),w.current.buttons.clear()},oe=()=>{let e=w.current;e.pointerFrame&&cancelAnimationFrame(e.pointerFrame),e.pointerFrame=null;let l=e.lastPointer;e.lastPointer=null,l&&(!e.readOnly||e.controlPhase==="acquiring")&&(!e.sentPointer||l.x!==e.sentPointer.x||l.y!==e.sentPointer.y)&&(P.current.input({type:"pointermove",...l}),e.sentPointer=l)},Pe=()=>{clearTimeout(w.current.reconnect),clearTimeout(w.current.firstFrame),w.current.reconnect=null,w.current.firstFrame=null},ye=(e=!0)=>{let l=w.current;l.reconnectAllowed=!1,Pe(),Ce(),l.generation+=1,de.current?.rejectAll();try{ce({type:"close"}),l.socket?.close(1e3,"panel closed")}catch{}P.current.reset({readOnly:!0}),l.lastDrawnFrame=null,l.socket=null,l.session=null,l.pendingFrame=null,l.frameMetadata=null,l.readOnly=!0,Ie.current?.blur(),l.suspended=!1,l.resuming=!1,l.pendingInputs=[],l.frameEpoch++,e&&l.mounted&&(B(l.config?.configured?"idle":"unconfigured"),te(!0))},z=e=>{ye(!1),te(!0),B("closed"),O(e?.reason==="lease-lost"||Number(e?.status)===409?"\u63A7\u5236\u79DF\u7EA6\u5DF2\u5931\u6548\uFF0C\u684C\u9762\u8FDE\u63A5\u5DF2\u5173\u95ED\uFF1B\u8BF7\u91CD\u65B0\u8FDE\u63A5\u6216\u9009\u62E9\u53EA\u8BFB\u65C1\u89C2":e?.code==="DESKTOP_SESSION_NOT_FOUND"||Number(e?.status)===404?"\u684C\u9762\u4F1A\u8BDD\u5DF2\u7ED3\u675F\uFF08\u53EF\u80FD\u56E0\u7A7A\u95F2\u8D85\u65F6\uFF09\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5":"\u684C\u9762\u8FDE\u63A5\u5DF2\u7ED3\u675F\uFF0C\u53EF\u91CD\u65B0\u8FDE\u63A5\u4E91\u7535\u8111")},pe=e=>{let l=w.current;if(e.type!=="pointermove"&&oe(),l.suspended||l.resuming){if(e.type==="pointermove")return!1;let A=l.mode==="control";if(A){if(l.pendingInputs.length>=32)return ye(),O("\u6062\u590D\u671F\u95F4\u8F93\u5165\u8FC7\u5FEB\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5"),!1;l.pendingInputs.push(e)}return l.resuming||y(),A}return!l.session||l.socket?.readyState!==1?(O("\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8F93\u5165\u672A\u53D1\u9001"),!1):P.current.input(e)},De=e=>{w.current.mounted&&(Se(e),he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{w.current.mounted&&Se("")},4e3))},ze=e=>{let l=!1;for(let A of e)l=pe(A)||l;return l},c=async()=>{let e=/Mac|iPhone|iPad/u.test(String(globalThis.navigator?.platform||""))?"Meta":"Control";if(!w.current.pressed.has("_copyShortcut")){w.current.pressed.add("_copyShortcut");try{ze([{type:"key",action:"down",key:e},{type:"key",action:"down",key:"c"},{type:"key",action:"up",key:"c"},{type:"key",action:"up",key:e}]),await new Promise(l=>setTimeout(l,150))}finally{w.current.pressed.delete("_copyShortcut")}}return ut({readCloud:()=>de.current.read(),notify:De})},h=()=>dt({readLocal:()=>Xe(),writeCloud:e=>de.current.write(e),sendKeys:ze,notify:De}),i=async()=>{let e=w.current;if(!e.decoding){e.decoding=!0;try{for(;e.pendingFrame;){let l=e.pendingFrame;e.pendingFrame=null;let A;try{if(A=await createImageBitmap(new Blob([l.bytes],{type:"image/jpeg"})),!e.mounted||e.suspended||l.frameEpoch!==e.frameEpoch||l.generation!==e.generation||l.seq<e.receivedSeq||!C.current)continue;e.lastDrawnFrame=l;let b=C.current,J=b.getBoundingClientRect(),le=Math.max(1,globalThis.devicePixelRatio||1);b.width=Math.max(1,Math.round(J.width*le)),b.height=Math.max(1,Math.round(J.height*le));let Q=b.getContext("2d"),se=e.display,Le=Math.min(b.width/se.width,b.height/se.height),ke=se.width*Le,_=se.height*Le;Q.clearRect(0,0,b.width,b.height),Q.drawImage(A,(b.width-ke)/2,(b.height-_)/2,ke,_);let Ae=e.firstFrame!==null;e.frames+=1,clearTimeout(e.firstFrame),e.firstFrame=null,e.retries=0,Ae&&O(""),B(e.readOnly?"readonly":"ready"),_e(0)}catch{e.mounted&&O("\u684C\u9762\u5E27\u65E0\u6CD5\u89E3\u7801\uFF0C\u8BF7\u91CD\u8BD5")}finally{A?.close()}}}finally{e.decoding=!1}}},u=e=>{let l=w.current;clearTimeout(l.firstFrame),l.firstFrame=null,l.suspended=!0,l.resuming=!1,l.readOnly=!0,l.pendingInputs=[],l.frameEpoch++,l.pendingFrame=null,l.frameMetadata=null,l.pressed.clear(),l.buttons.clear(),l.frames=0,xe(0),te(!0),B("dormant"),O(e?.leaseReleased===!1?"\u5DF2\u7A7A\u95F2\uFF0C\u753B\u9762\u5DF2\u6682\u505C\uFF1B\u63A7\u5236\u6743\u4ECD\u7531\u5916\u90E8\u4EFB\u52A1\u7BA1\u7406":"\u5DF2\u7A7A\u95F2\uFF0C\u63A7\u5236\u6743\u5DF2\u91CA\u653E\uFF1B\u64CD\u4F5C\u684C\u9762\u5373\u53EF\u6062\u590D")},y=()=>{let e=w.current;if(e.resuming||!e.suspended)return;if(e.socket?.readyState!==1){x(e.mode,!1,e.pendingInputs);return}e.resuming=!0,B("resuming"),O("\u6B63\u5728\u6062\u590D\u684C\u9762\u5E76\u68C0\u67E5\u63A7\u5236\u6743\uFF0C\u8BF7\u7A0D\u5019\u3002"),ce({type:"resume",mode:e.mode,activity:!0});let l=e.generation,A=e.socket;e.firstFrame=setTimeout(()=>{e.mounted&&e.generation===l&&e.firstFrame!==null&&A.close(4e3,"resume frame timeout")},It)},x=async(e="read",l=!1,A=[])=>{let b=w.current,J=String(b.botId||"").trim();if(!b.config?.configured){B("unconfigured");return}if(!J||!b.bots?.some(Q=>Q.botId===J)){O("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");return}ye(!1),b.pendingInputs=A,b.resuming=A.length>0;let le=++b.generation;b.reconnectAllowed=!0,l||(b.retries=0),b.mode=e,b.taskId||=`studio-desktop-${globalThis.crypto.randomUUID()}`,b.receivedSeq=-1,b.frameMetadata=null,B(l?"reconnecting":"connecting"),O("\u9996\u6B21\u6216\u4F11\u7720\u540E\u8FDE\u63A5\u53EF\u80FD\u9700\u8981\u6570\u79D2\uFF0C\u8BF7\u7A0D\u5019\u3002");try{let Q=await re("personal-assistant.desktop.ticket",{agentId:b.config.agentId,botId:J,mode:e==="observe"?"control":e});if(!b.mounted||le!==b.generation)return;let se=new WebSocket(Q.wsUrl,["agentkit.personal-assistant.desktop.v1",`agentkit.desktop.ticket.${Q.ticket}`]);se.binaryType="arraybuffer",b.socket=se;let Le=()=>b.mounted&&b.generation===le;se.onopen=()=>{if(!Le()){se.close();return}ce({type:"open",botId:J,taskId:b.taskId,mode:e,...Q.leaseId?{leaseId:Q.leaseId}:{}}),b.firstFrame=setTimeout(()=>{Le()&&(O("\u4E91\u7535\u8111\u54CD\u5E94\u8F83\u6162\uFF0C\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5"),se.close(4e3,"first frame timeout"))},It)},se.onmessage=ke=>{if(!Le())return;if(typeof ke.data!="string"){let Ae=b.frameMetadata;b.frameMetadata=null;let Ue=ke.data;if(!Ae||!Number.isSafeInteger(Ae.seq)||Ae.seq<=b.receivedSeq||!(Ue instanceof ArrayBuffer)||Ue.byteLength===0||Ue.byteLength>307200||b.suspended)return;b.receivedSeq=Ae.seq,b.pendingFrame={bytes:Ue,seq:Ae.seq,generation:le,frameEpoch:b.frameEpoch},i();return}let _;try{_=JSON.parse(ke.data)}catch{return}if(_.type==="ready"){b.suspended=!1,b.resuming=!1,b.receivedSeq=-1,b.session=_.sessionId,b.readOnly=!!_.readOnly,b.display=Qe(_.display),b.mode=e,P.current.reset(_);let Ae=b.pendingInputs;if(b.pendingInputs=[],b.readOnly)b.pressed.clear(),b.buttons.clear();else for(let Ue of Ae)P.current.input(Ue);te(b.readOnly),O("\u4E91\u7535\u8111\u5DF2\u8FDE\u63A5\uFF0C\u6B63\u5728\u51C6\u5907\u684C\u9762\u753B\u9762");return}if(_.type==="control"){P.current.accept(_),O("");return}if(_.type==="idle"){u(_);return}if(_.type==="frame"){_.unchanged||(b.frameMetadata=_);return}if(_.type==="clipboard.response"){de.current?.accept(_);return}if(_.type==="closed"){_.retryable!==!0&&z(_);return}if(_.type==="error"){if(Number.isSafeInteger(_.controlEpoch)&&_.controlEpoch<b.controlEpoch)return;if(O(_.message||_.code||"\u4E91\u7535\u8111\u8BF7\u6C42\u5931\u8D25"),b.handoffSupported&&_.recoverable===!0){P.current.reject(_);return}if(_.recoverable===!0&&Number(_.status)===409){_.code==="DESKTOP_SESSION_IDLE"?u():(b.pendingInputs=[],b.readOnly=!0,b.pressed.clear(),b.buttons.clear(),te(!0),B("readonly"));return}if(Number(_.status)===409&&e==="control"&&!b.session){x(w.current.handoffSupported?"observe":"read");return}[404,409].includes(Number(_.status))||_.code==="DESKTOP_SESSION_NOT_FOUND"?z(_):b.session||(B("error"),ye(!1))}},se.onerror=()=>{Le()&&O("\u684C\u9762\u901A\u9053\u6682\u65F6\u65AD\u5F00\uFF0C\u6B63\u5728\u91CD\u8FDE")},se.onclose=ke=>{if(!Le())return;if(b.suspended&&ke.code!==1e3){clearTimeout(b.firstFrame),b.firstFrame=null,b.socket=null,B("dormant");return}if(b.session=null,clearTimeout(b.firstFrame),b.firstFrame=null,!b.reconnectAllowed||ke.code===1e3){z();return}if(document.hidden){B("hidden");return}let _=++b.retries;if(_e(_),_>5){b.reconnectAllowed=!1,B("error"),O("\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7535\u8111\uFF0C\u8BF7\u68C0\u67E5\u5B9E\u4F8B\u72B6\u6001\u6216\u7F51\u7EDC\u540E\u91CD\u8BD5");return}B("reconnecting"),b.reconnect=setTimeout(()=>{x(e,!0,b.pendingInputs)},Math.min(8e3,1e3*2**(_-1)))}}catch(Q){b.mounted&&le===b.generation&&(B("error"),O(Tt(Q)))}},k=async e=>{if(e?.aborted)return null;try{let l=await re("personal-assistant.desktop.status");return l&&typeof l=="object"?l:null}catch(l){return l?.code==="PERSONAL_ASSISTANT_OPERATION_UNAVAILABLE"||l?.status===404?null:{configured:!1,reason:"unavailable",detail:Et(l),candidates:[]}}},fe=async e=>{if(!U){ve(e),O(e==="create"?"\u6B63\u5728\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406\uFF0C\u53EF\u80FD\u9700\u8981\u51E0\u5206\u949F\u2026":"\u6B63\u5728\u83B7\u53D6\u4E91\u7AEF\u8FDE\u63A5\u51ED\u8BC1\u2026");try{await re(`personal-assistant.desktop.${e}`),O(""),await F()}catch(l){O(Et(l)),G(await k().catch(()=>null))}finally{ve("")}}},F=async(e,l=!1)=>{ye(!1),B("loading"),O(""),T(""),ee(null);try{let A=await re("personal-assistant.configuration");if(e?.aborted||!w.current.mounted)return;if(w.current.config=A,D(A),!A.configured){let Q=await k(e);if(e?.aborted||!w.current.mounted)return;if(w.current.bots=[],R([]),Y(""),G(Q),B("unconfigured"),Q?.configured&&!l){await F(e,!0);return}return}G(null);let b=await re("personal-assistant.bots.list");if(e?.aborted||!w.current.mounted)return;if(b.directoryAvailable!==!0)throw Object.assign(new Error("directory unavailable"),{code:"PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE",status:409});let J=Ze(b.bots);w.current.bots=J,w.current.handoffSupported=b.features?.includes("desktop-handoff/v1")===!0,R(J);let le=J.length?Je(J,g||A.botId):"";w.current.botId=le,Y(le),B(J.length?"idle":"empty"),le&&["computer","native-tab"].includes(r)&&x(w.current.handoffSupported?"observe":"read")}catch(A){if(e?.aborted||!w.current.mounted)return;Number.isInteger(A?.closeCode)&&A.closeCode>=1e3&&A.closeCode<=4999&&ee(A.closeCode),w.current.bots=[],R([]),Y(""),B("directory-error"),T(nn(A)?"\u4E91\u7AEF\u52A9\u7406\u9700\u8981\u66F4\u65B0\uFF0C\u8BF7\u66F4\u65B0\u540E\u91CD\u65B0\u8FDE\u63A5\u3002":Tt(A))}};o(()=>{let e=w.current;e.mounted=!0;let l=new AbortController;F(l.signal);let A=setInterval(()=>{e.mounted&&xe(e.frames),e.frames=0},1e3),b=()=>{document.hidden?(Ce(),ce({type:"pause"})):e.socket?.readyState===1?ce({type:"resume"}):e.reconnectAllowed&&e.config?.configured&&e.session===null&&e.socket&&x(e.mode,!0)},J=typeof ResizeObserver=="function"?new ResizeObserver(()=>{e.lastDrawnFrame&&(e.pendingFrame=e.lastDrawnFrame,i())}):null;C.current&&J?.observe(C.current);let le=()=>Ce(),Q=se=>{ue.current?.contains(se.target)||Ce()};return document.addEventListener("visibilitychange",b),window.addEventListener("blur",le),document.addEventListener("pointerdown",Q,!0),()=>{e.mounted=!1,J?.disconnect(),e.pointerFrame&&cancelAnimationFrame(e.pointerFrame),l.abort(),ye(!1),clearInterval(A),document.removeEventListener("visibilitychange",b),window.removeEventListener("blur",le),document.removeEventListener("pointerdown",Q,!0)}},[t]);let me=e=>ot({clientX:e.clientX,clientY:e.clientY,rect:C.current.getBoundingClientRect(),display:w.current.display}),Me=e=>{e.preventDefault();let l=w.current,A=[1,2,3][e.button]||1;e.type==="pointerdown"?(Ie.current?.focus(),C.current?.setPointerCapture(e.pointerId),pe({type:"button",action:"down",button:A,...me(e)})&&l.buttons.add(A)):(pe({type:"button",action:"up",button:A,...me(e)}),l.buttons.delete(A),C.current?.hasPointerCapture(e.pointerId)&&C.current.releasePointerCapture(e.pointerId))},We=e=>{if(w.current.composition||e.isComposing||e.nativeEvent?.isComposing||e.key==="Process"||e.key==="Unidentified")return;if(lt(e)){e.preventDefault(),h();return}if(ct(e)){e.preventDefault(),e.type==="keydown"&&!e.repeat&&c();return}let l=e.ctrlKey||e.metaKey||e.altKey;if(e.key.length===1&&!l||e.key==="Escape"&&V.current)return;e.preventDefault();let A=rn[e.key]||e.key;/^[A-Za-z0-9_]+$/u.test(A)&&(e.type==="keydown"?!e.repeat&&pe({type:"key",action:"down",key:A})&&w.current.pressed.add(A):(pe({type:"key",action:"up",key:A}),w.current.pressed.delete(A)))},Ye={loading:"\u6B63\u5728\u68C0\u67E5\u52A9\u7406\u72B6\u6001",idle:"\u51C6\u5907\u8FDE\u63A5",dormant:"\u5DF2\u7A7A\u95F2",resuming:"\u6B63\u5728\u6062\u590D\u684C\u9762",unconfigured:"\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A",empty:"\u6682\u65F6\u6CA1\u6709\u53EF\u7528\u52A9\u7406","directory-error":"\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u52A9\u7406\u5217\u8868",connecting:"\u6B63\u5728\u542F\u52A8\u4E91\u7535\u8111",readonly:"\u53EA\u8BFB\u65C1\u89C2",ready:"\u6B63\u5728\u63A7\u5236\u4E91\u7535\u8111",reconnecting:"\u6B63\u5728\u6062\u590D\u8FDE\u63A5",hidden:"\u753B\u9762\u5DF2\u6682\u505C",closed:"\u684C\u9762\u8FDE\u63A5\u5DF2\u7ED3\u675F",error:"\u8FDE\u63A5\u6682\u65F6\u4E0D\u53EF\u7528"}[L],Ee={...H,borderRadius:6,padding:"7px 12px",cursor:"pointer",font:"inherit"},Z=["ready","readonly","hidden","reconnecting","dormant","resuming"].includes(L),Oe=S.length>0,Te=ie?.reason||"",Ct=Array.isArray(ie?.candidates)?ie.candidates.length:0,Dt=Te==="needs-create"?"\u8FD8\u6CA1\u6709\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406":Te==="credential-unavailable"?"\u6B63\u5728\u6062\u590D\u4E2A\u4EBA\u52A9\u7406\u7684\u8FDE\u63A5\u51ED\u8BC1":Te==="unavailable"?"\u6682\u65F6\u65E0\u6CD5\u81EA\u52A8\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406":"\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A",Ot=Te==="needs-create"?"\u4E91\u8D26\u53F7\u4E0B\u8FD8\u6CA1\u6709\u4E2A\u4EBA\u52A9\u7406\u5B9E\u4F8B\uFF0C\u521B\u5EFA\u540E\u5373\u53EF\u5728\u8FD9\u91CC\u8FDE\u63A5\u4E13\u5C5E\u4E91\u7535\u8111\u3002":Te==="credential-unavailable"?"\u4E91\u7AEF\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u8FDE\u63A5\u51ED\u8BC1\uFF0C\u53EF\u4EE5\u91CD\u65B0\u83B7\u53D6\u3002":Te==="unavailable"?ie?.detail||"\u8BF7\u68C0\u67E5\u4E91\u7AEF\u767B\u5F55\u72B6\u6001\u540E\u91CD\u8BD5\u3002":"\u5F00\u901A\u5B8C\u6210\u540E\uFF0C\u5373\u53EF\u5728\u8FD9\u91CC\u8FDE\u63A5\u4E13\u5C5E\u4E91\u7535\u8111\u3002",Lt=L==="unconfigured"?Dt:L==="empty"?"\u52A9\u7406\u6B63\u5728\u51C6\u5907\u4E2D":L==="directory-error"?"\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406":"\u6B63\u5728\u68C0\u67E5\u52A9\u7406\u72B6\u6001",Nt=L==="unconfigured"?Ot:L==="empty"?"\u4E91\u7AEF\u521D\u59CB\u5316\u5B8C\u6210\u540E\uFF0C\u53EF\u7528\u52A9\u7406\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002":L==="directory-error"?N:"\u8BF7\u7A0D\u5019",He=r==="computer"||r==="native-tab",nt=s("div",{ref:ue,"data-personal-assistant-desktop-card":He?"true":void 0,style:{position:"relative",background:"var(--dsw-alias-bg-layer-2, #f1f3f6)",...He?{width:"100%",aspectRatio:`${w.current.display.width} / ${w.current.display.height}`,flex:"none",minWidth:0,borderRadius:14,overflow:"hidden",boxShadow:"0 0 0 1px var(--dsw-alias-border-default, #d8dee8), 0 8px 28px #1018280d"}:{flex:1,minHeight:240}}},["dormant","resuming"].includes(L)?s("div",{role:"status",style:{position:"absolute",inset:0,zIndex:1,pointerEvents:"none",display:"grid",placeItems:"center",padding:16,textAlign:"center",background:"color-mix(in srgb, var(--dsw-alias-bg-layer-1, #fff) 82%, transparent)",color:"var(--dsw-alias-label-primary, #17202c)"}},L==="dormant"?"\u5DF2\u7A7A\u95F2\uFF0C\u64CD\u4F5C\u684C\u9762\u5373\u53EF\u6062\u590D":"\u6B63\u5728\u6062\u590D\u684C\u9762\u2026"):null,s("canvas",{ref:C,"aria-label":"\u4E91\u7535\u8111\u684C\u9762",tabIndex:Z?0:-1,onPointerDown:Me,onPointerUp:Me,onPointerCancel:be,onLostPointerCapture:be,onPointerLeave:()=>{j.current&&(j.current.style.visibility="hidden")},onPointerMove:e=>{let l=w.current,A=e.nativeEvent?.getCoalescedEvents?.().at(-1)||e;if(j.current){let b=C.current.getBoundingClientRect();j.current.style.transform=`translate(${A.clientX-b.left}px, ${A.clientY-b.top}px)`,j.current.style.visibility=l.readOnly?"hidden":"visible"}l.lastPointer=me(A),l.pointerFrame||(l.pointerFrame=requestAnimationFrame(()=>{l.mounted&&oe()}))},onContextMenu:e=>e.preventDefault(),onWheel:e=>{e.preventDefault(),pe({type:"wheel",deltaY:e.deltaY/100,deltaX:e.deltaX/100})},onKeyDown:We,onKeyUp:We,style:{...He?{position:"absolute",inset:0}:{},width:"100%",height:"100%",display:"block",visibility:Z?"visible":"hidden",pointerEvents:Z?"auto":"none",touchAction:"none",cursor:M?"default":"none"}}),s("div",{ref:j,"aria-hidden":!0,style:{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",zIndex:2,width:18,height:22}},s("svg",{viewBox:"0 0 18 22",width:18,height:22},s("path",{d:"M1 1v16l4-4 3 7 3-1-3-7h6z",fill:"#fff",stroke:"#162033",strokeWidth:1.2}))),Z?null:s("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,padding:16,textAlign:"center"}},s("h2",{style:{margin:0,fontSize:18,fontWeight:500}},Oe?Ye:Lt),s("p",{style:{margin:0,maxWidth:380,lineHeight:1.7,color:"var(--dsw-alias-label-secondary, #536174)"}},Oe?W||"\u8FDE\u63A5\u540E\u5373\u53EF\u4F7F\u7528\u4E91\u7AEF\u684C\u9762\uFF0C\u5173\u95ED\u9762\u677F\u4F1A\u91CA\u653E\u672C\u6B21\u63A7\u5236\u3002":Nt),!Oe&&L!=="loading"?s("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",alignItems:"center"}},L==="unconfigured"&&Te==="needs-create"?s("button",{style:Ee,disabled:!!U,onClick:()=>{fe("create")}},U==="create"?"\u6B63\u5728\u521B\u5EFA\u2026":"\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406"):null,L==="unconfigured"&&(Te==="credential-unavailable"||Ct>0)?s("button",{style:Ee,disabled:!!U,onClick:()=>{fe("connect")}},U==="connect"?"\u6B63\u5728\u83B7\u53D6\u2026":Te==="credential-unavailable"?"\u91CD\u65B0\u83B7\u53D6\u8FDE\u63A5\u51ED\u8BC1":"\u8FDE\u63A5\u5DF2\u53D1\u73B0\u7684\u4E2A\u4EBA\u52A9\u7406"):null,s("button",{style:{...Ee,background:"transparent"},disabled:!!U,onClick:()=>{F()}},"\u68C0\u67E5\u5F00\u901A\u72B6\u6001"),U?s("span",{role:"status",style:{color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12}},"\u5904\u7406\u4E2D\uFF0C\u8BF7\u7A0D\u5019\u2026"):null):null),s("input",{ref:Ie,"aria-label":"\u4E91\u7535\u8111\u6587\u672C\u8F93\u5165",autoComplete:"off",disabled:!Z||M&&!P.current.snapshot.available&&!(w.current.mode==="control"&&["dormant","resuming"].includes(L)),tabIndex:-1,style:{position:"absolute",width:1,height:1,opacity:0,left:0,top:0},onKeyDown:We,onKeyUp:We,onCompositionStart:()=>{w.current.composition=!0},onCompositionEnd:e=>{w.current.composition=!1;let l=e.currentTarget.value;e.currentTarget.value="",l&&pe({type:"text",text:l})},onInput:e=>{if(w.current.composition||e.nativeEvent?.isComposing)return;let l=e.currentTarget.value;e.currentTarget.value="",l&&pe({type:"text",text:l})}})),$e="var(--dsw-alias-label-secondary, #536174)",dn={...Ee,background:"transparent",color:"inherit",border:H.border},rt={...Ee,borderRadius:999,padding:"7px 16px",border:"none",fontWeight:500,background:"var(--dsw-alias-label-primary, #17202c)",color:"var(--dsw-alias-bg-layer-1, #fff)"};return He?s("section",{"data-personal-assistant-computer":"true",style:{...H,border:"none",height:"100%",minHeight:0,minWidth:0,display:"flex",flexDirection:"column",background:"var(--dsw-alias-bg-base, #fff)",color:"inherit",fontSize:13}},r!=="native-tab"?s("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:H.border}},s("strong",{style:{fontWeight:500}},"\u4E91\u7535\u8111"),s("span",{role:"status","aria-live":"polite",style:{color:$e,fontSize:12}},Ye),null):null,M&&Z&&!P.current.snapshot.available?s("div",{role:"alert",style:{background:"#fff0d6",color:"#763c00",padding:"8px 12px"}},"\u53EA\u8BFB\u65C1\u89C2\uFF1A\u9F20\u6807\u548C\u952E\u76D8\u4E0D\u4F1A\u53D1\u9001\u5230\u4E91\u7535\u8111"):null,s("div",{"data-personal-assistant-desktop-layout":"true",style:{flex:1,minHeight:0,minWidth:0,overflow:"auto",display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:"20px 16px 12px",boxSizing:"border-box"}},s("div",{"data-personal-assistant-desktop-stack":"true",style:{width:"100%",maxWidth:1280,margin:"auto 0",display:"flex",flexDirection:"column",alignItems:"center",gap:12,flex:"none"}},nt,Z||Oe?s("div",{"data-personal-assistant-control-capsule":"true",role:"status","aria-live":"polite",style:{display:"flex",flexWrap:"wrap",justifyContent:"center",alignItems:"center",gap:6,width:"fit-content",maxWidth:"100%",boxSizing:"border-box",padding:"7px 12px",borderRadius:999,background:"var(--dsw-alias-bg-layer-1, #fff)",border:H.border,boxShadow:"0 1px 4px #10182808",lineHeight:1.5}},!Z&&Oe?s("button",{style:rt,disabled:["connecting","resuming"].includes(L),onClick:()=>{x(w.current.handoffSupported?"observe":"read")}},L==="connecting"?"\u6B63\u5728\u542F\u52A8\u2026":"\u91CD\u65B0\u8FDE\u63A5"):null,Z&&M?s("span",{style:{color:$e,fontSize:12}},we==="acquiring"?"\u6B63\u5728\u63A5\u7BA1\u2026":we==="releasing"?"\u6B63\u5728\u4EA4\u8FD8\u2026":"\u52A9\u7406\u6B63\u5728\u4F7F\u7528 \xB7 \u70B9\u753B\u9762\u5373\u53EF\u63A5\u7BA1"):null,Z&&M&&P.current.snapshot.available?s("button",{style:{...rt,padding:"3px 9px",fontSize:11},onClick:()=>P.current.acquire()},"\u63A5\u7BA1"):null,Z&&!M?s("span",{style:{color:$e,fontSize:12}},"\u60A8\u62E5\u6709\u63A7\u5236\u6743 \xB7 \u70B9\u753B\u9762\u5916\u91CA\u653E"):null,Z&&W?s("span",{style:{color:$e,fontSize:12}},W):null,Z&&K?s("span",{role:"status","aria-live":"polite",style:{color:$e,fontSize:12}},K):null):null),s("details",{style:{alignSelf:"flex-end",color:"var(--dsw-alias-label-tertiary, #76808e)",fontSize:11,opacity:.8,maxWidth:"100%",overflowWrap:"anywhere"}},s("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),s("small",{"data-personal-assistant-build":je},`\u6784\u5EFA ${je}`)))):s("section",{"data-personal-assistant-panel":"true",style:{...H,border:"none",height:"100%",minHeight:0,display:"flex",flexDirection:"column",fontSize:13}},s("header",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center",padding:12,borderBottom:H.border}},s("strong",{style:{fontWeight:500,marginRight:8}},"\u4E2A\u4EBA\u52A9\u7406"),Oe&&["idle","closed","error"].includes(L)?s("button",{style:Ee,onClick:()=>{F()}},"\u5237\u65B0\u52A9\u7406\u5217\u8868"):null,typeof d=="function"?s("button",{style:Ee,onClick:d},"\u653E\u5230\u53F3\u4FA7\u680F"):null,Oe?s("button",{style:Ee,disabled:["connecting","resuming"].includes(L),onClick:()=>L==="dormant"?y():void x(w.current.handoffSupported?"observe":"control")},L==="dormant"?"\u6062\u590D\u753B\u9762":M&&L==="readonly"?"\u7533\u8BF7\u63A7\u5236":Z?"\u91CD\u65B0\u8FDE\u63A5":"\u8FDE\u63A5\u4E91\u7535\u8111"):null,Oe?s("button",{style:Ee,disabled:L==="connecting",onClick:()=>{x("read")}},"\u53EA\u8BFB\u65C1\u89C2"):null,Z?s("span",{role:"status","aria-live":"polite",style:{marginLeft:"auto",color:"var(--dsw-alias-label-secondary, #536174)"}},Ye):null),L==="readonly"?s("div",{role:"alert",style:{background:"#fff0d6",color:"#763c00",padding:"8px 12px"}},"\u5F53\u524D\u4E3A\u53EA\u8BFB\u65C1\u89C2\uFF0C\u9F20\u6807\u548C\u952E\u76D8\u8F93\u5165\u4E0D\u4F1A\u53D1\u9001\uFF1B\u53EF\u7533\u8BF7\u63A7\u5236"):null,Z&&W?s("div",{role:"status",style:{padding:"8px 12px"}},W):null,nt,s("footer",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:12,padding:"7px 12px",color:"var(--dsw-alias-label-secondary, #536174)",borderTop:H.border}},s("details",{open:v,onToggle:e=>ge(e.currentTarget.open)},s("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),$?s("div",{style:{paddingTop:8}},`\u76EE\u5F55\u8FDE\u63A5\u5173\u95ED\u7801\uFF1A${$}`):null,s("div",{style:{paddingTop:8,lineHeight:1.8,overflowWrap:"anywhere"}},s("div",null,`\u4E91\u7AEF\u5B9E\u4F8B\uFF1A${E?.agentId||"\u672A\u5F00\u901A"}`),s("div",null,`\u8FDE\u63A5\u6807\u8BC6\uFF1A${X||"\u672A\u8FDE\u63A5"}`),s("div",null,`\u753B\u9762\u5E27\u7387\uFF1A${ne} fps`),s("div",null,"\u5FEB\u6377\u952E\u4F1A\u8F6C\u53D1\u5230\u4E91\u7535\u8111\uFF1BEsc \u4F18\u5148\u9000\u51FA\u5168\u5C4F"))),s("small",{"data-personal-assistant-build":je,style:{opacity:.75}},`\u6784\u5EFA ${je}`)))}function on({request:t,nativeWorkbench:g}={}){let d=Ne||globalThis.React;if(!d)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:r,useEffect:n,useState:a,useCallback:s}=d,[o,f]=a(null),[p,E]=a(""),[D,S]=a(0);n(()=>{let N=!1;return f(null),E(""),(async()=>{try{let T=await t("personal-assistant.configuration");if(!T.configured)throw new Error("\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A\uFF0C\u8BF7\u5148\u5728\u8BBE\u7F6E\u4E2D\u8FDE\u63A5\u4E91\u7AEF\u5B9E\u4F8B");let $=await t("personal-assistant.bots.list");if($.directoryAvailable!==!0)throw new Error("\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");let ee=Je($.bots,T.botId||$.primaryBotId);N||f({agentId:T.agentId,botId:ee})}catch(T){N||E(T.message||"\u4E91\u7AEF\u52A9\u7406\u6682\u4E0D\u53EF\u7528")}})(),()=>{N=!0}},[t,D]);let R=s((N,T={})=>{if(!o)throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");if(T.agentId&&T.agentId!==o.agentId)throw new Error("\u4E91\u7AEF\u5B9E\u4F8B\u4E0D\u4E00\u81F4");if(N!=="personal-assistant.bots.list"&&T.botId&&T.botId!==o.botId)throw new Error("\u4E91\u7AEF\u52A9\u7406\u4E0D\u4E00\u81F4");return t(N,{...T,...o})},[t,o?.agentId,o?.botId]);return n(()=>{o&&g?.available?g.bind(o,R):o&&E(g?.unavailableReason||"\u5F53\u524D\u5BBF\u4E3B\u9700\u8981\u66F4\u65B0\u539F\u751F\u4FA7\u680F\u7EC4\u4EF6")},[g,R,o?.agentId,o?.botId]),o?g?.available?r("div",{key:`${o.agentId}:${o.botId}`,"data-personal-assistant-home":"true","data-agent-id":o.agentId,"data-bot-id":o.botId,style:{flex:"1 1 0px",height:"100%",maxHeight:"100%",minHeight:0,minWidth:0,overflow:"hidden",boxSizing:"border-box",display:"flex",flexDirection:"column"}},r(mt,{React:d,request:R,scope:o,onOpenComputer:()=>g.open()})):r("div",{role:"alert",style:{padding:24}},"\u5F53\u524D\u5BBF\u4E3B\u5C1A\u672A\u63D0\u4F9B\u539F\u751F\u4E91\u7535\u8111\u4FA7\u680F\uFF0C\u8BF7\u66F4\u65B0 Studio \u540E\u91CD\u65B0\u6253\u5F00\u3002"):r("div",{role:"status",style:{padding:24}},p||"\u6B63\u5728\u8FDE\u63A5\u4E91\u7AEF\u4E2A\u4EBA\u52A9\u7406\u2026",p?r("button",{onClick:()=>S(N=>N+1)},"\u91CD\u65B0\u8FDE\u63A5"):null)}var m={page:{padding:"2px 2px 28px",display:"flex",flexDirection:"column",gap:18,maxWidth:700,fontSize:13,color:"var(--dsw-alias-label-primary, #17202c)"},title:{margin:0,fontSize:18,fontWeight:600,letterSpacing:"-0.01em"},lede:{margin:0,color:"var(--dsw-alias-label-secondary, #536174)",fontSize:13,lineHeight:1.7},card:{border:H.border,borderRadius:12,overflow:"hidden"},row:{display:"flex",gap:16,padding:"12px 14px",borderTop:"1px solid var(--dsw-alias-border-default, #d8dee8)",alignItems:"flex-start"},rowFirst:{display:"flex",gap:16,padding:"12px 14px",alignItems:"flex-start"},label:{width:116,flex:"none",color:"var(--dsw-alias-label-secondary, #536174)",fontSize:13,lineHeight:1.7},value:{flex:1,minWidth:0,fontSize:13,lineHeight:1.7,overflowWrap:"anywhere"},mono:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12},actions:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},button:{...H,borderRadius:8,padding:"6px 11px",cursor:"pointer",font:"inherit",fontSize:13},note:{color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12,lineHeight:1.7},badge:{display:"inline-block",borderRadius:999,padding:"1px 8px",fontSize:12,lineHeight:1.7},badgeOk:{background:"color-mix(in srgb, #067647 12%, transparent)",color:"#067647"},badgeIdle:{background:"color-mix(in srgb, #946200 14%, transparent)",color:"#946200"},badgeError:{background:"color-mix(in srgb, #b42318 12%, transparent)",color:"#b42318"},dangerButton:{...H,borderRadius:8,padding:"6px 11px",cursor:"pointer",font:"inherit",fontSize:13,color:"#b42318",border:"1px solid color-mix(in srgb, #b42318 35%, transparent)",background:"transparent"},confirmBox:{border:"1px solid color-mix(in srgb, #b42318 30%, transparent)",borderRadius:12,padding:"12px 14px",display:"flex",flexDirection:"column",gap:10,background:"color-mix(in srgb, #b42318 4%, transparent)"},dangerInput:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"6px 9px",font:"inherit",fontSize:12,width:"100%",maxWidth:360,boxSizing:"border-box"},danger:{...H,borderRadius:8,padding:"6px 11px",cursor:"pointer",font:"inherit",fontSize:13,color:"#fff",border:"1px solid #b42318",background:"#b42318"},dangerDisabled:{...H,borderRadius:8,padding:"6px 11px",cursor:"not-allowed",font:"inherit",fontSize:13,color:"#fff",border:"1px solid color-mix(in srgb, #b42318 35%, transparent)",background:"color-mix(in srgb, #b42318 35%, transparent)"},success:{color:"#067647",fontSize:12,lineHeight:1.7},input:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"6px 9px",font:"inherit",fontSize:12,width:"100%",maxWidth:360,boxSizing:"border-box"},textarea:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"6px 9px",font:"inherit",fontSize:12,width:"100%",minHeight:76,resize:"vertical",boxSizing:"border-box"},envRow:{display:"flex",gap:6,alignItems:"center",marginBottom:6,flexWrap:"wrap"},envKey:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"5px 8px",font:"inherit",fontSize:12,width:190,boxSizing:"border-box"},envValue:{...H,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"5px 8px",font:"inherit",fontSize:12,width:220,boxSizing:"border-box"},tinyButton:{...H,borderRadius:8,padding:"4px 8px",cursor:"pointer",font:"inherit",fontSize:12}};function sn({request:t,openComputer:g=null}={}){let d=Ne||globalThis.React;if(!d)return"\u8BBE\u7F6E\u9875\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00 Studio";let{createElement:r,useEffect:n,useState:a,useCallback:s}=d,[o,f]=a(null),[p,E]=a(null),[D,S]=a(""),[R,N]=a(!1),[T,$]=a(""),[ee,v]=a(!1),[ge,X]=a(""),[Y,L]=a(!1),[B,W]=a(""),[O,M]=a(null),[te,Be]=a(null),[_e,ne]=a(""),[xe,we]=a(""),[q,ie]=a(""),[G,U]=a([]),[ve,K]=a([]),[Se,P]=a(""),[de,he]=a(""),[C,Ie]=a(!1),ue=s(async()=>{N(!0),S("");let h=Date.now();try{let i=await t("personal-assistant.configuration");if(f(i),i?.configured){let u=await t("personal-assistant.bots.list");E(Array.isArray(u?.bots)?u.bots:[]);try{let y=await t("personal-assistant.settings.inspect");M(y),ne(y?.model||""),we(y?.prompt||""),ie(y?.runtime?.version||""),U((y?.environmentVariables||[]).map(k=>({...k,saved:!0,dirty:!1}))),K([]),P("");let x=await t("personal-assistant.settings.versions",{currentVersion:y?.runtime?.version||""}).catch(k=>(P(k?.message||"\u6682\u65F6\u8BFB\u4E0D\u5230\u53EF\u5347\u7EA7\u7684\u7248\u672C"),null));Be(x)}catch(y){M(null),Be(null),P(y?.message||"\u8BFB\u53D6\u4E91\u7AEF\u914D\u7F6E\u5931\u8D25")}}else E([]),M(null),Be(null);$(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 ${Date.now()-h} ms`)}catch(i){S(i?.message||"\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25"),$(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 \u5931\u8D25`)}finally{N(!1)}},[t]),j=o?.agentId||"",V=!!j&&ge.trim()===j,w=s(async()=>{if(V){L(!0),S("");try{await t("personal-assistant.desktop.destroy",{confirmAgentId:j}),v(!1),X(""),W("\u4E2A\u4EBA\u52A9\u7406\u5DF2\u5173\u95ED\uFF1A\u4E91\u7AEF\u5B9E\u4F8B\u5DF2\u5220\u9664\uFF0C\u5173\u8054\u7684\u4E91\u8D44\u6E90\u8BA2\u5355\u6B63\u5728\u91CA\u653E\uFF0C\u672C\u673A\u7ED1\u5B9A\u5DF2\u6E05\u9664\u3002"),f({configured:!1}),E([]),$("")}catch(h){let i=String(h?.message||"");S(/更新 Studio|云连接服务/iu.test(i)?"\u5F53\u524D Studio \u7248\u672C\u8FD8\u4E0D\u652F\u6301\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406\uFF0C\u8BF7\u66F4\u65B0 Studio \u540E\u91CD\u8BD5\u3002":i||"\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{L(!1)}}},[j,V,t]),re=(h,i)=>U(u=>u.map((y,x)=>x===h?{...y,...i,dirty:!0}:y)),ce=()=>U(h=>[...h,{key:"",value:"",sensitive:!1,saved:!1,dirty:!0}]),Fe=h=>{let i=G[h];i&&(U(u=>u.filter((y,x)=>x!==h)),i.saved&&i.key&&K(u=>u.includes(i.key)?u:[...u,i.key]))},be=O?.recordSource==="studio",Ce=s(async()=>{if(!(!be||C)){Ie(!0),P(""),he("");try{let h=G.filter(i=>i.dirty===!0||i.saved!==!0).map(i=>({key:String(i.key||"").trim(),value:String(i.value||""),sensitive:i.sensitive===!0}));await t("personal-assistant.settings.update",{model:_e.trim(),prompt:xe,runtimeVersion:q,environmentVariables:h,deleteKeys:ve}),he(`\u5DF2\u63D0\u4EA4\u4E91\u7AEF\u66F4\u65B0\uFF08\u7248\u672C ${q}\uFF09\uFF0C\u4E2A\u4EBA\u52A9\u7406\u6B63\u5728\u5E94\u7528\u65B0\u914D\u7F6E\uFF0C\u901A\u5E38 1\u20132 \u5206\u949F\u5B8C\u6210\uFF0C\u671F\u95F4\u4E91\u7535\u8111\u4F1A\u77ED\u6682\u91CD\u8FDE\u3002`),K([]);try{let i=await t("personal-assistant.settings.inspect");M(i),ne(i?.model||""),we(i?.prompt||""),ie(i?.runtime?.version||q),U((i?.environmentVariables||[]).map(u=>({...u,saved:!0,dirty:!1})))}catch{}}catch(h){P(h?.message||"\u4FDD\u5B58\u914D\u7F6E\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{Ie(!1)}}},[be,ve,G,_e,xe,t,C,q]);n(()=>{ue()},[ue]);let oe=o?.configured===!0,Pe=o===null?"\u68C0\u67E5\u4E2D":oe?"\u5DF2\u5F00\u901A":"\u5C1A\u672A\u5F00\u901A",ye={...m.badge,...o===null?m.badgeIdle:oe?m.badgeOk:m.badgeIdle},z=(h,i,u=!1)=>r("div",{style:u?m.rowFirst:m.row},r("div",{style:m.label},h),r("div",{style:m.value},i)),pe={...m.note,display:"inline-flex",gap:4,alignItems:"center"},De={...m.actions,marginTop:6},ze={display:"flex",flexDirection:"column",gap:8},c=()=>{if(!O)return r("div",{style:m.card},z("\u4E91\u7AEF\u914D\u7F6E",r("div",{style:m.note},C?"\u8BFB\u53D6\u4E2D\u2026":Se||"\u6682\u65F6\u8BFB\u4E0D\u5230\u4E91\u7AEF\u914D\u7F6E\uFF1B\u8BF7\u70B9\u4E0B\u65B9\u201C\u68C0\u67E5\u8FDE\u63A5\u201D\u91CD\u8BD5"),!0));if(O.recordSource!=="studio")return r("div",{style:m.card},z("\u4E91\u7AEF\u914D\u7F6E",r("div",{style:m.note},"\u8FD9\u4E2A\u4E2A\u4EBA\u52A9\u7406\u662F\u7528\u65E7\u7248 Studio \u521B\u5EFA\u7684\uFF0C\u672C\u673A\u6CA1\u6709\u8BB0\u5F55\u5B83\u7684\u914D\u7F6E\u6E05\u5355\uFF0C\u6682\u65F6\u4E0D\u80FD\u5728\u7EBF\u4FEE\u6539\u3002\u53EF\u4EE5\u5173\u95ED\u540E\u91CD\u65B0\u521B\u5EFA\uFF1B\u7B49\u4E91\u7AEF\u5E73\u53F0\u63D0\u4F9B\u8BFB\u53D6\u63A5\u53E3\u540E\u5373\u53EF\u76F4\u63A5\u7F16\u8F91\u3002"),!0));let h=te&&te.catalogAvailable?r("select",{style:m.input,value:q,disabled:C,"aria-label":"\u8FD0\u884C\u65F6\u7248\u672C",onChange:y=>ie(String(y?.target?.value??""))},te.versions.map(y=>r("option",{key:y.version,value:y.version},y.version===O.runtime?.version?`${y.version}\uFF08\u5F53\u524D\uFF09`:y.version))):r("div",{style:m.note},`${O.runtime?.version||q||"\u672A\u77E5\u7248\u672C"} \xB7 \u4E91\u7AEF\u8FD8\u6CA1\u6709\u53D1\u5E03\u53EF\u5347\u7EA7\u7248\u672C`),i=r("div",null,G.length?G.map((y,x)=>r("div",{key:`env-${x}`,style:m.envRow},r("input",{style:m.envKey,value:y.key,placeholder:"KEY","aria-label":"\u73AF\u5883\u53D8\u91CF\u540D",disabled:C||y.saved===!0,onChange:k=>re(x,{key:String(k?.target?.value??"")})}),r("input",{style:m.envValue,value:y.value,"aria-label":"\u73AF\u5883\u53D8\u91CF\u503C",type:y.sensitive===!0?"password":"text",disabled:C,placeholder:y.saved===!0&&y.sensitive===!0?"\u5DF2\u4FDD\u5B58\uFF08\u7559\u7A7A\u4E0D\u4FEE\u6539\uFF09":"VALUE",onChange:k=>re(x,{value:String(k?.target?.value??"")})}),r("label",{style:pe},r("input",{type:"checkbox",checked:y.sensitive===!0,disabled:C,onChange:k=>re(x,{sensitive:k?.target?.checked===!0})}),"\u654F\u611F"),r("button",{style:m.tinyButton,disabled:C,onClick:()=>Fe(x)},"\u5220\u9664"))):r("div",{style:m.note},"\u8FD8\u6CA1\u6709\u914D\u7F6E\u73AF\u5883\u53D8\u91CF"),r("div",{style:De},r("button",{style:m.tinyButton,disabled:C,onClick:ce},"\u6DFB\u52A0\u53D8\u91CF"),r("span",{style:m.note},"\u5DF2\u4FDD\u5B58\u7684\u654F\u611F\u503C\u4E0D\u4F1A\u56DE\u663E\uFF0C\u7559\u7A7A\u8868\u793A\u4E0D\u4FEE\u6539\uFF1B\u5220\u9664\u540E\u4FDD\u5B58\u751F\u6548"))),u=r("div",{style:ze},de?r("div",{style:m.success},de):null,Se?r("div",{style:{...m.note,color:"#b42318"}},Se):null,r("div",{style:m.actions},r("button",{style:m.button,disabled:C,onClick:()=>{Ce()}},C?"\u6B63\u5728\u4FDD\u5B58\u2026":"\u4FDD\u5B58\u914D\u7F6E"),r("span",{style:m.note},"\u4FDD\u5B58\u4F1A\u63D0\u4EA4\u4E00\u6B21\u4E91\u7AEF\u66F4\u65B0\uFF0C\u7531\u4E91\u7AEF\u6EDA\u52A8\u5E94\u7528")));return r("div",{style:m.card},z("\u4E91\u7AEF\u914D\u7F6E",r("div",{style:m.note},"\u6A21\u578B\u3001\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3001\u8FD0\u884C\u65F6\u7248\u672C\u548C\u73AF\u5883\u53D8\u91CF\u4FDD\u5B58\u5728\u4E91\u7AEF\u5B9E\u4F8B\u3002\u4FDD\u5B58\u65F6\u63D0\u4EA4\u4E00\u6B21\u4E91\u7AEF\u66F4\u65B0\uFF0C\u7531\u4E91\u7AEF\u6EDA\u52A8\u5E94\u7528\u5230\u5B9E\u4F8B\uFF0C\u4E0D\u9700\u8981\u672C\u673A\u91CD\u542F\u3002"),!0),O.detailAvailable===!1?z("\u8BF4\u660E",r("div",{style:m.note},O.detailNote||"\u4E91\u7AEF\u5E73\u53F0\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u5B9E\u4F8B\u8BE6\u60C5\uFF0C\u4E0B\u9762\u663E\u793A\u7684\u662F\u672C\u673A\u8BB0\u5F55\u7684\u914D\u7F6E\uFF1B\u73AF\u5883\u53D8\u91CF\u8BE6\u60C5\u6682\u65F6\u4E0D\u53EF\u89C1\u3002")):null,z("\u6A21\u578B",r("input",{style:m.input,value:_e,disabled:C,placeholder:"\u4F8B\u5982 deepseek-v4.1-flash-1017","aria-label":"\u6A21\u578B\u540D\u79F0",onChange:y=>ne(String(y?.target?.value??""))})),z("\u7CFB\u7EDF\u63D0\u793A\u8BCD",r("textarea",{style:m.textarea,value:xe,disabled:C,"aria-label":"\u7CFB\u7EDF\u63D0\u793A\u8BCD",onChange:y=>we(String(y?.target?.value??""))})),z("\u8FD0\u884C\u65F6\u7248\u672C",h),z("\u73AF\u5883\u53D8\u91CF",i),z("\u4FDD\u5B58",u))};return r("section",{"data-personal-assistant-settings":"true",style:m.page},r("div",null,r("h1",{style:m.title},"\u4E2A\u4EBA\u52A9\u7406"),r("p",{style:{...m.lede,marginTop:6}},"\u4E91\u7AEF\u6301\u7EED\u8FD0\u884C\u7684\u52A9\u7406\uFF0C\u5E26\u4E00\u53F0\u72EC\u7ACB\u4E91\u7535\u8111\u3002\u5173\u6389\u7A97\u53E3\u5B83\u4E5F\u5728\u5DE5\u4F5C\uFF1B\u5BF9\u8BDD\u4E0E\u4E91\u7535\u8111\u5728\u5DE6\u4FA7\u300C\u4E2A\u4EBA\u52A9\u7406\u300D\u9875\u3002")),D?r("div",{role:"alert",style:{...m.note,color:"#b42318",background:"color-mix(in srgb, #b42318 8%, transparent)",border:"1px solid color-mix(in srgb, #b42318 25%, transparent)",borderRadius:10,padding:"9px 12px"}},D):null,r("div",{style:m.card},z("\u72B6\u6001",r("span",null,r("span",{style:ye},Pe),T?r("span",{style:m.note},`\u3000\u4E0A\u6B21\u68C0\u67E5 ${T}`):null),!0),z("\u4E91\u7AEF\u5B9E\u4F8B",o?.agentId?r("span",{style:m.mono},o.agentId):r("span",{style:m.note},oe?"\u672A\u8FD4\u56DE\u5B9E\u4F8B\u6807\u8BC6":"\u5F00\u901A\u540E\u7531 Studio \u7ED1\u5B9A")),z("\u7F51\u5173",o?.gatewayUrl?r("span",{style:m.mono},o.gatewayUrl):r("span",{style:m.note},"\u7531 Studio Host \u914D\u7F6E")),z("\u52A9\u7406\u8FDE\u63A5",r("span",{style:m.note},p===null?"\u68C0\u67E5\u4E2D":p.length?"\u5DF2\u8FDE\u63A5\u4F60\u7684\u52A9\u7406":"\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA")),z("\u8BB0\u5FC6",r("div",null,r("div",{style:m.mono},"/workspace/assistant-state"),r("div",{style:m.note},"\u8BB0\u5FC6\u3001\u4F1A\u8BDD\u4E0E\u5B9A\u65F6\u4EFB\u52A1\u968F\u4E91\u7535\u8111\u6301\u4E45\u4FDD\u5B58\uFF0C\u6362\u8BBE\u5907\u4E5F\u5728"))),z("\u4E91\u7AEF\u80FD\u529B",r("div",null,r("div",null,"\u9ED8\u8BA4\u5F00\u542F\uFF1A\u4E91\u7AEF\u547D\u4EE4\u6267\u884C\u3001\u4E91\u7AEF\u6D4F\u89C8\u5668"),r("div",{style:m.note},"\u90FD\u8DD1\u5728\u9694\u79BB\u5DE5\u4F5C\u533A\uFF1A\u8BFB\u4E0D\u5230\u672C\u673A\u6587\u4EF6\u4E0E\u51ED\u8BC1\uFF0C\u4E0D\u80FD\u8BBF\u95EE\u5185\u7F51\u4E0E\u672C\u673A\u5730\u5740\uFF1B\u654F\u611F\u64CD\u4F5C\u4F1A\u5148\u8BF7\u4F60\u786E\u8BA4"))),z("\u63D2\u4EF6\u7248\u672C",r("span",{style:m.note},`\u6784\u5EFA ${je}`))),oe?c():null,oe||B?r("div",{style:m.card},z("\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406",r("div",{style:{display:"flex",flexDirection:"column",gap:8}},r("div",{style:m.note},"\u5173\u95ED\u4F1A\u5220\u9664\u4E91\u7AEF\u5B9E\u4F8B\uFF08\u4E91\u7535\u8111 Pod\uFF09\u548C\u4E91\u7AEF\u52A9\u7406\u6570\u636E\uFF0C\u5E76\u91CA\u653E\u5173\u8054\u7684\u4E91\u8D44\u6E90\u8BA2\u5355\uFF1B\u672C\u673A\u7ED1\u5B9A\u4E5F\u4F1A\u4E00\u5E76\u6E05\u9664\uFF0C\u4E4B\u540E\u53EF\u91CD\u65B0\u521B\u5EFA\u3002"),B?r("div",{style:m.success},B):null,ee?r("div",{style:m.confirmBox},r("div",{style:{...m.note,color:"#b42318"}},"\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002\u8BF7\u8F93\u5165\u4E0A\u65B9\u300C\u4E91\u7AEF\u5B9E\u4F8B\u300D\u7684\u6807\u8BC6\u4EE5\u786E\u8BA4\u5173\u95ED\uFF1A"),r("input",{style:m.dangerInput,value:ge,placeholder:j||"ar-\u2026","aria-label":"\u8F93\u5165\u4E91\u7AEF\u5B9E\u4F8B\u6807\u8BC6\u4EE5\u786E\u8BA4\u5173\u95ED",disabled:Y,onChange:h=>X(String(h?.target?.value??""))}),r("div",{style:m.actions},r("button",{style:V&&!Y?m.danger:m.dangerDisabled,disabled:!V||Y,onClick:()=>{w()}},Y?"\u6B63\u5728\u5173\u95ED\u2026":"\u786E\u8BA4\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406"),r("button",{style:m.button,disabled:Y,onClick:()=>{v(!1),X("")}},"\u53D6\u6D88"))):r("div",{style:m.actions},r("button",{style:m.dangerButton,disabled:!oe||Y,onClick:()=>{v(!0),X(""),W("")}},"\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406"),r("span",{style:m.note},oe?"\u9700\u8981\u8F93\u5165\u5B9E\u4F8B\u6807\u8BC6\u4E8C\u6B21\u786E\u8BA4":"\u5F53\u524D\u6CA1\u6709\u5DF2\u5F00\u901A\u7684\u4E2A\u4EBA\u52A9\u7406"))),!0)):null,r("div",{style:m.actions},r("button",{style:m.button,disabled:R,onClick:()=>{ue()}},R?"\u6B63\u5728\u68C0\u67E5\u2026":"\u68C0\u67E5\u8FDE\u63A5"),r("span",{style:m.note},"\u68C0\u67E5\u4F1A\u8BFB\u53D6\u5F00\u901A\u72B6\u6001\u5E76\u62C9\u53D6\u4E00\u6B21\u52A9\u7406\u5217\u8868\uFF0C\u4E0D\u4F1A\u542F\u52A8\u4E91\u7535\u8111")))}function an({size:t}={}){let g=Ne,d=Number(t)>0?Number(t):16;return g?.createElement?g.createElement("svg",{width:d,height:d,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block"}},g.createElement("path",{d:"M3.4 3.2h9.2a1.3 1.3 0 0 1 1.3 1.3H7.7l-2.9 2.3v-2.3H3.4a1.3 1.3 0 0 1-1.3-1.3V4.5a1.3 1.3 0 0 1 1.3-1.3z"}),g.createElement("path",{d:"M8.1 5.6l.62 1.46 1.46.62-1.46.62L8.1 9.76l-.62-1.46-1.46-.62 1.46-.62z"})):"\u52A9"}function ln({size:t}={}){let g=Ne,d=Number(t)>0?Number(t):16;return g?.createElement?g.createElement("svg",{width:d,height:d,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",flex:"0 0 auto"}},g.createElement("rect",{x:2.2,y:3.4,width:11.6,height:7.4,rx:1.4}),g.createElement("path",{d:"M6.6 13.4h2.8"}),g.createElement("path",{d:"M8 10.8v2.6"})):null}function cn(){let t=Ne,g=ln({size:15});return!t?.createElement||!g?"\u4E91\u7535\u8111":t.createElement("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",lineHeight:1}},g,t.createElement("span",null,"\u4E91\u7535\u8111"))}function _t(t){if(!t?.slots?.inject||!t.slots.register)throw new TypeError("Personal Assistant client requires the public DSH slots service");let g=async(a,s={})=>{if(!t.connection?.rpc?.call)throw new tt;let o=await t.connection.rpc.call("/api","personal-assistant",{operation:a,payload:s});if(!o?.ok)throw Object.assign(new Error(o?.error?.message||"Studio Host \u8BF7\u6C42\u5931\u8D25"),{code:o?.error?.code,status:o?.error?.details?.status,closeCode:o?.error?.details?.closeCode});return o.value},d=(a,s)=>{try{let o=()=>a();return typeof t.effect=="function"?t.effect(o,s):o()}catch(o){try{console.warn(`[personal-assistant] ${s} \u6CE8\u518C\u5931\u8D25`,o)}catch{}return}},r=vt({sidebarRight:t.sidebarRight,slots:t.slots});r&&(r.render=a=>St({...a,React:Ne||globalThis.React,workbench:r,Panel:kt}),d(()=>()=>r.dispose(),"personal-assistant: native workbench")),d(()=>t.slots.inject("main",()=>t.slots.register({name:"main",key:et,inject:()=>({request:g,nativeWorkbench:r})},on)),"personal-assistant: main panel"),d(()=>t.slots.inject("sidebar.panellist",()=>t.slots.register({name:"sidebar.panellist",id:et,order:90,label:"\u4E2A\u4EBA\u52A9\u7406"},an)),"personal-assistant: sidebar row"),d(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:`${et}-settings`,order:196,label:"\u4E2A\u4EBA\u52A9\u7406",inject:()=>({request:g})},sn)),"personal-assistant: settings section"),typeof t.inject=="function"&&d(()=>t.inject(["sidebarRightTabs"],a=>{let s=[],o=f=>{typeof f=="function"&&s.push(f)};try{let f=a.sidebarRightTabs;if(f===void 0||typeof f.register!="function")return;o(f.register({id:Ve,kind:Ve,title:()=>"\u4E91\u7535\u8111",guide:[{order:20,title:()=>"\u4E91\u7535\u8111",description:()=>"\u4E2A\u4EBA\u52A9\u7406\u7684\u4E91\u7AEF\u7535\u8111\u753B\u9762\uFF0C\u53EF\u83B7\u53D6\u63A7\u5236\u6743"}]})),o(a.slots.inject("sidebar.right.pane.tab",()=>a.slots.register({name:"sidebar.right.pane.tab",key:Ve,inject:()=>({request:g})},p=>kt({...p,variant:"computer"})))),o(a.slots.inject("sidebar.right.pane.tab.title",()=>a.slots.register({name:"sidebar.right.pane.tab.title",key:Ve},cn)))}catch(f){try{console.warn("[personal-assistant] \u53F3\u4FA7\u680F\u6CE8\u518C\u5931\u8D25",f)}catch{}}return()=>{for(let f of s.reverse())f()}}),"personal-assistant: right tab")}window.__ModuleLoader__.load({id:"@kingsoftcloud/agentkit-personal-assistant",factory:t=>(Rt(t("react")),{name:"agentkit-personal-assistant",inject:At,apply:_t})});})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingsoftcloud/agentkit-personal-assistant",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Standalone personal assistant DSH plugin with multi-Bot profiles and an explicit Cloud Computer Broker boundary.",
5
5
  "homepage": "https://github.com/kingsoftcloud/agentkit-personal-assistant",
6
6
  "repository": {
@@ -762,6 +762,10 @@ export function PersonalAssistantSettings({ request, openComputer = null } = {})
762
762
  return h('div', { style: settingsStyle.card },
763
763
  line('云端配置', h('div', { style: settingsStyle.note },
764
764
  '模型、系统提示词、运行时版本和环境变量保存在云端实例。保存时提交一次云端更新,由云端滚动应用到实例,不需要本机重启。'), true),
765
+ settings.detailAvailable === false
766
+ ? line('说明', h('div', { style: settingsStyle.note },
767
+ settings.detailNote || '云端平台暂时没有返回实例详情,下面显示的是本机记录的配置;环境变量详情暂时不可见。'))
768
+ : null,
765
769
  line('模型', h('input', { style: settingsStyle.input, value: model, disabled: settingsBusy,
766
770
  placeholder: '例如 deepseek-v4.1-flash-1017', 'aria-label': '模型名称',
767
771
  onChange: event => setModel(String(event?.target?.value ?? '')) })),