A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
interpreter.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 The A11 Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
26#ifndef A11_FLOW_INTERPRETER_INTERPRETER_H_
27#define A11_FLOW_INTERPRETER_INTERPRETER_H_
28
29#include <memory>
30#include <optional>
31#include <string>
32#include <vector>
33
34#include <absl/status/status.h>
35#include <absl/status/statusor.h>
36#include <absl/time/time.h>
37
39#include "a11/flow/diagnostic.h"
40#include "a11/flow/limits.h"
41#include "a11/flow/runtime.h"
42#include "a11/flow/values.h"
43#include "a11/net/wire_stream.h"
44#include "sdk/flow/actions/policy.h"
45
46namespace a11::flow::interpreter {
47
49struct Source {
50 std::string text;
51 std::string name;
52 std::vector<std::string> source_roots = {};
54 bool single_item_slots = true;
55};
56
58struct RunOptions {
64 std::vector<std::string> arguments;
65
67 sdk::flow::CapabilitiesPtr capabilities;
68
70 std::shared_ptr<actions::ActionRegistry> registry;
71
73 std::optional<absl::Duration> timeout;
74
81 bool standard_streams = true;
82
89 std::shared_ptr<HostBridge> bridge;
90
103 std::shared_ptr<net::WireStream> dispatch_stream;
104
112 std::shared_ptr<service::Session> session;
113
116};
117
122 int exit_code = 0;
124 std::vector<Diagnostic> diagnostics;
125};
126
139absl::Status RegisterStandardLibrary(
140 actions::ActionRegistry& registry,
141 const sdk::flow::CapabilitiesPtr& capabilities, bool standard_streams);
142
149absl::StatusOr<RunOutcome> Run(const Source& source, const RunOptions& options);
150
157absl::StatusOr<RunOutcome> Check(const Source& source);
158
160absl::StatusOr<std::string> DescribeEntry(const Source& source);
161
162} // namespace a11::flow::interpreter
163
164#endif // A11_FLOW_INTERPRETER_INTERPRETER_H_
A thread-safe catalogue mapping action names to schema and handler.
Definition registry.h:59
LexResult Run()
Definition lexer.cc:422
Definition interpreter.cc:49
absl::StatusOr< std::string > DescribeEntry(const Source &source)
The entry flow's ports, as text a person reads. Used by --check.
Definition interpreter.cc:201
absl::Status RegisterStandardLibrary(actions::ActionRegistry &registry, const sdk::flow::CapabilitiesPtr &capabilities, bool standard_streams)
Registers the standard library on registry, under capabilities.
Definition interpreter.cc:166
absl::StatusOr< RunOutcome > Check(const Source &source)
Compiles source and says what its entry flow is, running nothing.
Definition interpreter.cc:195
The action registry: a catalogue of named schema/handler pairs.
stores::ChunkStoreReaderOptions options
Definition runtime_streams.cc:31
Host-controlled bounds shared by parsing, linking and semantic analysis.
Definition limits.h:24
Execution-frame storage policy, independent of Flow semantics.
Definition runtime.h:178
How to run it.
Definition interpreter.h:58
FrameOptions frames
Frame cache capacity and invocation-wide frame budget.
Definition interpreter.h:115
std::shared_ptr< HostBridge > bridge
How the program reaches types and chunks its host knows about.
Definition interpreter.h:89
sdk::flow::CapabilitiesPtr capabilities
Required policy describing what the program may do.
Definition interpreter.h:67
std::vector< std::string > arguments
The program's argv.
Definition interpreter.h:64
std::shared_ptr< service::Session > session
The session the dispatch stream belongs to.
Definition interpreter.h:112
std::shared_ptr< net::WireStream > dispatch_stream
Where the program's call steps go, when they are to leave this process.
Definition interpreter.h:103
std::shared_ptr< actions::ActionRegistry > registry
Registry to run against. A null value creates a new registry.
Definition interpreter.h:70
bool standard_streams
Whether to bind this process's own standard streams.
Definition interpreter.h:81
std::optional< absl::Duration > timeout
Bound for the run and the standard-library actions it starts.
Definition interpreter.h:73
What came of it.
Definition interpreter.h:119
int exit_code
The program's exit code: what it put on an out exit_code: integer port, or 0.
Definition interpreter.h:122
std::vector< Diagnostic > diagnostics
Everything the compiler said that was not an error. Errors are the status.
Definition interpreter.h:124
What to run: the source, and a name for it that diagnostics will quote.
Definition interpreter.h:49
bool single_item_slots
Definition interpreter.h:54
CompilationLimits limits
Definition interpreter.h:53
std::string name
Definition interpreter.h:51
std::vector< std::string > source_roots
Definition interpreter.h:52
std::string text
Definition interpreter.h:50
A11's transport abstraction: the bidirectional WireStream channel and the options/callbacks that driv...