* Fetches workflow input fields from the API.
( workflowId: string )
| 660 | * Fetches workflow input fields from the API. |
| 661 | */ |
| 662 | async function fetchWorkflowInputFields( |
| 663 | workflowId: string |
| 664 | ): Promise<Array<{ name: string; type: string; description?: string }>> { |
| 665 | try { |
| 666 | const { buildAuthHeaders, buildAPIUrl } = await import('@/executor/utils/http') |
| 667 | |
| 668 | const headers = await buildAuthHeaders() |
| 669 | const url = buildAPIUrl(`/api/workflows/${workflowId}`) |
| 670 | |
| 671 | const response = await fetch(url.toString(), { headers }) |
| 672 | if (!response.ok) { |
| 673 | throw new Error('Failed to fetch workflow') |
| 674 | } |
| 675 | |
| 676 | const { data } = await response.json() |
| 677 | return extractInputFieldsFromBlocks(data?.state?.blocks) |
| 678 | } catch (error) { |
| 679 | logger.error('Error fetching workflow input fields:', error) |
| 680 | return [] |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | /** |
| 685 | * Creates a complete tool schema for execution with all parameters |
no test coverage detected