zen-free 0.1.8: the free models Zen lists are offered again when OpenCode's docs or catalog can't be read, and the docs are read from where they moved (yetone/magpie#2305, MiniFullC)

The reporter, on 0.1.7 with the public key, saw only Big Pickle, Space
Bunny Free and Muse Spark 1.3 Free: the three models the plugin knows
offline. Two causes:

- DOCS pointed at packages/web/src/content/docs/zen.mdx, which OpenCode
  removed on 2026-10-12 (anomalyco/opencode#54761, "replace old Zen and Go
  pages with V2 console docs"). It answers 404, so every discovery since
  was partial. The endpoint table now lives in
  services/www/src/docs/content/console/models.mdx; parseProtocolDocs
  reads its rows as they are.
- A listed model the catalog (models.opencode.ai) didn't describe and the
  docs didn't name was left out. When the catalog can't be read, that is
  every listed model but the three in bootstrapProvider, which is the
  reporter's list exactly. bootstrapProtocols is now a snapshot of the
  console docs' free rows (2026-10-15), used under whatever the docs say,
  and bootstrapProvider gains the catalog's metadata for Cat Jam, Step 5
  Preview, LongCat 2.5 Preview, MiMo-V2.6-Flash and Nemotron 3.5
  Lightning Free.

Not changed, on purpose: jev-1.13-free is a SystemOne decision model
(docs: endpoint /v1/systemone, no AI SDK package), which can't answer a
chat, so it stays out as SystemOne models always have. exo-free is
"deprecated" in the catalog and not in Zen's /models list now.

Tests (no network; the fixture server): "listed free models are offered
when the catalog and the docs can't be read" (catalog 503, docs 404,
listing big-pickle, step-5-preview-free, cat-jam-free, jev-1.13-free,
paid -> the three free chat models only) and "reads the console docs'
endpoint table, and Jev stays out as SystemOne" (literal rows from the new
page). Both fail on 0.1.7's models.mjs/provider.mjs (2 fail, 170 pass)
and pass with the change; bun test: 172 pass. bun scripts/check.mjs ok.

