dsh-cliproxyapi-pro 0.0.0-stage → 1.4.1
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 +48 -0
- package/LICENSE +21 -0
- package/README.en.md +299 -0
- package/README.md +296 -2
- package/cordis.patch.yml +4 -0
- package/icon.svg +9 -0
- package/lib/client.js +1867 -0
- package/lib/index.js +2249 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +68 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this plugin. Versions follow [Semantic Versioning](https://semver.org/).
|
|
4
|
+
|
|
5
|
+
## 1.4.1 — 2026-10-19
|
|
6
|
+
|
|
7
|
+
Documentation and release tooling only; the plugin code is unchanged from 1.4.0.
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- `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.
|
|
11
|
+
- 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.
|
|
12
|
+
|
|
13
|
+
## 1.4.0 — 2026-10-19
|
|
14
|
+
|
|
15
|
+
First public release.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- **Multiple CLIProxyAPI accounts.** Each account has its own base URL, API key (own credential ref), provider route ID, protocol mode, model selection and per-model overrides, and synchronizes into its own `llm-pi-ai` routes (`cli-proxy-2`, `cli-proxy-2-responses`, `cli-proxy-2-messages`, …).
|
|
19
|
+
- **Per-account enable switch.** A disabled account keeps its settings but its routes are removed, so its models leave the picker. New accounts start disabled; a manual refresh still probes them so models can be picked before enabling.
|
|
20
|
+
- Settings panel account bar: switch accounts, **+ Add Account**, **Delete Account**, credential-ref field.
|
|
21
|
+
- `cliproxyapi` tool: `add_account` and `remove_account` actions, `account`, `enabled` and `apiKeyEnv` parameters; output lists every account.
|
|
22
|
+
- HTTP routes `POST /api/dsh-cliproxyapi/accounts/add` and `/accounts/remove`; `refresh` and `save` accept `accountId`.
|
|
23
|
+
- English `README.md` and Chinese `README.zh.md` with captioned screenshots; `screenshots.json` for plugin storefronts; `LICENSE`, `AGENTS.md`, `CHANGELOG.md`.
|
|
24
|
+
- GitHub Actions: CI (Ubuntu + Windows, Node 22 / 24) and a tag-triggered release that attaches the packed bundle and optionally publishes to npm.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- `state.json` is now `{ version: 2, refreshIntervalSeconds, probeTimeoutMs, accounts: [...] }`. A v1 single-account file migrates automatically into account `default` with the same routes, key and selection; the original is kept as `state.v1.json`.
|
|
28
|
+
- An account with an explicit base URL only probes that URL and never falls back to local `:8317`, the existing route or `CLIPROXYAPI_BASE_URL`.
|
|
29
|
+
- Overlapping provider route IDs between accounts are rejected on save; an overlapping account in a hand-edited file is reported as an error and never writes or removes another account's routes.
|
|
30
|
+
- Settings writes from concurrent account syncs are serialized.
|
|
31
|
+
- `/cpa-status` and `/cpa-refresh` cover every account.
|
|
32
|
+
- The DSH version requirement moved to top-level `engines.dsh`, where DSH reads it; `./icon` is exported.
|
|
33
|
+
- `engines.node` is now `>=22` (the versions CI tests).
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
- **First-run selection no longer uses hard-coded model ids.** An account without a saved selection is seeded once, on its first successful probe, with the newest model of each family from its own server's catalog (at most 12). Previously a fresh install pre-selected 7 fixed ids that most servers do not offer, so nothing reached the picker.
|
|
37
|
+
- **Reset to Recommended** uses the same catalog-derived list (with its count) instead of the fixed 7.
|
|
38
|
+
- Saving a new account before its catalog was ever probed no longer stores an empty selection.
|
|
39
|
+
- When a saved selection matches nothing on the server, the error names the server and the discovered models stay visible in the panel.
|
|
40
|
+
|
|
41
|
+
## 1.3.0
|
|
42
|
+
|
|
43
|
+
- Per-model native protocol routing (`protocolMode: "auto"`): Claude via Anthropic Messages, GPT/Codex/Grok via OpenAI Responses, others via OpenAI Chat, one `llm-pi-ai` route per protocol; the default model follows its route.
|
|
44
|
+
- Per-model protocol override and fixed protocol mode.
|
|
45
|
+
|
|
46
|
+
## 1.2.0 and earlier
|
|
47
|
+
|
|
48
|
+
- Auto-discovery of CLIProxyAPI, model selection filter, per-model parameter editor, credentials-service key storage, `/cpa-status` and `/cpa-refresh`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bowen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
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
|
+
- **Secure**: API keys live only in the DSH credentials service, never in configuration files.
|
|
18
|
+
- **Zero dependencies**: no npm dependencies and no build step; installs in seconds.
|
|
19
|
+
|
|
20
|
+
Works with DSH `0.2.0-rc.1` and later (desktop and web).
|
|
21
|
+
|
|
22
|
+
## Contents
|
|
23
|
+
|
|
24
|
+
- [Installation](#installation)
|
|
25
|
+
- [Getting started](#getting-started)
|
|
26
|
+
- [Screenshots](#screenshots)
|
|
27
|
+
- [Features in detail](#features-in-detail)
|
|
28
|
+
- [Agent tool and slash commands](#agent-tool-and-slash-commands)
|
|
29
|
+
- [Storage and configuration](#storage-and-configuration)
|
|
30
|
+
- [Upgrading and uninstalling](#upgrading-and-uninstalling)
|
|
31
|
+
- [FAQ](#faq)
|
|
32
|
+
- [AI installation guide](#ai-installation-guide)
|
|
33
|
+
- [Development](#development)
|
|
34
|
+
- [License](#license)
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
### Option 1: the DSH Plugins page (recommended)
|
|
41
|
+
|
|
42
|
+
1. Open DSH and click **Plugins** in the left sidebar.
|
|
43
|
+
2. Click **Add plugin** at the top of the page.
|
|
44
|
+
3. Enter the package name:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
dsh-cliproxyapi-pro
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
To pin a version, write `dsh-cliproxyapi-pro@1.4.1`.
|
|
51
|
+
4. Click **Install**. When it finishes, the dialog offers to enable the plugin right away — accept it.
|
|
52
|
+
|
|
53
|
+
> If downloads are slow in mainland China, open **Registry** next to the input and choose **the mainland China mirror**.
|
|
54
|
+
|
|
55
|
+
### Option 2: ask the agent in DSH
|
|
56
|
+
|
|
57
|
+
Just say in a DSH conversation:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
Install the DSH plugin dsh-cliproxyapi-pro
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
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-…".
|
|
64
|
+
|
|
65
|
+
### Option 3: command line
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
dsh plugin --profile <profile name> add dsh-cliproxyapi-pro
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
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.
|
|
72
|
+
|
|
73
|
+
### Option 4: from GitHub (without npm)
|
|
74
|
+
|
|
75
|
+
In **Add plugin**, or as the `plugin_manager` `target`, you can also enter:
|
|
76
|
+
|
|
77
|
+
| Source | What to enter |
|
|
78
|
+
|---|---|
|
|
79
|
+
| A released version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#v1.4.1` |
|
|
80
|
+
| Latest development version | `git+https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git#main` |
|
|
81
|
+
| 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 |
|
|
82
|
+
| Local source (development) | Absolute path of a cloned repository; installed as a link, so code changes go live when the plugin reloads |
|
|
83
|
+
|
|
84
|
+
All versions are listed under [Releases](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/releases).
|
|
85
|
+
|
|
86
|
+
## Getting started
|
|
87
|
+
|
|
88
|
+
1. **Open the settings panel**: sidebar **Plugins** → **CLIProxyAPI**, or **Settings** → **Built-in plugins** → the **CLIProxyAPI** tab.
|
|
89
|
+
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**.
|
|
90
|
+
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**.
|
|
91
|
+
4. **Use them**: open the model picker in a conversation; the models appear in a group named after the account.
|
|
92
|
+
|
|
93
|
+
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.
|
|
94
|
+
|
|
95
|
+
## Screenshots
|
|
96
|
+
|
|
97
|
+
The panel follows the DSH display language; the screenshots show the Chinese UI.
|
|
98
|
+
|
|
99
|
+
**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.
|
|
100
|
+
|
|
101
|
+

|
|
102
|
+
|
|
103
|
+
**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.
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
**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**.
|
|
108
|
+
|
|
109
|
+

|
|
110
|
+
|
|
111
|
+
## Features in detail
|
|
112
|
+
|
|
113
|
+
### Discovery and synchronization
|
|
114
|
+
|
|
115
|
+
- The base URL can be local or remote; suffixes such as `/v1`, `/v1/chat/completions` and `/v1/messages` are stripped.
|
|
116
|
+
- 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`.
|
|
117
|
+
- 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.
|
|
118
|
+
- All accounts refresh on a shared interval (300 s by default); an unchanged catalog writes no settings.
|
|
119
|
+
|
|
120
|
+
### Model selection
|
|
121
|
+
|
|
122
|
+
- 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.
|
|
123
|
+
- Include / exclude keyword rules filter further.
|
|
124
|
+
- 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.
|
|
125
|
+
|
|
126
|
+
### Per-model overrides
|
|
127
|
+
|
|
128
|
+
**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.
|
|
129
|
+
|
|
130
|
+
### Multiple accounts
|
|
131
|
+
|
|
132
|
+
- 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.
|
|
133
|
+
- **Disabling** an account keeps its settings but removes its routes, so its models leave the picker; other accounts are unaffected.
|
|
134
|
+
- **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.
|
|
135
|
+
- 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.
|
|
136
|
+
- Provider route IDs of different accounts must not overlap; conflicting changes are rejected.
|
|
137
|
+
- **Deleting** an account removes its routes but keeps its key in the credentials service.
|
|
138
|
+
|
|
139
|
+
### Protocol routing
|
|
140
|
+
|
|
141
|
+
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:
|
|
142
|
+
|
|
143
|
+
| Model family (from `owned_by` and the model id) | Protocol | Route (for `cli-proxy`) |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| Claude (including `devin/claude-*`, Antigravity Claude) | Anthropic Messages `/v1/messages` | `cli-proxy-messages` |
|
|
146
|
+
| OpenAI / Codex / GPT, xAI Grok | OpenAI Responses `/v1/responses` | `cli-proxy-responses` |
|
|
147
|
+
| Gemini, DeepSeek, Kimi, GLM, SWE, gpt-oss, … | OpenAI Chat `/v1/chat/completions` | `cli-proxy` |
|
|
148
|
+
|
|
149
|
+
- DSH custom routes cannot speak Gemini's native `generateContent`, so Gemini uses OpenAI Chat.
|
|
150
|
+
- 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.
|
|
151
|
+
- Claude 4.6+ / 5.x / Fable use adaptive thinking (`effort`); older Claude models use a token budget.
|
|
152
|
+
- Switch to one protocol for every model, or set a protocol per model under **Edit Parameters**.
|
|
153
|
+
- Other fields you add to a managed route by hand (such as `retryPolicy`) are kept.
|
|
154
|
+
|
|
155
|
+
## Agent tool and slash commands
|
|
156
|
+
|
|
157
|
+
### The `cliproxyapi` tool
|
|
158
|
+
|
|
159
|
+
The DSH agent uses this tool to inspect and configure the plugin; just ask in plain language.
|
|
160
|
+
|
|
161
|
+
| `action` | Effect |
|
|
162
|
+
|---|---|
|
|
163
|
+
| `status` | Show every account (or only `account`) with its state and models |
|
|
164
|
+
| `refresh` | Probe and sync now; without `account`, all accounts |
|
|
165
|
+
| `configure` | Update one account (the first by default), then refresh it |
|
|
166
|
+
| `add_account` | Create an account; enabled when `baseURL` is given, otherwise disabled |
|
|
167
|
+
| `remove_account` | Delete the `account` and its routes |
|
|
168
|
+
|
|
169
|
+
Parameters (all optional except `action`):
|
|
170
|
+
|
|
171
|
+
| Parameter | Meaning |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `account` | Account id (e.g. `default`, `account-2`), or its provider route ID or display name |
|
|
174
|
+
| `enabled` | Enable or disable the account |
|
|
175
|
+
| `baseURL` | CPA URL such as `http://127.0.0.1:8317`; an empty string means auto-discover |
|
|
176
|
+
| `apiKey` | Bearer key, stored under the account's `apiKeyEnv` ref |
|
|
177
|
+
| `apiKeyEnv` | Credential ref name (`[A-Za-z_][A-Za-z0-9_]*`) |
|
|
178
|
+
| `provider` | `llm-pi-ai` provider route ID, unique per account |
|
|
179
|
+
| `displayName` | Account name, also the group title in the model picker |
|
|
180
|
+
| `protocolMode` | `auto` (native protocol per family, default) or `fixed` |
|
|
181
|
+
| `protocol` | Protocol used in `fixed` mode: `openai-completions` / `openai-responses` / `anthropic-messages` |
|
|
182
|
+
| `selectedModels` | Model ids shown in the picker; `[]` shows all |
|
|
183
|
+
| `includePrefix` / `excludePrefix` | Comma-separated model id keywords |
|
|
184
|
+
| `modelOverrides` | `{ [modelId]: { contextWindow?, maxTokens?, image?, reasoningLevels?, protocol? } }`, replacing the whole map |
|
|
185
|
+
|
|
186
|
+
Examples:
|
|
187
|
+
|
|
188
|
+
```json
|
|
189
|
+
{ "action": "configure", "baseURL": "http://127.0.0.1:8317", "apiKey": "sk-...", "selectedModels": ["gpt-6.1-sol", "claude-opus-5-5"] }
|
|
190
|
+
{ "action": "add_account", "displayName": "Backup CPA", "baseURL": "https://other-cpa:8317", "apiKey": "sk-...", "selectedModels": ["gpt-6-astra"] }
|
|
191
|
+
{ "action": "configure", "account": "account-2", "enabled": false }
|
|
192
|
+
{ "action": "remove_account", "account": "account-2" }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
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`.
|
|
196
|
+
|
|
197
|
+
### Slash commands
|
|
198
|
+
|
|
199
|
+
- `/cpa-status` — show every account's status.
|
|
200
|
+
- `/cpa-refresh` — refresh every account now, including a catalog probe of disabled ones.
|
|
201
|
+
|
|
202
|
+
### HTTP API
|
|
203
|
+
|
|
204
|
+
Used by the settings panel. Requires the DSH Web session's authentication; POST accepts only same-origin requests from loopback or trusted hosts.
|
|
205
|
+
|
|
206
|
+
| Method | Path | Body | Meaning |
|
|
207
|
+
|---|---|---|---|
|
|
208
|
+
| GET | `/api/dsh-cliproxyapi/status` | — | `{ ok, global, accounts[] }` |
|
|
209
|
+
| POST | `/api/dsh-cliproxyapi/refresh` | `{ accountId? }` | Refresh one or all accounts |
|
|
210
|
+
| 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 |
|
|
211
|
+
| POST | `/api/dsh-cliproxyapi/accounts/add` | Optional account fields | Create a disabled account; returns `createdId` |
|
|
212
|
+
| POST | `/api/dsh-cliproxyapi/accounts/remove` | `{ accountId }` | Delete an account and its routes |
|
|
213
|
+
|
|
214
|
+
## Storage and configuration
|
|
215
|
+
|
|
216
|
+
- **State file**: `<profile dir>/.dsh-cliproxyapi/state.json` holds accounts, selections and overrides (no keys).
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"version": 2,
|
|
221
|
+
"refreshIntervalSeconds": 300,
|
|
222
|
+
"probeTimeoutMs": 5000,
|
|
223
|
+
"accounts": [
|
|
224
|
+
{
|
|
225
|
+
"id": "default", "enabled": true, "provider": "cli-proxy", "displayName": "CLI Proxy API",
|
|
226
|
+
"baseURL": "https://cpa.example.com", "apiKeyEnv": "CLI_PROXY_API_KEY",
|
|
227
|
+
"protocol": "openai-completions", "protocolMode": "auto",
|
|
228
|
+
"includePrefix": "", "excludePrefix": "", "selectedModels": ["gpt-6.1-sol"], "modelOverrides": {}
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
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`.
|
|
235
|
+
|
|
236
|
+
- **Keys**: stored and resolved by ref through the DSH `credentials` service, falling back to an environment variable of the same name.
|
|
237
|
+
- **Environment**: `CLIPROXYAPI_BASE_URL` is used only for auto-discovery of accounts without a base URL.
|
|
238
|
+
- **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.
|
|
239
|
+
|
|
240
|
+
## Upgrading and uninstalling
|
|
241
|
+
|
|
242
|
+
- **Upgrade**: uninstall and reinstall on the **Plugins** page, or run `dsh plugin --profile <profile name> add dsh-cliproxyapi-pro@latest`. Accounts, selections and parameters live in the profile directory and keys in the credentials service, so reinstalling keeps them.
|
|
243
|
+
- **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.
|
|
244
|
+
|
|
245
|
+
## FAQ
|
|
246
|
+
|
|
247
|
+
**No models in the model picker?**
|
|
248
|
+
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.
|
|
249
|
+
|
|
250
|
+
**"none of the selected models matched"?**
|
|
251
|
+
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.
|
|
252
|
+
|
|
253
|
+
**Connection failed / "no usable CPA service found"?**
|
|
254
|
+
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.
|
|
255
|
+
|
|
256
|
+
**A just-published version won't install?**
|
|
257
|
+
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.
|
|
258
|
+
|
|
259
|
+
## AI installation guide
|
|
260
|
+
|
|
261
|
+
> **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.
|
|
262
|
+
|
|
263
|
+
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.
|
|
264
|
+
2. **Configure** with the `cliproxyapi` tool:
|
|
265
|
+
- Local CPA on `http://127.0.0.1:8317` without auth: nothing to configure; call `{"action": "refresh"}`.
|
|
266
|
+
- 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.
|
|
267
|
+
- Narrow the picker with `selectedModels` (exact ids from the `status` output).
|
|
268
|
+
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**.
|
|
269
|
+
|
|
270
|
+
Never echo API keys back to the user or write them into files.
|
|
271
|
+
|
|
272
|
+
## Development
|
|
273
|
+
|
|
274
|
+
```text
|
|
275
|
+
lib/index.js Host plugin (discovery, sync, multi-account controller, tool, commands, HTTP API)
|
|
276
|
+
lib/client.js Web settings panel (hand-written ModuleLoader module, no build)
|
|
277
|
+
locale/*.json Title and description shown by the plugin manager
|
|
278
|
+
cordis.patch.yml Bundle patch inserting the dsh-cliproxyapi-pro row
|
|
279
|
+
tests/ node:test unit and integration tests
|
|
280
|
+
.github/workflows/ CI (tests) and release (GitHub Release + npm trusted publishing)
|
|
281
|
+
assets/screenshots/ README screenshots (listed in screenshots.json for plugin storefronts)
|
|
282
|
+
AGENTS.md Conventions, architecture and invariants for coding agents
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
git clone https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro.git
|
|
287
|
+
cd dsh-cliproxyapi-pro
|
|
288
|
+
npm test # run the tests
|
|
289
|
+
npm run check # syntax check + tests
|
|
290
|
+
npm run pack:check # list the files a packed bundle contains
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
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.
|
|
294
|
+
|
|
295
|
+
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.
|
|
296
|
+
|
|
297
|
+
## License
|
|
298
|
+
|
|
299
|
+
[MIT](https://github.com/TinyBOOOOM/dsh-cliproxyapi-pro/blob/main/LICENSE)
|