Skip to content

Commit dd456be

Browse files
committed
feat: add Browser Use V4 run operation
1 parent 92ab46e commit dd456be

11 files changed

Lines changed: 645 additions & 14 deletions

File tree

apps/docs/content/docs/en/integrations/browser_use.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,38 @@ Runs a browser automation task using BrowserUse
7777
| `shareUrl` | string | Public shareable URL for the recorded session \(post-run\) |
7878
| `sessionId` | string | Browser Use session identifier |
7979

80+
### Browser Use V4
81+
82+
Runs a Browser Use Cloud agent through the V4 run API
83+
84+
#### Input
85+
86+
| Parameter | Type | Required | Description |
87+
| --------- | ---- | -------- | ----------- |
88+
| `task` | string | Yes | What the browser agent should do |
89+
| `model` | string | No | V4 model identifier |
90+
| `sessionId` | string | No | Existing V4 session ID for a follow-up turn |
91+
| `workspaceId` | string | No | Existing V4 workspace ID whose files should be restored |
92+
| `profileId` | string | No | Browser profile ID for stored cookies and browser state |
93+
| `record` | boolean | No | Record the newly provisioned browser session |
94+
| `agentmail` | boolean | No | Give the run a temporary AgentMail inbox |
95+
| `maxCostUsd` | number | No | Maximum run cost in US dollars |
96+
| `secretBindings` | json | No | Run-scoped secrets with the domains where each may be typed |
97+
| `apiKey` | string | Yes | Browser Use API key |
98+
99+
#### Output
100+
101+
| Parameter | Type | Description |
102+
| --------- | ---- | ----------- |
103+
| `id` | string | V4 run identifier |
104+
| `status` | string | Run status |
105+
| `result` | string | Final agent result |
106+
| `error` | string | Run error |
107+
| `model` | string | Model used by the run |
108+
| `sessionId` | string | V4 conversation session identifier |
109+
| `workspaceId` | string | Persistent workspace identifier |
110+
| `totalCostUsd` | string | Total run cost in US dollars |
111+
| `totalInputTokens` | number | Total input tokens used |
112+
| `totalOutputTokens` | number | Total output tokens used |
113+
80114

apps/sim/blocks/blocks/browser_use.ts

