فهرست منبع

M4/M5(二):技能加载、打包与文档

- 内置网关加载 Profile 技能(Bot 只读共享),Bot 自有技能与原生对话新建的技能写回对应 Hermes home
- Docker 镜像在构建阶段准备 Python 3.11 内核依赖;compose 去掉 9119,新增只读导入挂载 compose.hermes-import.yaml
- 内核虚拟环境可放在 YAOYAO_KERNEL_VENV;缺少内核时首次启动自动准备并在完成后导入旧数据
- macOS 完整版打包 web-service/runtime,内核环境放在用户数据目录;LaunchAgent 不再写入 9119 变量
- Bot 提示词改为直接调用本轮工具目录,不再提及 yaoyao_tools/yaoyao_call
- README、Docker/npm/部署文档与迁移方案实施记录更新

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HvtCVd6vwAvwixrtCT1h76
Claude 2 روز پیش
والد
کامیت
9c8fca8b6c

+ 2 - 5
.dockerignore

@@ -26,11 +26,8 @@
 !bin/**
 !src/
 !src/**
-!integrations/
-!integrations/hermes-bots-bridge/
-!integrations/hermes-bots-bridge/**
-
-integrations/hermes-bots-bridge/tests/**
+!runtime/
+!runtime/**
 **/__pycache__/**
 **/*.py[cod]
 

+ 13 - 3
Dockerfile

@@ -16,7 +16,15 @@ COPY bin ./bin
 COPY deploy ./deploy
 COPY third-party ./third-party
 COPY src ./src
