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