mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-20 01:11:18 +00:00
refactor: Remove dead setupOpenclawBatched export and unused batched setup mechanism (#2069)
- 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 <qa@openrouter.ai> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
548cfdf0b1
commit
43843a882b
4 changed files with 28 additions and 94 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@openrouter/spawn",
|
||||
"version": "0.11.20",
|
||||
"version": "0.11.21",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"spawn": "cli.js"
|
||||
|
|
|
|||
|
|
@ -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<void> {
|
||||
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<void> {
|
||||
logStep("Starting OpenClaw gateway daemon...");
|
||||
// Start the daemon AND wait for port 18789 in a single SSH session.
|
||||
|
|
|
|||
|
|
@ -21,11 +21,6 @@ export interface AgentConfig {
|
|||
envVars: (apiKey: string) => string[];
|
||||
/** Agent-specific configuration (settings files, etc.). */
|
||||
configure?: (apiKey: string, modelId?: string) => Promise<void>;
|
||||
/**
|
||||
* 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<void>;
|
||||
/** Pre-launch hook (e.g., start gateway daemon). */
|
||||
preLaunch?: () => Promise<void>;
|
||||
/** Optional tip or warning shown to the user just before the agent launches. */
|
||||
|
|
|
|||
|
|
@ -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)");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue