From 5f78bb0089f993814b61b5372d338ba42f440b8b Mon Sep 17 00:00:00 2001 From: shadyrispy <144605632+shadyrispy@users.noreply.github.com> Date: Wed, 4 Nov 2026 10:51:40 +0800 Subject: [PATCH] codearts 0.3.5: OfficeAce models carry their cost coefficient as rate (#689) OfficeAce models carry the billable list's cost_coefficient as `rate` (only when it is a finite number; the static signed-out table has none and stays without). package.json 0.3.4 -> 0.3.5. Reviewed head 171e93c6. Read every changed line. The rates table is the existing /v1/model-token-rates read (fixture has the vendor's trailing-newline model_name); a missing or non-numeric coefficient was never in the table, so such a model gets no rate rather than 0. No conflict with #677 (names untouched; -0930 and -1017 stay separate ids with separate rates). Run on mote: bun test packages/codearts 169 pass / 0 fail; bun scripts/check.mjs codearts and registry ok. Broke it by hand (dropped the rate spread in officeAceLiveModels): the models-are-the-billable-list test went red, 168 pass / 1 fail. Not tried: a real OfficeAce account. Note: a coefficient of "" or false would read as 0 in the existing table parse (not changed here). --- packages/codearts/index.mjs | 7 ++++++- packages/codearts/index.test.mjs | 4 ++++ packages/codearts/package.json | 6 ++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/codearts/index.mjs b/packages/codearts/index.mjs index 112dba5..2d638ca 100644 --- a/packages/codearts/index.mjs +++ b/packages/codearts/index.mjs @@ -3393,7 +3393,7 @@ async function fetchOfficeAceCatalog(cred, fetcher = fetch) { } /** One OfficeAce model entry, as magpie wants it. */ -function officeAceModelEntry({ id, name, baseUrl = OA_MAAS_MARKET_BASE, context = 1_000_000, output = 128_000 }) { +function officeAceModelEntry({ id, name, baseUrl = OA_MAAS_MARKET_BASE, context = 1_000_000, output = 128_000, rate }) { return { id, name, @@ -3414,6 +3414,9 @@ function officeAceModelEntry({ id, name, baseUrl = OA_MAAS_MARKET_BASE, context }, release_date: "", variants: {}, + // magpie's own: the credits a request costs, as a multiple (0: none). + // The billable list's cost_coefficient; a static entry has no rate yet. + ...(Number.isFinite(rate) ? { rate } : {}), } } @@ -3435,12 +3438,14 @@ function officeAceLiveModels(rows, baseUrl, rates) { if (OA_UNAVAILABLE_IDS.has(id)) continue if (rates && rates.size > 0 && !rates.has(id)) continue const known = OA_FALLBACK_MODELS[id] + const rate = rates?.get(id) out[id] = officeAceModelEntry({ id, name: typeof row?.name === "string" && row.name.length > 0 ? row.name : id, baseUrl, context: known?.context ?? 1_000_000, output: known?.output ?? 128_000, + ...(Number.isFinite(rate) ? { rate } : {}), }) } return out diff --git a/packages/codearts/index.test.mjs b/packages/codearts/index.test.mjs index 026d3c3..f845bb3 100644 --- a/packages/codearts/index.test.mjs +++ b/packages/codearts/index.test.mjs @@ -2950,6 +2950,10 @@ test("models are the billable list: the multiplier is trimmed, and an id that al assert.equal(models["kimi-k3"].name, "Kimi-K3") assert.equal(models["glm-5.3"].name, "GLM-5.3 · x0.18") assert.equal(models["deepseek-v4.1-flash-0930"].name, "DeepSeek-V4.1-Flash · x1.5") + // magpie's own rate: the billable list's cost_coefficient, not only the name + assert.equal(models["glm-5.3"].rate, 0.18) + assert.equal(models["kimi-k3"].rate, 1) + assert.equal(models["deepseek-v4.1-flash-0930"].rate, 1.5) assert.equal(models["glm-5.3"].api.url, "https://api.modelarts-maas.com/v2") assert.equal(models["glm-5.3"].limit.context, 1_000_000) // the registry's un-callable placeholders are gone even though the rates list has one diff --git a/packages/codearts/package.json b/packages/codearts/package.json index 235a14d..ab320f6 100644 --- a/packages/codearts/package.json +++ b/packages/codearts/package.json @@ -1,10 +1,12 @@ { "name": "@magpie-community/opencode-codearts-auth", - "version": "0.3.4", + "version": "0.3.5", "description": "Huawei Cloud in OpenCode and magpie: CodeArts (码道) and OfficeAce (AgentArts), each from its own Huawei Cloud OAuth sign-in — models, credit rates, credit usage and the daily check-in (unofficial)", "type": "module", "main": "./opencode.mjs", - "exports": { ".": "./opencode2.mjs" }, + "exports": { + ".": "./opencode2.mjs" + }, "files": [ "index.mjs", "opencode.mjs",