import type { ServerResponse } from 'node:http'; import type { ConsoleEventEnvelope, ConsoleEventHistoryPage, ConsoleEventHistoryQuery, ConsoleEventPayloadMap, KnownConsoleEventType } from '@zhin.js/console-protocol'; /** * Console 实时事件枢纽(Plugin Runtime Host 的 `/api/events` SSE 事件源)。 * 单进程内 fan-out:`publish` 向所有已订阅的 SSE response 写帧; * write 失败或连接断开自动摘除订阅。 */ export interface ConsoleEventSubscriptionOptions { readonly runtimeId?: string; readonly after?: number; } export interface ConsoleEventHub { publish(type: Type, data: Type extends KnownConsoleEventType ? ConsoleEventPayloadMap[Type] : unknown): ConsoleEventEnvelope; history(query?: ConsoleEventHistoryQuery): ConsoleEventHistoryPage; /** In-process delivery for trusted Host bridges such as Device Protocol. */ listen(listener: (event: ConsoleEventEnvelope) => void): () => void; /** Atomically replay the resumable suffix, then join live fan-out. */ subscribe(response: ServerResponse, options?: ConsoleEventSubscriptionOptions): () => void; readonly runtimeId: string; readonly subscriberCount: number; } /** Shared Console event authority installed by the Plugin Runtime composition root. */ export declare const consoleEventHubToken: import("@zhin.js/plugin-runtime").Token; export interface ConsoleEventHubOptions { readonly runtimeId?: string; readonly historyLimit?: number; readonly historyByteLimit?: number; readonly historyPageByteLimit?: number; } export declare function createConsoleEventHub(options?: ConsoleEventHubOptions): ConsoleEventHub; export declare function serializeConsoleEvent(event: ConsoleEventEnvelope): string;