OpenClaw 本地存储架构
~/.openclaw/
├── openclaw.json # 核心配置文件
├── openclaw.json.bak* # 自动备份
├── .env # 环境变量
│
├── agents/ # Agent 配置目录
│ ├── main/ # 默认 agent
│ │ ├── agent/
│ │ │ ├── models.json # 模型配置
│ │ │ └── auth-profiles.json # 认证信息
│ │ └── sessions/
│ ├── will/ # 自定义 agent
│ │ ├── agent/
│ │ │ ├── models.json
│ │ │ └── auth-profiles.json
│ │ └── sessions/
│ └── ollama_test/ # 测试 agent
│
├── workspace/ # 主工作空间 (Git 仓库)
│ ├── .git/ # 版本控制
│ ├── AGENTS.md # Agent 行为指南
│ ├── BOOTSTRAP.md # 首次运行配置
│ ├── SOUL.md # Agent 人格定义
│ ├── USER.md # 用户信息
│ ├── TOOLS.md # 工具说明
│ ├── HEARTBEAT.md # 心跳/状态
│ └── memory/ # 记忆存储
│ └── YYYY-MM-DD.md # 每日记忆
│
├── workspace-will/ # Will agent 工作空间
├── workspace-ollama_test/ # Ollama 测试工作空间
│
├── subagents/ # 子 agent 配置
├── memory/ # 全局记忆
├── identity/ # 身份认证
├── credentials/ # 加密凭据存储
├── completions/ # 补全历史
├── canvas/ # Canvas 数据
├── cron/ # 定时任务
│ └── jobs.json
├── devices/ # 设备信息
├── extensions/ # 扩展插件
├── logs/ # 日志文件
│ ├── gateway.log
│ ├── gateway.err.log
│ └── commands.log
└── update-check.json # 更新检查
核心组件说明
目录/文件 │ 用途 │ 关键文件
─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────
openclaw.json │ 全局配置 │ 模型、网关、插件、渠道配置
agents/ │ 多 agent 支持 │ 每个 agent 独立的模型和认证
workspace/ │ 工作空间 │ Git 管理的记忆和配置
credentials/ │ 安全存储 │ 加密后的 API keys
memory/ │ 持久记忆 │ 跨会话的记忆保持
logs/ │ 运行日志 │ 排查问题用
我的多 Agent 架构示例
┌─────────────────────────────────────┐
│ OpenClaw Gateway │
│ (端口 18789) │
└─────────────┬───────────────────────┘
│
┌─────────┼─────────┐
▼ ▼ ▼
┌───────┐ ┌───────┐ ┌───────────┐
│ main │ │ will │ │ollama_test│
│agent │ │agent │ │ agent │
└───┬───┘ └───┬───┘ └─────┬─────┘
│ │ │
▼ ▼ ▼
┌───────┐ ┌───────┐ ┌───────────┐
│workspace│ │workspace-will│ │workspace-ollama│
└───────┘ └───────┘ └───────────┘
每个 agent 有独立的:
-
模型配置 (models.json)
-
认证信息 (auth-profiles.json)
-
工作空间 (workspace-{name}/)
-
会话历史 (sessions/)
记忆系统
类型 │ 位置 │ 用途
─────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────
每日记忆 │ workspace/memory/YYYY-MM-DD.md │ 原始对话记录
长期记忆 │ workspace/MEMORY.md │ 提炼的重要信息
Agent 指南 │ workspace/AGENTS.md │ 行为准则
用户画像 │ workspace/USER.md │ 用户偏好
