Skip to content

encodeEnvelope

encodeEnvelope(env): string

Defined in: packages/protocol/src/lib/envelope.ts:440

Serializes any envelope to the wire string. The inverse of the decode* functions; a plain JSON encode, isolated here so the contract has one encode/decode pair callers can reach for.

ClientEnvelope | ServerEnvelope

string

// connector side (client → engine host)
ws.send(encodeEnvelope(ChartRequestMessage({ sessionId, request })));
// host side (engine host → client)
ws.send(encodeEnvelope(EngineErrorMessage({ error: 'boom', requestId })));