Skip to content

Commit 866f22b

Browse files
committed
sync
1 parent ec7ab16 commit 866f22b

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

packages/opencode/src/tool/bash.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,23 @@ export const BashTool = Tool.define({
187187
if (BANNED_COMMANDS.some((item) => params.command.startsWith(item)))
188188
throw new Error(`Command '${params.command}' is not allowed`)
189189

190-
const process = Bun.spawnSync({
190+
const process = Bun.spawn({
191191
cmd: ["bash", "-c", params.command],
192192
maxBuffer: MAX_OUTPUT_LENGTH,
193193
timeout: timeout,
194194
})
195+
await process.exited
196+
const stdout = await new Response(process.stdout).text()
197+
const stderr = process.stderr
198+
? await new Response(process.stderr).text()
199+
: undefined
200+
195201
return {
196-
metadata: {},
197-
output: process.stdout.toString("utf-8"),
202+
metadata: {
203+
stderr,
204+
stdout,
205+
},
206+
output: stdout.replaceAll(/\x1b\[[0-9;]*m/g, ""),
198207
}
199208
},
200209
})

0 commit comments

Comments
 (0)