@tscgoods/codex-effort-discovery 0.3.1 → 0.5.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effort-discovery",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Probe the gateway for the reasoning-effort levels a model really accepts and generate a Codex model catalog that offers exactly those.",
5
5
  "author": {
6
6
  "name": "tscgoods"
package/README.md CHANGED
@@ -6,7 +6,7 @@ Codex CLI 插件:探测网关真正接受的 reasoning effort 档位,然后
6
6
 
7
7
  Codex 的档位列表来自 `model_catalog_json`(**配置**,不是插件接口):每个模型的 `supported_reasoning_levels` 决定 UI 里出现哪些档位。插件不能改枚举,但可以:
8
8
 
9
- 1. 探测网关(优先用网关原生的 `/models` catalog,零成本;否则发极小请求读回校验回显);
9
+ 1. 探测网关(默认:上游错误回显优先,原生 catalog 兜底);
10
10
  2. 把结果写进现有 catalog 的副本,并告诉你把 `model_catalog_json` 指过去。
11
11
 
12
12
  ## 安装
@@ -36,9 +36,22 @@ node scripts/sync-catalog.mjs --write
36
36
 
37
37
  插件还提供 `/efforts` 命令和 `effort-probe` 技能,让 agent 代跑这两步。
38
38
 
39
+ ## 哪个证据可信
40
+
41
+ DeepSeek 官方文档(https://api-docs.deepseek.com/zh-cn/guides/thinking_mode)明确写着 `reasoning_effort` 只接受 `low / high / max`,`medium` 和 `xhigh` 都会被映射成 `high`;Anthropic 格式是 `none/low/high/max`。
42
+
43
+ 但网关的原生 catalog(cc-switch 生成的 `/v1/models`)给 deepseek 标的是 `low/medium/high/xhigh`——**这个 catalog 是错的,而且漏了 max**,导致 Codex 菜单里选不到 max。
44
+
45
+ 因此 `probe.mjs` 的默认优先级是:
46
+
47
+ 1. **上游错误回显**(`/v1/chat/completions` 的非法值 400,反映实际接受的档位)→ `source: validated`;
48
+ 2. **原生 catalog** 兜底(错误回显拿不到时)→ `source: native-catalog`。
49
+
50
+ `none` 会被过滤掉(Codex 的 `supported_reasoning_levels` 不接受它),最终 deepseek 得到 `low/high/max`。`--no-native` 保留作"只看错误回显"的诊断开关。若网关原生 catalog 与错误回显一致,两者结果相同,无副作用。
51
+
39
52
  ## 更省事的替代
40
53
 
41
- 如果你的网关自己就返回 Codex 原生 catalog(`/models` 里有 `supported_reasoning_levels`),可以完全不装插件:
54
+ 如果网关的 catalog 本身准确,可以不装插件:
42
55
 
43
56
  ```toml
44
57
  [model_providers.custom]
@@ -46,6 +59,8 @@ base_url = "http://127.0.0.1:7891/v1"
46
59
  model_catalog_url = "http://127.0.0.1:7891/v1/models" # 必须与 base_url 同源同端口
47
60
  ```
48
61
 
62
+ 但本例中 cc-switch 的 catalog 是错的,所以要用插件生成并写入正确的 catalog。
63
+
49
64
  ## 注意
50
65
 
51
66
  - Codex 只在启动时读 catalog,改完需要重开会话。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscgoods/codex-effort-discovery",
3
- "version": "0.3.1",
3
+ "version": "0.5.0",
4
4
  "description": "Codex CLI plugin: probe which reasoning-effort levels your gateway accepts, then generate a model catalog that makes Codex offer exactly those.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/scripts/probe.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ CODEX_EFFORTS,
3
4
  cachePath,
4
5
  loadConfig,
5
6
  nativeCatalog,
@@ -54,19 +55,31 @@ const headers = entry.headers ?? {}
54
55
 
55
56
  const result = { at: Date.now(), provider: providerID, baseURL, models: {} }
56
57
 
57
- if (!args.noNative) {
58
- const native = await nativeCatalog({ baseURL, apiKey, headers })
59
- if (native) {
60
- for (const [model, levels] of Object.entries(native)) {
61
- result.models[model] = { levels, source: "native-catalog", at: Date.now() }
62
- }
63
- }
64
- }
58
+ const native = args.noNative ? undefined : await nativeCatalog({ baseURL, apiKey, headers })
59
+ const configured = args.models.length > 0 ? args.models : Array.isArray(entry.models) ? entry.models : []
60
+ const models = [...new Set([...Object.keys(native ?? {}), ...configured])]
65
61
 
66
- const models = args.models.length > 0 ? args.models : Array.isArray(entry.models) ? entry.models : []
67
62
  for (const model of models) {
68
- if (result.models[model] && !args.force) continue
69
- result.models[model] = await probeOpenAI({ baseURL, apiKey, model, headers })
63
+ const nativeLevels = native?.[model] ?? null
64
+ const probed = await probeOpenAI({ baseURL, apiKey, model, headers })
65
+ const validated = probed.source === "validated" && Array.isArray(probed.levels) && probed.levels.length > 0
66
+
67
+ // 上游错误回显优先(它反映实际接受的 effort),原生 catalog 兜底
68
+ const levels = validated
69
+ ? probed.levels.filter((level) => CODEX_EFFORTS.includes(level))
70
+ : nativeLevels ?? null
71
+
72
+ result.models[model] = {
73
+ levels,
74
+ source: validated
75
+ ? "validated"
76
+ : nativeLevels
77
+ ? "native-catalog"
78
+ : probed.source,
79
+ rawLevels: probed.levels,
80
+ nativeLevels,
81
+ at: Date.now(),
82
+ }
70
83
  await new Promise((resolve) => setTimeout(resolve, 200))
71
84
  }
72
85