import { AnyVoid, RequiredAll } from './internals/types.cjs'; import { Serializable } from './internals/serializable.cjs'; /** * Copyright 2025 © BeeAI a Series of LF Projects, LLC * SPDX-License-Identifier: Apache-2.0 */ type MatcherFn = (event: EventMeta) => boolean; type Matcher = "*" | "*.*" | RegExp | MatcherFn; type InferCallbackValue = NonNullable extends Callback ? P : never; type Callback = (value: T, event: EventMeta) => AnyVoid; type CleanupFn = () => void; type StringKey = Extract; interface EmitterOptions { isBlocking?: boolean; once?: boolean; persistent?: boolean; matchNested?: boolean; priority?: number; } interface EventTrace { id: string; runId: string; parentRunId?: string; } interface EventMeta { id: string; groupId?: string; name: string; path: string; createdAt: Date; source: Emitter; creator: object; context: C; trace?: EventTrace; } /** * Copyright 2025 © BeeAI a Series of LF Projects, LLC * SPDX-License-Identifier: Apache-2.0 */ interface EmitterInput { groupId?: string; namespace?: string[]; creator?: object; context?: E & object; trace?: EventTrace; } interface EmitterChildInput { groupId?: string; namespace?: string[]; creator?: object; context?: E & object; trace?: EventTrace; } interface Listener { readonly match: MatcherFn; readonly raw: Matcher; readonly callback: Callback; readonly options?: EmitterOptions; } declare class Emitter>> extends Serializable { protected listeners: Listener[]; protected readonly groupId?: string; readonly namespace: string[]; readonly creator?: object; readonly context: object; readonly trace?: EventTrace; protected readonly cleanups: CleanupFn[]; constructor(input?: EmitterInput); static get root(): Emitter>>; child(input?: EmitterChildInput): Emitter; pipe(target: Emitter): CleanupFn; destroy(): void; reset(): void; registerCallbacks>>(callbacks: Partial extends Callback ? Callback : never>>, options?: Partial>): CleanupFn; on>>(event: K, callback: NonNullable extends Callback ? T[K] : never, options?: EmitterOptions): CleanupFn; match(matcher: Matcher, callback: Callback, options?: EmitterOptions): CleanupFn; emit>>(name: K, value: NonNullable extends Callback ? X : unknown): Promise; protected invoke(data: unknown, event: EventMeta): Promise; protected createEvent(name: string): EventMeta; createSnapshot(): { groupId: string | undefined; namespace: string[]; creator: object | undefined; context: object; trace: EventTrace | undefined; listeners: { raw: Matcher; options?: EmitterOptions | undefined; callback: Callback; }[]; cleanups: CleanupFn[]; }; loadSnapshot({ listeners, ...snapshot }: ReturnType): void; } export { type Callback as C, Emitter as E, type InferCallbackValue as I, type Matcher as M, type StringKey as S, type EmitterOptions as a, type EventMeta as b, type CleanupFn as c, type EventTrace as d, type MatcherFn as e, type EmitterChildInput as f, type EmitterInput as g };