Files
plugins/packages/privacy-gate/docs/operations.md
T
Muyang da8b8d71f3 privacy-gate: release 0.3.0 with branded bilingual docs (#798)
privacy-gate 0.3.0: branded bilingual docs, ShyPie icon and README.

Installs with `magpie plugin add @magpie-community/middleware-privacy-gate`
(from this repo's dist index until npm has the package). Names the
built-in "JS gateway plugins" / "JS 网关插件" (id `middleware`). Icons
are a pie, a shield and a gold chevron, with no bird. magpie.icon points
at packages/privacy-gate/assets/shypie-icon.svg. The middleware code
(privacy-gate.middleware.js) is unchanged since e0a4548a.

Reviewed at 85dbd121b833017982d0a97a2f3fab50be98caab. The last round
(67ae63c3b..85dbd121b) changed only docs/operations.md:10 (ends the
sentence) and the aria-label of the two shypie-icon SVGs ("with a gold
chevron").

Run at 85dbd121b on mote (macOS), Bun 1.4.2, HOME=$(mktemp -d):
- bun test packages/privacy-gate: 62 pass, 0 fail.
- bun scripts/check.mjs privacy-gate: ok, exit 0.
- bun scripts/check.mjs (whole repo): exit 0.
- bun test (root): 6449 pass, 20 skip, 0 fail, 472 files.
- npm pack --dry-run: 12 files, version 0.3.0.
- git merge-tree with origin/main ab0d3fe54: clean.

Not tried: installing 0.3.0 into a running magpie (dist has 0.1.0 only
until this merges). No mover or min in yetone/magpie references it.
2026-11-07 05:56:05 +08:00

4.2 KiB

ShyPie

Operations

Installation, configuration, verification and troubleshooting for the Magpie middleware.

Install

magpie plugin add @magpie-community/middleware-privacy-gate
magpie plugin

Confirm that Magpie's built-in JS gateway plugins plugin is on (Settings → Plugins → Built-in, id middleware). If it is off, no middleware runs.

For a gateway where only Magpie-routed DSH traffic should carry PII as text:

{
  "binaryPolicy": "guide",
  "allowModels": ["deepseek/*", "copilot/*"],
  "localModels": ["ollama/*", "lmstudio/*"],
  "localProviders": ["ollama", "lmstudio"],
  "guideTools": []
}

Use "binaryPolicy": "fail" if you want a hard 403 instead of a withhold-and- prompt response.

guideTools should stay empty unless a matching local MCP extractor is actually configured for the agent. The middleware cannot execute a tool; it only names it in the guide prompt.

Verify

  1. Save options:

    magpie plugin options privacy-gate '{"binaryPolicy":"guide"}'
    magpie plugin
    
  2. Send a request with an image part to a non-local model.

    • guide: HTTP 200, the model asks how to process the file locally, and no image bytes appear at the provider.
    • fail: HTTP 403 and a privacy-gate: message.
  3. Send a text-only request through the same model. It should pass.

  4. Send a request whose text contains a 600-character base64 run. It should be rejected with a BLOB message even if there is no image part.

  5. Check Magpie's plugin log for counts and the usage line. The middleware never logs request content — only provider/model/status/blocked counters.

Troubleshooting

I get a 403 for an image

Expected in fail mode. Either extract the image locally and send text, or set binaryPolicy: "guide" so the model receives metadata and a local-processing prompt instead.

Guide mode returns 200 but the model cannot see the file

Correct. The middleware never forwards the bytes. The model must use a local MCP/extractor that the agent has configured. Without one, the response is advice, not extraction.

An image reaches a local but non-local provider

Set both localModels and localProviders; with only localModels, onProvider blanks the content rather than sending it.

A legitimate request is rejected with BLOB

A long hash, minified line or base64-ish text can exceed the 400-character threshold. Raise blobBase64Chars / blobHexChars deliberately and understand that a larger document can then pass. Do not disable the gate.

Guide mode returns a MIME-looking string that is not a MIME

Known open issue #795: the guide prompt may carry a clipped long media_type prefix. The binary bytes are still withheld; this is metadata-only.

The request went through even though the gate is on

Check the Magpie log for onRequest: took too long. Magpie drops a hook after 250 ms and forwards the original request. This is the engine's fail-open behavior, tracked in magpie#5305. The middleware's own budgets reduce the chance of a timeout but cannot change that outcome.

Update and rollback

Update through Magpie's plugin manager (magpie plugin update) and re-check the saved options after a version change.

To roll back to the strictest behavior, remove the options ({}) or set binaryPolicy: fail and clear localModels/localProviders. Removing the plugin leaves agents without the structural check; text masking is unaffected.

Companion deployment

The DSH half is @shypie_privacy/dsh-privacy-gate 0.3.0. It performs local image/PDF extraction before the DSH transcript and enforces the DSH llm/stream egress guard. This Magpie gate then covers every other agent behind the same gateway.

Support