Skip to content

Commit 4d7885a

Browse files
committed
fix(blocks): address PR review — move remaining param mutations from tool() to params()
- Moved field mappings from tool() to params() in grafana, posthog, lemlist, spotify, dropbox (same dynamic reference bug) - Fixed parallel.ts excerpts/full_content boolean logic - Fixed parallel.ts search_queries empty case (must set undefined) - Fixed elasticsearch.ts timeout not included when already ends with 's' - Restored dropbox.ts tool() switch for proper default fallback
1 parent afe0289 commit 4d7885a

File tree

8 files changed

+46
-93
lines changed

8 files changed

+46
-93
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ export const ServiceBlock: BlockConfig = {
246246

247247
Register in `blocks/registry.ts` (alphabetically).
248248

249-
**IMPORTANT:** `tools.config.tool` runs during serialization (before variable resolution). Never do `Number()` or other type coercions there — dynamic references like `<Block.output>` will be destroyed. Use `tools.config.params` for type coercions (it runs during execution, after variables are resolved).
249+
**Important:** `tools.config.tool` runs during serialization (before variable resolution). Never do `Number()` or other type coercions there — dynamic references like `<Block.output>` will be destroyed. Use `tools.config.params` for type coercions (it runs during execution, after variables are resolved).
250250

251251
**SubBlock Properties:**
252252
```typescript

apps/sim/blocks/blocks/dropbox.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,6 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
309309
],
310310
config: {
311311
tool: (params) => {
312-
// Normalize file input for upload operation - use canonical 'file' param
313-
const normalizedFile = normalizeFileInput(params.file, { single: true })
314-
if (normalizedFile) {
315-
params.file = normalizedFile
316-
}
317-
318312
switch (params.operation) {
319313
case 'dropbox_upload':
320314
return 'dropbox_upload'
@@ -344,6 +338,10 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
344338
const result: Record<string, unknown> = {}
345339
if (params.limit) result.limit = Number(params.limit)
346340
if (params.maxResults) result.maxResults = Number(params.maxResults)
341+
const normalizedFile = normalizeFileInput(params.file, { single: true })
342+
if (normalizedFile) {
343+
result.file = normalizedFile
344+
}
347345
return result
348346
},
349347
},

apps/sim/blocks/blocks/elasticsearch.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,8 @@ Return ONLY valid JSON - no explanations, no markdown code blocks.`,
465465
if (params.size) result.size = Number(params.size)
466466
if (params.from) result.from = Number(params.from)
467467
if (params.retryOnConflict) result.retryOnConflict = Number(params.retryOnConflict)
468-
// Append 's' to timeout for Elasticsearch time format
469-
if (params.timeout && typeof params.timeout === 'string' && !params.timeout.endsWith('s')) {
470-
result.timeout = `${params.timeout}s`
468+
if (params.timeout && typeof params.timeout === 'string') {
469+
result.timeout = params.timeout.endsWith('s') ? params.timeout : `${params.timeout}s`
471470
}
472471
return result
473472
},

apps/sim/blocks/blocks/grafana.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -606,23 +606,6 @@ Return ONLY the folder title - no explanations, no quotes, no extra text.`,
606606
],
607607
config: {
608608
tool: (params) => {
609-
// Map subblock fields to tool parameter names
610-
if (params.alertTitle) {
611-
params.title = params.alertTitle
612-
}
613-
if (params.folderTitle) {
614-
params.title = params.folderTitle
615-
}
616-
if (params.folderUidNew) {
617-
params.uid = params.folderUidNew
618-
}
619-
if (params.annotationTags) {
620-
params.tags = params.annotationTags
621-
}
622-
if (params.annotationDashboardUid) {
623-
params.dashboardUid = params.annotationDashboardUid
624-
}
625-
626609
return params.operation
627610
},
628611
params: (params) => {
@@ -633,6 +616,11 @@ Return ONLY the folder title - no explanations, no quotes, no extra text.`,
633616
if (params.timeEnd) result.timeEnd = Number(params.timeEnd)
634617
if (params.from) result.from = Number(params.from)
635618
if (params.to) result.to = Number(params.to)
619+
if (params.alertTitle) result.title = params.alertTitle
620+
if (params.folderTitle) result.title = params.folderTitle
621+
if (params.folderUidNew) result.uid = params.folderUidNew
622+
if (params.annotationTags) result.tags = params.annotationTags
623+
if (params.annotationDashboardUid) result.dashboardUid = params.annotationDashboardUid
636624
return result
637625
},
638626
},

