"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LearningRouter = void 0;
const PerformanceScorecard_1 = require("./PerformanceScorecard");
class LearningRouter {
    capabilityRouter;
    scoring;
    scorecard;
    constructor(capabilityRouter, scoring) {
        this.capabilityRouter = capabilityRouter;
        this.scoring = scoring;
        this.scorecard = new PerformanceScorecard_1.PerformanceScorecard();
    }
    route(task, input) {
        const route = this.capabilityRouter.route(task, input);
        route.agents = [...route.agents].sort((a, b) => {
            const scoreA = (this.scoring.get(a.id)?.score || 0) + (this.scorecard.get(a.id)?.score || 0);
            const scoreB = (this.scoring.get(b.id)?.score || 0) + (this.scorecard.get(b.id)?.score || 0);
            return scoreB - scoreA;
        });
        return route;
    }
}
exports.LearningRouter = LearningRouter;
