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
@@ -0,0 +1,40 @@
import { filterOutByProperty } from '@/utils/array/filterOutByProperty';
describe('filterOutByProperty', () => {
it('should filter out items matching the excluded value', () => {
const items = [
{ id: '1', status: 'active' },
{ id: '2', status: 'inactive' },
{ id: '3', status: 'active' },
];
const result = items.filter(filterOutByProperty('status', 'inactive'));
expect(result).toEqual([
{ id: '1', status: 'active' },
{ id: '3', status: 'active' },
]);
});
it('should keep all items when no match exists', () => {
const items = [
{ id: '1', name: 'Alice' },
{ id: '2', name: 'Bob' },
];
const result = items.filter(filterOutByProperty('name', 'Charlie'));
expect(result).toEqual(items);
});
it('should handle null exclusion value', () => {
const items = [
{ id: '1', name: null as string | null },
{ id: '2', name: 'Bob' },
];
const result = items.filter(filterOutByProperty('name', null));
expect(result).toEqual([{ id: '2', name: 'Bob' }]);
});
});
@@ -0,0 +1,33 @@
import { findByProperty } from '@/utils/array/findByProperty';
describe('findByProperty', () => {
it('should find item matching the value', () => {
const items = [
{ id: '1', status: 'active' },
{ id: '2', status: 'inactive' },
];
const result = items.find(findByProperty('status', 'inactive'));
expect(result).toEqual({ id: '2', status: 'inactive' });
});
it('should return undefined when no match exists', () => {
const items = [{ id: '1', name: 'Alice' }];
const result = items.find(findByProperty('name', 'Bob'));
expect(result).toBeUndefined();
});
it('should handle null match value', () => {
const items = [
{ id: '1', name: null as string | null },
{ id: '2', name: 'Bob' },
];
const result = items.find(findByProperty('name', null));
expect(result).toEqual({ id: '1', name: null });
});
});
@@ -0,0 +1,19 @@
import { getContiguousIncrementalValues } from '@/utils/array/getContiguousIncrementalValues';
describe('getContiguousIncrementalValues', () => {
it('should return incremental values starting from 0 by default', () => {
expect(getContiguousIncrementalValues(5)).toEqual([0, 1, 2, 3, 4]);
});
it('should return incremental values starting from a custom value', () => {
expect(getContiguousIncrementalValues(3, 10)).toEqual([10, 11, 12]);
});
it('should return an empty array for 0 values', () => {
expect(getContiguousIncrementalValues(0)).toEqual([]);
});
it('should handle negative starting values', () => {
expect(getContiguousIncrementalValues(3, -2)).toEqual([-2, -1, 0]);
});
});
@@ -0,0 +1,13 @@
import { mapById } from '@/utils/array/mapById';
describe('mapById', () => {
it('should extract the id from an item', () => {
expect(mapById({ id: 'abc-123' })).toBe('abc-123');
});
it('should work with Array.map', () => {
const items = [{ id: '1' }, { id: '2' }, { id: '3' }];
expect(items.map(mapById)).toEqual(['1', '2', '3']);
});
});
@@ -0,0 +1,18 @@
import { mapByProperty } from '@/utils/array/mapByProperty';
describe('mapByProperty', () => {
it('should extract the specified property from an item', () => {
const items = [
{ id: '1', name: 'Alice' },
{ id: '2', name: 'Bob' },
];
expect(items.map(mapByProperty('name'))).toEqual(['Alice', 'Bob']);
});
it('should extract the id property', () => {
const items = [{ id: 'a' }, { id: 'b' }];
expect(items.map(mapByProperty('id'))).toEqual(['a', 'b']);
});
});
@@ -0,0 +1,29 @@
import { sumByProperty } from '@/utils/array/sumByProperty';
describe('sumByProperty', () => {
it('should sum numeric property values', () => {
const items = [
{ id: '1', amount: 10 },
{ id: '2', amount: 20 },
{ id: '3', amount: 30 },
];
expect(items.reduce(sumByProperty('amount'), 0)).toBe(60);
});
it('should skip non-numeric values', () => {
const items = [
{ id: '1', amount: 10 },
{ id: '2', amount: 'not-a-number' as unknown as number },
{ id: '3', amount: 30 },
];
expect(items.reduce(sumByProperty('amount'), 0)).toBe(40);
});
it('should handle an empty array', () => {
const items: { id: string; amount: number }[] = [];
expect(items.reduce(sumByProperty('amount'), 0)).toBe(0);
});
});