repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources15d ago| #1 | /** |
| #2 | * HERMES x402 TUI — A2A Simulation & Status |
| #3 | * |
| #4 | * Simulates Google A2A (Agent-to-Agent) handshakes and |
| #5 | * updates the dashboard state with connection info. |
| #6 | * Real A2A calls go through x402/a2a-agent.ts in the main lib. |
| #7 | */ |
| #8 | |
| #9 | import { addLog, type DashboardState, type A2AConnection } from './state.js'; |
| #10 | |
| #11 | const KNOWN_PEERS: A2AConnection[] = [ |
| #12 | { |
| #13 | agentId: 'clawd-router', |
| #14 | endpoint: 'https://router.solanaclawd.com/a2a', |
| #15 | status: 'disconnected', |
| #16 | latencyMs: 0, |
| #17 | protocol: 'x402', |
| #18 | }, |
| #19 | { |
| #20 | agentId: 'paysh-gate', |
| #21 | endpoint: 'https://pay.sh/a2a', |
| #22 | status: 'disconnected', |
| #23 | latencyMs: 0, |
| #24 | protocol: 'ap2', |
| #25 | }, |
| #26 | ]; |
| #27 | |
| #28 | export async function initA2AConnections(state: DashboardState): Promise<void> { |
| #29 | state.a2aConnections = KNOWN_PEERS.map(p => ({ ...p })); |
| #30 | |
| #31 | for (const conn of state.a2aConnections) { |
| #32 | conn.status = 'handshaking'; |
| #33 | addLog(state, 'A2A', `Handshaking ${conn.agentId} via ${conn.protocol.toUpperCase()}…`, 'a2a'); |
| #34 | |
| #35 | try { |
| #36 | const start = Date.now(); |
| #37 | const agentCardUrl = `${conn.endpoint}/.well-known/agent.json`; |
| #38 | const r = await fetch(agentCardUrl, { |
| #39 | signal: AbortSignal.timeout(4000), |
| #40 | headers: { 'x-clawd-version': '1.7.0', 'x-protocol': conn.protocol }, |
| #41 | }); |
| #42 | conn.latencyMs = Date.now() - start; |
| #43 | |
| #44 | if (r.ok) { |
| #45 | conn.status = 'connected'; |
| #46 | addLog(state, 'A2A', `${conn.agentId} ESTABLISHED (${conn.latencyMs}ms)`, 'a2a'); |
| #47 | } else { |
| #48 | // 402 means the endpoint is alive but requires payment — still count as "connected" |
| #49 | if (r.status === 402) { |
| #50 | conn.status = 'connected'; |
| #51 | conn.latencyMs = Date.now() - start; |
| #52 | addLog(state, 'A2A', `${conn.agentId} READY (402 gated, ${conn.latencyMs}ms)`, 'a2a'); |
| #53 | } else { |
| #54 | conn.status = 'disconnected'; |
| #55 | addLog(state, 'A2A', `${conn.agentId} ${r.status} — unreachable`, 'warn'); |
| #56 | } |
| #57 | } |
| #58 | } catch { |
| #59 | conn.status = 'disconnected'; |
| #60 | addLog(state, 'A2A', `${conn.agentId} timeout — offline`, 'warn'); |
| #61 | } |
| #62 | } |
| #63 | |
| #64 | // pay.sh status inferred from paysh-gate connection |
| #65 | const paysh = state.a2aConnections.find(c => c.agentId === 'paysh-gate'); |
| #66 | state.payshStatus = paysh?.status === 'connected' ? 'online' : 'offline'; |
| #67 | |
| #68 | } |
| #69 |