qoder 0.2.1: a model is free only at a price_factor of 0 — Qwen3.8-Max, 0.5× with an off-peak discount, is no longer marked free
Qoder's listing (as it came on 2026-10-02) carries is_free true on Qwen3.8-Max, whose price_factor is 0.5 and whose promotion is the off-peak 60% off (错峰 4 折, rule idle_time_model_credit_discount, before_promotion_price_factor 0.5); Qoder's own app ignores is_free in the model picker and shows 0.5×. freeOf took is_free true OR a price_factor of 0, so Max came out free. Now the price decides, as Qoder's app shows it: a price_factor (priceFactor) of 0 is free — Qwen3.8-Flash, 0× with original_price_factor 0.1 struck through, stays free — any other price is not, whatever is_free says, and a 0 that lasts only while an active promotion with a price before it runs is a discount, not free. is_free is read only from a listing that gives no price at all. usage.test.mjs's new test feeds the listing's own entries (Max, Flash, Qwen3.7-Max, Kimi-K3) and promotion shapes; it fails against 0.2.0 (Max free). The built-in (internal/qoder/models.go, ModelInfo.free) has the same is_free || price 0 rule and needs the same change on magpie's side.
This commit is contained in:
@@ -291,13 +291,24 @@ const CN_MODELS = [
|
||||
{ id: "lite", name: "Lite" },
|
||||
]
|
||||
|
||||
// freeOf reads whether the listing marks a model free, as Qoder's client
|
||||
// reads it (internal/qoder/models.go): is_free true, or a price_factor (the
|
||||
// credits a request costs, as a multiple) of 0, either in snake or camel case.
|
||||
// freeOf reads whether a model costs the plan no credits: a price_factor
|
||||
// (the credits a request costs, as a multiple; priceFactor in camel case)
|
||||
// of 0, the price Qoder's own client shows ("0×"). is_free is no word on
|
||||
// that: Qoder's listing has it true on Qwen3.8-Max at 0.5×, an off-peak
|
||||
// discount (错峰 4 折) on it, and Qoder's client shows the price, not it.
|
||||
// It is taken only from a listing with no price at all. A price of 0 for
|
||||
// the while an active promotion lasts, with a price before it, is a
|
||||
// discount, not a free model; a limited-time free model (Qwen3.8-Flash:
|
||||
// 0×, its original_price_factor 0.1 struck through) is free while it is.
|
||||
function freeOf(raw) {
|
||||
const is = raw.is_free ?? raw.isFree
|
||||
const price = raw.price_factor ?? raw.priceFactor
|
||||
return is === true || (typeof price === "number" && price === 0)
|
||||
if (typeof price === "number" && Number.isFinite(price)) {
|
||||
if (price !== 0) return false
|
||||
const p = raw.promotion ?? raw.prommotion
|
||||
const before = p?.before_promotion_price_factor ?? p?.beforePromotionPriceFactor
|
||||
return !(p?.active === true && typeof before === "number" && before > 0)
|
||||
}
|
||||
return (raw.is_free ?? raw.isFree) === true
|
||||
}
|
||||
|
||||
// modelInfo reads one entry of the listing's "chat" array: its efforts and
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-qoder-auth",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.1",
|
||||
"description": "Qoder subscriptions in OpenCode and magpie: Qoder (qoder.com) and Qoder CN (qoder.cn)",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
@@ -226,13 +226,62 @@ test("errors don't name Qoder, which magpie adds", async () => {
|
||||
expect((await res.json()).error.message).toBe("not signed in")
|
||||
})
|
||||
|
||||
test("a model Qoder lists free (is_free, or a price_factor of 0) is marked free", async () => {
|
||||
test("a model at a price_factor of 0 is marked free; is_free only counts with no price", async () => {
|
||||
const { hooks, auth } = await chat(LISTING, () => new Response(""))
|
||||
const ms = await hooks.provider.models({ models: {} }, { auth })
|
||||
expect(Object.fromEntries(Object.entries(ms).map(([k, m]) => [k, m.free]))).toEqual({ qmodel: false, fmodel: true, pmodel: true, cmodel: false })
|
||||
expect(_internal.modelInfo({ key: "x", isFree: true }).free).toBe(true)
|
||||
})
|
||||
|
||||
// Qoder's listing as it came on 2026-10-02 (the built-in's saved one): its
|
||||
// app shows Qwen3.8-Max at 0.5× with an off-peak badge, Qwen3.8-Flash at 0×
|
||||
// with 0.1× struck through — both carry is_free true.
|
||||
const OFF_PEAK = {
|
||||
active: false,
|
||||
badge: { en: "Off-Peak 60% off", zh: "错峰 4 折" },
|
||||
description: { en: "Off-Peak 60% off (10 PM-8 AM UTC+8)", zh: "错峰时段4折优惠(10 PM-8 AM UTC+8)" },
|
||||
timezone: "Asia/Singapore",
|
||||
rule_id: "idle_time_model_credit_discount",
|
||||
discount_factor: 0.4,
|
||||
before_promotion_price_factor: 0.5,
|
||||
window_start: "22:00",
|
||||
window_end: "08:00",
|
||||
}
|
||||
const PRICED = {
|
||||
chat: [
|
||||
{ key: "qmodel_38max", display_name: "Qwen3.8-Max", enable: true, is_reasoning: true, price_factor: 0.5, is_free: true, promotion: OFF_PEAK },
|
||||
{ key: "qfmodel", display_name: "Qwen3.8-Flash", enable: true, is_reasoning: true, price_factor: 0.0, original_price_factor: 0.1, is_free: true },
|
||||
{ key: "qmodel_latest", display_name: "Qwen3.7-Max", enable: true, price_factor: 0.5, original_price_factor: 0.5 },
|
||||
{ key: "kmodel_latest", display_name: "Kimi-K3", enable: true, price_factor: 1.4, is_free: false },
|
||||
// 0 only while an active promotion lasts, with a price before it
|
||||
{ key: "window", display_name: "W", enable: true, price_factor: 0, is_free: true, promotion: { ...OFF_PEAK, active: true, discount_factor: 0.0001, before_promotion_price_factor: 0.5 } },
|
||||
// a promotion over, or one that had nothing to take off
|
||||
{ key: "over", display_name: "O", enable: true, price_factor: 0, promotion: { ...OFF_PEAK, active: false } },
|
||||
{ key: "nothing", display_name: "N", enable: true, price_factor: 0, promotion: { ...OFF_PEAK, active: true, before_promotion_price_factor: 0 } },
|
||||
// no price: is_free says it
|
||||
{ key: "unpriced", display_name: "U", enable: true, is_free: true },
|
||||
{ key: "unpriced2", display_name: "U2", enable: true, is_free: false },
|
||||
],
|
||||
}
|
||||
|
||||
test("a discount is not free: Qwen3.8-Max (0.5×, is_free true) is priced, Qwen3.8-Flash (0×) is free", async () => {
|
||||
const { hooks, auth } = await chat(PRICED, () => new Response(""))
|
||||
const ms = await hooks.provider.models({ models: {} }, { auth })
|
||||
expect(Object.fromEntries(Object.entries(ms).map(([k, m]) => [k, m.free]))).toEqual({
|
||||
qmodel_38max: false,
|
||||
qfmodel: true,
|
||||
qmodel_latest: false,
|
||||
kmodel_latest: false,
|
||||
window: false,
|
||||
over: true,
|
||||
nothing: true,
|
||||
unpriced: true,
|
||||
unpriced2: false,
|
||||
})
|
||||
expect(_internal.modelInfo({ key: "x", priceFactor: 0.5, isFree: true }).free).toBe(false)
|
||||
expect(_internal.modelInfo({ key: "x", priceFactor: 0, promotion: { active: true, beforePromotionPriceFactor: 1 } }).free).toBe(false)
|
||||
})
|
||||
|
||||
// a usage read on an account whose job token is due, the refresh answered by refresh()
|
||||
async function dueUsage(refresh, read) {
|
||||
let auth = { ...account(), expires: 0 }
|
||||
|
||||
Reference in New Issue
Block a user