import type { IMastraLogger } from '../logger/index.js';
import type { WorkflowsStorage } from '../storage/domains/workflows/base.js';
import type { RunFence, RunOwnershipRecord } from '../storage/run-fencing.js';
export declare const WORKFLOW_RUN_LEASE_TTL_MS: number;
export declare const WORKFLOW_RUN_LEASE_RENEW_INTERVAL_MS: number;
export interface WorkflowRunOwnership {
    release(): Promise<void>;
}
/**
 * Runs `tick` `intervalMs` after it starts, then again `intervalMs` after
 * each run of it settles, until the returned function is called. A tick that
 * is running when the chain is stopped finishes, and nothing runs after it.
 * Every tick runs in the async context this function was called in, and the
 * timer is unref'd. `tick` reports its own failures and must not reject.
 *
 * `intervalMs` can be a function, read before each wait, for a delay that
 * follows what the last tick saw. With `immediately`, the first tick runs at
 * once instead of after the first wait.
 */
export declare function repeatAfterSettled(tick: () => Promise<void>, intervalMs: number | (() => number), { immediately }?: {
    immediately?: boolean;
}): () => void;
/**
 * Renews the lease `fence` holds every {@link WORKFLOW_RUN_LEASE_RENEW_INTERVAL_MS}
 * until the returned function is called, counting each interval from the end
 * of the previous renewal. Stops by itself after the first renewal that finds
 * the claim superseded, reporting it through `onLost`.
 */
export declare function renewWorkflowLease({ store, fence, onLost, onError, }: {
    store: WorkflowsStorage;
    fence: RunFence;
    onLost: (owner: RunOwnershipRecord | null) => void;
    onError: (error: unknown) => void;
}): () => void;
/**
 * Marks this process as the live driver of a workflow run through the storage
 * run-ownership lease (the one durable agents use), renewing it while the run
 * executes. Writes stay unfenced: the lease only tells the boot-time recovery
 * sweep on other replicas that the run is not orphaned.
 *
 * Returns the current owner record instead of a handle when `force` is off and
 * another execution holds a live lease. Stores without run fencing get a no-op
 * handle, keeping their previous behaviour.
 */
export declare function claimWorkflowRunOwnership({ store, runId, force, logger, }: {
    store: WorkflowsStorage | undefined;
    runId: string;
    force: boolean;
    logger?: IMastraLogger;
}): Promise<WorkflowRunOwnership | {
    owner: RunOwnershipRecord | null;
}>;
//# sourceMappingURL=run-ownership.d.ts.map