Skip to main content

objectiveai_sdk/cli/command/logs/functions/inventions/response/subscribe/
mod.rs

1//! `logs functions inventions response subscribe` — async handler stub.
2
3use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.logs.functions.inventions.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.functions.inventions.response.subscribe.Path")]
17pub enum Path {
18    #[serde(rename = "logs/functions/inventions/response/subscribe")]
19    LogsFunctionsInventionsResponseSubscribe,
20}
21
22impl CommandRequest for Request {
23    fn into_command(&self) -> Vec<String> {
24        let mut argv: Vec<String> = vec!["logs", "functions", "inventions", "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::functions::inventions::response::streaming::FunctionInventionChunkLog;
40
41#[derive(clap::Args)]
42pub struct Args {
43    /// Identifier of the target log entry.
44    pub id: String,
45    /// Timeout in milliseconds before the subscription returns.
46    pub timeout_ms: u64,
47    /// Only wake when a modifying event occurs.
48    #[arg(long)]
49    pub require_modification: bool,
50    /// jq filter applied to the JSON output.
51    #[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    /// Emit the JSON Schema for this leaf's `Request` type and exit.
67    RequestSchema(request_schema::Args),
68    /// Emit the JSON Schema for this leaf's `Response` type and exit.
69    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::LogsFunctionsInventionsResponseSubscribe,
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;