Skip to content

About

A hybrid CLI, Web UI, and Electron desktop app for stealthy browser automation with Playwright, real-time scheduling, and task management

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Ghost Runner

A stealthy browser automation tool built with Playwright and anti-detection plugins, featuring a modern React dashboard for managing tasks, schedules, and settings.

Features

Core Capabilities

  • Stealth Mode: Persistent Chromium browser context with playwright-extra and puppeteer-extra-plugin-stealth to evade bot detection
  • Session Persistence: Automatic cookie and session storage in user_data/ directory
  • Geolocation Control: Configurable browser geolocation via Web UI

Task Management

  • Record & Replay: Use Playwright Codegen to record tasks, then replay them headlessly
  • Public/Private Tasks: Store shared tasks in tasks/public/ or private tasks in tasks/private/ (git-ignored)
  • Failure Tracking: Automatic detection of element not found, navigation failures, and timeouts with deduplication

Scheduling

  • Cron Jobs: Schedule recurring tasks with preset or custom cron expressions
  • One-Time Tasks: Execute tasks at a specific date/time (auto-removed after execution)
  • Calendar View: Visualize all scheduled tasks with react-big-calendar
  • Sleep Prevention: macOS caffeinate integration prevents system sleep during scheduled tasks

Dashboard

  • Real-Time Logs: Live execution log streaming via Socket.io
  • Focused Pages: Sidebar navigation between Overview, Tasks (run + schedule), Failures, Data, Logs, and Settings
  • Calm Dark Theme: A single warm, quiet dark theme with no decorative animation
  • Warnings Panel: Track task failures with color-coded error types and occurrence counts
  • Info Gathering: Dashboard for viewing data collected by info-gathering tasks

Tech Stack

Layer Technologies
Backend Node.js, TypeScript, Express, Socket.io, tsx (runtime TS)
Frontend React 19, Vite, TypeScript, Tailwind CSS, shadcn/ui, Radix UI
Automation Playwright, playwright-extra, puppeteer-extra-plugin-stealth
Scheduling node-cron, cron-parser
State React Query, localStorage (dashboard layout)

Prerequisites

  • Node.js v18+ (v20+ recommended)
  • npm or compatible package manager
  • macOS or Linux (Windows may work but is untested)

Installation

git clone https://github.com/vinicius741/ghost-runner.git
cd ghost-runner
npm install

Quick Start

1. First-Time Login Setup

To maintain persistent sessions (e.g., staying logged into Google):

npm run setup-login

A browser window opens. Log in to your desired services, then browse briefly to ensure session data is saved to user_data/.

Verify the session:

npm run verify-login

2. Start the Web UI

npm run ui

This starts:

  • Backend server on http://localhost:3333
  • Frontend dev server on http://localhost:5173 (with API proxy)

Open http://localhost:3333 in your browser.

3. Create Your First Task

  1. Click Record New Task in the dashboard
  2. Enter a task name and select public/private
  3. Perform your browser actions in the Codegen window
  4. Copy the generated code to the created task file
  5. Run the task from the dashboard

Commands Reference

Development

Command Description
npm run ui Start dev environment (backend + frontend with hot reload)
npm run ui:prod Build frontend and start production server
npm run build:server Compile backend/core TypeScript to dist/
npm run build:electron Compile Electron main/preload to dist-electron/
cd frontend && npm run dev Start frontend dev server only
cd frontend && npm run build Build frontend for production

Desktop (Electron)

Command Description
npm run electron:dev Build frontend/server/electron and launch desktop app
npm run electron:start Launch desktop app from existing build artifacts
npm run electron:dist Build a macOS distributable in release/
pnpm release Publish the next desktop release through GitHub Actions

Desktop builds can download and install updates from GitHub Releases. See Desktop updates for the release workflow and signing setup.

When running as a desktop app, mutable runtime data is stored in the Electron app data directory (~/Library/Application Support/<App>/ghost-runner) instead of the git repository. On first launch, the app copies tasks/public and tasks/private (if present) into that runtime directory.

