@@ -9,6 +9,7 @@ import fs from 'node:fs';
99import net from 'node:net' ;
1010
1111import { logger } from '../logger.js' ;
12+ import { START_INDICATOR } from '../server.js' ;
1213import { PipeTransport } from '../third_party/index.js' ;
1314
1415import type { DaemonMessage , DaemonResponse } from './types.js' ;
@@ -55,7 +56,7 @@ export async function startDaemon(mcpArgs: string[] = []) {
5556 logger ( 'Starting daemon...' ) ;
5657 const child = spawn ( process . execPath , [ DAEMON_SCRIPT_PATH , ...mcpArgs ] , {
5758 detached : true ,
58- stdio : 'ignore' ,
59+ stdio : [ 'ignore' , 'ignore' , 'pipe' ] ,
5960 cwd : process . cwd ( ) ,
6061 } ) ;
6162
@@ -71,8 +72,19 @@ export async function startDaemon(mcpArgs: string[] = []) {
7172 waitForFile ( getPidFilePath ( ) ) . then ( resolve ) . catch ( reject ) ;
7273 } ) ;
7374
74- child . unref ( ) ;
7575 logger ( `Pid file found ${ getPidFilePath ( ) } ` ) ;
76+
77+ child . stderr . pipe ( process . stderr ) ;
78+ await new Promise < void > ( resolve => {
79+ child . stderr . on ( 'data' , data => {
80+ if ( data . toString ( ) . includes ( START_INDICATOR ) ) {
81+ child . stderr . unpipe ( process . stderr ) ;
82+ child . stderr . destroy ( ) ;
83+ child . unref ( ) ;
84+ resolve ( ) ;
85+ }
86+ } ) ;
87+ } ) ;
7688}
7789
7890const SEND_COMMAND_TIMEOUT = 60_000 ; // ms
0 commit comments