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
80
81
82
83
84
85
86
87
88
//! A sandboxed Lua REPL for LLM tool use.
//!
//! LLM agents typically need dozens of specialized tools (calculator, date formatter,
//! string manipulator, etc.). Each tool requires a round-trip to the provider and you
//! pay for every token exchanged. **onetool replaces them all with a single sandboxed
//! Lua REPL** — the LLM writes code instead of calling single-purpose tools.
//!
//! # Quick Start
//!
//! ```
//! use onetool::Repl;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let repl = Repl::new()?;
//!
//! let outcome = repl.eval("return 1 + 1")?;
//!
//! match outcome.result {
//! Ok(values) => println!("Result: {:?}", values),
//! Err(error) => println!("Error: {}", error),
//! }
//!
//! for line in outcome.output {
//! print!("{}", line);
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! # Framework Adapters
//!
//! Ready-to-use adapters (each behind a feature flag of the same name):
//!
//! | Feature | Module | Framework |
//! |---------|--------|-----------|
//! | `genai` | `genai` | [genai](https://github.com/jeremychone/rust-genai) multi-provider client |
//! | `mistralrs` | `mistralrs` | [mistral.rs](https://github.com/EricLBuehler/mistral.rs) local inference |
//! | `rig` | `rig` | [rig-core](https://github.com/0xPlaygrounds/rig) modular framework |
//! | `aisdk` | `aisdk` | [aisdk](https://github.com/lazy-hq/aisdk) Vercel AI SDK port |
//! | `mcp` | `mcp` | [MCP](https://modelcontextprotocol.io/) server via rmcp |
//!
//! # Security
//!
//! The Lua runtime is sandboxed with policy-based access control. Functions are
//! categorized into three tiers: **safe** (no check), **unsafe** (wrapped, denied by
//! default), and **forbidden** (removed entirely). See [`runtime::sandbox`] for the
//! full security model and [`runtime::sandbox::DEFAULT_API_SPEC`] for the complete
//! function list.
//!
//! # Extending the Runtime
//!
//! Register custom Rust functions via [`Repl::with_runtime`] (post-init) or
//! [`Repl::new_with`] (pre-built runtime). See their documentation for examples.
//!
//! # Key Types
//!
//! - [`Repl`] — main interface for evaluating Lua code
//! - [`repl::EvalOutcome`] — result of a single evaluation (return values + captured output)
//! - [`ReplError`] — error type for REPL operations
//! - [`runtime`] — runtime creation, sandboxing, output capture, docs, and package paths
//! - [`tool_definition`] — tool name, description, and JSON schema for LLM integration
// -- Flatten
pub use ;
// -- Private modules
// -- Public modules