Commit Graph

6730 Commits

Author SHA1 Message Date
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
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
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
e89fb9b485 agent: simplify tool allocation and schema info
Remove `tool_schema_arena` from `Agent` and allocate the tools slice
directly using the general allocator.

Remove the pre-calculated `is_multiline_capable` field from
`SchemaInfo` and compute it dynamically in `isMultiLineCapable()`.
2026-05-21 22:24:27 +02:00
Adrià Arrufat
3b2956c400 schema: simplify initialization and parsing
- Use global schemas built once at startup instead of parsing on init.
- Simplify argument verification using `browser_tools.parseArgs`.
- Optimize `parseValue` with `std.ArrayList`.
- Panic on global schema parse failure since schemas are static.
2026-05-21 22:17: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
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
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
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
88ac71a474 agent: remove no_llm field 2026-05-21 19:05:55 +02:00
Adrià Arrufat
19c361c2e8 agent: use zenai credentials detection 2026-05-21 19:03:48 +02:00
Adrià Arrufat
2bd24ba30e agent: use zenai envVarName helper 2026-05-21 18:55:50 +02:00
Adrià Arrufat
758d2c48fb agent: require --no-llm for basic REPL 2026-05-21 18:37:16 +02:00
Adrià Arrufat
ceb5f368f0 script: rename raw_line to opener_line 2026-05-21 18:01:46 +02:00
Adrià Arrufat
31e20ae261 Recorder: pass directory to init and reuse arena
Update `Recorder.init` to accept a `std.fs.Dir` and relative path,
decoupling it from the current working directory.

