MCPcopy Create free account
hub / github.com/compozy/agh / newChannelRecvCommand

Function newChannelRecvCommand

internal/cli/agent_kernel.go:146–181  ·  view source on GitHub ↗
(deps commandDeps)

Source from the content-addressed store, hash-verified

144}
145
146func 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
183func newChannelSendCommand(deps commandDeps) *cobra.Command {
184 var bodyRaw string

Callers 1

newChannelCommandFunction · 0.85

Calls 6

exactOneNonBlankArgFunction · 0.85
clientFromDepsFunction · 0.85
agentActionCLIFunction · 0.85
AgentChannelRecvMethod · 0.65

Tested by

no test coverage detected