import { z } from "zod"; import { type AgentPageSessionManager } from "./agent-page-session.js"; import { discoverAgentRequest, discoverAgentRequestFromContext } from "./agent-browser-discovery.js"; import { loadAgentMemory, saveAgentMemoryEntry, searchAgentMemory } from "./agent-memory.js"; import { executeAgentMemoryRequest } from "./agent-request.js"; import type { AgentMemoryEntry, DiscoveredRequestCandidate, PageSessionState, SavedAuthUser, SemanticMemoryEntry, SerializedCookie } from "./types.js"; type AgentPageToolDependencies = { capturePageScreenshot: AgentPageSessionManager["capturePageScreenshot"]; closePage: AgentPageSessionManager["closePage"]; inspectDom: AgentPageSessionManager["inspectDom"]; inspectNetworkRequest: AgentPageSessionManager["inspectNetworkRequest"]; interactPage: AgentPageSessionManager["interactPage"]; listNetworkRequests: AgentPageSessionManager["listNetworkRequests"]; listOpenPages: AgentPageSessionManager["listOpenPages"]; openPage: AgentPageSessionManager["openPage"]; searchNetworkRequests: AgentPageSessionManager["searchNetworkRequests"]; }; export interface AgentToolDependencies extends AgentPageToolDependencies { discoverFromContext: typeof discoverAgentRequestFromContext; discoverFromPage: typeof discoverAgentRequest; executeRequest: typeof executeAgentMemoryRequest; loadMemory: typeof loadAgentMemory; saveMemory: typeof saveAgentMemoryEntry; searchMemory: typeof searchAgentMemory; } export interface AgentToolCallEvent { input: unknown; toolName: string; } export interface AgentToolResultEvent { durationMs: number; output?: unknown; status: "failed" | "succeeded"; toolName: string; } interface AgentToolRuntimeHelpers { __closePageSessions?: () => Promise; __getPageSessionState?: () => Promise; } interface AgentToolOptions { appendConversation?: (entry: SemanticMemoryEntry) => Promise; cookies: SerializedCookie[]; dependencies?: Partial; headed?: boolean; homeDir: string; onDiscoveryExecuted?: (payload: { candidate: DiscoveredRequestCandidate; entry: AgentMemoryEntry; response: unknown; }) => Promise | void; onDiscoveryInspected?: (payload: { candidate: DiscoveredRequestCandidate; response: unknown; }) => Promise | void; onDiscoveryMemorySaved?: (payload: { candidate: DiscoveredRequestCandidate; entry: AgentMemoryEntry; }) => Promise | void; onMemoryReplayed?: (payload: { entry: AgentMemoryEntry; response: unknown; }) => Promise | void; onPageConfirmed?: (pageUrl: string) => void; onToolCall?: (event: AgentToolCallEvent) => Promise | void; onToolResult?: (event: AgentToolResultEvent) => Promise | void; promptUser: (message: string) => Promise; user: SavedAuthUser; } export declare function sanitizeAgentToolData(value: unknown, depth?: number): unknown; export declare function createAgentTools(options: AgentToolOptions, dependencyOverrides?: Partial): { memory: { description: string; execute?: ((input: { command: "create" | "search" | "update" | "view"; document: "conversations" | "core" | "notes"; scope: "user" | "global"; content?: string | undefined; mode?: "overwrite" | "append" | undefined; query?: string | undefined; }) => { content: unknown; document: "conversations" | "core" | "notes"; scope: "user" | "global"; matches?: undefined; reason?: undefined; updated?: undefined; preview?: undefined; } | { document: "conversations" | "core" | "notes"; matches: unknown; scope: "user" | "global"; content?: undefined; reason?: undefined; updated?: undefined; preview?: undefined; } | { document: "conversations"; reason: string; scope: "user" | "global"; updated: boolean; content?: undefined; matches?: undefined; preview?: undefined; } | { document: "core" | "notes"; reason: string; scope: "user" | "global"; updated: boolean; content?: undefined; matches?: undefined; preview?: undefined; } | { document: "core" | "notes"; preview: string; scope: "user" | "global"; updated: boolean; content?: undefined; matches?: undefined; reason?: undefined; } | Promise<{ content: unknown; document: "conversations" | "core" | "notes"; scope: "user" | "global"; matches?: undefined; reason?: undefined; updated?: undefined; preview?: undefined; } | { document: "conversations" | "core" | "notes"; matches: unknown; scope: "user" | "global"; content?: undefined; reason?: undefined; updated?: undefined; preview?: undefined; } | { document: "conversations"; reason: string; scope: "user" | "global"; updated: boolean; content?: undefined; matches?: undefined; preview?: undefined; } | { document: "core" | "notes"; reason: string; scope: "user" | "global"; updated: boolean; content?: undefined; matches?: undefined; preview?: undefined; } | { document: "core" | "notes"; preview: string; scope: "user" | "global"; updated: boolean; content?: undefined; matches?: undefined; reason?: undefined; }>) | undefined; inputSchema: z.ZodObject<{ command: z.ZodEnum<{ create: "create"; search: "search"; update: "update"; view: "view"; }>; content: z.ZodOptional; document: z.ZodEnum<{ conversations: "conversations"; core: "core"; notes: "notes"; }>; mode: z.ZodOptional>; query: z.ZodOptional; scope: z.ZodEnum<{ user: "user"; global: "global"; }>; }, z.core.$strip>; }; searchMemory: { description: string; execute?: ((input: { query: string; }) => { matches: { id: string; intentExamples: string[]; keywords: string[]; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; }; responseGuide: string; }[]; } | Promise<{ matches: { id: string; intentExamples: string[]; keywords: string[]; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; }; responseGuide: string; }[]; }>) | undefined; inputSchema: z.ZodObject<{ query: z.ZodString; }, z.core.$strip>; }; replayMemoryRequest: { description: string; execute?: ((input: { memoryId: string; }) => { found: boolean; memoryId: string; entry?: undefined; responseBody?: undefined; } | { entry: { id: string; intentExamples: string[]; keywords: string[]; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; }; responseGuide: string; }; found: boolean; responseBody: unknown; memoryId?: undefined; } | Promise<{ found: boolean; memoryId: string; entry?: undefined; responseBody?: undefined; } | { entry: { id: string; intentExamples: string[]; keywords: string[]; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; }; responseGuide: string; }; found: boolean; responseBody: unknown; memoryId?: undefined; }>) | undefined; inputSchema: z.ZodObject<{ memoryId: z.ZodString; }, z.core.$strip>; }; discoverFromContext: { description: string; execute?: ((input: { objective: string; }) => { reason: string; resolved: boolean; candidates?: undefined; domEvidence?: undefined; pagePath?: undefined; } | { candidates: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }[]; domEvidence: import("./types.js").PageDomEvidence; pagePath: string; resolved: boolean; reason?: undefined; } | Promise<{ reason: string; resolved: boolean; candidates?: undefined; domEvidence?: undefined; pagePath?: undefined; } | { candidates: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }[]; domEvidence: import("./types.js").PageDomEvidence; pagePath: string; resolved: boolean; reason?: undefined; }>) | undefined; inputSchema: z.ZodObject<{ objective: z.ZodString; }, z.core.$strip>; }; discoverFromPage: { description: string; execute?: ((input: { objective: string; pageUrl: string; }) => { candidates: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }[]; domEvidence: import("./types.js").PageDomEvidence; pagePath: string; resolved: boolean; } | Promise<{ candidates: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }[]; domEvidence: import("./types.js").PageDomEvidence; pagePath: string; resolved: boolean; }>) | undefined; inputSchema: z.ZodObject<{ objective: z.ZodString; pageUrl: z.ZodString; }, z.core.$strip>; }; inspectDiscoveryCandidate: { description: string; execute?: ((input: { candidateId: string; }) => { candidateId: string; inspected: boolean; candidate?: undefined; responseBody?: undefined; } | { candidate: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }; inspected: boolean; responseBody: unknown; candidateId?: undefined; } | Promise<{ candidateId: string; inspected: boolean; candidate?: undefined; responseBody?: undefined; } | { candidate: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }; inspected: boolean; responseBody: unknown; candidateId?: undefined; }>) | undefined; inputSchema: z.ZodObject<{ candidateId: z.ZodString; }, z.core.$strip>; }; executeDiscoveryRequest: { description: string; execute?: ((input: { candidateId: string; }) => { candidateId: string; executed: boolean; candidate?: undefined; responseBody?: undefined; } | { candidate: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }; executed: boolean; responseBody: unknown; candidateId?: undefined; } | Promise<{ candidateId: string; executed: boolean; candidate?: undefined; responseBody?: undefined; } | { candidate: { candidateId: string; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; body?: {} | null | undefined; }; requestKeySummary: string[]; responseGuide: string; responseKeySummary: string[]; selectedRequestSummary: string; }; executed: boolean; responseBody: unknown; candidateId?: undefined; }>) | undefined; inputSchema: z.ZodObject<{ candidateId: z.ZodString; }, z.core.$strip>; }; saveDiscoveryMemory: { description: string; execute?: ((input: { candidateId: string; intent: string; keywords: string[]; responseGuide?: string | undefined; }) => { candidateId: string; saved: boolean; entry?: undefined; } | { entry: { id: string; intentExamples: string[]; keywords: string[]; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; }; responseGuide: string; }; saved: boolean; candidateId?: undefined; } | Promise<{ candidateId: string; saved: boolean; entry?: undefined; } | { entry: { id: string; intentExamples: string[]; keywords: string[]; pagePath: string; readOnlyConfirmed: boolean; request: { method: import("./types.js").AgentRequestMethod; relativePath: string; }; responseGuide: string; }; saved: boolean; candidateId?: undefined; }>) | undefined; inputSchema: z.ZodObject<{ candidateId: z.ZodString; intent: z.ZodString; keywords: z.ZodArray; responseGuide: z.ZodOptional; }, z.core.$strip>; }; requestUserInput: { description: string; execute?: ((input: { message: string; }) => { userInput: string; } | Promise<{ userInput: string; }>) | undefined; inputSchema: z.ZodObject<{ message: z.ZodString; }, z.core.$strip>; }; listOpenPages: { description: string; execute?: ((input: Record) => PageSessionState | Promise) | undefined; inputSchema: z.ZodObject<{}, z.core.$strip>; }; openPage: { description: string; execute?: ((input: { pageUrl: string; }) => import("./types.js").OpenPageSummary | Promise) | undefined; inputSchema: z.ZodObject<{ pageUrl: z.ZodString; }, z.core.$strip>; }; closePage: { description: string; execute?: ((input: { pageId: string; }) => { closed: boolean; pageId: string; } | Promise<{ closed: boolean; pageId: string; }>) | undefined; inputSchema: z.ZodObject<{ pageId: z.ZodString; }, z.core.$strip>; }; inspectDom: { description: string; execute?: ((input: { pageId?: string | undefined; }) => import("./types.js").DomInspectionResult | Promise) | undefined; inputSchema: z.ZodObject<{ pageId: z.ZodOptional; }, z.core.$strip>; }; interactPage: { description: string; execute?: ((input: { actions: ({ type: "click"; targetId?: string | undefined; text?: string | undefined; } | { type: "fill"; value: string; targetId?: string | undefined; text?: string | undefined; } | { key: string; type: "press"; targetId?: string | undefined; text?: string | undefined; } | { type: "hover"; targetId?: string | undefined; text?: string | undefined; } | { text: string; type: "waitForText"; } | { type: "waitForNetworkIdle"; })[]; pageId?: string | undefined; }) => { pageId: string; pageUrl: string; performedActions: import("./types.js").PageInteractionAction[]; } | Promise<{ pageId: string; pageUrl: string; performedActions: import("./types.js").PageInteractionAction[]; }>) | undefined; inputSchema: z.ZodObject<{ actions: z.ZodArray; text: z.ZodOptional; type: z.ZodLiteral<"click">; }, z.core.$strip>, z.ZodObject<{ targetId: z.ZodOptional; text: z.ZodOptional; type: z.ZodLiteral<"fill">; value: z.ZodString; }, z.core.$strip>, z.ZodObject<{ key: z.ZodString; targetId: z.ZodOptional; text: z.ZodOptional; type: z.ZodLiteral<"press">; }, z.core.$strip>, z.ZodObject<{ targetId: z.ZodOptional; text: z.ZodOptional; type: z.ZodLiteral<"hover">; }, z.core.$strip>, z.ZodObject<{ text: z.ZodString; type: z.ZodLiteral<"waitForText">; }, z.core.$strip>, z.ZodObject<{ type: z.ZodLiteral<"waitForNetworkIdle">; }, z.core.$strip>], "type">>; pageId: z.ZodOptional; }, z.core.$strip>; }; listNetworkRequests: { description: string; execute?: ((input: { pageId?: string | undefined; }) => { pageId: string; requests: import("./types.js").NetworkRequestCatalogItem[]; } | Promise<{ pageId: string; requests: import("./types.js").NetworkRequestCatalogItem[]; }>) | undefined; inputSchema: z.ZodObject<{ pageId: z.ZodOptional; }, z.core.$strip>; }; searchNetworkRequests: { description: string; execute?: ((input: { query: string; pageId?: string | undefined; }) => { matches: import("./types.js").NetworkRequestSearchMatch[]; pageId: string; } | Promise<{ matches: import("./types.js").NetworkRequestSearchMatch[]; pageId: string; }>) | undefined; inputSchema: z.ZodObject<{ pageId: z.ZodOptional; query: z.ZodString; }, z.core.$strip>; }; inspectNetworkRequest: { description: string; execute?: ((input: { requestId: string; pageId?: string | undefined; }) => { request: import("./types.js").NetworkRequestCatalogItem; responseBody?: unknown; } | Promise<{ request: import("./types.js").NetworkRequestCatalogItem; responseBody?: unknown; }>) | undefined; inputSchema: z.ZodObject<{ pageId: z.ZodOptional; requestId: z.ZodString; }, z.core.$strip>; }; capturePageScreenshot: { description: string; execute?: ((input: { height?: number | undefined; offsetY?: number | undefined; pageId?: string | undefined; }) => import("./types.js").PageScreenshotResult | Promise) | undefined; inputSchema: z.ZodObject<{ height: z.ZodOptional; offsetY: z.ZodOptional; pageId: z.ZodOptional; }, z.core.$strip>; }; } & AgentToolRuntimeHelpers; export {}; //# sourceMappingURL=agent-tools.d.ts.map