Skip to main content

objectiveai_sdk/cli/command/agents/read/pending/
mod.rs

1//! `agents read pending` — async handler stub.
2
3use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.agents.read.pending.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub agent_instance_hierarchies: Vec<String>,
10    pub jq: Option<String>,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.agents.read.pending.Path")]
15pub enum Path {
16    #[serde(rename = "agents/read/pending")]
17    AgentsReadPending,
18}
19
20impl CommandRequest for Request {
21    fn into_command(&self) -> Vec<String> {
22        let mut argv = vec![
23            "agents".to_string(),
24            "read".to_string(),
25            "pending".to_string(),
26        ];
27        argv.extend(self.agent_instance_hierarchies.iter().cloned());
28        if let Some(jq) = &self.jq {
29            argv.push("--jq".to_string());
30            argv.push(jq.clone());
31        }
32        argv
33    }
34}
35
36// Share the queue-item / queue-message / content shapes with
37// `agents read all` — same on-disk persistence rows surfaced as
38// either the full or the watermark-delta slice.
39pub use super::all::{ResponseContent, ResponseQueueItem, ResponseQueueMessage};
40
41#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
42#[schemars(rename = "cli.command.agents.read.pending.ResponseItem")]
43pub struct ResponseItem {
44    pub agent_id: String,
45    pub items: Vec<ResponseQueueItem>,
46}
47
48#[derive(clap::Args)]
49pub struct Args {
50    /// One or more agent_instance_hierarchy values.
51    #[arg(required = true)]
52    pub agent_instance_hierarchies: Vec<String>,
53    /// jq filter applied to the JSON output.
54    #[arg(long)]
55    pub jq: Option<String>,
56}
57
58#[derive(clap::Args)]
59#[command(args_conflicts_with_subcommands = true)]
60pub struct Command {
61    #[command(flatten)]
62    pub args: Args,
63    #[command(subcommand)]
64    pub schema: Option<Schema>,
65}
66
67#[derive(clap::Subcommand)]
68pub enum Schema {
69    /// Emit the JSON Schema for this leaf's `Request` type and exit.
70    RequestSchema(request_schema::Args),
71    /// Emit the JSON Schema for this leaf's `Response` type and exit.
72    ResponseSchema(response_schema::Args),
73}
74
75impl TryFrom<Args> for Request {
76    type Error = crate::cli::command::FromArgsError;
77    fn try_from(args: Args) -> Result<Self, Self::Error> {
78        Ok(Self { path_type: Path::AgentsReadPending,
79            agent_instance_hierarchies: args.agent_instance_hierarchies,
80            jq: args.jq,
81        })
82    }
83}
84
85#[cfg(feature = "cli-executor")]
86pub async fn execute<E: crate::cli::command::CommandExecutor>(
87    executor: &E,
88    mut request: Request,
89
90        agent_arguments: Option<&crate::cli::command::AgentArguments>,
91    ) -> Result<E::Stream<ResponseItem>, E::Error> {
92    request.jq = None;
93    executor.execute(request, agent_arguments).await
94}
95
96#[cfg(feature = "cli-executor")]
97pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
98    executor: &E,
99    mut request: Request,
100    jq: String,
101
102        agent_arguments: Option<&crate::cli::command::AgentArguments>,
103    ) -> Result<E::Stream<serde_json::Value>, E::Error> {
104    request.jq = Some(jq);
105    executor.execute(request, agent_arguments).await
106}
107
108#[cfg(feature = "mcp")]
109impl crate::cli::command::CommandResponse for ResponseItem {
110    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
111        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
112    }
113}
114
115pub mod request_schema;
116
117
118pub mod response_schema;