/**
 * apt-upgrade fix handler.
 * Runs `apt-get update && apt-get upgrade -y` with DEBIAN_FRONTEND=noninteractive
 * via stdin (avoids shell metacharacter issues).
 * No rollback step — system package upgrades are not reversible.
 */
import { sshExec } from "../../../utils/ssh.js";
import { raw } from "../../../utils/sshCommand.js";
const APT_UPGRADE_CMD = "apt-upgrade";
export const aptUpgradeHandler = {
    match(fixCommand) {
        if (fixCommand.trim() === APT_UPGRADE_CMD) {
            return { type: "apt-upgrade", action: "upgrade" };
        }
        return null;
    },
    async execute(ip, _params) {
        const result = await sshExec(ip, raw("DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y"), { useStdin: true });
        if (result.code !== 0) {
            return { success: false, error: result.stderr };
        }
        return { success: true };
    },
};
//# sourceMappingURL=aptUpgrade.js.map