"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetTestRunScreenshotsToolDefinition = exports.getTestRunScreenshotsResponseSchema = exports.getTestRunScreenshotsParamsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var agentToolNames_js_1 = require("./agentToolNames.js");
/**
 * GetTestRunScreenshotsDefinition - Tool definition for fetching screenshots from a test run.
 */
exports.getTestRunScreenshotsParamsSchema = zod_1.z.object({
    test_run_id: zod_1.z.string().meta({
        description: 'Required. Test run ID to fetch screenshots from.',
    }),
    step_indices: zod_1.z
        .array(zod_1.z.number())
        .optional()
        .meta({
        // The `Failed Step Number` reference below mirrors the label rendered by
        // `server-agents/src/agent/artifacts/testRecoveryContextArtifact.ts` — keep them in sync.
        description: [
            'Specific step indices to get screenshots for.',
            "These are 0-based execution-order indices (flat across nested steps and loop iterations) \u2014 they match the `stepIndex` returned by `".concat(agentToolNames_js_1.AgentToolNames.GetTestRunInfo, "` and the `stepIndex` in this tool's response."),
            'They are NOT the user-facing dotted step numbers like "21" or "5.2" (that is `stepNumber`, and the same value also appears in the failure prompt as `Failed Step Number`).',
            "Prefer `step_id_in_flow` when you have the step's stable ID (e.g. from the failure prompt or a previous `".concat(agentToolNames_js_1.AgentToolNames.GetTestRunInfo, "` call), especially when comparing screenshots across runs."),
            'If not specified, uses step_start_index and step_end_index.',
        ].join(' '),
    }),
    step_start_index: zod_1.z
        .number()
        .optional()
        .meta({
        description: [
            'Start of an execution-order step range (0-based, inclusive).',
            'Same index space as `step_indices` — NOT the dotted step number.',
            'Used if step_indices not specified. Default: 0',
        ].join(' '),
    }),
    step_end_index: zod_1.z
        .number()
        .optional()
        .meta({
        description: [
            'End of an execution-order step range (0-based, inclusive).',
            'Same index space as `step_indices` — NOT the dotted step number.',
            'Used if step_indices not specified. Default: last step',
        ].join(' '),
    }),
    step_run_ids: zod_1.z.array(zod_1.z.string()).optional().meta({
        description: 'Filter screenshots by step_run_id. Takes precedence over all other filter params.',
    }),
    step_id_in_flow: zod_1.z
        .array(zod_1.z.string())
        .optional()
        .meta({
        description: 'Filter screenshots by stable step ID (step_id_in_flow). ' +
            'Unlike step_run_id, this ID is stable across runs — the same step definition always has the same step_id_in_flow. ' +
            'Use this to find screenshots of a specific step from a previous run without needing to look up execution indices. ' +
            'Takes precedence over step_indices and index range params. Lower precedence than step_run_ids.',
    }),
    include_element_highlights: zod_1.z
        .boolean()
        .optional()
        .meta({
        description: 'Whether to draw element highlight overlays on screenshots that have bounding box data. ' +
            'Default: true. Set to false to get the original unmodified screenshots.',
    }),
});
var screenshotInfoSchema = zod_1.z.object({
    stepIndex: zod_1.z.number().meta({
        description: 'Execution-order step index (0-based). This matches the step indices from get_test_run_info. ' +
            'For looped flows, each iteration has unique indices.',
    }),
    stepNumber: zod_1.z.string().meta({
        description: 'Human-readable step number with dotted notation for nested steps (1-based). ' +
            'Examples: "5" for step 5, "3.2" for step 2 inside step group at position 3. ' +
            'Use this for display purposes instead of computing from stepIndex/nestedStepPath.',
    }),
    nestedStepPath: zod_1.z
        .array(zod_1.z.number())
        .optional()
        .meta({
        description: 'Path of step indices for nested steps. Format: [flow_index, step_index_in_flow, ...]. ' +
            'Example: [2, 1] means this step is within flow at index 2, and is step 1 within that flow. ' +
            'For step groups: [flow_index, step_group_index, step_in_group]. ' +
            'Empty or undefined for top-level steps in the main flow.',
    }),
    flowRunIndex: zod_1.z
        .number()
        .optional()
        .meta({
        description: 'For flows that execute multiple times (loops), the 0-based loop iteration (0=first, 1=second, etc). ' +
            'Only present if the flow ran more than once.',
    }),
    stepDescription: zod_1.z.string().meta({ description: 'Step description' }),
    screenshotUrl: zod_1.z.string().optional().meta({
        description: 'URL to the screenshot (gs:// format).',
    }),
    mediaType: zod_1.z.string().meta({ description: 'Media type of the screenshot' }),
    stepId: zod_1.z.string().optional().meta({
        description: 'Stable step identifier within the flow. Cross-reference with get_test_run_info step data.',
    }),
    stepRunId: zod_1.z.string().optional().meta({
        description: 'Unique identifier for this specific step execution instance.',
    }),
    hasElementHighlight: zod_1.z.boolean().meta({
        description: 'When true, the screenshot image has an orange (#FD812A) bounding box outline drawn around ' +
            'the element that was interacted with during this step (clicks, text entry, etc.).',
    }),
});
exports.getTestRunScreenshotsResponseSchema = zod_1.z.object({
    screenshots: zod_1.z.array(screenshotInfoSchema).meta({ description: 'List of screenshots with metadata' }),
    totalAvailable: zod_1.z.number().meta({ description: 'Total number of screenshots available in the test run' }),
    note: zod_1.z.string().optional().meta({ description: 'Any notes about the response, e.g., if screenshots were truncated' }),
});
exports.GetTestRunScreenshotsToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: agentToolNames_js_1.AgentToolNames.GetTestRunScreenshots,
    description: "Retrieves screenshots from a test run for visual analysis.\n\nUse this tool to:\n- View what the application looked like at specific steps\n- Analyze visual differences or issues\n- Understand the state of the UI when failures occurred\n- Compare screenshots from different steps\n\nYou can request screenshots by:\n- Specific step execution IDs (step_run_ids) - most precise, from get_test_run_info results\n- Stable step IDs (step_id_in_flow) - same step definition across runs, from get_test_run_info or get_test_run_screenshots results\n- Specific step indices (step_indices) - use execution-order indices from get_test_run_info\n- A range of steps (step_start_index to step_end_index)\n\nBest practices:\n- First use get_test_run_info to see all steps and identify the failed/important ones\n- Request only the steps you need to analyze (e.g., failed step, steps around the failure)\n\nThe tool returns:\n- Screenshot metadata for each step (step index, description, loop info)\n- Actual image data for you to analyze visually",
    argumentsSchema: exports.getTestRunScreenshotsParamsSchema,
    responseSchema: exports.getTestRunScreenshotsResponseSchema,
});
//# sourceMappingURL=GetTestRunScreenshotsDefinition.js.map