remote magpie: name its models by the provider serving them there (lcc580 on X)

lcc580 asked for a pass-through on the Remote magpie provider: show the
upstream magpie's own provider beside each model, so an agent can tell the
same model from two of its providers apart. Before, the names followed
both magpies' Provider in model names: with either one Off, both relays'
DeepSeek Chat reached the agents as "DeepSeek Chat · Office" (or plain
"DeepSeek Chat").

- The list a magpie gives another magpie (X-Magpie-Drawers) now names,
  as magpie_by, the provider serving each model there (Entry.ServedBy):
  "routing group" for a group, and for a model of its own Remote magpie
  the provider at the start of that chain. The fetch keeps it as the
  model's By (catalog/live.go).
- A Remote magpie provider gets upstreamProviders: the editor's "Model
  names" tick ("With the provider serving it there"), or
  `magpie provider set <id> upstream-providers=on`. With it on, each of
  its models is labelled "DeepSeek Chat · Office › Relay A" in every
  agent's list, whatever either magpie's Provider in model names says,
  unless the user named the model themselves under Own
  (Entry.Label/upstream, LabelsFor). Model settings' "Agents' lists show"
  line follows the tick at once.
- Ids are unchanged, so a request still goes by office/relay-b/model.
  Off (the default) names everything as before. A remote older than
  magpie_by has nothing to add, so its names stay as before.
- The core's scripts stay in budget: four long comments in app.js were
  cut to pay for it, no raise.

