Files
my-project/config/openclaw/backup/20260213_1932/ROBOT_STANDARDIZATION.md
T

453 lines
9.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 🤖 机器人标准化部署流程
> 创建时间: 2026-02-08
> 版本: v1.0
> 目标: 新建机器人的标准化配置指南
---
## 一、新建机器人检查清单
### 1.1 系统准备
```
□ 操作系统: Ubuntu 20.04+ / Debian 11+
□ 硬件要求:
- CPU: 2核心+
- 内存: 4GB+
- 存储: 20GB+
□ 网络: 能访问互联网
检查命令:
cat /etc/os-release
free -h
df -h
```
### 1.2 OpenClaw 安装
```bash
# 方式A: 全新安装
curl -sSf https://get.openclaw.ai | sh
# 方式B: 手动安装
git clone https://github.com/openclaw/openclaw.git
cd openclaw
npm install -g openclaw
```
### 1.3 基础配置
```
□ 创建 systemd 服务
□ 配置代理(如需要)
□ 设置防火墙规则
□ 配置 SSH 访问
```
---
## 二、必要设计(必选)
### 2.1 人格配置(SOUL.md)
**位置**: `/root/.openclaw/identity/SOUL.md`
**必要内容**:
```markdown
# SOUL.md - 机器人灵魂
## Core Truths
**核心定位** - 简明扼要描述机器人身份
## Boundaries
- **安全第一** - 不执行危险命令
- **诚实为本** - 做就是做,没做就是没做
- **记忆管理** - 重要信息记录到 MEMORY.md
## Vibe
- **风格** - 专业/简洁/稳重
- **沟通方式** - 直接给答案/不说废话
```
**诚实原则(必须包含)**:
```
=================================================================
🛡️ 诚实原则 - 最高优先级
=================================================================
1. 做就是做,没做就是没做
2. 必须提供证据(文件路径、日志、命令输出)
3. 分清状态(进行中≠已完成)
4. 禁止模糊回答(大概、可能、应该)
=================================================================
```
### 2.2 AGENTS.md 人格注入
**位置**: `/root/.openclaw/workspace/AGENTS.md`
**必要内容**:
```markdown
# AGENTS.md - 会话人格配置
## 核心人格注入
### 诚实原则(必须遵守)
[复制 SOUL.md 中的诚实原则]
### 机器人人格配置
身份: [名称]
风格: [风格描述]
核心职责:
1. [职责1]
2. [职责2]
3. [职责3]
### 会话启动规则
每次新会话启动时:
1. 读取 AGENTS.md
2. 读取 SOUL.md
3. 读取 USER.md
4. 读取 MEMORY.md
5. 注入系统提示
```
### 2.3 用户偏好(USER.md)
**位置**: `/root/.openclaw/identity/USER.md`
**模板**:
```markdown
# USER.md - 用户偏好
## 用户信息
- **Name**: [用户名]
- **Platform**: Telegram/WhatsApp/...
- **Timezone**: Asia/Shanghai
## 偏好设置
- **主力模型**: MiniMax/DeepSeek/...
- **沟通风格**: 简洁/详细/技术向
- **特殊要求**: [如有]
## 注意事项
- [重要提醒]
```
---
## 三、标准化配置流程
### 3.1 目录结构
```
/root/.openclaw/
├── openclaw.json # 系统配置
├── agents/ # Agent配置
│ └── main/
│ └── sessions/ # 会话文件
├── identity/ # 身份配置
│ ├── IDENTITY.md # 身份定义
│ ├── SOUL.md # 灵魂/人格
│ └── USER.md # 用户偏好
├── memory/ # 记忆存储
│ └── main.sqlite
├── workspace/ # 工作区
│ ├── AGENTS.md # 人格注入
│ ├── MEMORY.md # 长期记忆
│ └── sleep-learning/ # 自动学习
├── scripts/ # 脚本
│ ├── disaster-backup.sh # 灾难备份
│ ├── problem-detector.sh # 问题检测
│ └── auto-learning.sh # 自动学习
└── backups/ # 备份
```
### 3.2 配置文件模板
#### openclaw.json 必要配置
```json
{
"name": "机器人名称",
"channels": {
"telegram": {
"token": "YOUR_TOKEN"
}
},
"providers": {
"minimax": {
"models": { "default": "minimax-minimax" }
}
},
"memorySearch": {
"provider": "openai",
"model": "nomic-embed-text:latest"
}
}
```
#### cron 必要任务
```bash
# 1. 问题检测(每5分钟)
*/5 * * * * /root/.openclaw/scripts/problem-detector.sh
# 2. 灾难备份(每周日)
0 3 * * 0 /root/.openclaw/scripts/disaster-backup.sh backup
```
---
## 四、功能模块(可选)
### 4.1 核心功能(推荐)
| 功能 | 脚本 | 优先级 | 说明 |
|------|------|--------|------|
| **问题检测** | problem-detector.sh | P0 | 自动发现问题 |
| **灾难备份** | disaster-backup.sh | P0 | 系统恢复保障 |
| **自动学习** | auto-learning.sh | P1 | 持续知识更新 |
### 4.2 增强功能(可选)
| 功能 | 脚本 | 说明 |
|------|------|------|
| **混合学习** | hybrid-learning.sh | 定时+问题双模式 |
| **知识图谱** | update-knowledge-graph.sh | 知识体系可视化 |
| **强制反思** | robot-force-reflection.sh | 深度反思机制 |
### 4.3 监控功能(可选)
| 功能 | 脚本 | 说明 |
|------|------|------|
| **系统监控** | system-monitor.sh | CPU/内存/磁盘 |
| **会话监控** | session-monitor.sh | 会话文件大小 |
| **告警通知** | send-alert.sh | Telegram通知 |
---
## 五、新建机器人标准流程
### Step 1: 系统准备
```bash
# 1. SSH连接到新机器
ssh user@new_robot_ip
# 2. 创建工作目录
mkdir -p /root/.openclaw/{identity,workspace/sleep-learning,scripts,backups}
# 3. 安装OpenClaw
curl -sSf https://get.openclaw.ai | sh
```
### Step 2: 复制标准配置
```bash
# 从模板机器复制
scp template:/root/.openclaw/identity/*.md new:/root/.openclaw/identity/
scp template:/root/.openclaw/workspace/AGENTS.md new:/root/.openclaw/workspace/
scp template:/root/.openclaw/scripts/*.sh new:/root/.openclaw/scripts/
# 设置权限
chmod +x /root/.openclaw/scripts/*.sh
```
### Step 3: 配置个性化参数
```bash
# 编辑openclaw.json
vim /root/.openclaw/openclaw.json
# 编辑SOUL.md(修改机器人名称和定位)
vim /root/.openclaw/identity/SOUL.md
# 编辑USER.md(修改用户信息)
vim /root/.openclaw/identity/USER.md
```
### Step 4: 配置定时任务
```bash
# 添加cron任务
crontab -e
# 添加:
*/5 * * * * /root/.openclaw/scripts/problem-detector.sh
0 3 * * 0 /root/.openclaw/scripts/disaster-backup.sh backup
```
### Step 5: 启动服务
```bash
# 启动OpenClaw
openclaw gateway start
# 验证运行
openclaw status
```
### Step 6: 功能测试
```bash
# 测试问题检测
/root/.openclaw/scripts/problem-detector.sh
# 测试备份
/root/.openclaw/scripts/disaster-backup.sh status
# 测试自动学习(可选)
/root/.openclaw/scripts/auto-learning.sh 1
```
---
## 六、配置验证清单
### 6.1 人格配置验证
```bash
# 检查SOUL.md
cat /root/.openclaw/identity/SOUL.md | grep "诚实原则"
# 检查AGENTS.md
cat /root/.openclaw/workspace/AGENTS.md | grep "诚实原则 - 最高优先级"
# 检查USER.md
cat /root/.openclaw/identity/USER.md
```
### 6.2 定时任务验证
```bash
# 查看cron
crontab -l | grep -E "problem|disaster"
# 预期输出:
# */5 * * * * /root/.openclaw/scripts/problem-detector.sh
# 0 3 * * 0 /root/.openclaw/scripts/disaster-backup.sh backup
```
### 6.3 服务状态验证
```bash
# 检查Gateway
openclaw status | grep Running
# 检查日志
tail -f /tmp/openclaw/openclaw-*.log
```
---
## 七、常见问题处理
### Q1: SOUL.md 诚实原则不生效
```bash
# 确认AGENTS.md存在且包含注入
cat /root/.openclaw/workspace/AGENTS.md | grep "诚实原则 - 最高优先级"
# 如果不存在,从模板复制
scp template:/root/.openclaw/workspace/AGENTS.md new:/root/.openclaw/workspace/
```
### Q2: 定时任务不执行
```bash
# 检查cron服务
systemctl status cron
# 手动测试
/root/.openclaw/scripts/problem-detector.sh
# 查看日志
cat /var/log/openclaw/problem-detector.log
```
### Q3: 备份失败
```bash
# 检查备份目录权限
ls -la /root/.openclaw/backups/
# 手动执行
/root/.openclaw/scripts/disaster-backup.sh backup
# 查看错误
cat /var/log/openclaw/backup.log
```
---
## 八、最小配置 vs 完整配置
### 最小配置(必选)
```
必须:
✓ openclaw.json
✓ SOUL.md
✓ AGENTS.md
✓ USER.md
✓ disaster-backup.sh
✓ cron备份任务
可选:
✗ 自动学习
✗ 问题检测
✗ 知识图谱
```
### 完整配置(推荐)
```
核心:
✓ openclaw.json
✓ SOUL.md (含诚实原则)
✓ AGENTS.md
✓ USER.md
✓ identity/
自动化:
✓ disaster-backup.sh (备份)
✓ problem-detector.sh (检测)
✓ auto-learning.sh (学习)
增强:
✓ hybrid-learning.sh (混合学习)
✓ update-knowledge-graph.sh (知识图谱)
✓ force-reflection.sh (深度反思)
```
---
## 九、模板机器信息
### 守护者(模板机)
- **IP**: 192.168.0.32
- **路径**: /root/.openclaw/
- **用途**: 配置模板来源
### 青龙(模板机)
- **IP**: 192.168.0.31
- **路径**: /root/.openclaw/
- **用途**: 配置模板来源
---
## 十、快速部署命令
```bash
# 从守护者复制所有配置到新机器
./deploy-robot.sh new_robot_ip
# 脚本内容:
#!/bin/bash
IP=$1
ssh user@$IP "mkdir -p /root/.openclaw/{identity,workspace/sleep-learning,scripts,backups}"
scp /root/.openclaw/identity/*.md user@$IP:/root/.openclaw/identity/
scp /root/.openclaw/workspace/AGENTS.md user@$IP:/root/.openclaw/workspace/
scp /root/.openclaw/scripts/*.sh user@$IP:/root/.openclaw/scripts/
ssh user@$IP "chmod +x /root/.openclaw/scripts/*.sh"
echo "✅ 部署完成"
```
---
> 文档版本: v1.0
> 最后更新: 2026-02-08
> 维护者: 守护者