UNPKG

donobu

Version:

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

70 lines 3.45 kB
import type { Request, Response } from 'express'; import type { FlowsPersistenceRegistry } from '../persistence/flows/FlowsPersistenceRegistry'; /** * API controller for serving flow-related binary files including images, video, * and arbitrary file attachments. * * The FlowsFilesApi provides HTTP endpoints for retrieving binary assets associated with * Donobu flows — screenshots, video recordings, and generic files (e.g. treatment plans) * stored via {@link FlowsPersistence.setFlowFile}. This class handles proper content type * detection, HTTP range requests for video streaming, and multi-layer persistence fallback * for file retrieval. */ export declare class FlowsFilesApi { private readonly flowsPersistenceRegistry; constructor(flowsPersistenceRegistry: FlowsPersistenceRegistry); /** * Retrieves and serves a flow-related image file (screenshot). * * This endpoint serves screenshot images captured during flow execution. The method: * 1. Iterates through all available persistence layers in priority order * 2. Attempts to locate the requested image in each layer * 3. Automatically detects the image format (PNG/JPEG) and sets appropriate Content-Type * 4. Returns 404 if the image is not found in any persistence layer * * **Supported Image Formats:** * - PNG (`image/png`) * - JPEG (`image/jpeg`) * * @throws {FlowNotFoundException} When the flow doesn't exist in any persistence layer */ getFlowImage(req: Request, res: Response): Promise<void>; /** * Retrieves and serves flow video recordings with HTTP range request support. * * This endpoint serves video recordings of flow executions, typically in WebM format. * The method supports HTTP range requests for efficient video streaming and seeking, * allowing clients to request specific byte ranges of large video files. * * **Key Features:** * - HTTP Range Request support for video streaming * - Automatic Content-Type detection (typically `video/webm`) * - Partial content responses (HTTP 206) for range requests * - Multi-layer persistence fallback * - Proper Accept-Ranges header for client compatibility * * **Range Request Handling:** * - Parses Range header to determine requested byte range * - Supports single-range requests (e.g., `bytes=0-1023`) * - Supports open-ended ranges (e.g., `bytes=1024-`) * - Returns appropriate Content-Range header for partial responses * - Falls back to full video if no Range header is provided * * @throws {FlowNotFoundException} When the flow doesn't exist in any persistence layer */ getFlowVideo(req: Request, res: Response): Promise<void>; getFlowState(req: Request, res: Response): Promise<void>; /** * Retrieves an arbitrary file stored against a flow by its file ID. * * This endpoint serves any file previously persisted via * {@link FlowsPersistence.setFlowFile}, such as treatment plans or other * attachments. The Content-Type is inferred from the file ID extension; * when the extension is unrecognised it falls back to * `application/octet-stream`. * * @throws {FlowNotFoundException} When the flow doesn't exist in any persistence layer */ getFlowFile(req: Request, res: Response): Promise<void>; } //# sourceMappingURL=FlowsFilesApi.d.ts.map