@kingsoftcloud/agentkit-personal-assistant 0.0.0-stage → 0.1.7

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.
Files changed (70) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +7 -0
  3. package/README.md +38 -2
  4. package/cordis.patch.yml +6 -0
  5. package/dist/client.js +6 -0
  6. package/package.json +83 -4
  7. package/personal-assistant.plugin.json +31 -0
  8. package/personal-assistant.plugin.schema.json +43 -0
  9. package/runtime/assistant-runtime.mjs +317 -0
  10. package/runtime/check-manifest.mjs +21 -0
  11. package/runtime/cloud-browser-cdp.mjs +313 -0
  12. package/runtime/cloud-browser.mjs +972 -0
  13. package/runtime/cloud-execution.mjs +320 -0
  14. package/runtime/cloud-session-channel.mjs +45 -0
  15. package/runtime/computer-agentd.mjs +488 -0
  16. package/runtime/desktop-clipboard-limit.mjs +2 -0
  17. package/runtime/desktop-launcher.mjs +106 -0
  18. package/runtime/desktop-permit.mjs +42 -0
  19. package/runtime/desktop-session.mjs +840 -0
  20. package/runtime/desktop-ws.mjs +371 -0
  21. package/runtime/prepare-dsh-profile.mjs +17 -0
  22. package/runtime/welcome-server.mjs +144 -0
  23. package/scripts/assistant-runtime-launcher.sh +3 -0
  24. package/scripts/build-artifacts.mjs +81 -0
  25. package/scripts/build-client.mjs +82 -0
  26. package/scripts/computer-agentd-launcher.sh +3 -0
  27. package/scripts/deterministic_tar.py +21 -0
  28. package/scripts/install-local.mjs +262 -0
  29. package/scripts/scan-secrets.mjs +41 -0
  30. package/scripts/sync-public.mjs +52 -0
  31. package/scripts/verification/gateway-desktop-client.mjs +142 -0
  32. package/scripts/verification/verify-desktop-applications-linux.mjs +46 -0
  33. package/scripts/verification/verify-desktop-input-linux.mjs +127 -0
  34. package/scripts/verification/verify-desktop-pod-gateway.mjs +204 -0
  35. package/scripts/verify-cloud-turn.mjs +18 -0
  36. package/scripts/verify-computer-broker.mjs +10 -0
  37. package/src/automation-tools.mjs +18 -0
  38. package/src/bot-private-tools.mjs +23 -0
  39. package/src/bot-registry.mjs +157 -0
  40. package/src/bot-tool-policy.mjs +48 -0
  41. package/src/bot-tool-scope.mjs +40 -0
  42. package/src/client/bot-directory.mjs +23 -0
  43. package/src/client/components/desktop-clipboard.mjs +194 -0
  44. package/src/client/conversation.mjs +558 -0
  45. package/src/client/desktop-control.mjs +70 -0
  46. package/src/client/desktop-view.mjs +68 -0
  47. package/src/client/entry.mjs +8 -0
  48. package/src/client/index.mjs +733 -0
  49. package/src/client/markdown.mjs +130 -0
  50. package/src/client/native-workbench.mjs +62 -0
  51. package/src/cloud-computer-tools.mjs +245 -0
  52. package/src/cloud-files.mjs +57 -0
  53. package/src/cloud-model.mjs +10 -0
  54. package/src/cloud-session-transport.mjs +76 -0
  55. package/src/computer-broker-protocol.mjs +116 -0
  56. package/src/computer-broker.mjs +220 -0
  57. package/src/desktop-tools.mjs +64 -0
  58. package/src/dsh-session-bridge.mjs +207 -0
  59. package/src/dsh-web-bridge.mjs +127 -0
  60. package/src/host-gateway.mjs +281 -0
  61. package/src/host-session-channel.mjs +410 -0
  62. package/src/implementation-capabilities.mjs +10 -0
  63. package/src/index.mjs +148 -0
  64. package/src/persistent-state.mjs +201 -0
  65. package/src/platform-manifest.mjs +24 -0
  66. package/src/plugin-manifest.mjs +82 -0
  67. package/src/schedule-manager.mjs +88 -0
  68. package/src/system-fetch.mjs +72 -0
  69. package/src/workspace-tools.mjs +22 -0
  70. package/src/workspace.mjs +22 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,7 @@
