1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//! The adapter that runs a tool extension's Lua adapter in the airsl sandbox with zero grants, and
//! the only place Lua runs, so that an extension can only propose operations.
//!
//! It translates between the adapter port and the sandbox and decides nothing.
//!
//! # Responsibilities
//!
//! - [`AirslAdapter`] implements the adapter port, and [`Session`] is one extension's engine from
//! running its entry file to its last `plan` call.
//! - Reading every `.lua` file of an extension into memory, so Lua never touches the disk.
//! - Building the sandbox: Lua's pure base, `airsstack.json`, `airsstack.ext` and the
//! `agentstacks` table, with `print` and `warn` removed.
//! - The `agentstacks` table: `on` registers a handler; `write`, `copy`, `skip` and
//! `require_binary` propose operations while the `plan` handler runs; `read` serves the project
//! files the extension declared; `require` loads the extension's own modules from memory; and
//! `json.edit` edits JSON text.
//! - Reading the arguments of every call strictly, with no coercion; locating a refusal at the
//! nearest Lua frame; converting Lua values to JSON; and wording a Lua failure for the user.
//! - Building the payloads the handlers are called with and reading the answer of `values`.
//!
//! # Non-responsibilities
//!
//! No rule is decided here: the shape of an operation, a path or a JSON edit belongs to `types`,
//! and the order of the flows belongs to `app`. The host reaches the outside only through the
//! ports, and never writes.
//!
//! This file is an export-only module with no executable logic, so it carries no inline tests.
pub use AirslAdapter;
pub use Session;