# Mantis A unified perception-reasoning-action agent for computer use. Given a structured plan, Mantis drives a real browser (or any Xvfb-rendered application), takes actions, extracts structured data, and produces both a JSON result and an optional polished video walkthrough. [![Docs](https://img.shields.io/badge/docs-mkdocs--material-teal)](https://mercurialsolo.github.io/mantis/) [![License: AGPL v3](https://img.shields.io/badge/license-AGPL_v3-blue.svg)](LICENSE) ``` ┌──────────────────────┐ ┌─────────────────────────┐ 3p ──► │ Mantis CUA service │ ──────► │ Target app (Chrome, │ caller │ Holo3 + Claude │ │ file manager, terminal, │ │ /v1/predict │ │ LibreOffice, …) │ └──────────┬───────────┘ └─────────────────────────┘ │ ▼ ┌──────────────────────┐ │ Result + lead CSV + │ │ polished screencast │ └──────────────────────┘ ``` ## What you get - **Reliable multi-step plans.** A structured `MicroPlanRunner` enforces section / gate / loop semantics so even small models behave on long workflows. - **Cheap inference at click latency.** Holo3-35B-A3B (GGUF on a single GPU) for tactical click / scroll / type / drag actions; Anthropic Claude only for surgical reasoning steps (extract / verify / ground a click). - **Real browser, real desktop.** Xvfb + Chrome + xdotool. No Playwright fingerprints. Works against sites with bot detection. - **Cloud-portable.** Same image runs on Baseten, Modal, EKS, GKE, or your own Docker host. - **Multi-tenant out of the box.** Per-key auth, per-tenant rate limits, idempotency keys, HMAC-signed webhooks, URL allowlists, Prometheus metrics. - **Screencast included.** Every run can produce a title-card → captioned-run-with-action-overlays → outro video that's ready to share. ## Verified end-to-end | Path | Run | Result | |---|---|---| | Modal | 3-listing extraction | 2 / 3 leads with phone, ~$0.42, 13 min | | Baseten | 3-listing extraction | 3 / 3 leads with phone, ~$0.42, 9.5 min | Both deployments produce structured JSON rows (year / make / model / price / phone / url) for every successfully extracted listing. ## Documentation The full docs site is at **[mercurialsolo.github.io/mantis](https://mercurialsolo.github.io/mantis/)** (or `mkdocs serve` from this checkout). | If you want to… | Go here | |---|---| | Try it in 5 minutes | [Quickstart](docs/getting-started/quickstart.md) | | See what Mantis is good at | [Use cases](docs/getting-started/use-cases.md) — listings, jobs, real-estate, products, news, CRM edits, refunds, social posting, multi-app workflows | | Copy-paste a working plan | [Recipes](src/mantis_agent/recipes/) — 7 shipped recipes (marketplace listings, marketplace planner, staff CRM, job listings, form submit, search results, docs lookup); 5 more worked examples in the [docs](docs/integrations/recipes.md) | | Understand the architecture | [Concepts](docs/getting-started/concepts.md) · [Architecture](docs/architecture.md) | | Deploy your own instance | [Hosting](docs/hosting/index.md) — Baseten / Modal / EKS / GKE / local | | Integrate from your app | [Client](docs/client/index.md) — auth, plans, polling, recordings | | Run a multi-tenant fleet | [Operations](docs/operations/index.md) — tenant keys, rate limits, webhooks, metrics | | Look up an HTTP endpoint | [API reference](docs/api.md) | | Replace a Claude-CUA-style backend | [Any-agent integration](docs/integrations/any-agent.md) | ## Quick start (no deploy needed) The reference deployment is live on Baseten. With a tenant token from your operator: ```bash export ENDPOINT="https://model-qvvgkneq.api.baseten.co/production/sync" export BASETEN_API_KEY="..." export MANTIS_API_TOKEN="..." curl -fsS -X POST "$ENDPOINT/v1/predict" \ -H "Authorization: Api-Key $BASETEN_API_KEY" \ -H "X-Mantis-Token: $MANTIS_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "detached": true, "micro": "plans/example/extract_listings.json", "state_key": "first-run", "max_cost": 2, "max_time_minutes": 20, "record_video": true }' ``` Poll for `{action: "status"}` until the run terminates, then `{action: "result"}` to fetch leads, then `GET /v1/runs//video` for the screencast. Full walkthrough in the [Quickstart](docs/getting-started/quickstart.md). ## Install footprint The base install is intentionally slim. Pick the extras for your use case: ```bash pip install -e . # ~5 MB — Pillow only pip install -e ".[client]" # ~10 MB — typed HTTP client (`mantis_agent.client`) pip install -e ".[orchestrator]" # ~10 MB — MicroPlanRunner + remote Holo3 client pip install -e ".[server]" # ~15 MB — FastAPI server + Prometheus pip install -e ".[local-cua]" # ~2 GB — torch + transformers + pyautogui pip install -e ".[full]" # everything pip install -e ".[docs]" # mkdocs + material theme ``` ## Repository layout ``` src/mantis_agent/ core library api_schemas.py PredictRequest + plan validation + caps baseten_server/ FastAPI server package routes.py /v1/predict + /v1/chat/completions + /metrics + /v1/runs/{id}/video runtime.py BasetenCUARuntime — model + run lifecycle middleware.py X-Mantis-Token auth + per-tenant secret resolvers paths.py per-tenant data / Chrome-profile path resolvers logging_setup.py JSON log formatter + per-run log handler brain_holo3.py Holo3 inference client brain_claude.py Claude inference client extraction/ ClaudeExtractor + schema / spam / cache grounding.py ClaudeGrounding (refine click coordinates) gym/ base.py GymEnvironment ABC runner.py GymRunner — sync agent loop micro_runner.py MicroPlanRunner — structured plan executor xdotool_env.py Xvfb + Chrome + xdotool driver presentation.py Cards, captions, action overlays for the polished video recorder.py ffmpeg x11grab wrapper rate_limit.py Token bucket + concurrency gauge per tenant idempotency.py Idempotency-Key cache (24h TTL, file-backed) webhooks.py HMAC-signed run-completion callbacks metrics.py Prometheus counters / gauges / histograms tenant_auth.py JSON keys file → TenantConfig deploy/ cloud paths modal/ Modal entry-points (modal_cua_server.py, ...) baseten/ Baseten Truss configs (holo3, gemma4, ...) aws/ EKS — Terraform + k8s manifests + runbook gke/ GKE — Terraform + k8s manifests + runbook sim_envs/ Dockerized fixture apps for plan smoke-tests docker/ cua.Dockerfile Local CUA loop (Xvfb + xdotool + Chromium) server.Dockerfile Production FastAPI server (CUDA + llama.cpp + Holo3) hud.Dockerfile HUD evaluation harness image local.Dockerfile Local all-in-one dev image docs/ MkDocs site source index.md api.md architecture.md getting-started/ hosting/ client/ operations/ integrations/ reference/ appendix/ diagrams/ FigJam-rendered architecture diagrams scripts/ CLI helpers (run_*.py, monitor_*.sh, baseten_workload.py) plans/ plan files (.txt, .json) benchmarks/ OSWorld / VWA benchmark harnesses training/ distillation + fine-tuning configs tests/ pytest suite ``` ## Development Common tasks are wrapped in a `Makefile` — run `make help` for the full list. ```bash make sync # install locked dev env via uv (one-time) make precommit-install # install the ruff + hygiene pre-commit hook make test # pytest tests/ -q make lint # ruff check . make fmt # ruff auto-fix + format make docs # mkdocs serve → http://127.0.0.1:8000 ``` Don't have `uv`? `pip install -e ".[dev,docs]"` plus the underlying commands (`pytest tests/ -q`, `ruff check .`, `mkdocs serve`) still work — the `Makefile` just keeps them discoverable. ## License GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later). See [LICENSE](LICENSE). Mantis is network-copyleft: if you run a modified version of Mantis as a network service, you must offer the complete corresponding source of your modified version to its users.