npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

plugin-sensitive-filter

v0.1.6

Published

`plugin-sensitive-filter-xr` filters sensitive content for both input and output in two mutually exclusive modes:

Downloads

567

Readme

Sensitive Filter Middleware

plugin-sensitive-filter-xr filters sensitive content for both input and output in two mutually exclusive modes:

  • rule: deterministic rules (keyword / regex)
  • llm: natural-language policy evaluation with rewrite-only enforcement

Lifecycle Hooks

  • beforeAgent: evaluates and optionally rewrites/blocks input
  • wrapModelCall: evaluates and optionally rewrites/blocks output
  • afterAgent: writes audit snapshot

Configuration

Top-level

| Field | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | mode | 'rule' \| 'llm' | Yes | rule | Select one mode. | | rules | Array<Rule> | Runtime-required in rule mode | [] | Business rules for rule mode. | | caseSensitive | boolean | No | false | Case-sensitive matching in rule mode. | | normalize | boolean | No | true | Whitespace normalization in rule mode. | | llm | object | Runtime-required in llm mode | - | LLM mode configuration. |

Rule Mode (mode=rule)

rules[] fields:

| Field | Type | Required | Description | | --- | --- | --- | --- | | id | string | No | Auto-generated when empty (rule-{index+1}). | | pattern | string | Yes | Match pattern. | | type | 'keyword' \| 'regex' | Yes | Match type. | | scope | 'input' \| 'output' \| 'both' | Yes | Match phase. | | severity | 'high' \| 'medium' | Yes | Conflict priority (high > medium). | | action | 'block' \| 'rewrite' | Yes | Hit action. | | replacementText | string | No | Optional replacement/block message. |

Runtime validation requires at least one valid rule with: pattern/type/action/scope/severity.

LLM Mode (mode=llm)

| Field | Type | Required (runtime) | Default | Description | | --- | --- | --- | --- | --- | | model | ICopilotModel | Yes | - | Policy evaluation model. | | scope | 'input' \| 'output' \| 'both' | Yes | - | Evaluation phase scope. | | rulePrompt | string | Yes | - | Natural-language policy description. | | rewriteFallbackText | string | No | [已过滤] | Fallback rewrite text. | | timeoutMs | number | No | unlimited | Per-evaluation timeout (max 120000). |

Notes:

  • The middleware internally enforces rewrite-only behavior for LLM hits.
  • Structured output method is internally adaptive; the UI does not expose method selection.
  • Internal decision traces are muted from chat output.

Backward Compatibility

Historical configurations may still include generalPack.

Current behavior:

  • The field is ignored.
  • Execution continues.
  • Rule/LLM behavior is driven only by current supported fields.

Minimal LLM Example

{
  "mode": "llm",
  "llm": {
    "model": { "provider": "openai", "model": "gpt-4o-mini" },
    "scope": "both",
    "rulePrompt": "If content contains ID cards, phone numbers, bank cards, or home addresses, rewrite it into a privacy-safe response.",
    "rewriteFallbackText": "[已过滤]",
    "timeoutMs": 3000
  }
}

Troubleshooting

  1. No effect in rule mode:
  • Ensure at least one valid rule contains pattern/type/action/scope/severity.
  1. No effect in llm mode:
  • Ensure model/scope/rulePrompt are all present.
  1. Unexpected rewrites in LLM mode:
  • Check audit records for source=error-policy and reason starting with llm-error:.

Validation Commands

/Users/xr/Documents/code/xpert-plugins/xpertai/node_modules/.bin/tsc -p /Users/xr/Documents/code/xpert-plugins/xpertai/middlewares/sensitive-filter/tsconfig.lib.json --noEmit
npx jest --runInBand src/lib/sensitiveFilter.spec.ts
node /Users/xr/Documents/code/xpert-plugins/plugin-dev-harness/dist/index.js --workspace ./xpertai --plugin ./middlewares/sensitive-filter