Skip to content

Commit 50e9103

Browse files
committed
Add browser use as a subagent! Get system info on whether chrome is installed and pass into base agent
1 parent 4b1bbc6 commit 50e9103

File tree

14 files changed

+52
-12
lines changed

14 files changed

+52
-12
lines changed

agents/base2/base2.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ export function createBase2(
8282
isMax && 'thinker-best-of-n-opus',
8383
isDefault && 'editor',
8484
isMax && 'editor-multi-prompt',
85+
'tmux-cli',
86+
'browser-use',
8587
isFree && 'code-reviewer-lite',
8688
isDefault && 'code-reviewer',
8789
isMax && 'code-reviewer-multi-prompt',
8890
'thinker-gpt',
89-
'tmux-cli',
9091
'context-pruner',
9192
),
9293

agents/browser-use/browser-use.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const definition: AgentDefinition = {
2323
3. Check \`consoleErrors\` for any JavaScript errors found
2424
4. Check \`lessons\` for advice on improving future runs
2525
26-
**Requirements:** Chrome must be installed on the user's machine. The MCP server downloads automatically via npx on first use.`,
26+
**Requirements:** Chrome must be installed. Check System Info for "Chrome: installed" before spawning. If Chrome is not found, do NOT spawn this agent — instead inform the user that the browser-use agent requires Google Chrome or Chromium to be installed.`,
2727

2828
inputSchema: {
2929
prompt: {

common/src/__tests__/handlesteps-parsing.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe('handleSteps Parsing Tests', () => {
4343
arch: 'test',
4444
homedir: '/test',
4545
cpus: 1,
46+
chromeAvailable: false,
4647
},
4748
tokenCallers: {},
4849
}

common/src/testing/fixtures/agent-runtime.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export const mockFileContext: ProjectFileContext = {
4848
arch: 'test',
4949
homedir: '/home/test',
5050
cpus: 1,
51+
chromeAvailable: false,
5152
},
5253
}
5354

common/src/util/file.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const ProjectFileContextSchema = z.object({
8484
arch: z.string(),
8585
homedir: z.string(),
8686
cpus: z.number(),
87+
chromeAvailable: z.boolean(),
8788
}),
8889
})
8990

@@ -113,6 +114,7 @@ export type ProjectFileContext = {
113114
arch: string
114115
homedir: string
115116
cpus: number
117+
chromeAvailable: boolean
116118
}
117119
}
118120

@@ -157,6 +159,7 @@ export const getStubProjectFileContext = (): ProjectFileContext => ({
157159
arch: '',
158160
homedir: '',
159161
cpus: 0,
162+
chromeAvailable: false,
160163
},
161164
})
162165

common/src/util/system-info.ts

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import fs from 'fs'
12
import os from 'os'
23
import path from 'path'
34
import { platform } from 'process'
@@ -6,15 +7,47 @@ import { getProcessEnv } from '../env-process'
67

78
import type { ProcessEnv } from '../types/contracts/env'
89

10+
const CHROME_PATHS: Record<string, string[]> = {
11+
darwin: [
12+
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
13+
'/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta',
14+
'/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev',
15+
'/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
16+
'/Applications/Chromium.app/Contents/MacOS/Chromium',
17+
],
18+
linux: [
19+
'/usr/bin/google-chrome',
20+
'/usr/bin/google-chrome-stable',
21+
'/usr/bin/google-chrome-beta',
22+
'/usr/bin/google-chrome-unstable',
23+
'/usr/bin/chromium',
24+
'/usr/bin/chromium-browser',
25+
'/snap/bin/chromium',
26+
],
27+
win32: [
28+
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
29+
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
30+
`${process.env.LOCALAPPDATA ?? ''}\\Google\\Chrome\\Application\\chrome.exe`,
31+
],
32+
}
33+
34+
export const findChromeExecutable = (): string | null => {
35+
const paths = CHROME_PATHS[platform] ?? []
36+
for (const p of paths) {
37+
if (p && fs.existsSync(p)) return p
38+
}
39+
return null
40+
}
41+
942
export const getSystemInfo = (processEnv: ProcessEnv = getProcessEnv()) => {
10-
const shell = processEnv.SHELL || processEnv.COMSPEC || 'unknown'
1143

1244
return {
1345
platform,
14-
shell: path.basename(shell),
46+
shell: 'bash',
1547
nodeVersion: process.version,
1648
arch: process.arch,
1749
homedir: os.homedir(),
1850
cpus: os.cpus().length,
51+
chromeAvailable: findChromeExecutable() !== null,
1952
}
2053
}

packages/agent-runtime/src/__tests__/main-prompt.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ describe('mainPrompt', () => {
194194
arch: 'test',
195195
homedir: '/home/test',
196196
cpus: 1,
197+
chromeAvailable: false,
197198
},
198199
}
199200

packages/agent-runtime/src/__tests__/prompt-caching-subagents.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const mockFileContext: ProjectFileContext = {
3636
arch: 'test',
3737
homedir: '/home/test',
3838
cpus: 1,
39+
chromeAvailable: false,
3940
},
4041
}
4142

packages/agent-runtime/src/__tests__/run-agent-step-tools.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe('runAgentStep - set_output tool', () => {
152152
arch: 'test',
153153
homedir: '/home/test',
154154
cpus: 1,
155+
chromeAvailable: false,
155156
},
156157
agentTemplates: {},
157158
customToolDefinitions: {},

packages/agent-runtime/src/__tests__/test-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,6 @@ export const mockFileContext: ProjectFileContext = {
6969
arch: 'test',
7070
homedir: '/home/test',
7171
cpus: 1,
72+
chromeAvailable: false,
7273
},
7374
}

0 commit comments

Comments
 (0)