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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/airtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AirtableIcon } from '@/components/icons'
import { getScopesForService } from '@/lib/oauth/utils'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { toolCallArg } from '@/blocks/utils'
import { mapperOperation, toolCallArg } from '@/blocks/utils'
import { getTrigger } from '@/triggers'

/** Canonical account pair — an advanced-mode card only fills `manualCredential`. */
Expand Down Expand Up @@ -429,7 +429,7 @@ Return ONLY the valid JSON array of record ID strings - no explanations, no mark
...rest
} = params
/** Agent tool calls carry the stored operation only on `context`, not in `params`. */
const operation = params.operation ?? context?.operation
const operation = mapperOperation(params, context)
let parsedRecords: unknown
let parsedFields: unknown
let parsedFieldsToMergeOn: unknown
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/asana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AsanaIcon } from '@/components/icons'
import { getScopesForService } from '@/lib/oauth/utils'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { toolCallArg } from '@/blocks/utils'
import { mapperOperation, toolCallArg } from '@/blocks/utils'

const WORKSPACE_FIELD = ['workspaceSelector', 'workspace'] as const
const GET_TASKS_WORKSPACE_FIELD = ['getTasksWorkspaceSelector', 'getTasks_workspace'] as const
Expand Down Expand Up @@ -521,7 +521,7 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
params: (params, context) => {
const { oauthCredential } = params
/** Agent tool calls carry the stored operation only on `context`, not in `params`. */
const operation = params.operation ?? context?.operation
const operation = mapperOperation(params, context)

const splitGids = (value: unknown): string[] | undefined => {
if (Array.isArray(value)) return value.map(String)
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/blocks/blocks/attio.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AttioIcon } 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'

/*
Expand Down Expand Up @@ -1613,7 +1614,7 @@ Record reference: {"allowed_objects": ["people", "companies"]}`,
const cleanParams: Record<string, unknown> = {
oauthCredential: params.oauthCredential,
}
const op = params.operation ?? context?.operation
const op = mapperOperation(params, context)

// Record params — each field is only sent for the operations whose subBlock condition
// actually exposes it, so a stale value left over from switching operations never leaks
Expand Down
6 changes: 3 additions & 3 deletions apps/sim/blocks/blocks/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BoxCompanyIcon } from '@/components/icons'
import { getScopesForService } from '@/lib/oauth/utils'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { normalizeFileInput, toolCallArg } from '@/blocks/utils'
import { mapperOperation, normalizeFileInput, toolCallArg } from '@/blocks/utils'

/** Canonical pair for the upload payload: file picker in basic mode, file reference in advanced. */
const UPLOAD_FILE_FIELD = ['uploadFile', 'fileRef'] as const
Expand Down Expand Up @@ -534,8 +534,8 @@ export const BoxBlock = {
if (normalizedFile) {
params.file = normalizedFile
}
const { credential, operation: storedOperation, ...rest } = params
const operation = storedOperation ?? context?.operation
const { credential, ...rest } = params
const operation = mapperOperation(params, context)

const baseParams: Record<string, unknown> = {
accessToken: credential,
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/blocks/blocks/clickup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import {
isToolCall,
mapperOperation,
normalizeFileInput,
parseOptionalBooleanInput,
toolCallArg,
Expand Down Expand Up @@ -1479,7 +1480,7 @@ Return ONLY the value (plain string, number, or JSON) - no explanations, no extr
params: (params, context) => {
const { oauthCredential } = params
/** Agent tool calls carry the stored operation only on `context`, not in `params`. */
const operation = params.operation ?? context?.operation
const operation = mapperOperation(params, context)

const baseParams = {
accessToken: oauthCredential?.accessToken,
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/dropbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DropboxIcon } from '@/components/icons'
import { getScopesForService } from '@/lib/oauth/utils'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { normalizeFileInput, toolCallArg } from '@/blocks/utils'
import { mapperOperation, normalizeFileInput, toolCallArg } from '@/blocks/utils'

/*
* Canonical basic/advanced pair for the upload source, shared by the card
Expand Down Expand Up @@ -483,7 +483,7 @@ Return ONLY the timestamp string - no explanations, no quotes, no extra text.`,
},
params: (params, context) => {
const result: Record<string, unknown> = {}
const operation = params.operation ?? context?.operation
const operation = mapperOperation(params, context)
// `cursor` is List Shared Links' field; List Folder and Search page with their own
if (operation === 'dropbox_list_folder') {
result.cursor = params.listFolderCursor || toolCallArg(context, params.cursor)
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/blocks/blocks/gauge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GaugeIcon } from '@/components/icons'
import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types'
import { mapperOperation } from '@/blocks/utils'

export const GaugeBlock: BlockConfig = {
type: 'gauge',
Expand Down Expand Up @@ -972,7 +973,7 @@ export const GaugeBlock: BlockConfig = {
config: {
tool: (params) => params.operation,
params: (params, context) => {
const operation = context?.operation ?? params.operation
const operation = mapperOperation(params, context)
Comment thread
waleedlatif1 marked this conversation as resolved.
Resolved
const patch = ['gauge_bulk_update_prompts', 'gauge_update_prompt'].includes(operation)
return {
...params,
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/higgsfield.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HiggsfieldIcon } from '@/components/icons'
import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types'
import { parseOptionalNumberInput } from '@/blocks/utils'
import { mapperOperation, parseOptionalNumberInput } from '@/blocks/utils'

const GENERATE_OPERATIONS = ['higgsfield_generate', 'higgsfield_generate_soul_image']
const REQUEST_OPERATIONS = [
Expand Down Expand Up @@ -315,7 +315,7 @@ export const HiggsfieldBlock: BlockConfig = {
config: {
tool: (params) => params.operation,
params: (params, context) => {
const operation = context?.operation ?? params.operation
const operation = mapperOperation(params, context)
const isSoul = operation === SOUL
const isGenerate = GENERATE_OPERATIONS.includes(operation)
const isList = operation === 'higgsfield_list_characters'
Expand Down
5 changes: 2 additions & 3 deletions apps/sim/blocks/blocks/hubspot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HubspotIcon } from '@/components/icons'
import { getScopesForService } from '@/lib/oauth/utils'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { toolCallArg } from '@/blocks/utils'
import { mapperOperation, toolCallArg } from '@/blocks/utils'
import { getTrigger } from '@/triggers'

export const HubSpotBlock: BlockConfig = {
Expand Down Expand Up @@ -1635,7 +1635,6 @@ Return ONLY the JSON array of property names - no explanations, no markdown, no
params: (params, context) => {
const {
oauthCredential,
operation: storedOperation,
propertiesToSet,
properties,
searchProperties,
Expand All @@ -1647,7 +1646,7 @@ Return ONLY the JSON array of property names - no explanations, no markdown, no
archived,
...rest
} = params
const operation = storedOperation ?? context?.operation
const operation = mapperOperation(params, context)

const cleanParams: Record<string, any> = {
oauthCredential,
Expand Down
10 changes: 7 additions & 3 deletions apps/sim/blocks/blocks/intercom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { toBooleanFromInput } from '@sim/utils/coerce'
import { IntercomIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { createVersionedToolSelector, toolCallArg, withSavedCredential } from '@/blocks/utils'
import {
createVersionedToolSelector,
mapperOperation,
toolCallArg,
withSavedCredential,
} from '@/blocks/utils'
import { getTrigger } from '@/triggers'

/**
Expand Down Expand Up @@ -38,7 +43,6 @@ type IntercomParamsMapper = NonNullable<NonNullable<BlockConfig['tools']['config
/** Maps Intercom block fields to tool params; shared by every Intercom block version. */
const mapIntercomParams: IntercomParamsMapper = (params, context) => {
const {
operation: storedOperation,
message_type_msg,
company_name,
contact_company_id,
Expand Down Expand Up @@ -68,7 +72,7 @@ const mapIntercomParams: IntercomParamsMapper = (params, context) => {
event_created_at,
...rest
} = params
const operation = storedOperation ?? context?.operation
const operation = mapperOperation(params, context)
Comment thread
waleedlatif1 marked this conversation as resolved.
Resolved
const cleanParams: Record<string, any> = {}

if (operation === 'create_message' && message_type_msg) {
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/blocks/blocks/monaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { toBooleanFromInput } from '@sim/utils/coerce'
import { MonacoIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { mapperOperation } from '@/blocks/utils'

type FieldKind = 'string' | 'number' | 'boolean' | 'value'

Expand Down Expand Up @@ -1431,7 +1432,7 @@ export const MonacoBlock: BlockConfig = {
* subBlock has a different id falls back to the model's value.
*/
params: (params, context) => {
const operation = context?.operation ?? params.operation
const operation = mapperOperation(params, context)
const result: Record<string, unknown> = {
operation: undefined,
credential: undefined,
Expand Down
6 changes: 2 additions & 4 deletions apps/sim/blocks/blocks/monday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MondayIcon } from '@/components/icons'
import { getScopesForService } from '@/lib/oauth/utils'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { toolCallArg } from '@/blocks/utils'
import { mapperOperation, toolCallArg } from '@/blocks/utils'
import { getTrigger } from '@/triggers'

const BOARD_OPS = [
Expand Down Expand Up @@ -525,9 +525,7 @@ export const MondayBlock: BlockConfig = {
const baseParams: Record<string, unknown> = {
oauthCredential: params.oauthCredential,
}
/** Agent tool calls carry the stored operation only on `context`, not in `params`. */
const rawOperation = params.operation ?? context?.operation
const op = typeof rawOperation === 'string' ? rawOperation.trim() : 'list_boards'
const op = mapperOperation(params, context).trim() || 'list_boards'

switch (op) {
case 'list_boards':
Expand Down
9 changes: 6 additions & 3 deletions apps/sim/blocks/blocks/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { toError } from '@sim/utils/errors'
import { NotionIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { createVersionedToolSelector, parseOptionalJsonInput } from '@/blocks/utils'
import {
createVersionedToolSelector,
mapperOperation,
parseOptionalJsonInput,
} from '@/blocks/utils'
import { getTrigger } from '@/triggers'

/**
Expand Down Expand Up @@ -625,7 +629,6 @@ export const NotionBlock: BlockConfig = {
params: (params, context) => {
const {
oauthCredential,
operation: storedOperation,
properties,
filter,
sorts,
Expand All @@ -637,7 +640,7 @@ export const NotionBlock: BlockConfig = {
commentContent,
...rest
} = params
const operation = storedOperation ?? context?.operation
const operation = mapperOperation(params, context)

// Parse properties from JSON string for create/add operations
let parsedProperties
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/quickbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { QuickBooksIcon } from '@/components/icons'
import { getScopesForService } from '@/lib/oauth/utils'
import type { BlockConfig, BlockMeta, OutputCondition, SubBlockConfig } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { normalizeFileInput, toolCallArg } from '@/blocks/utils'
import { mapperOperation, normalizeFileInput, toolCallArg } from '@/blocks/utils'
import {
getQuickBooksReportTypesSupporting,
type QuickBooksReportControl,
Expand Down Expand Up @@ -2526,7 +2526,7 @@ export const QuickBooksBlock: BlockConfig = {
return operation
},
params: (params, context) => {
const operation = String(params.operation ?? context?.operation)
const operation = mapperOperation(params, context)
const oauthCredentialValue = params.oauthCredential
/**
* Resolves a tool param filled by a differently-named subBlock. On an agent tool call
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/sap_concur.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SapConcurIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { normalizeFileInput, toolCallArg } from '@/blocks/utils'
import { mapperOperation, normalizeFileInput, toolCallArg } from '@/blocks/utils'
import type { UserFileLike } from '@/tools/sap_concur/types'

const toBool = (v: unknown): boolean | undefined => {
Expand Down Expand Up @@ -2030,7 +2030,7 @@ Return ONLY the JSON object - no explanations, no extra text.`,
config: {
tool: (params) => params.operation,
params: (params, context) => {
const operation = params.operation ?? context?.operation
const operation = mapperOperation(params, context)
const auth = {
datacenter: params.datacenter || undefined,
grantType: params.grantType || undefined,
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/blocks/blocks/sap_s4hana.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SapS4HanaIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta, CanvasSentence } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { isToolCall } from '@/blocks/utils'
import { isToolCall, mapperOperation } from '@/blocks/utils'

/**
* Whichever name a new business partner carries: an organization has
Expand Down Expand Up @@ -1048,7 +1048,7 @@ Return ONLY the JSON array - no explanations, no extra text.`,
tool: (params) => params.operation,
params: (params, context) => {
/** Agent tool calls carry the stored operation only on `context`, not in `params`. */
const operation = params.operation ?? context?.operation
const operation = mapperOperation(params, context)
/**
* A differently named sub-block feeds each tool param below. On a tool call the model's
* arg arrives under the tool param name, so a blank sub-block falls back to it.
Expand Down
11 changes: 8 additions & 3 deletions apps/sim/blocks/blocks/servicenow.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { ServiceNowIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta, BlockToolParamsContext } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { isToolCall, normalizeFileInput, toolCallArg, withSavedCredential } from '@/blocks/utils'
import {
isToolCall,
mapperOperation,
normalizeFileInput,
toolCallArg,
withSavedCredential,
} from '@/blocks/utils'
import {
APPROVAL_DECISION_OPTIONS,
APPROVAL_STATE,
Expand Down Expand Up @@ -1624,7 +1630,6 @@ Output: {"state": "2", "assigned_to": "john.doe", "work_notes": "Assigned and st
tool: (params) => params.operation,
params: (params, context?: BlockToolParamsContext) => {
const {
operation: storedOperation,
fields,
readFields,
returnFields,
Expand All @@ -1644,7 +1649,7 @@ Output: {"state": "2", "assigned_to": "john.doe", "work_notes": "Assigned and st
knowledgeQuery,
...rest
} = params
const operation = context?.operation ?? storedOperation
const operation = mapperOperation(params, context)
/**
* A dedicated subblock's value, or on a tool call where it is blank, the
* model's arg under the tool param name. Without a model arg the subblock
Expand Down
13 changes: 3 additions & 10 deletions apps/sim/blocks/blocks/workday.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { WorkdayIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { IntegrationType } from '@/blocks/types'
import { mapperOperation } from '@/blocks/utils'

export const WorkdayBlock: BlockConfig = {
type: 'workday',
Expand Down Expand Up @@ -409,17 +410,9 @@ Output: {"Marital_Status_Reference":{"ID":{"attributes":{"wd:type":"Marital_Stat
config: {
tool: (params) => `workday_${params.operation}`,
params: (params, context) => {
const {
operation: storedOperation,
orgType,
fields,
jobProfileId,
locationId,
supervisoryOrgId,
...rest
} = params
const { orgType, fields, jobProfileId, locationId, supervisoryOrgId, ...rest } = params
/** Agent tool calls carry the stored operation only on `context`, not in `params`. */
const operation = storedOperation ?? context?.operation
const operation = mapperOperation(params, context)

if (rest.limit != null && rest.limit !== '') rest.limit = Number(rest.limit)
if (rest.offset != null && rest.offset !== '') rest.offset = Number(rest.offset)
Expand Down
Loading
Loading