import { z } from 'zod';
import { defineTool, } from '../toolDefinition.js';
import { AgentToolNames } from '../shared/agentToolNames.js';
import { ExecutePreexistingSnippetToolDefinition } from './ExecutePreexistingSnippetDefinition.js';
export const requestSnippetToolsParamsSchema = z.object({
    task_description: z.string().meta({
        description: 'Description of the current task to search for relevant snippets',
    }),
    snippet_types: z
        .array(z.enum(['javascript', 'postman', 'sql']))
        .meta({
        description: 'Types of snippets to search for. Choose based on the context:\n' +
            '- "javascript": For browser and mobile interactions (applicable to both web and mobile app testing)\n' +
            '- "postman": For API testing (REST API testing)\n' +
            '- "sql": For database operations\n' +
            'Select types that match the context. For browser or mobile interactions, include "javascript" and optionally "sql". For API testing, include "postman" and optionally "sql".',
    })
        .describe('Array of snippet types to search for: "javascript" for browser/mobile, "postman" for API, "sql" for database operations'),
    application_id: z
        .string()
        .optional()
        .meta({
        description: '**Best practice**: Limit search to a specific application when the application ID is known from context (e.g., from test information or workspace context). This improves search relevance by finding snippets specific to the relevant application.',
    })
        .describe('Optional application ID to limit snippet search to a specific application'),
});
const snippetParameterSchema = z.object({
    name: z.string(),
    default_value: z.string().optional(),
});
const snippetSummarySchema = z.object({
    snippet_id: z.string().meta({
        description: `The unique identifier for this snippet, use this with ${ExecutePreexistingSnippetToolDefinition.name} tool`,
    }),
    name: z.string().meta({
        description: 'The name of the snippet',
    }),
    description: z.string().optional().meta({
        description: 'Description of what the snippet does',
    }),
    snippet_type: z.string().optional().meta({
        description: 'Type of the snippet (e.g., javascript)',
    }),
    body: z.string().optional().meta({
        description: 'The decoded body/code of the snippet',
    }),
    parameters: z.array(snippetParameterSchema).meta({
        description: 'Parameters required by this snippet',
    }),
});
export const requestSnippetToolsResponseSchema = z.object({
    snippets_found: z.number().meta({
        description: 'Number of snippets found',
    }),
    snippets: z.array(snippetSummarySchema).meta({
        description: `List of snippets that can be executed using the ${ExecutePreexistingSnippetToolDefinition.name} tool`,
    }),
});
export const RequestSnippetToolsDefinition = defineTool({
    name: AgentToolNames.RequestSnippetTools,
    description: `Search for code snippets relevant to the current task. Returns a list of snippets with their details. Use this to find reusable code snippets that are related to your task. Specify snippet types (javascript for browser/mobile, postman for API, sql for database) and optionally limit to a specific application for better results.\n\nKeep in mind that when you are looking at the snippet details, snippets sometimes have input parameters. These parameters are important for when you use the ${ExecutePreexistingSnippetToolDefinition.name} tool, but they cannot be used as variables in other steps.`,
    argumentsSchema: requestSnippetToolsParamsSchema,
    responseSchema: requestSnippetToolsResponseSchema,
});
//# sourceMappingURL=RequestSnippetsDefinition.js.map