Vai al contenuto principale
C

dsh-siwc-native

calisweetleaf/dsh-siwc-native

Native Sign in with ChatGPT provider for DeepSeek Harness (Cordis). OAuth, live model discovery, Responses streaming, reasoning replay and cache affinity.

Installazione

dsh plugin --profile web add github:calisweetleaf/dsh-siwc-native

README

English | 简体中文

dsh-chatgpt-siwc

Your own ChatGPT plan inside DeepSeek Harness, over the official Sign in with ChatGPT route

npm version License Node DSH Tests Prompt cache

Wiki GitHub repository XERJ Corpus Hub contributor

Why this route

This section says what the plugin is and why the route it takes matters. dsh-chatgpt-siwc lets DeepSeek Harness (DSH) serve model calls from your own ChatGPT Plus/Pro plan, and it gets there the way OpenAI documents it: Sign in with ChatGPT (SIWC) with dynamic OAuth registration, then the public Responses API at https://api.openai.com/v1, authenticated with the SIWC token issued to you for this app.

This is not a ChatGPT wrapper, and it is not a Codex API auth call. It is the official Sign in with ChatGPT route, end to end: dynamic OAuth registration, then the public Responses API with the token issued to this app. It does not replace Codex, and it does not replace ChatGPT. It is something new entirely — your own plan, reached directly. Decentralized by design: no relay, no pooled account, no central credential. Every user signs in with their own account, and that account's token only ever travels with that account's requests.

As far as I can tell from the plugins listed in awesome-deepseek-harness, this is the only DSH plugin on that official route. The other subscription and OAuth plugins there go through the Codex backend or read the local Codex credentials. This one does neither:

  • It never calls chatgpt.com/backend-api/codex.
  • It never reads or writes ~/.codex/auth.json, and never uses the Codex CLI's app_EMoam… client.
  • It never routes through a sub2api relay or a pooled account. Requests go from the adapter straight to the public API with the signed-in account's own token.

What you get is deliberately small: one LLM provider route (siwc-dsh-core), one settings card, one discovery tool (siwc_discover), and one CLI. DSH stays the host; nothing here wraps, forks, or launches it.

Cache evidence

Because the plan route runs with store: false, every request re-sends the whole conversation, so prompt caching decides whether long sessions are practical. These are the numbers I measured in live DSH sessions, as recorded in the 2.2.0 changelog and the Wiki:

dsh-chatgpt-siwc 2.2.0  live DSH sessions, api.openai.com/v1/responses

session   tokens        cached        uncached   cache hit
A         10,353,568    -             -          98%
B         17,641,483    17,071,616    491,419*   96.8%

2.2.0 mid-session switch probe (scripts/probe-v220.mjs, gpt-6.2-astra / gpt-6.2-sol)
turn 1    default                      4,135 in        0 cached   cold start
turn 2    default                      4,159 in    2,176 cached   52.32% warm
turn 3    serviceTier -> priority      4,183 in        0 cached   cold
turn 4    model -> gpt-6.2-sol         4,207 in        0 cached   cold

* Session B: 96.8% is 17,071,616 cached of 17,641,483 total input tokens, the authoritative figure. The recorded uncached count, 491,419, does not reconcile: cached + uncached = 17,563,035, 78,448 short of the total. That gap is unexplained; no per-request log is committed, so it cannot be traced. Session A has no recorded cached/uncached breakdown.

Four things in the wire builder (siwc-core) make those hits land:

  1. One cache key, sent twice. The session-id request header carries the same value as the body's prompt_cache_key, so routing affinity and the cache key agree.
  2. The system prompt stays in history. With systemPromptUpdate: 'in-history', a changed system prompt is appended in place as a developer item instead of rewriting the prefix.
  3. Encrypted reasoning is replayed per account and model, so earlier turns keep the exact bytes the cache saw.
  4. store: false on every request. Nothing is kept server-side; the stable prefix is the whole mechanism.

Nothing from catalog metadata, serviceTier, contextBudget, modelOverrides, or usage telemetry is ever written into instructions or input. The probe also shows the cost of changing course: switching model or serviceTier mid-session starts that turn on a cold cache. The card's Cache Hit % is cacheReadTokens / (inputTokens + cacheReadTokens), so you can watch your own number. A same-task A/B against the Codex CLI has not been run, so I make no comparison.

Install

This section gets the plugin into DSH. You need Node ^22.19.0 || >=24.0.0 and DeepSeek Harness >=0.2.2-rc.1 <0.3.0.

From the web client: Plugins, install by package name, Git URL, tarball, or local path, restart when DSH asks, open the plugin's card, then Sign in with ChatGPT.

