CLI 自动化

CLI 自动化

使用 --non-interactive 自动化 openclaw onboard

--json 不意味着非交互模式。对于脚本,请使用 --non-interactive(和 --workspace)。

基线非交互示例

openclaw onboard --non-interactive \
  --mode local \
  --auth-choice apiKey \
  --anthropic-api-key "$ANTHROPIC_API_KEY" \
  --secret-input-mode plaintext \
  --gateway-port 18789 \
  --gateway-bind loopback \
  --install-daemon \
  --daemon-runtime node \
  --skip-skills

添加 --json 获取机器可读的摘要。

使用 --secret-input-mode ref 在认证配置文件中存储基于环境的引用,而不是明文值。 在引导向导流程中可用于环境变量引用和已配置的提供商引用(fileexec)之间的交互选择。

在非交互 ref 模式下,提供商环境变量必须在进程环境中设置。 传递内联密钥标志而没有匹配的环境变量现在会快速失败。

示例:

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

特定提供商示例

添加另一个代理

使用 openclaw agents add <name> 创建具有自己的工作区、 会话和认证配置文件的单独代理。在没有 --workspace 的情况下运行将启动向导。

openclaw agents add work \
  --workspace ~/.openclaw/workspace-work \
  --model openai/gpt-5.2 \
  --bind whatsapp:biz \
  --non-interactive \
  --json

它设置的内容:

  • agents.list[].name
  • agents.list[].workspace
  • agents.list[].agentDir

注意:

  • 默认工作区遵循 ~/.openclaw/workspace-<agentId>
  • 添加 bindings 以路由入站消息(向导可以完成此操作)。
  • 非交互标志:--model--agent-dir--bind--non-interactive

相关文档