import type { SessionRecord } from '../../storage/domains/harness/index.js'; export interface HarnessEventBase { id: string; timestamp: number; sessionId?: string; subagentSessionId?: string; runId?: string; signalId?: string; queuedItemId?: string; } export interface SessionCreatedEvent extends HarnessEventBase { type: 'session_created'; resourceId: string; threadId: string; parentSessionId?: string; modeId: string; modelId: string; } export interface ModeChangedEvent extends HarnessEventBase { type: 'mode_changed'; modeId: string; previousModeId: string; } export interface ModelChangedEvent extends HarnessEventBase { type: 'model_changed'; modelId: string; previousModelId: string; } export interface ThreadClonedEvent extends HarnessEventBase { type: 'thread_cloned'; threadId: string; resourceId: string; sourceThreadId: string; title?: string; } export interface CustomEvent extends HarnessEventBase { type: string; payload?: JsonSerializable; } export type HarnessEvent = SessionCreatedEvent | ModeChangedEvent | ModelChangedEvent | ThreadClonedEvent | CustomEvent; export type HarnessEventListener = (event: HarnessEvent) => void | Promise; export type HarnessEventUnsubscribe = () => void; export declare const HARNESS_EVENT_ID_PREFIX = "harness-v1"; export interface ParsedHarnessEventId { epoch: string; sequence: number; } export declare class HarnessValidationError extends Error { readonly path: string; constructor(path: string, message: string); } export declare class HarnessEventSerializationError extends HarnessValidationError { readonly eventType: string; readonly reason: EventSerializationReason; readonly sessionId?: string | undefined; constructor(eventType: string, reason: EventSerializationReason, sessionId?: string | undefined); } export type EventSerializationReason = 'undefined' | 'function' | 'symbol' | 'bigint' | 'date' | 'map' | 'set' | 'typed-array' | 'non-plain-object' | 'cycle'; type JsonPrimitive = string | number | boolean | null; type JsonSerializable = JsonPrimitive | JsonSerializable[] | { [key: string]: JsonSerializable; }; type DistributiveOmit = T extends unknown ? Omit : never; export type EmitInput = DistributiveOmit; export interface EmitterScope { sessionId?: string; } export declare function formatHarnessEventId(epoch: string, sequence: number): string; export declare function parseHarnessEventId(eventId: string): ParsedHarnessEventId; export declare function sessionCreatedPayload(record: SessionRecord): Omit; export declare function assertCustomEventType(eventType: string): void; export declare function assertJsonSerializable(eventType: string, sessionId: string | undefined, value: unknown): void; export declare class EventEmitter { private readonly listeners; private epoch?; private seq; private readonly scope; private readonly onEvent?; constructor(scope?: EmitterScope, opts?: { onEvent?: HarnessEventListener; epoch?: string; nextSequence?: number; }); scoped(scope: EmitterScope): EventEmitter; subscribe(listener: HarnessEventListener): HarnessEventUnsubscribe; emit(event: EmitInput, overrides?: { sessionId?: string; }): HarnessEvent; forward(event: HarnessEvent): void; get listenerCount(): number; get epochId(): string; private validateCustomEvent; private dispatch; } export {}; //# sourceMappingURL=events.d.ts.map