Skip to main content

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

1//! `daemon config 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.daemon.config.get.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.daemon.config.get.Path")]
15pub enum Path {
16    #[serde(rename = "daemon/config/get")]
17    DaemonConfigGet,
18}
19
20impl CommandRequest for Request {
21    fn request_base(&self) -> &crate::cli::command::RequestBase {
22        &self.base
23    }
24
25    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
26        Some(&mut self.base)
27    }
28}
29
30#[derive(PartialEq, Debug, Clone, Default, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
31#[schemars(rename = "cli.command.daemon.config.get.Response")]
32pub struct Response {
33    #[serde(skip_serializing_if = "Option::is_none")]
34    #[schemars(extend("omitempty" = true))]
35    pub address: Option<String>,
36    #[serde(skip_serializing_if = "Option::is_none")]
37    #[schemars(extend("omitempty" = true))]
38    pub secret: Option<String>,
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[schemars(extend("omitempty" = true))]
41    pub signature: Option<String>,
42}
43
44#[derive(clap::Args)]
45pub struct Args {
46    #[command(flatten)]
47    pub base: crate::cli::command::RequestBaseArgs,
48}
49
50#[derive(clap::Args)]
51#[command(args_conflicts_with_subcommands = true)]
52pub struct Command {
53    #[command(flatten)]
54    pub args: Args,
55    #[command(subcommand)]
56    pub schema: Option<Schema>,
57}
58
59#[derive(clap::Subcommand)]
60pub enum Schema {
61    /// Emit the JSON Schema for this leaf's `Request` type and exit.
62    RequestSchema(request_schema::Args),
63    /// Emit the JSON Schema for this leaf's `Response` type and exit.
64    ResponseSchema(response_schema::Args),
65}
66
67impl TryFrom<Args> for Request {
68    type Error = crate::cli::command::FromArgsError;
69    fn try_from(args: Args) -> Result<Self, Self::Error> {
70        Ok(Self { path_type: Path::DaemonConfigGet,
71            base: args.base.into(),
72        })
73    }
74}
75
76#[cfg(feature = "cli-executor")]
77pub async fn execute<E: crate::cli::command::CommandExecutor>(
78    executor: &E,
79    mut request: Request,
80
81        agent_arguments: Option<&crate::cli::command::AgentArguments>,
82    ) -> Result<Response, E::Error> {
83    request.base.clear_transform();
84    executor.execute_one(request, agent_arguments).await
85}
86
87#[cfg(feature = "cli-executor")]
88pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
89    executor: &E,
90    mut request: Request,
91    transform: crate::cli::command::Transform,
92
93        agent_arguments: Option<&crate::cli::command::AgentArguments>,
94    ) -> Result<serde_json::Value, E::Error> {
95    request.base.set_transform(transform);
96    executor.execute_one(request, agent_arguments).await
97}
98
99#[cfg(feature = "mcp")]
100impl crate::cli::command::CommandResponse for Response {
101    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
102        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
103    }
104}
105
106pub mod request_schema;
107
108pub mod response_schema;
109
110/// One `/listen` broadcast run of `mcp config get`: the actual
111/// [`Request`], the producer's
112/// [`AgentArguments`](crate::cli::command::AgentArguments), and the
113/// unary response future. See [`crate::cli::broadcast_listener`].
114#[cfg(feature = "cli-listener")]
115pub struct ListenerExecution {
116    pub request: Request,
117    pub agent_arguments: crate::cli::command::AgentArguments,
118    pub response: crate::cli::broadcast_listener::UnaryResponse<Response>,
119}