objectiveai_sdk/cli/command/agents/get/
mod.rs1use 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
42#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
44#[schemars(rename = "cli.command.agents.get.Response")]
45pub struct Response {
46 #[serde(flatten)]
47 #[schemars(schema_with = "crate::flatten_schema::<crate::RemotePath>")]
48 pub path: crate::RemotePath,
49 #[serde(flatten)]
51 #[schemars(
52 schema_with = "crate::flatten_schema::<crate::agent::RemoteAgentBaseWithFallbacks>"
53 )]
54 pub inner: crate::agent::RemoteAgentBaseWithFallbacks,
55}
56
57#[cfg(feature = "mcp")]
58impl crate::cli::command::CommandResponse for Response {
59 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
60 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
61 }
62}
63
64#[derive(clap::Args)]
65pub struct Args {
66 #[arg(long)]
68 pub path: String,
69 #[command(flatten)]
70 pub base: crate::cli::command::RequestBaseArgs,
71}
72
73#[derive(clap::Args)]
74#[command(args_conflicts_with_subcommands = true)]
75pub struct Command {
76 #[command(flatten)]
77 pub args: Args,
78 #[command(subcommand)]
79 pub schema: Option<Schema>,
80}
81
82#[derive(clap::Subcommand)]
83pub enum Schema {
84 RequestSchema(request_schema::Args),
86 ResponseSchema(response_schema::Args),
88}
89
90impl TryFrom<Args> for Request {
91 type Error = crate::cli::command::FromArgsError;
92 fn try_from(args: Args) -> Result<Self, Self::Error> {
93 let path = args
94 .path
95 .parse::<crate::RemotePathCommitOptional>()
96 .map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
97 Ok(Self { path_type: Path::AgentsGet, path, base: args.base.into() })
98 }
99}
100
101#[cfg(feature = "cli-executor")]
102pub async fn execute<E: crate::cli::command::CommandExecutor>(
103 executor: &E,
104 mut request: Request,
105
106 agent_arguments: Option<&crate::cli::command::AgentArguments>,
107 ) -> Result<Response, E::Error> {
108 request.base.clear_transform();
109 executor.execute_one(request, agent_arguments).await
110}
111
112#[cfg(feature = "cli-executor")]
113pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
114 executor: &E,
115 mut request: Request,
116 transform: crate::cli::command::Transform,
117
118 agent_arguments: Option<&crate::cli::command::AgentArguments>,
119 ) -> Result<serde_json::Value, E::Error> {
120 request.base.set_transform(transform);
121 executor.execute_one(request, agent_arguments).await
122}
123
124pub mod request_schema;
125
126
127pub mod response_schema;