Просмотр исходного кода

发布 v0.4.4:独立桌面接管、数据迁移与开放许可

Samien 2 месяцев назад
Родитель
Сommit
2d1aefcf15
100 измененных файлов с 1325 добавлено и 262 удалено
  1. 2 2
      .env.example
  2. 1 0
      .gitignore
  3. 4 2
      Dockerfile
  4. 188 44
      LICENSE
  5. 6 0
      NOTICE
  6. 8 8
      README.md
  7. 6 0
      bin/desktop-service-sync.mjs
  8. 8 4
      bin/hermes-yaoyao.mjs
  9. 4 0
      bin/lib/data-home.d.mts
  10. 24 0
      bin/lib/data-home.mjs
  11. 2 0
      bin/lib/data-migration.d.mts
  12. 107 0
      bin/lib/data-migration.mjs
  13. 45 0
      bin/lib/managed-data-migration.mjs
  14. 4 3
      bin/lib/release-source.mjs
  15. 20 0
      bin/migrate-data-home.mjs
  16. 4 4
      compose.desktops.yaml
  17. 4 4
      compose.yaml
  18. 54 0
      desktop/browser-environment.mjs
  19. 41 0
      desktop/browser-environment.test.mjs
  20. 95 0
      desktop/computer-helper.swift
  21. 42 0
      desktop/computer-viewer.mjs
  22. 42 0
      desktop/computer-viewer.test.mjs
  23. 13 1
      desktop/credentials.mjs
  24. 2 0
      desktop/data-home.mjs
  25. 45 0
      desktop/environment-host.mjs
  26. 20 8
      desktop/main.mjs
  27. 2 1
      desktop/preferences.mjs
  28. 7 0
      desktop/preload.cjs
  29. 1 0
      desktop/service-manager.mjs
  30. 1 0
      desktop/service-sync.mjs
  31. 3 3
      desktop/update-manager.test.mjs
  32. 3 3
      desktop/update-window.test.mjs
  33. 2 2
      docker.env.example
  34. 2 2
      docs/agent-install.md
  35. 2 2
      docs/chat-working-directory.md
  36. 1 1
      docs/computer-maintenance.md
  37. 3 3
      docs/docker-install.md
  38. 6 2
      docs/github-updates.md
  39. 4 4
      docs/macos-app.md
  40. 25 0
      docs/releases/v0.4.4.md
  41. 33 0
      docs/verification/2026-09-10-bot-environments/README.md
  42. BIN
      docs/verification/2026-09-10-bot-environments/desktop-browser.png
  43. BIN
      docs/verification/2026-09-10-bot-environments/ios-permissions.png
  44. BIN
      docs/verification/2026-09-10-bot-environments/phone-browser.png
  45. 29 0
      docs/verification/2026-09-10-bot-panels/README.md
  46. BIN
      docs/verification/2026-09-10-bot-panels/desktop-computer.png
  47. BIN
      docs/verification/2026-09-10-bot-panels/desktop-inspector.png
  48. BIN
      docs/verification/2026-09-10-bot-panels/desktop-routine-logs.png
  49. BIN
      docs/verification/2026-09-10-bot-panels/desktop-routines.png
  50. BIN
      docs/verification/2026-09-10-bot-panels/phone-group-inspector.png
  51. 23 0
      docs/verification/2026-09-10-grok-auth/README.md
  52. BIN
      docs/verification/2026-09-10-grok-auth/desktop-authorized.png
  53. BIN
      docs/verification/2026-09-10-grok-auth/desktop-waiting.png
  54. BIN
      docs/verification/2026-09-10-grok-auth/phone-authorized.png
  55. 8 0
      docs/verification/2026-09-10-v044/README.md
  56. BIN
      docs/verification/2026-09-10-v044/computer-takeover.png
  57. 1 0
      electron-builder.yml
  58. 1 1
      index.html
  59. 6 5
      package-lock.json
  60. 12 6
      package.json
  61. 7 0
      playwright.bot-panels.config.ts
  62. 7 0
      playwright.grok-auth.config.ts
  63. 2 0
      playwright.native-environment.config.ts
  64. 1 1
      public/manifest.webmanifest
  65. 3 3
      release.json
  66. 9 5
      scripts/build-desktop.mjs
  67. 1 1
      scripts/generate-desktop-compose.mjs
  68. 2 2
      src/client/App.vue
  69. 2 2
      src/client/api/profiles.ts
  70. 1 1
      src/client/components/app/AccountSecurityPanel.vue
  71. 2 2
      src/client/components/app/AgentIdentityDialog.vue
  72. 1 1
      src/client/components/app/AgentIdentityFixture.vue
  73. 1 1
      src/client/components/app/AgentIdentityPanel.vue
  74. 1 1
      src/client/components/app/DuplexVoicePanel.vue
  75. 10 9
      src/client/components/app/LocalVmSettingsPanel.vue
  76. 3 3
      src/client/components/app/ModelServicesPanel.vue
  77. 2 2
      src/client/components/app/RunnerSettingsPanel.vue
  78. 1 1
      src/client/components/app/ServerIdentityPanel.vue
  79. 5 5
      src/client/components/app/SettingsCenterDialog.vue
  80. 3 3
      src/client/components/app/SystemManagementPanel.vue
  81. 1 1
      src/client/components/app/SystemOverviewPanel.vue
  82. 12 12
      src/client/components/app/WorkspaceShell.vue
  83. 5 1
      src/client/components/common/AppIcon.vue
  84. 1 1
      src/client/components/common/BrandMark.vue
  85. 2 2
      src/client/components/composer/ComposerShell.vue
  86. 8 8
      src/client/components/groups/CreateGroupDialog.vue
  87. 11 11
      src/client/components/groups/GroupManager.vue
  88. 2 2
      src/client/components/groups/TopicTeamPickerDialog.vue
  89. 2 2
      src/client/components/kanban/KanbanTaskDrawer.vue
  90. 4 4
      src/client/components/kanban/presentation.ts
  91. 1 1
      src/client/components/messages/MessageTimeline.vue
  92. 29 0
      src/client/components/workspace/BrowserToolbar.vue
  93. 50 27
      src/client/components/workspace/ComputerPanel.vue
  94. 1 1
      src/client/components/workspace/ConversationList.vue
  95. 59 0
      src/client/components/workspace/GrokAuthPanel.vue
  96. 74 22
      src/client/components/workspace/LocalVmChatPanel.vue
  97. 3 3
      src/client/components/workspace/LocalVmWorkspace.vue
  98. 3 3
      src/client/components/workspace/RemoteAgentPicker.vue
  99. 3 3
      src/client/components/workspace/TeamPresetPicker.vue
  100. 24 0
      src/client/components/workspace/WorkspaceBotPanel.vue

+ 2 - 2
.env.example

@@ -12,7 +12,7 @@ HERMES_YAOYAO_SUPERVISE_DASHBOARD=0
 HERMES_YAOYAO_CHAT_CACHE_MODE=prefer-local
 # HERMES_YAOYAO_TLS_CERT=/absolute/path/to/cert.pem
 # HERMES_YAOYAO_TLS_KEY=/absolute/path/to/key.pem
-# HERMES_YAOYAO_HOME=/Users/you/.hermes-yaoyao
+# YAOYAO_HOME=/Users/you/.yaoyao
 # iOS 后台通知使用 APNs Token Key。四项中前三项必须同时配置,.p8 不得放入仓库。
 # 任一 APNs 环境变量存在时,系统管理中的本地路径配置为只读;全部留空才可由 Web 管理。
 # HERMES_YAOYAO_APNS_KEY_FILE=/absolute/path/to/AuthKey_XXXXXXXXXX.p8
@@ -25,7 +25,7 @@ HERMES_YAOYAO_CHAT_CACHE_MODE=prefer-local
 # HERMES_YAOYAO_FCM_PROJECT_ID=your-firebase-project-id
 # HERMES_YAOYAO_FCM_PACKAGE_NAME=cn.samien.yaoyao.hermes
 # 固定 Git 发布源。系统更新只接受这里发现的 vX.Y.Z 标签,不接受浏览器指定仓库。
-# HERMES_YAOYAO_RELEASE_SOURCE=https://git.samien.cn/samien/hermes-yaoyao.git
+# HERMES_YAOYAO_RELEASE_SOURCE=https://github.com/Lsamien/yaoyao.git
 # HERMES_YAOYAO_RELEASE_ROOT=/Users/you/.local/share/hermes-yaoyao
 # 系统更新默认仅允许从本机浏览器触发;可信网络确有需要时才显式开启。
 # HERMES_YAOYAO_ALLOW_REMOTE_UPDATE=0

+ 1 - 0
.gitignore

@@ -14,6 +14,7 @@ docker.env
 *.key
 hermes-yaoyao-*.tar
 .hermes-yaoyao/
+.yaoyao/
 .codegraph/
 .desktop-build/
 desktop-release/

+ 4 - 2
Dockerfile

@@ -27,16 +27,18 @@ FROM node:24-bookworm-slim AS runtime
 ENV NODE_ENV=production \
     HERMES_YAOYAO_HOST=0.0.0.0 \
     HERMES_YAOYAO_PORT=15300 \
-    HERMES_YAOYAO_HOME=/var/lib/hermes-yaoyao \
+    HERMES_YAOYAO_HOME=/home/node/.yaoyao \
     HERMES_YAOYAO_CHAT_CACHE_MODE=prefer-local \
     HERMES_YAOYAO_SUPERVISE_DASHBOARD=0 \
     HERMES_YAOYAO_LOCAL_VM_HOST=runner
 
 WORKDIR /app
 
-RUN install -d -o node -g node -m 0700 /var/lib/hermes-yaoyao
+RUN install -d -o node -g node -m 0700 /home/node/.yaoyao
 
 COPY --chown=node:node package.json package-lock.json release.json ./
+COPY --chown=node:node LICENSE NOTICE THIRD_PARTY_NOTICES.md ./
+COPY --chown=node:node licenses ./licenses
 COPY --chown=node:node --from=builder /app/node_modules ./node_modules
 COPY --chown=node:node --from=builder /app/dist ./dist
 COPY --chown=node:node --from=builder /app/dist-server ./dist-server

+ 188 - 44
LICENSE

@@ -1,58 +1,202 @@
-Business Source License 1.1
 
-Parameters
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
 
-Licensor:             EKKOLearnAI
-Licensed Work:        Hermes Studio, formerly known as Hermes Web UI,
-                      including the hermes-web-ui npm package and CLI,
-                      Hermes Studio desktop applications, web applications,
-                      server components, runtime integrations, firmware,
-                      release artifacts, documentation, and all associated
-                      files in this repository.
-Additional Use Grant: You may use the Licensed Work for non-commercial purposes,
-                      including personal use, education, and research.
-                      Commercial use (including but not limited to selling,
-                      licensing, SaaS hosting, or embedding in a commercial
-                      product) requires a separate commercial license from the
-                      Licensor.
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 
-Change Date:          2029-05-10
+   1. Definitions.
 
-Change License:       Apache License 2.0
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
 
-Notice
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
 
-The Licensed Work is provided under the Business Source License 1.1 (BSL 1.1).
-You may not use the Licensed Work except in compliance with the License.
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
 
-You may obtain a copy of the License at
-https://mariadb.com/bsl11/
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
 
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
 
----
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
 
-For the purposes of this License:
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
 
-- "Licensed Work" refers to Hermes Studio and all source code,
-  documentation, firmware, desktop applications, web applications, server
-  components, runtime integrations, release artifacts, packages, command-line
-  tools, and associated files in this repository. This includes materials
-  distributed or identified under the current Hermes Studio name, the former
-  Hermes Web UI name, the hermes-web-ui npm package name, and the
-  hermes-studio desktop application name.
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
 
-- "Non-commercial use" means use that is not primarily intended for or
-  directed toward commercial advantage or monetary compensation.
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
 
-- The Licensor (EKKOLearnAI) and its authorized representatives are not
-  subject to the Additional Use Grant restrictions and may use the Licensed
-  Work for any purpose, including commercial purposes, without limitation.
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
 
-On the Change Date (2029-05-10), this License will automatically convert to
-the Apache License 2.0, at which point all users may use the Licensed Work
-under the terms of the Apache License 2.0.
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

+ 6 - 0
NOTICE

@@ -0,0 +1,6 @@
+夭夭 AI
+Copyright 2026 Lsamien and Yaoyao contributors
+
+Licensed under the Apache License, Version 2.0.
+Third-party components retain their own licenses and copyright notices.
+See THIRD_PARTY_NOTICES.md and licenses/.

+ 8 - 8
README.md

@@ -1,8 +1,8 @@
-# 夭夭 Web
+# 夭夭 AI
 
-当前 Web 与 macOS 桌面发布版本:**v0.4.3**。桌面版提供 Apple Silicon(arm64)DMG,详见 [发布说明](docs/releases/v0.4.3.md)。
+当前 Web 与 macOS 桌面发布版本:**v0.4.4**。桌面版提供 Apple Silicon(arm64)DMG,详见 [发布说明](docs/releases/v0.4.4.md)。
 
-夭夭 Web 为网页、iOS 和安卓提供统一的 Agent、群聊、文件库及语音配置服务。Hermes 通过标准 9119 HTTP/WebSocket 接口执行任务。
+夭夭 AI 为网页、iOS 和安卓提供统一的 Agent、群聊、文件库及语音配置服务。Hermes 通过标准 9119 HTTP/WebSocket 接口执行任务。
 
 ## 聊天与 Agent
 
@@ -30,13 +30,13 @@ npm start
 HERMES_YAOYAO_UPSTREAM=http://服务器:9119 npm start
 ```
 
-Web 数据默认保存在 `~/.hermes-yaoyao`,可用 `HERMES_YAOYAO_HOME` 指定。备份应包含整个数据目录及加密密钥。
+Web 数据默认保存在 `~/.yaoyao`,可用 `YAOYAO_HOME` 指定(兼容 `HERMES_YAOYAO_HOME`)。旧默认目录 `~/.hermes-yaoyao` 会在服务空闲并停止后整体迁移至 `~/.yaoyao`,保留账号、会话、文件和密钥;两目录同时有数据时停止迁移,避免覆盖。备份应包含整个数据目录及加密密钥。
 
 由 Web 或 iOS 创建的普通聊天会按登录用户、Profile 和 Session ID 在 `chat-cache.sqlite3` 中登记所有权并持久化;后续续聊与列表展示以这份服务端登记为准,不再单独依赖 Hermes 的 `source` 标记。Web 的只读历史记录不进入该数据库,继续按需读取 9119。可通过 `HERMES_YAOYAO_CHAT_CACHE_MODE=upstream-only|shadow|prefer-local` 切换策略,默认 `prefer-local`。
 
 ## macOS 桌面版
 
-在 [v0.4.3 发布页](https://github.com/Lsamien/hermes-yaoyao/releases/tag/v0.4.3) 下载 `Yaoyao-0.4.3-arm64.dmg`,将“夭夭”拖到应用程序后打开。首次启动会核对并同步配套本机 Web 服务;普通退出保留后台运行,“停止后台服务并退出”可完整停止本应用管理的后台。详细说明见 [macOS App](docs/macos-app.md)。
+在 [v0.4.4 发布页](https://github.com/Lsamien/yaoyao/releases/tag/v0.4.4) 下载 `Yaoyao-0.4.4-arm64.dmg`,将“夭夭”拖到应用程序后打开。首次启动会核对并同步配套本机 Web 服务;普通退出保留后台运行,“停止后台服务并退出”可完整停止本应用管理的后台。详细说明见 [macOS App](docs/macos-app.md)。
 
 此 DMG 使用 Apple Development 开发签名,未做 Apple 公证。
 
@@ -51,7 +51,7 @@ docker compose --env-file docker.env config --quiet
 docker compose --env-file docker.env up -d --build
 ```
 
-默认访问 `http://127.0.0.1:15300`。应用数据保存在 `yaoyao-data` 命名卷,容器内路径为 `/var/lib/hermes-yaoyao`。首次打开页面创建管理员账号,并在系统设置中配置 Hermes 连接。
+默认访问 `http://127.0.0.1:15300`。应用数据保存在 `yaoyao-data` 命名卷,容器内路径为 `/home/node/.yaoyao`。首次打开页面创建管理员账号,并在系统设置中配置 Hermes 连接。
 
 宿主机连接、局域网访问、验证及升级步骤见 [Docker 部署说明](docs/docker-install.md)。
 
@@ -61,7 +61,7 @@ iOS 统一连接 Web 地址,通过设置中的手机登录二维码或账号
 
 ## 数据与升级
 
-Web 默认从 [GitHub Releases](https://github.com/Lsamien/hermes-yaoyao/releases) 检查稳定版本;桌面菜单“检查 App 更新…”可下载并校验 DMG 后手动安装。旧官方发布源会自动归一化为 GitHub,自定义仓库保留。详见 [GitHub 版本升级](docs/github-updates.md)。
+Web 默认从 [GitHub Releases](https://github.com/Lsamien/yaoyao/releases) 检查稳定版本;桌面菜单“检查 App 更新…”可下载并校验 DMG 后手动安装。旧官方发布源会自动归一化为 GitHub,自定义仓库保留。详见 [GitHub 版本升级](docs/github-updates.md)。
 
 发布版本由 `release.json` 记录。macOS 本机服务支持在系统设置中升级 Web 或回滚到上一个版本;其他源码部署更新代码、重新构建并重启服务,Docker 部署通过重新构建镜像并重建容器更新。升级前备份 Web 数据目录,客户端版本要求见对应发布说明。
 
@@ -77,4 +77,4 @@ npm run build
 
 ## 许可证
 
-BSL-1.1,详见仓库 LICENSE。
+Apache-2.0,详见 [LICENSE](LICENSE)。第三方组件保留各自许可与署名,见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md)。

+ 6 - 0
bin/desktop-service-sync.mjs

@@ -3,6 +3,7 @@ import { homedir } from 'node:os'
 import { createHash } from 'node:crypto'
 import { mkdirSync } from 'node:fs'
 import { LaunchAgentService, synchronizeDesktop, stopDesktopService } from './lib/service-update.mjs'
+import { migrateManagedDataHome } from './lib/managed-data-migration.mjs'
 
 // Losing the App's progress pipe must not interrupt a durable service transaction.
 process.stdout.on('error', error => { if (!['EPIPE', 'EIO'].includes(error.code)) process.exitCode = 1 })
@@ -13,6 +14,11 @@ try {
   const options = JSON.parse(input)
   const home = resolve(options.home), port = Number(options.port)
   if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error('本机服务端口无效')
+  if (options.action === 'migrate') {
+    if (!options.fixture) await migrateManagedDataHome({ home, port, onProgress: message => process.stdout.write(JSON.stringify({ message }) + '\n') })
+    process.stdout.write(JSON.stringify({ result: { action: 'migrated' } }) + '\n')
+    process.exit(0)
+  }
   mkdirSync(home, { recursive: true, mode: 0o700 })
   // Fixture mode isolates *all* service/update state, including launchd labels.
   const fixture = options.fixture === true

+ 8 - 4
bin/hermes-yaoyao.mjs

@@ -8,6 +8,8 @@ import { dirname, join, resolve } from 'node:path'
 import { setTimeout as delay } from 'node:timers/promises'
 import { fileURLToPath } from 'node:url'
 import { normalizeReleaseSource } from './lib/release-source.mjs'
+import { resolveDataHome } from './lib/data-home.mjs'
+import { migrateDataHome } from './lib/data-migration.mjs'
 
 const label = 'com.samien.hermes-yaoyao'
 const sourceProjectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
@@ -16,7 +18,7 @@ const uid = process.getuid?.() ?? 501
 const domain = `gui/${uid}`
 const launchAgents = join(homedir(), 'Library', 'LaunchAgents')
 const plistPath = join(launchAgents, `${label}.plist`)
-const dataHome = process.env.HERMES_YAOYAO_HOME || join(homedir(), '.hermes-yaoyao')
+const dataHome = resolveDataHome(process.env.YAOYAO_HOME || process.env.HERMES_YAOYAO_HOME)
 const logDir = join(homedir(), 'Library', 'Logs')
 const serverEntry = join(serviceRoot, 'dist-server', 'server', 'index.js')
 
@@ -70,11 +72,12 @@ export function launchAgentPlist(options = {}) {
   const envEntries = {
     PATH: `${dirname(node)}:${join(homedir(), '.local', 'bin')}:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`,
     NODE_ENV: 'production',
-    HERMES_YAOYAO_HOME: dataHome,
     HERMES_YAOYAO_PORT: '15300',
     HERMES_YAOYAO_UPSTREAM: 'http://127.0.0.1:9119',
     HERMES_YAOYAO_SUPERVISE_DASHBOARD: '1',
     ...environment(options.environment),
+    HERMES_YAOYAO_HOME: resolveDataHome(options.environment?.YAOYAO_HOME || options.environment?.HERMES_YAOYAO_HOME || dataHome),
+    YAOYAO_HOME: resolveDataHome(options.environment?.YAOYAO_HOME || options.environment?.HERMES_YAOYAO_HOME || dataHome),
     HERMES_YAOYAO_HOST: '0.0.0.0',
     HERMES_YAOYAO_ALLOW_INSECURE_LAN: '1',
   }
@@ -153,9 +156,10 @@ async function install() {
     throw new Error('未找到生产构建,请先运行 npm run build')
   }
   await mkdir(launchAgents, { recursive: true })
-  await mkdir(dataHome, { recursive: true, mode: 0o700 })
   await mkdir(logDir, { recursive: true })
   if (loaded()) run('launchctl', ['bootout', `${domain}/${label}`])
+  migrateDataHome(dataHome)
+  await mkdir(dataHome, { recursive: true, mode: 0o700 })
   await writeFile(plistPath, launchAgentPlist(), { mode: 0o600 })
   await chmod(plistPath, 0o600)
   run('plutil', ['-lint', plistPath], { inherit: true })
@@ -222,7 +226,7 @@ async function main() {
     if (command === 'uninstall') return uninstall()
   }
   if (group === 'uploads' && command === 'prune') return pruneUploads(args)
-  process.stdout.write(`夭夭 Web\n\n用法:\n  hermes-yaoyao service install|start|stop|status|uninstall\n  hermes-yaoyao uploads prune --older-than 30 --yes\n`)
+  process.stdout.write(`夭夭 AI\n\n用法:\n  yaoyao service install|start|stop|status|uninstall\n  yaoyao uploads prune --older-than 30 --yes\n`)
 }
 
 export function isMainModule(entry = process.argv[1]) {

+ 4 - 0
bin/lib/data-home.d.mts

@@ -0,0 +1,4 @@
+export function legacyDataHome(userHome?: string): string
+export function defaultDataHome(userHome?: string): string
+export function legacyUpdateActive(userHome?: string): boolean
+export function resolveDataHome(value?: string, options?: {userHome?: string; preserveActiveUpdate?: boolean}): string

+ 24 - 0
bin/lib/data-home.mjs

@@ -0,0 +1,24 @@
+import { existsSync, readFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join, resolve } from 'node:path'
+
+export const legacyDataHome = (userHome = homedir()) => join(userHome, '.hermes-yaoyao')
+export const defaultDataHome = (userHome = homedir()) => join(userHome, '.yaoyao')
+export function legacyUpdateActive(userHome = homedir()) {
+  const old = legacyDataHome(userHome)
+  try {
+    const { pid } = JSON.parse(readFileSync(join(old, 'updates', 'active.lock'), 'utf8'))
+    if (Number.isSafeInteger(pid) && pid > 0) {
+      try { process.kill(pid, 0); return true } catch (error) { if (error.code !== 'ESRCH') return true }
+    }
+  } catch { /* No active updater. */ }
+  return existsSync(join(old, 'updates', 'transition.json'))
+}
+/** Preserve explicit custom directories. Old official defaults migrate together. */
+export function resolveDataHome(value, { userHome = homedir(), preserveActiveUpdate = false } = {}) {
+  const requested = resolve(value?.trim() || defaultDataHome(userHome))
+  if (![legacyDataHome(userHome), defaultDataHome(userHome)].includes(requested)) return requested
+  // An old updater must finish its transaction against the original directory.
+  if (preserveActiveUpdate && legacyUpdateActive(userHome)) return legacyDataHome(userHome)
+  return defaultDataHome(userHome)
+}

+ 2 - 0
bin/lib/data-migration.d.mts

@@ -0,0 +1,2 @@
+export function migrateDataHome(home: string, options?: {userHome?: string}): boolean
+export function rebaseDataPath(value: unknown, old: string, home: string): unknown

+ 107 - 0
bin/lib/data-migration.mjs

@@ -0,0 +1,107 @@
+import { existsSync, lstatSync, readFileSync, readdirSync, renameSync, rmdirSync, writeFileSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join, resolve } from 'node:path'
+import { DatabaseSync } from 'node:sqlite'
+import { defaultDataHome, legacyDataHome, legacyUpdateActive } from './data-home.mjs'
+
+const markerName = '.data-home-migration.json'
+const read = file => JSON.parse(readFileSync(file, 'utf8'))
+function write(file, value) {
+  const temporary = file + '.tmp'
+  writeFileSync(temporary, JSON.stringify(value, null, 2) + '\n', { mode: 0o600 })
+  renameSync(temporary, file)
+}
+export function rebaseDataPath(value, old, home) {
+  return typeof value === 'string' && (value === old || value.startsWith(old + '/')) ? home + value.slice(old.length) : value
+}
+/** Only storage paths are rebased; conversation text and external paths stay intact. */
+function rebaseDatabasePaths(home, old) {
+  for (const [name, table, columns] of [
+    ['uploads.sqlite3', 'uploads', ['path']],
+    ['chat-cache.sqlite3', 'chat_attachments', ['local_path', 'source_path']],
+  ]) {
+    const file = join(home, name)
+    if (!existsSync(file)) continue
+    const db = new DatabaseSync(file)
+    try {
+      if (!db.prepare('SELECT 1 FROM sqlite_master WHERE type=\'table\' AND name=?').get(table)) continue
+      const fields = new Set(db.prepare(`PRAGMA table_info("${table}")`).all().map(row => row.name))
+      db.exec('BEGIN IMMEDIATE')
+      for (const column of columns) if (fields.has(column)) {
+        db.prepare(`UPDATE "${table}" SET "${column}"=? || substr("${column}",?) WHERE "${column}"=? OR substr("${column}",1,?)=?`)
+          .run(home, old.length + 1, old, old.length + 1, old + '/')
+      }
+      db.exec('COMMIT; PRAGMA wal_checkpoint(TRUNCATE)')
+    } finally { db.close() }
+  }
+  const rebase = value => typeof value === 'string' ? rebaseDataPath(value, old, home)
+    : Array.isArray(value) ? value.map(rebase)
+    : value && typeof value === 'object' ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, rebase(item)])) : value
+  // Durable update/notification configuration stores absolute paths as well.
+  for (const name of ['updates', 'push']) {
+    const directory = join(home, name)
+    if (!existsSync(directory)) continue
+    for (const entry of readdirSync(directory, { withFileTypes: true })) {
+      if (!entry.isFile() || !entry.name.endsWith('.json')) continue
+      const file = join(directory, entry.name), value = read(file), next = rebase(value)
+      if (JSON.stringify(value) !== JSON.stringify(next)) write(file, next)
+    }
+  }
+}
+export function migrateDataHome(home, { userHome = homedir() } = {}) {
+  home = resolve(home)
+  const old = legacyDataHome(userHome)
+  if (home !== defaultDataHome(userHome)) return false
+  const marker = join(home, markerName)
+  if (!existsSync(old)) {
+    if (existsSync(marker) && read(marker).phase === 'moving') {
+      const record = read(marker)
+      if (record.source !== old || record.target !== home) throw new Error('数据目录迁移记录不匹配')
+      rebaseDatabasePaths(home, old)
+      write(marker, { ...record, phase: 'complete' })
+    }
+    if (process.platform === 'linux' && home === '/home/node/.yaoyao' && existsSync(home)) {
+      const lock = new DatabaseSync(join(home, 'service-instance.sqlite3'))
+      try { lock.exec('PRAGMA busy_timeout=0; BEGIN EXCLUSIVE'); rebaseDatabasePaths(home, '/var/lib/hermes-yaoyao') }
+      finally { lock.close() }
+    }
+    return false
+  }
+  if (lstatSync(old).isSymbolicLink() || !lstatSync(old).isDirectory()) throw new Error('旧数据目录不是普通目录,请先核对实际数据位置')
+  if (existsSync(home) && (lstatSync(home).isSymbolicLink() || readdirSync(home).length))
+    throw new Error('~/.yaoyao 与 ~/.hermes-yaoyao 同时存在数据,已保留两份数据,请先合并确认后重试')
+  if (legacyUpdateActive(userHome)) throw new Error('旧版升级事务尚未完成,请完成更新后重试数据迁移')
+  const locks = []
+  try {
+    // Lock every SQLite database, including independent Runner owners, before moving.
+    const lockTree = directory => {
+      for (const entry of readdirSync(directory, { withFileTypes: true })) {
+        if (entry.isSymbolicLink() || ['backups', 'uploads', 'workspace-files', 'chat-cache-assets'].includes(entry.name)) continue
+        const path = join(directory, entry.name)
+        if (entry.isDirectory()) { if (['runner-state', 'updates'].includes(entry.name) || directory.startsWith(join(old, 'runner-state'))) lockTree(path) }
+        else if (/\.(sqlite3?|db)$/.test(entry.name)) {
+          const db = new DatabaseSync(path); locks.push(db)
+          db.exec('PRAGMA busy_timeout=0; BEGIN EXCLUSIVE')
+        }
+      }
+    }
+    lockTree(old)
+    const recordFile = join(old, 'service-instance.json')
+    if (existsSync(recordFile)) {
+      const { pid } = read(recordFile)
+      if (Number.isSafeInteger(pid) && pid > 0) {
+        try { process.kill(pid, 0); throw new Error('旧版服务仍在运行,请停止后台服务后重试数据迁移') }
+        catch (error) { if (error.code !== 'ESRCH') throw error }
+      }
+    }
+    write(join(old, markerName), { source: old, target: home, phase: 'moving', startedAt: new Date().toISOString() })
+    if (existsSync(home)) rmdirSync(home)
+    renameSync(old, home)
+  } catch (error) {
+    if (/locked|busy/i.test(error.message)) throw new Error('旧数据仍被服务或执行节点使用,停止后才能迁移')
+    throw error
+  } finally { for (const db of locks.reverse()) db.close() }
+  rebaseDatabasePaths(home, old)
+  write(marker, { ...read(marker), phase: 'complete' })
+  return true
+}

+ 45 - 0
bin/lib/managed-data-migration.mjs

@@ -0,0 +1,45 @@
+import { existsSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join } from 'node:path'
+import { LaunchAgentService } from './service-update.mjs'
+import { defaultDataHome, legacyDataHome } from './data-home.mjs'
+import { migrateDataHome, rebaseDataPath } from './data-migration.mjs'
+
+export async function migrateManagedDataHome({ home, port = 15300, onProgress = () => {}, beforeMove }) {
+  if (home !== defaultDataHome()) return
+  const old = legacyDataHome(), releaseRoot = join(homedir(), '.local', 'share', 'hermes-yaoyao')
+  let previous, driver
+  if (existsSync(old)) {
+    driver = new LaunchAgentService({ home: old, port, releaseRoot })
+    previous = driver.snapshot()
+    if (previous) {
+      onProgress('正在等待旧服务空闲,准备迁移数据到 ~/.yaoyao…')
+      await driver.quiesce(onProgress, 0)
+      await driver.stop()
+    }
+  }
+  try {
+    if (existsSync(old)) await beforeMove?.(old)
+    migrateDataHome(home)
+  } catch (error) {
+    if (previous && existsSync(old)) await driver.restore(previous)
+    throw error
+  }
+  // Also recover a crash between the atomic rename and the LaunchAgent rewrite.
+  if (!existsSync(home)) return
+  const currentDriver = new LaunchAgentService({ home, port, releaseRoot })
+  if (!previous && existsSync(join(home, '.data-home-migration.json')) && existsSync(currentDriver.plistPath)) {
+    const { execFileSync } = await import('node:child_process')
+    const plist = JSON.parse(execFileSync('/usr/bin/plutil', ['-convert', 'json', '-o', '-', currentDriver.plistPath], { encoding: 'utf8' }))
+    if (plist.EnvironmentVariables?.HERMES_YAOYAO_HOME === old) previous = { plist, wasRunning: true }
+  }
+  if (previous) {
+    for (const [key, value] of Object.entries(previous.plist.EnvironmentVariables ?? {})) previous.plist.EnvironmentVariables[key] = rebaseDataPath(value, old, home)
+    previous.plist.EnvironmentVariables.HERMES_YAOYAO_HOME = home
+    previous.plist.EnvironmentVariables.YAOYAO_HOME = home
+    for (const field of ['StandardOutPath', 'StandardErrorPath']) previous.plist[field] = rebaseDataPath(previous.plist[field], old, home)
+    currentDriver.writePlist(previous.plist)
+    if (previous.wasRunning) { await currentDriver.boot(); await currentDriver.verify(undefined) }
+    onProgress('账号、会话、文件和配置已迁移到 ~/.yaoyao')
+  }
+}

