UNPKG

donobu

Version:

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

93 lines 4.04 kB
import type { EnvPick } from 'env-struct'; import type { BrowserContext } from 'playwright'; import type { env } from '../envVars'; import type { InteractionVisualizer } from '../managers/InteractionVisualizer'; import type { BrowserStateReference } from '../models/BrowserStateFlowReference'; import type { BrowserStorageState } from '../models/BrowserStorageState'; import type { ControlPanelFactory } from '../models/ControlPanel'; import type { CreateDonobuFlow } from '../models/CreateDonobuFlow'; import type { TargetRuntime } from './TargetRuntime'; /** * Parameters passed to {@link TargetRuntimePlugin.createRuntime}. * * All runtimes receive the same bag of parameters and use what they need. * Optional fields (e.g. `browserContextOverride`) are only relevant to * specific targets and are safely ignored by others. */ export interface TargetRuntimeParams { flowParams: CreateDonobuFlow; flowId: string; interactionVisualizer: InteractionVisualizer; controlPanelFactory: ControlPanelFactory; environ: EnvPick<typeof env, 'BROWSERBASE_API_KEY' | 'BROWSERBASE_PROJECT_ID'>; /** * Pre-created browser context override. When present, the web runtime * uses this instead of creating a new browser context. Used by the * self-healing path to reuse the parent test's browser session. */ browserContextOverride?: BrowserContext; /** * Callback to resolve a {@link BrowserStorageState} from a reference. * Required by the web runtime when `flowParams.browser?.initialState` is set. */ getBrowserStorageState?: (ref: BrowserStateReference) => Promise<BrowserStorageState>; } /** * Static metadata returned by {@link TargetRuntimePlugin.describe} so the * frontend can discover available targets and render appropriate UI. */ export interface TargetDescriptor { /** Human-readable display name (e.g. "Web Browser", "Mobile Device"). */ label: string; /** Supported device/emulation names, if enumerable at startup. */ supportedDevices?: string[]; } /** * A target runtime plugin provides factories for creating * {@link TargetRuntime} instances for a specific target type. * * Plugins are registered with a string key matching the `target` field on * flow creation requests. They are self-contained — each plugin validates * its own configuration and manages its own lifecycle. * * The built-in `web` target is registered at startup. Additional targets * (e.g. `mobile`) are provided by plugins — see * {@link PluginModule.loadTargetRuntimePlugins}. */ export interface TargetRuntimePlugin { /** The target type string this plugin handles (e.g. `'web'`, `'mobile'`). */ type: string; /** * Return static metadata about this target for frontend discovery. * Called by `GET /api/targets`. */ describe(): TargetDescriptor; /** * Validate target-specific flow parameters. Throws * {@link InvalidParamValueException} on invalid configuration. * * Called before {@link createRuntime} to fail fast on bad input. */ validate(flowParams: CreateDonobuFlow): Promise<void>; /** * Create a live {@link TargetRuntime} for a flow. This may start sessions, * create browser contexts, provision devices, etc. * * The caller is responsible for calling {@link TargetRuntime.destroy} when * the flow completes or errors. */ createRuntime(params: TargetRuntimeParams): Promise<TargetRuntime>; } /** * An immutable registry of target runtime plugins, keyed by target type. * Created once at startup and threaded through the application. */ export declare class TargetRuntimePluginRegistry { private readonly plugins; constructor(plugins: TargetRuntimePlugin[]); /** Look up a registered target runtime plugin by target type. */ get(type: string): TargetRuntimePlugin | undefined; /** Return all registered target runtime plugins. */ getAll(): TargetRuntimePlugin[]; } //# sourceMappingURL=TargetRuntimePlugin.d.ts.map