Preface¶
When using @anysearch/anysearch-dsh in DSH, AnySearch calls depend on the ANYSEARCH_API_KEY credential. If you have a single KEY, you can simply write it directly into ~/.dsh/.credentials.yaml or an environment variable. However, if you have multiple KEYs (e.g., for different accounts, or separating test and production environments), you typically have to manually edit the credentials file, and afterwards worry about whether the process has picked up the new values.
The community plugin dsh-anysearch-key-mgm (maintainer ADkun, category admin-security) adds a AnySearch KEY page to the DSH settings. It allows you to register multiple KEYs in a local list with notes, and write them to the credential service via a simple click in the UI. Since the anysearch plugin re-parses credentials on every operation, switching KEYs takes effect immediately without restarting dsh. This eliminates the need to repeatedly edit .credentials.yaml when changing KEYs, and ensures the full KEY is never exposed to the browser via HTTP responses.
What is this¶
dsh-anysearch-key-mgm is an management panel for @anysearch/anysearch-dsh: a dedicated page in Web settings to maintain multiple AnySearch API KEYs and write the selected one to ANYSEARCH_API_KEY with a single click.
- Repository: ADkun/dsh-anysearch-key-mgm
- Directory Page: SkillHub Plugin Page
- License: MIT (see repository README)
- Runtime Environment: Node.js
>=22(seeenginesinpackage.json)
Core Features¶
The following introduces the settings page and backend behavior, sourced from the repository README.
Settings Page Operations¶
Path: Settings → AnySearch KEY.
| Feature | Description |
|---|---|
| Current Active | Displays the credential name, masked value, and source (file indicates the local credentials file, env indicates the environment variable fallback) |
| Register Current Active KEY | Adds the current entry from the credentials into the list for easy switching between multiple KEYs |
| Add KEY | Notes + KEY (the input box is of password type; only masks are returned via HTTP after persistence) |
| Switch to this KEY | Calls credentials.set(ANYSEARCH_API_KEY, selected_value); the next anysearch call will use this value |
| Delete | If the active entry is deleted, it automatically falls back to the first item in the list; if the list becomes empty, credentials.unset() is called, and the environment variable takes over again |
Data and Security¶
- List File:
${DSH_PROFILE_DIR || DSH_HOME || ~/.dsh}/anysearch-keys.json, with0600permissions, using atomic replacement (temp file + rename). - Active Value: Managed by the DSH credential service, stored in
ANYSEARCH_API_KEYwithin~/.dsh/.credentials.yaml. - Full KEY not exposed via HTTP: For example,
GET /api/anysearch-key-mgm/keysonly returns masks likeas_sk_…4572.
The host registers the API at /api/anysearch-key-mgm. Requests pass through the same-origin fence (loopback Host, rejection of sec-fetch-site: cross-site, origin/referer consistency with Host) and are dispatched via POST body.action for add | activate | remove | rename | import. The plugin provides no agent tools, runs no background tasks, and does not watch files.
Installation and Activation¶
The installation method provided by the official README is as follows (Windows path example; adjust the clone target path according to your local DSH plugin directory).
git clone https://github.com/ADkun/dsh-anysearch-key-mgm.git D:/dsh/plugins/dsh-anysearch-key-mgm
dsh plugin --profile web add "link:D:/dsh/plugins/dsh-anysearch-key-mgm"
dsh plugin add appends the package name to dsh.profile.bundles in ~/.dsh/profiles/web/package.json and links node_modules. After installation, refresh your browser once (the slot for the settings page is assembled at startup); the running dsh web will hot-reload the plugin.
Configuration¶
The plugin injects Cordis configuration via cordis.patch.yml, managing only the credential named ANYSEARCH_API_KEY by default:
- insert:
- id: dsh-anysearch-key-mgm
name: dsh-anysearch-key-mgm
config:
credentialRef: ANYSEARCH_API_KEY
credentialRef represents the managed credential name. If you need to change it to a different name, verify that the anysearch plugin’s apiKeyEnv (default ANYSEARCH_API_KEY, see @anysearch/anysearch-dsh’s lib/index.js) remains consistent with it.
Typical Usage¶
- Follow the previous section to complete installation and refresh the browser, then open Settings → AnySearch KEY.
- If a KEY already exists in the credentials, click Register Current Active KEY to include it in the list.
- Use Add KEY to register notes and a new KEY.
- Select an entry in the list and click Switch to this KEY; no dsh restart is needed, and subsequent anysearch calls will use the new value.
- Delete entries when they are no longer needed; note the fallback rules when deleting the current active item (see “Delete” above).
The repository provides self-test scripts that use only temporary directories (without reading or writing real credentials and lists):
node test/host.smoke.mjs # Host: Mock credentials + mock webServer, 11 test cases
node test/client.smoke.mjs # Client: Stub react/locale/slots, verify registration and dictionary
Scenarios and Notes¶
Who it is for: Developers already using AnySearch in a DSH Web profile who need to frequently switch between multiple API KEYs without manually editing .credentials.yaml.
Ecosystem Note: The DSH community plugin directory (such as SkillHub) is an independent site and has no official affiliation with DeepSeek or HFTrader (Hithink RoyalFlush); please review the source code and MIT license yourself before installing third-party plugins. The plugin runs with the permissions of the current dsh process, and both the list and credentials are stored in the local user directory. Please keep anysearch-keys.json and .credentials.yaml secure.
Conclusion¶
dsh-anysearch-key-mgm consolidates multi-KEY management for AnySearch into a one-click switch on the settings page. It aligns with the DSH credential service and the anysearch plugin’s per-call parsing behavior, avoiding the friction of manual file editing and restarts.
- Directory Page: https://www.skillhub.cn/plugins/ADkun/dsh-anysearch-key-mgm
- GitHub: https://github.com/ADkun/dsh-anysearch-key-mgm