Skip to main content

objectiveai_sdk/cli/command/agents/queue/delete/
mod.rs

1//! `agents queue delete` — manually drop one queued prompt
2//! by its `prompts.id` (the id surfaced by `agents queue
3//! list`). Returns the deleted row's metadata + content so callers
4//! can confirm exactly which item was dropped.
5//!
6//! Cascade on `prompt_contents.prompt_id` sweeps every per-kind
7//! content row inside the same transaction, so the delete is
8//! atomic.
9
10use crate::cli::command::CommandRequest;
11
12#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.agents.queue.delete.Request")]
14pub struct Request {
15    pub path_type: Path,
16    pub id: i64,
17    #[serde(flatten)]
18    pub base: crate::cli::command::RequestBase,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
22#[schemars(rename = "cli.command.agents.queue.delete.Path")]
23pub enum Path {
24    #[serde(rename = "agents/queue/delete")]
25    AgentsQueueDelete,
26}
27
28impl CommandRequest for Request {
29    fn into_command(&self) -> Vec<String> {
30        let mut argv = vec![
31            "agents".to_string(),
32            "queue".to_string(),
33            "delete".to_string(),
34            self.id.to_string(),
35        ];
36        self.base.push_flags(&mut argv);
37        argv
38    }
39
40    fn request_base(&self) -> &crate::cli::command::RequestBase {
41        &self.base
42    }
43
44    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
45        Some(&mut self.base)
46    }
47}
48
49/// What was deleted. Carries every column of the original
50/// `prompts` row so the caller can confirm the drop:
51/// exactly one of `agent_instance_hierarchy` / `agent_tag` is set
52/// (matching the original target), `enqueued_at` is the original
53/// unix-seconds timestamp, and `content` is the reconstructed
54/// `RichContent` body.
55#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
56#[schemars(rename = "cli.command.agents.queue.delete.Response")]
57pub struct Response {
58    pub id: i64,
59    #[serde(default, skip_serializing_if = "Option::is_none")]
60    #[schemars(extend("omitempty" = true))]
61    pub agent_instance_hierarchy: Option<String>,
62    #[serde(default, skip_serializing_if = "Option::is_none")]
63    #[schemars(extend("omitempty" = true))]
64    pub agent_tag: Option<String>,
65    /// Idempotency token, if the dropped row had one.
66    #[serde(default, skip_serializing_if = "Option::is_none")]
67    #[schemars(extend("omitempty" = true))]
68    pub key: Option<String>,
69    /// RFC3339 timestamp the dropped row was enqueued at.
70    pub enqueued_at: String,
71    pub content: crate::agent::completions::message::RichContent,
72}
73
74#[derive(clap::Args)]
75pub struct Args {
76    /// Row id of the queued prompt to delete (as surfaced by
77    /// `agents queue list`).
78    pub id: i64,
79    #[command(flatten)]
80    pub base: crate::cli::command::RequestBaseArgs,
81}
82
83#[derive(clap::Args)]
84#[command(args_conflicts_with_subcommands = true)]
85pub struct Command {
86    #[command(flatten)]
87    pub args: Args,
88    #[command(subcommand)]
89    pub schema: Option<Schema>,
90}
91
92#[derive(clap::Subcommand)]
93pub enum Schema {
94    /// Emit the JSON Schema for this leaf's `Request` type and exit.
95    RequestSchema(request_schema::Args),
96    /// Emit the JSON Schema for this leaf's `Response` type and exit.
97    ResponseSchema(response_schema::Args),
98}
99
100impl TryFrom<Args> for Request {
101    type Error = crate::cli::command::FromArgsError;
102    fn try_from(args: Args) -> Result<Self, Self::Error> {
103        Ok(Self {
104            path_type: Path::AgentsQueueDelete,
105            id: args.id,
106            base: args.base.into(),
107        })
108    }
109}
110
111#[cfg(feature = "cli-executor")]
112pub async fn execute<E: crate::cli::command::CommandExecutor>(
113    executor: &E,
114    mut request: Request,
115    agent_arguments: Option<&crate::cli::command::AgentArguments>,
116) -> Result<Response, E::Error> {
117    request.base.clear_transform();
118    executor.execute_one(request, agent_arguments).await
119}
120
121#[cfg(feature = "cli-executor")]
122pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
123    executor: &E,
124    mut request: Request,
125    transform: crate::cli::command::Transform,
126    agent_arguments: Option<&crate::cli::command::AgentArguments>,
127) -> Result<serde_json::Value, E::Error> {
128    request.base.set_transform(transform);
129    executor.execute_one(request, agent_arguments).await
130}
131
132#[cfg(feature = "mcp")]
133impl crate::cli::command::CommandResponse for Response {
134    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
135        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
136    }
137}
138
139pub mod request_schema;
140
141pub mod response_schema;