跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt

Use this file to discover all available pages before exploring further.

openclaw agent 可在命令行中运行单次智能体轮次,而无需 入站聊天消息。可将其用于脚本工作流、测试和 程序化投递。

快速开始

1

运行一个简单的智能体轮次

openclaw agent --message "What is the weather today?"
这会通过 Gateway 网关发送该消息并打印回复。
2

指定某个智能体或会话

# 指定某个智能体
openclaw agent --agent ops --message "Summarize logs"

# 指定一个电话号码(派生会话键)
openclaw agent --to +15555550123 --message "Status update"

# 复用一个现有会话
openclaw agent --session-id abc123 --message "Continue the task"
3

将回复投递到某个渠道

# 投递到 WhatsApp(默认渠道)
openclaw agent --to +15555550123 --message "Report ready" --deliver

# 投递到 Slack
openclaw agent --agent ops --message "Generate report" \
  --deliver --reply-channel slack --reply-to "#reports"

标志

标志描述
--message \<text\>要发送的消息(必需)
--to \<dest\>从目标(电话、chat id)派生会话键
--agent \<id\>指定一个已配置的智能体(使用其 main 会话)
--session-id \<id\>按 id 复用一个现有会话
--local强制使用本地嵌入式运行时(跳过 Gateway 网关)
--deliver将回复发送到聊天渠道
--channel \<name\>投递渠道(whatsapp、telegram、discord、slack 等)
--reply-to \<target\>投递目标覆盖
--reply-channel \<name\>投递渠道覆盖
--reply-account \<id\>投递账户 id 覆盖
--thinking \<level\>为所选模型 profile 设置 thinking 级别
--verbose \<on|full|off\>设置 verbose 级别
--timeout \<seconds\>覆盖智能体超时时间
--json输出结构化 JSON

行为

  • 默认情况下,CLI 会通过 Gateway 网关运行。添加 --local 可强制在当前机器上使用嵌入式运行时。
  • 如果 Gateway 网关不可达,CLI 会回退到本地嵌入式运行。
  • 会话选择:--to 会派生会话键(群组/频道目标保持隔离;私聊会折叠到 main)。
  • Thinking 和 verbose 标志会持久化到会话存储中。
  • 输出:默认是纯文本,或使用 --json 获取结构化负载 + 元数据。

示例

# 带 JSON 输出的简单轮次
openclaw agent --to +15555550123 --message "Trace logs" --verbose on --json

# 带 thinking 级别的轮次
openclaw agent --session-id 1234 --message "Summarize inbox" --thinking medium

# 投递到与当前会话不同的渠道
openclaw agent --agent ops --message "Alert" --deliver --reply-channel telegram --reply-to "@admin"

相关内容