DSH Account Switcher: Multi-Account Grant Library, Hot Switching, and Automatic Rotation

Introduction

When running model inference in DeepSeek Harness (DSH), official account credentials typically reside in the deepseek-account-platform/default grant within ~/.dsh/.credentials.yaml. If you have multiple DeepSeek official accounts, the common practice is to repeatedly log out and re-authorize via browser, or to log in to one account on different machines—the former revokes remote tokens, while the latter makes rotation on a single Desktop difficult. The community plugin dsh-account-switcher (maintainer hyqweasd5-png, category: Model Inference) consolidates multiple account grants into a local account vault. It allows switching the current account without restarting the GUI or actively revoking tokens, and supports automatic rotation based on authentication invalidation, quota exhaustion, rate limiting, or low balance. Login, SSH tunneling, etc., are still handled by the separate dsh-account-login plugin; the two plugins are designed to be used together.

What is this

DSH Account Switcher (GitHub: hyqweasd5-png/dsh-account-switcher, package name @local/dsh-account-switcher, version 0.3.0 in current materials) is a third-party plugin for DeepSeek Harness. It utilizes only Cordis services and Node built-in modules, without depending on @deepseek-ai/* runtime packages. The README indicates compatibility with DeepSeek Harness Desktop 0.2.1-rc.2 (the source code tag matches this version).

The core problem it solves is: maintaining multiple platform grants within a single-process DSH instance, hot-updating the current account in the credential store, and optionally switching to the next available account upon error signals or low balance.

Division of Labor with the Login Plugin

This plugin handles only switching and rotation; login, server portal access, SSH tunneling, and token caching are handled by dsh-account-login. When both are installed, the data flow is as follows:

Login Management (Login Plugin) → Login to new account → Write grant to ~/.dsh/account-login/accounts.json
Account Switching (This Plugin) → Sync login account → Import grant → Switch/Rotate

Core Features

Account Vault and Hot Switching

The account vault is independent of the credential store, defaulting to the path ~/.dsh/account-switcher/accounts.json (with directory and file permissions set to 0700 and 0600 respectively). During a switch, it atomically replaces the grant for deepseek-account-platform/default in ~/.dsh/.credentials.yaml via ctx.credentials.modifyRecord. Since the credential store monitors changes and the inference side reads the record on every request, official documentation states that the switch takes effect in approximately 1 second without requiring a restart.

Settings Page Capabilities

Once Account Switch appears on the left side of DSH Settings, the following actions are available:

  1. Save Current Account: Store the currently logged-in account into the account vault, optionally with a nickname.
  2. Add Account: Add a new account via the official browser login flow; upon success, it is automatically added to the vault and set as the current account, without revoking the original account’s token.
  3. Import Token: Paste the DSH account grant (x-dsh-auth-token value) from platform.deepseek.com; if platform validation fails, the write is rejected. Tokens from chat.deepseek.com web sessions cannot be imported directly (the platform returns code 40003); you must use “Add Account” to perform a platform browser login. A reliable source for the token is the payload.token of deepseek-account-platform/default in ~/.dsh/.credentials.yaml on another DSH machine that is already logged in.
  4. Exchange Web Token: Copy the Authorization: Bearer ... from the browser DevTools of a logged-in platform.deepseek.com session. The plugin exchanges it for a DSH grant via auth_init → auth_approve → auth_exchange and imports/switches to it. This supports platform login tokens only; the exchange token is not written to the account vault or logs.
  5. Switch: Write the target grant into the credential store.
  6. Sync Login Account: Import the grant from ~/.dsh/account-login/accounts.json (requires the login plugin to be installed and login completed).
  7. Balance: After switching, saving, or importing, the profile and balance are fetched in the background; the interface displays “Balance X CNY”, with credits merged into the total amount in the same currency. Manual refresh is supported.
  8. Delete: Removes the account only from the local vault; deleting the current account triggers a switch to the next one first. If there is no next account, it performs a local logout without sending a logout request to the platform.

Do not use “Logout” on the official account page to switch accounts: This operation calls POST /auth-api/v0/users/logout to revoke the token on the server side, and the copy in the account vault will also become invalid. Always use “Switch” on this page to change accounts.

Automatic Rotation

Disabled by default. When enabled, it switches accounts based on the signals in the table below, with safeguards: a minimum switch interval of 30 seconds, a maximum of 3 switches within 10 minutes, and a 10-minute cooldown per account. If no available account exists, it only warns and does not delete the current grant. Balance comparison is done by currency. The polling default is 5 minutes, and switching due to low balance only occurs when there are no running sessions.

Signal Source Behavior
Login state invalid (401 / 40003) Account events, Model errors Mark current account as invalid, switch to next
Quota exhausted (402 / QUOTA) Model errors Cooldown current account, switch to next
Rate limited (429 / RATE_LIMIT) Model errors Cooldown current account, switch to next; if two consecutive accounts are rate limited, pause for 5 minutes
Balance below threshold Scheduled polling Switch only when there are no running sessions

Automatic rotation only guarantees that the next request will use a new account; it does not automatically resend the failed conversation turn.

Installation and Activation

Command Line Installation (Source Code)

dsh plugin --profile web add github:hyqweasd5-png/dsh-account-switcher

Restart DeepSeek Harness once after installation. Subsequent switches will take effect dynamically (hot-reload).

Local Path Installation

  1. Open the DSH Plugins page, click Add Plugin → Install Third-party Plugin.
  2. Enter the absolute path of the local directory in the package name/path input box, for example:
    /path/to/dsh-account-switcher
  1. Enable Immediately and restart DSH once.
  2. Open Settings; Account Switch should appear on the left side.

If the settings page does not appear after a DSH upgrade, check the Host logs for output prefixed with account-switcher; a normal readiness message is account-switcher: ready.

Configuration (Optional)

Override the bundle patch config in ~/.dsh/profiles/desktop/cordis.patch.yml:

- id: account-switcher
  config:
    platformOrigin: https://platform.deepseek.com
    debug: false
Field Default Value Description
platformOrigin https://platform.deepseek.com Official platform origin
debug false When true, enables POST /account-switcher/api/debug/trigger for testing rotation
vaultPath $DSH_HOME/account-switcher/accounts.json Account vault path
clientVersion 0.2.1-rc.2 x-client-version for platform requests
locale System language x-client-locale for platform requests

Typical Usage

  1. Install this plugin; if you need to sync accounts from the login plugin, also install and configure dsh-account-login.
  2. Restart DSH, and use “Add Account” or “Import Token” in Settings → Account Switch to build the account vault.
  3. Select the target account in the list and click Switch; click Sync Login Account if alignment with the login plugin is needed.
  4. For long-running automated tasks, enable automatic rotation on the same page and set a low balance threshold (note the safeguards and the restriction that balance-based switching only occurs when there are no sessions).

Use Cases and Notes

Suitable for: Managing multiple your own DeepSeek official accounts on a single DSH Desktop, minimizing manual account switching during quota exhaustion, rate limiting, or token invalidation; combining with dsh-account-login for centralized login and local switching.

Limitations and Compliance (from README):

  • Official grants do not auto-refresh; re-login or re-import is required after invalidation.
  • Does not manage third-party provider API Keys.
  • After switching, if the target account has a different model catalog, the current model request may fail; you need to change the model or the account.
  • If multiple Hosts write to the same account vault simultaneously, the last write will overwrite the snapshot; the active grant is still protected by the credential store’s cross-process lock.
  • The plugin runs with the permissions of the current DSH process. Before installation, you should read the source code and MIT license on GitHub to evaluate the trust boundary yourself. The local API only accepts loopback connections and requires x-account-switcher: 1; see the “Security” section in the README for account vault and masked token design.
  • Using multi-account rotation to circumvent quota or platform risk controls may violate the Terms of Service.

The community plugin directory dsh-account-switcher on SkillHub has no official affiliation with DeepSeek or Hithink RoyalFlush; the DSH ecosystem emphasizes “Everything is a Plugin”, and this is a community-maintained model inference extension.

Uninstallation

Remove @local/dsh-account-switcher on the Plugins page and restart the App. The current grant remains in the credential store; the account vault can be deleted manually:

rm -rf ~/.dsh/account-switcher

For more complete troubleshooting, directory structure, and testing instructions, please refer to the repository README: https://github.com/hyqweasd5-png/dsh-account-switcher

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye