fix: allow attachments outside cwd, and support svg

This commit is contained in:
adamdotdevin
2025-08-13 10:36:50 -05:00
parent 7d54f893c9
commit f2021a85d6
3 changed files with 3 additions and 3 deletions

View File

@@ -525,6 +525,7 @@ export namespace Session {
abort: new AbortController().signal,
agent: input.agent!,
messageID: userMsg.id,
extra: { bypassCwdCheck: true },
metadata: async () => {},
}),
)

View File

@@ -24,7 +24,7 @@ export const ReadTool = Tool.define("read", {
filepath = path.join(process.cwd(), filepath)
}
const app = App.info()
if (!Filesystem.contains(app.path.cwd, filepath)) {
if (!ctx.extra?.["bypassCwdCheck"] && !Filesystem.contains(app.path.cwd, filepath)) {
throw new Error(`File ${filepath} is not in the current working directory`)
}
@@ -98,8 +98,6 @@ function isImageFile(filePath: string): string | false {
return "GIF"
case ".bmp":
return "BMP"
case ".svg":
return "SVG"
case ".webp":
return "WebP"
default:

View File

@@ -10,6 +10,7 @@ export namespace Tool {
agent: string
callID?: string
abort: AbortSignal
extra?: { [key: string]: any }
metadata(input: { title?: string; metadata?: M }): void
}
export interface Info<Parameters extends StandardSchemaV1 = StandardSchemaV1, M extends Metadata = Metadata> {