+ 4 - 3
bin/lib/release-source.mjs

@@ -1,9 +1,10 @@
-export const DEFAULT_RELEASE_SOURCE = 'https://github.com/Lsamien/hermes-yaoyao.git'
+export const DEFAULT_RELEASE_SOURCE = 'https://github.com/Lsamien/yaoyao.git'
 
 /** Only the former official repository is migrated; private forks stay private. */
 export function normalizeReleaseSource(value) {
   const source = value?.trim()
   if (!source) return DEFAULT_RELEASE_SOURCE
+  if (/^git@github\.com:Lsamien\/(?:hermes-yaoyao|yaoyao)(?:\.git)?\/?$/i.test(source)) return DEFAULT_RELEASE_SOURCE
   if (/^git@git\.samien\.cn:samien\/hermes-yaoyao(?:\.git)?\/?$/.test(source)) return DEFAULT_RELEASE_SOURCE
   try {
     const url = new URL(source)
@@ -11,10 +12,10 @@ export function normalizeReleaseSource(value) {
     if (!url.username && !url.password && !url.search && !url.hash
       && ['https:', 'http:', 'ssh:'].includes(url.protocol)
       && ['git.samien.cn', '192.168.153.8:3000'].includes(url.host)
-      && path === '/samien/hermes-yaoyao') return DEFAULT_RELEASE_SOURCE
+      && ['/samien/hermes-yaoyao', '/samien/yaoyao'].includes(path)) return DEFAULT_RELEASE_SOURCE
     if (url.protocol === 'https:' && url.hostname === 'github.com' && !url.port
       && !url.username && !url.password && !url.search && !url.hash && /^\/[\w.-]+\/[\w.-]+$/.test(path)) {
-      const normalized = `https://github.com${path}.git`
+      const normalized = /^\/Lsamien\/(?:hermes-yaoyao|yaoyao)$/i.test(path) ? DEFAULT_RELEASE_SOURCE : `https://github.com${path}.git`
       return normalized.toLowerCase() === DEFAULT_RELEASE_SOURCE.toLowerCase() ? DEFAULT_RELEASE_SOURCE : normalized
     }
   } catch { /* Custom SSH sources retain their existing Git transport. */ }

+ 20 - 0
bin/migrate-data-home.mjs

@@ -0,0 +1,20 @@
+import { appendFileSync } from 'node:fs'
+import { join } from 'node:path'
+import { defaultDataHome, legacyDataHome, legacyUpdateActive } from './lib/data-home.mjs'
+import { migrateManagedDataHome } from './lib/managed-data-migration.mjs'
+
+const deadline = Date.now() + 10 * 60 * 1000
+for (;;) {
+  try {
+    if (legacyUpdateActive()) throw new Error('旧版升级事务仍在运行')
+    await migrateManagedDataHome({ home: defaultDataHome(), port: Number(process.argv[2] || 15300) })
+    break
+  } catch (error) {
+    if (Date.now() >= deadline) {
+      try { appendFileSync(join(legacyDataHome(), 'data-migration.log'), `${new Date().toISOString()} ${error.message}\n`, { mode: 0o600 }) } catch {}
+      process.exitCode = 1
+      break
+    }
+    await new Promise(done => setTimeout(done, 5000))
+  }
+}

+ 4 - 4
compose.desktops.yaml

@@ -6,7 +6,7 @@ services:
     build:
       context: .
       dockerfile: Dockerfile
-    image: "${HERMES_YAOYAO_IMAGE:-hermes-yaoyao:local}"
+    image: "${HERMES_YAOYAO_IMAGE:-yaoyao:local}"
     restart: unless-stopped
     init: true
     read_only: true
@@ -31,14 +31,14 @@ services:
       HERMES_YAOYAO_LOCAL_VM_HOST: "runner"
       HERMES_YAOYAO_COMPOSE_DESKTOPS: "[{\"id\":\"160fe7cd-e530-4ac5-a97f-26c19a362b11\",\"name\":\"共享桌面 1\",\"socketPath\":\"/run/yaoyao-desktops/desktop-1/desktop.sock\"},{\"id\":\"eba5caaf-744e-4f27-bcdd-1f1f35d05a42\",\"name\":\"共享桌面 2\",\"socketPath\":\"/run/yaoyao-desktops/desktop-2/desktop.sock\"}]"
       HERMES_YAOYAO_CHAT_CACHE_MODE: "${HERMES_YAOYAO_CHAT_CACHE_MODE:-prefer-local}"
-      HERMES_YAOYAO_RELEASE_SOURCE: "${HERMES_YAOYAO_RELEASE_SOURCE:-https://github.com/Lsamien/hermes-yaoyao.git}"
-      HERMES_YAOYAO_HOME: /var/lib/hermes-yaoyao
+      HERMES_YAOYAO_RELEASE_SOURCE: "${HERMES_YAOYAO_RELEASE_SOURCE:-https://github.com/Lsamien/yaoyao.git}"
+      HERMES_YAOYAO_HOME: /home/node/.yaoyao
       HERMES_YAOYAO_APNS_KEY_FILE: "${HERMES_YAOYAO_APNS_KEY_FILE:-}"
       HERMES_YAOYAO_APNS_KEY_ID: "${HERMES_YAOYAO_APNS_KEY_ID:-}"
       HERMES_YAOYAO_APNS_TEAM_ID: "${HERMES_YAOYAO_APNS_TEAM_ID:-}"
       HERMES_YAOYAO_APNS_TOPIC: "${HERMES_YAOYAO_APNS_TOPIC:-}"
     volumes:
-      - yaoyao-data:/var/lib/hermes-yaoyao
+      - yaoyao-data:/home/node/.yaoyao
       - desktop-1-ipc:/run/yaoyao-desktops/desktop-1:ro
       - desktop-2-ipc:/run/yaoyao-desktops/desktop-2:ro
     tmpfs:

+ 4 - 4
compose.yaml

@@ -5,7 +5,7 @@ services:
     build:
       context: .
       dockerfile: Dockerfile
-    image: "${HERMES_YAOYAO_IMAGE:-hermes-yaoyao:local}"
+    image: "${HERMES_YAOYAO_IMAGE:-yaoyao:local}"
     restart: unless-stopped
     init: true
     read_only: true
@@ -29,14 +29,14 @@ services:
       HERMES_YAOYAO_SUPERVISE_DASHBOARD: "0"
       HERMES_YAOYAO_LOCAL_VM_HOST: "runner"
       HERMES_YAOYAO_CHAT_CACHE_MODE: "${HERMES_YAOYAO_CHAT_CACHE_MODE:-prefer-local}"
-      HERMES_YAOYAO_RELEASE_SOURCE: "${HERMES_YAOYAO_RELEASE_SOURCE:-https://github.com/Lsamien/hermes-yaoyao.git}"
-      HERMES_YAOYAO_HOME: /var/lib/hermes-yaoyao
+      HERMES_YAOYAO_RELEASE_SOURCE: "${HERMES_YAOYAO_RELEASE_SOURCE:-https://github.com/Lsamien/yaoyao.git}"
+      HERMES_YAOYAO_HOME: /home/node/.yaoyao
       HERMES_YAOYAO_APNS_KEY_FILE: "${HERMES_YAOYAO_APNS_KEY_FILE:-}"
       HERMES_YAOYAO_APNS_KEY_ID: "${HERMES_YAOYAO_APNS_KEY_ID:-}"
       HERMES_YAOYAO_APNS_TEAM_ID: "${HERMES_YAOYAO_APNS_TEAM_ID:-}"
       HERMES_YAOYAO_APNS_TOPIC: "${HERMES_YAOYAO_APNS_TOPIC:-}"
     volumes:
-      - yaoyao-data:/var/lib/hermes-yaoyao
+      - yaoyao-data:/home/node/.yaoyao
     tmpfs:
       - /tmp:mode=1777
 

+ 54 - 0
desktop/browser-environment.mjs

@@ -0,0 +1,54 @@
+import {BrowserWindow,session} from 'electron'
+import {randomUUID} from 'node:crypto'
+import {join} from 'node:path'
+import {mkdirSync,chmodSync} from 'node:fs'
+
+export function browserURL(value){if(typeof value!=='string'||value.length>4096||/[\\\x00-\x20]/.test(value))throw new Error('请输入完整的 http 或 https 地址');const u=new URL(value);if(!['http:','https:'].includes(u.protocol)||u.username||u.password)throw new Error('浏览器只支持 http 和 https 页面');return u.href}
+const allowed=url=>url==='about:blank'||(()=>{try{browserURL(url);return true}catch{return false}})()
+/** A bot gets an isolated Chromium profile, never the app or personal browser's
+ * cookies. All commands are structured; no model-supplied JavaScript or CDP. */
+export class BrowserEnvironment {
+ constructor(root){mkdirSync(root,{recursive:true,mode:0o700});chmodSync(root,0o700);this.root=root;this.browsers=new Map();this.sessions=new Map()}
+ state(key){const b=this.browsers.get(key);return {open:!!b,tabs:b?[...b.tabs].map(([id,w])=>({id,title:w.webContents.getTitle()||'新标签页',url:w.webContents.getURL(),active:id===b.active})):[],profile:b?.profile??'persistent'}}
+ async open(key,profile){if(!/^[a-f0-9]{64}$/.test(key)||!['persistent','temporary'].includes(profile))throw new Error('浏览器身份无效');let b=this.browsers.get(key);if(!b){let s=this.sessions.get(key);if(!s){s=profile==='persistent'?session.fromPath(join(this.root,key)):session.fromPartition('yaoyao-temporary-'+key+'-'+randomUUID());s.setPermissionRequestHandler((_w,_p,callback)=>callback(false));s.setPermissionCheckHandler(()=>false);s.on('will-download',event=>event.preventDefault());this.sessions.set(key,s)}b={tabs:new Map(),active:'',session:s,profile};this.browsers.set(key,b);await this.newTab(b,'about:blank')}return b}
+ async newTab(b,url){if(b.tabs.size>=12)throw new Error('最多打开 12 个标签页,请先关闭不用的页面');const id=randomUUID(),w=new BrowserWindow({show:false,width:1280,height:800,useContentSize:true,webPreferences:{session:b.session,sandbox:true,nodeIntegration:false,contextIsolation:true,backgroundThrottling:false,webSecurity:true,allowRunningInsecureContent:false}});b.tabs.set(id,w);b.active=id
+  w.webContents.setWindowOpenHandler(({url})=>{if(allowed(url))void this.newTab(b,url).catch(()=>{});return {action:'deny'}})
+  w.webContents.on('will-navigate',(event,url)=>{if(!allowed(url))event.preventDefault()});w.webContents.on('will-redirect',(event,url)=>{if(!allowed(url))event.preventDefault()});w.webContents.on('will-attach-webview',event=>event.preventDefault());w.webContents.on('did-start-navigation',()=>{w.snapshotId=undefined})
+  w.on('closed',()=>{b.tabs.delete(id);if(b.active===id)b.active=b.tabs.keys().next().value??''})
+  try{await this.load(w,url)}catch(error){if(!w.isDestroyed()&&error.code!=='ERR_ABORTED')throw new Error('页面加载失败,请检查地址或网络')}
+  return id
+ }
+ async load(w,url){let timer;try{await Promise.race([w.loadURL(url),new Promise((_,reject)=>{timer=setTimeout(()=>{if(!w.isDestroyed())w.webContents.stop();reject(new Error('页面加载超时'))},18000)})])}finally{clearTimeout(timer)}}
+ current(b){const w=b.tabs.get(b.active);if(!w||w.isDestroyed())throw new Error('浏览器标签页已关闭,请新建标签页');return w}
+ async view(key){const b=this.browsers.get(key);if(!b)throw new Error('浏览器尚未打开,点击打开浏览器');const wc=this.current(b).webContents;await wc.executeJavaScript('new Promise(resolve=>{requestAnimationFrame(()=>requestAnimationFrame(resolve));setTimeout(resolve,200)})').catch(()=>{});const image=await wc.capturePage();if(image.isEmpty())throw new Error('浏览器画面尚未就绪');return {data:image.toPNG().toString('base64'),...image.getSize()}}
+ async action(key,profile,a){const b=await this.open(key,profile);if(a.kind==='new-tab'){await this.newTab(b,browserURL(a.url));return this.state(key)}
+  if(['select-tab','close-tab'].includes(a.kind)){if(!b.tabs.has(a.tabId))throw new Error('标签页已关闭');if(a.kind==='select-tab')b.active=a.tabId;else{b.tabs.get(a.tabId).destroy();if(!b.tabs.size)await this.newTab(b,'about:blank')}return this.state(key)}
+  const w=this.current(b),wc=w.webContents
+  if(a.kind==='navigate'){const url=browserURL(a.url);w.snapshotId=undefined;try{await this.load(w,url)}catch(error){if(error.code!=='ERR_ABORTED')throw new Error('页面加载失败,请检查地址或网络')}}
+  else if(a.kind==='back'){w.snapshotId=undefined;if(wc.navigationHistory.canGoBack())wc.navigationHistory.goBack()}
+  else if(a.kind==='forward'){w.snapshotId=undefined;if(wc.navigationHistory.canGoForward())wc.navigationHistory.goForward()}
+  else if(a.kind==='reload'){w.snapshotId=undefined;wc.reload()}
+  else if(a.kind==='snapshot'){
+   const id=randomUUID();w.snapshotId=id
+   // Ref metadata lives in an isolated world, out of reach of page scripts.
+   const value=await wc.executeJavaScriptInIsolatedWorld(999,[{code:`(()=>{const nodes=[...document.querySelectorAll('a,button,input,textarea,select,[role="button"],[contenteditable="true"]')].filter(e=>e.getClientRects().length).slice(0,500);globalThis.__yaoyaoRefs=new Map(nodes.map((e,i)=>['e'+i,e]));return {title:document.title,url:location.href,text:document.body?.innerText.slice(0,24000)||'',elements:nodes.map((e,i)=>({ref:'e'+i,tag:e.tagName.toLowerCase(),role:e.getAttribute('role'),label:e.getAttribute('aria-label')||e.getAttribute('placeholder')||e.innerText?.slice(0,160)||'',type:e.getAttribute('type')}))}})()`}]);return {...value,snapshotId:id}
+  }else if(a.kind==='click'||a.kind==='fill'){
+   if(!w.snapshotId||w.snapshotId!==a.snapshotId||!/^e[0-9]+$/.test(a.ref))throw new Error('页面已变化,请重新读取 snapshot')
+   if(a.kind==='fill'&&typeof a.text!=='string')throw new Error('填写内容缺失')
+   const code=`(()=>{const e=globalThis.__yaoyaoRefs?.get(${JSON.stringify(a.ref)});if(!e||!e.isConnected||!e.getClientRects().length)throw new Error('元素已变化,请重新读取 snapshot');if(e instanceof HTMLInputElement&&e.type==='file')throw new Error('请通过页面接管处理文件选择');e.scrollIntoView({block:'center'});${a.kind==='click'?'e.click();':`if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e.isContentEditable))throw new Error('该元素不能填写');e.focus();if(e.isContentEditable)e.textContent=${JSON.stringify(a.text)};else{const setter=Object.getOwnPropertyDescriptor(e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,'value').set;setter.call(e,${JSON.stringify(a.text)})}e.dispatchEvent(new Event('input',{bubbles:true}));e.dispatchEvent(new Event('change',{bubbles:true}));`}return {ok:true}})()`
+   await wc.executeJavaScriptInIsolatedWorld(999,[{code}]);w.snapshotId=undefined
+  }else throw new Error('浏览器操作无效')
+  return this.state(key)
+ }
+ async input(key,a,frame){const b=this.browsers.get(key);if(!b)throw new Error('浏览器未打开');const w=this.current(b),wc=w.webContents,size=w.getContentSize();w.snapshotId=undefined
+  const point=(x,y)=>{if(!Number.isFinite(x)||!Number.isFinite(y)||x<0||y<0||x>=frame.width||y>=frame.height)throw new Error('输入超出画面');return {x:Math.floor(x*size[0]/frame.width),y:Math.floor(y*size[1]/frame.height)}}
+  if(a.kind==='text')await wc.insertText(a.text)
+  else if(a.kind==='key'){const keyCode=({Return:'Enter',BackSpace:'Backspace',Up:'Up',Down:'Down',Left:'Left',Right:'Right',space:'Space'}[a.key]??a.key),modifiers=(a.modifiers??[]).map(m=>({ctrl:'control',alt:'alt',shift:'shift',super:'meta'}[m]));wc.sendInputEvent({type:'keyDown',keyCode,modifiers});wc.sendInputEvent({type:'keyUp',keyCode,modifiers})}
+  else if(a.kind==='click'){const p=point(a.x,a.y),button=a.button??'left',clickCount=a.count??1;wc.sendInputEvent({type:'mouseMove',...p});wc.sendInputEvent({type:'mouseDown',...p,button,clickCount});wc.sendInputEvent({type:'mouseUp',...p,button,clickCount})}
+  else if(a.kind==='drag'){const start=point(a.fromX,a.fromY),end=point(a.toX,a.toY);wc.sendInputEvent({type:'mouseDown',...start,button:'left',clickCount:1});wc.sendInputEvent({type:'mouseMove',...end,modifiers:['leftButtonDown']});wc.sendInputEvent({type:'mouseUp',...end,button:'left',clickCount:1})}
+  else if(a.kind==='scroll'){const amount=(a.amount??3)*80;wc.sendInputEvent({type:'mouseWheel',x:Math.floor(size[0]/2),y:Math.floor(size[1]/2),deltaX:a.direction==='left'?-amount:a.direction==='right'?amount:0,deltaY:a.direction==='up'?-amount:a.direction==='down'?amount:0,canScroll:true})}
+  else throw new Error('浏览器输入无效')
+  return {ok:true}
+ }
+ async close(){for(const b of this.browsers.values())for(const w of b.tabs.values())w.destroy();this.browsers.clear();for(const s of this.sessions.values()){s.flushStorageData();await s.cookies.flushStore();if(!s.isPersistent())await s.clearStorageData()}this.sessions.clear()}
+}

+ 41 - 0
desktop/browser-environment.test.mjs

@@ -0,0 +1,41 @@
+import {test} from 'node:test'
+import assert from 'node:assert/strict'
+import {mkdtemp,writeFile,rm,mkdir} from 'node:fs/promises'
+import {tmpdir} from 'node:os'
+import {join,resolve} from 'node:path'
+import {pathToFileURL} from 'node:url'
+import {createServer} from 'node:http'
+import {randomUUID} from 'node:crypto'
+import {_electron} from '@playwright/test'
+
+test('real isolated Chromium supports refs, tabs, screenshots and separate persisted profiles',{timeout:60000},async()=>{
+ const home=await mkdtemp(join(tmpdir(),'yaoyao-browser-')),marker=randomUUID(),server=createServer((req,res)=>{res.setHeader('Content-Type','text/html; charset=utf-8');res.end(`<title>Browser ${marker}</title><body style="background:#edf4ff;font:24px sans-serif;padding:50px"><h1>独立浏览器验证</h1><label>随机内容 <input aria-label="验证输入"></label><button onclick="document.querySelector('output').textContent=document.querySelector('input').value">确认</button><output></output><p>${marker}</p><a href="/next">下一页</a></body>`)})
+ await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));const url=`http://127.0.0.1:${server.address().port}/`,moduleURL=pathToFileURL(resolve('desktop/browser-environment.mjs')).href
+ await writeFile(join(home,'main.mjs'),`import {app,BrowserWindow} from 'electron';app.setPath('userData',${JSON.stringify(join(home,'app'))});app.whenReady().then(async()=>{const hostWindow=new BrowserWindow({show:false});await hostWindow.loadURL('about:blank');const {BrowserEnvironment}=await import(${JSON.stringify(moduleURL)});globalThis.botBrowser=new BrowserEnvironment(${JSON.stringify(join(home,'profiles'))});app.on('window-all-closed',()=>{});});`)
+ let app
+ try{
+  app=await _electron.launch({args:[join(home,'main.mjs')],env:Object.fromEntries(Object.entries(process.env).filter(([key])=>key!=='ELECTRON_RUN_AS_NODE'))})
+  await app.evaluate(async()=>{for(let i=0;i<100&&!globalThis.botBrowser;i++)await new Promise(resolve=>setTimeout(resolve,20));if(!globalThis.botBrowser)throw new Error('browser host did not initialize')})
+  const call=async(method,...args)=>app.evaluate(async(_,{method,args})=>globalThis.botBrowser[method](...args),{method,args})
+  const a='a'.repeat(64),b='b'.repeat(64),t='c'.repeat(64)
+  assert.equal((await call('state',a)).open,false)
+  await call('action',a,'persistent',{kind:'navigate',url})
+  const snapshot=await call('action',a,'persistent',{kind:'snapshot'})
+  assert.ok(snapshot.text.includes(marker));const input=snapshot.elements.find(e=>e.label==='验证输入');assert.ok(input)
+  await call('action',a,'persistent',{kind:'fill',ref:input.ref,snapshotId:snapshot.snapshotId,text:marker})
+  await assert.rejects(call('action',a,'persistent',{kind:'click',ref:input.ref,snapshotId:snapshot.snapshotId}),/变化/)
+  const next=await call('action',a,'persistent',{kind:'snapshot'}),button=next.elements.find(e=>e.label==='确认')
+  await call('action',a,'persistent',{kind:'click',ref:button.ref,snapshotId:next.snapshotId})
+  assert.equal(await app.evaluate(()=>globalThis.botBrowser.current(globalThis.botBrowser.browsers.values().next().value).webContents.executeJavaScript('document.querySelector("output").textContent')),marker)
+  const frame=await call('view',a);assert.ok(frame.width>=1000);assert.ok(Buffer.from(frame.data,'base64').length>10000)
+  await mkdir(resolve('test-results/desktop'),{recursive:true});await writeFile(resolve('test-results/desktop/bot-browser.png'),Buffer.from(frame.data,'base64'))
+  await call('action',a,'persistent',{kind:'new-tab',url:url+'next'});const tabs=(await call('state',a)).tabs;assert.equal(tabs.length,2)
+  await call('action',a,'persistent',{kind:'close-tab',tabId:tabs.find(t=>t.active).id});assert.equal((await call('state',a)).tabs.length,1)
+  await assert.rejects(call('action',a,'persistent',{kind:'navigate',url:'file:///etc/passwd'}),/http/)
+  await app.evaluate(async(_,{a,url})=>globalThis.botBrowser.browsers.get(a).session.cookies.set({url,name:'owner',value:'a',expirationDate:Date.now()/1000+3600}),{a,url})
+  await call('action',b,'persistent',{kind:'navigate',url});assert.deepEqual(await app.evaluate(async(_,b)=>globalThis.botBrowser.browsers.get(b).session.cookies.get({name:'owner'}),b),[])
+  await call('action',t,'temporary',{kind:'navigate',url});await app.evaluate(async(_,{t,url})=>globalThis.botBrowser.browsers.get(t).session.cookies.set({url,name:'temporary',value:'yes',expirationDate:Date.now()/1000+3600}),{t,url})
+  await call('close');await app.close();app=await _electron.launch({args:[join(home,'main.mjs')],env:Object.fromEntries(Object.entries(process.env).filter(([key])=>key!=='ELECTRON_RUN_AS_NODE'))});await app.evaluate(async()=>{for(let i=0;i<100&&!globalThis.botBrowser;i++)await new Promise(resolve=>setTimeout(resolve,20))});await call('open',a,'persistent');assert.equal((await app.evaluate(async(_,a)=>globalThis.botBrowser.browsers.get(a).session.cookies.get({name:'owner'}),a))[0].value,'a')
+  await call('open',t,'temporary');assert.deepEqual(await app.evaluate(async(_,t)=>globalThis.botBrowser.browsers.get(t).session.cookies.get({name:'temporary'}),t),[])
+ }finally{await app?.close();await new Promise(resolve=>server.close(resolve));await rm(home,{recursive:true,force:true})}
+})

+ 95 - 0
desktop/computer-helper.swift

@@ -0,0 +1,95 @@
+import Foundation
+import Security
+import AppKit
+import ApplicationServices
+import Darwin
+
+// This helper's signed identity owns each Keychain item. Plaintext travels only
+// on private stdin/stdout, never in command arguments or logs.
+func fail(_ message: String) -> Never {
+    FileHandle.standardError.write(Data((message + "\n").utf8)); exit(1)
+}
+#if !DEVELOPMENT_HELPER
+// The distributed helper accepts only its containing, validly signed App with
+// the same signing team. Copying the helper or invoking it from a shell fails.
+@_silgen_name("proc_pidpath")
+func processPath(_ pid: Int32, _ buffer: UnsafeMutableRawPointer, _ size: UInt32) -> Int32
+var parentPath = [CChar](repeating: 0, count: 4096)
+let pathLength = parentPath.withUnsafeMutableBytes { processPath(getppid(), $0.baseAddress!, UInt32($0.count)) }
+guard pathLength > 0 else { fail("无法核对 App 身份") }
+let parentURL = URL(fileURLWithPath: String(cString: parentPath)).resolvingSymlinksInPath()
+let expected = parentURL.deletingLastPathComponent().appendingPathComponent("../Resources/runtime/computer-helper").standardizedFileURL.resolvingSymlinksInPath()
+guard expected.path == URL(fileURLWithPath: CommandLine.arguments[0]).resolvingSymlinksInPath().path else { fail("电脑助手只允许所属 App 调用") }
+var parentCode: SecCode?, ownCode: SecCode?
+guard SecCodeCopyGuestWithAttributes(nil, [kSecGuestAttributePid as String: getppid()] as CFDictionary, [], &parentCode) == errSecSuccess,
+      SecCodeCopySelf([], &ownCode) == errSecSuccess, let parentCode, let ownCode,
+      SecCodeCheckValidity(parentCode, [], nil) == errSecSuccess else { fail("App 签名无效") }
+func signingInfo(_ code: SecCode) -> [String: Any] {
+    var info: CFDictionary?
+    var staticCode: SecStaticCode?
+    guard SecCodeCopyStaticCode(code, [], &staticCode) == errSecSuccess, let staticCode else { fail("无法读取签名身份") }
+    guard SecCodeCopySigningInformation(staticCode, SecCSFlags(rawValue: kSecCSSigningInformation), &info) == errSecSuccess else { fail("无法核对签名身份") }
+    return info as? [String: Any] ?? [:]
+}
+let parentInfo = signingInfo(parentCode), ownInfo = signingInfo(ownCode)
+guard let team = ownInfo[kSecCodeInfoTeamIdentifier as String] as? String,
+      parentInfo[kSecCodeInfoTeamIdentifier as String] as? String == team,
+      parentInfo[kSecCodeInfoIdentifier as String] as? String == "cn.samien.yaoyao.desktop" else { fail("App 签名身份不匹配") }
+#endif
+let bytes = FileHandle.standardInput.readDataToEndOfFile()
+guard bytes.count <= 131072,
+      let input = try? JSONSerialization.jsonObject(with: bytes) as? [String: Any],
+      let action = input["action"] as? [String: Any], let kind = action["kind"] as? String,
+      let frame = input["frame"] as? [String: Any], let bounds = frame["bounds"] as? [String: Any],
+      let width = frame["width"] as? Double, let height = frame["height"] as? Double,
+      let bx = bounds["x"] as? Double, let by = bounds["y"] as? Double,
+      let bw = bounds["width"] as? Double, let bh = bounds["height"] as? Double,
+      width > 0, height > 0, bw > 0, bh > 0 else { fail("电脑输入格式无效") }
+guard AXIsProcessTrusted() else { fail("请在系统设置中允许夭夭使用辅助功能") }
+func point(_ xKey: String, _ yKey: String) -> CGPoint {
+    guard let x = action[xKey] as? Double, let y = action[yKey] as? Double,
+          x.isFinite, y.isFinite, x >= 0, y >= 0, x < width, y < height else { fail("输入超出当前画面") }
+    return CGPoint(x: bx + x * bw / width, y: by + y * bh / height)
+}
+func mouse(_ type: CGEventType, _ point: CGPoint, _ button: CGMouseButton = .left, _ clicks: Int64 = 1) {
+    guard let event = CGEvent(mouseEventSource: nil, mouseType: type, mouseCursorPosition: point, mouseButton: button) else { fail("无法创建鼠标输入") }
+    event.setIntegerValueField(.mouseEventClickState, value: clicks); event.post(tap: .cghidEventTap)
+}
+switch kind {
+case "click":
+    let p = point("x", "y"), name = action["button"] as? String ?? "left"
+    let button: CGMouseButton = name == "right" ? .right : name == "middle" ? .center : .left
+    let down: CGEventType = button == .left ? .leftMouseDown : button == .right ? .rightMouseDown : .otherMouseDown
+    let up: CGEventType = button == .left ? .leftMouseUp : button == .right ? .rightMouseUp : .otherMouseUp
+    let count = action["count"] as? Int ?? 1
+    guard (1...2).contains(count) else { fail("点击次数无效") }
+    mouse(.mouseMoved, p)
+    for i in 1...count { mouse(down,p,button,Int64(i)); mouse(up,p,button,Int64(i)); usleep(50000) }
+case "drag":
+    let start = point("fromX", "fromY"), end = point("toX", "toY")
+    mouse(.mouseMoved,start); mouse(.leftMouseDown,start)
+    for step in 1...12 { mouse(.leftMouseDragged,CGPoint(x:start.x+(end.x-start.x)*Double(step)/12,y:start.y+(end.y-start.y)*Double(step)/12)); usleep(12000) }
+    mouse(.leftMouseUp,end)
+case "text":
+    guard let text = action["text"] as? String, text.utf16.count <= 16000 else { fail("输入文本过长") }
+    let characters = Array(text.utf16)
+    for offset in stride(from: 0, to: characters.count, by: 200) {
+        let chunk = Array(characters[offset..<min(offset+200,characters.count)])
+        for down in [true,false] { guard let event = CGEvent(keyboardEventSource:nil,virtualKey:0,keyDown:down) else { fail("无法创建键盘输入") };chunk.withUnsafeBufferPointer { event.keyboardSetUnicodeString(stringLength:chunk.count,unicodeString:$0.baseAddress!) };event.post(tap:.cghidEventTap) }
+    }
+case "key":
+    let keys: [String:CGKeyCode] = ["a":0,"s":1,"d":2,"f":3,"h":4,"g":5,"z":6,"x":7,"c":8,"v":9,"b":11,"q":12,"w":13,"e":14,"r":15,"y":16,"t":17,"1":18,"2":19,"3":20,"4":21,"6":22,"5":23,"9":25,"7":26,"8":28,"0":29,"o":31,"u":32,"i":34,"p":35,"Return":36,"Enter":36,"l":37,"j":38,"k":40,"n":45,"m":46,"Tab":48,"Space":49,"space":49,"BackSpace":51,"Backspace":51,"Escape":53,"Delete":117,"Home":115,"End":119,"PageUp":116,"PageDown":121,"Left":123,"Right":124,"Down":125,"Up":126]
+    guard let name = action["key"] as? String, let key = keys[name] ?? keys[name.lowercased()] else { fail("暂不支持这个按键") }
+    var flags = CGEventFlags()
+    for modifier in action["modifiers"] as? [String] ?? [] { switch modifier { case "ctrl": flags.insert(.maskControl); case "alt": flags.insert(.maskAlternate); case "shift": flags.insert(.maskShift); case "super": flags.insert(.maskCommand); default: fail("按键修饰符无效") } }
+    for down in [true,false] { guard let event = CGEvent(keyboardEventSource:nil,virtualKey:key,keyDown:down) else { fail("无法创建键盘输入") };event.flags=flags;event.post(tap:.cghidEventTap) }
+case "scroll":
+    guard let direction = action["direction"] as? String, ["up","down","left","right"].contains(direction) else { fail("滚动方向无效") }
+    let amount = action["amount"] as? Int ?? 3
+    guard (1...50).contains(amount) else { fail("滚动距离无效") }
+    let vertical = direction == "up" ? amount : direction == "down" ? -amount : 0
+    let horizontal = direction == "left" ? amount : direction == "right" ? -amount : 0
+    guard let event = CGEvent(scrollWheelEvent2Source:nil,units:.line,wheelCount:2,wheel1:Int32(vertical),wheel2:Int32(horizontal),wheel3:0) else { fail("无法创建滚动输入") };event.post(tap:.cghidEventTap)
+default: fail("电脑操作无效")
+}
+FileHandle.standardOutput.write(Data("{\"ok\":true}".utf8))

