MCPcopy Index your code
hub / github.com/simstudioai/sim / applyDynamicSchemaForWorkflow

Function applyDynamicSchemaForWorkflow

apps/sim/tools/params.ts:630–657  ·  view source on GitHub ↗

* Apply dynamic schema enrichment for workflow_executor's inputMapping parameter

(
  propertySchema: any,
  workflowId: string
)

Source from the content-addressed store, hash-verified

628 * Apply dynamic schema enrichment for workflow_executor's inputMapping parameter
629 */
630async function applyDynamicSchemaForWorkflow(
631 propertySchema: any,
632 workflowId: string
633): Promise<void> {
634 try {
635 const workflowInputFields = await fetchWorkflowInputFields(workflowId)
636
637 if (workflowInputFields && workflowInputFields.length > 0) {
638 propertySchema.type = 'object'
639 propertySchema.properties = {}
640 propertySchema.required = []
641
642 // Convert workflow input fields to JSON schema properties
643 for (const field of workflowInputFields) {
644 propertySchema.properties[field.name] = {
645 type: field.type || 'string',
646 description: field.description || `Input field: ${field.name}`,
647 }
648 propertySchema.required.push(field.name)
649 }
650
651 // Update description to be more specific
652 propertySchema.description = `Input values for the workflow. Required fields: ${workflowInputFields.map((f) => f.name).join(', ')}`
653 }
654 } catch (error) {
655 logger.error('Failed to fetch workflow input fields for LLM schema:', error)
656 }
657}
658
659/**
660 * Fetches workflow input fields from the API.

Callers 1

createLLMToolSchemaFunction · 0.85

Calls 4

fetchWorkflowInputFieldsFunction · 0.85
joinMethod · 0.80
errorMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected