objectiveai_sdk/cli/command/logs/agents/completions/response/subscribe/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.logs.agents.completions.response.subscribe.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub id: String,
10 pub timeout_ms: u64,
11 pub require_modification: bool,
12 pub jq: Option<String>,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
16#[schemars(rename = "cli.command.logs.agents.completions.response.subscribe.Path")]
17pub enum Path {
18 #[serde(rename = "logs/agents/completions/response/subscribe")]
19 LogsAgentsCompletionsResponseSubscribe,
20}
21
22impl CommandRequest for Request {
23 fn into_command(&self) -> Vec<String> {
24 let mut argv: Vec<String> = vec!["logs", "agents", "completions", "response", "subscribe"]
25 .into_iter().map(String::from).collect();
26 argv.push(self.id.clone());
27 argv.push(self.timeout_ms.to_string());
28 if self.require_modification {
29 argv.push("--require-modification".to_string());
30 }
31 if let Some(jq) = &self.jq {
32 argv.push("--jq".to_string());
33 argv.push(jq.clone());
34 }
35 argv
36 }
37}
38
39pub type Response = crate::agent::completions::response::streaming::AgentCompletionChunkLog;
40
41#[derive(clap::Args)]
42pub struct Args {
43 pub id: String,
45 pub timeout_ms: u64,
47 #[arg(long)]
49 pub require_modification: bool,
50 #[arg(long)]
52 pub jq: Option<String>,
53}
54
55#[derive(clap::Args)]
56#[command(args_conflicts_with_subcommands = true)]
57pub struct Command {
58 #[command(flatten)]
59 pub args: Args,
60 #[command(subcommand)]
61 pub schema: Option<Schema>,
62}
63
64#[derive(clap::Subcommand)]
65pub enum Schema {
66 RequestSchema(request_schema::Args),
68 ResponseSchema(response_schema::Args),
70}
71
72impl TryFrom<Args> for Request {
73 type Error = crate::cli::command::FromArgsError;
74 fn try_from(args: Args) -> Result<Self, Self::Error> {
75 Ok(Self { path_type: Path::LogsAgentsCompletionsResponseSubscribe,
76 id: args.id,
77 timeout_ms: args.timeout_ms,
78 require_modification: args.require_modification,
79 jq: args.jq,
80 })
81 }
82}
83
84#[cfg(feature = "cli-executor")]
85pub async fn execute<E: crate::cli::command::CommandExecutor>(
86 executor: &E,
87 mut request: Request,
88
89 agent_arguments: Option<&crate::cli::command::AgentArguments>,
90 ) -> Result<Response, E::Error> {
91 request.jq = None;
92 executor.execute_one(request, agent_arguments).await
93}
94
95#[cfg(feature = "cli-executor")]
96pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
97 executor: &E,
98 mut request: Request,
99 jq: String,
100
101 agent_arguments: Option<&crate::cli::command::AgentArguments>,
102 ) -> Result<serde_json::Value, E::Error> {
103 request.jq = Some(jq);
104 executor.execute_one(request, agent_arguments).await
105}
106
107pub mod request_schema;
108
109
110pub mod response_schema;