MCPcopy
hub / github.com/google/ax / runExec

Function runExec

cmd/ax/exec.go:69–109  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

67)
68
69func runExec(cmd *cobra.Command, args []string) error {
70 ctx := cmd.Context()
71
72 if execConversationID == "" {
73 execConversationID = uuid.NewString()
74 }
75
76 // Setup signal handling for graceful shutdown
77 ctx, cancel := context.WithCancel(ctx)
78 defer cancel()
79
80 sigChan := make(chan os.Signal, 1)
81 signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
82
83 go func() {
84 <-sigChan
85 fmt.Println("\nReceived interrupt, shutting down...")
86 if execController != nil {
87 execController.Close()
88 }
89 cancel()
90 }()
91
92 if execServerAddr == "" {
93 cfg, err := newConfig(cmd, execConfigFile)
94 if err != nil {
95 return err
96 }
97 // Validate configuration (matches `ax serve`).
98 if err := cfg.Validate(); err != nil {
99 return fmt.Errorf("invalid configuration: %w", err)
100 }
101 c, err := cliutil.NewControllerFromConfig(ctx, cfg)
102 if err != nil {
103 return fmt.Errorf("error creating controller: %w", err)
104 }
105 execController = c
106 }
107
108 return execLoop(ctx, execConversationID, execAgentID, execInput, execLastSeq)
109}
110
111func execLoop(ctx context.Context, id string, agentID string, input string, lastSeq int32) error {
112 d := internal.NewDisplay(id)

Callers

nothing calls this directly

Calls 5

NewControllerFromConfigFunction · 0.92
newConfigFunction · 0.85
execLoopFunction · 0.85
ValidateMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected