Skip to content

Commit 81cbfe7

Browse files
authored
feat(browseruse): upgraded browseruse endpoints to v2 (#2890)
1 parent 739341b commit 81cbfe7

File tree

8 files changed

+85
-65
lines changed

8 files changed

+85
-65
lines changed

apps/docs/components/icons.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,12 +1739,12 @@ export function BrowserUseIcon(props: SVGProps<SVGSVGElement>) {
17391739
{...props}
17401740
version='1.0'
17411741
xmlns='http://www.w3.org/2000/svg'
1742-
width='150pt'
1743-
height='150pt'
1742+
width='28'
1743+
height='28'
17441744
viewBox='0 0 150 150'
17451745
preserveAspectRatio='xMidYMid meet'
17461746
>
1747-
<g transform='translate(0,150) scale(0.05,-0.05)' fill='#000000' stroke='none'>
1747+
<g transform='translate(0,150) scale(0.05,-0.05)' fill='currentColor' stroke='none'>
17481748
<path
17491749
d='M786 2713 c-184 -61 -353 -217 -439 -405 -76 -165 -65 -539 19 -666
17501750
l57 -85 -48 -124 c-203 -517 -79 -930 346 -1155 159 -85 441 -71 585 28 l111

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { BlockInfoCard } from "@/components/ui/block-info-card"
77

88
<BlockInfoCard
99
type="browser_use"
10-
color="#E0E0E0"
10+
color="#181C1E"
1111
/>
1212

1313
{/* MANUAL-CONTENT-START:intro */}

apps/docs/content/docs/en/tools/google_slides.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ Read content from a Google Slides presentation
5252
| --------- | ---- | ----------- |
5353
| `slides` | json | Array of slides with their content |
5454
| `metadata` | json | Presentation metadata including ID, title, and URL |
55+
|`presentationId` | string | The presentation ID |
56+
|`title` | string | The presentation title |
57+
|`pageSize` | object | Presentation page size |
58+
|`width` | json | Page width as a Dimension object |
59+
|`height` | json | Page height as a Dimension object |
60+
|`width` | json | Page width as a Dimension object |
61+
|`height` | json | Page height as a Dimension object |
62+
|`mimeType` | string | The mime type of the presentation |
63+
|`url` | string | URL to open the presentation |
5564

5665
### `google_slides_write`
5766

@@ -71,6 +80,10 @@ Write or update content in a Google Slides presentation
7180
| --------- | ---- | ----------- |
7281
| `updatedContent` | boolean | Indicates if presentation content was updated successfully |
7382
| `metadata` | json | Updated presentation metadata including ID, title, and URL |
83+
|`presentationId` | string | The presentation ID |
84+
|`title` | string | The presentation title |
85+
|`mimeType` | string | The mime type of the presentation |
86+
|`url` | string | URL to open the presentation |
7487

7588
### `google_slides_create`
7689

@@ -90,6 +103,10 @@ Create a new Google Slides presentation
90103
| Parameter | Type | Description |
91104
| --------- | ---- | ----------- |
92105
| `metadata` | json | Created presentation metadata including ID, title, and URL |
106+
|`presentationId` | string | The presentation ID |
107+
|`title` | string | The presentation title |
108+
|`mimeType` | string | The mime type of the presentation |
109+
|`url` | string | URL to open the presentation |
93110

94111
### `google_slides_replace_all_text`
95112

@@ -111,6 +128,10 @@ Find and replace all occurrences of text throughout a Google Slides presentation
111128
| --------- | ---- | ----------- |
112129
| `occurrencesChanged` | number | Number of text occurrences that were replaced |
113130
| `metadata` | json | Operation metadata including presentation ID and URL |
131+
|`presentationId` | string | The presentation ID |
132+
|`findText` | string | The text that was searched for |
133+
|`replaceText` | string | The text that replaced the matches |
134+
|`url` | string | URL to open the presentation |
114135

115136
### `google_slides_add_slide`
116137

@@ -131,6 +152,10 @@ Add a new slide to a Google Slides presentation with a specified layout
131152
| --------- | ---- | ----------- |
132153
| `slideId` | string | The object ID of the newly created slide |
133154
| `metadata` | json | Operation metadata including presentation ID, layout, and URL |
155+
|`presentationId` | string | The presentation ID |
156+
|`layout` | string | The layout used for the new slide |
157+
|`insertionIndex` | number | The zero-based index where the slide was inserted |
158+
|`url` | string | URL to open the presentation |
134159

135160
### `google_slides_add_image`
136161

@@ -154,6 +179,10 @@ Insert an image into a specific slide in a Google Slides presentation
154179
| --------- | ---- | ----------- |
155180
| `imageId` | string | The object ID of the newly created image |
156181
| `metadata` | json | Operation metadata including presentation ID and image URL |
182+
|`presentationId` | string | The presentation ID |
183+
|`pageObjectId` | string | The page object ID where the image was inserted |
184+
|`imageUrl` | string | The source image URL |
185+
|`url` | string | URL to open the presentation |
157186

158187
### `google_slides_get_thumbnail`
159188

@@ -176,6 +205,10 @@ Generate a thumbnail image of a specific slide in a Google Slides presentation
176205
| `width` | number | Width of the thumbnail in pixels |
177206
| `height` | number | Height of the thumbnail in pixels |
178207
| `metadata` | json | Operation metadata including presentation ID and page object ID |
208+
|`presentationId` | string | The presentation ID |
209+
|`pageObjectId` | string | The page object ID for the thumbnail |
210+
|`thumbnailSize` | string | The requested thumbnail size |
211+
|`mimeType` | string | The thumbnail MIME type |
179212

180213
### `google_slides_get_page`
181214

apps/sim/blocks/blocks/browser_use.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
1111
'Integrate Browser Use into the workflow. Can navigate the web and perform actions as if a real user was interacting with the browser.',
1212
docsLink: 'https://docs.sim.ai/tools/browser_use',
1313
category: 'tools',
14-
bgColor: '#E0E0E0',
14+
bgColor: '#181C1E',
1515
icon: BrowserUseIcon,
1616
subBlocks: [
1717
{

apps/sim/components/icons.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,12 +1739,12 @@ export function BrowserUseIcon(props: SVGProps<SVGSVGElement>) {
17391739
{...props}
17401740
version='1.0'
17411741
xmlns='http://www.w3.org/2000/svg'
1742-
width='150pt'
1743-
height='150pt'
1742+
width='28'
1743+
height='28'
17441744
viewBox='0 0 150 150'
17451745
preserveAspectRatio='xMidYMid meet'
17461746
>
1747-
<g transform='translate(0,150) scale(0.05,-0.05)' fill='#000000' stroke='none'>
1747+
<g transform='translate(0,150) scale(0.05,-0.05)' fill='currentColor' stroke='none'>
17481748
<path
17491749
d='M786 2713 c-184 -61 -353 -217 -439 -405 -76 -165 -65 -539 19 -666
17501750
l57 -85 -48 -124 c-203 -517 -79 -930 346 -1155 159 -85 441 -71 585 28 l111

apps/sim/tools/browser_use/run_task.ts

Lines changed: 27 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ export const runTaskTool: ToolConfig<BrowserUseRunTaskParams, BrowserUseRunTaskR
4646
},
4747
},
4848
request: {
49-
url: 'https://api.browser-use.com/api/v1/run-task',
49+
url: 'https://api.browser-use.com/api/v2/tasks',
5050
method: 'POST',
5151
headers: (params) => ({
5252
'Content-Type': 'application/json',
53-
Authorization: `Bearer ${params.apiKey}`,
53+
'X-Browser-Use-API-Key': params.apiKey,
5454
}),
5555
body: (params) => {
5656
const requestBody: Record<string, any> = {
@@ -121,12 +121,15 @@ export const runTaskTool: ToolConfig<BrowserUseRunTaskParams, BrowserUseRunTaskR
121121
let liveUrlLogged = false
122122

123123
try {
124-
const initialTaskResponse = await fetch(`https://api.browser-use.com/api/v1/task/${taskId}`, {
125-
method: 'GET',
126-
headers: {
127-
Authorization: `Bearer ${params.apiKey}`,
128-
},
129-
})
124+
const initialTaskResponse = await fetch(
125+
`https://api.browser-use.com/api/v2/tasks/${taskId}`,
126+
{
127+
method: 'GET',
128+
headers: {
129+
'X-Browser-Use-API-Key': params.apiKey,
130+
},
131+
}
132+
)
130133

131134
if (initialTaskResponse.ok) {
132135
const initialTaskData = await initialTaskResponse.json()
@@ -145,60 +148,36 @@ export const runTaskTool: ToolConfig<BrowserUseRunTaskParams, BrowserUseRunTaskR
145148

146149
while (elapsedTime < MAX_POLL_TIME_MS) {
147150
try {
148-
const statusResponse = await fetch(
149-
`https://api.browser-use.com/api/v1/task/${taskId}/status`,
150-
{
151-
method: 'GET',
152-
headers: {
153-
Authorization: `Bearer ${params.apiKey}`,
154-
},
155-
}
156-
)
151+
const statusResponse = await fetch(`https://api.browser-use.com/api/v2/tasks/${taskId}`, {
152+
method: 'GET',
153+
headers: {
154+
'X-Browser-Use-API-Key': params.apiKey,
155+
},
156+
})
157157

158158
if (!statusResponse.ok) {
159159
throw new Error(`Failed to get task status: ${statusResponse.statusText}`)
160160
}
161161

162-
const status = await statusResponse.json()
162+
const taskData = await statusResponse.json()
163+
const status = taskData.status
163164

164165
logger.info(`BrowserUse task ${taskId} status: ${status}`)
165166

166167
if (['finished', 'failed', 'stopped'].includes(status)) {
167-
const taskResponse = await fetch(`https://api.browser-use.com/api/v1/task/${taskId}`, {
168-
method: 'GET',
169-
headers: {
170-
Authorization: `Bearer ${params.apiKey}`,
171-
},
172-
})
173-
174-
if (taskResponse.ok) {
175-
const taskData = await taskResponse.json()
176-
result.output = {
177-
id: taskId,
178-
success: status === 'finished',
179-
output: taskData.output,
180-
steps: taskData.steps || [],
181-
}
168+
result.output = {
169+
id: taskId,
170+
success: status === 'finished',
171+
output: taskData.output ?? null,
172+
steps: taskData.steps || [],
182173
}
183174

184175
return result
185176
}
186177

187-
if (!liveUrlLogged && status === 'running') {
188-
const taskResponse = await fetch(`https://api.browser-use.com/api/v1/task/${taskId}`, {
189-
method: 'GET',
190-
headers: {
191-
Authorization: `Bearer ${params.apiKey}`,
192-
},
193-
})
194-
195-
if (taskResponse.ok) {
196-
const taskData = await taskResponse.json()
197-
if (taskData.live_url) {
198-
logger.info(`BrowserUse task ${taskId} running with live URL: ${taskData.live_url}`)
199-
liveUrlLogged = true
200-
}
201-
}
178+
if (!liveUrlLogged && status === 'running' && taskData.live_url) {
179+
logger.info(`BrowserUse task ${taskId} running with live URL: ${taskData.live_url}`)
180+
liveUrlLogged = true
202181
}
203182

204183
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS))

0 commit comments

Comments
 (0)