import { z } from 'zod';
import { defineTool, } from '../toolDefinition.js';
import { AgentToolNames } from '../shared/agentToolNames.js';
import { TOOL_ELEMENT_DESCRIPTION_INSTRUCTIONS } from '../shared/constants.js';
export const executeEnterAuthCodeArgumentsSchema = z.object({
    description: z.string().max(100).describe('A brief description of what this step does (max 100 characters)'),
    elementDescription: z.string().meta({
        description: TOOL_ELEMENT_DESCRIPTION_INSTRUCTIONS,
    }),
    reasoning: z
        .string()
        .optional()
        .describe('Brief explanation of why this action is being taken and what it aims to achieve'),
});
export const executeEnterAuthCodeServerResultSchema = z.object({
    elementDescription: z.string(),
    elementBoundingBox: z.object({
        top: z.number(),
        left: z.number(),
        bottom: z.number(),
        right: z.number(),
    }),
    elementTargetPoint: z.object({
        x: z.number(),
        y: z.number(),
    }),
});
/**
 * Response schema for execute_enter_auth_code tool.
 * The auth code value is fetched at run time from the test's configured credential — the agent
 * never sees or supplies the code. The client should include the new screenshot and current URL
 * after typing because the auth-code submission frequently navigates.
 */
export const executeEnterAuthCodeClientResponseSchema = z.object({
    success: z.boolean(),
    message: z.string().optional(),
    new_screenshot: z.string().optional().meta({
        description: 'Base64-encoded PNG screenshot of the page after entering the authentication code',
    }),
    current_url: z.string().optional().meta({
        description: 'The current URL after the action (auth-code entry frequently submits the form)',
    }),
});
export const ExecuteEnterAuthCodeToolDefinition = defineTool({
    name: AgentToolNames.ExecuteEnterAuthCode,
    description: 'Records an "enter authentication code" step that types a TOTP (time-based one-time password) into the specified input at run time. ' +
        "The code is fetched from the test's configured credential during execution — the agent does NOT supply or see the code. " +
        'Use ONLY when the application is showing an MFA / authenticator-app prompt (e.g., "Enter the 6-digit code from your authenticator app"). ' +
        'Precondition: the test must have a credential of type basic_with_totp configured for run-time success. ' +
        'If the auth code is split across multiple inputs (common 6-digit pattern), call this tool once per input, left to right. ' +
        `For ordinary password fields, use ${AgentToolNames.ExecuteEnterText} — not this tool.`,
    argumentsSchema: executeEnterAuthCodeArgumentsSchema,
    serverPrepareResultSchema: executeEnterAuthCodeServerResultSchema,
    responseSchema: executeEnterAuthCodeClientResponseSchema,
});
//# sourceMappingURL=ExecuteEnterAuthCodeDefinition.js.map