fix(executor/function): fix resolution of tag inputs to function block

This commit is contained in:
Waleed Latif
2025-03-04 13:38:09 -08:00
parent fd08e7e5eb
commit 6e7c34992b
3 changed files with 37 additions and 4 deletions
+19 -4
View File
@@ -2,7 +2,21 @@ import { ConditionalIcon } from '@/components/icons'
import { CodeExecutionOutput } from '@/tools/function/execute'
import { BlockConfig } from '../types'
export const ConditionBlock: BlockConfig<CodeExecutionOutput> = {
interface ConditionBlockOutput {
success: boolean
output: {
content: string
conditionResult: boolean
selectedPath: {
blockId: string
blockType: string
blockTitle: string
}
selectedConditionId: string
}
}
export const ConditionBlock: BlockConfig<ConditionBlockOutput> = {
type: 'condition',
name: 'Condition',
description: 'Add a condition',
@@ -26,9 +40,10 @@ export const ConditionBlock: BlockConfig<CodeExecutionOutput> = {
outputs: {
response: {
type: {
result: 'any',
stdout: 'string',
executionTime: 'number',
content: 'string',
conditionResult: 'boolean',
selectedPath: 'json',
selectedConditionId: 'string',
},
},
},
+15
View File
@@ -494,6 +494,21 @@ export class Executor {
}
if (blockType === 'condition') {
if (output && typeof output === 'object' && 'response' in output) {
return {
response: {
...output.response,
conditionResult: output.response.conditionResult || false,
selectedPath: output.response.selectedPath || {
blockId: '',
blockType: '',
blockTitle: '',
},
selectedConditionId: output.response.selectedConditionId || '',
},
}
}
return {
response: {
conditionResult: output?.conditionResult || false,
+3
View File
@@ -223,6 +223,9 @@ export class InputResolver {
if (currentBlock.metadata?.id === 'condition') {
formattedValue = this.stringifyForCondition(replacementValue)
} else if (currentBlock.metadata?.id === 'function' && typeof replacementValue === 'string') {
// For function blocks, we need to properly quote string values to avoid syntax errors
formattedValue = JSON.stringify(replacementValue)
} else {
formattedValue =
typeof replacementValue === 'object'