donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
103 lines • 4.11 kB
TypeScript
import type { AiQuery } from '../../models/AiQuery';
import type { BrowserStorageState } from '../../models/BrowserStorageState';
import type { FlowMetadata, FlowsQuery } from '../../models/FlowMetadata';
import type { PaginatedResult } from '../../models/PaginatedResult';
import type { ToolCall } from '../../models/ToolCall';
import type { VideoSegment } from '../../models/VideoSegment';
/**
* Interface for persisting data relating to DonobuFlow runs.
*/
export interface FlowsPersistence {
/**
* Set the given FlowMetadata for the associated flow. It can be looked up by
* its {@link FlowMetadata.id}.
*/
setFlowMetadata(flowMetadata: FlowMetadata): Promise<void>;
/**
* Load metadata for a specific flow by its ID.
* @throws FlowNotFoundException if the flow is not found
*/
getFlowMetadataById(flowId: string): Promise<FlowMetadata>;
/**
* Load metadata by a given flow name. If there are multiple flows with
* the same name, the one with the latest `startedAt` timestamp will be
* returned.
* @throws FlowNotFoundException if the flow is not found
*/
getFlowMetadataByName(flowName: string): Promise<FlowMetadata>;
/**
* Get flows' metadata matching a given query.
*/
getFlowsMetadata(query: FlowsQuery): Promise<PaginatedResult<FlowMetadata>>;
/**
* Save a screenshot for a specific flow. Supports PNG and JPEG images.
* @returns The identifier for the saved screenshot
*/
saveScreenShot(flowId: string, bytes: Buffer): Promise<string>;
/**
* Loads a screenshot. The returned image may be in PNG or a JPEG format.
*/
getScreenShot(flowId: string, screenShotId: string): Promise<Buffer | null>;
/**
* Save a tool call for a specific flow.
*/
setToolCall(flowId: string, toolCall: ToolCall): Promise<void>;
/**
* Load all tool calls for a specific flow.
* @throws FlowNotFoundException if the flow is not found
*/
getToolCalls(flowId: string): Promise<ToolCall[]>;
/**
* Delete a persisted tool call from a specific flow.
*/
deleteToolCall(flowId: string, toolCallId: string): Promise<void>;
/**
* Save an AI query record for a specific flow.
*/
setAiQuery(flowId: string, aiQuery: AiQuery): Promise<void>;
/**
* Load all AI query records for a specific flow, ordered by queriedAt.
* @throws FlowNotFoundException if the flow is not found
*/
getAiQueries(flowId: string): Promise<AiQuery[]>;
/**
* Set video data for a specific flow.
*/
setVideo(flowId: string, bytes: Buffer): Promise<void>;
/**
* Get a video segment for a specific flow.
* @throws FlowNotFoundException if the flow is not found
*/
getVideoSegment(flowId: string, startOffset: number, length: number): Promise<VideoSegment | null>;
/**
* Get a file associated with a specific flow.
*
* @throws FlowNotFoundException if the flow is not found.
*/
getFlowFile(flowId: string, fileId: string): Promise<Buffer | null>;
/**
* Set a file for a specific flow.
*/
setFlowFile(flowId: string, fileId: string, fileBytes: Buffer): Promise<void>;
/**
* Sets the given browser state for a specific flow.
*
* WARNING: This will NOT override the runtime browser state for a flow that
* is currently running. This is only for persisting the browser state for a
* flow that has completed so that it can be used by other flows in the
* future.
*/
setBrowserState(flowId: string, browserState: BrowserStorageState): Promise<void>;
/**
* Get the browser state for a specific flow. Note that not all flows will
* have an associated persisted browser state.
*
* @throws FlowNotFoundException if the flow is not found.
*/
getBrowserState(flowId: string): Promise<BrowserStorageState | null>;
/**
* Delete a specific flow and all associated data.
*/
deleteFlow(flowId: string): Promise<void>;
}
//# sourceMappingURL=FlowsPersistence.d.ts.map