diff --git a/packages/opendesign/index.mjs b/packages/opendesign/index.mjs index 0e33463..c91e3d0 100644 --- a/packages/opendesign/index.mjs +++ b/packages/opendesign/index.mjs @@ -42,6 +42,11 @@ const MODEL_WIRE = { "glm-5.3-flash": "anthropic", } const wireOf = (id) => WIRE[MODEL_WIRE[id]] ?? WIRE.chat +// alsoOf are the two APIs besides its own a model is served on (below), +// which magpie relays a client's request to as it was sent rather than +// translating it to the declared one (m.also; gaubeebangeel on X: +// OpenDesign's Anthropic request to a chat model went as chat completions) +const alsoOf = (id) => Object.values(WIRE).filter((w) => w !== wireOf(id)) // The API a model is declared on is only its default: amr-link serves // every model on all three (keyblues, plugins#888: each of the fourteen // answered on chat completions and Responses at /v1 and on Anthropic's @@ -346,6 +351,7 @@ function modelOf(id, m) { // the API magpie asks this model on (WIRE above), per model api: { npm: wireOf(id) }, provider: { npm: wireOf(id) }, + also: alsoOf(id), ...(rate && { rate }), limit: { context: Number.isFinite(context) && context > 0 ? context : 200_000, @@ -370,6 +376,7 @@ function servedOf(id, m) { id, name: c.name, api: { id, url: LINK, npm: wireOf(id) }, + also: alsoOf(id), status: "active", headers: {}, options: {}, @@ -528,7 +535,7 @@ export const OpenDesignAuthPlugin = async () => { // catalog's 232000 for glm-5.3-flash, which amr-link refuses (CAP) const out = Number(m.limit?.output) const limit = CAP[id] && !(out > 0 && out <= CAP[id]) ? { limit: { ...(m.limit ?? {}), output: CAP[id] } } : {} - models[id] = { ...m, ...limit, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, ...(rate && { rate }) } + models[id] = { ...m, ...limit, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, also: alsoOf(id), ...(rate && { rate }) } } cfg.provider[ID] = { name: "Open Design", diff --git a/packages/opendesign/index.test.mjs b/packages/opendesign/index.test.mjs index e180ceb..f18d108 100644 --- a/packages/opendesign/index.test.mjs +++ b/packages/opendesign/index.test.mjs @@ -153,6 +153,7 @@ test("the account's list is the vendor's own, live", () => { 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-compatible" }, + also: ["@ai-sdk/openai", "@ai-sdk/anthropic"], status: "active", headers: {}, options: {}, @@ -365,6 +366,19 @@ test("each model is asked on the API amr-link thinks on (plugins#141)", async () expect(p.models["kimi-k2.7-code"].provider.npm).toBe("@ai-sdk/openai-compatible") }) +test("each model says the two other APIs amr-link serves it on (plugins#888)", async () => { + // magpie relays a client's request on any of them as it was sent: an + // Anthropic request to a chat model went upstream as chat completions + // (gaubeebangeel on X) + const models = I.modelsOf(CATALOG) + expect(models["gpt-6-luna"].also).toEqual(["@ai-sdk/openai", "@ai-sdk/anthropic"]) + expect(models["deepseek-v4-pro"].also).toEqual(["@ai-sdk/openai-compatible", "@ai-sdk/anthropic"]) + const cfg = {} + await (await OpenDesignAuthPlugin({})).config(cfg) + expect(cfg.provider.opendesign.models["glm-5.3-flash"].also).toEqual(["@ai-sdk/openai-compatible", "@ai-sdk/openai"]) + expect(cfg.provider.opendesign.models["deepseek-v4.1-flash"].also).toEqual(["@ai-sdk/openai", "@ai-sdk/anthropic"]) +}) + // ---- what magpie is given ---------------------------------------------------- test("the plugin declares the provider and answers its methods", async () => { @@ -383,6 +397,7 @@ test("the plugin declares the provider and answers its methods", async () => { name: "DeepSeek V4.1 Flash", api: { npm: "@ai-sdk/openai-compatible" }, provider: { npm: "@ai-sdk/openai-compatible" }, + also: ["@ai-sdk/openai", "@ai-sdk/anthropic"], attachment: true, tool_call: true, reasoning: true, diff --git a/packages/opendesign/package.json b/packages/opendesign/package.json index fe8f801..7f98fa6 100644 --- a/packages/opendesign/package.json +++ b/packages/opendesign/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-opendesign-auth", - "version": "0.1.12", + "version": "0.1.13", "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": "./opencode.mjs",