Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/docs/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1739,12 +1739,12 @@ export function BrowserUseIcon(props: SVGProps<SVGSVGElement>) {
{...props}
version='1.0'
xmlns='http://www.w3.org/2000/svg'
width='150pt'
height='150pt'
width='28'
height='28'
viewBox='0 0 150 150'
preserveAspectRatio='xMidYMid meet'
>
<g transform='translate(0,150) scale(0.05,-0.05)' fill='#000000' stroke='none'>
<g transform='translate(0,150) scale(0.05,-0.05)' fill='currentColor' stroke='none'>
<path
d='M786 2713 c-184 -61 -353 -217 -439 -405 -76 -165 -65 -539 19 -666
l57 -85 -48 -124 c-203 -517 -79 -930 346 -1155 159 -85 441 -71 585 28 l111
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/en/tools/browser_use.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BlockInfoCard } from "@/components/ui/block-info-card"

<BlockInfoCard
type="browser_use"
color="#E0E0E0"
color="#181C1E"
/>

{/* MANUAL-CONTENT-START:intro */}
Expand Down
33 changes: 33 additions & 0 deletions apps/docs/content/docs/en/tools/google_slides.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ Read content from a Google Slides presentation
| --------- | ---- | ----------- |
| `slides` | json | Array of slides with their content |
| `metadata` | json | Presentation metadata including ID, title, and URL |
| ↳ `presentationId` | string | The presentation ID |
| ↳ `title` | string | The presentation title |
| ↳ `pageSize` | object | Presentation page size |
| ↳ `width` | json | Page width as a Dimension object |
| ↳ `height` | json | Page height as a Dimension object |
| ↳ `width` | json | Page width as a Dimension object |
| ↳ `height` | json | Page height as a Dimension object |
| ↳ `mimeType` | string | The mime type of the presentation |
| ↳ `url` | string | URL to open the presentation |

### `google_slides_write`

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

### `google_slides_create`

Expand All @@ -90,6 +103,10 @@ Create a new Google Slides presentation
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `metadata` | json | Created presentation metadata including ID, title, and URL |
| ↳ `presentationId` | string | The presentation ID |
| ↳ `title` | string | The presentation title |
| ↳ `mimeType` | string | The mime type of the presentation |
| ↳ `url` | string | URL to open the presentation |

### `google_slides_replace_all_text`

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

### `google_slides_add_slide`

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

### `google_slides_add_image`

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

### `google_slides_get_thumbnail`

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

### `google_slides_get_page`

Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/browser_use.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const BrowserUseBlock: BlockConfig<BrowserUseResponse> = {
'Integrate Browser Use into the workflow. Can navigate the web and perform actions as if a real user was interacting with the browser.',
docsLink: 'https://docs.sim.ai/tools/browser_use',
category: 'tools',
bgColor: '#E0E0E0',
bgColor: '#181C1E',
icon: BrowserUseIcon,
subBlocks: [
{
Expand Down
6 changes: 3 additions & 3 deletions apps/sim/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1739,12 +1739,12 @@ export function BrowserUseIcon(props: SVGProps<SVGSVGElement>) {
{...props}
version='1.0'
xmlns='http://www.w3.org/2000/svg'
width='150pt'
height='150pt'
width='28'
height='28'
viewBox='0 0 150 150'
preserveAspectRatio='xMidYMid meet'
>
<g transform='translate(0,150) scale(0.05,-0.05)' fill='#000000' stroke='none'>
<g transform='translate(0,150) scale(0.05,-0.05)' fill='currentColor' stroke='none'>
<path
d='M786 2713 c-184 -61 -353 -217 -439 -405 -76 -165 -65 -539 19 -666
l57 -85 -48 -124 c-203 -517 -79 -930 346 -1155 159 -85 441 -71 585 28 l111
Expand Down
75 changes: 27 additions & 48 deletions apps/sim/tools/browser_use/run_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export const runTaskTool: ToolConfig<BrowserUseRunTaskParams, BrowserUseRunTaskR
},
},
request: {
url: 'https://api.browser-use.com/api/v1/run-task',
url: 'https://api.browser-use.com/api/v2/tasks',
method: 'POST',
headers: (params) => ({
'Content-Type': 'application/json',
Authorization: `Bearer ${params.apiKey}`,
'X-Browser-Use-API-Key': params.apiKey,
}),
body: (params) => {
const requestBody: Record<string, any> = {
Expand Down Expand Up @@ -121,12 +121,15 @@ export const runTaskTool: ToolConfig<BrowserUseRunTaskParams, BrowserUseRunTaskR
let liveUrlLogged = false

try {
const initialTaskResponse = await fetch(`https://api.browser-use.com/api/v1/task/${taskId}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${params.apiKey}`,
},
})
const initialTaskResponse = await fetch(
`https://api.browser-use.com/api/v2/tasks/${taskId}`,
{
method: 'GET',
headers: {
'X-Browser-Use-API-Key': params.apiKey,
},
}
)

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

while (elapsedTime < MAX_POLL_TIME_MS) {
try {
const statusResponse = await fetch(
`https://api.browser-use.com/api/v1/task/${taskId}/status`,
{
method: 'GET',
headers: {
Authorization: `Bearer ${params.apiKey}`,
},
}
)
const statusResponse = await fetch(`https://api.browser-use.com/api/v2/tasks/${taskId}`, {
method: 'GET',
headers: {
'X-Browser-Use-API-Key': params.apiKey,
},
})

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

const status = await statusResponse.json()
const taskData = await statusResponse.json()
const status = taskData.status

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

if (['finished', 'failed', 'stopped'].includes(status)) {
const taskResponse = await fetch(`https://api.browser-use.com/api/v1/task/${taskId}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${params.apiKey}`,
},
})

if (taskResponse.ok) {
const taskData = await taskResponse.json()
result.output = {
id: taskId,
success: status === 'finished',
output: taskData.output,
steps: taskData.steps || [],
}
result.output = {
id: taskId,
success: status === 'finished',
output: taskData.output ?? null,
steps: taskData.steps || [],
}

return result
}

if (!liveUrlLogged && status === 'running') {
const taskResponse = await fetch(`https://api.browser-use.com/api/v1/task/${taskId}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${params.apiKey}`,
},
})

if (taskResponse.ok) {
const taskData = await taskResponse.json()
if (taskData.live_url) {
logger.info(`BrowserUse task ${taskId} running with live URL: ${taskData.live_url}`)
liveUrlLogged = true
}
}
if (!liveUrlLogged && status === 'running' && taskData.live_url) {
logger.info(`BrowserUse task ${taskId} running with live URL: ${taskData.live_url}`)
liveUrlLogged = true
}

await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS))
Expand Down
Loading