Skip to main content

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

1//! `tools 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.tools.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.tools.list.Path")]
17pub enum Path {
18    #[serde(rename = "tools/list")]
19    ToolsList,
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 `tools get`'s response —
33// `ResponseManifest` is the canonical definition. Re-export here so
34// list items deserialize as the same Rust type.
35pub use super::get::ResponseManifest as ResponseItem;
36
37#[derive(clap::Args)]
38pub struct Args {
39    /// Skip the first N matching entries.
40    #[arg(long)]
41    pub offset: Option<usize>,
42    /// Return at most N matching entries.
43    #[arg(long)]
44    pub limit: Option<usize>,
45    #[command(flatten)]
46    pub base: crate::cli::command::RequestBaseArgs,
47}
48
49#[derive(clap::Args)]
50#[command(args_conflicts_with_subcommands = true)]
51pub struct Command {
52    #[command(flatten)]
53    pub args: Args,
54    #[command(subcommand)]
55    pub schema: Option<Schema>,
56}
57
58#[derive(clap::Subcommand)]
59pub enum Schema {
60    /// Emit the JSON Schema for this leaf's `Request` type and exit.
61    RequestSchema(request_schema::Args),
62    /// Emit the JSON Schema for this leaf's `Response` type and exit.
63    ResponseSchema(response_schema::Args),
64}
65
66impl TryFrom<Args> for Request {
67    type Error = crate::cli::command::FromArgsError;
68    fn try_from(args: Args) -> Result<Self, Self::Error> {
69        Ok(Self { path_type: Path::ToolsList,
70            offset: args.offset,
71            limit: args.limit,
72            base: args.base.into(),
73        })
74    }
75}
76
77#[cfg(feature = "cli-executor")]
78pub async fn execute<E: crate::cli::command::CommandExecutor>(
79    executor: &E,
80    mut request: Request,
81
82        agent_arguments: Option<&crate::cli::command::AgentArguments>,
83    ) -> Result<E::Stream<ResponseItem>, E::Error> {
84    request.base.clear_transform();
85    executor.execute(request, agent_arguments).await
86}
87
88#[cfg(feature = "cli-executor")]
89pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
90    executor: &E,
91    mut request: Request,
92    transform: crate::cli::command::Transform,
93
94        agent_arguments: Option<&crate::cli::command::AgentArguments>,
95    ) -> Result<E::Stream<serde_json::Value>, E::Error> {
96    request.base.set_transform(transform);
97    executor.execute(request, agent_arguments).await
98}
99
100pub mod request_schema;
101
102
103pub mod response_schema;