Skip to main content

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

1//! `agents get` — 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.get.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub path: crate::RemotePathCommitOptional,
10    #[serde(flatten)]
11    pub base: crate::cli::command::RequestBase,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
15#[schemars(rename = "cli.command.agents.get.Path")]
16pub enum Path {
17    #[serde(rename = "agents/get")]
18    AgentsGet,
19}
20
21impl CommandRequest for Request {
22    fn into_command(&self) -> Vec<String> {
23        let mut argv = vec![
24            "agents".to_string(),
25            "get".to_string(),
26            "--path".to_string(),
27            crate::cli::command::path_ref::remote_path_to_arg_string(&self.path),
28        ];
29        self.base.push_flags(&mut argv);
30        argv
31    }
32
33    fn request_base(&self) -> &crate::cli::command::RequestBase {
34        &self.base
35    }
36
37    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
38        Some(&mut self.base)
39    }
40}
41
42pub type Response = crate::agent::response::GetAgentResponse;
43
44#[derive(clap::Args)]
45pub struct Args {
46    /// Path to the agent (remote path).
47    #[arg(long)]
48    pub path: String,
49    #[command(flatten)]
50    pub base: crate::cli::command::RequestBaseArgs,
51}
52
53#[derive(clap::Args)]
54#[command(args_conflicts_with_subcommands = true)]
55pub struct Command {
56    #[command(flatten)]
57    pub args: Args,
58    #[command(subcommand)]
59    pub schema: Option<Schema>,
60}
61
62#[derive(clap::Subcommand)]
63pub enum Schema {
64    /// Emit the JSON Schema for this leaf's `Request` type and exit.
65    RequestSchema(request_schema::Args),
66    /// Emit the JSON Schema for this leaf's `Response` type and exit.
67    ResponseSchema(response_schema::Args),
68}
69
70impl TryFrom<Args> for Request {
71    type Error = crate::cli::command::FromArgsError;
72    fn try_from(args: Args) -> Result<Self, Self::Error> {
73        let path = args
74            .path
75            .parse::<crate::RemotePathCommitOptional>()
76            .map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
77        Ok(Self { path_type: Path::AgentsGet, path, base: args.base.into() })
78    }
79}
80
81#[cfg(feature = "cli-executor")]
82pub async fn execute<E: crate::cli::command::CommandExecutor>(
83    executor: &E,
84    mut request: Request,
85
86        agent_arguments: Option<&crate::cli::command::AgentArguments>,
87    ) -> Result<Response, E::Error> {
88    request.base.clear_transform();
89    executor.execute_one(request, agent_arguments).await
90}
91
92#[cfg(feature = "cli-executor")]
93pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
94    executor: &E,
95    mut request: Request,
96    transform: crate::cli::command::Transform,
97
98        agent_arguments: Option<&crate::cli::command::AgentArguments>,
99    ) -> Result<serde_json::Value, E::Error> {
100    request.base.set_transform(transform);
101    executor.execute_one(request, agent_arguments).await
102}
103
104pub mod request_schema;
105
106
107pub mod response_schema;