@@ -23,12 +23,13 @@ import (
2323 "regexp"
2424 "strings"
2525
26+ "github.com/twitchtv/twirp"
27+
2628 livekitcli "github.com/livekit/livekit-cli/v2"
2729 "github.com/livekit/protocol/auth"
2830 lkproto "github.com/livekit/protocol/livekit"
2931 "github.com/livekit/protocol/logger"
3032 lksdk "github.com/livekit/server-sdk-go/v2"
31- "github.com/twitchtv/twirp"
3233)
3334
3435// Client is a wrapper around the lksdk.AgentClient that provides a simpler interface for creating and deploying agents.
@@ -63,7 +64,7 @@ func New(opts ...ClientOption) (*Client, error) {
6364 return nil , err
6465 }
6566 client .AgentClient = agentClient
66- client .agentsURL = client .getAgentsURL ()
67+ client .agentsURL = client .getAgentsURL ("" )
6768 if client .httpClient == nil {
6869 client .httpClient = & http.Client {}
6970 }
@@ -172,7 +173,7 @@ func (c *Client) uploadAndBuild(
172173 return nil
173174}
174175
175- func (c * Client ) getAgentsURL () string {
176+ func (c * Client ) getAgentsURL (serverRegion string ) string {
176177 agentsURL := c .projectURL
177178 if strings .HasPrefix (agentsURL , "ws" ) {
178179 agentsURL = strings .Replace (agentsURL , "ws" , "http" , 1 )
@@ -182,7 +183,10 @@ func (c *Client) getAgentsURL() string {
182183 } else if ! strings .Contains (agentsURL , "localhost" ) && ! strings .Contains (agentsURL , "127.0.0.1" ) {
183184 pattern := `^https://[a-zA-Z0-9\-]+\.`
184185 re := regexp .MustCompile (pattern )
185- agentsURL = re .ReplaceAllString (agentsURL , "https://agents." )
186+ if serverRegion != "" {
187+ serverRegion = fmt .Sprintf ("%s." , serverRegion )
188+ }
189+ agentsURL = re .ReplaceAllString (agentsURL , fmt .Sprintf ("https://%sagents." , serverRegion ))
186190 }
187191 return agentsURL
188192}
0 commit comments