"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const path_1 = __importDefault(require("path"));
const serverPath = path_1.default.join(__dirname, "dist", "src", "server.js");
const serverProcess = (0, child_process_1.spawn)("node", [serverPath], {
stdio: ["pipe", "pipe", "inherit"]
});
const requests = [
{
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: "2024-11-05",
capabilities: {},
clientInfo: {
name: "test-client",
version: "1.0.0"
}
}
},
{
jsonrpc: "2.0",
id: 2,
method: "tools/list",
params: {}
}
];
let buffer = "";
serverProcess.stdout.on("data", (data) => {
buffer += data.toString();
const lines = buffer.split("\n");
buffer = lines.pop() || "";
for (const line of lines) {
if (!line.trim())
continue;
try {
const response = JSON.parse(line);
console.log("Received response:", JSON.stringify(response, null, 2));
if (response.id === 2) {
console.log("Verification complete: Tools listed successfully.");
serverProcess.kill();
process.exit(0);
}
}
catch (e) {
console.error("Error parsing JSON:", e);
}
}
});
// Send requests
requests.forEach((req) => {
const msg = JSON.stringify(req) + "\n";
serverProcess.stdin.write(msg);
});
setTimeout(() => {
console.error("Timeout waiting for response");
serverProcess.kill();
process.exit(1);
}, 5000);