Commit Graph

6544 Commits

Author SHA1 Message Date
Adrià Arrufat
1400a0a62b Merge branch 'main' into agent 2026-05-14 07:41:04 +02:00
Karl Seguin
373916873f Merge pull request #2442 from lightpanda-io/worker_message_buffer
CI fixes, callback timing correctness
2026-05-14 08:56:36 +08:00
Karl Seguin
96ac9a49ea Update src/browser/webapi/Worker.zig
Co-authored-by: Navid EMAD <navid.emad@yespark.fr>
2026-05-14 08:33:32 +08:00
Karl Seguin
1580ab197f Merge pull request #2452 from lightpanda-io/event_worker
make Event worker-safe
2026-05-14 07:39:37 +08:00
Karl Seguin
bcafa175cb make Event worker-safe 2026-05-14 07:11:33 +08:00
Adrià Arrufat
70edee7063 lightpanda: close session before notification deinit 2026-05-13 17:49:00 +02:00
Adrià Arrufat
a0b6b656c3 Merge branch 'main' into agent 2026-05-13 17:43:33 +02:00
Karl Seguin
5595f7d298 Merge pull request #2448 from lightpanda-io/script_load_error_handling
Don't process scripts that failed to load
2026-05-13 23:19:40 +08:00
Pierre Tachoire
198c4e5a0f Merge pull request #2444 from lightpanda-io/useless-code
cdp: remove dead code
0.3.0
2026-05-13 15:36:16 +02:00
Pierre Tachoire
ffc2baa733 Merge pull request #2431 from lightpanda-io/cdp-double-frame-navigated-event
fix(cdp): remove duplicate Page.frameNavigated and fix context regist…
2026-05-13 15:17:27 +02:00
Adrià Arrufat
5316dffeb7 Merge branch 'main' into agent 2026-05-13 14:58:47 +02:00
Karl Seguin
7750bc94f6 Apply suggestions from code review
Remove no-longer needed setTimeouts in test now that messages are queued. 

Runner also checks ready_queue when determining doneness.

Co-authored-by: Navid EMAD <design.navid@gmail.com>
2026-05-13 20:57:59 +08:00
Karl Seguin
2326071036 Don't [try] to process scripts that failed to load
At some point recently, we started to process scripts that fail to load (e.g.
404). This stops such scripts from [trying] to be evaluated, and executes the
onerror handler in all script loading paths.
2026-05-13 20:48:08 +08:00
Adrià Arrufat
71824087e9 refactor: improve tool error logging and outcome handling
Adds debug logging for browser tool action and parsing errors.
Introduces a helper to deduplicate evaluation result handling in MCP.
2026-05-13 14:41:45 +02:00
Pierre Tachoire
12971a2420 Merge pull request #2445 from lightpanda-io/reset-bc-arena
cdp: reset browser context arena when bc is removed
2026-05-13 14:35:38 +02:00
Adrià Arrufat
38c74ab3b3 browser: extract formatJsError helper in tools.zig 2026-05-13 14:35:31 +02:00
Adrià Arrufat
48b8c4fb8c script: simplify formatHealReplacement 2026-05-13 14:34:12 +02:00
Adrià Arrufat
c009b291cb agent: correctly report JS errors in eval tool
Routes the eval tool through callEval instead of callValue. This
ensures JavaScript execution errors are flagged with is_error=true,
allowing the model to self-correct.
2026-05-13 14:33:11 +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
Pierre Tachoire
5d73d82bf6 cdp: call context created w/ correct is_default_context value
Co-authored-by: Navid EMAD <navid.emad@yespark.fr>
2026-05-13 14:11:53 +02:00
Adrià Arrufat
635546bf85 Recorder: simplify initialization and file opening 2026-05-13 14:03:18 +02:00
Adrià Arrufat
fb06e282c2 agent: simplify promptNumberedChoice API\ 2026-05-13 13:29:26 +02:00
Adrià Arrufat
b2454a9190 chore: add license headers to source files 2026-05-13 13:20:36 +02:00
Adrià Arrufat
b4b533d2be agent: derive Action enum from tool_defs and clean up Verifier
- Derives the `Action` enum in `src/browser/tools.zig` from `tool_defs` to prevent manual maintenance and potential drift.
- Refactors `verifyElementValue` in `src/script/Verifier.zig` to use a `Check` struct for its parameters.
- Reorganizes and cleans up imports in `src/agent/Agent.zig`.
2026-05-13 13:18:30 +02:00
Adrià Arrufat
f35c4219c9 refactor: improve error handling and rename Self to Agent
- Replace `unreachable` with explicit error returns in Agent and Executor.
- Add `EvalResult.err` helper in `tools.zig` to simplify error paths.
- Improve error propagation in `SlashCommand` and `Recorder`.
- Rename `Self` to `Agent` for better clarity in function signatures.
2026-05-13 13:15:44 +02:00
Adrià Arrufat
6478853e93 agent: simplify zig syntax and arena usage 2026-05-13 13:01:30 +02:00
Adrià Arrufat
c374f8b04e browser: unify element identification with ActionTarget
Introduces an `ActionTarget` union to handle selectors and backend node
IDs consistently. This simplifies the `formatActionResult` function and
ensures the identification method is preserved within `NodeAndPage`
during element resolution.
2026-05-13 12:54:18 +02:00
Adrià Arrufat
cc59dd64b9 script: make ScriptIterator.next fallible 2026-05-13 12:40:07 +02:00
Pierre Tachoire
8432cfbfba cdp: return error in case of missing event's frame
Instead of using the root_frame
2026-05-13 12:29:11 +02:00
Adrià Arrufat
18890ea695 spinner: reset state on thread spawn failure 2026-05-13 12:25:32 +02:00
Adrià Arrufat
9f5814a431 agent: add errdefers for cleanup in ToolExecutor.init 2026-05-13 12:23:39 +02:00
Adrià Arrufat
457c565df3 agent: move ai_client check earlier in runHealTurn
Ensures the function fails fast if no AI client is available before
performing other operations.
2026-05-13 12:22:10 +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
Karl Seguin
e895ce81e3 Merge pull request #2437 from lightpanda-io/window_frameElement
Add window.frameElement
2026-05-13 18:00:08 +08:00
Karl Seguin
3e31fde66c Merge pull request #2443 from lightpanda-io/url_fixes
Fix URLSearchParams constructor
2026-05-13 17:59:50 +08:00
Karl Seguin
625e240f5a Pump the http_client queue after perform, not just before
Client.tick drains self.queue (assigning conns to queued transfers) only
at the start. When perform / processMessages releases a batch of conns
back to the pool, those conns sit idle until the next tick — a queued
transfer that could have run this tick waits one Runner iteration
(~20 ms in the test runner) for no reason. Adds a second drainQueue
call after perform so newly-freed conns get picked up immediately.

