Agent Executor (AX) is Google's open agentic orchestration runtime
Go
Introduce openConn
JBDb42b3f9c8348
diff --git a/cmd/gar/inspect.go b/cmd/gar/inspect.goindex f5412b8..1e6924f 100644--- a/cmd/gar/inspect.go+++ b/cmd/gar/inspect.go@@ -7,8 +7,6 @@ import ("github.com/google/gar/proto""github.com/spf13/cobra"- "google.golang.org/grpc"- "google.golang.org/grpc/credentials/insecure")var (@@ -32,10 +30,9 @@ func init() {func runInspect(cmd *cobra.Command, args []string) error {fmt.Printf("Inspecting session: %s\n", inspectSessionID)- // Connect to gRPC server- conn, err := grpc.NewClient(inspectServerAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))+ conn, err := openConn(inspectServerAddr)if err != nil {- return fmt.Errorf("failed to connect to server: %w", err)+ return err}defer conn.Close()diff --git a/cmd/gar/main.go b/cmd/gar/main.goindex 2e04409..ef7073c 100644--- a/cmd/gar/main.go+++ b/cmd/gar/main.go@@ -6,6 +6,9 @@ package mainimport ("fmt""os"++ "google.golang.org/grpc"+ "google.golang.org/grpc/credentials/insecure")func main() {@@ -14,3 +17,11 @@ func main() {os.Exit(1)}}++func openConn(server string) (*grpc.ClientConn, error) {+ conn, err := grpc.NewClient(server, grpc.WithTransportCredentials(insecure.NewCredentials()))+ if err != nil {+ return nil, fmt.Errorf("failed to connect to server: %w", err)+ }+ return conn, nil+}diff --git a/cmd/gar/register.go b/cmd/gar/register.goindex b1193ad..6699197 100644--- a/cmd/gar/register.go+++ b/cmd/gar/register.go@@ -6,8 +6,6 @@ import ("github.com/google/gar/proto""github.com/spf13/cobra"- "google.golang.org/grpc"- "google.golang.org/grpc/credentials/insecure")var (@@ -44,10 +42,9 @@ func runRegister(cmd *cobra.Command, args []string) error {fmt.Printf(" Description: %s\n", registerAgentDesc)}- // Connect to gRPC server- conn, err := grpc.NewClient(registerServerAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))+ conn, err := openConn(inspectServerAddr)if err != nil {- return fmt.Errorf("failed to connect to server: %w", err)+ return err}defer conn.Close()diff --git a/cmd/gar/trigger.go b/cmd/gar/trigger.goindex 63a9f4e..dbdca15 100644--- a/cmd/gar/trigger.go+++ b/cmd/gar/trigger.go@@ -11,8 +11,6 @@ import ("github.com/google/gar/proto""github.com/google/uuid""github.com/spf13/cobra"- "google.golang.org/grpc"- "google.golang.org/grpc/credentials/insecure")var (@@ -73,15 +71,13 @@ func runTrigger(cmd *cobra.Command, args []string) error {cancel()}()- // Connect to gRPC server- conn, err := grpc.NewClient(triggerServerAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))+ conn, err := openConn(inspectServerAddr)if err != nil {- return fmt.Errorf("failed to connect to server: %w", err)+ return err}defer conn.Close()client := proto.NewGARServiceClient(conn)-stream, err := client.TriggerSession(ctx, &proto.TriggerSessionRequest{SessionId: triggerSessionID,Inputs: inputs,@@ -105,7 +101,5 @@ func runTrigger(cmd *cobra.Command, args []string) error {fmt.Printf("[%s] %s\n", resp.State, resp.Output.Data)}}-- fmt.Println("Session completed successfully")return nil}