import type { WorkflowExecutionEvent } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/event_pb";
import type { WorkflowEventType } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/event_pb";
import { ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/enum_pb";
import { WorkflowExecutionEventStore, type WorkflowEventStreamState, type DerivedTaskState, type DerivedCostSummary } from "../internal/store";
/** Options for {@link useWorkflowExecutionEventStream}. */
export interface UseWorkflowExecutionEventStreamOptions {
    /** Filter to specific event types for the subscription. */
    readonly eventTypes?: readonly WorkflowEventType[];
    /**
     * External store instance. When provided, the hook writes to this
     * store instead of creating an internal one. Useful for sharing
     * event state across multiple components.
     */
    readonly store?: WorkflowExecutionEventStore;
    /**
     * The current execution phase. When provided, the hook uses this to
     * decide between live streaming (non-terminal) and batch loading
     * (terminal). When omitted, defaults to live streaming.
     */
    readonly executionPhase?: ExecutionPhase;
}
/** Return value of {@link useWorkflowExecutionEventStream}. */
export interface UseWorkflowExecutionEventStreamReturn {
    /** All accumulated events, ordered by sequence_number ascending. */
    readonly events: readonly WorkflowExecutionEvent[];
    /** Derived task states from the event log. */
    readonly taskStates: ReadonlyMap<string, DerivedTaskState>;
    /** Derived cost/budget summary from the latest checkpoint or aggregation. */
    readonly costSummary: DerivedCostSummary;
    /** Stream lifecycle state. */
    readonly streamState: WorkflowEventStreamState;
    /** Total tasks declared in the execution_started event. */
    readonly totalTasks: number;
    /** `true` while receiving live events. */
    readonly isStreaming: boolean;
    /** `true` while connecting to the event stream. */
    readonly isConnecting: boolean;
    /** Error from the last failed stream attempt, or `null`. */
    readonly error: Error | null;
    /** Re-establish the stream subscription. */
    readonly reconnect: () => void;
}
/**
 * Pure function that detects a terminal-to-active phase transition —
 * the signal that a recovery has begun and the event store should be
 * reset to clear stale events from the previous run.
 *
 * Returns `false` when either phase is `undefined` (initial load or
 * unresolved execution), preventing false resets on first render.
 *
 * Extracted for testability (DD-003).
 */
export declare function isRecoveryTransition(prevPhase: ExecutionPhase | undefined, nextPhase: ExecutionPhase | undefined): boolean;
/**
 * Behavior hook that manages a live event stream subscription for a
 * workflow execution, or batch-loads events for completed executions.
 *
 * Internally maintains a {@link WorkflowExecutionEventStore} and
 * exposes its state via `useSyncExternalStore` for efficient React
 * integration.
 *
 * For running executions: subscribes via `subscribeEvents` with
 * replay+live-tail. On disconnect, reconnects from the last received
 * sequence number.
 *
 * For terminal executions: loads the full event log via paginated
 * `getEventLog` calls.
 *
 * On recovery (terminal → active phase transition for the same
 * execution), the store is reset so stale events from the failed run
 * are cleared before the new subscription begins.
 *
 * When `executionId` changes to a different execution, the store is
 * reset before subscribing — mirroring `useFetch`'s identity-change
 * reset — so the previous run's append-only events neither render as
 * stale progress nor cause the live subscription to resume from the
 * wrong `afterSequence`.
 *
 * Pass `null` for `executionId` to skip (stable no-op).
 */
export declare function useWorkflowExecutionEventStream(executionId: string | null, options?: UseWorkflowExecutionEventStreamOptions): UseWorkflowExecutionEventStreamReturn;
//# sourceMappingURL=useWorkflowExecutionEventStream.d.ts.map