BREAKING CHANGE: remove Tavily, Firecrawl, provider fallback, and web-search-config. web_search and web_fetch now use Exa-shaped inputs and return raw Exa-style details.
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { createWebFetchTool } from "./web-fetch.ts";
|
|
|
|
test("createWebFetchTool passes Exa getContents options through without injecting default text", async () => {
|
|
let captured: any;
|
|
|
|
const tool = createWebFetchTool({
|
|
async executeFetch(request) {
|
|
captured = request;
|
|
return {
|
|
requestId: "req-fetch-1",
|
|
results: [],
|
|
};
|
|
},
|
|
});
|
|
|
|
await tool.execute("tool-call", {
|
|
urls: ["https://pi.dev"],
|
|
summary: true,
|
|
extras: {
|
|
links: 5,
|
|
},
|
|
} as any);
|
|
|
|
assert.deepEqual(captured, {
|
|
urls: ["https://pi.dev/"],
|
|
summary: true,
|
|
extras: {
|
|
links: 5,
|
|
},
|
|
});
|
|
});
|
|
|
|
test("createWebFetchTool supports the single-url alias", async () => {
|
|
let captured: any;
|
|
|
|
const tool = createWebFetchTool({
|
|
async executeFetch(request) {
|
|
captured = request;
|
|
return {
|
|
requestId: "req-fetch-1",
|
|
results: [],
|
|
};
|
|
},
|
|
});
|
|
|
|
const prepared = tool.prepareArguments({ url: "https://exa.ai" });
|
|
await tool.execute("tool-call", prepared as any);
|
|
|
|
assert.deepEqual(captured, {
|
|
urls: ["https://exa.ai/"],
|
|
});
|
|
});
|
|
|
|
test("createWebFetchTool rejects invalid urls", async () => {
|
|
const tool = createWebFetchTool({
|
|
async executeFetch() {
|
|
throw new Error("not used");
|
|
},
|
|
});
|
|
|
|
await assert.rejects(() => tool.execute("tool-call", { urls: ["notaurl"] } as any), /Invalid URL: notaurl/);
|
|
});
|