前言¶
在 DeepSeek Harness 里使用 Codex 模型时,一个具体问题是:既要接入 openai-codex 模型路由,又不希望把完整 OAuth 凭据放到普通文件里。dsh-codex-keychain 是一个非官方、独立的 DSH 插件,用来处理这个场景:它为 DSH 添加 openai-codex 模型路由,并将完整 OAuth 凭据保留在操作系统的原生凭据存储中。
这是什么¶
dsh-codex-keychain 由 CpfPatrick 维护,许可证为 MIT。当前 0.1.0-alpha.1 是 developer preview,面向 DeepSeek Harness 0.1.0-rc.6 和 @earendil-works/pi-ai 0.82.1。
它不使用 OpenAI Platform API key,不使用 fallback 明文凭证文件,也不复用 ~/.codex/auth.json。该包只连接面向有资格 ChatGPT 账户开放的 Codex backend,并且与 OpenAI、DeepSeek 无隶属或背书关系。
核心功能¶
下面介绍已核实的能力:
- 添加
openai-codex模型路由。 - 将完整 OAuth 凭据保存在操作系统原生凭据存储中:
- macOS Keychain
- Windows Credential Manager
- Linux Secret Service
- 支持 browser ChatGPT OAuth 和 device-code ChatGPT OAuth。
- 支持 automatic locked token refresh。
- 提供 Codex model catalog 和 DSH model-picker 集成。
- 支持 DSH-native streaming、reasoning、tool calls、replay,以及已有 DSH image attachments/model vision。
- 提供专属 Web settings page 和 headless CLI。
status --json只包含 sign-in state、provider、platform、backend;失败时包含 stable code 和 safe message,不包含 tokens、account IDs 或 token timestamps。
安装与启用¶
先安装到指定 DSH profile:
dsh plugin --profile web add dsh-codex-keychain@next
启动 Web 端:
dsh web
接着在 Web 设置中完成登录:
1、打开 Settings → OpenAI Codex。
2、选择 Sign in with browser。
3、点击 Open authorization page,并完成 OpenAI 授权。
4、登录完成后,在 DSH 的 model picker 里选择 openai-codex 模型。
该插件不会修改默认模型;需要手动选择对应模型。
典型用法¶
浏览器不可用、需要 headless 主机、或 localhost callback 无法绑定时,可以用 CLI 登录:
dsh plugin --profile web exec dsh-codex-keychain login
dsh plugin --profile web exec dsh-codex-keychain login --device-code
查看状态:
dsh plugin --profile web exec dsh-codex-keychain status
dsh plugin --profile web exec dsh-codex-keychain status --json
退出登录:
dsh plugin --profile web exec dsh-codex-keychain logout
卸载前如需移除原生凭据,可先执行 logout,再移除插件:
dsh plugin --profile web exec dsh-codex-keychain logout
dsh plugin --profile web remove dsh-codex-keychain
安全与边界¶
这个插件的边界比较明确:
- 它面向 ChatGPT OAuth,不面向 OpenAI Platform API key。ChatGPT subscription access 与 OpenAI Platform API access 是不同产品。
- 它只连接面向有资格 ChatGPT 账户开放的 Codex backend。
- 如果原生凭据存储缺失、locked 或 unavailable,插件会报告
KEYCHAIN_UNAVAILABLE并拒绝登录,不做普通文件 fallback。 - Web authentication RPC 是 loopback-only;remote browsers 不能调用 authentication RPC。
- OAuth URLs 和 device codes 是 transient 的,插件不会写入 application logs 或 persistent storage。
- 浏览器回调使用
localhost端口1455。 - 刷新失败或不完整登录不会替换之前保存的凭据。
- 它不包含 quota displays、web search、standalone image-viewing UI 或 image generation。
已知 alpha limitation:当前请求不能取消因网络停滞导致的 token refresh。
适用场景与注意¶
适合以下情况:
- 希望在 DSH 中使用
openai-codex模型路由。 - 希望通过 ChatGPT OAuth 登录,而不是 OpenAI Platform API key。
- 希望凭据保存在操作系统原生凭据存储中,而不是明文文件。
- 需要 Web settings page 或 headless CLI 登录。
使用注意:
- 当前 alpha 固定面向 DSH
0.1.0-rc.6;升级 DSH 前需要注意兼容性。 - 运行要求 Node.js
^22.19 || >=24和 pnpm11.7.0。 - 插件以当前 dsh 进程权限运行;安装前应检查源码、许可证和依赖。
- CLI 登录时可能显示 OAuth URL 或 device code,这类输出属于临时凭据信息,不应分享或截屏传播。
链接¶
GitHub:https://github.com/CpfPatrick/dsh-codex-keychain