UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

34 lines (33 loc) 1.02 kB
import { t as formatErrorMessage } from "./errors-Db3Ymjlb.js"; import { r as runCommandWithTimeout } from "./exec-BIE-3oLG.js"; //#region src/plugin-sdk/run-command.ts /** Run a plugin-managed command with timeout handling and normalized stdout/stderr results. */ async function runPluginCommandWithTimeout(options) { const [command] = options.argv; if (!command) return { code: 1, stdout: "", stderr: "command is required" }; try { const result = await runCommandWithTimeout(options.argv, { timeoutMs: options.timeoutMs, cwd: options.cwd, env: options.env }); const timedOut = result.termination === "timeout" || result.termination === "no-output-timeout"; return { code: result.code ?? 1, stdout: result.stdout, stderr: timedOut ? result.stderr || `command timed out after ${options.timeoutMs}ms` : result.stderr }; } catch (error) { return { code: 1, stdout: "", stderr: formatErrorMessage(error) }; } } //#endregion export { runPluginCommandWithTimeout as t };