fix(cli): report unsupported icons as tool errors

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
This commit is contained in:
chrarnoldus
2026-06-04 12:43:30 +00:00
co-authored by kiloconnect[bot]
parent 165009df5f
commit 714f920b1e
2 changed files with 4 additions and 14 deletions
+1 -11
View File
@@ -108,7 +108,7 @@ export const WebFetchTool = Tool.define(
const contentType = response.headers["content-type"] || ""
const mime = contentType.split(";")[0]?.trim().toLowerCase() || ""
const title = `${url} (${contentType})` // kilocode_change
if (isIconMimeType(mime)) throw new Error(`Unsupported image format: ${mime}`) // kilocode_change
if (isImageAttachment(mime)) {
const base64Content = Buffer.from(arrayBuffer).toString("base64")
return {
@@ -125,16 +125,6 @@ export const WebFetchTool = Tool.define(
}
}
// kilocode_change start
if (isIconMimeType(mime)) {
return {
title,
output: `Unsupported image format: ${mime}.`,
metadata: {},
}
}
// kilocode_change end
const content = new TextDecoder().decode(arrayBuffer)
// Handle content based on requested format and actual content type
+3 -3
View File
@@ -91,9 +91,9 @@ describe("tool.webfetch", () => {
await WithInstance.provide({
directory: projectRoot,
fn: async () => {
const result = await exec({ url: new URL("/favicon.ico", url).toString(), format: "markdown" })
expect(result.output).toContain(`Unsupported image format: ${mime}`)
expect(result.attachments).toBeUndefined()
await expect(exec({ url: new URL("/favicon.ico", url).toString(), format: "markdown" })).rejects.toThrow(
`Unsupported image format: ${mime}`,
)
},
})
},