Commit Graph

25 Commits

Author SHA1 Message Date
Adrià Arrufat
6177d51c4e agent: use action enum for tool calls and trim REPL input
- Update `buildToolCall` to use `browser_tools.Action` enum.
- Trim whitespace from REPL input in `Agent.zig`.
- Replace `expectEqualStrings` with `expectString` in tests.
2026-05-21 23:06:34 +02:00
Adrià Arrufat
e9943a3976 command: use Action enum for ToolCall name
Replaces the string `name` in `ToolCall` with `action: browser_tools.Action`.
This avoids repeated string-to-enum parsing and simplifies schema lookups.
Also updates `zenai` dependency to use its JSON duplication helper.
2026-05-21 22:51:52 +02:00
Adrià Arrufat
459893f414 script: unify PandaScript to slash commands
Unifies PandaScript syntax by replacing uppercase keywords with slash
commands (e.g., `/goto`, `/click`, `/fill`). Refactors the `Command`
representation to use a generic tool call structure backed by schemas.

BREAKING CHANGE: Uppercase PandaScript keywords (GOTO, CLICK, TYPE, etc.)
are no longer supported. All scripts must use slash commands.
2026-05-21 20:38:21 +02:00
Adrià Arrufat
ceb5f368f0 script: rename raw_line to opener_line 2026-05-21 18:01:46 +02:00
Adrià Arrufat
88d56c63d0 script: optimize formatting and avoid redundant writes
- Skip atomic writes if the content is unchanged.
- Use allocating writer to reduce allocations during formatting.
2026-05-21 17:37:13 +02:00
Adrià Arrufat
55a50746fa script: move helper functions into Command union
Renames `Command.zig` to `command.zig` and moves associated functions
like `parse`, `toToolCall`, and `canHeal` directly into the `Command`
union. This simplifies usage from `Command.Command` to just `Command`.
2026-05-21 17:13:19 +02:00
Adrià Arrufat
061a740dbb script: improve reliability, CRLF support, and formatting
- Prevent UB in `applyReplacements` with pointer assertions.
- Reorder `writeAtomic` to build content before writing backup.
- Strip trailing `\r` in `ScriptIterator` for CRLF compatibility.
- Use shorter representation for `SCROLL` commands.
2026-05-19 10:43:20 +02:00
Adrià Arrufat
cbe81e150b agent: condense prompts and tool descriptions 2026-05-14 14:59:58 +02:00
Adrià Arrufat
2862feb7c4 agent: improve recording quality and tool guidance
- Filter redundant `extract` calls in recordings to reduce noise.
- Scrub literal `LP_*` secrets from recorded commands for portability.
- Throw a descriptive error in `extract` when no selectors match.
- Update tool descriptions and guidance to favor a `tree` ->
  `nodeDetails` -> `extract` workflow for more robust selectors.
2026-05-14 13:36:36 +02:00
Adrià Arrufat
9ac2c03a7e tools: unify eval and extract tool dispatching
- Add `callEvalLike` to consolidate tools returning `EvalResult`.
- Update `Agent` and `MCP` to use the new helper.
- Route failed data commands to stderr in `CommandExecutor`.
- Update CSS selector guidance in `script.zig`.
2026-05-14 11:14:11 +02:00
Adrià Arrufat
faba86cf82 docs(browser.tools): clarify extract tool schema and examples 2026-05-14 10:48:13 +02:00
Adrià Arrufat
3d8621561a tools: add extract tool for structured data
Adds the `extract` tool for lifting structured data via JSON schemas.
Updates the command system to support recording and replaying
extraction steps in PandaScript.
2026-05-14 10:32:59 +02:00
Adrià Arrufat
48b8c4fb8c script: simplify formatHealReplacement 2026-05-13 14:34:12 +02:00
Adrià Arrufat
6538a34f56 browser: separate operational and JS errors in eval
Changes `EvalResult` to a union and uses Zig errors for operational
failures, distinguishing them from JavaScript execution errors.
Also removes redundant `stringifyJson` in favor of standard library.
2026-05-13 14:27:28 +02:00
Adrià Arrufat
b2454a9190 chore: add license headers to source files 2026-05-13 13:20:36 +02:00
Adrià Arrufat
cc59dd64b9 script: make ScriptIterator.next fallible 2026-05-13 12:40:07 +02:00
Adrià Arrufat
f624077218 refactor: propagate OOM in substituteEnvVars and inline heal header
- Update `substituteEnvVars` to return `OutOfMemory` error instead of
  silently returning the original string on failure.
- Simplify `execFill` to always use the original text for display.
- Inline the `writeHealHeader` helper in `src/script.zig`.
2026-05-13 10:31:16 +02:00
Adrià Arrufat
947e9be5fc script: add test for healing multi-line EVAL blocks 2026-05-13 10:03:32 +02:00
Adrià Arrufat
c41955ade3 script: move script module to root src directory 2026-05-11 19:56:36 +02:00
Adrià Arrufat
1a84f56160 refactor: relocate PandaScript and improve agent reliability
Moves script logic to `browser/script/` for shared use. Implements
message rollback on API failure, caches environment variables, and
fixes a potential panic in the spinner.

- Relocate Command, Recorder, and Verifier to `src/browser/script/`
- Implement message rollback on API and synthesis failures in Agent
- Cache `LP_*` environment variables process-wide with mutex protection
- Fix potential panic in Spinner during backward clock jumps
- Improve Recorder to handle write failures and multi-line comments
- Update documentation regarding attachments and path safety
2026-05-11 19:49:15 +02:00
Adrià Arrufat
b5777ce35c agent: support listing LP_* variables in getEnv 2026-05-11 12:34:36 +02:00
Adrià Arrufat
5b5e42cbaa refactor: optimize string building and unify text extraction 2026-05-09 17:47:28 +02:00
Adrià Arrufat
372c0a12a2 agent: simplify logic and cleanup comments 2026-05-08 08:23:19 +02:00
Adrià Arrufat
77fc818976 refactor: optimize tool calls and improve script healing 2026-05-07 20:30:49 +02:00
Adrià Arrufat
c6ccd83ac4 mcp: add pandascript recording and self-healing tools
Adds tools to record sessions and heal scripts over MCP. Refactors
shared logic to `script.zig` and adds a TTY spinner for the agent.
2026-05-07 20:11:40 +02:00