Commit Graph

98 Commits

Author SHA1 Message Date
Francis Bouvier
31ef5246bc Add per-subcommand help via help or --help argument
`lightpanda <subcommand> help`, `lightpanda <subcommand> --help`
now print only the relevant subcommand options plus common options,
instead of the full text.

`lightpanda help <subcommand>` is also supported
(and that's what use internally).
2026-05-11 22:16:52 +02:00
Halil Durak
19401dc950 Config: update --inject-script documentation 2026-05-11 15:15:36 +03:00
Halil Durak
60d721caa2 Config: increase read file size for --inject-script-file 2026-05-11 15:15:36 +03:00
Halil Durak
246f91d1f8 --inject-script: prefer splice bytes into <head> directly 2026-05-11 15:15:35 +03:00
Halil Durak
c566d0c41c introduce --inject-script and --inject-script-file
* Prefer `--inject-*` prefix.
* Support injecting multiple scripts (also allows using both variants together).
* Instead of executing scripts in JS context, actually insert them to `<head>` for correct dump output.
2026-05-11 15:15:35 +03:00
Halil Durak
39f12a5669 fetch: add support for --script option
Allows passing a JS file as an arg to be executed alongside other scripts.
2026-05-11 15:15:35 +03:00
Halil Durak
c5b16cb18e Config: add a custom validator for --log-level 2026-04-28 12:37:16 +03:00
Karl Seguin
ae8013f967 Merge pull request #2275 from lightpanda-io/nikneym/cli-variants
`cli`: introduce `variants` + fix `--wait-script-file` regression
2026-04-28 07:32:35 +08:00
Karl Seguin
f515233b52 Merge pull request #2248 from lightpanda-io/blackhole_storage
Add and default to Blackhole storage
2026-04-27 21:48:54 +08:00
Halil Durak
968cf5f9e5 Config: log-filter-scopes -> --log-filter-scopes 2026-04-27 16:06:29 +03:00
Halil Durak
f4b220fb5f Config: fix --wait-script-file regression 2026-04-27 16:06:12 +03:00
Karl Seguin
7819ee50fa Add and default to Blackhole storage
Tweak sqlite build to omit more features, hoping to shrink the size when sqlite
is used.
2026-04-26 09:04:33 +08:00
Karl Seguin
12c2efb811 Adds --terminate-ms command line argument + ctrl-c improvements in fetch
The main.zig path for `fetch` now captures the *Browser so that
browser.env.terminate() can be called. This is a bit more complex than the serve
path because the Browser owns the Isolate and can't be moved from one thread to
another.

With main having access to the browser, two things are now possible:
1 - We can support a --terminate-ms flag (https://github.com/lightpanda-io/browser/issues/2206)
2 - ctrl-c can correctly stop blocked JavaScript processes

1 is implemented via setitimer to set a timer for SIGALRM, avoiding the need to
add another "watcher" thread, or putting a timer in Network.run.
2026-04-25 12:34:06 +08:00
Nikolay Govorov
999f57b729 Remove timeout flag 2026-04-24 12:40:25 +01:00
Nikolay Govorov
c7d004fefb Setup timeout via tcp keepalive 2026-04-24 12:40:21 +01:00
Nikolay Govorov
c964604c7a Fix canada.ca problem 2026-04-23 12:15:57 +01:00
Karl Seguin
859a41ab4e Adds navigator.userAgentData
This API isn't supported by FireFox (yet), so it isn't a huge priority, but I
did notice that its used across many Google properties. It uses the same value
as Sec-Ch-Ua (https://github.com/lightpanda-io/browser/pull/2100) to provide
consistent data.

Smaller changes:
1 - Allow `OffscreenCanvas` to be used with Worker (noticed this error too)
2 - Don't like JS execution errors at "error" level for "load" and
    "DOMContentLoaded". "error" should be reserved for things we can fix and
    should never be triggered from invalid a bug in JavaScript.
2026-04-23 16:24:42 +08:00
Halil Durak
7035317e3e Config: rebase to main 2026-04-22 16:14:28 +03:00
Halil Durak
f389e1945f rebase to main 2026-04-22 16:08:14 +03:00
Halil Durak
1da11d8da8 Config: revert to --strip-mode 2026-04-22 16:08:13 +03:00
Halil Durak
012fe40bb5 cli: remove aliases and shortcuts 2026-04-22 16:08:12 +03:00
Halil Durak
a3af914cda Config: adaptation to new cookie arguments 2026-04-22 16:08:12 +03:00
Halil Durak
29d8e0c9b7 Config: bring back validateUserAgent 2026-04-22 16:08:12 +03:00
Halil Durak
5e0c046e96 rebase and remove commented out code 2026-04-22 16:08:11 +03:00
Halil Durak
721b959dbf Config: always return a valid mode for --dump 2026-04-22 16:07:05 +03:00
Halil Durak
74a518c56f cli: reintroduce command sniffing 2026-04-22 16:07:04 +03:00
Halil Durak
f5b9bdb51b rebase and backport new feature from main 2026-04-22 16:07:04 +03:00
Halil Durak
85e624356b Commands: more aliases 2026-04-22 16:07:03 +03:00
Halil Durak
886448aaa3 Commands: add shortcuts for host and port of serve 2026-04-22 16:07:02 +03:00
Halil Durak
10914d6288 cli: fix --log-filter-scopes regression 2026-04-22 16:07:02 +03:00
Halil Durak
56b6fbe011 cli: many improvements
* Options with optional types are introduced to null by default
* Options with boolean types cannot be optional (nullable)
* Options with boolean types are introduced with false by default
* introduce shortcuts for options that can be provided via single dash
* introduce validators; custom parsing logic can be inserted for niche cases
2026-04-22 16:07:01 +03:00
Halil Durak
81b89e67b7 Config: adapt to new CLI builder 2026-04-22 16:07:01 +03:00
Karl Seguin
6d0003ad2b Sqlite
This adds an app.storage which is a union around configurable storage engine
(currently, only sqlite).

It is _not_ being used anywhere right now. The goal is to get feedback on
the implementation and then move cache to it.

This doesn't expose a generic query API. The goal is that the storage will
expose high level methods, e.g. `cacheGet(req: CacheGetRequest)` and every
storage engine will translate the `storage.CacheGetRequest` as needed.

A thin wrapper around the Sqlite C api is included, e.g. exec(SQL, .{args}) a
`rows` and `row` fetcher. A connection pool is included. By default, an
in-memory DB is currently created. And a `migrations` table with an id of `1`
is created/inserted. I don't imagine needing fancy migratations.
2026-04-20 17:13:06 +08:00
Karl Seguin
2d20e57f80 Change all @import("...../log.zig") to const log = lp.log;
@import("lightpanda") where needed.

Would also like to do this for String, Page, Session and js which all stand out
as types that are use across the codebase.

I know that a few devs are doing this in new work and I haven't heard anyone
voice an objection.
2026-04-20 12:40:04 +08:00
Pierre Tachoire
e922bf7369 update help for --cookies and --cookie-jar option 2026-04-15 10:48:23 -04:00
Matt Van Horn
35991a1b32 refactor: split --cookies-file into --cookie/--cookie-jar per curl convention
Split the single --cookies-file flag into two flags following curl's
convention as requested by @krichprollsch:

- --cookie (read-only): loads cookies at startup for fetch, mcp, and
  serve/CDP commands
- --cookie-jar (write-only): saves cookies on exit for fetch and mcp
  only (CDP cookie-jar deferred per maintainer guidance)

Add cookie integration to MCP server (load in init, save in deinit)
and CDP session creation (load only). The serve command now rejects
--cookie-jar with a clear error message.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 10:09:13 -04:00
Matt Van Horn
494ef345a1 fix: resolve Zig 0.15 compilation errors in cookies and config
- Escape braces in help text format string to avoid std.debug.print
  interpreting them as format specifiers
- Use writer.interface for std.Io.Writer methods (writeAll, stringify)
  instead of calling them directly on fs.File.Writer
- Replace writer.flush() with writer.end() per codebase convention

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 10:09:13 -04:00
Matt Van Horn
4d384dfe01 feat: add --cookies-file flag for session persistence
Add a --cookies-file CLI option that loads cookies from a JSON file
at startup and saves them back on exit. This enables AI agents to
maintain login sessions across multiple Lightpanda invocations.

The cookie format matches CDP Network.Cookie (compatible with
Puppeteer's page.cookies() export):
  [{"name":"sid","value":"abc","domain":".example.com","path":"/",
    "expires":1234567890,"secure":true,"httpOnly":true}]

Closes #335

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 10:09:12 -04: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
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
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
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