From 43843a882b0ddf82642ece77a46d8b27134fa0bc Mon Sep 17 00:00:00 2001 From: A <258483684+la14-1@users.noreply.github.com> Date: Sun, 1 Mar 2026 12:43:43 -0800 Subject: [PATCH] refactor: Remove dead setupOpenclawBatched export and unused batched setup mechanism (#2069) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Delete the exported `setupOpenclawBatched` function from `agent-setup.ts` — it was never imported or called anywhere in the codebase (confirmed via exhaustive grep) - Remove the unused `setup?` field from the `AgentConfig` interface in `agents.ts` — no agent implementation ever assigned this property - Remove the dead `if (agent.setup)` branch from `orchestrate.ts` — the batched path was always unreachable because no agent provided a `setup` callback Co-authored-by: spawn-qa-bot Co-authored-by: Claude Sonnet 4.6 --- packages/cli/package.json | 2 +- packages/cli/src/shared/agent-setup.ts | 56 ------------------------ packages/cli/src/shared/agents.ts | 5 --- packages/cli/src/shared/orchestrate.ts | 59 ++++++++++++-------------- 4 files changed, 28 insertions(+), 94 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 2b4a9968..c2b08674 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/spawn", - "version": "0.11.20", + "version": "0.11.21", "type": "module", "bin": { "spawn": "cli.js" diff --git a/packages/cli/src/shared/agent-setup.ts b/packages/cli/src/shared/agent-setup.ts index e85d67d9..847d13c6 100644 --- a/packages/cli/src/shared/agent-setup.ts +++ b/packages/cli/src/shared/agent-setup.ts @@ -294,62 +294,6 @@ async function setupOpenclawConfig(runner: CloudRunner, apiKey: string, modelId: await uploadConfigFile(runner, config, "$HOME/.openclaw/openclaw.json"); } -export async function setupOpenclawBatched( - runner: CloudRunner, - envContent: string, - apiKey: string, - modelId: string, -): Promise { - logStep("Setting up OpenClaw (install check + env + config)..."); - - const envB64 = Buffer.from(envContent).toString("base64"); - - const gatewayToken = crypto.randomUUID().replace(/-/g, ""); - const configJson = JSON.stringify({ - env: { - OPENROUTER_API_KEY: apiKey, - }, - gateway: { - mode: "local", - auth: { - token: gatewayToken, - }, - }, - agents: { - defaults: { - model: { - primary: modelId, - }, - }, - }, - }); - const configB64 = Buffer.from(configJson).toString("base64"); - - const script = [ - 'echo "==> Checking openclaw..."', - 'export PATH="$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$PATH"', - "if command -v openclaw >/dev/null 2>&1; then", - ' echo " openclaw found at $(command -v openclaw)"', - "else", - ' echo " openclaw not found, installing..."', - " mkdir -p ~/.npm-global/bin && npm install -g --prefix $HOME/.npm-global openclaw", - ' export PATH="$HOME/.npm-global/bin:$PATH"', - ' command -v openclaw || { echo "ERROR: openclaw install failed"; exit 1; }', - "fi", - 'echo "==> Writing environment variables..."', - `printf '%s' '${envB64}' | base64 -d > ~/.spawnrc && chmod 600 ~/.spawnrc`, - "grep -q 'source ~/.spawnrc' ~/.bashrc 2>/dev/null || echo '[ -f ~/.spawnrc ] && source ~/.spawnrc' >> ~/.bashrc", - "grep -q 'source ~/.spawnrc' ~/.zshrc 2>/dev/null || echo '[ -f ~/.spawnrc ] && source ~/.spawnrc' >> ~/.zshrc", - 'echo "==> Writing openclaw config..."', - "mkdir -p ~/.openclaw", - `printf '%s' '${configB64}' | base64 -d > ~/.openclaw/openclaw.json && chmod 600 ~/.openclaw/openclaw.json`, - 'echo "==> Setup complete"', - ].join("\n"); - - await runner.runServer(script); - logInfo("OpenClaw setup complete (install + env + config)"); -} - export async function startGateway(runner: CloudRunner): Promise { logStep("Starting OpenClaw gateway daemon..."); // Start the daemon AND wait for port 18789 in a single SSH session. diff --git a/packages/cli/src/shared/agents.ts b/packages/cli/src/shared/agents.ts index 045c6551..0fbd2675 100644 --- a/packages/cli/src/shared/agents.ts +++ b/packages/cli/src/shared/agents.ts @@ -21,11 +21,6 @@ export interface AgentConfig { envVars: (apiKey: string) => string[]; /** Agent-specific configuration (settings files, etc.). */ configure?: (apiKey: string, modelId?: string) => Promise; - /** - * Batched setup: install + env + configure in a single SSH session. - * When provided, orchestrate.ts calls this instead of the separate install / env / configure steps. - */ - setup?: (envContent: string, apiKey: string, modelId?: string) => Promise; /** Pre-launch hook (e.g., start gateway daemon). */ preLaunch?: () => Promise; /** Optional tip or warning shown to the user just before the agent launches. */ diff --git a/packages/cli/src/shared/orchestrate.ts b/packages/cli/src/shared/orchestrate.ts index d847e736..daa4ec59 100644 --- a/packages/cli/src/shared/orchestrate.ts +++ b/packages/cli/src/shared/orchestrate.ts @@ -84,41 +84,36 @@ export async function runOrchestration(cloud: CloudOrchestrator, agent: AgentCon const envContent = generateEnvConfig(agent.envVars(apiKey)); - if (agent.setup) { - // Batched path: install + env + config in a single SSH session - await agent.setup(envContent, apiKey, modelId); - } else { - // 8. Install agent - await agent.install(); + // 8. Install agent + await agent.install(); - // 9. Inject environment variables via .spawnrc - logStep("Setting up environment variables..."); - const envB64 = Buffer.from(envContent).toString("base64"); - try { - await withRetry( - "env setup", - () => - wrapSshCall( - cloud.runner.runServer( - `printf '%s' '${envB64}' | base64 -d > ~/.spawnrc && chmod 600 ~/.spawnrc; ` + - `grep -q 'source ~/.spawnrc' ~/.bashrc 2>/dev/null || echo '[ -f ~/.spawnrc ] && source ~/.spawnrc' >> ~/.bashrc; ` + - `grep -q 'source ~/.spawnrc' ~/.zshrc 2>/dev/null || echo '[ -f ~/.spawnrc ] && source ~/.spawnrc' >> ~/.zshrc`, - ), + // 9. Inject environment variables via .spawnrc + logStep("Setting up environment variables..."); + const envB64 = Buffer.from(envContent).toString("base64"); + try { + await withRetry( + "env setup", + () => + wrapSshCall( + cloud.runner.runServer( + `printf '%s' '${envB64}' | base64 -d > ~/.spawnrc && chmod 600 ~/.spawnrc; ` + + `grep -q 'source ~/.spawnrc' ~/.bashrc 2>/dev/null || echo '[ -f ~/.spawnrc ] && source ~/.spawnrc' >> ~/.bashrc; ` + + `grep -q 'source ~/.spawnrc' ~/.zshrc 2>/dev/null || echo '[ -f ~/.spawnrc ] && source ~/.spawnrc' >> ~/.zshrc`, ), - 2, - 5, - ); - } catch { - logWarn("Environment setup had errors"); - } + ), + 2, + 5, + ); + } catch { + logWarn("Environment setup had errors"); + } - // 10. Agent-specific configuration - if (agent.configure) { - try { - await withRetry("agent config", () => wrapSshCall(agent.configure!(apiKey, modelId)), 2, 5); - } catch { - logWarn("Agent configuration failed (continuing with defaults)"); - } + // 10. Agent-specific configuration + if (agent.configure) { + try { + await withRetry("agent config", () => wrapSshCall(agent.configure!(apiKey, modelId)), 2, 5); + } catch { + logWarn("Agent configuration failed (continuing with defaults)"); } }