📦 Agent — AI宪法护栏

v1.0.1

为AI智能体提供不可变规则、权限边界与行为约束的宪法级护栏,防止越权操作并支持审计追踪与自动升级告警。

16· 16·1 当前·1 累计
sky-lv 头像by @sky-lv (SKY-lv)
下载技能包
最后更新
2026/4/21
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
可疑
high confidence
The SKILL.md describes a Node-based, enforceable guardrail system but the package contains no code, no install, and declares no credentials — the instructions and requirements are internally inconsistent.
评估建议
This package is an instructional README showing how a Node-based 'constitution' system could work, but it contains no code or install and does not declare the credentials or binaries it expects. Do not assume the skill enforces anything by itself. If you want these guardrails: obtain the actual implementation from a trusted repository, review the source code (especially escalation/webhook/email/Slack code and audit-log storage), verify where audit logs are written and who can read them, provisio...
详细分析 ▾
用途与能力
该技能声称提供可执行、可审计的宪法级护栏系统(Node运行示例、init/audit/escalation命令),但包内无代码、无安装规范、无所需二进制文件。文档所述命令(node constitution.js ...)无法直接运行。其宣称的平台级强制能力与仅含说明的README不符。
指令范围
运行时指令要求agent/用户创建.constitution、运行Node脚本、检查动作、通过webhook/email/slack升级,并读写审计日志与文件(示例含“读取任意本地文件”)。这些指令涉及文件I/O与外部网络通信,但技能未声明所需配置、凭证或代码,指导宽泛模糊,易导致数据泄露或凭证滥用。
安装机制
无安装规范或代码文件(仅说明文档)。这降低了供应链风险,但也意味着技能仅提供文档,无实际可执行二进制或包来强制护栏。无安装机制与示例/教程一致,却与其“生产级”强制声明冲突。
凭证需求
SKILL.md演示通过webhook、email、Slack升级,并展示与外部API(如Stripe)交互,但注册元数据未声明所需环境变量或凭证。升级通道与外部API调用需密钥/URL(webhook端点、SMTP/Slack令牌、API密钥);清单中遗漏这些配置不一致且危险,用户可能直接复制示例而未安全配置凭证。
持久化与权限
always:false与默认非自动调用设置合理。然而技能宣称“不可变”规则“任何人都无法覆盖”仅为政策/组织断言,未提供平台级机制保证其不可变性。这种宣称权限与实际强制能力不匹配,应视为误导。
安全有层次,运行前请审查代码。

运行时依赖

无特殊依赖

版本

latestv1.0.12026/4/21

**Expanded features and compliance for agent constitutional guardrails** - Description and keywords updated for clarity, adding emphasis on escalation, audit, and compliance. - Skill metadata now includes author, license, and enriched detail about protection against prompt injection and social engineering. - Added architectural overview, illustrating multi-layered checks (immutable, policy, escalation, audit). - Usage instructions are more detailed, covering initialization, rule creation, permission checks, escalation flows, and audit review. - Explained rule levels (Immutable, Owner-only, Mutable, Advisory) in a clear comparison table. - Introduced real-world example rule configurations for production safety, cost control, and data privacy/GDPR. - Config reference and practical integration patterns for middleware and OpenClaw provided.

无害

安装命令

点击复制
官方npx clawhub@latest install agent-constitution-guard
镜像加速npx clawhub@latest install agent-constitution-guard --registry https://cn.longxiaskill.com

技能文档

