mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-26 10:26:26 +01:00
19 lines
928 B
TypeScript
19 lines
928 B
TypeScript
import { execFile } from "node:child_process";
|
|
import { promisify } from "node:util";
|
|
import type { CommandManagedRuntimeRunner } from "@paperclipai/adapter-utils/command-managed-runtime";
|
|
const exec = promisify(execFile);
|
|
export const localTestWorkFolderRunner: CommandManagedRuntimeRunner = {
|
|
async execute(input) {
|
|
try {
|
|
const execution = exec(input.command, input.args ?? [], { cwd: input.cwd,
|
|
env: { ...process.env, ...input.env }, timeout: input.timeoutMs, maxBuffer: 32 * 1024 * 1024 });
|
|
execution.child.stdin?.end(input.stdin);
|
|
const { stdout, stderr } = await execution;
|
|
return { stdout, stderr, exitCode: 0, signal: null, timedOut: false };
|
|
} catch (error) {
|
|
const value = error as Error & { stdout?: string; stderr?: string };
|
|
return { stdout: value.stdout ?? "", stderr: value.stderr ?? value.message, exitCode: 1, signal: null, timedOut: false };
|
|
}
|
|
},
|
|
};
|