Skip to main content

OpenClaw CLI 概览

OpenClaw 提供了一个强大的命令行界面 (CLI) 用于管理网关、代理、频道和配置。

安装

npm 安装

npm install -g openclaw@latest

源码安装

git clone https://github.com/openclaw/openclaw.git
cd openclaw
pnpm install
pnpm build

主要命令

网关管理

openclaw gateway                # 运行网关
openclaw gateway status         # 查看状态
openclaw gateway install        # 安装服务
openclaw gateway restart        # 重启网关

代理管理

openclaw agents list            # 列出代理
openclaw agents status          # 代理状态
openclaw agent --message "..." # 运行代理回合

频道管理

openclaw channels list          # 列出频道
openclaw channels status        # 频道状态
openclaw channels add           # 添加频道
openclaw channels login         # 登录频道

配置管理

openclaw config file            # 显示配置文件路径
openclaw config get <path>      # 获取配置值
openclaw config set <path> <value>  # 设置配置值
openclaw configure              # 配置向导

节点管理

openclaw nodes list             # 列出节点
openclaw nodes status           # 节点状态
openclaw nodes invoke           # 调用节点命令

定时任务

openclaw cron list              # 列出任务
openclaw cron add               # 添加任务
openclaw cron run <id>          # 运行任务

状态和诊断

openclaw status                 # 快速状态检查
openclaw status --all           # 完整状态报告
openclaw health                 # 健康检查
openclaw doctor                 # 诊断和修复
openclaw logs --follow          # 实时日志

常用选项

大多数命令支持以下选项:
  • --json:输出 JSON 格式
  • --verbose:详细输出
  • --help:显示帮助信息
  • --version:显示版本信息

快速开始流程

首次安装

# 1. 安装 CLI
curl -fsSL https://openclaw.ai/install.sh | bash

# 2. 运行入门向导
openclaw onboard

# 3. 查看状态
openclaw status

日常使用

# 查看网关状态
openclaw gateway status

# 查看频道状态
openclaw channels status

# 查看日志
openclaw logs --follow

# 重启网关
openclaw gateway restart

环境变量

  • OPENCLAW_CONFIG_PATH:配置文件路径
  • OPENCLAW_STATE_DIR:状态目录
  • OPENCLAW_GATEWAY_TOKEN:网关令牌
  • OPENCLAW_GATEWAY_PASSWORD:网关密码
  • NO_COLOR:禁用颜色输出

相关文档