agents
Version:
A home for your AI agents
81 lines (79 loc) • 2.46 kB
TypeScript
import {
S as WebFetchVia,
b as WebFetchToolInput,
c as WebFetchRequest,
l as WebFetchSource,
n as WebFetchToolOptions,
o as WebFetchError,
s as WebFetchErrorCode,
v as WebFetchFormat,
x as WebFetchToolOutput,
y as WebFetchPage
} from "../../../tool-DoVberpN.js";
import { FlexibleSchema } from "ai";
//#region src/web/fetch/tools/ai-sdk.d.ts
/**
* The part of the AI SDK's tool execution options the tool reads. Spelled
* out rather than imported so it fits every supported `ai` major.
*/
interface WebFetchToolExecuteOptions {
abortSignal?: AbortSignal;
}
/**
* The AI SDK tool {@link webFetchTool} returns. Assignable to the AI SDK's
* `Tool`; `execute` and `toModelOutput` are always present.
*/
interface WebFetchTool {
description: string;
inputSchema: FlexibleSchema<WebFetchToolInput>;
execute(
input: WebFetchToolInput,
options: WebFetchToolExecuteOptions
): Promise<WebFetchToolOutput>;
toModelOutput(options: { output: WebFetchToolOutput }): {
type: "text";
value: string;
};
}
/**
* Create an AI SDK tool that reads a URL as Markdown, JSON, or text. The
* tool's output is the window the model read plus the page's metadata
* (status, headers, redirects, total length), so it stays small in stored
* messages; `toModelOutput` renders it for the model. A failed fetch throws a `WebFetchError`, which
* the AI SDK reports to the model as a tool error: its `message` is written
* for the model, and its `cause` is the source's error with the detail.
*
* `toModelOutput` only applies to earlier turns when the tools are passed to
* `convertToModelMessages(messages, { tools })`; otherwise the AI SDK sends
* the output back to the model as JSON, without the header or the
* untrusted-content wrapper. `AiSdkHarness` passes them.
*
* @example
* ```ts
* import { webFetchTool } from "agents/webfetch/ai-sdk";
*
* const result = streamText({
* model,
* tools: { web_fetch: webFetchTool({ binding: env.AI }) },
* messages
* });
* ```
*/
declare function webFetchTool(options: WebFetchToolOptions): WebFetchTool;
//#endregion
export {
WebFetchError,
type WebFetchErrorCode,
type WebFetchFormat,
type WebFetchPage,
type WebFetchRequest,
type WebFetchSource,
WebFetchTool,
WebFetchToolExecuteOptions,
type WebFetchToolInput,
type WebFetchToolOptions,
type WebFetchToolOutput,
type WebFetchVia,
webFetchTool
};
//# sourceMappingURL=ai-sdk.d.ts.map