objectiveai_sdk/cli/plugins/output.rs
1//! Wire format for the plugin output protocol.
2//!
3//! Plugins emit one [`PluginOutput`] JSON object per line on their
4//! stdout. The host parses each line and dispatches per variant:
5//! `error` is displayed, `notification` is forwarded to whatever
6//! consumer the host has wired up, `command` is a request for the
7//! host to perform some action and (potentially) reply.
8
9use schemars::JsonSchema;
10use serde::{Deserialize, Serialize};
11
12pub use crate::cli::output::{Error, Level};
13
14/// One line of plugin output.
15///
16/// Identical in shape to [`crate::cli::output::Output`] except:
17///
18/// - [`PluginOutput::Notification`] is a plain `serde_json::Value`
19/// (no generic `T`, no nesting wrapper). The plugin is responsible
20/// for not including `"type"` as a top-level key in the value,
21/// which would collide with the discriminator.
22/// - No `Begin`/`End` markers — plugins don't bracket their stream.
23/// - Adds [`PluginOutput::Command`] — a request the host should act
24/// on, identified by a `command` string.
25#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
26#[serde(tag = "type", rename_all = "snake_case")]
27#[schemars(rename = "cli.plugins.PluginOutput")]
28pub enum PluginOutput {
29 #[schemars(title = "Error")]
30 Error(Error),
31 #[schemars(title = "Notification")]
32 Notification(serde_json::Value),
33 #[schemars(title = "Command")]
34 Command { command: String },
35}