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
1 change: 1 addition & 0 deletions apps/sim/blocks/blocks/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const WorkflowBlock: BlockConfig = {
outputs: {
success: { type: 'boolean', description: 'Execution success status' },
childWorkflowName: { type: 'string', description: 'Child workflow name' },
childWorkflowId: { type: 'string', description: 'Child workflow ID' },
result: { type: 'json', description: 'Workflow execution result' },
error: { type: 'string', description: 'Error message' },
childTraceSpans: {
Expand Down
1 change: 1 addition & 0 deletions apps/sim/blocks/blocks/workflow_input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const WorkflowInputBlock: BlockConfig = {
outputs: {
success: { type: 'boolean', description: 'Execution success status' },
childWorkflowName: { type: 'string', description: 'Child workflow name' },
childWorkflowId: { type: 'string', description: 'Child workflow ID' },
result: { type: 'json', description: 'Workflow execution result' },
error: { type: 'string', description: 'Error message' },
childTraceSpans: {
Expand Down
56 changes: 50 additions & 6 deletions apps/sim/executor/utils/block-data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import {
extractFieldsFromSchema,
parseResponseFormatSafely,
} from '@/lib/core/utils/response-format'
import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
import { isTriggerBehavior, normalizeName } from '@/executor/constants'
import type { ExecutionContext } from '@/executor/types'
Expand Down Expand Up @@ -43,23 +47,53 @@ function getInputFormatFields(block: SerializedBlock): OutputSchema {
const schema: OutputSchema = {}
for (const field of inputFormat) {
if (!field.name) continue
schema[field.name] = {
type: (field.type || 'any') as 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any',
}
schema[field.name] = { type: field.type || 'any' }
}

return schema
}

function getEvaluatorMetricsSchema(block: SerializedBlock): OutputSchema | undefined {
if (block.metadata?.id !== 'evaluator') return undefined

const metrics = block.config?.params?.metrics
if (!Array.isArray(metrics) || metrics.length === 0) return undefined

const validMetrics = metrics.filter(
(m: { name?: string }) => m?.name && typeof m.name === 'string'
)
if (validMetrics.length === 0) return undefined

const schema: OutputSchema = { ...(block.outputs as OutputSchema) }
for (const metric of validMetrics) {
schema[metric.name.toLowerCase()] = { type: 'number' }
}
return schema
}

function getResponseFormatSchema(block: SerializedBlock): OutputSchema | undefined {
const responseFormatValue = block.config?.params?.responseFormat
if (!responseFormatValue) return undefined

const parsed = parseResponseFormatSafely(responseFormatValue, block.id)
if (!parsed) return undefined

const fields = extractFieldsFromSchema(parsed)
if (fields.length === 0) return undefined

const schema: OutputSchema = {}
for (const field of fields) {
schema[field.name] = { type: field.type || 'any' }
}
return schema
}

export function getBlockSchema(
block: SerializedBlock,
toolConfig?: ToolConfig
): OutputSchema | undefined {
const blockType = block.metadata?.id

// For blocks that expose inputFormat as outputs, always merge them
// This includes both triggers (start_trigger, generic_webhook) and
// non-triggers (starter, human_in_the_loop) that have inputFormat
if (
blockType &&
BLOCKS_WITH_INPUT_FORMAT_OUTPUTS.includes(
Expand All @@ -74,6 +108,16 @@ export function getBlockSchema(
}
}

const evaluatorSchema = getEvaluatorMetricsSchema(block)
if (evaluatorSchema) {
return evaluatorSchema
}

const responseFormatSchema = getResponseFormatSchema(block)
if (responseFormatSchema) {
return responseFormatSchema
}

const isTrigger = isTriggerBehavior(block)

if (isTrigger && block.outputs && Object.keys(block.outputs).length > 0) {
Expand Down