objectiveai_sdk/cli/command/plugins/get/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.plugins.get.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub name: String,
10 pub jq: Option<String>,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.plugins.get.Path")]
15pub enum Path {
16 #[serde(rename = "plugins/get")]
17 PluginsGet,
18}
19
20impl CommandRequest for Request {
21 fn into_command(&self) -> Vec<String> {
22 let mut argv = vec!["plugins".to_string(), "get".to_string(), self.name.clone()];
23 if let Some(jq) = &self.jq {
24 argv.push("--jq".to_string());
25 argv.push(jq.clone());
26 }
27 argv
28 }
29}
30
31pub type Response = Option<ResponseManifest>;
32
33#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
34#[schemars(rename = "cli.command.plugins.get.ResponseManifest")]
35pub struct ResponseManifest {
36 pub name: String,
37 pub description: String,
38 pub version: String,
39 pub owner: String,
40 #[serde(default, skip_serializing_if = "Option::is_none")]
41 #[schemars(extend("omitempty" = true))]
42 pub author: Option<String>,
43 #[serde(default, skip_serializing_if = "Option::is_none")]
44 #[schemars(extend("omitempty" = true))]
45 pub homepage: Option<String>,
46 #[serde(default, skip_serializing_if = "Option::is_none")]
47 #[schemars(extend("omitempty" = true))]
48 pub license: Option<String>,
49 #[serde(default, skip_serializing_if = "ResponseBinaries::is_empty")]
50 pub binaries: ResponseBinaries,
51 #[serde(default, skip_serializing_if = "Option::is_none")]
52 #[schemars(extend("omitempty" = true))]
53 pub viewer_zip: Option<String>,
54 #[serde(default, skip_serializing_if = "Option::is_none")]
55 #[schemars(extend("omitempty" = true))]
56 pub viewer_url: Option<String>,
57 #[serde(default, skip_serializing_if = "Vec::is_empty")]
58 pub viewer_routes: Vec<ResponseViewerRoute>,
59 #[serde(default, skip_serializing_if = "std::ops::Not::not")]
60 pub mobile_ready: bool,
61 #[serde(default, skip_serializing_if = "Vec::is_empty")]
62 pub mcp_servers: Vec<ResponseMcpServer>,
63 pub source: String,
64}
65
66#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
67#[schemars(rename = "cli.command.plugins.get.ResponseBinaries")]
68pub struct ResponseBinaries {
69 #[serde(default, skip_serializing_if = "Option::is_none")]
70 #[schemars(extend("omitempty" = true))]
71 pub linux_x86_64: Option<String>,
72 #[serde(default, skip_serializing_if = "Option::is_none")]
73 #[schemars(extend("omitempty" = true))]
74 pub linux_aarch64: Option<String>,
75 #[serde(default, skip_serializing_if = "Option::is_none")]
76 #[schemars(extend("omitempty" = true))]
77 pub windows_x86_64: Option<String>,
78 #[serde(default, skip_serializing_if = "Option::is_none")]
79 #[schemars(extend("omitempty" = true))]
80 pub windows_aarch64: Option<String>,
81 #[serde(default, skip_serializing_if = "Option::is_none")]
82 #[schemars(extend("omitempty" = true))]
83 pub macos_x86_64: Option<String>,
84 #[serde(default, skip_serializing_if = "Option::is_none")]
85 #[schemars(extend("omitempty" = true))]
86 pub macos_aarch64: Option<String>,
87}
88
89impl ResponseBinaries {
90 fn is_empty(&self) -> bool {
91 self.linux_x86_64.is_none()
92 && self.linux_aarch64.is_none()
93 && self.windows_x86_64.is_none()
94 && self.windows_aarch64.is_none()
95 && self.macos_x86_64.is_none()
96 && self.macos_aarch64.is_none()
97 }
98}
99
100#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
101#[schemars(rename = "cli.command.plugins.get.ResponseViewerRoute")]
102pub struct ResponseViewerRoute {
103 pub path: String,
104 pub method: ResponseHttpMethod,
105 pub r#type: String,
106}
107
108#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
109#[serde(rename_all = "UPPERCASE")]
110#[schemars(rename = "cli.command.plugins.get.ResponseHttpMethod")]
111pub enum ResponseHttpMethod {
112 Get,
113 Post,
114 Put,
115 Patch,
116 Delete,
117}
118
119#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
120#[schemars(rename = "cli.command.plugins.get.ResponseMcpServer")]
121pub struct ResponseMcpServer {
122 pub name: String,
123 pub url: String,
124 pub authorization: bool,
125}
126
127#[derive(clap::Args)]
128pub struct Args {
129 pub name: String,
131 #[arg(long)]
133 pub jq: Option<String>,
134}
135
136#[derive(clap::Args)]
137#[command(args_conflicts_with_subcommands = true)]
138pub struct Command {
139 #[command(flatten)]
140 pub args: Args,
141 #[command(subcommand)]
142 pub schema: Option<Schema>,
143}
144
145#[derive(clap::Subcommand)]
146pub enum Schema {
147 RequestSchema(request_schema::Args),
149 ResponseSchema(response_schema::Args),
151}
152
153impl TryFrom<Args> for Request {
154 type Error = crate::cli::command::FromArgsError;
155 fn try_from(args: Args) -> Result<Self, Self::Error> {
156 Ok(Self { path_type: Path::PluginsGet,
157 name: args.name,
158 jq: args.jq,
159 })
160 }
161}
162
163#[cfg(feature = "cli-executor")]
164pub async fn execute<E: crate::cli::command::CommandExecutor>(
165 executor: &E,
166 mut request: Request,
167
168 agent_arguments: Option<&crate::cli::command::AgentArguments>,
169 ) -> Result<Response, E::Error> {
170 request.jq = None;
171 executor.execute_one(request, agent_arguments).await
172}
173
174#[cfg(feature = "cli-executor")]
175pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
176 executor: &E,
177 mut request: Request,
178 jq: String,
179
180 agent_arguments: Option<&crate::cli::command::AgentArguments>,
181 ) -> Result<serde_json::Value, E::Error> {
182 request.jq = Some(jq);
183 executor.execute_one(request, agent_arguments).await
184}
185
186#[cfg(feature = "mcp")]
187impl crate::cli::command::CommandResponse for ResponseManifest {
188 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
189 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
190 }
191}
192
193pub mod request_schema;
194
195
196pub mod response_schema;