Skip to content

Commit 71257d3

Browse files
committed
fix(blocks): keep tool-row conflictTarget, parse affinity rank/winRate args, fix CI type and canonical-id checks
Table upsert keeps a tool row's conflictTarget when conflictColumn is unset; affinity parses model rank/winRate through the same numeric validation; instantly treats a whitespace interestValue as empty on tool calls; file reads the model folderPath via its canonical folderRef; dub's mapper context is optional; buffer test typing; shrink the test-types baseline for ashby.
1 parent fa8953f commit 71257d3

8 files changed

Lines changed: 41 additions & 25 deletions

File tree

‎apps/sim/blocks/blocks/affinity.ts‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
mapperOperation,
77
parseOptionalBooleanInput,
88
parseOptionalNumberInput,
9+
toolCallArg,
910
withSavedCredential,
1011
} from '@/blocks/utils'
1112

@@ -1435,16 +1436,24 @@ export const AffinityBlock: BlockConfig = {
14351436
isPublic: isCreateList ? parseOptionalBooleanInput(params.isPublic) : undefined,
14361437
text: isDropdownWrite ? params.optionText : undefined,
14371438
rank: isDropdownWrite
1438-
? parseOptionalNumberInput(params.optionRank, 'Option Rank', { integer: true, min: 0 })
1439+
? parseOptionalNumberInput(
1440+
params.optionRank ?? toolCallArg(context, params.rank),
1441+
'Option Rank',
1442+
{ integer: true, min: 0 }
1443+
)
14391444
: undefined,
14401445
color: isDropdownWrite ? params.optionColor : undefined,
14411446
statusCategory: isDropdownWrite ? params.optionStatusCategory : undefined,
14421447
winRate: isDropdownWrite
1443-
? parseOptionalNumberInput(params.optionWinRate, 'Win Rate', {
1444-
integer: true,
1445-
min: 0,
1446-
max: 100,
1447-
})
1448+
? parseOptionalNumberInput(
1449+
params.optionWinRate ?? toolCallArg(context, params.winRate),
1450+
'Win Rate',
1451+
{
1452+
integer: true,
1453+
min: 0,
1454+
max: 100,
1455+
}
1456+
)
14481457
: undefined,
14491458
value: isIn(FIELD_VALUE_WRITE_OPERATIONS) ? params.fieldValue : undefined,
14501459
updates: isIn(FIELD_BATCH_WRITE_OPERATIONS) ? params.fieldUpdates : undefined,

‎apps/sim/blocks/blocks/buffer.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const mapToolParams = mapper
88
describe('BufferBlock tool calls', () => {
99
it('turns the default share mode into addToQueue when creating a post', () => {
1010
const merged = { apiKey: 'key', channelId: 'ch_1', text: 'Hello', mode: 'default' }
11-
const params = {
11+
const params: Record<string, unknown> = {
1212
...merged,
1313
...mapToolParams(merged, { operation: 'create_post' }),
1414
}

‎apps/sim/blocks/blocks/dub.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { omit } from '@sim/utils/object'
22
import { DubIcon } from '@/components/icons'
3-
import type { BlockConfig, BlockMeta } from '@/blocks/types'
3+
import type { BlockConfig, BlockMeta, BlockToolParamsContext } from '@/blocks/types'
44
import { AuthMode, IntegrationType } from '@/blocks/types'
55
import { isToolCall, mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils'
66

@@ -1032,7 +1032,7 @@ export const DubBlock = {
10321032
],
10331033
config: {
10341034
tool: (params) => `dub_${params.operation}`,
1035-
params: (params, context) => {
1035+
params: (params, context?: BlockToolParamsContext) => {
10361036
const operation = mapperOperation(params, context)
10371037
const result: Record<string, unknown> = {}
10381038
const isLinkMutation =

‎apps/sim/blocks/blocks/file.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,12 +1962,9 @@ export const FileV5Block: BlockConfig = {
19621962
const operation = mapperOperation(params, context) || 'file_read'
19631963
/**
19641964
* A tool call's `folderPath` arg shares its name with the basic half of the `folderRef`
1965-
* pair, so the canonical pass may have republished it there. Read on tool calls only.
1965+
* pair, so the canonical pass republishes it as `folderRef`. Read on tool calls only.
19661966
*/
1967-
const modelFolderPath = toolCallArg(
1968-
context,
1969-
optionalText(params.folderPath) ?? optionalText(params.folderRef)
1970-
)
1967+
const modelFolderPath = toolCallArg(context, optionalText(params.folderRef))
19711968

19721969
if (operation === 'file_search') {
19731970
const maxResultsInput =

‎apps/sim/blocks/blocks/instantly.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,9 @@ function mapInterestValueParam(
14331433
toolCall: boolean
14341434
): number | null | undefined {
14351435
if (operation !== 'update_lead_interest_status') return undefined
1436-
const blockValueEmpty = params.interestValue === undefined || params.interestValue === ''
1436+
const blockValueEmpty =
1437+
params.interestValue === undefined ||
1438+
(typeof params.interestValue === 'string' && params.interestValue.trim() === '')
14371439
if (toolCall && blockValueEmpty) return toNullableNumberParam(params.interest_value)
14381440
return toNullableNumberParam(params.interestValue, true)
14391441
}

‎apps/sim/blocks/blocks/table.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
resolveTableColumnSelection,
1111
TABLE_OUTPUT_COLUMNS_INPUT,
1212
TABLE_OUTPUT_COLUMNS_SUBBLOCK,
13+
toolCallArg,
1314
} from '@/blocks/utils'
1415
import { TABLE_ID_PARAM } from '@/tools/table/params'
1516
import { getTrigger } from '@/triggers'
@@ -70,6 +71,8 @@ interface TableBlockParams {
7071
bulkFilterMode?: string
7172
bulkFilterBuilder?: unknown
7273
conflictColumn?: string
74+
/** The tool's own `conflictTarget` param, set in an Agent tool row. */
75+
conflictTarget?: string
7376
}
7477

7578
/** Normalized params after parsing, ready for tool request body */
@@ -131,10 +134,11 @@ const paramTransformers: Record<
131134
data: parseJSON(params.data, 'Row Data'),
132135
}),
133136

134-
upsert_row: (params) => ({
137+
upsert_row: (params, context) => ({
135138
tableId: params.tableId,
136139
data: parseJSON(params.data, 'Row Data'),
137-
conflictTarget: params.conflictColumn || undefined,
140+
conflictTarget:
141+
params.conflictColumn || toolCallArg(context, params.conflictTarget) || undefined,
138142
}),
139143

140144
batch_insert_rows: (params) => ({

‎apps/sim/blocks/blocks/table_v2.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import type {
1111
TablePredicate,
1212
TablePredicateInput,
1313
} from '@/lib/table/types'
14-
import type { BlockConfig } from '@/blocks/types'
14+
import type { BlockConfig, BlockToolParamsContext } from '@/blocks/types'
1515
import {
1616
mapperOperation,
1717
resolveTableColumnSelection,
1818
TABLE_OUTPUT_COLUMNS_INPUT,
1919
TABLE_OUTPUT_COLUMNS_SUBBLOCK,
20+
toolCallArg,
2021
} from '@/blocks/utils'
2122
import { TABLE_ID_PARAM } from '@/tools/table/params'
2223
import { getTrigger } from '@/triggers'
@@ -66,6 +67,8 @@ interface TableBlockParams {
6667
limit?: string
6768
cursor?: string
6869
conflictColumn?: string
70+
/** The tool's own `conflictTarget` param, set in an Agent tool row. */
71+
conflictTarget?: string
6972
}
7073

7174
/**
@@ -146,16 +149,20 @@ function resolveCursor(raw: string | undefined): string | undefined {
146149
return raw
147150
}
148151

149-
const paramTransformers: Record<string, (params: TableBlockParams) => ParsedParams> = {
152+
const paramTransformers: Record<
153+
string,
154+
(params: TableBlockParams, context: BlockToolParamsContext | undefined) => ParsedParams
155+
> = {
150156
insert_row: (params) => ({
151157
tableId: params.tableId,
152158
data: parseJSON(params.data, 'Row Data'),
153159
}),
154160

155-
upsert_row: (params) => ({
161+
upsert_row: (params, context) => ({
156162
tableId: params.tableId,
157163
data: parseJSON(params.data, 'Row Data'),
158-
conflictTarget: params.conflictColumn || undefined,
164+
conflictTarget:
165+
params.conflictColumn || toolCallArg(context, params.conflictTarget) || undefined,
159166
}),
160167

161168
batch_insert_rows: (params) => ({
@@ -562,7 +569,7 @@ Return ONLY the JSON object:`,
562569
const { operation, ...rest } = params
563570
const transformer = paramTransformers[mapperOperation(params, context)]
564571
if (transformer) {
565-
return transformer(rest as TableBlockParams)
572+
return transformer(rest as TableBlockParams, context)
566573
}
567574
return rest
568575
},

‎scripts/check-test-types.baseline.json‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,6 @@
624624
"apps/sim/blocks/blocks/airtable.test.ts": {
625625
"TS18048": 1
626626
},
627-
"apps/sim/blocks/blocks/ashby.test.ts": {
628-
"TS18048": 11
629-
},
630627
"apps/sim/blocks/blocks/cloudtrail.test.ts": {
631628
"TS2554": 1
632629
},

0 commit comments

Comments
 (0)