Expand description
§greentic-interfaces
Shared WebAssembly Interface Types (WIT) and Rust bindings for the Greentic stack. All packages are MIT licensed and designed to evolve additively: new fields and functions land in minor releases, breaking changes require a new major package or crate version.
§Package overview
greentic:types-core@0.2.0– shared records and enums (flow metadata, tenant context, run results, error codes).greentic:host-import@0.2.0– host services that components import (secrets, telemetry, tool invocation, outbound HTTP).greentic:pack-export@0.2.0– pack services that components export (discover flows, execute flows, A2A search).greentic:component@0.4.0– component runtime contract with lifecycle hooks, invoke/invoke-stream, and structured errors.greentic:secrets@0.1.0– legacy secrets host interface (still published for compatibility).
Each WIT package lives under wit/<package>@<version>.wit. CI validates every file with wit-bindgen markdown and wasm-tools component wit so the schemas stay well-formed.
§Rust bindings
Add the crate to your Wasmtime host:
[dependencies]
greentic-interfaces = "0.2"
wasmtime = { version = "38", features = ["component-model"] }Then wire in the bindings you need. Example for greentic:component@0.4.0 control imports:
ⓘ
use greentic_interfaces::component_v0_4::{self, Component};
use greentic_interfaces::component_v0_4::greentic::component::node::{ExecCtx, TenantCtx};
use wasmtime::{component::Linker, Config, Store};
use std::{future::Future, pin::Pin};
struct MyControl;
type HostFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
impl component_v0_4::greentic::component::control::Host for MyControl {
fn should_cancel<'a, 'async_trait>(&'a mut self) -> HostFuture<'async_trait, bool>
where
'a: 'async_trait,
Self: 'async_trait,
{
Box::pin(async move { false })
}
fn yield_now<'a, 'async_trait>(&'a mut self) -> HostFuture<'async_trait, ()>
where
'a: 'async_trait,
Self: 'async_trait,
{
Box::pin(async move {})
}
}
let mut config = Config::new();
config.wasm_component_model(true);
let engine = wasmtime::Engine::new(&config)?;
let mut linker = Linker::new(&engine);
component_v0_4::add_control_to_linker(&mut linker, |state: &mut MyControl| state)?;
let component = wasmtime::component::Component::from_file(&engine, "component.wasm")?;
let mut store = Store::new(&engine, MyControl);
let (bindings, _instance) = Component::instantiate_async(&mut store, &component, &linker).await?;
let node = bindings.exports().greentic_component_node()?;Host integrations can use the helper modules:
types_core_v0_2exposes the canonical structs/enums (duplication ofgreentic:types-core@0.2.0).host_import_v0_2provides theHostImportstrait plusadd_to_linkerfor wiring the host services.pack_export_v0_2re-exports the generated exports when hosting pack components.
§Versioning
- Minor bumps add optional fields or functions; existing behaviour remains.
- Breaking changes require a new package (e.g.,
greentic:host-import@0.3.0) and crate minor bump. - The crate is published to crates.io (
0.2.xfor the current set) and taggedv0.2.xin git.
§Validation and tooling
bash scripts/validate-wit.sh– runwit-bindgen markdownandwasm-tools component wit --wasmover every.witfile.bash scripts/package-wit.sh <out-dir>– emit wasm-encoded packages for publishing.bash scripts/publish_wit.sh– package + push all WIT packages to GHCR (ghcr.io/<user>/wit/...).- CI (
.github/workflows/ci.yml) installswit-bindgen, validates WIT, and runscargo build.
§CHANGELOG
See CHANGELOG.md for release notes.
§License
MIT High-level bindings for Greentic WIT packages.
Modules§
- component_
v0_ 4 - Typed bindings for
greentic:component@0.4.0. - host_
import_ v0_ 2 - Typed bindings for
greentic:host-import@0.2.0. - pack_
export_ v0_ 2 - Typed bindings for
greentic:pack-export@0.2.0. - secrets_
v0_ 1 - WIT bindings for
greentic:secrets@0.1.0. - types_
core_ v0_ 2 - Typed bindings for
greentic:types-core@0.2.0.