Real use (live Zen, public key, this checkout): discovery now lists
big-pickle cat-jam-free longcat-2.5-preview-free mimo-v2.6-flash-free
muse-spark-1.3-contributor-free nemotron-3.5-lightning-free
space-bunny-free step-5-preview-free, not fallen back (0.1.7: the same
eight with the docs 404 marking it partial). A request to cat-jam-free
through the plugin's fetch streamed 200; step-5-preview-free answered
Zen's own 429 "Upstream request failed: Endpoint is unavailable." twice.
The reporter's catalog failure itself wasn't reproduced from here.
This commit is contained in:
yetone
2026-10-15 12:08:28 +08:00
parent 157c7c0f88
commit cbff94eb43
5 changed files with 126 additions and 6 deletions
+18
View File
@@ -307,6 +307,24 @@ test("partial catalog failure retains previously verified models rather than dro
assert.equal(fallback[Symbol.for("magpie.fellBack")], true);
});
// The reporter of #2305 (yetone/magpie) saw only the three models the
// plugin knew offline: the catalog and the docs out of reach dropped every
// listed free model they didn't name. A listed free model now takes its
// endpoint from the snapshot of OpenCode's console docs; Jev (SystemOne)
// and a paid model stay out, and a model not listed isn't offered.
test("listed free models are offered when the catalog and the docs can't be read", async (t) => {
const { plugin, state } = await fixture(t);
state.catalogStatus = 503;
state.docsStatus = 404;
state.ids = ["big-pickle", "step-5-preview-free", "cat-jam-free", "jev-1.13-free", "paid"];
const models = await plugin.provider.models({ models: {} }, { auth: await publicAuth() });
assert.deepEqual(Object.keys(models).sort(), ["big-pickle", "cat-jam-free", "step-5-preview-free"]);
assert.equal(models["step-5-preview-free"].api.npm, "@ai-sdk/openai-compatible");
assert.equal(models["step-5-preview-free"].name, "Step 5 Preview Free");
assert.equal(models["step-5-preview-free"].limit.context, 1000000);
assert.equal(models[Symbol.for("magpie.fellBack")], true);
});
test("forces upstream streaming, preserves existing tools and returns the SSE body unbuffered", async (t) => {
const { plugin, state, origin } = await fixture(t);
await plugin.provider.models({ models: {} }, { auth: await publicAuth() });
+64 -1
View File
@@ -85,10 +85,73 @@ export function buildModels(ids, provider, protocols, baseURL) {
return result;
}
// Offline bootstrap metadata from the OpenCode catalog, 2026-10-06.
// What each free model is asked at, from OpenCode's console docs
// (services/www/src/docs/content/console/models.mdx) on 2026-10-15: used for
// a listed model when the docs can't be read, so the catalog or the docs
// being out of reach never leaves a listed free model out. Jev is a
// SystemOne decision model, not one to chat with.
export const bootstrapProtocols = {
"big-pickle": "chat",
"space-bunny-free": "chat",
"cat-jam-free": "chat",
"longcat-2.5-preview-free": "chat",
"step-5-preview-free": "chat",
"mimo-v2.6-flash-free": "chat",
"nemotron-3.5-lightning-free": "chat",
"muse-spark-1.3-contributor-free": "responses",
"jev-1.13-free": "systemone",
};
// Offline bootstrap metadata from the OpenCode catalog, 2026-10-06; the
// free models listed since added on 2026-10-15.
export const bootstrapProvider = {
npm: SDK.chat,
models: {
"cat-jam-free": {
name: "Cat Jam Free",
cost: { input: 0, output: 0 },
limit: { context: 262144, output: 131072 },
reasoning: true,
tool_call: true,
interleaved: { field: "reasoning_content" },
reasoning_options: [{ type: "effort", values: ["low", "medium", "high", "xhigh", "max"] }],
},
"step-5-preview-free": {
name: "Step 5 Preview Free",
cost: { input: 0, output: 0 },
limit: { context: 1000000, input: 1000000, output: 65536 },
reasoning: true,
tool_call: true,
interleaved: { field: "reasoning_content" },
modalities: { input: ["text", "image", "video"], output: ["text"] },
reasoning_options: [{ type: "effort", values: ["low", "medium", "high"] }],
},
"longcat-2.5-preview-free": {
name: "LongCat 2.5 Preview Free",
cost: { input: 0, output: 0 },
limit: { context: 1000000, output: 131072 },
reasoning: true,
tool_call: true,
interleaved: { field: "reasoning_content" },
modalities: { input: ["text", "image"], output: ["text"] },
},
"mimo-v2.6-flash-free": {
name: "MiMo-V2.6-Flash Free",
cost: { input: 0, output: 0 },
limit: { context: 200000, output: 32000 },
reasoning: true,
tool_call: true,
interleaved: { field: "reasoning_content" },
modalities: { input: ["text", "image", "audio", "video"], output: ["text"] },
},
"nemotron-3.5-lightning-free": {
name: "Nemotron 3.5 Lightning Free",
cost: { input: 0, output: 0 },
limit: { context: 262144, output: 262144 },
reasoning: true,
tool_call: true,
interleaved: { field: "reasoning_content" },
},
"big-pickle": {
name: "Big Pickle",
cost: { input: 0, output: 0 },
+31
View File
@@ -68,3 +68,34 @@ test("unknown models require a known protocol rather than a guessed chat endpoin
assert.equal(models["new-free"].api.url, baseURL);
assert.equal(models["new-free"].cost.input, 0);
});
// Rows as OpenCode's console docs have them since 2026-10-12
// (services/www/src/docs/content/console/models.mdx), and the pricing
// table beside it that names no endpoint (#2305 on yetone/magpie).
const consoleDocs = [
"| Claude Haiku 4.5 | claude-haiku-4-5 | `https://opencode.ai/inference/v1/messages` | `@ai-sdk/anthropic` |",
"| Gemini 3 Flash | gemini-3-flash | `https://opencode.ai/inference/v1/models/gemini-3-flash` | `@ai-sdk/google` |",
"| Jev 1.13 Free | jev-1.13-free | `https://opencode.ai/inference/v1/systemone` | - |",
"| Big Pickle | big-pickle | `https://opencode.ai/inference/v1/chat/completions` | `@ai-sdk/openai-compatible` |",
"| Step 5 Preview Free | step-5-preview-free | `https://opencode.ai/inference/v1/chat/completions` | `@ai-sdk/openai-compatible` |",
"| Muse Spark 1.3 Contributor Free | muse-spark-1.3-contributor-free | `https://opencode.ai/inference/v1/responses` | `@ai-sdk/openai` |",
"| Step 5 Preview Free | Free | Free | Free | - |",
].join("\n");
test("reads the console docs' endpoint table, and Jev stays out as SystemOne", async () => {
const { buildModels, parseProtocolDocs, bootstrapProtocols } = await subject;
const protocols = parseProtocolDocs(consoleDocs);
assert.deepEqual(protocols, {
"claude-haiku-4-5": "anthropic",
"jev-1.13-free": "systemone",
"big-pickle": "chat",
"step-5-preview-free": "chat",
"muse-spark-1.3-contributor-free": "responses",
});
// the snapshot kept for when the docs can't be read says the same
for (const [id, protocol] of Object.entries(protocols)) {
if (bootstrapProtocols[id]) assert.equal(bootstrapProtocols[id], protocol, id);
}
const models = buildModels(["jev-1.13-free", "step-5-preview-free"], {}, protocols, baseURL);
assert.deepEqual(Object.keys(models), ["step-5-preview-free"]);
});
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-zen-free-auth",
"version": "0.1.7",
"version": "0.1.8",
"description": "OpenCode Zen free models through the public credential, with native streaming protocols",
"type": "module",
"main": "./index.mjs",
+12 -4
View File
@@ -2,6 +2,7 @@ import { createHash, randomBytes } from "node:crypto";
import {
PROVIDER,
SDK,
bootstrapProtocols,
bootstrapProvider,
buildModels,
configModels,
@@ -17,8 +18,10 @@ import { guardToolResponse } from "./tool-response.mjs";
const DEFAULT_BASE = "https://opencode.ai/inference/v1";
const LEGACY_BASE = "https://opencode.ai/zen/v1";
const CATALOG = "https://models.opencode.ai/api.json";
// OpenCode's table of what each model is asked at; packages/web's zen.mdx,
// read before, was removed on 2026-10-12 (anomalyco/opencode#54761)
const DOCS =
"https://raw.githubusercontent.com/anomalyco/opencode/dev/packages/web/src/content/docs/zen.mdx";
"https://raw.githubusercontent.com/anomalyco/opencode/dev/services/www/src/docs/content/console/models.mdx";
const PATHS = { chat: "/chat/completions", responses: "/responses", anthropic: "/messages" };
const CORE_TOOLS = ["bash", "edit", "glob", "grep", "read"];
// The parameter each stand-in takes, OpenCode's own first one: Zen's free
@@ -181,9 +184,14 @@ async function server(_input, options = {}) {
const baseURL = httpURL(options.baseURL ?? DEFAULT_BASE);
const catalogURL = httpURL(options.catalogURL ?? CATALOG);
const docsURL = httpURL(options.docsURL ?? DOCS);
let known = buildModels(Object.keys(bootstrapProvider.models), bootstrapProvider, {}, baseURL);
let known = buildModels(
Object.keys(bootstrapProvider.models),
bootstrapProvider,
bootstrapProtocols,
baseURL,
);
let metadata = bootstrapProvider;
let protocols = {};
let protocols = { ...bootstrapProtocols };
let listed = false;
let listedAt = 0;
@@ -202,7 +210,7 @@ async function server(_input, options = {}) {
partial = true;
}
if (docs.status === "fulfilled" && Object.keys(parseProtocolDocs(docs.value)).length) {
protocols = parseProtocolDocs(docs.value);
protocols = { ...bootstrapProtocols, ...parseProtocolDocs(docs.value) };
} else {
partial = true;
}