(agent: Agent)
| 26 | } |
| 27 | |
| 28 | private async performHealthCheck(agent: Agent): Promise<AgentHealth> { |
| 29 | const startTime = Date.now(); |
| 30 | const protocol = agent.protocol || "mcp"; |
| 31 | |
| 32 | // Only try the protocol the agent declares |
| 33 | const health = protocol === "a2a" |
| 34 | ? await this.tryA2A(agent, startTime) |
| 35 | : await this.tryMCP(agent, startTime); |
| 36 | |
| 37 | logOutboundRequest({ |
| 38 | agent_url: agent.url, |
| 39 | request_type: 'health_check', |
| 40 | user_agent: AAO_UA_HEALTH_CHECK, |
| 41 | response_time_ms: health.response_time_ms ?? (Date.now() - startTime), |
| 42 | success: health.online, |
| 43 | error_message: health.error, |
| 44 | }); |
| 45 | |
| 46 | return health; |
| 47 | } |
| 48 | |
| 49 | private async tryMCP(agent: Agent, startTime: number): Promise<AgentHealth> { |
| 50 | try { |
no test coverage detected