agents
Version:
A home for your AI agents
88 lines (86 loc) • 2.77 kB
TypeScript
import {
C as WebSearchResponse,
E as WebSearchToolOutput,
T as WebSearchToolInput,
c as WebSearchError,
d as WebSearchProvider,
l as WebSearchErrorCode,
p as WebSearchSource,
r as WebSearchToolOptions,
w as WebSearchResult
} from "../../../tool-CTp72Jb_.js";
import { ToolRegistration } from "@earendil-works/pi-durable";
//#region src/web/search/tools/pi.d.ts
/**
* The model's input schema. The description tells the model the host's
* `limit`; a larger value is not rejected (which would cost a validation
* round trip) but capped by the core. pi already coerces `"5"` to `5`.
*/
declare function webSearchParameters(
maxLimit: number
): import("@earendil-works/pi-schema").Schema<{
query: string;
limit?: number | undefined;
}>;
type WebSearchParameters = ReturnType<typeof webSearchParameters>;
/**
* Host-side details pi stores with each `web_search` result: the full API
* response (untrimmed descriptions, provider metadata) or the failure.
*/
type WebSearchToolDetails =
| {
ok: true;
output: WebSearchToolOutput;
}
| {
ok: false /** The source's error message, with the API's detail. */;
message: string;
status: number;
code: WebSearchErrorCode;
retryable: boolean;
requestId?: string;
};
/**
* Create a pi tool that searches the web through Cloudflare's Web Search
* API. Install it on a registry like any other pi tool.
*
* The model chooses the query and (within the host's `limit`) how many
* results; the host chooses the gateway, provider, and billing. The tool is
* `replay: "safe"`: a search interrupted mid-call (say, by an eviction) runs
* again when the session recovers, which is a second billed search.
* Completed results are stored and not searched again.
*
* @example
* ```ts
* import { createRegistry, Harness } from "@earendil-works/pi-durable";
* import { webSearchTool } from "agents/websearch/pi";
*
* // In PiHarness's factory, so each object gets its own registry.
* harness: ({ storage, context, onWake }) => {
* const registry = createRegistry();
* registry.install({
* name: "tools",
* tools: [webSearchTool({ binding: this.env.AI, provider: "exa" })]
* });
* return Harness.open(storage, { models, registry, onWake }, context);
* }
* ```
*/
declare function webSearchTool(
options: WebSearchToolOptions
): ToolRegistration<WebSearchParameters, WebSearchToolDetails>;
//#endregion
export {
WebSearchError,
type WebSearchErrorCode,
type WebSearchProvider,
type WebSearchResponse,
type WebSearchResult,
type WebSearchSource,
WebSearchToolDetails,
type WebSearchToolInput,
type WebSearchToolOptions,
type WebSearchToolOutput,
webSearchTool
};
//# sourceMappingURL=pi.d.ts.map