objectiveai_sdk/cli/command/agents/list/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.agents.list.Request")]
7pub struct Request {
8 pub path_type: Path,
9 #[serde(flatten)]
10 pub base: crate::cli::command::RequestBase,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.agents.list.Path")]
15pub enum Path {
16 #[serde(rename = "agents/list")]
17 AgentsList,
18}
19
20impl CommandRequest for Request {
21 fn into_command(&self) -> Vec<String> {
22 let mut argv = vec!["agents".to_string(), "list".to_string()];
23 self.base.push_flags(&mut argv);
24 argv
25 }
26
27 fn request_base(&self) -> &crate::cli::command::RequestBase {
28 &self.base
29 }
30
31 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
32 Some(&mut self.base)
33 }
34}
35
36pub type ResponseItem = crate::RemotePath;
41
42#[derive(clap::Args)]
43pub struct Args {
44 #[command(flatten)]
45 pub base: crate::cli::command::RequestBaseArgs,
46}
47
48#[derive(clap::Args)]
49#[command(args_conflicts_with_subcommands = true)]
50pub struct Command {
51 #[command(flatten)]
52 pub args: Args,
53 #[command(subcommand)]
54 pub schema: Option<Schema>,
55}
56
57#[derive(clap::Subcommand)]
58pub enum Schema {
59 RequestSchema(request_schema::Args),
61 ResponseSchema(response_schema::Args),
63}
64
65impl TryFrom<Args> for Request {
66 type Error = crate::cli::command::FromArgsError;
67 fn try_from(args: Args) -> Result<Self, Self::Error> {
68 Ok(Self { path_type: Path::AgentsList,
69 base: args.base.into(),
70 })
71 }
72}
73
74#[cfg(feature = "cli-executor")]
75pub async fn execute<E: crate::cli::command::CommandExecutor>(
76 executor: &E,
77 mut request: Request,
78
79 agent_arguments: Option<&crate::cli::command::AgentArguments>,
80 ) -> Result<E::Stream<ResponseItem>, E::Error> {
81 request.base.clear_transform();
82 executor.execute(request, agent_arguments).await
83}
84
85#[cfg(feature = "cli-executor")]
86pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
87 executor: &E,
88 mut request: Request,
89 transform: crate::cli::command::Transform,
90
91 agent_arguments: Option<&crate::cli::command::AgentArguments>,
92 ) -> Result<E::Stream<serde_json::Value>, E::Error> {
93 request.base.set_transform(transform);
94 executor.execute(request, agent_arguments).await
95}
96
97pub mod request_schema;
102
103
104pub mod response_schema;