Run:
- Tests that fail on the old code: TestRemoteMagpieUpstreamNames
  (gateway: an httptest remote with two relays' DeepSeek Chat and a
  group, every Provider in model names mode, on and off, the third
  magpie's magpie_by, ids kept), TestServedByAndUpstreamLabel (provider),
  and name-suffix-remote.test.cjs's new case (tick, hint, save body).
- Broken by hand: upstream() returning "" and the magpie_by line removed;
  both Go tests went red with the plain labels, then restored.
- Two real gateways, built -tags nogui on the Linux box (WSL) under
  sandbox HOMEs: B with Relay A and Relay B both serving deepseek-chat,
  A with B as Remote magpie "Office". A's /v1/models before:
  "DeepSeek Chat · Relay A · Office"; after
  `provider set office upstream-providers=on`:
  "DeepSeek Chat · Office › Relay A" / "› Relay B" / "› routing group".
  A request for office/relay-b/deepseek-chat reached relay-b on B.
- gofmt -l clean; go vet darwin, linux (nogui), windows on the touched
  packages; go test catalog, provider, gateway, cli, gui on mote
  (macOS) at the rebased head: ok (catalog 2.6s, provider 165s, gateway 948s, cli 56s, gui 149s).
- GUI on mote, chromium and webkit: name-suffix-remote, remote-magpie,
  remote-self, i18n-keys, i18n-en-no-cjk, gui-ja, gui-de, gui-zh-tw,
  provider-detect-draft, provider-unmasked, routing-remote-windows,
  usage-remote-cards: all green except reds that fail the same on origin/main 388ca9ad4 (run there on the Linux box): gui-ja "ja has every zh string" (#5943) and remote-magpie "asks for the other magpie's address" in both engines (#4398); name-suffix-remote's old "named alone under Off" once in chromium de (#5147, scrollends.js import under load). The new case first failed in webkit (route lost after the save, the page's host went to DNS); it now uses one route whose server is swapped, 20 of 20 on the Linux box (WSL), both engines.

Not tried: the full suite (starts after the tag); the real desktop app's
editor by hand; a chain of three real magpies (the third magpie's
magpie_by is covered by the gateway test only).
This commit is contained in:
yetone
2026-11-10 22:20:17 +08:00
parent b9a1b4aa1d
commit 7e1858515b
15 changed files with 349 additions and 33 deletions
+13
View File
@@ -214,6 +214,19 @@ that the upstream does not list are named against all listed names and ids;
listed models keep their `Available` names unchanged
([`Exposed`](../../internal/provider/models.go)).
The list a magpie gives another magpie also names, as `magpie_by`, the
provider serving each model there (`Entry.ServedBy`: "routing group" for a
group, and for a model of its own Remote magpie the provider at the start
of that chain), kept as the model's `By` ([`live.go`](../../internal/catalog/live.go)).
A Remote magpie set `upstreamProviders` (the editor's *Model names* tick,
`magpie provider set <id> upstream-providers=on`; lcc580 on X) names each
of its models by it, whatever either magpie's *Provider in model names*:
"DeepSeek Chat · Office › Relay A" (`Entry.Label`, `upstream`), so the same
model from two of the remote's providers can be told apart. Ids stay as
they were, and a remote older than the field names its models as before
(`TestRemoteMagpieUpstreamNames`, `TestServedByAndUpstreamLabel`,
`name-suffix-remote.test.cjs`).
A listed model's window, reply limit and levels come from the vendor's
list first; only what it leaves out is filled from models.dev. `Decorate`
matches the provider's own catalog by id, then by the same model under
+6
View File
@@ -85,6 +85,12 @@ type Model struct {
// provider after it (magpie_label): the name Provider in model names
// Off has here (ARNO on Discord).
Plain string `json:",omitempty"`
// By, on a model of another magpie's list, is the provider that
// magpie names as serving it (magpie_by): its own provider's name, or,
// for a model it has from a magpie further on, the one there, the
// first in the chain. Its Remote magpie's upstream names (Provider's
// UpstreamProviders) say it after the model (lcc580 on X).
By string `json:",omitempty"`
// Via, on a model of another magpie's list, is the magpies it passes
// through to its vendor, that one last (magpie_via.go)
Via []string `json:",omitempty"`
+5 -2
View File
@@ -933,7 +933,7 @@ func fetchPage(ctx context.Context, url, key string, anthropic bool, headers map
if len(apis) == 0 {
apis = targetAPIs(r.TypeTarget)
}
m := Model{ID: id, Name: name, Plain: plain, ImageInput: input, APIs: apis, Draws: drawer, Films: films, Decides: decision, Serves: serves,
m := Model{ID: id, Name: name, Plain: plain, By: strings.TrimSpace(r.By), ImageInput: input, APIs: apis, Draws: drawer, Films: films, Decides: decision, Serves: serves,
InputModalities: ins, OutputModalities: outs}
if n, ok := r.ContextLength.(float64); ok && n > 0 {
m.Context = int(n)
@@ -1024,7 +1024,10 @@ type liveModel struct {
// another magpie's name for the model with its provider there after
// it, and "image", "video" or "decision" for its other models
Label string `json:"magpie_label"`
Kind string `json:"kind"`
// the provider serving the model there, the first in a chain of
// magpies (Model.By)
By string `json:"magpie_by"`
Kind string `json:"kind"`
// how another magpie searches the web for the model: "native" or
// "magpie" (Model.WebSearch)
WebSearch string `json:"web_search"`
+17
View File
@@ -58,6 +58,9 @@ const providerUsage = `usage:
image-files=off sends DeepSeek's API an agent's images inline on every
turn; image-files=on, the default, uploads each once (for a day)
and names it by its file id
upstream-providers=on, on a Remote magpie, names its models by the
provider serving each there (Claude · Office › RelayA); off, the
default, as that magpie's own list names them
patience=2m keeps a request to it alone (not through a group) that long
while it is busy or briefly rate limited, asking again after a pause
(at most 4m); patience=off hands the agent the error at once;
@@ -1216,6 +1219,20 @@ func applyPairs(p *provider.Provider, pairs []string) error {
default:
return fmt.Errorf("image-files=on|off, not %q", v)
}
case "upstream-providers":
// on: a Remote magpie's models named by the provider serving
// each there (Provider.UpstreamProviders, lcc580 on X)
if !p.IsRemoteMagpie() {
return fmt.Errorf("upstream-providers is a Remote magpie's; %s is not one", p.ID)
}
switch strings.ToLower(v) {
case "on", "yes":
p.UpstreamProviders = true
case "off", "no", "default":
p.UpstreamProviders = false
default:
return fmt.Errorf("upstream-providers=on|off, not %q", v)
}
case "prompt":
// as-written: Antigravity's subscription is sent the system
// prompt exactly as the agent wrote it, the lines Google turns
+5
View File
@@ -1695,6 +1695,10 @@ func (s *Server) listModels(w http.ResponseWriter, r *http.Request) {
// magpie that is this one's remote too doesn't take
// back its own models (catalog's magpie_via.go)
m["magpie_via"] = catalog.ViaHere(viaOf(e))
// the provider serving it, the first in a chain of
// magpies, for one that names its models by it
// (provider.UpstreamNames, lcc580 on X)
m["magpie_by"] = e.ServedBy()
}
if ts := tiers[e.ID]; len(ts) > 0 {
m["service_tiers"] = ts
@@ -1749,6 +1753,7 @@ func (s *Server) listModels(w http.ResponseWriter, r *http.Request) {
m["kind"], m["magpie_label"] = "decision", labels[i]
m["native_endpoints"] = []string{"/v1/systemone"}
m["magpie_via"] = catalog.ViaHere(viaOf(e))
m["magpie_by"] = e.ServedBy()
data = append(data, m)
}
}
@@ -0,0 +1,115 @@
package gateway
import (
"context"
"encoding/json"
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/yetone/magpie/internal/provider"
)
// upstreamList is what another magpie, its own Provider in model names
// Off, lists for this one: DeepSeek Chat from two of its relays, each
// labelled by its name alone, so the agents here saw two "DeepSeek Chat ·
// Remote magpie" (lcc580 on X). magpie_by names the provider serving each
// there.
const upstreamList = `{"object":"list","data":[` +
`{"id":"relaya/deepseek-chat","object":"model","owned_by":"relaya","display_name":"DeepSeek Chat","magpie_label":"DeepSeek Chat","magpie_by":"Relay A","native_endpoints":["/v1/chat/completions"],"context_length":128000},` +
`{"id":"relayb/deepseek-chat","object":"model","owned_by":"relayb","display_name":"DeepSeek Chat","magpie_label":"DeepSeek Chat","magpie_by":"Relay B","native_endpoints":["/v1/chat/completions"],"context_length":128000},` +
`{"id":"group/fast","object":"model","owned_by":"relaya","display_name":"Fast","magpie_label":"Fast","magpie_by":"routing group","context_length":128000}]}`
type listed struct {
ID string `json:"id"`
Label string `json:"magpie_label"`
By string `json:"magpie_by"`
}
func listFor(t *testing.T, asMagpie bool) map[string]listed {
t.Helper()
rec := httptest.NewRecorder()
req := httptest.NewRequest("GET", "/v1/models", nil)
if asMagpie {
req.Header.Set(provider.DrawersHeader, "1")
}
New().Handler().ServeHTTP(rec, req)
var out struct{ Data []listed }
if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil {
t.Fatal(err)
}
got := map[string]listed{}
for _, m := range out.Data {
got[m.ID] = m
}
return got
}
// A Remote magpie's upstream names name each of its models by the
// provider serving it there, whatever either magpie's Provider in model
// names is, and its ids stay as they were. Off, the default, they are
// named as before. Listed on to a third magpie, a model names the provider
// at the start of the chain, not the Remote magpie it came through.
func TestRemoteMagpieUpstreamNames(t *testing.T) {
fresh(t)
remote := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
io.WriteString(w, upstreamList)
}))
t.Cleanup(remote.Close)
id, err := provider.Add(provider.Provider{ID: "office", Name: "Office", Key: "magpie", Preset: provider.RemoteMagpiePreset, Chat: remote.URL})
if err != nil {
t.Fatal(err)
}
p, _ := provider.Find(id)
if _, err := p.Fetch(context.Background()); err != nil {
t.Fatal(err)
}
t.Cleanup(func() { provider.SetSuffixMode(provider.SuffixOn) })
set := func(on bool) {
t.Helper()
p, _ := provider.Find(id)
p.UpstreamProviders = on
if err := provider.Save(*p); err != nil {
t.Fatal(err)
}
}
for _, c := range []struct {
on bool
mode string
a, b, group string
}{
{false, provider.SuffixOn, "DeepSeek Chat · Office", "DeepSeek Chat · Office", "Fast · Office"},
{false, provider.SuffixOff, "DeepSeek Chat · Office", "DeepSeek Chat · Office", "Fast"},
{true, provider.SuffixOn, "DeepSeek Chat · Office › Relay A", "DeepSeek Chat · Office › Relay B", "Fast · Office › routing group"},
{true, provider.SuffixOwn, "DeepSeek Chat · Office › Relay A", "DeepSeek Chat · Office › Relay B", "Fast · Office › routing group"},
{true, provider.SuffixOff, "DeepSeek Chat · Office › Relay A", "DeepSeek Chat · Office › Relay B", "Fast · Office › routing group"},
} {
set(c.on)
if err := provider.SetSuffixMode(c.mode); err != nil {
t.Fatal(err)
}
got := listFor(t, false)
a, b, g := got["office/relaya/deepseek-chat"], got["office/relayb/deepseek-chat"], got["office/group/fast"]
if a.Label != c.a || b.Label != c.b || g.Label != c.group {
t.Errorf("upstream names %v, %s: %q, %q, %q; want %q, %q, %q", c.on, c.mode, a.Label, b.Label, g.Label, c.a, c.b, c.group)
}
// an agent's list is told no magpie_by; another magpie's is
if a.By != "" {
t.Errorf("an agent's list has magpie_by %q", a.By)
}
}
// a third magpie is told the provider at the start of the chain
got := listFor(t, true)
for id, want := range map[string]string{"office/relaya/deepseek-chat": "Relay A", "office/relayb/deepseek-chat": "Relay B", "office/group/fast": "routing group"} {
if got[id].By != want {
t.Errorf("%s: magpie_by %q, want %q", id, got[id].By, want)
}
}
// a request still names the model by its id, which goes to the remote
if _, ok := got["office/relaya/deepseek-chat"]; !ok || strings.Contains(got["office/relaya/deepseek-chat"].ID, "›") {
t.Errorf("ids changed: %v", got)
}
}
+20 -21
View File
@@ -8998,12 +8998,8 @@ const edAlign = new ResizeObserver((es) => {
if (!n.isConnected) { edAlign.unobserve(n); continue; }
const cs = getComputedStyle(n.parentElement), cols = cs.gridTemplateColumns.split(" ");
const lab = cols.length > 1 ? parseFloat(cols[0]) || 0 : 0;
// only when changed, and in an open fold a change after the first a
// frame later: its rows take the column, so set while the observer is
// delivering, the fold's own height changes with it (a label wrapping)
// and the browser reports a loop as a page error (a group's editor
// narrowed with the window). A closed fold only moves its chevron, so
// it follows at once, never a frame out of line
// only when changed; an open fold's later change a frame later, or its
// own height change is reported as an observer loop (a page error)
const at = (lab && lab + parseFloat(cs.columnGap)) + "px";
if (n.style.getPropertyValue("--ed-lab") === lab + "px" && n.style.getPropertyValue("--ed-at") === at) continue;
const set = () => { n.style.setProperty("--ed-lab", lab + "px"); n.style.setProperty("--ed-at", at); };
@@ -9223,7 +9219,7 @@ function baseAPIOf(p) {
// draftOf is a saved provider as its editor's form holds it.
function draftOf(p) {
return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, best: !!p.bestInFamily, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), passHeaders: (p.passHeaders || []).join(", "), icon: p.icon || "", iconFrom: p.iconFrom || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], hiddenVideomakers: [...(p.hiddenVideomakers || [])], searches: !!p.searches, unredacted: !!p.unredacted, countFree: !!p.countFree, billing: p.billing || "", insecureTLS: !!p.insecureTLS, http1: !!p.http1, clientCert: p.clientCert || "", clientKey: p.clientKey || "", serverCA: p.serverCA || "", socket: p.socket || "", limitRestOff: !!p.limitRestOff, passErrors: !!p.passErrors, imageFilesOff: !!p.imageFilesOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: p.passUserAgent !== false, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", listOff: !!p.listOff, contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p), rateWindows: (p.rateWindows || []).map((w) => ({ ...w })) };
return { id: p.id, name: p.name, preset: p.preset, chat: p.chat, responses: p.responses, anthropic: p.anthropic, gemini: p.gemini || "", catalog: p.catalog, decide: p.decide || "", key: "", api: baseAPIOf(p), chosen: pickedOf(p), none: !!p.noModels, best: !!p.bestInFamily, extra: [], headers: headerRows(p.headers), extraBody: extraBodyText(p.extraBody), replyHeaders: (p.replyHeaders || []).join(", "), passHeaders: (p.passHeaders || []).join(", "), icon: p.icon || "", iconFrom: p.iconFrom || "", fallback: [...(p.fallback || [])], unlisted: !!p.unlisted, hiddenDrawers: [...(p.hiddenDrawers || [])], hiddenVideomakers: [...(p.hiddenVideomakers || [])], searches: !!p.searches, unredacted: !!p.unredacted, countFree: !!p.countFree, billing: p.billing || "", insecureTLS: !!p.insecureTLS, http1: !!p.http1, clientCert: p.clientCert || "", clientKey: p.clientKey || "", serverCA: p.serverCA || "", socket: p.socket || "", limitRestOff: !!p.limitRestOff, upstreamProviders: !!p.upstreamProviders, passErrors: !!p.passErrors, imageFilesOff: !!p.imageFilesOff, nativeCompaction: !!p.nativeCompaction, passUserAgent: p.passUserAgent !== false, pinUpstream: !!p.pinUpstream, authHeader: p.authHeader || "", balanceURL: p.balanceURL || "", balancePath: p.balancePath || "", balanceMethod: p.balanceMethod || "", modelsURL: p.modelsURL || "", listOff: !!p.listOff, contexts: contextsText(p.contexts), outputs: contextsText(p.outputs), compacts: contextsText(p.compacts), keysUrl: p.keysUrl || "", ...proxyDraft(p), ...concurrencyDraft(p), rateWindows: (p.rateWindows || []).map((w) => ({ ...w })) };
}
// duplicateProvider opens the Add form on a copy of p, its key p's unless another is pasted (#268).
@@ -9735,6 +9731,13 @@ function drawEditor(p, presetID) {
c.onchange = () => (draft.libraryMCP = c.checked);
ed.append(...field(t("MCP servers"), l));
}
// lcc580 on X
if ((p?.preset || pr?.id) === "remote-magpie") {
const [l, c] = tick(t("With the provider serving it there"), !!draft.upstreamProviders);
l.classList.add("upstream-providers");
c.onchange = () => { draft.upstreamProviders = c.checked; draft.onUpstreamProviders?.(); };
ed.append(...field(t("Model names"), l));
}
// A user-defined provider can have its own picture; presets keep theirs.
if (custom) ed.append(...field(t("Icon"), iconPicker(ed), ""));
@@ -10233,6 +10236,7 @@ function drawEditor(p, presetID) {
if (certTakes()) for (const k of CERT_FIELDS) body[k] = onHTTPS() ? (draft[k] || "").trim() : "";
if (socketable()) body.socket = draft.socket || "";
if (custom) body.limitRestOff = !!draft.limitRestOff;
if ((p?.preset || pr?.id) === "remote-magpie") body.upstreamProviders = !!draft.upstreamProviders;
if (p?.takesImageFiles) body.imageFilesOff = !!draft.imageFilesOff;
if (p ? p.takesPassErrors : custom) body.passErrors = !!draft.passErrors;
if (!decideOnly(p || pr)) body.nativeCompaction = !!draft.nativeCompaction && carriesCompaction();
@@ -11524,12 +11528,15 @@ function renderModels(p) {
const sayLabel = (mode) => {
const name = prefs[first.id]?.name ?? (first.default ? first.name : "");
const base = name || first.default || first.name || first.id;
let label = suffixed(base, p.name || p.id, !!name, mode);
// named by the provider serving it there (lcc580 on X)
const up = draft.upstreamProviders && first.by && !(name && (mode || suffixMode()) === "own");
let label = up ? (name || first.plain || base) + " · " + (p.name || p.id) + " › " + first.by : suffixed(base, p.name || p.id, !!name, mode);
// a remote magpie's model: its name there (ARNO)
if (!name && first.plain && label === base) label = first.plain;
if (!up && !name && first.plain && label === base) label = first.plain;
sfxSaid.textContent = t("Agents’ lists show “{label}”", { label });
};
sayLabel();
draft.onUpstreamProviders = () => sayLabel();
sfx.dataset.mode = suffixMode();
sfx.drawnAgain = sayLabel;
const where = el("button", "text action", t("Change in Settings"));
@@ -17063,12 +17070,8 @@ if (mode === "panel") document.addEventListener("visibilitychange", () => {
if (panelPeek || panelArranging) { panelPeek = ""; panelArranging = false; renderPanelQuota(); }
});
// The tray panel is four tabs over the one page: the agents, the allowances
// of every subscription and key (the "usage" tab, as it was named before),
// what the requests add up to (the "stats" tab, the window's Requests made
// small) and the gateway's latest requests (routing/client.js draws those). The saved
// profiles open from Profiles at the Agents tab's foot, over the list (a tab
// of their own was one too many). The tab is remembered.
// The tray panel's four tabs: agents, allowances ("usage"), totals ("stats")
// and latest requests; Profiles opens at the Agents tab's foot.
const profBtn = $("#profBtn"), profBox = $(".profiles");
function placeProfiles() {
if (!profBox.classList.contains("open")) return;
@@ -22997,12 +23000,8 @@ function setRoom(v, px) {
r.style.height = px + "px";
room.set(v, px);
}
// Where what's in the view ends, its padding at the foot included, the room
// aside. Not scrollHeight less the room: scrollHeight is never less than the
// view is tall, so under a list shorter than the view (the agents rolled up
// in a tall window) it counted the empty foot as content, the room made was
// too short to hold the list, and each frame's hold and fit took turns
// adding and taking it away, the list swinging between two places (#355).
// Where the view's content ends, the room aside; never scrollHeight less
// the room, which is never under the view's height (#355).
function contentEnd(v) {
const top = v.getBoundingClientRect().top - v.scrollTop;
let end = 0;
+8
View File
@@ -2769,6 +2769,8 @@ const I18N = {
"{name} added": "已添加 {name}",
"Give it a name": "先起个名字",
"Add its MCP servers to the Library": "把它的 MCP 服务器加到资源库",
"Model names": "模型名",
"With the provider serving it there": "带上它那边的供应商(穿透)",
"A base URL is needed": "需要填写 Base URL",
"Endpoint": "接口地址",
"Your resource's endpoint is needed": "需要填写你的资源接口地址",
@@ -7698,6 +7700,8 @@ const I18N = {
"{name} added": "已新增 {name}",
"Give it a name": "先起個名字",
"Add its MCP servers to the Library": "把它的 MCP 伺服器加到資源庫",
"Model names": "模型名稱",
"With the provider serving it there": "帶上它那邊的供應商(穿透)",
"A base URL is needed": "需要填寫 Base URL",
"Endpoint": "端點位址",
"Your resource's endpoint is needed": "需要填寫你的資源端點",
@@ -12605,6 +12609,8 @@ const I18N = {
"{name} added": "{name} を追加しました",
"Give it a name": "名前を付けてください",
"Add its MCP servers to the Library": "その MCP サーバーをライブラリに追加",
"Model names": "モデル名",
"With the provider serving it there": "向こうで提供しているプロバイダーを付ける",
"A base URL is needed": "ベース URL が必要です",
"Endpoint": "エンドポイント",
"Your resource's endpoint is needed": "リソースのエンドポイントが必要です",
@@ -17543,6 +17549,8 @@ const I18N = {
"{name} added": "{name} hinzugefügt",
"Give it a name": "Vergeben Sie einen Namen",
"Add its MCP servers to the Library": "Seine MCP-Server zur Bibliothek hinzufügen",
"Model names": "Modellnamen",
"With the provider serving it there": "Mit dem Anbieter, der es dort bereitstellt",
"A base URL is needed": "Eine Basis-URL ist erforderlich",
"Endpoint": "Endpunkt",
"Your resource's endpoint is needed": "Der Endpunkt Ihrer Ressource ist erforderlich",
File diff suppressed because one or more lines are too long
+19 -1
View File
@@ -36,6 +36,7 @@ type modelJSON struct {
Name string `json:"name"` // the user's name for it, if they gave one
Default string `json:"default,omitempty"` // its own name, when the user gave it another
Plain string `json:"plain,omitempty"` // a remote magpie's model's name there alone, when Name has its provider there after it (catalog.Model's)
By string `json:"by,omitempty"` // a remote magpie's model's provider there, the first in a chain (catalog.Model's)
Kept []string `json:"kept,omitempty"` // the reasoning levels the user keeps of Efforts, when not all
Efforts []string `json:"efforts,omitempty"`
Given bool `json:"given,omitempty"` // its levels aren't known: Efforts are those it can be given, Kept those it was
@@ -159,6 +160,9 @@ type providerJSON struct {
// asked as usual after a quota refusal or a 429, never set aside for
// it (provider.LimitRestOff)
LimitRestOff bool `json:"limitRestOff"`
// a Remote magpie's models named by the provider serving each there
// (provider.UpstreamProviders, lcc580 on X)
UpstreamProviders bool `json:"upstreamProviders,omitempty"`
// DeepSeek's own API sent an agent's images inline on every turn, not
// once by file id (provider.ImageFilesOff, #5407); TakesImageFiles:
// it is DeepSeek's own API, so the editor offers it
@@ -824,7 +828,7 @@ func providerInfoWith(p provider.Provider, ls provider.Listing, agents []agentUs
ID: p.ID, Name: p.Name, Icon: p.Icon, IconFrom: p.IconFrom, Preset: p.Preset, Host: p.Host(),
Chat: p.Chat, Responses: p.Responses, Anthropic: p.Anthropic, Gemini: p.Gemini, Decide: p.Decide, BaseAPI: p.BaseAPI, ModelTest: p.ModelTest(), TestsAs: p.TestClients(), DecideTest: p.AsksDecideModels(), MarksKinds: p.MarksKinds(),
Catalog: p.Catalog, Website: p.Website, KeysURL: p.KeysURL,
Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, AccountWindowAmounts: p.AccountWindowAmounts, AccountNames: p.AccountNames, Headers: p.Headers, ExtraBody: p.ExtraBody, ReplyHeaders: p.ReplyHeaders, PassHeaders: p.PassHeaders, Searches: p.Searches, Cline: p.ClinePinnable(), PinUpstream: p.PinUpstream, Unredacted: p.Unredacted, CountFree: p.CountFree, Billing: p.Billing, BillingKind: p.BillingKind(), InsecureTLS: p.InsecureTLS, TakesInsecureTLS: p.TakesInsecureTLS(), HTTP1: p.HTTP1, ClientCert: tilde(p.ClientCert), ClientKey: tilde(p.ClientKey), ServerCA: tilde(p.ServerCA), TakesClientCert: p.TakesClientCert(), Socket: p.Socket, TakesSocket: p.TakesSocket(), LimitRestOff: p.LimitRestOff, ImageFilesOff: p.ImageFilesOff, TakesImageFiles: p.TakesImageFiles(), NativeCompaction: p.NativeCompaction, CarriesCompaction: p.CarriesCompaction(), PassUserAgent: !p.MagpieUserAgent, OwnClient: p.OwnClient(), PassErrors: p.PassErrors, TakesPassErrors: p.TakesPassErrors(), AuthHeader: p.AuthHeader, BothAuth: p.BothAuth(), BalanceURL: p.BalanceURL, BalancePath: p.BalancePath, BalanceMethod: p.BalanceMethod, ModelsURL: p.ModelsURL, ListOff: p.ListsOff(), TakesListOff: p.Account == nil && !p.IsPlugin() && !p.DecideOnly(), TakesModelHeaders: p.Account == nil, DecideAPIKind: p.DecideAPIKind(),
Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, AccountWindowCaps: p.AccountWindowCaps, AccountWindowAmounts: p.AccountWindowAmounts, AccountNames: p.AccountNames, Headers: p.Headers, ExtraBody: p.ExtraBody, ReplyHeaders: p.ReplyHeaders, PassHeaders: p.PassHeaders, Searches: p.Searches, Cline: p.ClinePinnable(), PinUpstream: p.PinUpstream, Unredacted: p.Unredacted, CountFree: p.CountFree, Billing: p.Billing, BillingKind: p.BillingKind(), InsecureTLS: p.InsecureTLS, TakesInsecureTLS: p.TakesInsecureTLS(), HTTP1: p.HTTP1, ClientCert: tilde(p.ClientCert), ClientKey: tilde(p.ClientKey), ServerCA: tilde(p.ServerCA), TakesClientCert: p.TakesClientCert(), Socket: p.Socket, TakesSocket: p.TakesSocket(), LimitRestOff: p.LimitRestOff, UpstreamProviders: p.UpstreamProviders, ImageFilesOff: p.ImageFilesOff, TakesImageFiles: p.TakesImageFiles(), NativeCompaction: p.NativeCompaction, CarriesCompaction: p.CarriesCompaction(), PassUserAgent: !p.MagpieUserAgent, OwnClient: p.OwnClient(), PassErrors: p.PassErrors, TakesPassErrors: p.TakesPassErrors(), AuthHeader: p.AuthHeader, BothAuth: p.BothAuth(), BalanceURL: p.BalanceURL, BalancePath: p.BalancePath, BalanceMethod: p.BalanceMethod, ModelsURL: p.ModelsURL, ListOff: p.ListsOff(), TakesListOff: p.Account == nil && !p.IsPlugin() && !p.DecideOnly(), TakesModelHeaders: p.Account == nil, DecideAPIKind: p.DecideAPIKind(),
Ready: p.Ready(), Chosen: p.PicksOf(avail), Agents: make([]providerAgent, 0, len(agents)),
Fallback: p.Fallback, Routing: p.Routing, Sink: p.Sink, UseFirst: p.UseFirst, Affinity: p.Affinity, KeepLogin: p.KeepLogin, KeepLoginAs: p.KeepLoginAs, SwitchOnly: p.SwitchOnly, RestartApp: p.RestartApp, Self: p.SelfAnswered(), KeepSelf: p.KeepSelf, CapStop: p.CapStop, CapCareful: p.CapCareful, Unlisted: p.Unlisted, NoModels: p.ServesNone(), BestInFamily: p.BestInFamily && len(p.Models) == 0 && !p.NoModels, Off: p.Off, Contexts: p.Contexts,
MaxConcurrency: p.MaxConcurrency, PluginConcurrency: p.PluginConcurrency(), MaxAccounts: p.MaxAccounts, PluginAccounts: p.PluginAtOnce(), PriceRate: p.PriceRate,
@@ -1046,6 +1050,9 @@ func providerInfoWith(p provider.Provider, ls provider.Listing, agents []agentUs
} else {
j.Plain = m.Plain
}
if p.IsRemoteMagpie() {
j.By = m.By
}
if api, ok := p.ModelAPI(m.ID); ok {
j.API = string(api)
}
@@ -1622,6 +1629,9 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
// LimitRestOff is whether a quota refusal or a 429 leaves it
// asked as usual; a save that leaves it out keeps it
LimitRestOff *bool `json:"limitRestOff"`
// UpstreamProviders, on a Remote magpie, names its models by the
// provider serving each there; a save that leaves it out keeps it
UpstreamProviders *bool `json:"upstreamProviders"`
// ImageFilesOff is whether DeepSeek's own API is sent an
// agent's images inline (#5407); a save that leaves it out
// keeps it, as `magpie provider set <id> image-files=off` set it
@@ -2061,6 +2071,9 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
if req.LimitRestOff != nil {
in.LimitRestOff = *req.LimitRestOff
}
if req.UpstreamProviders != nil {
in.UpstreamProviders = *req.UpstreamProviders && in.IsRemoteMagpie()
}
if req.ImageFilesOff != nil {
in.ImageFilesOff = *req.ImageFilesOff
}
@@ -2115,6 +2128,11 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
} else if old != nil {
in.LimitRestOff = old.LimitRestOff
}
if req.UpstreamProviders != nil {
in.UpstreamProviders = *req.UpstreamProviders && in.IsRemoteMagpie()
} else if old != nil {
in.UpstreamProviders = old.UpstreamProviders
}
// DeepSeek's images sent inline, set here or with `magpie
// provider set <id> image-files=off` (#5407)
if req.ImageFilesOff != nil {
+49 -2
View File
@@ -13,11 +13,11 @@ const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
function serve(lang, posts, plainNames) {
function serve(lang, posts, plainNames, saves = []) {
let cur = { lang, theme: "light", plainNames, plainOwnNames: false };
const state = { agents: [{ id: "codex", name: "Codex", path: "/test/codex", fields: [] }], profiles: [], settings: { lang, theme: "light", plainNames } };
const models = [
{ id: "relaya/deepseek-chat", name: "DeepSeek Chat · Relay A", plain: "DeepSeek Chat", on: true, efforts: [], images: false },
{ id: "relaya/deepseek-chat", name: "DeepSeek Chat · Relay A", plain: "DeepSeek Chat", by: "Relay A", on: true, efforts: [], images: false },
];
const provider = { id: "remote-magpie", name: "Remote magpie", preset: "remote-magpie", icon: "generic", chat: "http://192.168.1.20:3425/v1", responses: "http://192.168.1.20:3425/v1", anthropic: "http://192.168.1.20:3425",
models, agents: [], key: { set: true, masked: "sk-…1234" }, ready: true };
@@ -34,6 +34,7 @@ function serve(lang, posts, plainNames) {
return json(cur);
}
if (url.pathname === "/api/settings") return json(cur);
if (url.pathname === "/api/provider/save") { saves.push(req.postDataJSON()); return json({ id: provider.id }); }
if (url.pathname === "/api/plugins") return json({ plugins: [] });
if (url.pathname === "/api/gateway/trace") {
if (url.searchParams.get("wait")) return new Promise(() => {});
@@ -83,3 +84,49 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
});
}
}
// lcc580 on X: a Remote magpie's models named by the provider serving each
// there, so one model from two of its providers is told apart here. Its
// editor's switch says what the agents' lists show, under On and Off
// alike, and is saved with the provider.
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
test(`${engine} ${lang}: a remote magpie's model named by its provider there`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: process.env.PLAYWRIGHT_CHANNEL || "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width: 420, height: 900 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
page.setDefaultNavigationTimeout(60000);
const errors = [], posts = [];
page.on("pageerror", (e) => errors.push(e.message));
// one route, its server swapped: WebKit lost a route set again after
// the save, and the page's address went to DNS
let served;
await page.route("**/*", (r) => served(r));
for (const plain of [false, true]) {
const saves = [];
served = serve(lang, posts, plain, saves);
await page.goto("http://magpie.test/?view=providers");
const tr = (k, vars = {}) => page.evaluate(([k, vars]) => t(k, vars), [k, vars]);
await page.locator(".row.provider").click();
if (!(await page.locator(".mnames:not([hidden])").count())) await page.getByRole("button", { name: await tr("Model settings"), exact: true }).click();
const sfx = page.locator(".mnames:not([hidden]) .msuffix");
await sfx.waitFor();
const tick = page.locator("label.upstream-providers");
assert.equal((await tick.textContent()).trim(), await tr("With the provider serving it there"));
assert.equal(await tick.locator("input").isChecked(), false);
await tick.locator("input").check();
await says(sfx.locator(".hint"), await tr("Agents’ lists show “{label}”", { label: "DeepSeek Chat · Remote magpie › Relay A" }));
await tick.locator("input").uncheck();
await says(sfx.locator(".hint"), await tr("Agents’ lists show “{label}”", { label: plain ? "DeepSeek Chat" : "DeepSeek Chat · Relay A · Remote magpie" }));
await tick.locator("input").check();
const ed = page.locator(".editor").filter({ has: tick });
await Promise.all([page.waitForResponse((r) => r.url().endsWith("/api/provider/save")), ed.locator(".bar button.primary").first().click()]);
assert.equal(saves.length, 1);
assert.equal(saves[0].upstreamProviders, true);
}
assert.deepEqual(posts, []);
assert.deepEqual(errors, []);
});
}
}
+43 -5
View File
@@ -839,15 +839,48 @@ func renameModelPrefs(s *settings.Settings, from, to string) bool {
// when they gave one, else the vendor's) with its provider's after it, or
// "routing group" for a group's — dropped only when a name of the user's
// own already carries the provider's, so it isn't said twice.
//
// A Remote magpie's model, with its upstream names on (UpstreamProviders), is
// named by its name there alone and the provider serving it there after
// this one's: "Claude Sonnet 5 · Office › RelayA" (lcc580 on X).
func (e Entry) Label() string {
by := e.Provider.Name
by, name := e.Provider.Name, e.Name
if e.Group != "" {
by = "routing group"
} else if up := e.upstream(); up != "" {
by = e.Provider.Name + " › " + up
if e.Default == "" {
name = e.PlainName()
}
}
if e.Default != "" && strings.Contains(strings.ToLower(e.Name), strings.ToLower(by)) {
return e.Name
if e.Default != "" && strings.Contains(strings.ToLower(name), strings.ToLower(by)) {
return name
}
return e.Name + " · " + by
return name + " · " + by
}
// upstream is the provider a Remote magpie's model is served by there,
// when its upstream names are on and that magpie's list said which; ""
// otherwise (a magpie from before magpie_by says none).
func (e Entry) upstream() string {
if e.Group != "" || !e.Provider.UpstreamProviders || !e.Provider.IsRemoteMagpie() {
return ""
}
return e.By
}
// ServedBy is the provider this magpie's list tells another magpie serves
// the entry (magpie_by): its own provider, or, for a model it has from a
// magpie further on, the one there, the first in the chain; "routing
// group" for a group's.
func (e Entry) ServedBy() string {
switch {
case e.Group != "":
return "routing group"
case e.Provider.IsRemoteMagpie() && e.By != "":
return e.By
}
return e.Provider.Name
}
// Labels are how an agent's list names each of es, in order: as Label, or,
@@ -893,6 +926,11 @@ func LabelsFor(agent string, es []Entry) []string {
if !(plain || mine) || name == "" {
continue
}
// a Remote magpie's model named by its provider there keeps it
// under Off too: the user turned that on for this one (lcc580)
if e.upstream() != "" && !mine {
continue
}
k := strings.ToLower(name)
if e.Group == "" && models[k] == 1 || e.Group != "" && models[k] == 0 && groups[k] == 1 {
out[i] = name
@@ -1472,7 +1510,7 @@ func wireKey(wires map[string]string, pid, model string) string {
return key
}
// UpstreamNames are the names the user gave the provider's models, by model
// UpstreamProviders are the names the user gave the provider's models, by model
// id, with the one given for all of them under "*" — each as it will be sent,
// trimmed, "*" and all, which is what a list of them shows. A name that is
// only whitespace is none, and is not listed.
+7 -1
View File
@@ -3129,7 +3129,10 @@ type Entry struct {
Default string `json:"default,omitempty"` // the model's own name, when the user gave it another
// Plain is a remote magpie's model's name there alone, when Name is
// its label there with that magpie's provider after it (catalog.Model's)
Plain string `json:"-"`
Plain string `json:"-"`
// By is the provider a remote magpie's list names as serving the
// model there, the first in a chain of magpies (catalog.Model's)
By string `json:"-"`
Efforts []string `json:"efforts,omitempty"`
Provider Provider `json:"-"` // a group's: its first member's
Group string `json:"group,omitempty"` // set on a routing group (group.go)
@@ -3477,6 +3480,9 @@ func entryFor(p Provider, m catalog.Model, s settings.Settings) Entry {
} else {
e.Plain = m.Plain
}
if p.IsRemoteMagpie() {
e.By = m.By
}
// a model that thinks still does with the levels the user kept or
// none at all; one its source says nothing of thinks as most of the
// providers serving it say (#402)
+9
View File
@@ -339,6 +339,15 @@ type Provider struct {
// by its file id (gateway's deepseek_files.go, #5407).
ImageFilesOff bool `json:"imageFilesOff,omitempty"`
// UpstreamProviders, on a Remote magpie, `upstream-providers=on`, names each
// of its models in the agents' lists by the provider serving it on
// the other magpie, the first in a chain of them: "Claude Sonnet 5 ·
// Office › RelayA", whatever that magpie's own Provider in model names
// is, so one model from two of its providers is told apart here
// (lcc580 on X). Off, the default, names each as that magpie's list
// does. The ids stay as they are: office/relaya/claude-sonnet-5.
UpstreamProviders bool `json:"upstreamProviders,omitempty"`
// PromptAsWritten, on Antigravity's subscription, has the system prompt
// go to Google exactly as the agent wrote it. By default the few lines
// Google answers with a 429 "Resource has been exhausted" whatever
+32
View File
@@ -0,0 +1,32 @@
package provider
import "testing"
// A magpie's list tells another the provider serving each model
// (magpie_by): its own provider, the one at the start of a chain of
// magpies for a Remote magpie's, "routing group" for a group (lcc580 on
// X). A Remote magpie whose list said none (one from before) is named
// as ever, upstream names on or off.
func TestServedByAndUpstreamLabel(t *testing.T) {
relay := Provider{ID: "relaya", Name: "Relay A"}
remote := Provider{ID: "office", Name: "Office", Preset: RemoteMagpiePreset, UpstreamProviders: true}
for _, c := range []struct {
e Entry
by, label string
}{
{Entry{Name: "DeepSeek Chat", Provider: relay}, "Relay A", "DeepSeek Chat · Relay A"},
{Entry{Name: "Fast", Group: "fast", Provider: relay}, "routing group", "Fast · routing group"},
{Entry{Name: "DeepSeek Chat · Relay A", Plain: "DeepSeek Chat", By: "Relay A", Provider: remote}, "Relay A", "DeepSeek Chat · Office › Relay A"},
{Entry{Name: "Mine", Default: "DeepSeek Chat", By: "Relay A", Provider: remote}, "Relay A", "Mine · Office › Relay A"},
{Entry{Name: "DeepSeek Chat · Relay A", Plain: "DeepSeek Chat", Provider: remote}, "Office", "DeepSeek Chat · Relay A · Office"},
// upstream names on a provider that isn't a Remote magpie do nothing
{Entry{Name: "DeepSeek Chat", By: "Relay A", Provider: Provider{ID: "x", Name: "X", UpstreamProviders: true}}, "X", "DeepSeek Chat · X"},
} {
if got := c.e.ServedBy(); got != c.by {
t.Errorf("%+v: served by %q, want %q", c.e, got, c.by)
}
if got := c.e.Label(); got != c.label {
t.Errorf("%+v: label %q, want %q", c.e, got, c.label)
}
}
}