( remoteUrl: string, initialPrompt?: string, )
| 126 | } |
| 127 | |
| 128 | export async function startRemoteTUIChat( |
| 129 | remoteUrl: string, |
| 130 | initialPrompt?: string, |
| 131 | ) { |
| 132 | // Critical safeguard: Prevent TUI initialization in TTY-less environment |
| 133 | if (isTTYless()) { |
| 134 | throw new Error( |
| 135 | "Cannot start remote TUI in TTY-less environment. No TTY available for interactive mode.", |
| 136 | ); |
| 137 | } |
| 138 | |
| 139 | // Test raw mode capability for remote TUI |
| 140 | if ( |
| 141 | process.stdin.isTTY && |
| 142 | typeof (process.stdin as any).setRawMode === "function" |
| 143 | ) { |
| 144 | try { |
| 145 | (process.stdin as any).setRawMode(true); |
| 146 | (process.stdin as any).setRawMode(false); |
| 147 | logger.debug("Raw mode test passed for remote TUI"); |
| 148 | } catch { |
| 149 | throw new Error( |
| 150 | "Terminal does not support raw mode required for interactive UI.", |
| 151 | ); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // Start the TUI in remote mode - no services needed |
| 156 | const { unmount } = render( |
| 157 | React.createElement(ServiceContainerProvider, { |
| 158 | children: React.createElement(AppRoot, { |
| 159 | remoteUrl, |
| 160 | initialPrompt, |
| 161 | }), |
| 162 | }), |
| 163 | { |
| 164 | stdin: process.stdin, |
| 165 | stdout: process.stdout, |
| 166 | stderr: process.stderr, |
| 167 | }, |
| 168 | ); |
| 169 | |
| 170 | // Register unmount function with main process for two-stage Ctrl+C exit |
| 171 | setTUIUnmount(unmount); |
| 172 | |
| 173 | return { unmount }; |
| 174 | } |
nothing calls this directly
no test coverage detected