Skip to main content

protocol/network

packages/protocol/src/network

Purpose

Public barrel for connect and presence protocol descriptors.

Public surface

agentCallableNetworkRpcMethods

Variable
Network RPCs callable by agent clients.

AgentConnect

Variable
Authenticate an agent WebSocket connection. Must be the first message on a new agent client connection.
  • Principal: none — the unauthenticated handshake. No principal exists pre-auth, so requires is empty and no gate runs before it.
  • Params: agentKey, minProtocol, maxProtocol.
  • Result: an empty HelloOk; success is the signal (the client holds its own id).
Returns: An empty HelloOk; success is the signal (the client holds its own id).

AgentPresenceSubscribe

Variable

appCallableNetworkRpcMethods

Variable
Network RPCs callable by app clients.

AppConnect

Variable
Authenticate an app WebSocket connection. Must be the first message on a new app client connection.
  • Principal: none — the unauthenticated handshake. No principal exists pre-auth, so requires is empty and no gate runs before it.
  • Params: appKey, minProtocol, maxProtocol.
  • Result: an empty HelloOk; success is the signal (the client holds its own id).
Returns: An empty HelloOk; success is the signal (the client holds its own id).

AppPresenceSubscribe

Variable

checkProtocolRange

Function

compareProtocolVersion

Function

HelloOk

TypeAlias

InvalidProtocolVersionError

Class

networkNotifications

Variable
Network notifications emitted by the server.

networkRpcMethods

Variable
Network RPCs accepted by the server.

PROTOCOL_VERSION

Variable
The published package version is also the wire-protocol version.

ProtocolMismatchError

Class
Raised by connect methods when the client’s [minProtocol, maxProtocol] range does not bracket the server’s PROTOCOL_VERSION. The server’s connect handlers raise it BEFORE auth resolution so old clients are rejected at the version gate. data carries the diagnostic { reason, serverVersion, clientMinProtocol, clientMaxProtocol }, concretely typed so error.data.reason narrows at every reader.

ProtocolMismatchReason

TypeAlias
Reason discriminant carried in ProtocolMismatchError.data.reason: server-above-client-max — the server is newer than the client’s maxProtocol; the client must update. server-below-client-min — the client is newer than the server supports.

Files

  • connect.ts
  • index.ts
  • presence.ts