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

@reaatech/tool-use-firewall-policies

v0.1.0

Published

Policy engine, rate limiting, cost tracking, and argument validation for tool-use-firewall

Readme

@reaatech/tool-use-firewall-policies

npm version License: MIT CI

Status: Pre-1.0 — APIs may change in minor versions. Pin to a specific version in production.

Policy engine, rate limiter, cost tracker, argument validators, SQL validator, and read-only enforcement for tool-use-firewall. All components implement the Middleware interface for pluggable use in the interceptor pipeline.

Installation

npm install @reaatech/tool-use-firewall-policies
# or
pnpm add @reaatech/tool-use-firewall-policies

Feature Overview

  • Policy engine — Priority-based rule evaluation with glob pattern matching for tool names
  • Token bucket rate limiter — Global, per-tool, and per-session limits with TTL-based memory eviction
  • Session cost tracker — Per-session budget enforcement with tool-level pricing and warn/block actions
  • SQL validator — Blocked patterns, injection detection, WHERE clause enforcement, read-only mode
  • Argument validator — Regex, shell-safety, and SQL-safety validators with custom rules from config
  • Schema validator — Validates tools/call arguments against the upstream's advertised JSON inputSchema
  • Secret scanner — Blocks tool calls whose arguments contain API keys, tokens, or other secrets
  • Anomaly detector — Flags tool calls that deviate from a session's recent behavioral baseline
  • Read-only check — Global toggle with per-tool exceptions and timing-safe bypass tokens
  • All implement Middleware — Drop into any InterceptorPipeline

Quick Start

import { PolicyEngine, RateLimiter, TokenBucket } from "@reaatech/tool-use-firewall-policies";
import { createRequestContext } from "@reaatech/tool-use-firewall-core";

// Rate limiting
const limiter = new RateLimiter({
  global: { requests_per_minute: 60, burst_capacity: 10 },
});

const ctx = createRequestContext({
  requestId: "1", sessionId: "s1", method: "tools/call", toolName: "db_query",
});

// Returns { action: "CONTINUE" } or throws RateLimitError
const result = await limiter.execute(ctx);

// Policy evaluation
const engine = new PolicyEngine({
  rules: [{ id: "r1", type: "block", tools: ["dangerous_tool"], priority: 10 }],
  settings: { default_action: "allow", audit_level: "full", read_only: false },
  version: "1.0",
});

const evalResult = await engine.evaluate(ctx);
// → { action: "ALLOW" | "BLOCK" | "APPROVAL_REQUIRED", rule?, reason? }

Exports

| Export | Description | |--------|-------------| | PolicyEngine | Rule evaluation engine: evaluates config rules against request context | | EvaluationResult | { action, rule?, reason? } | | RateLimiter | Middleware: global, per-tool, per-session token bucket rate limiting | | TokenBucket | Core token bucket algorithm (used internally, also exported for custom use) | | CostTracker | Middleware: session budget enforcement with tool-level costs | | ArgumentValidator | Middleware: schema and regex validation of tool arguments | | SQLValidator | Comprehensive SQL query validation (blocked patterns, injection, WHERE) | | SQLValidationResult / SQLValidationConfig | SQL validator types | | SchemaValidator | Middleware: validates arguments against the upstream's advertised JSON inputSchema | | SecretScanner | Middleware: blocks tool calls whose arguments contain secrets | | AnomalyDetector | Middleware: flags calls that deviate from a session's behavioral baseline | | ReadOnlyCheck | Middleware: blocks write operations when read-only mode is enabled | | ValidatorFn / ValidationResult | Argument validator function types |

License

MIT