+ 42 - 0
desktop/computer-viewer.mjs

@@ -0,0 +1,42 @@
+import { BrowserWindow, ipcMain } from 'electron'
+
+/** Local authenticated viewer. Agent ownership and control leases remain server-authoritative. */
+export function installComputerViewer({ owner, origin, preload, quitting = () => false }) {
+  let viewer, agentId, approvedClose = false
+  const trusted = event => event.sender === owner()?.webContents && event.senderFrame === event.sender.mainFrame
+    && new URL(event.senderFrame.url).origin === origin()
+  ipcMain.handle('desktop-computer:open', async (event, id) => {
+    if (!trusted(event) || typeof id !== 'string' || !/^[\w-]{1,128}$/.test(id)) throw new Error('电脑窗口请求无效')
+    if (viewer && !viewer.isDestroyed()) {
+      viewer.show(); viewer.focus()
+      if (agentId !== id) throw new Error('请先交还并关闭当前电脑,再接管另一台电脑')
+      return true
+    }
+    const url = new URL(`/conversations/computer/${encodeURIComponent(id)}`, origin()).href
+    agentId = id; approvedClose = false
+    const current = viewer = new BrowserWindow({ parent: owner(), modal: false, width: 1220, height: 820,
+      minWidth: 760, minHeight: 520, show: false, title: '电脑接管 · 夭夭 AI', backgroundColor: '#111315', autoHideMenuBar: true,
+      webPreferences: { preload, sandbox: true, contextIsolation: true, nodeIntegration: false, webSecurity: true } })
+    current.webContents.setWindowOpenHandler(() => ({ action: 'deny' }))
+    current.webContents.on('will-navigate', (event, target) => { if (target !== url) event.preventDefault() })
+    current.webContents.on('will-redirect', event => event.preventDefault())
+    current.webContents.on('will-attach-webview', event => event.preventDefault())
+    current.on('close', event => {
+      if (!approvedClose && !quitting() && !current.webContents.isCrashed()) {
+        event.preventDefault(); current.webContents.send('desktop-computer:request-close')
+      }
+    })
+    current.on('closed', () => { if (viewer === current) { viewer = undefined; agentId = undefined } })
+    current.once('ready-to-show', () => { current.show(); current.focus() })
+    try { await current.loadURL(url) } catch (error) { approvedClose = true; current.close(); throw error }
+    return true
+  })
+  ipcMain.handle('desktop-computer:closed', event => {
+    if (event.sender !== viewer?.webContents || event.senderFrame !== event.sender.mainFrame
+      || new URL(event.senderFrame.url).pathname !== `/conversations/computer/${agentId}`) throw new Error('电脑窗口身份无效')
+    approvedClose = true; viewer.close()
+  })
+  const close = () => { approvedClose = true; viewer?.destroy() }
+  close.owns = contents => contents === viewer?.webContents
+  return close
+}

+ 42 - 0
desktop/computer-viewer.test.mjs

@@ -0,0 +1,42 @@
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { mkdtemp, writeFile, mkdir, rm } from 'node:fs/promises'
+import { tmpdir } from 'node:os'
+import { join, resolve } from 'node:path'
+import { pathToFileURL } from 'node:url'
+import { spawn } from 'node:child_process'
+import { _electron as electron, expect } from '@playwright/test'
+const root=resolve(import.meta.dirname,'..')
+test('desktop takeover opens a separate large viewer and returns its lease before native close',{timeout:90000},async()=>{
+ const home=await mkdtemp(join(tmpdir(),'yaoyao-viewer-')),port=18864,origin=`http://127.0.0.1:${port}`
+ const server=spawn(process.execPath,['--import','tsx','tests/fixtures/workspace-server.ts'],{cwd:root,env:{...process.env,WORKSPACE_FIXTURE_HOME:home,WORKSPACE_FIXTURE_TEAM_TOOLS:'1',WORKSPACE_FIXTURE_PORT:String(port),WORKSPACE_FIXTURE_UPSTREAM_PORT:'19164'},stdio:'ignore'})
+ let app
+ try{
+  await expect.poll(async()=>{try{return(await fetch(origin+'/healthz')).status}catch{return 0}},{timeout:30000}).toBe(200)
+  const harness=join(home,'main.mjs')
+  await writeFile(harness,`import {app,BrowserWindow} from '${pathToFileURL(join(root,'node_modules/electron/index.js')).href}';\nimport {installComputerViewer} from '${pathToFileURL(join(root,'desktop/computer-viewer.mjs')).href}';\napp.setPath('userData',${JSON.stringify(join(home,'chromium'))});app.whenReady().then(async()=>{let quitting=false;app.on('before-quit',()=>quitting=true);const owner=new BrowserWindow({width:1440,height:900,webPreferences:{preload:${JSON.stringify(join(root,'desktop/preload.cjs'))},sandbox:true,contextIsolation:true}});installComputerViewer({owner:()=>owner,origin:()=>${JSON.stringify(origin)},preload:${JSON.stringify(join(root,'desktop/preload.cjs'))},quitting:()=>quitting});await owner.loadURL(${JSON.stringify(origin+'/conversations')});});`)
+  // Electron's built-in module must be resolved in its own process.
+  const content=await (await import('node:fs/promises')).readFile(harness,'utf8');await writeFile(harness,content.replace(pathToFileURL(join(root,'node_modules/electron/index.js')).href,'electron'))
+  app=await electron.launch({args:[harness],cwd:root})
+  const page=await app.firstWindow();await page.getByRole('textbox',{name:'账号',exact:true}).fill('fixture');await page.getByRole('textbox',{name:'密码',exact:true}).fill('fixture-pass');await page.getByRole('button',{name:'登录',exact:true}).click()
+  await expect(page.locator('.desktop-sidebar .sidebar-create-trigger')).toBeVisible()
+  const seed=await(await page.request.post(origin+'/__test/computer',{data:{}})).json()
+  await page.goto(origin+'/conversations/'+seed.conversationId)
+  const agents=(await(await page.request.get(origin+'/api/app/agents')).json()).agents
+  const agent=agents.find(item=>item.id===seed.agentId)||agents.find(item=>item.execution==='computer')||agents[0]
+  const opened=app.waitForEvent('window');await page.evaluate(id=>window.yaoyaoDesktop.openComputer(id),agent.id)
+  const viewer=await opened;await expect(viewer.locator('.computer-panel.standalone')).toContainText('人工控制中')
+  await expect(viewer.locator('.computer-screen img')).toBeVisible()
+  await expect(viewer.locator('footer')).toBeHidden()
+  const screen=await viewer.locator('.computer-screen').boundingBox();assert.ok(screen.height>650)
+  await viewer.locator('.computer-screen img').click();await viewer.keyboard.type('takeover-'+Date.now())
+  await expect.poll(async()=>(await(await page.request.get(origin+'/__test/computer')).json()).actions.filter(item=>item.kind==='text').length).toBeGreaterThan(0)
+  await mkdir(join(root,'docs/verification/2026-09-10-v044'),{recursive:true});await viewer.screenshot({path:join(root,'docs/verification/2026-09-10-v044/computer-takeover.png')})
+  await viewer.getByRole('button',{name:'键盘与操作',exact:true}).click();await expect(viewer.getByRole('textbox',{name:'交还说明'})).toBeVisible()
+  await viewer.getByRole('textbox',{name:'交还说明'}).fill('已完成人工操作')
+  await app.evaluate(({BrowserWindow})=>BrowserWindow.getAllWindows().find(win=>win.webContents.getURL().includes('/conversations/computer/')).close())
+  await expect.poll(()=>viewer.isClosed()).toBe(true)
+  const status=await(await page.request.get(origin+`/api/app/agents/${agent.id}/computer`)).json();assert.notEqual(status.mode,'human')
+  assert.equal(page.isClosed(),false)
+ }finally{await app?.close().catch(()=>{});server.kill('SIGTERM');if(server.exitCode===null)await new Promise(done=>server.once('exit',done));await rm(home,{recursive:true,force:true})}
+})

+ 13 - 1
desktop/credentials.mjs

@@ -1,8 +1,20 @@
 import {createHash} from 'node:crypto'
 import {execFile} from 'node:child_process'
