Agent Spawner
Deploy a new OpenClaw agent conversationally. Official install, carry over config from the current agent. User never edits a file.
1. Read Current Config (silent)
CODEBLOCK0
Identify:
- - Provider: check
auth.profiles in config — could be Anthropic, OpenAI, Gemini, custom, etc. - API key: from env var or config (e.g.
ANTHROPIC_API_KEY, GEMINI_API_KEY, OPENAI_API_KEY) - Model: from INLINECODE4
- Tool keys: anything in
tools.* (search APIs, etc.) - Plugins:
plugins.installs — names and npm specs - Skills: run
openclaw skills list to see what's bundled vs workspace-only. Only carry over non-bundled skills.
2. Ask
- 1. "Where should I deploy it?" — Docker (local or remote SSH) or bare metal?
- "Name?" — for container. Generate one if they don't care.
- "Anything special?" — purpose, constraints. Optional.
Don't ask about keys, plugins, skills, ports, or config. Carry everything over, use defaults.
3. Confirm Plan
After gathering answers, present the full plan before doing anything. Show everything in one summary:
CODEBLOCK1
Only list items that actually exist. Wait for explicit confirmation before proceeding. If the user wants changes, adjust and re-confirm.
4. Deploy
Docker
CODEBLOCK2
Set env and run non-interactive onboard. Match the provider detected in step 1:
CODEBLOCK3
Onboard flags vary by provider. Use the matching --auth-choice and key flag:
| Provider | --auth-choice | Key flag |
|---|
| Anthropic | INLINECODE9 | INLINECODE10 |
| Gemini |
gemini-api-key |
--gemini-api-key |
| OpenAI |
apiKey | (set
OPENAI_API_KEY env) |
| Custom |
custom-api-key |
--custom-api-key +
--custom-base-url +
--custom-model-id |
CODEBLOCK4
Official compose uses bind mounts — host user owns files, no permission issues.
Onboard error about gateway connection is expected (not running yet). Config is written.
Bare metal
CODEBLOCK5
5. Patch Running Agent
CLI alias:
- - Docker: INLINECODE19
- Bare metal: INLINECODE20
Config (only patch what the current agent actually has):
CODEBLOCK6
Plugins (from plugins.installs in current config):
CODEBLOCK7
Skills (copy workspace skills):
CODEBLOCK8
Restart:
CODEBLOCK9
6. Hand Off
Read the gateway token:
CODEBLOCK10
Tell the user:
- - URL: INLINECODE22
- Token: (from config — onboard auto-generates one)
- "Say hello — it'll bootstrap itself."
Notes
- -
openclaw not in PATH inside Docker. Use node /app/openclaw.mjs. - INLINECODE25 required for non-interactive onboard.
- INLINECODE26 — pre-built official image.
- Don't use named Docker volumes — root ownership issues. Official compose uses bind mounts.
- Multiple agents on same host: use different
OPENCLAW_CONFIG_DIR and OPENCLAW_GATEWAY_PORT. - Plugins and skills persist in
~/.openclaw/ volume (extensions/ and workspace/skills/). - SSH keys, git config, apt packages are ephemeral — not in the volume, by design.
Agent Spawner
以对话方式部署一个新的OpenClaw代理。官方安装,从当前代理继承配置。用户无需编辑任何文件。
1. 读取当前配置(静默执行)
bash
cat ~/.openclaw/openclaw.json
cat ~/.openclaw/.env 2>/dev/null
env | grep -iE API_KEY|TOKEN
ls ~/.openclaw/extensions/
ls /skills/
识别:
- - 提供商:检查配置中的 auth.profiles —— 可能是Anthropic、OpenAI、Gemini、自定义等
- API密钥:来自环境变量或配置(例如 ANTHROPICAPIKEY、GEMINIAPIKEY、OPENAIAPIKEY)
- 模型:来自 agents.defaults.model
- 工具密钥:tools.* 中的任何内容(搜索API等)
- 插件:plugins.installs —— 名称和npm规范
- 技能:运行 openclaw skills list 查看哪些是内置的,哪些仅在工作区。仅继承非内置技能。
2. 询问
- 1. 部署到哪里? —— Docker(本地或远程SSH)还是裸机?
- 名称? —— 用于容器。如果他们不在意,自动生成一个。
- 有什么特殊要求? —— 用途、限制。可选。
不要询问密钥、插件、技能、端口或配置。全部继承,使用默认值。
3. 确认计划
收集答案后,在执行任何操作前展示完整计划。在一个摘要中显示所有内容:
以下是计划:
📦 部署:Docker 在 <目标>
📛 名称:<代理名称>
🌐 端口:<端口>
从当前代理继承:
✅ 提供商:Anthropic(API密钥)
✅ 模型:anthropic/claude-sonnet-4-20250514
✅ Brave搜索API密钥
✅ 插件:openclaw-agent-reach
✅ 技能:agent-spawner, weather
✅ 心跳:30分钟
新代理将在首次消息时自举其身份。
准备好了吗?
仅列出实际存在的项目。在继续前等待明确确认。如果用户想要更改,调整后重新确认。
4. 部署
Docker
bash
git clone https://github.com/openclaw/openclaw.git <代理名称>
cd <代理名称>
设置环境变量并运行非交互式初始化。匹配步骤1中检测到的提供商:
bash
export OPENCLAW_IMAGE=alpine/openclaw:latest
export OPENCLAWCONFIGDIR=~/.openclaw-<代理名称>
export OPENCLAWWORKSPACEDIR=~/.openclaw-<代理名称>/workspace
export OPENCLAWGATEWAYPORT=<未使用的端口,默认18789>
export OPENCLAWGATEWAYBIND=lan
mkdir -p $OPENCLAWCONFIGDIR/workspace
初始化标志因提供商而异。 使用匹配的 --auth-choice 和密钥标志:
| 提供商 | --auth-choice | 密钥标志 |
|---|
| Anthropic | apiKey | --anthropic-api-key |
| Gemini |
gemini-api-key | --gemini-api-key |
| OpenAI | apiKey | (设置 OPENAI
APIKEY 环境变量) |
| 自定义 | custom-api-key | --custom-api-key + --custom-base-url + --custom-model-id |
bash
docker compose run --rm openclaw-cli onboard --non-interactive --accept-risk \
--mode local \
--auth-choice <检测到的> \
--<提供商>-api-key $API_KEY \
--gateway-port 18789 \
--gateway-bind lan \
--skip-skills
docker compose up -d openclaw-gateway
官方compose使用绑定挂载 —— 主机用户拥有文件,无权限问题。
初始化时关于网关连接的错误是预期的(尚未运行)。配置已写入。
裸机
bash
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard
openclaw onboard --non-interactive --accept-risk \
--mode local \
--auth-choice <检测到的> \
--<提供商>-api-key $API_KEY \
--gateway-port 18789 \
--gateway-bind lan \
--install-daemon \
--daemon-runtime node \
--skip-skills
5. 修补运行中的代理
CLI别名:
- - Docker:OC=docker compose exec openclaw-gateway node /app/openclaw.mjs
- 裸机:OC=openclaw
配置(仅修补当前代理实际拥有的内容):
bash
$OC config set agents.defaults.model <模型>
$OC config set agents.defaults.heartbeat.every 30m
工具密钥 —— 仅当当前配置中存在时才设置
$OC config set tools.web.search.apiKey <密钥>
插件(来自当前配置中的 plugins.installs):
bash
$OC plugins install
对每个插件重复执行
技能(复制工作区技能):
bash
Docker
docker cp <源工作区>/skills/ <容器>:/home/node/.openclaw/workspace/skills/
裸机
cp -r <源工作区>/skills/ ~/.openclaw/workspace/skills/
重启:
bash
docker compose restart openclaw-gateway # Docker
openclaw gateway restart # 裸机
6. 交接
读取网关令牌:
bash
grep -A1 token $OPENCLAWCONFIGDIR/openclaw.json
告知用户:
- - URL: http://<主机>:<端口>/
- 令牌:(来自配置 —— 初始化时自动生成)
- 打个招呼 —— 它会自举其身份。
注意事项
- - Docker内部 openclaw 不在PATH中。使用 node /app/openclaw.mjs。
- 非交互式初始化需要 --accept-risk。
- alpine/openclaw:latest —— 预构建的官方镜像。
- 不要使用命名的Docker卷 —— 会导致root所有权问题。官方compose使用绑定挂载。
- 同一主机上的多个代理:使用不同的 OPENCLAWCONFIGDIR 和 OPENCLAWGATEWAYPORT。
- 插件和技能持久化存储在 ~/.openclaw/ 卷中(extensions/ 和 workspace/skills/)。
- SSH密钥、git配置、apt包是临时的 —— 不在卷中,这是设计使然。