UNPKG

@vfarcic/dot-ai

Version:

AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance

102 lines (101 loc) 4.11 kB
"use strict"; /** * Tool Discovery and Execution Schemas * * Schemas for the /api/v1/tools and /api/v1/tools/:toolName endpoints. * PRD #354: REST API Route Registry with Auto-Generated OpenAPI and Test Fixtures */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ToolDiscoveryErrorSchema = exports.ToolExecutionErrorSchema = exports.InvalidToolRequestErrorSchema = exports.ToolNotFoundErrorSchema = exports.ToolExecutionResponseSchema = exports.ToolExecutionDataSchema = exports.ToolDiscoveryResponseSchema = exports.ToolDiscoveryDataSchema = exports.ToolInfoSchema = exports.ToolParameterSchema = void 0; const zod_1 = require("zod"); const common_1 = require("./common"); /** * Tool parameter schema */ exports.ToolParameterSchema = zod_1.z.object({ name: zod_1.z.string().describe('Parameter name'), type: zod_1.z.string().describe('Parameter type (string, number, boolean, object, array)'), description: zod_1.z.string().describe('Parameter description'), required: zod_1.z.boolean().describe('Whether the parameter is required'), default: zod_1.z.any().optional().describe('Default value if not provided'), enum: zod_1.z.array(zod_1.z.string()).optional().describe('Allowed values for enum parameters'), }); /** * Tool information schema * Matches ToolInfo from rest-registry.ts */ exports.ToolInfoSchema = zod_1.z.object({ name: zod_1.z.string().describe('Tool name/identifier'), description: zod_1.z.string().describe('Tool description'), category: zod_1.z.string().optional().describe('Tool category for grouping'), tags: zod_1.z.array(zod_1.z.string()).optional().describe('Tags for filtering'), parameters: zod_1.z.array(exports.ToolParameterSchema).optional().describe('Tool parameters'), inputSchema: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional().describe('JSON Schema for tool input'), }); /** * Tool discovery response data */ exports.ToolDiscoveryDataSchema = zod_1.z.object({ tools: zod_1.z.array(exports.ToolInfoSchema).describe('List of available tools'), total: zod_1.z.number().describe('Total number of tools'), categories: zod_1.z.array(zod_1.z.string()).optional().describe('Available categories'), tags: zod_1.z.array(zod_1.z.string()).optional().describe('Available tags'), }); /** * Tool discovery response schema * GET /api/v1/tools */ exports.ToolDiscoveryResponseSchema = (0, common_1.createSuccessResponseSchema)(exports.ToolDiscoveryDataSchema); /** * Tool execution result data */ exports.ToolExecutionDataSchema = zod_1.z.object({ result: zod_1.z.any().describe('Tool execution result'), tool: zod_1.z.string().describe('Name of the executed tool'), executionTime: zod_1.z.number().optional().describe('Execution time in milliseconds'), }); /** * Tool execution response schema * POST /api/v1/tools/:toolName */ exports.ToolExecutionResponseSchema = (0, common_1.createSuccessResponseSchema)(exports.ToolExecutionDataSchema); /** * Tool not found error */ exports.ToolNotFoundErrorSchema = common_1.NotFoundErrorSchema.extend({ error: zod_1.z.object({ code: zod_1.z.literal('TOOL_NOT_FOUND'), message: zod_1.z.string(), details: zod_1.z.any().optional(), }), }); /** * Invalid tool request error */ exports.InvalidToolRequestErrorSchema = common_1.BadRequestErrorSchema.extend({ error: zod_1.z.object({ code: zod_1.z.literal('INVALID_REQUEST'), message: zod_1.z.string(), details: zod_1.z.any().optional(), }), }); /** * Tool execution error */ exports.ToolExecutionErrorSchema = common_1.InternalServerErrorSchema.extend({ error: zod_1.z.object({ code: zod_1.z.literal('EXECUTION_ERROR'), message: zod_1.z.string(), details: zod_1.z.any().optional(), }), }); /** * Tool discovery error */ exports.ToolDiscoveryErrorSchema = common_1.InternalServerErrorSchema.extend({ error: zod_1.z.object({ code: zod_1.z.literal('DISCOVERY_ERROR'), message: zod_1.z.string(), details: zod_1.z.any().optional(), }), });