diff --git a/packages/sensenova/README.md b/packages/sensenova/README.md index 47a0aab..6e3f484 100644 --- a/packages/sensenova/README.md +++ b/packages/sensenova/README.md @@ -50,8 +50,10 @@ Flash-Lite。 模型列表是**账号目录 ∩ 计划覆盖**:计划不覆盖的模型(平台会回 403)不会列出。 DeepSeek 系列的输出上限用实测值(393,216 / 384,000,2026-10-29 在真实账号上 测到),而不是目录里偏保守的 `max_output_length`。没有 API Key 的账号不列 -模型;被平台拒绝的 key 也不列。会推理的模型给出 `none` / `low` / `high` 三档 -reasoning effort——这是一套**刻意收窄的通用值**,不是「每个模型都核实过支持」: +模型;被平台拒绝的 key 也不列。官方文档逐个写明档位的模型给文档里的档位 +(`kimi-k3` low/medium/high/max,`glm-5.3` low/high/max,`deepseek-flash` +none/low/high/max,`deepseek-v4-flash` none/minimal/low/medium/high/xhigh/max); +其余会推理的模型给出 `none` / `low` / `high` 三档——这是一套**刻意收窄的通用值**: 多给一档会在任务中途冒出 400,少给一档只是少一个选项。 ## OpenCode 2.x diff --git a/packages/sensenova/api.test.mjs b/packages/sensenova/api.test.mjs index 3246797..c0d078f 100644 --- a/packages/sensenova/api.test.mjs +++ b/packages/sensenova/api.test.mjs @@ -67,8 +67,7 @@ test("the listing carries each model's limits, input kinds and effort tiers", as const p = await plugin() const models = await p.provider.models({ id: "sensenova-token-plan", models: {} }, { auth }) expect(models["glm-5.2"].limit).toEqual({ context: 1048576, output: 131072 }) - // the tiers are the same for every model: the platform publishes no per-model - // list, so nothing narrower than "these are offered" is claimed + // a model SenseNova's docs give no tiers for gets the common three expect(Object.keys(models["glm-5.2"].variants)).toEqual(["none", "low", "high"]) expect(Object.keys(models["sensenova-6.8-flash-lite"].variants)).toEqual(["none", "low", "high"]) // what is claimed is checkable from the reply itself: whether it takes images @@ -86,6 +85,19 @@ test("a model the catalogue says doesn't reason gets no effort tiers", () => { expect(Object.keys(deep.variants)).toEqual(["none", "low", "high"]) }) +test("a model whose tiers SenseNova's docs list gets exactly those", () => { + // muran_91096 on Discord, from the docs: kimi-k3 and glm-5.3 take no "none", + // deepseek-flash goes to max, deepseek-v4-flash has seven + const tiers = (id) => Object.keys(_internal.modelOf({ id, name: id, context: 1, output: 1, reasoning: true }).variants) + expect(tiers("kimi-k3")).toEqual(["low", "medium", "high", "max"]) + expect(tiers("glm-5.3")).toEqual(["low", "high", "max"]) + expect(tiers("deepseek-flash")).toEqual(["none", "low", "high", "max"]) + expect(tiers("deepseek-v4-flash")).toEqual(["none", "minimal", "low", "medium", "high", "xhigh", "max"]) + expect(_internal.modelOf({ id: "kimi-k3", name: "k", context: 1, output: 1, reasoning: true }).variants.max).toEqual({ reasoningEffort: "max" }) + // a model the docs don't list keeps the common three + expect(tiers("glm-5.2")).toEqual(["none", "low", "high"]) +}) + test("two accounts on different plans list different models", async () => { // nothing about the plan is kept between calls: a module global would let // the first account's plan filter the second's list diff --git a/packages/sensenova/lib/models.mjs b/packages/sensenova/lib/models.mjs index 38d773e..50fa16b 100644 --- a/packages/sensenova/lib/models.mjs +++ b/packages/sensenova/lib/models.mjs @@ -368,20 +368,42 @@ function modalityFlags(modalities) { }; } +/** + * 官方文档逐个模型写明的 reasoning effort 取值(muran_91096 在 Discord 上贴的 + * SenseNova 文档,2026-11-10)。表里的模型就给文档写的这些档;不在表里的仍是 + * 刻意收窄的通用三档 none/low/high——多给一档会在任务中途冒出 400。 + */ +export const DOC_EFFORTS = { + "glm-5.3": ["low", "high", "max"], + "deepseek-flash": ["none", "low", "high", "max"], + "deepseek-v4-flash": ["none", "minimal", "low", "medium", "high", "xhigh", "max"], + "kimi-k3": ["low", "medium", "high", "max"], +}; + +const COMMON_EFFORTS = ["none", "low", "high"]; + +/** 一个模型能给的档位:文档写明的,否则是它声明的档里属于通用三档的。 */ +function effortsOf(m) { + if (DOC_EFFORTS[m.id]) return DOC_EFFORTS[m.id]; + const efforts = Array.isArray(m.efforts) && m.efforts.length ? m.efforts : COMMON_EFFORTS; + return efforts.filter((x) => COMMON_EFFORTS.includes(x)); +} + /** * 推理档位:每个 key 是档位,value 是该协议真正要发的参数。 * Chat 用 reasoningEffort;Anthropic 用 thinking/output_config;Responses 只留 none。 */ function variantsOf(m, protocol = "chat") { if (m.reasoning !== true) return {}; - const efforts = Array.isArray(m.efforts) && m.efforts.length ? m.efforts : ["none", "low", "high"]; const out = {}; - for (const level of efforts.filter((x) => ["none", "low", "high"].includes(x))) { + for (const level of effortsOf(m)) { if (protocol === "responses") { if (level === "none") out[level] = { reasoningEffort: "none" }; continue; } if (protocol === "anthropic") { + // Anthropic 的 effort 没有 minimal / xhigh + if (level === "minimal" || level === "xhigh") continue; out[level] = level === "none" ? { thinking: { type: "disabled" } } @@ -455,9 +477,9 @@ export function fellBack(map) { /** * A catalogue row as the provider lists it (the shape api.test.mjs reads). * The reasoning tiers are the catalogue's own supported_features gate: a model - * that stops reasoning stops offering tiers. The tier set is deliberately the - * common three (none/low/high): the platform publishes no per-model list, and - * a wrong tier is answered loudly with a 400 rather than silently. + * that stops reasoning stops offering tiers. A model whose tiers SenseNova's + * docs list (DOC_EFFORTS) gets those; any other the deliberately narrow common + * three (none/low/high): a wrong tier is answered with a 400 mid-task. */ export function modelOf(row) { const r = row ?? {}; @@ -478,7 +500,7 @@ export function modelOf(row) { input: { text: true, image }, output: { text: true }, }, - ...(reasoning ? { variants: { none: { reasoningEffort: "none" }, low: { reasoningEffort: "low" }, high: { reasoningEffort: "high" } } } : {}), + ...(reasoning ? { variants: variantsOf({ id: r.id, reasoning: true }) } : {}), }; return out; } \ No newline at end of file diff --git a/packages/sensenova/package.json b/packages/sensenova/package.json index 434e1ac..d026b4c 100644 --- a/packages/sensenova/package.json +++ b/packages/sensenova/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-sensenova-auth", - "version": "0.2.1", + "version": "0.2.2", "description": "SenseNova (SenseTime 日日新) Token Plan in OpenCode and magpie: browser or password sign-in for the credit pools, windows and grants, plus the plan's models through a Token Plan API key", "type": "module", "main": "./opencode.mjs",