MCPcopy Create free account
hub / github.com/SethGammon/Citadel / createEnvelope

Function createEnvelope

core/hooks/normalize-event.js:77–97  ·  view source on GitHub ↗
(runtime, nativeEventName, payload)

Source from the content-addressed store, hash-verified

75 const normalized = { ...(toolInput || {}) };
76 if (typeof normalized.file_path === 'string') normalized.file_path = normalized.file_path.replace(/\\/g, '/');
77 if (typeof normalized.path === 'string') normalized.path = normalized.path.replace(/\\/g, '/');
78 return normalized;
79}
80
81function createEnvelope(runtime, nativeEventName, payload) {
82 const eventMap = runtime === 'codex' ? CODEX_EVENT_MAP : CLAUDE_EVENT_MAP;
83 const normalizedEventId = eventMap[nativeEventName] || nativeEventName || 'unknown';
84 const toolName = normalizeToolName(payload.tool_name || payload.tool_type || payload.toolName || '');
85 const toolInput = normalizePathFields(payload.tool_input || payload.toolInput || {});
86
87 return {
88 event_id: normalizedEventId,
89 runtime,
90 native_event_name: nativeEventName || null,
91 timestamp: payload.timestamp || new Date().toISOString(),
92 session_id: payload.session_id || null,
93 turn_id: payload.turn_id || null,
94 cwd: payload.cwd || null,
95 transcript_path: payload.transcript_path || null,
96 model: payload.model || null,
97 tool_name: toolName,
98 tool_input: toolInput,
99 raw: payload,
100 };

Callers 3

normalizeClaudeHookInputFunction · 0.85
normalizeCodexHookInputFunction · 0.85

Calls 2

normalizeToolNameFunction · 0.85
normalizePathFieldsFunction · 0.85

Tested by

no test coverage detected