{"_id":"@agentxin-ai/plugin-sensitive-filter","_rev":"3-979bca08bbe195e3dbb3d38ca52ab07f","name":"@agentxin-ai/plugin-sensitive-filter","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.3":{"name":"@agentxin-ai/plugin-sensitive-filter","version":"0.0.3","author":{"url":"https://agentxinai.cn","name":"AgentXinAI"},"license":"AGPL-3.0","_id":"@agentxin-ai/plugin-sensitive-filter@0.0.3","maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"dist":{"shasum":"20d0d32379201452b333457e0cb25b19f11ff53d","tarball":"https://registry.npmjs.org/@agentxin-ai/plugin-sensitive-filter/-/plugin-sensitive-filter-0.0.3.tgz","fileCount":2,"integrity":"sha512-WZpfrm8ImJCSlbR7pyTfsHEz8F3CvbATZ+ZlpK1u1xPv3cwxG1KMn7D1eAVN7ylNRSS24egUSFBbZO1w/6+B1g==","signatures":[{"sig":"MEUCIQCxIdqeWssdUQeZfcwtU9irZsWi3DChEWDW6eWFc5CZMgIgWRhmZ3Tq3lSqWQa5mf5Xr4vjRw/Wp8H971CCzPkWjpA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5056},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","@agentxin-plugins-starter/source":"./src/index.ts"},"./package.json":"./package.json"},"_npmUser":{"name":"agentxin-ai","email":"1304040880@qq.com"},"repository":{"url":"git+https://github.com/agentxin-ai/agentxin-plugins.git","type":"git"},"_npmVersion":"10.9.4","description":"`@agentxin-ai/plugin-sensitive-filter` filters sensitive content for both input and output in two mutually exclusive modes:","directories":{},"_nodeVersion":"22.22.0","dependencies":{"tslib":"^2.3.0"},"_hasShrinkwrap":false,"peerDependencies":{"zod":"3.25.67","chalk":"4.1.2","@nestjs/common":"^11.1.6","@langchain/core":"0.3.72","@metad/contracts":"^3.8.1","@agentxin-ai/plugin-sdk":"^3.8.1"},"_npmOperationalInternal":{"tmp":"tmp/plugin-sensitive-filter_0.0.3_1773917395944_0.5063947820691193","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@agentxin-ai/plugin-sensitive-filter","version":"0.0.4","author":{"url":"https://agentxin.cn","name":"agentxinAI"},"license":"AGPL-3.0","_id":"@agentxin-ai/plugin-sensitive-filter@0.0.4","maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"dist":{"shasum":"c39607892a9324edeb69ae68e29b498c7414b71c","tarball":"https://registry.npmjs.org/@agentxin-ai/plugin-sensitive-filter/-/plugin-sensitive-filter-0.0.4.tgz","fileCount":14,"integrity":"sha512-RZ0rqVmsmjlJ/KRriCWctDec/RLcjOh/poa757/ReBbeLV09n4R2i1f5oCW69LDyJDiLK3Y8ZsAgrHLl8psXmQ==","signatures":[{"sig":"MEQCICywa94WEYZTNO/GguNubytnd6W4486q97bY0lwSRvQSAiB8hRJDnygCUCEC8iZe6rpv1mQ035SzbS8+GftH8KkBiQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":100488},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js","@xpert-plugins-starter/source":"./src/index.ts"},"./package.json":"./package.json"},"_npmUser":{"name":"agentxin-ai","email":"1304040880@qq.com"},"repository":{"url":"git+https://github.com/agentxin-ai/agentxin-plugins.git","type":"git"},"_npmVersion":"10.9.4","description":"`@xpert-ai/plugin-sensitive-filter` filters sensitive content for both input and output in two mutually exclusive modes:","directories":{},"_nodeVersion":"22.22.0","dependencies":{"tslib":"^2.3.0"},"_hasShrinkwrap":false,"peerDependencies":{"zod":"3.25.67","chalk":"4.1.2","@nestjs/common":"^11.1.6","@langchain/core":"0.3.72","@metad/contracts":"^3.8.1","@xpert-ai/plugin-sdk":"^3.8.1"},"_npmOperationalInternal":{"tmp":"tmp/plugin-sensitive-filter_0.0.4_1774330678322_0.3104687106268851","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@agentxin-ai/plugin-sensitive-filter","version":"0.0.5","author":{"name":"agentxinAI","url":"https://agentxin.cn"},"license":"AGPL-3.0","repository":{"type":"git","url":"git+https://github.com/agentxin-ai/agentxin-plugins.git"},"bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{"./package.json":"./package.json",".":{"@agentxin-plugins-starter/source":"./src/index.ts","types":"./dist/index.d.ts","import":"./dist/index.js","default":"./dist/index.js"}},"dependencies":{"tslib":"^2.3.0"},"peerDependencies":{"zod":"3.25.67","@agentxin-ai/plugin-sdk":"^3.8.1","chalk":"4.1.2","@langchain/core":"0.3.72","@nestjs/common":"^11.1.6","@metad/contracts":"^3.8.1"},"_id":"@agentxin-ai/plugin-sensitive-filter@0.0.5","description":"`@agentxin-ai/plugin-sensitive-filter` filters sensitive content for both input and output in two mutually exclusive modes:","homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-mRpT2G8xjxeqXxcxSaEs7u/3Wvr6zuwZyd+LJ3cBf2dVbz6rdeI8mMelE0ir/R14xDwjkRMpYcLdt5F6/Qy9ug==","shasum":"3a94b8f37eca860b413830ecd8ddd9bf4ccf4f16","tarball":"https://registry.npmjs.org/@agentxin-ai/plugin-sensitive-filter/-/plugin-sensitive-filter-0.0.5.tgz","fileCount":14,"unpackedSize":100527,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHIq3zmBF3NBiQu31uq3yMlzoUESWB4u8LW3Htp8Vp3lAiAWvN2tyr6hYNYErd8xGyBDGf/0eRLW2fzHwxUA6YXASw=="}]},"_npmUser":{"name":"agentxin-ai","email":"1304040880@qq.com"},"directories":{},"maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/plugin-sensitive-filter_0.0.5_1774575785245_0.26648899823243544"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-19T10:49:55.867Z","modified":"2026-03-27T01:43:05.910Z","0.0.3":"2026-03-19T10:49:56.092Z","0.0.4":"2026-03-24T05:37:58.496Z","0.0.5":"2026-03-27T01:43:05.402Z"},"bugs":{"url":"https://github.com/agentxin-ai/agentxin-plugins/issues"},"author":{"name":"agentxinAI","url":"https://agentxin.cn"},"license":"AGPL-3.0","homepage":"https://github.com/agentxin-ai/agentxin-plugins#readme","repository":{"type":"git","url":"git+https://github.com/agentxin-ai/agentxin-plugins.git"},"description":"`@agentxin-ai/plugin-sensitive-filter` filters sensitive content for both input and output in two mutually exclusive modes:","maintainers":[{"name":"agentxin-ai","email":"1304040880@qq.com"}],"readme":"# Sensitive Filter Middleware\n\n`@agentxin-ai/plugin-sensitive-filter` filters sensitive content for both input and output in two mutually exclusive modes:\n\n- `rule`: deterministic rules (`keyword` / `regex`)\n- `llm`: natural-language policy evaluation with rewrite-only enforcement\n\n## Lifecycle Hooks\n\n- `beforeAgent`: evaluates and optionally rewrites/blocks input\n- `wrapModelCall`: evaluates and optionally rewrites/blocks output\n- `afterAgent`: writes audit snapshot and sends matched alerts to configured WeCom group webhooks\n\n## Configuration\n\n### Top-level\n\n| Field | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `mode` | `'rule' \\| 'llm'` | Yes | `rule` | Select one mode. |\n| `rules` | `Array<Rule>` | Runtime-required in `rule` mode | `[]` | Business rules for `rule` mode. |\n| `caseSensitive` | `boolean` | No | `false` | Case-sensitive matching in `rule` mode. |\n| `normalize` | `boolean` | No | `true` | Whitespace normalization in `rule` mode. |\n| `llm` | `object` | Runtime-required in `llm` mode | - | LLM mode configuration. |\n| `wecom` | `object` | No | disabled when no groups | WeCom webhook notification config. |\n\n### WeCom Notify (`wecom`)\n\n| Field | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enabled` | `boolean` | No | `true` | Turn notification on/off. |\n| `groups` | `Array<{webhookUrl}>` | Runtime-required for sending | `[]` | One or more WeCom group webhook targets. |\n| `timeoutMs` | `number` | No | `10000` | Per webhook request timeout (max `120000`). |\n\n### Rule Mode (`mode=rule`)\n\n`rules[]` fields:\n\n| Field | Type | Required | Description |\n| --- | --- | --- | --- |\n| `id` | `string` | No | Auto-generated when empty (`rule-{index+1}`). |\n| `pattern` | `string` | Yes | Match pattern. |\n| `type` | `'keyword' \\| 'regex'` | Yes | Match type. |\n| `scope` | `'input' \\| 'output' \\| 'both'` | Yes | Match phase. |\n| `severity` | `'high' \\| 'medium'` | Yes | Conflict priority (`high` > `medium`). |\n| `action` | `'block' \\| 'rewrite'` | Yes | Hit action. |\n| `replacementText` | `string` | No | Optional replacement/block message. |\n\nRuntime validation requires at least one valid rule with:\n`pattern/type/action/scope/severity`.\n\n### LLM Mode (`mode=llm`)\n\n| Field | Type | Required (runtime) | Default | Description |\n| --- | --- | --- | --- | --- |\n| `model` | `ICopilotModel` | Yes | - | Policy evaluation model. |\n| `scope` | `'input' \\| 'output' \\| 'both'` | Yes | - | Evaluation phase scope. |\n| `rulePrompt` | `string` | Yes | - | Natural-language policy description. |\n| `rewriteFallbackText` | `string` | No | `[已过滤]` | Fallback rewrite text. |\n| `timeoutMs` | `number` | No | unlimited | Per-evaluation timeout (max `120000`). |\n\nNotes:\n\n- The middleware internally enforces rewrite-only behavior for LLM hits.\n- Structured output method is internally adaptive; the UI does not expose method selection.\n- Internal decision traces are muted from chat output.\n- Notifications are sent only when there is at least one matched record.\n\n## Backward Compatibility\n\nHistorical configurations may still include `generalPack`.\n\nCurrent behavior:\n\n- The field is ignored.\n- Execution continues.\n- Rule/LLM behavior is driven only by current supported fields.\n\n## Minimal LLM Example\n\n```json\n{\n  \"mode\": \"llm\",\n  \"llm\": {\n    \"model\": { \"provider\": \"openai\", \"model\": \"gpt-4o-mini\" },\n    \"scope\": \"both\",\n    \"rulePrompt\": \"If content contains ID cards, phone numbers, bank cards, or home addresses, rewrite it into a privacy-safe response.\",\n    \"rewriteFallbackText\": \"[已过滤]\",\n    \"timeoutMs\": 3000\n  }\n}\n```\n\n## Troubleshooting\n\n1. No effect in `rule` mode:\n- Ensure at least one valid rule contains `pattern/type/action/scope/severity`.\n\n2. No effect in `llm` mode:\n- Ensure `model/scope/rulePrompt` are all present.\n\n3. Unexpected rewrites in LLM mode:\n- Check audit records or runtime logs for entries with `source=error-policy` and `reason` starting with `llm-error:`.\n\n## Validation Commands\n","readmeFilename":"README.md"}