/**
 * Adapts TaskListItem to SlackTaskDetail for Slack run summary notifications.
 */
export function generateRunId() {
    const now = new Date();
    const pad = (n, len) => String(n).padStart(len, '0');
    return `run-${pad(now.getFullYear(), 4)}${pad(now.getMonth() + 1, 2)}${pad(now.getDate(), 2)}-${pad(now.getHours(), 2)}${pad(now.getMinutes(), 2)}${pad(now.getSeconds(), 2)}`;
}
function computeTaskDurationSec(item) {
    if (!item.startedAt || !item.completedAt) {
        return 0;
    }
    return Math.round((new Date(item.completedAt).getTime() - new Date(item.startedAt).getTime()) / 1000);
}
export function toSlackTaskDetail(item) {
    return {
        name: item.name,
        success: item.kind === 'completed',
        workflow: item.data?.workflow ?? 'default',
        issueNumber: item.data?.issue,
        durationSec: computeTaskDurationSec(item),
        branch: item.branch,
        worktreePath: item.worktreePath,
        prUrl: item.prUrl,
        failureStep: item.failure?.step,
        failureError: item.failure?.error,
        failureLastMessage: item.failure?.last_message,
    };
}
//# sourceMappingURL=slackSummaryAdapter.js.map