+import {readFileSync} from 'node:fs'
+import {join} from 'node:path'
+import {homedir} from 'node:os'
 const prefix=Buffer.from('YAOYAO-RUNNER-KEYCHAIN-1\n')
 export class DesktopCredentials {
-  constructor({home,helper,legacyDecrypt}){this.account=createHash('sha256').update(home).digest('hex');this.helper=helper;this.legacyDecrypt=legacyDecrypt}
+  constructor({home,helper,legacyDecrypt}){this.home=home;this.helper=helper;this.legacyDecrypt=legacyDecrypt}
+  get account(){
+    let identity=this.home
+    try {
+      const migration=JSON.parse(readFileSync(join(this.home,'.data-home-migration.json'),'utf8'))
+      const old=join(homedir(),'.hermes-yaoyao')
+      if(this.home===join(homedir(),'.yaoyao')&&migration.source===old&&migration.target===this.home)identity=old
+    }catch{/* Fresh directories retain their own Keychain identity. */}
+    return createHash('sha256').update(identity).digest('hex')
+  }
   async invoke(operation,input){
     if(input.length>1048576)throw new Error('执行节点配置超过加密大小上限')
     return new Promise((resolve,reject)=>{

+ 2 - 0
desktop/data-home.mjs

@@ -0,0 +1,2 @@
+// Source-mode counterpart; packaging copies the shared module beside main.mjs.
+export { resolveDataHome } from '../bin/lib/data-home.mjs'

+ 45 - 0
desktop/environment-host.mjs

@@ -0,0 +1,45 @@
+import {app,desktopCapturer,dialog,screen,shell,systemPreferences} from 'electron'
+import {hostname} from 'node:os'
+import {readFileSync,writeFileSync,mkdirSync} from 'node:fs'
+import {join} from 'node:path'
+import {randomUUID} from 'node:crypto'
+import {request} from 'node:http'
+import {execFile} from 'node:child_process'
+import {BrowserEnvironment} from './browser-environment.mjs'
+
+function exchange(record,body){return new Promise((resolve,reject)=>{const url=new URL('/desktop/environment',record.url);if(url.protocol!=='http:'||url.hostname!=='127.0.0.1')return reject(new Error('桌面服务地址无效'));const bytes=Buffer.from(JSON.stringify(body)),req=request(url,{method:'POST',headers:{'x-yaoyao-desktop-token':record.token,'content-type':'application/json','content-length':bytes.length}},res=>{let size=0;const chunks=[];res.on('data',chunk=>{size+=chunk.length;if(size>256*1024)res.destroy(new Error('桌面命令超过限制'));else chunks.push(chunk)});res.on('error',reject);res.on('end',()=>{try{if(res.statusCode!==200)throw new Error('桌面服务未连接');resolve(JSON.parse(Buffer.concat(chunks)))}catch(error){reject(error)}})});req.on('error',reject);req.setTimeout(5000,()=>req.destroy(new Error('桌面连接超时')));req.end(bytes)})}
+export class DesktopEnvironmentHost {
+ constructor({manager,root,dataRoot}){this.manager=manager;this.root=root;this.dataRoot=dataRoot;this.id=randomUUID();this.results=[];this.running=new Set();this.closed=false;this.browser=new BrowserEnvironment(join(dataRoot,'bot-browsers'));this.approved=new Set();this.permissionsFile=join(dataRoot,'computer-permissions.json');try{const list=JSON.parse(readFileSync(this.permissionsFile,'utf8'));if(Array.isArray(list))for(const key of list)if(/^[a-f0-9]{64}$/.test(key))this.approved.add(key)}catch{}this.frames=new Map()}
+ info(){return {id:this.id,name:hostname(),platform:process.platform,screen:process.platform==='darwin'&&systemPreferences.getMediaAccessStatus('screen')==='granted',accessibility:process.platform==='darwin'&&systemPreferences.isTrustedAccessibilityClient(false),approved:[...this.approved]}}
+ async revoke(){this.approved.clear();this.save();this.frames.clear();this.id=randomUUID()}
+ save(){mkdirSync(this.dataRoot,{recursive:true,mode:0o700});writeFileSync(this.permissionsFile,JSON.stringify([...this.approved]),{mode:0o600})}
+ async execute(c){const epoch=this.id;if(Date.now()>c.deadline||this.closed)throw new Error('桌面请求已过期');if(!/^[a-f0-9]{64}$/.test(c.owner))throw new Error('桌面请求身份无效')
+  if(c.operation==='authorize'){
+   if(process.platform!=='darwin')throw new Error('此电脑暂不支持本机控制')
+   const {response}=await dialog.showMessageBox({type:'question',title:'授权本机控制',message:`允许夭夭账号「${String(c.account??'当前账号').slice(0,100)}」的机器人查看和操作这台 Mac?`,detail:'授权后,机器人和该账号的 Web、手机端可以查看屏幕,并在接管时操作鼠标和键盘。你可以在夭夭菜单中撤销。',buttons:['取消','允许并检查系统权限'],defaultId:0,cancelId:0})
+   if(response!==1||Date.now()>c.deadline||this.closed||epoch!==this.id)throw new Error('本机控制授权已取消')
+   this.approved.add(c.owner);this.save()
+   if(!systemPreferences.isTrustedAccessibilityClient(false))systemPreferences.isTrustedAccessibilityClient(true)
+   if(systemPreferences.getMediaAccessStatus('screen')!=='granted'){await desktopCapturer.getSources({types:['screen'],thumbnailSize:{width:1,height:1}}).catch(()=>{});if(systemPreferences.getMediaAccessStatus('screen')!=='granted')await shell.openExternal('x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture')}
+   return {ok:true}
+  }
+  if(!['local','browser'].includes(c.mode)||!['persistent','temporary'].includes(c.profile)||!['open','view','input','browser','browser-state'].includes(c.operation))throw new Error('桌面命令无效')
+  if(c.mode==='browser'){
+   if(!/^[a-f0-9]{64}$/.test(c.resource))throw new Error('浏览器资源无效')
+   if(c.operation==='browser-state')return this.browser.state(c.resource)
+   if(c.operation==='open'){await this.browser.open(c.resource,c.profile);return {ok:true}}
+   if(c.operation==='browser')return this.browser.action(c.resource,c.profile,c.action)
+   if(c.operation==='view')return this.browser.view(c.resource)
+   return this.browser.input(c.resource,c.action,c.frame)
+  }
+  const info=this.info();if(!info.approved.includes(c.owner)||!info.screen||!info.accessibility)throw new Error('请在桌面端授权,并在系统设置开启屏幕录制和辅助功能')
+  if(c.operation==='open')return {ok:true}
+  if(c.operation==='view'){const d=screen.getPrimaryDisplay(),sources=await desktopCapturer.getSources({types:['screen'],thumbnailSize:{width:1600,height:1200}}),source=sources.find(s=>s.display_id===String(d.id));if(!source||source.thumbnail.isEmpty())throw new Error('系统尚未允许读取屏幕');const dimensions=source.thumbnail.getSize();this.frames.set(c.resource,{display:d.id,...dimensions,bounds:d.bounds});return {data:source.thumbnail.toPNG().toString('base64'),...dimensions}}
+  if(c.operation!=='input')throw new Error('本机操作无效')
+  const f=this.frames.get(c.resource),d=screen.getPrimaryDisplay();if(!f||f.display!==d.id||JSON.stringify(f.bounds)!==JSON.stringify(d.bounds)||f.width!==c.frame?.width||f.height!==c.frame?.height)throw new Error('显示器已变化,请刷新画面')
+  return new Promise((resolve,reject)=>{const child=execFile(join(this.root,app.isPackaged?'computer-helper':'computer-helper-dev'),[],{timeout:10000,maxBuffer:65536},(error,stdout,stderr)=>{if(error)reject(new Error(stderr.trim()||'系统未接受电脑输入'));else{try{resolve(JSON.parse(stdout))}catch{reject(new Error('电脑助手响应无效'))}}});child.stdin.end(JSON.stringify({action:c.action,frame:f}))})
+ }
+ async cycle(){if(this.closed)return;try{const record=await this.manager.readRecord();if(record){const verified=await this.manager.verify(record);record.url=verified.url;if(this.instance&&this.instance!==record.instanceId){this.results=[];this.id=randomUUID();await this.browser.close()}this.instance=record.instanceId;const sent=this.results.slice(),value=await exchange(record,{host:this.info(),results:sent});this.results.splice(0,sent.length);for(const c of value.commands??[]){if(this.running.has(c.id))continue;this.running.add(c.id);const epoch=this.id;void this.execute(c).then(value=>{if(epoch===this.id)this.results.push({id:c.id,value})},error=>{if(epoch===this.id)this.results.push({id:c.id,error:String(error.message).slice(0,500)})}).finally(()=>this.running.delete(c.id))}}}catch{}finally{if(!this.closed)this.timer=setTimeout(()=>void this.cycle(),400)}}
+ start(){this.closed=false;void this.cycle()}
+ async close(){this.closed=true;clearTimeout(this.timer);this.id=randomUUID();this.results=[];await this.browser.close()}
+}

+ 20 - 8
desktop/main.mjs

@@ -7,8 +7,11 @@ import { DesktopServiceManager } from './service-manager.mjs'
 import { DesktopRunnerManager } from './runner-manager.mjs'
 import { DesktopPreferences } from './preferences.mjs'
 import { DesktopCredentials } from './credentials.mjs'
-import { synchronizeLocalService, stopLocalService } from './service-sync.mjs'
+import { synchronizeLocalService, stopLocalService, migrateLocalData } from './service-sync.mjs'
+import { resolveDataHome } from './data-home.mjs'
+import { DesktopEnvironmentHost } from './environment-host.mjs'
 import { DesktopUpdateManager } from './update-manager.mjs'
+import { installComputerViewer } from './computer-viewer.mjs'
 
 const desktopRoot = dirname(fileURLToPath(import.meta.url))
 const fixtureHome = process.env.HERMES_YAOYAO_DESKTOP_TEST_HOME
@@ -18,7 +21,10 @@ app.setName('夭夭')
 if (!app.requestSingleInstanceLock()) { app.quit() }
 else {
   let window, tray, manager, runnerManager, quitting = false, closing = false, timer
-  let updateWindow, updater
+  let updateWindow, updater, environmentHost
+  const closeComputerViewer = installComputerViewer({ owner: () => window, origin: () => manager?.state.url,
+    preload: join(desktopRoot, 'preload.cjs'), quitting: () => quitting })
+  app.on('will-quit', closeComputerViewer)
   const updateURL = pathToFileURL(join(desktopRoot, 'update.html')).href
   const bootURL = pathToFileURL(join(desktopRoot, 'boot.html')).href
   const root = app.isPackaged ? join(process.resourcesPath, 'runtime') : join(app.getAppPath(), '.desktop-build')
@@ -26,7 +32,7 @@ else {
   mkdirSync(logRoot, { recursive: true })
   const logFile = join(logRoot, 'server.log')
   const log = text => appendFileSync(logFile, `${new Date().toISOString()} ${text.trim()}\n`, { mode: 0o600 })
-  const home = fixtureHome || process.env.HERMES_YAOYAO_HOME || join(homedir(), '.hermes-yaoyao')
+  const home = fixtureHome || resolveDataHome(process.env.YAOYAO_HOME || process.env.HERMES_YAOYAO_HOME)
   const preferences = new DesktopPreferences(home)
   let startHidden = false
   const port = Number(process.env.HERMES_YAOYAO_DESKTOP_PORT || 15300)
@@ -55,7 +61,7 @@ else {
       if (action === 'check') return updater.check()
       if (action === 'download') return updater.download()
       if (action === 'cancel') { updater.cancel(); return updater.snapshot() }
-      if (action === 'release') { safeExternal(updater.snapshot().releasePageUrl || 'https://github.com/Lsamien/hermes-yaoyao/releases'); return }
+      if (action === 'release') { safeExternal(updater.snapshot().releasePageUrl || 'https://github.com/Lsamien/yaoyao/releases'); return }
       const path = await updater.verifiedFile()
       if (closing || quitting || !trustedUpdate(event)) return
       if (action === 'folder') shell.showItemInFolder(path)
@@ -111,8 +117,10 @@ else {
       catch { return false }
     }
     window.webContents.session.setPermissionCheckHandler((contents, permission, origin) =>
-      trustedService(contents, origin) && ['media', 'notifications', 'clipboard-sanitized-write'].includes(permission))
+      closeComputerViewer.owns(contents) ? ['fullscreen', 'clipboard-sanitized-write'].includes(permission)
+        : trustedService(contents, origin) && ['media', 'notifications', 'clipboard-sanitized-write'].includes(permission))
     window.webContents.session.setPermissionRequestHandler((contents, permission, callback, details) => {
+      if (closeComputerViewer.owns(contents)) { callback(['fullscreen', 'clipboard-sanitized-write'].includes(permission)); return }
       if (!trustedService(contents, details.requestingUrl)) { callback(false); return }
       if (permission === 'media' && details.mediaTypes?.length && details.mediaTypes.every(type => type === 'audio')) {
         void systemPreferences.askForMediaAccess('microphone').then(callback, () => callback(false))
@@ -155,6 +163,7 @@ else {
     // Both cleanup and the final quit must run after that callback unwinds.
     setImmediate(() => { void (async()=>{
       try {
+        await environmentHost?.close()
         await runnerManager?.stop()
         if (stopBackground) await manager?.stopBackground()
         else await manager?.stop()
@@ -192,6 +201,7 @@ else {
       fetchImpl: (...args) => net.fetch(...args) })
     app.setAboutPanelOptions({applicationName:'夭夭',applicationVersion:packageVersion,version:`${String(buildInfo.commit).slice(0,12)}${buildInfo.dirty?' · 工作区快照':''}`})
     manager = new DesktopServiceManager({ home, port, version: packageVersion, log, onState: stateChanged,
+      prepareHome: !fixtureHome ? onProgress => migrateLocalData({ home, port, root, onProgress }) : undefined,
       stopBackground: (app.isPackaged && !fixtureHome) || (fixtureHome && process.env.HERMES_YAOYAO_DESKTOP_TEST_SYNC === '1')
         ? onProgress => stopLocalService({home,port,root,fixture:Boolean(fixtureHome),onProgress}) : undefined,
       synchronize: (app.isPackaged && !fixtureHome) || (fixtureHome && process.env.HERMES_YAOYAO_DESKTOP_TEST_SYNC === '1')
@@ -210,9 +220,9 @@ else {
         return utilityProcess.fork(join(root, 'server.mjs'), [], { cwd: root, env, stdio: 'pipe' })
       },
     })
+    environmentHost=new DesktopEnvironmentHost({manager,root,dataRoot:app.getPath('userData')})
     const { parseRunnerConfiguration } = await import(pathToFileURL(join(root,'runner-config.mjs')).href)
-    mkdirSync(home,{recursive:true,mode:0o700})
-    const credentials=new DesktopCredentials({home:realpathSync(home),helper:join(root,app.isPackaged?'keychain-helper':'keychain-helper-dev'),legacyDecrypt:async bytes=>(await safeStorage.decryptStringAsync(bytes)).result})
+    const credentials=new DesktopCredentials({home,helper:join(root,app.isPackaged?'keychain-helper':'keychain-helper-dev'),legacyDecrypt:async bytes=>(await safeStorage.decryptStringAsync(bytes)).result})
     runnerManager = new DesktopRunnerManager({home,validate:parseRunnerConfiguration,
       encrypt:value=>credentials.encrypt(value),
       decrypt:bytes=>credentials.decrypt(bytes),
@@ -242,6 +252,7 @@ else {
         { type: 'separator' },
         { role: 'hide', label: '隐藏夭夭' }, { role: 'hideOthers', label: '隐藏其他' }, { role: 'unhide', label: '显示全部' },
         { type: 'separator' },
+        {label:'撤销本机控制授权',click:()=>environmentHost.revoke()},
         { id:'desktop-quit',label:'退出夭夭(后台继续运行)',accelerator:'CommandOrControl+Q',click:()=>requestQuit() },
         { id:'desktop-stop-and-quit',label:'停止后台服务并退出',click:()=>requestQuit(true) }] },
       {label:'执行节点',submenu:[{id:'runner-status',label:'未配置执行节点',enabled:false},{type:'separator'},
@@ -260,6 +271,7 @@ else {
     powerMonitor.on('resume', () => { if(!closing&&!quitting)void manager.check() })
     timer = setInterval(() => { void manager.check() }, 10_000); timer.unref()
     await manager.start().catch(error => log(error.message))
-    if(!closing)await runnerManager.start().catch(error=>{runnerManager.publish(error.message)})
+    if(!closing)environmentHost.start()
+    if(!closing&&manager.state.phase==='ready')await runnerManager.start().catch(error=>{runnerManager.publish(error.message)})
   }).catch(error => { log(error.stack || error.message); quitting = true; app.quit() })
 }

+ 2 - 1
desktop/preferences.mjs

@@ -1,9 +1,10 @@
 import {readFile,writeFile,rename,mkdir,rm} from 'node:fs/promises'
 import {join} from 'node:path'
 import {randomUUID} from 'node:crypto'
+import {homedir} from 'node:os'
 export class DesktopPreferences {
   constructor(home){this.home=home;this.path=join(home,'desktop-preferences.json');this.value={backgroundAtLogin:false}}
-  async load(){try{const value=JSON.parse(await readFile(this.path,'utf8'));this.value={backgroundAtLogin:value.backgroundAtLogin===true}}catch(error){if(error.code!=='ENOENT')throw new Error('无法读取桌面偏好设置')}return this.value}
+  async load(){try{let source;try{source=await readFile(this.path,'utf8')}catch(error){if(error.code!=='ENOENT'||this.home!==join(homedir(),'.yaoyao'))throw error;source=await readFile(join(homedir(),'.hermes-yaoyao','desktop-preferences.json'),'utf8')}const value=JSON.parse(source);this.value={backgroundAtLogin:value.backgroundAtLogin===true}}catch(error){if(error.code!=='ENOENT')throw new Error('无法读取桌面偏好设置')}return this.value}
   async setBackgroundAtLogin(enabled){
     const value={backgroundAtLogin:enabled===true},temporary=this.path+'.'+randomUUID()
     await mkdir(this.home,{recursive:true,mode:0o700})

+ 7 - 0
desktop/preload.cjs

@@ -3,4 +3,11 @@ contextBridge.exposeInMainWorld('yaoyaoDesktop', Object.freeze({
   status: () => ipcRenderer.invoke('desktop:status'),
   retry: () => ipcRenderer.invoke('desktop:retry'),
   logs: () => ipcRenderer.invoke('desktop:logs'),
+  openComputer: id => ipcRenderer.invoke('desktop-computer:open', id),
+  computerClosed: () => ipcRenderer.invoke('desktop-computer:closed'),
+  onComputerClose: callback => {
+    const listener = () => callback()
+    ipcRenderer.on('desktop-computer:request-close', listener)
+    return () => ipcRenderer.removeListener('desktop-computer:request-close', listener)
+  },
 }))

+ 1 - 0
desktop/service-manager.mjs

@@ -113,6 +113,7 @@ export class DesktopServiceManager {
     const generation = ++this.generation
     this.publish({ phase: 'starting', message: '正在启动本地服务…' })
     try {
+      await this.options.prepareHome?.(message => this.publish({ phase: 'starting', message }))
       await mkdir(this.options.home, { recursive: true, mode: 0o700 })
       this.root = await realpath(this.options.home)
       this.updateNotice = undefined

+ 1 - 0
desktop/service-sync.mjs

@@ -5,6 +5,7 @@ import { join } from 'node:path'
  * The renderer never receives its configuration or a process-control bridge. */
 export const synchronizeLocalService = options => serviceCommand({...options,action:'sync'})
 export const stopLocalService = options => serviceCommand({...options,action:'stop'})
+export const migrateLocalData = options => serviceCommand({...options,action:'migrate'})
 function serviceCommand({ home, port, root, fixture, environment, onProgress = () => {}, action }) {
   return new Promise((done, reject) => {
     const runtimeRoot = join(root, 'web-service')

+ 3 - 3
desktop/update-manager.test.mjs

@@ -7,18 +7,18 @@ import { createHash } from 'node:crypto'
 import { DesktopUpdateManager, githubDownload } from './update-manager.mjs'
 
 const hash = bytes => createHash('sha256').update(bytes).digest('hex')
-const prefix = 'https://github.com/Lsamien/hermes-yaoyao/releases/download/v0.4.2/'
+const prefix = 'https://github.com/Lsamien/yaoyao/releases/download/v0.4.2/'
 const name = 'Yaoyao-0.4.2-arm64.dmg', data = Buffer.from('fixture-image')
 async function fixture(overrides = {}) {
   const home = await mkdtemp(join(tmpdir(), 'yaoyao-update-unit-'))
   const sums = Buffer.from(`${hash(data)}  ${name}\n`)
-  const release = { manifest: { webVersion: '0.4.2' }, commit: 'a'.repeat(40), notes: 'Notes', releasePageUrl: 'https://github.com/Lsamien/hermes-yaoyao/releases/tag/v0.4.2', assets: [
+  const release = { manifest: { webVersion: '0.4.2' }, commit: 'a'.repeat(40), notes: 'Notes', releasePageUrl: 'https://github.com/Lsamien/yaoyao/releases/tag/v0.4.2', assets: [
     { name, size: data.length, digest: `sha256:${hash(data)}`, url: prefix + name },
     { name: 'SHA256SUMS.txt', size: sums.length, digest: `sha256:${hash(sums)}`, url: prefix + 'SHA256SUMS.txt' },
   ] }
   const calls = [], verified = []
   const manager = new DesktopUpdateManager({ version: '0.4.1', arch: 'arm64', platform: 'darwin', cacheRoot: home,
-    source: 'https://github.com/Lsamien/hermes-yaoyao.git', inspect: async () => release,
+    source: 'https://github.com/Lsamien/yaoyao.git', inspect: async () => release,
     compare: (a, b) => Number(a.split('.').at(-1)) - Number(b.split('.').at(-1)),
     fetchImpl: async url => { calls.push(url); return new Response(url.endsWith('.dmg') ? data : sums) },
     verifyImage: async path => { verified.push(path) }, ...overrides })

+ 3 - 3
desktop/update-window.test.mjs

@@ -40,8 +40,8 @@ test('native update window works without a Web service, verifies a real DMG and
     assert.equal(denied, true)
     const opened = app.waitForEvent('window')
     await app.evaluate(({ net, shell, Menu }, fixture) => {
-      const tag = `v${fixture.version}`, api = 'https://api.github.com/repos/Lsamien/hermes-yaoyao'
-      const prefix = `https://github.com/Lsamien/hermes-yaoyao/releases/download/${tag}/`
+      const tag = `v${fixture.version}`, api = 'https://api.github.com/repos/Lsamien/yaoyao'
+      const prefix = `https://github.com/Lsamien/yaoyao/releases/download/${tag}/`
       const commit = 'a'.repeat(40)
       net.fetch = async url => {
         const path = String(url)
@@ -50,7 +50,7 @@ test('native update window works without a Web service, verifies a real DMG and
           { name: 'SHA256SUMS.txt', size: fixture.sums.length, state: 'uploaded', browser_download_url: prefix + 'SHA256SUMS.txt' },
         ] })
         if (path === `${api}/git/ref/tags/${tag}`) return Response.json({ object: { type: 'commit', sha: commit } })
-        if (path === `https://raw.githubusercontent.com/Lsamien/hermes-yaoyao/${commit}/release.json`) return Response.json({ schemaVersion: 1, releaseVersion: fixture.version, webVersion: fixture.version, gitTag: tag })
+        if (path === `https://raw.githubusercontent.com/Lsamien/yaoyao/${commit}/release.json`) return Response.json({ schemaVersion: 1, releaseVersion: fixture.version, webVersion: fixture.version, gitTag: tag })
         if (path === prefix + 'SHA256SUMS.txt') return new Response(fixture.sums)
         if (path === prefix + fixture.name) return new Response(Buffer.from(fixture.data, 'base64'))
         throw new Error('Unexpected update request')

+ 2 - 2
docker.env.example

@@ -2,7 +2,7 @@
 HERMES_YAOYAO_BIND_ADDRESS=127.0.0.1
 HERMES_YAOYAO_PUBLISHED_PORT=15300
 # 可选:使用已经导入或发布的镜像;留空时使用本地构建名称。
-# HERMES_YAOYAO_IMAGE=hermes-yaoyao:local
+# HERMES_YAOYAO_IMAGE=yaoyao:local
 # YAOYAO_DESKTOP_IMAGE=hermes-yaoyao-desktop:0.4.0
 
 # 部署步骤见 docs/docker-install.md;使用 docker compose --env-file docker.env 启动。
@@ -11,7 +11,7 @@ HERMES_YAOYAO_PUBLISHED_PORT=15300
 HERMES_YAOYAO_UPSTREAM=http://host.docker.internal:9119
 HERMES_YAOYAO_CHAT_CACHE_MODE=prefer-local
 # 官方稳定发布源;自定义 Git 仓库可覆盖。容器仍由部署者重建升级。
-HERMES_YAOYAO_RELEASE_SOURCE=https://github.com/Lsamien/hermes-yaoyao.git
+HERMES_YAOYAO_RELEASE_SOURCE=https://github.com/Lsamien/yaoyao.git
 # 首次登录后在 Web 系统设置中保存 Hermes 连接凭据。
 # 使用 compose.desktops.yaml 可同时部署固定数量的共享桌面容器。
 # 桌面数量以 Compose 为准,Web 仅连接已有桌面;详见 docs/docker-install.md。

+ 2 - 2
docs/agent-install.md

@@ -1,4 +1,4 @@
-# 部署夭夭 Web
+# 部署夭夭 AI
 
 ## 前提
 
@@ -26,7 +26,7 @@ docker compose --env-file docker.env config --quiet
 docker compose --env-file docker.env up -d --build
 ```
 
-Compose 将 Web 的 15300 端口发布到宿主机,使用 `yaoyao-data` 命名卷保存 `/var/lib/hermes-yaoyao`。宿主机连接、访问配置、备份及升级见 [Docker 部署说明](docker-install.md)。
+Compose 将 Web 的 15300 端口发布到宿主机,使用 `yaoyao-data` 命名卷保存 `/home/node/.yaoyao`。宿主机连接、访问配置、备份及升级见 [Docker 部署说明](docker-install.md)。
 
 ## 验收
 

+ 2 - 2
docs/chat-working-directory.md

@@ -1,6 +1,6 @@
 # 聊天工作目录
 
-夭夭 Web 与移动端通过同一个服务端执行规则,使用所选基础 Hermes Profile 的 `terminal.cwd`。客户端不决定服务器路径,也不把手机沙盒、Web 启动目录或历史会话目录作为覆盖值。
+夭夭 AI 与移动端通过同一个服务端执行规则,使用所选基础 Hermes Profile 的 `terminal.cwd`。客户端不决定服务器路径,也不把手机沙盒、Web 启动目录或历史会话目录作为覆盖值。
 
 - 新建普通聊天和 Bot 模式聊天时,服务端读取该 Profile 的 `/api/config`,将 `terminal.cwd` 传给 Hermes。
 - 旧会话恢复只恢复状态;在空闲会话下一次发送消息或上传附件前,使用 `session.cwd.set` 对齐工作目录。每次新一轮执行读取当前配置,目录已经一致时不重建终端。
@@ -9,4 +9,4 @@
 - `.`、`~` 和相对路径交给实际执行的 Hermes 主机解析。需要固定目录时应在 Hermes 配置中填写该主机上的绝对路径。
 - 扫码节点和远端 Agent 在目标服务读取自己的 Profile 配置,保留授权身份;原生 Hermes Bot 入口继续由其自身管理工作区。
 
-这是夭夭 Web 服务端的规则,两端客户端无需额外获取或缓存工作路径。部署更新后的 Web 服务后,移动端通过该服务发送的下一轮消息即可使用此规则;不迁移历史文件,不修改 Hermes 全局配置。
+这是夭夭 AI 服务端的规则,两端客户端无需额外获取或缓存工作路径。部署更新后的 Web 服务后,移动端通过该服务发送的下一轮消息即可使用此规则;不迁移历史文件,不修改 Hermes 全局配置。

+ 1 - 1
docs/computer-maintenance.md

@@ -30,7 +30,7 @@ node .runner-build/runner-maintenance.mjs restore --config /安全目录/runner.
 node .runner-build/runner-maintenance.mjs rebuild --config /安全目录/runner.json --environment UUID
 ```
 
-CLI 默认数据目录为配置旁的 `state/<runnerId>`。App 托管节点的数据目录是 `~/.hermes-yaoyao/runner-state/<runnerId>`,维护时用 `--home` 显式指定该目录,并使用原始私有配置文件;App 加密配置不能直接当作 JSON 读取。
+CLI 默认数据目录为配置旁的 `state/<runnerId>`。App 托管节点的数据目录是 `~/.yaoyao/runner-state/<runnerId>`,维护时用 `--home` 显式指定该目录,并使用原始私有配置文件;App 加密配置不能直接当作 JSON 读取。
 
 备份包含工作文件及持久浏览器资料,不包含运行中的内存、进程、模型密钥、Runner 身份或整个宿主 HOME。目录设为仅当前用户访问,浏览器资料仍可能包含登录状态,应作为私有数据保存。每份备份有账号/环境归属和逐文件校验;普通文件、目录、符号链接保留,不复制运行时 socket。上限为 20 GiB、20 万项。
 

+ 3 - 3
docs/docker-install.md

@@ -1,4 +1,4 @@
-# Docker 部署夭夭 Web
+# Docker 部署夭夭 AI
 
 ## 准备
 
@@ -94,14 +94,14 @@ node yaoyao-runner/runner.mjs --config /完整路径/runner.json
 
 ## 数据与备份
 
-Compose 使用 `yaoyao-data` 命名卷,挂载到 `/var/lib/hermes-yaoyao`。账号、SQLite 数据库、聊天缓存、文件及密钥随数据卷持久保存。固定桌面部署还必须备份每台桌面的 `desktop-*-workspace` 卷;`desktop-*-ipc` 卷只是连接通道。
+Compose 使用 `yaoyao-data` 命名卷,挂载到 `/home/node/.yaoyao`。账号、SQLite 数据库、聊天缓存、文件及密钥随数据卷持久保存。固定桌面部署还必须备份每台桌面的 `desktop-*-workspace` 卷;`desktop-*-ipc` 卷只是连接通道。
 
 备份时先停止 Web,然后复制完整数据目录,再启动服务:
 
 ```sh
 mkdir -p backups
 docker compose --env-file docker.env stop web
-docker compose --env-file docker.env cp web:/var/lib/hermes-yaoyao/. ./backups/
+docker compose --env-file docker.env cp web:/home/node/.yaoyao/. ./backups/
 docker compose --env-file docker.env start web
 ```
 

+ 6 - 2
docs/github-updates.md

@@ -1,6 +1,6 @@
 # GitHub 版本升级
 
-官方发布源为 `https://github.com/Lsamien/hermes-yaoyao.git`。检查使用公开稳定 Release,不需要 GitHub 账号、访问令牌或安装 GitHub CLI;尚未发布的标签和预发布版本不会被选为更新。
+官方发布源为 `https://github.com/Lsamien/yaoyao.git`。检查使用公开稳定 Release,不需要 GitHub 账号、访问令牌或安装 GitHub CLI;尚未发布的标签和预发布版本不会被选为更新。
 
 ## Web
 
@@ -22,8 +22,12 @@ macOS 独立 Web 继续使用现有升级事务:构建新版本、等待任务
 
 ## 旧安装迁移
 
-加载新版本后,空发布源以及官方旧仓库 `git.samien.cn/samien/hermes-yaoyao`、`192.168.153.8:3000/samien/hermes-yaoyao` 的无凭据 HTTP(S) 地址会映射到 GitHub;兼容 `.git` 后缀、尾部斜杠和既有 `git@git.samien.cn:samien/hermes-yaoyao.git` 地址。其他用户自定义仓库保持原样。
+加载新版本后,空发布源、`github.com/Lsamien/hermes-yaoyao`(包括 HTTPS 与 SSH)以及官方旧仓库 `git.samien.cn/samien/hermes-yaoyao`、`192.168.153.8:3000/samien/hermes-yaoyao` 的无凭据 HTTP(S) 地址会映射到 GitHub;兼容 `.git` 后缀、尾部斜杠和既有 `git@git.samien.cn:samien/hermes-yaoyao.git` 地址。其他用户自定义仓库保持原样。
 
 运行时先使用归一化后的源;下次生成或更新本应用管理的 LaunchAgent 配置时持久化,保留地址、TLS、上游等其他环境变量。不会直接改写用户维护的环境文件。
 
 旧程序不会凭空获得迁移能力:首次需手动安装包含此功能的新 App,或更新源码并重启。既有发布标签和安装包不会被改写。
+
+从 v0.4.4 起默认应用数据为 `~/.yaoyao`,兼容读取旧配置并迁移 `~/.hermes-yaoyao`。迁移按服务所有权和 SQLite 锁检查,旧升级事务完成后才改名;上传与缓存索引、通知配置及更新记录中的内部路径一起更新。新旧目录都已有数据时不覆盖。`YAOYAO_HOME` 可覆盖默认值,既有 `HERMES_YAOYAO_HOME` 继续有效。
+
+现有 LaunchAgent 标识和 `~/.local/share/hermes-yaoyao` 程序目录用于延续服务与回滚历史,不是 Web 应用数据目录。客户端历史缓存与身份命名空间也保留兼容。

+ 4 - 4
docs/macos-app.md

@@ -1,6 +1,6 @@
 # macOS App 与本地服务
 
-App、Web 服务、Vue 界面和 Runner 同仓维护。正式 App 在每个构建首次启动时,将较旧的本机 Web 同步为配套构建;已有更新的 Web 保留。Web 由独立 LaunchAgent 运行,App 连接它。源码开发模式仍使用包内子进程。默认数据目录为 `~/.hermes-yaoyao`,默认 Web 端口为 15300。Hermes 是独立基础运行时,由本地服务检测并按既有托管逻辑启动;隔离电脑另需本机 Docker 或 Podman。
+App、Web 服务、Vue 界面和 Runner 同仓维护。正式 App 在每个构建首次启动时,将较旧的本机 Web 同步为配套构建;已有更新的 Web 保留。Web 由独立 LaunchAgent 运行,App 连接它。源码开发模式仍使用包内子进程。默认数据目录为 `~/.yaoyao`,默认 Web 端口为 15300。Hermes 是独立基础运行时,由本地服务检测并按既有托管逻辑启动;隔离电脑另需本机 Docker 或 Podman。
 
 ## 生命周期与权限
 
@@ -31,7 +31,7 @@ App 新增“检查 App 更新…”窗口,直接从官方 GitHub 检查稳定
 - 原有旧版服务缺少协作暂停接口时,需要确认无未完成任务及本机服务进程的客户端连接。忙碌时 App 先连接已验证的原 Web,在菜单提示同步待完成并提供重试,不强行中断聊天。不能验证身份、TLS 或数据归属的服务不接管,启动页显示错误及恢复操作。
 - 回退单独通过 Web 的回滚入口处理。只在数据库结构兼容时切回程序并保留现有数据;结构已变化或缺少兼容性记录时拒绝直接降级,不能用旧备份覆盖升级后的新消息。
 
-正式后台服务的程序位于 `~/.local/share/hermes-yaoyao/releases`,`current` 指向启用的构建;数据仍在 `~/.hermes-yaoyao`。App 签名资源不被 Web 更新器改写。开发模式的包内服务仍随开发 App 管理,不提供服务内更新。
+正式后台服务的程序位于 `~/.local/share/hermes-yaoyao/releases`,`current` 指向启用的构建;数据仍在 `~/.yaoyao`。App 签名资源不被 Web 更新器改写。开发模式的包内服务仍随开发 App 管理,不提供服务内更新。
 
 ## 构建与验收
 
@@ -40,7 +40,7 @@ npm run desktop:build
 npm run desktop:test
 npm run desktop:pack
 codesign --verify --deep --strict desktop-release/mac-arm64/夭夭.app
-hdiutil verify desktop-release/Yaoyao-0.4.3-arm64.dmg
+hdiutil verify desktop-release/Yaoyao-0.4.4-arm64.dmg
 ```
 
 开发 App 的 6 项测试通过:真实内置服务启动、账号与 Runner 连接、关闭窗口保持运行、服务崩溃恢复、外部客户端不误停服务、退出清理、加密配置再次启动、偏好保存及手动重新打开、版本不符拒绝、钥匙串失败保护。另有更新器 14 项定向测试通过,包含 App 禁用源码更新及回退。
@@ -58,4 +58,4 @@ Electron 初始化时设置其钥匙串项目名称([v43.4.0 源码](https://g
 
 最终实际签名 App 的完整 Runner 导入、加密保存、服务崩溃恢复、窗口关闭保持连接、退出清理和再次打开自动连接均已通过;另有独立的核心服务生命周期测试通过。新加密助手在实际签名 App 中验证所属路径和签名团队。安装包经挂载检查,开发专用助手没有进入分发包。
 
-v0.4.3 同时发布 Web 与 macOS Apple Silicon DMG,见 [发布说明](releases/v0.4.3.md)。正式 App 首次启动按上文同步规则升级较旧的本机 Web;已有更新版本保留。独立预览应指定独立 `HERMES_YAOYAO_HOME` 和 `HERMES_YAOYAO_DESKTOP_PORT`。
+v0.4.4 同时发布 Web 与 macOS Apple Silicon DMG,见 [发布说明](releases/v0.4.4.md)。正式 App 首次启动按上文同步规则升级较旧的本机 Web;已有更新版本保留。独立预览应指定独立 `HERMES_YAOYAO_HOME` 和 `HERMES_YAOYAO_DESKTOP_PORT`。

+ 25 - 0
docs/releases/v0.4.4.md

@@ -0,0 +1,25 @@
+# 夭夭 AI v0.4.4
+
+本次发布 Web、macOS Apple Silicon 桌面版和 Android 1.3(162)正式签名 APK。
+
+- Bot 模式桌面接管参考 OpenMausBot,打开独立的大画面窗口;支持直接键鼠操作、适应窗口、原始大小、全屏和收起的键盘面板,关闭窗口前交还控制权。
+- Web 默认数据目录改为 `~/.yaoyao`。旧版 `~/.hermes-yaoyao` 整体迁移,保留账号、会话、文件、加密密钥和执行节点状态,并迁移内部文件索引。默认新旧目录同时有数据时保留两份数据并提示处理,不自动覆盖。
+- 统一版本检查、版本比较、安装包下载与源码入口为 https://github.com/Lsamien/yaoyao 。旧官方地址自动归一化,自定义仓库保留。
+- 产品介绍统一为“夭夭 AI”,采用 Apache-2.0 开源许可证,保留第三方许可与署名。
+
+## 下载
+
+- `Yaoyao-0.4.4-arm64.dmg`:macOS Apple Silicon。使用 Apple Development 开发签名,未做 Apple 公证。
+- `Yaoyao-1.3-162-android.apk`:Android 12 及以上,使用本次新建的正式发布密钥签名。若设备上已有使用其他签名的开发版,不能直接覆盖安装。
+- `Yaoyao-0.4.4-source.tar.gz`:Web 与桌面端源码。
+- `SHA256SUMS.txt`:以上附件的 SHA-256 校验。
+
+## 升级与迁移
+
+App 首次启动等待本机服务空闲,迁移数据并同步较旧的 Web;较新的独立 Web 继续保留。Web 仍可独立升级。旧升级器的事务先在原目录完成,之后由新版本迁移助手等待空闲并重启至新目录。
+
+支持 `YAOYAO_HOME`,兼容既有 `HERMES_YAOYAO_HOME`。显式自定义目录保持不变。原有 LaunchAgent 标识、程序发布目录、浏览器缓存键和账号身份命名空间保留兼容,避免丢失已有安装或重置身份;实际默认应用数据写入 `~/.yaoyao`。
+
+Docker 继续使用原 Compose 项目和 `yaoyao-data` 命名卷,容器内数据目录改为 `/home/node/.yaoyao`。重新构建并启动 Compose 即可复用原卷。不要执行删除数据卷的操作。
+
+迁移后本地虚拟机按新目录重新挂载持久工作区和浏览器资料。原来的已停止容器保留为带 `before-data-move` 后缀的备份,未自动删除其可写层。

+ 33 - 0
docs/verification/2026-09-10-bot-environments/README.md

@@ -0,0 +1,33 @@
+# Bot 本机与浏览器环境验收
+
+对照 OpenMausBot 的 `src/lib/local-computer.ts`、`server/local-computer.ts`、`server/browser-live.ts`、`src/components/BrowserPanel.tsx`:环境卡片显示连接电脑,本机显式申请系统权限;浏览器使用独立资料、标签页、地址栏、接管和交还,断线清除画面且不恢复输入权限。群聊仍只有 Inspector。
+
+实现:
+
+- 夭夭 Electron 提供本机截图与鼠标、键盘、拖动、滚轮输入。Web/手机通过当前账号连接的桌面端操作,展示实际主机名称。Mac 本机控制同时要求桌面账号授权、屏幕录制和辅助功能。App 菜单可以撤销授权。
+- 使用 Electron 自带 Chromium 的隔离浏览器,不读取个人浏览器资料。每个机器人独立保存 cookies;临时资料在退出桌面端时清除。支持标签新建/关闭/切换、导航/前进/后退/刷新、元素 snapshot/ref、填写与点击、截图与人工输入。浏览器页面没有 Node、preload 或桌面服务凭据。
+- 通过现有按任务授权的 Hermes 工具桥接入机器人;权限、来源、模式、浏览器资料、运行中断与桌面实例变化都会使旧请求失效。本机输入全局串行,浏览器按机器人资料串行;人工控制使用独立票据、代次、请求幂等、最新画面校验。过期或断线需要重新接管并交还,工具不自动重放。
+- 自动模式保留已有虚拟机选择;无虚拟机时优先使用已授权且系统权限就绪的本机,再按既有云端配置选择。查看面板不会创建浏览器或唤醒云端。浏览器在显式打开或机器人第一次工具调用时建立。
+
+验证:
+
+- Web/Server 类型检查与构建通过;全量 Vitest 891 项通过、7 项跳过。之后的控制就绪、画面归属和交还说明修改使用专项套件复核。
+- `tests/server/desktopEnvironments.test.ts` 8 项:私有传输、账号/来源、自动选择、全局本机控制、票据、旧画面、幂等、断开代次、人工接管、交还说明及运行中资料切换。与服务所有权测试共 14 项。
+- `desktop/browser-environment.test.mjs` 使用真正的 Electron/Chromium,随机输入、DOM 结果、截图与标签页实测;重启 Electron 后持久 cookies 保留,其他机器人与临时资料均隔离。
+- `playwright.native-environment.config.ts` 在临时 Web 数据目录启动真实 Electron 环境桥,Web 接管浏览器、导航到隔离页面、交还与重新接管通过。1280 像素桌面及 375 像素窄屏截图已检查。
+- iOS Simulator 签名构建、34 项 WorkspaceChatTests、3 项界面用例通过。界面用例使用 URLProtocol fixture,验证权限状态、浏览器工具栏、接管/交还、虚拟机回归及大字体群聊 Inspector。另追加“交还后再次接管”检查。未安装到 iPhone。
+
+边界:
+
+- 当前本机操作支持 macOS;需要运行更新后的夭夭桌面端并完成系统授权。本次未替用户授予权限,未在用户真实桌面执行鼠标/键盘输入。Swift 输入助手已编译,实际 TCC 授权和真实桌面输入仍需授权后验收。
+- 本轮验证了环境传输、浏览器真实动作与工具生命周期,未调用付费模型完成真实 Hermes 模型任务。浏览器暂不支持上传文件选择器、下载、麦克风/摄像头授权或个人 Chrome 配置接入。
+- 云端 Grok Bot 登录、共享虚拟机、定时任务和 Inspector 沿用现有机制。
+
+复现命令:
+
+```sh
+NODE_OPTIONS=--localstorage-file=/tmp/yaoyao-native-unit-localstorage npx vitest run tests/server/desktopEnvironments.test.ts tests/server/serviceInstance.test.ts --maxWorkers=2
+env -u http_proxy -u https_proxy -u all_proxy -u ELECTRON_RUN_AS_NODE NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost node --test desktop/browser-environment.test.mjs
+npm run desktop:build
+env -u http_proxy -u https_proxy -u all_proxy -u ELECTRON_RUN_AS_NODE NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost npx playwright test -c playwright.native-environment.config.ts
+```

BIN
docs/verification/2026-09-10-bot-environments/desktop-browser.png


BIN
docs/verification/2026-09-10-bot-environments/ios-permissions.png


BIN
docs/verification/2026-09-10-bot-environments/phone-browser.png


+ 29 - 0
docs/verification/2026-09-10-bot-panels/README.md

@@ -0,0 +1,29 @@
+# Bot 模式机器人侧栏与 Grok Bot 云端电脑
+
+## 完成内容
+
+- 共享本地虚拟机按同一账号、同一执行节点绑定多个机器人,不再按基础 Profile 分成多台。虚拟机运行数量上限单独管理;独立模式仍保留。共享电脑保留已确定的工作目录,机器人保留独立会话。
+- 机器人侧栏包含电脑、定时任务和 Inspector。电脑选择参照 OpenMausBot:自动、Grok Bot 云端、本地虚拟机、本机、仅浏览器、不使用电脑。当前执行节点没有本机控制与独立浏览器连接,因此对应两项不可选。
+- 自动选择保留可用本地虚拟机;新机器人可使用已就绪的本地执行节点,否则使用当前账号已连接的 Grok Bot 云端。查看侧栏只查询状态;显式打开云端电脑或实际工具执行才建立/唤醒连接。
+- Grok Bot 使用服务端保存的加密凭据,按账号复用同一台虚拟机。机器人通过当前基础 Hermes 的工具桥获得云端 shell、文件读写、截图与桌面输入工具;云端地址和认证令牌不下发到浏览器或手机。
+- 接管等待当前云端电脑操作完成,后续机器人电脑工具等待交还。两个页面不能同时取得控制;控制到期不自行恢复,重新接管并交还后才继续,交还说明进入后续工具结果。
+- 群聊侧栏只有 Inspector,没有电脑查看或控制入口。
+- 编辑机器人允许切换基础机器人,服务端校验来源授权、可用性和空闲状态。新执行使用新会话,近期聊天记录仍用于上下文。
+- 定时任务支持单次、间隔、每日、每周和明确时区。任务、下次执行时间与执行记录持久化,重启后补执行一次到期任务,不集中重放漏掉的所有周期;相同任务未结束时跳过重叠执行。结果进入机器人原聊天。
+- 定时任务排版对齐 OpenMausBot 的 RoutinesSection / RoutineList / RoutineLogs:顶部操作卡、独立任务卡、状态标记、下一次执行、最近结果、日志筛选与模态编辑器。仅编辑标题或提示词不会推迟原定执行时间。
+- Inspector 排版对齐 OpenMausBot 的 InspectorPanel:Events / Raw 切换、条目计数、刷新图标、等宽紧凑行、方向/事件标签、连续 delta 合并与按需展开原始记录。
+- Inspector 记录实际 Hermes 网关请求、响应、事件和错误,提供请求 ID、耗时与展开数据。每个聊天最多保留 2000 条,面板读取最新 400 条;凭据和附件数据隐藏,按账号/聊天/任务隔离,聊天删除时清理。
+- 用户界面的 Agent 文案改为机器人;协议字段、代码标识与原有文件路径保持兼容。
+
+## 验证
+
+- 使用独立测试目录验证 Grok Bot 0.47.0 连接:状态读取成功,真实 shell 返回 Linux x86_64、box、/workspace,退出码 0;读取到 1280×800 PNG 桌面截图。未向真实云端发送桌面输入或改动工作文件。
+- Web Playwright 使用一次性 Hermes fixture,覆盖编辑基础机器人、真实网关请求记录、定时任务创建/立即执行/完成、群聊移除电脑入口,以及 375px 深色/减少动态效果显示。这里验证应用链路,fixture 回复不作为真实模型推理证据。
+- 全量 Vitest:871 项通过、7 项按原配置跳过;生产构建通过。Web 完整侧栏流程 Playwright:1 项通过。iOS 本地签名模拟器:WorkspaceChatTests 33 项、界面测试 3 项通过。
+- `desktop-computer.png`、`desktop-inspector.png`、`desktop-routines.png`、`phone-group-inspector.png` 均为本次 fixture 的实际浏览器截图。
+
+## 启用
+
+管理员在机器人电脑侧栏的「Grok Bot 云端连接」中使用服务器上已有的 Grok Bot 登录,或提交有效登录凭据;客户端版本默认为 0.47.0。选择云端需要基础机器人所在 Hermes 已启用 `yaoyao-bot-bridge`,远程执行节点需支持同一工具桥协议。
+
+本次交付为 Web/桌面共用前端与服务端、iOS 源码和验证,不包含生产服务重启、桌面安装包发布或实体手机覆盖安装。

BIN
docs/verification/2026-09-10-bot-panels/desktop-computer.png


BIN
docs/verification/2026-09-10-bot-panels/desktop-inspector.png


BIN
docs/verification/2026-09-10-bot-panels/desktop-routine-logs.png


BIN
docs/verification/2026-09-10-bot-panels/desktop-routines.png


BIN
docs/verification/2026-09-10-bot-panels/phone-group-inspector.png


+ 23 - 0
docs/verification/2026-09-10-grok-auth/README.md

@@ -0,0 +1,23 @@
+# Grok Bot 浏览器登录授权
+
+机器人电脑侧栏现在通过浏览器登录 Cursor 账号,使用 PKCE(SHA-256 challenge + 私有 verifier)和服务端轮询取得授权。无需在 Web、桌面端或 iOS 主界面粘贴访问令牌。官方登录说明:https://prod.cursor.com/help/grok-bot/sign-in 。
+
+## 行为
+
+- 授权请求绑定当前本地账号、授权版本和一次性会话;有效期 10 分钟。关闭页面或手机进入后台后,服务端继续轮询,重启后恢复尚未过期的请求。
+- 提供继续授权、取消、手动检查、重新授权和断开连接。显示账号名称、邮箱、有效期与自动续期状态。
+- PKCE verifier、access token 和 refresh token 均仅在服务端保存,使用工作区密钥加密;回给客户端的状态不含这些凭据。
+- 访问凭据临近过期时合并并发续期,持久化轮换后的刷新令牌。临时网络/服务错误保留原有凭据并退避重试;明确撤销时要求重新登录,自动电脑模式不会静默改到其他环境。
+- 取消、权限变更、断开和重新授权后,迟到的登录或续期结果不能恢复旧连接。重新授权须匹配原 Grok Bot 账号;切换账号前先断开。
+- Grok Bot 上游拒绝与夭夭本地登录分开处理,不再把上游 401 转成客户端退出登录。协议版本更新错误也不删除已有凭据。
+- 断开会删除当前服务器上的授权与账号占用记录;存在云端任务或人工接管时要求先结束操作。不会删除或重置云端虚拟机。
+- 旧的服务器登录导入保留在兼容入口。只有 access token 的旧连接能继续使用,但需要浏览器重新授权才能自动续期。
+
+## 验证
+
+- 全量 Vitest:883 项通过,7 项按原配置跳过。其中 12 项专门覆盖 PKCE、归属、取消竞争、过期恢复、账号不匹配、轮换、临时错误和断开竞争。最后的原子提交调整又通过 20 项针对性测试。
+- 实际 Web 页面端到端测试通过:打开授权页、取消重试、完成授权、刷新后保留账号、上游拒绝不退出夭夭、375px 深色模式和断开清理。授权提供方为完全隔离的 fixture。
+- iOS 本地签名构建通过;34 项 WorkspaceChatTests 通过,授权界面端到端测试通过。
+- 真实官方登录页面 HTTP 200;未确认会话的官方轮询返回预期 HTTP 404。使用原有有效访问凭据在临时数据库验证了官方账号接口,可读取名称和邮箱,未导出凭据或修改原 Grok Bot 登录。
+
+隔离端到端测试不代表真实账号已通过新页面完成授权。实际首次使用仍需用户在官方浏览器页面完成登录与确认。截图只包含测试账号。

BIN
docs/verification/2026-09-10-grok-auth/desktop-authorized.png


BIN
docs/verification/2026-09-10-grok-auth/desktop-waiting.png


BIN
docs/verification/2026-09-10-grok-auth/phone-authorized.png


+ 8 - 0
docs/verification/2026-09-10-v044/README.md

@@ -0,0 +1,8 @@
+# v0.4.4 验证
+
+- 真实 Electron 独立窗口:本机测试服务授予控制租约,画面输入由服务器接收,系统关闭按钮先交还租约,主窗口保留。截图为交互测试画面,不表示真实虚拟机业务任务已完成。
+- 数据迁移:覆盖旧默认目录、自定义目录、SQLite 活跃锁、账号密钥、Runner 状态、文件索引、更新事务延后、冲突保留和改名后的恢复。
+- 已停止虚拟机旧挂载:验证所属节点、完整隔离配置与旧路径后保留原容器,重新挂载新目录下的工作文件。
+- 本机完整数据备份后迁移成功:247 条工作区实体、240 条缓存消息,三个数据库完整性检查通过,账号和密钥摘要保持一致。
+- Android 1.3(162)Release 构建与单元测试通过,APK 正式签名验证通过。
+- 最终 Web 回归:897 通过、7 跳过;类型检查与生产构建通过。Electron 生命周期/升级等 13 项、原生钥匙串 1 项和独立接管窗口 1 项通过;Bot 侧栏桌面/手机浏览器流程 1 项通过。

BIN
docs/verification/2026-09-10-v044/computer-takeover.png


+ 1 - 0
electron-builder.yml

@@ -25,6 +25,7 @@ extraResources:
       - build-info.json
       - github-release.mjs
       - keychain-helper
+      - computer-helper
       - ui/**/*
       - web-service/**/*
 asar: true

+ 1 - 1
index.html

@@ -4,7 +4,7 @@
     <meta charset="UTF-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
     <meta name="theme-color" content="#fafafa" />
-    <meta name="description" content="夭夭 Web:Hermes 聊天、团队、文件库与产物工作台" />
+    <meta name="description" content="夭夭 AI:Hermes 聊天、团队、文件库与产物工作台" />
     <link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32.png" />
     <link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png" />
     <link rel="manifest" href="/manifest.webmanifest" />

+ 6 - 5
package-lock.json

@@ -1,13 +1,13 @@
 {
-  "name": "hermes-yaoyao",
-  "version": "0.4.3",
+  "name": "yaoyao",
+  "version": "0.4.4",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
-      "name": "hermes-yaoyao",
-      "version": "0.4.3",
-      "license": "BSL-1.1",
+      "name": "yaoyao",
+      "version": "0.4.4",
+      "license": "Apache-2.0",
       "dependencies": {
         "@koa/bodyparser": "^5.0.0",
         "@koa/router": "^15.4.0",
@@ -50,6 +50,7 @@
         "zod": "^4.1.12"
       },
       "bin": {
+        "yaoyao": "bin/hermes-yaoyao.mjs",
         "hermes-yaoyao": "bin/hermes-yaoyao.mjs"
       },
       "devDependencies": {

+ 12 - 6
package.json

@@ -1,16 +1,17 @@
 {
-  "name": "hermes-yaoyao",
-  "version": "0.4.3",
+  "name": "yaoyao",
+  "version": "0.4.4",
   "private": true,
-  "license": "BSL-1.1",
-  "description": "夭夭 Web:直连 Hermes 9119 的聊天、团队、文件库与产物工作台",
+  "license": "Apache-2.0",
+  "description": "夭夭 AI:聊天、多 Agent 团队、文件库与电脑工作空间",
   "type": "module",
   "main": "desktop/main.mjs",
   "engines": {
     "node": ">=24.0.0"
   },
   "bin": {
-    "hermes-yaoyao": "./bin/hermes-yaoyao.mjs"
+    "hermes-yaoyao": "./bin/hermes-yaoyao.mjs",
+    "yaoyao": "./bin/hermes-yaoyao.mjs"
   },
   "scripts": {
     "dev": "cross-env NODE_ENV=development tsx watch src/server/index.ts",
@@ -89,5 +90,10 @@
     "supertest": "^7.1.4",
     "tsx": "^4.21.0",
     "vitest": "^3.2.4"
-  }
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/Lsamien/yaoyao.git"
+  },
+  "homepage": "https://github.com/Lsamien/yaoyao"
 }

+ 7 - 0
playwright.bot-panels.config.ts

@@ -0,0 +1,7 @@
+import {defineConfig,devices} from '@playwright/test'
+export default defineConfig({
+ testDir:'./tests/e2e',testMatch:'bot-panels.spec.ts',workers:1,timeout:60000,reporter:'list',
+ use:{baseURL:'http://127.0.0.1:18832',viewport:{width:1440,height:900},trace:'retain-on-failure',screenshot:'only-on-failure'},
+ projects:[{name:'chromium',use:{...devices['Desktop Chrome']}}],
+ webServer:{command:'WORKSPACE_FIXTURE_PORT=18832 WORKSPACE_FIXTURE_UPSTREAM_PORT=19132 node --import tsx tests/fixtures/workspace-server.ts',url:'http://127.0.0.1:18832/healthz',reuseExistingServer:false,timeout:60000},
+})

+ 7 - 0
playwright.grok-auth.config.ts

@@ -0,0 +1,7 @@
+import {defineConfig,devices} from '@playwright/test'
+export default defineConfig({
+ testDir:'./tests/e2e',testMatch:'grok-auth.spec.ts',workers:1,timeout:45000,reporter:'list',
+ use:{baseURL:'http://127.0.0.1:18842',viewport:{width:1440,height:900},trace:'retain-on-failure',screenshot:'only-on-failure'},
+ projects:[{name:'chromium',use:{...devices['Desktop Chrome']}}],
+ webServer:{command:'WORKSPACE_FIXTURE_GROK_AUTH=1 WORKSPACE_FIXTURE_PORT=18842 WORKSPACE_FIXTURE_UPSTREAM_PORT=19142 node --import tsx tests/fixtures/workspace-server.ts',url:'http://127.0.0.1:18842/healthz',reuseExistingServer:false,timeout:60000},
+})

+ 2 - 0
playwright.native-environment.config.ts

@@ -0,0 +1,2 @@
+import {defineConfig,devices} from '@playwright/test'
+export default defineConfig({testDir:'./tests/e2e',testMatch:'native-environment.spec.ts',workers:1,timeout:60000,reporter:'list',use:{baseURL:'http://127.0.0.1:18852',viewport:{width:1440,height:900},trace:'retain-on-failure',screenshot:'only-on-failure'},projects:[{name:'chromium',use:{...devices['Desktop Chrome']}}],webServer:{command:'WORKSPACE_FIXTURE_NATIVE=1 WORKSPACE_FIXTURE_PORT=18852 WORKSPACE_FIXTURE_UPSTREAM_PORT=19152 node --import tsx tests/fixtures/workspace-server.ts',url:'http://127.0.0.1:18852/healthz',reuseExistingServer:false,timeout:30000}})

+ 1 - 1
public/manifest.webmanifest

@@ -1,5 +1,5 @@
 {
-  "name": "夭夭 Web",
+  "name": "夭夭 AI",
   "short_name": "夭夭",
   "description": "Hermes 聊天、群聊、文件库与产物工作台",
   "start_url": "/",

+ 3 - 3
release.json

@@ -1,6 +1,6 @@
 {
   "schemaVersion": 1,
-  "releaseVersion": "0.4.3",
-  "webVersion": "0.4.3",
-  "gitTag": "v0.4.3"
+  "releaseVersion": "0.4.4",
+  "webVersion": "0.4.4",
+  "gitTag": "v0.4.4"
 }

+ 9 - 5
scripts/build-desktop.mjs

@@ -19,13 +19,16 @@ await build({ entryPoints: [resolve(root, 'src/server/githubReleases.ts')], outf
 const swiftTarget=process.arch==='arm64'?'arm64-apple-macosx12.0':'x86_64-apple-macosx12.0'
 execFileSync('xcrun',['swiftc','-O','-target',swiftTarget,resolve(root,'desktop/keychain-helper.swift'),'-o',resolve(out,'keychain-helper')],{stdio:'inherit'})
 execFileSync('xcrun',['swiftc','-O','-target',swiftTarget,'-D','DEVELOPMENT_HELPER',resolve(root,'desktop/keychain-helper.swift'),'-o',resolve(out,'keychain-helper-dev')],{stdio:'inherit'})
+for(const development of [false,true])execFileSync('xcrun',['swiftc','-O','-target',swiftTarget,...(development?['-D','DEVELOPMENT_HELPER']:[]),resolve(root,'desktop/computer-helper.swift'),'-o',resolve(out,development?'computer-helper-dev':'computer-helper')],{stdio:'inherit'})
 await cp(resolve(root, 'dist'), resolve(out, 'ui'), { recursive: true })
 await cp(resolve(root, 'release.json'), resolve(out, 'release.json'))
 await cp(resolve(root, 'public/icons/icon-512.png'), resolve(root, 'desktop/icon.png'))
 const shell = resolve(out, 'shell')
 await mkdir(shell)
+await cp(resolve(root, 'bin/lib/data-home.mjs'), resolve(shell, 'data-home.mjs'))
 for (const file of await readdir(resolve(root, 'desktop'))) {
-  if (file.endsWith('.test.mjs') || !/\.(js|mjs|cjs|html|css|png)$/.test(file)) continue
+  if (file === 'data-home.mjs' || file.endsWith('.test.mjs') || !/\.(js|mjs|cjs|html|css|png)$/.test(file)) continue
+  if(/\.(js|mjs|cjs)$/.test(file))execFileSync(process.execPath,['--check',resolve(root,'desktop',file)],{stdio:'inherit'})
   await cp(resolve(root, 'desktop', file), resolve(shell, file))
 }
 for (const file of ['boot.html', 'boot.js', 'boot.css', 'preload.cjs']) await readFile(resolve(shell, file))
@@ -34,13 +37,14 @@ const manifest = JSON.parse(await readFile(resolve(root, 'release.json'), 'utf8'
 const service = resolve(out, 'web-service')
 await mkdir(service)
 for (const file of ['server.mjs', 'ui', 'release.json', 'build-info.json', 'hermes_worker.py', 'guest_proxy.py', 'computer-image', 'third-party']) await cp(resolve(out, file), resolve(service, file), { recursive: true })
+for (const file of ['LICENSE', 'NOTICE', 'THIRD_PARTY_NOTICES.md', 'licenses']) await cp(resolve(root, file), resolve(service, file), { recursive: true })
 await cp(resolve(root, 'bin'), resolve(service, 'bin'), { recursive: true })
 await cp(await realpath(process.execPath), resolve(service, 'node'))
 await cp(resolve(await realpath(process.execPath), '../../LICENSE'), resolve(service, 'NODE-LICENSE.txt'))
 await chmod(resolve(service, 'node'), 0o755)
-await writeFile(resolve(service, 'package.json'), JSON.stringify({ name: 'hermes-yaoyao', version: manifest.webVersion, type: 'module' }))
+await writeFile(resolve(service, 'package.json'), JSON.stringify({ name: 'yaoyao', version: manifest.webVersion, type: 'module' }))
 sealRuntime(service)
-await writeFile(resolve(shell, 'package.json'), JSON.stringify({ name: 'hermes-yaoyao-desktop', version: manifest.webVersion,
-  productName: '夭夭', description: '夭夭:本地服务、多 Agent 团队与电脑工作空间',
-  author: 'YaoYao contributors', license: 'BSL-1.1', main: 'main.mjs', type: 'module' }, null, 2))
+await writeFile(resolve(shell, 'package.json'), JSON.stringify({ name: 'yaoyao-desktop', version: manifest.webVersion,
+  productName: '夭夭', description: '夭夭 AI:本地服务、多 Agent 团队与电脑工作空间',
+  author: 'YaoYao contributors', license: 'Apache-2.0', main: 'main.mjs', type: 'module' }, null, 2))
 console.log('桌面服务和界面已打包到 .desktop-build')

+ 1 - 1
scripts/generate-desktop-compose.mjs

@@ -9,7 +9,7 @@ const q=JSON.stringify
 const targets=entries.map(d=>({id:d.id,name:d.name,socketPath:`/run/yaoyao-desktops/${d.service}/desktop.sock`}))
 const base=readFileSync(resolve(root,'compose.yaml'),'utf8')
   .replace('      HERMES_YAOYAO_LOCAL_VM_HOST: "runner"','      HERMES_YAOYAO_LOCAL_VM_HOST: "runner"\n      HERMES_YAOYAO_COMPOSE_DESKTOPS: '+q(JSON.stringify(targets)))
-  .replace('      - yaoyao-data:/var/lib/hermes-yaoyao','      - yaoyao-data:/var/lib/hermes-yaoyao\n'+entries.map(d=>`      - ${d.service}-ipc:/run/yaoyao-desktops/${d.service}:ro`).join('\n'))
+  .replace('      - yaoyao-data:/home/node/.yaoyao','      - yaoyao-data:/home/node/.yaoyao\n'+entries.map(d=>`      - ${d.service}-ipc:/run/yaoyao-desktops/${d.service}:ro`).join('\n'))
 const volumesAt=base.indexOf('\nvolumes:')
 if(volumesAt<0||!base.includes('HERMES_YAOYAO_COMPOSE_DESKTOPS'))throw new Error('compose.yaml 模板结构已变化')
 let yaml='# Generated from compose.yaml and deploy/compose-desktops.json.\n'+base.slice(0,volumesAt)+'\n'

+ 2 - 2
src/client/App.vue

@@ -24,7 +24,7 @@ const agentIdentityFixture = import.meta.env.DEV
   && new URLSearchParams(window.location.search).get('fixture') === 'agent-identity'
 
 const pageTitle = computed(() => {
-  const name = route.path.startsWith('/history')
+  const name = route.name === 'computer' ? '电脑接管' : route.path.startsWith('/history')
     ? '历史记录'
     : route.path.startsWith('/conversations')
     ? '聊天'
@@ -33,7 +33,7 @@ const pageTitle = computed(() => {
     : route.path.startsWith('/files')
       ? '文件库'
       : chat.activeSession?.title || '对话'
-  return `${name} · 夭夭`
+  return `${name} · 夭夭 AI`
 })
 
 watch(() => theme.resolvedTheme, value => {

+ 2 - 2
src/client/api/profiles.ts

@@ -46,7 +46,7 @@ function readProfileEntries(value: JsonValue): Record<string, JsonValue>[] {
 function validateIdentity(input: ProfileIdentityInput): ProfileIdentityInput {
   const title = input.title.trim().replace(/\s+/g, ' ')
   if (!title || title.length > MAX_AGENT_NAME_LENGTH || /[\u0000-\u001f\u007f]/.test(title)) {
-    throw new Error(`Agent 名称应为 1 至 ${MAX_AGENT_NAME_LENGTH} 个字符`)
+    throw new Error(`机器人名称应为 1 至 ${MAX_AGENT_NAME_LENGTH} 个字符`)
   }
   const avatarDataURL = input.avatarDataURL === undefined ? undefined : input.avatarDataURL?.trim() || null
   if (avatarDataURL && (avatarDataURL.length > MAX_AGENT_AVATAR_LENGTH || !avatarDataURLPattern.test(avatarDataURL))) {
@@ -79,7 +79,7 @@ export async function updateProfileIdentity(profile: Profile, input: ProfileIden
   try {
     const listed = await control.request('profiles.list', { include_sessions: false })
     const current = readProfileEntries(listed).find(item => String(item.name ?? '') === profile.name)
-    if (!current) throw new Error('该 Agent 已不存在,请刷新后重试')
+    if (!current) throw new Error('该机器人已不存在,请刷新后重试')
     const revisions = jsonObject(current.ui_meta_revisions)
     const revision = typeof revisions[YAOYAO_AGENT_IDENTITY_NAMESPACE] === 'number'
       ? revisions[YAOYAO_AGENT_IDENTITY_NAMESPACE] as number

+ 1 - 1
src/client/components/app/AccountSecurityPanel.vue

@@ -230,7 +230,7 @@ watch(canSave, value => emit('can-save-change', value), { immediate: true, flush
       <p v-else-if="notice" class="form-message form-message--success" role="status">{{ notice }}</p>
 
       <footer v-if="showActions" class="form-actions">
-        <span>保存后不会修改 Agent、Provider 或系统服务配置。</span>
+        <span>保存后不会修改机器人、Provider 或系统服务配置。</span>
         <button class="solid-button" type="submit" :disabled="!canSave">{{ busy ? '正在保存…' : '保存修改' }}</button>
       </footer>
     </form>

+ 2 - 2
src/client/components/app/AgentIdentityDialog.vue

@@ -21,9 +21,9 @@ watch(() => [props.open, props.profile] as const, () => {
   <Teleport to="body">
     <Transition name="identity-fade">
       <div v-if="open && profile" class="identity-layer" @mousedown.self="emit('close')">
-        <section class="identity-dialog" role="dialog" aria-modal="true" aria-label="Agent 管理">
+        <section class="identity-dialog" role="dialog" aria-modal="true" aria-label="机器人管理">
           <header><div><small>AGENT 管理</small><h2>{{ profile.agentName || profile.displayName || profile.name }}</h2></div><button class="icon-button" type="button" aria-label="关闭" :disabled="busy" @click="emit('close')"><AppIcon name="close" /></button></header>
-          <nav v-if="isAdmin" class="management-tabs" aria-label="Agent 管理分类"><button type="button" :class="{ active: activeTab === 'identity' }" @click="activeTab = 'identity'">身份</button><button type="button" :class="{ active: activeTab === 'models' }" @click="activeTab = 'models'">模型服务</button><button type="button" :class="{ active: activeTab === 'voice' }" @click="activeTab = 'voice'">双流语音</button></nav>
+          <nav v-if="isAdmin" class="management-tabs" aria-label="机器人管理分类"><button type="button" :class="{ active: activeTab === 'identity' }" @click="activeTab = 'identity'">身份</button><button type="button" :class="{ active: activeTab === 'models' }" @click="activeTab = 'models'">模型服务</button><button type="button" :class="{ active: activeTab === 'voice' }" @click="activeTab = 'voice'">双流语音</button></nav>
           <AgentIdentityPanel v-if="activeTab === 'identity'" :profile="profile" :busy="busy" :error="error" @save="emit('save', $event)">
             <template #actions>
               <button class="quiet-button" type="button" :disabled="busy" @click="emit('close')">取消</button>

+ 1 - 1
src/client/components/app/AgentIdentityFixture.vue

@@ -23,7 +23,7 @@ const teamMembers = shapes.map(item => ({ name: item.name, avatar: item.avatar }
   <main class="identity-fixture">
     <header>
       <span>跨端角色系统</span>
-      <h1>自定义 Agent 角色</h1>
+      <h1>自定义机器人角色</h1>
       <p>采用 OpenMausBot 的纯色轮廓、五官与状态动画。</p>
     </header>
     <section class="shape-row" aria-label="三种头像形状">

+ 1 - 1
src/client/components/app/AgentIdentityPanel.vue

@@ -212,7 +212,7 @@ function resetAvatar() {
 
 function submit() {
   const normalized = title.value.trim().replace(/\s+/g, ' ')
-  if (!normalized) { localError.value = '请输入 Agent 名称'; return }
+  if (!normalized) { localError.value = '请输入机器人名称'; return }
   emit('save', {
     title: normalized,
     avatarMode: avatarMode.value,

+ 1 - 1
src/client/components/app/DuplexVoicePanel.vue

@@ -94,7 +94,7 @@ onMounted(() => { void load() })
 
 <template>
   <section class="voice-panel" aria-label="双流语音">
-    <div class="voice-heading"><div><h3>yaoyao 双流语音</h3><p>这是整个 yaoyao 安装共享的全局设置,不随当前 Agent 切换。</p></div><span>全局</span></div>
+    <div class="voice-heading"><div><h3>yaoyao 双流语音</h3><p>这是整个 yaoyao 安装共享的全局设置,不随当前机器人切换。</p></div><span>全局</span></div>
     <p v-if="error" class="voice-error" role="alert">{{ error }}</p><p v-else-if="notice" class="voice-notice" role="status">{{ notice }}</p>
     <p v-if="loading" class="voice-empty">正在读取语音设置…</p>
     <form v-else :aria-busy="busy" @submit.prevent="save">

+ 10 - 9
src/client/components/app/LocalVmSettingsPanel.vue

@@ -25,7 +25,7 @@ async function refresh(){
 async function action(work:()=>Promise<unknown>){acting.value=true;error.value='';try{await work()}catch(e){error.value=e instanceof Error?e.message:'操作未完成'}finally{acting.value=false;await refresh()}}
 function prepare(){void action(()=>apiRequest('/api/app/admin/local-vm/prepare',{method:'POST',body:{requestId:createUuid()}}))}
 function policy(mode:LocalVmMode,maxInstances=state.value?.maxInstances??2){
- if(mode==='shared'&&state.value?.mode!=='shared'&&!confirm('同一账号、同一基础 Agent 的机器人将共用桌面、工作文件和浏览器登录。确认使用共享虚拟机?'))return
+ if(mode==='shared'&&state.value?.mode!=='shared'&&!confirm('当前账号的多个机器人将共用桌面、工作文件和浏览器登录。确认使用共享虚拟机?'))return
  void action(()=>apiRequest('/api/app/admin/local-vm/policy',{method:'PUT',body:{requestId:createUuid(),mode,maxInstances}}))
 }
 function manage(agent:WorkspaceAgent,operation:LocalVmAction){
@@ -37,30 +37,31 @@ onMounted(cycle);onBeforeUnmount(()=>{closed=true;clearTimeout(timer)})
 </script>
 <template>
  <section class="local-vm-settings" aria-label="本地虚拟机设置">
-  <article><h3>{{state?.fixedCapacity?'Compose 共享桌面':'本地虚拟机'}}</h3><p>{{state?.fixedCapacity?'桌面容器随 Web 的 Compose 文件部署,工作文件与浏览器资料保存在各桌面的数据卷中。':'在 Hermes 所在电脑的隔离 Linux 桌面中运行 Agent,工作文件与浏览器资料持续保存。'}}</p>
+  <article><h3>{{state?.fixedCapacity?'Compose 共享桌面':'本地虚拟机'}}</h3><p>{{state?.fixedCapacity?'桌面容器随 Web 的 Compose 文件部署,工作文件与浏览器资料保存在各桌面的数据卷中。':'在 Hermes 所在电脑的隔离 Linux 桌面中运行机器人,工作文件与浏览器资料持续保存。'}}</p>
    <div class="row"><span class="status"><AppIcon :name="state?.image?'check':'monitor'"/>{{loading&&!state?'正在检查…':state?.image?'虚拟机环境已就绪':'尚未就绪'}}</span><button :disabled="loading||acting" @click="error='';refresh()"><AppIcon name="refresh"/>重新检查</button></div>
    <p v-if="state?.problem">{{state.problem}}</p><p v-if="error" role="alert">{{error}}</p>
    <p v-if="state?.job" role="status">{{state.job.message}}</p>
   </article>
   <article v-if="state?.executionHost==='runner'"><h3>Hermes 执行连接</h3><p>{{state.fixedCapacity?'执行连接负责 Hermes 模型与工具调用,桌面容器完全由这套 Compose 管理。':'虚拟桌面由运行 Hermes 的执行节点提供,Docker 版 Web 通过这条连接使用桌面。'}}{{state.runnerName?`当前节点:${state.runnerName}。`:''}}</p><button :aria-expanded="runnerSettingsOpen" @click="runnerSettingsOpen=!runnerSettingsOpen">{{runnerSettingsOpen?'收起执行节点设置':'打开执行节点设置'}}</button><RunnerSettingsPanel v-if="runnerSettingsOpen" computer-setup /></article>
-  <article v-if="state?.fixedCapacity"><h3>Compose 共享桌面</h3><p>已配置 {{state.maxInstances}} 台桌面,数量由 Compose 固定。请在 Agent 聊天的电脑面板选择已有桌面。</p><div v-for="desktop in state.desktops" :key="desktop.id" class="instance"><strong>{{desktop.name}}</strong><span>{{desktop.ready?'已就绪':desktop.online?'正在启动':'未连接'}}</span></div></article>
-  <article v-else-if="state"><h3>隔离方式</h3><p>按 Agent 创建独立桌面,或让可信的 Agent 共用一个桌面。</p>
-   <div class="segmented" role="group" aria-label="虚拟机隔离方式"><button :aria-pressed="state?.mode==='shared'" :disabled="!state?.configured||!!state?.setupRequired||acting||state.busy" @click="policy('shared')">共享虚拟机</button><button :aria-pressed="state?.mode==='per-bot'" :disabled="!state?.configured||!!state?.setupRequired||acting||state.busy" @click="policy('per-bot')">每个 Agent 独立</button></div>
-   <label class="row">最多同时运行的虚拟机<select aria-label="虚拟机数量上限" :value="state?.maxInstances??2" :disabled="!state?.configured||!!state?.setupRequired||acting||state.busy" @change="policy(state!.mode,Number(($event.target as HTMLSelectElement).value))"><option v-for="n in [1,2,3,4]" :key="n" :value="n">{{n}}</option></select></label>
+  <article v-if="state?.fixedCapacity"><h3>Compose 共享桌面</h3><p>已配置 {{state.maxInstances}} 台桌面,数量由 Compose 固定。请在机器人聊天的电脑面板选择已有桌面。</p><div v-for="desktop in state.desktops" :key="desktop.id" class="instance"><strong>{{desktop.name}}</strong><span>{{desktop.ready?'已就绪':desktop.online?'正在启动':'未连接'}}</span></div></article>
+  <article v-else-if="state"><h3>隔离方式</h3><p>按机器人创建独立桌面,或让可信的机器人共用一个桌面。</p>
+   <div class="segmented" role="group" aria-label="虚拟机隔离方式"><button :aria-pressed="state?.mode==='shared'" :disabled="!state?.configured||!!state?.setupRequired||acting||state.busy" @click="policy('shared')">共享虚拟机</button><button :aria-pressed="state?.mode==='per-bot'" :disabled="!state?.configured||!!state?.setupRequired||acting||state.busy" @click="policy('per-bot')">每个机器人独立</button></div>
+   <p class="sharing-explanation">共享指多个机器人操作同一台虚拟机,共用桌面和工作文件;与可同时运行的虚拟机数量无关。</p>
+   <label class="row">虚拟机运行数量上限<select aria-label="虚拟机数量上限" :value="state?.maxInstances??2" :disabled="!state?.configured||!!state?.setupRequired||acting||state.busy" @change="policy(state!.mode,Number(($event.target as HTMLSelectElement).value))"><option v-for="n in [1,2,3,4]" :key="n" :value="n">{{n}}</option></select></label>
   </article>
   <article v-if="state&&!state.fixedCapacity&&!state.setupRequired"><h3>准备运行环境</h3><p v-if="state?.executionHost==='runner'">以下检查和镜像准备均在执行节点所在电脑完成。</p><ol>
    <li><span class="step">{{state?.runtime?'✓':'1'}}</span><div><strong>安装 Docker 或 Podman</strong><p>{{state?.runtime?`已检测到 ${state.runtime}`:'请先安装 Docker Desktop 或 Podman。'}}</p></div></li>
    <li><span class="step">{{state?.daemonUp?'✓':'2'}}</span><div><strong>启动容器运行环境</strong><p>{{state?.daemonUp?'运行环境已启动':'打开 Docker / Podman,等待它完成启动后重新检查。'}}</p></div></li>
    <li><span class="step">{{state?.image?'✓':'3'}}</span><div><strong>准备本地虚拟机</strong><p>下载并检查托管桌面环境。后续创建虚拟机时会自动使用。</p><button class="primary" :disabled="acting||state?.busy||!state?.daemonUp" @click="prepare">{{state?.busy?'正在准备…':state?.image?'重新检查虚拟机镜像':'准备本地虚拟机'}}</button></div></li>
-   <li><span class="step">4</span><div><strong>从 Agent 聊天中创建桌面</strong><p>打开聊天右上角的“电脑”,选择“本地虚拟机”,然后创建该 Agent 的虚拟机。</p></div></li>
+   <li><span class="step">4</span><div><strong>从机器人聊天中创建桌面</strong><p>打开聊天右上角的“电脑”,选择“本地虚拟机”,然后创建该机器人的虚拟机。</p></div></li>
   </ol></article>
-  <article v-if="state&&!state.fixedCapacity"><h3>{{state?.mode==='shared'?'共享虚拟机':'Agent 虚拟机'}}</h3><p v-if="!instances.length">还没有 Agent 使用本地虚拟机。</p>
+  <article v-if="state&&!state.fixedCapacity"><h3>{{state?.mode==='shared'?'共享虚拟机':'机器人虚拟机'}}</h3><p v-if="!instances.length">还没有机器人使用本地虚拟机。</p>
    <div v-for="row in instances" :key="row.agent.id" class="instance"><div><strong>{{row.agent.computerEnvironmentName??row.agent.name}}</strong><p>{{row.vm.inUse?'正在使用':({running:'运行中',stopped:'已停止',missing:'尚未创建'})[row.vm.container]}}</p></div><div class="row">
     <button v-if="row.vm.container==='running'" :disabled="acting||row.vm.inUse" @click="manage(row.agent,'stop')">停止</button>
     <button v-else :disabled="acting||!state?.image" @click="manage(row.agent,row.vm.container==='missing'?'create':'start')">{{row.vm.container==='missing'?'创建':'启动'}}</button>
     <button v-if="row.vm.container!=='missing'" :disabled="acting||row.vm.inUse" @click="manage(row.agent,'remove')">移除实例</button>
    </div></div>
-   <div v-for="item in state?.instances?.filter(i=>i.orphaned)" :key="item.id" class="instance"><div><strong>{{item.name}}</strong><p>暂无 Agent 使用 · {{item.status==='free'?'已停止':'运行中或待核对'}}</p></div><div class="row"><button :disabled="acting" @click="action(()=>apiRequest(`/api/app/admin/local-vm/instances/${item.id}/stop`,{method:'POST',body:{requestId:createUuid()}}))">停止</button><button :disabled="acting" @click="action(()=>apiRequest(`/api/app/admin/local-vm/instances/${item.id}/remove`,{method:'POST',body:{requestId:createUuid()}}))">移除实例</button></div></div>
+   <div v-for="item in state?.instances?.filter(i=>i.orphaned)" :key="item.id" class="instance"><div><strong>{{item.name}}</strong><p>暂无机器人使用 · {{item.status==='free'?'已停止':'运行中或待核对'}}</p></div><div class="row"><button :disabled="acting" @click="action(()=>apiRequest(`/api/app/admin/local-vm/instances/${item.id}/stop`,{method:'POST',body:{requestId:createUuid()}}))">停止</button><button :disabled="acting" @click="action(()=>apiRequest(`/api/app/admin/local-vm/instances/${item.id}/remove`,{method:'POST',body:{requestId:createUuid()}}))">移除实例</button></div></div>
   </article>
  </section>
 </template>

+ 3 - 3
src/client/components/app/ModelServicesPanel.vue

@@ -266,7 +266,7 @@ async function activate(service: CustomModelService) {
     await activateModelService(props.profile, service.id)
     await load(true)
     notifyModelCatalogChanged(props.profile)
-    notice.value = `“${service.name}”已设为当前 Agent 的默认模型服务`
+    notice.value = `“${service.name}”已设为当前机器人的默认模型服务`
   } catch (cause) {
     error.value = cause instanceof Error ? cause.message : '设为默认失败'
   } finally {
@@ -299,7 +299,7 @@ onMounted(() => { void load() })
 
 <template>
   <section class="management-panel" aria-label="模型服务">
-    <div class="panel-context"><strong>9119 Provider 与模型</strong><span>全部来自当前 Agent:<b>{{ profile }}</b></span></div>
+    <div class="panel-context"><strong>9119 Provider 与模型</strong><span>全部来自当前机器人:<b>{{ profile }}</b></span></div>
     <form class="default-model-card" @submit.prevent="saveDefaultModel">
       <label><strong>默认全局模型</strong><small>仅用于之后新建的会话,已有会话保持原模型。</small></label>
       <select v-model="defaultModelKey" aria-label="默认全局模型" :disabled="busy || loading">
@@ -331,7 +331,7 @@ onMounted(() => { void load() })
       <p v-else class="editor-hint">该 Provider 的密钥不由 9119 环境变量管理,因此这里只编辑 URL 和模型。</p>
       <button v-if="draft.canEditApiKey && draft.hasApiKey && !draft.clearApiKey" class="text-button danger" type="button" :disabled="busy" @click="draft.apiKey = ''; draft.apiKeyTouched = false; draft.clearApiKey = true">清除已保存密钥</button><button v-else-if="draft.canEditApiKey && draft.clearApiKey" class="text-button" type="button" :disabled="busy" @click="draft.clearApiKey = false">取消清除密钥</button>
       <label>模型列表(每行一个)<textarea v-model="draft.modelsText" rows="5" :disabled="busy" placeholder="连接测试后自动填充,也可手动输入" /></label>
-      <label class="check-row"><input v-model="draft.discoverModels" type="checkbox" :disabled="busy" />允许 9119 自动发现模型</label><label v-if="draft.source === 'managed'" class="check-row"><input v-model="draft.makeDefault" type="checkbox" :disabled="busy" />保存后设为当前 Agent 默认服务</label>
+      <label class="check-row"><input v-model="draft.discoverModels" type="checkbox" :disabled="busy" />允许 9119 自动发现模型</label><label v-if="draft.source === 'managed'" class="check-row"><input v-model="draft.makeDefault" type="checkbox" :disabled="busy" />保存后设为当前机器人默认服务</label>
       <small class="editor-hint">{{ draft.source === 'legacy' ? '保存后模型列表按当前内容更新;当前默认 Provider 会同步新的 URL 与默认模型。' : '9119 会保留服务中已有的模型条目;删除整项服务会一并移除它们。' }}</small>
       <footer><button class="quiet-button" type="button" :disabled="busy" @click="probe">测试连接</button><button class="primary-button" type="submit" :disabled="busy">{{ busy ? '处理中…' : '保存模型服务' }}</button></footer>
     </form>

+ 2 - 2
src/client/components/app/RunnerSettingsPanel.vue

@@ -86,7 +86,7 @@ onMounted(()=>{void action(refresh)})
         <label>Hermes 源码目录<input v-model.trim="hermesSource" placeholder="留空使用默认安装"></label>
         <label>Hermes 配置目录<input v-model.trim="hermesHome" placeholder="留空使用默认安装"></label>
         <small>留空时在执行电脑上查找 ~/.hermes/hermes-agent/venv/bin/python。自定义安装请填写绝对路径;镜像可在节点连接后于本页准备。</small>
-        <small>这是外部执行节点的高级配置。本机虚拟机可直接在应用设置中准备,并从 Agent 聊天的电脑面板启用。</small>
+        <small>这是外部执行节点的高级配置。本机虚拟机可直接在应用设置中准备,并从机器人聊天的电脑面板启用。</small>
       </fieldset>
       <button class="solid-button" :disabled="busy || !name.trim() || !profiles.trim()">注册节点</button>
     </form>
@@ -95,7 +95,7 @@ onMounted(()=>{void action(refresh)})
       <p>配置包含本节点的连接凭据,仅本次可下载。将文件放在 Hermes 所在电脑,设置为仅自己可读:</p>
       <code v-if="bundleAvailable">mkdir -p yaoyao-runner<br>tar -xzf yaoyao-runner.tar.gz -C yaoyao-runner<br>chmod 600 runner.json<br>node yaoyao-runner/runner.mjs --config /完整路径/runner.json</code>
       <code v-else>chmod 600 runner.json<br>npm run runner -- --config /完整路径/runner.json</code>
-      <small>{{bundleAvailable?'在运行 Hermes 和 Docker/Podman 的电脑上执行,节点连接后返回本地虚拟机设置准备桌面。':'在 hermes-yaoyao 项目中先运行 npm run build。'}}配置丢失后可停用节点并重新注册。</small>
+      <small>{{bundleAvailable?'在运行 Hermes 和 Docker/Podman 的电脑上执行,节点连接后返回本地虚拟机设置准备桌面。':'在 yaoyao 项目中先运行 npm run build。'}}配置丢失后可停用节点并重新注册。</small>
     </div>
     <p v-if="error" class="runner-error" role="alert">{{ error }}</p>
     <p v-if="notice" role="status">{{ notice }}</p>

+ 1 - 1
src/client/components/app/ServerIdentityPanel.vue

@@ -34,7 +34,7 @@ void auth.refreshServerIdentity()
     <h3>服务器名称</h3>
     <form v-if="editable" @submit.prevent="save">
       <label>统一显示名称<input v-model="name" name="server-display-name" maxlength="100" placeholder="例如:家里的 Mac" :disabled="busy" /></label>
-      <p>该服务器上的 Agent 共用此名称,Web、iOS 和安卓同步。留空恢复服务器主机名。</p>
+      <p>该服务器上的机器人共用此名称,Web、iOS 和安卓同步。留空恢复服务器主机名。</p>
       <p v-if="error" role="alert">{{ error }}</p><p v-if="notice" role="status">{{ notice }}</p>
       <button type="submit" :disabled="busy || !dirty">{{ busy ? '保存中…' : '保存服务器名称' }}</button>
       <button v-if="error" type="button" :disabled="busy" @click="reload">重新载入</button>

+ 5 - 5
src/client/components/app/SettingsCenterDialog.vue

@@ -148,7 +148,7 @@ const activeScope = computed(() => {
 })
 
 function profileTitle(profile?: Profile): string {
-  return profile?.agentName || profile?.displayName || profile?.name || '未选择 Agent'
+  return profile?.agentName || profile?.displayName || profile?.name || '未选择机器人'
 }
 
 function setDirty(page: SettingsPage, dirty: boolean) {
@@ -283,10 +283,10 @@ function requestModeSwitch() {
                 <div v-if="showAgentSelector" class="settings-agent-selector">
                   <button ref="settingsAgentTrigger" type="button" aria-haspopup="listbox" :aria-expanded="profileMenuOpen" @click="toggleAgentMenu">
                     <AgentAvatar :name="profileTitle(activeProfile)" :avatar="activeProfile?.agentAvatar || ''" :size="34" />
-                    <span><strong>{{ profileTitle(activeProfile) }}</strong><small>{{ activeProfile?.name || '未选择 Agent' }}</small></span>
+                    <span><strong>{{ profileTitle(activeProfile) }}</strong><small>{{ activeProfile?.name || '未选择机器人' }}</small></span>
                     <AppIcon name="chevron-down" :size="14" />
                   </button>
-                  <div v-if="profileMenuOpen" class="settings-agent-menu" role="listbox" aria-label="切换正在设置的 Agent" @keydown="handleAgentMenuKeydown">
+                  <div v-if="profileMenuOpen" class="settings-agent-menu" role="listbox" aria-label="切换正在设置的机器人" @keydown="handleAgentMenuKeydown">
                     <button v-for="profile in profiles" :key="profile.name" type="button" role="option" :aria-selected="profile.name === activeProfile?.name" @click="selectProfile(profile.name)">
                       <AgentAvatar :name="profileTitle(profile)" :avatar="profile.agentAvatar || ''" :size="24" />
                       <span><strong>{{ profileTitle(profile) }}</strong><small>{{ profile.name }}</small></span>
@@ -302,7 +302,7 @@ function requestModeSwitch() {
                 <nav>
                   <section v-if="isAdmin"><button type="button" :disabled="updateLocked" @click="requestModeSwitch"><AppIcon :name="botMode ? 'chat' : 'users'" :size="18" /><span>{{ botMode ? '进入聊天模式' : '进入 Bot 模式' }}</span></button></section>
                   <section>
-                    <h3>当前 Agent</h3>
+                    <h3>当前机器人</h3>
                     <button v-for="item in agentItems" :key="item.key" type="button" :class="{ active: activePage === item.key }" :aria-current="activePage === item.key ? 'page' : undefined" @click="selectPage(item.key)"><AppIcon :name="item.icon" :size="20" /><span>{{ item.label }}</span></button>
                   </section>
                   <section>
@@ -336,7 +336,7 @@ function requestModeSwitch() {
                   @dirty-change="setDirty('agent-identity', $event)"
                   @save="emit('save-identity', $event)"
                 />
-                <p v-else-if="activePage === 'agent-identity'" class="settings-empty">尚未选择 Agent。</p>
+                <p v-else-if="activePage === 'agent-identity'" class="settings-empty">尚未选择机器人。</p>
                 <ModelServicesPanel v-else-if="activePage === 'agent-models' && activeProfile && isAdmin" :key="activeProfile.name" :profile="activeProfile.name" @dirty-change="setDirty('agent-models', $event)" />
                 <AccountSecurityPanel
                   v-else-if="activePage === 'account-security'"

+ 3 - 3
src/client/components/app/SystemManagementPanel.vue

@@ -414,8 +414,8 @@ watch(() => [props.active, props.section] as const, ([active, section]) => {
           <small>{{ user.role === 'admin' ? '管理员' : user.enabled ? (user.mustChangePassword ? '等待修改临时密码' : '普通用户') : '已禁用' }}</small>
         </span>
         <template v-if="user.role !== 'admin'">
-          <label class="user-assignment">基础 Agent
-            <select v-model="userAssignments[user.id]" multiple :disabled="busy" :aria-label="`分配给 ${user.username} 的基础 Agent`">
+          <label class="user-assignment">基础机器人
+            <select v-model="userAssignments[user.id]" multiple :disabled="busy" :aria-label="`分配给 ${user.username} 的基础机器人`">
               <option v-for="profile in profiles" :key="profile.name" :value="profile.name">{{ profile.agentName || profile.displayName || profile.name }}</option>
             </select>
           </label>
@@ -428,7 +428,7 @@ watch(() => [props.active, props.section] as const, ([active, section]) => {
       <form class="user-create-form" aria-label="创建用户" @submit.prevent="add">
         <label><span>新用户名</span><input v-model="username" name="managed-username" autocomplete="off" :disabled="busy" /></label>
         <label><span>临时密码</span><input v-model="password" name="managed-temporary-password" type="password" autocomplete="new-password" :disabled="busy" /><small>至少 8 位</small></label>
-        <label class="create-assignment"><span>分配基础 Agent</span><select v-model="assignedProfiles" multiple :disabled="busy" aria-label="新子账号的基础 Agent"><option v-for="profile in profiles" :key="profile.name" :value="profile.name">{{ profile.agentName || profile.displayName || profile.name }}</option></select><small>子账号仅可使用 Bot 模式,基于分配的 Agent 创建自己的 Agent;未分配时不可创建。保存权限后需重新登录。</small></label>
+        <label class="create-assignment"><span>分配基础机器人</span><select v-model="assignedProfiles" multiple :disabled="busy" aria-label="新子账号的基础机器人"><option v-for="profile in profiles" :key="profile.name" :value="profile.name">{{ profile.agentName || profile.displayName || profile.name }}</option></select><small>子账号仅可使用 Bot 模式,基于分配的机器人创建自己的机器人;未分配时不可创建。保存权限后需重新登录。</small></label>
         <button class="solid-button" :disabled="busy || !username.trim() || password.length < 8">创建用户</button>
       </form>
     </div>

+ 1 - 1
src/client/components/app/SystemOverviewPanel.vue

@@ -71,7 +71,7 @@ watch(() => props.active, active => { if (active) void refresh() }, { immediate:
 <template>
   <section class="system-overview-panel" aria-label="系统概览">
     <div class="overview-toolbar">
-      <p>影响整个夭夭安装及所有 Agent,仅管理员可见。</p>
+      <p>影响整个夭夭安装及所有机器人,仅管理员可见。</p>
       <button type="button" :disabled="checking" @click="refresh"><AppIcon name="refresh" :size="16" />{{ checking ? '检查中…' : '检查系统状态' }}</button>
     </div>
     <p v-if="error" class="overview-warning" role="status">{{ error }}</p>

+ 12 - 12
src/client/components/app/WorkspaceShell.vue

@@ -119,7 +119,7 @@ const desktopSidebarContext = ref<HTMLElement | null>(null)
 const mobileSidebarContext = ref<HTMLElement | null>(null)
 
 function profileTitle(profile?: Profile): string {
-  return profile?.agentName || profile?.displayName || profile?.name || '未选择 Agent'
+  return profile?.agentName || profile?.displayName || profile?.name || '未选择机器人'
 }
 
 const navItems: NavItem[] = [
@@ -391,13 +391,13 @@ defineExpose({openLocalVm:()=>{if(props.isAdmin)openSettings('system-local-vm')}
       :inert="mobileDrawerOpen"
     >
       <div v-if="applicationWorkspace" class="bot-list-header">
-        <button class="bot-logo-trigger sidebar-brand" type="button" aria-label="返回 Bot 列表" title="夭夭 Web" @click="navigate('/conversations')"><BrandMark :size="32" :label="false" compact bare /></button>
+        <button class="bot-logo-trigger sidebar-brand" type="button" aria-label="返回 Bot 列表" title="夭夭 AI" @click="navigate('/conversations')"><BrandMark :size="32" :label="false" compact bare /></button>
         <span class="bot-list-header__spacer" />
         <button class="bot-list-toolbar-button sidebar-search-trigger" type="button" aria-label="搜索" :aria-expanded="sidebarSearchOpen" @click="openSidebarSearch(desktopSidebarContext)"><AppIcon name="search" :size="21" /></button>
         <button class="bot-list-toolbar-button sidebar-create-trigger" type="button" aria-label="新建" aria-haspopup="menu" :aria-expanded="createMenuOpen" @click="openCreateMenu"><AppIcon name="plus" :size="23" /></button>
       </div>
       <div v-else class="sidebar-brand-row">
-        <button class="rail__brand sidebar-brand" type="button" aria-label="返回聊天" title="夭夭 Web" @click="navigate(applicationWorkspace ? '/conversations' : '/chat')">
+        <button class="rail__brand sidebar-brand" type="button" aria-label="返回聊天" title="夭夭 AI" @click="navigate(applicationWorkspace ? '/conversations' : '/chat')">
           <BrandMark :size="sidebarCollapsed ? 26 : 32" :label="false" compact bare />
         </button>
       </div>
@@ -469,12 +469,12 @@ defineExpose({openLocalVm:()=>{if(props.isAdmin)openSettings('system-local-vm')}
 
       <div class="sidebar-footer">
         <div class="sidebar-account-switcher">
-          <button class="sidebar-account-switcher__main" type="button" :title="applicationWorkspace ? '当前账号' : `切换 Agent:${profileTitle(activeProfile)}`" :aria-haspopup="applicationWorkspace ? undefined : 'listbox'" :aria-expanded="applicationWorkspace ? undefined : profileMenuOpen" @click="applicationWorkspace ? openSettings('account-security', $event) : toggleProfileMenu($event)">
+          <button class="sidebar-account-switcher__main" type="button" :title="applicationWorkspace ? '当前账号' : `切换机器人:${profileTitle(activeProfile)}`" :aria-haspopup="applicationWorkspace ? undefined : 'listbox'" :aria-expanded="applicationWorkspace ? undefined : profileMenuOpen" @click="applicationWorkspace ? openSettings('account-security', $event) : toggleProfileMenu($event)">
             <AccountInitialAvatar v-if="applicationWorkspace" :name="userName" :image-url="userAvatar" :size="30" />
             <AgentAvatar v-else :name="profileTitle(activeProfile)" :avatar="activeProfile?.agentAvatar || ''" :size="30" />
             <span class="account-copy">
               <strong>{{ applicationWorkspace ? userName : profileTitle(activeProfile) }}</strong>
-              <span>{{ serverName || (applicationWorkspace ? '当前账号' : activeProfile?.name || userName || '未选择 Agent') }}</span>
+              <span>{{ serverName || (applicationWorkspace ? '当前账号' : activeProfile?.name || userName || '未选择机器人') }}</span>
             </span>
             <AppIcon v-if="!applicationWorkspace" class="sidebar-account-switcher__chevron" name="chevron-down" :size="14" />
           </button>
@@ -482,8 +482,8 @@ defineExpose({openLocalVm:()=>{if(props.isAdmin)openSettings('system-local-vm')}
             <AppIcon name="settings" :size="17" />
           </button>
           <Transition name="menu-fade">
-            <div v-if="profileMenuOpen" class="profile-menu" role="listbox" aria-label="切换 Agent" @keydown="handleProfileMenuKeydown">
-              <strong class="profile-menu__heading">切换 Agent</strong>
+            <div v-if="profileMenuOpen" class="profile-menu" role="listbox" aria-label="切换机器人" @keydown="handleProfileMenuKeydown">
+              <strong class="profile-menu__heading">切换机器人</strong>
               <button
                 v-for="profile in profiles"
                 :key="profile.name"
@@ -576,12 +576,12 @@ defineExpose({openLocalVm:()=>{if(props.isAdmin)openSettings('system-local-vm')}
 
       <div class="sidebar-footer mobile-drawer__footer">
         <div class="sidebar-account-switcher">
-          <button class="sidebar-account-switcher__main" type="button" :title="applicationWorkspace ? '当前账号' : `切换 Agent:${profileTitle(activeProfile)}`" :aria-haspopup="applicationWorkspace ? undefined : 'listbox'" :aria-expanded="applicationWorkspace ? undefined : profileMenuOpen" @click="applicationWorkspace ? openSettings('account-security', $event) : toggleProfileMenu($event)">
+          <button class="sidebar-account-switcher__main" type="button" :title="applicationWorkspace ? '当前账号' : `切换机器人:${profileTitle(activeProfile)}`" :aria-haspopup="applicationWorkspace ? undefined : 'listbox'" :aria-expanded="applicationWorkspace ? undefined : profileMenuOpen" @click="applicationWorkspace ? openSettings('account-security', $event) : toggleProfileMenu($event)">
             <AccountInitialAvatar v-if="applicationWorkspace" :name="userName" :image-url="userAvatar" :size="30" />
             <AgentAvatar v-else :name="profileTitle(activeProfile)" :avatar="activeProfile?.agentAvatar || ''" :size="30" />
             <span class="account-copy">
               <strong>{{ applicationWorkspace ? userName : profileTitle(activeProfile) }}</strong>
-              <span>{{ serverName || (applicationWorkspace ? '当前账号' : activeProfile?.name || userName || '未选择 Agent') }}</span>
+              <span>{{ serverName || (applicationWorkspace ? '当前账号' : activeProfile?.name || userName || '未选择机器人') }}</span>
             </span>
             <AppIcon v-if="!applicationWorkspace" class="sidebar-account-switcher__chevron" name="chevron-down" :size="14" />
           </button>
@@ -589,8 +589,8 @@ defineExpose({openLocalVm:()=>{if(props.isAdmin)openSettings('system-local-vm')}
             <AppIcon name="settings" :size="17" />
           </button>
           <Transition name="menu-fade">
-            <div v-if="profileMenuOpen" class="profile-menu" role="listbox" aria-label="切换 Agent" @keydown="handleProfileMenuKeydown">
-              <strong class="profile-menu__heading">切换 Agent</strong>
+            <div v-if="profileMenuOpen" class="profile-menu" role="listbox" aria-label="切换机器人" @keydown="handleProfileMenuKeydown">
+              <strong class="profile-menu__heading">切换机器人</strong>
               <button
                 v-for="profile in profiles"
                 :key="profile.name"
@@ -660,7 +660,7 @@ defineExpose({openLocalVm:()=>{if(props.isAdmin)openSettings('system-local-vm')}
       <div v-if="createMenuOpen" class="workspace-create-dismiss" @pointerdown.self="closeCreateMenu" @keydown.esc.prevent.stop="closeCreateMenu">
         <div ref="createMenu" class="workspace-create-menu" :style="createPosition" role="menu" aria-label="新建聊天" @keydown="actionMenuKeydown">
           <button type="button" role="menuitem" @click="chooseCreate('agent')"><AppIcon name="users" :size="17" />新建 Bot</button>
-          <button v-if="isAdmin" type="button" role="menuitem" @click="chooseCreate('remote-agent')"><AppIcon name="users" :size="17" />添加远程 Agent</button>
+          <button v-if="isAdmin" type="button" role="menuitem" @click="chooseCreate('remote-agent')"><AppIcon name="users" :size="17" />添加远程机器人</button>
           <button type="button" role="menuitem" @click="chooseCreate('group')"><AppIcon name="groups" :size="17" />新建群聊</button>
         </div>
       </div>

+ 5 - 1
src/client/components/common/AppIcon.vue

@@ -49,6 +49,8 @@ type IconName =
   | 'globe'
   | 'bell'
   | 'monitor'
+  | 'calendar'
+  | 'bug'
 
 withDefaults(defineProps<{ name: IconName; size?: number }>(), { size: 18 })
 </script>
@@ -66,7 +68,9 @@ withDefaults(defineProps<{ name: IconName; size?: number }>(), { size: 18 })
     stroke-linejoin="round"
     aria-hidden="true"
   >
-    <template v-if="name === 'monitor'"><rect x="3" y="3" width="18" height="13" rx="2"/><path d="M8 21h8M12 16v5"/></template>
+    <template v-if="name === 'calendar'"><rect x="3" y="5" width="18" height="16" rx="2"/><path d="M16 3v4M8 3v4M3 11h18M8 15h2M14 15h2M8 18h2"/></template>
+    <template v-else-if="name === 'bug'"><path d="M8 9h8v7a4 4 0 0 1-8 0V9ZM9 9V6a3 3 0 0 1 6 0v3M12 10v10M4 10h4M16 10h4M3 15h5M16 15h5M5 21l3-3M16 18l3 3M5 4l4 3M15 7l4-3"/></template>
+    <template v-else-if="name === 'monitor'"><rect x="3" y="3" width="18" height="13" rx="2"/><path d="M8 21h8M12 16v5"/></template>
     <template v-else-if="name === 'chat'">
       <path d="M8 18h-3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2h-5l-6 4z" />
       <path d="M8 9h8M8 13h5" />

+ 1 - 1
src/client/components/common/BrandMark.vue

@@ -17,7 +17,7 @@ withDefaults(defineProps<{
     <span class="brand-mark__plate" :style="{ width: `${size}px`, height: `${size}px` }">
       <img src="/brand/AppIcon-1024.png" alt="" aria-hidden="true" />
     </span>
-    <span v-if="label" class="brand-mark__name">夭夭 Web</span>
+    <span v-if="label" class="brand-mark__name">夭夭 AI</span>
   </span>
 </template>
 

+ 2 - 2
src/client/components/composer/ComposerShell.vue

@@ -417,7 +417,7 @@ defineExpose({
 
     <div v-if="mode === 'group'" class="composer-activity-slot">
       <Transition name="composer-activity">
-        <div v-if="activityText" class="composer-activity" role="status" aria-label="Agent 输入状态" aria-live="polite" aria-atomic="true">
+        <div v-if="activityText" class="composer-activity" role="status" aria-label="机器人输入状态" aria-live="polite" aria-atomic="true">
           <span class="composer-typing-dots" aria-hidden="true"><i /><i /><i /></span>
           <strong>{{ activityText }}</strong>
         </div>
@@ -533,7 +533,7 @@ defineExpose({
 
       <Transition name="composer-menu">
         <div v-if="menuKind && menuOptions.length" class="composer-menu" role="listbox">
-          <div class="composer-menu__label">{{ menuKind === 'mention' ? '提及 Agent' : '命令' }}</div>
+          <div class="composer-menu__label">{{ menuKind === 'mention' ? '提及机器人' : '命令' }}</div>
           <button
             v-for="(option, index) in menuOptions"
             :key="option.id"

+ 8 - 8
src/client/components/groups/CreateGroupDialog.vue

@@ -152,12 +152,12 @@ function create() {
         <section class="create-dialog" role="dialog" aria-modal="true" aria-labelledby="create-group-title">
           <header><div><small>9119 团队</small><h2 id="create-group-title">新建团队</h2></div><button class="icon-button" type="button" aria-label="关闭" @click="emit('close')"><AppIcon name="close" /></button></header>
           <section class="preset-picker" aria-labelledby="team-preset-label">
-            <div class="preset-picker__heading"><span id="team-preset-label">团队预设</span><small>选择后自动分配现有 Agent</small></div>
+            <div class="preset-picker__heading"><span id="team-preset-label">团队预设</span><small>选择后自动分配现有机器人</small></div>
             <div class="preset-grid">
               <button type="button" :class="{ selected: selectedPresetId === 'custom' }" @click="choosePreset()">
-                <strong>自定义团队</strong><small>手动选择 Agent 和协作配置</small><em>自由配置</em>
+                <strong>自定义团队</strong><small>手动选择机器人和协作配置</small><em>自由配置</em>
               </button>
-              <button v-for="preset in TEAM_PRESETS" :key="preset.id" type="button" :class="{ selected: selectedPresetId === preset.id }" :disabled="presetShortage(preset) > 0" :aria-label="`${preset.name},${preset.roles.length} 人${presetShortage(preset) ? `,还缺 ${presetShortage(preset)} 个 Agent` : ''}`" @click="choosePreset(preset)">
+              <button v-for="preset in TEAM_PRESETS" :key="preset.id" type="button" :class="{ selected: selectedPresetId === preset.id }" :disabled="presetShortage(preset) > 0" :aria-label="`${preset.name},${preset.roles.length} 人${presetShortage(preset) ? `,还缺 ${presetShortage(preset)} 个机器人` : ''}`" @click="choosePreset(preset)">
                 <strong>{{ preset.name }}</strong><small>{{ preset.summary }}</small><em>{{ presetShortage(preset) ? `还缺 ${presetShortage(preset)} 人` : `${preset.roles.length} 人` }}</em>
               </button>
             </div>
@@ -169,22 +169,22 @@ function create() {
             <input ref="avatarInput" class="sr-only" type="file" accept="image/png,image/jpeg,image/webp" @change="chooseAvatar" />
           </section>
           <p v-if="avatarError" class="avatar-error" role="alert">{{ avatarError }}</p>
-          <label v-if="roomInstructionsEnabled" class="field room-instructions"><span>说明 <small>供所有 Agent 查阅的规则和形式准则</small></span><textarea v-model="instructions" maxlength="4000" rows="4" placeholder="例如:先确认事实;结论使用中文;涉及发布必须等待确认。" /></label>
+          <label v-if="roomInstructionsEnabled" class="field room-instructions"><span>说明 <small>供所有机器人查阅的规则和形式准则</small></span><textarea v-model="instructions" maxlength="4000" rows="4" placeholder="例如:先确认事实;结论使用中文;涉及发布必须等待确认。" /></label>
           <section v-if="selectedPreset" class="role-mapping" aria-labelledby="role-mapping-label">
-            <div class="role-mapping__heading"><span id="role-mapping-label">角色分配</span><small>{{ selectedPreset.roles.length }} 个角色已对应当前 Agent</small></div>
+            <div class="role-mapping__heading"><span id="role-mapping-label">角色分配</span><small>{{ selectedPreset.roles.length }} 个角色已对应当前机器人</small></div>
             <label v-for="(role, index) in selectedPreset.roles" :key="role.name">
               <span><strong>{{ role.name }}<em v-if="hostEnabled && role.host">管理员</em></strong><small>{{ role.description }}</small></span>
-              <select :value="selected[index]" :aria-label="`${role.name}对应的 Agent`" @change="assignRole(index, ($event.target as HTMLSelectElement).value)">
+              <select :value="selected[index]" :aria-label="`${role.name}对应的机器人`" @change="assignRole(index, ($event.target as HTMLSelectElement).value)">
                 <option v-for="profile in profiles" :key="profile.id" :value="profile.id">{{ profile.displayName }} · {{ profile.nodeLabel }}</option>
               </select>
             </label>
           </section>
           <div v-else class="agent-picker">
-            <div class="agent-picker__heading"><span>选择 Agent</span><small>{{ selected.length }}/8</small></div>
+            <div class="agent-picker__heading"><span>选择机器人</span><small>{{ selected.length }}/8</small></div>
             <button v-for="profile in profiles" :key="profile.id" type="button" :class="{ selected: selected.includes(profile.id) }" :disabled="!selected.includes(profile.id) && selected.length >= 8" @click="toggle(profile)">
               <AgentAvatar :name="profile.displayName" :avatar="profile.avatar || ''" :size="28" /><strong>{{ profile.displayName }}<small>{{ profile.profile }} · {{ profile.nodeLabel }}</small></strong><AppIcon v-if="selected.includes(profile.id)" name="check" :size="15" />
             </button>
-            <p v-if="!profiles.length">当前没有可用 Agent,请先在 Hermes 配置 Profile。</p>
+            <p v-if="!profiles.length">当前没有可用机器人,请先在 Hermes 配置 Profile。</p>
           </div>
           <label v-if="hostEnabled && !selectedPreset" class="host-picker">
             <span>管理员<small>用户没有明确 @ 时,管理员始终负责回应。</small></span>

+ 11 - 11
src/client/components/groups/GroupManager.vue

@@ -270,11 +270,11 @@ function statusLabel(status: GroupAgent['status']): string {
         <input ref="avatarInput" class="sr-only" type="file" accept="image/png,image/jpeg,image/webp" @change="chooseAvatar" />
       </div>
       <p v-if="avatarError" class="avatar-error" role="alert">{{ avatarError }}</p>
-      <label v-if="roomInstructionsEnabled"><span>说明<small>所有 Agent 都会在回复前查阅,可填写协作规则和形式准则。</small></span><textarea v-model="form.instructions" maxlength="4000" rows="5" aria-label="团队说明" placeholder="例如:先核对事实;结论使用中文;发布前等待确认。" @change="saveRoom" /></label>
+      <label v-if="roomInstructionsEnabled"><span>说明<small>所有机器人都会在回复前查阅,可填写协作规则和形式准则。</small></span><textarea v-model="form.instructions" maxlength="4000" rows="5" aria-label="团队说明" placeholder="例如:先核对事实;结论使用中文;发布前等待确认。" @change="saveRoom" /></label>
       <label class="rounds"><span>最多回复轮数<small>-1 表示无限</small></span><input v-model.number="form.replyRounds" type="number" min="-1" max="100" aria-label="最多回复轮数" @change="saveRoom" /></label>
       <label v-if="hostFlowEnabled" class="flow-mode">
         <span>协作模式<small>管理员可按依赖逐步调度,也可一次 @ 多人并列执行。</small></span>
-        <select v-model="form.orchestrationMode" aria-label="协作模式" :disabled="busy || hasActiveAgents" :title="hasActiveAgents ? '请等待当前回复完成或先中断 Agent' : ''" @change="saveRoom">
+        <select v-model="form.orchestrationMode" aria-label="协作模式" :disabled="busy || hasActiveAgents" :title="hasActiveAgents ? '请等待当前回复完成或先中断机器人' : ''" @change="saveRoom">
           <option value="free">自由讨论</option>
           <option value="host">管理员协调</option>
         </select>
@@ -301,8 +301,8 @@ function statusLabel(status: GroupAgent['status']): string {
       </div>
 
       <div v-if="agents.length < 8 && availableProfiles?.length" class="add-agent">
-        <select aria-label="选择要添加的 Agent" @change="($event.target as HTMLSelectElement).value && emit('addAgent', ($event.target as HTMLSelectElement).value); ($event.target as HTMLSelectElement).value = ''">
-          <option value="">添加 Agent…</option>
+        <select aria-label="选择要添加的机器人" @change="($event.target as HTMLSelectElement).value && emit('addAgent', ($event.target as HTMLSelectElement).value); ($event.target as HTMLSelectElement).value = ''">
+          <option value="">添加机器人…</option>
           <option v-for="profile in availableProfiles" :key="profile.id" :value="profile.id">{{ profile.displayName }} · {{ profile.nodeLabel }}</option>
         </select>
       </div>
@@ -316,18 +316,18 @@ function statusLabel(status: GroupAgent['status']): string {
 
   <Teleport to="body">
     <div v-if="selectedAgent && agentDrafts[selectedAgent.id]" class="agent-settings-backdrop" @click.self="closeAgentSettings">
-      <section class="agent-settings-dialog" role="dialog" aria-modal="true" :aria-label="`${selectedAgent.displayName} Agent 设置`" @keydown.esc="closeAgentSettings">
+      <section class="agent-settings-dialog" role="dialog" aria-modal="true" :aria-label="`${selectedAgent.displayName}机器人设置`" @keydown.esc="closeAgentSettings">
         <header>
           <span>
-            <small>Agent 设置</small>
+            <small>机器人设置</small>
             <strong class="settings-agent-name">{{ selectedAgent.displayName }}<em v-if="hostEnabled && selectedAgent.isHost" class="host-badge">管理员</em></strong>
           </span>
-          <button class="agent-settings-close" type="button" aria-label="关闭 Agent 设置" title="关闭 Agent 设置" @click="closeAgentSettings"><AppIcon name="close" :size="17" /></button>
+          <button class="agent-settings-close" type="button" aria-label="关闭机器人设置" title="关闭机器人设置" @click="closeAgentSettings"><AppIcon name="close" :size="17" /></button>
         </header>
         <fieldset class="agent-editor">
-          <legend class="sr-only">{{ selectedAgent.displayName }} Agent 设置</legend>
+          <legend class="sr-only">{{ selectedAgent.displayName }} 机器人设置</legend>
           <div class="editor-grid">
-            <label v-if="isRemoteAgent(selectedAgent)"><span>群内名称<small>仅影响此群,会同步到其他设备;不修改远端 Agent 名称。</small></span><input v-model="agentDrafts[selectedAgent.id].displayName" maxlength="100" aria-label="群内名称" @input="markDirty(selectedAgent.id)" /></label>
+            <label v-if="isRemoteAgent(selectedAgent)"><span>群内名称<small>仅影响此群,会同步到其他设备;不修改远端机器人名称。</small></span><input v-model="agentDrafts[selectedAgent.id].displayName" maxlength="100" aria-label="群内名称" @input="markDirty(selectedAgent.id)" /></label>
             <label><span>职责说明</span><textarea v-model="agentDrafts[selectedAgent.id].description" rows="3" maxlength="500" aria-label="职责说明" @input="markDirty(selectedAgent.id)" /></label>
             <label>
               <span>模型</span>
@@ -358,11 +358,11 @@ function statusLabel(status: GroupAgent['status']): string {
             <label><input v-model="agentDrafts[selectedAgent.id].enabled" type="checkbox" aria-label="启用" @change="markDirty(selectedAgent.id)" />启用</label>
             <label><input v-model="agentDrafts[selectedAgent.id].replyWithoutMention" type="checkbox" :aria-label="hostEnabled ? '无需 @ 也回复' : '自动回复'" @change="markDirty(selectedAgent.id)" />{{ hostEnabled ? '无需 @ 也回复' : '自动回复' }}</label>
           </div>
-          <p v-if="hostEnabled" class="host-explanation">{{ form.orchestrationMode === 'host' ? '管理员协调下此开关暂不触发自动并发;切回自由讨论后继续按原设置生效。' : (selectedAgent.isHost ? '管理员始终处理用户无 @ 消息;此开关仅决定是否自动参与 Agent 发出的无 @ 消息。' : '开启后,该成员会自动参与未明确 @ 的消息;用户无 @ 消息仍由管理员兜底。') }}</p>
+          <p v-if="hostEnabled" class="host-explanation">{{ form.orchestrationMode === 'host' ? '管理员协调下此开关暂不触发自动并发;切回自由讨论后继续按原设置生效。' : (selectedAgent.isHost ? '管理员始终处理用户无 @ 消息;此开关仅决定是否自动参与机器人发出的无 @ 消息。' : '开启后,该成员会自动参与未明确 @ 的消息;用户无 @ 消息仍由管理员兜底。') }}</p>
           <p v-if="agentUpdateError?.[selectedAgent.id]" class="agent-save-error" role="alert">{{ agentUpdateError[selectedAgent.id] }}</p>
           <div class="editor-actions">
             <button class="quiet-button" type="button" :disabled="busy || !hasAgentChanges(selectedAgent)" @click="resetAgent(selectedAgent)">取消更改</button>
-            <button class="save-agent" type="button" :disabled="busy || !hasAgentChanges(selectedAgent)" @click="saveAgent(selectedAgent)">保存 Agent 设置</button>
+            <button class="save-agent" type="button" :disabled="busy || !hasAgentChanges(selectedAgent)" @click="saveAgent(selectedAgent)">保存机器人设置</button>
           </div>
         </fieldset>
       </section>

+ 2 - 2
src/client/components/groups/TopicTeamPickerDialog.vue

@@ -40,7 +40,7 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown))
             <article v-for="room in rooms" :key="room.id" :class="{ current: room.id === currentRoomId, expanded: expandedRoomId === room.id }">
               <button class="topic-team-picker__choose" type="button" @click="emit('select', room.id)">
                 <TeamAvatar :name="room.name" :avatar="room.avatar || ''" :members="room.avatarMembers?.map(member => ({ name: member.displayName })) || []" :fallback-key="room.id" :size="34" />
-                <span class="topic-team-picker__copy"><strong>{{ room.name }}</strong><small>{{ room.agentCount }} 个 Agent</small></span>
+                <span class="topic-team-picker__copy"><strong>{{ room.name }}</strong><small>{{ room.agentCount }} 个机器人</small></span>
                 <em v-if="room.id === currentRoomId">当前</em>
                 <AppIcon class="topic-team-picker__next" name="chevron-left" :size="15" />
               </button>
@@ -50,7 +50,7 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown))
               <section v-if="expandedRoomId === room.id" class="topic-team-picker__details" :aria-label="`${room.name}团队详情`">
                 <p><strong>团队说明</strong><span>{{ room.instructions || '未填写团队说明' }}</span></p>
                 <dl>
-                  <div><dt>成员</dt><dd>{{ room.avatarMembers?.map(member => member.displayName).join('、') || `${room.agentCount} 个 Agent` }}</dd></div>
+                  <div><dt>成员</dt><dd>{{ room.avatarMembers?.map(member => member.displayName).join('、') || `${room.agentCount} 个机器人` }}</dd></div>
                   <div><dt>协作方式</dt><dd>{{ room.orchestrationMode === 'host' ? '管理员协调' : '自由讨论' }}</dd></div>
                   <div><dt>最多回复</dt><dd>{{ room.maxReplyRounds }} 轮</dd></div>
                 </dl>

+ 2 - 2
src/client/components/kanban/KanbanTaskDrawer.vue

@@ -165,13 +165,13 @@ function metadataText(value: unknown): string {
           <article v-for="item in detail.comments" :key="item.id"><header><strong>{{ item.author }}</strong><time>{{ formatKanbanTime(item.created_at) }}</time></header><p>{{ item.body }}</p></article>
         </div>
         <p v-else class="kanban-empty-copy">还没有评论。</p>
-        <form v-if="canEdit" class="kanban-comment-form" @submit.prevent="sendComment"><textarea v-model="comment" rows="3" placeholder="补充上下文或给 Agent 留言" /><button type="submit" :disabled="busy || !comment.trim()">添加评论</button></form>
+        <form v-if="canEdit" class="kanban-comment-form" @submit.prevent="sendComment"><textarea v-model="comment" rows="3" placeholder="补充上下文或给机器人留言" /><button type="submit" :disabled="busy || !comment.trim()">添加评论</button></form>
       </section>
 
       <section class="kanban-detail-section">
         <h3>运行记录 <span>{{ detail.runs.length }}</span></h3>
         <div v-if="detail.runs.length" class="kanban-runs">
-          <article v-for="run in detail.runs" :key="run.id"><header><strong>{{ run.profile || '未指定 Agent' }}</strong><span>{{ run.outcome || run.status }}</span></header><p v-if="run.summary">{{ run.summary }}</p><p v-if="run.error" class="run-error">{{ run.error }}</p><pre v-if="metadataText(run.metadata)">{{ metadataText(run.metadata) }}</pre><time>{{ formatKanbanTime(run.started_at) }}<template v-if="run.ended_at"> → {{ formatKanbanTime(run.ended_at) }}</template></time></article>
+          <article v-for="run in detail.runs" :key="run.id"><header><strong>{{ run.profile || '未指定机器人' }}</strong><span>{{ run.outcome || run.status }}</span></header><p v-if="run.summary">{{ run.summary }}</p><p v-if="run.error" class="run-error">{{ run.error }}</p><pre v-if="metadataText(run.metadata)">{{ metadataText(run.metadata) }}</pre><time>{{ formatKanbanTime(run.started_at) }}<template v-if="run.ended_at"> → {{ formatKanbanTime(run.ended_at) }}</template></time></article>
         </div>
         <p v-else class="kanban-empty-copy">尚未产生运行记录。</p>
       </section>

+ 4 - 4
src/client/components/kanban/presentation.ts

@@ -4,10 +4,10 @@ export const KANBAN_STATUS_META: Record<string, { label: string; color: string;
   triage: { label: '待分诊', color: '#8b8b86', description: '需要补充或拆解的任务' },
   todo: { label: '待办', color: '#68727e', description: '已明确但尚未进入执行队列' },
   scheduled: { label: '已计划', color: '#8b5cf6', description: '由系统在指定时间唤醒' },
-  ready: { label: '就绪', color: '#1677ff', description: '等待调度器分配 Agent' },
-  running: { label: '进行中', color: '#1a9a68', description: 'Agent 正在处理' },
+  ready: { label: '就绪', color: '#1677ff', description: '等待调度器分配机器人' },
+  running: { label: '进行中', color: '#1a9a68', description: '机器人正在处理' },
   blocked: { label: '已阻塞', color: '#d44848', description: '等待外部输入或恢复' },
-  review: { label: '评审中', color: '#c58a15', description: '等待人工或 Agent 评审' },
+  review: { label: '评审中', color: '#c58a15', description: '等待人工或机器人评审' },
   done: { label: '已完成', color: '#66756d', description: '已经完成的任务' },
   archived: { label: '已归档', color: '#999994', description: '已从活动看板移除' },
 }
@@ -53,7 +53,7 @@ export function eventDescription(event: KanbanEvent): string {
   if (event.kind === 'status') return `移动到 ${statusMeta(text('status')).label}`
   if (event.kind === 'assigned') return text('assignee') ? `分配给 ${text('assignee')}` : '取消分配'
   if (event.kind === 'commented') return `添加评论${text('author') ? ` · ${text('author')}` : ''}`
-  if (event.kind === 'claimed' || event.kind === 'spawned') return 'Agent 开始处理'
+  if (event.kind === 'claimed' || event.kind === 'spawned') return '机器人开始处理'
   if (event.kind === 'completed') return '任务完成'
   if (event.kind === 'blocked') return `任务阻塞${text('reason') ? ` · ${text('reason')}` : ''}`
   if (event.kind === 'unblocked') return '任务已恢复'

+ 1 - 1
src/client/components/messages/MessageTimeline.vue

@@ -307,7 +307,7 @@ defineExpose({ scrollToMessage, scrollToAnchor, scrollToBottom, isFollowingBotto
             </template>
             <template v-else>
             <div v-if="message.role !== 'assistant' || showAssistantIdentity" class="message__meta">
-              <strong><AppIcon v-if="message.isRemoteAgent" class="message__remote-agent" name="globe" :size="12" />{{ message.role === 'user' ? '你' : message.author || message.profile || (message.role === 'assistant' ? 'Agent' : '系统') }}</strong>
+              <strong><AppIcon v-if="message.isRemoteAgent" class="message__remote-agent" name="globe" :size="12" />{{ message.role === 'user' ? '你' : message.author || message.profile || (message.role === 'assistant' ? '机器人' : '系统') }}</strong>
               <span v-if="message.metadata" class="message__execution">{{ message.metadata }}</span>
               <time>{{ formatTime(message.createdAt) }}</time>
               <span v-if="message.status && !['settled', 'streaming'].includes(message.status)">{{ { preparing: '准备中', attached: '附件已就绪', pending: '等待回执', accepted: '已接收', streaming: '生成中', settled: '已完成', failed: '发送失败', 'unknown-receipt': '回执未知' }[message.status] }}</span>

+ 29 - 0
src/client/components/workspace/BrowserToolbar.vue

@@ -0,0 +1,29 @@
+<script setup lang="ts">
+import {computed,ref,watch} from 'vue'
+import type {BotBrowserState} from '@shared/desktopEnvironment'
+const props=defineProps<{state?:BotBrowserState;enabled:boolean}>(),emit=defineEmits<{action:[action:Record<string,string>]}>()
+const address=ref(''),editing=ref(false),active=computed(()=>props.state?.tabs.find(t=>t.active))
+watch(()=>active.value?.url,url=>{if(!editing.value)address.value=url==='about:blank'?'':url??''},{immediate:true})
+function navigate(){let url=address.value.trim();if(!url)return;if(!/^https?:\/\//i.test(url))url='https://'+url;editing.value=false;emit('action',{kind:'navigate',url})}
+</script>
+<template>
+ <div class="browser-toolbar" aria-label="机器人浏览器">
+  <div class="browser-tabs" role="tablist" aria-label="浏览器标签页">
+   <div v-for="tab in state?.tabs" :key="tab.id" class="tab" :class="{active:tab.active}">
+    <button role="tab" :aria-selected="tab.active" :title="tab.title" :disabled="!enabled" @click="emit('action',{kind:'select-tab',tabId:tab.id})">{{tab.title}}</button>
+    <button class="close-tab" :aria-label="`关闭标签页 ${tab.title}`" :disabled="!enabled" @click="emit('action',{kind:'close-tab',tabId:tab.id})">×</button>
+   </div>
+   <button class="new-tab" aria-label="新建标签页" :disabled="!enabled" @click="emit('action',{kind:'new-tab',url:'https://www.google.com/'})">+</button>
+  </div>
+  <form class="navigation" @submit.prevent="navigate">
+   <button type="button" aria-label="后退" :disabled="!enabled" @click="emit('action',{kind:'back'})">←</button>
+   <button type="button" aria-label="前进" :disabled="!enabled" @click="emit('action',{kind:'forward'})">→</button>
+   <button type="button" aria-label="重新加载页面" :disabled="!enabled" @click="emit('action',{kind:'reload'})">↻</button>
+   <input v-model="address" type="text" inputmode="url" autocomplete="off" spellcheck="false" aria-label="浏览器地址" placeholder="输入网址" :disabled="!enabled" @focus="editing=true" @blur="editing=false">
+   <button type="submit" :disabled="!enabled||!address.trim()">前往</button>
+  </form>
+ </div>
+</template>
+<style scoped>
+.browser-toolbar{min-width:0;background:var(--surface-soft);border-bottom:1px solid var(--line)}.browser-tabs{display:flex;overflow-x:auto;gap:4px;padding:7px 10px 0}.tab{display:flex;align-items:center;min-width:90px;max-width:210px;border:1px solid transparent;border-radius:8px 8px 0 0}.tab.active{background:var(--surface);border-color:var(--line);border-bottom-color:var(--surface)}.tab button:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px}.browser-toolbar button{font:inherit;font-size:12px;min-width:36px;min-height:40px;background:transparent;border:0;color:var(--text-primary);cursor:pointer}.tab .close-tab{min-width:32px}.browser-toolbar button:disabled{opacity:.45;cursor:default}.navigation{display:flex;align-items:center;gap:3px;padding:5px 10px}.navigation input{flex:1;min-width:0;min-height:40px;border:1px solid var(--line);border-radius:8px;padding:6px 10px;background:var(--surface);color:var(--text-primary);font:inherit;font-size:13px}button:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}@media(max-width:600px){.navigation{padding:4px}.browser-toolbar button{min-width:40px;min-height:44px}.tab button:first-child{max-width:130px}}
+</style>

+ 50 - 27
src/client/components/workspace/ComputerPanel.vue

@@ -1,19 +1,21 @@
 <script setup lang="ts">
 import {computed,onBeforeUnmount,onMounted,ref,watch} from 'vue'
 import {apiRequest} from '@/api/client'
+import BrowserToolbar from './BrowserToolbar.vue'
+import type {BotBrowserState} from '@shared/desktopEnvironment'
 import {createUuid} from '@/utils/id'
 import type {WorkspaceAgent} from '@shared/workspace'
 import type {ComputerControlStatus,ComputerFrame,ComputerInput} from '@shared/computerControl'
 import type {JsonValue} from '@shared/types'
-const props=defineProps<{agents:WorkspaceAgent[];embedded?:boolean;autoTake?:boolean}>(),emit=defineEmits<{close:[];changed:[];controlRequest:[]}>()
+const props=defineProps<{agents:WorkspaceAgent[];embedded?:boolean;standalone?:boolean;autoTake?:boolean}>(),emit=defineEmits<{close:[];changed:[];controlRequest:[]}>()
 const selected=ref(props.agents[0]?.id??''),dialog=ref<HTMLDialogElement>()
 const state=ref<ComputerControlStatus>({mode:'off'}),frame=ref<ComputerFrame>(),ticket=ref<{controlId:string;token:string}>()
-const controlsOpen=ref(false)
+const controlsOpen=ref(false),actualSize=ref(false),browserState=ref<BotBrowserState>()
 const selectedAgent=computed(()=>props.agents.find(agent=>agent.id===selected.value))
 const error=ref(''),busy=ref(false),text=ref(''),notes=ref(''),connectionOK=ref(false)
 let takeRequestId:string|undefined
 let timer:ReturnType<typeof setTimeout>|undefined,closed=false,polling=false,lastRenew=0,generation=0
-const labels:Record<ComputerControlStatus['mode'],string>={off:'电脑未运行',idle:'虚拟机空闲 · 仅查看',agent:'Agent 正在操作',pausing:'正在等待当前操作结束',human:'人工控制中',resuming:'正在交还 Agent',error:'电脑需要检查'}
+const labels:Record<ComputerControlStatus['mode'],string>={off:'电脑未运行',idle:'电脑空闲 · 仅查看',agent:'机器人正在操作',pausing:'正在等待当前操作结束',human:'人工控制中',resuming:'正在交还机器人',error:'电脑需要检查'}
 const mine=computed(()=>!!ticket.value&&ticket.value.controlId===state.value.controlId)
 const canSend=computed(()=>connectionOK.value&&!!frame.value&&mine.value&&state.value.mode==='human'&&frame.value?.generation===state.value.generation)
 const controllable=computed(()=>canSend.value&&!busy.value)
@@ -29,11 +31,13 @@ async function refresh(){
     connectionOK.value=true
     if(ticket.value&&status.controlId!==ticket.value.controlId&&status.mode!=='pausing')ticket.value=undefined
     if(mine.value&&Date.now()-lastRenew>8000){await post('/renew',ticket.value);lastRenew=Date.now()}
-    if(status.mode!=='off'){
+    if(status.backend==='browser'){browserState.value=await apiRequest<BotBrowserState>(`/api/app/agents/${encodeURIComponent(selected.value)}/browser`)}else browserState.value=undefined
+    if(status.mode!=='off'&&(status.backend!=='browser'||browserState.value?.open)){
       const image=await apiRequest<ComputerFrame>(base+'/frame')
       if(current===generation&&!closed)frame.value=image
-    }
-  }catch(cause){if(current===generation&&!closed){connectionOK.value=false;error.value=cause instanceof Error?cause.message:'无法读取电脑状态';if([401,403,410].includes(Number((cause as {status?:number}).status))){ticket.value=undefined;frame.value=undefined;state.value={mode:'off'}}}}
+    }else frame.value=undefined
+    error.value=''
+  }catch(cause){if(current===generation&&!closed){connectionOK.value=false;frame.value=undefined;inputs.length=0;error.value=cause instanceof Error?cause.message:'无法读取电脑状态';if([401,403,410].includes(Number((cause as {status?:number}).status))){ticket.value=undefined;frame.value=undefined;state.value={mode:'off'}}}}
   finally{polling=false}
 }
 async function run(action:()=>Promise<void>){
@@ -59,60 +63,75 @@ async function flushInputs(){
   try{await run(async()=>{await post('/input',{...credentials,requestId:createUuid(),generation:image.generation,frameId:image.id,action})});if(error.value)inputs.length=0}
   finally{flushing=false;if(inputs.length)setTimeout(()=>void flushInputs(),0)}
 }
-function point(event:MouseEvent|PointerEvent){const r=(event.currentTarget as HTMLImageElement).getBoundingClientRect(),f=frame.value!;return {x:Math.min(f.width-1,Math.max(0,Math.floor((event.clientX-r.left)*f.width/r.width))),y:Math.min(f.height-1,Math.max(0,Math.floor((event.clientY-r.top)*f.height/r.height)))}}
+function browserAction(action:Record<string,string>){if(!canSend.value||!frame.value||!ticket.value)return;const f=frame.value;void run(async()=>{await post('/browser',{...ticket.value,requestId:createUuid(),generation:f.generation,frameId:f.id,action})})}
+function point(event:MouseEvent|PointerEvent){
+  const r=(event.currentTarget as HTMLImageElement).getBoundingClientRect(),f=frame.value!
+  const scale=Math.min(r.width/f.width,r.height/f.height),left=r.left+(r.width-f.width*scale)/2,top=r.top+(r.height-f.height*scale)/2
+  const x=Math.floor((event.clientX-left)/scale),y=Math.floor((event.clientY-top)/scale)
+  if(x<0||y<0||x>=f.width||y>=f.height)return
+  return {x,y}
+}
 let dragStart:{x:number;y:number;clientX:number;clientY:number}|undefined,dragged=false
-function down(event:PointerEvent){if(!canSend.value||event.button!==0)return;const p=point(event);dragStart={...p,clientX:event.clientX,clientY:event.clientY};(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)}
-function up(event:PointerEvent){if(!dragStart)return;const start=dragStart;dragStart=undefined;if(!canSend.value)return;if(Math.hypot(event.clientX-start.clientX,event.clientY-start.clientY)>5){const end=point(event);dragged=true;send({kind:'drag',fromX:start.x,fromY:start.y,toX:end.x,toY:end.y})}}
+function down(event:PointerEvent){if(!canSend.value||event.button!==0)return;(event.currentTarget as HTMLElement).focus({preventScroll:true});const p=point(event);if(!p)return;dragStart={...p,clientX:event.clientX,clientY:event.clientY};(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)}
+function up(event:PointerEvent){if(!dragStart)return;const start=dragStart;dragStart=undefined;if(!canSend.value)return;if(Math.hypot(event.clientX-start.clientX,event.clientY-start.clientY)>5){const end=point(event);if(!end)return;dragged=true;send({kind:'drag',fromX:start.x,fromY:start.y,toX:end.x,toY:end.y})}}
 function wheel(event:WheelEvent){if(!canSend.value)return;event.preventDefault();send({kind:'scroll',direction:Math.abs(event.deltaX)>Math.abs(event.deltaY)?event.deltaX>0?'right':'left':event.deltaY>0?'down':'up',amount:Math.min(20,Math.max(1,Math.ceil(Math.abs(event.deltaY||event.deltaX)/80)))})}
 function keydown(event:KeyboardEvent){if(!canSend.value)return;event.preventDefault();event.stopPropagation();if(event.key==='Escape'){(event.currentTarget as HTMLElement).blur();return}const modifiers=[event.ctrlKey?'ctrl':'',event.altKey?'alt':'',event.shiftKey?'shift':'',event.metaKey?'super':''].filter(Boolean);if(event.key.length===1&&!event.ctrlKey&&!event.altKey&&!event.metaKey)send({kind:'text',text:event.key});else if(!['Control','Alt','Shift','Meta'].includes(event.key))send({kind:'key',key:({Enter:'Return',ArrowUp:'Up',ArrowDown:'Down',ArrowLeft:'Left',ArrowRight:'Right',Backspace:'BackSpace'} as Record<string,string>)[event.key]??event.key,modifiers})}
 function click(event:MouseEvent){
   if(dragged){dragged=false;return}
   if(!canSend.value||!frame.value)return
-  const rect=(event.currentTarget as HTMLImageElement).getBoundingClientRect()
-  const action:ComputerInput={kind:'click',x:Math.min(frame.value.width-1,Math.max(0,Math.floor((event.clientX-rect.left)*frame.value.width/rect.width))),y:Math.min(frame.value.height-1,Math.max(0,Math.floor((event.clientY-rect.top)*frame.value.height/rect.height))),button:event.button===2?'right':'left',count:event.detail>1?2:1}
+  const p=point(event);if(!p)return
+  const action:ComputerInput={kind:'click',...p,button:event.button===2?'right':'left',count:event.detail>1?2:1}
   if(event.button===2||event.detail>1){clearTimeout(clickTimer);pendingClick=undefined;send(action)}
   else {if(pendingClick){const old=pendingClick;pendingClick=undefined;clearTimeout(clickTimer);send(old)}pendingClick=action;clickTimer=setTimeout(()=>{const next=pendingClick;pendingClick=undefined;if(next)send(next)},180)}
 }
 async function giveBack(){if(ticket.value){await post('/giveback',{...ticket.value,notes:notes.value});ticket.value=undefined;takeRequestId=undefined;notes.value=''}}
-async function close(){if(busy.value)return;await run(giveBack);if(!ticket.value){closed=true;if(!props.embedded)dialog.value?.close();emit('close')}}
+async function close(){if(busy.value)return;await run(giveBack);if(!ticket.value){closed=true;if(!props.embedded&&!props.standalone)dialog.value?.close();emit('close')}}
+async function fullscreen(){try{if(document.fullscreenElement)await document.exitFullscreen();else await dialog.value?.requestFullscreen()}catch{error.value='无法进入全屏,请使用窗口最大化'}}
 async function cycle(){await refresh();if(!closed)timer=setTimeout(()=>void cycle(),1200)}
 watch(selected,()=>{inputs.length=0;connectionOK.value=false;generation++;takeRequestId=undefined;frame.value=undefined;ticket.value=undefined;state.value={mode:'off'};error.value='';void refresh()})
-onMounted(()=>{if(!props.embedded)dialog.value?.showModal();void cycle();if(props.autoTake)void take()})
+onMounted(()=>{if(!props.embedded&&!props.standalone)dialog.value?.showModal();void cycle();if(props.autoTake)void take()})
 onBeforeUnmount(()=>{inputs.length=0;pendingClick=undefined;clearTimeout(clickTimer);closed=true;generation++;clearTimeout(timer)})
-defineExpose({take,releaseControl:async()=>{await run(giveBack);if(ticket.value)throw new Error(error.value||'请先交还控制权')},hasControl:()=>!!ticket.value})
+defineExpose({take,close,releaseControl:async()=>{await run(giveBack);if(ticket.value)throw new Error(error.value||'请先交还控制权')},hasControl:()=>!!ticket.value})
 </script>
 <template>
-  <Teleport to="body" :disabled="embedded">
-    <component :is="embedded?'section':'dialog'" ref="dialog" class="computer-panel" :class="{embedded}" aria-label="隔离电脑" @cancel.prevent="close">
+  <Teleport to="body" :disabled="embedded||standalone">
+    <component :is="embedded||standalone?'section':'dialog'" ref="dialog" class="computer-panel" :class="{embedded,standalone}" :aria-label="state.backend==='local'?'本机':state.backend==='browser'?'浏览器':'隔离电脑'" @cancel.prevent="close">
       <header>
-        <div><strong>隔离电脑</strong><small>{{ labels[state.mode] }}</small></div>
+        <div><strong>{{state.backend==='grok'?'Grok Bot 云端电脑':state.backend==='local'?'本机 · '+state.hostName:state.backend==='browser'?'浏览器 · '+state.hostName:'隔离电脑'}}</strong><small>{{ labels[state.mode] }}</small></div>
         <select v-if="agents.length>1" v-model="selected" aria-label="选择电脑" :disabled="!!ticket"><option v-for="agent in agents" :key="agent.id" :value="agent.id">{{ agent.name }}</option></select>
         <span v-else-if="!embedded">{{ agents[0]?.name }}</span>
         <button v-if="embedded&&!ticket" :disabled="busy||state.mode==='human'" @click="emit('controlRequest')">接管电脑</button>
         <button v-if="embedded&&mine" @click="controlsOpen=!controlsOpen">键盘与操作</button>
         <button v-if="embedded&&mine" :disabled="busy||state.mode!=='human'" @click="run(giveBack)">交还</button>
-        <button v-if="!embedded" type="button" :disabled="busy" @click="close">{{ ticket ? '交还并关闭' : '关闭' }}</button>
+        <template v-if="!embedded">
+          <button v-if="mine" type="button" :aria-expanded="controlsOpen" @click="controlsOpen=!controlsOpen">键盘与操作</button>
+          <button type="button" :aria-pressed="actualSize" @click="actualSize=!actualSize">{{actualSize?'适应窗口':'原始大小'}}</button>
+          <button type="button" @click="fullscreen">全屏</button>
+        </template>
+        <button v-if="!embedded" class="return-control" type="button" :disabled="busy" @click="close">{{ ticket ? '交还并关闭' : '关闭' }}</button>
       </header>
-      <div class="computer-screen" :class="{controlling:canSend}">
-        <img v-if="frame" :src="`data:image/png;base64,${frame.data}`" alt="隔离电脑当前画面" draggable="false" tabindex="0" title="点按后可使用键盘、滚轮和拖动;按 Esc 退出键盘控制" @pointerdown="down" @pointerup="up" @pointercancel="dragStart=undefined" @wheel="wheel" @keydown="keydown" @click="click" @contextmenu.prevent="click">
+      <BrowserToolbar v-if="state.backend==='browser'" :state="browserState" :enabled="controllable" @action="browserAction"/>
+      <div class="computer-screen" :class="{controlling:canSend,'actual-size':actualSize}">
+        <img v-if="frame" :src="`data:image/png;base64,${frame.data}`" :alt="state.backend==='local'?'本机当前画面':state.backend==='browser'?'浏览器当前画面':'隔离电脑当前画面'" draggable="false" tabindex="0" title="点按后可使用键盘、滚轮和拖动;按 Esc 退出键盘控制" @pointerdown="down" @pointerup="up" @pointercancel="dragStart=undefined" @wheel="wheel" @keydown="keydown" @click="click" @contextmenu.prevent="click">
         <p v-else>{{ state.mode==='off' ? '打开电脑后可查看桌面。' : '正在读取电脑画面…' }}</p>
         <span v-if="frame&&(!mine||frame.generation!==state.generation)" class="view-label">{{mine?'正在同步画面':state.mode==='off'?'上次画面':'仅查看'}}</span>
       </div>
-      <p v-if="error" class="computer-error" role="alert">{{ error }}</p>
-      <footer v-if="!embedded||controlsOpen">
+      <p v-if="error||state.error" class="computer-error" role="alert">{{ error||state.error }}</p>
+      <footer v-if="controlsOpen||(!embedded&&!ticket)">
+        <p v-if="state.backend==='grok'">多个机器人共享同一台 Grok Bot 云端电脑、工作文件与浏览器资料。</p>
         <p v-if="selectedAgent?.computerEnvironmentId">共享电脑:{{ selectedAgent.computerEnvironmentName }}。成员共用工作文件和浏览器资料,同一时间只有一名操作者。</p>
-        <p v-if="!ticket">查看不会输入任何内容。接管后 Agent 会暂停,已有操作结束后才允许人工操作。</p>
+        <p v-if="!ticket">查看不会输入任何内容。接管后机器人会暂停,已有操作结束后才允许人工操作。</p>
         <button v-if="!ticket&&state.mode!=='human'" type="button" :disabled="busy" @click="embedded?emit('controlRequest'):take()">{{ state.mode==='off'?'打开并控制':'接管电脑' }}</button>
         <template v-if="mine">
-          <button type="button" @click="controlsOpen=!controlsOpen">{{controlsOpen?'收起键盘':'键盘与操作'}}</button>
+
           <section v-if="controlsOpen" class="manual-input">
           <div class="key-row"><button v-for="key in ['Return','Tab','Escape','BackSpace','Up','Down','Left','Right']" :key="key" type="button" :disabled="!controllable" @click="send({kind:'key',key})">{{ ({Return:'回车',Escape:'Esc',BackSpace:'退格',Up:'↑',Down:'↓',Left:'←',Right:'→'} as Record<string,string>)[key]||key }}</button></div>
-          <div class="key-row"><button :disabled="!controllable" @click="send({kind:'key',key:'a',modifiers:['ctrl']})">全选</button><button :disabled="!controllable" @click="send({kind:'key',key:'c',modifiers:['ctrl']})">复制</button><button :disabled="!controllable" @click="send({kind:'key',key:'v',modifiers:['ctrl']})">粘贴</button></div>
+          <div class="key-row"><button :disabled="!controllable" @click="send({kind:'key',key:'a',modifiers:[state.backend==='local'||state.backend==='browser'?'super':'ctrl']})">全选</button><button :disabled="!controllable" @click="send({kind:'key',key:'c',modifiers:[state.backend==='local'||state.backend==='browser'?'super':'ctrl']})">复制</button><button :disabled="!controllable" @click="send({kind:'key',key:'v',modifiers:[state.backend==='local'||state.backend==='browser'?'super':'ctrl']})">粘贴</button></div>
           <label>输入到电脑<textarea v-model="text" rows="2" maxlength="16000" placeholder="输入文字后点击发送" :disabled="!controllable" /></label>
           <button type="button" :disabled="!controllable||!text" @click="send({kind:'text',text});text=''">输入文字</button>
           </section>
-          <label>交还说明<textarea v-model="notes" rows="2" maxlength="4000" placeholder="告诉 Agent 你完成了什么,以及接下来需要做什么" /></label>
-          <button type="button" :disabled="busy||state.mode!=='human'" @click="run(giveBack)">{{ state.canResume ? '交还 Agent 并继续' : '结束控制' }}</button>
+          <label>交还说明<textarea v-model="notes" rows="2" maxlength="4000" placeholder="告诉机器人你完成了什么,以及接下来需要做什么" /></label>
+          <button type="button" :disabled="busy||state.mode!=='human'" @click="run(giveBack)">{{ state.canResume ? '交还机器人并继续' : '结束控制' }}</button>
           <small>控制只属于当前页面。页面断开后控制权会到期,任务不会自行恢复。</small>
         </template>
       </footer>
@@ -122,6 +141,10 @@ defineExpose({take,releaseControl:async()=>{await run(giveBack);if(ticket.value)
 <style scoped>
 .computer-panel.embedded{position:static;width:100%;max-height:none;height:100%;margin:0;border:0;border-radius:0;overflow:auto}.computer-panel.embedded{display:flex;flex-direction:column}.embedded .computer-screen{flex:1;min-height:150px}.embedded .computer-screen img{max-height:calc(100dvh - 250px);object-fit:contain}.embedded footer{max-height:45vh;overflow:auto}.manual-input{display:grid;gap:10px}
 .computer-panel{width:min(1120px,calc(100vw - 32px));max-height:calc(100dvh - 32px);padding:0;border:1px solid var(--line);border-radius:16px;background:var(--surface);color:var(--text-primary);overflow:auto}
+.computer-panel.standalone{display:flex;flex-direction:column;width:100vw;height:100dvh;max-height:none;margin:0;border:0;border-radius:0;overflow:hidden}
+.standalone .computer-screen{flex:1;min-height:0;overflow:hidden}.standalone .computer-screen img{height:100%;width:100%;max-height:100%;max-width:100%;object-fit:contain}.standalone header{flex-shrink:0;background:#1c1f23;color:#f4f4f5}.standalone header small{color:#bec4cc}.standalone header button,.standalone header select{background:#2b2f34;color:#f4f4f5;border-color:#474c54}.standalone header .return-control{background:#f4f4f5;color:#202327;border-color:#f4f4f5}.standalone footer{position:absolute;right:16px;top:78px;width:min(360px,calc(100vw - 64px));max-height:calc(100dvh - 130px);overflow:auto;background:var(--surface);border:1px solid var(--line);border-radius:12px;box-shadow:0 16px 50px #0006;z-index:2}
+.computer-panel:fullscreen{display:flex;flex-direction:column;width:100vw;height:100dvh;max-height:none;border:0;border-radius:0}.computer-panel:fullscreen .computer-screen{flex:1;min-height:0}.computer-panel:fullscreen .computer-screen img{max-height:100%}
+.computer-screen.actual-size{overflow:auto;align-items:flex-start;justify-content:flex-start}.computer-screen.actual-size img{width:auto;height:auto;max-width:none;max-height:none;flex:none}.return-control{font-weight:600}.standalone .computer-error{flex:none;margin:0;padding:10px 18px}
 .computer-panel::backdrop{background:rgba(0,0,0,.45)}header{display:flex;align-items:center;gap:14px;padding:14px 18px;border-bottom:1px solid var(--line)}header div{display:grid;gap:4px;margin-right:auto}small{font-size:12px;color:var(--text-muted);line-height:1.5}
 button,select,textarea,input{font:inherit;border:1px solid var(--line);border-radius:8px;background:var(--surface-raised);color:var(--text-primary)}button,select{min-height:44px;padding:8px 12px}button{cursor:pointer}button:disabled{opacity:.5;cursor:default}button:focus-visible,select:focus-visible,textarea:focus-visible,input:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
 .computer-screen{position:relative;display:flex;align-items:center;justify-content:center;min-height:220px;background:#14181e}.computer-screen img{max-width:100%;max-height:58vh;width:auto;height:auto;user-select:none}.controlling img{cursor:crosshair}.computer-screen img:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}.computer-screen p{color:#d8dee7}.view-label{position:absolute;top:10px;left:12px;padding:4px 8px;border-radius:6px;background:rgba(0,0,0,.65);color:white;font-size:12px;pointer-events:none}

+ 1 - 1
src/client/components/workspace/ConversationList.vue

@@ -26,7 +26,7 @@ function action(kind: 'pin' | 'archive' | 'delete') {
 <template>
   <div class="conversation-list">
     <ResourceSidebar :items="rows" :active-id="selected" :searchable="false" :avatar-size="44" external-search
-      empty-title="还没有聊天" empty-description="创建 Agent,或选择成员新建群聊。"
+      empty-title="还没有聊天" empty-description="创建机器人,或选择成员新建群聊。"
       @select="emit('select', $event)" @more="openMenu" @context-menu="openMenu" />
     <Teleport to="body">
       <div v-if="menuConversation" class="conversation-menu-dismiss" @pointerdown.self="menuId = ''" @keydown.esc="menuId = ''">

Разница между файлами не показана из-за своего большого размера
+ 59 - 0
src/client/components/workspace/GrokAuthPanel.vue


+ 74 - 22
src/client/components/workspace/LocalVmChatPanel.vue

@@ -2,18 +2,27 @@
 import {ref,computed,watch,onBeforeUnmount} from 'vue'
 import {apiRequest} from '@/api/client'
 import AppIcon from '@/components/common/AppIcon.vue'
+import type {DesktopEnvironmentState,BotBrowserState} from '@shared/desktopEnvironment'
+import GrokAuthPanel from './GrokAuthPanel.vue'
 import type {WorkspaceAgent} from '@shared/workspace'
 import type {ComputerFrame} from '@shared/computerControl'
 import type {LocalVmInstance,LocalVmAction} from '@shared/localVm'
-const props=defineProps<{agents:WorkspaceAgent[];isAdmin:boolean;active?:boolean}>()
+const props=defineProps<{agents:WorkspaceAgent[];isAdmin:boolean;active?:boolean;embedded?:boolean}>()
 const emit=defineEmits<{close:[];changed:[];settings:[];desktop:[agent:WorkspaceAgent];workspace:[agent:WorkspaceAgent]}>()
 const selected=ref(''),state=ref<LocalVmInstance&{enabled:boolean;controlMode?:string}>(),frame=ref<ComputerFrame>(),error=ref(''),busy=ref(false),loading=ref(true)
 const agent=computed(()=>props.agents.find(a=>a.id===selected.value))
-const computerTabs=ref<HTMLElement>()
-const computerChoice=computed(()=>state.value?.fixedCapacity?(state.value.desktopId??'off'):state.value?.enabled?'vm':'off')
+const native=ref<DesktopEnvironmentState>()
+const nativeSelected=computed(()=>native.value?.selected)
+const computerTabs=ref<HTMLElement>(),cloud=ref<{configured:boolean;running:boolean;connected:boolean;mode?:string}>(),connectionSettings=ref(false)
+const cloudSelected=computed(()=>agent.value?.computer==='cloud'||(agent.value?.computer==='auto'&&!nativeSelected.value&&agent.value.execution!=='computer'&&cloud.value?.configured))
+const computerChoice=computed(()=>state.value?.fixedCapacity?(state.value.desktopId??'off'):agent.value?.computer??(state.value?.enabled?'vm':'off'))
 const computerChoices=computed(()=>[
- {value:'off',label:'不使用电脑',disabled:false},
- ...(state.value?.fixedCapacity?(state.value.desktops??[]).map(desktop=>({value:desktop.id,label:desktop.name+(desktop.ready?'':' · 未就绪'),disabled:desktop.available===false})):[{value:'vm',label:'本地虚拟机',disabled:false}]),
+ {value:'auto',label:'自动',description:'按可用环境自动选择',icon:'bolt' as const,disabled:false},
+ {value:'cloud',label:'云端 · Grok Bot',description:'共享云端电脑,持续保存工作',icon:'globe' as const,disabled:false},
+ ...(state.value?.fixedCapacity?(state.value.desktops??[]).map(desktop=>({value:desktop.id,label:desktop.name,description:desktop.ready?'已有共享桌面':'桌面尚未就绪',icon:'monitor' as const,disabled:desktop.available===false})):[{value:'vm',label:'本地虚拟机',description:'在隔离的本地桌面中工作',icon:'monitor' as const,disabled:false}]),
+ {value:'local',label:'本机',description:native.value?.host?.name??'请在电脑上打开夭夭桌面端',icon:'monitor' as const,disabled:!native.value?.local.supported},
+ {value:'browser',label:'仅浏览器',description:native.value?.browser.available?'独立浏览器,保存登录资料':'请在电脑上打开夭夭桌面端',icon:'globe' as const,disabled:!native.value?.browser.available},
+ {value:'off',label:'不使用电脑',description:'使用基础机器人的其他工具',icon:'stop' as const,disabled:false},
 ])
 const computerChoiceDisabled=computed(()=>loading.value||!state.value||busy.value||state.value.inUse||!!agent.value?.remoteAgentId||!!agent.value?.temporaryGoalId)
 function selectComputer(value:string){
@@ -34,62 +43,99 @@ async function refresh(){
  if(closed||props.active===false||!selected.value||document.hidden||busy.value)return
  const version=revision
  try{
+  native.value=await apiRequest<DesktopEnvironmentState>(`/api/app/agents/${selected.value}/desktop-environment`);if(version!==revision||closed)return
+  if(nativeSelected.value){
+   const n=native.value;let ready=n.local.ready
+   if(nativeSelected.value==='browser'){const b=await apiRequest<BotBrowserState>(`/api/app/agents/${selected.value}/browser`);ready=b.open}
+   state.value={enabled:true,container:ready?'running':'stopped',ready,image:true,mode:'shared',maxInstances:1,inUse:false}
+   if(ready){const f=await apiRequest<ComputerFrame>(`/api/app/agents/${selected.value}/computer/frame`);if(version===revision&&!closed)frame.value=f}else frame.value=undefined
+   error.value='';return
+  }
+  const cloudState=await apiRequest<typeof cloud.value>(`/api/app/agents/${selected.value}/cloud-computer`);if(version!==revision||closed)return;cloud.value=cloudState
+  if(cloudSelected.value){
+   state.value={enabled:true,container:cloudState?.running?'running':'stopped',ready:!!cloudState?.connected&&!!cloudState?.running,image:!!cloudState?.configured,mode:'shared',maxInstances:1,inUse:cloudState?.mode==='agent'||cloudState?.mode==='human',controlMode:cloudState?.mode}
+   if(state.value.ready){const image=await apiRequest<ComputerFrame>(`/api/app/agents/${selected.value}/computer/frame`);if(version===revision&&!closed)frame.value=image}else frame.value=undefined
+   error.value='';return
+  }
   const result=await apiRequest<typeof state.value>(base());if(version!==revision||closed)return;state.value=result
   if(result?.container==='running'&&result.ready){const image=await apiRequest<ComputerFrame>(`/api/app/agents/${selected.value}/computer/frame`);if(version===revision&&!closed)frame.value=image}
   else frame.value=undefined
+  error.value=''
  }catch(e){if(version===revision)error.value=e instanceof Error?e.message:'无法读取电脑画面'}finally{if(version===revision)loading.value=false}
 }
 async function run(work:()=>Promise<unknown>){if(busy.value)return;busy.value=true;error.value='';try{await work();emit('changed')}catch(e){error.value=e instanceof Error?e.message:'电脑操作未完成'}finally{busy.value=false;await refresh()}}
 function choose(value:string){
- if(state.value?.fixedCapacity&&value!=='off'&&value!==state.value.desktopId&&!confirm('连接这台共享桌面?同一桌面的成员会共用文件和浏览器登录。'))return
- void run(()=>apiRequest(base(),{method:'PUT',body:state.value?.fixedCapacity?{enabled:value!=='off',...(value!=='off'?{desktopId:value}:{})}:{enabled:value==='vm'}}))
+ if(state.value?.fixedCapacity&&!['off','auto','cloud','local','browser'].includes(value)){
+   void run(()=>apiRequest(base(),{method:'PUT',body:{enabled:true,desktopId:value}}));return
+ }
+ void run(()=>apiRequest(`/api/app/agents/${selected.value}/computer-selection`,{method:'PUT',body:{computer:value}}))
 }
+async function openDesktop(){if(!agent.value)return;if(cloudSelected.value){await run(()=>apiRequest(`/api/app/agents/${selected.value}/cloud-computer/open`,{method:'POST',body:{}}));if(error.value)return}emit('desktop',agent.value)}
 function action(value:LocalVmAction){
  if(value==='recreate'&&!confirm('重建这台虚拟机?当前桌面程序将关闭,工作文件和浏览器资料会保留。'))return
  void run(()=>apiRequest(base()+'/'+value,{method:'POST',body:{}}))
 }
-async function cycle(){await refresh();if(!closed)timer=setTimeout(cycle,3000)}
+async function cycle(){const version=revision;await refresh();if(!closed&&version===revision)timer=setTimeout(cycle,3000)}
 watch(()=>props.agents.map(a=>a.id).join(','),()=>{if(!props.agents.some(a=>a.id===selected.value))selected.value=props.agents[0]?.id??''},{immediate:true})
-watch(selected,()=>{revision++;state.value=undefined;frame.value=undefined;error.value='';loading.value=true;clearTimeout(timer);void cycle()},{immediate:true})
+watch(selected,()=>{revision++;state.value=undefined;native.value=undefined;cloud.value=undefined;frame.value=undefined;error.value='';loading.value=true;clearTimeout(timer);void cycle()},{immediate:true})
 watch(()=>props.active,value=>{if(value)void refresh()})
 onBeforeUnmount(()=>{closed=true;revision++;clearTimeout(timer)})
 </script>
 <template>
- <aside class="local-vm-chat-panel" aria-label="Agent 电脑面板">
+ <aside class="local-vm-chat-panel" :class="{embedded}" aria-label="机器人电脑面板">
   <header><strong>电脑</strong><button aria-label="关闭电脑面板" @click="emit('close')"><AppIcon name="close"/></button></header>
   <div class="panel-body">
-   <label v-if="agents.length>1" class="agent-select">Agent<select v-model="selected" :disabled="busy"><option v-for="item in agents" :key="item.id" :value="item.id">{{item.name}}</option></select></label>
-   <p v-if="!agent">当前聊天没有可用的 Agent。</p>
+   <label v-if="agents.length>1" class="agent-select">机器人<select v-model="selected" :disabled="busy"><option v-for="item in agents" :key="item.id" :value="item.id">{{item.name}}</option></select></label>
+   <p v-if="!agent">当前聊天没有可用的机器人。</p>
    <template v-else>
-    <div class="screen-caption"><span>{{agent.name}}的电脑</span><small v-if="state?.enabled">本地虚拟机</small></div>
-    <button class="preview" :disabled="!frame||busy" :aria-label="`打开${agent.name}的桌面`" @click="emit('desktop',agent)">
+    <div class="screen-caption"><span>{{agent.name}}的电脑</span><small v-if="state?.enabled">{{nativeSelected?(native?.host?.name??'桌面端离线'):cloudSelected?'Grok Bot 云端':'本地虚拟机'}}</small></div>
+    <button class="preview" :disabled="!frame||busy" :aria-label="`打开${agent.name}的桌面`" @click="openDesktop">
      <img v-if="frame" :src="`data:image/png;base64,${frame.data}`" :alt="`${agent.name}的电脑画面`">
-     <span v-else class="empty"><AppIcon name="monitor" :size="26"/><span>{{loading?'正在检查电脑…':!state?.enabled?'未使用电脑':!state.image?'本地虚拟机尚未准备':state.container==='missing'?'尚未创建虚拟机':state.container==='stopped'?'虚拟机已停止':'正在连接桌面…'}}</span></span>
+     <span v-else class="empty"><AppIcon name="monitor" :size="26"/><span>{{loading?'正在检查电脑…':nativeSelected?(nativeSelected==='browser'?'点击打开机器人的独立浏览器':native?.local.ready?'正在读取本机画面…':'请完成本机控制授权'):!state?.enabled?(computerChoice==='auto'?'暂无可用电脑':'未使用电脑'):!state.image?(cloudSelected?'尚未连接 Grok Bot 账号':'本地虚拟机尚未准备'):state.container==='missing'?'尚未创建虚拟机':state.container==='stopped'?'虚拟机已停止':cloudSelected?'打开云端电脑后可查看桌面':'正在连接桌面…'}}</span></span>
      <span v-if="frame" class="open-badge"><AppIcon name="external" :size="12"/>打开桌面</span>
     </button>
     <p v-if="error||state?.problem" class="problem" role="alert">{{error||state?.problem}}</p>
     <div class="computer-select">
-     <span>此 Agent 使用的电脑</span>
-     <div ref="computerTabs" class="computer-tabs" role="tablist" aria-label="此 Agent 使用的电脑" @keydown="moveComputerTab">
-      <button v-for="option in computerChoices" :id="`computer-tab-${selected}-${option.value}`" :key="option.value" type="button" role="tab" :aria-selected="computerChoice===option.value" :aria-controls="`computer-options-${selected}`" :tabindex="computerChoice===option.value?0:-1" :disabled="computerChoiceDisabled||option.disabled" @click="selectComputer(option.value)">{{option.label}}</button>
+     <span>此机器人使用的电脑</span>
+     <div ref="computerTabs" class="computer-tabs" role="tablist" aria-label="此机器人使用的电脑" @keydown="moveComputerTab">
+      <button v-for="option in computerChoices" :id="`computer-tab-${selected}-${option.value}`" :key="option.value" type="button" role="tab" :aria-selected="computerChoice===option.value" :aria-controls="`computer-options-${selected}`" :tabindex="computerChoice===option.value?0:-1" :aria-label="option.label" :title="option.description" :disabled="computerChoiceDisabled||option.disabled" @click="selectComputer(option.value)"><span><AppIcon :name="computerChoice===option.value?'check':option.icon" :size="15"/>{{option.label}}</span><small>{{option.description}}</small></button>
      </div>
     </div>
     <div :id="`computer-options-${selected}`" class="computer-options" role="tabpanel" :aria-labelledby="`computer-tab-${selected}-${computerChoice}`">
-    <template v-if="state?.enabled">
-     <p>{{agent.temporaryGoalId?'临时助手的电脑由当前任务管理':state.mode==='shared'?'共享虚拟机 · 与其他成员共用桌面和工作文件':'此 Agent 的独立虚拟机'}}</p>
+    <p v-if="computerChoice==='auto'" class="hint">按已有可用环境自动选择。查看此面板不会创建或唤醒云端电脑。</p>
+    <template v-if="nativeSelected">
+     <p>{{nativeSelected==='local'?'机器人将查看并操作已连接电脑的真实桌面。':'浏览器在已连接的桌面端运行,机器人和你使用同一组标签页。'}}连接电脑:{{native?.host?.name??'未连接'}}。</p>
+     <template v-if="nativeSelected==='local'">
+      <div class="permission-list"><span>{{native?.local.authorized?'✓':'○'}} 本机控制授权</span><span>{{native?.local.screen?'✓':'○'}} 屏幕录制</span><span>{{native?.local.accessibility?'✓':'○'}} 辅助功能</span></div>
+      <button v-if="!native?.local.ready" class="primary" :disabled="busy||!native?.online||!isAdmin" @click="run(()=>apiRequest(`/api/app/agents/${selected}/desktop-environment/authorize`,{method:'POST',body:{},timeoutMs:125000}))">在桌面端授权</button>
+      <p v-if="!native?.local.ready" class="hint">在连接的 Mac 上确认授权,并按系统提示开启权限;系统可能要求重新打开 App。</p>
+     </template>
+     <label v-else>浏览器资料<select :value="native?.browser.profile" :disabled="busy" @change="run(()=>apiRequest(`/api/app/agents/${selected}/browser-profile`,{method:'PUT',body:{profile:($event.target as HTMLSelectElement).value}}))"><option value="persistent">此机器人的浏览器 · 保存登录</option><option value="temporary">临时浏览器 · 退出桌面端后清除</option></select></label>
+     <button class="primary" :disabled="busy||!native?.online||(nativeSelected==='local'&&!native?.local.ready)" @click="openDesktop">{{nativeSelected==='browser'?'打开浏览器':'接管本机'}}</button>
+    </template>
+    <template v-else-if="cloudSelected">
+     <p>多个机器人共用同一台 Grok Bot 云端虚拟机、工作文件和浏览器登录。基础机器人和聊天记录保持独立。</p>
+     <button v-if="cloud?.configured" class="primary" :disabled="busy" @click="openDesktop">{{state?.controlMode==='human'?'打开控制中的桌面':'接管云端电脑'}}</button>
+     <button @click="connectionSettings=!connectionSettings">{{cloud?.configured?'云端连接设置':'连接 Grok Bot'}}</button>
+     <p v-if="!isAdmin&&!cloud?.configured" class="hint">请由管理员为当前账号配置 Grok Bot 连接。</p>
+    </template>
+    <template v-else-if="state?.enabled">
+     <p>{{agent.temporaryGoalId?'临时助手的电脑由当前任务管理':state.mode==='shared'?'共享虚拟机 · 与其他成员共用桌面和工作文件':'此机器人的独立虚拟机'}}</p>
      <button v-if="!state.image" class="primary" :disabled="!isAdmin" @click="emit('settings')">设置本地虚拟机</button>
      <button v-else-if="!state.fixedCapacity&&state.container==='missing'&&!agent.temporaryGoalId" class="primary" :disabled="busy" @click="action('create')">创建 {{agent.name}} 的虚拟机</button>
      <button v-else-if="!state.fixedCapacity&&state.container==='stopped'&&!agent.temporaryGoalId" class="primary" :disabled="busy" @click="action('start')">启动虚拟机</button>
      <template v-else-if="state.container==='running'">
-      <button class="primary" :disabled="!state.ready||busy" @click="emit('desktop',agent)">打开桌面</button>
+      <button class="primary" :disabled="!state.ready||busy" @click="openDesktop">打开桌面</button>
       <button v-if="state.mode==='per-bot'" :disabled="busy" @click="emit('workspace',agent)"><AppIcon name="panel"/>打开双桌面</button>
-      <p class="control-state">{{state.controlMode==='human'?'你或其他操作者正在控制电脑':state.inUse?'Agent 正在操作':'仅查看 · 虚拟机空闲'}}</p>
+      <p class="control-state">{{state.controlMode==='human'?'你或其他操作者正在控制电脑':state.inUse?'机器人正在操作':'仅查看 · 虚拟机空闲'}}</p>
      </template>
      <div v-if="!state.fixedCapacity&&state.container!=='missing'&&!agent.temporaryGoalId" class="vm-actions"><button :disabled="busy||state.inUse" @click="action('stop')">停止虚拟机</button><button :disabled="busy||state.inUse" @click="action('recreate')">重建虚拟机</button></div>
      <p class="hint">{{state.fixedCapacity?'桌面由 Compose 创建,数量固定。这里只连接已有共享桌面;工作目录为 /home/cua/workspace。':'重建会保留工作目录和浏览器资料。虚拟机空闲 5 分钟后自动停止。'}}</p>
      <button v-if="isAdmin" class="settings-link" @click="emit('settings')"><AppIcon name="settings" :size="14"/>本地虚拟机设置</button>
     </template>
     </div>
+    <button v-if="!cloudSelected" class="settings-link" @click="connectionSettings=!connectionSettings"><AppIcon name="globe" :size="14"/>Grok Bot 云端连接</button>
+    <GrokAuthPanel v-if="connectionSettings" :is-admin="isAdmin" @changed="emit('changed');refresh()"/>
    </template>
   </div>
  </aside>
@@ -105,3 +151,9 @@ onBeforeUnmount(()=>{closed=true;revision++;clearTimeout(timer)})
 .computer-options{display:flex;flex-direction:column;gap:14px}
 .computer-options:empty{display:none}
 </style>
+
+<style scoped>.cloud-settings{display:grid;gap:10px;padding:14px;border:1px solid var(--line);border-radius:10px}.cloud-settings input{min-height:44px;font:inherit;color:var(--text-primary);background:var(--surface-raised);border:1px solid var(--line);border-radius:8px;padding:8px;min-width:0}.computer-tabs{display:grid;grid-template-columns:1fr 1fr;overflow:visible}.computer-tabs button{text-align:left;justify-content:flex-start;white-space:normal;min-height:48px}</style>
+
+<style scoped>.computer-tabs{gap:8px;border:0;padding:0;background:transparent}.computer-tabs button{display:flex;flex-direction:column;align-items:flex-start;gap:7px;padding:12px;border:1px solid var(--line);background:var(--surface-soft);min-height:82px}.computer-tabs button span{display:flex;align-items:center;gap:6px;font-weight:500}.computer-tabs button small{font-size:11px;line-height:1.5;color:var(--text-muted)}.computer-tabs button[aria-selected=true]{border-color:var(--accent);background:var(--surface-raised);box-shadow:none}.computer-tabs button:disabled{opacity:.55}</style>
+
+<style scoped>.permission-list{display:grid;gap:8px;font-size:13px;color:var(--text-secondary)}</style>

+ 3 - 3
src/client/components/workspace/LocalVmWorkspace.vue

@@ -18,12 +18,12 @@ defineExpose({close})
 </script>
 <template>
  <main class="local-vm-workspace" aria-label="双桌面工作区">
-  <header><div><strong>本地虚拟机 · 双桌面</strong><p>同时查看两个 Agent 的桌面,每次只控制其中一台。</p></div><button :disabled="busy" @click="close">交还并关闭</button></header>
+  <header><div><strong>本地虚拟机 · 双桌面</strong><p>同时查看两个机器人的桌面,每次只控制其中一台。</p></div><button :disabled="busy" @click="close">交还并关闭</button></header>
   <p v-if="error" role="alert">{{error}}</p>
   <div class="panes"><section v-for="(_,index) in slots" :key="index" class="pane" :class="{controlled:controlled===index}">
-   <label>桌面 {{index+1}}<select :value="slots[index]" :disabled="busy" :aria-label="`选择桌面 ${index+1}`" @change="select(index,($event.target as HTMLSelectElement).value)"><option value="">选择 Agent</option><option v-for="agent in choices" :key="agent.id" :value="agent.id" :disabled="slots[1-index]===agent.id">{{agent.name}}</option></select></label>
+   <label>桌面 {{index+1}}<select :value="slots[index]" :disabled="busy" :aria-label="`选择桌面 ${index+1}`" @change="select(index,($event.target as HTMLSelectElement).value)"><option value="">选择机器人</option><option v-for="agent in choices" :key="agent.id" :value="agent.id" :disabled="slots[1-index]===agent.id">{{agent.name}}</option></select></label>
    <ComputerPanel v-if="slots[index]&&choices.some(a=>a.id===slots[index])" :key="slots[index]" :ref="el=>panels[index]=el as InstanceType<typeof ComputerPanel>|null" embedded :agents="choices.filter(a=>a.id===slots[index])" @control-request="take(index)"/>
-   <p v-else class="empty">选择另一位 Agent。打开工作区不会创建或启动虚拟机。</p>
+   <p v-else class="empty">选择另一位机器人。打开工作区不会创建或启动虚拟机。</p>
   </section></div>
  </main>
 </template>

+ 3 - 3
src/client/components/workspace/RemoteAgentPicker.vue

@@ -25,12 +25,12 @@ async function add(agent:WorkspaceAgent){
 </script>
 <template>
   <dialog ref="dialog" class="remote-agent-picker" @cancel.prevent="!adding && emit('close')">
-    <header><h2>添加远程 Agent</h2><button type="button" :disabled="adding" @click="emit('close')">关闭</button></header>
-    <p>直接引用远端 Bot 模式的 Agent,配置由远端管理,可用于聊天和群聊。</p>
+    <header><h2>添加远程机器人</h2><button type="button" :disabled="adding" @click="emit('close')">关闭</button></header>
+    <p>直接引用远端 Bot 模式的机器人,配置由远端管理,可用于聊天和群聊。</p>
     <label>远程子节点<select v-model="nodeId" :disabled="busy"><option v-for="node in nodes" :key="node.id" :value="node.id">{{node.name}}</option></select></label>
     <p v-if="error" role="alert">{{error}}</p>
     <p v-if="!nodes.length">请先在远程节点中扫码添加子节点。</p>
-    <p v-else-if="!busy && !agents.length && !error">这个节点暂无可添加的 Agent。</p>
+    <p v-else-if="!busy && !agents.length && !error">这个节点暂无可添加的机器人。</p>
     <button v-for="agent in agents" :key="agent.id" class="agent-option" :disabled="busy" @click="add(agent)">{{agent.name}}<span>添加</span></button>
     <p v-if="busy">加载中…</p>
   </dialog>

+ 3 - 3
src/client/components/workspace/TeamPresetPicker.vue

@@ -6,14 +6,14 @@ const shortage = (preset: TeamPreset) => Math.max(0, preset.roles.length - props
 </script>
 <template>
   <section class="preset-picker" aria-label="团队预设">
-    <div class="preset-picker__heading"><span>团队预设</span><small>选择后分配已创建的 Agent</small></div>
+    <div class="preset-picker__heading"><span>团队预设</span><small>选择后分配已创建的机器人</small></div>
     <div class="preset-grid">
-      <button type="button" :class="{ selected: selected === 'custom' }" @click="emit('select')"><strong>自定义团队</strong><small>手动选择 Agent 和协作配置</small><em>自由配置</em></button>
+      <button type="button" :class="{ selected: selected === 'custom' }" @click="emit('select')"><strong>自定义团队</strong><small>手动选择机器人和协作配置</small><em>自由配置</em></button>
       <button v-for="preset in TEAM_PRESETS" :key="preset.id" type="button" :class="{ selected: selected === preset.id }" :disabled="shortage(preset) > 0" :aria-label="preset.name" @click="emit('select', preset)">
         <strong>{{ preset.name }}</strong><small>{{ preset.summary }}</small><em>{{ shortage(preset) ? `还缺 ${shortage(preset)} 人` : `${preset.roles.length} 人` }}</em>
       </button>
     </div>
-    <small v-if="available < 5" class="preset-help">成员不足时,请先创建所需的 Agent。</small>
+    <small v-if="available < 5" class="preset-help">成员不足时,请先创建所需的机器人。</small>
   </section>
 </template>
 <style scoped>

+ 24 - 0
src/client/components/workspace/WorkspaceBotPanel.vue

@@ -0,0 +1,24 @@
+<script setup lang="ts">
+import {ref,watch} from 'vue'
+import AppIcon from '@/components/common/AppIcon.vue'
+import LocalVmChatPanel from './LocalVmChatPanel.vue'
+import WorkspaceInspectorPanel from './WorkspaceInspectorPanel.vue'
+import WorkspaceRoutinesPanel from './WorkspaceRoutinesPanel.vue'
+import type {WorkspaceAgent} from '@shared/workspace'
+const props=defineProps<{agents:WorkspaceAgent[];conversationId:string;taskId?:string;group:boolean;isAdmin:boolean;active?:boolean;initialView?:'computer'|'routines'|'inspector'}>()
+const emit=defineEmits<{close:[];changed:[];settings:[];desktop:[agent:WorkspaceAgent];workspace:[agent:WorkspaceAgent]}>()
+const view=ref<'computer'|'routines'|'inspector'>('computer')
+watch(()=>[props.conversationId,props.initialView],()=>{let saved;try{saved=localStorage.getItem('yaoyao-bot-panel:'+props.conversationId)}catch{}view.value=props.group?'inspector':props.initialView??(['computer','routines','inspector'].includes(saved??'')?saved as typeof view.value:'computer')},{immediate:true})
+watch(view,value=>{try{localStorage.setItem('yaoyao-bot-panel:'+props.conversationId,value)}catch{}})
+</script>
+<template>
+ <aside class="bot-panel" aria-label="机器人右侧栏">
+  <header><div class="tabs" role="group" aria-label="机器人侧栏项目"><button v-if="!group" :aria-pressed="view==='computer'" @click="view='computer'"><AppIcon name="monitor" :size="15"/>电脑</button><button v-if="!group" :aria-pressed="view==='routines'" @click="view='routines'"><AppIcon name="calendar" :size="15"/>定时任务</button><button :aria-pressed="view==='inspector'" @click="view='inspector'"><AppIcon name="bug" :size="15"/>Inspector</button></div><button aria-label="关闭机器人侧栏" @click="emit('close')"><AppIcon name="close"/></button></header>
+  <LocalVmChatPanel v-if="view==='computer'&&!group" embedded :agents="agents" :is-admin="isAdmin" :active="active" @changed="emit('changed')" @settings="emit('settings')" @desktop="emit('desktop',$event)" @workspace="emit('workspace',$event)"/>
+  <WorkspaceRoutinesPanel v-else-if="view==='routines'&&agents[0]&&!group" :agent-id="agents[0].id"/>
+  <WorkspaceInspectorPanel v-else :conversation-id="conversationId" :task-id="taskId"/>
+ </aside>
+</template>
+<style scoped>
+.bot-panel{width:420px;min-width:320px;max-width:46%;height:100%;border-left:1px solid var(--line);background:var(--surface);display:flex;flex-direction:column;color:var(--text-primary)}header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 12px;border-bottom:1px solid var(--line)}.tabs{display:flex;flex-wrap:wrap;gap:2px}.tabs button{font-size:12px;padding:8px}.tabs button[aria-pressed=true]{background:var(--surface-soft);color:var(--text-primary);font-weight:600}button{font:inherit;display:inline-flex;align-items:center;justify-content:center;gap:5px;border:0;background:transparent;color:var(--text-secondary);border-radius:8px;min-width:44px;min-height:44px;cursor:pointer}button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(max-width:900px){.bot-panel{position:fixed;inset:0 0 0 auto;width:min(440px,100vw);max-width:100%;z-index:35;box-shadow:-20px 0 60px #0002}}:deep(.local-vm-chat-panel.embedded){width:100%;max-width:none;min-width:0;border:0;position:static;box-shadow:none;flex:1;min-height:0}:deep(.local-vm-chat-panel.embedded>header){display:none}
+</style>

Некоторые файлы не были показаны из-за большого количества измененных файлов