# Agent mode `lightpanda agent` runs a browsing agent backed by Lightpanda's headless engine. It can act as: - an **LLM agent** that drives the browser with tool calls (`--provider`), - a **scripted runner** that replays a `.lp` script deterministically, - a **dumb REPL** for hand-driven PandaScript with no LLM at all, - a **one-shot task runner** that prints a single answer to stdout (`--task`), - an **MCP server** that exposes the agent itself as a single `task` tool for other agents to delegate to (`--mcp`). All five modes share the same browser tools (`goto`, `click`, `fill`, `tree`, `markdown`, `search`, ...). The same set is exposed over MCP via `lightpanda mcp`, so an agent script and an MCP client see the same surface. ## Quick start ```console # Interactive REPL with an LLM ./lightpanda agent --provider anthropic # Dumb REPL (no API key, PandaScript only) ./lightpanda agent # Replay a recorded script ./lightpanda agent session.lp # Replay then continue interactively, appending new commands to the file ./lightpanda agent -i session.lp # One-shot: ask a question, capture the answer on stdout ./lightpanda agent --provider gemini --task "what is on the front page of hn?" # MCP server: expose a single `task` tool for other agents to delegate to ./lightpanda agent --mcp --provider anthropic ``` ## Providers and API keys | Provider | Flag | API key env | |-------------|------------------------|--------------------------------------| | Anthropic | `--provider anthropic` | `ANTHROPIC_API_KEY` | | OpenAI | `--provider openai` | `OPENAI_API_KEY` | | Gemini | `--provider gemini` | `GOOGLE_API_KEY` or `GEMINI_API_KEY` | | Ollama | `--provider ollama` | none (local) | Defaults: `--model` falls back to a sensible per-provider default; `--base-url` overrides the API endpoint (Ollama defaults to `http://localhost:11434/v1`). Without `--provider`, the REPL still works for PandaScript commands. Natural language, `LOGIN`, `ACCEPT_COOKIES`, and `--self-heal` all require a provider. ## PandaScript PandaScript is a tiny, line-oriented DSL for browser actions. Each line is one command. Comments start with `#`. Strings are quoted with `'`, `"`, or `'''…'''` for values that mix both quote styles. Quoting rules are content-aware so that recorded scripts round-trip through the parser. | Command | Form | Notes | |------------------|---------------------------------------|------------------------------------------------------| | `GOTO` | `GOTO ` | Navigate. URL is unquoted. | | `CLICK` | `CLICK ''` | CSS selector. | | `TYPE` | `TYPE '' ''` | Fills an input. `$LP_*` env refs auto-resolve. | | `WAIT` | `WAIT ''` | Wait for selector to be present in the DOM. | | `SCROLL` | `SCROLL [x] [y]` | Default `(0, 0)`. | | `HOVER` | `HOVER ''` | | | `SELECT` | `SELECT '' ''` | `