workbuddy 0.1.34: a free account's plan is "Free plan", not "Free" (#337)
Buger2008 read the "Free" beside their WorkBuddy account in Providers as
the model they picked (Deepseek-V4.1-Flash, 0.11x) being free, and as why
routing chose WorkBuddy first. It is the account's plan; routing doesn't
read it. The label now says it is a plan. Nothing in magpie or the plugins
compares a plan to "Free" (grepped internal/ and packages/).
Run: bun test in packages/workbuddy, sandbox HOME, network at a dead
proxy: 152 pass 0 fail; on the old index.mjs the 4 tests that say the
label fail. bun scripts/check.mjs: workbuddy ok.
Not tried: a real WorkBuddy account in the GUI.
Siblings: trae ("Free", d.plan || "Free") and mimo (plan "Free") say the
same; filed as their own issue.
This commit is contained in:
@@ -1598,9 +1598,11 @@ const compact = (n) => (Number.isInteger(n) ? String(n) : n.toFixed(2).replace(/
|
|||||||
// usageOf is the account's credits, from its resource summary: the plan's
|
// usageOf is the account's credits, from its resource summary: the plan's
|
||||||
// credits used against what the cycle grants, as magpie's built-in said —
|
// credits used against what the cycle grants, as magpie's built-in said —
|
||||||
// the count itself too (amount of limit, in credits), for magpie to say it
|
// the count itself too (amount of limit, in credits), for magpie to say it
|
||||||
// as used or left beside the share (magpie#659).
|
// as used or left beside the share (magpie#659). The free plan is said as a
|
||||||
|
// plan: "Free" alone beside the account read as the model being free, and
|
||||||
|
// routing as preferring it for that (#337).
|
||||||
function usageOf(sum, plan) {
|
function usageOf(sum, plan) {
|
||||||
const out = { plan: plan || (sum?.IsPaidUser ? "Pro" : "Free"), windows: [] }
|
const out = { plan: plan || (sum?.IsPaidUser ? "Pro" : "Free plan"), windows: [] }
|
||||||
let total = 0, used = 0
|
let total = 0, used = 0
|
||||||
for (const p of sum?.Packages ?? []) {
|
for (const p of sum?.Packages ?? []) {
|
||||||
total += capacity(p?.CycleTotalCapacity)
|
total += capacity(p?.CycleTotalCapacity)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@magpie-community/opencode-workbuddy-auth",
|
"name": "@magpie-community/opencode-workbuddy-auth",
|
||||||
"version": "0.1.33",
|
"version": "0.1.34",
|
||||||
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./index.mjs",
|
"main": "./index.mjs",
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ test("a free WorkBuddy AI account, at its own site and domain", async () => {
|
|||||||
const calls = serve({ "/billing/meter/get-user-resource-summary": () =>
|
const calls = serve({ "/billing/meter/get-user-resource-summary": () =>
|
||||||
ok({ IsPaidUser: false, Packages: [{ CycleTotalCapacity: "1000", CycleUsedCapacity: "100" }] }) })
|
ok({ IsPaidUser: false, Packages: [{ CycleTotalCapacity: "1000", CycleUsedCapacity: "100" }] }) })
|
||||||
const auth = { type: "oauth", access: "ai-access", expires: later(), uid: "ai2", domain: "www.codebuddy.ai" }
|
const auth = { type: "oauth", access: "ai-access", expires: later(), uid: "ai2", domain: "www.codebuddy.ai" }
|
||||||
expect(await usageOf(WorkBuddyAIAuthPlugin, auth)).toEqual({ signIn: "kept", plan: "Free", windows: [{ name: "Credits", used: 10, display: "100 / 1000", amount: 100, limit: 1000, unit: "credits" }] })
|
expect(await usageOf(WorkBuddyAIAuthPlugin, auth)).toEqual({ signIn: "kept", plan: "Free plan", windows: [{ name: "Credits", used: 10, display: "100 / 1000", amount: 100, limit: 1000, unit: "credits" }] })
|
||||||
expect(calls[0].url.origin).toBe("https://www.workbuddy.ai")
|
expect(calls[0].url.origin).toBe("https://www.workbuddy.ai")
|
||||||
expect(calls[0].headers.get("x-domain")).toBe("www.codebuddy.ai")
|
expect(calls[0].headers.get("x-domain")).toBe("www.codebuddy.ai")
|
||||||
})
|
})
|
||||||
@@ -74,7 +74,7 @@ test("counts and plans as Go says them", () => {
|
|||||||
.toEqual({ plan: "Team", windows: [{ name: "Credits", used: (100 * 438.88000002) / 3300, display: "438.88 / 3300", amount: 438.88000002, limit: 3300, unit: "credits" }] })
|
.toEqual({ plan: "Team", windows: [{ name: "Credits", used: (100 * 438.88000002) / 3300, display: "438.88 / 3300", amount: 438.88000002, limit: 3300, unit: "credits" }] })
|
||||||
// no capacity, no window
|
// no capacity, no window
|
||||||
expect(_internal.usageOf({ IsPaidUser: false, Packages: [{ CycleTotalCapacity: "", CycleUsedCapacity: null }] }, ""))
|
expect(_internal.usageOf({ IsPaidUser: false, Packages: [{ CycleTotalCapacity: "", CycleUsedCapacity: null }] }, ""))
|
||||||
.toEqual({ plan: "Free", windows: [] })
|
.toEqual({ plan: "Free plan", windows: [] })
|
||||||
expect(() => _internal.usageOf({ Packages: [{ CycleTotalCapacity: "lots" }] })).toThrow('strconv.ParseFloat: parsing "lots": invalid syntax')
|
expect(() => _internal.usageOf({ Packages: [{ CycleTotalCapacity: "lots" }] })).toThrow('strconv.ParseFloat: parsing "lots": invalid syntax')
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ test("a personal account with no credits isn't given the enterprise's, and its r
|
|||||||
"/billing/meter/get-enterprise-user-usage": () => new Response(PERSONAL_ENT, { status: 400 }),
|
"/billing/meter/get-enterprise-user-usage": () => new Response(PERSONAL_ENT, { status: 400 }),
|
||||||
})
|
})
|
||||||
const auth = { type: "oauth", access: "a", refresh: "r", expires: later(), uid: "u" }
|
const auth = { type: "oauth", access: "a", refresh: "r", expires: later(), uid: "u" }
|
||||||
expect(await usageOf(WorkBuddyAuthPlugin, auth)).toEqual({ signIn: "kept", plan: "Free", windows: [] })
|
expect(await usageOf(WorkBuddyAuthPlugin, auth)).toEqual({ signIn: "kept", plan: "Free plan", windows: [] })
|
||||||
})
|
})
|
||||||
|
|
||||||
test("a personal account with credits never asks the enterprise meter", async () => {
|
test("a personal account with credits never asks the enterprise meter", async () => {
|
||||||
@@ -402,7 +402,7 @@ test("credits used up don't count the free models (plugins#138, hheei)", async (
|
|||||||
for (const plugin of [WorkBuddyAuthPlugin, WorkBuddyAIAuthPlugin]) {
|
for (const plugin of [WorkBuddyAuthPlugin, WorkBuddyAIAuthPlugin]) {
|
||||||
serve({ "/billing/meter/get-user-resource-summary": () => ok(SPENT), "/v3/config": FREE_CFG })
|
serve({ "/billing/meter/get-user-resource-summary": () => ok(SPENT), "/v3/config": FREE_CFG })
|
||||||
const auth = { type: "oauth", access: "a", refresh: "r", expires: later(), uid: "u", domain: "" }
|
const auth = { type: "oauth", access: "a", refresh: "r", expires: later(), uid: "u", domain: "" }
|
||||||
expect(await usageOf(plugin, auth)).toEqual({ signIn: "kept", plan: "Free", windows: [{
|
expect(await usageOf(plugin, auth)).toEqual({ signIn: "kept", plan: "Free plan", windows: [{
|
||||||
name: "Credits", used: 100, display: "560 / 560", amount: 560, limit: 560, unit: "credits", notModels: ["deepseek-v4.1-flash"] }] })
|
name: "Credits", used: 100, display: "560 / 560", amount: 560, limit: 560, unit: "credits", notModels: ["deepseek-v4.1-flash"] }] })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user