devin 0.1.3: the card's quota windows are "1 day" and "7 days", shown only when Devin says what is left of them (one left out is no longer taken for used up); usage no longer overwrites the row's plan ("Devin Pro", as devin auth status names it) with planName's bare "Pro"; a refused key says "Devin's sign-in has expired — sign in again"; the efforts none and minimal go as given; a variant the user picked stays, as magpie's devinCollapse keeps it; only a model models.dev says takes images gets image input
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
// shaped as a live Teams account's (magpie's built-in Devin account showed
|
||||
// none of it).
|
||||
import { afterEach, expect, test } from "bun:test"
|
||||
import { DevinAuthPlugin } from "./index.mjs"
|
||||
import { mkdirSync, realpathSync, writeFileSync } from "node:fs"
|
||||
import { homedir, tmpdir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
import { DevinAuthPlugin, _internal } from "./index.mjs"
|
||||
|
||||
const real = globalThis.fetch
|
||||
afterEach(() => (globalThis.fetch = real))
|
||||
@@ -38,13 +41,13 @@ async function run(a, reply) {
|
||||
|
||||
test("a Teams plan: its end, its day and week, the extra usage balance", async () => {
|
||||
const { u, seen } = await run(auth, () => Response.json(status()))
|
||||
// no plan: the row keeps the sign-in's, as `devin auth status` names it
|
||||
expect(u).toEqual({
|
||||
plan: "Teams",
|
||||
until: "2026-10-26T21:45:55Z",
|
||||
balance: "$46.81",
|
||||
windows: [
|
||||
{ name: "Daily", used: 0, span: 86400, resetsAt: 1790841600 },
|
||||
{ name: "Weekly", used: 1, span: 604800, resetsAt: 1791100800 },
|
||||
{ name: "1 day", used: 0, span: 86400, resetsAt: 1790841600 },
|
||||
{ name: "7 days", used: 1, span: 604800, resetsAt: 1791100800 },
|
||||
],
|
||||
})
|
||||
expect(seen[0].url).toBe("https://server.codeium.com/exa.seat_management_pb.SeatManagementService/GetUserStatus")
|
||||
@@ -52,27 +55,80 @@ test("a Teams plan: its end, its day and week, the extra usage balance", async (
|
||||
expect(seen[0].body.metadata).toMatchObject({ ideName: "devin-cli", extensionName: "devin-cli", apiKey: "devin-key", locale: "en" })
|
||||
})
|
||||
|
||||
test("a quota with no share left is used up; a hidden one isn't shown; ACUs with a limit are", async () => {
|
||||
test("a quota Devin says nothing left of isn't taken for used up; a hidden one isn't shown; ACUs with a limit are", async () => {
|
||||
const s = status({ dailyQuotaRemainingPercent: undefined, overageBalanceMicros: undefined, acuConsumed: 12.5, acuLimit: 50 })
|
||||
s.userStatus.planStatus.planInfo.hideWeeklyQuota = true
|
||||
const { u } = await run({ ...auth, metadata: { ...auth.metadata, server: "https://eu.example" } }, () => Response.json(s))
|
||||
expect(u).toEqual({
|
||||
plan: "Teams",
|
||||
until: "2026-10-26T21:45:55Z",
|
||||
windows: [
|
||||
{ name: "Daily", used: 100, span: 86400, resetsAt: 1790841600 },
|
||||
{ name: "ACUs", used: 25, display: "12.5 / 50 ACUs", resetsAt: "2026-10-26T21:45:55Z", aside: true },
|
||||
],
|
||||
windows: [{ name: "ACUs", used: 25, display: "12.5 / 50 ACUs", resetsAt: "2026-10-26T21:45:55Z", aside: true }],
|
||||
})
|
||||
})
|
||||
|
||||
test("a plan without quotas is its name alone", async () => {
|
||||
test("a plan billed otherwise, with resets and no share given, has no quota windows", async () => {
|
||||
const s = status({ dailyQuotaRemainingPercent: undefined, weeklyQuotaRemainingPercent: undefined, overageBalanceMicros: undefined })
|
||||
s.userStatus.planStatus.planInfo.billingStrategy = "BILLING_STRATEGY_CREDITS"
|
||||
expect((await run(auth, () => Response.json(s))).u).toEqual({ until: "2026-10-26T21:45:55Z", windows: [] })
|
||||
})
|
||||
|
||||
test("a plan without quotas has no windows, and leaves the row's plan be", async () => {
|
||||
const s = { userStatus: { planStatus: { planInfo: { planName: "Free" } } } }
|
||||
expect((await run(auth, () => Response.json(s))).u).toEqual({ plan: "Free", windows: [] })
|
||||
expect((await run(auth, () => Response.json(s))).u).toEqual({ windows: [] })
|
||||
})
|
||||
|
||||
test("a refused key says to sign in again", async () => {
|
||||
const { u } = await run(auth, () => Response.json({ code: "unauthenticated", message: "invalid api key" }, { status: 401 }))
|
||||
expect(u).toEqual({ error: "invalid api key — sign in to Devin again", windows: [] })
|
||||
// worded so magpie's /sign-in has expired/ marks the account
|
||||
expect(u).toEqual({ error: "Devin's sign-in has expired — sign in again", windows: [] })
|
||||
expect(u.error).toMatch(/sign-in has expired/)
|
||||
const bare = await run(auth, () => new Response("", { status: 401 }))
|
||||
expect(bare.u.error).toBe("Devin's sign-in has expired — sign in again")
|
||||
expect((await run({ type: "oauth" }, () => Response.json({}))).u).toEqual({ error: "Devin isn't signed in" })
|
||||
})
|
||||
|
||||
// the built-in sends none and minimal as asked (devinVariantIn): the
|
||||
// family's variant nearest them
|
||||
test("the efforts none and minimal go as given", () => {
|
||||
const { effortOf, variantFor, familiesOf, SNAPSHOT } = _internal
|
||||
expect(effortOf("none")).toBe("none")
|
||||
expect(effortOf("minimal")).toBe("minimal")
|
||||
const fs = familiesOf(SNAPSHOT)
|
||||
expect(variantFor(fs, "gpt-6-sol", effortOf("none"))).toBe("gpt-6-sol-none")
|
||||
expect(variantFor(fs, "gemini-3.5-flash", effortOf("minimal"))).toBe("gemini-3-5-flash-minimal")
|
||||
})
|
||||
|
||||
// devinCollapse keeps a variant the user picked, at the effort its id is at
|
||||
test("a variant the user picked stays in the list, at its own effort", () => {
|
||||
const { listed, familiesOf, SNAPSHOT } = _internal
|
||||
const fs = familiesOf(SNAPSHOT)
|
||||
const ids = (ms) => ms.map((m) => m.id)
|
||||
expect(ids(listed(fs))).not.toContain("swe-2-medium")
|
||||
const kept = listed(fs, ["swe-2-medium", "claude-opus-5-5-high-fast", "not-a-devin-model", "swe-2"])
|
||||
expect(kept.find((m) => m.id === "swe-2-medium")).toEqual({ id: "swe-2-medium", name: "SWE-2 Medium", context: 262000, output: 128000, efforts: ["medium"] })
|
||||
expect(kept.find((m) => m.id === "claude-opus-5-5-high-fast").efforts).toEqual(["high"])
|
||||
expect(ids(kept)).not.toContain("not-a-devin-model")
|
||||
expect(ids(kept).filter((id) => id === "swe-2").length).toBe(1)
|
||||
})
|
||||
|
||||
// the built-in marks a model as taking images only when it does
|
||||
// (m.Images || catalog.SeesImages): models.dev's word, from the catalog cache
|
||||
test("only a model models.dev says takes images is given image input", () => {
|
||||
const { seesImages, runtimeModel, configModel, forgetImages } = _internal
|
||||
if (![tmpdir(), realpathSync(tmpdir())].some((t) => homedir().startsWith(t))) throw new Error("run with HOME=$(mktemp -d) bun test")
|
||||
const dir = join(process.env.XDG_CACHE_HOME || join(homedir(), ".cache"), "magpie")
|
||||
mkdirSync(dir, { recursive: true })
|
||||
writeFileSync(join(dir, "models.json"), JSON.stringify({
|
||||
anthropic: { models: { "claude-opus-5-5": { modalities: { input: ["text", "image"] } } } },
|
||||
zai: { models: { "glm-5-2": { modalities: { input: ["text"] } } } },
|
||||
}))
|
||||
forgetImages()
|
||||
const m = (id) => ({ id, name: id, context: 1, output: 1, efforts: [] })
|
||||
expect(seesImages("claude-opus-5-5")).toBe(true)
|
||||
expect(runtimeModel(m("claude-opus-5-5")).capabilities.input.image).toBe(true)
|
||||
expect(configModel(m("claude-opus-5-5")).modalities.input).toEqual(["text", "image"])
|
||||
for (const id of ["glm-5-2", "swe-2"]) {
|
||||
expect(runtimeModel(m(id)).capabilities.input.image).toBe(false)
|
||||
expect(runtimeModel(m(id)).capabilities.attachment).toBe(false)
|
||||
expect(configModel(m(id)).modalities.input).toEqual(["text"])
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user