routing: the mode chip leads to where the routing is set, and a lone key names none

xczzhh on X: "这个路由策略能自己选吗,我的一直是smart,也改不了好像". The
Routing page's hub chip and the Accounts and keys heading said Smart for
every provider, even one with a single key on, where there is nothing to
route, and nothing on the page said where it changes.

Now, where routing can be changed (a group, or a provider listed in
/api/groups' pools: two or more accounts or keys on), the chip and the
heading are .rt-go controls (goTo/goRouting): a click or Enter brings the
group's card or the provider's row under Several accounts or keys into
view via scrollOnPurpose, marks it (rt-found, off under reduced motion)
and focuses its routing picker. A provider with one on names no routing,
and the mode paragraph says to turn on a second in the provider's editor
(LONE, in zh, zh-TW, ja and de). The header is drawn again when the
groups arrive (headOf).

routing-weight-chip's fixture now lists its two-key relay in pools, as
/api/groups does.

Run: routing-mode-goes.test.cjs 40/40 (chromium+webkit, en/zh/zh-TW/ja/de,
1100px and 420px); all 20 chromium cases fail on the old routing.js. All
routing-*, quota-pool*, rate-limited-sink, panel-routing, click-scroll,
view-scrollbar-drag and i18n-keys tests pass (group-fold, keys-fold,
flood and context-fold failed only under a 6-way parallel full run and
pass alone, as on main). go test -tags nogui ./internal/gui ok.
This commit is contained in:
yetone
2026-10-10 19:49:14 +08:00
parent e70e7ed46a
commit 3d7acfb40f
7 changed files with 247 additions and 7 deletions
+13
View File
@@ -47,6 +47,19 @@ filter only when that request is excluded. Usage's purpose picker remains a
single choice sent to the ledger API. See `purpose-filter.test.cjs` and
`routing-purpose-state.test.cjs`.
### Routing mode chip
The stage's chip and the Accounts and keys heading in
[`routing.js`](../../internal/gui/assets/routing.js) name how a route
routes only where that can be changed: a group, or a provider in
`/api/groups`' `pools` (two or more accounts or keys on). There they are
`.rt-go` controls (`goTo`, `goRouting`) that bring the group's card or the
provider's row under Several accounts or keys into view through
`scrollOnPurpose`, mark it (`rt-found`) and focus its routing. A provider
with one on names no routing, and the mode paragraph says how to get one
(`LONE`). The header is drawn again when the groups come in (`headOf`).
See `routing-mode-goes.test.cjs`.
### Routing key and account folds
Three or more API keys, or three or more accounts, of one provider standing
+8
View File
@@ -3034,6 +3034,8 @@ const I18N = {
"{who} answered this conversation last, but a new turn begins and the group's rule {n} puts {use} first.": "{who} 上次回答了此会话,但新一轮命中分组规则 {n},{use} 排第一。",
"Several accounts or keys": "多账号 / 多 Key",
"each provider routes over its own": "各供应商在自己的账号或 Key 间路由",
"Change how {name} routes": "改 {name} 的路由方式",
"Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "这里只开了一个账号或 Key,路由没有可选的。在供应商的编辑页再开一个,路由方式就在下面的「多账号 / 多 Key」里设置。",
"{n} accounts": "{n} 个账号",
"Show 1 more account": "展开其余 1 个账号",
"Show {n} more accounts": "展开其余 {n} 个账号",
@@ -7052,6 +7054,8 @@ const I18N = {
"{who} answered this conversation last, but a new turn begins and the group's rule {n} puts {use} first.": "{who} 上次回答了此會話,但新一輪命中分組規則 {n},{use} 排第一。",
"Several accounts or keys": "多帳號 / 多 Key",
"each provider routes over its own": "各供應商在自己的帳號或 Key 間路由",
"Change how {name} routes": "改 {name} 的路由方式",
"Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "這裡只開了一個帳號或 Key,路由沒有可選的。在供應商的編輯頁再開一個,路由方式就在下面的「多帳號 / 多 Key」裡設定。",
"{n} accounts": "{n} 個帳號",
"Show 1 more account": "展開其餘 1 個帳號",
"Show {n} more accounts": "展開其餘 {n} 個帳號",
@@ -11087,6 +11091,8 @@ const I18N = {
"{who} answered this conversation last, but a new turn begins and the group's rule {n} puts {use} first.": "この会話に前回応答したのは {who} ですが、新しいターンが始まり、グループのルール {n} が {use} を先頭にします。",
"Several accounts or keys": "複数のアカウントやキー",
"each provider routes over its own": "各プロバイダが自身のアカウントやキーでルーティング",
"Change how {name} routes": "{name} のルーティングを変更",
"Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "有効なアカウントやキーが 1 つだけなので、ルーティングに選択肢はありません。プロバイダの編集画面で 2 つ目を有効にすると、ルーティングは下の「複数のアカウントやキー」で設定できます。",
"{n} accounts": "{n} 個のアカウント",
"Show 1 more account": "さらに 1 個のアカウントを表示",
"Show {n} more accounts": "さらに {n} 個のアカウントを表示",
@@ -15119,6 +15125,8 @@ const I18N = {
"{who} answered this conversation last, but a new turn begins and the group's rule {n} puts {use} first.": "{who} hat zuletzt in dieser Unterhaltung geantwortet, aber eine neue Runde beginnt und Regel {n} der Gruppe setzt {use} an die Spitze.",
"Several accounts or keys": "Mehrere Konten oder Schlüssel",
"each provider routes over its own": "jeder Anbieter leitet über seine eigenen weiter",
"Change how {name} routes": "Ändern, wie {name} weiterleitet",
"Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.": "Hier ist nur ein Konto oder Schlüssel aktiv, also hat die Weiterleitung keine Wahl. Aktiviere im Editor des Anbieters ein zweites; wie weitergeleitet wird, legst du dann unten unter „Mehrere Konten oder Schlüssel“ fest.",
"{n} accounts": "{n} Konten",
"Show 1 more account": "1 weiteres Konto anzeigen",
"Show {n} more accounts": "{n} weitere Konten anzeigen",
+9
View File
@@ -294,6 +294,15 @@ button.rt-session { cursor: pointer; }
.rt-prov .ic, .rt-prov .ic img, .rt-prov .ic svg { width: 14px; height: 14px; }
.rt-prov > span:last-child { margin-left: auto; font-size: 10.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.rt-prov:not(:first-child) { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }
/* a routing named where it can be changed: a way to where it is set */
.rt-go { cursor: pointer; }
.rt-go::after { content: " ›"; }
.rt-prov > span.rt-go:hover, .rt-prov > span.rt-go:focus-visible { color: var(--fg); border-color: var(--fg); }
.rt-hub i.rt-go:hover, .rt-hub i.rt-go:focus-visible { box-shadow: 0 0 0 3px var(--card-2), 0 0 0 4px var(--fg); }
.rt-go:focus-visible { outline: none; }
.rt-found { animation: rtfound 1.4s ease-out; }
@keyframes rtfound { 0%, 40% { box-shadow: inset 0 0 0 2px var(--fg); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
@media (prefers-reduced-motion: reduce) { .rt-found { animation: none; } }
.rt-act { display: grid; gap: 3px; padding: 6px 12px 6px 33px; font-size: 12px; }
.rt-act .nm { display: flex; gap: 6px; min-width: 0; }
.rt-act .nm b { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+61 -6
View File
@@ -368,6 +368,7 @@
};
const GROUP_ORDER = "In order: member by member, the first model the group names until it can't answer, each over its own accounts or keys as its provider routes them.";
const KEYS_SMART = "Smart: keys that suit the request go first — one made for the model's own API — then in their order. One resting after a failure goes last.";
const LONE = "Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.";
const agentOf = (id) => (state.clients || state.agents).find((a) => a.id === id);
const agentName = (id) => agentOf(id)?.name || (id && id !== "other" ? id : t("your agent"));
@@ -1362,21 +1363,61 @@
// header tells of the route the log tells of: its provider or group,
// and how it routes
// It names how the route routes where that can be changed, and takes
// the reader to where it is (xczzhh on X: it said Smart, and nothing
// changed it); a provider with only one account or key on has nothing
// to route, and says so instead.
let headOf = null; // what the head tells of, told again once the pools are in
function header(r, many) {
headOf = [r, many];
const f = r.order.find((x) => !x.fallback) || r.order[0];
const g = r.group;
const routing = g ? g.routing || "" : f?.routing || "";
const m = MODES[routing] || MODES[""];
chip.textContent = t(m[0]);
chip.hidden = false;
hubText();
const on = r.order.filter((x) => !x.fallback).length;
const pool = !g && f ? poolOf(f.provider) : null;
const lone = !g && on <= 1 && !pool;
chip.textContent = t(m[0]);
chip.hidden = lone;
goTo(chip, g ? "group:" + g.id : pool ? "pool:" + f.provider : "", g ? g.name : f?.name || r.provider);
hubText();
what.replaceChildren(el("b", "", g ? g.name : f?.name || r.provider),
el("span", "", (g ? " · " + t("routing group") : "") + " · " + t(on === 1 ? "one on" : "{n} on", { n: on })
+ (many > 1 ? " · " + t("{n} agents at once", { n: many }) : "")));
// keys that read their own windows are weighed as accounts are
mode.textContent = g && routing === "order" ? t(GROUP_ORDER) : t(!routing && f?.kind === "key" && !r.order.some((x) => x.known) && !g ? KEYS_SMART : m[1]);
mode.textContent = lone ? t(LONE) : g && routing === "order" ? t(GROUP_ORDER) : t(!routing && f?.kind === "key" && !r.order.some((x) => x.known) && !g ? KEYS_SMART : m[1]);
}
// goTo makes what names a routing a way to where it is set: a provider's
// own under Several accounts or keys, a group's its card
function goTo(e, go, name) {
e.dataset.go = go;
e.classList.toggle("rt-go", !!go);
if (go) {
e.tabIndex = 0;
e.setAttribute("role", "button");
e.title = t("Change how {name} routes", { name });
} else for (const a of ["data-go", "tabindex", "role", "title"]) e.removeAttribute(a);
}
function goRouting(e, go) {
const i = go.indexOf(":"), kind = go.slice(0, i), id = CSS.escape(go.slice(i + 1));
const row = kind === "group" ? gList.querySelector(`.rt-group[data-id="${id}"]`) : pList.querySelector(`.rt-pool[data-provider="${id}"]`);
if (!row) return;
if (window.scrollOnPurpose?.(e)) row.scrollIntoView({ block: "center", behavior: still() ? "auto" : "smooth" });
row.classList.remove("rt-found");
void row.offsetWidth;
row.classList.add("rt-found");
row.querySelector(".segs .opt.on")?.focus({ preventScroll: true });
}
$("#view-routing").addEventListener("click", (e) => {
const g = e.target.closest(".rt-go[data-go]");
if (g) goRouting(e, g.dataset.go);
});
$("#view-routing").addEventListener("keydown", (e) => {
const g = (e.key === "Enter" || e.key === " ") && e.target.closest?.(".rt-go[data-go]");
if (!g) return;
e.preventDefault();
goRouting(e, g.dataset.go);
});
// what a row says now: resting, answering, or what routing weighed it by
function render() {
@@ -2240,8 +2281,14 @@
prov = w.provider;
const h = el("div", "rt-prov");
h.append(icon(w.icon || w.preset || "generic"), el("b", "", w.name || w.provider));
const m = MODES[list.find((x) => x.w.provider === prov && !x.w.fallback)?.w.routing || ""] || MODES[""];
h.append(el("span", "", t(w.kind === "key" && !w.routing ? "Smart" : m[0])));
// how it routes, only where it routes over several, and a way to
// where that is set
if (poolOf(prov)) {
const m = MODES[list.find((x) => x.w.provider === prov && !x.w.fallback)?.w.routing || ""] || MODES[""];
const s = el("span", "", t(w.kind === "key" && !w.routing ? "Smart" : m[0]));
goTo(s, "pool:" + prov, w.name || w.provider);
h.append(s);
}
out.push(h);
}
// a provider's keys, FOLD_AT or more, under one row that sums them
@@ -2823,6 +2870,7 @@
for (const f of folds.values()) f.wire.remove();
folds.clear();
chip.hidden = true;
headOf = null;
hubText();
list.replaceChildren(el("li", "idle", t(purpose.length || day ? "No requests match these filters." : "No request yet")));
say(t("Every request an agent sends to magpie shows up here, routed for real."));
@@ -2995,12 +3043,18 @@
}
const slug = (s) => String(s || "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
let groups = null, gEdit = null; // gEdit: { id: "" for a new one, draft }
// poolOf is the provider's own routing over several accounts or keys,
// none while it has one on (or before the groups are in)
function poolOf(id) {
try { return groups?.pools?.find((p) => p.provider === id) || null; } catch { return null; }
}
// quiet: the window focused again; the same groups aren't drawn again
async function loadGroups(quiet) {
let next;
try { next = await api("groups"); } catch { return; }
if (quiet === true && groups && JSON.stringify(next) === JSON.stringify(groups)) return;
groups = next;
if (headOf) header(...headOf);
if (!gEdit && !gsec.contains(document.activeElement)) renderGroups(); // not under someone's hands
}
const groupDirty = () => !!gEdit && gEdit.was !== undefined &&
@@ -4296,6 +4350,7 @@
pHead.replaceChildren(el("span", "label", t("Several accounts or keys")), el("span", "grow"), el("span", "note", t("each provider routes over its own")));
pList.replaceChildren(...ps.map((p) => {
const row = el("div", "rt-pool");
row.dataset.provider = p.provider;
const nm = el("div", "nm");
nm.append(icon(p.icon || "generic"), el("b", "", p.name), el("span", "", p.protocol
? t("{n} keys for {api}", { n: p.who.length, api: API[p.protocol] || p.protocol })
+8
View File
@@ -547,6 +547,14 @@ each language), with the story telling whose share went first, while keys
under Smart keep Smart's chip and the keys' own mode line. It runs in
English, Chinese, Japanese and German on Chromium and WebKit.
`routing-mode-goes.test.cjs` checks where the stage's routing chip leads
(xczzhh on X: it always said Smart and nothing changed it). With one key
on, the chip and the Accounts and keys heading name no routing and the mode
paragraph says how to get one. With a provider over two keys, the chip and
the heading are a way to its row under Several accounts or keys: a click
or Enter brings it into view, marks it and focuses its routing. It runs in
every language on Chromium and WebKit, at 1100px and 420px.
`balance-fix.test.cjs` opens a custom provider whose balance token sits
beside new-api's `/api/usage/token` (and a new one with a token and no
Balance URL): the editor says so, one click moves it to `/api/user/self`
@@ -0,0 +1,145 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// The Routing page's chip said Smart for every request, and nothing on it
// changed that (xczzhh on X: "我的一直是smart,也改不了"). A provider with
// only one account or key on has nothing to route: its chip and the
// Accounts and keys heading say no routing, and the mode paragraph says
// how to get one. Where a provider routes over several, the chip and the
// heading are a way to its routing under Several accounts or keys: a
// click, or Enter, brings that row into view, marks it and focuses its
// routing — the page moves only because the reader asked. In every
// language, both engines, wide and narrow.
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(__dirname, "../assets");
const now = new Date();
const ago = (minutes) => new Date(now.getTime() - minutes * 60e3).toISOString();
const key = (provider, who) => ({ id: provider + "#" + who, provider, name: provider === "relay" ? "Relay" : "Solo", who, kind: "key", model: "gpt-6-astra", routing: "" });
const scenes = {
lone: { order: [key("solo", "solo-a")], pools: [] },
pooled: {
order: [key("relay", "relay-a"), key("relay", "relay-b")],
pools: [{ provider: "relay", name: "Relay", icon: "generic", kind: "key", who: ["relay-a", "relay-b"], routing: "", affinity: "" }],
},
};
// filler groups above the pools, so that the way to them is a long one
const filler = Array.from({ length: 14 }, (_, i) => ({ id: "g" + i, name: "Filler " + i, routing: "", members: ["relay/gpt-6-astra"],
ready: true, memberInfo: [{ id: "relay/gpt-6-astra", ready: true }], offers: [], shared: [] }));
function serve(lang, scene) {
const s = scenes[scene];
const route = {
id: 1, seq: 1, time: ago(1), agent: "codex", model: "gpt-6-astra", provider: s.order[0].provider, done: true, status: 200, ms: 900, tokens: 1200,
order: s.order, tries: [{ id: s.order[0].id, model: "gpt-6-astra", start: ago(1), done: true, status: 200, ms: 900 }],
};
return async (request) => {
const url = new URL(request.request().url());
const json = (data) => request.fulfill({ json: data });
if (url.pathname === "/boot.js") return request.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
if (url.pathname === "/wails/runtime.js") return request.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [{ id: "codex", name: "Codex", path: "/test/config.toml", fields: [] }], profiles: [], settings: { lang, theme: "light" } });
if (url.pathname === "/api/gateway/trace") {
if (url.searchParams.get("wait")) return new Promise(() => {}); // nothing more comes
return json({ mine: true, now: now.toISOString(), seq: 1, totals: { requests: 1 }, routes: [route] });
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
if (url.pathname === "/api/groups") return json({ models: [{ id: "relay/gpt-6-astra", name: "gpt-6-astra", providerName: "Relay", icon: "generic" }], groups: filler, pools: s.pools });
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
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 request.fulfill({ body: await fs.readFile(file), contentType });
};
}
// the words, as each language says them
const lone = {
en: "Only one account or key is on for this, so routing has nothing to choose between. Turn on a second in the provider's editor, and how it routes is set under Several accounts or keys below.",
zh: "这里只开了一个账号或 Key,路由没有可选的。在供应商的编辑页再开一个,路由方式就在下面的「多账号 / 多 Key」里设置。",
"zh-TW": "這裡只開了一個帳號或 Key,路由沒有可選的。在供應商的編輯頁再開一個,路由方式就在下面的「多帳號 / 多 Key」裡設定。",
ja: "有効なアカウントやキーが 1 つだけなので、ルーティングに選択肢はありません。プロバイダの編集画面で 2 つ目を有効にすると、ルーティングは下の「複数のアカウントやキー」で設定できます。",
de: "Hier ist nur ein Konto oder Schlüssel aktiv, also hat die Weiterleitung keine Wahl. Aktiviere im Editor des Anbieters ein zweites; wie weitergeleitet wird, legst du dann unten unter „Mehrere Konten oder Schlüssel“ fest.",
};
const change = { en: "Change how Relay routes", zh: "改 Relay 的路由方式", "zh-TW": "改 Relay 的路由方式", ja: "Relay のルーティングを変更", de: "Ändern, wie Relay weiterleitet" };
const smart = { en: "Smart", zh: "智能", "zh-TW": "智慧", ja: "スマート", de: "Intelligent" };
async function open(engine, lang, scene, width, t) {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await browser.newPage({ viewport: { width, height: 700 }, reducedMotion: "reduce" });
page.setDefaultTimeout(5000);
const errors = [];
page.on("pageerror", (error) => errors.push(error.message));
await page.route("**/*", serve(lang, scene));
await page.goto("http://magpie.test/?view=routing");
const req = page.locator(".rt-req").first();
await req.waitFor();
if (await req.getAttribute("aria-pressed") !== "true") await req.click();
return { page, errors };
}
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
for (const width of [1100, 420]) {
test(`${engine} ${lang} ${width}px: one key on has no routing to name, and says how to get one`, async (t) => {
const { page, errors } = await open(engine, lang, "lone", width, t);
await page.waitForFunction((s) => document.querySelector(".rt-mode")?.textContent.trim() === s, lone[lang]);
// the groups are in, and the chip still names no routing
await page.locator(".rt-group").first().waitFor();
await page.waitForTimeout(150);
assert.equal(await page.locator(".rt-hub i").isHidden(), true, "the chip names no routing");
assert.equal((await page.locator(".rt-mode").textContent()).trim(), lone[lang]);
await page.locator(".rt-prov").first().waitFor();
assert.equal((await page.locator(".rt-prov").first().innerText()).trim(), "Solo", "the heading names no routing");
assert.equal(await page.locator(".rt-go").count(), 0);
assert.deepEqual(errors, []);
});
test(`${engine} ${lang} ${width}px: a provider routing over several keys is a way to where it is set`, async (t) => {
const { page, errors } = await open(engine, lang, "pooled", width, t);
const chip = page.locator(".rt-hub i.rt-go");
await chip.waitFor();
assert.equal((await chip.textContent()).trim(), smart[lang]);
assert.equal(await chip.getAttribute("title"), change[lang]);
assert.equal(await chip.getAttribute("role"), "button");
assert.notEqual((await page.locator(".rt-mode").textContent()).trim(), lone[lang]);
// the heading names it too, the same way to it
const head = page.locator(".rt-prov > span.rt-go");
await head.waitFor();
assert.equal((await head.textContent()).trim(), smart[lang]);
assert.equal(await head.getAttribute("data-go"), "pool:relay");
const view = page.locator("#view-routing");
const pool = page.locator('.rt-pool[data-provider="relay"]');
await pool.waitFor({ state: "attached" });
const inView = () => pool.evaluate((p) => { const v = document.querySelector("#view-routing").getBoundingClientRect(), r = p.getBoundingClientRect();
return r.top >= v.top && r.bottom <= v.bottom; });
assert.equal(await inView(), false, "the pool starts out of view");
const top = await view.evaluate((v) => v.scrollTop);
// a click takes the reader there: in view, marked, its routing focused
await chip.click();
await page.waitForFunction(() => document.querySelector('.rt-pool[data-provider="relay"]')?.classList.contains("rt-found"));
assert.ok(await view.evaluate((v) => v.scrollTop) > top, "the view went down to it");
assert.equal(await inView(), true);
assert.equal(await page.evaluate(() => document.activeElement?.closest(".rt-pool")?.dataset.provider), "relay");
assert.equal(await page.evaluate(() => document.activeElement?.classList.contains("on")), true);
assert.equal((await page.evaluate(() => document.activeElement.textContent)).trim(), smart[lang]);
// the keyboard does the same from the top
await view.evaluate((v) => { v.scrollTop = 0; });
await chip.focus();
await page.keyboard.press("Enter");
await page.waitForFunction(() => document.querySelector("#view-routing").scrollTop > 0);
assert.equal(await inView(), true);
// nothing is drawn wider than the window
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true);
assert.deepEqual(errors, []);
});
}
}
}
@@ -39,7 +39,9 @@ function serve(lang, scene) {
return json({ mine: true, now: now.toISOString(), seq: 1, totals: { requests: 1 }, routes: [route] });
}
if (url.pathname === "/api/gateway/history") return json({ cut: false, days: [], routes: [] });
if (url.pathname === "/api/groups") return json({ groups: [] });
// the relay routes over its two keys, as /api/groups lists it
if (url.pathname === "/api/groups") return json({ groups: [], pools: [{ provider: "relay", name: "Relay", icon: "generic", kind: "key",
who: ["relay-a", "relay-b"], routing: scene === "weight" ? "weight" : "", affinity: "" }] });
if (url.pathname === "/api/providers") return json({ providers: [], presets: [], excluded: [], gateway: { running: true, window: true } });
if (url.pathname.startsWith("/api/")) return json({});
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);