/install fix-cli-device-scope
Fix CLI Device Scope
修复 OpenClaw CLI 设备 scope 权限不足导致的配对失败。
症状
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
快速诊断
一行命令输出完整诊断:
python3 scripts/diagnose.py
输出示例(需要修复):
=== 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 不了——死循环:
需要 admin scope → 才能 approve → admin scope 申请
⚠️ 检查点:修复前确认
执行修复脚本前,必须先展示将要改动的配置,等待用户确认:
# 先用 --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]:
用户确认后才执行:
python3 scripts/fix.py # 默认会先展示再询问
python3 scripts/fix.py --force # 跳过确认(仅限自动化场景)
验证修复
# 重启 gateway 加载新 scope
openclaw gateway restart
# 等待 ~5 秒后测试 spawn
用 sessions_spawn 工具验证,应该返回 status: accepted。
预防措施
- 修改前先备份
paired.json.bak和device-auth.json.bak - 确认 DEVICE_ID 是要修的设备(看
clientId=cli且platform=linux) - 不要删除其他正常设备的 paired 记录
- 修复后建议
openclaw doctor --fix检查整体健康状态
注意事项
- 必须重启 gateway 才能加载新 scopes
- 新 token 格式
cli_admin_\x3Crandom>,每次修复会更新 - 如果 gateway 从旧备份恢复,旧 token 会重新生效,需重新修复
- 没有 pending repair 请求的情况下,可手动构造 full_scopes 列表写入(
['operator.admin', 'operator.read', 'operator.write', 'operator.approvals', 'operator.pairing', 'operator.talk.secrets'])
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install fix-cli-device-scope - After installation, invoke the skill by name or use
/fix-cli-device-scope - Provide required inputs per the skill's parameter spec and get structured output
What is Fix CLI Device Scope?
修复 OpenClaw CLI 设备权限不足导致 subagent/spawn/cron 等操作被拒绝的问题。 触发词: pairing required, spawn失败, cron失败, 设备权限不足, admin scope, 死循环, CLI设备, scope不足。 当 spawn subagent 报... It is an AI Agent Skill for Claude Code / OpenClaw, with 83 downloads so far.
How do I install Fix CLI Device Scope?
Run "/install fix-cli-device-scope" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Fix CLI Device Scope free?
Yes, Fix CLI Device Scope is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Fix CLI Device Scope support?
Fix CLI Device Scope is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Fix CLI Device Scope?
It is built and maintained by whhh1994 (@whhh1994); the current version is v1.0.0.