/**
 * /api/interactive/sessions/[id]
 *
 * DELETE - Stop an active interactive session. Idempotent.
 * GET    - Retrieve session record by ID.
 */
import { NextResponse } from 'next/server';
import { resolve } from '../../../../../lib/server-container.js';
export const dynamic = 'force-dynamic';
export async function DELETE(_request, { params }) {
    try {
        const { id } = await params;
        const service = resolve('IInteractiveSessionService');
        // Verify session exists
        const session = await service.getSession(id);
        if (!session) {
            return NextResponse.json({ error: 'Session not found' }, { status: 404 });
        }
        await service.stopSession(id);
        return new NextResponse(null, { status: 204 });
    }
    catch (error) {
        // eslint-disable-next-line no-console
        console.error('[DELETE /api/interactive/sessions/:id]', error);
        return NextResponse.json({ error: error instanceof Error ? error.message : 'Internal server error' }, { status: 500 });
    }
}
export async function GET(_request, { params }) {
    try {
        const { id } = await params;
        const service = resolve('IInteractiveSessionService');
        const session = await service.getSession(id);
        if (!session) {
            return NextResponse.json({ error: 'Session not found' }, { status: 404 });
        }
        return NextResponse.json(session);
    }
    catch (error) {
        // eslint-disable-next-line no-console
        console.error('[GET /api/interactive/sessions/:id]', error);
        return NextResponse.json({ error: error instanceof Error ? error.message : 'Internal server error' }, { status: 500 });
    }
}
