dsh-llm-key-loop 0.0.0-stage → 2.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 +15 -0
- package/LICENSE +21 -0
- package/README.md +105 -2
- package/client.js +676 -0
- package/cordis.patch.yml +18 -0
- package/docs/DETAIL.md +56 -0
- package/icon.svg +7 -0
- package/index.js +673 -0
- package/locale/en.json +7 -0
- package/package.json +69 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.4.1
|
|
4
|
+
- Package metadata and README opening for discoverability; package can now be published to npm.
|
|
5
|
+
|
|
6
|
+
## 2.4.0
|
|
7
|
+
- Package renamed to `dsh-llm-key-loop` (was `@local/llm-key-loop`).
|
|
8
|
+
- New **Key Loop page** in the left menu: providers on the left, one merged row per key with usage, badges, test and remove; click a key for details.
|
|
9
|
+
- Red/amber/green provider dot reflects the key in use, not every backup key.
|
|
10
|
+
- Fix: DeepSeek keys are now found under `DEEPSEEK_API_KEY`; the DeepSeek Account entry is hidden.
|
|
11
|
+
- Fix: key test no longer reports a false error when a provider answers a 1-token chat with a server error.
|
|
12
|
+
- Settings → Models shows a short pointer to the new page.
|
|
13
|
+
|
|
14
|
+
## 2.3.x
|
|
15
|
+
- Per-provider key rotation, status-line usage, model-menu **Key** row, local usage counting for providers without a usage API.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alamin
|
|
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.md
CHANGED
|
@@ -1,3 +1,106 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Key Loop for DeepSeek Harness
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/thisisalamin/dsh-llm-key-loop/actions/workflows/ci.yml)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
Use several API keys for one model provider in DeepSeek Harness (DSH), switch between them automatically when a key hits its quota or rate limit, and see how much each key has used.
|
|
7
|
+
|
|
8
|
+
**Why Key Loop?** Running out of quota on one API key should not stop your work. Key Loop keeps a list of keys per provider (Main key → Key 1 → … → Key 9), moves to the next one when the current key fails, and shows each key's usage in one place. Other DSH plugins can rotate keys; Key Loop also gives you:
|
|
9
|
+
|
|
10
|
+
- a **Key Loop page** in the left menu with usage bars, status badges and a connection test for every key,
|
|
11
|
+
- **usage under the message box** and a **Key** row in the model menu to choose a key by hand,
|
|
12
|
+
- **request and token counting** for providers that do not report usage to an API key,
|
|
13
|
+
- a strict rule that it **never switches to a different provider**.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Automatic switching.** When the key in use hits its limit, is rejected, or is rate-limited, the next key takes over and the request is retried. Order: Main key → Key 1 → Key 2 → … → Key 9. If every key fails in one message, it stops and shows the error. It **never** switches to a different provider.
|
|
18
|
+
- **Key Loop page** in the left menu: every provider with its keys, usage bars, status badges and a connection test. Click a key for details. Add or remove keys in place.
|
|
19
|
+
- **Usage under the message box**, for example `Key 1 · 74%`. Click it to see every key's usage and reset time.
|
|
20
|
+
- **Manual choice.** Model menu → **Key** → pick a key. Automatic switching pauses until you choose **Default** again.
|
|
21
|
+
- **Safe by design.** Keys stay in DSH's own credential store. The browser UI only ever sees masked previews, and the plugin never logs key values.
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
Requires DeepSeek Harness `>=0.2.1-rc.5 <0.3.0`.
|
|
26
|
+
|
|
27
|
+
**Desktop app:** Plugins → **Add** → enter the path to the `.tgz` (download it from [Releases](https://github.com/thisisalamin/dsh-llm-key-loop/releases) or build it yourself below), then quit and reopen the app.
|
|
28
|
+
|
|
29
|
+
**Terminal:**
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
dsh plugin --profile desktop add /path/to/dsh-llm-key-loop-<version>.tgz
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**From source:**
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
git clone https://github.com/thisisalamin/dsh-llm-key-loop.git
|
|
39
|
+
cd dsh-llm-key-loop
|
|
40
|
+
npm pack # creates dsh-llm-key-loop-<version>.tgz
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If you also use `@m1khal3v/dsh-llm-key-rotation`, disable it first so only one plugin switches keys.
|
|
44
|
+
|
|
45
|
+
## Set up
|
|
46
|
+
|
|
47
|
+
1. Add your provider in **Settings → Models** as usual, with its normal API key. That key becomes the **Main key**.
|
|
48
|
+
2. Open **Key Loop** from the left menu and pick the provider.
|
|
49
|
+
3. Paste each backup key and click **Add key**. Use the 🔌 button to test a key; it turns green when the key works.
|
|
50
|
+
|
|
51
|
+
## Providers
|
|
52
|
+
|
|
53
|
+
Key Loop rotates keys for providers you have set up in **Settings → Models**, and it never falls back to a different provider. A provider is picked up when its key is stored under `<PROVIDER_ID>_API_KEY` (the provider id in capitals, dashes turned into underscores, for example `token-harbor` → `TOKEN_HARBOR_API_KEY`), which is what Models uses for providers you add there. DeepSeek, whose id differs from its key name, is mapped explicitly.
|
|
54
|
+
|
|
55
|
+
**Tested with:** Token Harbor, ClinePass, Xiaomi MiMo, River AI, DeepSeek and Anthropic.
|
|
56
|
+
|
|
57
|
+
Other providers that follow the same naming (OpenAI, OpenRouter, Mistral, Groq, Together AI, Fireworks, Moonshot, MiniMax, any OpenAI-compatible endpoint, …) should work but have not been tested. If one is not picked up, please [open an issue](https://github.com/thisisalamin/dsh-llm-key-loop/issues/new/choose) with the provider id and the name of its key reference.
|
|
58
|
+
|
|
59
|
+
## What usage shows
|
|
60
|
+
|
|
61
|
+
What you see next to each key depends on whether the plugin has a usage reader for that provider:
|
|
62
|
+
|
|
63
|
+
| Provider has a built-in usage reader | No reader yet |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Usage bars for each limit window (5-hour, weekly, monthly, plan credits) with the reset time, read from the provider's own read-only API about once a minute. | Requests and tokens counted by this app today, per key (resets at local midnight). Enter a daily request limit to see a percentage. |
|
|
66
|
+
| Today: Token Harbor, Xiaomi MiMo Token Plan, ClinePass. More can be added (see [CONTRIBUTING.md](CONTRIBUTING.md)). | Every other provider. Some APIs, such as Anthropic's pay-as-you-go keys, do not report usage to an API key at all. |
|
|
67
|
+
|
|
68
|
+
The local count only covers requests made from this app. It is stored as numbers only in `~/.dsh/llm-key-loop-counts.json`.
|
|
69
|
+
|
|
70
|
+
## How it works
|
|
71
|
+
|
|
72
|
+
Per provider, the plugin uses these credential references:
|
|
73
|
+
|
|
74
|
+
| Reference | Meaning |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `<PROVIDER>_API_KEY` | The key in use. The plugin writes only here. |
|
|
77
|
+
| `<PROVIDER>_API_KEY_DEFAULT` | The Main key (saved from the key in use when the plugin first starts). |
|
|
78
|
+
| `<PROVIDER>_API_KEY_CHAIN_1..9` | Backup keys. |
|
|
79
|
+
|
|
80
|
+
The server half listens on the agent loop's `agent/request-error` hook, classifies the failure (rejected, out of quota, rate-limited), moves to the next key and retries. The browser half renders the page, the status line and the model-menu row, and talks to the server through credential references only.
|
|
81
|
+
|
|
82
|
+
To exclude a provider, set `providers: { some-provider: { enabled: false } }` in the plugin's `config` (see `cordis.patch.yml`).
|
|
83
|
+
|
|
84
|
+
## Logs and files
|
|
85
|
+
|
|
86
|
+
- Lines tagged `[llm-key-loop]` are printed when the app is started from a terminal.
|
|
87
|
+
- `~/.dsh/llm-key-loop-status.json` holds a status summary with no key values.
|
|
88
|
+
- `~/.dsh/llm-key-loop-counts.json` holds the local request and token counts.
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
npm test # unit tests (node:test, no dependencies)
|
|
94
|
+
npm run check # syntax check of both files
|
|
95
|
+
npm pack # build the installable .tgz
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Source layout: `index.js` (server), `client.js` (browser UI), `cordis.patch.yml` (plugin registration), `locale/` (strings), `docs/` (long description shown in the app).
|
|
99
|
+
|
|
100
|
+
## Contributing
|
|
101
|
+
|
|
102
|
+
Issues and pull requests are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) first, and please follow the [Code of Conduct](CODE_OF_CONDUCT.md). To report a security problem, see [SECURITY.md](SECURITY.md).
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
[MIT](LICENSE) © Alamin
|