| 1 | import chalk from "chalk"; |
| 2 | |
| 3 | import { telemetryService } from "../telemetry/telemetryService.js"; |
| 4 | import { startRemoteTUIChat } from "../ui/index.js"; |
| 5 | import { gracefulExit } from "../util/exit.js"; |
| 6 | import { logger } from "../util/logger.js"; |
| 7 | |
| 8 | export async function remoteTest( |
| 9 | prompt?: string, |
| 10 | url: string = "http://localhost:8000", |
| 11 | ) { |
| 12 | console.info(chalk.white(`Connecting to remote environment at ${url}...`)); |
| 13 | |
| 14 | try { |
| 15 | // Record session start |
| 16 | telemetryService.recordSessionStart(); |
| 17 | telemetryService.startActiveTime(); |
| 18 | |
| 19 | try { |
| 20 | // Start the TUI in remote mode |
| 21 | await startRemoteTUIChat(url, prompt); |
| 22 | } finally { |
| 23 | telemetryService.stopActiveTime(); |
| 24 | } |
| 25 | } catch (error: any) { |
| 26 | logger.error( |
| 27 | chalk.red(`Failed to connect to remote environment: ${error.message}`), |
| 28 | ); |
| 29 | await gracefulExit(1); |
| 30 | } |
| 31 | } |