objectiveai_sdk/cli/command/agents/wait/
mod.rs1use crate::cli::command::CommandRequest;
22use crate::cli::command::agents::selector::AgentSelector;
23
24#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
25#[schemars(rename = "cli.command.agents.wait.Request")]
26pub struct Request {
27 pub path_type: Path,
28 pub agent: AgentSelector,
31 #[serde(flatten)]
32 pub base: crate::cli::command::RequestBase,
33}
34
35#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
36#[schemars(rename = "cli.command.agents.wait.Path")]
37pub enum Path {
38 #[serde(rename = "agents/wait")]
39 AgentsWait,
40}
41
42impl CommandRequest for Request {
43 fn into_command(&self) -> Vec<String> {
44 let mut argv = vec!["agents".to_string(), "wait".to_string()];
45 self.agent.push_flags(&mut argv);
46 self.base.push_flags(&mut argv);
47 argv
48 }
49
50 fn request_base(&self) -> &crate::cli::command::RequestBase {
51 &self.base
52 }
53
54 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
55 Some(&mut self.base)
56 }
57}
58
59pub type Response = crate::cli::command::Ok;
61
62#[derive(clap::Args)]
63pub struct Args {
64 #[command(flatten)]
65 pub agent: crate::cli::command::agents::selector::AgentSelectorArgs,
66 #[command(flatten)]
67 pub base: crate::cli::command::RequestBaseArgs,
68}
69
70#[derive(clap::Args)]
71#[command(args_conflicts_with_subcommands = true)]
72pub struct Command {
73 #[command(flatten)]
74 pub args: Args,
75 #[command(subcommand)]
76 pub schema: Option<Schema>,
77}
78
79#[derive(clap::Subcommand)]
80pub enum Schema {
81 RequestSchema(request_schema::Args),
83 ResponseSchema(response_schema::Args),
85}
86
87impl TryFrom<Args> for Request {
88 type Error = crate::cli::command::FromArgsError;
89 fn try_from(args: Args) -> Result<Self, Self::Error> {
90 let agent = AgentSelector::try_from(args.agent)?;
91 Ok(Self {
92 path_type: Path::AgentsWait,
93 agent,
94 base: args.base.into(),
95 })
96 }
97}
98
99#[cfg(feature = "cli-executor")]
100pub async fn execute<E: crate::cli::command::CommandExecutor>(
101 executor: &E,
102 mut request: Request,
103
104 agent_arguments: Option<&crate::cli::command::AgentArguments>,
105 ) -> Result<Response, E::Error> {
106 request.base.clear_transform();
107 executor.execute_one(request, agent_arguments).await
108}
109
110#[cfg(feature = "cli-executor")]
111pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
112 executor: &E,
113 mut request: Request,
114 transform: crate::cli::command::Transform,
115
116 agent_arguments: Option<&crate::cli::command::AgentArguments>,
117 ) -> Result<serde_json::Value, E::Error> {
118 request.base.set_transform(transform);
119 executor.execute_one(request, agent_arguments).await
120}
121
122pub mod request_schema;
123
124pub mod response_schema;