// GET /api/hail/engagements/[id]/setup-package  — read the current dry-run package

import { getEngagement } from '../../../../../../lib/hail/engagements.js';
import { getSetupPackage } from '../../../../../../lib/hail/setup-package.js';
import { requirePractitioner, errorResponse } from '../../../guard.js';

export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';

export async function GET(req, { params }) {
  const { id } = await params;
  try {
    await requirePractitioner(req);
    if (!getEngagement(id)) return Response.json({ error: 'engagement_not_found' }, { status: 404 });
    return Response.json({ setup_package: getSetupPackage(id) });
  } catch (err) {
    return errorResponse(err);
  }
}
