Files
plugins/packages
yetone 38594b5aee gemini-web 0.1.0: the Gemini web app, one streamed call to its own endpoint per request
@jtbbtnt54249 on X (11-18) asked for a Gemini web plugin: the community
@dorokuma/magpie-gemini-web is "太慢了根本用不了". The MCP in their
screenshot is a Gemini web "custom app" remote connector: Google's servers
call a public MCP URL, so it can't serve a local agent and is not a route.

Why the existing one is slow: it goes through a separate local Go backend
that fetches the XSRF token before every request, uploads prompts over
128KB as a file, sleeps 2s between retries, and holds replies behind a
tool-fence gate and a slot limiter.

This package calls gemini.google.com the way the app's page does:
- the page's tokens (SNlM0e, cfb2h, FdrFJe) are read from /app once and
  kept 15 minutes;
- each request is one POST to StreamGenerate, the whole request inline in
  a temporary chat (slot 45, nothing kept in history), read as it
  streams and given back as SSE or a whole completion;
- tools are asked for as <tool_call> text (prompt.mjs and openai.mjs from
  doubao-work) and given back as tool_calls;
- signed in: a Chrome profile of the plugin's own opens at Google's
  sign-in, the user signs in themselves, the google.com cookies are read
  with Storage.getCookies on the browser target (nothing attached to the
  page) and the window closes. Set-Cookie renewals are saved back with
  client.auth.set; RotateCookies every ten minutes; signed out, rotate,
  then reopen the profile headless, then ask for a sign-in;
- a visitor (no account) gets Google's visitor model;
- models from the account's own picker (otAQ7b), fallback marked;
- prompts over 600K characters get 413 before they are sent (measured:
  315K fine, 900K ignored the request, 1.8M refused with error 3); error 3
  is named as a refusal with its likely causes.

Run:
- HOME=$(mktemp -d) bun test packages/gemini-web on mote: 28 pass. The
  fixtures are real StreamGenerate replies (a signed-in "pong" served as
  4 Hydrogen, a visitor's rivers text with its real chunks) and a real
  otAQ7b list, with the location Google guessed scrubbed.
- Broken by hand: not sending `at` turns two tests red.
- Full suite on mote, HOME=$(mktemp -d) bun test at ea805ecc plus this change (before the root README line): 9091 pass, 20 skip, 0 fail.
- bun scripts/check.mjs: registry.json and gemini-web ok.
- Real, through the plugin's fetch from Bun on mote, as a visitor: three
  "pong" requests, first text at 14.0s (reads the page), 7.9s, 6.9s; a
  tool request came back as Echo {"text":"391"} with finish tool_calls.
  Signed in, in the app's own page: first text about 3.5s.

Not tried: a real Google sign-in through the plugin's window (Google may
refuse a browser with a DevTools port open), whether DBSC stops
RotateCookies, thinking output, paid models (4 Carbon, 4 Neon). Said in
the README.

First publish of a new package: publish.yml can't publish it (no trusted
publisher yet), so magpie installs it from the dist branch until the
owner publishes it once and adds the trust.
2026-11-19 14:14:50 +08:00
..
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