cline 0.1.13: no default DeepSeek pin; a refused providerOptions pin says how to turn it off (#819)
Since 2026-11-06 Cline answers any client-supplied `providerOptions` with
403 `client-supplied "providerOptions" model routing is not supported`
(yetone/magpie#5442). 0.1.12 pinned ClinePass's DeepSeek models with
`providerOptions` by default, so every such request failed unless the user
set `pinUpstream: false`.
Changed:
- No pin by default. `providerOptions` / `provider` is written only with
`pinUpstream` on, and the pins themselves are the same as 0.1.12. The
default pin's unpinned retry (`unpinWorthy`) is gone with it.
- A pin this plugin wrote that Cline refuses with that exact 403 comes back as
a 403 that says to turn the pin off. It is not retried unpinned. A client's
own `providerOptions` refusal is passed through as Cline sent it.
- README and comments: the 11-06 refusal, and glm-5.3-flash's top-level
`provider.only` being accepted but ignored (finalProvider stayed
`openai-compatible-private` in the author's live checks).
- 0.1.13.
Author's live checks (Cline API key): default Pass DeepSeek 200; pinned 403
with the hint and no retry; glm-5.3-flash 5/5 200 with the pin on or off,
finalProvider `openai-compatible-private`.
Review run at a2d43859 (on main 367edb50), on mote, HOME=$(mktemp -d),
Bun 1.4.2:
- bun test packages/cline: 92 pass, 0 fail.
- bun scripts/check.mjs cline: ok.
- bun test (repo): 6563 pass, 20 skip, 0 fail.
- Broken by hand, each red: the default pin back; the hint for any
providerOptions 403; ROUTING_REJECTION unanchored; a retry on the refusal;
no JSON-envelope read. Dropping ownsRouting on fetch's pin stays green: the
own-routing test runs without pinUpstream now (follow-up).
Not tried by the review: a live Cline request (no key), magpie's gateway with
0.1.13 end to end. Follow-ups in magpie: ClinePassAsked still assumes a
default plugin pin, and the Upstream tick still sends providerOptions
(yetone/magpie#5442 stays open).
This commit is contained in:
+34
-23
@@ -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
|
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.
|
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
|
Cline's gateway picks among the providers that serve a model. A request can
|
||||||
its own routing for a model wins over `only` alone, so since 0.1.11 a request
|
ask for the maker's own API, but Cline changed what it accepts:
|
||||||
for a ClinePass DeepSeek model (`cline-pass/deepseek-…`) carries, by default:
|
|
||||||
|
- **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
|
```json
|
||||||
"providerOptions": {"gateway": {"only": ["deepseek"], "has": ["vision", "implicit-caching"]}}
|
"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
|
`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
|
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
|
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
|
`deepseek-v4-pro`. Other DeepSeek models carry `only: ["deepseek"]`, and a
|
||||||
(hy125245 on X: `finalProvider` `deepseek`, and a fake upstream in `only`
|
GLM model (`cline-pass/glm-…`) carries `only: ["zai"]`, as before.
|
||||||
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.
|
|
||||||
|
|
||||||
With the `pinUpstream` option on, a request for any DeepSeek model (not the
|
If Cline answers that exact 403, the plugin keeps the failure and says to
|
||||||
`cline-free/` ones) is pinned too, the ClinePass ones as above without the
|
turn the pin off; it does not retry unpinned. This preserves the meaning of
|
||||||
way back, the others with `"providerOptions": {"gateway": {"only":
|
the option: a pin that Cline cannot honour is an error, not a silent
|
||||||
["deepseek"]}}`, so it is answered by DeepSeek's own API only, and one for a
|
downgrade. If Cline restores `providerOptions` routing, the same option works
|
||||||
GLM model (`cline-pass/glm-…`) carries `["zai"]`, so it is answered by Z.ai's
|
again without a plugin change. A request with `provider` or
|
||||||
own API only — the same as magpie's built-in ClinePass tick. Cline sends
|
`providerOptions` of its own — magpie's extra body, say — goes as sent.
|
||||||
`glm-5.3-flash` through OpenRouter rather than Vercel's gateway, and OpenRouter
|
|
||||||
ignores `providerOptions`, so that model's request carries OpenRouter's own
|
The option is off by default. Turn it on:
|
||||||
`"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:
|
|
||||||
|
|
||||||
- in magpie: the provider's editor › Upstream › tick "DeepSeek and GLM
|
- in magpie: the provider's editor › Upstream › tick "DeepSeek and GLM
|
||||||
models only from their makers' own APIs";
|
models only from their makers' own APIs";
|
||||||
|
|||||||
+59
-52
@@ -787,6 +787,15 @@ function usageOf(me, balance, limits) {
|
|||||||
// deepseek-v4.1-flash-1017 go through Vercel. An exact entry is a model
|
// 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
|
// 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).
|
// 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 = [
|
const MAKERS = [
|
||||||
{ name: "glm-5.3-flash", exact: true, upstream: "z-ai", openRouter: true },
|
{ name: "glm-5.3-flash", exact: true, upstream: "z-ai", openRouter: true },
|
||||||
{ name: "deepseek", upstream: "deepseek" },
|
{ name: "deepseek", upstream: "deepseek" },
|
||||||
@@ -799,8 +808,10 @@ const MAKERS = [
|
|||||||
// GLM, openRouter true for a model Cline sends through OpenRouter. Cline's
|
// GLM, openRouter true for a model Cline sends through OpenRouter. Cline's
|
||||||
// routers otherwise pick among the providers serving the model, and some
|
// 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.
|
// 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:
|
// Cline currently ignores the top-level provider field (live replies kept
|
||||||
// null.
|
// 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) {
|
function pinned(on, model) {
|
||||||
if (!on || typeof model !== "string" || model.startsWith("cline-free/")) return null
|
if (!on || typeof model !== "string" || model.startsWith("cline-free/")) return null
|
||||||
const name = model.slice(model.lastIndexOf("/") + 1).toLowerCase()
|
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-…
|
// PASS_DEEPSEEK is a ClinePass DeepSeek model: cline-pass/deepseek-…
|
||||||
const PASS_DEEPSEEK = /^cline-pass\/deepseek/i
|
const PASS_DEEPSEEK = /^cline-pass\/deepseek/i
|
||||||
|
|
||||||
// passPin is where a ClinePass DeepSeek request is pinned by default:
|
// passPin is where a ClinePass DeepSeek request is pinned when pinUpstream
|
||||||
// DeepSeek's own API, with the gateway's capability filter beside it
|
// 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
|
// (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
|
// 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
|
// 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
|
// matching upstream". has names what the upstream must do: cache a
|
||||||
// repeated prefix by itself ("implicit-caching") and, for a model that
|
// repeated prefix by itself ("implicit-caching") and, for a model that
|
||||||
// takes images, take them ("vision") — never for a text-only model
|
// 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"] } })
|
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
|
// pinOf is the field a request for model is pinned by, or null: with
|
||||||
// ClinePass DeepSeek model always (unless pinUpstream is set off), with
|
// pinUpstream on, a ClinePass DeepSeek model asks for DeepSeek with the
|
||||||
// fallback true when it is magpie's default rather than the user's
|
// gateway's capability filter, and the makers' table above; off, nothing.
|
||||||
// pinUpstream, so a request the pin can't be served under goes again as
|
function pinOf(on, model, images) {
|
||||||
// sent; and, with pinUpstream on, the makers' table above.
|
if (!on || typeof model !== "string") return null
|
||||||
function pinOf(on, model, images, off = false) {
|
if (PASS_DEEPSEEK.test(model)) return { key: "providerOptions", value: passPin(images) }
|
||||||
if (typeof model !== "string") return null
|
|
||||||
if (PASS_DEEPSEEK.test(model) && !off) return { key: "providerOptions", value: passPin(images), fallback: !on }
|
|
||||||
const pin = pinned(on, model)
|
const pin = pinned(on, model)
|
||||||
if (!pin) return null
|
if (!pin) return null
|
||||||
return pin.openRouter
|
return pin.openRouter
|
||||||
? { key: "provider", value: { only: [pin.upstream] }, fallback: false }
|
? { key: "provider", value: { only: [pin.upstream] } }
|
||||||
: { key: "providerOptions", value: { gateway: { only: [pin.upstream] } }, fallback: false }
|
: { key: "providerOptions", value: { gateway: { only: [pin.upstream] } } }
|
||||||
}
|
}
|
||||||
|
|
||||||
// withField is body with "key":value written in at the end, so the rest of
|
// 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
|
// pinBody is the request's body with its pin written in (pinOf), or the
|
||||||
// body as sent
|
// body as sent
|
||||||
function pinBody(body, chat, on, images = false, off = false) {
|
function pinBody(body, chat, on, images = false) {
|
||||||
const pin = ownsRouting(chat) ? null : pinOf(on, chat?.model, images, off)
|
const pin = ownsRouting(chat) ? null : pinOf(on, chat?.model, images)
|
||||||
return pin ? withField(body, pin.key, pin.value) : body
|
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)
|
// a bare image part)
|
||||||
const hasImages = (body) => /"type"\s*:\s*"(?:image_url|image|input_image)"/.test(body)
|
const hasImages = (body) => /"type"\s*:\s*"(?:image_url|image|input_image)"/.test(body)
|
||||||
|
|
||||||
// NO_UPSTREAM is the gateway saying no upstream meets the pin
|
// routingRejected is Cline refusing a client-supplied providerOptions
|
||||||
const NO_UPSTREAM = /no (?:matching|available|eligible) (?:upstream|provider|endpoint)s?|no upstream/i
|
// 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.
|
||||||
// unpinWorthy is a pinned request's failure that the same request unpinned
|
const ROUTING_REJECTION = /^(?:Error\s+403:\s*)?client-supplied\s+["“]providerOptions["”]\s+model routing is not supported\.?$/i
|
||||||
// may well not meet: no upstream matching the pin, or the pinned upstream
|
function routingRejected(status, text) {
|
||||||
// failing (a 5xx). An account's refusal (401, 402, 403, 429) is the
|
if (status !== 403) return false
|
||||||
// account's, whatever the pin.
|
let msg = String(text ?? "")
|
||||||
const unpinWorthy = (status, text) => status >= 500 || NO_UPSTREAM.test(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
|
// isOn is whether an option is set: true, or "true" in a config written by hand
|
||||||
const isOn = (v) => v === true || v === "true"
|
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 = {}) => {
|
export const ClinePlugin = async ({ client } = {}, options = {}) => {
|
||||||
// the accounts fresh renewed this run: the sign-in mark comes off on the
|
// 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
|
// pinUpstream: the plugin's own option, or the provider's in
|
||||||
// OpenCode's config (provider.cline.options.pinUpstream)
|
// OpenCode's config (provider.cline.options.pinUpstream)
|
||||||
const pin = isOn(options?.pinUpstream) || isOn(provider?.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 {}
|
if (a?.type !== "oauth" && a?.type !== "api") return {}
|
||||||
return {
|
return {
|
||||||
baseURL: API,
|
baseURL: API,
|
||||||
@@ -1102,18 +1111,16 @@ export const ClinePlugin = async ({ client } = {}, options = {}) => {
|
|||||||
if (!/\/chat\/completions$/.test(new URL(url).pathname))
|
if (!/\/chat\/completions$/.test(new URL(url).pathname))
|
||||||
return errorResponse({ status: 404, message: "only chat completions are served" })
|
return errorResponse({ status: 404, message: "only chat completions are served" })
|
||||||
let body
|
let body
|
||||||
// sent is the body as the client sent it; fallback is a
|
// appliedPin is the pin this request carries, if any
|
||||||
// default pin's way back to it
|
let appliedPin = null
|
||||||
let sent
|
|
||||||
let fallback = false
|
|
||||||
try {
|
try {
|
||||||
body = sent = await bodyText(input, init)
|
body = await bodyText(input, init)
|
||||||
const chat = JSON.parse(body)
|
const chat = JSON.parse(body)
|
||||||
if (!chat || typeof chat !== "object" || Array.isArray(chat)) throw new Error("not a chat completion")
|
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) {
|
if (p) {
|
||||||
body = withField(body, p.key, p.value)
|
body = withField(body, p.key, p.value)
|
||||||
fallback = p.fallback
|
appliedPin = p
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
return errorResponse({ status: 400, message: "a request that isn't a chat completion" })
|
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) {
|
} catch (e) {
|
||||||
return signed(errorResponse({ status: 502, message: String(e?.message ?? e) }), renewed(cred))
|
return signed(errorResponse({ status: 502, message: String(e?.message ?? e) }), renewed(cred))
|
||||||
}
|
}
|
||||||
// a default pin never fails a request that would have
|
if (!res.ok) {
|
||||||
// worked: no upstream matching it, or the pinned one
|
|
||||||
// down, and the request goes once more as sent
|
|
||||||
if (!res.ok && fallback) {
|
|
||||||
const text = (await res.text()).slice(0, 1 << 20)
|
const text = (await res.text()).slice(0, 1 << 20)
|
||||||
if (!unpinWorthy(res.status, text)) return signed(errorResponse(failure(res.status, text)), renewed(cred))
|
// Cline now refuses client-supplied providerOptions
|
||||||
try {
|
// routing. A pin the user asked for stays a failure;
|
||||||
res = await fetch(url, { ...init, method: init?.method ?? "POST", headers, body: sent, signal })
|
// the message says how to let Cline route instead.
|
||||||
} catch (e) {
|
if (appliedPin?.key === "providerOptions" && routingRejected(res.status, text))
|
||||||
return signed(errorResponse({ status: 502, message: String(e?.message ?? e) }), renewed(cred))
|
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))
|
return signed(await unwrapped(res), renewed(cred))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -1212,7 +1219,7 @@ export const _internal = {
|
|||||||
pinned,
|
pinned,
|
||||||
pinOf,
|
pinOf,
|
||||||
pinBody,
|
pinBody,
|
||||||
unpinWorthy,
|
routingRejected,
|
||||||
hasImages,
|
hasImages,
|
||||||
unwrapped,
|
unwrapped,
|
||||||
clientHeaders,
|
clientHeaders,
|
||||||
|
|||||||
@@ -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,
|
// sdytman (#feedback, 10-20): Cline sends glm-5.3-flash through OpenRouter,
|
||||||
// not Vercel's AI Gateway, and OpenRouter ignores providerOptions.gateway.only.
|
// 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
|
// It reads a top-level provider.only with its own slug, "z-ai". Cline
|
||||||
// v4.1 flash models go through Vercel and keep providerOptions.
|
// currently ignores that field too, so the request works but is not pinned.
|
||||||
test("pinBody pins glm-5.3-flash by OpenRouter's provider.only, keeping the body's prefix", () => {
|
// 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 { pinBody, pinned } = _internal
|
||||||
const body = `{"model":"cline-pass/glm-5.3-flash","messages":[{"role":"user","content":"hi"}],"stream":true}`
|
const body = `{"model":"cline-pass/glm-5.3-flash","messages":[{"role":"user","content":"hi"}],"stream":true}`
|
||||||
const out = pinBody(body, JSON.parse(body), 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))
|
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
|
// 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
|
// over providerOptions.gateway.only alone (a fake upstream was served all the
|
||||||
// same); with the gateway's capability filter beside it, has: ["vision",
|
// same); with the gateway's capability filter beside it, has: ["vision",
|
||||||
// "implicit-caching"], the request went to DeepSeek (finalProvider
|
// "implicit-caching"], the request went to DeepSeek (finalProvider
|
||||||
// "deepseek") and a fake upstream was refused with "no matching upstream".
|
// "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"] } })
|
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 { client: c } = client()
|
||||||
const hooks = await ClinePlugin({ client: c })
|
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 })]))
|
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 l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} })
|
||||||
const msgs = [{ role: "user", content: "hi" }]
|
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 () => {
|
test("the models hook's catalog says which ClinePass DeepSeek model the pin asks vision of", async () => {
|
||||||
const { client: c } = client()
|
const { client: c } = client()
|
||||||
const hooks = await ClinePlugin({ client: c })
|
const hooks = await ClinePlugin({ client: c }, { pinUpstream: true })
|
||||||
serve([
|
serve([
|
||||||
["/ai/cline/recommended-models", () => Response.json({ clinePass: [{ id: "cline-pass/deepseek-v4.1-flash" }, { id: "cline-pass/deepseek-v4-pro" }] })],
|
["/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: [
|
["/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])
|
expect(res.map((r) => r.status)).toEqual([200, 400, 200, 200])
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const [why, status, answer] of [
|
test("a client's own providerOptions refused by Cline is passed through, not blamed on pinUpstream", async () => {
|
||||||
["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 () => {
|
|
||||||
const { client: c } = client()
|
const { client: c } = client()
|
||||||
const hooks = await ClinePlugin({ client: c })
|
const hooks = await ClinePlugin({ client: c })
|
||||||
|
const own = { model: "cline-pass/deepseek-v4.1-flash", messages: [], providerOptions: { gateway: { only: ["deepseek"] } } }
|
||||||
serve([
|
serve([
|
||||||
[chatUrl, () => Response.json({ error: "no matching upstream" }, { status: 400 })],
|
[chatUrl, () => Response.json({ error: { message: 'Error 403: client-supplied "providerOptions" model routing is not supported' } }, { status: 403 })],
|
||||||
[chatUrl, () => Response.json({ error: { message: "upstream unavailable" } }, { status: 503 })],
|
|
||||||
[chatUrl, () => Response.json({ ok: true })],
|
|
||||||
])
|
])
|
||||||
const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} })
|
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: [] }))
|
const res = await l.fetch(chatUrl, chatInit(own))
|
||||||
expect(res.status).toBe(503)
|
expect(res.status).toBe(403)
|
||||||
expect(calls.length).toBe(2)
|
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 () => {
|
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" } }],
|
[400, { error: { message: "messages: field required" } }],
|
||||||
]) {
|
]) {
|
||||||
const { client: c } = client()
|
const { client: c } = client()
|
||||||
const hooks = await ClinePlugin({ client: c })
|
const hooks = await ClinePlugin({ client: c }, { pinUpstream: true })
|
||||||
serve([[chatUrl, () => Response.json(answer, { status })]])
|
serve([[chatUrl, () => Response.json(answer, { status })]])
|
||||||
const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }), { id: "cline", options: {} })
|
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: [] }))
|
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: [] })))
|
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 () => {
|
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 [[{ pinUpstream: false }, undefined], [undefined, { id: "cline", options: { pinUpstream: "false" } }]]) {
|
for (const [plugin, provider] of [
|
||||||
|
[undefined, undefined],
|
||||||
|
[{ pinUpstream: false }, undefined],
|
||||||
|
[undefined, { id: "cline", options: { pinUpstream: "false" } }],
|
||||||
|
]) {
|
||||||
const { client: c } = client()
|
const { client: c } = client()
|
||||||
const hooks = await ClinePlugin({ client: c }, plugin)
|
const hooks = await ClinePlugin({ client: c }, plugin)
|
||||||
serve([[chatUrl, () => Response.json({ ok: true })]])
|
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 { client: c } = client()
|
||||||
const hooks = await ClinePlugin({ client: c }, { pinUpstream: true })
|
const hooks = await ClinePlugin({ client: c }, { pinUpstream: true })
|
||||||
serve([
|
serve([[chatUrl, () => Response.json({ error: "no matching upstream" }, { status: 400 })]])
|
||||||
[chatUrl, () => Response.json({ error: "no matching upstream" }, { status: 400 })],
|
|
||||||
[chatUrl, () => Response.json({ ok: true })],
|
|
||||||
])
|
|
||||||
const l = await hooks.auth.loader(async () => ({ type: "api", key: "ck" }))
|
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: [] }))
|
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
|
// 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))
|
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", () => {
|
test("routingRejected reads Cline's exact providerOptions refusal, and nothing looser", () => {
|
||||||
const { unpinWorthy, hasImages } = _internal
|
const { routingRejected, hasImages } = _internal
|
||||||
expect(unpinWorthy(400, `{"error":"no matching upstream"}`)).toBe(true)
|
const exact = 'Error 403: client-supplied "providerOptions" model routing is not supported'
|
||||||
expect(unpinWorthy(404, "No available providers for this model")).toBe(true)
|
expect(routingRejected(403, exact)).toBe(true)
|
||||||
expect(unpinWorthy(502, "")).toBe(true)
|
expect(routingRejected(403, JSON.stringify({ error: { message: exact } }))).toBe(true)
|
||||||
for (const s of [400, 401, 402, 403, 429]) expect(unpinWorthy(s, `{"error":"nope"}`)).toBe(false)
|
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(true)
|
||||||
expect(hasImages(`{"messages":[{"content":"type image_url"}]}`)).toBe(false)
|
expect(hasImages(`{"messages":[{"content":"type image_url"}]}`)).toBe(false)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@magpie-community/opencode-cline-auth",
|
"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",
|
"description": "Cline (cline.bot) on your own account — usage billing, ClinePass and the free models — in OpenCode and magpie",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./opencode.mjs",
|
"main": "./opencode.mjs",
|
||||||
|
|||||||
Reference in New Issue
Block a user