import type { RuntimeEventEnvelope } from './envelope.js';
import type { AnyRuntimeEvent, RuntimeEventDomain, DomainEventMap } from '../../../events/domain-map.js';
export type { RuntimeEventEnvelope, EnvelopeContext } from './envelope.js';
export { createEventEnvelope } from './envelope.js';
export type { SessionEvent, SessionEventType } from '../../../events/session.js';
export type { TurnEvent, TurnEventType, TurnInputOrigin } from '../../../events/turn.js';
export type { ProviderEvent, ProviderEventType } from '../../../events/providers.js';
export type { ToolEvent, ToolEventType } from '../../../events/tools.js';
export type { TaskEvent, TaskEventType } from '../../../events/tasks.js';
export type { AgentEvent, AgentEventType } from '../../../events/agents.js';
export type { WorkflowEvent, WorkflowEventType } from '../../../events/workflows.js';
export type { OrchestrationEvent, OrchestrationEventType, OrchestrationTaskContract } from '../../../events/orchestration.js';
export type { CommunicationEvent, CommunicationEventType, CommunicationKind, CommunicationScope } from '../../../events/communication.js';
export type { PlannerEvent, PlannerEventType } from '../../../events/planner.js';
export type { PermissionEvent, PermissionEventType } from '../../../events/permissions.js';
export type { PluginEvent, PluginEventType } from '../../../events/plugins.js';
export type { McpEvent, McpEventType } from '../../../events/mcp.js';
export type { TransportEvent, TransportEventType } from '../../../events/transport.js';
export type { CompactionEvent, CompactionEventType } from '../../../events/compaction.js';
export type { GoodVibesUIEvent, GoodVibesUIEventType } from '../../../events/ui.js';
export type { OpsEvent, OpsEventType } from '../../../events/ops.js';
export type { OpsInterventionReason } from '../../../events/ops.js';
export { RUNTIME_EVENT_DOMAINS, isRuntimeEventDomain } from '../../../events/domain-map.js';
export { registeredEventTypes, validateKnownEvent } from '../../../events/contracts.js';
export type { AnyRuntimeEvent, RuntimeEventPayload, RuntimeEventDomain, DomainEventMap, RuntimeEventRecord } from '../../../events/domain-map.js';
export type { AutomationEvent, AutomationEventType, AutomationScheduleKind, AutomationExecutionMode, AutomationRunOutcome } from '../../../events/automation.js';
export { AUTOMATION_SCHEDULE_KINDS, AUTOMATION_RUN_OUTCOMES } from '../../../events/automation.js';
export type { RouteEvent, RouteEventType, RouteSurfaceKind, RouteTargetKind } from '../../../events/routes.js';
export { ROUTE_SURFACE_KINDS, ROUTE_TARGET_KINDS } from '../../../events/routes.js';
export type { ControlPlaneEvent, ControlPlaneEventType, ControlPlaneClientKind, ControlPlaneTransportKind, ControlPlanePrincipalKind } from '../../../events/control-plane.js';
export { CONTROL_PLANE_CLIENT_KINDS, CONTROL_PLANE_TRANSPORT_KINDS, CONTROL_PLANE_PRINCIPAL_KINDS } from '../../../events/control-plane.js';
export type { DeliveryEvent, DeliveryEventType, DeliveryKind } from '../../../events/deliveries.js';
export { DELIVERY_KINDS } from '../../../events/deliveries.js';
export type { WatcherEvent, WatcherEventType, WatcherSourceKind } from '../../../events/watchers.js';
export { WATCHER_SOURCE_KINDS } from '../../../events/watchers.js';
export type { SurfaceEvent, SurfaceEventType, SurfaceKind } from '../../../events/surfaces.js';
export { SURFACE_KINDS } from '../../../events/surfaces.js';
export type { KnowledgeEvent, KnowledgeEventType } from '../../../events/knowledge.js';
/** Listener callback receiving a fully-formed envelope. */
export type EnvelopeListener<T extends AnyRuntimeEvent = AnyRuntimeEvent> = (envelope: RuntimeEventEnvelope<T['type'], T>) => void;
/**
 * Maximum listeners per channel before a potential memory leak warning is emitted.
 *
 * 100 is a generous threshold for a single event type or domain; normal usage
 * rarely exceeds single-digit listeners. Exceeding this strongly suggests a
 * subscriber is being registered without a corresponding unsubscribe.
 */
