@@ -339,35 +339,35 @@ export class AgentServer {
339339 ) ;
340340
341341 this . #opts = opts ;
342- this . #httpServer = new HTTPServer (
343- opts . host ,
344- opts . port ,
345- ( ) => {
346- // Check if inference executor exists and is not alive
347- if ( this . #inferenceExecutor && ! this . #inferenceExecutor. isAlive ) {
348- return { healthy : false , message : 'inference process not running' } ;
349- }
350342
351- // Only healthy when fully connected with an active WebSocket
352- if (
353- this . #closed ||
354- this . #connecting ||
355- ! this . #session ||
356- this . #session. readyState !== WebSocket . OPEN
357- ) {
358- return { healthy : false , message : 'not connected to livekit' } ;
359- }
343+ const healthCheck = ( ) => {
344+ // Check if inference executor exists and is not alive
345+ if ( this . #inferenceExecutor && ! this . #inferenceExecutor. isAlive ) {
346+ return { healthy : false , message : 'inference process not running' } ;
347+ }
360348
361- return { healthy : true , message : 'OK' } ;
362- } ,
363- ( ) => ( {
364- agent_name : opts . agentName ,
365- worker_type : JobType [ opts . serverType ] ,
366- active_jobs : this . activeJobs . length ,
367- sdk_version : version ,
368- project_type : PROJECT_TYPE ,
369- } ) ,
370- ) ;
349+ // Only healthy when fully connected with an active WebSocket
350+ if (
351+ this . #closed ||
352+ this . #connecting ||
353+ ! this . #session ||
354+ this . #session. readyState !== WebSocket . OPEN
355+ ) {
356+ return { healthy : false , message : 'not connected to livekit' } ;
357+ }
358+
359+ return { healthy : true , message : 'OK' } ;
360+ } ;
361+
362+ const getWorkerInfo = ( ) => ( {
363+ agent_name : opts . agentName ,
364+ worker_type : JobType [ opts . serverType ] ,
365+ active_jobs : this . activeJobs . length ,
366+ sdk_version : version ,
367+ project_type : PROJECT_TYPE ,
368+ } ) ;
369+
370+ this . #httpServer = new HTTPServer ( opts . host , opts . port , healthCheck , getWorkerInfo ) ;
371371 }
372372
373373 /** @throws {@link WorkerError } if worker failed to connect or already running */
0 commit comments