@@ -11,6 +11,7 @@ import {
1111import type { AppIO } from "../io" ;
1212import type { Core } from "../handlers/types" ;
1313import { JsonKey } from "../handlers/keys" ;
14+ import { AgentCoreCLIError , ERROR_SOURCE , type AgentCoreCLIErrorOptions } from "../errors" ;
1415
1516// renderJson pretty-prints a value as indented JSON. It is the output
1617// counterpart to renderTui: handlers call it to emit machine-readable results
@@ -43,7 +44,7 @@ export async function renderTuiAt(
4344 io : AppIO ,
4445) : Promise < void > {
4546 if ( ! io . stdin . isTTY || ! io . stdout . isTTY ) {
46- throw new TypeError ( "interactive mode requires a TTY on stdin and stdout" ) ;
47+ throw new InvalidEnvironmentError ( "interactive mode requires a TTY on stdin and stdout" ) ;
4748 }
4849
4950 // alternateScreen switches the terminal to its alternate buffer so the TUI
@@ -74,3 +75,10 @@ export function renderTui(core: Core, io: AppIO): DefaultHandle {
7475 await renderTuiAt ( ctx . require ( PathKey ) , ctx , core , io ) ;
7576 } ;
7677}
78+
79+ /** Error raised when detecting an invalid environment */
80+ export class InvalidEnvironmentError extends AgentCoreCLIError {
81+ constructor ( message ?: string , options ?: Omit < AgentCoreCLIErrorOptions , "source" > ) {
82+ super ( message , { ...options , source : ERROR_SOURCE . USER } ) ;
83+ }
84+ }
0 commit comments