1+ import {
2+ extractFieldsFromSchema ,
3+ parseResponseFormatSafely ,
4+ } from '@/lib/core/utils/response-format'
15import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
26import { isTriggerBehavior , normalizeName } from '@/executor/constants'
37import type { ExecutionContext } from '@/executor/types'
@@ -51,15 +55,31 @@ function getInputFormatFields(block: SerializedBlock): OutputSchema {
5155 return schema
5256}
5357
58+ function getResponseFormatSchema ( block : SerializedBlock ) : OutputSchema | undefined {
59+ const responseFormatValue = block . config ?. params ?. responseFormat
60+ if ( ! responseFormatValue ) return undefined
61+
62+ const parsed = parseResponseFormatSafely ( responseFormatValue , block . id )
63+ if ( ! parsed ) return undefined
64+
65+ const fields = extractFieldsFromSchema ( parsed )
66+ if ( fields . length === 0 ) return undefined
67+
68+ const schema : OutputSchema = { }
69+ for ( const field of fields ) {
70+ schema [ field . name ] = {
71+ type : ( field . type || 'any' ) as 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any' ,
72+ }
73+ }
74+ return schema
75+ }
76+
5477export function getBlockSchema (
5578 block : SerializedBlock ,
5679 toolConfig ?: ToolConfig
5780) : OutputSchema | undefined {
5881 const blockType = block . metadata ?. id
5982
60- // For blocks that expose inputFormat as outputs, always merge them
61- // This includes both triggers (start_trigger, generic_webhook) and
62- // non-triggers (starter, human_in_the_loop) that have inputFormat
6383 if (
6484 blockType &&
6585 BLOCKS_WITH_INPUT_FORMAT_OUTPUTS . includes (
@@ -74,6 +94,11 @@ export function getBlockSchema(
7494 }
7595 }
7696
97+ const responseFormatSchema = getResponseFormatSchema ( block )
98+ if ( responseFormatSchema ) {
99+ return responseFormatSchema
100+ }
101+
77102 const isTrigger = isTriggerBehavior ( block )
78103
79104 if ( isTrigger && block . outputs && Object . keys ( block . outputs ) . length > 0 ) {
0 commit comments