0173e40a20
## Summary This PR enables serverless functions to be exposed as AI tools, allowing them to be used by AI agents. ### Changes - Added new `SERVERLESS_FUNCTION` tool category - Added `toolDescription`, `toolInputSchema`, and `toolOutputSchema` fields to serverless functions - Created database migration for the new schema columns - Added tool index query and resolver for fetching available tools - Added Settings AI page tabs (Skills, Tools, Settings) with new tools table - Added utility to convert tool schema to JSON schema format - Updated frontend to display tools in the settings page ### Implementation Details - Serverless functions can now define tool metadata (description, input/output schemas) - These functions are automatically registered in the tool registry - The tool index endpoint allows querying available tools with their schemas - Settings page now has a dedicated Tools tab showing all available tools
82 lines
1.6 KiB
TypeScript
82 lines
1.6 KiB
TypeScript
import { Field, InputType } from '@nestjs/graphql';
|
|
|
|
import { Type } from 'class-transformer';
|
|
import {
|
|
IsBoolean,
|
|
IsNotEmpty,
|
|
IsNumber,
|
|
IsObject,
|
|
IsOptional,
|
|
IsString,
|
|
IsUUID,
|
|
Max,
|
|
Min,
|
|
ValidateNested,
|
|
} from 'class-validator';
|
|
import graphqlTypeJson from 'graphql-type-json';
|
|
|
|
import type { Sources } from 'twenty-shared/types';
|
|
|
|
import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';
|
|
|
|
@InputType()
|
|
class UpdateServerlessFunctionInputUpdates {
|
|
@IsString()
|
|
@Field()
|
|
@IsOptional()
|
|
name?: string;
|
|
|
|
@IsString()
|
|
@Field({ nullable: true })
|
|
@IsOptional()
|
|
description?: string;
|
|
|
|
@IsNumber()
|
|
@Field({ nullable: true })
|
|
@Min(1)
|
|
@Max(900)
|
|
@IsOptional()
|
|
timeoutSeconds?: number;
|
|
|
|
@Field(() => graphqlTypeJson)
|
|
@IsObject()
|
|
code: Sources;
|
|
|
|
@IsString()
|
|
@Field({ nullable: true })
|
|
@IsOptional()
|
|
handlerName?: string;
|
|
|
|
@IsString()
|
|
@Field({ nullable: true })
|
|
@IsOptional()
|
|
handlerPath?: string;
|
|
|
|
@Field(() => graphqlTypeJson, { nullable: true })
|
|
@IsObject()
|
|
@IsOptional()
|
|
toolInputSchema?: object;
|
|
|
|
@IsBoolean()
|
|
@Field({ nullable: true })
|
|
@IsOptional()
|
|
isTool?: boolean;
|
|
}
|
|
|
|
@InputType()
|
|
export class UpdateServerlessFunctionInput {
|
|
@Field(() => UUIDScalarType, {
|
|
description: 'Id of the serverless function to update',
|
|
})
|
|
@IsNotEmpty()
|
|
@IsUUID()
|
|
id: string;
|
|
|
|
@Type(() => UpdateServerlessFunctionInputUpdates)
|
|
@ValidateNested()
|
|
@Field(() => UpdateServerlessFunctionInputUpdates, {
|
|
description: 'The serverless function updates',
|
|
})
|
|
update: UpdateServerlessFunctionInputUpdates;
|
|
}
|