Skip to main content

objectiveai_sdk/cli/command/agents/queue/open/
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.open.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.open.Path")]
26pub enum Path {
27    #[serde(rename = "agents/queue/open")]
28    AgentsQueueOpen,
29}
30
31impl CommandRequest for Request {
32    fn request_base(&self) -> &crate::cli::command::RequestBase {
33        &self.base
34    }
35
36    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
37        Some(&mut self.base)
38    }
39}
40
41/// The typed payload of one `prompt_contents.id`. Aliased directly
42/// to the SDK [`RichContentPart`] so the wire shape matches
43/// rich-content parts exactly — tagged by `type` with `text`,
44/// `image_url`, `input_audio`, `input_video`, `video_url`, or
45/// `file`. Queue content production today never emits the
46/// `input_video` variant (the walker stores both `InputVideo` and
47/// `VideoUrl` parts as `prompt_videos` rows reading back as
48/// `video_url`), but the type stays unconstrained for forward
49/// compatibility.
50///
51/// [`RichContentPart`]: crate::agent::completions::message::RichContentPart
52pub type Response = crate::agent::completions::message::RichContentPart;
53
54#[derive(clap::Args)]
55#[command(group(clap::ArgGroup::new("id_required").required(true).args(["id"])))]
56pub struct Args {
57    /// `prompt_contents.id` of the content row to fetch.
58    #[arg(long)]
59    pub id: Option<i64>,
60    #[command(flatten)]
61    pub base: crate::cli::command::RequestBaseArgs,
62}
63
64#[derive(clap::Args)]
65#[command(args_conflicts_with_subcommands = true)]
66pub struct Command {
67    #[command(flatten)]
68    pub args: Args,
69    #[command(subcommand)]
70    pub schema: Option<Schema>,
71}
72
73#[derive(clap::Subcommand)]
74pub enum Schema {
75    /// Emit the JSON Schema for this leaf's `Request` type and exit.
76    RequestSchema(request_schema::Args),
77    /// Emit the JSON Schema for this leaf's `Response` type and exit.
78    ResponseSchema(response_schema::Args),
79}
80
81impl TryFrom<Args> for Request {
82    type Error = crate::cli::command::FromArgsError;
83    fn try_from(args: Args) -> Result<Self, Self::Error> {
84        Ok(Self {
85            path_type: Path::AgentsQueueOpen,
86            id: args.id.ok_or_else(|| {
87                crate::cli::command::FromArgsError::path_parse(
88                    "id",
89                    "--id is required".to_string(),
90                )
91            })?,
92            base: args.base.into(),
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.base.clear_transform();
104    executor.execute_one(request, agent_arguments).await
105}
106
107#[cfg(feature = "cli-executor")]
108pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
109    executor: &E,
110    mut request: Request,
111    transform: crate::cli::command::Transform,
112    agent_arguments: Option<&crate::cli::command::AgentArguments>,
113) -> Result<serde_json::Value, E::Error> {
114    request.base.set_transform(transform);
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;