Wire IPC -- minimal binary framing over standard i/o.
WIPC gives you a bidirectional byte channel between any two processes connected by pipes. It handles framing, buffering, and resync. Everything else -- payload encoding, RPC semantics, method dispatch -- is yours to define.
If a process can read stdin and write stdout, it can speak WIPC.
npm install wipc-jsimport { Channel, MessageType } from "wipc-js";
import { spawn } from "node:child_process";
const child = spawn("wasmtime", ["./build/test.wasm"], {
stdio: ["pipe", "pipe", "inherit"],
});
class Echo extends Channel {
onDataMessage(data: Buffer) {
console.log("<-", data.toString("utf8"));
}
onPassthrough(data: Buffer) {
// Anything the guest writes to stdout that isn't a WIPC frame
process.stderr.write(data);
}
}
const ch = new Echo(child.stdout!, child.stdin!);
ch.send(MessageType.DATA, Buffer.from("hello"));import { readFrame, writeFrame, MessageType, Frame } from "wipc-js/assembly/channel";
while (true) {
const frame: Frame | null = readFrame();
if (frame === null) break;
writeFrame(frame.type, frame.payload);
if (frame.type == MessageType.CLOSE) break;
}That's it. The guest reads frames, echoes them back. The host sends frames, receives echoes.
9-byte header, then payload:
0 4 5 9 9+N
┌───────┬──────┬─────────┬─────────┐
│ WIPC │ type │ length │ payload │
└───────┴──────┴─────────┴─────────┘
4 B 1 B u32 LE N B
┌────────┬──────┬─────────┬──────────────────────┐
│ Offset │ Size │ Field │ Description │
├────────┼──────┼─────────┼──────────────────────┤
│ 0 │ 4 │ MAGIC │ ASCII "WIPC" │
│ 4 │ 1 │ TYPE │ Message type │
│ 5 │ 4 │ LENGTH │ Payload size, u32 LE │
│ 9 │ N │ PAYLOAD │ Opaque bytes │
└────────┴──────┴─────────┴──────────────────────┘
┌───────┬───────┬────────────────────────────┐
│ Value │ Name │ Purpose │
├───────┼───────┼────────────────────────────┤
│ 0x00 │ OPEN │ Channel initialization │
│ 0x01 │ CLOSE │ Graceful shutdown │
│ 0x02 │ CALL │ RPC / request-response │
│ 0x03 │ DATA │ Raw data transfer │
└───────┴───────┴────────────────────────────┘
Payloads are opaque. WIPC does not prescribe encoding -- use JSON, protobuf, raw bytes, whatever fits your use case.
See SPEC.md for the full protocol specification.
┌───────────────┐
│ FFI │
└───────────────┘
│
┌────────────────────┐ stdin / stdout (WIPC) ┌───────────────────────┐
│ Host │ <──────────────────────> │ Guest / Child │
└────────────────────┘ └───────────────────────┘
│
┌───────────────┐
│ passthrough │
└───────────────┘
WIPC frames and regular stdout coexist on the same stream. The Channel parser separates them: frames are dispatched, everything else goes to onPassthrough().
import { Channel, MessageType } from "wipc-js";Sending:
send(type, payload?)-- send a framesendJSON(type, msg)-- send a frame with a JSON-encoded payload
Receiving (override in a subclass):
onOpen()-- OPEN frameonClose()-- CLOSE frameonCall(msg)-- CALL frame (payload parsed as JSON)onDataMessage(data)-- DATA frame (raw Buffer)onPassthrough(data)-- non-WIPC bytes
import { readFrame, writeFrame, MessageType } from "wipc-js/assembly";writeFrame(type, payload?)-- write a frame to stdoutreadFrame(): Frame | null-- blocking read from stdinencode(type, payload): ArrayBuffer-- encode without sendingdecode(data): Frame | null-- decode without reading
npm run asbuild # build all targets
npm run asbuild:debug # debug build
npm run asbuild:release # release build
npm test # run test suiteHere's some benchmarks taken on my personal machine using Node.js v25:
Encode
encode small (27 B)
388ms | 2,577,150 ops/s | 57 MB/s
encode 1 KB
593ms | 1,685,483 ops/s | 1,726 MB/s
encode 64 KB
449ms | 222,904 ops/s | 14,608 MB/s
Decode (zero-copy, returns subarray view)
decode small (27 B)
88ms | 11,325,136 ops/s | 249 MB/s
decode 1 KB
88ms | 11,388,579 ops/s | 11,662 MB/s
decode 64 KB
88ms | 11,422,528 ops/s | 748,587 MB/s
Decode + copy (Buffer.from)
decode+copy small (27 B)
130ms | 7,694,254 ops/s | 169 MB/s
decode+copy 1 KB
222ms | 4,496,633 ops/s | 4,605 MB/s
decode+copy 64 KB
387ms | 258,641 ops/s | 16,950 MB/s
Channel round-trip (in-process echo)
echo small (27 B)
500,000 round-trips in 1,228ms | 407,213 rt/s | 18 MB/s
Decoding returns a subarray view -- no copies, constant time regardless of payload size. When you need to own the data, Buffer.from() copies at memcpy speed. Encoding cost is dominated by Buffer.concat. Round-trip throughput is limited by Node.js stream backpressure, not framing overhead.
Run benchmarks yourself:
npm run benchHost: Any runtime that WIPC is ported to.
Guest: Anything that reads stdin and writes stdout. The included AssemblyScript library targets WASI runtimes (Wasmtime, Wasmer). Porting to Rust, C, Go, or any other language is straightforward -- see SPEC.md.
This project is distributed under an open source license. Work on this project is done by passion, but if you want to support it financially, you can do so by making a donation to the project's GitHub Sponsors page.
You can view the full license using the following link: License
Please send all issues to GitHub Issues and to converse, please send me an email at me@jairus.dev
- Email: Send me inquiries, questions, or requests at me@jairus.dev
- GitHub: Visit the official GitHub repository Here
- Website: Visit my official website at jairus.dev
- Discord: Contact me at My Discord or on the AssemblyScript Discord Server