"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecuteCountElementsToolDefinition = exports.executeCountElementsClientResponseSchema = exports.executeCountElementsArgumentsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var agentToolNames_js_1 = require("../shared/agentToolNames.js");
var description = "\nCounts the number of elements matching a CSS or XPath selector and stores the count as a numeric variable. Use the resulting variable with execute_assert_variable to assert on the count (greater_than, equals, etc.).\n\nExamples:\n- count search results: variableName: 'searchResultCount', selectorType: 'css', selector: '.search-result'\n- count cart items: variableName: 'cartItemCount', selectorType: 'css', selector: '[data-test-id=\"cart-item\"]'\n- count rows in a table: variableName: 'tableRowCount', selectorType: 'xpath', selector: '//table[@id=\"orders\"]/tbody/tr'\n\nVariable names should be alphanumeric and underscores only, no periods. The count is always a non-negative integer; selectors that match nothing produce 0.\n".trim();
exports.executeCountElementsArgumentsSchema = zod_1.z.object({
    description: zod_1.z
        .string()
        .max(100)
        .meta({ description: 'A brief description of what this step does (max 100 characters)' }),
    variableName: zod_1.z
        .string()
        .regex(/^[A-Za-z0-9_]+$/)
        .meta({
        description: 'The name of the variable to store the count in. Alphanumeric and underscores only, no periods.',
    }),
    selectorType: zod_1.z.enum(['css', 'xpath']).meta({
        description: 'Which selector flavor `selector` is — CSS query or XPath expression.',
    }),
    selector: zod_1.z.string().min(1).meta({
        description: 'CSS query or XPath expression that matches the elements to count.',
    }),
    reasoning: zod_1.z.string().optional().meta({ description: 'Brief explanation of why this count is being captured.' }),
});
exports.executeCountElementsClientResponseSchema = zod_1.z.object({
    success: zod_1.z.boolean(),
    message: zod_1.z.string().optional(),
    variable_name: zod_1.z.string().optional().meta({
        description: 'The name of the variable that was created with the element count.',
    }),
    variable_value: zod_1.z.string().optional().meta({
        description: 'The count value stored in the variable, as a string.',
    }),
});
exports.ExecuteCountElementsToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.ExecuteCountElements,
    description: description,
    argumentsSchema: exports.executeCountElementsArgumentsSchema,
    responseSchema: exports.executeCountElementsClientResponseSchema,
});
//# sourceMappingURL=ExecuteCountElementsDefinition.js.map