fix(core): restore webfetch image output
This commit is contained in:
parent
592ef7433a
commit
50dde6a646
3 changed files with 96 additions and 13 deletions
|
|
@ -234,14 +234,41 @@ describe("WebFetchTool registration", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("keeps images and files unsupported until typed settlement can carry attachments", () =>
|
||||
it.effect("returns images as native media and keeps other files unsupported", () =>
|
||||
Effect.gen(function* () {
|
||||
reset()
|
||||
const registry = yield* ToolRegistry.Service
|
||||
respond = () => Effect.succeed(new Response("png", { headers: { "content-type": "image/png" } }))
|
||||
expect(yield* executeTool(registry, call({ url: "https://1.1.1.1/image", format: "html" }))).toEqual({
|
||||
type: "error",
|
||||
value: "Unable to fetch https://1.1.1.1/image",
|
||||
respond = () => Effect.succeed(new Response("png", { headers: { "content-type": "IMAGE/PNG; charset=binary" } }))
|
||||
expect(yield* settleTool(registry, call({ url: "https://1.1.1.1/image", format: "html" }))).toEqual({
|
||||
result: {
|
||||
type: "content",
|
||||
value: [
|
||||
{ type: "text", text: "Image fetched successfully" },
|
||||
{
|
||||
type: "file",
|
||||
uri: "data:image/png;base64,cG5n",
|
||||
mime: "image/png",
|
||||
name: "https://1.1.1.1/image",
|
||||
},
|
||||
],
|
||||
},
|
||||
output: {
|
||||
structured: {
|
||||
url: "https://1.1.1.1/image",
|
||||
contentType: "IMAGE/PNG; charset=binary",
|
||||
format: "html",
|
||||
output: "Image fetched successfully",
|
||||
},
|
||||
content: [
|
||||
{ type: "text", text: "Image fetched successfully" },
|
||||
{
|
||||
type: "file",
|
||||
uri: "data:image/png;base64,cG5n",
|
||||
mime: "image/png",
|
||||
name: "https://1.1.1.1/image",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
respond = () => Effect.succeed(new Response("pdf", { headers: { "content-type": "application/pdf" } }))
|
||||
|
|
@ -252,6 +279,26 @@ describe("WebFetchTool registration", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("keeps SVG and FastBid sheets as text instead of image media", () =>
|
||||
Effect.gen(function* () {
|
||||
reset()
|
||||
const registry = yield* ToolRegistry.Service
|
||||
respond = () =>
|
||||
Effect.succeed(new Response("<svg><text>hello</text></svg>", { headers: { "content-type": "image/svg+xml" } }))
|
||||
expect(yield* executeTool(registry, call({ url: "https://1.1.1.1/image.svg", format: "html" }))).toEqual({
|
||||
type: "text",
|
||||
value: "<svg><text>hello</text></svg>",
|
||||
})
|
||||
|
||||
respond = () =>
|
||||
Effect.succeed(new Response("table Sheet {}", { headers: { "content-type": "image/vnd.fastbidsheet" } }))
|
||||
expect(yield* executeTool(registry, call({ url: "https://1.1.1.1/sheet.fbs", format: "text" }))).toEqual({
|
||||
type: "text",
|
||||
value: "table Sheet {}",
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("retries Cloudflare challenges with an honest user agent", () =>
|
||||
Effect.gen(function* () {
|
||||
reset()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue