#!/usr/bin/env tsx
/**
* Test script for Web UI feature
*
* This script tests the open_terminal_ui tool by:
* 1. Creating a terminal manager
* 2. Creating some test terminals
* 3. Starting the Web UI
* 4. Keeping the server running for manual testing
*/
import { TerminalManager } from "../terminal-manager.js";
import { WebUIManager } from "../web-ui-manager.js";
async function main() {
console.log("π§ͺ Testing Web UI Feature...\n");
// Create terminal manager
console.log("1οΈβ£ Creating terminal manager...");
const terminalManager = new TerminalManager({
maxBufferSize: 10000,
sessionTimeout: 86400000,
});
console.log("β
Terminal manager created\n");
// Create some test terminals
console.log("2οΈβ£ Creating test terminals...");
const terminal1 = await terminalManager.createTerminal({
shell: "/bin/bash",
cwd: process.cwd(),
});
console.log(`β
Terminal 1 created: ${terminal1}`);
const terminal2 = await terminalManager.createTerminal({
shell: "/bin/bash",
cwd: process.cwd(),
});
console.log(`β
Terminal 2 created: ${terminal2}`);
// Send some commands to make them interesting
await terminalManager.writeToTerminal({
terminalId: terminal1,
input: 'echo "Hello from Terminal 1"',
});
await terminalManager.writeToTerminal({
terminalId: terminal2,
input: 'echo "Hello from Terminal 2"',
});
// Wait a bit for output
await new Promise((resolve) => setTimeout(resolve, 500));
console.log("\n3οΈβ£ Starting Web UI...");
// Create and start Web UI
const webUiManager = new WebUIManager();
try {
const result = await webUiManager.start({
port: 3002,
autoOpen: true,
terminalManager,
});
console.log("β
Web UI started successfully!\n");
console.log("π Details:");
console.log(` URL: ${result.url}`);
console.log(` Port: ${result.port}`);
console.log(` Mode: ${result.mode}`);
console.log(` Browser opened: ${result.autoOpened ? "Yes" : "No"}\n`);
console.log("π Web UI is now running!");
console.log(" Open your browser to: " + result.url);
console.log("\nπ You can:");
console.log(" - View the terminal list");
console.log(" - Click on a terminal to see its output");
console.log(" - Create new terminals");
console.log(" - Send commands to terminals");
console.log(" - Kill terminals");
console.log("\nβΈοΈ Press Ctrl+C to stop the server\n");
// Keep the process running
process.on("SIGINT", async () => {
console.log("\n\nπ Shutting down...");
await webUiManager.stop();
await terminalManager.shutdown();
console.log("β
Cleanup complete");
process.exit(0);
});
// Keep alive
await new Promise(() => {});
} catch (error) {
console.error("β Error starting Web UI:", error);
await terminalManager.shutdown();
process.exit(1);
}
}
main().catch((error) => {
console.error("β Fatal error:", error);
process.exit(1);
});
//# sourceMappingURL=test-web-ui.js.map