Skip to main content

objectiveai_sdk/cli/command/logs/agents/completions/request/messages/audio/
mod.rs

1pub mod get;
2
3#[derive(clap::Subcommand)]
4pub enum Command {
5    Get(get::Command),
6}
7
8#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
9#[serde(untagged)]
10#[schemars(rename = "cli.command.logs.agents.completions.request.messages.audio.Request")]
11pub enum Request {
12    #[schemars(title = "Get")]
13    Get(get::Request),
14    #[schemars(title = "GetRequestSchema")]
15    GetRequestSchema(get::request_schema::Request),
16    #[schemars(title = "GetResponseSchema")]
17    GetResponseSchema(get::response_schema::Request),
18}
19
20// Exempt from json-schema coverage: tier aggregate (see the root
21// `ResponseItem` in command.rs - TS7056).
22#[objectiveai_sdk_macros::json_schema_ignore]
23#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
24#[schemars(rename = "cli.command.logs.agents.completions.request.messages.audio.Response")]
25#[serde(untagged)]
26pub enum Response {
27    #[schemars(title = "Get")]
28    Get(get::Response),
29    #[schemars(title = "GetRequestSchema")]
30    GetRequestSchema(get::request_schema::Response),
31    #[schemars(title = "GetResponseSchema")]
32    GetResponseSchema(get::response_schema::Response),
33}
34
35#[cfg(feature = "mcp")]
36impl crate::cli::command::CommandResponse for Response {
37    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
38        match self {
39            Response::Get(v) => v.into_mcp(),
40            Response::GetRequestSchema(v) => v.into_mcp(),
41            Response::GetResponseSchema(v) => v.into_mcp(),
42        }
43    }
44}
45
46impl TryFrom<Command> for Request {
47    type Error = crate::cli::command::FromArgsError;
48    fn try_from(command: Command) -> Result<Self, Self::Error> {
49        match command {
50            Command::Get(cmd) => match cmd.schema {
51                None => Ok(Request::Get(get::Request::try_from(cmd.args)?)),
52                Some(get::Schema::RequestSchema(args)) =>
53                    Ok(Request::GetRequestSchema(get::request_schema::Request::try_from(args)?)),
54                Some(get::Schema::ResponseSchema(args)) =>
55                    Ok(Request::GetResponseSchema(get::response_schema::Request::try_from(args)?)),
56            },
57        }
58    }
59}
60
61impl crate::cli::command::CommandRequest for Request {
62    fn into_command(&self) -> Vec<String> {
63        match self {
64            Request::Get(inner) => inner.into_command(),
65            Request::GetRequestSchema(inner) => inner.into_command(),
66            Request::GetResponseSchema(inner) => inner.into_command(),
67        }
68    }
69}
70
71#[cfg(feature = "cli-executor")]
72pub async fn execute<E: crate::cli::command::CommandExecutor>(
73    executor: &E,
74    request: Request,
75
76        agent_arguments: Option<&crate::cli::command::AgentArguments>,
77    ) -> Result<
78    std::pin::Pin<Box<dyn futures::Stream<Item = Result<Response, E::Error>> + Send>>,
79    E::Error,
80> {
81    use futures::StreamExt;
82    let stream: std::pin::Pin<Box<dyn futures::Stream<Item = Result<Response, E::Error>> + Send>> =
83        match request {
84            Request::Get(req) => {
85                let value = get::execute(executor, req, agent_arguments).await?;
86                Box::pin(crate::cli::command::StreamOnce::new(Ok(
87                    Response::Get(value),
88                )))
89            }
90            Request::GetRequestSchema(req) => {
91                let value = get::request_schema::execute(executor, req, agent_arguments).await?;
92                Box::pin(crate::cli::command::StreamOnce::new(Ok(
93                    Response::GetRequestSchema(value),
94                )))
95            }
96            Request::GetResponseSchema(req) => {
97                let value = get::response_schema::execute(executor, req, agent_arguments).await?;
98                Box::pin(crate::cli::command::StreamOnce::new(Ok(
99                    Response::GetResponseSchema(value),
100                )))
101            }
102        };
103    Ok(stream)
104}
105
106#[cfg(feature = "cli-executor")]
107pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
108    executor: &E,
109    request: Request,
110    jq: String,
111
112        agent_arguments: Option<&crate::cli::command::AgentArguments>,
113    ) -> Result<
114    std::pin::Pin<Box<dyn futures::Stream<Item = Result<serde_json::Value, E::Error>> + Send>>,
115    E::Error,
116> {
117    let stream: std::pin::Pin<Box<dyn futures::Stream<Item = Result<serde_json::Value, E::Error>> + Send>> =
118        match request {
119            Request::Get(req) => {
120                let value = get::execute_jq(executor, req, jq, agent_arguments).await?;
121                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
122            }
123            Request::GetRequestSchema(req) => {
124                let value = get::request_schema::execute_jq(executor, req, jq, agent_arguments).await?;
125                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
126            }
127            Request::GetResponseSchema(req) => {
128                let value = get::response_schema::execute_jq(executor, req, jq, agent_arguments).await?;
129                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
130            }
131        };
132    Ok(stream)
133}