UNPKG

agents

Version:

A home for your AI agents

86 lines (84 loc) • 2.65 kB
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 { ToolRegistration } from "@earendil-works/pi-durable"; //#region src/web/fetch/tools/pi.d.ts /** The model's input schema. pi already coerces `"20000"` to `20000`. */ declare function webFetchParameters(): import("@earendil-works/pi-schema").Schema<{ url: string; offset?: number | undefined; format?: "auto" | "raw" | undefined; }>; type WebFetchParameters = ReturnType<typeof webFetchParameters>; /** * Host-side details pi stores with each `web_fetch` result: the output (the * window the model read, with the page's metadata) or the failure. */ type WebFetchToolDetails = | { ok: true; output: WebFetchToolOutput; } | { ok: false /** The source's error message, with the detail for the host. */; message: string; status: number; code: WebFetchErrorCode; retryable: boolean; url?: string /** The response's media type, when a response was read. */; contentType?: string; }; /** * Create a pi tool that reads a URL as Markdown, JSON, or text. Install it * on a registry like any other pi tool. * * The model chooses the URL, the window (`offset`), and the format; the * host chooses the URL policy, size limits, and window size. The tool is * `replay: "safe"`: a fetch interrupted mid-call (say, by an eviction) runs * again when the session recovers. Completed results are stored and not * fetched again. * * @example * ```ts * import { createRegistry, Harness } from "@earendil-works/pi-durable"; * import { webFetchTool } from "agents/webfetch/pi"; * * // In PiHarness's factory, so each object gets its own registry. * harness: ({ storage, context, onWake }) => { * const registry = createRegistry(); * registry.install({ * name: "tools", * tools: [webFetchTool({ binding: this.env.AI })] * }); * return Harness.open(storage, { models, registry, onWake }, context); * } * ``` */ declare function webFetchTool( options: WebFetchToolOptions ): ToolRegistration<WebFetchParameters, WebFetchToolDetails>; //#endregion export { WebFetchError, type WebFetchErrorCode, type WebFetchFormat, type WebFetchPage, type WebFetchRequest, type WebFetchSource, WebFetchToolDetails, type WebFetchToolInput, type WebFetchToolOptions, type WebFetchToolOutput, type WebFetchVia, webFetchTool }; //# sourceMappingURL=pi.d.ts.map