Lines changed: 142 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,26 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
1717
canvasPresentation: {
1818
defaultTitle: 'Browser Use',
1919
sentences: {
20-
default: [
21-
{ text: 'Run the browser task', field: 'task', core: true },
22-
{ text: ', starting at', field: 'startUrl' },
23-
],
20+
byOperation: {
21+
browser_use_run_task: [
22+
{ text: 'Run the legacy browser task', field: 'task', core: true },
23+
{ text: ', starting at', field: 'startUrl' },
24+
],
25+
browser_use_run_v4: [{ text: 'Run the V4 browser agent', field: 'task', core: true }],
26+
},
2427
},
2528
},
2629
subBlocks: [
30+
{
31+
id: 'operation',
32+
title: 'Operation',
33+
type: 'dropdown',
34+
options: [
35+
{ label: 'Run Task (V2)', id: 'browser_use_run_task' },
36+
{ label: 'Run Cloud Agent (V4)', id: 'browser_use_run_v4' },
37+
],
38+
value: () => 'browser_use_run_task',
39+
},
2740
{
2841
id: 'task',
2942
title: 'Task',
@@ -36,6 +49,7 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
3649
title: 'Start URL',
3750
type: 'short-input',
3851
placeholder: 'https://example.com (optional starting URL)',
52+
condition: { field: 'operation', value: 'browser_use_run_task' },
3953
},
4054
{
4155
id: 'variables',
@@ -44,11 +58,13 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
4458
password: true,
4559
required: false,
4660
columns: ['Key', 'Value'],
61+
condition: { field: 'operation', value: 'browser_use_run_task' },
4762
},
4863
{
4964
id: 'model',
5065
title: 'Model',
5166
type: 'dropdown',
67+
condition: { field: 'operation', value: 'browser_use_run_task' },
5268
options: [
5369
{ label: 'Browser Use LLM', id: 'browser-use-llm' },
5470
{ label: 'Browser Use 2.0', id: 'browser-use-2.0' },
@@ -77,20 +93,23 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
7793
title: 'Profile ID',
7894
type: 'short-input',
7995
placeholder: 'Enter browser profile ID (optional)',
96+
condition: { field: 'operation', value: 'browser_use_run_task' },
8097
},
8198
{
8299
id: 'maxSteps',
83100
title: 'Max Steps',
84101
type: 'short-input',
85102
placeholder: '100',
86103
mode: 'advanced',
104+
condition: { field: 'operation', value: 'browser_use_run_task' },
87105
},
88106
{
89107
id: 'allowedDomains',
90108
title: 'Allowed Domains',
91109
type: 'short-input',
92110
placeholder: 'example.com, docs.example.com',
93111
mode: 'advanced',
112+
condition: { field: 'operation', value: 'browser_use_run_task' },
94113
},
95114
{
96115
id: 'vision',
@@ -102,34 +121,39 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
102121
{ label: 'Disabled', id: 'false' },
103122
],
104123
mode: 'advanced',
124+
condition: { field: 'operation', value: 'browser_use_run_task' },
105125
},
106126
{
107127
id: 'flashMode',
108128
title: 'Flash Mode',
109129
type: 'switch',
110130
placeholder: 'Faster but less careful navigation',
111131
mode: 'advanced',
132+
condition: { field: 'operation', value: 'browser_use_run_task' },
112133
},
113134
{
114135
id: 'thinking',
115136
title: 'Thinking',
116137
type: 'switch',
117138
placeholder: 'Enable extended reasoning',
118139
mode: 'advanced',
140+
condition: { field: 'operation', value: 'browser_use_run_task' },
119141
},
120142
{
121143
id: 'highlightElements',
122144
title: 'Highlight Elements',
123145
type: 'switch',
124146
placeholder: 'Visually mark interactive elements',
125147
mode: 'advanced',
148+
condition: { field: 'operation', value: 'browser_use_run_task' },
126149
},
127150
{
128151
id: 'systemPromptExtension',
129152
title: 'System Prompt Extension',
130153
type: 'long-input',
131154
placeholder: 'Append custom instructions to the agent system prompt (max 2000 chars)',
132155
mode: 'advanced',
156+
condition: { field: 'operation', value: 'browser_use_run_task' },
133157
},
134158
{
135159
id: 'structuredOutput',
@@ -138,13 +162,88 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
138162
language: 'json',
139163
placeholder: 'Stringified JSON schema for structured output',
140164
mode: 'advanced',
165+
condition: { field: 'operation', value: 'browser_use_run_task' },
141166
},
142167
{
143168
id: 'metadata',
144169
title: 'Metadata',
145170
type: 'table',
146171
columns: ['Key', 'Value'],
147172
mode: 'advanced',
173+
condition: { field: 'operation', value: 'browser_use_run_task' },
174+
},
175+
{
176+
id: 'v4Model',
177+
title: 'Model',
178+
type: 'dropdown',
179+
options: [
180+
{ label: 'GPT-5.6 Luna (default)', id: 'gpt-5.6-luna' },
181+
{ label: 'GPT-5.6 Terra', id: 'gpt-5.6-terra' },
182+
{ label: 'GPT-5.6 Sol', id: 'gpt-5.6-sol' },
183+
{ label: 'Claude Sonnet 5', id: 'claude-sonnet-5' },
184+
{ label: 'Gemini 3.6 Flash', id: 'gemini-3.6-flash' },
185+
{ label: 'Kimi K3', id: 'kimi-k3' },
186+
],
187+
condition: { field: 'operation', value: 'browser_use_run_v4' },
188+
mode: 'advanced',
189+
},
190+
{
191+
id: 'v4SessionId',
192+
title: 'Session ID',
193+
type: 'short-input',
194+
placeholder: 'Continue an existing V4 conversation',
195+
condition: { field: 'operation', value: 'browser_use_run_v4' },
196+
mode: 'advanced',
197+
},
198+
{
199+
id: 'v4WorkspaceId',
200+
title: 'Workspace ID',
201+
type: 'short-input',
202+
placeholder: 'Restore files from an existing V4 workspace',
203+
condition: { field: 'operation', value: 'browser_use_run_v4' },
204+
mode: 'advanced',
205+
},
206+
{
207+
id: 'v4ProfileId',
208+
title: 'Profile ID',
209+
type: 'short-input',
210+
placeholder: 'Load saved cookies and browser state',
211+
condition: { field: 'operation', value: 'browser_use_run_v4' },
212+
mode: 'advanced',
213+
},
214+
{
215+
id: 'v4Record',
216+
title: 'Record Browser',
217+
type: 'switch',
218+
placeholder: 'Record a newly provisioned browser',
219+
condition: { field: 'operation', value: 'browser_use_run_v4' },
220+
mode: 'advanced',
221+
},
222+
{
223+
id: 'v4Agentmail',
224+
title: 'AgentMail',
225+
type: 'switch',
226+
placeholder: 'Give the run a temporary inbox',
227+
condition: { field: 'operation', value: 'browser_use_run_v4' },
228+
mode: 'advanced',
229+
},
230+
{
231+
id: 'v4MaxCostUsd',
232+
title: 'Max Cost (USD)',
233+
type: 'short-input',
234+
placeholder: '5.00',
235+
condition: { field: 'operation', value: 'browser_use_run_v4' },
236+
mode: 'advanced',
237+
},
238+
{
239+
id: 'v4SecretBindings',
240+
title: 'Secret Bindings',
241+
type: 'table',
242+
password: true,
243+
required: false,
244+
columns: ['Alias', 'Value', 'Allowed Domains'],
245+
condition: { field: 'operation', value: 'browser_use_run_v4' },
246+
mode: 'advanced',
148247
},
149248
{
150249
id: 'apiKey',
@@ -156,10 +255,30 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
156255
},
157256
],
158257
tools: {
159-
access: ['browser_use_run_task'],
258+
access: ['browser_use_run_task', 'browser_use_run_v4'],
160259
config: {
161-
tool: () => 'browser_use_run_task',
260+
tool: (params) =>
261+
params.operation === 'browser_use_run_v4' ? 'browser_use_run_v4' : 'browser_use_run_task',
162262
params: (params) => {
263+
if (params.operation === 'browser_use_run_v4') {
264+
const maxCost =
265+
typeof params.v4MaxCostUsd === 'string'
266+
? Number(params.v4MaxCostUsd.trim())
267+
: params.v4MaxCostUsd
268+
return {
269+
task: params.task,
270+
apiKey: params.apiKey,
271+
model: params.v4Model,
272+
sessionId: params.v4SessionId,
273+
workspaceId: params.v4WorkspaceId,
274+
profileId: params.v4ProfileId,
275+
record: params.v4Record,
276+
agentmail: params.v4Agentmail,
277+
maxCostUsd: Number.isFinite(maxCost) ? maxCost : undefined,
278+
secretBindings: params.v4SecretBindings,
279+
}
280+
}
281+
163282
const next: Record<string, any> = { ...params }
164283
if (typeof next.maxSteps === 'string') {
165284
const trimmed = next.maxSteps.trim()
@@ -186,6 +305,7 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
186305
},
187306
},
188307
inputs: {
308+
operation: { type: 'string', description: 'Browser Use API operation' },
189309
task: { type: 'string', description: 'Browser automation task' },
190310
startUrl: { type: 'string', description: 'Starting URL for the agent' },
191311
apiKey: { type: 'string', description: 'BrowserUse API key' },
@@ -201,6 +321,14 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
201321
systemPromptExtension: { type: 'string', description: 'Custom system prompt extension' },
202322
structuredOutput: { type: 'string', description: 'Stringified JSON schema' },
203323
metadata: { type: 'json', description: 'Custom key-value metadata' },
324+
v4Model: { type: 'string', description: 'V4 model to use' },
325+
v4SessionId: { type: 'string', description: 'Existing V4 session ID' },
326+
v4WorkspaceId: { type: 'string', description: 'Existing V4 workspace ID' },
327+
v4ProfileId: { type: 'string', description: 'Browser profile ID for the V4 run' },
328+
v4Record: { type: 'boolean', description: 'Record the V4 browser session' },
329+
v4Agentmail: { type: 'boolean', description: 'Enable a temporary AgentMail inbox' },
330+
v4MaxCostUsd: { type: 'number', description: 'Maximum V4 run cost in US dollars' },
331+
v4SecretBindings: { type: 'json', description: 'Run-scoped V4 secret bindings' },
204332
},
205333
outputs: {
206334
id: { type: 'string', description: 'Task execution identifier' },
@@ -220,6 +348,14 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
220348
description: 'Public shareable URL for the session (post-run)',
221349
},
222350
sessionId: { type: 'string', description: 'Browser Use session identifier' },
351+
status: { type: 'string', description: 'V4 run status' },
352+
result: { type: 'string', description: 'V4 final agent result' },
353+
error: { type: 'string', description: 'V4 run error' },
354+
model: { type: 'string', description: 'Model used by the V4 run' },
355+
workspaceId: { type: 'string', description: 'V4 persistent workspace identifier' },
356+
totalCostUsd: { type: 'string', description: 'Total V4 run cost in US dollars' },
357+
totalInputTokens: { type: 'number', description: 'Total V4 input tokens used' },
358+
totalOutputTokens: { type: 'number', description: 'Total V4 output tokens used' },
223359
},
224360
}
225361

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { runTaskTool } from '@/tools/browser_use/run_task'
2+
import { runV4Tool } from '@/tools/browser_use/run_v4'
23

34
export const browserUseRunTaskTool = runTaskTool
5+
export const browserUseRunV4Tool = runV4Tool

0 commit comments

Comments
 (0)