a2a_protocol_types/generated/events.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Tom F. <[email protected]> (https://github.com/tomtom215)
3// @generated by tools/a2a-codegen from proto/a2a_v1/a2a.proto,
4// sha256 e195bf96ab630c69797851970203e1b2b6b19528f2e9803b7d904b91a5104016.
5// Included by the `events` module. Do not edit: change the proto or
6// crates/a2a-protocol-types/codegen.toml and regenerate (ADR 0016).
7
8/// An event sent by the agent to notify the client of a change in a task's status.
9///
10/// In v1.0 this wraps [`TaskStatus`](crate::task::TaskStatus) directly instead
11/// of separate `state`/`message` fields, and the `final` field is gone.
12#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
13#[serde(rename_all = "camelCase")]
14#[non_exhaustive]
15pub struct TaskStatusUpdateEvent {
16 /// The ID of the task that has changed.
17 #[serde(alias = "task_id")]
18 pub task_id: crate::task::TaskId,
19 /// The ID of the context that the task belongs to.
20 #[serde(alias = "context_id")]
21 pub context_id: crate::task::ContextId,
22 /// The new status of the task.
23 pub status: crate::task::TaskStatus,
24 /// Optional. Metadata associated with the task update.
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub metadata: Option<serde_json::Value>,
27}
28
29/// A task delta where an artifact has been generated.
30///
31/// The wire `kind` field (`"artifact-update"`) is injected by the enclosing
32/// [`StreamResponse`] discriminated union.
33#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
34#[serde(rename_all = "camelCase")]
35#[non_exhaustive]
36pub struct TaskArtifactUpdateEvent {
37 /// The ID of the task for this artifact.
38 #[serde(alias = "task_id")]
39 pub task_id: crate::task::TaskId,
40 /// The ID of the context that this task belongs to.
41 #[serde(alias = "context_id")]
42 pub context_id: crate::task::ContextId,
43 /// The artifact that was generated or updated.
44 pub artifact: crate::artifact::Artifact,
45 /// If true, the content of this artifact should be appended to a previously
46 /// sent artifact with the same ID.
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub append: Option<bool>,
49 /// If true, this is the final chunk of the artifact.
50 #[serde(alias = "last_chunk", skip_serializing_if = "Option::is_none")]
51 pub last_chunk: Option<bool>,
52 /// Optional. Metadata associated with the artifact update.
53 #[serde(skip_serializing_if = "Option::is_none")]
54 pub metadata: Option<serde_json::Value>,
55}
56
57/// A wrapper object used in streaming operations to encapsulate different types of response data.
58///
59/// Externally tagged: serialized as a single-key object (`{"task": …}`,
60/// `{"statusUpdate": …}`, …) whose `camelCase` key names the variant. This
61/// matches the `ProtoJSON` encoding of the `StreamResponse.payload` `oneof` on
62/// the wire — it is **not** an untagged union, and must not be "corrected" to
63/// one without breaking wire compatibility.
64#[derive(Debug, Clone, serde::Serialize)]
65#[serde(rename_all = "camelCase")]
66#[non_exhaustive]
67pub enum StreamResponse {
68 /// A Task object containing the current state of the task.
69 Task(crate::task::Task),
70 /// A Message object containing a message from the agent.
71 Message(crate::message::Message),
72 /// An event indicating a task status update.
73 StatusUpdate(crate::events::TaskStatusUpdateEvent),
74 /// An event indicating a task artifact update.
75 ArtifactUpdate(crate::events::TaskArtifactUpdateEvent),
76}
77
78crate::oneof::oneof_deserialize!(
79 StreamResponse,
80 [
81 Task(crate::task::Task) = "task",
82 Message(crate::message::Message) = "message",
83 StatusUpdate(crate::events::TaskStatusUpdateEvent) = "statusUpdate" | "status_update",
84 ArtifactUpdate(crate::events::TaskArtifactUpdateEvent) =
85 "artifactUpdate" | "artifact_update",
86 ]
87);