(scriptPath: string, rawInput: string, env?: Record<string, string>)
| 24 | } |
| 25 | |
| 26 | function 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 | |
| 41 | function carefulInput(command: string) { |
| 42 | return { tool_input: { command } }; |
no test coverage detected