/** * Event Sink — structured event log for the control plane. * * Captures agent events into a queryable, time-ordered log. * This is a transport stub for future hosted integration: events * accumulate locally and can be flushed to an external system via onFlush. * * NOT an audit trail or compliance primitive. Delivery is best-effort, * at-most-once. The hosted layer owns durable persistence and retry. */ import type { AgentEventMap } from './events.js'; /** A single event in the sink. */ export interface SinkEvent { /** Unique event ID (monotonic counter + timestamp) */ id: string; /** ISO timestamp */ timestamp: string; /** Event type from AgentEventMap */ type: keyof AgentEventMap; /** Optional agent identifier (for fleet scenarios) */ agentId?: string; /** Event payload */ data: Record; } export interface EventSinkConfig { /** Maximum events to retain in memory (circular buffer). Default: 10000 */ maxEvents?: number; /** Callback invoked when events are flushed (for external systems). */ onFlush?: (events: SinkEvent[]) => void | Promise; /** Auto-flush interval in ms. Default: 30000 (30s). Set to 0 to disable. */ flushIntervalMs?: number; /** Agent ID to tag all events with (for fleet identification). */ agentId?: string; } /** * Structured event sink with circular buffer and flush support. * * Usage: * const sink = new EventSink({ * agentId: 'researcher-01', * onFlush: (events) => fetch('/api/events', { method: 'POST', body: JSON.stringify(events) }), * }); * * // Wire up to AgentCFO events: * agent.events.on('payment:success', (data) => sink.record('payment:success', data)); * agent.events.on('anomaly:blocked', (data) => sink.record('anomaly:blocked', data)); */ export declare class EventSink { private buffer; private maxEvents; private onFlush; private flushTimer; private agentId; private counter; constructor(config?: EventSinkConfig); /** * Record an event into the sink. */ record(type: keyof AgentEventMap, data: Record): void; /** * Flush buffered events to the onFlush callback. * Returns the events that were flushed. */ flush(): Promise; /** Get all buffered events (read-only). */ all(): readonly SinkEvent[]; /** Get events by type. */ byType(type: keyof AgentEventMap): SinkEvent[]; /** Get events in a time range. */ between(start: Date, end: Date): SinkEvent[]; /** Current buffer size. */ get size(): number; /** Stop auto-flush timer. */ stop(): void; } //# sourceMappingURL=sink.d.ts.map