summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-08-03 13:51:59 -0400
committerDax Raad <[email protected]>2025-08-03 13:52:50 -0400
commit21c52fd5cb2b6f4c289227906d35cee2939300c3 (patch)
tree228be2e947e2927e0cbf4c82875c501388247bde /packages
parent5e8634afafd7001c3abb4ddc6cf387fe1452d1dc (diff)
downloadopencode-21c52fd5cb2b6f4c289227906d35cee2939300c3.tar.gz
opencode-21c52fd5cb2b6f4c289227906d35cee2939300c3.zip
fix bash tool getting stuck on interactive commands
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/session/index.ts4
-rw-r--r--packages/opencode/src/tool/bash.ts24
2 files changed, 15 insertions, 13 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts
index 3fd156b84..01df6da74 100644
--- a/packages/opencode/src/session/index.ts
+++ b/packages/opencode/src/session/index.ts
@@ -737,7 +737,7 @@ export namespace Session {
)
const result = await item.execute(args, {
sessionID: input.sessionID,
- abort: abort.signal,
+ abort: options.abortSignal!,
messageID: assistantMsg.id,
callID: options.toolCallId,
metadata: async (val) => {
@@ -779,7 +779,7 @@ export namespace Session {
}
for (const [key, item] of Object.entries(await MCP.tools())) {
- if (mode.tools[key] === false) continue
+ if (enabledTools[key] === false) continue
const execute = item.execute
if (!execute) continue
item.execute = async (args, opts) => {
diff --git a/packages/opencode/src/tool/bash.ts b/packages/opencode/src/tool/bash.ts
index 5e0dddfb7..99cad0a1b 100644
--- a/packages/opencode/src/tool/bash.ts
+++ b/packages/opencode/src/tool/bash.ts
@@ -1,4 +1,6 @@
import { z } from "zod"
+import { spawn } from "child_process"
+import { text } from "stream/consumers"
import { Tool } from "./tool"
import DESCRIPTION from "./bash.txt"
import { App } from "../app/app"
@@ -10,7 +12,7 @@ import { Log } from "../util/log"
import { Wildcard } from "../util/wildcard"
import { $ } from "bun"
-const MAX_OUTPUT_LENGTH = 30000
+// const MAX_OUTPUT_LENGTH = 30000
const DEFAULT_TIMEOUT = 1 * 60 * 1000
const MAX_TIMEOUT = 10 * 60 * 1000
@@ -116,19 +118,19 @@ export const BashTool = Tool.define("bash", {
})
}
- const process = Bun.spawn({
- cmd: ["bash", "-c", params.command],
+ const process = spawn("bash", ["-c", params.command], {
+ stdio: "pipe",
cwd: app.path.cwd,
- maxBuffer: MAX_OUTPUT_LENGTH,
signal: ctx.abort,
- timeout: timeout,
- stdin: "pipe",
- stdout: "pipe",
- stderr: "pipe",
+ timeout,
})
- await process.exited
- const stdout = await new Response(process.stdout).text()
- const stderr = await new Response(process.stderr).text()
+ await new Promise<void>((resolve) => {
+ process.on("close", () => {
+ resolve()
+ })
+ })
+ const stdout = await text(process.stdout)
+ const stderr = await text(process.stderr)
return {
title: params.command,