A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::data Namespace Reference

Namespaces

namespace  serializable_internal
 

Classes

struct  ActionMessage
 The wire description of an action invocation. More...
 
struct  Chunk
 A unit of data: bytes plus optional descriptive metadata. More...
 
struct  ChunkMetadata
 Descriptive metadata attached to a a11::data::Chunk. More...
 
class  ChunkObject
 An in-process value a chunk may carry instead of its encoded bytes. More...
 
class  MsgpackReader
 Sequentially decode the fields of one A11 MessagePack wire record. More...
 
class  MsgpackWriter
 Incrementally encode the fields of one A11 wire record. More...
 
struct  NodeFragment
 One piece of a node's stream: an inline chunk or a node reference. More...
 
struct  NodeRef
 A reference to a (slice of a) logical node, in lieu of inline data. More...
 
struct  Port
 Binds an action's port name to the concrete node id serving it. More...
 
class  SerializationRegistry
 
class  TypedChunkObject
 The local fast path: a value in a chunk, encoded only if needed. More...
 
struct  TypeTag
 Empty tag carrying a type T so customization points are found by argument-dependent lookup even when T does not appear elsewhere in the call (e.g. More...
 
struct  WireMessage
 The top-level frame exchanged between two A11 endpoints. More...
 

Concepts

concept  JsonSerializable
 Whether T provides an ADL JSON representation.
 
concept  MsgpackSerializable
 Whether T can be serialized to MessagePack, either directly via A11ToMsgpackBytes / A11FromMsgpackBytes or derived from its JSON form.
 
concept  Serializable
 Whether T supports at least one representation.
 
concept  HasSerialTypeTag
 Whether T publishes a serialisation tag.
 

Typedefs

using Bytes = std::string
 Raw byte payload; an alias of std::string.
 
using ByteMap = absl::flat_hash_map< std::string, Bytes >
 String-keyed map of byte values (headers, attributes, etc.).
 

Functions

absl::StatusOr< Json > WireMessageToJsonValue (const WireMessage &message)
 
absl::StatusOr< std::string > WireMessageToJson (const WireMessage &message)
 
absl::StatusOr< WireMessage > WireMessageFromJsonValue (const Json &value)
 
absl::StatusOr< WireMessage > WireMessageFromJson (std::string_view encoded)
 
absl::StatusOr< WireMessage > WireMessageFromJsonValue (const nlohmann::json &value)
 
nlohmann::json Binary (std::string_view bytes)
 Wrap arbitrary bytes as a MessagePack binary JSON value.
 
absl::StatusOr< std::string > GetBinary (const nlohmann::json &value, std::string_view field_name)
 Read a binary JSON value, naming field_name in any validation error.
 
absl::StatusOr< std::string > PackStatus (const absl::Status &status)
 Encode a structured Abseil status for action and transport status fields.
 
absl::StatusOr< absl::Status > UnpackStatus (std::string_view bytes)
 Decode a structured status without losing A11 status details.
 
std::string_view A11SerialTag (TypeTag< ChunkMetadata >)
 
std::string_view A11SerialTag (TypeTag< Chunk >)
 
std::string_view A11SerialTag (TypeTag< NodeRef >)
 
std::string_view A11SerialTag (TypeTag< NodeFragment >)
 
std::string_view A11SerialTag (TypeTag< Port >)
 
std::string_view A11SerialTag (TypeTag< ActionMessage >)
 
std::string_view A11SerialTag (TypeTag< WireMessage >)
 
template<typename T >
requires serializable_internal::HasSerialTag<T>
std::string SerialTypeTag ()
 
template<typename T >
requires JsonSerializable<T>
absl::Status RegisterJsonSerializable (SerializationRegistry &registry)
 Registers a JSON codec (media type application/json) for T.
 
template<typename T >
requires MsgpackSerializable<T>
absl::Status RegisterMsgpackSerializable (SerializationRegistry &registry)
 Registers a MessagePack codec (media type application/x-msgpack) for T, using direct bytes when available or deriving from JSON.
 
template<typename T >
requires Serializable<T>
absl::Status RegisterSerializable (SerializationRegistry &registry, bool json=true, bool msgpack=true)
 Registers every representation T supports into registry.
 
SerializationRegistry & GlobalSerializationRegistry ()
 Returns the process-wide registry (defaults pre-installed).
 
template<typename T >
std::optional< T > TryTakeObject (const Chunk &chunk, std::string_view tag)
 Takes the value out of chunk, if it is carrying one of type T.
 
template<typename T >
Chunk MakeChunkObject (T value, std::string tag, std::string mimetype, std::shared_ptr< const SerializationRegistry > registry)
 Builds a chunk carrying value, with no bytes produced.
 
absl::Status ValidateName (std::string_view name)
 Validates an A11 identifier (node/port/action name).
 
absl::StatusOr< Chunk > MakeStatusChunk (const absl::Status &status, bool closing=false)
 Encodes status as a chunk of mimetype kStatusMimetype.
 
bool IsStatusChunk (const Chunk &chunk)
 Whether chunk carries a packed status.
 
bool IsCloseStatusChunk (const Chunk &chunk)
 Whether chunk is a status chunk marking write-half closure.
 
absl::StatusOr< absl::Status > StatusFromStatusChunk (const Chunk &chunk)
 Decodes a status previously encoded by MakeStatusChunk.
 
bool IsHalfCloseMessage (const WireMessage &message)
 Whether message is a transport half-close signal.
 
WireMessage MakeHalfCloseMessage (ByteMap trailers={})
 Builds a half-close WireMessage carrying optional trailers.
 
size_t EmptyWireMessageSize ()
 The encoded size of an empty WireMessage.
 

Variables

constexpr std::string_view kChunkMetadataTag = "a11.ChunkMetadata"
 
constexpr std::string_view kChunkTag = "a11.Chunk"
 
constexpr std::string_view kNodeRefTag = "a11.NodeRef"
 
constexpr std::string_view kNodeFragmentTag = "a11.NodeFragment"
 
constexpr std::string_view kPortTag = "a11.Port"
 
constexpr std::string_view kActionMessageTag = "a11.ActionMessage"
 
constexpr std::string_view kWireMessageTag = "a11.WireMessage"
 
constexpr std::string_view kStatusTag = "a11.Status"
 
constexpr std::string_view kTimeTag = "a11.Time"
 
constexpr std::string_view kDurationTag = "a11.Duration"
 
constexpr std::string_view kInteractionTag = "a11.sdk.Interaction"
 
constexpr std::string_view kPeerTag = "a11.sdk.Peer"
 
constexpr std::string_view kActionConfigTag = "a11.sdk.ActionConfig"
 
constexpr std::string_view kUsageMetadataTag = "a11.sdk.UsageMetadata"
 
constexpr std::string_view kInteractWithClaudeConfigTag
 
constexpr std::string_view kInteractWithClaudeCodeConfigTag
 
constexpr std::string_view kInteractWithGeminiConfigTag
 
constexpr std::string_view kInteractWithGptConfigTag
 
constexpr std::string_view kInteractWithCodexConfigTag
 
constexpr std::string_view kInteractWithOllamaConfigTag
 
constexpr std::string_view kInteractWithVllmConfigTag
 
constexpr std::string_view kInteractWithGemmaConfigTag
 
constexpr std::string_view kAudioBufferTag = "a11.sdk.AudioBuffer"
 
constexpr std::string_view kAudioInputOptionsTag
 
constexpr std::string_view kSpeechRecognizerOptionsTag
 
constexpr std::string_view kAudioDeviceInfoTag
 
constexpr std::string_view kAudioControlEventTag
 
constexpr std::string_view kAudioCaptureEventTag
 
constexpr std::string_view kTranscriptionEventTag
 
constexpr std::string_view kJsonMimetype = "application/json"
 Media type of the built-in JSON codec.
 
constexpr std::string_view kMsgpackMimetype = "application/x-msgpack"
 Media type of the built-in MessagePack codec.
 
constexpr std::string_view kTextMimetype = "text/plain"
 Media type of UTF-8 text carried as itself.
 
constexpr std::string_view kBytesMimetype = "application/octet-stream"
 Media type of opaque bytes carried as themselves.
 
constexpr std::string_view kStatusMimetype = "application/x-a11-status"
 Mimetype marking a chunk whose payload is a packed status.
 
constexpr std::string_view kCloseAttribute = "a11-close"
 Metadata attribute marking a status chunk as a closure marker.
 

Typedef Documentation

◆ ByteMap

using a11::data::ByteMap = typedef absl::flat_hash_map<std::string, Bytes>

String-keyed map of byte values (headers, attributes, etc.).

◆ Bytes

using a11::data::Bytes = typedef std::string

Raw byte payload; an alias of std::string.

Function Documentation

◆ A11SerialTag() [1/7]

std::string_view a11::data::A11SerialTag ( TypeTag< ActionMessage >  )
inline

◆ A11SerialTag() [2/7]

std::string_view a11::data::A11SerialTag ( TypeTag< Chunk >  )
inline

◆ A11SerialTag() [3/7]

std::string_view a11::data::A11SerialTag ( TypeTag< ChunkMetadata >  )
inline

◆ A11SerialTag() [4/7]

std::string_view a11::data::A11SerialTag ( TypeTag< NodeFragment >  )
inline

◆ A11SerialTag() [5/7]

std::string_view a11::data::A11SerialTag ( TypeTag< NodeRef >  )
inline

◆ A11SerialTag() [6/7]

std::string_view a11::data::A11SerialTag ( TypeTag< Port >  )
inline

◆ A11SerialTag() [7/7]

std::string_view a11::data::A11SerialTag ( TypeTag< WireMessage >  )
inline

◆ Binary()

nlohmann::json a11::data::Binary ( std::string_view  bytes)

Wrap arbitrary bytes as a MessagePack binary JSON value.

◆ EmptyWireMessageSize()

size_t a11::data::EmptyWireMessageSize ( )

The encoded size of an empty WireMessage.

Computed from the same encoder rather than hard-coded, so it stays correct if the wire format changes.

◆ GetBinary()

absl::StatusOr< std::string > a11::data::GetBinary ( const nlohmann::json &  value,
std::string_view  field_name 
)

Read a binary JSON value, naming field_name in any validation error.

◆ GlobalSerializationRegistry()

SerializationRegistry & a11::data::GlobalSerializationRegistry ( )

Returns the process-wide registry (defaults pre-installed).

◆ IsCloseStatusChunk()

bool a11::data::IsCloseStatusChunk ( const Chunk &  chunk)

Whether chunk is a status chunk marking write-half closure.

◆ IsHalfCloseMessage()

bool a11::data::IsHalfCloseMessage ( const WireMessage &  message)

Whether message is a transport half-close signal.

◆ IsStatusChunk()

bool a11::data::IsStatusChunk ( const Chunk &  chunk)

Whether chunk carries a packed status.

◆ MakeChunkObject()

template<typename T >
Chunk a11::data::MakeChunkObject ( T  value,
std::string  tag,
std::string  mimetype,
std::shared_ptr< const SerializationRegistry >  registry 
)

Builds a chunk carrying value, with no bytes produced.

Parameters
valueThe value, which must not change afterwards.
tagIts serialisation tag, from SerialTypeTag<T>().
mimetypeThe media type it would encode as; the chunk reports this as its mimetype, so a consumer selecting on media type sees the same thing it would have seen had the bytes been there.
registryUsed only if somebody asks for the bytes after all.

◆ MakeHalfCloseMessage()

WireMessage a11::data::MakeHalfCloseMessage ( ByteMap  trailers)

Builds a half-close WireMessage carrying optional trailers.

◆ MakeStatusChunk()

absl::StatusOr< Chunk > a11::data::MakeStatusChunk ( const absl::Status &  status,
bool  closing = false 
)

Encodes status as a chunk of mimetype kStatusMimetype.

Parameters
statusThe status to pack.
closingWhether to mark the chunk as a closure marker (kCloseAttribute), meaning the producer closed the node's write half.

◆ PackStatus()

absl::StatusOr< std::string > a11::data::PackStatus ( const absl::Status &  status)

Encode a structured Abseil status for action and transport status fields.

◆ RegisterJsonSerializable()

template<typename T >
requires JsonSerializable<T>
absl::Status a11::data::RegisterJsonSerializable ( SerializationRegistry &  registry)

Registers a JSON codec (media type application/json) for T.

Returns
OK, or AlreadyExists when a JSON codec is already registered.

◆ RegisterMsgpackSerializable()

template<typename T >
requires MsgpackSerializable<T>
absl::Status a11::data::RegisterMsgpackSerializable ( SerializationRegistry &  registry)

Registers a MessagePack codec (media type application/x-msgpack) for T, using direct bytes when available or deriving from JSON.

Returns
OK, or AlreadyExists when a MessagePack codec is already registered.

◆ RegisterSerializable()

template<typename T >
requires Serializable<T>
absl::Status a11::data::RegisterSerializable ( SerializationRegistry &  registry,
bool  json = true,
bool  msgpack = true 
)

Registers every representation T supports into registry.

JSON is registered first (so it is the default when no mimetype is given) when available, followed by MessagePack. Passing json / msgpack as false skips that representation even when the type supports it.

Returns
OK on success, or the first registration error.

◆ SerialTypeTag()

template<typename T >
requires serializable_internal::HasSerialTag<T>
std::string a11::data::SerialTypeTag ( )

◆ StatusFromStatusChunk()

absl::StatusOr< absl::Status > a11::data::StatusFromStatusChunk ( const Chunk &  chunk)

Decodes a status previously encoded by MakeStatusChunk.

◆ TryTakeObject()

template<typename T >
std::optional< T > a11::data::TryTakeObject ( const Chunk &  chunk,
std::string_view  tag 
)

Takes the value out of chunk, if it is carrying one of type T.

Returns nullopt when the chunk holds bytes instead, or holds a value of some other type. The value is copied to each reader, allowing multiple consumers to read the in-process object directly without repeated serialization.

◆ UnpackStatus()

absl::StatusOr< absl::Status > a11::data::UnpackStatus ( std::string_view  bytes)

Decode a structured status without losing A11 status details.

◆ ValidateName()

absl::Status a11::data::ValidateName ( std::string_view  name)

Validates an A11 identifier (node/port/action name).

Parameters
nameCandidate name.
Returns
OK when name matches A11's identifier grammar, else an error.

◆ WireMessageFromJson()

absl::StatusOr< WireMessage > a11::data::WireMessageFromJson ( std::string_view  encoded)

◆ WireMessageFromJsonValue() [1/2]

absl::StatusOr< WireMessage > a11::data::WireMessageFromJsonValue ( const Json &  value)

◆ WireMessageFromJsonValue() [2/2]

absl::StatusOr< WireMessage > a11::data::WireMessageFromJsonValue ( const nlohmann::json &  value)

◆ WireMessageToJson()

absl::StatusOr< std::string > a11::data::WireMessageToJson ( const WireMessage &  message)

◆ WireMessageToJsonValue()

absl::StatusOr< nlohmann::json > a11::data::WireMessageToJsonValue ( const WireMessage &  message)

Variable Documentation

◆ kActionConfigTag

constexpr std::string_view a11::data::kActionConfigTag = "a11.sdk.ActionConfig"
inlineconstexpr

◆ kActionMessageTag

constexpr std::string_view a11::data::kActionMessageTag = "a11.ActionMessage"
inlineconstexpr

◆ kAudioBufferTag

constexpr std::string_view a11::data::kAudioBufferTag = "a11.sdk.AudioBuffer"
inlineconstexpr

◆ kAudioCaptureEventTag

constexpr std::string_view a11::data::kAudioCaptureEventTag
inlineconstexpr
Initial value:
=
"a11.sdk.AudioCaptureEvent"

◆ kAudioControlEventTag

constexpr std::string_view a11::data::kAudioControlEventTag
inlineconstexpr
Initial value:
=
"a11.sdk.AudioControlEvent"

◆ kAudioDeviceInfoTag

constexpr std::string_view a11::data::kAudioDeviceInfoTag
inlineconstexpr
Initial value:
=
"a11.sdk.AudioDeviceInfo"

◆ kAudioInputOptionsTag

constexpr std::string_view a11::data::kAudioInputOptionsTag
inlineconstexpr
Initial value:
=
"a11.sdk.AudioInputOptions"

◆ kBytesMimetype

constexpr std::string_view a11::data::kBytesMimetype = "application/octet-stream"
inlineconstexpr

Media type of opaque bytes carried as themselves.

The default for a std::string, and for every language's byte-array type. Neither this nor kTextMimetype takes a ;type= parameter: the media type is the whole description, and the payload is the value with no framing – which is the point, since the JSON representation of bytes is base64 inside a quoted string, a third larger than the bytes themselves.

◆ kChunkMetadataTag

constexpr std::string_view a11::data::kChunkMetadataTag = "a11.ChunkMetadata"
inlineconstexpr

◆ kChunkTag

constexpr std::string_view a11::data::kChunkTag = "a11.Chunk"
inlineconstexpr

◆ kCloseAttribute

constexpr std::string_view a11::data::kCloseAttribute = "a11-close"
inlineconstexpr

Metadata attribute marking a status chunk as a closure marker.

A plain status chunk carries a value (an action's outcome) or a failure to apply to a node. One carrying this attribute instead reports that the producer has drained the node and closed its write half with that status; it holds no application value and is never stored.

◆ kDurationTag

constexpr std::string_view a11::data::kDurationTag = "a11.Duration"
inlineconstexpr

◆ kInteractionTag

constexpr std::string_view a11::data::kInteractionTag = "a11.sdk.Interaction"
inlineconstexpr

◆ kInteractWithClaudeCodeConfigTag

constexpr std::string_view a11::data::kInteractWithClaudeCodeConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithClaudeCodeConfig"

◆ kInteractWithClaudeConfigTag

constexpr std::string_view a11::data::kInteractWithClaudeConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithClaudeConfig"

◆ kInteractWithCodexConfigTag

constexpr std::string_view a11::data::kInteractWithCodexConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithCodexConfig"

◆ kInteractWithGeminiConfigTag

constexpr std::string_view a11::data::kInteractWithGeminiConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithGeminiConfig"

◆ kInteractWithGemmaConfigTag

constexpr std::string_view a11::data::kInteractWithGemmaConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithGemmaConfig"

◆ kInteractWithGptConfigTag

constexpr std::string_view a11::data::kInteractWithGptConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithGptConfig"

◆ kInteractWithOllamaConfigTag

constexpr std::string_view a11::data::kInteractWithOllamaConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithOllamaConfig"

◆ kInteractWithVllmConfigTag

constexpr std::string_view a11::data::kInteractWithVllmConfigTag
inlineconstexpr
Initial value:
=
"a11.sdk.InteractWithVllmConfig"

◆ kJsonMimetype

constexpr std::string_view a11::data::kJsonMimetype = "application/json"
inlineconstexpr

Media type of the built-in JSON codec.

◆ kMsgpackMimetype

constexpr std::string_view a11::data::kMsgpackMimetype = "application/x-msgpack"
inlineconstexpr

Media type of the built-in MessagePack codec.

◆ kNodeFragmentTag

constexpr std::string_view a11::data::kNodeFragmentTag = "a11.NodeFragment"
inlineconstexpr

◆ kNodeRefTag

constexpr std::string_view a11::data::kNodeRefTag = "a11.NodeRef"
inlineconstexpr

◆ kPeerTag

constexpr std::string_view a11::data::kPeerTag = "a11.sdk.Peer"
inlineconstexpr

◆ kPortTag

constexpr std::string_view a11::data::kPortTag = "a11.Port"
inlineconstexpr

◆ kSpeechRecognizerOptionsTag

constexpr std::string_view a11::data::kSpeechRecognizerOptionsTag
inlineconstexpr
Initial value:
=
"a11.sdk.SpeechRecognizerOptions"

◆ kStatusMimetype

constexpr std::string_view a11::data::kStatusMimetype = "application/x-a11-status"
inlineconstexpr

Mimetype marking a chunk whose payload is a packed status.

◆ kStatusTag

constexpr std::string_view a11::data::kStatusTag = "a11.Status"
inlineconstexpr

◆ kTextMimetype

constexpr std::string_view a11::data::kTextMimetype = "text/plain"
inlineconstexpr

Media type of UTF-8 text carried as itself.

The default for strings in the languages that distinguish text from bytes. C++ does not – a std::string is a sequence of bytes – so here it is available on request and kBytesMimetype is the default; see RegisterDefaults.

◆ kTimeTag

constexpr std::string_view a11::data::kTimeTag = "a11.Time"
inlineconstexpr

◆ kTranscriptionEventTag

constexpr std::string_view a11::data::kTranscriptionEventTag
inlineconstexpr
Initial value:
=
"a11.sdk.TranscriptionEvent"

◆ kUsageMetadataTag

constexpr std::string_view a11::data::kUsageMetadataTag = "a11.sdk.UsageMetadata"
inlineconstexpr

◆ kWireMessageTag

constexpr std::string_view a11::data::kWireMessageTag = "a11.WireMessage"
inlineconstexpr