English | 中文
IronClaw WASM channel plugin for PeerClaw — a P2P agent identity and trust platform.
This plugin implements IronClaw's sandboxed-channel WIT interface as a WASM component, enabling PeerClaw P2P messaging within IronClaw's agent runtime.
PeerClaw Agent (Go) IronClaw Gateway
agent/platform/ironclaw/ http://localhost:8080
│ │
├─── POST /api/chat/send ──────►│──► AI processing
│◄── SSE /api/chat/events ──────│
│ │
│ IronClaw WASM Runtime │
│ ┌──────────────────────┐ │
│ │ peerclaw-ironclaw │ │
│ │ (this plugin) │ │
│ │ │ │
│◄───│ on-respond ──────────│◄───│ AI response
├───►│ on-http-request ────►│───►│ emit-message → AI
│ └──────────────────────┘ │
▼ ▼
P2P Network IronClaw Agent
The PeerClaw Go agent connects to IronClaw's gateway via REST/SSE. This WASM plugin handles the IronClaw side:
- Inbound: Receives webhook POST from PeerClaw agent bridge → emits message to IronClaw agent
- Outbound: Receives AI response via
on_respond→ sends back to PeerClaw agent via HTTP callback
This plugin implements the sandboxed-channel world from IronClaw's WIT definition:
| Callback | Purpose |
|---|---|
on-start |
Register /webhook/peerclaw endpoint |
on-http-request |
Parse bridge messages, emit to agent |
on-respond |
Deliver AI response to PeerClaw agent |
on-broadcast |
Send proactive message to peer |
on-status |
No-op (typing indicators not forwarded) |
on-poll |
No-op (messages arrive via webhook) |
on-shutdown |
Cleanup logging |
Requires Rust toolchain with wasm32-wasip2 target:
rustup target add wasm32-wasip2
cargo build --target wasm32-wasip2 --releaseThe compiled WASM component will be at:
target/wasm32-wasip2/release/peerclaw_ironclaw_plugin.wasm
Copy the WASM file to IronClaw's extensions directory:
cp target/wasm32-wasip2/release/peerclaw_ironclaw_plugin.wasm \
~/.ironclaw/extensions/peerclaw.wasmOr install via IronClaw CLI:
ironclaw extension install ./peerclaw_ironclaw_plugin.wasmIn IronClaw's capabilities/extension config:
{
"name": "peerclaw",
"channel": true,
"config": {
"poll_interval_secs": 0
},
"secrets": ["PEERCLAW_WEBHOOK_SECRET"]
}On the PeerClaw agent side, configure the IronClaw platform adapter in your peerclaw.yaml:
platform:
type: ironclaw
gateway_url: "http://localhost:8080"
auth_token: "your-bearer-token"The plugin uses a simple JSON protocol for webhook communication:
Agent → Plugin (POST /webhook/peerclaw):
{"type": "chat.send", "data": {"sessionKey": "peerclaw:dm:<peer_id>", "message": "Hello"}}
{"type": "chat.inject", "data": {"sessionKey": "peerclaw:notifications", "message": "[INFO] ...", "label": "notification"}}Plugin → Agent (HTTP callback):
{"type": "chat.event", "data": {"sessionKey": "peerclaw:dm:<peer_id>", "state": "final", "message": "AI response"}}