"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.TestServer = void 0;
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
const database_js_1 = require("../../utils/database.js");
const git_js_1 = require("../../utils/git.js");
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
class TestServer {
    server;
    dbManager;
    gitOps;
    tempDbPath;
    constructor() {
        // Create temporary database for testing
        this.tempDbPath = path.join(os.tmpdir(), `test-mcp-${Date.now()}.db`);
        this.dbManager = new database_js_1.DatabaseManager({
            filename: this.tempDbPath,
            maxSize: 10 * 1024 * 1024, // 10MB
            walMode: true,
        });
        this.gitOps = new git_js_1.GitOperations(os.tmpdir());
        // Import and configure the server logic here
        // For now, we'll create a minimal server for testing
        this.server = new index_js_1.Server({
            name: 'test-memory-keeper',
            version: '1.0.0',
        }, {
            capabilities: {
                tools: {},
            },
        });
    }
    async callTool(name, args) {
        // This would call the actual tool handler
        // For now, returning a mock response
        return {
            content: [
                {
                    type: 'text',
                    text: `Called ${name} with ${JSON.stringify(args)}`,
                },
            ],
        };
    }
    cleanup() {
        this.dbManager.close();
        try {
            fs.unlinkSync(this.tempDbPath);
            fs.unlinkSync(`${this.tempDbPath}-wal`);
            fs.unlinkSync(`${this.tempDbPath}-shm`);
        }
        catch (_e) {
            // Ignore
        }
    }
}
exports.TestServer = TestServer;
