dsh-llm-workbuddy 0.1.14 → 0.1.15

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
@@ -4,6 +4,35 @@
4
4
  每次发版请同步 `package.json` 的 `version` 并打一个 `git tag`(如 `v0.1.13`),
5
5
  在 GitHub 创建 Release 时本文件即为更新说明来源。
6
6
 
7
+ ## [0.1.15] - 2026-09-10
8
+
9
+ ### Fixed
10
+ - **刷新模型看不到新上架模型**:内置目录此前同时充当白名单,代理
11
+ `/v1/models` 里凡不在目录中的模型一律被丢弃,所以平台新上架的模型
12
+ (如 `deepseek-v4.1-flash`)刷新多少次都不会出现。现改为**黑名单**
13
+ `RETIRED_MODEL_IDS`:只隐藏实测不可用(上游 `service info not found`)的
14
+ 旧模型 id,其余照单显示。顺带放出 7 个别名仍在服务、却被旧白名单误藏的模型
15
+ (`minimax-m2.7`、`glm-5.0-turbo`、`hy3-preview`、`deepseek-v3-1-lkeap`、
16
+ `deepseek-v3-0324-lkeap`、`deepseek-r1-0528-lkeap`、`hunyuan-2.0-instruct`)。
17
+ - 内置目录新增 `deepseek-v4.1-flash`,并在代理不可达时作为兜底条目。
18
+ - 🔍 诊断的「模型出字」误报修复:探针用 `hy3` + `max_tokens: 4` 发一次请求,
19
+ 而推理模型会把这 4 个 token 全花在思考上、`content` 返回空串,于是
20
+ "代理正常"被误判成「代理返回了空响应」。现承认"有计费 completion token +
21
+ 有 choice"即为正常。
22
+
23
+ ### Added
24
+ - **模型名后显示积分消耗倍率**:读取代理 `/v1/models` 的 `credits` 字段
25
+ (`"x0.06 credits"`)并拼成 `Deepseek-V4-Flash ×0.06`;实时值优先,内置目录
26
+ `credits` 兜底。平台未声明倍率的模型只显示模型名——不会用 0 或猜测值冒充。
27
+ - 内置目录补齐各模型 `credits`(取自 WorkBuddy 应用 `product.json`)。
28
+
29
+ ### Changed(代理侧,`.workbuddy-src` / workbuddy2api)
30
+ - `/v1/models` 透出 `credits` 字段(`model_to_codex_format`),倍率不再由各客户端
31
+ 各自维护。
32
+ - 官方应用 `product.json` 与本地 `models_config.json` 合并时倍率单独回填:官方
33
+ 条目为空则沿用本地倍率,避免官方合并把倍率抹平。
34
+ - `models_config.json` 补充 `deepseek-v4.1-flash`(1M 上下文 / 50k 输出)。
35
+
7
36
  ## [0.1.14] - 2026-08-28
8
37
 
9
38
  ### Changed
@@ -50,6 +79,7 @@
50
79
  ---
51
80
 
52
81
  <!-- 历史版本锚点(便于生成 Release 时对比区间) -->
82
+ [0.1.15]: https://github.com/zdk119746/dsh-llm-workbuddy/compare/v0.1.14...v0.1.15
53
83
  [0.1.14]: https://github.com/zdk119746/dsh-llm-workbuddy/compare/v0.1.13...v0.1.14
54
84
  [0.1.13]: https://github.com/zdk119746/dsh-llm-workbuddy/compare/v0.1.12...v0.1.13
55
85
  [0.1.12]: https://github.com/zdk119746/dsh-llm-workbuddy/compare/v0.1.11...v0.1.12
package/README.md CHANGED
@@ -284,16 +284,29 @@ DSH 的 `dsh.client` 机制只要求 `package.json` 里:
284
284
  # discovery: true # 实时拉取代理的 /v1/models(30s 缓存)
285
285
  # models: [...] # 静态目录(代理不可达时的兜底)
286
286
  # 每个条目可带 reasoningEffort: 'low'|'medium'|'high'(默认推理等级)
287
+ # 以及 credits: 'x0.06 credits'(显示为模型名后的 ×0.06)
287
288
  # loginScript: '' # 登录脚本绝对/相对路径;默认用包内 login_workbuddy.py
288
289
  # sessionFile: ~/.codebuddy-session.json # 会话文件路径;默认同上
