objectiveai_sdk/cli/command/plugins/logs/list/
mod.rs1use crate::cli::command::CommandRequest;
6
7#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
8#[schemars(rename = "cli.command.plugins.logs.list.Request")]
9pub struct Request {
10 pub path_type: Path,
11 pub owner: String,
12 pub name: String,
13 pub version: String,
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 #[serde(flatten)]
24 pub base: crate::cli::command::RequestBase,
25}
26
27#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
28#[schemars(rename = "cli.command.plugins.logs.list.Path")]
29pub enum Path {
30 #[serde(rename = "plugins/logs/list")]
31 PluginsLogsList,
32}
33
34impl CommandRequest for Request {
35 fn request_base(&self) -> &crate::cli::command::RequestBase {
36 &self.base
37 }
38
39 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
40 Some(&mut self.base)
41 }
42}
43
44#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
46#[schemars(rename = "cli.command.plugins.logs.list.ResponseItem")]
47pub struct ResponseItem {
48 pub index: i64,
51 pub owner: String,
52 pub name: String,
53 pub version: String,
54 pub agent_instance_hierarchy: String,
56 #[serde(default, skip_serializing_if = "Option::is_none")]
58 #[schemars(extend("omitempty" = true))]
59 pub response_id: Option<String>,
60 pub created_at: i64,
62 pub line: String,
63}
64
65#[derive(clap::Args)]
66#[command(group(clap::ArgGroup::new("owner_required").required(true).args(["owner"])))]
67#[command(group(clap::ArgGroup::new("name_required").required(true).args(["name"])))]
68#[command(group(clap::ArgGroup::new("version_required").required(true).args(["version"])))]
69pub struct Args {
70 #[arg(long)]
72 pub owner: Option<String>,
73 #[arg(long)]
75 pub name: Option<String>,
76 #[arg(long)]
78 pub version: Option<String>,
79 #[arg(long)]
81 pub after_id: Option<i64>,
82 #[arg(long)]
84 pub limit: Option<i64>,
85 #[command(flatten)]
86 pub base: crate::cli::command::RequestBaseArgs,
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 Ok(Self {
110 path_type: Path::PluginsLogsList,
111 owner: args.owner.ok_or_else(|| {
112 crate::cli::command::FromArgsError::path_parse(
113 "owner",
114 "--owner is required".to_string(),
115 )
116 })?,
117 name: args.name.ok_or_else(|| {
118 crate::cli::command::FromArgsError::path_parse(
119 "name",
120 "--name is required".to_string(),
121 )
122 })?,
123 version: args.version.ok_or_else(|| {
124 crate::cli::command::FromArgsError::path_parse(
125 "version",
126 "--version is required".to_string(),
127 )
128 })?,
129 after_id: args.after_id,
130 limit: args.limit,
131 base: args.base.into(),
132 })
133 }
134}
135
136#[cfg(feature = "cli-executor")]
137pub async fn execute<E: crate::cli::command::CommandExecutor>(
138 executor: &E,
139 mut request: Request,
140 agent_arguments: Option<&crate::cli::command::AgentArguments>,
141) -> Result<E::Stream<ResponseItem>, E::Error> {
142 request.base.clear_transform();
143 executor.execute(request, agent_arguments).await
144}
145
146#[cfg(feature = "cli-executor")]
147pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
148 executor: &E,
149 mut request: Request,
150 transform: crate::cli::command::Transform,
151 agent_arguments: Option<&crate::cli::command::AgentArguments>,
152) -> Result<E::Stream<serde_json::Value>, E::Error> {
153 request.base.set_transform(transform);
154 executor.execute(request, agent_arguments).await
155}
156
157#[cfg(feature = "mcp")]
158impl crate::cli::command::CommandResponse for ResponseItem {
159 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
160 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
161 }
162}
163
164pub mod request_schema;
165
166pub mod response_schema;