objectiveai_cli_sdk/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 serde::{Deserialize, Serialize};
10
11pub use crate::output::{Error, Level};
12
13/// One line of plugin output.
14///
15/// Identical in shape to [`crate::output::Output`] except:
16///
17/// - [`PluginOutput::Notification`] is a plain `serde_json::Value`
18/// (no generic `T`, no nesting wrapper). The plugin is responsible
19/// for not including `"type"` as a top-level key in the value,
20/// which would collide with the discriminator.
21/// - No `Begin`/`End` markers — plugins don't bracket their stream.
22/// - Adds [`PluginOutput::Command`] — a request the host should act
23/// on, identified by a `command` string.
24#[derive(Serialize, Deserialize, Debug, Clone)]
25#[serde(tag = "type", rename_all = "snake_case")]
26pub enum PluginOutput {
27 Error(Error),
28 Notification(serde_json::Value),
29 Command { command: String },
30}