From a terminal (the profile must come before the pnpm arguments):

dsh plugin --profile web add dsh-chatgpt-siwc              # from npm
dsh plugin --profile web add ./dsh-chatgpt-siwc-2.3.0.tgz  # from a packed tarball
dsh plugin --profile web why dsh-chatgpt-siwc              # inspect linkage and resolved version
dsh web --dump-config                                      # confirm the siwc-dsh-core route config

Install the npm package or a packed tarball, not a source directory: the published lib/ needs no build step on the host, and the private siwc-core engine ships inside the tarball through bundleDependencies. dsh plugin runs pnpm, so if it fails with spawn pnpm ENOENT, enable it with corepack enable pnpm. A stale copy of this package elsewhere on Node's module path can shadow the installed one; the plugin logs dsh-chatgpt-siwc <version> loaded from <path> at startup, and dsh-chatgpt-siwc doctor prints the same, so check it after every install.

Bundle patch and development install

The bundle patch (cordis.patch.yml, referenced from package.json as dsh.bundle.patch) inserts one row:

- insert:
    - id: dsh-chatgpt-siwc
      name: dsh-chatgpt-siwc
      config:
        provider: siwc-dsh-core
        agentNameHint: DSH SIWC

Working from source:

git clone https://github.com/calisweetleaf/dsh-siwc-native.git
cd dsh-siwc-native
npm ci
npm run typecheck
npm test                 # build, then vitest

Sign-in

This section explains what happens when you press Sign in with ChatGPT or run dsh-chatgpt-siwc login. Signing in alone enables nothing: model calls need the plan-usage scope chatgpt.tokens.use.direct in the account's granted scopes, and per-app caps are yours to manage in ChatGPT settings.

  1. Dynamic registration. The first sign-in starts with client_id=dynamic_agent_client, this host's stable ext_agent_host_id, and an agent_name_hint. The callback returns an oaiapp_… client id, saved with the account before the one-time code exchange, so a retry reconnects the same app instead of registering another one.
  2. Authorization code with PKCE (S256) against a loopback listener at http://127.0.0.1:<port>/auth/callback, with a fresh state and nonce each attempt.
  3. Code exchange with resource=https://api.openai.com/v1 and no client secret.
  4. ID-token verification against JWKS, issuer, audience, and nonce. Granted scopes, not identity, decide whether plan usage is on.
  5. Refresh is standard OAuth, serialized per account, with rotating tokens replaced atomically. Sign-out revokes at the discovery document's revocation endpoint, then clears local tokens.
Network, storage, and failure reporting

