objectiveai_sdk/cli/output/notification/notification.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// Wrapper that nests the notification payload one level deeper under a
5/// `value` field. Required because [`super::super::Output`] uses
6/// `#[serde(tag = "type")]` — if we let `T` flatten directly into the
7/// outer JSON object, any `T` carrying its own `"type"` field (e.g. a
8/// JSON Schema document with `"type": "object"`) would collide with
9/// the discriminator.
10///
11/// `agent_id` is stamped at emit time by [`super::super::Handle`] when
12/// its `agent_id` field is set; producers building a `Notification`
13/// inline almost always leave the field `None` and let the handle
14/// fill it. Serde-skipped when `None`.
15///
16/// Wire (in combination with `Output::Notification`):
17/// `{"type":"notification","value":<T>,"agent_id":"<id>"?}`.
18#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
19#[schemars(rename = "cli.output.notification.Notification.{T}")]
20pub struct Notification<T> {
21 pub value: T,
22 #[serde(default, skip_serializing_if = "Option::is_none")]
23 #[schemars(extend("omitempty" = true))]
24 pub agent_id: Option<String>,
25}