mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-02 23:23:45 +00:00
ask instead of throwing tool error if file is outside cwd
This commit is contained in:
@@ -37,7 +37,19 @@ 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`)
|
||||
const parentDir = path.dirname(filePath)
|
||||
await Permission.ask({
|
||||
type: "external-directory",
|
||||
pattern: parentDir,
|
||||
sessionID: ctx.sessionID,
|
||||
messageID: ctx.messageID,
|
||||
callID: ctx.callID,
|
||||
title: `Edit file outside working directory: ${filePath}`,
|
||||
metadata: {
|
||||
filepath: filePath,
|
||||
parentDir,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const agent = await Agent.get(ctx.agent)
|
||||
|
||||
Reference in New Issue
Block a user