Commit Graph

22 Commits

Author SHA1 Message Date
Adrià Arrufat
a5e7ec16be agent: unify interactive prompts and tool execution 2026-05-09 20:40:38 +02:00
Adrià Arrufat
7bf69a9a34 agent: remove integrated mcp server
Removes the `--mcp` flag and the internal `task` tool from the agent.
Users should use `lightpanda mcp` for external agent integrations.
2026-05-07 17:12:46 +02:00
Adrià Arrufat
bf172bd811 refactor: consolidate browser tool helpers and optimize logic
- Extract `awaitQueuedNavigation` and `mapActionError` in `tools.zig`.
- Optimize `substituteEnvVars` using `indexOfScalarPos` to reduce copies.
- Switch to `parseFromSliceLeaky` for tool arguments parsing.
- Improve error handling in `Agent.zig` self-healing and `Recorder.zig`.
- Simplify `callEval` by adding `evalScript` helper.
2026-05-07 09:52:43 +02:00
Adrià Arrufat
92a0f0e290 refactor: reorder tool arguments and optimize env substitution
- Reorder `arena` and `session` arguments in tool functions.
- Optimize `substituteEnvVars` to only process `$LP_` prefixes.
- Use stack buffer for backup paths in `Agent.zig`.
- Clean up `formatActionResult` implementation.
2026-05-07 09:25:36 +02:00
Adrià Arrufat
532dd593da agent: move tool ownership to ToolExecutor 2026-05-05 10:40:31 +02:00
Adrià Arrufat
80075efd6b agent: centralize session and node registry resets 2026-05-05 08:16:01 +02:00
Adrià Arrufat
a00161f54c Merge branch 'main' into agent 2026-05-05 08:05:57 +02:00
Adrià Arrufat
300fdfb34c agent: add MCP server mode with task tool 2026-04-30 17:11:48 +02:00
Adrià Arrufat
a6059c77f9 agent: add slash commands for manual tool execution 2026-04-28 18:51:52 +02:00
Adrià Arrufat
718c79049d agent: update callEval API and standardize initialization
- Update `ToolExecutor.callEval` to return `EvalResult` for better error handling.
- Swap `ScriptIterator.init` arguments to follow the allocator-first convention.
- Use explicit type syntax for `.init` calls across the agent package.
- Remove redundant `isKnownTool` helper in favor of direct enum conversion.
2026-04-26 08:49:51 +02:00
Adrià Arrufat
45dd2ba655 browser.tools: swap arena and registry argument order 2026-04-24 07:53:06 +02:00
Adrià Arrufat
04bc7a4add agent: cleanup resource management and simplify logic
- Use `atomicFile` for script updates in `Agent.zig`.
- Ensure `ai_client` is properly deinitialized on `init` failure.
- Consolidate JSON quoting into `Command.buildJson`.
- Simplify `Recorder` and `ToolExecutor` implementations.
- Fix page scope access in `mcp/tools.zig`.
2026-04-24 07:33:02 +02:00
Adrià Arrufat
9fa5fa93fc agent: reorder heal arguments and use leaky json parsing 2026-04-23 19:43:22 +02:00
Adrià Arrufat
58308cfdca Merge branch 'main' into agent 2026-04-22 07:13:04 +02:00
Adrià Arrufat
35200f9235 feat(agent): add command verification and retry logic
Introduces a Verifier to ensure commands like click or type actually
achieve their intended effects. Adds retry logic for flaky actions
and includes verification context in self-healing prompts.
2026-04-13 13:02:17 +02:00
Adrià Arrufat
20baa4f8dc agent: improve self-healing prompt and context
Adds the current URL and specific instructions to the self-healing
prompt to prevent navigation and limit the scope of the fix.
2026-04-13 12:39:23 +02:00
Adrià Arrufat
a5fd70f5dd refactor: improve tool execution and terminal formatting
- Standardize `fill` tool to use `value` instead of `text`.
- Add formatted output methods (`printInfoFmt`, `printErrorFmt`) to `Terminal`.
- Improve error handling in `ToolExecutor` and `browser/tools` by using error unions.
- Deduplicate `minify` utility and remove redundant code comments.
- Refactor tool dispatch to use `Action` enum tags instead of hardcoded strings.
2026-04-10 14:54:51 +02:00
Adrià Arrufat
286976a7c7 browser: centralize tool definitions 2026-04-09 16:07:05 +02:00
Adrià Arrufat
048cb46950 Refactor: extract shared tool execution layer from MCP and agent
Both MCP tools.zig and agent ToolExecutor.zig duplicated the same 20 tool
handlers. This extracts the shared logic into src/browser/tools.zig so new
tools only need to be added once. Reduces total code by ~620 lines while
keeping all 465 tests passing.
2026-04-07 08:05:36 +02:00
Adrià Arrufat
9a442ac5f1 agent: add new browser interaction tools
Adds hover, press, selectOption, setChecked, and findElement tools.
Increases backendNodeId search window in CommandExecutor to 500.
2026-04-07 07:46:40 +02:00
Adrià Arrufat
a5d3d686b8 agent: use arena allocators for messages and tools 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