remove unused code

This commit is contained in:
Vikhyath Mondreti
2026-02-09 19:04:32 -08:00
parent 606f0f3b8c
commit b32d4e4e48

View File

@@ -469,24 +469,6 @@ function isFileOutputDefinition(value: unknown): value is { type: FileOutputType
return type === 'file' || type === 'file[]'
}
export function getBlockOutputPaths(
blockType: string,
subBlocks?: Record<string, SubBlockWithValue>,
triggerMode?: boolean
): string[] {
const outputs = getBlockOutputs(blockType, subBlocks, triggerMode)
const paths = generateOutputPaths(outputs)
if (blockType === TRIGGER_TYPES.START) {
return paths.filter((path) => {
const key = path.split('.')[0]
return !shouldFilterReservedField(blockType, key, '', subBlocks)
})
}
return paths
}
function getFilePropertyType(outputs: OutputDefinition, pathParts: string[]): string | null {
const lastPart = pathParts[pathParts.length - 1]
if (!lastPart || !USER_FILE_PROPERTY_TYPES[lastPart as keyof typeof USER_FILE_PROPERTY_TYPES]) {
@@ -570,26 +552,6 @@ function extractType(value: unknown): string {
return typeof value === 'string' ? value : 'any'
}
export function getBlockOutputType(
blockType: string,
outputPath: string,
subBlocks?: Record<string, SubBlockWithValue>,
triggerMode?: boolean
): string {
const outputs = getBlockOutputs(blockType, subBlocks, triggerMode)
const cleanPath = outputPath.replace(/\[(\d+)\]/g, '')
const pathParts = cleanPath.split('.').filter(Boolean)
const filePropertyType = getFilePropertyType(outputs, pathParts)
if (filePropertyType) {
return filePropertyType
}
const value = traverseOutputPath(outputs, pathParts)
return extractType(value)
}
export function getEffectiveBlockOutputType(
blockType: string,
outputPath: string,
@@ -668,60 +630,6 @@ function generateOutputPaths(outputs: Record<string, any>, prefix = ''): string[
return paths
}
/**
* Recursively generates all output paths with their types from an outputs schema.
*
* @param outputs - The outputs schema object
* @param prefix - Current path prefix for recursion
* @returns Array of objects containing path and type for each output field
*/
function generateOutputPathsWithTypes(
outputs: Record<string, any>,
prefix = ''
): Array<{ path: string; type: string }> {
const paths: Array<{ path: string; type: string }> = []
for (const [key, value] of Object.entries(outputs)) {
const currentPath = prefix ? `${prefix}.${key}` : key
if (typeof value === 'string') {
paths.push({ path: currentPath, type: value })
} else if (typeof value === 'object' && value !== null) {
if ('type' in value && typeof value.type === 'string') {
if (isFileOutputDefinition(value)) {
paths.push({ path: currentPath, type: value.type })
for (const prop of USER_FILE_ACCESSIBLE_PROPERTIES) {
paths.push({
path: `${currentPath}.${prop}`,
type: USER_FILE_PROPERTY_TYPES[prop as keyof typeof USER_FILE_PROPERTY_TYPES],
})
}
continue
}
if (value.type === 'array' && value.items?.properties) {
paths.push({ path: currentPath, type: 'array' })
const subPaths = generateOutputPathsWithTypes(value.items.properties, currentPath)
paths.push(...subPaths)
} else if ((value.type === 'object' || value.type === 'json') && value.properties) {
paths.push({ path: currentPath, type: value.type })
const subPaths = generateOutputPathsWithTypes(value.properties, currentPath)
paths.push(...subPaths)
} else {
paths.push({ path: currentPath, type: value.type })
}
} else {
const subPaths = generateOutputPathsWithTypes(value, currentPath)
paths.push(...subPaths)
}
} else {
paths.push({ path: currentPath, type: 'any' })
}
}
return paths
}
/**
* Gets the tool outputs for a block operation.
*
@@ -764,41 +672,6 @@ export function getToolOutputs(
}
}
export function getToolOutputPaths(
blockConfig: BlockConfig,
subBlocks?: Record<string, SubBlockWithValue>
): string[] {
const outputs = getToolOutputs(blockConfig, subBlocks)
if (!outputs || Object.keys(outputs).length === 0) return []
if (subBlocks && blockConfig.outputs) {
const filteredOutputs: Record<string, any> = {}
for (const [key, value] of Object.entries(outputs)) {
const blockOutput = blockConfig.outputs[key]
if (!blockOutput || typeof blockOutput !== 'object') {
filteredOutputs[key] = value
continue
}
const condition = 'condition' in blockOutput ? blockOutput.condition : undefined
if (condition) {
if (evaluateOutputCondition(condition, subBlocks)) {
filteredOutputs[key] = value
}
} else {
filteredOutputs[key] = value
}
}
return generateOutputPaths(filteredOutputs)
}
return generateOutputPaths(outputs)
}
/**
* Generates output paths from a schema definition.
*
@@ -808,24 +681,3 @@ export function getToolOutputPaths(
export function getOutputPathsFromSchema(outputs: Record<string, any>): string[] {
return generateOutputPaths(outputs)
}
/**
* Gets the output type for a specific path in a tool's outputs.
*
* @param blockConfig - The block configuration containing tools config
* @param subBlocks - SubBlock values for tool selection
* @param path - The dot-separated path to the output field
* @returns The type of the output field, or 'any' if not found
*/
export function getToolOutputType(
blockConfig: BlockConfig,
subBlocks: Record<string, SubBlockWithValue> | undefined,
path: string
): string {
const outputs = getToolOutputs(blockConfig, subBlocks)
if (!outputs || Object.keys(outputs).length === 0) return 'any'
const pathsWithTypes = generateOutputPathsWithTypes(outputs)
const matchingPath = pathsWithTypes.find((p) => p.path === path)
return matchingPath?.type || 'any'
}