OpenClaw Self-Update
OpenClaw is distributed as an npm package. Version scheme: YYYY.M.D (date-based).
Workflow
1. Check for updates
Run the check script:
CODEBLOCK0
Report the result to the user clearly:
- - If already up to date: say so and show current version
- If an update is available: show current vs latest and ask for confirmation before updating
2. Apply update
Only run after user confirms. Use the channel the user configured (default: latest):
CODEBLOCK1
| Channel | Command |
|---|
| Stable (default) | INLINECODE2 |
| Beta |
npm install -g openclaw@beta |
| Dev |
npm install -g openclaw@dev |
3. Confirm result
After a successful install, inform the user that a gateway restart is required for changes to take effect. Do not restart automatically — tell the user to run openclaw restart or stop/start the daemon.
CODEBLOCK2
4. Error handling
- - If
check_update.sh fails → report the error, suggest checking network or npm config - If
npm install fails → report the error as-is, do not retry without user input - If the user asks for a channel that doesn't exist → show the channel table and ask again
Examples
| User says | Action |
|---|
| "Check for updates" | Run check script, report current vs latest |
| "Update openclaw" |
Run check script, if update available ask confirmation, then install |
| "Switch to beta channel" | Install
openclaw@beta, remind to restart |
| "What version am I on?" | Run check script, report current version |
OpenClaw 自我更新
OpenClaw 以 npm 包的形式分发。版本方案:YYYY.M.D(基于日期)。
工作流程
1. 检查更新
运行检查脚本:
json
{ tool: exec, command: bash {baseDir}/scripts/check_update.sh }
向用户清晰报告结果:
- - 如果已是最新:告知用户并显示当前版本
- 如果有可用更新:显示当前版本与最新版本,并在更新前请求用户确认
2. 应用更新
仅在用户确认后运行。使用用户配置的频道(默认:latest):
json
{ tool: exec, command: npm install -g openclaw@latest }
| 频道 | 命令 |
|---|
| 稳定版(默认) | npm install -g openclaw@latest |
| 测试版 |
npm install -g openclaw@beta |
| 开发版 | npm install -g openclaw@dev |
3. 确认结果
成功安装后,告知用户需要重启网关才能使更改生效。不要自动重启——告诉用户运行 openclaw restart 或停止/启动守护进程。
✅ OpenClaw 已更新:{旧版本} → {新版本}
⚠️ 重启网关:openclaw restart
4. 错误处理
- - 如果 check_update.sh 执行失败 → 报告错误,建议检查网络或 npm 配置
- 如果 npm install 执行失败 → 按原样报告错误,未经用户输入不要重试
- 如果用户请求的频道不存在 → 显示频道表格并再次询问
示例
| 用户输入 | 操作 |
|---|
| 检查更新 | 运行检查脚本,报告当前版本与最新版本 |
| 更新 openclaw |
运行检查脚本,如有可用更新则请求确认,然后安装 |
| 切换到测试版频道 | 安装 openclaw@beta,提醒重启 |
| 我当前是什么版本? | 运行检查脚本,报告当前版本 |