关于 openclaw-admin
openclaw-admin 是用于管理 core-openclaw 集群中网关和 Agent 的 OpenClaw skill。它通过命令行和 API 提供生命周期操作、配置补丁及压缩设置调整流程。
主要功能
- 01启动、停止、重启和更新网关
- 02应用 JSON Patch 配置变更
- 03调整压缩设置
- 04添加、移除和列出 Agent
- 05通过命令行或 API 操作
适用场景
- 01配置变更后重启网关
- 02在部署期间更新网关
- 03调整集群的压缩设置
- 04管理 Agent 成员
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ alphaonedev/ openclaw-graph --skill openclaw-admin安装后在 Claude Code 中输入/openclaw-admin确认已加载。
详细介绍
openclaw-admin
用途
此技能用于管理 OpenClaw 网关,可执行启动、停止、重启和更新网关、应用配置补丁、调整压缩设置,以及管理 core-openclaw 集群中的 Agent 等任务。
使用场景
在网关维护时使用此技能,例如部署期间(如应用更新)、故障排查时(如出错后重启),或调整配置时(如调整压缩设置以提升性能)。可在 core-openclaw 集群处于活动状态的生产环境中使用,也可用于分布式部署中的 Agent 生命周期管理。
主要功能
- 网关生命周期管理:使用 CLI 命令启动、停止、重启或更新网关,例如
openclaw gateway start --cluster core-openclaw --force。 - 配置补丁:应用 JSON Patch 文档,例如 {"op": "replace", "path": "/settings/compaction", "value": {"interval": 60}}。
- 压缩设置调整:通过标志调整设置,例如
openclaw compaction tune --threshold 80 --interval 300,以设置内存阈值和间隔。 - Agent 管理:通过命令添加、移除或列出 Agent,例如
openclaw agent add --name agent1 --cluster core-openclaw。 - 身份验证:所有操作都需要
$OPENCLAW_API_KEY环境变量。
使用模式
运行命令前,务必先设置 $OPENCLAW_API_KEY,例如 export OPENCLAW_API_KEY=your_api_key。使用 CLI 时,以 openclaw 为前缀并指定 --cluster core-openclaw 标志。使用 API 端点时,通过 HTTP 请求调用,并添加 Authorization: Bearer $OPENCLAW_API_KEY 标头。在脚本中,使用错误检查封装调用,例如在应用配置补丁前验证集群是否存在。进行自动化时,可通过从 bash 脚本调用 CLI,将其集成到 cron 作业或 CI/CD 流水线等工具中。
常用命令/API
- 启动网关:CLI:
openclaw gateway start --cluster core-openclaw --env prod。API:POST /api/gateway/start,请求体为 {"cluster": "core-openclaw", "env": "prod"}。 - 停止网关:CLI:
openclaw gateway stop --cluster core-openclaw --force。API:POST /api/gateway/stop,请求体为 {"cluster": "core-openclaw"}。 - 重启网关:CLI:
openclaw gateway restart --cluster core-openclaw。API:POST /api/gateway/restart,请求体为 {"cluster": "core-openclaw"}。 - 更新网关:CLI:
openclaw gateway update --cluster core-openclaw --version 2.1.0。API:POST /api/gateway/update,请求体为 {"cluster": "core-openclaw", "version": "2.1.0"}。 - 应用配置补丁:CLI:
openclaw config patch --file config.patch.json --cluster core-openclaw。API:PATCH /api/config,请求体来自 JSON 文件,例如 {"op": "add", "path": "/agents", "value": ["agent1"]}。 - 调整压缩设置:CLI:
openclaw compaction tune --cluster core-openclaw --threshold 75 --interval 600。API:PUT /api/compaction,请求体为 {"threshold": 75, "interval": 600}。 - 管理 Agent:CLI:
openclaw agent add --name agent2 --cluster core-openclaw。API:POST /api/agents,请求体为 {"name": "agent2", "cluster": "core-openclaw"}。 - API 调用代码片段(重启网关):
export OPENCLAW_API_KEY=your_key curl -X POST https://api.openclaw.com/api/gateway/restart \ -H "Authorization: Bearer $OPENCLAW_API_KEY" \ -d '{"cluster": "core-openclaw"}' - 配置补丁代码片段:
{"op": "replace", "path": "/settings/logLevel", "value": "debug"}
集成说明
通过 "openclaw-admin" ID 将此技能导入 AI 工作流,以完成集成。在知识图谱中进行基于向量的搜索时,使用嵌入提示 "openclaw gateway restart update config compaction agent"。对于外部系统,请确保其与 core-openclaw 集群端点兼容(例如通过 HTTPS)。与其他技能结合使用时,将输出作为输入传递,例如在监控工具中使用此技能提供的 Agent ID。将 $OPENCLAW_API_KEY 设置在环境文件中以确保安全访问,并通过在所有命令中追加 --cluster core-openclaw 来处理集群专属配置。
错误处理
检查身份验证错误(例如 HTTP 401)时,请确认 $OPENCLAW_API_KEY 已设置且有效;在脚本中使用 echo $OPENCLAW_API_KEY。如果找不到网关(HTTP 404),请使用 openclaw gateway status --cluster core-openclaw 确认集群状态。从 stderr 中解析 CLI 错误,例如,“Error: Cluster core-openclaw not reachable” 表示存在网络问题——请使用指数退避重试。对于配置补丁,请在脚本中使用 try-catch 处理无效 JSON,例如,在 bash 中:openclaw config patch --file invalid.json || echo "Invalid JSON format"。常见 API 错误:400 表示请求错误(检查请求体格式),500 表示服务器问题(记录日志并发出警报)。
具体使用示例
- 配置变更后重启网关:首先,导出密钥:
export OPENCLAW_API_KEY=your_api_key。然后,应用补丁:openclaw config patch --file patch.json --cluster core-openclaw,其中 patch.json 包含 {"op": "replace", "path": "/settings/restartTrigger", "value": true}。最后,重启:openclaw gateway restart --cluster core-openclaw。 - 调整压缩设置并添加 Agent,以优化性能:首先进行调整:
openclaw compaction tune --cluster core-openclaw --threshold 85 --interval 900。然后,添加 Agent:openclaw agent add --name monitoring-agent --cluster core-openclaw。使用以下命令验证:openclaw agent list --cluster core-openclaw,确保 Agent 处于活动状态。
图关系
- 依赖于:core-openclaw(所有操作所用的集群)
- 相关项:openclaw(主生态系统)、admin(基于角色的访问)、gateway(主要资源)、config(配置管理)
- 标签:openclaw、admin、gateway、config(用于搜索和链接)