import { z } from 'zod';
import { defineTool, } from '../toolDefinition.js';
import { AgentToolNames } from './agentToolNames.js';
import { testSearchMatchSchema, testSearchResponseSchema } from './searchTestsSchemas.js';
export const searchTestsByTextToolParamsSchema = z.object({
    query: z.string().meta({
        description: 'Keywords searched against test names, descriptions, intent, and labels via Spanner full-text search. ' +
            'Provide natural keywords (e.g., "login signin authentication") — by default (match_mode "any") any token ' +
            'may match, so you do NOT need to insert " OR " yourself. ' +
            'You MAY call this tool multiple times in parallel with different keyword sets to broaden recall.',
    }),
    search_field: z
        .enum(['combined', 'name', 'description', 'intent', 'labels'])
        .optional()
        .meta({
        description: 'Restrict the search to a single tokenized column. "combined" (default) searches name+description+intent+labels. ' +
            'Use "name" when the user appears to be typing a test name prefix. Use "labels" when the query is literally a label keyword.',
    }),
    match_mode: z
        .enum(['any', 'all'])
        .default('any')
        .meta({
        description: 'How the tokens in `query` combine. "any" (DEFAULT, best for recall): a test matches if it contains ANY ' +
            'token — use it for keyword sets and synonym expansions. "all": a test must contain ALL tokens — use it ' +
            'for precise phrases that must co-occur. ' +
            'Examples: query "login signin authentication" + "any" → tests mentioning any of those terms (broad recall); ' +
            'query "checkout payment" + "all" → only tests mentioning BOTH; ' +
            'search_field "labels" + query "smoke" + "any" → label lookup.',
    }),
    // No structural-filter arguments: test_type / mobile_platform / labels / updated_after are
    // request-level filters enforced server-side from tool context (like workspace/application
    // scope), never chosen by the model. See SearchTestsByTextTool for where they're applied.
    limit: z.number().int().min(1).max(200).default(20).meta({
        description: 'Per-call hard limit on candidates returned. Capped at 200 server-side. When you issue several text calls in parallel, set each high enough that the union surfaces every relevant test — up to 200 for a broad category, label, or type query.',
    }),
});
export const searchTestsByTextToolResponseSchema = z.object({
    total_candidates: z.number().int().meta({
        description: 'Number of unique tests returned by this tool call.',
    }),
    truncated: z.boolean().meta({
        description: 'True if any match had its annotated_step_summary budget-truncated. Per-match `truncated` flags indicate which.',
    }),
    matches: z.array(testSearchMatchSchema),
});
export const SearchTestsByTextToolDefinition = defineTool({
    name: AgentToolNames.SearchTestsByText,
    description: 'Token-based full-text search across test names, descriptions, intent, and labels. ' +
        'Best for keyword-style queries and label lookups. By default (match_mode "any") any token may match — ' +
        'just list natural keywords. May be called multiple times in parallel with different keyword sets.',
    argumentsSchema: searchTestsByTextToolParamsSchema,
    responseSchema: searchTestsByTextToolResponseSchema,
});
// Re-export the shared response schema for service-side reuse.
export { testSearchResponseSchema };
//# sourceMappingURL=SearchTestsByTextDefinition.js.map