"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecuteCreateVariableToolDefinition = exports.executeCreateVariableResponseSchema = exports.executeCreateVariableArgumentsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var agentToolNames_js_1 = require("../shared/agentToolNames.js");
exports.executeCreateVariableArgumentsSchema = zod_1.z.object({
    description: zod_1.z.string().max(100).describe('A brief description of what this step does (max 100 characters)'),
    variable_name: zod_1.z
        .string()
        .describe('The variable name to create. Provide the raw name without the "user." prefix — the system adds it automatically. ' +
        'Use the same name as the failed CreateVariable step so that subsequent steps referencing {{@variableName}} resolve correctly.'),
    variable_value: zod_1.z
        .string()
        .describe('The value to assign to the variable. This should match what the failed CreateVariable step was supposed to produce. ' +
        'For attribute extractions, use execute_javascript first to read the value from the DOM, then pass it here. ' +
        'For pattern-based values, generate a reasonable substitute.'),
});
exports.executeCreateVariableResponseSchema = zod_1.z.object({
    success: zod_1.z.boolean().describe('Whether the variable was successfully created'),
    message: zod_1.z.string().optional().describe('Status message or error description'),
    variable_name: zod_1.z.string().optional().describe('The variable name that was set (with user namespace prefix)'),
    variable_value: zod_1.z.string().optional().describe('The actual value that was assigned'),
});
exports.ExecuteCreateVariableToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.ExecuteCreateVariable,
    description: "Set a test variable in the execution context. Use this tool when a CreateVariable step has failed and you need to create the variable so that subsequent steps referencing {{@variableName}} can still execute.\n\nThis tool sets the variable in the test's variable context with the proper \"user.\" namespace prefix. The variable becomes immediately available for use in subsequent steps via the {{@variableName}} syntax.\n\nWhen to use:\n- A CreateVariable step failed and subsequent steps depend on the variable it was supposed to create\n- You have determined the correct value through investigation (e.g., by using execute_javascript to extract it from the DOM, or by examining the step definition)\n\nWhen NOT to use:\n- For failures unrelated to CreateVariable steps\n- To create arbitrary variables that were not part of the original test\n- To override existing variables with different values \u2014 if a step ran and PASSED, its variable has a value even if that value is an error string from the script's logic; do not overwrite it",
    argumentsSchema: exports.executeCreateVariableArgumentsSchema,
    responseSchema: exports.executeCreateVariableResponseSchema,
});
//# sourceMappingURL=ExecuteCreateVariableDefinition.js.map