Skip to content

Commit f3a65e1

Browse files
authored
fix(brightdata): align integration with live API docs, add markdown/mode/error-report support (#5470)
* fix(brightdata): align integration with live API docs, add markdown/mode/error-report support - fix Discover numResults docs (max 20, not 1000) and contentFormat value ("md" not "markdown", which the API always rejected) - add Discover mode param (standard/deep/fast/zeroRanking) - add markdown output support to Web Unlocker scrape_url via data_format - add include_errors support to scrape_dataset, matching sync_scrape - add .trim() on datasetId in scrape_dataset/sync_scrape URLs - add wandConfig on complex fields, tighten block output descriptions * fix(brightdata): default mode field to empty so it's opt-in like other advanced params Greptile flagged that mode shipped with a non-empty default ('standard'), causing it to be sent on every Discover call unlike the sibling dataFormat field which uses an empty/None default and only sends when the user opts in. Aligns mode with that same pattern.
1 parent a5b8c7e commit f3a65e1

6 files changed

Lines changed: 114 additions & 8 deletions

File tree

apps/sim/blocks/blocks/brightdata.ts

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
5959
value: () => 'raw',
6060
condition: { field: 'operation', value: 'scrape_url' },
6161
},
62+
{
63+
id: 'dataFormat',
64+
title: 'Convert To',
65+
type: 'dropdown',
66+
options: [
67+
{ label: 'None', id: '' },
68+
{ label: 'Markdown', id: 'markdown' },
69+
],
70+
value: () => '',
71+
mode: 'advanced',
72+
condition: { field: 'operation', value: 'scrape_url' },
73+
},
6274
{
6375
id: 'country',
6476
title: 'Country',
@@ -119,6 +131,26 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
119131
placeholder:
120132
'Describe what you are looking for (e.g., "find official pricing pages and change notes")',
121133
condition: { field: 'operation', value: 'discover' },
134+
wandConfig: {
135+
enabled: true,
136+
prompt:
137+
'Generate a concise description of what the agent is trying to accomplish, to help rank web-discovery results by relevance (e.g., "find official pricing pages and recent change notes"). Return ONLY the intent description - no explanations, no extra text.',
138+
placeholder: 'Describe what you are trying to accomplish...',
139+
},
140+
},
141+
{
142+
id: 'mode',
143+
title: 'Search Mode',
144+
type: 'dropdown',
145+
options: [
146+
{ label: 'Standard (Default)', id: '' },
147+
{ label: 'Deep', id: 'deep' },
148+
{ label: 'Fast', id: 'fast' },
149+
{ label: 'Zero Ranking', id: 'zeroRanking' },
150+
],
151+
value: () => '',
152+
mode: 'advanced',
153+
condition: { field: 'operation', value: 'discover' },
122154
},
123155
{
124156
id: 'includeContent',
@@ -133,7 +165,7 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
133165
type: 'dropdown',
134166
options: [
135167
{ label: 'JSON', id: 'json' },
136-
{ label: 'Markdown', id: 'markdown' },
168+
{ label: 'Markdown', id: 'md' },
137169
],
138170
value: () => 'json',
139171
mode: 'advanced',
@@ -154,6 +186,12 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
154186
placeholder: '[{"url": "https://example.com/product"}]',
155187
condition: { field: 'operation', value: 'sync_scrape' },
156188
required: { field: 'operation', value: 'sync_scrape' },
189+
wandConfig: {
190+
enabled: true,
191+
prompt:
192+
'Generate a JSON array of URL objects to scrape based on the user\'s description, in the form [{"url": "https://example.com/product"}]. Return ONLY the JSON array - no explanations, no extra text.',
193+
placeholder: 'Describe the URLs to scrape...',
194+
},
157195
},
158196
{
159197
id: 'syncFormat',
@@ -167,6 +205,13 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
167205
value: () => 'json',
168206
condition: { field: 'operation', value: 'sync_scrape' },
169207
},
208+
{
209+
id: 'syncIncludeErrors',
210+
title: 'Include Errors',
211+
type: 'switch',
212+
mode: 'advanced',
213+
condition: { field: 'operation', value: 'sync_scrape' },
214+
},
170215
{
171216
id: 'datasetId',
172217
title: 'Dataset ID',
@@ -182,6 +227,12 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
182227
placeholder: '[{"url": "https://example.com/product"}]',
183228
condition: { field: 'operation', value: 'scrape_dataset' },
184229
required: { field: 'operation', value: 'scrape_dataset' },
230+
wandConfig: {
231+
enabled: true,
232+
prompt:
233+
'Generate a JSON array of URL objects to scrape based on the user\'s description, in the form [{"url": "https://example.com/product"}]. Return ONLY the JSON array - no explanations, no extra text.',
234+
placeholder: 'Describe the URLs to scrape...',
235+
},
185236
},
186237
{
187238
id: 'datasetFormat',
@@ -194,6 +245,13 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
194245
value: () => 'json',
195246
condition: { field: 'operation', value: 'scrape_dataset' },
196247
},
248+
{
249+
id: 'datasetIncludeErrors',
250+
title: 'Include Errors',
251+
type: 'switch',
252+
mode: 'advanced',
253+
condition: { field: 'operation', value: 'scrape_dataset' },
254+
},
197255
{
198256
id: 'snapshotId',
199257
title: 'Snapshot ID',
@@ -251,6 +309,7 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
251309
result.url = params.url
252310
if (params.format) result.format = params.format
253311
if (params.country) result.country = params.country
312+
if (params.dataFormat) result.dataFormat = params.dataFormat
254313
break
255314

256315
case 'serp_search':
@@ -265,6 +324,7 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
265324
case 'discover':
266325
result.query = params.discoverQuery
267326
if (params.numResults) result.numResults = Number(params.numResults)
327+
if (params.mode) result.mode = params.mode
268328
if (params.intent) result.intent = params.intent
269329
if (params.includeContent != null) result.includeContent = params.includeContent
270330
if (params.contentFormat) result.format = params.contentFormat
@@ -276,12 +336,15 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
276336
result.datasetId = params.syncDatasetId
277337
result.urls = params.syncUrls
278338
if (params.syncFormat) result.format = params.syncFormat
339+
if (params.syncIncludeErrors != null) result.includeErrors = params.syncIncludeErrors
279340
break
280341

281342
case 'scrape_dataset':
282343
result.datasetId = params.datasetId
283344
result.urls = params.urls
284345
if (params.datasetFormat) result.format = params.datasetFormat
346+
if (params.datasetIncludeErrors != null)
347+
result.includeErrors = params.datasetIncludeErrors
285348
break
286349

287350
case 'snapshot_status':
@@ -308,33 +371,50 @@ export const BrightDataBlock: BlockConfig<BrightDataResponse> = {
308371
zone: { type: 'string', description: 'Bright Data zone name' },
309372
url: { type: 'string', description: 'URL to scrape' },
310373
format: { type: 'string', description: 'Response format' },
374+
dataFormat: { type: 'string', description: 'Convert scraped content to markdown' },
311375
country: { type: 'string', description: 'Country code for geo-targeting' },
312376
query: { type: 'string', description: 'Search query' },
313377
searchEngine: { type: 'string', description: 'Search engine to use' },
314378
language: { type: 'string', description: 'Language code' },
315379
numResults: { type: 'number', description: 'Number of results' },
316380
discoverQuery: { type: 'string', description: 'Discover search query' },
317381
intent: { type: 'string', description: 'Intent for ranking results' },
382+
mode: { type: 'string', description: 'Search depth and ranking mode for discover' },
318383
includeContent: { type: 'boolean', description: 'Include page content in discover results' },
319384
contentFormat: { type: 'string', description: 'Content format for discover results' },
320385
syncDatasetId: { type: 'string', description: 'Dataset scraper ID for sync scrape' },
321386
syncUrls: { type: 'string', description: 'JSON array of URL objects for sync scrape' },
322387
syncFormat: { type: 'string', description: 'Output format for sync scrape' },
388+
syncIncludeErrors: {
389+
type: 'boolean',
390+
description: 'Include error reports in sync scrape results',
391+
},
323392
datasetId: { type: 'string', description: 'Dataset scraper ID' },
324393
urls: { type: 'string', description: 'JSON array of URL objects to scrape' },
325394
datasetFormat: { type: 'string', description: 'Dataset output format' },
395+
datasetIncludeErrors: {
396+
type: 'boolean',
397+
description: 'Include error reports in scrape dataset results',
398+
},
326399
snapshotId: { type: 'string', description: 'Snapshot ID for status/download/cancel' },
327400
downloadFormat: { type: 'string', description: 'Download output format' },
328401
},
329402
outputs: {
330403
content: { type: 'string', description: 'Scraped page content' },
331404
url: { type: 'string', description: 'URL that was scraped' },
332405
statusCode: { type: 'number', description: 'HTTP status code' },
333-
results: { type: 'json', description: 'Search or discover results array' },
406+
results: {
407+
type: 'json',
408+
description:
409+
'Search or discover results array: [{title, url, description, rank}] for SERP search, or [{url, title, description, relevanceScore, content}] for discover',
410+
},
334411
query: { type: 'string', description: 'Search query executed' },
335412
searchEngine: { type: 'string', description: 'Search engine used' },
336413
totalResults: { type: 'number', description: 'Total number of discover results' },
337-
data: { type: 'json', description: 'Scraped data records' },
414+
data: {
415+
type: 'json',
416+
description: 'Array of scraped result records with dataset-specific fields',
417+
},
338418
snapshotId: { type: 'string', description: 'Snapshot ID' },
339419
isAsync: { type: 'boolean', description: 'Whether sync scrape fell back to async' },
340420
status: { type: 'string', description: 'Job status' },

apps/sim/tools/brightdata/discover.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const brightDataDiscoverTool: ToolConfig<
1717
id: 'brightdata_discover',
1818
name: 'Bright Data Discover',
1919
description:
20-
'AI-powered web discovery that finds and ranks results by intent. Returns up to 1,000 results with optional cleaned page content for RAG and verification.',
20+
'AI-powered web discovery that finds and ranks results by intent. Returns up to 20 results with optional cleaned page content for RAG and verification.',
2121
version: '1.0.0',
2222

2323
params: {
@@ -37,7 +37,14 @@ export const brightDataDiscoverTool: ToolConfig<
3737
type: 'number',
3838
required: false,
3939
visibility: 'user-or-llm',
40-
description: 'Number of results to return, up to 1000. Defaults to 10',
40+
description: 'Number of results to return (1-20). Defaults to 10',
41+
},
42+
mode: {
43+
type: 'string',
44+
required: false,
45+
visibility: 'user-or-llm',
46+
description:
47+
'Search depth and ranking mode: "standard" (balanced), "deep" (exhaustive, broader search), "fast" (optimized for speed), or "zeroRanking" (raw volume without AI filtering). Defaults to "standard"',
4148
},
4249
intent: {
4350
type: 'string',
@@ -56,7 +63,7 @@ export const brightDataDiscoverTool: ToolConfig<
5663
type: 'string',
5764
required: false,
5865
visibility: 'user-or-llm',
59-
description: 'Response format: "json" or "markdown". Defaults to "json"',
66+
description: 'Response format: "json" or "md". Defaults to "json"',
6067
},
6168
language: {
6269
type: 'string',
@@ -84,6 +91,7 @@ export const brightDataDiscoverTool: ToolConfig<
8491
query: params.query,
8592
}
8693
if (params.numResults) body.num_results = params.numResults
94+
if (params.mode) body.mode = params.mode
8795
if (params.intent) body.intent = params.intent
8896
if (params.includeContent != null) body.include_content = params.includeContent
8997
if (params.format) body.format = params.format

apps/sim/tools/brightdata/scrape_dataset.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,21 @@ export const brightDataScrapeDatasetTool: ToolConfig<
4141
visibility: 'user-or-llm',
4242
description: 'Output format: "json" or "csv". Defaults to "json"',
4343
},
44+
includeErrors: {
45+
type: 'boolean',
46+
required: false,
47+
visibility: 'user-or-llm',
48+
description: 'Whether to include a per-input error report in the results',
49+
},
4450
},
4551

