DSH Hub

yequ172672/dsh-codex-subscription

dsh-llm-codex

BundleWorkflow15 GitHub stars· updated 2026-08-17

DSH plugin: reuse your Codex CLI local subscription login to use ChatGPT subscription models in DeepSeek Harness, no API key required

Install

npx @deepseek-ai/dsh plugin --profile web add dsh-session-import-codex

Restart `dsh web` after install. Bundle APIs can change during the developer preview.

README badge

dsh-llm-codex DSH Hub badge
[![DSH Hub](https://dshhub.dev/badge/yequ172672-dsh-codex-subscription.svg)](https://dshhub.dev/plugins/yequ172672-dsh-codex-subscription)

Paste this into your README. The star count updates with every catalog sync.

From the README

Excerpt from yequ172672/dsh-codex-subscription, cleaned of badges and images.

dsh-llm-codex

📦 已发布到 npm:[email protected] · 📚 GitHub:yequ172672/dsh-codex-subscription · 🏷️ 属于 dsh-plugin 插件话题

DSH(DeepSeek Harness)LLM 适配器插件:直接复用 Codex CLI 的本地登录凭证,在 DSH 中 使用 ChatGPT 订阅模型(gpt-5.6-sol 等),不需要 API Key。

这是一个标准的 dsh 插件包:包内 dsh.bundle.patch 声明使其成为 profile 层, 通过官方 dsh plugin 命令安装后自动激活,无需手工编辑任何 composition 文件。

搭配推荐:dsh-session-import-codex

配合 dsh-session-import-codex 使用 效果更佳:它把 Codex 的历史会话导入 DSH(会话 id 形如 codex-<thread-id>),与本插件的 "凭证/模型复用"互补 —— 在 DSH 里既能用 Codex 订阅模型对话,又能无缝续聊 Codex 里 开过的对话,实现"模型 + 历史"全链路打通。

dsh plugin --profile web add dsh-session-import-codex
# 迁移(离线流程:先停止 dsh web 进程 → dry-run → 正式导入 → 重启 dsh)
pnpm --dir "$env:USERPROFILE\.dsh\profiles\web" exec dsh-import-codex --profile web --dry-run
pnpm --dir "$env:USERPROFILE\.dsh\profiles\web" exec dsh-import-codex --profile web

ℹ️ [email protected] 起已正确声明全部依赖,直接安装即可。

原理

Codex CLI(codex login)会把 ChatGPT 订阅的 OAuth 令牌写入 ~/.codex/auth.json(或 CODEX_HOME)。本插件与 codex CLI 同源读取该文件,并参照两个成熟实现 (参考实现:你的 oh-my-pi-cnopencodex)的 wire 细节:

凭证形态端点认证
tokens(auth_mode: chatgpt,订阅)https://chatgpt.com/backend-api/codex/responsesAuthorization: Bearer <access_token> + chatgpt-account-id + OpenAI-Beta: responses=experimental + originator: pi + version
OPENAI_API_KEY(auth_mode: apikey)https://api.openai.com/v1/responsesAuthorization: Bearer <api_key>
  • 凭证热跟随:每次请求都重新读 auth.json,CLI 登录/换号/登出,DSH 下一次请求自动生效。
  • 令牌刷新:access_token 过期(HTTP 401)时用 refresh_tokenauth.openai.com/oauth/token 刷新并自动重试一次;刷新成功后默认原子写回 auth.json(writeBack: false 可关闭),与 codex CLI 行为一致,两边凭证永远同步。
  • 模型目录:优先实时拉取 GET {base}/codex/models,失败时回退 ~/.codex/models_cache.json,再回退内置静态列表。
  • 协议:OpenAI Responses API(stream: true SSE),推理摘要、正文、工具调用分别映射为 DSH 的 reasoning / text / tool-call 块,usage 从 response.completed 提取。

目录结构

lib/
  index.js      插件入口(注册 provider "codex" + 可配置 provider 目录 + 设置段)
  adapter.js    CodexAdapter:fetch + SSE → StreamChunk(仿 dsh-llm-deepseek)
  auth.js       auth.json 读取 / 订阅令牌刷新 / 原子写回
  serialize.js  harness 消息 → Responses API 请求体
  translate.js  Responses SSE 事件 → StreamChunk
  sse.js        SSE 字节流解析(Responses 协议无 [DONE])
  models.js     模型目录:实时发现 → models_cache.json → 静态兜底
  transport.js  可选 HTTP CONNECT 代理(https-proxy-agent + node-fetch)
  constants.js  wire 常量(端点/头/上下文窗口)
cordis.bundle.yml   dsh.bundle 声明的 profile 层(插件行;安装后自动挂载)
test/serialize.mjs  请求序列化单元测试
test/smoke.mjs      端到端冒烟测试(只读,绝不写 auth.json)

安装(dsh 官方插件命令)

前置条件

  1. 已安装 dsh 本体(本插件是 dsh 的 profile 层,必须先有 dsh):
    npm install -g @deepseek-ai/dsh
    dsh --version   # 确认命令可用
    

    若提示 无法将"dsh"项识别为 cmdlet… / dsh: command not found, 说明 dsh 尚未安装或不在 PATH,与插件无关。

  2. 已安装 pnpm(dsh plugin 会转发给它;缺失时 CLI 会提示)。
  3. 已登录 Codex CLI:codex login(插件直接复用其凭证,无需 API Key)。
  4. 能访问 chatgpt.com(国内网络通常需要代理,见下文"机器相关配置")。

安装插件

安装已发布的包:

dsh plugin --profile web add dsh-llm-codex

本地开发直接加路径(pnpm 会以 link: 链接,改动即时生效):

dsh plugin --profile web add D:\CODE\dsh\dsh-llm-codex

Related plugins