Skip to main content

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

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