DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

fuyu1993 /

fuyu1993/dsh-anysearch-quota

Verified

DSH 插件:会话标题行的 AnySearch 额度徽章 + 额度视图,优先读取控制台仪表盘的真实剩余额度,回退到本机记账估算

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@f02c9e86

dsh-anysearch-quota

Answers one question for DSH: how much AnySearch search do I have left?

It does it in two places:

  • A badge on the session title row — AnySearch 958. Click it to open the full panel.
  • An 额度 tab in the conversation Views, beside Chat / Trajectory / Stats.

Where the numbers come from

Source What it gives Trust
Console dashboard remaining / used / total, plan tier, next reset The real account figure, same source as anysearch.com/console/overview
Local ledger calls this machine made, per UTC day Exact for this machine; an estimate against the account balance
Rate window x-ratelimit-limit / -remaining / -reset Real, but a short-lived limiter — not "calls left"

The dashboard source wins whenever it is available; the panel labels the local ledger as an estimate when it is not. The two are never mixed in one display.

The console dashboard source

AnySearch's public API has no endpoint for the remaining balance — its own docs say the console is authoritative. The console page is fed by an internal JSON API, which this plugin calls directly:

POST /auth/refresh              { refresh_token }        → session tokens
GET  /api/user/billing/overview Authorization: Bearer …  → the real counters

It authenticates as a console session, not with the as_sk_… API key (that key is rejected with 401). To enable it, copy the console's refresh token into a credential:

  1. Sign in at https://www.anysearch.com/console/overview.
  2. In the browser devtools, read localStorage['search-template-auth-state'] and copy its state.refreshToken.
  3. Store it as the credential ANYSEARCH_CONSOLE_REFRESH_TOKEN in $DSH_HOME/.credentials.yaml:
refs:
  ANYSEARCH_CONSOLE_REFRESH_TOKEN: "<the refresh token>"

That is the only value that leaves this machine besides the search requests themselves, and it only goes to www.anysearch.com. The console rotates the refresh token on every exchange; the rotated value is written back through the credential service, so the session survives a restart.

Without it the plugin still works: it shows the local ledger estimate and tells you which credential would enable the real figures.

The local ledger

Calls are counted from observed tools/result events, billed by AnySearch's own rules:

  • a successful web_search / anysearch_search → 1 call
  • a successful web_fetch (extract) → 1 call
  • anysearch_batch_search → 1 per successful sub-query
  • failed, invalid and timed-out requests → none (only a failure count)
  • anysearch_capabilities → none

The rate window

GET /v1/domains is documented as consuming no free or paid search quota, so it is the endpoint used to read the limiter headers. A 429 answer is recorded too — that is what a saturated window looks like. The panel states plainly that these headers are a window, not the daily quota.

Configuration

Optional keys on the plugin's row in cordis.patch.yml:

- id: dsh-anysearch-quota
  config:
    consoleEnabled: true                          # false: ledger estimate only
    consoleTokenEnv: ANYSEARCH_CONSOLE_REFRESH_TOKEN
    consoleBaseURL: https://www.anysearch.com
    consoleTtlMs: 60000                            # how long a dashboard reading is reused
    freeCalls: 1000                                # allowance the ledger estimate is drawn against
    probeEnabled: true                             # startup window probe + probe button
    probeMinIntervalMs: 30000
    apiKeyEnv: ANYSEARCH_API_KEY
    baseURL: https://api.anysearch.com
    stateFile: /path/state.json

Placement

  • The badge registers in conversation.session.header.actions (the Session title row) and, because the header hides its chrome on a blank New Session, also in conversation.hero.options. The two phases never overlap.
  • The panel is portalled to document.body: the header clips its overflow, so a panel growing inside it would be cut off.
  • The 额度 tab stays available for the full view.

Privacy

The API key and the console refresh token are resolved inside the Host process, per operation, from credential references. The browser half only ever receives numbers. The ledger is a local JSON file at $DSH_HOME/anysearch-quota/state.json; turning the plugin off stops the counting and removes the badge and tab, but keeps that file.

Notes

  • Counting starts when the plugin loads; calls made before installation are not in the ledger.
  • Calls from other devices or other clients are invisible to the ledger, which is why the ledger's "remaining" is an estimate and the dashboard's is not.
DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout
—/ 5

No ratings yet

Verified DSH bundle

Commit f02c9e86af05

Community comments

No comments yet. Be the first to write one.