Skip to main content

objectiveai_sdk/cli/command/laboratories/config/local/get/
mod.rs

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