(cmd *cobra.Command, args []string)
| 67 | ) |
| 68 | |
| 69 | func 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 | |
| 111 | func execLoop(ctx context.Context, id string, agentID string, input string, lastSeq int32) error { |
| 112 | d := internal.NewDisplay(id) |
nothing calls this directly
no test coverage detected