Skip to main content

server-core/network

packages/server/src/network

Purpose

Network-domain utilities.

Public surface

AgentEndpointResolver

Class
Multimap of agent → connection ids, plus a reverse index from connection → agent. All mutators run inside a single Ref.update so the forward and reverse views never disagree, even under concurrent add / remove calls from independent agent/network/connect and disconnect fibers.

agentEndpointResolverLive

Variable
Provides the agent endpoint resolver live runtime value.

AgentEndpointResolverTag

Class
Implements agent endpoint resolver tag.

broadcastNotificationToAgents

Function
Fan a server→client notification out to every live connection of each agent in agentIds. The notification rides the reverse RpcClient on each target connection (fired fork-and-forget, the void result settles on the client’s ack); the client’s reverse RpcServer routes it into its SubscriberRegistry. Replaces the raw socket.write(encodedFrame) path. Returns: The broadcast notification to agents result.

connectAgent

Variable
Provides the connect agent runtime value. Returns: The connect agent result.

connectionId

Variable
Decode a raw connection-id string through the protocol brand constructor. Used by tests that name connections with synthetic strings; production socket accept uses newConnectionId from protocol.

DeliveryAck

Class
Successful single-recipient write. The fan-out variant NetworkSendService.broadcast returns the delivered agent ids in its success channel and absorbs DeliveryError cases.

DeliveryError

TypeAlias
Represents delivery error conditions.

NetworkSendService

Class
Outbound-routing primitive. Use the constructor directly in code; route through NetworkSendServiceTag in DI-aware code.

networkSendServiceLive

Variable
Provides the network send service live runtime value.

NetworkSendServiceTag

Class
Implements network send service tag.

OpaquePayload

TypeAlias
Branded raw-string payload. The send primitive writes the exact bytes to the recipient socket — no parse, no transform, no validate. The nominal brand prevents an unwitting caller from passing an arbitrary string where a wire-ready frame is expected.

Files

  • agent-endpoint-resolver.ts
  • connect.handlers.ts
  • layer.ts
  • network-send.ts
  • notification-broadcast.ts