Commit Graph
3 Commits
Author SHA1 Message Date
Xudong Guo e08e420581 check: accept quota-only providers without model transport (#654)
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).
2026-11-03 10:49:03 +08:00
yetone eaca1cf4f1 check: parse registry.json and hold each entry to what magpie reads (#612)
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.
2026-11-02 05:57:45 +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