Commit Graph
18 Commits
Author SHA1 Message Date
yetoneandMagiczerowxy 526c7853c3 page-chat 0.1.0: Magic_zero's chat page, with tests, a registry entry and check.mjs for a page's host part
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>
2026-10-29 09:07:44 +08:00
wang2 6188ab5be7 search1api 0.1.0: Search1API's six tools with API key or OAuth sign-in (#384)
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.
2026-10-25 17:53:00 +08:00
yetone 0a998a8a7f antigravity-cloak 0.1.0: Claude Code and Claude Desktop on an Antigravity account
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.
2026-10-18 01:15:12 +08:00
yetone b93c9eca8c scripts: check tools-only plugins, skip pages and routings, run strategies.json
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.
2026-10-16 02:57:19 +08:00
yetone c59ee33efe scripts/owner.sh: npm asks for 2FA on the terminal, and a run with none stops first
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).
2026-10-15 18:13:30 +08:00
yetone 80baa27570 scripts/owner.sh: an npm owner's first publishes and Trusted Publishers in one command
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.
2026-10-15 18:07:43 +08:00
yetone f5308cdb0f publish: every version is packed onto the dist branch, so a new plugin merges without waiting for npm
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).
2026-10-15 04:42:51 +08:00
yetone 4ef68fbf3f publish: an NPM_TOKEN secret publishes what trusted publishing can't, a new package's first version and one with no Trusted Publisher, so nobody publishes by hand
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.
2026-10-15 01:58:21 +08:00
yetone 6e720301aa agent-aider 0.1.0: Aider as a magpie agent plugin, the first of the new agent kind (#78)
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.
2026-10-10 22:52:47 +08:00
yetoneandClaude Opus 5.5 2b0b2d9401 ci: a pull request runs the tests and fails while a package in it isn't on npm yet (#52)
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>
2026-10-08 21:59:38 +08:00
如是 ea0d006a63 scripts/try.sh: the sandbox gets a USERPROFILE on Windows, where that is the home (#44)
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.
2026-10-08 13:47:19 +08:00
yetone 17f46b7a15 publish: a package npm refuses doesn't stop the ones after it — model-map 0.1.1 (no Trusted Publisher yet) answered 404 and trae 0.2.4, after it in the list, was never published 2026-10-06 02:27:34 +08:00
yetone d9236e976f middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon. 2026-10-05 20:49:42 +08:00
yetone cc20fcaba9 publish: a package npm has never seen no longer stops the rest — trusted publishing can't create a package, so trae-auth 0.1.0's PUT came back 404 (run 37104702928) and set -e would have left every package after it (workbuddy, zcode, zed) unpublished on their next bump. In Actions a new package is passed by with an error naming the way out (its first version by hand with scripts/publish.sh <otp>, then this workflow as its Trusted Publisher), the rest are published, and the run fails at the end naming it. Tried with a stubbed npm publish: zed bumped publishes after trae is passed by, exit 1. 2026-10-03 15:18:18 +08:00
yetone 8f25b63718 publish from GitHub Actions with npm's trusted publishing, no one-time password [skip ci]
.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.
2026-10-03 00:00:23 +08:00
yetone dbc1c301df publish: always to registry.npmjs.org, whatever ~/.npmrc names — with npmmirror as the registry (common in China) the publish went there and was refused (ENEEDAUTH), and npm view checked the mirror for what is published 2026-10-02 16:58:50 +08:00
yetone e2301c37ed scripts/publish.sh: publishes every package whose version isn't on npm yet, with one OTP for the lot 2026-09-30 21:23:08 +08:00
yetone 2578f471bb Scaffold: conventions for OpenCode provider plugins of coding-plan subscriptions, a hook checker and a sandboxed magpie runner 2026-09-30 16:55:58 +08:00