import { Request, Response } from "express"; import { executionCoordinator } from "../services/execution"; import { asyncHandler } from "../services/errorHandler"; import { auditLog } from "../middleware"; /** * POST /api/plans/:planId/execute * Execute a plan */ export const executePlan = asyncHandler(async (req: Request, res: Response) => { const { planId } = req.params; const result = await executionCoordinator.executePlan(planId); res.json(result); }); /** * GET /api/plans/:planId/status * Get execution status */ export const getExecutionStatus = asyncHandler(async (req: Request, res: Response) => { const { planId } = req.params; const executionId = req.query.executionId as string; if (executionId) { const status = await executionCoordinator.getExecutionStatus(executionId); return res.json(status); } // Get latest execution for plan res.json({ status: "pending" }); }); /** * POST /api/plans/:planId/abort * Abort execution */ export const abortExecution = asyncHandler(async (req: Request, res: Response) => { const { planId } = req.params; const executionId = req.query.executionId as string; if (executionId) { await executionCoordinator.abortExecution(executionId, planId, "User aborted"); } res.json({ success: true }); });