mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(executor/function): fix resolution of tag inputs to function block
This commit is contained in:
@@ -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',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user