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

Function main

hooks_src/notification.js:30–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

28const AUTH_TYPES = new Set(['auth_required', 'auth_success', 'auth_failure', 'auth_error']);
29
30function main() {
31 let input = '';
32 process.stdin.setEncoding('utf8');
33 process.stdin.on('data', (chunk) => { input += chunk; });
34 process.stdin.on('end', () => {
35 let event = {};
36 try { event = JSON.parse(input); } catch { /* partial input ok */ }
37
38 const notificationType = event.notification_type || event.type || 'unknown';
39 const message = event.message || event.notification_message || null;
40 const sessionId = event.session_id || null;
41
42 health.increment('notification', 'count');
43
44 health.logTiming('notification', 0, {
45 event: 'notification',
46 notification_type: notificationType,
47 session_id: sessionId,
48 });
49
50 // Auth events → elevated audit (security-relevant, always log)
51 if (AUTH_TYPES.has(notificationType)) {
52 const severity = AUDIT_TYPES.has(notificationType) ? 'medium' : 'low';
53 health.writeAuditLog('auth-notification', {
54 notification_type: notificationType,
55 message: message ? message.slice(0, 200) : null,
56 severity,
57 });
58 }
59
60 // Idle alerts → diagnostic log entry
61 if (notificationType === 'idle' || notificationType === 'agent_idle') {
62 health.writeAuditLog('idle-notification', {
63 notification_type: notificationType,
64 severity: 'low',
65 });
66 }
67
68 process.exit(0);
69 });
70}
71
72main();

Callers 1

notification.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected