fix(cli): ignore stream-json input format in TTY mode to prevent hanging

- Force TEXT input format in TTY mode instead of allowing stream-json
  which would cause the process to hang when runNonInteractiveStreamJson
  is called without proper stdin data.
- Always initialize app regardless of input format to ensure proper setup.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Mingholy 2026-03-02 21:22:21 +08:00
parent f770be495f
commit 7679910f26

View file

@ -385,17 +385,16 @@ export async function main() {
setMaxSizedBoxDebugging(isDebugMode);
// Check input format early to determine initialization flow
const inputFormat =
typeof config.getInputFormat === 'function'
// In TTY mode, ignore stream-json input format to prevent process from hanging
const inputFormat = process.stdin.isTTY
? InputFormat.TEXT
: typeof config.getInputFormat === 'function'
? config.getInputFormat()
: InputFormat.TEXT;
// For stream-json mode, defer config.initialize() until after the initialize control request
// For other modes, initialize normally
let initializationResult: InitializationResult | undefined;
if (inputFormat !== InputFormat.STREAM_JSON) {
initializationResult = await initializeApp(config, settings);
}
const initializationResult = await initializeApp(config, settings);
if (config.getExperimentalZedIntegration()) {
return runAcpAgent(config, settings, argv);