Commit Graph

17 Commits

Author SHA1 Message Date
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
6cd75c454e script: optimize hint allocation and inline helper
Calculate the exact size needed for hint slots in schema.zig to avoid
overallocating. Also inline the single-use helper isDefaultTrueBool in
command.zig.
2026-05-22 09:23:52 +02:00
Adrià Arrufat
fec1909aa1 script: strip backendNodeId and fix error line reporting
- Allow recording commands with backendNodeId if they also have a
  selector, stripping backendNodeId during formatting.
- Point UnterminatedQuote errors to the opening line instead of EOF.
- Fix buildHints allocation when fields is empty but required is not.
- Update docs to clarify positional argument rules.
2026-05-22 09:18:32 +02:00
Adrià Arrufat
df42d18d6d command: check required fields for null-arg tool calls
Tool calls with null arguments are now only considered recorded if the
tool schema has no required fields. This prevents generating invalid,
unreplayable commands for tools like `goto` or `fill`.
2026-05-22 09:09:19 +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
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
13ebb9e802 agent: simplify command, schema, and repl logic
- Remove `input_schema_raw` from `SchemaInfo` and use `parameters` directly
- Simplify JSON field extraction in `Verifier` to avoid `parseArgs`
- Refactor REPL command splitting and environment substitution
- Clean up and condense comments across the codebase
2026-05-21 22:39:58 +02:00
Adrià Arrufat
349b4ea798 agent: clean up dead code and optimize schema parsing
- Remove unused `callEval` and `extract` from `ToolExecutor`.
- Optimize `parseValue` in `schema.zig` to allocate directly instead of
  using `std.ArrayList` when filling missing defaults.
- Simplify redundant checks and clean up comments.
2026-05-21 21:41:28 +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
0ce0d264a4 agent: prevent use-after-free in self-heal path 2026-05-21 20:45:03 +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