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.
scripts/check.mjs accepts a provider that declares auth.usage, an empty
model map and no npm or api (a quota-only provider). Its loader is still
required, and a provider with models, npm or api is still checked as
before. Tests in scripts/check.test.mjs cover the accepted case, the three
incomplete configurations and a missing loader. (sunny0826, split out of
#653 as asked there.)
Run at the reviewed head bc57c1362e, rebased on main d40a074, on mote
(Bun 1.4.2, temp HOME):
- bun test scripts/check.test.mjs: 11 pass, 0 fail
- bun test (whole repo): 4890 pass, 14 skip, 0 fail
- bun scripts/check.mjs: exit 0, no package marked ✗
- Broken by hand: dropping `&& !usageOnly` from the condition turns the
quota-only test red (10 pass, 1 fail).
bun scripts/check.mjs exited 0 on a registry.json that wasn't JSON, or
had an entry with a bogus kind, so a listing PR could break the Plugins
page's list and pass CI. check.mjs now checks registry.json first
(scripts/registry.mjs) and fails on:
- text that isn't JSON, isn't an object, or is over 1 MiB (what magpie
fetches); version not 1; plugins not a non-empty list;
- an entry whose package isn't a name magpie's pkgName pattern
(internal/plugin/store.go) matches, or over npm's 214 characters
(magpie drops such an entry); the same package listed twice;
- no name, no summary.en or summary.zh;
- a kind other than middleware, hooks, agent, tools or page (plugins.js's
kindOf; a provider has none), which would list it as a provider;
- a value of the wrong type for community, providers, replaces or
summary: market.go unmarshals the whole file into typed fields, so one
such value loses every listing; an icon with a scheme other than https
or data:image; a field magpie doesn't read (a typo like "kinds").
All 72 current entries pass, the 5 without community included (magpie
skips them; kept as they are).
Run on mote, HOME=$(mktemp -d), bun 1.4.2:
- bun test: 4709 pass, 12 skip, 0 fail (363 files).
- bun scripts/check.mjs: exit 0, ✓ registry.json.
Broken by hand on mote: "{" appended to registry.json -> exit 1, "not
JSON"; every "kind": "middleware" made "bogus" -> exit 1, each entry
named. registryProblems stubbed to return [] -> the three #612 tests go
red.
Open listing PRs (#611, #610) merged onto this commit pass the check;
#582 doesn't touch registry.json.
mail-watch 0.1.0: a hooks plugin that mails a rendered event (per event or as a digest) when a session ends, a turn fails, or a request is refused, through the user's own SMTP server.
The digest's due time is kept in the state file (digestAt/digestHours), so a restart neither resets nor fires it early; the timer step is capped at 2^31-1 ms and an early wake re-arms for the rest instead of sending.
Run at the reviewed head 8415dd9eb (sandbox HOME):
- mote: packages/mail-watch `bun test` 44 pass, 0 fail, three times; whole repo `bun test` 2982 pass, 8 skip, 0 fail; `bun scripts/check.mjs` exit 0; e2e.smoke.mjs against a local SMTP sink: onRequest returns undefined, onResponse returns without awaiting the mail, the mail arrives with the rendered event and subject.
- Linux (WSL2 Ubuntu 24.04): packages/mail-watch `bun test` 44 pass, 0 fail.
- Broken by hand, each red: no step cap (2 red: monthly digest, early wake), no due-time-ahead check (early wake), no persisted due time (restart test), no prune, raw guard, no shrink (1 red each). Making the persist write unconditional stayed green, as expected (a cost fix only).
- CI at this head: test and on-npm green.
Not tried: a real SMTP provider (Gmail, Fastmail); the smoke test uses a local sink.
Lists Magic_zero's (Magiczerowxy) magpie-chat as @magpie-community/page-chat:
a chat page in magpie's window over magpie's own gateway, models, MCP
servers, instructions and skills. Not a provider or a relay: it signs in
to nothing and every request goes through magpie's gateway.
- chat.test.mjs starts the service on a free port against a fake
gateway in a temp config folder: no token (Origin null and none), a
wrong token, another Origin and a rebound Host are refused and nothing
reaches the gateway; with the token a chat streams with the caller key;
the icon redirect has a Location; boot.js makes no request; app.js
sends the token.
- scripts/check.mjs takes the OpenCode v1 default export {id, server}
as magpie's host does, and doesn't start a page's server (it would bind
a port and write config); layerfs's tools are still checked.
- package.json declares the port option (3477) both parts read; boot.js's
comment says so instead of a fallback to 3478 that never existed.
- README in the repo's style with credit, what the service reads and
sends, who can use it, and the changes from the original.
- registry.json entry and a row in the Pages table.
Run on mote (bun 1.4.2) at this tree:
- cd packages/chat && HOME=$(mktemp -d) bun test: 11 pass.
- HOME=$(mktemp -d) bun test (whole repo): 3119 pass, 0 fail, 3127
tests across 261 files; bun scripts/check.mjs: exit 0, chat and
layerfs ok.
Broken by hand: with the token check off, "a page without the token
can't chat" went red; with the Host check off, "a DNS-rebound Host is
refused" went red.
Not tried: the page in a real magpie window (sandboxed frame navigation
and the host calling server()).
Co-authored-by: Magiczerowxy <magiczerowxy@users.noreply.github.com>
Adds packages/search1api as @magpie-community/tools-search1api 0.1.0
(fatwang2, replacing #340). It has six tools: search, news, ask, crawl,
sitemap and trending. Sign-in is one account by API key or OAuth: PKCE
S256, dynamic client registration and a loopback callback. Tokens refresh
through auth.refresh and on a 401. scripts/check.mjs now accepts a tools
plugin with auth and no loader, as long as its config gives the provider
no npm and no models.
Run at 7cf6a5c merged onto main, in a sandbox HOME, with HTTPS_PROXY
pointed at a dead port:
- bun test packages/search1api scripts/check.test.mjs: 19 pass.
- node --test on the package's own tests: 16 pass.
- tests/host.integration.mjs against main magpie's host.js: 2 pass.
- bun test across the whole repo: 2647 pass, 0 fail. This needs 017f05c.
Before it, gcp-ai's fetch guard refused this package's loopback
fixtures in the shared bun process.
- bun scripts/check.mjs: all ok.
Broken by hand, each one red:
- Dropping the SAME_SESSION check before a refresh: 1 test.
- Never refreshing an expired token: 3 tests.
- Ignoring the apiKey option: 4 tests.
- Not red: dropping the second check, which catches a logout during an
in-flight refresh. The first check covers it in the logout test.
Real use:
- A sandbox magpie took the package with `plugin add`. `plugin list`
shows its 6 tools. `plugin login search1api 2` with a key showed
Providers as "Search1API · signed in as API key …-384 · no models
exposed".
- The search tool ran against the real api.search1api.com with a fake
key and got 401.
- OAuth discovery is live: oauth-protected-resource points to
clerk.s1.dev, which has a registration endpoint and S256.
Not tried:
- A real OAuth consent, or a search with a real key. There is no
Search1API account here.
Notes:
- The plugin reads the signed-in record from
`<directory>/plugin-auth.json` itself, since tools get no getAuth.
magpie writes that file by temp-and-rename, so a read never sees half a
write.
- magpie's login line says "its models are search1api/<model>" for a
provider with no models. That is magpie's wording, not this PR's.
Antigravity answers a system prompt that reads as Claude Code's or the
Claude Agent SDK's with a 429 "Resource has been exhausted", whatever
quota is left (xzplzpl on X). Tried with a real account, it matches
"x-anthropic-billing-header:" and "You are a Claude agent, built on
Anthropic's Claude Agent SDK", and lets the same prompt through with a
U+200B inside each. This middleware puts one after the first letter of
both words, in system text only (Anthropic system, Chat/Responses system
and developer messages, Responses instructions, Gemini
systemInstruction), and only in what an Antigravity account is sent: it
uses magpie's new onProvider hook (v0.1.1283), so a Claude subscription
or any other provider in the same routing group gets the prompt as the
agent wrote it. Options: extraWords, accounts, off. The README says the
ban risk and what happens if Google changes its match. After hexiaolv's
magpie-antigravity-cloak (MIT), which changes every request.
scripts/middleware.mjs: a case's "provider" runs the request on through
onProvider with ctx.provider, and expect_request is that try's body.
Run:
- HOME=$(mktemp -d) bun test: 1783 pass, 0 fail (the package's 12 cases
among them). bun scripts/check.mjs: every package ok.
- Real use: magpie built from e44b9aef3 in a sandbox HOME, a real
Antigravity account, this package added from its folder. Claude Code
2.1.302 `claude -p` on antigravity/gemini-3-flash answered; with
{"off": true} the same run got the 400. /v1/messages with the billing
line, the SDK line and Claude Code's three system blocks: 200 each on,
400 each off.
check.mjs now checks a plugin whose only hook is `tool`: each tool's name
is one an MCP client takes, and it has a description, args and execute.
It skips packages with magpie.gateway (routing strategies) and page-only
packages (magpie.page with no main), whose own tests check them.
middleware.mjs gains order() and checkStrategies(): a gateway plugin's
strategy is asked for an order the way magpie's gateway asks it
(internal/routes.Apply), falling back to the listed order on a throw or
an answer that isn't a permutation, and strategies.json cases are run
against it.
Run: HOME=$(mktemp -d) bun test (1554 pass, 0 fail) and
bun scripts/check.mjs (every package ok) at this tree with the three
packages that follow.
Run through Claude Code's ! (no terminal), every npm step printed the 2FA
link and failed with EOTP at once: npm waits for the browser only when it
can ask on a terminal. npm now reads from /dev/tty, so piping the script
to sh still works, and a run with no terminal says so before any npm step.
Run: with no terminal, --dry-run lists the four packages and the real run
stops with the message, exit 1, nothing asked of npm. Not run on a terminal
(that takes the owner's 2FA).
Finds from the registry, for origin/main, each package npm doesn't have
(first publish, then publish.yml as its Trusted Publisher with
--allow-publish) and each whose version npm lacks (its trust revoked and
made again with --allow-publish, then publish.yml dispatched). Runs npm 11
through npx, since npm trust needs 11.5.
Run: sh -n; --dry-run against the real registry lists opendesign 0.1.4 and
type4me 0.1.0 as new, zed 0.1.7 and zen-free 0.1.8 as behind, and leaves
no worktree behind. The trust-id parser was tried on sample JSON. The
publish and trust steps themselves need an owner's 2FA and weren't run.
A new package's first npm version can't go through trusted publishing
(a Trusted Publisher is set on a package that exists, with an owner's
2FA), so reviewed plugin PRs (#84 and others) sat unmerged until an owner
published by hand. Now publish.yml's dist job packs every package's
version (scripts/dist.mjs, npm pack --ignore-scripts) onto the dist
branch: tgz/<file> and index.json with each tarball's sha512. magpie
installs a @magpie-community package from there when npm doesn't have
the version. A new package without NPM_TOKEN is a notice, not a failed
run; a version npm refuses still fails it, now naming the stage-only
default of trusts made since 2026-09-03 and --allow-publish.
Run: node scripts/dist.mjs into an empty folder packed all 22 packages
(index.json 164K); the zed tarball's sha512 equals npm pack's integrity;
a second run packs nothing. The workflow itself is tried on main after
this push (workflow_dispatch).
Every publish run on main since 13:27 UTC 10-14 is red: opencode-zed-auth
0.1.7 and opencode-zen-free-auth 0.1.6 answer 404 because their Trusted
Publisher isn't set, and a new package (opendesign-auth, AstraFlow) can't be
created by OIDC at all. Each of those needed an org owner's OTP by hand.
npm tries OIDC first and falls back to the token in .npmrc, so publish.yml
now hands setup-node's NODE_AUTH_TOKEN the repository's NPM_TOKEN secret.
publish.sh publishes a new package when the token is there instead of
passing it by, and its errors say which of the two is missing or that the
token expired. The PR check now notes a new package instead of failing,
since the merge publishes it. README gains a Publishing section with the
one-time token setup.
Run: sh -n on both scripts; scripts/new-to-npm.sh against npm (every
package is on npm); scripts/publish.sh with GITHUB_ACTIONS=true and a fake
npm on PATH (zed-auth "new"): token -> published with the token, exit 0; no
token -> ::error naming it, exit 1; token refused -> ::error saying replace
the token, exit 1.
Not tried: a real publish with a token, since the secret doesn't exist yet.
magpie (cb406c84) lets a plugin add an agent it has no setup of its own
for. This one writes Aider's ~/.aider.conf.yml: the model under litellm's
openai/ prefix, magpie's /v1 and Aider's own key. check.mjs skips agent
packages as it does middleware; README gains an Agents section.
Run: bun test packages/aider (2 pass); bun scripts/check.mjs; the module
loaded through magpie's agentplug.Compile and its connect returned the
three keys. The same module, in a sandbox magpie, wired a real aider
0.86.2 that answered from a real DeepSeek account, and Disconnect put
the file back byte for byte.
Trusted publishing can't create a package, so #39's block-patterns,
merged before its first version was on npm, left every publish run on
main red after it (8 runs, the last 37781353941), and a real refused
publish would have hidden behind it. pr.yml runs bun test and check.mjs
on each pull request, and scripts/new-to-npm.sh names any package npm
doesn't know, so its first version is published by hand and its Trusted
Publisher set before the merge. The README's market section says so.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
try.sh runs magpie with env -i and a HOME pointing into the sandbox, so
the real magpie, its agents and its sign-ins are never touched. On
Windows that is no sandbox: magpie's home comes from USERPROFILE
(appdir.homeVar) and HOME is not read, so env -i leaves USERPROFILE
unset and magpie found no home at all — it stopped before doing anything
with "USERPROFILE is not set: magpie needs the home folder to find its
own files and the agents'", and scripts/try.sh was unusable on Windows.
The sandbox is given USERPROFILE="$sb" beside HOME, which is a no-op
elsewhere. A portable magpie.exe ignores both and can't be sandboxed
this way, which predates this.
.github/workflows/publish.yml runs the tests (in a throwaway HOME) and
scripts/publish.sh on each package.json change pushed to main, or by hand;
npm's OIDC exchange stands in for a token and an OTP. Every package now
names magpie-community/plugins' publish.yml as its trusted publisher on
npmjs.com, and gets the repository field npm checks it against.