From c31569095ca9c480e33c4f23f545dddd7094644c Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 15 Nov 2026 16:41:49 -0800 Subject: [PATCH 1/6] =?UTF-8?q?fix(integrations):=20sweep2=20m4=20?= =?UTF-8?q?=E2=80=94=20read=20the=20mapper=20operation=20from=20the=20tool?= =?UTF-8?q?-call=20context=20and=20validate=20integrations=20against=20ven?= =?UTF-8?q?dor=20specs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/sim/blocks/blocks/jotform.test.ts | 10 + apps/sim/blocks/blocks/jotform.ts | 6 +- apps/sim/blocks/blocks/kalshi.test.ts | 16 + apps/sim/blocks/blocks/kalshi.ts | 6 +- apps/sim/blocks/blocks/ketch.test.ts | 24 + apps/sim/blocks/blocks/ketch.ts | 12 +- apps/sim/blocks/blocks/langsmith.test.ts | 18 + apps/sim/blocks/blocks/langsmith.ts | 18 +- apps/sim/blocks/blocks/launchdarkly.test.ts | 23 + apps/sim/blocks/blocks/launchdarkly.ts | 17 +- apps/sim/blocks/blocks/linkedin.ts | 5 +- apps/sim/blocks/blocks/linq.test.ts | 20 + apps/sim/blocks/blocks/linq.ts | 12 +- apps/sim/blocks/blocks/loops.ts | 11 +- apps/sim/blocks/blocks/manageengine-sdp.ts | 17 +- apps/sim/blocks/blocks/mem0.test.ts | 14 + apps/sim/blocks/blocks/mem0.ts | 22 +- apps/sim/blocks/blocks/mintlify.test.ts | 17 + apps/sim/blocks/blocks/mintlify.ts | 32 +- apps/sim/blocks/blocks/netsuite.test.ts | 24 + apps/sim/blocks/blocks/netsuite.ts | 17 +- apps/sim/blocks/blocks/otter.ts | 6 +- apps/sim/blocks/blocks/parallel.test.ts | 15 + apps/sim/blocks/blocks/parallel.ts | 15 +- apps/sim/blocks/blocks/peopledatalabs.test.ts | 27 + apps/sim/blocks/blocks/peopledatalabs.ts | 10 +- apps/sim/blocks/blocks/perplexity.test.ts | 27 + apps/sim/blocks/blocks/perplexity.ts | 15 +- apps/sim/blocks/blocks/persona.test.ts | 20 + apps/sim/blocks/blocks/persona.ts | 6 +- apps/sim/blocks/blocks/pitchbook.test.ts | 24 + apps/sim/blocks/blocks/pitchbook.ts | 13 +- apps/sim/blocks/blocks/plane.test.ts | 19 + apps/sim/blocks/blocks/plane.ts | 6 +- apps/sim/blocks/blocks/polymarket.ts | 5 +- apps/sim/blocks/blocks/powerbi.test.ts | 20 + apps/sim/blocks/blocks/powerbi.ts | 35 +- apps/sim/blocks/blocks/profound.ts | 6 +- apps/sim/blocks/blocks/reddit.test.ts | 39 + apps/sim/blocks/blocks/reddit.ts | 166 ++-- apps/sim/blocks/blocks/revenuecat.ts | 8 +- apps/sim/blocks/blocks/rocketlane.test.ts | 36 + apps/sim/blocks/blocks/rocketlane.ts | 69 +- apps/sim/blocks/blocks/rootly.test.ts | 33 + apps/sim/blocks/blocks/rootly.ts | 881 +++++++++--------- apps/sim/blocks/blocks/sendblue.test.ts | 29 + apps/sim/blocks/blocks/sendblue.ts | 7 +- apps/sim/blocks/blocks/sixtyfour.test.ts | 28 + apps/sim/blocks/blocks/sixtyfour.ts | 17 +- apps/sim/blocks/blocks/smartlead.test.ts | 35 + apps/sim/blocks/blocks/smartlead.ts | 135 +-- apps/sim/blocks/blocks/stripe.test.ts | 9 + apps/sim/blocks/blocks/stripe.ts | 38 +- apps/sim/blocks/blocks/tiktok.test.ts | 7 + apps/sim/blocks/blocks/tiktok.ts | 13 +- apps/sim/blocks/blocks/vanta.ts | 72 +- apps/sim/blocks/blocks/wealthbox.ts | 10 +- apps/sim/blocks/blocks/zendesk.ts | 11 +- apps/sim/blocks/blocks/zep.test.ts | 18 + apps/sim/blocks/blocks/zep.ts | 26 +- 60 files changed, 1493 insertions(+), 804 deletions(-) create mode 100644 apps/sim/blocks/blocks/kalshi.test.ts create mode 100644 apps/sim/blocks/blocks/ketch.test.ts create mode 100644 apps/sim/blocks/blocks/langsmith.test.ts create mode 100644 apps/sim/blocks/blocks/launchdarkly.test.ts create mode 100644 apps/sim/blocks/blocks/linq.test.ts create mode 100644 apps/sim/blocks/blocks/netsuite.test.ts create mode 100644 apps/sim/blocks/blocks/parallel.test.ts create mode 100644 apps/sim/blocks/blocks/peopledatalabs.test.ts create mode 100644 apps/sim/blocks/blocks/perplexity.test.ts create mode 100644 apps/sim/blocks/blocks/persona.test.ts create mode 100644 apps/sim/blocks/blocks/pitchbook.test.ts create mode 100644 apps/sim/blocks/blocks/plane.test.ts create mode 100644 apps/sim/blocks/blocks/powerbi.test.ts create mode 100644 apps/sim/blocks/blocks/reddit.test.ts create mode 100644 apps/sim/blocks/blocks/rocketlane.test.ts create mode 100644 apps/sim/blocks/blocks/rootly.test.ts create mode 100644 apps/sim/blocks/blocks/sendblue.test.ts create mode 100644 apps/sim/blocks/blocks/sixtyfour.test.ts create mode 100644 apps/sim/blocks/blocks/smartlead.test.ts create mode 100644 apps/sim/blocks/blocks/zep.test.ts diff --git a/apps/sim/blocks/blocks/jotform.test.ts b/apps/sim/blocks/blocks/jotform.test.ts index e3279e61ebb..632f9636056 100644 --- a/apps/sim/blocks/blocks/jotform.test.ts +++ b/apps/sim/blocks/blocks/jotform.test.ts @@ -25,4 +25,14 @@ describe('JotformBlock', () => { expect({ ...inputs, ...buildParams(inputs) }.questions).toBe(inputs.bulkQuestions) }) + + /** + * An agent tool call passes the operation only in `context`; a report title filled + * on the tool row must still reach the tool's `title` param. + */ + it('maps tool-row fields on an agent tool call', () => { + const args = { apiKey: 'key', formId: '2315', reportTitle: 'Weekly' } + + expect({ ...args, ...buildParams(args, { operation: 'create_report' }) }.title).toBe('Weekly') + }) }) diff --git a/apps/sim/blocks/blocks/jotform.ts b/apps/sim/blocks/blocks/jotform.ts index 7157680f467..d4b4d2cf8dd 100644 --- a/apps/sim/blocks/blocks/jotform.ts +++ b/apps/sim/blocks/blocks/jotform.ts @@ -1,6 +1,6 @@ import { JotformIcon } from '@/components/icons' import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, withSavedCredential } from '@/blocks/utils' import { getTrigger } from '@/triggers' /** @@ -730,10 +730,10 @@ export const JotformBlock: BlockConfig = { * Everything else — formId, submissionId, answers, the pagination fields — is * named after its param and reaches the tool unchanged. */ - params: (params) => { + params: (params, context) => { const result: Record = {} - switch (params.operation) { + switch (mapperOperation(params, context)) { case 'create_form': if (params.newFormQuestions) result.questions = params.newFormQuestions if (params.newFormProperties) result.properties = params.newFormProperties diff --git a/apps/sim/blocks/blocks/kalshi.test.ts b/apps/sim/blocks/blocks/kalshi.test.ts new file mode 100644 index 00000000000..ce22307fcd3 --- /dev/null +++ b/apps/sim/blocks/blocks/kalshi.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' +import { KalshiBlock } from '@/blocks/blocks/kalshi' + +describe('KalshiBlock', () => { + const buildParams = KalshiBlock.tools.config.params! + + /** + * An agent tool call passes the operation only in `context`; the order ID filled + * on the tool row must still reach the tool's `orderId` param. + */ + it('maps the order ID field on an agent tool call', () => { + const args = { keyId: 'key', privateKey: 'pem', orderIdParam: 'ord-1' } + + expect({ ...args, ...buildParams(args, { operation: 'cancel_order' }) }.orderId).toBe('ord-1') + }) +}) diff --git a/apps/sim/blocks/blocks/kalshi.ts b/apps/sim/blocks/blocks/kalshi.ts index 280e6eebed4..f11ef0a82cb 100644 --- a/apps/sim/blocks/blocks/kalshi.ts +++ b/apps/sim/blocks/blocks/kalshi.ts @@ -1,7 +1,7 @@ import { KalshiIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { createVersionedToolSelector, withSavedCredential } from '@/blocks/utils' +import { createVersionedToolSelector, mapperOperation, withSavedCredential } from '@/blocks/utils' /* * Mutually exclusive alternates, not canonical pairs — an order carries either @@ -695,9 +695,9 @@ Return ONLY the numeric timestamp (seconds since Unix epoch) - no explanations, return 'kalshi_get_markets' } }, - params: (params) => { + params: (params, context) => { + const operation = mapperOperation(params, context) const { - operation, orderStatus, tickerFilter, tickerFills, diff --git a/apps/sim/blocks/blocks/ketch.test.ts b/apps/sim/blocks/blocks/ketch.test.ts new file mode 100644 index 00000000000..199afb14115 --- /dev/null +++ b/apps/sim/blocks/blocks/ketch.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from 'vitest' +import { KetchBlock } from '@/blocks/blocks/ketch' + +describe('KetchBlock', () => { + const buildParams = KetchBlock.tools.config.params! + + /** + * An agent tool call passes the operation only in `context`; a purposes map the + * model sends as JSON text must reach the tool as an object, like the canvas sends it. + */ + it('parses a JSON-text purposes map on an agent tool call', () => { + const args = { + organizationCode: 'org', + propertyCode: 'web', + environmentCode: 'production', + identities: { email: 'a@example.com' }, + purposes: '{"analytics":{"allowed":"granted"}}', + } + + expect({ ...args, ...buildParams(args, { operation: 'set_consent' }) }.purposes).toEqual({ + analytics: { allowed: 'granted' }, + }) + }) +}) diff --git a/apps/sim/blocks/blocks/ketch.ts b/apps/sim/blocks/blocks/ketch.ts index 47baebd7da1..6601d23589d 100644 --- a/apps/sim/blocks/blocks/ketch.ts +++ b/apps/sim/blocks/blocks/ketch.ts @@ -1,6 +1,7 @@ import { KetchIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { IntegrationType } from '@/blocks/types' +import { mapperOperation } from '@/blocks/utils' export const KetchBlock: BlockConfig = { type: 'ketch', @@ -186,7 +187,8 @@ export const KetchBlock: BlockConfig = { ], config: { tool: (params) => `ketch_${params.operation}`, - params: (params) => { + params: (params, context) => { + const operation = mapperOperation(params, context) const result: Record = { organizationCode: params.organizationCode, propertyCode: params.propertyCode, @@ -203,20 +205,20 @@ export const KetchBlock: BlockConfig = { : params.identities } - if (params.operation === 'get_consent' && params.purposesFilter) { + if (operation === 'get_consent' && params.purposesFilter) { result.purposes = typeof params.purposesFilter === 'string' ? JSON.parse(params.purposesFilter) : params.purposesFilter } - if (params.operation === 'set_consent' && params.purposes) { + if (operation === 'set_consent' && params.purposes) { result.purposes = typeof params.purposes === 'string' ? JSON.parse(params.purposes) : params.purposes if (params.collectedAt) result.collectedAt = Number(params.collectedAt) } - if (params.operation === 'set_subscriptions') { + if (operation === 'set_subscriptions') { if (params.topics) { result.topics = typeof params.topics === 'string' ? JSON.parse(params.topics) : params.topics @@ -227,7 +229,7 @@ export const KetchBlock: BlockConfig = { } } - if (params.operation === 'invoke_right') { + if (operation === 'invoke_right') { if (params.rightCode) result.rightCode = params.rightCode if (params.userData) { result.userData = diff --git a/apps/sim/blocks/blocks/langsmith.test.ts b/apps/sim/blocks/blocks/langsmith.test.ts new file mode 100644 index 00000000000..fc8009ea405 --- /dev/null +++ b/apps/sim/blocks/blocks/langsmith.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from 'vitest' +import { LangsmithBlock } from '@/blocks/blocks/langsmith' + +describe('LangsmithBlock', () => { + const buildParams = LangsmithBlock.tools.config.params! + + /** + * The model names the create-run outputs after the tool's `run_outputs` param, not the + * block's `outputs` field; the mapper must not overwrite them with the empty field. + */ + it('keeps model run outputs on an agent create-run call', () => { + const args = { apiKey: 'key', name: 'run', run_type: 'chain', run_outputs: { answer: 42 } } + + expect( + { ...args, ...buildParams(args, { operation: 'langsmith_create_run' }) }.run_outputs + ).toEqual({ answer: 42 }) + }) +}) diff --git a/apps/sim/blocks/blocks/langsmith.ts b/apps/sim/blocks/blocks/langsmith.ts index ac7b3bbc4f9..2602e11e7e8 100644 --- a/apps/sim/blocks/blocks/langsmith.ts +++ b/apps/sim/blocks/blocks/langsmith.ts @@ -1,7 +1,7 @@ import { toError } from '@sim/utils/errors' import { LangsmithIcon } from '@/components/icons' import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils' export const LangsmithBlock: BlockConfig = { type: 'langsmith', @@ -315,7 +315,8 @@ Common patch fields: outputs, end_time, status, error`, ], config: { tool: (params) => params.operation, - params: (params) => { + params: (params, context) => { + const operation = mapperOperation(params, context) const parseJsonValue = (value: unknown, label: string) => { if (value === undefined || value === null || value === '') { return undefined @@ -332,7 +333,7 @@ Common patch fields: outputs, end_time, status, error`, const emptyToUndefined = (value: unknown) => (value === '' ? undefined : value) - if (params.operation === 'langsmith_create_runs_batch') { + if (operation === 'langsmith_create_runs_batch') { const post = parseJsonValue(params.post, 'post runs') const patch = parseJsonValue(params.patch, 'patch runs') @@ -347,7 +348,7 @@ Common patch fields: outputs, end_time, status, error`, } } - if (params.operation === 'langsmith_update_run') { + if (operation === 'langsmith_update_run') { const name = emptyToUndefined(params.name) const end_time = emptyToUndefined(params.end_time) const outputs = parseJsonValue(params.outputs, 'outputs') @@ -379,14 +380,14 @@ Common patch fields: outputs, end_time, status, error`, } } - if (params.operation === 'langsmith_get_run') { + if (operation === 'langsmith_get_run') { return { apiKey: params.apiKey, runId: params.runId, } } - if (params.operation === 'langsmith_create_feedback') { + if (operation === 'langsmith_create_feedback') { const parseScore = (value: unknown) => { if (value === undefined || value === null || value === '') { return undefined @@ -418,7 +419,10 @@ Common patch fields: outputs, end_time, status, error`, start_time: params.start_time, end_time: params.end_time, inputs: parseJsonValue(params.inputs, 'inputs'), - run_outputs: parseJsonValue(params.outputs, 'outputs'), + run_outputs: parseJsonValue( + params.outputs || toolCallArg(context, params.run_outputs), + 'outputs' + ), extra: parseJsonValue(params.extra, 'metadata'), tags: parseJsonValue(params.tags, 'tags'), parent_run_id: params.parent_run_id, diff --git a/apps/sim/blocks/blocks/launchdarkly.test.ts b/apps/sim/blocks/blocks/launchdarkly.test.ts new file mode 100644 index 00000000000..ed3237145e0 --- /dev/null +++ b/apps/sim/blocks/blocks/launchdarkly.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, it } from 'vitest' +import { LaunchDarklyBlock } from '@/blocks/blocks/launchdarkly' + +type Params = Record + +const toolCall = (args: Params, operation: string): Params => + LaunchDarklyBlock.tools.config?.params?.(args as never, { operation }) as Params + +describe('LaunchDarkly agent tool calls', () => { + it('keeps the model name, key and boolean temporary flag on create_flag', () => { + const mapped = toolCall( + { projectKey: 'default', name: 'New checkout', key: 'new-checkout', temporary: true }, + 'create_flag' + ) + expect(mapped).toMatchObject({ name: 'New checkout', key: 'new-checkout', temporary: true }) + }) + + it('keeps a boolean archive on update_flag', () => { + expect( + toolCall({ projectKey: 'default', flagKey: 'old-flag', archive: true }, 'update_flag').archive + ).toBe(true) + }) +}) diff --git a/apps/sim/blocks/blocks/launchdarkly.ts b/apps/sim/blocks/blocks/launchdarkly.ts index 4c07a164470..30a888ad1f8 100644 --- a/apps/sim/blocks/blocks/launchdarkly.ts +++ b/apps/sim/blocks/blocks/launchdarkly.ts @@ -1,7 +1,7 @@ import { LaunchDarklyIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils' export const LaunchDarklyBlock: BlockConfig = { type: 'launchdarkly', @@ -329,23 +329,24 @@ Return ONLY the resource specifier string - no explanations, no extra text.`, const operation = params.operation || 'list_flags' return `launchdarkly_${operation}` }, - params: (params) => { - const { operation, flagName, newFlagKey, ...rest } = params + params: (params, context) => { + const operation = mapperOperation(params, context) + const { flagName, newFlagKey, ...rest } = params if (operation === 'create_flag') { - rest.name = flagName - rest.key = newFlagKey + rest.name = flagName ?? toolCallArg(context, params.name) + rest.key = newFlagKey ?? toolCallArg(context, params.key) } if (operation === 'toggle_flag') { - rest.enabled = rest.enabled === 'true' + rest.enabled = rest.enabled === true || rest.enabled === 'true' } if (rest.temporary !== undefined) { - rest.temporary = rest.temporary === 'true' + rest.temporary = rest.temporary === true || rest.temporary === 'true' } - if (rest.archive !== undefined) { + if (rest.archive !== undefined && typeof rest.archive !== 'boolean') { if (rest.archive === 'true') rest.archive = true else if (rest.archive === 'false') rest.archive = false else rest.archive = undefined diff --git a/apps/sim/blocks/blocks/linkedin.ts b/apps/sim/blocks/blocks/linkedin.ts index 55ea31c45a0..5d0498b3bf4 100644 --- a/apps/sim/blocks/blocks/linkedin.ts +++ b/apps/sim/blocks/blocks/linkedin.ts @@ -2,6 +2,7 @@ import { LinkedInIcon } from '@/components/icons' import { getScopesForService } from '@/lib/oauth/utils' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { mapperOperation } from '@/blocks/utils' export const LinkedInBlock: BlockConfig = { type: 'linkedin', @@ -103,8 +104,8 @@ export const LinkedInBlock: BlockConfig = { return 'linkedin_share_post' }, - params: (inputs) => { - const operation = inputs.operation || 'share_post' + params: (inputs, context) => { + const operation = mapperOperation(inputs, context) || 'share_post' const { oauthCredential, ...rest } = inputs if (operation === 'get_profile') { diff --git a/apps/sim/blocks/blocks/linq.test.ts b/apps/sim/blocks/blocks/linq.test.ts new file mode 100644 index 00000000000..42604b97870 --- /dev/null +++ b/apps/sim/blocks/blocks/linq.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest' +import { LinqBlock } from '@/blocks/blocks/linq' + +type Params = Record + +const toolCall = (args: Params, operation: string): Params => + LinqBlock.tools.config?.params?.(args as never, { operation }) as Params + +describe('Linq agent tool calls', () => { + it('unwraps a single picked file on create_attachment', () => { + const file = { + id: 'f1', + name: 'card.png', + key: 'workspace/ws/card.png', + size: 10, + type: 'image/png', + } + expect(toolCall({ file: [file] }, 'create_attachment').file).toEqual(file) + }) +}) diff --git a/apps/sim/blocks/blocks/linq.ts b/apps/sim/blocks/blocks/linq.ts index 50f58eaf7ba..b9072c5d099 100644 --- a/apps/sim/blocks/blocks/linq.ts +++ b/apps/sim/blocks/blocks/linq.ts @@ -1,7 +1,7 @@ import { LinqIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { normalizeFileInput, withSavedCredential } from '@/blocks/utils' +import { mapperOperation, normalizeFileInput, withSavedCredential } from '@/blocks/utils' import { getTrigger } from '@/triggers' const CHAT_ID_OPS = [ @@ -781,9 +781,9 @@ export const LinqBlock: BlockConfig = { ], config: { tool: (params) => `linq_${params.operation || 'send_message'}`, - params: (params) => { + params: (params, context) => { + const operation = mapperOperation(params, context) const { - operation, senderFrom, recipients, messageText, @@ -881,7 +881,6 @@ export const LinqBlock: BlockConfig = { } if (operation === 'react_to_message') { - if (reactionOperation) rest.operation = reactionOperation if (reactionType) rest.type = reactionType if (reactionCustomEmoji) rest.customEmoji = reactionCustomEmoji if (reactionPartIndex !== undefined && reactionPartIndex !== '') { @@ -940,6 +939,11 @@ export const LinqBlock: BlockConfig = { rest.limit = toFiniteNumber(limit, 'Limit') } + // The react tool declares its own `operation` param: add or remove. + if (operation === 'react_to_message' && reactionOperation) { + return { ...rest, operation: reactionOperation } + } + return rest }, }, diff --git a/apps/sim/blocks/blocks/loops.ts b/apps/sim/blocks/blocks/loops.ts index a957b6a8401..ec1fe28eff0 100644 --- a/apps/sim/blocks/blocks/loops.ts +++ b/apps/sim/blocks/blocks/loops.ts @@ -1,7 +1,7 @@ import { LoopsIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils' import { getTrigger } from '@/triggers' /** How a contact is identified — email or user id, whichever the user filled. */ @@ -510,8 +510,9 @@ Return ONLY the JSON object - no explanations, no extra text.`, ], config: { tool: (params) => `loops_${params.operation}`, - params: (params) => { - const { operation, apiKey } = params + params: (params, context) => { + const operation = mapperOperation(params, context) + const { apiKey } = params const result: Record = { apiKey } switch (operation) { @@ -571,8 +572,8 @@ Return ONLY the JSON object - no explanations, no extra text.`, break case 'create_contact_property': - result.name = params.propertyName - result.type = params.propertyType + result.name = params.propertyName ?? toolCallArg(context, params.name) + result.type = params.propertyType ?? toolCallArg(context, params.type) break case 'list_contact_properties': diff --git a/apps/sim/blocks/blocks/manageengine-sdp.ts b/apps/sim/blocks/blocks/manageengine-sdp.ts index d95924575f8..35f485fbf60 100644 --- a/apps/sim/blocks/blocks/manageengine-sdp.ts +++ b/apps/sim/blocks/blocks/manageengine-sdp.ts @@ -2,6 +2,7 @@ import { ManageEngineIcon } from '@/components/icons' import { getScopesForService } from '@/lib/oauth/utils' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { isToolCall, mapperOperation } from '@/blocks/utils' import { SDP_DATA_CENTER_BASES } from '@/tools/manageengine_sdp/data-centers' /** @@ -1055,14 +1056,12 @@ export const ManageEngineSdpBlock: BlockConfig = { ], config: { tool: (params) => `manageengine_sdp_${params.operation}`, - params: (params) => { - // The agent-tool path does not carry `operation` inside params - it is a - // sibling of the tool call, used only to pick the tool - and there the - // model addresses tool params by their real names. The tool is already - // selected, so there is no cross-operation leak to guard against, while - // running the scoping below WOULD overwrite the model's own values with - // `undefined`. - if (typeof params.operation !== 'string') return params + params: (params, context) => { + // On a tool call the model addresses tool params by their real names and + // the tool is already selected, so there is no cross-operation leak to + // guard against, while running the scoping below WOULD overwrite the + // model's own values with `undefined`. + if (isToolCall(context)) return params // IMPORTANT: leaving a key out of the result does NOT keep it from the // tool. Both call sites merge this return value on top of the original @@ -1075,7 +1074,7 @@ export const ManageEngineSdpBlock: BlockConfig = { // under an unrelated operation. Every module-prefixed subBlock below is // therefore funnelled into the shared tool param name and every // inactive module's value is explicitly cleared. - const operation = params.operation + const operation = mapperOperation(params, context) const { // The five entity ids are destructured out and republished scoped // below. Passing them through would send a problem id typed earlier to diff --git a/apps/sim/blocks/blocks/mem0.test.ts b/apps/sim/blocks/blocks/mem0.test.ts index 7620aba09fa..9757a8e62e7 100644 --- a/apps/sim/blocks/blocks/mem0.test.ts +++ b/apps/sim/blocks/blocks/mem0.test.ts @@ -29,4 +29,18 @@ describe('Mem0Block', () => { }) ).toThrow('Each message must have role user or assistant and non-empty content') }) + + it('maps an agent search call, whose operation arrives only in context', () => { + const params = buildParams( + { apiKey: 'test-key', userId: 'alice', query: 'favorite tools', limit: 5 }, + { operation: 'search' } + ) + + expect(params).toEqual({ + apiKey: 'test-key', + userId: 'alice', + query: 'favorite tools', + limit: 5, + }) + }) }) diff --git a/apps/sim/blocks/blocks/mem0.ts b/apps/sim/blocks/blocks/mem0.ts index a50dabebff2..c321621cf4a 100644 --- a/apps/sim/blocks/blocks/mem0.ts +++ b/apps/sim/blocks/blocks/mem0.ts @@ -1,12 +1,22 @@ import { toError } from '@sim/utils/errors' import { Mem0Icon } from '@/components/icons' -import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { + AuthMode, + type BlockConfig, + type BlockMeta, + type BlockToolParamsContext, + IntegrationType, +} from '@/blocks/types' +import { mapperOperation, withSavedCredential } from '@/blocks/utils' import { parseMem0Messages } from '@/tools/mem0/utils' -function mem0ToolParams(params: Record, requireApiKey: boolean) { +function mem0ToolParams( + params: Record, + requireApiKey: boolean, + context?: BlockToolParamsContext +) { const errors: string[] = [] - const operation = params.operation || 'add' + const operation = mapperOperation(params, context) || 'add' if (requireApiKey && !params.apiKey) { errors.push('API Key is required') @@ -269,7 +279,7 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n return 'mem0_add_memories' } }, - params: (params) => mem0ToolParams(params, true), + params: (params, context) => mem0ToolParams(params, true, context), }, }, inputs: { @@ -403,6 +413,6 @@ export const Mem0V2Block: BlockConfig = { ...withSavedCredential( Mem0Block, { id: 'credential', type: 'oauth-input', serviceId: 'mem0', title: 'Mem0 Credential' }, - { params: (params) => mem0ToolParams(params, false) } + { params: (params, context) => mem0ToolParams(params, false, context) } ), } diff --git a/apps/sim/blocks/blocks/mintlify.test.ts b/apps/sim/blocks/blocks/mintlify.test.ts index 95ac6a5a0ad..7c15a199db0 100644 --- a/apps/sim/blocks/blocks/mintlify.test.ts +++ b/apps/sim/blocks/blocks/mintlify.test.ts @@ -50,4 +50,21 @@ describe('MintlifyBlock', () => { expect(result.limit).toBeUndefined() }) }) + + describe('agent tool calls', () => { + it('coerces numbers and keeps tool-named args when the operation arrives only in context', () => { + const args = { projectId: 'proj_1', source: 'contextual', status: 'pending', limit: '50' } + const result = { + ...args, + ...MintlifyBlock.tools.config.params!(args, { operation: 'get_feedback' }), + } + + expect(result).toEqual({ + projectId: 'proj_1', + source: 'contextual', + status: 'pending', + limit: 50, + }) + }) + }) }) diff --git a/apps/sim/blocks/blocks/mintlify.ts b/apps/sim/blocks/blocks/mintlify.ts index 646e9c75019..9f5ba6d655b 100644 --- a/apps/sim/blocks/blocks/mintlify.ts +++ b/apps/sim/blocks/blocks/mintlify.ts @@ -1,12 +1,15 @@ import { MintlifyIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { isToolCall, mapperOperation } from '@/blocks/utils' /** - * SubBlock IDs each operation may forward to its tool. Anything outside the - * selected operation's list is explicitly cleared, because the executor merges - * `tools.config.params` on top of the raw inputs and a retained advanced-mode - * value would otherwise leak across operations. + * SubBlock IDs each operation may forward to its tool. On the canvas anything + * outside the selected operation's list is explicitly cleared, because the + * executor merges `tools.config.params` on top of the raw inputs and a retained + * advanced-mode value would otherwise leak across operations. A tool call's + * params are the stored row plus the model's arguments, keyed by the tool's own + * param names (`path`, `source`, `status`), so nothing is cleared there. */ const OPERATION_PARAMS: Record = { trigger_update: ['projectId'], @@ -566,20 +569,16 @@ Return ONLY the JSON array.`, ], config: { tool: (params: Record) => `mintlify_${params.operation}`, - params: (params: Record) => { - const { operation } = params - // On the agent-tool path `operation` is a sibling of the tool call rather - // than a member of params, so clearing anything here would erase the - // model's own arguments. - if (typeof operation !== 'string') return {} - - const allowed = OPERATION_PARAMS[operation] + params: (params: Record, context) => { + const allowed = OPERATION_PARAMS[mapperOperation(params, context)] if (!allowed) return {} const result: Record = {} - for (const key of Object.keys(params)) { - if (key === 'operation' || key === 'apiKey') continue - result[key] = undefined + if (!isToolCall(context)) { + for (const key of Object.keys(params)) { + if (key === 'operation' || key === 'apiKey') continue + result[key] = undefined + } } for (const key of allowed) { @@ -588,8 +587,7 @@ Return ONLY the JSON array.`, if (NUMERIC_PARAMS.has(key)) { const numeric = Number(value) - if (!Number.isFinite(numeric)) continue - result[key] = numeric + result[key] = Number.isFinite(numeric) ? numeric : undefined continue } diff --git a/apps/sim/blocks/blocks/netsuite.test.ts b/apps/sim/blocks/blocks/netsuite.test.ts new file mode 100644 index 00000000000..069ddac1127 --- /dev/null +++ b/apps/sim/blocks/blocks/netsuite.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from 'vitest' +import { NetSuiteBlock } from '@/blocks/blocks/netsuite' + +describe('NetSuiteBlock', () => { + it('parses a JSON body on an agent tool call, whose operation arrives only in context', () => { + const args = { recordType: 'customer', body: '{"companyName":"Acme"}' } + const result = { + ...args, + ...NetSuiteBlock.tools.config.params!(args, { operation: 'netsuite_create_record' }), + } + + expect(result.body).toEqual({ companyName: 'Acme' }) + }) + + it('keeps the model task ID on an agent async status call', () => { + const args = { jobId: '42', view: 'task', taskId: '7' } + const result = { + ...args, + ...NetSuiteBlock.tools.config.params!(args, { operation: 'netsuite_get_async_status' }), + } + + expect(result.taskId).toBe('7') + }) +}) diff --git a/apps/sim/blocks/blocks/netsuite.ts b/apps/sim/blocks/blocks/netsuite.ts index 7801ad87d9b..b339e22c845 100644 --- a/apps/sim/blocks/blocks/netsuite.ts +++ b/apps/sim/blocks/blocks/netsuite.ts @@ -1,7 +1,7 @@ import { NetSuiteIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { parseOptionalNumberInput } from '@/blocks/utils' +import { mapperOperation, parseOptionalNumberInput, toolCallArg } from '@/blocks/utils' const RECORD_TYPE_OPERATIONS = [ 'netsuite_list_records', @@ -95,8 +95,8 @@ const BATCH_WRITE_OPERATIONS = [ 'netsuite_batch_upsert_records', ] -function usesOperation(operation: unknown, operations: readonly string[]): boolean { - return typeof operation === 'string' && operations.includes(operation) +function usesOperation(operation: string, operations: readonly string[]): boolean { + return operations.includes(operation) } function optionalBoolean(value: unknown): boolean | undefined { @@ -844,14 +844,15 @@ Return ONLY the SuiteQL query - no explanations, no markdown, no extra text.`, ], config: { tool: (params) => params.operation, - params: (params) => { - if (typeof params.operation !== 'string') return {} - const { operation, resultTaskId, statusTaskId, ...rest } = params + params: (params, context) => { + const operation = mapperOperation(params, context) + if (!operation) return {} + const { resultTaskId, statusTaskId, ...rest } = params const taskId = operation === 'netsuite_get_async_status' - ? statusTaskId + ? (statusTaskId ?? toolCallArg(context, rest.taskId)) : operation === 'netsuite_get_async_result' - ? resultTaskId + ? (resultTaskId ?? toolCallArg(context, rest.taskId)) : undefined return { ...rest, diff --git a/apps/sim/blocks/blocks/otter.ts b/apps/sim/blocks/blocks/otter.ts index 47b82d27654..7af188a053b 100644 --- a/apps/sim/blocks/blocks/otter.ts +++ b/apps/sim/blocks/blocks/otter.ts @@ -1,6 +1,6 @@ import { OtterIcon } from '@/components/icons' import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, withSavedCredential } from '@/blocks/utils' import { getTrigger } from '@/triggers' const CONVERSATION_ID_OPERATIONS = ['get_conversation', 'get_conversation_audio'] @@ -205,13 +205,13 @@ export const OtterBlock: BlockConfig = { ], config: { tool: (params) => `otter_${params.operation}`, - params: (params) => { + params: (params, context) => { const result: Record = {} if (params.limit !== undefined && params.limit !== null && params.limit !== '') { result.limit = Number(params.limit) } if ( - params.operation === 'list_conversations' && + mapperOperation(params, context) === 'list_conversations' && params.includeShared !== undefined && params.includeShared !== null && params.includeShared !== '' diff --git a/apps/sim/blocks/blocks/parallel.test.ts b/apps/sim/blocks/blocks/parallel.test.ts new file mode 100644 index 00000000000..b4d756743b1 --- /dev/null +++ b/apps/sim/blocks/blocks/parallel.test.ts @@ -0,0 +1,15 @@ +import { describe, expect, it } from 'vitest' +import { ParallelBlock } from '@/blocks/blocks/parallel' + +describe('ParallelBlock', () => { + it('maps an agent search call, whose operation arrives only in context', () => { + const args = { objective: 'When was the UN founded?', include_domains: 'un.org' } + const result = { + ...args, + ...ParallelBlock.tools.config.params!(args, { operation: 'search' }), + } + + expect(result.search_queries).toBe('When was the UN founded?') + expect(result.include_domains).toBe('un.org') + }) +}) diff --git a/apps/sim/blocks/blocks/parallel.ts b/apps/sim/blocks/blocks/parallel.ts index 540f567f121..33616fe7c5b 100644 --- a/apps/sim/blocks/blocks/parallel.ts +++ b/apps/sim/blocks/blocks/parallel.ts @@ -1,5 +1,6 @@ import { ParallelIcon } from '@/components/icons' import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' +import { mapperOperation, toolCallArg } from '@/blocks/utils' export const ParallelBlock: BlockConfig = { type: 'parallel_ai', @@ -220,9 +221,9 @@ export const ParallelBlock: BlockConfig = { return 'parallel_search' } }, - params: (params) => { + params: (params, context) => { const result: Record = {} - const operation = params.operation + const operation = mapperOperation(params, context) if (operation === 'search') { if (!params.search_queries && params.objective) { @@ -233,8 +234,14 @@ export const ParallelBlock: BlockConfig = { if (params.max_chars_per_result) { result.max_chars_per_result = Number(params.max_chars_per_result) } - result.include_domains = params.search_include_domains || undefined - result.exclude_domains = params.search_exclude_domains || undefined + result.include_domains = + params.search_include_domains || + toolCallArg(context, params.include_domains) || + undefined + result.exclude_domains = + params.search_exclude_domains || + toolCallArg(context, params.exclude_domains) || + undefined } if (operation === 'extract') { diff --git a/apps/sim/blocks/blocks/peopledatalabs.test.ts b/apps/sim/blocks/blocks/peopledatalabs.test.ts new file mode 100644 index 00000000000..08d45e4f620 --- /dev/null +++ b/apps/sim/blocks/blocks/peopledatalabs.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, it } from 'vitest' +import { PeopleDataLabsBlock } from '@/blocks/blocks/peopledatalabs' +import type { BlockToolParamsContext } from '@/blocks/types' + +function mapParams(params: Record, context?: BlockToolParamsContext) { + const mapper = PeopleDataLabsBlock.tools.config?.params + if (!mapper) throw new Error('People Data Labs block has no params mapper') + return { ...params, ...mapper(params, context) } +} + +describe('People Data Labs tool calls', () => { + it('keeps the model company identifiers and likelihood on Company Enrich', () => { + const result = mapParams( + { apiKey: 'k', name: 'Acme', website: 'acme.com', min_likelihood: 6 }, + { operation: 'pdl_company_enrich' } + ) + expect(result).toMatchObject({ name: 'Acme', website: 'acme.com', min_likelihood: 6 }) + }) + + it('keeps the model size on Autocomplete', () => { + const result = mapParams( + { apiKey: 'k', field: 'company', text: 'acm', size: 5 }, + { operation: 'pdl_autocomplete' } + ) + expect(result.size).toBe(5) + }) +}) diff --git a/apps/sim/blocks/blocks/peopledatalabs.ts b/apps/sim/blocks/blocks/peopledatalabs.ts index f5f6ec9ba7d..c66c6d0ae44 100644 --- a/apps/sim/blocks/blocks/peopledatalabs.ts +++ b/apps/sim/blocks/blocks/peopledatalabs.ts @@ -1,6 +1,7 @@ import { PeopleDataLabsIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { mapperOperation, toolCallArg } from '@/blocks/utils' /** Mutually exclusive person identifiers — first one supplied is the match key. */ const PERSON_MATCH_FIELD = ['email', 'profile', 'phone', 'first_name'] as const @@ -492,9 +493,9 @@ export const PeopleDataLabsBlock: BlockConfig = { return 'pdl_person_enrich' } }, - params: (params) => { + params: (params, context) => { const result: Record = { ...params } - const op = params.operation + const op = mapperOperation(params, context) // Strip alternate-operation aliases so stale values from prior operations // can't leak into the current request. @@ -554,9 +555,8 @@ export const PeopleDataLabsBlock: BlockConfig = { // accept `size` at all. result.size = undefined if (op === 'pdl_autocomplete') { - if (params.autocomplete_size !== undefined) { - result.size = Number(params.autocomplete_size) - } + const size = params.autocomplete_size ?? toolCallArg(context, params.size) + if (size !== undefined) result.size = Number(size) } else if (op === 'pdl_person_search' || op === 'pdl_company_search') { if (params.size !== undefined) result.size = Number(params.size) } diff --git a/apps/sim/blocks/blocks/perplexity.test.ts b/apps/sim/blocks/blocks/perplexity.test.ts new file mode 100644 index 00000000000..67f984f3afa --- /dev/null +++ b/apps/sim/blocks/blocks/perplexity.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, it } from 'vitest' +import { PerplexityBlock } from '@/blocks/blocks/perplexity' +import type { BlockToolParamsContext } from '@/blocks/types' + +function mapParams(params: Record, context?: BlockToolParamsContext) { + const mapper = PerplexityBlock.tools.config?.params + if (!mapper) throw new Error('Perplexity block has no params mapper') + return { ...params, ...mapper(params, context) } +} + +describe('Perplexity tool calls', () => { + it('keeps a model temperature of 0 on Chat', () => { + const result = mapParams( + { apiKey: 'k', content: 'q', temperature: 0 }, + { operation: 'perplexity_chat' } + ) + expect(result.temperature).toBe(0) + }) + + it('keeps a model domain filter array on Search', () => { + const result = mapParams( + { apiKey: 'k', query: 'q', search_domain_filter: ['nature.com', ' science.org '] }, + { operation: 'perplexity_search' } + ) + expect(result.search_domain_filter).toEqual(['nature.com', 'science.org']) + }) +}) diff --git a/apps/sim/blocks/blocks/perplexity.ts b/apps/sim/blocks/blocks/perplexity.ts index 777973ea5eb..07ce3d8f732 100644 --- a/apps/sim/blocks/blocks/perplexity.ts +++ b/apps/sim/blocks/blocks/perplexity.ts @@ -1,5 +1,6 @@ import { PerplexityIcon } from '@/components/icons' import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' +import { mapperOperation, toolCallArg } from '@/blocks/utils' export const PerplexityBlock: BlockConfig = { type: 'perplexity', @@ -202,15 +203,19 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n return 'perplexity_chat' } }, - params: (params) => { - if (params.operation === 'perplexity_search') { - // Process domain filter from comma-separated string to array + params: (params, context) => { + if (mapperOperation(params, context) === 'perplexity_search') { + // The block takes a comma-separated string; a tool call already sends an array. let domainFilter: string[] | undefined if (params.search_domain_filter && typeof params.search_domain_filter === 'string') { domainFilter = params.search_domain_filter .split(',') .map((d) => d.trim()) .filter((d) => d.length > 0) + } else if (Array.isArray(params.search_domain_filter)) { + domainFilter = params.search_domain_filter + .map((d) => String(d).trim()) + .filter((d) => d.length > 0) } const searchParams = { @@ -237,7 +242,9 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n content: params.content, systemPrompt: params.systemPrompt, max_tokens: params.max_tokens ? Number.parseInt(params.max_tokens) : undefined, - temperature: params.temperature ? Number.parseFloat(params.temperature) : undefined, + temperature: params.temperature + ? Number.parseFloat(params.temperature) + : toolCallArg(context, params.temperature === 0 ? 0 : undefined), } return chatParams diff --git a/apps/sim/blocks/blocks/persona.test.ts b/apps/sim/blocks/blocks/persona.test.ts new file mode 100644 index 00000000000..c0ee154c2b2 --- /dev/null +++ b/apps/sim/blocks/blocks/persona.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest' +import { PersonaBlock } from '@/blocks/blocks/persona' +import type { BlockToolParamsContext } from '@/blocks/types' + +function mapParams(params: Record, context?: BlockToolParamsContext) { + const mapper = PersonaBlock.tools.config?.params + if (!mapper) throw new Error('Persona block has no params mapper') + return { ...params, ...mapper(params, context) } +} + +describe('Persona tool calls', () => { + it('normalizes the stored CSV file on Import Accounts', () => { + const file = { name: 'accounts.csv', key: 'workspace/accounts.csv', size: 10 } + const result = mapParams( + { apiKey: 'k', file: JSON.stringify(file) }, + { operation: 'import_accounts' } + ) + expect(result.file).toEqual(file) + }) +}) diff --git a/apps/sim/blocks/blocks/persona.ts b/apps/sim/blocks/blocks/persona.ts index fddf90d4717..32a5414b8b7 100644 --- a/apps/sim/blocks/blocks/persona.ts +++ b/apps/sim/blocks/blocks/persona.ts @@ -1,6 +1,6 @@ import { PersonaIcon } from '@/components/icons' import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' -import { normalizeFileInput, withSavedCredential } from '@/blocks/utils' +import { mapperOperation, normalizeFileInput, withSavedCredential } from '@/blocks/utils' /** Canonical basic/advanced pair for the account importer's CSV. */ const IMPORT_FILE_FIELD = ['importFile', 'importFileRef'] as const @@ -519,10 +519,10 @@ export const PersonaBlock: BlockConfig = { ], config: { tool: (params) => `persona_${params.operation || 'create_inquiry'}`, - params: (params) => { + params: (params, context) => { const result: Record = {} - if (params.operation === 'import_accounts') { + if (mapperOperation(params, context) === 'import_accounts') { const file = normalizeFileInput(params.file, { single: true }) if (!file) { throw new Error('A CSV file is required to import accounts') diff --git a/apps/sim/blocks/blocks/pitchbook.test.ts b/apps/sim/blocks/blocks/pitchbook.test.ts new file mode 100644 index 00000000000..fce58c4fe40 --- /dev/null +++ b/apps/sim/blocks/blocks/pitchbook.test.ts @@ -0,0 +1,24 @@ +import { describe, expect, it } from 'vitest' +import { PitchBookBlock } from '@/blocks/blocks/pitchbook' +import type { BlockToolParamsContext } from '@/blocks/types' + +function mapParams(params: Record, context?: BlockToolParamsContext) { + const mapper = PitchBookBlock.tools.config?.params + if (!mapper) throw new Error('PitchBook block has no params mapper') + return { ...params, ...mapper(params, context) } +} + +describe('PitchBook tool calls', () => { + it('keeps the model pbId on a profile lookup', () => { + const result = mapParams({ apiKey: 'k', pbId: '10618-03' }, { operation: 'company_bio' }) + expect(result.pbId).toBe('10618-03') + }) + + it('keeps the model search filters on the owning search', () => { + const result = mapParams( + { apiKey: 'k', country: 'US', dealType: 'VC' }, + { operation: 'deal_search' } + ) + expect(result).toMatchObject({ country: 'US', dealType: 'VC' }) + }) +}) diff --git a/apps/sim/blocks/blocks/pitchbook.ts b/apps/sim/blocks/blocks/pitchbook.ts index bfd41f5aae5..da5663ca64d 100644 --- a/apps/sim/blocks/blocks/pitchbook.ts +++ b/apps/sim/blocks/blocks/pitchbook.ts @@ -3,6 +3,7 @@ import { getErrorMessage } from '@sim/utils/errors' import { PitchBookIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { mapperOperation, toolCallArg } from '@/blocks/utils' /** * Search subblock ids are prefixed per entity family because subblock ids must @@ -1906,9 +1907,9 @@ export const PitchBookBlock: BlockConfig = { } return `pitchbook_${operation}` }, - params: (params) => { + params: (params, context) => { const { additionalFilters, articleIds, page, perPage, trailingRange, ...rest } = params - const operation = String(params.operation ?? '') + const operation = mapperOperation(params, context) const mapped: Record = { ...rest } // Collapse only the ID subblock this operation owns onto `pbId`, clearing @@ -1916,7 +1917,10 @@ export const PitchBookBlock: BlockConfig = { for (const id of ID_SUBBLOCK_IDS) mapped[id] = undefined const idSubBlock = ID_SUBBLOCK_FOR_OPERATION[operation] const idValue = idSubBlock ? params[idSubBlock] : undefined - mapped.pbId = typeof idValue === 'string' && idValue !== '' ? idValue : undefined + mapped.pbId = + typeof idValue === 'string' && idValue !== '' + ? idValue + : toolCallArg(context, params.pbId) // Rename the prefixed filter subblocks onto their PitchBook param names, // dropping any that belong to a different operation (see the table's TSDoc). @@ -1926,7 +1930,8 @@ export const PitchBookBlock: BlockConfig = { const value = mapped[subBlockId] mapped[subBlockId] = undefined if (owner !== operation) continue - mapped[param] = value === undefined || value === '' ? undefined : value + mapped[param] = + value === undefined || value === '' ? toolCallArg(context, params[param]) : value } const parseJson = (raw: unknown, label: string): unknown => { diff --git a/apps/sim/blocks/blocks/plane.test.ts b/apps/sim/blocks/blocks/plane.test.ts new file mode 100644 index 00000000000..862ed4bb1ab --- /dev/null +++ b/apps/sim/blocks/blocks/plane.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from 'vitest' +import { PlaneBlock } from '@/blocks/blocks/plane' +import type { BlockToolParamsContext } from '@/blocks/types' + +function mapParams(params: Record, context?: BlockToolParamsContext) { + const mapper = PlaneBlock.tools.config?.params + if (!mapper) throw new Error('Plane block has no params mapper') + return { ...params, ...mapper(params, context) } +} + +describe('Plane tool calls', () => { + it('coerces the fields of the called operation, not List Projects', () => { + const result = mapParams( + { apiKey: 'k', workspace_slug: 'w', project_id: 'p', name: 'Sprint', sort_order: '5' }, + { operation: 'plane_create_cycle' } + ) + expect(result.sort_order).toBe(5) + }) +}) diff --git a/apps/sim/blocks/blocks/plane.ts b/apps/sim/blocks/blocks/plane.ts index 3c6dd503d61..7c62ad0112f 100644 --- a/apps/sim/blocks/blocks/plane.ts +++ b/apps/sim/blocks/blocks/plane.ts @@ -1,7 +1,7 @@ import { PlaneIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, withSavedCredential } from '@/blocks/utils' import { getTrigger } from '@/triggers' interface PlaneOperationField { @@ -4189,8 +4189,8 @@ export const PlaneBlock: BlockConfig = { ], config: { tool: (params) => String(params.operation || 'plane_list_projects'), - params: (params) => { - const operation = String(params.operation || 'plane_list_projects') + params: (params, context) => { + const operation = mapperOperation(params, context) || 'plane_list_projects' const result: Record = { apiKey: params.apiKey, baseUrl: params.baseUrl, diff --git a/apps/sim/blocks/blocks/polymarket.ts b/apps/sim/blocks/blocks/polymarket.ts index a067e56dab2..909b101f42b 100644 --- a/apps/sim/blocks/blocks/polymarket.ts +++ b/apps/sim/blocks/blocks/polymarket.ts @@ -1,6 +1,7 @@ import { PolymarketIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { IntegrationType } from '@/blocks/types' +import { mapperOperation } from '@/blocks/utils' const MARKET_REF_FIELD = ['marketId', 'marketSlug'] as const const EVENT_REF_FIELD = ['eventId', 'eventSlug'] as const @@ -757,9 +758,8 @@ Return ONLY the Unix timestamp as a number - no explanations, no quotes, no extr return 'polymarket_get_markets' } }, - params: (params) => { + params: (params, context) => { const { - operation, marketSlug, eventSlug, orderEvents, @@ -787,6 +787,7 @@ Return ONLY the Unix timestamp as a number - no explanations, no quotes, no extr holdersMinBalance, ...rest } = params + const operation = mapperOperation(params, context) const cleanParams: Record = {} if (operation === 'get_market' && marketSlug) { diff --git a/apps/sim/blocks/blocks/powerbi.test.ts b/apps/sim/blocks/blocks/powerbi.test.ts new file mode 100644 index 00000000000..987c5441a51 --- /dev/null +++ b/apps/sim/blocks/blocks/powerbi.test.ts @@ -0,0 +1,20 @@ +import { describe, expect, it } from 'vitest' +import { PowerBIBlock } from '@/blocks/blocks/powerbi' + +/** Runs the mapper the way an agent tool call does: its output spreads over the merged params. */ +function runToolCall(args: Record, operation: string) { + const mapper = PowerBIBlock.tools.config?.params + if (!mapper) throw new Error('Power BI block has no params mapper') + return { ...args, ...mapper(args, { operation }) } +} + +describe('PowerBIBlock tool-call params', () => { + it('keeps and coerces the model list arguments when the operation arrives only in context', () => { + const params = runToolCall( + { top: '25', skip: 5, filter: "contains(name,'Sales')" }, + 'powerbi_list_workspaces' + ) + + expect(params).toMatchObject({ top: 25, skip: 5, filter: "contains(name,'Sales')" }) + }) +}) diff --git a/apps/sim/blocks/blocks/powerbi.ts b/apps/sim/blocks/blocks/powerbi.ts index 772887c7c7b..db2e06f0493 100644 --- a/apps/sim/blocks/blocks/powerbi.ts +++ b/apps/sim/blocks/blocks/powerbi.ts @@ -2,7 +2,7 @@ import { PowerBIIcon } from '@/components/icons' import { getScopesForService } from '@/lib/oauth/utils' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { parseOptionalNumberInput } from '@/blocks/utils' +import { mapperOperation, parseOptionalNumberInput, toolCallArg } from '@/blocks/utils' const WORKSPACE_FIELD = ['workspaceSelector', 'manualWorkspaceId'] as const const DATASET_FIELD = ['datasetSelector', 'manualDatasetId'] as const @@ -294,29 +294,32 @@ export const PowerBIBlock: BlockConfig = { ], config: { tool: (params) => params.operation, - params: (params) => { - switch (params.operation) { + params: (params, context) => { + switch (mapperOperation(params, context)) { case 'powerbi_list_workspaces': return { top: - parseOptionalNumberInput(params.workspaceTop, 'Maximum workspaces', { - integer: true, - min: 0, - }) ?? 100, + parseOptionalNumberInput( + params.workspaceTop ?? toolCallArg(context, params.top), + 'Maximum workspaces', + { integer: true, min: 0 } + ) ?? 100, skip: - parseOptionalNumberInput(params.workspaceSkip, 'Workspace offset', { - integer: true, - min: 0, - }) ?? 0, - filter: params.workspaceFilter, + parseOptionalNumberInput( + params.workspaceSkip ?? toolCallArg(context, params.skip), + 'Workspace offset', + { integer: true, min: 0 } + ) ?? 0, + filter: params.workspaceFilter ?? toolCallArg(context, params.filter), } case 'powerbi_get_refresh_history': return { top: - parseOptionalNumberInput(params.refreshHistoryTop, 'Maximum refreshes', { - integer: true, - min: 1, - }) ?? 60, + parseOptionalNumberInput( + params.refreshHistoryTop ?? toolCallArg(context, params.top), + 'Maximum refreshes', + { integer: true, min: 1 } + ) ?? 60, } case 'powerbi_execute_query': return { includeNulls: parseIncludeNulls(params.includeNulls) } diff --git a/apps/sim/blocks/blocks/profound.ts b/apps/sim/blocks/blocks/profound.ts index e5e5334dba2..f8e99df8059 100644 --- a/apps/sim/blocks/blocks/profound.ts +++ b/apps/sim/blocks/blocks/profound.ts @@ -1,7 +1,7 @@ import { ProfoundIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, withSavedCredential } from '@/blocks/utils' const CATEGORY_REPORT_OPS = [ 'visibility_report', @@ -439,7 +439,7 @@ export const ProfoundBlock: BlockConfig = { ], config: { tool: (params) => `profound_${params.operation}`, - params: (params) => { + params: (params, context) => { const result: Record = {} const metricsMap: Record = { visibility_report: 'visibilityMetrics', @@ -450,7 +450,7 @@ export const ProfoundBlock: BlockConfig = { query_fanouts: 'fanoutsMetrics', prompt_volume: 'volumeMetrics', } - const metricsField = metricsMap[params.operation as string] + const metricsField = metricsMap[mapperOperation(params, context)] if (metricsField && params[metricsField]) { result.metrics = params[metricsField] } diff --git a/apps/sim/blocks/blocks/reddit.test.ts b/apps/sim/blocks/blocks/reddit.test.ts new file mode 100644 index 00000000000..4c642884d95 --- /dev/null +++ b/apps/sim/blocks/blocks/reddit.test.ts @@ -0,0 +1,39 @@ +import { describe, expect, it } from 'vitest' +import { RedditBlock } from '@/blocks/blocks/reddit' + +/** Runs the mapper the way an agent tool call does: its output spreads over the merged params. */ +function runToolCall(args: Record, operation: string) { + const mapper = RedditBlock.tools.config?.params + if (!mapper) throw new Error('Reddit block has no params mapper') + return { ...args, ...mapper(args, { operation }) } +} + +describe('RedditBlock tool-call params', () => { + it('keeps the model time window for controversial posts', () => { + const params = runToolCall({ subreddit: 'news', time: 'week', limit: 10 }, 'get_controversial') + + expect(params).toMatchObject({ subreddit: 'news', time: 'week', limit: 10 }) + }) + + it('submits the model post body and typed flags without the block-only post type', () => { + const params = runToolCall( + { subreddit: 'test', title: 'Hello', text: 'Body', nsfw: true, send_replies: false }, + 'submit_post' + ) + + expect(params).toMatchObject({ + subreddit: 'test', + title: 'Hello', + text: 'Body', + nsfw: true, + spoiler: false, + send_replies: false, + }) + }) + + it('keeps the model vote direction', () => { + const params = runToolCall({ id: 't3_abc', dir: -1 }, 'vote') + + expect(params).toMatchObject({ id: 't3_abc', dir: -1 }) + }) +}) diff --git a/apps/sim/blocks/blocks/reddit.ts b/apps/sim/blocks/blocks/reddit.ts index 3e27c778d67..fa1bd85f183 100644 --- a/apps/sim/blocks/blocks/reddit.ts +++ b/apps/sim/blocks/blocks/reddit.ts @@ -2,6 +2,7 @@ import { RedditIcon } from '@/components/icons' import { getScopesForService } from '@/lib/oauth/utils' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { isToolCall, mapperOperation } from '@/blocks/utils' const REPORT_REASON_FIELD = ['reportReason', 'reportOtherReason'] as const @@ -1080,17 +1081,36 @@ Return ONLY the message content - no meta-commentary.`, } return toolMap[operation] || 'reddit_get_posts' }, - params: (inputs) => { - const operation = inputs.operation || 'get_posts' + params: (inputs, context) => { + const operation = mapperOperation(inputs, context) || 'get_posts' const { oauthCredential } = inputs + /** + * The block field's value, or on a tool call with that field blank, the model's arg under the + * tool's own param name. Canvas runs get the block field unchanged. + */ + const pick = (dedicated: unknown, toolParam: string): unknown => + isToolCall(context) && (dedicated === undefined || dedicated === null || dedicated === '') + ? inputs[toolParam] + : dedicated + const int = (value: unknown): number | undefined => + value ? Number.parseInt(String(value)) : undefined + const flag = (dedicated: unknown, toolParam: string): boolean => { + const value = pick(dedicated, toolParam) + return value === true || value === 'true' + } + const optionalFlag = (dedicated: unknown, toolParam: string): boolean | undefined => { + const value = pick(dedicated, toolParam) + return value !== undefined ? value === true || value === 'true' : undefined + } + if (operation === 'get_posts') { return { subreddit: inputs.subreddit, sort: inputs.sort, time: inputs.sort === 'top' || inputs.sort === 'controversial' ? inputs.time : undefined, - limit: inputs.limit ? Number.parseInt(inputs.limit) : undefined, + limit: int(inputs.limit), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1101,10 +1121,10 @@ Return ONLY the message content - no meta-commentary.`, return { postId: inputs.postId, subreddit: inputs.subreddit, - sort: inputs.commentSort, - limit: inputs.commentLimit ? Number.parseInt(inputs.commentLimit) : undefined, - depth: inputs.commentDepth ? Number.parseInt(inputs.commentDepth) : undefined, - comment: inputs.commentFocus || undefined, + sort: pick(inputs.commentSort, 'sort'), + limit: int(pick(inputs.commentLimit, 'limit')), + depth: int(pick(inputs.commentDepth, 'depth')), + comment: pick(inputs.commentFocus, 'comment') || undefined, oauthCredential, } } @@ -1112,10 +1132,8 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'get_controversial') { return { subreddit: inputs.subreddit, - time: inputs.controversialTime, - limit: inputs.controversialLimit - ? Number.parseInt(inputs.controversialLimit) - : undefined, + time: pick(inputs.controversialTime, 'time'), + limit: int(pick(inputs.controversialLimit, 'limit')), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1125,10 +1143,10 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'search') { return { subreddit: inputs.subreddit, - query: inputs.searchQuery, - sort: inputs.searchSort, - time: inputs.searchTime, - limit: inputs.searchLimit ? Number.parseInt(inputs.searchLimit) : undefined, + query: pick(inputs.searchQuery, 'query'), + sort: pick(inputs.searchSort, 'sort'), + time: pick(inputs.searchTime, 'time'), + limit: int(pick(inputs.searchLimit, 'limit')), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1136,71 +1154,71 @@ Return ONLY the message content - no meta-commentary.`, } if (operation === 'submit_post') { + const postTypeUnset = isToolCall(context) && !inputs.postType return { - subreddit: inputs.submitSubreddit, + subreddit: pick(inputs.submitSubreddit, 'subreddit'), title: inputs.title, - text: inputs.postType === 'text' ? inputs.text : undefined, - url: inputs.postType === 'link' ? inputs.url : undefined, - nsfw: inputs.nsfw === 'true', - spoiler: inputs.spoiler === 'true', - send_replies: - inputs.sendReplies !== undefined ? inputs.sendReplies === 'true' : undefined, - flair_id: inputs.flairId || undefined, - flair_text: inputs.flairText || undefined, + text: postTypeUnset || inputs.postType === 'text' ? inputs.text : undefined, + url: postTypeUnset || inputs.postType === 'link' ? inputs.url : undefined, + nsfw: flag(inputs.nsfw, 'nsfw'), + spoiler: flag(inputs.spoiler, 'spoiler'), + send_replies: optionalFlag(inputs.sendReplies, 'send_replies'), + flair_id: pick(inputs.flairId, 'flair_id') || undefined, + flair_text: pick(inputs.flairText, 'flair_text') || undefined, oauthCredential, } } if (operation === 'vote') { return { - id: inputs.voteId, - dir: Number.parseInt(inputs.voteDirection), + id: pick(inputs.voteId, 'id'), + dir: Number.parseInt(String(pick(inputs.voteDirection, 'dir'))), oauthCredential, } } if (operation === 'save') { return { - id: inputs.saveId, - category: inputs.saveCategory || undefined, + id: pick(inputs.saveId, 'id'), + category: pick(inputs.saveCategory, 'category') || undefined, oauthCredential, } } if (operation === 'unsave') { return { - id: inputs.saveId, + id: pick(inputs.saveId, 'id'), oauthCredential, } } if (operation === 'reply') { return { - parent_id: inputs.replyParentId, - text: inputs.replyText, + parent_id: pick(inputs.replyParentId, 'parent_id'), + text: pick(inputs.replyText, 'text'), oauthCredential, } } if (operation === 'edit') { return { - thing_id: inputs.editThingId, - text: inputs.editText, + thing_id: pick(inputs.editThingId, 'thing_id'), + text: pick(inputs.editText, 'text'), oauthCredential, } } if (operation === 'delete') { return { - id: inputs.deleteId, + id: pick(inputs.deleteId, 'id'), oauthCredential, } } if (operation === 'subscribe') { return { - subreddit: inputs.subscribeSubreddit, - action: inputs.subscribeAction, + subreddit: pick(inputs.subscribeSubreddit, 'subreddit'), + action: pick(inputs.subscribeAction, 'action'), oauthCredential, } } @@ -1218,19 +1236,19 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'send_message') { return { - to: inputs.messageTo, - subject: inputs.messageSubject, - text: inputs.messageText, - from_sr: inputs.messageFromSr || undefined, + to: pick(inputs.messageTo, 'to'), + subject: pick(inputs.messageSubject, 'subject'), + text: pick(inputs.messageText, 'text'), + from_sr: pick(inputs.messageFromSr, 'from_sr') || undefined, oauthCredential, } } if (operation === 'get_messages') { return { - where: inputs.messageWhere, - limit: inputs.messageLimit ? Number.parseInt(inputs.messageLimit) : undefined, - mark: inputs.messageMark !== undefined ? inputs.messageMark === 'true' : undefined, + where: pick(inputs.messageWhere, 'where'), + limit: int(pick(inputs.messageLimit, 'limit')), + mark: optionalFlag(inputs.messageMark, 'mark'), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1252,14 +1270,15 @@ Return ONLY the message content - no meta-commentary.`, } if (operation === 'get_user_posts' || operation === 'get_user_comments') { + const sort = pick(inputs.userListSort, 'sort') return { - username: inputs.userListUsername, - sort: inputs.userListSort, + username: pick(inputs.userListUsername, 'username'), + sort, time: - inputs.userListSort === 'top' || inputs.userListSort === 'controversial' - ? inputs.userListTime + sort === 'top' || sort === 'controversial' + ? pick(inputs.userListTime, 'time') : undefined, - limit: inputs.userListLimit ? Number.parseInt(inputs.userListLimit) : undefined, + limit: int(pick(inputs.userListLimit, 'limit')), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1268,8 +1287,8 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'get_saved') { return { - username: inputs.userListUsername, - limit: inputs.userListLimit ? Number.parseInt(inputs.userListLimit) : undefined, + username: pick(inputs.userListUsername, 'username'), + limit: int(pick(inputs.userListLimit, 'limit')), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1278,18 +1297,16 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'get_info') { return { - id: inputs.infoIds, + id: pick(inputs.infoIds, 'id'), oauthCredential, } } if (operation === 'search_subreddits') { return { - q: inputs.searchSubredditsQuery, - sort: inputs.searchSubredditsSort, - limit: inputs.searchSubredditsLimit - ? Number.parseInt(inputs.searchSubredditsLimit) - : undefined, + q: pick(inputs.searchSubredditsQuery, 'q'), + sort: pick(inputs.searchSubredditsSort, 'sort'), + limit: int(pick(inputs.searchSubredditsLimit, 'limit')), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1298,7 +1315,7 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'list_my_subreddits') { return { - limit: inputs.listMineLimit ? Number.parseInt(inputs.listMineLimit) : undefined, + limit: int(pick(inputs.listMineLimit, 'limit')), after: inputs.after || undefined, before: inputs.before || undefined, oauthCredential, @@ -1307,30 +1324,30 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'report') { return { - thing_id: inputs.reportThingId, - reason: inputs.reportReason || undefined, - other_reason: inputs.reportOtherReason || undefined, + thing_id: pick(inputs.reportThingId, 'thing_id'), + reason: pick(inputs.reportReason, 'reason') || undefined, + other_reason: pick(inputs.reportOtherReason, 'other_reason') || undefined, oauthCredential, } } if (operation === 'hide' || operation === 'unhide') { return { - id: inputs.hideId, + id: pick(inputs.hideId, 'id'), oauthCredential, } } if (operation === 'marknsfw' || operation === 'unmarknsfw') { return { - id: inputs.nsfwId, + id: pick(inputs.nsfwId, 'id'), oauthCredential, } } if (operation === 'mark_read') { return { - id: inputs.markReadId, + id: pick(inputs.markReadId, 'id'), oauthCredential, } } @@ -1341,36 +1358,33 @@ Return ONLY the message content - no meta-commentary.`, if (operation === 'mod_approve' || operation === 'lock' || operation === 'unlock') { return { - id: inputs.modThingId, + id: pick(inputs.modThingId, 'id'), oauthCredential, } } if (operation === 'mod_remove') { return { - id: inputs.modThingId, - spam: inputs.removeSpam === 'true', + id: pick(inputs.modThingId, 'id'), + spam: flag(inputs.removeSpam, 'spam'), oauthCredential, } } if (operation === 'mod_distinguish') { return { - id: inputs.modThingId, - how: inputs.distinguishHow, - sticky: - inputs.distinguishSticky !== undefined - ? inputs.distinguishSticky === 'true' - : undefined, + id: pick(inputs.modThingId, 'id'), + how: pick(inputs.distinguishHow, 'how'), + sticky: optionalFlag(inputs.distinguishSticky, 'sticky'), oauthCredential, } } if (operation === 'mod_sticky') { return { - id: inputs.stickyId, - state: inputs.stickyState === 'true', - num: inputs.stickyNum ? Number.parseInt(inputs.stickyNum) : undefined, + id: pick(inputs.stickyId, 'id'), + state: flag(inputs.stickyState, 'state'), + num: int(pick(inputs.stickyNum, 'num')), oauthCredential, } } @@ -1378,7 +1392,7 @@ Return ONLY the message content - no meta-commentary.`, return { subreddit: inputs.subreddit, sort: inputs.sort, - limit: inputs.limit ? Number.parseInt(inputs.limit) : undefined, + limit: int(inputs.limit), oauthCredential, } }, diff --git a/apps/sim/blocks/blocks/revenuecat.ts b/apps/sim/blocks/blocks/revenuecat.ts index 6bd1f2f227e..1cca0509257 100644 --- a/apps/sim/blocks/blocks/revenuecat.ts +++ b/apps/sim/blocks/blocks/revenuecat.ts @@ -1,6 +1,7 @@ import { RevenueCatIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { mapperOperation } from '@/blocks/utils' import { getTrigger } from '@/triggers' export const RevenueCatBlock: BlockConfig = { @@ -443,13 +444,14 @@ Return ONLY the numeric timestamp, no text.`, ], config: { tool: (params) => `revenuecat_${params.operation}`, - params: (params) => { + params: (params, context) => { + const operation = mapperOperation(params, context) const next: Record = { ...params } - if (params.purchasePlatform && params.operation === 'create_purchase') { + if (params.purchasePlatform && operation === 'create_purchase') { next.platform = params.purchasePlatform } next.purchasePlatform = undefined - if (params.productId && params.operation === 'refund_google_subscription') { + if (params.productId && operation === 'refund_google_subscription') { next.storeTransactionId = params.productId next.productId = undefined } diff --git a/apps/sim/blocks/blocks/rocketlane.test.ts b/apps/sim/blocks/blocks/rocketlane.test.ts new file mode 100644 index 00000000000..db8a7ca70ee --- /dev/null +++ b/apps/sim/blocks/blocks/rocketlane.test.ts @@ -0,0 +1,36 @@ +import { describe, expect, it } from 'vitest' +import { RocketlaneBlock } from '@/blocks/blocks/rocketlane' + +/** Runs the mapper the way a tool call does: model args merged under the mapper's result. */ +function resolveToolCall(args: Record, operation: string) { + const mapper = RocketlaneBlock.tools.config?.params + if (!mapper) throw new Error('Rocketlane block has no params mapper') + return { ...args, ...mapper(args, { operation }) } +} + +describe('RocketlaneBlock agent tool calls', () => { + it('keeps and coerces the time source the model names when the operation arrives only in context', () => { + const result = resolveToolCall( + { apiKey: 'key', date: '2026-11-15', minutes: '30', projectId: '101' }, + 'create_time_entry' + ) + + expect(result).toMatchObject({ date: '2026-11-15', minutes: 30, projectId: 101 }) + expect(result.taskId).toBeUndefined() + }) +}) + +describe('RocketlaneBlock canvas mapping', () => { + it('sends a text filter that a reference resolved to a number instead of dropping it', () => { + const mapper = RocketlaneBlock.tools.config?.params + if (!mapper) throw new Error('Rocketlane block has no params mapper') + + const result = mapper({ + operation: 'list_projects', + apiKey: 'key', + externalReferenceIdEquals: 42, + }) + + expect(result.externalReferenceIdEquals).toBe('42') + }) +}) diff --git a/apps/sim/blocks/blocks/rocketlane.ts b/apps/sim/blocks/blocks/rocketlane.ts index a502311cb88..8e87be794a1 100644 --- a/apps/sim/blocks/blocks/rocketlane.ts +++ b/apps/sim/blocks/blocks/rocketlane.ts @@ -1,7 +1,7 @@ import { RocketlaneIcon } from '@/components/icons' -import type { BlockConfig, BlockMeta } from '@/blocks/types' +import type { BlockConfig, BlockMeta, BlockToolParamsContext } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils' /** * Who a membership change targets, for the card sentences below. Rocketlane @@ -219,8 +219,12 @@ function toNumber(value: unknown): number | undefined { return Number.isFinite(parsed) ? parsed : undefined } -/** Returns the trimmed string, or undefined for empty/non-string values. */ +/** + * Returns the trimmed string, or undefined for empty values. A finite number is stringified so an + * id or filter a model (or a resolved reference) sends as a number is not dropped. + */ function toStr(value: unknown): string | undefined { + if (typeof value === 'number') return Number.isFinite(value) ? String(value) : undefined if (typeof value !== 'string') return undefined const trimmed = value.trim() return trimmed.length > 0 ? trimmed : undefined @@ -302,9 +306,16 @@ function includeList(params: BlockParams) { } } -/** Builds the exact param set declared by the selected operation's tool. */ -function buildOperationParams(params: BlockParams): Record { - switch (params.operation) { +/** + * Builds the exact param set declared by the selected operation's tool. Where a block field is + * named differently from its tool param, a tool call (model args keyed by tool param names) falls + * back to the tool param via `toolCallArg`, so canvas output is unchanged. + */ +function buildOperationParams( + params: BlockParams, + context?: BlockToolParamsContext +): Record { + switch (mapperOperation(params, context)) { case 'create_project': return { projectName: toStr(params.projectName), @@ -411,7 +422,7 @@ function buildOperationParams(params: BlockParams): Record { projectId: toNumber(params.projectId), placeholderId: toNumber(params.placeholderId), userId: toNumber(params.userId), - userEmailId: toStr(params.userEmail), + userEmailId: toStr(params.userEmail) ?? toolCallArg(context, toStr(params.userEmailId)), } case 'unassign_placeholders': return { @@ -430,7 +441,7 @@ function buildOperationParams(params: BlockParams): Record { effortInMinutes: toNumber(params.effortInMinutes), progress: toNumber(params.progress), atRisk: toBool(params.atRisk), - type: toStr(params.taskType), + type: toStr(params.taskType) ?? toolCallArg(context, toStr(params.type)), phaseId: toNumber(params.phaseId), statusValue: toNumber(params.statusValue), assigneeUserIds: toNumberList(params.assigneeUserIds), @@ -472,7 +483,7 @@ function buildOperationParams(params: BlockParams): Record { effortInMinutes: toNumber(params.effortInMinutes), progress: toNumber(params.progress), atRisk: toBool(params.atRisk), - type: toStr(params.taskType), + type: toStr(params.taskType) ?? toolCallArg(context, toStr(params.type)), statusValue: toNumber(params.statusValue), externalReferenceId: toStr(params.externalReferenceId), private: toBool(params.private), @@ -586,10 +597,18 @@ function buildOperationParams(params: BlockParams): Record { date: toStr(params.date), minutes: toNumber(params.minutes), // Exactly one time source may be sent — pass only the selected one. - activityName: source === 'activity' ? toStr(params.timeEntryActivityName) : undefined, - taskId: source === 'task' ? toNumber(params.timeEntryTaskId) : undefined, - projectPhaseId: source === 'phase' ? toNumber(params.timeEntryPhaseId) : undefined, - projectId: source === 'project' ? toNumber(params.timeEntryProjectId) : undefined, + activityName: + (source === 'activity' ? toStr(params.timeEntryActivityName) : undefined) ?? + toolCallArg(context, toStr(params.activityName)), + taskId: + (source === 'task' ? toNumber(params.timeEntryTaskId) : undefined) ?? + toolCallArg(context, toNumber(params.taskId)), + projectPhaseId: + (source === 'phase' ? toNumber(params.timeEntryPhaseId) : undefined) ?? + toolCallArg(context, toNumber(params.projectPhaseId)), + projectId: + (source === 'project' ? toNumber(params.timeEntryProjectId) : undefined) ?? + toolCallArg(context, toNumber(params.projectId)), billable: toBool(params.billable), userId: toNumber(params.userId), userEmail: toStr(params.userEmail), @@ -634,8 +653,8 @@ function buildOperationParams(params: BlockParams): Record { dateEq: toStr(params.dateEq), dateGe: toStr(params.dateGe), dateLe: toStr(params.dateLe), - projectEq: toNumber(params.projectIdEq), - taskEq: toNumber(params.taskIdEq), + projectEq: toNumber(params.projectIdEq) ?? toolCallArg(context, toNumber(params.projectEq)), + taskEq: toNumber(params.taskIdEq) ?? toolCallArg(context, toNumber(params.taskEq)), projectPhaseIdEq: toNumber(params.projectPhaseIdEq), categoryIdEq: toNumber(params.categoryIdEq), userIdEq: toNumber(params.userIdEq), @@ -666,7 +685,7 @@ function buildOperationParams(params: BlockParams): Record { userEmail: toStr(params.userEmail), startDate: toStr(params.startDate), endDate: toStr(params.endDate), - type: toStr(params.timeOffType), + type: toStr(params.timeOffType) ?? toolCallArg(context, toStr(params.type)), durationInMinutes: toNumber(params.durationInMinutes), note: toStr(params.note), notifyProjectOwners: toBool(params.notifyProjectOwners), @@ -685,7 +704,7 @@ function buildOperationParams(params: BlockParams): Record { startDateLe: toStr(params.startDateLe), endDateGe: toStr(params.endDateGe), endDateLe: toStr(params.endDateLe), - typeEq: toStr(params.timeOffTypeEq), + typeEq: toStr(params.timeOffTypeEq) ?? toolCallArg(context, toStr(params.typeEq)), userIdEq: toStr(params.userIdEq), emailIdEq: toStr(params.emailIdEq), } @@ -703,8 +722,8 @@ function buildOperationParams(params: BlockParams): Record { lastNameCn: toStr(params.lastNameCn), emailEq: toStr(params.emailEq), emailCn: toStr(params.emailCn), - statusEq: toStr(params.userStatusEq), - typeEq: toStr(params.userTypeEq), + statusEq: toStr(params.userStatusEq) ?? toolCallArg(context, toStr(params.statusEq)), + typeEq: toStr(params.userTypeEq) ?? toolCallArg(context, toStr(params.typeEq)), } case 'create_space': @@ -738,7 +757,8 @@ function buildOperationParams(params: BlockParams): Record { spaceDocumentType: toStr(params.spaceDocumentType), spaceDocumentName: toStr(params.spaceDocumentName), url: toStr(params.url), - templateId: toNumber(params.documentTemplateId), + templateId: + toNumber(params.documentTemplateId) ?? toolCallArg(context, toNumber(params.templateId)), } case 'get_space_document': return { spaceDocumentId: toNumber(params.spaceDocumentId) } @@ -792,8 +812,9 @@ function buildOperationParams(params: BlockParams): Record { amountOutstandingGt: toNumber(params.amountOutstandingGt), invoiceNumberEq: toStr(params.invoiceNumberEq), invoiceNumberCn: toStr(params.invoiceNumberCn), - statusEq: toStr(params.invoiceStatusEq), - statusOneOf: toStr(params.invoiceStatusOneOf), + statusEq: toStr(params.invoiceStatusEq) ?? toolCallArg(context, toStr(params.statusEq)), + statusOneOf: + toStr(params.invoiceStatusOneOf) ?? toolCallArg(context, toStr(params.statusOneOf)), companyIdEq: toStr(params.companyIdEq), companyIdOneOf: toStr(params.companyIdOneOf), } @@ -2824,8 +2845,8 @@ export const RocketlaneBlock: BlockConfig = { ], config: { tool: (params) => `rocketlane_${params.operation}`, - params: (params) => ({ - ...buildOperationParams(params), + params: (params, context) => ({ + ...buildOperationParams(params, context), apiKey: params.apiKey, }), }, diff --git a/apps/sim/blocks/blocks/rootly.test.ts b/apps/sim/blocks/blocks/rootly.test.ts new file mode 100644 index 00000000000..81928ce3d0b --- /dev/null +++ b/apps/sim/blocks/blocks/rootly.test.ts @@ -0,0 +1,33 @@ +import { describe, expect, it } from 'vitest' +import { RootlyBlock } from '@/blocks/blocks/rootly' + +/** Runs the mapper the way a tool call does: merged row and model args under the mapper's result. */ +function resolveToolCall(args: Record, operation: string) { + const mapper = RootlyBlock.tools.config?.params + if (!mapper) throw new Error('Rootly block has no params mapper') + return { ...args, ...mapper(args, { operation }) } +} + +describe('RootlyBlock agent tool calls', () => { + it('maps a field saved on the tool row while keeping the model args named after tool params', () => { + const result = resolveToolCall( + { apiKey: 'key', updateIncidentId: 'inc_1', title: 'Database degraded', private: true }, + 'rootly_update_incident' + ) + + expect(result).toMatchObject({ + incidentId: 'inc_1', + title: 'Database degraded', + private: true, + }) + }) + + it('keeps a boolean resolveRelatedIncidents sent by the model', () => { + const result = resolveToolCall( + { apiKey: 'key', alertId: 'a1', resolveRelatedIncidents: true }, + 'rootly_resolve_alert' + ) + + expect(result).toMatchObject({ alertId: 'a1', resolveRelatedIncidents: true }) + }) +}) diff --git a/apps/sim/blocks/blocks/rootly.ts b/apps/sim/blocks/blocks/rootly.ts index 26c48533fa3..51b3e958e25 100644 --- a/apps/sim/blocks/blocks/rootly.ts +++ b/apps/sim/blocks/blocks/rootly.ts @@ -1,9 +1,439 @@ import { RootlyIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { + isToolCall, + mapperOperation, + parseOptionalBooleanInput, + withSavedCredential, +} from '@/blocks/utils' import { getTrigger } from '@/triggers' +/** + * Maps the block's per-operation fields onto the selected tool's params. Most block fields carry an + * operation prefix and are renamed to their tool param here. A few share the tool param's id + * (`title`, `resolveRelatedIncidents`, `mitigationMessage`, `resolutionMessage`, + * `cancellationMessage`), so on tool calls they hold the model's typed value and any coercion must + * accept it. + */ +function buildOperationParams( + params: Record, + operation: string +): Record { + const baseParams: Record = { + apiKey: params.apiKey, + } + + switch (operation) { + case 'rootly_create_incident': + return { + ...baseParams, + title: params.title, + summary: params.createSummary, + severityId: params.createSeverityId, + status: params.createStatus, + kind: params.createKind, + serviceIds: params.createServiceIds, + environmentIds: params.createEnvironmentIds, + groupIds: params.createGroupIds, + incidentTypeIds: params.createIncidentTypeIds, + functionalityIds: params.createFunctionalityIds, + labels: params.createLabels, + private: params.createPrivate ? params.createPrivate === 'true' : undefined, + } + + case 'rootly_get_incident': + return { + ...baseParams, + incidentId: params.getIncidentId, + } + + case 'rootly_update_incident': + return { + ...baseParams, + incidentId: params.updateIncidentId, + title: params.updateTitle, + summary: params.updateSummary, + status: params.updateStatus, + severityId: params.updateSeverityId, + kind: params.updateKind, + private: params.updatePrivate ? params.updatePrivate === 'true' : undefined, + mitigationMessage: params.mitigationMessage, + resolutionMessage: params.resolutionMessage, + cancellationMessage: params.cancellationMessage, + serviceIds: params.updateServiceIds, + environmentIds: params.updateEnvironmentIds, + groupIds: params.updateGroupIds, + incidentTypeIds: params.updateIncidentTypeIds, + functionalityIds: params.updateFunctionalityIds, + labels: params.updateLabels, + } + + case 'rootly_list_incidents': + return { + ...baseParams, + status: params.listIncidentsStatus, + search: params.listIncidentsSearch, + severity: params.listIncidentsSeverity, + services: params.listIncidentsServices, + teams: params.listIncidentsTeams, + environments: params.listIncidentsEnvironments, + sort: params.listIncidentsSort, + pageSize: params.listIncidentsPageSize ? Number(params.listIncidentsPageSize) : undefined, + pageNumber: params.listIncidentsPageNumber + ? Number(params.listIncidentsPageNumber) + : undefined, + } + + case 'rootly_create_alert': + return { + ...baseParams, + summary: params.alertSummary, + description: params.alertDescription, + source: params.alertSource, + status: params.alertStatus, + serviceIds: params.alertServiceIds, + groupIds: params.alertGroupIds, + environmentIds: params.alertEnvironmentIds, + externalId: params.alertExternalId, + deduplicationKey: params.alertDeduplicationKey, + externalUrl: params.alertExternalUrl, + } + + case 'rootly_list_alerts': + return { + ...baseParams, + status: params.listAlertsStatus, + source: params.listAlertsSource, + services: params.listAlertsServices, + environments: params.listAlertsEnvironments, + groups: params.listAlertsGroups, + pageSize: params.listAlertsPageSize ? Number(params.listAlertsPageSize) : undefined, + pageNumber: params.listAlertsPageNumber ? Number(params.listAlertsPageNumber) : undefined, + } + + case 'rootly_add_incident_event': + return { + ...baseParams, + incidentId: params.eventIncidentId, + event: params.eventText, + visibility: params.eventVisibility, + } + + case 'rootly_list_services': + return { + ...baseParams, + search: params.servicesSearch, + pageSize: params.servicesPageSize ? Number(params.servicesPageSize) : undefined, + pageNumber: params.servicesPageNumber ? Number(params.servicesPageNumber) : undefined, + } + + case 'rootly_list_severities': + return { + ...baseParams, + search: params.severitiesSearch, + pageSize: params.severitiesPageSize ? Number(params.severitiesPageSize) : undefined, + pageNumber: params.severitiesPageNumber ? Number(params.severitiesPageNumber) : undefined, + } + + case 'rootly_list_teams': + return { + ...baseParams, + search: params.teamsSearch, + pageSize: params.teamsPageSize ? Number(params.teamsPageSize) : undefined, + pageNumber: params.teamsPageNumber ? Number(params.teamsPageNumber) : undefined, + } + + case 'rootly_list_environments': + return { + ...baseParams, + search: params.environmentsSearch, + pageSize: params.environmentsPageSize ? Number(params.environmentsPageSize) : undefined, + pageNumber: params.environmentsPageNumber + ? Number(params.environmentsPageNumber) + : undefined, + } + + case 'rootly_list_incident_types': + return { + ...baseParams, + search: params.incidentTypesSearch, + pageSize: params.incidentTypesPageSize ? Number(params.incidentTypesPageSize) : undefined, + pageNumber: params.incidentTypesPageNumber + ? Number(params.incidentTypesPageNumber) + : undefined, + } + + case 'rootly_list_functionalities': + return { + ...baseParams, + search: params.functionalitiesSearch, + pageSize: params.functionalitiesPageSize + ? Number(params.functionalitiesPageSize) + : undefined, + pageNumber: params.functionalitiesPageNumber + ? Number(params.functionalitiesPageNumber) + : undefined, + } + + case 'rootly_list_retrospectives': + return { + ...baseParams, + status: params.retrospectivesStatus, + search: params.retrospectivesSearch, + pageSize: params.retrospectivesPageSize ? Number(params.retrospectivesPageSize) : undefined, + pageNumber: params.retrospectivesPageNumber + ? Number(params.retrospectivesPageNumber) + : undefined, + } + + case 'rootly_delete_incident': + return { + ...baseParams, + incidentId: params.deleteIncidentId, + } + + case 'rootly_get_alert': + return { + ...baseParams, + alertId: params.getAlertId, + } + + case 'rootly_update_alert': + return { + ...baseParams, + alertId: params.updateAlertId, + summary: params.updateAlertSummary, + description: params.updateAlertDescription, + source: params.updateAlertSource, + serviceIds: params.updateAlertServiceIds, + groupIds: params.updateAlertGroupIds, + environmentIds: params.updateAlertEnvironmentIds, + externalId: params.updateAlertExternalId, + externalUrl: params.updateAlertExternalUrl, + deduplicationKey: params.updateAlertDeduplicationKey, + } + + case 'rootly_acknowledge_alert': + return { + ...baseParams, + alertId: params.ackAlertId, + } + + case 'rootly_resolve_alert': + return { + ...baseParams, + alertId: params.resolveAlertId, + resolutionMessage: params.resolveResolutionMessage, + resolveRelatedIncidents: parseOptionalBooleanInput(params.resolveRelatedIncidents), + } + + case 'rootly_create_action_item': + return { + ...baseParams, + incidentId: params.actionItemIncidentId, + summary: params.actionItemSummary, + description: params.actionItemDescription, + kind: params.actionItemKind, + priority: params.actionItemPriority, + status: params.actionItemStatus, + assignedToUserId: params.actionItemAssignedToUserId, + dueDate: params.actionItemDueDate, + } + + case 'rootly_list_action_items': + return { + ...baseParams, + incidentId: params.listActionItemsIncidentId, + pageSize: params.listActionItemsPageSize + ? Number(params.listActionItemsPageSize) + : undefined, + pageNumber: params.listActionItemsPageNumber + ? Number(params.listActionItemsPageNumber) + : undefined, + } + + case 'rootly_list_users': + return { + ...baseParams, + search: params.usersSearch, + email: params.usersEmail, + pageSize: params.usersPageSize ? Number(params.usersPageSize) : undefined, + pageNumber: params.usersPageNumber ? Number(params.usersPageNumber) : undefined, + } + + case 'rootly_list_on_calls': + return { + ...baseParams, + scheduleIds: params.onCallsScheduleIds, + escalationPolicyIds: params.onCallsEscalationPolicyIds, + userIds: params.onCallsUserIds, + serviceIds: params.onCallsServiceIds, + } + + case 'rootly_list_schedules': + return { + ...baseParams, + search: params.schedulesSearch, + pageSize: params.schedulesPageSize ? Number(params.schedulesPageSize) : undefined, + pageNumber: params.schedulesPageNumber ? Number(params.schedulesPageNumber) : undefined, + } + + case 'rootly_list_escalation_policies': + return { + ...baseParams, + search: params.escalationPoliciesSearch, + pageSize: params.escalationPoliciesPageSize + ? Number(params.escalationPoliciesPageSize) + : undefined, + pageNumber: params.escalationPoliciesPageNumber + ? Number(params.escalationPoliciesPageNumber) + : undefined, + } + + case 'rootly_list_causes': + return { + ...baseParams, + search: params.causesSearch, + pageSize: params.causesPageSize ? Number(params.causesPageSize) : undefined, + pageNumber: params.causesPageNumber ? Number(params.causesPageNumber) : undefined, + } + + case 'rootly_list_playbooks': + return { + ...baseParams, + pageSize: params.playbooksPageSize ? Number(params.playbooksPageSize) : undefined, + pageNumber: params.playbooksPageNumber ? Number(params.playbooksPageNumber) : undefined, + } + + case 'rootly_mitigate_incident': + return { + ...baseParams, + incidentId: params.mitigateIncidentId, + mitigationMessage: params.mitigateMessage, + } + + case 'rootly_resolve_incident': + return { + ...baseParams, + incidentId: params.resolveIncidentId, + resolutionMessage: params.resolveIncidentMessage, + } + + case 'rootly_assign_incident_role': + return { + ...baseParams, + incidentId: params.assignRoleIncidentId, + userId: params.assignRoleUserId, + incidentRoleId: params.assignRoleId, + } + + case 'rootly_unassign_incident_role': + return { + ...baseParams, + incidentId: params.unassignRoleIncidentId, + userId: params.unassignRoleUserId, + incidentRoleId: params.unassignRoleId, + } + + case 'rootly_add_subscribers': + return { + ...baseParams, + incidentId: params.addSubsIncidentId, + userIds: params.addSubsUserIds, + } + + case 'rootly_remove_subscribers': + return { + ...baseParams, + incidentId: params.removeSubsIncidentId, + userIds: params.removeSubsUserIds, + } + + case 'rootly_create_status_page_event': + return { + ...baseParams, + incidentId: params.statusEventIncidentId, + event: params.statusEventText, + status: params.statusEventStatus, + statusPageId: params.statusEventStatusPageId, + notifySubscribers: params.statusEventNotify + ? params.statusEventNotify === 'true' + : undefined, + shouldTweet: params.statusEventTweet ? params.statusEventTweet === 'true' : undefined, + } + + case 'rootly_update_action_item': + return { + ...baseParams, + actionItemId: params.updateActionItemId, + summary: params.updateActionItemSummary, + description: params.updateActionItemDescription, + status: params.updateActionItemStatus, + priority: params.updateActionItemPriority, + kind: params.updateActionItemKind, + assignedToUserId: params.updateActionItemAssignee, + dueDate: params.updateActionItemDueDate, + } + + case 'rootly_delete_action_item': + return { + ...baseParams, + actionItemId: params.deleteActionItemId, + } + + case 'rootly_snooze_alert': + return { + ...baseParams, + alertId: params.snoozeAlertId, + delayMinutes: params.snoozeDelayMinutes ? Number(params.snoozeDelayMinutes) : undefined, + } + + case 'rootly_escalate_alert': + return { + ...baseParams, + alertId: params.escalateAlertId, + escalationPolicyId: params.escalatePolicyId, + escalationPolicyLevel: params.escalatePolicyLevel + ? Number(params.escalatePolicyLevel) + : undefined, + } + + case 'rootly_list_incident_events': + return { + ...baseParams, + incidentId: params.listEventsIncidentId, + pageSize: params.listEventsPageSize ? Number(params.listEventsPageSize) : undefined, + pageNumber: params.listEventsPageNumber ? Number(params.listEventsPageNumber) : undefined, + } + + case 'rootly_run_workflow': + return { + ...baseParams, + workflowId: params.runWorkflowId, + incidentId: params.runWorkflowIncidentId, + alertId: params.runWorkflowAlertId, + immediate: params.runWorkflowImmediate ? params.runWorkflowImmediate === 'true' : undefined, + checkConditions: params.runWorkflowCheckConditions + ? params.runWorkflowCheckConditions === 'true' + : undefined, + } + + case 'rootly_list_incident_roles': + return { + ...baseParams, + search: params.incidentRolesSearch, + pageSize: params.incidentRolesPageSize ? Number(params.incidentRolesPageSize) : undefined, + pageNumber: params.incidentRolesPageNumber + ? Number(params.incidentRolesPageNumber) + : undefined, + } + + default: + return baseParams + } +} + export const RootlyBlock: BlockConfig = { type: 'rootly', hideFromToolbar: true, @@ -1887,445 +2317,16 @@ export const RootlyBlock: BlockConfig = { ], config: { tool: (params) => params.operation, - params: (params) => { - const baseParams: Record = { - apiKey: params.apiKey, - } - - switch (params.operation) { - case 'rootly_create_incident': - return { - ...baseParams, - title: params.title, - summary: params.createSummary, - severityId: params.createSeverityId, - status: params.createStatus, - kind: params.createKind, - serviceIds: params.createServiceIds, - environmentIds: params.createEnvironmentIds, - groupIds: params.createGroupIds, - incidentTypeIds: params.createIncidentTypeIds, - functionalityIds: params.createFunctionalityIds, - labels: params.createLabels, - private: params.createPrivate ? params.createPrivate === 'true' : undefined, - } - - case 'rootly_get_incident': - return { - ...baseParams, - incidentId: params.getIncidentId, - } - - case 'rootly_update_incident': - return { - ...baseParams, - incidentId: params.updateIncidentId, - title: params.updateTitle, - summary: params.updateSummary, - status: params.updateStatus, - severityId: params.updateSeverityId, - kind: params.updateKind, - private: params.updatePrivate ? params.updatePrivate === 'true' : undefined, - mitigationMessage: params.mitigationMessage, - resolutionMessage: params.resolutionMessage, - cancellationMessage: params.cancellationMessage, - serviceIds: params.updateServiceIds, - environmentIds: params.updateEnvironmentIds, - groupIds: params.updateGroupIds, - incidentTypeIds: params.updateIncidentTypeIds, - functionalityIds: params.updateFunctionalityIds, - labels: params.updateLabels, - } - - case 'rootly_list_incidents': - return { - ...baseParams, - status: params.listIncidentsStatus, - search: params.listIncidentsSearch, - severity: params.listIncidentsSeverity, - services: params.listIncidentsServices, - teams: params.listIncidentsTeams, - environments: params.listIncidentsEnvironments, - sort: params.listIncidentsSort, - pageSize: params.listIncidentsPageSize - ? Number(params.listIncidentsPageSize) - : undefined, - pageNumber: params.listIncidentsPageNumber - ? Number(params.listIncidentsPageNumber) - : undefined, - } - - case 'rootly_create_alert': - return { - ...baseParams, - summary: params.alertSummary, - description: params.alertDescription, - source: params.alertSource, - status: params.alertStatus, - serviceIds: params.alertServiceIds, - groupIds: params.alertGroupIds, - environmentIds: params.alertEnvironmentIds, - externalId: params.alertExternalId, - deduplicationKey: params.alertDeduplicationKey, - externalUrl: params.alertExternalUrl, - } - - case 'rootly_list_alerts': - return { - ...baseParams, - status: params.listAlertsStatus, - source: params.listAlertsSource, - services: params.listAlertsServices, - environments: params.listAlertsEnvironments, - groups: params.listAlertsGroups, - pageSize: params.listAlertsPageSize ? Number(params.listAlertsPageSize) : undefined, - pageNumber: params.listAlertsPageNumber - ? Number(params.listAlertsPageNumber) - : undefined, - } - - case 'rootly_add_incident_event': - return { - ...baseParams, - incidentId: params.eventIncidentId, - event: params.eventText, - visibility: params.eventVisibility, - } - - case 'rootly_list_services': - return { - ...baseParams, - search: params.servicesSearch, - pageSize: params.servicesPageSize ? Number(params.servicesPageSize) : undefined, - pageNumber: params.servicesPageNumber ? Number(params.servicesPageNumber) : undefined, - } - - case 'rootly_list_severities': - return { - ...baseParams, - search: params.severitiesSearch, - pageSize: params.severitiesPageSize ? Number(params.severitiesPageSize) : undefined, - pageNumber: params.severitiesPageNumber - ? Number(params.severitiesPageNumber) - : undefined, - } - - case 'rootly_list_teams': - return { - ...baseParams, - search: params.teamsSearch, - pageSize: params.teamsPageSize ? Number(params.teamsPageSize) : undefined, - pageNumber: params.teamsPageNumber ? Number(params.teamsPageNumber) : undefined, - } - - case 'rootly_list_environments': - return { - ...baseParams, - search: params.environmentsSearch, - pageSize: params.environmentsPageSize - ? Number(params.environmentsPageSize) - : undefined, - pageNumber: params.environmentsPageNumber - ? Number(params.environmentsPageNumber) - : undefined, - } - - case 'rootly_list_incident_types': - return { - ...baseParams, - search: params.incidentTypesSearch, - pageSize: params.incidentTypesPageSize - ? Number(params.incidentTypesPageSize) - : undefined, - pageNumber: params.incidentTypesPageNumber - ? Number(params.incidentTypesPageNumber) - : undefined, - } - - case 'rootly_list_functionalities': - return { - ...baseParams, - search: params.functionalitiesSearch, - pageSize: params.functionalitiesPageSize - ? Number(params.functionalitiesPageSize) - : undefined, - pageNumber: params.functionalitiesPageNumber - ? Number(params.functionalitiesPageNumber) - : undefined, - } - - case 'rootly_list_retrospectives': - return { - ...baseParams, - status: params.retrospectivesStatus, - search: params.retrospectivesSearch, - pageSize: params.retrospectivesPageSize - ? Number(params.retrospectivesPageSize) - : undefined, - pageNumber: params.retrospectivesPageNumber - ? Number(params.retrospectivesPageNumber) - : undefined, - } - - case 'rootly_delete_incident': - return { - ...baseParams, - incidentId: params.deleteIncidentId, - } - - case 'rootly_get_alert': - return { - ...baseParams, - alertId: params.getAlertId, - } - - case 'rootly_update_alert': - return { - ...baseParams, - alertId: params.updateAlertId, - summary: params.updateAlertSummary, - description: params.updateAlertDescription, - source: params.updateAlertSource, - serviceIds: params.updateAlertServiceIds, - groupIds: params.updateAlertGroupIds, - environmentIds: params.updateAlertEnvironmentIds, - externalId: params.updateAlertExternalId, - externalUrl: params.updateAlertExternalUrl, - deduplicationKey: params.updateAlertDeduplicationKey, - } - - case 'rootly_acknowledge_alert': - return { - ...baseParams, - alertId: params.ackAlertId, - } - - case 'rootly_resolve_alert': - return { - ...baseParams, - alertId: params.resolveAlertId, - resolutionMessage: params.resolveResolutionMessage, - resolveRelatedIncidents: params.resolveRelatedIncidents - ? params.resolveRelatedIncidents === 'true' - : undefined, - } - - case 'rootly_create_action_item': - return { - ...baseParams, - incidentId: params.actionItemIncidentId, - summary: params.actionItemSummary, - description: params.actionItemDescription, - kind: params.actionItemKind, - priority: params.actionItemPriority, - status: params.actionItemStatus, - assignedToUserId: params.actionItemAssignedToUserId, - dueDate: params.actionItemDueDate, - } - - case 'rootly_list_action_items': - return { - ...baseParams, - incidentId: params.listActionItemsIncidentId, - pageSize: params.listActionItemsPageSize - ? Number(params.listActionItemsPageSize) - : undefined, - pageNumber: params.listActionItemsPageNumber - ? Number(params.listActionItemsPageNumber) - : undefined, - } - - case 'rootly_list_users': - return { - ...baseParams, - search: params.usersSearch, - email: params.usersEmail, - pageSize: params.usersPageSize ? Number(params.usersPageSize) : undefined, - pageNumber: params.usersPageNumber ? Number(params.usersPageNumber) : undefined, - } - - case 'rootly_list_on_calls': - return { - ...baseParams, - scheduleIds: params.onCallsScheduleIds, - escalationPolicyIds: params.onCallsEscalationPolicyIds, - userIds: params.onCallsUserIds, - serviceIds: params.onCallsServiceIds, - } - - case 'rootly_list_schedules': - return { - ...baseParams, - search: params.schedulesSearch, - pageSize: params.schedulesPageSize ? Number(params.schedulesPageSize) : undefined, - pageNumber: params.schedulesPageNumber - ? Number(params.schedulesPageNumber) - : undefined, - } - - case 'rootly_list_escalation_policies': - return { - ...baseParams, - search: params.escalationPoliciesSearch, - pageSize: params.escalationPoliciesPageSize - ? Number(params.escalationPoliciesPageSize) - : undefined, - pageNumber: params.escalationPoliciesPageNumber - ? Number(params.escalationPoliciesPageNumber) - : undefined, - } - - case 'rootly_list_causes': - return { - ...baseParams, - search: params.causesSearch, - pageSize: params.causesPageSize ? Number(params.causesPageSize) : undefined, - pageNumber: params.causesPageNumber ? Number(params.causesPageNumber) : undefined, - } - - case 'rootly_list_playbooks': - return { - ...baseParams, - pageSize: params.playbooksPageSize ? Number(params.playbooksPageSize) : undefined, - pageNumber: params.playbooksPageNumber - ? Number(params.playbooksPageNumber) - : undefined, - } - - case 'rootly_mitigate_incident': - return { - ...baseParams, - incidentId: params.mitigateIncidentId, - mitigationMessage: params.mitigateMessage, - } - - case 'rootly_resolve_incident': - return { - ...baseParams, - incidentId: params.resolveIncidentId, - resolutionMessage: params.resolveIncidentMessage, - } - - case 'rootly_assign_incident_role': - return { - ...baseParams, - incidentId: params.assignRoleIncidentId, - userId: params.assignRoleUserId, - incidentRoleId: params.assignRoleId, - } - - case 'rootly_unassign_incident_role': - return { - ...baseParams, - incidentId: params.unassignRoleIncidentId, - userId: params.unassignRoleUserId, - incidentRoleId: params.unassignRoleId, - } - - case 'rootly_add_subscribers': - return { - ...baseParams, - incidentId: params.addSubsIncidentId, - userIds: params.addSubsUserIds, - } - - case 'rootly_remove_subscribers': - return { - ...baseParams, - incidentId: params.removeSubsIncidentId, - userIds: params.removeSubsUserIds, - } - - case 'rootly_create_status_page_event': - return { - ...baseParams, - incidentId: params.statusEventIncidentId, - event: params.statusEventText, - status: params.statusEventStatus, - statusPageId: params.statusEventStatusPageId, - notifySubscribers: params.statusEventNotify - ? params.statusEventNotify === 'true' - : undefined, - shouldTweet: params.statusEventTweet ? params.statusEventTweet === 'true' : undefined, - } - - case 'rootly_update_action_item': - return { - ...baseParams, - actionItemId: params.updateActionItemId, - summary: params.updateActionItemSummary, - description: params.updateActionItemDescription, - status: params.updateActionItemStatus, - priority: params.updateActionItemPriority, - kind: params.updateActionItemKind, - assignedToUserId: params.updateActionItemAssignee, - dueDate: params.updateActionItemDueDate, - } - - case 'rootly_delete_action_item': - return { - ...baseParams, - actionItemId: params.deleteActionItemId, - } - - case 'rootly_snooze_alert': - return { - ...baseParams, - alertId: params.snoozeAlertId, - delayMinutes: params.snoozeDelayMinutes - ? Number(params.snoozeDelayMinutes) - : undefined, - } - - case 'rootly_escalate_alert': - return { - ...baseParams, - alertId: params.escalateAlertId, - escalationPolicyId: params.escalatePolicyId, - escalationPolicyLevel: params.escalatePolicyLevel - ? Number(params.escalatePolicyLevel) - : undefined, - } - - case 'rootly_list_incident_events': - return { - ...baseParams, - incidentId: params.listEventsIncidentId, - pageSize: params.listEventsPageSize ? Number(params.listEventsPageSize) : undefined, - pageNumber: params.listEventsPageNumber - ? Number(params.listEventsPageNumber) - : undefined, - } - - case 'rootly_run_workflow': - return { - ...baseParams, - workflowId: params.runWorkflowId, - incidentId: params.runWorkflowIncidentId, - alertId: params.runWorkflowAlertId, - immediate: params.runWorkflowImmediate - ? params.runWorkflowImmediate === 'true' - : undefined, - checkConditions: params.runWorkflowCheckConditions - ? params.runWorkflowCheckConditions === 'true' - : undefined, - } - - case 'rootly_list_incident_roles': - return { - ...baseParams, - search: params.incidentRolesSearch, - pageSize: params.incidentRolesPageSize - ? Number(params.incidentRolesPageSize) - : undefined, - pageNumber: params.incidentRolesPageNumber - ? Number(params.incidentRolesPageNumber) - : undefined, - } - - default: - return baseParams - } + params: (params, context) => { + const mapped = buildOperationParams(params, mapperOperation(params, context)) + if (!isToolCall(context)) return mapped + // Model args arrive under the tool's param names; keep one wherever its block field is empty. + return Object.fromEntries( + Object.entries(mapped).map(([key, value]) => [ + key, + value === undefined || value === '' ? params[key] : value, + ]) + ) }, }, }, diff --git a/apps/sim/blocks/blocks/sendblue.test.ts b/apps/sim/blocks/blocks/sendblue.test.ts new file mode 100644 index 00000000000..b89299686d5 --- /dev/null +++ b/apps/sim/blocks/blocks/sendblue.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, it } from 'vitest' +import { SendblueBlock } from '@/blocks/blocks/sendblue' + +/** Runs the mapper the way a tool call does: merged row and model args under the mapper's result. */ +function resolveToolCall(args: Record, operation: string) { + const mapper = SendblueBlock.tools.config?.params + if (!mapper) throw new Error('Sendblue block has no params mapper') + return { ...args, ...mapper(args, { operation }) } +} + +describe('SendblueBlock agent tool calls', () => { + it('splits recipients saved on the tool row when the operation arrives only in context', () => { + const result = resolveToolCall( + { numbers: '+19998887777\n+13334445555', from_number: '+15550001111', content: 'hi' }, + 'sendblue_send_group_message' + ) + + expect(result.numbers).toEqual(['+19998887777', '+13334445555']) + }) + + it('keeps the typing state the model sends under the tool param name', () => { + const result = resolveToolCall( + { number: '+19998887777', state: 'stop' }, + 'sendblue_send_typing_indicator' + ) + + expect(result.state).toBe('stop') + }) +}) diff --git a/apps/sim/blocks/blocks/sendblue.ts b/apps/sim/blocks/blocks/sendblue.ts index 11648dcdb0d..a1d1a747cf6 100644 --- a/apps/sim/blocks/blocks/sendblue.ts +++ b/apps/sim/blocks/blocks/sendblue.ts @@ -1,6 +1,7 @@ import { SendblueIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { mapperOperation, toolCallArg } from '@/blocks/utils' import { getTrigger } from '@/triggers' const SEND_STYLE_OPTIONS = [ @@ -245,13 +246,13 @@ export const SendblueBlock: BlockConfig = { ], config: { tool: (params) => params.operation || 'sendblue_send_message', - params: (params) => { + params: (params, context) => { const base: Record = { apiKeyId: params.apiKeyId, apiSecretKey: params.apiSecretKey, } - switch (params.operation) { + switch (mapperOperation(params, context)) { case 'sendblue_send_message': return { ...base, @@ -293,7 +294,7 @@ export const SendblueBlock: BlockConfig = { ...base, number: params.number, from_number: params.from_number || undefined, - state: params.typing_state || undefined, + state: params.typing_state || toolCallArg(context, params.state) || undefined, max_duration_ms: params.max_duration_ms !== undefined && params.max_duration_ms !== '' && diff --git a/apps/sim/blocks/blocks/sixtyfour.test.ts b/apps/sim/blocks/blocks/sixtyfour.test.ts new file mode 100644 index 00000000000..1827ce6b4c0 --- /dev/null +++ b/apps/sim/blocks/blocks/sixtyfour.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from 'vitest' +import { SixtyfourBlock } from '@/blocks/blocks/sixtyfour' + +/** Runs the mapper the way a tool call does: merged row and model args under the mapper's result. */ +function resolveToolCall(args: Record, operation: string) { + const mapper = SixtyfourBlock.tools.config?.params + if (!mapper) throw new Error('Sixtyfour block has no params mapper') + return { ...args, ...mapper(args, { operation }) } +} + +describe('SixtyfourBlock agent tool calls', () => { + it('maps the struct saved on the tool row when the operation arrives only in context', () => { + const struct = { website: 'Company website' } + const result = resolveToolCall( + { targetCompany: { name: 'Acme' }, companyStruct: struct }, + 'enrich_company' + ) + + expect(result.struct).toEqual(struct) + }) + + it('keeps the struct the model sends under the tool param name', () => { + const struct = { title: 'Job title' } + const result = resolveToolCall({ leadInfo: { name: 'Ada' }, struct }, 'enrich_lead') + + expect(result.struct).toEqual(struct) + }) +}) diff --git a/apps/sim/blocks/blocks/sixtyfour.ts b/apps/sim/blocks/blocks/sixtyfour.ts index 1a4cdeefacf..a16c28ad78d 100644 --- a/apps/sim/blocks/blocks/sixtyfour.ts +++ b/apps/sim/blocks/blocks/sixtyfour.ts @@ -1,6 +1,6 @@ import { SixtyfourIcon } from '@/components/icons' import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils' const PHONE_LOOKUP_FIELD = ['name', 'linkedinUrl', 'emailInput'] as const const EMAIL_LOOKUP_FIELD = ['name', 'linkedinUrl', 'phoneInput'] as const @@ -223,20 +223,21 @@ export const SixtyfourBlock: BlockConfig = { ], config: { tool: (params) => `sixtyfour_${params.operation}`, - params: (params) => { + params: (params, context) => { const result: Record = {} + const operation = mapperOperation(params, context) - if (params.operation === 'find_phone') { + if (operation === 'find_phone') { if (params.emailInput) result.email = params.emailInput - } else if (params.operation === 'find_email') { + } else if (operation === 'find_email') { if (params.phoneInput) result.phone = params.phoneInput - } else if (params.operation === 'enrich_lead') { + } else if (operation === 'enrich_lead') { result.leadInfo = params.leadInfo - result.struct = params.leadStruct + result.struct = params.leadStruct ?? toolCallArg(context, params.struct) if (params.leadResearchPlan) result.researchPlan = params.leadResearchPlan - } else if (params.operation === 'enrich_company') { + } else if (operation === 'enrich_company') { result.targetCompany = params.targetCompany - result.struct = params.companyStruct + result.struct = params.companyStruct ?? toolCallArg(context, params.struct) if (params.findPeople !== undefined) result.findPeople = Boolean(params.findPeople) if (params.fullOrgChart !== undefined) result.fullOrgChart = Boolean(params.fullOrgChart) if (params.peopleFocusPrompt) result.peopleFocusPrompt = params.peopleFocusPrompt diff --git a/apps/sim/blocks/blocks/smartlead.test.ts b/apps/sim/blocks/blocks/smartlead.test.ts new file mode 100644 index 00000000000..d536aecc676 --- /dev/null +++ b/apps/sim/blocks/blocks/smartlead.test.ts @@ -0,0 +1,35 @@ +/** + * An agent tool call passes the model's args under the tool's param names with the operation only + * in the mapper context, and the mapper's result is spread over those args. + */ +import { describe, expect, it } from 'vitest' +import { SmartleadBlock } from '@/blocks/blocks/smartlead' +import { addLeadsToCampaignTool } from '@/tools/smartlead/add_leads_to_campaign' +import { getLeadByEmailTool } from '@/tools/smartlead/get_lead_by_email' + +function agentToolParams(operation: string, args: Record) { + const mapped = SmartleadBlock.tools.config?.params?.(args, { operation }) ?? {} + return { ...args, ...mapped } as never +} + +describe('Smartlead agent tool calls', () => { + it('adds the leads the model passes to the campaign', () => { + const params = agentToolParams('add_leads_to_campaign', { + apiKey: 'key', + campaignId: 42, + leads: [{ email: 'ada@example.com', first_name: 'Ada' }], + }) + const body = addLeadsToCampaignTool.request.body?.(params) as { lead_list: unknown[] } + expect(body.lead_list).toHaveLength(1) + expect(body.lead_list[0]).toMatchObject({ email: 'ada@example.com' }) + }) + + it('looks up the lead by the email the model passes', () => { + const params = agentToolParams('get_lead_by_email', { + apiKey: 'key', + email: 'ada@example.com', + }) + const url = new URL((getLeadByEmailTool.request.url as (p: never) => string)(params)) + expect(url.searchParams.get('email')).toBe('ada@example.com') + }) +}) diff --git a/apps/sim/blocks/blocks/smartlead.ts b/apps/sim/blocks/blocks/smartlead.ts index a61d074b85a..2f551f2ed15 100644 --- a/apps/sim/blocks/blocks/smartlead.ts +++ b/apps/sim/blocks/blocks/smartlead.ts @@ -2,7 +2,7 @@ import { isRecordLike } from '@sim/utils/object' import { SmartleadIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils' const CAMPAIGN_ID_OPERATIONS = [ 'get_campaign', @@ -913,69 +913,76 @@ export const SmartleadBlock: BlockConfig = { ], config: { tool: (params) => `smartlead_${params.operation}`, - params: (params) => ({ - campaignId: toNumberParam(params.campaignId), - leadId: toNumberParam(params.leadId), - clientId: toNumberParam(params.clientId), - categoryId: toNumberParam(params.categoryId), - webhookId: toNumberParam( - params.operation === 'delete_campaign_webhook' ? params.deleteWebhookId : params.webhookId - ), - campaignLeadMapId: toNumberParam(params.campaignLeadMapId), - leadListId: toNumberParam(params.leadListId), - emailAccountIds: parseNumberList(params.emailAccountIds), - listName: emptyToUndefined(params.listName), - fromTime: emptyToUndefined(params.fromTime), - toTime: emptyToUndefined(params.toTime), - unreadOnly: toBooleanParam(params.unreadOnly), - offset: toNumberParam(params.offset), - limit: toNumberParam(params.limit), - emailSequenceNumber: toNumberParam(params.emailSequenceNumber), - minTimeBetweenEmails: toNumberParam(params.minTimeBetweenEmails), - maxNewLeadsPerDay: toNumberParam(params.maxNewLeadsPerDay), - resumeLeadWithDelayDays: toNumberParam(params.resumeLeadWithDelayDays), - includeTags: toBooleanParam(params.includeTags), - sendAsPlainText: toBooleanParam(params.sendAsPlainText), - pauseLead: toBooleanParam(params.pauseLead), - name: params.operation === 'create_campaign' ? params.campaignName : params.webhookName, - email: emptyToUndefined(params.leadEmail), - // Empty means "not chosen", so required validation reports it instead of - // the API rejecting an empty status. - status: emptyToUndefined(params.status), - emailStatus: emptyToUndefined(params.emailStatus), - stopLeadSettings: emptyToUndefined(params.stopLeadSettings), - daysOfTheWeek: parseNumberList(params.daysOfTheWeek), - trackSettings: parseStringList(params.trackSettings), - eventTypes: parseStringList(params.eventTypes), - categories: parseStringList(params.categories), - followUpPercentage: toNumberParam(params.followUpPercentage), - enableAiEspMatching: toBooleanParam(params.enableAiEspMatching), - unsubscribeText: emptyToUndefined(params.unsubscribeText), - scheduleStartTime: emptyToUndefined(params.scheduleStartTime), - companyUrl: emptyToUndefined(params.companyUrl), - sentTimeStartDate: emptyToUndefined(params.sentTimeStartDate), - sentTimeEndDate: emptyToUndefined(params.sentTimeEndDate), - ignoreGlobalBlockList: toBooleanParam(params.ignoreGlobalBlockList), - ignoreUnsubscribeList: toBooleanParam(params.ignoreUnsubscribeList), - ignoreDuplicateLeadsInOtherCampaign: toBooleanParam( - params.ignoreDuplicateLeadsInOtherCampaign - ), - ignoreCommunityBounceList: toBooleanParam(params.ignoreCommunityBounceList), - // Parsed only for the operation that consumes them, so a stale value left in a - // hidden field cannot fail an unrelated operation. - leads: - params.operation === 'add_leads_to_campaign' - ? parseJsonArray(params.leads, 'Leads') - : undefined, - sequences: - params.operation === 'save_campaign_sequences' - ? parseJsonArray(params.sequences, 'Sequences') - : undefined, - customFields: - params.operation === 'update_lead' - ? parseJsonObject(params.customFields, 'Custom Fields') - : undefined, - }), + params: (params, context) => { + const operation = mapperOperation(params, context) + return { + campaignId: toNumberParam(params.campaignId), + leadId: toNumberParam(params.leadId), + clientId: toNumberParam(params.clientId), + categoryId: toNumberParam(params.categoryId), + webhookId: + operation === 'delete_campaign_webhook' + ? (toNumberParam(params.deleteWebhookId) ?? + toNumberParam(toolCallArg(context, params.webhookId))) + : toNumberParam(params.webhookId), + campaignLeadMapId: toNumberParam(params.campaignLeadMapId), + leadListId: toNumberParam(params.leadListId), + emailAccountIds: parseNumberList(params.emailAccountIds), + listName: emptyToUndefined(params.listName), + fromTime: emptyToUndefined(params.fromTime), + toTime: emptyToUndefined(params.toTime), + unreadOnly: toBooleanParam(params.unreadOnly), + offset: toNumberParam(params.offset), + limit: toNumberParam(params.limit), + emailSequenceNumber: toNumberParam(params.emailSequenceNumber), + minTimeBetweenEmails: toNumberParam(params.minTimeBetweenEmails), + maxNewLeadsPerDay: toNumberParam(params.maxNewLeadsPerDay), + resumeLeadWithDelayDays: toNumberParam(params.resumeLeadWithDelayDays), + includeTags: toBooleanParam(params.includeTags), + sendAsPlainText: toBooleanParam(params.sendAsPlainText), + pauseLead: toBooleanParam(params.pauseLead), + name: + (operation === 'create_campaign' ? params.campaignName : params.webhookName) ?? + toolCallArg(context, params.name), + email: emptyToUndefined(params.leadEmail) ?? toolCallArg(context, params.email), + // Empty means "not chosen", so required validation reports it instead of + // the API rejecting an empty status. + status: emptyToUndefined(params.status), + emailStatus: emptyToUndefined(params.emailStatus), + stopLeadSettings: emptyToUndefined(params.stopLeadSettings), + daysOfTheWeek: parseNumberList(params.daysOfTheWeek), + trackSettings: parseStringList(params.trackSettings), + eventTypes: parseStringList(params.eventTypes), + categories: parseStringList(params.categories), + followUpPercentage: toNumberParam(params.followUpPercentage), + enableAiEspMatching: toBooleanParam(params.enableAiEspMatching), + unsubscribeText: emptyToUndefined(params.unsubscribeText), + scheduleStartTime: emptyToUndefined(params.scheduleStartTime), + companyUrl: emptyToUndefined(params.companyUrl), + sentTimeStartDate: emptyToUndefined(params.sentTimeStartDate), + sentTimeEndDate: emptyToUndefined(params.sentTimeEndDate), + ignoreGlobalBlockList: toBooleanParam(params.ignoreGlobalBlockList), + ignoreUnsubscribeList: toBooleanParam(params.ignoreUnsubscribeList), + ignoreDuplicateLeadsInOtherCampaign: toBooleanParam( + params.ignoreDuplicateLeadsInOtherCampaign + ), + ignoreCommunityBounceList: toBooleanParam(params.ignoreCommunityBounceList), + // Parsed only for the operation that consumes them, so a stale value left in a + // hidden field cannot fail an unrelated operation. + leads: + operation === 'add_leads_to_campaign' + ? parseJsonArray(params.leads, 'Leads') + : undefined, + sequences: + operation === 'save_campaign_sequences' + ? parseJsonArray(params.sequences, 'Sequences') + : undefined, + customFields: + operation === 'update_lead' + ? parseJsonObject(params.customFields, 'Custom Fields') + : undefined, + } + }, }, }, inputs: { diff --git a/apps/sim/blocks/blocks/stripe.test.ts b/apps/sim/blocks/blocks/stripe.test.ts index 4f77fad8616..1afc7c94741 100644 --- a/apps/sim/blocks/blocks/stripe.test.ts +++ b/apps/sim/blocks/blocks/stripe.test.ts @@ -95,6 +95,15 @@ describe('Stripe block keeps unset fields out of requests', () => { ).toThrow(/path separator/) }) + it('an agent updates a subscription with the metadata object it passes', () => { + const params = agentToolParams(StripeBlock, 'update_subscription', { + apiKey: 'sk_test', + id: 'sub_1', + metadata: { plan: 'pro' }, + }) + expect(formBody(stripeUpdateSubscriptionTool, params).get('metadata[plan]')).toBe('pro') + }) + it('an agent paginates list charges with the cursor it passes', () => { const params = agentToolParams(StripeBlock, 'list_charges', { apiKey: 'sk_test', diff --git a/apps/sim/blocks/blocks/stripe.ts b/apps/sim/blocks/blocks/stripe.ts index 48a57a62a0d..481d2da3957 100644 --- a/apps/sim/blocks/blocks/stripe.ts +++ b/apps/sim/blocks/blocks/stripe.ts @@ -1,7 +1,8 @@ +import { getErrorMessage } from '@sim/utils/errors' import { StripeIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { isToolCall, withSavedCredential } from '@/blocks/utils' +import { isToolCall, mapperOperation, withSavedCredential } from '@/blocks/utils' import { getTrigger } from '@/triggers' /** @@ -20,6 +21,15 @@ function parseOptionalBoolean(value: unknown): boolean | undefined { return value === true || value === 'true' } +/** + * Reads a JSON input. The canvas stores it as text; a tool call passes the model's already-parsed + * object or array, which is kept as is. + */ +function parseJsonInput(value: unknown): unknown { + if (!value) return undefined + return typeof value === 'string' ? JSON.parse(value) : value +} + const SUBSCRIPTION_LIST_OPERATION = 'list_subscriptions' const SUBSCRIPTION_SEARCH_OPERATION = 'search_subscriptions' @@ -928,8 +938,8 @@ export const StripeBlock: BlockConfig = { return `stripe_${params.operation}` }, params: (params, context) => { + const operation = mapperOperation(params, context) const { - operation, apiKey, address, metadata, @@ -952,20 +962,20 @@ export const StripeBlock: BlockConfig = { ...rest } = params - let parsedAddress: any | undefined - let parsedMetadata: any | undefined - let parsedItems: any | undefined - let parsedImages: any | undefined - let parsedRecurring: any | undefined + let parsedAddress: unknown + let parsedMetadata: unknown + let parsedItems: unknown + let parsedImages: unknown + let parsedRecurring: unknown try { - if (address) parsedAddress = JSON.parse(address) - if (metadata) parsedMetadata = JSON.parse(metadata) - if (items) parsedItems = JSON.parse(items) - if (images) parsedImages = JSON.parse(images) - if (recurring) parsedRecurring = JSON.parse(recurring) - } catch (error: any) { - throw new Error(`Invalid JSON input: ${error.message}`) + parsedAddress = parseJsonInput(address) + parsedMetadata = parseJsonInput(metadata) + parsedItems = parseJsonInput(items) + parsedImages = parseJsonInput(images) + parsedRecurring = parseJsonInput(recurring) + } catch (error) { + throw new Error(`Invalid JSON input: ${getErrorMessage(error)}`) } // Every key is assigned, unset ones as `undefined`: the executor merges these over the raw diff --git a/apps/sim/blocks/blocks/tiktok.test.ts b/apps/sim/blocks/blocks/tiktok.test.ts index 1002576562e..e8d56bbea5b 100644 --- a/apps/sim/blocks/blocks/tiktok.test.ts +++ b/apps/sim/blocks/blocks/tiktok.test.ts @@ -24,4 +24,11 @@ describe('TikTokBlock', () => { expect(finalInputs.file).toEqual(file) expect(finalInputs.videoIds).toBeUndefined() }) + + it('queries the video ids an agent passes as an array', () => { + const args = { videoIds: ['v1', ' v2 '] } + const finalInputs = { ...args, ...buildParams(args, { operation: 'tiktok_query_videos' }) } + + expect(finalInputs.videoIds).toEqual(['v1', 'v2']) + }) }) diff --git a/apps/sim/blocks/blocks/tiktok.ts b/apps/sim/blocks/blocks/tiktok.ts index 1c41d44395c..f535088adc6 100644 --- a/apps/sim/blocks/blocks/tiktok.ts +++ b/apps/sim/blocks/blocks/tiktok.ts @@ -2,7 +2,7 @@ import { TikTokIcon } from '@/components/icons' import { getScopesForService } from '@/lib/oauth/utils' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { normalizeFileInput } from '@/blocks/utils' +import { mapperOperation, normalizeFileInput } from '@/blocks/utils' import { getTrigger } from '@/triggers' const TIKTOK_TOOL_IDS = new Set([ @@ -212,8 +212,8 @@ export const TikTokBlock: BlockConfig = { } return operation }, - params: (params) => { - const operation = params.operation || 'tiktok_get_user' + params: (params, context) => { + const operation = mapperOperation(params, context) || 'tiktok_get_user' const result: Record = {} for (const key of TIKTOK_OPERATION_INPUT_KEYS) { result[key] = undefined @@ -230,8 +230,11 @@ export const TikTokBlock: BlockConfig = { } break case 'tiktok_query_videos': - result.videoIds = (params.videoIds || '') - .split(/[,\n]+/) + result.videoIds = ( + Array.isArray(params.videoIds) + ? params.videoIds.map(String) + : String(params.videoIds || '').split(/[,\n]+/) + ) .map((id: string) => id.trim()) .filter(Boolean) break diff --git a/apps/sim/blocks/blocks/vanta.ts b/apps/sim/blocks/blocks/vanta.ts index 5dd0e1616d7..30702ede8d8 100644 --- a/apps/sim/blocks/blocks/vanta.ts +++ b/apps/sim/blocks/blocks/vanta.ts @@ -1,7 +1,7 @@ import { VantaIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { normalizeFileInput } from '@/blocks/utils' +import { mapperOperation, normalizeFileInput, toolCallArg } from '@/blocks/utils' const LIST_OPERATIONS = [ 'list_frameworks', @@ -893,66 +893,78 @@ export const VantaBlock: BlockConfig = { ], config: { tool: (params) => `vanta_${params.operation}`, - params: (params) => { - const { operation, ...rest } = params + params: (params, context) => { + const operation = mapperOperation(params, context) const result: Record = {} if (LIST_OPERATIONS.includes(operation)) { result.pageSize = - rest.pageSize !== undefined && rest.pageSize !== '' && rest.pageSize !== null - ? Number(rest.pageSize) + params.pageSize !== undefined && params.pageSize !== '' && params.pageSize !== null + ? Number(params.pageSize) : undefined - result.pageCursor = optionalString(rest.pageCursor) + result.pageCursor = optionalString(params.pageCursor) } switch (operation) { case 'list_test_entities': - result.entityStatus = dropdownFilter(rest.entityStatus) + result.entityStatus = dropdownFilter(params.entityStatus) break case 'upload_document_file': { - const normalizedFile = normalizeFileInput(rest.file, { single: true }) + const normalizedFile = normalizeFileInput(params.file, { single: true }) if (normalizedFile) result.file = normalizedFile - result.fileName = optionalString(rest.uploadFileName) - result.description = optionalString(rest.uploadDescription) - result.effectiveAtDate = optionalString(rest.effectiveAtDate) + result.fileName = + optionalString(params.uploadFileName) ?? + optionalString(toolCallArg(context, params.fileName)) + result.description = + optionalString(params.uploadDescription) ?? + optionalString(toolCallArg(context, params.description)) + result.effectiveAtDate = optionalString(params.effectiveAtDate) break } case 'list_documents': - result.statusMatchesAny = optionalString(rest.documentStatusFilter) + result.statusMatchesAny = + optionalString(params.documentStatusFilter) ?? + optionalString(toolCallArg(context, params.statusMatchesAny)) break case 'list_tests': - result.statusFilter = dropdownFilter(rest.statusFilter) - result.categoryFilter = dropdownFilter(rest.categoryFilter) - result.isInRollout = triStateToBoolean(rest.isInRollout) + result.statusFilter = dropdownFilter(params.statusFilter) + result.categoryFilter = dropdownFilter(params.categoryFilter) + result.isInRollout = triStateToBoolean(params.isInRollout) break case 'list_people': - result.employmentStatus = dropdownFilter(rest.employmentStatus) + result.employmentStatus = dropdownFilter(params.employmentStatus) break case 'list_vendors': - result.name = optionalString(rest.vendorName) - result.statusMatchesAny = optionalString(rest.vendorStatusFilter) + result.name = + optionalString(params.vendorName) ?? optionalString(toolCallArg(context, params.name)) + result.statusMatchesAny = + optionalString(params.vendorStatusFilter) ?? + optionalString(toolCallArg(context, params.statusMatchesAny)) break case 'list_vulnerabilities': - result.q = optionalString(rest.searchQuery) - result.severity = dropdownFilter(rest.severity) - result.isFixAvailable = triStateToBoolean(rest.isFixAvailable) - result.isDeactivated = triStateToBoolean(rest.isDeactivated) + result.q = + optionalString(params.searchQuery) ?? optionalString(toolCallArg(context, params.q)) + result.severity = dropdownFilter(params.severity) + result.isFixAvailable = triStateToBoolean(params.isFixAvailable) + result.isDeactivated = triStateToBoolean(params.isDeactivated) result.includeVulnerabilitiesWithoutSlas = triStateToBoolean( - rest.includeVulnerabilitiesWithoutSlas + params.includeVulnerabilitiesWithoutSlas ) break case 'list_vulnerability_remediations': - result.severity = dropdownFilter(rest.severity) - result.isRemediatedOnTime = triStateToBoolean(rest.isRemediatedOnTime) + result.severity = dropdownFilter(params.severity) + result.isRemediatedOnTime = triStateToBoolean(params.isRemediatedOnTime) break case 'list_vulnerable_assets': - result.q = optionalString(rest.searchQuery) - result.assetType = dropdownFilter(rest.assetType) + result.q = + optionalString(params.searchQuery) ?? optionalString(toolCallArg(context, params.q)) + result.assetType = dropdownFilter(params.assetType) break case 'list_risk_scenarios': - result.type = dropdownFilter(rest.riskType) - result.includeIgnored = triStateToBoolean(rest.includeIgnored) - result.orderBy = dropdownFilter(rest.orderBy) + result.type = + dropdownFilter(params.riskType) ?? optionalString(toolCallArg(context, params.type)) + result.includeIgnored = triStateToBoolean(params.includeIgnored) + result.orderBy = dropdownFilter(params.orderBy) break default: break diff --git a/apps/sim/blocks/blocks/wealthbox.ts b/apps/sim/blocks/blocks/wealthbox.ts index 40d50c07b2e..c849500d0d4 100644 --- a/apps/sim/blocks/blocks/wealthbox.ts +++ b/apps/sim/blocks/blocks/wealthbox.ts @@ -2,6 +2,7 @@ import { WealthboxIcon } from '@/components/icons' import { getScopesForService } from '@/lib/oauth/utils' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' +import { isToolCall, mapperOperation } from '@/blocks/utils' const CONTACT_FIELD = ['contactId', 'manualContactId'] as const @@ -207,8 +208,9 @@ Return ONLY the date/time string - no explanations, no quotes, no extra text.`, throw new Error(`Unknown operation: ${params.operation}`) } }, - params: (params) => { - const { oauthCredential, operation, contactId, taskId, ...rest } = params + params: (params, context) => { + const operation = mapperOperation(params, context) + const { oauthCredential, contactId, taskId, ...rest } = params // contactId is the canonical param for both basic (file-selector) and advanced (manualContactId) modes const effectiveContactId = contactId ? String(contactId).trim() : '' @@ -226,7 +228,7 @@ Return ONLY the date/time string - no explanations, no quotes, no extra text.`, } } if (operation === 'read_contact') { - if (!effectiveContactId) { + if (!effectiveContactId && !isToolCall(context)) { throw new Error('Contact ID is required for contact operations') } return { @@ -236,6 +238,7 @@ Return ONLY the date/time string - no explanations, no quotes, no extra text.`, } if (operation === 'read_task') { if (!taskId?.trim()) { + if (isToolCall(context)) return baseParams throw new Error('Task ID is required for task operations') } return { @@ -245,6 +248,7 @@ Return ONLY the date/time string - no explanations, no quotes, no extra text.`, } if (operation === 'write_task' || operation === 'write_note') { if (!contactId?.trim()) { + if (isToolCall(context)) return baseParams throw new Error('Contact ID is required for this operation') } return { diff --git a/apps/sim/blocks/blocks/zendesk.ts b/apps/sim/blocks/blocks/zendesk.ts index 9e469856d1b..cc7c083e971 100644 --- a/apps/sim/blocks/blocks/zendesk.ts +++ b/apps/sim/blocks/blocks/zendesk.ts @@ -1,7 +1,12 @@ import { ZendeskIcon } from '@/components/icons' import type { BlockConfig, BlockMeta } from '@/blocks/types' import { AuthMode, IntegrationType } from '@/blocks/types' -import { parseOptionalBooleanInput, toolCallArg, withSavedCredential } from '@/blocks/utils' +import { + mapperOperation, + parseOptionalBooleanInput, + toolCallArg, + withSavedCredential, +} from '@/blocks/utils' import { getTrigger } from '@/triggers' export const ZendeskBlock: BlockConfig = { @@ -844,7 +849,7 @@ Return ONLY the search query - no explanations.`, } }, params: (params, context) => { - const { apiToken, operation, organizationName, commentPublic, ...rest } = params + const { apiToken, organizationName, commentPublic, ...rest } = params const cleanParams: Record = { apiToken } Object.entries(rest).forEach(([key, value]) => { @@ -854,7 +859,7 @@ Return ONLY the search query - no explanations.`, }) // Organization tools take `name`; the block's `name` field belongs to users. - const selectedOperation = operation ?? context?.operation + const selectedOperation = mapperOperation(params, context) if ( selectedOperation === 'autocomplete_organizations' || selectedOperation === 'create_organization' || diff --git a/apps/sim/blocks/blocks/zep.test.ts b/apps/sim/blocks/blocks/zep.test.ts new file mode 100644 index 00000000000..db340902527 --- /dev/null +++ b/apps/sim/blocks/blocks/zep.test.ts @@ -0,0 +1,18 @@ +import { describe, expect, it } from 'vitest' +import { ZepBlock } from '@/blocks/blocks/zep' + +describe('ZepBlock', () => { + const buildParams = ZepBlock.tools.config?.params + if (!buildParams) throw new Error('ZepBlock.tools.config.params is missing') + + /** + * An agent tool call passes the operation only in `context`. The mapper must validate and + * coerce for that operation, not fall back to `create_thread` and reject the call for a + * missing user ID. + */ + it('maps an agent tool call for the operation in context', () => { + const args = { apiKey: 'key', threadId: 'thread_1', limit: '10' } + + expect({ ...args, ...buildParams(args, { operation: 'get_messages' }) }.limit).toBe(10) + }) +}) diff --git a/apps/sim/blocks/blocks/zep.ts b/apps/sim/blocks/blocks/zep.ts index 0bd138a6e58..1767a576ef8 100644 --- a/apps/sim/blocks/blocks/zep.ts +++ b/apps/sim/blocks/blocks/zep.ts @@ -1,8 +1,18 @@ import { ZepIcon } from '@/components/icons' -import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types' -import { withSavedCredential } from '@/blocks/utils' +import { + AuthMode, + type BlockConfig, + type BlockMeta, + type BlockToolParamsContext, + IntegrationType, +} from '@/blocks/types' +import { isToolCall, mapperOperation, withSavedCredential } from '@/blocks/utils' -function zepToolParams(params: Record, requireApiKey: boolean) { +function zepToolParams( + params: Record, + requireApiKey: boolean, + context?: BlockToolParamsContext +) { const errors: string[] = [] // Validate required API key for all operations @@ -10,7 +20,7 @@ function zepToolParams(params: Record, requireApiKey: boolean) { errors.push('API Key is required') } - const operation = params.operation || 'create_thread' + const operation = mapperOperation(params, context) || 'create_thread' // Validate operation-specific required fields if ( @@ -35,7 +45,9 @@ function zepToolParams(params: Record, requireApiKey: boolean) { } } - if (operation === 'add_messages') { + // A tool call may send `messages` as a JSON string, which the tool parses and validates itself. + const toolParsesMessages = typeof params.messages === 'string' && isToolCall(context) + if (operation === 'add_messages' && !toolParsesMessages) { if (!params.messages) { errors.push('Messages are required') } else if (!Array.isArray(params.messages) || params.messages.length === 0) { @@ -290,7 +302,7 @@ export const ZepBlock: BlockConfig = { return 'zep_create_thread' } }, - params: (params) => zepToolParams(params, true), + params: (params, context) => zepToolParams(params, true, context), }, }, inputs: { @@ -436,6 +448,6 @@ export const ZepV2Block: BlockConfig = { ...withSavedCredential( ZepBlock, { id: 'credential', type: 'oauth-input', serviceId: 'zep', title: 'Zep Credential' }, - { params: (params) => zepToolParams(params, false) } + { params: (params, context) => zepToolParams(params, false, context) } ), } From df7face5f886e6d39fded07e5150d0ba864acd60 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 15 Nov 2026 16:48:07 -0800 Subject: [PATCH 2/6] chore: regenerate tool metadata, docs and ratchet baselines --- apps/sim/blocks/blocks/kalshi.test.ts | 5 +-- apps/sim/blocks/blocks/ketch.test.ts | 5 +-- apps/sim/blocks/blocks/langsmith.test.ts | 5 +-- apps/sim/blocks/blocks/mintlify.test.ts | 7 ++-- apps/sim/blocks/blocks/netsuite.test.ts | 7 ++-- apps/sim/blocks/blocks/parallel.test.ts | 5 ++- scripts/check-explicit-any.baseline.json | 2 -- scripts/check-mapper-operation.baseline.json | 35 -------------------- 8 files changed, 23 insertions(+), 48 deletions(-) diff --git a/apps/sim/blocks/blocks/kalshi.test.ts b/apps/sim/blocks/blocks/kalshi.test.ts index ce22307fcd3..7fb92b3d852 100644 --- a/apps/sim/blocks/blocks/kalshi.test.ts +++ b/apps/sim/blocks/blocks/kalshi.test.ts @@ -1,9 +1,10 @@ import { describe, expect, it } from 'vitest' import { KalshiBlock } from '@/blocks/blocks/kalshi' -describe('KalshiBlock', () => { - const buildParams = KalshiBlock.tools.config.params! +const buildParams = KalshiBlock.tools.config?.params +if (!buildParams) throw new Error('KalshiBlock has no params mapper') +describe('KalshiBlock', () => { /** * An agent tool call passes the operation only in `context`; the order ID filled * on the tool row must still reach the tool's `orderId` param. diff --git a/apps/sim/blocks/blocks/ketch.test.ts b/apps/sim/blocks/blocks/ketch.test.ts index 199afb14115..03c6dbaae40 100644 --- a/apps/sim/blocks/blocks/ketch.test.ts +++ b/apps/sim/blocks/blocks/ketch.test.ts @@ -1,9 +1,10 @@ import { describe, expect, it } from 'vitest' import { KetchBlock } from '@/blocks/blocks/ketch' -describe('KetchBlock', () => { - const buildParams = KetchBlock.tools.config.params! +const buildParams = KetchBlock.tools.config?.params +if (!buildParams) throw new Error('KetchBlock has no params mapper') +describe('KetchBlock', () => { /** * An agent tool call passes the operation only in `context`; a purposes map the * model sends as JSON text must reach the tool as an object, like the canvas sends it. diff --git a/apps/sim/blocks/blocks/langsmith.test.ts b/apps/sim/blocks/blocks/langsmith.test.ts index fc8009ea405..9ae7ff9d66e 100644 --- a/apps/sim/blocks/blocks/langsmith.test.ts +++ b/apps/sim/blocks/blocks/langsmith.test.ts @@ -1,9 +1,10 @@ import { describe, expect, it } from 'vitest' import { LangsmithBlock } from '@/blocks/blocks/langsmith' -describe('LangsmithBlock', () => { - const buildParams = LangsmithBlock.tools.config.params! +const buildParams = LangsmithBlock.tools.config?.params +if (!buildParams) throw new Error('LangsmithBlock has no params mapper') +describe('LangsmithBlock', () => { /** * The model names the create-run outputs after the tool's `run_outputs` param, not the * block's `outputs` field; the mapper must not overwrite them with the empty field. diff --git a/apps/sim/blocks/blocks/mintlify.test.ts b/apps/sim/blocks/blocks/mintlify.test.ts index 7c15a199db0..a8c76f6e458 100644 --- a/apps/sim/blocks/blocks/mintlify.test.ts +++ b/apps/sim/blocks/blocks/mintlify.test.ts @@ -1,13 +1,16 @@ import { describe, expect, it } from 'vitest' import { MintlifyBlock } from '@/blocks/blocks/mintlify' +const blockParams = MintlifyBlock.tools.config?.params +if (!blockParams) throw new Error('MintlifyBlock has no params mapper') + /** * The executor merges `tools.config.params` on top of the raw inputs, so every * assertion runs against the merged result rather than the transform's return * value alone. */ function resolveParams(inputs: Record) { - return { ...inputs, ...MintlifyBlock.tools.config.params!(inputs) } + return { ...inputs, ...blockParams(inputs) } } describe('MintlifyBlock', () => { @@ -56,7 +59,7 @@ describe('MintlifyBlock', () => { const args = { projectId: 'proj_1', source: 'contextual', status: 'pending', limit: '50' } const result = { ...args, - ...MintlifyBlock.tools.config.params!(args, { operation: 'get_feedback' }), + ...blockParams(args, { operation: 'get_feedback' }), } expect(result).toEqual({ diff --git a/apps/sim/blocks/blocks/netsuite.test.ts b/apps/sim/blocks/blocks/netsuite.test.ts index 069ddac1127..5a4e6dc75af 100644 --- a/apps/sim/blocks/blocks/netsuite.test.ts +++ b/apps/sim/blocks/blocks/netsuite.test.ts @@ -1,12 +1,15 @@ import { describe, expect, it } from 'vitest' import { NetSuiteBlock } from '@/blocks/blocks/netsuite' +const blockParams = NetSuiteBlock.tools.config?.params +if (!blockParams) throw new Error('NetSuiteBlock has no params mapper') + describe('NetSuiteBlock', () => { it('parses a JSON body on an agent tool call, whose operation arrives only in context', () => { const args = { recordType: 'customer', body: '{"companyName":"Acme"}' } const result = { ...args, - ...NetSuiteBlock.tools.config.params!(args, { operation: 'netsuite_create_record' }), + ...blockParams(args, { operation: 'netsuite_create_record' }), } expect(result.body).toEqual({ companyName: 'Acme' }) @@ -16,7 +19,7 @@ describe('NetSuiteBlock', () => { const args = { jobId: '42', view: 'task', taskId: '7' } const result = { ...args, - ...NetSuiteBlock.tools.config.params!(args, { operation: 'netsuite_get_async_status' }), + ...blockParams(args, { operation: 'netsuite_get_async_status' }), } expect(result.taskId).toBe('7') diff --git a/apps/sim/blocks/blocks/parallel.test.ts b/apps/sim/blocks/blocks/parallel.test.ts index b4d756743b1..96e05a4e3da 100644 --- a/apps/sim/blocks/blocks/parallel.test.ts +++ b/apps/sim/blocks/blocks/parallel.test.ts @@ -1,12 +1,15 @@ import { describe, expect, it } from 'vitest' import { ParallelBlock } from '@/blocks/blocks/parallel' +const blockParams = ParallelBlock.tools.config?.params +if (!blockParams) throw new Error('ParallelBlock has no params mapper') + describe('ParallelBlock', () => { it('maps an agent search call, whose operation arrives only in context', () => { const args = { objective: 'When was the UN founded?', include_domains: 'un.org' } const result = { ...args, - ...ParallelBlock.tools.config.params!(args, { operation: 'search' }), + ...blockParams(args, { operation: 'search' }), } expect(result.search_queries).toBe('When was the UN founded?') diff --git a/scripts/check-explicit-any.baseline.json b/scripts/check-explicit-any.baseline.json index 02ee28b9eea..ecbcf04bfd6 100644 --- a/scripts/check-explicit-any.baseline.json +++ b/scripts/check-explicit-any.baseline.json @@ -114,7 +114,6 @@ "apps/sim/blocks/blocks/sharepoint.ts": 5, "apps/sim/blocks/blocks/slack.ts": 1, "apps/sim/blocks/blocks/sportmonks.ts": 1, - "apps/sim/blocks/blocks/stripe.ts": 6, "apps/sim/blocks/blocks/tinybird.ts": 1, "apps/sim/blocks/blocks/translate.ts": 2, "apps/sim/blocks/blocks/zep.ts": 3, @@ -1220,7 +1219,6 @@ "apps/sim/blocks/blocks/logs.test.ts": 4, "apps/sim/blocks/blocks/mem0.test.ts": 1, "apps/sim/blocks/blocks/microsoft_ad.test.ts": 1, - "apps/sim/blocks/blocks/mintlify.test.ts": 1, "apps/sim/blocks/blocks/modal.test.ts": 2, "apps/sim/blocks/blocks/mssql.test.ts": 1, "apps/sim/blocks/blocks/slack-resources.test.ts": 4, diff --git a/scripts/check-mapper-operation.baseline.json b/scripts/check-mapper-operation.baseline.json index 0511f7e9d5b..37b5936fd30 100644 --- a/scripts/check-mapper-operation.baseline.json +++ b/scripts/check-mapper-operation.baseline.json @@ -55,20 +55,10 @@ "apps/sim/blocks/blocks/instantly.ts": 17, "apps/sim/blocks/blocks/jira.ts": 1, "apps/sim/blocks/blocks/jira_service_management.ts": 1, - "apps/sim/blocks/blocks/jotform.ts": 1, - "apps/sim/blocks/blocks/kalshi.ts": 1, - "apps/sim/blocks/blocks/ketch.ts": 4, "apps/sim/blocks/blocks/knowledge.ts": 11, - "apps/sim/blocks/blocks/langsmith.ts": 4, "apps/sim/blocks/blocks/latex.ts": 1, - "apps/sim/blocks/blocks/launchdarkly.ts": 1, "apps/sim/blocks/blocks/linear.ts": 1, - "apps/sim/blocks/blocks/linkedin.ts": 1, - "apps/sim/blocks/blocks/linq.ts": 2, "apps/sim/blocks/blocks/logs.ts": 2, - "apps/sim/blocks/blocks/loops.ts": 1, - "apps/sim/blocks/blocks/manageengine-sdp.ts": 2, - "apps/sim/blocks/blocks/mem0.ts": 1, "apps/sim/blocks/blocks/memory.ts": 8, "apps/sim/blocks/blocks/microsoft_ad.ts": 9, "apps/sim/blocks/blocks/microsoft_dataverse.ts": 1, @@ -77,42 +67,17 @@ "apps/sim/blocks/blocks/microsoft_planner.ts": 1, "apps/sim/blocks/blocks/microsoft_teams.ts": 1, "apps/sim/blocks/blocks/microsoft_word.ts": 1, - "apps/sim/blocks/blocks/mintlify.ts": 1, - "apps/sim/blocks/blocks/netsuite.ts": 2, "apps/sim/blocks/blocks/okta.ts": 2, "apps/sim/blocks/blocks/onedrive.ts": 3, - "apps/sim/blocks/blocks/otter.ts": 1, "apps/sim/blocks/blocks/outlook.ts": 17, "apps/sim/blocks/blocks/pagerduty.ts": 1, - "apps/sim/blocks/blocks/parallel.ts": 1, - "apps/sim/blocks/blocks/peopledatalabs.ts": 1, - "apps/sim/blocks/blocks/perplexity.ts": 1, - "apps/sim/blocks/blocks/persona.ts": 1, - "apps/sim/blocks/blocks/pitchbook.ts": 1, - "apps/sim/blocks/blocks/plane.ts": 1, - "apps/sim/blocks/blocks/polymarket.ts": 1, - "apps/sim/blocks/blocks/powerbi.ts": 1, - "apps/sim/blocks/blocks/profound.ts": 1, - "apps/sim/blocks/blocks/reddit.ts": 1, - "apps/sim/blocks/blocks/revenuecat.ts": 2, "apps/sim/blocks/blocks/rippling.ts": 1, - "apps/sim/blocks/blocks/rocketlane.ts": 1, - "apps/sim/blocks/blocks/rootly.ts": 1, "apps/sim/blocks/blocks/sailpoint.ts": 1, - "apps/sim/blocks/blocks/sendblue.ts": 1, "apps/sim/blocks/blocks/sharepoint.ts": 6, - "apps/sim/blocks/blocks/sixtyfour.ts": 4, "apps/sim/blocks/blocks/slack.ts": 6, - "apps/sim/blocks/blocks/smartlead.ts": 5, "apps/sim/blocks/blocks/snowflake.ts": 1, - "apps/sim/blocks/blocks/stripe.ts": 1, "apps/sim/blocks/blocks/table.ts": 1, "apps/sim/blocks/blocks/table_v2.ts": 1, - "apps/sim/blocks/blocks/tiktok.ts": 1, "apps/sim/blocks/blocks/trello.ts": 1, - "apps/sim/blocks/blocks/vanta.ts": 1, - "apps/sim/blocks/blocks/wealthbox.ts": 1, - "apps/sim/blocks/blocks/zendesk.ts": 1, - "apps/sim/blocks/blocks/zep.ts": 1, "apps/sim/blocks/blocks/zoho-desk.ts": 38 } From ec0a631fd17662b4067b00d1cebfacb4f4282851 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 15 Nov 2026 17:01:36 -0800 Subject: [PATCH 3/6] refactor: simplify and clean up the sweep changes --- apps/sim/blocks/blocks/netsuite.ts | 16 ++++++---------- apps/sim/blocks/blocks/perplexity.ts | 22 ++++++++++------------ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/apps/sim/blocks/blocks/netsuite.ts b/apps/sim/blocks/blocks/netsuite.ts index b339e22c845..d4048b05e56 100644 --- a/apps/sim/blocks/blocks/netsuite.ts +++ b/apps/sim/blocks/blocks/netsuite.ts @@ -95,10 +95,6 @@ const BATCH_WRITE_OPERATIONS = [ 'netsuite_batch_upsert_records', ] -function usesOperation(operation: string, operations: readonly string[]): boolean { - return operations.includes(operation) -} - function optionalBoolean(value: unknown): boolean | undefined { if (value === true || value === 'true') return true if (value === false || value === 'false') return false @@ -856,24 +852,24 @@ Return ONLY the SuiteQL query - no explanations, no markdown, no extra text.`, : undefined return { ...rest, - body: usesOperation(operation, BODY_OPERATIONS) + body: BODY_OPERATIONS.includes(operation) ? parseJson(rest.body, 'Record fields') : undefined, - items: usesOperation(operation, BATCH_WRITE_OPERATIONS) + items: BATCH_WRITE_OPERATIONS.includes(operation) ? parseJson(rest.items, 'Records') : undefined, - limit: usesOperation(operation, PAGING_OPERATIONS) + limit: PAGING_OPERATIONS.includes(operation) ? parseOptionalNumberInput(rest.limit, 'Limit', { integer: true, min: 1, max: 1_000, }) : undefined, - offset: usesOperation(operation, PAGING_OPERATIONS) + offset: PAGING_OPERATIONS.includes(operation) ? parseOptionalNumberInput(rest.offset, 'Offset', { integer: true, min: 0 }) : undefined, - expand: usesOperation(operation, RECORD_QUERY_OPERATIONS) ? rest.expand : undefined, - expandSubResources: usesOperation(operation, RECORD_QUERY_OPERATIONS) + expand: RECORD_QUERY_OPERATIONS.includes(operation) ? rest.expand : undefined, + expandSubResources: RECORD_QUERY_OPERATIONS.includes(operation) ? optionalBoolean(rest.expandSubResources) : undefined, roleId: diff --git a/apps/sim/blocks/blocks/perplexity.ts b/apps/sim/blocks/blocks/perplexity.ts index 07ce3d8f732..5e35b3e2711 100644 --- a/apps/sim/blocks/blocks/perplexity.ts +++ b/apps/sim/blocks/blocks/perplexity.ts @@ -206,17 +206,13 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n params: (params, context) => { if (mapperOperation(params, context) === 'perplexity_search') { // The block takes a comma-separated string; a tool call already sends an array. - let domainFilter: string[] | undefined - if (params.search_domain_filter && typeof params.search_domain_filter === 'string') { - domainFilter = params.search_domain_filter - .split(',') - .map((d) => d.trim()) - .filter((d) => d.length > 0) - } else if (Array.isArray(params.search_domain_filter)) { - domainFilter = params.search_domain_filter - .map((d) => String(d).trim()) - .filter((d) => d.length > 0) - } + const rawDomains: unknown[] | undefined = + params.search_domain_filter && typeof params.search_domain_filter === 'string' + ? params.search_domain_filter.split(',') + : Array.isArray(params.search_domain_filter) + ? params.search_domain_filter + : undefined + const domainFilter = rawDomains?.map((d) => String(d).trim()).filter((d) => d.length > 0) const searchParams = { apiKey: params.apiKey, @@ -244,7 +240,9 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n max_tokens: params.max_tokens ? Number.parseInt(params.max_tokens) : undefined, temperature: params.temperature ? Number.parseFloat(params.temperature) - : toolCallArg(context, params.temperature === 0 ? 0 : undefined), + : params.temperature === 0 + ? toolCallArg(context, 0) + : undefined, } return chatParams From 24de74f56de7ac0a63bbc7bcda1dded24a98970c Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 15 Nov 2026 17:04:48 -0800 Subject: [PATCH 4/6] fix(blocks): type the sweep2 m4 mapper tests and stripe JSON spreads for test-types --- apps/sim/blocks/blocks/jotform.test.ts | 2 +- apps/sim/blocks/blocks/kalshi.test.ts | 2 +- apps/sim/blocks/blocks/mintlify.test.ts | 5 +++-- apps/sim/blocks/blocks/parallel.test.ts | 5 ++++- apps/sim/blocks/blocks/stripe.ts | 10 +++++----- scripts/check-test-types.baseline.json | 3 --- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/apps/sim/blocks/blocks/jotform.test.ts b/apps/sim/blocks/blocks/jotform.test.ts index 632f9636056..da3a395a959 100644 --- a/apps/sim/blocks/blocks/jotform.test.ts +++ b/apps/sim/blocks/blocks/jotform.test.ts @@ -31,7 +31,7 @@ describe('JotformBlock', () => { * on the tool row must still reach the tool's `title` param. */ it('maps tool-row fields on an agent tool call', () => { - const args = { apiKey: 'key', formId: '2315', reportTitle: 'Weekly' } + const args: Record = { apiKey: 'key', formId: '2315', reportTitle: 'Weekly' } expect({ ...args, ...buildParams(args, { operation: 'create_report' }) }.title).toBe('Weekly') }) diff --git a/apps/sim/blocks/blocks/kalshi.test.ts b/apps/sim/blocks/blocks/kalshi.test.ts index 7fb92b3d852..cdda31845f1 100644 --- a/apps/sim/blocks/blocks/kalshi.test.ts +++ b/apps/sim/blocks/blocks/kalshi.test.ts @@ -10,7 +10,7 @@ describe('KalshiBlock', () => { * on the tool row must still reach the tool's `orderId` param. */ it('maps the order ID field on an agent tool call', () => { - const args = { keyId: 'key', privateKey: 'pem', orderIdParam: 'ord-1' } + const args: Record = { keyId: 'key', privateKey: 'pem', orderIdParam: 'ord-1' } expect({ ...args, ...buildParams(args, { operation: 'cancel_order' }) }.orderId).toBe('ord-1') }) diff --git a/apps/sim/blocks/blocks/mintlify.test.ts b/apps/sim/blocks/blocks/mintlify.test.ts index a8c76f6e458..4d6eefaf63c 100644 --- a/apps/sim/blocks/blocks/mintlify.test.ts +++ b/apps/sim/blocks/blocks/mintlify.test.ts @@ -1,8 +1,9 @@ import { describe, expect, it } from 'vitest' import { MintlifyBlock } from '@/blocks/blocks/mintlify' -const blockParams = MintlifyBlock.tools.config?.params -if (!blockParams) throw new Error('MintlifyBlock has no params mapper') +const mapper = MintlifyBlock.tools.config?.params +if (!mapper) throw new Error('MintlifyBlock has no params mapper') +const blockParams = mapper /** * The executor merges `tools.config.params` on top of the raw inputs, so every diff --git a/apps/sim/blocks/blocks/parallel.test.ts b/apps/sim/blocks/blocks/parallel.test.ts index 96e05a4e3da..2fe1530b226 100644 --- a/apps/sim/blocks/blocks/parallel.test.ts +++ b/apps/sim/blocks/blocks/parallel.test.ts @@ -6,7 +6,10 @@ if (!blockParams) throw new Error('ParallelBlock has no params mapper') describe('ParallelBlock', () => { it('maps an agent search call, whose operation arrives only in context', () => { - const args = { objective: 'When was the UN founded?', include_domains: 'un.org' } + const args: Record = { + objective: 'When was the UN founded?', + include_domains: 'un.org', + } const result = { ...args, ...blockParams(args, { operation: 'search' }), diff --git a/apps/sim/blocks/blocks/stripe.ts b/apps/sim/blocks/blocks/stripe.ts index 481d2da3957..60e3958738f 100644 --- a/apps/sim/blocks/blocks/stripe.ts +++ b/apps/sim/blocks/blocks/stripe.ts @@ -1006,11 +1006,11 @@ export const StripeBlock: BlockConfig = { return { apiKey, ...rest, - ...(parsedAddress && { address: parsedAddress }), - ...(parsedMetadata && { metadata: parsedMetadata }), - ...(parsedItems && { items: parsedItems }), - ...(parsedImages && { images: parsedImages }), - ...(parsedRecurring && { recurring: parsedRecurring }), + ...(parsedAddress ? { address: parsedAddress } : {}), + ...(parsedMetadata ? { metadata: parsedMetadata } : {}), + ...(parsedItems ? { items: parsedItems } : {}), + ...(parsedImages ? { images: parsedImages } : {}), + ...(parsedRecurring ? { recurring: parsedRecurring } : {}), ...parsedBooleans, ...pagination, } diff --git a/scripts/check-test-types.baseline.json b/scripts/check-test-types.baseline.json index 36e295e7ee2..663c4079ee1 100644 --- a/scripts/check-test-types.baseline.json +++ b/scripts/check-test-types.baseline.json @@ -652,9 +652,6 @@ "apps/sim/blocks/blocks/mem0.test.ts": { "TS18048": 1 }, - "apps/sim/blocks/blocks/mintlify.test.ts": { - "TS18048": 1 - }, "apps/sim/blocks/blocks/mssql.test.ts": { "TS18048": 1, "TS2339": 2 From 2e466efdeb50e3beac2eb0ef358e39a6578ceaf4 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 15 Nov 2026 17:15:34 -0800 Subject: [PATCH 5/6] fix(rocketlane): send only the saved time source when a tool call also names another --- apps/sim/blocks/blocks/rocketlane.test.ts | 17 +++++++++++++ apps/sim/blocks/blocks/rocketlane.ts | 31 +++++++++++++---------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/apps/sim/blocks/blocks/rocketlane.test.ts b/apps/sim/blocks/blocks/rocketlane.test.ts index db8a7ca70ee..87f444feab4 100644 --- a/apps/sim/blocks/blocks/rocketlane.test.ts +++ b/apps/sim/blocks/blocks/rocketlane.test.ts @@ -18,6 +18,23 @@ describe('RocketlaneBlock agent tool calls', () => { expect(result).toMatchObject({ date: '2026-11-15', minutes: 30, projectId: 101 }) expect(result.taskId).toBeUndefined() }) + + it('sends only the saved time source when the model also names a different one', () => { + const result = resolveToolCall( + { + apiKey: 'key', + date: '2026-11-15', + minutes: '30', + timeEntrySource: 'task', + timeEntryTaskId: '42', + projectId: '101', + }, + 'create_time_entry' + ) + + expect(result).toMatchObject({ taskId: 42 }) + expect(result.projectId).toBeUndefined() + }) }) describe('RocketlaneBlock canvas mapping', () => { diff --git a/apps/sim/blocks/blocks/rocketlane.ts b/apps/sim/blocks/blocks/rocketlane.ts index 8e87be794a1..18f9535fe96 100644 --- a/apps/sim/blocks/blocks/rocketlane.ts +++ b/apps/sim/blocks/blocks/rocketlane.ts @@ -593,22 +593,27 @@ function buildOperationParams( case 'create_time_entry': { const source = params.timeEntrySource ?? 'task' + // Exactly one time source may be sent. A saved source is used alone; only when none is + // saved does a tool call fall back to the sources the model passed under the tool names. + const savedSource = { + activityName: source === 'activity' ? toStr(params.timeEntryActivityName) : undefined, + taskId: source === 'task' ? toNumber(params.timeEntryTaskId) : undefined, + projectPhaseId: source === 'phase' ? toNumber(params.timeEntryPhaseId) : undefined, + projectId: source === 'project' ? toNumber(params.timeEntryProjectId) : undefined, + } + const hasSavedSource = Object.values(savedSource).some((value) => value !== undefined) + const timeSource = hasSavedSource + ? savedSource + : { + activityName: toolCallArg(context, toStr(params.activityName)), + taskId: toolCallArg(context, toNumber(params.taskId)), + projectPhaseId: toolCallArg(context, toNumber(params.projectPhaseId)), + projectId: toolCallArg(context, toNumber(params.projectId)), + } return { date: toStr(params.date), minutes: toNumber(params.minutes), - // Exactly one time source may be sent — pass only the selected one. - activityName: - (source === 'activity' ? toStr(params.timeEntryActivityName) : undefined) ?? - toolCallArg(context, toStr(params.activityName)), - taskId: - (source === 'task' ? toNumber(params.timeEntryTaskId) : undefined) ?? - toolCallArg(context, toNumber(params.taskId)), - projectPhaseId: - (source === 'phase' ? toNumber(params.timeEntryPhaseId) : undefined) ?? - toolCallArg(context, toNumber(params.projectPhaseId)), - projectId: - (source === 'project' ? toNumber(params.timeEntryProjectId) : undefined) ?? - toolCallArg(context, toNumber(params.projectId)), + ...timeSource, billable: toBool(params.billable), userId: toNumber(params.userId), userEmail: toStr(params.userEmail), From 3e19ee535c4041be412280ddee32fe0331f2e245 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sun, 15 Nov 2026 19:23:48 -0800 Subject: [PATCH 6/6] chore: regenerate tool metadata and mapper baseline after merging staging --- scripts/check-mapper-operation.baseline.json | 35 -------------------- 1 file changed, 35 deletions(-) diff --git a/scripts/check-mapper-operation.baseline.json b/scripts/check-mapper-operation.baseline.json index f6d8c547a3c..c11a521de81 100644 --- a/scripts/check-mapper-operation.baseline.json +++ b/scripts/check-mapper-operation.baseline.json @@ -1,43 +1,8 @@ { - "apps/sim/blocks/blocks/jotform.ts": 1, - "apps/sim/blocks/blocks/kalshi.ts": 1, - "apps/sim/blocks/blocks/ketch.ts": 4, - "apps/sim/blocks/blocks/langsmith.ts": 4, - "apps/sim/blocks/blocks/launchdarkly.ts": 1, - "apps/sim/blocks/blocks/linkedin.ts": 1, - "apps/sim/blocks/blocks/linq.ts": 2, - "apps/sim/blocks/blocks/loops.ts": 1, - "apps/sim/blocks/blocks/manageengine-sdp.ts": 2, - "apps/sim/blocks/blocks/mem0.ts": 1, "apps/sim/blocks/blocks/microsoft_dynamics_365.ts": 2, - "apps/sim/blocks/blocks/mintlify.ts": 1, - "apps/sim/blocks/blocks/netsuite.ts": 2, "apps/sim/blocks/blocks/okta.ts": 2, - "apps/sim/blocks/blocks/otter.ts": 1, - "apps/sim/blocks/blocks/parallel.ts": 1, - "apps/sim/blocks/blocks/peopledatalabs.ts": 1, - "apps/sim/blocks/blocks/perplexity.ts": 1, - "apps/sim/blocks/blocks/persona.ts": 1, - "apps/sim/blocks/blocks/pitchbook.ts": 1, - "apps/sim/blocks/blocks/plane.ts": 1, - "apps/sim/blocks/blocks/polymarket.ts": 1, - "apps/sim/blocks/blocks/powerbi.ts": 1, - "apps/sim/blocks/blocks/profound.ts": 1, - "apps/sim/blocks/blocks/reddit.ts": 1, - "apps/sim/blocks/blocks/revenuecat.ts": 2, "apps/sim/blocks/blocks/rippling.ts": 1, - "apps/sim/blocks/blocks/rocketlane.ts": 1, - "apps/sim/blocks/blocks/rootly.ts": 1, "apps/sim/blocks/blocks/sailpoint.ts": 1, - "apps/sim/blocks/blocks/sendblue.ts": 1, - "apps/sim/blocks/blocks/sixtyfour.ts": 4, - "apps/sim/blocks/blocks/smartlead.ts": 5, "apps/sim/blocks/blocks/snowflake.ts": 1, - "apps/sim/blocks/blocks/stripe.ts": 1, - "apps/sim/blocks/blocks/tiktok.ts": 1, - "apps/sim/blocks/blocks/vanta.ts": 1, - "apps/sim/blocks/blocks/wealthbox.ts": 1, - "apps/sim/blocks/blocks/zendesk.ts": 1, - "apps/sim/blocks/blocks/zep.ts": 1, "apps/sim/blocks/blocks/zoho-desk.ts": 38 }