In practice this matters whenever httpMaxHostOpen / httpMaxConcurrent
is exceeded — pages with N > limit subresources had each "wave" of
queue overflow paying one extra tick of latency.
2026-05-13 17:58:49 +08:00
Karl Seguin
c79dd2bf1f Make runner aware of http_client.queue
When connections are queued, the processing cannot be considered done.
2026-05-13 17:55:39 +08:00
Karl Seguin
2bcf9a22d5 Disable cache=true from e2e matrix
cache=true is problematic for a few reasons

1 - The current cache implementation is known to cause timing issues; i.e. it
    executes callbacks synchronously.

2 - Unlike something like robots.txt or proxy, cache tests need to be explicitly
    tested. The response has to include cache headers and the resource loaded
    again.
2026-05-13 17:52:46 +08:00
Adrià Arrufat
b23eb8a51a agent: handle user cancellation in interactive prompts 2026-05-13 11:51:36 +02:00
Karl Seguin
afc0942655 Merge pull request #2441 from lightpanda-io/fix-robots-crash
Fix crash on `robots.txt` being fulfilled synchronously
2026-05-13 17:39:22 +08:00
Pierre Tachoire
36b55339cd cdp: reset browser context arena when bc is removed 2026-05-13 11:26:09 +02:00
Pierre Tachoire
403fe0d293 cdp: remove dead code 2026-05-13 11:18:05 +02:00
Adrià Arrufat
900b8be10d script: propagate allocation errors in command conversion 2026-05-13 11:06:10 +02:00
Adrià Arrufat
bbe3e58724 tools: extract page context formatting to helper
Moves page URL and title formatting into a separate `appendPageContext`
function and removes the page parameter from `formatActionResult`.
This simplifies tool execution logic and decouples action descriptions
from page metadata.
2026-05-13 10:55:05 +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
ee2964fb0f agent.spinner: handle thread spawn failure 2026-05-13 10:15:33 +02:00
Adrià Arrufat
7e1d0529a8 script: support triple-double quotes in command formatting 2026-05-13 10:12:43 +02:00
Adrià Arrufat
947e9be5fc script: add test for healing multi-line EVAL blocks 2026-05-13 10:03:32 +02:00
Karl Seguin
c860a9a9e5 Split xhr-in-worker tests into their own file
xhr.html can brush up against the timeout as we add more and more cases. This
is particularly true on the slow CI, in debug builds, with TSAN.
2026-05-13 15:59:29 +08:00
Karl Seguin
dd99102f4b Defer HTTP completion callbacks to next tick
Client.makeRequest used to call self.perform(0) after handing the transfer
to libcurl. That perform() does two things: drives curl_multi_perform (so
bytes hit the wire) AND drains curl_multi_info_read messages, which is
what fires the user-facing header/data/done callbacks.

The issue is that, even in non-cache cases, a request could be immediately
resolved in libcurl, and thus callbacks executed synchronously.

By only calling `curl_multi_perform` on a new request, we prevent this from
happening.
2026-05-13 15:59:29 +08:00