@kingsoftcloud/agentkit-personal-assistant 0.1.10 → 0.1.12
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 +5 -5
- package/package.json +2 -1
- package/runtime/assistant-runtime.mjs +2 -1
- package/runtime/build-info.mjs +40 -0
- package/runtime/cloud-browser-cdp.mjs +52 -7
- package/runtime/cloud-browser.mjs +110 -9
- package/runtime/cloud-session-channel.mjs +2 -2
- package/runtime/computer-agentd.mjs +27 -2
- package/runtime/desktop-session.mjs +25 -9
- package/runtime/desktop-ws.mjs +7 -2
- package/scripts/build-artifacts.mjs +3 -0
- package/scripts/build-client.mjs +4 -2
- package/src/client/components/desktop-clipboard.mjs +99 -14
- package/src/client/conversation.mjs +143 -31
- package/src/client/desktop-view.mjs +39 -0
- package/src/client/entry.mjs +11 -1
- package/src/client/index.mjs +318 -36
- package/src/dsh-web-bridge.mjs +23 -10
- package/src/host-gateway.mjs +70 -1
- package/src/persistent-state.mjs +3 -1
- package/web/welcome.html +285 -0
package/dist/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(()=>{var qe=Object.freeze({width:1280,height:800});function Qe(t={}){let g=Number(t.width)||qe.width,d=Number(t.height)||qe.height;return!Number.isFinite(g)||!Number.isFinite(d)||g<=0||d<=0?qe:Object.freeze({width:Math.round(g),height:Math.round(d)})}function ot({clientX:t,clientY:g,rect:d,display:r=qe}){let n=Qe(r),a=Number(d?.width)||n.width,s=Number(d?.height)||n.height,o=Number(d?.left)||0,f=Number(d?.top)||0,p=Math.min(a/n.width,s/n.height),T=o+(a-n.width*p)/2,D=f+(s-n.height*p)/2,S=Math.max(0,Math.min(n.width-1,Math.round((Number(t)-T)/p))),O=Math.max(0,Math.min(n.height-1,Math.round((Number(g)-D)/p)));return{x:S,y:O}}function st({send:t,changed:g=()=>{},failed:d=()=>{},setTimer:r=setTimeout,clearTimer:n=clearTimeout}={}){let a=!1,s=0,o="observe",f=!1,p=[],T="",D,S=()=>g({phase:o,readOnly:o!=="controlling",controlEpoch:s,available:a}),O=()=>{n(D),D=void 0;let v=T;T="",v&&o==="controlling"&&t({type:"input",controlEpoch:s,event:{type:"text",text:v}})},_=v=>{v.type==="text"?(T.length+v.text.length>16384&&O(),T+=v.text,D||(D=r(O,30))):(O(),t({type:"input",controlEpoch:s,event:v}))},E=()=>{o="acquiring",S(),t({type:"control.acquire",controlEpoch:s})},M=v=>{if(v.type==="pointermove"&&p.at(-1)?.type==="pointermove")p[p.length-1]=v;else if(p.length<32)p.push(v);else return ee.release(),d("\u63A5\u7BA1\u671F\u95F4\u8F93\u5165\u8FC7\u5FEB\uFF0C\u8BF7\u91CD\u65B0\u70B9\u51FB\u4E91\u7535\u8111"),!1;return!0},ee={get snapshot(){return{phase:o,readOnly:o!=="controlling",controlEpoch:s,available:a}},reset(v={}){n(D),D=void 0,T="",p=[],a=v.controlAvailable===!0,s=Number.isSafeInteger(v.controlEpoch)?v.controlEpoch:0,o=v.readOnly===!1?"controlling":"observe",f=o==="controlling",S()},input(v){return o==="controlling"?(_(v),!0):(!f||o==="observe")&&(v.type==="pointermove"||["button","key"].includes(v.type)&&v.action==="up")||v.type==="pointermove"&&o==="observe"?!1:a?(f=!0,M(v)?(o==="observe"&&E(),!0):!1):(v.type!=="pointermove"&&d("\u5F53\u524D\u4E3A\u53EA\u8BFB\u65C1\u89C2\uFF0C\u9F20\u6807\u548C\u952E\u76D8\u4E0D\u4F1A\u53D1\u9001\u5230\u4E91\u7535\u8111"),!1)},acquire(){return a?(f=!0,o==="observe"&&E(),!0):!1},release(){f=!1,p=[],o==="controlling"&&(O(),o="releasing",S(),t({type:"control.release",controlEpoch:s}))},accept(v){if(!Number.isSafeInteger(v.controlEpoch)||v.controlEpoch<s)return;if(v.controlEpoch!==s&&(n(D),D=void 0,T=""),s=v.controlEpoch,a=v.controlAvailable===!0,v.readOnly){o!=="releasing"&&(f=!1,p=[]),o="observe",S(),f&&a&&E();return}if(!f){p=[],o="releasing",S(),t({type:"control.release",controlEpoch:s});return}o="controlling",S();let ge=p;p=[];for(let X of ge)_(X)},reject(v){Number.isSafeInteger(v.controlEpoch)&&v.controlEpoch<s||(f=!1,p=[],n(D),D=void 0,T="",Number.isSafeInteger(v.controlEpoch)&&v.controlEpoch>=s&&(s=v.controlEpoch),o=v.readOnly===!1?"controlling":"observe",S(),d(v.message||"\u63A7\u5236\u6743\u6682\u4E0D\u53EF\u7528\uFF0C\u4ECD\u53EF\u7EE7\u7EED\u65C1\u89C2"))},dispose(){ee.release(),n(D),D=void 0,T="",p=[]}};return ee}var Re=(t,g,d)=>Object.assign(new Error(g),{code:t,cause:d}),Pt=t=>{try{return new TextEncoder().encode(t).length}catch{return t.length}},at=t=>typeof t=="string"?t:String(t?.text??"");async function Xe({clipboard:t}={}){let g=t||globalThis.navigator?.clipboard;if(!g||typeof g.readText!="function")throw Re("CLIPBOARD_UNAVAILABLE","\u5F53\u524D\u73AF\u5883\u4E0D\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF0C\u8BF7\u70B9\u300C\u7C98\u8D34\u300D\u6309\u94AE\u518D\u8BD5");try{let d=await g.readText();return typeof d=="string"?d:""}catch(d){throw Re("CLIPBOARD_READ_DENIED","\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF0C\u8BF7\u6309 \u2318V / Ctrl+V \u518D\u8BD5",d)}}async function Bt(t,{clipboard:g}={}){let d=g||globalThis.navigator?.clipboard;if(!d||typeof d.writeText!="function")throw Re("CLIPBOARD_UNAVAILABLE","\u5F53\u524D\u73AF\u5883\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u624B\u52A8\u590D\u5236");try{await d.writeText(String(t??""))}catch(r){throw Re("CLIPBOARD_WRITE_DENIED","\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u91CD\u8BD5",r)}}function zt(){return Object.freeze([Object.freeze({type:"key",action:"down",key:"Control_L"}),Object.freeze({type:"key",action:"down",key:"v"}),Object.freeze({type:"key",action:"up",key:"v"}),Object.freeze({type:"key",action:"up",key:"Control_L"})])}function Ke(t){let g=String(t?.code||"");return["COMPUTER_LEASE_REQUIRED","DESKTOP_CONTROL_GRANT_REQUIRED","DESKTOP_READ_ONLY","DESKTOP_CONTROL_EPOCH_CHANGED"].includes(g)?"\u9700\u8981\u5148\u70B9\u753B\u9762\u63A5\u7BA1\u4E91\u7535\u8111\uFF0C\u624D\u80FD\u8BFB\u5199\u4E91\u7AEF\u526A\u8D34\u677F":["DESKTOP_SESSION_IDLE","DESKTOP_SESSION_NOT_FOUND","CLIPBOARD_CLOSED"].includes(g)?"\u4E91\u7535\u8111\u5DF2\u7A7A\u95F2\u6216\u65AD\u5F00\uFF0C\u8BF7\u5148\u6062\u590D\u753B\u9762\u518D\u8BD5":g==="CLIPBOARD_TEXT_TOO_LARGE"?"\u526A\u8D34\u677F\u5185\u5BB9\u8D85\u8FC7 64 KiB\uFF0C\u4E91\u7535\u8111\u526A\u8D34\u677F\u653E\u4E0D\u4E0B":["DESKTOP_UNAVAILABLE","DESKTOP_FRAME_FAILED","DESKTOP_SESSION_FAILED"].includes(g)?"\u4E91\u7535\u8111\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5":["CLIPBOARD_FAILED","CLOUD_SESSION_FAILED"].includes(g)?"\u526A\u8D34\u677F\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5":g==="CLIPBOARD_TEXT_INVALID"?"\u526A\u8D34\u677F\u5185\u5BB9\u683C\u5F0F\u4E0D\u88AB\u4E91\u7AEF\u63A5\u53D7\uFF0C\u8BF7\u91CD\u8BD5":t?.message?String(t.message):g?`\u526A\u8D34\u677F\u64CD\u4F5C\u5931\u8D25\uFF08${g}\uFF09`:"\u526A\u8D34\u677F\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"}var Ut=0,Ft=()=>{let t=globalThis.crypto?.randomUUID?.();return t?`clip-${t}`:`clip-${Date.now().toString(36)}-${Ut+=1}`};function it({send:t,timeoutMs:g=5e3,controlEpoch:d,setTimer:r=setTimeout,clearTimer:n=clearTimeout}={}){let a=new Map,s=(f,p)=>{a.delete(f.id),n(f.timer),p()},o=(f,p)=>new Promise((T,D)=>{let S=Ft(),O=r(()=>{let M=a.get(S);M&&s(M,()=>D(Re("CLIPBOARD_TIMEOUT","\u4E91\u7AEF\u52A9\u7406\u7248\u672C\u8F83\u65E7\uFF0C\u526A\u8D34\u677F\u901A\u9053\u672A\u542F\u7528\uFF08\u91CD\u65B0\u90E8\u7F72\u540E\u53EF\u7528\uFF09")))},g);a.set(S,{id:S,timer:O,resolve:T,reject:M=>D(M)});let _=!1,E;try{E=typeof d=="function"?d():void 0}catch{E=void 0}try{_=t({type:f,requestId:S,...Number.isSafeInteger(E)?{controlEpoch:E}:{},...p})!==!1}catch(M){s(a.get(S),()=>D(Re("CLIPBOARD_UNAVAILABLE","\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u526A\u8D34\u677F\u6682\u4E0D\u53EF\u7528",M)));return}_||s(a.get(S),()=>D(Re("CLIPBOARD_UNAVAILABLE","\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u526A\u8D34\u677F\u6682\u4E0D\u53EF\u7528")))});return Object.freeze({read:()=>o("clipboard.read").then(f=>({text:at(f)})),write:f=>o("clipboard.write",{text:String(f)}).then(p=>({written:p?.written!==!1})),accept(f){if(!f||f.type!=="clipboard.response")return!1;let p=a.get(String(f.requestId||""));return p?(s(p,()=>{f.ok!==!1?p.resolve(f.value):p.reject(Re(f.error?.code||"CLIPBOARD_FAILED",f.error?.message||"",f.error))}),!0):!1},rejectAll(f=Re("CLIPBOARD_CLOSED","\u4E91\u7535\u8111\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u526A\u8D34\u677F\u64CD\u4F5C\u672A\u5B8C\u6210")){for(let p of[...a.values()])s(p,()=>p.reject(f))},get size(){return a.size}})}function lt(t){return!t||String(t.key??"").toLowerCase()!=="v"||t.altKey||t.shiftKey||t.isComposing||t.nativeEvent?.isComposing?!1:t.metaKey===!0||t.ctrlKey===!0}function ct(t){return!t||String(t.key??"").toLowerCase()!=="c"||t.altKey||t.shiftKey||t.isComposing||t.nativeEvent?.isComposing?!1:t.metaKey===!0||t.ctrlKey===!0}async function dt({readLocal:t,writeCloud:g,sendKeys:d,notify:r=()=>{}}={}){let n=t||(()=>Xe()),a="";try{a=await n()}catch(s){return r(Ke(s)||"\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF0C\u8BF7\u6309 \u2318V / Ctrl+V \u518D\u8BD5"),{ok:!1,code:s?.code||"CLIPBOARD_READ_FAILED"}}if(!a)return r("\u672C\u5730\u526A\u8D34\u677F\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53EF\u7C98\u8D34\u7684\u5185\u5BB9"),{ok:!1,code:"CLIPBOARD_EMPTY"};if(Pt(a)>65536)return r("\u526A\u8D34\u677F\u5185\u5BB9\u8D85\u8FC7 64 KiB\uFF0C\u4E91\u7535\u8111\u526A\u8D34\u677F\u653E\u4E0D\u4E0B"),{ok:!1,code:"CLIPBOARD_TOO_LARGE"};try{await g(a)}catch(s){return r(Ke(s)||"\u5199\u5165\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_WRITE_FAILED"}}if(typeof d=="function"){let s=!1;try{s=d(zt())!==!1}catch(o){return{ok:!0,code:"CLIPBOARD_KEY_FAILED",error:o}}if(!s)return r("\u5DF2\u5199\u5165\u4E91\u7535\u8111\u526A\u8D34\u677F\uFF0C\u4F46\u5F53\u524D\u6CA1\u6709\u63A7\u5236\u6743\uFF1B\u63A5\u7BA1\u4E91\u7535\u8111\u540E\u518D\u6309 Ctrl+V"),{ok:!0,code:"CLIPBOARD_KEY_NOT_SENT"}}return r("\u5DF2\u7C98\u8D34\u5230\u4E91\u7535\u8111"),{ok:!0}}async function ut({readCloud:t,writeLocal:g,notify:d=()=>{}}={}){let r=g||(s=>Bt(s)),n;try{n=await t()}catch(s){return d(Ke(s)||"\u8BFB\u53D6\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_READ_FAILED"}}let a=at(n);if(!a)return d("\u4E91\u7535\u8111\u526A\u8D34\u677F\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53EF\u590D\u5236\u7684\u5185\u5BB9"),{ok:!1,code:"CLIPBOARD_EMPTY"};try{await r(a)}catch(s){return d(Ke(s)||"\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_WRITE_FAILED"}}return d("\u5DF2\u590D\u5236\u5230\u672C\u5730"),{ok:!0,text:a}}var Mt=/^```\s*([\w+#.-]*)\s*$/u,$t=/^(#{1,6})\s+(.*)$/u,pt=/^\s*[-*+]\s+(.*)$/u,ft=/^\s*(\d{1,3})[.)]\s+(.*)$/u,Ge=/^\s*>\s?(.*)$/u,jt=/^\s*([-*_])\s*(?:\1\s*){2,}$/u;function Wt(t){let d=(typeof t=="string"?t.replace(/\r\n?/gu,`
|
|
1
|
+
(()=>{var rt=Object.freeze({width:1280,height:800});var kt=100;function ot(t={}){let d=Number(t.width)||rt.width,c=Number(t.height)||rt.height;return!Number.isFinite(d)||!Number.isFinite(c)||d<=0||c<=0?rt:Object.freeze({width:Math.round(d),height:Math.round(c)})}function Tt({clientX:t,clientY:d,rect:c,display:r=rt}){let u=ot(r),n=Number(c?.width)||u.width,s=Number(c?.height)||u.height,o=Number(c?.left)||0,b=Number(c?.top)||0,g=Math.min(n/u.width,s/u.height),h=o+(n-u.width*g)/2,x=b+(s-u.height*g)/2,k=Math.max(0,Math.min(u.width-1,Math.round((Number(t)-h)/g))),_=Math.max(0,Math.min(u.height-1,Math.round((Number(d)-x)/g)));return{x:k,y:_}}function Rt({availableWidth:t,availableHeight:d,display:c=rt,maxWidth:r=Number.POSITIVE_INFINITY}={}){let u=ot(c),n=Number(t)>0?Number(t):0,s=Number(d)>0?Number(d):0,o=Number(r)>0?Number(r):Number.POSITIVE_INFINITY;if(!n||!s)return{width:0,height:0};let b=Math.min(n,o,s*(u.width/u.height)),g=h=>Math.round(h*100)/100;return{width:g(b),height:g(b*(u.height/u.width))}}function _t(t={x:0,y:0},{deltaX:d=0,deltaY:c=0}={},r=kt){let u=Number(r)>0?Number(r):kt,n=(Number(t?.x)||0)+(Number(d)||0),s=(Number(t?.y)||0)+(Number(c)||0),o=Math.trunc(n/u),b=Math.trunc(s/u);return{pending:Object.freeze({x:n-o*u,y:s-b*u}),clicks:Object.freeze({deltaX:o,deltaY:b})}}function Ct({send:t,changed:d=()=>{},failed:c=()=>{},setTimer:r=setTimeout,clearTimer:u=clearTimeout}={}){let n=!1,s=0,o="observe",b=!1,g=[],h="",x,k=()=>d({phase:o,readOnly:o!=="controlling",controlEpoch:s,available:n}),_=()=>{u(x),x=void 0;let w=h;h="",w&&o==="controlling"&&t({type:"input",controlEpoch:s,event:{type:"text",text:w}})},A=w=>{w.type==="text"?(h.length+w.text.length>16384&&_(),h+=w.text,x||(x=r(_,30))):(_(),t({type:"input",controlEpoch:s,event:w}))},J=()=>{o="acquiring",k(),t({type:"control.acquire",controlEpoch:s})},X=w=>{if(w.type==="pointermove"&&g.at(-1)?.type==="pointermove")g[g.length-1]=w;else if(g.length<32)g.push(w);else return P.release(),c("\u63A5\u7BA1\u671F\u95F4\u8F93\u5165\u8FC7\u5FEB\uFF0C\u8BF7\u91CD\u65B0\u70B9\u51FB\u4E91\u7535\u8111"),!1;return!0},P={get snapshot(){return{phase:o,readOnly:o!=="controlling",controlEpoch:s,available:n}},reset(w={}){u(x),x=void 0,h="",g=[],n=w.controlAvailable===!0,s=Number.isSafeInteger(w.controlEpoch)?w.controlEpoch:0,o=w.readOnly===!1?"controlling":"observe",b=o==="controlling",k()},input(w){return o==="controlling"?(A(w),!0):(!b||o==="observe")&&(w.type==="pointermove"||["button","key"].includes(w.type)&&w.action==="up")||w.type==="pointermove"&&o==="observe"?!1:n?(b=!0,X(w)?(o==="observe"&&J(),!0):!1):(w.type!=="pointermove"&&c("\u5F53\u524D\u4E3A\u53EA\u8BFB\u65C1\u89C2\uFF0C\u9F20\u6807\u548C\u952E\u76D8\u4E0D\u4F1A\u53D1\u9001\u5230\u4E91\u7535\u8111"),!1)},acquire(){return n?(b=!0,o==="observe"&&J(),!0):!1},release(){b=!1,g=[],o==="controlling"&&(_(),o="releasing",k(),t({type:"control.release",controlEpoch:s}))},accept(w){if(!Number.isSafeInteger(w.controlEpoch)||w.controlEpoch<s)return;if(w.controlEpoch!==s&&(u(x),x=void 0,h=""),s=w.controlEpoch,n=w.controlAvailable===!0,w.readOnly){o!=="releasing"&&(b=!1,g=[]),o="observe",k(),b&&n&&J();return}if(!b){g=[],o="releasing",k(),t({type:"control.release",controlEpoch:s});return}o="controlling",k();let ve=g;g=[];for(let O of ve)A(O)},reject(w){Number.isSafeInteger(w.controlEpoch)&&w.controlEpoch<s||(b=!1,g=[],u(x),x=void 0,h="",Number.isSafeInteger(w.controlEpoch)&&w.controlEpoch>=s&&(s=w.controlEpoch),o=w.readOnly===!1?"controlling":"observe",k(),c(w.message||"\u63A7\u5236\u6743\u6682\u4E0D\u53EF\u7528\uFF0C\u4ECD\u53EF\u7EE7\u7EED\u65C1\u89C2"))},dispose(){P.release(),u(x),x=void 0,h="",g=[]}};return P}var xe=(t,d,c)=>Object.assign(new Error(d),{code:t,cause:c}),pn=t=>{try{return new TextEncoder().encode(t).length}catch{return t.length}},st=t=>typeof t=="string"?t:String(t?.text??"");async function pt({clipboard:t}={}){let d=t||globalThis.navigator?.clipboard;if(!d||typeof d.readText!="function")throw xe("CLIPBOARD_UNAVAILABLE","\u5F53\u524D\u73AF\u5883\u4E0D\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF0C\u8BF7\u70B9\u300C\u7C98\u8D34\u300D\u6309\u94AE\u518D\u8BD5");try{let c=await d.readText();return typeof c=="string"?c:""}catch(c){throw xe("CLIPBOARD_READ_DENIED","\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF0C\u8BF7\u6309 \u2318V / Ctrl+V \u518D\u8BD5",c)}}async function ft(t,{clipboard:d}={}){let c=d||globalThis.navigator?.clipboard;if(!c||typeof c.writeText!="function")throw xe("CLIPBOARD_UNAVAILABLE","\u5F53\u524D\u73AF\u5883\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u624B\u52A8\u590D\u5236");try{await c.writeText(String(t??""))}catch(r){throw xe("CLIPBOARD_WRITE_DENIED","\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u91CD\u8BD5",r)}}function fn(){return Object.freeze([Object.freeze({type:"key",action:"down",key:"Control_L"}),Object.freeze({type:"key",action:"down",key:"v"}),Object.freeze({type:"key",action:"up",key:"v"}),Object.freeze({type:"key",action:"up",key:"Control_L"})])}function Ot(){return Object.freeze([Object.freeze({type:"key",action:"down",key:"Control_L"}),Object.freeze({type:"key",action:"down",key:"c"}),Object.freeze({type:"key",action:"up",key:"c"}),Object.freeze({type:"key",action:"up",key:"Control_L"})])}async function Dt({readCloud:t,beforeText:d="",timeoutMs:c=1200,settleMs:r=180,pollMs:u=50,sleep:n=o=>new Promise(b=>setTimeout(b,o)),now:s=Date.now}={}){if(typeof t!="function")throw xe("CLIPBOARD_READ_FAILED","\u8BFB\u53D6\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");let o=Number.isFinite(c)&&c>=0?c:1200,b=Number.isFinite(r)&&r>=0?r:180,g=Number.isFinite(u)&&u>0?u:50,h=typeof s=="function"?s:Date.now,x=Number(h()),k="";for(;Number(h())-x<=o;){let _=await t();k=st(_);let A=Number(h())-x;if(k&&(k!==String(d??"")||A>=b))return{text:k,changed:k!==String(d??"")};if(A>=o)break;await n(Math.min(g,o-A))}return{text:k,changed:k!==String(d??"")}}function Ze(t){let d=String(t?.code||"");return d==="COMPUTER_USER_CONTROLLED"?"\u5F53\u524D\u6709\u4EBA\u6B63\u5728\u64CD\u4F5C\u4E91\u7535\u8111\uFF0C\u8BF7\u7B49\u5BF9\u65B9\u4EA4\u8FD8\u540E\u518D\u590D\u5236\u6216\u7C98\u8D34":d==="COMPUTER_LEASE_CONFLICT"?"\u4E91\u7535\u8111\u6B63\u5728\u88AB\u5176\u4ED6\u4EFB\u52A1\u4F7F\u7528\uFF0C\u8BF7\u7A0D\u540E\u518D\u590D\u5236\u6216\u7C98\u8D34":["COMPUTER_LEASE_REQUIRED","DESKTOP_CONTROL_GRANT_REQUIRED","DESKTOP_READ_ONLY","DESKTOP_CONTROL_EPOCH_CHANGED"].includes(d)?"\u9700\u8981\u5148\u70B9\u753B\u9762\u63A5\u7BA1\u4E91\u7535\u8111\uFF0C\u624D\u80FD\u8BFB\u5199\u4E91\u7AEF\u526A\u8D34\u677F":["DESKTOP_SESSION_IDLE","DESKTOP_SESSION_NOT_FOUND","CLIPBOARD_CLOSED"].includes(d)?"\u4E91\u7535\u8111\u5DF2\u7A7A\u95F2\u6216\u65AD\u5F00\uFF0C\u8BF7\u5148\u6062\u590D\u753B\u9762\u518D\u8BD5":d==="CLIPBOARD_UPGRADE_REQUIRED"?"\u5F53\u524D\u4E91\u7AEF\u7248\u672C\u5C1A\u4E0D\u652F\u6301\u526A\u8D34\u677F\uFF0C\u8BF7\u66F4\u65B0\u4E91\u7AEF\u52A9\u7406\u540E\u91CD\u8BD5":d==="CLIPBOARD_CONTROL_REQUIRED"?"\u9700\u8981\u5148\u63A5\u7BA1\u4E91\u7535\u8111\uFF0C\u624D\u80FD\u8BFB\u5199\u4E91\u7AEF\u526A\u8D34\u677F":d==="CLIPBOARD_RESPONSE_INVALID"?"\u4E91\u7AEF\u6CA1\u6709\u786E\u8BA4\u526A\u8D34\u677F\u64CD\u4F5C\u6210\u529F\uFF0C\u8BF7\u91CD\u8BD5":d==="CLIPBOARD_TIMEOUT"?"\u4E91\u7AEF\u526A\u8D34\u677F\u54CD\u5E94\u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5":d==="CLIPBOARD_UNAVAILABLE"?"\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8BF7\u6062\u590D\u753B\u9762\u540E\u91CD\u8BD5":d==="CLIPBOARD_TEXT_TOO_LARGE"?"\u526A\u8D34\u677F\u5185\u5BB9\u8D85\u8FC7 64 KiB\uFF0C\u4E91\u7535\u8111\u526A\u8D34\u677F\u653E\u4E0D\u4E0B":["DESKTOP_UNAVAILABLE","DESKTOP_FRAME_FAILED","DESKTOP_SESSION_FAILED"].includes(d)?"\u4E91\u7535\u8111\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5":["CLIPBOARD_FAILED","CLOUD_SESSION_FAILED"].includes(d)?"\u526A\u8D34\u677F\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5":d==="CLIPBOARD_TEXT_INVALID"?"\u526A\u8D34\u677F\u5185\u5BB9\u683C\u5F0F\u4E0D\u88AB\u4E91\u7AEF\u63A5\u53D7\uFF0C\u8BF7\u91CD\u8BD5":t?.message?String(t.message):d?`\u526A\u8D34\u677F\u64CD\u4F5C\u5931\u8D25\uFF08${d}\uFF09`:"\u526A\u8D34\u677F\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"}var gn=0,yn=()=>{let t=globalThis.crypto?.randomUUID?.();return t?`clip-${t}`:`clip-${Date.now().toString(36)}-${gn+=1}`};function Nt({send:t,timeoutMs:d=5e3,controlEpoch:c,setTimer:r=setTimeout,clearTimer:u=clearTimeout}={}){let n=new Map,s=()=>{try{return typeof c=="function"?c():void 0}catch{return}},o=(h,x)=>{!h||!n.has(h.id)||(n.delete(h.id),u(h.timer),x())},b=(h,x)=>new Promise((k,_)=>{let A=yn(),J=r(()=>{let w=n.get(A);w&&o(w,()=>_(xe("CLIPBOARD_TIMEOUT","\u4E91\u7AEF\u526A\u8D34\u677F\u54CD\u5E94\u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u540E\u91CD\u8BD5")))},d),X=s();n.set(A,{id:A,timer:J,type:h,epoch:X,resolve:k,reject:w=>_(w)});let P=!1;try{P=t({type:h,requestId:A,...Number.isSafeInteger(X)?{controlEpoch:X}:{},...x})!==!1}catch(w){o(n.get(A),()=>_(xe("CLIPBOARD_UNAVAILABLE","\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u526A\u8D34\u677F\u6682\u4E0D\u53EF\u7528",w)));return}P||o(n.get(A),()=>_(xe("CLIPBOARD_UNAVAILABLE","\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u526A\u8D34\u677F\u6682\u4E0D\u53EF\u7528")))}),g=Object.freeze({read:()=>b("clipboard.read").then(h=>({text:st(h)})),write:h=>b("clipboard.write",{text:String(h)}).then(()=>({written:!0})),accept(h){if(h?.type==="error"&&h.code==="DESKTOP_MESSAGE_UNSUPPORTED"&&n.size>0)return g.rejectAll(xe("CLIPBOARD_UPGRADE_REQUIRED","\u5F53\u524D\u4E91\u7AEF\u7248\u672C\u5C1A\u4E0D\u652F\u6301\u526A\u8D34\u677F\uFF0C\u8BF7\u66F4\u65B0\u4E91\u7AEF\u52A9\u7406\u540E\u91CD\u8BD5")),!0;if(!h||h.type!=="clipboard.response")return!1;let x=n.get(String(h.requestId||""));return x?(o(x,()=>{if(Number.isSafeInteger(x.epoch)&&x.epoch!==s()){x.reject(xe("DESKTOP_CONTROL_EPOCH_CHANGED","\u4E91\u7535\u8111\u63A7\u5236\u6743\u5DF2\u6539\u53D8\uFF0C\u672C\u6B21\u526A\u8D34\u677F\u64CD\u4F5C\u672A\u5B8C\u6210"));return}if(h.ok===!1){x.reject(xe(h.error?.code||"CLIPBOARD_FAILED",h.error?.message||"",h.error));return}let k=x.type==="clipboard.read"?typeof h.value=="string"||typeof h.value?.text=="string":h.value?.written===!0;if(h.ok!==!0||!k){x.reject(xe("CLIPBOARD_RESPONSE_INVALID","\u4E91\u7AEF\u6CA1\u6709\u786E\u8BA4\u526A\u8D34\u677F\u64CD\u4F5C\u6210\u529F\uFF0C\u8BF7\u91CD\u8BD5"));return}x.resolve(h.value)}),!0):!1},rejectAll(h=xe("CLIPBOARD_CLOSED","\u4E91\u7535\u8111\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u526A\u8D34\u677F\u64CD\u4F5C\u672A\u5B8C\u6210")){for(let x of[...n.values()])o(x,()=>x.reject(h))},get size(){return n.size}});return g}function Lt(t){return!t||String(t.key??"").toLowerCase()!=="v"||t.altKey||t.shiftKey||t.isComposing||t.nativeEvent?.isComposing?!1:t.metaKey===!0||t.ctrlKey===!0}function Pt(t){return!t||String(t.key??"").toLowerCase()!=="c"||t.altKey||t.shiftKey||t.isComposing||t.nativeEvent?.isComposing?!1:t.metaKey===!0||t.ctrlKey===!0}async function gt({readLocal:t,writeCloud:d,sendKeys:c,ensureControl:r,notify:u=()=>{}}={}){let n=t||(()=>pt()),s="";try{s=await n()}catch(o){return u(Ze(o)||"\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF0C\u8BF7\u6309 \u2318V / Ctrl+V \u518D\u8BD5"),{ok:!1,code:o?.code||"CLIPBOARD_READ_FAILED"}}if(!s)return u("\u672C\u5730\u526A\u8D34\u677F\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53EF\u7C98\u8D34\u7684\u5185\u5BB9"),{ok:!1,code:"CLIPBOARD_EMPTY"};if(pn(s)>65536)return u("\u526A\u8D34\u677F\u5185\u5BB9\u8D85\u8FC7 64 KiB\uFF0C\u4E91\u7535\u8111\u526A\u8D34\u677F\u653E\u4E0D\u4E0B"),{ok:!1,code:"CLIPBOARD_TOO_LARGE"};if(typeof r=="function")try{if(!await r())return u("\u9700\u8981\u5148\u63A5\u7BA1\u4E91\u7535\u8111\uFF0C\u624D\u80FD\u7C98\u8D34\u5230\u4E91\u7535\u8111"),{ok:!1,code:"CLIPBOARD_CONTROL_REQUIRED"}}catch(o){return u(Ze(o)||"\u63A5\u7BA1\u4E91\u7535\u8111\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:o?.code||"CLIPBOARD_CONTROL_REQUIRED"}}try{if((await d(s))?.written!==!0)throw xe("CLIPBOARD_RESPONSE_INVALID","\u4E91\u7AEF\u6CA1\u6709\u786E\u8BA4\u526A\u8D34\u677F\u5199\u5165\u6210\u529F\uFF0C\u8BF7\u91CD\u8BD5")}catch(o){return u(Ze(o)||"\u5199\u5165\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_WRITE_FAILED"}}if(typeof c=="function"){let o=!1;try{o=c(fn())!==!1}catch(b){return{ok:!0,code:"CLIPBOARD_KEY_FAILED",error:b}}if(!o)return u("\u5DF2\u5199\u5165\u4E91\u7535\u8111\u526A\u8D34\u677F\uFF0C\u4F46\u5F53\u524D\u6CA1\u6709\u63A7\u5236\u6743\uFF1B\u63A5\u7BA1\u4E91\u7535\u8111\u540E\u518D\u6309 Ctrl+V"),{ok:!0,code:"CLIPBOARD_KEY_NOT_SENT"}}return u("\u5DF2\u7C98\u8D34\u5230\u4E91\u7535\u8111"),{ok:!0}}async function Bt({readCloud:t,writeLocal:d,ensureControl:c,notify:r=()=>{}}={}){let u=d||(o=>ft(o));if(typeof c=="function")try{if(!await c())return r("\u9700\u8981\u5148\u63A5\u7BA1\u4E91\u7535\u8111\uFF0C\u624D\u80FD\u590D\u5236\u4E91\u7535\u8111\u5185\u5BB9"),{ok:!1,code:"CLIPBOARD_CONTROL_REQUIRED"}}catch(o){return r(Ze(o)||"\u63A5\u7BA1\u4E91\u7535\u8111\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:o?.code||"CLIPBOARD_CONTROL_REQUIRED"}}let n;try{n=await t()}catch(o){return r(Ze(o)||"\u8BFB\u53D6\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_READ_FAILED"}}let s=st(n);if(!s)return r("\u4E91\u7535\u8111\u526A\u8D34\u677F\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53EF\u590D\u5236\u7684\u5185\u5BB9"),{ok:!1,code:"CLIPBOARD_EMPTY"};try{await u(s)}catch(o){return r(Ze(o)||"\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_WRITE_FAILED"}}return r("\u5DF2\u590D\u5236\u5230\u672C\u5730"),{ok:!0,text:s}}var bn=/^```\s*([\w+#.-]*)\s*$/u,hn=/^(#{1,6})\s+(.*)$/u,zt=/^\s*[-*+]\s+(.*)$/u,Ut=/^\s*(\d{1,3})[.)]\s+(.*)$/u,yt=/^\s*>\s?(.*)$/u,mn=/^\s*([-*_])\s*(?:\1\s*){2,}$/u;function xn(t){let c=(typeof t=="string"?t.replace(/\r\n?/gu,`
|
|
2
2
|
`):"").split(`
|
|
3
|
-
`),r=[],
|
|
4
|
-
`)}),o.length=0)},s=[];for(;
|
|
5
|
-
`)});continue}if(o.trim()===""){
|
|
6
|
-
`)});continue}let D=pt.exec(o),S=ft.exec(o);if(D||S){a(s);let O={type:S?"ordered":"unordered",items:[],start:S?Number(S[1]):1};for(;n<d.length;){let _=pt.exec(d[n]),E=ft.exec(d[n]);if(!_&&!E)break;O.items.push((_?_[1]:E[2]).trim()),n+=1}r.push(O);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),T=p<0?n.length:p+1;r(n.slice(0,T)),n=n.slice(T)}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,T)=>t("li",{key:`${o}-l${T}`},n(p,`${o}-l${T}`))))}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,T]=f("loading"),[D,S]=f(""),[O,_]=f([]),[E,M]=f(""),[ee,v]=f([]),[ge,X]=f(""),[Y,N]=f([]),B=o(null),[W,L]=f(!1),[$,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=$;let de=o("loading");de.current=p;let he=o(0),C=o(!0),Ie=o(null),ue=o(!0),j=o("");j.current=E;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;M(c),T("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),T("ready")}catch(u){if(!C.current||i!==he.current)return;T("error"),S(u?.message||"\u65E0\u6CD5\u8BFB\u53D6\u4F1A\u8BDD\u5185\u5BB9")}},[V]),ce=a(async()=>{if(T("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(_(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);_(u?[{sessionId:u,title:ae(i?.title)||"\u65B0\u4F1A\u8BDD"}]:[]),await re(u)}catch(c){if(!C.current)return;T("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"||!E)return;let c=!1,h=null,i=async()=>{try{let u=await V("personal-assistant.session.events",{sessionId:E,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(E);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,E,V,w,re]),s(()=>{let c=Ie.current;c&&ue.current&&(c.scrollTop=c.scrollHeight)},[ee,$]);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&&N(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,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},...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"||!E)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||$){be([...U.current,{clientTurnId:crypto.randomUUID(),text:h,sessionId:E,uploads:i,attempts:0,queuedAt:Date.now()}]),ue.current=!0,X(""),N([]),S(""),q("");return}X(""),N([]),S(""),q("");let u=await Pe({clientTurnId:crypto.randomUUID(),text:h,sessionId:E,uploads:i,attempts:0},{restoreDraft:!0});!u.ok&&oe(u.failure)&&ye(u.item,u.failure)};s(()=>{if(p!=="ready"||!E||W||$||ne.length===0)return;let c=setTimeout(()=>{z(!1)},Yt);return()=>clearTimeout(c)},[p,E,W,$,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:E,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)}),$?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:()=>N(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||$?"\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||$?"\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||$?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 _ of[...n])_()},p=()=>{if(!r)throw Jt();if(s)throw new Error("\u4E91\u7535\u8111\u5DE5\u4F5C\u9762\u677F\u5DF2\u5173\u95ED")},T,D,S=()=>t.openPanelTab(d,xt),O={available:r,unavailableReason:r?null:wt,subscribe:_=>(n.add(_),()=>n.delete(_)),getSnapshot:()=>o,bind(_,E){if(p(),!_?.agentId||!_?.botId||typeof E!="function")throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");a&&(a.scope.agentId!==_.agentId||a.scope.botId!==_.botId)&&(T(),T=t.registerPanelSurface(d)),a=Object.freeze({scope:Object.freeze({..._}),request:E}),f(),S()},open(){p(),a&&(S(),t.setPanelExpanded(d,!0))},collapse(){p(),t.setPanelExpanded(d,!1)},dispose(){s||(s=!0,D?.(),T?.(),n.clear())}};return r&&(T=t.registerPanelSurface(d),D=g.inject("sidebar.right.panel.tab",()=>g.register({name:"sidebar.right.panel.tab",key:xt,inject:()=>({workbench:O})},en))),O}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-28T11:01:46.027Z",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,[T,D]=p(null),[S,O]=p([]),[_,E]=p(""),[M,ee]=p(null),[v,ge]=p(!1),[X,Y]=p(g),[N,B]=p("loading"),[W,L]=p(""),[$,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&&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))},z=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,R=se.height*Le;Q.clearRect(0,0,b.width,b.height),Q.drawImage(A,(b.width-ke)/2,(b.height-R)/2,ke,R);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 R;try{R=JSON.parse(ke.data)}catch{return}if(R.type==="ready"){b.suspended=!1,b.resuming=!1,b.receivedSeq=-1,b.session=R.sessionId,b.readOnly=!!R.readOnly,b.display=Qe(R.display),b.mode=e,P.current.reset(R);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(R.type==="control"){P.current.accept(R),L("");return}if(R.type==="idle"){u(R);return}if(R.type==="frame"){R.unchanged||(b.frameMetadata=R);return}if(R.type==="clipboard.response"){de.current?.accept(R);return}if(R.type==="closed"){R.retryable!==!0&&z(R);return}if(R.type==="error"){if(Number.isSafeInteger(R.controlEpoch)&&R.controlEpoch<b.controlEpoch)return;if(L(R.message||R.code||"\u4E91\u7535\u8111\u8BF7\u6C42\u5931\u8D25"),b.handoffSupported&&R.recoverable===!0){P.current.reject(R);return}if(R.recoverable===!0&&Number(R.status)===409){R.code==="DESKTOP_SESSION_IDLE"?u():(b.pendingInputs=[],b.readOnly=!0,b.pressed.clear(),b.buttons.clear(),te(!0),B("readonly"));return}if(Number(R.status)===409&&e==="control"&&!b.session){x(w.current.handoffSupported?"observe":"read");return}[404,409].includes(Number(R.status))||R.code==="DESKTOP_SESSION_NOT_FOUND"?z(R):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){z();return}if(document.hidden){B("hidden");return}let R=++b.retries;if(_e(R),R>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**(R-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(!U){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(""),E(""),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=[],O([]),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,O(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=[],O([]),Y(""),B("directory-error"),E(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"}[N],Ee={...H,borderRadius:6,padding:"7px 12px",cursor:"pointer",font:"inherit"},Z=["ready","readonly","hidden","reconnecting","dormant","resuming"].includes(N),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=N==="unconfigured"?Dt:N==="empty"?"\u52A9\u7406\u6B63\u5728\u51C6\u5907\u4E2D":N==="directory-error"?"\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406":"\u6B63\u5728\u68C0\u67E5\u52A9\u7406\u72B6\u6001",Nt=N==="unconfigured"?Ot:N==="empty"?"\u4E91\u7AEF\u521D\u59CB\u5316\u5B8C\u6210\u540E\uFF0C\u53EF\u7528\u52A9\u7406\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002":N==="directory-error"?_:"\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(N)?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)"}},N==="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:$?"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&&N!=="loading"?s("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",alignItems:"center"}},N==="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,N==="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||$&&!P.current.snapshot.available&&!(w.current.mode==="control"&&["dormant","resuming"].includes(N)),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,$&&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(N),onClick:()=>{x(w.current.handoffSupported?"observe":"read")}},N==="connecting"?"\u6B63\u5728\u542F\u52A8\u2026":"\u91CD\u65B0\u8FDE\u63A5"):null,Z&&$?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&&$&&P.current.snapshot.available?s("button",{style:{...rt,padding:"3px 9px",fontSize:11},onClick:()=>P.current.acquire()},"\u63A5\u7BA1"):null,Z&&!$?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(N)?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(N),onClick:()=>N==="dormant"?y():void x(w.current.handoffSupported?"observe":"control")},N==="dormant"?"\u6062\u590D\u753B\u9762":$&&N==="readonly"?"\u7533\u8BF7\u63A7\u5236":Z?"\u91CD\u65B0\u8FDE\u63A5":"\u8FDE\u63A5\u4E91\u7535\u8111"):null,Oe?s("button",{style:Ee,disabled:N==="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),N==="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"),M?s("div",{style:{paddingTop:8}},`\u76EE\u5F55\u8FDE\u63A5\u5173\u95ED\u7801\uFF1A${M}`):null,s("div",{style:{paddingTop:8,lineHeight:1.8,overflowWrap:"anywhere"}},s("div",null,`\u4E91\u7AEF\u5B9E\u4F8B\uFF1A${T?.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,T]=a(""),[D,S]=a(0);n(()=>{let _=!1;return f(null),T(""),(async()=>{try{let E=await t("personal-assistant.configuration");if(!E.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 M=await t("personal-assistant.bots.list");if(M.directoryAvailable!==!0)throw new Error("\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");let ee=Je(M.bots,E.botId||M.primaryBotId);_||f({agentId:E.agentId,botId:ee})}catch(E){_||T(E.message||"\u4E91\u7AEF\u52A9\u7406\u6682\u4E0D\u53EF\u7528")}})(),()=>{_=!0}},[t,D]);let O=s((_,E={})=>{if(!o)throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");if(E.agentId&&E.agentId!==o.agentId)throw new Error("\u4E91\u7AEF\u5B9E\u4F8B\u4E0D\u4E00\u81F4");if(_!=="personal-assistant.bots.list"&&E.botId&&E.botId!==o.botId)throw new Error("\u4E91\u7AEF\u52A9\u7406\u4E0D\u4E00\u81F4");return t(_,{...E,...o})},[t,o?.agentId,o?.botId]);return n(()=>{o&&g?.available?g.bind(o,O):o&&T(g?.unavailableReason||"\u5F53\u524D\u5BBF\u4E3B\u9700\u8981\u66F4\u65B0\u539F\u751F\u4FA7\u680F\u7EC4\u4EF6")},[g,O,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:O,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(_=>_+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,T]=a(null),[D,S]=a(""),[O,_]=a(!1),[E,M]=a(""),[ee,v]=a(!1),[ge,X]=a(""),[Y,N]=a(!1),[B,W]=a(""),[L,$]=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()=>{_(!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");T(Array.isArray(u?.bots)?u.bots:[]);try{let y=await t("personal-assistant.settings.inspect");$(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){$(null),Be(null),P(y?.message||"\u8BFB\u53D6\u4E91\u7AEF\u914D\u7F6E\u5931\u8D25")}}else T([]),$(null),Be(null);M(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 ${Date.now()-h} ms`)}catch(i){S(i?.message||"\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25"),M(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 \u5931\u8D25`)}finally{_(!1)}},[t]),j=o?.agentId||"",V=!!j&&ge.trim()===j,w=s(async()=>{if(V){N(!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}),T([]),M("")}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{N(!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=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");$(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(!L)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(L.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===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},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),L.detailAvailable===!1?z("\u8BF4\u660E",r("div",{style:m.note},L.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),E?r("span",{style:m.note},`\u3000\u4E0A\u6B21\u68C0\u67E5 ${E}`):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:O,onClick:()=>{ue()}},O?"\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})});})();
|
|
3
|
+
`),r=[],u=0,n=o=>{o.length!==0&&(r.push({type:"paragraph",text:o.join(`
|
|
4
|
+
`)}),o.length=0)},s=[];for(;u<c.length;){let o=c[u],b=bn.exec(o);if(b){n(s);let _=[];for(u+=1;u<c.length&&!/^```\s*$/u.test(c[u]);)_.push(c[u]),u+=1;u+=1,r.push({type:"code",lang:b[1]||"",text:_.join(`
|
|
5
|
+
`)});continue}if(o.trim()===""){n(s),u+=1;continue}let g=hn.exec(o);if(g){n(s),r.push({type:"heading",level:g[1].length,text:g[2].trim()}),u+=1;continue}if(mn.test(o)){n(s),r.push({type:"rule"}),u+=1;continue}let h=yt.exec(o);if(h){n(s);let _=[h[1]];for(u+=1;u<c.length&&yt.test(c[u]);)_.push(yt.exec(c[u])[1]),u+=1;r.push({type:"quote",text:_.join(`
|
|
6
|
+
`)});continue}let x=zt.exec(o),k=Ut.exec(o);if(x||k){n(s);let _={type:k?"ordered":"unordered",items:[],start:k?Number(k[1]):1};for(;u<c.length;){let A=zt.exec(c[u]),J=Ut.exec(c[u]);if(!A&&!J)break;_.items.push((A?A[1]:J[2]).trim()),u+=1}r.push(_);continue}s.push(o),u+=1}return n(s),r}function wn(t){let d=typeof t=="string"?t:"",c=[],r=n=>{n&&c.push({type:"text",text:n})},u=d;for(;u.length>0;){let n=/^`([^`]+)`/u.exec(u);if(n){c.push({type:"code",text:n[1]}),u=u.slice(n[0].length);continue}let s=/^\*\*([^*\n]+)\*\*/u.exec(u)||/^__([^_\n]+)__/u.exec(u);if(s){c.push({type:"strong",text:s[1]}),u=u.slice(s[0].length);continue}let o=/^\*([^*\s][^*\n]*)\*/u.exec(u)||/^_([^_\s][^_\n]*)_/u.exec(u);if(o){c.push({type:"em",text:o[1]}),u=u.slice(o[0].length);continue}let b=/^\[([^\]]+)\]\(([^)\s]+)\)/u.exec(u);if(b){c.push({type:"link",text:b[1],href:b[2]}),u=u.slice(b[0].length);continue}let g=u.slice(1).search(/[`*_[\]\n]/u),h=g<0?u.length:g+1;r(u.slice(0,h)),u=u.slice(h)}return c.reduce((n,s)=>{let o=n[n.length-1];return s.type==="text"&&o&&o.type==="text"?n[n.length-1]={type:"text",text:o.text+s.text}:n.push(s),n},[])}function Ft(t,d,c={}){let r=xn(d);if(r.length===0)return null;let u=(n,s)=>wn(n).map((o,b)=>{let g=`${s}-i${b}`;return o.type==="code"?t("code",{key:g,style:c.inlineCode},o.text):o.type==="strong"?t("strong",{key:g},o.text):o.type==="em"?t("em",{key:g},o.text):o.type==="link"?/^(https?:|mailto:|cloud-file:)/iu.test(o.href)?t("a",{key:g,href:o.href,target:"_blank",rel:"noreferrer noopener",style:c.link},o.text):t("span",{key:g},o.text):t("span",{key:g},o.text)});return r.map((n,s)=>{let o=`b${s}`;if(n.type==="code")return t("pre",{key:o,style:c.codeBlock},t("code",null,n.text));if(n.type==="heading")return t("div",{key:o,style:{...c.heading,...n.level<=2?c.headingStrong:null}},u(n.text,o));if(n.type==="rule")return t("hr",{key:o,style:c.rule});if(n.type==="quote")return t("blockquote",{key:o,style:c.quote},u(n.text,o));if(n.type==="unordered"||n.type==="ordered"){let b=n.type==="ordered"?"ol":"ul";return t(b,{key:o,style:c.list,start:n.type==="ordered"&&n.start!==1?n.start:void 0},n.items.map((g,h)=>t("li",{key:`${o}-l${h}`},u(g,`${o}-l${h}`))))}return t("p",{key:o,style:c.paragraph},u(n.text,o))})}var Sn={code:{copyLabel:"\u590D\u5236",copiedLabel:"\u5DF2\u590D\u5236",toolbarLabels:{codeLabel:"\u4EE3\u7801",wrapLabel:"\u81EA\u52A8\u6362\u884C",unwrapLabel:"\u53D6\u6D88\u6362\u884C"}},footnotes:"\u811A\u6CE8"};function In(t,d,c,r){let u=r?.MarkdownText,n=typeof d=="string"?d:"";return typeof u=="function"?t(u,{text:n,labels:Sn}):Ft(t,n,c)||"\u2026"}var vn="\u6709\u4EC0\u4E48\u53EF\u4EE5\u5E2E\u4F60\uFF1F",En=new Set(["DSH_SESSION_BUSY","DSH_TURN_TIMEOUT"]),$t={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"},An=t=>{let d=String(t||"").trim();return d?$t[d]?$t[d]:/^[A-Z][A-Z0-9_]{5,}$/u.test(d)?"\u4E91\u7AEF\u6CA1\u6709\u5B8C\u6210\u8FD9\u4E00\u8F6E\uFF0C\u8BF7\u91CD\u8BD5":d.slice(0,160):"\u8BF7\u68C0\u67E5\u4EFB\u52A1\u72B6\u6001\u540E\u91CD\u8BD5"},kn=400,Tn=8,Mt=1500,T={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}},U=t=>typeof t=="string"?t:"",Rn="agentkit.personal-assistant.current-session.v1",_n=t=>{let d=U(t?.agentId),c=U(t?.botId);return d&&c?`${Rn}:${encodeURIComponent(d)}:${encodeURIComponent(c)}`:""},Cn=t=>{if(!t)return"";try{return U(globalThis.localStorage?.getItem(t))}catch{return""}},On=(t,d)=>{let c=U(d);if(!(!t||!c))try{globalThis.localStorage?.setItem(t,c)}catch{}},Ye=(t,d,c=503)=>Object.assign(new Error(d),{code:t,status:c}),Dn=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"})),Nn=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"})),jt=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 Wt({React:t,request:d,scope:c,markdown:r=void 0,onOpenComputer:u=null}={}){if(!t)return"\u4E2A\u4EBA\u52A9\u7406\u5BF9\u8BDD\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:n,useCallback:s,useEffect:o,useRef:b,useState:g}=t,h=_n(c),[x,k]=g("loading"),[_,A]=g(""),[J,X]=g([]),[P,w]=g(""),[ve,O]=g(""),[D,we]=g(""),[C,N]=g([]),[q,L]=g(""),[ee,ue]=g([]),Ke=b(null),[re,Me]=g(!1),[se,pe]=g(!1),[Ve,Se]=g(""),[W,le]=g([]),[Ne,oe]=g(""),ye=b(0),F=b(new Map),ce=b([]),H=b(!1),de=b(null),ke=b(!1);ke.current=re;let je=b(!1);je.current=se;let z=b("loading");z.current=x;let ie=b(0),M=b(!0),fe=b(null),ge=b(!0),Ie=b("");Ie.current=P;let K=s(async(i,y={})=>{if(typeof d!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return d(i,y)},[d]),_e=s(i=>{!Array.isArray(i)||i.length===0||N(y=>{let f=[...y];for(let l of i)if(!(!l||typeof l!="object")){if(l.type==="message"){let I=U(l.id)||`local-${f.length}`,v=U(l.role)||"assistant",B=U(l.text),Ae=f.findIndex(Be=>Be.id===I),G={id:I,role:v,text:B,done:l.done!==!1,clientTurnId:l.clientTurnId,status:"accepted"};if(Ae>=0)f[Ae]={...f[Ae],...G};else if(v==="user"){let Be=f.findIndex(Re=>Re.role==="user"&&l.clientTurnId&&Re.clientTurnId===l.clientTurnId);Be>=0?f[Be]={...G}:f.push(G)}else f.push(G)}else if(l.type==="delta"){let I=U(l.id)||`local-${f.length}`,v=f.findIndex(B=>B.id===I);v>=0?f[v]={...f[v],text:f[v].text+U(l.text)}:f.push({id:I,role:"assistant",text:U(l.text),done:!1})}else if(l.type==="step"&&U(l.text)){let I={id:U(l.id),role:"step",text:U(l.text),done:!0},v=f.findIndex(B=>B.id===I.id);v>=0?f[v]=I:f.push(I)}}return f})},[]),be=s(async i=>{if(!i)return;let y=Ie.current;if(y&&y!==i&&ce.current.length>0){let l=ce.current.length;ce.current=[],le([]),de.current&&(clearTimeout(de.current),de.current=null),oe(`\u5DF2\u5207\u6362\u4F1A\u8BDD\uFF0C${l} \u6761\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001\uFF0C\u5DF2\u53D6\u6D88`)}else y&&y!==i&&oe("");Ie.current=i;let f=++ie.current;w(i),k("loading"),A(""),ye.current=0,ge.current=!0,N([]);try{let l=await K("personal-assistant.session.snapshot",{sessionId:i});if(!M.current||Ie.current!==i||f!==ie.current)return;if(!l||typeof l!="object"||Array.isArray(l)||!Array.isArray(l.messages)||!Array.isArray(l.turns)||!Number.isSafeInteger(l.cursor)||l.cursor<0)throw Ye("PERSONAL_ASSISTANT_SESSION_SNAPSHOT_INVALID","\u4E91\u7AEF\u4F1A\u8BDD\u5FEB\u7167\u683C\u5F0F\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u540C\u6B65");O(U(l?.runtimeInstanceId)),we(U(l?.stateStorage)),ye.current=l.cursor;let I=l.messages;N(I.map((v,B)=>({id:U(v?.id)||`history-${B}`,role:U(v?.role)||"assistant",text:U(v?.text),done:!0}))),pe(l.turns?.some(v=>["queued","running"].includes(v.status))||!1),On(h,i),k("ready")}catch(l){if(!M.current||f!==ie.current)return;k("error"),A(l?.message||"\u65E0\u6CD5\u8BFB\u53D6\u4F1A\u8BDD\u5185\u5BB9")}},[K,h]),We=s(async()=>{if(M.current){if(ke.current||je.current||ce.current.length>0){oe("\u5F53\u524D\u4F1A\u8BDD\u8FD8\u6709\u8FDB\u884C\u4E2D\u7684\u4EFB\u52A1\uFF0C\u8BF7\u7B49\u5F85\u5B8C\u6210\u540E\u518D\u65B0\u5EFA\u4F1A\u8BDD");return}k("loading"),A("");try{let i=await K("personal-assistant.session.create",{}),y=U(i?.sessionId);if(!y)throw Ye("PERSONAL_ASSISTANT_SESSION_CREATE_INVALID","\u4E91\u7AEF\u6CA1\u6709\u8FD4\u56DE\u6709\u6548\u7684\u65B0\u4F1A\u8BDD\u6807\u8BC6");X(f=>[...f.filter(l=>U(l?.sessionId)!==y),{sessionId:y,title:U(i?.title)||"\u65B0\u4F1A\u8BDD"}]),await be(y)}catch(i){if(!M.current)return;k("error"),A(i?.message||"\u65B0\u4F1A\u8BDD\u521B\u5EFA\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5")}}},[K,be]),S=s(async()=>{if(k("loading"),A(""),!!M.current)try{let i=await K("personal-assistant.sessions.list");if(!M.current)return;if(!Array.isArray(i?.sessions))throw Ye("PERSONAL_ASSISTANT_SESSION_LIST_INVALID","\u4E91\u7AEF\u4F1A\u8BDD\u76EE\u5F55\u683C\u5F0F\u65E0\u6548\uFF0C\u8BF7\u91CD\u8BD5");let y=new Set;if(i.sessions.some(I=>{let v=U(I?.sessionId);return!I||typeof I!="object"||!v||y.has(v)?!0:(y.add(v),!1)}))throw Ye("PERSONAL_ASSISTANT_SESSION_LIST_INVALID","\u4E91\u7AEF\u4F1A\u8BDD\u76EE\u5F55\u5305\u542B\u65E0\u6548\u4F1A\u8BDD\uFF0C\u8BF7\u91CD\u8BD5");let f=i.sessions;O(U(i.runtimeInstanceId)),we(U(i.stateStorage)),X(f);let l=Cn(h);if(l&&!f.some(I=>U(I.sessionId)===l))throw Ye("PERSONAL_ASSISTANT_SESSION_STATE_MISSING","\u4E91\u7AEF\u5386\u53F2\u4F1A\u8BDD\u6682\u65F6\u4E0D\u53EF\u89C1\uFF0C\u8BF7\u68C0\u67E5\u5B9E\u4F8B\u72B6\u6001\u540E\u91CD\u8BD5\uFF0C\u6216\u624B\u52A8\u9009\u62E9\u4F1A\u8BDD");if(f.length>0){let I=f.find(v=>U(v.sessionId)===l)||f[0];await be(U(I.sessionId));return}await We()}catch(i){if(!M.current)return;k("error"),A(i?.message||"\u4F1A\u8BDD\u901A\u9053\u6682\u65F6\u4E0D\u53EF\u7528")}},[K,We,be,h]);o(()=>(M.current=!0,S(),()=>{M.current=!1,de.current&&(clearTimeout(de.current),de.current=null)}),[S]),o(()=>{if(x!=="ready"||!P)return;let i=!1,y=null,f=async()=>{try{let l=await K("personal-assistant.session.events",{sessionId:P,cursor:ye.current});if(i)return;if(!l||typeof l!="object"||Array.isArray(l)||!Array.isArray(l.events)||!Array.isArray(l.turns)||!Number.isSafeInteger(l.cursor))throw Ye("PERSONAL_ASSISTANT_SESSION_EVENTS_INVALID","\u4E91\u7AEF\u4F1A\u8BDD\u589E\u91CF\u683C\u5F0F\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u540C\u6B65");if(l.cursor<ye.current)throw Ye("SESSION_CURSOR_STALE","\u4F1A\u8BDD\u65E5\u5FD7\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u540C\u6B65",409);ye.current=l.cursor,_e(l.events),pe(l.turns.some(G=>["queued","running"].includes(G.status)));let I=l.turns.findLast(G=>["queued","running"].includes(G.status)),v={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"},B=I?.progress?.tool;Se(B?`${I.progress.state==="running"?"\u6B63\u5728":"\u5DF2\u5B8C\u6210"}${v[B]||(B.startsWith("cloud_browser_")?"\u64CD\u4F5C\u4E91\u7AEF\u6D4F\u89C8\u5668":"\u6267\u884C\u5DE5\u5177")}`:"");let Ae=l.turns.filter(G=>["failed","interrupted","cancelled"].includes(G.status)&&!En.has(String(G.error||""))).map(G=>({type:"step",id:`turn-status-${G.turnId}`,text:`\u4EFB\u52A1${G.status==="failed"?"\u5931\u8D25":"\u5DF2\u4E2D\u65AD"}\uFF1A${An(G.error)}`}));_e(Ae),A("")}catch(l){if(!i){if(l.code==="SESSION_CURSOR_STALE"||l.code==="PERSONAL_ASSISTANT_SESSION_EVENTS_INVALID"){be(P);return}A(l.message||"\u4E91\u7AEF\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u6B63\u5728\u6062\u590D\uFF1B\u4EFB\u52A1\u4E0D\u4F1A\u6539\u5230\u672C\u673A\u6267\u884C")}}i||(y=setTimeout(f,600))};return y=setTimeout(f,200),()=>{i=!0,clearTimeout(y)}},[x,P,K,_e,be]),o(()=>{let i=fe.current;i&&ge.current&&(i.scrollTop=i.scrollHeight)},[C,se]);let Te=async i=>{let y=Array.from(i.target.files||[]);i.target.value="";let f=[];for(let l of y.slice(0,4)){if(!l||l.size>512*1024){A("\u6BCF\u4E2A\u9644\u4EF6\u6700\u591A 512 KiB\uFF0C\u8BF7\u5148\u538B\u7F29\u6216\u62C6\u5206\u6587\u4EF6");continue}let I=await new Promise(v=>{let B=new FileReader;B.onload=()=>v(String(B.result||"")),B.onerror=()=>v(""),B.readAsDataURL(l)});I&&f.push({id:`${Date.now()}-${l.name}`,name:l.name,mimeType:l.type||"application/octet-stream",size:l.size,dataUrl:I})}f.length&&ue(l=>[...l,...f].slice(0,4))},V=i=>{ce.current=i,le(i)},et=()=>{de.current&&(clearTimeout(de.current),de.current=null)},Le=i=>Number(i?.status)===409||/SESSION_BUSY|active turn|正忙|处理中/u.test(`${i?.code||""} ${i?.message||""}`),$=async(i,{restoreDraft:y=!1}={})=>{F.current.set(i.clientTurnId,i),ge.current=!0,Me(!0),A(""),pe(!0),N(l=>l.some(I=>I.clientTurnId===i.clientTurnId)?l.map(I=>I.clientTurnId===i.clientTurnId?{...I,status:"pending"}:I):[...l,{id:`local-user-${i.clientTurnId}`,clientTurnId:i.clientTurnId,role:"user",text:i.text,done:!1,status:"pending"}]);let f=i;try{let l=Array.isArray(f.attachments)?f.attachments:[];if(l.length===0&&Array.isArray(f.uploads)&&f.uploads.length>0){let v=[];for(let B of f.uploads)v.push(await K("personal-assistant.file.upload",{sessionId:f.sessionId,name:B.name,dataUrl:B.dataUrl}));l=v.map(({path:B,name:Ae,mediaType:G,bytes:Be})=>({path:B,name:Ae,mediaType:G,bytes:Be})),f={...f,attachments:l,uploads:[]},F.current.set(f.clientTurnId,f)}let I=await K("personal-assistant.turn.submit",{sessionId:f.sessionId,text:f.text,clientTurnId:f.clientTurnId,attachments:l});return M.current?(F.current.delete(f.clientTurnId),N(v=>v.map(B=>B.clientTurnId===f.clientTurnId?{...B,status:"accepted",turnId:I.turnId}:B)),{ok:!0,item:f}):{ok:!0,item:f}}catch(l){return M.current?(pe(Le(l)),y&&!Le(l)&&L(I=>I||f.text),N(I=>I.map(v=>v.clientTurnId===f.clientTurnId?{...v,status:"failed",failure:l.message||"\u53D1\u9001\u7ED3\u679C\u5F85\u786E\u8BA4\uFF0C\u91CD\u8BD5\u5C06\u590D\u7528\u539F\u6807\u8BC6"}:v)),{ok:!1,failure:l,item:f}):{ok:!1,failure:l,item:f}}finally{M.current&&Me(!1)}},Ce=(i,y)=>{let f=(i.attempts||0)+1;if(F.current.delete(i.clientTurnId),N(I=>I.filter(v=>v.clientTurnId!==i.clientTurnId)),f>Tn){oe(`\u6392\u961F\u6D88\u606F\u591A\u6B21\u672A\u53D1\u51FA\uFF08${y?.message||"\u4E91\u7535\u8111\u4ECD\u5FD9"}\uFF09\uFF0C\u5DF2\u653E\u56DE\u8F93\u5165\u6846\uFF0C\u8BF7\u624B\u52A8\u91CD\u8BD5`),L(I=>I||i.text);return}V([{...i,attempts:f},...ce.current]);let l=(Mt*Math.min(f,3)/1e3).toFixed(1);oe(`\u4E91\u7535\u8111\u4ECD\u5728\u5904\u7406\u4E0A\u4E00\u8F6E\uFF0C\u6D88\u606F\u5DF2\u6392\u961F\uFF0C\u7EA6 ${l} \u79D2\u540E\u81EA\u52A8\u91CD\u53D1`),et(),de.current=setTimeout(()=>{de.current=null,Qe(!0)},Mt*Math.min(f,3))},Qe=async i=>{let y=Ie.current;if(H.current||!M.current||z.current!=="ready"||!y||ke.current||!i&&je.current)return!1;let f=ce.current[0];if(!f)return!1;if(f.sessionId!==y)return V([]),oe("\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001"),!1;H.current=!0,V(ce.current.slice(1));try{let l=await $(f);return l.ok?!0:(Le(l.failure)?Ce(l.item||f,l.failure):oe(`\u6392\u961F\u6D88\u606F\u53D1\u9001\u5931\u8D25\uFF1A${l.failure?.message||"\u8BF7\u70B9\u51FB\u91CD\u8BD5"}`),!1)}finally{H.current=!1}},Oe=i=>{F.current.delete(i),V(ce.current.filter(y=>y.clientTurnId!==i)),oe("\u5DF2\u64A4\u56DE\u6392\u961F\u6D88\u606F")},Pe=async(i=null)=>{if(x!=="ready"||!P)return;if(i){re||$(i,{restoreDraft:!0});return}let y=q.trim()||(ee.length?"\u8BF7\u67E5\u770B\u9644\u4EF6\u3002":"");if(!y)return;let f=ee.map(({name:I,mimeType:v,size:B,dataUrl:Ae})=>({name:I,mimeType:v,size:B,dataUrl:Ae}));if(re||se){V([...ce.current,{clientTurnId:crypto.randomUUID(),text:y,sessionId:P,uploads:f,attempts:0,queuedAt:Date.now()}]),ge.current=!0,L(""),ue([]),A(""),oe("");return}L(""),ue([]),A(""),oe("");let l=await $({clientTurnId:crypto.randomUUID(),text:y,sessionId:P,uploads:f,attempts:0},{restoreDraft:!0});!l.ok&&Le(l.failure)&&Ce(l.item,l.failure)};o(()=>{if(x!=="ready"||!P||re||se||W.length===0)return;let i=setTimeout(()=>{Qe(!1)},kn);return()=>clearTimeout(i)},[x,P,re,se,W]),o(()=>{if(W.length===0||typeof window>"u"||typeof window.addEventListener!="function")return;let i=y=>{y.preventDefault(),y.returnValue=""};return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[W.length]);let Ee=[P?"\u5F53\u524D\u52A9\u7406\u7EBF\u7A0B\u5DF2\u6301\u4E45\u5316":"",ve?`\u8FD0\u884C\u5B9E\u4F8B ${ve}`:"",D?`\u72B6\u6001 ${D}`:""].filter(Boolean).join(" \xB7 "),he=n("header",{style:T.header,"data-window-drag":""},n("h1",{style:T.title},"\u4E2A\u4EBA\u52A9\u7406"),n("span",{style:T.status,title:Ee||void 0},x==="ready"?"\u4E91\u7AEF\u5E38\u9A7B\uFF0C\u5173\u6389\u7A97\u53E3\u4E5F\u4F1A\u7EE7\u7EED":x==="loading"?"\u6B63\u5728\u8FDE\u63A5\u2026":"\u8FDE\u63A5\u4E0D\u53EF\u7528"),n("span",{style:T.spacer}),n("button",{type:"button","data-window-drag-recall":"",disabled:x==="loading"||re||se||W.length>0,onClick:()=>{We()},"aria-label":"\u5F00\u59CB\u65B0\u4EFB\u52A1",title:W.length>0?"\u8BF7\u7B49\u5F85\u6392\u961F\u6D88\u606F\u53D1\u9001\u540E\u518D\u5F00\u59CB\u65B0\u4EFB\u52A1":"\u5F00\u59CB\u4E00\u4E2A\u65B0\u7684\u52A9\u7406\u4EFB\u52A1\u7EBF\u7A0B",style:T.ghost},"\u65B0\u4EFB\u52A1"),u?n("button",{type:"button","data-window-drag-recall":"",onClick:u,"aria-label":"\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",title:"\u6253\u5F00\u6216\u91CD\u65B0\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",style:{...T.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","data-agent-id":U(c?.agentId)||void 0,"data-bot-id":U(c?.botId)||void 0,"data-session-id":P||void 0,"data-runtime-instance-id":ve||void 0,"data-state-storage":D||void 0,style:T.page,onClick:async i=>{let y=i.target.closest?.('a[href^="cloud-file:"]');if(y){i.preventDefault();try{let f=await K("personal-assistant.file.download",{sessionId:P,path:decodeURIComponent(y.getAttribute("href").slice(11))}),l=Uint8Array.from(atob(f.data),B=>B.charCodeAt(0)),I=URL.createObjectURL(new Blob([l],{type:"application/octet-stream"})),v=document.createElement("a");v.href=I,v.download=f.name,v.click(),setTimeout(()=>URL.revokeObjectURL(I),1e3)}catch(f){A(f.message||"\u4E91\u7AEF\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}}}},he,n("style",null,"@keyframes pa-awaiting { 0%, 100% { opacity: 0.35 } 50% { opacity: 1 } }"),_&&C.length>0?n("div",{role:"alert",style:{padding:"8px 16px",background:"#fff0d6",display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"}},n("span",null,_),P?n("button",{type:"button",style:T.ghost,disabled:x==="loading",onClick:()=>{be(P)}},"\u91CD\u65B0\u540C\u6B65\u4F1A\u8BDD"):null):null,n("div",{ref:fe,"data-personal-assistant-messages":"true",style:T.scroller,onScroll:i=>{let y=i.currentTarget;ge.current=y.scrollHeight-y.clientHeight-y.scrollTop<64}},n("div",{style:T.thread},C.length===0?n("div",{style:{...T.status,paddingTop:40,textAlign:"center"}},x==="error"?n("div",{style:{...T.centeredInner,margin:"0 auto"}},n("strong",null,"\u6682\u65F6\u8FDE\u4E0D\u4E0A\u4E2A\u4EBA\u52A9\u7406"),n("span",null,_||"\u8BF7\u7A0D\u540E\u91CD\u8BD5"),n("button",{style:T.ghost,onClick:()=>{S()}},"\u91CD\u8BD5")):x==="loading"?"\u6B63\u5728\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406\u2026":vn):null,C.map(i=>{if(i.role==="step")return n("div",{key:i.id,style:T.step},`\xB7 ${i.text}`);let y=i.role==="user";return n("div",{key:i.id,style:y?T.rowUser:T.row},n("span",{style:T.who},y?"\u4F60":"\u52A9\u7406"),n("div",{style:y?T.bubbleUser:T.bubble},y?i.text||"\u2026":In(n,i.text,T,r)),i.status==="failed"?n("button",{onClick:()=>{Pe(F.current.get(i.clientTurnId))},disabled:re},`${i.failure} \xB7 \u91CD\u8BD5\u53D1\u9001`):null)}),se?n("div",{key:"awaiting",style:T.row},n("span",{style:T.who},"\u52A9\u7406"),n("div",{style:{...T.bubble,color:"var(--dsw-alias-label-secondary, #536174)"}},n("span",{style:T.pulse},Ve||"\u6B63\u5728\u5904\u7406\u2026"))):null,W.map(i=>n("div",{key:`queued-${i.clientTurnId}`,style:T.rowUser},n("span",{style:T.who},"\u4F60 \xB7 \u6392\u961F\u4E2D"),n("div",{style:T.queueBubble},`${i.text}${i.uploads?.length?`\uFF08${i.uploads.length} \u4E2A\u9644\u4EF6\u5F85\u53D1\uFF09`:""}`),n("div",{style:T.queueRow},n("span",{style:T.queueHint},i.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${i.text.slice(0,24)}`,title:"\u64A4\u56DE\u8FD9\u6761\u6392\u961F\u6D88\u606F",style:T.queueCancel,onClick:()=>Oe(i.clientTurnId)},jt(n),"\u64A4\u56DE")))))),n("div",{"data-personal-assistant-composer":"true",style:T.composer},Ne?n("div",{role:"status",style:T.queueNotice},Ne):null,n("div",{style:T.composerInner},ee.length>0?n("div",{style:T.attachRow},ee.map(i=>n("span",{key:i.id,style:T.attach},i.mimeType.startsWith("image/")?n("img",{src:i.dataUrl,alt:"",style:T.attachThumb}):null,n("span",{style:T.attachName},i.name),n("button",{"aria-label":`\u79FB\u9664 ${i.name}`,style:{...T.iconButton,width:16,height:16,border:"none"},onClick:()=>ue(y=>y.filter(f=>f.id!==i.id))},jt(n))))):null,n("textarea",{"aria-label":"\u7ED9\u4E2A\u4EBA\u52A9\u7406\u53D1\u6D88\u606F",value:q,rows:1,style:T.textarea,placeholder:x!=="ready"?"\u4E91\u7AEF\u6682\u672A\u8FDE\u63A5\uFF0C\u53EF\u5148\u5199\u4E0B\u6D88\u606F":re||se?"\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:i=>L(i.target.value),onKeyDown:i=>{x==="ready"&&i.key==="Enter"&&!i.shiftKey&&!i.nativeEvent?.isComposing&&(i.preventDefault(),Pe())}}),n("div",{style:T.composerBar},n("button",{"aria-label":"\u6DFB\u52A0\u9644\u4EF6",style:T.iconButton,disabled:x!=="ready"||re,title:"\u4E0A\u4F20\u5230\u4E91\u7535\u8111\uFF1A\u6700\u591A 4 \u4E2A\u6587\u4EF6\uFF0C\u6BCF\u4E2A 512 KiB",onClick:()=>Ke.current?.click()},Nn(n)),n("input",{ref:Ke,type:"file",multiple:!0,accept:"image/*,.txt,.md,.json,.pdf",style:{display:"none"},onChange:Te}),n("span",{style:T.spacer}),W.length>0?n("span",{role:"status",style:T.queueBadge},`\u6392\u961F\u4E2D ${W.length}`):null,n("button",{"aria-label":W.length>0?`\u53D1\u9001\u6D88\u606F\uFF08\u6392\u961F\u4E2D ${W.length} \u6761\uFF09`:"\u53D1\u9001\u6D88\u606F",title:re||se?"\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:x!=="ready"||!q.trim()&&ee.length===0,style:x!=="ready"||!q.trim()&&ee.length===0?{...T.send,...T.sendDisabled}:re||se?T.sendQueued:T.send,onClick:()=>{Pe()}},Dn(n))))))}var Ht="personal-assistant-computer",Ln="personal-assistant",Kt="\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",Pn=()=>Object.assign(new Error(Kt),{code:"PERSONAL_ASSISTANT_NATIVE_SIDEBAR_REQUIRED"});function Bn(t){return t.workbench.render(t)}function Vt({sidebarRight:t,slots:d,panelId:c=Ln}={}){let r=typeof t?.registerPanelSurface=="function"&&typeof t?.openPanelTab=="function"&&typeof t?.setPanelExpanded=="function"&&typeof d?.inject=="function"&&typeof d?.register=="function",u=new Set,n,s=!1,o=Object.freeze({binding:void 0}),b=()=>{o=Object.freeze({binding:n});for(let A of[...u])A()},g=()=>{if(!r)throw Pn();if(s)throw new Error("\u4E91\u7535\u8111\u5DE5\u4F5C\u9762\u677F\u5DF2\u5173\u95ED")},h,x,k=()=>t.openPanelTab(c,Ht),_={available:r,unavailableReason:r?null:Kt,subscribe:A=>(u.add(A),()=>u.delete(A)),getSnapshot:()=>o,bind(A,J){if(g(),!A?.agentId||!A?.botId||typeof J!="function")throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");n&&(n.scope.agentId!==A.agentId||n.scope.botId!==A.botId)&&(h(),h=t.registerPanelSurface(c)),n=Object.freeze({scope:Object.freeze({...A}),request:J}),b(),k()},open(){g(),n&&(k(),t.setPanelExpanded(c,!0))},collapse(){g(),t.setPanelExpanded(c,!1)},dispose(){s||(s=!0,x?.(),h?.(),u.clear())}};return r&&(h=t.registerPanelSurface(c),x=d.inject("sidebar.right.panel.tab",()=>d.register({name:"sidebar.right.panel.tab",key:Ht,inject:()=>({workbench:_})},Bn))),_}function qt({React:t,workbench:d,Panel:c,active:r=!0,fullscreen:u=!1}){let{createElement:n,useSyncExternalStore:s}=t,o=s(d.subscribe,d.getSnapshot,d.getSnapshot);if(!r||!o.binding)return null;let{scope:b,request:g}=o.binding;return n(c,{key:`${b.agentId}:${b.botId}:${b.sessionId||""}`,request:g,initialBotId:b.botId,initialSessionId:b.sessionId,agentId:b.agentId,variant:"native-tab",active:r,nativeFullscreen:u})}var zn="__directory__";function bt(t){if(!Array.isArray(t)||t.length>128)throw new TypeError("\u52A9\u7406\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");let d=new Set;return t.map(c=>{let r=String(c?.botId||"").trim(),u=String(c?.displayName||r).trim();if(!r||r.length>64||/[\u0000-\u001f]/u.test(r)||r===zn||d.has(r)||!u||u.length>256)throw new TypeError("\u52A9\u7406\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");return d.add(r),{botId:r,displayName:r==="default"&&u==="Personal Assistant"?"\u9ED8\u8BA4\u52A9\u7406":r==="researcher"&&u==="Researcher"?"\u7814\u7A76\u52A9\u7406":u}})}function ht(t,d=""){let c=bt(t),r=String(d||"").trim(),u=r?c.find(n=>n.botId===r):c.find(n=>n.botId==="default")||(c.length===1?c[0]:void 0);if(!u)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 u.botId}var wt=class extends Error{constructor(){super("Personal Assistant gateway is not connected"),this.name="PersonalAssistantGatewayUnavailableError",this.code="PERSONAL_ASSISTANT_GATEWAY_UNAVAILABLE"}};var Gt=Object.freeze(["slots","connection","sidebarRight"]),mt="personal-assistant",Jn=Object.freeze({enabled:!1,autoConnect:!1}),at="personal-assistant-computer",Je="0.1.12 @ 2026-11-02T10:01:10.557Z",Yt=12e3,He;function Zt(t){He=t}var Jt;function en(t){Jt=t&&typeof t.MarkdownText=="function"?t:void 0}var Q={background:"var(--dsw-alias-bg-layer-1, #fff)",color:"var(--dsw-alias-label-primary, #17202c)",border:"1px solid var(--dsw-alias-border-default, #d8dee8)"},xt=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",Qt=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",Un=t=>Number(t?.status)===409&&["PERSONAL_ASSISTANT_DIRECTORY_UNSUPPORTED","PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE"].includes(t?.code);function St(t){let d=typeof t?.reason=="string"?t.reason:"",c=Array.isArray(t?.candidates)?t.candidates.filter(n=>typeof n?.agentId=="string"&&n.agentId):[],r={id:"check",label:"\u68C0\u67E5\u5F00\u901A\u72B6\u6001"};return c.length>0?{tone:"reuse",title:"\u53D1\u73B0\u5DF2\u5F00\u901A\u7684\u4E2A\u4EBA\u52A9\u7406",detail:`\u8D26\u53F7\u4E0B\u5DF2\u6709 ${c.length} \u4E2A\u4E2A\u4EBA\u52A9\u7406\u3002\u4E00\u4E2A\u5B50\u8D26\u53F7\u53EA\u9700\u8981\u4E00\u4E2A\uFF0C\u76F4\u63A5\u8FDE\u63A5\u5373\u53EF\u590D\u7528\uFF0C\u4E0D\u4F1A\u91CD\u590D\u521B\u5EFA\u3002`,actions:[{id:"connect",label:"\u8FDE\u63A5\u5DF2\u53D1\u73B0\u7684\u4E2A\u4EBA\u52A9\u7406",primary:!0},r]}:d==="needs-create"?{tone:"create",title:"\u5F00\u901A\u4E2A\u4EBA\u52A9\u7406",detail:"\u4E00\u4E2A\u5B50\u8D26\u53F7\u53EF\u5F00\u901A\u4E00\u4E2A\u4E2A\u4EBA\u52A9\u7406\u3002\u5F00\u901A\u540E\u4F1A\u5F97\u5230\u4E00\u4F4D\u4E91\u7AEF\u6301\u7EED\u8FD0\u884C\u7684\u52A9\u7406\u548C\u4E00\u53F0\u4E13\u5C5E\u4E91\u7535\u8111\uFF0C\u5173\u6389 Studio \u4E5F\u4F1A\u7EE7\u7EED\u5DE5\u4F5C\u3002",actions:[{id:"create",label:"\u5F00\u901A\u4E2A\u4EBA\u52A9\u7406",primary:!0},r]}:d==="credential-unavailable"?{tone:"reuse",title:"\u6B63\u5728\u6062\u590D\u8FDE\u63A5\u51ED\u8BC1",detail:"\u4E2A\u4EBA\u52A9\u7406\u5B9E\u4F8B\u5DF2\u7ECF\u5728\u8D26\u53F7\u4E0B\uFF0C\u4F46\u4E91\u7AEF\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u8FDE\u63A5\u51ED\u8BC1\u3002\u91CD\u65B0\u83B7\u53D6\u5373\u53EF\u590D\u7528\u73B0\u6709\u5B9E\u4F8B\uFF0C\u4E0D\u9700\u8981\u91CD\u65B0\u5F00\u901A\u3002",actions:[{id:"connect",label:"\u91CD\u65B0\u83B7\u53D6\u8FDE\u63A5\u51ED\u8BC1",primary:!0},r]}:{tone:"retry",title:"\u6682\u65F6\u8BFB\u4E0D\u5230\u5F00\u901A\u72B6\u6001",detail:`${typeof t?.detail=="string"&&t.detail?t.detail:""}\u8BF7\u5148\u786E\u8BA4 Studio \u5DF2\u767B\u5F55\u4E91\u7AEF\u8D26\u53F7\uFF0C\u518D\u91CD\u65B0\u68C0\u67E5\u4E00\u6B21\uFF1B\u786E\u8BA4\u8D26\u53F7\u4E0B\u786E\u5B9E\u6CA1\u6709\u4E2A\u4EBA\u52A9\u7406\u540E\u518D\u5F00\u901A\uFF0C\u907F\u514D\u91CD\u590D\u521B\u5EFA\u3002`,actions:[r,{id:"create",label:"\u786E\u8BA4\u672A\u5F00\u901A\u540E\u5F00\u901A",primary:!1}]}}var tn=t=>t==="reuse"?["\u786E\u8BA4\u8D26\u53F7\u4E0B\u7684\u4E2A\u4EBA\u52A9\u7406\u5B9E\u4F8B","\u76F4\u63A5\u8FDE\u63A5\u5373\u53EF\u590D\u7528\uFF0C\u4E0D\u4F1A\u91CD\u590D\u521B\u5EFA","\u9700\u8981\u770B\u753B\u9762\u6216\u52A8\u624B\u65F6\uFF0C\u6253\u5F00\u300C\u4E91\u7535\u8111\u300D\u63A5\u7BA1"]:["\u767B\u5F55 Studio \u4E91\u7AEF\u8D26\u53F7\uFF0C\u5F00\u901A\u4E2A\u4EBA\u52A9\u7406\uFF08\u7EA6 1\u20132 \u5206\u949F\uFF09","\u8FDE\u63A5\u540E\u5373\u53EF\u5728\u300C\u4E2A\u4EBA\u52A9\u7406\u300D\u9875\u5BF9\u8BDD\uFF0C\u4E91\u7AEF 7\xD724 \u8FD0\u884C","\u9700\u8981\u770B\u753B\u9762\u6216\u52A8\u624B\u65F6\uFF0C\u6253\u5F00\u300C\u4E91\u7535\u8111\u300D\u63A5\u7BA1"],j={page:{flex:"1 1 auto",minHeight:0,overflowY:"auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:14,padding:"32px 20px",textAlign:"center",boxSizing:"border-box"},eyebrow:{fontSize:11,letterSpacing:"0.1em",textTransform:"uppercase",color:"var(--dsw-alias-label-secondary, #536174)"},title:{margin:0,fontSize:20,fontWeight:600,letterSpacing:"-0.01em"},detail:{margin:0,maxWidth:460,lineHeight:1.75,color:"var(--dsw-alias-label-secondary, #536174)"},steps:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:8,textAlign:"left",maxWidth:460},step:{display:"flex",gap:10,alignItems:"flex-start",lineHeight:1.7},stepIndex:{flex:"none",width:20,height:20,borderRadius:999,display:"grid",placeItems:"center",fontSize:12,background:"color-mix(in srgb, currentColor 10%, transparent)"},actions:{display:"flex",gap:10,flexWrap:"wrap",justifyContent:"center",alignItems:"center",marginTop:4},primary:{...Q,borderRadius:8,padding:"8px 16px",cursor:"pointer",font:"inherit",fontSize:13,fontWeight:500,border:"none",background:"var(--dsw-alias-label-primary, #17202c)",color:"var(--dsw-alias-bg-layer-1, #fff)"},ghost:{...Q,borderRadius:8,padding:"8px 14px",cursor:"pointer",font:"inherit",fontSize:13,background:"transparent"},notice:{margin:0,maxWidth:460,color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12,lineHeight:1.7},diag:{alignSelf:"center",color:"var(--dsw-alias-label-tertiary, #76808e)",fontSize:11,opacity:.8,maxWidth:"100%",overflowWrap:"anywhere"}},Fn={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 Xt({request:t,initialBotId:d="",openInSidebar:c=null,variant:r="page",nativeFullscreen:u=!1}={}){let n=He||globalThis.React;if(!n)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:s,useEffect:o,useRef:b,useState:g}=n,h=n.useLayoutEffect||o,[x,k]=g(null),[_,A]=g([]),[J,X]=g(""),[P,w]=g(null),[ve,O]=g(!1),[D,we]=g(d),[C,N]=g("loading"),[q,L]=g(""),[ee,ue]=g(!0),[Ke,re]=g(0),[Me,se]=g(0),[pe,Ve]=g("observe"),[Se,W]=g(null),[le,Ne]=g(""),[oe,ye]=g(""),[F,ce]=g(null),[H,de]=g(()=>ot()),[ke,je]=g(null),z=b(null),ie=b(null),M=b(null),fe=b(null),ge=b(null),Ie=b(null),K=b(null),_e=b(null),be=b(null),We=b(u);We.current=u;let S=b({mounted:!0,socket:null,generation:0,frameEpoch:0,session:null,suspended:!1,resuming:!1,pendingInputs:[],display:{width:1280,height:800},readOnly:!0,botId:D,config:null,reconnect:null,firstFrame:null,receivedSeq:-1,pendingFrame:null,decoding:!1,frames:0,lastMove:0,wheelPending:{x:0,y:0},wheelFrame:0,pressed:new Set,buttons:new Set,composition:!1,retries:0,taskId:"",mode:"control",frameMetadata:null,reconnectAllowed:!1,controlError:""});S.current.botId=D;let Te=async(e,a={})=>{if(typeof t!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return t(e,a)},V=e=>{let a=S.current;return a.socket?.readyState!==1?!1:(a.socket.send(JSON.stringify(e)),!0)},et=()=>{let e=S.current;for(let a of e.pressed)z.current?.input({type:"key",action:"up",key:a});for(let a of e.buttons)z.current?.input({type:"button",action:"up",button:a});e.pressed.clear(),e.buttons.clear()},Le=()=>{for(let e of S.current.buttons)z.current?.input({type:"button",action:"up",button:e});S.current.buttons.clear()};z.current||(z.current=Ct({send:V,changed:e=>{let a=S.current;a.controlPhase=e.phase,a.readOnly=e.readOnly,a.controlEpoch=e.controlEpoch,e.phase==="controlling"&&(a.controlError=""),e.readOnly&&K.current&&(K.current.style.visibility="hidden"),e.phase==="observe"&&(a.pressed.clear(),a.buttons.clear()),a.mounted&&(ue(e.readOnly),Ve(e.phase))},failed:e=>{S.current.controlError=e||"\u63A7\u5236\u6743\u6682\u4E0D\u53EF\u7528",S.current.mounted&&L(e)}})),ie.current||(ie.current=Nt({send:V,controlEpoch:()=>z.current?.snapshot?.controlEpoch}));let $=()=>{et(),z.current.release(),S.current.pressed.clear(),S.current.buttons.clear()},Ce=()=>{let e=S.current;e.pointerFrame&&cancelAnimationFrame(e.pointerFrame),e.pointerFrame=null;let a=e.lastPointer;e.lastPointer=null,a&&(!e.readOnly||e.controlPhase==="acquiring")&&(!e.sentPointer||a.x!==e.sentPointer.x||a.y!==e.sentPointer.y)&&(z.current.input({type:"pointermove",...a}),e.sentPointer=a)},Qe=()=>{clearTimeout(S.current.reconnect),clearTimeout(S.current.firstFrame),S.current.reconnect=null,S.current.firstFrame=null},Oe=(e=!0)=>{let a=S.current;a.reconnectAllowed=!1,Qe(),$(),a.generation+=1,ie.current?.rejectAll();try{V({type:"close"}),a.socket?.close(1e3,"panel closed")}catch{}z.current.reset({readOnly:!0}),a.lastDrawnFrame=null,a.socket=null,a.session=null,a.pendingFrame=null,a.frameMetadata=null,a.readOnly=!0,ge.current?.blur(),a.suspended=!1,a.resuming=!1,a.pendingInputs=[],a.frameEpoch++,a.mounted&&ce(null),e&&a.mounted&&(N(a.config?.configured?"idle":"unconfigured"),ue(!0))},Pe=e=>{Oe(!1),ue(!0),N("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")},Ee=e=>{let a=S.current;if(e.type!=="pointermove"&&Ce(),a.suspended||a.resuming){if(e.type==="pointermove")return!1;let E=a.mode==="control";if(E){if(a.pendingInputs.length>=32)return Oe(),L("\u6062\u590D\u671F\u95F4\u8F93\u5165\u8FC7\u5FEB\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5"),!1;a.pendingInputs.push(e)}return a.resuming||Be(),E}return!a.session||a.socket?.readyState!==1?(L("\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8F93\u5165\u672A\u53D1\u9001"),!1):z.current.input(e)},he=e=>{S.current.mounted&&(ye(e),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{S.current.mounted&&ye("")},4e3))},i=e=>{let a=!1;for(let E of e)a=Ee(E)||a;return a},y=async()=>{let e=S.current,a=z.current?.snapshot;if(!e.session||e.socket?.readyState!==1)return he("\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8BF7\u5148\u6253\u5F00\u684C\u9762"),!1;if(a&&a.phase==="controlling"&&a.readOnly===!1)return!0;if(e.suspended||e.resuming)return he("\u4E91\u7535\u8111\u6B63\u5728\u6062\u590D\uFF0C\u8BF7\u7A0D\u5019\u518D\u8BD5"),!1;if(!a?.available)return he("\u5F53\u524D\u4E3A\u53EA\u8BFB\u65C1\u89C2\uFF0C\u8BF7\u5148\u6253\u5F00\u63A7\u5236\u6A21\u5F0F"),!1;if(e.controlError="",!z.current.acquire())return he("\u5F53\u524D\u65E0\u6CD5\u63A5\u7BA1\u4E91\u7535\u8111\uFF0C\u8BF7\u91CD\u8BD5"),!1;let E=Date.now()+8e3;for(;Date.now()<E;){await new Promise(Z=>setTimeout(Z,50));let p=z.current.snapshot;if(p.phase==="controlling"&&p.readOnly===!1)return!0;if(e.controlError)break}return he(e.controlError||"\u63A5\u7BA1\u4E91\u7535\u8111\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5"),!1},f=async()=>{if(!await y())return{ok:!1,code:"CLIPBOARD_CONTROL_REQUIRED"};let e=await ie.current.read().catch(()=>({text:""})),a=!1;if(!S.current.pressed.has("_copyShortcut")){S.current.pressed.add("_copyShortcut");try{a=i(Ot())!==!1}finally{S.current.pressed.delete("_copyShortcut")}}if(!a)return he("\u590D\u5236\u6309\u952E\u672A\u53D1\u9001\uFF0C\u8BF7\u5148\u63A5\u7BA1\u4E91\u7535\u8111\u540E\u518D\u8BD5"),{ok:!1,code:"CLIPBOARD_KEY_NOT_SENT"};let E;try{E=await Dt({readCloud:()=>ie.current.read(),beforeText:st(e)})}catch(p){return he(p?.message||"\u8BFB\u53D6\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:p?.code||"CLIPBOARD_READ_FAILED"}}return Bt({readCloud:async()=>E,writeLocal:p=>I(p),notify:he})},l=async()=>{try{let e=await Te("personal-assistant.clipboard.read");if(typeof e?.text=="string")return e.text}catch{}return pt()},I=async e=>{try{await Te("personal-assistant.clipboard.write",{text:String(e??"")});return}catch{}await ft(String(e??""))},v=()=>gt({readLocal:()=>l(),writeCloud:e=>ie.current.write(e),sendKeys:i,ensureControl:y,notify:he}),B=e=>gt({readLocal:async()=>String(e??""),writeCloud:a=>ie.current.write(a),sendKeys:i,ensureControl:y,notify:he}),Ae=async()=>{let e=S.current;if(!e.decoding){e.decoding=!0;try{for(;e.pendingFrame;){let a=e.pendingFrame;e.pendingFrame=null;let E;try{if(E=await createImageBitmap(new Blob([a.bytes],{type:"image/jpeg"})),!e.mounted||e.suspended||a.frameEpoch!==e.frameEpoch||a.generation!==e.generation||a.seq<e.receivedSeq||!fe.current)continue;e.lastDrawnFrame=a;let p=fe.current,Z=p.getBoundingClientRect(),ae=Math.max(1,globalThis.devicePixelRatio||1);p.width=Math.max(1,Math.round(Z.width*ae)),p.height=Math.max(1,Math.round(Z.height*ae));let ne=p.getContext("2d"),Y=e.display,me=Math.min(p.width/Y.width,p.height/Y.height),Fe=Y.width*me,R=Y.height*me;ne.clearRect(0,0,p.width,p.height),ne.drawImage(E,(p.width-Fe)/2,(p.height-R)/2,Fe,R);let $e=e.firstFrame!==null;e.frames+=1,clearTimeout(e.firstFrame),e.firstFrame=null,e.retries=0,$e&&L(""),N(e.readOnly?"readonly":"ready"),re(0)}catch{e.mounted&&L("\u684C\u9762\u5E27\u65E0\u6CD5\u89E3\u7801\uFF0C\u8BF7\u91CD\u8BD5")}finally{E?.close()}}}finally{e.decoding=!1}}},G=e=>{let a=S.current;clearTimeout(a.firstFrame),a.firstFrame=null,a.suspended=!0,a.resuming=!1,a.readOnly=!0,a.pendingInputs=[],a.frameEpoch++,a.pendingFrame=null,a.frameMetadata=null,a.pressed.clear(),a.buttons.clear(),a.frames=0,se(0),ue(!0),N("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")},Be=()=>{let e=S.current;if(e.resuming||!e.suspended)return;if(e.socket?.readyState!==1){Re(e.mode,!1,e.pendingInputs);return}e.resuming=!0,N("resuming"),L("\u6B63\u5728\u6062\u590D\u684C\u9762\u5E76\u68C0\u67E5\u63A7\u5236\u6743\uFF0C\u8BF7\u7A0D\u5019\u3002"),V({type:"resume",mode:e.mode,activity:!0});let a=e.generation,E=e.socket;e.firstFrame=setTimeout(()=>{e.mounted&&e.generation===a&&e.firstFrame!==null&&E.close(4e3,"resume frame timeout")},Yt)},Re=async(e="read",a=!1,E=[])=>{let p=S.current,Z=String(p.botId||"").trim();if(!p.config?.configured){N("unconfigured");return}if(!Z||!p.bots?.some(ne=>ne.botId===Z)){L("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");return}Oe(!1),p.pendingInputs=E,p.resuming=E.length>0;let ae=++p.generation;p.reconnectAllowed=!0,a||(p.retries=0),p.mode=e,p.taskId||=`studio-desktop-${globalThis.crypto.randomUUID()}`,p.receivedSeq=-1,p.frameMetadata=null,N(a?"reconnecting":"connecting"),L("\u9996\u6B21\u6216\u4F11\u7720\u540E\u8FDE\u63A5\u53EF\u80FD\u9700\u8981\u6570\u79D2\uFF0C\u8BF7\u7A0D\u5019\u3002");try{let ne=await Te("personal-assistant.desktop.ticket",{agentId:p.config.agentId,botId:Z,mode:e==="observe"?"control":e});if(!p.mounted||ae!==p.generation)return;let Y=new WebSocket(ne.wsUrl,["agentkit.personal-assistant.desktop.v1",`agentkit.desktop.ticket.${ne.ticket}`]);Y.binaryType="arraybuffer",p.socket=Y;let me=()=>p.mounted&&p.generation===ae;Y.onopen=()=>{if(!me()){Y.close();return}V({type:"open",botId:Z,taskId:p.taskId,mode:e,...ne.leaseId?{leaseId:ne.leaseId}:{}}),p.firstFrame=setTimeout(()=>{me()&&(L("\u4E91\u7535\u8111\u54CD\u5E94\u8F83\u6162\uFF0C\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5"),Y.close(4e3,"first frame timeout"))},Yt)},Y.onmessage=Fe=>{if(!me())return;if(typeof Fe.data!="string"){let $e=p.frameMetadata;p.frameMetadata=null;let Ge=Fe.data;if(!$e||!Number.isSafeInteger($e.seq)||$e.seq<=p.receivedSeq||!(Ge instanceof ArrayBuffer)||Ge.byteLength===0||Ge.byteLength>307200||p.suspended)return;p.receivedSeq=$e.seq,p.pendingFrame={bytes:Ge,seq:$e.seq,generation:ae,frameEpoch:p.frameEpoch},Ae();return}let R;try{R=JSON.parse(Fe.data)}catch{return}if(R.type==="ready"){p.suspended=!1,p.resuming=!1,p.receivedSeq=-1,p.session=R.sessionId,p.readOnly=!!R.readOnly,p.display=ot(R.display),de(p.display),ce(R.diagnostics||null),p.mode=e,z.current.reset(R);let $e=p.pendingInputs;if(p.pendingInputs=[],p.readOnly)p.pressed.clear(),p.buttons.clear();else for(let Ge of $e)z.current.input(Ge);ue(p.readOnly),L("\u4E91\u7535\u8111\u5DF2\u8FDE\u63A5\uFF0C\u6B63\u5728\u51C6\u5907\u684C\u9762\u753B\u9762");return}if(R.type==="control"){z.current.accept(R),L("");return}if(R.type==="idle"){G(R);return}if(R.type==="frame"){R.unchanged||(p.frameMetadata=R);return}if(R.type==="clipboard.response"){ie.current?.accept(R);return}if(R.type==="closed"){R.retryable!==!0&&Pe(R);return}if(R.type==="error"){if(ie.current?.accept(R)||Number.isSafeInteger(R.controlEpoch)&&R.controlEpoch<p.controlEpoch)return;if(L(R.message||R.code||"\u4E91\u7535\u8111\u8BF7\u6C42\u5931\u8D25"),p.handoffSupported&&R.recoverable===!0){z.current.reject(R);return}if(R.recoverable===!0&&Number(R.status)===409){R.code==="DESKTOP_SESSION_IDLE"?G():(p.pendingInputs=[],p.readOnly=!0,p.pressed.clear(),p.buttons.clear(),ue(!0),N("readonly"));return}if(Number(R.status)===409&&e==="control"&&!p.session){Re(S.current.handoffSupported?"observe":"read");return}[404,409].includes(Number(R.status))||R.code==="DESKTOP_SESSION_NOT_FOUND"?Pe(R):p.session||(N("error"),Oe(!1))}},Y.onerror=()=>{me()&&L("\u684C\u9762\u901A\u9053\u6682\u65F6\u65AD\u5F00\uFF0C\u6B63\u5728\u91CD\u8FDE")},Y.onclose=Fe=>{if(!me())return;if(ie.current?.rejectAll(),p.suspended&&Fe.code!==1e3){clearTimeout(p.firstFrame),p.firstFrame=null,p.socket=null,N("dormant");return}if(p.session=null,clearTimeout(p.firstFrame),p.firstFrame=null,!p.reconnectAllowed||Fe.code===1e3){Pe();return}if(document.hidden){N("hidden");return}let R=++p.retries;if(re(R),R>5){p.reconnectAllowed=!1,N("error"),L("\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7535\u8111\uFF0C\u8BF7\u68C0\u67E5\u5B9E\u4F8B\u72B6\u6001\u6216\u7F51\u7EDC\u540E\u91CD\u8BD5");return}N("reconnecting"),p.reconnect=setTimeout(()=>{Re(e,!0,p.pendingInputs)},Math.min(8e3,1e3*2**(R-1)))}}catch(ne){p.mounted&&ae===p.generation&&(N("error"),L(Qt(ne)))}},lt=async e=>{if(e?.aborted)return null;try{let a=await Te("personal-assistant.desktop.status");return a&&typeof a=="object"?a:null}catch(a){return a?.code==="PERSONAL_ASSISTANT_OPERATION_UNAVAILABLE"||a?.status===404?null:{configured:!1,reason:"unavailable",detail:xt(a),candidates:[]}}},ct=async e=>{if(!le){Ne(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 Te(`personal-assistant.desktop.${e}`),L(""),await qe()}catch(a){L(xt(a)),W(await lt().catch(()=>null))}finally{Ne("")}}},qe=async(e,a=!1)=>{Oe(!1),N("loading"),L(""),X(""),w(null);try{let E=await Te("personal-assistant.configuration");if(e?.aborted||!S.current.mounted)return;if(S.current.config=E,k(E),!E.configured){let ne=await lt(e);if(e?.aborted||!S.current.mounted)return;if(S.current.bots=[],A([]),we(""),W(ne),N("unconfigured"),ne?.configured&&!a){await qe(e,!0);return}return}W(null);let p=await Te("personal-assistant.bots.list");if(e?.aborted||!S.current.mounted)return;if(p.directoryAvailable!==!0)throw Object.assign(new Error("directory unavailable"),{code:"PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE",status:409});let Z=bt(p.bots);S.current.bots=Z,S.current.handoffSupported=p.features?.includes("desktop-handoff/v1")===!0,A(Z);let ae=Z.length?ht(Z,d||E.botId):"";S.current.botId=ae,we(ae),N(Z.length?"idle":"empty"),ae&&["computer","native-tab"].includes(r)&&Re(S.current.handoffSupported?"observe":"read")}catch(E){if(e?.aborted||!S.current.mounted)return;Number.isInteger(E?.closeCode)&&E.closeCode>=1e3&&E.closeCode<=4999&&w(E.closeCode),S.current.bots=[],A([]),we("");let p=a?null:await lt(e).catch(()=>null);if(e?.aborted||!S.current.mounted)return;if(p?.configured){W(null),await qe(e,!0);return}if(p){W(typeof p.reason=="string"&&p.reason?p:{...p,reason:"unavailable",detail:xt(E)}),N("unconfigured");return}N("directory-error"),X(Un(E)?"\u4E91\u7AEF\u52A9\u7406\u9700\u8981\u66F4\u65B0\uFF0C\u8BF7\u66F4\u65B0\u540E\u91CD\u65B0\u8FDE\u63A5\u3002":Qt(E))}};o(()=>{let e=S.current;e.mounted=!0;let a=new AbortController;qe(a.signal);let E=setInterval(()=>{e.mounted&&se(e.frames),e.frames=0},1e3),p=()=>{document.hidden?($(),V({type:"pause"})):e.socket?.readyState===1?V({type:"resume"}):e.reconnectAllowed&&e.config?.configured&&e.session===null&&e.socket&&Re(e.mode,!0)},Z=typeof ResizeObserver=="function"?new ResizeObserver(()=>{e.lastDrawnFrame&&(e.pendingFrame=e.lastDrawnFrame,Ae())}):null;fe.current&&Z?.observe(fe.current);let ae=()=>$(),ne=Y=>{Ie.current?.contains(Y.target)||$()};return document.addEventListener("visibilitychange",p),window.addEventListener("blur",ae),document.addEventListener("pointerdown",ne,!0),()=>{e.mounted=!1,Z?.disconnect(),e.pointerFrame&&cancelAnimationFrame(e.pointerFrame),e.wheelFrame&&cancelAnimationFrame(e.wheelFrame),a.abort(),Oe(!1),clearInterval(E),document.removeEventListener("visibilitychange",p),window.removeEventListener("blur",ae),document.removeEventListener("pointerdown",ne,!0)}},[t]);let dt=e=>Tt({clientX:e.clientX,clientY:e.clientY,rect:fe.current.getBoundingClientRect(),display:S.current.display}),rn=e=>{e.preventDefault();let a=S.current,E=a.wheelPending||(a.wheelPending={x:0,y:0});a.wheelPending={x:E.x+(Number(e.deltaX)||0),y:E.y+(Number(e.deltaY)||0)},!a.wheelFrame&&(a.wheelFrame=requestAnimationFrame(()=>{if(a.wheelFrame=0,!a.mounted)return;let p=_t(a.wheelPending);a.wheelPending=p.pending,!(!p.clicks.deltaX&&!p.clicks.deltaY)&&Ee({type:"wheel",deltaX:p.clicks.deltaX,deltaY:p.clicks.deltaY})}))},It=e=>{e.preventDefault();let a=S.current,E=[1,2,3][e.button]||1;e.type==="pointerdown"?(ge.current?.focus(),fe.current?.setPointerCapture(e.pointerId),Ee({type:"button",action:"down",button:E,...dt(e)})&&a.buttons.add(E)):(Ee({type:"button",action:"up",button:E,...dt(e)}),a.buttons.delete(E),fe.current?.hasPointerCapture(e.pointerId)&&fe.current.releasePointerCapture(e.pointerId))},it=e=>{if(S.current.composition||e.isComposing||e.nativeEvent?.isComposing||e.key==="Process"||e.key==="Unidentified")return;if(Lt(e)){e.preventDefault(),v();return}if(Pt(e)){e.preventDefault(),e.type==="keydown"&&!e.repeat&&f();return}let a=e.ctrlKey||e.metaKey||e.altKey;if(e.key.length===1&&!a||e.key==="Escape"&&We.current)return;e.preventDefault();let E=Fn[e.key]||e.key;/^[A-Za-z0-9_]+$/u.test(E)&&(e.type==="keydown"?!e.repeat&&Ee({type:"key",action:"down",key:E})&&S.current.pressed.add(E):(Ee({type:"key",action:"up",key:E}),S.current.pressed.delete(E)))},ut={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"}[C],ze={...Q,borderRadius:6,padding:"7px 12px",cursor:"pointer",font:"inherit"},te=["ready","readonly","hidden","reconnecting","dormant","resuming"].includes(C),De=_.length>0,Ue=Se?.reason||"",on=Array.isArray(Se?.candidates)?Se.candidates.length:0,sn=Ue==="needs-create"?"\u8FD8\u6CA1\u6709\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406":Ue==="credential-unavailable"?"\u6B63\u5728\u6062\u590D\u4E2A\u4EBA\u52A9\u7406\u7684\u8FDE\u63A5\u51ED\u8BC1":Ue==="unavailable"?"\u6682\u65F6\u65E0\u6CD5\u81EA\u52A8\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406":"\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A",an=Ue==="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":Ue==="credential-unavailable"?"\u4E91\u7AEF\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u8FDE\u63A5\u51ED\u8BC1\uFF0C\u53EF\u4EE5\u91CD\u65B0\u83B7\u53D6\u3002":Ue==="unavailable"?Se?.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",ln=C==="unconfigured"?sn:C==="empty"?"\u52A9\u7406\u6B63\u5728\u51C6\u5907\u4E2D":C==="directory-error"?"\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406":"\u6B63\u5728\u68C0\u67E5\u52A9\u7406\u72B6\u6001",cn=C==="unconfigured"?an:C==="empty"?"\u4E91\u7AEF\u521D\u59CB\u5316\u5B8C\u6210\u540E\uFF0C\u53EF\u7528\u52A9\u7406\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002":C==="directory-error"?J:"\u8BF7\u7A0D\u5019",Xe=r==="computer"||r==="native-tab";h(()=>{if(!Xe)return;let e=_e.current;if(!e)return;let a=()=>{let p=e.getBoundingClientRect(),Z=be.current?.getBoundingClientRect?.().height||0,ae=te||De?Math.min(128,Math.max(44,Z)):0,ne=Math.max(0,p.height-(ae?ae+10:0)),Y=Rt({availableWidth:p.width,availableHeight:ne,display:H,maxWidth:1280});je(me=>Y.width>0&&Y.height>0?me&&Math.abs(me.width-Y.width)<.5&&Math.abs(me.height-Y.height)<.5?me:Y:me??null)};a();let E=typeof ResizeObserver=="function"?new ResizeObserver(a):null;return E?.observe(e),be.current&&E?.observe(be.current),()=>E?.disconnect()},[Xe,H,te,De,pe,q,oe]);let tt=C==="unconfigured"?St(Se):null,dn=e=>{e==="check"?qe():ct(e)},vt=tt?s("div",{"data-personal-assistant-onboarding":"true",style:j.page},s("div",{"data-window-drag":"",style:{display:"flex",flexDirection:"column",gap:4,alignItems:"center"}},s("div",{style:j.eyebrow},"\u4E2A\u4EBA\u52A9\u7406 \xB7 \u5F00\u901A\u5F15\u5BFC"),s("h2",{style:j.title},tt.title)),s("p",{style:j.detail},tt.detail),s("ol",{style:j.steps},tn(tt.tone).map((e,a)=>s("li",{key:e,style:j.step},s("span",{style:j.stepIndex},String(a+1)),s("span",null,e)))),s("div",{style:j.actions},tt.actions.map(e=>s("button",{key:e.id,disabled:!!le,style:e.primary?j.primary:j.ghost,onClick:()=>dn(e.id)},le===e.id?e.id==="create"?"\u6B63\u5728\u5F00\u901A\u2026":e.id==="connect"?"\u6B63\u5728\u8FDE\u63A5\u2026":"\u68C0\u67E5\u4E2D\u2026":e.label)),le?s("span",{role:"status",style:j.notice},"\u5904\u7406\u4E2D\uFF0C\u8BF7\u7A0D\u5019\u2026"):null),q?s("p",{role:"status",style:j.notice},q):null,s("details",{style:j.diag},s("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),s("small",{"data-personal-assistant-build":Je},`\u6784\u5EFA ${Je}`))):null,Et=s("div",{ref:Ie,"data-personal-assistant-desktop-card":Xe?"true":void 0,style:{position:"relative",background:"var(--dsw-alias-bg-layer-2, #f1f3f6)",...Xe?{...ke&&ke.width>0&&ke.height>0?{width:`${ke.width}px`,height:`${ke.height}px`}:{width:"100%",aspectRatio:`${H.width} / ${H.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(C)?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)"}},C==="dormant"?"\u5DF2\u7A7A\u95F2\uFF0C\u64CD\u4F5C\u684C\u9762\u5373\u53EF\u6062\u590D":"\u6B63\u5728\u6062\u590D\u684C\u9762\u2026"):null,s("canvas",{ref:fe,"aria-label":"\u4E91\u7535\u8111\u684C\u9762",tabIndex:te?0:-1,onPointerDown:It,onPointerUp:It,onPointerCancel:Le,onLostPointerCapture:Le,onPointerLeave:()=>{K.current&&(K.current.style.visibility="hidden")},onPointerMove:e=>{let a=S.current,E=e.nativeEvent?.getCoalescedEvents?.().at(-1)||e;if(K.current){let p=fe.current.getBoundingClientRect();K.current.style.transform=`translate(${E.clientX-p.left}px, ${E.clientY-p.top}px)`,K.current.style.visibility=a.readOnly?"hidden":"visible"}a.lastPointer=dt(E),a.pointerFrame||(a.pointerFrame=requestAnimationFrame(()=>{a.mounted&&Ce()}))},onContextMenu:e=>e.preventDefault(),onWheel:rn,onKeyDown:it,onKeyUp:it,style:{...Xe?{position:"absolute",inset:0}:{},width:"100%",height:"100%",display:"block",visibility:te?"visible":"hidden",pointerEvents:te?"auto":"none",touchAction:"none",cursor:ee?"default":"none"}}),s("div",{ref:K,"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}))),te?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}},De?ut:ln),s("p",{style:{margin:0,maxWidth:380,lineHeight:1.7,color:"var(--dsw-alias-label-secondary, #536174)"}},De?q||"\u8FDE\u63A5\u540E\u5373\u53EF\u4F7F\u7528\u4E91\u7AEF\u684C\u9762\uFF0C\u5173\u95ED\u9762\u677F\u4F1A\u91CA\u653E\u672C\u6B21\u63A7\u5236\u3002":cn),!De&&C!=="loading"?s("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",alignItems:"center"}},C==="unconfigured"&&Ue==="needs-create"?s("button",{style:ze,disabled:!!le,onClick:()=>{ct("create")}},le==="create"?"\u6B63\u5728\u521B\u5EFA\u2026":"\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406"):null,C==="unconfigured"&&(Ue==="credential-unavailable"||on>0)?s("button",{style:ze,disabled:!!le,onClick:()=>{ct("connect")}},le==="connect"?"\u6B63\u5728\u83B7\u53D6\u2026":Ue==="credential-unavailable"?"\u91CD\u65B0\u83B7\u53D6\u8FDE\u63A5\u51ED\u8BC1":"\u8FDE\u63A5\u5DF2\u53D1\u73B0\u7684\u4E2A\u4EBA\u52A9\u7406"):null,s("button",{style:{...ze,background:"transparent"},disabled:!!le,onClick:()=>{qe()}},"\u68C0\u67E5\u5F00\u901A\u72B6\u6001"),le?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:ge,"aria-label":"\u4E91\u7535\u8111\u6587\u672C\u8F93\u5165",autoComplete:"off",disabled:!te||ee&&!z.current.snapshot.available&&!(S.current.mode==="control"&&["dormant","resuming"].includes(C)),tabIndex:-1,style:{position:"absolute",width:1,height:1,opacity:0,left:0,top:0},onKeyDown:it,onKeyUp:it,onPaste:e=>{let a=e.clipboardData?.getData?.("text/plain")??"";a&&(e.preventDefault(),B(a))},onCompositionStart:()=>{S.current.composition=!0},onCompositionEnd:e=>{S.current.composition=!1;let a=e.currentTarget.value;e.currentTarget.value="",a&&Ee({type:"text",text:a})},onInput:e=>{if(S.current.composition||e.nativeEvent?.isComposing)return;let a=e.currentTarget.value;e.currentTarget.value="",a&&Ee({type:"text",text:a})}})),nt="var(--dsw-alias-label-secondary, #536174)",un={...ze,background:"transparent",color:"inherit",border:Q.border},At={...ze,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 Xe?s("section",{"data-personal-assistant-computer":"true",style:{...Q,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:Q.border}},s("strong",{style:{fontWeight:500}},"\u4E91\u7535\u8111"),s("span",{role:"status","aria-live":"polite",style:{color:nt,fontSize:12}},ut),null):null,ee&&te&&!z.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:"hidden",display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:"20px 16px 12px",boxSizing:"border-box"}},s("div",{ref:_e,"data-personal-assistant-desktop-stack":"true",style:{width:"100%",maxWidth:1280,minHeight:0,flex:"1 1 auto",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10}},vt||Et,te||De?s("div",{ref:be,"data-personal-assistant-control-capsule":"true",role:"status","aria-live":"polite",style:{flex:"none",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:Q.border,boxShadow:"0 1px 4px #10182808",lineHeight:1.5}},!te&&De?s("button",{style:At,disabled:["connecting","resuming"].includes(C),onClick:()=>{Re(S.current.handoffSupported?"observe":"read")}},C==="connecting"?"\u6B63\u5728\u542F\u52A8\u2026":"\u91CD\u65B0\u8FDE\u63A5"):null,te&&ee?s("span",{style:{color:nt,fontSize:12}},pe==="acquiring"?"\u6B63\u5728\u63A5\u7BA1\u2026":pe==="releasing"?"\u6B63\u5728\u4EA4\u8FD8\u2026":"\u52A9\u7406\u6B63\u5728\u4F7F\u7528 \xB7 \u70B9\u753B\u9762\u5373\u53EF\u63A5\u7BA1"):null,te&&ee&&z.current.snapshot.available?s("button",{style:{...At,padding:"3px 9px",fontSize:11},onClick:()=>z.current.acquire()},"\u63A5\u7BA1"):null,te&&!ee?s("span",{style:{color:nt,fontSize:12}},"\u60A8\u62E5\u6709\u63A7\u5236\u6743 \xB7 \u70B9\u753B\u9762\u5916\u91CA\u653E"):null,te&&!ee?s("button",{style:{...un,padding:"3px 9px",fontSize:11},onClick:$},"\u4EA4\u8FD8"):null,te&&q?s("span",{style:{color:nt,fontSize:12}},q):null,te&&oe?s("span",{role:"status","aria-live":"polite",style:{color:nt,fontSize:12}},oe):null):null)),s("details",{style:{flex:"none",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("div",{style:{paddingTop:8,lineHeight:1.7}},s("div",null,`\u5BA2\u6237\u7AEF\uFF1A${Je}`),F?s("div",null,`\u4E91\u7535\u8111\u5305\uFF1A${F.packageVersion||"\u672A\u77E5"} \xB7 \u6E05\u5355\uFF1A${F.manifestVersion||"\u672A\u77E5"}`):null,F?.runtimeBuild&&F.runtimeBuild!=="unknown"?s("div",null,`\u8FD0\u884C\u65F6\u6784\u5EFA\uFF1A${F.runtimeBuild}`):null,F?.computerImage&&F.computerImage!=="unknown"?s("div",null,`\u7535\u8111\u955C\u50CF\uFF1A${F.computerImage}`):null,F?.dock?s("div",null,`Dock\uFF1A${F.dock.position} \xB7 ${F.dock.iconCount} \u4E2A\u56FE\u6807`):null))):s("section",{"data-personal-assistant-panel":"true",style:{...Q,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:Q.border}},s("strong",{style:{fontWeight:500,marginRight:8}},"\u4E2A\u4EBA\u52A9\u7406"),De&&["idle","closed","error"].includes(C)?s("button",{style:ze,onClick:()=>{qe()}},"\u5237\u65B0\u52A9\u7406\u5217\u8868"):null,typeof c=="function"?s("button",{style:ze,onClick:c},"\u653E\u5230\u53F3\u4FA7\u680F"):null,De?s("button",{style:ze,disabled:["connecting","resuming"].includes(C),onClick:()=>C==="dormant"?Be():void Re(S.current.handoffSupported?"observe":"control")},C==="dormant"?"\u6062\u590D\u753B\u9762":ee&&C==="readonly"?"\u7533\u8BF7\u63A7\u5236":te?"\u91CD\u65B0\u8FDE\u63A5":"\u8FDE\u63A5\u4E91\u7535\u8111"):null,De?s("button",{style:ze,disabled:C==="connecting",onClick:()=>{Re("read")}},"\u53EA\u8BFB\u65C1\u89C2"):null,te?s("span",{role:"status","aria-live":"polite",style:{marginLeft:"auto",color:"var(--dsw-alias-label-secondary, #536174)"}},ut):null),C==="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,te&&q?s("div",{role:"status",style:{padding:"8px 12px"}},q):null,vt||Et,s("footer",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:12,padding:"7px 12px",color:"var(--dsw-alias-label-secondary, #536174)",borderTop:Q.border}},s("details",{open:ve,onToggle:e=>O(e.currentTarget.open)},s("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),P?s("div",{style:{paddingTop:8}},`\u76EE\u5F55\u8FDE\u63A5\u5173\u95ED\u7801\uFF1A${P}`):null,s("div",{style:{paddingTop:8,lineHeight:1.8,overflowWrap:"anywhere"}},s("div",null,`\u4E91\u7AEF\u5B9E\u4F8B\uFF1A${x?.agentId||"\u672A\u5F00\u901A"}`),s("div",null,`\u8FDE\u63A5\u6807\u8BC6\uFF1A${D||"\u672A\u8FDE\u63A5"}`),s("div",null,`\u753B\u9762\u5E27\u7387\uFF1A${Me} fps`),F?s("div",null,`\u4E91\u7535\u8111\u5305\uFF1A${F.packageVersion||"\u672A\u77E5"} \xB7 \u6E05\u5355\uFF1A${F.manifestVersion||"\u672A\u77E5"}`):null,F?.dock?s("div",null,`Dock\uFF1A${F.dock.position} \xB7 ${F.dock.iconCount} \u4E2A\u56FE\u6807`):null,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 $n({request:t,nativeWorkbench:d}={}){let c=He||globalThis.React;if(!c)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:r,useEffect:u,useState:n,useCallback:s}=c,[o,b]=n(null),[g,h]=n(""),[x,k]=n(null),[_,A]=n(""),[J,X]=n(0);u(()=>{let O=!1;return b(null),h(""),k(null),(async()=>{try{let D=await t("personal-assistant.configuration");if(!D.configured){let N=await t("personal-assistant.desktop.status").catch(()=>null);O||k(N||{configured:!1,reason:"unavailable",candidates:[]});return}let we=await t("personal-assistant.bots.list");if(we.directoryAvailable!==!0)throw new Error("\u6682\u65F6\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7AEF\u52A9\u7406\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");let C=ht(we.bots,D.botId||we.primaryBotId);O||b({agentId:D.agentId,botId:C})}catch(D){O||h(D.message||"\u4E91\u7AEF\u52A9\u7406\u6682\u4E0D\u53EF\u7528")}})(),()=>{O=!0}},[t,J]);let P=s((O,D={})=>{if(!o)throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");if(D.agentId&&D.agentId!==o.agentId)throw new Error("\u4E91\u7AEF\u5B9E\u4F8B\u4E0D\u4E00\u81F4");if(O!=="personal-assistant.bots.list"&&D.botId&&D.botId!==o.botId)throw new Error("\u4E91\u7AEF\u52A9\u7406\u4E0D\u4E00\u81F4");return t(O,{...D,...o})},[t,o?.agentId,o?.botId]);u(()=>{o&&d?.available?d.bind(o,P):o&&h(d?.unavailableReason||"\u5F53\u524D\u5BBF\u4E3B\u9700\u8981\u66F4\u65B0\u539F\u751F\u4FA7\u680F\u7EC4\u4EF6")},[d,P,o?.agentId,o?.botId]);let w=x?St(x):null,ve=O=>{_||(A(O),h(""),(async()=>{try{await t(`personal-assistant.desktop.${O}`),X(D=>D+1)}catch(D){h(D?.message||"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{A("")}})())};return!o&&w?r("div",{"data-personal-assistant-onboarding":"true",style:j.page},r("div",{"data-window-drag":"",style:{display:"flex",flexDirection:"column",gap:4,alignItems:"center"}},r("div",{style:j.eyebrow},"\u4E2A\u4EBA\u52A9\u7406 \xB7 \u5F00\u901A\u5F15\u5BFC"),r("h2",{style:j.title},w.title)),r("p",{style:j.detail},w.detail),r("ol",{style:j.steps},tn(w.tone).map((O,D)=>r("li",{key:O,style:j.step},r("span",{style:j.stepIndex},String(D+1)),r("span",null,O)))),r("div",{style:j.actions},w.actions.map(O=>r("button",{key:O.id,disabled:!!_,style:O.primary?j.primary:j.ghost,onClick:()=>O.id==="check"?X(D=>D+1):ve(O.id)},_===O.id?"\u5904\u7406\u4E2D\u2026":O.label))),g?r("p",{role:"alert",style:{...j.notice,color:"#b42318"}},g):null):o?d?.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(Wt,{React:c,request:P,scope:o,markdown:Jt,onOpenComputer:()=>d.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}},g||"\u6B63\u5728\u8FDE\u63A5\u4E91\u7AEF\u4E2A\u4EBA\u52A9\u7406\u2026",g?r("button",{onClick:()=>X(O=>O+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:Q.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:{...Q,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:{...Q,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:{...Q,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:{...Q,borderRadius:8,padding:"6px 11px",cursor:"pointer",font:"inherit",fontSize:13,color:"#fff",border:"1px solid #b42318",background:"#b42318"},dangerDisabled:{...Q,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:{...Q,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:{...Q,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:{...Q,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"5px 8px",font:"inherit",fontSize:12,width:190,boxSizing:"border-box"},envValue:{...Q,border:"1px solid var(--dsw-alias-border-default, #d8dee8)",borderRadius:8,padding:"5px 8px",font:"inherit",fontSize:12,width:220,boxSizing:"border-box"},tinyButton:{...Q,borderRadius:8,padding:"4px 8px",cursor:"pointer",font:"inherit",fontSize:12}};function Mn({request:t,openComputer:d=null}={}){let c=He||globalThis.React;if(!c)return"\u8BBE\u7F6E\u9875\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00 Studio";let{createElement:r,useEffect:u,useState:n,useCallback:s}=c,[o,b]=n(null),[g,h]=n(null),[x,k]=n(""),[_,A]=n(!1),[J,X]=n(""),[P,w]=n(!1),[ve,O]=n(""),[D,we]=n(!1),[C,N]=n(""),[q,L]=n(null),[ee,ue]=n(null),[Ke,re]=n(""),[Me,se]=n(""),[pe,Ve]=n(""),[Se,W]=n([]),[le,Ne]=n([]),[oe,ye]=n(""),[F,ce]=n(""),[H,de]=n(!1),[ke,je]=n(null),[z,ie]=n(""),M=s(async()=>{A(!0),k("");let i=Date.now();try{let y=await t("personal-assistant.configuration");if(b(y),y?.configured?je(null):je(await t("personal-assistant.desktop.status").catch(()=>null)),y?.configured){let f=await t("personal-assistant.bots.list");h(Array.isArray(f?.bots)?f.bots:[]);try{let l=await t("personal-assistant.settings.inspect");L(l),re(l?.model||""),se(l?.prompt||""),Ve(l?.runtime?.version||""),W((l?.environmentVariables||[]).map(v=>({...v,saved:!0,dirty:!1}))),Ne([]),ye("");let I=await t("personal-assistant.settings.versions",{currentVersion:l?.runtime?.version||""}).catch(v=>(ye(v?.message||"\u6682\u65F6\u8BFB\u4E0D\u5230\u53EF\u5347\u7EA7\u7684\u7248\u672C"),null));ue(I)}catch(l){L(null),ue(null),ye(l?.message||"\u8BFB\u53D6\u4E91\u7AEF\u914D\u7F6E\u5931\u8D25")}}else h([]),L(null),ue(null);X(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 ${Date.now()-i} ms`)}catch(y){k(y?.message||"\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25"),X(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 \u5931\u8D25`)}finally{A(!1)}},[t]),fe=s(async i=>{if(!z){ie(i),k("");try{await t(`personal-assistant.desktop.${i}`),await M()}catch(y){k(y?.message||"\u64CD\u4F5C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{ie("")}}},[z,M,t]),ge=o?.agentId||"",Ie=!!ge&&ve.trim()===ge,K=s(async()=>{if(Ie){we(!0),k("");try{await t("personal-assistant.desktop.destroy",{confirmAgentId:ge}),w(!1),O(""),N("\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"),b({configured:!1}),h([]),X("")}catch(i){let y=String(i?.message||"");k(/更新 Studio|云连接服务/iu.test(y)?"\u5F53\u524D Studio \u7248\u672C\u8FD8\u4E0D\u652F\u6301\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406\uFF0C\u8BF7\u66F4\u65B0 Studio \u540E\u91CD\u8BD5\u3002":y||"\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{we(!1)}}},[ge,Ie,t]),_e=(i,y)=>W(f=>f.map((l,I)=>I===i?{...l,...y,dirty:!0}:l)),be=()=>W(i=>[...i,{key:"",value:"",sensitive:!1,saved:!1,dirty:!0}]),We=i=>{let y=Se[i];y&&(W(f=>f.filter((l,I)=>I!==i)),y.saved&&y.key&&Ne(f=>f.includes(y.key)?f:[...f,y.key]))},S=q?.recordSource==="studio",Te=s(async()=>{if(!(!S||H)){de(!0),ye(""),ce("");try{let i=Se.filter(y=>y.dirty===!0||y.saved!==!0).map(y=>({key:String(y.key||"").trim(),value:String(y.value||""),sensitive:y.sensitive===!0}));await t("personal-assistant.settings.update",{model:Ke.trim(),prompt:Me,runtimeVersion:pe,environmentVariables:i,deleteKeys:le}),ce(`\u5DF2\u63D0\u4EA4\u4E91\u7AEF\u66F4\u65B0\uFF08\u7248\u672C ${pe}\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`),Ne([]);try{let y=await t("personal-assistant.settings.inspect");L(y),re(y?.model||""),se(y?.prompt||""),Ve(y?.runtime?.version||pe),W((y?.environmentVariables||[]).map(f=>({...f,saved:!0,dirty:!1})))}catch{}}catch(i){ye(i?.message||"\u4FDD\u5B58\u914D\u7F6E\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}finally{de(!1)}}},[S,le,Se,Ke,Me,t,H,pe]);u(()=>{M()},[M]);let V=o?.configured===!0,et=o===null?"\u68C0\u67E5\u4E2D":V?"\u5DF2\u5F00\u901A":"\u5C1A\u672A\u5F00\u901A",Le={...m.badge,...o===null?m.badgeIdle:V?m.badgeOk:m.badgeIdle},$=(i,y,f=!1)=>r("div",{style:f?m.rowFirst:m.row},r("div",{style:m.label},i),r("div",{style:m.value},y)),Ce=V?null:St(ke),Qe=Ce?r("div",{"data-personal-assistant-onboarding":"true",style:m.card},r("div",{style:{...m.rowFirst,flexDirection:"column",gap:8,alignItems:"stretch"}},r("div",{style:{fontSize:15,fontWeight:600}},Ce.title),r("div",{style:m.note},Ce.detail),r("div",{style:m.actions},Ce.actions.map(i=>r("button",{key:i.id,disabled:!!z,style:i.primary?m.button:{...m.button,background:"transparent"},onClick:()=>i.id==="check"?void M():void fe(i.id)},z===i.id?"\u5904\u7406\u4E2D\u2026":i.label))))):null,Oe={...m.note,display:"inline-flex",gap:4,alignItems:"center"},Pe={...m.actions,marginTop:6},Ee={display:"flex",flexDirection:"column",gap:8},he=()=>{if(!q)return r("div",{style:m.card},$("\u4E91\u7AEF\u914D\u7F6E",r("div",{style:m.note},H?"\u8BFB\u53D6\u4E2D\u2026":oe||"\u6682\u65F6\u8BFB\u4E0D\u5230\u4E91\u7AEF\u914D\u7F6E\uFF1B\u8BF7\u70B9\u4E0B\u65B9\u201C\u68C0\u67E5\u8FDE\u63A5\u201D\u91CD\u8BD5"),!0));if(q.recordSource!=="studio")return r("div",{style:m.card},$("\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 i=ee&&ee.catalogAvailable?r("select",{style:m.input,value:pe,disabled:H,"aria-label":"\u8FD0\u884C\u65F6\u7248\u672C",onChange:l=>Ve(String(l?.target?.value??""))},ee.versions.map(l=>r("option",{key:l.version,value:l.version},l.version===q.runtime?.version?`${l.version}\uFF08\u5F53\u524D\uFF09`:l.version))):r("div",{style:m.note},`${q.runtime?.version||pe||"\u672A\u77E5\u7248\u672C"} \xB7 \u4E91\u7AEF\u8FD8\u6CA1\u6709\u53D1\u5E03\u53EF\u5347\u7EA7\u7248\u672C`),y=r("div",null,Se.length?Se.map((l,I)=>r("div",{key:`env-${I}`,style:m.envRow},r("input",{style:m.envKey,value:l.key,placeholder:"KEY","aria-label":"\u73AF\u5883\u53D8\u91CF\u540D",disabled:H||l.saved===!0,onChange:v=>_e(I,{key:String(v?.target?.value??"")})}),r("input",{style:m.envValue,value:l.value,"aria-label":"\u73AF\u5883\u53D8\u91CF\u503C",type:l.sensitive===!0?"password":"text",disabled:H,placeholder:l.saved===!0&&l.sensitive===!0?"\u5DF2\u4FDD\u5B58\uFF08\u7559\u7A7A\u4E0D\u4FEE\u6539\uFF09":"VALUE",onChange:v=>_e(I,{value:String(v?.target?.value??"")})}),r("label",{style:Oe},r("input",{type:"checkbox",checked:l.sensitive===!0,disabled:H,onChange:v=>_e(I,{sensitive:v?.target?.checked===!0})}),"\u654F\u611F"),r("button",{style:m.tinyButton,disabled:H,onClick:()=>We(I)},"\u5220\u9664"))):r("div",{style:m.note},"\u8FD8\u6CA1\u6709\u914D\u7F6E\u73AF\u5883\u53D8\u91CF"),r("div",{style:Pe},r("button",{style:m.tinyButton,disabled:H,onClick:be},"\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"))),f=r("div",{style:Ee},F?r("div",{style:m.success},F):null,oe?r("div",{style:{...m.note,color:"#b42318"}},oe):null,r("div",{style:m.actions},r("button",{style:m.button,disabled:H,onClick:()=>{Te()}},H?"\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},$("\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),q.detailAvailable===!1?$("\u8BF4\u660E",r("div",{style:m.note},q.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,$("\u6A21\u578B",r("input",{style:m.input,value:Ke,disabled:H,placeholder:"\u4F8B\u5982 deepseek-v4.1-flash-1017","aria-label":"\u6A21\u578B\u540D\u79F0",onChange:l=>re(String(l?.target?.value??""))})),$("\u7CFB\u7EDF\u63D0\u793A\u8BCD",r("textarea",{style:m.textarea,value:Me,disabled:H,"aria-label":"\u7CFB\u7EDF\u63D0\u793A\u8BCD",onChange:l=>se(String(l?.target?.value??""))})),$("\u8FD0\u884C\u65F6\u7248\u672C",i),$("\u73AF\u5883\u53D8\u91CF",y),$("\u4FDD\u5B58",f))};return r("section",{"data-personal-assistant-settings":"true",style:m.page},r("div",{"data-window-drag":""},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")),x?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"}},x):null,Qe,r("div",{style:m.card},$("\u72B6\u6001",r("span",null,r("span",{style:Le},et),J?r("span",{style:m.note},`\u3000\u4E0A\u6B21\u68C0\u67E5 ${J}`):null),!0),$("\u4E91\u7AEF\u5B9E\u4F8B",o?.agentId?r("span",{style:m.mono},o.agentId):r("span",{style:m.note},V?"\u672A\u8FD4\u56DE\u5B9E\u4F8B\u6807\u8BC6":"\u5F00\u901A\u540E\u7531 Studio \u7ED1\u5B9A")),$("\u7F51\u5173",o?.gatewayUrl?r("span",{style:m.mono},o.gatewayUrl):r("span",{style:m.note},"\u7531 Studio Host \u914D\u7F6E")),$("\u52A9\u7406\u8FDE\u63A5",r("span",{style:m.note},g===null?"\u68C0\u67E5\u4E2D":g.length?"\u5DF2\u8FDE\u63A5\u4F60\u7684\u52A9\u7406":"\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA")),$("\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"))),$("\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"))),$("\u63D2\u4EF6\u7248\u672C",r("span",{style:m.note},`\u6784\u5EFA ${Je}`))),V?he():null,V||C?r("div",{style:m.card},$("\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"),C?r("div",{style:m.success},C):null,P?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:ve,placeholder:ge||"ar-\u2026","aria-label":"\u8F93\u5165\u4E91\u7AEF\u5B9E\u4F8B\u6807\u8BC6\u4EE5\u786E\u8BA4\u5173\u95ED",disabled:D,onChange:i=>O(String(i?.target?.value??""))}),r("div",{style:m.actions},r("button",{style:Ie&&!D?m.danger:m.dangerDisabled,disabled:!Ie||D,onClick:()=>{K()}},D?"\u6B63\u5728\u5173\u95ED\u2026":"\u786E\u8BA4\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406"),r("button",{style:m.button,disabled:D,onClick:()=>{w(!1),O("")}},"\u53D6\u6D88"))):r("div",{style:m.actions},r("button",{style:m.dangerButton,disabled:!V||D,onClick:()=>{w(!0),O(""),N("")}},"\u5173\u95ED\u4E2A\u4EBA\u52A9\u7406"),r("span",{style:m.note},V?"\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:_,onClick:()=>{M()}},_?"\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 jn({size:t}={}){let d=He,c=Number(t)>0?Number(t):16;return d?.createElement?d.createElement("svg",{width:c,height:c,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block"}},d.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"}),d.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 Wn({size:t}={}){let d=He,c=Number(t)>0?Number(t):16;return d?.createElement?d.createElement("svg",{width:c,height:c,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"}},d.createElement("rect",{x:2.2,y:3.4,width:11.6,height:7.4,rx:1.4}),d.createElement("path",{d:"M6.6 13.4h2.8"}),d.createElement("path",{d:"M8 10.8v2.6"})):null}function Hn(){let t=He,d=Wn({size:15});return!t?.createElement||!d?"\u4E91\u7535\u8111":t.createElement("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",lineHeight:1}},d,t.createElement("span",null,"\u4E91\u7535\u8111"))}function nn(t){if(!t?.slots?.inject||!t.slots.register)throw new TypeError("Personal Assistant client requires the public DSH slots service");let d=async(n,s={})=>{if(!t.connection?.rpc?.call)throw new wt;let o=await t.connection.rpc.call("/api","personal-assistant",{operation:n,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},c=(n,s)=>{try{let o=()=>n();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=n=>qt({...n,React:He||globalThis.React,workbench:r,Panel:Xt}),c(()=>()=>r.dispose(),"personal-assistant: native workbench")),c(()=>t.slots.inject("main",()=>t.slots.register({name:"main",key:mt,inject:()=>({request:d,nativeWorkbench:r})},$n)),"personal-assistant: main panel"),c(()=>t.slots.inject("sidebar.panellist",()=>t.slots.register({name:"sidebar.panellist",id:mt,order:90,label:"\u4E2A\u4EBA\u52A9\u7406"},jn)),"personal-assistant: sidebar row"),c(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:`${mt}-settings`,order:196,label:"\u4E2A\u4EBA\u52A9\u7406",inject:()=>({request:d})},Mn)),"personal-assistant: settings section"),typeof t.inject=="function"&&c(()=>t.inject(["sidebarRightTabs"],n=>{let s=[],o=b=>{typeof b=="function"&&s.push(b)};try{let b=n.sidebarRightTabs;if(b===void 0||typeof b.register!="function")return;o(b.register({id:at,kind:at,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(n.slots.inject("sidebar.right.pane.tab",()=>n.slots.register({name:"sidebar.right.pane.tab",key:at,inject:()=>({request:d})},g=>Xt({...g,variant:"computer"})))),o(n.slots.inject("sidebar.right.pane.tab.title",()=>n.slots.register({name:"sidebar.right.pane.tab.title",key:at},Hn)))}catch(b){try{console.warn("[personal-assistant] \u53F3\u4FA7\u680F\u6CE8\u518C\u5931\u8D25",b)}catch{}}return()=>{for(let b of s.reverse())b()}}),"personal-assistant: right tab")}window.__ModuleLoader__.load({id:"@kingsoftcloud/agentkit-personal-assistant",factory:t=>{Zt(t("react"));let d;try{d=t("@deepseek-ai/dsh-client-ui-primitives")}catch{d=void 0}return en(d),{name:"agentkit-personal-assistant",inject:Gt,apply:nn}}});})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingsoftcloud/agentkit-personal-assistant",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
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": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"src",
|
|
36
36
|
"runtime",
|
|
37
|
+
"web",
|
|
37
38
|
"scripts",
|
|
38
39
|
"personal-assistant.plugin.json",
|
|
39
40
|
"cordis.patch.yml",
|
|
@@ -35,6 +35,7 @@ const workspace = values.get('workspace') || env.WORKSPACE_PATH || env.AGENTKIT_
|
|
|
35
35
|
const artifacts = values.get('artifacts') || env.AGENTKIT_ARTIFACTS_DIR || `${workspace}/files`;
|
|
36
36
|
const state = values.get('state') || env.ASSISTANT_STATE_PATH || env.AGENTKIT_STATE_DIR || `${workspace}/.agentkit/state`;
|
|
37
37
|
const runtimeToken = env.AGENTKIT_RUNTIME_TOKEN || '';
|
|
38
|
+
const runtimeInstanceId = randomUUID();
|
|
38
39
|
const registryPath = values.get('bot-registry') || env.BOT_REGISTRY_PATH;
|
|
39
40
|
await mkdir(workspace, { recursive: true, mode: 0o700 });
|
|
40
41
|
await mkdir(artifacts, { recursive: true, mode: 0o750 });
|
|
@@ -360,7 +361,7 @@ const server = createServer(async (request, response) => {
|
|
|
360
361
|
return send(response, status, { error: error?.code || error?.message || 'PERSONAL_ASSISTANT_RUNTIME_FAILED' });
|
|
361
362
|
}
|
|
362
363
|
});
|
|
363
|
-
attachDesktopWebSocket({ server, runtimeToken, assistantId, brokerDesktopRequest, brokerDesktopFrameBinary, botIdOf, taskIdOf, listBots: () => registry.list(), sessionRequest: createCloudSessionChannel({ assistantId, computerId, stateStore, registry, sessionCreate, turnWrite, scheduleWrite, cloudFiles }) });
|
|
364
|
+
attachDesktopWebSocket({ server, runtimeToken, assistantId, brokerDesktopRequest, brokerDesktopFrameBinary, botIdOf, taskIdOf, listBots: () => registry.list(), sessionRequest: createCloudSessionChannel({ assistantId, computerId, runtimeInstanceId, stateStore, registry, sessionCreate, turnWrite, scheduleWrite, cloudFiles }) });
|
|
364
365
|
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(port, host, resolve); });
|
|
365
366
|
return { server, stateStore, waitForIdle: () => Promise.allSettled([...pendingTurns]), close: () => { scheduler.dispose(); return new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve())); } };
|
|
366
367
|
}
|