Commit Graph

77 Commits

Author SHA1 Message Date
Adrià Arrufat
c30ccae5fb terminal: improve log routing and navigation error reporting
- Route logs through a terminal sink to avoid trampling the spinner.
- Track and format the last navigation error in browser tools.
2026-05-22 19:58:02 +02:00
Adrià Arrufat
0219ee66b7 tools: add argument diagnostics
Validate tool arguments like `waitUntil` before parsing to provide
clearer error messages with expected enum values.
2026-05-22 19:33:53 +02:00
Adrià Arrufat
f7a4d1f6e2 terminal: unify tool and action result printing
Replaces `printActionResult` and `printToolResult` with a single
`printToolOutcome` function. This unifies the output path and adds
red/green color coding for tool failures and successes.
2026-05-22 19:05:46 +02:00
Adrià Arrufat
1309407e01 script: unify heal formatting and move TTY helpers
- Merge `formatHealReplacement` and `formatHealReplacementLines` using
  a new `HealBody` union.
- Move `interactiveTty` and `promptNumberedChoice` to `Terminal.zig`.
- Relocate and consolidate tests for `canHeal` and `isRecorded`.
- Make internal `Schema` functions private.
2026-05-22 16:19:46 +02:00
Adrià Arrufat
486d0d53a9 agent: inline CommandRunner and simplify Command union 2026-05-22 15:50:36 +02:00
Adrià Arrufat
3a792c7c1c command: centralize slash command parsing and retry logic 2026-05-22 15:17:59 +02:00
Adrià Arrufat
8fb3c7baed tools: restructure browser tools and script schemas
- Replace `Action` enum with `Tool` enum using exhaustive switches
- Extract `ScriptIterator` to `Iterator.zig`
- Refactor `schema.zig` into `Schema.zig`
- Move string substitution logic into `tools.zig`
- Clean up `SlashCommand.zig` to only handle REPL meta-commands
2026-05-22 13:41:04 +02:00
Adrià Arrufat
a3eeec0b26 agent: use global tools and simplify meta commands
- Initialize tools once globally instead of allocating per-agent.
- Refactor meta commands to use an enum for cleaner dispatch.
- Remove unused `findSchemaCanonical` and simplify command parsing.
2026-05-21 23:24:21 +02:00
Adrià Arrufat
8cf431b771 agent: remove ToolExecutor abstraction
Inlines the browser, session, and node registry management directly
into Agent. Updates CommandRunner to use Session and Registry directly,
and calls browser_tools.call without the ToolExecutor wrapper.
2026-05-21 22:02:27 +02:00
Adrià Arrufat
d16f8a032e script: support triple-quoted strings and optimize lookups
- Add support for triple-quoted strings (''' and """) in the tokenizer
  and quote stripper.
- Avoid allocations in `stripQuotes` by returning slices.
- Optimize schema lookups using O(1) enum-based canonical resolution.
- Skip env var substitution if "$LP_" is not present in the string.
2026-05-21 21:33:05 +02:00
Adrià Arrufat
7f60d73338 use global schemas and enum-based tool matching
- Use `SlashCommand.globalSchemas()` instead of passing schemas around.
- Use `browser_tools.Action` enums for tool matching in Agent and Verifier.
- Optimize string substitution and quote stripping with early exits.
2026-05-21 21:08:02 +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
3e0a59c96a browser: avoid dangling pointers in lpEnvNames
Walk std.c.environ dynamically and duplicate names into a provided
allocator instead of caching pointers to std.os.environ, which can
be invalidated by setenv.
2026-05-21 17:28:49 +02:00
Adrià Arrufat
19e3e7b74e agent: simplify spinner and remove tool failure state 2026-05-19 13:16:51 +02:00
Adrià Arrufat
92733763d8 refactor: use explicit type names and encapsulate spinner state
- Replace `Self` with `Recorder` and `Verifier` for improved clarity.
- Add `Spinner.isEnabled()` to encapsulate atomic state access.
- Shorten and refine various comments across the codebase.
2026-05-19 11:13:15 +02:00
Adrià Arrufat
8d250ac7b0 agent: rename --task-attachment to --attach
Adds the `-a` short flag, improves CLI validation for one-shot mode,
and ensures `--model` takes precedence over `--pick-model`.

BREAKING CHANGE: `--task-attachment` has been renamed to `--attach`.
2026-05-19 11:02:46 +02:00
Adrià Arrufat
0efbcc1289 spinner: make enabled flag atomic
Updates the `enabled` field in `Spinner` to use `std.atomic.Value(bool)`.
This prevents potential race conditions between the agent thread and
the spinner worker thread when checking or updating the state.
2026-05-19 10:23:24 +02:00
Adrià Arrufat
373920841c agent: add /verbosity slash command 2026-05-15 10:51:21 +02:00
Adrià Arrufat
b2454a9190 chore: add license headers to source files 2026-05-13 13:20:36 +02:00
Adrià Arrufat
96fce3c56f refactor: unify tool UI and browser action finalization
- Add `beginTool` and `endTool` to `Terminal` to encapsulate spinner logic.
- Consolidate navigation awaiting and context tagging in browser tools
  via a new `finalizeAction` helper.
2026-05-13 12:10:07 +02:00
Adrià Arrufat
ecd27791e4 terminal: skip isocline setup in script mode
Prevents unwanted terminal probes (ESC[6n) when not in REPL mode by
wrapping Isocline initialization in a conditional.
2026-05-12 15:10:06 +02:00
Adrià Arrufat
bfe9f98fb7 agent: unify REPL result and error formatting 2026-05-12 12:22:17 +02:00
Adrià Arrufat
11fb6a3f6e agent: improve slash command parsing and spinner logic
- Use `SlashCommand.splitNameRest` for cleaner command handling.
- Centralize `max_hint_slots` constant and add assertions.
- Refactor `Spinner` thread management and rendering code.
2026-05-12 11:58:24 +02:00
Adrià Arrufat
ef1dde49a6 terminal: improve command highlighting with prefix checking 2026-05-12 11:29:34 +02:00
Adrià Arrufat
19c33499cb terminal: delay error highlighting until token is closed 2026-05-12 11:25:04 +02:00
Adrià Arrufat
60a880a88c terminal: simplify command completion logic
Removes hardcoded starters and uses trailing spaces to trigger hints for
commands with parameters. Updates isocline dependency.
2026-05-12 11:19:48 +02:00
Adrià Arrufat
619e99d803 repl: add progressive argument hints for commands 2026-05-12 10:57:27 +02:00
Adrià Arrufat
13fc1ee044 refactor: optimize agent tool handling and browser helpers
- Omit tool definitions when tool_choice is none to reduce request size.
- Skip tool argument stringification in low-verbosity modes.
- Optimize capToolOutput to avoid large memory copies during truncation.
- Introduce requireFrame and renderJson helpers in browser tools.
- Use a pre-computed tool names array for faster lookups.
2026-05-12 09:59:26 +02:00
Adrià Arrufat
45da2c8196 refactor: localize keyword check and simplify command tests 2026-05-11 20:08:38 +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
c1b4c0e52e agent: report recording status and refine verification 2026-05-11 18:56:34 +02:00
Adrià Arrufat
08dde25923 terminal: simplify slash command argument analysis 2026-05-11 17:52:49 +02:00
Adrià Arrufat
aa9304f150 terminal: add inline hints for commands 2026-05-11 17:52:49 +02:00
Adrià Arrufat
30af107e04 terminal: improve tab-completion with starters and arg hints 2026-05-11 17:52:49 +02:00
Adrià Arrufat
5df501f419 agent: improve command syntax error handling in REPL 2026-05-11 17:52:49 +02:00
Adrià Arrufat
729de62012 test: add keywordSyntax and isAllUpper tests
Adds unit tests for command keyword parsing and string casing. Also removes the unused `history_path` field from the `Terminal` struct.
2026-05-11 17:52:49 +02:00
Adrià Arrufat
82f6b4c002 terminal: improve repl completion and highlighting 2026-05-11 17:52:49 +02:00
Adrià Arrufat
98b082ddc1 terminal: improve REPL prompt, completion, and highlighting
- Cache environment variable names to improve completion performance.
- Refactor terminal styles into constants.
- Move `isAllUpper` to `string.zig` and `meta_names` to `SlashCommand.zig`.
- Align quoted string scanning logic with the slash command parser.
2026-05-11 17:52:49 +02:00
Adrià Arrufat
1abf05aec7 agent: unify command keywords and simplify env listing
Centralizes PandaScript keywords in Command.zig as a single source of
truth for the parser and REPL. Simplifies environment variable listing
and formatting in tools.zig.
2026-05-11 17:52:49 +02:00
Adrià Arrufat
e962ba9575 refactor: simplify terminal prompt and enable brace insertion
- Simplify prompt handling by relying on default markers.
- Enable brace insertion in the terminal.
- Optimize `lpEnvNames` by pre-allocating capacity.
- Clean up and trim verbose comments across `Terminal.zig`.
2026-05-11 17:52:49 +02:00
Adrià Arrufat
6da9497fda repl: add syntax highlighting and completions 2026-05-11 17:52:49 +02:00
Adrià Arrufat
5d70174288 terminal: replace linenoise with isocline
Replaces the linenoise library with isocline for improved REPL
functionality. Updates build scripts and moves completion state from
global variables into the Terminal struct.
2026-05-11 17:52:49 +02:00
Adrià Arrufat
0338bf71af refactor: simplify mcp communication and tool dispatching 2026-05-11 08:57:36 +02:00
Adrià Arrufat
e7d6597e08 refactor: unify URL handling and clean up agent logic 2026-05-10 00:04:51 +02:00
Adrià Arrufat
372c0a12a2 agent: simplify logic and cleanup comments 2026-05-08 08:23:19 +02:00
Adrià Arrufat
16e61e342e terminal: simplify spinner access and organize ansi codes 2026-05-07 16:38:11 +02:00
Adrià Arrufat
855ab768fa terminal: show tool execution trace in spinner mode 2026-05-07 16:28:16 +02:00
Adrià Arrufat
a254e4041a agent: refine verbosity levels and tool output UI 2026-05-07 16:11:28 +02:00
Adrià Arrufat
598a3b984b agent: add status spinner for AI turns
Adds a visual spinner to the REPL to indicate agent activity (thinking
or tool execution). Refactors terminal output to prevent interleaving
with spinner frames.
2026-05-07 15:25:26 +02:00
Adrià Arrufat
bf172bd811 refactor: consolidate browser tool helpers and optimize logic
- Extract `awaitQueuedNavigation` and `mapActionError` in `tools.zig`.
- Optimize `substituteEnvVars` using `indexOfScalarPos` to reduce copies.
- Switch to `parseFromSliceLeaky` for tool arguments parsing.
- Improve error handling in `Agent.zig` self-healing and `Recorder.zig`.
- Simplify `callEval` by adding `evalScript` helper.
2026-05-07 09:52:43 +02:00