"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandRouter = void 0;
const AgentRegistry_1 = require("./AgentRegistry");
const SquadRegistry_1 = require("./SquadRegistry");
const SkillRegistryV2_1 = require("./SkillRegistryV2");
const OrgStructure_1 = require("./OrgStructure");
const ExecutionBoard_1 = require("./ExecutionBoard");
const RoleHandoff_1 = require("./RoleHandoff");
const CadenceEngine_1 = require("./CadenceEngine");
class CommandRouter {
    agents = new AgentRegistry_1.AgentRegistry();
    squads = new SquadRegistry_1.SquadRegistry();
    skills = new SkillRegistryV2_1.SkillRegistryV2();
    org = new OrgStructure_1.OrgStructure();
    board = new ExecutionBoard_1.ExecutionBoard();
    handoffs = new RoleHandoff_1.RoleHandoff();
    cadence = new CadenceEngine_1.CadenceEngine();
    route(parsed) {
        if (parsed.kind === 'slash') {
            switch (parsed.command) {
                case 'status':
                    return 'Use `openlife system status` ou `openlife system doctor-world` para diagnóstico do sistema.';
                case 'doctor':
                    return 'Use `openlife system doctor` ou `openlife system doctor-world`.\n';
                case 'bootstrap':
                    return 'Use `openlife system bootstrap-world` para bootstrap world-class.';
                case 'skills':
                    return this.skills.all().slice(0, 20).map(s => `- ${s.id}`).join('\n');
                case 'squads':
                    return this.squads.all().slice(0, 20).map(s => `- ${s.id}`).join('\n');
                case 'agents':
                    return this.agents.all().slice(0, 20).map(a => `- ${a.id}`).join('\n');
                case 'memory':
                    return 'Use `openlife memory status`, `provider-list`, `provider-use` ou `test`.';
                case 'benchmark':
                    return 'Use `openlife benchmark run`, `compare` ou `report`.';
                case 'swarm':
                    return 'Use `openlife swarm run` ou `openlife swarm consensus-test`.';
                case 'org':
                    return this.org.all().map(r => `- ${r.id}: ${r.title}`).join('\n');
                case 'board':
                    return this.board.getAll().slice(0, 20).map(item => `- [${item.status}] ${item.id} (${item.ownerRole})`).join('\n') || 'Execution board vazio.';
                case 'handoff':
                    return this.handoffs.getAll().slice(0, 20).map(item => `- ${item.fromRole} -> ${item.toRole} [${item.status}] ${item.missionId}`).join('\n') || 'Sem handoffs.';
                case 'cadence':
                    return this.cadence.getAll().slice(0, 20).map(item => `- ${item.kind} [${item.status}] ${item.title}`).join('\n') || 'Sem eventos de cadence.';
                case 'consent':
                    return 'Use `openlife governance consent destructive <userId>` para liberar ações destrutivas por janela curta.';
                default:
                    return `Comando /${parsed.command} ainda não reconhecido.`;
            }
        }
        if (parsed.kind === 'mention' && parsed.target) {
            const target = parsed.target;
            const agent = this.agents.all().find(a => a.id === target || a.name.toLowerCase() === target.toLowerCase());
            if (agent)
                return `Agente resolvido: ${agent.id} (${agent.role})`;
            const squad = this.squads.all().find(s => s.id === target);
            if (squad)
                return `Squad resolvida: ${squad.id} (${squad.domain})`;
            const skill = this.skills.all().find(s => s.id === target);
            if (skill)
                return `Skill resolvida: ${skill.id}`;
            return `@${target} não foi resolvido em agente, squad ou skill.`;
        }
        return null;
    }
}
exports.CommandRouter = CommandRouter;
