objectiveai_sdk/cli/command/agents/laboratories/detach/
mod.rs1use crate::cli::command::CommandRequest;
7use crate::cli::command::agents::selector::{AgentSelector, AgentSelectorArgs};
8
9#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
10#[schemars(rename = "cli.command.agents.laboratories.detach.Request")]
11pub struct Request {
12 pub path_type: Path,
13 pub selector: AgentSelector,
14 pub laboratory_id: String,
15 #[serde(flatten)]
16 pub base: crate::cli::command::RequestBase,
17}
18
19#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
20#[schemars(rename = "cli.command.agents.laboratories.detach.Path")]
21pub enum Path {
22 #[serde(rename = "agents/laboratories/detach")]
23 AgentsLaboratoriesDetach,
24}
25
26impl CommandRequest for Request {
27 fn request_base(&self) -> &crate::cli::command::RequestBase {
28 &self.base
29 }
30
31 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
32 Some(&mut self.base)
33 }
34}
35
36#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
39#[schemars(rename = "cli.command.agents.laboratories.detach.Response")]
40pub struct Response {
41 pub laboratory_id: String,
43}
44
45#[derive(clap::Args)]
46#[command(group(clap::ArgGroup::new("laboratory_id_required").required(true).args(["laboratory_id"])))]
47pub struct Args {
48 #[command(flatten)]
49 pub selector: AgentSelectorArgs,
50 #[arg(long)]
52 pub laboratory_id: Option<String>,
53 #[command(flatten)]
54 pub base: crate::cli::command::RequestBaseArgs,
55}
56
57#[derive(clap::Args)]
58#[command(args_conflicts_with_subcommands = true)]
59pub struct Command {
60 #[command(flatten)]
61 pub args: Args,
62 #[command(subcommand)]
63 pub schema: Option<Schema>,
64}
65
66#[derive(clap::Subcommand)]
67pub enum Schema {
68 RequestSchema(request_schema::Args),
70 ResponseSchema(response_schema::Args),
72}
73
74impl TryFrom<Args> for Request {
75 type Error = crate::cli::command::FromArgsError;
76 fn try_from(args: Args) -> Result<Self, Self::Error> {
77 let selector = AgentSelector::try_from(args.selector)?;
78 let laboratory_id = args.laboratory_id.ok_or_else(|| {
79 crate::cli::command::FromArgsError::path_parse(
80 "laboratory_id",
81 "--laboratory-id is required".to_string(),
82 )
83 })?;
84 Ok(Self {
85 path_type: Path::AgentsLaboratoriesDetach,
86 selector,
87 laboratory_id,
88 base: args.base.into(),
89 })
90 }
91}
92
93#[cfg(feature = "cli-executor")]
94pub async fn execute<E: crate::cli::command::CommandExecutor>(
95 executor: &E,
96 mut request: Request,
97 agent_arguments: Option<&crate::cli::command::AgentArguments>,
98) -> Result<Response, E::Error> {
99 request.base.clear_transform();
100 executor.execute_one(request, agent_arguments).await
101}
102
103#[cfg(feature = "cli-executor")]
104pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
105 executor: &E,
106 mut request: Request,
107 transform: crate::cli::command::Transform,
108 agent_arguments: Option<&crate::cli::command::AgentArguments>,
109) -> Result<serde_json::Value, E::Error> {
110 request.base.set_transform(transform);
111 executor.execute_one(request, agent_arguments).await
112}
113
114#[cfg(feature = "mcp")]
115impl crate::cli::command::CommandResponse for Response {
116 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
117 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
118 }
119}
120
121pub mod request_schema;
122
123pub mod response_schema;
124
125#[cfg(feature = "cli-listener")]
130pub struct ListenerExecution {
131 pub request: Request,
132 pub agent_arguments: crate::cli::command::AgentArguments,
133 pub response: crate::cli::websocket_listener::UnaryResponse<Response>,
134}