import { logger } from "../logger.js";
export function wireRealtimeToAgent(options) {
    const { realtimeHandle, channelManager } = options;
    realtimeHandle.onVoiceSessionFinished((event) => {
        if (event.summary.noActionable) {
            logger.system(`[Realtime] Voice session ${event.sessionId} has no actionable items; not enqueueing follow-up.`);
            return;
        }
        const text = event.summaryText || event.summary.headline || "Voice session ended.";
        const filename = `${event.sessionId}.json`;
        const msg = {
            id: `realtime_voice_${event.sessionId}`,
            channel: "system",
            sender: "realtime",
            text: `## Realtime Voice Session Completed\n${text}`,
            attachments: [],
            timestamp: event.endedAt,
            meta: {
                kind: "realtime-voice-followup",
                sessionId: event.sessionId,
                transcriptFilename: filename,
            },
        };
        channelManager.enqueueInternalMessage(msg);
        realtimeHandle.markTranscriptProcessed(filename).catch((err) => {
            logger.warn(`[Realtime] Failed to mark transcript processed after enqueue: ${err instanceof Error ? err.message : String(err)}`);
        });
        logger.system(`[Realtime] Enqueued voice follow-up through message path (session ${event.sessionId}).`);
    });
}
//# sourceMappingURL=agent-bridge.js.map