Skip to main content

systemprompt_models/events/payloads/
a2a.rs

1//! A2A event payload shapes.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8use systemprompt_identifiers::{ArtifactId, ContextId, MessageId, TaskId};
9
10use crate::a2a::{Artifact, TaskState};
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct TaskSubmittedPayload {
15    pub task_id: TaskId,
16    pub context_id: ContextId,
17    pub agent_name: String,
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub input: Option<Value>,
20}
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
23#[serde(rename_all = "camelCase")]
24pub struct TaskStatusUpdatePayload {
25    pub task_id: TaskId,
26    pub context_id: ContextId,
27    pub state: TaskState,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub message: Option<String>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(rename_all = "camelCase")]
34pub struct ArtifactCreatedPayload {
35    pub task_id: TaskId,
36    pub context_id: ContextId,
37    pub artifact: Artifact,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(rename_all = "camelCase")]
42pub struct ArtifactUpdatedPayload {
43    pub task_id: TaskId,
44    pub context_id: ContextId,
45    pub artifact_id: ArtifactId,
46    pub append: bool,
47    pub last_chunk: bool,
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub content: Option<Value>,
50}
51
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(rename_all = "camelCase")]
54pub struct AgentMessagePayload {
55    pub task_id: TaskId,
56    pub context_id: ContextId,
57    pub message_id: MessageId,
58    pub content: String,
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(rename_all = "camelCase")]
63pub struct InputRequiredPayload {
64    pub task_id: TaskId,
65    pub context_id: ContextId,
66    pub prompt: String,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(rename_all = "camelCase")]
71pub struct AuthRequiredPayload {
72    pub task_id: TaskId,
73    pub context_id: ContextId,
74    pub auth_url: String,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct JsonRpcResponsePayload {
80    pub id: Value,
81    pub result: Value,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(rename_all = "camelCase")]
86pub struct JsonRpcErrorPayload {
87    pub id: Value,
88    pub code: i32,
89    pub message: String,
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub data: Option<Value>,
92}