export declare const MAX_LISTENERS = 100;
/**
 * Options accepted by the RuntimeEventBus constructor.
 */
export interface RuntimeEventBusOptions {
    /**
     * Override the maximum number of listeners per channel.
     * Defaults to MAX_LISTENERS (100).
     * Values above zero are accepted; the cap is applied per event-type channel
     * and per domain channel independently.
     */
    maxListeners?: number | undefined;
}
/**
 * RuntimeEventBus — typed event bus for domain-structured runtime events.
 *
 * Supports two subscription modes:
 * - `on(eventType, callback)` — subscribe to a specific event type
 * - `onDomain(domain, callback)` — subscribe to all events in a domain
 *
 * All events are wrapped in a RuntimeEventEnvelope providing traceId,
 * sessionId, timestamps, and source context.
 *
 * This is the authoritative event transport for runtime domain signaling.
 */
export declare class RuntimeEventBus {
    /** Per-event-type listener sets. Keyed by the exact event type string. */
    private readonly _listeners;
    /** Per-domain listener sets. Keyed by RuntimeEventDomain. */
    private readonly _domainListeners;
    /** Effective listener cap for this instance. */
    private readonly _maxListeners;
    /** Track per-listener error counts for misbehaving-listener dedup. */
    private readonly _listenerErrorCounts;
    /** Number of errors a listener must throw before OPS_LISTENER_MISBEHAVING is emitted. */
    private static readonly _MISBEHAVE_DEDUP_THRESHOLD;
    constructor(opts?: RuntimeEventBusOptions);
    /**
     * Subscribe to a specific event type.
     *
     * @param eventType - The exact event type string to listen for.
     * @param callback - Called with the full envelope on each emission.
     * @returns An unsubscribe function.
     */
    on<T extends AnyRuntimeEvent>(eventType: T['type'], callback: EnvelopeListener<T>): () => void;
    /**
     * Subscribe to all events in a named domain.
     *
     * @param domain - Domain name (e.g. 'turn', 'tools', 'session').
     * @param callback - Called with the full envelope for each domain event.
     * @returns An unsubscribe function.
     */
    onDomain<D extends RuntimeEventDomain>(domain: D, callback: EnvelopeListener<DomainEventMap[D]>): () => void;
    /**
     * Emit a runtime event envelope to all matching per-type and per-domain subscribers.
     *
     * Callers MUST use the typed emitter wrapper functions from
     * `platform/runtime/emitters/` rather than calling this method directly.
     * Direct usage bypasses domain-event type enforcement: TypeScript cannot
     * statically link the `domain` argument to the `envelope` payload type due
     * to union complexity limitations (TS2590), meaning mismatched pairs compile
     * without error.
     *
     * @see emitTurnSubmitted, emitToolReceived, etc. in `src/runtime/emitters/`
     *
     * Domain-keyed overload: when the domain is statically known, the envelope
     * type is narrowed to the corresponding DomainEventMap entry — no cast needed.
     *
     * @param domain - Domain this event belongs to.
     * @param envelope - The fully-formed envelope to dispatch.
     */
    emit<D extends RuntimeEventDomain>(domain: D, envelope: RuntimeEventEnvelope<DomainEventMap[D]['type'], DomainEventMap[D]>): void;
    /**
     * Record a listener error: increment metrics, update error count, emit
     * OPS_LISTENER_MISBEHAVING once the dedup threshold is reached, and log.
     *
     * @param listener - The misbehaving listener function.
     * @param eventType - The event type that triggered the listener.
     * @param err - The thrown value caught from the listener.
     * @param domain - Optional domain name, present when the listener was a domain subscriber.
     */
    private _recordListenerError;
    /**
     * Directly dispatch an OPS_LISTENER_MISBEHAVING envelope to any registered
     * OPS_LISTENER_MISBEHAVING and 'ops' domain listeners.
     *
     * Bypasses emit() to avoid potential recursion: a listener watching for
     * misbehaving events itself misbehaving would otherwise cause infinite loops.
     */
    private _emitListenerMisbehaving;
    private _off;
    private _offDomain;
}
//# sourceMappingURL=index.d.ts.map