太陽と向日葵 on magpie's Discord: Usage no longer shows what calls through Devin cost. Two causes, both in what the list gives magpie: - Every model went with a price of 0 (runtimeModel's cost), and magpie falls back to models.dev, which has none of Devin's own models (SWE-2, SWE-1.7 Lightning). Devin lists each paid model's price in GetCliModelConfigs: field 32 of a config, one per "Input", "Cached input" and "Output", a float32 in USD per "1M tokens". parsePrices reads it (fields() now keeps a fixed32's bytes), and listed() gives an entry the price its variants share, none when they differ. Read from Devin's own response on 10-15: Opus 5.5 4/20 (cache 0.2), its fast run 8/40, SWE-1.7 Lightning 2.5/12.5, SWE-2 Lightning 1/5, GLM-5.2 1.4/4.4. The Free tier lists none. - Devin now files swe-2-high-, -medium- and -max-lightning under SWE-2 at the High cost tier. A family was free only when every model under it was, so swe-2 lost free (seen in the owner's plugin-providers.json on 0.1.17), and with it 0.1.16's rule that a used-up day and week don't hold SWE-2. A family is now judged by the variants variantFor sends it as: those at an effort and its default. Run: HOME=<mktemp -d> bun test in packages/devin: 84 pass. prices.test.mjs uses Devin's real GetCliModelConfigs bytes of 10-15, cut to 11 configs (testdata/model-configs-1015.bin, no account data in it). Without the index.mjs change: 3 of its 4 tests red. Broke by hand: the family's free over every model again turns 2 red; cost back at 0 turns 1 red. bun scripts/check.mjs devin: ok. Every price above checked by decoding the full real response with a separate Python reader. Not run: magpie end to end with this version (magpie reads a plugin's price from its next commit on).
67 lines
3.5 KiB
JavaScript
67 lines
3.5 KiB
JavaScript
// 太陽と向日葵 on magpie's Discord (2026-10-15): Usage showed no cost for
|
|
// calls through Devin. Devin lists a price for each model it doesn't
|
|
// serve free, in USD per 1M tokens, in GetCliModelConfigs (field 32), and
|
|
// the list gave every model a price of 0. And Devin now files three
|
|
// -lightning variants at the High cost tier under SWE-2, so swe-2, which
|
|
// is sent as swe-2-high, -medium or -max, all Free, was no longer free.
|
|
import { afterEach, expect, test } from "bun:test"
|
|
import { readFileSync } from "node:fs"
|
|
import { join } from "node:path"
|
|
import { DevinAuthPlugin, _internal } from "./index.mjs"
|
|
|
|
const real = globalThis.fetch
|
|
afterEach(() => {
|
|
globalThis.fetch = real
|
|
_internal.forgetSaid()
|
|
})
|
|
|
|
// Devin's own response to GetCliModelConfigs (2026-10-15), cut to SWE-2's
|
|
// six variants, SWE-1.7 Lightning, Gemini 4 Argon's three and GLM-5.2
|
|
const configs = readFileSync(join(import.meta.dir, "testdata", "model-configs-1015.bin"))
|
|
|
|
function serve() {
|
|
globalThis.fetch = async (url) => {
|
|
if (String(url).endsWith("/GetUserStatus")) return Response.json({ userStatus: { planStatus: { planInfo: { planName: "Teams", isDevin: true }, planEnd: "2026-10-26T21:45:55Z" } } })
|
|
if (String(url).endsWith("/GetCliModelConfigs")) return new Response(configs)
|
|
throw new Error("unexpected fetch " + url)
|
|
}
|
|
}
|
|
|
|
test("Devin's prices are read from its model configs, as Devin wrote them", () => {
|
|
const p = _internal.parsePrices(new Uint8Array(configs))
|
|
expect(p.get("swe-1-7-lightning")).toEqual({ input: 2.5, output: 12.5, cache: { read: 1 } })
|
|
expect(p.get("swe-2-high-lightning")).toEqual({ input: 1, output: 5, cache: { read: 0.1 } })
|
|
// a float32's 1.4 and 0.26, not 1.39999997…
|
|
expect(p.get("glm-5-2")).toEqual({ input: 1.4, output: 4.4, cache: { read: 0.26 } })
|
|
// the Free tier lists none
|
|
expect(p.has("swe-2-high")).toBe(false)
|
|
})
|
|
|
|
test("the list gives each model Devin's price, and SWE-2 stays free beside its Lightning variants", async () => {
|
|
serve()
|
|
const got = await (await DevinAuthPlugin()).provider.models({ models: {} }, { auth: { type: "api", key: "key-prices-list" } })
|
|
expect(got["swe-2"].free).toBe(true)
|
|
expect(got["swe-2"].cost).toEqual({ input: 0, output: 0, cache: { read: 0, write: 0 } })
|
|
expect(got["swe-2-high-lightning"].free).toBeUndefined()
|
|
expect(got["swe-2-high-lightning"].cost).toEqual({ input: 1, output: 5, cache: { read: 0.1, write: 0 } })
|
|
// a family is priced at its variants' one price
|
|
expect(got["gemini-4-argon"].cost).toEqual({ input: 1, output: 5, cache: { read: 0.05, write: 0 } })
|
|
const swe17 = got["swe-1.7-lightning"] ?? got["swe-1-7-lightning"]
|
|
expect(swe17.cost).toEqual({ input: 2.5, output: 12.5, cache: { read: 1, write: 0 } })
|
|
})
|
|
|
|
test("a family whose variants Devin lists at different prices has none", () => {
|
|
const f = { uid: "fam", label: "Fam", aliases: [], models: [{ id: "fam-low" }, { id: "fam-high" }] }
|
|
const prices = new Map([["fam-low", { input: 1, output: 2, cache: { read: 0 } }], ["fam-high", { input: 3, output: 6, cache: { read: 0 } }]])
|
|
const [fam] = _internal.listed([f], [], {}, new Set(), prices)
|
|
expect(fam.cost).toBeUndefined()
|
|
expect(_internal.runtimeModel(fam).cost).toEqual({ input: 0, output: 0, cache: { read: 0, write: 0 } })
|
|
})
|
|
|
|
test("SWE-2 used up a quota doesn't count, with its Lightning variants in the list", async () => {
|
|
serve()
|
|
const ids = await _internal.freeIDs("key-prices-free", "https://server.self-serve.windsurf.com")
|
|
expect(ids).toContain("swe-2")
|
|
expect(ids).not.toContain("swe-2-high-lightning")
|
|
})
|