Commit Graph
235 Commits
Author SHA1 Message Date
Karl Seguin 65f8a83585 v8: call v8__Platform__NotifyIsolateShutdown on isolate shutdown
The v8 documentation says this "Has to be called", and claude flagged it as a
potential leak.

Required a new zig-v8-fork build (v0.5.5) which I released.
2026-09-11 10:20:20 +08:00
Adrià Arrufat c9329d5955 AdBlocker: run /regex/ filters with PCRE2
Filter lists carry a few hundred rules written as JavaScript regex
literals (24 in EasyList, 165 in uBO's badware list); they parsed but
were dropped as unsupported. PCRE2 reads that syntax as-is, `\/` and
friends included, its compiled patterns are immutable so the one
blocker shared by every HTTP client thread can run them, and 10.48
ships a build.zig for 0.16, so it is wired like sqlite3.

`Regex.Context` routes every PCRE2 allocation through the blocker's
allocator, which puts the compiled patterns under the test runner's
leak detection, and caps match and depth so a broken pattern costs a
false negative rather than a stalled request. As in uBO, a regex
tests the raw URL with the case-insensitive flag unless `$match-case`.

Regex filters are still never tokenized: they ride the fallback bucket.
2026-09-09 12:43:39 +02:00
Adrià Arrufat 94a47f3a4b build: update curl to 8.22.0
curl 8.22 moved the resolver sources into lib/vdns/, renamed the QUIC
backends to cf-ngtcp2*/cf-quiche, folded noproxy.c into proxy.c and
added a handful of new files. Regenerate the source list from the
tarball and drop the four config defines the 8.22 template no longer
declares (Zig errors on unused config header values).
2026-09-03 10:27:02 +02:00
Adrià Arrufat 0d1e3c0c8b agent: fix agent history in JS mode 2026-08-28 09:07:16 +02:00
Adrià Arrufat e70b316aea agent: use zenai's hasImage
zenai exports it now; drop the local copy and re-pin.
2026-08-27 15:03:19 +02:00
Adrià Arrufat e6203ff1fe agent: hand the model inline screenshots
zenai tool results now carry image parts (lightpanda-io/zenai#12, #13),
so the model-driven tool path opts into inline images: a screenshot
without `path` reaches the model as text plus the PNG, on every backend.
The slash-command path still needs `path`, its result goes to the
terminal.
2026-08-27 15:03:19 +02:00
Karl Seguin 6955751c10 Merge pull request #3285 from lightpanda-io/mem-vmhwm
mem: include v8 functions in binary layout optimization
2026-08-27 07:35:30 +08:00
Karl Seguin c8abf899ef mem: include v8 functions in binary layout optimization
https://github.com/lightpanda-io/browser/pull/3271 introduce an orderfile so
that hot sections of code were grouped together in the binary, resulting in more
efficient loading. But, it excluded v8 functions because v8 is compiled with
`-fno-unique-section-names` so each section gets the same name. Because of this
the orderfile can't target specific "hot" or "cold" functions.

As a follow up to 3271, I thought we'd be able to re-compile v8 without that
flag, but:

1 - The flag isn't directly exposed by v8, so we'd need to change v8's own build
    BUILD.gn in our build process
2 - It would make the .a file ~ 40MB larger (though the final lightpanda binary
    would stay the same size
3 - If we wanted to created two .a files (one with -fno-unique-section-names and
    one without), it would require a full rebuild (for both x86-64 and arm).

I didn't love those compromises, so I asked Claude if the sections names could
be generated in a separate file and then that could be used when generating out
lightpanda.ld. What claude came up with was a small Zig script
(mark_hot_sections.zig) which is now run as part of the build. It takes the
v8.a file (which still has `-fno-unique-section-names`), it takes a text list
of hot functions, and it re-generates v8.a with a special .text.hot and
.rodata.hot sections. lightpanda.ld can include these.

This PR depends on https://github.com/lightpanda-io/zig-v8-fork/pull/202 but
202 doesn't require a v8 rebuild. It merely allows prebuilt_v8_path to be
a lazypath, which we need because the prebuilt_v8_path that we pass is now
generated from this build script.
2026-08-26 12:53:45 +08:00
Adrià Arrufat 42c3cbf20b search: default to Keenable's keyless endpoint, drop the DuckDuckGo scrape
The DuckDuckGo HTML endpoint the search tool fell back to is disallowed by
its robots.txt, so it is removed: the `duckduckgo` engine, the scrape via
`performGoto`, and the tool's browser-side dependency (`execSearch` no
longer needs a session). In its place `.auto` is a single walk over the
API engines in table order — each when its key is set — with Keenable
last, keyed if `KEENABLE_API_KEY` is set and its public endpoint
otherwise. Search therefore always has a rung with zero configuration,
and a set key is never shadowed by a keyless retry.

Every search now goes through zenai's `std.http.Client`, which had no
timeout at all; a stalled response would have blocked the MCP server's
shared browser thread for every session. zenai now bounds each attempt
(lightpanda-io/zenai#10, pinned here), and the tool's `timeout` argument
drives it, defaulting to 10 s. Retries are a property of the call path:
off in the cascade, where the next rung is the retry, and the engine
default for an explicit engine.

Cleanups from the #3252 review: `keyless` is derived from the client's
`api_key` type instead of a hand-set table flag; `engineIndex` no longer
depends on enum declaration order; one `searchKeyStatus` query replaces
three pub helpers for the REPL; the engine order and env-var list in the
tool description and `/searchEngine` help are generated from the table;
an empty result title renders as its URL instead of `****`.
2026-08-25 09:35:26 +02:00
Adrià Arrufat f1742ad1af search: repin zenai to the merged commit and finish the review follow-ups
- build.zig.zon points at lightpanda-io/zenai's merge commit of zenai#9
  (same tree, so the hash is unchanged)
- the keyless rung is no longer skipped when KEENABLE_API_KEY is set:
  the public endpoint has its own rate-limit regime, so it is worth
  trying after a failed keyed attempt — which the search tool
  description already promised
- keenable retries are disabled: the fallback cascade is the retry
  mechanism, and honoring the public endpoint's 60s Retry-After would
  stall the search tool short of the DDG rung
- stale SearchEngine/searchExplicit doc comments updated for keyless
2026-08-24 10:39:47 +02:00
Ilya Bogin 56e5daed54 search: track zenai review changes for the keenable engine
zenai's review round made keyless explicit in the client's type
(init takes ?[]const u8; null selects the public endpoint) and removed
the always-empty description field from results:

- the .auto keyless rung and searchExplicit pass null instead of "";
  the null-key call is comptime-gated to keyless-capable engines and
  apiSearch's key parameter is anytype to admit both shapes
- a set-but-empty KEENABLE_API_KEY is now keyed and fails loudly
  instead of silently switching to the keyless rate-limit regime
- formatKeenableMarkdown reads snippet only (description no longer
  exists to fall back to)
- build.zig.zon repinned to the reviewed zenai commit
2026-08-24 10:44:38 +03:00
Ilya Bogin 6cbe30b088 search: add Keenable engine with a keyless rung above the DDG scrape
Adds keenable to the search tool's engines (KEENABLE_API_KEY, tried
after brave/tavily/exa in .auto). Unlike the other engines it also
answers without any key: its client routes an empty key to the public
endpoint (rate-limited per client IP), so .auto now tries that as the
last rung before the DuckDuckGo scrape, and an explicit
/searchEngine keenable works keyless instead of erroring. Engine table
entries gain init_options so the Keenable client can carry the
lightpanda attribution header.

Needs the zenai Keenable search client (lightpanda-io/zenai PR #9); the
zon pin points at that branch until it lands.
2026-08-23 15:42:06 +03:00
Adrià Arrufat 9a57a34b46 tools: cap exa search highlights to 3 sentences 2026-08-19 16:42:43 +02:00
Adrià Arrufat d76ead300a browser: add exa search engine support 2026-08-18 21:10:45 +02:00
Karl Seguin c95135b5c2 update v8 dep 2026-08-13 19:31:37 +08:00
Karl Seguin af99e845df dev: support for pre-build shared library
Supports prebuild-v8 shared library and adds a `download-v8-shared` make target.
Depends on: https://github.com/lightpanda-io/zig-v8-fork/pull/198

The auto-discovery of the .so is done in the build.zig, which is different than
the auto-discovery of the .a which is done in the Makefile. This is intentional
and if we inverse -Ddev_fast so that it's on by default, the .a's auto discovery
will be moved to build.zig for consistency and explicitness. As-is, we have no
way to tell whether -Dprebuilt_v8_path=v8.a is being injected by Makefile or
is explicit (which isn't a problem so long as we're not doing dev_fast by
default).
2026-08-13 19:28:21 +08:00
Karl Seguin 5d2910034c update v8 dep 2026-08-11 09:54:33 +08:00
Karl Seguin 77ef54f0ac dev: add -Ddev_fast flag
Only works in Debug mode. Only works on x86_64 Linux.

sets use_llvm = false and forces glibc 2.43 (1), causes v8 to be dynamically
linked (https://github.com/lightpanda-io/zig-v8-fork/pull/197).

For me, zig build -Ddev_fast is about 6x faster (~60 seconds -> ~10 seconds)

(1) https://codeberg.org/ziglang/zig/issues/31272
2026-08-11 09:39:45 +08:00
Adrià Arrufat 8e3d6adeee build: update zenai dependency
Pulls in the latest three zenai commits:

- f721fd4 feat(retry): honor Retry-After hints on retryable responses
- 103f5e1 feat(retry): treat 408 request timeout as retryable
- 75597b3 feat(types): sync with upstream Go SDK releases
2026-08-06 14:24:11 +02:00
Adrià Arrufat a324ad9add build: update zenai dependency 2026-07-28 13:29:05 +02:00
Adrià Arrufat 8b6f7fe064 agent: simplify credential and key ownership handling 2026-07-28 13:05:46 +02:00
Adrià Arrufat 00cdc3ba8d agent: update zenai and switch auth to interruptible HTTP 2026-07-28 11:17:08 +02:00
Adrià Arrufat 01a7b091db agent: map models_dev_id and filter tool-call models 2026-07-28 10:56:24 +02:00
Adrià Arrufat d7cc090ca1 Merge branch 'main' into codex 2026-07-28 10:11:31 +02:00
Adrià Arrufat e99a5ab99b agent: pivot subscription auth from Claude Code to Codex
Replace the Anthropic Claude-Code-import flow with OpenAI Codex (ChatGPT
subscription) OAuth: device-code login, a real token store (auth.json,
0600) with refresh-grant, and JWT ChatGPT-Account-Id extraction. Codex is
now a distinct zenai provider, so the bearer-mode credential collapses to
provider==.codex; account_id threads to the client via InitOptions.

Unit-tested (build green): JWT account-id extraction, token store
round-trip, OAuth request-body encoding, token-response parsing. The
device-login / refresh network path is unverified pending a subscription.

Pins zenai to the codex branch (6967324).
2026-07-27 11:24:01 +02:00
Adrià Arrufat b3f6b0a929 Merge pull request #3019 from lightpanda-io/brave-search
tools: add Brave search + /searchEngine metacommand
2026-07-26 17:44:13 +02:00
Karl Seguin e2f80ace33 update v8 dep 2026-07-24 11:34:45 +08:00
Adrià Arrufat 41cd1cd734 agent: support subscription auth via Claude Code 2026-07-23 14:56:41 +02:00
Adrià Arrufat bae9388f1c Merge branch 'main' into brave-search 2026-07-22 16:27:35 +02:00
Adrià Arrufat 99262190da feat(tools): add Brave search + /searchEngine metacommand
Add Brave as a second API-backed web search engine: the search tool's
auto mode tries Brave then Tavily (keyed on BRAVE_API_KEY/TAVILY_API_KEY)
before the DuckDuckGo scrape. A new /searchEngine REPL metacommand pins
the engine explicitly (auto|tavily|brave|duckduckgo) — an explicit
engine surfaces its failures instead of silently degrading — and is
persisted to .lp-agent.zon like the other REPL settings.

Bumps zenai to pick up the zenai.search.brave client.
2026-07-22 13:44:51 +02:00
Karl Seguin 802862120f update zenai dep (zig 0.16) 2026-07-22 13:26:06 +08:00
Karl Seguin 8e42d63c1c zig: Zig 0.16
Built against https://github.com/lightpanda-io/zig-v8-fork/tree/zig-0.16 but
it doesn't require a new v8 build.

Built against https://github.com/lightpanda-io/boringssl-zig/tree/zig-0.16
since the current fork we point to isn't updated.

A global std.Io instance, lp.io. Way easier this way and requires 0 changes to
our libcurl integration / event loop.

Network code uses a new layer that does what Zig 0.15's posix package used to
do. Again, quicker migration that way. But, as long as we have the global IO,
and given the half-baked nature of networking in std.Io 0.16, this just makes
sense. Things can be migrated as needed.

The std.time.* -> std.Io.Timestamp/Clock/Duration resulted in _a lot_ of
changes. ArrayList = .{} -> ArrayList -> .empty also resulted in a lot of
changes, but that's obviously superficial. As is the trimLeft/trimRight ->
trimStart/trimEnd rename.

Locking adopt the `Uncancelable` variants, e.g. mutex.lockUncancelable() to
preserve the error-free signature (and, because cancellation would be something
we'd have to put more thought into).

std.json.ObjectMap is now unmanaged, so the allocator had to be passed along.
However, there's still a deprecated managed variant of MemoryPool, so I switched
to it (we can do a small follow up PR to move to the unmanaged after).

I tried use_llvm = false, but it locks my computer, consuming RAM until MacOS
gives me a popup I've never seen before, begging me to start killing processes.

Agent and the networking stuff saw the most significant changes.
2026-07-22 13:26:03 +08:00
Adrià Arrufat f06681587d build: update zenai dependency 2026-07-13 14:47:09 +02:00
Adrià Arrufat 70b5d400fa build: bump zenai dependency 2026-07-12 22:56:27 +02:00
Adrià Arrufat 40b902fed5 build: update zenai dependency 2026-07-11 00:52:58 +02:00
Adrià Arrufat 049c5f08f2 feat(agent): add assistant text streaming 2026-07-11 00:50:01 +02:00
Karl Seguin 4253bd852d update v8 dep 2026-07-07 20:41:12 +08:00
Adrià Arrufat 1c9acfa6bc Merge pull request #2878 from lightpanda-io/agent-vertex
agent: add Google Vertex AI support
2026-07-04 12:10:32 +02:00
Karl Seguin a082dc2b07 update v8 2026-07-04 07:29:40 +08:00
Adrià Arrufat ff7545a8c3 agent: add Google Vertex AI support
Supports both express mode (via VERTEX_API_KEY) and project mode
(via GOOGLE_CLOUD_PROJECT and gcloud auth). Handles automatic
OAuth token retrieval and refresh.
2026-07-03 20:23:51 +02:00
Karl Seguin 1f8076b8be Merge pull request #2834 from lightpanda-io/update-v8
Update v8
2026-06-30 13:58:58 +08:00
Karl Seguin 98157e18ab update zig-v8-fork dep 2026-06-30 13:36:02 +08:00
Karl Seguin d9c76d0b0e update zig-v8-fork dep hash 2026-06-28 14:25:13 +08:00
Karl Seguin 8350076972 update intercepted type from u8 to u32 2026-06-28 14:18:12 +08:00
Karl Seguin d550a89330 v8, dep: Update v8
This update of zig-v8-fork is an update of v8 itself.
2026-06-28 08:03:02 +08:00
Karl Seguin b054b26e56 dep: update libcurl and nghttp2
Nothing major, but the feature that caught my eye was the addition of a
threadpool for DNS resolution, rather than a thread-per-resolution (1). I've
enabled it.

(1) https://github.com/curl/curl/commit/39036c90216e059bbee64b86b198eae3135e0cda
2026-06-27 19:06:47 +08:00
Adrià Arrufat 59dc69f1fe agent: support provider-specific default effort
Updates the zenai dependency and resolves the agent's effort based on
the configured provider's default. Also dynamically updates the active
effort when switching providers.
2026-06-18 13:22:29 +02:00
Adrià Arrufat 117c254923 build: bump zenai dependency to change Mistral's default model 2026-06-18 09:15:37 +02:00
Karl Seguin 0b85904967 update v8 dep 2026-06-18 11:19:18 +08:00
Karl Seguin cecc7d27fd Add global object (window) identity across navigates
Essentially makes it so that:

```
var w = iframe.contentWindow
iframe.src = 'spice.html';
w === iframe.contentWindow
```

Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/182 and leverages
v8's own ability to re-use globals.

This uses v8
2026-06-18 11:16:09 +08:00