Skip to main content

protocol/network

packages/protocol/src/network

Purpose

Public barrel for connect 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).

checkProtocolRange

Function
Executes the check protocol range operation. Returns: The check protocol range result.

compareProtocolVersion

Function
Executes the compare protocol version operation. Returns: The compare protocol version result.

HelloOk

TypeAlias
Represents hello ok values.

httpBaseUrl

Function
The HTTP control-plane origin for the same server. Returns: The http base url result.

InvalidProtocolVersionError

Class
Reports invalid protocol version failures.

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.

serverBaseUrl

Variable
Throwing constructor for addresses a caller already knows are well-formed, such as one a locally started server just reported. Decode with Schema.decodeEither(ServerBaseUrl) wherever the value comes from configuration or another package.

ServerBaseUrl

TypeAlias
A MoltZap server address carrying no path, query, or fragment, over http, https, ws, or wss.

serverBaseUrlSchema

Variable
Decodes either address a caller is likely to hold — the base URL or the socket endpoint — into the path-free base. Any other path fails.

serverUrlTypeCanaries

Variable
Retains both the runtime positive control and compile-time negative proof.

webSocketUrl

Function
The socket endpoint a client dials for the given server. Returns: The web socket url result.

Files

  • connect.ts
  • index.ts
  • server-url.ts
  • server-url.types-check.ts