{"versions":{"0.0.0-stage":{"name":"@magpie-community/middleware-param-override","version":"0.0.0-stage","_id":"@magpie-community/middleware-param-override@0.0.0-stage","stub":true,"maintainers":[{"name":"anonymous","email":"yetoneful@gmail.com"}],"dist":{"shasum":"b5df36c265ea9dbed66cb63ee5f555a8f2b4016b","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@magpie-community/middleware-param-override/-/middleware-param-override-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-vo/C7GJP5U+8GKJ5pRWVxkiA7x8S41vUg0cQ2nrKqplXOabssO4Ixa15nCgfcniFhPOBXU/ki3FiO6UEbVCl2Q==","signatures":[{"sig":"MEQCIAonnzyLCAfBksOWszGwyq4fgCq6vywPMUf5H0kYK4BKAiBb6FQlb+8Q1opqqIU9MRB0rI5f9aLahhYLyS2Dlt5OCQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":365,"size":383},"_npmUser":{"name":"anonymous","email":"yetoneful@gmail.com"},"description":"Temporary package placeholder for staged publishing","directories":{},"_cnpmcore_publish_time":"2026-10-05T18:02:35.858Z","publish_time":1791223355858,"_hasShrinkwrap":false,"_source_registry_name":"default","contributors":[]},"0.1.0":{"_id":"@magpie-community/middleware-param-override@0.1.0","bugs":{"url":"https://github.com/magpie-community/plugins/issues"},"dist":{"shasum":"ff3574583a2c4b3a1af062a65f20bc15fa5fdbbb","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@magpie-community/middleware-param-override/-/middleware-param-override-0.1.0.tgz","fileCount":3,"integrity":"sha512-Y/ZjfsJAW1YT/n+R0O/jRDr7gH34Lv1YK9Z6TG0p8+Eo+Y4G/G99Nj/5K7MGV7YvxW5Zt40OzqELE9yfrI5jIQ==","signatures":[{"sig":"MEUCIBWplmxqMqJutatM31DcsdbY8EkWaKYKCLQmBWPOZcBSAiEApX4VLnw1KI08F01uHNLrYQm7Kki95THSzvlYnKWIKvE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDn3LsjRDOWOCP6OsHetVikrvQWdVsuk/WOLj5FkeBSswIhAJlVIl/CG89xKHsW+pfZyGist3bzsL/ZHy3mk4zESjrI"}],"unpackedSize":16217,"size":5761},"name":"@magpie-community/middleware-param-override","type":"module","magpie":{"options":{"operations":[{"mode":"set","path":"max_tokens","value":32000,"conditions":[{"mode":"gt","path":"max_tokens","value":32000}]},{"mode":"delete","path":"temperature","conditions":[{"mode":"contains","path":"model","value":"reasoner"}]}]},"middleware":"./param-override.middleware.js"},"gitHead":"719ba0c6212999f3f15a7d3d1fc85dfdc06263a8","license":"MIT","version":"0.1.0","_npmUser":{"name":"anonymous","email":"yetoneful@gmail.com"},"homepage":"https://github.com/magpie-community/plugins#readme","keywords":["magpie","magpie-middleware","new-api","param-override","llm-gateway"],"repository":{"url":"git+https://github.com/magpie-community/plugins.git","type":"git","directory":"packages/param-override"},"_npmVersion":"10.9.4","description":"New API's param_override (参数覆盖) as magpie gateway middleware: set, delete, move and rewrite any field of what agents send, with conditions","directories":{},"maintainers":[{"name":"anonymous","email":"yetoneful@gmail.com"}],"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/middleware-param-override_0.1.0_1791223451908_0.9728043257194638"},"_cnpmcore_publish_time":"2026-10-05T18:04:12.000Z","publish_time":1791223452000,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"0.1.0"},"name":"@magpie-community/middleware-param-override","time":{"created":"2026-10-06T12:02:46.101Z","modified":"2026-10-06T12:02:47.002Z","0.0.0-stage":"2026-10-05T18:02:35.858Z","0.1.0":"2026-10-05T18:04:12.000Z"},"readme":"# @magpie-community/middleware-param-override\n\nNew API's **参数覆盖** (a channel's `param_override`) as [magpie](https://usemagpie.ai) gateway middleware. It sets, deletes, moves and rewrites any field of the requests agents send through magpie, whichever provider serves them. The options are New API's JSON as it is, so you can paste a `param_override` from New API unchanged.\n\nInstall it from magpie's **Plugins › Discover**, or with `magpie plugin add @magpie-community/middleware-param-override`. Then set its options under **Plugins › Installed › Options**, or with `magpie plugin options param-override '<json>'`.\n\n## Options\n\nThere are two forms, as in New API:\n\n```json\n{ \"temperature\": 0.2, \"max_tokens\": 8000 }\n```\n\nEach key is set on the body as it is.\n\n```json\n{ \"operations\": [\n  { \"path\": \"max_tokens\", \"mode\": \"set\", \"value\": 32000,\n    \"conditions\": [{ \"path\": \"max_tokens\", \"mode\": \"gt\", \"value\": 32000 }] },\n  { \"path\": \"temperature\", \"mode\": \"delete\",\n    \"conditions\": [{ \"path\": \"model\", \"mode\": \"contains\", \"value\": \"reasoner\" }] },\n  { \"mode\": \"return_error\", \"value\": { \"message\": \"opus is not allowed here\", \"status_code\": 403 },\n    \"conditions\": [{ \"path\": \"model\", \"mode\": \"contains\", \"value\": \"opus\" }] }\n] }\n```\n\nThe operations run in order. Keys set beside `operations` are applied first.\n\n| Field | |\n| --- | --- |\n| `path` | A gjson path: `a.b.0`. `messages.-1` counts from the end, `tools.*.name` matches every item, and `\\.` is a dot inside a key. |\n| `mode` | `set` (`keep_origin`: only when missing), `delete`, `move` / `copy` (`from`, `to`), `prepend` / `append` (arrays joined, strings joined, objects merged; `keep_origin` keeps keys already there), `trim_prefix`, `trim_suffix`, `ensure_prefix`, `ensure_suffix`, `trim_space`, `to_lower`, `to_upper`, `replace` / `regex_replace` (`from`, `to`; Go's `${1}` works), `return_error`, `prune_objects` |\n| `value` | What to set, join or trim. For `return_error`, a message or `{message, status_code}`; the agent gets the error in its own API's shape. For `prune_objects`, a `type` or `{type, where, conditions, logic, recursive}`. |\n| `conditions` | `[{path, mode, value, invert, pass_missing_key}]`, where `mode` is `full`, `prefix`, `suffix`, `contains`, `gt`, `gte`, `lt` or `lte`. A path is looked up in the body first, then in the request: `model`, `request_path`, `protocol` (`anthropic`, `chat`, `responses`, `gemini`), `agent`, `stream`. |\n| `logic` | `OR` (New API's default) or `AND`. |\n\nSome of New API's modes have nothing to act on here and are left out: the header modes (`set_header`, `pass_headers`…), `sync_fields`, and conditions on retries, users and groups. The middleware sees only the body.\n\nUnlike New API, an operation that can't apply is skipped (a `move` from a missing path, `trim_prefix` on a number) and the request goes on. If the middleware itself fails, magpie sends the request as it came.\n\n## Recipes\n\n- Cap `max_tokens` for a provider with a lower limit: the first example above.\n- Drop a parameter a provider refuses: `{\"path\": \"tools.*.input_examples\", \"mode\": \"delete\"}`.\n- Strip a vendor prefix from model names: `{\"path\": \"model\", \"mode\": \"trim_prefix\", \"value\": \"openai/\"}`.\n- Keep an agent off a model: `return_error` with a `model` condition.\n- Remove old thinking blocks: `{\"path\": \"messages\", \"mode\": \"prune_objects\", \"value\": \"thinking\"}`.\n\n中文：New API 的「参数覆盖」，作为 magpie 网关中间件。配置是 New API 的同一份 JSON，可以原样粘贴过来。","users":{}}