@djdowbnac/dsh-claude-auth

中文文档
0.1.4发布于 2026/09/29MITTypeScriptES Module零依赖近 30 天下载 4975

LLM provider plugin for the DeepSeek Harness (dsh): streams Claude (Sonnet/Haiku/Opus) through your Claude Code subscription (claude.ai OAuth credentials), no Anthropic API key required.

原始使用文档
文档目录8 节
  1. How refresh works
  2. Install
  3. Settings
  4. Web settings
  5. Develop
  6. Limitations
  7. References
  8. License

@djdowbnac/dsh-claude-auth

dsh model provider that streams Claude through your Claude Code subscription. No Anthropic API key.

Registers a claude-subscription provider on ctx.llm. On the first request the plugin queries GET /v1/models with your OAuth token and serves every model your account can use, with its real context window and output cap. The catalog updates itself when Anthropic ships or retires models, so there is no static model list to maintain.

Requests go to api.anthropic.com/v1/messages with the Claude Code first-party headers. Credentials come from ~/.claude/.credentials.json, the same file the claude CLI writes.

Anthropic reserves subscription tokens for official clients. This is a community workaround, same class as opencode-claude-auth. It draws from your plan limits, not API billing, and may stop working when Anthropic changes its OAuth surface.

How refresh works

The plugin keeps an access token in memory for 30 seconds and only calls the token endpoint when the token is within 60 seconds of expiry, or once per hour as a background pre-refresh. A cross-process lock serializes concurrent instances: the loser waits up to 15 seconds and adopts the winner's token instead of refreshing again. Anthropic rotates refresh tokens on single use, so double refreshes were what broke tokens before.

Install

Prerequisites: dsh on the 0.1.7-rc line, bun, and a one-time claude login.

dsh plugin --profile <name> add @djdowbnac/dsh-claude-auth

That is the whole install. The command registers the package in the profile's dsh.profile.bundles, and dsh mounts the plugin's cordis.patch.yml as an automatic bundle layer on every boot. No manual patch entry, no profile edits.

For a local checkout, add . from inside the checkout directory. Restart dsh and pick a claude-subscription model.

Settings

Namespace claude-auth:

KeyDefaultMeaning
credentialsPath'' (→ ~/.claude/.credentials.json)Override the credentials file path.
disabledModels[]Model ids to stop serving.
streamIdleTimeoutMs600000Abort the stream when SSE goes quiet this long.
requestTimeoutMs900000Per-request budget.

Changes apply on the next request. A missing or invalid credentials file shows as a diagnostic on the provider entry, and requests fail with a typed error.

Web settings

The Models page in the dsh web UI shows a green credential dot next to the provider when your Claude subscription credentials are valid. The plugin mirrors the current access token into the dsh credential store under the CLAUDE_SUBSCRIPTION_API_KEY reference, which is the same reference the page checks. When the token expires or the credentials file disappears, the dot goes away and the provider row shows a diagnostic.

The provider editor card is read-only by design in the dsh web UI. The page renders curated field layouts only for the two first-party provider namespaces (llm-deepseek, llm-pi-ai); every other namespace falls back to the "edit settings.yaml directly" hint. To change streamIdleTimeoutMs or disabledModels, edit the claude-auth section in ~/.dsh/settings.yaml.

Reasoning effort is not a provider setting. Pick it in the model selection popup: the effort selector appears for every model that supports adaptive thinking (all current Opus, Sonnet, Fable, and Haiku 4.5+ models). The chosen effort is sent as output_config.effort on the wire request.

Develop

bun test        # 81 tests, all offline
bun run build
bun run smoke   # one live request, costs a few tokens
FileWhat it does
src/index.tsPlugin entry: config schema, provider registration, settings, disposal.
src/adapter.tsLlmAdapter: headers, fetch, SSE consumption, error mapping, model discovery.
src/serialize.tsHarness Message[] to Anthropic wire request.
src/translate.tsAnthropic SSE to harness StreamChunks.
src/sse.tsSSE framing parser.
src/auth.tsCredential read, refresh, write-back, backoff, cross-process lock.
src/model-config.tsBeta headers, effort support, catalog fallback.

Unit tests inject fetchImpl, so they run offline. The smoke script is the only live path.

Limitations

  • Text only. Image and file content blocks return UNSUPPORTED_CONTENT.
  • One credentials file per provider route. Multi-account is not wired.
  • If the models endpoint is unreachable, the plugin falls back to a static catalog of the current Claude 5 lineup.

References

License

MIT

版本与发布记录

@djdowbnac/dsh-claude-auth 共发布 5 个版本,首次发布于 2026/09/12;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.1.4latest2026/09/291 个月前
0.1.32026/09/151 个月前
0.1.22026/09/131 个月前
0.1.12026/09/131 个月前
0.1.02026/09/122 个月前

关于 @djdowbnac/dsh-claude-auth 的常见问题

@djdowbnac/dsh-claude-auth 是什么?

LLM provider plugin for the DeepSeek Harness (dsh): streams Claude (Sonnet/Haiku/Opus) through your Claude Code subscription (claude.ai OAuth credentials), no Anthropic API key required.

如何安装 @djdowbnac/dsh-claude-auth?

在项目目录运行 npm install @djdowbnac/dsh-claude-auth,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@deepseek-ai/cordis(^4.0.2)、@deepseek-ai/dsh-llm(^0.1.7-rc.2)、@deepseek-ai/dsh-timeout(^0.1.7-rc.2)、@deepseek-ai/dsh-settings(^0.1.7-rc.2)、@deepseek-ai/dsh-credentials(^0.1.7-rc.2)、@deepseek-ai/dsh-launch-environment(^0.1.7-rc.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@djdowbnac/dsh-claude-auth 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@djdowbnac/dsh-claude-auth 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@djdowbnac/dsh-claude-auth 可以商用吗?

@djdowbnac/dsh-claude-auth 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@djdowbnac/dsh-claude-auth 的下载量有多少?

根据 npm 官方下载统计,@djdowbnac/dsh-claude-auth 在 2026/10/13 – 2026/11/11 这 30 天内被下载 4,975 次,日均约 166 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@djdowbnac/dsh-claude-auth 还在维护吗?

最新版本 0.1.4 发布于 2026/09/29(1 个月前);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/09/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。