Commit Graph

8347 Commits

Author SHA1 Message Date
Adrià Arrufat
d8c7a8c050 agent: add select verification and improve retry logic
- Implement `verifySelect` to check element values in `Verifier`.
- Add `.select` to retryable commands in `Agent`.
- Increase retries to 3 with incremental backoff.
- Simplify click verification by removing navigation intent logic.
2026-04-13 14:44:57 +02:00
gujishh
ea67e41660 docs: match WSL section formatting 2026-04-13 21:09:27 +09:00
Karl Seguin
ce811c1b48 Merge pull request #2142 from lightpanda-io/formdata_encoding
Encode form data based on the form (or documents) encoding.
2026-04-13 19:51:17 +08:00
Karl Seguin
6723d6642a 'fix' test 2026-04-13 19:51:04 +08:00
Adrià Arrufat
ed8ae3f83a agent: unify verification logic and failure reporting
Consolidates verification and failure reason generation into a single
call. Optimizes state capture to be command-aware and fixes EVAL block
parsing logic in `Command.zig`.
2026-04-13 13:11:02 +02:00
Adrià Arrufat
35200f9235 feat(agent): add command verification and retry logic
Introduces a Verifier to ensure commands like click or type actually
achieve their intended effects. Adds retry logic for flaky actions
and includes verification context in self-healing prompts.
2026-04-13 13:02:17 +02:00
Adrià Arrufat
75586c5fa9 Merge branch 'main' into agent 2026-04-13 12:39:45 +02:00
Adrià Arrufat
20baa4f8dc agent: improve self-healing prompt and context
Adds the current URL and specific instructions to the self-healing
prompt to prevent navigation and limit the scope of the fix.
2026-04-13 12:39:23 +02:00
Karl Seguin
cdd109a41b Improve loaderId and requestId compatibility
This introduces two slightly related changes.

My understanding is:

- frameId represents the page. Even if the page navigates, it's the same
  frameId. We capture this in Page._frame_id. Nothing here changes.

- loaderId is essentially for a specific document of the page. If the page
  navigates, it should be a different loaderId. We were using a distinct
  loaderId per request. Not sure what problems that caused. But it was wrong.
  This was achieved by exposing Page.id to CDP.

- requestId was mostly correct: unique per request. HOWEVER, for the original
  document, apparently, requestId == loaderId. This change is particularly
  important for various puppeteer and playwrightb behavior. This is a bit
  hacked. CDP will look at the resource_type, if it's .document, it'll return
  the loaderId, else it returns the requestId it always id.
2026-04-13 18:33:43 +08:00
Karl Seguin
cd4e977020 Merge pull request #2150 from lightpanda-io/eventcounts
Add EventCounts API
2026-04-13 18:33:24 +08:00
Karl Seguin
3fe8c3ee8f Merge pull request #2148 from lightpanda-io/fix_typedarray_offset
Correctly treat a view's offset as a byte offset, not an element offset
2026-04-13 18:33:08 +08:00
Adrià Arrufat
59030d510a agent: rewrite scripts with healed commands
Tracks command spans and automatically updates script files with
LLM-generated fixes when self-healing succeeds. Includes atomic file
writes and automatic .bak file creation.
2026-04-13 11:59:21 +02:00
Karl Seguin
ca061b46b7 Merge pull request #2149 from lightpanda-io/websocket_protocol
Basic protocol support for websocket.
2026-04-13 17:34:28 +08:00
Karl Seguin
577629f536 Merge pull request #2151 from lightpanda-io/text_decoder_streaming
TextDecoder streaming stop
2026-04-13 17:34:16 +08:00
Pierre Tachoire
920ae57f9a cdp: ignore UA containing Mozilla
Instead of returning an error when the UA contains Mozilla, we ignore
the option and log an message.
2026-04-13 11:25:16 +02:00
Pierre Tachoire
1589445ec0 zig fmt 2026-04-13 10:36:35 +02:00
Pierre Tachoire
21e27a257d cdp: add warning for non-implemented params on Emulation.setUserAgentOverride 2026-04-13 10:32:36 +02:00
Pierre Tachoire
05a08f1f97 cdp: forward Network.setUserAgentOverride to Emulation.setUserAgentOverride 2026-04-13 10:23:55 +02:00
zed
9fe3a48c3a test: add tests for setting CDP user agent 2026-04-13 10:23:54 +02:00
zed
5e5a573a9f new: allow CDP change useragent 2026-04-13 10:23:54 +02:00
Karl Seguin
299104ff1d TextDecoder streaming stop
When we stop streaming, we need to use any previously streamed data as part of
the last "unstreamed" chunk. Or, put differently, when stream is false, that
merely stops any subsequent streams, it doesn't discard any previously streamed
data.
2026-04-13 13:06:16 +08:00
Karl Seguin
592dc3e18d Add EventCounts API 2026-04-13 12:30:49 +08:00
Karl Seguin
5c161260fd don't break union probing 2026-04-13 11:35:32 +08:00
Karl Seguin
28a7e7fe45 Basic protocol support for websocket.
Websockets client can send a Protocol which the server can agree to. This isn't
as fancy as it sounds. We just send a specific header on websocket handshake
and then read the response header.
2026-04-13 11:21:59 +08:00
Karl Seguin
de167861c6 handle null buffers 2026-04-13 10:03:19 +08:00
Karl Seguin
cde8229be5 Correctly treat a view's offset as a byte offset, not an element offset 2026-04-13 09:52:03 +08:00
gujishh
1923877a74 Clarify WSL install notes 2026-04-13 00:12:43 +09:00
Adrià Arrufat
33d6a8dee2 Merge branch 'main' into agent 2026-04-12 16:08:58 +02:00
Karl Seguin
e6cffaef72 Merge pull request #2144 from lightpanda-io/feat/console-group
Feat/console group
2026-04-12 20:15:32 +08:00
Karl Seguin
6ebe112525 Add form acceptCharset accessor
Pre-size encoding buffer for possible numeric character insertion.
2026-04-12 19:38:36 +08:00
Karl Seguin
57f20e1831 Encode form data based on the form (or documents) encoding.
Does something similar to https://github.com/lightpanda-io/browser/pull/2126
but for form submission. It uses the form's accept-charset attribute, or
fallsback to the document's charset.
2026-04-12 19:38:36 +08:00
William Chan
e6fd004767 refactor: remove unused _group_depth tracking
Since group depth is not used for indentation in headless mode,
simplify by removing the field. group/groupCollapsed just log,
groupEnd is a no-op.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-12 19:37:39 +08:00
William Chan
d5556fda93 feat(console): implement group, groupCollapsed, and groupEnd
Add missing console grouping APIs per the WHATWG Console spec:
- console.group(...data): logs label and increments group depth
- console.groupCollapsed(...data): same as group (headless mode has no
  visual collapsing, so behavior is identical to group)
