# Hermes 多 Profile 登录凭证集中化

更新时间：2026-05-16T15:48:37+0800

## 当前结论

bot1 上 Hermes 多 profile 的 OpenAI Codex / ChatGPT OAuth 登录凭证集中维护：

```text
机器: bot1deMac-mini.local / 192.168.1.10
Hermes home: /Users/bot1/.hermes
中心目录: /Users/bot1/.hermes/shared-auth
中心文件: /Users/bot1/.hermes/shared-auth/openai-codex-auth.json
目录权限: 700
文件权限: 600
```

各 profile 的 `auth.json` 应是 symlink：

```text
/Users/bot1/.hermes/auth.json -> /Users/bot1/.hermes/shared-auth/openai-codex-auth.json
/Users/bot1/.hermes/profiles/<profile>/auth.json -> /Users/bot1/.hermes/shared-auth/openai-codex-auth.json
```

## 维护规则

1. 新建 bot1 profile 默认链接中心 `auth.json`，不要复制多份 `auth.json`。
2. 排查登录问题时，先检查 symlink，再运行 `hermes -p <profile> auth status openai-codex`。
3. 如果某 profile 必须使用独立 Codex/ChatGPT 账号，需用户明确批准后再移除该 profile 的 symlink 并单独登录。
4. 不打印、不复制、不写入 NAS/Git/Skill/Memory 的 `auth.json` 正文。
5. 写入或迁移 profile 前，先执行 `新机器人创建机器预检规则.md`。

## 不参与集中化的内容

Feishu/Lark app 身份必须 profile 独立，禁止跨 profile 复制：

- `FEISHU_APP_ID`
- `FEISHU_APP_SECRET`
- `FEISHU_APP_VERIFICATION_TOKEN`
- `FEISHU_APP_ENCRYPT_KEY`
- `LARK_*`
- pairing / approved user 状态
- gateway 连接状态

原因：Feishu/Lark app 凭证代表具体机器人身份；混用会导致多个 profile 抢同一个 bot/websocket。

## 新建 profile 默认片段

```bash
p=<profile-name>
central=/Users/bot1/.hermes/shared-auth/openai-codex-auth.json
profile_home=/Users/bot1/.hermes/profiles/$p

mkdir -p /Users/bot1/.hermes/shared-auth
chmod 700 /Users/bot1/.hermes/shared-auth
chmod 600 "$central"
[ -e "$profile_home/auth.json" ] && mv "$profile_home/auth.json" "$profile_home/auth.json.backup.$(date +%Y%m%d_%H%M%S)"
ln -s "$central" "$profile_home/auth.json"
hermes -p "$p" auth status openai-codex
```