apps/sim/blocks/blocks/lemlist.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,6 @@ export const LemlistBlock: BlockConfig<LemlistResponse> = {
169169
access: ['lemlist_get_activities', 'lemlist_get_lead', 'lemlist_send_email'],
170170
config: {
171171
tool: (params) => {
172-
// Map filterLeadId to leadId for get_activities tool
173-
if (params.filterLeadId) {
174-
params.leadId = params.filterLeadId
175-
}
176-
177172
switch (params.operation) {
178173
case 'get_activities':
179174
return 'lemlist_get_activities'
@@ -189,6 +184,7 @@ export const LemlistBlock: BlockConfig<LemlistResponse> = {
189184
const result: Record<string, unknown> = {}
190185
if (params.limit) result.limit = Number(params.limit)
191186
if (params.offset) result.offset = Number(params.offset)
187+
if (params.filterLeadId) result.leadId = params.filterLeadId
192188
return result
193189
},
194190
},

apps/sim/blocks/blocks/parallel.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ export const ParallelBlock: BlockConfig<ToolResponse> = {
172172
.filter((query: string) => query.length > 0)
173173
if (queries.length > 0) {
174174
result.search_queries = queries
175+
} else {
176+
result.search_queries = undefined
175177
}
176178
}
177179
if (params.max_results) result.max_results = Number(params.max_results)
@@ -182,16 +184,8 @@ export const ParallelBlock: BlockConfig<ToolResponse> = {
182184

183185
if (operation === 'extract') {
184186
result.objective = params.extract_objective
185-
result.excerpts =
186-
params.excerpts === 'true' || params.excerpts === true
187-
? true
188-
: !(params.excerpts === 'false' || params.excerpts === false)
189-
result.full_content =
190-
params.full_content === 'true' || params.full_content === true
191-
? true
192-
: params.full_content === 'false' || params.full_content === false
193-
? false
194-
: false
187+
result.excerpts = !(params.excerpts === 'false' || params.excerpts === false)
188+
result.full_content = params.full_content === 'true' || params.full_content === true
195189
}
196190

197191
if (operation === 'deep_research') {

apps/sim/blocks/blocks/posthog.ts

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,96 +1185,84 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
11851185
],
11861186
config: {
11871187
tool: (params) => {
1188-
// Map projectIdParam to projectId for get_project operation
1188+
return params.operation as string
1189+
},
1190+
params: (params) => {
1191+
const result: Record<string, unknown> = {}
1192+
if (params.limit) result.limit = Number(params.limit)
1193+
if (params.offset) result.offset = Number(params.offset)
1194+
if (params.rolloutPercentage) result.rolloutPercentage = Number(params.rolloutPercentage)
1195+
if (params.responsesLimit) result.responsesLimit = Number(params.responsesLimit)
1196+
11891197
if (params.operation === 'posthog_get_project' && params.projectIdParam) {
1190-
params.projectId = params.projectIdParam
1198+
result.projectId = params.projectIdParam
11911199
}
1192-
1193-
// Map personalApiKey to apiKey for all private endpoint tools
11941200
if (params.personalApiKey) {
1195-
params.apiKey = params.personalApiKey
1201+
result.apiKey = params.personalApiKey
11961202
}
11971203

1198-
// Map featureFlagId to flagId for feature flag operations
11991204
const flagOps = [
12001205
'posthog_get_feature_flag',
12011206
'posthog_update_feature_flag',
12021207
'posthog_delete_feature_flag',
12031208
]
12041209
if (flagOps.includes(params.operation as string) && params.featureFlagId) {
1205-
params.flagId = params.featureFlagId
1210+
result.flagId = params.featureFlagId
12061211
}
12071212

1208-
// Map surveyType to type for survey operations
12091213
if (
12101214
(params.operation === 'posthog_create_survey' ||
12111215
params.operation === 'posthog_update_survey') &&
12121216
params.surveyType
12131217
) {
1214-
params.type = params.surveyType
1218+
result.type = params.surveyType
12151219
}
12161220

1217-
// Map isStatic for cohorts
12181221
if (params.operation === 'posthog_create_cohort' && params.isStatic !== undefined) {
1219-
params.is_static = params.isStatic
1222+
result.is_static = params.isStatic
12201223
}
12211224

1222-
// Map dateMarker to date_marker for annotations
12231225
if (params.operation === 'posthog_create_annotation' && params.dateMarker) {
1224-
params.date_marker = params.dateMarker
1226+
result.date_marker = params.dateMarker
12251227
}
12261228

1227-
// Map propertyType to property_type
12281229
if (params.operation === 'posthog_update_property_definition' && params.propertyType) {
1229-
params.property_type = params.propertyType
1230+
result.property_type = params.propertyType
12301231
}
12311232

1232-
// Map insightQuery to query for insights
12331233
if (params.operation === 'posthog_create_insight' && params.insightQuery) {
1234-
params.query = params.insightQuery
1234+
result.query = params.insightQuery
12351235
}
12361236

1237-
// Map insightTags to tags for insights
12381237
if (params.operation === 'posthog_create_insight' && params.insightTags) {
1239-
params.tags = params.insightTags
1238+
result.tags = params.insightTags
12401239
}
12411240

1242-
// Map distinctIdFilter to distinctId for list_persons
12431241
if (params.operation === 'posthog_list_persons' && params.distinctIdFilter) {
1244-
params.distinctId = params.distinctIdFilter
1242+
result.distinctId = params.distinctIdFilter
12451243
}
12461244

1247-
// Map experiment date fields
12481245
if (params.operation === 'posthog_create_experiment') {
12491246
if (params.experimentStartDate) {
1250-
params.startDate = params.experimentStartDate
1247+
result.startDate = params.experimentStartDate
12511248
}
12521249
if (params.experimentEndDate) {
1253-
params.endDate = params.experimentEndDate
1250+
result.endDate = params.experimentEndDate
12541251
}
12551252
}
12561253

1257-
// Map survey date fields
12581254
if (
12591255
params.operation === 'posthog_create_survey' ||
12601256
params.operation === 'posthog_update_survey'
12611257
) {
12621258
if (params.surveyStartDate) {
1263-
params.startDate = params.surveyStartDate
1259+
result.startDate = params.surveyStartDate
12641260
}
12651261
if (params.surveyEndDate) {
1266-
params.endDate = params.surveyEndDate
1262+
result.endDate = params.surveyEndDate
12671263
}
12681264
}
12691265

1270-
return params.operation as string
1271-
},
1272-
params: (params) => {
1273-
const result: Record<string, unknown> = {}
1274-
if (params.limit) result.limit = Number(params.limit)
1275-
if (params.offset) result.offset = Number(params.offset)
1276-
if (params.rolloutPercentage) result.rolloutPercentage = Number(params.rolloutPercentage)
1277-
if (params.responsesLimit) result.responsesLimit = Number(params.responsesLimit)
12781266
return result
12791267
},
12801268
},

apps/sim/blocks/blocks/spotify.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -755,22 +755,6 @@ export const SpotifyBlock: BlockConfig<ToolResponse> = {
755755
],
756756
config: {
757757
tool: (params) => {
758-
// Map followType to type for check_following
759-
if (params.followType) {
760-
params.type = params.followType
761-
}
762-
// Map newName to name for update_playlist
763-
if (params.newName) {
764-
params.name = params.newName
765-
}
766-
// Map playUris to uris for play
767-
if (params.playUris) {
768-
params.uris = params.playUris
769-
}
770-
// Normalize file input for cover image
771-
if (params.coverImage !== undefined) {
772-
params.coverImage = normalizeFileInput(params.coverImage, { single: true })
773-
}
774758
return params.operation || 'spotify_search'
775759
},
776760
params: (params) => {
@@ -781,6 +765,12 @@ export const SpotifyBlock: BlockConfig<ToolResponse> = {
781765
if (params.insert_before) result.insert_before = Number(params.insert_before)
782766
if (params.range_length) result.range_length = Number(params.range_length)
783767
if (params.position_ms) result.position_ms = Number(params.position_ms)
768+
if (params.followType) result.type = params.followType
769+
if (params.newName) result.name = params.newName
770+
if (params.playUris) result.uris = params.playUris
771+
if (params.coverImage !== undefined) {
772+
result.coverImage = normalizeFileInput(params.coverImage, { single: true })
773+
}
784774
return result
785775
},
786776
},

0 commit comments

Comments
 (0)