import type { WorkflowExecutionEvent } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/event_pb";
import type { WorkflowTaskKind } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/enum_pb";
export type WorkflowEventStreamState = {
    readonly stage: "idle";
} | {
    readonly stage: "connecting";
    readonly executionId: string;
} | {
    readonly stage: "streaming";
    readonly executionId: string;
} | {
    readonly stage: "complete";
    readonly executionId: string;
} | {
    readonly stage: "error";
    readonly executionId: string;
    readonly error: Error;
} | {
    readonly stage: "unsupported";
    readonly executionId: string;
};
export interface DerivedTaskState {
    readonly taskName: string;
    readonly taskKind: WorkflowTaskKind;
    readonly status: "pending" | "running" | "completed" | "failed" | "skipped" | "retrying" | "waiting_approval";
    readonly durationMs: number;
    readonly costMicros: bigint;
    readonly tokensUsed: bigint;
    readonly attemptNumber: number;
    readonly error: string;
    readonly childExecutionId: string;
    readonly agentSlug: string;
    readonly currentToolName: string;
    readonly messagesCount: number;
    readonly toolCallsCount: number;
}
export interface DerivedCostSummary {
    readonly costConsumedMicros: bigint;
    readonly costRemainingMicros: bigint;
    readonly tokensConsumed: bigint;
    readonly tokensRemaining: bigint;
    readonly thresholdBreached: boolean;
}
type Listener = () => void;
/**
 * Framework-agnostic store that accumulates workflow execution events
 * in an append-only list and derives task states and cost summaries.
 *
 * Implements the contract required by React's `useSyncExternalStore`.
 *
 * Unlike `ConversationStore` (which stores mutable execution snapshots
 * and applies structural sharing), this store is append-only: events
 * are immutable once received. Derived state (task map, cost summary)
 * is lazily recomputed and cached.
 */
export declare class WorkflowExecutionEventStore {
    private _events;
    private _streamState;
    private _listeners;
    private _taskStatesCache;
    private _costSummaryCache;
    private _totalTasks;
    /**
     * Append new events to the store. Deduplicates by sequence_number
     * and maintains ascending order. Notifies listeners only when new
     * events are actually added.
     */
    appendEvents(events: readonly WorkflowExecutionEvent[]): void;
    /**
     * Transition the stream lifecycle state.
     */
    setStreamState(state: WorkflowEventStreamState): void;
    /**
     * Reset to initial state.
     */
    reset(): void;
    subscribe: (listener: Listener) => (() => void);
    getEvents: () => readonly WorkflowExecutionEvent[];
    getStreamState: () => WorkflowEventStreamState;
    getLatestSequence: () => bigint;
    getTotalTasks: () => number;
    /**
     * Derived task state map, lazily computed and cached until new
     * events are appended. Walks the event list once per invalidation
     * to build a `Map<taskName, DerivedTaskState>`.
     */
    getTaskStates: () => ReadonlyMap<string, DerivedTaskState>;
    /**
     * Derived cost summary from the latest budget_checkpoint event.
     * Falls back to aggregating task_completed events when no checkpoint exists.
     */
    getCostSummary: () => DerivedCostSummary;
    private _notify;
}
export {};
//# sourceMappingURL=workflow-execution-event-store.d.ts.map