From da17052c0c0691b16746a089c510b42e9ec882d0 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 14 Nov 2026 17:48:20 +0800 Subject: [PATCH] loomy 0.1.8: the vendor's vision, reasoning and tool calls reach the host (#1141) The models hook gave each listed model in OpenCode's config shape (modalities, reasoning, tool_call), and replaced the entry it was given with it. The host (magpie's and OpenCode's) reads a listed model by its runtime shape: capabilities.input.image, capabilities.reasoning, capabilities.toolcall. So a model models.dev doesn't know, like deepseek-v4-flash-1017, went as one of no known vision, and its reasoning and tool calls were dropped too. listedModel now merges over the existing entry, keeps the config's fields, and sets capabilities from what the vendor says; what it doesn't say keeps what was known of the model. Run (mica, temp HOME): packages/loomy bun test 33 pass; bun scripts/check.mjs loomy ok. With main's index.mjs the new test fails (32 pass, 1 fail). Not tried against a real Loomy account. --- packages/loomy/index.mjs | 28 +++++++++++++++++++++++++++- packages/loomy/index.test.mjs | 17 +++++++++++++++++ packages/loomy/package.json | 2 +- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/packages/loomy/index.mjs b/packages/loomy/index.mjs index 885bc59..34c03d7 100644 --- a/packages/loomy/index.mjs +++ b/packages/loomy/index.mjs @@ -341,6 +341,32 @@ function catalogModel(entry) { return { id, config } } +// listedModel is the vendor's entry as the models hook gives it: the +// config's fields, and the capabilities OpenCode (and magpie's host) read +// a listed model by. The config's fields alone left the vendor's vision, +// reasoning and tool calls unread, so deepseek-v4-flash-1017, which +// models.dev doesn't know, went as a text-only model of no known +// vision (plugins#1141). What the vendor doesn't say keeps what was known +// of the model (models.dev, the static table). +function listedModel(was, m, entry) { + const caps = entry?.capabilities ?? {} + const had = was?.capabilities ?? { temperature: true, toolcall: true, input: { text: true }, output: { text: true } } + const capabilities = { ...had, input: { ...(had.input ?? { text: true }) } } + if (typeof caps.reasoning === "boolean") capabilities.reasoning = caps.reasoning + if (typeof caps.function_calling === "boolean") capabilities.toolcall = caps.function_calling + if (typeof caps.vision === "boolean") { + capabilities.input.image = caps.vision + capabilities.attachment = caps.vision + } + return { + ...(was ?? {}), + ...m.config, + id: m.id, + limit: { ...(was?.limit ?? {}), ...(m.config.limit ?? {}) }, + capabilities, + } +} + // ── the plugin ───────────────────────────────────────────────────────────── export async function LoomyAuthPlugin({ client } = {}) { @@ -641,7 +667,7 @@ export async function LoomyAuthPlugin({ client } = {}) { for (const entry of entries) { const m = catalogModel(entry) if (!m) continue - p.models[m.id] = m.config + p.models[m.id] = listedModel(p.models[m.id], m, entry) } return p.models } catch { diff --git a/packages/loomy/index.test.mjs b/packages/loomy/index.test.mjs index a9146b2..8c64346 100644 --- a/packages/loomy/index.test.mjs +++ b/packages/loomy/index.test.mjs @@ -299,6 +299,23 @@ describe("models", () => { expect(list["plain"].rate).toBeUndefined() expect(list["plain"].name).toBe("No Suffix At All") }) + + // plugins#1141: the host reads a listed model by OpenCode's shape + // (capabilities.input.image, capabilities.reasoning, capabilities.toolcall), + // so the vendor's vision and reasoning go there too. + test("the vendor's capabilities, in the shape the host reads", async () => { + const p = { models: { "deepseek-v4-flash": { id: "deepseek-v4-flash", name: "DS", limit: { context: 1000000, output: 64000 }, capabilities: { temperature: true, reasoning: false, attachment: false, toolcall: true, input: { text: true, image: false }, output: { text: true } }, api: { id: "deepseek-v4-flash", npm: "@ai-sdk/openai-compatible" } } } } + const list = await plugin.provider.models(p, { auth: saved }) + expect(list["glm-5.3-flash"].capabilities.input.image).toBe(true) + expect(list["glm-5.3-flash"].capabilities.attachment).toBe(true) + expect(list["spark-x"].capabilities.reasoning).toBe(true) + expect(list["spark-x"].capabilities.toolcall).toBe(true) + expect(list["spark-x"].capabilities.input.image).toBe(false) + // what the vendor doesn't say keeps what was known of the model + expect(list["deepseek-v4-flash"].limit.context).toBe(1000000) + expect(list["deepseek-v4-flash"].api.npm).toBe("@ai-sdk/openai-compatible") + expect(list["deepseek-v4-flash"].rate).toBe("x3.0") + }) }) describe("usage", () => { diff --git a/packages/loomy/package.json b/packages/loomy/package.json index 755ae04..3c7d442 100644 --- a/packages/loomy/package.json +++ b/packages/loomy/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-loomy-auth", - "version": "0.1.7", + "version": "0.1.8", "description": "OpenCode & Magpie provider plugin for Loomy (讯飞, loomyad.xunfei.cn): SMS sign-in, chat, models, the two point wallets and the daily first-login grant", "type": "module", "main": "./opencode.mjs",