diff --git a/packages/workbuddy/efforts.test.mjs b/packages/workbuddy/efforts.test.mjs new file mode 100644 index 0000000..c8d1723 --- /dev/null +++ b/packages/workbuddy/efforts.test.mjs @@ -0,0 +1,36 @@ +// plugins#255 (kylesean): eight models in WorkBuddy's /v3/config say +// supportsReasoning and a default reasoning.effort but no +// reasoning.supportedEfforts, so the plugin listed them as not reasoning. +// testdata/config-efforts.json is WorkBuddy AI's own config (2026-10-20, +// descriptions left out), cut to those models and a few beside them. +import { afterEach, expect, test } from "bun:test" +import { readFileSync } from "node:fs" +import { _internal } from "./index.mjs" + +const real = globalThis.fetch +afterEach(() => (globalThis.fetch = real)) + +const config = readFileSync(new URL("./testdata/config-efforts.json", import.meta.url), "utf8") + +async function listed() { + globalThis.fetch = async () => new Response(config) + const out = await _internal.liveModels(_internal.SITES["workbuddy-ai"], { access: "a", uid: "u" }) + return Object.fromEntries(out.map((m) => [m.id, m.efforts])) +} + +test("a model that says only supportsReasoning and a default takes low, high, max and its default", async () => { + const e = await listed() + expect(e["fast-model"]).toEqual(["low", "medium", "high", "max"]) + expect(e["kimi-k3"]).toEqual(["low", "medium", "high", "max"]) + expect(e["gemini-3.5-flash"]).toEqual(["low", "medium", "high", "max"]) + expect(e["primary-model"]).toEqual(["low", "high", "max"]) + expect(e["deepseek-v4.1-flash-sg"]).toEqual(["low", "high", "max"]) +}) + +test("listed efforts are kept as they are, and a model that doesn't reason gets none", async () => { + const e = await listed() + expect(e["hy3"]).toEqual(["low", "high"]) + expect(e["gpt-5.6-sol"]).toEqual(["none", "low", "medium", "high", "xhigh", "max"]) + expect(e["glm-5.2"]).toEqual(["none", "high", "xhigh"]) + expect(e["default-model"]).toBeUndefined() +}) diff --git a/packages/workbuddy/index.mjs b/packages/workbuddy/index.mjs index 58700c3..2e0f48c 100644 --- a/packages/workbuddy/index.mjs +++ b/packages/workbuddy/index.mjs @@ -1461,6 +1461,21 @@ function priceOf(d, promotions, now = Date.now()) { return { free: base === 0, rate: base } } +// effortsOf are the levels a config model takes. Most list them in +// reasoning.supportedEfforts; some (fast-model, deepseek-v4.1-flash, kimi-k3, +// gemini-3.5-flash … on both sites, plugins#255) say only supportsReasoning +// and a default reasoning.effort. Those take low, high and max (each +// reasoned under a real account, on four of them) and their own default. +const EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"] +function effortsOf(d) { + const said = d.reasoning?.supportedEfforts + if (Array.isArray(said) && said.length) return said + if (d.supportsReasoning !== true) return [] + const own = d.reasoning?.effort + const set = new Set(["low", "high", "max", ...(typeof own === "string" && EFFORT_ORDER.includes(own) ? [own] : [])]) + return EFFORT_ORDER.filter((e) => set.has(e)) +} + async function liveModels(site, a) { const headers = new Headers() sign(site, a, headers) @@ -1483,7 +1498,7 @@ async function liveModels(site, a) { m.output = d.maxOutputTokens m.images = d.supportsImages === true && !textOnly(site, id) Object.assign(m, priceOf(d, cfg.modelPromotions)) - const es = d.reasoning?.supportedEfforts ?? [] + const es = effortsOf(d) if (es.length) { const canOff = d.reasoning?.canDisableThinking m.efforts = [...(!d.onlyReasoning && (canOff == null || canOff) ? ["none"] : []), ...es] diff --git a/packages/workbuddy/package.json b/packages/workbuddy/package.json index f090a93..5b3698c 100644 --- a/packages/workbuddy/package.json +++ b/packages/workbuddy/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-workbuddy-auth", - "version": "0.1.25", + "version": "0.1.26", "description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)", "type": "module", "main": "./index.mjs", diff --git a/packages/workbuddy/testdata/config-efforts.json b/packages/workbuddy/testdata/config-efforts.json new file mode 100644 index 0000000..c849a64 --- /dev/null +++ b/packages/workbuddy/testdata/config-efforts.json @@ -0,0 +1,233 @@ +{ + "code": 0, + "data": { + "models": [ + { + "credits": "", + "id": "default-model", + "isDefault": true, + "maxAllowedSize": 200000, + "maxInputTokens": 176000, + "maxOutputTokens": 24000, + "name": "Auto", + "supportsImages": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "e" + }, + { + "credits": "x0.34 credits", + "id": "fast-model", + "maxAllowedSize": 200000, + "maxInputTokens": 200000, + "maxOutputTokens": 32000, + "name": "Fast", + "onlyReasoning": true, + "reasoning": { + "effort": "medium", + "summary": "auto" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "i" + }, + { + "credits": "x3.31 credits", + "id": "primary-model", + "maxAllowedSize": 272000, + "maxInputTokens": 272000, + "maxOutputTokens": 72000, + "name": "Primary", + "onlyReasoning": true, + "reasoning": { + "effort": "high", + "summary": "auto" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "vendor": "e" + }, + { + "contextWindow": { + "defaultLength": 300000, + "supportedLengths": [ + 300000, + 1000000 + ] + }, + "credits": "x0.03", + "id": "deepseek-v4.1-flash-sg", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 128000, + "name": "Deepseek-V4.1-Flash", + "onlyReasoning": true, + "reasoning": { + "effort": "high", + "summary": "auto" + }, + "relatedModels": { + "lite": "deepseek-v4.1-flash-sg", + "reasoning": "deepseek-v4.1-flash-sg" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + }, + { + "credits": "x0.00", + "disabledMultimodal": false, + "id": "hy3", + "maxAllowedSize": 192000, + "maxInputTokens": 192000, + "maxOutputTokens": 64000, + "name": "Hy3", + "onlyReasoning": true, + "reasoning": { + "canDisableThinking": false, + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "low", + "high" + ] + }, + "relatedModels": { + "lite": "hy3", + "reasoning": "hy3" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "tags": [ + "craft" + ], + "temperature": 0.9, + "top_p": 1, + "vendor": "j" + }, + { + "credits": "x3.47", + "id": "gpt-5.6-sol", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 128000, + "name": "GPT-5.6-Sol", + "onlyReasoning": false, + "reasoning": { + "canDisableThinking": true, + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "low", + "medium", + "high", + "xhigh", + "max" + ] + }, + "relatedModels": { + "lite": "gpt-5.6-sol", + "reasoning": "gpt-5.6-sol" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "tags": [], + "vendor": "e" + }, + { + "credits": "x0.99", + "id": "gemini-3.5-flash", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 65536, + "name": "Gemini-3.5-Flash", + "onlyReasoning": true, + "reasoning": { + "effort": "medium", + "summary": "auto" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "tags": [], + "temperature": 1, + "vendor": "e" + }, + { + "credits": "x0.79", + "id": "glm-5.2", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 48000, + "name": "GLM-5.2", + "onlyReasoning": false, + "reasoning": { + "canDisableThinking": true, + "defaultEffort": "high", + "summary": "auto", + "supportedEfforts": [ + "high", + "xhigh" + ] + }, + "relatedModels": { + "lite": "glm-5.2", + "reasoning": "glm-5.2" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "tags": [ + "craft" + ], + "temperature": 1, + "vendor": "e" + }, + { + "credits": "x1.62", + "id": "kimi-k3", + "maxAllowedSize": 1000000, + "maxInputTokens": 1000000, + "maxOutputTokens": 32000, + "name": "Kimi-K3", + "onlyReasoning": true, + "reasoning": { + "effort": "medium", + "summary": "auto" + }, + "relatedModels": { + "lite": "kimi-k3-1", + "reasoning": "kimi-k3-1" + }, + "supportsImages": true, + "supportsReasoning": true, + "supportsToolCall": true, + "temperature": 1, + "vendor": "f" + } + ], + "agents": [ + { + "name": "cli", + "models": [ + "default-model", + "fast-model", + "primary-model", + "hy3", + "deepseek-v4.1-flash-sg", + "gpt-5.6-sol", + "gemini-3.5-flash", + "glm-5.2", + "kimi-k3" + ] + } + ] + } +}