CLI 自動化
使用 --non-interactive 來自動化 openclaw onboard。
--json 並不隱含非互動式模式。請使用 --non-interactive(以及 --workspace)進行指令碼。
基線非互動式範例
openclaw onboard --non-interactive \
--mode local \
--auth-choice apiKey \
--anthropic-api-key "$ANTHROPIC_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback \
--install-daemon \
--daemon-runtime node \
--skip-skills
加上 --json 以獲得機器可讀的摘要。
使用 --secret-input-mode ref 在認證設定檔中儲存環境變數參考而非純文字值。
互動式選擇環境參考和配置的提供者參考(file 或 exec)可在入門精靈流程中使用。
在非互動式 ref 模式中,提供者環境變數必須在程序環境中設定。
不使用匹配的環境變數傳遞內聯鍵旗標現在會快速失敗。
範例:
openclaw onboard --non-interactive \
--mode local \
--auth-choice openai-api-key \
--secret-input-mode ref \
--accept-risk
提供者特定範例
openclaw onboard --non-interactive \
--mode local \
--auth-choice gemini-api-key \
--gemini-api-key "$GEMINI_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice zai-api-key \
--zai-api-key "$ZAI_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice ai-gateway-api-key \
--ai-gateway-api-key "$AI_GATEWAY_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice cloudflare-ai-gateway-api-key \
--cloudflare-ai-gateway-account-id "your-account-id" \
--cloudflare-ai-gateway-gateway-id "your-gateway-id" \
--cloudflare-ai-gateway-api-key "$CLOUDFLARE_AI_GATEWAY_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice moonshot-api-key \
--moonshot-api-key "$MOONSHOT_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice synthetic-api-key \
--synthetic-api-key "$SYNTHETIC_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
openclaw onboard --non-interactive \
--mode local \
--auth-choice opencode-zen \
--opencode-zen-api-key "$OPENCODE_API_KEY" \
--gateway-port 18789 \
--gateway-bind loopback
改用 --auth-choice opencode-go --opencode-go-api-key "$OPENCODE_API_KEY" 切換至 Go 目錄。
openclaw onboard --non-interactive \
--mode local \
--auth-choice ollama \
--custom-model-id "qwen3.5:27b" \
--accept-risk \
--gateway-port 18789 \
--gateway-bind loopback
添加另一個代理
使用 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。
相關文件