The app automatically handles ASAR archives for packaged builds. Since ASAR archives are read-only and cannot be used as a working directory for spawned processes, the TaskRunner detects ASAR paths and uses the parent directory for child process execution. This ensures tasks, scheduler, and setup-login processes spawn correctly in both development and packaged environments.

If you want the desktop shell to connect to an already-running Ghost Runner server instead of starting the embedded backend, set one of these environment variables before launch:

  • GHOST_RUNNER_SERVER_URL=http://127.0.0.1:3333
  • GHOST_RUNNER_API_URL=http://127.0.0.1:3333 (legacy fallback name)

CLI / Automation

Command Description
npm run bot -- --task=name Run a specific task via CLI
npm run record -- --name=mytask --type=private Launch Playwright Codegen recorder
npm run schedule Run scheduler headless
npm run setup-login Launch browser for manual login setup
npm run verify-login Verify session persistence

Testing

Command Description
npm test Run backend tests
cd frontend && npm run test Run frontend unit tests (Vitest)
cd frontend && npm run test:ui Run frontend tests with UI
cd frontend && npm run test:coverage Run tests with coverage

Project Structure

ghost-runner/
├── src/                          # Backend source
│   ├── core/                     # Task runner, scheduler, recorder
│   │   ├── index.ts              # CLI entry point
│   │   ├── scheduler.ts          # Cron scheduler
│   │   ├── record-new-task.ts    # Codegen launcher
│   │   ├── errors.ts             # Structured error types
│   │   ├── pageWrapper.ts        # Monitored Playwright Page
│   │   └── taskReporter.ts       # Status reporting
│   ├── server/                   # Express + Socket.io server
│   │   ├── index.ts              # Server entry point
│   │   ├── controllers/          # API controllers
│   │   ├── routes/               # Route definitions
│   │   ├── services/             # Business logic
│   │   └── repositories/         # Data persistence
│   ├── config/                   # Browser configuration
│   └── utils/                    # Utility functions
├── frontend/                     # React frontend
│   └── src/
│       ├── components/           # React components
│       │   ├── dashboard/        # Dashboard widgets
│       │   └── ui/               # shadcn/ui primitives
│       ├── hooks/                # Custom React hooks
│       ├── lib/                  # Utilities
│       └── types.ts              # TypeScript types
├── tasks/                        # Automation scripts
│   ├── public/                   # Shared tasks (tracked)
│   └── private/                  # Private tasks (git-ignored)
├── user_data/                    # Browser profile (DO NOT DELETE)
├── schedule.json                 # Scheduler configuration
├── settings.json                 # Global settings
├── failures.json                 # Task failure records
└── info-gathering.json           # Cached info-gathering data

API Endpoints

Method Endpoint Description
GET /api/health Health check
GET /api/tasks List available tasks
POST /api/tasks/run Execute a task
POST /api/record Start task recording
GET/PUT /api/schedule Read/write schedule
GET/PUT /api/settings Read/write settings
GET/DELETE /api/failures List/clear failures
POST /api/failures/:id/dismiss Dismiss a failure
GET/DELETE /api/info-gathering List/clear gathered data

Socket.io Events

Event Direction Description
task-started Server → Client Task execution began
task-completed Server → Client Task finished successfully
task-failed Server → Client Task execution failed
log Server → Client Log line from task/scheduler
scheduler-status Server → Client Scheduler running status
failure-recorded Server → Client New failure recorded
info-data-updated Server → Client Info-gathering data updated

Task Template

Tasks are JavaScript modules that export a run(page) function:

// tasks/public/my-task.js
export async function run(page) {
  await page.goto('https://example.com');
  await page.waitForSelector('#content');
  // Your automation logic here
}

Documentation

License

ISC

About

A hybrid CLI, Web UI, and Electron desktop app for stealthy browser automation with Playwright, real-time scheduling, and task management

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages