| 31 | const KNOWN_SERVERS = new Set([]); |
| 32 | |
| 33 | function main() { |
| 34 | let input = ''; |
| 35 | process.stdin.setEncoding('utf8'); |
| 36 | process.stdin.on('data', (chunk) => { input += chunk; }); |
| 37 | process.stdin.on('end', () => { |
| 38 | let event = {}; |
| 39 | try { event = JSON.parse(input); } catch { /* partial input ok */ } |
| 40 | |
| 41 | const hookEventName = event.hook_event_name || ''; |
| 42 | const isResult = hookEventName === 'ElicitationResult' || |
| 43 | event.accepted !== undefined; |
| 44 | |
| 45 | const serverName = event.server_name || event.mcp_server || null; |
| 46 | const accepted = event.accepted !== undefined ? event.accepted : null; |
| 47 | const sessionId = event.session_id || null; |
| 48 | |
| 49 | const eventLabel = isResult ? 'elicitation-result' : 'elicitation'; |
| 50 | |
| 51 | health.increment('elicitation', 'count'); |
| 52 | |
| 53 | health.logTiming('elicitation', 0, { |
| 54 | event: eventLabel, |
| 55 | server: serverName, |
| 56 | accepted: accepted, |
| 57 | known_server: serverName ? KNOWN_SERVERS.has(serverName) : false, |
| 58 | session_id: sessionId, |
| 59 | }); |
| 60 | |
| 61 | // No auto-response: exit 0 with no stdout = defer to user |
| 62 | process.exit(0); |
| 63 | }); |
| 64 | } |
| 65 | |
| 66 | main(); |