objectiveai_sdk/cli/command/command_request.rs
1/// Convert a typed CLI request struct into the argv tail the cli binary
2/// should be invoked with. Implementors are the per-leaf request shapes
3/// in the surrounding tree (e.g. `agents::spawn::Request`) and emit the
4/// flags + positional args their leaf command expects — without the
5/// binary name. Callers prepend whatever launcher prefix they need
6/// (`["objectiveai-cli"]`, `["objectiveai-cli", "instance"]`, …).
7pub trait CommandRequest {
8 fn into_command(&self) -> Vec<String>;
9
10 /// The request's flattened [`RequestBase`] envelope (`jq` /
11 /// `python` / `timeout` / `max_tokens`). Every leaf embeds one,
12 /// so the implementation is `&self.base`.
13 ///
14 /// [`RequestBase`]: crate::cli::command::RequestBase
15 fn request_base(&self) -> &crate::cli::command::RequestBase;
16
17 /// Mutable access to the request's flattened [`RequestBase`]
18 /// envelope, when it has one (`Some(&mut self.base)`). Lets a
19 /// caller inject the envelope controls (e.g. `timeout` /
20 /// `max_tokens`) onto an already-parsed request in place, without
21 /// re-serializing it through argv — used by the MCP server.
22 ///
23 /// [`RequestBase`]: crate::cli::command::RequestBase
24 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase>;
25}