fix(starter): change starter block output format from .type.input to .input, tested

This commit is contained in:
Waleed Latif
2025-03-05 13:57:18 -08:00
parent 350a0dca57
commit 07780800d8
3 changed files with 19 additions and 8 deletions
+8 -1
View File
@@ -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<StarterBlockOutput> = {
type: 'starter',
name: 'Starter',
description: 'Start workflow',
+10 -4
View File
@@ -57,18 +57,24 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
// 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<TagDropdownProps> = ({
}
// 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<TagDropdownProps> = ({
}
// 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}`)
})
+1 -3
View File
@@ -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,
},
}