Просмотр исходного кода

fix: allow attachments outside cwd, and support svg

adamdotdevin 6 месяцев назад
Родитель
Сommit
f2021a85d6

+ 1 - 0
packages/opencode/src/session/index.ts

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

+ 1 - 3
packages/opencode/src/tool/read.ts

@@ -24,7 +24,7 @@ export const ReadTool = Tool.define("read", {
       filepath = path.join(process.cwd(), filepath)
       filepath = path.join(process.cwd(), filepath)
     }
     }
     const app = App.info()
     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`)
       throw new Error(`File ${filepath} is not in the current working directory`)
     }
     }
 
 
@@ -98,8 +98,6 @@ function isImageFile(filePath: string): string | false {
       return "GIF"
       return "GIF"
     case ".bmp":
     case ".bmp":
       return "BMP"
       return "BMP"
-    case ".svg":
-      return "SVG"
     case ".webp":
     case ".webp":
       return "WebP"
       return "WebP"
     default:
     default:

+ 1 - 0
packages/opencode/src/tool/tool.ts

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