NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
types.h File Reference

Core data types for the Agent-to-Agent (A2A) protocol. More...

#include <neograph/api.h>
#include <neograph/json.h>
#include <optional>
#include <string>
#include <vector>
Include dependency graph for types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  neograph::a2a::AgentCard
 Subset of AgentCard required to interact (spec §5.5). More...
 
struct  neograph::a2a::AgentInterface
 One protocol binding + version + URL an agent exposes (1.0 AgentInterface; 0.3 cards contribute additionalInterfaces entries). More...
 
struct  neograph::a2a::AgentSkill
 One capability the agent advertises (1.0 AgentSkill). More...
 
struct  neograph::a2a::Artifact
 Generated output (spec §6.7). More...
 
struct  neograph::a2a::Message
 A single conversational turn (spec §6.4). More...
 
struct  neograph::a2a::MessageSendConfiguration
 Optional knobs for message/send (spec §7.2). More...
 
struct  neograph::a2a::MessageSendParams
 Params object for message/send and message/stream. More...
 
struct  neograph::a2a::Part
 One content fragment of a Message or Artifact. More...
 
struct  neograph::a2a::StreamEvent
 Tagged union over the two streaming event types + the terminal Task message. More...
 
struct  neograph::a2a::Task
 A unit of work tracked by the agent (spec §6.1). More...
 
struct  neograph::a2a::TaskStatus
 Status snapshot of a running Task (spec §6.5). More...
 
struct  neograph::a2a::TaskStatusUpdateEvent
 SSE event emitted by message/stream and tasks/resubscribe while a Task is running. More...
 

Enumerations

enum class  neograph::a2a::Role
 Message role (spec §6.4).
 
enum class  neograph::a2a::TaskState
 TaskState — kebab-case strings on the 0.3 wire, TASK_STATE_* on 1.0.
 
enum class  neograph::a2a::WireDialect
 A2A wire dialect — the JSON encoding of the data model. More...
 

Functions

NEOGRAPH_API StreamEvent neograph::a2a::parse_stream_event (const json &j)
 Parse a single SSE data: {...} JSON object into the right variant.
 
NEOGRAPH_API Role neograph::a2a::role_from_string (std::string_view s)
 Accepts both user/agent (0.3) and ROLE_USER/ROLE_AGENT (1.0).
 
NEOGRAPH_API Task neograph::a2a::task_from_result (const json &result)
 Coerce a SendMessage / message/send / GetTask / CancelTask result into a Task.
 
NEOGRAPH_API TaskState neograph::a2a::task_state_from_string (std::string_view s)
 Accepts both the kebab-case (0.3) and TASK_STATE_* (1.0) spellings.
 
NEOGRAPH_API void neograph::a2a::to_json (json &j, const AgentCard &c)
 The card a 0.3 reader receives: the 0.3 fields plus the 1.0 supportedInterfaces when the card lists them.
 
NEOGRAPH_API void neograph::a2a::to_json (json &j, const AgentCard &c, WireDialect dialect)
 One card per protocol version.
 

Detailed Description

Core data types for the Agent-to-Agent (A2A) protocol.

Mirrors the canonical proto / JSON schema at https://github.com/a2aproject/A2A (specification/a2a.proto).

Only the surface needed by the client is modelled here. The wire format is JSON; structs round-trip through nlohmann::json via to_json/from_json ADL hooks defined in src/a2a/types.cpp.

Definition in file types.h.

Enumeration Type Documentation

◆ WireDialect

enum class neograph::a2a::WireDialect
strong

A2A wire dialect — the JSON encoding of the data model.

  • V0_3: A2A 0.3 JSON Schema form. kind discriminators on Message / Task / Part / stream events, lower-case role (user, agent) and kebab-case task states (input-required), slash-form JSON-RPC methods (message/send), FilePart.file = {bytes|uri, mimeType, name}.
  • V1_0: A2A 1.0 protobuf ProtoJSON form (lf.a2a.v1). No kind discriminators, flat Parts ({"text"} / {"raw"|"url", "filename", "mediaType"} / {"data"}), ROLE_USER / TASK_STATE_WORKING enums, PascalCase methods (SendMessage) and {"task"} / {"message"} / {"statusUpdate"} / {"artifactUpdate"} result wrappers.

Serialisation is dialect-selected (to_json(j, value, dialect)); the two-argument to_json overloads emit V0_3. Parsing (from_json) is dialect-tolerant and accepts either encoding.

Definition at line 40 of file types.h.

Function Documentation

◆ parse_stream_event()

NEOGRAPH_API StreamEvent neograph::a2a::parse_stream_event ( const json &  j)

Parse a single SSE data: {...} JSON object into the right variant.

0.3: discriminator kind = "status-update" | "artifact-update" | "task" | "message". 1.0: the single populated key of StreamResponse (statusUpdate | artifactUpdate | task | message). A Message payload is coerced into a Task (see task_from_result). Anything else falls back to Task.

1.0 status updates carry no final flag; it is derived from the state (terminal or interrupted => final), matching the spec's stream-close rule.

References neograph::a2a::parse_stream_event().

Referenced by neograph::a2a::parse_stream_event().

◆ task_from_result()

NEOGRAPH_API Task neograph::a2a::task_from_result ( const json &  result)

Coerce a SendMessage / message/send / GetTask / CancelTask result into a Task.

Accepts the 1.0 wrappers ({"task"} / {"message"}), the 0.3 kind-discriminated objects, and a bare 1.0 Task (object with id + status). A Message becomes a Completed Task carrying it as status.message and history. Null yields a Failed Task; anything unrecognised yields an Unknown Task with the payload in metadata.

References neograph::a2a::task_from_result().

Referenced by neograph::a2a::task_from_result().

◆ to_json() [1/2]

NEOGRAPH_API void neograph::a2a::to_json ( json &  j,
const AgentCard &  c 
)

The card a 0.3 reader receives: the 0.3 fields plus the 1.0 supportedInterfaces when the card lists them.

A card with raw set is emitted verbatim.

◆ to_json() [2/2]

NEOGRAPH_API void neograph::a2a::to_json ( json &  j,
const AgentCard &  c,
WireDialect  dialect 
)

One card per protocol version.

V1_0 emits a pure 1.0 AgentCard (no 0.3 fields, non-empty skill tags, capabilities.extendedAgentCard); V0_3 is the two-argument form. A card with raw set is emitted verbatim.