/**
 * Handler for terminal_resize messages.
 *
 * Resizes a PTY process identified by terminalId to new dimensions.
 */
import { ErrorCode } from "@pocketcoder/shared/constants";
import { resizeTerminal } from "../services/terminal-manager.js";
import { logger } from "../utils/logger.js";
export async function handleTerminalResize(message, send) {
    const msg = message;
    const { requestId, payload } = msg;
    const { terminalId, cols, rows } = payload;
    try {
        resizeTerminal(terminalId, cols, rows);
    }
    catch (err) {
        const errMsg = err instanceof Error ? err.message : String(err);
        logger.error(`terminal_resize failed: ${errMsg}`);
        send({
            type: "terminal_resize",
            requestId,
            error: {
                code: ErrorCode.TERMINAL_NOT_FOUND,
                message: `Terminal not found: ${terminalId}`,
            },
        });
    }
}
//# sourceMappingURL=terminal-resize.js.map