- supports isTool and timeout settings in defineLogicFunction in apps and in setting tabs definition - compute for all toolInputSchema for logic funciton, in settings and in code steps <img width="991" height="802" alt="image" src="https://github.com/user-attachments/assets/05dc1221-cac9-45a3-87b0-3b13161446fd" />
27 lines
693 B
TypeScript
27 lines
693 B
TypeScript
import { isDefined } from '@/utils/validation/isDefined';
|
|
import {
|
|
DEFAULT_TOOL_INPUT_SCHEMA,
|
|
type InputJsonSchema,
|
|
} from '@/logic-function';
|
|
|
|
export const getInputSchemaFromSourceCode = async (
|
|
sourceCode: string,
|
|
): Promise<InputJsonSchema> => {
|
|
const { getFunctionInputSchema } = await import(
|
|
'./get-function-input-schema'
|
|
);
|
|
const inputSchema = getFunctionInputSchema(sourceCode);
|
|
|
|
// Logic functions take a single params object
|
|
const firstParam = inputSchema[0];
|
|
|
|
if (firstParam?.type === 'object' && isDefined(firstParam.properties)) {
|
|
return {
|
|
type: 'object',
|
|
properties: firstParam.properties,
|
|
};
|
|
}
|
|
|
|
return DEFAULT_TOOL_INPUT_SCHEMA;
|
|
};
|