Commit Graph

85 Commits

Author SHA1 Message Date
Adrià Arrufat
bbe1b40c41 Merge branch 'main' into agent 2026-04-16 09:21:48 +02:00
Karl Seguin
5c33c8fc3c Merge pull request #2158 from lightpanda-io/websocket_tweaks
WS.close returns DOMException
2026-04-15 07:08:37 +08:00
Karl Seguin
eb0af793c2 WS.close returns DOMException
Cleanup WS after sending disconnetion events

Mapping support for []f32 and []f64

Default max WS connections 8 -> 64
2026-04-14 21:58:43 +08:00
Karl Seguin
5226df9968 Tweak tests
De-duplicate user agent validation
2026-04-14 17:11:54 +08:00
Adrià Arrufat
570c901239 agent: improve recorder robustness and cleanup
- Add heap fallback for `Recorder` when fixed buffers overflow.
- Replace global atomic `agent_failed` with a local variable in `main.zig`.
- Fix `UnkownOption` typo in `Config.zig`.
- Add `Verifier` tests and debug logging for navigations.
- Add memory usage TODO and pointer arithmetic comments in `Agent.zig`.
2026-04-13 18:02:18 +02:00
Pierre Tachoire
1589445ec0 zig fmt 2026-04-13 10:36:35 +02:00
zed
9fe3a48c3a test: add tests for setting CDP user agent 2026-04-13 10:23:54 +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
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
4a63bbf233 agent: replace --save with --interactive flag
Replays scripts then enters REPL to append new commands to the file.
The --save flag is removed in favor of this new interactive mode.
2026-04-10 20:57:22 +02:00
Adrià Arrufat
81413d9291 agent: add scroll command and improve script reliability
Adds the SCROLL command and ensures WAIT actions are recorded.
Refactors TYPE to use the fill tool, adds self-heal retries, and
propagates agent failures to the process exit code.
2026-04-10 11:45:14 +02:00
Adrià Arrufat
397f69fac5 cli: update agent help text for scripts and self-healing 2026-04-10 10:05:49 +02:00
Adrià Arrufat
7fe580214e Merge branch 'main' into agent 2026-04-10 09:32:43 +02:00
Pierre Tachoire
a4617390de Merge pull request #2104 from lightpanda-io/feat/add-ip-filter
Feat/add ip filter
2026-04-10 08:46:06 +02:00
Karl Seguin
8eaeafe16c Fix a lot of typos.
I used https://github.com/crate-ci/typos, it worked well.

Also, make sure cdp-initiated KeyboardEvent is freed when no element is in focus
2026-04-10 06:51:10 +08:00
Adrià Arrufat
7aa11c7006 agent: update CLI args and refactor code 2026-04-09 17:51:56 +02:00
Adrià Arrufat
ffb38f268b agent: add --self-heal flag to control self-healing 2026-04-08 18:15:34 +02:00
Adrià Arrufat
796a17ff81 agent: update default AI models 2026-04-08 16:35:10 +02:00
Adrià Arrufat
7ca289ece6 Config: support user agent for agent mode 2026-04-08 16:34:47 +02:00
Adrià Arrufat
f8497ca090 Merge branch 'main' into agent 2026-04-08 16:15:07 +02:00
Pierre Tachoire
f884b562ba user-agent ovveride must not contain mozilla 2026-04-08 12:11:09 +02:00
Pierre Tachoire
efb2fa9c22 Send Sec-Ch-Ua http header 2026-04-08 12:11:09 +02:00
Pierre Tachoire
ae9b4d3fc6 stricter user-agent rule 2026-04-08 12:11:09 +02:00
Trevin Chow
f0aacad52e feat: add --user-agent flag for full User-Agent override
When --user-agent is set, the provided string replaces the entire
User-Agent header instead of appending to "Lightpanda/1.0".
The existing --user-agent-suffix behavior is unchanged.

Fixes #2029
2026-04-08 12:11:08 +02:00
Lucien Coffe
7f5abfc9cf fix: use dashes in CLI flag names for consistency
Rename --block_private_networks to --block-private-networks and
--block_cidrs to --block-cidrs to match the existing flag naming
convention (e.g. --http-proxy, --proxy-bearer-token).
2026-04-08 12:10:46 +02:00
Lucien Coffe
fb6c4e4978 feat: add allow-list exclusions to --block_cidrs
CIDRs prefixed with '-' are treated as allow rules that exempt matching
IPs from blocking. Allow rules take precedence over both
--block_private_networks and custom block CIDRs.

Example: --block_private_networks --block_cidrs -10.0.0.42/32
blocks all private ranges except 10.0.0.42.

Adds 3 new tests for allow-list behavior.
2026-04-08 12:10:46 +02:00
Lucien Coffe
f5cfc4d315 feat: add --block_private_networks and --block_cidrs CLI flags
Block outbound HTTP requests to specified IP ranges before TCP handshake
using libcurl CURLOPT_OPENSOCKETFUNCTION callback. Fires after DNS
resolution, reads resolved IP directly from sockaddr, does bitwise CIDR
comparison. Fail-closed: unknown address families are blocked.

