import { readAuditLog } from '../engine/autopilot/audit-logger.js';
export async function handleAutopilotAudit(args) {
    const filter = {
        trigger: args.trigger,
        action: args.action,
        status: args.status,
        since: args.since,
        limit: args.limit ?? 50,
    };
    const entries = await readAuditLog(args.projectPath, filter);
    if (entries.length === 0) {
        return {
            content: [
                {
                    type: 'text',
                    text: 'No audit entries found matching the given filters.',
                },
            ],
        };
    }
    const rows = entries
        .map((e) => {
        const icon = e.status === 'ok'
            ? '✅'
            : e.status === 'fail'
                ? '❌'
                : e.status === 'skipped'
                    ? '⏭️'
                    : '⏱️';
        const meta = e.metadata ? ` | ${JSON.stringify(e.metadata)}` : '';
        const err = e.error ? ` | error: ${e.error}` : '';
        return `${icon} \`${e.ts}\` **${e.trigger}** → \`${e.action}\` (${String(e.durationMs)}ms)${meta}${err}`;
    })
        .join('\n');
    const summary = `## Autopilot Audit Log\n\n**${String(entries.length)} entries**\n\n${rows}`;
    return {
        content: [
            {
                type: 'text',
                text: summary,
            },
        ],
    };
}
//# sourceMappingURL=autopilot-audit.js.map