diff --git a/packages/cline/README.md b/packages/cline/README.md index 86c853e..2f44a21 100644 --- a/packages/cline/README.md +++ b/packages/cline/README.md @@ -62,11 +62,31 @@ subscription page shows). An account without ClinePass (a 404 there) has none; limits that fail to read for any other reason say so on the card beside the balance, and limits read are kept when the balance can't be. -### DeepSeek models only through DeepSeek's own API +### Upstream pinning and Cline's routing policy -Cline's gateway picks among the providers that serve a model. On ClinePass -its own routing for a model wins over `only` alone, so since 0.1.11 a request -for a ClinePass DeepSeek model (`cline-pass/deepseek-…`) carries, by default: +Cline's gateway picks among the providers that serve a model. A request can +ask for the maker's own API, but Cline changed what it accepts: + +- **Since 2026-11-06, Cline refuses `providerOptions` routing.** A request + carrying `"providerOptions"` is answered with + `403: client-supplied "providerOptions" model routing is not supported` + (magpie#5442). This applies to ClinePass DeepSeek models and to the + usage-billed DeepSeek/GLM models that Cline sends through Vercel's AI + Gateway. +- **`glm-5.3-flash` still works, but is not actually pinned.** Cline sends it + through OpenRouter, so the plugin writes a top-level + `"provider": {"only": ["z-ai"]}` rather than `providerOptions` (since + 0.1.10). Cline does not reject that field; it ignores it. In five live + requests with the Upstream tick on, + `provider_metadata.gateway.routing.finalProvider` stayed + `"openai-compatible-private"` (and `canonicalSlug` was + `private/cw-glm-53-flash`), so the request succeeds but stays on Cline's + own route. Check `finalProvider`, not the displayed model name. That is why + it still works while DeepSeek fails. + +The plugin therefore sends no pin by default. With the `pinUpstream` option +on, a request for a ClinePass DeepSeek model (`cline-pass/deepseek-…`) +carries: ```json "providerOptions": {"gateway": {"only": ["deepseek"], "has": ["vision", "implicit-caching"]}} @@ -75,26 +95,17 @@ for a ClinePass DeepSeek model (`cline-pass/deepseek-…`) carries, by default: `has` is the gateway's capability filter: the upstream must cache a repeated prefix by itself, and take images — `vision` is asked only of a model Cline's catalog says takes images (or a request carrying one), never of the text-only -`deepseek-v4-pro`. With it the request is answered by DeepSeek's own API -(hy125245 on X: `finalProvider` `deepseek`, and a fake upstream in `only` -refused with "no matching upstream"). A pinned request that fails with no -upstream matching it, or with a 5xx, goes once more as sent, so the pin -never fails a request that would have worked; a refusal of the account (401, -402, 403, 429) is answered as it is. A request with `provider` or -`providerOptions` of its own — magpie's extra body, say — goes as sent. Set -`pinUpstream` to `false` to send ClinePass's DeepSeek models unpinned. +`deepseek-v4-pro`. Other DeepSeek models carry `only: ["deepseek"]`, and a +GLM model (`cline-pass/glm-…`) carries `only: ["zai"]`, as before. -With the `pinUpstream` option on, a request for any DeepSeek model (not the -`cline-free/` ones) is pinned too, the ClinePass ones as above without the -way back, the others with `"providerOptions": {"gateway": {"only": -["deepseek"]}}`, so it is answered by DeepSeek's own API only, and one for a -GLM model (`cline-pass/glm-…`) carries `["zai"]`, so it is answered by Z.ai's -own API only — the same as magpie's built-in ClinePass tick. Cline sends -`glm-5.3-flash` through OpenRouter rather than Vercel's gateway, and OpenRouter -ignores `providerOptions`, so that model's request carries OpenRouter's own -`"provider": {"only": ["z-ai"]}` instead (since 0.1.10). Other models, and a -request with `provider` or `providerOptions` of its own, go as sent. It is off -by default. Turn it on: +If Cline answers that exact 403, the plugin keeps the failure and says to +turn the pin off; it does not retry unpinned. This preserves the meaning of +the option: a pin that Cline cannot honour is an error, not a silent +downgrade. If Cline restores `providerOptions` routing, the same option works +again without a plugin change. A request with `provider` or +`providerOptions` of its own — magpie's extra body, say — goes as sent. + +The option is off by default. Turn it on: - in magpie: the provider's editor › Upstream › tick "DeepSeek and GLM models only from their makers' own APIs"; diff --git a/packages/cline/index.mjs b/packages/cline/index.mjs index 3ce783a..6726502 100644 --- a/packages/cline/index.mjs +++ b/packages/cline/index.mjs @@ -787,6 +787,15 @@ function usageOf(me, balance, limits) { // deepseek-v4.1-flash-1017 go through Vercel. An exact entry is a model // name; the others match a name's start, the first match winning. magpie's // built-in ClinePass has the same table (internal/provider/cline.go). +// +// Since 2026-11-06 Cline answers a client-supplied providerOptions routing +// field with 403 "client-supplied \"providerOptions\" model routing is not +// supported" (magpie#5442). A providerOptions pin is therefore attempted +// only when pinUpstream is on; an exact 403 is reported with a hint to turn +// it off, never retried unpinned. The top-level provider.only path +// (glm-5.3-flash) is not rejected, but Cline currently ignores it: in live +// replies routing.finalProvider stayed "openai-compatible-private", so the +// request works without being actually pinned. const MAKERS = [ { name: "glm-5.3-flash", exact: true, upstream: "z-ai", openRouter: true }, { name: "deepseek", upstream: "deepseek" }, @@ -799,8 +808,10 @@ const MAKERS = [ // GLM, openRouter true for a model Cline sends through OpenRouter. Cline's // routers otherwise pick among the providers serving the model, and some // answer worse than the maker's own API, which also keeps the prompt cache. -// A cline-free/ model is left to Cline, as is every other maker's model: -// null. +// Cline currently ignores the top-level provider field (live replies kept +// routing.finalProvider "openai-compatible-private"), so the openRouter path +// is sent without error but does not pin. A cline-free/ model is left to +// Cline, as is every other maker's model: null. function pinned(on, model) { if (!on || typeof model !== "string" || model.startsWith("cline-free/")) return null const name = model.slice(model.lastIndexOf("/") + 1).toLowerCase() @@ -811,8 +822,8 @@ function pinned(on, model) { // PASS_DEEPSEEK is a ClinePass DeepSeek model: cline-pass/deepseek-… const PASS_DEEPSEEK = /^cline-pass\/deepseek/i -// passPin is where a ClinePass DeepSeek request is pinned by default: -// DeepSeek's own API, with the gateway's capability filter beside it +// passPin is where a ClinePass DeepSeek request is pinned when pinUpstream +// is on: DeepSeek's own API, with the gateway's capability filter beside it // (hy125245 on X, 10-23). On ClinePass the server's own routing for the // model wins over gateway.only alone, and a fake upstream in only was // served all the same; with has beside it, the request went to DeepSeek @@ -820,22 +831,21 @@ const PASS_DEEPSEEK = /^cline-pass\/deepseek/i // matching upstream". has names what the upstream must do: cache a // repeated prefix by itself ("implicit-caching") and, for a model that // takes images, take them ("vision") — never for a text-only model -// (deepseek-v4-pro), whose upstreams it would all rule out. +// (deepseek-v4-pro), whose upstreams it would all rule out. Cline now +// refuses providerOptions; the fetch path reports that refusal with a hint. const passPin = (images) => ({ gateway: { only: ["deepseek"], has: [...(images ? ["vision"] : []), "implicit-caching"] } }) -// pinOf is the field a request for model is pinned by, or null: a -// ClinePass DeepSeek model always (unless pinUpstream is set off), with -// fallback true when it is magpie's default rather than the user's -// pinUpstream, so a request the pin can't be served under goes again as -// sent; and, with pinUpstream on, the makers' table above. -function pinOf(on, model, images, off = false) { - if (typeof model !== "string") return null - if (PASS_DEEPSEEK.test(model) && !off) return { key: "providerOptions", value: passPin(images), fallback: !on } +// pinOf is the field a request for model is pinned by, or null: with +// pinUpstream on, a ClinePass DeepSeek model asks for DeepSeek with the +// gateway's capability filter, and the makers' table above; off, nothing. +function pinOf(on, model, images) { + if (!on || typeof model !== "string") return null + if (PASS_DEEPSEEK.test(model)) return { key: "providerOptions", value: passPin(images) } const pin = pinned(on, model) if (!pin) return null return pin.openRouter - ? { key: "provider", value: { only: [pin.upstream] }, fallback: false } - : { key: "providerOptions", value: { gateway: { only: [pin.upstream] } }, fallback: false } + ? { key: "provider", value: { only: [pin.upstream] } } + : { key: "providerOptions", value: { gateway: { only: [pin.upstream] } } } } // withField is body with "key":value written in at the end, so the rest of @@ -856,8 +866,8 @@ const ownsRouting = (chat) => chat?.providerOptions !== undefined || chat?.provi // pinBody is the request's body with its pin written in (pinOf), or the // body as sent -function pinBody(body, chat, on, images = false, off = false) { - const pin = ownsRouting(chat) ? null : pinOf(on, chat?.model, images, off) +function pinBody(body, chat, on, images = false) { + const pin = ownsRouting(chat) ? null : pinOf(on, chat?.model, images) return pin ? withField(body, pin.key, pin.value) : body } @@ -865,19 +875,21 @@ function pinBody(body, chat, on, images = false, off = false) { // a bare image part) const hasImages = (body) => /"type"\s*:\s*"(?:image_url|image|input_image)"/.test(body) -// NO_UPSTREAM is the gateway saying no upstream meets the pin -const NO_UPSTREAM = /no (?:matching|available|eligible) (?:upstream|provider|endpoint)s?|no upstream/i - -// unpinWorthy is a pinned request's failure that the same request unpinned -// may well not meet: no upstream matching the pin, or the pinned upstream -// failing (a 5xx). An account's refusal (401, 402, 403, 429) is the -// account's, whatever the pin. -const unpinWorthy = (status, text) => status >= 500 || NO_UPSTREAM.test(String(text ?? "")) +// routingRejected is Cline refusing a client-supplied providerOptions +// routing field. The field is read from the error envelope when there is +// one, so a JSON-escaped message reads the same as a plain one. +const ROUTING_REJECTION = /^(?:Error\s+403:\s*)?client-supplied\s+["“]providerOptions["”]\s+model routing is not supported\.?$/i +function routingRejected(status, text) { + if (status !== 403) return false + let msg = String(text ?? "") + const j = safeJson(msg) + if (typeof j?.error?.message === "string") msg = j.error.message + else if (typeof j?.message === "string") msg = j.message + return ROUTING_REJECTION.test(msg.trim()) +} // isOn is whether an option is set: true, or "true" in a config written by hand const isOn = (v) => v === true || v === "true" -// isOff is an option set off in so many words: false, or "false" -const isOff = (v) => v === false || v === "false" export const ClinePlugin = async ({ client } = {}, options = {}) => { // the accounts fresh renewed this run: the sign-in mark comes off on the @@ -1088,9 +1100,6 @@ export const ClinePlugin = async ({ client } = {}, options = {}) => { // pinUpstream: the plugin's own option, or the provider's in // OpenCode's config (provider.cline.options.pinUpstream) const pin = isOn(options?.pinUpstream) || isOn(provider?.options?.pinUpstream) - // set off in so many words, nothing is pinned, ClinePass's - // DeepSeek models included - const unpinned = isOff(options?.pinUpstream) || isOff(provider?.options?.pinUpstream) if (a?.type !== "oauth" && a?.type !== "api") return {} return { baseURL: API, @@ -1102,18 +1111,16 @@ export const ClinePlugin = async ({ client } = {}, options = {}) => { if (!/\/chat\/completions$/.test(new URL(url).pathname)) return errorResponse({ status: 404, message: "only chat completions are served" }) let body - // sent is the body as the client sent it; fallback is a - // default pin's way back to it - let sent - let fallback = false + // appliedPin is the pin this request carries, if any + let appliedPin = null try { - body = sent = await bodyText(input, init) + body = await bodyText(input, init) const chat = JSON.parse(body) if (!chat || typeof chat !== "object" || Array.isArray(chat)) throw new Error("not a chat completion") - const p = ownsRouting(chat) ? null : pinOf(pin, chat.model, images.get(chat.model) || hasImages(body), unpinned) + const p = ownsRouting(chat) ? null : pinOf(pin, chat.model, images.get(chat.model) || hasImages(body)) if (p) { body = withField(body, p.key, p.value) - fallback = p.fallback + appliedPin = p } } catch { return errorResponse({ status: 400, message: "a request that isn't a chat completion" }) @@ -1139,22 +1146,22 @@ export const ClinePlugin = async ({ client } = {}, options = {}) => { } catch (e) { return signed(errorResponse({ status: 502, message: String(e?.message ?? e) }), renewed(cred)) } - // a default pin never fails a request that would have - // worked: no upstream matching it, or the pinned one - // down, and the request goes once more as sent - if (!res.ok && fallback) { + if (!res.ok) { const text = (await res.text()).slice(0, 1 << 20) - if (!unpinWorthy(res.status, text)) return signed(errorResponse(failure(res.status, text)), renewed(cred)) - try { - res = await fetch(url, { ...init, method: init?.method ?? "POST", headers, body: sent, signal }) - } catch (e) { - return signed(errorResponse({ status: 502, message: String(e?.message ?? e) }), renewed(cred)) - } + // Cline now refuses client-supplied providerOptions + // routing. A pin the user asked for stays a failure; + // the message says how to let Cline route instead. + if (appliedPin?.key === "providerOptions" && routingRejected(res.status, text)) + return signed( + errorResponse({ + status: 403, + message: + 'Cline refused the providerOptions pin (HTTP 403: client-supplied "providerOptions" model routing is not supported). Turn off pinUpstream (the Upstream tick) and let Cline route the model itself; glm-5.3-flash still works, but Cline ignores its top-level provider field, so it is not actually pinned.', + }), + renewed(cred), + ) + return signed(errorResponse(failure(res.status, text)), renewed(cred)) } - // a renewed token cleared the lapse mark whatever the - // request then met, a refused one included (qoder's - // renewed()): the failure is reported, the mark stays off - if (!res.ok) return signed(errorResponse(failure(res.status, (await res.text()).slice(0, 1 << 20))), renewed(cred)) return signed(await unwrapped(res), renewed(cred)) }, } @@ -1212,7 +1219,7 @@ export const _internal = { pinned, pinOf, pinBody, - unpinWorthy, + routingRejected, hasImages, unwrapped, clientHeaders, diff --git a/packages/cline/index.test.mjs b/packages/cline/index.test.mjs index 8bac699..76f9484 100644 --- a/packages/cline/index.test.mjs +++ b/packages/cline/index.test.mjs @@ -1163,9 +1163,11 @@ test("pinBody pins a GLM model to Z.ai's API, keeping the body's prefix", () => // sdytman (#feedback, 10-20): Cline sends glm-5.3-flash through OpenRouter, // not Vercel's AI Gateway, and OpenRouter ignores providerOptions.gateway.only. -// It reads a top-level provider.only with its own slug, "z-ai". DeepSeek's -// v4.1 flash models go through Vercel and keep providerOptions. -test("pinBody pins glm-5.3-flash by OpenRouter's provider.only, keeping the body's prefix", () => { +// It reads a top-level provider.only with its own slug, "z-ai". Cline +// currently ignores that field too, so the request works but is not pinned. +// DeepSeek's v4.1 flash models go through Vercel and use providerOptions when +// pinned (Cline refuses that field; see the pinUpstream tests below). +test("pinBody writes glm-5.3-flash's OpenRouter provider.only, which Cline currently ignores without error", () => { const { pinBody, pinned } = _internal const body = `{"model":"cline-pass/glm-5.3-flash","messages":[{"role":"user","content":"hi"}],"stream":true}` const out = pinBody(body, JSON.parse(body), true) @@ -1225,19 +1227,31 @@ test("without pinUpstream a usage-billed DeepSeek request goes as sent", async ( expect(calls[0].init.body).toBe(JSON.stringify(sent)) }) -// ---- ClinePass's DeepSeek models: pinned to DeepSeek by default ------------------ +// ---- ClinePass's DeepSeek models: pinned only when pinUpstream is on ------------- // // hy125245 on X (10-23): on ClinePass the server's own routing for a model wins // over providerOptions.gateway.only alone (a fake upstream was served all the // same); with the gateway's capability filter beside it, has: ["vision", // "implicit-caching"], the request went to DeepSeek (finalProvider // "deepseek") and a fake upstream was refused with "no matching upstream". +// Since 2026-11-06 Cline refuses the field outright, so it is sent only when +// the user asks for the pin, and that refusal is reported with a hint. const PASS_PIN = (images) => ({ gateway: { only: ["deepseek"], has: [...(images ? ["vision"] : []), "implicit-caching"] } }) -test("a ClinePass DeepSeek request is pinned to DeepSeek by default, vision asked only of a model that takes images", async () => { +test("a ClinePass DeepSeek request goes as sent unless pinUpstream is on", async () => { const { client: c } = client() const hooks = await ClinePlugin({ client: c }) + serve([[chatUrl, () => Response.json({ ok: true })]]) + const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} }) + const sent = { model: "cline-pass/deepseek-v4.1-flash", messages: [] } + await l.fetch(chatUrl, chatInit(sent)) + expect(calls[0].init.body).toBe(JSON.stringify(sent)) +}) + +test("with pinUpstream on a ClinePass DeepSeek request is pinned to DeepSeek, vision asked only of a model that takes images", async () => { + const { client: c } = client() + const hooks = await ClinePlugin({ client: c }, { pinUpstream: true }) serve([0, 1, 2, 3].map(() => [chatUrl, () => Response.json({ ok: true })])) const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} }) const msgs = [{ role: "user", content: "hi" }] @@ -1254,7 +1268,7 @@ test("a ClinePass DeepSeek request is pinned to DeepSeek by default, vision aske test("the models hook's catalog says which ClinePass DeepSeek model the pin asks vision of", async () => { const { client: c } = client() - const hooks = await ClinePlugin({ client: c }) + const hooks = await ClinePlugin({ client: c }, { pinUpstream: true }) serve([ ["/ai/cline/recommended-models", () => Response.json({ clinePass: [{ id: "cline-pass/deepseek-v4.1-flash" }, { id: "cline-pass/deepseek-v4-pro" }] })], ["/ai/cline/models", () => Response.json({ data: [ @@ -1295,44 +1309,38 @@ test("the user's own provider or providerOptions on a ClinePass DeepSeek request expect(res.map((r) => r.status)).toEqual([200, 400, 200, 200]) }) -for (const [why, status, answer] of [ - ["no upstream matches the pin", 400, { error: "no matching upstream" }], - ["no upstream matches the pin (OpenAI's error shape)", 404, { error: { message: "No matching upstream for cline-pass/deepseek-v4-pro" } }], - ["DeepSeek's upstream is down", 503, { error: { message: "upstream unavailable" } }], -]) { - test(`a default pin that fails because ${why} goes once more as sent`, async () => { - const { client: c } = client() - const hooks = await ClinePlugin({ client: c }) - serve([ - [chatUrl, () => Response.json(answer, { status })], - [chatUrl, () => new Response("data: {}\n\n", { headers: { "Content-Type": "text/event-stream" } })], - ]) - const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} }) - const sent = { model: "cline-pass/deepseek-v4.1-flash-1017", messages: [{ role: "user", content: "hi" }], stream: true } - const res = await l.fetch(chatUrl, chatInit(sent)) - expect(res.status).toBe(200) - expect(await res.text()).toBe("data: {}\n\n") - expect(calls.length).toBe(2) - expect(JSON.parse(calls[0].init.body).providerOptions).toEqual(PASS_PIN(true)) - expect(calls[1].init.body).toBe(JSON.stringify(sent)) - // the retry carries the same account and Cline's headers - expect(new Headers(calls[1].init.headers).get("Authorization")).toBe("Bearer ck") - expect(new Headers(calls[1].init.headers).get("X-CLIENT-TYPE")).toBe(CLIENT.type) - }) -} - -test("the unpinned retry runs once: its own failure is the answer", async () => { +test("a client's own providerOptions refused by Cline is passed through, not blamed on pinUpstream", async () => { const { client: c } = client() const hooks = await ClinePlugin({ client: c }) + const own = { model: "cline-pass/deepseek-v4.1-flash", messages: [], providerOptions: { gateway: { only: ["deepseek"] } } } serve([ - [chatUrl, () => Response.json({ error: "no matching upstream" }, { status: 400 })], - [chatUrl, () => Response.json({ error: { message: "upstream unavailable" } }, { status: 503 })], - [chatUrl, () => Response.json({ ok: true })], + [chatUrl, () => Response.json({ error: { message: 'Error 403: client-supplied "providerOptions" model routing is not supported' } }, { status: 403 })], ]) const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} }) - const res = await l.fetch(chatUrl, chatInit({ model: "cline-pass/deepseek-v4-pro", messages: [] })) - expect(res.status).toBe(503) - expect(calls.length).toBe(2) + const res = await l.fetch(chatUrl, chatInit(own)) + expect(res.status).toBe(403) + const body = await res.json() + expect(body.error.message).toBe('Error 403: client-supplied "providerOptions" model routing is not supported') + expect(calls.length).toBe(1) + expect(calls[0].init.body).toBe(JSON.stringify(own)) +}) + +test("a pinUpstream DeepSeek request Cline refuses says how to turn the pin off, and is not retried", async () => { + const { client: c } = client() + const hooks = await ClinePlugin({ client: c }, { pinUpstream: true }) + serve([ + [chatUrl, () => Response.json({ error: { message: 'Error 403: client-supplied "providerOptions" model routing is not supported' } }, { status: 403 })], + ]) + const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} }) + const res = await l.fetch(chatUrl, chatInit({ model: "cline-pass/deepseek-v4.1-flash", messages: [] })) + expect(res.status).toBe(403) + const body = await res.json() + expect(body.error.type).toBe("cline_error") + expect(body.error.message).toContain("Turn off pinUpstream") + expect(body.error.message).toContain("glm-5.3-flash") + expect(body.error.message).toContain("not actually pinned") + expect(calls.length).toBe(1) + expect(JSON.parse(calls[0].init.body).providerOptions).toEqual(PASS_PIN(true)) }) test("a pinned request the account was refused is not retried without the pin", async () => { @@ -1344,7 +1352,7 @@ test("a pinned request the account was refused is not retried without the pin", [400, { error: { message: "messages: field required" } }], ]) { const { client: c } = client() - const hooks = await ClinePlugin({ client: c }) + const hooks = await ClinePlugin({ client: c }, { pinUpstream: true }) serve([[chatUrl, () => Response.json(answer, { status })]]) const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} }) const res = await l.fetch(chatUrl, chatInit({ model: "cline-pass/deepseek-v4.1-flash", messages: [] })) @@ -1366,8 +1374,12 @@ test("other models go as sent: ClinePass's non-DeepSeek, the free DeepSeek and u expect(calls.map((x) => x.init.body)).toEqual(models.map((model) => JSON.stringify({ model, messages: [] }))) }) -test("pinUpstream set off leaves ClinePass's DeepSeek models unpinned; set on, they are pinned with no way back", async () => { - for (const [plugin, provider] of [[{ pinUpstream: false }, undefined], [undefined, { id: "cline", options: { pinUpstream: "false" } }]]) { +test("pinUpstream off, including by default, leaves ClinePass's DeepSeek models unpinned; on, they are pinned and a 400 is not undone", async () => { + for (const [plugin, provider] of [ + [undefined, undefined], + [{ pinUpstream: false }, undefined], + [undefined, { id: "cline", options: { pinUpstream: "false" } }], + ]) { const { client: c } = client() const hooks = await ClinePlugin({ client: c }, plugin) serve([[chatUrl, () => Response.json({ ok: true })]]) @@ -1378,10 +1390,7 @@ test("pinUpstream set off leaves ClinePass's DeepSeek models unpinned; set on, t } const { client: c } = client() const hooks = await ClinePlugin({ client: c }, { pinUpstream: true }) - serve([ - [chatUrl, () => Response.json({ error: "no matching upstream" }, { status: 400 })], - [chatUrl, () => Response.json({ ok: true })], - ]) + serve([[chatUrl, () => Response.json({ error: "no matching upstream" }, { status: 400 })]]) const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" })) const res = await l.fetch(chatUrl, chatInit({ model: "cline-pass/deepseek-v4.1-flash", messages: [] })) // the user asked for DeepSeek's own API only: that is kept, not undone @@ -1390,12 +1399,14 @@ test("pinUpstream set off leaves ClinePass's DeepSeek models unpinned; set on, t expect(JSON.parse(calls[0].init.body).providerOptions).toEqual(PASS_PIN(true)) }) -test("unpinWorthy is a missing upstream or a 5xx, never an account's refusal", () => { - const { unpinWorthy, hasImages } = _internal - expect(unpinWorthy(400, `{"error":"no matching upstream"}`)).toBe(true) - expect(unpinWorthy(404, "No available providers for this model")).toBe(true) - expect(unpinWorthy(502, "")).toBe(true) - for (const s of [400, 401, 402, 403, 429]) expect(unpinWorthy(s, `{"error":"nope"}`)).toBe(false) +test("routingRejected reads Cline's exact providerOptions refusal, and nothing looser", () => { + const { routingRejected, hasImages } = _internal + const exact = 'Error 403: client-supplied "providerOptions" model routing is not supported' + expect(routingRejected(403, exact)).toBe(true) + expect(routingRejected(403, JSON.stringify({ error: { message: exact } }))).toBe(true) + expect(routingRejected(401, exact)).toBe(false) + expect(routingRejected(403, "providerOptions not supported")).toBe(false) + expect(routingRejected(403, "prefix: " + exact)).toBe(false) expect(hasImages(`{"messages":[{"content":[{"type": "image_url"}]}]}`)).toBe(true) expect(hasImages(`{"messages":[{"content":"type image_url"}]}`)).toBe(false) }) diff --git a/packages/cline/package.json b/packages/cline/package.json index a13f396..6a17a81 100644 --- a/packages/cline/package.json +++ b/packages/cline/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-cline-auth", - "version": "0.1.12", + "version": "0.1.13", "description": "Cline (cline.bot) on your own account — usage billing, ClinePass and the free models — in OpenCode and magpie", "type": "module", "main": "./opencode.mjs",