Skip to main content

objectiveai_sdk/cli/command/
command_request.rs

1/// Common accessors shared by the per-leaf typed CLI request shapes in the
2/// surrounding tree (e.g. `agents::spawn::Request`): the flattened
3/// [`RequestBase`] envelope every leaf embeds.
4///
5/// Lowering a request to an argv tail no longer lives here — requests are
6/// dispatched to the cli as JSON via its top-level `--request` flag, so the
7/// SDK serializes the typed request directly rather than building argv.
8///
9/// [`RequestBase`]: crate::cli::command::RequestBase
10pub trait CommandRequest {
11    /// The request's flattened [`RequestBase`] envelope (`jq` /
12    /// `python` / `timeout` / `max_tokens`). Every leaf embeds one,
13    /// so the implementation is `&self.base`.
14    ///
15    /// [`RequestBase`]: crate::cli::command::RequestBase
16    fn request_base(&self) -> &crate::cli::command::RequestBase;
17
18    /// Mutable access to the request's flattened [`RequestBase`]
19    /// envelope, when it has one (`Some(&mut self.base)`). Lets a
20    /// caller inject the envelope controls (e.g. `timeout` /
21    /// `max_tokens`) onto an already-parsed request in place, without
22    /// re-serializing it through argv — used by the MCP server.
23    ///
24    /// [`RequestBase`]: crate::cli::command::RequestBase
25    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase>;
26}