import { exec } from 'child_process';
import { getWorkspace } from '../storage/workspace-store.js';
export async function executeCommandNode(workspaceId, node) {
    const workspace = getWorkspace(workspaceId);
    const data = node.data;
    const cwd = data.cwd || workspace?.boundDirs?.[0] || process.cwd();
    return new Promise((resolve) => {
        exec(data.script, {
            cwd,
            env: { ...process.env, ...data.env },
            shell: data.shell || undefined,
            timeout: 300_000,
            maxBuffer: 10 * 1024 * 1024,
        }, (error, stdout, stderr) => {
            resolve({
                success: !error,
                exitCode: error ? (typeof error.code === 'number' ? error.code : 1) : 0,
                stdout: stdout || '',
                stderr: stderr || '',
            });
        });
    });
}
//# sourceMappingURL=workflow-command-runner.js.map