Skip to content

openclawunboxed/clawreflex

Repository files navigation

ClawReflex

Teach OpenClaw to do a repetitive browser task once. It runs automatically forever — no AI cost after that.

You show it the task. It records the steps. Every future run is pure Playwright — fast, free, deterministic. When something breaks, a cheap local model notices and a strong model fixes it. You pay for AI once, not every run.

ClawReflex is an OpenClaw skill that adds browser workflow graduation to your OpenClaw setup.


What it does

Without ClawReflex With ClawReflex
Strong model runs every step, every time Strong model teaches once, then steps aside
Full token cost on every run Token cost only when something breaks
Agent re-discovers the site on every run Compiled Playwright macro — deterministic
Failure is silent or hard to interpret Screenshot + plain-English error on every failure

Requirements

  • OpenClaw installed and running
  • Node.js ≥ 20

Install

macOS:

open install/install-macos.command
# or: bash install/install-linux.sh

Linux:

bash install/install-linux.sh

Windows (PowerShell):

.\install\install-windows.ps1

Restart OpenClaw after install. Then run npm run doctor to confirm everything is connected.


Quick start

Open the OpenClaw dashboard and type:

teach a workflow

The skill asks what site, what task, what counts as success. You confirm. It records and compiles. Then:

# Copy the example input and fill in your values
cp ~/.openclaw/workspace/clawreflex/workflows/<slug>/macro/input.example.json \
   ~/.openclaw/workspace/clawreflex/workflows/<slug>/macro/input.json
# Edit input.json with your real credentials and settings

# Run it
npm run supervise <slug> ~/.openclaw/workspace/clawreflex/workflows/<slug>/macro/input.json

You'll see:

✓  my-workflow  [step 7/7] download file

   Status   : success
   Verdict  : accept  (confidence: 98%)
   Rationale: Deterministic lane completed cleanly.

   Run completed successfully.
   Next run: npm run supervise my-workflow input.json

All commands

npm run doctor                         # check environment and workflow health
npm run teach <observed-run.json>      # compile a workflow from a recorded session
npm run supervise <slug> <input.json>  # run + validate + supervise
npm run run <slug> <input.json>        # run macro only (no supervision)
npm run run-all                        # run all enabled workflows
npm run list                           # show all workflows with health status
npm run verify <slug>                  # re-check validation rules without running
npm run repair <slug>                  # generate a repair prompt for OpenClaw
npm run capture-auth <slug>            # save a browser session (for MFA/SSO sites)
npm run schedule add <slug> --cron "" # register a scheduled run
npm run schedule list                  # list all schedules
npm run schedule remove <slug>         # remove a schedule
npm run export <slug>                  # export a sanitized shareable workflow
npm run import <file-or-url>           # import a workflow
npm run report                         # token cost and ROI summary
npm run help                           # show this command list

Supervisor setup (optional)

By default, ClawReflex uses a local deterministic classifier — no model cost at all on clean runs. To add an AI supervisor for suspicious runs:

Ollama (local, free):

export SUPERVISOR_KIND=ollama
export SUPERVISOR_MODEL=phi3:mini
export SUPERVISOR_BASE_URL=http://localhost:11434

HuggingFace or any OpenAI-compatible API:

export SUPERVISOR_KIND=openai-compat
export SUPERVISOR_MODEL=microsoft/Phi-3-mini-4k-instruct
export SUPERVISOR_BASE_URL=https://api-inference.huggingface.co/v1
export SUPERVISOR_API_KEY=hf_yourTokenHere

Copy .env.example to .env and fill in your values. See config-templates/ for full setup examples.


OCR fallback (optional)

When a Playwright locator fails, ClawReflex can fall back to a local vision model to find the element by screenshot:

ollama pull llava
export CLAWREFLEX_OCR_KIND=ollama-vision
export CLAWREFLEX_OCR_MODEL=llava
export CLAWREFLEX_ENGINE_PATH=/path/to/clawreflex/engine/src

Documentation


Tests

npm test          # 135 unit tests
SKIP_E2E=0 node --test tests/e2e.test.js  # e2e (requires playwright install)

License

MIT

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages