TypeScript SDK
A Peer for Node and Bun, with the wire types generated from the JSON Schema and no runtime dependencies.
The TypeScript SDK is @agentwireprotocol/sdk. A Peer listens and connects, sends messages in threads, and delivers what arrives as typed events, with everything the protocol asks for inside: resume with an outbox on disk, acks, dedup by id, blobs in chunks, grants and introductions, ping/pong, reconnection with backoff.
Node 20 or later, or Bun. No runtime dependencies: Ed25519 comes from node:crypto.
npm install @agentwireprotocol/sdkA peer in a few lines
import { Peer } from "@agentwireprotocol/sdk";
const peer = new Peer({ dir: "~/.mybot", name: "mybot@builder" });
const address = await peer.listen("tailcat"); // or "tcp:127.0.0.1:7000", "unix:/tmp/awp.sock"
console.log("share this:", address);
const key = await peer.connect("tc..."); // an address shared out of band
peer.send(key, "Please run make test at a1b2c3.", { subject: "Run the suite" });
for await (const event of peer.events()) {
switch (event.type) {
case "message":
console.log(`${event.peer}: ${event.text}`);
break;
case "state":
console.log(`${event.peer} is ${event.state} in ${event.thread}`);
break;
case "blob":
console.log(`file ${event.name} at ${event.path}`);
break;
}
}API
Options, the Peer’s methods, and every event with its fields.
Delegating a task
Connect, open a thread with the ask, wait for events, collect the result.
Taking a task
Listen, handle messages, report progress, send results and files back.
Files, grants, transports
Blobs, capabilities and requests, addresses and reconnection.
How it fits
new Peer({ dir }) loads or creates the identity, and per peer an append-only outbox log of unacked messages, an inbox log of received ids and blob progress, the threads and the grants; without dir the Peer is ephemeral. listen takes tcp:, unix: or "tailcat", a WireGuard tunnel through the tailcat CLI with an address any peer can reach. connect resolves with the peer’s key after the handshake and keeps dialing with backoff, capped at a minute, whenever there is unfinished business. send never fails because the peer is away; waitAck waits for the ack.
The wire types (Hello, Msg, Part, Grant, …) are generated from the protocol’s JSON Schema, vendored in the package, and exported as the wire namespace. CI fails when they drift from the schema.
Conformance
bun test in the SDK’s repository runs the wire primitives, a two-peer conversation with states, a reply, a multi-chunk blob, grants and bye, queued delivery across a restart, and, with AWP_BIN set, the protocol’s conformance suite against a Peer, both listening and dialing.