objectiveai_sdk/cli/command/agents/instances/list/
mod.rs1use crate::cli::command::CommandRequest;
6
7pub use super::super::logs::list::Target;
11
12#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.agents.instances.list.Request")]
14pub struct Request {
15 pub path_type: Path,
16 pub targets: Vec<Target>,
19 #[serde(default, skip_serializing_if = "Option::is_none")]
22 #[schemars(extend("omitempty" = true))]
23 pub all: Option<bool>,
24 #[serde(flatten)]
25 pub base: crate::cli::command::RequestBase,
26}
27
28#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
29#[schemars(rename = "cli.command.agents.instances.list.Path")]
30pub enum Path {
31 #[serde(rename = "agents/instances/list")]
32 AgentsInstancesList,
33}
34
35impl CommandRequest for Request {
36 fn request_base(&self) -> &crate::cli::command::RequestBase {
37 &self.base
38 }
39
40 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
41 Some(&mut self.base)
42 }
43}
44
45#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
48#[schemars(rename = "cli.command.agents.instances.list.ResponseItem")]
49pub struct ResponseItem {
50 pub agent_instance_hierarchy: String,
52 pub tags: Vec<String>,
54 pub queued: u64,
57 #[serde(default, skip_serializing_if = "Option::is_none")]
60 #[schemars(extend("omitempty" = true))]
61 pub created_at: Option<String>,
62 #[serde(default, skip_serializing_if = "Option::is_none")]
65 #[schemars(extend("omitempty" = true))]
66 pub last_active_at: Option<String>,
67 pub logged: u64,
69 #[serde(default, skip_serializing_if = "Option::is_none")]
74 #[schemars(extend("omitempty" = true))]
75 pub laboratories: Option<Vec<LaboratoryAttachment>>,
76 #[serde(default, skip_serializing_if = "Option::is_none")]
81 #[schemars(extend("omitempty" = true))]
82 pub agent: Option<crate::agent::InlineAgentBaseWithFallbacksOrRemoteCommitOptional>,
83}
84
85#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
88#[schemars(rename = "cli.command.agents.instances.list.LaboratoryAttachment")]
89pub struct LaboratoryAttachment {
90 pub id: String,
92 pub attached_at: String,
94 #[serde(default, skip_serializing_if = "Option::is_none")]
97 #[schemars(extend("omitempty" = true))]
98 pub attached_by: Option<String>,
99 #[serde(default, skip_serializing_if = "Option::is_none")]
103 #[schemars(extend("omitempty" = true))]
104 pub machine: Option<String>,
105 #[serde(default, skip_serializing_if = "Option::is_none")]
107 #[schemars(extend("omitempty" = true))]
108 pub machine_state: Option<String>,
109}
110
111#[derive(clap::Args)]
112pub struct Args {
113 #[arg(long = "target", required_unless_present = "all")]
117 pub targets: Vec<String>,
118 #[arg(long = "all", conflicts_with = "targets")]
121 pub all: bool,
122 #[command(flatten)]
123 pub base: crate::cli::command::RequestBaseArgs,
124}
125
126#[derive(clap::Args)]
127#[command(args_conflicts_with_subcommands = true)]
128pub struct Command {
129 #[command(flatten)]
130 pub args: Args,
131 #[command(subcommand)]
132 pub schema: Option<Schema>,
133}
134
135#[derive(clap::Subcommand)]
136pub enum Schema {
137 RequestSchema(request_schema::Args),
139 ResponseSchema(response_schema::Args),
141}
142
143impl TryFrom<Args> for Request {
144 type Error = crate::cli::command::FromArgsError;
145 fn try_from(args: Args) -> Result<Self, Self::Error> {
146 let targets = args
147 .targets
148 .iter()
149 .map(|s| {
150 s.parse::<Target>().map_err(|msg| {
151 crate::cli::command::FromArgsError::path_parse("target", msg)
152 })
153 })
154 .collect::<Result<Vec<_>, _>>()?;
155 Ok(Self {
156 path_type: Path::AgentsInstancesList,
157 targets,
158 all: args.all.then_some(true),
159 base: args.base.into(),
160 })
161 }
162}
163
164#[cfg(feature = "cli-executor")]
165pub async fn execute<E: crate::cli::command::CommandExecutor>(
166 executor: &E,
167 mut request: Request,
168
169 agent_arguments: Option<&crate::cli::command::AgentArguments>,
170 ) -> Result<E::Stream<ResponseItem>, E::Error> {
171 request.base.clear_transform();
172 executor.execute(request, agent_arguments).await
173}
174
175#[cfg(feature = "cli-executor")]
176pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
177 executor: &E,
178 mut request: Request,
179 transform: crate::cli::command::Transform,
180
181 agent_arguments: Option<&crate::cli::command::AgentArguments>,
182 ) -> Result<E::Stream<serde_json::Value>, E::Error> {
183 request.base.set_transform(transform);
184 executor.execute(request, agent_arguments).await
185}
186
187#[cfg(feature = "mcp")]
188impl crate::cli::command::CommandResponse for ResponseItem {
189 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
190 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
191 }
192}
193
194pub mod request_schema;
195
196pub mod response_schema;
197
198#[cfg(feature = "cli-listener")]
203pub struct ListenerExecution {
204 pub request: Request,
205 pub agent_arguments: crate::cli::command::AgentArguments,
206 pub response: crate::cli::broadcast_listener::ResponseItemStream<ResponseItem>,
207}