onEvent masked an Anthropic delta, a Responses delta and a Chat chunk, but had no branch for Gemini's own shape (candidates[].content.parts[].text) — while onResponse right below it did. So with replies: true, a word the user asked to keep out of replies was masked in every API but a streamed Gemini one, where it went to the client untouched. A case covers it in both directions: a streamed Gemini reply in its own place (and a part that isn't text left alone), and a whole one. It fails on 0.1.0 — "acme Inc" reaches the client — and passes here. The reply is what the option promises, so a filter that silently skips one of the four APIs magpie serves is a hole rather than a missing feature. Co-authored-by: TryWorld2026 <tryworld@users.noreply.github.com>
15 lines
753 B
JSON
15 lines
753 B
JSON
{
|
|
"name": "@magpie-community/middleware-word-guard",
|
|
"version": "0.1.1",
|
|
"description": "New API's sensitive-word filter (敏感词过滤) as magpie gateway middleware: turn away or mask words and patterns in what agents send, and in replies",
|
|
"type": "module",
|
|
"files": ["word-guard.middleware.js", "README.md"],
|
|
"keywords": ["magpie", "magpie-middleware", "new-api", "sensitive-words", "guardrails", "llm-gateway"],
|
|
"license": "MIT",
|
|
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/word-guard" },
|
|
"magpie": {
|
|
"middleware": "./word-guard.middleware.js",
|
|
"options": { "words": ["project-codename"], "patterns": [], "action": "reject", "check": "last" }
|
|
}
|
|
}
|