@ponydev/dsh-model-usage 1.0.6 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.7 — 2026-10-20
4
+
5
+ ### 修复
6
+ - **凭据引用改为「路由派生优先」**:如 `opencode-go` → `OPENCODE_GO_API_KEY`(与 DSH Models 页的 `apiKeyEnv` 一致),修复已配置 Key 的供应商仍显示未配置/不显示的问题
7
+
3
8
  ## 1.0.6 — 2026-10-20
4
9
 
5
10
  ### 新增
package/lib/adapters.js CHANGED
@@ -53,9 +53,18 @@ export async function fetchT(url, init, ms) {
53
53
  }
54
54
 
55
55
  /** 按顺序解析凭据 ref:优先注入作用域的 credentials 服务,再回退环境变量 */
56
+ function routeKeyRef(route) {
57
+ const base = String(route || '').toUpperCase().replace(/[^A-Z0-9]+/g, '_').replace(/^_+|_+$/g, '')
58
+ return base ? base + '_API_KEY' : null
59
+ }
60
+
56
61
  export async function resolveKey(env) {
57
62
  const cred = env.credentials
58
- for (const ref of env.refs || []) {
63
+ // 优先按路由派生的引用(如 opencode-go → OPENCODE_GO_API_KEY,与 DSH Models 页 apiKeyEnv 一致)
64
+ const refs = [...(env.refs || [])]
65
+ const derived = routeKeyRef(env.route)
66
+ if (derived && !refs.includes(derived)) refs.unshift(derived)
67
+ for (const ref of refs) {
59
68
  if (!ref) continue
60
69
  if (cred && typeof cred.resolve === 'function') {
61
70
  for (let attempt = 0; attempt < 2; attempt++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ponydev/dsh-model-usage",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "DSH Web 插件:实时显示模型供应商额度与用量(DeepSeek / GLM Coding Plan / OpenRouter / Kimi Coding Plan + 自定义适配器)",
5
5
  "keywords": [
6
6
  "dsh",