diff options
| author | Dax Raad <[email protected]> | 2025-06-03 13:08:47 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-06-03 13:08:47 -0400 |
| commit | 866f22b0770247202c77658301ffac1293d3066c (patch) | |
| tree | 4837b3e8f01ab61f67e242a827d45a7b7d8a890e | |
| parent | ec7ab16ce4cc03d56cf96d63e37c621e06c7bffc (diff) | |
| download | opencode-866f22b0770247202c77658301ffac1293d3066c.tar.gz opencode-866f22b0770247202c77658301ffac1293d3066c.zip | |
sync
| -rw-r--r-- | packages/opencode/src/tool/bash.ts | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts index 14af360d2..da188f0ef 100644 --- a/packages/opencode/src/tool/bash.ts +++ b/packages/opencode/src/tool/bash.ts @@ -187,14 +187,23 @@ export const BashTool = Tool.define({ if (BANNED_COMMANDS.some((item) => params.command.startsWith(item))) throw new Error(`Command '${params.command}' is not allowed`) - const process = Bun.spawnSync({ + const process = Bun.spawn({ cmd: ["bash", "-c", params.command], maxBuffer: MAX_OUTPUT_LENGTH, timeout: timeout, }) + await process.exited + const stdout = await new Response(process.stdout).text() + const stderr = process.stderr + ? await new Response(process.stderr).text() + : undefined + return { - metadata: {}, - output: process.stdout.toString("utf-8"), + metadata: { + stderr, + stdout, + }, + output: stdout.replaceAll(/\x1b\[[0-9;]*m/g, ""), } }, }) |
