import type { EventMessageType, RequestMessageType, ResponseMessageType, RuntimeEventEnvelope, RuntimeRequestEnvelope } from '../protocol/types'; import type { RuntimeEngineConfig, SendRequestOptions, WaitForRequestOptions } from './engine.types'; /** * Low-level COIP transport runtime. * Owns listener lifecycle, request correlation, and event fan-out. */ export declare class RuntimeEngine { private readonly targetWindow; private readonly targetOrigin; private readonly sourceWindow; private readonly protocolVersion; private readonly requestTimeoutMs; private readonly maxClockSkewMs; private readonly now; private readonly pendingRequests; private readonly requestWaiters; private readonly requestHandlers; private readonly eventSubscribers; private started; private messageHandler; constructor(config: RuntimeEngineConfig); /** * Attaches the message listener once; repeated calls are no-ops. */ start(): void; /** * Detaches listeners and rejects all in-flight request promises. */ stop(): void; /** * Sends a typed request envelope and resolves when matching response arrives. */ sendRequest(type: RequestMessageType, payload: TRequestPayload, options?: SendRequestOptions): Promise; /** * Emits a typed response envelope for a known requestId. */ respond(responseType: ResponseMessageType, requestId: string, payload: TPayload): void; /** * Emits an unsolicited event envelope to plugin listeners. */ emitEvent(eventType: EventMessageType, payload: TPayload): void; /** * Registers a request handler and returns an unsubscribe function. */ onRequest(requestType: RequestMessageType, handler: (request: RuntimeRequestEnvelope) => Promise | unknown): () => void; /** * Waits for the next inbound request of a specific type. */ waitForRequest(requestType: RequestMessageType, options?: WaitForRequestOptions): Promise; /** * Registers an event subscriber and returns an unsubscribe function. */ onEvent(eventType: EventMessageType, handler: (event: RuntimeEventEnvelope) => void): () => void; /** * Centralizes outbound postMessage calls with the trusted target origin. */ private postEnvelope; private handleIncomingMessage; private handleRequest; /** * Resolves/rejects pending request promises based on inbound response envelopes. */ private handleResponse; /** * Broadcasts inbound events to all registered subscribers for the event type. */ private handleEvent; /** * Emits normalized SP_ERROR_RES envelopes for protocol/runtime failures. */ private sendError; /** * Best-effort requestId extraction for malformed payload error responses. */ private tryExtractRequestId; } export { RuntimeEngineError } from './engine.error'; export type { RuntimeEngineConfig }; //# sourceMappingURL=engine.d.ts.map