1
+ AgentKit Personal Assistant
2
+ Copyright 2026 Kingsoft Cloud.
3
+
4
+ This project is an original implementation of a DSH plugin. It does not copy
5
+ source code from DeepSeek-Bot or DSH private modules. DeepSeek-Bot is used only
6
+ as a public design reference for long-lived Bots, persistent state, and plugin
7
+ boundaries. Any future source reuse must preserve its Apache-2.0 notices.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # AgentKit 个人助理
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@kingsoftcloud/agentkit-personal-assistant` 是面向 [DeepSeek Harness](https://github.com/deepseek-ai)(DSH)的个人助理插件:在 Studio 右侧提供助理对话面板,并把对话绑定到一台用户专属的云电脑上——助理可以打开浏览器、终端、文件管理器,替用户操作桌面并实时回传画面。
4
+
5
+ ## 能力
6
+
7
+ - 多逻辑 Bot:同一个助理下管理多个 Bot(不同模型 / 系统提示 / 工具范围)
8
+ - 会话与记忆、日程与自动化任务
9
+ - 云电脑工具入口:截图、键鼠输入、浏览器导航、剪贴板(仅快捷键路径)
10
+ - 桌面接管使用**短期一次性 permit**(`scope=desktop`、可读/可控两种模式、单次 jti、最长 60 秒),不使用长期凭证
11
+
12
+ ## 安装
13
+
14
+ ```sh
15
+ npm i @kingsoftcloud/agentkit-personal-assistant
16
+ ```
17
+
18
+ 插件随 DSH profile 安装;客户端面板产物是 `dist/client.js`(安装时由 `prepack` 构建)。宿主侧要求 Node.js 22.23.4+,DSH 0.2.1。
19
+
20
+ ## 运行架构
21
+
22
+ 插件本身只包含宿主侧入口、面板客户端与云电脑工具协议;云电脑中的桌面进程由配套服务提供。一个云上子用户对应一台个人助理 Pod(`agent-runtime` + `personal-assistant-computer`),插件通过受鉴权的 broker 通道和一次性桌面 permit 访问它,仓库与 Pod 内都不保存长期云凭证。
23
+
24
+ ## 开发
25
+
26
+ ```sh
27
+ npm ci
28
+ npm run build:client
29
+ npm test
30
+ npm pack
31
+ ```
32
+
33
+ ## 安全
34
+
35
+ 见 [SECURITY.md](SECURITY.md)。本仓库不包含任何云凭证;敏感配置全部通过环境变量注入。
36
+
37
+ ## 许可证
38
+
39
+ Apache-2.0,见 [LICENSE](LICENSE) 与 [NOTICE](NOTICE)。
@@ -0,0 +1,6 @@
1
+ # DSH bundle entry for the standalone Personal Assistant plugin.
2
+ # Product defaults (panel disabled and no auto-connect) are owned by the
3
+ # application metadata/feature gate; the Loader only sees this composition row.
4
+ - insert:
5
+ - id: personal-assistant
6
+ name: '@kingsoftcloud/agentkit-personal-assistant'
package/dist/client.js ADDED
@@ -0,0 +1,6 @@
1
+ (()=>{var We=Object.freeze({width:1280,height:800});function Ve(t={}){let g=Number(t.width)||We.width,l=Number(t.height)||We.height;return!Number.isFinite(g)||!Number.isFinite(l)||g<=0||l<=0?We:Object.freeze({width:Math.round(g),height:Math.round(l)})}function ot({clientX:t,clientY:g,rect:l,display:c=We}){let n=Ve(c),s=Number(l?.width)||n.width,o=Number(l?.height)||n.height,r=Number(l?.left)||0,u=Number(l?.top)||0,d=Math.min(s/n.width,o/n.height),v=r+(s-n.width*d)/2,_=u+(o-n.height*d)/2,I=Math.max(0,Math.min(n.width-1,Math.round((Number(t)-v)/d))),k=Math.max(0,Math.min(n.height-1,Math.round((Number(g)-_)/d)));return{x:I,y:k}}function st({send:t,changed:g=()=>{},failed:l=()=>{},setTimer:c=setTimeout,clearTimer:n=clearTimeout}={}){let s=!1,o=0,r="observe",u=!1,d=[],v="",_,I=()=>g({phase:r,readOnly:r!=="controlling",controlEpoch:o,available:s}),k=()=>{n(_),_=void 0;let b=v;v="",b&&r==="controlling"&&t({type:"input",controlEpoch:o,event:{type:"text",text:b}})},D=b=>{b.type==="text"?(v.length+b.text.length>16384&&k(),v+=b.text,_||(_=c(k,30))):(k(),t({type:"input",controlEpoch:o,event:b}))},S=()=>{r="acquiring",I(),t({type:"control.acquire",controlEpoch:o})},M=b=>{if(b.type==="pointermove"&&d.at(-1)?.type==="pointermove")d[d.length-1]=b;else if(d.length<32)d.push(b);else return $.release(),l("\u63A5\u7BA1\u671F\u95F4\u8F93\u5165\u8FC7\u5FEB\uFF0C\u8BF7\u91CD\u65B0\u70B9\u51FB\u4E91\u7535\u8111"),!1;return!0},$={get snapshot(){return{phase:r,readOnly:r!=="controlling",controlEpoch:o,available:s}},reset(b={}){n(_),_=void 0,v="",d=[],s=b.controlAvailable===!0,o=Number.isSafeInteger(b.controlEpoch)?b.controlEpoch:0,r=b.readOnly===!1?"controlling":"observe",u=r==="controlling",I()},input(b){return r==="controlling"?(D(b),!0):(!u||r==="observe")&&(b.type==="pointermove"||["button","key"].includes(b.type)&&b.action==="up")||b.type==="pointermove"&&r==="observe"?!1:s?(u=!0,M(b)?(r==="observe"&&S(),!0):!1):(b.type!=="pointermove"&&l("\u5F53\u524D\u4E3A\u53EA\u8BFB\u65C1\u89C2\uFF0C\u9F20\u6807\u548C\u952E\u76D8\u4E0D\u4F1A\u53D1\u9001\u5230\u4E91\u7535\u8111"),!1)},acquire(){return s?(u=!0,r==="observe"&&S(),!0):!1},release(){u=!1,d=[],r==="controlling"&&(k(),r="releasing",I(),t({type:"control.release",controlEpoch:o}))},accept(b){if(!Number.isSafeInteger(b.controlEpoch)||b.controlEpoch<o)return;if(b.controlEpoch!==o&&(n(_),_=void 0,v=""),o=b.controlEpoch,s=b.controlAvailable===!0,b.readOnly){r!=="releasing"&&(u=!1,d=[]),r="observe",I(),u&&s&&S();return}if(!u){d=[],r="releasing",I(),t({type:"control.release",controlEpoch:o});return}r="controlling",I();let ae=d;d=[];for(let J of ae)D(J)},reject(b){Number.isSafeInteger(b.controlEpoch)&&b.controlEpoch<o||(u=!1,d=[],n(_),_=void 0,v="",Number.isSafeInteger(b.controlEpoch)&&b.controlEpoch>=o&&(o=b.controlEpoch),r=b.readOnly===!1?"controlling":"observe",I(),l(b.message||"\u63A7\u5236\u6743\u6682\u4E0D\u53EF\u7528\uFF0C\u4ECD\u53EF\u7EE7\u7EED\u65C1\u89C2"))},dispose(){$.release(),n(_),_=void 0,v="",d=[]}};return $}var me=(t,g,l)=>Object.assign(new Error(g),{code:t,cause:l}),Nt=t=>{try{return new TextEncoder().encode(t).length}catch{return t.length}},at=t=>typeof t=="string"?t:String(t?.text??"");async function Qe({clipboard:t}={}){let g=t||globalThis.navigator?.clipboard;if(!g||typeof g.readText!="function")throw me("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 l=await g.readText();return typeof l=="string"?l:""}catch(l){throw me("CLIPBOARD_READ_DENIED","\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF0C\u8BF7\u6309 \u2318V / Ctrl+V \u518D\u8BD5",l)}}async function Pt(t,{clipboard:g}={}){let l=g||globalThis.navigator?.clipboard;if(!l||typeof l.writeText!="function")throw me("CLIPBOARD_UNAVAILABLE","\u5F53\u524D\u73AF\u5883\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u624B\u52A8\u590D\u5236");try{await l.writeText(String(t??""))}catch(c){throw me("CLIPBOARD_WRITE_DENIED","\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u91CD\u8BD5",c)}}function Bt(){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 qe(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 Ft=0,Mt=()=>{let t=globalThis.crypto?.randomUUID?.();return t?`clip-${t}`:`clip-${Date.now().toString(36)}-${Ft+=1}`};function it({send:t,timeoutMs:g=5e3,controlEpoch:l,setTimer:c=setTimeout,clearTimer:n=clearTimeout}={}){let s=new Map,o=(u,d)=>{s.delete(u.id),n(u.timer),d()},r=(u,d)=>new Promise((v,_)=>{let I=Mt(),k=c(()=>{let M=s.get(I);M&&o(M,()=>_(me("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);s.set(I,{id:I,timer:k,resolve:v,reject:M=>_(M)});let D=!1,S;try{S=typeof l=="function"?l():void 0}catch{S=void 0}try{D=t({type:u,requestId:I,...Number.isSafeInteger(S)?{controlEpoch:S}:{},...d})!==!1}catch(M){o(s.get(I),()=>_(me("CLIPBOARD_UNAVAILABLE","\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u526A\u8D34\u677F\u6682\u4E0D\u53EF\u7528",M)));return}D||o(s.get(I),()=>_(me("CLIPBOARD_UNAVAILABLE","\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u526A\u8D34\u677F\u6682\u4E0D\u53EF\u7528")))});return Object.freeze({read:()=>r("clipboard.read").then(u=>({text:at(u)})),write:u=>r("clipboard.write",{text:String(u)}).then(d=>({written:d?.written!==!1})),accept(u){if(!u||u.type!=="clipboard.response")return!1;let d=s.get(String(u.requestId||""));return d?(o(d,()=>{u.ok!==!1?d.resolve(u.value):d.reject(me(u.error?.code||"CLIPBOARD_FAILED",u.error?.message||"",u.error))}),!0):!1},rejectAll(u=me("CLIPBOARD_CLOSED","\u4E91\u7535\u8111\u8FDE\u63A5\u5DF2\u65AD\u5F00\uFF0C\u526A\u8D34\u677F\u64CD\u4F5C\u672A\u5B8C\u6210")){for(let d of[...s.values()])o(d,()=>d.reject(u))},get size(){return s.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:l,notify:c=()=>{}}={}){let n=t||(()=>Qe()),s="";try{s=await n()}catch(o){return c(qe(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 c("\u672C\u5730\u526A\u8D34\u677F\u662F\u7A7A\u7684\uFF0C\u6CA1\u6709\u53EF\u7C98\u8D34\u7684\u5185\u5BB9"),{ok:!1,code:"CLIPBOARD_EMPTY"};if(Nt(s)>65536)return c("\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(s)}catch(o){return c(qe(o)||"\u5199\u5165\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_WRITE_FAILED"}}if(typeof l=="function"){let o=!1;try{o=l(Bt())!==!1}catch(r){return{ok:!0,code:"CLIPBOARD_KEY_FAILED",error:r}}if(!o)return c("\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 c("\u5DF2\u7C98\u8D34\u5230\u4E91\u7535\u8111"),{ok:!0}}async function ut({readCloud:t,writeLocal:g,notify:l=()=>{}}={}){let c=g||(o=>Pt(o)),n;try{n=await t()}catch(o){return l(qe(o)||"\u8BFB\u53D6\u4E91\u7535\u8111\u526A\u8D34\u677F\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_READ_FAILED"}}let s=at(n);if(!s)return l("\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 c(s)}catch(o){return l(qe(o)||"\u6D4F\u89C8\u5668\u4E0D\u5141\u8BB8\u5199\u5165\u526A\u8D34\u677F\uFF0C\u8BF7\u91CD\u8BD5"),{ok:!1,code:"CLIPBOARD_WRITE_FAILED"}}return l("\u5DF2\u590D\u5236\u5230\u672C\u5730"),{ok:!0,text:s}}var Ut=/^```\s*([\w+#.-]*)\s*$/u,zt=/^(#{1,6})\s+(.*)$/u,pt=/^\s*[-*+]\s+(.*)$/u,ft=/^\s*(\d{1,3})[.)]\s+(.*)$/u,Xe=/^\s*>\s?(.*)$/u,$t=/^\s*([-*_])\s*(?:\1\s*){2,}$/u;function jt(t){let l=(typeof t=="string"?t.replace(/\r\n?/gu,`
2
+ `):"").split(`
3
+ `),c=[],n=0,s=r=>{r.length!==0&&(c.push({type:"paragraph",text:r.join(`
4
+ `)}),r.length=0)},o=[];for(;n<l.length;){let r=l[n],u=Ut.exec(r);if(u){s(o);let k=[];for(n+=1;n<l.length&&!/^```\s*$/u.test(l[n]);)k.push(l[n]),n+=1;n+=1,c.push({type:"code",lang:u[1]||"",text:k.join(`
5
+ `)});continue}if(r.trim()===""){s(o),n+=1;continue}let d=zt.exec(r);if(d){s(o),c.push({type:"heading",level:d[1].length,text:d[2].trim()}),n+=1;continue}if($t.test(r)){s(o),c.push({type:"rule"}),n+=1;continue}let v=Xe.exec(r);if(v){s(o);let k=[v[1]];for(n+=1;n<l.length&&Xe.test(l[n]);)k.push(Xe.exec(l[n])[1]),n+=1;c.push({type:"quote",text:k.join(`
6
+ `)});continue}let _=pt.exec(r),I=ft.exec(r);if(_||I){s(o);let k={type:I?"ordered":"unordered",items:[],start:I?Number(I[1]):1};for(;n<l.length;){let D=pt.exec(l[n]),S=ft.exec(l[n]);if(!D&&!S)break;k.items.push((D?D[1]:S[2]).trim()),n+=1}c.push(k);continue}o.push(r),n+=1}return s(o),c}function Wt(t){let g=typeof t=="string"?t:"",l=[],c=s=>{s&&l.push({type:"text",text:s})},n=g;for(;n.length>0;){let s=/^`([^`]+)`/u.exec(n);if(s){l.push({type:"code",text:s[1]}),n=n.slice(s[0].length);continue}let o=/^\*\*([^*\n]+)\*\*/u.exec(n)||/^__([^_\n]+)__/u.exec(n);if(o){l.push({type:"strong",text:o[1]}),n=n.slice(o[0].length);continue}let r=/^\*([^*\s][^*\n]*)\*/u.exec(n)||/^_([^_\s][^_\n]*)_/u.exec(n);if(r){l.push({type:"em",text:r[1]}),n=n.slice(r[0].length);continue}let u=/^\[([^\]]+)\]\(([^)\s]+)\)/u.exec(n);if(u){l.push({type:"link",text:u[1],href:u[2]}),n=n.slice(u[0].length);continue}let d=n.slice(1).search(/[`*_[\]\n]/u),v=d<0?n.length:d+1;c(n.slice(0,v)),n=n.slice(v)}return l.reduce((s,o)=>{let r=s[s.length-1];return o.type==="text"&&r&&r.type==="text"?s[s.length-1]={type:"text",text:r.text+o.text}:s.push(o),s},[])}function gt(t,g,l={}){let c=jt(g);if(c.length===0)return null;let n=(s,o)=>Wt(s).map((r,u)=>{let d=`${o}-i${u}`;return r.type==="code"?t("code",{key:d,style:l.inlineCode},r.text):r.type==="strong"?t("strong",{key:d},r.text):r.type==="em"?t("em",{key:d},r.text):r.type==="link"?/^(https?:|mailto:|cloud-file:)/iu.test(r.href)?t("a",{key:d,href:r.href,target:"_blank",rel:"noreferrer noopener",style:l.link},r.text):t("span",{key:d},r.text):t("span",{key:d},r.text)});return c.map((s,o)=>{let r=`b${o}`;if(s.type==="code")return t("pre",{key:r,style:l.codeBlock},t("code",null,s.text));if(s.type==="heading")return t("div",{key:r,style:{...l.heading,...s.level<=2?l.headingStrong:null}},n(s.text,r));if(s.type==="rule")return t("hr",{key:r,style:l.rule});if(s.type==="quote")return t("blockquote",{key:r,style:l.quote},n(s.text,r));if(s.type==="unordered"||s.type==="ordered"){let u=s.type==="ordered"?"ol":"ul";return t(u,{key:r,style:l.list,start:s.type==="ordered"&&s.start!==1?s.start:void 0},s.items.map((d,v)=>t("li",{key:`${r}-l${v}`},n(d,`${r}-l${v}`))))}return t("p",{key:r,style:l.paragraph},n(s.text,r))})}var qt="\u6709\u4EC0\u4E48\u53EF\u4EE5\u5E2E\u4F60\uFF1F",Ht=400,Kt=8,yt=1500,w={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}},V=t=>typeof t=="string"?t:"",Yt=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"})),Vt=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 bt({React:t,request:g,scope:l,onOpenComputer:c=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:r,useState:u}=t,[d,v]=u("loading"),[_,I]=u(""),[k,D]=u([]),[S,M]=u(""),[$,b]=u([]),[ae,J]=u(""),[z,C]=u([]),L=r(null),[B,N]=u(!1),[j,te]=u(!1),[tt,Ue]=u(""),[ne,Le]=u([]),[Oe,re]=u(""),ie=r(0),le=r(new Map),W=r([]),ke=r(!1),Q=r(null),Ne=r(!1);Ne.current=B;let F=r(!1);F.current=j;let pe=r("loading");pe.current=d;let ve=r(0),P=r(!0),Ae=r(null),xe=r(!0),X=r("");X.current=S;let Z=s(async(i,m={})=>{if(typeof g!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return g(i,m)},[g]),h=s(i=>{!Array.isArray(i)||i.length===0||b(m=>{let y=[...m];for(let p of i)if(!(!p||typeof p!="object")){if(p.type==="message"){let T=V(p.id)||`local-${y.length}`,x=V(p.role)||"assistant",R=V(p.text),U=y.findIndex(de=>de.id===T),ee={id:T,role:x,text:R,done:p.done!==!1,clientTurnId:p.clientTurnId,status:"accepted"};if(U>=0)y[U]={...y[U],...ee};else if(x==="user"){let de=y.findIndex(Be=>Be.role==="user"&&p.clientTurnId&&Be.clientTurnId===p.clientTurnId);de>=0?y[de]={...ee}:y.push(ee)}else y.push(ee)}else if(p.type==="delta"){let T=V(p.id)||`local-${y.length}`,x=y.findIndex(R=>R.id===T);x>=0?y[x]={...y[x],text:y[x].text+V(p.text)}:y.push({id:T,role:"assistant",text:V(p.text),done:!1})}else if(p.type==="step"&&V(p.text)){let T={id:V(p.id),role:"step",text:V(p.text),done:!0},x=y.findIndex(R=>R.id===T.id);x>=0?y[x]=T:y.push(T)}}return y})},[]),oe=s(async i=>{if(!i)return;let m=X.current;if(m&&m!==i&&W.current.length>0){let p=W.current.length;W.current=[],Le([]),Q.current&&(clearTimeout(Q.current),Q.current=null),re(`\u5DF2\u5207\u6362\u4F1A\u8BDD\uFF0C${p} \u6761\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001\uFF0C\u5DF2\u53D6\u6D88`)}else m&&m!==i&&re("");X.current=i;let y=++ve.current;M(i),v("loading"),I(""),ie.current=0,xe.current=!0,b([]);try{let p=await Z("personal-assistant.session.snapshot",{sessionId:i});if(!P.current||X.current!==i||y!==ve.current)return;ie.current=Number(p?.cursor)||0;let T=Array.isArray(p?.messages)?p.messages:[];b(T.map((x,R)=>({id:V(x?.id)||`history-${R}`,role:V(x?.role)||"assistant",text:V(x?.text),done:!0}))),te(p.turns?.some(x=>["queued","running"].includes(x.status))||!1),v("ready")}catch(p){if(!P.current||y!==ve.current)return;v("error"),I(p?.message||"\u65E0\u6CD5\u8BFB\u53D6\u4F1A\u8BDD\u5185\u5BB9")}},[Z]),se=s(async()=>{if(v("loading"),I(""),!!P.current)try{let i=await Z("personal-assistant.sessions.list");if(!P.current)return;let m=Array.isArray(i?.sessions)?i.sessions:[];if(D(m),m.length>0){await oe(V(m[0].sessionId));return}let y=await Z("personal-assistant.session.create",{});if(!P.current)return;let p=V(y?.sessionId);D(p?[{sessionId:p,title:V(y?.title)||"\u65B0\u4F1A\u8BDD"}]:[]),await oe(p)}catch(i){if(!P.current)return;v("error"),I(i?.message||"\u4F1A\u8BDD\u901A\u9053\u6682\u65F6\u4E0D\u53EF\u7528")}},[Z,oe]);o(()=>(P.current=!0,se(),()=>{P.current=!1,Q.current&&(clearTimeout(Q.current),Q.current=null)}),[se]),o(()=>{if(d!=="ready"||!S)return;let i=!1,m=null,y=async()=>{try{let p=await Z("personal-assistant.session.events",{sessionId:S,cursor:ie.current});if(i)return;if(ie.current=Number(p?.cursor??ie.current)||0,h(p?.events),Array.isArray(p.turns)){te(p.turns.some(U=>["queued","running"].includes(U.status)));let T=p.turns.findLast(U=>["queued","running"].includes(U.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"},R=T?.progress?.tool;Ue(R?`${T.progress.state==="running"?"\u6B63\u5728":"\u5DF2\u5B8C\u6210"}${x[R]||(R.startsWith("cloud_browser_")?"\u64CD\u4F5C\u4E91\u7AEF\u6D4F\u89C8\u5668":"\u6267\u884C\u5DE5\u5177")}`:""),h(p.turns.filter(U=>["failed","interrupted","cancelled"].includes(U.status)).map(U=>({type:"step",id:`turn-status-${U.turnId}`,text:`\u4EFB\u52A1${U.status==="failed"?"\u5931\u8D25":"\u5DF2\u4E2D\u65AD"}\uFF1A${U.error||"\u8BF7\u68C0\u67E5\u4EFB\u52A1\u72B6\u6001\u540E\u91CD\u8BD5"}`})))}I("")}catch(p){if(!i){if(p.code==="SESSION_CURSOR_STALE"){oe(S);return}I(p.message||"\u4E91\u7AEF\u8FDE\u63A5\u4E2D\u65AD\uFF0C\u6B63\u5728\u6062\u590D\uFF1B\u4EFB\u52A1\u4E0D\u4F1A\u6539\u5230\u672C\u673A\u6267\u884C")}}i||(m=setTimeout(y,600))};return m=setTimeout(y,200),()=>{i=!0,clearTimeout(m)}},[d,S,Z,h,oe]),o(()=>{let i=Ae.current;i&&xe.current&&(i.scrollTop=i.scrollHeight)},[$,j]);let Ke=async i=>{let m=Array.from(i.target.files||[]);i.target.value="";let y=[];for(let p of m.slice(0,4)){if(!p||p.size>512*1024){I("\u6BCF\u4E2A\u9644\u4EF6\u6700\u591A 512 KiB\uFF0C\u8BF7\u5148\u538B\u7F29\u6216\u62C6\u5206\u6587\u4EF6");continue}let T=await new Promise(x=>{let R=new FileReader;R.onload=()=>x(String(R.result||"")),R.onerror=()=>x(""),R.readAsDataURL(p)});T&&y.push({id:`${Date.now()}-${p.name}`,name:p.name,mimeType:p.type||"application/octet-stream",size:p.size,dataUrl:T})}y.length&&C(p=>[...p,...y].slice(0,4))},we=i=>{W.current=i,Le(i)},_e=()=>{Q.current&&(clearTimeout(Q.current),Q.current=null)},Te=i=>Number(i?.status)===409||/SESSION_BUSY|active turn|正忙|处理中/u.test(`${i?.code||""} ${i?.message||""}`),Pe=async(i,{restoreDraft:m=!1}={})=>{le.current.set(i.clientTurnId,i),xe.current=!0,N(!0),I(""),te(!0),b(p=>p.some(T=>T.clientTurnId===i.clientTurnId)?p.map(T=>T.clientTurnId===i.clientTurnId?{...T,status:"pending"}:T):[...p,{id:`local-user-${i.clientTurnId}`,clientTurnId:i.clientTurnId,role:"user",text:i.text,done:!1,status:"pending"}]);let y=i;try{let p=Array.isArray(y.attachments)?y.attachments:[];if(p.length===0&&Array.isArray(y.uploads)&&y.uploads.length>0){let x=[];for(let R of y.uploads)x.push(await Z("personal-assistant.file.upload",{sessionId:y.sessionId,name:R.name,dataUrl:R.dataUrl}));p=x.map(({path:R,name:U,mediaType:ee,bytes:de})=>({path:R,name:U,mediaType:ee,bytes:de})),y={...y,attachments:p,uploads:[]},le.current.set(y.clientTurnId,y)}let T=await Z("personal-assistant.turn.submit",{sessionId:y.sessionId,text:y.text,clientTurnId:y.clientTurnId,attachments:p});return P.current?(le.current.delete(y.clientTurnId),b(x=>x.map(R=>R.clientTurnId===y.clientTurnId?{...R,status:"accepted",turnId:T.turnId}:R)),{ok:!0,item:y}):{ok:!0,item:y}}catch(p){return P.current?(te(Te(p)),m&&!Te(p)&&J(T=>T||y.text),b(T=>T.map(x=>x.clientTurnId===y.clientTurnId?{...x,status:"failed",failure:p.message||"\u53D1\u9001\u7ED3\u679C\u5F85\u786E\u8BA4\uFF0C\u91CD\u8BD5\u5C06\u590D\u7528\u539F\u6807\u8BC6"}:x)),{ok:!1,failure:p,item:y}):{ok:!1,failure:p,item:y}}finally{P.current&&N(!1)}},fe=(i,m)=>{let y=(i.attempts||0)+1;if(le.current.delete(i.clientTurnId),b(T=>T.filter(x=>x.clientTurnId!==i.clientTurnId)),y>Kt){re(`\u6392\u961F\u6D88\u606F\u591A\u6B21\u672A\u53D1\u51FA\uFF08${m?.message||"\u4E91\u7535\u8111\u4ECD\u5FD9"}\uFF09\uFF0C\u5DF2\u653E\u56DE\u8F93\u5165\u6846\uFF0C\u8BF7\u624B\u52A8\u91CD\u8BD5`),J(T=>T||i.text);return}we([{...i,attempts:y},...W.current]);let p=(yt*Math.min(y,3)/1e3).toFixed(1);re(`\u4E91\u7535\u8111\u4ECD\u5728\u5904\u7406\u4E0A\u4E00\u8F6E\uFF0C\u6D88\u606F\u5DF2\u6392\u961F\uFF0C\u7EA6 ${p} \u79D2\u540E\u81EA\u52A8\u91CD\u53D1`),_e(),Q.current=setTimeout(()=>{Q.current=null,Ce(!0)},yt*Math.min(y,3))},Ce=async i=>{let m=X.current;if(ke.current||!P.current||pe.current!=="ready"||!m||Ne.current||!i&&F.current)return!1;let y=W.current[0];if(!y)return!1;if(y.sessionId!==m)return we([]),re("\u4F1A\u8BDD\u5DF2\u53D8\u5316\uFF0C\u6392\u961F\u6D88\u606F\u672A\u53D1\u9001"),!1;ke.current=!0,we(W.current.slice(1));try{let p=await Pe(y);return p.ok?!0:(Te(p.failure)?fe(p.item||y,p.failure):re(`\u6392\u961F\u6D88\u606F\u53D1\u9001\u5931\u8D25\uFF1A${p.failure?.message||"\u8BF7\u70B9\u51FB\u91CD\u8BD5"}`),!1)}finally{ke.current=!1}},ce=i=>{le.current.delete(i),we(W.current.filter(m=>m.clientTurnId!==i)),re("\u5DF2\u64A4\u56DE\u6392\u961F\u6D88\u606F")},Re=async(i=null)=>{if(d!=="ready"||!S)return;if(i){B||Pe(i,{restoreDraft:!0});return}let m=ae.trim()||(z.length?"\u8BF7\u67E5\u770B\u9644\u4EF6\u3002":"");if(!m)return;let y=z.map(({name:T,mimeType:x,size:R,dataUrl:U})=>({name:T,mimeType:x,size:R,dataUrl:U}));if(B||j){we([...W.current,{clientTurnId:crypto.randomUUID(),text:m,sessionId:S,uploads:y,attempts:0,queuedAt:Date.now()}]),xe.current=!0,J(""),C([]),I(""),re("");return}J(""),C([]),I(""),re("");let p=await Pe({clientTurnId:crypto.randomUUID(),text:m,sessionId:S,uploads:y,attempts:0},{restoreDraft:!0});!p.ok&&Te(p.failure)&&fe(p.item,p.failure)};o(()=>{if(d!=="ready"||!S||B||j||ne.length===0)return;let i=setTimeout(()=>{Ce(!1)},Ht);return()=>clearTimeout(i)},[d,S,B,j,ne]),o(()=>{if(ne.length===0||typeof window>"u"||typeof window.addEventListener!="function")return;let i=m=>{m.preventDefault(),m.returnValue=""};return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[ne.length]);let ze=n("header",{style:w.header},n("h1",{style:w.title},"\u4E2A\u4EBA\u52A9\u7406"),n("span",{style:w.status},d==="ready"?"\u4E91\u7AEF\u5E38\u9A7B\uFF0C\u5173\u6389\u7A97\u53E3\u4E5F\u4F1A\u7EE7\u7EED":d==="loading"?"\u6B63\u5728\u8FDE\u63A5\u2026":"\u8FDE\u63A5\u4E0D\u53EF\u7528"),n("span",{style:w.spacer}),c?n("button",{type:"button",onClick:c,"aria-label":"\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",title:"\u6253\u5F00\u6216\u91CD\u65B0\u6253\u5F00\u4E91\u7535\u8111\u4FA7\u680F",style:{...w.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:w.page,onClick:async i=>{let m=i.target.closest?.('a[href^="cloud-file:"]');if(m){i.preventDefault();try{let y=await Z("personal-assistant.file.download",{sessionId:S,path:decodeURIComponent(m.getAttribute("href").slice(11))}),p=Uint8Array.from(atob(y.data),R=>R.charCodeAt(0)),T=URL.createObjectURL(new Blob([p],{type:"application/octet-stream"})),x=document.createElement("a");x.href=T,x.download=y.name,x.click(),setTimeout(()=>URL.revokeObjectURL(T),1e3)}catch(y){I(y.message||"\u4E91\u7AEF\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}}}},ze,n("style",null,"@keyframes pa-awaiting { 0%, 100% { opacity: 0.35 } 50% { opacity: 1 } }"),_&&$.length>0?n("div",{role:"alert",style:{padding:"8px 16px",background:"#fff0d6"}},_):null,n("div",{ref:Ae,"data-personal-assistant-messages":"true",style:w.scroller,onScroll:i=>{let m=i.currentTarget;xe.current=m.scrollHeight-m.clientHeight-m.scrollTop<64}},n("div",{style:w.thread},$.length===0?n("div",{style:{...w.status,paddingTop:40,textAlign:"center"}},d==="error"?n("div",{style:{...w.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:w.ghost,onClick:()=>{se()}},"\u91CD\u8BD5")):d==="loading"?"\u6B63\u5728\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406\u2026":qt):null,$.map(i=>{if(i.role==="step")return n("div",{key:i.id,style:w.step},`\xB7 ${i.text}`);let m=i.role==="user";return n("div",{key:i.id,style:m?w.rowUser:w.row},n("span",{style:w.who},m?"\u4F60":"\u52A9\u7406"),n("div",{style:m?w.bubbleUser:w.bubble},m?i.text||"\u2026":gt(n,i.text||"",w)||"\u2026"),i.status==="failed"?n("button",{onClick:()=>{Re(le.current.get(i.clientTurnId))},disabled:B},`${i.failure} \xB7 \u91CD\u8BD5\u53D1\u9001`):null)}),j?n("div",{key:"awaiting",style:w.row},n("span",{style:w.who},"\u52A9\u7406"),n("div",{style:{...w.bubble,color:"var(--dsw-alias-label-secondary, #536174)"}},n("span",{style:w.pulse},tt||"\u6B63\u5728\u5904\u7406\u2026"))):null,ne.map(i=>n("div",{key:`queued-${i.clientTurnId}`,style:w.rowUser},n("span",{style:w.who},"\u4F60 \xB7 \u6392\u961F\u4E2D"),n("div",{style:w.queueBubble},`${i.text}${i.uploads?.length?`\uFF08${i.uploads.length} \u4E2A\u9644\u4EF6\u5F85\u53D1\uFF09`:""}`),n("div",{style:w.queueRow},n("span",{style:w.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:w.queueCancel,onClick:()=>ce(i.clientTurnId)},ht(n),"\u64A4\u56DE")))))),n("div",{"data-personal-assistant-composer":"true",style:w.composer},Oe?n("div",{role:"status",style:w.queueNotice},Oe):null,n("div",{style:w.composerInner},z.length>0?n("div",{style:w.attachRow},z.map(i=>n("span",{key:i.id,style:w.attach},i.mimeType.startsWith("image/")?n("img",{src:i.dataUrl,alt:"",style:w.attachThumb}):null,n("span",{style:w.attachName},i.name),n("button",{"aria-label":`\u79FB\u9664 ${i.name}`,style:{...w.iconButton,width:16,height:16,border:"none"},onClick:()=>C(m=>m.filter(y=>y.id!==i.id))},ht(n))))):null,n("textarea",{"aria-label":"\u7ED9\u4E2A\u4EBA\u52A9\u7406\u53D1\u6D88\u606F",value:ae,rows:1,style:w.textarea,placeholder:d!=="ready"?"\u4E91\u7AEF\u6682\u672A\u8FDE\u63A5\uFF0C\u53EF\u5148\u5199\u4E0B\u6D88\u606F":B||j?"\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=>J(i.target.value),onKeyDown:i=>{d==="ready"&&i.key==="Enter"&&!i.shiftKey&&!i.nativeEvent?.isComposing&&(i.preventDefault(),Re())}}),n("div",{style:w.composerBar},n("button",{"aria-label":"\u6DFB\u52A0\u9644\u4EF6",style:w.iconButton,disabled:d!=="ready"||B,title:"\u4E0A\u4F20\u5230\u4E91\u7535\u8111\uFF1A\u6700\u591A 4 \u4E2A\u6587\u4EF6\uFF0C\u6BCF\u4E2A 512 KiB",onClick:()=>L.current?.click()},Vt(n)),n("input",{ref:L,type:"file",multiple:!0,accept:"image/*,.txt,.md,.json,.pdf",style:{display:"none"},onChange:Ke}),n("span",{style:w.spacer}),ne.length>0?n("span",{role:"status",style:w.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:B||j?"\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:d!=="ready"||!ae.trim()&&z.length===0,style:d!=="ready"||!ae.trim()&&z.length===0?{...w.send,...w.sendDisabled}:B||j?w.sendQueued:w.send,onClick:()=>{Re()}},Yt(n))))))}var mt="personal-assistant-computer",Qt="personal-assistant",xt="\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",Xt=()=>Object.assign(new Error(xt),{code:"PERSONAL_ASSISTANT_NATIVE_SIDEBAR_REQUIRED"});function Gt(t){return t.workbench.render(t)}function wt({sidebarRight:t,slots:g,panelId:l=Qt}={}){let c=typeof t?.registerPanelSurface=="function"&&typeof t?.openPanelTab=="function"&&typeof t?.setPanelExpanded=="function"&&typeof g?.inject=="function"&&typeof g?.register=="function",n=new Set,s,o=!1,r=Object.freeze({binding:void 0}),u=()=>{r=Object.freeze({binding:s});for(let k of[...n])k()},d=()=>{if(!c)throw Xt();if(o)throw new Error("\u4E91\u7535\u8111\u5DE5\u4F5C\u9762\u677F\u5DF2\u5173\u95ED")},v,_,I={available:c,unavailableReason:c?null:xt,subscribe:k=>(n.add(k),()=>n.delete(k)),getSnapshot:()=>r,bind(k,D){if(d(),!k?.agentId||!k?.botId||typeof D!="function")throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");s&&(s.scope.agentId!==k.agentId||s.scope.botId!==k.botId)&&(v(),v=t.registerPanelSurface(l)),s=Object.freeze({scope:Object.freeze({...k}),request:D}),u(),I.open()},open(){d(),s&&t.openPanelTab(l,mt)},collapse(){d(),t.setPanelExpanded(l,!1)},dispose(){o||(o=!0,_?.(),v?.(),n.clear())}};return c&&(v=t.registerPanelSurface(l),_=g.inject("sidebar.right.panel.tab",()=>g.register({name:"sidebar.right.panel.tab",key:mt,inject:()=>({workbench:I})},Gt))),I}function It({React:t,workbench:g,Panel:l,active:c=!0,fullscreen:n=!1}){let{createElement:s,useSyncExternalStore:o}=t,r=o(g.subscribe,g.getSnapshot,g.getSnapshot);if(!c||!r.binding)return null;let{scope:u,request:d}=r.binding;return s(l,{key:`${u.agentId}:${u.botId}:${u.sessionId||""}`,request:d,initialBotId:u.botId,initialSessionId:u.sessionId,agentId:u.agentId,variant:"native-tab",active:c,nativeFullscreen:n})}var Jt="__directory__";function Ge(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(l=>{let c=String(l?.botId||"").trim(),n=String(l?.displayName||c).trim();if(!c||c.length>64||/[\u0000-\u001f]/u.test(c)||c===Jt||g.has(c)||!n||n.length>256)throw new TypeError("\u52A9\u7406\u76EE\u5F55\u683C\u5F0F\u65E0\u6548");return g.add(c),{botId:c,displayName:c==="default"&&n==="Personal Assistant"?"\u9ED8\u8BA4\u52A9\u7406":c==="researcher"&&n==="Researcher"?"\u7814\u7A76\u52A9\u7406":n}})}function Je(t,g=""){let l=Ge(t),c=String(g||"").trim(),n=c?l.find(s=>s.botId===c):l.find(s=>s.botId==="default")||(l.length===1?l[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 et=class extends Error{constructor(){super("Personal Assistant gateway is not connected"),this.name="PersonalAssistantGatewayUnavailableError",this.code="PERSONAL_ASSISTANT_GATEWAY_UNAVAILABLE"}};var kt=Object.freeze(["slots","connection","sidebarRight"]),Ze="personal-assistant",hn=Object.freeze({enabled:!1,autoConnect:!1}),He="personal-assistant-computer",Me="2026-10-28T03:37:57.547Z",St=12e3,Ee;function At(t){Ee=t}var ue={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",vt=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",Zt=t=>Number(t?.status)===409&&["PERSONAL_ASSISTANT_DIRECTORY_UNSUPPORTED","PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE"].includes(t?.code),en={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 Tt({request:t,initialBotId:g="",openInSidebar:l=null,variant:c="page",nativeFullscreen:n=!1}={}){let s=Ee||globalThis.React;if(!s)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:o,useEffect:r,useRef:u,useState:d}=s,[v,_]=d(null),[I,k]=d([]),[D,S]=d(""),[M,$]=d(null),[b,ae]=d(!1),[J,z]=d(g),[C,L]=d("loading"),[B,N]=d(""),[j,te]=d(!0),[tt,Ue]=d(0),[ne,Le]=d(0),[Oe,re]=d("observe"),[ie,le]=d(null),[W,ke]=d(""),[Q,Ne]=d(""),F=u(null),pe=u(null),ve=u(null),P=u(null),Ae=u(null),xe=u(null),X=u(null),Z=u(n);Z.current=n;let h=u({mounted:!0,socket:null,generation:0,frameEpoch:0,session:null,suspended:!1,resuming:!1,pendingInputs:[],display:{width:1280,height:800},readOnly:!0,botId:J,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});h.current.botId=J;let oe=async(e,a={})=>{if(typeof t!="function")throw new Error("Studio Host \u5C1A\u672A\u8FDE\u63A5");return t(e,a)},se=e=>{let a=h.current;return a.socket?.readyState!==1?!1:(a.socket.send(JSON.stringify(e)),!0)},Ke=()=>{let e=h.current;for(let a of e.pressed)F.current?.input({type:"key",action:"up",key:a});for(let a of e.buttons)F.current?.input({type:"button",action:"up",button:a});e.pressed.clear(),e.buttons.clear()},we=()=>{for(let e of h.current.buttons)F.current?.input({type:"button",action:"up",button:e});h.current.buttons.clear()};F.current||(F.current=st({send:se,changed:e=>{let a=h.current;a.controlPhase=e.phase,a.readOnly=e.readOnly,a.controlEpoch=e.controlEpoch,e.readOnly&&X.current&&(X.current.style.visibility="hidden"),e.phase==="observe"&&(a.pressed.clear(),a.buttons.clear()),a.mounted&&(te(e.readOnly),re(e.phase))},failed:e=>{h.current.mounted&&N(e)}})),pe.current||(pe.current=it({send:se,controlEpoch:()=>F.current?.snapshot?.controlEpoch}));let _e=()=>{Ke(),F.current.release(),h.current.pressed.clear(),h.current.buttons.clear()},Te=()=>{let e=h.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)&&(F.current.input({type:"pointermove",...a}),e.sentPointer=a)},Pe=()=>{clearTimeout(h.current.reconnect),clearTimeout(h.current.firstFrame),h.current.reconnect=null,h.current.firstFrame=null},fe=(e=!0)=>{let a=h.current;a.reconnectAllowed=!1,Pe(),_e(),a.generation+=1,pe.current?.rejectAll();try{se({type:"close"}),a.socket?.close(1e3,"panel closed")}catch{}F.current.reset({readOnly:!0}),a.lastDrawnFrame=null,a.socket=null,a.session=null,a.pendingFrame=null,a.frameMetadata=null,a.readOnly=!0,Ae.current?.blur(),a.suspended=!1,a.resuming=!1,a.pendingInputs=[],a.frameEpoch++,e&&a.mounted&&(L(a.config?.configured?"idle":"unconfigured"),te(!0))},Ce=e=>{fe(!1),te(!0),L("closed"),N(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")},ce=e=>{let a=h.current;if(e.type!=="pointermove"&&Te(),a.suspended||a.resuming){if(e.type==="pointermove")return!1;let E=a.mode==="control";if(E){if(a.pendingInputs.length>=32)return fe(),N("\u6062\u590D\u671F\u95F4\u8F93\u5165\u8FC7\u5FEB\uFF0C\u8BF7\u91CD\u65B0\u8FDE\u63A5"),!1;a.pendingInputs.push(e)}return a.resuming||T(),E}return!a.session||a.socket?.readyState!==1?(N("\u4E91\u7535\u8111\u5C1A\u672A\u8FDE\u63A5\uFF0C\u8F93\u5165\u672A\u53D1\u9001"),!1):F.current.input(e)},Re=e=>{h.current.mounted&&(Ne(e),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{h.current.mounted&&Ne("")},4e3))},ze=e=>{let a=!1;for(let E of e)a=ce(E)||a;return a},i=async()=>{let e=/Mac|iPhone|iPad/u.test(String(globalThis.navigator?.platform||""))?"Meta":"Control";if(!h.current.pressed.has("_copyShortcut")){h.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(a=>setTimeout(a,150))}finally{h.current.pressed.delete("_copyShortcut")}}return ut({readCloud:()=>pe.current.read(),notify:Re})},m=()=>dt({readLocal:()=>Qe(),writeCloud:e=>pe.current.write(e),sendKeys:ze,notify:Re}),y=async()=>{let e=h.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||!P.current)continue;e.lastDrawnFrame=a;let f=P.current,K=f.getBoundingClientRect(),G=Math.max(1,globalThis.devicePixelRatio||1);f.width=Math.max(1,Math.round(K.width*G)),f.height=Math.max(1,Math.round(K.height*G));let q=f.getContext("2d"),Y=e.display,Se=Math.min(f.width/Y.width,f.height/Y.height),he=Y.width*Se,A=Y.height*Se;q.clearRect(0,0,f.width,f.height),q.drawImage(E,(f.width-he)/2,(f.height-A)/2,he,A);let be=e.firstFrame!==null;e.frames+=1,clearTimeout(e.firstFrame),e.firstFrame=null,e.retries=0,be&&N(""),L(e.readOnly?"readonly":"ready"),Ue(0)}catch{e.mounted&&N("\u684C\u9762\u5E27\u65E0\u6CD5\u89E3\u7801\uFF0C\u8BF7\u91CD\u8BD5")}finally{E?.close()}}}finally{e.decoding=!1}}},p=e=>{let a=h.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,Le(0),te(!0),L("dormant"),N(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")},T=()=>{let e=h.current;if(e.resuming||!e.suspended)return;if(e.socket?.readyState!==1){x(e.mode,!1,e.pendingInputs);return}e.resuming=!0,L("resuming"),N("\u6B63\u5728\u6062\u590D\u684C\u9762\u5E76\u68C0\u67E5\u63A7\u5236\u6743\uFF0C\u8BF7\u7A0D\u5019\u3002"),se({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")},St)},x=async(e="read",a=!1,E=[])=>{let f=h.current,K=String(f.botId||"").trim();if(!f.config?.configured){L("unconfigured");return}if(!K||!f.bots?.some(q=>q.botId===K)){N("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");return}fe(!1),f.pendingInputs=E,f.resuming=E.length>0;let G=++f.generation;f.reconnectAllowed=!0,a||(f.retries=0),f.mode=e,f.taskId||=`studio-desktop-${globalThis.crypto.randomUUID()}`,f.receivedSeq=-1,f.frameMetadata=null,L(a?"reconnecting":"connecting"),N("\u9996\u6B21\u6216\u4F11\u7720\u540E\u8FDE\u63A5\u53EF\u80FD\u9700\u8981\u6570\u79D2\uFF0C\u8BF7\u7A0D\u5019\u3002");try{let q=await oe("personal-assistant.desktop.ticket",{agentId:f.config.agentId,botId:K,mode:e==="observe"?"control":e});if(!f.mounted||G!==f.generation)return;let Y=new WebSocket(q.wsUrl,["agentkit.personal-assistant.desktop.v1",`agentkit.desktop.ticket.${q.ticket}`]);Y.binaryType="arraybuffer",f.socket=Y;let Se=()=>f.mounted&&f.generation===G;Y.onopen=()=>{if(!Se()){Y.close();return}se({type:"open",botId:K,taskId:f.taskId,mode:e,...q.leaseId?{leaseId:q.leaseId}:{}}),f.firstFrame=setTimeout(()=>{Se()&&(N("\u4E91\u7535\u8111\u54CD\u5E94\u8F83\u6162\uFF0C\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5"),Y.close(4e3,"first frame timeout"))},St)},Y.onmessage=he=>{if(!Se())return;if(typeof he.data!="string"){let be=f.frameMetadata;f.frameMetadata=null;let De=he.data;if(!be||!Number.isSafeInteger(be.seq)||be.seq<=f.receivedSeq||!(De instanceof ArrayBuffer)||De.byteLength===0||De.byteLength>307200||f.suspended)return;f.receivedSeq=be.seq,f.pendingFrame={bytes:De,seq:be.seq,generation:G,frameEpoch:f.frameEpoch},y();return}let A;try{A=JSON.parse(he.data)}catch{return}if(A.type==="ready"){f.suspended=!1,f.resuming=!1,f.receivedSeq=-1,f.session=A.sessionId,f.readOnly=!!A.readOnly,f.display=Ve(A.display),f.mode=e,F.current.reset(A);let be=f.pendingInputs;if(f.pendingInputs=[],f.readOnly)f.pressed.clear(),f.buttons.clear();else for(let De of be)F.current.input(De);te(f.readOnly),N("\u4E91\u7535\u8111\u5DF2\u8FDE\u63A5\uFF0C\u6B63\u5728\u51C6\u5907\u684C\u9762\u753B\u9762");return}if(A.type==="control"){F.current.accept(A),N("");return}if(A.type==="idle"){p(A);return}if(A.type==="frame"){A.unchanged||(f.frameMetadata=A);return}if(A.type==="clipboard.response"){pe.current?.accept(A);return}if(A.type==="closed"){A.retryable!==!0&&Ce(A);return}if(A.type==="error"){if(Number.isSafeInteger(A.controlEpoch)&&A.controlEpoch<f.controlEpoch)return;if(N(A.message||A.code||"\u4E91\u7535\u8111\u8BF7\u6C42\u5931\u8D25"),f.handoffSupported&&A.recoverable===!0){F.current.reject(A);return}if(A.recoverable===!0&&Number(A.status)===409){A.code==="DESKTOP_SESSION_IDLE"?p():(f.pendingInputs=[],f.readOnly=!0,f.pressed.clear(),f.buttons.clear(),te(!0),L("readonly"));return}if(Number(A.status)===409&&e==="control"&&!f.session){x(h.current.handoffSupported?"observe":"read");return}[404,409].includes(Number(A.status))||A.code==="DESKTOP_SESSION_NOT_FOUND"?Ce(A):f.session||(L("error"),fe(!1))}},Y.onerror=()=>{Se()&&N("\u684C\u9762\u901A\u9053\u6682\u65F6\u65AD\u5F00\uFF0C\u6B63\u5728\u91CD\u8FDE")},Y.onclose=he=>{if(!Se())return;if(f.suspended&&he.code!==1e3){clearTimeout(f.firstFrame),f.firstFrame=null,f.socket=null,L("dormant");return}if(f.session=null,clearTimeout(f.firstFrame),f.firstFrame=null,!f.reconnectAllowed||he.code===1e3){Ce();return}if(document.hidden){L("hidden");return}let A=++f.retries;if(Ue(A),A>5){f.reconnectAllowed=!1,L("error"),N("\u65E0\u6CD5\u8FDE\u63A5\u4E91\u7535\u8111\uFF0C\u8BF7\u68C0\u67E5\u5B9E\u4F8B\u72B6\u6001\u6216\u7F51\u7EDC\u540E\u91CD\u8BD5");return}L("reconnecting"),f.reconnect=setTimeout(()=>{x(e,!0,f.pendingInputs)},Math.min(8e3,1e3*2**(A-1)))}}catch(q){f.mounted&&G===f.generation&&(L("error"),N(vt(q)))}},R=async e=>{if(e?.aborted)return null;try{let a=await oe("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:Et(a),candidates:[]}}},U=async e=>{if(!W){ke(e),N(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 oe(`personal-assistant.desktop.${e}`),N(""),await ee()}catch(a){N(Et(a)),le(await R().catch(()=>null))}finally{ke("")}}},ee=async(e,a=!1)=>{fe(!1),L("loading"),N(""),S(""),$(null);try{let E=await oe("personal-assistant.configuration");if(e?.aborted||!h.current.mounted)return;if(h.current.config=E,_(E),!E.configured){let q=await R(e);if(e?.aborted||!h.current.mounted)return;if(h.current.bots=[],k([]),z(""),le(q),L("unconfigured"),q?.configured&&!a){await ee(e,!0);return}return}le(null);let f=await oe("personal-assistant.bots.list");if(e?.aborted||!h.current.mounted)return;if(f.directoryAvailable!==!0)throw Object.assign(new Error("directory unavailable"),{code:"PERSONAL_ASSISTANT_DIRECTORY_UNAVAILABLE",status:409});let K=Ge(f.bots);h.current.bots=K,h.current.handoffSupported=f.features?.includes("desktop-handoff/v1")===!0,k(K);let G=K.length?Je(K,g||E.botId):"";h.current.botId=G,z(G),L(K.length?"idle":"empty"),G&&["computer","native-tab"].includes(c)&&x(h.current.handoffSupported?"observe":"read")}catch(E){if(e?.aborted||!h.current.mounted)return;Number.isInteger(E?.closeCode)&&E.closeCode>=1e3&&E.closeCode<=4999&&$(E.closeCode),h.current.bots=[],k([]),z(""),L("directory-error"),S(Zt(E)?"\u4E91\u7AEF\u52A9\u7406\u9700\u8981\u66F4\u65B0\uFF0C\u8BF7\u66F4\u65B0\u540E\u91CD\u65B0\u8FDE\u63A5\u3002":vt(E))}};r(()=>{let e=h.current;e.mounted=!0;let a=new AbortController;ee(a.signal);let E=setInterval(()=>{e.mounted&&Le(e.frames),e.frames=0},1e3),f=()=>{document.hidden?(_e(),se({type:"pause"})):e.socket?.readyState===1?se({type:"resume"}):e.reconnectAllowed&&e.config?.configured&&e.session===null&&e.socket&&x(e.mode,!0)},K=typeof ResizeObserver=="function"?new ResizeObserver(()=>{e.lastDrawnFrame&&(e.pendingFrame=e.lastDrawnFrame,y())}):null;P.current&&K?.observe(P.current);let G=()=>_e(),q=Y=>{xe.current?.contains(Y.target)||_e()};return document.addEventListener("visibilitychange",f),window.addEventListener("blur",G),document.addEventListener("pointerdown",q,!0),()=>{e.mounted=!1,K?.disconnect(),e.pointerFrame&&cancelAnimationFrame(e.pointerFrame),a.abort(),fe(!1),clearInterval(E),document.removeEventListener("visibilitychange",f),window.removeEventListener("blur",G),document.removeEventListener("pointerdown",q,!0)}},[t]);let de=e=>ot({clientX:e.clientX,clientY:e.clientY,rect:P.current.getBoundingClientRect(),display:h.current.display}),Be=e=>{e.preventDefault();let a=h.current,E=[1,2,3][e.button]||1;e.type==="pointerdown"?(Ae.current?.focus(),P.current?.setPointerCapture(e.pointerId),ce({type:"button",action:"down",button:E,...de(e)})&&a.buttons.add(E)):(ce({type:"button",action:"up",button:E,...de(e)}),a.buttons.delete(E),P.current?.hasPointerCapture(e.pointerId)&&P.current.releasePointerCapture(e.pointerId))},$e=e=>{if(h.current.composition||e.isComposing||e.nativeEvent?.isComposing||e.key==="Process"||e.key==="Unidentified")return;if(lt(e)){e.preventDefault(),m();return}if(ct(e)){e.preventDefault(),e.type==="keydown"&&!e.repeat&&i();return}let a=e.ctrlKey||e.metaKey||e.altKey;if(e.key.length===1&&!a||e.key==="Escape"&&Z.current)return;e.preventDefault();let E=en[e.key]||e.key;/^[A-Za-z0-9_]+$/u.test(E)&&(e.type==="keydown"?!e.repeat&&ce({type:"key",action:"down",key:E})&&h.current.pressed.add(E):(ce({type:"key",action:"up",key:E}),h.current.pressed.delete(E)))},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"}[C],ge={...ue,borderRadius:6,padding:"7px 12px",cursor:"pointer",font:"inherit"},H=["ready","readonly","hidden","reconnecting","dormant","resuming"].includes(C),Ie=I.length>0,ye=ie?.reason||"",Ct=Array.isArray(ie?.candidates)?ie.candidates.length:0,Rt=ye==="needs-create"?"\u8FD8\u6CA1\u6709\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406":ye==="credential-unavailable"?"\u6B63\u5728\u6062\u590D\u4E2A\u4EBA\u52A9\u7406\u7684\u8FDE\u63A5\u51ED\u8BC1":ye==="unavailable"?"\u6682\u65F6\u65E0\u6CD5\u81EA\u52A8\u8FDE\u63A5\u4E2A\u4EBA\u52A9\u7406":"\u4E2A\u4EBA\u52A9\u7406\u5C1A\u672A\u5F00\u901A",Dt=ye==="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":ye==="credential-unavailable"?"\u4E91\u7AEF\u6682\u65F6\u6CA1\u6709\u8FD4\u56DE\u8FDE\u63A5\u51ED\u8BC1\uFF0C\u53EF\u4EE5\u91CD\u65B0\u83B7\u53D6\u3002":ye==="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=C==="unconfigured"?Rt: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",Ot=C==="unconfigured"?Dt: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"?D:"\u8BF7\u7A0D\u5019",je=c==="computer"||c==="native-tab",nt=o("div",{ref:xe,"data-personal-assistant-desktop-card":je?"true":void 0,style:{position:"relative",background:"var(--dsw-alias-bg-layer-2, #f1f3f6)",...je?{width:"100%",aspectRatio:`${h.current.display.width} / ${h.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(C)?o("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,o("canvas",{ref:P,"aria-label":"\u4E91\u7535\u8111\u684C\u9762",tabIndex:H?0:-1,onPointerDown:Be,onPointerUp:Be,onPointerCancel:we,onLostPointerCapture:we,onPointerLeave:()=>{X.current&&(X.current.style.visibility="hidden")},onPointerMove:e=>{let a=h.current,E=e.nativeEvent?.getCoalescedEvents?.().at(-1)||e;if(X.current){let f=P.current.getBoundingClientRect();X.current.style.transform=`translate(${E.clientX-f.left}px, ${E.clientY-f.top}px)`,X.current.style.visibility=a.readOnly?"hidden":"visible"}a.lastPointer=de(E),a.pointerFrame||(a.pointerFrame=requestAnimationFrame(()=>{a.mounted&&Te()}))},onContextMenu:e=>e.preventDefault(),onWheel:e=>{e.preventDefault(),ce({type:"wheel",deltaY:e.deltaY/100,deltaX:e.deltaX/100})},onKeyDown:$e,onKeyUp:$e,style:{...je?{position:"absolute",inset:0}:{},width:"100%",height:"100%",display:"block",visibility:H?"visible":"hidden",pointerEvents:H?"auto":"none",touchAction:"none",cursor:j?"default":"none"}}),o("div",{ref:X,"aria-hidden":!0,style:{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",zIndex:2,width:18,height:22}},o("svg",{viewBox:"0 0 18 22",width:18,height:22},o("path",{d:"M1 1v16l4-4 3 7 3-1-3-7h6z",fill:"#fff",stroke:"#162033",strokeWidth:1.2}))),H?null:o("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,padding:16,textAlign:"center"}},o("h2",{style:{margin:0,fontSize:18,fontWeight:500}},Ie?Ye:Lt),o("p",{style:{margin:0,maxWidth:380,lineHeight:1.7,color:"var(--dsw-alias-label-secondary, #536174)"}},Ie?B||"\u8FDE\u63A5\u540E\u5373\u53EF\u4F7F\u7528\u4E91\u7AEF\u684C\u9762\uFF0C\u5173\u95ED\u9762\u677F\u4F1A\u91CA\u653E\u672C\u6B21\u63A7\u5236\u3002":Ot),!Ie&&C!=="loading"?o("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",alignItems:"center"}},C==="unconfigured"&&ye==="needs-create"?o("button",{style:ge,disabled:!!W,onClick:()=>{U("create")}},W==="create"?"\u6B63\u5728\u521B\u5EFA\u2026":"\u521B\u5EFA\u4E2A\u4EBA\u52A9\u7406"):null,C==="unconfigured"&&(ye==="credential-unavailable"||Ct>0)?o("button",{style:ge,disabled:!!W,onClick:()=>{U("connect")}},W==="connect"?"\u6B63\u5728\u83B7\u53D6\u2026":ye==="credential-unavailable"?"\u91CD\u65B0\u83B7\u53D6\u8FDE\u63A5\u51ED\u8BC1":"\u8FDE\u63A5\u5DF2\u53D1\u73B0\u7684\u4E2A\u4EBA\u52A9\u7406"):null,o("button",{style:{...ge,background:"transparent"},disabled:!!W,onClick:()=>{ee()}},"\u68C0\u67E5\u5F00\u901A\u72B6\u6001"),W?o("span",{role:"status",style:{color:"var(--dsw-alias-label-secondary, #536174)",fontSize:12}},"\u5904\u7406\u4E2D\uFF0C\u8BF7\u7A0D\u5019\u2026"):null):null),o("input",{ref:Ae,"aria-label":"\u4E91\u7535\u8111\u6587\u672C\u8F93\u5165",autoComplete:"off",disabled:!H||j&&!F.current.snapshot.available&&!(h.current.mode==="control"&&["dormant","resuming"].includes(C)),tabIndex:-1,style:{position:"absolute",width:1,height:1,opacity:0,left:0,top:0},onKeyDown:$e,onKeyUp:$e,onCompositionStart:()=>{h.current.composition=!0},onCompositionEnd:e=>{h.current.composition=!1;let a=e.currentTarget.value;e.currentTarget.value="",a&&ce({type:"text",text:a})},onInput:e=>{if(h.current.composition||e.nativeEvent?.isComposing)return;let a=e.currentTarget.value;e.currentTarget.value="",a&&ce({type:"text",text:a})}})),Fe="var(--dsw-alias-label-secondary, #536174)",an={...ge,background:"transparent",color:"inherit",border:ue.border},rt={...ge,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 je?o("section",{"data-personal-assistant-computer":"true",style:{...ue,border:"none",height:"100%",minHeight:0,minWidth:0,display:"flex",flexDirection:"column",background:"var(--dsw-alias-bg-base, #fff)",color:"inherit",fontSize:13}},c!=="native-tab"?o("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:ue.border}},o("strong",{style:{fontWeight:500}},"\u4E91\u7535\u8111"),o("span",{role:"status","aria-live":"polite",style:{color:Fe,fontSize:12}},Ye),null):null,j&&H&&!F.current.snapshot.available?o("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,o("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"}},o("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,H||Ie?o("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:ue.border,boxShadow:"0 1px 4px #10182808",lineHeight:1.5}},!H&&Ie?o("button",{style:rt,disabled:["connecting","resuming"].includes(C),onClick:()=>{x(h.current.handoffSupported?"observe":"read")}},C==="connecting"?"\u6B63\u5728\u542F\u52A8\u2026":"\u91CD\u65B0\u8FDE\u63A5"):null,H&&j?o("span",{style:{color:Fe,fontSize:12}},Oe==="acquiring"?"\u6B63\u5728\u63A5\u7BA1\u2026":Oe==="releasing"?"\u6B63\u5728\u4EA4\u8FD8\u2026":"\u52A9\u7406\u6B63\u5728\u4F7F\u7528 \xB7 \u70B9\u753B\u9762\u5373\u53EF\u63A5\u7BA1"):null,H&&j&&F.current.snapshot.available?o("button",{style:{...rt,padding:"3px 9px",fontSize:11},onClick:()=>F.current.acquire()},"\u63A5\u7BA1"):null,H&&!j?o("span",{style:{color:Fe,fontSize:12}},"\u60A8\u62E5\u6709\u63A7\u5236\u6743 \xB7 \u70B9\u753B\u9762\u5916\u91CA\u653E"):null,H&&B?o("span",{style:{color:Fe,fontSize:12}},B):null,H&&Q?o("span",{role:"status","aria-live":"polite",style:{color:Fe,fontSize:12}},Q):null):null),o("details",{style:{alignSelf:"flex-end",color:"var(--dsw-alias-label-tertiary, #76808e)",fontSize:11,opacity:.8,maxWidth:"100%",overflowWrap:"anywhere"}},o("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),o("small",{"data-personal-assistant-build":Me},`\u6784\u5EFA ${Me}`)))):o("section",{"data-personal-assistant-panel":"true",style:{...ue,border:"none",height:"100%",minHeight:0,display:"flex",flexDirection:"column",fontSize:13}},o("header",{style:{display:"flex",flexWrap:"wrap",gap:8,alignItems:"center",padding:12,borderBottom:ue.border}},o("strong",{style:{fontWeight:500,marginRight:8}},"\u4E2A\u4EBA\u52A9\u7406"),Ie&&["idle","closed","error"].includes(C)?o("button",{style:ge,onClick:()=>{ee()}},"\u5237\u65B0\u52A9\u7406\u5217\u8868"):null,typeof l=="function"?o("button",{style:ge,onClick:l},"\u653E\u5230\u53F3\u4FA7\u680F"):null,Ie?o("button",{style:ge,disabled:["connecting","resuming"].includes(C),onClick:()=>C==="dormant"?T():void x(h.current.handoffSupported?"observe":"control")},C==="dormant"?"\u6062\u590D\u753B\u9762":j&&C==="readonly"?"\u7533\u8BF7\u63A7\u5236":H?"\u91CD\u65B0\u8FDE\u63A5":"\u8FDE\u63A5\u4E91\u7535\u8111"):null,Ie?o("button",{style:ge,disabled:C==="connecting",onClick:()=>{x("read")}},"\u53EA\u8BFB\u65C1\u89C2"):null,H?o("span",{role:"status","aria-live":"polite",style:{marginLeft:"auto",color:"var(--dsw-alias-label-secondary, #536174)"}},Ye):null),C==="readonly"?o("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,H&&B?o("div",{role:"status",style:{padding:"8px 12px"}},B):null,nt,o("footer",{style:{display:"flex",alignItems:"start",justifyContent:"space-between",gap:12,padding:"7px 12px",color:"var(--dsw-alias-label-secondary, #536174)",borderTop:ue.border}},o("details",{open:b,onToggle:e=>ae(e.currentTarget.open)},o("summary",{style:{cursor:"pointer"}},"\u8BCA\u65AD"),M?o("div",{style:{paddingTop:8}},`\u76EE\u5F55\u8FDE\u63A5\u5173\u95ED\u7801\uFF1A${M}`):null,o("div",{style:{paddingTop:8,lineHeight:1.8,overflowWrap:"anywhere"}},o("div",null,`\u4E91\u7AEF\u5B9E\u4F8B\uFF1A${v?.agentId||"\u672A\u5F00\u901A"}`),o("div",null,`\u8FDE\u63A5\u6807\u8BC6\uFF1A${J||"\u672A\u8FDE\u63A5"}`),o("div",null,`\u753B\u9762\u5E27\u7387\uFF1A${ne} fps`),o("div",null,"\u5FEB\u6377\u952E\u4F1A\u8F6C\u53D1\u5230\u4E91\u7535\u8111\uFF1BEsc \u4F18\u5148\u9000\u51FA\u5168\u5C4F"))),o("small",{"data-personal-assistant-build":Me,style:{opacity:.75}},`\u6784\u5EFA ${Me}`)))}function tn({request:t,nativeWorkbench:g}={}){let l=Ee||globalThis.React;if(!l)return"\u4E2A\u4EBA\u52A9\u7406\u9875\u9762\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00";let{createElement:c,useEffect:n,useState:s,useCallback:o}=l,[r,u]=s(null),[d,v]=s(""),[_,I]=s(0);n(()=>{let D=!1;return u(null),v(""),(async()=>{try{let S=await t("personal-assistant.configuration");if(!S.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 $=Je(M.bots,S.botId||M.primaryBotId);D||u({agentId:S.agentId,botId:$})}catch(S){D||v(S.message||"\u4E91\u7AEF\u52A9\u7406\u6682\u4E0D\u53EF\u7528")}})(),()=>{D=!0}},[t,_]);let k=o((D,S={})=>{if(!r)throw new Error("\u4E91\u7AEF\u52A9\u7406\u5C1A\u672A\u8FDE\u63A5");if(S.agentId&&S.agentId!==r.agentId)throw new Error("\u4E91\u7AEF\u5B9E\u4F8B\u4E0D\u4E00\u81F4");if(D!=="personal-assistant.bots.list"&&S.botId&&S.botId!==r.botId)throw new Error("\u4E91\u7AEF\u52A9\u7406\u4E0D\u4E00\u81F4");return t(D,{...S,...r})},[t,r?.agentId,r?.botId]);return n(()=>{r&&g?.available?g.bind(r,k):r&&v(g?.unavailableReason||"\u5F53\u524D\u5BBF\u4E3B\u9700\u8981\u66F4\u65B0\u539F\u751F\u4FA7\u680F\u7EC4\u4EF6")},[g,k,r?.agentId,r?.botId]),r?g?.available?c("div",{key:`${r.agentId}:${r.botId}`,"data-personal-assistant-home":"true","data-agent-id":r.agentId,"data-bot-id":r.botId,style:{flex:"1 1 0px",height:"100%",maxHeight:"100%",minHeight:0,minWidth:0,overflow:"hidden",boxSizing:"border-box",display:"flex",flexDirection:"column"}},c(bt,{React:l,request:k,scope:r,onOpenComputer:()=>g.open()})):c("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"):c("div",{role:"status",style:{padding:24}},d||"\u6B63\u5728\u8FDE\u63A5\u4E91\u7AEF\u4E2A\u4EBA\u52A9\u7406\u2026",d?c("button",{onClick:()=>I(D=>D+1)},"\u91CD\u65B0\u8FDE\u63A5"):null)}var O={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:ue.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:{...ue,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"}};function nn({request:t,openComputer:g=null}={}){let l=Ee||globalThis.React;if(!l)return"\u8BBE\u7F6E\u9875\u5C1A\u672A\u5C31\u7EEA\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00 Studio";let{createElement:c,useEffect:n,useState:s,useCallback:o}=l,[r,u]=s(null),[d,v]=s(null),[_,I]=s(""),[k,D]=s(!1),[S,M]=s(""),$=o(async()=>{D(!0),I("");let C=Date.now();try{let L=await t("personal-assistant.configuration");if(u(L),L?.configured){let B=await t("personal-assistant.bots.list");v(Array.isArray(B?.bots)?B.bots:[])}else v([]);M(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 ${Date.now()-C} ms`)}catch(L){I(L?.message||"\u8FDE\u63A5\u68C0\u67E5\u5931\u8D25"),M(`${new Date().toLocaleTimeString("zh-CN",{hour12:!1})} \xB7 \u5931\u8D25`)}finally{D(!1)}},[t]);n(()=>{$()},[$]);let b=r?.configured===!0,ae=r===null?"\u68C0\u67E5\u4E2D":b?"\u5DF2\u5F00\u901A":"\u5C1A\u672A\u5F00\u901A",J={...O.badge,...r===null?O.badgeIdle:b?O.badgeOk:O.badgeIdle},z=(C,L,B=!1)=>c("div",{style:B?O.rowFirst:O.row},c("div",{style:O.label},C),c("div",{style:O.value},L));return c("section",{"data-personal-assistant-settings":"true",style:O.page},c("div",null,c("h1",{style:O.title},"\u4E2A\u4EBA\u52A9\u7406"),c("p",{style:{...O.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")),_?c("div",{role:"alert",style:{...O.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"}},_):null,c("div",{style:O.card},z("\u72B6\u6001",c("span",null,c("span",{style:J},ae),S?c("span",{style:O.note},`\u3000\u4E0A\u6B21\u68C0\u67E5 ${S}`):null),!0),z("\u4E91\u7AEF\u5B9E\u4F8B",r?.agentId?c("span",{style:O.mono},r.agentId):c("span",{style:O.note},b?"\u672A\u8FD4\u56DE\u5B9E\u4F8B\u6807\u8BC6":"\u5F00\u901A\u540E\u7531 Studio \u7ED1\u5B9A")),z("\u7F51\u5173",r?.gatewayUrl?c("span",{style:O.mono},r.gatewayUrl):c("span",{style:O.note},"\u7531 Studio Host \u914D\u7F6E")),z("\u52A9\u7406\u8FDE\u63A5",c("span",{style:O.note},d===null?"\u68C0\u67E5\u4E2D":d.length?"\u5DF2\u8FDE\u63A5\u4F60\u7684\u52A9\u7406":"\u52A9\u7406\u5C1A\u672A\u5C31\u7EEA")),z("\u8BB0\u5FC6",c("div",null,c("div",{style:O.mono},"/workspace/assistant-state"),c("div",{style:O.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",c("div",null,c("div",null,"\u9ED8\u8BA4\u5F00\u542F\uFF1A\u4E91\u7AEF\u547D\u4EE4\u6267\u884C\u3001\u4E91\u7AEF\u6D4F\u89C8\u5668"),c("div",{style:O.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",c("span",{style:O.note},`\u6784\u5EFA ${Me}`))),c("div",{style:O.actions},c("button",{style:O.button,disabled:k,onClick:()=>{$()}},k?"\u6B63\u5728\u68C0\u67E5\u2026":"\u68C0\u67E5\u8FDE\u63A5"),c("span",{style:O.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 rn({size:t}={}){let g=Ee,l=Number(t)>0?Number(t):16;return g?.createElement?g.createElement("svg",{width:l,height:l,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 on({size:t}={}){let g=Ee,l=Number(t)>0?Number(t):16;return g?.createElement?g.createElement("svg",{width:l,height:l,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 sn(){let t=Ee,g=on({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(s,o={})=>{if(!t.connection?.rpc?.call)throw new et;let r=await t.connection.rpc.call("/api","personal-assistant",{operation:s,payload:o});if(!r?.ok)throw Object.assign(new Error(r?.error?.message||"Studio Host \u8BF7\u6C42\u5931\u8D25"),{code:r?.error?.code,status:r?.error?.details?.status,closeCode:r?.error?.details?.closeCode});return r.value},l=(s,o)=>{try{let r=()=>s();return typeof t.effect=="function"?t.effect(r,o):r()}catch(r){try{console.warn(`[personal-assistant] ${o} \u6CE8\u518C\u5931\u8D25`,r)}catch{}return}},c=wt({sidebarRight:t.sidebarRight,slots:t.slots});c&&(c.render=s=>It({...s,React:Ee||globalThis.React,workbench:c,Panel:Tt}),l(()=>()=>c.dispose(),"personal-assistant: native workbench")),l(()=>t.slots.inject("main",()=>t.slots.register({name:"main",key:Ze,inject:()=>({request:g,nativeWorkbench:c})},tn)),"personal-assistant: main panel"),l(()=>t.slots.inject("sidebar.panellist",()=>t.slots.register({name:"sidebar.panellist",id:Ze,order:90,label:"\u4E2A\u4EBA\u52A9\u7406"},rn)),"personal-assistant: sidebar row"),l(()=>t.slots.inject("settings.section",()=>t.slots.register({name:"settings.section",id:`${Ze}-settings`,order:196,label:"\u4E2A\u4EBA\u52A9\u7406",inject:()=>({request:g})},nn)),"personal-assistant: settings section"),typeof t.inject=="function"&&l(()=>t.inject(["sidebarRightTabs"],s=>{let o=[],r=u=>{typeof u=="function"&&o.push(u)};try{let u=s.sidebarRightTabs;if(u===void 0||typeof u.register!="function")return;r(u.register({id:He,kind:He,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"}]})),r(s.slots.inject("sidebar.right.pane.tab",()=>s.slots.register({name:"sidebar.right.pane.tab",key:He,inject:()=>({request:g})},d=>Tt({...d,variant:"computer"})))),r(s.slots.inject("sidebar.right.pane.tab.title",()=>s.slots.register({name:"sidebar.right.pane.tab.title",key:He},sn)))}catch(u){try{console.warn("[personal-assistant] \u53F3\u4FA7\u680F\u6CE8\u518C\u5931\u8D25",u)}catch{}}return()=>{for(let u of o.reverse())u()}}),"personal-assistant: right tab")}window.__ModuleLoader__.load({id:"@kingsoftcloud/agentkit-personal-assistant",factory:t=>(At(t("react")),{name:"agentkit-personal-assistant",inject:kt,apply:_t})});})();
package/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@kingsoftcloud/agentkit-personal-assistant",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.7",
4
+ "description": "Standalone personal assistant DSH plugin with multi-Bot profiles and an explicit Cloud Computer Broker boundary.",
5
+ "homepage": "https://github.com/kingsoftcloud/agentkit-personal-assistant",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/kingsoftcloud/agentkit-personal-assistant.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/kingsoftcloud/agentkit-personal-assistant/issues"
12
+ },
13
+ "license": "Apache-2.0",
14
+ "type": "module",
15
+ "engines": {
16
+ "node": "^22.23.4 || >=24.22.1",
17
+ "dsh": "0.2.1-rc.2"
18
+ },
19
+ "exports": {
20
+ ".": "./src/index.mjs",
21
+ "./client": "./dist/client.js",
22
+ "./manifest": "./personal-assistant.plugin.json",
23
+ "./bot-registry": "./src/bot-registry.mjs",
24
+ "./computer-broker": "./src/computer-broker.mjs",
25
+ "./computer-broker-protocol": "./src/computer-broker-protocol.mjs",
26
+ "./plugin-manifest": "./src/plugin-manifest.mjs",
27
+ "./cloud-computer-tools": "./src/cloud-computer-tools.mjs",
28
+ "./schedule-manager": "./src/schedule-manager.mjs",
29
+ "./persistent-state": "./src/persistent-state.mjs",
30
+ "./workspace": "./src/workspace.mjs",
31
+ "./implementation-capabilities": "./src/implementation-capabilities.mjs",
32
+ "./dsh-session-bridge": "./src/dsh-session-bridge.mjs"
33
+ },
34
+ "files": [
35
+ "src",
36
+ "runtime",
37
+ "scripts",
38
+ "personal-assistant.plugin.json",
39
+ "cordis.patch.yml",
40
+ "README.md",
41
+ "LICENSE",
42
+ "NOTICE",
43
+ "personal-assistant.plugin.schema.json",
44
+ "dist/client.js"
45
+ ],
46
+ "scripts": {
47
+ "test": "node --test test/*.test.mjs",
48
+ "check": "node --check src/index.mjs && node --check src/bot-registry.mjs && node --check src/computer-broker-protocol.mjs && node --check src/computer-broker.mjs && node --check src/client/index.mjs && npm test && node --check src/cloud-computer-tools.mjs && node --check src/dsh-session-bridge.mjs && node --check src/implementation-capabilities.mjs && node --check src/persistent-state.mjs && node --check src/schedule-manager.mjs && node --check src/workspace.mjs && node --check runtime/assistant-runtime.mjs && node --check runtime/computer-agentd.mjs && node --check src/host-gateway.mjs && node --check src/host-session-channel.mjs && node --check src/system-fetch.mjs && node --check src/client/markdown.mjs && node --check src/client/conversation.mjs && node --check src/client/desktop-view.mjs",
49
+ "pack:check": "npm pack --dry-run",
50
+ "build:artifacts": "node scripts/build-artifacts.mjs",
51
+ "build:client": "node scripts/build-client.mjs",
52
+ "dev:client": "node scripts/build-client.mjs --watch",
53
+ "prepack": "npm run build:client",
54
+ "publish:check": "node --check src/index.mjs && npm test && npm pack --dry-run"
55
+ },
56
+ "peerDependencies": {
57
+ "@deepseek-ai/cordis": "^4.0.5"
58
+ },
59
+ "dsh": {
60
+ "client": {
61
+ "platform": "web",
62
+ "inject": [
63
+ "@deepseek-ai/dsh-client-connection",
64
+ "@deepseek-ai/dsh-client-ui-renderer",
65
+ "@deepseek-ai/dsh-client-ui-sidebar-right",
66
+ "@deepseek-ai/dsh-client-ui-sidebar",
67
+ "@deepseek-ai/dsh-client-ui-layout"
68
+ ],
69
+ "external": [
70
+ "@deepseek-ai/dsh-client-connection"
71
+ ]
72
+ },
73
+ "bundle": {
74
+ "patch": "./cordis.patch.yml"
75
+ }
76
+ },
77
+ "main": "./src/index.mjs",
78
+ "devDependencies": {
79
+ "esbuild": "0.27.7"
80
+ },
81
+ "publishConfig": {
82
+ "access": "public",
83
+ "registry": "https://registry.npmjs.org/"
84
+ }
85
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "./personal-assistant.plugin.schema.json",
3
+ "format": "agentkit-personal-assistant.plugin/v1",
4
+ "pluginId": "@kingsoftcloud/agentkit-personal-assistant",
5
+ "version": "0.1.2-desktop.20261026",
6
+ "compatibility": {
7
+ "requiredDsh": "0.2.1-rc.2",
8
+ "requiredHostApi": "dsh-native/0.2.1-rc.2",
9
+ "requiredHostContract": 1
10
+ },
11
+ "metadata": {
12
+ "defaultEnabled": false,
13
+ "autoConnect": false,
14
+ "capabilities": [
15
+ "personal-assistant.bots",
16
+ "personal-assistant.sessions",
17
+ "personal-assistant.memory",
18
+ "personal-assistant.computer-broker"
19
+ ],
20
+ "contributes": [
21
+ "route",
22
+ "resource",
23
+ "command",
24
+ "settings"
25
+ ],
26
+ "entrypoints": {
27
+ "host": ".",
28
+ "client": "./client"
29
+ }
30
+ }
31
+ }