[OpenClaw 文档]参考--CLI 命令

.ocdoc h2 { margin-top:2em; padding-bottom:.3em; border-bottom:2px solid #FF5A36; color:#FF5A36; }
.ocdoc h3 { margin-top:1.5em; color:#333; }
.ocdoc pre { background:#1e1e2e; color:#cdd6f4; padding:16px; border-radius:8px; overflow-x:auto; font-size:14px; line-height:1.6; }
.ocdoc code { font-family:'JetBrains Mono','Fira Code',Consolas,monospace; }
.ocdoc pre code { background:none; padding:0; color:inherit; }
.ocdoc :not(pre)>code { background:#f0f0f0; padding:2px 6px; border-radius:3px; font-size:.9em; color:#d63384; }
.ocdoc table { border-collapse:collapse; margin:1em 0; }
.ocdoc th,.ocdoc td { border:1px solid #ddd; padding:8px 12px; }
.ocdoc th { background:#f5f5f5; }
.ocdoc blockquote { border-left:4px solid #FF5A36; padding:.5em 1em; background:#fff7f4; color:#555; margin:1em 0; }
.ocdoc .page-sep { margin:2.5em 0; border:none; border-top:1px dashed #ccc; }
.ocdoc .page-title { color:#444; font-size:1.3em; margin-top:1em; padding:.4em .6em; background:#fafafa; border-left:4px solid #FF5A36; }
.ocdoc .src-link { font-size:.85em; color:#888; margin-top:2em; padding-top:1em; border-top:1px solid #e0e0e0; }
.ocdoc .toc-box { background:#f8f9fa; padding:1em 1.5em; border-radius:6px; margin:1em 0; }

[OpenClaw 文档]参考--CLI 命令

本文档汇总了 OpenClaw 官方文档站 参考 > CLI 命令 子模块下的全部 41 篇内容,源自 docs.openclaw.ai/zh-CN

📄 CLI 参考

原文:https://docs.openclaw.ai/zh-CN/cli

openclaw 是主要的 CLI 入口点。每个核心命令都有专门的参考页面,或者记录在它所别名指向的命令中;本索引列出命令、全局标志,以及适用于整个 CLI 的输出样式规则。

按意图使用设置命令:

  • openclaw setup 创建基线配置和工作区,不会走完整的引导式新手引导流程。
  • openclaw onboard 是完整的引导式首次运行路径,覆盖 Gateway 网关、模型凭证、工作区、渠道、Skills 和健康检查。
  • openclaw configure 更改现有设置中的特定部分,例如模型凭证、Gateway 网关、渠道、插件或 Skills。
  • openclaw channels add 在基线存在后配置渠道账号;不带标志运行可进入引导式渠道设置,或带渠道专用标志用于脚本。

命令页面

区域 命令
设置和新手引导 crestodian · setup · onboard · configure · config · completion · doctor · dashboard
重置和卸载 backup · reset · uninstall · update
消息和智能体 message · agent · agents · acp · mcp
健康检查和会话 status · health · sessions
Gateway 网关和日志 gateway · logs · system
Models 和推理 models · infer · capabilityinfer 的别名) · memory · commitments · wiki
网络和节点 directory · nodes · devices · node
运行时和沙箱 approvals · exec-policy(见 approvals) · sandbox · tui · chat/terminaltui --local 的别名) · browser
自动化 cron · tasks · hooks · webhooks
设备发现和文档 dns · docs
配对和渠道 pairing · qr · channels
安全和插件 security · secrets · skills · plugins · proxy
旧版别名 daemon(Gateway 网关服务) · clawbot(命名空间)
插件(可选) path · voicecall(如果已安装)

全局标志

标志 用途
--dev 将状态隔离在 ~/.openclaw-dev 下,并偏移默认端口
--profile <name> 将状态隔离在 ~/.openclaw-<name>
--container <name> 将执行目标设为指定命名容器
--no-color 禁用 ANSI 颜色(也会遵守 NO_COLOR=1
--update openclaw update 的简写(仅限源码安装)
-V, --version, -v 打印版本并退出

输出模式

  • ANSI 颜色和进度指示器仅在 TTY 会话中渲染。
  • 支持时,OSC-8 超链接会渲染为可点击链接;否则 CLI 会回退为纯 URL。
  • --json(以及支持处的 --plain)会禁用样式,以便获得干净输出。
  • 长时间运行的命令会显示进度指示器(支持时使用 OSC 9;4)。

调色板权威来源:src/terminal/palette.ts

命令树

openclaw [--dev] [--profile <name>] <command>
  crestodian
  setup
  onboard
  configure
  config
    get
    set
    unset
    file
    schema
    validate
  completion
  doctor
  dashboard
  backup
    create
    verify
  security
    audit
  secrets
    reload
    audit
    configure
    apply
  reset
  uninstall
  update
    wizard
    status
  channels
    list
    status
    capabilities
    resolve
    logs
    add
    remove
    login
    logout
  directory
    self
    peers list
    groups list|members
  skills
    search
    install
    update
    list
    info
    check
  plugins
    list
    inspect
    install
    uninstall
    update
    enable
    disable
    doctor
    marketplace list
  memory
    status
    index
    search
  path
    resolve
    find
    set
    validate
    emit
  commitments
    list
    dismiss
  wiki
    status
    doctor
    init
    ingest
    compile
    lint
    search
    get
    apply
    bridge import
    unsafe-local import
    obsidian status|search|open|command|daily
  message
    send
    broadcast
    poll
    react
    reactions
    read
    edit
    delete
    pin
    unpin
    pins
    permissions
    search
    thread create|list|reply
    emoji list|upload
    sticker send|upload
    role info|add|remove
    channel info|list
    member info
    voice status
    event list|create
    timeout
    kick
    ban
  agent
  agents
    list
    add
    delete
    bindings
    bind
    unbind
    set-identity
  acp
  mcp
    serve
    list
    show
    set
    unset
  status
  health
  sessions
    cleanup
  tasks
    list
    audit
    maintenance
    show
    notify
    cancel
    flow list|show|cancel
  gateway
    call
    usage-cost
    health
    status
    probe
    discover
    install
    uninstall
    start
    stop
    restart
    run
  daemon
    status
    install
    uninstall
    start
    stop
    restart
  logs
  system
    event
    heartbeat last|enable|disable
    presence
  models
    list
    status
    set
    set-image
    aliases list|add|remove
    fallbacks list|add|remove|clear
    image-fallbacks list|add|remove|clear
    scan
  infer (alias: capability)
    list
    inspect
    model run|list|inspect|providers|auth login|logout|status
    image generate|edit|describe|describe-many|providers
    audio transcribe|providers
    tts convert|voices|providers|status|enable|disable|set-provider
    video generate|describe|providers
    web search|fetch|providers
    embedding create|providers
    auth add|login|login-github-copilot|setup-token|paste-token
    auth order get|set|clear
  sandbox
    list
    recreate
    explain
  cron
    status
    list
    get
    add
    edit
    rm
    enable
    disable
    runs
    run
  nodes
    status
    describe
    list
    pending
    approve
    reject
    rename
    invoke
    notify
    push
    canvas snapshot|present|hide|navigate|eval
    canvas a2ui push|reset
    camera list|snap|clip
    screen record
    location get
  devices
    list
    remove
    clear
    approve
    reject
    rotate
    revoke
  node
    run
    status
    install
    uninstall
    stop
    restart
  approvals
    get
    set
    allowlist add|remove
  exec-policy
    show
    preset
    set
  browser
    status
    start
    stop
    reset-profile
    tabs
    open
    focus
    close
    profiles
    create-profile
    delete-profile
    screenshot
    snapshot
    navigate
    resize
    click
    type
    press
    hover
    drag
    select
    upload
    fill
    dialog
    wait
    evaluate
    console
    pdf
  hooks
    list
    info
    check
    enable
    disable
    install
    update
  webhooks
    gmail setup|run
  proxy
    start
    run
    coverage
    sessions
    query
    blob
    purge
  pairing
    list
    approve
  qr
  clawbot
    qr
  docs
  dns
    setup
  tui
  chat (alias: tui --local)
  terminal (alias: tui --local)

插件可以添加额外的顶级命令(例如 openclaw voicecall)。

聊天斜杠命令

聊天消息支持 /... 命令。见斜杠命令

重点:

  • /status — 快速诊断。
  • /trace — 会话范围的插件跟踪/调试行。
  • /config — 持久化的配置更改。
  • /debug — 仅运行时配置覆盖(内存中,不写入磁盘;需要 commands.debug: true)。

用量跟踪

当 OAuth/API 凭证可用时,openclaw status --usage 和控制 UI 会显示提供商用量/配额。数据直接来自提供商用量端点,并规范化为 X% left。拥有当前用量窗口的提供商:Anthropic、GitHub Copilot、Gemini CLI、OpenAI Codex、MiniMax、Xiaomi 和 z.ai。

详见用量跟踪

相关


📄 ACP

原文:https://docs.openclaw.ai/zh-CN/cli/acp

运行与 OpenClaw Gateway 网关通信的 Agent Client Protocol (ACP) bridge。

此命令通过 stdio 为 IDE 提供 ACP,并通过 WebSocket 将提示转发到 Gateway 网关。它会保持 ACP 会话与 Gateway 网关会话键之间的映射。

openclaw acp 是一个由 Gateway 网关支持的 ACP bridge,而不是完整的 ACP 原生编辑器运行时。它专注于会话路由、提示投递和基础流式传输更新。

如果你希望外部 MCP 客户端直接与 OpenClaw 渠道对话通信,而不是托管 ACP harness 会话,请改用 openclaw mcp serve

这不是什么

本页面经常会与 ACP harness 会话混淆。

openclaw acp 表示:

  • OpenClaw 充当 ACP 服务器
  • IDE 或 ACP 客户端连接到 OpenClaw
  • OpenClaw 将该工作转发到 Gateway 网关会话中

这不同于 ACP Agents,后者是 OpenClaw 通过 acpx 运行 Codex 或 Claude Code 等外部 harness。

快速规则:

  • 编辑器/客户端想通过 ACP 与 OpenClaw 通信:使用 openclaw acp
  • OpenClaw 应作为 ACP harness 启动 Codex/Claude/Gemini:使用 /acp spawnACP Agents

兼容性矩阵

ACP 范围 Status 备注
initialize, newSession, prompt, cancel 已实现 通过 stdio 到 Gateway 网关 chat/send + abort 的核心 bridge 流程。
listSessions, slash commands 已实现 会话列表基于 Gateway 网关会话状态工作,支持有界游标分页;当 Gateway 网关会话行带有工作区元数据时支持 cwd 过滤;命令通过 available_commands_update 公告。
会话谱系元数据 已实现 会话列表和会话信息快照会在 _meta 中包含 OpenClaw 父级和子级谱系,使 ACP 客户端无需私有 Gateway 网关旁路通道即可渲染子智能体图。
resumeSession, closeSession 已实现 Resume 会将 ACP 会话重新绑定到现有 Gateway 网关会话,而不重放历史。Close 会取消活动 bridge 工作,将挂起提示解析为已取消,并释放 bridge 会话状态。
loadSession 部分支持 将 ACP 会话重新绑定到 Gateway 网关键,并为 bridge 创建的会话重放 ACP 事件账本历史。较旧/无账本会话会回退到已存储的用户/助手文本。
提示内容(text、嵌入式 resource、图像) 部分支持 文本/资源会被展平为聊天输入;图像会成为 Gateway 网关附件。
会话模式 部分支持 支持 session/set_mode,并且 bridge 会公开初始 Gateway 网关支持的会话控件,包括思考级别、工具详细程度、推理、用量详情和提权操作。更广泛的 ACP 原生模式/配置界面仍不在范围内。
会话信息和用量更新 部分支持 bridge 会从缓存的 Gateway 网关会话快照发出 session_info_update 和尽力而为的 usage_update 通知。用量为近似值,并且仅在 Gateway 网关令牌总数被标记为新鲜时发送。
工具流式传输 部分支持 当 Gateway 网关工具参数/结果公开相关信息时,tool_call / tool_call_update 事件会包含原始 I/O、文本内容和尽力而为的文件位置。嵌入式终端和更丰富的 diff 原生输出仍未公开。
Exec 审批 部分支持 活动 ACP 提示轮次期间的 Gateway 网关 exec 审批提示会通过 session/request_permission 转发给 ACP 客户端。
每会话 MCP 服务器(mcpServers 不支持 Bridge 模式会拒绝每会话 MCP 服务器请求。请改为在 OpenClaw gateway 或智能体上配置 MCP。
客户端文件系统方法(fs/read_text_file, fs/write_text_file 不支持 bridge 不会调用 ACP 客户端文件系统方法。
客户端终端方法(terminal/* 不支持 bridge 不会创建 ACP 客户端终端,也不会通过工具调用流式传输终端 ID。
会话计划 / 思考流式传输 不支持 bridge 当前会发出输出文本和工具状态,而不是 ACP 计划或思考更新。

已知限制

  • loadSession 仅能为 bridge 创建的会话重放完整 ACP 事件账本历史。较旧/无账本会话仍使用转录回退,不会重建历史工具调用或系统通知。
  • 如果多个 ACP 客户端共享同一个 Gateway 网关键,事件和取消路由将是尽力而为,而不是按客户端严格隔离。需要干净的编辑器本地轮次时,优先使用默认隔离的 acp:<uuid> 会话。
  • Gateway 网关停止状态会被转换为 ACP 停止原因,但该映射的表达能力弱于完全 ACP 原生的运行时。
  • 初始会话控件当前仅暴露 Gateway 网关旋钮的一个聚焦子集:思考级别、工具详细程度、推理、用量详情和提权操作。模型选择和 exec 主机控件尚未作为 ACP 配置选项公开。
  • session_info_updateusage_update 派生自 Gateway 网关会话快照,而不是实时 ACP 原生运行时计量。用量是近似值,不包含成本数据,并且仅在 Gateway 网关将总令牌数据标记为新鲜时发出。
  • 工具跟随数据是尽力而为。bridge 可以展示出现在已知工具参数/结果中的文件路径,但尚未发出 ACP 终端或结构化文件 diff。
  • Exec 审批转发仅限于活动 ACP 提示轮次;来自其他 Gateway 网关会话的审批会被忽略。

用法

openclaw acp

# Remote Gateway
openclaw acp --url wss://gateway-host:18789 --token <token>

# Remote Gateway (token from file)
openclaw acp --url wss://gateway-host:18789 --token-file ~/.openclaw/gateway.token

# Attach to an existing session key
openclaw acp --session agent:main:main

# Attach by label (must already exist)
openclaw acp --session-label "support inbox"

# Reset the session key before the first prompt
openclaw acp --session agent:main:main --reset-session

ACP 客户端(调试)

使用内置 ACP 客户端在不依赖 IDE 的情况下对 bridge 做完整性检查。
它会生成 ACP bridge,并允许你交互式输入提示。

openclaw acp client

# Point the spawned bridge at a remote Gateway
openclaw acp client --server-args --url wss://gateway-host:18789 --token-file ~/.openclaw/gateway.token

# Override the server command (default: openclaw)
openclaw acp client --server "node" --server-args openclaw.mjs acp --url ws://127.0.0.1:19001

权限模型(客户端调试模式):

  • 自动审批基于允许列表,并且仅适用于受信任的核心工具 ID。
  • read 自动审批仅限当前工作目录(设置时为 --cwd)。
  • ACP 仅自动审批狭窄的只读类别:活动 cwd 下有范围限制的 read 调用,以及只读搜索工具(searchweb_searchmemory_search)。未知/非核心工具、范围外读取、具备 exec 能力的工具、控制平面工具、会修改状态的工具和交互式流程始终需要显式提示审批。
  • 服务器提供的 toolCall.kind 会被视为不可信元数据(不是授权来源)。
  • 此 ACP bridge 策略独立于 ACPX harness 权限。如果你通过 acpx 后端运行 OpenClaw,plugins.entries.acpx.config.permissionMode=approve-all 是该 harness 会话的应急 “yolo” 开关。

协议冒烟测试

对于协议级调试,请使用隔离状态启动 Gateway 网关,并使用 ACP JSON-RPC 客户端通过 stdio 驱动 openclaw acp。覆盖 initializesession/new、带绝对 cwdsession/listsession/resumesession/close、重复关闭和缺失恢复。

证明应包括公告的生命周期能力、Gateway 网关支持的会话行、更新通知和 Gateway 网关 sessions.list 日志:

{
  "initialize": {
    "protocolVersion": 1,
    "agentCapabilities": {
      "sessionCapabilities": {
        "list": {},
        "resume": {},
        "close": {}
      }
    }
  },
  "listSessions": {
    "sessions": [
      {
        "sessionId": "agent:main:acp-smoke",
        "cwd": "/path/to/workspace",
        "_meta": {
          "sessionKey": "agent:main:acp-smoke",
          "kind": "direct"
        }
      }
    ],
    "nextCursor": null
  },
  "notifications": ["session_info_update", "available_commands_update", "usage_update"],
  "gatewayLogTail": ["[gateway] ready", "[ws] ⇄ res ✓ sessions.list 305ms"]
}

避免将 openclaw gateway call sessions.list 作为唯一 ACP 证明。该 CLI 路径可能会请求 fresh-token 操作员范围升级;ACP bridge 正确性应通过 ACP stdio 帧加 Gateway 网关 sessions.list 日志来证明。

如何使用

当 IDE(或其他客户端)使用 Agent Client Protocol,并且你希望它驱动 OpenClaw Gateway 网关会话时,请使用 ACP。

  1. 确保 Gateway 网关正在运行(本地或远程)。
  2. 配置 Gateway 网关目标(配置或标志)。
  3. 将你的 IDE 指向通过 stdio 运行的 openclaw acp

示例配置(持久化):

openclaw config set gateway.remote.url wss://gateway-host:18789
openclaw config set gateway.remote.token <token>

示例直接运行(不写入配置):

openclaw acp --url wss://gateway-host:18789 --token <token>
# preferred for local process safety
openclaw acp --url wss://gateway-host:18789 --token-file ~/.openclaw/gateway.token

选择智能体

ACP 不会直接选择智能体。它按 Gateway 网关会话键进行路由。

使用限定智能体范围的会话键来指定特定智能体:

openclaw acp --session agent:main:main
openclaw acp --session agent:design:main
openclaw acp --session agent:qa:bug-123

每个 ACP 会话都会映射到单个 Gateway 网关会话键。一个智能体可以有多个
会话;除非你覆盖该键或标签,否则 ACP 默认使用隔离的 acp:<uuid> 会话。

桥接模式不支持按会话设置 mcpServers。如果 ACP 客户端在 newSessionloadSession
期间发送它们,桥接会返回明确错误,而不是静默忽略。

如果你希望 ACPX 支持的会话能够看到 OpenClaw 插件工具或所选内置工具(例如 cron),请启用
Gateway 网关侧的 ACPX MCP 桥接,而不是尝试传入按会话设置的 mcpServers。请参阅
ACP 智能体
OpenClaw 工具 MCP 桥接

acpx 使用(Codex、Claude、其他 ACP 客户端)

如果你希望 Codex 或 Claude Code 这样的编码智能体通过 ACP 与你的
OpenClaw bot 通信,请使用 acpx 及其内置的 openclaw 目标。

典型流程:

  1. 运行 Gateway 网关,并确保 ACP 桥接可以访问它。
  2. acpx openclaw 指向 openclaw acp
  3. 定位你希望编码智能体使用的 OpenClaw 会话键。

示例:

# One-shot request into your default OpenClaw ACP session
acpx openclaw exec "Summarize the active OpenClaw session state."

# Persistent named session for follow-up turns
acpx openclaw sessions ensure --name codex-bridge
acpx openclaw -s codex-bridge --cwd /path/to/repo \
  "Ask my OpenClaw work agent for recent context relevant to this repo."

如果你希望 acpx openclaw 每次都定位到特定的 Gateway 网关和会话键,请在 ~/.acpx/config.json
中覆盖 openclaw 智能体命令:

{
  "agents": {
    "openclaw": {
      "command": "env OPENCLAW_HIDE_BANNER=1 OPENCLAW_SUPPRESS_NOTES=1 openclaw acp --url ws://127.0.0.1:18789 --token-file ~/.openclaw/gateway.token --session agent:main:main"
    }
  }
}

对于仓库本地的 OpenClaw checkout,请使用直接 CLI 入口点,而不是开发运行器,这样 ACP 流才能保持干净。例如:

env OPENCLAW_HIDE_BANNER=1 OPENCLAW_SUPPRESS_NOTES=1 node openclaw.mjs acp ...

这是让 Codex、Claude Code 或其他支持 ACP 的客户端从 OpenClaw 智能体拉取上下文信息的最简单方式,无需抓取终端内容。

Zed 编辑器设置

~/.config/zed/settings.json 中添加自定义 ACP 智能体(或使用 Zed 的设置 UI):

{
  "agent_servers": {
    "OpenClaw ACP": {
      "type": "custom",
      "command": "openclaw",
      "args": ["acp"],
      "env": {}
    }
  }
}

要定位特定的 Gateway 网关或智能体:

{
  "agent_servers": {
    "OpenClaw ACP": {
      "type": "custom",
      "command": "openclaw",
      "args": [
        "acp",
        "--url",
        "wss://gateway-host:18789",
        "--token",
        "<token>",
        "--session",
        "agent:design:main"
      ],
      "env": {}
    }
  }
}

在 Zed 中,打开 Agent 面板并选择 “OpenClaw ACP” 以启动一个线程。

会话映射

默认情况下,ACP 会话会获得一个带有 acp: 前缀的隔离 Gateway 网关会话键。
要复用已知会话,请传入会话键或标签:

  • --session <key>:使用特定的 Gateway 网关会话键。
  • --session-label <label>:按标签解析现有会话。
  • --reset-session:为该键生成新的会话 ID(相同键,新的转录记录)。

如果你的 ACP 客户端支持元数据,可以按会话覆盖:

{
  "_meta": {
    "sessionKey": "agent:main:main",
    "sessionLabel": "support inbox",
    "resetSession": true
  }
}

/concepts/session 了解更多关于会话键的信息。

选项

  • --url <url>:Gateway 网关 WebSocket URL(配置后默认使用 gateway.remote.url)。
  • --token <token>:Gateway 网关认证令牌。
  • --token-file <path>:从文件读取 Gateway 网关认证令牌。
  • --password <password>:Gateway 网关认证密码。
  • --password-file <path>:从文件读取 Gateway 网关认证密码。
  • --session <key>:默认会话键。
  • --session-label <label>:要解析的默认会话标签。
  • --require-existing:如果会话键/标签不存在,则失败。
  • --reset-session:首次使用前重置会话键。
  • --no-prefix-cwd:不要在提示前加上工作目录。
  • --provenance <off|meta|meta+receipt>:包含 ACP 溯源元数据或回执。
  • --verbose, -v:将详细日志输出到 stderr。

安全注意事项:

  • 在某些系统上,--token--password 可能会出现在本地进程列表中。
  • 优先使用 --token-file/--password-file 或环境变量(OPENCLAW_GATEWAY_TOKENOPENCLAW_GATEWAY_PASSWORD)。
  • Gateway 网关认证解析遵循其他 Gateway 网关客户端使用的共享契约:
  • 本地模式:env(OPENCLAW_GATEWAY_*)-> gateway.auth.* -> 仅当 gateway.auth.* 未设置时回退到 gateway.remote.*(已配置但未解析的本地 SecretRefs 会失败关闭)
  • 远程模式:gateway.remote.*,并按远程优先级规则使用 env/config 回退
  • --url 是覆盖安全的,不会复用隐式 config/env 凭证;请传入显式 --token/--password(或文件变体)
  • ACP 运行时后端子进程会接收 OPENCLAW_SHELL=acp,可用于特定上下文的 shell/profile 规则。
  • openclaw acp client 会在生成的桥接进程上设置 OPENCLAW_SHELL=acp-client

acp client 选项

  • --cwd <dir>:ACP 会话的工作目录。
  • --server <command>:ACP 服务器命令(默认:openclaw)。
  • --server-args <args...>:传递给 ACP 服务器的额外参数。
  • --server-verbose:在 ACP 服务器上启用详细日志。
  • --verbose, -v:详细客户端日志。

相关


📄 智能体

原文:https://docs.openclaw.ai/zh-CN/cli/agent

openclaw agent

通过 Gateway 网关运行一次智能体轮次(嵌入式模式使用 --local)。
使用 --agent <id> 直接定位一个已配置的智能体。

至少传入一个会话选择器:

  • --to <dest>
  • --session-id <id>
  • --agent <id>

相关:

选项

  • -m, --message <text>:必需的消息正文
  • -t, --to <dest>:用于派生会话键的接收方
  • --session-id <id>:显式会话 id
  • --agent <id>:智能体 id;覆盖路由绑定
  • --model <id>:本次运行的模型覆盖项(provider/model 或模型 id)
  • --thinking <level>:智能体思考级别(offminimallowmediumhigh,以及提供商支持的自定义级别,例如 xhighadaptivemax
  • --verbose <on|off>:为会话持久化详细级别
  • --channel <channel>:投递渠道;省略时使用主会话渠道
  • --reply-to <target>:投递目标覆盖项
  • --reply-channel <channel>:投递渠道覆盖项
  • --reply-account <id>:投递账号覆盖项
  • --local:直接运行嵌入式智能体(在插件注册表预加载之后)
  • --deliver:将回复发送回所选渠道/目标
  • --timeout <seconds>:覆盖智能体超时时间(默认 600 或配置值)
  • --json:输出 JSON

示例

openclaw agent --to +15555550123 --message "status update" --deliver
openclaw agent --agent ops --message "Summarize logs"
openclaw agent --agent ops --model openai/gpt-5.4 --message "Summarize logs"
openclaw agent --session-id 1234 --message "Summarize inbox" --thinking medium
openclaw agent --to +15555550123 --message "Trace logs" --verbose on --json
openclaw agent --agent ops --message "Generate report" --deliver --reply-channel slack --reply-to "#reports"
openclaw agent --agent ops --message "Run locally" --local

注意事项

  • 当 Gateway 网关请求失败时,Gateway 网关模式会回退到嵌入式智能体。使用 --local 可从一开始就强制嵌入式执行。
  • --local 仍会先预加载插件注册表,因此插件提供的提供商、工具和渠道在嵌入式运行期间仍然可用。
  • --local 和嵌入式回退运行会被视为一次性运行。为该本地进程打开的内置 MCP 回环资源和预热的 Claude stdio 会话会在回复后被回收,因此脚本化调用不会让本地子进程保持存活。
  • Gateway 网关支持的运行会将 Gateway 网关拥有的 MCP 回环资源留在正在运行的 Gateway 网关进程下;较旧的客户端可能仍会发送历史清理标志,但 Gateway 网关会将其作为兼容性空操作接受。
  • --channel--reply-channel--reply-account 影响回复投递,而不影响会话路由。
  • --json 会将 stdout 保留给 JSON 响应。Gateway 网关、插件和嵌入式回退诊断信息会路由到 stderr,因此脚本可以直接解析 stdout。
  • 嵌入式回退 JSON 包含 meta.transport: "embedded"meta.fallbackFrom: "gateway",因此脚本可以区分回退运行和 Gateway 网关运行。
  • 如果 Gateway 网关接受了智能体运行,但 CLI 在等待最终回复时超时,嵌入式回退会使用一个新的显式 gateway-fallback-* 会话/运行 id,并报告 meta.fallbackReason: "gateway_timeout" 以及回退会话字段。这样可以避免与 Gateway 网关拥有的转录锁竞争,或静默替换原始路由会话。
  • 当此命令触发 models.json 重新生成时,由 SecretRef 管理的提供商凭证会以非密钥标记形式持久化(例如环境变量名称、secretref-env:ENV_VAR_NAMEsecretref-managed),而不是解析后的密钥明文。
  • 标记写入以源为权威:OpenClaw 会从活动源配置快照持久化标记,而不是从解析后的运行时密钥值持久化。

JSON 投递状态

使用 --json --deliver 时,CLI JSON 响应可能包含顶层 deliveryStatus,以便脚本区分已投递、已抑制、部分失败和发送失败:

{
  "payloads": [{ "text": "Report ready", "mediaUrl": null }],
  "meta": { "durationMs": 1200 },
  "deliveryStatus": {
    "requested": true,
    "attempted": true,
    "status": "sent",
    "succeeded": true,
    "resultCount": 1
  }
}

deliveryStatus.statussentsuppressedpartial_failedfailed 之一。suppressed 表示有意未发送投递,例如消息发送钩子取消了它,或者没有可见结果;它仍然是一个终止性的无重试结果。partial_failed 表示至少一个载荷已发送,但后续载荷失败。failed 表示没有完成持久发送,或投递预检失败。

Gateway 网关支持的 CLI 响应也会保留原始 Gateway 网关结果形状,其中同一对象可在 result.deliveryStatus 中获得。

常见字段:

  • requested:对象存在时始终为 true
  • attempted:持久发送路径运行后为 true;预检失败或没有可见载荷时为 false
  • succeededtruefalse"partial""partial"status: "partial_failed" 配对。
  • reason:来自持久投递或预检验证的小写 snake-case 原因。已知原因包括 cancelled_by_message_sending_hookno_visible_payloadno_visible_resultchannel_resolved_to_internalunknown_channelinvalid_delivery_targetno_delivery_target;失败的持久发送也可能报告失败阶段。将未知值视为不透明值,因为集合可能会扩展。
  • resultCount:可用时表示渠道发送结果的数量。
  • sentBeforeError:部分失败在发生错误前已发送至少一个载荷时为 true
  • error:发送失败或部分失败时布尔值为 true
  • errorMessage:仅在捕获到底层投递错误消息时包含。预检失败会带有 errorreason,但没有 errorMessage
  • payloadOutcomes:可选的逐载荷结果,可用时包含 indexstatusreasonresultCounterrorstagesentBeforeError 或钩子元数据。

相关


📄 智能体

原文:https://docs.openclaw.ai/zh-CN/cli/agents

openclaw agents

管理隔离的智能体(工作区 + 凭证 + 路由)。

相关内容:

示例

openclaw agents list
openclaw agents list --bindings
openclaw agents add work --workspace ~/.openclaw/workspace-work
openclaw agents add ops --workspace ~/.openclaw/workspace-ops --bind telegram:ops --non-interactive
openclaw agents bindings
openclaw agents bind --agent work --bind telegram:ops
openclaw agents unbind --agent work --bind telegram:ops
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity
openclaw agents set-identity --agent main --avatar avatars/openclaw.png
openclaw agents delete work

路由绑定

使用路由绑定将入站渠道流量固定到特定智能体。

如果你还想为每个智能体配置不同的可见 Skills,请在 openclaw.json 中配置 agents.defaults.skillsagents.list[].skills。请参阅 Skills 配置配置参考

列出绑定:

openclaw agents bindings
openclaw agents bindings --agent work
openclaw agents bindings --json

添加绑定:

openclaw agents bind --agent work --bind telegram:ops --bind discord:guild-a

如果省略 accountId--bind <channel>),OpenClaw 会在可用时从渠道默认值和插件设置钩子中解析它。

如果对 bindunbind 省略 --agent,OpenClaw 会以当前默认智能体为目标。

绑定范围行为

  • 没有 accountId 的绑定只匹配渠道默认账号。
  • accountId: "*" 是渠道范围的后备项(所有账号),其优先级低于显式账号绑定。
  • 如果同一个智能体已经有一个匹配的、没有 accountId 的渠道绑定,而你稍后使用显式或解析出的 accountId 进行绑定,OpenClaw 会就地升级现有绑定,而不是添加重复项。

示例:

# initial channel-only binding
openclaw agents bind --agent work --bind telegram

# later upgrade to account-scoped binding
openclaw agents bind --agent work --bind telegram:ops

升级后,该绑定的路由范围限定为 telegram:ops。如果你还想要默认账号路由,请显式添加它(例如 --bind telegram:default)。

移除绑定:

openclaw agents unbind --agent work --bind telegram:ops
openclaw agents unbind --agent work --all

unbind 接受 --all 或一个或多个 --bind 值,不能同时使用两者。

命令表面

agents

不带子命令运行 openclaw agents 等同于 openclaw agents list

agents list

选项:

  • --json
  • --bindings:包含完整路由规则,而不仅是每个智能体的计数/摘要

agents add [name]

选项:

  • --workspace <dir>
  • --model <id>
  • --agent-dir <dir>
  • --bind <channel[:accountId]>(可重复)
  • --non-interactive
  • --json

注意:

  • 传入任何显式添加标志都会将命令切换到非交互路径。
  • 非交互模式需要同时提供智能体名称和 --workspace
  • main 是保留字,不能用作新的智能体 ID。
  • 在交互模式下,凭证植入只会复制可移植的静态配置文件
    (默认是 api_key 和静态 token)。OAuth 刷新令牌配置文件仍然
    只能通过从真实 main 智能体存储进行读取继承来使用。
    如果配置的默认智能体不是 main,请为新智能体单独登录 OAuth
    配置文件。

agents bindings

选项:

  • --agent <id>
  • --json

agents bind

选项:

  • --agent <id>(默认为当前默认智能体)
  • --bind <channel[:accountId]>(可重复)
  • --json

agents unbind

选项:

  • --agent <id>(默认为当前默认智能体)
  • --bind <channel[:accountId]>(可重复)
  • --all
  • --json

agents delete <id>

选项:

  • --force
  • --json

注意:

  • main 不能被删除。
  • 如果没有 --force,需要交互式确认。
  • 工作区、智能体状态和会话转录目录会被移动到废纸篓,而不是硬删除。
  • 当 Gateway 网关可访问时,删除会通过 Gateway 网关发送,因此配置和会话存储清理会与运行时流量共享同一个写入器。如果无法访问 Gateway 网关,CLI 会回退到离线本地路径。
  • 如果另一个智能体的工作区是同一路径、位于此工作区内,或包含此工作区,
    该工作区会被保留,并且 --json 会报告 workspaceRetained
    workspaceRetainedReasonworkspaceSharedWith

身份文件

每个智能体工作区都可以在工作区根目录包含一个 IDENTITY.md

  • 示例路径:~/.openclaw/workspace/IDENTITY.md
  • set-identity --from-identity 从工作区根目录(或显式的 --identity-file)读取

头像路径相对于工作区根目录解析。

设置身份

set-identity 会将字段写入 agents.list[].identity

  • name
  • theme
  • emoji
  • avatar(工作区相对路径、http(s) URL 或 data URI)

选项:

  • --agent <id>
  • --workspace <dir>
  • --identity-file <path>
  • --from-identity
  • --name <name>
  • --theme <theme>
  • --emoji <emoji>
  • --avatar <value>
  • --json

注意:

  • --agent--workspace 可用于选择目标智能体。
  • 如果你依赖 --workspace,且多个智能体共享该工作区,命令会失败并要求你传入 --agent
  • 如果没有提供显式身份字段,命令会从 IDENTITY.md 读取身份数据。

IDENTITY.md 加载:

openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity

显式覆盖字段:

openclaw agents set-identity --agent main --name "OpenClaw" --emoji "🦞" --avatar avatars/openclaw.png

配置示例:

{
  agents: {
    list: [
      {
        id: "main",
        identity: {
          name: "OpenClaw",
          theme: "space lobster",
          emoji: "🦞",
          avatar: "avatars/openclaw.png",
        },
      },
    ],
  },
}

相关内容


📄 批准

原文:https://docs.openclaw.ai/zh-CN/cli/approvals

openclaw approvals

管理本地主机Gateway 网关主机节点主机的执行批准设置。
默认情况下,命令会针对磁盘上的本地 approvals 文件。使用 --gateway 可将目标设为 Gateway 网关,或使用 --node 将目标设为特定节点。

别名:openclaw exec-approvals

相关内容:

openclaw exec-policy

openclaw exec-policy 是一个本地方便命令,用于一步保持请求的
tools.exec.* 配置与本地主机 approvals 文件对齐。

在以下情况下使用它:

  • 检查本地请求策略、主机 approvals 文件和生效后的合并结果
  • 应用本地预设,例如 YOLO 或全部拒绝
  • 同步本地 tools.exec.* 和本地 ~/.openclaw/exec-approvals.json

示例:

openclaw exec-policy show
openclaw exec-policy show --json

openclaw exec-policy preset yolo
openclaw exec-policy preset cautious --json

openclaw exec-policy set --host gateway --security full --ask off --ask-fallback full

输出模式:

  • 不使用 --json:打印便于阅读的表格视图
  • --json:打印适合机器读取的结构化输出

当前范围:

  • exec-policy 仅限本地
  • 它会同时更新本地配置文件和本地 approvals 文件
  • 不会将策略推送到 Gateway 网关主机或节点主机
  • 在此命令中,--host node 会被拒绝,因为节点执行批准是在运行时从节点获取的,必须改用面向节点的 approvals 命令来管理
  • openclaw exec-policy show 会将 host=node 范围标记为运行时由节点管理,而不是根据本地 approvals 文件推导生效策略

如果你需要直接编辑远程主机 approvals,请继续使用 openclaw approvals set --gateway
openclaw approvals set --node <id|name|ip>

常用命令

openclaw approvals get
openclaw approvals get --node <id|name|ip>
openclaw approvals get --gateway

openclaw approvals get 现在会显示本地、Gateway 网关和节点目标的生效执行策略:

  • 请求的 tools.exec 策略
  • 主机 approvals 文件策略
  • 应用优先级规则后的生效结果

这种优先级设计是有意为之:

  • 主机 approvals 文件是可执行的事实来源
  • 请求的 tools.exec 策略可以收紧或放宽意图,但生效结果仍然由主机规则推导得出
  • --node 会将节点主机 approvals 文件与 Gateway 网关 tools.exec 策略组合,因为两者在运行时仍然会同时生效
  • 如果 Gateway 网关配置不可用,CLI 会回退到节点 approvals 快照,并注明无法计算最终运行时策略

从文件替换 approvals

openclaw approvals set --file ./exec-approvals.json
openclaw approvals set --stdin <<'EOF'
{ version: 1, defaults: { security: "full", ask: "off" } }
EOF
openclaw approvals set --node <id|name|ip> --file ./exec-approvals.json
openclaw approvals set --gateway --file ./exec-approvals.json

set 接受 JSON5,而不只是严格 JSON。使用 --file--stdin 其中之一,不要同时使用两者。

“永不提示” / YOLO 示例

对于一个不应因执行批准而中断的主机,将主机 approvals 默认值设置为 full + off

openclaw approvals set --stdin <<'EOF'
{
  version: 1,
  defaults: {
    security: "full",
    ask: "off",
    askFallback: "full"
  }
}
EOF

节点变体:

openclaw approvals set --node <id|name|ip> --stdin <<'EOF'
{
  version: 1,
  defaults: {
    security: "full",
    ask: "off",
    askFallback: "full"
  }
}
EOF

这只会更改主机 approvals 文件。要让请求的 OpenClaw 策略也保持一致,还需要设置:

openclaw config set tools.exec.host gateway
openclaw config set tools.exec.security full
openclaw config set tools.exec.ask off

为什么这个示例里使用 tools.exec.host=gateway

  • host=auto 仍然表示“如果可用则使用沙箱,否则使用 Gateway 网关”。
  • YOLO 关乎批准,而不是路由。
  • 如果你希望即使已配置沙箱也使用主机执行,请使用 gateway/exec host=gateway 明确指定主机选择。

这与当前主机默认的 YOLO 行为一致。如果你希望启用批准,请收紧它。

本地快捷方式:

openclaw exec-policy preset yolo

这个本地快捷方式会同时更新请求的本地 tools.exec.* 配置和本地 approvals 默认值。
其意图等同于上面的手动两步设置,但仅适用于本机。

允许列表辅助命令

openclaw approvals allowlist add "~/Projects/**/bin/rg"
openclaw approvals allowlist add --agent main --node <id|name|ip> "/usr/bin/uptime"
openclaw approvals allowlist add --agent "*" "/usr/bin/uname"

openclaw approvals allowlist remove "~/Projects/**/bin/rg"

常用选项

getsetallowlist add|remove 都支持:

  • --node <id|name|ip>
  • --gateway
  • 共享的节点 RPC 选项:--url--token--timeout--json

目标说明:

  • 不带目标标志表示磁盘上的本地 approvals 文件
  • --gateway 以 Gateway 网关主机 approvals 文件为目标
  • --node 会在解析 id、名称、IP 或 id 前缀后,以某个节点主机为目标

allowlist add|remove 还支持:

  • --agent <id>(默认为 *

注意事项

  • --node 使用与 openclaw nodes 相同的解析器(id、名称、ip 或 id 前缀)。
  • --agent 默认为 "*",适用于所有智能体。
  • 节点主机必须声明 system.execApprovals.get/set(macOS 应用或无头节点主机)。
  • Approvals 文件按主机存储在 ~/.openclaw/exec-approvals.json

相关内容


📄 浏览器

原文:https://docs.openclaw.ai/zh-CN/cli/browser

openclaw browser

管理 OpenClaw 的浏览器控制界面并运行浏览器操作(生命周期、配置档案、标签页、快照、截图、导航、输入、状态模拟和调试)。

相关内容:

常用标志

  • --url <gatewayWsUrl>:Gateway 网关 WebSocket URL(默认来自配置)。
  • --token <token>:Gateway 网关令牌(如果需要)。
  • --timeout <ms>:请求超时时间(毫秒)。
  • --expect-final:等待最终的 Gateway 网关响应。
  • --browser-profile <name>:选择浏览器配置档案(默认来自配置)。
  • --json:机器可读输出(在支持的地方)。

快速开始(本地)

openclaw browser profiles
openclaw browser --browser-profile openclaw start
openclaw browser --browser-profile openclaw open https://example.com
openclaw browser --browser-profile openclaw snapshot

智能体也可以使用同样的就绪检查:browser({ action: "doctor" })

快速故障排除

如果 start 失败并显示 not reachable after start,请先排查 CDP 就绪状态。如果 starttabs 成功,但 opennavigate 失败,说明浏览器控制平面是正常的,而失败通常是导航 SSRF 策略导致的。

最小排查顺序:

openclaw browser --browser-profile openclaw doctor
openclaw browser --browser-profile openclaw start
openclaw browser --browser-profile openclaw tabs
openclaw browser --browser-profile openclaw open https://example.com

详细指南:浏览器故障排除

生命周期

openclaw browser status
openclaw browser doctor
openclaw browser doctor --deep
openclaw browser start
openclaw browser start --headless
openclaw browser stop
openclaw browser --browser-profile openclaw reset-profile

说明:

  • doctor --deep 会增加一个实时快照探测。当基础 CDP 就绪状态显示正常,但你想确认当前标签页确实可被检查时,这会很有用。
  • 对于 attachOnly 和远程 CDP 配置档案,openclaw browser stop 会关闭当前活动控制会话,并清除临时模拟覆盖项,即使 OpenClaw 本身没有启动浏览器进程也是如此。
  • 对于本地受管配置档案,openclaw browser stop 会停止所启动的浏览器进程。
  • openclaw browser start --headless 仅适用于这一次启动请求,并且只在 OpenClaw 启动本地受管浏览器时生效。它不会改写 browser.headless 或配置档案配置,对于已经在运行的浏览器也不会产生效果。
  • 在没有 DISPLAYWAYLAND_DISPLAY 的 Linux 主机上,本地受管配置档案会自动以无头模式运行,除非 OPENCLAW_BROWSER_HEADLESS=0browser.headless=falsebrowser.profiles.<name>.headless=false 明确要求显示浏览器界面。

如果命令不存在

如果 openclaw browser 是未知命令,请检查 ~/.openclaw/openclaw.json 中的 plugins.allow

当存在 plugins.allow 时,请显式列出内置的浏览器插件,除非配置中已经有根级 browser 块:

{
  plugins: {
    allow: ["telegram", "browser"],
  },
}

显式的根级 browser 块,例如 browser.enabled=truebrowser.profiles.<name>,也会在受限的插件允许列表下激活内置浏览器插件。

相关内容:Browser 工具

配置档案

配置档案是具名的浏览器路由配置。实际使用中:

  • openclaw:启动或连接到专用的 OpenClaw 受管 Chrome 实例(隔离的用户数据目录)。
  • user:通过 Chrome DevTools MCP 控制你当前已登录的 Chrome 会话。
  • 自定义 CDP 配置档案:指向本地或远程 CDP 端点。
openclaw browser profiles
openclaw browser create-profile --name work --color "#FF5A36"
openclaw browser create-profile --name chrome-live --driver existing-session
openclaw browser create-profile --name remote --cdp-url https://browser-host.example.com
openclaw browser delete-profile --name work

使用特定配置档案:

openclaw browser --browser-profile work tabs

标签页

openclaw browser tabs
openclaw browser tab new --label docs
openclaw browser tab label t1 docs
openclaw browser tab select 2
openclaw browser tab close 2
openclaw browser open https://docs.openclaw.ai --label docs
openclaw browser focus docs
openclaw browser close t1

tabs 会先返回 suggestedTargetId,然后是稳定的 tabId(如 t1)、可选标签以及原始 targetId。智能体应将 suggestedTargetId 传回 focusclose、快照和操作命令。你可以通过 open --labeltab new --labeltab label 分配标签;标签、标签页 ID、原始目标 ID,以及唯一的目标 ID 前缀都可以使用。
当 Chromium 在导航或表单提交期间替换底层原始目标时,只要 OpenClaw 能够确认匹配关系,就会将稳定的 tabId/标签附加到替换后的标签页上。原始目标 ID 仍然是不稳定的;优先使用 suggestedTargetId

快照 / 截图 / 操作

快照:

openclaw browser snapshot
openclaw browser snapshot --urls

截图:

openclaw browser screenshot
openclaw browser screenshot --full-page
openclaw browser screenshot --ref e12
openclaw browser screenshot --labels

说明:

  • --full-page 仅用于整页截图;不能与 --ref--element 组合使用。
  • existing-session / user 配置档案支持整页截图,以及基于快照输出中的 --ref 的截图,但不支持 CSS --element 截图。
  • --labels 会在截图上叠加当前快照引用标记。
  • snapshot --urls 会将已发现的链接目标地址追加到 AI 快照中,这样智能体就可以选择直接导航目标,而不必仅根据链接文本猜测。

导航 / 点击 / 输入(基于 ref 的 UI 自动化):

openclaw browser navigate https://example.com
openclaw browser click <ref>
openclaw browser click-coords 120 340
openclaw browser type <ref> "hello"
openclaw browser press Enter
openclaw browser hover <ref>
openclaw browser scrollintoview <ref>
openclaw browser drag <startRef> <endRef>
openclaw browser select <ref> OptionA OptionB
openclaw browser fill --fields '[{"ref":"1","value":"Ada"}]'
openclaw browser wait --text "Done"
openclaw browser evaluate --fn '(el) => el.textContent' --ref <ref>

在 OpenClaw 能够确认替换标签页时,操作响应会在操作触发页面替换后返回当前原始 targetId。对于长生命周期工作流,脚本仍应存储并传递 suggestedTargetId/标签。

文件和对话框辅助命令:

openclaw browser upload /tmp/openclaw/uploads/file.pdf --ref <ref>
openclaw browser waitfordownload
openclaw browser download <ref> report.pdf
openclaw browser dialog --accept

受管 Chrome 配置档案会将普通点击触发的下载保存到 OpenClaw 下载目录(默认是 /tmp/openclaw/downloads,或已配置的临时根目录)。当智能体需要等待特定文件并返回其路径时,请使用 waitfordownloaddownload;这些显式等待器会接管下一次下载。

状态和存储

视口 + 模拟:

openclaw browser resize 1280 720
openclaw browser set viewport 1280 720
openclaw browser set offline on
openclaw browser set media dark
openclaw browser set timezone Europe/London
openclaw browser set locale en-GB
openclaw browser set geo 51.5074 -0.1278 --accuracy 25
openclaw browser set device "iPhone 14"
openclaw browser set headers '{"x-test":"1"}'
openclaw browser set credentials myuser mypass

Cookies + 存储:

openclaw browser cookies
openclaw browser cookies set session abc123 --url https://example.com
openclaw browser cookies clear
openclaw browser storage local get
openclaw browser storage local set token abc123
openclaw browser storage session clear

调试

openclaw browser console --level error
openclaw browser pdf
openclaw browser responsebody "**/api"
openclaw browser highlight <ref>
openclaw browser errors --clear
openclaw browser requests --filter api
openclaw browser trace start
openclaw browser trace stop --out trace.zip

通过 MCP 使用现有 Chrome

使用内置的 user 配置档案,或者创建你自己的 existing-session 配置档案:

openclaw browser --browser-profile user tabs
openclaw browser create-profile --name chrome-live --driver existing-session
openclaw browser create-profile --name brave-live --driver existing-session --user-data-dir "~/Library/Application Support/BraveSoftware/Brave-Browser"
openclaw browser --browser-profile chrome-live tabs

这一路径仅适用于主机本机。对于 Docker、无头服务器、Browserless 或其他远程设置,请改用 CDP 配置档案。

当前 existing-session 的限制:

  • 基于快照的操作使用 ref,而不是 CSS 选择器
  • 当调用方省略 timeoutMs 时,browser.actionTimeoutMs 会将受支持的 act 请求默认设置为 60000 毫秒;但每次调用传入的 timeoutMs 仍然优先生效。
  • click 仅支持左键点击
  • type 不支持 slowly=true
  • press 不支持 delayMs
  • hoverscrollintoviewdragselectfillevaluate 会拒绝每次调用的超时覆盖
  • select 仅支持单个值
  • 不支持 wait --load networkidle
  • 文件上传需要 --ref / --input-ref,不支持 CSS --element,并且当前一次只支持一个文件
  • 对话框钩子不支持 --timeout
  • 截图支持整页截图和 --ref,但不支持 CSS --element
  • responsebody、下载拦截、PDF 导出以及批量操作仍然需要受管浏览器或原始 CDP 配置档案

远程浏览器控制(节点主机代理)

如果 Gateway 网关运行在与浏览器不同的机器上,请在安装了 Chrome/Brave/Edge/Chromium 的机器上运行一个节点主机。Gateway 网关会将浏览器操作代理到该节点(不需要单独的浏览器控制服务器)。

使用 gateway.nodes.browser.mode 控制自动路由,并使用 gateway.nodes.browser.node 在连接了多个节点时固定到特定节点。

安全性与远程设置:Browser 工具远程访问Tailscale安全性

相关内容


📄 渠道

原文:https://docs.openclaw.ai/zh-CN/cli/channels

openclaw channels

管理 Gateway 网关上的聊天渠道账户及其运行时状态。

相关文档:

常用命令

openclaw channels list
openclaw channels list --all
openclaw channels status
openclaw channels capabilities
openclaw channels capabilities --channel discord --target channel:123
openclaw channels capabilities --channel discord --target channel:<voice-channel-id>
openclaw channels resolve --channel slack "#general" "@jane"
openclaw channels logs --channel all

channels list 只显示聊天渠道:默认显示已配置的账户,并按账户显示 installedconfiguredenabled 状态标签。传入 --all 还会显示尚未配置账户的内置渠道,以及尚未落盘的可安装目录渠道。这里不再打印认证提供商(OAuth + API key)和模型提供商用量/配额快照;使用 openclaw models auth list 查看提供商认证配置文件,使用 openclaw statusopenclaw models list 查看用量。

状态 / 能力 / 解析 / 日志

  • channels status--channel <name>--probe--timeout <ms>--json
  • channels capabilities--channel <name>--account <id>(仅与 --channel 搭配使用)、--target <dest>--timeout <ms>--json
  • channels resolve<entries...>--channel <name>--account <id>--kind <auto|user|group>--json
  • channels logs--channel <name|all>--lines <n>--json

channels status --probe 是实时路径:在可访问的 Gateway 网关上,它会按账户运行
probeAccount 和可选的 auditAccount 检查,因此输出可以包含传输
状态,以及 worksprobe failedaudit okaudit failed 等探测结果。
如果 Gateway 网关无法访问,channels status 会回退为仅基于配置的摘要,
而不是实时探测输出。

不要将 openclaw sessions、Gateway 网关 sessions.list 或智能体
sessions_list 工具用作渠道套接字健康信号。这些界面报告的是
已存储的对话行,而不是提供商运行时状态。Discord 提供商
重启后,已连接但安静的账户可能是健康的,但在下一次入站或出站对话事件之前,
不会出现 Discord 会话行。

添加 / 移除账户

openclaw channels add --channel telegram --token <bot-token>
openclaw channels add --channel nostr --private-key "$NOSTR_PRIVATE_KEY"
openclaw channels remove --channel telegram --delete

openclaw channels add --help 会显示各渠道的标志(token、private key、app token、signal-cli 路径等)。

channels remove 只作用于已安装/已配置的渠道插件。对于可安装目录渠道,请先使用 channels add
对于由运行时支持的渠道插件,channels remove 还会要求正在运行的 Gateway 网关在更新配置前停止所选账户,因此禁用或删除账户不会让旧监听器一直保持活跃直到重启。

常见的非交互式添加界面包括:

  • bot-token 渠道:--token--bot-token--app-token--token-file
  • Signal/iMessage 传输字段:--signal-number--cli-path--http-url--http-host--http-port--db-path--service--region
  • Google Chat 字段:--webhook-path--webhook-url--audience-type--audience
  • Matrix 字段:--homeserver--user-id--access-token--password--device-name--initial-sync-limit
  • Nostr 字段:--private-key--relay-urls
  • Tlon 字段:--ship--url--code--group-channels--dm-allowlist--auto-discover-channels
  • --use-env 用于受支持位置的默认账户环境变量支持认证

如果在由标志驱动的添加命令期间需要安装渠道插件,OpenClaw 会使用该渠道的默认安装来源,而不会打开交互式插件安装提示。

当你不带标志运行 openclaw channels add 时,交互式向导可以提示:

  • 每个所选渠道的账户 ID
  • 这些账户的可选显示名称
  • Route these channel accounts to agents now?

如果你确认立即绑定,向导会询问每个已配置渠道账户应由哪个智能体拥有,并写入账户范围的路由绑定。

你也可以稍后使用 openclaw agents bindingsopenclaw agents bindopenclaw agents unbind 管理相同的路由规则(参见 agents)。

当你向仍在使用单账户顶层设置的渠道添加非默认账户时,OpenClaw 会在写入新账户之前,将账户范围的顶层值提升到该渠道的账户映射中。大多数渠道会将这些值落在 channels.<channel>.accounts.default 中,但内置渠道可以改为保留现有的匹配提升账户。Matrix 是当前示例:如果已经存在一个命名账户,或者 defaultAccount 指向现有命名账户,提升会保留该账户,而不是创建新的 accounts.default

路由行为保持一致:

  • 现有的仅渠道绑定(没有 accountId)会继续匹配默认账户。
  • channels add 在非交互模式下不会自动创建或重写绑定。
  • 交互式设置可以选择添加账户范围的绑定。

如果你的配置已经处于混合状态(存在命名账户,同时仍设置了顶层单账户值),请运行 openclaw doctor --fix,将账户范围的值移动到为该渠道选择的提升账户中。大多数渠道会提升到 accounts.default;Matrix 可以改为保留现有的命名/默认目标。

登录和登出(交互式)

openclaw channels login --channel whatsapp
openclaw channels logout --channel whatsapp
  • channels login 支持 --verbose
  • 当只配置了一个受支持的登录目标时,channels loginlogout 可以推断渠道。
  • channels logout 在可访问时优先使用实时 Gateway 网关路径,因此登出会在清除渠道认证状态前停止所有活跃监听器。如果本地 Gateway 网关不可访问,它会回退为本地认证清理。
  • 请从 Gateway 网关主机上的终端运行 channels login。智能体 exec 会阻塞此交互式登录流程;可用时,应从聊天中使用渠道原生智能体登录工具,例如 whatsapp_login

故障排除

  • 运行 openclaw status --deep 进行广泛探测。
  • 使用 openclaw doctor 获取引导式修复。
  • openclaw channels list 不再打印模型提供商用量/配额快照。如需这些信息,请使用 openclaw status(概览)或 openclaw models list(按提供商)。
  • 当 Gateway 网关无法访问时,openclaw channels status 会回退为仅基于配置的摘要。如果受支持的渠道凭据通过 SecretRef 配置,但在当前命令路径中不可用,它会将该账户报告为已配置并附带降级说明,而不是显示为未配置。

能力探测

获取提供商能力提示(可用时包括 intent/scope)以及静态功能支持:

openclaw channels capabilities
openclaw channels capabilities --channel discord --target channel:123

说明:

  • --channel 是可选的;省略它可列出每个渠道(包括插件)。
  • --account 仅在与 --channel 搭配使用时有效。
  • --target 接受 channel:<id> 或原始数字渠道 ID,并且仅适用于 Discord。对于 Discord 语音渠道,权限检查会标记缺失的 ViewChannelConnectSpeakSendMessagesReadMessageHistory
  • 探测因提供商而异:Discord intent + 可选渠道权限;Slack bot + user scope;Telegram bot 标志 + webhook;Signal daemon 版本;Microsoft Teams app token + Graph 角色/scope(在已知位置添加注释)。没有探测的渠道会报告 Probe: unavailable

将名称解析为 ID

使用提供商目录将渠道/用户名称解析为 ID:

openclaw channels resolve --channel slack "#general" "@jane"
openclaw channels resolve --channel discord "My Server/#support" "@someone"
openclaw channels resolve --channel matrix "Project Room"

说明:

  • 使用 --kind user|group|auto 强制目标类型。
  • 当多个条目共享同一名称时,解析会优先选择活跃匹配项。
  • channels resolve 是只读的。如果所选账户通过 SecretRef 配置,但该凭据在当前命令路径中不可用,该命令会返回带说明的降级未解析结果,而不是中止整个运行。
  • channels resolve 不会安装渠道插件。对于可安装目录渠道,请先使用 channels add --channel <name>,再解析名称。

相关


📄 配置

原文:https://docs.openclaw.ai/zh-CN/cli/config

用于在 openclaw.json 中进行非交互式编辑的配置辅助命令:按路径获取/设置/修补/取消设置/输出文件/输出 schema/验证值,并打印活动配置文件。不带子命令运行会打开配置向导(等同于 openclaw configure)。

OPENCLAW_NIX_MODE=1 时,OpenClaw 会将 openclaw.json 视为不可变文件。config getconfig fileconfig schemaconfig validate 等只读命令仍然可用,但配置写入命令会拒绝执行。智能体应改为编辑该安装的 Nix 源;对于第一方 nix-openclaw 发行版,请使用 nix-openclaw Quick Start,并在 programs.openclaw.configinstances.<name>.config 下设置值。

根选项

<ParamField path="--section \

" type="string">
当你不带子命令运行 openclaw config 时,可重复使用的引导式设置分区过滤器。

支持的引导分区:workspacemodelwebgatewaydaemonchannelspluginsskillshealth

示例

openclaw config file
openclaw config --section model
openclaw config --section gateway --section daemon
openclaw config schema
openclaw config get browser.executablePath
openclaw config set browser.executablePath "/usr/bin/google-chrome"
openclaw config set browser.profiles.work.executablePath "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
openclaw config set agents.defaults.heartbeat.every "2h"
openclaw config set agents.list[0].tools.exec.node "node-id-or-name"
openclaw config set agents.defaults.models '{"openai/gpt-5.4":{}}' --strict-json --merge
openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN
openclaw config set secrets.providers.vaultfile --provider-source file --provider-path /etc/openclaw/secrets.json --provider-mode json
openclaw config patch --file ./openclaw.patch.json5 --dry-run
openclaw config unset plugins.entries.brave.config.webSearch.apiKey
openclaw config set channels.discord.token --ref-provider default --ref-source env --ref-id DISCORD_BOT_TOKEN --dry-run
openclaw config validate
openclaw config validate --json

config schema

将为 openclaw.json 生成的 JSON schema 以 JSON 形式打印到 stdout。

- 当前根配置 schema,以及供编辑器工具使用的根 $schema 字符串字段。
- Control UI 使用的字段 titledescription 文档元数据。
- 当存在匹配字段文档时,嵌套对象、通配符(*)和数组项([])节点会继承相同的 title / description 元数据。
- 当存在匹配字段文档时,anyOf / oneOf / allOf 分支也会继承相同的文档元数据。
- 当可加载运行时清单时,尽力提供实时插件 + 渠道 schema 元数据。
- 即使当前配置无效,也会提供干净的回退 schema。

config.schema.lookup 会返回一个规范化配置路径,并附带浅层 schema 节点(titledescriptiontypeenumconst、常见边界)、匹配的 UI 提示元数据以及直接子项摘要。可在 Control UI 或自定义客户端中用于按路径下钻。

openclaw config schema

如果想用其他工具检查或验证它,可以将其管道输出到文件:

openclaw config schema > openclaw.schema.json

路径

路径使用点号或方括号表示法:

openclaw config get agents.defaults.workspace
openclaw config get agents.list[0].id

使用智能体列表索引来定位特定智能体:

openclaw config get agents.list
openclaw config set agents.list[1].tools.exec.node "node-id-or-name"

值会在可能时按 JSON5 解析;否则会被视为字符串。使用 --strict-json 要求必须进行 JSON5 解析。--json 仍作为旧版别名受支持。

openclaw config set agents.defaults.heartbeat.every "0m"
openclaw config set gateway.port 19001 --strict-json
openclaw config set channels.whatsapp.groups '["*"]' --strict-json

config get <path> --json 会将原始值以 JSON 形式打印,而不是终端格式化文本。

对象赋值默认会替换目标路径。常用于保存用户添加条目的受保护映射/列表路径,例如 agents.defaults.modelsmodels.providersmodels.providers.<id>.modelsplugins.entriesauth.profiles,会拒绝可能移除现有条目的替换,除非你传入 --replace

向这些映射添加条目时,请使用 --merge

openclaw config set agents.defaults.models '{"openai/gpt-5.4":{}}' --strict-json --merge
openclaw config set models.providers.ollama.models '[{"id":"llama3.2","name":"Llama 3.2"}]' --strict-json --merge

只有在你明确希望提供的值成为完整目标值时,才使用 --replace

config set 模式

openclaw config set 支持四种赋值样式:

bash
openclaw config set <path> <value>

bash
openclaw config set channels.discord.token \
--ref-provider default \
--ref-source env \
--ref-id DISCORD_BOT_TOKEN

提供商构建器模式仅针对 secrets.providers.<alias> 路径:

```bash
openclaw config set secrets.providers.vault \
  --provider-source exec \
  --provider-command /usr/local/bin/openclaw-vault \
  --provider-arg read \
  --provider-arg openai/api-key \
  --provider-timeout-ms 5000
```

bash
openclaw config set --batch-json '[
{
"path": "secrets.providers.default",
"provider": { "source": "env" }
},
{
"path": "channels.discord.token",
"ref": { "source": "env", "provider": "default", "id": "DISCORD_BOT_TOKEN" }
}
]'

```bash
openclaw config set --batch-file ./config-set.batch.json --dry-run
```

SecretRef 赋值会在不支持运行时可变的表面上被拒绝(例如 hooks.tokencommands.ownerDisplaySecret、Discord 线程绑定 webhook token,以及 WhatsApp 凭据 JSON)。请参阅 SecretRef 凭据表面

批量解析始终使用批量载荷(--batch-json/--batch-file)作为真实来源。--strict-json / --json 不会改变批量解析行为。

config patch

当你想粘贴或管道传入配置形状的补丁,而不是运行许多基于路径的 config set 命令时,请使用 config patch。输入是 JSON5 对象。对象会递归合并,数组和标量值会替换目标值,null 会删除目标路径。

openclaw config patch --file ./openclaw.patch.json5 --dry-run
openclaw config patch --file ./openclaw.patch.json5

你也可以通过 stdin 管道传入补丁,这对远程设置脚本很有用:

ssh openclaw-host 'openclaw config patch --stdin --dry-run' < ./openclaw.patch.json5
ssh openclaw-host 'openclaw config patch --stdin' < ./openclaw.patch.json5

示例补丁:

{
  channels: {
    slack: {
      enabled: true,
      mode: "socket",
      botToken: { source: "env", provider: "default", id: "SLACK_BOT_TOKEN" },
      appToken: { source: "env", provider: "default", id: "SLACK_APP_TOKEN" },
      groupPolicy: "open",
      requireMention: false,
    },
    discord: {
      enabled: true,
      token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },
      dmPolicy: "disabled",
      dm: { enabled: false },
      groupPolicy: "allowlist",
    },
  },
  agents: {
    defaults: {
      model: { primary: "openai/gpt-5.5" },
      models: {
        "openai/gpt-5.5": { params: { fastMode: true } },
      },
    },
  },
}

当某个对象或数组必须精确变成提供的值,而不是递归修补时,请使用 --replace-path <path>

openclaw config patch --file ./discord.patch.json5 --replace-path 'channels.discord.guilds["123"].channels'

--dry-run 会运行 schema 和 SecretRef 可解析性检查,但不会写入。dry-run 期间默认跳过由 exec 支持的 SecretRef;当你明确希望 dry-run 执行提供商命令时,请添加 --allow-exec

JSON 路径/值模式仍支持 SecretRef 和提供商:

openclaw config set channels.discord.token \
  '{"source":"env","provider":"default","id":"DISCORD_BOT_TOKEN"}' \
  --strict-json

openclaw config set secrets.providers.vaultfile \
  '{"source":"file","path":"/etc/openclaw/secrets.json","mode":"json"}' \
  --strict-json

提供商构建器标志

提供商构建器目标必须使用 secrets.providers.<alias> 作为路径。

- --provider-source <env|file|exec>
- --provider-timeout-ms <ms>fileexec

- --provider-allowlist <ENV_VAR>(可重复)

- --provider-path <path>(必需)
- --provider-mode <singleValue|json>
- --provider-max-bytes <bytes>
- --provider-allow-insecure-path

- --provider-command <path>(必需)
- --provider-arg <arg>(可重复)
- --provider-no-output-timeout-ms <ms>
- --provider-max-output-bytes <bytes>
- --provider-json-only
- --provider-env <KEY=VALUE>(可重复)
- --provider-pass-env <ENV_VAR>(可重复)
- --provider-trusted-dir <path>(可重复)
- --provider-allow-insecure-path
- --provider-allow-symlink-command

强化的 exec 提供商示例:

openclaw config set secrets.providers.vault \
  --provider-source exec \
  --provider-command /usr/local/bin/openclaw-vault \
  --provider-arg read \
  --provider-arg openai/api-key \
  --provider-json-only \
  --provider-pass-env VAULT_TOKEN \
  --provider-trusted-dir /usr/local/bin \
  --provider-timeout-ms 5000

Dry run

使用 --dry-run 验证更改,而不写入 openclaw.json

openclaw config set channels.discord.token \
  --ref-provider default \
  --ref-source env \
  --ref-id DISCORD_BOT_TOKEN \
  --dry-run

openclaw config set channels.discord.token \
  --ref-provider default \
  --ref-source env \
  --ref-id DISCORD_BOT_TOKEN \
  --dry-run \
  --json

openclaw config set channels.discord.token \
  --ref-provider vault \
  --ref-source exec \
  --ref-id discord/token \
  --dry-run \
  --allow-exec

- 构建器模式:对已更改的引用/提供商运行 SecretRef 可解析性检查。
- JSON 模式(--strict-json--json 或批量模式):运行 schema 验证以及 SecretRef 可解析性检查。
- 策略验证也会针对已知不受支持的 SecretRef 目标表面运行。
- 策略检查会评估完整的更改后配置,因此父对象写入(例如将 hooks 设置为对象)无法绕过不受支持表面的验证。
- dry-run 期间默认跳过 exec SecretRef 检查,以避免命令副作用。
- 将 --allow-exec--dry-run 一起使用可选择启用 exec SecretRef 检查(这可能会执行提供商命令)。
- --allow-exec 仅适用于 dry-run;如果不与 --dry-run 一起使用,会报错。

--dry-run --json 会打印机器可读报告:

- `ok`:dry-run 是否通过
- `operations`:已评估的赋值数量
- `checks`:是否运行了 schema/可解析性检查
- `checks.resolvabilityComplete`:可解析性检查是否运行完成(跳过 exec 引用时为 false
- `refsChecked`:dry-run 期间实际解析的引用数量
- `skippedExecRefs`:由于未设置 `--allow-exec` 而跳过的 exec 引用数量
- `errors``ok=false` 时的结构化 schema/可解析性失败

JSON 输出结构

{
  ok: boolean,
  operations: number,
  configPath: string,
  inputModes: ["value" | "json" | "builder", ...],
  checks: {
    schema: boolean,
    resolvability: boolean,
    resolvabilityComplete: boolean,
  },
  refsChecked: number,
  skippedExecRefs: number,
  errors?: [
    {
      kind: "schema" | "resolvability",
      message: string,
      ref?: string, // present for resolvability errors
    },
  ],
}

json
{
"ok": true,
"operations": 1,
"configPath": "~/.openclaw/openclaw.json",
"inputModes": ["builder"],
"checks": {
"schema": false,
"resolvability": true,
"resolvabilityComplete": true
},
"refsChecked": 1,
"skippedExecRefs": 0
}

json
{
"ok": false,
"operations": 1,
"configPath": "~/.openclaw/openclaw.json",
"inputModes": ["builder"],
"checks": {
"schema": false,
"resolvability": true,
"resolvabilityComplete": true
},
"refsChecked": 1,
"skippedExecRefs": 0,
"errors": [
{
"kind": "resolvability",
"message": "Error: Environment variable \"MISSING_TEST_SECRET\" is not set.",
"ref": "env:default:MISSING_TEST_SECRET"
}
]
}

- config schema validation failed:变更后的配置结构无效;修正路径/值或 提供商/ref 对象结构。
- Config policy validation failed: unsupported SecretRef usage:将该凭证移回明文/字符串输入,并仅在受支持的表面上保留 SecretRefs。
- SecretRef assignment(s) could not be resolved:引用的 提供商/ref 当前无法解析(缺少环境变量、文件指针无效、exec 提供商失败,或 提供商/source 不匹配)。
- Dry run note: skipped <n> exec SecretRef resolvability check(s):dry-run 跳过了 exec 引用;如果需要 exec 可解析性验证,请使用 --allow-exec 重新运行。
- 对于批处理模式,请修正失败条目,并在写入前重新运行 --dry-run

写入安全

openclaw config set 和其他由 OpenClaw 拥有的配置写入器会在提交到磁盘前验证完整的变更后配置。如果新载荷未通过 schema 验证,或看起来像破坏性覆盖,活动配置会保持不变,被拒绝的载荷会以 openclaw.json.rejected.* 保存到旁边。

活动配置路径必须是常规文件。不支持对符号链接的 openclaw.json 布局执行写入;请改用 OPENCLAW_CONFIG_PATH 直接指向真实文件。

小改动优先使用 CLI 写入:

openclaw config set gateway.reload.mode hybrid --dry-run
openclaw config set gateway.reload.mode hybrid
openclaw config validate

如果写入被拒绝,请检查保存的载荷并修正完整配置结构:

CONFIG="$(openclaw config file)"
ls -lt "$CONFIG".rejected.* 2>/dev/null | head
openclaw config validate

仍然允许直接用编辑器写入,但运行中的 Gateway 网关会在其通过验证前将其视为不可信。无效的直接编辑会导致启动失败,或被热重载跳过;Gateway 网关不会重写 openclaw.json。运行 openclaw doctor --fix 可修复带前缀/被覆盖的配置,或恢复最后一个已知良好的副本。参见 Gateway 网关故障排除

整文件恢复保留给 Doctor 修复。插件 schema 变更或 minHostVersion 偏差会明确报错,而不是回滚无关的用户设置,例如 模型、提供商、凭证配置文件、渠道、Gateway 网关暴露、工具、memory、browser 或 cron 配置。

子命令

  • config file:打印活动配置文件路径(从 OPENCLAW_CONFIG_PATH 或默认位置解析)。该路径应指向常规文件,而不是符号链接。

编辑后重启 Gateway 网关。

验证

在不启动 Gateway 网关的情况下,根据活动 schema 验证当前配置。

openclaw config validate
openclaw config validate --json

openclaw config validate 通过后,你可以使用本地 TUI,让嵌入式智能体在你从同一个终端验证每项更改时,将活动配置与文档进行比较:

如果验证已经失败,请先运行 openclaw configureopenclaw doctor --fixopenclaw chat 不会绕过无效配置保护。

openclaw chat

然后在 TUI 内:

!openclaw config file
!openclaw docs gateway auth token secretref
!openclaw config validate
!openclaw doctor

典型修复循环:

让智能体将你的当前配置与相关文档页面进行比较,并建议最小修复。

使用 openclaw config setopenclaw configure 应用定向编辑。

每次更改后重新运行 openclaw config validate

如果验证通过但运行时仍不健康,请运行 openclaw doctoropenclaw doctor --fix 获取迁移和修复帮助。

相关内容


📄 配置

原文:https://docs.openclaw.ai/zh-CN/cli/configure

openclaw configure

用于对现有设置进行定向更改的交互式提示:凭证、设备、智能体默认值、Gateway 网关、渠道、插件、Skills 和健康检查。

使用 openclaw onboard 完成完整的首次运行引导流程,使用 openclaw setup 仅设置基线配置/工作区,只需要设置渠道账号时使用 openclaw channels add

模型部分包含一个用于 agents.defaults.models 允许列表的多选项(会显示在 /model 和模型选择器中)。按提供商范围设置的选择会将所选模型合并到现有允许列表中,而不是替换配置中已有的其他无关提供商。

从 configure 重新运行提供商认证会保留现有的 agents.defaults.model.primary,即使提供商的认证步骤返回了带有其推荐默认模型的配置补丁也是如此。这意味着添加或重新认证 xAI、OpenRouter 或其他提供商时,应会让新模型可用,而不会接管你当前的主模型。只有在你明确想更改默认模型时,才使用 openclaw models auth login --provider <id> --set-defaultopenclaw models set <model>

当 configure 从提供商认证选择启动时,默认模型和允许列表选择器会自动优先使用该提供商。对于 Volcengine 和 BytePlus 等成对提供商,相同的偏好也会匹配它们的编码计划变体(volcengine-plan/*byteplus-plan/*)。如果首选提供商筛选器会生成空列表,configure 会回退到未筛选的目录,而不是显示空白选择器。

不带子命令的 openclaw config 会打开同一个向导。使用 openclaw config get|set|unset 进行非交互式编辑。

对于 Web 搜索,openclaw configure --section web 可让你选择提供商
并配置其凭证。某些提供商还会显示特定于提供商的
后续提示:

  • Grok 可以使用相同的 XAI_API_KEY 提供可选的 x_search 设置,并
    让你选择一个 x_search 模型。
  • Kimi 可以询问 Moonshot API 区域(api.moonshot.ai
    api.moonshot.cn)以及默认 Kimi Web 搜索模型。

相关:

选项

  • --section <section>:可重复的部分筛选器

可用部分:

  • workspace
  • model
  • web
  • gateway
  • daemon
  • channels
  • plugins
  • skills
  • health

注意事项:

  • 选择 Gateway 网关运行位置总是会更新 gateway.mode。如果这就是你需要的全部内容,可以在不选择其他部分的情况下选择“继续”。
  • 写入本地配置后,如果所选设置路径需要可下载插件,configure 会安装所选插件。远程 Gateway 网关配置不会安装本地插件包。
  • 面向渠道的服务(Slack/Discord/Matrix/Microsoft Teams)会在设置期间提示输入渠道/房间允许列表。你可以输入名称或 ID;向导会在可能的情况下将名称解析为 ID。
  • 如果你运行 daemon 安装步骤,令牌认证需要令牌,并且 gateway.auth.token 由 SecretRef 管理,configure 会验证 SecretRef,但不会将解析后的明文令牌值持久化到 supervisor 服务环境元数据中。
  • 如果令牌认证需要令牌,而配置的令牌 SecretRef 未解析,configure 会阻止 daemon 安装,并给出可执行的修复指导。
  • 如果同时配置了 gateway.auth.tokengateway.auth.password,且 gateway.auth.mode 未设置,configure 会阻止 daemon 安装,直到显式设置模式。

示例

openclaw configure
openclaw configure --section web
openclaw configure --section model --section channels
openclaw configure --section gateway --section daemon

相关


📄 Cron

原文:https://docs.openclaw.ai/zh-CN/cli/cron

openclaw cron

管理 Gateway 网关调度器的 cron 任务。

运行 openclaw cron --help 查看完整命令界面。概念指南请参阅 Cron 任务

会话

--session 接受 mainisolatedcurrentsession:<id>

- main 绑定到智能体的主会话。
- isolated 为每次运行创建新的转录记录和会话 ID。
- current 绑定到创建时的活动会话。
- session:<id> 固定到一个显式的持久会话键。

隔离运行会重置环境对话上下文。渠道和群组路由、发送/排队策略、提权、来源以及 ACP 运行时绑定都会为新运行重置。安全偏好设置以及用户显式选择的模型或凭证覆盖项可以跨运行保留。

递送

openclaw cron listopenclaw cron show <job-id> 会预览解析后的递送路由。对于 channel: "last",预览会显示路由是从主会话还是当前会话解析得到,或者会以关闭失败告终。

带提供商前缀的目标可以消除未解析公告渠道的歧义。例如,to: "telegram:123" 会在省略 delivery.channel 或其为 last 时选择 Telegram。只有已加载插件声明的前缀才是提供商选择器。如果 delivery.channel 是显式的,前缀必须与该渠道匹配;channel: "whatsapp" 搭配 to: "telegram:123" 会被拒绝。imessage:sms: 等服务前缀仍然是由渠道拥有的目标语法。

隔离的 cron add 任务默认使用 --announce 递送。使用 --no-deliver 可将输出保留在内部。--deliver 仍作为 --announce 的已弃用别名保留。

递送所有权

隔离 cron 聊天递送由智能体和运行器共享:

  • 当聊天路由可用时,智能体可以使用 message 工具直接发送。
  • 只有当智能体未直接发送到解析后的目标时,announce 才会回退递送最终回复。
  • webhook 将完成后的负载发布到 URL。
  • none 禁用运行器回退递送。

--announce 是最终回复的运行器回退递送。--no-deliver 会禁用该回退,但当聊天路由可用时,不会移除智能体的 message 工具。

从活动聊天创建的提醒会保留实时聊天递送目标,用于回退公告递送。内部会话键可能是小写;不要把它们当作用于区分大小写的提供商 ID 的事实来源,例如 Matrix 房间 ID。

失败递送

失败通知按以下顺序解析:

  1. 任务上的 delivery.failureDestination
  2. 全局 cron.failureDestination
  3. 任务的主要公告目标(未设置显式失败目标时)。

主会话任务仅在主要递送模式为 webhook 时才可使用 delivery.failureDestination。隔离任务在所有模式下都接受它。

注意:隔离 cron 运行会将运行级智能体失败视为任务错误,即使没有生成回复负载也是如此,因此模型/提供商失败仍会递增错误计数器并触发失败通知。

如果隔离运行在首次模型请求前超时,openclaw cron showopenclaw cron runs 会包含阶段特定错误,例如 setup timed out before runner startstalled before first model call (last phase: context-engine)。对于 CLI 支持的提供商,预模型看门狗会保持活动状态,直到外部 CLI 轮次开始,因此会话查找、钩子、凭证、提示词和 CLI 设置卡顿会被报告为预模型 cron 失败。

调度

一次性任务

--at <datetime> 会调度一次性运行。不带偏移量的日期时间会被视为 UTC,除非你同时传入 --tz <iana>,此时会按给定时区解释挂钟时间。

一次性任务默认在成功后删除。使用 --keep-after-run 可保留它们。

周期性任务

周期性任务在连续错误后使用指数重试退避:30 秒、1 分钟、5 分钟、15 分钟、60 分钟。下一次成功运行后,调度会恢复正常。

跳过的运行与执行错误分开跟踪。它们不会影响重试退避,但 openclaw cron edit <job-id> --failure-alert-include-skipped 可以让失败警报包含重复的跳过运行通知。

对于以本地配置模型提供商为目标的隔离任务,cron 会在启动智能体轮次前运行轻量级提供商预检。Loopback、私有网络和 .localapi: "ollama" 提供商会在 /api/tags 上探测;本地 OpenAI 兼容提供商(例如 vLLM、SGLang 和 LM Studio)会在 /models 上探测。如果端点不可达,该运行会记录为 skipped,并在之后的调度中重试;匹配的失效端点会缓存 5 分钟,以避免大量任务冲击同一个本地服务器。

注意:cron 任务定义位于 jobs.json,而待处理运行时状态位于 jobs-state.json。如果 jobs.json 被外部编辑,Gateway 网关会重新加载已更改的调度并清除陈旧的待处理槽位;仅格式化的重写不会清除待处理槽位。

手动运行

openclaw cron run 会在手动运行排队后立即返回。成功响应包含 { ok: true, enqueued: true, runId }。使用 openclaw cron runs --id <job-id> 跟踪最终结果。

openclaw cron run <job-id> 默认强制运行。使用 --due 可保留旧的“仅在到期时运行”行为。

Models

cron add|edit --model <ref> 为任务选择允许的模型。

如果模型不被允许或无法解析,cron 会让运行因显式验证错误而失败,而不是回退到任务的智能体或默认模型选择。

Cron --model任务主模型,不是聊天会话 /model 覆盖。这意味着:

  • 当所选任务模型失败时,配置的模型回退仍然适用。
  • 当存在按任务负载的 fallbacks 时,它会替换配置的回退列表。
  • 空的按任务回退列表(任务负载/API 中的 fallbacks: [])会使 cron 运行严格执行。
  • 当任务有 --model 但未配置回退列表时,OpenClaw 会传入显式空回退覆盖项,这样智能体主模型就不会作为隐藏重试目标追加。

隔离 cron 模型优先级

隔离 cron 按以下顺序解析活动模型:

  1. Gmail 钩子覆盖项。
  2. 按任务的 --model
  3. 已存储的 cron 会话模型覆盖项(当用户选择了一个时)。
  4. 智能体或默认模型选择。

快速模式

隔离 cron 快速模式遵循解析后的实时模型选择。模型配置 params.fastMode 默认适用,但已存储的会话 fastMode 覆盖项仍优先于配置。

实时模型切换重试

如果隔离运行抛出 LiveSessionModelSwitchError,cron 会在重试前为活动运行持久化切换后的提供商和模型(以及存在时切换后的凭证配置覆盖项)。外层重试循环在初始尝试后最多允许两次切换重试,随后中止而不是无限循环。

运行输出和拒绝

陈旧确认抑制

隔离 cron 轮次会抑制陈旧的仅确认回复。如果第一个结果只是临时状态更新,并且没有后代子智能体运行负责最终答案,cron 会在递送前重新提示一次以获取真实结果。

静默令牌抑制

如果隔离 cron 运行只返回静默令牌(NO_REPLYno_reply),cron 会同时抑制直接出站递送和回退排队摘要路径,因此不会向聊天发回任何内容。

结构化拒绝

隔离 cron 运行优先使用嵌入式运行中的结构化执行拒绝元数据,然后回退到最终输出中的已知拒绝标记,例如 SYSTEM_RUN_DENIEDINVALID_REQUEST 和审批绑定拒绝短语。

cron list 和运行历史会显示拒绝原因,而不是将被阻止的命令报告为 ok

保留

保留和修剪在配置中控制:

  • cron.sessionRetention(默认 24h)会修剪已完成的隔离运行会话。
  • cron.runLog.maxBytescron.runLog.keepLines 会修剪 ~/.openclaw/cron/runs/<jobId>.jsonl

迁移旧任务

如果你有当前递送和存储格式之前的 cron 任务,请运行 openclaw doctor --fix。Doctor 会规范化旧版 cron 字段(jobIdschedule.cron、顶层递送字段,包括旧版 threadId、负载 provider 递送别名),并在配置了 cron.webhook 时,将简单的 notify: true webhook 回退任务迁移为显式 webhook 递送。

常见编辑

更新递送设置而不更改消息:

openclaw cron edit <job-id> --announce --channel telegram --to "123456789"

禁用隔离任务的递送:

openclaw cron edit <job-id> --no-deliver

为隔离任务启用轻量级引导上下文:

openclaw cron edit <job-id> --light-context

公告到特定渠道:

openclaw cron edit <job-id> --announce --channel slack --to "channel:C1234567890"

公告到 Telegram 论坛话题:

openclaw cron edit <job-id> --announce --channel telegram --to "-1001234567890" --thread-id 42

创建带轻量级引导上下文的隔离任务:

openclaw cron add \
  --name "Lightweight morning brief" \
  --cron "0 7 * * *" \
  --session isolated \
  --message "Summarize overnight updates." \
  --light-context \
  --no-deliver

--light-context 仅适用于隔离智能体轮次任务。对于 cron 运行,轻量级模式会保持引导上下文为空,而不是注入完整的工作区引导集。

常见管理命令

手动运行和检查:

openclaw cron list
openclaw cron list --agent ops
openclaw cron get <job-id>
openclaw cron show <job-id>
openclaw cron run <job-id>
openclaw cron run <job-id> --due
openclaw cron runs --id <job-id> --limit 50

openclaw cron list 默认显示所有匹配的任务。传入 --agent <id> 可仅显示有效规范化智能体 ID 匹配的任务;没有存储智能体 ID 的任务会计为配置的默认智能体。

openclaw cron get <job-id> 会直接返回存储的任务 JSON。当你需要带递送路由预览的可读视图时,请使用 cron show <job-id>

cron list --jsoncron show <job-id> --json 在每个任务上包含顶层 status 字段,该字段根据 enabledstate.runningAtMsstate.lastRunStatus 计算。取值:disabledrunningokerrorskippedidle。这与可读状态列保持一致,因此外部工具可以读取任务状态,而无需重新推导。

cron runs 条目包含递送诊断信息,包括预期的 cron 目标、解析后的目标、message 工具发送、回退使用情况以及已递送状态。

智能体和会话重定向:

openclaw cron edit <job-id> --agent ops
openclaw cron edit <job-id> --clear-agent
openclaw cron edit <job-id> --session current
openclaw cron edit <job-id> --session "session:daily-brief"

openclaw cron add 会在智能体轮次任务省略 --agent 时发出警告,并回退到默认智能体(main)。创建时传入 --agent <id> 可固定到特定智能体。

递送微调:

openclaw cron edit <job-id> --announce --channel slack --to "channel:C1234567890"
openclaw cron edit <job-id> --best-effort-deliver
openclaw cron edit <job-id> --no-best-effort-deliver
openclaw cron edit <job-id> --no-deliver

相关


📄 仪表盘

原文:https://docs.openclaw.ai/zh-CN/cli/dashboard

openclaw dashboard

使用你当前的认证信息打开控制 UI。

openclaw dashboard
openclaw dashboard --no-open

注意事项:

  • dashboard 会尽可能解析已配置的 gateway.auth.token SecretRefs。
  • dashboard 遵循 gateway.tls.enabled:启用 TLS 的 Gateway 网关会打印/打开
    https:// 控制 UI URL,并通过 wss:// 连接。
  • 如果带令牌认证的仪表板 URL 的剪贴板/浏览器传递失败,
    dashboard 会记录一条安全的手动认证提示,提到 OPENCLAW_GATEWAY_TOKEN
    gateway.auth.token 和片段键 token,但不会打印令牌
    值。
  • 对于由 SecretRef 管理的令牌(无论已解析或未解析),dashboard 会打印/复制/打开不含令牌的 URL,以避免在终端输出、剪贴板历史记录或浏览器启动参数中暴露外部密钥。
  • 如果 gateway.auth.token 由 SecretRef 管理,但在此命令路径中未解析,该命令会打印不含令牌的 URL 和明确的修复指导,而不是嵌入无效的令牌占位符。

相关


📄 设备

原文:https://docs.openclaw.ai/zh-CN/cli/devices

openclaw devices

管理设备配对请求和设备作用域的令牌。

命令

openclaw devices list

列出待处理的配对请求和已配对设备。

openclaw devices list
openclaw devices list --json

当设备已经配对时,待处理请求输出会在设备当前已批准访问权限旁显示请求的访问权限。这样会明确显示作用域/角色升级,而不是看起来像配对丢失了。

openclaw devices remove <deviceId>

移除一个已配对设备条目。

当你使用已配对设备令牌进行身份验证时,非管理员调用者只能移除自己的设备条目。移除其他设备需要 operator.admin

openclaw devices remove <deviceId>
openclaw devices remove <deviceId> --json

openclaw devices clear --yes [--pending]

批量清除已配对设备。

openclaw devices clear --yes
openclaw devices clear --yes --pending
openclaw devices clear --yes --pending --json

openclaw devices approve [requestId] [--latest]

通过精确的 requestId 批准待处理的设备配对请求。如果省略 requestId 或传入 --latest,OpenClaw 只会打印选中的待处理请求并退出;请在确认详情后,用精确的请求 ID 重新运行批准命令。

如果设备使用已更改的凭证详情(角色、作用域或公钥)重试配对,OpenClaw 会取代之前的待处理条目,并签发新的 requestId。请在批准前立即运行 openclaw devices list,以使用当前 ID。

如果设备已经配对,并请求更广的作用域或更高的角色,OpenClaw 会保留现有批准,并创建新的待处理升级请求。请在 openclaw devices list 中查看 RequestedApproved 列,或使用 openclaw devices approve --latest 在批准前预览精确的升级内容。

如果 Gateway 网关显式配置了 gateway.nodes.pairing.autoApproveCidrs,来自匹配客户端 IP 的首次 role: node 请求可以在出现在此列表之前被批准。该策略默认禁用,并且绝不适用于操作员/浏览器客户端或升级请求。

openclaw devices approve
openclaw devices approve <requestId>
openclaw devices approve --latest

openclaw devices reject <requestId>

拒绝待处理的设备配对请求。

openclaw devices reject <requestId>

openclaw devices rotate --device <id> --role <role> [--scope <scope...>]

轮换特定角色的设备令牌(可选择更新作用域)。
目标角色必须已经存在于该设备已批准的配对契约中;轮换不能生成新的未批准角色。
如果省略 --scope,后续使用已存储轮换令牌重新连接时,会复用该令牌缓存的已批准作用域。如果传入显式的 --scope 值,这些值会成为未来缓存令牌重新连接的已存储作用域集合。
非管理员的已配对设备调用者只能轮换自己的设备令牌。
目标令牌作用域集合必须保持在调用者会话自身的操作员作用域内;轮换不能生成或保留比调用者已拥有权限更广的操作员令牌。

openclaw devices rotate --device <deviceId> --role operator --scope operator.read --scope operator.write

以 JSON 返回轮换元数据。如果调用者在使用该设备令牌进行身份验证时轮换自己的令牌,响应还会包含替换令牌,以便客户端在重新连接前持久化它。共享/管理员轮换不会回显 bearer 令牌。

openclaw devices revoke --device <id> --role <role>

撤销特定角色的设备令牌。

非管理员的已配对设备调用者只能撤销自己的设备令牌。撤销其他设备的令牌需要 operator.admin
目标令牌作用域集合也必须符合调用者会话自身的操作员作用域;仅配对调用者不能撤销管理员/写入操作员令牌。

openclaw devices revoke --device <deviceId> --role node

以 JSON 返回撤销结果。

常用选项

  • --url <url>:Gateway 网关 WebSocket URL(配置后默认为 gateway.remote.url)。
  • --token <token>:Gateway 网关令牌(如需要)。
  • --password <password>:Gateway 网关密码(密码凭证)。
  • --timeout <ms>:RPC 超时。
  • --json:JSON 输出(推荐用于脚本)。

设置 --url 时,CLI 不会回退到配置或环境凭证。请显式传入 --token--password。缺少显式凭证是错误。

说明

  • 令牌轮换会返回新令牌(敏感)。请像处理密钥一样处理它。
  • 这些命令需要 operator.pairing(或 operator.admin)作用域。某些批准还要求调用者持有目标设备将生成或继承的操作员作用域;请参阅操作员作用域
  • gateway.nodes.pairing.autoApproveCidrs 是仅用于新节点设备配对的可选 Gateway 网关策略;它不会更改 CLI 批准权限。
  • 令牌轮换和撤销会保持在该设备已批准的配对角色集合和已批准作用域基线内。游离的缓存令牌条目不会授予令牌管理目标。
  • 对于已配对设备令牌会话,跨设备管理仅限管理员:除非调用者拥有 operator.admin,否则 removerotaterevoke 仅限自操作。
  • 令牌变更也受调用者作用域约束:仅配对会话不能轮换或撤销当前携带 operator.adminoperator.write 的令牌。
  • devices clear 有意要求使用 --yes
  • 如果 local loopback 上配对作用域不可用(且未传入显式 --url),list/approve 可以使用本地配对回退。
  • devices approve 在生成令牌前需要显式请求 ID;省略 requestId 或传入 --latest 只会预览最新的待处理请求。

令牌漂移恢复检查清单

当控制 UI 或其他客户端持续因 AUTH_TOKEN_MISMATCHAUTH_DEVICE_TOKEN_MISMATCHAUTH_SCOPE_MISMATCH 失败时使用此清单。

  1. 确认当前 Gateway 网关令牌来源:
openclaw config get gateway.auth.token
  1. 列出已配对设备并识别受影响的设备 ID:
openclaw devices list
  1. 为受影响设备轮换操作员令牌:
openclaw devices rotate --device <deviceId> --role operator
  1. 如果轮换还不够,移除过时配对并重新批准:
openclaw devices remove <deviceId>
openclaw devices list
openclaw devices approve <requestId>
  1. 使用当前共享令牌/密码重试客户端连接。

说明:

  • 正常重新连接凭证优先级为:显式共享令牌/密码优先,其次是显式 deviceToken,再其次是已存储设备令牌,最后是引导令牌。
  • 可信的 AUTH_TOKEN_MISMATCH 恢复可以在一次有界重试中临时同时发送共享令牌和已存储设备令牌。
  • AUTH_SCOPE_MISMATCH 表示设备令牌已被识别,但不携带请求的作用域集合;请先修复配对/作用域批准契约,再更改共享 Gateway 网关凭证。

相关:

相关


📄 目录

原文:https://docs.openclaw.ai/zh-CN/cli/directory

openclaw directory

用于支持目录查找的渠道(联系人/对等方、群组和 "me")的目录查找。

常用标志

  • --channel <name>:渠道 ID/别名(配置了多个渠道时必需;仅配置一个渠道时自动使用)
  • --account <id>:账户 ID(默认:渠道默认值)
  • --json:输出 JSON

说明

  • directory 旨在帮助你找到可粘贴到其他命令中的 ID(尤其是 openclaw message send --target ...)。
  • 对许多渠道来说,结果由配置支持(允许列表/已配置群组),而不是来自实时提供商目录。
  • 已安装的渠道插件仍可省略目录支持;在这种情况下,命令会报告不支持的目录操作,而不是重新安装插件。
  • 默认输出为 id(有时还有 name),用制表符分隔;脚本使用请加 --json

将结果用于 message send

openclaw directory peers list --channel slack --query "U0"
openclaw message send --channel slack --target user:U012ABCDEF --message "hello"

ID 格式(按渠道)

  • WhatsApp:+15551234567(私信)、1234567890-1234567890@g.us(群组)、120363123456789@newsletter(频道/Newsletter 出站目标)
  • Telegram:@username 或数字聊天 ID;群组是数字 ID
  • Slack:user:U…channel:C…
  • Discord:user:<id>channel:<id>
  • Matrix(插件):user:@user:serverroom:!roomId:server#alias:server
  • Microsoft Teams(插件):user:<id>conversation:<id>
  • Zalo(插件):用户 ID(Bot API)
  • Zalo Personal / zalouser(插件):来自 zcamefriend listgroup list)的线程 ID(私信/群组)

自己("me")

openclaw directory self --channel zalouser

对等方(联系人/用户)

openclaw directory peers list --channel zalouser
openclaw directory peers list --channel zalouser --query "name"
openclaw directory peers list --channel zalouser --limit 50

群组

openclaw directory groups list --channel zalouser
openclaw directory groups list --channel zalouser --query "work"
openclaw directory groups members --channel zalouser --group-id <id>

相关


📄 DNS

原文:https://docs.openclaw.ai/zh-CN/cli/dns

openclaw dns

用于广域设备发现(Tailscale + CoreDNS)的 DNS 辅助工具。目前专注于 macOS + Homebrew CoreDNS。

相关内容:

设置

openclaw dns setup
openclaw dns setup --domain openclaw.internal
openclaw dns setup --apply

dns setup

规划或应用用于单播 DNS-SD 设备发现的 CoreDNS 设置。

选项:

  • --domain <domain>:广域设备发现域名(例如 openclaw.internal
  • --apply:安装或更新 CoreDNS 配置并重启服务(需要 sudo;仅限 macOS)

它会显示:

  • 解析后的设备发现域名
  • 区域文件路径
  • 当前 tailnet IP
  • 推荐的 openclaw.json 设备发现配置
  • 需要设置的 Tailscale Split DNS 名称服务器/域名值

注意事项:

  • 不带 --apply 时,该命令仅作为规划辅助工具,并会打印推荐设置。
  • 如果省略 --domain,OpenClaw 会使用配置中的 discovery.wideArea.domain
  • --apply 目前仅支持 macOS,并要求使用 Homebrew CoreDNS。
  • --apply 会在需要时初始化区域文件,确保 CoreDNS import stanza 存在,并重启 coredns brew 服务。

相关内容


📄 文档

原文:https://docs.openclaw.ai/zh-CN/cli/docs

openclaw docs

从终端搜索实时 OpenClaw 文档索引。该命令会调用公开的 Mintlify 托管文档 MCP 搜索端点 https://docs.openclaw.ai/mcp.SearchOpenClaw,并在你的终端中呈现结果。

用法

openclaw docs                       # print docs entrypoint and example search
openclaw docs <query...>            # search the live docs index

参数:

参数 描述
[query...] 自由格式搜索查询。多词查询会用空格连接,并作为一个查询发送。

示例

openclaw docs browser existing-session
openclaw docs sandbox allowHostControl
openclaw docs gateway token secretref

没有查询时,openclaw docs 会打印文档入口 URL 和一个示例搜索命令,而不是运行搜索。

工作原理

openclaw docs 会调用 mcporter CLI 来调用文档搜索 MCP 工具,然后将工具输出中的 Title: / Link: / Content: 块解析为结果列表。

为解析 mcporter,OpenClaw 会按顺序检查:

  1. PATH 上的 mcporter(如果存在则直接使用)。
  2. 如果已安装 pnpm,则使用 pnpm dlx mcporter ...
  3. 如果已安装 npx,则使用 npx -y mcporter ...

如果都不可用,该命令会失败,并提示安装 pnpmnpm install -g pnpm)。

搜索调用使用固定的 30 秒超时。结果摘要会被截断为每条约 220 个字符。

输出

在富文本(TTY)终端中,结果会呈现为一个标题,后跟项目符号列表。每个项目符号会显示页面标题、链接的文档 URL,以及下一行的简短摘要。空结果会打印 “No results.”。

在非富文本输出中(管道、--no-color、脚本),相同数据会呈现为 Markdown:

# Docs search: <query>

- [Title](https://docs.openclaw.ai/...) - snippet
- [Title](https://docs.openclaw.ai/...) - snippet

退出代码

代码 含义
0 搜索成功(包括零结果响应)。
1 MCP 工具调用失败;stderr 会内联打印。

相关内容


📄 Doctor

原文:https://docs.openclaw.ai/zh-CN/cli/doctor

openclaw doctor

Gateway 网关和渠道的健康检查 + 快速修复。

相关:

示例

openclaw doctor
openclaw doctor --repair
openclaw doctor --deep
openclaw doctor --repair --non-interactive
openclaw doctor --generate-gateway-token

对于渠道特定权限,请使用渠道探测,而不是 doctor

openclaw channels capabilities --channel discord --target channel:<channel-id>
openclaw channels status --probe

定向的 Discord 能力探测会报告机器人的有效渠道权限;状态探测会审计已配置的 Discord 渠道和语音自动加入目标。

选项

  • --no-workspace-suggestions:禁用工作区记忆/搜索建议
  • --yes:不提示,接受默认值
  • --repair:不提示,应用推荐的非服务修复;Gateway 网关服务安装和重写仍需要交互式确认或显式 Gateway 网关命令
  • --fix--repair 的别名
  • --force:应用激进修复,包括在需要时覆盖自定义服务配置
  • --non-interactive:不提示运行;仅执行安全迁移和非服务修复
  • --generate-gateway-token:生成并配置 Gateway 网关令牌
  • --deep:扫描系统服务中额外的 Gateway 网关安装,并报告最近的 Gateway supervisor 重启移交

注意事项:

  • 在 Nix 模式(OPENCLAW_NIX_MODE=1)下,只读的 Doctor 检查仍可工作,但 doctor --fixdoctor --repairdoctor --yesdoctor --generate-gateway-token 会被禁用,因为 openclaw.json 是不可变的。请改为编辑此安装的 Nix 源;对于 nix-openclaw,请使用以智能体优先的快速开始
  • 交互式提示(如钥匙串/OAuth 修复)仅在标准输入是 TTY 且设置 --non-interactive 时运行。无头运行(cron、Telegram、无终端)会跳过提示。
  • 性能:非交互式 doctor 运行会跳过预先加载插件,因此无头健康检查保持快速。交互式会话在检查需要插件参与时仍会完整加载插件。
  • --fix--repair 的别名)会将备份写入 ~/.openclaw/openclaw.json.bak,并删除未知配置键,同时列出每项移除。
  • doctor --fix --non-interactive 会报告缺失或过期的 Gateway 网关服务定义,但在更新修复模式之外不会安装或重写它们。对于缺失的服务,运行 openclaw gateway install;当你有意替换启动器时,运行 openclaw gateway install --force
  • 状态完整性检查现在会检测会话目录中的孤立转录文件。将它们归档为 .deleted.<timestamp> 需要交互式确认;--fix--yes 和无头运行会将它们保留在原处。
  • Doctor 还会扫描 ~/.openclaw/cron/jobs.json(或 cron.store)中的旧版 cron 任务形态,并可在调度器必须在运行时自动规范化它们之前就地重写。
  • 在 Linux 上,如果用户的 crontab 仍运行旧版 ~/.openclaw/bin/ensure-whatsapp.sh,Doctor 会发出警告;该脚本已不再维护,并且当 cron 缺少 systemd 用户总线环境时,可能记录错误的 WhatsApp Gateway 网关故障。
  • 启用 WhatsApp 时,Doctor 会检查是否存在退化的 Gateway 网关事件循环且本地 openclaw-tui 客户端仍在运行。doctor --fix 只会停止已验证的本地 TUI 客户端,因此 WhatsApp 回复不会排在过期的 TUI 刷新循环之后。
  • Doctor 会在主模型、回退模型、heartbeat/subagent/compaction 覆盖项、钩子、渠道模型覆盖项和过期会话路由固定项中,将旧版 openai-codex/* 模型引用重写为规范的 openai/* 引用。--fix 会将 Codex 意图移到按提供商/模型作用域配置的 agentRuntime.id: "codex" 条目上,保留会话 auth-profile 固定项(如 openai-codex:...),移除过期的整智能体/会话运行时固定项,并让已修复的 OpenAI 智能体引用继续使用 Codex 凭证路由,而不是直接使用 OpenAI API-key 凭证。
  • Doctor 会清理旧版 OpenClaw 创建的旧版插件依赖暂存状态,并为声明 openclaw 为 peer dependency 的托管 npm 插件重新链接主机 openclaw 包。它还会修复配置中引用的缺失可下载插件,例如 plugins.entries、已配置渠道、已配置提供商/搜索设置或已配置 Agent Runtimes。在包更新期间,Doctor 会跳过 package-manager 插件修复,直到包替换完成;如果已配置插件仍需恢复,请随后重新运行 openclaw doctor --fix。如果下载失败,Doctor 会报告安装错误,并保留已配置插件条目以供下一次修复尝试。
  • 当插件发现正常时,Doctor 会通过从 plugins.allow/plugins.deny/plugins.entries 中移除缺失的插件 id,并移除匹配的悬空渠道配置、Heartbeat 目标和渠道模型覆盖项,来修复过期插件配置。
  • Doctor 会隔离无效插件配置,方法是禁用受影响的 plugins.entries.<id> 条目并移除其无效的 config 载荷。Gateway 网关启动已只会跳过该问题插件,因此其他插件和渠道可以继续运行。
  • 当另一个 supervisor 拥有 Gateway 网关生命周期时,请设置 OPENCLAW_SERVICE_REPAIR_POLICY=external。Doctor 仍会报告 Gateway 网关/服务健康状况并应用非服务修复,但会跳过服务安装/启动/重启/bootstrap 和旧版服务清理。
  • 在 Linux 上,Doctor 会忽略非活动的额外类似 Gateway 网关的 systemd 单元,并且在修复期间不会重写正在运行的 systemd Gateway 网关服务的命令/入口点元数据。当你有意替换活动启动器时,请先停止服务,或使用 openclaw gateway install --force
  • Doctor 会将旧版扁平 Talk 配置(talk.voiceIdtalk.modelId 及类似项)自动迁移到 talk.provider + talk.providers.<provider>
  • 当唯一差异是对象键顺序时,重复运行 doctor --fix 不再报告/应用 Talk 规范化。
  • Doctor 包含记忆搜索就绪性检查,并可在缺少嵌入凭证时推荐 openclaw configure --section model
  • 当没有配置命令所有者时,Doctor 会发出警告。命令所有者是允许运行仅所有者命令并批准危险操作的人类操作员账户。私信配对只允许某人与机器人对话;如果你在首次所有者 bootstrap 存在之前批准了发送者,请显式设置 commands.ownerAllowFrom
  • 当配置了 Codex 模式智能体且操作员的 Codex 主目录中存在个人 Codex CLI 资产时,Doctor 会发出警告。本地 Codex app-server 启动使用隔离的按智能体主目录,因此请使用 openclaw migrate codex --dry-run 清点应有意提升的资产。
  • Doctor 会移除已退役的 plugins.entries.codex.config.codexDynamicToolsProfile;Codex app-server 始终保持 Codex 原生工作区工具为原生。
  • 当默认智能体允许的技能因缺少二进制、环境变量、配置或操作系统要求而在当前运行时环境不可用时,Doctor 会发出警告。doctor --fix 可以通过 skills.entries.<skill>.enabled=false 禁用这些不可用技能;当你希望保持该技能活跃时,请改为安装/配置缺失要求。
  • 如果已启用沙箱模式但 Docker 不可用,Doctor 会报告高信号警告并附带修复建议(install Dockeropenclaw config set agents.defaults.sandbox.mode off)。
  • 如果存在旧版沙箱注册表文件(~/.openclaw/sandbox/containers.json~/.openclaw/sandbox/browsers.json),Doctor 会报告它们;openclaw doctor --fix 会将有效条目迁移到分片注册表目录,并隔离无效的旧版文件。
  • 如果 gateway.auth.token/gateway.auth.password 由 SecretRef 管理且在当前命令路径中不可用,Doctor 会报告只读警告,并且不会写入明文回退凭证。
  • 如果渠道 SecretRef 检查在修复路径中失败,Doctor 会继续并报告警告,而不是提前退出。
  • 状态目录迁移后,当已启用的默认 Telegram 或 Discord 账户依赖环境回退且 TELEGRAM_BOT_TOKENDISCORD_BOT_TOKEN 对 Doctor 进程不可用时,Doctor 会发出警告。
  • Telegram allowFrom 用户名自动解析(doctor --fix)要求当前命令路径中有可解析的 Telegram 令牌。如果令牌检查不可用,Doctor 会报告警告,并跳过本轮自动解析。

macOS:launchctl 环境覆盖

如果你之前运行过 launchctl setenv OPENCLAW_GATEWAY_TOKEN ...(或 ...PASSWORD),该值会覆盖你的配置文件,并可能导致持续的“未授权”错误。

launchctl getenv OPENCLAW_GATEWAY_TOKEN
launchctl getenv OPENCLAW_GATEWAY_PASSWORD

launchctl unsetenv OPENCLAW_GATEWAY_TOKEN
launchctl unsetenv OPENCLAW_GATEWAY_PASSWORD

相关


📄 Gateway 网关

原文:https://docs.openclaw.ai/zh-CN/cli/gateway

Gateway 网关是 OpenClaw 的 WebSocket 服务器(渠道、节点、会话、钩子)。本页中的子命令位于 openclaw gateway … 之下。

本地 mDNS + 广域 DNS-SD 设置。

OpenClaw 如何广播和发现 Gateway 网关。

顶层 Gateway 网关配置键名。

运行 Gateway 网关

运行本地 Gateway 网关进程:

openclaw gateway

前台别名:

openclaw gateway run

- 默认情况下,除非在 ~/.openclaw/openclaw.json 中设置了 gateway.mode=local,否则 Gateway 网关会拒绝启动。对临时/开发运行使用 --allow-unconfigured
- openclaw onboard --mode localopenclaw setup 应写入 gateway.mode=local。如果文件存在但缺少 gateway.mode,应将其视为损坏或被覆盖的配置并修复,而不是隐式假定为本地模式。
- 如果文件存在且缺少 gateway.mode,Gateway 网关会将其视为可疑的配置损坏,并拒绝为你“猜测本地模式”。
- 未经身份验证绑定到 loopback 之外会被阻止(安全防护栏)。
- SIGUSR1 会在已授权时触发进程内重启(默认启用 commands.restart;设置 commands.restart: false 可阻止手动重启,同时仍允许 Gateway 网关工具/配置应用/更新)。
- SIGINT/SIGTERM 处理程序会停止 Gateway 网关进程,但不会恢复任何自定义终端状态。如果你用 TUI 或 raw-mode 输入包装 CLI,请在退出前恢复终端。

选项

<ParamField path="--port \" type="number">
WebSocket 端口(默认值来自配置/环境;通常为 18789)。

<ParamField path="--bind \" type="string">
监听器绑定模式。

<ParamField path="--auth \" type="string">
身份验证模式覆盖。

<ParamField path="--token \" type="string">
Token 覆盖(也会为该进程设置 OPENCLAW_GATEWAY_TOKEN)。

<ParamField path="--password \" type="string">
密码覆盖。

<ParamField path="--password-file \" type="string">
从文件读取 Gateway 网关密码。

<ParamField path="--tailscale \" type="string">
通过 Tailscale 暴露 Gateway 网关。

关闭时重置 Tailscale serve/funnel 配置。

允许在配置中没有 gateway.mode=local 的情况下启动 Gateway 网关。仅为临时/开发 bootstrap 绕过启动防护;不会写入或修复配置文件。

如果缺失,则创建开发配置 + 工作区(跳过 BOOTSTRAP.md)。

重置开发配置 + 凭据 + 会话 + 工作区(需要 --dev)。

启动前杀掉所选端口上的任何现有监听器。

详细日志。

仅在控制台显示 CLI 后端日志(并启用 stdout/stderr)。

<ParamField path="--ws-log \" type="string" default="auto">
Websocket 日志样式。

--ws-log compact 的别名。

将原始模型流事件记录到 jsonl。

<ParamField path="--raw-stream-path \" type="string">
原始流 jsonl 路径。

重启 Gateway 网关

openclaw gateway restart
openclaw gateway restart --safe
openclaw gateway restart --safe --skip-deferral
openclaw gateway restart --force

openclaw gateway restart --safe 会要求正在运行的 Gateway 网关在重启前预检活跃的 OpenClaw 工作。如果队列操作、回复投递、嵌入式运行或任务运行处于活跃状态,Gateway 网关会报告阻塞项、合并重复的安全重启请求,并在活跃工作排空后重启。普通 restart 会保留现有服务管理器行为以保持兼容性。仅当你明确需要立即覆盖路径时才使用 --force

openclaw gateway restart --safe --skip-deferral 会运行与 --safe 相同的 OpenClaw 感知协调重启,但会绕过活跃工作延迟门控,因此即使报告了阻塞项,Gateway 网关也会立即发出重启。当延迟被卡住的任务运行固定住,而单独使用 --safe 会无限期等待时,可将其作为操作员逃生口。--skip-deferral 需要 --safe

内联 --password 可能会暴露在本地进程列表中。优先使用 --password-file、环境变量,或由 SecretRef 支持的 gateway.auth.password

启动性能分析

  • 设置 OPENCLAW_GATEWAY_STARTUP_TRACE=1 以记录 Gateway 网关启动期间的阶段耗时,包括每个阶段的 eventLoopMax 延迟,以及 installed-index、清单注册表、启动规划和 owner-map 工作的插件查找表耗时。
  • 设置 OPENCLAW_DIAGNOSTICS=timeline 并配合 OPENCLAW_DIAGNOSTICS_TIMELINE_PATH=<path>,为外部 QA harness 写入尽力而为的 JSONL 启动诊断时间线。你也可以在配置中通过 diagnostics.flags: ["timeline"] 启用该标志;路径仍由环境提供。添加 OPENCLAW_DIAGNOSTICS_EVENT_LOOP=1 可包含事件循环采样。
  • 运行 pnpm test:startup:gateway -- --runs 5 --warmup 1 来基准测试 Gateway 网关启动。该基准会记录首次进程输出、/healthz/readyz、启动跟踪耗时、事件循环延迟,以及插件查找表耗时详情。

查询正在运行的 Gateway 网关

所有查询命令都使用 WebSocket RPC。

- 默认:人类可读(TTY 中带颜色)。
- --json:机器可读 JSON(无样式/加载动画)。
- --no-color(或 NO_COLOR=1):在保留人类布局的同时禁用 ANSI。

- --url <url>:Gateway 网关 WebSocket URL。
- --token <token>:Gateway 网关 token。
- --password <password>:Gateway 网关密码。
- --timeout <ms>:超时/预算(因命令而异)。
- --expect-final:等待“final”响应(智能体调用)。

设置 --url 时,CLI 不会回退到配置或环境凭据。请显式传入 --token--password。缺少显式凭据会报错。

gateway health

openclaw gateway health --url ws://127.0.0.1:18789

HTTP /healthz 端点是存活探针:服务器能够响应 HTTP 后即返回。HTTP /readyz 端点更严格,在启动插件 sidecar、渠道或已配置钩子仍在稳定期间会保持红色。本地或已认证的详细就绪响应会包含一个 eventLoop 诊断块,其中有事件循环延迟、事件循环利用率、CPU 核心比率和 degraded 标志。

gateway usage-cost

从会话日志获取 usage-cost 摘要。

openclaw gateway usage-cost
openclaw gateway usage-cost --days 7
openclaw gateway usage-cost --json

<ParamField path="--days \" type="number" default="30">
要包含的天数。

gateway stability

从正在运行的 Gateway 网关获取最近的诊断稳定性记录器。

openclaw gateway stability
openclaw gateway stability --type payload.large
openclaw gateway stability --bundle latest
openclaw gateway stability --bundle latest --export
openclaw gateway stability --json

<ParamField path="--limit \" type="number" default="25">
要包含的最近事件最大数量(最大 1000)。

<ParamField path="--type \" type="string">
按诊断事件类型过滤,例如 payload.largediagnostic.memory.pressure

<ParamField path="--since-seq \" type="number">
仅包含某个诊断序列号之后的事件。

读取已持久化的稳定性包,而不是调用正在运行的 Gateway 网关。使用 --bundle latest(或仅 --bundle)读取状态目录下的最新包,或直接传入包 JSON 路径。

写入可共享的支持诊断 zip,而不是打印稳定性详情。

<ParamField path="--output \" type="string">
--export 的输出路径。

- 记录会保留运行元数据:事件名称、计数、字节大小、内存读数、队列/会话状态、渠道/插件名称,以及已脱敏的会话摘要。它们不会保留聊天文本、webhook 正文、工具输出、原始请求或响应正文、token、cookie、密钥值、主机名或原始会话 ID。设置 diagnostics.enabled: false 可完全禁用记录器。
- 在 Gateway 网关致命退出、关闭超时和重启启动失败时,如果记录器有事件,OpenClaw 会将同一诊断快照写入 ~/.openclaw/logs/stability/openclaw-stability-*.json。使用 openclaw gateway stability --bundle latest 检查最新包;--limit--type--since-seq 也适用于包输出。

gateway diagnostics export

写入本地诊断 zip,设计用于附加到错误报告。有关隐私模型和包内容,请参阅 诊断导出

openclaw gateway diagnostics export
openclaw gateway diagnostics export --output openclaw-diagnostics.zip
openclaw gateway diagnostics export --json

<ParamField path="--output \" type="string">
输出 zip 路径。默认写入状态目录下的支持导出。

<ParamField path="--log-lines \" type="number" default="5000">
要包含的已清理日志行最大数量。

<ParamField path="--log-bytes \" type="number" default="1000000">
要检查的最大日志字节数。

<ParamField path="--url \" type="string">
用于健康快照的 Gateway 网关 WebSocket URL。

<ParamField path="--token \" type="string">
用于健康快照的 Gateway 网关 token。

<ParamField path="--password \" type="string">
用于健康快照的 Gateway 网关密码。

<ParamField path="--timeout \" type="number" default="3000">
Status/健康快照超时。

跳过已持久化稳定性包查找。

将写入路径、大小和清单打印为 JSON。

导出内容包含清单、Markdown 摘要、配置形状、已清理的配置详情、已清理的日志摘要、已清理的 Gateway 网关 Status/健康快照,以及存在时的最新稳定性包。

它用于共享。它会保留有助于调试的运行细节,例如安全的 OpenClaw 日志字段、子系统名称、状态码、时长、已配置模式、端口、插件 ID、提供商 ID、非密钥功能设置,以及已脱敏的运行日志消息。它会省略或脱敏聊天文本、webhook 正文、工具输出、凭据、cookie、账号/消息标识符、提示/指令文本、主机名和密钥值。当 LogTape 风格的消息看起来像用户/聊天/工具载荷文本时,导出只保留一条消息被省略及其字节数。

gateway status

gateway status 会显示 Gateway 网关服务(launchd/systemd/schtasks),以及一个可选的连通性/身份验证能力探针。

openclaw gateway status
openclaw gateway status --json
openclaw gateway status --require-rpc

<ParamField path="--url \" type="string">
添加显式探测目标。已配置的远程目标 + localhost 仍会被探测。

<ParamField path="--token \" type="string">
探测使用的令牌认证。

<ParamField path="--password \" type="string">
探测使用的密码认证。

<ParamField path="--timeout \" type="number" default="10000">
探测超时时间。

跳过连通性探测(仅服务视图)。

同时扫描系统级服务。

将默认连通性探测升级为读取探测,并在该读取探测失败时以非零状态退出。不能与 --no-probe 组合使用。

- 即使本地 CLI 配置缺失或无效,gateway status 仍可用于诊断。
- 默认的 gateway status 会证明服务状态、WebSocket 连接,以及握手时可见的认证能力。它不会证明读/写/管理操作。
- 对首次设备认证,诊断探测不会产生变更:当已有缓存设备令牌时会复用它们,但不会仅为检查状态而创建新的 CLI 设备身份或只读设备配对记录。
- 可行时,gateway status 会解析已配置的认证 SecretRefs 用于探测认证。
- 如果此命令路径中所需的认证 SecretRef 未解析,gateway status --json 会在探测连通性/认证失败时报告 rpc.authWarning;请显式传入 --token/--password,或先解析密钥来源。
- 如果探测成功,未解析的认证引用警告会被抑制,以避免误报。
- 当监听服务本身还不够,而你还需要读取范围的 RPC 调用也健康时,请在脚本和自动化中使用 --require-rpc
- --deep 会添加对额外 launchd/systemd/schtasks 安装的尽力扫描。当检测到多个类似 Gateway 网关的服务时,人类可读输出会打印清理提示,并警告大多数设置应在每台机器上运行一个 Gateway 网关。
- 当服务进程为外部监督器重启而干净退出时,--deep 也会报告最近一次 Gateway 网关监督器重启交接。
- --deep 会以插件感知模式(pluginValidation: "full")运行配置验证,并显示已配置插件清单警告(例如缺少渠道配置元数据),以便安装和更新冒烟检查能捕获它们。默认的 gateway status 保持快速只读路径,跳过插件验证。
- 人类可读输出包含解析后的文件日志路径,以及 CLI 与服务配置路径/有效性快照,用于帮助诊断配置文件或状态目录漂移。

- 在 Linux systemd 安装上,服务认证漂移检查会从单元中读取 Environment=EnvironmentFile= 值(包括 %h、带引号的路径、多个文件以及可选的 - 文件)。
- 漂移检查会使用合并后的运行时环境解析 gateway.auth.token SecretRefs(先使用服务命令环境,再回退到进程环境)。
- 如果令牌认证实际上未启用(显式 gateway.auth.modepassword/none/trusted-proxy,或模式未设置且密码可能优先、没有令牌候选可能优先),令牌漂移检查会跳过配置令牌解析。

gateway probe

gateway probe 是“调试所有内容”的命令。它始终会探测:

  • 你已配置的远程 Gateway 网关(如果已设置),以及
  • localhost(loopback),即使已配置远程目标

如果你传入 --url,该显式目标会被添加到两者之前。人类可读输出会将目标标记为:

  • URL (explicit)
  • Remote (configured)Remote (configured, inactive)
  • Local loopback

如果多个 Gateway 网关可达,它会全部打印出来。当你使用隔离的配置文件/端口(例如救援 bot)时,支持多个 Gateway 网关,但大多数安装仍只运行单个 Gateway 网关。

openclaw gateway probe
openclaw gateway probe --json

- Reachable: yes 表示至少一个目标接受了 WebSocket 连接。
- Capability: read-only|write-capable|admin-capable|pairing-pending|connect-only 报告探测能证明的认证情况。它与可达性是分开的。
- Read probe: ok 表示读取范围的详细 RPC 调用(health/status/system-presence/config.get)也成功了。
- Read probe: limited - missing scope: operator.read 表示连接成功,但读取范围的 RPC 受限。这会被报告为降级可达性,而不是完全失败。
- Connect: ok 之后的 Read probe: failed 表示 Gateway 网关接受了 WebSocket 连接,但后续读取诊断超时或失败。这同样是降级可达性,而不是 Gateway 网关不可达。
- 与 gateway status 一样,probe 会复用现有缓存设备认证,但不会创建首次设备身份或配对状态。
- 只有在没有任何被探测目标可达时,退出码才为非零。

顶层:

- `ok`:至少一个目标可达。
- `degraded`:至少一个目标接受了连接,但未完成完整的详细 RPC 诊断。
- `capability`:在可达目标中看到的最佳能力(`read_only``write_capable``admin_capable``pairing_pending``connected_no_operator_scope`  `unknown`)。
- `primaryTargetId`:按以下顺序视为当前活跃胜出者的最佳目标:显式 URL、SSH 隧道、已配置远程目标,然后是 local loopback。
- `warnings[]`:尽力而为的警告记录,包含 `code``message` 和可选的 `targetIds`
- `network`:从当前配置和主机网络派生的 local loopback/tailnet URL 提示。
- `discovery.timeoutMs`  `discovery.count`:此探测轮次使用的实际设备发现预算/结果数量。

每个目标(`targets[].connect`):

- `ok`:连接后的可达性 + 降级分类。
- `rpcOk`:完整详细 RPC 成功。
- `scopeLimited`:详细 RPC 因缺少 operator scope 而失败。

每个目标(`targets[].auth`):

- `role`:可用时,`hello-ok` 中报告的认证角色。
- `scopes`:可用时,`hello-ok` 中报告的已授予 scope。
- `capability`:该目标显示的认证能力分类。

- ssh_tunnel_failed:SSH 隧道设置失败;命令回退到直接探测。
- multiple_gateways:多个目标可达;除非你有意运行隔离的配置文件(例如救援 bot),否则这并不常见。
- auth_secretref_unresolved:无法为失败目标解析已配置的认证 SecretRef。
- probe_scope_limited:WebSocket 连接成功,但读取探测因缺少 operator.read 而受限。

通过 SSH 访问远程目标(与 Mac 应用一致)

macOS 应用的“通过 SSH 访问远程目标”模式使用本地端口转发,因此远程 Gateway 网关(它可能只绑定到 loopback)会在 ws://127.0.0.1:<port> 可达。

CLI 等效命令:

openclaw gateway probe --ssh user@gateway-host

<ParamField path="--ssh \" type="string">
user@hostuser@host:port(端口默认为 22)。

<ParamField path="--ssh-identity \" type="string">
身份文件。

从解析后的设备发现端点(local. 加上已配置的广域域名,如果有)中选择第一个发现的 Gateway 网关主机作为 SSH 目标。仅 TXT 的提示会被忽略。

配置(可选,用作默认值):

  • gateway.remote.sshTarget
  • gateway.remote.sshIdentity

gateway call <method>

低层 RPC 辅助命令。

openclaw gateway call status
openclaw gateway call logs.tail --params '{"sinceMs": 60000}'

<ParamField path="--params \" type="string" default="{}">
params 的 JSON 对象字符串。

<ParamField path="--url \" type="string">
Gateway 网关 WebSocket URL。

<ParamField path="--token \" type="string">
Gateway 网关令牌。

<ParamField path="--password \" type="string">
Gateway 网关密码。

<ParamField path="--timeout \" type="number">
超时预算。

主要用于 agent 风格的 RPC,这类 RPC 会在最终载荷之前流式传输中间事件。

机器可读的 JSON 输出。

--params 必须是有效的 JSON。

管理 Gateway 网关服务

openclaw gateway install
openclaw gateway start
openclaw gateway stop
openclaw gateway restart
openclaw gateway uninstall

使用包装器安装

当托管服务必须通过另一个可执行文件启动时,请使用 --wrapper,例如密钥管理器 shim 或 run-as 辅助程序。包装器会接收普通 Gateway 网关参数,并负责最终用这些参数 exec openclaw 或 Node。

cat > ~/.local/bin/openclaw-doppler <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
exec doppler run --project my-project --config production -- openclaw "$@"
EOF
chmod +x ~/.local/bin/openclaw-doppler

openclaw gateway install --wrapper ~/.local/bin/openclaw-doppler --force
openclaw gateway restart

你也可以通过环境设置包装器。gateway install 会验证路径是可执行文件,将包装器写入服务 ProgramArguments,并在服务环境中持久化 OPENCLAW_WRAPPER,供后续强制重新安装、更新和 Doctor 修复使用。

OPENCLAW_WRAPPER="$HOME/.local/bin/openclaw-doppler" openclaw gateway install --force
openclaw doctor

要移除已持久化的包装器,请在重新安装时清空 OPENCLAW_WRAPPER

OPENCLAW_WRAPPER= openclaw gateway install --force
openclaw gateway restart

- gateway status--url--token--password--timeout--no-probe--require-rpc--deep--json
- gateway install--port--runtime <node|bun>--token--wrapper <path>--force--json
- gateway restart--safe--skip-deferral--force--wait <duration>--json
- gateway uninstall|start--json
- gateway stop--disable--json

- 使用 gateway restart 重启托管服务。不要把 gateway stopgateway start 串联起来作为重启替代方式。
- 在 macOS 上,gateway stop 默认使用 launchctl bootout,这会从当前启动会话中移除 LaunchAgent,但不会持久化禁用设置 —— KeepAlive 自动恢复会在后续崩溃时继续生效,并且 gateway start 可以干净地重新启用,无需手动执行 launchctl enable。传入 --disable 可持久化抑制 KeepAlive 和 RunAtLoad,使 Gateway 网关在下一次显式执行 gateway start 之前不会重新生成;当手动停止需要在重启或系统重启后仍然保持时,请使用此选项。
- gateway restart --safe 会要求正在运行的 Gateway 网关预检活跃的 OpenClaw 工作,并将重启推迟到回复交付、嵌入式运行和任务运行全部排空之后。--safe 不能与 --force--wait 组合使用。
- gateway restart --wait 30s 会覆盖该次重启配置的重启排空预算。裸数字表示毫秒;也接受 smh 等单位。--wait 0 会无限期等待。
- gateway restart --safe --skip-deferral 会运行感知 OpenClaw 的安全重启,但绕过延迟门控,因此即使报告了阻塞项,Gateway 网关也会立即发出重启。用于任务运行延迟卡住时的操作员逃生口;需要 --safe
- gateway restart --force 会跳过活跃工作排空并立即重启。当操作员已经检查过列出的任务阻塞项,并希望 Gateway 网关立即恢复时使用。
- 生命周期命令接受 --json,用于脚本编写。

- 当令牌认证需要令牌且 gateway.auth.token 由 SecretRef 管理时,gateway install 会验证 SecretRef 可解析,但不会将解析后的令牌持久化到服务环境元数据中。
- 如果令牌认证需要令牌,而配置的令牌 SecretRef 未解析,安装会关闭失败,而不是持久化回退明文。
- 对于 gateway run 上的密码认证,优先使用 OPENCLAW_GATEWAY_PASSWORD--password-file,或由 SecretRef 支持的 gateway.auth.password,而不是内联 --password
- 在推断认证模式下,仅存在于 shell 中的 OPENCLAW_GATEWAY_PASSWORD 不会放宽安装令牌要求;安装托管服务时,请使用持久化配置(gateway.auth.password 或配置 env)。
- 如果同时配置了 gateway.auth.tokengateway.auth.password,并且 gateway.auth.mode 未设置,安装会被阻止,直到显式设置模式。

发现 Gateway 网关(Bonjour)

gateway discover 会扫描 Gateway 网关信标(_openclaw-gw._tcp)。

  • 组播 DNS-SD:local.
  • 单播 DNS-SD(广域 Bonjour):选择一个域(示例:openclaw.internal.)并设置拆分 DNS + DNS 服务器;请参阅 Bonjour

只有启用了 Bonjour 发现(默认)的 Gateway 网关才会广播该信标。

广域发现记录可以包含这些 TXT 提示:

  • role(Gateway 网关角色提示)
  • transport(传输提示,例如 gateway
  • gatewayPort(WebSocket 端口,通常为 18789
  • sshPort(仅完整发现模式;缺失时,客户端默认 SSH 目标为 22
  • tailnetDns(MagicDNS 主机名,可用时)
  • gatewayTls / gatewayTlsSha256(已启用 TLS + 证书指纹)
  • cliPath(仅完整发现模式)

gateway discover

openclaw gateway discover

<ParamField path="--timeout \" type="number" default="2000">
每条命令的超时(浏览/解析)。

机器可读输出(也会禁用样式和 spinner)。

示例:

openclaw gateway discover --timeout 4000
openclaw gateway discover --json | jq '.beacons[].wsUrl'

- CLI 会扫描 local.,以及启用后配置的广域域。
- JSON 输出中的 wsUrl 派生自已解析的服务端点,而不是仅来自 TXT 的提示,例如 lanHosttailnetDns
- 在 local. mDNS 和广域 DNS-SD 上,只有当 discovery.mdns.modefull 时,才会发布 sshPortcliPath

相关


📄 健康状态

原文:https://docs.openclaw.ai/zh-CN/cli/health

openclaw health

从正在运行的 Gateway 网关获取健康状态。

选项

标志 默认值 描述
--json false 输出机器可读的 JSON,而不是文本。
--timeout <ms> 10000 连接超时,单位为毫秒。
--verbose false 详细日志记录。强制执行实时探测,并展开每个智能体的输出。
--debug false --verbose 的别名。

示例:

openclaw health
openclaw health --json
openclaw health --timeout 2500
openclaw health --verbose
openclaw health --debug

备注:

  • 默认的 openclaw health 会向正在运行的 Gateway 网关请求其健康状态快照。当该
    Gateway 网关已有新的缓存快照时,它可以返回该缓存负载,并在后台刷新。
  • --verbose 会强制执行实时探测,打印 Gateway 网关连接详情,并展开所有已配置账户和智能体的
    人类可读输出。
  • 当配置了多个智能体时,输出会包含每个智能体的会话存储。

相关内容


📄 钩子

原文:https://docs.openclaw.ai/zh-CN/cli/hooks

openclaw hooks

管理智能体钩子(用于 /new/reset 和 Gateway 网关启动等命令的事件驱动自动化)。

不带子命令运行 openclaw hooks 等同于 openclaw hooks list

相关内容:

列出所有钩子

openclaw hooks list

列出从工作区、托管目录、额外目录和内置目录发现的所有钩子。
Gateway 网关启动时不会加载内部钩子处理程序,除非至少配置了一个内部钩子。

选项:

  • --eligible:仅显示符合条件的钩子(满足要求)
  • --json:以 JSON 输出
  • -v, --verbose:显示详细信息,包括缺失的要求

示例输出:

Hooks (4/4 ready)

Ready:
  🚀 boot-md ✓ - Run BOOT.md on gateway startup
  📎 bootstrap-extra-files ✓ - Inject extra workspace bootstrap files during agent bootstrap
  📝 command-logger ✓ - Log all command events to a centralized audit file
  💾 session-memory ✓ - Save session context to memory when /new or /reset command is issued

示例(详细):

openclaw hooks list --verbose

显示不符合条件的钩子缺失的要求。

示例(JSON):

openclaw hooks list --json

返回用于程序化使用的结构化 JSON。

获取钩子信息

openclaw hooks info <name>

显示特定钩子的详细信息。

参数:

  • <name>:钩子名称或钩子键(例如 session-memory

选项:

  • --json:以 JSON 输出

示例:

openclaw hooks info session-memory

输出:

💾 session-memory ✓ Ready

Save session context to memory when /new or /reset command is issued

Details:
  Source: openclaw-bundled
  Path: /path/to/openclaw/hooks/bundled/session-memory/HOOK.md
  Handler: /path/to/openclaw/hooks/bundled/session-memory/handler.ts
  Homepage: https://docs.openclaw.ai/automation/hooks#session-memory
  Events: command:new, command:reset

Requirements:
  Config: ✓ workspace.dir

检查钩子资格

openclaw hooks check

显示钩子资格状态摘要(多少已就绪、多少未就绪)。

选项:

  • --json:以 JSON 输出

示例输出:

Hooks Status

Total hooks: 4
Ready: 4
Not ready: 0

启用钩子

openclaw hooks enable <name>

通过将特定钩子添加到你的配置中来启用它(默认是 ~/.openclaw/openclaw.json)。

注意: 工作区钩子默认处于禁用状态,直到在这里或配置中启用。由插件管理的钩子会在 openclaw hooks list 中显示 plugin:<id>,不能在这里启用或禁用。请改为启用或禁用对应插件。

参数:

  • <name>:钩子名称(例如 session-memory

示例:

openclaw hooks enable session-memory

输出:

✓ Enabled hook: 💾 session-memory

它会做什么:

  • 检查钩子是否存在且符合条件
  • 在你的配置中更新 hooks.internal.entries.<name>.enabled = true
  • 将配置保存到磁盘

如果钩子来自 <workspace>/hooks/,则必须先执行此选择启用步骤,
Gateway 网关才会加载它。

启用后:

  • 重启 Gateway 网关以重新加载钩子(在 macOS 上重启菜单栏应用,或在开发环境中重启你的 Gateway 网关进程)。

禁用钩子

openclaw hooks disable <name>

通过更新你的配置来禁用特定钩子。

参数:

  • <name>:钩子名称(例如 command-logger

示例:

openclaw hooks disable command-logger

输出:

⏸ Disabled hook: 📝 command-logger

禁用后:

  • 重启 Gateway 网关以重新加载钩子

备注

  • openclaw hooks list --jsoninfo --jsoncheck --json 会将结构化 JSON 直接写入 stdout。
  • 由插件管理的钩子不能在这里启用或禁用;请改为启用或禁用所属插件。

安装钩子包

openclaw plugins install <package>        # npm by default
openclaw plugins install npm:<package>    # npm only
openclaw plugins install <package> --pin  # pin version
openclaw plugins install <path>           # local path

通过统一的插件安装器安装钩子包。

openclaw hooks install 仍可作为兼容别名使用,但它会打印弃用警告,
并转发到 openclaw plugins install

npm 规范仅限注册表(包名 + 可选的精确版本
dist-tag)。Git/URL/file 规范和 semver 范围会被拒绝。为了安全,即使你的
shell 配置了全局 npm 安装设置,依赖安装也会以项目本地方式运行,并带上 --ignore-scripts

裸规范和 @latest 会留在稳定轨道上。如果 npm 将其中任何一种解析为预发布版本,
OpenClaw 会停止并要求你使用 @beta/@rc 等预发布标签或精确预发布版本来显式选择加入。

它会做什么:

  • 将钩子包复制到 ~/.openclaw/hooks/<id>
  • hooks.internal.entries.* 中启用已安装的钩子
  • hooks.internal.installs 下记录安装

选项:

  • -l, --link:链接本地目录而不是复制(将其添加到 hooks.internal.load.extraDirs
  • --pin:将 npm 安装记录为 hooks.internal.installs 中解析后的精确 name@version

支持的归档格式: .zip.tgz.tar.gz.tar

示例:

# Local directory
openclaw plugins install ./my-hook-pack

# Local archive
openclaw plugins install ./my-hook-pack.zip

# NPM package
openclaw plugins install @openclaw/my-hook-pack

# Link a local directory without copying
openclaw plugins install -l ./my-hook-pack

已链接的钩子包会被视为来自操作员配置目录的托管钩子,
而不是工作区钩子。

更新钩子包

openclaw plugins update <id>
openclaw plugins update --all

通过统一的插件更新器更新已跟踪的基于 npm 的钩子包。

openclaw hooks update 仍可作为兼容别名使用,但它会打印弃用警告,
并转发到 openclaw plugins update

选项:

  • --all:更新所有已跟踪的钩子包
  • --dry-run:显示会发生什么变化但不写入

当已存储完整性哈希且获取到的制品哈希发生变化时,
OpenClaw 会打印警告并在继续之前请求确认。在 CI/非交互式运行中使用
全局 --yes 可绕过提示。

内置钩子

session-memory

当你发出 /new/reset 时,将会话上下文保存到记忆中。

启用:

openclaw hooks enable session-memory

输出: 默认写入 ~/.openclaw/workspace/memory/YYYY-MM-DD-HHMM.md。设置 hooks.internal.entries.session-memory.llmSlug: true 可使用模型生成的文件名 slug。

参见: session-memory 文档

bootstrap-extra-files

agent:bootstrap 期间注入额外的启动文件(例如 monorepo 本地的 AGENTS.md / TOOLS.md)。

启用:

openclaw hooks enable bootstrap-extra-files

参见: bootstrap-extra-files 文档

command-logger

将所有命令事件记录到集中式审计文件。

启用:

openclaw hooks enable command-logger

输出: ~/.openclaw/logs/commands.log

查看日志:

# Recent commands
tail -n 20 ~/.openclaw/logs/commands.log

# Pretty-print
cat ~/.openclaw/logs/commands.log | jq .

# Filter by action
grep '"action":"new"' ~/.openclaw/logs/commands.log | jq .

参见: command-logger 文档

boot-md

Gateway 网关启动时(在渠道启动后)运行 BOOT.md

事件gateway:startup

启用

openclaw hooks enable boot-md

参见: boot-md 文档

相关内容


📄 日志

原文:https://docs.openclaw.ai/zh-CN/cli/logs

openclaw logs

通过 RPC 追踪 Gateway 网关文件日志(适用于远程模式)。

相关:

选项

  • --limit <n>:要返回的最大日志行数(默认 200
  • --max-bytes <n>:从日志文件读取的最大字节数(默认 250000
  • --follow:跟随日志流
  • --interval <ms>:跟随时的轮询间隔(默认 1000
  • --json:输出按行分隔的 JSON 事件
  • --plain:不带样式格式的纯文本输出
  • --no-color:禁用 ANSI 颜色
  • --local-time:按你的本地时区渲染时间戳

共享 Gateway 网关 RPC 选项

openclaw logs 也接受标准 Gateway 网关客户端标志:

  • --url <url>:Gateway 网关 WebSocket URL
  • --token <token>:Gateway 网关令牌
  • --timeout <ms>:超时时间,单位为 ms(默认 30000
  • --expect-final:当 Gateway 网关调用由智能体支持时,等待最终响应

传入 --url 时,CLI 不会自动应用配置或环境凭证。如果目标 Gateway 网关需要认证,请显式包含 --token

示例

openclaw logs
openclaw logs --follow
openclaw logs --follow --interval 2000
openclaw logs --limit 500 --max-bytes 500000
openclaw logs --json
openclaw logs --plain
openclaw logs --no-color
openclaw logs --limit 500
openclaw logs --local-time
openclaw logs --follow --local-time
openclaw logs --url ws://127.0.0.1:18789 --token "$OPENCLAW_GATEWAY_TOKEN"

备注

  • 使用 --local-time 按你的本地时区渲染时间戳。
  • 如果隐式 local loopback Gateway 网关要求配对、在连接期间关闭,或在 logs.tail 应答之前超时,openclaw logs 会自动回退到已配置的 Gateway 网关文件日志。显式 --url 目标不会使用此回退。
  • 使用 --follow 时,临时性 gateway 断开(WebSocket 关闭、超时、连接中断)会触发带指数退避的自动重连(最多 8 次重试,尝试间隔上限为 30 s)。每次重试都会向 stderr 打印警告,轮询成功后会打印一次 [logs] gateway reconnected 通知。在 --json 模式下,重试警告和重连转换都会作为 {"type":"notice"} 记录输出到 stderr。不可恢复的错误(认证失败、配置错误)仍会立即退出。

相关


📄 记忆

原文:https://docs.openclaw.ai/zh-CN/cli/memory

openclaw memory

管理语义记忆索引和搜索。
由主动记忆插件提供(默认:memory-core;设置 plugins.slots.memory = "none" 可禁用)。

相关内容:

示例

openclaw memory status
openclaw memory status --deep
openclaw memory status --fix
openclaw memory index --force
openclaw memory search "meeting notes"
openclaw memory search --query "deployment" --max-results 20
openclaw memory promote --limit 10 --min-score 0.75
openclaw memory promote --apply
openclaw memory promote --json --min-recall-count 0 --min-unique-queries 0
openclaw memory promote-explain "router vlan"
openclaw memory promote-explain "router vlan" --json
openclaw memory rem-harness
openclaw memory rem-harness --json
openclaw memory status --json
openclaw memory status --deep --index
openclaw memory status --deep --index --verbose
openclaw memory status --agent main
openclaw memory index --agent main --verbose

选项

memory statusmemory index

  • --agent <id>:限定到单个智能体。如果未提供,这些命令会为每个已配置的智能体运行;如果未配置智能体列表,则回退到默认智能体。
  • --verbose:在探测和索引期间输出详细日志。

memory status

  • --deep:探测本地向量存储就绪状态、嵌入提供商就绪状态,以及语义向量搜索就绪状态。普通 memory status 保持快速,不会运行实时嵌入或提供商发现工作;未知的向量存储或语义向量状态表示该命令中未探测它。QMD 词法 searchMode: "search" 即使带有 --deep,也会跳过语义向量探测和嵌入维护。
  • --index:如果存储为脏状态,则运行重新索引(隐含 --deep)。
  • --fix:修复过期的召回锁并规范化提升元数据。
  • --json:打印 JSON 输出。

如果 memory status 显示 Dreaming status: blocked,则表示托管的 Dreaming cron 已启用,但驱动它的 Heartbeat 未针对默认智能体触发。请参阅 Dreaming 从不运行,了解两个常见原因。

memory index

  • --force:强制完整重新索引。

memory search

  • 查询输入:传入位置参数 [query]--query <text>
  • 如果两者都提供,--query 优先。
  • 如果两者都未提供,命令会以错误退出。
  • --agent <id>:限定到单个智能体(默认:默认智能体)。
  • --max-results <n>:限制返回的结果数量。
  • --min-score <n>:过滤掉低分匹配项。
  • --json:打印 JSON 结果。

memory promote

预览并应用短期记忆提升。

openclaw memory promote [--apply] [--limit <n>] [--include-promoted]
  • --apply -- 将提升写入 MEMORY.md(默认:仅预览)。
  • --limit <n> -- 限制显示的候选项数量。
  • --include-promoted -- 包含在先前周期中已提升的条目。

完整选项:

  • 使用加权提升信号(frequencyrelevancequery diversityrecencyconsolidationconceptual richness)对来自 memory/YYYY-MM-DD.md 的短期候选项排序。
  • 使用来自记忆召回和每日摄取流程的短期信号,以及 light/REM 阶段强化信号。
  • 启用 Dreaming 后,memory-core 会自动管理一个在后台运行完整扫描(light -> REM -> deep)的 cron 作业(无需手动 openclaw cron add)。
  • --agent <id>:限定到单个智能体(默认:默认智能体)。
  • --limit <n>:返回/应用的最大候选项数量。
  • --min-score <n>:最低加权提升分数。
  • --min-recall-count <n>:候选项所需的最低召回次数。
  • --min-unique-queries <n>:候选项所需的最低不同查询数。
  • --apply:将选中的候选项追加到 MEMORY.md 并将其标记为已提升。
  • --include-promoted:在输出中包含已提升的候选项。
  • --json:打印 JSON 输出。

memory promote-explain

解释特定提升候选项及其分数细分。

openclaw memory promote-explain <selector> [--agent <id>] [--include-promoted] [--json]
  • <selector>:要查找的候选项键、路径片段或片段内容。
  • --agent <id>:限定到单个智能体(默认:默认智能体)。
  • --include-promoted:包含已提升的候选项。
  • --json:打印 JSON 输出。

memory rem-harness

预览 REM 反思、候选真相和深度提升输出,而不写入任何内容。

openclaw memory rem-harness [--agent <id>] [--include-promoted] [--json]
  • --agent <id>:限定到单个智能体(默认:默认智能体)。
  • --include-promoted:包含已提升的 deep 候选项。
  • --json:打印 JSON 输出。

Dreaming

Dreaming 是后台记忆整合系统,包含三个协作阶段:light(整理/暂存短期材料)、deep(将持久事实提升到 MEMORY.md)和 REM(反思并呈现主题)。

  • 使用 plugins.entries.memory-core.config.dreaming.enabled: true 启用。
  • 通过聊天中的 /dreaming on|off 切换(或使用 /dreaming status 查看)。
  • Dreaming 按一个托管扫描计划(dreaming.frequency)运行,并按顺序执行阶段:light、REM、deep。
  • 只有 deep 阶段会将持久记忆写入 MEMORY.md
  • 人类可读的阶段输出和日记条目会写入 DREAMS.md(或现有的 dreams.md),也可在 memory/dreaming/<phase>/YYYY-MM-DD.md 中生成可选的分阶段报告。
  • 排名使用加权信号:召回频率、检索相关性、查询多样性、时间新近度、跨日整合,以及派生概念丰富度。
  • 提升会在写入 MEMORY.md 前重新读取实时每日笔记,因此已编辑或删除的短期片段不会从过期的召回存储快照中被提升。
  • 定时和手动 memory promote 运行共享相同的 deep 阶段默认值,除非你传入 CLI 阈值覆盖项。
  • 自动运行会分发到已配置的记忆工作区。

默认调度:

  • 扫描节奏dreaming.frequency = 0 3 * * *
  • Deep 阈值minScore=0.8minRecallCount=3minUniqueQueries=3recencyHalfLifeDays=14maxAgeDays=30

示例:

{
  "plugins": {
    "entries": {
      "memory-core": {
        "config": {
          "dreaming": {
            "enabled": true
          }
        }
      }
    }
  }
}

注意事项:

  • memory index --verbose 会打印每个阶段的详细信息(提供商、模型、来源、批处理活动)。
  • memory status 包含通过 memorySearch.extraPaths 配置的任何额外路径。
  • 如果实际生效的主动记忆远程 API key 字段配置为 SecretRefs,该命令会从活跃的 Gateway 网关快照解析这些值。如果 Gateway 网关不可用,该命令会快速失败。
  • Gateway 网关版本偏差说明:此命令路径需要支持 secrets.resolve 的 Gateway 网关;较旧的 Gateway 网关会返回 unknown-method 错误。
  • 使用 dreaming.frequency 调整定时扫描节奏。Deep 提升策略除此之外为内部策略;需要一次性手动覆盖时,在 memory promote 上使用 CLI 标志。
  • memory rem-harness --path <file-or-dir> --grounded 会从历史每日笔记预览有依据的 What HappenedReflectionsPossible Lasting Updates,而不写入任何内容。
  • memory rem-backfill --path <file-or-dir> 会将可逆的有依据日记条目写入 DREAMS.md,供 UI 审查。
  • memory rem-backfill --path <file-or-dir> --stage-short-term 还会将有依据的持久候选项播种到实时短期提升存储中,使普通 deep 阶段可以对其排序。
  • memory rem-backfill --rollback 会移除先前写入的有依据日记条目,memory rem-backfill --rollback-short-term 会移除先前暂存的有依据短期候选项。
  • 请参阅 Dreaming,了解完整阶段描述和配置参考。

相关内容


📄 消息

原文:https://docs.openclaw.ai/zh-CN/cli/message

openclaw message

用于发送消息和频道操作的单一出站命令
(Discord/Google Chat/iMessage/Matrix/Mattermost(插件)/Microsoft Teams/Signal/Slack/Telegram/WhatsApp)。

用法

openclaw message <subcommand> [flags]

频道选择:

  • 如果配置了多个渠道,则必须提供 --channel
  • 如果只配置了一个渠道,它会成为默认值。
  • 值:discord|googlechat|imessage|matrix|mattermost|msteams|signal|slack|telegram|whatsapp(Mattermost 需要插件)
  • 当存在 --channel 或带渠道前缀的目标时,openclaw message 会将所选渠道解析为其所属插件;否则会加载已配置的渠道插件来推断默认渠道。

目标格式(--target):

  • WhatsApp:E.164、群组 JID,或 WhatsApp 频道/Newsletter JID(...@newsletter
  • Telegram:聊天 ID、@username,或论坛主题目标(-1001234567890:topic:42,或 --thread-id 42
  • Discord:channel:<id>user:<id>(或 <@id> 提及;原始数字 ID 会被视为频道)
  • Google Chat:spaces/<spaceId>users/<userId>
  • Slack:channel:<id>user:<id>(接受原始频道 ID)
  • Mattermost(插件):channel:<id>user:<id>,或 @username(裸 ID 会被视为频道)
  • Signal:+E.164group:<id>signal:+E.164signal:group:<id>,或 username:<name>/u:<name>
  • iMessage:句柄、chat_id:<id>chat_guid:<guid>,或 chat_identifier:<id>
  • Matrix:@user:server!room:server,或 #alias:server
  • Microsoft Teams:会话 ID(19:...@thread.tacv2)或 conversation:<id>user:<aad-object-id>

名称查找:

  • 对于受支持的提供商(Discord/Slack 等),像 Help#help 这样的频道名称会通过目录缓存解析。
  • 缓存未命中时,如果提供商支持,OpenClaw 会尝试实时目录查找。

常用标志

  • --channel <name>
  • --account <id>
  • --target <dest>(发送/投票/读取等操作的目标频道或用户)
  • --targets <name>(可重复;仅广播)
  • --json
  • --dry-run
  • --verbose

SecretRef 行为

  • openclaw message 会在运行所选操作前解析受支持渠道的 SecretRef。
  • 在可能时,解析范围会限定到当前操作目标:
  • 设置 --channel 时为渠道范围(或从 discord:... 等带前缀目标推断)
  • 设置 --account 时为账号范围(渠道全局项 + 所选账号表面)
  • 省略 --account 时,OpenClaw 不会强制使用 default 账号 SecretRef 作用域
  • 无关渠道上未解析的 SecretRef 不会阻止定向消息操作。
  • 如果所选渠道/账号的 SecretRef 未解析,该命令会对该操作失败关闭。

操作

核心

  • send
  • 渠道:WhatsApp/Telegram/Discord/Google Chat/Slack/Mattermost(插件)/Signal/iMessage/Matrix/Microsoft Teams
  • 必需:--target,以及 --message--media--presentation
  • 可选:--media--presentation--delivery--pin--reply-to--thread-id--gif-playback--force-document--silent
  • 共享呈现载荷:--presentation 发送语义块(textcontextdividerbuttonsselect),核心会通过所选渠道声明的能力进行渲染。参见 Message Presentation
  • 通用投递偏好:--delivery 接受投递提示,例如 { "pin": true };当渠道支持时,--pin 是固定投递的简写。
  • 仅 Telegram:--force-document(将图片、GIF 和视频作为文档发送,以避免 Telegram 压缩)
  • 仅 Telegram:--thread-id(论坛主题 ID)
  • 仅 Slack:--thread-id(线程时间戳;--reply-to 使用同一字段)
  • Telegram + Discord:--silent
  • 仅 WhatsApp:--gif-playback;WhatsApp 频道/Newsletter 使用其原生 @newsletter JID 寻址。

  • poll

  • 渠道:WhatsApp/Telegram/Discord/Matrix/Microsoft Teams
  • 必需:--target--poll-question--poll-option(可重复)
  • 可选:--poll-multi
  • 仅 Discord:--poll-duration-hours--silent--message
  • 仅 Telegram:--poll-duration-seconds(5-600)、--silent--poll-anonymous / --poll-public--thread-id

  • react

  • 渠道:Discord/Google Chat/Slack/Telegram/WhatsApp/Signal/Matrix
  • 必需:--message-id--target
  • 可选:--emoji--remove--participant--from-me--target-author--target-author-uuid
  • 注意:--remove 需要 --emoji(省略 --emoji 可在支持的地方清除自己的回应;参见 /tools/reactions)
  • 仅 WhatsApp:--participant--from-me
  • Signal 群组回应:需要 --target-author--target-author-uuid

  • reactions

  • 渠道:Discord/Google Chat/Slack/Matrix
  • 必需:--message-id--target
  • 可选:--limit

  • read

  • 渠道:Discord/Slack/Matrix
  • 必需:--target
  • 可选:--limit--message-id--before--after
  • 仅 Slack:--message-id 读取特定 Slack 消息时间戳;与 --thread-id 结合可读取精确的线程回复。
  • 仅 Discord:--around

  • edit

  • 渠道:Discord/Slack/Matrix
  • 必需:--message-id--message--target

  • delete

  • 渠道:Discord/Slack/Telegram/Matrix
  • 必需:--message-id--target

  • pin / unpin

  • 渠道:Discord/Slack/Matrix
  • 必需:--message-id--target

  • pins(列表)

  • 渠道:Discord/Slack/Matrix
  • 必需:--target

  • permissions

  • 渠道:Discord/Matrix
  • 必需:--target
  • 仅 Matrix:在启用 Matrix 加密且允许验证操作时可用

  • search

  • 渠道:Discord
  • 必需:--guild-id--query
  • 可选:--channel-id--channel-ids(可重复)、--author-id--author-ids(可重复)、--limit

线程

  • thread create
  • 渠道:Discord
  • 必需:--thread-name--target(频道 ID)
  • 可选:--message-id--message--auto-archive-min

  • thread list

  • 渠道:Discord
  • 必需:--guild-id
  • 可选:--channel-id--include-archived--before--limit

  • thread reply

  • 渠道:Discord
  • 必需:--target(线程 ID)、--message
  • 可选:--media--reply-to

表情符号

  • emoji list
  • Discord:--guild-id
  • Slack:无额外标志

  • emoji upload

  • 渠道:Discord
  • 必需:--guild-id--emoji-name--media
  • 可选:--role-ids(可重复)

贴纸

  • sticker send
  • 渠道:Discord
  • 必需:--target--sticker-id(可重复)
  • 可选:--message

  • sticker upload

  • 渠道:Discord
  • 必需:--guild-id--sticker-name--sticker-desc--sticker-tags--media

角色 / 频道 / 成员 / 语音

  • role info(Discord):--guild-id
  • role add / role remove(Discord):--guild-id--user-id--role-id
  • channel info(Discord):--target
  • channel list(Discord):--guild-id
  • member info(Discord/Slack):--user-id(Discord 还需要 --guild-id
  • voice status(Discord):--guild-id--user-id

事件

  • event list(Discord):--guild-id
  • event create(Discord):--guild-id--event-name--start-time
  • 可选:--end-time--desc--channel-id--location--event-type

审核(Discord)

  • timeout--guild-id--user-id(可选 --duration-min--until;两者都省略则清除超时)
  • kick--guild-id--user-id(+ --reason
  • ban--guild-id--user-id(+ --delete-days--reason
  • timeout 也支持 --reason

广播

  • broadcast
  • 渠道:任意已配置渠道;使用 --channel all 以面向所有提供商
  • 必需:--targets <target...>
  • 可选:--message--media--dry-run

示例

发送 Discord 回复:

openclaw message send --channel discord \
  --target channel:123 --message "hi" --reply-to 456

发送带语义按钮的消息:

openclaw message send --channel discord \
  --target channel:123 --message "Choose:" \
  --presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Approve","value":"approve","style":"success"},{"label":"Decline","value":"decline","style":"danger"}]}]}'

核心会根据渠道能力,将同一个 presentation 载荷渲染为 Discord 组件、Slack 块、Telegram 内联按钮、Mattermost 属性,或 Teams/Feishu 卡片。完整契约和回退规则见 Message Presentation

发送更丰富的呈现载荷:

openclaw message send --channel googlechat --target spaces/AAA... \
  --message "Choose:" \
  --presentation '{"title":"Deploy approval","tone":"warning","blocks":[{"type":"text","text":"Choose a path"},{"type":"buttons","buttons":[{"label":"Approve","value":"approve"},{"label":"Decline","value":"decline"}]}]}'

创建 Discord 投票:

openclaw message poll --channel discord \
  --target channel:123 \
  --poll-question "Snack?" \
  --poll-option Pizza --poll-option Sushi \
  --poll-multi --poll-duration-hours 48

创建 Telegram 投票(2 分钟后自动关闭):

openclaw message poll --channel telegram \
  --target @mychat \
  --poll-question "Lunch?" \
  --poll-option Pizza --poll-option Sushi \
  --poll-duration-seconds 120 --silent

发送 Teams 主动消息:

openclaw message send --channel msteams \
  --target conversation:19:abc@thread.tacv2 --message "hi"

创建 Teams 投票:

openclaw message poll --channel msteams \
  --target conversation:19:abc@thread.tacv2 \
  --poll-question "Lunch?" \
  --poll-option Pizza --poll-option Sushi

在 Slack 中回应:

openclaw message react --channel slack \
  --target C123 --message-id 456 --emoji "✅"

在 Signal 群组中回应:

openclaw message react --channel signal \
  --target signal:group:abc123 --message-id 1737630212345 \
  --emoji "✅" --target-author-uuid 123e4567-e89b-12d3-a456-426614174000

通过通用呈现发送 Telegram 内联按钮:

openclaw message send --channel telegram --target @mychat --message "Choose:" \
  --presentation '{"blocks":[{"type":"buttons","buttons":[{"label":"Yes","value":"cmd:yes"},{"label":"No","value":"cmd:no"}]}]}'

通过通用呈现发送 Teams 卡片:

openclaw message send --channel msteams \
  --target conversation:19:abc@thread.tacv2 \
  --presentation '{"title":"Status update","blocks":[{"type":"text","text":"Build completed"}]}'

将 Telegram 图片作为文档发送以避免压缩:

openclaw message send --channel telegram --target @mychat \
  --media ./diagram.png --force-document

相关


📄 Models

原文:https://docs.openclaw.ai/zh-CN/cli/models

openclaw models

模型发现、扫描和配置(默认模型、回退模型、认证配置文件)。

相关:

常用命令

openclaw models status
openclaw models list
openclaw models set <model-or-alias>
openclaw models scan

openclaw models status 会显示解析后的默认值/回退项以及认证概览。
当提供商使用量快照可用时,OAuth/API-key 状态部分会包含
提供商使用窗口和配额快照。
当前的使用窗口提供商:Anthropic、GitHub Copilot、Gemini CLI、OpenAI
Codex、MiniMax、Xiaomi 和 z.ai。使用量认证会在可用时来自提供商专用钩子;
否则 OpenClaw 会回退到从认证配置文件、环境变量或配置中匹配 OAuth/API-key
凭证。
--json 输出中,auth.providers 是感知环境变量/配置/存储的提供商
概览,而 auth.oauth 仅表示认证存储配置文件健康状况。
添加 --probe 可针对每个已配置的提供商配置文件运行实时认证探测。
探测是真实请求(可能消耗 token 并触发速率限制)。
使用 --agent <id> 检查已配置 Agent 的模型/认证状态。省略时,
该命令会使用 OPENCLAW_AGENT_DIR/PI_CODING_AGENT_DIR(如果已设置),否则使用
已配置的默认 Agent。
探测行可以来自认证配置文件、环境变量凭证或 models.json
对于 Codex OAuth 故障排除,openclaw models status
openclaw models auth list --provider openai-codex
openclaw config get agents.defaults.model --json 是确认某个 Agent 是否具备可用
openai-codex 认证配置文件,以便通过原生 Codex runtime 使用
openai/* 的最快方式。参见 OpenAI provider 设置

注意:

  • models set <model-or-alias> 接受 provider/model 或别名。
  • models list 是只读的:它会读取配置、认证配置文件、现有目录状态以及提供商拥有的目录行,
    但不会重写 models.json
  • Auth 列是提供商级别且只读的。它根据本地认证配置文件元数据、环境变量标记、
    已配置的提供商键、本地提供商标记、AWS Bedrock 环境变量/配置文件标记以及插件合成认证元数据计算;
    它不会加载提供商运行时、读取钥匙串密钥、调用提供商 API,或证明精确的逐模型执行就绪状态。
  • models list --all --provider <id> 可以包含来自插件清单或内置提供商目录元数据的、
    提供商拥有的静态目录行,即使你尚未对该提供商完成认证。这些行仍会显示为不可用,
    直到配置了匹配的认证。
  • 当提供商目录发现很慢时,models list 会保持控制平面响应。默认视图和已配置视图会在短暂等待后
    回退到已配置或合成的模型行,并让发现过程在后台完成。需要精确完整的已发现目录且愿意等待提供商发现时,
    使用 --all
  • 宽泛的 models list --all 会将清单目录行合并到注册表行之上,
    而不加载提供商运行时补充钩子。按提供商过滤的清单快速路径只使用标记为 static 的提供商;
    标记为 refreshable 的提供商保持由注册表/缓存支持,并将清单行追加为补充项,
    而标记为 runtime 的提供商保持使用注册表/运行时发现。
  • models list 会区分原生模型元数据和运行时上限。在表格输出中,
    当有效运行时上限不同于原生上下文窗口时,Ctx 会显示 contextTokens/contextWindow
    当提供商暴露该上限时,JSON 行会包含 contextTokens
  • models list --provider <id> 按提供商 id 过滤,例如 moonshot
    openai-codex。它不接受交互式提供商选择器中的显示标签,例如 Moonshot AI
  • 模型引用会按第一个 / 拆分解析。如果模型 ID 包含 /(OpenRouter 风格),请包含提供商前缀(示例:openrouter/moonshotai/kimi-k2)。
  • 如果省略提供商,OpenClaw 会先将输入解析为别名,然后解析为该精确模型 id 在已配置提供商中的唯一匹配,
    最后才回退到已配置的默认提供商并给出弃用警告。
    如果该提供商不再暴露已配置的默认模型,OpenClaw 会回退到第一个已配置的提供商/模型,
    而不是显示一个已移除提供商的过期默认值。
  • models status 可能会在认证输出中为非密钥占位符显示 marker(<value>)(例如 OPENAI_API_KEYsecretref-managedminimax-oauthoauth:chutesollama-local),而不是将它们遮蔽为密钥。

Models 扫描

models scan 会读取 OpenRouter 的公开 :free 目录,并对回退使用的候选项进行排名。
该目录本身是公开的,因此仅元数据扫描不需要 OpenRouter key。

默认情况下,OpenClaw 会尝试通过实时模型调用探测工具和图像支持。
如果未配置 OpenRouter key,该命令会回退到仅元数据输出,并说明 :free 模型仍然需要
OPENROUTER_API_KEY 才能进行探测和推理。

选项:

  • --no-probe(仅元数据;不查找配置/密钥)
  • --min-params <b>
  • --max-age-days <days>
  • --provider <name>
  • --max-candidates <n>
  • --timeout <ms>(目录请求和每次探测的超时)
  • --concurrency <n>
  • --yes
  • --no-input
  • --set-default
  • --set-image
  • --json

--set-default--set-image 需要实时探测;仅元数据扫描
结果仅供参考,不会应用到配置。

Models 状态

选项:

  • --json
  • --plain
  • --check(退出码 1=已过期/缺失,2=即将过期)
  • --probe(对已配置的认证配置文件进行实时探测)
  • --probe-provider <name>(探测一个提供商)
  • --probe-profile <id>(重复指定或逗号分隔的配置文件 id)
  • --probe-timeout <ms>
  • --probe-concurrency <n>
  • --probe-max-tokens <n>
  • --agent <id>(已配置的 Agent id;覆盖 OPENCLAW_AGENT_DIR/PI_CODING_AGENT_DIR

--json 会将 stdout 保留给 JSON 载荷。认证配置文件、提供商和启动诊断会路由到 stderr,
因此脚本可以将 stdout 直接管道传入 jq 等工具。

探测状态分组:

  • ok
  • auth
  • rate_limit
  • billing
  • timeout
  • format
  • unknown
  • no_model

可预期的探测详情/原因代码情况:

  • excluded_by_auth_order:存在已存储的配置文件,但显式
    auth.order.<provider> 省略了它,因此探测会报告该排除,而不是尝试使用它。
  • missing_credentialinvalid_expiresexpiredunresolved_ref
    配置文件存在,但不符合条件/无法解析。
  • no_model:提供商认证存在,但 OpenClaw 无法为该提供商解析出可探测的
    模型候选项。

别名 + 回退

openclaw models aliases list
openclaw models fallbacks list

认证配置文件

openclaw models auth add
openclaw models auth list [--provider <id>] [--json]
openclaw models auth login --provider <id>
openclaw models auth setup-token --provider <id>
openclaw models auth paste-token

models auth add 是交互式认证助手。它可以启动提供商认证
流程(OAuth/API key),也可以根据你选择的提供商引导你手动粘贴 token。

models auth list 会列出所选 Agent 的已保存认证配置文件,
不会打印 token、API-key 或 OAuth 密钥材料。使用 --provider <id> 过滤到一个提供商,
例如 openai-codex;使用 --json 便于脚本处理。

models auth login 会运行提供商插件的认证流程(OAuth/API key)。使用
openclaw plugins list 查看已安装的提供商。
使用 openclaw models auth --agent <id> <subcommand> 可将认证结果写入某个
特定已配置的 Agent 存储。父级 --agent 标志会被
addlistloginsetup-tokenpaste-token
login-github-copilot 遵循。

对于 OpenAI 模型,--provider openai 默认使用 ChatGPT/Codex 账户登录。
仅当你想添加 OpenAI API-key 配置文件时才使用 --method api-key
通常作为 Codex 订阅限制的备份。旧式
--provider openai-codex 写法仍适用于现有脚本。

示例:

openclaw models auth login --provider openai --set-default
openclaw models auth login --provider openai --method api-key
openclaw models auth list --provider openai

注意:

  • setup-tokenpaste-token 仍是面向暴露 token 认证方法的提供商的通用 token 命令。
  • setup-token 需要交互式 TTY,并运行提供商的 token 认证
    方法(当该提供商暴露 setup-token 方法时,默认使用该方法)。
  • paste-token 接受在其他地方生成或来自自动化的 token 字符串。
  • paste-token 需要 --provider,会提示输入 token 值,并将其写入默认配置文件 id
    <provider>:manual,除非你传入 --profile-id
  • paste-token --expires-in <duration> 会根据相对时长(例如 365d12h)存储绝对 token 过期时间。
  • Anthropic 说明:Anthropic 员工告知我们 OpenClaw 风格的 Claude CLI 使用方式再次被允许,
    因此 OpenClaw 将 Claude CLI 复用和 claude -p 用法视为此集成中受认可的方式,
    除非 Anthropic 发布新政策。
  • Anthropic setup-token / paste-token 仍作为受支持的 OpenClaw token 路径可用,
    但 OpenClaw 现在会在可用时优先使用 Claude CLI 复用和 claude -p

相关


📄 节点

原文:https://docs.openclaw.ai/zh-CN/cli/node

openclaw node

运行一个无头节点主机,它会连接到 Gateway 网关 WebSocket,并在这台机器上暴露
system.run / system.which

为什么使用节点主机?

当你希望智能体在你的网络中的其他机器上运行命令,但又不想在那里安装完整的 macOS 配套应用时,可以使用节点主机。

常见用例:

  • 在远程 Linux/Windows 机器上运行命令(构建服务器、实验室机器、NAS)。
  • 将 exec 在 Gateway 网关上保持沙箱隔离,但把已批准的运行委派给其他主机。
  • 为自动化或 CI 节点提供轻量级、无头的执行目标。

执行仍受节点主机上的 exec 审批和每个智能体的允许列表保护,因此你可以让命令访问保持有范围且显式。

浏览器代理(零配置)

如果节点上的 browser.enabled 未被禁用,节点主机会自动通告浏览器代理。这让智能体无需额外配置即可在该节点上使用浏览器自动化。

默认情况下,代理会暴露节点的常规浏览器配置文件表面。如果设置了 nodeHost.browserProxy.allowProfiles,代理会变为限制模式:非允许列表中的配置文件目标会被拒绝,持久配置文件的创建/删除路由会通过代理被阻止。

如有需要,可在节点上禁用它:

{
  nodeHost: {
    browserProxy: {
      enabled: false,
    },
  },
}

运行(前台)

openclaw node run --host <gateway-host> --port 18789

选项:

  • --host <host>:Gateway 网关 WebSocket 主机(默认:127.0.0.1
  • --port <port>:Gateway 网关 WebSocket 端口(默认:18789
  • --tls:为 Gateway 网关连接使用 TLS
  • --tls-fingerprint <sha256>:预期的 TLS 证书指纹(sha256)
  • --node-id <id>:覆盖节点 ID(清除配对令牌)
  • --display-name <name>:覆盖节点显示名称

节点主机的 Gateway 网关认证

openclaw node runopenclaw node install 会从配置/环境变量解析 Gateway 网关认证(节点命令没有 --token/--password 标志):

  • 首先检查 OPENCLAW_GATEWAY_TOKEN / OPENCLAW_GATEWAY_PASSWORD
  • 然后回退到本地配置:gateway.auth.token / gateway.auth.password
  • 在本地模式下,节点主机有意不继承 gateway.remote.token / gateway.remote.password
  • 如果通过 SecretRef 显式配置了 gateway.auth.token / gateway.auth.password 且未解析成功,节点认证解析会失败关闭(不会用远程回退来掩盖)。
  • gateway.mode=remote 中,远程客户端字段(gateway.remote.token / gateway.remote.password)也会根据远程优先级规则纳入候选。
  • 节点主机认证解析只识别 OPENCLAW_GATEWAY_* 环境变量。

对于连接到可信私有网络上非 local loopback ws:// Gateway 网关的节点,请设置 OPENCLAW_ALLOW_INSECURE_PRIVATE_WS=1。如果不设置,节点启动会失败关闭,并要求你使用 wss://、SSH 隧道或 Tailscale。
这是一个进程环境变量 opt-in,不是 openclaw.json 配置键。
openclaw node install 的安装命令环境中存在该变量时,它会将其持久化到受监管的节点服务中。

服务(后台)

将无头节点主机安装为用户服务。

openclaw node install --host <gateway-host> --port 18789

选项:

  • --host <host>:Gateway 网关 WebSocket 主机(默认:127.0.0.1
  • --port <port>:Gateway 网关 WebSocket 端口(默认:18789
  • --tls:为 Gateway 网关连接使用 TLS
  • --tls-fingerprint <sha256>:预期的 TLS 证书指纹(sha256)
  • --node-id <id>:覆盖节点 ID(清除配对令牌)
  • --display-name <name>:覆盖节点显示名称
  • --runtime <runtime>:服务运行时(nodebun
  • --force:如果已安装,则重新安装/覆盖

管理服务:

openclaw node status
openclaw node start
openclaw node stop
openclaw node restart
openclaw node uninstall

使用 openclaw node run 运行前台节点主机(无服务)。

服务命令接受 --json 以输出机器可读结果。

节点主机会在进程内重试 Gateway 网关重启和网络关闭。如果 Gateway 网关报告终止性的令牌/密码/bootstrap 认证暂停,节点主机会记录关闭详情并以非零状态退出,以便 launchd/systemd 能使用新的配置和凭据重启它。需要配对的暂停会留在前台流程中,以便待处理请求可以被批准。

配对

首次连接会在 Gateway 网关上创建一个待处理的设备配对请求(role: node)。
通过以下方式批准它:

openclaw devices list
openclaw devices approve <requestId>

在严格控制的节点网络中,Gateway 网关操作员可以显式 opt in,允许来自可信 CIDR 的首次节点配对自动批准:

{
  gateway: {
    nodes: {
      pairing: {
        autoApproveCidrs: ["192.168.1.0/24"],
      },
    },
  },
}

默认情况下此功能被禁用。它只适用于没有请求范围的新 role: node 配对。操作员/浏览器客户端、Control UI、WebChat,以及角色、范围、元数据或公钥升级仍需要手动批准。

如果节点使用变更后的认证详情(角色/范围/公钥)重试配对,之前的待处理请求会被取代,并创建新的 requestId
批准前请再次运行 openclaw devices list

节点主机会将其节点 ID、令牌、显示名称和 Gateway 网关连接信息存储在
~/.openclaw/node.json 中。

Exec 审批

system.run 受本地 exec 审批控制:

  • ~/.openclaw/exec-approvals.json
  • Exec 审批
  • openclaw approvals --node <id|name|ip>(从 Gateway 网关编辑)

对于已批准的异步节点 exec,OpenClaw 会在提示前准备规范的 systemRunPlan
随后获批的 system.run 转发会复用存储的计划,因此在创建审批请求之后对命令/cwd/会话字段的编辑会被拒绝,而不是改变节点要执行的内容。

相关


📄 节点

原文:https://docs.openclaw.ai/zh-CN/cli/nodes

openclaw nodes

管理已配对的节点(设备)并调用节点能力。

相关:

常用选项:

  • --url--token--timeout--json

常用命令

openclaw nodes list
openclaw nodes list --connected
openclaw nodes list --last-connected 24h
openclaw nodes pending
openclaw nodes approve <requestId>
openclaw nodes reject <requestId>
openclaw nodes remove --node <id|name|ip>
openclaw nodes rename --node <id|name|ip> --name <displayName>
openclaw nodes status
openclaw nodes status --connected
openclaw nodes status --last-connected 24h

nodes list 会打印待处理/已配对表。已配对行包含最近连接经过的时间(Last Connect)。
使用 --connected 仅显示当前已连接的节点。使用 --last-connected <duration>
筛选在某个时长内连接过的节点(例如 24h7d)。
使用 nodes remove --node <id|name|ip> 删除过期的、由 Gateway 网关拥有的节点配对记录。

审批说明:

  • openclaw nodes pending 只需要配对作用域。
  • gateway.nodes.pairing.autoApproveCidrs 只能为明确受信任的、首次 role: node 设备配对跳过待处理步骤。它默认关闭,并且不会批准升级。
  • openclaw nodes approve <requestId> 会从待处理请求继承额外的作用域要求:
  • 无命令请求:仅配对
  • 非执行类节点命令:配对 + 写入
  • system.run / system.run.prepare / system.which:配对 + 管理员

调用

openclaw nodes invoke --node <id|name|ip> --command <command> --params <json>

调用标志:

  • --params <json>:JSON 对象字符串(默认 {})。
  • --invoke-timeout <ms>:节点调用超时(默认 15000)。
  • --idempotency-key <key>:可选的幂等键。
  • 此处会阻止 system.runsystem.run.prepare;如需执行 shell,请使用带有 host=nodeexec 工具。

如需在节点上执行 shell,请使用带有 host=nodeexec 工具,而不是 openclaw nodes run
nodes CLI 现在专注于能力:通过 nodes invoke 直接 RPC,再加上配对、摄像头、
屏幕、位置、Canvas 和通知。Canvas 命令由内置的实验性 Canvas 插件实现;核心保留了兼容性钩子,因此它们仍位于 openclaw nodes canvas 下。

相关


📄 新手引导

原文:https://docs.openclaw.ai/zh-CN/cli/onboard

openclaw onboard

用于本地或远程 Gateway 网关设置的完整引导式新手引导。当你希望 OpenClaw 在一个流程中依次完成模型认证、工作区、Gateway 网关、渠道、技能和健康检查时,请使用此命令。

相关指南

交互式 CLI 流程的演练。

OpenClaw 新手引导如何衔接在一起。

输出、内部机制和逐步行为。

非交互式标志和脚本化设置。

macOS 菜单栏应用的新手引导流程。

示例

openclaw onboard
openclaw onboard --modern
openclaw onboard --flow quickstart
openclaw onboard --flow manual
openclaw onboard --flow import
openclaw onboard --import-from hermes --import-source ~/.hermes
openclaw onboard --skip-bootstrap
openclaw onboard --mode remote --remote-url wss://gateway-host:18789

--flow import 使用插件所有的迁移提供商,例如 Hermes。它只会针对全新的 OpenClaw 设置运行;如果已有配置、凭证、会话或工作区记忆/身份文件存在,请先重置,或在导入前选择全新设置。

--modern 会启动 Crestodian 对话式新手引导预览。如果不使用
--modernopenclaw onboard 会保留经典新手引导流程。

对于明文私有网络 ws:// 目标(仅限受信任网络),请在新手引导进程环境中设置
OPENCLAW_ALLOW_INSECURE_PRIVATE_WS=1
这个客户端侧传输应急开关没有等价的 openclaw.json 配置项。

非交互式自定义提供商:

openclaw onboard --non-interactive \
  --auth-choice custom-api-key \
  --custom-base-url "https://llm.example.com/v1" \
  --custom-model-id "foo-large" \
  --custom-api-key "$CUSTOM_API_KEY" \
  --secret-input-mode plaintext \
  --custom-compatibility openai \
  --custom-image-input

--custom-api-key 在非交互式模式下是可选的。如果省略,新手引导会检查 CUSTOM_API_KEY
OpenClaw 会自动将常见视觉模型 ID 标记为支持图像。对于未知的自定义视觉 ID,请传入 --custom-image-input;或传入 --custom-text-input 强制使用仅文本元数据。

LM Studio 在非交互式模式下也支持提供商专用密钥标志:

openclaw onboard --non-interactive \
  --auth-choice lmstudio \
  --custom-base-url "http://localhost:1234/v1" \
  --custom-model-id "qwen/qwen3.5-9b" \
  --lmstudio-api-key "$LM_API_TOKEN" \
  --accept-risk

非交互式 Ollama:

openclaw onboard --non-interactive \
  --auth-choice ollama \
  --custom-base-url "http://ollama-host:11434" \
  --custom-model-id "qwen3.5:27b" \
  --accept-risk

--custom-base-url 默认值为 http://127.0.0.1:11434--custom-model-id 是可选项;如果省略,新手引导会使用 Ollama 建议的默认值。诸如 kimi-k2.5:cloud 的云模型 ID 也可以在这里使用。

将提供商密钥存储为引用,而不是明文:

openclaw onboard --non-interactive \
  --auth-choice openai-api-key \
  --secret-input-mode ref \
  --accept-risk

使用 --secret-input-mode ref 时,新手引导会写入由环境支持的引用,而不是明文密钥值。
对于由认证配置文件支持的提供商,这会写入 keyRef 条目;对于自定义提供商,这会将 models.providers.<id>.apiKey 写为环境引用(例如 { source: "env", provider: "default", id: "CUSTOM_API_KEY" })。

非交互式 ref 模式契约:

  • 在新手引导进程环境中设置提供商环境变量(例如 OPENAI_API_KEY)。
  • 不要传入内联密钥标志(例如 --openai-api-key),除非该环境变量也已设置。
  • 如果传入内联密钥标志但缺少必需的环境变量,新手引导会快速失败并给出指导。

非交互式模式下的 Gateway 网关令牌选项:

  • --gateway-auth token --gateway-token <token> 存储明文令牌。
  • --gateway-auth token --gateway-token-ref-env <name>gateway.auth.token 存储为环境 SecretRef。
  • --gateway-token--gateway-token-ref-env 互斥。
  • --gateway-token-ref-env 要求新手引导进程环境中存在非空环境变量。
  • 使用 --install-daemon 时,如果令牌认证需要令牌,由 SecretRef 管理的 Gateway 网关令牌会被验证,但不会作为已解析的明文持久化到 supervisor 服务环境元数据中。
  • 使用 --install-daemon 时,如果令牌模式需要令牌且配置的令牌 SecretRef 无法解析,新手引导会关闭失败并给出修复指导。
  • 使用 --install-daemon 时,如果同时配置了 gateway.auth.tokengateway.auth.password,且未设置 gateway.auth.mode,新手引导会阻止安装,直到明确设置模式。
  • 本地新手引导会将 gateway.mode="local" 写入配置。如果后续配置文件缺少 gateway.mode,请将其视为配置损坏或未完成的手动编辑,而不是有效的本地模式快捷方式。
  • 当所选设置路径需要可下载插件时,本地新手引导会安装所选插件。
  • 远程新手引导只写入远程 Gateway 网关的连接信息,不会安装本地插件包。
  • --allow-unconfigured 是一个单独的 Gateway 网关运行时逃生开关。它不表示新手引导可以省略 gateway.mode

示例:

export OPENCLAW_GATEWAY_TOKEN="your-token"
openclaw onboard --non-interactive \
  --mode local \
  --auth-choice skip \
  --gateway-auth token \
  --gateway-token-ref-env OPENCLAW_GATEWAY_TOKEN \
  --accept-risk

非交互式本地 Gateway 网关健康检查:

  • 除非传入 --skip-health,否则新手引导会等待本地 Gateway 网关可访问后才成功退出。
  • --install-daemon 会先启动托管 Gateway 网关安装路径。如果未使用它,你必须已经有一个本地 Gateway 网关在运行,例如 openclaw gateway run
  • 如果你只想在自动化中写入配置/工作区/bootstrap,请使用 --skip-health
  • 如果你自行管理工作区文件,请传入 --skip-bootstrap 以设置 agents.defaults.skipBootstrap: true,并跳过创建 AGENTS.mdSOUL.mdTOOLS.mdIDENTITY.mdUSER.mdHEARTBEAT.mdBOOTSTRAP.md
  • 在原生 Windows 上,--install-daemon 会先尝试 Scheduled Tasks;如果任务创建被拒绝,则回退到每用户 Startup 文件夹登录项。

使用引用模式时的交互式新手引导行为:

  • 在提示时选择 使用密钥引用
  • 然后选择以下任一项:
  • 环境变量
  • 已配置的密钥提供商(fileexec
  • 新手引导会在保存引用前执行快速预检验证。
  • 如果验证失败,新手引导会显示错误并允许你重试。

非交互式 Z.AI 端点选择

--auth-choice zai-api-key 会自动检测最适合你的密钥的 Z.AI 端点(优先使用带有 zai/glm-5.1 的通用 API)。如果你明确想使用 GLM Coding Plan 端点,请选择 zai-coding-globalzai-coding-cn

# Promptless endpoint selection
openclaw onboard --non-interactive \
  --auth-choice zai-coding-global \
  --zai-api-key "$ZAI_API_KEY"

# Other Z.AI endpoint choices:
# --auth-choice zai-coding-cn
# --auth-choice zai-global
# --auth-choice zai-cn

非交互式 Mistral 示例:

openclaw onboard --non-interactive \
  --auth-choice mistral-api-key \
  --mistral-api-key "$MISTRAL_API_KEY"

流程说明

- quickstart:最少提示,自动生成 Gateway 网关令牌。
- manual:针对端口、绑定和认证提供完整提示(advanced 的别名)。
- import:运行检测到的迁移提供商,预览计划,然后在确认后应用。

当认证选择暗示首选提供商时,新手引导会将默认模型和 allowlist 选择器预筛选到该提供商。对于 Volcengine 和 BytePlus,这也会匹配 coding-plan 变体(volcengine-plan/*byteplus-plan/*)。

如果首选提供商筛选尚未产生已加载模型,新手引导会回退到未筛选目录,而不是让选择器为空。

一些 Web 搜索提供商会触发提供商专用的后续提示:

- **Grok** 可以提供可选的 `x_search` 设置,使用相同的 `XAI_API_KEY` 和一个 `x_search` 模型选择。
- **Kimi** 可以询问 Moonshot API 区域(`api.moonshot.ai`  `api.moonshot.cn`)以及默认 Kimi Web 搜索模型。

- 本地新手引导私信范围行为:CLI 设置参考
- 最快的首次聊天:openclaw dashboard(Control UI,无需渠道设置)。
- 自定义提供商:连接任何兼容 OpenAI 或 Anthropic 的端点,包括未列出的托管提供商。使用 Unknown 可自动检测。
- 如果检测到 Hermes 状态,新手引导会提供迁移流程。使用 迁移 获取 dry-run 计划、覆盖模式、报告和精确映射。

常见后续命令

openclaw channels add
openclaw configure
openclaw agents add <name>

当你只需要基线配置/工作区时,请改用 openclaw setup。稍后可使用 openclaw configure 进行针对性更改,并使用 openclaw channels add 进行仅渠道设置。

--json 并不意味着非交互式模式。脚本请使用 --non-interactive


📄 配对

原文:https://docs.openclaw.ai/zh-CN/cli/pairing

openclaw pairing

批准或查看私信配对请求(适用于支持配对的渠道)。

相关:

命令

openclaw pairing list telegram
openclaw pairing list --channel telegram --account work
openclaw pairing list telegram --json

openclaw pairing approve <code>
openclaw pairing approve telegram <code>
openclaw pairing approve --channel telegram --account work <code> --notify

pairing list

列出一个渠道中待处理的配对请求。

选项:

  • [channel]:位置参数渠道 ID
  • --channel <channel>:显式渠道 ID
  • --account <accountId>:多账户渠道的账户 ID
  • --json:机器可读输出

注意:

  • 如果配置了多个支持配对的渠道,你必须通过位置参数或 --channel 提供一个渠道。
  • 只要渠道 ID 有效,就允许使用插件渠道。

pairing approve

批准待处理的配对码,并允许该发送者。

用法:

  • openclaw pairing approve <channel> <code>
  • openclaw pairing approve --channel <channel> <code>
  • 当只配置了一个支持配对的渠道时,可使用 openclaw pairing approve <code>

选项:

  • --channel <channel>:显式渠道 ID
  • --account <accountId>:多账户渠道的账户 ID
  • --notify:通过同一渠道向请求者发回确认消息

所有者引导:

  • 如果你批准配对码时 commands.ownerAllowFrom 为空,OpenClaw 还会使用渠道范围的条目(例如 telegram:123456789)将已批准的发送者记录为命令所有者。
  • 这只会引导第一个所有者。后续配对批准不会替换或扩展 commands.ownerAllowFrom
  • 命令所有者是被允许运行仅所有者可用命令,并批准危险操作的人类操作员账户,例如 /diagnostics/export-trajectory/config 和 exec 批准。

注意

  • 渠道输入:通过位置参数传入(pairing list telegram),或使用 --channel <channel>
  • pairing list 支持用于多账户渠道的 --account <accountId>
  • pairing approve 支持 --account <accountId>--notify
  • 如果只配置了一个支持配对的渠道,则允许使用 pairing approve <code>
  • 如果你在此引导机制存在之前批准过某个发送者,请运行 openclaw doctor;当未配置命令所有者时,它会发出警告,并显示用于修复的 openclaw config set commands.ownerAllowFrom ... 命令。

相关


📄 插件

原文:https://docs.openclaw.ai/zh-CN/cli/plugins

管理 Gateway 网关插件、钩子包和兼容包。

面向最终用户的插件安装、启用和故障排除指南。

安装、列出、更新、卸载和发布的快速示例。

包兼容性模型。

清单字段和配置架构。

插件安装的安全加固。

命令

openclaw plugins list
openclaw plugins list --enabled
openclaw plugins list --verbose
openclaw plugins list --json
openclaw plugins search <query>
openclaw plugins search <query> --limit 20
openclaw plugins search <query> --json
openclaw plugins install <path-or-spec>
openclaw plugins inspect <id>
openclaw plugins inspect <id> --runtime
openclaw plugins inspect <id> --json
openclaw plugins inspect --all
openclaw plugins info <id>
openclaw plugins enable <id>
openclaw plugins disable <id>
openclaw plugins registry
openclaw plugins registry --refresh
openclaw plugins uninstall <id>
openclaw plugins doctor
openclaw plugins update <id-or-npm-spec>
openclaw plugins update --all
openclaw plugins marketplace list <marketplace>
openclaw plugins marketplace list <marketplace> --json

若要调查缓慢的安装、检查、卸载或注册表刷新,请在运行命令时设置 OPENCLAW_PLUGIN_LIFECYCLE_TRACE=1。跟踪会将阶段耗时写入 stderr,并保持 JSON 输出可解析。参见调试

在 Nix 模式(OPENCLAW_NIX_MODE=1)下,插件生命周期变更命令会被禁用。请改用该安装的 Nix 源,而不是 plugins installplugins updateplugins uninstallplugins enableplugins disable;对于 nix-openclaw,请使用 agent 优先的快速开始

内置插件随 OpenClaw 一起发布。有些默认启用(例如内置模型提供商、内置语音提供商和内置浏览器插件);其他插件需要运行 plugins enable

原生 OpenClaw 插件必须随附 openclaw.plugin.json,并包含内联 JSON Schema(configSchema,即使为空)。兼容包则使用自己的包清单。

plugins list 会显示 Format: openclawFormat: bundle。详细列表/信息输出还会显示包子类型(codexclaudecursor)以及检测到的包能力。

安装

openclaw plugins search "calendar"                   # search ClawHub plugins
openclaw plugins install <package>                      # npm by default
openclaw plugins install clawhub:<package>              # ClawHub only
openclaw plugins install npm:<package>                  # npm only
openclaw plugins install npm-pack:<path.tgz>            # local npm pack through npm install semantics
openclaw plugins install git:github.com/<owner>/<repo>  # git repo
openclaw plugins install git:github.com/<owner>/<repo>@<ref>
openclaw plugins install <package> --force              # overwrite existing install
openclaw plugins install <package> --pin                # pin version
openclaw plugins install <package> --dangerously-force-unsafe-install
openclaw plugins install <path>                         # local path
openclaw plugins install <plugin>@<marketplace>         # marketplace
openclaw plugins install <plugin> --marketplace <name>  # marketplace (explicit)
openclaw plugins install <plugin> --marketplace https://github.com/<owner>/<repo>

测试设置期安装的维护者可以使用受保护的环境变量覆盖自动插件安装来源。参见插件安装覆盖

裸包名在启动切换期间默认从 npm 安装。ClawHub 请使用 clawhub:<package>。请像运行代码一样对待插件安装。优先使用固定版本。

plugins search 会查询 ClawHub 中可安装的插件包,并输出可直接安装的包名。它搜索代码插件和包插件包,而不是 Skills。ClawHub Skills 请使用 openclaw skills search

ClawHub 是大多数插件的主要分发和发现界面。Npm 仍是受支持的回退和直接安装路径。OpenClaw 拥有的 @openclaw/* 插件包已重新发布到 npm;请在 npmjs.com/org/openclaw插件清单查看当前列表。稳定版安装使用 latest。Beta 频道的安装和更新会在 npm beta dist-tag 可用时优先使用它,然后回退到 latest

如果你的 plugins 部分由单文件 $include 支撑,plugins install/update/enable/disable/uninstall 会写入该被包含的文件,并保持 openclaw.json 不变。根 include、include 数组以及带有同级覆盖的 include 会封闭失败,而不是扁平化。有关受支持的形态,请参见配置 include

如果安装期间配置无效,`plugins install` 通常会封闭失败,并提示你先运行 `openclaw doctor --fix`。在 Gateway 网关启动和热重载期间,无效插件配置会像任何其他无效配置一样封闭失败;`openclaw doctor --fix` 可以隔离该无效插件条目。唯一有文档说明的安装时例外,是针对显式选择加入 `openclaw.install.allowInvalidConfigRecovery` 的插件的窄范围内置插件恢复路径。

--force 会复用现有安装目标,并就地覆盖已安装的插件或钩子包。当你有意从新的本地路径、归档、ClawHub 包或 npm 构件重新安装相同 id 时使用它。对于已跟踪的 npm 插件的常规升级,优先使用 openclaw plugins update <id-or-npm-spec>

如果你对已安装插件 id 运行 `plugins install`,OpenClaw 会停止并将你指向 `plugins update <id-or-npm-spec>` 进行正常升级如果你确实想从其他来源覆盖当前安装则指向 `plugins install <package> --force`。

--pin 仅适用于 npm 安装。它不支持 git: 安装;如果你想要固定来源,请使用显式 git ref,例如 git:github.com/acme/plugin@v1.2.3。它不支持 --marketplace,因为 marketplace 安装会持久化 marketplace 来源元数据,而不是 npm spec。

--dangerously-force-unsafe-install 是用于内置危险代码扫描器误报的应急选项。即使内置扫描器报告 critical 发现,它也允许继续安装,但它不会绕过插件 before_install 钩子策略阻断,也不会绕过扫描失败。

 CLI 标志适用于插件安装/更新流程。由 Gateway 网关支撑的 skill 依赖安装使用对应的 `dangerouslyForceUnsafeInstall` 请求覆盖,而 `openclaw skills install` 仍是单独的 ClawHub skill 下载/安装流程。

如果你发布到 ClawHub 的插件被注册表扫描阻断,请使用 [ClawHub](/zh-CN/clawhub/security) 中的发布者步骤。

plugins install 也是安装在 package.json 中暴露 openclaw.hooks 的钩子包的入口。请使用 openclaw hooks 查看筛选后的钩子可见性并启用单个钩子,而不是安装包。

Npm spec **仅限注册表**包名 + 可选的**精确版本** **dist-tag**)。Git/URL/file spec  semver 范围会被拒绝为安全起见依赖安装会使用 `--ignore-scripts` 在项目本地运行即使你的 shell 配置了全局 npm 安装设置托管插件 npm 根会继承 OpenClaw 包级别的 npm `overrides`,因此主机安全固定也会应用到提升的插件依赖

当你想明确使用 npm 解析时请使用 `npm:<package>`。裸包 spec 在启动切换期间也会直接从 npm 安装

 spec  `@latest` 会留在稳定轨道OpenClaw 带日期戳的修正版版本例如 `2026.5.3-1`)在此检查中属于稳定发布如果 npm 将其中任一解析为预发布版本OpenClaw 会停止并要求你使用预发布标签例如 `@beta`/`@rc`)或精确预发布版本例如 `@1.2.3-beta.4`)显式选择加入

如果裸安装 spec 匹配官方插件 id例如 `diffs`),OpenClaw 会直接安装目录条目若要安装同名 npm 请使用显式带作用域 spec例如 `@scope/diffs`)。

使用 git:<repo> 可直接从 git 仓库安装。支持的形式包括 git:github.com/owner/repogit:owner/repo、完整 https://ssh://git://file:// 以及 git@host:owner/repo.git 克隆 URL。添加 @<ref>#<ref> 可在安装前检出分支、标签或提交。

Git 安装会克隆到临时目录,在存在所请求的 ref 时检出它,然后使用普通插件目录安装器。这意味着清单验证、危险代码扫描、包管理器安装工作和安装记录的行为都与 npm 安装相同。记录的 git 安装会包含源 URL/ref 以及解析后的提交,以便 `openclaw plugins update` 后续可以重新解析该来源。

 git 安装后,请使用 `openclaw plugins inspect <id> --runtime --json` 验证运行时注册,例如 gateway 方法和 CLI 命令。如果插件通过 `api.registerCli` 注册了 CLI 根,请直接通过 OpenClaw  CLI 执行该命令,例如 `openclaw demo-plugin ping`。

支持的归档:.zip.tgz.tar.gz.tar。原生 OpenClaw 插件归档必须在解压后的插件根目录包含有效的 openclaw.plugin.json;只包含 package.json 的归档会在 OpenClaw 写入安装记录前被拒绝。

当文件是 npm-pack tarball且你想测试与注册表安装相同的托管 npm 根安装路径时请使用 `npm-pack:<path.tgz>`,包括 `package-lock.json` 验证提升依赖扫描和 npm 安装记录普通归档路径仍会作为本地归档安装在插件 extensions 根下

也支持 Claude marketplace 安装

ClawHub 安装使用显式 clawhub:<package> 定位符:

openclaw plugins install clawhub:openclaw-codex-app-server
openclaw plugins install clawhub:openclaw-codex-app-server@1.2.3

裸 npm 安全插件 spec 在启动切换期间默认从 npm 安装:

openclaw plugins install openclaw-codex-app-server

使用 npm: 可明确仅使用 npm 解析:

openclaw plugins install npm:openclaw-codex-app-server
openclaw plugins install npm:@scope/plugin-name@1.0.1

OpenClaw 会在安装前检查声明的插件 API / 最低 Gateway 网关兼容性。当选定的 ClawHub 版本发布 ClawPack 构件时,OpenClaw 会下载带版本的 npm-pack .tgz,验证 ClawHub 摘要标头和构件摘要,然后通过常规归档路径安装。没有 ClawPack 元数据的较旧 ClawHub 版本仍会通过旧版包归档验证路径安装。记录的安装会保留其 ClawHub 来源元数据、构件类型、npm integrity、npm shasum、tarball 名称以及 ClawPack 摘要信息,以供后续更新使用。
未指定版本的 ClawHub 安装会保留未指定版本的记录规范,因此 openclaw plugins update 可以跟随更新的 ClawHub 版本;显式版本或标签选择器(例如 clawhub:pkg@1.2.3clawhub:pkg@beta)会继续固定到该选择器。

市场简写

当 Claude 的本地注册表缓存在 ~/.claude/plugins/known_marketplaces.json 中存在该市场名称时,使用 plugin@marketplace 简写:

openclaw plugins marketplace list <marketplace-name>
openclaw plugins install <plugin-name>@<marketplace-name>

当你想显式传入市场来源时,使用 --marketplace

openclaw plugins install <plugin-name> --marketplace <marketplace-name>
openclaw plugins install <plugin-name> --marketplace <owner/repo>
openclaw plugins install <plugin-name> --marketplace https://github.com/<owner>/<repo>
openclaw plugins install <plugin-name> --marketplace ./my-marketplace

- 来自 ~/.claude/plugins/known_marketplaces.json 的 Claude 已知市场名称
- 本地市场根目录或 marketplace.json 路径
- GitHub 仓库简写,例如 owner/repo
- GitHub 仓库 URL,例如 https://github.com/owner/repo
- git URL

对于从 GitHub 或 git 加载的远程市场,插件条目必须留在克隆的市场仓库内。OpenClaw 接受来自该仓库的相对路径来源,并拒绝远程清单中的 HTTP(S)、绝对路径、git、GitHub 以及其他非路径插件来源。

对于本地路径和归档,OpenClaw 会自动检测:

  • 原生 OpenClaw 插件(openclaw.plugin.json
  • Codex 兼容包(.codex-plugin/plugin.json
  • Claude 兼容包(.claude-plugin/plugin.json 或默认 Claude 组件布局)
  • Cursor 兼容包(.cursor-plugin/plugin.json

兼容包会安装到常规插件根目录,并参与同一套 list/info/enable/disable 流程。目前支持包 Skills、Claude 命令 Skills、Claude settings.json 默认值、Claude .lsp.json / 清单声明的 lspServers 默认值、Cursor 命令 Skills 以及兼容的 Codex 钩子目录;其他检测到的包能力会显示在 diagnostics/info 中,但尚未接入运行时执行。

列出

openclaw plugins list
openclaw plugins list --enabled
openclaw plugins list --verbose
openclaw plugins list --json
openclaw plugins search <query>
openclaw plugins search <query> --limit 20
openclaw plugins search <query> --json

仅显示已启用的插件。

从表格视图切换到每个插件的详细行,其中包含来源/源点/版本/激活元数据。

机器可读的清单,加上注册表诊断和包依赖安装状态。

plugins list 会先读取持久化的本地插件注册表;当注册表缺失或无效时,回退到仅由清单派生的结果。它适合用于检查插件是否已安装、已启用,以及是否对冷启动规划可见,但它不是对已经运行的 Gateway 网关进程的实时运行时探测。更改插件代码、启用状态、钩子策略或 plugins.load.paths 后,请先重启为该渠道提供服务的 Gateway 网关,再期待新的 register(api) 代码或钩子运行。对于远程/容器部署,请确认你重启的是实际的 openclaw gateway run 子进程,而不只是包装进程。

plugins list --json 包含每个插件来自 package.json
dependenciesoptionalDependenciesdependencyStatus。OpenClaw 会检查这些包
名称是否出现在该插件正常 Node node_modules 查找路径上;它
不会导入插件运行时代码、运行包管理器,或修复缺失的
依赖。

plugins search 是远程 ClawHub 目录查询。它不会检查本地
状态、变更配置、安装包,或加载插件运行时代码。搜索
结果包含 ClawHub 包名称、族、渠道、版本、摘要,以及
类似 openclaw plugins install clawhub:<package> 的安装提示。

对于打包 Docker 镜像内的内置插件工作,请将插件
源目录 bind-mount 到匹配的打包源路径之上,例如
/app/extensions/synology-chat。OpenClaw 会先发现该挂载的源
覆盖层,然后才是 /app/dist/extensions/synology-chat;普通复制的源
目录保持不生效,因此常规打包安装仍会使用编译后的 dist。

对于运行时钩子调试:

  • openclaw plugins inspect <id> --runtime --json 会显示模块加载检查过程中注册的钩子和诊断。运行时检查永远不会安装依赖;使用 openclaw doctor --fix 清理旧版依赖状态,或恢复配置引用的缺失可下载插件。
  • openclaw gateway status --deep --require-rpc 会确认可访问的 Gateway 网关、服务/进程提示、配置路径以及 RPC 健康状态。
  • 非内置对话钩子(llm_inputllm_outputbefore_model_resolvebefore_agent_replybefore_agent_runbefore_agent_finalizeagent_end)需要 plugins.entries.<id>.hooks.allowConversationAccess=true

使用 --link 可避免复制本地目录(会添加到 plugins.load.paths):

openclaw plugins install -l ./my-plugin

--force 不支持与 --link 一起使用,因为链接安装会复用源路径,而不是覆盖托管安装目标。

在 npm 安装上使用 --pin,可将解析后的精确规范(name@version)保存到托管插件索引中,同时保持默认行为不固定版本。

插件索引

插件安装元数据是机器管理的状态,不是用户配置。安装和更新会把它写入活动 OpenClaw 状态目录下的 plugins/installs.json。其顶层 installRecords 映射是安装元数据的持久来源,包括损坏或缺失插件清单的记录。plugins 数组是由清单派生的冷注册表缓存。该文件包含不要编辑警告,并由 openclaw plugins update、卸载、诊断以及冷插件注册表使用。

当 OpenClaw 在配置中看到已发布的旧版 plugins.installs 记录时,运行时读取会将它们作为兼容性输入处理,而不会重写 openclaw.json。显式插件写入和 openclaw doctor --fix 会在允许写入配置时把这些记录移动到插件索引,并移除配置键;如果任一写入失败,配置记录会被保留,因此安装元数据不会丢失。

卸载

openclaw plugins uninstall <id>
openclaw plugins uninstall <id> --dry-run
openclaw plugins uninstall <id> --keep-files

uninstall 会从 plugins.entries、持久化插件索引、插件允许/拒绝列表条目,以及适用时的链接 plugins.load.paths 条目中移除插件记录。除非设置了 --keep-files,卸载还会在被跟踪的托管安装目录位于 OpenClaw 插件扩展根目录内时移除该目录。对于主动记忆插件,记忆槽位会重置为 memory-core

--keep-config 作为 --keep-files 的已弃用别名受支持。

更新

openclaw plugins update <id-or-npm-spec>
openclaw plugins update --all
openclaw plugins update <id-or-npm-spec> --dry-run
openclaw plugins update @openclaw/voice-call
openclaw plugins update openclaw-codex-app-server --dangerously-force-unsafe-install

更新适用于托管插件索引中跟踪的插件安装,以及 hooks.internal.installs 中跟踪的 hook-pack 安装。

当你传入插件 id 时,OpenClaw 会复用该插件记录的安装规范。这意味着之前存储的 dist-tag(例如 @beta)和精确固定版本会在后续 update <id> 运行中继续使用。

对于 npm 安装,你也可以传入带 dist-tag 或精确版本的显式 npm 包规范。OpenClaw 会将该包名称解析回被跟踪的插件记录,更新该已安装插件,并记录新的 npm 规范以供后续基于 id 的更新使用。

传入不带版本或标签的 npm 包名称也会解析回被跟踪的插件记录。当插件已固定到精确版本,而你想把它移回注册表的默认发布线时,请使用这种方式。

openclaw plugins update 会复用被跟踪的插件规范,除非你传入新规范。openclaw update 还知道活动的 OpenClaw 更新渠道:在 beta 渠道上,默认线 npm 和 ClawHub 插件记录会先尝试 @beta,如果不存在插件 beta 版本,则回退到记录的默认/latest 规范。该回退会以警告形式报告,并且不会导致核心更新失败。精确版本和显式标签会保持固定到该选择器。

在实时 npm 更新之前,OpenClaw 会根据 npm 注册表元数据检查已安装包版本。如果已安装版本和记录的构件身份已经与解析后的目标匹配,则会跳过更新,不下载、不重新安装,也不重写 openclaw.json

当存在已存储的完整性哈希且获取到的构件哈希发生变化时,OpenClaw 会将其视为 npm 构件漂移。交互式 `openclaw plugins update` 命令会打印预期和实际哈希,并在继续之前请求确认。非交互式更新辅助工具会默认失败关闭,除非调用方提供显式继续策略。

--dangerously-force-unsafe-install 也可用于 plugins update,作为插件更新期间内置危险代码扫描误报的紧急覆盖。它仍不会绕过插件 before_install 策略阻断或扫描失败阻断,并且只适用于插件更新,不适用于 hook-pack 更新。

检查

openclaw plugins inspect <id>
openclaw plugins inspect <id> --runtime
openclaw plugins inspect <id> --json

Inspect 默认不导入插件运行时,会显示身份、加载状态、来源、清单能力、策略标志、诊断、安装元数据、包能力,以及任何检测到的 MCP 或 LSP 服务器支持。添加 --runtime 可加载插件模块,并包含已注册的钩子、工具、命令、服务、Gateway 网关方法以及 HTTP 路由。运行时检查会直接报告缺失的插件依赖;安装和修复保留在 openclaw plugins installopenclaw plugins updateopenclaw doctor --fix 中。

插件拥有的 CLI 命令通常作为根 openclaw 命令组安装,但插件也可以在核心父级下注册嵌套命令,例如 openclaw nodes。在 inspect --runtimecliCommands 下显示某个命令后,请按列出的路径运行它;例如,注册 demo-git 的插件可用 openclaw demo-git ping 验证。

每个插件会按其在运行时实际注册的内容分类:

  • plain-capability — 一种能力类型(例如仅提供商插件)
  • hybrid-capability — 多种能力类型(例如文本 + 语音 + 图像)
  • hook-only — 仅钩子,没有能力或界面
  • non-capability — 工具/命令/服务,但没有能力

参阅 插件形态,了解有关能力模型的更多内容。

--json 标志会输出适合脚本编写和审计的机器可读报告。inspect --all 会渲染一张覆盖全部插件的表格,包含形态、能力种类、兼容性提示、内置能力和钩子摘要列。infoinspect 的别名。

Doctor

openclaw plugins doctor

doctor 会报告插件加载错误、清单/设备发现诊断以及兼容性提示。当一切正常时,它会打印 No plugin issues detected.

如果已配置的插件存在于磁盘上,但被加载器的路径安全检查阻止,配置验证会保留该插件条目,并将其报告为 present but blocked。请修复前面的被阻止插件诊断,例如路径所有权或全局可写权限,而不是移除 plugins.entries.<id>plugins.allow 配置。

对于缺少 register/activate 导出等模块形态失败,请使用 OPENCLAW_PLUGIN_LOAD_DEBUG=1 重新运行,以便在诊断输出中包含紧凑的导出形态摘要。

注册表

openclaw plugins registry
openclaw plugins registry --refresh
openclaw plugins registry --json

本地插件注册表是 OpenClaw 持久化的冷读模型,用于已安装插件身份、启用状态、来源元数据和贡献归属。正常启动、提供商所有者查找、渠道设置分类和插件清单都可以读取它,而无需导入插件运行时模块。

使用 plugins registry 检查持久化注册表是否存在、是否为当前版本或是否已过期。使用 --refresh 可基于持久化插件索引、配置策略以及清单/包元数据重建它。这是修复路径,不是运行时激活路径。

openclaw doctor --fix 也会修复与注册表相邻的受管 npm 漂移:如果受管插件 npm 根目录下孤立或恢复的 @openclaw/* 包遮蔽了内置插件,Doctor 会移除该过期包并重建注册表,使启动流程根据内置清单进行验证。Doctor 还会将宿主 openclaw 包重新链接到声明了 peerDependencies.openclaw 的受管 npm 插件中,使 openclaw/plugin-sdk/* 等包本地运行时导入在更新或 npm 修复后能够解析。

OPENCLAW_DISABLE_PERSISTED_PLUGIN_REGISTRY=1 是一个已弃用的应急兼容性开关,用于处理注册表读取失败。优先使用 plugins registry --refreshopenclaw doctor --fix;该环境变量回退仅用于迁移推出期间的紧急启动恢复。

市场

openclaw plugins marketplace list <source>
openclaw plugins marketplace list <source> --json

市场列表接受本地市场路径、marketplace.json 路径、类似 owner/repo 的 GitHub 简写、GitHub 仓库 URL 或 git URL。--json 会打印解析后的来源标签,以及解析出的市场清单和插件条目。

相关


📄 重置

原文:https://docs.openclaw.ai/zh-CN/cli/reset

openclaw reset

重置本地配置/状态(保留 CLI 已安装)。

选项:

  • --scope <scope>configconfig+creds+sessionsfull
  • --yes:跳过确认提示
  • --non-interactive:禁用提示;需要同时设置 --scope--yes
  • --dry-run:打印操作内容而不删除文件

示例:

openclaw backup create
openclaw reset
openclaw reset --dry-run
openclaw reset --scope config --yes --non-interactive
openclaw reset --scope config+creds+sessions --yes --non-interactive
openclaw reset --scope full --yes --non-interactive

说明:

  • 如果你想在删除本地状态前保留一个可恢复的快照,请先运行 openclaw backup create
  • 如果你省略 --scopeopenclaw reset 会使用交互式提示来选择要删除的内容。
  • --non-interactive 仅在同时设置 --scope--yes 时有效。

相关内容


📄 沙箱 CLI

原文:https://docs.openclaw.ai/zh-CN/cli/sandbox

管理用于隔离智能体执行的沙箱运行时。

概览

OpenClaw 可以在隔离的沙箱运行时中运行智能体以提高安全性。sandbox 命令可帮助你在更新或配置变更后检查并重新创建这些运行时。

目前这通常意味着:

  • Docker 沙箱容器
  • agents.defaults.sandbox.backend = "ssh" 时的 SSH 沙箱运行时
  • agents.defaults.sandbox.backend = "openshell" 时的 OpenShell 沙箱运行时

对于 ssh 和 OpenShell remote,重新创建比 Docker 更重要:

  • 初始播种后,远程工作区是规范来源
  • openclaw sandbox recreate 会删除所选范围的规范远程工作区
  • 下次使用时会从当前本地工作区再次播种

命令

openclaw sandbox explain

检查生效的沙箱模式/范围/工作区访问权限、沙箱工具策略,以及提权门禁(包含修复用配置键路径)。

openclaw sandbox explain
openclaw sandbox explain --session agent:main:main
openclaw sandbox explain --agent work
openclaw sandbox explain --json

openclaw sandbox list

列出所有沙箱运行时及其状态和配置。

openclaw sandbox list
openclaw sandbox list --browser  # List only browser containers
openclaw sandbox list --json     # JSON output

输出包括:

  • 运行时名称和状态
  • 后端(dockeropenshell 等)
  • 配置标签,以及它是否匹配当前配置
  • 存续时间(自创建以来的时间)
  • 空闲时间(自上次使用以来的时间)
  • 关联的会话/智能体

openclaw sandbox recreate

移除沙箱运行时,以强制使用更新后的配置重新创建。

openclaw sandbox recreate --all                # Recreate all containers
openclaw sandbox recreate --session main       # Specific session
openclaw sandbox recreate --agent mybot        # Specific agent
openclaw sandbox recreate --browser            # Only browser containers
openclaw sandbox recreate --all --force        # Skip confirmation

选项:

  • --all:重新创建所有沙箱容器
  • --session <key>:为特定会话重新创建容器
  • --agent <id>:为特定智能体重新创建容器
  • --browser:仅重新创建浏览器容器
  • --force:跳过确认提示

下次使用智能体时,运行时会自动重新创建。

使用场景

更新 Docker 镜像后

# Pull new image
docker pull openclaw-sandbox:latest
docker tag openclaw-sandbox:latest openclaw-sandbox:bookworm-slim

# Update config to use new image
# Edit config: agents.defaults.sandbox.docker.image (or agents.list[].sandbox.docker.image)

# Recreate containers
openclaw sandbox recreate --all

更改沙箱配置后

# Edit config: agents.defaults.sandbox.* (or agents.list[].sandbox.*)

# Recreate to apply new config
openclaw sandbox recreate --all

更改 SSH 目标或 SSH 认证材料后

# Edit config:
# - agents.defaults.sandbox.backend
# - agents.defaults.sandbox.ssh.target
# - agents.defaults.sandbox.ssh.workspaceRoot
# - agents.defaults.sandbox.ssh.identityFile / certificateFile / knownHostsFile
# - agents.defaults.sandbox.ssh.identityData / certificateData / knownHostsData

openclaw sandbox recreate --all

对于核心 ssh 后端,重新创建会删除 SSH 目标上对应范围的远程工作区根目录。下一次运行会从本地工作区再次播种。

更改 OpenShell 来源、策略或模式后

# Edit config:
# - agents.defaults.sandbox.backend
# - plugins.entries.openshell.config.from
# - plugins.entries.openshell.config.mode
# - plugins.entries.openshell.config.policy

openclaw sandbox recreate --all

对于 OpenShell remote 模式,重新创建会删除该范围的规范远程工作区。下一次运行会从本地工作区再次播种。

更改 setupCommand 后

openclaw sandbox recreate --all
# or just one agent:
openclaw sandbox recreate --agent family

仅针对特定智能体

# Update only one agent's containers
openclaw sandbox recreate --agent alfred

为什么需要这样做

当你更新沙箱配置时:

  • 现有运行时会继续使用旧设置运行。
  • 运行时只有在空闲 24 小时后才会被清理。
  • 经常使用的智能体会让旧运行时无限期保持存活。

使用 openclaw sandbox recreate 强制移除旧运行时。下次需要时,它们会使用当前设置自动重新创建。

优先使用 openclaw sandbox recreate,而不是手动执行后端特定的清理。它会使用 Gateway 网关的运行时注册表,并避免范围或会话键发生变化时出现不匹配。

注册表迁移

OpenClaw 会将沙箱运行时元数据存储为沙箱状态目录下每个容器/浏览器条目对应的一个 JSON 分片。较旧的安装可能仍有单体旧版文件:

  • ~/.openclaw/sandbox/containers.json
  • ~/.openclaw/sandbox/browsers.json

常规沙箱运行时读取不会重写这些文件。运行 openclaw doctor --fix 可将有效的旧版条目迁移到分片注册表目录中。无效的旧版文件会被隔离,避免一个损坏的旧注册表隐藏当前运行时条目。

配置

沙箱设置位于 ~/.openclaw/openclaw.jsonagents.defaults.sandbox 下(按智能体覆盖项放在 agents.list[].sandbox 中):

{
  "agents": {
    "defaults": {
      "sandbox": {
        "mode": "all", // off, non-main, all
        "backend": "docker", // docker, ssh, openshell
        "scope": "agent", // session, agent, shared
        "docker": {
          "image": "openclaw-sandbox:bookworm-slim",
          "containerPrefix": "openclaw-sbx-",
          // ... more Docker options
        },
        "prune": {
          "idleHours": 24, // Auto-prune after 24h idle
          "maxAgeDays": 7, // Auto-prune after 7 days
        },
      },
    },
  },
}

相关


📄 安全

原文:https://docs.openclaw.ai/zh-CN/cli/security

openclaw security

安全工具(审计 + 可选修复)。

相关内容:

审计

openclaw security audit
openclaw security audit --deep
openclaw security audit --deep --password <password>
openclaw security audit --deep --token <token>
openclaw security audit --fix
openclaw security audit --json

普通的 security audit 会停留在冷配置/文件系统/只读路径。它默认不会发现插件运行时安全收集器,因此常规审计不会加载每个已安装的插件运行时。使用 --deep 可包含尽力而为的实时 Gateway 网关探测和插件拥有的安全审计收集器;显式内部调用方在已有适当运行时作用域时,也可以选择启用这些插件拥有的收集器。

当多个私信发送者共享主会话时,审计会发出警告,并建议使用安全私信模式session.dmScope="per-channel-peer"(对于多账号渠道,则使用 per-account-channel-peer)来处理共享收件箱。
这是用于协作式/共享收件箱加固。不建议让互不信任/对抗性的操作员共享同一个 Gateway 网关;请用独立 Gateway 网关(或独立 OS 用户/主机)拆分信任边界。
当配置暗示可能存在共享用户入口时(例如开放私信/群组策略、已配置群组目标或通配符发送者规则),它还会发出 security.trust_model.multi_user_heuristic,并提醒你 OpenClaw 默认采用个人助理信任模型。
对于有意的共享用户设置,审计建议是对所有会话启用沙箱隔离,将文件系统访问限制在工作区范围内,并让个人/私有身份或凭证远离该运行时。
当小模型(<=300B)在未启用沙箱隔离且启用了 Web/浏览器工具的情况下使用时,它也会发出警告。
对于 webhook 入口,当 hooks.token 复用 Gateway 网关令牌、hooks.token 过短、hooks.path="/"hooks.defaultSessionKey 未设置、hooks.allowedAgentIds 不受限制、启用了请求 sessionKey 覆盖,以及在未设置 hooks.allowedSessionKeyPrefixes 的情况下启用覆盖时,它会发出警告。
当配置了沙箱 Docker 设置但沙箱模式关闭时、gateway.nodes.denyCommands 使用无效的类模式/未知条目时(只按精确节点命令名匹配,不进行 shell 文本过滤)、gateway.nodes.allowCommands 显式启用危险节点命令时、全局 tools.profile="minimal" 被智能体工具配置文件覆盖时、写入/编辑工具被禁用但 exec 仍可用且没有受约束的沙箱文件系统边界时、开放群组在没有沙箱/工作区保护的情况下暴露运行时/文件系统工具时,以及已安装的插件工具可能在宽松工具策略下可达时,它也会发出警告。
它还会标记 gateway.allowRealIpFallback=true(代理配置错误时存在标头伪造风险)和 discovery.mdns.mode="full"(通过 mDNS TXT 记录泄露元数据)。
当沙箱浏览器使用 Docker bridge 网络且未设置 sandbox.browser.cdpSourceRange 时,它也会发出警告。
它还会标记危险的沙箱 Docker 网络模式(包括 hostcontainer:* 命名空间加入)。
当现有沙箱浏览器 Docker 容器缺少/存在过期哈希标签时(例如迁移前容器缺少 openclaw.browserConfigEpoch),它也会发出警告,并建议运行 openclaw sandbox recreate --browser --all
当基于 npm 的插件/钩子安装记录未固定版本、缺少完整性元数据,或与当前已安装的软件包版本发生漂移时,它也会发出警告。
当渠道 allowlist 依赖可变名称/邮箱/标签而不是稳定 ID 时,它会发出警告(Discord、Slack、Google Chat、Microsoft Teams、Mattermost、IRC 作用域,在适用时)。
gateway.auth.mode="none" 让 Gateway 网关 HTTP API 在没有共享密钥的情况下可访问时,它会发出警告(/tools/invoke 以及任何已启用的 /v1/* 端点)。
dangerous/dangerously 为前缀的设置是显式的紧急操作员覆盖;启用其中一个设置本身并不构成安全漏洞报告。
如需完整的危险参数清单,请参阅 安全 中的“Insecure or dangerous flags summary”部分。

SecretRef 行为:

  • security audit 会以只读模式解析其目标路径中受支持的 SecretRef。
  • 如果当前命令路径中无法使用某个 SecretRef,审计会继续并报告 secretDiagnostics(而不是崩溃)。
  • --token--password 只会覆盖该命令调用的深度探测认证;它们不会重写配置或 SecretRef 映射。

JSON 输出

使用 --json 进行 CI/策略检查:

openclaw security audit --json | jq '.summary'
openclaw security audit --deep --json | jq '.findings[] | select(.severity=="critical") | .checkId'

如果同时使用 --fix--json,输出会同时包含修复操作和最终报告:

openclaw security audit --fix --json | jq '{fix: .fix.ok, summary: .report.summary}'

--fix 会更改什么

--fix 会应用安全、确定性的修复:

  • 将常见的 groupPolicy="open" 切换为 groupPolicy="allowlist"(包括受支持渠道中的账号变体)
  • 当 WhatsApp 群组策略切换为 allowlist 时,如果已存储的 allowFrom 文件中存在该列表且配置尚未
    定义 allowFrom,则从该文件中填充 groupAllowFrom
  • logging.redactSensitive"off" 设置为 "tools"
  • 收紧状态/配置和常见敏感文件的权限
    credentials/*.jsonauth-profiles.jsonsessions.json、会话
    *.jsonl
  • 同时收紧从 openclaw.json 引用的配置 include 文件
  • 在 POSIX 主机上使用 chmod,在 Windows 上使用 icacls 重置

--fix 不会

  • 轮换令牌/密码/API 密钥
  • 禁用工具(gatewaycronexec 等)
  • 更改 Gateway 网关绑定/认证/网络暴露选择
  • 移除或重写插件/Skills

相关内容


📄 会话

原文:https://docs.openclaw.ai/zh-CN/cli/sessions

openclaw sessions

列出已存储的对话会话。

会话列表不是渠道/提供商存活检查。它们显示来自会话存储的持久化对话行。安静的 Discord、Slack、Telegram 或其他渠道可以成功重新连接,但在处理消息之前不会创建新的会话行。当你需要实时渠道连接性时,请使用 openclaw channels status --probeopenclaw status --deepopenclaw health --verbose

openclaw sessions 和 Gateway 网关 sessions.list 响应默认有边界限制,因此大型长期存储无法独占 CLI 进程或 Gateway 网关事件循环。CLI 默认返回最新的 100 个会话;传递 --limit <n> 获取更小/更大的窗口,或者在你明确需要完整存储时传递 --limit all。当调用方需要显示存在更多行时,JSON 响应会包含 totalCountlimitAppliedhasMore

RPC 客户端可以传递 configuredAgentsOnly: true,以保留宽泛的组合发现源,但只返回当前存在于配置中的智能体对应的行。控制 UI 默认使用该模式,因此已删除或仅存在于磁盘上的智能体存储不会重新出现在会话视图中。

openclaw sessions
openclaw sessions --agent work
openclaw sessions --all-agents
openclaw sessions --active 120
openclaw sessions --limit 25
openclaw sessions --verbose
openclaw sessions --json

范围选择:

  • 默认:已配置的默认智能体存储
  • --verbose:详细日志
  • --agent <id>:一个已配置的智能体存储
  • --all-agents:聚合所有已配置的智能体存储
  • --store <path>:显式存储路径(不能与 --agent--all-agents 组合使用)
  • --limit <n|all>:要输出的最大行数(默认 100all 恢复完整输出)

为已存储的会话导出轨迹包:

openclaw sessions export-trajectory --session-key "agent:main:telegram:direct:123" --workspace .
openclaw sessions export-trajectory --session-key "agent:main:telegram:direct:123" --output bug-123 --json

这是所有者批准 exec 请求后,/export-trajectory 斜杠命令使用的命令路径。输出目录始终解析到所选工作区下的 .openclaw/trajectory-exports/ 内。

openclaw sessions --all-agents 读取已配置的智能体存储。Gateway 网关和 ACP 会话发现更宽泛:它们还会包含在默认 agents/ 根目录或模板化 session.store 根目录下找到的仅磁盘存储。这些被发现的存储必须解析为智能体根目录内的常规 sessions.json 文件;符号链接和根目录外路径会被跳过。

JSON 示例:

openclaw sessions --all-agents --json

{
  "path": null,
  "stores": [
    { "agentId": "main", "path": "/home/user/.openclaw/agents/main/sessions/sessions.json" },
    { "agentId": "work", "path": "/home/user/.openclaw/agents/work/sessions/sessions.json" }
  ],
  "allAgents": true,
  "count": 2,
  "totalCount": 2,
  "limitApplied": 100,
  "hasMore": false,
  "activeMinutes": null,
  "sessions": [
    { "agentId": "main", "key": "agent:main:main", "model": "gpt-5" },
    { "agentId": "work", "key": "agent:work:main", "model": "claude-opus-4-6" }
  ]
}

清理维护

立即运行维护(而不是等待下一个写入周期):

openclaw sessions cleanup --dry-run
openclaw sessions cleanup --agent work --dry-run
openclaw sessions cleanup --all-agents --dry-run
openclaw sessions cleanup --enforce
openclaw sessions cleanup --enforce --active-key "agent:main:telegram:direct:123"
openclaw sessions cleanup --dry-run --fix-dm-scope
openclaw sessions cleanup --json

openclaw sessions cleanup 使用配置中的 session.maintenance 设置:

  • 范围说明:openclaw sessions cleanup 维护会话存储、转录记录和轨迹 sidecar。它不会修剪 cron 运行日志(cron/runs/<jobId>.jsonl),这些日志由 Cron 配置 中的 cron.runLog.maxBytescron.runLog.keepLines 管理,并在 Cron 维护 中说明。
  • 清理还会修剪早于 session.maintenance.pruneAfter 的未引用主转录记录、压缩检查点和轨迹 sidecar;仍被 sessions.json 引用的文件会被保留。

  • --dry-run:预览在不写入的情况下会修剪/封顶多少条目。

  • 在文本模式下,dry-run 会打印每个会话的操作表(ActionKeyAgeModelFlags),以便你查看哪些会保留、哪些会移除。
  • --enforce:即使 session.maintenance.modewarn,也应用维护。
  • --fix-missing:移除转录记录文件缺失的条目,即使它们通常尚未因年龄/数量而被清出。
  • --fix-dm-scope:当 session.dmScopemain 时,停用早期 per-peerper-channel-peerper-account-channel-peer 路由遗留的过期对等方键控直接私信行。请先使用 --dry-run;应用清理会从 sessions.json 中移除这些行,并将其转录记录保留为已删除归档。
  • --active-key <key>:保护特定活动键不被磁盘预算驱逐。持久外部对话指针(例如群组会话和线程范围聊天会话)也会在基于年龄/数量/磁盘预算的维护中保留。
  • --agent <id>:为一个已配置的智能体存储运行清理。
  • --all-agents:为所有已配置的智能体存储运行清理。
  • --store <path>:针对特定 sessions.json 文件运行。
  • --json:打印 JSON 摘要。使用 --all-agents 时,输出会包含每个存储的一份摘要。

当 Gateway 网关可访问时,针对已配置智能体存储的非 dry-run 清理会通过 Gateway 网关发送,因此它与运行时流量共享同一个会话存储写入器。使用 --store <path> 对存储文件进行显式离线修复。

openclaw sessions cleanup --all-agents --dry-run --json

{
  "allAgents": true,
  "mode": "warn",
  "dryRun": true,
  "stores": [
    {
      "agentId": "main",
      "storePath": "/home/user/.openclaw/agents/main/sessions/sessions.json",
      "beforeCount": 120,
      "afterCount": 80,
      "missing": 0,
      "dmScopeRetired": 0,
      "pruned": 40,
      "capped": 0
    },
    {
      "agentId": "work",
      "storePath": "/home/user/.openclaw/agents/work/sessions/sessions.json",
      "beforeCount": 18,
      "afterCount": 18,
      "missing": 0,
      "dmScopeRetired": 0,
      "pruned": 0,
      "capped": 0
    }
  ]
}

相关:

相关


📄 设置

原文:https://docs.openclaw.ai/zh-CN/cli/setup

openclaw setup

初始化基线配置和 Agent 工作区。只要存在任何新手引导标志,也会运行向导。

openclaw setup 用于可变配置安装。在 Nix 模式(OPENCLAW_NIX_MODE=1)下,OpenClaw 会拒绝 setup 写入,因为配置文件由 Nix 管理。请使用第一方 nix-openclaw 快速开始,或为另一个 Nix 包使用等效的源配置。

选项

标志 描述
--workspace <dir> Agent 工作区目录(默认 ~/.openclaw/workspace;存储为 agents.defaults.workspace)。
--wizard 运行交互式新手引导。
--non-interactive 在没有提示的情况下运行新手引导。
--mode <mode> 新手引导模式:localremote
--import-from <provider> 新手引导期间要运行的迁移提供商。
--import-source <path> --import-from 的源 Agent 主目录。
--import-secrets 在新手引导迁移期间导入支持的密钥。
--remote-url <url> 远程 Gateway 网关 WebSocket URL。
--remote-token <token> 远程 Gateway 网关令牌(可选)。

向导自动触发

即使没有 --wizard,当显式提供以下任意标志时,openclaw setup 也会运行向导:

--wizard--non-interactive--mode--import-from--import-source--import-secrets--remote-url--remote-token

示例

openclaw setup
openclaw setup --workspace ~/.openclaw/workspace
openclaw setup --wizard
openclaw setup --wizard --import-from hermes --import-source ~/.hermes
openclaw setup --non-interactive --mode remote --remote-url wss://gateway-host:18789 --remote-token <token>

说明

  • 普通的 openclaw setup 会初始化配置和工作区,而不运行完整的新手引导流程。
  • 普通 setup 后,运行 openclaw onboard 开始完整的引导流程,运行 openclaw configure 进行定向更改,或运行 openclaw channels add 添加渠道账户。
  • 如果检测到 Hermes 状态,交互式新手引导可以自动提供迁移。导入式新手引导需要全新 setup;在新手引导之外,请使用 迁移 来进行试运行计划、备份和覆盖模式。

相关内容


📄 Skills

原文:https://docs.openclaw.ai/zh-CN/cli/skills

openclaw skills

检查本地 Skills,并从 ClawHub 安装/更新 Skills。

相关:

命令

openclaw skills search "calendar"
openclaw skills search --limit 20 --json
openclaw skills install <slug>
openclaw skills install <slug> --version <version>
openclaw skills install <slug> --force
openclaw skills install <slug> --agent <id>
openclaw skills update <slug>
openclaw skills update --all
openclaw skills update --all --agent <id>
openclaw skills list
openclaw skills list --eligible
openclaw skills list --json
openclaw skills list --verbose
openclaw skills list --agent <id>
openclaw skills info <name>
openclaw skills info <name> --json
openclaw skills info <name> --agent <id>
openclaw skills check
openclaw skills check --agent <id>
openclaw skills check --json

search/install/update 直接使用 ClawHub,并安装到当前
workspace 的 skills/ 目录。list/info/check 仍会检查当前
workspace 和配置可见的本地 Skills。基于 workspace 的命令会先从
--agent <id> 解析目标 workspace,然后在当前工作目录位于已配置的
agent workspace 内时使用当前工作目录,最后使用默认 agent。

这个 CLI install 命令会从 ClawHub 下载技能文件夹。从新手引导或
Skills 设置触发的、由 Gateway 网关支持的技能依赖安装改用单独的
skills.install 请求路径。

注意:

  • search [query...] 接受可选查询;省略它即可浏览默认的
    ClawHub 搜索动态。
  • search --limit <n> 会限制返回结果数量。
  • install --force 会覆盖同一 slug 已存在的 workspace 技能文件夹。
  • --agent <id> 以一个已配置的 agent workspace 为目标,并覆盖当前
    工作目录推断。
  • update --all 只更新当前 workspace 中已跟踪的 ClawHub 安装。
  • check --agent <id> 会检查所选 agent 的 workspace,并报告哪些
    已就绪的 Skills 实际可见于该 agent 的提示词或命令界面。
  • 未提供子命令时,list 是默认操作。
  • listinfocheck 会将其渲染后的输出写入 stdout。使用
    --json 时,这意味着机器可读的载荷会保留在 stdout,供管道和脚本使用。

相关


📄 openclaw status

原文:https://docs.openclaw.ai/zh-CN/cli/status

用于渠道 + 会话的诊断。

openclaw status
openclaw status --all
openclaw status --deep
openclaw status --usage

注意:

  • --deep 会运行实时探测(WhatsApp Web + Telegram + Discord + Slack + Signal)。
  • 普通的 openclaw status 会走快速只读路径;当它跳过记忆检查时,会将记忆标记为 not checked,而不是不可用。繁重的安全审计、插件兼容性和记忆向量探测会留给 openclaw status --allopenclaw status --deepopenclaw security auditopenclaw memory status --deep
  • status --json --all 会报告由 plugins.slots.memory 选择的主动记忆插件运行时提供的记忆详情。自定义记忆插件可以让内置的 agents.defaults.memorySearch.enabled 保持禁用,同时仍报告自己的文件、分块、向量和 FTS 状态。
  • --usage 会以 X% left 形式打印规范化的提供商使用窗口。
  • 会话状态输出会分开显示 Execution:Runtime:Execution 是沙箱路径(directdocker/*),而 Runtime 会告诉你该会话使用的是 OpenClaw Pi DefaultOpenAI Codex、CLI 后端,还是像 codex (acp/acpx) 这样的 ACP 后端。有关提供商/模型/运行时的区别,请参阅 Agent Runtimes
  • MiniMax 的原始 usage_percent / usagePercent 字段表示剩余额度,因此 OpenClaw 会在显示前将其反转;如果存在基于计数的字段,则优先使用这些字段。model_remains 响应优先使用聊天模型条目,在需要时从时间戳推导窗口标签,并在计划标签中包含模型名称。
  • 当当前会话快照较稀疏时,/status 可以从最近的 transcript 使用日志回填 token 和缓存计数。现有的非零实时值仍优先于 transcript 回退值。
  • /status 包含紧凑的 Gateway 网关进程运行时间和主机系统运行时间。
  • 当实时会话条目缺少活动运行时模型标签时,transcript 回退也可以恢复该标签。如果该 transcript 模型不同于所选模型,status 会基于恢复出的运行时模型而不是所选模型来解析上下文窗口。
  • 对于提示大小核算,当会话元数据缺失或较小时,transcript 回退会优先使用更大的面向提示的总量,因此自定义提供商会话不会退化为显示 0 token。
  • 当配置了多个智能体时,输出会包含每个智能体的会话存储。
  • 当可用时,概览会包含 Gateway 网关 + 节点主机服务的安装/运行时状态。
  • 概览会包含更新频道 + git SHA(用于源码检出)。
  • 更新信息会显示在概览中;如果有可用更新,status 会打印提示以运行 openclaw update(参见更新)。
  • 模型价格刷新失败会显示为可选的价格警告。它们并不意味着 Gateway 网关或渠道不健康。
  • 只读 status 界面(statusstatus --jsonstatus --all)会尽可能解析其目标配置路径支持的 SecretRefs。
  • 如果配置了受支持渠道的 SecretRef,但它在当前命令路径中不可用,status 会保持只读并报告降级输出,而不是崩溃。人工可读输出会显示类似 “configured token unavailable in this command path” 的警告,JSON 输出会包含 secretDiagnostics
  • 当命令本地 SecretRef 解析成功时,status 会优先使用已解析的快照,并从最终输出中清除临时的 “secret unavailable” 渠道标记。
  • status --all 包含一行 Secrets 概览,以及一个诊断章节,用于汇总密钥诊断(为可读性会截断),且不会停止报告生成。

相关内容


📄 系统

原文:https://docs.openclaw.ai/zh-CN/cli/system

openclaw system

用于 Gateway 网关的系统级辅助工具:将系统事件加入队列、控制 Heartbeat,并查看在线状态。

所有 system 子命令都使用 Gateway 网关 RPC,并接受共享客户端标志:

  • --url <url>
  • --token <token>
  • --timeout <ms>
  • --expect-final

常用命令

openclaw system event --text "Check for urgent follow-ups" --mode now
openclaw system event --text "Check for urgent follow-ups" --url ws://127.0.0.1:18789 --token "$OPENCLAW_GATEWAY_TOKEN"
openclaw system heartbeat enable
openclaw system heartbeat last
openclaw system presence

system event

默认在 会话上将系统事件加入队列。下一次 Heartbeat 会将其作为提示词中的 System: 行注入。使用 --mode now 可立即触发 Heartbeat;next-heartbeat 会等待下一次计划的 tick。

传入 --session-key 可定向到特定会话(例如,将异步任务完成事件转发回启动它的渠道)。

使用 --session-key 时的时序例外: 提供 --session-key 时,
--mode next-heartbeat 会折叠为一次立即的定向唤醒,而不是等待下一次计划的 tick。
定向唤醒使用 Heartbeat 意图 immediate,因此会绕过运行器的未到期门控;否则该门控会延迟
(并实际丢弃)一个 event 意图的唤醒。如果你想要延迟投递,请省略 --session-key
这样事件会落在主会话上,并随下一次常规 Heartbeat 发送。

标志:

  • --text <text>:必需的系统事件文本。
  • --mode <mode>nownext-heartbeat(默认)。
  • --session-key <sessionKey>:可选;定向到特定智能体会话,而不是智能体的主会话。不属于已解析智能体的键会回退到智能体的主会话。
  • --json:机器可读输出。
  • --url--token--timeout--expect-final:共享的 Gateway 网关 RPC 标志。

system heartbeat last|enable|disable

Heartbeat 控制:

  • last:显示上一次 Heartbeat 事件。
  • enable:重新开启 Heartbeat(如果它们被禁用,请使用此项)。
  • disable:暂停 Heartbeat。

标志:

  • --json:机器可读输出。
  • --url--token--timeout--expect-final:共享的 Gateway 网关 RPC 标志。

system presence

列出 Gateway 网关当前已知的系统在线状态条目(节点、实例和类似的状态行)。

标志:

  • --json:机器可读输出。
  • --url--token--timeout--expect-final:共享的 Gateway 网关 RPC 标志。

备注

  • 需要一个正在运行且可通过你的当前配置访问的 Gateway 网关(本地或远程)。
  • 系统事件是临时性的,不会在重启后持久保留。

相关


📄 文本用户界面

原文:https://docs.openclaw.ai/zh-CN/cli/tui

openclaw tui

打开连接到 Gateway 网关的终端 UI,或在本地嵌入模式下运行它。

相关:

  • TUI 指南:TUI

选项

标志 默认值 描述
--local false 使用本地嵌入式智能体运行时,而不是 Gateway 网关。
--url <url> 来自配置的 gateway.remote.url Gateway 网关 WebSocket URL。
--token <token> (无) 如有要求,提供 Gateway 网关令牌。
--password <pass> (无) 如有要求,提供 Gateway 网关密码。
--session <key> main(或作用域为全局时的 global 会话键。在智能体工作区内,除非带前缀,否则会自动选择该智能体。
--deliver false 通过已配置的渠道递送助手回复。
--thinking <level> (模型默认值) 思考级别覆盖值。
--message <text> (无) 连接后发送初始消息。
--timeout-ms <ms> agents.defaults.timeoutSeconds 智能体超时。无效值会记录警告并被忽略。
--history-limit <n> 200 附加时加载的历史条目数。

别名:openclaw chatopenclaw terminal 会调用同一命令,并隐含 --local

注意:

  • chatterminalopenclaw tui --local 的别名。
  • --local 不能与 --url--token--password 组合使用。
  • 在可行时,tui 会解析已配置的 Gateway 网关认证 SecretRefs,用于令牌/密码认证(env/file/exec 提供商)。
  • 从已配置的智能体工作区目录内启动时,TUI 会自动选择该智能体作为会话键默认值(除非 --session 显式为 agent:<id>:...)。
  • 本地模式会直接使用嵌入式智能体运行时。大多数本地工具可以工作,但仅 Gateway 网关支持的功能不可用。
  • 本地模式会在 TUI 命令界面内添加 /auth [provider]
  • 插件审批门禁在本地模式下仍然适用。需要审批的工具会在终端中提示做出决定;不会因为未涉及 Gateway 网关就静默自动批准任何内容。

示例

openclaw chat
openclaw tui --local
openclaw tui
openclaw tui --url ws://127.0.0.1:18789 --token <token>
openclaw tui --session main --deliver
openclaw chat --message "Compare my config to the docs and tell me what to fix"
# when run inside an agent workspace, infers that agent automatically
openclaw tui --session bugfix

配置修复循环

当当前配置已经验证通过,并且你希望嵌入式智能体检查它、将它与文档对比,并从同一个终端帮助修复它时,请使用本地模式:

如果 openclaw config validate 已经失败,请先使用 openclaw configureopenclaw doctor --fixopenclaw chat 不会绕过无效配置防护。

openclaw chat

然后在 TUI 内:

!openclaw config file
!openclaw docs gateway auth token secretref
!openclaw config validate
!openclaw doctor

使用 openclaw config setopenclaw configure 应用有针对性的修复,然后重新运行 openclaw config validate。请参阅 TUI配置

相关


📄 卸载

原文:https://docs.openclaw.ai/zh-CN/cli/uninstall

openclaw uninstall

卸载 Gateway 网关服务和本地数据(CLI 会保留)。

选项:

  • --service:移除 Gateway 网关服务
  • --state:移除状态和配置
  • --workspace:移除工作区目录
  • --app:移除 macOS 应用
  • --all:移除服务、状态、工作区和应用
  • --yes:跳过确认提示
  • --non-interactive:禁用提示;需要配合 --yes
  • --dry-run:打印将执行的操作而不删除文件

示例:

openclaw backup create
openclaw uninstall
openclaw uninstall --service --yes --non-interactive
openclaw uninstall --state --workspace --yes --non-interactive
openclaw uninstall --all --yes
openclaw uninstall --dry-run

说明:

  • 如果你想在移除状态或工作区之前保留一个可恢复的快照,请先运行 openclaw backup create
  • --all 是同时移除服务、状态、工作区和应用的简写。
  • --non-interactive 需要配合 --yes

相关内容


📄 更新

原文:https://docs.openclaw.ai/zh-CN/cli/update

openclaw update

安全更新 OpenClaw,并在 stable/beta/dev 渠道之间切换。

如果你通过 npm/pnpm/bun 安装(全局安装,没有 git 元数据),
更新会通过 更新 中的包管理器流程进行。

用法

openclaw update
openclaw update status
openclaw update wizard
openclaw update --channel beta
openclaw update --channel dev
openclaw update --tag beta
openclaw update --tag main
openclaw update --dry-run
openclaw update --no-restart
openclaw update --yes
openclaw update --json
openclaw --update

选项

  • --no-restart:成功更新后跳过重启 Gateway 网关服务。会重启 Gateway 网关的包管理器更新,会在命令成功前验证重启后的服务报告预期的已更新版本。
  • --channel <stable|beta|dev>:设置更新渠道(git + npm;持久化到配置中)。
  • --tag <dist-tag|version|spec>:仅为本次更新覆盖包目标。对于包安装,main 映射到 github:openclaw/openclaw#main
  • --dry-run:预览计划的更新操作(渠道/标签/目标/重启流程),但不写入配置、不安装、不同步插件,也不重启。
  • --json:打印机器可读的 UpdateRunResult JSON,包括
    核心更新成功后损坏或无法卸载的托管插件需要
    修复时的 postUpdate.plugins.warnings,插件没有 beta 版本时的 beta 渠道插件回退详情,
    以及在更新后插件同步期间检测到 npm 插件制品漂移时的 postUpdate.plugins.integrityDrifts
  • --timeout <seconds>:每个步骤的超时时间(默认是 1800 秒)。
  • --yes:跳过确认提示(例如降级确认)。

openclaw update 没有 --verbose 标志。使用 --dry-run 预览
计划的渠道/标签/安装/重启操作,使用 --json 获取机器可读
结果;如果你只需要渠道和可用性详情,使用 openclaw update status --json
如果你在调试更新期间的 Gateway 网关日志,
控制台详细程度和文件日志级别是分开的:Gateway 网关的 --verbose 会影响
终端/WebSocket 输出,而文件日志需要在配置中设置 logging.level: "debug"
"trace"。参见 Gateway 网关日志

在 Nix 模式(OPENCLAW_NIX_MODE=1)下,禁用会修改状态的 openclaw update 运行。请改为更新此安装的 Nix 源或 flake 输入;对于 nix-openclaw,请使用 agent-first 快速开始openclaw update statusopenclaw update --dry-run 仍保持只读。

降级需要确认,因为较旧版本可能会破坏配置。

update status

显示活动更新渠道 + git 标签/分支/SHA(针对源码检出),以及更新可用性。

openclaw update status
openclaw update status --json
openclaw update status --timeout 10

选项:

  • --json:打印机器可读的状态 JSON。
  • --timeout <seconds>:检查超时时间(默认是 3 秒)。

update wizard

交互式流程,用于选择更新渠道,并确认更新后是否重启 Gateway 网关
(默认会重启)。如果你在没有 git 检出的情况下选择 dev
它会提示创建一个。

选项:

  • --timeout <seconds>:每个更新步骤的超时时间(默认 1800

它会做什么

当你显式切换渠道(--channel ...)时,OpenClaw 也会保持
安装方式一致:

  • dev → 确保存在 git 检出(默认:~/openclaw,可用 OPENCLAW_GIT_DIR 覆盖),
    更新该检出,并从该检出安装全局 CLI。
  • stable → 使用 latest 从 npm 安装。
  • beta → 优先使用 npm dist-tag beta,但当 beta 缺失或
    早于当前 stable 版本时,回退到 latest

Gateway 网关核心自动更新器(通过配置启用时)会在实时 Gateway 网关请求处理程序
之外启动 CLI 更新路径。控制平面的 update.run 包管理器
更新会在包替换后强制执行非延迟、无冷却的更新重启,
因为旧 Gateway 网关进程可能仍有指向
新包已移除文件的内存中分块。

对于包管理器安装,openclaw update 会在调用包管理器前解析目标包
版本。npm 全局安装使用分阶段
安装:OpenClaw 将新包安装到临时 npm 前缀中,在那里验证
打包的 dist 清单,然后将该干净的包树替换到
真正的全局前缀中。如果验证失败,更新后 doctor、插件同步和
重启工作不会从可疑树中运行。即使已安装版本
已经匹配目标,命令也会刷新全局包安装,
然后运行插件同步、核心命令补全刷新和重启工作。这会
让打包的 sidecar 和渠道拥有的插件记录与
已安装的 OpenClaw 构建保持一致,同时将完整的插件命令补全重建留给
显式的 openclaw completion --write-state 运行。

当已安装本地托管的 Gateway 网关服务且启用重启时,
包管理器更新会先停止正在运行的服务,再替换包
树,然后从更新后的安装刷新服务元数据,重启
服务,并在报告成功前验证重启后的 Gateway 网关报告预期版本。
在 macOS 上,更新后检查还会验证 LaunchAgent
已为活动配置文件加载/运行,并且配置的 loopback 端口
健康。如果 plist 已安装但 launchd 没有监管它,OpenClaw
会自动重新引导 LaunchAgent,然后重新运行
健康/版本/渠道就绪检查。全新引导会直接加载 RunAtLoad
作业,因此更新恢复不会立即对新生成的 Gateway 网关执行 kickstart -k
如果 Gateway 网关仍未变为健康状态,命令会以非零状态退出,并打印
重启日志路径,以及明确的重启、重新安装和
包回滚说明。使用 --no-restart 时,
包替换仍会运行,但托管服务不会被停止或
重启,因此正在运行的 Gateway 网关可能会继续使用旧代码,直到你手动重启它。

Git 检出流程

渠道选择

  • stable:检出最新的非 beta 标签,然后构建并运行 doctor。
  • beta:优先使用最新的 -beta 标签,但当 beta 缺失或更旧时,回退到最新 stable 标签。
  • dev:检出 main,然后 fetch 并 rebase。

更新步骤

要求没有未提交的更改。

切换到所选渠道(标签或分支)。

仅限 dev。

在临时工作树中运行 TypeScript 构建。如果顶端提交失败,会向前回退最多 10 个提交,以找到最新的可构建提交。设置 OPENCLAW_UPDATE_PREFLIGHT_LINT=1 还会在此预检期间运行 lint;lint 会以受限串行模式运行,因为用户更新主机通常小于 CI runner。

Rebase 到所选提交(仅限 dev)。

使用仓库包管理器。对于 pnpm 检出,更新器会按需引导 pnpm(先通过 corepack,然后使用临时 npm install pnpm@11 回退),而不是在 pnpm 工作区内运行 npm run build

构建 Gateway 网关和 Control UI。

openclaw doctor 会作为最终的安全更新检查运行。

将插件同步到活动渠道。dev 使用内置插件;stable 和 beta 使用 npm。更新已跟踪的插件安装。

在 beta 更新渠道上,遵循默认/latest 线的已跟踪 npm 和 ClawHub 插件安装
会先尝试插件 @beta 版本。如果插件没有
beta 版本,OpenClaw 会回退到记录的默认/latest spec,并将其报告
为警告。对于 npm 插件,当 beta
包存在但安装验证失败时,OpenClaw 也会回退。这些插件回退警告不会
导致核心更新失败。精确版本和显式标签不会
被重写。

如果一个精确固定的 npm 插件更新解析到的制品完整性与存储的安装记录不同,openclaw update 会中止该插件制品更新,而不是安装它。只有在验证你信任新制品后,才显式重新安装或更新该插件。

如果更新后插件同步失败仅限于某个托管插件,并且同步路径可以绕过该失败(例如非必要插件的 npm 注册表不可达),则在核心更新成功后将其报告为警告。JSON 结果会保持顶层更新 status: "ok",并报告 postUpdate.plugins.status: "warning",同时提供 openclaw doctor --fixopenclaw plugins inspect <id> --runtime --json 指引。意外的更新器或同步异常仍会导致更新结果失败。修复插件安装或更新错误后,重新运行 openclaw doctor --fixopenclaw update

在每个插件同步步骤之后,openclaw update 会在 Gateway 网关重启之前运行强制性的核心后收敛步骤:它会修复缺失的已配置插件载荷,验证磁盘上每条_活动_已跟踪安装记录,并静态验证其 package.json 可解析(以及任何显式声明的 main 存在)。此步骤的失败,以及无效的 OpenClaw 配置快照,会返回 postUpdate.plugins.status: "error",并将顶层更新 status 翻转为 "error",因此 openclaw update 会以非零状态退出,并且 Gateway 网关_不会_在插件集未验证的情况下重启。错误包含结构化的 postUpdate.plugins.warnings[].guidance 行,指向 openclaw doctor --fixopenclaw plugins inspect <id> --runtime --json 以供后续处理。已禁用的插件条目,以及未链接到受信源官方同步目标的记录会在此跳过,与缺失载荷检查使用的 skipDisabledPlugins 策略一致,因此过期的已禁用插件记录不会阻止其他有效更新。

当更新后的 Gateway 网关启动时,插件加载仅用于验证:启动不会运行包管理器或修改依赖树。包管理器 update.run 重启会在包树替换后绕过正常的空闲延迟和重启冷却,因此旧进程无法继续惰性加载已移除的分块。

如果 pnpm 引导仍然失败,更新器会提前停止并给出包管理器特定错误,而不是尝试在检出内运行 npm run build

--update 简写

openclaw --update 会重写为 openclaw update(对 shell 和启动器脚本很有用)。

相关


📄 语音通话

原文:https://docs.openclaw.ai/zh-CN/cli/voicecall

openclaw voicecall

voicecall 是由插件提供的命令。它仅在 voice-call 插件已安装并启用时出现。

当 Gateway 网关正在运行时,操作命令(callstartcontinuespeakdtmfendstatus)会路由到该 Gateway 网关的 voice-call 运行时。如果无法连接到 Gateway 网关,它们会回退到独立 CLI 运行时。

子命令

openclaw voicecall setup    [--json]
openclaw voicecall smoke    [-t <phone>] [--message <text>] [--mode <m>] [--yes] [--json]
openclaw voicecall call     -m <text> [-t <phone>] [--mode <m>]
openclaw voicecall start    --to <phone> [--message <text>] [--mode <m>]
openclaw voicecall continue --call-id <id> --message <text>
openclaw voicecall speak    --call-id <id> --message <text>
openclaw voicecall dtmf     --call-id <id> --digits <digits>
openclaw voicecall end      --call-id <id>
openclaw voicecall status   [--call-id <id>] [--json]
openclaw voicecall tail     [--file <path>] [--since <n>] [--poll <ms>]
openclaw voicecall latency  [--file <path>] [--last <n>]
openclaw voicecall expose   [--mode <m>] [--path <p>] [--port <port>] [--serve-path <p>]
子命令 描述
setup 显示提供商和 webhook 就绪检查。
smoke 运行就绪检查;仅在带有 --yes 时发起实时测试呼叫。
call 发起外呼语音通话。
start call 的别名,要求使用 --to--message 可选。
continue 播放一条消息并等待下一条响应。
speak 播放一条消息,不等待响应。
dtmf 向活动通话发送 DTMF 数字。
end 挂断活动通话。
status 检查活动通话(或通过 --call-id 检查某一个)。
tail 跟踪 calls.jsonl(在提供商测试期间很有用)。
latency 汇总 calls.jsonl 中的轮次延迟指标。
expose 为 webhook 端点切换 Tailscale serve/funnel。

设置和冒烟测试

setup

默认打印人类可读的就绪检查。为脚本传入 --json

openclaw voicecall setup
openclaw voicecall setup --json

smoke

运行相同的就绪检查。除非同时存在 --to--yes,否则不会拨打真实电话。

标志 默认值 描述
-t, --to <phone> (无) 用于实时冒烟测试呼叫的电话号码。
--message <text> OpenClaw voice call smoke test. 冒烟测试通话期间要播放的消息。
--mode <mode> notify 通话模式:notifyconversation
--yes false 实际发起实时外呼。
--json false 打印机器可读的 JSON。
openclaw voicecall smoke
openclaw voicecall smoke --to "+15555550123"        # dry run
openclaw voicecall smoke --to "+15555550123" --yes  # live notify call

对于外部提供商(twiliotelnyxplivo),setupsmoke 需要来自 publicUrl、隧道或 Tailscale 暴露的公共 webhook URL。环回或私有 serve 回退会被拒绝,因为运营商无法访问它。

通话生命周期

call

发起外呼语音通话。

标志 必需 默认值 描述
-m, --message <text> (无) 通话接通时要播放的消息。
-t, --to <phone> 配置 toNumber 要呼叫的 E.164 电话号码。
--mode <mode> conversation 通话模式:notify(播放消息后挂断)或 conversation(保持通话)。
openclaw voicecall call --to "+15555550123" --message "Hello"
openclaw voicecall call -m "Heads up" --mode notify

start

call 的别名,默认标志形式不同。

标志 必需 默认值 描述
--to <phone> (无) 要呼叫的电话号码。
--message <text> (无) 通话接通时要播放的消息。
--mode <mode> conversation 通话模式:notifyconversation

continue

播放一条消息并等待响应。

标志 必需 描述
--call-id <id> 通话 ID。
--message <text> 要播放的消息。

speak

播放一条消息,不等待响应。

标志 必需 描述
--call-id <id> 通话 ID。
--message <text> 要播放的消息。

dtmf

向活动通话发送 DTMF 数字。

标志 必需 描述
--call-id <id> 通话 ID。
--digits <digits> DTMF 数字(例如,用于等待的 ww123456#)。

end

挂断活动通话。

标志 必需 描述
--call-id <id> 通话 ID。

status

检查活动通话。

标志 默认值 描述
--call-id <id> (无) 将输出限制为一个通话。
--json false 打印机器可读的 JSON。
openclaw voicecall status
openclaw voicecall status --json
openclaw voicecall status --call-id <id>

日志和指标

tail

跟踪语音通话 JSONL 日志。启动时打印最后 --since 行,然后在写入新行时流式输出它们。

标志 默认值 描述
--file <path> 从插件存储解析 calls.jsonl 的路径。
--since <n> 25 跟踪前要打印的行数。
--poll <ms> 250(最小值 50) 轮询间隔,单位为毫秒。

latency

汇总 calls.jsonl 中的轮次延迟和监听等待指标。输出为 JSON,包含 recordsScannedturnLatencylistenWait 摘要。

标志 默认值 描述
--file <path> 从插件存储解析 calls.jsonl 的路径。
--last <n> 200(最小值 1) 要分析的最近记录数。

暴露 Webhook

expose

启用、禁用或更改语音 webhook 的 Tailscale serve/funnel 配置。

标志 默认值 描述
--mode <mode> funnel offserve(tailnet)或 funnel(公共)。
--path <path> 配置 tailscale.path--serve-path 要暴露的 Tailscale 路径。
--port <port> 配置 serve.port3334 本地 webhook 端口。
--serve-path <path> 配置 serve.path/voice/webhook 本地 webhook 路径。
openclaw voicecall expose --mode serve
openclaw voicecall expose --mode funnel
openclaw voicecall expose --mode off

仅将 webhook 端点暴露给你信任的网络。尽可能优先使用 Tailscale Serve,而不是 Funnel。

相关内容


📄 网络钩子

原文:https://docs.openclaw.ai/zh-CN/cli/webhooks

openclaw webhooks

网络钩子辅助工具和集成。目前,此接口范围限定为与内置 gog 监视器集成的 Gmail Pub/Sub 流程。

子命令

openclaw webhooks gmail setup --account <email> [...]
openclaw webhooks gmail run   [--account <email>] [...]
子命令 描述
gmail setup 配置 Gmail 监视、Pub/Sub 主题/订阅,以及 OpenClaw 网络钩子投递目标。
gmail run 运行 gog watch serve 以及监视自动续订循环。

webhooks gmail setup

配置 Gmail 监视、Pub/Sub 和 OpenClaw 网络钩子投递。

openclaw webhooks gmail setup --account you@example.com
openclaw webhooks gmail setup --account you@example.com --project my-gcp-project --json
openclaw webhooks gmail setup --account you@example.com --hook-url https://gateway.example.com/hooks/gmail

必需

标志 描述
--account <email> 要监视的 Gmail 账号。

Pub/Sub 选项

标志 默认值 描述
--project <id> (无) GCP 项目 ID(OAuth 客户端所有者)。
--topic <name> gog-gmail-watch Pub/Sub 主题名称。
--subscription <name> gog-gmail-watch-push Pub/Sub 订阅名称。
--label <label> INBOX 要监视的 Gmail 标签。
--push-endpoint <url> (无) 显式 Pub/Sub 推送端点。会覆盖 Tailscale。

OpenClaw 投递选项

标志 默认值 描述
--hook-url <url> (无) OpenClaw 网络钩子 URL。
--hook-token <token> (无) OpenClaw 网络钩子令牌。
--push-token <token> (无) 转发给 gog watch serve 的推送令牌。

gog watch serve 选项

标志 默认值 描述
--bind <host> 127.0.0.1 gog watch serve 绑定主机。
--port <port> 8788 gog watch serve 端口。
--path <path> /gmail-pubsub gog watch serve 路径。
--include-body true 包含邮件正文片段。传入 --no-include-body 可禁用。
--max-bytes <n> 20000 每个正文片段的最大字节数。
--renew-minutes <n> 720(12h) 每 N 分钟续订 Gmail 监视。

Tailscale 暴露

标志 默认值 描述
--tailscale <mode> funnel 通过 tailscale 暴露推送端点:funnelserveoff
--tailscale-path <path> (无) tailscale serve/funnel 的路径。
--tailscale-target <t> (无) Tailscale serve/funnel 目标(端口、host:port 或 URL)。

输出

标志 描述
--json 打印机器可读摘要,而不是文本。

webhooks gmail run

在前台运行 gog watch serve 以及监视自动续订循环。

openclaw webhooks gmail run --account you@example.com

run 接受与 setup 相同的 gog watch serve、OpenClaw 投递、Pub/Sub 和 Tailscale 标志,但有以下例外:

  • --accountrun 中是可选的(它会回退到已配置的账号)。
  • run 接受 --project--push-endpoint--json
  • run 标志没有内置默认值;缺失值会回退到 setup 写入的值。
类别 标志
Pub/Sub --account--topic--subscription--label
OpenClaw 投递 --hook-url--hook-token--push-token
gog watch serve --bind--port--path--include-body--max-bytes--renew-minutes
Tailscale --tailscale--tailscale-path--tailscale-target

对于 run--topic 值是完整的 Pub/Sub 主题路径(projects/.../topics/...),而不只是短主题名称。

端到端流程

请参阅 Gmail Pub/Sub 集成,了解与这些 CLI 命令配套使用的 GCP 项目、OAuth 和 Gateway 网关侧设置。

相关

上一篇 鸿蒙 PC 跨设备拖拽:实现原理 + 实战代码