MCPcopy
hub / github.com/garrytan/gstack / runHookRaw

Function runHookRaw

test/hook-scripts.test.ts:26–39  ·  view source on GitHub ↗
(scriptPath: string, rawInput: string, env?: Record<string, string>)

Source from the content-addressed store, hash-verified

24}
25
26function runHookRaw(scriptPath: string, rawInput: string, env?: Record<string, string>): { exitCode: number; output: any; raw: string } {
27 const result = spawnSync('bash', [scriptPath], {
28 input: rawInput,
29 stdio: ['pipe', 'pipe', 'pipe'],
30 env: { ...process.env, ...env },
31 timeout: 5000,
32 });
33 const raw = result.stdout.toString().trim();
34 let output: any = {};
35 try {
36 output = JSON.parse(raw);
37 } catch {}
38 return { exitCode: result.status ?? 1, output, raw };
39}
40
41function carefulInput(command: string) {
42 return { tool_input: { command } };

Callers 1

Calls 1

spawnSyncFunction · 0.85

Tested by

no test coverage detected