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

@openclaw-harness/guardrails

v0.1.0

Published

OpenClaw Harness Guardrails - Comprehensive safety and security layer for Agent interactions

Readme

@openclaw-harness/guardrails

npm version License: MIT

English | 中文

用于 Agent 交互的全面安全和防护护栏

特性

  • 🔒 输入验证 - PII 检测、毒性过滤、注入防护
  • 输出审查 - 幻觉检测、策略合规
  • 🛡️ 执行控制 - 工具权限、速率限制、成本追踪
  • 📊 违规追踪 - 全面的审计日志

安装

npm install @openclaw-harness/guardrails

快速开始

import { HarnessGuardrailsPlugin } from '@openclaw-harness/guardrails';

const plugin = new HarnessGuardrailsPlugin();

// 初始化
await plugin.init(openClawContext);

// 获取护栏服务
const guardrailsService = openClawContext.api.getService('harness:guardrails');

// 验证输入
const result = await guardrailsService.validateInput(
  'Contact me at [email protected]'
);

if (!result.valid) {
  console.log('检测到 PII:', result.violations);
  console.log('脱敏后:', result.sanitized);
}

检测类型

输入护栏

  • PII 检测 - 邮箱、电话、身份证号、信用卡等
  • 毒性检测 - 侮辱性语言、威胁、仇恨言论
  • 注入检测 - 提示词注入、越狱尝试

输出护栏

  • 幻觉检测 - 识别不确定的陈述
  • 策略合规 - 检查是否符合使用策略

执行护栏

  • 工具权限 - 控制可访问的工具
  • 速率限制 - 防止过度使用
  • 成本追踪 - 监控 API 调用成本

CLI 命令

# 查看护栏状态
openclaw harness:guardrails:status

# 查看违规记录
openclaw harness:guardrails:violations --limit 10

# 验证输入
openclaw harness:guardrails:validate "需要验证的文本"

# 审查输出
openclaw harness:guardrails:review "AI 生成的响应"

HTTP API

# 查看状态
curl http://localhost:3000/harness/guardrails/status

# 验证输入
curl -X POST http://localhost:3000/harness/guardrails/validate \
  -H "Content-Type: application/json" \
  -d '{"input": "Contact me at [email protected]"}'

# 审查输出
curl -X POST http://localhost:3000/harness/guardrails/review \
  -H "Content-Type: application/json" \
  -d '{"output": "AI response here"}'

# 查看违规记录
curl "http://localhost:3000/harness/guardrails/violations?limit=10&type=pii"

配置示例

{
  "enabled": true,
  "layers": {
    "input": {
      "enabled": true,
      "onViolation": "block",
      "guardrails": [
        { "id": "input-pii", "type": "pii", "enabled": true },
        { "id": "input-toxicity", "type": "toxicity", "enabled": true },
        { "id": "input-injection", "type": "injection", "enabled": true }
      ]
    },
    "output": {
      "enabled": true,
      "onViolation": "warn",
      "guardrails": [
        { "id": "output-hallucination", "type": "hallucination", "enabled": true }
      ]
    },
    "execution": {
      "enabled": true,
      "onViolation": "block",
      "guardrails": [
        { "id": "exec-permission", "type": "permission", "enabled": true },
        { 
          "id": "exec-rate-limit", 
          "type": "rate-limit", 
          "enabled": true,
          "config": {
            "strategies": [
              {
                "id": "global",
                "scope": "global",
                "limit": 1000,
                "window": 60000
              }
            ]
          }
        }
      ]
    }
  }
}

文档

查看 完整文档 获取更多详情。

许可证

MIT © OpenClaw Harness Team