commandcode 0.1.12: each plan lists only the models it may use; a Go account no longer lists GOAT's (01huadalang on Discord)

01huadalang, signed in on the Go plan, was shown models only GOAT and above
may use. Command Code's /provider/v1/models is the same 87 models for every
plan (read with a GOAT key and without one on 2026-10-13: the same but for
"created"); which of them a plan may use is the CLI's own table (command-code
1.79.2, evaluateModelAccess: each model's category, premium or open, and
each plan's allowedCategories and blockedModels), and the Provider API turns
the rest away only when asked (403 "MODEL_NOT_IN_PLAN: Claude Opus 5.5
available in Provider and above plans or extra on demand usage").

Cause: the plugin filtered Go's list by a copy of CLI 1.73.0's table, which
didn't have Claude Haiku 5.5 (1.79.2: "haiku 5.5 in goat plan", blocked for
Go), and didn't filter any other plan at all, so GOAT, Pro and Provider were
shown models their plan refuses (a real GOAT account listed all 87, Claude
Opus 5.5 and GPT-6 Sol among them).

Now:
- PLAN_MODELS is CLI 1.79.2's table by plan name: Go and GOAT the open
  models only, Go also blocked from GOAT's (Sonnet 5.5, Haiku 5.5, GPT-5.6
  Sol, Grok 4.6/4.7, Muse Spark 1.2/1.3, Gemini 3.7/3.8 Flash, MiMo V2.6 Pro
  UltraSpeed), Pro blocked from Opus, Fable, GPT-6 Astra, GPT-6.1 Sol and
  Fugu Ultra, Provider from GPT-6.1 Sol, Max/Ultra/Teams Pro everything.
  GO_REFUSED is derived from it. Blocks are by id: the CLI's own block of
  "vercel-ai-gateway:xiaomi/mimo-v2.6-pro-ultraspeed" misses its "cai"
  model, and Go stays kept off it as before.
- provider.models filters every plan's list (and the default list standing
  in when the list can't be read) by it.
- A plan not read (billing/subscriptions failing, nothing saved), "No plan",
  or a plan name the table doesn't know keeps the whole list.
- Bought or free credits (billing/credits) let every model, as the CLI does;
  credits not read are taken as last read, else none, so the plan's list
  stands and a model it leaves out is still refused by Command Code.
- The refusal itself is unchanged: the Provider API's 403 reaches the agent
  as it came, and on Go's endpoint failure() says "Model not in plan: …".

Tests: plan-models.test.mjs is new, built from real bytes in testdata
(models-2026-10-13.json, a GOAT account's subscriptions and credits replies
with its ids zeroed, the two MODEL_NOT_IN_PLAN refusals). The Go case uses
the GOAT reply with Go's planId: there is no Go account here. All 7 fail on
0.1.11. Broken by hand, each goes red: Haiku 5.5 unblocked for Go (Go test),
no plan filter (5 tests), credits ignored, an unread plan refusing premium,
the stand-in list unfiltered, credits unread taken as extra.
models.test.mjs's pictures test moves from Pro to Max, since Pro's list no
longer has Claude Opus 5.5.

Ran: TMPDIR=<scratch> HOME=<scratch>/home bun test (all packages, 1144 pass,
0 fail) and bun scripts/check.mjs commandcode. The new provider.models hook
against the owner's real GOAT account (saved plan and none) lists 66 models:
Sonnet 5.5, Haiku 5.5 and GPT-5.6 Sol in, Opus 5.5, Sonnet 5 and GPT-6 Sol
out; a 1-token request confirmed GOAT gets Haiku 5.5 (200) and is refused
Sonnet 5 (403 MODEL_NOT_IN_PLAN).
Not tried: a real Go account (none here), an account with bought credits,
and the new version inside a running OpenCode/magpie; magpie needs the
mover's min raised to 0.1.12 for moved users to get it.
This commit is contained in:
yetone
2026-10-13 00:44:50 +08:00
parent f573cfdcba
commit 49e9d89d59
10 changed files with 264 additions and 37 deletions
+90 -27
View File
@@ -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 })
},
},
}