objectiveai_sdk/cli/command/agents/queue/deliver/
mod.rs1use crate::cli::command::CommandRequest;
29
30#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
31#[schemars(rename = "cli.command.agents.queue.deliver.Request")]
32pub struct Request {
33 pub path_type: Path,
34 pub dangerous_advanced: Option<RequestDangerousAdvanced>,
35 #[serde(flatten)]
36 pub base: crate::cli::command::RequestBase,
37}
38
39#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
40#[schemars(rename = "cli.command.agents.queue.deliver.Path")]
41pub enum Path {
42 #[serde(rename = "agents/queue/deliver")]
43 AgentsQueueDeliver,
44}
45
46#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
47#[schemars(rename = "cli.command.agents.queue.deliver.RequestDangerousAdvanced")]
48pub struct RequestDangerousAdvanced {
49 #[serde(default, skip_serializing_if = "Option::is_none")]
53 #[schemars(extend("omitempty" = true))]
54 pub stream_spawns: Option<bool>,
55}
56
57impl CommandRequest for Request {
58 fn request_base(&self) -> &crate::cli::command::RequestBase {
59 &self.base
60 }
61
62 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
63 Some(&mut self.base)
64 }
65}
66
67#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
73#[serde(untagged)]
74#[schemars(rename = "cli.command.agents.queue.deliver.ResponseItem")]
75pub enum ResponseItem {
76 #[schemars(title = "Value")]
77 Value(ValueResponseItem),
78 #[schemars(title = "AgentActive")]
79 AgentActive(AgentActiveResponseItem),
80 #[schemars(title = "AgentSpawned")]
81 AgentSpawned(AgentSpawnedResponseItem),
82 #[schemars(title = "TagActive")]
83 TagActive(TagActiveResponseItem),
84 #[schemars(title = "TagSpawned")]
85 TagSpawned(TagSpawnedResponseItem),
86 #[schemars(title = "AllAgentsActive")]
87 AllAgentsActive(AllAgentsActive),
88}
89
90#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
103#[schemars(rename = "cli.command.agents.queue.deliver.ValueResponseItem")]
104pub struct ValueResponseItem {
105 pub agent_instance_hierarchy: String,
107 #[schemars(with = "serde_json::Value")]
109 pub value: Box<crate::cli::command::ResponseItem>,
110}
111
112#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
115#[schemars(rename = "cli.command.agents.queue.deliver.AgentActiveResponseItem")]
116pub struct AgentActiveResponseItem {
117 pub r#type: AgentActiveType,
118 pub agent_instance_hierarchy: String,
119}
120
121#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
122#[schemars(rename = "cli.command.agents.queue.deliver.AgentActiveType")]
123pub enum AgentActiveType {
124 #[serde(rename = "AgentActive")]
125 AgentActive,
126}
127
128#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
131#[schemars(rename = "cli.command.agents.queue.deliver.AgentSpawnedResponseItem")]
132pub struct AgentSpawnedResponseItem {
133 pub r#type: AgentSpawnedType,
134 pub agent_instance_hierarchy: String,
135}
136
137#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
138#[schemars(rename = "cli.command.agents.queue.deliver.AgentSpawnedType")]
139pub enum AgentSpawnedType {
140 #[serde(rename = "AgentSpawned")]
141 AgentSpawned,
142}
143
144#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
148#[schemars(rename = "cli.command.agents.queue.deliver.TagActiveResponseItem")]
149pub struct TagActiveResponseItem {
150 pub r#type: TagActiveType,
151 pub agent_tag: String,
152}
153
154#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
155#[schemars(rename = "cli.command.agents.queue.deliver.TagActiveType")]
156pub enum TagActiveType {
157 #[serde(rename = "TagActive")]
158 TagActive,
159}
160
161#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
167#[schemars(rename = "cli.command.agents.queue.deliver.TagSpawnedResponseItem")]
168pub struct TagSpawnedResponseItem {
169 pub r#type: TagSpawnedType,
170 pub agent_tag: String,
171}
172
173#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
174#[schemars(rename = "cli.command.agents.queue.deliver.TagSpawnedType")]
175pub enum TagSpawnedType {
176 #[serde(rename = "TagSpawned")]
177 TagSpawned,
178}
179
180#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
186#[schemars(rename = "cli.command.agents.queue.deliver.AllAgentsActive")]
187pub enum AllAgentsActive {
188 AllAgentsActive,
189}
190
191#[derive(clap::Args)]
192pub struct Args {
193 #[arg(long)]
196 pub dangerous_advanced: Option<String>,
197 #[command(flatten)]
198 pub base: crate::cli::command::RequestBaseArgs,
199}
200
201#[derive(clap::Args)]
202#[command(args_conflicts_with_subcommands = true)]
203pub struct Command {
204 #[command(flatten)]
205 pub args: Args,
206 #[command(subcommand)]
207 pub schema: Option<Schema>,
208}
209
210#[derive(clap::Subcommand)]
211pub enum Schema {
212 RequestSchema(request_schema::Args),
214 ResponseSchema(response_schema::Args),
216}
217
218impl TryFrom<Args> for Request {
219 type Error = crate::cli::command::FromArgsError;
220 fn try_from(args: Args) -> Result<Self, Self::Error> {
221 let dangerous_advanced: Option<RequestDangerousAdvanced> =
222 if let Some(s) = args.dangerous_advanced {
223 let mut de = serde_json::Deserializer::from_str(&s);
224 let v = serde_path_to_error::deserialize(&mut de).map_err(|source| {
225 crate::cli::command::FromArgsError {
226 field: "dangerous_advanced",
227 source: source.into(),
228 }
229 })?;
230 Some(v)
231 } else {
232 None
233 };
234 Ok(Self {
235 path_type: Path::AgentsQueueDeliver,
236 dangerous_advanced,
237 base: args.base.into(),
238 })
239 }
240}
241
242#[cfg(feature = "cli-executor")]
243pub async fn execute<E: crate::cli::command::CommandExecutor>(
244 executor: &E,
245 mut request: Request,
246 agent_arguments: Option<&crate::cli::command::AgentArguments>,
247) -> Result<E::Stream<ResponseItem>, E::Error> {
248 request.base.clear_transform();
249 executor.execute(request, agent_arguments).await
250}
251
252#[cfg(feature = "cli-executor")]
253pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
254 executor: &E,
255 mut request: Request,
256 transform: crate::cli::command::Transform,
257 agent_arguments: Option<&crate::cli::command::AgentArguments>,
258) -> Result<E::Stream<serde_json::Value>, E::Error> {
259 request.base.set_transform(transform);
260 executor.execute(request, agent_arguments).await
261}
262
263#[cfg(feature = "mcp")]
264impl crate::cli::command::CommandResponse for ResponseItem {
265 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
266 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
267 }
268}
269
270pub mod request_schema;
271
272pub mod response_schema;