UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

78 lines 5.2 kB
import { TestFixture } from '@playwright/test'; import type { Page } from '@playwright/test'; import { FlowMetadata } from './models/FlowMetadata'; import { BrowserStorageState } from './models/BrowserStorageState'; import { BrowserStateReference } from './models/BrowserStateFlowReference'; import { ToolCallResult } from './models/ToolCallResult'; import { AnalyzePageTextToolCoreParameters } from './tools/AnalyzePageTextTool'; import { AssertToolCoreParameters } from './tools/AssertTool'; import { GptClient } from './clients/GptClient'; import { SelectorBasedChooseSelectOptionToolParameters } from './tools/ChooseSelectOptionTool'; import { SelectorBasedInputRandomizedEmailAddressToolParameters } from './tools/InputRandomizedEmailAddressTool'; import { SelectorBasedInputTextToolParameters } from './tools/InputTextTool'; import { SelectorBasedPressKeyToolParameters } from './tools/PressKeyTool'; import { ScrollPageToolCoreParameters } from './tools/ScrollPageTool'; import { SelectorBasedHoverOverElementToolParameters } from './tools/HoverOverElementTool'; import { SelectorBasedClickToolParameters } from './tools/ClickTool'; import { LanguageModel } from 'ai'; import { AssertPageTextToolCoreParameters } from './tools/AssertPageTextTool'; import { DonobuStack } from './managers/DonobuStack'; /** * Extends the Page object with additional test-related methods. */ interface DonobuExtendedPage extends Page { run(toolName: string, toolParams?: any): Promise<ToolCallResult>; analyzePageText(params: AnalyzePageTextToolCoreParameters): Promise<ToolCallResult>; assertPageText(params: AssertPageTextToolCoreParameters): Promise<ToolCallResult>; chooseSelectOption(params: SelectorBasedChooseSelectOptionToolParameters): Promise<ToolCallResult>; clickElement(params: SelectorBasedClickToolParameters): Promise<ToolCallResult>; createCookieReport(): Promise<ToolCallResult>; detectBrokenLinks(): Promise<ToolCallResult>; hoverOverElement(params: SelectorBasedHoverOverElementToolParameters): Promise<ToolCallResult>; inputRandomizedEmailAddress(params: SelectorBasedInputRandomizedEmailAddressToolParameters): Promise<ToolCallResult>; inputText(params: SelectorBasedInputTextToolParameters): Promise<ToolCallResult>; pressKey(params: SelectorBasedPressKeyToolParameters): Promise<ToolCallResult>; runAccessibilityTest(): Promise<ToolCallResult>; scroll(params: ScrollPageToolCoreParameters): Promise<ToolCallResult>; visuallyAssert(params: AssertToolCoreParameters): Promise<ToolCallResult>; _donobuFlowMetadata: FlowMetadata; } export declare function getOrCreateDonobuStack(): Promise<DonobuStack>; export declare function getBrowserStorageState(flowIdOrName: BrowserStateReference): Promise<BrowserStorageState>; export declare function getBrowserStorageStateFixture(flowIdOrName: BrowserStateReference): TestFixture<BrowserStorageState, any>; export declare function anthropicClient(modelName: string, apiKey?: string): Promise<GptClient>; export declare function anthropicClientFixture(modelName: string, apiKey?: string): TestFixture<GptClient, any>; export declare function anthropicAwsBedrockClient(modelName: string, region: string, accessKeyId?: string, secretAccessKey?: string): Promise<GptClient>; export declare function anthropicAwsBedrockClientFixture(modelName: string, region: string, accessKeyId?: string, secretAccessKey?: string): TestFixture<GptClient, any>; export declare function googleGeminiClient(modelName: string, apiKey?: string): Promise<GptClient>; export declare function googleGeminiClientFixture(modelName: string, apiKey?: string): TestFixture<GptClient, any>; export declare function openAiClient(modelName: string, apiKey?: string): Promise<GptClient>; export declare function openAiClientFixture(modelName: string, apiKey?: string): TestFixture<GptClient, any>; export declare function vercelAiClientFixture(model: LanguageModel): TestFixture<GptClient, any>; /** * This fixture resolves a GPT client based on environment variables. * Supplying different environment variables will result in different GPT * clients being created. Here is a mapping of client type to environment * variables for how to create the various types of clients... * * Anthropic GPT client requires: * - ANTHROPIC_API_KEY * * Google GPT client requires: * - GOOGLE_GENERATIVE_AI_API_KEY * * OpenAI GPT client requires: * - OPENAI_API_KEY * * If the modelName is not specified, it will be defaulted according to the * DEFAULT_GPT_MODEL_FOR_PLATFORM mapping. */ export declare function gptClient(modelName?: string): Promise<GptClient>; export declare function gptClientFixture(modelName?: string): TestFixture<GptClient, any>; export * from 'playwright/test'; export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & { storageState?: BrowserStorageState | Promise<BrowserStorageState>; gptClient?: GptClient; page: DonobuExtendedPage; }, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions>; //# sourceMappingURL=test.d.ts.map