import { z } from 'zod';
import { defineTool, } from '../toolDefinition.js';
import { AgentToolNames } from '../shared/agentToolNames.js';
export const executeCreateVariableArgumentsSchema = z.object({
    description: z.string().max(100).describe('A brief description of what this step does (max 100 characters)'),
    variable_name: 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: 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.'),
});
export const executeCreateVariableResponseSchema = z.object({
    success: z.boolean().describe('Whether the variable was successfully created'),
    message: z.string().optional().describe('Status message or error description'),
    variable_name: z.string().optional().describe('The variable name that was set (with user namespace prefix)'),
    variable_value: z.string().optional().describe('The actual value that was assigned'),
});
export const ExecuteCreateVariableToolDefinition = defineTool({
    name: 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.

This 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.

When to use:
- A CreateVariable step failed and subsequent steps depend on the variable it was supposed to create
- 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)

When NOT to use:
- For failures unrelated to CreateVariable steps
- To create arbitrary variables that were not part of the original test
- To override existing variables with different values — 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: executeCreateVariableArgumentsSchema,
    responseSchema: executeCreateVariableResponseSchema,
});
//# sourceMappingURL=ExecuteCreateVariableDefinition.js.map