import { z } from 'zod';
import { defineTool, } from '../toolDefinition.js';
import { AgentToolNames } from './agentToolNames.js';
export const executeScrollArgumentsSchema = z.object({
    description: z
        .string()
        .max(100)
        .optional()
        .describe('A brief description of what this step does (max 100 characters)'),
    reasoning: z
        .string()
        .optional()
        .describe('Brief explanation of why this action is being taken and what it aims to achieve'),
    direction: z.string().meta({
        description: '"up" or "down" to scroll in the desired direction',
    }),
    sectionDescription: z.string().optional().meta({
        description: 'If provided, scrolls the specific section with this description instead of the page. This is useful for cases where pages have sections that are independently scrollable such as a modal or side menu. It is generally better to be more specific than less on what to scroll.',
    }),
    scrollFactor: z.number().optional().meta({
        description: 'Controls how much of the viewport height to scroll per action (0.0 to 1.0). Default is 0.75. Use the default at first, but consider using a smaller value (e.g., 0.25-0.5) for finer scrolling if you need more precise positioning, or a larger value (e.g., 0.9-1.0) if you need to scroll through more content quickly after a previous scroll was insufficient.',
    }),
});
export const executeScrollServerResultSchema = z.object({
    direction: z.string(),
    scrollFactor: z.number(),
    sectionDescription: z.string().optional(),
    elementBoundingBox: z
        .object({
        top: z.number(),
        left: z.number(),
        bottom: z.number(),
        right: z.number(),
    })
        .optional(),
    elementTargetPoint: z
        .object({
        x: z.number(),
        y: z.number(),
    })
        .optional(),
});
/**
 * Response schema for execute_scroll tool.
 * The client should include the new screenshot after the scroll action
 * to show newly visible content.
 */
export const executeScrollClientResponseSchema = z.object({
    success: z.boolean(),
    message: z.string().optional(),
    // Context fields - client should include these after executing the action
    new_screenshot: z.string().optional().meta({
        description: 'Base64-encoded PNG screenshot of the page after scrolling',
    }),
    current_url: z.string().optional().meta({
        description: 'The current URL (may change if scrolling triggers lazy loading or hash changes)',
    }),
});
export const ExecuteScrollToolDefinition = defineTool({
    name: AgentToolNames.ExecuteScroll,
    description: 'Scrolls the application in the desired direction. The client response will include a new screenshot showing the newly visible content. ' +
        'Scrolling is not saved as a test step; replay auto-scrolls to elements on find. ' +
        'If a visual assertion depends on scroll position, record an execute_javascript scroll (e.g. window.scrollTo) before it.',
    argumentsSchema: executeScrollArgumentsSchema,
    serverPrepareResultSchema: executeScrollServerResultSchema,
    responseSchema: executeScrollClientResponseSchema,
});
//# sourceMappingURL=ExecuteScrollDefinition.js.map