New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

dsh-account-balance

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsh-account-balance

DSH web composer tool-row DeepSeek account balance indicator

latest
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

dsh-account-balance

English | 中文

A DeepSeek Harness (DSH) web client plugin: a small label in the composer tool row (right end, beside the send button) showing your DeepSeek API account balance.

Scope: balance only for now. A "spent today" readout is a planned follow-up — DeepSeek has no usage-history API, so it must be computed separately.

Features

  • Recharge balance at a glance — shows topped_up_balance as ¥ 1,234.56.
  • Tooltip breakdown — hover for total / granted / topped-up balances.
  • 60 s auto-refresh + click to refresh — click the label to force an immediate re-fetch.
  • Safe by default — the host resolves the key through DSH's credential seam (DEEPSEEK_API_KEY) and never exposes it to the browser.

How it works

A DSH plugin is an npm package with two halves:

HalfFileJob
Hostlib/index.jsCordis service registering GET /dsh-usage/balance; resolves the key and calls DeepSeek's balance API behind a 60 s cache.
Clientlib/client.jsModule-loader bundle injecting a React label into the conversation.input.right slot.

The client polls GET /dsh-usage/balance every 60 s and passes ?refresh=1 on click. No build step: the client bundle is hand-authored in module-loader format.

Data source

GET https://api.deepseek.com/user/balance returns balance_infos[0] with total_balance, granted_balance, and topped_up_balance (CNY, as strings). The host parses them into numbers.

Requirements

The composition must provide the DEEPSEEK_API_KEY credential (the same key DSH uses to call DeepSeek). The host reads it through ctx.credentials, falling back to the process environment.

Install

Requires DSH's web profile. The default web profile lives at ~/.dsh/profiles/web/.

dsh plugin --profile web add dsh-account-balance

Installs from npm and reconciles it into the profile's bundle list (the package declares dsh.bundle). Requires pnpm on PATH.

From source

git clone https://github.com/weiyuou-chowbus/dsh-usage.git
ln -sfn "$(pwd)/dsh-usage" ~/.dsh/profiles/web/node_modules/dsh-account-balance

Then add the row to ~/.dsh/profiles/web/cordis.patch.yml:

# ~/.dsh/profiles/web/cordis.patch.yml
- insert:
    - id: usage
      name: dsh-account-balance

Restart with npm exec @deepseek-ai/dsh web and refresh http://127.0.0.1:3080.

Configuration

KeyTypeRequiredMeaning
apiKeyEnvstringnoCredential ref to resolve (default DEEPSEEK_API_KEY).

HTTP API

RouteMethodQueryResponse
/dsh-usage/balanceGET?refresh=1 (optional, bypass cache){ isAvailable, currency, totalBalance, grantedBalance, toppedUpBalance }

On failure: 502 { error, balance: null }.

Limitations

  • Balance only — no per-request or per-day spend yet.
  • Official endpoint only — the balance host is fixed to api.deepseek.com; a custom chat baseURL is ignored.
  • Cache — the host caches for 60 s, so a top-up shows up on the next refresh (or immediately on click).

Development

  • Client changes (lib/client.js) hot-reload: DSH's client-modules watcher re-hashes the bundle and a refresh applies it.
  • Host changes (lib/index.js) need a dsh web restart.
  • dsh.client declares inject: ["@deepseek-ai/dsh-client-runtime"] and platform: "web", so the shell serves /plugins/dsh-account-balance/client.js.

License

MIT

FAQs

Package last updated on 17 Aug 2026

Related posts