act_runtime/lib.rs
1//! Embeddable wasmtime host for ACT components.
2//!
3//! This is the engine behind the `act` CLI, packaged so other hosts — a
4//! toolserver, a gateway, anything that has to run a component the same way —
5//! get identical capability decisions, credential namespacing, consent
6//! routing and audit records rather than a second implementation of them.
7//!
8//! The crate is headless: it knows nothing about terminals, MCP, HTTP or
9//! configuration files. A host supplies the decisions ([`RuntimeConfig`]) and
10//! the channel it reaches a human on ([`ConsentConfig`]); the runtime supplies
11//! everything downstream of that.
12//!
13//! ```no_run
14//! # async fn example() -> anyhow::Result<()> {
15//! let rt = act_runtime::ComponentRuntime::new()?;
16//! let component = "ghcr.io/actpkg/sqlite:0.1.0".parse()?;
17//!
18//! // Ask-mode grants with a denying prompter: the headless default, and the
19//! // reason a capability the operator did not grant stays denied rather than
20//! // silently allowed when no one is there to ask.
21//! let running = rt
22//! .load(
23//! &component,
24//! &act_runtime::RuntimeConfig::default(),
25//! act_runtime::ConsentConfig::deny(),
26//! )
27//! .await?;
28//!
29//! let tools = running.handle().list_tools(&Default::default()).await?;
30//! let result = running
31//! .handle()
32//! .call_tool("query", Vec::new(), Vec::new(), None)
33//! .await?;
34//! # let _ = (tools, result);
35//! # Ok(())
36//! # }
37//! ```
38
39pub mod audit;
40pub mod consent;
41pub mod credentials;
42pub mod fs_policy;
43pub mod http_client;
44pub mod http_policy;
45pub mod resolve;
46mod runtime;
47pub mod sessions;
48pub mod validate;
49
50mod actor;
51mod engine;
52mod info;
53pub(crate) mod store;
54
55// Generated bindings from WIT — fully auto-generated, no manual patching.
56#[allow(unused_mut, unused_variables, dead_code)]
57mod bindings;
58pub use bindings::*;
59
60#[cfg(test)]
61mod tests;
62
63pub use actor::{
64 AuditContext, CallToolResult, ComponentHandle, Metadata, ToolProvider, instantiate_component,
65 spawn_component_actor,
66};
67pub use engine::{create_engine, create_linker, load_component};
68pub use info::{ComponentError, ComponentInfo, read_component_info};
69pub use resolve::ComponentRef;
70pub use runtime::{
71 AuditOptions, ComponentRuntime, ConsentConfig, CredentialsSource, RunningComponent,
72 RuntimeConfig,
73};
74pub use store::{HostState, create_store};