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    #[serde(flatten)]
21    pub base: crate::cli::command::RequestBase,
22}
23
24#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
25#[schemars(rename = "cli.command.agents.queue.read.id.Path")]
26pub enum Path {
27    #[serde(rename = "agents/queue/read/id")]
28    AgentsQueueReadId,
29}
30
31impl CommandRequest for Request {
32    fn into_command(&self) -> Vec<String> {
33        let mut argv = vec![
34            "agents".to_string(),
35            "queue".to_string(),
36            "read".to_string(),
37            "id".to_string(),
38            self.id.to_string(),
39        ];
40        self.base.push_flags(&mut argv);
41        argv
42    }
43
44    fn request_base(&self) -> &crate::cli::command::RequestBase {
45        &self.base
46    }
47
48    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
49        Some(&mut self.base)
50    }
51}
52
53/// The typed payload of one `prompt_contents.id`. Aliased directly
54/// to the SDK [`RichContentPart`] so the wire shape matches
55/// rich-content parts exactly — tagged by `type` with `text`,
56/// `image_url`, `input_audio`, `input_video`, `video_url`, or
57/// `file`. Queue content production today never emits the
58/// `input_video` variant (the walker stores both `InputVideo` and
59/// `VideoUrl` parts as `prompt_videos` rows reading back as
60/// `video_url`), but the type stays unconstrained for forward
61/// compatibility.
62///
63/// [`RichContentPart`]: crate::agent::completions::message::RichContentPart
64pub type Response = crate::agent::completions::message::RichContentPart;
65
66#[derive(clap::Args)]
67pub struct Args {
68    /// `prompt_contents.id` of the content row to fetch.
69    pub id: i64,
70    #[command(flatten)]
71    pub base: crate::cli::command::RequestBaseArgs,
72}
73
74#[derive(clap::Args)]
75#[command(args_conflicts_with_subcommands = true)]
76pub struct Command {
77    #[command(flatten)]
78    pub args: Args,
79    #[command(subcommand)]
80    pub schema: Option<Schema>,
81}
82
83#[derive(clap::Subcommand)]
84pub enum Schema {
85    /// Emit the JSON Schema for this leaf's `Request` type and exit.
86    RequestSchema(request_schema::Args),
87    /// Emit the JSON Schema for this leaf's `Response` type and exit.
88    ResponseSchema(response_schema::Args),
89}
90
91impl TryFrom<Args> for Request {
92    type Error = crate::cli::command::FromArgsError;
93    fn try_from(args: Args) -> Result<Self, Self::Error> {
94        Ok(Self {
95            path_type: Path::AgentsQueueReadId,
96            id: args.id,
97            base: args.base.into(),
98        })
99    }
100}
101
102#[cfg(feature = "cli-executor")]
103pub async fn execute<E: crate::cli::command::CommandExecutor>(
104    executor: &E,
105    mut request: Request,
106    agent_arguments: Option<&crate::cli::command::AgentArguments>,
107) -> Result<Response, E::Error> {
108    request.base.clear_transform();
109    executor.execute_one(request, agent_arguments).await
110}
111
112#[cfg(feature = "cli-executor")]
113pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
114    executor: &E,
115    mut request: Request,
116    transform: crate::cli::command::Transform,
117    agent_arguments: Option<&crate::cli::command::AgentArguments>,
118) -> Result<serde_json::Value, E::Error> {
119    request.base.set_transform(transform);
120    executor.execute_one(request, agent_arguments).await
121}
122
123// `RichContentPart` already implements `CommandResponse` via the
124// canonical impl in `cli::command::command_response.rs` — no leaf-
125// local impl needed (and adding one would conflict).
126
127pub mod request_schema;
128
129pub mod response_schema;