@omdp/dsh-key-fallback 3.1.3 → 3.1.4
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/README.md +5 -1
- package/README.zh-CN.md +5 -1
- package/lib/index.js +7 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Multi-key API key pool with automatic rotation for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness)** — sits between the LLM adapter and the credential store. Before each request the plugin picks a key from the per-provider pool and pre-writes it into the provider's credential reference; when a configured trigger error occurs it marks the failed key cooling (fixed `cooldownMs`, no exponential backoff) and advances to the next key. **Re-sending is left entirely to DSH's own `dsh-llm-retry`** — this plugin never re-sends on its own; it only switches the key and lets the retry policy decide.
|
|
6
6
|
|
|
7
|
-
Current version: **v3.1.
|
|
7
|
+
Current version: **v3.1.4** (`v6` UI generation).
|
|
8
8
|
|
|
9
9
|
## Requirements
|
|
10
10
|
|
|
@@ -12,6 +12,10 @@ Current version: **v3.1.3** (`v6` UI generation).
|
|
|
12
12
|
- Node.js `^22.19` or `>=24`
|
|
13
13
|
- Peer ranges strictly enumerate **only compatibility-tested versions** — `@deepseek-ai/dsh-credentials` `0.1.0-rc.6 || 0.1.1-rc.2 || 0.1.2-alpha.1 || 0.1.2-alpha.2`, `@deepseek-ai/dsh-llm` / `@deepseek-ai/dsh-settings` `0.1.1-rc.2 || 0.1.2-alpha.1 || 0.1.2-alpha.2`, `@deepseek-ai/cordis` `4.0.1 || 4.0.2`, `@deepseek-ai/schemastery` `3.18.1 || 3.18.2`. No open-ended ranges (`<0.2.0`, caret): untested versions are deliberately excluded until verified. The plugin only uses the credential-reference half (`resolve`/`describe`/`set`/`unset`/`credentialRef` — stable since `0.1.0-rc.6`) and the `agent/request` + `agent/request-error` waterfall (payload unchanged across the enumerated versions); `isCredentialRefName` (added `rc.8`) is implemented locally for compatibility.
|
|
14
14
|
|
|
15
|
+
## What v3.1.4 offers
|
|
16
|
+
|
|
17
|
+
- **Env name auto-derivation sanitized**: creating a pool for a provider whose id contains non-identifier characters (`b-ai`, `B.AI`, …) no longer fails with `env must be POSIX identifier` — the derived env name (`<PROVIDER>_API_KEY`) now strips `-`/`.` etc. (`b-ai` → `B_AI_API_KEY`). Explicit `env` values are still validated as before. Fixes the "选择 LLM provider → 启用" 400 error for such providers.
|
|
18
|
+
|
|
15
19
|
## What v3.1.3 offers
|
|
16
20
|
|
|
17
21
|
**Settings → API Key 回退** — a top-level settings page with a redesigned UI (status dots, badges, gradient pool cards, per-key rows):
|
package/README.zh-CN.md
CHANGED
|
@@ -4,7 +4,7 @@ English | [简体中文](README.md)
|
|
|
4
4
|
|
|
5
5
|
**为 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) 提供多 key 池 + 自动轮换**——插件位于 LLM 适配器与凭证存储之间:每次请求前从按 provider 分组的 key 池里选一把,预写入该 provider 的凭证引用;遇到配置的触发错误时,把失败 key 标记为冷却(固定 `cooldownMs`,无指数退避)并前进到下一把。**重发完全交给 DSH 自带的 `dsh-llm-retry`**——本插件从不自行重发,只负责换 key,重试策略由 retry policy 决定。
|
|
6
6
|
|
|
7
|
-
当前版本:**v3.1.
|
|
7
|
+
当前版本:**v3.1.4**(v6 UI 代)。
|
|
8
8
|
|
|
9
9
|
## 环境要求
|
|
10
10
|
|
|
@@ -12,6 +12,10 @@ English | [简体中文](README.md)
|
|
|
12
12
|
- Node.js `^22.19` 或 `>=24`
|
|
13
13
|
- peer 范围**只枚举已实际进行过兼容测试的版本**——`@deepseek-ai/dsh-credentials` `0.1.0-rc.6 || 0.1.1-rc.2 || 0.1.2-alpha.1 || 0.1.2-alpha.2`、`@deepseek-ai/dsh-llm` / `@deepseek-ai/dsh-settings` `0.1.1-rc.2 || 0.1.2-alpha.1 || 0.1.2-alpha.2`、`@deepseek-ai/cordis` `4.0.1 || 4.0.2`、`@deepseek-ai/schemastery` `3.18.1 || 3.18.2`。不使用 `<0.2.0`、caret 之类的开放范围:未测试版本在核查通过前刻意排除。插件只使用 credential-reference 半边(`resolve`/`describe`/`set`/`unset`/`credentialRef`,自 `0.1.0-rc.6` 起稳定)与 `agent/request` + `agent/request-error` waterfall(载荷跨上述枚举版本未变);`isCredentialRefName`(rc.8 新增)本地实现兜底。
|
|
14
14
|
|
|
15
|
+
## v3.1.4 新增
|
|
16
|
+
|
|
17
|
+
- **env 名自动派生已消毒**:为 id 含非法字符(`b-ai`、`B.AI` 等)的 provider 建池不再报 `env must be POSIX identifier`——自动派生的 env 名(`<PROVIDER>_API_KEY`)现在会把 `-`/`.` 等转成 `_`(`b-ai` → `B_AI_API_KEY`)。显式传入的 `env` 仍按原规则校验。修复"选择 LLM provider → 启用"对此类 provider 的 400 报错。
|
|
18
|
+
|
|
15
19
|
## v3.1.3 提供什么
|
|
16
20
|
|
|
17
21
|
**设置 → API Key 回退** —— 顶层设置页,全新 UI(状态点、徽章、渐变池卡片、逐 key 行):
|
package/lib/index.js
CHANGED
|
@@ -23,6 +23,11 @@ import z from '@deepseek-ai/schemastery'
|
|
|
23
23
|
function isCredentialRefName(value) {
|
|
24
24
|
return typeof value === 'string' && /^[A-Za-z_][A-Za-z0-9_]*$/.test(value)
|
|
25
25
|
}
|
|
26
|
+
// provider id 可能是 b-ai / B.AI 这类含非法字符的名字,自动派生 env 时消毒
|
|
27
|
+
// (- . 等 → _),保证派生名始终是合法 POSIX 标识符。
|
|
28
|
+
function deriveEnvName(name) {
|
|
29
|
+
return String(name).toUpperCase().replace(/[^A-Z0-9]/g, '_') + '_API_KEY'
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
export const name = 'key-fallback'
|
|
28
33
|
export const inject = ['llm', 'settings', 'webServer', 'credentials']
|
|
@@ -199,7 +204,7 @@ export function apply(ctx) {
|
|
|
199
204
|
for (const name in providers) {
|
|
200
205
|
if (!pools.has(name)) pools.set(name, { cfg: providers[name], keyValues: [], cursor: 0, currentRef: '' })
|
|
201
206
|
else pools.get(name).cfg = providers[name]
|
|
202
|
-
const envName = (providers[name] && providers[name].env) || (name
|
|
207
|
+
const envName = (providers[name] && providers[name].env) || deriveEnvName(name)
|
|
203
208
|
poolsByEnv.set(envName, pools.get(name))
|
|
204
209
|
}
|
|
205
210
|
for (const name of [...pools.keys()]) if (!providers[name]) pools.delete(name)
|
|
@@ -554,7 +559,7 @@ export function apply(ctx) {
|
|
|
554
559
|
const body = await readBody()
|
|
555
560
|
const { provider, enabled, env, cooldownMs, rotateOn, displayName, useKeyRef } = body || {}
|
|
556
561
|
if (typeof provider !== 'string' || !provider) return sendJson(res, 400, { error: 'provider required' })
|
|
557
|
-
const envName = (typeof env === 'string' && env) ? env : (provider
|
|
562
|
+
const envName = (typeof env === 'string' && env) ? env : deriveEnvName(provider)
|
|
558
563
|
if (!isCredentialRefName(envName)) return sendJson(res, 400, { error: 'env must be POSIX identifier' })
|
|
559
564
|
const cfg = readSettings()
|
|
560
565
|
cfg.providers = cfg.providers || {}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omdp/dsh-key-fallback",
|
|
3
3
|
"description": "API Key 回退轮换插件:多 key 池 + 自动轮换(触发码可配置,含 LlmError 标准码全集)+ 环境密钥编辑 + 明文揭示 + 短 ref 迁移。Settings → API Key 回退 UI. v6.1.",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"exports": {
|