@@ -83,11 +83,10 @@ var (
8383 Required : false ,
8484 }
8585
86- regionFlag = & cli.StringSliceFlag {
87- Name : "regions " ,
88- Usage : "Region(s) to deploy the agent to. If unset, will deploy to the nearest region." ,
86+ regionFlag = & cli.StringFlag {
87+ Name : "region " ,
88+ Usage : "Region to deploy the agent to. If unset, will deploy to the nearest region." ,
8989 Required : false ,
90- Hidden : true ,
9190 }
9291
9392 skipSDKCheckFlag = & cli.BoolFlag {
@@ -141,7 +140,9 @@ var (
141140 },
142141 }},
143142 }},
144- Flags : []cli.Flag {},
143+ Flags : []cli.Flag {
144+ regionFlag ,
145+ },
145146 ArgsUsage : "[AGENT-NAME]" ,
146147 DisableSliceFlagSeparator : true ,
147148 },
@@ -554,7 +555,31 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
554555 }
555556 }
556557
557- regions := cmd .StringSlice ("regions" )
558+ region := cmd .String ("region" )
559+ if region == "" {
560+ availableRegionsStr , ok := settingsMap ["available_regions" ]
561+ if ok && availableRegionsStr != "" {
562+ regionOptions := strings .Split (availableRegionsStr , "," )
563+ for i , r := range regionOptions {
564+ regionOptions [i ] = strings .TrimSpace (r )
565+ }
566+
567+ if err := huh .NewSelect [string ]().
568+ Title ("Select region for agent deployment" ).
569+ Options (huh .NewOptions (regionOptions ... )... ).
570+ Value (& region ).
571+ WithTheme (util .Theme ).
572+ Run (); err != nil {
573+ return err
574+ }
575+ } else {
576+ // we shouldn't ever get here, but if we do, just default to us-east
577+ logger .Debugw ("no available regions found, defaulting to us-east. please contact LiveKit support if this is unexpected." )
578+ region = "us-east"
579+ }
580+ }
581+
582+ regions := []string {region }
558583 excludeFiles := []string {fmt .Sprintf ("**/%s" , config .LiveKitTOMLFile )}
559584 resp , err := agentsClient .CreateAgent (ctx , os .DirFS (workingDir ), secrets , regions , excludeFiles )
560585 if err != nil {
0 commit comments