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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! Embeddable Lua runtime with a host standard library.
//!
//! `airsl` runs sandboxed Lua from Rust and gives those scripts the capabilities a shell or Python
//! script would otherwise reach for — JSON, filesystem access, subprocesses, real regular
//! expressions — through host modules implemented in Rust. Everything a script can do arrives
//! under a single `airsstack` global, so the host decides the surface rather than the Lua
//! standard library.
//!
//! ```no_run
//! use airsl::{Engine, FailurePolicy, Policy, Script};
//!
//! let engine = Engine::builder().policy(Policy::confined()).build()?;
//! let script = Script::from_file("hooks/enforce.lua")?;
//!
//! if let Err(error) = engine.eval(&script) {
//! // A hook must never block the tool call that triggered it.
//! if !FailurePolicy::FailOpen.swallows_errors() {
//! eprintln!("{error}");
//! }
//! }
//! # Ok::<(), airsl::Error>(())
//! ```
//!
//! Extend the surface by implementing [`HostModule`] and adding it to a [`ModuleSet`]; the module
//! becomes a subtable of `airsstack` alongside the built-ins.
//!
//! Third-party scripts load as [`extension`]s: a directory with its own `extension.toml` manifest,
//! negotiated against the host's ceiling and run through an [`ExtensionHost`] that owns the
//! resulting engines.
// Unix only, and deliberately loud about it. `modules::proc` decides whether a program is
// executable from the mode bits, and the sandbox tests build symlinks through `std::os::unix::fs`.
// Neither has a meaning on Windows, where executability is decided by the file extension and
// `PATHEXT`. Supporting it is a decision about what "executable" should mean there, not a
// portability patch — so the crate refuses to build with a sentence a reader can act on, instead of
// nine resolution errors pointing at std.
compile_error!;
/// The Lua binding this crate is built on.
///
/// Re-exported because it is part of the public contract rather than an implementation detail:
/// [`HostModule::install`] receives an `&mlua::Lua` and an `&mlua::Table`, so a module cannot be
/// written without naming these types. Depending on `airsl::mlua` rather than declaring `mlua`
/// separately keeps a contributor on the same version the engine was built with — a mismatch
/// otherwise produces type errors that never mention the real cause.
pub use mlua;
pub use ;
pub use Engine;
pub use ;
pub use ;
pub use FailurePolicy;
pub use ;
pub use ;
pub use Script;
pub use ;