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 request_base(&self) -> &crate::cli::command::RequestBase {
44 &self.base
45 }
46
47 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
48 Some(&mut self.base)
49 }
50}
51
52pub type Response = crate::cli::command::Ok;
54
55#[derive(clap::Args)]
56pub struct Args {
57 #[command(flatten)]
58 pub agent: crate::cli::command::agents::selector::AgentSelectorArgs,
59 #[command(flatten)]
60 pub base: crate::cli::command::RequestBaseArgs,
61}
62
63#[derive(clap::Args)]
64#[command(args_conflicts_with_subcommands = true)]
65pub struct Command {
66 #[command(flatten)]
67 pub args: Args,
68 #[command(subcommand)]
69 pub schema: Option<Schema>,
70}
71
72#[derive(clap::Subcommand)]
73pub enum Schema {
74 RequestSchema(request_schema::Args),
76 ResponseSchema(response_schema::Args),
78}
79
80impl TryFrom<Args> for Request {
81 type Error = crate::cli::command::FromArgsError;
82 fn try_from(args: Args) -> Result<Self, Self::Error> {
83 let agent = AgentSelector::try_from(args.agent)?;
84 Ok(Self {
85 path_type: Path::AgentsWait,
86 agent,
87 base: args.base.into(),
88 })
89 }
90}
91
92#[cfg(feature = "cli-executor")]
93pub async fn execute<E: crate::cli::command::CommandExecutor>(
94 executor: &E,
95 mut request: Request,
96
97 agent_arguments: Option<&crate::cli::command::AgentArguments>,
98 ) -> Result<Response, E::Error> {
99 request.base.clear_transform();
100 executor.execute_one(request, agent_arguments).await
101}
102
103#[cfg(feature = "cli-executor")]
104pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
105 executor: &E,
106 mut request: Request,
107 transform: crate::cli::command::Transform,
108
109 agent_arguments: Option<&crate::cli::command::AgentArguments>,
110 ) -> Result<serde_json::Value, E::Error> {
111 request.base.set_transform(transform);
112 executor.execute_one(request, agent_arguments).await
113}
114
115pub mod request_schema;
116
117pub mod response_schema;