π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(builtin-skills): stop claiming agent-browser is pre-installed (#20086)
Arvin Xu03171c01ebcf
diff --git a/apps/desktop/src/main/modules/binaries/agentBrowserBinaries.ts b/apps/desktop/src/main/modules/binaries/agentBrowserBinaries.tsindex dd7c32c2fd8..e4867aa7428 100644--- a/apps/desktop/src/main/modules/binaries/agentBrowserBinaries.ts+++ b/apps/desktop/src/main/modules/binaries/agentBrowserBinaries.ts@@ -16,6 +16,9 @@ export const agentBrowserBinary: BinarySpec = defineCommandBinary('agent-browserdescription: 'Vercel agent-browser - headless browser automation for AI agents',manage: {githubRepo: 'vercel-labs/agent-browser',+ // Keep in sync with AGENT_BROWSER_PINNED_VERSION in+ // packages/builtin-skills/src/agent-browser/content.ts (the skill's npx fallback);+ // its content.test.ts fails when they drift.pinnedVersion: '0.31.1',postInstall: [['install']],release: ({ arch, platform, version }) => {diff --git a/packages/builtin-skills/src/agent-browser/content.test.ts b/packages/builtin-skills/src/agent-browser/content.test.tsnew file mode 100644index 00000000000..b9ced8d846f--- /dev/null+++ b/packages/builtin-skills/src/agent-browser/content.test.ts@@ -0,0 +1,53 @@+import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';++import { describe, expect, it } from 'vitest';++import { AGENT_BROWSER_PINNED_VERSION, systemPrompt } from './content';++/**+ * The desktop app downloads agent-browser lazily and a failed download only logs+ * a warning, and gateway devices may never have it at all β the skill is still+ * offered. The instructions must not promise the CLI is there, and the `npx`+ * fallback must run the same version the desktop app pins.+ */+describe('agent-browser skill content', () => {+ it('does not claim agent-browser or Chrome is pre-installed', () => {+ expect(systemPrompt).not.toMatch(/pre-installed/i);+ expect(systemPrompt).not.toMatch(/no setup needed/i);+ });++ it('tells the model to check for the CLI and fall back to a pinned npx run', () => {+ expect(systemPrompt).toContain('command -v agent-browser');+ expect(systemPrompt).toContain(`npx -y agent-browser@${AGENT_BROWSER_PINNED_VERSION}`);+ });++ // Windows commands usually run in PowerShell, where a bare `where` is the+ // Where-Object alias and finds nothing even when the binary is installed.+ it('probes Windows with where.exe, which works in both cmd and PowerShell', () => {+ expect(systemPrompt).toContain('where.exe agent-browser');+ expect(systemPrompt).not.toMatch(/^where agent-browser/m);+ });++ it('gives a Chrome launch command for each desktop platform', () => {+ expect(systemPrompt).toContain('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome');+ expect(systemPrompt).toContain('google-chrome');+ expect(systemPrompt).toMatch(/chrome\.exe/);+ });++ it('pins the same agent-browser version the desktop app downloads', () => {+ const desktopSpec = readFileSync(+ fileURLToPath(+ new URL(+ '../../../../apps/desktop/src/main/modules/binaries/agentBrowserBinaries.ts',+ import.meta.url,+ ),+ ),+ 'utf8',+ );+ const desktopVersion = desktopSpec.match(/pinnedVersion:\s*'([^']+)'/)?.[1];++ expect(desktopVersion).toBeDefined();+ expect(AGENT_BROWSER_PINNED_VERSION).toBe(desktopVersion);+ });+});diff --git a/packages/builtin-skills/src/agent-browser/content.ts b/packages/builtin-skills/src/agent-browser/content.tsindex c0d89f3f8d5..89b076d57b7 100644--- a/packages/builtin-skills/src/agent-browser/content.ts+++ b/packages/builtin-skills/src/agent-browser/content.ts@@ -1,9 +1,35 @@+/**+ * The agent-browser release the desktop app downloads+ * (`apps/desktop/src/main/modules/binaries/agentBrowserBinaries.ts` `pinnedVersion`).+ * The `npx` fallback below runs this same version; `content.test.ts` fails if the+ * two drift apart.+ */+export const AGENT_BROWSER_PINNED_VERSION = '0.31.1';++const NPX_AGENT_BROWSER = `npx -y agent-browser@${AGENT_BROWSER_PINNED_VERSION}`;+export const systemPrompt = `<agent_browser_guides># agent-browser\`agent-browser\` is a fast browser automation CLI for AI agents β drives Chrome/Chromium via CDP and serves accessibility-tree snapshots with compact \`@eN\` element refs (so you act on the page in a few hundred tokens, not raw HTML).-\`agent-browser\` and Chrome are pre-installed β no setup needed.+## Before the first command β check the CLI is available++The desktop app downloads \`agent-browser\` in the background, so it may be missing (first launch, offline, download failed) β and on other devices it may never have been installed. Check once before using it:++\`\`\`bash+command -v agent-browser # macOS / Linux+where.exe agent-browser # Windows (cmd or PowerShell)+\`\`\`++- **Found** β use \`agent-browser\` as written below.+- **Not found** (or a command fails with \`command not found\` / exit 127 / ENOENT) β if Node.js is available, run it through npx instead, and substitute this prefix for every \`agent-browser\` in the commands below (each command runs in a fresh shell, so repeat the full prefix):+ \`\`\`bash+ ${NPX_AGENT_BROWSER} open example.com+ \`\`\`+- **Neither works** (no \`npx\` either) β stop and tell the user \`agent-browser\` isn't installed on this device yet. The LobeHub desktop app retries the download on its next launch, and **Settings β System Tools β Browser Automation** shows whether it's been detected; they can also install it themselves with \`npm i -g agent-browser\` or \`brew install agent-browser\`. Don't hand-roll a replacement with curl/python scraping.++If a command fails because no browser is available, run \`agent-browser install\` (same prefix) once to download Chrome for Testing, then retry.## The core loop@@ -32,15 +58,21 @@ Empty body, verification screen, or obfuscated JS means the page is **blocked, n1. **Verify once** β \`agent-browser open <url>\`, then \`agent-browser wait --fn "document.body.innerText.length > 100" --timeout 3000\`. If it succeeds, page is usable β continue.2. **Timed out β launch real Chrome over CDP.** Its human fingerprint bypasses JS challenges:\`\`\`bash- # macOS (Linux: use \`google-chrome\`)+ # macOS:"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \\--remote-debugging-port=9222 --user-data-dir="$HOME/.agent-browser-cdp" &+ # Linux (binary may be \`google-chrome-stable\`, \`chromium\` or \`chromium-browser\` β check with \`command -v\`):+ # google-chrome --remote-debugging-port=9222 --user-data-dir="$HOME/.agent-browser-cdp" &+ # Windows (PowerShell):+ # Start-Process "$env:ProgramFiles\\Google\\Chrome\\Application\\chrome.exe" -ArgumentList '--remote-debugging-port=9222',"--user-data-dir=$env:USERPROFILE\\.agent-browser-cdp"agent-browser --cdp 9222 open <url>agent-browser --cdp 9222 wait --fn "document.body.innerText.length > 100" --timeout 3000agent-browser --cdp 9222 read # read rendered DOM as clean markdown# when done, close the CDP Chrome (it keeps running otherwise):agent-browser --cdp 9222 close- pkill -f "user-data-dir=$HOME/.agent-browser-cdp" # kill only the automation instance+ pkill -f "user-data-dir=$HOME/.agent-browser-cdp" # macOS / Linux: kill only the automation instance+ # Windows (PowerShell):+ # Get-CimInstance Win32_Process -Filter "Name='chrome.exe'" | Where-Object { $_.CommandLine -like '*agent-browser-cdp*' } | ForEach-Object { Stop-Process -Id $_.ProcessId }\`\`\`**Once you switch, commit to real Chrome.** Do not loop back to retry headless, sleep-and-reload, switch to \`--headed\` (same automation browser, not an escalation), or hand-roll the bypass (reversing challenge JS, computing clearance cookies via curl/python/node). Real Chrome is the general answer.