diff --git a/packages/opendesign/README.md b/packages/opendesign/README.md index ffe91e6..9068fa6 100644 --- a/packages/opendesign/README.md +++ b/packages/opendesign/README.md @@ -81,9 +81,12 @@ The script keeps the names and measured levels already there — the catalog carries neither — and reads nothing else: no secret is written to the file or printed. -Requests go to the **Responses** API (`@ai-sdk/openai` at -`https://amr-link.open-design.ai/v1`), which is what an Open Design API key -page recommends for Codex-style clients and what keeps thinking intact. +Requests go to `https://amr-link.open-design.ai/v1`, each model on the API +amr-link answers its thinking on (measured, plugins#141): chat completions +(`@ai-sdk/openai-compatible`) for most, the Responses API (`@ai-sdk/openai`) +for `claude-haiku-5.5` and `deepseek-v4-pro`, and Anthropic's messages +(`@ai-sdk/anthropic`) for `glm-5.3-flash`. Every model reasons at `low`, +`high` and `max`. ## Where the sign-in is kept diff --git a/packages/opendesign/index.mjs b/packages/opendesign/index.mjs index 1989482..8063a0b 100644 --- a/packages/opendesign/index.mjs +++ b/packages/opendesign/index.mjs @@ -21,7 +21,28 @@ import { MODELS } from "./models.mjs" const ID = "opendesign" const CONTROL = "https://amr-api.open-design.ai" const LINK = "https://amr-link.open-design.ai/v1" -const NPM = "@ai-sdk/openai" // the Responses API, at LINK +// WHICH API each model is asked on: magpie reads the protocol off the AI SDK +// package a model declares (its api.npm) — "@ai-sdk/openai" is the Responses +// API, "@ai-sdk/anthropic" Anthropic's messages, the compatible package chat +// completions. amr-link answers thinking on a different one per model +// (sryimnoob123's measurements, plugins#141: a streaming request to each model +// on each of the three): chat completions carries the thinking of ten of the +// eleven; deepseek-v4-pro and claude-haiku-5.5 think longer on Responses, and +// glm-5.3-flash only thinks on Anthropic's messages among the two others. +const WIRE = { + chat: "@ai-sdk/openai-compatible", + responses: "@ai-sdk/openai", + anthropic: "@ai-sdk/anthropic", +} +const MODEL_WIRE = { + "claude-haiku-5.5": "responses", + "deepseek-v4-pro": "responses", + "glm-5.3-flash": "anthropic", +} +const wireOf = (id) => WIRE[MODEL_WIRE[id]] ?? WIRE.chat +// the provider's own default: a model this plugin doesn't name is asked on +// chat completions, where ten of the eleven thought +const NPM = WIRE.chat const SOURCE = "opencode-opendesign-auth/" + pkg.version // as the manifest has it const CLI_VERSION = "0.1.4" // what the sign-in says it is, as the CLI does const TIMEOUT = 20_000 @@ -261,6 +282,9 @@ function modelOf(id, m) { tool_call: true, reasoning: thinking, ...(levels.length && { variants: Object.fromEntries(levels.map((e) => [e, { reasoningEffort: e }])) }), + // the API magpie asks this model on (WIRE above), per model + api: { npm: wireOf(id) }, + provider: { npm: wireOf(id) }, ...(rate && { rate }), limit: { context: Number.isFinite(context) && context > 0 ? context : 200_000, @@ -284,7 +308,7 @@ function servedOf(id, m) { return { id, name: c.name, - api: { id, url: LINK, npm: NPM }, + api: { id, url: LINK, npm: wireOf(id) }, status: "active", headers: {}, options: {}, @@ -400,12 +424,19 @@ export const OpenDesignAuthPlugin = async () => { config: async (cfg) => { cfg.provider ??= {} const was = cfg.provider[ID] ?? {} + // the wire is this plugin's to declare, never a kept copy's: magpie + // hands back what the hook last wrote, and a model kept from 0.1.5 + // would otherwise stay on the Responses API it chose for every model + const models = { ...seed(), ...(was.models ?? {}) } + for (const [id, m] of Object.entries(models)) { + models[id] = { ...m, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) } } + } cfg.provider[ID] = { name: "Open Design", - npm: NPM, api: LINK, ...was, - models: { ...seed(), ...(was.models ?? {}) }, + npm: NPM, + models, } }, // the plan decides which models an account gets, so the list is read diff --git a/packages/opendesign/index.test.mjs b/packages/opendesign/index.test.mjs index 61fd8bc..e84beca 100644 --- a/packages/opendesign/index.test.mjs +++ b/packages/opendesign/index.test.mjs @@ -150,7 +150,7 @@ test("the account's list is the vendor's own, live", () => { expect(models["gpt-6-luna"]).toEqual({ id: "gpt-6-luna", name: "GPT-6 Luna", - api: { id: "gpt-6-luna", url: "https://amr-link.open-design.ai/v1", npm: "@ai-sdk/openai" }, + api: { id: "gpt-6-luna", url: "https://amr-link.open-design.ai/v1", npm: "@ai-sdk/openai-compatible" }, status: "active", headers: {}, options: {}, @@ -180,12 +180,13 @@ test("the account's list is the vendor's own, live", () => { }) }) -// #137 (sryimnoob123): amr-link took reasoning_effort low and high on all 11 +// #137 (sryimnoob123): amr-link took reasoning_effort low and high (max too, +// plugins#141) on all 11 // models, and every one but GPT-6 Luna thought at it, "standard" or not test("a signed-in account's models reason at the levels amr-link took (#137)", () => { const models = I.modelsOf(CATALOG) - expect(asMagpieReads(models["deepseek-v4-pro"])).toEqual({ reasoning: true, variants: ["low", "high"], image: false }) - expect(models["deepseek-v4-pro"].variants).toEqual({ low: { reasoningEffort: "low" }, high: { reasoningEffort: "high" } }) + expect(asMagpieReads(models["deepseek-v4-pro"])).toEqual({ reasoning: true, variants: ["low", "high", "max"], image: false }) + expect(models["deepseek-v4-pro"].variants).toEqual({ low: { reasoningEffort: "low" }, high: { reasoningEffort: "high" }, max: { reasoningEffort: "max" } }) // took the level and never thought at it expect(asMagpieReads(models["gpt-6-luna"])).toEqual({ reasoning: false, variants: [], image: true }) // "advanced" but never measured: it reasons, at no level said for it @@ -194,7 +195,7 @@ test("a signed-in account's models reason at the levels amr-link took (#137)", ( const standard = I.modelsOf({ data: ["claude-haiku-5.5", "deepseek-v4-flash", "deepseek-v4-flash-vision-exp", "mimo-v2.6-flash"].map((id) => ({ id, metadata: { capability: "standard" } })), }) - for (const m of Object.values(standard)) expect(asMagpieReads(m)).toMatchObject({ reasoning: true, variants: ["low", "high"] }) + for (const m of Object.values(standard)) expect(asMagpieReads(m)).toMatchObject({ reasoning: true, variants: ["low", "high", "max"] }) }) test("the seed's models carry the measured levels as the config's variants", async () => { @@ -204,17 +205,17 @@ test("the seed's models carry the measured levels as the config's variants", asy const models = cfg.provider.opendesign.models const levels = Object.fromEntries(Object.entries(models).map(([id, m]) => [id, m.reasoning ? Object.keys(m.variants ?? {}) : null])) expect(levels).toEqual({ - "claude-haiku-5.5": ["low", "high"], - "deepseek-v4-flash": ["low", "high"], - "deepseek-v4-flash-vision-exp": ["low", "high"], - "deepseek-v4-pro": ["low", "high"], - "deepseek-v4.1-flash": ["low", "high"], - "glm-5.3-flash": ["low", "high"], - "glm-5.3-flashx": ["low", "high"], + "claude-haiku-5.5": ["low", "high", "max"], + "deepseek-v4-flash": ["low", "high", "max"], + "deepseek-v4-flash-vision-exp": ["low", "high", "max"], + "deepseek-v4-pro": ["low", "high", "max"], + "deepseek-v4.1-flash": ["low", "high", "max"], + "glm-5.3-flash": ["low", "high", "max"], + "glm-5.3-flashx": ["low", "high", "max"], "gpt-6-luna": null, - "kimi-k2.7-code": ["low", "high"], - "mimo-v2.6-flash": ["low", "high"], - "mimo-v2.6-pro": ["low", "high"], + "kimi-k2.7-code": ["low", "high", "max"], + "mimo-v2.6-flash": ["low", "high", "max"], + "mimo-v2.6-pro": ["low", "high", "max"], }) expect(models["claude-haiku-5.5"].variants.high).toEqual({ reasoningEffort: "high" }) }) @@ -224,6 +225,23 @@ test("an empty catalog is no models", () => { expect(I.modelsOf(null)).toEqual({}) }) +test("each model is asked on the API amr-link thinks on (plugins#141)", async () => { + expect(I.modelsOf(CATALOG)["deepseek-v4-pro"].api.npm).toBe("@ai-sdk/openai") + expect(I.modelsOf(CATALOG)["gpt-6-luna"].api.npm).toBe("@ai-sdk/openai-compatible") + // a model kept from 0.1.5, which put every model on the Responses API, + // is moved to its own wire + const kept = { "glm-5.3-flash": { id: "glm-5.3-flash", name: "GLM", provider: { npm: "@ai-sdk/openai" }, api: { npm: "@ai-sdk/openai" } } } + const cfg = { provider: { opendesign: { npm: "@ai-sdk/openai", models: kept } } } + await (await OpenDesignAuthPlugin({})).config(cfg) + const p = cfg.provider.opendesign + expect(p.npm).toBe("@ai-sdk/openai-compatible") + expect(p.models["glm-5.3-flash"].provider.npm).toBe("@ai-sdk/anthropic") + expect(p.models["glm-5.3-flash"].api.npm).toBe("@ai-sdk/anthropic") + expect(p.models["glm-5.3-flash"].name).toBe("GLM") + expect(p.models["claude-haiku-5.5"].provider.npm).toBe("@ai-sdk/openai") + expect(p.models["kimi-k2.7-code"].provider.npm).toBe("@ai-sdk/openai-compatible") +}) + // ---- what magpie is given ---------------------------------------------------- test("the plugin declares the provider and answers its methods", async () => { @@ -232,7 +250,7 @@ test("the plugin declares the provider and answers its methods", async () => { await hooks.config(cfg) expect(cfg.provider.opendesign).toMatchObject({ name: "Open Design", - npm: "@ai-sdk/openai", + npm: "@ai-sdk/openai-compatible", api: "https://amr-link.open-design.ai/v1", }) // the seed models.mjs carries, which a signed-in account's list replaces @@ -240,10 +258,12 @@ test("the plugin declares the provider and answers its methods", async () => { expect(cfg.provider.opendesign.models["deepseek-v4.1-flash"]).toEqual({ id: "deepseek-v4.1-flash", name: "DeepSeek V4.1 Flash", + api: { npm: "@ai-sdk/openai-compatible" }, + provider: { npm: "@ai-sdk/openai-compatible" }, attachment: true, tool_call: true, reasoning: true, - variants: { low: { reasoningEffort: "low" }, high: { reasoningEffort: "high" } }, + variants: { low: { reasoningEffort: "low" }, high: { reasoningEffort: "high" }, max: { reasoningEffort: "max" } }, rate: "x0.5", limit: { context: 1048000, output: 232000 }, modalities: { input: ["text", "image"], output: ["text"] }, diff --git a/packages/opendesign/models.mjs b/packages/opendesign/models.mjs index 75b8673..aa78ad0 100644 --- a/packages/opendesign/models.mjs +++ b/packages/opendesign/models.mjs @@ -8,18 +8,19 @@ // the non-text modalities it takes; cost and capability: the vendor's own // words, which the plugin turns into magpie's rate and thinking flags; // efforts: the reasoning levels amr-link was seen to take and think at, -// measured, not read (#137), so a refresh keeps them. +// measured, not read (#137; max too, plugins#141: the vendor names low, high +// and max when asked for one it doesn't take), so a refresh keeps them. export const MODELS = { - "claude-haiku-5.5": { name: "Claude Haiku 5.5", context: 1000000, output: 132000, input: ["image", "file"], cost: "low", capability: "standard", efforts: ["low", "high"] }, - "deepseek-v4-flash": { name: "DeepSeek V4 Flash", context: 1048000, output: 232000, cost: "medium", capability: "standard", efforts: ["low", "high"] }, - "deepseek-v4-flash-vision-exp": { name: "DeepSeek V4 Flash Vision (exp)", context: 1048000, output: 232000, input: ["image"], cost: "medium", capability: "standard", efforts: ["low", "high"] }, - "deepseek-v4-pro": { name: "DeepSeek V4 Pro", context: 1048000, output: 232000, cost: "high", capability: "advanced", efforts: ["low", "high"] }, - "deepseek-v4.1-flash": { name: "DeepSeek V4.1 Flash", context: 1048000, output: 232000, input: ["image"], cost: "low", capability: "advanced", efforts: ["low", "high"] }, - "glm-5.3-flash": { name: "GLM 5.3 Flash", context: 1048000, output: 232000, input: ["image", "video"], cost: "low", capability: "advanced", efforts: ["low", "high"] }, - "glm-5.3-flashx": { name: "GLM 5.3 FlashX", context: 1000000, output: 232000, input: ["image", "file", "video"], cost: "medium", capability: "advanced", efforts: ["low", "high"] }, + "claude-haiku-5.5": { name: "Claude Haiku 5.5", context: 1000000, output: 132000, input: ["image", "file"], cost: "low", capability: "standard", efforts: ["low", "high", "max"] }, + "deepseek-v4-flash": { name: "DeepSeek V4 Flash", context: 1048000, output: 232000, cost: "medium", capability: "standard", efforts: ["low", "high", "max"] }, + "deepseek-v4-flash-vision-exp": { name: "DeepSeek V4 Flash Vision (exp)", context: 1048000, output: 232000, input: ["image"], cost: "medium", capability: "standard", efforts: ["low", "high", "max"] }, + "deepseek-v4-pro": { name: "DeepSeek V4 Pro", context: 1048000, output: 232000, cost: "high", capability: "advanced", efforts: ["low", "high", "max"] }, + "deepseek-v4.1-flash": { name: "DeepSeek V4.1 Flash", context: 1048000, output: 232000, input: ["image"], cost: "low", capability: "advanced", efforts: ["low", "high", "max"] }, + "glm-5.3-flash": { name: "GLM 5.3 Flash", context: 1048000, output: 232000, input: ["image", "video"], cost: "low", capability: "advanced", efforts: ["low", "high", "max"] }, + "glm-5.3-flashx": { name: "GLM 5.3 FlashX", context: 1000000, output: 232000, input: ["image", "file", "video"], cost: "medium", capability: "advanced", efforts: ["low", "high", "max"] }, "gpt-6-luna": { name: "GPT-6 Luna", context: 1050000, output: 304000, input: ["image", "file"], cost: "low", capability: "standard", efforts: [] }, - "kimi-k2.7-code": { name: "Kimi K2.7 Code", context: 262000, output: 262000, input: ["image"], cost: "medium", capability: "advanced", efforts: ["low", "high"] }, - "mimo-v2.6-flash": { name: "MiMo V2.6 Flash", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "low", capability: "standard", efforts: ["low", "high"] }, - "mimo-v2.6-pro": { name: "MiMo V2.6 Pro", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "medium", capability: "advanced", efforts: ["low", "high"] }, + "kimi-k2.7-code": { name: "Kimi K2.7 Code", context: 262000, output: 262000, input: ["image"], cost: "medium", capability: "advanced", efforts: ["low", "high", "max"] }, + "mimo-v2.6-flash": { name: "MiMo V2.6 Flash", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "low", capability: "standard", efforts: ["low", "high", "max"] }, + "mimo-v2.6-pro": { name: "MiMo V2.6 Pro", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "medium", capability: "advanced", efforts: ["low", "high", "max"] }, } diff --git a/packages/opendesign/package.json b/packages/opendesign/package.json index 2f9a733..e520900 100644 --- a/packages/opendesign/package.json +++ b/packages/opendesign/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-opendesign-auth", - "version": "0.1.5", + "version": "0.1.6", "description": "Open Design Cloud (Design Plan) in OpenCode and magpie: the account's device sign-in, its models, and the plan's 5-hour and 7-day allowance", "type": "module", "main": "./index.mjs",