AWP

API

The Go SDK's Options, the Peer's methods, and every event.

import "github.com/agentwireprotocol/go-sdk/awp"

Options

FieldMeaning
DirThe state directory: identity, the SQLite store with the outbox, threads and grants, and received blobs. Empty means a temporary directory with a fresh identity, removed on Close.
Name, AboutSent in hello. Name defaults to awp@<hostname>.
ListenAddresses to accept connections on: tailcat, tcp:host:port, unix:/path. Empty for a peer that only connects out.
AdvertiseThe address sent in hello so peers can reconnect: the tailcat address by default, none to send nothing.
PolicyAdmission and capabilities: Accept (awp.AcceptAny or awp.AcceptAllowlist), Allow, Trust, Serve (exec, fs:read, fs:write the Peer fulfils itself), Root.
BlobLimitThe largest blob sent or received; 50 MiB.
PingInterval, HandshakeTimeout, MaxBackoff, OutboxTTL30 s, 30 s, 60 s, 7 days.
AllowPlaintextPermits plain TCP to public addresses, which the spec advises against.
PresencePublishes this Peer’s signed presence to the network.
Logf, TraceThe engine’s log, and every line sent and received.

Peer

MethodDoes
New(o Options) (*Peer, error)Opens the state, loads or creates the identity, starts listening and reconnecting.
Close() errorStops everything without a bye; peers resume next time.
Key(), Name(), Dir()The identity, the hello name, the state directory.
Addresses() []stringWhat the Peer listens on, tailcat first. TailcatAddress() says why it is missing while the tunnel starts.
Connect(ctx, addr) (string, error)Dials and returns the peer’s key after the handshake.
Connected(peer) boolWhether there is a live connection now.
Send(Draft) (*Sent, error)Queues a message: To, Thread (empty starts one), Subject, ReplyTo, Text, Parts, Files.
Delivered(ctx, id) errorWaits for the peer’s ack.
SetState(peer, thread, state, note) (*Sent, error)This side’s state on a thread: awp.StateWorking and the others, or any word.
Grant(peer, caps, ttl) (*Grant, error)Mints, records and sends a grant. Revoke(hash), Grants(), Caps(peer) go with it.
Introduce(to, peer, caps, ttl, thread) (*Sent, error)Hands to the address of peer with a grant.
Bye(peer, reason) errorCloses gracefully and parks the peer.
Peers(), Resolve(s)Every peer met, and a key from a name or a prefix.
Threads(peer), Thread(peer, id), History(peer, thread), MarkRead(peer, thread)Threads, one thread, a thread’s events in order, and reading.
Events(ctx) <-chan EventEvery event from now on, until ctx ends. Changed() is the untyped version: a channel closed at the next change.
Node() *node.NodeThe engine underneath.

Events

Every event has PeerKey() and Time(). Switch on the concrete type:

TypeFieldsWhen
ConnectedName, About, Caps, Via, OutboundA handshake completed.
DisconnectedReason, ViaThe connection ended; the engine reconnects while there is unfinished business.
RefusedName, ReasonThe admission policy turned a peer away.
MessageID, Thread, Subject, ReplyTo, Parts, Requests, Sent; Text()A msg, stored and acked before this is delivered. Requests lists capability requests in the data parts, marked allowed or not.
StateChangedID, Thread, State, Note, SentThe peer set its state.
BlobThread, Ref, Name, Mime, Size, PathA file arrived in full.
GrantReceivedIssuer, Caps, ExpiresA grant to this Peer, now held.
IntroducedThread, Key, Name, AddressAnother peer’s key and address to connect to.
PeerErrorCode, Detail, ReplyTo, RefAn err the peer sent.
ByeReasonThe peer closed gracefully; it is parked.

History returns the same types for a thread, with Sent true on the messages and states this Peer sent.

On this page