Commit Graph

41 Commits

Author SHA1 Message Date
Adrià Arrufat
3cc652776b agent: simplify command execution and REPL logic
- Use `std.json.Stringify` for safer JS escaping in `execExtract`.
- Streamline `CommandExecutor` and remove redundant helpers.
- Add "QUIT" as an alias for the "EXIT" command.
- Clean up REPL loop control flow and error reporting in `Agent`.
- Simplify `Recorder` file operations and logging.
2026-04-11 15:33:06 +02:00
Adrià Arrufat
b606d28454 agent: improve command quoting and parsing
Implement content-aware quoting and robust quote stripping to ensure
better round-tripping of Pandascript commands.
2026-04-11 15:13:24 +02:00
Adrià Arrufat
c4cfd5e363 agent: make AI provider optional for "dumb" REPL mode
Allows starting the agent without a provider to use Pandascript
commands without an API key. Commands requiring an LLM and
--self-heal now explicitly require a provider.
2026-04-11 12:34:32 +02:00
Adrià Arrufat
ed8bb7f4b7 agent: update default openai and gemini models 2026-04-11 11:47:24 +02:00
Adrià Arrufat
4a63bbf233 agent: replace --save with --interactive flag
Replays scripts then enters REPL to append new commands to the file.
The --save flag is removed in favor of this new interactive mode.
2026-04-10 20:57:22 +02:00
Adrià Arrufat
3a9573e1ae agent: route data to stdout and actions to stderr 2026-04-10 18:03:57 +02:00
Adrià Arrufat
a5fd70f5dd refactor: improve tool execution and terminal formatting
- Standardize `fill` tool to use `value` instead of `text`.
- Add formatted output methods (`printInfoFmt`, `printErrorFmt`) to `Terminal`.
- Improve error handling in `ToolExecutor` and `browser/tools` by using error unions.
- Deduplicate `minify` utility and remove redundant code comments.
- Refactor tool dispatch to use `Action` enum tags instead of hardcoded strings.
2026-04-10 14:54:51 +02:00
Adrià Arrufat
d1b429655f tools: add selector support for hover, select, and check actions 2026-04-10 14:15:55 +02:00
Adrià Arrufat
d0c36f7e3e terminal: add persistent REPL history
Persists REPL history to .lp-history, except in script mode.
2026-04-10 11:59:55 +02:00
Adrià Arrufat
81413d9291 agent: add scroll command and improve script reliability
Adds the SCROLL command and ensures WAIT actions are recorded.
Refactors TYPE to use the fill tool, adds self-heal retries, and
propagates agent failures to the process exit code.
2026-04-10 11:45:14 +02:00
Adrià Arrufat
7aa11c7006 agent: update CLI args and refactor code 2026-04-09 17:51:56 +02:00
Adrià Arrufat
9a8ad8951f agent: rename missing tool calls to semanticTree and eval 2026-04-09 17:08:35 +02:00
Adrià Arrufat
a1ef413a9a Terminal: add command completion and hints 2026-04-09 17:02:31 +02:00
Adrià Arrufat
61fd69eaae agent: improve script recording logic and formatting 2026-04-09 16:51:54 +02:00
Adrià Arrufat
286976a7c7 browser: centralize tool definitions 2026-04-09 16:07:05 +02:00
Adrià Arrufat
d2a4d388b1 agent: consolidate findNodeIdByText tests 2026-04-08 19:29:54 +02:00
Adrià Arrufat
ad13eb76e2 agent: improve element lookup in CommandExecutor
Replaces heuristic string search with JSON parsing and case-insensitive
matching across multiple fields. Adds unit tests for verification.
2026-04-08 19:21:07 +02:00
Adrià Arrufat
ffb38f268b agent: add --self-heal flag to control self-healing 2026-04-08 18:15:34 +02:00
Adrià Arrufat
8d3d3a2c67 agent: improve command parsing and selector reliability
- Support single quotes in commands for nested CSS selectors.
- Mask password values in interactive element output.
- Update system prompt and recorder for better reproducibility.
- Try CSS selectors first in click actions.
2026-04-08 18:10:04 +02:00
Adrià Arrufat
c242e324f3 browser: auto-resolve env vars in fill tool 2026-04-08 17:17:23 +02:00
Adrià Arrufat
b8ae185cad tools: support CSS selectors for click and fill actions 2026-04-08 16:56:10 +02:00
Adrià Arrufat
796a17ff81 agent: update default AI models 2026-04-08 16:35:10 +02:00
Adrià Arrufat
3cc46f10e2 agent: remove unused allocator from findNodeIdByText 2026-04-08 11:00:00 +02:00
Adrià Arrufat
91264c4995 agent: use zenai.provider.Client directly 2026-04-08 10:34:34 +02:00
Adrià Arrufat
a147f91acc agent: add explicit type to url variable 2026-04-08 08:37:52 +02:00
Adrià Arrufat
bfe223c8ad agent: simplify client init and tool execution 2026-04-08 08:33:08 +02:00
Adrià Arrufat
1aca921327 agent: use Command union for recording 2026-04-08 08:20:06 +02:00
Adrià Arrufat
fa14b0865c agent: use runTools for tool execution loop 2026-04-07 10:13:43 +02:00
Adrià Arrufat
adabc24897 agent: add ollama provider and base-url support 2026-04-07 08:55:33 +02:00
Adrià Arrufat
3fde7fb6b5 Config: remove --api-key CLI flag 2026-04-07 08:34:15 +02:00
Adrià Arrufat
048cb46950 Refactor: extract shared tool execution layer from MCP and agent
Both MCP tools.zig and agent ToolExecutor.zig duplicated the same 20 tool
handlers. This extracts the shared logic into src/browser/tools.zig so new
tools only need to be added once. Reduces total code by ~620 lines while
keeping all 465 tests passing.
2026-04-07 08:05:36 +02:00
Adrià Arrufat
9a442ac5f1 agent: add new browser interaction tools
Adds hover, press, selectOption, setChecked, and findElement tools.
Increases backendNodeId search window in CommandExecutor to 500.
2026-04-07 07:46:40 +02:00
Adrià Arrufat
1f75ce1778 agent: add unit tests for Command, CommandExecutor, and Recorder 2026-04-04 08:28:56 +02:00
Adrià Arrufat
7aabda9392 agent: add recorder, self-healing, env substitution, and security fixes
- Add Recorder for recording REPL sessions to .panda files, with
  --no-record flag and positional file arg support. Skips read-only
  commands (WAIT, TREE, MARKDOWN) per spec.