4652
request: {
4753
method: 'POST',
4854
url: (params) => {
4955
const queryParams = new URLSearchParams()
50-
queryParams.set('dataset_id', params.datasetId)
56+
queryParams.set('dataset_id', params.datasetId.trim())
5157
queryParams.set('format', params.format || 'json')
58+
if (params.includeErrors) queryParams.set('include_errors', 'true')
5259
return `https://api.brightdata.com/datasets/v3/trigger?${queryParams.toString()}`
5360
},
5461
headers: (params) => ({

apps/sim/tools/brightdata/scrape_url.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ export const brightDataScrapeUrlTool: ToolConfig<
4646
visibility: 'user-or-llm',
4747
description: 'Two-letter country code for geo-targeting (e.g., "us", "gb")',
4848
},
49+
dataFormat: {
50+
type: 'string',
51+
required: false,
52+
visibility: 'user-or-llm',
53+
description:
54+
'Convert the response to "markdown" instead of raw HTML, useful for feeding page content to an LLM. Omit for the default HTML/JSON response',
55+
},
4956
},
5057

5158
request: {
@@ -62,6 +69,7 @@ export const brightDataScrapeUrlTool: ToolConfig<
6269
format: params.format || 'raw',
6370
}
6471
if (params.country) body.country = params.country
72+
if (params.dataFormat) body.data_format = params.dataFormat
6573
return body
6674
},
6775
},

