Skip to main content

objectiveai_sdk/cli/command/agents/
mod.rs

1pub mod enqueue;
2pub mod get;
3pub mod instances;
4pub mod laboratories;
5pub mod list;
6pub mod logs;
7pub mod mcp;
8pub mod message;
9pub mod publish;
10pub mod queue;
11pub mod selector;
12pub mod spawn;
13pub mod tags;
14pub mod wait;
15
16#[derive(clap::Subcommand)]
17pub enum Command {
18    /// Park a message in the queue against an agent instance or tag
19    /// and return immediately (no delivery race, no spawn).
20    Enqueue(enqueue::Command),
21    /// Get an agent by remote path.
22    Get(get::Command),
23    /// Caller-side handles for live spawned agents that didn't earn
24    /// their own top-level home: `me`, `list`.
25    Instances {
26        #[command(subcommand)]
27        command: instances::Command,
28    },
29    /// Attach/detach/list laboratory ids on an agent target.
30    Laboratories {
31        #[command(subcommand)]
32        command: laboratories::Command,
33    },
34    /// List remote agents available from a given source.
35    List(list::Command),
36    /// Persisted log tier — `open`, `list`, `subscribe`.
37    Logs {
38        #[command(subcommand)]
39        command: logs::Command,
40    },
41    /// Query a live agent's aggregated MCP surface — `resources`,
42    /// `tools` — over its per-`response_id` listener socket.
43    Mcp {
44        #[command(subcommand)]
45        command: mcp::Command,
46    },
47    /// Deliver a message to a running spawned agent (or resume its
48    /// most recent completion via continuation if it's dormant).
49    Message(message::Command),
50    /// Publish an agent to the local filesystem.
51    Publish(publish::Command),
52    /// Deferred-prompt queue — `open`, `list`, `delete`, `deliver`.
53    /// (Add is gone — use `agents message` instead.)
54    Queue {
55        #[command(subcommand)]
56        command: queue::Command,
57    },
58    /// Spawn an agent completion (open a streaming run as a child of
59    /// this caller).
60    Spawn(spawn::Command),
61    /// Client-side agent tags — lookup / apply.
62    Tags {
63        #[command(subcommand)]
64        command: tags::Command,
65    },
66    /// Block until an agent (instance or tag) is done — its lock
67    /// chain fully released — or the timeout elapses.
68    Wait(wait::Command),
69}
70
71#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
72#[serde(untagged)]
73#[schemars(rename = "cli.command.agents.Request")]
74pub enum Request {
75    #[schemars(title = "Enqueue")]
76    Enqueue(enqueue::Request),
77    #[schemars(title = "EnqueueRequestSchema")]
78    EnqueueRequestSchema(enqueue::request_schema::Request),
79    #[schemars(title = "EnqueueResponseSchema")]
80    EnqueueResponseSchema(enqueue::response_schema::Request),
81    #[schemars(title = "Get")]
82    Get(get::Request),
83    #[schemars(title = "GetRequestSchema")]
84    GetRequestSchema(get::request_schema::Request),
85    #[schemars(title = "GetResponseSchema")]
86    GetResponseSchema(get::response_schema::Request),
87    #[schemars(title = "Instances")]
88    Instances(instances::Request),
89    #[schemars(title = "Laboratories")]
90    Laboratories(laboratories::Request),
91    #[schemars(title = "List")]
92    List(list::Request),
93    #[schemars(title = "ListRequestSchema")]
94    ListRequestSchema(list::request_schema::Request),
95    #[schemars(title = "ListResponseSchema")]
96    ListResponseSchema(list::response_schema::Request),
97    #[schemars(title = "Logs")]
98    Logs(logs::Request),
99    #[schemars(title = "Mcp")]
100    Mcp(mcp::Request),
101    #[schemars(title = "Message")]
102    Message(message::Request),
103    #[schemars(title = "MessageRequestSchema")]
104    MessageRequestSchema(message::request_schema::Request),
105    #[schemars(title = "MessageResponseSchema")]
106    MessageResponseSchema(message::response_schema::Request),
107    #[schemars(title = "Publish")]
108    Publish(publish::Request),
109    #[schemars(title = "PublishRequestSchema")]
110    PublishRequestSchema(publish::request_schema::Request),
111    #[schemars(title = "PublishResponseSchema")]
112    PublishResponseSchema(publish::response_schema::Request),
113    #[schemars(title = "Queue")]
114    Queue(queue::Request),
115    #[schemars(title = "Spawn")]
116    Spawn(spawn::Request),
117    #[schemars(title = "SpawnRequestSchema")]
118    SpawnRequestSchema(spawn::request_schema::Request),
119    #[schemars(title = "SpawnResponseSchema")]
120    SpawnResponseSchema(spawn::response_schema::Request),
121    #[schemars(title = "Tags")]
122    Tags(tags::Request),
123    #[schemars(title = "Wait")]
124    Wait(wait::Request),
125    #[schemars(title = "WaitRequestSchema")]
126    WaitRequestSchema(wait::request_schema::Request),
127    #[schemars(title = "WaitResponseSchema")]
128    WaitResponseSchema(wait::response_schema::Request),
129}
130
131// Exempt from json-schema coverage: tier aggregate (see the root
132// `ResponseItem` in command.rs - TS7056).
133#[objectiveai_sdk_macros::json_schema_ignore]
134#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
135#[schemars(rename = "cli.command.agents.ResponseItem")]
136#[serde(untagged)]
137pub enum ResponseItem {
138    #[schemars(title = "Enqueue")]
139    Enqueue(enqueue::Response),
140    #[schemars(title = "EnqueueRequestSchema")]
141    EnqueueRequestSchema(enqueue::request_schema::Response),
142    #[schemars(title = "EnqueueResponseSchema")]
143    EnqueueResponseSchema(enqueue::response_schema::Response),
144    #[schemars(title = "Get")]
145    Get(get::Response),
146    #[schemars(title = "GetRequestSchema")]
147    GetRequestSchema(get::request_schema::Response),
148    #[schemars(title = "GetResponseSchema")]
149    GetResponseSchema(get::response_schema::Response),
150    #[schemars(title = "Instances")]
151    Instances(instances::ResponseItem),
152    #[schemars(title = "Laboratories")]
153    Laboratories(laboratories::ResponseItem),
154    #[schemars(title = "List")]
155    List(list::ResponseItem),
156    #[schemars(title = "ListRequestSchema")]
157    ListRequestSchema(list::request_schema::Response),
158    #[schemars(title = "ListResponseSchema")]
159    ListResponseSchema(list::response_schema::Response),
160    #[schemars(title = "Logs")]
161    Logs(logs::ResponseItem),
162    #[schemars(title = "Mcp")]
163    Mcp(mcp::ResponseItem),
164    #[schemars(title = "Message")]
165    Message(message::Response),
166    #[schemars(title = "MessageRequestSchema")]
167    MessageRequestSchema(message::request_schema::Response),
168    #[schemars(title = "MessageResponseSchema")]
169    MessageResponseSchema(message::response_schema::Response),
170    #[schemars(title = "Publish")]
171    Publish(publish::Response),
172    #[schemars(title = "PublishRequestSchema")]
173    PublishRequestSchema(publish::request_schema::Response),
174    #[schemars(title = "PublishResponseSchema")]
175    PublishResponseSchema(publish::response_schema::Response),
176    #[schemars(title = "Queue")]
177    Queue(queue::ResponseItem),
178    #[schemars(title = "Spawn")]
179    Spawn(spawn::ResponseItem),
180    #[schemars(title = "SpawnRequestSchema")]
181    SpawnRequestSchema(spawn::request_schema::Response),
182    #[schemars(title = "SpawnResponseSchema")]
183    SpawnResponseSchema(spawn::response_schema::Response),
184    #[schemars(title = "Tags")]
185    Tags(tags::ResponseItem),
186    #[schemars(title = "Wait")]
187    Wait(wait::Response),
188    #[schemars(title = "WaitRequestSchema")]
189    WaitRequestSchema(wait::request_schema::Response),
190    #[schemars(title = "WaitResponseSchema")]
191    WaitResponseSchema(wait::response_schema::Response),
192}
193
194#[cfg(feature = "mcp")]
195impl crate::cli::command::CommandResponse for ResponseItem {
196    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
197        match self {
198            ResponseItem::Enqueue(v) => v.into_mcp(),
199            ResponseItem::EnqueueRequestSchema(v) => v.into_mcp(),
200            ResponseItem::EnqueueResponseSchema(v) => v.into_mcp(),
201            ResponseItem::Get(v) => v.into_mcp(),
202            ResponseItem::GetRequestSchema(v) => v.into_mcp(),
203            ResponseItem::GetResponseSchema(v) => v.into_mcp(),
204            ResponseItem::Instances(v) => v.into_mcp(),
205            ResponseItem::Laboratories(v) => v.into_mcp(),
206            ResponseItem::List(v) => v.into_mcp(),
207            ResponseItem::ListRequestSchema(v) => v.into_mcp(),
208            ResponseItem::ListResponseSchema(v) => v.into_mcp(),
209            ResponseItem::Logs(v) => v.into_mcp(),
210            ResponseItem::Mcp(v) => v.into_mcp(),
211            ResponseItem::Message(v) => v.into_mcp(),
212            ResponseItem::MessageRequestSchema(v) => v.into_mcp(),
213            ResponseItem::MessageResponseSchema(v) => v.into_mcp(),
214            ResponseItem::Publish(v) => v.into_mcp(),
215            ResponseItem::PublishRequestSchema(v) => v.into_mcp(),
216            ResponseItem::PublishResponseSchema(v) => v.into_mcp(),
217            ResponseItem::Queue(v) => v.into_mcp(),
218            ResponseItem::Spawn(v) => v.into_mcp(),
219            ResponseItem::SpawnRequestSchema(v) => v.into_mcp(),
220            ResponseItem::SpawnResponseSchema(v) => v.into_mcp(),
221            ResponseItem::Tags(v) => v.into_mcp(),
222            ResponseItem::Wait(v) => v.into_mcp(),
223            ResponseItem::WaitRequestSchema(v) => v.into_mcp(),
224            ResponseItem::WaitResponseSchema(v) => v.into_mcp(),
225        }
226    }
227}
228
229impl TryFrom<Command> for Request {
230    type Error = crate::cli::command::FromArgsError;
231    fn try_from(command: Command) -> Result<Self, Self::Error> {
232        match command {
233            Command::Enqueue(cmd) => match cmd.schema {
234                None => Ok(Request::Enqueue(enqueue::Request::try_from(cmd.args)?)),
235                Some(enqueue::Schema::RequestSchema(args)) =>
236                    Ok(Request::EnqueueRequestSchema(enqueue::request_schema::Request::try_from(args)?)),
237                Some(enqueue::Schema::ResponseSchema(args)) =>
238                    Ok(Request::EnqueueResponseSchema(enqueue::response_schema::Request::try_from(args)?)),
239            },
240            Command::Get(cmd) => match cmd.schema {
241                None => Ok(Request::Get(get::Request::try_from(cmd.args)?)),
242                Some(get::Schema::RequestSchema(args)) =>
243                    Ok(Request::GetRequestSchema(get::request_schema::Request::try_from(args)?)),
244                Some(get::Schema::ResponseSchema(args)) =>
245                    Ok(Request::GetResponseSchema(get::response_schema::Request::try_from(args)?)),
246            },
247            Command::Instances { command } =>
248                Ok(Request::Instances(instances::Request::try_from(command)?)),
249            Command::Laboratories { command } =>
250                Ok(Request::Laboratories(laboratories::Request::try_from(command)?)),
251            Command::List(cmd) => match cmd.schema {
252                None => Ok(Request::List(list::Request::try_from(cmd.args)?)),
253                Some(list::Schema::RequestSchema(args)) =>
254                    Ok(Request::ListRequestSchema(list::request_schema::Request::try_from(args)?)),
255                Some(list::Schema::ResponseSchema(args)) =>
256                    Ok(Request::ListResponseSchema(list::response_schema::Request::try_from(args)?)),
257            },
258            Command::Logs { command } =>
259                Ok(Request::Logs(logs::Request::try_from(command)?)),
260            Command::Mcp { command } =>
261                Ok(Request::Mcp(mcp::Request::try_from(command)?)),
262            Command::Message(cmd) => match cmd.schema {
263                None => Ok(Request::Message(message::Request::try_from(cmd.args)?)),
264                Some(message::Schema::RequestSchema(args)) =>
265                    Ok(Request::MessageRequestSchema(message::request_schema::Request::try_from(args)?)),
266                Some(message::Schema::ResponseSchema(args)) =>
267                    Ok(Request::MessageResponseSchema(message::response_schema::Request::try_from(args)?)),
268            },
269            Command::Publish(cmd) => match cmd.schema {
270                None => Ok(Request::Publish(publish::Request::try_from(cmd.args)?)),
271                Some(publish::Schema::RequestSchema(args)) =>
272                    Ok(Request::PublishRequestSchema(publish::request_schema::Request::try_from(args)?)),
273                Some(publish::Schema::ResponseSchema(args)) =>
274                    Ok(Request::PublishResponseSchema(publish::response_schema::Request::try_from(args)?)),
275            },
276            Command::Queue { command } =>
277                Ok(Request::Queue(queue::Request::try_from(command)?)),
278            Command::Spawn(cmd) => match cmd.schema {
279                None => Ok(Request::Spawn(spawn::Request::try_from(cmd.args)?)),
280                Some(spawn::Schema::RequestSchema(args)) =>
281                    Ok(Request::SpawnRequestSchema(spawn::request_schema::Request::try_from(args)?)),
282                Some(spawn::Schema::ResponseSchema(args)) =>
283                    Ok(Request::SpawnResponseSchema(spawn::response_schema::Request::try_from(args)?)),
284            },
285            Command::Tags { command } =>
286                Ok(Request::Tags(tags::Request::try_from(command)?)),
287            Command::Wait(cmd) => match cmd.schema {
288                None => Ok(Request::Wait(wait::Request::try_from(cmd.args)?)),
289                Some(wait::Schema::RequestSchema(args)) =>
290                    Ok(Request::WaitRequestSchema(wait::request_schema::Request::try_from(args)?)),
291                Some(wait::Schema::ResponseSchema(args)) =>
292                    Ok(Request::WaitResponseSchema(wait::response_schema::Request::try_from(args)?)),
293            },
294        }
295    }
296}
297
298impl crate::cli::command::CommandRequest for Request {
299    fn request_base(&self) -> &crate::cli::command::RequestBase {
300        match self {
301            Request::Enqueue(inner) => inner.request_base(),
302            Request::EnqueueRequestSchema(inner) => inner.request_base(),
303            Request::EnqueueResponseSchema(inner) => inner.request_base(),
304            Request::Get(inner) => inner.request_base(),
305            Request::GetRequestSchema(inner) => inner.request_base(),
306            Request::GetResponseSchema(inner) => inner.request_base(),
307            Request::Instances(inner) => inner.request_base(),
308            Request::Laboratories(inner) => inner.request_base(),
309            Request::List(inner) => inner.request_base(),
310            Request::ListRequestSchema(inner) => inner.request_base(),
311            Request::ListResponseSchema(inner) => inner.request_base(),
312            Request::Logs(inner) => inner.request_base(),
313            Request::Mcp(inner) => inner.request_base(),
314            Request::Message(inner) => inner.request_base(),
315            Request::MessageRequestSchema(inner) => inner.request_base(),
316            Request::MessageResponseSchema(inner) => inner.request_base(),
317            Request::Publish(inner) => inner.request_base(),
318            Request::PublishRequestSchema(inner) => inner.request_base(),
319            Request::PublishResponseSchema(inner) => inner.request_base(),
320            Request::Queue(inner) => inner.request_base(),
321            Request::Spawn(inner) => inner.request_base(),
322            Request::SpawnRequestSchema(inner) => inner.request_base(),
323            Request::SpawnResponseSchema(inner) => inner.request_base(),
324            Request::Tags(inner) => inner.request_base(),
325            Request::Wait(inner) => inner.request_base(),
326            Request::WaitRequestSchema(inner) => inner.request_base(),
327            Request::WaitResponseSchema(inner) => inner.request_base(),
328        }
329    }
330
331    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
332        match self {
333            Request::Enqueue(inner) => inner.request_base_mut(),
334            Request::EnqueueRequestSchema(inner) => inner.request_base_mut(),
335            Request::EnqueueResponseSchema(inner) => inner.request_base_mut(),
336            Request::Get(inner) => inner.request_base_mut(),
337            Request::GetRequestSchema(inner) => inner.request_base_mut(),
338            Request::GetResponseSchema(inner) => inner.request_base_mut(),
339            Request::Instances(inner) => inner.request_base_mut(),
340            Request::Laboratories(inner) => inner.request_base_mut(),
341            Request::List(inner) => inner.request_base_mut(),
342            Request::ListRequestSchema(inner) => inner.request_base_mut(),
343            Request::ListResponseSchema(inner) => inner.request_base_mut(),
344            Request::Logs(inner) => inner.request_base_mut(),
345            Request::Mcp(inner) => inner.request_base_mut(),
346            Request::Message(inner) => inner.request_base_mut(),
347            Request::MessageRequestSchema(inner) => inner.request_base_mut(),
348            Request::MessageResponseSchema(inner) => inner.request_base_mut(),
349            Request::Publish(inner) => inner.request_base_mut(),
350            Request::PublishRequestSchema(inner) => inner.request_base_mut(),
351            Request::PublishResponseSchema(inner) => inner.request_base_mut(),
352            Request::Queue(inner) => inner.request_base_mut(),
353            Request::Spawn(inner) => inner.request_base_mut(),
354            Request::SpawnRequestSchema(inner) => inner.request_base_mut(),
355            Request::SpawnResponseSchema(inner) => inner.request_base_mut(),
356            Request::Tags(inner) => inner.request_base_mut(),
357            Request::Wait(inner) => inner.request_base_mut(),
358            Request::WaitRequestSchema(inner) => inner.request_base_mut(),
359            Request::WaitResponseSchema(inner) => inner.request_base_mut(),
360        }
361    }
362}
363
364#[cfg(feature = "cli-executor")]
365pub async fn execute<E: crate::cli::command::CommandExecutor>(
366    executor: &E,
367    request: Request,
368
369        agent_arguments: Option<&crate::cli::command::AgentArguments>,
370    ) -> Result<
371    std::pin::Pin<Box<dyn futures::Stream<Item = Result<ResponseItem, E::Error>> + Send>>,
372    E::Error,
373> {
374    use futures::StreamExt;
375    let stream: std::pin::Pin<Box<dyn futures::Stream<Item = Result<ResponseItem, E::Error>> + Send>> =
376        match request {
377            Request::Enqueue(req) => {
378                let value = enqueue::execute(executor, req, agent_arguments).await?;
379                Box::pin(crate::cli::command::StreamOnce::new(Ok(
380                    ResponseItem::Enqueue(value),
381                )))
382            }
383            Request::EnqueueRequestSchema(req) => {
384                let value = enqueue::request_schema::execute(executor, req, agent_arguments).await?;
385                Box::pin(crate::cli::command::StreamOnce::new(Ok(
386                    ResponseItem::EnqueueRequestSchema(value),
387                )))
388            }
389            Request::EnqueueResponseSchema(req) => {
390                let value = enqueue::response_schema::execute(executor, req, agent_arguments).await?;
391                Box::pin(crate::cli::command::StreamOnce::new(Ok(
392                    ResponseItem::EnqueueResponseSchema(value),
393                )))
394            }
395            Request::Get(req) => {
396                let value = get::execute(executor, req, agent_arguments).await?;
397                Box::pin(crate::cli::command::StreamOnce::new(Ok(
398                    ResponseItem::Get(value),
399                )))
400            }
401            Request::GetRequestSchema(req) => {
402                let value = get::request_schema::execute(executor, req, agent_arguments).await?;
403                Box::pin(crate::cli::command::StreamOnce::new(Ok(
404                    ResponseItem::GetRequestSchema(value),
405                )))
406            }
407            Request::GetResponseSchema(req) => {
408                let value = get::response_schema::execute(executor, req, agent_arguments).await?;
409                Box::pin(crate::cli::command::StreamOnce::new(Ok(
410                    ResponseItem::GetResponseSchema(value),
411                )))
412            }
413            Request::Instances(req) => {
414                let inner = instances::execute(executor, req, agent_arguments).await?;
415                Box::pin(inner.map(|r| r.map(ResponseItem::Instances)))
416            }
417            Request::Laboratories(req) => {
418                let inner = laboratories::execute(executor, req, agent_arguments).await?;
419                Box::pin(inner.map(|r| r.map(ResponseItem::Laboratories)))
420            }
421            Request::List(req) => {
422                let inner = list::execute(executor, req, agent_arguments).await?;
423                Box::pin(inner.map(|r| r.map(ResponseItem::List)))
424            }
425            Request::ListRequestSchema(req) => {
426                let value = list::request_schema::execute(executor, req, agent_arguments).await?;
427                Box::pin(crate::cli::command::StreamOnce::new(Ok(
428                    ResponseItem::ListRequestSchema(value),
429                )))
430            }
431            Request::ListResponseSchema(req) => {
432                let value = list::response_schema::execute(executor, req, agent_arguments).await?;
433                Box::pin(crate::cli::command::StreamOnce::new(Ok(
434                    ResponseItem::ListResponseSchema(value),
435                )))
436            }
437            Request::Logs(req) => {
438                let inner = logs::execute(executor, req, agent_arguments).await?;
439                Box::pin(inner.map(|r| r.map(ResponseItem::Logs)))
440            }
441            Request::Mcp(req) => {
442                let inner = mcp::execute(executor, req, agent_arguments).await?;
443                Box::pin(inner.map(|r| r.map(ResponseItem::Mcp)))
444            }
445            Request::Message(req) => {
446                let value = message::execute(executor, req, agent_arguments).await?;
447                Box::pin(crate::cli::command::StreamOnce::new(Ok(
448                    ResponseItem::Message(value),
449                )))
450            }
451            Request::MessageRequestSchema(req) => {
452                let value = message::request_schema::execute(executor, req, agent_arguments).await?;
453                Box::pin(crate::cli::command::StreamOnce::new(Ok(
454                    ResponseItem::MessageRequestSchema(value),
455                )))
456            }
457            Request::MessageResponseSchema(req) => {
458                let value = message::response_schema::execute(executor, req, agent_arguments).await?;
459                Box::pin(crate::cli::command::StreamOnce::new(Ok(
460                    ResponseItem::MessageResponseSchema(value),
461                )))
462            }
463            Request::Publish(req) => {
464                let value = publish::execute(executor, req, agent_arguments).await?;
465                Box::pin(crate::cli::command::StreamOnce::new(Ok(
466                    ResponseItem::Publish(value),
467                )))
468            }
469            Request::PublishRequestSchema(req) => {
470                let value = publish::request_schema::execute(executor, req, agent_arguments).await?;
471                Box::pin(crate::cli::command::StreamOnce::new(Ok(
472                    ResponseItem::PublishRequestSchema(value),
473                )))
474            }
475            Request::PublishResponseSchema(req) => {
476                let value = publish::response_schema::execute(executor, req, agent_arguments).await?;
477                Box::pin(crate::cli::command::StreamOnce::new(Ok(
478                    ResponseItem::PublishResponseSchema(value),
479                )))
480            }
481            Request::Queue(req) => {
482                let inner = queue::execute(executor, req, agent_arguments).await?;
483                Box::pin(inner.map(|r| r.map(ResponseItem::Queue)))
484            }
485            Request::Spawn(req) => {
486                let want_streaming = req
487                    .dangerous_advanced
488                    .as_ref()
489                    .and_then(|a| a.stream)
490                    .unwrap_or(false);
491                if want_streaming {
492                    let inner = spawn::execute_streaming(executor, req, agent_arguments).await?;
493                    Box::pin(inner.map(|r| r.map(ResponseItem::Spawn)))
494                } else {
495                    let value = spawn::execute(executor, req, agent_arguments).await?;
496                    Box::pin(crate::cli::command::StreamOnce::new(Ok(
497                        ResponseItem::Spawn(spawn::ResponseItem::Id(value)),
498                    )))
499                }
500            }
501            Request::SpawnRequestSchema(req) => {
502                let value = spawn::request_schema::execute(executor, req, agent_arguments).await?;
503                Box::pin(crate::cli::command::StreamOnce::new(Ok(
504                    ResponseItem::SpawnRequestSchema(value),
505                )))
506            }
507            Request::SpawnResponseSchema(req) => {
508                let value = spawn::response_schema::execute(executor, req, agent_arguments).await?;
509                Box::pin(crate::cli::command::StreamOnce::new(Ok(
510                    ResponseItem::SpawnResponseSchema(value),
511                )))
512            }
513            Request::Tags(req) => {
514                let inner = tags::execute(executor, req, agent_arguments).await?;
515                Box::pin(inner.map(|r| r.map(ResponseItem::Tags)))
516            }
517            Request::Wait(req) => {
518                let value = wait::execute(executor, req, agent_arguments).await?;
519                Box::pin(crate::cli::command::StreamOnce::new(Ok(
520                    ResponseItem::Wait(value),
521                )))
522            }
523            Request::WaitRequestSchema(req) => {
524                let value = wait::request_schema::execute(executor, req, agent_arguments).await?;
525                Box::pin(crate::cli::command::StreamOnce::new(Ok(
526                    ResponseItem::WaitRequestSchema(value),
527                )))
528            }
529            Request::WaitResponseSchema(req) => {
530                let value = wait::response_schema::execute(executor, req, agent_arguments).await?;
531                Box::pin(crate::cli::command::StreamOnce::new(Ok(
532                    ResponseItem::WaitResponseSchema(value),
533                )))
534            }
535        };
536    Ok(stream)
537}
538
539#[cfg(feature = "cli-executor")]
540pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
541    executor: &E,
542    request: Request,
543    transform: crate::cli::command::Transform,
544
545        agent_arguments: Option<&crate::cli::command::AgentArguments>,
546    ) -> Result<
547    std::pin::Pin<Box<dyn futures::Stream<Item = Result<serde_json::Value, E::Error>> + Send>>,
548    E::Error,
549> {
550    let stream: std::pin::Pin<Box<dyn futures::Stream<Item = Result<serde_json::Value, E::Error>> + Send>> =
551        match request {
552            Request::Enqueue(req) => {
553                let value = enqueue::execute_transform(executor, req, transform, agent_arguments).await?;
554                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
555            }
556            Request::EnqueueRequestSchema(req) => {
557                let value =
558                    enqueue::request_schema::execute_transform(executor, req, transform, agent_arguments).await?;
559                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
560            }
561            Request::EnqueueResponseSchema(req) => {
562                let value =
563                    enqueue::response_schema::execute_transform(executor, req, transform, agent_arguments).await?;
564                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
565            }
566            Request::Get(req) => {
567                let value = get::execute_transform(executor, req, transform, agent_arguments).await?;
568                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
569            }
570            Request::GetRequestSchema(req) => {
571                let value = get::request_schema::execute_transform(executor, req, transform, agent_arguments).await?;
572                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
573            }
574            Request::GetResponseSchema(req) => {
575                let value = get::response_schema::execute_transform(executor, req, transform, agent_arguments).await?;
576                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
577            }
578            Request::Instances(req) => {
579                let inner = instances::execute_transform(executor, req, transform, agent_arguments).await?;
580                Box::pin(inner)
581            }
582            Request::Laboratories(req) => {
583                let inner = laboratories::execute_transform(executor, req, transform, agent_arguments).await?;
584                Box::pin(inner)
585            }
586            Request::List(req) => {
587                let inner = list::execute_transform(executor, req, transform, agent_arguments).await?;
588                Box::pin(inner)
589            }
590            Request::ListRequestSchema(req) => {
591                let value = list::request_schema::execute_transform(executor, req, transform, agent_arguments).await?;
592                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
593            }
594            Request::ListResponseSchema(req) => {
595                let value = list::response_schema::execute_transform(executor, req, transform, agent_arguments).await?;
596                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
597            }
598            Request::Logs(req) => {
599                let inner = logs::execute_transform(executor, req, transform, agent_arguments).await?;
600                Box::pin(inner)
601            }
602            Request::Mcp(req) => {
603                let inner = mcp::execute_transform(executor, req, transform, agent_arguments).await?;
604                Box::pin(inner)
605            }
606            Request::Message(req) => {
607                let value = message::execute_transform(executor, req, transform, agent_arguments).await?;
608                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
609            }
610            Request::MessageRequestSchema(req) => {
611                let value =
612                    message::request_schema::execute_transform(executor, req, transform, agent_arguments).await?;
613                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
614            }
615            Request::MessageResponseSchema(req) => {
616                let value =
617                    message::response_schema::execute_transform(executor, req, transform, agent_arguments).await?;
618                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
619            }
620            Request::Publish(req) => {
621                let value = publish::execute_transform(executor, req, transform, agent_arguments).await?;
622                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
623            }
624            Request::PublishRequestSchema(req) => {
625                let value = publish::request_schema::execute_transform(executor, req, transform, agent_arguments).await?;
626                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
627            }
628            Request::PublishResponseSchema(req) => {
629                let value = publish::response_schema::execute_transform(executor, req, transform, agent_arguments).await?;
630                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
631            }
632            Request::Queue(req) => {
633                let inner = queue::execute_transform(executor, req, transform, agent_arguments).await?;
634                Box::pin(inner)
635            }
636            Request::Spawn(req) => {
637                let want_streaming = req
638                    .dangerous_advanced
639                    .as_ref()
640                    .and_then(|a| a.stream)
641                    .unwrap_or(false);
642                if want_streaming {
643                    let inner = spawn::execute_streaming_transform(executor, req, transform, agent_arguments).await?;
644                    Box::pin(inner)
645                } else {
646                    let value = spawn::execute_transform(executor, req, transform, agent_arguments).await?;
647                    Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
648                }
649            }
650            Request::SpawnRequestSchema(req) => {
651                let value =
652                    spawn::request_schema::execute_transform(executor, req, transform, agent_arguments).await?;
653                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
654            }
655            Request::SpawnResponseSchema(req) => {
656                let value =
657                    spawn::response_schema::execute_transform(executor, req, transform, agent_arguments).await?;
658                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
659            }
660            Request::Tags(req) => {
661                let inner = tags::execute_transform(executor, req, transform, agent_arguments).await?;
662                Box::pin(inner)
663            }
664            Request::Wait(req) => {
665                let value = wait::execute_transform(executor, req, transform, agent_arguments).await?;
666                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
667            }
668            Request::WaitRequestSchema(req) => {
669                let value =
670                    wait::request_schema::execute_transform(executor, req, transform, agent_arguments).await?;
671                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
672            }
673            Request::WaitResponseSchema(req) => {
674                let value =
675                    wait::response_schema::execute_transform(executor, req, transform, agent_arguments).await?;
676                Box::pin(crate::cli::command::StreamOnce::new(Ok(value)))
677            }
678        };
679    Ok(stream)
680}