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 request_base(&self) -> &crate::cli::command::RequestBase {
23 &self.base
24 }
25
26 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
27 Some(&mut self.base)
28 }
29}
30
31#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
33#[schemars(rename = "cli.command.agents.get.Response")]
34pub struct Response {
35 #[serde(flatten)]
36 #[schemars(schema_with = "crate::flatten_schema::<crate::RemotePath>")]
37 pub path: crate::RemotePath,
38 #[serde(flatten)]
40 #[schemars(
41 schema_with = "crate::flatten_schema::<crate::agent::RemoteAgentBaseWithFallbacks>"
42 )]
43 pub inner: crate::agent::RemoteAgentBaseWithFallbacks,
44}
45
46#[cfg(feature = "mcp")]
47impl crate::cli::command::CommandResponse for Response {
48 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
49 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
50 }
51}
52
53#[derive(clap::Args)]
54#[command(group(clap::ArgGroup::new("path_required").required(true).args(["path"])))]
55pub struct Args {
56 #[arg(long)]
58 pub path: Option<String>,
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 path = args
84 .path
85 .ok_or_else(|| {
86 crate::cli::command::FromArgsError::path_parse(
87 "path",
88 "--path is required".to_string(),
89 )
90 })?
91 .parse::<crate::RemotePathCommitOptional>()
92 .map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
93 Ok(Self { path_type: Path::AgentsGet, path, base: args.base.into() })
94 }
95}
96
97#[cfg(feature = "cli-executor")]
98pub async fn execute<E: crate::cli::command::CommandExecutor>(
99 executor: &E,
100 mut request: Request,
101
102 agent_arguments: Option<&crate::cli::command::AgentArguments>,
103 ) -> Result<Response, E::Error> {
104 request.base.clear_transform();
105 executor.execute_one(request, agent_arguments).await
106}
107
108#[cfg(feature = "cli-executor")]
109pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
110 executor: &E,
111 mut request: Request,
112 transform: crate::cli::command::Transform,
113
114 agent_arguments: Option<&crate::cli::command::AgentArguments>,
115 ) -> Result<serde_json::Value, E::Error> {
116 request.base.set_transform(transform);
117 executor.execute_one(request, agent_arguments).await
118}
119
120pub mod request_schema;
121
122
123pub mod response_schema;