Skip to main content

objectiveai_sdk/cli/command/plugins/list/
mod.rs

1//! `plugins list` — 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.plugins.list.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub offset: Option<usize>,
10    pub limit: Option<usize>,
11    #[serde(flatten)]
12    pub base: crate::cli::command::RequestBase,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
16#[schemars(rename = "cli.command.plugins.list.Path")]
17pub enum Path {
18    #[serde(rename = "plugins/list")]
19    PluginsList,
20}
21
22impl CommandRequest for Request {
23    fn request_base(&self) -> &crate::cli::command::RequestBase {
24        &self.base
25    }
26
27    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
28        Some(&mut self.base)
29    }
30}
31
32// Each list item carries the same shape as `plugins get`'s response —
33// `ResponseManifest` is the canonical definition. Re-export here so
34// list items deserialize as the same Rust type the bare-naked
35// dispatcher already constructs.
36pub use super::get::{ResponseManifest as ResponseItem, ResponseMcpServer};
37
38#[derive(clap::Args)]
39pub struct Args {
40    /// Skip the first N matching entries.
41    #[arg(long)]
42    pub offset: Option<usize>,
43    /// Return at most N matching entries.
44    #[arg(long)]
45    pub limit: Option<usize>,
46    #[command(flatten)]
47    pub base: crate::cli::command::RequestBaseArgs,
48}
49
50#[derive(clap::Args)]
51#[command(args_conflicts_with_subcommands = true)]
52pub struct Command {
53    #[command(flatten)]
54    pub args: Args,
55    #[command(subcommand)]
56    pub schema: Option<Schema>,
57}
58
59#[derive(clap::Subcommand)]
60pub enum Schema {
61    /// Emit the JSON Schema for this leaf's `Request` type and exit.
62    RequestSchema(request_schema::Args),
63    /// Emit the JSON Schema for this leaf's `Response` type and exit.
64    ResponseSchema(response_schema::Args),
65}
66
67impl TryFrom<Args> for Request {
68    type Error = crate::cli::command::FromArgsError;
69    fn try_from(args: Args) -> Result<Self, Self::Error> {
70        Ok(Self { path_type: Path::PluginsList,
71            offset: args.offset,
72            limit: args.limit,
73            base: args.base.into(),
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<E::Stream<ResponseItem>, E::Error> {
85    request.base.clear_transform();
86    executor.execute(request, agent_arguments).await
87}
88
89#[cfg(feature = "cli-executor")]
90pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
91    executor: &E,
92    mut request: Request,
93    transform: crate::cli::command::Transform,
94
95        agent_arguments: Option<&crate::cli::command::AgentArguments>,
96    ) -> Result<E::Stream<serde_json::Value>, E::Error> {
97    request.base.set_transform(transform);
98    executor.execute(request, agent_arguments).await
99}
100
101pub mod request_schema;
102
103pub mod response_schema;
104
105/// One `/listen` broadcast run of `plugins list`: the actual
106/// [`Request`], the producer's
107/// [`AgentArguments`](crate::cli::command::AgentArguments), and the
108/// response-item stream. See [`crate::cli::websocket_listener`].
109#[cfg(feature = "cli-listener")]
110pub struct ListenerExecution {
111    pub request: Request,
112    pub agent_arguments: crate::cli::command::AgentArguments,
113    pub response: crate::cli::websocket_listener::ResponseItemStream<ResponseItem>,
114}