Skip to main content

objectiveai_sdk/cli/command/logs/agents/completions/response/messages/subscribe/
mod.rs

1//! `logs agents completions response messages 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.agents.completions.response.messages.subscribe.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub id: String,
10    pub message_index: u64,
11    pub timeout_ms: u64,
12    pub require_modification: bool,
13    pub jq: Option<String>,
14}
15
16#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
17#[schemars(rename = "cli.command.logs.agents.completions.response.messages.subscribe.Path")]
18pub enum Path {
19    #[serde(rename = "logs/agents/completions/response/messages/subscribe")]
20    LogsAgentsCompletionsResponseMessagesSubscribe,
21}
22
23impl CommandRequest for Request {
24    fn into_command(&self) -> Vec<String> {
25        let mut argv: Vec<String> = vec!["logs", "agents", "completions", "response", "messages", "subscribe"]
26            .into_iter().map(String::from).collect();
27        argv.push(self.id.clone());
28        argv.push(self.message_index.to_string());
29        argv.push(self.timeout_ms.to_string());
30        if self.require_modification {
31            argv.push("--require-modification".to_string());
32        }
33        if let Some(jq) = &self.jq {
34            argv.push("--jq".to_string());
35            argv.push(jq.clone());
36        }
37        argv
38    }
39}
40
41pub type Response = crate::agent::completions::message::MessageLog;
42
43#[derive(clap::Args)]
44pub struct Args {
45    /// Identifier of the target log entry.
46    pub id: String,
47    /// Index of the message within the response.
48    pub message_index: u64,
49    /// Timeout in milliseconds before the subscription returns.
50    pub timeout_ms: u64,
51    /// Only wake when a modifying event occurs.
52    #[arg(long)]
53    pub require_modification: bool,
54    /// jq filter applied to the JSON output.
55    #[arg(long)]
56    pub jq: Option<String>,
57}
58
59#[derive(clap::Args)]
60#[command(args_conflicts_with_subcommands = true)]
61pub struct Command {
62    #[command(flatten)]
63    pub args: Args,
64    #[command(subcommand)]
65    pub schema: Option<Schema>,
66}
67
68#[derive(clap::Subcommand)]
69pub enum Schema {
70    /// Emit the JSON Schema for this leaf's `Request` type and exit.
71    RequestSchema(request_schema::Args),
72    /// Emit the JSON Schema for this leaf's `Response` type and exit.
73    ResponseSchema(response_schema::Args),
74}
75
76impl TryFrom<Args> for Request {
77    type Error = crate::cli::command::FromArgsError;
78    fn try_from(args: Args) -> Result<Self, Self::Error> {
79        Ok(Self { path_type: Path::LogsAgentsCompletionsResponseMessagesSubscribe,
80            id: args.id,
81            message_index: args.message_index,
82            timeout_ms: args.timeout_ms,
83            require_modification: args.require_modification,
84            jq: args.jq,
85        })
86    }
87}
88
89#[cfg(feature = "cli-executor")]
90pub async fn execute<E: crate::cli::command::CommandExecutor>(
91    executor: &E,
92    mut request: Request,
93
94        agent_arguments: Option<&crate::cli::command::AgentArguments>,
95    ) -> Result<Response, E::Error> {
96    request.jq = None;
97    executor.execute_one(request, agent_arguments).await
98}
99
100#[cfg(feature = "cli-executor")]
101pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
102    executor: &E,
103    mut request: Request,
104    jq: String,
105
106        agent_arguments: Option<&crate::cli::command::AgentArguments>,
107    ) -> Result<serde_json::Value, E::Error> {
108    request.jq = Some(jq);
109    executor.execute_one(request, agent_arguments).await
110}
111
112pub mod request_schema;
113
114
115pub mod response_schema;