修复: Profile clone 时智能清理独占平台凭据 + 平台设置独占警告#283
Merged
Merged
Conversation
# 问题 `hermes profile create <name> --clone` 完整复制 .env + config.yaml(含独占型平台凭据 如 WEIXIN_TOKEN / TELEGRAM_BOT_TOKEN 等),导致多个 profile 共享同一身份 token。 hermes-agent 在 platform adapter 初始化或 scoped lock 获取阶段失败,gateway 健康检查 持续 15s 超时,前端报 'API Error 500: Gateway health check timed out'。 # 修复 在 web-ui 后端 clone 完成后自动: 1. 从 <profile>/.env 删除匹配独占平台的环境变量(写 .env.bak.* 备份) 2. 在 <profile>/config.yaml 中把 platforms.<exclusive>.enabled 置为 false 3. 清理节点直挂 + extra 子节点下的敏感字段(token / app_secret / account_id 等) 前端 toast 提示被剥离的凭据、被禁用的平台、被剥离的 config 字段,便于用户后续手动 重新填入新身份再启用。 # EXCLUSIVE_PLATFORMS 列表来源 精确对齐 hermes-agent gateway/platforms/*.py 中调用 _acquire_platform_lock 的 7 个 adapter: telegram, discord, slack, whatsapp, signal, weixin, feishu。 未来上游加新独占平台时用 `grep -l _acquire_platform_lock gateway/platforms/*.py` 验证。 # 测试 新增 tests/server/profile-credentials.test.ts(12 用例全过),覆盖: - isExclusivePlatformKey 命中/未命中边界 - env 文件剥离 + 备份 - config.yaml 平台禁用 + 节点凭据清理 - 已 disabled 平台仍清理残留凭据(防止后续 re-enable 复用旧身份) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
在 PlatformSettings 中为使用 token 互斥锁的 6 个平台 (telegram, discord, slack, whatsapp, feishu, weixin) 添加视觉警告,提示用户每个 profile 必须使用不同的身份 token,避免与其他 profile 冲突。 # 背景 hermes-agent 的 acquire_scoped_lock 是 token-level(不是 platform-level),所以 设计上支持多 profile 各自配不同身份的同一平台(如 default 用个人微信、staging 用公司微信)。但用户从 UI 配置时容易误填同一 token,导致 gateway 启动失败。 # 实现 - PlatformCard 新增 exclusive 可选 prop,开启时 body 顶部用 NAlert (warning) 展示提示 - PlatformSettings 在 6 个独占平台数组项标记 exclusive: true 并传给 PlatformCard - 8 个 i18n locale 新增 platform.exclusiveTokenWarning 翻译 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
xinke666
pushed a commit
to xinke666/hermes-web-ui
that referenced
this pull request
May 23, 2026
ifsherlock
pushed a commit
to ifsherlock/hermes-web-ui
that referenced
this pull request
Jun 10, 2026
* 修复: profile clone 时智能清理独占平台凭据,避免 gateway 健康检查超时 # 问题 `hermes profile create <name> --clone` 完整复制 .env + config.yaml(含独占型平台凭据 如 WEIXIN_TOKEN / TELEGRAM_BOT_TOKEN 等),导致多个 profile 共享同一身份 token。 hermes-agent 在 platform adapter 初始化或 scoped lock 获取阶段失败,gateway 健康检查 持续 15s 超时,前端报 'API Error 500: Gateway health check timed out'。 # 修复 在 web-ui 后端 clone 完成后自动: 1. 从 <profile>/.env 删除匹配独占平台的环境变量(写 .env.bak.* 备份) 2. 在 <profile>/config.yaml 中把 platforms.<exclusive>.enabled 置为 false 3. 清理节点直挂 + extra 子节点下的敏感字段(token / app_secret / account_id 等) 前端 toast 提示被剥离的凭据、被禁用的平台、被剥离的 config 字段,便于用户后续手动 重新填入新身份再启用。 # EXCLUSIVE_PLATFORMS 列表来源 精确对齐 hermes-agent gateway/platforms/*.py 中调用 _acquire_platform_lock 的 7 个 adapter: telegram, discord, slack, whatsapp, signal, weixin, feishu。 未来上游加新独占平台时用 `grep -l _acquire_platform_lock gateway/platforms/*.py` 验证。 # 测试 新增 tests/server/profile-credentials.test.ts(12 用例全过),覆盖: - isExclusivePlatformKey 命中/未命中边界 - env 文件剥离 + 备份 - config.yaml 平台禁用 + 节点凭据清理 - 已 disabled 平台仍清理残留凭据(防止后续 re-enable 复用旧身份) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * feat(平台设置): 独占平台显示 token 隔离警告 在 PlatformSettings 中为使用 token 互斥锁的 6 个平台 (telegram, discord, slack, whatsapp, feishu, weixin) 添加视觉警告,提示用户每个 profile 必须使用不同的身份 token,避免与其他 profile 冲突。 # 背景 hermes-agent 的 acquire_scoped_lock 是 token-level(不是 platform-level),所以 设计上支持多 profile 各自配不同身份的同一平台(如 default 用个人微信、staging 用公司微信)。但用户从 UI 配置时容易误填同一 token,导致 gateway 启动失败。 # 实现 - PlatformCard 新增 exclusive 可选 prop,开启时 body 顶部用 NAlert (warning) 展示提示 - PlatformSettings 在 6 个独占平台数组项标记 exclusive: true 并传给 PlatformCard - 8 个 i18n locale 新增 platform.exclusiveTokenWarning 翻译 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题 / Problem
hermes profile create <name> --clone完整复制源 profile 的.env+config.yaml(含独占型平台凭据如WEIXIN_TOKEN/TELEGRAM_BOT_TOKEN),导致多个 profile 共享同一身份 token。hermes-agent 在 platform adapter 初始化或 scoped lock 获取阶段失败,gateway 健康检查持续 15s 超时:hermes profile create <name> --clonecopies the source profile's.env+config.yamlverbatim (including exclusive platform credentials likeWEIXIN_TOKEN/TELEGRAM_BOT_TOKEN), causing multiple profiles to share the same identity token. hermes-agent fails during platform adapter initialization or scoped lock acquisition, and the gateway health check times out after 15s:根因 / Root Cause
hermes-agent 的
acquire_scoped_lock()实现了 token 级别的互斥锁(gateway/status.py),防止同一 bot token 被多个 gateway 实例同时使用。--clone完整复制凭据后,新旧 profile 持有完全相同的 token → 后启动的 gateway 必然 lock 失败。hermes-agent's
acquire_scoped_lock()implements token-level mutual exclusion (gateway/status.py), preventing the same bot token from being used by multiple gateway instances simultaneously. After--clonecopies credentials verbatim, both profiles hold the exact same token → the later gateway inevitably fails the lock.受影响的 7 个平台 / Affected platforms (all call
_acquire_platform_lockingateway/platforms/*.py):telegram, discord, slack, whatsapp, signal, weixin, feishu
修复方案 / Fix
1. 后端:智能克隆清理 / Backend: Smart Clone Cleanup (
profile-credentials.ts)clone 完成后自动 / Automatically after clone:
<profile>/.env删除匹配独占平台的环境变量(写.env.bak.*备份)/ Strip exclusive platform env vars from.env(backup to.env.bak.*)<profile>/config.yaml中把platforms.<exclusive>.enabled置为false/ Setplatforms.<exclusive>.enabledtofalseinconfig.yamlextra子节点下的敏感字段(token / app_secret / account_id 等)/ Strip sensitive credential fields from platform nodes and theirextrasub-nodes2. 前端 toast 通知 / Frontend Toast Notification
clone 完成后 toast 显示清理摘要 / Toast displays cleanup summary after clone:
3. 平台设置独占警告 / Platform Settings Exclusive Warning
在 PlatformSettings 中为 6 个独占平台卡片顶部添加 NAlert 警告 / Added NAlert warning at top of 6 exclusive platform cards in PlatformSettings:
EXCLUSIVE_PLATFORMS 列表来源 / List Source
精确对齐 hermes-agent 源码
gateway/platforms/*.py中调用_acquire_platform_lock的 7 个 adapter。Precisely aligned with the 7 adapters in hermes-agent's
gateway/platforms/*.pythat call_acquire_platform_lock.验证方法 / Verification:
grep -l _acquire_platform_lock ~/.hermes/hermes-agent/gateway/platforms/*.py测试 / Tests
新增
tests/server/profile-credentials.test.ts(12 用例全过)/ Added 12 test cases (all passing):isExclusivePlatformKey命中 / 未命中边界 / hit/miss boundary cases (including removed aliases wechat/lark/line).env文件剥离 + 备份 /.envstripping + backupconfig.yaml平台禁用 + 节点凭据清理 /config.yamlplatform disable + credential stripping复现步骤 / Reproduction Steps (before fix)
.env配置WEIXIN_TOKEN等独占凭据并启动 gateway / ConfigureWEIXIN_TOKENetc. in default profile.envand start gatewayAPI Error 500: Gateway health check timed out after 15000ms相关 / Related
文件变更 / File Changes
packages/server/src/services/hermes/profile-credentials.tspackages/server/src/controllers/hermes/profiles.tspackages/client/src/api/hermes/profiles.tspackages/client/src/stores/hermes/profiles.tspackages/client/src/components/hermes/profiles/ProfileCreateModal.vuepackages/client/src/components/hermes/settings/PlatformCard.vuepackages/client/src/components/hermes/settings/PlatformSettings.vuepackages/client/src/i18n/locales/*.tstests/server/profile-credentials.test.ts