fix-cli-device-scope

修复 OpenClaw CLI 设备权限不足导致 subagent/spawn/cron 等操作被拒绝的问题。 触发词: pairing required, spawn失败, cron失败, 设备权限不足, admin scope, 死循环, CLI设备, scope不足。 当 spawn subagent 报 "gateway closed (1008): pairing required",且 gateway 本身运行正常时触发。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "fix-cli-device-scope" with this command: npx skills add whhh1994/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 running
  • openclaw 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.bakdevice-auth.json.bak
  • 确认 DEVICE_ID 是要修的设备(看 clientId=cliplatform=linux
  • 不要删除其他正常设备的 paired 记录
  • 修复后建议 openclaw doctor --fix 检查整体健康状态

注意事项

  • 必须重启 gateway 才能加载新 scopes
  • 新 token 格式 cli_admin_<random>,每次修复会更新
  • 如果 gateway 从旧备份恢复,旧 token 会重新生效,需重新修复
  • 没有 pending repair 请求的情况下,可手动构造 full_scopes 列表写入(['operator.admin', 'operator.read', 'operator.write', 'operator.approvals', 'operator.pairing', 'operator.talk.secrets']

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

run.dev — Local Dev Environment Manager

Local dev environment manager. Process management, automatic HTTPS domains, SSL certificates, reverse proxy, and AI crash diagnosis — single binary, zero con...

Registry SourceRecently Updated
Coding

ifly-image-understanding

iFlytek Image Understanding (图片理解) — analyze and answer questions about images using Spark Vision model. WebSocket API, pure Python stdlib, no pip dependencies.

Registry SourceRecently Updated
Coding

Civic Google

Use gog (Google CLI) without manual OAuth setup — Civic handles token management automatically

Registry SourceRecently Updated
2000Profile unavailable
Coding

Agent Browser.Skip

A fast Rust-based headless browser automation CLI with Node.js fallback that enables AI agents to navigate, click, type, and snapshot pages via structured co...

Registry SourceRecently Updated
2000Profile unavailable