"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("./config");
const logger_1 = __importDefault(require("./logger"));
const mcpServer_1 = require("./mcpServer");
// Ensure all required directories exist
(0, config_1.ensureDirectories)();
// Log startup information
logger_1.default.info(`Starting ${config_1.config.name}`);
logger_1.default.info(`Memories directory: ${config_1.config.memoriesDir}`);
try {
// Create and start the MCP server
const server = new mcpServer_1.MCPServer();
server.start();
// Handle graceful shutdown
process.on('SIGINT', () => {
logger_1.default.info('Received SIGINT signal. Shutting down gracefully...');
process.exit(0);
});
process.on('SIGTERM', () => {
logger_1.default.info('Received SIGTERM signal. Shutting down gracefully...');
process.exit(0);
});
// Handle uncaught exceptions
process.on('uncaughtException', (error) => {
logger_1.default.error(`Uncaught Exception: ${error.message}`);
logger_1.default.error(error.stack);
process.exit(1);
});
process.on('unhandledRejection', (reason, promise) => {
logger_1.default.error('Unhandled Promise Rejection:');
logger_1.default.error(`Promise: ${promise}`);
logger_1.default.error(`Reason: ${reason}`);
});
}
catch (error) {
logger_1.default.error(`Failed to start server: ${error}`);
process.exit(1);
}