@@ -79,7 +79,7 @@ const defaultRequestFunc = async (ctx: JobRequest) => {
7979} ;
8080
8181// eslint-disable-next-line @typescript-eslint/no-unused-vars
82- const defaultCpuLoad = async ( worker : Worker ) : Promise < number > => {
82+ const defaultCpuLoad = async ( worker : AgentServer ) : Promise < number > => {
8383 return new Promise ( ( resolve ) => {
8484 const cpus1 = os . cpus ( ) ;
8585
@@ -141,17 +141,17 @@ export class WorkerPermissions {
141141 *
142142 * This class is mostly useful in conjunction with {@link cli.runApp}.
143143 */
144- export class WorkerOptions {
144+ export class ServerOptions {
145145 agent : string ;
146146 requestFunc : ( job : JobRequest ) => Promise < void > ;
147- loadFunc : ( worker : Worker ) => Promise < number > ;
147+ loadFunc : ( worker : AgentServer ) => Promise < number > ;
148148 loadThreshold : number ;
149149 numIdleProcesses : number ;
150150 shutdownProcessTimeout : number ;
151151 initializeProcessTimeout : number ;
152152 permissions : WorkerPermissions ;
153153 agentName : string ;
154- workerType : JobType ;
154+ serverType : JobType ;
155155 maxRetry : number ;
156156 wsURL : string ;
157157 apiKey ?: string ;
@@ -175,7 +175,7 @@ export class WorkerOptions {
175175 initializeProcessTimeout = 10 * 1000 ,
176176 permissions = new WorkerPermissions ( ) ,
177177 agentName = '' ,
178- workerType = JobType . JT_ROOM ,
178+ serverType = JobType . JT_ROOM ,
179179 maxRetry = MAX_RECONNECT_ATTEMPTS ,
180180 wsURL = 'ws://localhost:7880' ,
181181 apiKey = undefined ,
@@ -195,15 +195,15 @@ export class WorkerOptions {
195195 agent : string ;
196196 requestFunc ?: ( job : JobRequest ) => Promise < void > ;
197197 /** Called to determine the current load of the worker. Should return a value between 0 and 1. */
198- loadFunc ?: ( worker : Worker ) => Promise < number > ;
198+ loadFunc ?: ( worker : AgentServer ) => Promise < number > ;
199199 /** When the load exceeds this threshold, the worker will be marked as unavailable. */
200200 loadThreshold ?: number ;
201201 numIdleProcesses ?: number ;
202202 shutdownProcessTimeout ?: number ;
203203 initializeProcessTimeout ?: number ;
204204 permissions ?: WorkerPermissions ;
205205 agentName ?: string ;
206- workerType ?: JobType ;
206+ serverType ?: JobType ;
207207 maxRetry ?: number ;
208208 wsURL ?: string ;
209209 apiKey ?: string ;
@@ -228,7 +228,7 @@ export class WorkerOptions {
228228 this . initializeProcessTimeout = initializeProcessTimeout ;
229229 this . permissions = permissions ;
230230 this . agentName = agentName ;
231- this . workerType = workerType ;
231+ this . serverType = serverType ;
232232 this . maxRetry = maxRetry ;
233233 this . wsURL = wsURL ;
234234 this . apiKey = apiKey ;
@@ -261,8 +261,8 @@ class PendingAssignment {
261261 * you don't have access to a command line, such as a headless program, or one that uses Agents
262262 * behind a wrapper.
263263 */
264- export class Worker {
265- #opts: WorkerOptions ;
264+ export class AgentServer {
265+ #opts: ServerOptions ;
266266 #procPool: ProcPool ;
267267
268268 #id = 'unregistered' ;
@@ -279,23 +279,23 @@ export class Worker {
279279 #logger = log ( ) . child ( { version } ) ;
280280 #inferenceExecutor?: InferenceProcExecutor ;
281281
282- /** @throws {@link MissingCredentialsError } if URL, API key or API secret are missing */
283- constructor ( opts : WorkerOptions ) {
282+ /* @throws {@link MissingCredentialsError } if URL, API key or API secret are missing */
283+ constructor ( opts : ServerOptions ) {
284284 opts . wsURL = opts . wsURL || process . env . LIVEKIT_URL || '' ;
285285 opts . apiKey = opts . apiKey || process . env . LIVEKIT_API_KEY || '' ;
286286 opts . apiSecret = opts . apiSecret || process . env . LIVEKIT_API_SECRET || '' ;
287287
288288 if ( opts . wsURL === '' )
289289 throw new MissingCredentialsError (
290- 'URL is required: Set LIVEKIT_URL, run with --url, or pass wsURL in WorkerOptions ' ,
290+ 'URL is required: Set LIVEKIT_URL, run with --url, or pass wsURL in ServerOptions ' ,
291291 ) ;
292292 if ( opts . apiKey === '' )
293293 throw new MissingCredentialsError (
294- 'API Key is required: Set LIVEKIT_API_KEY, run with --api-key, or pass apiKey in WorkerOptions ' ,
294+ 'API Key is required: Set LIVEKIT_API_KEY, run with --api-key, or pass apiKey in ServerOptions ' ,
295295 ) ;
296296 if ( opts . apiSecret === '' )
297297 throw new MissingCredentialsError (
298- 'API Secret is required: Set LIVEKIT_API_SECRET, run with --api-secret, or pass apiSecret in WorkerOptions ' ,
298+ 'API Secret is required: Set LIVEKIT_API_SECRET, run with --api-secret, or pass apiSecret in ServerOptions ' ,
299299 ) ;
300300
301301 if ( opts . workerToken ) {
@@ -340,7 +340,7 @@ export class Worker {
340340 this . #opts = opts ;
341341 this . #httpServer = new HTTPServer ( opts . host , opts . port , ( ) => ( {
342342 agent_name : opts . agentName ,
343- worker_type : JobType [ opts . workerType ] ,
343+ worker_type : JobType [ opts . serverType ] ,
344344 active_jobs : this . activeJobs . length ,
345345 sdk_version : version ,
346346 project_type : PROJECT_TYPE ,
@@ -610,7 +610,7 @@ export class Worker {
610610 message : {
611611 case : 'register' ,
612612 value : {
613- type : this . #opts. workerType ,
613+ type : this . #opts. serverType ,
614614 agentName : this . #opts. agentName ,
615615 allowedPermissions : new ParticipantPermission ( {
616616 canPublish : this . #opts. permissions . canPublish ,
@@ -788,3 +788,13 @@ export class Worker {
788788 await this . #close. await ;
789789 }
790790}
791+
792+ /**
793+ * @deprecated Use {@link AgentServer} instead. This alias is provided for backward compatibility.
794+ */
795+ export const Worker = AgentServer ;
796+
797+ /**
798+ * @deprecated Use {@link ServerOptions} instead. This alias is provided for backward compatibility.
799+ */
800+ export const WorkerOptions = ServerOptions ;
0 commit comments