objectiveai_sdk/cli/plugins/command.rs
1//! Wire shape for a plugin-emitted command-execution request.
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6/// Plugin requests the host execute a command. The host streams
7/// every emission back into the plugin's stdin; plugins demultiplex
8/// concurrent in-flight commands by matching against the echoed
9/// `id` on each response line.
10///
11/// The constant `type:"command"` discriminator disambiguates this
12/// variant from the rest of the untagged [`super::Output`] catch-all,
13/// mirroring the `type:"error"` discriminator on
14/// [`crate::cli::Error`].
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
16#[schemars(rename = "cli.plugins.Command")]
17pub struct Command {
18 pub r#type: CommandType,
19 /// Plugin-minted correlation id. Echoed by the host on every
20 /// response line so the plugin can demux concurrent calls.
21 pub id: String,
22 pub command: String,
23}
24
25/// Single-variant discriminator for [`Command`]'s `type` field.
26/// Always `"command"` on the wire.
27#[derive(
28 Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema,
29)]
30#[serde(rename_all = "snake_case")]
31#[schemars(rename = "cli.plugins.CommandType")]
32pub enum CommandType {
33 Command,
34}