agents
Version:
A home for your AI agents
73 lines (71 loc) • 2.24 kB
TypeScript
import {
n as BrowserToolOptions,
r as BrowserToolOutput,
t as BrowserToolInput
} from "./browser-tool-Cxtiwfua.js";
import { FlexibleSchema, JSONValue } from "ai";
//#region src/browser/tool-helpers.d.ts
/** What the model sees in place of a browser tool's output. */
type BrowserModelOutput =
| {
type: "text";
value: string;
}
| {
type: "json";
value: JSONValue;
};
//#endregion
//#region src/browser/tools/ai-sdk.d.ts
/**
* The AI SDK tool {@link browserTool} returns. Assignable to the AI SDK's
* `Tool`, and `execute` / `toModelOutput` are always present.
*/
interface BrowserTool {
description: string;
inputSchema: FlexibleSchema<BrowserToolInput>;
execute(
input: BrowserToolInput,
options: unknown
): Promise<BrowserToolOutput>;
toModelOutput(options: { output: BrowserToolOutput }): BrowserModelOutput;
}
/**
* Create an AI SDK tool that lets the model drive a persistent browser with
* JavaScript and the Chrome DevTools Protocol.
*
* The browser outlives each run: tabs, cookies, and logins carry over. The
* model never starts, closes, or resets it, and `sessionId: "active"`
* addresses the tab it last worked in. If the browser had to be replaced
* (it expired or was closed), the code still runs in the new browser and the
* result's `notice` says so.
*
* Browser Run only (Chromium). Guardrails, `keepAliveMs`, and recording are
* set on the `Browser`'s provider.
*
* @example
* ```ts
* import { Browser, browserRun } from "agents/browser";
* import { browserTool } from "agents/browser/ai-sdk";
*
* export class MyAgent extends Agent<Env> {
* browser = new Browser({ provider: browserRun(this.env.BROWSER) });
*
* constructor(ctx: AgentContext, env: Env) {
* super(ctx, env);
* this.lifecycle.use(this.browser);
* }
*
* async onChatMessage() {
* const tools = {
* browser: browserTool({ browser: this.browser, loader: this.env.LOADER })
* };
* // …pass `tools` to streamText / generateText
* }
* }
* ```
*/
declare function browserTool(options: BrowserToolOptions): BrowserTool;
//#endregion
export { browserTool as n, BrowserTool as t };
//# sourceMappingURL=ai-sdk-CpuRsjP5.d.ts.map