Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui: a partner's editor link names its own page (www.kimi.com), not usemagpie.ai
yetone19f9a80d90dc
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 628d6148b..70306fb7b 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -9025,11 +9025,12 @@ function drawEditor(p, presetID) {h.append(icon(p?.icon || (copyOf && draft.icon) || pr?.icon || "generic"), el("b", "", p ? p.name : copyOf ? t("Copy of {name}", { name: copyOf.name }) : pr ? pr.name : t("Custom provider")));if (pr?.kind === "partner") { if (partnerNote(pr)) h.append(el("span", "note", partnerNote(pr))); } else if (pr?.note) h.append(el("span", "note", t(pr.note)));h.append(el("span", "grow"));- // a region with docs of its own (Tencent Cloud's plan and TokenHub) has- // its page here, following the region picked below- const site = regionAt(pr, draft)?.website || pr?.website || p?.website || hostSite(p);+ // a region's own page (Tencent Cloud's), following the region picked+ // below; a partner's /go link is named by where it goes (siteHost)+ const at = regionAt(pr, draft)?.website ? regionAt(pr, draft) : pr;+ const site = at?.website || p?.website || hostSite(p);if (site) {- const b = el("button", "link site", hostOf(site) + " ↗");+ const b = el("button", "link site", hostOf(at?.siteHost || site) + " ↗");b.dataset.url = site;b.onclick = () => api("open", { url: b.dataset.url });h.append(b);@@ -9699,7 +9700,7 @@ function drawEditor(p, presetID) {const site = ed.querySelector(".ehead .link.site");if (site && pr.regions.some((x) => x.website)) {site.dataset.url = r.website || pr.website;- site.textContent = hostOf(site.dataset.url) + " ↗";+ site.textContent = hostOf((r.website ? r : pr).siteHost || site.dataset.url) + " ↗";}onRegion(r);accessAt(r);diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.goindex 1cc138c03..6fed24fb3 100644--- a/internal/gui/core_budget_test.go+++ b/internal/gui/core_budget_test.go@@ -15,8 +15,8 @@ import (// so a page can't quietly grow back into the core; a change that needs more// raises them and says why in its commit.const (- appScriptBudget = 1_337_633 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added- coreScriptBudget = 1_529_393 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added+ appScriptBudget = 1_337_735 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23)+ coreScriptBudget = 1_529_495 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added)func TestCoreScriptBudget(t *testing.T) {diff --git a/internal/gui/tests/partners.test.cjs b/internal/gui/tests/partners.test.cjsindex 4217bf358..fe65184c2 100644--- a/internal/gui/tests/partners.test.cjs+++ b/internal/gui/tests/partners.test.cjs@@ -18,7 +18,13 @@ const assets = path.resolve(__dirname, "../assets");const partner = (id, name, extra = {}) => ({ id, name, icon: "generic", kind: "partner", sponsored: true, chat: `https://api.${id}.example.com/v1`, ...extra });const partners = [- partner("acme", "Acme AI", { notes: { en: "Fast relay", zh: "快速中转", ja: "高速な中継" } }),+ partner("acme", "Acme AI", { notes: { en: "Fast relay", zh: "快速中转", ja: "高速な中継" },+ // its pages are /go links, named by the host they send the browser to+ website: "https://usemagpie.ai/go/acme/site", siteHost: "www.acme.example",+ regions: [+ { id: "cn", name: "China", chat: "https://api.acme.example.com/v1", website: "https://usemagpie.ai/go/acme/site/cn", siteHost: "cn.acme.example" },+ { id: "global", name: "Global", chat: "https://global.acme.example.com/v1", website: "https://usemagpie.ai/go/acme/site/global", siteHost: "global.acme.example" },+ ] }),partner("zhonly", "China Only", { langs: ["zh"], notes: { en: "Mainland relay", zh: "国内中转" } }),partner("taken", "Taken", { added: true }),];@@ -111,6 +117,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",await sheet.locator(".tile", { hasText: "Acme AI" }).click();await page.locator("#modal .editor .ehead .note").waitFor();assert.equal(await page.locator("#modal .editor .ehead .note").textContent(), w.note);+ // and its site by the partner's own host, not usemagpie.ai's,+ // following the region picked+ const site = page.locator("#modal .editor .ehead .link.site");+ assert.equal(await site.textContent(), "cn.acme.example ↗");+ await page.locator("#modal .editor .segs.regions .opt").nth(1).click();+ assert.equal(await site.textContent(), "global.acme.example ↗");+ assert.equal(await site.getAttribute("data-url"), "https://usemagpie.ai/go/acme/site/global");assert.deepEqual(errors, []);await page.context().close();});diff --git a/internal/provider/partners_test.go b/internal/provider/partners_test.goindex bd190cdaa..91d9b562d 100644--- a/internal/provider/partners_test.go+++ b/internal/provider/partners_test.go@@ -64,6 +64,7 @@ func TestPartnersFromTheFeed(t *testing.T) {var body atomic.Valuebody.Store(`{"partners":[{"id":"acme","name":"Acme AI","chat":"https://api.acme.example/v1","keysUrl":"https://acme.example/keys?ref=magpie",+ "website":"https://usemagpie.ai/go/acme/site","siteHost":"www.acme.example","iconUrl":"https://acme.example/logo.png","notes":{"en":"Fast relay","zh":"快速中转"},"langs":["zh"],"decide":"https://api.acme.example/decide","noKey":true},{"id":"plain","name":"Plain","chat":"http://api.plain.example/v1"},@@ -72,7 +73,7 @@ func TestPartnersFromTheFeed(t *testing.T) {{"id":"noname","chat":"https://x.example/v1"},{"id":"later","name":"Later","chat":"https://later.example/v1","from":"` + future + `"},{"id":"gone","name":"Gone","chat":"https://gone.example/v1","until":"` + past + `"},- {"id":"regioned","name":"Regioned","regions":[{"id":"cn","name":"China","chat":"https://cn.regioned.example/v1"}]},+ {"id":"regioned","name":"Regioned","regions":[{"id":"cn","name":"China","chat":"https://cn.regioned.example/v1","website":"https://usemagpie.ai/go/regioned/site/cn","siteHost":"cn.regioned.example"}]},{"id":"acme","name":"Acme twice","chat":"https://twice.example/v1"}]}`)t.Setenv("MAGPIE_PARTNERS", partnerFeedServer(t, &body).URL)@@ -95,6 +96,10 @@ func TestPartnersFromTheFeed(t *testing.T) {if got[1].Chat != "https://cn.regioned.example/v1" {t.Errorf("a partner with regions only is at %q, not its first region", got[1].Chat)}+ // the host a /go website sends the browser to, which the editor's link reads+ if a.SiteHost != "www.acme.example" || got[1].Regions[0].SiteHost != "cn.regioned.example" {+ t.Errorf("siteHost = %q, region's %q", a.SiteHost, got[1].Regions[0].SiteHost)+ }// a provider is added from it as from a presetp, err := FromPreset("acme")@@ -117,7 +122,7 @@ func TestPartnersFromTheFeed(t *testing.T) {t.Fatalf("partners after the list emptied = %s", partnerIDs(got))}resetPartners()- if pr := Preset("acme"); pr == nil || pr.Sponsored || pr.Chat != "https://api.acme.example/v1" {+ if pr := Preset("acme"); pr == nil || pr.Sponsored || pr.Chat != "https://api.acme.example/v1" || pr.SiteHost != "www.acme.example" {t.Fatalf("Preset(acme) after it left = %+v", pr)}diff --git a/internal/provider/presets.go b/internal/provider/presets.goindex 79e7609cf..31939fe11 100644--- a/internal/provider/presets.go+++ b/internal/provider/presets.go@@ -31,6 +31,7 @@ type PresetDef struct {Decide string `json:"decide,omitempty"` // a decision API: the provider only routes (see decide.go)Catalog string `json:"catalog,omitempty"`Website string `json:"website,omitempty"`+ SiteHost string `json:"siteHost,omitempty"` // a partner's: the host its usemagpie.ai/go Website sends the browser to, which the editor's link readsKeysURL string `json:"keysUrl,omitempty"`NoKey bool `json:"noKey,omitempty"` // local servers: a key is optionalKeyHint string `json:"keyHint,omitempty"` // the key field's placeholder, when it says more than NoKey's@@ -80,7 +81,8 @@ type Region struct {KeysURL string `json:"keysUrl,omitempty"`// Website, when the region's docs are another page than the preset's,// is where the editor's link goes.- Website string `json:"website,omitempty"`+ Website string `json:"website,omitempty"`+ SiteHost string `json:"siteHost,omitempty"` // as PresetDef's// Catalog, for a region whose models another models.dev entry names// than the preset's (Tencent Cloud's pay as you go, beside its plan's// none), is that entry's id.diff --git a/site/worker.js b/site/worker.jsindex e49404dcb..cafbb2896 100644--- a/site/worker.js+++ b/site/worker.js@@ -166,10 +166,13 @@ function live(p, now) {// served is the list the app gets: those whose term hasn't ended (an// ended one stays in partners.js, so the /go links of providers added from-// it keep working), with their website and key page as /go links.+// it keep working), with their website and key page as /go links. A+// website's own host goes beside it as siteHost, for the editor's link to+// read (www.kimi.com, not usemagpie.ai).export function served(list, now) {const go = (p, what, r) => GO + [p.id, what, r && r.id].filter(Boolean).map(encodeURIComponent).join("/");- const linked = (o, p, r) => ({ ...o, ...(o.website && { website: go(p, "site", r) }), ...(o.keysUrl && { keysUrl: go(p, "keys", r) }) });+ const host = (u) => { try { return new URL(u).host; } catch { return ""; } };+ const linked = (o, p, r) => ({ ...o, ...(o.website && { website: go(p, "site", r), siteHost: host(o.website) }), ...(o.keysUrl && { keysUrl: go(p, "keys", r) }) });return list.filter((p) => !p.until || now < Date.parse(p.until)).map((p) => ({ ...linked(p, p), ...(p.regions && { regions: p.regions.map((r) => linked(r, p, r)) }) }));diff --git a/site/worker.test.mjs b/site/worker.test.mjsindex 99f1e4bbe..4c882727c 100644--- a/site/worker.test.mjs+++ b/site/worker.test.mjs@@ -322,6 +322,10 @@ test("partners: links go through /go", () => {assert.equal(acme.chat, LIST[0].chat);assert.equal(acme.regions[0].keysUrl, "https://usemagpie.ai/go/acme/keys/cn");assert.equal(acme.regions[0].website, undefined);+ // the editor names a /go website by the host it sends the browser to+ assert.equal(acme.siteHost, "acme.example");+ assert.equal(acme.regions[0].siteHost, undefined);+ assert.equal(plain.siteHost, undefined);assert.equal(acme.regions[1].keysUrl, undefined);assert.deepEqual(plain, LIST[1]);// partners.js itself is left as it is