From 07780800d87527b2b5b02845636784d82ccc025f Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 5 Mar 2025 13:57:18 -0800 Subject: [PATCH] fix(starter): change starter block output format from .type.input to .input, tested --- blocks/blocks/starter.ts | 9 ++++++++- components/ui/tag-dropdown.tsx | 14 ++++++++++---- executor/index.ts | 4 +--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/blocks/blocks/starter.ts b/blocks/blocks/starter.ts index 1f7fc28553..a0544ba305 100644 --- a/blocks/blocks/starter.ts +++ b/blocks/blocks/starter.ts @@ -1,7 +1,14 @@ import { StartIcon } from '@/components/icons' +import { ToolResponse } from '@/tools/types' import { BlockConfig } from '../types' -export const StarterBlock: BlockConfig = { +interface StarterBlockOutput extends ToolResponse { + output: { + input: any + } +} + +export const StarterBlock: BlockConfig = { type: 'starter', name: 'Starter', description: 'Start workflow', diff --git a/components/ui/tag-dropdown.tsx b/components/ui/tag-dropdown.tsx index 36e9229af4..937118ad3a 100644 --- a/components/ui/tag-dropdown.tsx +++ b/components/ui/tag-dropdown.tsx @@ -57,18 +57,24 @@ export const TagDropdown: React.FC = ({ // Get source block and compute tags const { tags } = useMemo(() => { // Helper function to get output paths - const getOutputPaths = (obj: any, prefix = ''): string[] => { + const getOutputPaths = (obj: any, prefix = '', isStarterBlock = false): string[] => { if (typeof obj !== 'object' || obj === null) { return prefix ? [prefix] : [] } + // Special handling for starter block. + // TODO: In the future, we will support response formats and required input types. For now, we just take the input altogether. + if (isStarterBlock && prefix === 'response') { + return ['response.input'] + } + if ('type' in obj && typeof obj.type === 'string') { return [prefix] } return Object.entries(obj).flatMap(([key, value]) => { const newPrefix = prefix ? `${prefix}.${key}` : key - return getOutputPaths(value, newPrefix) + return getOutputPaths(value, newPrefix, isStarterBlock) }) } @@ -118,7 +124,7 @@ export const TagDropdown: React.FC = ({ } // Fall back to default outputs if no response format - const outputPaths = getOutputPaths(sourceBlock.outputs) + const outputPaths = getOutputPaths(sourceBlock.outputs, '', sourceBlock.type === 'starter') return { tags: outputPaths.map((path) => `${normalizedBlockName}.${path}`), } @@ -167,7 +173,7 @@ export const TagDropdown: React.FC = ({ } // Fall back to default outputs if no response format - const outputPaths = getOutputPaths(sourceBlock.outputs) + const outputPaths = getOutputPaths(sourceBlock.outputs, '', sourceBlock.type === 'starter') return outputPaths.map((path) => `${normalizedBlockName}.${path}`) }) diff --git a/executor/index.ts b/executor/index.ts index f7be3f27d8..1df766d01c 100644 --- a/executor/index.ts +++ b/executor/index.ts @@ -217,9 +217,7 @@ export class Executor { // Initialize the starter block with the workflow input const starterOutput = { response: { - type: { - input: this.workflowInput, - }, + input: this.workflowInput, }, }