Local Approvals Skill
A local approval system that manages agent permissions with auto-approve lists and approval history tracking.
Quick Start
CODEBLOCK0
Commands
approve(id)
Approve a pending request by ID.
CODEBLOCK1
Options:
- -
--learn: Add the category to the agent's auto-approve list - INLINECODE1 : Who is approving (default: "user")
Example:
CODEBLOCK2
deny(id)
Deny a pending request by ID.
CODEBLOCK3
Options:
- -
--reviewer: Who is denying (default: "user")
Example:
CODEBLOCK4
list_pending()
List all pending requests, optionally filtered by agent.
CODEBLOCK5
Options:
- -
--agent: Filter requests by agent ID
Example:
CODEBLOCK6
show_history()
Show approval history from state.json.
CODEBLOCK7
Options:
- -
--limit: Maximum number of entries to show (default: 20)
Example:
CODEBLOCK8
reset_categories(agent)
Reset an agent's auto-approved categories list.
CODEBLOCK9
Example:
CODEBLOCK10
Additional Commands
categories
Show auto-approved categories for one or all agents.
CODEBLOCK11
Options:
- -
--agent: Show categories for specific agent
Example:
CODEBLOCK12
State Files
The skill maintains two JSON files in the state directory:
- - state.json: Auto-approve lists and approval history
- pending.json: Pending approval requests
Location: INLINECODE6
Core Functions
The core.py module provides the underlying functionality:
- -
check_auto_approve(agent, category) - Check if a category is auto-approved - INLINECODE9 - Submit a pending request
- INLINECODE10 - Add category to auto-approve list
- INLINECODE11 - Retrieve a request by ID
- INLINECODE12 - Update request with decision
- INLINECODE13 - List pending requests
- INLINECODE14 - Get agent's auto-approved categories
Best Practices
- 1. Review before approving: Always check the operation and reasoning before approving
- Use auto-learn carefully: Only use
--learn for trusted categories that you want to auto-approve - Check history regularly: Review
history to understand approval patterns - Reset when needed: Use
reset to clear an agent's auto-approve list if you suspect issues
Examples
Complete Workflow
CODEBLOCK13
Managing Categories
CODEBLOCK14
Integration
The CLI is designed to be used both interactively and programmatically. Exit codes:
- -
0: Success - INLINECODE19 : Error (request not found, agent not found, etc.)
Files
- -
cli.py - Command-line interface (this file) - INLINECODE21 - Core approval functions
- INLINECODE22 - JSON schema definitions
- INLINECODE23 - State schema template
- INLINECODE24 - Pending requests schema template
本地审批技能
一个管理代理权限的本地审批系统,包含自动审批列表和审批历史记录追踪。
快速开始
bash
列出待处理请求
python C:\Users\Shai\.openclaw\skills\local-approvals\cli.py list
批准请求
python C:\Users\Shai\.openclaw\skills\local-approvals\cli.py approve abc123
拒绝请求
python C:\Users\Shai\.openclaw\skills\local-approvals\cli.py deny abc123
显示审批历史
python C:\Users\Shai\.openclaw\skills\local-approvals\cli.py history
重置代理的分类
python C:\Users\Shai\.openclaw\skills\local-approvals\cli.py reset assistant
命令
approve(id)
根据ID批准待处理请求。
bash
python cli.py approve [--learn] [--reviewer ]
选项:
- - --learn:将该分类添加到代理的自动审批列表
- --reviewer:审批人(默认:user)
示例:
bash
python cli.py approve abc123 --learn
deny(id)
根据ID拒绝待处理请求。
bash
python cli.py deny [--reviewer ]
选项:
- - --reviewer:拒绝人(默认:user)
示例:
bash
python cli.py deny abc123
list_pending()
列出所有待处理请求,可选择按代理筛选。
bash
python cli.py list [--agent ]
选项:
示例:
bash
python cli.py list --agent assistant
show_history()
从state.json显示审批历史。
bash
python cli.py history [--limit ]
选项:
- - --limit:显示的最大条目数(默认:20)
示例:
bash
python cli.py history --limit 50
reset_categories(agent)
重置代理的自动审批分类列表。
bash
python cli.py reset
示例:
bash
python cli.py reset assistant
附加命令
categories
显示一个或所有代理的自动审批分类。
bash
python cli.py categories [--agent ]
选项:
示例:
bash
python cli.py categories --agent planner
状态文件
该技能在状态目录中维护两个JSON文件:
- - state.json:自动审批列表和审批历史
- pending.json:待处理的审批请求
位置:~/.openclaw/skills/local-approvals/
核心函数
core.py模块提供底层功能:
- - checkautoapprove(agent, category) - 检查分类是否已自动审批
- submitrequest(agent, category, operation, reasoning) - 提交待处理请求
- learncategory(agent, category) - 将分类添加到自动审批列表
- getrequest(requestid) - 根据ID检索请求
- updaterequest(requestid, decision, reviewer) - 更新请求的审批决定
- listpending(agent) - 列出待处理请求
- getagent_approvals(agent) - 获取代理的自动审批分类
最佳实践
- 1. 批准前先审查:在批准前始终检查操作和理由
- 谨慎使用自动学习:仅对您希望自动审批的可信分类使用--learn
- 定期检查历史:查看history以了解审批模式
- 必要时重置:如果怀疑有问题,使用reset清除代理的自动审批列表
示例
完整工作流程
bash
1. 检查待处理内容
python cli.py list
2. 审查请求详情(输出显示代理、分类、操作、理由)
ID: abc123
代理: assistant
分类: file_write
操作: 创建配置文件
理由: 设置新环境
3. 批准并自动学习此分类以备将来使用
python cli.py approve abc123 --learn
4. 验证已批准
python cli.py list # 应显示无待处理请求
5. 检查历史
python cli.py history
6. 查看自动审批分类
python cli.py categories
管理分类
bash
查看所有自动审批分类
python cli.py categories
查看特定代理的分类
python cli.py categories --agent assistant
重置代理的分类(清除所有自动审批)
python cli.py reset assistant
集成
CLI设计为既可交互使用也可编程使用。退出代码:
文件
- - cli.py - 命令行界面(此文件)
- core.py - 核心审批函数
- schemas/ - JSON模式定义
- schemas/state.json - 状态模式模板
- schemas/pending.json - 待处理请求模式模板