195 lines
4.5 KiB
Markdown
195 lines
4.5 KiB
Markdown
# OpenClaw Agent 管理指南
|
||
|
||
> 创建日期: 2026-03-15
|
||
> 作者: 星曜
|
||
|
||
---
|
||
|
||
## 1. 创建新 Agent
|
||
|
||
### 基本命令
|
||
|
||
```bash
|
||
openclaw agents add <agent-name> --non-interactive --workspace <workspace-path>
|
||
```
|
||
|
||
### 参数说明
|
||
|
||
| 参数 | 说明 |
|
||
| ------------------- | ----------------- |
|
||
| `<agent-name>` | Agent 名称(唯一标识) |
|
||
| `--non-interactive` | 跳过交互式提示,自动创建 |
|
||
| `--workspace` | 指定 workspace 目录路径 |
|
||
|
||
### 示例
|
||
|
||
```bash
|
||
# 创建名为 xinghui 的 agent
|
||
openclaw agents add xinghui --non-interactive --workspace ~/.openclaw/workspace-agent-xinghui
|
||
|
||
# 创建名为 xingyao 的 agent(复制现有workspace)
|
||
openclaw agents add xingyao --non-interactive --workspace ~/.openclaw/workspace-agent-xingyao
|
||
```
|
||
|
||
### Workspace 路径规范
|
||
|
||
- 格式: `~/.openclaw/workspace-agent-<agent-name>`
|
||
- 示例: `~/.openclaw/workspace-agent-xinghui`
|
||
|
||
---
|
||
|
||
## 2. 复制 Workspace 到新 Agent
|
||
|
||
### 场景
|
||
创建一个与现有 agent(通常是 main)拥有相同内容的 workspace
|
||
|
||
### 方法一:rsync 复制(推荐)
|
||
|
||
```bash
|
||
rsync -av --exclude='.git' /Users/weishen/.openclaw/workspace/ /Users/weishen/.openclaw/workspace-agent-xingyao/
|
||
```
|
||
|
||
### 方法二:软链接共享记忆
|
||
|
||
如果想让多个 agent 共享记忆(MEMORY.md 和 memory/ 目录):
|
||
|
||
```bash
|
||
# 为新 agent 创建软链接
|
||
ln -sf /Users/weishen/.openclaw/workspace/memory /Users/weishen/.openclaw/workspace-agent-<agent-name>/memory
|
||
ln -sf /Users/weishen/.openclaw/workspace/MEMORY.md /Users/weishen/.openclaw/workspace-agent-<agent-name>/MEMORY.md
|
||
```
|
||
|
||
**注意**: 共用 workspace 可能导致配置冲突,建议独立 workspace + 软链接共享 memory 目录
|
||
|
||
---
|
||
|
||
## 3. 绑定 Agent 到 Channel
|
||
|
||
### 查看当前绑定
|
||
|
||
```bash
|
||
openclaw agents bindings
|
||
```
|
||
|
||
### 绑定命令
|
||
|
||
```bash
|
||
openclaw agents bind --agent <agent-name> --bind <channel>:<accountId>
|
||
```
|
||
|
||
### 参数说明
|
||
|
||
| 参数 | 说明 |
|
||
| -------------- | ----------------------------------- |
|
||
| `<agent-name>` | 要绑定的 agent 名称 |
|
||
| `<channel>` | 频道类型(telegram, discord, whatsapp 等) |
|
||
| `<accountId>` | 账号 ID(数字形式) |
|
||
|
||
### 示例[[How to get Youtube Channel ID]]
|
||
|
||
```bash
|
||
# 绑定 xinghui 到 Telegram
|
||
openclaw agents bind --agent xinghui --bind telegram:5038825565
|
||
|
||
# 绑定 xingyao 到 Telegram
|
||
openclaw agents bind --agent xingyao --bind telegram:5038825565
|
||
```
|
||
|
||
### 解绑
|
||
|
||
```bash
|
||
# 解绑指定 channel
|
||
openclaw agents unbind --bind telegram:5038825565
|
||
|
||
# 解绑指定 agent 的 channel
|
||
openclaw agents unbind --agent xinghui --bind telegram:5038825565
|
||
```
|
||
|
||
---
|
||
|
||
## 4. 删除 Agent
|
||
|
||
### 命令
|
||
|
||
```bash
|
||
openclaw agents delete <agent-name>
|
||
```
|
||
|
||
### 示例
|
||
|
||
```bash
|
||
# 需要确认
|
||
openclaw agents delete agent-macmini-001
|
||
|
||
# 强制删除(非交互模式)
|
||
openclaw agents delete agent-macmini-001 --force
|
||
```
|
||
|
||
### 删除效果
|
||
- Workspace 目录移至废纸篓
|
||
- Sessions 目录删除
|
||
- 从配置文件移除
|
||
|
||
---
|
||
|
||
## 5. 查看 Agent 列表
|
||
|
||
```bash
|
||
openclaw agents list
|
||
```
|
||
|
||
### 输出示例
|
||
|
||
```
|
||
Agents:
|
||
- main (default)
|
||
Workspace: ~/.openclaw/workspace
|
||
Agent dir: ~/.openclaw/agents/main/agent
|
||
Model: minimax-portal/MiniMax-M2.5
|
||
Routing rules: 0
|
||
Routing: default (no explicit rules)
|
||
- xinghui
|
||
Workspace: ~/.openclaw/workspace-agent-xinghui
|
||
Agent dir: ~/.openclaw/agents/xinghui/agent
|
||
Model: minimax-portal/MiniMax-M2.5
|
||
Routing rules: 0
|
||
```
|
||
|
||
---
|
||
|
||
## 6. Agent 配置说明
|
||
|
||
### 默认模型
|
||
所有新创建的 agent 默认使用: `minimax-portal/MiniMax-M2.5`
|
||
|
||
### 配置文件位置
|
||
- 主配置: `~/.openclaw/openclaw.json`
|
||
- Agent 状态: `~/.openclaw/agents/<agent-name>/agent/`
|
||
|
||
---
|
||
|
||
## 7. 常用命令速查
|
||
|
||
| 操作 | 命令 |
|
||
|------|------|
|
||
| 创建 agent | `openclaw agents add <name> --non-interactive --workspace ~/.openclaw/workspace-agent-<name>` |
|
||
| 查看列表 | `openclaw agents list` |
|
||
| 查看绑定 | `openclaw agents bindings` |
|
||
| 绑定 channel | `openclaw agents bind --agent <name> --bind telegram:<id>` |
|
||
| 解绑 channel | `openclaw agents unbind --bind telegram:<id>` |
|
||
| 删除 agent | `openclaw agents delete <name> --force` |
|
||
|
||
---
|
||
|
||
## 8. 当前已创建的 Agent
|
||
|
||
| Agent 名称 | Workspace | 状态 |
|
||
|------------|-----------|------|
|
||
| main | ~/.openclaw/workspace | 默认 |
|
||
| xinghui | ~/.openclaw/workspace-agent-xinghui | 独立(无共享记忆) |
|
||
| xingyao | ~/.openclaw/workspace-agent-xingyao | 完整复制 main workspace |
|
||
|
||
---
|
||
|
||
*最后更新: 2026-03-15 14:33*
|