Skip to main content

objectiveai_sdk/cli/command/agents/list/
mod.rs

1//! `agents list available` — async handler stub.
2
3use 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
36/// The list endpoints return remote paths verbatim, so this is a plain
37/// alias of [`crate::RemotePath`] (not a wrapper enum) — its published
38/// schema is therefore the bare `RemotePath` `$ref` with no distinct
39/// named type for the SDK code generators to reconstruct.
40pub 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    /// Emit the JSON Schema for this leaf's `Request` type and exit.
60    RequestSchema(request_schema::Args),
61    /// Emit the JSON Schema for this leaf's `Response` type and exit.
62    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
97// `ResponseItem` is `crate::RemotePath`; its `CommandResponse` impl lives
98// on `RemotePath` in `crate::remote` (one impl shared by every list leaf
99// that aliases it).
100
101pub mod request_schema;
102
103
104pub mod response_schema;