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 sources16d ago| #1 | /** |
| #2 | * HERMES x402 TUI — Payments & Protocol Panel |
| #3 | * |
| #4 | * Shows x402 / pay.sh / A2A / confidential agent status and payment history. |
| #5 | */ |
| #6 | |
| #7 | import chalk from 'chalk'; |
| #8 | import type { DashboardState } from '../state.js'; |
| #9 | |
| #10 | function statusDot(online: boolean | string): string { |
| #11 | if (online === 'online' || online === true) return chalk.green('●'); |
| #12 | if (online === 'degraded') return chalk.yellow('◐'); |
| #13 | return chalk.red('○'); |
| #14 | } |
| #15 | |
| #16 | function shortSig(sig: string): string { |
| #17 | if (sig.length <= 12) return sig; |
| #18 | return sig.slice(0, 6) + '…' + sig.slice(-4); |
| #19 | } |
| #20 | |
| #21 | export function renderPayments(state: DashboardState, height: number): string[] { |
| #22 | const lines: string[] = []; |
| #23 | const { usdcBalance, clawdBalance, lastPayment, totalSpent, a2aConnections, |
| #24 | confidentialMode, darkDefiArmed, payshStatus, activeModel } = state; |
| #25 | |
| #26 | lines.push(chalk.cyan('┌─ x402 PAYMENTS & PROTOCOLS ───┐')); |
| #27 | |
| #28 | // Balance |
| #29 | const bal = usdcBalance > 0 ? usdcBalance.toFixed(2) : '0.00'; |
| #30 | lines.push(`│ ${chalk.cyan('BALANCE')} │`); |
| #31 | lines.push(`│ ${chalk.bold.green(bal + ' USDC').padEnd(32)}│`); |
| #32 | lines.push(`│ ${chalk.hex('#ff00ff')(clawdBalance.toFixed(0) + ' $CLAWD').padEnd(32)}│`); |
| #33 | lines.push(`│ Spent: ${chalk.yellow('$' + totalSpent.toFixed(4)).padEnd(23)}│`); |
| #34 | |
| #35 | lines.push(chalk.gray('│ ──────────────────────────── │')); |
| #36 | |
| #37 | // Protocol status |
| #38 | lines.push(`│ ${chalk.cyan('PROTOCOLS')} │`); |
| #39 | lines.push(`│ ${statusDot('online')} x402 ${chalk.white('ENABLED').padEnd(20)} │`); |
| #40 | lines.push(`│ ${statusDot(payshStatus)} pay.sh ${chalk.white(payshStatus.toUpperCase()).padEnd(20)} │`); |
| #41 | lines.push(`│ ${statusDot('online')} MPP ${chalk.white('ENABLED').padEnd(20)} │`); |
| #42 | lines.push(`│ ${statusDot('online')} AP2 ${chalk.white('ENABLED').padEnd(20)} │`); |
| #43 | |
| #44 | lines.push(chalk.gray('│ ──────────────────────────── │')); |
| #45 | |
| #46 | // A2A connections |
| #47 | const active = a2aConnections.filter(c => c.status === 'connected'); |
| #48 | lines.push(`│ ${chalk.cyan('A2A AGENTS')} (${active.length}/${a2aConnections.length}) │`); |
| #49 | for (const conn of a2aConnections.slice(0, 3)) { |
| #50 | const d = statusDot(conn.status === 'connected'); |
| #51 | const id = conn.agentId.slice(0, 12).padEnd(12); |
| #52 | const lat = conn.latencyMs > 0 ? chalk.gray(conn.latencyMs + 'ms') : chalk.gray('---'); |
| #53 | lines.push(`│ ${d} ${chalk.white(id)} ${lat.padEnd(8)} │`); |
| #54 | } |
| #55 | if (a2aConnections.length === 0) { |
| #56 | lines.push('│ No A2A peers yet │'); |
| #57 | } |
| #58 | |
| #59 | lines.push(chalk.gray('│ ──────────────────────────── │')); |
| #60 | |
| #61 | // Agent / model |
| #62 | lines.push(`│ ${chalk.cyan('INFERENCE')} │`); |
| #63 | const modelLabel = activeModel.toUpperCase().slice(0, 20).padEnd(20); |
| #64 | lines.push(`│ Model: ${chalk.hex('#ff00ff')(modelLabel.slice(0, 14)).padEnd(24)}│`); |
| #65 | |
| #66 | lines.push(chalk.gray('│ ──────────────────────────── │')); |
| #67 | |
| #68 | // Security flags |
| #69 | lines.push(`│ ${chalk.cyan('SECURITY')} │`); |
| #70 | const confStr = confidentialMode ? chalk.green('✓ ON ') : chalk.red('✗ OFF'); |
| #71 | const darkStr = darkDefiArmed ? chalk.green('✓ ARMED ') : chalk.yellow('○ DISARMED'); |
| #72 | lines.push(`│ Confidential : ${confStr.padEnd(16)}│`); |
| #73 | lines.push(`│ Dark DeFi : ${darkStr.padEnd(16)}│`); |
| #74 | |
| #75 | lines.push(chalk.gray('│ ──────────────────────────── │')); |
| #76 | |
| #77 | // Last payment |
| #78 | lines.push(`│ ${chalk.cyan('LAST PAYMENT')} │`); |
| #79 | if (lastPayment) { |
| #80 | const amt = lastPayment.amount.toFixed(4); |
| #81 | const proto = lastPayment.protocol.toUpperCase().padEnd(4); |
| #82 | const conf = lastPayment.confidential ? chalk.green('🔒') : chalk.gray(' '); |
| #83 | lines.push(`│ ${chalk.yellow(amt)} ${chalk.white(lastPayment.asset)} via ${chalk.magenta(proto)} ${conf} │`); |
| #84 | lines.push(`│ ${chalk.gray(shortSig(lastPayment.signature)).padEnd(33)}│`); |
| #85 | const res = lastPayment.resource.slice(0, 26).padEnd(26); |
| #86 | lines.push(`│ ${chalk.gray(res).padEnd(33)}│`); |
| #87 | } else { |
| #88 | lines.push('│ No payments yet │'); |
| #89 | lines.push('│ │'); |
| #90 | lines.push('│ │'); |
| #91 | } |
| #92 | |
| #93 | lines.push(chalk.cyan('└────────────────────────────────┘')); |
| #94 | |
| #95 | while (lines.length < height) lines.push(''); |
| #96 | return lines; |
| #97 | } |
| #98 |