- Record resolved LLM tool calls as Pandascript commands so the
  generated artifact is deterministic.
- Add self-healing in --run mode: on command failure, prompt the LLM
  with the # INTENT context to resolve an alternative.
- Add LOGIN and ACCEPT_COOKIES high-level commands (LLM-resolved).
- Add multi-line EVAL """...""" support via ScriptIterator.
- Add $VAR_NAME environment variable substitution in command arguments.
- Escape JS strings in execType/execExtract to prevent injection.
- Sanitize output file paths in EXTRACT to prevent path traversal.
2026-04-04 08:14:48 +02:00
Adrià Arrufat
e29f33642c agent: add --run command for deterministic script replay 2026-04-04 07:56:10 +02:00
Adrià Arrufat
d94effb237 agent: improve tool call detection and logging 2026-04-04 07:56:10 +02:00
Adrià Arrufat
3b1ef66b51 agent: add markdown command 2026-04-04 07:56:10 +02:00
Adrià Arrufat
15c0a7be83 agent: add manual command support to REPL
Adds a parser and executor for manual commands like GOTO and CLICK.
Unrecognized input continues to be processed by the AI.
2026-04-04 07:56:10 +02:00
Adrià Arrufat
a5d3d686b8 agent: use arena allocators for messages and tools 2026-04-04 07:56:10 +02:00
Adrià Arrufat
20c31a3f71 agent: remove bold formatting from prompt 2026-04-04 07:56:10 +02:00
Adrià Arrufat
a81a24229b Add interactive agent mode with LLM-powered web browsing
Introduces `lightpanda agent` command that provides a REPL where users
can chat with an AI that uses the browser's tools (goto, markdown, click,
fill, etc.) to browse the web. Uses zenai for multi-provider LLM support
(Anthropic, OpenAI, Gemini) and linenoise v2 for terminal line editing.
2026-04-04 07:56:10 +02:00