import type { RuntimeEventBus } from '../runtime/events/index.js'; export type ReplayTrackedEventName = 'AGENT_COMPLETED' | 'AGENT_FAILED' | 'WORKFLOW_STATE_CHANGED' | 'WORKFLOW_CHAIN_PASSED' | 'WORKFLOW_CHAIN_FAILED'; export interface QueuedEvent { id: string; eventName: ReplayTrackedEventName; payload: unknown; timestamp: number; acknowledged: boolean; turnCount: number; replayCount: number; } /** Events that are significant enough to track for replay. */ export declare const TRACKED_EVENTS: readonly ["AGENT_COMPLETED", "AGENT_FAILED", "WORKFLOW_STATE_CHANGED", "WORKFLOW_CHAIN_PASSED", "WORKFLOW_CHAIN_FAILED"]; /** * EventReplayQueue, holds events and replays unacknowledged ones. * * Grace period: events are held for 1 full LLM turn after they fire. * After the grace period, if unacknowledged, they are replayed as * system messages in the conversation. * * Delivery semantics: the caller acknowledges an event as soon as its * formatted message is injected into the conversation (see the orchestrator's * turn-completion hook), injection IS delivery, so each event reaches the * model exactly once. maxReplays remains as a backstop for callers that * defer acknowledgment; events exceeding it are dropped with a log line. */ export declare class EventReplayQueue { private queue; private currentTurn; private droppedCount; private readonly maxReplays; private readonly graceTurns; constructor(maxReplays?: number, graceTurns?: number); /** * Enqueue an event for tracking. * Called when significant events fire (agent complete, WRFC state change, etc.) * Returns the assigned event ID. */ enqueue(eventName: ReplayTrackedEventName, payload: unknown): string; /** * Mark an event as acknowledged by ID. * Called when the model demonstrates awareness of the event. */ acknowledge(eventId: string): void; /** * Acknowledge all events matching a predicate. * E.g., acknowledge all events for a specific agent ID. * Returns the number of events acknowledged. */ acknowledgeWhere(predicate: (event: QueuedEvent) => boolean): number; /** * Signal that an LLM turn has completed. * Increments the turn counter and returns events that need replaying. * Events that exceed maxReplays are dropped (logged and removed from queue). */ onTurnComplete(): QueuedEvent[]; /** * Format replay events as system messages ready to inject into the conversation. */ formatReplays(events: QueuedEvent[]): string[]; /** * Get queue stats for telemetry and debugging. */ getStats(): { queued: number; acknowledged: number; pending: number; replayed: number; dropped: number; }; /** * Clear all events (e.g., on session reset). */ clear(): void; /** Format a human-readable message for a single event. */ private _formatEventMessage; /** * Wire up listeners for replay-significant events on the typed runtime bus. * Returns an unsubscribe function that removes all listeners. */ static attachToRuntimeBus(bus: RuntimeEventBus, queue: EventReplayQueue): () => void; } //# sourceMappingURL=event-replay.d.ts.map