@tscgoods/dsh-effort-discovery 0.5.2 → 0.5.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 CHANGED
@@ -38,13 +38,14 @@ dsh --profile web --dump-config | Select-String effort-discovery
38
38
  node packages\dsh\scripts\probe.mjs --provider ts-dpsk
39
39
  ```
40
40
 
41
- 结果写到 `~/.cache/effort-discovery/dsh.json`。启动/配置更新时,只有 provider 名、baseURL、`openai-completions` 协议和模型 id 均匹配,且实测缓存未超过 TTL 时才变换;否则保留原配置。
41
+ 结果写到 `~/.cache/effort-discovery/dsh.json`。同一网关可能对不同的非法值返回不同列表(模型自己的 `none/low/high/max`,或网关通用的全档位列表);探针会收集多次响应,取更窄且能交叉验证的子集。启动/配置更新时,只有 provider 名、baseURL、`openai-completions` 协议和模型 id 均匹配,且实测缓存未超过 TTL 时才变换;否则保留原配置。
42
42
 
43
43
  ## 行为
44
44
 
45
45
  | 情况 | 结果 |
46
46
  | --- | --- |
47
- | 探测到合法档位 | `reasoningEfforts` 只保留实测档位(`none` → `off: null`),沿用原有 wire 值 |
47
+ | 探测到具体档位(少于 6 个) | `reasoningEfforts` 只保留实测档位(`none` → `off: null`),沿用原有 wire 值 |
48
+ | 网关回显全档位/过宽列表 | 视为不可靠,不扩菜单,保留原配置 |
48
49
  | 探测到只有 `none` | `reasoningEfforts: false`(当作非推理模型,菜单不再出现 Effort) |
49
50
  | 没探测结果 / `unknown` / 超过 TTL / 路由不匹配 | 不动原配置 |
50
51
  | `mode: "off"` | 完全不改配置,只保留 `reasoning_effort_probe` 工具 |
package/lib/index.js CHANGED
@@ -54,6 +54,8 @@ function readCache() {
54
54
  */
55
55
  export function narrowEfforts(model, levels) {
56
56
  if (!Array.isArray(levels) || levels.length === 0) return undefined
57
+ // 通用网关常把所有档位都列为“合法”;过宽的列表不足以作为菜单依据。
58
+ if (levels.length >= 6) return undefined
57
59
  const current = model?.reasoningEfforts
58
60
  // current === false 往往只是 YAML 里没配/手写了“不推理”,不是上游证据。
59
61
  // 既然探测到了档位,就以探测结果为准重新生成 map。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscgoods/dsh-effort-discovery",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "DeepSeek Harness (dsh) bundle: probe the gateway for the reasoning-effort levels each model accepts and narrow llm-pi-ai reasoningEfforts to them.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
package/scripts/probe.mjs CHANGED
@@ -60,10 +60,22 @@ function parseLevels(text) {
60
60
  return null
61
61
  }
62
62
 
63
+ /** 通用网关会回显“所有已知档位”;只取更窄的、可交叉验证的子集 */
64
+ function pickLevels(candidates) {
65
+ const specific = candidates.filter((levels) => levels.length > 0 && levels.length < 6)
66
+ if (specific.length === 0) return null
67
+ let result = specific[0]
68
+ for (const levels of specific.slice(1)) {
69
+ result = result.filter((level) => levels.includes(level))
70
+ }
71
+ return result.length > 0 ? result : null
72
+ }
73
+
63
74
  async function probe({ baseURL, apiKey, model, headers = {} }) {
64
75
  const url = `${String(baseURL).replace(/\/+$/, "")}/chat/completions`
65
76
  let last = { levels: null, source: "error", at: Date.now() }
66
77
  let sawOk = false
78
+ const candidates = []
67
79
  for (const sentinel of ["effort-discovery-probe", "ultra", "maximum", "bogus"]) {
68
80
  let response
69
81
  try {
@@ -93,10 +105,16 @@ async function probe({ baseURL, apiKey, model, headers = {} }) {
93
105
  continue
94
106
  }
95
107
  const levels = parseLevels(text)
96
- if (levels) return { levels, source: "validated", at: Date.now() }
108
+ if (levels) {
109
+ candidates.push(levels)
110
+ continue
111
+ }
97
112
  last = { levels: null, source: `http-${response.status}`, at: Date.now() }
98
113
  if ([401, 403, 429].includes(response.status)) return last
99
114
  }
115
+ const levels = pickLevels(candidates)
116
+ if (levels) return { levels, source: "validated", at: Date.now() }
117
+ if (candidates.length > 0) return { levels: null, source: "no-validation", at: Date.now() }
100
118
  return sawOk ? { levels: null, source: "no-validation", at: Date.now() } : last
101
119
  }
102
120