Skip to main content

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

1//! `config 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.config.agents.get.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub filter: Option<String>,
10    pub jq: Option<String>,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.config.agents.get.Path")]
15pub enum Path {
16    #[serde(rename = "config/agents/get")]
17    ConfigAgentsGet,
18}
19
20impl CommandRequest for Request {
21    fn into_command(&self) -> Vec<String> {
22        let mut argv = vec![
23            "config".to_string(),
24            "agents".to_string(),
25            "get".to_string(),
26        ];
27        if let Some(filter) = &self.filter {
28            argv.push(filter.clone());
29        }
30        if let Some(jq) = &self.jq {
31            argv.push("--jq".to_string());
32            argv.push(jq.clone());
33        }
34        argv
35    }
36}
37
38#[derive(PartialEq, Debug, Clone, Default, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
39#[schemars(rename = "cli.command.config.agents.get.Response")]
40pub struct Response {
41    #[serde(skip_serializing_if = "Option::is_none")]
42    #[schemars(extend("omitempty" = true))]
43    pub favorites: Option<Vec<super::favorites::get::ResponseItem>>,
44}
45
46#[derive(clap::Args)]
47pub struct Args {
48    /// Optional path filter into the config tree.
49    pub filter: Option<String>,
50    /// jq filter applied to the JSON output.
51    #[arg(long)]
52    pub jq: Option<String>,
53}
54
55#[derive(clap::Args)]
56#[command(args_conflicts_with_subcommands = true)]
57pub struct Command {
58    #[command(flatten)]
59    pub args: Args,
60    #[command(subcommand)]
61    pub schema: Option<Schema>,
62}
63
64#[derive(clap::Subcommand)]
65pub enum Schema {
66    /// Emit the JSON Schema for this leaf's `Request` type and exit.
67    RequestSchema(request_schema::Args),
68    /// Emit the JSON Schema for this leaf's `Response` type and exit.
69    ResponseSchema(response_schema::Args),
70}
71
72impl TryFrom<Args> for Request {
73    type Error = crate::cli::command::FromArgsError;
74    fn try_from(args: Args) -> Result<Self, Self::Error> {
75        Ok(Self { path_type: Path::ConfigAgentsGet,
76            filter: args.filter,
77            jq: args.jq,
78        })
79    }
80}
81
82#[cfg(feature = "cli-executor")]
83pub async fn execute<E: crate::cli::command::CommandExecutor>(
84    executor: &E,
85    mut request: Request,
86
87        agent_arguments: Option<&crate::cli::command::AgentArguments>,
88    ) -> Result<Response, E::Error> {
89    request.jq = None;
90    executor.execute_one(request, agent_arguments).await
91}
92
93#[cfg(feature = "cli-executor")]
94pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
95    executor: &E,
96    mut request: Request,
97    jq: String,
98
99        agent_arguments: Option<&crate::cli::command::AgentArguments>,
100    ) -> Result<serde_json::Value, E::Error> {
101    request.jq = Some(jq);
102    executor.execute_one(request, agent_arguments).await
103}
104
105#[cfg(feature = "mcp")]
106impl crate::cli::command::CommandResponse for Response {
107    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
108        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
109    }
110}
111
112pub mod request_schema;
113
114
115pub mod response_schema;