7575 Required : false ,
7676 }
7777
78+ regionFlag = & cli.StringSliceFlag {
79+ Name : "regions" ,
80+ Usage : "Region(s) to deploy the agent to. If unset, will deploy to the nearest region." ,
81+ Required : false ,
82+ Hidden : true ,
83+ }
84+
7885 AgentCommands = []* cli.Command {
7986 {
8087 Name : "agent" ,
9097 secretsFlag ,
9198 secretsFileFlag ,
9299 silentFlag ,
100+ regionFlag ,
93101 },
94102 ArgsUsage : "[working-dir]" ,
95103 },
@@ -324,6 +332,11 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
324332 fmt .Printf ("Creating new agent\n " )
325333 }
326334
335+ regions := cmd .StringSlice ("regions" )
336+ if len (regions ) != 0 {
337+ lkConfig .Agent .Regions = regions
338+ }
339+
327340 secrets , err := requireSecrets (ctx , cmd , false , false )
328341 if err != nil {
329342 return err
@@ -335,6 +348,7 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
335348
336349 req := & lkproto.CreateAgentRequest {
337350 Secrets : secrets ,
351+ Regions : lkConfig .Agent .Regions ,
338352 }
339353
340354 resp , err := agentsClient .CreateAgent (ctx , req )
@@ -440,10 +454,16 @@ func createAgentConfig(ctx context.Context, cmd *cli.Command) error {
440454 return fmt .Errorf ("invalid project URL: %s" , project .URL )
441455 }
442456
457+ var regions []string
458+ for _ , regionalAgent := range response .Agents [0 ].AgentDeployments {
459+ regions = append (regions , regionalAgent .Region )
460+ }
461+
443462 agent := response .Agents [0 ]
444463 lkConfig := config .NewLiveKitTOML (matches [1 ])
445464 lkConfig .Agent = & config.LiveKitTOMLAgentConfig {
446- ID : agent .AgentId ,
465+ ID : agent .AgentId ,
466+ Regions : regions ,
447467 }
448468
449469 if err := lkConfig .SaveTOMLFile ("" , tomlFilename ); err != nil {
@@ -577,8 +597,14 @@ func updateAgent(ctx context.Context, cmd *cli.Command) error {
577597 return fmt .Errorf ("no agent config found in [%s]" , tomlFilename )
578598 }
579599
600+ regions := cmd .StringSlice ("regions" )
601+ if len (regions ) != 0 {
602+ lkConfig .Agent .Regions = regions
603+ }
604+
580605 req := & lkproto.UpdateAgentRequest {
581606 AgentId : lkConfig .Agent .ID ,
607+ Regions : lkConfig .Agent .Regions ,
582608 }
583609
584610 secrets , err := requireSecrets (ctx , cmd , false , true )
@@ -601,7 +627,8 @@ func updateAgent(ctx context.Context, cmd *cli.Command) error {
601627
602628 if resp .Success {
603629 fmt .Printf ("Updated agent [%s]\n " , util .Accented (lkConfig .Agent .ID ))
604- return nil
630+ err = lkConfig .SaveTOMLFile ("" , tomlFilename )
631+ return err
605632 }
606633
607634 return fmt .Errorf ("failed to update agent: %s" , resp .Message )
0 commit comments