DeepSeek Harness 插件

trmquang93/dsh-claude-code-account

Star 数 ★ 0 下载量(近 30 天) 635 分类 模型与账号接入 收录于 2026-11-16 npm @trmquang93/dsh-claude-code-account

用 Claude Code(Claude Pro/Max)登录作为 DSH 的 anthropic 模型提供方,让 DSH 的 pi-ai 凭据记录与 Claude Code 钥匙串共用同一条轮换中的 OAuth 凭据链。

安装

# npm 包(预构建)

dsh plugin --profile web add @trmquang93/dsh-claude-code-account

# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)

dsh plugin --profile web add github:trmquang93/dsh-claude-code-account

装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。

README

该插件的 README 只有英文版本。

Use a Claude Code sign-in (Claude Pro/Max subscription) as a DSH model provider.

Claude Code keeps its OAuth grant in the login keychain, one item per CLAUDE_CONFIG_DIR. DSH's pi-ai adapter keeps its own copy of that grant in the credential record llm-pi-ai/<provider> and refreshes it when it expires. This plugin keeps both sides on the same rotating chain, so

  • the account keeps powering DSH model requests (through the anthropic route) with no second OAuth sign-in, and
  • the Claude Code CLI login keeps working after DSH refreshes the token, because the rotated grant is written back to the keychain.

It refreshes once when neither side holds a usable access token, and mirrors whichever side already holds the fresher valid grant (so a refresh DSH performed itself is repaired back into the keychain instead of being spent twice).

Install

dsh plugin --profile <name> add @trmquang93/dsh-claude-code-account

The package ships prebuilt JavaScript, so the install runs no build script and needs no permission. It declares a bundle: dsh appends it to the profile's dsh.profile.bundles and applies its patch on the next boot. Signing in to Claude Code first is optional — the plugin reports a missing login instead of failing the boot.

Prerequisite: the provider route

The route is configuration, not code. DSH's last patch layer — the profile's own $DSH_HOME/profiles/<profile>/cordis.patch.yml — must list anthropic under llm-pi-ai.providers. Keep the route key equal to the plugin's provider:

- id: llm-pi-ai
  name: '@deepseek-ai/dsh-llm-pi-ai'
  config:
    providers:
      opencode-go:
        apiKeyEnv: OPENCODE_GO_API_KEY
      openrouter:
        apiKeyEnv: OPENROUTER_API_KEY
      anthropic:
        displayName: Claude Code (personal)

The plugin ships its own Claude model list (models.json) and serves it on the route, so new models appear without waiting for the app's bundled pi-ai. A models list set on the route in the profile wins over it. Set the route's displayName to the account it is wired to; the plugin writes the credential and never the route.

Configuration

- id: claude-code-account
  name: '@trmquang93/dsh-claude-code-account'
  config:
    account: default              # default/work → ~/.claude, personal → ~/.claude-personal
    provider: anthropic           # pi-ai route whose record this plugin owns
    accounts:                     # optional: extra name → config-dir map
      personal: .claude-personal
      work: .claude
    configDir: /abs/dir           # optional: an absolute CLAUDE_CONFIG_DIR instead
    refreshLeadMs: 600000         # refresh when the access token is this close
    intervalMs: 300000            # how often the timer re-checks
    writeBack: true               # write rotated tokens back into the keychain
    claudeCommand: claude         # used for `claude auth status --json` metadata

The account name selects the Claude Code config directory, and the directory selects the keychain item:

account config dir keychain service
default, work ~/.claude Claude Code-credentials
personal ~/.claude-personal Claude Code-credentials-<sha256(absolute dir)[:8]>
any configDir that directory Claude Code-credentials, or the suffix above for a non-default directory

That is exactly how Claude Code namespaces several logins in one keychain, so a second login at ~/.claude-personal resolves to its own suffixed item (sha256("<home>/.claude-personal")[:8]).

Use

  1. Sign in to Claude Code for the chosen account: claude auth login, or CLAUDE_CONFIG_DIR=~/.claude-personal claude auth login for a second one.
  2. Make sure the anthropic route is in the profile patch (above). DSH applies patch changes live with HMR.
  3. Pick a Claude model in the model selector. The plugin has already mirrored the account's grant into llm-pi-ai/anthropic.
  4. Ask claude_code_account (tool) or read the startup log line for the account email, plan and access-token expiry.

The tool returns no secret values:

{
  "account": "personal",
  "configDir": "/Users/quangtran/.claude-personal",
  "keychainService": "Claude Code-credentials-6195afbc",
  "provider": "anthropic",
  "providerRegistered": true,
  "email": "trmquang@icloud.com",
  "subscriptionType": "pro",
  "accessExpiresAt": "2026-11-10T19:10:43.114Z",
  "accessExpiresInMinutes": 469,
  "source": "keychain",
  "recordConfigured": true
}

action: "sync" forces a reconcile pass (refreshing when needed).

What can go wrong

  • The plugin owns llm-pi-ai/<provider>. Signing out or signing in to the same route from the Models page writes the same record; the next timer pass restores the Claude Code account's grant. Use another route key (and another provider in this plugin's config) if the two must coexist.
  • A keychain write can be refused when the login keychain's access control does not allow security to update the item; the sync then still updates DSH but the CLI keeps its old chain. The record reports the failure via lastError; re-enable the CLI by running claude auth login for the account.
  • An account that was never signed in fails with an actionable run "claude auth login" message instead of silently leaving DSH keyless.
  • macOS only for the keychain read. Other platforms fall back to <configDir>/.credentials.json, which is where Claude Code stores its grant on Linux. Nothing else is platform-specific.
  • Claude Code must keep working with the account. The plugin writes rotated tokens back, but if the account's refresh token has expired, both sides need a fresh claude auth login.

Release

npm test
npm publish        # publishConfig sets access:public and the public registry

Bump version first; files limits the tarball to the entry points, the patch, the README and the LICENSE.

Tests

node --test test/ covers the decision logic (which side wins, when a network refresh happens, write-back), the keychain-service naming, document merging, and the record shape, all with injected fakes.

Verify a mounted account

  1. claude_code_account (tool) or the startup log line reports the account email, plan and access-token expiry; action: "sync" forces a reconcile.
  2. The composer model menu (or /model) lists a Claude Code (personal) group once the anthropic route is configured.
  3. Send a short prompt with a Claude model selected — the answer comes from the subscription, not an API key.
  4. CLAUDE_CONFIG_DIR=~/.claude-personal claude auth status and a one-shot claude -p "ok" must still work: that proves the write-back preserved the CLI login.

内容来自项目 README(GitHub)↗

链接

同类插件

查看整个分类 →

社区评论

评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。