Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

routing: a ClinePass route reads as its route, with what was asked for (zRain)

yetonec819e00c4ed3
diff --git a/internal/gateway/cline_asked_test.go b/internal/gateway/cline_asked_test.go
new file mode 100644
index 000000000..42db84815
--- /dev/null
+++ b/internal/gateway/cline_asked_test.go
@@ -0,0 +1,68 @@
+package gateway
+
+import (
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+
+ "github.com/yetone/magpie/internal/provider"
+)
+
+// A ClinePass reply that names a route of its own (vmc/…-contributor-
+// fallbacks) and no provider still leaves its try saying what was asked
+// for, so the Routing page can tell "DeepSeek asked for, not said who
+// answered" from "nothing asked for" (zRain on Discord, 10-24): DeepSeek
+// with the Upstream tick, nothing without it, on a Chat client's path and
+// on the Responses one Codex takes.
+func TestClinePassTryKeepsWhatWasAsked(t *testing.T) {
+ for _, path := range []string{"/v1/chat/completions", "/v1/responses"} {
+ for _, tick := range []bool{false, true} {
+ name := path + "/tick-off"
+ want := ""
+ if tick {
+ name, want = path+"/tick-on", "deepseek"
+ }
+ t.Run(name, func(t *testing.T) {
+ fresh(t)
+ var sent string
+ up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ b, _ := io.ReadAll(r.Body)
+ sent = string(b)
+ w.Header().Set("Content-Type", "text/event-stream")
+ io.WriteString(w, `data: {"id":"g1","object":"chat.completion.chunk","model":"vmc/deepseek-v4p1-flash-1017-contributor-fallbacks","choices":[{"index":0,"delta":{"role":"assistant","content":"hi"}}]}`+"\n\n")
+ io.WriteString(w, `data: {"id":"g1","object":"chat.completion.chunk","model":"vmc/deepseek-v4p1-flash-1017-contributor-fallbacks","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":3,"completion_tokens":1,"total_tokens":4}}`+"\n\n")
+ io.WriteString(w, "data: [DONE]\n\n")
+ }))
+ t.Cleanup(up.Close)
+ p := provider.Provider{ID: "clinepass", Name: "ClinePass", Preset: "clinepass", Key: "k", Chat: up.URL + "/v1",
+ Models: []string{"cline-pass/deepseek-v4.1-flash-1017"}, PinUpstream: tick}
+ if err := provider.Save(p); err != nil {
+ t.Fatal(err)
+ }
+ body := `{"model":"clinepass/cline-pass/deepseek-v4.1-flash-1017","max_tokens":100,"stream":true,"messages":[{"role":"user","content":"hi"}]}`
+ if path == "/v1/responses" {
+ body = `{"model":"clinepass/cline-pass/deepseek-v4.1-flash-1017","stream":true,"input":"hi"}`
+ }
+ s := New()
+ rec := httptest.NewRecorder()
+ s.Handler().ServeHTTP(rec, httptest.NewRequest("POST", path, strings.NewReader(body)))
+ if rec.Code != 200 {
+ t.Fatalf("%d %s", rec.Code, rec.Body)
+ }
+ if pinned := strings.Contains(sent, `"only":["deepseek"]`); pinned != tick {
+ t.Errorf("pin sent %v with the tick %v: %s", pinned, tick, sent)
+ }
+ r := lastRoute(s)
+ if len(r.Tries) != 1 {
+ t.Fatalf("tries %+v", r.Tries)
+ }
+ tr := r.Tries[0]
+ if tr.Pin != want || tr.Upstream != "" || !strings.HasPrefix(tr.Served, "vmc/") {
+ t.Errorf("try pin %q (want %q), upstream %q, served %q", tr.Pin, want, tr.Upstream, tr.Served)
+ }
+ })
+ }
+ }
+}
diff --git a/internal/gateway/gateway.go b/internal/gateway/gateway.go
index a7c418aee..e8f7860e4 100644
--- a/internal/gateway/gateway.go
+++ b/internal/gateway/gateway.go
@@ -2847,7 +2847,7 @@ func (s *Server) serve(w http.ResponseWriter, r *http.Request, from provider.Pro
wentTier = at.tier
ended = time.Now()
try := Try{ID: c.rest, Model: c.model, Effort: wentAt, Picked: picked, Fixed: fixed, RuleEffort: ruled, Fast: fast, Start: began, Done: true, Status: call.Status, Millis: ended.Sub(began).Milliseconds(), Error: call.Error, Queued: queued,
- Served: call.Usage.Served, Upstream: call.Usage.Upstream, Tier: wentTier, TierServed: call.Usage.Tier, Auto: autoPicked(),
+ Served: call.Usage.Served, Upstream: call.Usage.Upstream, Pin: c.p.ClinePassAsked(c.model), Tier: wentTier, TierServed: call.Usage.Tier, Auto: autoPicked(),
Net: nt.timing(began, queued)}
if resetFirst != nil {
// the reset spent for it before it was asked
diff --git a/internal/gateway/trace.go b/internal/gateway/trace.go
index 2ab57eded..30fa86d21 100644
--- a/internal/gateway/trace.go
+++ b/internal/gateway/trace.go
@@ -348,6 +348,9 @@ type Try struct {
// Upstream: the provider an aggregator said answered behind it
// (OpenRouter's DeepInfra, Novita …)
Upstream string `json:"upstream,omitempty"`
+ // Pin: the upstream the try asked the Cline API to serve it from
+ // (provider.ClinePassAsked), "" when it asked for none
+ Pin string `json:"pin,omitempty"`
// Tier: the service tier it went out at, once a fast pick or an
// account without Ultrafast had changed it; TierServed: the one its
// reply said it ran at, when it said one (#1784)
diff --git a/internal/gui/assets/plugins/routing/client.js b/internal/gui/assets/plugins/routing/client.js
index 99ee15ee0..d3a9f6364 100644
--- a/internal/gui/assets/plugins/routing/client.js
+++ b/internal/gui/assets/plugins/routing/client.js
@@ -2361,11 +2361,27 @@ function routingPage(part) {
// for: a vendor serving a cheaper model in its place, which only the
// reply's model field tells (its dated name is the same model)
function swapTag(tr, short) {
- const k = el("span", "swap", short ? t("served {served}", { served: tr.served }) : t("requested {sent} · served {served}", { sent: tr.model, served: tr.served }));
+ const route = clineRoute(tr);
+ const k = el("span", "swap", short ? t(route ? "ClinePass route {served}" : "served {served}", { served: tr.served })
+ : t(route ? "requested {sent} · ClinePass route {served}" : "requested {sent} · served {served}", { sent: tr.model, served: tr.served }));
k.title = swapWhy(tr);
return k;
}
- const swapWhy = (tr) => t("The vendor was asked for {sent}, but its reply says {served} answered: likely another model. The same model under a dated name or spelled otherwise isn't marked.", { sent: tr.model, served: tr.served });
+ // ClinePass names a reply by the route it picked (its VMC,
+ // vmc/deepseek-v4p1-flash-1017-contributor-fallbacks), not by a model:
+ // such a reply is said as its route, with what was asked of it and
+ // whether it said who answered (zRain on Discord, 10-24). pin is the
+ // provider the try asked for; a Usage row doesn't keep it (pinUnknown).
+ const clineRoute = (tr) => /^vmc\//.test(tr.served || "") && /(^|\/)cline-pass\//.test(tr.model || "");
+ function swapWhy(tr, o = {}) {
+ if (!clineRoute(tr)) return t("The vendor was asked for {sent}, but its reply says {served} answered: likely another model. The same model under a dated name or spelled otherwise isn't marked.", { sent: tr.model, served: tr.served });
+ const s = t("ClinePass answered {sent} through {served}, a route it picks itself: the name is the route's, not another model's.", { sent: tr.model, served: tr.served });
+ if (tr.upstream) return s + " " + t("Its reply says {upstream} answered.", { upstream: tr.upstream });
+ if (o.pinUnknown) return s + " " + t("Its reply didn't say which provider answered.");
+ if (tr.pin) return s + " " + t("{pin} was asked for, but its reply didn't say which provider answered, so whether ClinePass kept to it is unknown.", { pin: tr.pin });
+ const tick = /(^|\/)cline-pass\/(deepseek|glm)/i.test(tr.model) ? " " + t("To ask for the maker's own API, tick “{tick}” in the provider's settings.", { tick: t("DeepSeek and GLM models only from their makers' own APIs") }) : "";
+ return s + " " + t("No provider was asked for, and its reply didn't say which one answered.") + tick;
+ }
window.swapWhy = swapWhy; // the Usage page's Requests say it too
// a try that asked a remote magpie for one of its routing groups: the
// reply names the member the group routed to, which is the group
diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.js
index f4b33f56d..47086a669 100644
--- a/internal/gui/assets/plugins/routing/i18n.js
+++ b/internal/gui/assets/plugins/routing/i18n.js
@@ -544,6 +544,14 @@ magpie.strings({
"The aggregator passed the request on to {upstream}, as its reply says: the provider that actually answered it.": "聚合供应商把这条请求转给了 {upstream},由它实际作答(聚合供应商的回复里写明)。",
"{sent} is a routing group of the remote magpie, and it routed the request to {served}: the group picking one of its models, not the vendor swapping the model.": "{sent} 是远程 magpie 的路由组,请求被路由给 {served}:这是路由组选择了组内模型,并非服务商替换了模型。",
"The vendor was asked for {sent}, but its reply says {served} answered: likely another model. The same model under a dated name or spelled otherwise isn't marked.": "向服务商请求的是 {sent},但回复说是 {served} 作答,很可能换成了别的模型。(同一模型只是带了日期或写法不同,不会这样标出。)",
+ "ClinePass route {served}": "ClinePass 路由 {served}",
+ "requested {sent} · ClinePass route {served}": "请求 {sent} · ClinePass 路由 {served}",
+ "ClinePass answered {sent} through {served}, a route it picks itself: the name is the route's, not another model's.": "ClinePass 通过它自己选的路由 {served} 回答了 {sent}:这是路由的名字,不是换成了别的模型。",
+ "Its reply says {upstream} answered.": "回复说是 {upstream} 作答。",
+ "Its reply didn't say which provider answered.": "回复没有说是哪家上游作答。",
+ "{pin} was asked for, but its reply didn't say which provider answered, so whether ClinePass kept to it is unknown.": "请求时指定了 {pin},但回复没有说是哪家上游作答,所以无法确定 ClinePass 是否照做。",
+ "To ask for the maker's own API, tick “{tick}” in the provider's settings.": "要指定模型厂商的官方 API,请在该服务商设置里勾选“{tick}”。",
+ "No provider was asked for, and its reply didn't say which one answered.": "请求时没有指定上游,回复也没有说是哪家作答。",
"{h} h {m} min": "{h} 小时 {m} 分钟",
},
"zh-TW": {
@@ -1089,6 +1097,14 @@ magpie.strings({
"The aggregator passed the request on to {upstream}, as its reply says: the provider that actually answered it.": "聚合供應商把這條請求轉給了 {upstream},由它實際作答(聚合供應商的回覆裡寫明)。",
"{sent} is a routing group of the remote magpie, and it routed the request to {served}: the group picking one of its models, not the vendor swapping the model.": "{sent} 是遠端 magpie 的路由組,請求被路由給 {served}:這是路由組選擇了組內模型,並非服務商替換了模型。",
"The vendor was asked for {sent}, but its reply says {served} answered: likely another model. The same model under a dated name or spelled otherwise isn't marked.": "向服務商請求的是 {sent},但回覆說是 {served} 作答,很可能換成了別的模型。(同一模型只是帶了日期或寫法不同,不會這樣標出。)",
+ "ClinePass route {served}": "ClinePass 路由 {served}",
+ "requested {sent} · ClinePass route {served}": "請求 {sent} · ClinePass 路由 {served}",
+ "ClinePass answered {sent} through {served}, a route it picks itself: the name is the route's, not another model's.": "ClinePass 透過它自己選的路由 {served} 回答了 {sent}:這是路由的名字,不是換成了別的模型。",
+ "Its reply says {upstream} answered.": "回覆說是 {upstream} 作答。",
+ "Its reply didn't say which provider answered.": "回覆沒有說是哪家上游作答。",
+ "{pin} was asked for, but its reply didn't say which provider answered, so whether ClinePass kept to it is unknown.": "請求時指定了 {pin},但回覆沒有說是哪家上游作答,所以無法確定 ClinePass 是否照做。",
+ "To ask for the maker's own API, tick “{tick}” in the provider's settings.": "要指定模型廠商的官方 API,請在該服務商設定裡勾選「{tick}」。",
+ "No provider was asked for, and its reply didn't say which one answered.": "請求時沒有指定上游,回覆也沒有說是哪家作答。",
"{h} h {m} min": "{h} 小時 {m} 分鐘",
},
ja: {
@@ -1632,6 +1648,14 @@ magpie.strings({
"The aggregator passed the request on to {upstream}, as its reply says: the provider that actually answered it.": "アグリゲーターはこのリクエストを {upstream} に回したと応答に書いています。実際に応答したプロバイダーです。",
"{sent} is a routing group of the remote magpie, and it routed the request to {served}: the group picking one of its models, not the vendor swapping the model.": "{sent} はリモート magpie のルーティンググループで、リクエストを {served} にルーティングしました。グループがモデルを選んだもので、ベンダーがモデルを差し替えたのではありません。",
"The vendor was asked for {sent}, but its reply says {served} answered: likely another model. The same model under a dated name or spelled otherwise isn't marked.": "ベンダーには {sent} をリクエストしましたが、応答では {served} が答えたとあり、別のモデルに替えられた可能性があります。(同じモデルに日付が付いただけ、または表記が違うだけなら表示しません。)",
+ "ClinePass route {served}": "ClinePass ルート {served}",
+ "requested {sent} · ClinePass route {served}": "リクエスト {sent} · ClinePass ルート {served}",
+ "ClinePass answered {sent} through {served}, a route it picks itself: the name is the route's, not another model's.": "ClinePass は自ら選んだルート {served} で {sent} に応答しました。これはルートの名前で、別のモデルに替えられたわけではありません。",
+ "Its reply says {upstream} answered.": "応答では {upstream} が答えたとあります。",
+ "Its reply didn't say which provider answered.": "応答にはどのプロバイダーが答えたか書かれていません。",
+ "{pin} was asked for, but its reply didn't say which provider answered, so whether ClinePass kept to it is unknown.": "{pin} を指定しましたが、応答にはどのプロバイダーが答えたか書かれておらず、ClinePass がそれに従ったかは分かりません。",
+ "To ask for the maker's own API, tick “{tick}” in the provider's settings.": "モデル提供元の公式 API を指定するには、プロバイダーの設定で「{tick}」をオンにしてください。",
+ "No provider was asked for, and its reply didn't say which one answered.": "プロバイダーは指定されておらず、応答にもどこが答えたか書かれていません。",
"{h} h {m} min": "{h} 時間 {m} 分",
"This routing group will no longer be available to agents.": "このルーティンググループはエージェントから利用できなくなります。",
"These routing groups will no longer be available to agents.": "これらのルーティンググループはエージェントから利用できなくなります。",
@@ -2177,6 +2201,14 @@ magpie.strings({
"The aggregator passed the request on to {upstream}, as its reply says: the provider that actually answered it.": "Der Aggregator hat die Anfrage laut seiner Antwort an {upstream} weitergegeben: der Anbieter, der sie tatsächlich beantwortet hat.",
"{sent} is a routing group of the remote magpie, and it routed the request to {served}: the group picking one of its models, not the vendor swapping the model.": "{sent} ist eine Weiterleitungsgruppe des entfernten magpie und hat die Anfrage an {served} weitergeleitet: Die Gruppe wählt eines ihrer Modelle, nicht der Anbieter tauscht das Modell.",
"The vendor was asked for {sent}, but its reply says {served} answered: likely another model. The same model under a dated name or spelled otherwise isn't marked.": "Beim Anbieter wurde {sent} angefragt, laut Antwort hat aber {served} geantwortet – wahrscheinlich ein anderes Modell. (Dasselbe Modell mit Datum oder anderer Schreibweise wird nicht markiert.)",
+ "ClinePass route {served}": "ClinePass-Route {served}",
+ "requested {sent} · ClinePass route {served}": "angefragt {sent} · ClinePass-Route {served}",
+ "ClinePass answered {sent} through {served}, a route it picks itself: the name is the route's, not another model's.": "ClinePass hat {sent} über {served} beantwortet, eine Route, die es selbst wählt: Der Name gehört zur Route, nicht zu einem anderen Modell.",
+ "Its reply says {upstream} answered.": "Laut Antwort hat {upstream} geantwortet.",
+ "Its reply didn't say which provider answered.": "Die Antwort sagt nicht, welcher Anbieter geantwortet hat.",
+ "{pin} was asked for, but its reply didn't say which provider answered, so whether ClinePass kept to it is unknown.": "{pin} wurde angefragt, aber die Antwort sagt nicht, welcher Anbieter geantwortet hat; ob ClinePass sich daran gehalten hat, ist unbekannt.",
+ "To ask for the maker's own API, tick “{tick}” in the provider's settings.": "Um die eigene API des Herstellers anzufragen, aktiviere „{tick}“ in den Einstellungen des Anbieters.",
+ "No provider was asked for, and its reply didn't say which one answered.": "Es wurde kein Anbieter angefragt, und die Antwort sagt nicht, wer geantwortet hat.",
"{h} h {m} min": "{h} h {m} min",
"This routing group will no longer be available to agents.": "Diese Weiterleitungsgruppe steht Agenten nicht mehr zur Verfügung.",
"These routing groups will no longer be available to agents.": "Diese Weiterleitungsgruppen stehen Agenten nicht mehr zur Verfügung.",
diff --git a/internal/gui/assets/plugins/usage/page.js b/internal/gui/assets/plugins/usage/page.js
index 3fe4a62ba..0903f340d 100644
--- a/internal/gui/assets/plugins/usage/page.js
+++ b/internal/gui/assets/plugins/usage/page.js
@@ -811,7 +811,7 @@ function ledServed(r) {
}
if (!r.swapped) return el("span", "model-value", r.served);
const k = el("span", "swap", r.served);
- k.title = window.swapWhy ? window.swapWhy({ model: r.model, served: r.served }) : "";
+ k.title = window.swapWhy ? window.swapWhy({ model: r.model, served: r.served, upstream: r.upstream }, { pinUnknown: true }) : "";
return k;
}
diff --git a/internal/gui/tests/routing-cline-route.test.cjs b/internal/gui/tests/routing-cline-route.test.cjs
new file mode 100644
index 000000000..4b3cd2c04
--- /dev/null
+++ b/internal/gui/tests/routing-cline-route.test.cjs
@@ -0,0 +1,163 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// A ClinePass reply named for a route ClinePass picked itself
+// (vmc/deepseek-v4p1-flash-1017-contributor-fallbacks) and no provider
+// (zRain on Discord, 10-24): its tag says "ClinePass route …", not
+// "served …", and its title and story say it is the route's name, not
+// another model, and whether DeepSeek was asked for: asked and not said
+// who answered, or nothing asked and the tick that asks. Another vendor's
+// swap still reads as one. The Usage page's Requests say the route too.
+// English and Chinese; the API is faked. MAGPIE_ROUTE_ASSETS points at an
+// older asset folder to watch it fail.
+const assert = require("node:assert/strict");
+const fs = require("node:fs/promises");
+const path = require("node:path");
+const { test } = require("node:test");
+const { chromium, webkit } = require("playwright");
+
+const assets = path.resolve(process.env.MAGPIE_ROUTE_ASSETS || path.join(__dirname, "../assets"));
+const now = new Date();
+const day = [now.getFullYear(), now.getMonth() + 1, now.getDate()].map((n) => String(n).padStart(2, "0")).join("-");
+const at = (i) => new Date(now.getTime() - (i + 1) * 60e3).toISOString();
+const VMC = "vmc/deepseek-v4p1-flash-1017-contributor-fallbacks";
+const DS = "cline-pass/deepseek-v4.1-flash-1017";
+const key = { id: "clinepass", provider: "clinepass", name: "ClinePass", kind: "provider", model: DS };
+const other = { id: "relay", provider: "relay", name: "Relay", kind: "provider", model: "gpt-5.5" };
+// newest first: DeepSeek asked for, nothing asked for, another vendor's swap
+const cases = [
+ { k: key, model: DS, served: VMC, pin: "deepseek" },
+ { k: key, model: DS, served: VMC },
+ { k: other, model: "gpt-5.5", served: "gpt-4o-mini" },
+];
+const routes = cases.map((c, i) => ({
+ id: 100 - i, seq: 100 - i, time: at(i), agent: "codex", model: c.k.id + "/" + c.model, provider: c.k.id,
+ order: [c.k], tries: [{ id: c.k.id, model: c.model, start: at(i), done: true, status: 200, ms: 900, served: c.served, swapped: true, ...(c.pin ? { pin: c.pin } : {}) }],
+ done: true, status: 200, ms: 900, tokens: 1200, served: c.served,
+}));
+const ROWS = [{
+ t: at(0), agent: "codex", agentName: "Codex", icon: "codex-color", provider: "clinepass", providerName: "ClinePass",
+ req: "clinepass/" + DS, model: DS, served: VMC, swapped: true, in: 300, out: 40, ms: 2000, status: 200, rid: "gen-0", ep: "/backend-api/codex/responses → /v1/chat/completions",
+}];
+
+function serve(lang) {
+ const state = { agents: [{ id: "codex", name: "Codex", path: "/test/config.toml", fields: [] }], profiles: [], settings: { lang, theme: "light" } };
+ return async (route) => {
+ const url = new URL(route.request().url());
+ const json = (data) => route.fulfill({ json: data });
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
+ if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
+ if (url.pathname === "/api/state") return json(state);
+ if (url.pathname === "/api/gateway/trace") {
+ if (url.searchParams.get("wait")) await new Promise((r) => setTimeout(r, 20e3));
+ return json({ mine: true, now: now.toISOString(), seq: 1, totals: { requests: 0, rerouted: 0, errors: 0 }, routes: [] });
+ }
+ if (url.pathname === "/api/gateway/history") {
+ const d = url.searchParams.get("day");
+ return json({ cut: false, days: [{ day, requests: routes.length }], routes: d ? routes : [] });
+ }
+ if (url.pathname === "/api/groups") return json({ groups: [], models: [] });
+ if (url.pathname === "/api/providers") return json({ providers: [], excluded: [], gateway: { running: true, window: true } });
+ if (url.pathname === "/api/plugins") return json({ plugins: [] });
+ if (url.pathname === "/api/usage/requests") return json({ period: url.searchParams.get("period"), rows: ROWS, offset: 0, total: 1, calls: 1, errors: 0, input: 300, output: 40, cache_read: 0, cache_write: 0, reasoning: 0, cost: 0, unpriced: 1, agents: [{ id: "codex", name: "Codex", icon: "codex-color" }] });
+ if (url.pathname === "/api/usage/requests/content") return json({ found: false, why: "read" });
+ if (url.pathname === "/api/usage/quotas") return json([]);
+ if (url.pathname === "/api/usage") return json({ calls: 1, errors: 0, input: 300, output: 40, cache_read: 0, cache_write: 0, reasoning: 0, unpriced: 1, cost: 0, bucket: "day", series: [], agents: [], models: [], path: "~/.config/magpie/usage.jsonl" });
+ if (url.pathname === "/api/sessions") return json({ sessions: [], dirs: [] });
+ if (url.pathname === "/api/sessions/stats") return json({ from: "", to: "", days: [], agents: {} });
+ if (url.pathname.startsWith("/api/")) return json({});
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await route.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+const want = {
+ en: {
+ tags: ["ClinePass route " + VMC, "ClinePass route " + VMC, "served gpt-4o-mini"],
+ route: /a route it picks itself: the name is the route's, not another model's/,
+ asked: /deepseek was asked for, but its reply didn't say which provider answered/,
+ none: /No provider was asked for.*tick “DeepSeek and GLM models only from their makers' own APIs”/,
+ swap: /likely another model/,
+ usage: /didn't say which provider answered\.$/,
+ },
+ zh: {
+ tags: ["ClinePass 路由 " + VMC, "ClinePass 路由 " + VMC, "实际 gpt-4o-mini"],
+ route: /这是路由的名字,不是换成了别的模型/,
+ asked: /请求时指定了 deepseek,但回复没有说是哪家上游作答/,
+ none: /请求时没有指定上游.*勾选“DeepSeek、GLM 模型只走各自官方上游”/,
+ swap: /很可能换成了别的模型/,
+ usage: /回复没有说是哪家上游作答。$/,
+ },
+};
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ for (const lang of ["en", "zh"]) {
+ test(`${engine} ${lang}: a ClinePass route reads as its route, with what was asked`, async (t) => {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ const context = await browser.newContext({ viewport: { width: 1100, height: 760 }, reducedMotion: "reduce" });
+ const page = await context.newPage();
+ page.setDefaultTimeout(5000);
+ const errors = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", serve(lang));
+ t.after(async () => {
+ if (process.env.ARTIFACT_DIR) {
+ await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
+ await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-cline-route.png`), fullPage: true });
+ }
+ await browser.close();
+ });
+ await page.goto("http://magpie.test/?view=routing");
+ await page.locator(".rt-day").nth(1).waitFor({ state: "visible", timeout: 15000 });
+ await page.locator(".rt-day").nth(1).click();
+ await page.locator(".rt-req").nth(cases.length - 1).waitFor();
+ const w = want[lang];
+
+ const tags = await page.locator(".rt-req").evaluateAll((rows) => rows.map((r) => {
+ const s = r.querySelector(".to .swap");
+ return s ? [s.textContent, s.title] : ["", ""];
+ }));
+ assert.deepEqual(tags.map((x) => x[0]), w.tags);
+ assert.match(tags[0][1], w.route);
+ assert.match(tags[0][1], w.asked);
+ assert.match(tags[1][1], w.route);
+ assert.match(tags[1][1], w.none);
+ assert.doesNotMatch(tags[0][1], w.swap);
+ assert.match(tags[2][1], w.swap);
+ const fits = await page.locator(".rt-req .to .swap").evaluateAll((es) => es.map((e) => {
+ const row = e.closest(".rt-req").getBoundingClientRect(), b = e.getBoundingClientRect();
+ return b.width > 0 && b.left >= row.left && b.right <= row.right + 0.5 && getComputedStyle(e).borderLeftWidth === "0px";
+ }));
+ assert.deepEqual(fits, [true, true, true], "each tag sits in its row, no left-border accent");
+
+ // the story of each says the same
+ for (const [i, re] of [[0, w.asked], [1, w.none], [2, w.swap]]) {
+ await page.locator(".rt-req").nth(i).click();
+ // the story is drawn again once the pick lands: wait for the line
+ const said = await page.waitForFunction((src) => {
+ const li = document.querySelector(".rt-steps li.swap");
+ return li && new RegExp(src).test(li.textContent) && li.textContent;
+ }, re.source).then((h) => h.jsonValue(), (e) => page.locator(".rt-steps li.swap").first().textContent().catch(() => String(e)));
+ assert.match(said, re);
+ }
+
+ // the Usage page's Requests: the served model's title says the route
+ await page.locator('[data-view="usage"]').first().click();
+ await page.locator(":is(#usageTab .opt, .nav-s):visible").nth(1).click();
+ const served = page.locator(".led tbody tr.led-row .swap").first();
+ await served.waitFor();
+ const title = await served.getAttribute("title");
+ assert.match(title, w.route);
+ assert.match(title, w.usage);
+ for (const l of ["zh", "zh-TW", "ja", "de"]) {
+ const missing = await page.evaluate((l) => ["ClinePass route {served}", "requested {sent} · ClinePass route {served}",
+ "ClinePass answered {sent} through {served}, a route it picks itself: the name is the route's, not another model's.",
+ "Its reply says {upstream} answered.", "Its reply didn't say which provider answered.",
+ "{pin} was asked for, but its reply didn't say which provider answered, so whether ClinePass kept to it is unknown.",
+ "To ask for the maker's own API, tick “{tick}” in the provider's settings.",
+ "No provider was asked for, and its reply didn't say which one answered."].filter((k) => !I18N[l][k]), l);
+ assert.deepEqual(missing, [], `every string has its ${l}`);
+ }
+ assert.deepEqual(errors, []);
+ });
+ }
+}
diff --git a/internal/provider/cline.go b/internal/provider/cline.go
index d807c4686..689accfe4 100644
--- a/internal/provider/cline.go
+++ b/internal/provider/cline.go
@@ -223,6 +223,23 @@ func (p Provider) ClinePin(model string) (upstream string, openRouter bool) {
return "", false
}
+// ClinePassAsked is the upstream a request for model asks the Cline API
+// to serve it from on p, "" when it asks for none: ClinePin's, sent with
+// the Upstream tick, or, on the Cline plugin's provider, DeepSeek for a
+// ClinePass DeepSeek model, which opencode-cline-auth 0.1.11 pins by
+// itself unless its pinUpstream option is set off. The Routing page says
+// it beside a reply that names no provider, so a route ClinePass picked
+// reads as asked for DeepSeek or not (zRain on Discord, 10-24).
+func (p Provider) ClinePassAsked(model string) string {
+ if up, _ := p.ClinePin(model); up != "" {
+ return up
+ }
+ if p.PluginProvider() == "cline" && clinePassDeepSeek(model) {
+ return "deepseek"
+ }
+ return ""
+}
+
// clinePassDeepSeek is a ClinePass DeepSeek model: cline-pass/deepseek-…
func clinePassDeepSeek(model string) bool {
return strings.HasPrefix(strings.ToLower(model), "cline-pass/deepseek")
diff --git a/internal/provider/cline_asked_test.go b/internal/provider/cline_asked_test.go
new file mode 100644
index 000000000..5a7ac1ec3
--- /dev/null
+++ b/internal/provider/cline_asked_test.go
@@ -0,0 +1,37 @@
+package provider
+
+import (
+ "testing"
+
+ "github.com/yetone/magpie/internal/plugin"
+)
+
+// ClinePassAsked says what a ClinePass DeepSeek request asks the Cline API
+// for (zRain on Discord, 10-24): the built-in ClinePass only with the
+// Upstream tick, the Cline plugin's provider by default (the plugin pins
+// it itself), and nothing for a model with no maker to pin to.
+func TestClinePassAsked(t *testing.T) {
+ const ds = "cline-pass/deepseek-v4.1-flash-1017"
+ builtin := Provider{ID: "clinepass", Preset: "clinepass"}
+ ticked := builtin
+ ticked.PinUpstream = true
+ plug := Provider{ID: "cline", Account: &Account{plugin: &plugin.Provider{ID: "cline"}}}
+ other := Provider{ID: "grok", Account: &Account{plugin: &plugin.Provider{ID: "grok"}}}
+ for _, c := range []struct {
+ name string
+ p Provider
+ model string
+ want string
+ }{
+ {"built-in, tick off", builtin, ds, ""},
+ {"built-in, tick on", ticked, ds, "deepseek"},
+ {"built-in, tick on, GLM", ticked, "cline-pass/glm-5.3", "zai"},
+ {"plugin by default", plug, ds, "deepseek"},
+ {"plugin, a model it doesn't pin", plug, "cline-pass/kimi-k3", ""},
+ {"another plugin", other, ds, ""},
+ } {
+ if got := c.p.ClinePassAsked(c.model); got != c.want {
+ t.Errorf("%s: ClinePassAsked(%s) = %q; want %q", c.name, c.model, got, c.want)
+ }
+ }
+}