- console.groupEnd(): decrements group depth, clamped at 0

Depth is tracked via _group_depth (u32) on the Console struct.
Saturation arithmetic (+|=) prevents overflow on runaway group() calls.

Fixes TypeError crashes on sites that use console.group* APIs (e.g.
React/Vite dev builds).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-12 19:37:38 +08:00
Pierre Tachoire
dc8e917084 Merge pull request #2143 from lightpanda-io/ci-snap-cache
ci: invalidate snapshot cache on src/browser/webapi change
2026-04-12 11:56:26 +02:00
Pierre Tachoire
f7ef2be5cd ci: invalidate snapshot cache on src/browser/webapi change 2026-04-12 11:54:53 +02:00
Adrià Arrufat
e1747d5f29 agent: improve eval parsing and command recording
- Extract `getJsonString` helper in Agent.zig.
- Match specific triple quote types in EVAL blocks to allow nested quotes.
- Use `cmd.format` and larger buffers in Recorder.zig.
2026-04-12 10:20:22 +02:00
Adrià Arrufat
654e11719c tools: rename semanticTree tool to tree 2026-04-12 09:38:55 +02:00
Adrià Arrufat
e1f1d8f76b refactor: use std.ascii for character checks and conversions
Replaces manual ASCII range checks and case conversions with standard
library functions from `std.ascii` for improved readability.
2026-04-11 15:49:29 +02:00
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
6b97e6c4ab Config: simplify common options access
Use the commonOpts() helper to access shared configuration fields instead of manual switching over modes.
2026-04-11 11:45:56 +02:00
Adrià Arrufat
c61423ff94 Merge branch 'main' into agent 2026-04-11 11:28:57 +02:00
Karl Seguin
af4363ad8f Map a zig error.RangeError to a proper JS RangeError
Fixes WPT /encoding/api-invalid-label.any.html?1-1000
2026-04-11 15:35:01 +08:00
Karl Seguin
87e9e9190c Handle http response with closed socket
https://github.com/lightpanda-io/browser/pull/1987 added support for a
connection that was close with a valid response. This commit goes a step further
and removes the requirement for a "connection: close" header.

We see a lot of these in WPT tests, e.g.
/referrer-policy/gen/iframe.http-rp/unset/iframe-tag.http.html
2026-04-11 15:24:48 +08:00
Karl Seguin
283f3d4986 Merge pull request #2136 from lightpanda-io/debug_allocator
Re-enable debug allocator in debug
2026-04-11 12:58:52 +08:00
Karl Seguin
63104a7f82 Re-enable debug allocator in debug
Disabled this when looking at memory profiles, and must have accidentally
committed it.
2026-04-11 12:24:19 +08:00
Karl Seguin
da8d206c52 On Page cleanup, capture next linked list node _before_ releasing MO
Also, switch MO and IO to use a "small" arena, as they probably don't require
too many allocations in most normal cases (just observing 1 or 2 things).
2026-04-11 11:39:05 +08:00
Karl Seguin
3be913750e Cache-Control is public by default
- If private isn't specified, default to public.
- Add some tests
- Optimize parsing by lower-casing once and switch to std.mem
2026-04-11 07:23:56 +08:00