Skip to main content

objectiveai_cli/command/laboratories/
create.rs

1//! `laboratories create` — create + start a laboratory container via podman,
2//! injecting and running the bundled lab MCP binary. Echoes back what it
3//! created. Only client-side laboratories are supported today.
4
5use objectiveai_sdk::cli::command::laboratories::create::{Kind, Request, Response};
6
7use crate::context::Context;
8use crate::error::Error;
9use crate::podman::laboratory;
10
11pub async fn execute(ctx: &Context, request: Request) -> Result<Response, Error> {
12    // Only `Client` exists today; the match stays exhaustive so adding
13    // `Server` later forces a decision here.
14    match request.kind {
15        Kind::Client => {}
16    }
17
18    let podman_mounts: Vec<laboratory::Mount> = request
19        .mounts
20        .iter()
21        .map(|m| laboratory::Mount {
22            host: m.host.clone(),
23            container: m.container.clone(),
24        })
25        .collect();
26    let env: Vec<(String, String)> = request
27        .env
28        .iter()
29        .map(|e| (e.key.clone(), e.value.clone()))
30        .collect();
31
32    laboratory::create(
33        ctx,
34        &request.id,
35        &request.image,
36        &podman_mounts,
37        &env,
38        &request.cwd,
39    )
40    .await?;
41
42    Ok(Response {
43        id: request.id,
44        image: request.image,
45        mounts: request.mounts,
46        env: request.env,
47        cwd: request.cwd,
48    })
49}
50
51pub mod request_schema {
52    use objectiveai_sdk::cli::command::laboratories::create as sdk;
53    use objectiveai_sdk::cli::command::laboratories::create::request_schema::{Request, Response};
54
55    use crate::context::Context;
56    use crate::error::Error;
57
58    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
59        Ok(objectiveai_sdk::cli::command::ResponseSchema(
60            schemars::schema_for!(sdk::Request),
61        ))
62    }
63}
64
65pub mod response_schema {
66    use objectiveai_sdk::cli::command::laboratories::create as sdk;
67    use objectiveai_sdk::cli::command::laboratories::create::response_schema::{Request, Response};
68
69    use crate::context::Context;
70    use crate::error::Error;
71
72    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
73        Ok(objectiveai_sdk::cli::command::ResponseSchema(
74            schemars::schema_for!(sdk::Response),
75        ))
76    }
77}