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-astudio-auth
把 AStudio(科大讯飞 Astron Studio 桌面端) 的账号额度接入 magpie 与 OpenCode:复用桌面端登录态,直连云端模型网关(OpenAI Responses 协议),agent 以 astudio/<model> 使用它的模型;支持每日登录积分自动签到与积分余额显示。
与 Providers Hub 的 hub-astudio 的区别
AStudio 在 registry 里有两个入口,都保留(#614):
本包(astudio) |
magpie-providers-hub(hub-astudio) |
|
|---|---|---|
| 登录 | 读取本机 AStudio 桌面端的登录态,或粘贴 modelBearerToken;不需要再输手机号或密码 |
本机打开一个登录页:手机验证码、账号密码或微信扫码(含极验验证),不依赖桌面端 |
| 适合 | 装了 AStudio 桌面端的用户(数据目录按 ASTUDIO_HOME、Windows 注册表、~/.acode 查找;其他情况粘贴凭据) |
任何平台,没装桌面端也行 |
| 模型端点 | …/model-gateway/v1/responses(OpenAI Responses,与桌面端一致) |
…/model-gateway/v1/chat/completions |
| 每日积分 | 做一次会话活跃,按前后余额差记录,不调用领取接口 | 调用 client-popups 领取每日奖励和新人礼包弹窗 |
两者用同一个 AStudio 账号时,读的是同一个 points/balance,模型调用也扣同一份积分:每日登录积分是一个池子,装两个不会多一份。 同一账号两边都登录只会重复显示同一笔余额。
English: two entries serve AStudio. This one reuses the AStudio desktop's
sign-in (or a pasted modelBearerToken) and calls the Responses endpoint;
Providers Hub's hub-astudio signs in on a local page (SMS code, password
or WeChat QR) and calls chat/completions. On one account both draw on the
same daily points balance.
登录什么
两种方式(登录时二选一):
- 读取 AStudio 桌面端登录态(推荐)——本机装有 AStudio 桌面版并登录过即可,插件自动从它的数据目录读出模型凭据与网页会话(积分/签到用)。数据目录按以下顺序查找:
ASTUDIO_HOME(或SYNARA_HOME)环境变量指定的目录;- Windows 注册表
HKCU\Software\AStudioStorage的Production/Canary/DevelopmentDataRoot; - 兜底
~/.acode/acode/。 - 目标文件:
<数据根>/userdata/astron-session.json(其次<数据根>/runtime/acode-home/config.toml,该方式无网页会话,积分/签到不可用)。
- 粘贴 modelBearerToken——从
astron-session.json的modelBearerToken(或config.toml的experimental_bearer_token)复制粘贴;可选填账号面accountId与网页会话token(两者齐才能用积分/签到,另有ssoSessionId/uid 可选)。
每个 AStudio 账号登录一次即得一个 magpie 账号,可多账号故障切换。凭据保存在 magpie 的 plugin-auth.json(权限 600),不上传。
模型
供应商 id astudio。目录按账号实时拉取(GET /api/v1/model-manager/models,读取不计费),含思考档位与限免标记。2026-11 实测目录:
| modelId | 名称 | context | 备注 |
|---|---|---|---|
astronclaw-auto |
Auto | 256k | 智能路由 |
spark-x2.6 |
Spark-X2.6 | 256k | 抢先体验 |
spark-x2.6-4b |
Spark-X2.6-Lite | 1M | 限免 |
spark-x2.5 |
Spark-X2.5 | 256k | |
xopglm52 |
GLM-5.2 | 1M | |
xopdeepseekv4pro0813 |
DeepSeek-V4-Pro | 1M | |
xopdsv4flash0731in |
DeepSeek-V4-Flash | 1M |
思考档位(none / high / max,随模型)映射为 magpie 的推理档位;上游字段变化以实时目录为准。
每日签到(每日登录积分)
AStudio 有「每日登录积分」:服务端在当天账号会话首次活跃时发放(体验版 100 分/天,标准版 200,高级/畅享 400;活动期 31 天有效),客户端弹窗只做通知、没有领取接口。插件为此提供 magpie 的 auth.checkin:每天替账号做一次会话活跃(只读请求)并观测前后余额差——涨了记为已领取;没涨不谎称已签,如实报「未观测到新发放」(发放可能挂靠桌面端登录)。签到需要账号带网页会话(桌面端登录态方式默认有)。
用量
有网页会话时显示真实数据:会员档(体验版/标准版/高级版/畅享版)、通用积分余额(含最近到期批次与时间)、星火积分余额。所有读取均不计费;模型调用本身才消耗账号额度。401/403/登录异常会把账号标记为需要重新登录。
协议与上游
- 模型调用:
POST https://astronstudio-api-volces-prod.xf-yun.com/model-gateway/v1/responses(OpenAI Responses,Authorization: Bearer)——与 AStudio 桌面端写进 acode 内核的base_url/wire_api完全一致。 - 模型目录:
GET https://astronstudio-api-volces-prod.xf-yun.com/api/v1/model-manager/models。 - 账号面:
https://agent.xfyun.cn/xingchen-studio/(points/balance、membership/me、membership/plan-config,Cookie 会话鉴权)。
风险提示
非官方集成,凭据与协议来自桌面客户端逆向,上游随时可能变更;共享登录态的自动化使用可能违反 AStudio 服务条款,账号风险自担。请勿用于批量/滥用场景。
安装与开发
magpie plugin add @magpie-community/opencode-astudio-auth
magpie plugin login astudio # 选「读取 AStudio 桌面端登录态」或「粘贴 modelBearerToken」
magpie provider test astudio spark-x2.6-4b # 限免模型,验收一发
测试(零依赖,Node ≥18 或 Bun):
npm test # = node --test
# 或 bun test