mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-19 01:51:21 +08:00
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:
co-authored by
kiloconnect[bot]
parent
165009df5f
commit
714f920b1e
@@ -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
|
||||
|
||||
@@ -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}`,
|
||||
)
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user