packages/rust/examples/README.md
This directory contains practical examples for the elizaOS Rust crate in both native and WASM environments.
Native examples run with Cargo and require the native feature.
Creates a simple agent runtime with a character:
cargo run --example basic_runtime --features native
Demonstrates registering a model handler:
cargo run --example with_handlers --features native
WASM examples run with Bun or Node.js and use the compiled WASM module.
# From packages/rust directory
./build-wasm.sh
# Or just build for Node.js
wasm-pack build --target nodejs --out-dir pkg-node --no-default-features --features wasm
Demonstrates UUID generation, character parsing, and memory operations:
bun run examples/wasm/basic.ts
Shows the full WasmAgentRuntime lifecycle with model handlers:
bun run examples/wasm/runtime.ts
An interactive chat session with the agent:
bun run examples/wasm/chat.ts
Type messages to chat, type exit to quit.
Measures JSON round-trips and handler throughput:
bun run examples/wasm/benchmark.ts