MCPcopy Create free account
hub / github.com/EvoMap/evolver / ensureEnvelope

Function ensureEnvelope

src/proxy/envelope.js:48–57  ·  view source on GitHub ↗

* Wrap `body` in a GEP-A2A envelope unless it already is one. * * When the caller hands us a pre-built envelope, sender_id is still forced * to the proxy's own node_id: callers must not be able to impersonate * another node through the proxy (same rule as the ATP passthrough routes). * * @para

(messageType, body, senderId)

Source from the content-addressed store, hash-verified

46 * @returns {object} Full protocol envelope
47 */
48function ensureEnvelope(messageType, body, senderId) {
49 const b = body || {};
50 const isEnvelope = b.protocol === PROTOCOL_NAME
51 && typeof b.message_type === 'string'
52 && b.payload && typeof b.payload === 'object';
53 if (isEnvelope) {
54 return { ...b, sender_id: senderId || b.sender_id || null };
55 }
56 return buildEnvelope(messageType, b, senderId);
57}
58
59module.exports = { buildEnvelope, ensureEnvelope, PROTOCOL_NAME, PROTOCOL_VERSION };

Callers 2

_wrapA2aMethod · 0.85

Calls 1

buildEnvelopeFunction · 0.85

Tested by

no test coverage detected