21namespace neograph::a2a {
23using json = neograph::json;
55NEOGRAPH_API std::string task_state_to_string(TaskState s);
56NEOGRAPH_API std::string task_state_to_string(TaskState s, WireDialect dialect);
61enum class Role { User, Agent };
63NEOGRAPH_API std::string role_to_string(Role r);
64NEOGRAPH_API std::string role_to_string(Role r, WireDialect dialect);
95 std::vector<std::string> reference_task_ids;
96 std::vector<std::string> extensions;
98 std::string kind =
"message";
103 std::string artifact_id;
104 std::vector<Part> parts;
105 std::optional<std::string> name;
106 std::optional<std::string> description;
113 std::optional<Message> message;
122 std::vector<Artifact> artifacts;
123 std::vector<Message> history;
125 std::string kind =
"task";
130 std::vector<std::string> accepted_output_modes;
131 std::optional<bool> blocking;
132 std::optional<int> history_length;
139 std::optional<MessageSendConfiguration> configuration;
151 std::string context_id;
155 std::string kind =
"status-update";
158struct NEOGRAPH_API TaskArtifactUpdateEvent {
160 std::string context_id;
163 bool last_chunk =
false;
165 std::string kind =
"artifact-update";
172 enum class Type { StatusUpdate, ArtifactUpdate,
Task };
173 Type type = Type::Task;
174 std::optional<TaskStatusUpdateEvent> status_update;
175 std::optional<TaskArtifactUpdateEvent> artifact_update;
176 std::optional<a2a::Task> task;
178 bool is_final()
const noexcept {
179 if (type == Type::StatusUpdate && status_update)
return status_update->final;
182 if (type == Type::Task) {
183 if (!task)
return true;
184 return task->status.state != TaskState::Submitted
185 && task->status.state != TaskState::Working;
206 std::string description;
207 std::vector<std::string> tags;
208 std::vector<std::string> examples;
209 std::vector<std::string> input_modes;
210 std::vector<std::string> output_modes;
224 std::string description;
236 std::string preferred_transport =
"JSONRPC";
237 std::vector<std::string> default_input_modes;
238 std::vector<std::string> default_output_modes;
243 bool streaming =
true;
246 bool push_notifications =
false;
249 bool extended_card =
false;
250 bool supports_authenticated_extended =
false;
296NEOGRAPH_API
void to_json(json& j,
const TaskArtifactUpdateEvent& e,
WireDialect dialect);
298NEOGRAPH_API
void to_json(json& j,
const Part& p);
299NEOGRAPH_API
void from_json(
const json& j,
Part& p);
301NEOGRAPH_API
void to_json(json& j,
const Message& m);
302NEOGRAPH_API
void from_json(
const json& j,
Message& m);
304NEOGRAPH_API
void to_json(json& j,
const Artifact& a);
305NEOGRAPH_API
void from_json(
const json& j,
Artifact& a);
307NEOGRAPH_API
void to_json(json& j,
const TaskStatus& s);
308NEOGRAPH_API
void from_json(
const json& j,
TaskStatus& s);
310NEOGRAPH_API
void to_json(json& j,
const Task& t);
311NEOGRAPH_API
void from_json(
const json& j,
Task& t);
327NEOGRAPH_API
void from_json(
const json& j,
AgentCard& c);
332NEOGRAPH_API
void to_json(json& j,
const TaskArtifactUpdateEvent& e);
333NEOGRAPH_API
void from_json(
const json& j, TaskArtifactUpdateEvent& e);
NEOGRAPH_API Role role_from_string(std::string_view s)
Accepts both user/agent (0.3) and ROLE_USER/ROLE_AGENT (1.0).
Role
Message role (spec §6.4).
NEOGRAPH_API TaskState task_state_from_string(std::string_view s)
Accepts both the kebab-case (0.3) and TASK_STATE_* (1.0) spellings.
NEOGRAPH_API Task task_from_result(const json &result)
Coerce a SendMessage / message/send / GetTask / CancelTask result into a Task.
NEOGRAPH_API StreamEvent parse_stream_event(const json &j)
Parse a single SSE data: {...} JSON object into the right variant.
WireDialect
A2A wire dialect — the JSON encoding of the data model.
TaskState
TaskState — kebab-case strings on the 0.3 wire, TASK_STATE_* on 1.0.
NEOGRAPH_API export/import macro for shared-library builds.
Thin C++ RAII wrapper around yyjson with nlohmann-compatible API.
Subset of AgentCard required to interact (spec §5.5).
std::string url
Public endpoint of the JSON-RPC binding.
json security_requirements
1.0 securityRequirements: an array of {"schemes": {"<name>": {"list": [<scope>...]}}}.
json security_schemes
1.0 securitySchemes: an object mapping a scheme name to a 1.0 SecurityScheme in ProtoJSON form,...
std::string protocol_version
The 0.3 card's protocolVersion; A2AServer always serves "0.3.0" in the 0.3 card and 1....
std::vector< AgentSkill > skills
Full skill objects (parsed, or set by a server).
std::vector< AgentInterface > supported_interfaces
1.0 supportedInterfaces in card order (preferred first).
json extensions
capabilities.extensions (both versions): an array of AgentExtension objects {uri, description,...
std::vector< std::string > skill_names
Parsed skill ids.
json raw
Full original document as received. Preserves fields we don't yet model.
One protocol binding + version + URL an agent exposes (1.0 AgentInterface; 0.3 cards contribute addit...
std::string protocol_binding
"JSONRPC" | "GRPC" | "HTTP+JSON" | custom
std::string protocol_version
"Major.Minor", e.g. "1.0" / "0.3"
std::string tenant
optional routing id (1.0 only)
One capability the agent advertises (1.0 AgentSkill).
Generated output (spec §6.7).
Optional knobs for message/send (spec §7.2).
Params object for message/send and message/stream.
A single conversational turn (spec §6.4).
std::vector< Part > parts
REQUIRED, ≥1 element.
std::string message_id
client-generated UUID, REQUIRED
std::optional< std::string > context_id
grouping id
json metadata
optional bag
std::optional< std::string > task_id
server task id (omit on first send)
One content fragment of a Message or Artifact.
std::string media_type
1.0 Part.media_type for text/data parts (e.g.
json metadata
optional extension bag
std::string kind
"text" | "file" | "data"
static Part text_part(std::string s)
Convenience: TextPart of given content.
json file
populated when kind == "file".
json data
populated when kind == "data" (arbitrary JSON)
std::string text
populated when kind == "text"
Tagged union over the two streaming event types + the terminal Task message.
SSE event emitted by message/stream and tasks/resubscribe while a Task is running.
Status snapshot of a running Task (spec §6.5).
std::optional< std::string > timestamp
RFC3339 UTC.
A unit of work tracked by the agent (spec §6.1).
std::string id
server-generated, REQUIRED
std::string context_id
server-generated grouping id