Endpoints come from the OIDC discovery document (https://auth.openai.com/.well-known/openid-configuration), with the documented production values as fallback. The machine running the plugin must reach auth.openai.com (discovery, token, JWKS, and the revocation endpoint discovery names) and api.openai.com, or the configured apiBaseUrl, for models and Responses. The browser used for sign-in must run on the same machine as DSH, because the callback is on 127.0.0.1.

Every control-plane fetch is bounded, and the held loopback page has its own deadline, so no sign-in can hang a tab. The tab stays open until the flow validates and lands on the outcome itself. If sign-in stops, the card names the step it stopped at (for example exchanging the approval for access) with a machine code, and the host log carries the same line.

Accounts live under the Harness home in chatgpt-siwc/accounts.json (0600, directory 0700), next to a non-secret host.json that holds the stable host id. Writes are atomic and cross-process locked, so a rotating refresh token cannot be spent twice by two processes.

Configuration

This section lists the keys you can change from the card or the bundle config. Config fields are volatile: a committed change applies without a restart, and renaming provider re-registers the route atomically.

KeyDefaultEffect
serviceTier'default''default' omits service_tier entirely. 'priority' requests the Fast tier (2x speed when the model's catalog discloses it) and may use ChatGPT plan usage faster. Sent only when the catalog lists priority and the model is not flagged unsupported; one 400 naming service_tier drops it and retries once.
contextBudgetunsetGlobal positive-integer token cap, clamped so it never exceeds the model's catalog contextWindow.
includeHiddenModelsfalseShows visibility: 'hide' chat models. The utility slugs codex-auto-review and gpt-reserve stay hidden unless listed in modelOverrides.
modelOverridesunsetPer-model { contextWindow?, efforts? }. Wins over contextBudget, still clamped to the catalog contextWindow.
reasoningEffortunsetDefault effort when a call names none. An unsupported default is omitted; an explicit per-request effort stays strict.
apiBaseUrlhttps://api.openai.comOnly https://api.openai.com or a loopback host is accepted.
streamIdleTimeoutMs300000Byte-idle watchdog for the stream, and the same budget for waiting on HTTP headers.
storePathHarness home chatgpt-siwc/accounts.jsonAccounts file override.

Efforts and their descriptions come from the selected model's catalog entry; when the endpoint returns no effort metadata, the picker invents none.

CLI

This section covers the bundled command line, which handles everything outside the model-call path. No command prints a token.

dsh-chatgpt-siwc login [--no-browser] [--new]   # reuses this host's registration unless --new
dsh-chatgpt-siwc doctor          # token-free JSON: loaded build, accounts file, registrations, lock, port
dsh-chatgpt-siwc discover [--refresh] [--json]  # token-free summary or JSON: plugin, readiness, models
dsh-chatgpt-siwc status          # token-free public view of the account
dsh-chatgpt-siwc models          # rebuild and merge the account's index; print visible models and efforts
dsh-chatgpt-siwc logout [--purge]
dsh-chatgpt-siwc help

Run doctor first after any install; it tells you which build actually loaded and from where. models, the card's Refresh Catalog, and discover --refresh all merge rows per slug, so a thin refresh never erases known capabilities. Human output is English or Simplified Chinese: pass --lang zh or --lang en, or let it follow LC_ALL, LC_MESSAGES, then LANG. JSON, error codes, model slugs, and URLs are never translated.

Boundaries

This section is the contract the code holds to, and the tests that hold it.

  • Not the Codex login. No Codex client, no Codex endpoint, no ~/.codex/auth.json, no contact with Codex harness state. The only token this plugin touches is your SIWC token issued to this app.
  • No pooling. One account's client id only ever travels with that account's tokens.
  • Plan usage is a grant, not an identity. Without chatgpt.tokens.use.direct, no model call is made.
  • Omission is the contract. Every request sends store: false and stream: true. Never sent: max_output_tokens, temperature, top_p, prompt_cache_retention, truncation, metadata, user. service_tier is omitted unless it resolves to 'priority'.
  • Function tools only. Hosted tools are not offered on the plan route.
  • Nothing private crosses the card's RPC. CatalogModel.raw and base_instructions are stripped by toSafeCatalogModel.
  • Not affiliated with or endorsed by OpenAI or DeepSeek. "ChatGPT" is a mark of OpenAI; the package name uses it descriptively.
How the pieces fit

The repository is an npm workspace with two packages. dsh-chatgpt-siwc (the root) is the DSH integration shell: the Cordis plugin entry, the siwc-dsh-core adapter, the settings card and browser bundle, the host-free src/discover.ts, the OAuth and account store, and the CLI. siwc-core (packages/siwc-core) is the portable engine: request IR, stream-event model and Responses SSE translator, catalog merge and budget helpers, and the Responses wire builder. It has zero host imports and zero node:* imports, which tests/architecture.test.ts enforces, and its pure-TS SHA-256 is byte-identical to node:crypto so prompt_cache_key stays stable across runtimes. Golden fixtures pin the wire bytes and stream chunks.

The tests cover everything verifiable without an account, using injected fakes rather than live endpoints: the wire contract, prefix-invariant bytes, catalog merge, the service_tier fallback, SSE translation, ID-token verification, OAuth end to end against a real loopback listener, plugin registration, the settings card, and English and Chinese parity. Live sign-in is an operator step, never an automated test.

Status

This section says what works today and what does not yet. Version 2.3.0 is the current release on npm latest (v2.3.0), and the npm badge above shows what is live.

Working: SIWC sign-in, merge-per-slug model discovery with offline fallback to the cached catalog, per-model surface image input (input_image data: URLs), per-model efforts, contextBudget and modelOverrides clamping, the settings card with Cache Hit %, the cached catalog table, and the passive usage-window readout, and the prompt cache measured above.

Open items, stated plainly:

  • Image input is per model; files are text. Since 2.3.0, a user-message image is sent as input_image (data: URL, PNG/JPEG/WEBP/GIF, at most 20 MiB per image and 64 MiB of base64 per request) only to a model whose catalog discloses image input; other models get the host's text placeholder. Files and images inside tool results still go out as text. Not yet exercised against the live API.
  • The Fast tier is not yet proven to apply. The live priority probe returned HTTP 200, but response.created reported service_tier: 'auto' and response.completed reported service_tier: 'default'. The request is sent correctly; whether the plan honours it is unconfirmed.
  • Live Ultra inference is not tested. Ultra appears in the picker for models that advertise it.
  • No Codex CLI A/B yet. A same-task cache comparison against the Codex CLI has not been run.
  • Orphan lock. A process killed while holding accounts.json.lock leaves a lock that blocks writers until it is removed.

Documentation and license

This section points to the rest of the documentation.

Plugin correlati