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/values.h"
41#include "a11/net/wire_stream.h"
42#include "sdk/flow/actions/policy.h"
43
44namespace a11::flow::interpreter {
45
47struct Source {
48 std::string text;
49 std::string name;
50};
51
53struct RunOptions {
59 std::vector<std::string> arguments;
60
62 sdk::flow::CapabilitiesPtr capabilities;
63
65 std::shared_ptr<actions::ActionRegistry> registry;
66
68 std::optional<absl::Duration> timeout;
69
76 bool standard_streams = true;
77
84 std::shared_ptr<HostBridge> bridge;
85
98 std::shared_ptr<net::WireStream> dispatch_stream;
99
107 std::shared_ptr<service::Session> session;
108};
109
114 int exit_code = 0;
116 std::vector<Diagnostic> diagnostics;
117};
118
131absl::Status RegisterStandardLibrary(
132 actions::ActionRegistry& registry,
133 const sdk::flow::CapabilitiesPtr& capabilities, bool standard_streams);
134
141absl::StatusOr<RunOutcome> Run(const Source& source, const RunOptions& options);
142
149absl::StatusOr<RunOutcome> Check(const Source& source);
150
152absl::StatusOr<std::string> DescribeEntry(const Source& source);
153
154} // namespace a11::flow::interpreter
155
156#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:382
Definition interpreter.cc:48
absl::StatusOr< std::string > DescribeEntry(const Source &source)
The entry flow's ports, as text a person reads. Used by --check.
Definition interpreter.cc:196
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:161
absl::StatusOr< RunOutcome > Check(const Source &source)
Compiles source and says what its entry flow is, running nothing.
Definition interpreter.cc:190
The action registry: a catalogue of named schema/handler pairs.
How to run it.
Definition interpreter.h:53
std::shared_ptr< HostBridge > bridge
How the program reaches types and chunks its host knows about.
Definition interpreter.h:84
sdk::flow::CapabilitiesPtr capabilities
Required policy describing what the program may do.
Definition interpreter.h:62
std::vector< std::string > arguments
The program's argv.
Definition interpreter.h:59
std::shared_ptr< service::Session > session
The session the dispatch stream belongs to.
Definition interpreter.h:107
std::shared_ptr< net::WireStream > dispatch_stream
Where the program's call steps go, when they are to leave this process.
Definition interpreter.h:98
std::shared_ptr< actions::ActionRegistry > registry
Registry to run against. A null value creates a new registry.
Definition interpreter.h:65
bool standard_streams
Whether to bind this process's own standard streams.
Definition interpreter.h:76
std::optional< absl::Duration > timeout
Bound for the run and the standard-library actions it starts.
Definition interpreter.h:68
What came of it.
Definition interpreter.h:111
int exit_code
The program's exit code: what it put on an out exit_code: integer port, or 0.
Definition interpreter.h:114
std::vector< Diagnostic > diagnostics
Everything the compiler said that was not an error. Errors are the status.
Definition interpreter.h:116
What to run: the source, and a name for it that diagnostics will quote.
Definition interpreter.h:47
std::string name
Definition interpreter.h:49
std::string text
Definition interpreter.h:48
A11's transport abstraction: the bidirectional WireStream channel and the options/callbacks that driv...