@@ -25,6 +25,8 @@ import { CURRENT_UNMANAGED_DEPLOYMENT_LABEL } from "~/consts";
2525import  {  resolveVariablesForEnvironment  }  from  "~/v3/environmentVariables/environmentVariablesRepository.server" ; 
2626import  {  generateJWTTokenForEnvironment  }  from  "~/services/apiAuth.server" ; 
2727import  {  fromFriendlyId  }  from  "@trigger.dev/core/v3/apps" ; 
28+ import  {  machinePresetFromName  }  from  "~/v3/machinePresets.server" ; 
29+ import  {  defaultMachine  }  from  "@trigger.dev/platform/v3" ; 
2830
2931export  class  WorkerGroupTokenService  extends  WithRunEngine  { 
3032  private  readonly  tokenPrefix  =  "tr_wgt_" ; 
@@ -205,6 +207,7 @@ export class WorkerGroupTokenService extends WithRunEngine {
205207        prisma : this . _prisma , 
206208        engine : this . _engine , 
207209        type : WorkerInstanceGroupType . MANAGED , 
210+         name : workerGroup . name , 
208211        workerGroupId : workerGroup . id , 
209212        workerInstanceId : workerInstance . id , 
210213        masterQueue : workerGroup . masterQueue , 
@@ -240,6 +243,7 @@ export class WorkerGroupTokenService extends WithRunEngine {
240243      prisma : this . _prisma , 
241244      engine : this . _engine , 
242245      type : WorkerInstanceGroupType . UNMANAGED , 
246+       name : workerGroup . name , 
243247      workerGroupId : workerGroup . id , 
244248      workerInstanceId : workerInstance . id , 
245249      masterQueue : workerGroup . masterQueue , 
@@ -479,6 +483,7 @@ export type WorkerInstanceEnv = z.infer<typeof WorkerInstanceEnv>;
479483
480484export  type  AuthenticatedWorkerInstanceOptions  =  WithRunEngineOptions < { 
481485  type : WorkerInstanceGroupType ; 
486+   name : string ; 
482487  workerGroupId : string ; 
483488  workerInstanceId : string ; 
484489  masterQueue : string ; 
@@ -490,20 +495,22 @@ export type AuthenticatedWorkerInstanceOptions = WithRunEngineOptions<{
490495
491496export  class  AuthenticatedWorkerInstance  extends  WithRunEngine  { 
492497  readonly  type : WorkerInstanceGroupType ; 
498+   readonly  name : string ; 
493499  readonly  workerGroupId : string ; 
494500  readonly  workerInstanceId : string ; 
495501  readonly  masterQueue : string ; 
496502  readonly  environment : RuntimeEnvironment  |  null ; 
497503  readonly  deploymentId ?: string ; 
498504  readonly  backgroundWorkerId ?: string ; 
499505
500-   // FIXME 
506+   // FIXME: Required for unmanaged workers  
501507  readonly  isLatestDeployment  =  true ; 
502508
503509  constructor ( opts : AuthenticatedWorkerInstanceOptions )  { 
504510    super ( {  prisma : opts . prisma ,  engine : opts . engine  } ) ; 
505511
506512    this . type  =  opts . type ; 
513+     this . name  =  opts . name ; 
507514    this . workerGroupId  =  opts . workerGroupId ; 
508515    this . workerInstanceId  =  opts . workerInstanceId ; 
509516    this . masterQueue  =  opts . masterQueue ; 
@@ -647,12 +654,7 @@ export class AuthenticatedWorkerInstance extends WithRunEngine {
647654      isWarmStart, 
648655    } ) ; 
649656
650-     const  defaultMachinePreset  =  { 
651-       name : "small-1x" , 
652-       cpu : 1 , 
653-       memory : 1 , 
654-       centsPerMs : 0 , 
655-     }  satisfies  MachinePreset ; 
657+     const  defaultMachinePreset  =  machinePresetFromName ( defaultMachine ) ; 
656658
657659    const  environment  = 
658660      this . environment  ?? 
@@ -718,6 +720,7 @@ export class AuthenticatedWorkerInstance extends WithRunEngine {
718720    if  ( this . type  ===  WorkerInstanceGroupType . MANAGED )  { 
719721      return  { 
720722        type : WorkerInstanceGroupType . MANAGED , 
723+         name : this . name , 
721724        workerGroupId : this . workerGroupId , 
722725        workerInstanceId : this . workerInstanceId , 
723726        masterQueue : this . masterQueue , 
@@ -726,6 +729,7 @@ export class AuthenticatedWorkerInstance extends WithRunEngine {
726729
727730    return  { 
728731      type : WorkerInstanceGroupType . UNMANAGED , 
732+       name : this . name , 
729733      workerGroupId : this . workerGroupId , 
730734      workerInstanceId : this . workerInstanceId , 
731735      masterQueue : this . masterQueue , 
@@ -764,12 +768,14 @@ export class AuthenticatedWorkerInstance extends WithRunEngine {
764768export  type  WorkerGroupTokenAuthenticationResponse  = 
765769  |  { 
766770      type : typeof  WorkerInstanceGroupType . MANAGED ; 
771+       name : string ; 
767772      workerGroupId : string ; 
768773      workerInstanceId : string ; 
769774      masterQueue : string ; 
770775    } 
771776  |  { 
772777      type : typeof  WorkerInstanceGroupType . UNMANAGED ; 
778+       name : string ; 
773779      workerGroupId : string ; 
774780      workerInstanceId : string ; 
775781      masterQueue : string ; 
0 commit comments