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.
This commit is contained in:
yetone
2026-11-14 17:48:20 +08:00
parent 8e19b6a0e7
commit da17052c0c
3 changed files with 45 additions and 2 deletions
+27 -1
View File
@@ -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 {
+17
View File
@@ -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", () => {
+1 -1
View File
@@ -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",