import { DEFAULT_TRACE_SUMMARIZERS } from './default-trace-summarizers.js';
/**
 * Summarizes trace events into durable evidence strings for turn/session
 * records. It owns event summarization policy, not live host status rendering.
 */
export class TraceSummaryService {
    static defaultService = new TraceSummaryService();
    summarizers;
    constructor(summarizers = {}) {
        this.summarizers = { ...DEFAULT_TRACE_SUMMARIZERS, ...summarizers };
    }
    static default() {
        return TraceSummaryService.defaultService;
    }
    summarizeEvent(event, context) {
        const handler = this.summarizers[event.type];
        return TraceSummaryService.normalizeSummary(handler?.(event, context));
    }
    summarizeTrace(trace) {
        return trace.flatMap((event, index) => this.summarizeEvent(event, { trace, index }));
    }
    countAssistantSteps(trace) {
        return trace.filter((event) => event.type === 'assistant.turn').length;
    }
    static normalizeSummary(summary) {
        if (Array.isArray(summary)) {
            return summary;
        }
        return summary ? [summary] : [];
    }
}
//# sourceMappingURL=trace-summary-service.js.map