dsh-cliproxyapi-pro 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.en.md +378 -0
- package/README.md +286 -147
- package/lib/client.js +640 -2
- package/lib/index.js +90 -0
- package/lib/updater.js +376 -0
- package/package.json +4 -3
- package/README.zh.md +0 -237
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this plugin. Versions follow [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
+
## 1.5.0 — 2026-10-19
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Plugin update card**, independent of account forms and drafts, with Chinese/English strings, localized errors, current/latest versions, Stable / Beta / Dev channels, Auto / Global / Mainland China regions, automatic checks and optional automatic downloads. The card is collapsed by default to a single compact row (title, current version, short update status) and expands on click; polling and saves never reset that choice.
|
|
9
|
+
- Automatic checks enabled by default about 3 seconds after startup or rescheduling preferences, then every 6 hours; automatic downloads are off by default and run only after an automatic check finds a newer version. No automatic installation, uninstall, source overwrite or restart.
|
|
10
|
+
- Strict SemVer channel checks using npm `latest` / `beta` / `dev`, explicit errors for unpublished channels, and no cross-channel fallback or downgrade. Auto region races npmjs and npmmirror for the first valid metadata; explicit regions stay on their selected registry and do not affect CPA traffic.
|
|
11
|
+
- Mainland China downloads follow npmmirror's official CDN redirects through an exact host/package/version allowlist, with at most three HTTPS hops and the original metadata integrity preserved. External, local, cross-region and downgrade redirects are refused.
|
|
12
|
+
- Verified offline package preparation: registry-provided SHA-512 integrity plus bounded gzip/tar, package identity/version and file-structure checks. Reject traversal, links/special entries, unexpected files, dependencies and installation lifecycle scripts; never extract or execute an update. These checks are not publisher-signature or npm provenance verification.
|
|
13
|
+
- Packages saved atomically under the profile's `.dsh-cliproxyapi/updates/` directory, with a version-specific download confirmation and an offline `dsh plugin --profile 'name' add 'absolute.tgz'` command for use after DSH is closed, followed by a restart. Linked local installations can check/download but receive no command, protecting the source-based installation.
|
|
14
|
+
- Separate versioned `update-settings.json` preferences; invalid or unreadable files disable automatic network checks, while a missing file uses first-run defaults. Existing v2 account state and credentials remain untouched. Check results and download notices are in-memory only; downloaded files remain for user-managed cleanup.
|
|
15
|
+
- Authenticated update HTTP routes: read-only `GET /api/dsh-cliproxyapi/updates/status` and `POST` operations `/check`, `/save`, `/download`. Update POSTs require an explicit exact same-origin header matching the actual connection scheme and Host, without trusting forwarded-protocol claims.
|
|
16
|
+
- Offline updater, HTTP and dependency-free VM/Hook client tests; actual-component offline previews (collapsed and expanded) with clearly labeled example versions.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Release automation publishes stable versions to npm `latest` and Beta / Dev prereleases to `beta` / `dev`, marking the corresponding GitHub Releases as prereleases without replacing stable.
|
|
20
|
+
- Both READMEs and the architecture guide explain download-versus-install behavior, linked-source protection, storage, API admission and the manual closed-DSH upgrade workflow. The packed zero-dependency bundle now includes the internal `lib/updater.js` module.
|
|
21
|
+
|
|
22
|
+
## 1.4.1 — 2026-10-19
|
|
23
|
+
|
|
24
|
+
Documentation and release tooling only; the plugin code is unchanged from 1.4.0.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- `README.md` is now Chinese (the default on GitHub and npm), with the English version in `README.en.md`. Both are rewritten: a quick start, four verified ways to install (DSH **Plugins** page, the DSH agent, `dsh plugin add`, GitHub / offline package), upgrading and uninstalling, and a FAQ. Images and links use absolute URLs so they also render on npmjs.com.
|
|
28
|
+
- Releases publish to npm through npm trusted publishing (GitHub Actions OIDC) with an automatic provenance statement; no npm token is stored anywhere. The release workflow can also be run by hand for an existing tag and skips steps that are already done.
|
|
29
|
+
|
|
5
30
|
## 1.4.0 — 2026-10-19
|
|
6
31
|
|
|
7
32
|
First public release.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
# dsh-cliproxyapi-pro
|
|
2
|
+
|
|
3
|
+
[中文](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/README.md) | English
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-cliproxyapi-pro)
|
|
6
|
+
[](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/actions/workflows/ci.yml)
|
|
7
|
+
[](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
**Bring the models of [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) (CPA) into the model picker of [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH).**
|
|
10
|
+
|
|
11
|
+
Enter a server URL and an API key, and the plugin reads the CPA model catalog and synchronizes the models you check — with their context window, image input and reasoning levels — into DSH, each over the protocol that suits it best. Connect several CPA accounts at once and enable or disable each one on its own.
|
|
12
|
+
|
|
13
|
+
- **Multiple accounts**: each account has its own URL, key, model selection and parameters, and can be switched off at any time.
|
|
14
|
+
- **Works out of the box**: on the first connection, the newest model of each family in that server's own catalog is checked (at most 12), so the picker isn't flooded with hundreds of models.
|
|
15
|
+
- **Native protocols**: Claude over Anthropic Messages, GPT / Codex / Grok over OpenAI Responses, everything else over OpenAI Chat — fewer protocol translations inside CPA.
|
|
16
|
+
- **Visual management**: check models and edit per-model parameters in the settings panel, or let the DSH agent configure things for you through the `cliproxyapi` tool.
|
|
17
|
+
- **Plugin updates**: automatically check Stable / Beta / Dev channels, choose global / Mainland China sources, and optionally download verified offline packages. Upgrade manually with DSH closed; nothing installs or restarts automatically.
|
|
18
|
+
- **Secure**: API keys live only in the DSH credentials service, never in configuration files.
|
|
19
|
+
- **Zero dependencies**: no npm dependencies and no build step; installs in seconds.
|
|
20
|
+
|
|
21
|
+
Works with DSH `0.2.0-rc.1` and later (desktop and web).
|
|
22
|
+
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
- [Installation](#installation)
|
|
26
|
+
- [Getting started](#getting-started)
|
|
27
|
+
- [Screenshots](#screenshots)
|
|
28
|
+
- [Features in detail](#features-in-detail)
|
|
29
|
+
- [Updating this plugin](#updating-this-plugin)
|
|
30
|
+
- [Agent tool and slash commands](#agent-tool-and-slash-commands)
|
|
31
|
+
- [Storage and configuration](#storage-and-configuration)
|
|
32
|
+
- [Upgrading and uninstalling](#upgrading-and-uninstalling)
|
|
33
|
+
- [FAQ](#faq)
|
|
34
|
+
- [AI installation guide](#ai-installation-guide)
|
|
35
|
+
- [Development](#development)
|
|
36
|
+
- [License](#license)
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
The plugin is published on npm as [`dsh-cliproxyapi-pro`](https://www.npmjs.com/package/dsh-cliproxyapi-pro) and is also available from the China mainland mirror (npmmirror). Pick any one of the methods below.
|
|
41
|
+
|
|
42
|
+
### Option 1: the DSH Plugins page (recommended)
|
|
43
|
+
|
|
44
|
+
1. Open DSH and click **Plugins** in the left sidebar.
|
|
45
|
+
2. Click **Add plugin** at the top of the page.
|
|
46
|
+
3. Enter the package name:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
dsh-cliproxyapi-pro
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
To pin a version, write `dsh-cliproxyapi-pro@1.5.0`.
|
|
53
|
+
4. Click **Install**. When it finishes, the dialog offers to enable the plugin right away — accept it.
|
|
54
|
+
|
|
55
|
+
> If downloads are slow in mainland China, open **Registry** next to the input and choose **the mainland China mirror**.
|
|
56
|
+
|
|
57
|
+
### Option 2: ask the agent in DSH
|
|
58
|
+
|
|
59
|
+
Just say in a DSH conversation:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
Install the DSH plugin dsh-cliproxyapi-pro
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The agent installs and enables it with `plugin_manager` (depending on your permission settings, it may ask for your approval). Then ask it to configure the plugin, e.g. "set the CLIProxyAPI URL to http://127.0.0.1:8317 with key sk-…".
|
|
66
|
+
|
|
67
|
+
### Option 3: command line
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
dsh plugin --profile <profile name> add dsh-cliproxyapi-pro
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This downloads the plugin from npm and adds it to the profile's enabled plugins in one step. The DSH desktop profile is usually called `desktop`; if DSH is running, restart it to load the plugin.
|
|
74
|
+
|
|
75
|
+
### Option 4: from GitHub (without npm)
|
|
76
|
+
|
|
77
|
+
In **Add plugin**, or as the `plugin_manager` `target`, you can also enter:
|
|
78
|
+
|
|
79
|
+
| Source | What to enter |
|
|
80
|
+
|---|---|
|
|
81
|
+
| A released version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.5.0` |
|
|
82
|
+
| Latest development version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#main` |
|
|
83
|
+
| Offline package | Download [`dsh-cliproxyapi-pro.tgz`](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/releases/latest/download/dsh-cliproxyapi-pro.tgz) (always the latest release) and enter its absolute local path |
|
|
84
|
+
| Local source (development) | Absolute path of a cloned repository; installed as a link, so code changes go live when the plugin reloads |
|
|
85
|
+
|
|
86
|
+
All versions are listed under [Releases](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/releases).
|
|
87
|
+
|
|
88
|
+
## Getting started
|
|
89
|
+
|
|
90
|
+
1. **Open the settings panel**: sidebar **Plugins** → **CLIProxyAPI**, or **Settings** → **Built-in plugins** → the **CLIProxyAPI** tab.
|
|
91
|
+
2. **Enter the connection**: under **Connection & Authentication**, fill in the **CLIProxyAPI Base URL** (e.g. `http://127.0.0.1:8317`, without `/v1`) and the **API Key** (leave it empty for a local CPA without authentication), then click **Save & Apply**.
|
|
92
|
+
3. **Choose models**: once connected, **Model Picker Filter** lists every model on the server, with the newest model of each family already checked. Adjust the selection and click **Apply Selected Models**.
|
|
93
|
+
4. **Use them**: open the model picker in a conversation; the models appear in a group named after the account.
|
|
94
|
+
|
|
95
|
+
If CPA runs on this machine on the default port `8317` without a key, there is nothing to fill in: the plugin finds it automatically.
|
|
96
|
+
|
|
97
|
+
## Screenshots
|
|
98
|
+
|
|
99
|
+
The panel follows the DSH display language; the screenshots show the Chinese UI.
|
|
100
|
+
|
|
101
|
+
**1. Account bar and account status.** The bar at the top lists every account: a green dot means connected, a grey dot plus the **Off** badge means disabled. Here a second account, *CLI Proxy API 2*, was just added with **+ Add Account**: it starts disabled, gets its own provider route `cli-proxy-2`, and — since no base URL is set yet — the probe reports that no local CPA was found.
|
|
102
|
+
|
|
103
|
+

|
|
104
|
+
|
|
105
|
+
**2. Model picker filter.** All 168 models discovered from the CPA server, with All / Checked / Unchecked tabs, family chips (GPT, CLAUDE, GEMINI, GROK, …), search and bulk actions. Checked models are the only ones synchronized into the DSH model picker; each shows the protocol it will use (here OpenAI Responses), image input, reasoning levels and context window, and **Edit Parameters** opens its per-model overrides.
|
|
106
|
+
|
|
107
|
+

|
|
108
|
+
|
|
109
|
+
**3. Connection & Authentication.** Per-account settings: the **Enable This Account** switch, base URL, API key stored under the account's own credential ref (`CLI_PROXY_API_KEY_2`), wire protocol, account name, the collapsible advanced section, **Save & Apply** and **Delete Account**.
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
|
|
113
|
+
**4. Plugin update card (collapsed by default).** The real component is rendered offline with fictional update state: it takes a single row showing the current version and update status, and expands to reveal channels, download regions and automatic-update switches. This is not a live GUI screenshot and does not indicate an actual published version.
|
|
114
|
+
|
|
115
|
+

|
|
116
|
+
|
|
117
|
+

|
|
118
|
+
|
|
119
|
+
## Features in detail
|
|
120
|
+
|
|
121
|
+
### Discovery and synchronization
|
|
122
|
+
|
|
123
|
+
- The base URL can be local or remote; suffixes such as `/v1`, `/v1/chat/completions` and `/v1/messages` are stripped.
|
|
124
|
+
- With an empty URL, the plugin tries, in order: the existing route's URL, the `CLIPROXYAPI_BASE_URL` environment variable, and local `127.0.0.1:8317`.
|
|
125
|
+
- The enriched catalog comes from `/v1/models?client_version=pi` (standard OpenAI `data[]` catalogs work too); `owned_by` from `/v1/models` identifies each model's family.
|
|
126
|
+
- All accounts refresh on a shared interval (300 s by default); an unchanged catalog writes no settings.
|
|
127
|
+
|
|
128
|
+
### Model selection
|
|
129
|
+
|
|
130
|
+
- Search, family chips, All / Checked / Unchecked tabs and bulk selection. **Only checked models appear in the model picker**; an empty selection shows all of them.
|
|
131
|
+
- Include / exclude keyword rules filter further.
|
|
132
|
+
- An account that has never saved a selection gets the newest model of each family checked on its first successful probe (at most 12), computed from that server's own catalog; **Reset to Recommended** restores that set at any time.
|
|
133
|
+
|
|
134
|
+
### Per-model overrides
|
|
135
|
+
|
|
136
|
+
**Edit Parameters** on a checked model sets its context window, max output, image input, thinking levels (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`) and request protocol, each resettable to the discovered value.
|
|
137
|
+
|
|
138
|
+
### Multiple accounts
|
|
139
|
+
|
|
140
|
+
- Each account writes its own set of routes: the first account uses `cli-proxy` / `cli-proxy-responses` / `cli-proxy-messages`, later ones `cli-proxy-2*`, `cli-proxy-3*`, …; credential refs are `CLI_PROXY_API_KEY`, `CLI_PROXY_API_KEY_2`, …. The model picker groups models by account name.
|
|
141
|
+
- **Disabling** an account keeps its settings but removes its routes, so its models leave the picker; other accounts are unaffected.
|
|
142
|
+
- **New** accounts start disabled. Fill in the URL and key, click **Probe & Refresh** to preview and check models, then turn on **Enable This Account** and save.
|
|
143
|
+
- An account with a base URL **only connects to that URL** and reports an error when it is unreachable; it never silently falls back to local `:8317`, so two accounts cannot end up on the same server.
|
|
144
|
+
- Provider route IDs of different accounts must not overlap; conflicting changes are rejected.
|
|
145
|
+
- **Deleting** an account removes its routes but keeps its key in the credentials service.
|
|
146
|
+
|
|
147
|
+
### Protocol routing
|
|
148
|
+
|
|
149
|
+
CPA serves every model on OpenAI Chat, OpenAI Responses and Anthropic Messages, translating when the entry protocol differs from the upstream one. The default auto mode sends each model over its upstream's own protocol:
|
|
150
|
+
|
|
151
|
+
| Model family (from `owned_by` and the model id) | Protocol | Route (for `cli-proxy`) |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| Claude (including `devin/claude-*`, Antigravity Claude) | Anthropic Messages `/v1/messages` | `cli-proxy-messages` |
|
|
154
|
+
| OpenAI / Codex / GPT, xAI Grok | OpenAI Responses `/v1/responses` | `cli-proxy-responses` |
|
|
155
|
+
| Gemini, DeepSeek, Kimi, GLM, SWE, gpt-oss, … | OpenAI Chat `/v1/chat/completions` | `cli-proxy` |
|
|
156
|
+
|
|
157
|
+
- DSH custom routes cannot speak Gemini's native `generateContent`, so Gemini uses OpenAI Chat.
|
|
158
|
+
- A DSH route has a single protocol, so models are split across the three routes; a route left without models is removed. When the default model moves to another route, `agent-default-model` follows it.
|
|
159
|
+
- Claude 4.6+ / 5.x / Fable use adaptive thinking (`effort`); older Claude models use a token budget.
|
|
160
|
+
- Switch to one protocol for every model, or set a protocol per model under **Edit Parameters**.
|
|
161
|
+
- Other fields you add to a managed route by hand (such as `retryPolicy`) are kept.
|
|
162
|
+
|
|
163
|
+
## Updating this plugin
|
|
164
|
+
|
|
165
|
+
The **Plugin Updates** card near the top of the settings panel is collapsed to one row by default, showing only the current version and update status; click it to expand channels, download regions and automatic-update settings. Background checks still follow the saved switches, and polling never resets the expanded state. It manages only `dsh-cliproxyapi-pro`. It does not update the CPA server or DSH, or change CPA routes, accounts or model selections. Update settings save immediately; the card polls independently without reloading unsaved account forms.
|
|
166
|
+
|
|
167
|
+
> **Downloading is not installing.** Current DSH versions cannot replace an installed plugin while running. This plugin only checks versions and downloads verified offline packages: it never automatically installs, uninstalls, overwrites source code, or restarts DSH. Close DSH before manually upgrading, then start it again.
|
|
168
|
+
|
|
169
|
+
### Channels, regions and automatic controls
|
|
170
|
+
|
|
171
|
+
| Setting | Default | Behavior |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| Update channel | Stable (`stable`) | Stable / Beta / Dev read the npm `latest` / `beta` / `dev` dist-tags respectively. An unpublished Beta / Dev channel reports an error rather than silently falling back to Stable. |
|
|
174
|
+
| Download region | Auto (`auto`) | Auto races global npmjs and Mainland China npmmirror, selecting the first source with **valid version metadata**. Global (`global`) uses only `https://registry.npmjs.org`; Mainland China (`cn`) uses `https://registry.npmmirror.com` and its official `cdn.npmmirror.com` package host. The offline package uses the selected source, with at most 3 HTTPS redirects validated against the host allowlist and exact package/version path; it never falls back across regions. |
|
|
175
|
+
| Automatically check for updates | On | Check about 3 seconds after plugin startup or rescheduling update settings, then every 6 hours. **Check for Updates** remains available when disabled. |
|
|
176
|
+
| Automatically download updates | Off | Download and verify an offline package only when an **automatic check** finds a newer version. Never installs or restarts automatically. Enabling this while automatic checks are off does not trigger background downloads. |
|
|
177
|
+
|
|
178
|
+
- Strict SemVer comparison offers downloads only when the selected channel is newer than the running version; there is no automatic downgrade. Automatic region selection never falls back across channels.
|
|
179
|
+
- The region affects only this plugin's update metadata and package downloads, **not CPA connections, model requests, or other plugins' installation sources**.
|
|
180
|
+
- Check again after switching channel or region. Opening the card, polling, or reloading status only reads in-memory state and does not itself contact an update source; background checks follow the controls above.
|
|
181
|
+
- Errors are localized, including unpublished channels, network failures, package integrity failures and storage failures, without exposing backend stack traces.
|
|
182
|
+
|
|
183
|
+
### Download, verification and offline upgrade
|
|
184
|
+
|
|
185
|
+
1. Click **Check for Updates**. If a newer version is available, click **Download Update** and confirm its version, or wait for enabled automatic checks and downloads.
|
|
186
|
+
2. The download must match the npm metadata's **SHA-512** integrity, then pass gzip / tar, expected file and directory, package name and version checks. Path traversal, links and other special entries, dependencies and installation lifecycle scripts are rejected. The package is saved without extracting into the installation directory or executing its code.
|
|
187
|
+
3. After verification, the card displays the absolute package path and an upgrade command when applicable. Packages are stored at `<profile dir>/.dsh-cliproxyapi/updates/dsh-cliproxyapi-pro-<version>.tgz`.
|
|
188
|
+
4. **Save your work and fully close DSH first**, then run the card's command in a terminal. This example is illustrative; use the actual profile name and absolute path from your card:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
dsh plugin --profile 'desktop' add '/absolute/path/dsh-cliproxyapi-pro-<version>.tgz'
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
5. Start DSH again to load the new version. Check results and downloaded-package notices do not persist across plugin reloads; the offline files remain on disk. Remove old downloads yourself when no longer needed; the plugin does not automatically clean them up.
|
|
195
|
+
|
|
196
|
+
**Linked local installations (`link:`)** can check and download packages, but do not receive an upgrade command and their source directories are never overwritten. To keep the development setup, manually update the Git source at an appropriate time, then restart DSH. Reinstalling from an offline package changes the plugin's installation source from the link to the package.
|
|
197
|
+
|
|
198
|
+
## Agent tool and slash commands
|
|
199
|
+
|
|
200
|
+
### The `cliproxyapi` tool
|
|
201
|
+
|
|
202
|
+
The DSH agent uses this tool to inspect and configure the plugin; just ask in plain language.
|
|
203
|
+
|
|
204
|
+
| `action` | Effect |
|
|
205
|
+
|---|---|
|
|
206
|
+
| `status` | Show every account (or only `account`) with its state and models |
|
|
207
|
+
| `refresh` | Probe and sync now; without `account`, all accounts |
|
|
208
|
+
| `configure` | Update one account (the first by default), then refresh it |
|
|
209
|
+
| `add_account` | Create an account; enabled when `baseURL` is given, otherwise disabled |
|
|
210
|
+
| `remove_account` | Delete the `account` and its routes |
|
|
211
|
+
|
|
212
|
+
Parameters (all optional except `action`):
|
|
213
|
+
|
|
214
|
+
| Parameter | Meaning |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `account` | Account id (e.g. `default`, `account-2`), or its provider route ID or display name |
|
|
217
|
+
| `enabled` | Enable or disable the account |
|
|
218
|
+
| `baseURL` | CPA URL such as `http://127.0.0.1:8317`; an empty string means auto-discover |
|
|
219
|
+
| `apiKey` | Bearer key, stored under the account's `apiKeyEnv` ref |
|
|
220
|
+
| `apiKeyEnv` | Credential ref name (`[A-Za-z_][A-Za-z0-9_]*`) |
|
|
221
|
+
| `provider` | `llm-pi-ai` provider route ID, unique per account |
|
|
222
|
+
| `displayName` | Account name, also the group title in the model picker |
|
|
223
|
+
| `protocolMode` | `auto` (native protocol per family, default) or `fixed` |
|
|
224
|
+
| `protocol` | Protocol used in `fixed` mode: `openai-completions` / `openai-responses` / `anthropic-messages` |
|
|
225
|
+
| `selectedModels` | Model ids shown in the picker; `[]` shows all |
|
|
226
|
+
| `includePrefix` / `excludePrefix` | Comma-separated model id keywords |
|
|
227
|
+
| `modelOverrides` | `{ [modelId]: { contextWindow?, maxTokens?, image?, reasoningLevels?, protocol? } }`, replacing the whole map |
|
|
228
|
+
|
|
229
|
+
Examples:
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{ "action": "configure", "baseURL": "http://127.0.0.1:8317", "apiKey": "sk-...", "selectedModels": ["gpt-6.1-sol", "claude-opus-5-5"] }
|
|
233
|
+
{ "action": "add_account", "displayName": "Backup CPA", "baseURL": "https://other-cpa:8317", "apiKey": "sk-...", "selectedModels": ["gpt-6-astra"] }
|
|
234
|
+
{ "action": "configure", "account": "account-2", "enabled": false }
|
|
235
|
+
{ "action": "remove_account", "account": "account-2" }
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
The output has `accounts[]` (each with `id`, `displayName`, `provider`, `enabled`, `state`, `endpoint`, `modelCount`, `totalDiscovered`, `error`) and a text `summary`. `state` is one of `idle`, `probing`, `connected`, `disabled`, `error`.
|
|
239
|
+
|
|
240
|
+
### Slash commands
|
|
241
|
+
|
|
242
|
+
- `/cpa-status` — show every account's status.
|
|
243
|
+
- `/cpa-refresh` — refresh every account now, including a catalog probe of disabled ones.
|
|
244
|
+
|
|
245
|
+
### HTTP API
|
|
246
|
+
|
|
247
|
+
Used by the settings panel. Requires the DSH Web session's authentication; POST accepts only same-origin requests from loopback or trusted hosts.
|
|
248
|
+
|
|
249
|
+
| Method | Path | Body | Meaning |
|
|
250
|
+
|---|---|---|---|
|
|
251
|
+
| GET | `/api/dsh-cliproxyapi/status` | — | `{ ok, global, accounts[] }` |
|
|
252
|
+
| POST | `/api/dsh-cliproxyapi/refresh` | `{ accountId? }` | Refresh one or all accounts |
|
|
253
|
+
| POST | `/api/dsh-cliproxyapi/save` | `{ accountId?, …account fields, apiKey?, clearApiKey?, refreshIntervalSeconds?, probeTimeoutMs? }` | Save an account (the first by default); a body with only global fields saves just the globals |
|
|
254
|
+
| POST | `/api/dsh-cliproxyapi/accounts/add` | Optional account fields | Create a disabled account; returns `createdId` |
|
|
255
|
+
| POST | `/api/dsh-cliproxyapi/accounts/remove` | `{ accountId }` | Delete an account and its routes |
|
|
256
|
+
| GET | `/api/dsh-cliproxyapi/updates/status` | — | Read update state without contacting a registry |
|
|
257
|
+
| POST | `/api/dsh-cliproxyapi/updates/check` | `{}` | Check the selected channel and region now; a manual check does not trigger automatic downloading |
|
|
258
|
+
| POST | `/api/dsh-cliproxyapi/updates/save` | `{ autoCheck?, autoDownload?, channel?, region? }` | Save only these four update preferences, independently of accounts |
|
|
259
|
+
| POST | `/api/dsh-cliproxyapi/updates/download` | `{ version }` | Download the newer version confirmed by the latest check, verify it, and save an offline package without installing |
|
|
260
|
+
|
|
261
|
+
Update operation responses use `{ ok, update }`. State includes `currentVersion`, `latestVersion`, `available`, `channel`, `region`, `effectiveRegion`, `autoCheck`, `autoDownload`, `checking`, `downloading`, `lastCheckedAt`, `error` / `errorCode`, `blockedReason`, `downloadedVersion`, `downloadPath` and `upgradeCommand`. Fields without a check or download result are `null`. `channel` is `stable` / `beta` / `dev`; `region` is `auto` / `global` / `cn`; `effectiveRegion` is the `global` / `cn` source used by the last successful check (`null` before one).
|
|
262
|
+
|
|
263
|
+
Failures use a top-level `errorCode` or `update.errorCode`; HTTP status or `ok` alone does not establish success. Common codes include `network-error`, `invalid-metadata`, `channel-unavailable`, `integrity-error`, `invalid-package`, `storage-error`, `busy`, `stale-version` and `disposed`. In addition to host authentication and trusted-host policy, update POSTs **require an explicit `Origin` matching the actual connection protocol and Host exactly**. Missing or mismatched origins are rejected; the account endpoints' compatibility with absent origins does not apply. Plain unauthenticated `curl` cannot call these endpoints. Scheme validation uses the actual connection, not arbitrary `Forwarded` / `X-Forwarded-*` claims; the `Origin` must match end to end. A proxy that terminates HTTPS and connects to DSH over HTTP will have update POSTs rejected. In that case, use the local DSH page on the machine running DSH first; compatibility with every reverse-proxy deployment is not implied.
|
|
264
|
+
|
|
265
|
+
## Storage and configuration
|
|
266
|
+
|
|
267
|
+
- **State file**: `<profile dir>/.dsh-cliproxyapi/state.json` holds accounts, selections and overrides (no keys).
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"version": 2,
|
|
272
|
+
"refreshIntervalSeconds": 300,
|
|
273
|
+
"probeTimeoutMs": 5000,
|
|
274
|
+
"accounts": [
|
|
275
|
+
{
|
|
276
|
+
"id": "default", "enabled": true, "provider": "cli-proxy", "displayName": "CLI Proxy API",
|
|
277
|
+
"baseURL": "https://cpa.example.com", "apiKeyEnv": "CLI_PROXY_API_KEY",
|
|
278
|
+
"protocol": "openai-completions", "protocolMode": "auto",
|
|
279
|
+
"includePrefix": "", "excludePrefix": "", "selectedModels": ["gpt-6.1-sol"], "modelOverrides": {}
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
The file is re-read on every access; after a manual edit, click **Probe & Refresh**. A single-account file from 1.3.x and earlier migrates automatically into account `default` with the same routes, key and selection, and the original is kept as `state.v1.json`.
|
|
286
|
+
|
|
287
|
+
- **Update settings**: stored separately at `<profile dir>/.dsh-cliproxyapi/update-settings.json`. They neither extend nor rewrite the account `state.json` v2 file, nor access credentials. When this file does not yet exist, defaults are:
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"version": 1,
|
|
292
|
+
"autoCheck": true,
|
|
293
|
+
"autoDownload": false,
|
|
294
|
+
"channel": "stable",
|
|
295
|
+
"region": "auto"
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Panel saves take effect immediately. After editing this file manually, reload the plugin or restart DSH to re-read it. Corrupt, structurally invalid, invalid-field or unreadable files use safe defaults with automatic network checks disabled. Check results, the candidate version, download notices and commands are in-memory only and reset on plugin reload; downloaded packages remain in the separate `updates` subdirectory for you to clean up when needed.
|
|
300
|
+
- **Keys**: stored and resolved by ref through the DSH `credentials` service, falling back to an environment variable of the same name.
|
|
301
|
+
- **Environment**: `CLIPROXYAPI_BASE_URL` is used only for auto-discovery of accounts without a base URL.
|
|
302
|
+
- **Plugin row config**: the plugin row's `config` in `cordis.patch.yml` is overlaid on the state file at startup: `accounts` replaces the account list, other fields apply to the first account. Normally keep it `{}` and configure through the panel or the tool.
|
|
303
|
+
|
|
304
|
+
## Upgrading and uninstalling
|
|
305
|
+
|
|
306
|
+
- **Upgrade**: preferably download a verified offline package through the card above, save your work and close DSH, run the displayed `dsh plugin --profile 'name' add 'absolute-package-path'` command, then restart. There is no need to uninstall first. Alternatively, with DSH closed, run `dsh plugin --profile <profile name> add dsh-cliproxyapi-pro@latest` to upgrade from npm. Accounts, selections and parameters remain in the profile directory, and keys in the credentials service; the updater never rewrites them. To preserve a linked source installation, update its source yourself rather than reinstalling from an offline package.
|
|
307
|
+
- **Uninstall**: uninstall on the **Plugins** page. The synchronized model routes are stored in DSH settings and are not removed with the plugin; to remove those models from the picker too, disable or delete every account before uninstalling.
|
|
308
|
+
|
|
309
|
+
## FAQ
|
|
310
|
+
|
|
311
|
+
**No models in the model picker?**
|
|
312
|
+
Check that the account has **Enable This Account** on and at least one model checked (or an empty selection, meaning all). Run `/cpa-status` to see every account's state.
|
|
313
|
+
|
|
314
|
+
**"none of the selected models matched"?**
|
|
315
|
+
None of the checked models exists on this server (typical after switching servers). The panel still lists the server's models — check new ones, or click **Reset to Recommended**, then save.
|
|
316
|
+
|
|
317
|
+
**Connection failed / "no usable CPA service found"?**
|
|
318
|
+
Make sure the base URL is reachable from the machine running DSH and the API key is correct. An account with a URL never tries another address; the error lists every address tried and why it failed.
|
|
319
|
+
|
|
320
|
+
**A just-published version won't install?**
|
|
321
|
+
The pnpm used by DSH may enforce a waiting period for new releases (`minimumReleaseAge`); the install screen shows which version it actually installed. Try again later or name the version explicitly.
|
|
322
|
+
|
|
323
|
+
**Why automatic downloads, but no automatic installation?**
|
|
324
|
+
Current DSH versions reject replacing an installed plugin while running. To avoid interrupting sessions using this plugin's routes, the updater never tries to uninstall, overwrite files or restart DSH; it prepares an offline package for an upgrade after DSH is closed.
|
|
325
|
+
|
|
326
|
+
**No release available on Beta / Dev?**
|
|
327
|
+
A channel is usable only after the maintainer publishes its npm dist-tag. Stable is never presented as an unpublished Beta / Dev build. A channel version no newer than the running version does not offer a downgrade download either.
|
|
328
|
+
|
|
329
|
+
**The update card says "update service unavailable" or "network error"?**
|
|
330
|
+
The collapsed row names the actual cause. **Update service unavailable** means the page runs newer client code than the host plugin (disable and re-enable this plugin on the Plugins page, then refresh the page). **Network error** means requests to npmjs or the Mainland China mirror failed; switch the download region and check proxies/firewalls. **Channel unpublished** means that channel has no matching release yet. Expand the card for the matching explanation.
|
|
331
|
+
|
|
332
|
+
**Downloaded the update and restarted, but the version did not change?**
|
|
333
|
+
Downloading and verification do not install anything. Exit DSH, run the card's upgrade command, then start it again. Linked installations do not receive that command; update their source manually to keep the link. If a plugin reload clears the download notice, the offline file remains in the profile's `updates` directory.
|
|
334
|
+
|
|
335
|
+
## AI installation guide
|
|
336
|
+
|
|
337
|
+
> **For the AI agent in DeepSeek Harness**: when the user asks you to install or configure this plugin, follow these steps. The package has no npm dependencies and no build scripts.
|
|
338
|
+
|
|
339
|
+
1. **Install**: call `plugin_manager` with `{"action": "install_bundle", "target": "dsh-cliproxyapi-pro", "enabled": true}`. Read `application` and `warnings` in the result; `restart-required` means DSH must restart before the new code runs.
|
|
340
|
+
2. **Configure** with the `cliproxyapi` tool:
|
|
341
|
+
- Local CPA on `http://127.0.0.1:8317` without auth: nothing to configure; call `{"action": "refresh"}`.
|
|
342
|
+
- Remote URL or key: `{"action": "configure", "baseURL": "...", "apiKey": "..."}` (first account), or `{"action": "add_account", ...}` for another account. Pass `"account": "<id>"` to target a specific account.
|
|
343
|
+
- Narrow the picker with `selectedModels` (exact ids from the `status` output).
|
|
344
|
+
3. **Verify**: `{"action": "status"}` shows `state: "connected"` and `modelCount > 0` for each enabled account. Tell the user the models are in the DSH model picker under the account's name, and that accounts are managed in **Sidebar → Plugins → CLIProxyAPI** or **Settings → Built-in plugins → CLIProxyAPI**.
|
|
345
|
+
|
|
346
|
+
Never echo API keys back to the user or write them into files.
|
|
347
|
+
|
|
348
|
+
## Development
|
|
349
|
+
|
|
350
|
+
```text
|
|
351
|
+
lib/index.js Host plugin (discovery, sync, multi-account controller, tool, commands, HTTP API)
|
|
352
|
+
lib/client.js Web settings panel (ModuleLoader; isolated update card and account forms, no build)
|
|
353
|
+
lib/updater.js Update settings, SemVer/channels, region race, SHA-512/package checks, offline storage
|
|
354
|
+
locale/*.json Title and description shown by the plugin manager
|
|
355
|
+
cordis.patch.yml Bundle patch inserting the dsh-cliproxyapi-pro row
|
|
356
|
+
tests/ node:test unit and integration tests
|
|
357
|
+
.github/workflows/ CI (tests) and release (GitHub Release + npm trusted publishing)
|
|
358
|
+
assets/screenshots/ README screenshots (listed in screenshots.json for plugin storefronts)
|
|
359
|
+
AGENTS.md Conventions, architecture and invariants for coding agents
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
git clone https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git
|
|
364
|
+
cd dsh-cliproxyapi-pro
|
|
365
|
+
npm test # run the tests
|
|
366
|
+
npm run check # syntax check + tests
|
|
367
|
+
npm run pack:check # list the files a packed bundle contains
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
`npm run check` syntax-checks all three `lib/*.js` modules and runs every test. Offline update tests are `tests/updater.test.mjs` (settings, SemVer, regions, download integrity and package structure), `tests/update-routes.test.mjs` (HTTP authentication and same-origin policy), and `tests/client.test.mjs` (the update card and request lifecycle). They never access the real network or profile. `npm run pack:check` should include `lib/updater.js`, but not tests or screenshots; no runtime dependencies need installing.
|
|
371
|
+
|
|
372
|
+
Releasing is a pushed `v<version>` tag: GitHub Actions runs the tests, creates a GitHub Release with the package attached, and publishes to npm through npm trusted publishing (no token involved) with a provenance statement. Stable releases publish to npm `latest`; Beta / Dev prereleases publish to `beta` / `dev` and are marked as GitHub prereleases, without replacing the stable channel. The updater checks registry-provided SHA-512 integrity and package structure only; it does not verify publisher signatures or npm provenance.
|
|
373
|
+
|
|
374
|
+
Read [AGENTS.md](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/AGENTS.md) before changing code; see [CHANGELOG.md](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/CHANGELOG.md) for history. Issues and pull requests are welcome — when you change the documentation, update both the Chinese and the English README.
|
|
375
|
+
|
|
376
|
+
## License
|
|
377
|
+
|
|
378
|
+
[MIT](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/LICENSE)
|