Phase 3 / Ep 13: 权限模型概览 —— tools.profile 与安全哲学

⏱ 预计阅读 4 分钟 更新于 2026/4/13

🎯 学习目标:理解 OpenClaw 的分级权限设计,掌握 tools.profile 配置。

1. 安全哲学:最小权限原则

OpenClaw Agent 拥有强大的工具能力。强大意味着危险——如果你给一个 Agent 完整的 Shell 访问权限,它可能会误删你的文件。

核心原则:永远不要给 Agent 不必要的能力。

2. 四级权限模型

graph LR
    Basic["🟢 basic\n只读 · 无 Shell\n安全对话"] --> Standard["🟡 standard\n文件读写\n有限 Shell"]
    Standard --> Coding["🔵 coding\n完整 Shell\n代码执行 · Git"]
    Coding --> Full["🔴 full\n系统级访问\n网络 · 进程管理"]

    style Basic fill:#dcfce7,stroke:#16a34a
    style Standard fill:#fef9c3,stroke:#ca8a04
    style Coding fill:#dbeafe,stroke:#2563eb
    style Full fill:#fee2e2,stroke:#dc2626

3. 能力对照表

能力 🟢 basic 🟡 standard 🔵 coding 🔴 full
对话回复
文件读取
文件写入
Shell 命令 受限白名单
Git 操作
代码执行
网络访问 受限
进程管理
系统配置

4. 配置方法

# 设置权限等级
openclaw config set tools.profile basic
openclaw config set tools.profile standard
openclaw config set tools.profile coding
openclaw config set tools.profile full

# 为特定 Agent 设置
openclaw agents config code-agent tools.profile coding
openclaw agents config ops-agent tools.profile full

5. 典型配置方案

Agent 类型 推荐权限 运行环境 理由
日常助手 basic 任意 只需对话和提醒
内容创作 standard 任意 需要读写文件
编程助手 coding 原生 / Docker 需要 Shell 和 Git
运维监控 full 仅限 Docker/VM 需要系统级权限

⚠️ 红线full 权限 绝对不要 在 macOS 原生环境中使用。必须在 Docker 容器或 UTM 虚拟机中运行。

下节预告: Ep 14,用 coding 权限让 Agent 成为你的编程助手——clone 仓库、写代码、跑测试、提 PR。