UNPKG

claude-code-mobile-terminal-server

Version:

WebSocket terminal server for Claude Code Mobile - enables mobile access to Claude Code in GitHub Codespaces

85 lines (69 loc) • 2.04 kB
#!/usr/bin/env node const { TerminalServer } = require('../src/server'); const commands = { start: startCommand, status: statusCommand, help: helpCommand }; function main() { const args = process.argv.slice(2); const command = args[0] || 'help'; if (commands[command]) { commands[command](args.slice(1)); } else { console.error(`āŒ Unknown command: ${command}`); helpCommand(); process.exit(1); } } async function startCommand(args) { const port = args.includes('--port') ? args[args.indexOf('--port') + 1] : 8080; const host = args.includes('--host') ? args[args.indexOf('--host') + 1] : '0.0.0.0'; console.log('šŸš€ Starting Terminal Server...'); try { const server = new TerminalServer({ port, host }); await server.start(); } catch (error) { console.error('āŒ Failed to start:', error.message); process.exit(1); } } async function statusCommand() { const port = process.env.CC_MOBILE_PORT || 8080; try { const response = await fetch(`http://localhost:${port}/health`); if (response.ok) { const data = await response.json(); console.log('āœ… Server Status: Running'); console.log(`šŸ“Š Active Terminals: ${data.activeTerminals}`); console.log(`ā±ļø Uptime: ${Math.round(data.uptime)} seconds`); } } catch (error) { console.log('āŒ Server Status: Not Running'); } } function helpCommand() { console.log(` šŸš€ Claude Code Mobile Terminal Server USAGE: cc-mobile-server <command> [options] COMMANDS: start Start the terminal server status Check if server is running help Show this help OPTIONS: --port <port> Server port (default: 8080) --host <host> Server host (default: 0.0.0.0) EXAMPLES: cc-mobile-server start cc-mobile-server start --port 3000 cc-mobile-server status `); } // Add fetch polyfill for older Node.js if (typeof fetch === 'undefined') { global.fetch = require('node-fetch'); } if (require.main === module) { main(); }