修复 OpenClaw CLI 设备 scope 权限不足导致的配对失败。
text
sessions_spawn error: gateway closed (1008): pairing required
[tools] cron failed: gateway closed (1008): pairing required
同时确认:
openclaw gateway status 显示 gateway runningopenclaw devices list 显示 CLI 设备 Paired 但 scopes 只有 operator.read,没有 admin一行命令输出完整诊断:
bash
python3 scripts/diagnose.py
输出示例(需要修复):
text
=== CLI Device Scope 诊断 ===
✓ Gateway 正在运行
设备 ID: 2f5c98cfd06a980cb20ca1217580e6d8be7df78034a278b0fdaf81a9d8ac99c5
当前 scopes: ['operator.read']
pending: 1 repair 请求
⚠️ 需要修复:CLI 设备缺少 admin scope
死循环:当前只有 read,无法 approve 自己的升级请求
修复命令:
python3 scripts/fix.py --dry-run # 先预览
python3 scripts/fix.py # 执行修复
Gateway 设备的 scope 太低(只有 operator.read),而 subagent spawn / cron 等操作需要 operator.admin。有一个 repair pending 请求在队列里等着升级 scope,但当前 token 权限不够 approve 不了——死循环:
text
需要 admin scope → 才能 approve → admin scope 申请
执行修复脚本前, 必须先展示将要改动的配置,等待用户确认:
bash
# 先用 --dry-run 看改动(不执行写入)
python3 scripts/fix.py --dry-run
# 输出示例:
# Device: 2f5c98cf...
# Current scopes: ['operator.read']
# New scopes: ['operator.admin', 'operator.read', 'operator.write', ...]
# Files to modify:
# - paired.json
# - device-auth.json
# - pending.json (cleanup)
#
# ❓ Proceed? [y/N]:
用户确认后才执行:
bash
python3 scripts/fix.py # 默认会先展示再询问
python3 scripts/fix.py --force # 跳过确认(仅限自动化场景)
bash
# 重启 gateway 加载新 scope
openclaw gateway restart
# 等待 ~5 秒后测试 spawn
用 sessions_spawn 工具验证,应该返回 status: accepted。
paired.json.bak 和 device-auth.json.bakclientId=cli 且 platform=linux)openclaw doctor --fix 检查整体健康状态cli_admin_<random>,每次修复会更新['operator.admin', 'operator.read', 'operator.write', 'operator.approvals', 'operator.pairing', 'operator.talk.secrets'])