import { EventIdentity, WithoutIdentity } from "../contracts/events/event-identity.type.mjs"; import { OrchestratorEventHandler, OrchestratorEventHandlers, OrchestratorEventMap, OrchestratorEventName } from "../contracts/orchestrator/orchestrator-event.type.mjs"; //#region ../ai/src/orchestrator/emitter.d.ts /** Full identity-stamped payload an orchestrator handler receives. */ type EventPayload = OrchestratorEventMap[K] & EventIdentity; /** * Three-tier orchestrator event emitter — definition (factory) → * instance → per-call — for the `orchestrator.*` namespace (design * §14.3). Mirrors {@link import("../supervisor/emitter").SupervisorEmitter} * structurally; the differences are the event map and a central * identity-injection chokepoint (`emit` accepts an identity-less * payload and stamps {@link EventIdentity} once so all three tiers, and * any mirror like the stream, see the same value). * * Owns: the instance-handler registry and the fan-out order. Does NOT * own: child `supervisor.*` / `agent.*` events — those bubble up * unmodified under their own identity (§14.2) and never pass through * this emitter. All matching handlers fire in tier order; a handler * throwing never derails the turn. * * @example * const emitter = new OrchestratorEmitter(config.on); * const off = emitter.on("orchestrator.turn.completed", (event) => log(event)); * emitter.emit( * "orchestrator.turn.starting", * { sessionId, turnIndex }, * { runId, rootRunId }, * perCallHandlers, * ); */ declare class OrchestratorEmitter { private readonly factoryHandlers?; private readonly instanceHandlers; constructor(factoryHandlers?: OrchestratorEventHandlers); /** * Subscribe an instance-level handler (tier 2). Returns an * unsubscribe function equivalent to `off(event, handler)`. */ on(event: K, handler: OrchestratorEventHandler): () => void; /** * Remove a previously-subscribed instance handler. No-op when the * handler was never registered or already removed. */ off(event: K, handler: OrchestratorEventHandler): void; /** * Stamp run identity onto the payload, then fan out through all three * tiers in order: definition → instance → per-call. Returns the full * identity-stamped payload so the caller can mirror the same value * into the stream controller (keeping `.on()` and iteration in lockstep). */ emit(event: K, payload: WithoutIdentity, identity: EventIdentity, perCallHandlers?: OrchestratorEventHandlers): EventPayload; } //#endregion export { OrchestratorEmitter }; //# sourceMappingURL=emitter.d.mts.map