/** * @oni.bot/core — Pub/Sub coordination * * Provides topic-based publish/subscribe messaging between agents. * Supports wildcard patterns ("*" for single segment, "**" for deep match). */ export interface TopicMessage { topic: string; data: unknown; from: string; timestamp: number; } export declare class PubSub { private subscribers; private buffer; private maxBufferSize; constructor(opts?: { maxBufferSize?: number; }); /** Publish a message to a topic, notifying all matching subscribers. */ publish(from: string, topic: string, data: unknown): void; /** * Subscribe to a topic pattern. Returns an unsubscribe function. * Patterns support "*" (single segment) and "**" (deep match). */ subscribe(pattern: string, handler: (msg: TopicMessage) => void): () => void; /** Return all buffered messages matching the given topic pattern. */ getMessages(pattern: string): TopicMessage[]; /** Drain the buffer, returning all buffered messages. */ flush(): TopicMessage[]; /** * Remove all subscribers and clear the message buffer. * Call when the PubSub instance is no longer needed to allow GC. */ dispose(): void; } /** * Check whether a topic pattern matches a concrete topic string. * * Rules: * - Exact match: "a.b" matches "a.b" * - Global wildcard: "*" matches any topic * - Single-segment wildcard: "a.*" matches "a.b" but not "a.b.c" * - Deep wildcard: "a.**" matches "a.b", "a.b.c", "a.b.c.d", etc. * `**` may appear anywhere in the pattern — "a.**.b" matches "a.x.b", "a.x.y.b", etc. */ export declare function topicMatches(pattern: string, topic: string): boolean; //# sourceMappingURL=pubsub.d.ts.map