import { ReviewProgressMemoryGateway } from "../modules/review-execution/interface-adapters/gateways/reviewProgress.memory.gateway.js";
import { JobContextMemoryGateway } from "../modules/review-execution/interface-adapters/gateways/jobContext.memory.gateway.js";
export function createMcpDependencies(input) {
    const { reviewContextGateway, onProgressChange } = input;
    const progressGateway = new ReviewProgressMemoryGateway();
    const jobContextGateway = new JobContextMemoryGateway();
    progressGateway.setOnProgressChange((jobId, progress) => {
        if (onProgressChange) {
            onProgressChange(jobId, progress);
        }
        syncProgressToReviewContext(jobId, progress, jobContextGateway, reviewContextGateway);
    });
    return {
        progressGateway,
        jobContextGateway,
        reviewContextGateway,
    };
}
function syncProgressToReviewContext(jobId, progress, jobContextGateway, reviewContextGateway) {
    const jobContext = jobContextGateway.get(jobId);
    if (!jobContext) {
        return;
    }
    const runningAgent = progress.agents.find((a) => a.status === "running");
    const completedAgents = progress.agents
        .filter((a) => a.status === "completed" || a.status === "failed")
        .map((a) => a.name);
    reviewContextGateway.updateProgress(jobContext.localPath, jobContext.mergeRequestId, {
        phase: progress.currentPhase,
        currentStep: runningAgent?.name ?? null,
        stepsCompleted: completedAgents,
        updatedAt: new Date().toISOString(),
    });
}
//# sourceMappingURL=mcpDependencies.js.map