Files
plugins/packages/zen-free/package.json
T
yetone f32736f015 zen-free 0.1.16: requests go with OpenCode 2.0.25's User-Agent, since Zen refuses the 1.19.0 one 0.1.15 sent
杨梅 (yangmei_61422) on magpie's Discord, 10-26: Zen Free from Kimi
Code/Work fails again ("反代失败") a day after 0.1.15.

Cause, found against opencode.ai from this machine on 2026-10-26: Zen's
free tier now answers 429 FreeUsageLimitError ("Free usage limit
reached. Free models work in OpenCode") to the exact User-Agent 0.1.6 to
0.1.15 sent, OpenCode 1.19.0's
`opencode/1.19.0 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14`,
whatever the body says. One request (short system prompt + the <env>
block + the five core tools, our other headers), only the UA changed:
that exact string 429; with provider-utils 4.0.24, bun 1.3.15, opencode
1.19.1, the ai-sdk or runtime part dropped, or an "x " prefix: 200;
"opencode/latest/2.0.25/cli" (what OpenCode 2.0.25 sends,
`opencode/${channel}/${version}/${name}` in its binary): 200. So it is
that one string, the plugin's fingerprint, not a version floor. The env
block is still needed: 2.0.25's UA without it is 429. Path
(/inference/v1), project "global", x-opencode-request and the
x-session-* pair made no difference either way.

Fix: userAgent() is OpenCode 2.0.25's on every protocol, and the header
set is the one captured from 2.0.25 on 10-25: its session id also under
x-session-affinity and x-session-id, no x-opencode-request. A caller's
own session headers still never go on.

Run:
- Real, through the plugin's loader.fetch: a Kimi Code request (its
  system.md rendered, Shell/ReadFile/Glob/Grep/WriteFile/StrReplaceFile/
  SetTodoList with Kimi's own descriptions, UA KimiCLI/1.0) and a plain
  one. At origin/main (0.1.15): deepseek-v4.1-flash-free 429
  FreeUsageLimitError for both. With this change: deepseek-v4.1-flash-
  free, glm-5.3-flash-free and big-pickle 200 for both.
- tools-smoke.mjs, real: big-pickle and mimo-v2.6-flash-free, stream and
  not, 200 with a Bash call.
- Header tests (project identity x4, per-protocol header set x3, the
  streaming one): red on origin/main's provider.mjs (8 of 199 fail),
  green with it.
- HOME=$(mktemp -d) bun test at the repo root: 2675 pass, 0 fail;
  bun scripts/check.mjs: ok.

Not tried: Kimi Code or Kimi Work themselves through magpie (the request
was built from Kimi CLI's installed prompt and tool files); a Responses
or Anthropic free model (Zen lists none free now).
2026-10-26 15:07:51 +08:00

14 lines
683 B
JSON

{
"name": "@magpie-community/opencode-zen-free-auth",
"version": "0.1.16",
"description": "OpenCode Zen free models through the public credential, with native streaming protocols",
"type": "module",
"main": "./index.mjs",
"files": ["index.mjs", "provider.mjs", "models.mjs", "stream.mjs", "tool-response.mjs", "README.md", "LICENSE"],
"keywords": ["opencode", "opencode-plugin", "zen", "free", "magpie"],
"license": "MIT",
"repository": { "type": "git", "url": "https://github.com/magpie-community/plugins", "directory": "packages/zen-free" },
"scripts": { "test": "bun test" },
"magpie": { "icon": "https://opencode.ai/favicon-v3.ico", "maxConcurrency": 2 }
}