greentic_runner/lib.rs
1#![forbid(unsafe_code)]
2//! Canonical entrypoint for embedding the Greentic runner.
3//!
4//! This crate provides two supported integration paths:
5//! - [`run_http_host`] mirrors the CLI and starts the HTTP server that exposes
6//! ingress adapters, admin endpoints, and the pack watcher.
7//! - [`start_embedded_host`] constructs a [`RunnerHost`] without spinning up the
8//! HTTP server so callers can drive `handle_activity` manually (desktop/dev
9//! harnesses, tests, etc.).
10
11use anyhow::Result;
12
13pub use greentic_runner_host::{
14 self as host, Activity, ActivityKind, HostBuilder, HostServer, RunnerConfig, RunnerHost,
15 TenantHandle, config, http, imports, pack, routing, runner, runtime, runtime_wasmtime,
16 telemetry, verify, watcher,
17};
18
19pub mod desktop {
20 pub use greentic_runner_desktop::*;
21}
22
23pub mod gen_bindings;
24
25/// Launch the canonical HTTP host. This is equivalent to running the
26/// `greentic-runner` binary with the provided [`RunnerConfig`].
27pub async fn run_http_host(cfg: RunnerConfig) -> Result<()> {
28 greentic_runner_host::run(cfg).await
29}
30
31/// Build and start a [`RunnerHost`] without wiring the HTTP ingress server.
32/// Callers are responsible for loading packs via [`RunnerHost::load_pack`] and
33/// invoking [`RunnerHost::handle_activity`] directly.
34pub async fn start_embedded_host(builder: HostBuilder) -> Result<RunnerHost> {
35 let host = builder.build()?;
36 host.start().await?;
37 Ok(host)
38}