Expand description
§outl-exec
Engine that runs the code inside a fenced markdown block (```lisp,
```python, …) and writes the result back into the page as a
sibling subblock — idempotent on re-run.
The crate is intentionally tiny and modular:
runtime::Runtime— the only trait you implement to add a new language. Everything else (registry, orchestration, result block upkeep) treats runtimes as opaque.registry::RuntimeRegistry— resolves a fence info-string ("lisp","python", …) to the concreteruntime::Runtime.sandbox— cross-platform timeout helper. Runtimes that need stronger isolation (memory, syscalls) layer it on top — the wasmtime-based runtimes coming in M2 will, the in-process ones today don’t.result_block— pure functions that find / create the result subblock under a code block. No I/O.orchestrate::run_block_at_index— single entry point for every UI (TUI, future Tauri GUI, future mobile via uniffi). Takes a workspace + page path + block flat-index, runs, persists, reconciles.
§Adding a new language in 10 lines
ⓘ
struct RubyRuntime;
impl outl_exec::Runtime for RubyRuntime {
fn language(&self) -> &'static str { "ruby" }
fn execute(&self, source: &str, ctx: &outl_exec::ExecContext)
-> Result<outl_exec::ExecOutput, outl_exec::ExecError>
{
// run the source however you like (wasm, subprocess, ...);
// populate stdout/stderr/duration/exit and return.
todo!()
}
}
let mut reg = outl_exec::RuntimeRegistry::default();
reg.register(RubyRuntime);Re-exports§
pub use language::extract_fence;pub use language::FenceParts;pub use orchestrate::run_block_at_index;pub use orchestrate::run_block_at_index_if_source_changed;pub use orchestrate::RunError;pub use orchestrate::RunReport;pub use registry::RuntimeRegistry;pub use result_block::render_result_body;pub use result_block::result_source_hash;pub use result_block::source_hash;pub use result_block::upsert_result_child;pub use result_block::upsert_result_child_with_hash;pub use result_block::upsert_result_embeds;pub use result_block::RESULT_MARKER;pub use result_block::SOURCE_HASH_KEY;pub use runtime::ExecContext;pub use runtime::ExecError;pub use runtime::ExecOutput;pub use runtime::ExitStatus;pub use runtime::OutputFormat;pub use runtime::Runtime;pub use runtimes::query::run_query_dsl;pub use runtimes::query::run_query_structured;pub use runtimes::query::QueryHit;pub use runtimes::query::QueryParams;
Modules§
- language
- Extract
(language, body)from a block’s raw text. - orchestrate
- End-to-end “run this block”: single function every UI calls.
- registry
- Map from fence info-string (
"lisp","python", …) to runtime. - result_
block - Build and place the
> **result:**subblock under a code block. - runtime
- The
Runtimetrait and its surrounding value types. - runtimes
- Built-in runtimes — one file per language, each behind a feature.
- sandbox
- Cross-platform sandbox helpers shared by every runtime.
- wasm
- WebAssembly sandbox — the uniform execution path that every language can eventually share.