import type Valkey from 'iovalkey'; import { type TenantScope } from './keys'; import { type Logger } from './logger'; import type { EnvelopeStatus, ExecutionId, StepId, TenantId } from './types'; export type ExecutionEventKind = 'step.committed' | 'step.failed' | 'execution.status' | 'execution.log'; export interface BaseExecutionEvent { kind: ExecutionEventKind; executionId: ExecutionId; attempt: number; ts: string; } export interface StepCommittedEvent extends BaseExecutionEvent { kind: 'step.committed'; stepId: StepId; envelopeRef?: string; } export interface StepFailedEvent extends BaseExecutionEvent { kind: 'step.failed'; stepId: StepId; errorRef?: string; } export interface ExecutionStatusEvent extends BaseExecutionEvent { kind: 'execution.status'; status: EnvelopeStatus; sessionPatch?: Record; } export interface ExecutionLogEvent extends BaseExecutionEvent { kind: 'execution.log'; stepId?: StepId; level: 'debug' | 'info' | 'warn' | 'error'; message: string; } export type ExecutionEvent = StepCommittedEvent | StepFailedEvent | ExecutionStatusEvent | ExecutionLogEvent; export declare function executionStreamKey(scope: TenantScope): string; export declare class ExecutionEventStreamUnavailableError extends Error { constructor(message: string); } export interface ExecutionEventPublisherOptions { client: Valkey; streamMaxLen?: number; logger?: Logger; } export declare class ExecutionEventPublisher { private readonly client; private readonly streamMaxLen; private readonly logger; constructor(options: ExecutionEventPublisherOptions); publish(scope: TenantScope, event: ExecutionEvent): Promise; } export interface ExecutionEventSubscriberOptions { client: Valkey; group: string; consumer: string; blockMs?: number; batchSize?: number; startAt?: '$' | '0'; logger?: Logger; } export type EventHandler = (event: ExecutionEvent, meta: { id: string; idem: string; tenantId: TenantId; }) => Promise | void; export declare class ExecutionEventSubscriber { private readonly client; private readonly group; private readonly consumer; private readonly blockMs; private readonly batchSize; private readonly startAt; private readonly logger; private readonly seen; private running; constructor(options: ExecutionEventSubscriberOptions); ensureGroup(scope: TenantScope): Promise; consumeOnce(scope: TenantScope, handler: EventHandler): Promise; runLoop(scope: TenantScope, handler: EventHandler): Promise; stop(): void; private ack; private alreadySeen; private markSeen; } //# sourceMappingURL=executionEvents.d.ts.map