diff --git a/internal/dev/server.go b/internal/dev/server.go index 006b05fd..3e2c7c39 100644 --- a/internal/dev/server.go +++ b/internal/dev/server.go @@ -106,6 +106,7 @@ type ConnectionResponse struct { func (s *Server) Close() error { s.logger.Debug("closing connection") s.once.Do(func() { + s.closeConnection() s.cancel() s.wg.Wait() if s.conn != nil { @@ -119,6 +120,12 @@ func (s *Server) Close() error { return nil } +func (s *Server) closeConnection() { + if err := s.apiclient.Do("DELETE", "/cli/devmode/"+s.Project.Project.ProjectId+"/"+s.ID, nil, nil); err != nil { + s.logger.Error("failed to send close connection: %s", err) + } +} + func (s *Server) refreshConnection() error { var resp ConnectionResponse if err := s.apiclient.Do("GET", "/cli/devmode/"+s.Project.Project.ProjectId+"/"+s.ID, nil, &resp); err != nil { @@ -660,7 +667,7 @@ func New(args ServerArgs) (*Server, error) { tracer: tracer, version: args.Version, port: args.Port, - apiclient: util.NewAPIClient(ctx, args.Logger, args.APIURL, args.APIKey), + apiclient: util.NewAPIClient(context.WithoutCancel(ctx), args.Logger, args.APIURL, args.APIKey), connected: make(chan error, 1), } diff --git a/internal/util/api.go b/internal/util/api.go index 8b8279f9..73d789be 100644 --- a/internal/util/api.go +++ b/internal/util/api.go @@ -266,16 +266,16 @@ func GetURLs(logger logger.Logger) (string, string, string) { if apiUrl == "https://api.agentuity.com" && appUrl != "https://app.agentuity.com" { logger.Debug("switching app url to production since the api url is production") appUrl = "https://app.agentuity.com" - } else if apiUrl == "https://api.agentuity.dev" && appUrl == "https://app.agentuity.com" { + } else if apiUrl == "https://api.agentuity.io" && appUrl == "https://app.agentuity.com" { logger.Debug("switching app url to dev since the api url is dev") - appUrl = "http://127.0.0.1:3000" + appUrl = "https://app.agentuity.io" } - if apiUrl == "https://api.agentuity.com" && transportUrl != "https://agentuity.api" { + if apiUrl == "https://api.agentuity.com" && transportUrl != "https://agentuity.ai" { logger.Debug("switching transport url to production since the api url is production") transportUrl = "https://agentuity.ai" - } else if apiUrl == "https://api.agentuity.dev" && transportUrl == "https://agentuity.ai" { + } else if apiUrl == "https://api.agentuity.io" && transportUrl == "https://agentuity.ai" { logger.Debug("switching transport url to dev since the api url is dev") - transportUrl = "http://127.0.0.1:3939" + transportUrl = "https://ai.agentuity.io" } return TransformUrl(apiUrl), TransformUrl(appUrl), TransformUrl(transportUrl) }