Skip to main content

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    /// The command to run, as an already-tokenized argv vector — one
23    /// element per argument. Carried structured (NOT a space-joined
24    /// string) so an argument whose value contains whitespace (e.g.
25    /// `["agents", "message", "leaf", "--simple", "a b c"]`) keeps its
26    /// boundary intact; the host dispatches it verbatim without
27    /// re-tokenizing.
28    pub command: Vec<String>,
29}
30
31/// Single-variant discriminator for [`Command`]'s `type` field.
32/// Always `"command"` on the wire.
33#[derive(
34    Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema,
35)]
36#[serde(rename_all = "snake_case")]
37#[schemars(rename = "cli.plugins.CommandType")]
38pub enum CommandType {
39    Command,
40}