"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LlmOrchestrationModule = void 0;
const common_1 = require("@nestjs/common");
const typeorm_1 = require("@nestjs/typeorm");
const llm_output_parser_service_1 = require("./parser/llm-output-parser.service");
const llm_turn_processor_service_1 = require("./llm-turn-processor.service");
const tool_schema_service_1 = require("./tool-schema.service");
const history_compression_service_1 = require("./history-compression.service");
const ai_actions_module_1 = require("../ai-actions/ai-actions.module");
const session_inputs_module_1 = require("../session-inputs/session-inputs.module");
const chat_module_1 = require("../interactive-chat/chat.module");
const events_module_1 = require("../events/events.module");
const application_state_module_1 = require("../application-state/application-state.module");
const message_bus_module_1 = require("../message-bus/message-bus.module");
const notifications_module_1 = require("../notifications/notifications.module");
const app_module_1 = require("../app.module");
const core_entities_1 = require("../core-entities");
const execution_logs_module_1 = require("../execution-logs/execution-logs.module");
const system_prompts_module_1 = require("../system-prompts/system-prompts.module");
const sessions_module_1 = require("../sessions/sessions.module");
const workspace_module_1 = require("../workspace/workspace.module");
const mcp_module_1 = require("../mcp/mcp.module");
const sub_agents_module_1 = require("../sub-agents/sub-agents.module");
const tool_hooks_module_1 = require("../tool-hooks/tool-hooks.module");
const syntax_validation_module_1 = require("../syntax-validation/syntax-validation.module");
const context_generation_module_1 = require("../context-generation/context-generation.module");
const context_templates_module_1 = require("../context-templates/context-templates.module");
const context_snippets_module_1 = require("../context-snippets/context-snippets.module");
const custom_snippets_module_1 = require("../custom-snippets/custom-snippets.module");
const custom_variables_module_1 = require("../custom-variables/custom-variables.module");
const agents_module_1 = require("../agents/agents.module");
const create_file_handler_1 = require("./action-handlers/create-file.handler");
const delete_file_handler_1 = require("./action-handlers/delete-file.handler");
const overwrite_file_handler_1 = require("./action-handlers/overwrite-file.handler");
const run_command_handler_1 = require("./action-handlers/run-command.handler");
const request_context_handler_1 = require("./action-handlers/request-context.handler");
const final_handler_1 = require("./action-handlers/final.handler");
const quick_edit_handler_1 = require("./action-handlers/quick-edit.handler");
const apply_diff_handler_1 = require("./action-handlers/apply-diff.handler");
const patch_handler_1 = require("./action-handlers/patch.handler");
const new_session_handler_1 = require("./action-handlers/new-session.handler");
const write_todo_handler_1 = require("./action-handlers/write-todo.handler");
const execute_code_handler_1 = require("./action-handlers/execute-code.handler");
const invoke_subagent_handler_1 = require("./action-handlers/invoke-subagent.handler");
const list_sub_agents_handler_1 = require("./action-handlers/list-sub-agents.handler");
const get_session_history_handler_1 = require("./action-handlers/get-session-history.handler");
const generate_title_handler_1 = require("./action-handlers/generate-title.handler");
const ask_user_handler_1 = require("./action-handlers/ask-user.handler");
const get_messages_handler_1 = require("./action-handlers/get-messages.handler");
const discard_messages_handler_1 = require("./action-handlers/discard-messages.handler");
const html_final_handler_1 = require("./action-handlers/html-final.handler");
const manage_system_prompts_handler_1 = require("./action-handlers/manage-system-prompts.handler");
const manage_context_templates_handler_1 = require("./action-handlers/manage-context-templates.handler");
const manage_context_snippets_handler_1 = require("./action-handlers/manage-context-snippets.handler");
const manage_custom_snippets_handler_1 = require("./action-handlers/manage-custom-snippets.handler");
const manage_custom_variables_handler_1 = require("./action-handlers/manage-custom-variables.handler");
const manage_sub_agents_handler_1 = require("./action-handlers/manage-sub-agents.handler");
const manage_agents_handler_1 = require("./action-handlers/manage-agents.handler");
const manage_mcp_servers_handler_1 = require("./action-handlers/manage-mcp-servers.handler");
const manage_tool_hooks_handler_1 = require("./action-handlers/manage-tool-hooks.handler");
const invalid_tool_feedback_hook_1 = require("./hooks/invalid-tool-feedback.hook");
const frontend_notification_hook_1 = require("./hooks/frontend-notification.hook");
const follow_up_post_execution_hook_1 = require("./hooks/follow-up-post-execution.hook");
const yolo_mode_post_execution_hook_1 = require("./hooks/yolo-mode-post-execution.hook");
let LlmOrchestrationModule = class LlmOrchestrationModule {
};
exports.LlmOrchestrationModule = LlmOrchestrationModule;
exports.LlmOrchestrationModule = LlmOrchestrationModule = __decorate([
    (0, common_1.Module)({
        imports: [
            typeorm_1.TypeOrmModule.forFeature([core_entities_1.AIAction, core_entities_1.SessionInput, core_entities_1.Session, core_entities_1.SystemPrompt]),
            (0, common_1.forwardRef)(() => ai_actions_module_1.AIActionsModule),
            (0, common_1.forwardRef)(() => session_inputs_module_1.SessionInputsModule),
            (0, common_1.forwardRef)(() => chat_module_1.InteractiveChatModule),
            events_module_1.EventsModule,
            message_bus_module_1.MessageBusModule,
            notifications_module_1.NotificationsModule,
            (0, common_1.forwardRef)(() => app_module_1.AppModule),
            (0, common_1.forwardRef)(() => system_prompts_module_1.SystemPromptsModule),
            sessions_module_1.SessionsModule,
            application_state_module_1.ApplicationStateModule,
            execution_logs_module_1.ExecutionLogsModule,
            workspace_module_1.WorkspaceModule,
            mcp_module_1.McpModule,
            sub_agents_module_1.SubAgentsModule,
            tool_hooks_module_1.ToolHooksModule,
            syntax_validation_module_1.SyntaxValidationModule,
            context_generation_module_1.ContextGenerationModule,
            context_templates_module_1.ContextTemplatesModule,
            context_snippets_module_1.ContextSnippetsModule,
            custom_snippets_module_1.CustomSnippetsModule,
            custom_variables_module_1.CustomVariablesModule,
            agents_module_1.AgentsModule,
        ],
        providers: [
            llm_output_parser_service_1.LlmOutputParserService,
            llm_turn_processor_service_1.LlmTurnProcessorService,
            tool_schema_service_1.ToolSchemaService,
            history_compression_service_1.HistoryCompressionService,
            create_file_handler_1.CreateFileHandler,
            delete_file_handler_1.DeleteFileHandler,
            overwrite_file_handler_1.OverwriteFileHandler,
            run_command_handler_1.RunCommandHandler,
            request_context_handler_1.RequestContextHandler,
            final_handler_1.FinalHandler,
            quick_edit_handler_1.QuickEditHandler,
            apply_diff_handler_1.ApplyDiffHandler,
            patch_handler_1.PatchHandler,
            new_session_handler_1.NewSessionHandler,
            write_todo_handler_1.WriteTodoHandler,
            execute_code_handler_1.ExecuteCodeHandler,
            invoke_subagent_handler_1.InvokeSubAgentHandler,
            list_sub_agents_handler_1.ListSubAgentsHandler,
            get_session_history_handler_1.GetSessionHistoryHandler,
            generate_title_handler_1.GenerateTitleHandler,
            ask_user_handler_1.AskUserHandler,
            get_messages_handler_1.GetMessagesHandler,
            discard_messages_handler_1.DiscardMessagesHandler,
            html_final_handler_1.HtmlFinalHandler,
            manage_system_prompts_handler_1.ManageSystemPromptsHandler,
            manage_context_templates_handler_1.ManageContextTemplatesHandler,
            manage_context_snippets_handler_1.ManageContextSnippetsHandler,
            manage_custom_snippets_handler_1.ManageCustomSnippetsHandler,
            manage_custom_variables_handler_1.ManageCustomVariablesHandler,
            manage_sub_agents_handler_1.ManageSubAgentsHandler,
            manage_agents_handler_1.ManageAgentsHandler,
            manage_mcp_servers_handler_1.ManageMcpServersHandler,
            manage_tool_hooks_handler_1.ManageToolHooksHandler,
            invalid_tool_feedback_hook_1.InvalidToolFeedbackHook,
            frontend_notification_hook_1.FrontendNotificationHook,
            follow_up_post_execution_hook_1.FollowUpPostExecutionHook,
            yolo_mode_post_execution_hook_1.YoloModePostExecutionHook,
            {
                provide: 'ACTION_HANDLER_REGISTRY',
                useFactory: (createFile, deleteFile, overwriteFile, runCommand, requestContext, final, quickEdit, applyDiff, patch, newSession, writeTodo, executeCode, invokeSubAgent, listSubAgents, getSessionHistory, generateTitle, askUser, getMessages, discardMessages, htmlFinal, manageSystemPrompts, manageContextTemplates, manageContextSnippets, manageCustomSnippets, manageCustomVariables, manageSubAgents, manageAgents, manageMcpServers, manageToolHooks) => {
                    const registry = new Map();
                    registry.set(createFile.toolName, createFile);
                    registry.set(deleteFile.toolName, deleteFile);
                    registry.set(overwriteFile.toolName, overwriteFile);
                    registry.set(runCommand.toolName, runCommand);
                    registry.set(requestContext.toolName, requestContext);
                    registry.set(final.toolName, final);
                    registry.set(quickEdit.toolName, quickEdit);
                    registry.set(applyDiff.toolName, applyDiff);
                    registry.set(patch.toolName, patch);
                    registry.set(newSession.toolName, newSession);
                    registry.set(writeTodo.toolName, writeTodo);
                    registry.set(executeCode.toolName, executeCode);
                    registry.set(invokeSubAgent.toolName, invokeSubAgent);
                    registry.set(listSubAgents.toolName, listSubAgents);
                    registry.set(getSessionHistory.toolName, getSessionHistory);
                    registry.set(generateTitle.toolName, generateTitle);
                    registry.set(askUser.toolName, askUser);
                    registry.set(getMessages.toolName, getMessages);
                    registry.set(discardMessages.toolName, discardMessages);
                    registry.set(htmlFinal.toolName, htmlFinal);
                    registry.set(manageSystemPrompts.toolName, manageSystemPrompts);
                    registry.set(manageContextTemplates.toolName, manageContextTemplates);
                    registry.set(manageContextSnippets.toolName, manageContextSnippets);
                    registry.set(manageCustomSnippets.toolName, manageCustomSnippets);
                    registry.set(manageCustomVariables.toolName, manageCustomVariables);
                    registry.set(manageSubAgents.toolName, manageSubAgents);
                    registry.set(manageAgents.toolName, manageAgents);
                    registry.set(manageMcpServers.toolName, manageMcpServers);
                    registry.set(manageToolHooks.toolName, manageToolHooks);
                    return registry;
                },
                inject: [
                    create_file_handler_1.CreateFileHandler,
                    delete_file_handler_1.DeleteFileHandler,
                    overwrite_file_handler_1.OverwriteFileHandler,
                    run_command_handler_1.RunCommandHandler,
                    request_context_handler_1.RequestContextHandler,
                    final_handler_1.FinalHandler,
                    quick_edit_handler_1.QuickEditHandler,
                    apply_diff_handler_1.ApplyDiffHandler,
                    patch_handler_1.PatchHandler,
                    new_session_handler_1.NewSessionHandler,
                    write_todo_handler_1.WriteTodoHandler,
                    execute_code_handler_1.ExecuteCodeHandler,
                    invoke_subagent_handler_1.InvokeSubAgentHandler,
                    list_sub_agents_handler_1.ListSubAgentsHandler,
                    get_session_history_handler_1.GetSessionHistoryHandler,
                    generate_title_handler_1.GenerateTitleHandler,
                    ask_user_handler_1.AskUserHandler,
                    get_messages_handler_1.GetMessagesHandler,
                    discard_messages_handler_1.DiscardMessagesHandler,
                    html_final_handler_1.HtmlFinalHandler,
                    manage_system_prompts_handler_1.ManageSystemPromptsHandler,
                    manage_context_templates_handler_1.ManageContextTemplatesHandler,
                    manage_context_snippets_handler_1.ManageContextSnippetsHandler,
                    manage_custom_snippets_handler_1.ManageCustomSnippetsHandler,
                    manage_custom_variables_handler_1.ManageCustomVariablesHandler,
                    manage_sub_agents_handler_1.ManageSubAgentsHandler,
                    manage_agents_handler_1.ManageAgentsHandler,
                    manage_mcp_servers_handler_1.ManageMcpServersHandler,
                    manage_tool_hooks_handler_1.ManageToolHooksHandler,
                ],
            },
            {
                provide: 'POST_EXECUTION_HOOKS',
                useFactory: (invalidTool, frontendNotification, followUp, yoloMode) => {
                    return [invalidTool, yoloMode, followUp, frontendNotification];
                },
                inject: [
                    invalid_tool_feedback_hook_1.InvalidToolFeedbackHook,
                    frontend_notification_hook_1.FrontendNotificationHook,
                    follow_up_post_execution_hook_1.FollowUpPostExecutionHook,
                    yolo_mode_post_execution_hook_1.YoloModePostExecutionHook,
                ],
            },
        ],
        exports: [
            llm_turn_processor_service_1.LlmTurnProcessorService,
            tool_schema_service_1.ToolSchemaService,
            history_compression_service_1.HistoryCompressionService,
            'ACTION_HANDLER_REGISTRY',
        ],
    })
], LlmOrchestrationModule);
//# sourceMappingURL=llm-orchestration.module.js.map