Commit Graph

141 Commits

Author SHA1 Message Date
Francis Bouvier
8052f0ad81 Agent model provider picker (#2581)
* agent: add a /model command to chnage current model

And remove the pick-model CLI option

* agent: add /provider to change the current provider

* agent: extract requireLlmNoArg helper

* agent: simplify provider detection

* repl: add tab completion for /model and /provider

Changes `/model` and `/provider` to accept an optional name argument
instead of prompting with a numbered list. Bare commands now print the
current selection, while Tab dynamically completes candidates. Model
lists are fetched and cached to prevent redundant network requests.

* agent: remember last selected provider and model

Persists the last selected AI provider and model in a local
`.lp-agent` file and resumes it on startup. Removes the
interactive provider picker in favor of deterministic auto-detection.

* agent: simplify requireLlm and model resolution

Changes `requireLlm` to return a boolean instead of credentials, and
cleans up the model initialization logic to use `resolved` directly.
Also removes unused user errors.

---------

Co-authored-by: Adrià Arrufat <adria.arrufat@gmail.com>
2026-05-30 19:02:44 +02:00
Adrià Arrufat
ff95f83f74 agent: track and print token usage in one-shot mode
Updates zenai and aggregates token usage across all model calls.
Prints a `$usage` summary to stderr at the end of a task.
2026-05-29 12:44:20 +02:00
Adrià Arrufat
ddd9c84195 agent: update zenai and tune agent settings 2026-05-23 23:36:07 +02:00
Adrià Arrufat
e9943a3976 command: use Action enum for ToolCall name
Replaces the string `name` in `ToolCall` with `action: browser_tools.Action`.
This avoids repeated string-to-enum parsing and simplifies schema lookups.
Also updates `zenai` dependency to use its JSON duplication helper.
2026-05-21 22:51:52 +02:00
Adrià Arrufat
19c361c2e8 agent: use zenai credentials detection 2026-05-21 19:03:48 +02:00
Adrià Arrufat
2bd24ba30e agent: use zenai envVarName helper 2026-05-21 18:55:50 +02:00
Adrià Arrufat
0707187fa0 build: bump zenai dependency 2026-05-21 15:11:40 +02:00
Adrià Arrufat
c04062f4de build: bump zenai dependency 2026-05-21 15:04:56 +02:00
Adrià Arrufat
85276df004 deps: update zenai and use thinking_level 2026-05-20 00:16:03 +02:00
Adrià Arrufat
d0a8da453b agent: implement graceful Ctrl-C interruption 2026-05-15 18:45:56 +02:00
Adrià Arrufat
882ed74e89 agent: update zenai and default models 2026-05-14 19:35:38 +02:00
Adrià Arrufat
927340ee64 build: update zenai dependency 2026-05-14 19:07:36 +02:00
Adrià Arrufat
258d6463e5 Merge branch 'main' into agent 2026-05-12 14:42:29 +02:00
Adrià Arrufat
60a880a88c terminal: simplify command completion logic
Removes hardcoded starters and uses trailing spaces to trigger hints for
commands with parameters. Updates isocline dependency.
2026-05-12 11:19:48 +02:00
Karl Seguin
bcd94c4f9d Update v8 dep
https://github.com/lightpanda-io/browser/issues/2407
2026-05-12 14:06:17 +08:00
Adrià Arrufat
2078d332c2 agent: update zenai and tool call handling 2026-05-11 20:28:34 +02:00
Adrià Arrufat
aa9304f150 terminal: add inline hints for commands 2026-05-11 17:52:49 +02:00
Adrià Arrufat
e962ba9575 refactor: simplify terminal prompt and enable brace insertion
- Simplify prompt handling by relying on default markers.
- Enable brace insertion in the terminal.
- Optimize `lpEnvNames` by pre-allocating capacity.
- Clean up and trim verbose comments across `Terminal.zig`.
2026-05-11 17:52:49 +02:00
Adrià Arrufat
5d70174288 terminal: replace linenoise with isocline
Replaces the linenoise library with isocline for improved REPL
functionality. Updates build scripts and moves completion state from
global variables into the Terminal struct.
2026-05-11 17:52:49 +02:00
Adrià Arrufat
938795ec8d agent: add --pick-model for interactive selection 2026-05-09 20:11:52 +02:00
Adrià Arrufat
357033eb0c agent: add --list-models flag 2026-05-09 19:16:48 +02:00
Adrià Arrufat
d5f9f12de8 agent: use zenai for provider defaults and api keys 2026-05-05 08:40:34 +02:00
Adrià Arrufat
976d188820 agent: use dupeMessages from zenai library 2026-05-05 08:33:43 +02:00
Adrià Arrufat
a00161f54c Merge branch 'main' into agent 2026-05-05 08:05:57 +02:00
Pierre Tachoire
0794fbdc68 upgrade zig-v8-fork 2026-05-04 17:27:44 +02:00
Adrià Arrufat
dc441a85a1 browser.tools: add Tavily search support with scraping fallback
Integrates the Tavily Search API as the primary search provider when
TAVILY_API_KEY is set. Falls back to scraping Google and DuckDuckGo
on failure or if the key is missing. Updates zenai dependency.
2026-05-04 15:45:51 +02:00
Adrià Arrufat
f56b0426ca Merge branch 'main' into agent 2026-05-04 07:58:57 +02:00
Karl Seguin
ab93cbb56c Merge pull request #2318 from lightpanda-io/atob_btoa
Fix atob/btoa
2026-05-04 08:29:11 +08:00
Karl Seguin
560b15c9b2 update v8 dep 2026-05-01 09:11:16 +08:00
Adrià Arrufat
59dcb13cb4 Merge branch 'main' into agent 2026-04-30 07:36:48 +02:00
Karl Seguin
21e9c5184c Fix atob/btoa
Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/175

This started as an investigation into errors when loading recaptcha. Turns out
our atob/btoa is naive. Specifically, we take a `[]const u8` input which, via
the bridge, goes through the v8 utf8 path. This can result in the input being
fundamentally altered.

This commit introduces a new discriminatory type, js.String.OneByte which uses
the String::NewFromOneByte when going from js->zig and String:WriteOneByte when
going from zig->js, avoiding any changes to the raw data.

Also adds a placeholder MessageEvent.ports getter (which showed up in debugging)
2026-04-29 17:01:07 +08:00
Karl Seguin
9fe628dd0f Initial idn support
Links to libidn2 and builds libcurl with it. This makes libcurl work, and by
extension browser, work on international domain names, e.g.

zig build run -- fetch "https://räksmörgås.se/"

With it available, we can use it in our WebAPIs which should also support these
domains, e.g:
  testing.expectEqual('xn--rksmrgs-5wao1o.se', new URL('https://räksmörgås.se').hostname);

There is more integration to be done here, but this is a first step.

claude wrote all of the build.zig code.

I don't have a strong opinion about this feature, I just dislike that our WPT
/url/* tests are at 1704 / 9095 and, this is the biggest chunk (although, this
specific commit just does the basic integration and probably won't fix too many
WPT cases directly).
2026-04-28 22:21:27 +08:00
Adrià Arrufat
86ac6232f9 Merge branch 'main' into agent 2026-04-28 09:01:29 +02:00
Karl Seguin
2f6ce92db2 update v8 dep 2026-04-28 08:56:22 +08:00
Adrià Arrufat
a422a69770 agent: use safe truncation when pruning messages 2026-04-27 08:17:48 +02:00
Adrià Arrufat
138665d746 agent: update zenai dependency 2026-04-26 17:40:48 +02:00
Adrià Arrufat
d31bc17a39 Merge branch 'main' into agent 2026-04-25 09:49:47 +02:00
Karl Seguin
5ec7c660da update v8 dep 2026-04-25 09:51:58 +08:00
Karl Seguin
757c70b6db Add adoptedCallback for CustomElements
Fired when elements are moved from one document to another. I don't think this
is really used much, but it helps pass a number of WPT cases.

This required tweaking insertAdjacentHTML as it was creating a full document
and trigger spurious callbacks in the new code. A DocumentFragment is now used
instead.
2026-04-24 17:26:39 +08:00
Karl Seguin
2c4179f1ad Support direct instantiation of custom element
Support `new MyElement()` syntax to create custom element. The implementation
for this is pretty straightforward, but it depends on:
https://github.com/lightpanda-io/zig-v8-fork/pull/173.

Also modify the `attributeChangedCallback` and pass a missing parameter: the
namespace. Currently, we pass `null`, but this is less likely to cause issues
than not passing anything.
2026-04-24 16:48:24 +08:00
Adrià Arrufat
919d07c832 agent: update zenai and tool call error handling 2026-04-24 10:14:44 +02:00
Adrià Arrufat
935a7ba3d5 build: update zenai dependency 2026-04-22 16:49:56 +02:00
Adrià Arrufat
7e7cfee980 Merge branch 'main' into agent 2026-04-22 08:59:46 +02:00
Adrià Arrufat
ca1f2c0854 build: port sqlite3 to zig build system 2026-04-22 07:52:10 +02:00
Adrià Arrufat
01824d8ef6 agent: disable thinking budget for finalize turn 2026-04-21 11:12:01 +02:00
Adrià Arrufat
7328990777 agent: add --task-attachment for one-shot mode 2026-04-20 16:13:18 +02:00
Adrià Arrufat
bbe1b40c41 Merge branch 'main' into agent 2026-04-16 09:21:48 +02:00
Karl Seguin
0adb482bae update v8 dep 2026-04-16 15:02:58 +08:00
Adrià Arrufat
7fed6e18ad build(deps): switch zenai dependency to remote git
Updates the zenai dependency from a local relative path to a specific
git commit on the remote repository.
2026-04-15 11:13:57 +02:00
Karl Seguin
0b72826cab Fix Page.createIsolatedWorld
Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/170

Gets the correct executeContextId from the v8 inspector.
2026-04-15 16:02:24 +08:00