//#region extensions/crypto/src/services/event-bus.d.ts /** * Event Bus — typed pub/sub for internal plan-engine events. * * Lightweight, zero-dependency event emitter for decoupling trigger sources * (price watcher, cron evaluator) from the scheduler. Events are fire-and-forget * (handlers run async but errors don't propagate). * * Usage: * const bus = getEventBus(); * bus.on('price_crossed', handler); * bus.emit('price_crossed', { token: 'ETH', ... }); */ interface PriceCrossedEvent { type: 'price_crossed'; token: string; condition: 'above' | 'below' | 'crosses'; threshold: number; currentPrice: number; previousPrice: number; timestamp: number; } interface CronTickEvent { type: 'cron_tick'; /** The cron expression that matched. */ expression: string; /** ISO timestamp of the tick. */ tickTime: string; timestamp: number; } interface PlanCompletedEvent { type: 'plan_completed'; planId: string; executionId: string; status: 'completed' | 'failed' | 'cancelled'; timestamp: number; } interface CheckpointResumedEvent { type: 'checkpoint_resumed'; planId: string; executionId: string; nodeId: string; timestamp: number; } interface OnChainEvent { type: 'onchain_event'; /** Chain ID where the event was detected. */ chainId: number; /** Contract address that emitted the event. */ contractAddress: string; /** Event signature (e.g. 'Transfer(address,address,uint256)'). */ eventSignature: string; /** Decoded event topics. */ topics: string[]; /** Raw log data. */ data: string; /** Block number. */ blockNumber: number; /** Transaction hash. */ txHash: string; timestamp: number; } interface BalanceChangedEvent { type: 'balance_changed'; /** Token symbol or address. */ token: string; /** Chain ID. */ chainId: number; /** Previous balance. */ previousBalance: number; /** Current balance. */ currentBalance: number; /** Absolute change. */ change: number; /** Direction of change. */ direction: 'increased' | 'decreased'; /** Wallet address. */ walletAddress: string; timestamp: number; } interface WebhookReceivedEvent { type: 'webhook_received'; /** Route name that matched. */ route: string; /** Source label (e.g. "GitHub", "Stripe"). */ source: string; /** Parsed payload body. */ payload: unknown; /** HTTP headers from the request. */ headers: Record; /** When the webhook was received. */ receivedAt: number; timestamp: number; } type BusEvent = PriceCrossedEvent | CronTickEvent | PlanCompletedEvent | CheckpointResumedEvent | OnChainEvent | BalanceChangedEvent | WebhookReceivedEvent; type BusEventType = BusEvent['type']; type EventOfType = Extract; type BusEventHandler = (event: EventOfType) => void | Promise; declare class EventBus { private handlers; private allHandlers; /** Subscribe to a specific event type. Returns unsubscribe function. */ on(type: T, handler: BusEventHandler): () => void; /** Subscribe to all events. Returns unsubscribe function. */ onAny(handler: BusEventHandler): () => void; /** Emit an event to all subscribers (async, errors swallowed). */ emit(type: T, event: EventOfType): void; /** Remove all handlers. */ clear(): void; /** Get handler count for a specific event type (for testing). */ listenerCount(type?: BusEventType): number; } declare function getEventBus(): EventBus; declare function resetEventBus(): void; //#endregion export { BalanceChangedEvent, BusEvent, BusEventHandler, BusEventType, CheckpointResumedEvent, CronTickEvent, EventBus, OnChainEvent, PlanCompletedEvent, PriceCrossedEvent, WebhookReceivedEvent, getEventBus, resetEventBus }; //# sourceMappingURL=event-bus.d.mts.map