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 — Agent Activity Log Panel |
| #3 | * |
| #4 | * Shows real-time log entries from all OODA/payment/A2A activity. |
| #5 | */ |
| #6 | |
| #7 | import chalk, { type ChalkInstance } from 'chalk'; |
| #8 | import type { DashboardState, LogEntry } from '../state.js'; |
| #9 | |
| #10 | const LEVEL_COLOR: Record<LogEntry['level'], ChalkInstance> = { |
| #11 | info: chalk.cyan, |
| #12 | warn: chalk.yellow, |
| #13 | error: chalk.red, |
| #14 | pay: chalk.green, |
| #15 | a2a: chalk.magenta, |
| #16 | trade: chalk.hex('#ff8c00'), |
| #17 | }; |
| #18 | |
| #19 | const PHASE_COLOR: Record<string, ChalkInstance> = { |
| #20 | OBSERVE: chalk.cyan, |
| #21 | ORIENT: chalk.yellow, |
| #22 | DECIDE: chalk.magenta, |
| #23 | ACT: chalk.red, |
| #24 | LEARN: chalk.green, |
| #25 | PAY: chalk.green, |
| #26 | A2A: chalk.hex('#ff00ff'), |
| #27 | TRADE: chalk.hex('#ff8c00'), |
| #28 | SYSTEM: chalk.gray, |
| #29 | }; |
| #30 | |
| #31 | function fmtTime(ts: number): string { |
| #32 | const d = new Date(ts); |
| #33 | return d.toTimeString().slice(0, 8); |
| #34 | } |
| #35 | |
| #36 | function truncate(s: string, max: number): string { |
| #37 | return s.length > max ? s.slice(0, max - 1) + '…' : s; |
| #38 | } |
| #39 | |
| #40 | export function renderLog( |
| #41 | state: DashboardState, |
| #42 | width: number, |
| #43 | maxLines: number, |
| #44 | ): string[] { |
| #45 | const lines: string[] = []; |
| #46 | const innerWidth = width - 4; // ║ + space on each side |
| #47 | |
| #48 | // Header |
| #49 | const model = chalk.hex('#ff00ff').bold(state.activeModel.toUpperCase()); |
| #50 | const headerLabel = `AGENT LOG [${state.activeModel.toUpperCase()}]`; |
| #51 | lines.push(chalk.cyan('╠') + chalk.cyan('═'.repeat(width)) + chalk.cyan('╣')); |
| #52 | lines.push( |
| #53 | chalk.cyan('║') + |
| #54 | ' ' + chalk.bold.white('AGENT LOG') + |
| #55 | ' ' + chalk.gray('[') + model + chalk.gray(']') + |
| #56 | ' '.repeat(Math.max(0, innerWidth - headerLabel.length - 1)) + |
| #57 | chalk.cyan('║'), |
| #58 | ); |
| #59 | |
| #60 | const entries = state.log.slice(0, maxLines); |
| #61 | const padLen = maxLines - entries.length; |
| #62 | |
| #63 | for (const entry of entries) { |
| #64 | const timeStr = chalk.gray(fmtTime(entry.ts)); |
| #65 | const phaseColor = PHASE_COLOR[entry.phase] ?? chalk.white; |
| #66 | const phaseStr = phaseColor(`[${entry.phase.padEnd(7)}]`); |
| #67 | const levelColor = LEVEL_COLOR[entry.level] ?? chalk.white; |
| #68 | const msgColored = levelColor(truncate(entry.msg, innerWidth - 22)); |
| #69 | const raw = `[${fmtTime(entry.ts)}] [${entry.phase.padEnd(7)}] ${truncate(entry.msg, innerWidth - 22)}`; |
| #70 | const pad = Math.max(0, innerWidth - raw.length); |
| #71 | lines.push( |
| #72 | chalk.cyan('║') + |
| #73 | ' ' + timeStr + ' ' + phaseStr + ' ' + msgColored + |
| #74 | ' '.repeat(pad) + |
| #75 | chalk.cyan('║'), |
| #76 | ); |
| #77 | } |
| #78 | |
| #79 | for (let i = 0; i < padLen; i++) { |
| #80 | lines.push(chalk.cyan('║') + ' '.repeat(width) + chalk.cyan('║')); |
| #81 | } |
| #82 | |
| #83 | return lines; |
| #84 | } |
| #85 |