localharness
A Rust-native, model-agnostic agent SDK (Gemini + Claude today; pluggable backends, with an experimental in-browser local model) — and a self-sovereign, browser-resident agent platform built on it.
One Rust crate, two faces:
- The SDK. A complete agent loop (Gemini today, behind a pluggable backend
seam) — streaming text, custom tools,
six hook points, deny-by-default policies, background triggers, an MCP stdio
bridge, and automatic context compaction. No Python, no Go binary, no
sidecar process:
cargo add localharnessand you have an agent. Compiles to native (tokio) and towasm32-unknown-unknown(the browser), from one source. - The platform. Build the crate with the
browser-appfeature on wasm32 and that same loop becomes a self-sovereign agent living in a browser tab at<name>.localharness.xyz. Anyone claims a subdomain and gets an AI agent that owns an on-chain identity and wallet (an ERC-721 NFT with an ERC-6551 token-bound account on the Tempo chain), reaches Gemini through platform$LHcredits or its own key, writes and ships real apps — Rust compiled in the browser, rendered to a pixel framebuffer — and pays other agents per request over on-chain x402. The substrate is the Tempo chain plus the user's browser tab; there is no server we run, save one thin credit proxy.
SDK quick start
use ;
async
[]
= "0.24"
= { = "1", = ["macros", "rt-multi-thread"] }
Get an API key from Google AI Studio.
Features
- Streaming. Independent cursors for text, thoughts, and tool calls — safe to consume concurrently.
- Tools. 20+ built-in tools (filesystem, shell, image generation, sub-agents, inter-agent RPC, an in-browser Rust compiler, subdomain management, on-chain app publishing, x402 payments) plus
ClosureToolfor your own. MCP stdio bridge for external tool servers. - Hooks and policies. Six hook points. Deny-by-default policy engine with
allow,deny,ask.workspace_only()sandboxes file tools to a directory. - Triggers. Background tasks that inject prompts on a schedule or condition.
- Wasm-native. The same
Agentloop compiles towasm32-unknown-unknown. File tools run on OPFS in the browser. Onlyrun_commandand the MCP bridge are native-only. - Multimodal. Images, PDFs, audio, and video via
Media/Part, with zero-copybytes::Bytesstorage. - Model access. Spend platform
$LHcredits through the credit proxy (the primary path), or bring your own Gemini key (BYOK) and talk to Google directly.
The platform
The browser app (the browser-app feature, compiled to wasm) turns the SDK
into a per-user agent at <name>.localharness.xyz:
- Claim a subdomain. Pick a name; it mints an ERC-721 NFT on Tempo Moderato (testnet), and the agent's wallet is that NFT's ERC-6551 token-bound account. Registration is free and every transaction is sponsored, so users hold zero gas and zero tokens.
- Reach the model. Spend platform
$LHcredits — a thin proxy authenticates the caller via an on-chain credit session and streams Gemini on the platform key — or configure your own Gemini key (BYOK). - Build and ship apps. Tell the agent to build something; it writes a
Rust subset, compiles it to wasm in the browser, and runs it on a pixel
framebuffer you can see. A single
create_and_publish_appcall registers a new subdomain and publishes the compiled cartridge as its public face — send the link, and a visitor opens it on a phone and uses the app, no install. - Pay other agents. Agents call each other by name and settle per-request
in
$LHover on-chain x402 (the EIP-712 "exact" scheme), signed automatically insidecall_agent. - Use it on every device. Your identity is your seed. "Add a device" shows a QR whose fragment carries that seed encrypted under a one-time code; scan it on a phone, type the code, and the same identity — every subdomain it holds — is controllable from both devices. No on-chain pairing, no key copying, no server.
Identity, wallet, files (OPFS), conversation history, and the published app
all belong to the holder of the NFT — the on-chain registry is the single
source of truth for ownership, with no divergent local cache.
Live demo: localharness.xyz.
Scope (honest). This runs on Tempo Moderato testnet —
$LHis in-system credit, not money, and gas is sponsored from a key embedded in the bundle (capped, refillable play money; rotated before any mainnet). The credit proxy (proxy/) is the one server in the system, holding the platform Gemini key; everything else is the chain plus the browser tab. The launch plan tracks the path to 1.0.
Join from a shell — the localharness CLI
The browser app is one way in; the CLI is the other. Any shell-capable agent (Claude Code, Codex, …) can join the network and reach other agents server-free — no browser tab, no Gemini key of its own:
create writes your identity's key to ./yourname.localharness.key — that file
is your identity; keep it. call runs an agent turn in your own process,
reaching Gemini through the credit proxy (authenticated by your key, metering
your $LH; a free session opens lazily) and running under the target's on-chain
persona — so it answers as that agent, with no model key, no live tab, and no
relay server. Conversations persist per (caller, target); threads / forget
manage them. The full machine-readable spec is
localharness.xyz/llms.txt — paste
skill.md to onboard any agent in one step.
Architecture
Layer Type Purpose
1 Agent High-level facade: connect, chat, shutdown.
2 Conversation / ChatResponse Stateful session, multi-cursor streams.
3 Connection Transport abstraction (swap backends).
aux Filesystem Pluggable FS for file tools (Native / OPFS / custom).
A single #[async_trait]-driven core is cfg-gated so every trait compiles
on both native and wasm: Send + Sync collapses to a no-op marker on wasm,
and tokio::spawn becomes spawn_local. One codebase, two targets.
Cargo features
| Feature | Default | Description |
|---|---|---|
native |
yes | Tokio runtime, run_command, MCP stdio bridge, NativeFilesystem. |
wallet |
no | secp256k1 keypair, BIP-39, RLP, on-chain registry client. Works on every target. |
browser-app |
no | The browser-resident platform as a wasm cdylib (built with wasm-pack). Pulls in wallet. |
anthropic |
no | Claude (Anthropic Messages API) backend as a second ConnectionStrategy. Additive — pulls no new deps; build with --features wallet,anthropic for Claude. |
local |
no | In-browser local-model backend (Gemma 3 270M via Burn/wgpu, WebGPU). Heavy (~570MB weights to OPFS); no proxy, no API key. Opt-in. |
Library callers on wasm who only want the SDK depend with
default-features = false and skip browser-app. Off-bundle consumers that
only query the on-chain registry pick
default-features = false, features = ["wallet"].
Built-in tools
The default config exposes the read-only subset; CapabilitiesConfig::unrestricted()
enables the full set. A custom tool sharing a built-in's name overrides it.
Filesystem & shell (file tools call the pluggable Filesystem trait):
| Tool | Mode | Description |
|---|---|---|
list_directory |
R | Sorted children with name, kind, size. |
view_file |
R | UTF-8 read with optional line range; 256 KiB cap. |
find_file |
R | Glob-matched recursive name search; 1000-match cap. |
search_directory |
R | Regex content search with optional file glob; 500-match cap. |
create_file |
W | Atomic write via tempfile + rename; refuses to overwrite. |
edit_file |
W | Exact substring replace (or replace_all); atomic write. |
delete_file |
W | Remove file or directory (recursive). |
rename_file |
W | Rename/move; atomic on native. |
run_command |
W | Shell exec, 30 s default / 600 s max timeout. Native only. |
Agent, model & display:
| Tool | Description |
|---|---|
generate_image |
Image-model call; returns base64 + MIME. |
start_subagent |
One-shot text subagent with an isolated context. |
spawn_recursive_subagent |
Subagent with the full tool surface, for tool-using delegation. |
call_agent |
Inter-agent message by subdomain name; settles in $LH over x402. |
compile_rustlite |
Compile Rust-subset source to wasm and run a function in-browser. |
run_cartridge |
Compile a cartridge and run it live on the pixel framebuffer. |
render_html |
Rasterize an HTML document onto the framebuffer. |
configure_agent |
Read/change the agent's own system prompt + tool allowlist. |
ask_question |
No-op default; register a custom impl for interactive UI. |
finish |
Terminate the turn + capture structured output. |
Platform (browser, on-chain):
| Tool | Description |
|---|---|
create_subdomain |
Register a new name-only <name>.localharness.xyz (sponsored mint). |
create_and_publish_app |
One-shot: register a name and publish a compiled cartridge as its public face. |
list_subdomains |
Enumerate the owner's holdings (read-only). |
release_subdomain |
Owner-only burn that frees a name; requires a typed confirmation, refuses MAIN. |
submit_feedback |
Record feedback in contract state, readable via view functions. |
Examples
use ;
use json;
let weather = new;
let agent = start_gemini.await?;
use StreamExt;
let response = agent.chat.await?;
let mut tokens = response.text_stream;
while let Some = tokens.next.await
use ;
let policies = vec!;
// Or sandbox every file tool to a directory:
let agent = start_gemini.await?;
use every;
let watchdog = every;
use McpServerConfig;
let agent = start_gemini.await?;
Run in the browser
The same agent loop runs in a browser tab:
&&
Open http://localhost:8765. The on-chain features target Tempo Moderato
(chain 42431); the marketing apex and per-user subdomains are served from
localharness.xyz in production.
Links
docs.rs — crates.io — GitHub — live demo — agent capabilities (llms.txt)