/** * Event system for tooled-prompt * * Provides a simple event emitter for streaming LLM events */ /** * Event types emitted during prompt execution */ export interface TooledPromptEvents { /** Emitted at the start of each prompt execution */ start: () => void; /** Thinking/reasoning content from the LLM */ thinking: (content: string) => void; /** Response content from the LLM */ content: (content: string) => void; /** Tool call started */ tool_call: (name: string, args: Record) => void; /** Tool call completed successfully */ tool_result: (name: string, result: string, duration: number) => void; /** Tool call failed */ tool_error: (name: string, error: string) => void; } /** * Event handler function type */ type EventHandler = TooledPromptEvents[K]; /** * Simple typed event emitter for tooled-prompt events */ export declare class TooledPromptEmitter { private handlers; /** * Subscribe to an event */ on(event: K, handler: EventHandler): void; /** * Unsubscribe from an event */ off(event: K, handler: EventHandler): void; /** * Emit an event to all subscribers */ emit(event: K, ...args: Parameters): void; /** * Check if there are any handlers for an event */ hasHandlers(event: K): boolean; /** * Remove all handlers for all events */ clear(): void; } /** * Default content handler - writes to stdout */ export declare function defaultContentHandler(content: string): void; /** * Default thinking handler - writes to stdout with formatting */ export declare function defaultThinkingHandler(content: string): void; /** * Default tool_call handler - logs tool invocation */ export declare function defaultToolCallHandler(name: string, args: Record): void; /** * Default tool_result handler - logs result */ export declare function defaultToolResultHandler(_name: string, result: string, _duration: number): void; /** * Default tool_error handler - logs error */ export declare function defaultToolErrorHandler(name: string, error: string): void; /** * Options for installDefaultHandlers */ export interface DefaultHandlerOptions { /** When returns true, suppresses all console output */ isSilent?: () => boolean; /** When returns true, streams full thinking content instead of just showing a label */ showThinking?: () => boolean; } /** * Install default logging handlers on an emitter * * @param target - Object with an `on` method for subscribing to events * @param options - Optional getters for silent and showThinking behavior */ export declare function installDefaultHandlers(target: { on: TooledPromptEmitter['on']; }, options?: DefaultHandlerOptions): void; export {}; //# sourceMappingURL=events.d.ts.map