-COPY integrations/hermes-bots-bridge ./integrations/hermes-bots-bridge
+COPY runtime ./runtime
+
+# Embedded Hermes kernel: Debian bookworm ships Python 3.11, the version the lock file targets.
+RUN apt-get update \
+  && apt-get install -y --no-install-recommends python3 python3-venv python3-dev build-essential \
+  && rm -rf /var/lib/apt/lists/* \
+  && python3 -m venv /app/.venv \
+  && /app/.venv/bin/pip install --no-cache-dir --require-hashes -r runtime/requirements.lock \
+  && find runtime -name __pycache__ -prune -exec rm -rf {} +
 
 RUN npm run build \
   && npm run runner:build \
@@ -30,8 +38,8 @@ ENV NODE_ENV=production \
     HERMES_YAOYAO_PORT=15300 \
     HERMES_YAOYAO_HOME=/home/node/.yaoyao \
     HERMES_YAOYAO_CHAT_CACHE_MODE=prefer-local \
-    HERMES_YAOYAO_SUPERVISE_DASHBOARD=0 \
-    HERMES_YAOYAO_LOCAL_VM_HOST=runner
+    HERMES_YAOYAO_LOCAL_VM_HOST=runner \
+    PYTHONDONTWRITEBYTECODE=1
 
 WORKDIR /app
 
@@ -47,6 +55,8 @@ 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
 COPY --chown=node:node --from=builder /app/bin ./bin
+COPY --chown=node:node --from=builder /app/runtime ./runtime
+COPY --chown=node:node --from=builder /app/.venv ./.venv
 COPY --chown=node:node --from=builder /app/build-info.json /app/runner-bundle.tar.gz ./
 
 USER node

+ 20 - 13
README.md

@@ -2,7 +2,7 @@
 
 当前 Web 与 macOS 桌面发布版本:**v0.4.82**。桌面版提供 Apple Silicon(arm64)客户端正式 DMG;本次未发布完整版桌面安装包,Windows 与 Android 沿用旧版,详见 [发布说明](docs/releases/v0.4.82.md)。
 
-夭夭 AI 为网页、iOS 和安卓提供统一的 Agent、群聊、文件库及语音配置服务。Hermes 通过标准 9119 HTTP/WebSocket 接口执行任务。
+夭夭 AI 为网页、iOS 和安卓提供统一的 Agent、群聊、文件库及语音配置服务。Hermes(0.23.0)已内置在夭夭服务中,由服务端直接拉起内核进程执行任务,不再需要单独运行 9119 服务。
 
 ## 聊天与 Agent
 
@@ -11,7 +11,7 @@
 - 聊天列表混排角色单聊与群聊,不含默认 Profile 对话,没有独立话题列表。
 - 群聊可增减成员,当前管理员不能移除。可修改群规则、管理员、协作方式和自动回复轮数;默认管理员协调、3 轮。
 - 角色规则在下一次执行生效。归档角色隐藏单聊并禁止再加入群聊,但不自动移出现有群聊。
-- 原生对话保留独立入口,由 Web 转发给 Hermes。
+- 原生对话保留独立入口,由内置 Hermes 执行。
 - 新聊天、事件及文件按登录用户隔离;基础 Profile 的工具、技能和既有记忆能力继续由 Hermes 管理。
 
 Bot 模式的“工具”菜单提供“自动化”和“已连接应用”两个独立入口。“已连接应用”统一管理应用连接与 MCP;“自动化”使用独立的日历、任务列表和运行日志页面。所有模式均可从底部菜单打开独立的“关于”对话框。这些页面不属于设置中心。
@@ -20,23 +20,29 @@ Bot 模式的“工具”菜单提供“自动化”和“已连接应用”两
 
 ## 运行
 
-需要 Node.js 24 和可通过标准 API 访问的 Hermes 9119 服务。
+需要 Node.js 24。内置 Hermes 内核需要 Python 3.11 和锁定依赖,`npm run kernel:setup` 会用 uv 自动准备(缺少 uv 时自动下载)。
 
 ```sh
 npm ci
+npm run kernel:setup
 npm run build
 npm start
 ```
 
-默认 Web 地址为 `http://127.0.0.1:15300`,上游为 `http://127.0.0.1:9119`。首次打开 Web 时自行创建管理员账号;服务不会生成固定的默认账号或密码。远端 Hermes 的凭据可在系统设置中配置。
+默认 Web 地址为 `http://127.0.0.1:15300`。首次打开 Web 时自行创建管理员账号;服务不会生成固定的默认账号或密码。之后在“系统设置 → 模型服务”中配置模型供应商和默认模型。
 
-```sh
-HERMES_YAOYAO_UPSTREAM=http://服务器:9119 npm start
-```
+### 内置 Hermes
+
+- 源码位于 `runtime/hermes`(Hermes 0.23.0,取自 yaovi-agent 的内置适配版本);`runtime/worker.py` 每轮对话启动一个内核进程,`runtime/hermes_service.py` 负责模型、配置与授权等管理操作。
+- 数据保存在 `<数据目录>/hermes`:默认 Profile 即该目录,具名 Profile 在 `hermes/profiles/<名称>`;每个 Bot 使用独立的 `bots/<Bot ID>/runtime`,以所选 Profile 为父级读取配置和凭据。
+- 首次启动时如果检测到原有 `~/.hermes`(或 `YAOYAO_IMPORT_HERMES_HOME` 指定的目录),会只读导入会话、Profile、配置、凭据、技能和附件,不修改原目录;导入失败时从空数据启动并在日志中提示。设置 `YAOYAO_IMPORT_HERMES=0` 可跳过导入。
+- Hermes 原生终端、文件和代码工具在服务器上执行,按系统设置中的审批策略逐次确认。
+- 不再支持:连接外部 9119、工具桥插件 `yaoyao-bot-bridge`、Hermes 看板(Kanban)、直连远程 Hermes 的节点。设置 `HERMES_YAOYAO_UPSTREAM*`、`HERMES_YAOYAO_SUPERVISE_DASHBOARD`、`HERMES_YAOYAO_BRIDGE_*` 后,启动时会提示这些变量已停用。
+- 迁移方案与实施记录见 [内置 Hermes 迁移](docs/embedded-hermes-migration.md)。
 
 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`。
+由 Web 或 iOS 创建的普通聊天会按登录用户、Profile 和 Session ID 在 `chat-cache.sqlite3` 中登记所有权并持久化;后续续聊与列表展示以这份服务端登记为准,不再单独依赖 Hermes 的 `source` 标记。Web 的只读历史记录不进入该数据库,按需读取内置 Hermes 的会话库。可通过 `HERMES_YAOYAO_CHAT_CACHE_MODE=upstream-only|shadow|prefer-local` 切换策略,默认 `prefer-local`。
 
 ## macOS 桌面版
 
@@ -58,7 +64,7 @@ npm install -g @lsamien/yaoyao
 yaoyao service install
 ```
 
-安装后访问 `http://127.0.0.1:15300` 创建管理员账号。macOS 通过 LaunchAgent 开机自启;Linux 的服务安装支持在路线图中。详见 [npm 安装说明](docs/npm-install.md)。
+安装脚本会准备内置 Hermes 内核;若 npm 跳过了安装脚本,可运行 `yaoyao setup`(首次启动也会自动补做),并用 `yaoyao doctor` 检查。安装后访问 `http://127.0.0.1:15300` 创建管理员账号。macOS 通过 LaunchAgent 开机自启;Linux 的服务安装支持在路线图中。详见 [npm 安装说明](docs/npm-install.md)。
 
 执行 `yaoyao service restart` 重启服务,执行 `yaoyao --version`(或 `yaoyao version` / `yaoyao -v`)查询已安装的 npm 包版本。
 
@@ -72,7 +78,7 @@ yaoyao service install
 | `samienluo/yaoyao:v0.4.82` | 自动匹配 AMD64 / ARM64 |
 | `samienluo/yaoyao:latest` | 最新稳定版通用镜像,当前与 `v0.4.82` 相同 |
 
-准备好 Docker Engine/Compose 和容器可访问的 Hermes 9119 服务,在仓库目录将 `docker.env.example` 复制为 `docker.env`。配置上游地址,并设置 `HERMES_YAOYAO_IMAGE=samienluo/yaoyao:v0.4.82`(或 `samienluo/yaoyao:latest`),即可使用远程镜像:
+准备好 Docker Engine/Compose,在仓库目录将 `docker.env.example` 复制为 `docker.env`。镜像已内置 Hermes 内核和 Python 依赖;如需导入原有 Hermes 数据,设置 `HERMES_YAOYAO_HERMES_DIR` 并在启动命令中加 `-f compose.hermes-import.yaml`。设置 `HERMES_YAOYAO_IMAGE=samienluo/yaoyao:v0.4.82`(或 `samienluo/yaoyao:latest`),即可使用远程镜像:
 
 ```sh
 docker compose --env-file docker.env pull web
@@ -83,12 +89,12 @@ docker compose --env-file docker.env up -d --no-build web
 
 ```sh
 cp docker.env.example docker.env
-# 按实际环境修改 docker.env 中的上游地址和发布地址
+# 按实际环境修改 docker.env 中的发布地址
 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` 命名卷,容器内路径为 `/home/node/.yaoyao`。首次打开页面创建管理员账号,并在系统设置中配置 Hermes 连接。
+默认访问 `http://127.0.0.1:15300`。应用数据保存在 `yaoyao-data` 命名卷,容器内路径为 `/home/node/.yaoyao`。首次打开页面创建管理员账号,并在“系统设置 → 模型服务”中配置模型。
 
 宿主机连接、局域网访问、验证及升级步骤见 [Docker 部署说明](docs/docker-install.md)。
 
@@ -96,7 +102,7 @@ docker compose --env-file docker.env up -d --build
 
 ## iOS
 
-iOS 统一连接 Web 地址,通过设置中的手机登录二维码或账号密码登录。不能再直接填写 9119 地址;旧 15300 Web 账号和本机聊天缓存继续保留。
+iOS 统一连接 Web 地址,通过设置中的手机登录二维码或账号密码登录。服务端已内置 Hermes,手机端需升级到支持内置 Hermes 的版本;旧 15300 Web 账号和本机聊天缓存继续保留。
 
 ## 数据与升级
 
@@ -114,6 +120,7 @@ npm 安装的 macOS 服务支持在「更新与回滚」中下载 npm 新版本
 npm run typecheck
 npm test
 npm run build
+npm run kernel:test   # 内置 Hermes 内核与模型服务(需先运行 npm run kernel:setup)
 ```
 
 接口契约见 [聊天接口与运行模型](docs/workspace-chat.md),安装步骤见 [部署说明](docs/agent-install.md)。

+ 4 - 7
bin/hermes-yaoyao.mjs

@@ -40,15 +40,11 @@ function environment(env = process.env) {
   const allowed = [
     'HERMES_YAOYAO_HOST',
     'HERMES_YAOYAO_PORT',
-    'HERMES_YAOYAO_UPSTREAM',
-    'HERMES_YAOYAO_UPSTREAM_USERNAME',
-    'HERMES_YAOYAO_UPSTREAM_PASSWORD_FILE',
     'HERMES_YAOYAO_ALLOWED_HOSTS',
     'HERMES_YAOYAO_HOME',
     'HERMES_YAOYAO_TLS_CERT',
     'HERMES_YAOYAO_TLS_KEY',
     'HERMES_YAOYAO_ALLOW_INSECURE_LAN',
-    'HERMES_YAOYAO_SUPERVISE_DASHBOARD',
     'HERMES_YAOYAO_CHAT_CACHE_MODE',
     'HERMES_YAOYAO_RELEASE_SOURCE',
     'HERMES_YAOYAO_RELEASE_ROOT',
@@ -61,6 +57,9 @@ function environment(env = process.env) {
     'HERMES_YAOYAO_FCM_PROJECT_ID',
     'HERMES_YAOYAO_FCM_PACKAGE_NAME',
     'HERMES_YAOYAO_SERVICE_ROOT',
+    'YAOYAO_KERNEL_PYTHON',
+    'YAOYAO_KERNEL_VENV',
+    'YAOYAO_IMPORT_HERMES_HOME',
   ]
   return { ...Object.fromEntries(allowed.flatMap(key => env[key] ? [[key, env[key]]] : [])),
     HERMES_YAOYAO_RELEASE_SOURCE: normalizeReleaseSource(env.HERMES_YAOYAO_RELEASE_SOURCE) }
@@ -74,8 +73,6 @@ export function launchAgentPlist(options = {}) {
     PATH: `${dirname(node)}:${join(homedir(), '.local', 'bin')}:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`,
     NODE_ENV: 'production',
     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),
@@ -184,7 +181,7 @@ async function restart() {
 
 function stop() {
   if (loaded()) run('launchctl', ['bootout', `${domain}/${label}`])
-  process.stdout.write(`已停止 ${label};Hermes 9119 未被操作\n`)
+  process.stdout.write(`已停止 ${label}\n`)
 }
 
 async function uninstall() {

+ 4 - 0
bin/lib/kernel-setup.d.mts

@@ -0,0 +1,4 @@
+export function kernelVenv(root: string, env?: NodeJS.ProcessEnv): string
+export function kernelPython(root: string, env?: NodeJS.ProcessEnv): string
+export function verifyKernel(options: { root: string; env?: NodeJS.ProcessEnv; python?: string }): string
+export function prepareKernel(options: { root: string; env?: NodeJS.ProcessEnv; force?: boolean }): Promise<string>

+ 15 - 8
bin/lib/kernel-setup.mjs

@@ -4,13 +4,18 @@ import {spawnSync} from 'node:child_process'
 import {createHash} from 'node:crypto'
 import {existsSync,mkdirSync,mkdtempSync,readFileSync,rmSync,writeFileSync} from 'node:fs'
 import {tmpdir} from 'node:os'
-import {join} from 'node:path'
+import {dirname,join} from 'node:path'
 
 const UV_VERSION='0.13.0'
 
+/** Virtual environment for the kernel: packaged apps keep it outside their read-only bundle. */
+export function kernelVenv(root,env=process.env){
+  return env.YAOYAO_KERNEL_VENV||join(root,'.venv')
+}
+
 /** Interpreter used for runtime/worker.py and runtime/hermes_service.py. */
 export function kernelPython(root,env=process.env){
-  return env.YAOYAO_KERNEL_PYTHON||(existsSync(join(root,'runtime/python/bin/python3'))?join(root,'runtime/python/bin/python3'):join(root,'.venv/bin/python'))
+  return env.YAOYAO_KERNEL_PYTHON||(existsSync(join(root,'runtime/python/bin/python3'))?join(root,'runtime/python/bin/python3'):join(kernelVenv(root,env),'bin/python'))
 }
 
 function runCommand(command,args,{cwd,env,input,quiet=false}={}){
@@ -31,7 +36,8 @@ export function verifyKernel({root,env=process.env,python=kernelPython(root,env)
 
 async function resolveUv(root,env,run,fetchImpl){
   if(env.YAOYAO_UV){run(env.YAOYAO_UV,['--version'],{cwd:root,env,quiet:true});return env.YAOYAO_UV}
-  const local=join(root,'.tool-bin/uv')
+  const tools=env.YAOYAO_KERNEL_VENV?join(dirname(env.YAOYAO_KERNEL_VENV),'tool-bin'):join(root,'.tool-bin')
+  const local=join(tools,'uv')
   if(existsSync(local))return local
   try{run('uv',['--version'],{cwd:root,env,quiet:true});return 'uv'}catch{/* install a private copy below */}
   console.log(`正在安装内核依赖管理器 uv ${UV_VERSION}…`)
@@ -39,8 +45,8 @@ async function resolveUv(root,env,run,fetchImpl){
   if(!response.ok)throw new Error(`uv 下载失败(HTTP ${response.status})`)
   const installer=await response.text()
   if(installer.length>1024*1024)throw new Error('uv 安装脚本大小异常')
-  mkdirSync(join(root,'.tool-bin'),{recursive:true})
-  run('sh',[],{cwd:root,env:{...env,UV_UNMANAGED_INSTALL:join(root,'.tool-bin'),UV_NO_MODIFY_PATH:'1'},input:installer})
+  mkdirSync(tools,{recursive:true})
+  run('sh',[],{cwd:root,env:{...env,UV_UNMANAGED_INSTALL:tools,UV_NO_MODIFY_PATH:'1'},input:installer})
   if(!existsSync(local))throw new Error('uv 安装未生成可执行文件')
   return local
 }
@@ -52,14 +58,15 @@ export async function prepareKernel({root,env=process.env,run=runCommand,fetchIm
   if(env.YAOYAO_KERNEL_PYTHON)return verifyKernel({root,env,python,run})
   if(python===join(root,'runtime/python/bin/python3'))return python
   const fingerprint=createHash('sha256').update(readFileSync(join(root,'runtime/requirements.lock'))).digest('hex')
-  const marker=join(root,'.venv/.yaoyao-requirements')
+  const venv=kernelVenv(root,env)
+  const marker=join(venv,'.yaoyao-requirements')
   if(!force&&existsSync(python)&&existsSync(marker)&&readFileSync(marker,'utf8')===fingerprint)return python
   // A previous successful fingerprint must not survive a failed repair.
   rmSync(marker,{force:true})
   try{
-    const installEnv={...env,UV_PYTHON_INSTALL_DIR:join(root,'.python'),UV_PYTHON_DOWNLOADS:'automatic'}
+    const installEnv={...env,UV_PYTHON_INSTALL_DIR:env.YAOYAO_KERNEL_VENV?join(dirname(venv),'python'):join(root,'.python'),UV_PYTHON_DOWNLOADS:'automatic'}
     const uv=await resolveUv(root,installEnv,run,fetchImpl)
-    if(!existsSync(python))run(uv,['venv','--managed-python','--python','3.11',join(root,'.venv')],{cwd:root,env:installEnv})
+    if(!existsSync(python))run(uv,['venv','--managed-python','--python','3.11',venv],{cwd:root,env:installEnv})
     console.log('正在准备 Hermes 内核依赖…')
     run(uv,['pip','sync','--python',python,'--require-hashes',join(root,'runtime/requirements.lock')],{cwd:root,env:installEnv})
     verifyKernel({root,env,python,run})

+ 0 - 2
compose.desktops.cursor.yaml

@@ -22,12 +22,10 @@ services:
       NODE_ENV: production
       HERMES_YAOYAO_HOST: 0.0.0.0
       HERMES_YAOYAO_PORT: 15300
-      HERMES_YAOYAO_UPSTREAM: "${HERMES_YAOYAO_UPSTREAM:-http://host.docker.internal:9119}"
       # Permit localhost access when the published host port differs from the
       # container's fixed 15300 port; configured public host names remain opt-in.
       HERMES_YAOYAO_ALLOWED_HOSTS: "localhost,127.0.0.1,${HERMES_YAOYAO_ALLOWED_HOSTS:-}"
       HERMES_YAOYAO_ALLOW_INSECURE_LAN: "1"
-      HERMES_YAOYAO_SUPERVISE_DASHBOARD: "0"
       HERMES_YAOYAO_LOCAL_VM_HOST: "runner"
       HERMES_YAOYAO_COMPOSE_DESKTOPS: "[{\"id\":\"647fbb98-0c40-4d96-91e0-3290eb9020eb\",\"name\":\"Cursor 开发桌面\",\"socketPath\":\"/run/yaoyao-desktops/desktop-cursor/desktop.sock\",\"networkSocketPath\":\"/run/yaoyao-networks/desktop-cursor/gateway.sock\",\"imageKey\":\"cursor\"}]"
       HERMES_YAOYAO_CHAT_CACHE_MODE: "${HERMES_YAOYAO_CHAT_CACHE_MODE:-prefer-local}"

+ 0 - 2
compose.desktops.yaml

@@ -22,12 +22,10 @@ services:
       NODE_ENV: production
       HERMES_YAOYAO_HOST: 0.0.0.0
       HERMES_YAOYAO_PORT: 15300
-      HERMES_YAOYAO_UPSTREAM: "${HERMES_YAOYAO_UPSTREAM:-http://host.docker.internal:9119}"
       # Permit localhost access when the published host port differs from the
       # container's fixed 15300 port; configured public host names remain opt-in.
       HERMES_YAOYAO_ALLOWED_HOSTS: "localhost,127.0.0.1,${HERMES_YAOYAO_ALLOWED_HOSTS:-}"
       HERMES_YAOYAO_ALLOW_INSECURE_LAN: "1"
-      HERMES_YAOYAO_SUPERVISE_DASHBOARD: "0"
       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\",\"networkSocketPath\":\"/run/yaoyao-networks/desktop-1/gateway.sock\",\"imageKey\":\"standard\"},{\"id\":\"eba5caaf-744e-4f27-bcdd-1f1f35d05a42\",\"name\":\"共享桌面 2\",\"socketPath\":\"/run/yaoyao-desktops/desktop-2/desktop.sock\",\"networkSocketPath\":\"/run/yaoyao-networks/desktop-2/gateway.sock\",\"imageKey\":\"standard\"}]"
       HERMES_YAOYAO_CHAT_CACHE_MODE: "${HERMES_YAOYAO_CHAT_CACHE_MODE:-prefer-local}"

+ 14 - 0
compose.hermes-import.yaml

@@ -0,0 +1,14 @@
+# Optional overlay: import an existing Hermes data directory once, read-only.
+# The embedded Hermes copies it into the yaoyao-data volume on first start and never writes to it.
+# Combine with compose.yaml (or a desktops compose file): docker compose -f compose.yaml -f compose.hermes-import.yaml up -d
+services:
+  web:
+    environment:
+      YAOYAO_IMPORT_HERMES_HOME: /import/hermes
+    volumes:
+      - type: bind
+        source: "${HERMES_YAOYAO_HERMES_DIR:?Set HERMES_YAOYAO_HERMES_DIR to the existing Hermes data directory}"
+        target: /import/hermes
+        read_only: true
+        bind:
+          create_host_path: false

+ 0 - 2
compose.yaml

@@ -21,12 +21,10 @@ services:
       NODE_ENV: production
       HERMES_YAOYAO_HOST: 0.0.0.0
       HERMES_YAOYAO_PORT: 15300
-      HERMES_YAOYAO_UPSTREAM: "${HERMES_YAOYAO_UPSTREAM:-http://host.docker.internal:9119}"
       # Permit localhost access when the published host port differs from the
       # container's fixed 15300 port; configured public host names remain opt-in.
       HERMES_YAOYAO_ALLOWED_HOSTS: "localhost,127.0.0.1,${HERMES_YAOYAO_ALLOWED_HOSTS:-}"
       HERMES_YAOYAO_ALLOW_INSECURE_LAN: "1"
-      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/yaoyao.git}"

+ 4 - 4
desktop/main.mjs

@@ -375,6 +375,8 @@ else {
         return info
       })
     }
+    // Embedded Hermes: sources ship in web-service/runtime; the venv lives in writable user data.
+    const kernelEnvironment = () => ({ YAOYAO_KERNEL_ROOT: join(root, 'web-service'), YAOYAO_KERNEL_VENV: join(app.getPath('userData'), 'hermes-kernel', 'venv') })
     if (platform.server) {
     manager = new DesktopServiceManager({ home, port, version: packageVersion, log, onState: stateChanged,
       prepareHome: !fixtureHome ? onProgress => migrateLocalData({ home, port, root, onProgress }) : undefined,
@@ -382,16 +384,14 @@ else {
         ? onProgress => stopLocalService({home,port,root,fixture:Boolean(fixtureHome),onProgress}) : undefined,
       synchronize: (app.isPackaged && !fixtureHome) || (fixtureHome && process.env.HERMES_YAOYAO_DESKTOP_TEST_SYNC === '1')
         ? (onProgress, { force = false } = {}) => synchronizeLocalService({ home, port, root, fixture: Boolean(fixtureHome), onProgress, force,
-          environment: { HERMES_YAOYAO_UPSTREAM: process.env.HERMES_YAOYAO_UPSTREAM || 'http://127.0.0.1:9119', HERMES_YAOYAO_SUPERVISE_DASHBOARD: fixtureHome ? '0' : '1', HERMES_YAOYAO_DEFER_HERMES: '1' } })
+          environment: { ...kernelEnvironment(), HERMES_YAOYAO_DEFER_HERMES: '1' } })
         : undefined,
       fork: ({ home, port }) => {
         const env = { ...process.env, NODE_ENV: 'production', NODE_USE_ENV_PROXY: '0',
           PATH: [join(homedir(), '.local/bin'), '/opt/homebrew/bin', '/usr/local/bin', process.env.PATH || '/usr/bin:/bin'].join(':'),
           HERMES_YAOYAO_DESKTOP: '1', HERMES_YAOYAO_HOME: home, HERMES_YAOYAO_HOST: '127.0.0.1',
           HERMES_YAOYAO_PORT: String(port), HERMES_YAOYAO_STATIC_DIR: join(root, 'ui'),
-          HERMES_YAOYAO_SUPERVISE_DASHBOARD: fixtureHome ? '0' : '1',
-          HERMES_YAOYAO_DEFER_HERMES: '1',
-          HERMES_YAOYAO_UPSTREAM: process.env.HERMES_YAOYAO_UPSTREAM || 'http://127.0.0.1:9119' }
+          HERMES_YAOYAO_DEFER_HERMES: '1', ...kernelEnvironment() }
         delete env.ELECTRON_RUN_AS_NODE
         delete env.HERMES_YAOYAO_TLS_CERT; delete env.HERMES_YAOYAO_TLS_KEY
         return utilityProcess.fork(join(root, 'server.mjs'), [], { cwd: root, env, stdio: 'pipe' })

+ 3 - 6
docker.env.example

@@ -14,17 +14,14 @@ HERMES_YAOYAO_PUBLISHED_PORT=15300
 # YAOYAO_CURSOR_DESKTOP_IMAGE=samienluo/yaoyao-desktop:v0.4.12-cursor-amd
 
 # 部署步骤见 docs/docker-install.md;使用 docker compose --env-file docker.env 启动。
-# 填写容器可访问的 Hermes Dashboard/Gateway 地址。
-# Docker Desktop 可用这个地址访问宿主机;Linux 上的 9119 还必须监听容器可达的宿主机地址。
-HERMES_YAOYAO_UPSTREAM=http://host.docker.internal:9119
-# 可选工具桥安装:填写上述 Hermes 使用的数据目录的宿主机绝对路径(包含 config.yaml)。
-# 启动时额外加 -f compose.hermes-bridge.yaml;目录必须已存在且容器用户有读写权限。
+# Hermes 已内置在镜像中,不再需要 9119 服务。
+# 可选:首次启动只读导入原有 Hermes 数据目录(包含 config.yaml),启动时额外加 -f compose.hermes-import.yaml。
 # Linux 示例:/srv/hermes-data;macOS 示例:/Users/你的用户名/.hermes。
 # HERMES_YAOYAO_HERMES_DIR=/srv/hermes-data
 HERMES_YAOYAO_CHAT_CACHE_MODE=prefer-local
 # 官方稳定发布源;自定义 Git 仓库可覆盖。容器仍由部署者重建升级。
 HERMES_YAOYAO_RELEASE_SOURCE=https://github.com/Lsamien/yaoyao.git
-# 首次登录后在 Web 系统设置中保存 Hermes 连接凭据。
+# 首次登录后在 Web 系统设置 → 模型服务中配置模型。
 # 使用 compose.desktops.yaml 可同时部署固定数量的共享桌面容器。
 # 桌面数量以 Compose 为准,Web 仅连接已有桌面;详见 docs/docker-install.md。
 

+ 3 - 3
docs/agent-install.md

@@ -3,13 +3,13 @@
 ## 前提
 
 - 源码安装需要 Node.js 24;容器安装需要 Docker Engine 或 Docker Desktop。
-- 可访问的 Hermes Dashboard/Gateway(通常为 9119),支持会话创建、恢复、提示词提交、附件及审批 RPC。
+- 不需要单独的 Hermes 服务:Hermes 0.23.0 已内置。源码部署运行 `npm run kernel:setup`(npm 安装运行 `yaoyao setup`)准备 Python 3.11 依赖。
 
 ## 源码安装
 
 在仓库执行 `npm ci`、`npm run build`,然后执行 `npm start`。Web 默认监听 `127.0.0.1:15300`。
 
-上游地址由 `HERMES_YAOYAO_UPSTREAM` 配置。远端凭据在 Web 系统设置中保存。需要环境配置时使用 `HERMES_YAOYAO_UPSTREAM_USERNAME` 和 `HERMES_YAOYAO_UPSTREAM_PASSWORD`,不要把凭据嵌入 URL。
+模型供应商、默认模型和凭据在 Web 的“系统设置 → 模型服务”中配置,保存在数据目录的 `hermes/` 下。首次启动会只读导入原有 `~/.hermes`。
 
 首次打开 Web 时创建管理员账号和至少 8 位的密码。服务不会生成固定的默认账号或密码;iOS 使用 Web 账号或手机登录二维码。
 
@@ -19,7 +19,7 @@
 
 ## Docker 安装
 
-复制 `docker.env.example` 为 `docker.env`,填写容器可访问的 `HERMES_YAOYAO_UPSTREAM`,然后执行:
+复制 `docker.env.example` 为 `docker.env`,按需填写发布地址(导入原有数据见 [Docker 部署说明](docker-install.md#导入原有-hermes-数据)),然后执行:
 
 ```sh
 docker compose --env-file docker.env config --quiet

+ 17 - 62
docs/docker-install.md

@@ -3,7 +3,7 @@
 ## 准备
 
 - 安装 Docker Engine 和 Compose,或 Docker Desktop。
-- 准备容器可访问的 Hermes Dashboard/Gateway,通常使用 9119 端口。
+- 不需要单独的 Hermes 服务:镜像已内置 Hermes 0.23.0 内核及其 Python 依赖。
 - 获取本项目源码,在仓库目录执行后续命令。
 
 ## 已发布的远程镜像
@@ -35,13 +35,13 @@ cp docker.env.example docker.env
 | 配置 | 用途 |
 | --- | --- |
 | `HERMES_YAOYAO_IMAGE` | 远程镜像可设为 `samienluo/yaoyao:v0.4.77` 或 `samienluo/yaoyao:latest`;未设置时使用本地构建名称 |
-| `HERMES_YAOYAO_UPSTREAM` | Hermes 上游地址,默认 `http://host.docker.internal:9119` |
+| `HERMES_YAOYAO_HERMES_DIR` | 可选,原有 Hermes 数据目录的宿主机路径,配合 `compose.hermes-import.yaml` 首次启动只读导入 |
 | `HERMES_YAOYAO_BIND_ADDRESS` | Web 的宿主机发布地址,默认 `127.0.0.1`;局域网访问可设为 `0.0.0.0` |
 | `HERMES_YAOYAO_PUBLISHED_PORT` | 宿主机 Web 端口,默认 `15300` |
 | `HERMES_YAOYAO_ALLOWED_HOSTS` | 使用域名访问时填写对应域名,多个值用英文逗号分隔 |
 | `HERMES_YAOYAO_CHAT_CACHE_MODE` | 普通聊天缓存策略,默认 `prefer-local` |
 
-Docker Desktop 可通过 `host.docker.internal` 访问宿主机。Linux 上 Compose 将该名称映射到宿主机网关;Hermes 需要监听容器可访问的宿主机地址。远程 Hermes 直接填写其可访问地址。
+内置 Hermes 的会话、Profile、模型配置和凭据都保存在 `yaoyao-data` 数据卷的 `hermes/` 目录;首次登录后在“系统设置 → 模型服务”中配置模型。
 
 使用远程镜像时,在 `docker.env` 设置上述镜像标签后执行:
 
@@ -62,64 +62,20 @@ docker compose --env-file docker.env ps
 
 默认打开 `http://127.0.0.1:15300`。局域网设备使用宿主机 IP 和发布端口访问。首次打开页面创建管理员账号,再到系统设置配置 Hermes 连接凭据。通过域名提供公网访问时,在反向代理上配置 HTTPS,并将域名加入允许列表。
 
-## 映射 Hermes 目录以安装工具桥
+## 导入原有 Hermes 数据
 
-可额外加载 `compose.hermes-bridge.yaml`,让“设置 → Hermes 连接 → 工具桥插件”直接检查、安装和修复共享目录中的插件。这个可选文件适用于普通 Web、标准共享桌面和 Cursor 共享桌面三种 Compose 配置。
-
-在 `docker.env` 中填写 **上游 Hermes 实际使用的数据目录** 的宿主机绝对路径。该目录应包含 `config.yaml`,命名 Profile 位于其中的 `profiles/`:
-
-```dotenv
-# Linux 示例;macOS 可填写 /Users/你的用户名/.hermes。
-HERMES_YAOYAO_HERMES_DIR=/srv/hermes-data
-```
-
-普通 Web 使用:
-
-```sh
-docker compose --env-file docker.env -f compose.yaml -f compose.hermes-bridge.yaml config --quiet
-docker compose --env-file docker.env -f compose.yaml -f compose.hermes-bridge.yaml up -d --build web
-```
-
-若使用共享桌面,将上面的第一个 `-f compose.yaml` 换成 `-f compose.desktops.yaml` 或 `-f compose.desktops.cursor.yaml`,保留第二个映射文件。
-
-- 宿主目录以读写方式挂载到容器 `/hermes`,必须已存在;路径写错时不会自动创建一个空 Hermes 目录。
-- 选择与 `HERMES_YAOYAO_UPSTREAM` 对应实例相同的数据目录。远程主机的目录需要先以共享存储等方式提供给 Docker 宿主机。
-- Web 仍使用非 root 用户,默认 UID/GID 为 `1000:1000`。映射目录需要允许该用户读取配置,并写入 `config.yaml`、`plugins/`、`profiles/` 和 `backups/`。权限不匹配时应在宿主机配置对应用户或 ACL;Web 页面会报告读取或安装失败。
-- 镜像自带 Linux Python 3 和 PyYAML。安装器只使用容器 `/usr/bin/python3`,宿主机的 `venv` 和 Hermes 程序不会被执行。
-- 映射模式只安装共享数据目录中的工具桥,不执行 `--repair-profile-runtime`。Profile 模型兼容修复必须在实际运行 Hermes 的容器或节点,使用其 Python 单独执行;页面会明确提示这一点。
-- 安装前备份插件与配置,先安装默认 Profile 的后台入口,再处理命名 Profile。安装后在 Hermes 所在节点重启服务,再在 Web 点击“重新检查”。
-- 映射不会赋予 Web 管理 Docker 或 Hermes 进程的能力;既有 Compose 桌面数量、隔离设置及生命周期继续按原配置管理。
-
-此功能需要包含本次改动的新镜像;旧的远程镜像标签不会因添加目录映射而自动获得安装功能。可按上述命令从当前源码构建。
-
-自定义部署可使用以下容器环境变量:
-
-| 配置 | 用途 |
-| --- | --- |
-| `HERMES_YAOYAO_BRIDGE_MOUNTED=1` | 明确允许通过映射目录安装工具桥 |
-| `HERMES_YAOYAO_BRIDGE_HOME=/hermes` | 容器内实际挂载路径,必须是绝对路径 |
-| `HERMES_YAOYAO_BRIDGE_PYTHON=/usr/bin/python3` | 容器自身的 Python 路径 |
-
-仅设置目录但没有开启 `BRIDGE_MOUNTED` 时,外部 Hermes 仍只提供状态检查,不开放目录安装。
-
-### Docker 安装报 Profile 模型兼容修复失败
-
-旧版 Web 安装接口会无条件添加 `--repair-profile-runtime`。当 Hermes 与夭夭运行在不同容器、仅共享数据目录时,夭夭容器的 Python 找不到 `tui_gateway`,即使目录可写也会报“工具桥或 Profile 模型兼容修复安装失败”。应更新到包含修复的 Web 镜像,或从当前源码构建;添加目录映射、反复重启不会修复旧版接口。
-
-暂未更新镜像时,可直接调用镜像内的安装器,仅安装工具桥。以下假设容器名为 `yaoyao`、`hermes-agent`,共享目录在夭夭中为 `/hermes`:
+已有 Hermes 数据目录(包含 `config.yaml`、`state.db`、`profiles/` 等)时,可在首次启动时只读导入:
 
 ```sh
-docker exec yaoyao /usr/bin/python3 /app/dist-server/runner/install-hermes-bridge.py \
-  --hermes-home /hermes --profile default --enable
+# docker.env 中填写宿主机绝对路径;Linux 示例 /srv/hermes-data,macOS 示例 /Users/你的用户名/.hermes
+HERMES_YAOYAO_HERMES_DIR=/srv/hermes-data
+docker compose --env-file docker.env -f compose.yaml -f compose.hermes-import.yaml up -d --build web
 ```
 
-每个使用中的命名 Profile 也需安装,将 `default` 替换为对应名称;先完成默认 Profile。命令会备份配置和旧插件,失败会直接显示具体原因。安装成功后,在空闲时执行 `docker restart hermes-agent`,再回 Web 重新检查。
-
-此命令不修复 Hermes 核心模型解析。需要该修复时,将同一 Web 镜像中的安装器和插件包复制到 Hermes 容器,使用运行 Hermes 的 Python 执行安装器并添加 `--repair-profile-runtime`。修复需要 Hermes 源码写入权限,并会先验证兼容性;验证失败时不修改核心文件。Hermes 程序位于容器自身文件系统时,核心修复不会随共享数据目录持久化,重建或升级 Hermes 容器后需重新检查。
-
-共享数据目录还需要匹配两个服务的运行 UID/GID。可用 `docker exec yaoyao id` 和 Hermes 容器中实际服务用户的 `id` 核对。安装器会原子替换配置文件,只有旧文件的写权限并不足够,新的配置也必须能由 Hermes 服务用户读取;优先对齐两端运行 UID/GID,不要仅放宽旧文件权限。
-
-若两个服务在同一 Compose 网络,直接设置 `HERMES_YAOYAO_UPSTREAM: http://hermes-agent:9119`。宿主机发布的 `9120:9119` 用于从宿主机访问;不需要把 `hermes-agent` 通过 `extra_hosts` 覆盖成宿主机网关。
+- 目录以只读方式挂载到 `/import/hermes`,导入过程不会写入原目录;SQLite 数据库使用在线备份读取,原 Hermes 仍在运行时也能得到一致副本,但建议先停止原 Hermes。
+- 只在 `yaoyao-data` 中的 `hermes/` 为空时导入一次;重复启动不会覆盖已有数据。导入失败时内置 Hermes 从空数据启动,原因写入日志和数据目录中的 `hermes-import-error.json`。
+- 导入完成后可移除 `compose.hermes-import.yaml` 和挂载。
+- `compose.hermes-import.yaml` 也可与 `compose.desktops.yaml`、`compose.desktops.cursor.yaml` 组合使用。
 
 ## 验证
 
@@ -131,7 +87,7 @@ curl --fail http://127.0.0.1:15300/readyz
 docker compose --env-file docker.env logs --tail=100 web
 ```
 
-`healthz` 检查 Web 服务,`readyz` 检查 Hermes 上游。若上游不可达,检查 `HERMES_YAOYAO_UPSTREAM`、Hermes 监听地址及网络连通性;若需要认证,在 Web 系统设置中保存连接凭据。
+`healthz` 检查 Web 服务,`readyz` 检查内置 Hermes 是否可用。系统设置中的“内置 Hermes”页面显示内核状态和数据目录。
 
 登录后创建会话、收发消息、上传并下载附件,验证实际使用流程。
 
@@ -143,7 +99,7 @@ docker compose --env-file docker.env logs --tail=100 web
 
 ```sh
 cp docker.env.example docker.env
-# 配置 Web 发布地址、端口和已有 Hermes 的 9119 地址。
+# 配置 Web 发布地址和端口。
 docker compose --env-file docker.env -f compose.desktops.yaml up -d --build
 docker compose --env-file docker.env -f compose.desktops.yaml ps
 ```
@@ -192,7 +148,6 @@ cp -n docker.env.example docker.env
 
 ```dotenv
 HERMES_YAOYAO_IMAGE=yaoyao:local
-HERMES_YAOYAO_UPSTREAM=http://host.docker.internal:9119
 HERMES_YAOYAO_BIND_ADDRESS=127.0.0.1
 HERMES_YAOYAO_PUBLISHED_PORT=15300
 YAOYAO_CURSOR_DESKTOP_IMAGE=yaoyao-desktop:cursor
@@ -256,11 +211,11 @@ docker compose --env-file docker.env -f compose.desktops.cursor.yaml -f compose.
 
 聊天电脑面板显示每台桌面的镜像名称,机器人通过选择已有桌面来选择环境。不同桌面各自使用独立数据卷,可同时使用不同镜像;共享同一桌面的成员只能使用该桌面的一个镜像。改变现有条目的镜像会在下次 Compose 部署时重建该实例,请先结束使用它的任务,保留原有 ID、service 和数据卷。
 
-### Hermes 执行连接
+### 执行节点
 
-Compose 管理桌面,Hermes 执行连接负责模型运行和工具调用。沿用已有执行节点;新部署可在 **设置 → 本地虚拟机 → 打开执行节点设置** 下载程序和注册配置。此部署生成的配置自动带 `managedBy: compose`,执行节点不再创建桌面,也不需要安装 Docker。
+Compose 管理桌面,执行节点负责连接桌面并执行虚拟机工具;模型运行由 Web 内置的 Hermes 完成。沿用已有执行节点;新部署可在 **设置 → 本地虚拟机 → 打开执行节点设置** 下载程序和注册配置。此部署生成的配置自动带 `managedBy: compose`,执行节点不再创建桌面,也不需要安装 Docker。
 
-执行节点只需已有 Hermes 和 Node.js 24+。默认 Hermes 路径可留空;自定义安装填写绝对路径。把下载的程序和 `runner.json` 放在运行 Hermes 的电脑:
+执行节点需要 Node.js 24+。把下载的程序和 `runner.json` 放在执行节点所在的电脑:
 
 ```sh
 mkdir -p yaoyao-runner

+ 45 - 1
docs/embedded-hermes-migration.md

@@ -1,6 +1,6 @@
 # 内置 Hermes 迁移方案(草案,待确认)
 
-日期:2026-11-14 状态:**已确认,实施中(M0–M5 一次完成)**
+日期:2026-11-14 状态:**已实施(M0–M5),分支 `claude/zen-wozniak-309vnm`**
 
 目标:夭夭不再依赖外部 Hermes Dashboard(9119 HTTP/WebSocket),改为与 yaovi-agent 相同的方式,把 Hermes 源码内置在仓库中,由夭夭服务端直接拉起和管理内核进程。
 
@@ -160,3 +160,47 @@ yaovi-agent 在内置 Hermes 的同时还做了很多产品层改动,本方案
 5. **Hermes 副本**:直接复用 yaovi-agent 的 `0.23.0+yaovi`(建议),还是从官方 0.23.0 重新内置、只带夭夭需要的修改?
 6. **远程节点**:同意节点之间改为夭夭到夭夭(要求对端也升级)吗?
 7. **范围**:先只做 M0–M2(Bot 不再依赖外部 Hermes),还是一次做到 M5?
+
+
+---
+
+## 11. 实施记录(2026-11-14)
+
+### 实际架构
+
+| 组件 | 位置 | 作用 |
+| --- | --- | --- |
+| 内置 Hermes | `runtime/hermes`、`runtime/*.py` | 取自 yaovi-agent 的 0.23.0+yaovi,仅把对模型的产品身份改为夭夭 |
+| 内核进程 | `src/server/hermes/kernel.ts` → `runtime/worker.py` | 每轮一个进程;工具调用回到 Node 执行 |
+| 管理进程 | `src/server/hermes/service.ts` → `runtime/hermes_service.py` | 每个 Hermes home 一个常驻进程;新增 `dashboard.call`(直接调用 Hermes 原生 Dashboard 处理函数)、`botmodels.*` |
+| 进程内 API | `src/server/hermes/api.ts` | 原来发往 9119 的 REST 请求在进程内应答,返回结构与 Dashboard 相同 |
+| 进程内网关 | `src/server/hermes/gateway.ts` | 实现原 TUI 网关的 JSON-RPC 方法与事件;Bot 执行(`WorkspaceGateway`)和原生对话(`realtimeBroker`,经 `EmbeddedSocket`)共用 |
+| 导入 | `runtime/hermes_import.py`、`src/server/hermes/import.ts` | 首次启动只读导入 |
+| 技能 | `src/server/hermes/skills.ts` | Profile 技能随轮次加载;Bot 自己的技能写入其 runtime home |
+
+### 与方案的差异
+
+1. **Profile(第 5 节)**:没有采用“从模板复制”。具名 Profile 保留 Hermes 原生布局(`<data>/hermes/profiles/<名称>`);每个 Bot 有独立 runtime home(会话、上下文、自有技能),配置、`.env` 和凭据通过父级读取实时继承所选 Profile。效果上同样是“Bot 独立 home、不修改基础 Profile”,修改 Profile 的模型或凭据后 Bot 下一轮即生效。
+2. **原生对话协议(M3)**:内置网关实现了与原 Hermes 网关相同的 JSON-RPC 方法和事件,Web 客户端没有改动。移动端使用同一 HTTP+SSE 接口,理论上无需改协议;按你的决定,仍要求客户端升级后使用,旧版未做验证。
+3. **`/api/*` 转发**:保留了按白名单(status、profiles、sessions、model、files、attachments)转发的入口,供已配对设备读取会话和文件;现在由进程内 API 应答,不再访问 9119。通用 Dashboard 功能(Kanban、cron 页面等)已删除。
+4. **导入范围(第 4 节)**:导入整个 Hermes home(跳过 Hermes 程序、venv、日志、缓存、运行时下载和旧工具桥插件),而不是只导入已登记会话,这样历史记录视图能看到全部会话。
+5. **测试传输**:`createApplication({ fetchImpl })` 仍作为测试用的假 Dashboard 传输保留在 `UpstreamClient` 中;生产环境始终走进程内 API。
+
+### 验证
+
+- `npm run typecheck`、`npm run build` 通过。
+- `npm test`:2224 通过,28 失败;这 28 个在原提交 `f433741` 上同样失败(凭据保险箱、服务 CLI 版本、时间格式等与本环境相关的用例),没有新增失败。
+- `npm run kernel:test`:内核 11、模型服务 12、导入 2 个用例全部通过。
+- 新增真实内核 + 受控模型的测试:原生对话流式事件与续聊、授权工具调用、审批允许/拒绝、等待审批时中断、Profile 技能加载与新建、Bot 单聊与工具调用、扫码设备经 HTTP+SSE 对话、进程内 Dashboard API。
+- 桌面测试:93 通过、25 失败,与原提交完全相同(依赖 macOS/Electron 的用例)。
+- 生产构建冒烟:`node dist-server/server/index.js` 启动后 `/healthz`、`/readyz` 返回 200,9119 无监听;首次启动导入成功。
+
+### 已知限制与未完成项
+
+- **Docker 镜像未实际构建**:本环境没有 Docker 守护进程。已确认 `pip --require-hashes` 在 Python 3.11 下接受 `runtime/requirements.lock`;镜像构建和容器内运行需在有 Docker 的机器上验证。
+- **macOS 完整版桌面**:已把 `runtime/` 打进 `web-service/`,内核虚拟环境放在用户数据目录、首次启动自动准备;未实际打包验证。客户端版不受影响。
+- **执行节点(Runner)**:服务端发起的虚拟机工具会话(`toolsOnly`)不经过 Hermes;Runner 自身遗留的 Hermes 托管会话路径仍读取 `hermesURL`,服务端已不再使用该路径,未清理。
+- **未实现的网关方法**:`session.branch`(返回“暂不支持”)、`session.events.since`(断线重连时改为重置并从转录恢复)。
+- **会话标题**:使用首条消息截取,不再调用 Hermes 的标题生成。
+- **Hermes 内置 `memory` 工具**:yaovi-agent 版本已停用该工具,长期记忆走夭夭的工作区记忆工具;原生对话不再有 MEMORY.md/USER.md。
+- **用户数据隔离**:与原来连接同一个 9119 时相同,所有账号共用系统 Hermes 配置;Bot 按 ID 使用独立 runtime home。

+ 2 - 1
docs/npm-install.md

@@ -44,7 +44,8 @@ yaoyao --version          # 查看已安装的 npm 包版本
 | --- | --- | --- |
 | `YAOYAO_HOME` | 数据目录 | `~/.yaoyao` |
 | `HERMES_YAOYAO_PORT` | Web 端口 | `15300` |
-| `HERMES_YAOYAO_UPSTREAM` | Hermes 上游地址 | `http://127.0.0.1:9119` |
+| `YAOYAO_KERNEL_VENV` | 内置 Hermes 内核的 Python 虚拟环境目录 | 安装目录下的 `.venv` |
+| `YAOYAO_IMPORT_HERMES_HOME` | 首次启动只读导入的原 Hermes 数据目录 | `~/.hermes` |
 
 LaunchAgent 安装时的环境会写入 plist;修改环境变量配置后,执行 `yaoyao service install` 重新写入配置并启动服务。`yaoyao service restart` 使用已保存的配置重启。
 

+ 1 - 1
package.json

@@ -43,7 +43,7 @@
     "desktop:pack:win": "npm run desktop:build:win && node scripts/windows-desktop-release.mjs",
     "desktop:test:win": "node scripts/test-windows-desktop.mjs",
     "kernel:setup": "node scripts/kernel-setup.mjs",
-    "kernel:test": ".venv/bin/python tests/runtime/test_kernel.py && .venv/bin/python tests/runtime/test_hermes_service.py",
+    "kernel:test": ".venv/bin/python tests/runtime/test_kernel.py && .venv/bin/python tests/runtime/test_hermes_service.py && .venv/bin/python tests/runtime/test_hermes_import.py",
     "postinstall": "node scripts/kernel-setup.mjs --postinstall"
   },
   "dependencies": {

+ 2 - 1
runtime/worker.py

@@ -25,7 +25,8 @@ startup_steers = []
 # Prefix of the per-turn application state Yaovi renders (src/server/workspacePrompt.ts).
 TURN_CONTEXT_SENTINEL = "[[YAOVI_TURN_CONTEXT_V1]]"
 # Control-plane RPCs whose replies are JSON values, never model-facing tool output.
-CONTROL_TOOLS = ("yaovi_clarify", "yaovi_native_authorize", "yaovi_native_check")
+CONTROL_TOOLS = ("yaovi_clarify", "yaovi_native_authorize", "yaovi_native_check",
+                 "yaovi_skills_authorize", "yaovi_skills_load", "yaovi_skills_commit")
 
 
 def emit(kind, **payload):

+ 2 - 0
scripts/build-desktop.mjs

@@ -47,6 +47,8 @@ const service = resolve(out, 'web-service')
 await mkdir(service)
 for (const file of ['server.mjs', 'vm-data-migrate.mjs', 'node_modules', 'ui', 'release.json', 'build-info.json', 'file_transfer.py', 'hermes_worker.py', 'profile_skills.py', 'skill_bundle.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 })
+// Embedded Hermes kernel sources; the Python environment is prepared on first start in the user data directory.
+await cp(resolve(root, 'runtime'), resolve(service, 'runtime'), { recursive: true, filter: source => !source.includes('__pycache__') && !source.endsWith('.pyc') && !/[\\/](?:\.env|auth\.json)$/.test(source) })
 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'))

+ 18 - 3
src/server/hermes/gateway.ts

@@ -6,6 +6,7 @@ import type { GatewayFrame } from '../workspaceGateway.js'
 import { defaultKernelConfig, runKernel, type KernelControl, type KernelTool } from './kernel.js'
 import type { HermesScope, HermesServicePool } from './service.js'
 import type { EmbeddedSession, EmbeddedSessions, SessionModel } from './sessions.js'
+import { collectSkills, commitSkills } from './skills.js'
 
 /**
  * In-process replacement for the Hermes dashboard's TUI gateway (`/api/ws` JSON-RPC).
@@ -43,7 +44,8 @@ interface Turn { id: string; controller: AbortController; control: KernelControl
 
 const SESSION_ID = /^[A-Za-z0-9_-]{1,128}$/
 const PROFILE = /^[a-z0-9][a-z0-9_-]{0,63}$/
-const READ_ONLY_NATIVE = new Set(['read_file', 'search_files', 'skills_list', 'skill_view', 'clarify', 'session_search', 'todo'])
+// Reads, and skill edits (confined to the turn's skill copy and committed by the host), need no approval.
+const READ_ONLY_NATIVE = new Set(['read_file', 'search_files', 'skills_list', 'skill_view', 'skill_manage', 'clarify', 'session_search', 'todo'])
 const MAX_ATTACHMENT = 32 * 1024 * 1024
 const BUILTIN_TOOLS: ToolDescriptor[] = [
   { id: 'web_search', name: 'web_search', description: 'Search the web with the configured Hermes provider. Returns titles, URLs and snippets; use web_extract for page content.', inputSchema: { type: 'object', properties: { query: { type: 'string' }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 5 } }, required: ['query'], additionalProperties: false } },
@@ -447,13 +449,20 @@ export class EmbeddedGateway {
         writeFileSync(path, bytes, { mode: 0o600 })
         return path
       }
+      // Skills: the Profile's library (editable from native chats, shared read-only with Bots) plus a Bot's own.
+      const profileHome = pool.profileHome(session.profile)
+      const skillOwner = session.botId ?? session.profile
+      const skills = collectSkills(session.botId
+        ? [{ home: profileHome }, { home: pool.home(scope), owner: session.botId }]
+        : [{ home: profileHome, owner: session.profile }])
+      const skillHome = session.botId ? pool.home(scope) : profileHome
       const result = await runKernel({
-        workspaceId: 'yaoyao', botId: session.botId ?? session.profile, sessionId: session.id, runId: turn.id,
+        workspaceId: 'yaoyao', botId: skillOwner, sessionId: session.id, runId: turn.id,
         dataRoot: pool.home(scope), ...(pool.parent(scope) ? { hermesRoot: pool.parent(scope) } : {}),
         ...(cwd && !policy.denyHostTools && existsSync(cwd) ? { hostWorkspace: { cwd } } : {}),
         route: { provider, model, reasoningEffort: session.model?.reasoningEffort || 'default', fastMode: session.model?.fastMode ?? 'normal' },
         config: defaultKernelConfig(config), instructions: grant ? GRANT_INSTRUCTIONS : '', text: input, tools,
-        botPolicy: { enabled: true, foreground: true, version: 2 }, platform: session.source || 'web',
+        botPolicy: { enabled: true, foreground: true, version: 2 }, platform: session.source || 'web', skills,
       }, {
         signal: turn.controller.signal, control: turn.control, env: this.options.env,
         maxSeconds: this.options.maxTurnSeconds ?? 6 * 3600, waiting: () => turn.pending.size > 0,
@@ -474,6 +483,12 @@ export class EmbeddedGateway {
           const input = args && typeof args === 'object' ? args as Record<string, any> : {}
           if (name === 'yaovi_native_authorize') return this.authorize(session, turn, input)
           if (name === 'yaovi_native_check') return { allow: policy.approval !== 'deny' }
+          if (name === 'yaovi_skills_authorize') return skills.map(entry => entry.id)
+          if (name === 'yaovi_skills_load') return { entries: [] }
+          if (name === 'yaovi_skills_commit') {
+            try { return { entries: commitSkills(skillHome, skillOwner, input.changes) } }
+            catch (error) { return { error: error instanceof Error ? error.message : '技能保存失败' } }
+          }
           if (name === 'yaovi_clarify') {
             const answer = await this.ask(session, turn, 'clarify', { question: str(input.question), message: str(input.question), choices: Array.isArray(input.choices) ? input.choices.map(String) : [] })
             return typeof answer === 'string' ? answer : null

+ 2 - 0
src/server/hermes/kernel.ts

@@ -42,6 +42,8 @@ export interface KernelRequest {
   botPolicy?: { enabled: boolean; foreground: boolean; version?: 2 }
   /** Hermes session source (`web` native chats, `yaoyao_workspace` Bot sessions). */
   platform?: string
+  /** Admitted skill bundles (runtime/native_skills.py); omit to run without skills. */
+  skills?: unknown[]
   compact?: Record<string, never>
 }
 export interface KernelControl { steer?: (text: string) => Promise<boolean> }

+ 9 - 2
src/server/hermes/paths.ts

@@ -8,12 +8,19 @@ export const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..
 
 export interface KernelPaths { root: string; python: string; worker: string; service: string }
 
+/** Source checkout, npm package, esbuild bundle (runtime/ beside the bundle) or an explicit root. */
+function kernelRoot(env: NodeJS.ProcessEnv): string {
+  if (env.YAOYAO_KERNEL_ROOT) return env.YAOYAO_KERNEL_ROOT
+  const candidates = [PACKAGE_ROOT, dirname(fileURLToPath(import.meta.url)), process.cwd()]
+  return candidates.find(root => existsSync(join(root, 'runtime/worker.py'))) ?? PACKAGE_ROOT
+}
+
 export function kernelPaths(env: NodeJS.ProcessEnv = process.env): KernelPaths {
-  const root = env.YAOYAO_KERNEL_ROOT || PACKAGE_ROOT
+  const root = kernelRoot(env)
   const bundled = join(root, 'runtime/python/bin/python3')
   return {
     root,
-    python: env.YAOYAO_KERNEL_PYTHON || (existsSync(bundled) ? bundled : join(root, '.venv/bin/python')),
+    python: env.YAOYAO_KERNEL_PYTHON || (existsSync(bundled) ? bundled : join(env.YAOYAO_KERNEL_VENV || join(root, '.venv'), 'bin/python')),
     worker: env.YAOYAO_KERNEL_WORKER || join(root, 'runtime/worker.py'),
     service: env.YAOYAO_HERMES_SERVICE || join(root, 'runtime/hermes_service.py'),
   }

+ 111 - 0
src/server/hermes/skills.ts

@@ -0,0 +1,111 @@
+import { createHash } from 'node:crypto'
+import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs'
+import { dirname, join, relative, resolve, sep } from 'node:path'
+
+/**
+ * Skill admission for embedded workers (runtime/native_skills.py).
+ *
+ * Hermes skills live in `<home>/skills/<category>/<name>/SKILL.md` with supporting files. A turn
+ * receives a frozen copy of every admitted skill; successful native edits come back as a change set
+ * and are written to the owning home. `owner` marks entries the turn may modify.
+ */
+export interface SkillEntry {
+  id: string
+  revision: number
+  nativePath: string
+  content: string
+  resources: Record<string, string>
+  resourceEncodings: Record<string, 'base64'>
+  enabled: boolean
+  botId?: string
+}
+export interface SkillSource { home: string; owner?: string }
+
+const MAX_FILE = 1024 * 1024
+const MAX_SKILL = 4 * 1024 * 1024
+const MAX_SKILLS = 400
+
+function revision(content: string, resources: Record<string, string>): number {
+  return parseInt(createHash('sha256').update(content).update(JSON.stringify(resources)).digest('hex').slice(0, 8), 16)
+}
+
+function readSkill(root: string, dir: string, owner: string | undefined, prefix: string): SkillEntry | undefined {
+  const nativePath = relative(root, dir).split(sep).join('/')
+  const content = readFileSync(join(dir, 'SKILL.md'), 'utf8')
+  const resources: Record<string, string> = {}, resourceEncodings: Record<string, 'base64'> = {}
+  let total = Buffer.byteLength(content)
+  const walk = (current: string) => {
+    for (const name of readdirSync(current)) {
+      if (name.startsWith('.') || name === '__pycache__') continue
+      const path = join(current, name), info = lstatSync(path)
+      if (info.isSymbolicLink()) continue
+      if (info.isDirectory()) { if (!existsSync(join(path, 'SKILL.md'))) walk(path); continue }
+      if (!info.isFile() || path === join(dir, 'SKILL.md') || info.size > MAX_FILE || total + info.size > MAX_SKILL) continue
+      const bytes = readFileSync(path), key = relative(dir, path).split(sep).join('/')
+      const text = bytes.toString('utf8')
+      if (Buffer.from(text, 'utf8').equals(bytes)) resources[key] = text
+      else { resources[key] = bytes.toString('base64'); resourceEncodings[key] = 'base64' }
+      total += info.size
+    }
+  }
+  walk(dir)
+  return { id: `${prefix}:${nativePath}`, revision: revision(content, resources), nativePath, content, resources, resourceEncodings, enabled: true, ...(owner ? { botId: owner } : {}) }
+}
+
+/** Later sources win for the same native path (a Bot's own skill shadows its Profile's). */
+export function collectSkills(sources: SkillSource[]): SkillEntry[] {
+  const entries = new Map<string, SkillEntry>()
+  for (const [index, source] of sources.entries()) {
+    const root = join(source.home, 'skills')
+    if (!existsSync(root)) continue
+    const visit = (dir: string, depth: number) => {
+      if (depth > 4 || entries.size >= MAX_SKILLS) return
+      if (existsSync(join(dir, 'SKILL.md')) && dir !== root) {
+        try { const entry = readSkill(root, dir, source.owner, `s${index}`); if (entry) entries.set(entry.nativePath, entry) } catch { /* unreadable skill is skipped */ }
+        return
+      }
+      for (const name of readdirSync(dir)) {
+        if (name.startsWith('.')) continue
+        const path = join(dir, name)
+        try { if (lstatSync(path).isDirectory()) visit(path, depth + 1) } catch { /* skip */ }
+      }
+    }
+    visit(root, 0)
+  }
+  return [...entries.values()]
+}
+
+interface SkillChange { nativePath?: unknown; content?: unknown; resources?: unknown; resourceEncodings?: unknown; id?: unknown; expectedRevision?: unknown }
+
+/** Persist one native change set into `home/skills`; returns the committed entries. */
+export function commitSkills(home: string, owner: string, changes: unknown): SkillEntry[] {
+  if (!Array.isArray(changes)) throw new Error('Invalid skill change set')
+  const root = resolve(home, 'skills')
+  const committed: SkillEntry[] = []
+  for (const raw of changes as SkillChange[]) {
+    const nativePath = typeof raw.nativePath === 'string' ? raw.nativePath : ''
+    const dir = resolve(root, nativePath)
+    if (!nativePath || !dir.startsWith(root + sep) || nativePath.split('/').some(part => !part || part === '..' || part.startsWith('.')))
+      throw new Error('Invalid skill path')
+    if (raw.content === null || raw.content === undefined) { rmSync(dir, { recursive: true, force: true }); continue }
+    if (typeof raw.content !== 'string') throw new Error('Invalid skill content')
+    const resources = raw.resources && typeof raw.resources === 'object' ? raw.resources as Record<string, unknown> : {}
+    const encodings = raw.resourceEncodings && typeof raw.resourceEncodings === 'object' ? raw.resourceEncodings as Record<string, unknown> : {}
+    const staging = `${dir}.tmp-${process.pid}-${Date.now()}`
+    mkdirSync(staging, { recursive: true, mode: 0o700 })
+    writeFileSync(join(staging, 'SKILL.md'), raw.content)
+    for (const [name, value] of Object.entries(resources)) {
+      const target = resolve(staging, name)
+      if (typeof value !== 'string' || !target.startsWith(staging + sep)) throw new Error('Invalid skill resource')
+      mkdirSync(dirname(target), { recursive: true })
+      writeFileSync(target, encodings[name] === 'base64' ? Buffer.from(value, 'base64') : value)
+    }
+    rmSync(dir, { recursive: true, force: true })
+    mkdirSync(dirname(dir), { recursive: true })
+    // Rename keeps a half-written skill from ever being visible to a concurrent turn.
+    renameSync(staging, dir)
+    const entry = readSkill(root, dir, owner, 'local')!
+    committed.push({ ...entry, id: typeof raw.id === 'string' ? raw.id : entry.id })
+  }
+  return committed
+}

+ 16 - 3
src/server/index.ts

@@ -12,6 +12,8 @@ import { legacyDataHome, resolveDataHome } from '../../bin/lib/data-home.mjs'
 import { spawn } from 'node:child_process'
 import { DesktopActivation } from './desktopActivation.js'
 import { importLegacyHermes } from './hermes/import.js'
+import { kernelPaths } from './hermes/paths.js'
+import { prepareKernel } from '../../bin/lib/kernel-setup.mjs'
 
 migrateDataHome(resolveDataHome(process.env.YAOYAO_HOME || process.env.HERMES_YAOYAO_HOME, { preserveActiveUpdate: true }))
 const config = loadServerConfig()
@@ -25,9 +27,20 @@ process.once('exit', () => instance.release())
 const retiredHermesVariables = ['HERMES_YAOYAO_UPSTREAM', 'HERMES_YAOYAO_UPSTREAM_USERNAME', 'HERMES_YAOYAO_UPSTREAM_PASSWORD', 'HERMES_YAOYAO_UPSTREAM_PASSWORD_FILE', 'HERMES_YAOYAO_SUPERVISE_DASHBOARD', 'HERMES_YAOYAO_BRIDGE_MOUNTED', 'HERMES_YAOYAO_BRIDGE_HOME', 'HERMES_YAOYAO_BRIDGE_PYTHON'].filter(name => process.env[name])
 if (retiredHermesVariables.length) console.warn(`Hermes 已内置在夭夭中,以下变量不再生效:${retiredHermesVariables.join('、')}`)
 // First start with the embedded kernel: copy an existing ~/.hermes (read-only) into <data>/hermes.
-const hermesImport = importLegacyHermes(config.home)
-if (hermesImport.status === 'imported') console.log(`已导入原 Hermes 数据(${hermesImport.source},${hermesImport.files} 个文件)`)
-else if (hermesImport.status === 'failed') console.error(`原 Hermes 数据导入失败,内置 Hermes 将从空数据启动:${hermesImport.error}`)
+const reportImport = (result: ReturnType<typeof importLegacyHermes>) => {
+  if (result.status === 'imported') console.log(`已导入原 Hermes 数据(${result.source},${result.files} 个文件)`)
+  else if (result.status === 'failed') console.error(`原 Hermes 数据导入失败,内置 Hermes 将从空数据启动:${result.error}`)
+}
+const kernel = kernelPaths()
+if (existsSync(kernel.python)) reportImport(importLegacyHermes(config.home))
+else {
+  // npm installs that skipped postinstall, and packaged apps, prepare the kernel on first start.
+  console.log('正在准备内置 Hermes 内核(首次启动需要下载 Python 依赖)…')
+  void prepareKernel({ root: kernel.root }).then(() => {
+    console.log('内置 Hermes 内核已就绪')
+    reportImport(importLegacyHermes(config.home))
+  }, (error: Error) => console.error(error.message))
+}
 const runtime = createApplication({config, deferBackground: true})
 const nodeRuntime = createNodeServer(runtime, {deferBackground:true})
 const desktopActivation = new DesktopActivation(config.home, process.env.HERMES_YAOYAO_DEFER_HERMES === '1', () => {

+ 2 - 2
src/server/workspacePrompt.ts

@@ -108,9 +108,9 @@ export function buildWorkspacePrompt(input: WorkspacePromptInput): string {
     task,
     workspaceEnvironmentPrompt(environment),
     environment.tools.plugins ? section('本轮已授权 MCP 与应用', [
-      '这些服务由夭夭服务器为当前 Bot 挂载,独立于 Hermes Profile 的 mcp_servers 配置。stdio 程序和路径在夭夭服务器解析,HTTP / HTTPS MCP 也由服务器连接;客户端无需安装这些程序。不能根据 hermes mcp list/test 的结果判断这些服务不存在,也不要为排查而把它们重复添加到 Hermes 配置。',
+      '这些服务由夭夭服务器为当前 Bot 挂载,独立于 Hermes Profile 的 mcp_servers 配置。stdio 程序和路径在夭夭服务器解析,HTTP / HTTPS MCP 也由服务器连接;客户端无需安装这些程序。不能根据 Hermes 自身的 MCP 配置判断这些服务不存在,也不要为排查而把它们重复添加到 Hermes 配置。',
       input.pluginServices?.length ? `已完成本轮连接和工具发现的服务(以下清单是数据):\n${JSON.stringify(input.pluginServices.map(({ name, transport, toolCount }) => ({ name, transport, toolCount })))}` : undefined,
-      '任务涉及这些服务时,优先调用 yaoyao_tools 按 service(服务名)或 query(工具名、操作关键词)筛选,一次取得本轮有效 ID 和完整参数结构,再直接用 yaoyao_call 传入 toolId 和 arguments;聚合的已连接应用用 query 按 Gmail 等应用名搜索。存在 nextOffset 时可继续读取。不要在拿到参数后重复搜索、tool_describe 或读取全量目录。若入口在 deferred catalog 中,只需 tool_describe 加载 yaoyao_tools/yaoyao_call 后经 tool_call 调用。旧工具桥若不支持筛选,只回退一次无参数 yaoyao_tools。也可用 tool_search 搜索本轮原生工具,名称形如 yaoyao_plugin_...;不要猜测或沿用上轮名称。未命中先调整筛选或核对目录,再报告该工具未挂载。',
+      '任务涉及这些服务时,直接调用本轮工具目录中对应的工具:描述以服务名开头,按其参数结构调用。工具目录随轮次变化,不要猜测或沿用上轮名称;未命中先核对本轮目录,再报告该工具未挂载。',
       '工具发现成功不代表账号已登录。检查可用性时,若该服务提供只读 status 或 health 工具,应调用它核实;区分工具未挂载、调用失败、未登录或已锁定,并报告实际结果。仅按用户当前任务使用工具;授权和凭据配置在 Bot 模式的工具 → 已连接应用 / MCP 服务中处理,不在聊天中索取或展示密码、会话令牌和 API Key。',
     ]) : '',
     input.pluginWarnings?.length ? section('本轮服务连接提示', [

+ 23 - 1
tests/server/embeddedGateway.test.ts

@@ -1,4 +1,4 @@
-import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { existsSync, mkdirSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
 import { createServer, type Server } from 'node:http'
 import { tmpdir } from 'node:os'
 import { join } from 'node:path'
@@ -166,4 +166,26 @@ describe.skipIf(!kernel)('embedded Hermes gateway', () => {
     await waitFor(frames, () => hermes!.gateway.idle, 10_000).catch(() => undefined)
     expect(hermes!.gateway.running(created.session_id)).toBe(false)
   }, 180_000)
+
+  it('admits Profile skills and commits a skill created in a native chat', async () => {
+    let step = 0
+    const { channel, frames } = await setup(messages => {
+      step++
+      if (step === 1) return { call: { name: 'skills_list', arguments: {} } }
+      if (step === 2) return { call: { name: 'skill_manage', arguments: { action: 'create', name: 'release-notes', content: '---\nname: release-notes\ndescription: Write release notes.\n---\n# Release notes\nList user-visible changes.\n' } } }
+      return { content: '技能:' + messages.filter(m => m.role === 'tool').map(m => String(m.content).slice(0, 300)).join(' | ') }
+    })
+    const skill = join(home, 'hermes', 'skills', 'writing', 'weekly-report')
+    mkdirSync(skill, { recursive: true })
+    writeFileSync(join(skill, 'SKILL.md'), '---\nname: weekly-report\ndescription: Draft a weekly report.\n---\nUse the template.\n')
+    writeFileSync(join(skill, 'template.md'), '# Week')
+    const created = await channel.rpc('session.create', { profile: 'default' })
+    await channel.rpc('prompt.submit', { session_id: created.session_id, text: '有哪些技能?再建一个发布说明技能' })
+    const done = await waitFor(frames, f => f.type === 'message.complete')
+    expect(done.payload!.status).toBe('complete')
+    expect(String(done.payload!.text)).toContain('weekly-report')
+    expect(frames.some(f => f.type === 'approval.request')).toBe(false)
+    const written = join(home, 'hermes', 'skills')
+    expect(readdirSync(written, { recursive: true }).some(path => String(path).endsWith('release-notes/SKILL.md'))).toBe(true)
+  }, 180_000)
 })

+ 2 - 2
tests/server/workspace.test.ts

@@ -144,8 +144,8 @@ it('includes only the connected per-turn MCP inventory in the submitted Bot prom
   expect(services).toHaveBeenCalledOnce()
   const prompt = requests.find(frame => frame.method === 'prompt.submit')!.params.text
   expect(prompt).toContain('"name":"vaultwarden","transport":"stdio","toolCount":59')
-  expect(prompt).toContain('yaoyao_tools')
-  expect(prompt).toContain('不能根据 hermes mcp list/test 的结果判断这些服务不存在')
+  expect(prompt).toContain('直接调用本轮工具目录中对应的工具')
+  expect(prompt).toContain('不能根据 Hermes 自身的 MCP 配置判断这些服务不存在')
 })
 it('executes a structured assignment on its actual worker and leaves acceptance to its coordinator', async () => {
   const lead = store.updateAgent(owner, agent('负责人').id, { canManageTeam: true })

+ 3 - 7
tests/server/workspacePrompt.test.ts

@@ -130,16 +130,12 @@ describe('Bot prompt composition', () => {
     const text = buildWorkspacePrompt(fixture)
     expect(text).toContain('"name":"vaultwarden","transport":"stdio","toolCount":59')
     expect(text).toContain('"name":"远程服务","transport":"http","toolCount":2')
-    expect(text).toContain('tool_search')
-    expect(text).toContain('yaoyao_tools')
-    expect(text).toContain('yaoyao_call')
-    expect(text).toContain('按 service(服务名)或 query')
-    expect(text).toContain('不要在拿到参数后重复搜索')
     expect(text).not.toContain('看板')
     expect(text).toContain('不重复相同的无效调用')
-    expect(text).toContain('yaoyao_plugin_')
     expect(text).not.toContain('工具名以 plugin_ 开头')
-    expect(text).toContain('不能根据 hermes mcp list/test 的结果判断这些服务不存在')
+    expect(text).toContain('不能根据 Hermes 自身的 MCP 配置判断这些服务不存在')
+    expect(text).toContain('直接调用本轮工具目录中对应的工具')
+    expect(text).not.toContain('yaoyao_call')
     expect(text).toContain('工具发现成功不代表账号已登录')
     fixture.environment.tools.plugins = false
     expect(buildWorkspacePrompt(fixture)).not.toContain('vaultwarden')

+ 6 - 5
tests/serviceCli.test.ts

@@ -125,11 +125,13 @@ describe('hermes-yaoyao LaunchAgent plist', () => {
     expect(plist).toContain(`${join(homedir(), '.local', 'bin')}:`)
   })
 
-  it('enables Dashboard supervision by default', () => {
-    expect(launchAgentPlist()).toContain('<key>HERMES_YAOYAO_SUPERVISE_DASHBOARD</key>')
+  it('no longer configures an external Hermes Dashboard', () => {
+    const plist = launchAgentPlist({ environment: { HERMES_YAOYAO_UPSTREAM: 'http://127.0.0.1:9119', HERMES_YAOYAO_SUPERVISE_DASHBOARD: '1' } })
+    expect(plist).not.toContain('HERMES_YAOYAO_SUPERVISE_DASHBOARD')
+    expect(plist).not.toContain('HERMES_YAOYAO_UPSTREAM')
   })
 
-  it('uses 15300 without injecting credentials into 9119 startup', () => {
+  it('uses 15300 without injecting Hermes service credentials', () => {
     const plist = launchAgentPlist({ environment: {} })
 
     expect(plist).toContain('<key>HERMES_YAOYAO_PORT</key>\n      <string>15300</string>')
@@ -137,12 +139,11 @@ describe('hermes-yaoyao LaunchAgent plist', () => {
     expect(plist).not.toContain('HERMES_YAOYAO_UPSTREAM_PASSWORD')
   })
 
-  it('binds managed Web to the trusted LAN and enables local Dashboard supervision by default', () => {
+  it('binds managed Web to the trusted LAN by default', () => {
     const plist = launchAgentPlist({ environment: {} })
 
     expect(plist).toContain('<key>HERMES_YAOYAO_HOST</key>\n      <string>0.0.0.0</string>')
     expect(plist).toContain('<key>HERMES_YAOYAO_ALLOW_INSECURE_LAN</key>\n      <string>1</string>')
-    expect(plist).toContain('<key>HERMES_YAOYAO_SUPERVISE_DASHBOARD</key>\n      <string>1</string>')
   })
 
   it('keeps the managed installation on LAN even with stale loopback environment', () => {