diff options
| author | Dax Raad <[email protected]> | 2025-07-25 15:48:19 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-07-25 15:48:42 -0400 |
| commit | 7044662cfacbb2a3cbc9845013b87616d8c98df1 (patch) | |
| tree | f8a616c56d464cc9b203988486a45ee4682eaed7 | |
| parent | 92656fdf29b9d85f4553256ab8928e6d6e3e3bf6 (diff) | |
| download | opencode-7044662cfacbb2a3cbc9845013b87616d8c98df1.tar.gz opencode-7044662cfacbb2a3cbc9845013b87616d8c98df1.zip | |
handle uploaded text/plain
| -rw-r--r-- | packages/opencode/src/session/index.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index b4ffda39d..86e3e15b7 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -388,6 +388,34 @@ export namespace Session { if (part.type === "file") { const url = new URL(part.url) switch (url.protocol) { + case "data:": + if (part.mime === "text/plain") { + return [ + { + id: Identifier.ascending("part"), + messageID: userMsg.id, + sessionID: input.sessionID, + type: "text", + synthetic: true, + text: `Called the Read tool with the following input: ${JSON.stringify({ filePath: part.filename })}`, + }, + { + id: Identifier.ascending("part"), + messageID: userMsg.id, + sessionID: input.sessionID, + type: "text", + synthetic: true, + text: Buffer.from(part.url, "base64url").toString(), + }, + { + ...part, + id: part.id ?? Identifier.ascending("part"), + messageID: userMsg.id, + sessionID: input.sessionID, + }, + ] + } + break case "file:": // have to normalize, symbol search returns absolute paths // Decode the pathname since URL constructor doesn't automatically decode it |
