/**
 * POST /api/terminal/[sessionId]/resize
 *
 * Resizes the pseudo-terminal for a session. Body: `{ cols, rows }`.
 */
import { resolve } from '../../../../../lib/server-container.js';
export const dynamic = 'force-dynamic';
export async function POST(request, { params }) {
    const { sessionId } = await params;
    try {
        const body = (await request.json().catch(() => ({})));
        if (typeof body.cols !== 'number' || typeof body.rows !== 'number') {
            return Response.json({ error: 'cols and rows are required' }, { status: 400 });
        }
        const service = resolve('ITerminalSessionService');
        if (!service.exists(sessionId)) {
            return Response.json({ error: 'session not found' }, { status: 404 });
        }
        service.resize(sessionId, body.cols, body.rows);
        return Response.json({ ok: true });
    }
    catch (error) {
        // eslint-disable-next-line no-console
        console.error('[POST /api/terminal/:sessionId/resize]', error);
        return Response.json({ error: String(error) }, { status: 500 });
    }
}
