import { EventEmitter } from 'events'; import { AgentActivity, ActivityType, ActivityStatus, ActivityBatch } from './types'; export interface StreamSubscription { id: string; filters: StreamFilter; callback: (event: StreamEvent) => void; metadata?: Record; createdAt: Date; lastActivity?: Date; unsubscribe: () => void; } export interface StreamFilter { agentDID?: string | string[]; parentDID?: string | string[]; serviceDID?: string | string[]; types?: ActivityType[]; status?: ActivityStatus[]; scopes?: string[]; critical?: boolean; minDuration?: number; errorOnly?: boolean; } export interface StreamEvent { id: string; timestamp: Date; type: StreamEventType; data: AgentActivity | ActivityBatch | ActivityAlert; metadata?: Record; } export declare enum StreamEventType { ACTIVITY_LOGGED = "activity_logged", BATCH_PROCESSED = "batch_processed", ACTIVITY_ALERT = "activity_alert", AGENT_SESSION_START = "agent_session_start", AGENT_SESSION_END = "agent_session_end", SYSTEM_ALERT = "system_alert" } export interface ActivityAlert { id: string; agentDID: string; parentDID: string; alertType: AlertType; severity: AlertSeverity; message: string; timestamp: Date; relatedActivityId?: string; details?: Record; } export declare enum AlertType { HIGH_ERROR_RATE = "high_error_rate", SUSPICIOUS_ACTIVITY = "suspicious_activity", PERMISSION_ESCALATION = "permission_escalation", UNUSUAL_PATTERN = "unusual_pattern", RATE_LIMIT_EXCEEDED = "rate_limit_exceeded", SYSTEM_ERROR = "system_error" } export declare enum AlertSeverity { LOW = "low", MEDIUM = "medium", HIGH = "high", CRITICAL = "critical" } export interface StreamManagerConfig { maxSubscriptions?: number; eventRetentionMs?: number; alertThresholds?: { errorRateThreshold?: number; suspiciousVolumeThreshold?: number; unusualHoursThreshold?: number; }; enableAlerts?: boolean; enableMetrics?: boolean; } export declare class ActivityStreamManager extends EventEmitter { private subscriptions; private recentEvents; private config; private metrics; constructor(config?: StreamManagerConfig); /** * Subscribe to activity stream with filters */ subscribe(filters: StreamFilter, callback: (event: StreamEvent) => void, metadata?: Record): StreamSubscription; /** * Subscribe to specific agent activities */ subscribeToAgent(agentDID: string, callback: (event: StreamEvent) => void, metadata?: Record): StreamSubscription; /** * Subscribe to user activities (all agents under a parent DID) */ subscribeToUser(parentDID: string, callback: (event: StreamEvent) => void, metadata?: Record): StreamSubscription; /** * Subscribe to critical events only */ subscribeToCriticalEvents(callback: (event: StreamEvent) => void, metadata?: Record): StreamSubscription; /** * Subscribe to alerts */ subscribeToAlerts(callback: (event: StreamEvent) => void, severity?: AlertSeverity[], metadata?: Record): StreamSubscription; /** * Publish an activity to subscribers */ publishActivity(activity: AgentActivity): Promise; /** * Publish a batch processed event */ publishBatch(batch: ActivityBatch): Promise; /** * Publish an alert */ publishAlert(alert: ActivityAlert): Promise; /** * Get recent events (for replay/catch-up) */ getRecentEvents(filters?: Partial, limit?: number): StreamEvent[]; /** * Get subscription statistics */ getSubscriptionStats(): { total: number; byFilter: Record; active: number; }; /** * Get streaming metrics */ getMetrics(): typeof this.metrics; /** * Clear old events and inactive subscriptions */ cleanup(): void; private publishEvent; private matchesFilter; private checkForAlerts; private getRecentActivityCount; private getRecentErrorCount; private getRecentUnusualHoursCount; private generateId; private startCleanupTimer; } //# sourceMappingURL=activity-stream-manager.d.ts.map