feat: implement runCommand wrapper and refactor command executions across modules

This commit is contained in:
Lauren ten Hoor
2026-02-13 10:50:35 +08:00
parent e55b7fa555
commit 83f1f1adf0
24 changed files with 209 additions and 178 deletions

View File

@@ -1,13 +1,10 @@
/**
* setup/agent.ts — Agent creation and workspace resolution.
*/
import { execFile } from "node:child_process";
import { promisify } from "node:util";
import fs from "node:fs/promises";
import path from "node:path";
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
const execFileAsync = promisify(execFile);
import { runCommand } from "../run-command.js";
/**
* Create a new agent via `openclaw agents add`.
@@ -27,7 +24,7 @@ export async function createAgent(
if (channelBinding) args.push("--bind", channelBinding);
try {
await execFileAsync("openclaw", args, { timeout: 30_000 });
await runCommand(["openclaw", ...args], { timeoutMs: 30_000 });
} catch (err) {
throw new Error(`Failed to create agent "${name}": ${(err as Error).message}`);
}