No description
  • Rust 93.8%
  • HTML 3.4%
  • JavaScript 1.9%
  • CSS 0.9%
Find a file
despiegk d802eae3f1
Some checks failed
Build and Test / build (push) Failing after 3s
Test / test (push) Failing after 3s
refactor: migrate socket resolution to herolib_core and add generated SDK client
- Replace local socket_base_dir() helpers in hero_browser and hero_browser_server
  with herolib_core::base::resolve_socket_path / resolve_socket_path_with_override
- Remove duplicate BUILD_NR const from hero_browser_admin and hero_browser_server
  (already provided by service_base!() macro)
- Add prepare_sockets() call in hero_browser_admin startup
- Add startup banner to hero_browser CLI
- Add generated OpenRPC client for hero_browser_sdk

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 09:17:35 +02:00
.forgejo/workflows ci: rename release artifacts to target-triple shape (home#212) (#23) 2026-05-06 16:03:38 +00:00
crates refactor: migrate socket resolution to herolib_core and add generated SDK client 2026-05-17 09:17:35 +02:00
docs refactor: rename hero_browser_mcp references to hero_browser 2026-04-20 12:35:19 +02:00
examples/rhai Clean up project structure: remove old scripts, reorganize examples, enhance server and UI 2026-03-20 18:11:03 +01:00
.gitignore chore: add .hero/ to .gitignore 2026-05-12 17:00:01 +02:00
Cargo.toml fix: remove hardcoded /Volumes/T7 [patch] section and fix .gitignore 2026-05-12 15:37:56 +02:00
Cargo.toml.hero_builder_backup chore: upgrade dependency versions to canonical form (1.0) 2026-05-09 00:11:11 +02:00
CLAUDE.md refactor: rename hero_browser_ui -> hero_browser_admin (ui.sock -> admin.sock) (#24) 2026-05-08 02:05:59 +00:00
PURPOSE.md chore: consolidate build config and inline startup banners 2026-05-16 15:41:46 +02:00
README.md fix(hero_service_test): comply with Hero service conventions 2026-05-15 07:23:32 +02:00

Hero Browser

Headless browser automation with MCP protocol support and Rhai scripting.

Architecture

Multi-crate workspace following Hero OS conventions:

hero_browser/
├── Cargo.toml
├── crates/
│   ├── hero_browser_sdk/    (lib: types, browser pool, activity log)
│   ├── hero_browser_server/ (bin: MCP daemon, OpenRPC, Unix socket + TCP 8884)
│   ├── hero_browser/        (bin: CLI client, script runner)
│   ├── hero_browser_admin/  (bin: Axum admin dashboard)
│   └── hero_browser_rhai/   (lib: Rhai scripting bindings)

Dependency Graph

hero_browser_sdk  (no internal deps)
     ↑         ↑          ↑           ↑
  server     CLI         admin      rhai

Sockets & Ports

Component Socket TCP Port
Server (MCP) $HERO_SOCKET_DIR/hero_browser/rpc.sock 8884 (env: HERO_BROWSER_MCP_PORT)
Admin UI $HERO_SOCKET_DIR/hero_browser/admin.sock

HERO_SOCKET_DIR defaults to ~/hero/var/sockets.

Important: The MCP server listens on both the Unix socket and TCP port 8884. The TCP port is required for Claude Code MCP integration (claude mcp add --transport http hero_browser http://localhost:8884/mcp). Do not remove the TCP listener.

Features

  • MCP Server: Control browsers via Model Context Protocol (HTTP transport)
  • Rhai Scripting: Write automation scripts with a simple scripting language
  • Shebang Support: Run scripts directly with #!/usr/bin/env hero_browser
  • Visible Mode: Debug scripts by watching the browser in action with --show flag
  • Admin Dashboard: Monitor sessions and activity in real-time

Quick Start

# Install all binaries and register with hero_proc
lab service browser --install
lab service browser --start

# Check status
lab service browser --status

# Stop
lab service browser --stop

Requirements

  • Google Chrome (macOS) or Chromium (Linux)
  • Rust 1.82+

MCP Server

The hero_browser_server binary provides a Model Context Protocol server for Claude Code integration.

# Start (managed by lab)
lab service browser --start

# Verify health
curl -s --unix-socket ~/hero/var/sockets/hero_browser/rpc.sock \
  http://localhost/health | jq .

API endpoints on rpc.sock (and TCP 8884):

  • POST /rpc — JSON-RPC 2.0 / OpenRPC dispatch
  • GET /openrpc.json — OpenRPC document
  • GET /health — Health check
  • GET /.well-known/heroservice.json — Discovery manifest
  • GET /api/sessions — List active browser sessions
  • GET /api/activity — Recent MCP activity log
  • POST /mcp — MCP streamable HTTP transport

Claude Code Configuration

The server auto-configures on startup. Manual setup (or to re-register after a restart):

claude mcp remove hero_browser
claude mcp add --scope user --transport http hero_browser http://localhost:8884/mcp

Admin Dashboard

The hero_browser_admin binary provides a web dashboard for monitoring browser sessions and activity.

Served from $HERO_SOCKET_DIR/hero_browser/admin.sock and proxied through hero_router at /<service>/admin/.

CLI

The hero_browser binary provides a CLI for running Rhai scripts.

# Run a Rhai script
hero_browser script.rhai

# Run with visible browser
hero_browser --show script.rhai

Smoke Tests

# Health check
curl -s --unix-socket ~/hero/var/sockets/hero_browser/rpc.sock \
  http://localhost/health | jq .

# OpenRPC doc
curl -s --unix-socket ~/hero/var/sockets/hero_browser/rpc.sock \
  http://localhost/openrpc.json | jq '.methods[].name'

# Discovery manifest
curl -s --unix-socket ~/hero/var/sockets/hero_browser/rpc.sock \
  http://localhost/.well-known/heroservice.json | jq .

# JSON-RPC ping
curl -s --unix-socket ~/hero/var/sockets/hero_browser/rpc.sock \
  -X POST http://localhost/rpc \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"system.ping","params":{}}'

Available Rhai Functions

Browser Lifecycle

  • browser_create() - Create new browser, returns browser_id
  • browser_create_with_options(opts) - Create with options
  • browser_destroy(browser_id) - Close browser
  • browser_list() - List active browser IDs

Page Operations

  • page_create(browser_id) - Create new page
  • page_navigate(browser_id, page_id, url) - Navigate to URL
  • page_navigate_back/forward(browser_id, page_id) - History navigation
  • page_url/content/title(browser_id, page_id) - Get page info
  • page_screenshot(browser_id, page_id) - Take screenshot (base64)
  • page_screenshot_save(browser_id, page_id, path) - Save screenshot
  • page_close(browser_id, page_id) - Close page

Element Interaction

  • element_click(browser_id, page_id, selector) - Click element
  • element_type(browser_id, page_id, selector, text) - Type text
  • element_hover(browser_id, page_id, selector) - Hover
  • element_wait(browser_id, page_id, selector, timeout_ms) - Wait for element
  • element_drag_drop(browser_id, page_id, source, target) - Drag and drop

JavaScript, Cookies, Network, Accessibility

  • js_execute(browser_id, page_id, script) - Execute JavaScript
  • cookies_get/set/delete(...) - Cookie management
  • network_install/requests/clear(...) - Network monitoring
  • accessibility_tree/snapshot(...) - Accessibility info
  • console_install/messages/clear(...) - Console capture
  • viewport_set/set_mobile(...) - Viewport control
  • key_press(browser_id, page_id, key) - Keyboard input
  • dialog_accept/dismiss(...) - Dialog handling

Documentation

License

Apache-2.0