Kautism on Discord: a gateway key held to a few routing groups couldn't use Clef or Jev, and they showed nowhere for it. A decision model is a model: /v1/systemone and the decision list another magpie asks for (DecidersHeader) hold a key to it as to any model, which stays so (the restriction covers both routes). But GET /api/caller-keys/models listed only provider.Catalog, which has no decision models, so the only way to let a held key ask one was All models. - caller_keys.go: the picker's list now has OfferedDeciders, each after its provider's chat models, marked decides. - keys.js: such a model's note says it is a decision model that a routing group asks whatever the key may use, and that picking it lets the key ask it itself; en, zh, zh-TW, ja, de. - A group the key names still asks its own Jev for every turn with no key check (askJev); TestGatewayKeyHeldToAGroupKeepsItsDecider holds that, and that the key is refused Jev at /v1/systemone and not listed it until it names it, then allowed and listed. - docs/reference.md and gateway-routing.md say so. Run on mote at the pre-rebase head; at the pushed head (rebased on066ece93b, which touches no gui, gateway or access file) TestCallerKey* and TestGatewayKey* in internal/gui and internal/gateway ran again: ok. - go test ./internal/gui/: ok except TestMainWindowCorners/macOS_26_SDK, the AppKit test red on macOS 27 (#3949), unrelated. - go test -run 'Key|Decide|Jev|SystemOne|Decider' ./internal/gateway/: ok. - go vet darwin, GOOS=linux -tags nogui, GOOS=windows for internal/gui and internal/gateway: ok. gofmt -l clean. - GUI: gateway-key-*.test.cjs and i18n*.test.cjs, chromium and webkit: 136 of 138 ok; the 2 reds are gateway-key-models "en ... wider than 560" (#4081), red 2 of 3 webkit runs on untouched origin/maind24be3c25too. The new gateway-key-deciders.test.cjs: chromium and webkit, 1000px and 400px, all five languages, ok. Broken by hand: OfferedDeciders(nil)[:0] in the handler, and TestCallerKeyModelsOfferDeciders went red ("ts/jev-latest not offered"); the key check in serveSystemOne turned off, and TestGatewayKeyHeldToAGroupKeepsItsDecider went red (200 for Jev). Not tried: a real Cloudflare Clef or TypeSafe Jev account, another magpie connected with a held key in a real app, and the whole GUI suite (mote was at load ~150 with other sessions' suites).
60 lines
3.8 KiB
JavaScript
60 lines
3.8 KiB
JavaScript
// Run with Node's test runner and Playwright on the module path; see README.md.
|
|
// A gateway key held to routing groups can be let ask a decision model
|
|
// too (Kautism on Discord: a key held to two groups, and Clef and Jev
|
|
// listed nowhere): the key's models menu lists them, each saying it is a
|
|
// decision model a routing group asks whatever the key may use, and a
|
|
// pick is sent beside the groups.
|
|
const assert = require("node:assert/strict");
|
|
const { test } = require("node:test");
|
|
const { chromium, webkit } = require("playwright");
|
|
const { fixture } = require("./fixtures/caller-keys.cjs");
|
|
|
|
const notes = {
|
|
en: "Decision model: a routing group asks it whatever this key may use; pick it so the key may ask it itself",
|
|
zh: "决策模型:路由组照常会问它,与此密钥能用哪些模型无关;勾选后此密钥也能直接问它",
|
|
"zh-TW": "決策模型:路由組照常會問它,與此金鑰能用哪些模型無關;勾選後此金鑰也能直接問它",
|
|
ja: "決定モデル:このキーで使えるモデルに関係なく、ルーティンググループは問い合わせます。選ぶとこのキーから直接問い合わせられます",
|
|
de: "Entscheidungsmodell: Routing-Gruppen fragen es, egal was dieser Schlüssel nutzen darf; wähle es, damit der Schlüssel es selbst fragen darf",
|
|
};
|
|
|
|
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
|
for (const width of [1000, 400]) {
|
|
for (const lang of Object.keys(notes)) {
|
|
test(`${engine} ${width}px ${lang}: a key held to groups is let ask Clef`, async (t) => {
|
|
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
|
t.after(() => browser.close());
|
|
const page = await (await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce" })).newPage();
|
|
page.setDefaultTimeout(6000);
|
|
page.setDefaultNavigationTimeout(60000);
|
|
const events = [], errors = [];
|
|
page.on("pageerror", (e) => errors.push(e.message));
|
|
await page.route("**/*", fixture(lang, "light", events, { lan: true, groups: true, deciders: true, limits: { server: { models: ["group/fast", "group/coding"] } } }));
|
|
await page.goto("http://magpie.test/?view=gateway");
|
|
const badge = page.locator('#gatewayKeys .acc[data-key="server"] .key-models');
|
|
await badge.waitFor();
|
|
await badge.click();
|
|
const menu = page.locator(".proto-menu");
|
|
await menu.waitFor();
|
|
const clef = menu.locator(".pm-item", { hasText: "Clef" });
|
|
const jev = menu.locator(".pm-item", { hasText: "Jev" });
|
|
for (const [item, id] of [[clef, "cf/@cf/cloudflare/clef"], [jev, "ts/jev-latest"]]) {
|
|
const note = (await item.locator(".pm-note").textContent()).trim();
|
|
assert.equal(note, id + " · " + notes[lang]);
|
|
}
|
|
// a chat model says its id alone
|
|
assert.equal((await menu.locator(".pm-item", { hasText: "GPT-5" }).locator(".pm-note").textContent()).trim(), "openai/gpt-5");
|
|
// the note fits the menu: wrapped, not cut off past its edge
|
|
const m = await menu.boundingBox(), n = await clef.locator(".pm-note").boundingBox();
|
|
assert(n.x >= m.x - 1 && n.x + n.width <= m.x + m.width + 1, `the note runs past the menu: ${JSON.stringify({ m, n })}`);
|
|
assert(m.x >= 0 && m.x + m.width <= width + 1, `the menu runs off the window: ${JSON.stringify(m)}`);
|
|
await clef.click();
|
|
await page.keyboard.press("Escape");
|
|
await menu.waitFor({ state: "detached" });
|
|
assert.deepEqual(events.filter((e) => e.action === "models-key").map((e) => e.body),
|
|
[{ key: "server", models: ["group/coding", "group/fast", "cf/@cf/cloudflare/clef"] }]);
|
|
assert.deepEqual(errors, []);
|
|
});
|
|
}
|
|
}
|
|
}
|