Skip to main content

objectiveai_sdk/cli/command/agents/queue/read/id/
mod.rs

1//! `agents queue read id` — fetch one piece of queued content by
2//! its `prompt_contents.id`.
3//!
4//! `agents queue list` emits a `content: ResponseContent` field on
5//! each item (`One(i64)` or `Many(Vec<i64>)`) — the same shape
6//! `RichContent` decomposes to. This leaf takes one such id and
7//! returns the typed payload directly as a
8//! [`crate::agent::completions::message::RichContentPart`], so the
9//! wire form for queue content is bit-identical to a rich-content
10//! part of the same kind. No fork between queue media and message
11//! media at the type level.
12
13use crate::cli::command::CommandRequest;
14
15#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
16#[schemars(rename = "cli.command.agents.queue.read.id.Request")]
17pub struct Request {
18    pub path_type: Path,
19    pub id: i64,
20    pub jq: Option<String>,
21}
22
23#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
24#[schemars(rename = "cli.command.agents.queue.read.id.Path")]
25pub enum Path {
26    #[serde(rename = "agents/queue/read/id")]
27    AgentsQueueReadId,
28}
29
30impl CommandRequest for Request {
31    fn into_command(&self) -> Vec<String> {
32        let mut argv = vec![
33            "agents".to_string(),
34            "queue".to_string(),
35            "read".to_string(),
36            "id".to_string(),
37            self.id.to_string(),
38        ];
39        if let Some(jq) = &self.jq {
40            argv.push("--jq".to_string());
41            argv.push(jq.clone());
42        }
43        argv
44    }
45}
46
47/// The typed payload of one `prompt_contents.id`. Aliased directly
48/// to the SDK [`RichContentPart`] so the wire shape matches
49/// rich-content parts exactly — tagged by `type` with `text`,
50/// `image_url`, `input_audio`, `input_video`, `video_url`, or
51/// `file`. Queue content production today never emits the
52/// `input_video` variant (the walker stores both `InputVideo` and
53/// `VideoUrl` parts as `prompt_videos` rows reading back as
54/// `video_url`), but the type stays unconstrained for forward
55/// compatibility.
56///
57/// [`RichContentPart`]: crate::agent::completions::message::RichContentPart
58pub type Response = crate::agent::completions::message::RichContentPart;
59
60#[derive(clap::Args)]
61pub struct Args {
62    /// `prompt_contents.id` of the content row to fetch.
63    pub id: i64,
64    /// jq filter applied to the JSON output.
65    #[arg(long)]
66    pub jq: Option<String>,
67}
68
69#[derive(clap::Args)]
70#[command(args_conflicts_with_subcommands = true)]
71pub struct Command {
72    #[command(flatten)]
73    pub args: Args,
74    #[command(subcommand)]
75    pub schema: Option<Schema>,
76}
77
78#[derive(clap::Subcommand)]
79pub enum Schema {
80    /// Emit the JSON Schema for this leaf's `Request` type and exit.
81    RequestSchema(request_schema::Args),
82    /// Emit the JSON Schema for this leaf's `Response` type and exit.
83    ResponseSchema(response_schema::Args),
84}
85
86impl TryFrom<Args> for Request {
87    type Error = crate::cli::command::FromArgsError;
88    fn try_from(args: Args) -> Result<Self, Self::Error> {
89        Ok(Self {
90            path_type: Path::AgentsQueueReadId,
91            id: args.id,
92            jq: args.jq,
93        })
94    }
95}
96
97#[cfg(feature = "cli-executor")]
98pub async fn execute<E: crate::cli::command::CommandExecutor>(
99    executor: &E,
100    mut request: Request,
101    agent_arguments: Option<&crate::cli::command::AgentArguments>,
102) -> Result<Response, E::Error> {
103    request.jq = None;
104    executor.execute_one(request, agent_arguments).await
105}
106
107#[cfg(feature = "cli-executor")]
108pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
109    executor: &E,
110    mut request: Request,
111    jq: String,
112    agent_arguments: Option<&crate::cli::command::AgentArguments>,
113) -> Result<serde_json::Value, E::Error> {
114    request.jq = Some(jq);
115    executor.execute_one(request, agent_arguments).await
116}
117
118// `RichContentPart` already implements `CommandResponse` via the
119// canonical impl in `cli::command::command_response.rs` — no leaf-
120// local impl needed (and adding one would conflict).
121
122pub mod request_schema;
123
124pub mod response_schema;