Operator Fleet Manager
This skill lets you manage your Operator fleet of OpenClaw agent instances by sending requests to the Operator chat API.
When to Use This Skill
Use this skill when the user:
- - Asks about their Operator instances or agents
- Wants to create, delete, restart, or configure instances
- Needs to check instance logs or status
- Wants to message a running agent
- Asks about secrets, automations, or webhooks
- Mentions "Operator", "fleet", or "OpenClaw"
Authentication
Step 1: Check for existing API key
Read the config file to check if the user is already logged in:
CODEBLOCK0
Look for operatorApiKey (starts with ck_) and operatorAppUrl in the JSON. If the file exists and has a key, skip to "Using the API" below.
Step 2: Login (if no key found)
If no API key is found, guide the user through browser-based login:
- 1. Generate a session ID:
CODEBLOCK1
- 2. Tell the user to open this URL in their browser (replace
SESSION_ID with the generated UUID):
CODEBLOCK2
- 3. After the user confirms they've logged in, poll for the API key:
CODEBLOCK3
The response will contain operatorApiKey when auth is complete.
- 4. Save the credentials:
CODEBLOCK4
Using the API
Read credentials
CODEBLOCK5
Health check
Verify auth is working:
CODEBLOCK6
Returns authenticated, email, and planName.
Send a request to the Operator manager
The Operator manager is an AI that has tools for managing your entire fleet. Send it natural language requests and parse the SSE response to extract text and tool results:
CODEBLOCK7
To continue a conversation (for follow-up requests), include the id field. The chat ID is returned in the stream's start event:
CODEBLOCK8
Understanding the SSE response
The API returns a Server-Sent Events stream. Each line is data: {JSON}. The important event types are:
- -
{"type":"start"} — stream started - INLINECODE12 — the manager is beginning a step (may use tools)
- INLINECODE13 — text response chunks (concatenate for full answer)
- INLINECODE14 — the manager is calling a tool
- INLINECODE15 — tool result data (instance lists, config, logs, etc.)
- INLINECODE16 — step complete
- INLINECODE17 — response complete
The python pipe above extracts just the text and tool results, giving you clean readable output. Always use this pipe when calling the API.
What the Operator Manager Can Do
The manager has tools for:
- - Instances: list, create, delete, restart, clone, get details, check capacity, get logs
- Config: update instance configuration (JSON patch), deploy skills, list/read/write workspace files
- Agents: message a running agent, check latest session activity
- Secrets: list user secrets, grant/revoke instance access
- Automations: list, create, update, delete scheduled cron automations
- Webhooks: list, create, update, delete webhook triggers
- Checkpoints: search and install agent checkpoint repos
Important Notes
- - Always read credentials from
~/.operator/config.json before every API call. - If a
401 error is returned, the API key may be expired. Run the login flow again. - If a
429 error is returned, the user has hit their rate limit. Wait before retrying. - The manager handles multi-step operations internally. Send one natural language request and it will use its tools as needed.
- Never expose the raw API key value to the user. Show only a masked version like
ck_...xxxx.
Operator 舰队管理器
此技能允许您通过向 Operator 聊天 API 发送请求来管理 OpenClaw 代理实例的 Operator 舰队。
何时使用此技能
当用户出现以下情况时使用此技能:
- - 询问其 Operator 实例或代理
- 想要创建、删除、重启或配置实例
- 需要检查实例日志或状态
- 想要向正在运行的代理发送消息
- 询问关于密钥、自动化或 Webhook 的问题
- 提及Operator、舰队或OpenClaw
身份验证
步骤 1:检查现有 API 密钥
读取配置文件,检查用户是否已登录:
bash
cat ~/.operator/config.json 2>/dev/null
在 JSON 中查找 operatorApiKey(以 ck_ 开头)和 operatorAppUrl。如果文件存在且包含密钥,请跳至下方的使用 API部分。
步骤 2:登录(如果未找到密钥)
如果未找到 API 密钥,引导用户完成基于浏览器的登录:
- 1. 生成会话 ID:
bash
python3 -c import uuid; print(uuid.uuid4())
- 2. 告知用户在浏览器中打开此 URL(将 SESSION_ID 替换为生成的 UUID):
https://www.operator.io/auth/cli?session=SESSION_ID
- 3. 用户确认已登录后,轮询获取 API 密钥:
bash
curl -s https://www.operator.io/api/cli/poll?session=SESSION_ID
认证完成后,响应中将包含 operatorApiKey。
- 4. 保存凭据:
bash
mkdir -p ~/.operator
python3 -c
import json
config = {operatorApiKey: THE_KEY, operatorAppUrl: https://www.operator.io}
with open($HOME/.operator/config.json, w) as f:
json.dump(config, f, indent=2)
print(已保存凭据至 ~/.operator/config.json)
使用 API
读取凭据
bash
OPERATOR_KEY=$(python3 -c import json; c=json.load(open($HOME/.operator/config.json)); print(c.get(operatorApiKey,)))
OPERATOR_URL=$(python3 -c import json; c=json.load(open($HOME/.operator/config.json)); print(c.get(operatorAppUrl,https://www.operator.io)))
健康检查
验证身份验证是否正常:
bash
curl -s $OPERATOR_URL/api/cli/health \
-H Authorization: Bearer $OPERATOR_KEY
返回 authenticated、email 和 planName。
向 Operator 管理器发送请求
Operator 管理器是一个 AI,拥有管理整个舰队的工具。向其发送自然语言请求,并解析 SSE 响应以提取文本和工具结果:
bash
curl -sN $OPERATOR_URL/api/chat \
-H Authorization: Bearer $OPERATOR_KEY \
-H Content-Type: application/json \
-d {messages:[{role:user,parts:[{type:text,text:YOURMESSAGEHERE}]}]} \
| python3 -c
import sys, json
for line in sys.stdin:
line = line.strip()
if not line.startswith(data: ):
continue
try:
event = json.loads(line[6:])
t = event.get(type,)
if t == text:
print(event.get(value,), end=)
elif t == tool-result:
result = event.get(result)
if result is not None:
print(json.dumps(result, indent=2))
elif t == error:
print(ERROR:, event.get(value,))
except:
pass
print()
要延续对话(用于后续请求),请包含 id 字段。聊天 ID 在流的 start 事件中返回:
bash
curl -sN $OPERATOR_URL/api/chat \
-H Authorization: Bearer $OPERATOR_KEY \
-H Content-Type: application/json \
-d {id:CHATID,messages:[{role:user,parts:[{type:text,text:YOURFOLLOWUP}]}]} \
| python3 -c
import sys, json
for line in sys.stdin:
line = line.strip()
if not line.startswith(data: ):
continue
try:
event = json.loads(line[6:])
t = event.get(type,)
if t == text:
print(event.get(value,), end=)
elif t == tool-result:
result = event.get(result)
if result is not None:
print(json.dumps(result, indent=2))
elif t == error:
print(ERROR:, event.get(value,))
except:
pass
print()
理解 SSE 响应
API 返回服务器发送事件流。每行格式为 data: {JSON}。重要的事件类型包括:
- - {type:start} — 流已开始
- {type:start-step} — 管理器开始执行步骤(可能使用工具)
- {type:text,value:...} — 文本响应片段(拼接后得到完整答案)
- {type:tool-call,toolCallId:...,toolName:...,args:{}} — 管理器正在调用工具
- {type:tool-result,toolCallId:...,result:{}} — 工具结果数据(实例列表、配置、日志等)
- {type:finish-step} — 步骤完成
- {type:finish,finishReason:stop} — 响应完成
上述 Python 管道仅提取文本和工具结果,为您提供清晰可读的输出。调用 API 时请始终使用此管道。
Operator 管理器可执行的操作
管理器拥有以下工具:
- - 实例:列出、创建、删除、重启、克隆、获取详情、检查容量、获取日志
- 配置:更新实例配置(JSON 补丁)、部署技能、列出/读取/写入工作区文件
- 代理:向正在运行的代理发送消息、检查最新会话活动
- 密钥:列出用户密钥、授予/撤销实例访问权限
- 自动化:列出、创建、更新、删除计划性 cron 自动化
- Webhook:列出、创建、更新、删除 Webhook 触发器
- 检查点:搜索和安装代理检查点仓库
重要说明
- - 每次 API 调用前,始终从 ~/.operator/config.json 读取凭据。
- 如果返回 401 错误,API 密钥可能已过期。请重新运行登录流程。
- 如果返回 429 错误,用户已达到速率限制。请等待后重试。
- 管理器内部处理多步骤操作。发送一个自然语言请求,它将根据需要自行使用工具。
- 切勿向用户暴露原始 API 密钥值。仅显示掩码版本,如 ck_...xxxx。