AgentClient speak one protocol of JSON frames, encoded with SuperJSON so that a Date, a Map, a Set or undefined in a payload survives the wire. @telnyx/edge-runtime/agent-socket exports the frame functions and types for servers, and @telnyx/edge-runtime/client exports the same set for clients, with isFrame and applyMergePatch besides.
Versions
Every frame carries its version as
v and its kind as kind.
Functions
v1 Frames
AnyFrame is the union of every v1 frame.
ErrorCode is "method_not_found", "method_private", "method_error", "protocol_error" or "version_mismatch".
v2 Frames
AnyFrameV2 is the union of the attach-mode frames, AnyKnownFrame the union of both versions, and FrameKindV2 the v2 kind values. Each v2 frame is exported as its own type.
ErrorCodeV2 is any ErrorCode, "unauthorized" or "subscription_denied".
Streams and Claims
Stream is "state", "messages" or "events", the streams a v2 client can subscribe to. Claim is "read", "rpc" or any other string: a capability authorize grants a connection. With authorize configured, a call frame needs the "rpc" claim.