fix(opencode): omit unsupported MCP blobs
This commit is contained in:
@@ -742,7 +742,8 @@ export const layer = Layer.effect(
|
||||
} else if ("blob" in c && c.blob) {
|
||||
const mime = ("mimeType" in c ? c.mimeType : undefined) ?? part.mime
|
||||
const url = `data:${mime};base64,${c.blob}`
|
||||
if (mime.split(";")[0]?.trim().toLowerCase() === "text/plain") {
|
||||
const mediaType = mime.split(";")[0]?.trim().toLowerCase()
|
||||
if (mediaType === "text/plain") {
|
||||
pieces.push({
|
||||
messageID: info.id,
|
||||
sessionID: input.sessionID,
|
||||
@@ -751,6 +752,20 @@ export const layer = Layer.effect(
|
||||
text: decodeDataUrl(url),
|
||||
})
|
||||
}
|
||||
const supported =
|
||||
mediaType?.startsWith("image/") ||
|
||||
mediaType?.startsWith("audio/") ||
|
||||
mediaType?.startsWith("video/") ||
|
||||
mediaType === "application/pdf"
|
||||
if (mediaType !== "text/plain" && !supported) {
|
||||
pieces.push({
|
||||
messageID: info.id,
|
||||
sessionID: input.sessionID,
|
||||
type: "text",
|
||||
synthetic: true,
|
||||
text: `[Binary content: ${mime}]`,
|
||||
})
|
||||
}
|
||||
pieces.push({
|
||||
messageID: info.id,
|
||||
sessionID: input.sessionID,
|
||||
@@ -758,6 +773,7 @@ export const layer = Layer.effect(
|
||||
mime,
|
||||
filename: part.filename,
|
||||
url,
|
||||
source: supported || mediaType === "text/plain" ? undefined : part.source,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user