objectiveai_sdk/cli/command/agents/logs/read/pending/
mod.rs1use crate::cli::command::CommandRequest;
8
9#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
10#[schemars(rename = "cli.command.agents.logs.read.pending.Request")]
11pub struct Request {
12 pub path_type: Path,
13 pub targets: Vec<Target>,
14 #[serde(default, skip_serializing_if = "Option::is_none")]
17 #[schemars(extend("omitempty" = true))]
18 pub after_id: Option<i64>,
19 #[serde(default, skip_serializing_if = "Option::is_none")]
21 #[schemars(extend("omitempty" = true))]
22 pub limit: Option<i64>,
23 pub jq: Option<String>,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
27#[schemars(rename = "cli.command.agents.logs.read.pending.Path")]
28pub enum Path {
29 #[serde(rename = "agents/logs/read/pending")]
30 AgentsLogsReadPending,
31}
32
33impl CommandRequest for Request {
34 fn into_command(&self) -> Vec<String> {
35 let mut argv = vec![
36 "agents".to_string(),
37 "logs".to_string(),
38 "read".to_string(),
39 "pending".to_string(),
40 ];
41 for target in &self.targets {
42 argv.push("--target".to_string());
43 argv.push(target.into_arg_string());
44 }
45 if let Some(after_id) = self.after_id {
46 argv.push("--after-id".to_string());
47 argv.push(after_id.to_string());
48 }
49 if let Some(limit) = self.limit {
50 argv.push("--limit".to_string());
51 argv.push(limit.to_string());
52 }
53 if let Some(jq) = &self.jq {
54 argv.push("--jq".to_string());
55 argv.push(jq.clone());
56 }
57 argv
58 }
59}
60
61pub use super::all::{
66 AssistantResponsePart, AssistantResponsePartType, ClientNotificationPart,
67 ClientNotificationPartType, ResponseItem, Target, ToolResponsePart, ToolResponsePartType,
68};
69
70#[derive(clap::Args)]
71pub struct Args {
72 #[arg(long = "target", required = true)]
77 pub targets: Vec<String>,
78 #[arg(long)]
80 pub after_id: Option<i64>,
81 #[arg(long)]
83 pub limit: Option<i64>,
84 #[arg(long)]
86 pub jq: Option<String>,
87}
88
89#[derive(clap::Args)]
90#[command(args_conflicts_with_subcommands = true)]
91pub struct Command {
92 #[command(flatten)]
93 pub args: Args,
94 #[command(subcommand)]
95 pub schema: Option<Schema>,
96}
97
98#[derive(clap::Subcommand)]
99pub enum Schema {
100 RequestSchema(request_schema::Args),
102 ResponseSchema(response_schema::Args),
104}
105
106impl TryFrom<Args> for Request {
107 type Error = crate::cli::command::FromArgsError;
108 fn try_from(args: Args) -> Result<Self, Self::Error> {
109 let targets = args
110 .targets
111 .iter()
112 .map(|s| {
113 s.parse::<Target>().map_err(|msg| {
114 crate::cli::command::FromArgsError::path_parse("target", msg)
115 })
116 })
117 .collect::<Result<Vec<_>, _>>()?;
118 Ok(Self {
119 path_type: Path::AgentsLogsReadPending,
120 targets,
121 after_id: args.after_id,
122 limit: args.limit,
123 jq: args.jq,
124 })
125 }
126}
127
128#[cfg(feature = "cli-executor")]
129pub async fn execute<E: crate::cli::command::CommandExecutor>(
130 executor: &E,
131 mut request: Request,
132
133 agent_arguments: Option<&crate::cli::command::AgentArguments>,
134 ) -> Result<E::Stream<ResponseItem>, E::Error> {
135 request.jq = None;
136 executor.execute(request, agent_arguments).await
137}
138
139#[cfg(feature = "cli-executor")]
140pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
141 executor: &E,
142 mut request: Request,
143 jq: String,
144
145 agent_arguments: Option<&crate::cli::command::AgentArguments>,
146 ) -> Result<E::Stream<serde_json::Value>, E::Error> {
147 request.jq = Some(jq);
148 executor.execute(request, agent_arguments).await
149}
150
151pub mod request_schema;
152
153
154pub mod response_schema;