/**
 * Shared types for the StreamAgentEventsUseCase and its pure helper modules.
 *
 * Extracted from the monolithic use case as part of the clean-arch cleanup
 * (spec 089, file size violation #30). These types are consumed by the
 * orchestrator use case AND by the per-delta helper functions that live
 * next to it.
 */
import { AgentRunStatus, InteractiveSessionStatus } from '../../../../domain/generated/output.js';
import { InteractiveSessionEventType, NotificationEventType, NotificationSeverity, } from '../../../../domain/generated/output.js';
/**
 * Mapping table from terminal-ish `AgentRunStatus` values to the notification
 * they should produce. Exported so helper modules can share one source of
 * truth with the orchestrator.
 */
export const STATUS_TO_EVENT = {
    [AgentRunStatus.running]: {
        eventType: NotificationEventType.AgentStarted,
        severity: NotificationSeverity.Info,
    },
    [AgentRunStatus.waitingApproval]: {
        eventType: NotificationEventType.WaitingApproval,
        severity: NotificationSeverity.Warning,
    },
    [AgentRunStatus.completed]: {
        eventType: NotificationEventType.AgentCompleted,
        severity: NotificationSeverity.Success,
    },
    [AgentRunStatus.failed]: {
        eventType: NotificationEventType.AgentFailed,
        severity: NotificationSeverity.Error,
    },
    [AgentRunStatus.interrupted]: {
        eventType: NotificationEventType.AgentFailed,
        severity: NotificationSeverity.Warning,
    },
    [AgentRunStatus.cancelled]: {
        eventType: NotificationEventType.AgentFailed,
        severity: NotificationSeverity.Warning,
    },
};
/** Map agent graph node name from `AgentRun.result` to a phase name. */
export function resultToPhase(result) {
    if (!result?.startsWith('node:'))
        return undefined;
    return result.slice(5); // "node:analyze" → "analyze"
}
/**
 * Map interactive session status → event type. Stays pure so helper modules
 * can call it without hitting tsyringe.
 */
export function statusToInteractiveEventType(status) {
    switch (status) {
        case InteractiveSessionStatus.booting:
            return InteractiveSessionEventType.Booting;
        case InteractiveSessionStatus.ready:
            return InteractiveSessionEventType.Ready;
        case InteractiveSessionStatus.error:
            return InteractiveSessionEventType.Error;
        default:
            return InteractiveSessionEventType.Stopped;
    }
}
