import { GptClient } from '../clients/GptClient';
import { DonobuFlow } from './DonobuFlow';
import { FlowMetadata } from '../models/FlowMetadata';
import { CreateDonobuFlow } from '../models/CreateDonobuFlow';
import { FlowsPersistenceFactory } from '../persistence/FlowsPersistenceFactory';
import { PaginatedFlowsResult } from '../persistence/FlowsPersistence';
import { ToolCall } from '../models/ToolCall';
import { BrowserStorageState } from '../models/BrowserStorageState';
import { BrowserStateReference } from '../models/BrowserStateFlowReference';
import { DonobuDeploymentEnvironment } from '../models/DonobuDeploymentEnvironment';
import { GptConfigsManager } from './GptConfigsManager';
import { AgentsManager } from './AgentsManager';
import { DonobuAgent } from '../models/DonobuAgentType';
import { FlowsQuery } from '../models/FlowsQuery';
/**
 * Response wrapper for `createFlow` calls.
 */
export interface FlowHandle {
    readonly donobuFlow: DonobuFlow;
    readonly job: Promise<void>;
}
export declare class DonobuFlowsManager {
    private readonly deploymentEnvironment;
    private readonly gptConfigsManager;
    private readonly agentsManager;
    private readonly flowsPersistenceFactory;
    private static readonly DEFAULT_TOOL_TIP_DURATION;
    private static readonly DEFAULT_MAX_ITERATIONS;
    private static readonly DEFAULT_BROWSER_CONFIG;
    static readonly DEFAULT_BROWSER_STATE_FILENAME = "browserstate.json";
    private readonly activeFlows;
    private readonly codeGenerator;
    constructor(deploymentEnvironment: DonobuDeploymentEnvironment, gptConfigsManager: GptConfigsManager, agentsManager: AgentsManager, flowsPersistenceFactory: FlowsPersistenceFactory);
    /**
     * Create a flow with the given parameters and invoke its `DonobuFlow#run`
     * method, adding it to list of active flows.
     */
    createFlow(flowParams: CreateDonobuFlow): Promise<FlowHandle>;
    /**
     * Loads the given flow by ID and returns a `CreateDonobuFlow` object that can be passed to `createFlow`
     * as to execute the flow as a rerun (i.e. without agentic decisioning).
     *
     * @param flowId The ID of the flow to prepare as a rerun.
     * @returns Parameters that can be passed to createFlow to execute the flow as a rerun.
     */
    getFlowAsRerun(flowId: string): Promise<CreateDonobuFlow>;
    /** Add a proposed tool call the tool call queue for the given flow by ID. */
    proposeToolCall(flowId: string, toolName: string, parameters: Record<string, unknown>): Promise<void>;
    /**
     * If the application is running in a non-hosted context, returns a direct,
     * raw, `DonobuFlow` object by ID. If there is no flow in an active state
     * with the given ID, or the application is running on some far flung server,
     * then `ActiveFlowNotFoundException` is thrown. Mutations made to the
     * returned object will be reflected by the active flow, and vice versa.
     */
    getActiveFlow(flowId: string): DonobuFlow;
    /**
     * Get flows metadata across multiple persistence layers with pagination and filtering.
     */
    getFlowsMetadata(query: FlowsQuery): Promise<PaginatedFlowsResult>;
    /**
     * Returns the metadata for the given flow by ID. If the flow is active, the
     * returned metadata object is shared with the underlying flow and changes
     * made to this metadata object will be visible to the flow. If the flow is
     * not active, a copy of the persisted metadata is returned.
     */
    getFlowMetadata(flowId: string): Promise<FlowMetadata>;
    /**
     * Returns the metadata for the given flow by name.
     */
    getFlowByName(flowName: string): Promise<FlowMetadata>;
    /** Returns all the tool calls made by the given flow by ID. */
    getToolCalls(flowId: string): Promise<ToolCall[]>;
    /**
     * Attempts to delete a flow by ID. If the flow is active, then
     * `CannotDeleteRunningFlowException` is thrown. If the flow is not active,
     * then the flow's persisted data is deleted.
     */
    deleteFlowById(flowId: string): Promise<void>;
    /**
     * Attempts to cancel a flow by ID. If the flow is active, the flow is ended
     * with a state of `FAILED`. If the flow is not active, this method has no
     * effect.
     */
    cancelFlow(flowId: string): Promise<FlowMetadata>;
    /** Creates a Node.js Microsoft Playwright script to replay the given flow. */
    getFlowAsPlaywrightScript(flowId: string): Promise<string>;
    /**
     * Creates a GPT client using the provided GPT configuration by name. If the
     * configuration name is null, or resolves to a missing configuration, then
     * the default GPT configuration associated with the 'flow-runner' agent is
     * used.
     *
     * This method is public for testing purposes only.
     **/
    createGptClient(gptConfigName: string | null): Promise<{
        gptConfigName: string | null;
        agentName: DonobuAgent | null;
        gptClient: GptClient | null;
    }>;
    /**
     * Loads the browser state associated with the given flow. Throws
     * {@link BrowserStateNotFoundException} if it is not found.
     */
    getBrowserStorageState(browserStateRef: BrowserStateReference): Promise<BrowserStorageState>;
    private validateFlowParams;
    private setupAllowedTools;
    private prepareInitialToolCalls;
    private createTempDirectoryForFlow;
    private runFlow;
    private findLargestVideo;
    private isLocallyRunning;
    private checkIfAnyToolsRequireGpt;
    private prepareToolCallsForRerun;
    /**
     * Parses the given argument as a URL, returning null on failure.
     */
    private static parseUrl;
    /**
     * Parse a composite page token into pagination state
     */
    private parseCompositePageToken;
    /**
     * Create a composite page token from pagination state
     */
    private createCompositePageToken;
}
//# sourceMappingURL=DonobuFlowsManager.d.ts.map