No description
  • Rust 57.9%
  • Shell 17%
  • HTML 14.8%
  • JavaScript 7%
  • CSS 2.2%
  • Other 1.1%
Find a file
Mahmoud Emad e34a4195da
All checks were successful
Build & Test / check (pull_request) Successful in 2m30s
Build & Test / check (push) Successful in 3m15s
Merge pull request 'Merge main to development' (#21) from main into development
Reviewed-on: #21
2026-04-07 14:25:57 +00:00
.forgejo/workflows fix: main is the only allowed branch 2026-04-02 15:05:39 +02:00
config/repos add example config/repos template for hero_proc service definition 2026-04-05 06:49:27 +02:00
crates/hero_router fix: resolve all clippy warnings for CI 2026-04-07 16:16:28 +02:00
scripts cleanup scripts and migrate to CLI-managed service registration 2026-04-05 05:25:59 +02:00
.gitignore Add *.db to .gitignore to exclude database files from version control 2026-03-22 10:15:32 +01:00
buildenv.sh fix: update BINARIES to single hero_router binary 2026-04-07 15:39:03 +02:00
Cargo.lock fix: use git dependencies for hero_rpc crates instead of local paths 2026-04-07 16:03:52 +02:00
Cargo.toml fix: use git dependencies for hero_rpc crates instead of local paths 2026-04-07 16:03:52 +02:00
Makefile refactor: consolidate hero_router crates into single binary 2026-04-07 05:43:58 +02:00
README.md feat: split server/ui ports, add TCP to server, enable CORS 2026-04-06 10:38:13 +02:00
SPEC.md feat: rename hero_inspector to hero_router with new routing endpoints 2026-04-06 09:11:13 +02:00

Hero Router

A CLI tool and web dashboard for discovering and documenting RPC services.

Hero Router scans your Hero OS service ecosystem, fetches OpenRPC specifications, generates documentation, and provides an interactive web UI for exploring your services.

Features

  • Auto-discovery — scan ~/hero/var/sockets/ for live RPC services
  • Web Dashboard — interactive two-pane interface with Bootstrap 5 styling
  • CLI Tool — inspect services, generate docs, list services without running a server
  • Manual imports — add any OpenRPC spec by local file path or HTTP(S) URL
  • Documentation generation — produce Markdown and HTML docs
  • JSON-RPC 2.0 API — all data operations available via RPC
  • MCP Gateway — expose each healthy service as MCP-compatible endpoint
  • Dark/Light theme — responsive design with theme toggle

Architecture

hero_router/
├── Cargo.toml                         # workspace root
├── Makefile
├── buildenv.sh
├── scripts/
│   ├── build_lib.sh
│   └── download-assets.sh
├── crates/
│   ├── hero_router/                # core library (herolib_router)
│   ├── hero_router_server/         # JSON-RPC backend + TCP routing entry point
│   ├── hero_router_sdk/            # generated OpenRPC client
│   ├── hero_router_ui/             # web admin dashboard
│   └── hero_router_examples/       # SDK usage examples
Crate Type Description
herolib_router library Core logic: scanner, cache, probe, doc generation
hero_router_server binary JSON-RPC backend, TCP routing entry point, CLI subcommands
hero_router_sdk library Generated typed client from OpenRPC spec
hero_router_ui binary Web admin dashboard
hero_router_examples examples SDK usage examples

Sockets & Ports

Component Unix Socket TCP Port Purpose
hero_router_server ~/hero/var/sockets/hero_router_server.sock 9998 JSON-RPC backend + routing entry point
hero_router_ui ~/hero/var/sockets/hero_router_ui.sock 9997 Web admin dashboard
  • hero_router_server always binds TCP — it is the single TCP entry point that proxies traffic from /<service>/rpc to per-service Unix sockets. It also exposes CORS headers so browser clients at any origin can call /rpc directly.
  • hero_router_ui provides the admin web interface and can run independently of the server.

Quick Start

# Clone and build
git clone ssh://forge.ourworld.tf/lhumina_code/hero_router.git
cd hero_router
make install

# Run both server and UI
make run

# Or run in debug mode
make rundev

Running with a custom port

# Server on a non-default port
hero_router_server --port 8998

# UI on a non-default port
hero_router_ui --port 8997

CLI Usage

# List discovered services
hero_router_server list

# Scan for services
hero_router_server scan --verbose

# Fetch a service spec
hero_router_server spec hero_books

# Generate Markdown documentation
hero_router_server markdown hero_books --output docs.md

# Generate HTML documentation
hero_router_server html hero_books --output docs.html

JSON-RPC API

The server is accessible at http://127.0.0.1:9998/rpc (TCP) or via its Unix socket. CORS is enabled so browser clients at any origin can POST directly.

Method Description
router.services List all services
router.service Get single service by ID
router.scan Trigger re-scan
router.openrpc Get cached OpenRPC spec
router.markdown Generate Markdown docs
router.html Generate HTML docs
router.status Health and stats
router.add Register manual spec
router.remove Remove manual spec
router.mcp_logs MCP gateway logs
router.mcp_logs_clear Clear MCP logs
admin.health Simple health check
rpc.discover Return this OpenRPC spec

Configuration

Setting Default CLI Flag Env Var
Server TCP port 9998 --port (hero_router_server) ROUTER_SERVER_PORT
UI TCP port 9997 --port (hero_router_ui) ROUTER_UI_PORT
Socket directory ~/hero/var/sockets HERO_SOCKET_DIR
Refresh interval 30 seconds ROUTER_REFRESH
Probe timeout 3 seconds ROUTER_PROBE_TIMEOUT

Building

make build       # Build release binaries
make check       # Fast code check
make test        # Run tests
make lint        # Run clippy
make install     # Build and install to ~/hero/bin
make clean       # Remove build artifacts

Security

  • TCP listeners are 127.0.0.1 only (never 0.0.0.0)
  • No authentication required (localhost-only access)
  • All OpenRPC text is HTML-escaped by Askama
  • Router only calls rpc.discover — never executes arbitrary methods

License

See LICENSE file in repository root.