본문으로 건너뛰기
M

dsh-codex-plus

mia-wong1016/dsh-codex-plus

이 컴퓨터에서 로그인한 Codex(ChatGPT Plus/Pro) 구독을 DSH에서 사용합니다. (1) 사이드바에 5시간·주간 사용 창, 초기화 시각, 남은 초기화 크레딧을 표시하며 원클릭 초기화는 크레딧 1개를 소비합니다. (2) 할당량을 읽을 때 llm-pi-ai에 구독 경로(openai-codex)를 등록해 Codex 모델을 선택기에 표시합니다. (3) OAuth 액세스 토큰 만료 전에 갱신해 원자적으로 기록하므로 키를 수동 교체할 필요가 없습니다. (4) 로컬 Codex 에이전트에 작업을 위임하는 codex 도구를 추가합니다. API 키 입력은 필요 없습니다.

설치

dsh plugin --profile web add github:mia-wong1016/dsh-codex-plus

README

dsh-codex-plus

用途:把你本机已经登录的 Codex(ChatGPT Plus/Pro)订阅接入 DeepSeek Harness。 它显示 5 小时窗口与一周窗口的剩余额度、重置时间与剩余重置券数量,支持选择并消耗指定重置券来重置额度; 读取额度时自动把订阅线路注册进 DSH,使 Codex 模型出现在模型选择器中;并在 access token 到期前 自动续期。无需填写任何 API key,使用的是你本机 Codex 登录已有的凭证。

平台支持:Linux 与 Windows。 Windows 会从 PATH、OpenAI Codex 官方安装目录和 npm 命令垫片中定位 CLI。

中文更新记录:CHANGELOG.zh.md

English: use your Codex (ChatGPT Plus/Pro) subscription inside DeepSeek Harness

用途

  1. 看得见订阅额度 —— 侧边栏 Codex 胶囊与面板显示两个窗口的剩余额度与重置券;
  2. 能用订阅的模型 —— 读额度时自动注册 openai-codex 路由,模型出现在模型选择器;
  3. 能指定重置券 —— 面板逐张列出可用券并单选,按钮只消耗所选券,重置 5 小时 + 一周窗口;
  4. 凭证自动续期 —— token 剩余不足 24 小时时自动续期并原子写回。

中文详解(功能明细、面板路由、安装与配置、安全边界)见 README.zh.md。


English

Use your Codex (ChatGPT Plus/Pro) subscription inside DeepSeek Harness.

It reads the quota of the Codex account you are already signed in to on this machine, shows it in the UI, exposes the subscription's models to DSH's model picker, and can spend a specifically selected rate-limit reset credit.

What it does

Quota panel

  • A Codex chip in the sidebar footer: remaining 5-hour window, remaining weekly window, and how many reset credits are left (collapses to the percentage when the sidebar is in rail mode).
  • Click it for a panel with both windows (used %, reset time) and every reset credit with its expiry date.
  • Selected-credit reset spends the reset credit selected with the radio control and resets the 5-hour + weekly windows. The button is disabled when no credit is available, and the outcome is reported (reset / nothingToReset / noCredit / alreadyRedeemed). This consumes a real credit and cannot be undone.

Model routing

Reading the quota also registers the subscription route in the llm-pi-ai settings namespace, so the Codex models appear in DSH's model picker:

llm-pi-ai:
  providers:
    openai-codex:
      apiKeyEnv: OPENAI_CODEX_API_KEY
      displayName: Codex (ChatGPT Plus/Pro)
      baseURL: https://chatgpt.com/backend-api

Only that provider entry is replaced through settingsController.mutate(). No fixed settings-file path is assumed, and every other provider remains untouched. The profile declares the complete eight-model catalog, including gpt-6-luna and gpt-6-sol.

Token upkeep

The access token is refreshed against auth.openai.com when it has less than 24 hours left, and the rotated access_token / refresh_token / id_token triple is written back to auth.json atomically; POSIX systems additionally enforce mode 0600, while Windows keeps the profile ACL. The current access token is stored in DSH's credential store under the reference name above, so settings.yaml never holds a secret.

Panel transport

The browser half talks to the host half over this plugin's own same-origin routes — GET /codex-plus/status, POST /codex-plus/sync, POST /codex-plus/reset (JSON body: { "creditId": "…" }) — which the DSH web server already protects with its browser-session policy. No new RPC channel and no token in the page are involved.

Delegation tool

codex hands a self-contained task to the local Codex agent and returns its final answer — useful for a second opinion, a fresh-context review, or an independent subtask.

ToolPurpose
codexRun a task through codex exec and return the answer
codex_quotaRead the quota and re-sync the provider route
codex_models_syncRefresh the token and re-register the models now
codexprobeDiagnostics: resolved CLI, Codex home, cached catalog, quota read

Requirements

  • Linux and Windows are supported.
  • A Codex CLI on this machine that is already signed in with a ChatGPT account (codex login); its login lives in <codexHome>/auth.json.
  • The CLI lookup order is DSH_CODEX_BIN, the established Linux locations, PATH, then Windows fallbacks under %LOCALAPPDATA%\OpenAI\Codex\bin\<hash>\codex.exe and %APPDATA%\npm\codex.cmd|exe. A real .exe is preferred over command shims.
  • The Codex home is DSH_CODEX_HOME, else ~/.codex on both platforms.
  • Node 20 or newer. No Python, no extra npm dependency.

Install

dsh plugin --profile web add dsh-codex-plus

Then restart the profile and refresh the page. Switch the conversation's model to Codex (ChatGPT Plus/Pro) to use the subscription for that session.

Configuration

All keys are optional.

- id: codex-plus
  name: 'dsh-codex-plus'
  config:
    codexBin: /usr/local/bin/codex        # explicit CLI path
    codexHome: ~/.codex                   # explicit CODEX_HOME
    workspace: /path/to/workspace         # shell sandbox root (default: process cwd)
    providerRoute: openai-codex           # pi-ai catalog route to configure
    providerDisplayName: Codex (ChatGPT Plus/Pro)
    credentialRef: OPENAI_CODEX_API_KEY   # credential-store reference name
    syncProviders: true                   # set false to skip the settings write entirely
    sandboxPolicy: true                   # false disables the workspace-write policy

Set syncProviders: false if you only want the quota panel and would rather wire the provider yourself.

Security

  • No credentials are bundled, and none are logged. The plugin reads the token your own Codex login already wrote to auth.json.
  • The token value goes to DSH's credential store; settings.yaml only carries the reference name OPENAI_CODEX_API_KEY.
  • auth.json is only ever written with the refreshed triple, atomically, at mode 0600.
  • The reset action requires an explicit confirmation argument and an available credit.
  • The panel routes are readable by any caller that already holds a valid DSH web session (they are behind the same browser-session policy as the rest of the web UI); they expose the quota, the plan type, and the account email, not the token.
  • codex exec runs with the sandbox you pass to the codex tool (read-only by default). Note that running Codex inside a sandbox that already blocks user namespaces can make Codex's own workspace-write sandbox fail; danger-full-access then defers to DSH's own sandbox, which is the safer pairing.

Licence

MIT

관련 플러그인