Support define is tool logic function (#17926)

- 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"
/>
This commit is contained in:
martmull
2026-02-16 10:43:29 +01:00
committed by GitHub
parent f694bb99b3
commit da064d5e88
138 changed files with 4839 additions and 367 deletions
@@ -5,5 +5,4 @@ export type {
Node,
NodeType,
} from './types/base-output-schema.type';
export { buildOutputSchemaFromValue } from './utils/buildOutputSchemaFromValue';
export { navigateOutputSchemaProperty } from './utils/navigateOutputSchemaProperty';
@@ -1,106 +0,0 @@
import { buildOutputSchemaFromValue } from '../buildOutputSchemaFromValue';
describe('buildOutputSchemaFromValue', () => {
it('should compute outputSchema properly for mixed types', () => {
const testResult = {
a: null,
b: 'b',
c: { cc: 1 },
d: true,
e: [1, 2, 3],
};
const expectedOutputSchema = {
a: {
isLeaf: true,
type: 'unknown',
value: null,
label: 'a',
},
b: {
isLeaf: true,
type: 'string',
value: 'b',
label: 'b',
},
c: {
isLeaf: false,
type: 'object',
label: 'c',
value: {
cc: {
isLeaf: true,
type: 'number',
value: 1,
label: 'cc',
},
},
},
d: {
isLeaf: true,
type: 'boolean',
value: true,
label: 'd',
},
e: {
isLeaf: true,
type: 'array',
value: [1, 2, 3],
label: 'e',
},
};
expect(buildOutputSchemaFromValue(testResult)).toEqual(
expectedOutputSchema,
);
});
it('should handle nested objects', () => {
const testResult = {
user: {
name: 'John',
address: {
street: '123 Main St',
city: 'New York',
},
},
};
const result = buildOutputSchemaFromValue(testResult);
expect(result.user).toEqual({
isLeaf: false,
type: 'object',
label: 'user',
value: {
name: {
isLeaf: true,
type: 'string',
value: 'John',
label: 'name',
},
address: {
isLeaf: false,
type: 'object',
label: 'address',
value: {
street: {
isLeaf: true,
type: 'string',
value: '123 Main St',
label: 'street',
},
city: {
isLeaf: true,
type: 'string',
value: 'New York',
label: 'city',
},
},
},
},
});
});
it('should return empty object for empty input', () => {
expect(buildOutputSchemaFromValue({})).toEqual({});
});
});
@@ -1,53 +0,0 @@
import { isDefined } from '@/utils';
import {
type BaseOutputSchemaV2,
type LeafType,
} from '@/workflow/workflow-schema/types/base-output-schema.type';
import { isObject } from '@sniptt/guards';
const getValueType = (value: any): LeafType => {
if (!isDefined(value) || value === null) {
return 'unknown';
}
if (typeof value === 'string') {
return 'string';
}
if (typeof value === 'number') {
return 'number';
}
if (typeof value === 'boolean') {
return 'boolean';
}
if (Array.isArray(value)) {
return 'array';
}
return 'unknown';
};
export const buildOutputSchemaFromValue = (
testResult: object,
): BaseOutputSchemaV2 => {
return testResult
? Object.entries(testResult).reduce(
(acc: BaseOutputSchemaV2, [key, value]) => {
if (isObject(value) && !Array.isArray(value)) {
acc[key] = {
isLeaf: false,
type: 'object',
label: key,
value: buildOutputSchemaFromValue(value),
};
} else {
acc[key] = {
isLeaf: true,
value,
type: getValueType(value),
label: key,
};
}
return acc;
},
{},
)
: {};
};