"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecuteVariableToolDefinition = exports.executeVariableClientResponseSchema = exports.executeVariableServerResultSchema = exports.executeVariableArgumentsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var agentToolNames_js_1 = require("../shared/agentToolNames.js");
var constants_js_1 = require("../shared/constants.js");
var customFind_js_1 = require("../shared/customFind.js");
var variableToolDescription = "\nCreates or sets a variable with the given name and value. Variables can be used in other steps by wrapping the variable name in curly braces with an @ symbol in front of the variable name, e.g. {{@variableName}}. Variable names you create should not have periods and should only be alphanumeric. The variable value can be one that you create or it can be extracted from the text of an element in the application. If you are extracting the value from an element, you should include a good element description in the elementDescription parameter.\n\nYou cannot create a variable with arbitrary code. The only options are a direct string value, the use of faker (as described below), or extracting the text of an element in the application.\n\n".concat(constants_js_1.DYNAMIC_VALUE_INSTRUCTIONS, "\n");
exports.executeVariableArgumentsSchema = zod_1.z.object({
    elementDescription: zod_1.z
        .string()
        .meta({
        description: constants_js_1.TOOL_ELEMENT_DESCRIPTION_INSTRUCTIONS,
    })
        .optional(),
    variableName: zod_1.z.string().meta({
        description: 'The name of the variable to create or set',
    }),
    variableValue: zod_1.z.string().meta({
        description: 'The current value of the variable. If extracting the value from an element, this should be the expected value of the variable.',
    }),
    customFind: customFind_js_1.customFindSchema.optional(),
});
exports.executeVariableServerResultSchema = zod_1.z.object({
    variableName: zod_1.z.string(),
    variableValue: zod_1.z.string(),
    elementDescription: zod_1.z.string().optional(),
    elementBoundingBox: zod_1.z
        .object({
        top: zod_1.z.number(),
        left: zod_1.z.number(),
        bottom: zod_1.z.number(),
        right: zod_1.z.number(),
    })
        .optional(),
    elementTargetPoint: zod_1.z
        .object({
        x: zod_1.z.number(),
        y: zod_1.z.number(),
    })
        .optional(),
});
/**
 * Response schema for execute_create_or_set_variable tool.
 * The client should include the confirmed variable name and its actual value
 * to provide context about what was created without requiring a separate lookup.
 */
exports.executeVariableClientResponseSchema = zod_1.z.object({
    success: zod_1.z.boolean(),
    message: zod_1.z.string().optional(),
    // Context fields - client should include these after executing the action
    variable_name: zod_1.z.string().optional().meta({
        description: 'The name of the variable that was created or updated',
    }),
    variable_value: zod_1.z.string().optional().meta({
        description: 'The actual value assigned to the variable (may differ if extracted from element)',
    }),
});
exports.ExecuteVariableToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.ExecuteCreateOrSetVariable,
    description: variableToolDescription,
    argumentsSchema: exports.executeVariableArgumentsSchema,
    serverPrepareResultSchema: exports.executeVariableServerResultSchema,
    responseSchema: exports.executeVariableClientResponseSchema,
});
//# sourceMappingURL=ExecuteVariableDefinition.js.map