agent-hub-mcp
Version:
Universal AI agent coordination platform based on Model Context Protocol (MCP)
1 lines • 2.58 kB
Source Map (JSON)
{"version":3,"sources":["../src/checker.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { execSync } from 'child_process';\nimport { basename } from 'path';\n\nimport type { JsonRpcResponse, MessagesResponse } from './types';\n\n// Agent Hub Message Checker - TypeScript version\n// Uses MCP server communication to check for pending messages\n\nfunction main() {\n try {\n // Get agent ID from current directory name\n const agentId = basename(process.cwd());\n\n // Prepare JSON-RPC request to get messages without marking as read\n const payload = JSON.stringify({\n jsonrpc: '2.0',\n id: 1,\n method: 'tools/call',\n params: {\n name: 'get_messages',\n arguments: {\n agent: agentId,\n markAsRead: false,\n },\n },\n });\n\n // Execute the agent-hub-mcp server with the payload\n const result = execSync(`echo '${payload}' | agent-hub-mcp 2>/dev/null`, {\n encoding: 'utf8',\n timeout: 2000,\n });\n\n // Parse JSON-RPC response\n const response: JsonRpcResponse = JSON.parse(result);\n const messagesData: MessagesResponse = JSON.parse(response.result.content[0].text);\n\n // Count unread messages\n const unreadCount = messagesData.messages.filter(message => !message.read).length;\n\n // Output notification if there are unread messages\n if (unreadCount > 0) {\n const hookOutput = {\n systemMessage: `📬 You have ${unreadCount} unread messages from other agents. Type '/hub:sync' to check.`,\n suppressOutput: true,\n };\n\n // eslint-disable-next-line no-console\n console.log(JSON.stringify(hookOutput));\n }\n\n process.exit(0);\n } catch {\n // Fail silently to avoid disrupting Claude Code\n process.exit(0);\n }\n}\n\nmain();\n"],"mappings":";;;AAEA,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AAOzB,SAAS,OAAO;AACd,MAAI;AAEF,UAAM,UAAU,SAAS,QAAQ,IAAI,CAAC;AAGtC,UAAM,UAAU,KAAK,UAAU;AAAA,MAC7B,SAAS;AAAA,MACT,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,WAAW;AAAA,UACT,OAAO;AAAA,UACP,YAAY;AAAA,QACd;AAAA,MACF;AAAA,IACF,CAAC;AAGD,UAAM,SAAS,SAAS,SAAS,OAAO,iCAAiC;AAAA,MACvE,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAGD,UAAM,WAA4B,KAAK,MAAM,MAAM;AACnD,UAAM,eAAiC,KAAK,MAAM,SAAS,OAAO,QAAQ,CAAC,EAAE,IAAI;AAGjF,UAAM,cAAc,aAAa,SAAS,OAAO,aAAW,CAAC,QAAQ,IAAI,EAAE;AAG3E,QAAI,cAAc,GAAG;AACnB,YAAM,aAAa;AAAA,QACjB,eAAe,sBAAe,WAAW;AAAA,QACzC,gBAAgB;AAAA,MAClB;AAGA,cAAQ,IAAI,KAAK,UAAU,UAAU,CAAC;AAAA,IACxC;AAEA,YAAQ,KAAK,CAAC;AAAA,EAChB,QAAQ;AAEN,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK;","names":[]}