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

Function buildEnvelope

src/proxy/envelope.js:21–34  ·  view source on GitHub ↗

* Build a GEP-A2A protocol envelope around a payload. * * Strict hub endpoints (/a2a/hello, /a2a/fetch, /a2a/validate, ...) run * isValidProtocolMessage server-side and reject bare bodies with * 400 invalid_protocol_message. Lenient endpoints such as * /a2a/assets/search accept raw bodies and m

(messageType, payload, senderId)

Source from the content-addressed store, hash-verified

19 * @returns {object} Full protocol envelope
20 */
21function buildEnvelope(messageType, payload, senderId) {
22 if (!messageType || typeof messageType !== 'string') {
23 throw new Error('buildEnvelope: messageType is required');
24 }
25 return {
26 protocol: PROTOCOL_NAME,
27 protocol_version: PROTOCOL_VERSION,
28 message_type: messageType,
29 message_id: 'msg_' + Date.now() + '_' + crypto.randomBytes(4).toString('hex'),
30 sender_id: senderId || null,
31 timestamp: new Date().toISOString(),
32 payload: payload || {},
33 };
34}
35
36/**
37 * Wrap `body` in a GEP-A2A envelope unless it already is one.

Callers 3

ensureEnvelopeFunction · 0.85
helloMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected