diff --git a/README.md b/README.md
index 04c2326..b0a07fd 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,7 @@ These packages aren't OpenCode plugins. magpie runs them in its gateway, on the
| [system-prompt](packages/system-prompt) | Your own system prompt on every request, or on some agents' or models', in each API's own place |
| [word-guard](packages/word-guard) | New API's 敏感词过滤: turn away or mask words and patterns in what users send, and in replies |
| [think-tags](packages/think-tags) | Take `…` out of a reply's text, or put a Chat reply's `reasoning_content` into it (`thinking_to_content`) |
+| [antigravity-cloak](packages/antigravity-cloak) | Claude Code and Claude Desktop on Antigravity: break the words Antigravity turns their system prompt away for, in what Antigravity alone is sent |
| [codex-history](packages/codex-history) | Opt-in Responses history compatibility after switching providers: remove historical ciphertext and optional item IDs while preserving readable content and tool-call pairing |
```sh
diff --git a/packages/antigravity-cloak/README.md b/packages/antigravity-cloak/README.md
new file mode 100644
index 0000000..9230f1d
--- /dev/null
+++ b/packages/antigravity-cloak/README.md
@@ -0,0 +1,33 @@
+# @magpie-community/middleware-antigravity-cloak
+
+Claude Code and Claude Desktop on an Antigravity account, as [magpie](https://usemagpie.ai) gateway middleware.
+
+Antigravity answers a request whose system prompt reads as Claude Code's or the Claude Agent SDK's (which Claude Desktop's chats use) with `429 Resource has been exhausted`, however much quota is left. magpie shows it as a 400 that says so. Tried with a real account, Antigravity matches two pieces of the prompt:
+
+- Claude Code's billing line, `x-anthropic-billing-header: …`;
+- `You are a Claude agent, built on Anthropic's Claude Agent SDK`.
+
+The same prompt goes through when each has a zero-width space (U+200B) inside it. This middleware puts one after the first letter of `x-anthropic-billing-header` and `Claude Agent SDK`, in the system prompt only, and only in what an Antigravity account is sent. Every other provider, a Claude subscription above all, gets the prompt as the agent wrote it, even in a routing group that tries Antigravity first. The model reads the words as before.
+
+It needs a magpie with the `onProvider` hook (v0.1.1283 or later): an older magpie loads it and never calls it, so requests go as they came.
+
+Install it from magpie's **Plugins › Discover**, or with `magpie plugin add @magpie-community/middleware-antigravity-cloak`.
+
+## Before you turn it on
+
+- This changes what Google is sent so that a request it means to refuse isn't refused. It may be against Antigravity's terms, and Google can ban the account for it. Use it on an account you can afford to lose.
+- Google can change what it matches at any time. Then the refusal comes back, and magpie may no longer recognise it as this refusal: it can read as a real quota running out and rest the account. If that happens, add the new words to `extraWords`, or turn the plugin off.
+
+## Options
+
+```json
+{ "extraWords": [], "accounts": ["antigravity"], "off": false }
+```
+
+- `extraWords`: more words to break the same way, matched whatever their case.
+- `accounts`: the subscriptions it acts on, by kind. `antigravity` is the default.
+- `off`: leave every request as it came.
+
+中文:Antigravity 看到 Claude Code / Claude Agent SDK 的系统提示词会回一个假的 429。这个中间件只在发给 Antigravity 账号的请求里,往 `x-anthropic-billing-header` 和 `Claude Agent SDK` 里插一个零宽空格,其他供应商(尤其是 Claude 订阅)收到的提示词不变。这样做可能违反 Antigravity 的条款,账号有被封的风险,请只用在可以承受损失的账号上。需要 magpie v0.1.1283 或更新版本。
+
+After [hexiaolv/magpie-antigravity-cloak](https://github.com/hexiaolv/magpie-antigravity-cloak) (MIT), which breaks a longer list of words in every request, whatever provider it goes to.
diff --git a/packages/antigravity-cloak/antigravity-cloak.middleware.js b/packages/antigravity-cloak/antigravity-cloak.middleware.js
new file mode 100644
index 0000000..5c413a2
--- /dev/null
+++ b/packages/antigravity-cloak/antigravity-cloak.middleware.js
@@ -0,0 +1,77 @@
+// Antigravity answers a request whose system prompt reads as Claude Code's
+// or the Claude Agent SDK's with a 429 "Resource has been exhausted", which
+// isn't about the account's quota at all. Tried with a real account, it
+// matches these words in the system prompt:
+//
+// "x-anthropic-billing-header:" Claude Code's billing line
+// "You are a Claude agent, built on Anthropic's Claude Agent SDK"
+//
+// and lets the same prompt through with a zero-width space (U+200B) inside
+// each. This middleware puts one after the first letter of each word in
+// what Antigravity alone is sent (onProvider, ctx.provider.account): every
+// other provider, a Claude subscription above all, gets the prompt as the
+// agent wrote it. The model reads the words as before.
+//
+// {"extraWords": [], "accounts": ["antigravity"], "off": false}
+//
+// extraWords are more words to break the same way, should Google match
+// others; accounts are the subscriptions' kinds it acts on.
+//
+// After hexiaolv's magpie-antigravity-cloak (MIT), which does the same to
+// every request whatever provider it goes to.
+
+export const words = ["x-anthropic-billing-header", "Claude Agent SDK"]
+
+const zwsp = ""
+
+export function onProvider(body, ctx) {
+ const o = ctx.options || {}
+ if (o.off) return
+ const accounts = Array.isArray(o.accounts) && o.accounts.length ? o.accounts : ["antigravity"]
+ if (!accounts.includes(ctx.provider?.account)) return
+ const list = words.concat(Array.isArray(o.extraWords) ? o.extraWords.filter((w) => typeof w === "string" && w.length > 1) : [])
+ const cloak = cloaker(list)
+ let changed = false
+ const text = (s) => {
+ if (typeof s !== "string") return s
+ const t = cloak(s)
+ if (t !== s) changed = true
+ return t
+ }
+ switch (ctx.protocol) {
+ case "anthropic":
+ body.system = typeof body.system === "string" ? text(body.system) : parts(body.system, text)
+ break
+ case "chat":
+ if (Array.isArray(body.messages)) for (const m of body.messages) system(m, text)
+ break
+ case "responses":
+ body.instructions = text(body.instructions)
+ if (Array.isArray(body.input)) for (const m of body.input) system(m, text)
+ break
+ case "gemini":
+ for (const k of ["systemInstruction", "system_instruction"]) if (body[k]) parts(body[k].parts, text)
+ break
+ }
+ return changed ? body : undefined
+}
+
+// a system or developer message's text, a string or parts
+function system(m, text) {
+ if (!m || (m.role !== "system" && m.role !== "developer")) return
+ m.content = typeof m.content === "string" ? text(m.content) : parts(m.content, text)
+}
+
+function parts(list, text) {
+ if (Array.isArray(list)) for (const p of list) if (p && typeof p.text === "string") p.text = text(p.text)
+ return list
+}
+
+// cloaker breaks every word of list where it appears, whatever its case
+function cloaker(list) {
+ const res = list.map((w) => new RegExp(w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "gi"))
+ return (s) => {
+ for (const re of res) s = s.replace(re, (m) => m[0] + zwsp + m.slice(1))
+ return s
+ }
+}
diff --git a/packages/antigravity-cloak/antigravity-cloak.test.mjs b/packages/antigravity-cloak/antigravity-cloak.test.mjs
new file mode 100644
index 0000000..f2a37e2
--- /dev/null
+++ b/packages/antigravity-cloak/antigravity-cloak.test.mjs
@@ -0,0 +1,4 @@
+import * as mod from "./antigravity-cloak.middleware.js"
+import { check } from "../../scripts/middleware.mjs"
+
+check(import.meta.dir, mod)
diff --git a/packages/antigravity-cloak/cases.json b/packages/antigravity-cloak/cases.json
new file mode 100644
index 0000000..02ffa32
--- /dev/null
+++ b/packages/antigravity-cloak/cases.json
@@ -0,0 +1,14 @@
+[
+ {"name": "Anthropic: Claude Code's blocks, to Antigravity", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "request": {"model": "m", "system": [{"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}, {"type": "text", "text": "You are a Claude agent, built on Anthropic's Claude Agent SDK.", "cache_control": {"type": "ephemeral"}}], "messages": [{"role": "user", "content": "Claude Agent SDK"}]}, "expect_request": {"model": "m", "system": [{"type": "text", "text": "x\u200b-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}, {"type": "text", "text": "You are a Claude agent, built on Anthropic's C\u200blaude Agent SDK.", "cache_control": {"type": "ephemeral"}}], "messages": [{"role": "user", "content": "Claude Agent SDK"}]}},
+ {"name": "Anthropic: the same to a Claude subscription stays as it was", "provider": {"id": "c", "name": "Claude", "account": "claude", "model": "claude-sonnet-4-5"}, "request": {"model": "m", "system": [{"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}, {"type": "text", "text": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}], "messages": []}},
+ {"name": "Anthropic: an API key, no account, stays as it was", "provider": {"id": "k", "name": "Key", "model": "m"}, "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK.", "messages": []}},
+ {"name": "Anthropic: a string system, any case", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "request": {"model": "m", "system": "X-Anthropic-Billing-Header: a\nbuilt on the claude agent sdk"}, "expect_request": {"model": "m", "system": "X\u200b-Anthropic-Billing-Header: a\nbuilt on the c\u200blaude agent sdk"}},
+ {"name": "Anthropic: no words, nothing changed", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "request": {"model": "m", "system": "You code.", "messages": []}},
+ {"name": "Chat: system and developer messages, not the user's", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "ctx": {"protocol": "chat"}, "request": {"model": "m", "messages": [{"role": "system", "content": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}, {"role": "developer", "content": [{"type": "text", "text": "x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]}, {"role": "user", "content": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}, "expect_request": {"model": "m", "messages": [{"role": "system", "content": "You are a Claude agent, built on Anthropic's C\u200blaude Agent SDK."}, {"role": "developer", "content": [{"type": "text", "text": "x\u200b-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]}, {"role": "user", "content": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}},
+ {"name": "Responses: instructions and a system input item", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "ctx": {"protocol": "responses"}, "request": {"model": "m", "instructions": "You are a Claude agent, built on Anthropic's Claude Agent SDK.", "input": [{"role": "system", "content": [{"type": "input_text", "text": "x-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]}, {"role": "user", "content": [{"type": "input_text", "text": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}]}, "expect_request": {"model": "m", "instructions": "You are a Claude agent, built on Anthropic's C\u200blaude Agent SDK.", "input": [{"role": "system", "content": [{"type": "input_text", "text": "x\u200b-anthropic-billing-header: cc_version=2.1.0.abc; cc_entrypoint=cli; cch=1a2b3;"}]}, {"role": "user", "content": [{"type": "input_text", "text": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}]}},
+ {"name": "Gemini: systemInstruction", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "ctx": {"protocol": "gemini"}, "request": {"systemInstruction": {"parts": [{"text": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}]}, "contents": []}, "expect_request": {"systemInstruction": {"parts": [{"text": "You are a Claude agent, built on Anthropic's C\u200blaude Agent SDK."}]}, "contents": []}},
+ {"name": "extraWords are broken too", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "options": {"extraWords": ["Claude Code"]}, "request": {"model": "m", "system": "You are Claude Code."}, "expect_request": {"model": "m", "system": "You are C\u200blaude Code."}},
+ {"name": "accounts says which subscriptions", "provider": {"id": "g", "name": "Gemini", "account": "gemini", "model": "m"}, "options": {"accounts": ["gemini"]}, "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}, "expect_request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's C\u200blaude Agent SDK."}},
+ {"name": "off leaves it", "provider": {"id": "7c1958d885953cd3", "name": "Antigravity", "account": "antigravity", "model": "gemini-3-flash"}, "options": {"off": true}, "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}},
+ {"name": "onRequest isn't there: before routing nothing is changed", "request": {"model": "m", "system": "You are a Claude agent, built on Anthropic's Claude Agent SDK."}}
+]
diff --git a/packages/antigravity-cloak/package.json b/packages/antigravity-cloak/package.json
new file mode 100644
index 0000000..373f970
--- /dev/null
+++ b/packages/antigravity-cloak/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "@magpie-community/middleware-antigravity-cloak",
+ "version": "0.1.0",
+ "description": "magpie gateway middleware: Antigravity stops turning Claude Code's and the Claude Agent SDK's system prompts away, and no other provider's request is changed",
+ "type": "module",
+ "files": ["antigravity-cloak.middleware.js", "README.md"],
+ "keywords": ["magpie", "magpie-middleware", "antigravity", "claude-code", "llm-gateway"],
+ "license": "MIT",
+ "repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/antigravity-cloak" },
+ "magpie": {
+ "middleware": "./antigravity-cloak.middleware.js",
+ "options": { "extraWords": [] }
+ }
+}
diff --git a/registry.json b/registry.json
index ede12ee..af14824 100644
--- a/registry.json
+++ b/registry.json
@@ -48,6 +48,8 @@
"summary": { "en": "New API's sensitive-word filter: turn away or mask words and patterns in what you send, and in replies.", "zh": "New API 的敏感词过滤:拒绝或替换你发出的内容和回复里的词与正则。" } },
{ "package": "@magpie-community/middleware-think-tags", "name": "Think Tags", "kind": "middleware", "community": true,
"summary": { "en": "Take a model's … out of its reply's text, or put a Chat reply's reasoning into it.", "zh": "去掉回复正文开头的 …,或把 Chat 回复的思考内容放进正文。" } },
+ { "package": "@magpie-community/middleware-antigravity-cloak", "name": "Antigravity Cloak", "kind": "middleware", "community": true,
+ "summary": { "en": "Claude Code and Claude Desktop on an Antigravity account: the words Antigravity refuses their system prompt for are broken up, in what Antigravity alone is sent.", "zh": "让 Claude Code 和 Claude Desktop 能用 Antigravity 账号:只在发给 Antigravity 的请求里拆开它据以拒绝系统提示词的那几个词。" } },
{ "package": "@magpie-community/middleware-codex-history", "name": "Codex History Filter", "kind": "middleware", "community": true,
"summary": { "en": "Opt-in, per-provider Codex Responses history filtering after switching providers. Preserves readable content and tool-call pairing; no model probes.", "zh": "按供应商开关 Codex Responses 历史过滤,缓解切换上游后的密文和历史 ID 兼容问题;保留正文与工具配对,不运行模型检测。" } },
{ "package": "@magpie-community/agent-aider", "name": "Aider", "kind": "agent", "community": true,
diff --git a/scripts/middleware.mjs b/scripts/middleware.mjs
index bd28b95..911c1f7 100644
--- a/scripts/middleware.mjs
+++ b/scripts/middleware.mjs
@@ -1,6 +1,8 @@
// Runs a gateway middleware's cases the way magpie's gateway calls it: one
// ctx for the request's hooks (so ctx.state carries over), each body a fresh
// copy of its JSON, undefined keeping what came in, null dropping an event.
+// A case's provider is the one the request is tried on (ctx.provider): its
+// request goes on through onProvider, and what it expects is that try's.
// The same cases.json runs in magpie's own JavaScript engine (moejs), so a
// middleware is checked in both.
import { readFileSync } from "node:fs"
@@ -25,6 +27,10 @@ export async function run(mod, c) {
const r = m.onRequest ? await m.onRequest(copy(c.request), ctx) : undefined
if (rejected) out.reject = rejected
else out.request = r === undefined ? c.request : copy(r)
+ if (!rejected && c.provider && m.onProvider) {
+ const p = await m.onProvider(copy(out.request), { ...ctx, provider: c.provider })
+ if (p !== undefined && p !== null) out.request = copy(p)
+ }
}
if (c.events) {
out.events = []