diff --git a/packages/commandcode/README.md b/packages/commandcode/README.md index 501282e..8797604 100644 --- a/packages/commandcode/README.md +++ b/packages/commandcode/README.md @@ -66,14 +66,27 @@ The `config` hook declares the default list: Once signed in, the `provider.models` hook replaces the default list with the account's own: +Command Code's `/models` list is the same for every plan. A plan's list is +that list less the models the plan may not use, as the CLI's own table +(command-code 1.79.2) has it: + +- **Go** and **GOAT** may not use the premium models (Claude Sonnet 5 and + Opus, GPT-6 Sol, GPT-5.6 Terra, …). Go is also blocked from GOAT's own + (Claude Sonnet 5.5 and Haiku 5.5, GPT-5.6 Sol, Grok 4.6 and 4.7, …). +- **Pro** may not use Claude Opus and Fable, GPT-6 Astra, GPT-6.1 Sol and + Fugu Ultra; **Provider** may not use GPT-6.1 Sol. +- **Max**, **Ultra** and **Teams Pro** may use every model. + +An account with bought or free credits may use every model, and so may one +whose plan can't be read: then the whole list is shown. A model the plan +doesn't have is still refused by Command Code (403 `MODEL_NOT_IN_PLAN`), and +that refusal reaches the agent. + - **Every plan but Go**: the Provider API's `/models` list. Each model's `supported_endpoints` picks the API it speaks. - **Go**: the same `/models` list, asked without the key (it answers - without one, and Go's key has no Provider API), less the models the - CLI's table (command-code 1.73.0) refuses Go: the premium ones (Claude, - GPT-6 Sol, GPT-5.6 Terra, …) and those it blocks for Go (GPT-5.6 Sol, - Claude Sonnet 5.5, Grok 4.6 and 4.7, …). That is 56 models as of - 2026-10-01. When the list can't be had, the CLI's own Go table (57 + without one, and Go's key has no Provider API). That is 56 models as of + 2026-10-13. When the list can't be had, the CLI's own Go table (57 models) stands in. The Go models carry their reasoning levels, and a requested level is diff --git a/packages/commandcode/index.mjs b/packages/commandcode/index.mjs index 37f66df..5790751 100644 --- a/packages/commandcode/index.mjs +++ b/packages/commandcode/index.mjs @@ -118,24 +118,59 @@ const GO_MODELS = [ { id: "xai/grok-4.5", name: "Grok 4.5", context: 500_000, images: true, efforts: ["low", "medium", "high"] }, ] -// The models of Command Code's list the Go plan is refused, as the CLI's -// table has it (1.73.0): its "premium" ones, and those "individual-go" -// blocks — magpie's cmdGoRefused. A model the table doesn't name the CLI -// lets any plan pick; one the plan hasn't after all is refused with -// MODEL_NOT_IN_PLAN. -const GO_REFUSED = new Set([ - // premium +// The models each plan is let use, as the CLI's own table has it +// (command-code 1.79.2: evaluateModelAccess over its model categories and +// its plans' allowedCategories and blockedModels). Command Code's list is +// the same 87 models for every plan, asked with a key or without, and the +// Provider API turns a model the plan hasn't away only when it is asked +// (403 "MODEL_NOT_IN_PLAN: Claude Opus 5.5 available in Provider and above +// plans or extra on demand usage"). So a plan's list is Command Code's less +// what its plan refuses: a premium model when the plan has the open models +// alone (Go, GOAT), and the models it blocks. A model the table doesn't +// name the CLI lets any plan pick; one the plan hasn't after all is refused +// with MODEL_NOT_IN_PLAN, which the agent is told. Blocks are by the +// model's id: the CLI's own block of "vercel-ai-gateway:xiaomi/mimo-v2.6- +// pro-ultraspeed" misses its "cai" model, and Go is still kept off it. +const PREMIUM = new Set([ "claude-sonnet-5", "claude-sonnet-4-6", "claude-fable-5-1", "claude-fable-5", "claude-opus-5-5", "claude-opus-5", "claude-opus-4-8", "claude-opus-4-7", - "claude-haiku-4-5-20251001", "gpt-6-astra", "gpt-6.1-sol", "gpt-6-sol", - "gpt-5.6-terra", "gpt-5.5", "gpt-5.4", "gpt-5.3-codex", "gpt-5.4-mini", + "claude-haiku-4-5-20251001", "gpt-5.6-terra", "gpt-6-astra", "gpt-6.1-sol", + "gpt-6-sol", "gpt-5.5", "gpt-5.4", "gpt-5.3-codex", "gpt-5.4-mini", "google/gemini-3.5-flash", "google/gemini-3.1-flash-lite", "sakana/fugu-ultra", "meta/muse-spark-1.1", - // blocked for Go - "claude-sonnet-5-5", "gpt-5.6-sol", "xai/grok-4.6", "xai/grok-4.7", - "meta/muse-spark-1.2", "meta/muse-spark-1.3", "xiaomi/mimo-v2.6-pro-ultraspeed", - "google/gemini-3.7-flash", "google/gemini-3.8-flash", ]) +const GO_BLOCKED = new Set([ + "meta/muse-spark-1.2", "meta/muse-spark-1.3", "xai/grok-4.6", "xai/grok-4.7", + "xiaomi/mimo-v2.6-pro-ultraspeed", "google/gemini-3.7-flash", "google/gemini-3.8-flash", + "gpt-5.6-sol", "claude-sonnet-5-5", "claude-haiku-5-5", +]) +const PRO_BLOCKED = new Set([ + "claude-fable-5-1", "claude-fable-5", "claude-opus-5-5", "claude-opus-5", + "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-opus-4-5-20251101", + "gpt-6-astra", "gpt-6.1-sol", "sakana/fugu-ultra", +]) +// by the plan's name (PLAN_NAMES): the old Pro and the new are let the same +const PLAN_MODELS = { + Go: { premium: false, blocked: GO_BLOCKED }, + GOAT: { premium: false }, + Pro: { premium: true, blocked: PRO_BLOCKED }, + Provider: { premium: true, blocked: new Set(["gpt-6.1-sol"]) }, + Max: { premium: true }, + Ultra: { premium: true }, + "Teams Pro": { premium: true }, +} + +// refuses is whether the plan named refuses the model: never for a plan +// the table doesn't know, "No plan" and an unread one among them. +function refuses(plan, id) { + const p = PLAN_MODELS[plan] + if (!p) return false + return (!p.premium && PREMIUM.has(id)) || !!p.blocked?.has(id) +} + +// The models of Command Code's list the Go plan is refused — magpie's +// cmdGoRefused. +const GO_REFUSED = new Set([...PREMIUM, ...GO_BLOCKED]) const GO_EFFORTS = Object.fromEntries(GO_MODELS.map((m) => [m.id, m.efforts ?? []])) const isClaude = (id) => /^claude-/i.test(id) || id.startsWith("anthropic/") @@ -231,8 +266,9 @@ async function liveModels(key) { // model takes its name when the list gives none, its reasoning levels and, // when the list doesn't say, its pictures and window from GO_MODELS // (catalog.Decorate). Every Go model is asked on chat completions, which -// the fetch sends on to /alpha/generate. -async function goModels() { +// the fetch sends on to /alpha/generate. An account with credits beyond +// the plan's (open) is let every model, as the CLI lets it. +async function goModels(open = false) { const url = BASE + "/models" const res = await fetch(url, { headers: { Accept: "application/json", "User-Agent": "magpie" }, signal: AbortSignal.timeout(8_000) }) const text = await res.text() @@ -276,7 +312,7 @@ async function goModels() { listed.push(m) } if (!listed.length) throw new Error(`${url}: no models listed`) - const out = listed.filter((m) => !GO_REFUSED.has(m.id)) + const out = open ? listed : listed.filter((m) => !GO_REFUSED.has(m.id)) if (!out.length) throw new Error("Command Code listed no models for the Go plan") return out } @@ -464,7 +500,27 @@ const subsSeen = new Map() // doesn't include API access. Upgrade to Provider or higher …" (#969) const GO_NO_API = /\bGo plan doesn.t include API access/i const SUB_KEEP = 10 * 60 * 1000 -const waits = { subWait: 9_000 } +const waits = { subWait: 9_000, creditWait: 5_000 } + +// Each key's credits beyond its plan's, as last read: bought or free ones +// let the account every model, the plan's or not (the CLI's +// evaluateModelAccess; Command Code's refusal: "… or extra on demand +// usage"). +const extraSeen = new Map() +const hasExtra = (c) => number(c?.credits?.purchasedCredits) > 0 || number(c?.credits?.freeCredits) > 0 + +// extraNow is whether the key has such credits: read now, else as last +// read, else none, so the plan's list stands when they can't be read and +// a model it leaves out is still refused by Command Code, as it was asked. +async function extraNow(key) { + try { + const v = hasExtra(await accountJSON("/alpha/billing/credits", key, waits.creditWait)) + extraSeen.set(key, v) + return v + } catch { + return extraSeen.get(key) ?? false + } +} function subscriptionNow(key, wait = waits.subWait) { const seen = subsSeen.get(key) ?? {} @@ -502,6 +558,7 @@ async function usage(key, saved) { // billing/credits leaves the plan out: the month of credits the pool // is made of is the subscription's plan's const c = credits.c ?? {} + extraSeen.set(key, hasExtra(c)) out = allowanceOf({ ...c, credits: { ...(c.credits ?? {}), planId: c.credits?.planId || sub?.id || "" } }) } if (sub) { @@ -1107,7 +1164,7 @@ async function generate(key, chat, signal, place) { // ---- the plugin --------------------------------------------------------------- -export const _internal = { subsSeen, waits, liveKey, failure, goModels, GO_MODELS, GO_REFUSED } +export const _internal = { subsSeen, extraSeen, waits, liveKey, failure, goModels, refuses, GO_MODELS, GO_REFUSED } export async function CommandCodePlugin({ client } = {}) { // isGo keeps a key as Go's, for its models and endpoint: in the @@ -1205,19 +1262,23 @@ export async function CommandCodePlugin({ client } = {}) { } }, // the plan's list: the Provider API's, with what each model is served - // on; Go's key has no Provider API: its list is the same one, asked - // without it, less what Go is refused, and the CLI's table when that - // can't be had + // on, less what the plan refuses (PLAN_MODELS); Go's key has no + // Provider API: its list is the same one, asked without it, less what + // Go is refused, and the CLI's table when that can't be had. A plan + // not read (nothing saved, billing/subscriptions failing) keeps the + // whole list, and so does an account with credits beyond its plan's. provider: { id: ID, async models(provider, { auth } = {}) { if (auth?.type !== "api" || !auth.key) return provider.models const key = await liveKey(auth) - if ((await planNow(key, auth.metadata?.plan)) === "Go") { + const [plan, extra] = await Promise.all([planNow(key, auth.metadata?.plan), extraNow(key)]) + const keep = (id) => extra || !refuses(plan, id) + if (plan === "Go") { let ms = GO_MODELS let fell = false try { - ms = await goModels() + ms = await goModels(extra) } catch { fell = true } @@ -1228,10 +1289,12 @@ export async function CommandCodePlugin({ client } = {}) { return out } try { - return Object.fromEntries((await liveModels(key)).map((m) => [m.id, runtimeModel(m)])) - } catch { - return Object.assign(provider.models, { [FELL_BACK]: true }) - } + const out = Object.fromEntries((await liveModels(key)).filter((m) => keep(m.id)).map((m) => [m.id, runtimeModel(m)])) + if (Object.keys(out).length) return out + } catch {} + // the default list stands in, less what the plan refuses + const out = Object.fromEntries(Object.entries(provider.models ?? {}).filter(([id]) => keep(id))) + return Object.assign(out, { [FELL_BACK]: true }) }, }, } diff --git a/packages/commandcode/models.test.mjs b/packages/commandcode/models.test.mjs index 71dadc9..d01e324 100644 --- a/packages/commandcode/models.test.mjs +++ b/packages/commandcode/models.test.mjs @@ -90,10 +90,10 @@ test("the list's failures read as the built-in's", async () => { // so; of one it doesn't know, nothing is said, and magpie answers from // models.dev as the built-in does. test("a model says it takes pictures when known, and nothing when not", async () => { - const pro = { type: "api", key: "pro-key", metadata: { plan: "Pro" } } + const pro = { type: "api", key: "max-key", metadata: { plan: "Max" } } globalThis.fetch = async (url) => { const path = new URL(String(url)).pathname - if (path === "/alpha/billing/subscriptions") return Response.json({ success: true, data: { planId: "individual-pro-monthly", status: "active" } }) + if (path === "/alpha/billing/subscriptions") return Response.json({ success: true, data: { planId: "individual-max-monthly", status: "active" } }) if (path === "/provider/v1/models") return new Response(list, { status: 200 }) return new Response("", { status: 404 }) } @@ -116,11 +116,11 @@ test("a model says it takes pictures when known, and nothing when not", async () // a list that says, is taken at its word globalThis.fetch = async (url) => { const path = new URL(String(url)).pathname - if (path === "/alpha/billing/subscriptions") return Response.json({ success: true, data: { planId: "individual-pro-monthly", status: "active" } }) + if (path === "/alpha/billing/subscriptions") return Response.json({ success: true, data: { planId: "individual-max-monthly", status: "active" } }) return Response.json({ data: [{ id: "claude-opus-5-5", modalities: { input: ["text"] } }, { id: "x/seer", modalities: { input: ["text", "image"] } }] }) } _internal.subsSeen.clear() - const said2 = await (await CommandCodePlugin()).provider.models({ models: {} }, { auth: { ...pro, key: "pro-key-2" } }) + const said2 = await (await CommandCodePlugin()).provider.models({ models: {} }, { auth: { ...pro, key: "max-key-2" } }) expect(said2["claude-opus-5-5"].capabilities.input.image).toBe(false) expect(said2["x/seer"].capabilities.input.image).toBe(true) diff --git a/packages/commandcode/package.json b/packages/commandcode/package.json index 95e8777..e3dbb1c 100644 --- a/packages/commandcode/package.json +++ b/packages/commandcode/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-commandcode-auth", - "version": "0.1.11", + "version": "0.1.12", "description": "Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams) in OpenCode and magpie", "type": "module", "main": "./index.mjs", diff --git a/packages/commandcode/plan-models.test.mjs b/packages/commandcode/plan-models.test.mjs new file mode 100644 index 0000000..47be34b --- /dev/null +++ b/packages/commandcode/plan-models.test.mjs @@ -0,0 +1,146 @@ +// 01huadalang on Discord: signed in on the Go plan, magpie listed models +// only GOAT and above may use. Command Code's list is the same for every +// plan (testdata/models-2026-10-13.json, 87 models, as api.commandcode.ai +// answered it with a GOAT key and without one, the same but for +// "created"); which of them a plan may use is the CLI's own table +// (command-code 1.79.2, evaluateModelAccess), and the Provider API turns +// the rest away only when asked (testdata/refused-*.json: a GOAT key +// asking Claude Opus 5.5 and GPT-6 Sol). Each plan's list is Command +// Code's less what the plan refuses; a plan not read keeps all of it, and +// so does an account with credits beyond the plan's. +// +// testdata/subscriptions-goat.json and credits-goat.json are a GOAT +// account's billing replies (its ids zeroed); a Go account's is the same +// reply with Go's planId, as there is no Go account here to read one from. +import { afterEach, expect, test } from "bun:test" +import { readFileSync } from "node:fs" +import { join } from "node:path" +import { CommandCodePlugin, _internal } from "./index.mjs" + +const real = globalThis.fetch +const saved = { ..._internal.waits } +afterEach(() => { + globalThis.fetch = real + _internal.subsSeen.clear() + _internal.extraSeen.clear() + Object.assign(_internal.waits, saved) +}) + +const data = (f) => readFileSync(join(import.meta.dir, "testdata", f), "utf8") +const LIST = data("models-2026-10-13.json") +const ALL = JSON.parse(LIST).data.map((m) => m.id) +const subOf = (planId) => { + const s = JSON.parse(data("subscriptions-goat.json")) + s.data.planId = planId + return JSON.stringify(s) +} +const CREDITS = data("credits-goat.json") +const withExtra = (field) => { + const c = JSON.parse(CREDITS) + c.credits[field] = 5 + return JSON.stringify(c) +} + +// the models the provider.models hook lists for a key whose +// billing/subscriptions answers sub and billing/credits credits (a body, +// or a status) +async function listed({ sub, credits = CREDITS, list = LIST, metadata } = {}) { + _internal.subsSeen.clear() // a plan read is kept ten minutes + const reply = (r) => (typeof r === "number" ? new Response("", { status: r }) : new Response(r, { status: 200 })) + globalThis.fetch = async (url) => { + const path = new URL(String(url)).pathname + if (path === "/alpha/billing/subscriptions") return reply(sub) + if (path === "/alpha/billing/credits") return reply(credits) + if (path === "/provider/v1/models") return reply(list) + return new Response("", { status: 404 }) + } + _internal.waits.subWait = 50 + _internal.waits.creditWait = 50 + const hooks = await CommandCodePlugin() + const config = { provider: {} } + await hooks.config(config) + return hooks.provider.models({ models: config.provider["commandcode-plan"].models }, { auth: { type: "api", key: "k", ...(metadata ? { metadata } : {}) } }) +} + +// the CLI 1.79.2's models GOAT may use and Go may not: a Go account was +// shown Claude Haiku 5.5 ("haiku 5.5 in goat plan") +const GOAT_NOT_GO = ["claude-sonnet-5-5", "claude-haiku-5-5", "gpt-5.6-sol", "xai/grok-4.6", "xai/grok-4.7", "meta/muse-spark-1.2", "meta/muse-spark-1.3", "google/gemini-3.7-flash", "google/gemini-3.8-flash"] +const PREMIUM = ["claude-sonnet-5", "claude-opus-5-5", "claude-fable-5-1", "claude-haiku-4-5-20251001", "gpt-6-sol", "gpt-6.1-sol", "gpt-5.5", "sakana/fugu-ultra", "meta/muse-spark-1.1", "google/gemini-3.5-flash"] + +test("a Go account lists none of GOAT's models, nor the premium ones", async () => { + const got = Object.keys(await listed({ sub: subOf("individual-go") })) + for (const id of [...GOAT_NOT_GO, ...PREMIUM, "xiaomi/mimo-v2.6-pro-ultraspeed"]) expect(got).not.toContain(id) + for (const id of ["gpt-6-luna", "gpt-5.6-luna", "deepseek/deepseek-v4-pro", "moonshotai/Kimi-K3", "mistral/mistral-large-4", "stealth/glyph-cluster:free", "xai/grok-4.5"]) expect(got).toContain(id) + // 87 less the 21 premium and the 10 Go is blocked + expect(got.length).toBe(56) +}) + +test("a GOAT account lists GOAT's models and none of the premium ones", async () => { + const ms = await listed({ sub: data("subscriptions-goat.json") }) + const got = Object.keys(ms) + for (const id of GOAT_NOT_GO) expect(got).toContain(id) + for (const id of PREMIUM) expect(got).not.toContain(id) + expect(got.length).toBe(87 - 21) + expect(ms[Symbol.for("magpie.fellBack")]).toBeUndefined() +}) + +test("each plan lists what the CLI's table lets it use", async () => { + const of = async (planId) => Object.keys(await listed({ sub: subOf(planId) })) + const pro = await of("individual-pro-monthly") + for (const id of ["claude-opus-5-5", "claude-fable-5-1", "gpt-6-astra", "gpt-6.1-sol", "sakana/fugu-ultra"]) expect(pro).not.toContain(id) + for (const id of ["claude-sonnet-5", "gpt-6-sol", "claude-haiku-4-5-20251001", "claude-sonnet-5-5"]) expect(pro).toContain(id) + expect(pro.length).toBe(87 - 9) + expect(await of("individual-pro-v1")).toEqual(pro) + expect(await of("individual-provider")).toEqual(ALL.filter((id) => id !== "gpt-6.1-sol")) + for (const p of ["individual-max", "individual-ultra", "teams-pro"]) expect(await of(p)).toEqual(ALL) +}) + +test("a plan not read keeps the whole list; one saved with the key stands for it", async () => { + // billing/subscriptions failing, nothing saved: unknown, not refused + expect(Object.keys(await listed({ sub: 503 }))).toEqual(ALL) + // no plan at all (credits alone): the CLI lets every model + expect(Object.keys(await listed({ sub: JSON.stringify({ success: true, data: null }) }))).toEqual(ALL) + expect(Object.keys(await listed({ sub: 503, metadata: { plan: "GOAT" } })).length).toBe(87 - 21) +}) + +test("credits beyond the plan's let it every model; credits not read leave the plan's list", async () => { + for (const field of ["purchasedCredits", "freeCredits"]) { + _internal.extraSeen.clear() + expect(Object.keys(await listed({ sub: data("subscriptions-goat.json"), credits: withExtra(field) }))).toEqual(ALL) + // Go's list, less only what isn't for text (none of these 87) + expect(Object.keys(await listed({ sub: subOf("individual-go"), credits: withExtra(field) }))).toEqual(ALL) + } + _internal.extraSeen.clear() + expect(Object.keys(await listed({ sub: data("subscriptions-goat.json"), credits: 503 })).length).toBe(87 - 21) + // as last read, when it can't be read now + _internal.extraSeen.set("k", true) + expect(Object.keys(await listed({ sub: data("subscriptions-goat.json"), credits: 503 }))).toEqual(ALL) +}) + +test("the default list stands in less what the plan refuses", async () => { + const ms = await listed({ sub: data("subscriptions-goat.json"), list: 500 }) + expect(ms[Symbol.for("magpie.fellBack")]).toBe(true) + expect(Object.keys(ms)).toEqual(["deepseek/deepseek-v4-pro", "deepseek/deepseek-v4-flash", "moonshotai/Kimi-K3", "zai-org/GLM-5.3", "MiniMaxAI/MiniMax-M3"]) +}) + +// the plan's data unknown or behind Command Code's: a model the plan +// hasn't is still told as Command Code tells it +test("a model the plan refuses reaches the agent as Command Code's refusal", async () => { + for (const [path, f, model] of [["/provider/v1/messages", "refused-messages.json", "claude-opus-5-5"], ["/provider/v1/chat/completions", "refused-chat.json", "gpt-6-sol"]]) { + const body = data(f) + globalThis.fetch = async (url) => { + const p = new URL(String(url)).pathname + if (p === "/alpha/billing/subscriptions") return new Response(data("subscriptions-goat.json")) + if (p === path) return new Response(body, { status: 403, headers: { "Content-Type": "application/json" } }) + return new Response("", { status: 404 }) + } + const hooks = await CommandCodePlugin() + const opts = await hooks.auth.loader(async () => ({ type: "api", key: "goat-key" })) + const res = await opts.fetch("https://api.commandcode.ai" + path, { method: "POST", body: JSON.stringify({ model, messages: [{ role: "user", content: "hi" }] }) }) + expect(res.status).toBe(403) + expect(await res.text()).toBe(body) + expect(body).toContain("MODEL_NOT_IN_PLAN") + } + // and on Go's endpoint, as failure says it + expect(_internal.failure(403, data("refused-chat.json"))).toEqual({ status: 403, message: "Model not in plan: GPT-6 Sol available in Pro and above plans or extra on demand usage" }) +}) diff --git a/packages/commandcode/testdata/credits-goat.json b/packages/commandcode/testdata/credits-goat.json new file mode 100644 index 0000000..5ce81fb --- /dev/null +++ b/packages/commandcode/testdata/credits-goat.json @@ -0,0 +1 @@ +{"credits":{"belowThreshold":false,"creditThreshold":0,"monthlyCredits":69.8033399,"purchasedCredits":0,"freeCredits":0},"windowLimits":{"limited":true,"exceeded":null,"fiveHour":{"used":0,"cap":14,"exceeded":false,"resetAt":0},"weekly":{"used":0.002814,"cap":35,"exceeded":false,"resetAt":1792149831000}},"sandboxAccess":true,"sandboxMinutes":{"usedMinutes":0,"limitMinutes":0,"overageUsd":0,"resetAt":1793491200000}} \ No newline at end of file diff --git a/packages/commandcode/testdata/models-2026-10-13.json b/packages/commandcode/testdata/models-2026-10-13.json new file mode 100644 index 0000000..0981188 --- /dev/null +++ b/packages/commandcode/testdata/models-2026-10-13.json @@ -0,0 +1 @@ +{"object":"list","data":[{"id":"claude-sonnet-5-5","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Sonnet 5.5","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-sonnet-5","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Sonnet 5","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-sonnet-4-6","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Sonnet 4.6","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-fable-5-1","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Fable 5.1","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-fable-5","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Fable 5","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-opus-5-5","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Opus 5.5","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-opus-5","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Opus 5","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-opus-4-8","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Opus 4.8","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-opus-4-7","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Opus 4.7","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-haiku-5-5","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Haiku 5.5","context_length":1000000,"supported_endpoints":["/messages"]},{"id":"claude-haiku-4-5-20251001","object":"model","created":1791823041,"owned_by":"command-code","name":"Claude Haiku 4.5","context_length":200000,"supported_endpoints":["/messages"]},{"id":"gpt-6-astra","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-6 Astra","context_length":1050000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-6.1-sol","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-6.1 Sol","context_length":1050000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-6-sol","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-6 Sol","context_length":1050000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-6-luna","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-6 Luna","context_length":1050000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-5.6-sol","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-5.6 Sol","context_length":1050000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-5.6-terra","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-5.6 Terra","context_length":1050000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-5.6-luna","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-5.6 Luna","context_length":1050000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-5.5","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-5.5","context_length":400000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-5.4","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-5.4","context_length":400000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-5.3-codex","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-5.3 Codex","context_length":400000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"gpt-5.4-mini","object":"model","created":1791823041,"owned_by":"command-code","name":"GPT-5.4 Mini","context_length":400000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"deepseek/deepseek-v4-pro","object":"model","created":1791823041,"owned_by":"command-code","name":"DeepSeek V4 Pro (latest)","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"deepseek/deepseek-v4-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"DeepSeek V4 Flash (latest)","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"deepseek/deepseek-v4-flash-vision-exp","object":"model","created":1791823041,"owned_by":"command-code","name":"DeepSeek V4 Flash Vision (exp)","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"deepseek/deepseek-v4-flash-fast","object":"model","created":1791823041,"owned_by":"command-code","name":"DeepSeek V4 Flash Fast","context_length":1000000,"supported_endpoints":["/chat/completions"]},{"id":"deepseek/deepseek-v4.1-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"DeepSeek V4.1 Flash","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"deepseek/deepseek-v4.1-flash-fast","object":"model","created":1791823041,"owned_by":"command-code","name":"DeepSeek V4.1 Flash Fast","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"moonshotai/Kimi-K3","object":"model","created":1791823041,"owned_by":"command-code","name":"Kimi K3","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"moonshotai/Kimi-K2.7-Code","object":"model","created":1791823041,"owned_by":"command-code","name":"Kimi K2.7 Code","context_length":256000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"moonshotai/Kimi-K2.7-Code-Highspeed","object":"model","created":1791823041,"owned_by":"command-code","name":"Kimi K2.7 Code HighSpeed","context_length":262000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"moonshotai/Kimi-K2.6","object":"model","created":1791823041,"owned_by":"command-code","name":"Kimi K2.6","context_length":256000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"moonshotai/Kimi-K2.5","object":"model","created":1791823041,"owned_by":"command-code","name":"Kimi K2.5","context_length":256000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"z-ai/glm-5.3-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"GLM-5.3 Flash","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"z-ai/glm-5.3-flashx","object":"model","created":1791823041,"owned_by":"command-code","name":"GLM-5.3 FlashX","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"zai-org/GLM-5.3","object":"model","created":1791823041,"owned_by":"command-code","name":"GLM-5.3","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"zai-org/GLM-5.2","object":"model","created":1791823041,"owned_by":"command-code","name":"GLM-5.2","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"zai-org/GLM-5.2-Fast","object":"model","created":1791823041,"owned_by":"command-code","name":"GLM-5.2 Fast","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"zai-org/GLM-5.1","object":"model","created":1791823041,"owned_by":"command-code","name":"GLM-5.1","context_length":200000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"zai-org/GLM-5","object":"model","created":1791823041,"owned_by":"command-code","name":"GLM-5","context_length":200000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"MiniMaxAI/MiniMax-M3","object":"model","created":1791823041,"owned_by":"command-code","name":"MiniMax M3","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"MiniMaxAI/MiniMax-M2.7","object":"model","created":1791823041,"owned_by":"command-code","name":"MiniMax M2.7","context_length":200000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"MiniMaxAI/MiniMax-M2.5","object":"model","created":1791823041,"owned_by":"command-code","name":"MiniMax M2.5","context_length":200000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xiaomi/mimo-v2.6-pro","object":"model","created":1791823041,"owned_by":"command-code","name":"MiMo V2.6 Pro","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xiaomi/mimo-v2.6-pro-ultraspeed","object":"model","created":1791823041,"owned_by":"command-code","name":"MiMo V2.6 Pro UltraSpeed","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xiaomi/mimo-v2.6-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"MiMo V2.6 Flash","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xiaomi/mimo-v2.5-pro","object":"model","created":1791823041,"owned_by":"command-code","name":"MiMo V2.5 Pro","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xiaomi/mimo-v2.5","object":"model","created":1791823041,"owned_by":"command-code","name":"MiMo V2.5","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.8-Omni-Flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.8 Omni Flash","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.8-Max-0902","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.8 Max 0902","context_length":1000000,"supported_endpoints":["/chat/completions"]},{"id":"Qwen/Qwen3.8-Max","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.8 Max","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.8-27B","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.8 27B","context_length":262144,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.8-Flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.8 Flash","context_length":1000000,"supported_endpoints":["/chat/completions"]},{"id":"Qwen/Qwen3.7-Max","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.7 Max","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.7-Plus","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.7 Plus","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.7-Flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.7 Flash","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.6-Max-Preview","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.6 Max Preview","context_length":200000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"Qwen/Qwen3.6-Plus","object":"model","created":1791823041,"owned_by":"command-code","name":"Qwen 3.6 Plus","context_length":200000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"meituan/LongCat-2.0","object":"model","created":1791823041,"owned_by":"command-code","name":"LongCat 2.0","context_length":1048576,"supported_endpoints":["/chat/completions"]},{"id":"stepfun/Step-5-Preview","object":"model","created":1791823041,"owned_by":"command-code","name":"Step 5 Preview","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"stepfun/Step-3.7-Flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Step 3.7 Flash","context_length":256000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"stepfun/Step-3.5-Flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Step 3.5 Flash","context_length":262144,"supported_endpoints":["/chat/completions","/responses"]},{"id":"tencent/hy3-paid","object":"model","created":1791823041,"owned_by":"command-code","name":"Tencent Hy3","context_length":262144,"supported_endpoints":["/chat/completions","/responses"]},{"id":"tencent/hy4-preview","object":"model","created":1791823041,"owned_by":"command-code","name":"Tencent Hy4 Preview","context_length":1048576,"supported_endpoints":["/chat/completions"]},{"id":"google/gemini-3.8-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Gemini 3.8 Flash","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"google/gemini-3.7-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Gemini 3.7 Flash","context_length":1048576,"supported_endpoints":["/chat/completions"]},{"id":"google/gemini-3.6-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Gemini 3.6 Flash","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"google/gemini-3.5-flash","object":"model","created":1791823041,"owned_by":"command-code","name":"Gemini 3.5 Flash","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"google/gemini-3.5-flash-lite","object":"model","created":1791823041,"owned_by":"command-code","name":"Gemini 3.5 Flash Lite","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"google/gemini-3.1-flash-lite","object":"model","created":1791823041,"owned_by":"command-code","name":"Gemini 3.1 Flash Lite","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"sakana/fugu-ultra","object":"model","created":1791823041,"owned_by":"command-code","name":"Fugu Ultra","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"nvidia/nemotron-3-ultra-550b-a55b","object":"model","created":1791823041,"owned_by":"command-code","name":"Nemotron 3 Ultra","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"thinkingmachines/inkling","object":"model","created":1791823041,"owned_by":"command-code","name":"Inkling","context_length":256000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"thinkingmachines/inkling-small","object":"model","created":1791823041,"owned_by":"command-code","name":"Inkling Small","context_length":1000000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"stealth/glyph-cluster:free","object":"model","created":1791823041,"owned_by":"command-code","name":"Glyph Cluster","context_length":256000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"poolside/laguna-s-2.1-free","object":"model","created":1791823041,"owned_by":"command-code","name":"Laguna S 2.1","context_length":256000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"inclusionai/ling-3.0-flash-sante:free","object":"model","created":1791823041,"owned_by":"command-code","name":"Ling 3.0 Flash Sante","context_length":262144,"supported_endpoints":["/chat/completions"]},{"id":"inclusionai/ling-3.1-flash:free","object":"model","created":1791823041,"owned_by":"command-code","name":"Ling 3.1 Flash","context_length":262144,"supported_endpoints":["/chat/completions"]},{"id":"meta/muse-spark-1.1","object":"model","created":1791823041,"owned_by":"command-code","name":"Muse Spark 1.1","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"meta/muse-spark-1.2","object":"model","created":1791823041,"owned_by":"command-code","name":"Muse Spark 1.2","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"meta/muse-spark-1.2-contributor","object":"model","created":1791823041,"owned_by":"command-code","name":"Muse Spark 1.2 Contributor","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"meta/muse-spark-1.3","object":"model","created":1791823041,"owned_by":"command-code","name":"Muse Spark 1.3","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"meta/muse-spark-1.3-contributor","object":"model","created":1791823041,"owned_by":"command-code","name":"Muse Spark 1.3 Contributor","context_length":1048576,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xai/grok-4.5","object":"model","created":1791823041,"owned_by":"command-code","name":"Grok 4.5","context_length":500000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xai/grok-4.6","object":"model","created":1791823041,"owned_by":"command-code","name":"Grok 4.6","context_length":500000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"xai/grok-4.7","object":"model","created":1791823041,"owned_by":"command-code","name":"Grok 4.7","context_length":500000,"supported_endpoints":["/chat/completions","/responses"]},{"id":"mistral/mistral-large-4","object":"model","created":1791823041,"owned_by":"command-code","name":"Mistral Large 4","context_length":524288,"supported_endpoints":["/chat/completions","/responses"]}]} \ No newline at end of file diff --git a/packages/commandcode/testdata/refused-chat.json b/packages/commandcode/testdata/refused-chat.json new file mode 100644 index 0000000..54d2864 --- /dev/null +++ b/packages/commandcode/testdata/refused-chat.json @@ -0,0 +1 @@ +{"error":{"message":"MODEL_NOT_IN_PLAN: GPT-6 Sol available in Pro and above plans or extra on demand usage","type":"permission_error","code":"FORBIDDEN"}} \ No newline at end of file diff --git a/packages/commandcode/testdata/refused-messages.json b/packages/commandcode/testdata/refused-messages.json new file mode 100644 index 0000000..e5abc74 --- /dev/null +++ b/packages/commandcode/testdata/refused-messages.json @@ -0,0 +1 @@ +{"type":"error","error":{"type":"permission_error","message":"MODEL_NOT_IN_PLAN: Claude Opus 5.5 available in Provider and above plans or extra on demand usage"}} \ No newline at end of file diff --git a/packages/commandcode/testdata/subscriptions-goat.json b/packages/commandcode/testdata/subscriptions-goat.json new file mode 100644 index 0000000..09d6f27 --- /dev/null +++ b/packages/commandcode/testdata/subscriptions-goat.json @@ -0,0 +1 @@ +{"success":true,"data":{"id":"sub_0000000000000000000000","status":"active","userId":"00000000-0000-0000-0000-000000000000","orgId":null,"createdAt":"2026-09-28T16:16:42.000Z","priceId":"price_0000000000000000000000","metadata":{"fbp":"fb.1.0.0","commandCode":"true","commandCodeUserId":"00000000-0000-0000-0000-000000000000"},"quantity":1,"cancelAtPeriodEnd":true,"currentPeriodStart":"2026-09-28T16:16:42.000Z","currentPeriodEnd":"2026-10-28T16:16:42.000Z","endedAt":null,"cancelAt":"2026-10-28T16:16:42.000Z","canceledAt":"2026-09-28T16:18:08.000Z","planId":"individual-goat","pendingPhase":null}} \ No newline at end of file