Also add a persistent arena allocator to `Recorder` to reuse
allocations when scrubbing environment variables on each write.
2026-05-21 17:45:54 +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
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
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
0707187fa0 build: bump zenai dependency 2026-05-21 15:11:40 +02:00
Adrià Arrufat
c04062f4de build: bump zenai dependency 2026-05-21 15:04:56 +02:00
Adrià Arrufat
651504efb5 agent: consolidate LLM provider and key resolution
Introduce an `Llm` struct to bundle the provider and API key together.
Add `UserError` to identify errors that have already printed human-
readable messages, preventing duplicate logging on exit.
2026-05-21 15:01:44 +02:00
Adrià Arrufat
7df1e80ce5 config: fix agent mode 2026-05-21 13:49:08 +02:00
Adrià Arrufat
54482831ed Merge branch 'main' into agent 2026-05-20 17:33:07 +02:00
Pierre Tachoire
5905319e78 Merge pull request #2503 from lightpanda-io/general_help
Remove options from main help
2026-05-20 16:25:39 +02:00
Pierre Tachoire
5fce406a13 compact more help options 2026-05-20 16:09:16 +02:00
Pierre Tachoire
af6175cc56 rewrite help in a more compact way
Inspired by go help output
2026-05-20 16:05:17 +02:00
Francis Bouvier
dffa961f45 Remove options from main help 2026-05-20 16:05:13 +02:00
Adrià Arrufat
989932b40a Merge branch 'main' into agent 2026-05-20 14:57:32 +02:00
Pierre Tachoire
f1b0adf923 Merge pull request #2498 from navidemad/fix/author-display-rule-beats-ua-hidden
`StyleManager`: author `display` rule must beat UA `[hidden]` / `display:none`
2026-05-20 14:01:25 +02:00
Pierre Tachoire
bb2d62d189 Merge pull request #2500 from lightpanda-io/parseHtmlAsChildren_assertion
parseHtmlAsChildren handling for unexpected dom (custom element callb…
2026-05-20 14:00:58 +02:00
Pierre Tachoire
6e6b3caf96 Merge pull request #2479 from navidemad/accessibility-query-ax-tree
Implement Accessibility.queryAXTree CDP method (and fix latent frame-binding bug)
2026-05-20 13:59:35 +02:00
Pierre Tachoire
2ad2c9d878 Merge pull request #2487 from navidemad/feat/external-stylesheets-flag
Add --enable-external-stylesheets flag with fetch + parse
2026-05-20 13:41:59 +02:00
Karl Seguin
b6fd09c5ab Merge pull request #2502 from lightpanda-io/max-cdp-conn
by using httpClient, fetch generates a call to Config.maxConnections
2026-05-20 16:28:56 +08:00
Pierre Tachoire
639cb14cb3 Merge pull request #2494 from marchelbling/feat-fetch-json-option
feat: add --json to fetch command
2026-05-20 10:17:21 +02:00
Pierre Tachoire
6eb25d5c44 by using httpClient, fetch generates a call to Config.maxConnections 2026-05-20 10:14:17 +02:00
Karl Seguin
a314984b2e Merge pull request #2495 from lightpanda-io/cdp_inbox
Main/Network reads CDP socket
2026-05-20 14:35:29 +08:00
Karl Seguin
5fb0f5a204 parseHtmlAsChildren handling for unexpected dom (custom element callback)
Removes an assertion that can break with custom element callbacks.
https://github.com/lightpanda-io/browser/pull/2429 does not solve this issue
since it isn't a result of when reactions are executed, but just that they
happen.

(I should note, that I'm not 100% sure the above statement is correct. It's
possible that our CE reactions are (in some cases at least) too micro. Maybe
some operations, like setInnerHtml should operate within a more atomic
frameworks, vs an CE-reaction per internal step. But that's a pretty big change)
2026-05-20 14:33:03 +08:00
Pierre Tachoire
29d5a7ae9e Merge pull request #2497 from lightpanda-io/ci-revert-cdp-logs
ci: remove cdp logs from end to end tests
2026-05-20 08:30:12 +02:00
Karl Seguin
e7b16983bb Add help documentation + small tweaks
This adds help documentation for the --json flag. This is the only thing that
must be kept from this commit.

It uses our testing.zig to streamline the json testing (instead of string
probing). It removes the JsonEnvelope in favor of an anonymous struct (though,
I'm fine with adding it back in if it's needed to resolve something ambiguous).

Finally, I removed the last unit test as, at that point, it's really just
testing Zig's JSON stringifier (could arguably make the same case for the other
two, but there's some logic there about how nulls/empty might be handled).
2026-05-20 10:44:41 +08:00
Karl Seguin
2fd2be0e51 Small largely stylistic tweaks
Trim down a lot of the comments. Inline remarks in some cases rather than a
large function header.

Removing the `errdefer headers.deinit();` is unfortunate but currently
necessary to avoid a potential double-free if the request gets far enough that
http_client frees it and still returns an error. This is a known issue that
needs to be fixed separately and that impacts multiple call-sites. My "fix"
introduces a possible (very small) memory leak versus a possible crash.
2026-05-20 10:31:28 +08:00
Karl Seguin
61386059c1 promote invalid CDP message from warn to err 2026-05-20 07:19:57 +08:00
Karl Seguin
037db695ff Merge pull request #2492 from lightpanda-io/cdp_connection
Re-organization CDP connection
2026-05-20 06:45:30 +08:00
Adrià Arrufat
85276df004 deps: update zenai and use thinking_level 2026-05-20 00:16:03 +02:00
Adrià Arrufat
98baccf1db agent: update default Gemini model 2026-05-19 23:56:41 +02:00
Navid EMAD
814ca8ab3f accessibility: unify query+tree writers, route objectId via dom.getNode
Fold QueryWriter into Writer behind an Opts.filter. Tree mode is unchanged
(filter=null); query mode walks the full subtree (including AX-ignored
nodes per the queryAXTree spec) and emits the flat-match shape. Shared
resolveRole helper handles label-promotion for both paths so the two
can't drift.

Drop the "objectId not yet supported" carve-out: queryAXTree now reuses
dom.getNode, which already resolves nodeId/backendNodeId/objectId.
2026-05-19 20:43:54 +02:00