apps/sim/tools/brightdata/sync_scrape.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const brightDataSyncScrapeTool: ToolConfig<
5353
method: 'POST',
5454
url: (params) => {
5555
const queryParams = new URLSearchParams()
56-
queryParams.set('dataset_id', params.datasetId)
56+
queryParams.set('dataset_id', params.datasetId.trim())
5757
queryParams.set('format', params.format || 'json')
5858
if (params.includeErrors) queryParams.set('include_errors', 'true')
5959
return `https://api.brightdata.com/datasets/v3/scrape?${queryParams.toString()}`

apps/sim/tools/brightdata/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface BrightDataScrapeUrlParams {
66
url: string
77
format?: string
88
country?: string
9+
dataFormat?: string
910
}
1011

1112
export interface BrightDataScrapeUrlResponse extends ToolResponse {
@@ -44,6 +45,7 @@ export interface BrightDataScrapeDatasetParams {
4445
datasetId: string
4546
urls: string
4647
format?: string
48+
includeErrors?: boolean
4749
}
4850

4951
export interface BrightDataScrapeDatasetResponse extends ToolResponse {
@@ -113,6 +115,7 @@ export interface BrightDataDiscoverParams {
113115
apiKey: string
114116
query: string
115117
numResults?: number
118+
mode?: string
116119
intent?: string
117120
includeContent?: boolean
118121
format?: string

0 commit comments

Comments
 (0)