A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
stream_reference.h
Go to the documentation of this file.
1// Copyright 2026 The A11 Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef A11_ACTIONS_STREAM_REFERENCE_H_
16#define A11_ACTIONS_STREAM_REFERENCE_H_
17
18#include <string>
19#include <string_view>
20
21#include <absl/status/status.h>
22#include <absl/status/statusor.h>
23
24#include "a11/data/types.h"
25
26namespace a11::actions {
27
29inline constexpr std::string_view kStreamReferenceAttribute =
30 "a11-stream-reference";
31
34 std::string producer_id{};
35 std::string parent_producer_id{};
37 std::string purpose{};
39
41 absl::Status Validate() const;
42
43 friend bool operator==(const StreamReference&,
44 const StreamReference&) = default;
45};
46
48absl::StatusOr<data::Chunk> StreamReferenceToChunk(
49 const StreamReference& reference);
50
52absl::StatusOr<StreamReference> StreamReferenceFromChunk(data::Chunk chunk);
53
54} // namespace a11::actions
55
56#endif // A11_ACTIONS_STREAM_REFERENCE_H_
Definition action.cc:66
absl::StatusOr< data::Chunk > StreamReferenceToChunk(const StreamReference &reference)
Encode a reference and its source as a plain JSON object chunk.
Definition stream_reference.cc:39
absl::StatusOr< StreamReference > StreamReferenceFromChunk(data::Chunk chunk)
Decode a reference, preserving source metadata as an opaque JSON chunk.
Definition stream_reference.cc:73
constexpr std::string_view kStreamReferenceAttribute
Metadata identifying a reference chunk on a scope's reserved output.
Definition stream_reference.h:29
Locate an auxiliary producer independently of its stream payload.
Definition stream_reference.h:33
data::NodeRef node
Node readable in the receiving scope.
Definition stream_reference.h:36
data::Chunk source
Opaque source metadata as a JSON object.
Definition stream_reference.h:38
absl::Status Validate() const
Validate the identifiers independently of source serialization.
Definition stream_reference.cc:31
std::string producer_id
Stable logical producer identity.
Definition stream_reference.h:34
std::string parent_producer_id
Enclosing producer, or empty.
Definition stream_reference.h:35
std::string purpose
Payload protocol, such as llm_usage.
Definition stream_reference.h:37
friend bool operator==(const StreamReference &, const StreamReference &)=default
A unit of data: bytes plus optional descriptive metadata.
Definition types.h:173
A reference to a (slice of a) logical node, in lieu of inline data.
Definition types.h:311
A11's core wire value types: chunks, node fragments and messages.