A safe, simple, extensible, and fast agent harness
2.0 kB · 81 lines
Markdown
at main

Project Setup #

Plugins are standalone Rust library crates compiled to wasm32-wasip2. You don't need to clone or modify the Ein repository.

Prerequisites #

You need Rust stable and the WASM target:

rustup target add wasm32-wasip2

Verify it's installed:

rustup target list --installed | grep wasm32
# wasm32-wasip2

Create a new crate #

cargo new --lib my_tool
cd my_tool

Configure Cargo.toml #

Two things are required: the crate must produce a cdylib (the WASM component format), and it must depend on ein_plugin.

ein_plugin is not published to crates.io — add it as a git dependency:

[package]
name = "my_tool"
version = "0.1.0"
edition = "2024"

[lib]
crate-type = ["cdylib"]

[dependencies]
ein_plugin  = { git = "https://github.com/mstallmo/ein" }
anyhow      = "1"
serde       = { version = "1", features = ["derive"] }
serde_json  = "1"
wit-bindgen = "0.53"

The wit-bindgen version should match what Ein uses. Check the releases page or the workspace Cargo.toml if you're unsure.

Locking to a specific Ein release #

By default the git dependency tracks the main branch. To pin to a release tag:

ein_plugin = { git = "https://github.com/mstallmo/ein", tag = "v0.1.0" }

Or a specific commit:

ein_plugin = { git = "https://github.com/mstallmo/ein", rev = "abc1234" }

Verify the setup #

Try a build before writing any plugin code:

cargo build --target wasm32-wasip2

If this succeeds (producing target/wasm32-wasip2/debug/my_tool.wasm), your environment is configured correctly.

Tip: cargo check --target wasm32-wasip2 is faster for iterating — it type-checks without producing a binary.

Next steps #