objectiveai_sdk/cli/command/laboratories/list/
mod.rs1use crate::cli::command::CommandRequest;
8
9#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
10#[schemars(rename = "cli.command.laboratories.list.Request")]
11pub struct Request {
12 pub path_type: Path,
13 pub kind: super::create::Kind,
14 #[serde(flatten)]
15 pub base: crate::cli::command::RequestBase,
16}
17
18#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
19#[schemars(rename = "cli.command.laboratories.list.Path")]
20pub enum Path {
21 #[serde(rename = "laboratories/list")]
22 LaboratoriesList,
23}
24
25impl CommandRequest for Request {
26 fn request_base(&self) -> &crate::cli::command::RequestBase {
27 &self.base
28 }
29
30 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
31 Some(&mut self.base)
32 }
33}
34
35#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
39#[schemars(rename = "cli.command.laboratories.list.ResponseItem")]
40pub struct ResponseItem {
41 pub id: String,
42 pub image: crate::laboratories::LaboratoryImage,
43 pub mounts: Vec<super::create::Mount>,
44 pub env: Vec<super::create::EnvVar>,
45 pub cwd: String,
46 #[serde(default, skip_serializing_if = "Option::is_none")]
50 #[schemars(extend("omitempty" = true))]
51 pub created_at: Option<i64>,
52 #[serde(default, skip_serializing_if = "Option::is_none")]
55 #[schemars(extend("omitempty" = true))]
56 pub agent_full_id: Option<String>,
57 #[serde(default, skip_serializing_if = "Option::is_none")]
59 #[schemars(extend("omitempty" = true))]
60 pub machine: Option<crate::machine::MachineIdentity>,
61 #[serde(default, skip_serializing_if = "Option::is_none")]
64 #[schemars(extend("omitempty" = true))]
65 pub machine_state: Option<String>,
66 #[serde(default)]
70 pub running: bool,
71}
72
73#[derive(clap::Args)]
74#[command(group(clap::ArgGroup::new("side").required(true).args(["client"])))]
75pub struct Args {
76 #[arg(long)]
79 pub client: bool,
80 #[command(flatten)]
81 pub base: crate::cli::command::RequestBaseArgs,
82}
83
84#[derive(clap::Args)]
85#[command(args_conflicts_with_subcommands = true)]
86pub struct Command {
87 #[command(flatten)]
88 pub args: Args,
89 #[command(subcommand)]
90 pub schema: Option<Schema>,
91}
92
93#[derive(clap::Subcommand)]
94pub enum Schema {
95 RequestSchema(request_schema::Args),
97 ResponseSchema(response_schema::Args),
99}
100
101impl TryFrom<Args> for Request {
102 type Error = crate::cli::command::FromArgsError;
103 fn try_from(args: Args) -> Result<Self, Self::Error> {
104 if !args.client {
105 return Err(crate::cli::command::FromArgsError::path_parse(
106 "client",
107 "--client is required".to_string(),
108 ));
109 }
110 Ok(Self {
111 path_type: Path::LaboratoriesList,
112 kind: super::create::Kind::Client,
113 base: args.base.into(),
114 })
115 }
116}
117
118#[cfg(feature = "cli-executor")]
119pub async fn execute<E: crate::cli::command::CommandExecutor>(
120 executor: &E,
121 mut request: Request,
122 agent_arguments: Option<&crate::cli::command::AgentArguments>,
123) -> Result<E::Stream<ResponseItem>, E::Error> {
124 request.base.clear_transform();
125 executor.execute(request, agent_arguments).await
126}
127
128#[cfg(feature = "cli-executor")]
129pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
130 executor: &E,
131 mut request: Request,
132 transform: crate::cli::command::Transform,
133 agent_arguments: Option<&crate::cli::command::AgentArguments>,
134) -> Result<E::Stream<serde_json::Value>, E::Error> {
135 request.base.set_transform(transform);
136 executor.execute(request, agent_arguments).await
137}
138
139#[cfg(feature = "mcp")]
140impl crate::cli::command::CommandResponse for ResponseItem {
141 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
142 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
143 }
144}
145
146pub mod request_schema;
147
148pub mod response_schema;
149
150#[cfg(feature = "cli-listener")]
155pub struct ListenerExecution {
156 pub request: Request,
157 pub agent_arguments: crate::cli::command::AgentArguments,
158 pub response: crate::cli::broadcast_listener::ResponseItemStream<ResponseItem>,
159}