pub mod config;
#[derive(clap::Subcommand)]
pub enum Command {
Config {
#[command(subcommand)]
command: config::Command,
},
}
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
#[serde(untagged)]
#[schemars(rename = "cli.command.api.Request")]
pub enum Request {
Config(config::Request),
}
#[objectiveai_sdk_macros::json_schema_ignore]
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
#[schemars(rename = "cli.command.api.Response")]
#[serde(untagged)]
pub enum Response {
#[schemars(title = "Config")]
Config(config::Response),
}
#[cfg(feature = "mcp")]
impl crate::cli::command::CommandResponse for Response {
fn into_mcp(self) -> crate::cli::command::McpResponseItem {
match self {
Response::Config(v) => v.into_mcp(),
}
}
}
impl TryFrom<Command> for Request {
type Error = crate::cli::command::FromArgsError;
fn try_from(command: Command) -> Result<Self, Self::Error> {
match command {
Command::Config { command } =>
Ok(Request::Config(config::Request::try_from(command)?)),
}
}
}
impl crate::cli::command::CommandRequest for Request {
fn request_base(&self) -> &crate::cli::command::RequestBase {
match self {
Request::Config(inner) => inner.request_base(),
}
}
fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
match self {
Request::Config(inner) => inner.request_base_mut(),
}
}
}
#[cfg(feature = "cli-executor")]
pub async fn execute<E: crate::cli::command::CommandExecutor>(
executor: &E,
request: Request,
agent_arguments: Option<&crate::cli::command::AgentArguments>,
) -> Result<
std::pin::Pin<Box<dyn futures::Stream<Item = Result<Response, E::Error>> + Send>>,
E::Error,
> {
use futures::StreamExt;
let stream: std::pin::Pin<Box<dyn futures::Stream<Item = Result<Response, E::Error>> + Send>> =
match request {
Request::Config(req) => {
let inner = config::execute(executor, req, agent_arguments).await?;
Box::pin(inner.map(|r| r.map(Response::Config)))
}
};
Ok(stream)
}
#[cfg(feature = "cli-executor")]
pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
executor: &E,
request: Request,
transform: crate::cli::command::Transform,
agent_arguments: Option<&crate::cli::command::AgentArguments>,
) -> Result<
std::pin::Pin<Box<dyn futures::Stream<Item = Result<serde_json::Value, E::Error>> + Send>>,
E::Error,
> {
let stream: std::pin::Pin<Box<dyn futures::Stream<Item = Result<serde_json::Value, E::Error>> + Send>> =
match request {
Request::Config(req) => {
let inner = config::execute_transform(executor, req, transform, agent_arguments).await?;
Box::pin(inner)
}
};
Ok(stream)
}
#[cfg(feature = "cli-listener")]
pub enum ListenerExecution {
Config(config::ListenerExecution),
}