File tree Expand file tree Collapse file tree
packages/opencode/src/tool Expand file tree Collapse file tree Original file line number Diff line number Diff 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} )
You can’t perform that action at this time.
0 commit comments