(deps commandDeps)
| 144 | } |
| 145 | |
| 146 | func newChannelRecvCommand(deps commandDeps) *cobra.Command { |
| 147 | var wait bool |
| 148 | var limit int |
| 149 | |
| 150 | cmd := &cobra.Command{ |
| 151 | Use: "recv <channel>", |
| 152 | Short: "Receive queued coordination messages for a channel", |
| 153 | Args: exactOneNonBlankArg(), |
| 154 | Example: ` # Receive currently queued messages |
| 155 | agh ch recv coord-run-123 |
| 156 | |
| 157 | # Wait for messages and stream each record as JSONL |
| 158 | agh ch recv coord-run-123 --wait --limit 10 -o jsonl`, |
| 159 | RunE: func(cmd *cobra.Command, args []string) error { |
| 160 | client, err := clientFromDeps(deps) |
| 161 | if err != nil { |
| 162 | return err |
| 163 | } |
| 164 | credentials, err := requireAgentCommandIdentity(cmd.Context(), deps, client, agentActionCLI("ch.recv")) |
| 165 | if err != nil { |
| 166 | return err |
| 167 | } |
| 168 | messages, err := client.AgentChannelRecv(cmd.Context(), strings.TrimSpace(args[0]), AgentChannelRecvQuery{ |
| 169 | Wait: wait, |
| 170 | Limit: limit, |
| 171 | }, credentials) |
| 172 | if err != nil { |
| 173 | return err |
| 174 | } |
| 175 | return writeAgentChannelMessages(cmd, messages) |
| 176 | }, |
| 177 | } |
| 178 | cmd.Flags().BoolVar(&wait, "wait", false, "Wait until at least one matching message is available") |
| 179 | cmd.Flags().IntVar(&limit, "limit", 0, "Maximum messages to return") |
| 180 | return cmd |
| 181 | } |
| 182 | |
| 183 | func newChannelSendCommand(deps commandDeps) *cobra.Command { |
| 184 | var bodyRaw string |
no test coverage detected