autobot-wasm
autobot-wasm
WebAssembly plugin for Autobot. Write tools in any language (Rust, Go, C, AssemblyScript, etc.), compile to .wasm, and expose them to the LLM agent.
Prerequisites
- Wasmer runtime v2.x installed
WASMER_DIRenvironment variable set
Installation
Add to your shard.yml:
dependencies:
autobot-wasm:
github: crystal-autobot/autobot-wasm
version: ~> 0.1.0
Then require it alongside autobot:
require "autobot"
require "autobot-wasm"
The plugin registers itself automatically.
How it works
- Place
.wasm+.jsonmanifest pairs inworkspace/wasm/ - On startup, the plugin discovers all manifests, compiles the WASM modules, and registers them as tools
- Tools are exposed to the LLM with the
wasm_prefix (e.g.,wasm_string_reverse) - When called, parameters are passed as JSON in
argv[1]via WASI, and the tool writes its result to stdout
Manifest format
Each tool needs a JSON manifest alongside its .wasm file:
workspace/wasm/
string_reverse.json
string_reverse.wasm
Example string_reverse.json:
{
"name": "string_reverse",
"description": "Reverse a string and return the result",
"parameters": {
"properties": {
"input": { "type": "string", "description": "The string to reverse" }
},
"required": ["input"]
},
"timeout": 30,
"env": {}
}
Fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
name |
string | yes | Tool name (becomes wasm_<name>) |
|
description |
string | yes | Shown to the LLM | |
parameters |
object | yes | JSON Schema-style parameter definitions | |
timeout |
integer | no | 30 | Execution timeout in seconds |
env |
object | no | {} |
Environment variables passed to WASI |
Parameter properties
Each property in parameters.properties supports:
type—string,integer,number,boolean,array,objectdescription— Human-readable descriptionenum— Array of allowed values (strings only)minimum/maximum— Numeric boundsitems— Schema for array items
Writing a WASM tool
Communication protocol
- Arguments are received via WASI args:
argv[0]is the tool name,argv[1]is a JSON string of parameters - Output is written to stdout
- The tool should exit with code 0 on success
Example in Rust
use std::env;
use std::io;
fn main() {
let args: Vec<String> = env::args().collect();
let params: serde_json::Value = serde_json::from_str(&args[1]).unwrap();
let input = params["input"].as_str().unwrap();
let reversed: String = input.chars().rev().collect();
print!("{}", reversed);
}
Compile with:
cargo build --target wasm32-wasi --release
cp target/wasm32-wasi/release/string_reverse.wasm workspace/wasm/
Example in C
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
// argv[1] contains JSON params - parse as needed
// Write result to stdout
printf("Hello from C WASM tool!");
return 0;
}
Compile with:
clang --target=wasm32-wasi -o workspace/wasm/hello.wasm hello.c
Limits
- Output: Truncated at 50 KB
- Timeout: Configurable per tool (default 30s)
- Memory: Managed by the Wasmer runtime
Development
shards install
crystal spec
crystal tool format
./bin/ameba
License
MIT
Repository
autobot-wasm
Owner
Statistic
- 0
- 0
- 0
- 0
- 3
- 11 days ago
- February 23, 2026
License
MIT License
Links
Synced at
Mon, 23 Feb 2026 07:49:02 GMT
Languages