# agent-constitution-guard > AI 代理的宪法级护栏——定义不可更改的行为规则、权限边界、升级策略和安全互锁,使代理在任何上下文或用户压力下都无法逾越授权范围。 ## 技能元数据 - Slug: agent-constitution-guard - Version: 1.1.0 - Author: SKY-lv - Description: 生产级的 AI 代理宪法护栏系统。定义不可变行为规则、多级权限边界、人工升级策略、安全互锁与完整审计日志。无论上下文、提示注入或社会工程攻击,代理都必须遵守这些规则。 - Category: safety - License: MIT - Trigger Keywords: constitution, guardrail, permission guard, safety rule, behavioral constraint, boundary check, escalation policy, agent safety, immutable rule, compliance guard, red line, permission boundary --- ## 为什么重要 能够访问文件、API 与外部系统的 AI 代理必须具备可强制执行的边界。没有宪法护栏时: - 代理可能在误导提示下删除生产数据库 - 代理可能将敏感数据外泄到外部端点 - 代理可能在无监管情况下花费数千美元调用 API - 代理可能修改系统文件,破坏宿主环境 本技能提供可强制执行、可审计、多层次的保护。 --- ## 架构 \\\ ┌─────────────────────────────────────┐ │ AGENT ACTION REQUEST │ └──────────────────┬──────────────────┘ │ ▼ ┌─────────────────────────────────────┐ │ Layer 1: IMMUTABLE CHECK │ ← Cannot be overridden by anyone │ (Hard safety boundaries) │ └──────────────────┬──────────────────┘ │ PASS ▼ ┌─────────────────────────────────────┐ │ Layer 2: POLICY ENGINE │ ← Rule-based permission checks │ (Context-aware rules) │ └──────────────────┬──────────────────┘ │ PASS ▼ ┌─────────────────────────────────────┐ │ Layer 3: ESCALATION │ ← Human approval for sensitive ops │ (Owner confirmation) │ └──────────────────┬──────────────────┘ │ APPROVED ▼ ┌─────────────────────────────────────┐ │ Layer 4: AUDIT LOG │ ← Every check is recorded │ (Immutable audit trail) │ └─────────────────────────────────────┘ \\\ --- ## 分步使用指南 ### 步骤 1:初始化宪法 \\\bash node constitution.js init --name "my-agent" --owner "admin@company.com" \\\ 创建 .constitution/ 目录,包含默认规则与审计日志。 ### 步骤 2:添加规则 \\\bash # Immutable rule: never call external APIs without confirmation node constitution.js rule add \ --level immutable \ --action deny \ --scope "external_write" \ --description "Never write to external APIs without owner confirmation" \ --escalation owner # Owner-only rule: can modify workspace files node constitution.js rule add \ --level owner-only \ --action allow \ --scope "workspace_write" \ --description "Can write files within workspace directory" # Mutable rule: can read any file node constitution.js rule add \ --level mutable \ --action allow \ --scope "file_read" \ --description "Read any local file" \\\ ### 步骤 3:行动前检查权限 \\\javascript const guard = require('./constitution.js'); // Check if an action is allowed const decision = guard.check('external_write', { target: 'https://api.stripe.com/charges', payload: { amount: 9999 }, userId: 'user-123' }); console.log(decision); // { // allowed: false, // layer: 'immutable', // rule: 'R001', // reason: 'External write requires owner confirmation', // escalation: 'owner', // escalationMessage: 'Agent wants to POST to https://api.stripe.com/charges. Approve?' // } \\\ ### 步骤 4:处理升级 \\\javascript if (!decision.allowed && decision.escalation) { // Send escalation request to owner const approved = await guard.escalate(decision, { channel: 'webhook', // or 'email', 'slack', 'console' timeout: 300000, // 5 min timeout details: decision.escalationMessage }); if (approved) { await executeAction(); } } \\\ ### 步骤 5:审查审计日志 \\\bash # View all decisions in last 24 hours node constitution.js audit --last 24h # View only denied actions node constitution.js audit --status denied # View audit for specific scope node constitution.js audit --scope external_write # Export for compliance reporting node constitution.js audit --export csv --output audit_2024_Q1.csv \\\ --- ## 规则级别说明 | Level | 谁可修改 | 能否 Override | 使用场景 | |-------|---------------|----------|----------| | Immutable | 无人 | 永不 | 删除生产库、外部网络访问、凭据访问 | | Owner-only | 仅代理所有者 | 永不 | 部署到生产、修改计费、发送邮件 | | Mutable | 代理(在边界内) | 自行调整 | 文件读取路径、日志级别、缓存设置 | | Advisory | 任何人 | 始终 | 性能提示、优化建议 | --- ## 真实案例 ### 示例 1:生产数据库保护 \\\json { "id": "DB-PROTECT", "level": "immutable", "action": "deny", "scope": ["database_delete", "database_drop", "database_truncate"], "description": "Never delete, drop, or truncate any production database", "conditions": { "environment": ["production", "prod"] } } \\\ ### 示例 2:成本控制(每日 API 预算 100 美元) \\\json { "id": "COST-GUARD", "level": "owner-only", "action": "allow", "scope": "external_api_call", "description": "Allow external API calls within daily budget", "limits": { "maxDailyCost": 100, "maxCostPerCall": 10 }, "escalation": "owner" } \\\ ### 示例 3:数据隐私(GDPR 合规) \\\json { "id": "GDPR-GUARD", "level": "immutable", "action": "deny", "scope": ["data_export", "data_share"], "description": "Never export or share PII data without legal approval", "conditions": { "dataTypes": ["email", "phone", "ssn", "address", "financial"] } } \\\ --- ## 配置参考 \\\json { "constitution": { "version": "1.0", "agent": "my-agent", "owner": "admin@company.com", "defaults": { "denyAction": "block", "logLevel": "all", "escalationTimeout": 300000 }, "layers": { "immutable": { "enabled": true, "log": true }, "policy": { "enabled": true, "log": true }, "escalation": { "enabled": true, "channels": ["console"] }, "audit": { "enabled": true, "retention": "90d" } } } } \\\ --- ## 集成模式 ### 模式 1:Express/Fastify 中间件 \\\javascript app.use(async (req, res, next) => { const decision = guard.check('external_write', { method: req.method, url: req.url }); if (!decision.allowed) return res.status(403).json(decision); next(); }); \\\ ### 模式 2:OpenClaw 技能包装器 \\\javascript // Before executing any tool call: const toolGuard = guard.checkForTool(toolName, toolParams); if (!toolGuard.allowed) { if (toolGuard.escalation === 'owner') { // Ask OpenClaw to prompt user for approval } return { blocked: true, reason: toolGuard.reason }; } \\\ ### 模式 3:CI/CD 流水线门禁 \\\bash # In your deployment pipeline: node constitution.js ci-check --env production --strict # Exit code 0 = safe to deploy, 1 = violations found \\\

数据来源ClawHub ↗ · 中文优化:龙虾技能库