Skip to main content

objectiveai_sdk/cli/command/api/config/mcp_timeout_ms/set/
mod.rs

1//! `config api mcp-timeout-ms set` — 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.api.config.mcp_timeout_ms.set.Request")]
7pub struct Request {
8    pub path_type: Path,
9    #[serde(flatten)]
10    pub base: crate::cli::command::RequestBase,
11    pub scope: crate::cli::command::SetScope,
12    /// The new MCP timeout in milliseconds, as a decimal integer string.
13    /// Carried verbatim here; the cli handler parses it to a `u64`.
14    pub value: String,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
18#[schemars(rename = "cli.command.api.config.mcp_timeout_ms.set.Path")]
19pub enum Path {
20    #[serde(rename = "api/config/mcp_timeout_ms/set")]
21    ApiConfigMcpTimeoutMsSet,
22}
23
24impl CommandRequest for Request {
25    fn request_base(&self) -> &crate::cli::command::RequestBase {
26        &self.base
27    }
28
29    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
30        Some(&mut self.base)
31    }
32}
33
34pub type Response = crate::cli::command::Ok;
35
36#[derive(clap::Args)]
37#[command(group(clap::ArgGroup::new("value_required").required(true).args(["value"])))]
38pub struct Args {
39    /// Mutate the global config layer.
40    #[arg(long)]
41    pub global: bool,
42    /// Mutate the state config layer.
43    #[arg(long)]
44    pub state: bool,
45    #[command(flatten)]
46    pub base: crate::cli::command::RequestBaseArgs,
47    /// New MCP timeout in milliseconds (a decimal integer).
48    #[arg(long)]
49    pub value: Option<String>,
50}
51
52#[derive(clap::Args)]
53#[command(args_conflicts_with_subcommands = true)]
54pub struct Command {
55    #[command(flatten)]
56    pub args: Args,
57    #[command(subcommand)]
58    pub schema: Option<Schema>,
59}
60
61#[derive(clap::Subcommand)]
62pub enum Schema {
63    /// Emit the JSON Schema for this leaf's `Request` type and exit.
64    RequestSchema(request_schema::Args),
65    /// Emit the JSON Schema for this leaf's `Response` type and exit.
66    ResponseSchema(response_schema::Args),
67}
68
69impl TryFrom<Args> for Request {
70    type Error = crate::cli::command::FromArgsError;
71    fn try_from(args: Args) -> Result<Self, Self::Error> {
72        let scope = match (args.global, args.state) {
73            (true, false) => crate::cli::command::SetScope::Global,
74            (false, true) => crate::cli::command::SetScope::State,
75            _ => {
76                return Err(crate::cli::command::FromArgsError {
77                    field: "scope",
78                    source: crate::cli::command::FromArgsErrorSource::Plain(
79                        "exactly one of --global, --state is required".to_string(),
80                    ),
81                });
82            }
83        };
84        Ok(Self {
85            base: args.base.into(), path_type: Path::ApiConfigMcpTimeoutMsSet,
86            scope,
87            value: args.value.ok_or_else(|| {
88                crate::cli::command::FromArgsError::path_parse(
89                    "value",
90                    "--value is required".to_string(),
91                )
92            })?,
93        })
94    }
95}
96
97#[cfg(feature = "cli-executor")]
98pub async fn execute<E: crate::cli::command::CommandExecutor>(
99    executor: &E,
100    request: Request,
101
102        agent_arguments: Option<&crate::cli::command::AgentArguments>,
103    ) -> Result<Response, E::Error> {
104    executor.execute_one(request, agent_arguments).await
105}
106
107pub mod request_schema;
108
109
110pub mod response_schema;
111
112#[cfg(feature = "cli-executor")]
113pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
114    executor: &E,
115    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    let resp: Response = executor.execute_one(request, agent_arguments).await?;
121    Ok(serde_json::to_value(resp).expect("Response serializes"))
122}