Files
yetone 04e188aaec qoder 0.2.13: an account lists the models Qoder's app shows, Fast (0.8×) among them, and keeps Performance (#97)
Qoder's model listing (/algo/api/v2/model/list) has a list per scene. The
plugin read only "chat", while its requests are sent as Qoder's app
(product and session_type "app"). On 2026-10-12 the app scene lists Fast
(key fast, 0.8×) where chat still lists Performance (1.1×), so magpie
showed Performance and never Fast, which Qoder's app shows (yygutn, #97).

The models hook now lists the app scene in its order and adds each model
only chat still lists after the model it follows there, so a pick of
Performance stays served. Each key once; the app's entry wins. A listing
with one scene gives that one. New app models show from the account's
own listing without a plugin release. The fallback list gains Fast.

Verified:
- The real listing read through the plugin on the owner's Qoder account
  (sandbox HOME, credential copied in memory, nothing written, no token
  renewed): fast "Fast" rate 0.8 and performance rate 1.1 both listed.
- models.test.mjs runs on that real listing (testdata/listing.json, the
  chat and app scenes); all 4 tests fail with modelInfos put back to
  listing.chat, and pass with the change.
- bun test (sandbox HOME/TMPDIR): 1133 pass, 0 fail. bun scripts/check.mjs ok.

Not verified: a real chat on fast. Every model on that account (fast,
performance, efficient, qfmodel) was refused with 403 code 10605
(serviceAvailable false, queueType p3, retryAfterSeconds 30) though the
trial has 143/300 credits; the plugin reports that as a lapsed sign-in,
filed separately. Qoder CN's listing wasn't read (no CN account).
2026-10-12 21:04:10 +08:00

52 lines
2.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The models an account lists are the "app" scene's, which Qoder's app
// shows and a request names, with any model only "chat" still lists kept
// (magpie-community/plugins#97). testdata/listing.json is a real account's
// /algo/api/v2/model/list on 2026-10-12 (its chat and app scenes): the app
// lists Fast at 0.8× where chat lists Performance at 1.1×.
import { afterEach, expect, test } from "bun:test"
import { readFileSync } from "node:fs"
import { QoderAuthPlugin } from "./index.mjs"
const LISTING = JSON.parse(readFileSync(new URL("./testdata/listing.json", import.meta.url), "utf8"))
const real = globalThis.fetch
afterEach(() => (globalThis.fetch = real))
const account = () => ({ type: "oauth", access: "jt", refresh: "rt", expires: Date.now() + 3_600_000, accountId: "a@x", uid: "u1", machineId: "m1" })
async function listed(listing) {
globalThis.fetch = async (url) => {
if (new URL(String(url)).pathname === "/algo/api/v2/model/list") return new Response(JSON.stringify(listing))
return new Response("", { status: 404 })
}
const hooks = await QoderAuthPlugin({ client: { auth: { set: async () => {} } } })
return hooks.provider.models({ models: { fallback: {} } }, { auth: account() })
}
test("the app's Fast is listed at its price, and chat's Performance stays", async () => {
const ms = await listed(LISTING)
expect(ms.fast).toMatchObject({ name: "Fast", rate: 0.8 })
expect(ms.performance).toMatchObject({ name: "Performance", rate: 1.1 })
expect(Object.keys(ms)).toEqual([
"ultimate", "performance", "fast", "efficient", "smodel", "cmodel", "qmodel_38max", "qfmodel", "qmodel_latest", "qmodel",
"gmodel", "gfmodel", "kmodel_latest", "kmodel", "dmodel", "dfmodel", "mmodel",
])
})
test("a model both scenes list is listed once, as the app gives it", async () => {
const chat = LISTING.chat.map((m) => (m.key === "ultimate" ? { ...m, display_name: "Ultimate (chat)" } : m))
const ms = await listed({ chat, app: LISTING.app })
expect(ms.ultimate.name).toBe("Ultimate")
})
test("a listing with only one scene lists that scene", async () => {
expect(Object.keys(await listed({ chat: LISTING.chat }))).toContain("performance")
expect(Object.keys(await listed({ chat: LISTING.chat }))).not.toContain("fast")
expect(Object.keys(await listed({ app: LISTING.app }))).toContain("fast")
expect(Object.keys(await listed({ app: LISTING.app }))).not.toContain("performance")
})
test("a model the app turns off isn't listed though chat has it on", async () => {
const app = LISTING.app.map((m) => (m.key === "efficient" ? { ...m, enable: false } : m))
expect(Object.keys(await listed({ chat: LISTING.chat, app }))).not.toContain("efficient")
})