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 — OODA Loop Panel |
| #3 | * |
| #4 | * Visualizes the current OODA phase with neon indicators. |
| #5 | */ |
| #6 | |
| #7 | import chalk, { type ChalkInstance } from 'chalk'; |
| #8 | import type { DashboardState, OODAPhase } from '../state.js'; |
| #9 | |
| #10 | const PHASE_ORDER: OODAPhase[] = ['observe', 'orient', 'decide', 'act', 'learn']; |
| #11 | |
| #12 | const PHASE_LABELS: Record<OODAPhase, string> = { |
| #13 | observe: 'OBSERVE', |
| #14 | orient: 'ORIENT ', |
| #15 | decide: 'DECIDE ', |
| #16 | act: 'ACT ', |
| #17 | learn: 'LEARN ', |
| #18 | idle: 'IDLE ', |
| #19 | }; |
| #20 | |
| #21 | const PHASE_COLORS: Record<OODAPhase, ChalkInstance> = { |
| #22 | observe: chalk.cyan, |
| #23 | orient: chalk.yellow, |
| #24 | decide: chalk.magenta, |
| #25 | act: chalk.red, |
| #26 | learn: chalk.green, |
| #27 | idle: chalk.gray, |
| #28 | }; |
| #29 | |
| #30 | function dot(active: boolean, phase: OODAPhase, current: OODAPhase): string { |
| #31 | if (current === phase) return chalk.bold.white('◉'); |
| #32 | if (active) return PHASE_COLORS[phase]('○'); |
| #33 | return chalk.gray('·'); |
| #34 | } |
| #35 | |
| #36 | export function renderOODA(state: DashboardState, height: number): string[] { |
| #37 | const lines: string[] = []; |
| #38 | const { oodaPhase, pulseIntervalSec, cycleCount, memory } = state; |
| #39 | |
| #40 | const currentIdx = PHASE_ORDER.indexOf(oodaPhase === 'idle' ? 'learn' : oodaPhase); |
| #41 | |
| #42 | lines.push(chalk.cyan('┌─ OODA LOOP ────────────────┐')); |
| #43 | |
| #44 | for (let i = 0; i < PHASE_ORDER.length; i++) { |
| #45 | const phase = PHASE_ORDER[i]!; |
| #46 | const isActive = i <= currentIdx || oodaPhase === 'idle'; |
| #47 | const isCurrent = phase === oodaPhase; |
| #48 | const d = dot(isActive, phase, oodaPhase); |
| #49 | const label = isCurrent |
| #50 | ? chalk.bold.white(PHASE_LABELS[phase]) |
| #51 | : isActive |
| #52 | ? PHASE_COLORS[phase](PHASE_LABELS[phase]) |
| #53 | : chalk.gray(PHASE_LABELS[phase]); |
| #54 | |
| #55 | const arrow = i < PHASE_ORDER.length - 1 ? chalk.gray(' →') : ' '; |
| #56 | const marker = isCurrent ? chalk.bold.hex('#ff00ff')(' ◄') : ' '; |
| #57 | lines.push(`│ ${d} ${label}${arrow}${marker} │`); |
| #58 | |
| #59 | // Connector arrow between phases |
| #60 | if (i < PHASE_ORDER.length - 1) { |
| #61 | lines.push(chalk.gray('│ ↓ │')); |
| #62 | } |
| #63 | } |
| #64 | |
| #65 | lines.push(chalk.cyan('└────────────────────────────┘')); |
| #66 | |
| #67 | // Status rows |
| #68 | const phaseColor = PHASE_COLORS[oodaPhase] ?? chalk.gray; |
| #69 | const phaseLabel = oodaPhase.toUpperCase().padEnd(7); |
| #70 | lines.push(` Phase : ${phaseColor.bold(phaseLabel)}`); |
| #71 | lines.push(` Pulse : ${chalk.yellow(pulseIntervalSec + 's')}`); |
| #72 | lines.push(` Cycles: ${chalk.cyan(String(cycleCount))}`); |
| #73 | lines.push(` Mem : ${chalk.green('K:' + memory.known)} ${chalk.yellow('L:' + memory.learned)} ${chalk.magenta('I:' + memory.inferred)}`); |
| #74 | |
| #75 | // Pad to height |
| #76 | while (lines.length < height) lines.push(''); |
| #77 | |
| #78 | return lines; |
| #79 | } |
| #80 |