@omdp/dsh-key-fallback 1.0.5 → 1.0.7

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/lib/client.js CHANGED
@@ -121,12 +121,29 @@ window.__ModuleLoader__.load({
121
121
  )
122
122
  }
123
123
 
124
+ function FallbackSection() {
125
+ // 同一个 KeyFallbackCard 样式,只是放在 section 页面容器中。
126
+ return React.createElement('div', { style: { padding: '12px 0' } },
127
+ React.createElement('h3', { style: { margin: '0 0 8px 0', fontSize: '14px', fontWeight: 600 } }, 'API Key 回退 — 池状态'),
128
+ React.createElement(KeyFallbackCard))
129
+ }
130
+
124
131
  function apply(ctx) {
125
- // settings.plugin.item 是 root-scope 的 keyed slot,按 settings 命名空间
126
- // 分发:host 端 installSettingsSection 注册 key-fallback 命名空间,使它
127
- // 进入 served 集合后,本卡片才会被 ConfigurablePluginsTab 渲染。
128
- // 参考 dshmarket:注册通过嵌套 settingsScope inject(保持模块级无
129
- // settingsScope 硬依赖——旧宿主没有该服务时不至于拖垮整个插件)。
132
+ var slots = ctx.get('slots')
133
+ if (slots === undefined) return
134
+ // 1) 独立设置页:左侧菜单出现“API Key 回退”项(永远可见,不依赖 served)。
135
+ // 与 dshmarket/connector 的 settings.section 同构。
136
+ slots.inject('settings.section', function () {
137
+ return slots.register({
138
+ name: 'settings.section',
139
+ id: 'key-fallback',
140
+ order: 62,
141
+ label: 'API Key 回退',
142
+ }, FallbackSection)
143
+ })
144
+ // 2) 插件配置标签下的状态卡(served 时显示;上述独立页的补充)。
145
+ // 我们的 host 已用 installSettingsSection 注册 key-fallback 命名空间使它可 serve;
146
+ // 这里复用同一 KeyFallbackCard。
130
147
  var scopedInject = ctx.inject
131
148
  if (typeof scopedInject === 'function') {
132
149
  scopedInject(['settingsScope'], function (scoped) {
package/lib/index.js CHANGED
@@ -13,7 +13,7 @@ import * as dshSettings from '@deepseek-ai/dsh-settings'
13
13
  import * as zs from '@deepseek-ai/schemastery'
14
14
 
15
15
  export const name = 'key-fallback'
16
- export const inject = ['llm', 'settings', 'webServer']
16
+ export const inject = ['llm', 'settings', 'webServer', 'credentials']
17
17
  const API_BASE = '/dsh-key-fallback'
18
18
  const SETTINGS_FILE = join(homedir(), '.dsh', 'settings.yaml')
19
19
  // 与客户端 slots.register key 保持一致的命名空间名。
@@ -128,6 +128,11 @@ export function apply(ctx) {
128
128
  const key = pickKey(provider)
129
129
  if (!key) return config
130
130
  process.env[pool.env] = key
131
+ // ninerouter 这类 llm-pi-ai provider 凭据走 credentials 域(apiKeyEnv),
132
+ // 只写 env 不会生效 — 同步覆盖 credentials,使真实请求用池中 key。
133
+ if (ctx.credentials) {
134
+ try { await ctx.credentials.set(pool.env, key) } catch (e) {}
135
+ }
131
136
  return config
132
137
  })
133
138
 
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "@omdp/dsh-key-fallback",
3
3
  "description": "Minimal API key fallback for DeepSeek Harness: on a retryable request error, silently retry the same call with the next key in the pool.",
4
- "version": "1.0.5",
4
+ "version": "1.0.7",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
8
- ".": { "default": "./lib/index.js" },
9
- "./client": { "default": "./lib/client.js" },
8
+ ".": {
9
+ "default": "./lib/index.js"
10
+ },
11
+ "./client": {
12
+ "default": "./lib/client.js"
13
+ },
10
14
  "./package.json": "./package.json"
11
15
  },
12
16
  "files": [
@@ -23,10 +27,14 @@
23
27
  "access": "public"
24
28
  },
25
29
  "dsh": {
26
- "bundle": { "patch": "./cordis.patch.yml" },
30
+ "bundle": {
31
+ "patch": "./cordis.patch.yml"
32
+ },
27
33
  "client": {
28
34
  "platform": "web",
29
- "inject": ["@deepseek-ai/dsh-client-ui-settings"]
35
+ "inject": [
36
+ "@deepseek-ai/dsh-client-ui-settings"
37
+ ]
30
38
  }
31
39
  },
32
40
  "peerDependencies": {