donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
54 lines • 2.56 kB
TypeScript
import type { TargetInspector } from '../managers/TargetInspector';
import type { ControlPanel } from '../models/ControlPanel';
import type { CreateDonobuFlow } from '../models/CreateDonobuFlow';
import type { FlowMetadata } from '../models/FlowMetadata';
import type { ProposedToolCall } from '../models/ProposedToolCall';
/**
* Encapsulates target-specific lifecycle and configuration for a single flow.
*
* {@link DonobuFlowsManager.createFlow} resolves a `TargetRuntime`, calls its
* methods generically, and never branches on target type. New platforms
* (desktop, etc.) implement this interface and register via the plugin system.
*
* Lifecycle:
* 1. The {@link TargetRuntimePlugin} validates flow params and creates a
* `TargetRuntime` (which may start sessions, create browser contexts, etc.).
* 2. `createFlow()` reads {@link inspector}, {@link controlPanel},
* {@link getMetadataFields}, {@link getInitialToolCalls}, and
* {@link videoDir} to set up the flow.
* 3. When the flow completes (or errors), `createFlow()` calls
* {@link destroy} to clean up all resources.
*/
export interface TargetRuntime {
/** Target type identifier for tool filtering (e.g. `'web'`, `'mobile'`). */
readonly targetType: string;
/** Inspector bound to the live session (browser page, mobile device, etc.). */
readonly inspector: TargetInspector;
/** Control panel for this flow. {@link NoOpControlPanel} if unsupported. */
readonly controlPanel: ControlPanel;
/**
* Target-specific fields to spread into {@link FlowMetadata}.
*
* Each target returns a `target` discriminant plus a target-specific config
* block — e.g. `{ target: 'web', web: { browser, targetWebsite } }`.
*/
getMetadataFields(): Partial<FlowMetadata>;
/**
* Initial tool calls when no `toolCallsOnStart` is provided by the caller.
*
* For example, the web target returns a `GoToWebpage` call.
*/
getInitialToolCalls(flowParams: CreateDonobuFlow): ProposedToolCall[];
/**
* Temp directory for video recording, or `undefined` if this target does
* not support video. When defined, the runtime is responsible for saving
* the video and cleaning up the directory in {@link destroy}.
*/
readonly videoDir: string | undefined;
/**
* Tear down the session, save video (if applicable), and clean up all
* resources. Called in the `finally` block of `createFlow()`.
*/
destroy(): Promise<void>;
}
//# sourceMappingURL=TargetRuntime.d.ts.map