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",