Remove path-based restrictions

This commit is contained in:
2025-09-11 21:01:09 +02:00
parent 6835f9084c
commit d78bbff439
4 changed files with 18 additions and 18 deletions

View File

@@ -4,7 +4,7 @@ import { exec } from "child_process"
import { Tool } from "./tool"
import DESCRIPTION from "./bash.txt"
import { Permission } from "../permission"
import { Filesystem } from "../util/filesystem"
// import { Filesystem } from "../util/filesystem"
import { lazy } from "../util/lazy"
import { Log } from "../util/log"
import { Wildcard } from "../util/wildcard"
@@ -87,11 +87,11 @@ export const BashTool = Tool.define("bash", {
.text()
.then((x) => x.trim())
log.info("resolved path", { arg, resolved })
if (resolved && !Filesystem.contains(Instance.directory, resolved)) {
throw new Error(
`This command references paths outside of ${Instance.directory} so it is not allowed to be executed.`,
)
}
// if (resolved && !Filesystem.contains(Instance.directory, resolved)) {
// throw new Error(
// `This command references paths outside of ${Instance.directory} so it is not allowed to be executed.`,
// )
// }
}
}

View File

@@ -13,7 +13,7 @@ import DESCRIPTION from "./edit.txt"
import { File } from "../file"
import { Bus } from "../bus"
import { FileTime } from "../file/time"
import { Filesystem } from "../util/filesystem"
// import { Filesystem } from "../util/filesystem"
import { Instance } from "../project/instance"
import { Agent } from "../agent/agent"
@@ -35,9 +35,9 @@ export const EditTool = Tool.define("edit", {
}
const filePath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath)
if (!Filesystem.contains(Instance.directory, filePath)) {
throw new Error(`File ${filePath} is not in the current working directory`)
}
// if (!Filesystem.contains(Instance.directory, filePath)) {
// throw new Error(`File ${filePath} is not in the current working directory`)
// }
const agent = await Agent.get(ctx.agent)
let diff = ""

View File

@@ -5,7 +5,7 @@ import { Tool } from "./tool"
import { LSP } from "../lsp"
import { FileTime } from "../file/time"
import DESCRIPTION from "./read.txt"
import { Filesystem } from "../util/filesystem"
// import { Filesystem } from "../util/filesystem"
import { Instance } from "../project/instance"
const DEFAULT_READ_LIMIT = 2000
@@ -23,9 +23,9 @@ export const ReadTool = Tool.define("read", {
if (!path.isAbsolute(filepath)) {
filepath = path.join(process.cwd(), filepath)
}
if (!ctx.extra?.["bypassCwdCheck"] && !Filesystem.contains(Instance.directory, filepath)) {
throw new Error(`File ${filepath} is not in the current working directory`)
}
// if (!ctx.extra?.["bypassCwdCheck"] && !Filesystem.contains(Instance.directory, filepath)) {
// throw new Error(`File ${filepath} is not in the current working directory`)
// }
const file = Bun.file(filepath)
if (!(await file.exists())) {

View File

@@ -7,7 +7,7 @@ import DESCRIPTION from "./write.txt"
import { Bus } from "../bus"
import { File } from "../file"
import { FileTime } from "../file/time"
import { Filesystem } from "../util/filesystem"
// import { Filesystem } from "../util/filesystem"
import { Instance } from "../project/instance"
import { Agent } from "../agent/agent"
@@ -19,9 +19,9 @@ export const WriteTool = Tool.define("write", {
}),
async execute(params, ctx) {
const filepath = path.isAbsolute(params.filePath) ? params.filePath : path.join(Instance.directory, params.filePath)
if (!Filesystem.contains(Instance.directory, filepath)) {
throw new Error(`File ${filepath} is not in the current working directory`)
}
// if (!Filesystem.contains(Instance.directory, filepath)) {
// throw new Error(`File ${filepath} is not in the current working directory`)
// }
const file = Bun.file(filepath)
const exists = await file.exists()