Преглед изворни кода

proper fix for image attachments (#4562)

Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
shuv пре 3 месеци
родитељ
комит
bdcf864678
3 измењених фајлова са 24 додато и 14 уклоњено
  1. 22 12
      packages/opencode/src/session/prompt.ts
  2. 1 1
      packages/plugin/package.json
  3. 1 1
      packages/sdk/js/package.json

+ 22 - 12
packages/opencode/src/session/prompt.ts

@@ -907,22 +907,32 @@ export namespace SessionPrompt {
                       extra: { bypassCwdCheck: true, ...info.model },
                       metadata: async () => {},
                     })
-                    pieces.push(
-                      {
-                        id: Identifier.ascending("part"),
-                        messageID: info.id,
-                        sessionID: input.sessionID,
-                        type: "text",
-                        synthetic: true,
-                        text: result.output,
-                      },
-                      {
+                    pieces.push({
+                      id: Identifier.ascending("part"),
+                      messageID: info.id,
+                      sessionID: input.sessionID,
+                      type: "text",
+                      synthetic: true,
+                      text: result.output,
+                    })
+                    if (result.attachments?.length) {
+                      pieces.push(
+                        ...result.attachments.map((attachment) => ({
+                          ...attachment,
+                          synthetic: true,
+                          filename: attachment.filename ?? part.filename,
+                          messageID: info.id,
+                          sessionID: input.sessionID,
+                        })),
+                      )
+                    } else {
+                      pieces.push({
                         ...part,
                         id: part.id ?? Identifier.ascending("part"),
                         messageID: info.id,
                         sessionID: input.sessionID,
-                      },
-                    )
+                      })
+                    }
                   })
                   .catch((error) => {
                     log.error("failed to read file", { error })

+ 1 - 1
packages/plugin/package.json

@@ -24,4 +24,4 @@
     "typescript": "catalog:",
     "@typescript/native-preview": "catalog:"
   }
-}
+}

+ 1 - 1
packages/sdk/js/package.json

@@ -26,4 +26,4 @@
   "publishConfig": {
     "directory": "dist"
   }
-}
+}