import { parseJsonl, buildTraceFromRecords } from './traceReportParser.js';
import { cloneStepsForMode, sanitizeTraceParamsForMode } from './traceReportRedaction.js';
import { assertTraceParams, renderTraceReportMarkdown } from './traceReportRenderer.js';
export { assertTraceParams, renderTraceReportMarkdown };
export function renderTraceReportFromLogs(params, ndjsonLogPath, promptLogPath, mode) {
    if (mode === 'off') {
        return undefined;
    }
    const records = parseJsonl(ndjsonLogPath);
    if (records.length === 0) {
        throw new Error(`No session records found for trace report: ${ndjsonLogPath}`);
    }
    const promptRecords = promptLogPath ? parseJsonl(promptLogPath) : [];
    return renderTraceReportFromRecords(params, records, promptRecords, mode);
}
export function renderTraceReportFromRecords(params, records, promptRecords, mode) {
    if (mode === 'off') {
        return undefined;
    }
    if (records.length === 0) {
        throw new Error('No session records found for trace report from records');
    }
    const trace = buildTraceFromRecords(records, promptRecords, params.endTime);
    const paramsForMode = sanitizeTraceParamsForMode(params, mode);
    const stepsForMode = cloneStepsForMode(trace.steps, mode);
    return renderTraceReportMarkdown(paramsForMode, trace.traceStartedAt, stepsForMode);
}
//# sourceMappingURL=traceReport.js.map