This commit is contained in:
Dax Raad
2025-08-07 00:41:50 -04:00
parent d45d5d664c
commit 1fb54efdd2
25 changed files with 149 additions and 142 deletions
+4 -5
View File
@@ -3,7 +3,6 @@ import { exec } from "child_process"
import { text } from "stream/consumers"
import { Tool } from "./tool"
import DESCRIPTION from "./bash.txt"
import { App } from "../app/app"
import { Permission } from "../permission"
import { Config } from "../config/config"
import { Filesystem } from "../util/filesystem"
@@ -11,6 +10,7 @@ import { lazy } from "../util/lazy"
import { Log } from "../util/log"
import { Wildcard } from "../util/wildcard"
import { $ } from "bun"
import { Paths } from "../project/path"
const MAX_OUTPUT_LENGTH = 30000
const DEFAULT_TIMEOUT = 1 * 60 * 1000
@@ -39,7 +39,6 @@ export const BashTool = Tool.define("bash", {
}),
async execute(params, ctx) {
const timeout = Math.min(params.timeout ?? DEFAULT_TIMEOUT, MAX_TIMEOUT)
const app = App.info()
const cfg = await Config.get()
const tree = await parser().then((p) => p.parse(params.command))
const permissions = (() => {
@@ -83,9 +82,9 @@ export const BashTool = Tool.define("bash", {
.text()
.then((x) => x.trim())
log.info("resolved path", { arg, resolved })
if (resolved && !Filesystem.contains(app.path.cwd, resolved)) {
if (resolved && !Filesystem.contains(Paths.directory, resolved)) {
throw new Error(
`This command references paths outside of ${app.path.cwd} so it is not allowed to be executed.`,
`This command references paths outside of ${Paths.directory} so it is not allowed to be executed.`,
)
}
}
@@ -124,7 +123,7 @@ export const BashTool = Tool.define("bash", {
}
const process = exec(params.command, {
cwd: app.path.cwd,
cwd: Paths.directory,
signal: ctx.abort,
maxBuffer: MAX_OUTPUT_LENGTH,
timeout,