/** * PiEventBridge — IEventBridge adapter for Pi (plugin) platform events. * * Translates Pi Extension API raw events into CanonicalEvents and * dispatches them to registered handlers. Does NOT import from * any Pi SDK (@opencode-ai/plugin or @opencode-ai/sdk). * * @module */ import type { CanonicalEvent, CanonicalEventHandler, CanonicalEventType, IEventBridge } from "../../ports/event-bridge.ts"; /** * Map a Pi Extension API event type string to a CanonicalEventType. * Unknown or unmapped types resolve to "unknown". */ export declare function mapPiEventType(piType: string): CanonicalEventType; /** * IEventBridge implementation that adapts Pi Extension API events * into the canonical event system. * * Maintains a set of general-purpose handlers (invoked for all events) * and a map of type-specific handlers (invoked only for matching types). */ export declare class PiEventBridge implements IEventBridge { /** General-purpose handlers invoked for every emitted event. */ private readonly handlers; /** Type-specific handlers, keyed by canonical event type. */ private readonly typeHandlers; /** * Subscribe a general-purpose event handler. * The handler receives all emitted canonical events. * * @param handler - Callback receiving the canonical event. * @returns An unsubscribe function that removes the handler. */ on(handler: CanonicalEventHandler): () => void; /** * Subscribe a type-specific event handler. * The handler only receives events matching the specified canonical type. * * @param type - The canonical event type to subscribe to. * @param handler - Callback receiving the canonical event. * @returns An unsubscribe function that removes the handler. */ onType(type: CanonicalEventType, handler: CanonicalEventHandler): () => void; /** * Normalize a raw Pi platform event into a CanonicalEvent. * * Expects `rawEvent` to be an object with a `type` string property * containing the Pi Extension API event type name. All other properties * on the raw event are captured in the `properties` bag. * * @param rawEvent - The raw Pi event (unknown shape). * @returns A normalized CanonicalEvent. */ normalize(rawEvent: unknown): CanonicalEvent; /** * Emit a canonical event to all matching subscribers. * * Dispatches to both general-purpose handlers and type-specific handlers. * All handlers are invoked and awaited; if any handler rejects, the * error is captured and re-thrown after all handlers have settled. * * @param event - The canonical event to dispatch. */ emit(event: CanonicalEvent): Promise; /** * Extract the Pi event type string from a raw event object. * Returns "unknown" when the raw event is not an object or has no type string. */ private extractRawType; /** * Extract all enumerable properties except `type` from the raw event * into a plain record for the `properties` bag. */ private extractProperties; } //# sourceMappingURL=event-bridge.d.ts.map