289
290
  ```
290
291
 
291
292
  模型列表默认取插件内置目录;代理可达时改为实时拉取 `/v1/models`(支持
292
293
  `{"models": [...]}` / `{"data": [...]}` 两种返回),未列出的模型 id 仍可原样
293
- 传递。**内置目录充当白名单**:代理返回的已下架/不可用模型(如 glm-4.6v、
294
- glm-5.0、minimax-m2.5 等,上游返回 `service info not found`)会被过滤,不显示
295
- UI 中。每个模型的推理等级(`reasoningEffort`)默认来自内置目录,代理可达时
296
- 优先沿用目录值(代理 `/v1/models` 当前只上报 `High`,不区分模型)。
294
+ 传递。**内置目录不再是白名单**:平台新上架的模型刷新后即出现在选择器里,
295
+ 无需等插件发版;只有已下架/不可用的模型 id(`RETIRED_MODEL_IDS`,上游返回
296
+ `service info not found`)会被隐藏。每个模型的推理等级(`reasoningEffort`)
297
+ 默认来自内置目录,代理可达时优先沿用目录值(代理 `/v1/models` 当前只上报
298
+ `High`,不区分模型)。
299
+
300
+ **积分倍率**:模型名后面会拼上平台声明的积分倍率,例如
301
+ `Deepseek-V4-Flash ×0.06`。倍率来自代理 `/v1/models` 的 `credits` 字段
302
+ (`"x0.06 credits"`,平台写在 WorkBuddy 应用 `product.json` /
303
+ `models_config.json` 里),实时值优先、内置目录兜底;平台没声明的模型
304
+ (如个别新模型尚未写入 `product.json`)只显示模型名,不会猜一个数字。
305
+
306
+ **刷新模型**:⚙️ 设置 → 🔄 刷新模型 会清掉插件的 30s 发现缓存并重新拉取
307
+ 代理列表。注意代理自身的模型清单来自本机 WorkBuddy 应用的 `product.json`
308
+ 与 `models_config.json`——两者都没有的模型,刷新也不会出现,需先更新应用或
309
+ 把模型补进代理配置。
297
310
 
298
311
  ---
299
312
 
package/lib/index.js CHANGED
@@ -77,26 +77,53 @@ const DISCOVERY_TIMEOUT_MS = 2_000;
77
77
  * CodeBuddy/WorkBuddy platform (from workbuddy2api's models_config.json).
78
78
  * It is advisory and replaced by the live `/v1/models` answer whenever the
79
79
  * proxy is reachable; entries not announced by the proxy are still listed.
80
+ *
81
+ * `credits` is the platform's declared multiplier (`"x0.06 credits"`), shown
82
+ * after the model name. The live answer wins when it carries one — this copy
83
+ * only covers the proxy-down / discovery-off fallback.
80
84
  */
81
85
  const DEFAULT_MODELS = [
82
- { id: "deepseek-v4-pro", name: "Deepseek-V4-Pro", contextWindow: 1_000_000, maxTokens: 50_000, inputModalities: ["text", "image"], reasoningEffort: "high" },
83
- { id: "deepseek-v4-flash", name: "Deepseek-V4-Flash", contextWindow: 1_000_000, maxTokens: 50_000, inputModalities: ["text", "image"], reasoningEffort: "high" },
84
- { id: "deepseek-v3-2-volc", name: "DeepSeek-V3.2", contextWindow: 96_000, maxTokens: 32_000, reasoningEffort: "medium" },
85
- { id: "glm-5.2", name: "GLM-5.2", contextWindow: 1_000_000, maxTokens: 48_000, inputModalities: ["text", "image"], reasoningEffort: "medium" },
86
- { id: "glm-5.1", name: "GLM-5.1", contextWindow: 200_000, maxTokens: 48_000, reasoningEffort: "medium" },
87
- { id: "glm-5v-turbo", name: "GLM-5v-Turbo", contextWindow: 200_000, maxTokens: 64_000, inputModalities: ["text", "image"], reasoningEffort: "medium" },
88
- { id: "kimi-k3-1", name: "Kimi-K3", contextWindow: 1_000_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium" },
89
- { id: "kimi-k2.7", name: "Kimi-K2.7-Code", contextWindow: 256_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium" },
90
- { id: "kimi-k2.6", name: "Kimi-K2.6", contextWindow: 256_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium" },
91
- { id: "kimi-k2.5", name: "Kimi-K2.5", contextWindow: 164_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium" },
92
- { id: "minimax-m3", name: "MiniMax-M3", contextWindow: 512_000, maxTokens: 128_000, inputModalities: ["text", "image"], reasoningEffort: "medium" },
93
- { id: "hy3", name: "Hy3", contextWindow: 192_000, maxTokens: 64_000, inputModalities: ["text", "image"], reasoningEffort: "high" },
94
- { id: "hunyuan-2.0-thinking", name: "Hunyuan-2.0-Thinking", contextWindow: 128_000, maxTokens: 24_000, reasoningEffort: "medium" },
86
+ { id: "deepseek-v4.1-flash", name: "Deepseek-V4.1-Flash", contextWindow: 1_000_000, maxTokens: 50_000, inputModalities: ["text", "image"], reasoningEffort: "high" },
87
+ { id: "deepseek-v4-pro", name: "Deepseek-V4-Pro", contextWindow: 1_000_000, maxTokens: 50_000, inputModalities: ["text", "image"], reasoningEffort: "high", credits: "x0.16 credits" },
88
+ { id: "deepseek-v4-flash", name: "Deepseek-V4-Flash", contextWindow: 1_000_000, maxTokens: 50_000, inputModalities: ["text", "image"], reasoningEffort: "high", credits: "x0.06 credits" },
89
+ { id: "deepseek-v3-2-volc", name: "DeepSeek-V3.2", contextWindow: 96_000, maxTokens: 32_000, reasoningEffort: "medium", credits: "x0.29 credits" },
90
+ { id: "glm-5.2", name: "GLM-5.2", contextWindow: 1_000_000, maxTokens: 48_000, inputModalities: ["text", "image"], reasoningEffort: "medium", credits: "x0.79 credits" },
91
+ { id: "glm-5.1", name: "GLM-5.1", contextWindow: 200_000, maxTokens: 48_000, reasoningEffort: "medium", credits: "x0.79 credits" },
92
+ { id: "glm-5v-turbo", name: "GLM-5v-Turbo", contextWindow: 200_000, maxTokens: 64_000, inputModalities: ["text", "image"], reasoningEffort: "medium", credits: "x0.95 credits" },
93
+ { id: "kimi-k3-1", name: "Kimi-K3", contextWindow: 1_000_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium", credits: "x1.62 credits" },
94
+ { id: "kimi-k2.7", name: "Kimi-K2.7-Code", contextWindow: 256_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium", credits: "x0.57 credits" },
95
+ { id: "kimi-k2.6", name: "Kimi-K2.6", contextWindow: 256_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium", credits: "x0.52 credits" },
96
+ { id: "kimi-k2.5", name: "Kimi-K2.5", contextWindow: 164_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "medium", credits: "x0.45 credits" },
97
+ { id: "minimax-m3", name: "MiniMax-M3", contextWindow: 512_000, maxTokens: 128_000, inputModalities: ["text", "image"], reasoningEffort: "medium", credits: "x0.25 credits" },
98
+ { id: "hy3", name: "Hy3", contextWindow: 192_000, maxTokens: 64_000, inputModalities: ["text", "image"], reasoningEffort: "high", credits: "x0.00 credits" },
99
+ { id: "hunyuan-2.0-thinking", name: "Hunyuan-2.0-Thinking", contextWindow: 128_000, maxTokens: 24_000, reasoningEffort: "medium", credits: "x0.04 credits" },
95
100
  { id: "hunyuan-chat", name: "Hunyuan-Turbos", contextWindow: 200_000, maxTokens: 8_192 },
96
101
  { id: "auto", name: "Auto", contextWindow: 168_000, maxTokens: 32_000, inputModalities: ["text", "image"], reasoningEffort: "high" },
97
- { id: "default", name: "Default", contextWindow: 200_000, maxTokens: 24_000 },
102
+ { id: "default", name: "Default", contextWindow: 200_000, maxTokens: 24_000, credits: "x2.00 credits" },
98
103
  ];
99
104
 
105
+ /**
106
+ * Models the proxy still announces but that the upstream platform rejects with
107
+ * `service info not found` (each id re-probed 2026-09-10 against the live
108
+ * endpoint). The catalog is no longer a whitelist — a model the platform
109
+ * launches shows up after a refresh without a plugin update — so dead ids are
110
+ * hidden here by name instead.
111
+ */
112
+ const RETIRED_MODEL_IDS = new Set([
113
+ "minimax-m2.5",
114
+ "glm-5.0",
115
+ "glm-4.7",
116
+ "glm-4.6",
117
+ "glm-4.6v",
118
+ "kimi-k2-thinking",
119
+ "deepseek-v3-1",
120
+ "deepseek-v3-1-volc",
121
+ "kimi-k2-instruct-taiji",
122
+ "completion-gf",
123
+ "default-1.1",
124
+ "default-1.2",
125
+ ]);
126
+
100
127
  /** Selectable reasoning efforts exposed to the harness UI, in display order. */
101
128
  const REASONING_EFFORTS = [
102
129
  { id: "low", name: "Low" },
@@ -156,6 +183,26 @@ function liveInputModalities(entry) {
156
183
  return valid.length > 0 ? [...new Set(valid)] : ["text"];
157
184
  }
158
185
 
186
+ /**
187
+ * Parse the platform's credit declaration into the `×0.06` suffix appended to
188
+ * a model name. The platform writes these as `"x0.06 credits"` (product.json /
189
+ * models_config.json), and the proxy relays the string verbatim; a bare number
190
+ * or an already-compact `×1.62` also parses. Anything without a recognizable
191
+ * number yields `undefined`, so callers omit the suffix rather than guess —
192
+ * an unknown multiplier must not be rendered as 0.
193
+ */
194
+ function creditsMultiplier(value) {
195
+ if (typeof value !== "string") return undefined;
196
+ const match = /^[x×*]?\s*(\d+(?:\.\d+)?)\s*(?:credits?)?$/i.exec(value.trim());
197
+ return match === null ? undefined : `×${match[1]}`;
198
+ }
199
+
200
+ /** Append the credit multiplier to a model's display name, when declared. */
201
+ function withCredits(name, credits) {
202
+ const multiplier = creditsMultiplier(credits);
203
+ return multiplier === undefined ? name : `${name} ${multiplier}`;
204
+ }
205
+
159
206
 
160
207
  // #region serialize
161
208
 
@@ -580,7 +627,7 @@ function modelInfo(provider, model) {
580
627
  return {
581
628
  provider,
582
629
  id: model.id,
583
- name: model.name ?? model.id,
630
+ name: withCredits(model.name ?? model.id, model.credits),
584
631
  ...(model.description === undefined ? {} : { description: model.description }),
585
632
  inputModalities: model.inputModalities ?? ["text"],
586
633
  ...(reasoning === undefined ? {} : { reasoning }),
@@ -673,6 +720,10 @@ export class WorkBuddyAdapter extends LlmAdapter {
673
720
  description: typeof entry.description === "string" && entry.description.length > 0
674
721
  ? entry.description
675
722
  : undefined,
723
+ // Platform-declared credit multiplier, relayed by the proxy.
724
+ credits: typeof entry.credits === "string" && entry.credits.trim().length > 0
725
+ ? entry.credits.trim()
726
+ : undefined,
676
727
  modalities: liveInputModalities(entry),
677
728
  contextWindow: Number.isInteger(entry.context_window) && entry.context_window > 0
678
729
  ? entry.context_window
@@ -689,19 +740,23 @@ export class WorkBuddyAdapter extends LlmAdapter {
689
740
  if (seen.has(entry.id)) continue;
690
741
  seen.add(entry.id);
691
742
  const catalog = byId.get(entry.id);
692
- // The static catalog doubles as a whitelist. The proxy still announces
693
- // retired/legacy models (deepseek-v3-1, glm-4.6, glm-4.6v, kimi-k2,
694
- // kimi-k2-thinking, minimax-m2.5, hunyuan-image-v3.0, ...) that the
695
- // upstream rejects with `service info not found`. Drop any live entry
696
- // that is not in the catalog so those never reach the UI; the catalog
697
- // is the curated set that matches what the official client shows.
698
- if (catalog === undefined) continue;
743
+ // Retired ids are hidden by name (RETIRED_MODEL_IDS) rather than by
744
+ // absence from the catalog: the proxy still announces models upstream
745
+ // rejects, but a model the platform launches must appear after a
746
+ // refresh without waiting for a new plugin release. The catalog is now
747
+ // only a metadata overlay plus a fallback for unannounced entries.
748
+ if (RETIRED_MODEL_IDS.has(entry.id)) continue;
699
749
  const effort = liveReasoningEffort(entry, catalog?.reasoningEffort);
700
750
  const reasoning = modelReasoningInfo(effort);
701
751
  merged.push({
702
752
  provider,
703
753
  id: entry.id,
704
- name: entry.name ?? catalog?.name ?? entry.id,
754
+ // The proxy's multiplier tracks the platform; the catalog's is a
755
+ // snapshot, so the live value wins and the catalog only fills gaps.
756
+ name: withCredits(
757
+ entry.name ?? catalog?.name ?? entry.id,
758
+ entry.credits ?? catalog?.credits,
759
+ ),
705
760
  ...(catalog?.description !== undefined || entry.description !== undefined
706
761
  ? { description: catalog?.description ?? entry.description }
707
762
  : {}),
@@ -843,6 +898,9 @@ const catalogModel = z.object({
843
898
  maxTokens: z.number().step(1).min(1),
844
899
  inputModalities: z.array(z.union(MODEL_MODALITIES)).min(1).default(["text"]),
845
900
  reasoningEffort: z.string(),
901
+ // Platform-declared credit multiplier, e.g. "x0.06 credits"; displayed after
902
+ // the model name as "×0.06".
903
+ credits: z.string(),
846
904
  });
847
905
 
848
906
  export const Config = z.object({
@@ -890,6 +948,10 @@ function resolveModels(models) {
890
948
  if (reasoningEffort !== undefined && !REASONING_EFFORT_IDS.has(reasoningEffort)) {
891
949
  throw new Error(`dsh-llm-workbuddy: catalog model "${model.id}" reasoningEffort must be one of low|medium|high`);
892
950
  }
951
+ const credits = typeof model.credits === "string" ? model.credits.trim() : undefined;
952
+ if (credits !== undefined && credits.length > 0 && creditsMultiplier(credits) === undefined) {
953
+ throw new Error(`dsh-llm-workbuddy: catalog model "${model.id}" credits must read like "x0.06 credits"`);
954
+ }
893
955
  return {
894
956
  id: model.id,
895
957
  ...(model.name === undefined ? {} : { name: model.name }),
@@ -898,6 +960,7 @@ function resolveModels(models) {
898
960
  ...(model.maxTokens === undefined ? {} : { maxTokens: model.maxTokens }),
899
961
  inputModalities: [...inputModalities],
900
962
  ...(reasoningEffort === undefined ? {} : { reasoningEffort }),
963
+ ...(credits === undefined || credits.length === 0 ? {} : { credits }),
901
964
  };
902
965
  });
903
966
  }
@@ -1234,10 +1297,19 @@ async function probeChatWorking(baseURL) {
1234
1297
  return { chatWorking: false, chatError: `HTTP ${response.status}${text ? `: ${text.slice(0, 200)}` : ""}` };
1235
1298
  }
1236
1299
  const body = await response.json().catch(() => null);
1237
- const content = body?.choices?.[0]?.message?.content;
1300
+ const choice = body?.choices?.[0];
1301
+ const content = choice?.message?.content;
1238
1302
  if (typeof content === "string" && content.length > 0) {
1239
1303
  return { chatWorking: true };
1240
1304
  }
1305
+ // A reasoning model spends the whole 4-token cap on thinking and answers
1306
+ // with `content: ""` + `finish_reason: "length"` — that is a healthy proxy,
1307
+ // not an empty response (probed against hy3, which is all-thinking at this
1308
+ // cap). Any billed completion token proves the upstream round trip worked.
1309
+ const completionTokens = body?.usage?.completion_tokens;
1310
+ if (choice !== undefined && typeof completionTokens === "number" && completionTokens > 0) {
1311
+ return { chatWorking: true };
1312
+ }
1241
1313
  return { chatWorking: false, chatError: "代理返回了空响应" };
1242
1314
  } catch (error) {
1243
1315
  return { chatWorking: false, chatError: String(error?.message ?? error) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-llm-workbuddy",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "WorkBuddy (via the local workbuddy2api proxy) LLM provider adapter for DeepSeek Harness, with a Web login-status widget",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",