--block_private_networks blocks RFC1918, localhost, link-local, ULA.
--block_cidrs blocks additional comma-separated CIDRs.
IPv4-mapped IPv6 (::ffff:x.x.x.x) is unwrapped to prevent bypass.
2026-04-08 12:10:42 +02:00
Adrià Arrufat
0aa96bff79 config: remove --no-record agent argument 2026-04-08 11:55:58 +02:00
Adrià Arrufat
1650702e39 Merge branch 'main' into agent 2026-04-07 14:46:22 +02:00
Adrià Arrufat
afd6c11b34 Config: remove mcp version flag and simplify usage 2026-04-07 12:24:19 +02:00
Adrià Arrufat
a344f280d7 Config: remove redundant no_record field 2026-04-07 12:06:59 +02:00
Adrià Arrufat
adabc24897 agent: add ollama provider and base-url support 2026-04-07 08:55:33 +02:00
Adrià Arrufat
3fde7fb6b5 Config: remove --api-key CLI flag 2026-04-07 08:34:15 +02:00
Adrià Arrufat
e6228cafaf Config: simplify common options access 2026-04-07 08:14:14 +02:00
Adrià Arrufat
b5b8e79899 Config: support agent mode in wsMaxConcurrent 2026-04-07 07:32:47 +02:00
Adrià Arrufat
f7a4f1345f Merge branch 'main' into agent 2026-04-07 06:49:56 +02:00
Adrià Arrufat
7aabda9392 agent: add recorder, self-healing, env substitution, and security fixes
- Add Recorder for recording REPL sessions to .panda files, with
  --no-record flag and positional file arg support. Skips read-only
  commands (WAIT, TREE, MARKDOWN) per spec.
- Record resolved LLM tool calls as Pandascript commands so the
  generated artifact is deterministic.
- Add self-healing in --run mode: on command failure, prompt the LLM
  with the # INTENT context to resolve an alternative.
- Add LOGIN and ACCEPT_COOKIES high-level commands (LLM-resolved).
- Add multi-line EVAL """...""" support via ScriptIterator.
- Add $VAR_NAME environment variable substitution in command arguments.
- Escape JS strings in execType/execExtract to prevent injection.
- Sanitize output file paths in EXTRACT to prevent path traversal.
2026-04-04 08:14:48 +02:00
Adrià Arrufat
e29f33642c agent: add --run command for deterministic script replay 2026-04-04 07:56:10 +02:00
Adrià Arrufat
15c0a7be83 agent: add manual command support to REPL
Adds a parser and executor for manual commands like GOTO and CLICK.
Unrecognized input continues to be processed by the AI.
2026-04-04 07:56:10 +02:00
Adrià Arrufat
a81a24229b Add interactive agent mode with LLM-powered web browsing
Introduces `lightpanda agent` command that provides a REPL where users
can chat with an AI that uses the browser's tools (goto, markdown, click,
fill, etc.) to browse the web. Uses zenai for multi-provider LLM support
(Anthropic, OpenAI, Gemini) and linenoise v2 for terminal line editing.
2026-04-04 07:56:10 +02:00
Karl Seguin
14dcb7895a Give websockets their own connection pool, improve websocket message logging 2026-04-04 07:00:24 +08:00
Muki Kiboigo
ca5fa2b866 change --cache-dir -> --http-cache-dir 2026-04-03 07:23:32 -07:00
Muki Kiboigo
619a2653d1 update cacheDir config option 2026-04-03 07:23:31 -07:00
Muki Kiboigo
6633b6effc add cache dir to configuration opts 2026-04-03 07:22:20 -07:00
Karl Seguin
b6020e4770 Merge pull request #2066 from lightpanda-io/fix/agent-integration-and-mcp-cdp
mcp: improve navigation reliability and add CDP support
2026-04-03 08:27:55 +08:00
Karl Seguin
0604056f76 Improve network naming consistency
1.
Runtime.zig -> Network.zig (especially since most places imported it as
`const Network = @import("Runtime.zig")`

2.
const net_http = @import(...) -> const http = @import(...)
2026-04-01 18:46:03 +08:00
Adrià Arrufat
58fc60d669 mcp: improve navigation reliability and add CDP support
- Configurable navigation timeouts and wait strategies in MCP tools.
- Default navigation timeout increased from 2s to 10s.
- Added navigate, eval, and screenshot MCP tools.
- Supported running a CDP server alongside MCP using --cdp-port.
- Fixed various startup crashes when running CDP in MCP mode.
- Hardened MCP server error handling.
2026-04-01 12:41:56 +02:00
Karl Seguin
ab6c63b24b Add --wait-selector, --wait-script and --wait-script-file options to fetch
These new optional parameter run AFTER --wait-until, allowing the (imo) useful
combination of `--wait-until load --wait-script "report.complete === true"`.
However, if `--wait-until` IS NOT specified but `--wait-selector/script` IS,
then there is no default wait and it'll just check the selector/script. If
neither `--wait-selector` or `--wait-script/--wait-script-file` are specified
 then  `--wait-until` continues to default to `done`.

These waiters were added to the Runner, and the existing Action.waitForSelector
now uses the runner's version. Selector querying has been split into distinct
parse and query functions, so that we can parse once, and query on every tick.

We could potentially optimize --wait-script to compile the script once and call
it on each tick, but we'd have to detect page navigation to recompile the script
in the new context. Something I'd rather optimize separately.
2026-03-31 12:30:46 +08:00
Adrià Arrufat
d99599fa21 zig fmt 2026-03-30 07:24:08 +02:00
Adrià Arrufat
20e62a5551 mcp: inline mcpVersion helper from Config 2026-03-30 07:13:45 +02:00