* Apply dynamic schema enrichment for workflow_executor's inputMapping parameter
( propertySchema: any, workflowId: string )
| 628 | * Apply dynamic schema enrichment for workflow_executor's inputMapping parameter |
| 629 | */ |
| 630 | async 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. |
no test coverage detected