Files
openclaw/src/daemon/exec-file.ts
T
Peter Steinberger db02a96c4c refactor(process): route bounded commands through Execa (#106495)
* refactor(process): centralize bounded command execution

* refactor(process): migrate core one-shot commands

* refactor(plugins): migrate one-shot commands

* fix(process): await Windows tree termination

* chore(plugin-sdk): refresh process runtime surface

* refactor(process): migrate remaining bounded commands

* refactor(process): normalize command result handling

* refactor(process): split execution responsibilities

* chore(plugin-sdk): refresh API baseline

* chore(process): remove release-owned changelog entry

* fix(process): narrow binary command input checks

* fix(process): cap sandbox command output

* fix(qa-lab): preserve exact node probe env

* chore(ci): refresh dead export baseline

* fix(process): preserve force-kill command deadlines

* fix(process): avoid post-exit timeout reclassification

* test(process): update scp staging wrapper mock

* test(process): update remaining wrapper mocks

* refactor(qa-lab): preserve Execa tar execution
2026-07-13 11:07:35 -07:00

36 lines
1.1 KiB
TypeScript

/** Child-process wrapper used by daemon installers to preserve stdout/stderr on failure. */
import { runCommandWithTimeout } from "../process/exec.js";
type ExecResult = { stdout: string; stderr: string; code: number };
/** Runs a child process as UTF-8 and returns exit data instead of throwing on nonzero exit. */
export async function execFileUtf8(
command: string,
args: string[],
options: {
cwd?: string;
env?: NodeJS.ProcessEnv;
timeout?: number;
killSignal?: NodeJS.Signals | number;
windowsHide?: boolean;
} = {},
): Promise<ExecResult> {
try {
const result = await runCommandWithTimeout([command, ...args], {
baseEnv: options.env,
cwd: options.cwd,
killSignal: options.killSignal,
maxOutputBytes: 1024 * 1024,
timeoutMs: options.timeout,
});
return {
stdout: result.stdout,
stderr: result.stderr,
code: result.code ?? 1,
};
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
return { stdout: "", stderr: message, code: 1 };
}
}