nbczw8750 (#657): trae 0.2.26 on OpenCode 2.2.5 fails with "Plugin must export a default definition with an id and an effect or setup function. (cause: SchemaError(Missing key at ["default"]))". 2.x imports a package's exports["."] (a plugin dir and an npm install alike) and has no V1 path at all, so every package here that serves models failed the same way, not only trae. Every one of the 32 model packages now has: - opencode2.mjs, exports["."]: a copy of scripts/opencode2.mjs, an adapter that runs the package's V1 plugins inside 2.x's promise API. Config providers become 2.x providers (package pinned so the aisdk sdk hook runs), V1 auth methods become integration methods (oauth auto/code with forms; api without authorize as a key method), V1 credentials are kept in metadata.v1, the loader's baseURL, apiKey, headers and fetch are applied through the sdk hook, an auth.set renewal is stored per credential, and credential.switched /updated reload the account's own model list. - opencode.mjs, main: re-exports the V1 plugin functions only. OpenCode 1.x and magpie's host.js take main. On 1.x, trae 0.2.26's main exported a non-plugin (_internal) and 1.19.5 refused it ("Plugin export is not a function"); the new main fixes that too. - both files in "files"; patch version bumped. devin already had 2.x and is unchanged. scripts/check.mjs fails a model package whose 2.x entry has no default {id, setup}, whose opencode2.mjs differs from the canonical one, whose entry is missing from files, or whose main exports a non-plugin. Run at this head (mote): - HOME=$(mktemp -d) bun test, as CI runs it: 4900 pass, 0 fail (4914 tests, 374 files). A first run set globalThis.fetch for the whole process from opencode2.test and failed 528 tests in other packages; the block is now set and put back around that file's tests. - bun scripts/check.mjs: every package passes. With the network blocked cloudflare-workers-ai fails on its fetched catalog, the same on origin/main. - Real OpenCode 2.2.5 (npm opencode-ai), sandbox HOME, packed trae 0.2.27: loads with no error; /api/integration lists trae-cn "Trae CN" and trae-global "Trae Global" with their browser sign-ins; `auth login` starts the trae.cn authorization and waits (cancelled there); with a fake credential POSTed to /api/credential, `opencode models` lists trae-cn's six models. - Real 2.2.5 with a fake V1 key plugin through the same adapter against a local fake server: `auth login` with a key, `models`, `opencode run` reached /real/v1/chat/completions with the loader's "Bearer loader-sk-fake" and header, and printed the fake's reply; with @ai-sdk/anthropic it reached /real/v1/messages with x-api-key from the loader. This run found the key method missing after 2.x's second integration transform (a once-only flag outside the transform); fixed, and opencode2.test checks a rebuild. - Real OpenCode 1.19.5, sandbox HOME, trae 0.2.27: `opencode models` lists trae-cn and trae-global models; 0.2.26 failed there. Broken by hand (scratch copy, bun test scripts/ and check.mjs): - trae's exports back to "./index.mjs": the trae 2.x test fails (default.id undefined), check fails trae with "OpenCode 2.x: ./index.mjs has no default {id, setup} (plugins#657)". - zed's opencode2.mjs changed: the copies test fails, check fails zed "differs from scripts/opencode2.mjs". - the key flag back outside the transform: the 1.x plugin test fails on the rebuilt sign-ins (key missing). Not tried: a real sign-in with a real account on 2.x; Windows (the reporter's OS); chat.headers, chat.params, usage and tool hooks, which the adapter doesn't carry to 2.x; the tools/pages packages (calc, goanyapi, layerfs, search1api, aelios, agent-console, chat, fingerprint, nowledge-mem, kimi-desktop), which still load only on 1.x.
@magpie-community/opencode-agnes-code-auth
把 Agnes Code 桌面端 的账号额度接入 magpie 与 OpenCode:复用桌面端登录态(会话文件解密),直连云端 OpenAI 兼容网关,agent 以 agnes-code/<model> 使用它的模型;支持「每日登录送积分」自动观测与积分余额显示。
登录什么
两种方式(登录时二选一):
- 读取 Agnes Code 桌面端登录态(推荐,仅 Windows)——本机装有 Agnes Code 桌面版并登录过即可。插件按 Chrome 同款方案解出会话(
Local State的 DPAPI 包裹 AES 主密钥 → 解code-auth-session.v1的 AES-256-GCM),只在本机、当前 Windows 用户下可解,凭据不外传:- 会话目录:
%APPDATA%\AgnesCode\。macOS/Linux 下桌面端解密不可用,会明确提示改用粘贴方式。 - 会话 JWT 过期会提示打开 Agnes Code 重新登录后重试(桌面端负责续期)。
- 会话目录:
- 粘贴 accessToken——从桌面端会话里复制 JWT(
eyJ…);可选填用户名便于区分账号。
每个账号登录一次即得一个 magpie 账号,可多账号故障切换。凭据保存在 magpie 的 plugin-auth.json(权限 600),不上传。
模型
供应商 id agnes-code。目录按账号实时拉取(GET /v1/models,读取不计费)。2026-11 实测目录:
| modelId | context | 备注 |
|---|---|---|
agnes-3.0-flash |
512k | 免费,思考 |
agnes-2.5-flash |
512k | 免费,思考 |
agnes-2.5-pro |
512k | 免费,思考 |
gpt-6.1-sol |
1M | 会员 |
gpt-6-astra |
1M | 会员 |
grok-4.7 |
500k | 会员 |
claude-opus-5-5 |
1M | 会员 |
deepseek-v4.1-flash |
1M | 会员,思考 |
deepseek-v4-pro |
1M | 会员,思考 |
glm-5.3 |
1M | 会员 |
kimi-k3 |
1M | 会员 |
带 thinking_toggle 的模型标为推理模型;会员专属模型照常列出,免费账号调用会得到上游透明的 403(subscription_required),不影响登录态。
每日签到
免费档「每日登录送 600 积分」由服务端随当日会话自动发放,没有领取接口——插件的 auth.checkin 每天做一次账号会话活跃(只读请求)并观测发放前后的余额差:涨了记已领取(+600);没涨不谎称已签,如实报「未观测到新发放」(发放可能挂靠桌面端登录)。
用量
显示真实积分余额(GET /api/v2/subscription/credits-balance,读取不计费):积分总额、限时积分、永久积分(有则显示)。401/403 会把账号标记为需要重新登录。
协议与上游
- 模型调用:
POST https://api-agnes-code.agnes-ai.com/v1/chat/completions(OpenAI chat 协议,Authorization: Bearer <accessToken>,思考在reasoning_content)。 - 模型目录:
GET https://api-agnes-code.agnes-ai.com/v1/models。 - 积分:
GET https://api.agnes-ai.com/api/v2/subscription/credits-balance。
风险提示
非官方集成,凭据与协议来自桌面客户端逆向,上游随时可能变更;共享登录态的自动化使用可能违反 Agnes Code 服务条款,账号风险自担。请勿用于批量/滥用场景。
安装与开发
magpie plugin add @magpie-community/opencode-agnes-code-auth
magpie plugin login agnes-code # 选「读取 Agnes Code 桌面端登录态」或「粘贴 accessToken」
magpie provider test agnes-code agnes-3.0-flash
测试(零依赖,Node ≥18 或 Bun):
npm test # = node --test
# 或 bun test